feat: create new session with yolo mode (#13)

* feat: create new session with yolo mode

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* fix: harden sequence typecheck

* feat: add unified --yolo flag across all agents

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: weishu <twsxtd@gmail.com>
This commit is contained in:
Ruihang Xia
2025-12-27 21:03:34 +08:00
committed by GitHub
co-authored by weishu
parent 126c5e483c
commit 58e61b3db9
12 changed files with 115 additions and 19 deletions
+7 -2
View File
@@ -652,10 +652,15 @@ export class SyncEngine {
async spawnSession(
machineId: string,
directory: string,
agent: 'claude' | 'codex' | 'gemini' = 'claude'
agent: 'claude' | 'codex' | 'gemini' = 'claude',
yolo?: boolean
): Promise<{ type: 'success'; sessionId: string } | { type: 'error'; message: string }> {
try {
const result = await this.machineRpc(machineId, 'spawn-happy-session', { type: 'spawn-in-directory', directory, agent })
const result = await this.machineRpc(
machineId,
'spawn-happy-session',
{ type: 'spawn-in-directory', directory, agent, yolo }
)
if (result && typeof result === 'object') {
const obj = result as Record<string, unknown>
if (obj.type === 'success' && typeof obj.sessionId === 'string') {
+8 -2
View File
@@ -5,7 +5,8 @@ import type { WebAppEnv } from '../middleware/auth'
const spawnBodySchema = z.object({
directory: z.string().min(1),
agent: z.enum(['claude', 'codex', 'gemini']).optional()
agent: z.enum(['claude', 'codex', 'gemini']).optional(),
yolo: z.boolean().optional()
})
export function createMachinesRoutes(getSyncEngine: () => SyncEngine | null): Hono<WebAppEnv> {
@@ -39,7 +40,12 @@ export function createMachinesRoutes(getSyncEngine: () => SyncEngine | null): Ho
return c.json({ error: 'Invalid body' }, 400)
}
const result = await engine.spawnSession(machineId, parsed.data.directory, parsed.data.agent)
const result = await engine.spawnSession(
machineId,
parsed.data.directory,
parsed.data.agent,
parsed.data.yolo
)
return c.json(result)
})