@agentxjs/core 1.9.3-dev → 1.9.6-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.
Files changed (80) hide show
  1. package/dist/Processor-DT0N1qI6.d.ts +64 -0
  2. package/dist/agent/engine/internal/index.d.ts +223 -0
  3. package/dist/agent/engine/internal/index.js +24 -0
  4. package/dist/agent/engine/internal/index.js.map +1 -0
  5. package/dist/agent/engine/mealy/index.d.ts +157 -0
  6. package/dist/agent/engine/mealy/index.js +26 -0
  7. package/dist/agent/engine/mealy/index.js.map +1 -0
  8. package/dist/agent/index.d.ts +244 -0
  9. package/dist/agent/index.js +66 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/agent/types/index.d.ts +322 -0
  12. package/dist/agent/types/index.js +12 -0
  13. package/dist/agent/types/index.js.map +1 -0
  14. package/dist/base-m40r3Qgu.d.ts +157 -0
  15. package/dist/bus-uF1DM2ox.d.ts +906 -0
  16. package/dist/chunk-7D4SUZUM.js +38 -0
  17. package/dist/chunk-7D4SUZUM.js.map +1 -0
  18. package/dist/chunk-7ZDX3O6I.js +173 -0
  19. package/dist/chunk-7ZDX3O6I.js.map +1 -0
  20. package/dist/chunk-AT5P47YA.js +543 -0
  21. package/dist/chunk-AT5P47YA.js.map +1 -0
  22. package/dist/chunk-E5FPOAPO.js +123 -0
  23. package/dist/chunk-E5FPOAPO.js.map +1 -0
  24. package/dist/chunk-EKHT54KN.js +272 -0
  25. package/dist/chunk-EKHT54KN.js.map +1 -0
  26. package/dist/chunk-I7GYR3MN.js +502 -0
  27. package/dist/chunk-I7GYR3MN.js.map +1 -0
  28. package/dist/chunk-K6WXQ2RW.js +38 -0
  29. package/dist/chunk-K6WXQ2RW.js.map +1 -0
  30. package/dist/chunk-RL3JRNXM.js +3 -0
  31. package/dist/chunk-RL3JRNXM.js.map +1 -0
  32. package/dist/combinators-nEa5dD0T.d.ts +271 -0
  33. package/dist/common/index.d.ts +1 -0
  34. package/dist/common/index.js +2 -0
  35. package/dist/common/index.js.map +1 -0
  36. package/dist/common/logger/index.d.ts +163 -0
  37. package/dist/common/logger/index.js +184 -0
  38. package/dist/common/logger/index.js.map +1 -0
  39. package/dist/container/index.d.ts +110 -0
  40. package/dist/container/index.js +127 -0
  41. package/dist/container/index.js.map +1 -0
  42. package/dist/driver/index.d.ts +266 -0
  43. package/dist/driver/index.js +1 -0
  44. package/dist/driver/index.js.map +1 -0
  45. package/dist/event/index.d.ts +55 -0
  46. package/dist/event/index.js +60 -0
  47. package/dist/event/index.js.map +1 -0
  48. package/dist/event/types/index.d.ts +1149 -0
  49. package/dist/event/types/index.js +56 -0
  50. package/dist/event/types/index.js.map +1 -0
  51. package/dist/event-CDuTzs__.d.ts +296 -0
  52. package/dist/image/index.d.ts +112 -0
  53. package/dist/image/index.js +151 -0
  54. package/dist/image/index.js.map +1 -0
  55. package/dist/index.d.ts +8 -0
  56. package/dist/index.js +67 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/message-BMrMm1pq.d.ts +305 -0
  59. package/dist/mq/index.d.ts +165 -0
  60. package/dist/mq/index.js +37 -0
  61. package/dist/mq/index.js.map +1 -0
  62. package/dist/network/index.d.ts +567 -0
  63. package/dist/network/index.js +435 -0
  64. package/dist/network/index.js.map +1 -0
  65. package/dist/persistence/index.d.ts +155 -0
  66. package/dist/persistence/index.js +1 -0
  67. package/dist/persistence/index.js.map +1 -0
  68. package/dist/runtime/index.d.ts +240 -0
  69. package/dist/runtime/index.js +347 -0
  70. package/dist/runtime/index.js.map +1 -0
  71. package/dist/session/index.d.ts +92 -0
  72. package/dist/session/index.js +56 -0
  73. package/dist/session/index.js.map +1 -0
  74. package/dist/workspace/index.d.ts +111 -0
  75. package/dist/workspace/index.js +1 -0
  76. package/dist/workspace/index.js.map +1 -0
  77. package/dist/wrapper-Y3UTVU2E.js +3635 -0
  78. package/dist/wrapper-Y3UTVU2E.js.map +1 -0
  79. package/package.json +74 -14
  80. package/tsconfig.json +0 -10
@@ -0,0 +1,56 @@
1
+ import {
2
+ hasIntent,
3
+ isAgentEvent,
4
+ isAgentMessageEvent,
5
+ isAgentStateEvent,
6
+ isAgentStreamEvent,
7
+ isAgentTurnEvent,
8
+ isCommandEvent,
9
+ isCommandRequest,
10
+ isCommandResponse,
11
+ isConnectionEvent,
12
+ isContainerEvent,
13
+ isContainerLifecycleEvent,
14
+ isDriveableEvent,
15
+ isFromSource,
16
+ isMCPEvent,
17
+ isNotification,
18
+ isRequest,
19
+ isResult,
20
+ isSandboxEvent,
21
+ isSessionActionEvent,
22
+ isSessionEvent,
23
+ isSessionLifecycleEvent,
24
+ isSessionPersistEvent,
25
+ isStopReason,
26
+ isWorkdirEvent
27
+ } from "../../chunk-E5FPOAPO.js";
28
+ import "../../chunk-7D4SUZUM.js";
29
+ export {
30
+ hasIntent,
31
+ isAgentEvent,
32
+ isAgentMessageEvent,
33
+ isAgentStateEvent,
34
+ isAgentStreamEvent,
35
+ isAgentTurnEvent,
36
+ isCommandEvent,
37
+ isCommandRequest,
38
+ isCommandResponse,
39
+ isConnectionEvent,
40
+ isContainerEvent,
41
+ isContainerLifecycleEvent,
42
+ isDriveableEvent,
43
+ isFromSource,
44
+ isMCPEvent,
45
+ isNotification,
46
+ isRequest,
47
+ isResult,
48
+ isSandboxEvent,
49
+ isSessionActionEvent,
50
+ isSessionEvent,
51
+ isSessionLifecycleEvent,
52
+ isSessionPersistEvent,
53
+ isStopReason,
54
+ isWorkdirEvent
55
+ };
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,296 @@
1
+ import { U as UserMessage, A as AssistantMessage, T as ToolCallMessage, a as ToolResultMessage, E as ErrorMessage, b as TokenUsage } from './message-BMrMm1pq.js';
2
+
3
+ /**
4
+ * Event Types - Stream, State, Message, and Turn Events
5
+ *
6
+ * This file defines all event types for the AgentEngine:
7
+ * - Base EngineEvent type
8
+ * - Stream Events: message_start, text_delta, tool_use_*, etc.
9
+ * - State Events: conversation_*, tool_*, error_*
10
+ * - Message Events: user_message, assistant_message, etc.
11
+ * - Turn Events: turn_request, turn_response
12
+ * - AgentOutput: Union of all output events
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+
17
+ /**
18
+ * EngineEvent - Lightweight event base for AgentEngine domain
19
+ *
20
+ * EngineEvent is the simplified event structure used inside AgentEngine.
21
+ * It only contains: type, timestamp, data
22
+ *
23
+ * This is a self-contained type without external dependencies.
24
+ * All specific event types (StreamEvent, StateEvent, etc.) extend this base.
25
+ */
26
+ interface EngineEvent<T extends string = string, D = unknown> {
27
+ /**
28
+ * Event type identifier (e.g., "text_delta", "assistant_message")
29
+ */
30
+ readonly type: T;
31
+ /**
32
+ * Event timestamp (Unix milliseconds)
33
+ */
34
+ readonly timestamp: number;
35
+ /**
36
+ * Event payload data
37
+ */
38
+ readonly data: D;
39
+ }
40
+ /**
41
+ * @deprecated Use EngineEvent instead
42
+ */
43
+ type AgentEvent<T extends string = string, D = unknown> = EngineEvent<T, D>;
44
+ /**
45
+ * AgentState
46
+ *
47
+ * Agent conversation states for fine-grained monitoring.
48
+ *
49
+ * State transitions:
50
+ * ```
51
+ * idle -> thinking -> responding -> idle
52
+ * |
53
+ * planning_tool -> awaiting_tool_result
54
+ * |
55
+ * thinking -> responding -> idle
56
+ *
57
+ * Any state can transition to error:
58
+ * thinking/responding/planning_tool/awaiting_tool_result -> error -> idle
59
+ * ```
60
+ */
61
+ type AgentState = "idle" | "thinking" | "responding" | "planning_tool" | "awaiting_tool_result" | "error";
62
+ /**
63
+ * Error category
64
+ */
65
+ type AgentErrorCategory = "network" | "validation" | "system" | "business";
66
+ /**
67
+ * AgentError - Standardized error structure
68
+ */
69
+ interface AgentError {
70
+ /**
71
+ * Error category
72
+ */
73
+ category: AgentErrorCategory;
74
+ /**
75
+ * Error code (e.g., "NETWORK_TIMEOUT", "INVALID_INPUT")
76
+ */
77
+ code: string;
78
+ /**
79
+ * Human-readable error message
80
+ */
81
+ message: string;
82
+ /**
83
+ * Whether the error is recoverable
84
+ */
85
+ recoverable: boolean;
86
+ /**
87
+ * Original error (if any)
88
+ */
89
+ cause?: Error;
90
+ /**
91
+ * Additional context
92
+ */
93
+ context?: Record<string, unknown>;
94
+ }
95
+ /**
96
+ * Stop reason for message completion
97
+ */
98
+ type StopReason = "end_turn" | "max_tokens" | "stop_sequence" | "tool_use";
99
+ interface MessageStartData {
100
+ messageId: string;
101
+ model: string;
102
+ }
103
+ interface MessageDeltaData {
104
+ usage?: {
105
+ inputTokens: number;
106
+ outputTokens: number;
107
+ };
108
+ }
109
+ interface MessageStopData {
110
+ stopReason?: StopReason;
111
+ }
112
+ interface TextDeltaData {
113
+ text: string;
114
+ }
115
+ interface ToolUseStartData {
116
+ toolCallId: string;
117
+ toolName: string;
118
+ }
119
+ interface InputJsonDeltaData {
120
+ partialJson: string;
121
+ }
122
+ interface ToolUseStopData {
123
+ toolCallId: string;
124
+ toolName: string;
125
+ input: Record<string, unknown>;
126
+ }
127
+ interface ToolResultData {
128
+ toolCallId: string;
129
+ result: unknown;
130
+ isError?: boolean;
131
+ }
132
+ interface ErrorReceivedData {
133
+ message: string;
134
+ errorCode?: string;
135
+ }
136
+ type MessageStartEvent = EngineEvent<"message_start", MessageStartData>;
137
+ type MessageDeltaEvent = EngineEvent<"message_delta", MessageDeltaData>;
138
+ type MessageStopEvent = EngineEvent<"message_stop", MessageStopData>;
139
+ type TextDeltaEvent = EngineEvent<"text_delta", TextDeltaData>;
140
+ type ToolUseStartEvent = EngineEvent<"tool_use_start", ToolUseStartData>;
141
+ type InputJsonDeltaEvent = EngineEvent<"input_json_delta", InputJsonDeltaData>;
142
+ type ToolUseStopEvent = EngineEvent<"tool_use_stop", ToolUseStopData>;
143
+ type ToolResultEvent = EngineEvent<"tool_result", ToolResultData>;
144
+ type ErrorReceivedEvent = EngineEvent<"error_received", ErrorReceivedData>;
145
+ /**
146
+ * StreamEvent - All lightweight stream events
147
+ */
148
+ type StreamEvent = MessageStartEvent | MessageDeltaEvent | MessageStopEvent | TextDeltaEvent | ToolUseStartEvent | InputJsonDeltaEvent | ToolUseStopEvent | ToolResultEvent | ErrorReceivedEvent;
149
+ /**
150
+ * StreamEventType - String literal union
151
+ */
152
+ type StreamEventType = StreamEvent["type"];
153
+ interface ConversationQueuedData {
154
+ messageId: string;
155
+ }
156
+ interface ConversationStartData {
157
+ messageId: string;
158
+ }
159
+ interface ConversationThinkingData {
160
+ }
161
+ interface ConversationRespondingData {
162
+ }
163
+ interface ConversationEndData {
164
+ reason: "completed" | "interrupted" | "error";
165
+ }
166
+ interface ConversationInterruptedData {
167
+ reason: string;
168
+ }
169
+ interface ToolPlannedData {
170
+ toolId: string;
171
+ toolName: string;
172
+ }
173
+ interface ToolExecutingData {
174
+ toolId: string;
175
+ toolName: string;
176
+ input: Record<string, unknown>;
177
+ }
178
+ interface ToolCompletedData {
179
+ toolId: string;
180
+ toolName: string;
181
+ result: unknown;
182
+ }
183
+ interface ToolFailedData {
184
+ toolId: string;
185
+ toolName: string;
186
+ error: string;
187
+ }
188
+ interface ErrorOccurredData {
189
+ code: string;
190
+ message: string;
191
+ recoverable: boolean;
192
+ category?: string;
193
+ }
194
+ /**
195
+ * StateEvent - Base type for state events
196
+ * @deprecated Use specific event types instead
197
+ */
198
+ interface StateEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {
199
+ }
200
+ type ConversationQueuedEvent = EngineEvent<"conversation_queued", ConversationQueuedData>;
201
+ type ConversationStartEvent = EngineEvent<"conversation_start", ConversationStartData>;
202
+ type ConversationThinkingEvent = EngineEvent<"conversation_thinking", ConversationThinkingData>;
203
+ type ConversationRespondingEvent = EngineEvent<"conversation_responding", ConversationRespondingData>;
204
+ type ConversationEndEvent = EngineEvent<"conversation_end", ConversationEndData>;
205
+ type ConversationInterruptedEvent = EngineEvent<"conversation_interrupted", ConversationInterruptedData>;
206
+ type ToolPlannedEvent = EngineEvent<"tool_planned", ToolPlannedData>;
207
+ type ToolExecutingEvent = EngineEvent<"tool_executing", ToolExecutingData>;
208
+ type ToolCompletedEvent = EngineEvent<"tool_completed", ToolCompletedData>;
209
+ type ToolFailedEvent = EngineEvent<"tool_failed", ToolFailedData>;
210
+ type ErrorOccurredEvent = EngineEvent<"error_occurred", ErrorOccurredData>;
211
+ /**
212
+ * Alias for ErrorOccurredEvent (legacy compatibility)
213
+ */
214
+ type AgentErrorOccurredEvent = ErrorOccurredEvent;
215
+ /**
216
+ * AgentStateEvent - All lightweight state events
217
+ */
218
+ type AgentStateEvent = ConversationQueuedEvent | ConversationStartEvent | ConversationThinkingEvent | ConversationRespondingEvent | ConversationEndEvent | ConversationInterruptedEvent | ToolPlannedEvent | ToolExecutingEvent | ToolCompletedEvent | ToolFailedEvent | ErrorOccurredEvent;
219
+ /**
220
+ * Type guard: is this a state event?
221
+ */
222
+ declare function isStateEvent(event: EngineEvent): event is AgentStateEvent;
223
+ /**
224
+ * MessageEvent - Base type for message events
225
+ * @deprecated Use specific event types instead
226
+ */
227
+ interface MessageEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {
228
+ }
229
+ type UserMessageEvent = EngineEvent<"user_message", UserMessage>;
230
+ type AssistantMessageEvent = EngineEvent<"assistant_message", AssistantMessage>;
231
+ type ToolCallMessageEvent = EngineEvent<"tool_call_message", ToolCallMessage>;
232
+ type ToolResultMessageEvent = EngineEvent<"tool_result_message", ToolResultMessage>;
233
+ type ErrorMessageEvent = EngineEvent<"error_message", ErrorMessage>;
234
+ /**
235
+ * AgentMessageEvent - All lightweight message events
236
+ */
237
+ type AgentMessageEvent = UserMessageEvent | AssistantMessageEvent | ToolCallMessageEvent | ToolResultMessageEvent | ErrorMessageEvent;
238
+ /**
239
+ * Type guard: is this a message event?
240
+ */
241
+ declare function isMessageEvent(event: EngineEvent): event is AgentMessageEvent;
242
+ interface TurnRequestData {
243
+ turnId: string;
244
+ messageId: string;
245
+ content: string;
246
+ timestamp: number;
247
+ }
248
+ interface TurnResponseData {
249
+ turnId: string;
250
+ messageId: string;
251
+ duration: number;
252
+ usage?: TokenUsage;
253
+ model?: string;
254
+ stopReason?: string;
255
+ timestamp: number;
256
+ }
257
+ /**
258
+ * TurnEvent - Base type for turn events
259
+ * @deprecated Use specific event types instead
260
+ */
261
+ interface TurnEvent<T extends string = string, D = unknown> extends EngineEvent<T, D> {
262
+ }
263
+ type TurnRequestEvent = EngineEvent<"turn_request", TurnRequestData>;
264
+ type TurnResponseEvent = EngineEvent<"turn_response", TurnResponseData>;
265
+ /**
266
+ * AgentTurnEvent - All lightweight turn events
267
+ */
268
+ type AgentTurnEvent = TurnRequestEvent | TurnResponseEvent;
269
+ /**
270
+ * Type guard: is this a turn event?
271
+ */
272
+ declare function isTurnEvent(event: EngineEvent): event is AgentTurnEvent;
273
+ /**
274
+ * AgentOutput - Union of all possible agent output events
275
+ *
276
+ * Includes all event layers:
277
+ * - Stream: Real-time streaming events from Driver
278
+ * - State: State machine transitions
279
+ * - Message: Assembled messages
280
+ * - Turn: Turn analytics
281
+ */
282
+ type AgentOutput = StreamEvent | AgentStateEvent | AgentMessageEvent | AgentTurnEvent;
283
+ /**
284
+ * Unsubscribe function returned by on()
285
+ */
286
+ type Unsubscribe = () => void;
287
+ /**
288
+ * Agent output event callback function type
289
+ */
290
+ type AgentOutputCallback<T extends AgentOutput = AgentOutput> = (event: T) => void;
291
+ /**
292
+ * @deprecated Use AgentOutputCallback instead
293
+ */
294
+ type AgentEventHandler<T extends AgentOutput = AgentOutput> = AgentOutputCallback<T>;
295
+
296
+ export { type AgentStateEvent as $, type AgentOutput as A, type ConversationInterruptedData as B, type ConversationQueuedData as C, type ToolPlannedData as D, type EngineEvent as E, type ToolExecutingData as F, type ToolCompletedData as G, type ToolFailedData as H, type InputJsonDeltaData as I, type ErrorOccurredData as J, type StateEvent as K, type ConversationQueuedEvent as L, type MessageStartData as M, type ConversationStartEvent as N, type ConversationThinkingEvent as O, type ConversationRespondingEvent as P, type ConversationEndEvent as Q, type ConversationInterruptedEvent as R, type StreamEvent as S, type TextDeltaData as T, type Unsubscribe as U, type ToolPlannedEvent as V, type ToolExecutingEvent as W, type ToolCompletedEvent as X, type ToolFailedEvent as Y, type ErrorOccurredEvent as Z, type AgentErrorOccurredEvent as _, type AgentState as a, type MessageEvent as a0, type UserMessageEvent as a1, type AssistantMessageEvent as a2, type ToolCallMessageEvent as a3, type ToolResultMessageEvent as a4, type ErrorMessageEvent as a5, type AgentMessageEvent as a6, type TurnRequestData as a7, type TurnResponseData as a8, type TurnEvent as a9, type TurnRequestEvent as aa, type TurnResponseEvent as ab, type AgentTurnEvent as ac, type AgentEventHandler as ad, isStateEvent as ae, isMessageEvent as af, isTurnEvent as ag, type AgentOutputCallback as b, type AgentEvent as c, type AgentErrorCategory as d, type AgentError as e, type StopReason as f, type MessageDeltaData as g, type MessageStopData as h, type ToolUseStartData as i, type ToolUseStopData as j, type ToolResultData as k, type ErrorReceivedData as l, type MessageStartEvent as m, type MessageDeltaEvent as n, type MessageStopEvent as o, type TextDeltaEvent as p, type ToolUseStartEvent as q, type InputJsonDeltaEvent as r, type ToolUseStopEvent as s, type ToolResultEvent as t, type ErrorReceivedEvent as u, type StreamEventType as v, type ConversationStartData as w, type ConversationThinkingData as x, type ConversationRespondingData as y, type ConversationEndData as z };
@@ -0,0 +1,112 @@
1
+ import { ImageRecord, ImageRepository, SessionRepository } from '../persistence/index.js';
2
+ export { ImageMetadata } from '../persistence/index.js';
3
+ import { McpServerConfig } from '../driver/index.js';
4
+ import '../message-BMrMm1pq.js';
5
+
6
+ /**
7
+ * Image - Persistent conversation entity
8
+ */
9
+ interface Image {
10
+ readonly imageId: string;
11
+ readonly containerId: string;
12
+ readonly sessionId: string;
13
+ readonly name: string;
14
+ readonly description: string | undefined;
15
+ readonly systemPrompt: string | undefined;
16
+ readonly mcpServers: Record<string, McpServerConfig> | undefined;
17
+ readonly createdAt: number;
18
+ readonly updatedAt: number;
19
+ /**
20
+ * Update image metadata (name, description)
21
+ */
22
+ update(updates: {
23
+ name?: string;
24
+ description?: string;
25
+ }): Promise<Image>;
26
+ /**
27
+ * Delete this image and its session
28
+ */
29
+ delete(): Promise<void>;
30
+ /**
31
+ * Get the underlying record
32
+ */
33
+ toRecord(): ImageRecord;
34
+ }
35
+ /**
36
+ * Context needed by Image operations
37
+ */
38
+ interface ImageContext {
39
+ imageRepository: ImageRepository;
40
+ sessionRepository: SessionRepository;
41
+ }
42
+ /**
43
+ * Configuration for creating a new Image
44
+ */
45
+ interface ImageCreateConfig {
46
+ containerId: string;
47
+ name?: string;
48
+ description?: string;
49
+ systemPrompt?: string;
50
+ mcpServers?: Record<string, McpServerConfig>;
51
+ }
52
+
53
+ /**
54
+ * ImageImpl - Image implementation
55
+ */
56
+ declare class ImageImpl implements Image {
57
+ private readonly record;
58
+ private readonly context;
59
+ private constructor();
60
+ get imageId(): string;
61
+ get containerId(): string;
62
+ get sessionId(): string;
63
+ get name(): string;
64
+ get description(): string | undefined;
65
+ get systemPrompt(): string | undefined;
66
+ get mcpServers(): Record<string, McpServerConfig> | undefined;
67
+ get createdAt(): number;
68
+ get updatedAt(): number;
69
+ /**
70
+ * Create a new image (conversation)
71
+ */
72
+ static create(config: ImageCreateConfig, context: ImageContext): Promise<ImageImpl>;
73
+ /**
74
+ * Load an existing image from storage
75
+ */
76
+ static load(imageId: string, context: ImageContext): Promise<ImageImpl | null>;
77
+ /**
78
+ * List all images in a container
79
+ */
80
+ static listByContainer(containerId: string, context: ImageContext): Promise<ImageRecord[]>;
81
+ /**
82
+ * List all images
83
+ */
84
+ static listAll(context: ImageContext): Promise<ImageRecord[]>;
85
+ /**
86
+ * Update image metadata
87
+ */
88
+ update(updates: {
89
+ name?: string;
90
+ description?: string;
91
+ }): Promise<Image>;
92
+ /**
93
+ * Delete this image and its session
94
+ */
95
+ delete(): Promise<void>;
96
+ /**
97
+ * Get the underlying record
98
+ */
99
+ toRecord(): ImageRecord;
100
+ private static generateImageId;
101
+ private static generateSessionId;
102
+ }
103
+ /**
104
+ * Create a new Image
105
+ */
106
+ declare function createImage(config: ImageCreateConfig, context: ImageContext): Promise<Image>;
107
+ /**
108
+ * Load an existing Image
109
+ */
110
+ declare function loadImage(imageId: string, context: ImageContext): Promise<Image | null>;
111
+
112
+ export { type Image, type ImageContext, type ImageCreateConfig, ImageImpl, ImageRecord, ImageRepository, createImage, loadImage };
@@ -0,0 +1,151 @@
1
+ import "../chunk-7D4SUZUM.js";
2
+
3
+ // src/image/Image.ts
4
+ import { createLogger } from "commonxjs/logger";
5
+ var logger = createLogger("image/Image");
6
+ var ImageImpl = class _ImageImpl {
7
+ constructor(record, context) {
8
+ this.record = record;
9
+ this.context = context;
10
+ }
11
+ // ==================== Getters ====================
12
+ get imageId() {
13
+ return this.record.imageId;
14
+ }
15
+ get containerId() {
16
+ return this.record.containerId;
17
+ }
18
+ get sessionId() {
19
+ return this.record.sessionId;
20
+ }
21
+ get name() {
22
+ return this.record.name;
23
+ }
24
+ get description() {
25
+ return this.record.description;
26
+ }
27
+ get systemPrompt() {
28
+ return this.record.systemPrompt;
29
+ }
30
+ get mcpServers() {
31
+ return this.record.mcpServers;
32
+ }
33
+ get createdAt() {
34
+ return this.record.createdAt;
35
+ }
36
+ get updatedAt() {
37
+ return this.record.updatedAt;
38
+ }
39
+ // ==================== Static Factory Methods ====================
40
+ /**
41
+ * Create a new image (conversation)
42
+ */
43
+ static async create(config, context) {
44
+ const now = Date.now();
45
+ const imageId = _ImageImpl.generateImageId();
46
+ const sessionId = _ImageImpl.generateSessionId();
47
+ const record = {
48
+ imageId,
49
+ containerId: config.containerId,
50
+ sessionId,
51
+ name: config.name ?? "New Conversation",
52
+ description: config.description,
53
+ systemPrompt: config.systemPrompt,
54
+ mcpServers: config.mcpServers,
55
+ createdAt: now,
56
+ updatedAt: now
57
+ };
58
+ await context.imageRepository.saveImage(record);
59
+ await context.sessionRepository.saveSession({
60
+ sessionId,
61
+ imageId,
62
+ containerId: config.containerId,
63
+ createdAt: now,
64
+ updatedAt: now
65
+ });
66
+ logger.info("Image created", {
67
+ imageId,
68
+ sessionId,
69
+ containerId: config.containerId,
70
+ name: record.name
71
+ });
72
+ return new _ImageImpl(record, context);
73
+ }
74
+ /**
75
+ * Load an existing image from storage
76
+ */
77
+ static async load(imageId, context) {
78
+ const record = await context.imageRepository.findImageById(imageId);
79
+ if (!record) {
80
+ logger.debug("Image not found", { imageId });
81
+ return null;
82
+ }
83
+ logger.debug("Image loaded", { imageId, name: record.name });
84
+ return new _ImageImpl(record, context);
85
+ }
86
+ /**
87
+ * List all images in a container
88
+ */
89
+ static async listByContainer(containerId, context) {
90
+ return context.imageRepository.findImagesByContainerId(containerId);
91
+ }
92
+ /**
93
+ * List all images
94
+ */
95
+ static async listAll(context) {
96
+ return context.imageRepository.findAllImages();
97
+ }
98
+ // ==================== Instance Methods ====================
99
+ /**
100
+ * Update image metadata
101
+ */
102
+ async update(updates) {
103
+ const now = Date.now();
104
+ const updatedRecord = {
105
+ ...this.record,
106
+ name: updates.name ?? this.record.name,
107
+ description: updates.description ?? this.record.description,
108
+ updatedAt: now
109
+ };
110
+ await this.context.imageRepository.saveImage(updatedRecord);
111
+ logger.info("Image updated", { imageId: this.imageId, updates });
112
+ return new _ImageImpl(updatedRecord, this.context);
113
+ }
114
+ /**
115
+ * Delete this image and its session
116
+ */
117
+ async delete() {
118
+ await this.context.sessionRepository.deleteSession(this.sessionId);
119
+ await this.context.imageRepository.deleteImage(this.imageId);
120
+ logger.info("Image deleted", { imageId: this.imageId, sessionId: this.sessionId });
121
+ }
122
+ /**
123
+ * Get the underlying record
124
+ */
125
+ toRecord() {
126
+ return { ...this.record };
127
+ }
128
+ // ==================== Private Helpers ====================
129
+ static generateImageId() {
130
+ const timestamp = Date.now().toString(36);
131
+ const random = Math.random().toString(36).substring(2, 8);
132
+ return `img_${timestamp}_${random}`;
133
+ }
134
+ static generateSessionId() {
135
+ const timestamp = Date.now().toString(36);
136
+ const random = Math.random().toString(36).substring(2, 8);
137
+ return `sess_${timestamp}_${random}`;
138
+ }
139
+ };
140
+ async function createImage(config, context) {
141
+ return ImageImpl.create(config, context);
142
+ }
143
+ async function loadImage(imageId, context) {
144
+ return ImageImpl.load(imageId, context);
145
+ }
146
+ export {
147
+ ImageImpl,
148
+ createImage,
149
+ loadImage
150
+ };
151
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/image/Image.ts"],"sourcesContent":["/**\n * Image - Persistent conversation entity\n *\n * Image is the primary entity that users interact with (displayed as \"conversation\").\n * Agent is a transient runtime instance created from Image.\n */\n\nimport { createLogger } from \"commonxjs/logger\";\nimport type { Image, ImageRecord, ImageContext, ImageCreateConfig } from \"./types\";\n\nconst logger = createLogger(\"image/Image\");\n\n/**\n * ImageImpl - Image implementation\n */\nexport class ImageImpl implements Image {\n private constructor(\n private readonly record: ImageRecord,\n private readonly context: ImageContext\n ) {}\n\n // ==================== Getters ====================\n\n get imageId(): string {\n return this.record.imageId;\n }\n\n get containerId(): string {\n return this.record.containerId;\n }\n\n get sessionId(): string {\n return this.record.sessionId;\n }\n\n get name(): string {\n return this.record.name;\n }\n\n get description(): string | undefined {\n return this.record.description;\n }\n\n get systemPrompt(): string | undefined {\n return this.record.systemPrompt;\n }\n\n get mcpServers() {\n return this.record.mcpServers;\n }\n\n get createdAt(): number {\n return this.record.createdAt;\n }\n\n get updatedAt(): number {\n return this.record.updatedAt;\n }\n\n // ==================== Static Factory Methods ====================\n\n /**\n * Create a new image (conversation)\n */\n static async create(config: ImageCreateConfig, context: ImageContext): Promise<ImageImpl> {\n const now = Date.now();\n const imageId = ImageImpl.generateImageId();\n const sessionId = ImageImpl.generateSessionId();\n\n // Create image record\n const record: ImageRecord = {\n imageId,\n containerId: config.containerId,\n sessionId,\n name: config.name ?? \"New Conversation\",\n description: config.description,\n systemPrompt: config.systemPrompt,\n mcpServers: config.mcpServers,\n createdAt: now,\n updatedAt: now,\n };\n\n // Persist image\n await context.imageRepository.saveImage(record);\n\n // Create associated session (for message storage)\n await context.sessionRepository.saveSession({\n sessionId,\n imageId,\n containerId: config.containerId,\n createdAt: now,\n updatedAt: now,\n });\n\n logger.info(\"Image created\", {\n imageId,\n sessionId,\n containerId: config.containerId,\n name: record.name,\n });\n\n return new ImageImpl(record, context);\n }\n\n /**\n * Load an existing image from storage\n */\n static async load(imageId: string, context: ImageContext): Promise<ImageImpl | null> {\n const record = await context.imageRepository.findImageById(imageId);\n if (!record) {\n logger.debug(\"Image not found\", { imageId });\n return null;\n }\n\n logger.debug(\"Image loaded\", { imageId, name: record.name });\n return new ImageImpl(record, context);\n }\n\n /**\n * List all images in a container\n */\n static async listByContainer(containerId: string, context: ImageContext): Promise<ImageRecord[]> {\n return context.imageRepository.findImagesByContainerId(containerId);\n }\n\n /**\n * List all images\n */\n static async listAll(context: ImageContext): Promise<ImageRecord[]> {\n return context.imageRepository.findAllImages();\n }\n\n // ==================== Instance Methods ====================\n\n /**\n * Update image metadata\n */\n async update(updates: { name?: string; description?: string }): Promise<Image> {\n const now = Date.now();\n const updatedRecord: ImageRecord = {\n ...this.record,\n name: updates.name ?? this.record.name,\n description: updates.description ?? this.record.description,\n updatedAt: now,\n };\n\n await this.context.imageRepository.saveImage(updatedRecord);\n\n logger.info(\"Image updated\", { imageId: this.imageId, updates });\n return new ImageImpl(updatedRecord, this.context);\n }\n\n /**\n * Delete this image and its session\n */\n async delete(): Promise<void> {\n // Delete session first (including messages)\n await this.context.sessionRepository.deleteSession(this.sessionId);\n\n // Delete image\n await this.context.imageRepository.deleteImage(this.imageId);\n\n logger.info(\"Image deleted\", { imageId: this.imageId, sessionId: this.sessionId });\n }\n\n /**\n * Get the underlying record\n */\n toRecord(): ImageRecord {\n return { ...this.record };\n }\n\n // ==================== Private Helpers ====================\n\n private static generateImageId(): string {\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 8);\n return `img_${timestamp}_${random}`;\n }\n\n private static generateSessionId(): string {\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 8);\n return `sess_${timestamp}_${random}`;\n }\n}\n\n/**\n * Create a new Image\n */\nexport async function createImage(\n config: ImageCreateConfig,\n context: ImageContext\n): Promise<Image> {\n return ImageImpl.create(config, context);\n}\n\n/**\n * Load an existing Image\n */\nexport async function loadImage(imageId: string, context: ImageContext): Promise<Image | null> {\n return ImageImpl.load(imageId, context);\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,8 @@
1
+ export * from 'commonxjs/logger';
2
+ export { AgentEngineState, AgentProcessorInput, AgentProcessorOutput, AgentStateMachine, MealyMachine, agentProcessor, createAgent, createInitialAgentEngineState, createMealyMachine } from './agent/index.js';
3
+ export { A as AssistantMessage, C as ContentPart, E as ErrorMessage, F as FilePart, I as ImagePart, M as Message, i as MessageRole, j as MessageSubtype, d as TextPart, e as ThinkingPart, b as TokenUsage, T as ToolCallMessage, f as ToolCallPart, a as ToolResultMessage, g as ToolResultOutput, h as ToolResultPart, c as UserContentPart, U as UserMessage } from './message-BMrMm1pq.js';
4
+ export { e as AgentError, d as AgentErrorCategory, _ as AgentErrorOccurredEvent, c as AgentEvent, ad as AgentEventHandler, a6 as AgentMessageEvent, A as AgentOutput, b as AgentOutputCallback, a as AgentState, $ as AgentStateEvent, ac as AgentTurnEvent, a2 as AssistantMessageEvent, z as ConversationEndData, Q as ConversationEndEvent, B as ConversationInterruptedData, R as ConversationInterruptedEvent, C as ConversationQueuedData, L as ConversationQueuedEvent, y as ConversationRespondingData, P as ConversationRespondingEvent, w as ConversationStartData, N as ConversationStartEvent, x as ConversationThinkingData, O as ConversationThinkingEvent, E as EngineEvent, a5 as ErrorMessageEvent, J as ErrorOccurredData, Z as ErrorOccurredEvent, l as ErrorReceivedData, u as ErrorReceivedEvent, I as InputJsonDeltaData, r as InputJsonDeltaEvent, g as MessageDeltaData, n as MessageDeltaEvent, a0 as MessageEvent, M as MessageStartData, m as MessageStartEvent, h as MessageStopData, o as MessageStopEvent, K as StateEvent, f as StopReason, S as StreamEvent, v as StreamEventType, T as TextDeltaData, p as TextDeltaEvent, a3 as ToolCallMessageEvent, G as ToolCompletedData, X as ToolCompletedEvent, F as ToolExecutingData, W as ToolExecutingEvent, H as ToolFailedData, Y as ToolFailedEvent, D as ToolPlannedData, V as ToolPlannedEvent, k as ToolResultData, t as ToolResultEvent, a4 as ToolResultMessageEvent, i as ToolUseStartData, q as ToolUseStartEvent, j as ToolUseStopData, s as ToolUseStopEvent, a9 as TurnEvent, a7 as TurnRequestData, aa as TurnRequestEvent, a8 as TurnResponseData, ab as TurnResponseEvent, U as Unsubscribe, a1 as UserMessageEvent, af as isMessageEvent, ae as isStateEvent, ag as isTurnEvent } from './event-CDuTzs__.js';
5
+ export { AgentEngine, AgentEventBus, AgentInterceptor, AgentInterceptorNext, AgentMiddleware, AgentMiddlewareNext, AgentPresenter, AgentSource, AgentStateMachineInterface, CreateAgentOptions, EventHandlerMap, MessageQueue, ReactHandlerMap, StateChange, StateChangeHandler } from './agent/types/index.js';
6
+ export { MessageAssemblerInput, MessageAssemblerOutput, MessageAssemblerState, PendingContent, PendingTurn, StateEventProcessorContext, StateEventProcessorInput, StateEventProcessorOutput, TurnTrackerInput, TurnTrackerOutput, TurnTrackerState, createInitialMessageAssemblerState, createInitialStateEventProcessorContext, createInitialTurnTrackerState, messageAssemblerProcessor, messageAssemblerProcessorDef, stateEventProcessor, stateEventProcessorDef, turnTrackerProcessor, turnTrackerProcessorDef } from './agent/engine/internal/index.js';
7
+ export { M as MemoryStore, a as Sink, b as SinkDefinition, c as Source, d as SourceDefinition, S as Store, g as chainProcessors, f as combineInitialStates, e as combineProcessors, h as filterProcessor, i as identityProcessor, m as mapOutput, w as withLogging } from './combinators-nEa5dD0T.js';
8
+ export { P as Processor, b as ProcessorDefinition, a as ProcessorResult } from './Processor-DT0N1qI6.js';