feat(session): validate agents and browse workspace directories

This commit is contained in:
weishu
2026-08-25 16:12:29 +08:00
parent a04275b51d
commit e5a8212f4a
77 changed files with 3409 additions and 312 deletions
+23 -1
View File
@@ -130,7 +130,12 @@ export type MachinesResponse = { machines: Machine[] }
export type SpawnResponse =
| { type: 'success'; sessionId: string }
| { type: 'error'; message: string }
| {
type: 'error'
message: string
code?: 'agent_unavailable' | 'runner_upgrade_required' | 'outside_workspace_roots'
agent?: z.infer<typeof AgentFlavorSchema>
}
export const SessionPermissionModeRequestSchema = z.object({
mode: PermissionModeSchema
@@ -633,6 +638,21 @@ export const MachinePathsExistsRequestSchema = z.object({
export type MachinePathsExistsRequest = z.infer<typeof MachinePathsExistsRequestSchema>
export const AgentAvailabilityReasonSchema = z.enum(['not_found', 'invalid_configuration'])
export type AgentAvailabilityReason = z.infer<typeof AgentAvailabilityReasonSchema>
export const AgentAvailabilityEntrySchema = z.object({
agent: AgentFlavorSchema,
available: z.boolean(),
reason: AgentAvailabilityReasonSchema.optional()
})
export type AgentAvailabilityEntry = z.infer<typeof AgentAvailabilityEntrySchema>
export const AgentAvailabilityResponseSchema = z.object({
agents: z.array(AgentAvailabilityEntrySchema)
})
export type AgentAvailabilityResponse = z.infer<typeof AgentAvailabilityResponseSchema>
export const AuthRequestSchema = z.union([
z.object({ initData: z.string() }),
z.object({ accessToken: z.string() })
@@ -716,6 +736,8 @@ export type MachineListDirectoryResponse = {
export type PathExistsResponse = {
exists: Record<string, boolean>
/** Requested paths rejected by the runner's configured workspace roots. */
outsideWorkspaceRoots?: string[]
}
export type MachinePathsExistsResponse = PathExistsResponse