agent-console-server 3.3.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/LICENSE +201 -0
- package/README.md +56 -0
- package/bin/cli.js +2 -0
- package/dist/EphemeralAgentEventTypes-Cm5oNQXu.js +274 -0
- package/dist/ServerMessage-Deh-bExC.js +363 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +36 -0
- package/dist/constants-eNCfNezp.d.ts +902 -0
- package/dist/contracts.d.ts +2 -0
- package/dist/contracts.js +3 -0
- package/dist/index.d.ts +323 -0
- package/dist/index.js +4 -0
- package/dist/readToken-CAukYBGj.js +1377 -0
- package/package.json +75 -0
|
@@ -0,0 +1,363 @@
|
|
|
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 };
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { G as TOKEN_QUERY_PARAMETER, H as DEFAULT_HOSTNAME, U as DEFAULT_PORT, V as DEFAULT_APP_ORIGIN, W as PAIRING_HASH_PARAMETER } from "./EphemeralAgentEventTypes-Cm5oNQXu.js";
|
|
2
|
+
import { f as createClaudeAgentSdkDriver, n as createAgentConsoleServer, t as readToken } from "./readToken-CAukYBGj.js";
|
|
3
|
+
import { RoutePath } from "@esposter/shared";
|
|
4
|
+
import { hostname } from "node:os";
|
|
5
|
+
import { once } from "node:events";
|
|
6
|
+
import { parseArgs } from "node:util";
|
|
7
|
+
//#region src/cli.ts
|
|
8
|
+
const { values } = parseArgs({ options: {
|
|
9
|
+
hostname: {
|
|
10
|
+
default: DEFAULT_HOSTNAME,
|
|
11
|
+
type: "string"
|
|
12
|
+
},
|
|
13
|
+
origin: {
|
|
14
|
+
default: DEFAULT_APP_ORIGIN,
|
|
15
|
+
type: "string"
|
|
16
|
+
},
|
|
17
|
+
port: {
|
|
18
|
+
default: String(DEFAULT_PORT),
|
|
19
|
+
type: "string"
|
|
20
|
+
}
|
|
21
|
+
} });
|
|
22
|
+
const token = readToken();
|
|
23
|
+
const server = await createAgentConsoleServer({
|
|
24
|
+
createDriver: (callbacks) => createClaudeAgentSdkDriver(callbacks),
|
|
25
|
+
hostname: values.hostname,
|
|
26
|
+
port: Number(values.port),
|
|
27
|
+
token
|
|
28
|
+
});
|
|
29
|
+
const reachableHostname = values.hostname === "0.0.0.0" ? hostname() : values.hostname;
|
|
30
|
+
const hostUrl = `ws://${reachableHostname}:${server.port}/?${TOKEN_QUERY_PARAMETER}=${token}`;
|
|
31
|
+
const pairingUrl = `${values.origin}${RoutePath.AgentConsole}#${PAIRING_HASH_PARAMETER}=${encodeURIComponent(hostUrl)}`;
|
|
32
|
+
process.stdout.write(`Agent console host listening on ${reachableHostname}:${server.port}\n\nOpen to pair:\n ${pairingUrl}\n\nOr paste this host URL into the page:\n ${hostUrl}\n`);
|
|
33
|
+
await once(process, "SIGINT");
|
|
34
|
+
await server.close();
|
|
35
|
+
//#endregion
|
|
36
|
+
export {};
|