Files
hapi/shared/src/resume.ts
T
wushenghua baeeb11356 fix: preserve deployed session fixes
Persist paged Codex history checkpoints and bounded, acknowledged delivery.
Keep usage sources and accounting across deleted or merged sessions.
Include native Goal controls, faster peer/session queries, and release guards.
Track the complete deployed source so isolated builds cannot omit local fixes.

Validation: all typechecks pass. The full suite reports 7,997 passing tests
and 46 existing failures, each reproduced against the prior commit.
2026-10-08 19:51:45 +08:00

57 lines
2.0 KiB
TypeScript

import { z } from 'zod'
import { CodexCollaborationModeSchema, CopilotAgentModeSchema, PermissionModeSchema } from './schemas'
import { AgentFlavorSchema, type AgentFlavor } from './modes'
/** Cold Codex resumes can spend substantially longer loading native thread state. */
export function sessionStartupTimeoutMs(flavor?: AgentFlavor, resumeSessionId?: string): number {
return flavor === 'codex' && resumeSessionId ? 120_000 : 15_000
}
export const LocalResumeTargetSchema = z.object({
sessionId: z.string().min(1),
flavor: AgentFlavorSchema,
directory: z.string().min(1),
machineId: z.string().optional(),
host: z.string().optional(),
active: z.boolean(),
thinking: z.boolean(),
controlledByUser: z.boolean(),
agentSessionId: z.string().min(1),
model: z.string().nullable().optional(),
effort: z.string().nullable().optional(),
modelReasoningEffort: z.string().nullable().optional(),
serviceTier: z.string().nullable().optional(),
permissionMode: PermissionModeSchema.optional(),
collaborationMode: CodexCollaborationModeSchema.optional(),
copilotAgentMode: CopilotAgentModeSchema.optional()
})
export type LocalResumeTarget = z.infer<typeof LocalResumeTargetSchema>
export const ResumableSessionSchema = LocalResumeTargetSchema.extend({
updatedAt: z.number(),
name: z.string().optional(),
summary: z.string().optional(),
firstUserMessage: z.string().optional()
})
export type ResumableSession = z.infer<typeof ResumableSessionSchema>
export const LocalResumeTargetResponseSchema = z.object({
target: LocalResumeTargetSchema
})
export type LocalResumeTargetResponse = z.infer<typeof LocalResumeTargetResponseSchema>
export const ResumableSessionsResponseSchema = z.object({
sessions: z.array(ResumableSessionSchema)
})
export type ResumableSessionsResponse = z.infer<typeof ResumableSessionsResponseSchema>
export const LocalHandoffResponseSchema = z.object({
ok: z.boolean()
})
export type LocalHandoffResponse = z.infer<typeof LocalHandoffResponseSchema>