Unify agent flavor definitions

This commit is contained in:
weishu
2026-05-21 10:23:57 +08:00
parent 15113668cc
commit 9698aa9f4c
11 changed files with 27 additions and 18 deletions
+3 -5
View File
@@ -7,7 +7,7 @@
* - No E2E encryption; data is stored as JSON in SQLite
*/
import type { LocalResumeTarget, ResumableSession } from '@hapi/protocol'
import { isKnownFlavor, type LocalResumeTarget, type ResumableSession } from '@hapi/protocol'
import type { AgentFlavor, CodexCollaborationMode, DecryptedMessage, PermissionMode, Session, SyncEvent } from '@hapi/protocol/types'
import { unwrapRoleWrappedRecordEnvelope } from '@hapi/protocol/messages'
import type { Server } from 'socket.io'
@@ -459,7 +459,7 @@ export class SyncEngine {
async spawnSession(
machineId: string,
directory: string,
agent: 'claude' | 'codex' | 'cursor' | 'gemini' | 'opencode' = 'claude',
agent: AgentFlavor = 'claude',
model?: string,
modelReasoningEffort?: string,
yolo?: boolean,
@@ -486,9 +486,7 @@ export class SyncEngine {
private resolveFlavor(session: Session): AgentFlavor {
const flavor = session.metadata?.flavor
return flavor === 'codex' || flavor === 'gemini' || flavor === 'opencode' || flavor === 'cursor'
? flavor
: 'claude'
return isKnownFlavor(flavor) ? flavor : 'claude'
}
private resolveAgentResumeId(session: Session, namespace: string): string | null {