@agentxjs/types 0.0.6 → 0.2.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 (86) hide show
  1. package/dist/Agent-BXUYGlWZ.d.cts +510 -0
  2. package/dist/Agent-CaSxMF_E.d.ts +510 -0
  3. package/dist/CommandEvent-CbXzPolX.d.ts +495 -0
  4. package/dist/CommandEvent-DCdk7lzX.d.cts +495 -0
  5. package/dist/Container-DR-1g44i.d.ts +641 -0
  6. package/dist/Container-dBDOcjhk.d.cts +641 -0
  7. package/dist/ContentPart-CqOh-rI1.d.ts +19 -0
  8. package/dist/ContentPart-DEFnYXCU.d.cts +19 -0
  9. package/dist/DriveableEvent-Bj7nn-Uk.d.ts +161 -0
  10. package/dist/DriveableEvent-CCMC1h_C.d.cts +161 -0
  11. package/dist/ErrorMessage-BoIh3MIO.d.cts +24 -0
  12. package/dist/ErrorMessage-BoIh3MIO.d.ts +24 -0
  13. package/dist/ImageRecord-Cn0VcJWk.d.cts +71 -0
  14. package/dist/ImageRecord-Cn0VcJWk.d.ts +71 -0
  15. package/dist/LoggerFactory-DZtw0M7U.d.cts +129 -0
  16. package/dist/LoggerFactory-DZtw0M7U.d.ts +129 -0
  17. package/dist/Message-Crh81uLL.d.cts +45 -0
  18. package/dist/Message-DWQUt647.d.ts +45 -0
  19. package/dist/Persistence-BQkdKomV.d.ts +230 -0
  20. package/dist/Persistence-Dr70FEBh.d.cts +230 -0
  21. package/dist/StopReason-D4DthB1h.d.cts +39 -0
  22. package/dist/StopReason-D4DthB1h.d.ts +39 -0
  23. package/dist/SystemEvent-CPvvxdMQ.d.cts +159 -0
  24. package/dist/SystemEvent-CPvvxdMQ.d.ts +159 -0
  25. package/dist/ToolResultMessage-CDG2L7Zv.d.ts +332 -0
  26. package/dist/ToolResultMessage-CRKMSf5d.d.cts +332 -0
  27. package/dist/agent-internal.cjs +19 -0
  28. package/dist/agent-internal.cjs.map +1 -0
  29. package/dist/agent-internal.d.cts +52 -0
  30. package/dist/agent-internal.d.ts +52 -0
  31. package/dist/agent-internal.js +1 -0
  32. package/dist/agent-internal.js.map +1 -0
  33. package/dist/agent.cjs +70 -0
  34. package/dist/agent.cjs.map +1 -0
  35. package/dist/agent.d.cts +229 -0
  36. package/dist/agent.d.ts +229 -0
  37. package/dist/agent.js +41 -0
  38. package/dist/agent.js.map +1 -0
  39. package/dist/agentx.cjs +38 -0
  40. package/dist/agentx.cjs.map +1 -0
  41. package/dist/agentx.d.cts +311 -0
  42. package/dist/agentx.d.ts +311 -0
  43. package/dist/agentx.js +12 -0
  44. package/dist/agentx.js.map +1 -0
  45. package/dist/chunk-2QHAIM3V.js +1 -0
  46. package/dist/chunk-2QHAIM3V.js.map +1 -0
  47. package/dist/common.cjs +19 -0
  48. package/dist/common.cjs.map +1 -0
  49. package/dist/common.d.cts +43 -0
  50. package/dist/common.d.ts +43 -0
  51. package/dist/common.js +2 -0
  52. package/dist/common.js.map +1 -0
  53. package/dist/event.cjs +184 -0
  54. package/dist/event.cjs.map +1 -0
  55. package/dist/event.d.cts +769 -0
  56. package/dist/event.d.ts +769 -0
  57. package/dist/event.js +134 -0
  58. package/dist/event.js.map +1 -0
  59. package/dist/index-CjFNcCxR.d.cts +299 -0
  60. package/dist/index-usKuk41S.d.ts +299 -0
  61. package/dist/index.cjs +2 -185
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.d.cts +8 -5267
  64. package/dist/index.d.ts +8 -5267
  65. package/dist/index.js +1 -150
  66. package/dist/index.js.map +1 -1
  67. package/dist/network.cjs +19 -0
  68. package/dist/network.cjs.map +1 -0
  69. package/dist/network.d.cts +168 -0
  70. package/dist/network.d.ts +168 -0
  71. package/dist/network.js +1 -0
  72. package/dist/network.js.map +1 -0
  73. package/dist/runtime-internal.cjs +19 -0
  74. package/dist/runtime-internal.cjs.map +1 -0
  75. package/dist/runtime-internal.d.cts +943 -0
  76. package/dist/runtime-internal.d.ts +943 -0
  77. package/dist/runtime-internal.js +1 -0
  78. package/dist/runtime-internal.js.map +1 -0
  79. package/dist/runtime.cjs +19 -0
  80. package/dist/runtime.cjs.map +1 -0
  81. package/dist/runtime.d.cts +217 -0
  82. package/dist/runtime.d.ts +217 -0
  83. package/dist/runtime.js +1 -0
  84. package/dist/runtime.js.map +1 -0
  85. package/package.json +82 -10
  86. package/LICENSE +0 -21
@@ -0,0 +1,332 @@
1
+ import { S as SystemEvent, c as EventContext } from './SystemEvent-CPvvxdMQ.cjs';
2
+
3
+ /**
4
+ * Text Part
5
+ *
6
+ * Plain text content in a message.
7
+ */
8
+ interface TextPart {
9
+ /** Content type discriminator */
10
+ type: "text";
11
+ /** The text content (supports Markdown) */
12
+ text: string;
13
+ }
14
+
15
+ /**
16
+ * Image Part
17
+ *
18
+ * Image content in a message.
19
+ */
20
+ interface ImagePart {
21
+ /** Content type discriminator */
22
+ type: "image";
23
+ /** Image data (base64-encoded string or URL) */
24
+ data: string;
25
+ /** Image MIME type */
26
+ mediaType: "image/png" | "image/jpeg" | "image/gif" | "image/webp";
27
+ /** Optional image name/filename */
28
+ name?: string;
29
+ }
30
+
31
+ /**
32
+ * File Part
33
+ *
34
+ * File attachment in a message (PDF, documents, etc.).
35
+ */
36
+ interface FilePart {
37
+ /** Content type discriminator */
38
+ type: "file";
39
+ /** File data (base64-encoded string or URL) */
40
+ data: string;
41
+ /** File MIME type (IANA media type) */
42
+ mediaType: string;
43
+ /** Optional filename */
44
+ filename?: string;
45
+ }
46
+
47
+ /**
48
+ * User Message
49
+ *
50
+ * Message sent by the user.
51
+ * Can contain simple text or rich content (text, images, files).
52
+ */
53
+ interface UserMessage {
54
+ /** Unique identifier */
55
+ id: string;
56
+ /** Message role */
57
+ role: "user";
58
+ /** Message subtype for serialization */
59
+ subtype: "user";
60
+ /** Message content - can be simple string or array of parts */
61
+ content: string | Array<TextPart | ImagePart | FilePart>;
62
+ /** When this message was created (Unix timestamp in milliseconds) */
63
+ timestamp: number;
64
+ /** Parent message ID for threading (optional) */
65
+ parentId?: string;
66
+ }
67
+
68
+ /**
69
+ * Thinking Part
70
+ *
71
+ * AI's reasoning/thinking process (extended thinking).
72
+ */
73
+ interface ThinkingPart {
74
+ /** Content type discriminator */
75
+ type: "thinking";
76
+ /** The reasoning text */
77
+ reasoning: string;
78
+ /** Tokens used for thinking (optional) */
79
+ tokenCount?: number;
80
+ }
81
+
82
+ /**
83
+ * BaseAgentEvent - Base type for all Agent domain events
84
+ *
85
+ * All Agent events have:
86
+ * - source: "agent"
87
+ * - category: stream | state | message | turn
88
+ * - intent: "notification"
89
+ */
90
+
91
+ /**
92
+ * Agent event categories
93
+ */
94
+ type AgentEventCategory = "stream" | "state" | "message" | "turn";
95
+ /**
96
+ * BaseAgentEvent - Base interface for all Agent events
97
+ *
98
+ * Extends SystemEvent with fixed source and intent.
99
+ */
100
+ interface BaseAgentEvent<T extends string, D, C extends AgentEventCategory> extends SystemEvent<T, D, "agent", C, "notification"> {
101
+ /**
102
+ * Runtime context (optional, added by Presenter)
103
+ */
104
+ readonly context?: EventContext;
105
+ }
106
+
107
+ /**
108
+ * Agent Turn Events
109
+ *
110
+ * Turn-level events for analytics and billing.
111
+ * A turn = one user message + assistant response cycle.
112
+ * - source: "agent"
113
+ * - category: "turn"
114
+ * - intent: "notification"
115
+ */
116
+
117
+ /**
118
+ * Base type for turn events
119
+ */
120
+ interface AgentTurnEventBase<T extends string, D> extends BaseAgentEvent<T, D, "turn"> {
121
+ }
122
+ /**
123
+ * Token usage information
124
+ */
125
+ interface TokenUsage {
126
+ inputTokens: number;
127
+ outputTokens: number;
128
+ totalTokens?: number;
129
+ }
130
+ /**
131
+ * TurnRequestEvent - Turn started (user message received)
132
+ */
133
+ interface TurnRequestEvent extends AgentTurnEventBase<"turn_request", {
134
+ turnId: string;
135
+ messageId: string;
136
+ content: string;
137
+ timestamp: number;
138
+ }> {
139
+ }
140
+ /**
141
+ * TurnResponseEvent - Turn completed (assistant response finished)
142
+ */
143
+ interface TurnResponseEvent extends AgentTurnEventBase<"turn_response", {
144
+ turnId: string;
145
+ messageId: string;
146
+ duration: number;
147
+ usage?: TokenUsage;
148
+ model?: string;
149
+ stopReason?: string;
150
+ timestamp: number;
151
+ }> {
152
+ }
153
+ /**
154
+ * AgentTurnEvent - All turn events
155
+ */
156
+ type AgentTurnEvent = TurnRequestEvent | TurnResponseEvent;
157
+ /**
158
+ * AgentTurnEventType - String literal union
159
+ */
160
+ type AgentTurnEventType = AgentTurnEvent["type"];
161
+ /**
162
+ * Type guard: is this a turn event?
163
+ */
164
+ declare function isAgentTurnEvent(event: {
165
+ source?: string;
166
+ category?: string;
167
+ }): event is AgentTurnEvent;
168
+
169
+ /**
170
+ * Assistant Message
171
+ *
172
+ * Message generated by the AI assistant.
173
+ * Contains text, thinking process, or files.
174
+ *
175
+ * Note: Tool calls are separate - use ToolCallMessage for tool invocations.
176
+ */
177
+ interface AssistantMessage {
178
+ /** Unique identifier */
179
+ id: string;
180
+ /** Message role */
181
+ role: "assistant";
182
+ /** Message subtype for serialization */
183
+ subtype: "assistant";
184
+ /** Message content - can be simple string or array of parts */
185
+ content: string | Array<TextPart | ThinkingPart | FilePart>;
186
+ /** When this message was created (Unix timestamp in milliseconds) */
187
+ timestamp: number;
188
+ /** Parent message ID for threading (optional) */
189
+ parentId?: string;
190
+ /** Token usage for this AI response (optional) */
191
+ usage?: TokenUsage;
192
+ }
193
+
194
+ /**
195
+ * Tool Call Part
196
+ *
197
+ * AI's request to invoke a tool.
198
+ */
199
+ interface ToolCallPart {
200
+ /** Content type discriminator */
201
+ type: "tool-call";
202
+ /** Unique identifier for this tool call */
203
+ id: string;
204
+ /** Tool name */
205
+ name: string;
206
+ /** Tool input parameters */
207
+ input: Record<string, unknown>;
208
+ }
209
+
210
+ /**
211
+ * Tool Call Message
212
+ *
213
+ * Represents AI's request to invoke a tool.
214
+ * Emitted when tool call parameters are fully assembled.
215
+ *
216
+ * Subject: Assistant (AI decided to call a tool)
217
+ * Timing: At tool_use_content_block_stop
218
+ */
219
+
220
+ /**
221
+ * Tool Call Message
222
+ */
223
+ interface ToolCallMessage {
224
+ /** Unique message identifier */
225
+ id: string;
226
+ /** Message role - assistant initiates tool calls */
227
+ role: "assistant";
228
+ /** Message subtype for serialization */
229
+ subtype: "tool-call";
230
+ /** Tool call details */
231
+ toolCall: ToolCallPart;
232
+ /** When this message was created (Unix timestamp in milliseconds) */
233
+ timestamp: number;
234
+ /** Parent message ID (the assistant message that triggered this) */
235
+ parentId?: string;
236
+ }
237
+
238
+ /**
239
+ * Tool Result Output
240
+ *
241
+ * Enhanced tool result format supporting multiple output types.
242
+ * Based on Vercel AI SDK and industry best practices.
243
+ */
244
+ type ToolResultOutput =
245
+ /**
246
+ * Plain text result
247
+ */
248
+ {
249
+ type: "text";
250
+ value: string;
251
+ }
252
+ /**
253
+ * JSON result
254
+ */
255
+ | {
256
+ type: "json";
257
+ value: unknown;
258
+ }
259
+ /**
260
+ * Text error
261
+ */
262
+ | {
263
+ type: "error-text";
264
+ value: string;
265
+ }
266
+ /**
267
+ * JSON error
268
+ */
269
+ | {
270
+ type: "error-json";
271
+ value: unknown;
272
+ }
273
+ /**
274
+ * User denied tool execution
275
+ */
276
+ | {
277
+ type: "execution-denied";
278
+ reason?: string;
279
+ }
280
+ /**
281
+ * Rich content (multiple parts)
282
+ */
283
+ | {
284
+ type: "content";
285
+ value: Array<TextPart | ImagePart | FilePart>;
286
+ };
287
+
288
+ /**
289
+ * Tool Result Part
290
+ *
291
+ * Result of tool execution.
292
+ */
293
+ interface ToolResultPart {
294
+ /** Content type discriminator */
295
+ type: "tool-result";
296
+ /** Tool call ID this result corresponds to */
297
+ id: string;
298
+ /** Tool name */
299
+ name: string;
300
+ /** Tool execution output */
301
+ output: ToolResultOutput;
302
+ }
303
+
304
+ /**
305
+ * Tool Result Message
306
+ *
307
+ * Represents the result of tool execution.
308
+ * Emitted after tool execution completes.
309
+ *
310
+ * Subject: Tool (execution completed with result)
311
+ * Timing: At tool_result event
312
+ */
313
+
314
+ /**
315
+ * Tool Result Message
316
+ */
317
+ interface ToolResultMessage {
318
+ /** Unique message identifier */
319
+ id: string;
320
+ /** Message role - tool returns results */
321
+ role: "tool";
322
+ /** Message subtype for serialization */
323
+ subtype: "tool-result";
324
+ /** Tool result details */
325
+ toolResult: ToolResultPart;
326
+ /** ID of the corresponding tool call */
327
+ toolCallId: string;
328
+ /** When this message was created (Unix timestamp in milliseconds) */
329
+ timestamp: number;
330
+ }
331
+
332
+ export { type AssistantMessage as A, type BaseAgentEvent as B, type FilePart as F, type ImagePart as I, type ToolCallMessage as T, type UserMessage as U, type ToolResultMessage as a, type TextPart as b, type ThinkingPart as c, type ToolCallPart as d, type ToolResultPart as e, type ToolResultOutput as f, type TokenUsage as g, type AgentTurnEvent as h, type TurnRequestEvent as i, type TurnResponseEvent as j, type AgentEventCategory as k, type AgentTurnEventBase as l, type AgentTurnEventType as m, isAgentTurnEvent as n };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/agent/internal/index.ts
17
+ var internal_exports = {};
18
+ module.exports = __toCommonJS(internal_exports);
19
+ //# sourceMappingURL=agent-internal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/agent/internal/index.ts"],"sourcesContent":["/**\n * Internal Agent Types\n *\n * These are types used internally by the agent package implementation.\n * Users typically don't need to use these directly.\n *\n * Import from: @agentxjs/types/agent/internal\n */\n\n// Middleware & Interceptor\nexport type { AgentMiddleware, AgentMiddlewareNext } from \"./AgentMiddleware\";\nexport type { AgentInterceptor, AgentInterceptorNext } from \"./AgentInterceptor\";\n\n// Event handling (also re-exported from public for convenience)\nexport type { AgentOutputCallback, AgentEventHandler, Unsubscribe } from \"./AgentOutputCallback\";\n\n// State Machine\nexport type { AgentStateMachine } from \"./AgentStateMachine\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,52 @@
1
+ import { A as AgentState, a as AgentOutput, S as StateChangeHandler, U as Unsubscribe } from './Agent-BXUYGlWZ.cjs';
2
+ export { g as AgentEventHandler, d as AgentInterceptor, e as AgentInterceptorNext, b as AgentMiddleware, c as AgentMiddlewareNext, f as AgentOutputCallback } from './Agent-BXUYGlWZ.cjs';
3
+ import './ToolResultMessage-CRKMSf5d.cjs';
4
+ import './SystemEvent-CPvvxdMQ.cjs';
5
+ import './index-CjFNcCxR.cjs';
6
+ import './ErrorMessage-BoIh3MIO.cjs';
7
+
8
+ /**
9
+ * AgentStateMachine - State management interface
10
+ *
11
+ * Manages agent state transitions driven by StateEvents.
12
+ * Single source of truth for agent state.
13
+ *
14
+ * Flow:
15
+ * StreamEvent → MealyMachine → StateEvent → AgentStateMachine → state update
16
+ *
17
+ * Responsibilities:
18
+ * - Process StateEvents
19
+ * - Maintain current AgentState
20
+ * - Notify state change subscribers
21
+ */
22
+
23
+ /**
24
+ * AgentStateMachine interface
25
+ *
26
+ * Processes StateEvents to update internal agent state and notify subscribers.
27
+ */
28
+ interface AgentStateMachine {
29
+ /**
30
+ * Current agent state
31
+ */
32
+ readonly state: AgentState;
33
+ /**
34
+ * Process a StateEvent and update internal state
35
+ *
36
+ * @param event - StateEvent from MealyMachine
37
+ */
38
+ process(event: AgentOutput): void;
39
+ /**
40
+ * Subscribe to state changes
41
+ *
42
+ * @param handler - Callback receiving { prev, current } state change
43
+ * @returns Unsubscribe function
44
+ */
45
+ onStateChange(handler: StateChangeHandler): Unsubscribe;
46
+ /**
47
+ * Reset state machine (used on destroy)
48
+ */
49
+ reset(): void;
50
+ }
51
+
52
+ export { type AgentStateMachine, Unsubscribe };
@@ -0,0 +1,52 @@
1
+ import { A as AgentState, a as AgentOutput, S as StateChangeHandler, U as Unsubscribe } from './Agent-CaSxMF_E.js';
2
+ export { g as AgentEventHandler, d as AgentInterceptor, e as AgentInterceptorNext, b as AgentMiddleware, c as AgentMiddlewareNext, f as AgentOutputCallback } from './Agent-CaSxMF_E.js';
3
+ import './ToolResultMessage-CDG2L7Zv.js';
4
+ import './SystemEvent-CPvvxdMQ.js';
5
+ import './index-usKuk41S.js';
6
+ import './ErrorMessage-BoIh3MIO.js';
7
+
8
+ /**
9
+ * AgentStateMachine - State management interface
10
+ *
11
+ * Manages agent state transitions driven by StateEvents.
12
+ * Single source of truth for agent state.
13
+ *
14
+ * Flow:
15
+ * StreamEvent → MealyMachine → StateEvent → AgentStateMachine → state update
16
+ *
17
+ * Responsibilities:
18
+ * - Process StateEvents
19
+ * - Maintain current AgentState
20
+ * - Notify state change subscribers
21
+ */
22
+
23
+ /**
24
+ * AgentStateMachine interface
25
+ *
26
+ * Processes StateEvents to update internal agent state and notify subscribers.
27
+ */
28
+ interface AgentStateMachine {
29
+ /**
30
+ * Current agent state
31
+ */
32
+ readonly state: AgentState;
33
+ /**
34
+ * Process a StateEvent and update internal state
35
+ *
36
+ * @param event - StateEvent from MealyMachine
37
+ */
38
+ process(event: AgentOutput): void;
39
+ /**
40
+ * Subscribe to state changes
41
+ *
42
+ * @param handler - Callback receiving { prev, current } state change
43
+ * @returns Unsubscribe function
44
+ */
45
+ onStateChange(handler: StateChangeHandler): Unsubscribe;
46
+ /**
47
+ * Reset state machine (used on destroy)
48
+ */
49
+ reset(): void;
50
+ }
51
+
52
+ export { type AgentStateMachine, Unsubscribe };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=agent-internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/agent.cjs ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/agent/index.ts
21
+ var agent_exports = {};
22
+ __export(agent_exports, {
23
+ isMessageEvent: () => isMessageEvent,
24
+ isStateEvent: () => isStateEvent,
25
+ isTurnEvent: () => isTurnEvent
26
+ });
27
+ module.exports = __toCommonJS(agent_exports);
28
+
29
+ // src/agent/event/state/index.ts
30
+ function isStateEvent(event) {
31
+ const stateTypes = [
32
+ "conversation_queued",
33
+ "conversation_start",
34
+ "conversation_thinking",
35
+ "conversation_responding",
36
+ "conversation_end",
37
+ "conversation_interrupted",
38
+ "tool_planned",
39
+ "tool_executing",
40
+ "tool_completed",
41
+ "tool_failed",
42
+ "error_occurred"
43
+ ];
44
+ return stateTypes.includes(event.type);
45
+ }
46
+
47
+ // src/agent/event/message/index.ts
48
+ function isMessageEvent(event) {
49
+ const messageTypes = [
50
+ "user_message",
51
+ "assistant_message",
52
+ "tool_call_message",
53
+ "tool_result_message",
54
+ "error_message"
55
+ ];
56
+ return messageTypes.includes(event.type);
57
+ }
58
+
59
+ // src/agent/event/turn/index.ts
60
+ function isTurnEvent(event) {
61
+ const turnTypes = ["turn_request", "turn_response"];
62
+ return turnTypes.includes(event.type);
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ isMessageEvent,
67
+ isStateEvent,
68
+ isTurnEvent
69
+ });
70
+ //# sourceMappingURL=agent.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/agent/index.ts","../src/agent/event/state/index.ts","../src/agent/event/message/index.ts","../src/agent/event/turn/index.ts"],"sourcesContent":["/**\n * Agent Module - AgentEngine Domain Types\n *\n * AgentEngine is an independent event processing unit that can be tested\n * in isolation without Runtime dependencies (Container, Session, Bus).\n *\n * ## Two-Domain Architecture\n *\n * ```\n * ┌─────────────────────────────────────────────────────────────┐\n * │ Runtime Domain (@agentxjs/types/runtime) │\n * │ - SystemEvent (source, category, intent, context) │\n * │ - Container, Session, Sandbox, Environment │\n * │ - Agent (complete runtime entity with lifecycle) │\n * │ │\n * │ ┌─────────────────────────────────────────────────────┐ │\n * │ │ AgentEngine Domain (@agentxjs/types/agent) │ │\n * │ │ - AgentEvent (lightweight: type, timestamp, data) │ │\n * │ │ - AgentEngine (event processing unit) │ │\n * │ │ - Independent, testable in isolation │ │\n * │ │ │ │\n * │ │ Driver ←── AgentEngine ──→ Presenter │ │\n * │ │ ↑ │ ↓ │ │\n * │ └────│────────────│───────────────│───────────────────┘ │\n * │ │ │ │ │\n * │ DriveableEvent │ SystemEvent │\n * │ → StreamEvent │ (add context) │\n * └─────────────────────│───────────────────────────────────────┘\n * │\n * MealyMachine\n * (pure event processor)\n * ```\n *\n * ## Core Components\n *\n * - **AgentEngine**: Event processing unit (Driver + MealyMachine + Presenter)\n * - **AgentDriver**: Input adapter - converts external events to StreamEvent\n * - **AgentPresenter**: Output adapter - emits AgentOutput to external systems\n * - **MealyMachine**: Pure Mealy Machine that transforms StreamEvent → AgentOutput\n *\n * ## Event Layers (AgentOutput)\n *\n * 1. **StreamEvent**: Real-time incremental events (text_delta, tool_use_start...)\n * 2. **AgentStateEvent**: Events that affect AgentState (conversation_*, tool_*, error_*)\n * 3. **AgentMessageEvent**: Assembled messages (user_message, assistant_message...)\n * 4. **AgentTurnEvent**: Turn analytics (turn_request, turn_response)\n *\n * ## Message Types (Three-Party Model)\n *\n * - **User**: Human participant (UserMessage)\n * - **Assistant**: AI participant (AssistantMessage, ToolCallMessage)\n * - **Tool**: Computer/execution environment (ToolResultMessage)\n *\n * @packageDocumentation\n */\n\n// Core types\nexport type {\n AgentEngine,\n StateChange,\n StateChangeHandler,\n EventHandlerMap,\n ReactHandlerMap,\n} from \"./Agent\";\nexport type { AgentState } from \"./AgentState\";\nexport type { AgentOutput } from \"./AgentOutput\";\nexport type { AgentError, AgentErrorCategory } from \"./AgentError\";\nexport type { MessageQueue } from \"./MessageQueue\";\n\n// Driver & Presenter\nexport type { AgentDriver } from \"./AgentDriver\";\nexport type { AgentPresenter } from \"./AgentPresenter\";\n\n// Factory\nexport type { CreateAgentOptions } from \"./createAgent\";\nexport { createAgent } from \"./createAgent\";\n\n// Event handling types\nexport type {\n AgentOutputCallback,\n AgentEventHandler,\n Unsubscribe,\n} from \"./internal/AgentOutputCallback\";\n\n// Message types\nexport type {\n UserMessage,\n AssistantMessage,\n ToolCallMessage,\n ToolResultMessage,\n ErrorMessage,\n Message,\n MessageRole,\n MessageSubtype,\n ContentPart,\n TextPart,\n ThinkingPart,\n ImagePart,\n FilePart,\n ToolCallPart,\n ToolResultPart,\n ToolResultOutput,\n} from \"./message\";\n\n// Event types\nexport * from \"./event\";\n","/**\n * Engine State Events (Lightweight)\n *\n * Lightweight state events for AgentEngine internal use.\n * Derived from full AgentStateEvent in @agentxjs/types/event/agent.\n */\n\nimport type {\n AgentStateEvent as FullAgentStateEvent,\n ConversationQueuedEvent as FullConversationQueuedEvent,\n ConversationStartEvent as FullConversationStartEvent,\n ConversationThinkingEvent as FullConversationThinkingEvent,\n ConversationRespondingEvent as FullConversationRespondingEvent,\n ConversationEndEvent as FullConversationEndEvent,\n ConversationInterruptedEvent as FullConversationInterruptedEvent,\n ToolPlannedEvent as FullToolPlannedEvent,\n ToolExecutingEvent as FullToolExecutingEvent,\n ToolCompletedEvent as FullToolCompletedEvent,\n ToolFailedEvent as FullToolFailedEvent,\n ErrorOccurredEvent as FullErrorOccurredEvent,\n} from \"~/event/agent/state\";\nimport type { EngineEvent, ToEngineEvent, ToEngineEventUnion } from \"../EngineEvent\";\n\n// ============================================================================\n// Base Type (for backward compatibility)\n// ============================================================================\n\n/**\n * StateEvent - Base type for state events\n * @deprecated Use specific event types instead\n */\nexport interface StateEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {}\n\n// ============================================================================\n// Lightweight Event Types\n// ============================================================================\n\nexport type ConversationQueuedEvent = ToEngineEvent<FullConversationQueuedEvent>;\nexport type ConversationStartEvent = ToEngineEvent<FullConversationStartEvent>;\nexport type ConversationThinkingEvent = ToEngineEvent<FullConversationThinkingEvent>;\nexport type ConversationRespondingEvent = ToEngineEvent<FullConversationRespondingEvent>;\nexport type ConversationEndEvent = ToEngineEvent<FullConversationEndEvent>;\nexport type ConversationInterruptedEvent = ToEngineEvent<FullConversationInterruptedEvent>;\nexport type ToolPlannedEvent = ToEngineEvent<FullToolPlannedEvent>;\nexport type ToolExecutingEvent = ToEngineEvent<FullToolExecutingEvent>;\nexport type ToolCompletedEvent = ToEngineEvent<FullToolCompletedEvent>;\nexport type ToolFailedEvent = ToEngineEvent<FullToolFailedEvent>;\nexport type ErrorOccurredEvent = ToEngineEvent<FullErrorOccurredEvent>;\n\n/**\n * Alias for ErrorOccurredEvent (legacy compatibility)\n */\nexport type AgentErrorOccurredEvent = ErrorOccurredEvent;\n\n/**\n * AgentStateEvent - All lightweight state events\n */\nexport type AgentStateEvent = ToEngineEventUnion<FullAgentStateEvent>;\n\n/**\n * Type guard: is this a state event?\n */\nexport function isStateEvent(event: EngineEvent): event is AgentStateEvent {\n const stateTypes = [\n \"conversation_queued\",\n \"conversation_start\",\n \"conversation_thinking\",\n \"conversation_responding\",\n \"conversation_end\",\n \"conversation_interrupted\",\n \"tool_planned\",\n \"tool_executing\",\n \"tool_completed\",\n \"tool_failed\",\n \"error_occurred\",\n ];\n return stateTypes.includes(event.type);\n}\n","/**\n * Engine Message Events (Lightweight)\n *\n * Lightweight message events for AgentEngine internal use.\n * Derived from full AgentMessageEvent in @agentxjs/types/event/agent.\n */\n\nimport type {\n AgentMessageEvent as FullAgentMessageEvent,\n UserMessageEvent as FullUserMessageEvent,\n AssistantMessageEvent as FullAssistantMessageEvent,\n ToolCallMessageEvent as FullToolCallMessageEvent,\n ToolResultMessageEvent as FullToolResultMessageEvent,\n ErrorMessageEvent as FullErrorMessageEvent,\n} from \"~/event/agent/message\";\nimport type { EngineEvent, ToEngineEvent, ToEngineEventUnion } from \"../EngineEvent\";\n\n// Re-export parts (they're not events, just types)\nexport type { ContentPart, ToolCallPart, ToolResultPart } from \"../../message/parts\";\n\n// ============================================================================\n// Base Type (for backward compatibility)\n// ============================================================================\n\n/**\n * MessageEvent - Base type for message events\n * @deprecated Use specific event types instead\n */\nexport interface MessageEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {}\n\n// ============================================================================\n// Lightweight Event Types\n// ============================================================================\n\nexport type UserMessageEvent = ToEngineEvent<FullUserMessageEvent>;\nexport type AssistantMessageEvent = ToEngineEvent<FullAssistantMessageEvent>;\nexport type ToolCallMessageEvent = ToEngineEvent<FullToolCallMessageEvent>;\nexport type ToolResultMessageEvent = ToEngineEvent<FullToolResultMessageEvent>;\nexport type ErrorMessageEvent = ToEngineEvent<FullErrorMessageEvent>;\n\n/**\n * AgentMessageEvent - All lightweight message events\n */\nexport type AgentMessageEvent = ToEngineEventUnion<FullAgentMessageEvent>;\n\n/**\n * Type guard: is this a message event?\n */\nexport function isMessageEvent(event: EngineEvent): event is AgentMessageEvent {\n const messageTypes = [\n \"user_message\",\n \"assistant_message\",\n \"tool_call_message\",\n \"tool_result_message\",\n \"error_message\",\n ];\n return messageTypes.includes(event.type);\n}\n","/**\n * Engine Turn Events (Lightweight)\n *\n * Lightweight turn events for AgentEngine internal use.\n * Derived from full AgentTurnEvent in @agentxjs/types/event/agent.\n */\n\nimport type {\n AgentTurnEvent as FullAgentTurnEvent,\n TurnRequestEvent as FullTurnRequestEvent,\n TurnResponseEvent as FullTurnResponseEvent,\n TokenUsage,\n} from \"~/event/agent/turn\";\nimport type { EngineEvent, ToEngineEvent, ToEngineEventUnion } from \"../EngineEvent\";\n\n// Re-export TokenUsage (it's not an event, just a type)\nexport type { TokenUsage };\n\n// ============================================================================\n// Base Type (for backward compatibility)\n// ============================================================================\n\n/**\n * TurnEvent - Base type for turn events\n * @deprecated Use specific event types instead\n */\nexport interface TurnEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {}\n\n// ============================================================================\n// Lightweight Event Types\n// ============================================================================\n\nexport type TurnRequestEvent = ToEngineEvent<FullTurnRequestEvent>;\nexport type TurnResponseEvent = ToEngineEvent<FullTurnResponseEvent>;\n\n/**\n * AgentTurnEvent - All lightweight turn events\n */\nexport type AgentTurnEvent = ToEngineEventUnion<FullAgentTurnEvent>;\n\n/**\n * Type guard: is this a turn event?\n */\nexport function isTurnEvent(event: EngineEvent): event is AgentTurnEvent {\n const turnTypes = [\"turn_request\", \"turn_response\"];\n return turnTypes.includes(event.type);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC8DO,SAAS,aAAa,OAA8C;AACzE,QAAM,aAAa;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,WAAW,SAAS,MAAM,IAAI;AACvC;;;AC7BO,SAAS,eAAe,OAAgD;AAC7E,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,SAAO,aAAa,SAAS,MAAM,IAAI;AACzC;;;ACdO,SAAS,YAAY,OAA6C;AACvE,QAAM,YAAY,CAAC,gBAAgB,eAAe;AAClD,SAAO,UAAU,SAAS,MAAM,IAAI;AACtC;","names":[]}