@agentxjs/core 1.9.5-dev → 1.9.7-dev
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/Processor-DT0N1qI6.d.ts +64 -0
- package/dist/agent/engine/internal/index.d.ts +223 -0
- package/dist/agent/engine/internal/index.js +24 -0
- package/dist/agent/engine/internal/index.js.map +1 -0
- package/dist/agent/engine/mealy/index.d.ts +157 -0
- package/dist/agent/engine/mealy/index.js +26 -0
- package/dist/agent/engine/mealy/index.js.map +1 -0
- package/dist/agent/index.d.ts +244 -0
- package/dist/agent/index.js +66 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/types/index.d.ts +322 -0
- package/dist/agent/types/index.js +12 -0
- package/dist/agent/types/index.js.map +1 -0
- package/dist/base-m40r3Qgu.d.ts +157 -0
- package/dist/bus-uF1DM2ox.d.ts +906 -0
- package/dist/chunk-7D4SUZUM.js +38 -0
- package/dist/chunk-7D4SUZUM.js.map +1 -0
- package/dist/chunk-7ZDX3O6I.js +173 -0
- package/dist/chunk-7ZDX3O6I.js.map +1 -0
- package/dist/chunk-E5FPOAPO.js +123 -0
- package/dist/chunk-E5FPOAPO.js.map +1 -0
- package/dist/chunk-EKHT54KN.js +272 -0
- package/dist/chunk-EKHT54KN.js.map +1 -0
- package/dist/chunk-I7GYR3MN.js +502 -0
- package/dist/chunk-I7GYR3MN.js.map +1 -0
- package/dist/chunk-K6WXQ2RW.js +38 -0
- package/dist/chunk-K6WXQ2RW.js.map +1 -0
- package/dist/chunk-RL3JRNXM.js +3 -0
- package/dist/chunk-RL3JRNXM.js.map +1 -0
- package/dist/chunk-TBU7FFZT.js +543 -0
- package/dist/chunk-TBU7FFZT.js.map +1 -0
- package/dist/combinators-nEa5dD0T.d.ts +271 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +2 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/logger/index.d.ts +163 -0
- package/dist/common/logger/index.js +184 -0
- package/dist/common/logger/index.js.map +1 -0
- package/dist/container/index.d.ts +110 -0
- package/dist/container/index.js +127 -0
- package/dist/container/index.js.map +1 -0
- package/dist/driver/index.d.ts +266 -0
- package/dist/driver/index.js +1 -0
- package/dist/driver/index.js.map +1 -0
- package/dist/event/index.d.ts +55 -0
- package/dist/event/index.js +60 -0
- package/dist/event/index.js.map +1 -0
- package/dist/event/types/index.d.ts +1149 -0
- package/dist/event/types/index.js +56 -0
- package/dist/event/types/index.js.map +1 -0
- package/dist/event-CDuTzs__.d.ts +296 -0
- package/dist/image/index.d.ts +112 -0
- package/dist/image/index.js +151 -0
- package/dist/image/index.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/message-BMrMm1pq.d.ts +305 -0
- package/dist/mq/index.d.ts +165 -0
- package/dist/mq/index.js +37 -0
- package/dist/mq/index.js.map +1 -0
- package/dist/network/index.d.ts +567 -0
- package/dist/network/index.js +435 -0
- package/dist/network/index.js.map +1 -0
- package/dist/persistence/index.d.ts +155 -0
- package/dist/persistence/index.js +1 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/runtime/index.d.ts +240 -0
- package/dist/runtime/index.js +347 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/session/index.d.ts +92 -0
- package/dist/session/index.js +56 -0
- package/dist/session/index.js.map +1 -0
- package/dist/workspace/index.d.ts +111 -0
- package/dist/workspace/index.js +1 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/wrapper-Y3UTVU2E.js +3635 -0
- package/dist/wrapper-Y3UTVU2E.js.map +1 -0
- package/package.json +73 -14
- package/tsconfig.json +0 -10
|
@@ -0,0 +1,1149 @@
|
|
|
1
|
+
import { S as SystemEvent, c as EventContext } from '../../base-m40r3Qgu.js';
|
|
2
|
+
export { B as BusEvent, b as EventCategory, a as EventIntent, E as EventSource, h as hasIntent, i as isFromSource, f as isNotification, d as isRequest, e as isResult } from '../../base-m40r3Qgu.js';
|
|
3
|
+
export { u as AgentDestroyAllRequest, v as AgentDestroyAllResponse, s as AgentDestroyRequest, t as AgentDestroyResponse, o as AgentGetRequest, p as AgentGetResponse, y as AgentInterruptRequest, z as AgentInterruptResponse, q as AgentListRequest, r as AgentListResponse, A as AgentXResponse, B as BusEventHandler, a1 as CommandEvent, C as CommandEventMap, a2 as CommandEventType, $ as CommandRequest, a6 as CommandRequestResponseMap, a as CommandRequestType, a0 as CommandResponse, i as ContainerCreateRequest, j as ContainerCreateResponse, k as ContainerGetRequest, l as ContainerGetResponse, m as ContainerListRequest, n as ContainerListResponse, E as EventBus, c as EventConsumer, d as EventProducer, F as FilePart, D as ImageCreateRequest, G as ImageCreateResponse, X as ImageDeleteRequest, Y as ImageDeleteResponse, V as ImageGetRequest, W as ImageGetResponse, h as ImageListItem, P as ImageListRequest, Q as ImageListResponse, Z as ImageMessagesRequest, _ as ImageMessagesResponse, f as ImageMetadata, I as ImagePart, g as ImageRecord, H as ImageRunRequest, J as ImageRunResponse, K as ImageStopRequest, L as ImageStopResponse, N as ImageUpdateRequest, O as ImageUpdateResponse, M as McpServerConfig, w as MessageSendRequest, x as MessageSendResponse, R as RequestDataFor, b as ResponseEventFor, a7 as ResponseTypeFor, S as SubscribeOptions, T as TextPart, U as Unsubscribe, e as UserContentPart, a3 as isCommandEvent, a4 as isCommandRequest, a5 as isCommandResponse } from '../../bus-uF1DM2ox.js';
|
|
4
|
+
import { U as UserMessage, A as AssistantMessage, T as ToolCallMessage, a as ToolResultMessage, E as ErrorMessage } from '../../message-BMrMm1pq.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Environment Events - External world events (LLM API, Network)
|
|
8
|
+
*
|
|
9
|
+
* DriveableEvent, ConnectionEvent, StopReason, ErrorEvent
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Reason why the LLM stopped generating
|
|
14
|
+
*
|
|
15
|
+
* Based on common stop reasons across multiple LLM providers:
|
|
16
|
+
* - Anthropic Claude: end_turn, max_tokens, tool_use, stop_sequence
|
|
17
|
+
* - OpenAI: stop, length, tool_calls, content_filter
|
|
18
|
+
* - Vercel AI SDK: stop, length, tool-calls, content-filter, error, other
|
|
19
|
+
*/
|
|
20
|
+
type StopReason =
|
|
21
|
+
/**
|
|
22
|
+
* Natural completion - model decided to stop
|
|
23
|
+
*/
|
|
24
|
+
"end_turn"
|
|
25
|
+
/**
|
|
26
|
+
* Reached maximum token limit
|
|
27
|
+
*/
|
|
28
|
+
| "max_tokens"
|
|
29
|
+
/**
|
|
30
|
+
* Model requested tool usage
|
|
31
|
+
*/
|
|
32
|
+
| "tool_use"
|
|
33
|
+
/**
|
|
34
|
+
* Encountered a custom stop sequence
|
|
35
|
+
*/
|
|
36
|
+
| "stop_sequence"
|
|
37
|
+
/**
|
|
38
|
+
* Content filter triggered
|
|
39
|
+
*/
|
|
40
|
+
| "content_filter"
|
|
41
|
+
/**
|
|
42
|
+
* Error occurred during generation
|
|
43
|
+
*/
|
|
44
|
+
| "error"
|
|
45
|
+
/**
|
|
46
|
+
* Other/unknown reason
|
|
47
|
+
*/
|
|
48
|
+
| "other";
|
|
49
|
+
/**
|
|
50
|
+
* Type guard to check if a string is a valid StopReason
|
|
51
|
+
*/
|
|
52
|
+
declare function isStopReason(value: string): value is StopReason;
|
|
53
|
+
/**
|
|
54
|
+
* Base interface for all LLM stream events (DriveableEvent)
|
|
55
|
+
*
|
|
56
|
+
* All DriveableEvents have:
|
|
57
|
+
* - source: "driver" (from LLM Driver)
|
|
58
|
+
* - category: "stream" (streaming output)
|
|
59
|
+
* - intent: "notification" (informational, no action needed)
|
|
60
|
+
* - requestId: correlation with the original request
|
|
61
|
+
* - context: agent/image/session scope (inherited from SystemEvent)
|
|
62
|
+
*/
|
|
63
|
+
interface BaseStreamEvent<T extends string, D = unknown> extends SystemEvent<T, D, "driver", "stream", "notification"> {
|
|
64
|
+
/**
|
|
65
|
+
* Content block index (for multi-block responses)
|
|
66
|
+
*/
|
|
67
|
+
index?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Request ID for correlating events with the original message_send_request
|
|
70
|
+
*/
|
|
71
|
+
requestId?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* MessageStartEvent - Emitted when streaming message begins
|
|
75
|
+
*/
|
|
76
|
+
interface MessageStartEvent extends BaseStreamEvent<"message_start", {
|
|
77
|
+
message: {
|
|
78
|
+
id: string;
|
|
79
|
+
model: string;
|
|
80
|
+
};
|
|
81
|
+
}> {
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* MessageDeltaEvent - Emitted with message-level updates
|
|
85
|
+
*/
|
|
86
|
+
interface MessageDeltaEvent extends BaseStreamEvent<"message_delta", {
|
|
87
|
+
usage?: {
|
|
88
|
+
inputTokens: number;
|
|
89
|
+
outputTokens: number;
|
|
90
|
+
};
|
|
91
|
+
}> {
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* MessageStopEvent - Emitted when streaming message completes
|
|
95
|
+
*/
|
|
96
|
+
interface MessageStopEvent extends BaseStreamEvent<"message_stop", {
|
|
97
|
+
stopReason?: StopReason;
|
|
98
|
+
stopSequence?: string;
|
|
99
|
+
}> {
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* TextContentBlockStartEvent - Text block started
|
|
103
|
+
*/
|
|
104
|
+
interface TextContentBlockStartEvent extends BaseStreamEvent<"text_content_block_start", Record<string, never>> {
|
|
105
|
+
index: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* TextDeltaEvent - Incremental text output
|
|
109
|
+
*/
|
|
110
|
+
interface TextDeltaEvent extends BaseStreamEvent<"text_delta", {
|
|
111
|
+
text: string;
|
|
112
|
+
}> {
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* TextContentBlockStopEvent - Text block completed
|
|
116
|
+
*/
|
|
117
|
+
interface TextContentBlockStopEvent extends BaseStreamEvent<"text_content_block_stop", Record<string, never>> {
|
|
118
|
+
index: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* ToolUseContentBlockStartEvent - Tool use block started
|
|
122
|
+
*/
|
|
123
|
+
interface ToolUseContentBlockStartEvent extends BaseStreamEvent<"tool_use_content_block_start", {
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
}> {
|
|
127
|
+
index: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* InputJsonDeltaEvent - Incremental tool input JSON
|
|
131
|
+
*/
|
|
132
|
+
interface InputJsonDeltaEvent extends BaseStreamEvent<"input_json_delta", {
|
|
133
|
+
partialJson: string;
|
|
134
|
+
}> {
|
|
135
|
+
index: number;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* ToolUseContentBlockStopEvent - Tool use block completed
|
|
139
|
+
*/
|
|
140
|
+
interface ToolUseContentBlockStopEvent extends BaseStreamEvent<"tool_use_content_block_stop", Record<string, never>> {
|
|
141
|
+
index: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* ToolCallEvent - Tool call ready for execution
|
|
145
|
+
*/
|
|
146
|
+
interface ToolCallEvent extends BaseStreamEvent<"tool_call", {
|
|
147
|
+
id: string;
|
|
148
|
+
name: string;
|
|
149
|
+
input: Record<string, unknown>;
|
|
150
|
+
}> {
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* ToolResultEvent - Tool execution result
|
|
154
|
+
*/
|
|
155
|
+
interface ToolResultEvent extends BaseStreamEvent<"tool_result", {
|
|
156
|
+
toolUseId: string;
|
|
157
|
+
result: unknown;
|
|
158
|
+
isError?: boolean;
|
|
159
|
+
}> {
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* InterruptedEvent - Stream interrupted
|
|
163
|
+
*/
|
|
164
|
+
interface InterruptedEvent extends BaseStreamEvent<"interrupted", {
|
|
165
|
+
reason: "user_interrupt" | "timeout" | "error" | "system";
|
|
166
|
+
}> {
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* ErrorReceivedEvent - Error received from environment (e.g., Claude API error)
|
|
170
|
+
*
|
|
171
|
+
* This event drives the MealyMachine to produce:
|
|
172
|
+
* - error_occurred (StateEvent) -> state transitions to "error"
|
|
173
|
+
* - error_message (MessageEvent) -> displayed in chat
|
|
174
|
+
*/
|
|
175
|
+
interface ErrorReceivedEvent extends BaseStreamEvent<"error_received", {
|
|
176
|
+
/** Error message (human-readable) */
|
|
177
|
+
message: string;
|
|
178
|
+
/** Error code (e.g., "rate_limit_error", "api_error", "overloaded_error") */
|
|
179
|
+
errorCode?: string;
|
|
180
|
+
}> {
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* DriveableEvent - All events that can drive Agent
|
|
184
|
+
*/
|
|
185
|
+
type DriveableEvent = MessageStartEvent | MessageDeltaEvent | MessageStopEvent | TextContentBlockStartEvent | TextDeltaEvent | TextContentBlockStopEvent | ToolUseContentBlockStartEvent | InputJsonDeltaEvent | ToolUseContentBlockStopEvent | ToolCallEvent | ToolResultEvent | InterruptedEvent | ErrorReceivedEvent;
|
|
186
|
+
/**
|
|
187
|
+
* DriveableEventType - String literal union of all driveable event types
|
|
188
|
+
*/
|
|
189
|
+
type DriveableEventType = DriveableEvent["type"];
|
|
190
|
+
/**
|
|
191
|
+
* Type guard: is this a DriveableEvent?
|
|
192
|
+
*/
|
|
193
|
+
declare function isDriveableEvent(event: {
|
|
194
|
+
source?: string;
|
|
195
|
+
category?: string;
|
|
196
|
+
}): event is DriveableEvent;
|
|
197
|
+
/**
|
|
198
|
+
* Base interface for all connection events
|
|
199
|
+
*/
|
|
200
|
+
interface BaseConnectionEvent<T extends string, D = unknown> extends SystemEvent<T, D, "driver", "connection", "notification"> {
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* ConnectedEvent - Connection established
|
|
204
|
+
*/
|
|
205
|
+
interface ConnectedEvent extends BaseConnectionEvent<"connected", {
|
|
206
|
+
url?: string;
|
|
207
|
+
reconnectAttempt?: number;
|
|
208
|
+
}> {
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* DisconnectedEvent - Connection lost
|
|
212
|
+
*/
|
|
213
|
+
interface DisconnectedEvent extends BaseConnectionEvent<"disconnected", {
|
|
214
|
+
reason?: string;
|
|
215
|
+
code?: number;
|
|
216
|
+
willReconnect?: boolean;
|
|
217
|
+
}> {
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* ReconnectingEvent - Attempting to reconnect
|
|
221
|
+
*/
|
|
222
|
+
interface ReconnectingEvent extends BaseConnectionEvent<"reconnecting", {
|
|
223
|
+
attempt: number;
|
|
224
|
+
maxAttempts?: number;
|
|
225
|
+
delayMs: number;
|
|
226
|
+
}> {
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* ConnectionEvent - All network status events
|
|
230
|
+
*/
|
|
231
|
+
type ConnectionEvent = ConnectedEvent | DisconnectedEvent | ReconnectingEvent;
|
|
232
|
+
/**
|
|
233
|
+
* ConnectionEventType - String literal union
|
|
234
|
+
*/
|
|
235
|
+
type ConnectionEventType = ConnectionEvent["type"];
|
|
236
|
+
/**
|
|
237
|
+
* Type guard: is this a ConnectionEvent?
|
|
238
|
+
*/
|
|
239
|
+
declare function isConnectionEvent(event: {
|
|
240
|
+
source?: string;
|
|
241
|
+
category?: string;
|
|
242
|
+
}): event is ConnectionEvent;
|
|
243
|
+
/**
|
|
244
|
+
* EnvironmentEvent - Union of all environment events
|
|
245
|
+
*/
|
|
246
|
+
type EnvironmentEvent = DriveableEvent | ConnectionEvent;
|
|
247
|
+
/**
|
|
248
|
+
* SystemError - Generic error event
|
|
249
|
+
*
|
|
250
|
+
* Used for all errors until we create specific error types.
|
|
251
|
+
* Can originate from any source (runtime, agent, container, etc.)
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* const error: SystemError = {
|
|
256
|
+
* type: "system_error",
|
|
257
|
+
* timestamp: Date.now(),
|
|
258
|
+
* source: "container",
|
|
259
|
+
* category: "error",
|
|
260
|
+
* intent: "notification",
|
|
261
|
+
* data: {
|
|
262
|
+
* message: "Container not found: default",
|
|
263
|
+
* requestId: "req_123",
|
|
264
|
+
* severity: "error",
|
|
265
|
+
* },
|
|
266
|
+
* context: { containerId: "default" }
|
|
267
|
+
* };
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
interface SystemError extends SystemEvent<"system_error", {
|
|
271
|
+
/**
|
|
272
|
+
* Error message (human-readable)
|
|
273
|
+
*/
|
|
274
|
+
message: string;
|
|
275
|
+
/**
|
|
276
|
+
* Associated request ID (if error is related to a request)
|
|
277
|
+
*/
|
|
278
|
+
requestId?: string;
|
|
279
|
+
/**
|
|
280
|
+
* Error severity
|
|
281
|
+
* - info: Informational, no action needed
|
|
282
|
+
* - warn: Warning, operation succeeded but with issues
|
|
283
|
+
* - error: Error, operation failed
|
|
284
|
+
* - fatal: Fatal error, system unstable
|
|
285
|
+
*/
|
|
286
|
+
severity?: "info" | "warn" | "error" | "fatal";
|
|
287
|
+
/**
|
|
288
|
+
* Additional error details (stack trace, error code, etc.)
|
|
289
|
+
*/
|
|
290
|
+
details?: unknown;
|
|
291
|
+
}, "agent" | "container" | "driver" | "session" | "sandbox" | "command", "error", "notification"> {
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Error event map - will grow as we add specific error types
|
|
295
|
+
*/
|
|
296
|
+
interface ErrorEventMap {
|
|
297
|
+
system_error: SystemError;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Error event types
|
|
301
|
+
*/
|
|
302
|
+
type ErrorEventType = keyof ErrorEventMap;
|
|
303
|
+
/**
|
|
304
|
+
* Union of all error events
|
|
305
|
+
*/
|
|
306
|
+
type ErrorEvent = ErrorEventMap[ErrorEventType];
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Agent Events - Events from Agent domain (stream/state/message/turn)
|
|
310
|
+
*
|
|
311
|
+
* Agent events for the EventBus system.
|
|
312
|
+
*/
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Agent event categories
|
|
316
|
+
*/
|
|
317
|
+
type AgentEventCategory = "stream" | "state" | "message" | "turn";
|
|
318
|
+
/**
|
|
319
|
+
* BaseAgentEvent - Base interface for all Agent events
|
|
320
|
+
*
|
|
321
|
+
* Extends SystemEvent with fixed source and intent.
|
|
322
|
+
*/
|
|
323
|
+
interface BaseAgentEvent<T extends string, D, C extends AgentEventCategory> extends SystemEvent<T, D, "agent", C, "notification"> {
|
|
324
|
+
/**
|
|
325
|
+
* Runtime context (optional, added by Presenter)
|
|
326
|
+
*/
|
|
327
|
+
readonly context?: EventContext;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Base type for agent stream events
|
|
331
|
+
*/
|
|
332
|
+
interface AgentStreamEventBase<T extends string, D> extends BaseAgentEvent<T, D, "stream"> {
|
|
333
|
+
}
|
|
334
|
+
type AgentStopReason = StopReason;
|
|
335
|
+
/**
|
|
336
|
+
* AgentMessageStartEvent - Streaming message begins
|
|
337
|
+
*/
|
|
338
|
+
interface AgentMessageStartEvent extends AgentStreamEventBase<"message_start", {
|
|
339
|
+
messageId: string;
|
|
340
|
+
model: string;
|
|
341
|
+
}> {
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* AgentMessageDeltaEvent - Message-level updates (usage info)
|
|
345
|
+
*/
|
|
346
|
+
interface AgentMessageDeltaEvent extends AgentStreamEventBase<"message_delta", {
|
|
347
|
+
usage?: {
|
|
348
|
+
inputTokens: number;
|
|
349
|
+
outputTokens: number;
|
|
350
|
+
};
|
|
351
|
+
}> {
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* AgentMessageStopEvent - Streaming message completes
|
|
355
|
+
*/
|
|
356
|
+
interface AgentMessageStopEvent extends AgentStreamEventBase<"message_stop", {
|
|
357
|
+
stopReason?: StopReason;
|
|
358
|
+
}> {
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* AgentTextDeltaEvent - Incremental text output
|
|
362
|
+
*/
|
|
363
|
+
interface AgentTextDeltaEvent extends AgentStreamEventBase<"text_delta", {
|
|
364
|
+
text: string;
|
|
365
|
+
}> {
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* AgentToolUseStartEvent - Tool use block started
|
|
369
|
+
*/
|
|
370
|
+
interface AgentToolUseStartEvent extends AgentStreamEventBase<"tool_use_start", {
|
|
371
|
+
toolCallId: string;
|
|
372
|
+
toolName: string;
|
|
373
|
+
}> {
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* AgentInputJsonDeltaEvent - Incremental tool input JSON
|
|
377
|
+
*/
|
|
378
|
+
interface AgentInputJsonDeltaEvent extends AgentStreamEventBase<"input_json_delta", {
|
|
379
|
+
partialJson: string;
|
|
380
|
+
}> {
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* AgentToolUseStopEvent - Tool use block completed
|
|
384
|
+
*/
|
|
385
|
+
interface AgentToolUseStopEvent extends AgentStreamEventBase<"tool_use_stop", {
|
|
386
|
+
toolCallId: string;
|
|
387
|
+
toolName: string;
|
|
388
|
+
input: Record<string, unknown>;
|
|
389
|
+
}> {
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* AgentToolResultEvent - Tool execution result
|
|
393
|
+
*/
|
|
394
|
+
interface AgentToolResultEvent extends AgentStreamEventBase<"tool_result", {
|
|
395
|
+
toolCallId: string;
|
|
396
|
+
result: unknown;
|
|
397
|
+
isError?: boolean;
|
|
398
|
+
}> {
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* AgentErrorReceivedEvent - Error received from environment
|
|
402
|
+
*
|
|
403
|
+
* Processed by MealyMachine to produce:
|
|
404
|
+
* - error_occurred (StateEvent)
|
|
405
|
+
* - error_message (MessageEvent)
|
|
406
|
+
*/
|
|
407
|
+
interface AgentErrorReceivedEvent extends AgentStreamEventBase<"error_received", {
|
|
408
|
+
/** Error message (human-readable) */
|
|
409
|
+
message: string;
|
|
410
|
+
/** Error code (e.g., "rate_limit_error", "api_error") */
|
|
411
|
+
errorCode?: string;
|
|
412
|
+
}> {
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* AgentStreamEvent - All stream events
|
|
416
|
+
*/
|
|
417
|
+
type AgentStreamEvent = AgentMessageStartEvent | AgentMessageDeltaEvent | AgentMessageStopEvent | AgentTextDeltaEvent | AgentToolUseStartEvent | AgentInputJsonDeltaEvent | AgentToolUseStopEvent | AgentToolResultEvent | AgentErrorReceivedEvent;
|
|
418
|
+
/**
|
|
419
|
+
* AgentStreamEventType - String literal union
|
|
420
|
+
*/
|
|
421
|
+
type AgentStreamEventType = AgentStreamEvent["type"];
|
|
422
|
+
/**
|
|
423
|
+
* Type guard: is this a stream event?
|
|
424
|
+
*/
|
|
425
|
+
declare function isAgentStreamEvent(event: {
|
|
426
|
+
source?: string;
|
|
427
|
+
category?: string;
|
|
428
|
+
}): event is AgentStreamEvent;
|
|
429
|
+
/**
|
|
430
|
+
* Base type for state events
|
|
431
|
+
*/
|
|
432
|
+
interface AgentStateEventBase<T extends string, D> extends BaseAgentEvent<T, D, "state"> {
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* ConversationQueuedEvent - Message queued for processing
|
|
436
|
+
*/
|
|
437
|
+
interface ConversationQueuedEvent extends AgentStateEventBase<"conversation_queued", {
|
|
438
|
+
messageId: string;
|
|
439
|
+
}> {
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* ConversationStartEvent - Conversation started
|
|
443
|
+
*/
|
|
444
|
+
interface ConversationStartEvent extends AgentStateEventBase<"conversation_start", {
|
|
445
|
+
messageId: string;
|
|
446
|
+
}> {
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* ConversationThinkingEvent - Agent is thinking
|
|
450
|
+
*/
|
|
451
|
+
interface ConversationThinkingEvent extends AgentStateEventBase<"conversation_thinking", Record<string, never>> {
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* ConversationRespondingEvent - Agent is responding
|
|
455
|
+
*/
|
|
456
|
+
interface ConversationRespondingEvent extends AgentStateEventBase<"conversation_responding", Record<string, never>> {
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* ConversationEndEvent - Conversation ended
|
|
460
|
+
*/
|
|
461
|
+
interface ConversationEndEvent extends AgentStateEventBase<"conversation_end", {
|
|
462
|
+
reason: "completed" | "interrupted" | "error";
|
|
463
|
+
}> {
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* ConversationInterruptedEvent - Conversation interrupted
|
|
467
|
+
*/
|
|
468
|
+
interface ConversationInterruptedEvent extends AgentStateEventBase<"conversation_interrupted", {
|
|
469
|
+
reason: string;
|
|
470
|
+
}> {
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* ToolPlannedEvent - Tool use planned
|
|
474
|
+
*/
|
|
475
|
+
interface ToolPlannedEvent extends AgentStateEventBase<"tool_planned", {
|
|
476
|
+
toolId: string;
|
|
477
|
+
toolName: string;
|
|
478
|
+
}> {
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* ToolExecutingEvent - Tool is executing
|
|
482
|
+
*/
|
|
483
|
+
interface ToolExecutingEvent extends AgentStateEventBase<"tool_executing", {
|
|
484
|
+
toolId: string;
|
|
485
|
+
toolName: string;
|
|
486
|
+
input: Record<string, unknown>;
|
|
487
|
+
}> {
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* ToolCompletedEvent - Tool execution completed
|
|
491
|
+
*/
|
|
492
|
+
interface ToolCompletedEvent extends AgentStateEventBase<"tool_completed", {
|
|
493
|
+
toolId: string;
|
|
494
|
+
toolName: string;
|
|
495
|
+
result: unknown;
|
|
496
|
+
}> {
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* ToolFailedEvent - Tool execution failed
|
|
500
|
+
*/
|
|
501
|
+
interface ToolFailedEvent extends AgentStateEventBase<"tool_failed", {
|
|
502
|
+
toolId: string;
|
|
503
|
+
toolName: string;
|
|
504
|
+
error: string;
|
|
505
|
+
}> {
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* ErrorOccurredEvent - Error occurred during processing
|
|
509
|
+
*/
|
|
510
|
+
interface ErrorOccurredEvent extends AgentStateEventBase<"error_occurred", {
|
|
511
|
+
code: string;
|
|
512
|
+
message: string;
|
|
513
|
+
recoverable: boolean;
|
|
514
|
+
category?: string;
|
|
515
|
+
}> {
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* AgentStateEvent - All state events
|
|
519
|
+
*/
|
|
520
|
+
type AgentStateEvent = ConversationQueuedEvent | ConversationStartEvent | ConversationThinkingEvent | ConversationRespondingEvent | ConversationEndEvent | ConversationInterruptedEvent | ToolPlannedEvent | ToolExecutingEvent | ToolCompletedEvent | ToolFailedEvent | ErrorOccurredEvent;
|
|
521
|
+
/**
|
|
522
|
+
* AgentStateEventType - String literal union
|
|
523
|
+
*/
|
|
524
|
+
type AgentStateEventType = AgentStateEvent["type"];
|
|
525
|
+
/**
|
|
526
|
+
* Type guard: is this a state event?
|
|
527
|
+
*/
|
|
528
|
+
declare function isAgentStateEvent(event: {
|
|
529
|
+
source?: string;
|
|
530
|
+
category?: string;
|
|
531
|
+
}): event is AgentStateEvent;
|
|
532
|
+
/**
|
|
533
|
+
* Base type for message events
|
|
534
|
+
*/
|
|
535
|
+
interface AgentMessageEventBase<T extends string, D> extends BaseAgentEvent<T, D, "message"> {
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* UserMessageEvent - User sent a message
|
|
539
|
+
* Data: Complete UserMessage object
|
|
540
|
+
*/
|
|
541
|
+
interface UserMessageEvent extends AgentMessageEventBase<"user_message", UserMessage> {
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* AssistantMessageEvent - Assistant response message
|
|
545
|
+
* Data: Complete AssistantMessage object
|
|
546
|
+
*/
|
|
547
|
+
interface AssistantMessageEvent extends AgentMessageEventBase<"assistant_message", AssistantMessage> {
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* ToolCallMessageEvent - Tool call message (part of assistant turn)
|
|
551
|
+
* Data: Complete ToolCallMessage object
|
|
552
|
+
*/
|
|
553
|
+
interface ToolCallMessageEvent extends AgentMessageEventBase<"tool_call_message", ToolCallMessage> {
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* ToolResultMessageEvent - Tool result message
|
|
557
|
+
* Data: Complete ToolResultMessage object
|
|
558
|
+
*/
|
|
559
|
+
interface ToolResultMessageEvent extends AgentMessageEventBase<"tool_result_message", ToolResultMessage> {
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* ErrorMessageEvent - Error message displayed in chat
|
|
563
|
+
* Data: Complete ErrorMessage object
|
|
564
|
+
*
|
|
565
|
+
* Generated when error_received StreamEvent is processed by MealyMachine.
|
|
566
|
+
* Displayed in the chat history so users can see what went wrong.
|
|
567
|
+
*/
|
|
568
|
+
interface ErrorMessageEvent extends AgentMessageEventBase<"error_message", ErrorMessage> {
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* AgentMessageEvent - All message events
|
|
572
|
+
*/
|
|
573
|
+
type AgentMessageEvent = UserMessageEvent | AssistantMessageEvent | ToolCallMessageEvent | ToolResultMessageEvent | ErrorMessageEvent;
|
|
574
|
+
/**
|
|
575
|
+
* AgentMessageEventType - String literal union
|
|
576
|
+
*/
|
|
577
|
+
type AgentMessageEventType = AgentMessageEvent["type"];
|
|
578
|
+
/**
|
|
579
|
+
* Type guard: is this a message event?
|
|
580
|
+
*/
|
|
581
|
+
declare function isAgentMessageEvent(event: {
|
|
582
|
+
source?: string;
|
|
583
|
+
category?: string;
|
|
584
|
+
}): event is AgentMessageEvent;
|
|
585
|
+
/**
|
|
586
|
+
* Base type for turn events
|
|
587
|
+
*/
|
|
588
|
+
interface AgentTurnEventBase<T extends string, D> extends BaseAgentEvent<T, D, "turn"> {
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Token usage information
|
|
592
|
+
*/
|
|
593
|
+
interface TokenUsage {
|
|
594
|
+
inputTokens: number;
|
|
595
|
+
outputTokens: number;
|
|
596
|
+
totalTokens?: number;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* TurnRequestEvent - Turn started (user message received)
|
|
600
|
+
*/
|
|
601
|
+
interface TurnRequestEvent extends AgentTurnEventBase<"turn_request", {
|
|
602
|
+
turnId: string;
|
|
603
|
+
messageId: string;
|
|
604
|
+
content: string;
|
|
605
|
+
timestamp: number;
|
|
606
|
+
}> {
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* TurnResponseEvent - Turn completed (assistant response finished)
|
|
610
|
+
*/
|
|
611
|
+
interface TurnResponseEvent extends AgentTurnEventBase<"turn_response", {
|
|
612
|
+
turnId: string;
|
|
613
|
+
messageId: string;
|
|
614
|
+
duration: number;
|
|
615
|
+
usage?: TokenUsage;
|
|
616
|
+
model?: string;
|
|
617
|
+
stopReason?: string;
|
|
618
|
+
timestamp: number;
|
|
619
|
+
}> {
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* AgentTurnEvent - All turn events
|
|
623
|
+
*/
|
|
624
|
+
type AgentTurnEvent = TurnRequestEvent | TurnResponseEvent;
|
|
625
|
+
/**
|
|
626
|
+
* AgentTurnEventType - String literal union
|
|
627
|
+
*/
|
|
628
|
+
type AgentTurnEventType = AgentTurnEvent["type"];
|
|
629
|
+
/**
|
|
630
|
+
* Type guard: is this a turn event?
|
|
631
|
+
*/
|
|
632
|
+
declare function isAgentTurnEvent(event: {
|
|
633
|
+
source?: string;
|
|
634
|
+
category?: string;
|
|
635
|
+
}): event is AgentTurnEvent;
|
|
636
|
+
/**
|
|
637
|
+
* AgentEvent - All events from Agent domain
|
|
638
|
+
*/
|
|
639
|
+
type AgentEvent = AgentStreamEvent | AgentStateEvent | AgentMessageEvent | AgentTurnEvent;
|
|
640
|
+
/**
|
|
641
|
+
* Type guard: is this an agent event?
|
|
642
|
+
*/
|
|
643
|
+
declare function isAgentEvent(event: {
|
|
644
|
+
source?: string;
|
|
645
|
+
}): event is AgentEvent;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Session Events - Session lifecycle, persist, and action events
|
|
649
|
+
*
|
|
650
|
+
* Events for session operations in the event system.
|
|
651
|
+
*/
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Base SessionLifecycleEvent
|
|
655
|
+
*/
|
|
656
|
+
interface BaseSessionLifecycleEvent<T extends string, D = unknown> extends SystemEvent<T, D, "session", "lifecycle", "notification"> {
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* SessionCreatedEvent - Session was created
|
|
660
|
+
*/
|
|
661
|
+
interface SessionCreatedEvent extends BaseSessionLifecycleEvent<"session_created", {
|
|
662
|
+
sessionId: string;
|
|
663
|
+
imageId: string;
|
|
664
|
+
containerId: string;
|
|
665
|
+
title?: string;
|
|
666
|
+
createdAt: number;
|
|
667
|
+
}> {
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* SessionDestroyedEvent - Session was destroyed
|
|
671
|
+
*/
|
|
672
|
+
interface SessionDestroyedEvent extends BaseSessionLifecycleEvent<"session_destroyed", {
|
|
673
|
+
sessionId: string;
|
|
674
|
+
reason?: string;
|
|
675
|
+
}> {
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* SessionLifecycleEvent - All session lifecycle events
|
|
679
|
+
*/
|
|
680
|
+
type SessionLifecycleEvent = SessionCreatedEvent | SessionDestroyedEvent;
|
|
681
|
+
/**
|
|
682
|
+
* Type guard: is this a SessionLifecycleEvent?
|
|
683
|
+
*/
|
|
684
|
+
declare function isSessionLifecycleEvent(event: {
|
|
685
|
+
source?: string;
|
|
686
|
+
category?: string;
|
|
687
|
+
}): event is SessionLifecycleEvent;
|
|
688
|
+
/**
|
|
689
|
+
* Base SessionPersistRequest
|
|
690
|
+
*/
|
|
691
|
+
interface BaseSessionPersistRequest<T extends string, D = unknown> extends SystemEvent<T, D, "session", "persist", "request"> {
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Base SessionPersistResult
|
|
695
|
+
*/
|
|
696
|
+
interface BaseSessionPersistResult<T extends string, D = unknown> extends SystemEvent<T, D, "session", "persist", "result"> {
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* SessionSaveRequest - Request to save session
|
|
700
|
+
*/
|
|
701
|
+
interface SessionSaveRequest extends BaseSessionPersistRequest<"session_save_request", {
|
|
702
|
+
sessionId: string;
|
|
703
|
+
title?: string;
|
|
704
|
+
metadata?: Record<string, unknown>;
|
|
705
|
+
}> {
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* SessionSavedEvent - Session was saved
|
|
709
|
+
*/
|
|
710
|
+
interface SessionSavedEvent extends BaseSessionPersistResult<"session_saved", {
|
|
711
|
+
sessionId: string;
|
|
712
|
+
savedAt: number;
|
|
713
|
+
}> {
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* MessagePersistRequest - Request to persist a message
|
|
717
|
+
*/
|
|
718
|
+
interface MessagePersistRequest extends BaseSessionPersistRequest<"message_persist_request", {
|
|
719
|
+
sessionId: string;
|
|
720
|
+
messageId: string;
|
|
721
|
+
role: "user" | "assistant" | "tool_call" | "tool_result";
|
|
722
|
+
content: unknown;
|
|
723
|
+
}> {
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* MessagePersistedEvent - Message was persisted
|
|
727
|
+
*/
|
|
728
|
+
interface MessagePersistedEvent extends BaseSessionPersistResult<"message_persisted", {
|
|
729
|
+
sessionId: string;
|
|
730
|
+
messageId: string;
|
|
731
|
+
savedAt: number;
|
|
732
|
+
}> {
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* SessionPersistEvent - All session persist events
|
|
736
|
+
*/
|
|
737
|
+
type SessionPersistEvent = SessionSaveRequest | SessionSavedEvent | MessagePersistRequest | MessagePersistedEvent;
|
|
738
|
+
/**
|
|
739
|
+
* Session persist request events
|
|
740
|
+
*/
|
|
741
|
+
type SessionPersistRequestEvent = SessionSaveRequest | MessagePersistRequest;
|
|
742
|
+
/**
|
|
743
|
+
* Session persist result events
|
|
744
|
+
*/
|
|
745
|
+
type SessionPersistResultEvent = SessionSavedEvent | MessagePersistedEvent;
|
|
746
|
+
/**
|
|
747
|
+
* Type guard: is this a SessionPersistEvent?
|
|
748
|
+
*/
|
|
749
|
+
declare function isSessionPersistEvent(event: {
|
|
750
|
+
source?: string;
|
|
751
|
+
category?: string;
|
|
752
|
+
}): event is SessionPersistEvent;
|
|
753
|
+
/**
|
|
754
|
+
* Base SessionActionRequest
|
|
755
|
+
*/
|
|
756
|
+
interface BaseSessionActionRequest<T extends string, D = unknown> extends SystemEvent<T, D, "session", "action", "request"> {
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Base SessionActionResult
|
|
760
|
+
*/
|
|
761
|
+
interface BaseSessionActionResult<T extends string, D = unknown> extends SystemEvent<T, D, "session", "action", "result"> {
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* SessionResumeRequest - Request to resume a session
|
|
765
|
+
*/
|
|
766
|
+
interface SessionResumeRequest extends BaseSessionActionRequest<"session_resume_request", {
|
|
767
|
+
sessionId: string;
|
|
768
|
+
containerId?: string;
|
|
769
|
+
}> {
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* SessionResumedEvent - Session was resumed
|
|
773
|
+
*/
|
|
774
|
+
interface SessionResumedEvent extends BaseSessionActionResult<"session_resumed", {
|
|
775
|
+
sessionId: string;
|
|
776
|
+
agentId: string;
|
|
777
|
+
resumedAt: number;
|
|
778
|
+
}> {
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* SessionForkRequest - Request to fork a session
|
|
782
|
+
*/
|
|
783
|
+
interface SessionForkRequest extends BaseSessionActionRequest<"session_fork_request", {
|
|
784
|
+
sessionId: string;
|
|
785
|
+
newTitle?: string;
|
|
786
|
+
}> {
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* SessionForkedEvent - Session was forked
|
|
790
|
+
*/
|
|
791
|
+
interface SessionForkedEvent extends BaseSessionActionResult<"session_forked", {
|
|
792
|
+
originalSessionId: string;
|
|
793
|
+
newSessionId: string;
|
|
794
|
+
newImageId: string;
|
|
795
|
+
forkedAt: number;
|
|
796
|
+
}> {
|
|
797
|
+
}
|
|
798
|
+
/**
|
|
799
|
+
* SessionTitleUpdateRequest - Request to update session title
|
|
800
|
+
*/
|
|
801
|
+
interface SessionTitleUpdateRequest extends BaseSessionActionRequest<"session_title_update_request", {
|
|
802
|
+
sessionId: string;
|
|
803
|
+
title: string;
|
|
804
|
+
}> {
|
|
805
|
+
}
|
|
806
|
+
/**
|
|
807
|
+
* SessionTitleUpdatedEvent - Session title was updated
|
|
808
|
+
*/
|
|
809
|
+
interface SessionTitleUpdatedEvent extends BaseSessionActionResult<"session_title_updated", {
|
|
810
|
+
sessionId: string;
|
|
811
|
+
title: string;
|
|
812
|
+
updatedAt: number;
|
|
813
|
+
}> {
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* SessionActionEvent - All session action events
|
|
817
|
+
*/
|
|
818
|
+
type SessionActionEvent = SessionResumeRequest | SessionResumedEvent | SessionForkRequest | SessionForkedEvent | SessionTitleUpdateRequest | SessionTitleUpdatedEvent;
|
|
819
|
+
/**
|
|
820
|
+
* Session action request events
|
|
821
|
+
*/
|
|
822
|
+
type SessionActionRequestEvent = SessionResumeRequest | SessionForkRequest | SessionTitleUpdateRequest;
|
|
823
|
+
/**
|
|
824
|
+
* Session action result events
|
|
825
|
+
*/
|
|
826
|
+
type SessionActionResultEvent = SessionResumedEvent | SessionForkedEvent | SessionTitleUpdatedEvent;
|
|
827
|
+
/**
|
|
828
|
+
* Type guard: is this a SessionActionEvent?
|
|
829
|
+
*/
|
|
830
|
+
declare function isSessionActionEvent(event: {
|
|
831
|
+
source?: string;
|
|
832
|
+
category?: string;
|
|
833
|
+
}): event is SessionActionEvent;
|
|
834
|
+
/**
|
|
835
|
+
* SessionEvent - All session events
|
|
836
|
+
*/
|
|
837
|
+
type SessionEvent = SessionLifecycleEvent | SessionPersistEvent | SessionActionEvent;
|
|
838
|
+
/**
|
|
839
|
+
* Type guard: is this a session event?
|
|
840
|
+
*/
|
|
841
|
+
declare function isSessionEvent(event: {
|
|
842
|
+
source?: string;
|
|
843
|
+
}): event is SessionEvent;
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* Container Events - Container lifecycle and sandbox events
|
|
847
|
+
*
|
|
848
|
+
* Events for container operations in the event system.
|
|
849
|
+
*/
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Base ContainerLifecycleEvent
|
|
853
|
+
*/
|
|
854
|
+
interface BaseContainerLifecycleEvent<T extends string, D = unknown> extends SystemEvent<T, D, "container", "lifecycle", "notification"> {
|
|
855
|
+
}
|
|
856
|
+
/**
|
|
857
|
+
* ContainerCreatedEvent - Container was created
|
|
858
|
+
*/
|
|
859
|
+
interface ContainerCreatedEvent extends BaseContainerLifecycleEvent<"container_created", {
|
|
860
|
+
containerId: string;
|
|
861
|
+
name?: string;
|
|
862
|
+
createdAt: number;
|
|
863
|
+
}> {
|
|
864
|
+
}
|
|
865
|
+
/**
|
|
866
|
+
* ContainerDestroyedEvent - Container was destroyed
|
|
867
|
+
*/
|
|
868
|
+
interface ContainerDestroyedEvent extends BaseContainerLifecycleEvent<"container_destroyed", {
|
|
869
|
+
containerId: string;
|
|
870
|
+
reason?: string;
|
|
871
|
+
agentCount: number;
|
|
872
|
+
}> {
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* AgentRegisteredEvent - Agent was registered to container
|
|
876
|
+
*/
|
|
877
|
+
interface AgentRegisteredEvent extends BaseContainerLifecycleEvent<"agent_registered", {
|
|
878
|
+
containerId: string;
|
|
879
|
+
agentId: string;
|
|
880
|
+
definitionName: string;
|
|
881
|
+
registeredAt: number;
|
|
882
|
+
}> {
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* AgentUnregisteredEvent - Agent was unregistered from container
|
|
886
|
+
*/
|
|
887
|
+
interface AgentUnregisteredEvent extends BaseContainerLifecycleEvent<"agent_unregistered", {
|
|
888
|
+
containerId: string;
|
|
889
|
+
agentId: string;
|
|
890
|
+
reason?: string;
|
|
891
|
+
}> {
|
|
892
|
+
}
|
|
893
|
+
/**
|
|
894
|
+
* ContainerLifecycleEvent - All container lifecycle events
|
|
895
|
+
*/
|
|
896
|
+
type ContainerLifecycleEvent = ContainerCreatedEvent | ContainerDestroyedEvent | AgentRegisteredEvent | AgentUnregisteredEvent;
|
|
897
|
+
/**
|
|
898
|
+
* Type guard: is this a ContainerLifecycleEvent?
|
|
899
|
+
*/
|
|
900
|
+
declare function isContainerLifecycleEvent(event: {
|
|
901
|
+
source?: string;
|
|
902
|
+
category?: string;
|
|
903
|
+
}): event is ContainerLifecycleEvent;
|
|
904
|
+
/**
|
|
905
|
+
* Base WorkdirRequest
|
|
906
|
+
*/
|
|
907
|
+
interface BaseWorkdirRequest<T extends string, D = unknown> extends SystemEvent<T, D, "sandbox", "workdir", "request"> {
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Base WorkdirResult
|
|
911
|
+
*/
|
|
912
|
+
interface BaseWorkdirResult<T extends string, D = unknown> extends SystemEvent<T, D, "sandbox", "workdir", "result"> {
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Base WorkdirNotification
|
|
916
|
+
*/
|
|
917
|
+
interface BaseWorkdirNotification<T extends string, D = unknown> extends SystemEvent<T, D, "sandbox", "workdir", "notification"> {
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* FileReadRequest - Request to read a file
|
|
921
|
+
*/
|
|
922
|
+
interface FileReadRequest extends BaseWorkdirRequest<"file_read_request", {
|
|
923
|
+
path: string;
|
|
924
|
+
encoding?: string;
|
|
925
|
+
}> {
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* FileReadResult - File read result
|
|
929
|
+
*/
|
|
930
|
+
interface FileReadResult extends BaseWorkdirResult<"file_read_result", {
|
|
931
|
+
path: string;
|
|
932
|
+
content: string;
|
|
933
|
+
size: number;
|
|
934
|
+
encoding: string;
|
|
935
|
+
}> {
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* FileWriteRequest - Request to write a file
|
|
939
|
+
*/
|
|
940
|
+
interface FileWriteRequest extends BaseWorkdirRequest<"file_write_request", {
|
|
941
|
+
path: string;
|
|
942
|
+
content: string;
|
|
943
|
+
encoding?: string;
|
|
944
|
+
createDirectories?: boolean;
|
|
945
|
+
}> {
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* FileWrittenEvent - File was written
|
|
949
|
+
*/
|
|
950
|
+
interface FileWrittenEvent extends BaseWorkdirResult<"file_written", {
|
|
951
|
+
path: string;
|
|
952
|
+
size: number;
|
|
953
|
+
timestamp: number;
|
|
954
|
+
}> {
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* FileDeleteRequest - Request to delete a file
|
|
958
|
+
*/
|
|
959
|
+
interface FileDeleteRequest extends BaseWorkdirRequest<"file_delete_request", {
|
|
960
|
+
path: string;
|
|
961
|
+
recursive?: boolean;
|
|
962
|
+
}> {
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* FileDeletedEvent - File was deleted
|
|
966
|
+
*/
|
|
967
|
+
interface FileDeletedEvent extends BaseWorkdirResult<"file_deleted", {
|
|
968
|
+
path: string;
|
|
969
|
+
timestamp: number;
|
|
970
|
+
}> {
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* DirectoryListRequest - Request to list directory
|
|
974
|
+
*/
|
|
975
|
+
interface DirectoryListRequest extends BaseWorkdirRequest<"directory_list_request", {
|
|
976
|
+
path: string;
|
|
977
|
+
recursive?: boolean;
|
|
978
|
+
pattern?: string;
|
|
979
|
+
}> {
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* DirectoryListResult - Directory listing result
|
|
983
|
+
*/
|
|
984
|
+
interface DirectoryListResult extends BaseWorkdirResult<"directory_list_result", {
|
|
985
|
+
path: string;
|
|
986
|
+
entries: Array<{
|
|
987
|
+
name: string;
|
|
988
|
+
type: "file" | "directory";
|
|
989
|
+
size?: number;
|
|
990
|
+
modifiedAt?: number;
|
|
991
|
+
}>;
|
|
992
|
+
}> {
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* WorkdirErrorEvent - Workdir operation error
|
|
996
|
+
*/
|
|
997
|
+
interface WorkdirErrorEvent extends BaseWorkdirNotification<"workdir_error", {
|
|
998
|
+
operation: string;
|
|
999
|
+
path: string;
|
|
1000
|
+
code: string;
|
|
1001
|
+
message: string;
|
|
1002
|
+
}> {
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* WorkdirEvent - All workdir events
|
|
1006
|
+
*/
|
|
1007
|
+
type WorkdirEvent = FileReadRequest | FileReadResult | FileWriteRequest | FileWrittenEvent | FileDeleteRequest | FileDeletedEvent | DirectoryListRequest | DirectoryListResult | WorkdirErrorEvent;
|
|
1008
|
+
/**
|
|
1009
|
+
* Workdir request events
|
|
1010
|
+
*/
|
|
1011
|
+
type WorkdirRequestEvent = FileReadRequest | FileWriteRequest | FileDeleteRequest | DirectoryListRequest;
|
|
1012
|
+
/**
|
|
1013
|
+
* Workdir result events
|
|
1014
|
+
*/
|
|
1015
|
+
type WorkdirResultEvent = FileReadResult | FileWrittenEvent | FileDeletedEvent | DirectoryListResult;
|
|
1016
|
+
/**
|
|
1017
|
+
* Type guard: is this a WorkdirEvent?
|
|
1018
|
+
*/
|
|
1019
|
+
declare function isWorkdirEvent(event: {
|
|
1020
|
+
source?: string;
|
|
1021
|
+
category?: string;
|
|
1022
|
+
}): event is WorkdirEvent;
|
|
1023
|
+
/**
|
|
1024
|
+
* Base MCPRequest
|
|
1025
|
+
*/
|
|
1026
|
+
interface BaseMCPRequest<T extends string, D = unknown> extends SystemEvent<T, D, "sandbox", "mcp", "request"> {
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Base MCPResult
|
|
1030
|
+
*/
|
|
1031
|
+
interface BaseMCPResult<T extends string, D = unknown> extends SystemEvent<T, D, "sandbox", "mcp", "result"> {
|
|
1032
|
+
}
|
|
1033
|
+
/**
|
|
1034
|
+
* Base MCPNotification
|
|
1035
|
+
*/
|
|
1036
|
+
interface BaseMCPNotification<T extends string, D = unknown> extends SystemEvent<T, D, "sandbox", "mcp", "notification"> {
|
|
1037
|
+
}
|
|
1038
|
+
/**
|
|
1039
|
+
* ToolExecuteRequest - Request to execute a tool
|
|
1040
|
+
*/
|
|
1041
|
+
interface ToolExecuteRequest extends BaseMCPRequest<"tool_execute_request", {
|
|
1042
|
+
toolId: string;
|
|
1043
|
+
toolName: string;
|
|
1044
|
+
serverName: string;
|
|
1045
|
+
input: Record<string, unknown>;
|
|
1046
|
+
timestamp: number;
|
|
1047
|
+
}> {
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* ToolExecutedEvent - Tool execution completed
|
|
1051
|
+
*/
|
|
1052
|
+
interface ToolExecutedEvent extends BaseMCPResult<"tool_executed", {
|
|
1053
|
+
toolId: string;
|
|
1054
|
+
toolName: string;
|
|
1055
|
+
result: unknown;
|
|
1056
|
+
duration: number;
|
|
1057
|
+
timestamp: number;
|
|
1058
|
+
}> {
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* ToolExecutionErrorEvent - Tool execution failed
|
|
1062
|
+
*/
|
|
1063
|
+
interface ToolExecutionErrorEvent extends BaseMCPNotification<"tool_execution_error", {
|
|
1064
|
+
toolId: string;
|
|
1065
|
+
toolName: string;
|
|
1066
|
+
code: string;
|
|
1067
|
+
message: string;
|
|
1068
|
+
timestamp: number;
|
|
1069
|
+
}> {
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* MCPServerConnectedEvent - MCP server connected
|
|
1073
|
+
*/
|
|
1074
|
+
interface MCPServerConnectedEvent extends BaseMCPNotification<"mcp_server_connected", {
|
|
1075
|
+
serverName: string;
|
|
1076
|
+
version?: string;
|
|
1077
|
+
toolCount: number;
|
|
1078
|
+
resourceCount: number;
|
|
1079
|
+
timestamp: number;
|
|
1080
|
+
}> {
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* MCPServerDisconnectedEvent - MCP server disconnected
|
|
1084
|
+
*/
|
|
1085
|
+
interface MCPServerDisconnectedEvent extends BaseMCPNotification<"mcp_server_disconnected", {
|
|
1086
|
+
serverName: string;
|
|
1087
|
+
reason?: string;
|
|
1088
|
+
timestamp: number;
|
|
1089
|
+
}> {
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* ResourceReadRequest - Request to read an MCP resource
|
|
1093
|
+
*/
|
|
1094
|
+
interface ResourceReadRequest extends BaseMCPRequest<"resource_read_request", {
|
|
1095
|
+
serverName: string;
|
|
1096
|
+
uri: string;
|
|
1097
|
+
}> {
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* ResourceReadResult - Resource read result
|
|
1101
|
+
*/
|
|
1102
|
+
interface ResourceReadResult extends BaseMCPResult<"resource_read_result", {
|
|
1103
|
+
serverName: string;
|
|
1104
|
+
uri: string;
|
|
1105
|
+
content: unknown;
|
|
1106
|
+
mimeType?: string;
|
|
1107
|
+
}> {
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* MCPEvent - All MCP events
|
|
1111
|
+
*/
|
|
1112
|
+
type MCPEvent = ToolExecuteRequest | ToolExecutedEvent | ToolExecutionErrorEvent | MCPServerConnectedEvent | MCPServerDisconnectedEvent | ResourceReadRequest | ResourceReadResult;
|
|
1113
|
+
/**
|
|
1114
|
+
* MCP request events
|
|
1115
|
+
*/
|
|
1116
|
+
type MCPRequestEvent = ToolExecuteRequest | ResourceReadRequest;
|
|
1117
|
+
/**
|
|
1118
|
+
* MCP result events
|
|
1119
|
+
*/
|
|
1120
|
+
type MCPResultEvent = ToolExecutedEvent | ResourceReadResult;
|
|
1121
|
+
/**
|
|
1122
|
+
* Type guard: is this a MCPEvent?
|
|
1123
|
+
*/
|
|
1124
|
+
declare function isMCPEvent(event: {
|
|
1125
|
+
source?: string;
|
|
1126
|
+
category?: string;
|
|
1127
|
+
}): event is MCPEvent;
|
|
1128
|
+
/**
|
|
1129
|
+
* SandboxEvent - All sandbox events
|
|
1130
|
+
*/
|
|
1131
|
+
type SandboxEvent = WorkdirEvent | MCPEvent;
|
|
1132
|
+
/**
|
|
1133
|
+
* Type guard: is this a sandbox event?
|
|
1134
|
+
*/
|
|
1135
|
+
declare function isSandboxEvent(event: {
|
|
1136
|
+
source?: string;
|
|
1137
|
+
}): event is SandboxEvent;
|
|
1138
|
+
/**
|
|
1139
|
+
* ContainerEvent - All container events
|
|
1140
|
+
*/
|
|
1141
|
+
type ContainerEvent = ContainerLifecycleEvent | SandboxEvent;
|
|
1142
|
+
/**
|
|
1143
|
+
* Type guard: is this a container event?
|
|
1144
|
+
*/
|
|
1145
|
+
declare function isContainerEvent(event: {
|
|
1146
|
+
source?: string;
|
|
1147
|
+
}): event is ContainerEvent;
|
|
1148
|
+
|
|
1149
|
+
export { type AgentErrorReceivedEvent, type AgentEvent, type AgentEventCategory, type AgentInputJsonDeltaEvent, type AgentMessageDeltaEvent, type AgentMessageEvent, type AgentMessageEventBase, type AgentMessageEventType, type AgentMessageStartEvent, type AgentMessageStopEvent, type AgentRegisteredEvent, type AgentStateEvent, type AgentStateEventBase, type AgentStateEventType, type AgentStopReason, type AgentStreamEvent, type AgentStreamEventBase, type AgentStreamEventType, type AgentTextDeltaEvent, type AgentToolResultEvent, type AgentToolUseStartEvent, type AgentToolUseStopEvent, type AgentTurnEvent, type AgentTurnEventBase, type AgentTurnEventType, type AgentUnregisteredEvent, type AssistantMessageEvent, type BaseAgentEvent, type ConnectedEvent, type ConnectionEvent, type ConnectionEventType, type ContainerCreatedEvent, type ContainerDestroyedEvent, type ContainerEvent, type ContainerLifecycleEvent, type ConversationEndEvent, type ConversationInterruptedEvent, type ConversationQueuedEvent, type ConversationRespondingEvent, type ConversationStartEvent, type ConversationThinkingEvent, type DirectoryListRequest, type DirectoryListResult, type DisconnectedEvent, type DriveableEvent, type DriveableEventType, type EnvironmentEvent, type ErrorEvent, type ErrorEventMap, type ErrorEventType, type ErrorMessageEvent, type ErrorOccurredEvent, type ErrorReceivedEvent, EventContext, type FileDeleteRequest, type FileDeletedEvent, type FileReadRequest, type FileReadResult, type FileWriteRequest, type FileWrittenEvent, type InputJsonDeltaEvent, type InterruptedEvent, type MCPEvent, type MCPRequestEvent, type MCPResultEvent, type MCPServerConnectedEvent, type MCPServerDisconnectedEvent, type MessageDeltaEvent, type MessagePersistRequest, type MessagePersistedEvent, type MessageStartEvent, type MessageStopEvent, type ReconnectingEvent, type ResourceReadRequest, type ResourceReadResult, type SandboxEvent, type SessionActionEvent, type SessionActionRequestEvent, type SessionActionResultEvent, type SessionCreatedEvent, type SessionDestroyedEvent, type SessionEvent, type SessionForkRequest, type SessionForkedEvent, type SessionLifecycleEvent, type SessionPersistEvent, type SessionPersistRequestEvent, type SessionPersistResultEvent, type SessionResumeRequest, type SessionResumedEvent, type SessionSaveRequest, type SessionSavedEvent, type SessionTitleUpdateRequest, type SessionTitleUpdatedEvent, type StopReason, type SystemError, SystemEvent, type TextContentBlockStartEvent, type TextContentBlockStopEvent, type TextDeltaEvent, type TokenUsage, type ToolCallEvent, type ToolCallMessageEvent, type ToolCompletedEvent, type ToolExecuteRequest, type ToolExecutedEvent, type ToolExecutingEvent, type ToolExecutionErrorEvent, type ToolFailedEvent, type ToolPlannedEvent, type ToolResultEvent, type ToolResultMessageEvent, type ToolUseContentBlockStartEvent, type ToolUseContentBlockStopEvent, type TurnRequestEvent, type TurnResponseEvent, type UserMessageEvent, type WorkdirErrorEvent, type WorkdirEvent, type WorkdirRequestEvent, type WorkdirResultEvent, isAgentEvent, isAgentMessageEvent, isAgentStateEvent, isAgentStreamEvent, isAgentTurnEvent, isConnectionEvent, isContainerEvent, isContainerLifecycleEvent, isDriveableEvent, isMCPEvent, isSandboxEvent, isSessionActionEvent, isSessionEvent, isSessionLifecycleEvent, isSessionPersistEvent, isStopReason, isWorkdirEvent };
|