@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.
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-E5FPOAPO.js +123 -0
  21. package/dist/chunk-E5FPOAPO.js.map +1 -0
  22. package/dist/chunk-EKHT54KN.js +272 -0
  23. package/dist/chunk-EKHT54KN.js.map +1 -0
  24. package/dist/chunk-I7GYR3MN.js +502 -0
  25. package/dist/chunk-I7GYR3MN.js.map +1 -0
  26. package/dist/chunk-K6WXQ2RW.js +38 -0
  27. package/dist/chunk-K6WXQ2RW.js.map +1 -0
  28. package/dist/chunk-RL3JRNXM.js +3 -0
  29. package/dist/chunk-RL3JRNXM.js.map +1 -0
  30. package/dist/chunk-TBU7FFZT.js +543 -0
  31. package/dist/chunk-TBU7FFZT.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 +73 -14
  80. package/tsconfig.json +0 -10
@@ -0,0 +1,110 @@
1
+ import { ContainerRecord, ContainerRepository, ImageRepository, SessionRepository } from '../persistence/index.js';
2
+ export { ContainerConfig } from '../persistence/index.js';
3
+ import '../message-BMrMm1pq.js';
4
+ import '../driver/index.js';
5
+
6
+ /**
7
+ * Container - Resource isolation unit
8
+ *
9
+ * Manages Images and Agents within an isolated boundary.
10
+ */
11
+ interface Container {
12
+ readonly containerId: string;
13
+ readonly createdAt: number;
14
+ readonly updatedAt: number;
15
+ readonly config: Record<string, unknown> | undefined;
16
+ /**
17
+ * Update container configuration
18
+ */
19
+ update(updates: {
20
+ config?: Record<string, unknown>;
21
+ }): Promise<Container>;
22
+ /**
23
+ * Delete this container and all its resources
24
+ */
25
+ delete(): Promise<void>;
26
+ /**
27
+ * Get the underlying record
28
+ */
29
+ toRecord(): ContainerRecord;
30
+ }
31
+ /**
32
+ * Context needed by Container operations
33
+ */
34
+ interface ContainerContext {
35
+ containerRepository: ContainerRepository;
36
+ imageRepository: ImageRepository;
37
+ sessionRepository: SessionRepository;
38
+ }
39
+ /**
40
+ * Configuration for creating a new Container
41
+ */
42
+ interface ContainerCreateConfig {
43
+ containerId?: string;
44
+ config?: Record<string, unknown>;
45
+ }
46
+
47
+ /**
48
+ * Container - Resource isolation unit
49
+ *
50
+ * Container provides an isolated environment for Images and Agents.
51
+ * Each container can have multiple Images (conversations).
52
+ */
53
+
54
+ /**
55
+ * ContainerImpl - Container implementation
56
+ */
57
+ declare class ContainerImpl implements Container {
58
+ private readonly record;
59
+ private readonly context;
60
+ private constructor();
61
+ get containerId(): string;
62
+ get createdAt(): number;
63
+ get updatedAt(): number;
64
+ get config(): Record<string, unknown> | undefined;
65
+ /**
66
+ * Create a new container
67
+ */
68
+ static create(config: ContainerCreateConfig, context: ContainerContext): Promise<ContainerImpl>;
69
+ /**
70
+ * Load an existing container from storage
71
+ */
72
+ static load(containerId: string, context: ContainerContext): Promise<ContainerImpl | null>;
73
+ /**
74
+ * Get or create a container
75
+ */
76
+ static getOrCreate(containerId: string, context: ContainerContext): Promise<ContainerImpl>;
77
+ /**
78
+ * List all containers
79
+ */
80
+ static listAll(context: ContainerContext): Promise<ContainerRecord[]>;
81
+ /**
82
+ * Update container configuration
83
+ */
84
+ update(updates: {
85
+ config?: Record<string, unknown>;
86
+ }): Promise<Container>;
87
+ /**
88
+ * Delete this container and all its resources
89
+ */
90
+ delete(): Promise<void>;
91
+ /**
92
+ * Get the underlying record
93
+ */
94
+ toRecord(): ContainerRecord;
95
+ private static generateContainerId;
96
+ }
97
+ /**
98
+ * Create a new Container
99
+ */
100
+ declare function createContainer(config: ContainerCreateConfig, context: ContainerContext): Promise<Container>;
101
+ /**
102
+ * Load an existing Container
103
+ */
104
+ declare function loadContainer(containerId: string, context: ContainerContext): Promise<Container | null>;
105
+ /**
106
+ * Get or create a Container
107
+ */
108
+ declare function getOrCreateContainer(containerId: string, context: ContainerContext): Promise<Container>;
109
+
110
+ export { type Container, type ContainerContext, type ContainerCreateConfig, ContainerImpl, ContainerRecord, ContainerRepository, createContainer, getOrCreateContainer, loadContainer };
@@ -0,0 +1,127 @@
1
+ import "../chunk-7D4SUZUM.js";
2
+
3
+ // src/container/Container.ts
4
+ import { createLogger } from "commonxjs/logger";
5
+ var logger = createLogger("container/Container");
6
+ var ContainerImpl = class _ContainerImpl {
7
+ constructor(record, context) {
8
+ this.record = record;
9
+ this.context = context;
10
+ }
11
+ // ==================== Getters ====================
12
+ get containerId() {
13
+ return this.record.containerId;
14
+ }
15
+ get createdAt() {
16
+ return this.record.createdAt;
17
+ }
18
+ get updatedAt() {
19
+ return this.record.updatedAt;
20
+ }
21
+ get config() {
22
+ return this.record.config;
23
+ }
24
+ // ==================== Static Factory Methods ====================
25
+ /**
26
+ * Create a new container
27
+ */
28
+ static async create(config, context) {
29
+ const now = Date.now();
30
+ const containerId = config.containerId ?? _ContainerImpl.generateContainerId();
31
+ const record = {
32
+ containerId,
33
+ createdAt: now,
34
+ updatedAt: now,
35
+ config: config.config
36
+ };
37
+ await context.containerRepository.saveContainer(record);
38
+ logger.info("Container created", { containerId });
39
+ return new _ContainerImpl(record, context);
40
+ }
41
+ /**
42
+ * Load an existing container from storage
43
+ */
44
+ static async load(containerId, context) {
45
+ const record = await context.containerRepository.findContainerById(containerId);
46
+ if (!record) {
47
+ logger.debug("Container not found", { containerId });
48
+ return null;
49
+ }
50
+ logger.debug("Container loaded", { containerId });
51
+ return new _ContainerImpl(record, context);
52
+ }
53
+ /**
54
+ * Get or create a container
55
+ */
56
+ static async getOrCreate(containerId, context) {
57
+ const existing = await _ContainerImpl.load(containerId, context);
58
+ if (existing) {
59
+ return existing;
60
+ }
61
+ return _ContainerImpl.create({ containerId }, context);
62
+ }
63
+ /**
64
+ * List all containers
65
+ */
66
+ static async listAll(context) {
67
+ return context.containerRepository.findAllContainers();
68
+ }
69
+ // ==================== Instance Methods ====================
70
+ /**
71
+ * Update container configuration
72
+ */
73
+ async update(updates) {
74
+ const now = Date.now();
75
+ const updatedRecord = {
76
+ ...this.record,
77
+ config: updates.config ?? this.record.config,
78
+ updatedAt: now
79
+ };
80
+ await this.context.containerRepository.saveContainer(updatedRecord);
81
+ logger.info("Container updated", { containerId: this.containerId, updates });
82
+ return new _ContainerImpl(updatedRecord, this.context);
83
+ }
84
+ /**
85
+ * Delete this container and all its resources
86
+ */
87
+ async delete() {
88
+ const images = await this.context.imageRepository.findImagesByContainerId(this.containerId);
89
+ for (const image of images) {
90
+ await this.context.sessionRepository.deleteSession(image.sessionId);
91
+ await this.context.imageRepository.deleteImage(image.imageId);
92
+ }
93
+ await this.context.containerRepository.deleteContainer(this.containerId);
94
+ logger.info("Container deleted", {
95
+ containerId: this.containerId,
96
+ imagesDeleted: images.length
97
+ });
98
+ }
99
+ /**
100
+ * Get the underlying record
101
+ */
102
+ toRecord() {
103
+ return { ...this.record };
104
+ }
105
+ // ==================== Private Helpers ====================
106
+ static generateContainerId() {
107
+ const timestamp = Date.now().toString(36);
108
+ const random = Math.random().toString(36).substring(2, 8);
109
+ return `ctr_${timestamp}_${random}`;
110
+ }
111
+ };
112
+ async function createContainer(config, context) {
113
+ return ContainerImpl.create(config, context);
114
+ }
115
+ async function loadContainer(containerId, context) {
116
+ return ContainerImpl.load(containerId, context);
117
+ }
118
+ async function getOrCreateContainer(containerId, context) {
119
+ return ContainerImpl.getOrCreate(containerId, context);
120
+ }
121
+ export {
122
+ ContainerImpl,
123
+ createContainer,
124
+ getOrCreateContainer,
125
+ loadContainer
126
+ };
127
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/container/Container.ts"],"sourcesContent":["/**\n * Container - Resource isolation unit\n *\n * Container provides an isolated environment for Images and Agents.\n * Each container can have multiple Images (conversations).\n */\n\nimport { createLogger } from \"commonxjs/logger\";\nimport type { ContainerRecord } from \"../persistence/types\";\nimport type { Container, ContainerContext, ContainerCreateConfig } from \"./types\";\n\nconst logger = createLogger(\"container/Container\");\n\n/**\n * ContainerImpl - Container implementation\n */\nexport class ContainerImpl implements Container {\n private constructor(\n private readonly record: ContainerRecord,\n private readonly context: ContainerContext\n ) {}\n\n // ==================== Getters ====================\n\n get containerId(): string {\n return this.record.containerId;\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 get config(): Record<string, unknown> | undefined {\n return this.record.config;\n }\n\n // ==================== Static Factory Methods ====================\n\n /**\n * Create a new container\n */\n static async create(\n config: ContainerCreateConfig,\n context: ContainerContext\n ): Promise<ContainerImpl> {\n const now = Date.now();\n const containerId = config.containerId ?? ContainerImpl.generateContainerId();\n\n const record: ContainerRecord = {\n containerId,\n createdAt: now,\n updatedAt: now,\n config: config.config,\n };\n\n await context.containerRepository.saveContainer(record);\n\n logger.info(\"Container created\", { containerId });\n\n return new ContainerImpl(record, context);\n }\n\n /**\n * Load an existing container from storage\n */\n static async load(containerId: string, context: ContainerContext): Promise<ContainerImpl | null> {\n const record = await context.containerRepository.findContainerById(containerId);\n if (!record) {\n logger.debug(\"Container not found\", { containerId });\n return null;\n }\n\n logger.debug(\"Container loaded\", { containerId });\n return new ContainerImpl(record, context);\n }\n\n /**\n * Get or create a container\n */\n static async getOrCreate(containerId: string, context: ContainerContext): Promise<ContainerImpl> {\n const existing = await ContainerImpl.load(containerId, context);\n if (existing) {\n return existing;\n }\n\n return ContainerImpl.create({ containerId }, context);\n }\n\n /**\n * List all containers\n */\n static async listAll(context: ContainerContext): Promise<ContainerRecord[]> {\n return context.containerRepository.findAllContainers();\n }\n\n // ==================== Instance Methods ====================\n\n /**\n * Update container configuration\n */\n async update(updates: { config?: Record<string, unknown> }): Promise<Container> {\n const now = Date.now();\n const updatedRecord: ContainerRecord = {\n ...this.record,\n config: updates.config ?? this.record.config,\n updatedAt: now,\n };\n\n await this.context.containerRepository.saveContainer(updatedRecord);\n\n logger.info(\"Container updated\", { containerId: this.containerId, updates });\n return new ContainerImpl(updatedRecord, this.context);\n }\n\n /**\n * Delete this container and all its resources\n */\n async delete(): Promise<void> {\n // Find all images in this container\n const images = await this.context.imageRepository.findImagesByContainerId(this.containerId);\n\n // Delete all images and their sessions\n for (const image of images) {\n await this.context.sessionRepository.deleteSession(image.sessionId);\n await this.context.imageRepository.deleteImage(image.imageId);\n }\n\n // Delete container\n await this.context.containerRepository.deleteContainer(this.containerId);\n\n logger.info(\"Container deleted\", {\n containerId: this.containerId,\n imagesDeleted: images.length,\n });\n }\n\n /**\n * Get the underlying record\n */\n toRecord(): ContainerRecord {\n return { ...this.record };\n }\n\n // ==================== Private Helpers ====================\n\n private static generateContainerId(): string {\n const timestamp = Date.now().toString(36);\n const random = Math.random().toString(36).substring(2, 8);\n return `ctr_${timestamp}_${random}`;\n }\n}\n\n/**\n * Create a new Container\n */\nexport async function createContainer(\n config: ContainerCreateConfig,\n context: ContainerContext\n): Promise<Container> {\n return ContainerImpl.create(config, context);\n}\n\n/**\n * Load an existing Container\n */\nexport async function loadContainer(\n containerId: string,\n context: ContainerContext\n): Promise<Container | null> {\n return ContainerImpl.load(containerId, context);\n}\n\n/**\n * Get or create a Container\n */\nexport async function getOrCreateContainer(\n containerId: string,\n context: ContainerContext\n): Promise<Container> {\n return ContainerImpl.getOrCreate(containerId, context);\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,266 @@
1
+ import { U as UserMessage } from '../message-BMrMm1pq.js';
2
+
3
+ /**
4
+ * Driver Types - LLM Communication Layer
5
+ *
6
+ * Driver is the bridge between AgentX and external LLM (Claude, OpenAI, etc.)
7
+ *
8
+ * ```
9
+ * AgentX
10
+ * │
11
+ * receive() │ AsyncIterable<StreamEvent>
12
+ * ─────────► │ ◄─────────────────────────
13
+ * │
14
+ * ┌───────────────┐
15
+ * │ Driver │
16
+ * │ │
17
+ * │ UserMessage │
18
+ * │ ↓ │
19
+ * │ [SDK call] │
20
+ * │ ↓ │
21
+ * │ StreamEvent │
22
+ * └───────────────┘
23
+ * │
24
+ * ▼
25
+ * External LLM
26
+ * (Claude SDK)
27
+ * ```
28
+ *
29
+ * Key Design:
30
+ * - Driver = single session communication (like Kimi SDK's Session)
31
+ * - Clear input/output boundary (for recording/playback)
32
+ * - Configuration defined by us (capability boundary)
33
+ */
34
+
35
+ /**
36
+ * MCP Server configuration
37
+ *
38
+ * Defines how to launch an MCP server process.
39
+ */
40
+ interface McpServerConfig {
41
+ /**
42
+ * Command to run the MCP server
43
+ */
44
+ command: string;
45
+ /**
46
+ * Command arguments
47
+ */
48
+ args?: string[];
49
+ /**
50
+ * Environment variables for the process
51
+ */
52
+ env?: Record<string, string>;
53
+ }
54
+ /**
55
+ * StopReason - Why the LLM stopped generating
56
+ */
57
+ type StopReason = "end_turn" | "max_tokens" | "tool_use" | "stop_sequence" | "content_filter" | "error" | "other";
58
+ /**
59
+ * StreamEvent - Lightweight event from Driver
60
+ *
61
+ * Only contains essential fields: type, timestamp, data
62
+ * No source, category, intent, context (those are added by upper layers)
63
+ */
64
+ interface StreamEvent<T extends string = string, D = unknown> {
65
+ readonly type: T;
66
+ readonly timestamp: number;
67
+ readonly data: D;
68
+ }
69
+ interface MessageStartEvent extends StreamEvent<"message_start", {
70
+ messageId: string;
71
+ model: string;
72
+ }> {
73
+ }
74
+ interface MessageStopEvent extends StreamEvent<"message_stop", {
75
+ stopReason: StopReason;
76
+ }> {
77
+ }
78
+ interface TextDeltaEvent extends StreamEvent<"text_delta", {
79
+ text: string;
80
+ }> {
81
+ }
82
+ interface ToolUseStartEvent extends StreamEvent<"tool_use_start", {
83
+ toolCallId: string;
84
+ toolName: string;
85
+ }> {
86
+ }
87
+ interface InputJsonDeltaEvent extends StreamEvent<"input_json_delta", {
88
+ partialJson: string;
89
+ }> {
90
+ }
91
+ interface ToolUseStopEvent extends StreamEvent<"tool_use_stop", {
92
+ toolCallId: string;
93
+ toolName: string;
94
+ input: Record<string, unknown>;
95
+ }> {
96
+ }
97
+ interface ToolResultEvent extends StreamEvent<"tool_result", {
98
+ toolCallId: string;
99
+ result: unknown;
100
+ isError?: boolean;
101
+ }> {
102
+ }
103
+ interface ErrorEvent extends StreamEvent<"error", {
104
+ message: string;
105
+ errorCode?: string;
106
+ }> {
107
+ }
108
+ interface InterruptedEvent extends StreamEvent<"interrupted", {
109
+ reason: "user" | "timeout" | "error";
110
+ }> {
111
+ }
112
+ /**
113
+ * DriverStreamEvent - Union of all stream events from Driver
114
+ */
115
+ type DriverStreamEvent = MessageStartEvent | MessageStopEvent | TextDeltaEvent | ToolUseStartEvent | InputJsonDeltaEvent | ToolUseStopEvent | ToolResultEvent | ErrorEvent | InterruptedEvent;
116
+ /**
117
+ * DriverStreamEventType - String literal union of event types
118
+ */
119
+ type DriverStreamEventType = DriverStreamEvent["type"];
120
+ /**
121
+ * DriverConfig - All configuration for creating a Driver
122
+ *
123
+ * This is our capability boundary - we define what we support.
124
+ * Specific implementations (Claude, OpenAI) must work within this.
125
+ */
126
+ interface DriverConfig {
127
+ /**
128
+ * API key for authentication
129
+ */
130
+ apiKey: string;
131
+ /**
132
+ * Base URL for API endpoint (optional, for custom deployments)
133
+ */
134
+ baseUrl?: string;
135
+ /**
136
+ * Model identifier (e.g., "claude-sonnet-4-20250514")
137
+ */
138
+ model?: string;
139
+ /**
140
+ * Request timeout in milliseconds (default: 600000 = 10 minutes)
141
+ */
142
+ timeout?: number;
143
+ /**
144
+ * Agent ID (for identification and logging)
145
+ */
146
+ agentId: string;
147
+ /**
148
+ * System prompt for the agent
149
+ */
150
+ systemPrompt?: string;
151
+ /**
152
+ * Current working directory for tool execution
153
+ */
154
+ cwd?: string;
155
+ /**
156
+ * MCP servers configuration
157
+ */
158
+ mcpServers?: Record<string, McpServerConfig>;
159
+ /**
160
+ * Session ID to resume (for conversation continuity)
161
+ *
162
+ * If provided, Driver will attempt to resume this session.
163
+ * If not provided, a new session is created.
164
+ */
165
+ resumeSessionId?: string;
166
+ /**
167
+ * Callback when SDK session ID is captured
168
+ *
169
+ * Called once when the session ID becomes available.
170
+ * Save this ID to enable session resume later.
171
+ */
172
+ onSessionIdCaptured?: (sessionId: string) => void;
173
+ }
174
+ /**
175
+ * DriverState - Current state of the Driver
176
+ *
177
+ * - idle: Ready to receive messages
178
+ * - active: Currently processing a message
179
+ * - disposed: Driver has been disposed, cannot be used
180
+ */
181
+ type DriverState = "idle" | "active" | "disposed";
182
+ /**
183
+ * Driver - LLM Communication Interface
184
+ *
185
+ * Responsible for a single session's communication with LLM.
186
+ * Similar to Kimi SDK's Session concept.
187
+ *
188
+ * Lifecycle:
189
+ * 1. createDriver(config) → Driver instance
190
+ * 2. driver.initialize() → Start SDK, MCP servers
191
+ * 3. driver.receive(message) → Send message, get events
192
+ * 4. driver.dispose() → Cleanup
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const driver = createDriver(config);
197
+ * await driver.initialize();
198
+ *
199
+ * const events = driver.receive(message);
200
+ * for await (const event of events) {
201
+ * if (event.type === "text_delta") {
202
+ * console.log(event.data.text);
203
+ * }
204
+ * }
205
+ *
206
+ * await driver.dispose();
207
+ * ```
208
+ */
209
+ interface Driver {
210
+ /**
211
+ * Driver name (for identification and logging)
212
+ */
213
+ readonly name: string;
214
+ /**
215
+ * SDK Session ID (available after first message)
216
+ */
217
+ readonly sessionId: string | null;
218
+ /**
219
+ * Current state
220
+ */
221
+ readonly state: DriverState;
222
+ /**
223
+ * Receive a user message and return stream of events
224
+ *
225
+ * @param message - User message to send
226
+ * @returns AsyncIterable of stream events
227
+ */
228
+ receive(message: UserMessage): AsyncIterable<DriverStreamEvent>;
229
+ /**
230
+ * Interrupt current operation
231
+ *
232
+ * Stops the current receive() operation gracefully.
233
+ * The AsyncIterable will emit an "interrupted" event and complete.
234
+ */
235
+ interrupt(): void;
236
+ /**
237
+ * Initialize the Driver
238
+ *
239
+ * Starts SDK subprocess, MCP servers, etc.
240
+ * Must be called before receive().
241
+ */
242
+ initialize(): Promise<void>;
243
+ /**
244
+ * Dispose and cleanup resources
245
+ *
246
+ * Stops SDK subprocess, MCP servers, etc.
247
+ * Driver cannot be used after dispose().
248
+ */
249
+ dispose(): Promise<void>;
250
+ }
251
+ /**
252
+ * CreateDriver - Factory function type for creating Driver instances
253
+ *
254
+ * Each implementation package exports a function of this type.
255
+ *
256
+ * @example
257
+ * ```typescript
258
+ * // @agentxjs/claude-driver
259
+ * export const createDriver: CreateDriver = (config) => {
260
+ * return new ClaudeDriverImpl(config);
261
+ * };
262
+ * ```
263
+ */
264
+ type CreateDriver = (config: DriverConfig) => Driver;
265
+
266
+ export type { CreateDriver, Driver, DriverConfig, DriverState, DriverStreamEvent, DriverStreamEventType, ErrorEvent, InputJsonDeltaEvent, InterruptedEvent, McpServerConfig, MessageStartEvent, MessageStopEvent, StopReason, StreamEvent, TextDeltaEvent, ToolResultEvent, ToolUseStartEvent, ToolUseStopEvent };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,55 @@
1
+ import { B as BusEvent } from '../base-m40r3Qgu.js';
2
+ export { b as EventCategory, c as EventContext, a as EventIntent, E as EventSource, S as SystemEvent, h as hasIntent, i as isFromSource, f as isNotification, d as isRequest, e as isResult } from '../base-m40r3Qgu.js';
3
+ import { E as EventBus, B as BusEventHandler, S as SubscribeOptions, U as Unsubscribe, C as CommandEventMap, a as CommandRequestType, R as RequestDataFor, b as ResponseEventFor, c as EventConsumer, d as EventProducer } from '../bus-uF1DM2ox.js';
4
+ 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, a1 as CommandEvent, a2 as CommandEventType, $ as CommandRequest, a6 as CommandRequestResponseMap, a0 as CommandResponse, i as ContainerCreateRequest, j as ContainerCreateResponse, k as ContainerGetRequest, l as ContainerGetResponse, m as ContainerListRequest, n as ContainerListResponse, 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, a7 as ResponseTypeFor, T as TextPart, e as UserContentPart, a3 as isCommandEvent, a4 as isCommandRequest, a5 as isCommandResponse } from '../bus-uF1DM2ox.js';
5
+ export { AgentErrorReceivedEvent, AgentEvent, AgentEventCategory, AgentInputJsonDeltaEvent, AgentMessageDeltaEvent, AgentMessageEvent, AgentMessageEventBase, AgentMessageEventType, AgentMessageStartEvent, AgentMessageStopEvent, AgentRegisteredEvent, AgentStateEvent, AgentStateEventBase, AgentStateEventType, AgentStopReason, AgentStreamEvent, AgentStreamEventBase, AgentStreamEventType, AgentTextDeltaEvent, AgentToolResultEvent, AgentToolUseStartEvent, AgentToolUseStopEvent, AgentTurnEvent, AgentTurnEventBase, AgentTurnEventType, AgentUnregisteredEvent, AssistantMessageEvent, BaseAgentEvent, ConnectedEvent, ConnectionEvent, ConnectionEventType, ContainerCreatedEvent, ContainerDestroyedEvent, ContainerEvent, ContainerLifecycleEvent, ConversationEndEvent, ConversationInterruptedEvent, ConversationQueuedEvent, ConversationRespondingEvent, ConversationStartEvent, ConversationThinkingEvent, DirectoryListRequest, DirectoryListResult, DisconnectedEvent, DriveableEvent, DriveableEventType, EnvironmentEvent, ErrorEvent, ErrorEventMap, ErrorEventType, ErrorMessageEvent, ErrorOccurredEvent, ErrorReceivedEvent, FileDeleteRequest, FileDeletedEvent, FileReadRequest, FileReadResult, FileWriteRequest, FileWrittenEvent, InputJsonDeltaEvent, InterruptedEvent, MCPEvent, MCPRequestEvent, MCPResultEvent, MCPServerConnectedEvent, MCPServerDisconnectedEvent, MessageDeltaEvent, MessagePersistRequest, MessagePersistedEvent, MessageStartEvent, MessageStopEvent, ReconnectingEvent, ResourceReadRequest, ResourceReadResult, SandboxEvent, SessionActionEvent, SessionActionRequestEvent, SessionActionResultEvent, SessionCreatedEvent, SessionDestroyedEvent, SessionEvent, SessionForkRequest, SessionForkedEvent, SessionLifecycleEvent, SessionPersistEvent, SessionPersistRequestEvent, SessionPersistResultEvent, SessionResumeRequest, SessionResumedEvent, SessionSaveRequest, SessionSavedEvent, SessionTitleUpdateRequest, SessionTitleUpdatedEvent, StopReason, SystemError, TextContentBlockStartEvent, TextContentBlockStopEvent, TextDeltaEvent, TokenUsage, ToolCallEvent, ToolCallMessageEvent, ToolCompletedEvent, ToolExecuteRequest, ToolExecutedEvent, ToolExecutingEvent, ToolExecutionErrorEvent, ToolFailedEvent, ToolPlannedEvent, ToolResultEvent, ToolResultMessageEvent, ToolUseContentBlockStartEvent, ToolUseContentBlockStopEvent, TurnRequestEvent, TurnResponseEvent, UserMessageEvent, WorkdirErrorEvent, WorkdirEvent, WorkdirRequestEvent, WorkdirResultEvent, isAgentEvent, isAgentMessageEvent, isAgentStateEvent, isAgentStreamEvent, isAgentTurnEvent, isConnectionEvent, isContainerEvent, isContainerLifecycleEvent, isDriveableEvent, isMCPEvent, isSandboxEvent, isSessionActionEvent, isSessionEvent, isSessionLifecycleEvent, isSessionPersistEvent, isStopReason, isWorkdirEvent } from './types/index.js';
6
+ import '../message-BMrMm1pq.js';
7
+
8
+ /**
9
+ * EventBus - Central event bus implementation
10
+ *
11
+ * Pub/Sub event bus for runtime communication.
12
+ * Uses RxJS Subject for reactive event distribution.
13
+ */
14
+
15
+ /**
16
+ * EventBusImpl - EventBus implementation using RxJS Subject
17
+ */
18
+ declare class EventBusImpl implements EventBus {
19
+ private readonly subject;
20
+ private subscriptions;
21
+ private nextId;
22
+ private isDestroyed;
23
+ private producerView;
24
+ private consumerView;
25
+ constructor();
26
+ emit(event: BusEvent): void;
27
+ emitBatch(events: BusEvent[]): void;
28
+ on<T extends string>(typeOrTypes: T | string[], handler: BusEventHandler<BusEvent & {
29
+ type: T;
30
+ }>, options?: SubscribeOptions<BusEvent & {
31
+ type: T;
32
+ }>): Unsubscribe;
33
+ onAny(handler: BusEventHandler, options?: SubscribeOptions): Unsubscribe;
34
+ once<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
35
+ type: T;
36
+ }>): Unsubscribe;
37
+ onCommand<T extends keyof CommandEventMap>(type: T, handler: (event: CommandEventMap[T]) => void): Unsubscribe;
38
+ emitCommand<T extends keyof CommandEventMap>(type: T, data: CommandEventMap[T]["data"]): void;
39
+ request<T extends CommandRequestType>(type: T, data: RequestDataFor<T>, timeout?: number): Promise<ResponseEventFor<T>>;
40
+ destroy(): void;
41
+ private dispatch;
42
+ private matchesType;
43
+ private sortByPriority;
44
+ private removeSubscription;
45
+ /**
46
+ * Get a read-only consumer view (only subscribe methods)
47
+ */
48
+ asConsumer(): EventConsumer;
49
+ /**
50
+ * Get a write-only producer view (only emit methods)
51
+ */
52
+ asProducer(): EventProducer;
53
+ }
54
+
55
+ export { BusEvent, BusEventHandler, CommandEventMap, CommandRequestType, EventBus, EventBusImpl, EventConsumer, EventProducer, RequestDataFor, ResponseEventFor, SubscribeOptions, Unsubscribe };
@@ -0,0 +1,60 @@
1
+ import {
2
+ EventBusImpl
3
+ } from "../chunk-7ZDX3O6I.js";
4
+ import {
5
+ hasIntent,
6
+ isAgentEvent,
7
+ isAgentMessageEvent,
8
+ isAgentStateEvent,
9
+ isAgentStreamEvent,
10
+ isAgentTurnEvent,
11
+ isCommandEvent,
12
+ isCommandRequest,
13
+ isCommandResponse,
14
+ isConnectionEvent,
15
+ isContainerEvent,
16
+ isContainerLifecycleEvent,
17
+ isDriveableEvent,
18
+ isFromSource,
19
+ isMCPEvent,
20
+ isNotification,
21
+ isRequest,
22
+ isResult,
23
+ isSandboxEvent,
24
+ isSessionActionEvent,
25
+ isSessionEvent,
26
+ isSessionLifecycleEvent,
27
+ isSessionPersistEvent,
28
+ isStopReason,
29
+ isWorkdirEvent
30
+ } from "../chunk-E5FPOAPO.js";
31
+ import "../chunk-7D4SUZUM.js";
32
+ export {
33
+ EventBusImpl,
34
+ hasIntent,
35
+ isAgentEvent,
36
+ isAgentMessageEvent,
37
+ isAgentStateEvent,
38
+ isAgentStreamEvent,
39
+ isAgentTurnEvent,
40
+ isCommandEvent,
41
+ isCommandRequest,
42
+ isCommandResponse,
43
+ isConnectionEvent,
44
+ isContainerEvent,
45
+ isContainerLifecycleEvent,
46
+ isDriveableEvent,
47
+ isFromSource,
48
+ isMCPEvent,
49
+ isNotification,
50
+ isRequest,
51
+ isResult,
52
+ isSandboxEvent,
53
+ isSessionActionEvent,
54
+ isSessionEvent,
55
+ isSessionLifecycleEvent,
56
+ isSessionPersistEvent,
57
+ isStopReason,
58
+ isWorkdirEvent
59
+ };
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}