mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
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:
@@ -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') {
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user