agentxjs 2.3.1 → 2.5.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 +64 -34
- package/dist/{chunk-X44CQZPK.js → chunk-7GW66EMD.js} +6 -4
- package/dist/chunk-7GW66EMD.js.map +1 -0
- package/dist/index.d.ts +123 -38
- package/dist/index.js +133 -46
- package/dist/index.js.map +1 -1
- package/dist/server-55XTEGMF.js +7 -0
- package/package.json +3 -3
- package/src/AgentHandle.ts +65 -0
- package/src/CommandHandler.ts +14 -7
- package/src/LocalClient.ts +58 -17
- package/src/RemoteClient.ts +60 -19
- package/src/index.ts +13 -20
- package/src/namespaces/presentations.ts +11 -6
- package/src/presentation/Presentation.ts +2 -2
- package/src/types.ts +146 -37
- package/dist/chunk-X44CQZPK.js.map +0 -1
- package/dist/server-BWI5JE4B.js +0 -7
- /package/dist/{server-BWI5JE4B.js.map → server-55XTEGMF.js.map} +0 -0
package/README.md
CHANGED
|
@@ -21,17 +21,13 @@ const createDriver = (config) => createMonoDriver({
|
|
|
21
21
|
|
|
22
22
|
const ax = createAgentX(nodePlatform({ createDriver }));
|
|
23
23
|
|
|
24
|
-
await ax.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
containerId: "my-app",
|
|
28
|
-
systemPrompt: "You are a helpful assistant.",
|
|
24
|
+
const agent = await ax.create({
|
|
25
|
+
name: "My Assistant",
|
|
26
|
+
embody: { systemPrompt: "You are a helpful assistant." },
|
|
29
27
|
});
|
|
30
28
|
|
|
31
|
-
const { agentId } = await ax.agent.create({ imageId: image.imageId });
|
|
32
|
-
|
|
33
29
|
ax.on("text_delta", (e) => process.stdout.write(e.data.text));
|
|
34
|
-
await
|
|
30
|
+
await agent.send("Hello!");
|
|
35
31
|
```
|
|
36
32
|
|
|
37
33
|
### Remote Mode (WebSocket Client)
|
|
@@ -44,15 +40,13 @@ import { createAgentX } from "agentxjs";
|
|
|
44
40
|
const ax = createAgentX();
|
|
45
41
|
const client = await ax.connect("ws://localhost:5200");
|
|
46
42
|
|
|
47
|
-
await client.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
systemPrompt: "You are a helpful assistant.",
|
|
43
|
+
const agent = await client.create({
|
|
44
|
+
name: "My Assistant",
|
|
45
|
+
embody: { systemPrompt: "You are a helpful assistant." },
|
|
51
46
|
});
|
|
52
|
-
const { agentId } = await client.agent.create({ imageId: image.imageId });
|
|
53
47
|
|
|
54
48
|
client.on("text_delta", (e) => process.stdout.write(e.data.text));
|
|
55
|
-
await
|
|
49
|
+
await agent.send("Hello!");
|
|
56
50
|
```
|
|
57
51
|
|
|
58
52
|
### Server Mode
|
|
@@ -83,13 +77,16 @@ interface AgentX {
|
|
|
83
77
|
readonly connected: boolean;
|
|
84
78
|
readonly events: EventBus;
|
|
85
79
|
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
readonly
|
|
80
|
+
// Top-level Agent API
|
|
81
|
+
create(params: { name?, description?, contextId?, embody?, customData? }): Promise<AgentHandle>;
|
|
82
|
+
list(): Promise<ImageListResponse>;
|
|
83
|
+
get(agentId: string): Promise<AgentHandle | null>;
|
|
84
|
+
|
|
85
|
+
// Low-level subsystems
|
|
86
|
+
readonly instance: InstanceNamespace;
|
|
87
|
+
|
|
88
|
+
// LLM provider management (system-level)
|
|
89
|
+
readonly provider: LLMNamespace;
|
|
93
90
|
|
|
94
91
|
// Universal RPC
|
|
95
92
|
rpc<T = unknown>(method: string, params?: unknown): Promise<T>;
|
|
@@ -113,7 +110,29 @@ interface AgentXBuilder extends AgentX {
|
|
|
113
110
|
}
|
|
114
111
|
```
|
|
115
112
|
|
|
116
|
-
###
|
|
113
|
+
### AgentHandle
|
|
114
|
+
|
|
115
|
+
Returned by `create()` and `get()`. A live reference to an agent with instance-level operations.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
interface AgentHandle {
|
|
119
|
+
readonly agentId: string;
|
|
120
|
+
readonly imageId: string;
|
|
121
|
+
readonly containerId: string;
|
|
122
|
+
readonly sessionId: string;
|
|
123
|
+
|
|
124
|
+
send(content: string | unknown[]): Promise<MessageSendResponse>;
|
|
125
|
+
interrupt(): Promise<BaseResponse>;
|
|
126
|
+
history(): Promise<Message[]>;
|
|
127
|
+
present(options?: PresentationOptions): Promise<Presentation>;
|
|
128
|
+
update(updates: { name?, description?, embody?, customData? }): Promise<void>;
|
|
129
|
+
delete(): Promise<void>;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Instance Namespace (low-level)
|
|
134
|
+
|
|
135
|
+
For advanced use cases, access `ax.instance.*` for direct subsystem operations:
|
|
117
136
|
|
|
118
137
|
**container**:
|
|
119
138
|
|
|
@@ -123,10 +142,10 @@ interface AgentXBuilder extends AgentX {
|
|
|
123
142
|
|
|
124
143
|
**image**:
|
|
125
144
|
|
|
126
|
-
- `create(params: { containerId, name?, description?,
|
|
145
|
+
- `create(params: { containerId, name?, description?, contextId?, embody?, customData? }): Promise<ImageCreateResponse>`
|
|
127
146
|
- `get(imageId: string): Promise<ImageGetResponse>`
|
|
128
147
|
- `list(containerId?: string): Promise<ImageListResponse>`
|
|
129
|
-
- `update(imageId: string, updates: { name?, description?, customData? }): Promise<ImageUpdateResponse>`
|
|
148
|
+
- `update(imageId: string, updates: { name?, description?, embody?, customData? }): Promise<ImageUpdateResponse>`
|
|
130
149
|
- `delete(imageId: string): Promise<BaseResponse>`
|
|
131
150
|
- `getMessages(imageId: string): Promise<Message[]>`
|
|
132
151
|
|
|
@@ -143,7 +162,7 @@ interface AgentXBuilder extends AgentX {
|
|
|
143
162
|
- `interrupt(agentId: string): Promise<BaseResponse>`
|
|
144
163
|
- `getMessages(agentId: string): Promise<Message[]>`
|
|
145
164
|
|
|
146
|
-
**
|
|
165
|
+
**present**:
|
|
147
166
|
|
|
148
167
|
- `create(agentId: string, options?: PresentationOptions): Promise<Presentation>`
|
|
149
168
|
|
|
@@ -159,17 +178,29 @@ interface AgentXBuilder extends AgentX {
|
|
|
159
178
|
|
|
160
179
|
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"`.
|
|
161
180
|
|
|
162
|
-
|
|
181
|
+
### Embodiment
|
|
182
|
+
|
|
183
|
+
Runtime configuration for an agent's "body":
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
interface Embodiment {
|
|
187
|
+
model?: string; // LLM model name
|
|
188
|
+
systemPrompt?: string; // System prompt
|
|
189
|
+
mcpServers?: Record<string, McpServerConfig>; // MCP tool servers
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Model priority: `embody.model > container default provider > environment variable`.
|
|
163
194
|
|
|
164
195
|
### Universal RPC
|
|
165
196
|
|
|
166
197
|
Transport-agnostic JSON-RPC entry point. Works in all modes — local dispatches to CommandHandler, remote forwards via WebSocket.
|
|
167
198
|
|
|
168
199
|
```typescript
|
|
169
|
-
// Equivalent to ax.container.create("default")
|
|
200
|
+
// Equivalent to ax.instance.container.create("default")
|
|
170
201
|
await ax.rpc("container.create", { containerId: "default" });
|
|
171
202
|
|
|
172
|
-
// Equivalent to ax.image.list()
|
|
203
|
+
// Equivalent to ax.instance.image.list()
|
|
173
204
|
const { records } = await ax.rpc<{ records: ImageRecord[] }>("image.list");
|
|
174
205
|
|
|
175
206
|
// Useful for custom transport (e.g. Cloudflare Workers/DO)
|
|
@@ -192,7 +223,7 @@ Most applications only need the Presentation layer. `ax.onError` is for advanced
|
|
|
192
223
|
When an LLM call fails (e.g., 403 Forbidden, network timeout), the error automatically appears in `state.conversations` as an `ErrorConversation`:
|
|
193
224
|
|
|
194
225
|
```typescript
|
|
195
|
-
const
|
|
226
|
+
const pres = await agent.present({
|
|
196
227
|
onUpdate: (state) => {
|
|
197
228
|
for (const conv of state.conversations) {
|
|
198
229
|
if (conv.role === "user") {
|
|
@@ -202,7 +233,6 @@ const presentation = await ax.presentation.create(agentId, {
|
|
|
202
233
|
} else if (conv.role === "error") {
|
|
203
234
|
// LLM errors show up here automatically
|
|
204
235
|
renderErrorMessage(conv.message);
|
|
205
|
-
// e.g. "403 Forbidden: Invalid API key"
|
|
206
236
|
}
|
|
207
237
|
}
|
|
208
238
|
},
|
|
@@ -260,7 +290,7 @@ ax.onError((error) => {
|
|
|
260
290
|
High-level UI state management. Aggregates raw stream events into structured conversation state — the recommended way to build chat UIs.
|
|
261
291
|
|
|
262
292
|
```typescript
|
|
263
|
-
const
|
|
293
|
+
const pres = await agent.present({
|
|
264
294
|
onUpdate: (state) => {
|
|
265
295
|
// state.conversations — completed messages (user, assistant, and error)
|
|
266
296
|
// state.streaming — current streaming response (or null)
|
|
@@ -269,9 +299,9 @@ const presentation = await ax.presentation.create(agentId, {
|
|
|
269
299
|
},
|
|
270
300
|
});
|
|
271
301
|
|
|
272
|
-
await
|
|
273
|
-
const state =
|
|
274
|
-
|
|
302
|
+
await pres.send("What is the weather?");
|
|
303
|
+
const state = pres.getState();
|
|
304
|
+
pres.dispose();
|
|
275
305
|
```
|
|
276
306
|
|
|
277
307
|
**Conversation types in `state.conversations`:**
|
|
@@ -115,11 +115,11 @@ var CommandHandler = class {
|
|
|
115
115
|
}
|
|
116
116
|
// ==================== Image Commands ====================
|
|
117
117
|
async handleImageCreate(params) {
|
|
118
|
-
const { containerId, name, description,
|
|
118
|
+
const { containerId, name, description, contextId, embody, customData } = params;
|
|
119
119
|
const { imageRepository, sessionRepository } = this.runtime.platform;
|
|
120
120
|
const { createImage } = await import("@agentxjs/core/image");
|
|
121
121
|
const image = await createImage(
|
|
122
|
-
{ containerId, name, description,
|
|
122
|
+
{ containerId, name, description, contextId, embody, customData },
|
|
123
123
|
{ imageRepository, sessionRepository }
|
|
124
124
|
);
|
|
125
125
|
return ok({
|
|
@@ -202,9 +202,11 @@ var CommandHandler = class {
|
|
|
202
202
|
if (!imageRecord) {
|
|
203
203
|
return err(404, `Image not found: ${imageId}`);
|
|
204
204
|
}
|
|
205
|
+
const { embody: embodyUpdates, ...otherUpdates } = updates;
|
|
205
206
|
const updatedRecord = {
|
|
206
207
|
...imageRecord,
|
|
207
|
-
...
|
|
208
|
+
...otherUpdates,
|
|
209
|
+
embody: embodyUpdates ? { ...imageRecord.embody, ...embodyUpdates } : imageRecord.embody,
|
|
208
210
|
updatedAt: Date.now()
|
|
209
211
|
};
|
|
210
212
|
await this.runtime.platform.imageRepository.saveImage(updatedRecord);
|
|
@@ -566,4 +568,4 @@ export {
|
|
|
566
568
|
CommandHandler,
|
|
567
569
|
createServer
|
|
568
570
|
};
|
|
569
|
-
//# sourceMappingURL=chunk-
|
|
571
|
+
//# sourceMappingURL=chunk-7GW66EMD.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 // 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 // ==================== 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;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,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
|
@@ -229,6 +229,14 @@ interface AgentInfo {
|
|
|
229
229
|
sessionId: string;
|
|
230
230
|
lifecycle?: string;
|
|
231
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Embodiment — runtime configuration for an agent's "body".
|
|
234
|
+
*/
|
|
235
|
+
interface Embodiment {
|
|
236
|
+
model?: string;
|
|
237
|
+
systemPrompt?: string;
|
|
238
|
+
mcpServers?: Record<string, unknown>;
|
|
239
|
+
}
|
|
232
240
|
/**
|
|
233
241
|
* Image record from server
|
|
234
242
|
*/
|
|
@@ -238,7 +246,12 @@ interface ImageRecord {
|
|
|
238
246
|
sessionId: string;
|
|
239
247
|
name?: string;
|
|
240
248
|
description?: string;
|
|
249
|
+
contextId?: string;
|
|
250
|
+
embody?: Embodiment;
|
|
251
|
+
/** @deprecated Use `embody.systemPrompt` instead. */
|
|
241
252
|
systemPrompt?: string;
|
|
253
|
+
/** @deprecated Use `embody.mcpServers` instead. */
|
|
254
|
+
mcpServers?: Record<string, unknown>;
|
|
242
255
|
customData?: Record<string, unknown>;
|
|
243
256
|
createdAt: number;
|
|
244
257
|
updatedAt: number;
|
|
@@ -382,14 +395,14 @@ interface ContainerNamespace {
|
|
|
382
395
|
*/
|
|
383
396
|
interface ImageNamespace {
|
|
384
397
|
/**
|
|
385
|
-
* Create a new image
|
|
398
|
+
* Create a new image from an Agent blueprint
|
|
386
399
|
*/
|
|
387
400
|
create(params: {
|
|
388
401
|
containerId: string;
|
|
389
402
|
name?: string;
|
|
390
403
|
description?: string;
|
|
391
|
-
|
|
392
|
-
|
|
404
|
+
contextId?: string;
|
|
405
|
+
embody?: Embodiment;
|
|
393
406
|
customData?: Record<string, unknown>;
|
|
394
407
|
}): Promise<ImageCreateResponse>;
|
|
395
408
|
/**
|
|
@@ -406,6 +419,7 @@ interface ImageNamespace {
|
|
|
406
419
|
update(imageId: string, updates: {
|
|
407
420
|
name?: string;
|
|
408
421
|
description?: string;
|
|
422
|
+
embody?: Embodiment;
|
|
409
423
|
customData?: Record<string, unknown>;
|
|
410
424
|
}): Promise<ImageUpdateResponse>;
|
|
411
425
|
/**
|
|
@@ -515,7 +529,7 @@ interface PresentationNamespace {
|
|
|
515
529
|
*
|
|
516
530
|
* @example
|
|
517
531
|
* ```typescript
|
|
518
|
-
* const pres =
|
|
532
|
+
* const pres = ax.present(agentId, {
|
|
519
533
|
* onUpdate: (state) => renderUI(state),
|
|
520
534
|
* onError: (error) => console.error(error),
|
|
521
535
|
* });
|
|
@@ -527,7 +541,79 @@ interface PresentationNamespace {
|
|
|
527
541
|
create(agentId: string, options?: PresentationOptions): Promise<Presentation>;
|
|
528
542
|
}
|
|
529
543
|
/**
|
|
530
|
-
*
|
|
544
|
+
* Instance — low-level access to internal subsystems.
|
|
545
|
+
*
|
|
546
|
+
* Most users should use the top-level Agent API (ax.create, ax.send, etc.).
|
|
547
|
+
* Instance exposes the underlying image, agent, session, container, llm,
|
|
548
|
+
* and presentation subsystems for advanced use cases.
|
|
549
|
+
*/
|
|
550
|
+
interface InstanceNamespace {
|
|
551
|
+
readonly container: ContainerNamespace;
|
|
552
|
+
readonly image: ImageNamespace;
|
|
553
|
+
readonly agent: AgentNamespace;
|
|
554
|
+
readonly session: SessionNamespace;
|
|
555
|
+
readonly present: PresentationNamespace;
|
|
556
|
+
readonly llm: LLMNamespace;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* AgentHandle — a live reference to a created agent.
|
|
560
|
+
*
|
|
561
|
+
* Returned by `ax.create()` and `ax.get()`. Holds the agent's identity
|
|
562
|
+
* and provides instance-level operations (send, interrupt, etc.).
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* const agent = await ax.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
567
|
+
* await agent.send("Hello!");
|
|
568
|
+
* const messages = await agent.history();
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
interface AgentHandle {
|
|
572
|
+
readonly agentId: string;
|
|
573
|
+
readonly imageId: string;
|
|
574
|
+
readonly containerId: string;
|
|
575
|
+
readonly sessionId: string;
|
|
576
|
+
/**
|
|
577
|
+
* Send a message to this agent
|
|
578
|
+
*/
|
|
579
|
+
send(content: string | unknown[]): Promise<MessageSendResponse>;
|
|
580
|
+
/**
|
|
581
|
+
* Interrupt this agent's current response
|
|
582
|
+
*/
|
|
583
|
+
interrupt(): Promise<BaseResponse>;
|
|
584
|
+
/**
|
|
585
|
+
* Get message history
|
|
586
|
+
*/
|
|
587
|
+
history(): Promise<Message[]>;
|
|
588
|
+
/**
|
|
589
|
+
* Create a presentation for UI integration
|
|
590
|
+
*/
|
|
591
|
+
present(options?: PresentationOptions): Promise<Presentation>;
|
|
592
|
+
/**
|
|
593
|
+
* Update this agent's metadata
|
|
594
|
+
*/
|
|
595
|
+
update(updates: {
|
|
596
|
+
name?: string;
|
|
597
|
+
description?: string;
|
|
598
|
+
embody?: Embodiment;
|
|
599
|
+
customData?: Record<string, unknown>;
|
|
600
|
+
}): Promise<void>;
|
|
601
|
+
/**
|
|
602
|
+
* Delete this agent
|
|
603
|
+
*/
|
|
604
|
+
delete(): Promise<void>;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* AgentX Client SDK — unified interface for local, remote, and server modes.
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* const ax = createAgentX(config);
|
|
612
|
+
* const agent = await ax.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
613
|
+
* await agent.send("Hello!");
|
|
614
|
+
* ```
|
|
615
|
+
*
|
|
616
|
+
* For advanced use cases, access `ax.instance.*` for low-level subsystems.
|
|
531
617
|
*/
|
|
532
618
|
interface AgentX {
|
|
533
619
|
/**
|
|
@@ -538,43 +624,40 @@ interface AgentX {
|
|
|
538
624
|
* Event bus for subscribing to events
|
|
539
625
|
*/
|
|
540
626
|
readonly events: EventBus;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
627
|
+
/**
|
|
628
|
+
* Create a new agent from a blueprint
|
|
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
|
|
639
|
+
*/
|
|
640
|
+
list(): Promise<ImageListResponse>;
|
|
641
|
+
/**
|
|
642
|
+
* Get agent by ID
|
|
643
|
+
*/
|
|
644
|
+
get(agentId: string): Promise<AgentHandle | null>;
|
|
645
|
+
/**
|
|
646
|
+
* Low-level access to internal subsystems (image, agent, session, container, llm).
|
|
647
|
+
*/
|
|
648
|
+
readonly instance: InstanceNamespace;
|
|
649
|
+
/**
|
|
650
|
+
* LLM provider management (system-level, not per-agent)
|
|
651
|
+
*/
|
|
652
|
+
readonly provider: LLMNamespace;
|
|
547
653
|
on<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
|
|
548
654
|
type: T;
|
|
549
655
|
}>): Unsubscribe;
|
|
550
656
|
onAny(handler: BusEventHandler): Unsubscribe;
|
|
551
657
|
subscribe(sessionId: string): void;
|
|
552
|
-
/**
|
|
553
|
-
* Top-level error handler — receives all AgentXError instances from any layer.
|
|
554
|
-
*
|
|
555
|
-
* Independent of `on("error", ...)` (stream events) and `presentation.onError` (UI errors).
|
|
556
|
-
*
|
|
557
|
-
* @example
|
|
558
|
-
* ```typescript
|
|
559
|
-
* ax.onError((error) => {
|
|
560
|
-
* console.error(`[${error.category}] ${error.code}: ${error.message}`);
|
|
561
|
-
* if (!error.recoverable) {
|
|
562
|
-
* // Circuit is open, stop sending requests
|
|
563
|
-
* }
|
|
564
|
-
* });
|
|
565
|
-
* ```
|
|
566
|
-
*/
|
|
567
658
|
onError(handler: (error: AgentXError) => void): Unsubscribe;
|
|
568
659
|
/**
|
|
569
|
-
* Universal JSON-RPC entry point
|
|
570
|
-
* - Local: dispatches to CommandHandler directly
|
|
571
|
-
* - Remote: forwards to the remote server via RPC client
|
|
572
|
-
*
|
|
573
|
-
* @example
|
|
574
|
-
* ```typescript
|
|
575
|
-
* const result = await ax.rpc("container.create", { containerId: "default" });
|
|
576
|
-
* const { records } = await ax.rpc<{ records: ImageRecord[] }>("image.list");
|
|
577
|
-
* ```
|
|
660
|
+
* Universal JSON-RPC entry point
|
|
578
661
|
*/
|
|
579
662
|
rpc<T = unknown>(method: string, params?: unknown): Promise<T>;
|
|
580
663
|
disconnect(): Promise<void>;
|
|
@@ -626,7 +709,8 @@ interface AgentXServer {
|
|
|
626
709
|
* const ax = createAgentX(node({ createDriver }))
|
|
627
710
|
*
|
|
628
711
|
* // Local use
|
|
629
|
-
* await ax.
|
|
712
|
+
* const agent = await ax.create({ name: "Aristotle" })
|
|
713
|
+
* await agent.send("Hello!")
|
|
630
714
|
*
|
|
631
715
|
* // Connect to remote server
|
|
632
716
|
* const client = await ax.connect("wss://...")
|
|
@@ -753,7 +837,8 @@ declare function createServer(config: ServerConfig): Promise<AgentXServer>;
|
|
|
753
837
|
* import { nodePlatform } from "@agentxjs/node-platform";
|
|
754
838
|
*
|
|
755
839
|
* const ax = createAgentX(nodePlatform({ createDriver }));
|
|
756
|
-
* await ax.
|
|
840
|
+
* const agent = await ax.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
841
|
+
* await agent.send("Hello!");
|
|
757
842
|
* ```
|
|
758
843
|
*
|
|
759
844
|
* @example Remote mode
|
|
@@ -784,4 +869,4 @@ interface PlatformConfig {
|
|
|
784
869
|
*/
|
|
785
870
|
declare function createAgentX(config?: PlatformConfig): AgentXBuilder;
|
|
786
871
|
|
|
787
|
-
export { type AgentCreateResponse, type AgentGetResponse, 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 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 ServeConfig, type ServerConfig, type SessionNamespace, type TextBlock, type ToolBlock, type UserConversation, addUserConversation, createAgentX, createInitialState, createServer, initialPresentationState, messagesToConversations, presentationReducer };
|
|
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 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 ServeConfig, type ServerConfig, type SessionNamespace, type TextBlock, type ToolBlock, type UserConversation, addUserConversation, createAgentX, createInitialState, createServer, initialPresentationState, messagesToConversations, presentationReducer };
|