agentxjs 2.4.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 +74 -34
- package/dist/{chunk-X44CQZPK.js → chunk-JTHR3AK6.js} +87 -4
- package/dist/chunk-JTHR3AK6.js.map +1 -0
- package/dist/index.d.ts +212 -39
- package/dist/index.js +294 -54
- package/dist/index.js.map +1 -1
- package/dist/server-UCQISBKH.js +7 -0
- package/package.json +3 -3
- package/src/AgentHandle.ts +65 -0
- package/src/CommandHandler.ts +131 -7
- package/src/LocalClient.ts +87 -27
- package/src/RemoteClient.ts +77 -17
- package/src/index.ts +19 -17
- package/src/namespaces/presentations.ts +11 -6
- package/src/namespaces/prototypes.ts +136 -0
- package/src/presentation/Presentation.ts +2 -2
- package/src/types.ts +254 -38
- package/dist/chunk-X44CQZPK.js.map +0 -1
- package/dist/server-BWI5JE4B.js +0 -7
- /package/dist/{server-BWI5JE4B.js.map → server-UCQISBKH.js.map} +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prototype namespace factories
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RpcClient } from "@agentxjs/core/network";
|
|
6
|
+
import type { AgentXPlatform } from "@agentxjs/core/runtime";
|
|
7
|
+
import type {
|
|
8
|
+
BaseResponse,
|
|
9
|
+
PrototypeCreateResponse,
|
|
10
|
+
PrototypeGetResponse,
|
|
11
|
+
PrototypeListResponse,
|
|
12
|
+
PrototypeNamespace,
|
|
13
|
+
PrototypeUpdateResponse,
|
|
14
|
+
} from "../types";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create local prototype namespace backed by embedded runtime
|
|
18
|
+
*/
|
|
19
|
+
export function createLocalPrototypes(platform: AgentXPlatform): PrototypeNamespace {
|
|
20
|
+
return {
|
|
21
|
+
async create(params): Promise<PrototypeCreateResponse> {
|
|
22
|
+
const repo = platform.prototypeRepository;
|
|
23
|
+
if (!repo) {
|
|
24
|
+
throw new Error("Prototype repository not available");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
const random = Math.random().toString(36).slice(2, 8);
|
|
29
|
+
const record = {
|
|
30
|
+
prototypeId: `proto_${now}_${random}`,
|
|
31
|
+
containerId: params.containerId,
|
|
32
|
+
name: params.name,
|
|
33
|
+
description: params.description,
|
|
34
|
+
contextId: params.contextId,
|
|
35
|
+
embody: params.embody,
|
|
36
|
+
customData: params.customData,
|
|
37
|
+
createdAt: now,
|
|
38
|
+
updatedAt: now,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
await repo.savePrototype(record);
|
|
42
|
+
return { record, requestId: "" };
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
async get(prototypeId: string): Promise<PrototypeGetResponse> {
|
|
46
|
+
const repo = platform.prototypeRepository;
|
|
47
|
+
if (!repo) {
|
|
48
|
+
throw new Error("Prototype repository not available");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const record = await repo.findPrototypeById(prototypeId);
|
|
52
|
+
return { record, requestId: "" };
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
async list(containerId?: string): Promise<PrototypeListResponse> {
|
|
56
|
+
const repo = platform.prototypeRepository;
|
|
57
|
+
if (!repo) {
|
|
58
|
+
throw new Error("Prototype repository not available");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const records = containerId
|
|
62
|
+
? await repo.findPrototypesByContainerId(containerId)
|
|
63
|
+
: await repo.findAllPrototypes();
|
|
64
|
+
|
|
65
|
+
return { records, requestId: "" };
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
async update(prototypeId, updates): Promise<PrototypeUpdateResponse> {
|
|
69
|
+
const repo = platform.prototypeRepository;
|
|
70
|
+
if (!repo) {
|
|
71
|
+
throw new Error("Prototype repository not available");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const existing = await repo.findPrototypeById(prototypeId);
|
|
75
|
+
if (!existing) {
|
|
76
|
+
throw new Error(`Prototype not found: ${prototypeId}`);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const { embody: embodyUpdates, ...otherUpdates } = updates;
|
|
80
|
+
const updatedRecord = {
|
|
81
|
+
...existing,
|
|
82
|
+
...otherUpdates,
|
|
83
|
+
embody: embodyUpdates ? { ...existing.embody, ...embodyUpdates } : existing.embody,
|
|
84
|
+
updatedAt: Date.now(),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
await repo.savePrototype(updatedRecord);
|
|
88
|
+
return { record: updatedRecord, requestId: "" };
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
async delete(prototypeId: string): Promise<BaseResponse> {
|
|
92
|
+
const repo = platform.prototypeRepository;
|
|
93
|
+
if (!repo) {
|
|
94
|
+
throw new Error("Prototype repository not available");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
await repo.deletePrototype(prototypeId);
|
|
98
|
+
return { requestId: "" };
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Create remote prototype namespace backed by RPC client
|
|
105
|
+
*/
|
|
106
|
+
export function createRemotePrototypes(rpcClient: RpcClient): PrototypeNamespace {
|
|
107
|
+
return {
|
|
108
|
+
async create(params): Promise<PrototypeCreateResponse> {
|
|
109
|
+
const result = await rpcClient.call<PrototypeCreateResponse>("prototype.create", params);
|
|
110
|
+
return { ...result, requestId: "" };
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
async get(prototypeId: string): Promise<PrototypeGetResponse> {
|
|
114
|
+
const result = await rpcClient.call<PrototypeGetResponse>("prototype.get", { prototypeId });
|
|
115
|
+
return { ...result, requestId: "" };
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
async list(containerId?: string): Promise<PrototypeListResponse> {
|
|
119
|
+
const result = await rpcClient.call<PrototypeListResponse>("prototype.list", { containerId });
|
|
120
|
+
return { ...result, requestId: "" };
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
async update(prototypeId, updates): Promise<PrototypeUpdateResponse> {
|
|
124
|
+
const result = await rpcClient.call<PrototypeUpdateResponse>("prototype.update", {
|
|
125
|
+
prototypeId,
|
|
126
|
+
updates,
|
|
127
|
+
});
|
|
128
|
+
return { ...result, requestId: "" };
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
async delete(prototypeId: string): Promise<BaseResponse> {
|
|
132
|
+
const result = await rpcClient.call<BaseResponse>("prototype.delete", { prototypeId });
|
|
133
|
+
return { ...result, requestId: "" };
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -110,7 +110,7 @@ export class Presentation {
|
|
|
110
110
|
|
|
111
111
|
try {
|
|
112
112
|
// Send message via agentx
|
|
113
|
-
await this.agentx.session.send(this.agentId, content);
|
|
113
|
+
await this.agentx.runtime.session.send(this.agentId, content);
|
|
114
114
|
} catch (error) {
|
|
115
115
|
this.notifyError(error instanceof Error ? error : new Error(String(error)));
|
|
116
116
|
}
|
|
@@ -121,7 +121,7 @@ export class Presentation {
|
|
|
121
121
|
*/
|
|
122
122
|
async interrupt(): Promise<void> {
|
|
123
123
|
try {
|
|
124
|
-
await this.agentx.session.interrupt(this.agentId);
|
|
124
|
+
await this.agentx.runtime.session.interrupt(this.agentId);
|
|
125
125
|
} catch (error) {
|
|
126
126
|
this.notifyError(error instanceof Error ? error : new Error(String(error)));
|
|
127
127
|
}
|
package/src/types.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { Message } from "@agentxjs/core/agent";
|
|
6
6
|
import type { AgentXError } from "@agentxjs/core/error";
|
|
7
7
|
import type { BusEvent, BusEventHandler, EventBus, Unsubscribe } from "@agentxjs/core/event";
|
|
8
|
-
import type { LLMProtocol, LLMProviderRecord } from "@agentxjs/core/persistence";
|
|
8
|
+
import type { LLMProtocol, LLMProviderRecord, PrototypeRecord } from "@agentxjs/core/persistence";
|
|
9
9
|
import type { AgentXPlatform } from "@agentxjs/core/runtime";
|
|
10
10
|
import type { Presentation, PresentationOptions } from "./presentation";
|
|
11
11
|
|
|
@@ -46,6 +46,15 @@ export interface AgentInfo {
|
|
|
46
46
|
lifecycle?: string;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Embodiment — runtime configuration for an agent's "body".
|
|
51
|
+
*/
|
|
52
|
+
export interface Embodiment {
|
|
53
|
+
model?: string;
|
|
54
|
+
systemPrompt?: string;
|
|
55
|
+
mcpServers?: Record<string, unknown>;
|
|
56
|
+
}
|
|
57
|
+
|
|
49
58
|
/**
|
|
50
59
|
* Image record from server
|
|
51
60
|
*/
|
|
@@ -55,7 +64,12 @@ export interface ImageRecord {
|
|
|
55
64
|
sessionId: string;
|
|
56
65
|
name?: string;
|
|
57
66
|
description?: string;
|
|
67
|
+
contextId?: string;
|
|
68
|
+
embody?: Embodiment;
|
|
69
|
+
/** @deprecated Use `embody.systemPrompt` instead. */
|
|
58
70
|
systemPrompt?: string;
|
|
71
|
+
/** @deprecated Use `embody.mcpServers` instead. */
|
|
72
|
+
mcpServers?: Record<string, unknown>;
|
|
59
73
|
customData?: Record<string, unknown>;
|
|
60
74
|
createdAt: number;
|
|
61
75
|
updatedAt: number;
|
|
@@ -200,6 +214,38 @@ export interface LLMProviderDefaultResponse extends BaseResponse {
|
|
|
200
214
|
record: LLMProviderRecord | null;
|
|
201
215
|
}
|
|
202
216
|
|
|
217
|
+
// ============================================================================
|
|
218
|
+
// Prototype Response Types
|
|
219
|
+
// ============================================================================
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Prototype create response
|
|
223
|
+
*/
|
|
224
|
+
export interface PrototypeCreateResponse extends BaseResponse {
|
|
225
|
+
record: PrototypeRecord;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Prototype get response
|
|
230
|
+
*/
|
|
231
|
+
export interface PrototypeGetResponse extends BaseResponse {
|
|
232
|
+
record: PrototypeRecord | null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Prototype list response
|
|
237
|
+
*/
|
|
238
|
+
export interface PrototypeListResponse extends BaseResponse {
|
|
239
|
+
records: PrototypeRecord[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Prototype update response
|
|
244
|
+
*/
|
|
245
|
+
export interface PrototypeUpdateResponse extends BaseResponse {
|
|
246
|
+
record: PrototypeRecord;
|
|
247
|
+
}
|
|
248
|
+
|
|
203
249
|
// ============================================================================
|
|
204
250
|
// Namespace Interfaces
|
|
205
251
|
// ============================================================================
|
|
@@ -229,14 +275,14 @@ export interface ContainerNamespace {
|
|
|
229
275
|
*/
|
|
230
276
|
export interface ImageNamespace {
|
|
231
277
|
/**
|
|
232
|
-
* Create a new image
|
|
278
|
+
* Create a new image from an Agent blueprint
|
|
233
279
|
*/
|
|
234
280
|
create(params: {
|
|
235
281
|
containerId: string;
|
|
236
282
|
name?: string;
|
|
237
283
|
description?: string;
|
|
238
|
-
|
|
239
|
-
|
|
284
|
+
contextId?: string;
|
|
285
|
+
embody?: Embodiment;
|
|
240
286
|
customData?: Record<string, unknown>;
|
|
241
287
|
}): Promise<ImageCreateResponse>;
|
|
242
288
|
|
|
@@ -258,6 +304,7 @@ export interface ImageNamespace {
|
|
|
258
304
|
updates: {
|
|
259
305
|
name?: string;
|
|
260
306
|
description?: string;
|
|
307
|
+
embody?: Embodiment;
|
|
261
308
|
customData?: Record<string, unknown>;
|
|
262
309
|
}
|
|
263
310
|
): Promise<ImageUpdateResponse>;
|
|
@@ -376,6 +423,52 @@ export interface LLMNamespace {
|
|
|
376
423
|
getDefault(containerId: string): Promise<LLMProviderDefaultResponse>;
|
|
377
424
|
}
|
|
378
425
|
|
|
426
|
+
/**
|
|
427
|
+
* Prototype operations namespace — manage reusable agent templates
|
|
428
|
+
*/
|
|
429
|
+
export interface PrototypeNamespace {
|
|
430
|
+
/**
|
|
431
|
+
* Register a new prototype
|
|
432
|
+
*/
|
|
433
|
+
create(params: {
|
|
434
|
+
containerId: string;
|
|
435
|
+
name: string;
|
|
436
|
+
description?: string;
|
|
437
|
+
contextId?: string;
|
|
438
|
+
embody?: Embodiment;
|
|
439
|
+
customData?: Record<string, unknown>;
|
|
440
|
+
}): Promise<PrototypeCreateResponse>;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Get prototype by ID
|
|
444
|
+
*/
|
|
445
|
+
get(prototypeId: string): Promise<PrototypeGetResponse>;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* List prototypes
|
|
449
|
+
*/
|
|
450
|
+
list(containerId?: string): Promise<PrototypeListResponse>;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Update prototype
|
|
454
|
+
*/
|
|
455
|
+
update(
|
|
456
|
+
prototypeId: string,
|
|
457
|
+
updates: {
|
|
458
|
+
name?: string;
|
|
459
|
+
description?: string;
|
|
460
|
+
contextId?: string;
|
|
461
|
+
embody?: Embodiment;
|
|
462
|
+
customData?: Record<string, unknown>;
|
|
463
|
+
}
|
|
464
|
+
): Promise<PrototypeUpdateResponse>;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Delete prototype
|
|
468
|
+
*/
|
|
469
|
+
delete(prototypeId: string): Promise<BaseResponse>;
|
|
470
|
+
}
|
|
471
|
+
|
|
379
472
|
/**
|
|
380
473
|
* Presentation operations namespace
|
|
381
474
|
*/
|
|
@@ -385,7 +478,7 @@ export interface PresentationNamespace {
|
|
|
385
478
|
*
|
|
386
479
|
* @example
|
|
387
480
|
* ```typescript
|
|
388
|
-
* const pres =
|
|
481
|
+
* const pres = ax.present(agentId, {
|
|
389
482
|
* onUpdate: (state) => renderUI(state),
|
|
390
483
|
* onError: (error) => console.error(error),
|
|
391
484
|
* });
|
|
@@ -397,12 +490,138 @@ export interface PresentationNamespace {
|
|
|
397
490
|
create(agentId: string, options?: PresentationOptions): Promise<Presentation>;
|
|
398
491
|
}
|
|
399
492
|
|
|
493
|
+
// ============================================================================
|
|
494
|
+
// Instance Namespace — internal implementation details
|
|
495
|
+
// ============================================================================
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Instance — low-level access to internal subsystems.
|
|
499
|
+
*
|
|
500
|
+
* Most users should use the top-level Agent API (ax.create, ax.send, etc.).
|
|
501
|
+
* Instance exposes the underlying image, agent, session, container, llm,
|
|
502
|
+
* and presentation subsystems for advanced use cases.
|
|
503
|
+
*/
|
|
504
|
+
export interface RuntimeNamespace {
|
|
505
|
+
readonly container: ContainerNamespace;
|
|
506
|
+
readonly image: ImageNamespace;
|
|
507
|
+
readonly agent: AgentNamespace;
|
|
508
|
+
readonly session: SessionNamespace;
|
|
509
|
+
readonly present: PresentationNamespace;
|
|
510
|
+
readonly llm: LLMNamespace;
|
|
511
|
+
readonly prototype: PrototypeNamespace;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// ============================================================================
|
|
515
|
+
// Agent Handle
|
|
516
|
+
// ============================================================================
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* AgentHandle — a live reference to a created agent.
|
|
520
|
+
*
|
|
521
|
+
* Returned by `ax.chat.create()` and `ax.chat.get()`. Holds the agent's identity
|
|
522
|
+
* and provides instance-level operations (send, interrupt, etc.).
|
|
523
|
+
*
|
|
524
|
+
* @example
|
|
525
|
+
* ```typescript
|
|
526
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
527
|
+
* await agent.send("Hello!");
|
|
528
|
+
* const messages = await agent.history();
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
export interface AgentHandle {
|
|
532
|
+
readonly agentId: string;
|
|
533
|
+
readonly imageId: string;
|
|
534
|
+
readonly containerId: string;
|
|
535
|
+
readonly sessionId: string;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Send a message to this agent
|
|
539
|
+
*/
|
|
540
|
+
send(content: string | unknown[]): Promise<MessageSendResponse>;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* Interrupt this agent's current response
|
|
544
|
+
*/
|
|
545
|
+
interrupt(): Promise<BaseResponse>;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Get message history
|
|
549
|
+
*/
|
|
550
|
+
history(): Promise<Message[]>;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Create a presentation for UI integration
|
|
554
|
+
*/
|
|
555
|
+
present(options?: PresentationOptions): Promise<Presentation>;
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Update this agent's metadata
|
|
559
|
+
*/
|
|
560
|
+
update(updates: {
|
|
561
|
+
name?: string;
|
|
562
|
+
description?: string;
|
|
563
|
+
embody?: Embodiment;
|
|
564
|
+
customData?: Record<string, unknown>;
|
|
565
|
+
}): Promise<void>;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* Delete this agent
|
|
569
|
+
*/
|
|
570
|
+
delete(): Promise<void>;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// ============================================================================
|
|
574
|
+
// Chat Namespace
|
|
575
|
+
// ============================================================================
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Chat operations — create and manage conversations.
|
|
579
|
+
*
|
|
580
|
+
* Each conversation is backed by an Image (persistent record)
|
|
581
|
+
* and returns an AgentHandle for interaction.
|
|
582
|
+
*/
|
|
583
|
+
export interface ChatNamespace {
|
|
584
|
+
/**
|
|
585
|
+
* Create a new conversation
|
|
586
|
+
*
|
|
587
|
+
* When `prototypeId` is provided, the conversation inherits the prototype's
|
|
588
|
+
* configuration (contextId, embody, etc.). Inline params override prototype values.
|
|
589
|
+
*/
|
|
590
|
+
create(params: {
|
|
591
|
+
prototypeId?: string;
|
|
592
|
+
name?: string;
|
|
593
|
+
description?: string;
|
|
594
|
+
contextId?: string;
|
|
595
|
+
embody?: Embodiment;
|
|
596
|
+
customData?: Record<string, unknown>;
|
|
597
|
+
}): Promise<AgentHandle>;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* List all conversations
|
|
601
|
+
*/
|
|
602
|
+
list(): Promise<ImageListResponse>;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Get a conversation by ID
|
|
606
|
+
*/
|
|
607
|
+
get(id: string): Promise<AgentHandle | null>;
|
|
608
|
+
}
|
|
609
|
+
|
|
400
610
|
// ============================================================================
|
|
401
611
|
// AgentX Client Interface
|
|
402
612
|
// ============================================================================
|
|
403
613
|
|
|
404
614
|
/**
|
|
405
|
-
* AgentX Client SDK — unified interface for local, remote, and server modes
|
|
615
|
+
* AgentX Client SDK — unified interface for local, remote, and server modes.
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```typescript
|
|
619
|
+
* const ax = createAgentX(config);
|
|
620
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
621
|
+
* await agent.send("Hello!");
|
|
622
|
+
* ```
|
|
623
|
+
*
|
|
624
|
+
* For advanced use cases, access `ax.runtime.*` for low-level subsystems.
|
|
406
625
|
*/
|
|
407
626
|
export interface AgentX {
|
|
408
627
|
/**
|
|
@@ -415,14 +634,33 @@ export interface AgentX {
|
|
|
415
634
|
*/
|
|
416
635
|
readonly events: EventBus;
|
|
417
636
|
|
|
418
|
-
// ====================
|
|
637
|
+
// ==================== Chat (conversation) ====================
|
|
419
638
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
readonly
|
|
424
|
-
|
|
425
|
-
|
|
639
|
+
/**
|
|
640
|
+
* Conversation management — create, list, and open conversations.
|
|
641
|
+
*/
|
|
642
|
+
readonly chat: ChatNamespace;
|
|
643
|
+
|
|
644
|
+
// ==================== Prototype (templates) ====================
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Prototype management — register and manage reusable agent templates.
|
|
648
|
+
*/
|
|
649
|
+
readonly prototype: PrototypeNamespace;
|
|
650
|
+
|
|
651
|
+
// ==================== Instance (low-level) ====================
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Low-level access to internal subsystems (image, agent, session, container, llm).
|
|
655
|
+
*/
|
|
656
|
+
readonly runtime: RuntimeNamespace;
|
|
657
|
+
|
|
658
|
+
// ==================== LLM Provider (system-level) ====================
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* LLM provider management (system-level, not per-agent)
|
|
662
|
+
*/
|
|
663
|
+
readonly provider: LLMNamespace;
|
|
426
664
|
|
|
427
665
|
// ==================== Event Subscription ====================
|
|
428
666
|
|
|
@@ -432,35 +670,12 @@ export interface AgentX {
|
|
|
432
670
|
|
|
433
671
|
// ==================== Error Handling ====================
|
|
434
672
|
|
|
435
|
-
/**
|
|
436
|
-
* Top-level error handler — receives all AgentXError instances from any layer.
|
|
437
|
-
*
|
|
438
|
-
* Independent of `on("error", ...)` (stream events) and `presentation.onError` (UI errors).
|
|
439
|
-
*
|
|
440
|
-
* @example
|
|
441
|
-
* ```typescript
|
|
442
|
-
* ax.onError((error) => {
|
|
443
|
-
* console.error(`[${error.category}] ${error.code}: ${error.message}`);
|
|
444
|
-
* if (!error.recoverable) {
|
|
445
|
-
* // Circuit is open, stop sending requests
|
|
446
|
-
* }
|
|
447
|
-
* });
|
|
448
|
-
* ```
|
|
449
|
-
*/
|
|
450
673
|
onError(handler: (error: AgentXError) => void): Unsubscribe;
|
|
451
674
|
|
|
452
675
|
// ==================== RPC ====================
|
|
453
676
|
|
|
454
677
|
/**
|
|
455
|
-
* Universal JSON-RPC entry point
|
|
456
|
-
* - Local: dispatches to CommandHandler directly
|
|
457
|
-
* - Remote: forwards to the remote server via RPC client
|
|
458
|
-
*
|
|
459
|
-
* @example
|
|
460
|
-
* ```typescript
|
|
461
|
-
* const result = await ax.rpc("container.create", { containerId: "default" });
|
|
462
|
-
* const { records } = await ax.rpc<{ records: ImageRecord[] }>("image.list");
|
|
463
|
-
* ```
|
|
678
|
+
* Universal JSON-RPC entry point
|
|
464
679
|
*/
|
|
465
680
|
rpc<T = unknown>(method: string, params?: unknown): Promise<T>;
|
|
466
681
|
|
|
@@ -523,7 +738,8 @@ export interface AgentXServer {
|
|
|
523
738
|
* const ax = createAgentX(node({ createDriver }))
|
|
524
739
|
*
|
|
525
740
|
* // Local use
|
|
526
|
-
* await ax.
|
|
741
|
+
* const agent = await ax.chat.create({ name: "Aristotle" })
|
|
742
|
+
* await agent.send("Hello!")
|
|
527
743
|
*
|
|
528
744
|
* // Connect to remote server
|
|
529
745
|
* const client = await ax.connect("wss://...")
|
|
@@ -1 +0,0 @@
|
|
|
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, systemPrompt, mcpServers, customData } = params as {\n containerId: string;\n name?: string;\n description?: string;\n systemPrompt?: string;\n mcpServers?: Record<string, unknown>;\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, systemPrompt, mcpServers: mcpServers as any, 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: { name?: string; description?: string; customData?: Record<string, unknown> };\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\n const updatedRecord = {\n ...imageRecord,\n ...updates,\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;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,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