agent-console-server 3.3.0 → 3.5.0
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/README.md +14 -12
- package/dist/EphemeralAgentEventTypes-DGkHIIcW.js +838 -0
- package/dist/cli.js +104 -26
- package/dist/contracts.d.ts +2 -2
- package/dist/contracts.js +2 -3
- package/dist/{constants-eNCfNezp.d.ts → getSignedText-DQwqr8CH.d.ts} +267 -8
- package/dist/index.d.ts +321 -12
- package/dist/index.js +3 -4
- package/dist/{readToken-CAukYBGj.js → spawnPtyShell-CtAiD2BH.js} +1104 -115
- package/package.json +9 -5
- package/dist/EphemeralAgentEventTypes-Cm5oNQXu.js +0 -274
- package/dist/ServerMessage-Deh-bExC.js +0 -363
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-console-server",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "The host behind the Esposter agent console — a loopback WebSocket that runs Claude Code sessions through the Claude Agent SDK and speaks a typed wire to the page.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsdown",
|
|
48
|
+
"build:sea": "tsdown -c tsdown.sea.config.ts && node scripts/copyClaudeCodeExecutable.ts && node scripts/copyNodePty.ts && node scripts/writeSeaConfig.ts && node --build-sea dist-sea/sea-config.json",
|
|
48
49
|
"export:gen": "generate-exports",
|
|
49
50
|
"format": "oxfmt",
|
|
50
51
|
"format:check": "oxfmt --check",
|
|
@@ -56,12 +57,12 @@
|
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
59
|
"@anthropic-ai/claude-agent-sdk": "^0.3.283",
|
|
59
|
-
"@esposter/shared": "3.
|
|
60
|
-
"ws": "^8.
|
|
60
|
+
"@esposter/shared": "3.5.0",
|
|
61
|
+
"ws": "^8.22.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@arethetypeswrong/core": "^0.18.5",
|
|
64
|
-
"@esposter/configuration": "3.
|
|
65
|
+
"@esposter/configuration": "3.5.0",
|
|
65
66
|
"@types/node": "^26.6.3",
|
|
66
67
|
"@types/ws": "^8.18.1",
|
|
67
68
|
"publint": "^0.3.24",
|
|
@@ -71,5 +72,8 @@
|
|
|
71
72
|
"peerDependencies": {
|
|
72
73
|
"zod": "^4.6.5"
|
|
73
74
|
},
|
|
74
|
-
"
|
|
75
|
+
"optionalDependencies": {
|
|
76
|
+
"node-pty": "^1.1.0"
|
|
77
|
+
},
|
|
78
|
+
"gitHead": "dd47fa9c4f07dcf7a9ce49a09874a6bcf4e4ace4"
|
|
75
79
|
}
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
//#region src/services/constants.ts
|
|
3
|
-
const DEFAULT_APP_ORIGIN = "https://esposter.com";
|
|
4
|
-
const DEFAULT_HOSTNAME = "127.0.0.1";
|
|
5
|
-
const DEFAULT_PORT = 7437;
|
|
6
|
-
const PAIRING_HASH_PARAMETER = "host";
|
|
7
|
-
const TOKEN_QUERY_PARAMETER = "token";
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/models/event/AgentEventType.ts
|
|
10
|
-
let AgentEventType = /* @__PURE__ */ function(AgentEventType) {
|
|
11
|
-
AgentEventType["AssistantMessage"] = "AssistantMessage";
|
|
12
|
-
AgentEventType["Capabilities"] = "Capabilities";
|
|
13
|
-
AgentEventType["CommandOutput"] = "CommandOutput";
|
|
14
|
-
AgentEventType["Compaction"] = "Compaction";
|
|
15
|
-
AgentEventType["ContextUsage"] = "ContextUsage";
|
|
16
|
-
AgentEventType["FileRewind"] = "FileRewind";
|
|
17
|
-
AgentEventType["Hook"] = "Hook";
|
|
18
|
-
AgentEventType["HostError"] = "HostError";
|
|
19
|
-
AgentEventType["PermissionRequest"] = "PermissionRequest";
|
|
20
|
-
AgentEventType["PermissionResolution"] = "PermissionResolution";
|
|
21
|
-
AgentEventType["RateLimit"] = "RateLimit";
|
|
22
|
-
AgentEventType["SessionInit"] = "SessionInit";
|
|
23
|
-
AgentEventType["SessionSettings"] = "SessionSettings";
|
|
24
|
-
AgentEventType["SessionState"] = "SessionState";
|
|
25
|
-
AgentEventType["StreamDelta"] = "StreamDelta";
|
|
26
|
-
AgentEventType["Subagent"] = "Subagent";
|
|
27
|
-
AgentEventType["Thinking"] = "Thinking";
|
|
28
|
-
AgentEventType["TodoUpdate"] = "TodoUpdate";
|
|
29
|
-
AgentEventType["ToolProgress"] = "ToolProgress";
|
|
30
|
-
AgentEventType["ToolResult"] = "ToolResult";
|
|
31
|
-
AgentEventType["ToolUse"] = "ToolUse";
|
|
32
|
-
AgentEventType["TurnResult"] = "TurnResult";
|
|
33
|
-
AgentEventType["TurnUsage"] = "TurnUsage";
|
|
34
|
-
AgentEventType["Unknown"] = "Unknown";
|
|
35
|
-
AgentEventType["UserMessage"] = "UserMessage";
|
|
36
|
-
return AgentEventType;
|
|
37
|
-
}({});
|
|
38
|
-
const agentEventTypeSchema = z.enum(AgentEventType);
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/models/session/SessionState.ts
|
|
41
|
-
let SessionState = /* @__PURE__ */ function(SessionState) {
|
|
42
|
-
SessionState["Closed"] = "Closed";
|
|
43
|
-
SessionState["Compacting"] = "Compacting";
|
|
44
|
-
SessionState["Idle"] = "Idle";
|
|
45
|
-
SessionState["RequiresAction"] = "RequiresAction";
|
|
46
|
-
SessionState["Running"] = "Running";
|
|
47
|
-
return SessionState;
|
|
48
|
-
}({});
|
|
49
|
-
const sessionStateSchema = z.enum(SessionState);
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/models/command/PermissionBehavior.ts
|
|
52
|
-
let PermissionBehavior = /* @__PURE__ */ function(PermissionBehavior) {
|
|
53
|
-
PermissionBehavior["Allow"] = "Allow";
|
|
54
|
-
PermissionBehavior["AllowAlways"] = "AllowAlways";
|
|
55
|
-
PermissionBehavior["Deny"] = "Deny";
|
|
56
|
-
return PermissionBehavior;
|
|
57
|
-
}({});
|
|
58
|
-
const permissionBehaviorSchema = z.enum(PermissionBehavior);
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/models/session/PermissionMode.ts
|
|
61
|
-
let PermissionMode = /* @__PURE__ */ function(PermissionMode) {
|
|
62
|
-
PermissionMode["AcceptEdits"] = "acceptEdits";
|
|
63
|
-
PermissionMode["Auto"] = "auto";
|
|
64
|
-
PermissionMode["BypassPermissions"] = "bypassPermissions";
|
|
65
|
-
PermissionMode["Default"] = "default";
|
|
66
|
-
PermissionMode["DontAsk"] = "dontAsk";
|
|
67
|
-
PermissionMode["Plan"] = "plan";
|
|
68
|
-
return PermissionMode;
|
|
69
|
-
}({});
|
|
70
|
-
const permissionModeSchema = z.enum(PermissionMode);
|
|
71
|
-
//#endregion
|
|
72
|
-
//#region src/models/event/TodoStatus.ts
|
|
73
|
-
let TodoStatus = /* @__PURE__ */ function(TodoStatus) {
|
|
74
|
-
TodoStatus["Completed"] = "completed";
|
|
75
|
-
TodoStatus["InProgress"] = "in_progress";
|
|
76
|
-
TodoStatus["Pending"] = "pending";
|
|
77
|
-
return TodoStatus;
|
|
78
|
-
}({});
|
|
79
|
-
const todoStatusSchema = z.enum(TodoStatus);
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/models/event/CompactionTrigger.ts
|
|
82
|
-
let CompactionTrigger = /* @__PURE__ */ function(CompactionTrigger) {
|
|
83
|
-
CompactionTrigger["Auto"] = "auto";
|
|
84
|
-
CompactionTrigger["Manual"] = "manual";
|
|
85
|
-
return CompactionTrigger;
|
|
86
|
-
}({});
|
|
87
|
-
const compactionTriggerSchema = z.enum(CompactionTrigger);
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/models/event/HookPhase.ts
|
|
90
|
-
let HookPhase = /* @__PURE__ */ function(HookPhase) {
|
|
91
|
-
HookPhase["Progress"] = "Progress";
|
|
92
|
-
HookPhase["Response"] = "Response";
|
|
93
|
-
HookPhase["Started"] = "Started";
|
|
94
|
-
return HookPhase;
|
|
95
|
-
}({});
|
|
96
|
-
const hookPhaseSchema = z.enum(HookPhase);
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/models/event/SubagentStatus.ts
|
|
99
|
-
let SubagentStatus = /* @__PURE__ */ function(SubagentStatus) {
|
|
100
|
-
SubagentStatus["Completed"] = "Completed";
|
|
101
|
-
SubagentStatus["Failed"] = "Failed";
|
|
102
|
-
SubagentStatus["Running"] = "Running";
|
|
103
|
-
SubagentStatus["Started"] = "Started";
|
|
104
|
-
SubagentStatus["Stopped"] = "Stopped";
|
|
105
|
-
return SubagentStatus;
|
|
106
|
-
}({});
|
|
107
|
-
const subagentStatusSchema = z.enum(SubagentStatus);
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/models/command/AttachmentMediaType.ts
|
|
110
|
-
let AttachmentMediaType = /* @__PURE__ */ function(AttachmentMediaType) {
|
|
111
|
-
AttachmentMediaType["Gif"] = "image/gif";
|
|
112
|
-
AttachmentMediaType["Jpeg"] = "image/jpeg";
|
|
113
|
-
AttachmentMediaType["Pdf"] = "application/pdf";
|
|
114
|
-
AttachmentMediaType["Png"] = "image/png";
|
|
115
|
-
AttachmentMediaType["Text"] = "text/plain";
|
|
116
|
-
AttachmentMediaType["Webp"] = "image/webp";
|
|
117
|
-
return AttachmentMediaType;
|
|
118
|
-
}({});
|
|
119
|
-
const attachmentMediaTypeSchema = z.enum(AttachmentMediaType);
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/models/command/BaseCommand.ts
|
|
122
|
-
const createBaseCommandSchema = (typeSchema) => z.object({
|
|
123
|
-
id: z.string().min(1),
|
|
124
|
-
type: typeSchema
|
|
125
|
-
});
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region src/models/command/CommandType.ts
|
|
128
|
-
let CommandType = /* @__PURE__ */ function(CommandType) {
|
|
129
|
-
CommandType["CloseSession"] = "CloseSession";
|
|
130
|
-
CommandType["CreateSession"] = "CreateSession";
|
|
131
|
-
CommandType["Fork"] = "Fork";
|
|
132
|
-
CommandType["Interrupt"] = "Interrupt";
|
|
133
|
-
CommandType["ListSessions"] = "ListSessions";
|
|
134
|
-
CommandType["PermissionVerdict"] = "PermissionVerdict";
|
|
135
|
-
CommandType["Prompt"] = "Prompt";
|
|
136
|
-
CommandType["Resume"] = "Resume";
|
|
137
|
-
CommandType["ResumeAt"] = "ResumeAt";
|
|
138
|
-
CommandType["RewindFiles"] = "RewindFiles";
|
|
139
|
-
CommandType["SetModel"] = "SetModel";
|
|
140
|
-
CommandType["SetPermissionMode"] = "SetPermissionMode";
|
|
141
|
-
CommandType["SlashCommand"] = "SlashCommand";
|
|
142
|
-
return CommandType;
|
|
143
|
-
}({});
|
|
144
|
-
const commandTypeSchema = z.enum(CommandType);
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/models/command/SessionId.ts
|
|
147
|
-
const sessionIdSchema = z.object({ sessionId: z.string().min(1) });
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region src/models/command/CloseSessionCommand.ts
|
|
150
|
-
const closeSessionCommandSchema = z.object({
|
|
151
|
-
...createBaseCommandSchema(z.literal("CloseSession")).shape,
|
|
152
|
-
...sessionIdSchema.shape
|
|
153
|
-
});
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region src/models/command/CreateSessionCommand.ts
|
|
156
|
-
const createSessionCommandSchema = z.object({
|
|
157
|
-
...createBaseCommandSchema(z.literal("CreateSession")).shape,
|
|
158
|
-
cwd: z.string().min(1)
|
|
159
|
-
});
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/models/command/ForkCommand.ts
|
|
162
|
-
const forkCommandSchema = z.object({
|
|
163
|
-
...createBaseCommandSchema(z.literal("Fork")).shape,
|
|
164
|
-
...sessionIdSchema.shape,
|
|
165
|
-
messageUuid: z.string()
|
|
166
|
-
});
|
|
167
|
-
//#endregion
|
|
168
|
-
//#region src/models/command/InterruptCommand.ts
|
|
169
|
-
const interruptCommandSchema = z.object({
|
|
170
|
-
...createBaseCommandSchema(z.literal("Interrupt")).shape,
|
|
171
|
-
...sessionIdSchema.shape
|
|
172
|
-
});
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/models/command/ListSessionsCommand.ts
|
|
175
|
-
const listSessionsCommandSchema = z.object({ ...createBaseCommandSchema(z.literal("ListSessions")).shape });
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region src/models/command/PermissionVerdictCommand.ts
|
|
178
|
-
const permissionVerdictCommandSchema = z.object({
|
|
179
|
-
...createBaseCommandSchema(z.literal("PermissionVerdict")).shape,
|
|
180
|
-
...sessionIdSchema.shape,
|
|
181
|
-
behavior: permissionBehaviorSchema,
|
|
182
|
-
message: z.string(),
|
|
183
|
-
requestId: z.string().min(1)
|
|
184
|
-
});
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/models/command/Attachment.ts
|
|
187
|
-
const attachmentSchema = z.object({
|
|
188
|
-
data: z.string(),
|
|
189
|
-
mediaType: attachmentMediaTypeSchema,
|
|
190
|
-
name: z.string()
|
|
191
|
-
});
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/models/command/PromptCommand.ts
|
|
194
|
-
const promptCommandSchema = z.object({
|
|
195
|
-
...createBaseCommandSchema(z.literal("Prompt")).shape,
|
|
196
|
-
...sessionIdSchema.shape,
|
|
197
|
-
attachments: attachmentSchema.array(),
|
|
198
|
-
text: z.string()
|
|
199
|
-
});
|
|
200
|
-
//#endregion
|
|
201
|
-
//#region src/models/command/ResumeAtCommand.ts
|
|
202
|
-
const resumeAtCommandSchema = z.object({
|
|
203
|
-
...createBaseCommandSchema(z.literal("ResumeAt")).shape,
|
|
204
|
-
...sessionIdSchema.shape,
|
|
205
|
-
messageUuid: z.string().min(1)
|
|
206
|
-
});
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/models/command/ResumeCommand.ts
|
|
209
|
-
const resumeCommandSchema = z.object({
|
|
210
|
-
...createBaseCommandSchema(z.literal("Resume")).shape,
|
|
211
|
-
...sessionIdSchema.shape
|
|
212
|
-
});
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/models/command/RewindFilesCommand.ts
|
|
215
|
-
const rewindFilesCommandSchema = z.object({
|
|
216
|
-
...createBaseCommandSchema(z.literal("RewindFiles")).shape,
|
|
217
|
-
...sessionIdSchema.shape,
|
|
218
|
-
messageUuid: z.string().min(1)
|
|
219
|
-
});
|
|
220
|
-
//#endregion
|
|
221
|
-
//#region src/models/command/SetModelCommand.ts
|
|
222
|
-
const setModelCommandSchema = z.object({
|
|
223
|
-
...createBaseCommandSchema(z.literal("SetModel")).shape,
|
|
224
|
-
...sessionIdSchema.shape,
|
|
225
|
-
model: z.string().min(1)
|
|
226
|
-
});
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/models/command/SetPermissionModeCommand.ts
|
|
229
|
-
const setPermissionModeCommandSchema = z.object({
|
|
230
|
-
...createBaseCommandSchema(z.literal("SetPermissionMode")).shape,
|
|
231
|
-
...sessionIdSchema.shape,
|
|
232
|
-
permissionMode: permissionModeSchema
|
|
233
|
-
});
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/models/command/SlashCommandCommand.ts
|
|
236
|
-
const slashCommandCommandSchema = z.object({
|
|
237
|
-
...createBaseCommandSchema(z.literal("SlashCommand")).shape,
|
|
238
|
-
...sessionIdSchema.shape,
|
|
239
|
-
arguments: z.string(),
|
|
240
|
-
name: z.string().min(1)
|
|
241
|
-
});
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region src/models/command/Command.ts
|
|
244
|
-
const commandSchema = z.discriminatedUnion("type", [
|
|
245
|
-
closeSessionCommandSchema,
|
|
246
|
-
createSessionCommandSchema,
|
|
247
|
-
forkCommandSchema,
|
|
248
|
-
interruptCommandSchema,
|
|
249
|
-
listSessionsCommandSchema,
|
|
250
|
-
permissionVerdictCommandSchema,
|
|
251
|
-
promptCommandSchema,
|
|
252
|
-
resumeAtCommandSchema,
|
|
253
|
-
resumeCommandSchema,
|
|
254
|
-
rewindFilesCommandSchema,
|
|
255
|
-
setModelCommandSchema,
|
|
256
|
-
setPermissionModeCommandSchema,
|
|
257
|
-
slashCommandCommandSchema
|
|
258
|
-
]);
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/models/server/ServerMessageType.ts
|
|
261
|
-
let ServerMessageType = /* @__PURE__ */ function(ServerMessageType) {
|
|
262
|
-
ServerMessageType["CommandError"] = "CommandError";
|
|
263
|
-
ServerMessageType["Events"] = "Events";
|
|
264
|
-
ServerMessageType["SessionOpened"] = "SessionOpened";
|
|
265
|
-
ServerMessageType["SessionReset"] = "SessionReset";
|
|
266
|
-
ServerMessageType["Sessions"] = "Sessions";
|
|
267
|
-
return ServerMessageType;
|
|
268
|
-
}({});
|
|
269
|
-
const serverMessageTypeSchema = z.enum(ServerMessageType);
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region src/models/event/EphemeralAgentEventTypes.ts
|
|
272
|
-
const EphemeralAgentEventTypes = ["StreamDelta", "TurnUsage"];
|
|
273
|
-
//#endregion
|
|
274
|
-
export { compactionTriggerSchema as A, agentEventTypeSchema as B, AttachmentMediaType as C, HookPhase as D, subagentStatusSchema as E, PermissionBehavior as F, TOKEN_QUERY_PARAMETER as G, DEFAULT_HOSTNAME as H, permissionBehaviorSchema as I, SessionState as L, todoStatusSchema as M, PermissionMode as N, hookPhaseSchema as O, permissionModeSchema as P, sessionStateSchema as R, createBaseCommandSchema as S, SubagentStatus as T, DEFAULT_PORT as U, DEFAULT_APP_ORIGIN as V, PAIRING_HASH_PARAMETER as W, createSessionCommandSchema as _, slashCommandCommandSchema as a, CommandType as b, rewindFilesCommandSchema as c, promptCommandSchema as d, attachmentSchema as f, forkCommandSchema as g, interruptCommandSchema as h, commandSchema as i, TodoStatus as j, CompactionTrigger as k, resumeCommandSchema as l, listSessionsCommandSchema as m, ServerMessageType as n, setPermissionModeCommandSchema as o, permissionVerdictCommandSchema as p, serverMessageTypeSchema as r, setModelCommandSchema as s, EphemeralAgentEventTypes as t, resumeAtCommandSchema as u, closeSessionCommandSchema as v, attachmentMediaTypeSchema as w, commandTypeSchema as x, sessionIdSchema as y, AgentEventType as z };
|
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import { A as compactionTriggerSchema, E as subagentStatusSchema, I as permissionBehaviorSchema, M as todoStatusSchema, O as hookPhaseSchema, P as permissionModeSchema, R as sessionStateSchema } from "./EphemeralAgentEventTypes-Cm5oNQXu.js";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { createUniqueArraySchema } from "@esposter/shared";
|
|
4
|
-
//#region src/models/event/BaseAgentEvent.ts
|
|
5
|
-
const createBaseAgentEventSchema = (typeSchema) => z.object({
|
|
6
|
-
createdAt: z.coerce.date(),
|
|
7
|
-
id: z.string().min(1),
|
|
8
|
-
type: typeSchema
|
|
9
|
-
});
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/models/event/MessageUuid.ts
|
|
12
|
-
const messageUuidSchema = z.object({ messageUuid: z.string() });
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/models/event/ParentToolUseId.ts
|
|
15
|
-
const parentToolUseIdSchema = z.object({ parentToolUseId: z.string() });
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/models/event/AssistantMessageEvent.ts
|
|
18
|
-
const assistantMessageEventSchema = z.object({
|
|
19
|
-
...createBaseAgentEventSchema(z.literal("AssistantMessage")).shape,
|
|
20
|
-
...messageUuidSchema.shape,
|
|
21
|
-
...parentToolUseIdSchema.shape,
|
|
22
|
-
text: z.string()
|
|
23
|
-
});
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/models/event/Model.ts
|
|
26
|
-
const modelSchema = z.object({
|
|
27
|
-
description: z.string(),
|
|
28
|
-
displayName: z.string(),
|
|
29
|
-
value: z.string().min(1)
|
|
30
|
-
});
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/models/event/SlashCommand.ts
|
|
33
|
-
const slashCommandSchema = z.object({
|
|
34
|
-
argumentHint: z.string(),
|
|
35
|
-
description: z.string(),
|
|
36
|
-
name: z.string().min(1)
|
|
37
|
-
});
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/models/event/CapabilitiesEvent.ts
|
|
40
|
-
const capabilitiesEventSchema = z.object({
|
|
41
|
-
...createBaseAgentEventSchema(z.literal("Capabilities")).shape,
|
|
42
|
-
commands: createUniqueArraySchema(slashCommandSchema, "name"),
|
|
43
|
-
models: createUniqueArraySchema(modelSchema, "value")
|
|
44
|
-
});
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/models/event/CommandOutputEvent.ts
|
|
47
|
-
const commandOutputEventSchema = z.object({
|
|
48
|
-
...createBaseAgentEventSchema(z.literal("CommandOutput")).shape,
|
|
49
|
-
content: z.string()
|
|
50
|
-
});
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/models/event/CompactionEvent.ts
|
|
53
|
-
const compactionEventSchema = z.object({
|
|
54
|
-
...createBaseAgentEventSchema(z.literal("Compaction")).shape,
|
|
55
|
-
postTokens: z.int().nonnegative(),
|
|
56
|
-
preTokens: z.int().nonnegative(),
|
|
57
|
-
trigger: compactionTriggerSchema
|
|
58
|
-
});
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/models/event/ContextUsageEvent.ts
|
|
61
|
-
const contextUsageEventSchema = z.object({
|
|
62
|
-
...createBaseAgentEventSchema(z.literal("ContextUsage")).shape,
|
|
63
|
-
autoCompactThreshold: z.int().nonnegative(),
|
|
64
|
-
isAutoCompactEnabled: z.boolean(),
|
|
65
|
-
maxTokens: z.int().positive(),
|
|
66
|
-
percentage: z.number().nonnegative(),
|
|
67
|
-
totalTokens: z.int().nonnegative()
|
|
68
|
-
});
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region src/models/event/FileRewindEvent.ts
|
|
71
|
-
const fileRewindEventSchema = z.object({
|
|
72
|
-
...createBaseAgentEventSchema(z.literal("FileRewind")).shape,
|
|
73
|
-
...messageUuidSchema.shape,
|
|
74
|
-
deletions: z.int().nonnegative(),
|
|
75
|
-
filePaths: z.string().array(),
|
|
76
|
-
insertions: z.int().nonnegative()
|
|
77
|
-
});
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/models/event/HookEvent.ts
|
|
80
|
-
const hookEventSchema = z.object({
|
|
81
|
-
...createBaseAgentEventSchema(z.literal("Hook")).shape,
|
|
82
|
-
exitCode: z.int(),
|
|
83
|
-
hookEvent: z.string().min(1),
|
|
84
|
-
hookId: z.string().min(1),
|
|
85
|
-
hookName: z.string(),
|
|
86
|
-
outcome: z.string(),
|
|
87
|
-
output: z.string(),
|
|
88
|
-
phase: hookPhaseSchema,
|
|
89
|
-
stderr: z.string(),
|
|
90
|
-
stdout: z.string()
|
|
91
|
-
});
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/models/event/HostErrorEvent.ts
|
|
94
|
-
const hostErrorEventSchema = z.object({
|
|
95
|
-
...createBaseAgentEventSchema(z.literal("HostError")).shape,
|
|
96
|
-
message: z.string().min(1)
|
|
97
|
-
});
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/models/event/PermissionRequestEvent.ts
|
|
100
|
-
const permissionRequestEventSchema = z.object({
|
|
101
|
-
...createBaseAgentEventSchema(z.literal("PermissionRequest")).shape,
|
|
102
|
-
blockedPath: z.string(),
|
|
103
|
-
decisionReason: z.string(),
|
|
104
|
-
hasSuggestions: z.boolean(),
|
|
105
|
-
input: z.record(z.string(), z.unknown()),
|
|
106
|
-
requestId: z.string().min(1),
|
|
107
|
-
title: z.string(),
|
|
108
|
-
toolName: z.string().min(1),
|
|
109
|
-
toolUseId: z.string()
|
|
110
|
-
});
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/models/event/PermissionResolutionEvent.ts
|
|
113
|
-
const permissionResolutionEventSchema = z.object({
|
|
114
|
-
...createBaseAgentEventSchema(z.literal("PermissionResolution")).shape,
|
|
115
|
-
behavior: permissionBehaviorSchema,
|
|
116
|
-
requestId: z.string().min(1)
|
|
117
|
-
});
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/models/event/RateLimitEvent.ts
|
|
120
|
-
const rateLimitEventSchema = z.object({
|
|
121
|
-
...createBaseAgentEventSchema(z.literal("RateLimit")).shape,
|
|
122
|
-
rateLimitType: z.string(),
|
|
123
|
-
resetsAt: z.coerce.date().optional(),
|
|
124
|
-
status: z.string().min(1),
|
|
125
|
-
utilization: z.number().min(0).max(1).optional()
|
|
126
|
-
});
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/models/event/McpServer.ts
|
|
129
|
-
const mcpServerSchema = z.object({
|
|
130
|
-
name: z.string(),
|
|
131
|
-
status: z.string()
|
|
132
|
-
});
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region src/models/event/SessionInitEvent.ts
|
|
135
|
-
const sessionInitEventSchema = z.object({
|
|
136
|
-
...createBaseAgentEventSchema(z.literal("SessionInit")).shape,
|
|
137
|
-
agents: createUniqueArraySchema(z.string()),
|
|
138
|
-
claudeCodeVersion: z.string(),
|
|
139
|
-
cwd: z.string(),
|
|
140
|
-
mcpServers: createUniqueArraySchema(mcpServerSchema, "name"),
|
|
141
|
-
model: z.string(),
|
|
142
|
-
outputStyle: z.string(),
|
|
143
|
-
permissionMode: permissionModeSchema,
|
|
144
|
-
plugins: createUniqueArraySchema(z.string()),
|
|
145
|
-
skills: createUniqueArraySchema(z.string()),
|
|
146
|
-
slashCommands: createUniqueArraySchema(z.string()),
|
|
147
|
-
tools: createUniqueArraySchema(z.string())
|
|
148
|
-
});
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/models/event/SessionSettingsEvent.ts
|
|
151
|
-
const sessionSettingsEventSchema = z.object({
|
|
152
|
-
...createBaseAgentEventSchema(z.literal("SessionSettings")).shape,
|
|
153
|
-
model: z.string(),
|
|
154
|
-
permissionMode: permissionModeSchema
|
|
155
|
-
});
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/models/event/SessionStateEvent.ts
|
|
158
|
-
const sessionStateEventSchema = z.object({
|
|
159
|
-
...createBaseAgentEventSchema(z.literal("SessionState")).shape,
|
|
160
|
-
state: sessionStateSchema
|
|
161
|
-
});
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/models/event/StreamDeltaEvent.ts
|
|
164
|
-
const streamDeltaEventSchema = z.object({
|
|
165
|
-
...createBaseAgentEventSchema(z.literal("StreamDelta")).shape,
|
|
166
|
-
blockId: z.string().min(1),
|
|
167
|
-
isThinking: z.boolean(),
|
|
168
|
-
text: z.string()
|
|
169
|
-
});
|
|
170
|
-
//#endregion
|
|
171
|
-
//#region src/models/event/SubagentEvent.ts
|
|
172
|
-
const subagentEventSchema = z.object({
|
|
173
|
-
...createBaseAgentEventSchema(z.literal("Subagent")).shape,
|
|
174
|
-
description: z.string(),
|
|
175
|
-
durationMs: z.number().nonnegative(),
|
|
176
|
-
lastToolName: z.string(),
|
|
177
|
-
status: subagentStatusSchema,
|
|
178
|
-
subagentType: z.string(),
|
|
179
|
-
summary: z.string(),
|
|
180
|
-
taskId: z.string().min(1),
|
|
181
|
-
toolUseId: z.string(),
|
|
182
|
-
toolUses: z.int().nonnegative(),
|
|
183
|
-
totalTokens: z.int().nonnegative()
|
|
184
|
-
});
|
|
185
|
-
//#endregion
|
|
186
|
-
//#region src/models/event/ThinkingEvent.ts
|
|
187
|
-
const thinkingEventSchema = z.object({
|
|
188
|
-
...createBaseAgentEventSchema(z.literal("Thinking")).shape,
|
|
189
|
-
...messageUuidSchema.shape,
|
|
190
|
-
...parentToolUseIdSchema.shape,
|
|
191
|
-
thinking: z.string()
|
|
192
|
-
});
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/models/event/Todo.ts
|
|
195
|
-
const todoSchema = z.object({
|
|
196
|
-
activeForm: z.string(),
|
|
197
|
-
content: z.string(),
|
|
198
|
-
id: z.string().min(1),
|
|
199
|
-
status: todoStatusSchema
|
|
200
|
-
});
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region src/models/event/TodoUpdateEvent.ts
|
|
203
|
-
const todoUpdateEventSchema = z.object({
|
|
204
|
-
...createBaseAgentEventSchema(z.literal("TodoUpdate")).shape,
|
|
205
|
-
todos: createUniqueArraySchema(todoSchema, "id")
|
|
206
|
-
});
|
|
207
|
-
//#endregion
|
|
208
|
-
//#region src/models/event/ToolProgressEvent.ts
|
|
209
|
-
const toolProgressEventSchema = z.object({
|
|
210
|
-
...createBaseAgentEventSchema(z.literal("ToolProgress")).shape,
|
|
211
|
-
...parentToolUseIdSchema.shape,
|
|
212
|
-
elapsedSeconds: z.number().nonnegative(),
|
|
213
|
-
toolUseId: z.string().min(1)
|
|
214
|
-
});
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region src/models/event/ToolResultEvent.ts
|
|
217
|
-
const toolResultEventSchema = z.object({
|
|
218
|
-
...createBaseAgentEventSchema(z.literal("ToolResult")).shape,
|
|
219
|
-
...parentToolUseIdSchema.shape,
|
|
220
|
-
content: z.string(),
|
|
221
|
-
isError: z.boolean(),
|
|
222
|
-
originalText: z.string().optional(),
|
|
223
|
-
toolUseId: z.string().min(1)
|
|
224
|
-
});
|
|
225
|
-
//#endregion
|
|
226
|
-
//#region src/models/event/ToolUseEvent.ts
|
|
227
|
-
const toolUseEventSchema = z.object({
|
|
228
|
-
...createBaseAgentEventSchema(z.literal("ToolUse")).shape,
|
|
229
|
-
...messageUuidSchema.shape,
|
|
230
|
-
...parentToolUseIdSchema.shape,
|
|
231
|
-
input: z.record(z.string(), z.unknown()),
|
|
232
|
-
name: z.string().min(1),
|
|
233
|
-
toolUseId: z.string().min(1)
|
|
234
|
-
});
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/models/event/TokenUsage.ts
|
|
237
|
-
const tokenUsageSchema = z.object({
|
|
238
|
-
cacheCreationInputTokens: z.int().nonnegative(),
|
|
239
|
-
cacheReadInputTokens: z.int().nonnegative(),
|
|
240
|
-
inputTokens: z.int().nonnegative(),
|
|
241
|
-
outputTokens: z.int().nonnegative()
|
|
242
|
-
});
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/models/event/TurnResultEvent.ts
|
|
245
|
-
const turnResultEventSchema = z.object({
|
|
246
|
-
...createBaseAgentEventSchema(z.literal("TurnResult")).shape,
|
|
247
|
-
durationApiMs: z.number().nonnegative(),
|
|
248
|
-
durationMs: z.number().nonnegative(),
|
|
249
|
-
errors: z.string().array(),
|
|
250
|
-
isError: z.boolean(),
|
|
251
|
-
numTurns: z.int().nonnegative(),
|
|
252
|
-
result: z.string(),
|
|
253
|
-
subtype: z.string().min(1),
|
|
254
|
-
totalCostUsd: z.number().nonnegative(),
|
|
255
|
-
usage: tokenUsageSchema
|
|
256
|
-
});
|
|
257
|
-
//#endregion
|
|
258
|
-
//#region src/models/event/TurnUsageEvent.ts
|
|
259
|
-
const turnUsageEventSchema = z.object({
|
|
260
|
-
...createBaseAgentEventSchema(z.literal("TurnUsage")).shape,
|
|
261
|
-
outputTokens: z.int().nonnegative()
|
|
262
|
-
});
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/models/event/UnknownEvent.ts
|
|
265
|
-
const unknownEventSchema = z.object({
|
|
266
|
-
...createBaseAgentEventSchema(z.literal("Unknown")).shape,
|
|
267
|
-
raw: z.string(),
|
|
268
|
-
sdkType: z.string()
|
|
269
|
-
});
|
|
270
|
-
//#endregion
|
|
271
|
-
//#region src/models/event/UserMessageEvent.ts
|
|
272
|
-
const userMessageEventSchema = z.object({
|
|
273
|
-
...createBaseAgentEventSchema(z.literal("UserMessage")).shape,
|
|
274
|
-
...messageUuidSchema.shape,
|
|
275
|
-
...parentToolUseIdSchema.shape,
|
|
276
|
-
attachmentCount: z.int().nonnegative(),
|
|
277
|
-
text: z.string()
|
|
278
|
-
});
|
|
279
|
-
//#endregion
|
|
280
|
-
//#region src/models/event/AgentEvent.ts
|
|
281
|
-
const agentEventSchema = z.discriminatedUnion("type", [
|
|
282
|
-
assistantMessageEventSchema,
|
|
283
|
-
capabilitiesEventSchema,
|
|
284
|
-
commandOutputEventSchema,
|
|
285
|
-
compactionEventSchema,
|
|
286
|
-
contextUsageEventSchema,
|
|
287
|
-
fileRewindEventSchema,
|
|
288
|
-
hookEventSchema,
|
|
289
|
-
hostErrorEventSchema,
|
|
290
|
-
permissionRequestEventSchema,
|
|
291
|
-
permissionResolutionEventSchema,
|
|
292
|
-
rateLimitEventSchema,
|
|
293
|
-
sessionInitEventSchema,
|
|
294
|
-
sessionSettingsEventSchema,
|
|
295
|
-
sessionStateEventSchema,
|
|
296
|
-
streamDeltaEventSchema,
|
|
297
|
-
subagentEventSchema,
|
|
298
|
-
thinkingEventSchema,
|
|
299
|
-
todoUpdateEventSchema,
|
|
300
|
-
toolProgressEventSchema,
|
|
301
|
-
toolResultEventSchema,
|
|
302
|
-
toolUseEventSchema,
|
|
303
|
-
turnResultEventSchema,
|
|
304
|
-
turnUsageEventSchema,
|
|
305
|
-
unknownEventSchema,
|
|
306
|
-
userMessageEventSchema
|
|
307
|
-
]);
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region src/models/server/BaseServerMessage.ts
|
|
310
|
-
const createBaseServerMessageSchema = (typeSchema) => z.object({ type: typeSchema });
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region src/models/server/CommandErrorMessage.ts
|
|
313
|
-
const commandErrorMessageSchema = z.object({
|
|
314
|
-
...createBaseServerMessageSchema(z.literal("CommandError")).shape,
|
|
315
|
-
commandId: z.string(),
|
|
316
|
-
message: z.string().min(1)
|
|
317
|
-
});
|
|
318
|
-
//#endregion
|
|
319
|
-
//#region src/models/server/EventsMessage.ts
|
|
320
|
-
const eventsMessageSchema = z.object({
|
|
321
|
-
...createBaseServerMessageSchema(z.literal("Events")).shape,
|
|
322
|
-
events: createUniqueArraySchema(agentEventSchema, "id"),
|
|
323
|
-
sessionId: z.string().min(1)
|
|
324
|
-
});
|
|
325
|
-
//#endregion
|
|
326
|
-
//#region src/models/server/SessionOpenedMessage.ts
|
|
327
|
-
const sessionOpenedMessageSchema = z.object({
|
|
328
|
-
...createBaseServerMessageSchema(z.literal("SessionOpened")).shape,
|
|
329
|
-
commandId: z.string().min(1),
|
|
330
|
-
sessionId: z.string().min(1)
|
|
331
|
-
});
|
|
332
|
-
//#endregion
|
|
333
|
-
//#region src/models/server/SessionResetMessage.ts
|
|
334
|
-
const sessionResetMessageSchema = z.object({
|
|
335
|
-
...createBaseServerMessageSchema(z.literal("SessionReset")).shape,
|
|
336
|
-
sessionId: z.string().min(1)
|
|
337
|
-
});
|
|
338
|
-
//#endregion
|
|
339
|
-
//#region src/models/session/SessionSummary.ts
|
|
340
|
-
const sessionSummarySchema = z.object({
|
|
341
|
-
cwd: z.string(),
|
|
342
|
-
id: z.string().min(1),
|
|
343
|
-
lastActivityAt: z.coerce.date(),
|
|
344
|
-
state: sessionStateSchema,
|
|
345
|
-
title: z.string()
|
|
346
|
-
});
|
|
347
|
-
//#endregion
|
|
348
|
-
//#region src/models/server/SessionsMessage.ts
|
|
349
|
-
const sessionsMessageSchema = z.object({
|
|
350
|
-
...createBaseServerMessageSchema(z.literal("Sessions")).shape,
|
|
351
|
-
sessions: createUniqueArraySchema(sessionSummarySchema, "id")
|
|
352
|
-
});
|
|
353
|
-
//#endregion
|
|
354
|
-
//#region src/models/server/ServerMessage.ts
|
|
355
|
-
const serverMessageSchema = z.discriminatedUnion("type", [
|
|
356
|
-
commandErrorMessageSchema,
|
|
357
|
-
eventsMessageSchema,
|
|
358
|
-
sessionOpenedMessageSchema,
|
|
359
|
-
sessionResetMessageSchema,
|
|
360
|
-
sessionsMessageSchema
|
|
361
|
-
]);
|
|
362
|
-
//#endregion
|
|
363
|
-
export { hostErrorEventSchema as A, parentToolUseIdSchema as B, sessionStateEventSchema as C, rateLimitEventSchema as D, mcpServerSchema as E, commandOutputEventSchema as F, createBaseAgentEventSchema as H, capabilitiesEventSchema as I, slashCommandSchema as L, fileRewindEventSchema as M, contextUsageEventSchema as N, permissionResolutionEventSchema as O, compactionEventSchema as P, modelSchema as R, streamDeltaEventSchema as S, sessionInitEventSchema as T, messageUuidSchema as V, toolProgressEventSchema as _, sessionOpenedMessageSchema as a, thinkingEventSchema as b, createBaseServerMessageSchema as c, unknownEventSchema as d, turnUsageEventSchema as f, toolResultEventSchema as g, toolUseEventSchema as h, sessionResetMessageSchema as i, hookEventSchema as j, permissionRequestEventSchema as k, agentEventSchema as l, tokenUsageSchema as m, sessionsMessageSchema as n, eventsMessageSchema as o, turnResultEventSchema as p, sessionSummarySchema as r, commandErrorMessageSchema as s, serverMessageSchema as t, userMessageEventSchema as u, todoUpdateEventSchema as v, sessionSettingsEventSchema as w, subagentEventSchema as x, todoSchema as y, assistantMessageEventSchema as z };
|