@directive-run/ai 1.13.0 → 1.14.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.
Files changed (122) hide show
  1. package/dist/anthropic.d.cts +1 -1
  2. package/dist/anthropic.d.ts +1 -1
  3. package/dist/{chunk-XV2QSBBE.cjs → chunk-2TD4ZSGZ.cjs} +7 -7
  4. package/dist/{chunk-XV2QSBBE.cjs.map → chunk-2TD4ZSGZ.cjs.map} +1 -1
  5. package/dist/chunk-5JQ2A3JK.js +2 -0
  6. package/dist/chunk-5JQ2A3JK.js.map +1 -0
  7. package/dist/chunk-A22KLB23.cjs +67 -0
  8. package/dist/chunk-A22KLB23.cjs.map +1 -0
  9. package/dist/chunk-A5K77UDX.cjs +4 -0
  10. package/dist/chunk-A5K77UDX.cjs.map +1 -0
  11. package/dist/chunk-DN5NAJM6.js +6 -0
  12. package/dist/chunk-DN5NAJM6.js.map +1 -0
  13. package/dist/chunk-FABDFT74.cjs +6 -0
  14. package/dist/chunk-FABDFT74.cjs.map +1 -0
  15. package/dist/chunk-FBT73WFY.js +2 -0
  16. package/dist/chunk-FBT73WFY.js.map +1 -0
  17. package/dist/chunk-FFRWQNK7.cjs +7 -0
  18. package/dist/chunk-FFRWQNK7.cjs.map +1 -0
  19. package/dist/chunk-IR3IHBVQ.cjs +2 -0
  20. package/dist/chunk-IR3IHBVQ.cjs.map +1 -0
  21. package/dist/chunk-IUGSMTBE.js +16 -0
  22. package/dist/{chunk-Q3PQLWBR.js.map → chunk-IUGSMTBE.js.map} +1 -1
  23. package/dist/chunk-J2Q5KKPN.js +37 -0
  24. package/dist/chunk-J2Q5KKPN.js.map +1 -0
  25. package/dist/chunk-K64WKZ22.cjs +2 -0
  26. package/dist/chunk-K64WKZ22.cjs.map +1 -0
  27. package/dist/chunk-LKY4K5TV.cjs +11 -0
  28. package/dist/chunk-LKY4K5TV.cjs.map +1 -0
  29. package/dist/chunk-LXUMJKGJ.js +67 -0
  30. package/dist/chunk-LXUMJKGJ.js.map +1 -0
  31. package/dist/chunk-NNAQ4ZH2.js +11 -0
  32. package/dist/chunk-NNAQ4ZH2.js.map +1 -0
  33. package/dist/chunk-PD772MSE.cjs +30 -0
  34. package/dist/chunk-PD772MSE.cjs.map +1 -0
  35. package/dist/chunk-POBEEJR6.js +30 -0
  36. package/dist/chunk-POBEEJR6.js.map +1 -0
  37. package/dist/chunk-QRXWLD6H.js +4 -0
  38. package/dist/chunk-QRXWLD6H.js.map +1 -0
  39. package/dist/chunk-UR4ZGO7V.js +7 -0
  40. package/dist/chunk-UR4ZGO7V.js.map +1 -0
  41. package/dist/chunk-UR5BMWEN.js +2 -0
  42. package/dist/chunk-UR5BMWEN.js.map +1 -0
  43. package/dist/chunk-WOFIBIPW.cjs +2 -0
  44. package/dist/chunk-WOFIBIPW.cjs.map +1 -0
  45. package/dist/chunk-XN5LUOVS.cjs +37 -0
  46. package/dist/chunk-XN5LUOVS.cjs.map +1 -0
  47. package/dist/debug-timeline-DpnRMnLU.d.cts +87 -0
  48. package/dist/debug-timeline-L13P-U2I.d.ts +87 -0
  49. package/dist/devtools.cjs +2 -0
  50. package/dist/devtools.cjs.map +1 -0
  51. package/dist/devtools.d.cts +354 -0
  52. package/dist/devtools.d.ts +354 -0
  53. package/dist/devtools.js +2 -0
  54. package/dist/devtools.js.map +1 -0
  55. package/dist/evals.cjs +2 -0
  56. package/dist/evals.cjs.map +1 -0
  57. package/dist/evals.d.cts +361 -0
  58. package/dist/evals.d.ts +361 -0
  59. package/dist/evals.js +2 -0
  60. package/dist/evals.js.map +1 -0
  61. package/dist/gemini.d.cts +1 -1
  62. package/dist/gemini.d.ts +1 -1
  63. package/dist/guardrails.cjs +2 -0
  64. package/dist/guardrails.cjs.map +1 -0
  65. package/dist/guardrails.d.cts +618 -0
  66. package/dist/guardrails.d.ts +618 -0
  67. package/dist/guardrails.js +2 -0
  68. package/dist/guardrails.js.map +1 -0
  69. package/dist/health-monitor-C6xoXrQz.d.cts +55 -0
  70. package/dist/health-monitor-qL9RNMH3.d.ts +55 -0
  71. package/dist/index.cjs +21 -99
  72. package/dist/index.cjs.map +1 -1
  73. package/dist/index.d.cts +1197 -4735
  74. package/dist/index.d.ts +1197 -4735
  75. package/dist/index.js +21 -99
  76. package/dist/index.js.map +1 -1
  77. package/dist/mcp.cjs +2 -0
  78. package/dist/mcp.cjs.map +1 -0
  79. package/dist/mcp.d.cts +450 -0
  80. package/dist/mcp.d.ts +450 -0
  81. package/dist/mcp.js +2 -0
  82. package/dist/mcp.js.map +1 -0
  83. package/dist/multi-agent-orchestrator-QWWQKKGX.js +2 -0
  84. package/dist/{multi-agent-orchestrator-4PXNYRHB.js.map → multi-agent-orchestrator-QWWQKKGX.js.map} +1 -1
  85. package/dist/multi-agent-orchestrator-Y5U4JCFO.cjs +2 -0
  86. package/dist/{multi-agent-orchestrator-KFGTEGE5.cjs.map → multi-agent-orchestrator-Y5U4JCFO.cjs.map} +1 -1
  87. package/dist/multi-agent.cjs +2 -0
  88. package/dist/multi-agent.cjs.map +1 -0
  89. package/dist/multi-agent.d.cts +1429 -0
  90. package/dist/multi-agent.d.ts +1429 -0
  91. package/dist/multi-agent.js +2 -0
  92. package/dist/multi-agent.js.map +1 -0
  93. package/dist/ollama.d.cts +1 -1
  94. package/dist/ollama.d.ts +1 -1
  95. package/dist/openai.d.cts +2 -2
  96. package/dist/openai.d.ts +2 -2
  97. package/dist/{orchestrator-types-CTfIKk0W.d.ts → orchestrator-types-DGBhL6mc.d.ts} +5 -138
  98. package/dist/{orchestrator-types-Bh8r3_Sq.d.cts → orchestrator-types-DeIMRLR7.d.cts} +5 -138
  99. package/dist/predicate.cjs +2 -0
  100. package/dist/predicate.cjs.map +1 -0
  101. package/dist/predicate.d.cts +371 -0
  102. package/dist/predicate.d.ts +371 -0
  103. package/dist/predicate.js +2 -0
  104. package/dist/predicate.js.map +1 -0
  105. package/dist/{semantic-cache-nBpQqILc.d.cts → semantic-cache-DM7ev7NQ.d.cts} +1 -1
  106. package/dist/{semantic-cache-nBpQqILc.d.ts → semantic-cache-DM7ev7NQ.d.ts} +1 -1
  107. package/dist/testing.cjs +1 -1
  108. package/dist/testing.cjs.map +1 -1
  109. package/dist/testing.d.cts +4 -2
  110. package/dist/testing.d.ts +4 -2
  111. package/dist/testing.js +1 -1
  112. package/dist/testing.js.map +1 -1
  113. package/dist/{types-CRmwFnVk.d.cts → types-DJ09LjZX.d.cts} +1 -1
  114. package/dist/{types-CRmwFnVk.d.ts → types-DJ09LjZX.d.ts} +1 -1
  115. package/package.json +32 -2
  116. package/dist/chunk-Q3PQLWBR.js +0 -16
  117. package/dist/chunk-RW4R3O5P.js +0 -72
  118. package/dist/chunk-RW4R3O5P.js.map +0 -1
  119. package/dist/chunk-X3VQ5F7D.cjs +0 -72
  120. package/dist/chunk-X3VQ5F7D.cjs.map +0 -1
  121. package/dist/multi-agent-orchestrator-4PXNYRHB.js +0 -2
  122. package/dist/multi-agent-orchestrator-KFGTEGE5.cjs +0 -2
@@ -0,0 +1,354 @@
1
+ import { D as DebugTimeline } from './debug-timeline-DpnRMnLU.cjs';
2
+ export { a as DebugTimelineListener, b as DebugTimelineOptions, c as createDebugTimeline, d as createDebugTimelinePlugin } from './debug-timeline-DpnRMnLU.cjs';
3
+ import { A as AgentHealthMetrics, H as HealthMonitor } from './health-monitor-C6xoXrQz.cjs';
4
+ export { a as HealthCircuitState, c as createHealthMonitor } from './health-monitor-C6xoXrQz.cjs';
5
+ import { l as DebugEvent, b8 as BreakpointState } from './types-DJ09LjZX.cjs';
6
+ import '@directive-run/core';
7
+
8
+ /**
9
+ * DevTools Server — WebSocket-based bridge between orchestrators and DevTools UI.
10
+ *
11
+ * Streams debug timeline events, health metrics, breakpoint state, and system
12
+ * snapshots in real-time to connected DevTools clients. Accepts commands from
13
+ * clients to resume/cancel breakpoints and request snapshots.
14
+ *
15
+ * Transport-agnostic: works with any WebSocket implementation (ws, Bun, Deno)
16
+ * via the {@link DevToolsTransport} interface.
17
+ *
18
+ * @module
19
+ */
20
+
21
+ /** A connected DevTools client */
22
+ interface DevToolsClient {
23
+ /** Send a JSON-serializable message to this client */
24
+ send(data: string): void;
25
+ /** Close the connection */
26
+ close(): void;
27
+ }
28
+ /**
29
+ * Transport layer for the DevTools server.
30
+ *
31
+ * Implement this interface to bridge any WebSocket library (ws, Bun.serve, Deno.serve).
32
+ *
33
+ * @example Node.js with `ws`:
34
+ * ```typescript
35
+ * import { WebSocketServer } from "ws";
36
+ *
37
+ * function createWsTransport(port: number): DevToolsTransport {
38
+ * const wss = new WebSocketServer({ port });
39
+ * let onConnect: ((client: DevToolsClient) => void) | null = null;
40
+ *
41
+ * wss.on("connection", (ws) => {
42
+ * const client: DevToolsClient = {
43
+ * send: (data) => { if (ws.readyState === ws.OPEN) ws.send(data); },
44
+ * close: () => ws.close(),
45
+ * };
46
+ * ws.on("message", (raw) => {
47
+ * if (client._onMessage) client._onMessage(raw.toString());
48
+ * });
49
+ * ws.on("close", () => {
50
+ * if (client._onClose) client._onClose();
51
+ * });
52
+ * onConnect?.(client);
53
+ * });
54
+ *
55
+ * return {
56
+ * onConnection(handler) { onConnect = handler; },
57
+ * close() { wss.close(); },
58
+ * };
59
+ * }
60
+ * ```
61
+ */
62
+ interface DevToolsTransport {
63
+ /** Register a handler for new client connections */
64
+ onConnection(handler: (client: DevToolsClient, onMessage: (handler: (data: string) => void) => void, onClose: (handler: () => void) => void) => void): void;
65
+ /** Shut down the transport */
66
+ close(): void;
67
+ }
68
+ /** Messages sent FROM the server TO clients */
69
+ type DevToolsServerMessage = {
70
+ type: "welcome";
71
+ version: number;
72
+ sessionId: string;
73
+ timestamp: number;
74
+ } | {
75
+ type: "event";
76
+ event: DebugEvent;
77
+ } | {
78
+ type: "event_batch";
79
+ events: DebugEvent[];
80
+ } | {
81
+ type: "snapshot";
82
+ data: DevToolsSnapshot;
83
+ } | {
84
+ type: "health";
85
+ metrics: Record<string, AgentHealthMetrics>;
86
+ } | {
87
+ type: "breakpoints";
88
+ state: BreakpointState;
89
+ } | {
90
+ type: "pong";
91
+ timestamp: number;
92
+ } | {
93
+ type: "scratchpad_state";
94
+ data: Record<string, unknown>;
95
+ } | {
96
+ type: "scratchpad_update";
97
+ key: string;
98
+ value: unknown;
99
+ } | {
100
+ type: "derived_state";
101
+ data: Record<string, unknown>;
102
+ } | {
103
+ type: "derived_update";
104
+ id: string;
105
+ value: unknown;
106
+ } | {
107
+ type: "fork_complete";
108
+ eventId: number;
109
+ newEventCount: number;
110
+ } | {
111
+ type: "token_stream";
112
+ agentId: string;
113
+ tokens: string;
114
+ tokenCount: number;
115
+ } | {
116
+ type: "stream_done";
117
+ agentId: string;
118
+ totalTokens: number;
119
+ } | {
120
+ type: "error";
121
+ code: string;
122
+ message: string;
123
+ };
124
+ /** Messages sent FROM clients TO the server */
125
+ type DevToolsClientMessage = {
126
+ type: "authenticate";
127
+ token: string;
128
+ } | {
129
+ type: "request_snapshot";
130
+ } | {
131
+ type: "request_health";
132
+ } | {
133
+ type: "request_events";
134
+ since?: number;
135
+ } | {
136
+ type: "request_breakpoints";
137
+ } | {
138
+ type: "resume_breakpoint";
139
+ breakpointId: string;
140
+ modifications?: {
141
+ input?: string;
142
+ skip?: boolean;
143
+ };
144
+ } | {
145
+ type: "cancel_breakpoint";
146
+ breakpointId: string;
147
+ reason?: string;
148
+ } | {
149
+ type: "export_session";
150
+ } | {
151
+ type: "import_session";
152
+ data: string;
153
+ } | {
154
+ type: "request_scratchpad";
155
+ } | {
156
+ type: "request_derived";
157
+ } | {
158
+ type: "fork_from_snapshot";
159
+ eventId: number;
160
+ } | {
161
+ type: "ping";
162
+ };
163
+ /** System snapshot sent to clients on demand */
164
+ interface DevToolsSnapshot {
165
+ timestamp: number;
166
+ agents: Record<string, {
167
+ status: string;
168
+ lastInput?: string;
169
+ lastOutput?: unknown;
170
+ totalTokens: number;
171
+ runCount: number;
172
+ }>;
173
+ coordinator?: {
174
+ globalTokens: number;
175
+ status: string;
176
+ };
177
+ derived?: Record<string, unknown>;
178
+ eventCount: number;
179
+ }
180
+ /** Configuration for the DevTools server */
181
+ interface DevToolsServerConfig {
182
+ /** Transport to use for WebSocket connections */
183
+ transport: DevToolsTransport;
184
+ /** Debug timeline to subscribe to */
185
+ timeline: DebugTimeline;
186
+ /** Health monitor for metrics (optional) */
187
+ healthMonitor?: HealthMonitor | null;
188
+ /** Callback to get current agent states for snapshots */
189
+ getSnapshot?: () => DevToolsSnapshot;
190
+ /** Callback to get current breakpoint state */
191
+ getBreakpointState?: () => BreakpointState;
192
+ /** Callback to resume a breakpoint */
193
+ onResumeBreakpoint?: (id: string, modifications?: {
194
+ input?: string;
195
+ skip?: boolean;
196
+ }) => void;
197
+ /** Callback to cancel a breakpoint */
198
+ onCancelBreakpoint?: (id: string, reason?: string) => void;
199
+ /** Callback to get current scratchpad state */
200
+ getScratchpadState?: () => Record<string, unknown>;
201
+ /** Callback to get current derived state */
202
+ getDerivedState?: () => Record<string, unknown>;
203
+ /** Callback to fork from a snapshot event */
204
+ onForkFromSnapshot?: (eventId: number) => {
205
+ newEventCount: number;
206
+ };
207
+ /** Maximum events to batch before flushing. Default: 1 (no batching) */
208
+ batchSize?: number;
209
+ /** Flush interval for batched events (ms). Default: 50 */
210
+ batchIntervalMs?: number;
211
+ /** Health metrics push interval (ms). 0 = no auto-push. Default: 0 */
212
+ healthPushIntervalMs?: number;
213
+ /** Maximum connected clients. Default: 50 */
214
+ maxClients?: number;
215
+ /** Token authentication callback. When set, new connections must send an `authenticate` message before receiving data. */
216
+ authenticate?: (token: string) => boolean | Promise<boolean>;
217
+ }
218
+ /** DevTools server instance */
219
+ interface DevToolsServer {
220
+ /** Number of connected clients */
221
+ readonly clientCount: number;
222
+ /** Broadcast a message to all connected clients */
223
+ broadcast(message: DevToolsServerMessage): void;
224
+ /** Push current health metrics to all clients */
225
+ pushHealth(): void;
226
+ /** Push current breakpoint state to all clients */
227
+ pushBreakpoints(): void;
228
+ /** Push a scratchpad key update to all clients */
229
+ pushScratchpadUpdate(key: string, value: unknown): void;
230
+ /** Push a derived value update to all clients */
231
+ pushDerivedUpdate(id: string, value: unknown): void;
232
+ /** Push streaming tokens to all clients */
233
+ pushTokenStream(agentId: string, tokens: string, tokenCount: number): void;
234
+ /** Signal stream completion to all clients */
235
+ pushStreamDone(agentId: string, totalTokens: number): void;
236
+ /** Shut down the server and disconnect all clients */
237
+ close(): void;
238
+ }
239
+ /**
240
+ * Create a DevTools server that bridges orchestrator state to DevTools UI clients.
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * const server = createDevToolsServer({
245
+ * transport: createWsTransport(4040),
246
+ * timeline: orchestrator.timeline!,
247
+ * healthMonitor: orchestrator.healthMonitor,
248
+ * getSnapshot: () => buildSnapshot(orchestrator),
249
+ * getBreakpointState: () => orchestrator.getBreakpointState(),
250
+ * onResumeBreakpoint: (id, mods) => orchestrator.resumeBreakpoint(id, mods),
251
+ * onCancelBreakpoint: (id, reason) => orchestrator.cancelBreakpoint(id, reason),
252
+ * });
253
+ * ```
254
+ */
255
+ declare function createDevToolsServer(config: DevToolsServerConfig): DevToolsServer;
256
+ /** Options for connecting DevTools to an orchestrator */
257
+ interface ConnectDevToolsOptions {
258
+ /** Port for the WebSocket server. Default: 4040 */
259
+ port?: number;
260
+ /** Host to bind to. Default: "localhost" */
261
+ host?: string;
262
+ /** Health metrics push interval (ms). Default: 5000 */
263
+ healthPushIntervalMs?: number;
264
+ /** Event batching size. Default: 1 (no batching) */
265
+ batchSize?: number;
266
+ /** Token authentication callback. When set, clients must authenticate before receiving data. */
267
+ authenticate?: (token: string) => boolean | Promise<boolean>;
268
+ }
269
+ /** Minimal orchestrator interface for DevTools connection */
270
+ interface DevToolsCompatibleOrchestrator {
271
+ timeline: {
272
+ subscribe: (listener: (event: DebugEvent) => void) => () => void;
273
+ getEvents: () => DebugEvent[];
274
+ import: (json: string) => void;
275
+ export: () => string;
276
+ forkFrom?: (eventId: number) => void;
277
+ } | null;
278
+ healthMonitor?: {
279
+ getAllMetrics: () => Record<string, AgentHealthMetrics>;
280
+ } | null;
281
+ getPendingBreakpoints?: () => Array<{
282
+ id: string;
283
+ type: string;
284
+ agentId: string;
285
+ input: string;
286
+ label?: string;
287
+ requestedAt: number;
288
+ }>;
289
+ resumeBreakpoint?: (id: string, modifications?: {
290
+ input?: string;
291
+ skip?: boolean;
292
+ }) => void;
293
+ cancelBreakpoint?: (id: string, reason?: string) => void;
294
+ getAllAgentStates?: () => Record<string, {
295
+ status: string;
296
+ lastInput?: string;
297
+ lastOutput?: unknown;
298
+ totalTokens: number;
299
+ runCount: number;
300
+ }>;
301
+ /** Get current scratchpad state (multi-agent only) */
302
+ getScratchpadState?: () => Record<string, unknown>;
303
+ /** Get current derived values (multi-agent only) */
304
+ getDerivedState?: () => Record<string, unknown>;
305
+ }
306
+ /**
307
+ * Connect DevTools to an orchestrator instance.
308
+ *
309
+ * Convenience function that creates a WebSocket transport and DevTools server,
310
+ * automatically wiring up the orchestrator's timeline, health monitor, and breakpoint system.
311
+ *
312
+ * Requires the `ws` package: `npm install ws`
313
+ *
314
+ * **Security:** Binding to `0.0.0.0` exposes the server to all network interfaces.
315
+ * Only do this behind a firewall or with proper authentication.
316
+ *
317
+ * @example
318
+ * ```typescript
319
+ * const orchestrator = createMultiAgentOrchestrator({ debug: true, ... });
320
+ * const devtools = await connectDevTools(orchestrator, { port: 4040 });
321
+ *
322
+ * // Later, clean up:
323
+ * devtools.close();
324
+ * ```
325
+ */
326
+ declare function connectDevTools(orchestrator: DevToolsCompatibleOrchestrator, options?: ConnectDevToolsOptions): Promise<DevToolsServer>;
327
+ /**
328
+ * Configuration for the built-in Node.js `ws` transport.
329
+ *
330
+ * Requires the `ws` package to be installed: `npm install ws`
331
+ */
332
+ interface WsTransportConfig {
333
+ /** Port to listen on. Default: 4040 */
334
+ port?: number;
335
+ /** Host to bind to. Default: "localhost" */
336
+ host?: string;
337
+ /** Maximum incoming message size in bytes. Default: 1048576 (1MB) */
338
+ maxPayloadBytes?: number;
339
+ }
340
+ /**
341
+ * Create a DevTools transport using the Node.js `ws` WebSocket library.
342
+ *
343
+ * This is a convenience helper — you can implement {@link DevToolsTransport}
344
+ * with any WebSocket library.
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * const transport = await createWsTransport({ port: 4040 });
349
+ * const server = createDevToolsServer({ transport, timeline });
350
+ * ```
351
+ */
352
+ declare function createWsTransport(config?: WsTransportConfig): Promise<DevToolsTransport>;
353
+
354
+ export { AgentHealthMetrics, type ConnectDevToolsOptions, DebugTimeline, type DevToolsClient, type DevToolsClientMessage, type DevToolsCompatibleOrchestrator, type DevToolsServer, type DevToolsServerConfig, type DevToolsServerMessage, type DevToolsSnapshot, type DevToolsTransport, HealthMonitor, type WsTransportConfig, connectDevTools, createDevToolsServer, createWsTransport };
@@ -0,0 +1,354 @@
1
+ import { D as DebugTimeline } from './debug-timeline-L13P-U2I.js';
2
+ export { a as DebugTimelineListener, b as DebugTimelineOptions, c as createDebugTimeline, d as createDebugTimelinePlugin } from './debug-timeline-L13P-U2I.js';
3
+ import { A as AgentHealthMetrics, H as HealthMonitor } from './health-monitor-qL9RNMH3.js';
4
+ export { a as HealthCircuitState, c as createHealthMonitor } from './health-monitor-qL9RNMH3.js';
5
+ import { l as DebugEvent, b8 as BreakpointState } from './types-DJ09LjZX.js';
6
+ import '@directive-run/core';
7
+
8
+ /**
9
+ * DevTools Server — WebSocket-based bridge between orchestrators and DevTools UI.
10
+ *
11
+ * Streams debug timeline events, health metrics, breakpoint state, and system
12
+ * snapshots in real-time to connected DevTools clients. Accepts commands from
13
+ * clients to resume/cancel breakpoints and request snapshots.
14
+ *
15
+ * Transport-agnostic: works with any WebSocket implementation (ws, Bun, Deno)
16
+ * via the {@link DevToolsTransport} interface.
17
+ *
18
+ * @module
19
+ */
20
+
21
+ /** A connected DevTools client */
22
+ interface DevToolsClient {
23
+ /** Send a JSON-serializable message to this client */
24
+ send(data: string): void;
25
+ /** Close the connection */
26
+ close(): void;
27
+ }
28
+ /**
29
+ * Transport layer for the DevTools server.
30
+ *
31
+ * Implement this interface to bridge any WebSocket library (ws, Bun.serve, Deno.serve).
32
+ *
33
+ * @example Node.js with `ws`:
34
+ * ```typescript
35
+ * import { WebSocketServer } from "ws";
36
+ *
37
+ * function createWsTransport(port: number): DevToolsTransport {
38
+ * const wss = new WebSocketServer({ port });
39
+ * let onConnect: ((client: DevToolsClient) => void) | null = null;
40
+ *
41
+ * wss.on("connection", (ws) => {
42
+ * const client: DevToolsClient = {
43
+ * send: (data) => { if (ws.readyState === ws.OPEN) ws.send(data); },
44
+ * close: () => ws.close(),
45
+ * };
46
+ * ws.on("message", (raw) => {
47
+ * if (client._onMessage) client._onMessage(raw.toString());
48
+ * });
49
+ * ws.on("close", () => {
50
+ * if (client._onClose) client._onClose();
51
+ * });
52
+ * onConnect?.(client);
53
+ * });
54
+ *
55
+ * return {
56
+ * onConnection(handler) { onConnect = handler; },
57
+ * close() { wss.close(); },
58
+ * };
59
+ * }
60
+ * ```
61
+ */
62
+ interface DevToolsTransport {
63
+ /** Register a handler for new client connections */
64
+ onConnection(handler: (client: DevToolsClient, onMessage: (handler: (data: string) => void) => void, onClose: (handler: () => void) => void) => void): void;
65
+ /** Shut down the transport */
66
+ close(): void;
67
+ }
68
+ /** Messages sent FROM the server TO clients */
69
+ type DevToolsServerMessage = {
70
+ type: "welcome";
71
+ version: number;
72
+ sessionId: string;
73
+ timestamp: number;
74
+ } | {
75
+ type: "event";
76
+ event: DebugEvent;
77
+ } | {
78
+ type: "event_batch";
79
+ events: DebugEvent[];
80
+ } | {
81
+ type: "snapshot";
82
+ data: DevToolsSnapshot;
83
+ } | {
84
+ type: "health";
85
+ metrics: Record<string, AgentHealthMetrics>;
86
+ } | {
87
+ type: "breakpoints";
88
+ state: BreakpointState;
89
+ } | {
90
+ type: "pong";
91
+ timestamp: number;
92
+ } | {
93
+ type: "scratchpad_state";
94
+ data: Record<string, unknown>;
95
+ } | {
96
+ type: "scratchpad_update";
97
+ key: string;
98
+ value: unknown;
99
+ } | {
100
+ type: "derived_state";
101
+ data: Record<string, unknown>;
102
+ } | {
103
+ type: "derived_update";
104
+ id: string;
105
+ value: unknown;
106
+ } | {
107
+ type: "fork_complete";
108
+ eventId: number;
109
+ newEventCount: number;
110
+ } | {
111
+ type: "token_stream";
112
+ agentId: string;
113
+ tokens: string;
114
+ tokenCount: number;
115
+ } | {
116
+ type: "stream_done";
117
+ agentId: string;
118
+ totalTokens: number;
119
+ } | {
120
+ type: "error";
121
+ code: string;
122
+ message: string;
123
+ };
124
+ /** Messages sent FROM clients TO the server */
125
+ type DevToolsClientMessage = {
126
+ type: "authenticate";
127
+ token: string;
128
+ } | {
129
+ type: "request_snapshot";
130
+ } | {
131
+ type: "request_health";
132
+ } | {
133
+ type: "request_events";
134
+ since?: number;
135
+ } | {
136
+ type: "request_breakpoints";
137
+ } | {
138
+ type: "resume_breakpoint";
139
+ breakpointId: string;
140
+ modifications?: {
141
+ input?: string;
142
+ skip?: boolean;
143
+ };
144
+ } | {
145
+ type: "cancel_breakpoint";
146
+ breakpointId: string;
147
+ reason?: string;
148
+ } | {
149
+ type: "export_session";
150
+ } | {
151
+ type: "import_session";
152
+ data: string;
153
+ } | {
154
+ type: "request_scratchpad";
155
+ } | {
156
+ type: "request_derived";
157
+ } | {
158
+ type: "fork_from_snapshot";
159
+ eventId: number;
160
+ } | {
161
+ type: "ping";
162
+ };
163
+ /** System snapshot sent to clients on demand */
164
+ interface DevToolsSnapshot {
165
+ timestamp: number;
166
+ agents: Record<string, {
167
+ status: string;
168
+ lastInput?: string;
169
+ lastOutput?: unknown;
170
+ totalTokens: number;
171
+ runCount: number;
172
+ }>;
173
+ coordinator?: {
174
+ globalTokens: number;
175
+ status: string;
176
+ };
177
+ derived?: Record<string, unknown>;
178
+ eventCount: number;
179
+ }
180
+ /** Configuration for the DevTools server */
181
+ interface DevToolsServerConfig {
182
+ /** Transport to use for WebSocket connections */
183
+ transport: DevToolsTransport;
184
+ /** Debug timeline to subscribe to */
185
+ timeline: DebugTimeline;
186
+ /** Health monitor for metrics (optional) */
187
+ healthMonitor?: HealthMonitor | null;
188
+ /** Callback to get current agent states for snapshots */
189
+ getSnapshot?: () => DevToolsSnapshot;
190
+ /** Callback to get current breakpoint state */
191
+ getBreakpointState?: () => BreakpointState;
192
+ /** Callback to resume a breakpoint */
193
+ onResumeBreakpoint?: (id: string, modifications?: {
194
+ input?: string;
195
+ skip?: boolean;
196
+ }) => void;
197
+ /** Callback to cancel a breakpoint */
198
+ onCancelBreakpoint?: (id: string, reason?: string) => void;
199
+ /** Callback to get current scratchpad state */
200
+ getScratchpadState?: () => Record<string, unknown>;
201
+ /** Callback to get current derived state */
202
+ getDerivedState?: () => Record<string, unknown>;
203
+ /** Callback to fork from a snapshot event */
204
+ onForkFromSnapshot?: (eventId: number) => {
205
+ newEventCount: number;
206
+ };
207
+ /** Maximum events to batch before flushing. Default: 1 (no batching) */
208
+ batchSize?: number;
209
+ /** Flush interval for batched events (ms). Default: 50 */
210
+ batchIntervalMs?: number;
211
+ /** Health metrics push interval (ms). 0 = no auto-push. Default: 0 */
212
+ healthPushIntervalMs?: number;
213
+ /** Maximum connected clients. Default: 50 */
214
+ maxClients?: number;
215
+ /** Token authentication callback. When set, new connections must send an `authenticate` message before receiving data. */
216
+ authenticate?: (token: string) => boolean | Promise<boolean>;
217
+ }
218
+ /** DevTools server instance */
219
+ interface DevToolsServer {
220
+ /** Number of connected clients */
221
+ readonly clientCount: number;
222
+ /** Broadcast a message to all connected clients */
223
+ broadcast(message: DevToolsServerMessage): void;
224
+ /** Push current health metrics to all clients */
225
+ pushHealth(): void;
226
+ /** Push current breakpoint state to all clients */
227
+ pushBreakpoints(): void;
228
+ /** Push a scratchpad key update to all clients */
229
+ pushScratchpadUpdate(key: string, value: unknown): void;
230
+ /** Push a derived value update to all clients */
231
+ pushDerivedUpdate(id: string, value: unknown): void;
232
+ /** Push streaming tokens to all clients */
233
+ pushTokenStream(agentId: string, tokens: string, tokenCount: number): void;
234
+ /** Signal stream completion to all clients */
235
+ pushStreamDone(agentId: string, totalTokens: number): void;
236
+ /** Shut down the server and disconnect all clients */
237
+ close(): void;
238
+ }
239
+ /**
240
+ * Create a DevTools server that bridges orchestrator state to DevTools UI clients.
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * const server = createDevToolsServer({
245
+ * transport: createWsTransport(4040),
246
+ * timeline: orchestrator.timeline!,
247
+ * healthMonitor: orchestrator.healthMonitor,
248
+ * getSnapshot: () => buildSnapshot(orchestrator),
249
+ * getBreakpointState: () => orchestrator.getBreakpointState(),
250
+ * onResumeBreakpoint: (id, mods) => orchestrator.resumeBreakpoint(id, mods),
251
+ * onCancelBreakpoint: (id, reason) => orchestrator.cancelBreakpoint(id, reason),
252
+ * });
253
+ * ```
254
+ */
255
+ declare function createDevToolsServer(config: DevToolsServerConfig): DevToolsServer;
256
+ /** Options for connecting DevTools to an orchestrator */
257
+ interface ConnectDevToolsOptions {
258
+ /** Port for the WebSocket server. Default: 4040 */
259
+ port?: number;
260
+ /** Host to bind to. Default: "localhost" */
261
+ host?: string;
262
+ /** Health metrics push interval (ms). Default: 5000 */
263
+ healthPushIntervalMs?: number;
264
+ /** Event batching size. Default: 1 (no batching) */
265
+ batchSize?: number;
266
+ /** Token authentication callback. When set, clients must authenticate before receiving data. */
267
+ authenticate?: (token: string) => boolean | Promise<boolean>;
268
+ }
269
+ /** Minimal orchestrator interface for DevTools connection */
270
+ interface DevToolsCompatibleOrchestrator {
271
+ timeline: {
272
+ subscribe: (listener: (event: DebugEvent) => void) => () => void;
273
+ getEvents: () => DebugEvent[];
274
+ import: (json: string) => void;
275
+ export: () => string;
276
+ forkFrom?: (eventId: number) => void;
277
+ } | null;
278
+ healthMonitor?: {
279
+ getAllMetrics: () => Record<string, AgentHealthMetrics>;
280
+ } | null;
281
+ getPendingBreakpoints?: () => Array<{
282
+ id: string;
283
+ type: string;
284
+ agentId: string;
285
+ input: string;
286
+ label?: string;
287
+ requestedAt: number;
288
+ }>;
289
+ resumeBreakpoint?: (id: string, modifications?: {
290
+ input?: string;
291
+ skip?: boolean;
292
+ }) => void;
293
+ cancelBreakpoint?: (id: string, reason?: string) => void;
294
+ getAllAgentStates?: () => Record<string, {
295
+ status: string;
296
+ lastInput?: string;
297
+ lastOutput?: unknown;
298
+ totalTokens: number;
299
+ runCount: number;
300
+ }>;
301
+ /** Get current scratchpad state (multi-agent only) */
302
+ getScratchpadState?: () => Record<string, unknown>;
303
+ /** Get current derived values (multi-agent only) */
304
+ getDerivedState?: () => Record<string, unknown>;
305
+ }
306
+ /**
307
+ * Connect DevTools to an orchestrator instance.
308
+ *
309
+ * Convenience function that creates a WebSocket transport and DevTools server,
310
+ * automatically wiring up the orchestrator's timeline, health monitor, and breakpoint system.
311
+ *
312
+ * Requires the `ws` package: `npm install ws`
313
+ *
314
+ * **Security:** Binding to `0.0.0.0` exposes the server to all network interfaces.
315
+ * Only do this behind a firewall or with proper authentication.
316
+ *
317
+ * @example
318
+ * ```typescript
319
+ * const orchestrator = createMultiAgentOrchestrator({ debug: true, ... });
320
+ * const devtools = await connectDevTools(orchestrator, { port: 4040 });
321
+ *
322
+ * // Later, clean up:
323
+ * devtools.close();
324
+ * ```
325
+ */
326
+ declare function connectDevTools(orchestrator: DevToolsCompatibleOrchestrator, options?: ConnectDevToolsOptions): Promise<DevToolsServer>;
327
+ /**
328
+ * Configuration for the built-in Node.js `ws` transport.
329
+ *
330
+ * Requires the `ws` package to be installed: `npm install ws`
331
+ */
332
+ interface WsTransportConfig {
333
+ /** Port to listen on. Default: 4040 */
334
+ port?: number;
335
+ /** Host to bind to. Default: "localhost" */
336
+ host?: string;
337
+ /** Maximum incoming message size in bytes. Default: 1048576 (1MB) */
338
+ maxPayloadBytes?: number;
339
+ }
340
+ /**
341
+ * Create a DevTools transport using the Node.js `ws` WebSocket library.
342
+ *
343
+ * This is a convenience helper — you can implement {@link DevToolsTransport}
344
+ * with any WebSocket library.
345
+ *
346
+ * @example
347
+ * ```typescript
348
+ * const transport = await createWsTransport({ port: 4040 });
349
+ * const server = createDevToolsServer({ transport, timeline });
350
+ * ```
351
+ */
352
+ declare function createWsTransport(config?: WsTransportConfig): Promise<DevToolsTransport>;
353
+
354
+ export { AgentHealthMetrics, type ConnectDevToolsOptions, DebugTimeline, type DevToolsClient, type DevToolsClientMessage, type DevToolsCompatibleOrchestrator, type DevToolsServer, type DevToolsServerConfig, type DevToolsServerMessage, type DevToolsSnapshot, type DevToolsTransport, HealthMonitor, type WsTransportConfig, connectDevTools, createDevToolsServer, createWsTransport };
@@ -0,0 +1,2 @@
1
+ export{b as connectDevTools,a as createDevToolsServer,c as createWsTransport}from'./chunk-5JQ2A3JK.js';export{a as createDebugTimeline,b as createDebugTimelinePlugin,c as createHealthMonitor}from'./chunk-FBT73WFY.js';//# sourceMappingURL=devtools.js.map
2
+ //# sourceMappingURL=devtools.js.map