agentxjs 2.5.0 → 2.6.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 +22 -12
- package/dist/{chunk-7GW66EMD.js → chunk-JTHR3AK6.js} +82 -1
- package/dist/chunk-JTHR3AK6.js.map +1 -0
- package/dist/index.d.ts +112 -24
- package/dist/index.js +243 -90
- package/dist/index.js.map +1 -1
- package/dist/server-UCQISBKH.js +7 -0
- package/package.json +3 -3
- package/src/AgentHandle.ts +3 -3
- package/src/CommandHandler.ts +117 -0
- package/src/LocalClient.ts +79 -60
- package/src/RemoteClient.ts +67 -48
- package/src/index.ts +17 -8
- package/src/namespaces/prototypes.ts +136 -0
- package/src/presentation/Presentation.ts +2 -2
- package/src/types.ts +130 -23
- package/dist/chunk-7GW66EMD.js.map +0 -1
- package/dist/server-55XTEGMF.js +0 -7
- /package/dist/{server-55XTEGMF.js.map → server-UCQISBKH.js.map} +0 -0
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ const createDriver = (config) => createMonoDriver({
|
|
|
21
21
|
|
|
22
22
|
const ax = createAgentX(nodePlatform({ createDriver }));
|
|
23
23
|
|
|
24
|
-
const agent = await ax.create({
|
|
24
|
+
const agent = await ax.chat.create({
|
|
25
25
|
name: "My Assistant",
|
|
26
26
|
embody: { systemPrompt: "You are a helpful assistant." },
|
|
27
27
|
});
|
|
@@ -40,7 +40,7 @@ import { createAgentX } from "agentxjs";
|
|
|
40
40
|
const ax = createAgentX();
|
|
41
41
|
const client = await ax.connect("ws://localhost:5200");
|
|
42
42
|
|
|
43
|
-
const agent = await client.create({
|
|
43
|
+
const agent = await client.chat.create({
|
|
44
44
|
name: "My Assistant",
|
|
45
45
|
embody: { systemPrompt: "You are a helpful assistant." },
|
|
46
46
|
});
|
|
@@ -77,13 +77,11 @@ interface AgentX {
|
|
|
77
77
|
readonly connected: boolean;
|
|
78
78
|
readonly events: EventBus;
|
|
79
79
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
list(): Promise<ImageListResponse>;
|
|
83
|
-
get(agentId: string): Promise<AgentHandle | null>;
|
|
80
|
+
// Conversation management
|
|
81
|
+
readonly chat: ChatNamespace;
|
|
84
82
|
|
|
85
83
|
// Low-level subsystems
|
|
86
|
-
readonly
|
|
84
|
+
readonly runtime: RuntimeNamespace;
|
|
87
85
|
|
|
88
86
|
// LLM provider management (system-level)
|
|
89
87
|
readonly provider: LLMNamespace;
|
|
@@ -110,9 +108,21 @@ interface AgentXBuilder extends AgentX {
|
|
|
110
108
|
}
|
|
111
109
|
```
|
|
112
110
|
|
|
111
|
+
### ChatNamespace
|
|
112
|
+
|
|
113
|
+
Conversation management — create, list, and open conversations:
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
interface ChatNamespace {
|
|
117
|
+
create(params: { name?, description?, contextId?, embody?, customData? }): Promise<AgentHandle>;
|
|
118
|
+
list(): Promise<ImageListResponse>;
|
|
119
|
+
get(id: string): Promise<AgentHandle | null>;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
113
123
|
### AgentHandle
|
|
114
124
|
|
|
115
|
-
Returned by `create()` and `get()`. A live reference to
|
|
125
|
+
Returned by `chat.create()` and `chat.get()`. A live reference to a conversation with agent operations.
|
|
116
126
|
|
|
117
127
|
```typescript
|
|
118
128
|
interface AgentHandle {
|
|
@@ -130,9 +140,9 @@ interface AgentHandle {
|
|
|
130
140
|
}
|
|
131
141
|
```
|
|
132
142
|
|
|
133
|
-
###
|
|
143
|
+
### Runtime Namespace (low-level)
|
|
134
144
|
|
|
135
|
-
For advanced use cases, access `ax.
|
|
145
|
+
For advanced use cases, access `ax.runtime.*` for direct subsystem operations:
|
|
136
146
|
|
|
137
147
|
**container**:
|
|
138
148
|
|
|
@@ -197,10 +207,10 @@ Model priority: `embody.model > container default provider > environment variabl
|
|
|
197
207
|
Transport-agnostic JSON-RPC entry point. Works in all modes — local dispatches to CommandHandler, remote forwards via WebSocket.
|
|
198
208
|
|
|
199
209
|
```typescript
|
|
200
|
-
// Equivalent to ax.
|
|
210
|
+
// Equivalent to ax.runtime.container.create("default")
|
|
201
211
|
await ax.rpc("container.create", { containerId: "default" });
|
|
202
212
|
|
|
203
|
-
// Equivalent to ax.
|
|
213
|
+
// Equivalent to ax.runtime.image.list()
|
|
204
214
|
const { records } = await ax.rpc<{ records: ImageRecord[] }>("image.list");
|
|
205
215
|
|
|
206
216
|
// Useful for custom transport (e.g. Cloudflare Workers/DO)
|
|
@@ -71,6 +71,17 @@ var CommandHandler = class {
|
|
|
71
71
|
// Message
|
|
72
72
|
case "message.send":
|
|
73
73
|
return await this.handleMessageSend(params);
|
|
74
|
+
// Prototype
|
|
75
|
+
case "prototype.create":
|
|
76
|
+
return await this.handlePrototypeCreate(params);
|
|
77
|
+
case "prototype.get":
|
|
78
|
+
return await this.handlePrototypeGet(params);
|
|
79
|
+
case "prototype.list":
|
|
80
|
+
return await this.handlePrototypeList(params);
|
|
81
|
+
case "prototype.update":
|
|
82
|
+
return await this.handlePrototypeUpdate(params);
|
|
83
|
+
case "prototype.delete":
|
|
84
|
+
return await this.handlePrototypeDelete(params);
|
|
74
85
|
// LLM Provider
|
|
75
86
|
case "llm.create":
|
|
76
87
|
return await this.handleLLMCreate(params);
|
|
@@ -303,6 +314,76 @@ var CommandHandler = class {
|
|
|
303
314
|
await this.runtime.receive(targetAgentId, content);
|
|
304
315
|
return ok({ agentId: targetAgentId, imageId });
|
|
305
316
|
}
|
|
317
|
+
// ==================== Prototype Commands ====================
|
|
318
|
+
async handlePrototypeCreate(params) {
|
|
319
|
+
const { containerId, name, description, contextId, embody, customData } = params;
|
|
320
|
+
const repo = this.runtime.platform.prototypeRepository;
|
|
321
|
+
if (!repo) {
|
|
322
|
+
return err(-32e3, "Prototype repository not available");
|
|
323
|
+
}
|
|
324
|
+
const now = Date.now();
|
|
325
|
+
const random = Math.random().toString(36).slice(2, 8);
|
|
326
|
+
const record = {
|
|
327
|
+
prototypeId: `proto_${now}_${random}`,
|
|
328
|
+
containerId,
|
|
329
|
+
name,
|
|
330
|
+
description,
|
|
331
|
+
contextId,
|
|
332
|
+
embody,
|
|
333
|
+
customData,
|
|
334
|
+
createdAt: now,
|
|
335
|
+
updatedAt: now
|
|
336
|
+
};
|
|
337
|
+
await repo.savePrototype(record);
|
|
338
|
+
return ok({ record });
|
|
339
|
+
}
|
|
340
|
+
async handlePrototypeGet(params) {
|
|
341
|
+
const { prototypeId } = params;
|
|
342
|
+
const repo = this.runtime.platform.prototypeRepository;
|
|
343
|
+
if (!repo) {
|
|
344
|
+
return err(-32e3, "Prototype repository not available");
|
|
345
|
+
}
|
|
346
|
+
const record = await repo.findPrototypeById(prototypeId);
|
|
347
|
+
return ok({ record });
|
|
348
|
+
}
|
|
349
|
+
async handlePrototypeList(params) {
|
|
350
|
+
const { containerId } = params;
|
|
351
|
+
const repo = this.runtime.platform.prototypeRepository;
|
|
352
|
+
if (!repo) {
|
|
353
|
+
return err(-32e3, "Prototype repository not available");
|
|
354
|
+
}
|
|
355
|
+
const records = containerId ? await repo.findPrototypesByContainerId(containerId) : await repo.findAllPrototypes();
|
|
356
|
+
return ok({ records });
|
|
357
|
+
}
|
|
358
|
+
async handlePrototypeUpdate(params) {
|
|
359
|
+
const { prototypeId, updates } = params;
|
|
360
|
+
const repo = this.runtime.platform.prototypeRepository;
|
|
361
|
+
if (!repo) {
|
|
362
|
+
return err(-32e3, "Prototype repository not available");
|
|
363
|
+
}
|
|
364
|
+
const existing = await repo.findPrototypeById(prototypeId);
|
|
365
|
+
if (!existing) {
|
|
366
|
+
return err(404, `Prototype not found: ${prototypeId}`);
|
|
367
|
+
}
|
|
368
|
+
const { embody: embodyUpdates, ...otherUpdates } = updates;
|
|
369
|
+
const updated = {
|
|
370
|
+
...existing,
|
|
371
|
+
...otherUpdates,
|
|
372
|
+
embody: embodyUpdates ? { ...existing.embody, ...embodyUpdates } : existing.embody,
|
|
373
|
+
updatedAt: Date.now()
|
|
374
|
+
};
|
|
375
|
+
await repo.savePrototype(updated);
|
|
376
|
+
return ok({ record: updated });
|
|
377
|
+
}
|
|
378
|
+
async handlePrototypeDelete(params) {
|
|
379
|
+
const { prototypeId } = params;
|
|
380
|
+
const repo = this.runtime.platform.prototypeRepository;
|
|
381
|
+
if (!repo) {
|
|
382
|
+
return err(-32e3, "Prototype repository not available");
|
|
383
|
+
}
|
|
384
|
+
await repo.deletePrototype(prototypeId);
|
|
385
|
+
return ok({ prototypeId });
|
|
386
|
+
}
|
|
306
387
|
// ==================== LLM Provider Commands ====================
|
|
307
388
|
async handleLLMCreate(params) {
|
|
308
389
|
const { containerId, name, vendor, protocol, apiKey, baseUrl, model } = params;
|
|
@@ -568,4 +649,4 @@ export {
|
|
|
568
649
|
CommandHandler,
|
|
569
650
|
createServer
|
|
570
651
|
};
|
|
571
|
-
//# sourceMappingURL=chunk-
|
|
652
|
+
//# sourceMappingURL=chunk-JTHR3AK6.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 // Agent\n case \"agent.get\":\n return await this.handleAgentGet(params);\n case \"agent.list\":\n return await this.handleAgentList(params);\n case \"agent.destroy\":\n return await this.handleAgentDestroy(params);\n case \"agent.destroyAll\":\n return await this.handleAgentDestroyAll(params);\n case \"agent.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, agentId: requestedAgentId } = params as {\n imageId: string;\n agentId?: 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 agentId: existingAgent.agentId,\n });\n return ok({\n imageId,\n agentId: existingAgent.agentId,\n sessionId: existingAgent.sessionId,\n containerId: existingAgent.containerId,\n reused: true,\n });\n }\n\n // Create new agent (with optional custom agentId)\n const agent = await this.runtime.createAgent({\n imageId,\n agentId: requestedAgentId,\n });\n logger.info(\"Created new agent for image\", {\n imageId,\n agentId: agent.agentId,\n });\n\n return ok({\n imageId,\n agentId: agent.agentId,\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.agentId);\n logger.info(\"Stopped agent for image\", { imageId, agentId: agent.agentId });\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 { agentId } = params as { agentId: string };\n const agent = this.runtime.getAgent(agentId);\n\n return ok({\n agent: agent\n ? {\n agentId: agent.agentId,\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 agentId: a.agentId,\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 { agentId } = params as { agentId: string };\n\n // Check if agent exists first\n const agent = this.runtime.getAgent(agentId);\n if (!agent) {\n return ok({ agentId, success: false });\n }\n\n await this.runtime.destroyAgent(agentId);\n return ok({ agentId, 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.agentId);\n }\n return ok({ containerId });\n }\n\n private async handleAgentInterrupt(params: unknown): Promise<RpcResponse> {\n const { agentId } = params as { agentId: string };\n this.runtime.interrupt(agentId);\n return ok({ agentId });\n }\n\n // ==================== Message Commands ====================\n\n private async handleMessageSend(params: unknown): Promise<RpcResponse> {\n const { agentId, imageId, content } = params as {\n agentId?: string;\n imageId?: string;\n content: string | UserContentPart[];\n };\n\n let targetAgentId: string;\n\n if (agentId) {\n // Direct agent reference\n targetAgentId = agentId;\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 targetAgentId = existingAgent.agentId;\n logger.debug(\"Using existing agent for message\", {\n imageId,\n agentId: targetAgentId,\n });\n } else {\n // Create new agent for this image\n const agent = await this.runtime.createAgent({ imageId });\n targetAgentId = agent.agentId;\n logger.info(\"Auto-created agent for message\", {\n imageId,\n agentId: targetAgentId,\n });\n }\n } else {\n return err(-32602, \"Either agentId or imageId is required\");\n }\n\n await this.runtime.receive(targetAgentId, content);\n return ok({ agentId: targetAgentId, 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,SAAwB;AAClC,SAAK,UAAU;AACf,WAAO,MAAM,wBAAwB;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAO,QAAmB,QAAuC;AACrE,WAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC;AAE/C,QAAI;AACF,cAAQ,QAAQ;AAAA;AAAA,QAEd,KAAK;AACH,iBAAO,MAAM,KAAK,sBAAsB,MAAM;AAAA,QAChD,KAAK;AACH,iBAAO,MAAM,KAAK,mBAAmB,MAAM;AAAA,QAC7C,KAAK;AACH,iBAAO,MAAM,KAAK,oBAAoB,MAAM;AAAA;AAAA,QAG9C,KAAK;AACH,iBAAO,MAAM,KAAK,kBAAkB,MAAM;AAAA,QAC5C,KAAK;AACH,iBAAO,MAAM,KAAK,eAAe,MAAM;AAAA,QACzC,KAAK;AACH,iBAAO,MAAM,KAAK,gBAAgB,MAAM;AAAA,QAC1C,KAAK;AACH,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AS,OAAO,OAAO,QAAQ,MAAM;AACrC,IAAAA,QAAO,KAAK,yCAAyC,EAAE,MAAM,OAAO,CAAC;AAAA,EACvE;AAEA,SAAO;AAAA,IACL,MAAM,OAAO,MAAe,MAAe;AACzC,UAAI,OAAO,QAAQ;AACjB,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AAAA,MACF;AAEA,YAAM,aAAa,QAAQ,OAAO,QAAQ;AAC1C,YAAM,aAAa,QAAQ,OAAO,QAAQ;AAE1C,YAAM,SAAS,OAAO,YAAY,UAAU;AAC5C,MAAAA,QAAO,KAAK,oBAAoB,EAAE,MAAM,YAAY,MAAM,WAAW,CAAC;AAAA,IACxE;AAAA,IAEA,MAAM,QAAQ;AACZ,YAAM,SAAS,MAAM;AACrB,MAAAA,QAAO,KAAK,eAAe;AAAA,IAC7B;AAAA,IAEA,MAAM,UAAU;AAEd,YAAM,SAAS,QAAQ;AACvB,qBAAe,QAAQ;AACvB,YAAM,QAAQ,SAAS;AACvB,MAAAA,QAAO,KAAK,iBAAiB;AAAA,IAC/B;AAAA,EACF;AACF;","names":["createLogger","logger","createLogger","err"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Message } from '@agentxjs/core/agent';
|
|
|
4
4
|
import { AgentXError } from '@agentxjs/core/error';
|
|
5
5
|
export { AgentXError, AgentXErrorCategory, AgentXErrorCode, AgentXErrorContext } from '@agentxjs/core/error';
|
|
6
6
|
import { Unsubscribe, BusEvent, EventBus, BusEventHandler } from '@agentxjs/core/event';
|
|
7
|
-
import { LLMProtocol, LLMProviderRecord } from '@agentxjs/core/persistence';
|
|
7
|
+
import { PrototypeRecord, LLMProtocol, LLMProviderRecord } from '@agentxjs/core/persistence';
|
|
8
8
|
import * as _agentxjs_core_network from '@agentxjs/core/network';
|
|
9
9
|
import { RpcMethod } from '@agentxjs/core/network';
|
|
10
10
|
|
|
@@ -373,6 +373,30 @@ interface LLMProviderUpdateResponse extends BaseResponse {
|
|
|
373
373
|
interface LLMProviderDefaultResponse extends BaseResponse {
|
|
374
374
|
record: LLMProviderRecord | null;
|
|
375
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Prototype create response
|
|
378
|
+
*/
|
|
379
|
+
interface PrototypeCreateResponse extends BaseResponse {
|
|
380
|
+
record: PrototypeRecord;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Prototype get response
|
|
384
|
+
*/
|
|
385
|
+
interface PrototypeGetResponse extends BaseResponse {
|
|
386
|
+
record: PrototypeRecord | null;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Prototype list response
|
|
390
|
+
*/
|
|
391
|
+
interface PrototypeListResponse extends BaseResponse {
|
|
392
|
+
records: PrototypeRecord[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Prototype update response
|
|
396
|
+
*/
|
|
397
|
+
interface PrototypeUpdateResponse extends BaseResponse {
|
|
398
|
+
record: PrototypeRecord;
|
|
399
|
+
}
|
|
376
400
|
/**
|
|
377
401
|
* Container operations namespace
|
|
378
402
|
*/
|
|
@@ -520,6 +544,44 @@ interface LLMNamespace {
|
|
|
520
544
|
*/
|
|
521
545
|
getDefault(containerId: string): Promise<LLMProviderDefaultResponse>;
|
|
522
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* Prototype operations namespace — manage reusable agent templates
|
|
549
|
+
*/
|
|
550
|
+
interface PrototypeNamespace {
|
|
551
|
+
/**
|
|
552
|
+
* Register a new prototype
|
|
553
|
+
*/
|
|
554
|
+
create(params: {
|
|
555
|
+
containerId: string;
|
|
556
|
+
name: string;
|
|
557
|
+
description?: string;
|
|
558
|
+
contextId?: string;
|
|
559
|
+
embody?: Embodiment;
|
|
560
|
+
customData?: Record<string, unknown>;
|
|
561
|
+
}): Promise<PrototypeCreateResponse>;
|
|
562
|
+
/**
|
|
563
|
+
* Get prototype by ID
|
|
564
|
+
*/
|
|
565
|
+
get(prototypeId: string): Promise<PrototypeGetResponse>;
|
|
566
|
+
/**
|
|
567
|
+
* List prototypes
|
|
568
|
+
*/
|
|
569
|
+
list(containerId?: string): Promise<PrototypeListResponse>;
|
|
570
|
+
/**
|
|
571
|
+
* Update prototype
|
|
572
|
+
*/
|
|
573
|
+
update(prototypeId: string, updates: {
|
|
574
|
+
name?: string;
|
|
575
|
+
description?: string;
|
|
576
|
+
contextId?: string;
|
|
577
|
+
embody?: Embodiment;
|
|
578
|
+
customData?: Record<string, unknown>;
|
|
579
|
+
}): Promise<PrototypeUpdateResponse>;
|
|
580
|
+
/**
|
|
581
|
+
* Delete prototype
|
|
582
|
+
*/
|
|
583
|
+
delete(prototypeId: string): Promise<BaseResponse>;
|
|
584
|
+
}
|
|
523
585
|
/**
|
|
524
586
|
* Presentation operations namespace
|
|
525
587
|
*/
|
|
@@ -547,23 +609,24 @@ interface PresentationNamespace {
|
|
|
547
609
|
* Instance exposes the underlying image, agent, session, container, llm,
|
|
548
610
|
* and presentation subsystems for advanced use cases.
|
|
549
611
|
*/
|
|
550
|
-
interface
|
|
612
|
+
interface RuntimeNamespace {
|
|
551
613
|
readonly container: ContainerNamespace;
|
|
552
614
|
readonly image: ImageNamespace;
|
|
553
615
|
readonly agent: AgentNamespace;
|
|
554
616
|
readonly session: SessionNamespace;
|
|
555
617
|
readonly present: PresentationNamespace;
|
|
556
618
|
readonly llm: LLMNamespace;
|
|
619
|
+
readonly prototype: PrototypeNamespace;
|
|
557
620
|
}
|
|
558
621
|
/**
|
|
559
622
|
* AgentHandle — a live reference to a created agent.
|
|
560
623
|
*
|
|
561
|
-
* Returned by `ax.create()` and `ax.get()`. Holds the agent's identity
|
|
624
|
+
* Returned by `ax.chat.create()` and `ax.chat.get()`. Holds the agent's identity
|
|
562
625
|
* and provides instance-level operations (send, interrupt, etc.).
|
|
563
626
|
*
|
|
564
627
|
* @example
|
|
565
628
|
* ```typescript
|
|
566
|
-
* const agent = await ax.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
629
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
567
630
|
* await agent.send("Hello!");
|
|
568
631
|
* const messages = await agent.history();
|
|
569
632
|
* ```
|
|
@@ -603,17 +666,47 @@ interface AgentHandle {
|
|
|
603
666
|
*/
|
|
604
667
|
delete(): Promise<void>;
|
|
605
668
|
}
|
|
669
|
+
/**
|
|
670
|
+
* Chat operations — create and manage conversations.
|
|
671
|
+
*
|
|
672
|
+
* Each conversation is backed by an Image (persistent record)
|
|
673
|
+
* and returns an AgentHandle for interaction.
|
|
674
|
+
*/
|
|
675
|
+
interface ChatNamespace {
|
|
676
|
+
/**
|
|
677
|
+
* Create a new conversation
|
|
678
|
+
*
|
|
679
|
+
* When `prototypeId` is provided, the conversation inherits the prototype's
|
|
680
|
+
* configuration (contextId, embody, etc.). Inline params override prototype values.
|
|
681
|
+
*/
|
|
682
|
+
create(params: {
|
|
683
|
+
prototypeId?: string;
|
|
684
|
+
name?: string;
|
|
685
|
+
description?: string;
|
|
686
|
+
contextId?: string;
|
|
687
|
+
embody?: Embodiment;
|
|
688
|
+
customData?: Record<string, unknown>;
|
|
689
|
+
}): Promise<AgentHandle>;
|
|
690
|
+
/**
|
|
691
|
+
* List all conversations
|
|
692
|
+
*/
|
|
693
|
+
list(): Promise<ImageListResponse>;
|
|
694
|
+
/**
|
|
695
|
+
* Get a conversation by ID
|
|
696
|
+
*/
|
|
697
|
+
get(id: string): Promise<AgentHandle | null>;
|
|
698
|
+
}
|
|
606
699
|
/**
|
|
607
700
|
* AgentX Client SDK — unified interface for local, remote, and server modes.
|
|
608
701
|
*
|
|
609
702
|
* @example
|
|
610
703
|
* ```typescript
|
|
611
704
|
* const ax = createAgentX(config);
|
|
612
|
-
* const agent = await ax.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
705
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
613
706
|
* await agent.send("Hello!");
|
|
614
707
|
* ```
|
|
615
708
|
*
|
|
616
|
-
* For advanced use cases, access `ax.
|
|
709
|
+
* For advanced use cases, access `ax.runtime.*` for low-level subsystems.
|
|
617
710
|
*/
|
|
618
711
|
interface AgentX {
|
|
619
712
|
/**
|
|
@@ -625,27 +718,17 @@ interface AgentX {
|
|
|
625
718
|
*/
|
|
626
719
|
readonly events: EventBus;
|
|
627
720
|
/**
|
|
628
|
-
*
|
|
629
|
-
*/
|
|
630
|
-
create(params: {
|
|
631
|
-
name?: string;
|
|
632
|
-
description?: string;
|
|
633
|
-
contextId?: string;
|
|
634
|
-
embody?: Embodiment;
|
|
635
|
-
customData?: Record<string, unknown>;
|
|
636
|
-
}): Promise<AgentHandle>;
|
|
637
|
-
/**
|
|
638
|
-
* List all agents
|
|
721
|
+
* Conversation management — create, list, and open conversations.
|
|
639
722
|
*/
|
|
640
|
-
|
|
723
|
+
readonly chat: ChatNamespace;
|
|
641
724
|
/**
|
|
642
|
-
*
|
|
725
|
+
* Prototype management — register and manage reusable agent templates.
|
|
643
726
|
*/
|
|
644
|
-
|
|
727
|
+
readonly prototype: PrototypeNamespace;
|
|
645
728
|
/**
|
|
646
729
|
* Low-level access to internal subsystems (image, agent, session, container, llm).
|
|
647
730
|
*/
|
|
648
|
-
readonly
|
|
731
|
+
readonly runtime: RuntimeNamespace;
|
|
649
732
|
/**
|
|
650
733
|
* LLM provider management (system-level, not per-agent)
|
|
651
734
|
*/
|
|
@@ -709,7 +792,7 @@ interface AgentXServer {
|
|
|
709
792
|
* const ax = createAgentX(node({ createDriver }))
|
|
710
793
|
*
|
|
711
794
|
* // Local use
|
|
712
|
-
* const agent = await ax.create({ name: "Aristotle" })
|
|
795
|
+
* const agent = await ax.chat.create({ name: "Aristotle" })
|
|
713
796
|
* await agent.send("Hello!")
|
|
714
797
|
*
|
|
715
798
|
* // Connect to remote server
|
|
@@ -779,6 +862,11 @@ declare class CommandHandler {
|
|
|
779
862
|
private handleAgentDestroyAll;
|
|
780
863
|
private handleAgentInterrupt;
|
|
781
864
|
private handleMessageSend;
|
|
865
|
+
private handlePrototypeCreate;
|
|
866
|
+
private handlePrototypeGet;
|
|
867
|
+
private handlePrototypeList;
|
|
868
|
+
private handlePrototypeUpdate;
|
|
869
|
+
private handlePrototypeDelete;
|
|
782
870
|
private handleLLMCreate;
|
|
783
871
|
private handleLLMGet;
|
|
784
872
|
private handleLLMList;
|
|
@@ -837,7 +925,7 @@ declare function createServer(config: ServerConfig): Promise<AgentXServer>;
|
|
|
837
925
|
* import { nodePlatform } from "@agentxjs/node-platform";
|
|
838
926
|
*
|
|
839
927
|
* const ax = createAgentX(nodePlatform({ createDriver }));
|
|
840
|
-
* const agent = await ax.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
928
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
841
929
|
* await agent.send("Hello!");
|
|
842
930
|
* ```
|
|
843
931
|
*
|
|
@@ -869,4 +957,4 @@ interface PlatformConfig {
|
|
|
869
957
|
*/
|
|
870
958
|
declare function createAgentX(config?: PlatformConfig): AgentXBuilder;
|
|
871
959
|
|
|
872
|
-
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, 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
|
|
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 };
|