mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(codex): import and resume sessions from runners (#1088)
* fix codex import resume flow * fix hub restart session active state * fix codex transcript workspace scoping * Address Codex import review findings * Fix Codex import machine selection * Update Codex sessions error test * Address Codex import review findings * Preserve forked Codex session id on sync * Make Codex duplicate cleanup source-aware * Handle Codex archive failures * Limit existing session flag to Codex * Preserve Codex import machine binding * fix: rebase runner Codex import onto current main * fix: preserve runner-scoped Codex import behavior --------- Co-authored-by: syy <815728149@qq.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
type RpcGeneratedImageResponse,
|
||||
type RpcListDirectoryResponse,
|
||||
type RpcListCodexModelsResponse,
|
||||
type RpcArchiveCodexSessionResponse,
|
||||
type RpcListCursorModelsResponse,
|
||||
type RpcListOpencodeModelsResponse,
|
||||
type RpcListGrokModelsResponse,
|
||||
@@ -807,7 +808,8 @@ export class SyncEngine {
|
||||
resumeSessionId?: string,
|
||||
effort?: string,
|
||||
permissionMode?: PermissionMode,
|
||||
serviceTier?: string
|
||||
serviceTier?: string,
|
||||
existingSessionId?: string
|
||||
): Promise<{ type: 'success'; sessionId: string } | { type: 'error'; message: string }> {
|
||||
return await this.rpcGateway.spawnSession(
|
||||
machineId,
|
||||
@@ -821,7 +823,8 @@ export class SyncEngine {
|
||||
resumeSessionId,
|
||||
effort,
|
||||
permissionMode,
|
||||
serviceTier
|
||||
serviceTier,
|
||||
existingSessionId
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1274,9 +1277,12 @@ export class SyncEngine {
|
||||
}
|
||||
}
|
||||
|
||||
const preferredPermissionMode = opts?.permissionMode
|
||||
?? session.permissionMode
|
||||
?? session.metadata?.preferredPermissionMode
|
||||
const metadataPermissionMode = session.metadata?.preferredPermissionMode
|
||||
const preferredPermissionMode = metadataPermissionMode === 'yolo' && opts?.permissionMode === 'default'
|
||||
? metadataPermissionMode
|
||||
: opts?.permissionMode
|
||||
?? session.permissionMode
|
||||
?? metadataPermissionMode
|
||||
const spawnResult = await this.rpcGateway.spawnSession(
|
||||
targetMachine.id,
|
||||
directory,
|
||||
@@ -1289,7 +1295,8 @@ export class SyncEngine {
|
||||
resumeToken,
|
||||
session.effort ?? undefined,
|
||||
preferredPermissionMode,
|
||||
session.serviceTier ?? undefined
|
||||
session.serviceTier ?? undefined,
|
||||
access.sessionId
|
||||
)
|
||||
|
||||
if (spawnResult.type !== 'success') {
|
||||
@@ -1332,6 +1339,7 @@ export class SyncEngine {
|
||||
}
|
||||
}
|
||||
|
||||
this.sessionCache.markSessionActive(spawnResult.sessionId)
|
||||
return { type: 'success', sessionId: spawnResult.sessionId }
|
||||
}
|
||||
|
||||
@@ -1690,6 +1698,14 @@ export class SyncEngine {
|
||||
return await this.rpcGateway.listCodexModelsForMachine(machineId)
|
||||
}
|
||||
|
||||
async listCodexSessionsForMachine(machineId: string, cwd?: string | null, sessionIds?: string[]) {
|
||||
return await this.rpcGateway.listCodexSessionsForMachine(machineId, cwd, sessionIds)
|
||||
}
|
||||
|
||||
async archiveCodexSessionForMachine(machineId: string, sessionId: string): Promise<RpcArchiveCodexSessionResponse> {
|
||||
return await this.rpcGateway.archiveCodexSessionForMachine(machineId, sessionId)
|
||||
}
|
||||
|
||||
async listCursorModelsForSession(sessionId: string): Promise<RpcListCursorModelsResponse> {
|
||||
return await this.rpcGateway.listCursorModelsForSession(sessionId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user