@getpaseo/server 0.1.67 → 0.1.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scripts/dev-runner.js +4 -1
- package/dist/scripts/dev-runner.js.map +1 -1
- package/dist/scripts/supervisor-entrypoint.js +32 -10
- package/dist/scripts/supervisor-entrypoint.js.map +1 -1
- package/dist/scripts/supervisor.js +71 -6
- package/dist/scripts/supervisor.js.map +1 -1
- package/dist/server/server/agent/agent-storage.d.ts +2 -2
- package/dist/server/server/agent/mcp-server.js +1 -1
- package/dist/server/server/agent/mcp-server.js.map +1 -1
- package/dist/server/server/agent/mcp-shared.d.ts +2 -2
- package/dist/server/server/agent/providers/claude-agent.d.ts +2 -1
- package/dist/server/server/agent/providers/claude-agent.d.ts.map +1 -1
- package/dist/server/server/agent/providers/claude-agent.js +46 -1
- package/dist/server/server/agent/providers/claude-agent.js.map +1 -1
- package/dist/server/server/bootstrap.d.ts +2 -0
- package/dist/server/server/bootstrap.d.ts.map +1 -1
- package/dist/server/server/bootstrap.js +0 -8
- package/dist/server/server/bootstrap.js.map +1 -1
- package/dist/server/server/chat/chat-rpc-schemas.d.ts +42 -42
- package/dist/server/server/chat/chat-types.d.ts +6 -6
- package/dist/server/server/config.d.ts.map +1 -1
- package/dist/server/server/config.js +20 -1
- package/dist/server/server/config.js.map +1 -1
- package/dist/server/server/daemon-worker.d.ts +2 -0
- package/dist/server/server/daemon-worker.d.ts.map +1 -0
- package/dist/server/server/{index.js → daemon-worker.js} +10 -41
- package/dist/server/server/daemon-worker.js.map +1 -0
- package/dist/server/server/logger.d.ts +2 -6
- package/dist/server/server/logger.d.ts.map +1 -1
- package/dist/server/server/logger.js +28 -118
- package/dist/server/server/logger.js.map +1 -1
- package/dist/server/server/loop/rpc-schemas.d.ts +272 -272
- package/dist/server/server/loop-service.d.ts +50 -50
- package/dist/server/server/persisted-config.d.ts +18 -16
- package/dist/server/server/persisted-config.d.ts.map +1 -1
- package/dist/server/server/persisted-config.js +2 -2
- package/dist/server/server/persisted-config.js.map +1 -1
- package/dist/server/server/schedule/rpc-schemas.d.ts +52 -52
- package/dist/server/server/schedule/types.d.ts +12 -12
- package/dist/server/shared/messages.d.ts +3073 -3073
- package/dist/server/terminal/terminal-capture.d.ts +12 -0
- package/dist/server/terminal/terminal-capture.d.ts.map +1 -0
- package/dist/server/terminal/terminal-capture.js +43 -0
- package/dist/server/terminal/terminal-capture.js.map +1 -0
- package/dist/server/terminal/terminal-manager-factory.d.ts +2 -6
- package/dist/server/terminal/terminal-manager-factory.d.ts.map +1 -1
- package/dist/server/terminal/terminal-manager-factory.js +2 -10
- package/dist/server/terminal/terminal-manager-factory.js.map +1 -1
- package/dist/server/terminal/terminal-worker-process.js +1 -1
- package/dist/server/terminal/terminal-worker-process.js.map +1 -1
- package/dist/server/terminal/terminal-worker-protocol.d.ts +1 -1
- package/dist/server/terminal/terminal-worker-protocol.d.ts.map +1 -1
- package/dist/server/terminal/terminal.d.ts +1 -11
- package/dist/server/terminal/terminal.d.ts.map +1 -1
- package/dist/server/terminal/terminal.js +1 -42
- package/dist/server/terminal/terminal.js.map +1 -1
- package/dist/server/utils/worktree.d.ts.map +1 -1
- package/dist/server/utils/worktree.js +18 -43
- package/dist/server/utils/worktree.js.map +1 -1
- package/dist/src/server/agent/agent-sdk-types.js +12 -0
- package/dist/src/server/agent/agent-sdk-types.js.map +1 -0
- package/dist/src/server/agent/agent-title-limits.js +3 -0
- package/dist/src/server/agent/agent-title-limits.js.map +1 -0
- package/dist/src/server/agent/provider-launch-config.js +189 -0
- package/dist/src/server/agent/provider-launch-config.js.map +1 -0
- package/dist/src/server/agent/provider-manifest.js +186 -0
- package/dist/src/server/agent/provider-manifest.js.map +1 -0
- package/dist/src/server/chat/chat-rpc-schemas.js +103 -0
- package/dist/src/server/chat/chat-rpc-schemas.js.map +1 -0
- package/dist/src/server/chat/chat-types.js +22 -0
- package/dist/src/server/chat/chat-types.js.map +1 -0
- package/dist/src/server/loop/rpc-schemas.js +159 -0
- package/dist/src/server/loop/rpc-schemas.js.map +1 -0
- package/dist/src/server/paseo-env.js +70 -0
- package/dist/src/server/paseo-env.js.map +1 -0
- package/dist/src/server/persisted-config.js +362 -0
- package/dist/src/server/persisted-config.js.map +1 -0
- package/dist/src/server/schedule/rpc-schemas.js +112 -0
- package/dist/src/server/schedule/rpc-schemas.js.map +1 -0
- package/dist/src/server/schedule/types.js +73 -0
- package/dist/src/server/schedule/types.js.map +1 -0
- package/dist/src/shared/agent-lifecycle.js +8 -0
- package/dist/src/shared/agent-lifecycle.js.map +1 -0
- package/dist/src/shared/client-capabilities.js +4 -0
- package/dist/src/shared/client-capabilities.js.map +1 -0
- package/dist/src/shared/literal-union.js +2 -0
- package/dist/src/shared/literal-union.js.map +1 -0
- package/dist/src/shared/messages.js +3022 -0
- package/dist/src/shared/messages.js.map +1 -0
- package/dist/src/utils/executable.js +114 -0
- package/dist/src/utils/executable.js.map +1 -0
- package/dist/src/utils/paseo-config-schema.js +60 -0
- package/dist/src/utils/paseo-config-schema.js.map +1 -0
- package/dist/src/utils/spawn.js +70 -0
- package/dist/src/utils/spawn.js.map +1 -0
- package/dist/src/utils/windows-command.js +41 -0
- package/dist/src/utils/windows-command.js.map +1 -0
- package/package.json +5 -5
- package/dist/server/server/index.d.ts +0 -2
- package/dist/server/server/index.d.ts.map +0 -1
- package/dist/server/server/index.js.map +0 -1
|
@@ -0,0 +1,3022 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CLIENT_CAPS } from "./client-capabilities.js";
|
|
3
|
+
import { AGENT_LIFECYCLE_STATUSES } from "./agent-lifecycle.js";
|
|
4
|
+
import { MAX_EXPLICIT_AGENT_TITLE_CHARS } from "../server/agent/agent-title-limits.js";
|
|
5
|
+
import { AgentProviderSchema } from "../server/agent/provider-manifest.js";
|
|
6
|
+
import { TOOL_CALL_ICON_NAMES } from "../server/agent/agent-sdk-types.js";
|
|
7
|
+
import { ChatCreateRequestSchema, ChatListRequestSchema, ChatInspectRequestSchema, ChatDeleteRequestSchema, ChatPostRequestSchema, ChatReadRequestSchema, ChatWaitRequestSchema, ChatCreateResponseSchema, ChatListResponseSchema, ChatInspectResponseSchema, ChatDeleteResponseSchema, ChatPostResponseSchema, ChatReadResponseSchema, ChatWaitResponseSchema, } from "../server/chat/chat-rpc-schemas.js";
|
|
8
|
+
import { ScheduleCreateRequestSchema, ScheduleListRequestSchema, ScheduleInspectRequestSchema, ScheduleLogsRequestSchema, SchedulePauseRequestSchema, ScheduleResumeRequestSchema, ScheduleDeleteRequestSchema, ScheduleCreateResponseSchema, ScheduleListResponseSchema, ScheduleInspectResponseSchema, ScheduleLogsResponseSchema, SchedulePauseResponseSchema, ScheduleResumeResponseSchema, ScheduleDeleteResponseSchema, } from "../server/schedule/rpc-schemas.js";
|
|
9
|
+
import { LoopRunRequestSchema, LoopListRequestSchema, LoopInspectRequestSchema, LoopLogsRequestSchema, LoopStopRequestSchema, LoopRunResponseSchema, LoopListResponseSchema, LoopInspectResponseSchema, LoopLogsResponseSchema, LoopStopResponseSchema, } from "../server/loop/rpc-schemas.js";
|
|
10
|
+
import { PaseoConfigRawSchema, PaseoLifecycleCommandRawSchema, PaseoScriptEntryRawSchema, PaseoWorktreeConfigRawSchema, PaseoConfigRevisionSchema, ProjectConfigRpcErrorSchema, } from "../utils/paseo-config-schema.js";
|
|
11
|
+
export { PaseoConfigRawSchema, PaseoLifecycleCommandRawSchema, PaseoScriptEntryRawSchema, PaseoWorktreeConfigRawSchema, };
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Mutable daemon config schemas (shared between server store and client)
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
const MutableDaemonProviderModelSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
id: z.string().min(1),
|
|
18
|
+
label: z.string().min(1),
|
|
19
|
+
description: z.string().optional(),
|
|
20
|
+
isDefault: z.boolean().optional(),
|
|
21
|
+
})
|
|
22
|
+
.passthrough();
|
|
23
|
+
const MutableDaemonProviderConfigSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
enabled: z.boolean().optional(),
|
|
26
|
+
additionalModels: z.array(MutableDaemonProviderModelSchema).optional(),
|
|
27
|
+
})
|
|
28
|
+
.passthrough();
|
|
29
|
+
export const MutableDaemonConfigSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
mcp: z
|
|
32
|
+
.object({
|
|
33
|
+
injectIntoAgents: z.boolean(),
|
|
34
|
+
})
|
|
35
|
+
.passthrough(),
|
|
36
|
+
providers: z.record(z.string(), MutableDaemonProviderConfigSchema).default({}),
|
|
37
|
+
})
|
|
38
|
+
.passthrough();
|
|
39
|
+
export const MutableDaemonConfigPatchSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
mcp: MutableDaemonConfigSchema.shape.mcp.partial().optional(),
|
|
42
|
+
providers: z
|
|
43
|
+
.record(z.string(), MutableDaemonProviderConfigSchema.partial().passthrough())
|
|
44
|
+
.optional(),
|
|
45
|
+
})
|
|
46
|
+
.partial()
|
|
47
|
+
.passthrough();
|
|
48
|
+
export const AgentStatusSchema = z.enum(AGENT_LIFECYCLE_STATUSES);
|
|
49
|
+
const AgentModeSchema = z.object({
|
|
50
|
+
id: z.string(),
|
|
51
|
+
label: z.string(),
|
|
52
|
+
description: z.string().optional(),
|
|
53
|
+
icon: z.string().optional(),
|
|
54
|
+
colorTier: z.string().optional(),
|
|
55
|
+
});
|
|
56
|
+
const ProviderStatusSchema = z.enum([
|
|
57
|
+
"ready",
|
|
58
|
+
"loading",
|
|
59
|
+
"error",
|
|
60
|
+
"unavailable",
|
|
61
|
+
]);
|
|
62
|
+
const AgentSelectOptionSchema = z.object({
|
|
63
|
+
id: z.string(),
|
|
64
|
+
label: z.string(),
|
|
65
|
+
description: z.string().optional(),
|
|
66
|
+
isDefault: z.boolean().optional(),
|
|
67
|
+
metadata: z.record(z.unknown()).optional(),
|
|
68
|
+
});
|
|
69
|
+
export const AgentFeatureToggleSchema = z.object({
|
|
70
|
+
type: z.literal("toggle"),
|
|
71
|
+
id: z.string(),
|
|
72
|
+
label: z.string(),
|
|
73
|
+
description: z.string().optional(),
|
|
74
|
+
tooltip: z.string().optional(),
|
|
75
|
+
icon: z.string().optional(),
|
|
76
|
+
value: z.boolean(),
|
|
77
|
+
});
|
|
78
|
+
export const AgentFeatureSelectSchema = z.object({
|
|
79
|
+
type: z.literal("select"),
|
|
80
|
+
id: z.string(),
|
|
81
|
+
label: z.string(),
|
|
82
|
+
description: z.string().optional(),
|
|
83
|
+
tooltip: z.string().optional(),
|
|
84
|
+
icon: z.string().optional(),
|
|
85
|
+
value: z.string().nullable(),
|
|
86
|
+
options: z.array(AgentSelectOptionSchema),
|
|
87
|
+
});
|
|
88
|
+
export const AgentFeatureSchema = z.discriminatedUnion("type", [
|
|
89
|
+
AgentFeatureToggleSchema,
|
|
90
|
+
AgentFeatureSelectSchema,
|
|
91
|
+
]);
|
|
92
|
+
const AgentModelDefinitionSchema = z.object({
|
|
93
|
+
provider: AgentProviderSchema,
|
|
94
|
+
id: z.string(),
|
|
95
|
+
label: z.string(),
|
|
96
|
+
description: z.string().optional(),
|
|
97
|
+
isDefault: z.boolean().optional(),
|
|
98
|
+
metadata: z.record(z.unknown()).optional(),
|
|
99
|
+
thinkingOptions: z.array(AgentSelectOptionSchema).optional(),
|
|
100
|
+
defaultThinkingOptionId: z.string().optional(),
|
|
101
|
+
});
|
|
102
|
+
export const ProviderSnapshotEntrySchema = z.object({
|
|
103
|
+
provider: AgentProviderSchema,
|
|
104
|
+
status: ProviderStatusSchema,
|
|
105
|
+
enabled: z.boolean().optional().default(true),
|
|
106
|
+
error: z.string().optional(),
|
|
107
|
+
models: z.array(AgentModelDefinitionSchema).optional(),
|
|
108
|
+
modes: z.array(AgentModeSchema).optional(),
|
|
109
|
+
fetchedAt: z.string().optional(),
|
|
110
|
+
label: z.string().optional(),
|
|
111
|
+
description: z.string().optional(),
|
|
112
|
+
defaultModeId: z.string().nullable().optional(),
|
|
113
|
+
});
|
|
114
|
+
const AgentCapabilityFlagsSchema = z.object({
|
|
115
|
+
supportsStreaming: z.boolean(),
|
|
116
|
+
supportsSessionPersistence: z.boolean(),
|
|
117
|
+
supportsDynamicModes: z.boolean(),
|
|
118
|
+
supportsMcpServers: z.boolean(),
|
|
119
|
+
supportsReasoningStream: z.boolean(),
|
|
120
|
+
supportsToolInvocations: z.boolean(),
|
|
121
|
+
});
|
|
122
|
+
const AgentUsageSchema = z.object({
|
|
123
|
+
inputTokens: z.number().optional(),
|
|
124
|
+
cachedInputTokens: z.number().optional(),
|
|
125
|
+
outputTokens: z.number().optional(),
|
|
126
|
+
totalCostUsd: z.number().optional(),
|
|
127
|
+
contextWindowMaxTokens: z.number().optional(),
|
|
128
|
+
contextWindowUsedTokens: z.number().optional(),
|
|
129
|
+
});
|
|
130
|
+
const McpStdioServerConfigSchema = z.object({
|
|
131
|
+
type: z.literal("stdio"),
|
|
132
|
+
command: z.string(),
|
|
133
|
+
args: z.array(z.string()).optional(),
|
|
134
|
+
env: z.record(z.string()).optional(),
|
|
135
|
+
});
|
|
136
|
+
const McpHttpServerConfigSchema = z.object({
|
|
137
|
+
type: z.literal("http"),
|
|
138
|
+
url: z.string(),
|
|
139
|
+
headers: z.record(z.string()).optional(),
|
|
140
|
+
});
|
|
141
|
+
const McpSseServerConfigSchema = z.object({
|
|
142
|
+
type: z.literal("sse"),
|
|
143
|
+
url: z.string(),
|
|
144
|
+
headers: z.record(z.string()).optional(),
|
|
145
|
+
});
|
|
146
|
+
const McpServerConfigSchema = z.discriminatedUnion("type", [
|
|
147
|
+
McpStdioServerConfigSchema,
|
|
148
|
+
McpHttpServerConfigSchema,
|
|
149
|
+
McpSseServerConfigSchema,
|
|
150
|
+
]);
|
|
151
|
+
const AgentSessionConfigSchema = z.object({
|
|
152
|
+
provider: AgentProviderSchema,
|
|
153
|
+
cwd: z.string(),
|
|
154
|
+
modeId: z.string().optional(),
|
|
155
|
+
model: z.string().optional(),
|
|
156
|
+
thinkingOptionId: z.string().optional(),
|
|
157
|
+
featureValues: z.record(z.unknown()).optional(),
|
|
158
|
+
title: z.string().trim().min(1).max(MAX_EXPLICIT_AGENT_TITLE_CHARS).optional().nullable(),
|
|
159
|
+
approvalPolicy: z.string().optional(),
|
|
160
|
+
sandboxMode: z.string().optional(),
|
|
161
|
+
networkAccess: z.boolean().optional(),
|
|
162
|
+
webSearch: z.boolean().optional(),
|
|
163
|
+
extra: z
|
|
164
|
+
.object({
|
|
165
|
+
codex: z.record(z.unknown()).optional(),
|
|
166
|
+
claude: z.record(z.unknown()).optional(),
|
|
167
|
+
})
|
|
168
|
+
.partial()
|
|
169
|
+
.optional(),
|
|
170
|
+
systemPrompt: z.string().optional(),
|
|
171
|
+
mcpServers: z.record(McpServerConfigSchema).optional(),
|
|
172
|
+
});
|
|
173
|
+
const AgentPermissionUpdateSchema = z.record(z.unknown());
|
|
174
|
+
const AgentPermissionActionSchema = z.object({
|
|
175
|
+
id: z.string(),
|
|
176
|
+
label: z.string(),
|
|
177
|
+
behavior: z.enum(["allow", "deny"]),
|
|
178
|
+
variant: z.enum(["primary", "secondary", "danger"]).optional(),
|
|
179
|
+
intent: z.enum(["implement", "implement_resume", "dismiss"]).optional(),
|
|
180
|
+
});
|
|
181
|
+
export const AgentPermissionResponseSchema = z.union([
|
|
182
|
+
z.object({
|
|
183
|
+
behavior: z.literal("allow"),
|
|
184
|
+
selectedActionId: z.string().optional(),
|
|
185
|
+
updatedInput: z.record(z.unknown()).optional(),
|
|
186
|
+
updatedPermissions: z.array(AgentPermissionUpdateSchema).optional(),
|
|
187
|
+
}),
|
|
188
|
+
z.object({
|
|
189
|
+
behavior: z.literal("deny"),
|
|
190
|
+
selectedActionId: z.string().optional(),
|
|
191
|
+
message: z.string().optional(),
|
|
192
|
+
interrupt: z.boolean().optional(),
|
|
193
|
+
}),
|
|
194
|
+
]);
|
|
195
|
+
export const AgentPermissionRequestPayloadSchema = z.object({
|
|
196
|
+
id: z.string(),
|
|
197
|
+
provider: AgentProviderSchema,
|
|
198
|
+
name: z.string(),
|
|
199
|
+
kind: z.enum(["tool", "plan", "question", "mode", "other"]),
|
|
200
|
+
title: z.string().optional(),
|
|
201
|
+
description: z.string().optional(),
|
|
202
|
+
input: z.record(z.unknown()).optional(),
|
|
203
|
+
detail: z.lazy(() => ToolCallDetailPayloadSchema).optional(),
|
|
204
|
+
suggestions: z.array(AgentPermissionUpdateSchema).optional(),
|
|
205
|
+
actions: z.array(AgentPermissionActionSchema).optional(),
|
|
206
|
+
metadata: z.record(z.unknown()).optional(),
|
|
207
|
+
});
|
|
208
|
+
const UnknownValueSchema = z.union([
|
|
209
|
+
z.null(),
|
|
210
|
+
z.boolean(),
|
|
211
|
+
z.number(),
|
|
212
|
+
z.string(),
|
|
213
|
+
z.array(z.unknown()),
|
|
214
|
+
z.object({}).passthrough(),
|
|
215
|
+
]);
|
|
216
|
+
const NonNullUnknownSchema = z.union([
|
|
217
|
+
z.boolean(),
|
|
218
|
+
z.number(),
|
|
219
|
+
z.string(),
|
|
220
|
+
z.array(z.unknown()),
|
|
221
|
+
z.object({}).passthrough(),
|
|
222
|
+
]);
|
|
223
|
+
const WorktreeSetupCommandSnapshotSchema = z.object({
|
|
224
|
+
index: z.number().int().positive(),
|
|
225
|
+
command: z.string(),
|
|
226
|
+
cwd: z.string(),
|
|
227
|
+
log: z.string().optional().default(""),
|
|
228
|
+
status: z.enum(["running", "completed", "failed"]),
|
|
229
|
+
exitCode: z.number().nullable(),
|
|
230
|
+
durationMs: z.number().nonnegative().optional(),
|
|
231
|
+
});
|
|
232
|
+
const WorktreeSetupDetailPayloadSchema = z.object({
|
|
233
|
+
type: z.literal("worktree_setup"),
|
|
234
|
+
worktreePath: z.string(),
|
|
235
|
+
branchName: z.string(),
|
|
236
|
+
log: z.string(),
|
|
237
|
+
commands: z.array(WorktreeSetupCommandSnapshotSchema),
|
|
238
|
+
truncated: z.boolean().optional(),
|
|
239
|
+
});
|
|
240
|
+
const ToolCallDetailPayloadSchema = z.discriminatedUnion("type", [
|
|
241
|
+
WorktreeSetupDetailPayloadSchema,
|
|
242
|
+
z.object({
|
|
243
|
+
type: z.literal("shell"),
|
|
244
|
+
command: z.string(),
|
|
245
|
+
cwd: z.string().optional(),
|
|
246
|
+
output: z.string().optional(),
|
|
247
|
+
exitCode: z.number().nullable().optional(),
|
|
248
|
+
}),
|
|
249
|
+
z.object({
|
|
250
|
+
type: z.literal("read"),
|
|
251
|
+
filePath: z.string(),
|
|
252
|
+
content: z.string().optional(),
|
|
253
|
+
offset: z.number().optional(),
|
|
254
|
+
limit: z.number().optional(),
|
|
255
|
+
}),
|
|
256
|
+
z.object({
|
|
257
|
+
type: z.literal("edit"),
|
|
258
|
+
filePath: z.string(),
|
|
259
|
+
oldString: z.string().optional(),
|
|
260
|
+
newString: z.string().optional(),
|
|
261
|
+
unifiedDiff: z.string().optional(),
|
|
262
|
+
}),
|
|
263
|
+
z.object({
|
|
264
|
+
type: z.literal("write"),
|
|
265
|
+
filePath: z.string(),
|
|
266
|
+
content: z.string().optional(),
|
|
267
|
+
}),
|
|
268
|
+
z.object({
|
|
269
|
+
type: z.literal("search"),
|
|
270
|
+
query: z.string(),
|
|
271
|
+
toolName: z.enum(["search", "grep", "glob", "web_search"]).optional(),
|
|
272
|
+
content: z.string().optional(),
|
|
273
|
+
filePaths: z.array(z.string()).optional(),
|
|
274
|
+
webResults: z
|
|
275
|
+
.array(z.object({
|
|
276
|
+
title: z.string(),
|
|
277
|
+
url: z.string(),
|
|
278
|
+
}))
|
|
279
|
+
.optional(),
|
|
280
|
+
annotations: z.array(z.string()).optional(),
|
|
281
|
+
numFiles: z.number().optional(),
|
|
282
|
+
numMatches: z.number().optional(),
|
|
283
|
+
durationMs: z.number().optional(),
|
|
284
|
+
durationSeconds: z.number().optional(),
|
|
285
|
+
truncated: z.boolean().optional(),
|
|
286
|
+
mode: z.enum(["content", "files_with_matches", "count"]).optional(),
|
|
287
|
+
}),
|
|
288
|
+
z.object({
|
|
289
|
+
type: z.literal("fetch"),
|
|
290
|
+
url: z.string(),
|
|
291
|
+
prompt: z.string().optional(),
|
|
292
|
+
result: z.string().optional(),
|
|
293
|
+
code: z.number().optional(),
|
|
294
|
+
codeText: z.string().optional(),
|
|
295
|
+
bytes: z.number().optional(),
|
|
296
|
+
durationMs: z.number().optional(),
|
|
297
|
+
}),
|
|
298
|
+
z.object({
|
|
299
|
+
type: z.literal("sub_agent"),
|
|
300
|
+
subAgentType: z.string().optional(),
|
|
301
|
+
description: z.string().optional(),
|
|
302
|
+
childSessionId: z.string().optional(),
|
|
303
|
+
log: z.string(),
|
|
304
|
+
// Compat cruft for clients <= 0.1.65-beta.3 that required this field. Producers still
|
|
305
|
+
// emit `[]`; nothing reads it. Drop the field (and the `[]` emissions) once those
|
|
306
|
+
// clients are no longer in the field.
|
|
307
|
+
actions: z
|
|
308
|
+
.array(z.object({
|
|
309
|
+
index: z.number().int().positive(),
|
|
310
|
+
toolName: z.string(),
|
|
311
|
+
summary: z.string().optional(),
|
|
312
|
+
}))
|
|
313
|
+
.optional(),
|
|
314
|
+
}),
|
|
315
|
+
z.object({
|
|
316
|
+
type: z.literal("plain_text"),
|
|
317
|
+
label: z.string().optional(),
|
|
318
|
+
text: z.string().optional(),
|
|
319
|
+
icon: z.enum(TOOL_CALL_ICON_NAMES).optional(),
|
|
320
|
+
}),
|
|
321
|
+
z.object({
|
|
322
|
+
type: z.literal("plan"),
|
|
323
|
+
text: z.string(),
|
|
324
|
+
}),
|
|
325
|
+
z.object({
|
|
326
|
+
type: z.literal("unknown"),
|
|
327
|
+
input: UnknownValueSchema,
|
|
328
|
+
output: UnknownValueSchema,
|
|
329
|
+
}),
|
|
330
|
+
]);
|
|
331
|
+
const ToolCallBasePayloadSchema = z
|
|
332
|
+
.object({
|
|
333
|
+
type: z.literal("tool_call"),
|
|
334
|
+
callId: z.string(),
|
|
335
|
+
name: z.string(),
|
|
336
|
+
detail: ToolCallDetailPayloadSchema,
|
|
337
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
338
|
+
})
|
|
339
|
+
.strict();
|
|
340
|
+
const ToolCallRunningPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
341
|
+
status: z.literal("running"),
|
|
342
|
+
error: z.null(),
|
|
343
|
+
});
|
|
344
|
+
const ToolCallCompletedPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
345
|
+
status: z.literal("completed"),
|
|
346
|
+
error: z.null(),
|
|
347
|
+
});
|
|
348
|
+
const ToolCallFailedPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
349
|
+
status: z.literal("failed"),
|
|
350
|
+
error: NonNullUnknownSchema,
|
|
351
|
+
});
|
|
352
|
+
const ToolCallCanceledPayloadSchema = ToolCallBasePayloadSchema.extend({
|
|
353
|
+
status: z.literal("canceled"),
|
|
354
|
+
error: z.null(),
|
|
355
|
+
});
|
|
356
|
+
const ToolCallTimelineItemPayloadSchema = z.union([
|
|
357
|
+
ToolCallRunningPayloadSchema,
|
|
358
|
+
ToolCallCompletedPayloadSchema,
|
|
359
|
+
ToolCallFailedPayloadSchema,
|
|
360
|
+
ToolCallCanceledPayloadSchema,
|
|
361
|
+
]);
|
|
362
|
+
export const AgentTimelineItemPayloadSchema = z.union([
|
|
363
|
+
z.object({
|
|
364
|
+
type: z.literal("user_message"),
|
|
365
|
+
text: z.string(),
|
|
366
|
+
messageId: z.string().optional(),
|
|
367
|
+
}),
|
|
368
|
+
z.object({
|
|
369
|
+
type: z.literal("assistant_message"),
|
|
370
|
+
text: z.string(),
|
|
371
|
+
}),
|
|
372
|
+
z.object({
|
|
373
|
+
type: z.literal("reasoning"),
|
|
374
|
+
text: z.string(),
|
|
375
|
+
}),
|
|
376
|
+
ToolCallTimelineItemPayloadSchema,
|
|
377
|
+
z.object({
|
|
378
|
+
type: z.literal("todo"),
|
|
379
|
+
items: z.array(z.object({
|
|
380
|
+
text: z.string(),
|
|
381
|
+
completed: z.boolean(),
|
|
382
|
+
})),
|
|
383
|
+
}),
|
|
384
|
+
z.object({
|
|
385
|
+
type: z.literal("error"),
|
|
386
|
+
message: z.string(),
|
|
387
|
+
}),
|
|
388
|
+
z.object({
|
|
389
|
+
type: z.literal("compaction"),
|
|
390
|
+
status: z.enum(["loading", "completed"]),
|
|
391
|
+
trigger: z.enum(["auto", "manual"]).optional(),
|
|
392
|
+
preTokens: z.number().optional(),
|
|
393
|
+
}),
|
|
394
|
+
]);
|
|
395
|
+
export const AgentStreamEventPayloadSchema = z.discriminatedUnion("type", [
|
|
396
|
+
z.object({
|
|
397
|
+
type: z.literal("thread_started"),
|
|
398
|
+
sessionId: z.string(),
|
|
399
|
+
provider: AgentProviderSchema,
|
|
400
|
+
}),
|
|
401
|
+
z.object({
|
|
402
|
+
type: z.literal("turn_started"),
|
|
403
|
+
provider: AgentProviderSchema,
|
|
404
|
+
}),
|
|
405
|
+
z.object({
|
|
406
|
+
type: z.literal("turn_completed"),
|
|
407
|
+
provider: AgentProviderSchema,
|
|
408
|
+
usage: AgentUsageSchema.optional(),
|
|
409
|
+
}),
|
|
410
|
+
z.object({
|
|
411
|
+
type: z.literal("turn_failed"),
|
|
412
|
+
provider: AgentProviderSchema,
|
|
413
|
+
error: z.string(),
|
|
414
|
+
code: z.string().optional(),
|
|
415
|
+
diagnostic: z.string().optional(),
|
|
416
|
+
}),
|
|
417
|
+
z.object({
|
|
418
|
+
type: z.literal("turn_canceled"),
|
|
419
|
+
provider: AgentProviderSchema,
|
|
420
|
+
reason: z.string(),
|
|
421
|
+
}),
|
|
422
|
+
z.object({
|
|
423
|
+
type: z.literal("timeline"),
|
|
424
|
+
provider: AgentProviderSchema,
|
|
425
|
+
item: AgentTimelineItemPayloadSchema,
|
|
426
|
+
}),
|
|
427
|
+
z.object({
|
|
428
|
+
type: z.literal("permission_requested"),
|
|
429
|
+
provider: AgentProviderSchema,
|
|
430
|
+
request: AgentPermissionRequestPayloadSchema,
|
|
431
|
+
}),
|
|
432
|
+
z.object({
|
|
433
|
+
type: z.literal("permission_resolved"),
|
|
434
|
+
provider: AgentProviderSchema,
|
|
435
|
+
requestId: z.string(),
|
|
436
|
+
resolution: AgentPermissionResponseSchema,
|
|
437
|
+
}),
|
|
438
|
+
z.object({
|
|
439
|
+
type: z.literal("attention_required"),
|
|
440
|
+
provider: AgentProviderSchema,
|
|
441
|
+
reason: z.enum(["finished", "error", "permission"]),
|
|
442
|
+
timestamp: z.string(),
|
|
443
|
+
shouldNotify: z.boolean(),
|
|
444
|
+
notification: z
|
|
445
|
+
.object({
|
|
446
|
+
title: z.string(),
|
|
447
|
+
body: z.string(),
|
|
448
|
+
data: z.object({
|
|
449
|
+
serverId: z.string(),
|
|
450
|
+
agentId: z.string(),
|
|
451
|
+
reason: z.enum(["finished", "error", "permission"]),
|
|
452
|
+
}),
|
|
453
|
+
})
|
|
454
|
+
.optional(),
|
|
455
|
+
}),
|
|
456
|
+
]);
|
|
457
|
+
const AgentPersistenceHandleSchema = z
|
|
458
|
+
.object({
|
|
459
|
+
provider: AgentProviderSchema,
|
|
460
|
+
sessionId: z.string(),
|
|
461
|
+
nativeHandle: z.string().optional(),
|
|
462
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
463
|
+
})
|
|
464
|
+
.nullable();
|
|
465
|
+
const AgentRuntimeInfoSchema = z.object({
|
|
466
|
+
provider: AgentProviderSchema,
|
|
467
|
+
sessionId: z.string().nullable(),
|
|
468
|
+
model: z.string().nullable().optional(),
|
|
469
|
+
thinkingOptionId: z.string().nullable().optional(),
|
|
470
|
+
modeId: z.string().nullable().optional(),
|
|
471
|
+
extra: z.record(z.string(), z.unknown()).optional(),
|
|
472
|
+
});
|
|
473
|
+
export const AgentSnapshotPayloadSchema = z.object({
|
|
474
|
+
id: z.string(),
|
|
475
|
+
provider: AgentProviderSchema,
|
|
476
|
+
cwd: z.string(),
|
|
477
|
+
model: z.string().nullable(),
|
|
478
|
+
features: z.array(AgentFeatureSchema).optional(),
|
|
479
|
+
thinkingOptionId: z.string().nullable().optional(),
|
|
480
|
+
effectiveThinkingOptionId: z.string().nullable().optional(),
|
|
481
|
+
createdAt: z.string(),
|
|
482
|
+
updatedAt: z.string(),
|
|
483
|
+
lastUserMessageAt: z.string().nullable(),
|
|
484
|
+
status: AgentStatusSchema,
|
|
485
|
+
capabilities: AgentCapabilityFlagsSchema,
|
|
486
|
+
currentModeId: z.string().nullable(),
|
|
487
|
+
availableModes: z.array(AgentModeSchema),
|
|
488
|
+
pendingPermissions: z.array(AgentPermissionRequestPayloadSchema),
|
|
489
|
+
persistence: AgentPersistenceHandleSchema.nullable(),
|
|
490
|
+
runtimeInfo: AgentRuntimeInfoSchema.optional(),
|
|
491
|
+
lastUsage: AgentUsageSchema.optional(),
|
|
492
|
+
lastError: z.string().optional(),
|
|
493
|
+
title: z.string().nullable(),
|
|
494
|
+
labels: z.record(z.string(), z.string()).default({}),
|
|
495
|
+
requiresAttention: z.boolean().optional(),
|
|
496
|
+
attentionReason: z.enum(["finished", "error", "permission"]).nullable().optional(),
|
|
497
|
+
attentionTimestamp: z.string().nullable().optional(),
|
|
498
|
+
archivedAt: z.string().nullable().optional(),
|
|
499
|
+
providerUnavailable: z.boolean().optional(),
|
|
500
|
+
});
|
|
501
|
+
export const AgentListItemPayloadSchema = z.object({
|
|
502
|
+
id: z.string(),
|
|
503
|
+
shortId: z.string(),
|
|
504
|
+
title: z.string().nullable(),
|
|
505
|
+
provider: AgentProviderSchema,
|
|
506
|
+
model: z.string().nullable(),
|
|
507
|
+
thinkingOptionId: z.string().nullable().optional(),
|
|
508
|
+
effectiveThinkingOptionId: z.string().nullable().optional(),
|
|
509
|
+
status: AgentStatusSchema,
|
|
510
|
+
cwd: z.string(),
|
|
511
|
+
createdAt: z.string(),
|
|
512
|
+
updatedAt: z.string(),
|
|
513
|
+
lastUserMessageAt: z.string().nullable(),
|
|
514
|
+
archivedAt: z.string().nullable().optional(),
|
|
515
|
+
requiresAttention: z.boolean().optional(),
|
|
516
|
+
attentionReason: z.enum(["finished", "error", "permission"]).nullable().optional(),
|
|
517
|
+
attentionTimestamp: z.string().nullable().optional(),
|
|
518
|
+
labels: z.record(z.string(), z.string()).default({}),
|
|
519
|
+
providerUnavailable: z.boolean().optional(),
|
|
520
|
+
});
|
|
521
|
+
// ============================================================================
|
|
522
|
+
// Session Inbound Messages (Session receives these)
|
|
523
|
+
// ============================================================================
|
|
524
|
+
export const VoiceAudioChunkMessageSchema = z.object({
|
|
525
|
+
type: z.literal("voice_audio_chunk"),
|
|
526
|
+
audio: z.string(), // base64 encoded
|
|
527
|
+
format: z.string(),
|
|
528
|
+
isLast: z.boolean(),
|
|
529
|
+
});
|
|
530
|
+
export const AbortRequestMessageSchema = z.object({
|
|
531
|
+
type: z.literal("abort_request"),
|
|
532
|
+
});
|
|
533
|
+
export const AudioPlayedMessageSchema = z.object({
|
|
534
|
+
type: z.literal("audio_played"),
|
|
535
|
+
id: z.string(),
|
|
536
|
+
});
|
|
537
|
+
const AgentDirectoryFilterSchema = z.object({
|
|
538
|
+
labels: z.record(z.string()).optional(),
|
|
539
|
+
projectKeys: z.array(z.string()).optional(),
|
|
540
|
+
statuses: z.array(AgentStatusSchema).optional(),
|
|
541
|
+
includeArchived: z.boolean().optional(),
|
|
542
|
+
requiresAttention: z.boolean().optional(),
|
|
543
|
+
thinkingOptionId: z.string().nullable().optional(),
|
|
544
|
+
});
|
|
545
|
+
export const DeleteAgentRequestMessageSchema = z.object({
|
|
546
|
+
type: z.literal("delete_agent_request"),
|
|
547
|
+
agentId: z.string(),
|
|
548
|
+
requestId: z.string(),
|
|
549
|
+
});
|
|
550
|
+
export const ArchiveAgentRequestMessageSchema = z.object({
|
|
551
|
+
type: z.literal("archive_agent_request"),
|
|
552
|
+
agentId: z.string(),
|
|
553
|
+
requestId: z.string(),
|
|
554
|
+
});
|
|
555
|
+
export const CloseItemsRequestMessageSchema = z.object({
|
|
556
|
+
type: z.literal("close_items_request"),
|
|
557
|
+
agentIds: z.array(z.string()).default([]),
|
|
558
|
+
terminalIds: z.array(z.string()).default([]),
|
|
559
|
+
requestId: z.string(),
|
|
560
|
+
});
|
|
561
|
+
export const UpdateAgentRequestMessageSchema = z.object({
|
|
562
|
+
type: z.literal("update_agent_request"),
|
|
563
|
+
agentId: z.string(),
|
|
564
|
+
name: z.string().optional(),
|
|
565
|
+
labels: z.record(z.string()).optional(),
|
|
566
|
+
requestId: z.string(),
|
|
567
|
+
});
|
|
568
|
+
export const SetVoiceModeMessageSchema = z.object({
|
|
569
|
+
type: z.literal("set_voice_mode"),
|
|
570
|
+
enabled: z.boolean(),
|
|
571
|
+
agentId: z.string().optional(),
|
|
572
|
+
requestId: z.string().optional(),
|
|
573
|
+
});
|
|
574
|
+
export const GitHubPrAttachmentSchema = z.object({
|
|
575
|
+
type: z.literal("github_pr"),
|
|
576
|
+
mimeType: z.literal("application/github-pr"),
|
|
577
|
+
number: z.number().int().positive(),
|
|
578
|
+
title: z.string(),
|
|
579
|
+
url: z.string(),
|
|
580
|
+
body: z.string().nullable().optional(),
|
|
581
|
+
baseRefName: z.string().nullable().optional(),
|
|
582
|
+
headRefName: z.string().nullable().optional(),
|
|
583
|
+
});
|
|
584
|
+
export const GitHubIssueAttachmentSchema = z.object({
|
|
585
|
+
type: z.literal("github_issue"),
|
|
586
|
+
mimeType: z.literal("application/github-issue"),
|
|
587
|
+
number: z.number().int().positive(),
|
|
588
|
+
title: z.string(),
|
|
589
|
+
url: z.string(),
|
|
590
|
+
body: z.string().nullable().optional(),
|
|
591
|
+
});
|
|
592
|
+
export const TextAttachmentSchema = z.object({
|
|
593
|
+
type: z.literal("text"),
|
|
594
|
+
mimeType: z.literal("text/plain"),
|
|
595
|
+
title: z.string().nullable().optional(),
|
|
596
|
+
text: z.string(),
|
|
597
|
+
});
|
|
598
|
+
export const ReviewAttachmentContextLineSchema = z.object({
|
|
599
|
+
oldLineNumber: z.number().int().positive().nullable(),
|
|
600
|
+
newLineNumber: z.number().int().positive().nullable(),
|
|
601
|
+
type: z.enum(["add", "remove", "context"]),
|
|
602
|
+
content: z.string(),
|
|
603
|
+
});
|
|
604
|
+
export const ReviewAttachmentCommentSchema = z.object({
|
|
605
|
+
filePath: z.string(),
|
|
606
|
+
side: z.enum(["old", "new"]),
|
|
607
|
+
lineNumber: z.number().int().positive(),
|
|
608
|
+
body: z.string(),
|
|
609
|
+
context: z.object({
|
|
610
|
+
hunkHeader: z.string(),
|
|
611
|
+
targetLine: ReviewAttachmentContextLineSchema,
|
|
612
|
+
lines: z.array(ReviewAttachmentContextLineSchema),
|
|
613
|
+
}),
|
|
614
|
+
});
|
|
615
|
+
export const ReviewAttachmentSchema = z.object({
|
|
616
|
+
type: z.literal("review"),
|
|
617
|
+
mimeType: z.literal("application/paseo-review"),
|
|
618
|
+
cwd: z.string(),
|
|
619
|
+
mode: z.enum(["uncommitted", "base"]),
|
|
620
|
+
baseRef: z.string().nullable().optional(),
|
|
621
|
+
comments: z.array(ReviewAttachmentCommentSchema),
|
|
622
|
+
});
|
|
623
|
+
export const AgentAttachmentSchema = z.discriminatedUnion("type", [
|
|
624
|
+
GitHubPrAttachmentSchema,
|
|
625
|
+
GitHubIssueAttachmentSchema,
|
|
626
|
+
TextAttachmentSchema,
|
|
627
|
+
ReviewAttachmentSchema,
|
|
628
|
+
]);
|
|
629
|
+
function normalizeAgentAttachments(input) {
|
|
630
|
+
if (!Array.isArray(input)) {
|
|
631
|
+
return [];
|
|
632
|
+
}
|
|
633
|
+
const normalized = [];
|
|
634
|
+
for (const item of input) {
|
|
635
|
+
const parsed = AgentAttachmentSchema.safeParse(item);
|
|
636
|
+
if (parsed.success) {
|
|
637
|
+
normalized.push(parsed.data);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return normalized;
|
|
641
|
+
}
|
|
642
|
+
const AgentAttachmentsSchema = z.unknown().transform(normalizeAgentAttachments).optional();
|
|
643
|
+
const ImageAttachmentSchema = z.object({
|
|
644
|
+
data: z.string(), // base64 encoded image
|
|
645
|
+
mimeType: z.string(), // e.g., "image/jpeg", "image/png"
|
|
646
|
+
});
|
|
647
|
+
export const SendAgentMessageSchema = z.object({
|
|
648
|
+
type: z.literal("send_agent_message"),
|
|
649
|
+
agentId: z.string(),
|
|
650
|
+
text: z.string(),
|
|
651
|
+
messageId: z.string().optional(), // Client-provided ID for deduplication
|
|
652
|
+
images: z.array(ImageAttachmentSchema).optional(),
|
|
653
|
+
attachments: AgentAttachmentsSchema,
|
|
654
|
+
});
|
|
655
|
+
// ============================================================================
|
|
656
|
+
// Agent RPCs (requestId-correlated)
|
|
657
|
+
// ============================================================================
|
|
658
|
+
export const FetchAgentsRequestMessageSchema = z.object({
|
|
659
|
+
type: z.literal("fetch_agents_request"),
|
|
660
|
+
requestId: z.string(),
|
|
661
|
+
scope: z.enum(["active"]).optional(),
|
|
662
|
+
filter: AgentDirectoryFilterSchema.optional(),
|
|
663
|
+
sort: z
|
|
664
|
+
.array(z.object({
|
|
665
|
+
key: z.enum(["status_priority", "created_at", "updated_at", "title"]),
|
|
666
|
+
direction: z.enum(["asc", "desc"]),
|
|
667
|
+
}))
|
|
668
|
+
.optional(),
|
|
669
|
+
page: z
|
|
670
|
+
.object({
|
|
671
|
+
limit: z.number().int().positive().max(200),
|
|
672
|
+
cursor: z.string().min(1).optional(),
|
|
673
|
+
})
|
|
674
|
+
.optional(),
|
|
675
|
+
subscribe: z
|
|
676
|
+
.object({
|
|
677
|
+
subscriptionId: z.string().optional(),
|
|
678
|
+
})
|
|
679
|
+
.optional(),
|
|
680
|
+
});
|
|
681
|
+
const WorkspaceStateBucketSchema = z.enum([
|
|
682
|
+
"needs_input",
|
|
683
|
+
"failed",
|
|
684
|
+
"running",
|
|
685
|
+
"attention",
|
|
686
|
+
"done",
|
|
687
|
+
]);
|
|
688
|
+
export const FetchWorkspacesRequestMessageSchema = z.object({
|
|
689
|
+
type: z.literal("fetch_workspaces_request"),
|
|
690
|
+
requestId: z.string(),
|
|
691
|
+
filter: z
|
|
692
|
+
.object({
|
|
693
|
+
query: z.string().optional(),
|
|
694
|
+
projectId: z.string().optional(),
|
|
695
|
+
idPrefix: z.string().optional(),
|
|
696
|
+
})
|
|
697
|
+
.optional(),
|
|
698
|
+
sort: z
|
|
699
|
+
.array(z.object({
|
|
700
|
+
key: z.enum(["status_priority", "activity_at", "name", "project_id"]),
|
|
701
|
+
direction: z.enum(["asc", "desc"]),
|
|
702
|
+
}))
|
|
703
|
+
.optional(),
|
|
704
|
+
page: z
|
|
705
|
+
.object({
|
|
706
|
+
limit: z.number().int().positive().max(200),
|
|
707
|
+
cursor: z.string().min(1).optional(),
|
|
708
|
+
})
|
|
709
|
+
.optional(),
|
|
710
|
+
subscribe: z
|
|
711
|
+
.object({
|
|
712
|
+
subscriptionId: z.string().optional(),
|
|
713
|
+
})
|
|
714
|
+
.optional(),
|
|
715
|
+
});
|
|
716
|
+
export const FetchAgentHistoryRequestMessageSchema = z.object({
|
|
717
|
+
type: z.literal("fetch_agent_history_request"),
|
|
718
|
+
requestId: z.string(),
|
|
719
|
+
filter: AgentDirectoryFilterSchema.optional(),
|
|
720
|
+
sort: z
|
|
721
|
+
.array(z.object({
|
|
722
|
+
key: z.enum(["status_priority", "created_at", "updated_at", "title"]),
|
|
723
|
+
direction: z.enum(["asc", "desc"]),
|
|
724
|
+
}))
|
|
725
|
+
.optional(),
|
|
726
|
+
page: z
|
|
727
|
+
.object({
|
|
728
|
+
limit: z.number().int().positive().max(200),
|
|
729
|
+
cursor: z.string().min(1).optional(),
|
|
730
|
+
})
|
|
731
|
+
.optional(),
|
|
732
|
+
});
|
|
733
|
+
export const FetchAgentRequestMessageSchema = z.object({
|
|
734
|
+
type: z.literal("fetch_agent_request"),
|
|
735
|
+
requestId: z.string(),
|
|
736
|
+
/** Accepts full ID, unique prefix, or exact full title (server resolves). */
|
|
737
|
+
agentId: z.string(),
|
|
738
|
+
});
|
|
739
|
+
export const SendAgentMessageRequestSchema = z.object({
|
|
740
|
+
type: z.literal("send_agent_message_request"),
|
|
741
|
+
requestId: z.string(),
|
|
742
|
+
/** Accepts full ID, unique prefix, or exact full title (server resolves). */
|
|
743
|
+
agentId: z.string(),
|
|
744
|
+
text: z.string(),
|
|
745
|
+
messageId: z.string().optional(), // Client-provided ID for deduplication
|
|
746
|
+
images: z.array(ImageAttachmentSchema).optional(),
|
|
747
|
+
attachments: AgentAttachmentsSchema,
|
|
748
|
+
});
|
|
749
|
+
export const WaitForFinishRequestSchema = z.object({
|
|
750
|
+
type: z.literal("wait_for_finish_request"),
|
|
751
|
+
requestId: z.string(),
|
|
752
|
+
/** Accepts full ID, unique prefix, or exact full title (server resolves). */
|
|
753
|
+
agentId: z.string(),
|
|
754
|
+
timeoutMs: z.number().int().positive().optional(),
|
|
755
|
+
});
|
|
756
|
+
export const GetDaemonConfigRequestMessageSchema = z.object({
|
|
757
|
+
type: z.literal("get_daemon_config_request"),
|
|
758
|
+
requestId: z.string(),
|
|
759
|
+
});
|
|
760
|
+
export const SetDaemonConfigRequestMessageSchema = z.object({
|
|
761
|
+
type: z.literal("set_daemon_config_request"),
|
|
762
|
+
requestId: z.string(),
|
|
763
|
+
config: MutableDaemonConfigPatchSchema,
|
|
764
|
+
});
|
|
765
|
+
export const ReadProjectConfigRequestMessageSchema = z.object({
|
|
766
|
+
type: z.literal("read_project_config_request"),
|
|
767
|
+
requestId: z.string(),
|
|
768
|
+
repoRoot: z.string(),
|
|
769
|
+
});
|
|
770
|
+
export const WriteProjectConfigRequestMessageSchema = z.object({
|
|
771
|
+
type: z.literal("write_project_config_request"),
|
|
772
|
+
requestId: z.string(),
|
|
773
|
+
repoRoot: z.string(),
|
|
774
|
+
config: PaseoConfigRawSchema,
|
|
775
|
+
expectedRevision: PaseoConfigRevisionSchema.nullable(),
|
|
776
|
+
});
|
|
777
|
+
// ============================================================================
|
|
778
|
+
// Dictation Streaming (lossless, resumable)
|
|
779
|
+
// ============================================================================
|
|
780
|
+
export const DictationStreamStartMessageSchema = z.object({
|
|
781
|
+
type: z.literal("dictation_stream_start"),
|
|
782
|
+
dictationId: z.string(),
|
|
783
|
+
format: z.string(), // e.g. "audio/pcm;rate=16000;bits=16"
|
|
784
|
+
});
|
|
785
|
+
export const DictationStreamChunkMessageSchema = z.object({
|
|
786
|
+
type: z.literal("dictation_stream_chunk"),
|
|
787
|
+
dictationId: z.string(),
|
|
788
|
+
seq: z.number().int().nonnegative(),
|
|
789
|
+
audio: z.string(), // base64 encoded chunk
|
|
790
|
+
format: z.string(), // e.g. "audio/pcm;rate=16000;bits=16"
|
|
791
|
+
});
|
|
792
|
+
export const DictationStreamFinishMessageSchema = z.object({
|
|
793
|
+
type: z.literal("dictation_stream_finish"),
|
|
794
|
+
dictationId: z.string(),
|
|
795
|
+
finalSeq: z.number().int().nonnegative(),
|
|
796
|
+
});
|
|
797
|
+
export const DictationStreamCancelMessageSchema = z.object({
|
|
798
|
+
type: z.literal("dictation_stream_cancel"),
|
|
799
|
+
dictationId: z.string(),
|
|
800
|
+
});
|
|
801
|
+
const GitSetupOptionsSchema = z.object({
|
|
802
|
+
baseBranch: z.string().optional(),
|
|
803
|
+
createNewBranch: z.boolean().optional(),
|
|
804
|
+
newBranchName: z.string().optional(),
|
|
805
|
+
createWorktree: z.boolean().optional(),
|
|
806
|
+
worktreeSlug: z.string().optional(),
|
|
807
|
+
refName: z.string().min(1).optional(),
|
|
808
|
+
action: z.enum(["branch-off", "checkout"]).optional(),
|
|
809
|
+
githubPrNumber: z.number().int().positive().optional(),
|
|
810
|
+
});
|
|
811
|
+
export const CreateAgentRequestMessageSchema = z.object({
|
|
812
|
+
type: z.literal("create_agent_request"),
|
|
813
|
+
config: AgentSessionConfigSchema,
|
|
814
|
+
workspaceId: z.string().optional(),
|
|
815
|
+
worktreeName: z.string().optional(),
|
|
816
|
+
initialPrompt: z.string().optional(),
|
|
817
|
+
clientMessageId: z.string().optional(),
|
|
818
|
+
outputSchema: z.record(z.unknown()).optional(),
|
|
819
|
+
images: z.array(ImageAttachmentSchema).optional(),
|
|
820
|
+
attachments: AgentAttachmentsSchema,
|
|
821
|
+
git: GitSetupOptionsSchema.optional(),
|
|
822
|
+
labels: z.record(z.string()).default({}),
|
|
823
|
+
requestId: z.string(),
|
|
824
|
+
});
|
|
825
|
+
export const ListProviderModelsRequestMessageSchema = z.object({
|
|
826
|
+
type: z.literal("list_provider_models_request"),
|
|
827
|
+
provider: AgentProviderSchema,
|
|
828
|
+
cwd: z.string().optional(),
|
|
829
|
+
requestId: z.string(),
|
|
830
|
+
});
|
|
831
|
+
export const ListProviderModesRequestMessageSchema = z.object({
|
|
832
|
+
type: z.literal("list_provider_modes_request"),
|
|
833
|
+
provider: AgentProviderSchema,
|
|
834
|
+
cwd: z.string().optional(),
|
|
835
|
+
requestId: z.string(),
|
|
836
|
+
});
|
|
837
|
+
export const ListAvailableProvidersRequestMessageSchema = z.object({
|
|
838
|
+
type: z.literal("list_available_providers_request"),
|
|
839
|
+
requestId: z.string(),
|
|
840
|
+
});
|
|
841
|
+
export const GetProvidersSnapshotRequestMessageSchema = z.object({
|
|
842
|
+
type: z.literal("get_providers_snapshot_request"),
|
|
843
|
+
cwd: z.string().optional(),
|
|
844
|
+
requestId: z.string(),
|
|
845
|
+
});
|
|
846
|
+
export const RefreshProvidersSnapshotRequestMessageSchema = z.object({
|
|
847
|
+
type: z.literal("refresh_providers_snapshot_request"),
|
|
848
|
+
cwd: z.string().optional(),
|
|
849
|
+
providers: z.array(AgentProviderSchema).optional(),
|
|
850
|
+
requestId: z.string(),
|
|
851
|
+
});
|
|
852
|
+
export const ProviderDiagnosticRequestMessageSchema = z.object({
|
|
853
|
+
type: z.literal("provider_diagnostic_request"),
|
|
854
|
+
provider: AgentProviderSchema,
|
|
855
|
+
requestId: z.string(),
|
|
856
|
+
});
|
|
857
|
+
export const ResumeAgentRequestMessageSchema = z.object({
|
|
858
|
+
type: z.literal("resume_agent_request"),
|
|
859
|
+
handle: AgentPersistenceHandleSchema,
|
|
860
|
+
overrides: AgentSessionConfigSchema.partial().optional(),
|
|
861
|
+
requestId: z.string(),
|
|
862
|
+
});
|
|
863
|
+
export const ImportAgentRequestMessageSchema = z.object({
|
|
864
|
+
type: z.literal("import_agent_request"),
|
|
865
|
+
provider: AgentProviderSchema,
|
|
866
|
+
sessionId: z.string(),
|
|
867
|
+
cwd: z.string().optional(),
|
|
868
|
+
labels: z.record(z.string()).optional(),
|
|
869
|
+
requestId: z.string(),
|
|
870
|
+
});
|
|
871
|
+
export const RefreshAgentRequestMessageSchema = z.object({
|
|
872
|
+
type: z.literal("refresh_agent_request"),
|
|
873
|
+
agentId: z.string(),
|
|
874
|
+
requestId: z.string(),
|
|
875
|
+
});
|
|
876
|
+
export const CancelAgentRequestMessageSchema = z.object({
|
|
877
|
+
type: z.literal("cancel_agent_request"),
|
|
878
|
+
agentId: z.string(),
|
|
879
|
+
requestId: z.string().optional(),
|
|
880
|
+
});
|
|
881
|
+
export const RestartServerRequestMessageSchema = z.object({
|
|
882
|
+
type: z.literal("restart_server_request"),
|
|
883
|
+
reason: z.string().optional(),
|
|
884
|
+
requestId: z.string(),
|
|
885
|
+
});
|
|
886
|
+
export const ShutdownServerRequestMessageSchema = z.object({
|
|
887
|
+
type: z.literal("shutdown_server_request"),
|
|
888
|
+
requestId: z.string(),
|
|
889
|
+
});
|
|
890
|
+
export const AgentTimelineCursorSchema = z.object({
|
|
891
|
+
epoch: z.string(),
|
|
892
|
+
seq: z.number().int().nonnegative(),
|
|
893
|
+
});
|
|
894
|
+
export const FetchAgentTimelineRequestMessageSchema = z.object({
|
|
895
|
+
type: z.literal("fetch_agent_timeline_request"),
|
|
896
|
+
agentId: z.string(),
|
|
897
|
+
requestId: z.string(),
|
|
898
|
+
direction: z.enum(["tail", "before", "after"]).optional(),
|
|
899
|
+
cursor: AgentTimelineCursorSchema.optional(),
|
|
900
|
+
// 0 means "all matching rows for this query window".
|
|
901
|
+
limit: z.number().int().nonnegative().optional(),
|
|
902
|
+
// Default should be projected for app timeline loading.
|
|
903
|
+
projection: z.enum(["projected", "canonical"]).optional(),
|
|
904
|
+
});
|
|
905
|
+
export const SetAgentModeRequestMessageSchema = z.object({
|
|
906
|
+
type: z.literal("set_agent_mode_request"),
|
|
907
|
+
agentId: z.string(),
|
|
908
|
+
modeId: z.string(),
|
|
909
|
+
requestId: z.string(),
|
|
910
|
+
});
|
|
911
|
+
const AgentActionResponsePayloadSchema = z.object({
|
|
912
|
+
requestId: z.string(),
|
|
913
|
+
agentId: z.string(),
|
|
914
|
+
accepted: z.boolean(),
|
|
915
|
+
error: z.string().nullable(),
|
|
916
|
+
});
|
|
917
|
+
export const SetAgentModeResponseMessageSchema = z.object({
|
|
918
|
+
type: z.literal("set_agent_mode_response"),
|
|
919
|
+
payload: AgentActionResponsePayloadSchema,
|
|
920
|
+
});
|
|
921
|
+
export const SetAgentModelRequestMessageSchema = z.object({
|
|
922
|
+
type: z.literal("set_agent_model_request"),
|
|
923
|
+
agentId: z.string(),
|
|
924
|
+
modelId: z.string().nullable(),
|
|
925
|
+
requestId: z.string(),
|
|
926
|
+
});
|
|
927
|
+
export const SetAgentModelResponseMessageSchema = z.object({
|
|
928
|
+
type: z.literal("set_agent_model_response"),
|
|
929
|
+
payload: AgentActionResponsePayloadSchema,
|
|
930
|
+
});
|
|
931
|
+
export const SetAgentThinkingRequestMessageSchema = z.object({
|
|
932
|
+
type: z.literal("set_agent_thinking_request"),
|
|
933
|
+
agentId: z.string(),
|
|
934
|
+
thinkingOptionId: z.string().nullable(),
|
|
935
|
+
requestId: z.string(),
|
|
936
|
+
});
|
|
937
|
+
export const SetAgentThinkingResponseMessageSchema = z.object({
|
|
938
|
+
type: z.literal("set_agent_thinking_response"),
|
|
939
|
+
payload: AgentActionResponsePayloadSchema,
|
|
940
|
+
});
|
|
941
|
+
export const SetAgentFeatureRequestMessageSchema = z.object({
|
|
942
|
+
type: z.literal("set_agent_feature_request"),
|
|
943
|
+
agentId: z.string(),
|
|
944
|
+
featureId: z.string(),
|
|
945
|
+
value: z.unknown(),
|
|
946
|
+
requestId: z.string(),
|
|
947
|
+
});
|
|
948
|
+
export const SetAgentFeatureResponseMessageSchema = z.object({
|
|
949
|
+
type: z.literal("set_agent_feature_response"),
|
|
950
|
+
payload: AgentActionResponsePayloadSchema,
|
|
951
|
+
});
|
|
952
|
+
export const UpdateAgentResponseMessageSchema = z.object({
|
|
953
|
+
type: z.literal("update_agent_response"),
|
|
954
|
+
payload: AgentActionResponsePayloadSchema,
|
|
955
|
+
});
|
|
956
|
+
export const SetVoiceModeResponseMessageSchema = z.object({
|
|
957
|
+
type: z.literal("set_voice_mode_response"),
|
|
958
|
+
payload: z.object({
|
|
959
|
+
requestId: z.string(),
|
|
960
|
+
enabled: z.boolean(),
|
|
961
|
+
agentId: z.string().nullable(),
|
|
962
|
+
accepted: z.boolean(),
|
|
963
|
+
error: z.string().nullable(),
|
|
964
|
+
reasonCode: z.string().optional(),
|
|
965
|
+
retryable: z.boolean().optional(),
|
|
966
|
+
missingModelIds: z.array(z.string()).optional(),
|
|
967
|
+
}),
|
|
968
|
+
});
|
|
969
|
+
export const AgentPermissionResponseMessageSchema = z.object({
|
|
970
|
+
type: z.literal("agent_permission_response"),
|
|
971
|
+
agentId: z.string(),
|
|
972
|
+
requestId: z.string(),
|
|
973
|
+
response: AgentPermissionResponseSchema,
|
|
974
|
+
});
|
|
975
|
+
const CheckoutErrorCodeSchema = z.enum([
|
|
976
|
+
"NOT_GIT_REPO",
|
|
977
|
+
"NOT_ALLOWED",
|
|
978
|
+
"MERGE_CONFLICT",
|
|
979
|
+
"UNKNOWN",
|
|
980
|
+
]);
|
|
981
|
+
const CheckoutErrorSchema = z.object({
|
|
982
|
+
code: CheckoutErrorCodeSchema,
|
|
983
|
+
message: z.string(),
|
|
984
|
+
});
|
|
985
|
+
const CheckoutDiffCompareSchema = z.object({
|
|
986
|
+
mode: z.enum(["uncommitted", "base"]),
|
|
987
|
+
baseRef: z.string().optional(),
|
|
988
|
+
ignoreWhitespace: z.boolean().optional(),
|
|
989
|
+
});
|
|
990
|
+
export const CheckoutStatusRequestSchema = z.object({
|
|
991
|
+
type: z.literal("checkout_status_request"),
|
|
992
|
+
cwd: z.string(),
|
|
993
|
+
requestId: z.string(),
|
|
994
|
+
});
|
|
995
|
+
export const SubscribeCheckoutDiffRequestSchema = z.object({
|
|
996
|
+
type: z.literal("subscribe_checkout_diff_request"),
|
|
997
|
+
subscriptionId: z.string(),
|
|
998
|
+
cwd: z.string(),
|
|
999
|
+
compare: CheckoutDiffCompareSchema,
|
|
1000
|
+
requestId: z.string(),
|
|
1001
|
+
});
|
|
1002
|
+
export const UnsubscribeCheckoutDiffRequestSchema = z.object({
|
|
1003
|
+
type: z.literal("unsubscribe_checkout_diff_request"),
|
|
1004
|
+
subscriptionId: z.string(),
|
|
1005
|
+
});
|
|
1006
|
+
export const CheckoutCommitRequestSchema = z.object({
|
|
1007
|
+
type: z.literal("checkout_commit_request"),
|
|
1008
|
+
cwd: z.string(),
|
|
1009
|
+
message: z.string().optional(),
|
|
1010
|
+
addAll: z.boolean().optional(),
|
|
1011
|
+
requestId: z.string(),
|
|
1012
|
+
});
|
|
1013
|
+
export const CheckoutMergeRequestSchema = z.object({
|
|
1014
|
+
type: z.literal("checkout_merge_request"),
|
|
1015
|
+
cwd: z.string(),
|
|
1016
|
+
baseRef: z.string().optional(),
|
|
1017
|
+
strategy: z.enum(["merge", "squash"]).optional(),
|
|
1018
|
+
requireCleanTarget: z.boolean().optional(),
|
|
1019
|
+
requestId: z.string(),
|
|
1020
|
+
});
|
|
1021
|
+
export const CheckoutMergeFromBaseRequestSchema = z.object({
|
|
1022
|
+
type: z.literal("checkout_merge_from_base_request"),
|
|
1023
|
+
cwd: z.string(),
|
|
1024
|
+
baseRef: z.string().optional(),
|
|
1025
|
+
requireCleanTarget: z.boolean().optional(),
|
|
1026
|
+
requestId: z.string(),
|
|
1027
|
+
});
|
|
1028
|
+
export const CheckoutPullRequestSchema = z.object({
|
|
1029
|
+
type: z.literal("checkout_pull_request"),
|
|
1030
|
+
cwd: z.string(),
|
|
1031
|
+
requestId: z.string(),
|
|
1032
|
+
});
|
|
1033
|
+
export const CheckoutPushRequestSchema = z.object({
|
|
1034
|
+
type: z.literal("checkout_push_request"),
|
|
1035
|
+
cwd: z.string(),
|
|
1036
|
+
requestId: z.string(),
|
|
1037
|
+
});
|
|
1038
|
+
export const CheckoutPrCreateRequestSchema = z.object({
|
|
1039
|
+
type: z.literal("checkout_pr_create_request"),
|
|
1040
|
+
cwd: z.string(),
|
|
1041
|
+
title: z.string().optional(),
|
|
1042
|
+
body: z.string().optional(),
|
|
1043
|
+
baseRef: z.string().optional(),
|
|
1044
|
+
requestId: z.string(),
|
|
1045
|
+
});
|
|
1046
|
+
export const CheckoutPrStatusRequestSchema = z.object({
|
|
1047
|
+
type: z.literal("checkout_pr_status_request"),
|
|
1048
|
+
cwd: z.string(),
|
|
1049
|
+
requestId: z.string(),
|
|
1050
|
+
});
|
|
1051
|
+
export const PullRequestTimelineRequestSchema = z.object({
|
|
1052
|
+
type: z.literal("pull_request_timeline_request"),
|
|
1053
|
+
cwd: z.string(),
|
|
1054
|
+
prNumber: z.number(),
|
|
1055
|
+
repoOwner: z.string(),
|
|
1056
|
+
repoName: z.string(),
|
|
1057
|
+
requestId: z.string(),
|
|
1058
|
+
});
|
|
1059
|
+
export const ValidateBranchRequestSchema = z.object({
|
|
1060
|
+
type: z.literal("validate_branch_request"),
|
|
1061
|
+
cwd: z.string(),
|
|
1062
|
+
branchName: z.string(),
|
|
1063
|
+
requestId: z.string(),
|
|
1064
|
+
});
|
|
1065
|
+
export const CheckoutSwitchBranchRequestSchema = z.object({
|
|
1066
|
+
type: z.literal("checkout_switch_branch_request"),
|
|
1067
|
+
cwd: z.string(),
|
|
1068
|
+
branch: z.string(),
|
|
1069
|
+
requestId: z.string(),
|
|
1070
|
+
});
|
|
1071
|
+
export const StashSaveRequestSchema = z.object({
|
|
1072
|
+
type: z.literal("stash_save_request"),
|
|
1073
|
+
cwd: z.string(),
|
|
1074
|
+
/** Branch name to tag the stash with for later identification. */
|
|
1075
|
+
branch: z.string().optional(),
|
|
1076
|
+
requestId: z.string(),
|
|
1077
|
+
});
|
|
1078
|
+
export const StashPopRequestSchema = z.object({
|
|
1079
|
+
type: z.literal("stash_pop_request"),
|
|
1080
|
+
cwd: z.string(),
|
|
1081
|
+
/** Zero-based index from stash_list_response. */
|
|
1082
|
+
stashIndex: z.number().int().min(0),
|
|
1083
|
+
requestId: z.string(),
|
|
1084
|
+
});
|
|
1085
|
+
export const StashListRequestSchema = z.object({
|
|
1086
|
+
type: z.literal("stash_list_request"),
|
|
1087
|
+
cwd: z.string(),
|
|
1088
|
+
/** If true, only return paseo-created stashes. Default true. */
|
|
1089
|
+
paseoOnly: z.boolean().optional(),
|
|
1090
|
+
requestId: z.string(),
|
|
1091
|
+
});
|
|
1092
|
+
export const BranchSuggestionsRequestSchema = z.object({
|
|
1093
|
+
type: z.literal("branch_suggestions_request"),
|
|
1094
|
+
cwd: z.string(),
|
|
1095
|
+
query: z.string().optional(),
|
|
1096
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
1097
|
+
requestId: z.string(),
|
|
1098
|
+
});
|
|
1099
|
+
export const GitHubSearchItemSchema = z.object({
|
|
1100
|
+
kind: z.enum(["issue", "pr"]),
|
|
1101
|
+
number: z.number(),
|
|
1102
|
+
title: z.string(),
|
|
1103
|
+
url: z.string(),
|
|
1104
|
+
state: z.string(),
|
|
1105
|
+
body: z.string().nullable(),
|
|
1106
|
+
labels: z.array(z.string()),
|
|
1107
|
+
baseRefName: z.string().nullable().optional(),
|
|
1108
|
+
headRefName: z.string().nullable().optional(),
|
|
1109
|
+
updatedAt: z.string().optional(),
|
|
1110
|
+
});
|
|
1111
|
+
export const GitHubSearchKindSchema = z.enum(["github-issue", "github-pr"]);
|
|
1112
|
+
export const GitHubSearchRequestSchema = z.object({
|
|
1113
|
+
type: z.literal("github_search_request"),
|
|
1114
|
+
cwd: z.string(),
|
|
1115
|
+
query: z.string(),
|
|
1116
|
+
limit: z.number().int().min(1).max(50).optional(),
|
|
1117
|
+
kinds: z.array(GitHubSearchKindSchema).optional(),
|
|
1118
|
+
requestId: z.string(),
|
|
1119
|
+
});
|
|
1120
|
+
export const DirectorySuggestionsRequestSchema = z.object({
|
|
1121
|
+
type: z.literal("directory_suggestions_request"),
|
|
1122
|
+
query: z.string(),
|
|
1123
|
+
cwd: z.string().optional(),
|
|
1124
|
+
includeFiles: z.boolean().optional(),
|
|
1125
|
+
includeDirectories: z.boolean().optional(),
|
|
1126
|
+
limit: z.number().int().min(1).max(100).optional(),
|
|
1127
|
+
requestId: z.string(),
|
|
1128
|
+
});
|
|
1129
|
+
export const PaseoWorktreeListRequestSchema = z.object({
|
|
1130
|
+
type: z.literal("paseo_worktree_list_request"),
|
|
1131
|
+
cwd: z.string().optional(),
|
|
1132
|
+
repoRoot: z.string().optional(),
|
|
1133
|
+
requestId: z.string(),
|
|
1134
|
+
});
|
|
1135
|
+
export const PaseoWorktreeArchiveRequestSchema = z.object({
|
|
1136
|
+
type: z.literal("paseo_worktree_archive_request"),
|
|
1137
|
+
worktreePath: z.string().optional(),
|
|
1138
|
+
repoRoot: z.string().optional(),
|
|
1139
|
+
branchName: z.string().optional(),
|
|
1140
|
+
requestId: z.string(),
|
|
1141
|
+
});
|
|
1142
|
+
export const FirstAgentContextSchema = z.object({
|
|
1143
|
+
prompt: z.string().optional(),
|
|
1144
|
+
attachments: AgentAttachmentsSchema,
|
|
1145
|
+
});
|
|
1146
|
+
export const CreatePaseoWorktreeRequestSchema = z.object({
|
|
1147
|
+
type: z.literal("create_paseo_worktree_request"),
|
|
1148
|
+
cwd: z.string(),
|
|
1149
|
+
worktreeSlug: z.string().optional(),
|
|
1150
|
+
nameContext: z.string().optional(),
|
|
1151
|
+
attachments: AgentAttachmentsSchema.optional(),
|
|
1152
|
+
firstAgentContext: FirstAgentContextSchema.optional(),
|
|
1153
|
+
refName: z.string().min(1).optional(),
|
|
1154
|
+
action: z.enum(["branch-off", "checkout"]).optional(),
|
|
1155
|
+
githubPrNumber: z.number().int().positive().optional(),
|
|
1156
|
+
requestId: z.string(),
|
|
1157
|
+
});
|
|
1158
|
+
export const WorkspaceSetupStatusRequestSchema = z.object({
|
|
1159
|
+
type: z.literal("workspace_setup_status_request"),
|
|
1160
|
+
workspaceId: z.string(),
|
|
1161
|
+
requestId: z.string(),
|
|
1162
|
+
});
|
|
1163
|
+
// TODO(2026-07): Remove once most clients are on >=0.1.50 and support arbitrary editor ids.
|
|
1164
|
+
export const LEGACY_EDITOR_TARGET_IDS = [
|
|
1165
|
+
"cursor",
|
|
1166
|
+
"vscode",
|
|
1167
|
+
"zed",
|
|
1168
|
+
"finder",
|
|
1169
|
+
"explorer",
|
|
1170
|
+
"file-manager",
|
|
1171
|
+
];
|
|
1172
|
+
export const KNOWN_EDITOR_TARGET_IDS = [...LEGACY_EDITOR_TARGET_IDS, "webstorm"];
|
|
1173
|
+
export const KnownEditorTargetIdSchema = z.enum(KNOWN_EDITOR_TARGET_IDS);
|
|
1174
|
+
export const LegacyEditorTargetIdSchema = z.enum(LEGACY_EDITOR_TARGET_IDS);
|
|
1175
|
+
export const EditorTargetIdSchema = z.string().trim().min(1);
|
|
1176
|
+
const KNOWN_EDITOR_TARGET_ID_SET = new Set(KNOWN_EDITOR_TARGET_IDS);
|
|
1177
|
+
const LEGACY_EDITOR_TARGET_ID_SET = new Set(LEGACY_EDITOR_TARGET_IDS);
|
|
1178
|
+
export function isKnownEditorTargetId(value) {
|
|
1179
|
+
return KNOWN_EDITOR_TARGET_ID_SET.has(value);
|
|
1180
|
+
}
|
|
1181
|
+
export function isLegacyEditorTargetId(value) {
|
|
1182
|
+
return LEGACY_EDITOR_TARGET_ID_SET.has(value);
|
|
1183
|
+
}
|
|
1184
|
+
export const EditorTargetDescriptorPayloadSchema = z.object({
|
|
1185
|
+
id: EditorTargetIdSchema,
|
|
1186
|
+
label: z.string(),
|
|
1187
|
+
});
|
|
1188
|
+
export const ListAvailableEditorsRequestSchema = z.object({
|
|
1189
|
+
type: z.literal("list_available_editors_request"),
|
|
1190
|
+
requestId: z.string(),
|
|
1191
|
+
});
|
|
1192
|
+
export const OpenInEditorRequestSchema = z.object({
|
|
1193
|
+
type: z.literal("open_in_editor_request"),
|
|
1194
|
+
path: z.string(),
|
|
1195
|
+
editorId: EditorTargetIdSchema,
|
|
1196
|
+
requestId: z.string(),
|
|
1197
|
+
});
|
|
1198
|
+
export const OpenProjectRequestSchema = z.object({
|
|
1199
|
+
type: z.literal("open_project_request"),
|
|
1200
|
+
cwd: z.string(),
|
|
1201
|
+
requestId: z.string(),
|
|
1202
|
+
});
|
|
1203
|
+
export const ArchiveWorkspaceRequestSchema = z.object({
|
|
1204
|
+
type: z.literal("archive_workspace_request"),
|
|
1205
|
+
workspaceId: z.string(),
|
|
1206
|
+
requestId: z.string(),
|
|
1207
|
+
});
|
|
1208
|
+
// Highlighted diff token schema
|
|
1209
|
+
// Note: style can be a compound class name (e.g., "heading meta") from the syntax highlighter
|
|
1210
|
+
const HighlightTokenSchema = z.object({
|
|
1211
|
+
text: z.string(),
|
|
1212
|
+
style: z.string().nullable(),
|
|
1213
|
+
});
|
|
1214
|
+
const DiffLineSchema = z.object({
|
|
1215
|
+
type: z.enum(["add", "remove", "context", "header"]),
|
|
1216
|
+
content: z.string(),
|
|
1217
|
+
tokens: z.array(HighlightTokenSchema).optional(),
|
|
1218
|
+
});
|
|
1219
|
+
const DiffHunkSchema = z.object({
|
|
1220
|
+
oldStart: z.number(),
|
|
1221
|
+
oldCount: z.number(),
|
|
1222
|
+
newStart: z.number(),
|
|
1223
|
+
newCount: z.number(),
|
|
1224
|
+
lines: z.array(DiffLineSchema),
|
|
1225
|
+
});
|
|
1226
|
+
const ParsedDiffFileSchema = z.object({
|
|
1227
|
+
path: z.string(),
|
|
1228
|
+
isNew: z.boolean(),
|
|
1229
|
+
isDeleted: z.boolean(),
|
|
1230
|
+
additions: z.number(),
|
|
1231
|
+
deletions: z.number(),
|
|
1232
|
+
hunks: z.array(DiffHunkSchema),
|
|
1233
|
+
status: z.enum(["ok", "too_large", "binary"]).optional(),
|
|
1234
|
+
});
|
|
1235
|
+
const FileExplorerEntrySchema = z.object({
|
|
1236
|
+
name: z.string(),
|
|
1237
|
+
path: z.string(),
|
|
1238
|
+
kind: z.enum(["file", "directory"]),
|
|
1239
|
+
size: z.number(),
|
|
1240
|
+
modifiedAt: z.string(),
|
|
1241
|
+
});
|
|
1242
|
+
const FileExplorerFileSchema = z.object({
|
|
1243
|
+
path: z.string(),
|
|
1244
|
+
kind: z.enum(["text", "image", "binary"]),
|
|
1245
|
+
encoding: z.enum(["utf-8", "base64", "none"]),
|
|
1246
|
+
content: z.string().optional(),
|
|
1247
|
+
mimeType: z.string().optional(),
|
|
1248
|
+
size: z.number(),
|
|
1249
|
+
modifiedAt: z.string(),
|
|
1250
|
+
});
|
|
1251
|
+
const FileExplorerDirectorySchema = z.object({
|
|
1252
|
+
path: z.string(),
|
|
1253
|
+
entries: z.array(FileExplorerEntrySchema),
|
|
1254
|
+
});
|
|
1255
|
+
export const FileExplorerRequestSchema = z.object({
|
|
1256
|
+
type: z.literal("file_explorer_request"),
|
|
1257
|
+
cwd: z.string(),
|
|
1258
|
+
path: z.string().optional(),
|
|
1259
|
+
mode: z.enum(["list", "file"]),
|
|
1260
|
+
requestId: z.string(),
|
|
1261
|
+
acceptBinary: z.boolean().optional(),
|
|
1262
|
+
});
|
|
1263
|
+
export const ProjectIconRequestSchema = z.object({
|
|
1264
|
+
type: z.literal("project_icon_request"),
|
|
1265
|
+
cwd: z.string(),
|
|
1266
|
+
requestId: z.string(),
|
|
1267
|
+
});
|
|
1268
|
+
export const FileDownloadTokenRequestSchema = z.object({
|
|
1269
|
+
type: z.literal("file_download_token_request"),
|
|
1270
|
+
cwd: z.string(),
|
|
1271
|
+
path: z.string(),
|
|
1272
|
+
requestId: z.string(),
|
|
1273
|
+
});
|
|
1274
|
+
export const ClearAgentAttentionMessageSchema = z.object({
|
|
1275
|
+
type: z.literal("clear_agent_attention"),
|
|
1276
|
+
agentId: z.union([z.string(), z.array(z.string())]),
|
|
1277
|
+
requestId: z.string().optional(),
|
|
1278
|
+
});
|
|
1279
|
+
export const ClientHeartbeatMessageSchema = z.object({
|
|
1280
|
+
type: z.literal("client_heartbeat"),
|
|
1281
|
+
deviceType: z.enum(["web", "mobile"]),
|
|
1282
|
+
focusedAgentId: z.string().nullable(),
|
|
1283
|
+
lastActivityAt: z.string(),
|
|
1284
|
+
appVisible: z.boolean(),
|
|
1285
|
+
appVisibilityChangedAt: z.string().optional(),
|
|
1286
|
+
});
|
|
1287
|
+
export const PingMessageSchema = z.object({
|
|
1288
|
+
type: z.literal("ping"),
|
|
1289
|
+
requestId: z.string(),
|
|
1290
|
+
clientSentAt: z.number().int().optional(),
|
|
1291
|
+
});
|
|
1292
|
+
const ListCommandsDraftConfigSchema = z.object({
|
|
1293
|
+
provider: AgentProviderSchema,
|
|
1294
|
+
cwd: z.string(),
|
|
1295
|
+
modeId: z.string().optional(),
|
|
1296
|
+
model: z.string().optional(),
|
|
1297
|
+
thinkingOptionId: z.string().optional(),
|
|
1298
|
+
featureValues: z.record(z.unknown()).optional(),
|
|
1299
|
+
});
|
|
1300
|
+
export const ListProviderFeaturesRequestMessageSchema = z.object({
|
|
1301
|
+
type: z.literal("list_provider_features_request"),
|
|
1302
|
+
draftConfig: ListCommandsDraftConfigSchema,
|
|
1303
|
+
requestId: z.string(),
|
|
1304
|
+
});
|
|
1305
|
+
export const ListCommandsRequestSchema = z.object({
|
|
1306
|
+
type: z.literal("list_commands_request"),
|
|
1307
|
+
agentId: z.string(),
|
|
1308
|
+
draftConfig: ListCommandsDraftConfigSchema.optional(),
|
|
1309
|
+
requestId: z.string(),
|
|
1310
|
+
});
|
|
1311
|
+
export const RegisterPushTokenMessageSchema = z.object({
|
|
1312
|
+
type: z.literal("register_push_token"),
|
|
1313
|
+
token: z.string(),
|
|
1314
|
+
});
|
|
1315
|
+
// ============================================================================
|
|
1316
|
+
// Terminal Messages
|
|
1317
|
+
// ============================================================================
|
|
1318
|
+
export const ListTerminalsRequestSchema = z.object({
|
|
1319
|
+
type: z.literal("list_terminals_request"),
|
|
1320
|
+
cwd: z.string().optional(),
|
|
1321
|
+
requestId: z.string(),
|
|
1322
|
+
});
|
|
1323
|
+
export const SubscribeTerminalsRequestSchema = z.object({
|
|
1324
|
+
type: z.literal("subscribe_terminals_request"),
|
|
1325
|
+
cwd: z.string(),
|
|
1326
|
+
});
|
|
1327
|
+
export const UnsubscribeTerminalsRequestSchema = z.object({
|
|
1328
|
+
type: z.literal("unsubscribe_terminals_request"),
|
|
1329
|
+
cwd: z.string(),
|
|
1330
|
+
});
|
|
1331
|
+
export const CreateTerminalRequestSchema = z.object({
|
|
1332
|
+
type: z.literal("create_terminal_request"),
|
|
1333
|
+
cwd: z.string(),
|
|
1334
|
+
name: z.string().optional(),
|
|
1335
|
+
agentId: z.string().optional(),
|
|
1336
|
+
command: z.string().optional(),
|
|
1337
|
+
args: z.array(z.string()).optional(),
|
|
1338
|
+
requestId: z.string(),
|
|
1339
|
+
});
|
|
1340
|
+
export const StartWorkspaceScriptRequestSchema = z.object({
|
|
1341
|
+
type: z.literal("start_workspace_script_request"),
|
|
1342
|
+
workspaceId: z.string(),
|
|
1343
|
+
scriptName: z.string(),
|
|
1344
|
+
requestId: z.string(),
|
|
1345
|
+
});
|
|
1346
|
+
export const SubscribeTerminalRequestSchema = z.object({
|
|
1347
|
+
type: z.literal("subscribe_terminal_request"),
|
|
1348
|
+
terminalId: z.string(),
|
|
1349
|
+
requestId: z.string(),
|
|
1350
|
+
});
|
|
1351
|
+
export const UnsubscribeTerminalRequestSchema = z.object({
|
|
1352
|
+
type: z.literal("unsubscribe_terminal_request"),
|
|
1353
|
+
terminalId: z.string(),
|
|
1354
|
+
});
|
|
1355
|
+
const TerminalClientMessageSchema = z.discriminatedUnion("type", [
|
|
1356
|
+
z.object({ type: z.literal("input"), data: z.string() }),
|
|
1357
|
+
z.object({ type: z.literal("resize"), rows: z.number(), cols: z.number() }),
|
|
1358
|
+
z.object({
|
|
1359
|
+
type: z.literal("mouse"),
|
|
1360
|
+
row: z.number(),
|
|
1361
|
+
col: z.number(),
|
|
1362
|
+
button: z.number(),
|
|
1363
|
+
action: z.enum(["down", "up", "move"]),
|
|
1364
|
+
}),
|
|
1365
|
+
]);
|
|
1366
|
+
export const TerminalInputSchema = z.object({
|
|
1367
|
+
type: z.literal("terminal_input"),
|
|
1368
|
+
terminalId: z.string(),
|
|
1369
|
+
message: TerminalClientMessageSchema,
|
|
1370
|
+
});
|
|
1371
|
+
export const KillTerminalRequestSchema = z.object({
|
|
1372
|
+
type: z.literal("kill_terminal_request"),
|
|
1373
|
+
terminalId: z.string(),
|
|
1374
|
+
requestId: z.string(),
|
|
1375
|
+
});
|
|
1376
|
+
export const CaptureTerminalRequestSchema = z.object({
|
|
1377
|
+
type: z.literal("capture_terminal_request"),
|
|
1378
|
+
terminalId: z.string(),
|
|
1379
|
+
start: z.number().int().optional(),
|
|
1380
|
+
end: z.number().int().optional(),
|
|
1381
|
+
stripAnsi: z.boolean().default(true),
|
|
1382
|
+
requestId: z.string(),
|
|
1383
|
+
});
|
|
1384
|
+
export const SessionInboundMessageSchema = z.discriminatedUnion("type", [
|
|
1385
|
+
VoiceAudioChunkMessageSchema,
|
|
1386
|
+
AbortRequestMessageSchema,
|
|
1387
|
+
AudioPlayedMessageSchema,
|
|
1388
|
+
FetchAgentsRequestMessageSchema,
|
|
1389
|
+
FetchAgentHistoryRequestMessageSchema,
|
|
1390
|
+
FetchWorkspacesRequestMessageSchema,
|
|
1391
|
+
FetchAgentRequestMessageSchema,
|
|
1392
|
+
DeleteAgentRequestMessageSchema,
|
|
1393
|
+
ArchiveAgentRequestMessageSchema,
|
|
1394
|
+
CloseItemsRequestMessageSchema,
|
|
1395
|
+
UpdateAgentRequestMessageSchema,
|
|
1396
|
+
SetVoiceModeMessageSchema,
|
|
1397
|
+
SendAgentMessageRequestSchema,
|
|
1398
|
+
WaitForFinishRequestSchema,
|
|
1399
|
+
GetDaemonConfigRequestMessageSchema,
|
|
1400
|
+
SetDaemonConfigRequestMessageSchema,
|
|
1401
|
+
ReadProjectConfigRequestMessageSchema,
|
|
1402
|
+
WriteProjectConfigRequestMessageSchema,
|
|
1403
|
+
DictationStreamStartMessageSchema,
|
|
1404
|
+
DictationStreamChunkMessageSchema,
|
|
1405
|
+
DictationStreamFinishMessageSchema,
|
|
1406
|
+
DictationStreamCancelMessageSchema,
|
|
1407
|
+
CreateAgentRequestMessageSchema,
|
|
1408
|
+
ListProviderModelsRequestMessageSchema,
|
|
1409
|
+
ListProviderModesRequestMessageSchema,
|
|
1410
|
+
ListProviderFeaturesRequestMessageSchema,
|
|
1411
|
+
ListAvailableProvidersRequestMessageSchema,
|
|
1412
|
+
GetProvidersSnapshotRequestMessageSchema,
|
|
1413
|
+
RefreshProvidersSnapshotRequestMessageSchema,
|
|
1414
|
+
ProviderDiagnosticRequestMessageSchema,
|
|
1415
|
+
ResumeAgentRequestMessageSchema,
|
|
1416
|
+
ImportAgentRequestMessageSchema,
|
|
1417
|
+
RefreshAgentRequestMessageSchema,
|
|
1418
|
+
CancelAgentRequestMessageSchema,
|
|
1419
|
+
ShutdownServerRequestMessageSchema,
|
|
1420
|
+
RestartServerRequestMessageSchema,
|
|
1421
|
+
FetchAgentTimelineRequestMessageSchema,
|
|
1422
|
+
SetAgentModeRequestMessageSchema,
|
|
1423
|
+
SetAgentModelRequestMessageSchema,
|
|
1424
|
+
SetAgentThinkingRequestMessageSchema,
|
|
1425
|
+
SetAgentFeatureRequestMessageSchema,
|
|
1426
|
+
AgentPermissionResponseMessageSchema,
|
|
1427
|
+
CheckoutStatusRequestSchema,
|
|
1428
|
+
SubscribeCheckoutDiffRequestSchema,
|
|
1429
|
+
UnsubscribeCheckoutDiffRequestSchema,
|
|
1430
|
+
CheckoutCommitRequestSchema,
|
|
1431
|
+
CheckoutMergeRequestSchema,
|
|
1432
|
+
CheckoutMergeFromBaseRequestSchema,
|
|
1433
|
+
CheckoutPullRequestSchema,
|
|
1434
|
+
CheckoutPushRequestSchema,
|
|
1435
|
+
CheckoutPrCreateRequestSchema,
|
|
1436
|
+
CheckoutPrStatusRequestSchema,
|
|
1437
|
+
PullRequestTimelineRequestSchema,
|
|
1438
|
+
CheckoutSwitchBranchRequestSchema,
|
|
1439
|
+
StashSaveRequestSchema,
|
|
1440
|
+
StashPopRequestSchema,
|
|
1441
|
+
StashListRequestSchema,
|
|
1442
|
+
ValidateBranchRequestSchema,
|
|
1443
|
+
BranchSuggestionsRequestSchema,
|
|
1444
|
+
GitHubSearchRequestSchema,
|
|
1445
|
+
DirectorySuggestionsRequestSchema,
|
|
1446
|
+
PaseoWorktreeListRequestSchema,
|
|
1447
|
+
PaseoWorktreeArchiveRequestSchema,
|
|
1448
|
+
CreatePaseoWorktreeRequestSchema,
|
|
1449
|
+
WorkspaceSetupStatusRequestSchema,
|
|
1450
|
+
ListAvailableEditorsRequestSchema,
|
|
1451
|
+
OpenInEditorRequestSchema,
|
|
1452
|
+
OpenProjectRequestSchema,
|
|
1453
|
+
ArchiveWorkspaceRequestSchema,
|
|
1454
|
+
FileExplorerRequestSchema,
|
|
1455
|
+
ProjectIconRequestSchema,
|
|
1456
|
+
FileDownloadTokenRequestSchema,
|
|
1457
|
+
ClearAgentAttentionMessageSchema,
|
|
1458
|
+
ClientHeartbeatMessageSchema,
|
|
1459
|
+
PingMessageSchema,
|
|
1460
|
+
ListCommandsRequestSchema,
|
|
1461
|
+
RegisterPushTokenMessageSchema,
|
|
1462
|
+
ListTerminalsRequestSchema,
|
|
1463
|
+
SubscribeTerminalsRequestSchema,
|
|
1464
|
+
UnsubscribeTerminalsRequestSchema,
|
|
1465
|
+
CreateTerminalRequestSchema,
|
|
1466
|
+
StartWorkspaceScriptRequestSchema,
|
|
1467
|
+
SubscribeTerminalRequestSchema,
|
|
1468
|
+
UnsubscribeTerminalRequestSchema,
|
|
1469
|
+
TerminalInputSchema,
|
|
1470
|
+
KillTerminalRequestSchema,
|
|
1471
|
+
CaptureTerminalRequestSchema,
|
|
1472
|
+
ChatCreateRequestSchema,
|
|
1473
|
+
ChatListRequestSchema,
|
|
1474
|
+
ChatInspectRequestSchema,
|
|
1475
|
+
ChatDeleteRequestSchema,
|
|
1476
|
+
ChatPostRequestSchema,
|
|
1477
|
+
ChatReadRequestSchema,
|
|
1478
|
+
ChatWaitRequestSchema,
|
|
1479
|
+
ScheduleCreateRequestSchema,
|
|
1480
|
+
ScheduleListRequestSchema,
|
|
1481
|
+
ScheduleInspectRequestSchema,
|
|
1482
|
+
ScheduleLogsRequestSchema,
|
|
1483
|
+
SchedulePauseRequestSchema,
|
|
1484
|
+
ScheduleResumeRequestSchema,
|
|
1485
|
+
ScheduleDeleteRequestSchema,
|
|
1486
|
+
LoopRunRequestSchema,
|
|
1487
|
+
LoopListRequestSchema,
|
|
1488
|
+
LoopInspectRequestSchema,
|
|
1489
|
+
LoopLogsRequestSchema,
|
|
1490
|
+
LoopStopRequestSchema,
|
|
1491
|
+
]);
|
|
1492
|
+
// ============================================================================
|
|
1493
|
+
// Session Outbound Messages (Session emits these)
|
|
1494
|
+
// ============================================================================
|
|
1495
|
+
export const ActivityLogPayloadSchema = z.object({
|
|
1496
|
+
id: z.string(),
|
|
1497
|
+
timestamp: z.coerce.date(),
|
|
1498
|
+
type: z.enum(["transcript", "assistant", "tool_call", "tool_result", "error", "system"]),
|
|
1499
|
+
content: z.string(),
|
|
1500
|
+
metadata: z.record(z.unknown()).optional(),
|
|
1501
|
+
});
|
|
1502
|
+
export const ActivityLogMessageSchema = z.object({
|
|
1503
|
+
type: z.literal("activity_log"),
|
|
1504
|
+
payload: ActivityLogPayloadSchema,
|
|
1505
|
+
});
|
|
1506
|
+
export const AssistantChunkMessageSchema = z.object({
|
|
1507
|
+
type: z.literal("assistant_chunk"),
|
|
1508
|
+
payload: z.object({
|
|
1509
|
+
chunk: z.string(),
|
|
1510
|
+
}),
|
|
1511
|
+
});
|
|
1512
|
+
export const AudioOutputMessageSchema = z.object({
|
|
1513
|
+
type: z.literal("audio_output"),
|
|
1514
|
+
payload: z.object({
|
|
1515
|
+
audio: z.string(), // base64 encoded
|
|
1516
|
+
format: z.string(),
|
|
1517
|
+
id: z.string(),
|
|
1518
|
+
isVoiceMode: z.boolean(), // Mode when audio was generated (for drift protection)
|
|
1519
|
+
groupId: z.string().optional(), // Logical utterance id
|
|
1520
|
+
chunkIndex: z.number().int().nonnegative().optional(),
|
|
1521
|
+
isLastChunk: z.boolean().optional(),
|
|
1522
|
+
}),
|
|
1523
|
+
});
|
|
1524
|
+
export const TranscriptionResultMessageSchema = z.object({
|
|
1525
|
+
type: z.literal("transcription_result"),
|
|
1526
|
+
payload: z.object({
|
|
1527
|
+
text: z.string(),
|
|
1528
|
+
language: z.string().optional(),
|
|
1529
|
+
duration: z.number().optional(),
|
|
1530
|
+
requestId: z.string(), // Echoed back from request for tracking
|
|
1531
|
+
avgLogprob: z.number().optional(),
|
|
1532
|
+
isLowConfidence: z.boolean().optional(),
|
|
1533
|
+
byteLength: z.number().optional(),
|
|
1534
|
+
format: z.string().optional(),
|
|
1535
|
+
debugRecordingPath: z.string().optional(),
|
|
1536
|
+
}),
|
|
1537
|
+
});
|
|
1538
|
+
export const VoiceInputStateMessageSchema = z.object({
|
|
1539
|
+
type: z.literal("voice_input_state"),
|
|
1540
|
+
payload: z.object({
|
|
1541
|
+
isSpeaking: z.boolean(),
|
|
1542
|
+
}),
|
|
1543
|
+
});
|
|
1544
|
+
export const DictationStreamAckMessageSchema = z.object({
|
|
1545
|
+
type: z.literal("dictation_stream_ack"),
|
|
1546
|
+
payload: z.object({
|
|
1547
|
+
dictationId: z.string(),
|
|
1548
|
+
ackSeq: z.number().int(),
|
|
1549
|
+
}),
|
|
1550
|
+
});
|
|
1551
|
+
export const DictationStreamFinishAcceptedMessageSchema = z.object({
|
|
1552
|
+
type: z.literal("dictation_stream_finish_accepted"),
|
|
1553
|
+
payload: z.object({
|
|
1554
|
+
dictationId: z.string(),
|
|
1555
|
+
timeoutMs: z.number().int().positive(),
|
|
1556
|
+
}),
|
|
1557
|
+
});
|
|
1558
|
+
export const DictationStreamPartialMessageSchema = z.object({
|
|
1559
|
+
type: z.literal("dictation_stream_partial"),
|
|
1560
|
+
payload: z.object({
|
|
1561
|
+
dictationId: z.string(),
|
|
1562
|
+
text: z.string(),
|
|
1563
|
+
}),
|
|
1564
|
+
});
|
|
1565
|
+
export const DictationStreamFinalMessageSchema = z.object({
|
|
1566
|
+
type: z.literal("dictation_stream_final"),
|
|
1567
|
+
payload: z.object({
|
|
1568
|
+
dictationId: z.string(),
|
|
1569
|
+
text: z.string(),
|
|
1570
|
+
debugRecordingPath: z.string().optional(),
|
|
1571
|
+
}),
|
|
1572
|
+
});
|
|
1573
|
+
export const DictationStreamErrorMessageSchema = z.object({
|
|
1574
|
+
type: z.literal("dictation_stream_error"),
|
|
1575
|
+
payload: z.object({
|
|
1576
|
+
dictationId: z.string(),
|
|
1577
|
+
error: z.string(),
|
|
1578
|
+
retryable: z.boolean(),
|
|
1579
|
+
reasonCode: z.string().optional(),
|
|
1580
|
+
missingModelIds: z.array(z.string()).optional(),
|
|
1581
|
+
debugRecordingPath: z.string().optional(),
|
|
1582
|
+
}),
|
|
1583
|
+
});
|
|
1584
|
+
export const ServerCapabilityStateSchema = z.object({
|
|
1585
|
+
enabled: z.boolean(),
|
|
1586
|
+
reason: z.string(),
|
|
1587
|
+
});
|
|
1588
|
+
export const ServerVoiceCapabilitiesSchema = z.object({
|
|
1589
|
+
dictation: ServerCapabilityStateSchema,
|
|
1590
|
+
voice: ServerCapabilityStateSchema,
|
|
1591
|
+
});
|
|
1592
|
+
export const ServerCapabilitiesSchema = z
|
|
1593
|
+
.object({
|
|
1594
|
+
voice: ServerVoiceCapabilitiesSchema.optional(),
|
|
1595
|
+
})
|
|
1596
|
+
.passthrough();
|
|
1597
|
+
const ServerInfoHostnameSchema = z.unknown().transform((value) => {
|
|
1598
|
+
if (typeof value !== "string") {
|
|
1599
|
+
return null;
|
|
1600
|
+
}
|
|
1601
|
+
const trimmed = value.trim();
|
|
1602
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1603
|
+
});
|
|
1604
|
+
const ServerInfoVersionSchema = z.unknown().transform((value) => {
|
|
1605
|
+
if (typeof value !== "string") {
|
|
1606
|
+
return null;
|
|
1607
|
+
}
|
|
1608
|
+
const trimmed = value.trim();
|
|
1609
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1610
|
+
});
|
|
1611
|
+
const ServerCapabilitiesFromUnknownSchema = z
|
|
1612
|
+
.unknown()
|
|
1613
|
+
.optional()
|
|
1614
|
+
.transform((value) => {
|
|
1615
|
+
if (value === undefined) {
|
|
1616
|
+
return undefined;
|
|
1617
|
+
}
|
|
1618
|
+
const parsed = ServerCapabilitiesSchema.safeParse(value);
|
|
1619
|
+
if (!parsed.success) {
|
|
1620
|
+
return undefined;
|
|
1621
|
+
}
|
|
1622
|
+
return parsed.data;
|
|
1623
|
+
});
|
|
1624
|
+
export const ServerInfoStatusPayloadSchema = z
|
|
1625
|
+
.object({
|
|
1626
|
+
status: z.literal("server_info"),
|
|
1627
|
+
serverId: z.string().trim().min(1),
|
|
1628
|
+
hostname: ServerInfoHostnameSchema.optional(),
|
|
1629
|
+
version: ServerInfoVersionSchema.optional(),
|
|
1630
|
+
capabilities: ServerCapabilitiesFromUnknownSchema,
|
|
1631
|
+
// COMPAT(providersSnapshot): added in v0.1.48, remove gating when all clients use snapshot
|
|
1632
|
+
features: z
|
|
1633
|
+
.object({
|
|
1634
|
+
providersSnapshot: z.boolean().optional(),
|
|
1635
|
+
})
|
|
1636
|
+
.optional(),
|
|
1637
|
+
})
|
|
1638
|
+
.passthrough()
|
|
1639
|
+
.transform((payload) => ({
|
|
1640
|
+
...payload,
|
|
1641
|
+
hostname: payload.hostname ?? null,
|
|
1642
|
+
version: payload.version ?? null,
|
|
1643
|
+
}));
|
|
1644
|
+
export const StatusMessageSchema = z.object({
|
|
1645
|
+
type: z.literal("status"),
|
|
1646
|
+
payload: z
|
|
1647
|
+
.object({
|
|
1648
|
+
status: z.string(),
|
|
1649
|
+
})
|
|
1650
|
+
.passthrough(), // Allow additional fields
|
|
1651
|
+
});
|
|
1652
|
+
export const PongMessageSchema = z.object({
|
|
1653
|
+
type: z.literal("pong"),
|
|
1654
|
+
payload: z.object({
|
|
1655
|
+
requestId: z.string(),
|
|
1656
|
+
clientSentAt: z.number().int().optional(),
|
|
1657
|
+
serverReceivedAt: z.number().int(),
|
|
1658
|
+
serverSentAt: z.number().int(),
|
|
1659
|
+
}),
|
|
1660
|
+
});
|
|
1661
|
+
export const RpcErrorMessageSchema = z.object({
|
|
1662
|
+
type: z.literal("rpc_error"),
|
|
1663
|
+
payload: z.object({
|
|
1664
|
+
requestId: z.string(),
|
|
1665
|
+
requestType: z.string().optional(),
|
|
1666
|
+
error: z.string(),
|
|
1667
|
+
code: z.string().optional(),
|
|
1668
|
+
}),
|
|
1669
|
+
});
|
|
1670
|
+
const AgentStatusWithRequestSchema = z.object({
|
|
1671
|
+
agentId: z.string(),
|
|
1672
|
+
requestId: z.string(),
|
|
1673
|
+
});
|
|
1674
|
+
const AgentStatusWithTimelineSchema = AgentStatusWithRequestSchema.extend({
|
|
1675
|
+
timelineSize: z.number().optional(),
|
|
1676
|
+
});
|
|
1677
|
+
export const AgentCreatedStatusPayloadSchema = z
|
|
1678
|
+
.object({
|
|
1679
|
+
status: z.literal("agent_created"),
|
|
1680
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1681
|
+
})
|
|
1682
|
+
.extend(AgentStatusWithRequestSchema.shape);
|
|
1683
|
+
export const AgentCreateFailedStatusPayloadSchema = z.object({
|
|
1684
|
+
status: z.literal("agent_create_failed"),
|
|
1685
|
+
requestId: z.string(),
|
|
1686
|
+
error: z.string(),
|
|
1687
|
+
errorCode: z.string().optional(),
|
|
1688
|
+
});
|
|
1689
|
+
export const AgentResumedStatusPayloadSchema = z
|
|
1690
|
+
.object({
|
|
1691
|
+
status: z.literal("agent_resumed"),
|
|
1692
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1693
|
+
})
|
|
1694
|
+
.extend(AgentStatusWithTimelineSchema.shape);
|
|
1695
|
+
export const AgentRefreshedStatusPayloadSchema = z
|
|
1696
|
+
.object({
|
|
1697
|
+
status: z.literal("agent_refreshed"),
|
|
1698
|
+
})
|
|
1699
|
+
.extend(AgentStatusWithTimelineSchema.shape);
|
|
1700
|
+
export const RestartRequestedStatusPayloadSchema = z.object({
|
|
1701
|
+
status: z.literal("restart_requested"),
|
|
1702
|
+
clientId: z.string(),
|
|
1703
|
+
reason: z.string().optional(),
|
|
1704
|
+
requestId: z.string(),
|
|
1705
|
+
});
|
|
1706
|
+
export const ShutdownRequestedStatusPayloadSchema = z.object({
|
|
1707
|
+
status: z.literal("shutdown_requested"),
|
|
1708
|
+
clientId: z.string(),
|
|
1709
|
+
requestId: z.string(),
|
|
1710
|
+
});
|
|
1711
|
+
export const DaemonConfigChangedStatusPayloadSchema = z
|
|
1712
|
+
.object({
|
|
1713
|
+
status: z.literal("daemon_config_changed"),
|
|
1714
|
+
config: MutableDaemonConfigSchema,
|
|
1715
|
+
})
|
|
1716
|
+
.passthrough();
|
|
1717
|
+
export const KnownStatusPayloadSchema = z.discriminatedUnion("status", [
|
|
1718
|
+
AgentCreatedStatusPayloadSchema,
|
|
1719
|
+
AgentCreateFailedStatusPayloadSchema,
|
|
1720
|
+
AgentResumedStatusPayloadSchema,
|
|
1721
|
+
AgentRefreshedStatusPayloadSchema,
|
|
1722
|
+
ShutdownRequestedStatusPayloadSchema,
|
|
1723
|
+
RestartRequestedStatusPayloadSchema,
|
|
1724
|
+
DaemonConfigChangedStatusPayloadSchema,
|
|
1725
|
+
]);
|
|
1726
|
+
export const ArtifactMessageSchema = z.object({
|
|
1727
|
+
type: z.literal("artifact"),
|
|
1728
|
+
payload: z.object({
|
|
1729
|
+
type: z.enum(["markdown", "diff", "image", "code"]),
|
|
1730
|
+
id: z.string(),
|
|
1731
|
+
title: z.string(),
|
|
1732
|
+
content: z.string(),
|
|
1733
|
+
isBase64: z.boolean(),
|
|
1734
|
+
}),
|
|
1735
|
+
});
|
|
1736
|
+
export const ProjectCheckoutLiteNotGitPayloadSchema = z
|
|
1737
|
+
.object({
|
|
1738
|
+
cwd: z.string(),
|
|
1739
|
+
isGit: z.literal(false),
|
|
1740
|
+
currentBranch: z.null(),
|
|
1741
|
+
remoteUrl: z.null(),
|
|
1742
|
+
worktreeRoot: z.null().optional(),
|
|
1743
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
1744
|
+
mainRepoRoot: z.null(),
|
|
1745
|
+
})
|
|
1746
|
+
.transform((value) => ({
|
|
1747
|
+
...value,
|
|
1748
|
+
worktreeRoot: null,
|
|
1749
|
+
}));
|
|
1750
|
+
export const ProjectCheckoutLiteGitNonPaseoPayloadSchema = z
|
|
1751
|
+
.object({
|
|
1752
|
+
cwd: z.string(),
|
|
1753
|
+
isGit: z.literal(true),
|
|
1754
|
+
currentBranch: z.string().nullable(),
|
|
1755
|
+
remoteUrl: z.string().nullable(),
|
|
1756
|
+
worktreeRoot: z.string().optional(),
|
|
1757
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
1758
|
+
mainRepoRoot: z.string().nullable().optional().default(null),
|
|
1759
|
+
})
|
|
1760
|
+
.transform((value) => ({
|
|
1761
|
+
...value,
|
|
1762
|
+
worktreeRoot: value.worktreeRoot ?? value.cwd,
|
|
1763
|
+
}));
|
|
1764
|
+
export const ProjectCheckoutLiteGitPaseoPayloadSchema = z
|
|
1765
|
+
.object({
|
|
1766
|
+
cwd: z.string(),
|
|
1767
|
+
isGit: z.literal(true),
|
|
1768
|
+
currentBranch: z.string().nullable(),
|
|
1769
|
+
remoteUrl: z.string().nullable(),
|
|
1770
|
+
worktreeRoot: z.string().optional(),
|
|
1771
|
+
isPaseoOwnedWorktree: z.literal(true),
|
|
1772
|
+
mainRepoRoot: z.string(),
|
|
1773
|
+
})
|
|
1774
|
+
.transform((value) => ({
|
|
1775
|
+
...value,
|
|
1776
|
+
worktreeRoot: value.worktreeRoot ?? value.cwd,
|
|
1777
|
+
}));
|
|
1778
|
+
export const ProjectCheckoutLitePayloadSchema = z.union([
|
|
1779
|
+
ProjectCheckoutLiteNotGitPayloadSchema,
|
|
1780
|
+
ProjectCheckoutLiteGitNonPaseoPayloadSchema,
|
|
1781
|
+
ProjectCheckoutLiteGitPaseoPayloadSchema,
|
|
1782
|
+
]);
|
|
1783
|
+
export const ProjectPlacementPayloadSchema = z.object({
|
|
1784
|
+
projectKey: z.string(),
|
|
1785
|
+
projectName: z.string(),
|
|
1786
|
+
checkout: ProjectCheckoutLitePayloadSchema,
|
|
1787
|
+
});
|
|
1788
|
+
export const WorkspaceScriptLifecycleSchema = z.enum(["running", "stopped"]);
|
|
1789
|
+
export const WorkspaceScriptHealthSchema = z.enum(["healthy", "unhealthy"]);
|
|
1790
|
+
export const WorkspaceScriptPayloadSchema = z.object({
|
|
1791
|
+
scriptName: z.string(),
|
|
1792
|
+
type: z.enum(["script", "service"]).optional().default("service"),
|
|
1793
|
+
hostname: z.string(),
|
|
1794
|
+
port: z.number().int().positive().nullable(),
|
|
1795
|
+
proxyUrl: z.string().nullable().optional().default(null),
|
|
1796
|
+
lifecycle: WorkspaceScriptLifecycleSchema,
|
|
1797
|
+
health: WorkspaceScriptHealthSchema.nullable(),
|
|
1798
|
+
exitCode: z.number().nullable().optional().default(null),
|
|
1799
|
+
terminalId: z.string().nullable().optional().default(null),
|
|
1800
|
+
});
|
|
1801
|
+
const WorkspaceGitRuntimePayloadSchema = z
|
|
1802
|
+
.object({
|
|
1803
|
+
currentBranch: z.string().nullable().optional(),
|
|
1804
|
+
remoteUrl: z.string().nullable().optional(),
|
|
1805
|
+
isPaseoOwnedWorktree: z.boolean().optional(),
|
|
1806
|
+
isDirty: z.boolean().nullable().optional(),
|
|
1807
|
+
aheadBehind: z
|
|
1808
|
+
.object({
|
|
1809
|
+
ahead: z.number(),
|
|
1810
|
+
behind: z.number(),
|
|
1811
|
+
})
|
|
1812
|
+
.nullable()
|
|
1813
|
+
.optional(),
|
|
1814
|
+
aheadOfOrigin: z.number().nullable().optional(),
|
|
1815
|
+
behindOfOrigin: z.number().nullable().optional(),
|
|
1816
|
+
})
|
|
1817
|
+
.optional()
|
|
1818
|
+
.nullable();
|
|
1819
|
+
const WorkspaceGitHubRuntimePayloadSchema = z
|
|
1820
|
+
.object({
|
|
1821
|
+
featuresEnabled: z.boolean().optional(),
|
|
1822
|
+
pullRequest: z
|
|
1823
|
+
.object({
|
|
1824
|
+
url: z.string(),
|
|
1825
|
+
title: z.string(),
|
|
1826
|
+
state: z.string(),
|
|
1827
|
+
baseRefName: z.string(),
|
|
1828
|
+
headRefName: z.string(),
|
|
1829
|
+
isMerged: z.boolean(),
|
|
1830
|
+
})
|
|
1831
|
+
.nullable()
|
|
1832
|
+
.optional(),
|
|
1833
|
+
error: z
|
|
1834
|
+
.object({
|
|
1835
|
+
message: z.string(),
|
|
1836
|
+
})
|
|
1837
|
+
.nullable()
|
|
1838
|
+
.optional(),
|
|
1839
|
+
refreshedAt: z.string().nullable().optional(),
|
|
1840
|
+
})
|
|
1841
|
+
.optional()
|
|
1842
|
+
.nullable();
|
|
1843
|
+
export const WorkspaceDescriptorPayloadSchema = z
|
|
1844
|
+
.object({
|
|
1845
|
+
id: z.string(),
|
|
1846
|
+
projectId: z.string(),
|
|
1847
|
+
projectDisplayName: z.string(),
|
|
1848
|
+
projectRootPath: z.string(),
|
|
1849
|
+
workspaceDirectory: z.string().optional(),
|
|
1850
|
+
projectKind: z.enum(["git", "non_git", "directory"]),
|
|
1851
|
+
// COMPAT(workspaces): keep legacy directory workspace kind parseable.
|
|
1852
|
+
workspaceKind: z.enum(["directory", "local_checkout", "checkout", "worktree"]),
|
|
1853
|
+
name: z.string(),
|
|
1854
|
+
archivingAt: z.string().nullable().optional().default(null),
|
|
1855
|
+
status: WorkspaceStateBucketSchema,
|
|
1856
|
+
activityAt: z.string().nullable(),
|
|
1857
|
+
diffStat: z
|
|
1858
|
+
.object({
|
|
1859
|
+
additions: z.number(),
|
|
1860
|
+
deletions: z.number(),
|
|
1861
|
+
})
|
|
1862
|
+
.nullable()
|
|
1863
|
+
.optional(),
|
|
1864
|
+
scripts: z.array(WorkspaceScriptPayloadSchema).default([]),
|
|
1865
|
+
gitRuntime: WorkspaceGitRuntimePayloadSchema,
|
|
1866
|
+
githubRuntime: WorkspaceGitHubRuntimePayloadSchema,
|
|
1867
|
+
project: ProjectPlacementPayloadSchema.optional(),
|
|
1868
|
+
})
|
|
1869
|
+
.transform((workspace) => ({
|
|
1870
|
+
...workspace,
|
|
1871
|
+
workspaceDirectory: workspace.workspaceDirectory ?? workspace.projectRootPath,
|
|
1872
|
+
}));
|
|
1873
|
+
export const AgentUpdateMessageSchema = z.object({
|
|
1874
|
+
type: z.literal("agent_update"),
|
|
1875
|
+
payload: z.discriminatedUnion("kind", [
|
|
1876
|
+
z.object({
|
|
1877
|
+
kind: z.literal("upsert"),
|
|
1878
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1879
|
+
project: ProjectPlacementPayloadSchema.nullable().optional(),
|
|
1880
|
+
}),
|
|
1881
|
+
z.object({
|
|
1882
|
+
kind: z.literal("remove"),
|
|
1883
|
+
agentId: z.string(),
|
|
1884
|
+
}),
|
|
1885
|
+
]),
|
|
1886
|
+
});
|
|
1887
|
+
export const AgentStreamMessageSchema = z.object({
|
|
1888
|
+
type: z.literal("agent_stream"),
|
|
1889
|
+
payload: z.object({
|
|
1890
|
+
agentId: z.string(),
|
|
1891
|
+
event: AgentStreamEventPayloadSchema,
|
|
1892
|
+
timestamp: z.string(),
|
|
1893
|
+
// Present for timeline events. Maps 1:1 to canonical in-memory timeline rows.
|
|
1894
|
+
seq: z.number().int().nonnegative().optional(),
|
|
1895
|
+
epoch: z.string().optional(),
|
|
1896
|
+
}),
|
|
1897
|
+
});
|
|
1898
|
+
export const AgentStatusMessageSchema = z.object({
|
|
1899
|
+
type: z.literal("agent_status"),
|
|
1900
|
+
payload: z.object({
|
|
1901
|
+
agentId: z.string(),
|
|
1902
|
+
status: z.string(),
|
|
1903
|
+
info: AgentSnapshotPayloadSchema,
|
|
1904
|
+
}),
|
|
1905
|
+
});
|
|
1906
|
+
export const AgentListMessageSchema = z.object({
|
|
1907
|
+
type: z.literal("agent_list"),
|
|
1908
|
+
payload: z.object({
|
|
1909
|
+
agents: z.array(AgentSnapshotPayloadSchema),
|
|
1910
|
+
}),
|
|
1911
|
+
});
|
|
1912
|
+
const AgentDirectoryResponseEntrySchema = z.object({
|
|
1913
|
+
agent: AgentSnapshotPayloadSchema,
|
|
1914
|
+
project: ProjectPlacementPayloadSchema,
|
|
1915
|
+
});
|
|
1916
|
+
const AgentDirectoryPageInfoSchema = z.object({
|
|
1917
|
+
nextCursor: z.string().nullable(),
|
|
1918
|
+
prevCursor: z.string().nullable(),
|
|
1919
|
+
hasMore: z.boolean(),
|
|
1920
|
+
});
|
|
1921
|
+
export const FetchAgentsResponseMessageSchema = z.object({
|
|
1922
|
+
type: z.literal("fetch_agents_response"),
|
|
1923
|
+
payload: z.object({
|
|
1924
|
+
requestId: z.string(),
|
|
1925
|
+
subscriptionId: z.string().nullable().optional(),
|
|
1926
|
+
entries: z.array(AgentDirectoryResponseEntrySchema),
|
|
1927
|
+
pageInfo: AgentDirectoryPageInfoSchema,
|
|
1928
|
+
}),
|
|
1929
|
+
});
|
|
1930
|
+
export const FetchAgentHistoryResponseMessageSchema = z.object({
|
|
1931
|
+
type: z.literal("fetch_agent_history_response"),
|
|
1932
|
+
payload: z.object({
|
|
1933
|
+
requestId: z.string(),
|
|
1934
|
+
entries: z.array(AgentDirectoryResponseEntrySchema),
|
|
1935
|
+
pageInfo: AgentDirectoryPageInfoSchema,
|
|
1936
|
+
}),
|
|
1937
|
+
});
|
|
1938
|
+
export const FetchWorkspacesResponseMessageSchema = z.object({
|
|
1939
|
+
type: z.literal("fetch_workspaces_response"),
|
|
1940
|
+
payload: z.object({
|
|
1941
|
+
requestId: z.string(),
|
|
1942
|
+
subscriptionId: z.string().nullable().optional(),
|
|
1943
|
+
entries: z.array(WorkspaceDescriptorPayloadSchema),
|
|
1944
|
+
pageInfo: z.object({
|
|
1945
|
+
nextCursor: z.string().nullable(),
|
|
1946
|
+
prevCursor: z.string().nullable(),
|
|
1947
|
+
hasMore: z.boolean(),
|
|
1948
|
+
}),
|
|
1949
|
+
}),
|
|
1950
|
+
});
|
|
1951
|
+
export const WorkspaceUpdateMessageSchema = z.object({
|
|
1952
|
+
type: z.literal("workspace_update"),
|
|
1953
|
+
payload: z.discriminatedUnion("kind", [
|
|
1954
|
+
z.object({
|
|
1955
|
+
kind: z.literal("upsert"),
|
|
1956
|
+
workspace: WorkspaceDescriptorPayloadSchema,
|
|
1957
|
+
}),
|
|
1958
|
+
z.object({
|
|
1959
|
+
kind: z.literal("remove"),
|
|
1960
|
+
id: z.string(),
|
|
1961
|
+
}),
|
|
1962
|
+
]),
|
|
1963
|
+
});
|
|
1964
|
+
export const ScriptStatusUpdateMessageSchema = z.object({
|
|
1965
|
+
type: z.literal("script_status_update"),
|
|
1966
|
+
payload: z.object({
|
|
1967
|
+
workspaceId: z.string(),
|
|
1968
|
+
scripts: z.array(WorkspaceScriptPayloadSchema),
|
|
1969
|
+
}),
|
|
1970
|
+
});
|
|
1971
|
+
export const WorkspaceSetupProgressMessageSchema = z.object({
|
|
1972
|
+
type: z.literal("workspace_setup_progress"),
|
|
1973
|
+
payload: z.object({
|
|
1974
|
+
workspaceId: z.string(),
|
|
1975
|
+
status: z.enum(["running", "completed", "failed"]),
|
|
1976
|
+
detail: WorktreeSetupDetailPayloadSchema,
|
|
1977
|
+
error: z.string().nullable(),
|
|
1978
|
+
}),
|
|
1979
|
+
});
|
|
1980
|
+
export const WorkspaceSetupSnapshotSchema = z.object({
|
|
1981
|
+
status: z.enum(["running", "completed", "failed"]),
|
|
1982
|
+
detail: WorktreeSetupDetailPayloadSchema,
|
|
1983
|
+
error: z.string().nullable(),
|
|
1984
|
+
});
|
|
1985
|
+
export const WorkspaceSetupStatusResponseMessageSchema = z.object({
|
|
1986
|
+
type: z.literal("workspace_setup_status_response"),
|
|
1987
|
+
payload: z.object({
|
|
1988
|
+
requestId: z.string(),
|
|
1989
|
+
workspaceId: z.string(),
|
|
1990
|
+
snapshot: WorkspaceSetupSnapshotSchema.nullable(),
|
|
1991
|
+
}),
|
|
1992
|
+
});
|
|
1993
|
+
export const OpenProjectResponseMessageSchema = z.object({
|
|
1994
|
+
type: z.literal("open_project_response"),
|
|
1995
|
+
payload: z.object({
|
|
1996
|
+
requestId: z.string(),
|
|
1997
|
+
workspace: WorkspaceDescriptorPayloadSchema.nullable(),
|
|
1998
|
+
error: z.string().nullable(),
|
|
1999
|
+
}),
|
|
2000
|
+
});
|
|
2001
|
+
export const StartWorkspaceScriptResponseMessageSchema = z.object({
|
|
2002
|
+
type: z.literal("start_workspace_script_response"),
|
|
2003
|
+
payload: z.object({
|
|
2004
|
+
requestId: z.string(),
|
|
2005
|
+
workspaceId: z.string(),
|
|
2006
|
+
scriptName: z.string(),
|
|
2007
|
+
terminalId: z.string().nullable(),
|
|
2008
|
+
error: z.string().nullable(),
|
|
2009
|
+
}),
|
|
2010
|
+
});
|
|
2011
|
+
export const ListAvailableEditorsResponseMessageSchema = z.object({
|
|
2012
|
+
type: z.literal("list_available_editors_response"),
|
|
2013
|
+
payload: z.object({
|
|
2014
|
+
requestId: z.string(),
|
|
2015
|
+
editors: z.array(EditorTargetDescriptorPayloadSchema),
|
|
2016
|
+
error: z.string().nullable(),
|
|
2017
|
+
}),
|
|
2018
|
+
});
|
|
2019
|
+
export const OpenInEditorResponseMessageSchema = z.object({
|
|
2020
|
+
type: z.literal("open_in_editor_response"),
|
|
2021
|
+
payload: z.object({
|
|
2022
|
+
requestId: z.string(),
|
|
2023
|
+
error: z.string().nullable(),
|
|
2024
|
+
}),
|
|
2025
|
+
});
|
|
2026
|
+
export const ArchiveWorkspaceResponseMessageSchema = z.object({
|
|
2027
|
+
type: z.literal("archive_workspace_response"),
|
|
2028
|
+
payload: z.object({
|
|
2029
|
+
requestId: z.string(),
|
|
2030
|
+
workspaceId: z.string(),
|
|
2031
|
+
archivedAt: z.string().nullable(),
|
|
2032
|
+
error: z.string().nullable(),
|
|
2033
|
+
}),
|
|
2034
|
+
});
|
|
2035
|
+
export const FetchAgentResponseMessageSchema = z.object({
|
|
2036
|
+
type: z.literal("fetch_agent_response"),
|
|
2037
|
+
payload: z.object({
|
|
2038
|
+
requestId: z.string(),
|
|
2039
|
+
agent: AgentSnapshotPayloadSchema.nullable(),
|
|
2040
|
+
project: ProjectPlacementPayloadSchema.nullable().optional(),
|
|
2041
|
+
error: z.string().nullable(),
|
|
2042
|
+
}),
|
|
2043
|
+
});
|
|
2044
|
+
const AgentTimelineSeqRangeSchema = z.object({
|
|
2045
|
+
startSeq: z.number().int().nonnegative(),
|
|
2046
|
+
endSeq: z.number().int().nonnegative(),
|
|
2047
|
+
});
|
|
2048
|
+
export const AgentTimelineEntryPayloadSchema = z.object({
|
|
2049
|
+
provider: AgentProviderSchema,
|
|
2050
|
+
item: AgentTimelineItemPayloadSchema,
|
|
2051
|
+
timestamp: z.string(),
|
|
2052
|
+
seqStart: z.number().int().nonnegative(),
|
|
2053
|
+
seqEnd: z.number().int().nonnegative(),
|
|
2054
|
+
sourceSeqRanges: z.array(AgentTimelineSeqRangeSchema),
|
|
2055
|
+
collapsed: z.array(z.enum(["assistant_merge", "reasoning_merge", "tool_lifecycle"])),
|
|
2056
|
+
});
|
|
2057
|
+
export const FetchAgentTimelineResponseMessageSchema = z.object({
|
|
2058
|
+
type: z.literal("fetch_agent_timeline_response"),
|
|
2059
|
+
payload: z.object({
|
|
2060
|
+
requestId: z.string(),
|
|
2061
|
+
agentId: z.string(),
|
|
2062
|
+
agent: AgentSnapshotPayloadSchema.nullable(),
|
|
2063
|
+
direction: z.enum(["tail", "before", "after"]),
|
|
2064
|
+
projection: z.enum(["projected", "canonical"]),
|
|
2065
|
+
epoch: z.string(),
|
|
2066
|
+
reset: z.boolean(),
|
|
2067
|
+
staleCursor: z.boolean(),
|
|
2068
|
+
gap: z.boolean(),
|
|
2069
|
+
window: z.object({
|
|
2070
|
+
minSeq: z.number().int().nonnegative(),
|
|
2071
|
+
maxSeq: z.number().int().nonnegative(),
|
|
2072
|
+
nextSeq: z.number().int().nonnegative(),
|
|
2073
|
+
}),
|
|
2074
|
+
startCursor: AgentTimelineCursorSchema.nullable(),
|
|
2075
|
+
endCursor: AgentTimelineCursorSchema.nullable(),
|
|
2076
|
+
hasOlder: z.boolean(),
|
|
2077
|
+
hasNewer: z.boolean(),
|
|
2078
|
+
entries: z.array(AgentTimelineEntryPayloadSchema),
|
|
2079
|
+
error: z.string().nullable(),
|
|
2080
|
+
}),
|
|
2081
|
+
});
|
|
2082
|
+
export const CancelAgentResponseMessageSchema = z.object({
|
|
2083
|
+
type: z.literal("cancel_agent_response"),
|
|
2084
|
+
payload: z.object({
|
|
2085
|
+
requestId: z.string(),
|
|
2086
|
+
agentId: z.string(),
|
|
2087
|
+
agent: AgentSnapshotPayloadSchema.nullable(),
|
|
2088
|
+
}),
|
|
2089
|
+
});
|
|
2090
|
+
export const ClearAgentAttentionResponseMessageSchema = z.object({
|
|
2091
|
+
type: z.literal("clear_agent_attention_response"),
|
|
2092
|
+
payload: z.object({
|
|
2093
|
+
requestId: z.string(),
|
|
2094
|
+
agentId: z.string().or(z.array(z.string())),
|
|
2095
|
+
agents: z.array(AgentSnapshotPayloadSchema),
|
|
2096
|
+
}),
|
|
2097
|
+
});
|
|
2098
|
+
export const SendAgentMessageResponseMessageSchema = z.object({
|
|
2099
|
+
type: z.literal("send_agent_message_response"),
|
|
2100
|
+
payload: z.object({
|
|
2101
|
+
requestId: z.string(),
|
|
2102
|
+
agentId: z.string(),
|
|
2103
|
+
accepted: z.boolean(),
|
|
2104
|
+
error: z.string().nullable(),
|
|
2105
|
+
}),
|
|
2106
|
+
});
|
|
2107
|
+
export const WaitForFinishResponseMessageSchema = z.object({
|
|
2108
|
+
type: z.literal("wait_for_finish_response"),
|
|
2109
|
+
payload: z.object({
|
|
2110
|
+
requestId: z.string(),
|
|
2111
|
+
status: z.enum(["idle", "error", "permission", "timeout"]),
|
|
2112
|
+
final: AgentSnapshotPayloadSchema.nullable(),
|
|
2113
|
+
error: z.string().nullable(),
|
|
2114
|
+
lastMessage: z.string().nullable(),
|
|
2115
|
+
}),
|
|
2116
|
+
});
|
|
2117
|
+
export const GetDaemonConfigResponseMessageSchema = z.object({
|
|
2118
|
+
type: z.literal("get_daemon_config_response"),
|
|
2119
|
+
payload: z
|
|
2120
|
+
.object({
|
|
2121
|
+
requestId: z.string(),
|
|
2122
|
+
config: MutableDaemonConfigSchema,
|
|
2123
|
+
})
|
|
2124
|
+
.passthrough(),
|
|
2125
|
+
});
|
|
2126
|
+
export const SetDaemonConfigResponseMessageSchema = z.object({
|
|
2127
|
+
type: z.literal("set_daemon_config_response"),
|
|
2128
|
+
payload: z
|
|
2129
|
+
.object({
|
|
2130
|
+
requestId: z.string(),
|
|
2131
|
+
config: MutableDaemonConfigSchema,
|
|
2132
|
+
})
|
|
2133
|
+
.passthrough(),
|
|
2134
|
+
});
|
|
2135
|
+
export const ReadProjectConfigResponseMessageSchema = z.object({
|
|
2136
|
+
type: z.literal("read_project_config_response"),
|
|
2137
|
+
payload: z.discriminatedUnion("ok", [
|
|
2138
|
+
z.object({
|
|
2139
|
+
requestId: z.string(),
|
|
2140
|
+
repoRoot: z.string(),
|
|
2141
|
+
ok: z.literal(true),
|
|
2142
|
+
config: PaseoConfigRawSchema.nullable(),
|
|
2143
|
+
revision: PaseoConfigRevisionSchema.nullable(),
|
|
2144
|
+
}),
|
|
2145
|
+
z.object({
|
|
2146
|
+
requestId: z.string(),
|
|
2147
|
+
repoRoot: z.string(),
|
|
2148
|
+
ok: z.literal(false),
|
|
2149
|
+
error: ProjectConfigRpcErrorSchema,
|
|
2150
|
+
}),
|
|
2151
|
+
]),
|
|
2152
|
+
});
|
|
2153
|
+
export const WriteProjectConfigResponseMessageSchema = z.object({
|
|
2154
|
+
type: z.literal("write_project_config_response"),
|
|
2155
|
+
payload: z.discriminatedUnion("ok", [
|
|
2156
|
+
z.object({
|
|
2157
|
+
requestId: z.string(),
|
|
2158
|
+
repoRoot: z.string(),
|
|
2159
|
+
ok: z.literal(true),
|
|
2160
|
+
config: PaseoConfigRawSchema,
|
|
2161
|
+
revision: PaseoConfigRevisionSchema,
|
|
2162
|
+
}),
|
|
2163
|
+
z.object({
|
|
2164
|
+
requestId: z.string(),
|
|
2165
|
+
repoRoot: z.string(),
|
|
2166
|
+
ok: z.literal(false),
|
|
2167
|
+
error: ProjectConfigRpcErrorSchema,
|
|
2168
|
+
}),
|
|
2169
|
+
]),
|
|
2170
|
+
});
|
|
2171
|
+
export const AgentPermissionRequestMessageSchema = z.object({
|
|
2172
|
+
type: z.literal("agent_permission_request"),
|
|
2173
|
+
payload: z.object({
|
|
2174
|
+
agentId: z.string(),
|
|
2175
|
+
request: AgentPermissionRequestPayloadSchema,
|
|
2176
|
+
}),
|
|
2177
|
+
});
|
|
2178
|
+
export const AgentPermissionResolvedMessageSchema = z.object({
|
|
2179
|
+
type: z.literal("agent_permission_resolved"),
|
|
2180
|
+
payload: z.object({
|
|
2181
|
+
agentId: z.string(),
|
|
2182
|
+
requestId: z.string(),
|
|
2183
|
+
resolution: AgentPermissionResponseSchema,
|
|
2184
|
+
}),
|
|
2185
|
+
});
|
|
2186
|
+
export const AgentDeletedMessageSchema = z.object({
|
|
2187
|
+
type: z.literal("agent_deleted"),
|
|
2188
|
+
payload: z.object({
|
|
2189
|
+
agentId: z.string(),
|
|
2190
|
+
requestId: z.string(),
|
|
2191
|
+
}),
|
|
2192
|
+
});
|
|
2193
|
+
export const AgentArchivedMessageSchema = z.object({
|
|
2194
|
+
type: z.literal("agent_archived"),
|
|
2195
|
+
payload: z.object({
|
|
2196
|
+
agentId: z.string(),
|
|
2197
|
+
archivedAt: z.string(),
|
|
2198
|
+
requestId: z.string(),
|
|
2199
|
+
}),
|
|
2200
|
+
});
|
|
2201
|
+
const CloseItemsAgentResultSchema = z.object({
|
|
2202
|
+
agentId: z.string(),
|
|
2203
|
+
archivedAt: z.string(),
|
|
2204
|
+
});
|
|
2205
|
+
const CloseItemsTerminalResultSchema = z.object({
|
|
2206
|
+
terminalId: z.string(),
|
|
2207
|
+
success: z.boolean(),
|
|
2208
|
+
});
|
|
2209
|
+
export const CloseItemsResponseSchema = z.object({
|
|
2210
|
+
type: z.literal("close_items_response"),
|
|
2211
|
+
payload: z.object({
|
|
2212
|
+
agents: z.array(CloseItemsAgentResultSchema),
|
|
2213
|
+
terminals: z.array(CloseItemsTerminalResultSchema),
|
|
2214
|
+
requestId: z.string(),
|
|
2215
|
+
}),
|
|
2216
|
+
});
|
|
2217
|
+
const AheadBehindSchema = z.object({
|
|
2218
|
+
ahead: z.number(),
|
|
2219
|
+
behind: z.number(),
|
|
2220
|
+
});
|
|
2221
|
+
const CheckoutStatusCommonSchema = z.object({
|
|
2222
|
+
cwd: z.string(),
|
|
2223
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2224
|
+
requestId: z.string(),
|
|
2225
|
+
});
|
|
2226
|
+
const CheckoutStatusNotGitSchema = CheckoutStatusCommonSchema.extend({
|
|
2227
|
+
isGit: z.literal(false),
|
|
2228
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
2229
|
+
repoRoot: z.null(),
|
|
2230
|
+
currentBranch: z.null(),
|
|
2231
|
+
isDirty: z.null(),
|
|
2232
|
+
baseRef: z.null(),
|
|
2233
|
+
aheadBehind: z.null(),
|
|
2234
|
+
aheadOfOrigin: z.null(),
|
|
2235
|
+
behindOfOrigin: z.null(),
|
|
2236
|
+
hasRemote: z.boolean(),
|
|
2237
|
+
remoteUrl: z.null(),
|
|
2238
|
+
});
|
|
2239
|
+
const CheckoutStatusGitNonPaseoSchema = CheckoutStatusCommonSchema.extend({
|
|
2240
|
+
isGit: z.literal(true),
|
|
2241
|
+
isPaseoOwnedWorktree: z.literal(false),
|
|
2242
|
+
repoRoot: z.string(),
|
|
2243
|
+
mainRepoRoot: z.string().nullable().optional().default(null),
|
|
2244
|
+
currentBranch: z.string().nullable(),
|
|
2245
|
+
isDirty: z.boolean(),
|
|
2246
|
+
baseRef: z.string().nullable(),
|
|
2247
|
+
aheadBehind: AheadBehindSchema.nullable(),
|
|
2248
|
+
aheadOfOrigin: z.number().nullable(),
|
|
2249
|
+
behindOfOrigin: z.number().nullable(),
|
|
2250
|
+
hasRemote: z.boolean(),
|
|
2251
|
+
remoteUrl: z.string().nullable(),
|
|
2252
|
+
});
|
|
2253
|
+
const CheckoutStatusGitPaseoSchema = CheckoutStatusCommonSchema.extend({
|
|
2254
|
+
isGit: z.literal(true),
|
|
2255
|
+
isPaseoOwnedWorktree: z.literal(true),
|
|
2256
|
+
repoRoot: z.string(),
|
|
2257
|
+
mainRepoRoot: z.string(),
|
|
2258
|
+
currentBranch: z.string().nullable(),
|
|
2259
|
+
isDirty: z.boolean(),
|
|
2260
|
+
baseRef: z.string(),
|
|
2261
|
+
aheadBehind: AheadBehindSchema.nullable(),
|
|
2262
|
+
aheadOfOrigin: z.number().nullable(),
|
|
2263
|
+
behindOfOrigin: z.number().nullable(),
|
|
2264
|
+
hasRemote: z.boolean(),
|
|
2265
|
+
remoteUrl: z.string().nullable(),
|
|
2266
|
+
});
|
|
2267
|
+
export const CheckoutStatusResponseSchema = z.object({
|
|
2268
|
+
type: z.literal("checkout_status_response"),
|
|
2269
|
+
payload: z.union([
|
|
2270
|
+
CheckoutStatusNotGitSchema,
|
|
2271
|
+
CheckoutStatusGitNonPaseoSchema,
|
|
2272
|
+
CheckoutStatusGitPaseoSchema,
|
|
2273
|
+
]),
|
|
2274
|
+
});
|
|
2275
|
+
export const CheckoutPrStatusSchema = z.object({
|
|
2276
|
+
number: z.number().optional(),
|
|
2277
|
+
url: z.string(),
|
|
2278
|
+
title: z.string(),
|
|
2279
|
+
state: z.string(),
|
|
2280
|
+
baseRefName: z.string(),
|
|
2281
|
+
headRefName: z.string(),
|
|
2282
|
+
isMerged: z.boolean(),
|
|
2283
|
+
isDraft: z.boolean().optional().default(false),
|
|
2284
|
+
checks: z
|
|
2285
|
+
.array(z.object({
|
|
2286
|
+
name: z.string(),
|
|
2287
|
+
status: z.string(),
|
|
2288
|
+
url: z.string().nullable(),
|
|
2289
|
+
workflow: z.string().optional(),
|
|
2290
|
+
duration: z.string().optional(),
|
|
2291
|
+
}))
|
|
2292
|
+
.optional()
|
|
2293
|
+
.default([]),
|
|
2294
|
+
checksStatus: z.string().optional(),
|
|
2295
|
+
reviewDecision: z.string().nullable().optional(),
|
|
2296
|
+
repoOwner: z.string().optional(),
|
|
2297
|
+
repoName: z.string().optional(),
|
|
2298
|
+
});
|
|
2299
|
+
const CheckoutPrStatusPayloadSchema = z.object({
|
|
2300
|
+
cwd: z.string(),
|
|
2301
|
+
status: CheckoutPrStatusSchema.nullable(),
|
|
2302
|
+
githubFeaturesEnabled: z.boolean(),
|
|
2303
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2304
|
+
requestId: z.string(),
|
|
2305
|
+
});
|
|
2306
|
+
const CheckoutStatusUpdateMetadataSchema = z.object({
|
|
2307
|
+
prStatus: CheckoutPrStatusPayloadSchema.optional(),
|
|
2308
|
+
});
|
|
2309
|
+
export const CheckoutStatusUpdateSchema = z.object({
|
|
2310
|
+
type: z.literal("checkout_status_update"),
|
|
2311
|
+
payload: z
|
|
2312
|
+
.union([
|
|
2313
|
+
CheckoutStatusNotGitSchema,
|
|
2314
|
+
CheckoutStatusGitNonPaseoSchema,
|
|
2315
|
+
CheckoutStatusGitPaseoSchema,
|
|
2316
|
+
])
|
|
2317
|
+
.and(CheckoutStatusUpdateMetadataSchema),
|
|
2318
|
+
});
|
|
2319
|
+
const CheckoutDiffSubscriptionPayloadSchema = z.object({
|
|
2320
|
+
subscriptionId: z.string(),
|
|
2321
|
+
cwd: z.string(),
|
|
2322
|
+
files: z.array(ParsedDiffFileSchema),
|
|
2323
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2324
|
+
});
|
|
2325
|
+
export const SubscribeCheckoutDiffResponseSchema = z.object({
|
|
2326
|
+
type: z.literal("subscribe_checkout_diff_response"),
|
|
2327
|
+
payload: CheckoutDiffSubscriptionPayloadSchema.extend({
|
|
2328
|
+
requestId: z.string(),
|
|
2329
|
+
}),
|
|
2330
|
+
});
|
|
2331
|
+
export const CheckoutDiffUpdateSchema = z.object({
|
|
2332
|
+
type: z.literal("checkout_diff_update"),
|
|
2333
|
+
payload: CheckoutDiffSubscriptionPayloadSchema,
|
|
2334
|
+
});
|
|
2335
|
+
export const CheckoutCommitResponseSchema = z.object({
|
|
2336
|
+
type: z.literal("checkout_commit_response"),
|
|
2337
|
+
payload: z.object({
|
|
2338
|
+
cwd: z.string(),
|
|
2339
|
+
success: z.boolean(),
|
|
2340
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2341
|
+
requestId: z.string(),
|
|
2342
|
+
}),
|
|
2343
|
+
});
|
|
2344
|
+
export const CheckoutMergeResponseSchema = z.object({
|
|
2345
|
+
type: z.literal("checkout_merge_response"),
|
|
2346
|
+
payload: z.object({
|
|
2347
|
+
cwd: z.string(),
|
|
2348
|
+
success: z.boolean(),
|
|
2349
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2350
|
+
requestId: z.string(),
|
|
2351
|
+
}),
|
|
2352
|
+
});
|
|
2353
|
+
export const CheckoutMergeFromBaseResponseSchema = z.object({
|
|
2354
|
+
type: z.literal("checkout_merge_from_base_response"),
|
|
2355
|
+
payload: z.object({
|
|
2356
|
+
cwd: z.string(),
|
|
2357
|
+
success: z.boolean(),
|
|
2358
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2359
|
+
requestId: z.string(),
|
|
2360
|
+
}),
|
|
2361
|
+
});
|
|
2362
|
+
export const CheckoutPullResponseSchema = z.object({
|
|
2363
|
+
type: z.literal("checkout_pull_response"),
|
|
2364
|
+
payload: z.object({
|
|
2365
|
+
cwd: z.string(),
|
|
2366
|
+
success: z.boolean(),
|
|
2367
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2368
|
+
requestId: z.string(),
|
|
2369
|
+
}),
|
|
2370
|
+
});
|
|
2371
|
+
export const CheckoutPushResponseSchema = z.object({
|
|
2372
|
+
type: z.literal("checkout_push_response"),
|
|
2373
|
+
payload: z.object({
|
|
2374
|
+
cwd: z.string(),
|
|
2375
|
+
success: z.boolean(),
|
|
2376
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2377
|
+
requestId: z.string(),
|
|
2378
|
+
}),
|
|
2379
|
+
});
|
|
2380
|
+
export const CheckoutPrCreateResponseSchema = z.object({
|
|
2381
|
+
type: z.literal("checkout_pr_create_response"),
|
|
2382
|
+
payload: z.object({
|
|
2383
|
+
cwd: z.string(),
|
|
2384
|
+
url: z.string().nullable(),
|
|
2385
|
+
number: z.number().nullable(),
|
|
2386
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2387
|
+
requestId: z.string(),
|
|
2388
|
+
}),
|
|
2389
|
+
});
|
|
2390
|
+
export const CheckoutPrStatusResponseSchema = z.object({
|
|
2391
|
+
type: z.literal("checkout_pr_status_response"),
|
|
2392
|
+
payload: CheckoutPrStatusPayloadSchema,
|
|
2393
|
+
});
|
|
2394
|
+
const PullRequestTimelineKnownErrorSchema = z.discriminatedUnion("kind", [
|
|
2395
|
+
z.object({
|
|
2396
|
+
kind: z.literal("not_found"),
|
|
2397
|
+
message: z.string().optional().default(""),
|
|
2398
|
+
}),
|
|
2399
|
+
z.object({
|
|
2400
|
+
kind: z.literal("forbidden"),
|
|
2401
|
+
message: z.string().optional().default(""),
|
|
2402
|
+
}),
|
|
2403
|
+
z.object({
|
|
2404
|
+
kind: z.literal("unknown"),
|
|
2405
|
+
message: z.string().optional().default(""),
|
|
2406
|
+
}),
|
|
2407
|
+
]);
|
|
2408
|
+
const PullRequestTimelineErrorSchema = z.preprocess((value) => {
|
|
2409
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2410
|
+
return { kind: "unknown", message: "" };
|
|
2411
|
+
}
|
|
2412
|
+
const error = value;
|
|
2413
|
+
if (error.kind === "not_found" || error.kind === "forbidden" || error.kind === "unknown") {
|
|
2414
|
+
return error;
|
|
2415
|
+
}
|
|
2416
|
+
return { ...error, kind: "unknown" };
|
|
2417
|
+
}, PullRequestTimelineKnownErrorSchema);
|
|
2418
|
+
const PullRequestTimelineReviewItemSchema = z.object({
|
|
2419
|
+
id: z.string().optional().default(""),
|
|
2420
|
+
kind: z.literal("review"),
|
|
2421
|
+
author: z.string().optional().default("unknown"),
|
|
2422
|
+
body: z.string().optional().default(""),
|
|
2423
|
+
createdAt: z.number().optional().default(0),
|
|
2424
|
+
url: z.string().optional().default(""),
|
|
2425
|
+
reviewState: z
|
|
2426
|
+
.enum(["approved", "changes_requested", "commented"])
|
|
2427
|
+
.optional()
|
|
2428
|
+
.default("commented"),
|
|
2429
|
+
});
|
|
2430
|
+
const PullRequestTimelineCommentItemSchema = z.object({
|
|
2431
|
+
id: z.string().optional().default(""),
|
|
2432
|
+
kind: z.literal("comment"),
|
|
2433
|
+
author: z.string().optional().default("unknown"),
|
|
2434
|
+
body: z.string().optional().default(""),
|
|
2435
|
+
createdAt: z.number().optional().default(0),
|
|
2436
|
+
url: z.string().optional().default(""),
|
|
2437
|
+
});
|
|
2438
|
+
export const PullRequestTimelineItemSchema = z.preprocess((value) => {
|
|
2439
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2440
|
+
return value;
|
|
2441
|
+
}
|
|
2442
|
+
const item = value;
|
|
2443
|
+
if (item.kind === "review" || item.kind === "comment") {
|
|
2444
|
+
return item;
|
|
2445
|
+
}
|
|
2446
|
+
return { ...item, kind: "comment" };
|
|
2447
|
+
}, z.discriminatedUnion("kind", [
|
|
2448
|
+
PullRequestTimelineReviewItemSchema,
|
|
2449
|
+
PullRequestTimelineCommentItemSchema,
|
|
2450
|
+
]));
|
|
2451
|
+
export const PullRequestTimelineResponseSchema = z.object({
|
|
2452
|
+
type: z.literal("pull_request_timeline_response"),
|
|
2453
|
+
payload: z
|
|
2454
|
+
.object({
|
|
2455
|
+
cwd: z.string().optional().default(""),
|
|
2456
|
+
prNumber: z.number().nullable().optional().default(null),
|
|
2457
|
+
items: z.array(PullRequestTimelineItemSchema).optional().default([]),
|
|
2458
|
+
truncated: z.boolean().optional().default(false),
|
|
2459
|
+
error: PullRequestTimelineErrorSchema.nullable().optional().default(null),
|
|
2460
|
+
requestId: z.string().optional().default(""),
|
|
2461
|
+
githubFeaturesEnabled: z.boolean().optional().default(true),
|
|
2462
|
+
})
|
|
2463
|
+
.optional()
|
|
2464
|
+
.default({}),
|
|
2465
|
+
});
|
|
2466
|
+
export const CheckoutSwitchBranchResponseSchema = z.object({
|
|
2467
|
+
type: z.literal("checkout_switch_branch_response"),
|
|
2468
|
+
payload: z.object({
|
|
2469
|
+
cwd: z.string(),
|
|
2470
|
+
success: z.boolean(),
|
|
2471
|
+
branch: z.string(),
|
|
2472
|
+
source: z.enum(["local", "remote"]).optional(),
|
|
2473
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2474
|
+
requestId: z.string(),
|
|
2475
|
+
}),
|
|
2476
|
+
});
|
|
2477
|
+
const StashEntrySchema = z.object({
|
|
2478
|
+
index: z.number().int().min(0),
|
|
2479
|
+
message: z.string(),
|
|
2480
|
+
branch: z.string().nullable(),
|
|
2481
|
+
isPaseo: z.boolean(),
|
|
2482
|
+
});
|
|
2483
|
+
export const StashSaveResponseSchema = z.object({
|
|
2484
|
+
type: z.literal("stash_save_response"),
|
|
2485
|
+
payload: z.object({
|
|
2486
|
+
cwd: z.string(),
|
|
2487
|
+
success: z.boolean(),
|
|
2488
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2489
|
+
requestId: z.string(),
|
|
2490
|
+
}),
|
|
2491
|
+
});
|
|
2492
|
+
export const StashPopResponseSchema = z.object({
|
|
2493
|
+
type: z.literal("stash_pop_response"),
|
|
2494
|
+
payload: z.object({
|
|
2495
|
+
cwd: z.string(),
|
|
2496
|
+
success: z.boolean(),
|
|
2497
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2498
|
+
requestId: z.string(),
|
|
2499
|
+
}),
|
|
2500
|
+
});
|
|
2501
|
+
export const StashListResponseSchema = z.object({
|
|
2502
|
+
type: z.literal("stash_list_response"),
|
|
2503
|
+
payload: z.object({
|
|
2504
|
+
cwd: z.string(),
|
|
2505
|
+
entries: z.array(StashEntrySchema),
|
|
2506
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2507
|
+
requestId: z.string(),
|
|
2508
|
+
}),
|
|
2509
|
+
});
|
|
2510
|
+
export const ValidateBranchResponseSchema = z.object({
|
|
2511
|
+
type: z.literal("validate_branch_response"),
|
|
2512
|
+
payload: z.object({
|
|
2513
|
+
exists: z.boolean(),
|
|
2514
|
+
resolvedRef: z.string().nullable(),
|
|
2515
|
+
isRemote: z.boolean(),
|
|
2516
|
+
error: z.string().nullable(),
|
|
2517
|
+
requestId: z.string(),
|
|
2518
|
+
}),
|
|
2519
|
+
});
|
|
2520
|
+
export const BranchSuggestionsResponseSchema = z.object({
|
|
2521
|
+
type: z.literal("branch_suggestions_response"),
|
|
2522
|
+
payload: z.object({
|
|
2523
|
+
branches: z.array(z.string()),
|
|
2524
|
+
branchDetails: z
|
|
2525
|
+
.array(z.object({
|
|
2526
|
+
name: z.string(),
|
|
2527
|
+
committerDate: z.number(),
|
|
2528
|
+
hasLocal: z.boolean().optional(),
|
|
2529
|
+
hasRemote: z.boolean().optional(),
|
|
2530
|
+
}))
|
|
2531
|
+
.optional(),
|
|
2532
|
+
error: z.string().nullable(),
|
|
2533
|
+
requestId: z.string(),
|
|
2534
|
+
}),
|
|
2535
|
+
});
|
|
2536
|
+
export const GitHubSearchResponseSchema = z.object({
|
|
2537
|
+
type: z.literal("github_search_response"),
|
|
2538
|
+
payload: z.object({
|
|
2539
|
+
items: z.array(GitHubSearchItemSchema),
|
|
2540
|
+
githubFeaturesEnabled: z.boolean(),
|
|
2541
|
+
error: z.string().nullable(),
|
|
2542
|
+
requestId: z.string(),
|
|
2543
|
+
}),
|
|
2544
|
+
});
|
|
2545
|
+
export const DirectorySuggestionsResponseSchema = z.object({
|
|
2546
|
+
type: z.literal("directory_suggestions_response"),
|
|
2547
|
+
payload: z.object({
|
|
2548
|
+
directories: z.array(z.string()),
|
|
2549
|
+
entries: z
|
|
2550
|
+
.array(z.object({
|
|
2551
|
+
path: z.string(),
|
|
2552
|
+
kind: z.enum(["file", "directory"]),
|
|
2553
|
+
}))
|
|
2554
|
+
.optional()
|
|
2555
|
+
.default([]),
|
|
2556
|
+
error: z.string().nullable(),
|
|
2557
|
+
requestId: z.string(),
|
|
2558
|
+
}),
|
|
2559
|
+
});
|
|
2560
|
+
const PaseoWorktreeSchema = z.object({
|
|
2561
|
+
worktreePath: z.string(),
|
|
2562
|
+
createdAt: z.string(),
|
|
2563
|
+
branchName: z.string().nullable().optional(),
|
|
2564
|
+
head: z.string().nullable().optional(),
|
|
2565
|
+
});
|
|
2566
|
+
export const PaseoWorktreeListResponseSchema = z.object({
|
|
2567
|
+
type: z.literal("paseo_worktree_list_response"),
|
|
2568
|
+
payload: z.object({
|
|
2569
|
+
worktrees: z.array(PaseoWorktreeSchema),
|
|
2570
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2571
|
+
requestId: z.string(),
|
|
2572
|
+
}),
|
|
2573
|
+
});
|
|
2574
|
+
export const PaseoWorktreeArchiveResponseSchema = z.object({
|
|
2575
|
+
type: z.literal("paseo_worktree_archive_response"),
|
|
2576
|
+
payload: z.object({
|
|
2577
|
+
success: z.boolean(),
|
|
2578
|
+
removedAgents: z.array(z.string()).optional(),
|
|
2579
|
+
error: CheckoutErrorSchema.nullable(),
|
|
2580
|
+
requestId: z.string(),
|
|
2581
|
+
}),
|
|
2582
|
+
});
|
|
2583
|
+
export const CreatePaseoWorktreeResponseSchema = z.object({
|
|
2584
|
+
type: z.literal("create_paseo_worktree_response"),
|
|
2585
|
+
payload: z.object({
|
|
2586
|
+
workspace: WorkspaceDescriptorPayloadSchema.nullable(),
|
|
2587
|
+
error: z.string().nullable(),
|
|
2588
|
+
errorCode: z.string().optional(),
|
|
2589
|
+
setupTerminalId: z.string().nullable(),
|
|
2590
|
+
requestId: z.string(),
|
|
2591
|
+
}),
|
|
2592
|
+
});
|
|
2593
|
+
export const FileExplorerResponseSchema = z.object({
|
|
2594
|
+
type: z.literal("file_explorer_response"),
|
|
2595
|
+
payload: z.object({
|
|
2596
|
+
cwd: z.string(),
|
|
2597
|
+
path: z.string(),
|
|
2598
|
+
mode: z.enum(["list", "file"]),
|
|
2599
|
+
directory: FileExplorerDirectorySchema.nullable(),
|
|
2600
|
+
file: FileExplorerFileSchema.nullable(),
|
|
2601
|
+
error: z.string().nullable(),
|
|
2602
|
+
requestId: z.string(),
|
|
2603
|
+
}),
|
|
2604
|
+
});
|
|
2605
|
+
const ProjectIconSchema = z.object({
|
|
2606
|
+
data: z.string(),
|
|
2607
|
+
mimeType: z.string(),
|
|
2608
|
+
});
|
|
2609
|
+
export const ProjectIconResponseSchema = z.object({
|
|
2610
|
+
type: z.literal("project_icon_response"),
|
|
2611
|
+
payload: z.object({
|
|
2612
|
+
cwd: z.string(),
|
|
2613
|
+
icon: ProjectIconSchema.nullable(),
|
|
2614
|
+
error: z.string().nullable(),
|
|
2615
|
+
requestId: z.string(),
|
|
2616
|
+
}),
|
|
2617
|
+
});
|
|
2618
|
+
export const FileDownloadTokenResponseSchema = z.object({
|
|
2619
|
+
type: z.literal("file_download_token_response"),
|
|
2620
|
+
payload: z.object({
|
|
2621
|
+
cwd: z.string(),
|
|
2622
|
+
path: z.string(),
|
|
2623
|
+
token: z.string().nullable(),
|
|
2624
|
+
fileName: z.string().nullable(),
|
|
2625
|
+
mimeType: z.string().nullable(),
|
|
2626
|
+
size: z.number().nullable(),
|
|
2627
|
+
error: z.string().nullable(),
|
|
2628
|
+
requestId: z.string(),
|
|
2629
|
+
}),
|
|
2630
|
+
});
|
|
2631
|
+
export const ListProviderModelsResponseMessageSchema = z.object({
|
|
2632
|
+
type: z.literal("list_provider_models_response"),
|
|
2633
|
+
payload: z.object({
|
|
2634
|
+
provider: AgentProviderSchema,
|
|
2635
|
+
models: z.array(AgentModelDefinitionSchema).optional(),
|
|
2636
|
+
error: z.string().nullable().optional(),
|
|
2637
|
+
fetchedAt: z.string(),
|
|
2638
|
+
requestId: z.string(),
|
|
2639
|
+
}),
|
|
2640
|
+
});
|
|
2641
|
+
export const ListProviderModesResponseMessageSchema = z.object({
|
|
2642
|
+
type: z.literal("list_provider_modes_response"),
|
|
2643
|
+
payload: z.object({
|
|
2644
|
+
provider: AgentProviderSchema,
|
|
2645
|
+
modes: z.array(AgentModeSchema).optional(),
|
|
2646
|
+
error: z.string().nullable().optional(),
|
|
2647
|
+
fetchedAt: z.string(),
|
|
2648
|
+
requestId: z.string(),
|
|
2649
|
+
}),
|
|
2650
|
+
});
|
|
2651
|
+
export const ListProviderFeaturesResponseMessageSchema = z.object({
|
|
2652
|
+
type: z.literal("list_provider_features_response"),
|
|
2653
|
+
payload: z.object({
|
|
2654
|
+
provider: AgentProviderSchema,
|
|
2655
|
+
features: z.array(AgentFeatureSchema).optional(),
|
|
2656
|
+
error: z.string().nullable().optional(),
|
|
2657
|
+
fetchedAt: z.string(),
|
|
2658
|
+
requestId: z.string(),
|
|
2659
|
+
}),
|
|
2660
|
+
});
|
|
2661
|
+
const ProviderAvailabilitySchema = z.object({
|
|
2662
|
+
provider: AgentProviderSchema,
|
|
2663
|
+
available: z.boolean(),
|
|
2664
|
+
error: z.string().nullable().optional(),
|
|
2665
|
+
});
|
|
2666
|
+
export const ListAvailableProvidersResponseSchema = z.object({
|
|
2667
|
+
type: z.literal("list_available_providers_response"),
|
|
2668
|
+
payload: z.object({
|
|
2669
|
+
providers: z.array(ProviderAvailabilitySchema),
|
|
2670
|
+
error: z.string().nullable().optional(),
|
|
2671
|
+
fetchedAt: z.string(),
|
|
2672
|
+
requestId: z.string(),
|
|
2673
|
+
}),
|
|
2674
|
+
});
|
|
2675
|
+
// COMPAT(providersSnapshot): added in v0.1.48, remove gating when all clients use snapshot
|
|
2676
|
+
export const GetProvidersSnapshotResponseMessageSchema = z.object({
|
|
2677
|
+
type: z.literal("get_providers_snapshot_response"),
|
|
2678
|
+
payload: z.object({
|
|
2679
|
+
entries: z.array(ProviderSnapshotEntrySchema),
|
|
2680
|
+
generatedAt: z.string(),
|
|
2681
|
+
requestId: z.string(),
|
|
2682
|
+
}),
|
|
2683
|
+
});
|
|
2684
|
+
// COMPAT(providersSnapshot): added in v0.1.48, remove gating when all clients use snapshot
|
|
2685
|
+
export const ProvidersSnapshotUpdateMessageSchema = z.object({
|
|
2686
|
+
type: z.literal("providers_snapshot_update"),
|
|
2687
|
+
payload: z.object({
|
|
2688
|
+
cwd: z.string().optional(),
|
|
2689
|
+
entries: z.array(ProviderSnapshotEntrySchema),
|
|
2690
|
+
generatedAt: z.string(),
|
|
2691
|
+
}),
|
|
2692
|
+
});
|
|
2693
|
+
// COMPAT(providersSnapshot): added in v0.1.48, remove gating when all clients use snapshot
|
|
2694
|
+
export const RefreshProvidersSnapshotResponseMessageSchema = z.object({
|
|
2695
|
+
type: z.literal("refresh_providers_snapshot_response"),
|
|
2696
|
+
payload: z.object({
|
|
2697
|
+
requestId: z.string(),
|
|
2698
|
+
acknowledged: z.boolean(),
|
|
2699
|
+
}),
|
|
2700
|
+
});
|
|
2701
|
+
// COMPAT(providersSnapshot): added in v0.1.48, remove gating when all clients use snapshot
|
|
2702
|
+
export const ProviderDiagnosticResponseMessageSchema = z.object({
|
|
2703
|
+
type: z.literal("provider_diagnostic_response"),
|
|
2704
|
+
payload: z.object({
|
|
2705
|
+
provider: AgentProviderSchema,
|
|
2706
|
+
diagnostic: z.string(),
|
|
2707
|
+
requestId: z.string(),
|
|
2708
|
+
}),
|
|
2709
|
+
});
|
|
2710
|
+
const AgentSlashCommandSchema = z.object({
|
|
2711
|
+
name: z.string(),
|
|
2712
|
+
description: z.string(),
|
|
2713
|
+
argumentHint: z.string(),
|
|
2714
|
+
});
|
|
2715
|
+
export const ListCommandsResponseSchema = z.object({
|
|
2716
|
+
type: z.literal("list_commands_response"),
|
|
2717
|
+
payload: z.object({
|
|
2718
|
+
agentId: z.string(),
|
|
2719
|
+
commands: z.array(AgentSlashCommandSchema),
|
|
2720
|
+
error: z.string().nullable(),
|
|
2721
|
+
requestId: z.string(),
|
|
2722
|
+
}),
|
|
2723
|
+
});
|
|
2724
|
+
// ============================================================================
|
|
2725
|
+
// Terminal Outbound Messages
|
|
2726
|
+
// ============================================================================
|
|
2727
|
+
const TerminalInfoSchema = z.object({
|
|
2728
|
+
id: z.string(),
|
|
2729
|
+
name: z.string(),
|
|
2730
|
+
cwd: z.string(),
|
|
2731
|
+
title: z.string().optional(),
|
|
2732
|
+
});
|
|
2733
|
+
export const TerminalCellSchema = z
|
|
2734
|
+
.object({
|
|
2735
|
+
char: z.string(),
|
|
2736
|
+
fg: z.number().optional(),
|
|
2737
|
+
bg: z.number().optional(),
|
|
2738
|
+
fgMode: z.number().optional(),
|
|
2739
|
+
bgMode: z.number().optional(),
|
|
2740
|
+
bold: z.boolean().optional(),
|
|
2741
|
+
italic: z.boolean().optional(),
|
|
2742
|
+
underline: z.boolean().optional(),
|
|
2743
|
+
dim: z.boolean().optional(),
|
|
2744
|
+
inverse: z.boolean().optional(),
|
|
2745
|
+
strikethrough: z.boolean().optional(),
|
|
2746
|
+
})
|
|
2747
|
+
.strict();
|
|
2748
|
+
export const TerminalCursorStyleSchema = z.enum(["block", "underline", "bar"]);
|
|
2749
|
+
export const TerminalCursorSchema = z
|
|
2750
|
+
.object({
|
|
2751
|
+
row: z.number(),
|
|
2752
|
+
col: z.number(),
|
|
2753
|
+
hidden: z.boolean().optional(),
|
|
2754
|
+
style: TerminalCursorStyleSchema.optional(),
|
|
2755
|
+
blink: z.boolean().optional(),
|
|
2756
|
+
})
|
|
2757
|
+
.strict();
|
|
2758
|
+
export const TerminalStateSchema = z
|
|
2759
|
+
.object({
|
|
2760
|
+
rows: z.number(),
|
|
2761
|
+
cols: z.number(),
|
|
2762
|
+
grid: z.array(z.array(TerminalCellSchema)),
|
|
2763
|
+
scrollback: z.array(z.array(TerminalCellSchema)),
|
|
2764
|
+
cursor: TerminalCursorSchema,
|
|
2765
|
+
title: z.string().optional(),
|
|
2766
|
+
})
|
|
2767
|
+
.strict();
|
|
2768
|
+
export const ListTerminalsResponseSchema = z.object({
|
|
2769
|
+
type: z.literal("list_terminals_response"),
|
|
2770
|
+
payload: z.object({
|
|
2771
|
+
cwd: z.string().optional(),
|
|
2772
|
+
terminals: z.array(TerminalInfoSchema.omit({ cwd: true })),
|
|
2773
|
+
requestId: z.string(),
|
|
2774
|
+
}),
|
|
2775
|
+
});
|
|
2776
|
+
export const TerminalsChangedSchema = z.object({
|
|
2777
|
+
type: z.literal("terminals_changed"),
|
|
2778
|
+
payload: z.object({
|
|
2779
|
+
cwd: z.string(),
|
|
2780
|
+
terminals: z.array(TerminalInfoSchema.omit({ cwd: true })),
|
|
2781
|
+
}),
|
|
2782
|
+
});
|
|
2783
|
+
export const CreateTerminalResponseSchema = z.object({
|
|
2784
|
+
type: z.literal("create_terminal_response"),
|
|
2785
|
+
payload: z.object({
|
|
2786
|
+
terminal: TerminalInfoSchema.nullable(),
|
|
2787
|
+
error: z.string().nullable(),
|
|
2788
|
+
requestId: z.string(),
|
|
2789
|
+
}),
|
|
2790
|
+
});
|
|
2791
|
+
export const SubscribeTerminalResponseSchema = z.object({
|
|
2792
|
+
type: z.literal("subscribe_terminal_response"),
|
|
2793
|
+
payload: z.union([
|
|
2794
|
+
z.object({
|
|
2795
|
+
terminalId: z.string(),
|
|
2796
|
+
slot: z.number().int().min(0).max(255),
|
|
2797
|
+
error: z.null(),
|
|
2798
|
+
requestId: z.string(),
|
|
2799
|
+
}),
|
|
2800
|
+
z.object({
|
|
2801
|
+
terminalId: z.string(),
|
|
2802
|
+
error: z.string(),
|
|
2803
|
+
requestId: z.string(),
|
|
2804
|
+
}),
|
|
2805
|
+
]),
|
|
2806
|
+
});
|
|
2807
|
+
export const KillTerminalResponseSchema = z.object({
|
|
2808
|
+
type: z.literal("kill_terminal_response"),
|
|
2809
|
+
payload: z.object({
|
|
2810
|
+
terminalId: z.string(),
|
|
2811
|
+
success: z.boolean(),
|
|
2812
|
+
requestId: z.string(),
|
|
2813
|
+
}),
|
|
2814
|
+
});
|
|
2815
|
+
export const CaptureTerminalResponseSchema = z.object({
|
|
2816
|
+
type: z.literal("capture_terminal_response"),
|
|
2817
|
+
payload: z.object({
|
|
2818
|
+
terminalId: z.string(),
|
|
2819
|
+
lines: z.array(z.string()),
|
|
2820
|
+
totalLines: z.number().int().nonnegative(),
|
|
2821
|
+
requestId: z.string(),
|
|
2822
|
+
}),
|
|
2823
|
+
});
|
|
2824
|
+
export const TerminalStreamExitSchema = z.object({
|
|
2825
|
+
type: z.literal("terminal_stream_exit"),
|
|
2826
|
+
payload: z.object({
|
|
2827
|
+
terminalId: z.string(),
|
|
2828
|
+
}),
|
|
2829
|
+
});
|
|
2830
|
+
export const SessionOutboundMessageSchema = z.discriminatedUnion("type", [
|
|
2831
|
+
ActivityLogMessageSchema,
|
|
2832
|
+
AssistantChunkMessageSchema,
|
|
2833
|
+
AudioOutputMessageSchema,
|
|
2834
|
+
TranscriptionResultMessageSchema,
|
|
2835
|
+
VoiceInputStateMessageSchema,
|
|
2836
|
+
DictationStreamAckMessageSchema,
|
|
2837
|
+
DictationStreamFinishAcceptedMessageSchema,
|
|
2838
|
+
DictationStreamPartialMessageSchema,
|
|
2839
|
+
DictationStreamFinalMessageSchema,
|
|
2840
|
+
DictationStreamErrorMessageSchema,
|
|
2841
|
+
StatusMessageSchema,
|
|
2842
|
+
PongMessageSchema,
|
|
2843
|
+
RpcErrorMessageSchema,
|
|
2844
|
+
ArtifactMessageSchema,
|
|
2845
|
+
AgentUpdateMessageSchema,
|
|
2846
|
+
WorkspaceUpdateMessageSchema,
|
|
2847
|
+
ScriptStatusUpdateMessageSchema,
|
|
2848
|
+
WorkspaceSetupProgressMessageSchema,
|
|
2849
|
+
WorkspaceSetupStatusResponseMessageSchema,
|
|
2850
|
+
AgentStreamMessageSchema,
|
|
2851
|
+
AgentStatusMessageSchema,
|
|
2852
|
+
FetchAgentsResponseMessageSchema,
|
|
2853
|
+
FetchAgentHistoryResponseMessageSchema,
|
|
2854
|
+
FetchWorkspacesResponseMessageSchema,
|
|
2855
|
+
OpenProjectResponseMessageSchema,
|
|
2856
|
+
StartWorkspaceScriptResponseMessageSchema,
|
|
2857
|
+
ListAvailableEditorsResponseMessageSchema,
|
|
2858
|
+
OpenInEditorResponseMessageSchema,
|
|
2859
|
+
ArchiveWorkspaceResponseMessageSchema,
|
|
2860
|
+
FetchAgentResponseMessageSchema,
|
|
2861
|
+
FetchAgentTimelineResponseMessageSchema,
|
|
2862
|
+
CancelAgentResponseMessageSchema,
|
|
2863
|
+
ClearAgentAttentionResponseMessageSchema,
|
|
2864
|
+
SendAgentMessageResponseMessageSchema,
|
|
2865
|
+
SetVoiceModeResponseMessageSchema,
|
|
2866
|
+
GetDaemonConfigResponseMessageSchema,
|
|
2867
|
+
SetDaemonConfigResponseMessageSchema,
|
|
2868
|
+
ReadProjectConfigResponseMessageSchema,
|
|
2869
|
+
WriteProjectConfigResponseMessageSchema,
|
|
2870
|
+
SetAgentModeResponseMessageSchema,
|
|
2871
|
+
SetAgentModelResponseMessageSchema,
|
|
2872
|
+
SetAgentThinkingResponseMessageSchema,
|
|
2873
|
+
SetAgentFeatureResponseMessageSchema,
|
|
2874
|
+
UpdateAgentResponseMessageSchema,
|
|
2875
|
+
WaitForFinishResponseMessageSchema,
|
|
2876
|
+
AgentPermissionRequestMessageSchema,
|
|
2877
|
+
AgentPermissionResolvedMessageSchema,
|
|
2878
|
+
AgentDeletedMessageSchema,
|
|
2879
|
+
AgentArchivedMessageSchema,
|
|
2880
|
+
CloseItemsResponseSchema,
|
|
2881
|
+
CheckoutStatusResponseSchema,
|
|
2882
|
+
CheckoutStatusUpdateSchema,
|
|
2883
|
+
SubscribeCheckoutDiffResponseSchema,
|
|
2884
|
+
CheckoutDiffUpdateSchema,
|
|
2885
|
+
CheckoutCommitResponseSchema,
|
|
2886
|
+
CheckoutMergeResponseSchema,
|
|
2887
|
+
CheckoutMergeFromBaseResponseSchema,
|
|
2888
|
+
CheckoutPullResponseSchema,
|
|
2889
|
+
CheckoutPushResponseSchema,
|
|
2890
|
+
CheckoutPrCreateResponseSchema,
|
|
2891
|
+
CheckoutPrStatusResponseSchema,
|
|
2892
|
+
PullRequestTimelineResponseSchema,
|
|
2893
|
+
CheckoutSwitchBranchResponseSchema,
|
|
2894
|
+
StashSaveResponseSchema,
|
|
2895
|
+
StashPopResponseSchema,
|
|
2896
|
+
StashListResponseSchema,
|
|
2897
|
+
ValidateBranchResponseSchema,
|
|
2898
|
+
BranchSuggestionsResponseSchema,
|
|
2899
|
+
GitHubSearchResponseSchema,
|
|
2900
|
+
DirectorySuggestionsResponseSchema,
|
|
2901
|
+
PaseoWorktreeListResponseSchema,
|
|
2902
|
+
PaseoWorktreeArchiveResponseSchema,
|
|
2903
|
+
CreatePaseoWorktreeResponseSchema,
|
|
2904
|
+
FileExplorerResponseSchema,
|
|
2905
|
+
ProjectIconResponseSchema,
|
|
2906
|
+
FileDownloadTokenResponseSchema,
|
|
2907
|
+
ListProviderModelsResponseMessageSchema,
|
|
2908
|
+
ListProviderModesResponseMessageSchema,
|
|
2909
|
+
ListProviderFeaturesResponseMessageSchema,
|
|
2910
|
+
ListAvailableProvidersResponseSchema,
|
|
2911
|
+
GetProvidersSnapshotResponseMessageSchema,
|
|
2912
|
+
ProvidersSnapshotUpdateMessageSchema,
|
|
2913
|
+
RefreshProvidersSnapshotResponseMessageSchema,
|
|
2914
|
+
ProviderDiagnosticResponseMessageSchema,
|
|
2915
|
+
ListCommandsResponseSchema,
|
|
2916
|
+
ListTerminalsResponseSchema,
|
|
2917
|
+
TerminalsChangedSchema,
|
|
2918
|
+
CreateTerminalResponseSchema,
|
|
2919
|
+
SubscribeTerminalResponseSchema,
|
|
2920
|
+
KillTerminalResponseSchema,
|
|
2921
|
+
CaptureTerminalResponseSchema,
|
|
2922
|
+
TerminalStreamExitSchema,
|
|
2923
|
+
ChatCreateResponseSchema,
|
|
2924
|
+
ChatListResponseSchema,
|
|
2925
|
+
ChatInspectResponseSchema,
|
|
2926
|
+
ChatDeleteResponseSchema,
|
|
2927
|
+
ChatPostResponseSchema,
|
|
2928
|
+
ChatReadResponseSchema,
|
|
2929
|
+
ChatWaitResponseSchema,
|
|
2930
|
+
ScheduleCreateResponseSchema,
|
|
2931
|
+
ScheduleListResponseSchema,
|
|
2932
|
+
ScheduleInspectResponseSchema,
|
|
2933
|
+
ScheduleLogsResponseSchema,
|
|
2934
|
+
SchedulePauseResponseSchema,
|
|
2935
|
+
ScheduleResumeResponseSchema,
|
|
2936
|
+
ScheduleDeleteResponseSchema,
|
|
2937
|
+
LoopRunResponseSchema,
|
|
2938
|
+
LoopListResponseSchema,
|
|
2939
|
+
LoopInspectResponseSchema,
|
|
2940
|
+
LoopLogsResponseSchema,
|
|
2941
|
+
LoopStopResponseSchema,
|
|
2942
|
+
]);
|
|
2943
|
+
// ============================================================================
|
|
2944
|
+
// WebSocket Level Messages (wraps session messages)
|
|
2945
|
+
// ============================================================================
|
|
2946
|
+
// WebSocket-only messages (not session messages)
|
|
2947
|
+
export const WSPingMessageSchema = z.object({
|
|
2948
|
+
type: z.literal("ping"),
|
|
2949
|
+
});
|
|
2950
|
+
export const WSPongMessageSchema = z.object({
|
|
2951
|
+
type: z.literal("pong"),
|
|
2952
|
+
});
|
|
2953
|
+
export const WSHelloMessageSchema = z.object({
|
|
2954
|
+
type: z.literal("hello"),
|
|
2955
|
+
clientId: z.string().min(1),
|
|
2956
|
+
clientType: z.enum(["mobile", "browser", "cli", "mcp"]),
|
|
2957
|
+
protocolVersion: z.number().int(),
|
|
2958
|
+
appVersion: z.string().optional(),
|
|
2959
|
+
capabilities: z
|
|
2960
|
+
.object({
|
|
2961
|
+
voice: z.boolean().optional(),
|
|
2962
|
+
pushNotifications: z.boolean().optional(),
|
|
2963
|
+
[CLIENT_CAPS.reasoningMergeEnum]: z.boolean().optional(),
|
|
2964
|
+
})
|
|
2965
|
+
.passthrough()
|
|
2966
|
+
.optional(),
|
|
2967
|
+
});
|
|
2968
|
+
export const WSRecordingStateMessageSchema = z.object({
|
|
2969
|
+
type: z.literal("recording_state"),
|
|
2970
|
+
isRecording: z.boolean(),
|
|
2971
|
+
});
|
|
2972
|
+
// Wrapped session message
|
|
2973
|
+
export const WSSessionInboundSchema = z.object({
|
|
2974
|
+
type: z.literal("session"),
|
|
2975
|
+
message: SessionInboundMessageSchema,
|
|
2976
|
+
});
|
|
2977
|
+
export const WSSessionOutboundSchema = z.object({
|
|
2978
|
+
type: z.literal("session"),
|
|
2979
|
+
message: SessionOutboundMessageSchema,
|
|
2980
|
+
});
|
|
2981
|
+
// Complete WebSocket message schemas
|
|
2982
|
+
export const WSInboundMessageSchema = z.discriminatedUnion("type", [
|
|
2983
|
+
WSPingMessageSchema,
|
|
2984
|
+
WSHelloMessageSchema,
|
|
2985
|
+
WSRecordingStateMessageSchema,
|
|
2986
|
+
WSSessionInboundSchema,
|
|
2987
|
+
]);
|
|
2988
|
+
export const WSOutboundMessageSchema = z.discriminatedUnion("type", [
|
|
2989
|
+
WSPongMessageSchema,
|
|
2990
|
+
WSSessionOutboundSchema,
|
|
2991
|
+
]);
|
|
2992
|
+
// ============================================================================
|
|
2993
|
+
// Helper functions for message conversion
|
|
2994
|
+
// ============================================================================
|
|
2995
|
+
/**
|
|
2996
|
+
* Extract session message from WebSocket message
|
|
2997
|
+
* Returns null if message should be handled at WS level only
|
|
2998
|
+
*/
|
|
2999
|
+
export function extractSessionMessage(wsMsg) {
|
|
3000
|
+
if (wsMsg.type === "session") {
|
|
3001
|
+
return wsMsg.message;
|
|
3002
|
+
}
|
|
3003
|
+
// Ping and recording_state are WS-level only
|
|
3004
|
+
return null;
|
|
3005
|
+
}
|
|
3006
|
+
/**
|
|
3007
|
+
* Wrap session message in WebSocket envelope
|
|
3008
|
+
*/
|
|
3009
|
+
export function wrapSessionMessage(sessionMsg) {
|
|
3010
|
+
return {
|
|
3011
|
+
type: "session",
|
|
3012
|
+
message: sessionMsg,
|
|
3013
|
+
};
|
|
3014
|
+
}
|
|
3015
|
+
export function parseServerInfoStatusPayload(payload) {
|
|
3016
|
+
const parsed = ServerInfoStatusPayloadSchema.safeParse(payload);
|
|
3017
|
+
if (!parsed.success) {
|
|
3018
|
+
return null;
|
|
3019
|
+
}
|
|
3020
|
+
return parsed.data;
|
|
3021
|
+
}
|
|
3022
|
+
//# sourceMappingURL=messages.js.map
|