agentxjs 2.6.1 → 2.7.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.
package/README.md CHANGED
@@ -80,6 +80,9 @@ interface AgentX {
80
80
  // Conversation management
81
81
  readonly chat: ChatNamespace;
82
82
 
83
+ // Prototype registry — reusable agent templates
84
+ readonly prototype: PrototypeNamespace;
85
+
83
86
  // Low-level subsystems
84
87
  readonly runtime: RuntimeNamespace;
85
88
 
@@ -114,12 +117,14 @@ Conversation management — create, list, and open conversations:
114
117
 
115
118
  ```typescript
116
119
  interface ChatNamespace {
117
- create(params: { name?, description?, contextId?, embody?, customData? }): Promise<AgentHandle>;
120
+ create(params: { prototypeId?, name?, description?, contextId?, embody?, customData? }): Promise<AgentHandle>;
118
121
  list(): Promise<ImageListResponse>;
119
122
  get(id: string): Promise<AgentHandle | null>;
120
123
  }
121
124
  ```
122
125
 
126
+ When `prototypeId` is provided, the conversation inherits the prototype's configuration. Inline params override prototype values.
127
+
123
128
  ### AgentHandle
124
129
 
125
130
  Returned by `chat.create()` and `chat.get()`. A live reference to a conversation with agent operations.
@@ -140,6 +145,32 @@ interface AgentHandle {
140
145
  }
141
146
  ```
142
147
 
148
+ ### PrototypeNamespace
149
+
150
+ Manage reusable agent templates — register once, create many conversations:
151
+
152
+ ```typescript
153
+ interface PrototypeNamespace {
154
+ create(params: { containerId, name, description?, contextId?, embody?, customData? }): Promise<PrototypeCreateResponse>;
155
+ get(prototypeId: string): Promise<PrototypeGetResponse>;
156
+ list(containerId?: string): Promise<PrototypeListResponse>;
157
+ update(prototypeId: string, updates: { name?, description?, contextId?, embody?, customData? }): Promise<PrototypeUpdateResponse>;
158
+ delete(prototypeId: string): Promise<BaseResponse>;
159
+ }
160
+ ```
161
+
162
+ ```typescript
163
+ // Register a prototype
164
+ const res = await ax.prototype.create({
165
+ containerId: "default",
166
+ name: "Code Reviewer",
167
+ embody: { model: "claude-sonnet-4-6", systemPrompt: "You review code." },
168
+ });
169
+
170
+ // Create conversation from prototype
171
+ const agent = await ax.chat.create({ prototypeId: res.record.prototypeId });
172
+ ```
173
+
143
174
  ### Runtime Namespace (low-level)
144
175
 
145
176
  For advanced use cases, access `ax.runtime.*` for direct subsystem operations:
@@ -186,6 +217,14 @@ For advanced use cases, access `ax.runtime.*` for direct subsystem operations:
186
217
  - `setDefault(id: string): Promise<BaseResponse>`
187
218
  - `getDefault(containerId: string): Promise<LLMProviderDefaultResponse>`
188
219
 
220
+ **prototype**:
221
+
222
+ - `create(params: { containerId, name, description?, contextId?, embody?, customData? }): Promise<PrototypeCreateResponse>`
223
+ - `get(prototypeId: string): Promise<PrototypeGetResponse>`
224
+ - `list(containerId?: string): Promise<PrototypeListResponse>`
225
+ - `update(prototypeId: string, updates: { name?, description?, contextId?, embody?, customData? }): Promise<PrototypeUpdateResponse>`
226
+ - `delete(prototypeId: string): Promise<BaseResponse>`
227
+
189
228
  Each LLM provider has a **vendor** (who provides the service — `anthropic`, `openai`, `deepseek`, `ollama`) and a **protocol** (API format — `anthropic` or `openai`). These are separate dimensions: e.g., Deepseek uses vendor `"deepseek"` with protocol `"openai"`.
190
229
 
191
230
  ### Embodiment
@@ -213,6 +252,10 @@ await ax.rpc("container.create", { containerId: "default" });
213
252
  // Equivalent to ax.runtime.image.list()
214
253
  const { records } = await ax.rpc<{ records: ImageRecord[] }>("image.list");
215
254
 
255
+ // Prototype operations via RPC
256
+ await ax.rpc("prototype.create", { containerId: "default", name: "My Agent" });
257
+ const { records } = await ax.rpc<{ records: PrototypeRecord[] }>("prototype.list", {});
258
+
216
259
  // Useful for custom transport (e.g. Cloudflare Workers/DO)
217
260
  const response = await ax.rpc(request.method, request.params);
218
261
  ```
@@ -57,16 +57,16 @@ var CommandHandler = class {
57
57
  return await this.handleImageUpdate(params);
58
58
  case "image.messages":
59
59
  return await this.handleImageMessages(params);
60
- // Agent
61
- case "agent.get":
60
+ // Instance
61
+ case "instance.get":
62
62
  return await this.handleAgentGet(params);
63
- case "agent.list":
63
+ case "instance.list":
64
64
  return await this.handleAgentList(params);
65
- case "agent.destroy":
65
+ case "instance.destroy":
66
66
  return await this.handleAgentDestroy(params);
67
- case "agent.destroyAll":
67
+ case "instance.destroyAll":
68
68
  return await this.handleAgentDestroyAll(params);
69
- case "agent.interrupt":
69
+ case "instance.interrupt":
70
70
  return await this.handleAgentInterrupt(params);
71
71
  // Message
72
72
  case "message.send":
@@ -165,16 +165,16 @@ var CommandHandler = class {
165
165
  return ok({ imageId });
166
166
  }
167
167
  async handleImageRun(params) {
168
- const { imageId, agentId: requestedAgentId } = params;
168
+ const { imageId, instanceId: requestedInstanceId } = params;
169
169
  const existingAgent = this.runtime.getAgents().find((a) => a.imageId === imageId && a.lifecycle === "running");
170
170
  if (existingAgent) {
171
171
  logger.debug("Reusing existing agent for image", {
172
172
  imageId,
173
- agentId: existingAgent.agentId
173
+ instanceId: existingAgent.instanceId
174
174
  });
175
175
  return ok({
176
176
  imageId,
177
- agentId: existingAgent.agentId,
177
+ instanceId: existingAgent.instanceId,
178
178
  sessionId: existingAgent.sessionId,
179
179
  containerId: existingAgent.containerId,
180
180
  reused: true
@@ -182,15 +182,15 @@ var CommandHandler = class {
182
182
  }
183
183
  const agent = await this.runtime.createAgent({
184
184
  imageId,
185
- agentId: requestedAgentId
185
+ instanceId: requestedInstanceId
186
186
  });
187
187
  logger.info("Created new agent for image", {
188
188
  imageId,
189
- agentId: agent.agentId
189
+ instanceId: agent.instanceId
190
190
  });
191
191
  return ok({
192
192
  imageId,
193
- agentId: agent.agentId,
193
+ instanceId: agent.instanceId,
194
194
  sessionId: agent.sessionId,
195
195
  containerId: agent.containerId,
196
196
  reused: false
@@ -200,8 +200,8 @@ var CommandHandler = class {
200
200
  const { imageId } = params;
201
201
  const agent = this.runtime.getAgents().find((a) => a.imageId === imageId && a.lifecycle === "running");
202
202
  if (agent) {
203
- await this.runtime.stopAgent(agent.agentId);
204
- logger.info("Stopped agent for image", { imageId, agentId: agent.agentId });
203
+ await this.runtime.stopAgent(agent.instanceId);
204
+ logger.info("Stopped agent for image", { imageId, instanceId: agent.instanceId });
205
205
  } else {
206
206
  logger.debug("No running agent found for image", { imageId });
207
207
  }
@@ -238,11 +238,11 @@ var CommandHandler = class {
238
238
  }
239
239
  // ==================== Agent Commands ====================
240
240
  async handleAgentGet(params) {
241
- const { agentId } = params;
242
- const agent = this.runtime.getAgent(agentId);
241
+ const { instanceId } = params;
242
+ const agent = this.runtime.getAgent(instanceId);
243
243
  return ok({
244
244
  agent: agent ? {
245
- agentId: agent.agentId,
245
+ instanceId: agent.instanceId,
246
246
  imageId: agent.imageId,
247
247
  containerId: agent.containerId,
248
248
  sessionId: agent.sessionId,
@@ -256,7 +256,7 @@ var CommandHandler = class {
256
256
  const agents = containerId ? this.runtime.getAgentsByContainer(containerId) : this.runtime.getAgents();
257
257
  return ok({
258
258
  agents: agents.map((a) => ({
259
- agentId: a.agentId,
259
+ instanceId: a.instanceId,
260
260
  imageId: a.imageId,
261
261
  containerId: a.containerId,
262
262
  sessionId: a.sessionId,
@@ -265,54 +265,54 @@ var CommandHandler = class {
265
265
  });
266
266
  }
267
267
  async handleAgentDestroy(params) {
268
- const { agentId } = params;
269
- const agent = this.runtime.getAgent(agentId);
268
+ const { instanceId } = params;
269
+ const agent = this.runtime.getAgent(instanceId);
270
270
  if (!agent) {
271
- return ok({ agentId, success: false });
271
+ return ok({ instanceId, success: false });
272
272
  }
273
- await this.runtime.destroyAgent(agentId);
274
- return ok({ agentId, success: true });
273
+ await this.runtime.destroyAgent(instanceId);
274
+ return ok({ instanceId, success: true });
275
275
  }
276
276
  async handleAgentDestroyAll(params) {
277
277
  const { containerId } = params;
278
278
  const agents = this.runtime.getAgentsByContainer(containerId);
279
279
  for (const agent of agents) {
280
- await this.runtime.destroyAgent(agent.agentId);
280
+ await this.runtime.destroyAgent(agent.instanceId);
281
281
  }
282
282
  return ok({ containerId });
283
283
  }
284
284
  async handleAgentInterrupt(params) {
285
- const { agentId } = params;
286
- this.runtime.interrupt(agentId);
287
- return ok({ agentId });
285
+ const { instanceId } = params;
286
+ this.runtime.interrupt(instanceId);
287
+ return ok({ instanceId });
288
288
  }
289
289
  // ==================== Message Commands ====================
290
290
  async handleMessageSend(params) {
291
- const { agentId, imageId, content } = params;
292
- let targetAgentId;
293
- if (agentId) {
294
- targetAgentId = agentId;
291
+ const { instanceId, imageId, content } = params;
292
+ let targetInstanceId;
293
+ if (instanceId) {
294
+ targetInstanceId = instanceId;
295
295
  } else if (imageId) {
296
296
  const existingAgent = this.runtime.getAgents().find((a) => a.imageId === imageId && a.lifecycle === "running");
297
297
  if (existingAgent) {
298
- targetAgentId = existingAgent.agentId;
298
+ targetInstanceId = existingAgent.instanceId;
299
299
  logger.debug("Using existing agent for message", {
300
300
  imageId,
301
- agentId: targetAgentId
301
+ instanceId: targetInstanceId
302
302
  });
303
303
  } else {
304
304
  const agent = await this.runtime.createAgent({ imageId });
305
- targetAgentId = agent.agentId;
305
+ targetInstanceId = agent.instanceId;
306
306
  logger.info("Auto-created agent for message", {
307
307
  imageId,
308
- agentId: targetAgentId
308
+ instanceId: targetInstanceId
309
309
  });
310
310
  }
311
311
  } else {
312
- return err(-32602, "Either agentId or imageId is required");
312
+ return err(-32602, "Either instanceId or imageId is required");
313
313
  }
314
- await this.runtime.receive(targetAgentId, content);
315
- return ok({ agentId: targetAgentId, imageId });
314
+ await this.runtime.receive(targetInstanceId, content);
315
+ return ok({ instanceId: targetInstanceId, imageId });
316
316
  }
317
317
  // ==================== Prototype Commands ====================
318
318
  async handlePrototypeCreate(params) {
@@ -649,4 +649,4 @@ export {
649
649
  CommandHandler,
650
650
  createServer
651
651
  };
652
- //# sourceMappingURL=chunk-JTHR3AK6.js.map
652
+ //# sourceMappingURL=chunk-NPRCFKO5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server.ts","../src/CommandHandler.ts"],"sourcesContent":["/**\n * AgentX Server Implementation (JSON-RPC 2.0)\n *\n * Creates a WebSocket server that:\n * 1. Accepts client connections\n * 2. Handles JSON-RPC requests directly via CommandHandler\n * 3. Broadcasts stream events as JSON-RPC notifications\n *\n * Message Types:\n * - RPC Request (has id): Client → Server → Client (direct response)\n * - RPC Notification (no id): Server → Client (stream events)\n */\n\nimport type { CreateDriver } from \"@agentxjs/core/driver\";\nimport type { BusEvent, SystemEvent } from \"@agentxjs/core/event\";\nimport type { ChannelConnection } from \"@agentxjs/core/network\";\nimport {\n createErrorResponse,\n createStreamEvent,\n createSuccessResponse,\n isNotification,\n isRequest,\n parseMessage,\n RpcErrorCodes,\n type RpcMethod,\n} from \"@agentxjs/core/network\";\nimport type { AgentXPlatform } from \"@agentxjs/core/runtime\";\nimport { createAgentXRuntime } from \"@agentxjs/core/runtime\";\nimport { createLogger } from \"@deepracticex/logger\";\nimport { CommandHandler } from \"./CommandHandler\";\nimport type { AgentXServer } from \"./types\";\n\nconst logger = createLogger(\"server/Server\");\n\n/**\n * Connection state\n */\ninterface ConnectionState {\n connection: ChannelConnection;\n subscribedTopics: Set<string>;\n}\n\n/**\n * Server configuration (supports both immediate and deferred platforms)\n */\nexport interface ServerConfig {\n /**\n * AgentX Platform — must provide `channelServer` for accepting WebSocket connections.\n */\n platform: AgentXPlatform;\n\n /**\n * LLM Driver factory function - creates Driver per Agent\n */\n createDriver: CreateDriver;\n\n /**\n * Port to listen on (standalone mode)\n */\n port?: number;\n\n /**\n * Host to bind to (default: \"0.0.0.0\")\n */\n host?: string;\n\n /**\n * Existing HTTP server to attach to (attached mode)\n */\n server?: import(\"@agentxjs/core/network\").MinimalHTTPServer;\n\n /**\n * WebSocket path when attached (default: \"/ws\")\n */\n wsPath?: string;\n\n /**\n * Enable debug logging\n */\n debug?: boolean;\n}\n\n/**\n * Create an AgentX server\n */\nexport async function createServer(config: ServerConfig): Promise<AgentXServer> {\n const { wsPath = \"/ws\" } = config;\n const platform = config.platform;\n\n // Create runtime from platform + driver\n const runtime = createAgentXRuntime(platform, config.createDriver);\n\n // Get channel server from platform\n const wsServer = platform.channelServer;\n if (!wsServer) {\n throw new Error(\"Platform must provide channelServer for server mode\");\n }\n\n // Create command handler (no longer needs eventBus)\n const commandHandler = new CommandHandler(runtime);\n\n // Track connections\n const connections = new Map<string, ConnectionState>();\n\n /**\n * Subscribe connection to a topic\n */\n function subscribeToTopic(connectionId: string, topic: string): void {\n const state = connections.get(connectionId);\n if (!state || state.subscribedTopics.has(topic)) return;\n\n state.subscribedTopics.add(topic);\n logger.debug(\"Connection subscribed to topic\", { connectionId, topic });\n }\n\n /**\n * Check if event should be sent to connection based on subscriptions\n */\n function shouldSendToConnection(state: ConnectionState, event: BusEvent): boolean {\n // Skip internal driver events\n if (event.source === \"driver\" && event.intent !== \"notification\") {\n return false;\n }\n\n // Skip command events (they are handled via RPC, not broadcast)\n if (event.source === \"command\") {\n return false;\n }\n\n // Check if subscribed to event's session\n const eventWithContext = event as BusEvent & { context?: { sessionId?: string } };\n const sessionId = eventWithContext.context?.sessionId;\n if (sessionId && state.subscribedTopics.has(sessionId)) {\n return true;\n }\n\n // Send to global subscribers\n return state.subscribedTopics.has(\"global\");\n }\n\n /**\n * Send JSON-RPC response to a specific connection\n */\n function sendResponse(connection: ChannelConnection, id: string | number, result: unknown): void {\n const response = createSuccessResponse(id, result);\n connection.send(JSON.stringify(response));\n }\n\n /**\n * Send JSON-RPC error to a specific connection\n */\n function sendError(\n connection: ChannelConnection,\n id: string | number | null,\n code: number,\n message: string\n ): void {\n const response = createErrorResponse(id, code, message);\n connection.send(JSON.stringify(response));\n }\n\n // Handle new connections\n wsServer.onConnection((connection) => {\n const state: ConnectionState = {\n connection,\n subscribedTopics: new Set([\"global\"]),\n };\n connections.set(connection.id, state);\n\n logger.info(\"Client connected\", {\n connectionId: connection.id,\n totalConnections: connections.size,\n });\n\n // Handle messages from client\n connection.onMessage(async (message) => {\n try {\n const parsed = parseMessage(message);\n\n // Handle single message (not batch)\n if (!Array.isArray(parsed)) {\n await handleParsedMessage(connection, state, parsed);\n } else {\n // Handle batch (not common, but supported by JSON-RPC 2.0)\n for (const item of parsed) {\n await handleParsedMessage(connection, state, item);\n }\n }\n } catch (err) {\n logger.error(\"Failed to parse message\", { error: (err as Error).message });\n sendError(connection, null, RpcErrorCodes.PARSE_ERROR, \"Parse error\");\n }\n });\n\n // Cleanup on disconnect\n connection.onClose(() => {\n connections.delete(connection.id);\n logger.info(\"Client disconnected\", {\n connectionId: connection.id,\n totalConnections: connections.size,\n });\n });\n });\n\n /**\n * Handle a parsed JSON-RPC message\n */\n async function handleParsedMessage(\n connection: ChannelConnection,\n state: ConnectionState,\n parsed: import(\"jsonrpc-lite\").IParsedObject\n ): Promise<void> {\n if (isRequest(parsed)) {\n // JSON-RPC Request - handle and respond directly\n const payload = parsed.payload as {\n id: string | number;\n method: string;\n params: unknown;\n };\n const { id, method, params } = payload;\n\n logger.debug(\"Received RPC request\", { id, method });\n\n // Call command handler\n const result = await commandHandler.handle(method as RpcMethod, params);\n\n if (result.success) {\n sendResponse(connection, id, result.data);\n } else {\n sendError(connection, id, result.code, result.message);\n }\n } else if (isNotification(parsed)) {\n // JSON-RPC Notification - control messages\n const payload = parsed.payload as {\n method: string;\n params: unknown;\n };\n const { method, params } = payload;\n\n logger.debug(\"Received notification\", { method });\n\n if (method === \"subscribe\") {\n const { topic } = params as { topic: string };\n subscribeToTopic(connection.id, topic);\n } else if (method === \"unsubscribe\") {\n const { topic } = params as { topic: string };\n state.subscribedTopics.delete(topic);\n logger.debug(\"Connection unsubscribed from topic\", { connectionId: connection.id, topic });\n } else if (method === \"control.ack\") {\n // ACK for reliable delivery - handled by network layer\n logger.debug(\"Received ACK notification\");\n }\n } else {\n // Invalid message\n logger.warn(\"Received invalid JSON-RPC message\");\n }\n }\n\n // Route internal events to connected clients as JSON-RPC notifications\n platform.eventBus.onAny((event) => {\n // Only broadcast broadcastable events\n if (!shouldBroadcastEvent(event)) {\n return;\n }\n\n // Get topic from event context\n const eventWithContext = event as BusEvent & { context?: { sessionId?: string } };\n const topic = eventWithContext.context?.sessionId || \"global\";\n\n // Wrap as JSON-RPC notification\n const notification = createStreamEvent(topic, event as SystemEvent);\n const message = JSON.stringify(notification);\n\n for (const [connectionId, state] of connections) {\n if (shouldSendToConnection(state, event)) {\n state.connection.sendReliable(message, {\n timeout: 10000,\n onTimeout: () => {\n logger.warn(\"Event ACK timeout\", {\n connectionId,\n eventType: event.type,\n });\n },\n });\n }\n }\n });\n\n /**\n * Check if event should be broadcast\n */\n function shouldBroadcastEvent(event: BusEvent): boolean {\n // Skip internal driver events\n if (event.source === \"driver\" && event.intent !== \"notification\") {\n return false;\n }\n\n // Skip command events (handled via RPC)\n if (event.source === \"command\") {\n return false;\n }\n\n // Check broadcastable flag\n const systemEvent = event as SystemEvent;\n if (systemEvent.broadcastable === false) {\n return false;\n }\n\n return true;\n }\n\n // Attach to existing server if provided\n if (config.server) {\n wsServer.attach(config.server, wsPath);\n logger.info(\"WebSocket attached to existing server\", { path: wsPath });\n }\n\n return {\n async listen(port?: number, host?: string) {\n if (config.server) {\n throw new Error(\n \"Cannot listen when attached to existing server. The server should call listen() instead.\"\n );\n }\n\n const listenPort = port ?? config.port ?? 5200;\n const listenHost = host ?? config.host ?? \"0.0.0.0\";\n\n await wsServer.listen(listenPort, listenHost);\n logger.info(\"Server listening\", { port: listenPort, host: listenHost });\n },\n\n async close() {\n await wsServer.close();\n logger.info(\"Server closed\");\n },\n\n async dispose() {\n // Cleanup in order\n await wsServer.dispose();\n commandHandler.dispose();\n await runtime.shutdown();\n logger.info(\"Server disposed\");\n },\n };\n}\n","/**\n * CommandHandler - Handles JSON-RPC requests directly\n *\n * No longer uses EventBus for request/response. Instead:\n * - Receives RPC requests directly\n * - Returns RPC responses directly\n * - EventBus is only used for stream events (notifications)\n */\n\nimport type { UserContentPart } from \"@agentxjs/core/agent\";\nimport type { RpcMethod } from \"@agentxjs/core/network\";\nimport type { AgentXRuntime } from \"@agentxjs/core/runtime\";\nimport { createLogger } from \"@deepracticex/logger\";\n\nconst logger = createLogger(\"server/CommandHandler\");\n\n/**\n * RPC Result type\n */\nexport interface RpcResult<T = unknown> {\n success: true;\n data: T;\n}\n\nexport interface RpcError {\n success: false;\n code: number;\n message: string;\n}\n\nexport type RpcResponse<T = unknown> = RpcResult<T> | RpcError;\n\n/**\n * Helper to create success result\n */\nfunction ok<T>(data: T): RpcResult<T> {\n return { success: true, data };\n}\n\n/**\n * Helper to create error result\n */\nfunction err(code: number, message: string): RpcError {\n return { success: false, code, message };\n}\n\n/**\n * CommandHandler - Processes RPC requests directly\n */\nexport class CommandHandler {\n private readonly runtime: AgentXRuntime;\n\n constructor(runtime: AgentXRuntime) {\n this.runtime = runtime;\n logger.debug(\"CommandHandler created\");\n }\n\n /**\n * Handle an RPC request and return response\n */\n async handle(method: RpcMethod, params: unknown): Promise<RpcResponse> {\n logger.debug(\"Handling RPC request\", { method });\n\n try {\n switch (method) {\n // Container\n case \"container.create\":\n return await this.handleContainerCreate(params);\n case \"container.get\":\n return await this.handleContainerGet(params);\n case \"container.list\":\n return await this.handleContainerList(params);\n\n // Image\n case \"image.create\":\n return await this.handleImageCreate(params);\n case \"image.get\":\n return await this.handleImageGet(params);\n case \"image.list\":\n return await this.handleImageList(params);\n case \"image.delete\":\n return await this.handleImageDelete(params);\n case \"image.run\":\n return await this.handleImageRun(params);\n case \"image.stop\":\n return await this.handleImageStop(params);\n case \"image.update\":\n return await this.handleImageUpdate(params);\n case \"image.messages\":\n return await this.handleImageMessages(params);\n\n // Instance\n case \"instance.get\":\n return await this.handleAgentGet(params);\n case \"instance.list\":\n return await this.handleAgentList(params);\n case \"instance.destroy\":\n return await this.handleAgentDestroy(params);\n case \"instance.destroyAll\":\n return await this.handleAgentDestroyAll(params);\n case \"instance.interrupt\":\n return await this.handleAgentInterrupt(params);\n\n // Message\n case \"message.send\":\n return await this.handleMessageSend(params);\n\n // Prototype\n case \"prototype.create\":\n return await this.handlePrototypeCreate(params);\n case \"prototype.get\":\n return await this.handlePrototypeGet(params);\n case \"prototype.list\":\n return await this.handlePrototypeList(params);\n case \"prototype.update\":\n return await this.handlePrototypeUpdate(params);\n case \"prototype.delete\":\n return await this.handlePrototypeDelete(params);\n\n // LLM Provider\n case \"llm.create\":\n return await this.handleLLMCreate(params);\n case \"llm.get\":\n return await this.handleLLMGet(params);\n case \"llm.list\":\n return await this.handleLLMList(params);\n case \"llm.update\":\n return await this.handleLLMUpdate(params);\n case \"llm.delete\":\n return await this.handleLLMDelete(params);\n case \"llm.default\":\n return await this.handleLLMDefault(params);\n\n default:\n return err(-32601, `Method not found: ${method}`);\n }\n } catch (error) {\n logger.error(\"RPC handler error\", { method, error });\n return err(-32000, error instanceof Error ? error.message : String(error));\n }\n }\n\n // ==================== Container Commands ====================\n\n private async handleContainerCreate(params: unknown): Promise<RpcResponse> {\n const { containerId } = params as { containerId: string };\n const { getOrCreateContainer } = await import(\"@agentxjs/core/container\");\n const { containerRepository, imageRepository, sessionRepository } = this.runtime.platform;\n\n const container = await getOrCreateContainer(containerId, {\n containerRepository,\n imageRepository,\n sessionRepository,\n });\n\n return ok({ containerId: container.containerId });\n }\n\n private async handleContainerGet(params: unknown): Promise<RpcResponse> {\n const { containerId } = params as { containerId: string };\n const exists = await this.runtime.platform.containerRepository.containerExists(containerId);\n return ok({ containerId, exists });\n }\n\n private async handleContainerList(_params: unknown): Promise<RpcResponse> {\n const containers = await this.runtime.platform.containerRepository.findAllContainers();\n return ok({ containerIds: containers.map((c) => c.containerId) });\n }\n\n // ==================== Image Commands ====================\n\n private async handleImageCreate(params: unknown): Promise<RpcResponse> {\n const { containerId, name, description, contextId, embody, customData } = params as {\n containerId: string;\n name?: string;\n description?: string;\n contextId?: string;\n embody?: import(\"@agentxjs/core/persistence\").Embodiment;\n customData?: Record<string, unknown>;\n };\n\n const { imageRepository, sessionRepository } = this.runtime.platform;\n const { createImage } = await import(\"@agentxjs/core/image\");\n\n const image = await createImage(\n { containerId, name, description, contextId, embody, customData },\n { imageRepository, sessionRepository }\n );\n\n return ok({\n record: image.toRecord(),\n __subscriptions: [image.sessionId],\n });\n }\n\n private async handleImageGet(params: unknown): Promise<RpcResponse> {\n const { imageId } = params as { imageId: string };\n const record = await this.runtime.platform.imageRepository.findImageById(imageId);\n return ok({\n record,\n __subscriptions: record?.sessionId ? [record.sessionId] : undefined,\n });\n }\n\n private async handleImageList(params: unknown): Promise<RpcResponse> {\n const { containerId } = params as { containerId?: string };\n const records = containerId\n ? await this.runtime.platform.imageRepository.findImagesByContainerId(containerId)\n : await this.runtime.platform.imageRepository.findAllImages();\n\n return ok({\n records,\n __subscriptions: records.map((r) => r.sessionId),\n });\n }\n\n private async handleImageDelete(params: unknown): Promise<RpcResponse> {\n const { imageId } = params as { imageId: string };\n const { loadImage } = await import(\"@agentxjs/core/image\");\n const { imageRepository, sessionRepository } = this.runtime.platform;\n\n const image = await loadImage(imageId, { imageRepository, sessionRepository });\n if (image) {\n await image.delete();\n }\n\n return ok({ imageId });\n }\n\n private async handleImageRun(params: unknown): Promise<RpcResponse> {\n const { imageId, instanceId: requestedInstanceId } = params as {\n imageId: string;\n instanceId?: string;\n };\n\n // Check if already have a running agent for this image\n const existingAgent = this.runtime\n .getAgents()\n .find((a) => a.imageId === imageId && a.lifecycle === \"running\");\n\n if (existingAgent) {\n logger.debug(\"Reusing existing agent for image\", {\n imageId,\n instanceId: existingAgent.instanceId,\n });\n return ok({\n imageId,\n instanceId: existingAgent.instanceId,\n sessionId: existingAgent.sessionId,\n containerId: existingAgent.containerId,\n reused: true,\n });\n }\n\n // Create new agent (with optional custom instanceId)\n const agent = await this.runtime.createAgent({\n imageId,\n instanceId: requestedInstanceId,\n });\n logger.info(\"Created new agent for image\", {\n imageId,\n instanceId: agent.instanceId,\n });\n\n return ok({\n imageId,\n instanceId: agent.instanceId,\n sessionId: agent.sessionId,\n containerId: agent.containerId,\n reused: false,\n });\n }\n\n private async handleImageStop(params: unknown): Promise<RpcResponse> {\n const { imageId } = params as { imageId: string };\n\n // Find running agent for this image\n const agent = this.runtime\n .getAgents()\n .find((a) => a.imageId === imageId && a.lifecycle === \"running\");\n\n if (agent) {\n await this.runtime.stopAgent(agent.instanceId);\n logger.info(\"Stopped agent for image\", { imageId, instanceId: agent.instanceId });\n } else {\n logger.debug(\"No running agent found for image\", { imageId });\n }\n\n return ok({ imageId });\n }\n\n private async handleImageUpdate(params: unknown): Promise<RpcResponse> {\n const { imageId, updates } = params as {\n imageId: string;\n updates: {\n name?: string;\n description?: string;\n embody?: import(\"@agentxjs/core/persistence\").Embodiment;\n customData?: Record<string, unknown>;\n };\n };\n\n // Get existing image\n const imageRecord = await this.runtime.platform.imageRepository.findImageById(imageId);\n if (!imageRecord) {\n return err(404, `Image not found: ${imageId}`);\n }\n\n // Update image record (embody is merged, not replaced)\n const { embody: embodyUpdates, ...otherUpdates } = updates;\n const updatedRecord = {\n ...imageRecord,\n ...otherUpdates,\n embody: embodyUpdates ? { ...imageRecord.embody, ...embodyUpdates } : imageRecord.embody,\n updatedAt: Date.now(),\n };\n\n await this.runtime.platform.imageRepository.saveImage(updatedRecord);\n\n logger.info(\"Updated image\", { imageId, updates });\n\n return ok({ record: updatedRecord });\n }\n\n private async handleImageMessages(params: unknown): Promise<RpcResponse> {\n const { imageId } = params as { imageId: string };\n\n // Get image record to find sessionId\n const imageRecord = await this.runtime.platform.imageRepository.findImageById(imageId);\n if (!imageRecord) {\n return err(404, `Image not found: ${imageId}`);\n }\n\n // Get messages from session\n const messages = await this.runtime.platform.sessionRepository.getMessages(\n imageRecord.sessionId\n );\n\n logger.debug(\"Got messages for image\", { imageId, count: messages.length });\n\n return ok({ imageId, messages });\n }\n\n // ==================== Agent Commands ====================\n\n private async handleAgentGet(params: unknown): Promise<RpcResponse> {\n const { instanceId } = params as { instanceId: string };\n const agent = this.runtime.getAgent(instanceId);\n\n return ok({\n agent: agent\n ? {\n instanceId: agent.instanceId,\n imageId: agent.imageId,\n containerId: agent.containerId,\n sessionId: agent.sessionId,\n lifecycle: agent.lifecycle,\n }\n : null,\n exists: !!agent,\n });\n }\n\n private async handleAgentList(params: unknown): Promise<RpcResponse> {\n const { containerId } = params as { containerId?: string };\n const agents = containerId\n ? this.runtime.getAgentsByContainer(containerId)\n : this.runtime.getAgents();\n\n return ok({\n agents: agents.map((a) => ({\n instanceId: a.instanceId,\n imageId: a.imageId,\n containerId: a.containerId,\n sessionId: a.sessionId,\n lifecycle: a.lifecycle,\n })),\n });\n }\n\n private async handleAgentDestroy(params: unknown): Promise<RpcResponse> {\n const { instanceId } = params as { instanceId: string };\n\n // Check if agent exists first\n const agent = this.runtime.getAgent(instanceId);\n if (!agent) {\n return ok({ instanceId, success: false });\n }\n\n await this.runtime.destroyAgent(instanceId);\n return ok({ instanceId, success: true });\n }\n\n private async handleAgentDestroyAll(params: unknown): Promise<RpcResponse> {\n const { containerId } = params as { containerId: string };\n const agents = this.runtime.getAgentsByContainer(containerId);\n for (const agent of agents) {\n await this.runtime.destroyAgent(agent.instanceId);\n }\n return ok({ containerId });\n }\n\n private async handleAgentInterrupt(params: unknown): Promise<RpcResponse> {\n const { instanceId } = params as { instanceId: string };\n this.runtime.interrupt(instanceId);\n return ok({ instanceId });\n }\n\n // ==================== Message Commands ====================\n\n private async handleMessageSend(params: unknown): Promise<RpcResponse> {\n const { instanceId, imageId, content } = params as {\n instanceId?: string;\n imageId?: string;\n content: string | UserContentPart[];\n };\n\n let targetInstanceId: string;\n\n if (instanceId) {\n // Direct agent reference\n targetInstanceId = instanceId;\n } else if (imageId) {\n // Auto-activate image: find or create agent\n const existingAgent = this.runtime\n .getAgents()\n .find((a) => a.imageId === imageId && a.lifecycle === \"running\");\n\n if (existingAgent) {\n targetInstanceId = existingAgent.instanceId;\n logger.debug(\"Using existing agent for message\", {\n imageId,\n instanceId: targetInstanceId,\n });\n } else {\n // Create new agent for this image\n const agent = await this.runtime.createAgent({ imageId });\n targetInstanceId = agent.instanceId;\n logger.info(\"Auto-created agent for message\", {\n imageId,\n instanceId: targetInstanceId,\n });\n }\n } else {\n return err(-32602, \"Either instanceId or imageId is required\");\n }\n\n await this.runtime.receive(targetInstanceId, content);\n return ok({ instanceId: targetInstanceId, imageId });\n }\n\n // ==================== Prototype Commands ====================\n\n private async handlePrototypeCreate(params: unknown): Promise<RpcResponse> {\n const { containerId, name, description, contextId, embody, customData } = params as {\n containerId: string;\n name: string;\n description?: string;\n contextId?: string;\n embody?: import(\"@agentxjs/core/persistence\").Embodiment;\n customData?: Record<string, unknown>;\n };\n\n const repo = this.runtime.platform.prototypeRepository;\n if (!repo) {\n return err(-32000, \"Prototype repository not available\");\n }\n\n const now = Date.now();\n const random = Math.random().toString(36).slice(2, 8);\n const record = {\n prototypeId: `proto_${now}_${random}`,\n containerId,\n name,\n description,\n contextId,\n embody,\n customData,\n createdAt: now,\n updatedAt: now,\n };\n\n await repo.savePrototype(record);\n return ok({ record });\n }\n\n private async handlePrototypeGet(params: unknown): Promise<RpcResponse> {\n const { prototypeId } = params as { prototypeId: string };\n const repo = this.runtime.platform.prototypeRepository;\n if (!repo) {\n return err(-32000, \"Prototype repository not available\");\n }\n\n const record = await repo.findPrototypeById(prototypeId);\n return ok({ record });\n }\n\n private async handlePrototypeList(params: unknown): Promise<RpcResponse> {\n const { containerId } = params as { containerId?: string };\n const repo = this.runtime.platform.prototypeRepository;\n if (!repo) {\n return err(-32000, \"Prototype repository not available\");\n }\n\n const records = containerId\n ? await repo.findPrototypesByContainerId(containerId)\n : await repo.findAllPrototypes();\n\n return ok({ records });\n }\n\n private async handlePrototypeUpdate(params: unknown): Promise<RpcResponse> {\n const { prototypeId, updates } = params as {\n prototypeId: string;\n updates: {\n name?: string;\n description?: string;\n contextId?: string;\n embody?: import(\"@agentxjs/core/persistence\").Embodiment;\n customData?: Record<string, unknown>;\n };\n };\n\n const repo = this.runtime.platform.prototypeRepository;\n if (!repo) {\n return err(-32000, \"Prototype repository not available\");\n }\n\n const existing = await repo.findPrototypeById(prototypeId);\n if (!existing) {\n return err(404, `Prototype not found: ${prototypeId}`);\n }\n\n const { embody: embodyUpdates, ...otherUpdates } = updates;\n const updated = {\n ...existing,\n ...otherUpdates,\n embody: embodyUpdates ? { ...existing.embody, ...embodyUpdates } : existing.embody,\n updatedAt: Date.now(),\n };\n\n await repo.savePrototype(updated);\n return ok({ record: updated });\n }\n\n private async handlePrototypeDelete(params: unknown): Promise<RpcResponse> {\n const { prototypeId } = params as { prototypeId: string };\n const repo = this.runtime.platform.prototypeRepository;\n if (!repo) {\n return err(-32000, \"Prototype repository not available\");\n }\n\n await repo.deletePrototype(prototypeId);\n return ok({ prototypeId });\n }\n\n // ==================== LLM Provider Commands ====================\n\n private async handleLLMCreate(params: unknown): Promise<RpcResponse> {\n const { containerId, name, vendor, protocol, apiKey, baseUrl, model } = params as {\n containerId: string;\n name: string;\n vendor: string;\n protocol: string;\n apiKey: string;\n baseUrl?: string;\n model?: string;\n };\n\n const repo = this.runtime.platform.llmProviderRepository;\n if (!repo) {\n return err(-32000, \"LLM provider repository not available\");\n }\n\n const { generateId } = await import(\"@deepracticex/id\");\n const now = Date.now();\n const record = {\n id: generateId(\"llm\"),\n containerId,\n name,\n vendor,\n protocol: protocol as \"anthropic\" | \"openai\",\n apiKey,\n baseUrl,\n model,\n isDefault: false,\n createdAt: now,\n updatedAt: now,\n };\n\n await repo.saveLLMProvider(record);\n return ok({ record });\n }\n\n private async handleLLMGet(params: unknown): Promise<RpcResponse> {\n const { id } = params as { id: string };\n const repo = this.runtime.platform.llmProviderRepository;\n if (!repo) {\n return err(-32000, \"LLM provider repository not available\");\n }\n\n const record = await repo.findLLMProviderById(id);\n return ok({ record });\n }\n\n private async handleLLMList(params: unknown): Promise<RpcResponse> {\n const { containerId } = params as { containerId: string };\n const repo = this.runtime.platform.llmProviderRepository;\n if (!repo) {\n return err(-32000, \"LLM provider repository not available\");\n }\n\n const records = await repo.findLLMProvidersByContainerId(containerId);\n return ok({ records });\n }\n\n private async handleLLMUpdate(params: unknown): Promise<RpcResponse> {\n const { id, updates } = params as {\n id: string;\n updates: Record<string, unknown>;\n };\n const repo = this.runtime.platform.llmProviderRepository;\n if (!repo) {\n return err(-32000, \"LLM provider repository not available\");\n }\n\n const existing = await repo.findLLMProviderById(id);\n if (!existing) {\n return err(404, `LLM provider not found: ${id}`);\n }\n\n const updated = {\n ...existing,\n ...updates,\n id: existing.id,\n containerId: existing.containerId,\n createdAt: existing.createdAt,\n updatedAt: Date.now(),\n };\n\n await repo.saveLLMProvider(updated);\n return ok({ record: updated });\n }\n\n private async handleLLMDelete(params: unknown): Promise<RpcResponse> {\n const { id } = params as { id: string };\n const repo = this.runtime.platform.llmProviderRepository;\n if (!repo) {\n return err(-32000, \"LLM provider repository not available\");\n }\n\n await repo.deleteLLMProvider(id);\n return ok({ id });\n }\n\n private async handleLLMDefault(params: unknown): Promise<RpcResponse> {\n const { id, containerId } = params as { id?: string; containerId?: string };\n const repo = this.runtime.platform.llmProviderRepository;\n if (!repo) {\n return err(-32000, \"LLM provider repository not available\");\n }\n\n if (id) {\n // Set default\n await repo.setDefaultLLMProvider(id);\n return ok({ id });\n }\n if (containerId) {\n // Get default\n const record = await repo.findDefaultLLMProvider(containerId);\n return ok({ record });\n }\n return err(-32602, \"Either id or containerId is required\");\n }\n\n // ==================== Lifecycle ====================\n\n dispose(): void {\n logger.debug(\"CommandHandler disposed\");\n }\n}\n"],"mappings":";AAgBA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,2BAA2B;AACpC,SAAS,gBAAAA,qBAAoB;;;AChB7B,SAAS,oBAAoB;AAE7B,IAAM,SAAS,aAAa,uBAAuB;AAqBnD,SAAS,GAAM,MAAuB;AACpC,SAAO,EAAE,SAAS,MAAM,KAAK;AAC/B;AAKA,SAAS,IAAI,MAAc,SAA2B;AACpD,SAAO,EAAE,SAAS,OAAO,MAAM,QAAQ;AACzC;AAKO,IAAM,iBAAN,MAAqB;AAAA,EACT;AAAA,EAEjB,YAAY,S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A,EACF;AACF;","names":["createLogger","logger","createLogger","err"]}
package/dist/index.d.ts CHANGED
@@ -134,12 +134,12 @@ interface PresentationOptions {
134
134
  */
135
135
  declare class Presentation {
136
136
  private agentx;
137
- private agentId;
137
+ private instanceId;
138
138
  private state;
139
139
  private updateHandlers;
140
140
  private errorHandlers;
141
141
  private eventUnsubscribe;
142
- constructor(agentx: AgentX, agentId: string, options?: PresentationOptions, initialConversations?: Conversation[]);
142
+ constructor(agentx: AgentX, instanceId: string, options?: PresentationOptions, initialConversations?: Conversation[]);
143
143
  /**
144
144
  * Get current state
145
145
  */
@@ -222,8 +222,8 @@ type MaybeAsync<T> = T | (() => T) | (() => Promise<T>);
222
222
  /**
223
223
  * Agent info returned from server
224
224
  */
225
- interface AgentInfo {
226
- agentId: string;
225
+ interface InstanceInfo {
226
+ instanceId: string;
227
227
  imageId: string;
228
228
  containerId: string;
229
229
  sessionId: string;
@@ -272,8 +272,8 @@ interface BaseResponse {
272
272
  /**
273
273
  * Agent create response
274
274
  */
275
- interface AgentCreateResponse extends BaseResponse {
276
- agentId: string;
275
+ interface InstanceCreateResponse extends BaseResponse {
276
+ instanceId: string;
277
277
  imageId: string;
278
278
  containerId: string;
279
279
  sessionId: string;
@@ -281,15 +281,15 @@ interface AgentCreateResponse extends BaseResponse {
281
281
  /**
282
282
  * Agent get response
283
283
  */
284
- interface AgentGetResponse extends BaseResponse {
285
- agent: AgentInfo | null;
284
+ interface InstanceGetResponse extends BaseResponse {
285
+ agent: InstanceInfo | null;
286
286
  exists: boolean;
287
287
  }
288
288
  /**
289
289
  * Agent list response
290
290
  */
291
- interface AgentListResponse extends BaseResponse {
292
- agents: AgentInfo[];
291
+ interface InstanceListResponse extends BaseResponse {
292
+ agents: InstanceInfo[];
293
293
  }
294
294
  /**
295
295
  * Image create response
@@ -341,7 +341,7 @@ interface ContainerListResponse extends BaseResponse {
341
341
  * Message send response
342
342
  */
343
343
  interface MessageSendResponse extends BaseResponse {
344
- agentId: string;
344
+ instanceId: string;
345
345
  }
346
346
  /**
347
347
  * LLM provider create response
@@ -458,26 +458,26 @@ interface ImageNamespace {
458
458
  /**
459
459
  * Agent operations namespace
460
460
  */
461
- interface AgentNamespace {
461
+ interface InstanceNamespace {
462
462
  /**
463
463
  * Create a new agent
464
464
  */
465
465
  create(params: {
466
466
  imageId: string;
467
- agentId?: string;
468
- }): Promise<AgentCreateResponse>;
467
+ instanceId?: string;
468
+ }): Promise<InstanceCreateResponse>;
469
469
  /**
470
470
  * Get agent by ID
471
471
  */
472
- get(agentId: string): Promise<AgentGetResponse>;
472
+ get(instanceId: string): Promise<InstanceGetResponse>;
473
473
  /**
474
474
  * List agents
475
475
  */
476
- list(containerId?: string): Promise<AgentListResponse>;
476
+ list(containerId?: string): Promise<InstanceListResponse>;
477
477
  /**
478
478
  * Destroy an agent
479
479
  */
480
- destroy(agentId: string): Promise<BaseResponse>;
480
+ destroy(instanceId: string): Promise<BaseResponse>;
481
481
  }
482
482
  /**
483
483
  * Session operations namespace (messaging)
@@ -486,15 +486,15 @@ interface SessionNamespace {
486
486
  /**
487
487
  * Send message to agent
488
488
  */
489
- send(agentId: string, content: string | unknown[]): Promise<MessageSendResponse>;
489
+ send(instanceId: string, content: string | unknown[]): Promise<MessageSendResponse>;
490
490
  /**
491
491
  * Interrupt agent
492
492
  */
493
- interrupt(agentId: string): Promise<BaseResponse>;
493
+ interrupt(instanceId: string): Promise<BaseResponse>;
494
494
  /**
495
495
  * Get message history for an agent's session
496
496
  */
497
- getMessages(agentId: string): Promise<Message[]>;
497
+ getMessages(instanceId: string): Promise<Message[]>;
498
498
  }
499
499
  /**
500
500
  * LLM provider operations namespace
@@ -591,7 +591,7 @@ interface PresentationNamespace {
591
591
  *
592
592
  * @example
593
593
  * ```typescript
594
- * const pres = ax.present(agentId, {
594
+ * const pres = ax.present(instanceId, {
595
595
  * onUpdate: (state) => renderUI(state),
596
596
  * onError: (error) => console.error(error),
597
597
  * });
@@ -600,7 +600,7 @@ interface PresentationNamespace {
600
600
  * pres.dispose();
601
601
  * ```
602
602
  */
603
- create(agentId: string, options?: PresentationOptions): Promise<Presentation>;
603
+ create(instanceId: string, options?: PresentationOptions): Promise<Presentation>;
604
604
  }
605
605
  /**
606
606
  * Instance — low-level access to internal subsystems.
@@ -612,7 +612,7 @@ interface PresentationNamespace {
612
612
  interface RuntimeNamespace {
613
613
  readonly container: ContainerNamespace;
614
614
  readonly image: ImageNamespace;
615
- readonly agent: AgentNamespace;
615
+ readonly instance: InstanceNamespace;
616
616
  readonly session: SessionNamespace;
617
617
  readonly present: PresentationNamespace;
618
618
  readonly llm: LLMNamespace;
@@ -632,7 +632,7 @@ interface RuntimeNamespace {
632
632
  * ```
633
633
  */
634
634
  interface AgentHandle {
635
- readonly agentId: string;
635
+ readonly instanceId: string;
636
636
  readonly imageId: string;
637
637
  readonly containerId: string;
638
638
  readonly sessionId: string;
@@ -957,4 +957,4 @@ interface PlatformConfig {
957
957
  */
958
958
  declare function createAgentX(config?: PlatformConfig): AgentXBuilder;
959
959
 
960
- export { type AgentCreateResponse, type AgentGetResponse, type AgentHandle, type AgentInfo, type AgentListResponse, type AgentNamespace, type AgentX, type AgentXBuilder, type AgentXServer, type AssistantConversation, type BaseResponse, type Block, type ChatNamespace, CommandHandler, type ConnectOptions, type ContainerCreateResponse, type ContainerGetResponse, type ContainerInfo, type ContainerListResponse, type ContainerNamespace, type Conversation, type Embodiment, type ErrorConversation, type ImageBlock, type ImageCreateResponse, type ImageGetResponse, type ImageListResponse, type ImageNamespace, type ImageRecord, type LLMNamespace, type LLMProviderCreateResponse, type LLMProviderDefaultResponse, type LLMProviderGetResponse, type LLMProviderListResponse, type LLMProviderUpdateResponse, type MaybeAsync, type MessageSendResponse, type PlatformConfig, Presentation, type PresentationErrorHandler, type PresentationNamespace, type PresentationOptions, type PresentationState, type PresentationUpdateHandler, type PrototypeCreateResponse, type PrototypeGetResponse, type PrototypeListResponse, type PrototypeNamespace, type PrototypeUpdateResponse, type RuntimeNamespace, type ServeConfig, type ServerConfig, type SessionNamespace, type TextBlock, type ToolBlock, type UserConversation, addUserConversation, createAgentX, createInitialState, createServer, initialPresentationState, messagesToConversations, presentationReducer };
960
+ export { type AgentHandle, type AgentX, type AgentXBuilder, type AgentXServer, type AssistantConversation, type BaseResponse, type Block, type ChatNamespace, CommandHandler, type ConnectOptions, type ContainerCreateResponse, type ContainerGetResponse, type ContainerInfo, type ContainerListResponse, type ContainerNamespace, type Conversation, type Embodiment, type ErrorConversation, type ImageBlock, type ImageCreateResponse, type ImageGetResponse, type ImageListResponse, type ImageNamespace, type ImageRecord, type InstanceCreateResponse, type InstanceGetResponse, type InstanceInfo, type InstanceListResponse, type InstanceNamespace, type LLMNamespace, type LLMProviderCreateResponse, type LLMProviderDefaultResponse, type LLMProviderGetResponse, type LLMProviderListResponse, type LLMProviderUpdateResponse, type MaybeAsync, type MessageSendResponse, type PlatformConfig, Presentation, type PresentationErrorHandler, type PresentationNamespace, type PresentationOptions, type PresentationState, type PresentationUpdateHandler, type PrototypeCreateResponse, type PrototypeGetResponse, type PrototypeListResponse, type PrototypeNamespace, type PrototypeUpdateResponse, type RuntimeNamespace, type ServeConfig, type ServerConfig, type SessionNamespace, type TextBlock, type ToolBlock, type UserConversation, addUserConversation, createAgentX, createInitialState, createServer, initialPresentationState, messagesToConversations, presentationReducer };