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
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Message } from '@agentxjs/core/agent';
|
|
|
4
4
|
import { AgentXError } from '@agentxjs/core/error';
|
|
5
5
|
export { AgentXError, AgentXErrorCategory, AgentXErrorCode, AgentXErrorContext } from '@agentxjs/core/error';
|
|
6
6
|
import { Unsubscribe, BusEvent, EventBus, BusEventHandler } from '@agentxjs/core/event';
|
|
7
|
-
import { LLMProtocol, LLMProviderRecord } from '@agentxjs/core/persistence';
|
|
7
|
+
import { PrototypeRecord, LLMProtocol, LLMProviderRecord } from '@agentxjs/core/persistence';
|
|
8
8
|
import * as _agentxjs_core_network from '@agentxjs/core/network';
|
|
9
9
|
import { RpcMethod } from '@agentxjs/core/network';
|
|
10
10
|
|
|
@@ -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;
|
|
@@ -360,6 +373,30 @@ interface LLMProviderUpdateResponse extends BaseResponse {
|
|
|
360
373
|
interface LLMProviderDefaultResponse extends BaseResponse {
|
|
361
374
|
record: LLMProviderRecord | null;
|
|
362
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* Prototype create response
|
|
378
|
+
*/
|
|
379
|
+
interface PrototypeCreateResponse extends BaseResponse {
|
|
380
|
+
record: PrototypeRecord;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Prototype get response
|
|
384
|
+
*/
|
|
385
|
+
interface PrototypeGetResponse extends BaseResponse {
|
|
386
|
+
record: PrototypeRecord | null;
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Prototype list response
|
|
390
|
+
*/
|
|
391
|
+
interface PrototypeListResponse extends BaseResponse {
|
|
392
|
+
records: PrototypeRecord[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Prototype update response
|
|
396
|
+
*/
|
|
397
|
+
interface PrototypeUpdateResponse extends BaseResponse {
|
|
398
|
+
record: PrototypeRecord;
|
|
399
|
+
}
|
|
363
400
|
/**
|
|
364
401
|
* Container operations namespace
|
|
365
402
|
*/
|
|
@@ -382,14 +419,14 @@ interface ContainerNamespace {
|
|
|
382
419
|
*/
|
|
383
420
|
interface ImageNamespace {
|
|
384
421
|
/**
|
|
385
|
-
* Create a new image
|
|
422
|
+
* Create a new image from an Agent blueprint
|
|
386
423
|
*/
|
|
387
424
|
create(params: {
|
|
388
425
|
containerId: string;
|
|
389
426
|
name?: string;
|
|
390
427
|
description?: string;
|
|
391
|
-
|
|
392
|
-
|
|
428
|
+
contextId?: string;
|
|
429
|
+
embody?: Embodiment;
|
|
393
430
|
customData?: Record<string, unknown>;
|
|
394
431
|
}): Promise<ImageCreateResponse>;
|
|
395
432
|
/**
|
|
@@ -406,6 +443,7 @@ interface ImageNamespace {
|
|
|
406
443
|
update(imageId: string, updates: {
|
|
407
444
|
name?: string;
|
|
408
445
|
description?: string;
|
|
446
|
+
embody?: Embodiment;
|
|
409
447
|
customData?: Record<string, unknown>;
|
|
410
448
|
}): Promise<ImageUpdateResponse>;
|
|
411
449
|
/**
|
|
@@ -506,6 +544,44 @@ interface LLMNamespace {
|
|
|
506
544
|
*/
|
|
507
545
|
getDefault(containerId: string): Promise<LLMProviderDefaultResponse>;
|
|
508
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* Prototype operations namespace — manage reusable agent templates
|
|
549
|
+
*/
|
|
550
|
+
interface PrototypeNamespace {
|
|
551
|
+
/**
|
|
552
|
+
* Register a new prototype
|
|
553
|
+
*/
|
|
554
|
+
create(params: {
|
|
555
|
+
containerId: string;
|
|
556
|
+
name: string;
|
|
557
|
+
description?: string;
|
|
558
|
+
contextId?: string;
|
|
559
|
+
embody?: Embodiment;
|
|
560
|
+
customData?: Record<string, unknown>;
|
|
561
|
+
}): Promise<PrototypeCreateResponse>;
|
|
562
|
+
/**
|
|
563
|
+
* Get prototype by ID
|
|
564
|
+
*/
|
|
565
|
+
get(prototypeId: string): Promise<PrototypeGetResponse>;
|
|
566
|
+
/**
|
|
567
|
+
* List prototypes
|
|
568
|
+
*/
|
|
569
|
+
list(containerId?: string): Promise<PrototypeListResponse>;
|
|
570
|
+
/**
|
|
571
|
+
* Update prototype
|
|
572
|
+
*/
|
|
573
|
+
update(prototypeId: string, updates: {
|
|
574
|
+
name?: string;
|
|
575
|
+
description?: string;
|
|
576
|
+
contextId?: string;
|
|
577
|
+
embody?: Embodiment;
|
|
578
|
+
customData?: Record<string, unknown>;
|
|
579
|
+
}): Promise<PrototypeUpdateResponse>;
|
|
580
|
+
/**
|
|
581
|
+
* Delete prototype
|
|
582
|
+
*/
|
|
583
|
+
delete(prototypeId: string): Promise<BaseResponse>;
|
|
584
|
+
}
|
|
509
585
|
/**
|
|
510
586
|
* Presentation operations namespace
|
|
511
587
|
*/
|
|
@@ -515,7 +591,7 @@ interface PresentationNamespace {
|
|
|
515
591
|
*
|
|
516
592
|
* @example
|
|
517
593
|
* ```typescript
|
|
518
|
-
* const pres =
|
|
594
|
+
* const pres = ax.present(agentId, {
|
|
519
595
|
* onUpdate: (state) => renderUI(state),
|
|
520
596
|
* onError: (error) => console.error(error),
|
|
521
597
|
* });
|
|
@@ -527,7 +603,110 @@ interface PresentationNamespace {
|
|
|
527
603
|
create(agentId: string, options?: PresentationOptions): Promise<Presentation>;
|
|
528
604
|
}
|
|
529
605
|
/**
|
|
530
|
-
*
|
|
606
|
+
* Instance — low-level access to internal subsystems.
|
|
607
|
+
*
|
|
608
|
+
* Most users should use the top-level Agent API (ax.create, ax.send, etc.).
|
|
609
|
+
* Instance exposes the underlying image, agent, session, container, llm,
|
|
610
|
+
* and presentation subsystems for advanced use cases.
|
|
611
|
+
*/
|
|
612
|
+
interface RuntimeNamespace {
|
|
613
|
+
readonly container: ContainerNamespace;
|
|
614
|
+
readonly image: ImageNamespace;
|
|
615
|
+
readonly agent: AgentNamespace;
|
|
616
|
+
readonly session: SessionNamespace;
|
|
617
|
+
readonly present: PresentationNamespace;
|
|
618
|
+
readonly llm: LLMNamespace;
|
|
619
|
+
readonly prototype: PrototypeNamespace;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* AgentHandle — a live reference to a created agent.
|
|
623
|
+
*
|
|
624
|
+
* Returned by `ax.chat.create()` and `ax.chat.get()`. Holds the agent's identity
|
|
625
|
+
* and provides instance-level operations (send, interrupt, etc.).
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```typescript
|
|
629
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
630
|
+
* await agent.send("Hello!");
|
|
631
|
+
* const messages = await agent.history();
|
|
632
|
+
* ```
|
|
633
|
+
*/
|
|
634
|
+
interface AgentHandle {
|
|
635
|
+
readonly agentId: string;
|
|
636
|
+
readonly imageId: string;
|
|
637
|
+
readonly containerId: string;
|
|
638
|
+
readonly sessionId: string;
|
|
639
|
+
/**
|
|
640
|
+
* Send a message to this agent
|
|
641
|
+
*/
|
|
642
|
+
send(content: string | unknown[]): Promise<MessageSendResponse>;
|
|
643
|
+
/**
|
|
644
|
+
* Interrupt this agent's current response
|
|
645
|
+
*/
|
|
646
|
+
interrupt(): Promise<BaseResponse>;
|
|
647
|
+
/**
|
|
648
|
+
* Get message history
|
|
649
|
+
*/
|
|
650
|
+
history(): Promise<Message[]>;
|
|
651
|
+
/**
|
|
652
|
+
* Create a presentation for UI integration
|
|
653
|
+
*/
|
|
654
|
+
present(options?: PresentationOptions): Promise<Presentation>;
|
|
655
|
+
/**
|
|
656
|
+
* Update this agent's metadata
|
|
657
|
+
*/
|
|
658
|
+
update(updates: {
|
|
659
|
+
name?: string;
|
|
660
|
+
description?: string;
|
|
661
|
+
embody?: Embodiment;
|
|
662
|
+
customData?: Record<string, unknown>;
|
|
663
|
+
}): Promise<void>;
|
|
664
|
+
/**
|
|
665
|
+
* Delete this agent
|
|
666
|
+
*/
|
|
667
|
+
delete(): Promise<void>;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Chat operations — create and manage conversations.
|
|
671
|
+
*
|
|
672
|
+
* Each conversation is backed by an Image (persistent record)
|
|
673
|
+
* and returns an AgentHandle for interaction.
|
|
674
|
+
*/
|
|
675
|
+
interface ChatNamespace {
|
|
676
|
+
/**
|
|
677
|
+
* Create a new conversation
|
|
678
|
+
*
|
|
679
|
+
* When `prototypeId` is provided, the conversation inherits the prototype's
|
|
680
|
+
* configuration (contextId, embody, etc.). Inline params override prototype values.
|
|
681
|
+
*/
|
|
682
|
+
create(params: {
|
|
683
|
+
prototypeId?: string;
|
|
684
|
+
name?: string;
|
|
685
|
+
description?: string;
|
|
686
|
+
contextId?: string;
|
|
687
|
+
embody?: Embodiment;
|
|
688
|
+
customData?: Record<string, unknown>;
|
|
689
|
+
}): Promise<AgentHandle>;
|
|
690
|
+
/**
|
|
691
|
+
* List all conversations
|
|
692
|
+
*/
|
|
693
|
+
list(): Promise<ImageListResponse>;
|
|
694
|
+
/**
|
|
695
|
+
* Get a conversation by ID
|
|
696
|
+
*/
|
|
697
|
+
get(id: string): Promise<AgentHandle | null>;
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* AgentX Client SDK — unified interface for local, remote, and server modes.
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```typescript
|
|
704
|
+
* const ax = createAgentX(config);
|
|
705
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
706
|
+
* await agent.send("Hello!");
|
|
707
|
+
* ```
|
|
708
|
+
*
|
|
709
|
+
* For advanced use cases, access `ax.runtime.*` for low-level subsystems.
|
|
531
710
|
*/
|
|
532
711
|
interface AgentX {
|
|
533
712
|
/**
|
|
@@ -538,43 +717,30 @@ interface AgentX {
|
|
|
538
717
|
* Event bus for subscribing to events
|
|
539
718
|
*/
|
|
540
719
|
readonly events: EventBus;
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
readonly
|
|
545
|
-
|
|
546
|
-
|
|
720
|
+
/**
|
|
721
|
+
* Conversation management — create, list, and open conversations.
|
|
722
|
+
*/
|
|
723
|
+
readonly chat: ChatNamespace;
|
|
724
|
+
/**
|
|
725
|
+
* Prototype management — register and manage reusable agent templates.
|
|
726
|
+
*/
|
|
727
|
+
readonly prototype: PrototypeNamespace;
|
|
728
|
+
/**
|
|
729
|
+
* Low-level access to internal subsystems (image, agent, session, container, llm).
|
|
730
|
+
*/
|
|
731
|
+
readonly runtime: RuntimeNamespace;
|
|
732
|
+
/**
|
|
733
|
+
* LLM provider management (system-level, not per-agent)
|
|
734
|
+
*/
|
|
735
|
+
readonly provider: LLMNamespace;
|
|
547
736
|
on<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
|
|
548
737
|
type: T;
|
|
549
738
|
}>): Unsubscribe;
|
|
550
739
|
onAny(handler: BusEventHandler): Unsubscribe;
|
|
551
740
|
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
741
|
onError(handler: (error: AgentXError) => void): Unsubscribe;
|
|
568
742
|
/**
|
|
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
|
-
* ```
|
|
743
|
+
* Universal JSON-RPC entry point
|
|
578
744
|
*/
|
|
579
745
|
rpc<T = unknown>(method: string, params?: unknown): Promise<T>;
|
|
580
746
|
disconnect(): Promise<void>;
|
|
@@ -626,7 +792,8 @@ interface AgentXServer {
|
|
|
626
792
|
* const ax = createAgentX(node({ createDriver }))
|
|
627
793
|
*
|
|
628
794
|
* // Local use
|
|
629
|
-
* await ax.
|
|
795
|
+
* const agent = await ax.chat.create({ name: "Aristotle" })
|
|
796
|
+
* await agent.send("Hello!")
|
|
630
797
|
*
|
|
631
798
|
* // Connect to remote server
|
|
632
799
|
* const client = await ax.connect("wss://...")
|
|
@@ -695,6 +862,11 @@ declare class CommandHandler {
|
|
|
695
862
|
private handleAgentDestroyAll;
|
|
696
863
|
private handleAgentInterrupt;
|
|
697
864
|
private handleMessageSend;
|
|
865
|
+
private handlePrototypeCreate;
|
|
866
|
+
private handlePrototypeGet;
|
|
867
|
+
private handlePrototypeList;
|
|
868
|
+
private handlePrototypeUpdate;
|
|
869
|
+
private handlePrototypeDelete;
|
|
698
870
|
private handleLLMCreate;
|
|
699
871
|
private handleLLMGet;
|
|
700
872
|
private handleLLMList;
|
|
@@ -753,7 +925,8 @@ declare function createServer(config: ServerConfig): Promise<AgentXServer>;
|
|
|
753
925
|
* import { nodePlatform } from "@agentxjs/node-platform";
|
|
754
926
|
*
|
|
755
927
|
* const ax = createAgentX(nodePlatform({ createDriver }));
|
|
756
|
-
* await ax.
|
|
928
|
+
* const agent = await ax.chat.create({ name: "Aristotle", embody: { model: "claude-sonnet-4-6" } });
|
|
929
|
+
* await agent.send("Hello!");
|
|
757
930
|
* ```
|
|
758
931
|
*
|
|
759
932
|
* @example Remote mode
|
|
@@ -784,4 +957,4 @@ interface PlatformConfig {
|
|
|
784
957
|
*/
|
|
785
958
|
declare function createAgentX(config?: PlatformConfig): AgentXBuilder;
|
|
786
959
|
|
|
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 };
|
|
960
|
+
export { type AgentCreateResponse, type AgentGetResponse, type AgentHandle, type AgentInfo, type AgentListResponse, type AgentNamespace, type AgentX, type AgentXBuilder, type AgentXServer, type AssistantConversation, type BaseResponse, type Block, type ChatNamespace, CommandHandler, type ConnectOptions, type ContainerCreateResponse, type ContainerGetResponse, type ContainerInfo, type ContainerListResponse, type ContainerNamespace, type Conversation, type Embodiment, type ErrorConversation, type ImageBlock, type ImageCreateResponse, type ImageGetResponse, type ImageListResponse, type ImageNamespace, type ImageRecord, type LLMNamespace, type LLMProviderCreateResponse, type LLMProviderDefaultResponse, type LLMProviderGetResponse, type LLMProviderListResponse, type LLMProviderUpdateResponse, type MaybeAsync, type MessageSendResponse, type PlatformConfig, Presentation, type PresentationErrorHandler, type PresentationNamespace, type PresentationOptions, type PresentationState, type PresentationUpdateHandler, type PrototypeCreateResponse, type PrototypeGetResponse, type PrototypeListResponse, type PrototypeNamespace, type PrototypeUpdateResponse, type RuntimeNamespace, type ServeConfig, type ServerConfig, type SessionNamespace, type TextBlock, type ToolBlock, type UserConversation, addUserConversation, createAgentX, createInitialState, createServer, initialPresentationState, messagesToConversations, presentationReducer };
|