agentxjs 2.0.2 → 2.0.4

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/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { Message } from '@agentxjs/core/agent';
2
1
  import { CreateDriver } from '@agentxjs/core/driver';
2
+ import { AgentXRuntime, AgentXPlatform } from '@agentxjs/core/runtime';
3
+ import { Message } from '@agentxjs/core/agent';
3
4
  import { Unsubscribe, BusEvent, EventBus, BusEventHandler } from '@agentxjs/core/event';
4
- import { AgentXPlatform } from '@agentxjs/core/runtime';
5
+ import * as _agentxjs_core_network from '@agentxjs/core/network';
6
+ import { RpcMethod } from '@agentxjs/core/network';
5
7
 
6
8
  /**
7
9
  * Presentation Types
@@ -214,87 +216,6 @@ declare function messagesToConversations(messages: Message[]): Conversation[];
214
216
  * Static or dynamic value
215
217
  */
216
218
  type MaybeAsync<T> = T | (() => T) | (() => Promise<T>);
217
- /**
218
- * LLM provider identifier
219
- */
220
- type LLMProvider = "anthropic" | "openai" | "google" | "xai" | "deepseek" | "mistral";
221
- /**
222
- * AgentX unified configuration
223
- *
224
- * Supports two modes:
225
- * - **Local mode**: `apiKey` present → embedded Runtime + MonoDriver
226
- * - **Remote mode**: `serverUrl` present → WebSocket client
227
- */
228
- interface AgentXConfig {
229
- /**
230
- * API key for LLM provider (local mode)
231
- * If present, enables local mode with embedded Runtime
232
- */
233
- apiKey?: string;
234
- /**
235
- * LLM provider (local mode)
236
- * @default "anthropic"
237
- */
238
- provider?: LLMProvider;
239
- /**
240
- * Model ID (local mode)
241
- */
242
- model?: string;
243
- /**
244
- * Base URL for API endpoint (local mode, for proxy/private deployments)
245
- */
246
- baseUrl?: string;
247
- /**
248
- * Data storage path (local mode)
249
- * @default ":memory:" (in-memory storage)
250
- */
251
- dataPath?: string;
252
- /**
253
- * Custom CreateDriver factory (local mode, advanced)
254
- * If provided, overrides the default MonoDriver
255
- */
256
- createDriver?: CreateDriver;
257
- /**
258
- * Custom AgentXPlatform (local mode, advanced)
259
- * If provided, overrides the default NodePlatform
260
- */
261
- customPlatform?: AgentXPlatform;
262
- /**
263
- * WebSocket server URL (remote mode)
264
- * If present, enables remote mode
265
- */
266
- serverUrl?: string;
267
- /**
268
- * Headers for authentication (remote mode, static or dynamic)
269
- * In Node.js: sent during WebSocket handshake
270
- * In browsers: sent as first auth message (WebSocket API limitation)
271
- */
272
- headers?: MaybeAsync<Record<string, string>>;
273
- /**
274
- * Business context injected into all requests (remote mode)
275
- * Useful for passing userId, tenantId, permissions, etc.
276
- */
277
- context?: MaybeAsync<Record<string, unknown>>;
278
- /**
279
- * Log level for AgentX runtime
280
- * Controls verbosity of console/file logging.
281
- * @default "info"
282
- */
283
- logLevel?: "debug" | "info" | "warn" | "error" | "silent";
284
- /**
285
- * Request timeout in milliseconds (default: 30000)
286
- */
287
- timeout?: number;
288
- /**
289
- * Enable debug logging
290
- * @deprecated Use `logLevel: "debug"` instead
291
- */
292
- debug?: boolean;
293
- /**
294
- * Auto reconnect on connection loss (default: true, remote mode only)
295
- */
296
- autoReconnect?: boolean;
297
- }
298
219
  /**
299
220
  * Agent info returned from server
300
221
  */
@@ -509,7 +430,7 @@ interface PresentationNamespace {
509
430
  *
510
431
  * @example
511
432
  * ```typescript
512
- * const pres = agentx.presentations.create(agentId, {
433
+ * const pres = agentx.presentation.create(agentId, {
513
434
  * onUpdate: (state) => renderUI(state),
514
435
  * onError: (error) => console.error(error),
515
436
  * });
@@ -521,106 +442,226 @@ interface PresentationNamespace {
521
442
  create(agentId: string, options?: PresentationOptions): Promise<Presentation>;
522
443
  }
523
444
  /**
524
- * AgentX Client SDK
445
+ * AgentX Client SDK — unified interface for local, remote, and server modes
525
446
  */
526
447
  interface AgentX {
527
448
  /**
528
- * Check if connected to server
449
+ * Check if connected/active
529
450
  */
530
451
  readonly connected: boolean;
531
452
  /**
532
453
  * Event bus for subscribing to events
533
454
  */
534
455
  readonly events: EventBus;
456
+ readonly container: ContainerNamespace;
457
+ readonly image: ImageNamespace;
458
+ readonly agent: AgentNamespace;
459
+ readonly session: SessionNamespace;
460
+ readonly presentation: PresentationNamespace;
461
+ on<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
462
+ type: T;
463
+ }>): Unsubscribe;
464
+ onAny(handler: BusEventHandler): Unsubscribe;
465
+ subscribe(sessionId: string): void;
466
+ disconnect(): Promise<void>;
467
+ dispose(): Promise<void>;
468
+ }
469
+ /**
470
+ * Options for connecting to a remote AgentX server
471
+ */
472
+ interface ConnectOptions {
473
+ /** Authentication headers */
474
+ headers?: MaybeAsync<Record<string, string>>;
475
+ /** Business context injected into requests */
476
+ context?: MaybeAsync<Record<string, unknown>>;
477
+ /** Request timeout in ms (default: 30000) */
478
+ timeout?: number;
479
+ /** Auto reconnect on disconnect (default: true) */
480
+ autoReconnect?: boolean;
481
+ }
482
+ /**
483
+ * Configuration for serving as an AgentX server
484
+ */
485
+ interface ServeConfig {
486
+ /** Port to listen on (default: 5200) */
487
+ port?: number;
488
+ /** Host to bind to (default: "0.0.0.0") */
489
+ host?: string;
490
+ /** Existing HTTP server to attach to */
491
+ server?: unknown;
492
+ /** WebSocket path when attached (default: "/ws") */
493
+ wsPath?: string;
494
+ }
495
+ /**
496
+ * Server instance returned by serve()
497
+ */
498
+ interface AgentXServer {
499
+ listen(port?: number, host?: string): Promise<void>;
500
+ close(): Promise<void>;
501
+ dispose(): Promise<void>;
502
+ }
503
+ /**
504
+ * AgentXBuilder — fluent API entry point
505
+ *
506
+ * Created by `createAgentX(platform?)`. The builder itself is an AgentX
507
+ * instance (local mode). Call `.connect()` to get a remote client,
508
+ * or `.serve()` to start a server.
509
+ *
510
+ * @example
511
+ * ```typescript
512
+ * const ax = createAgentX(node({ createDriver }))
513
+ *
514
+ * // Local use
515
+ * await ax.agent.create({ imageId: "..." })
516
+ *
517
+ * // Connect to remote server
518
+ * const client = await ax.connect("wss://...")
519
+ *
520
+ * // Serve as server
521
+ * const server = await ax.serve({ port: 3100 })
522
+ * ```
523
+ */
524
+ interface AgentXBuilder extends AgentX {
535
525
  /**
536
- * Container operations
537
- */
538
- readonly containers: ContainerNamespace;
539
- /**
540
- * Image operations
526
+ * Connect to a remote AgentX server
541
527
  */
542
- readonly images: ImageNamespace;
528
+ connect(serverUrl: string, options?: ConnectOptions): Promise<AgentX>;
543
529
  /**
544
- * Agent operations
530
+ * Start serving as an AgentX server
545
531
  */
546
- readonly agents: AgentNamespace;
532
+ serve(config?: ServeConfig): Promise<AgentXServer>;
533
+ }
534
+
535
+ /**
536
+ * CommandHandler - Handles JSON-RPC requests directly
537
+ *
538
+ * No longer uses EventBus for request/response. Instead:
539
+ * - Receives RPC requests directly
540
+ * - Returns RPC responses directly
541
+ * - EventBus is only used for stream events (notifications)
542
+ */
543
+
544
+ /**
545
+ * RPC Result type
546
+ */
547
+ interface RpcResult<T = unknown> {
548
+ success: true;
549
+ data: T;
550
+ }
551
+ interface RpcError {
552
+ success: false;
553
+ code: number;
554
+ message: string;
555
+ }
556
+ type RpcResponse<T = unknown> = RpcResult<T> | RpcError;
557
+ /**
558
+ * CommandHandler - Processes RPC requests directly
559
+ */
560
+ declare class CommandHandler {
561
+ private readonly runtime;
562
+ constructor(runtime: AgentXRuntime);
563
+ /**
564
+ * Handle an RPC request and return response
565
+ */
566
+ handle(method: RpcMethod, params: unknown): Promise<RpcResponse>;
567
+ private handleContainerCreate;
568
+ private handleContainerGet;
569
+ private handleContainerList;
570
+ private handleImageCreate;
571
+ private handleImageGet;
572
+ private handleImageList;
573
+ private handleImageDelete;
574
+ private handleImageRun;
575
+ private handleImageStop;
576
+ private handleImageUpdate;
577
+ private handleImageMessages;
578
+ private handleAgentGet;
579
+ private handleAgentList;
580
+ private handleAgentDestroy;
581
+ private handleAgentDestroyAll;
582
+ private handleAgentInterrupt;
583
+ private handleMessageSend;
584
+ dispose(): void;
585
+ }
586
+
587
+ /**
588
+ * Server configuration (supports both immediate and deferred platforms)
589
+ */
590
+ interface ServerConfig {
547
591
  /**
548
- * Session operations (messaging)
592
+ * AgentX Platform — must provide `channelServer` for accepting WebSocket connections.
549
593
  */
550
- readonly sessions: SessionNamespace;
594
+ platform: AgentXPlatform;
551
595
  /**
552
- * Presentation operations (UI integration)
596
+ * LLM Driver factory function - creates Driver per Agent
553
597
  */
554
- readonly presentations: PresentationNamespace;
598
+ createDriver: CreateDriver;
555
599
  /**
556
- * Subscribe to specific event type
600
+ * Port to listen on (standalone mode)
557
601
  */
558
- on<T extends string>(type: T, handler: BusEventHandler<BusEvent & {
559
- type: T;
560
- }>): Unsubscribe;
602
+ port?: number;
561
603
  /**
562
- * Subscribe to all events
604
+ * Host to bind to (default: "0.0.0.0")
563
605
  */
564
- onAny(handler: BusEventHandler): Unsubscribe;
606
+ host?: string;
565
607
  /**
566
- * Subscribe to session events
608
+ * Existing HTTP server to attach to (attached mode)
567
609
  */
568
- subscribe(sessionId: string): void;
610
+ server?: _agentxjs_core_network.MinimalHTTPServer;
569
611
  /**
570
- * Disconnect from server
612
+ * WebSocket path when attached (default: "/ws")
571
613
  */
572
- disconnect(): Promise<void>;
614
+ wsPath?: string;
573
615
  /**
574
- * Dispose and cleanup
616
+ * Enable debug logging
575
617
  */
576
- dispose(): Promise<void>;
618
+ debug?: boolean;
577
619
  }
620
+ /**
621
+ * Create an AgentX server
622
+ */
623
+ declare function createServer(config: ServerConfig): Promise<AgentXServer>;
578
624
 
579
625
  /**
580
626
  * agentxjs - AgentX Client SDK
581
627
  *
582
- * Unified entry point supporting local and remote modes.
628
+ * Fluent API supporting local, remote, and server modes.
583
629
  *
584
- * @example Local mode (embedded runtime)
630
+ * @example Local mode
585
631
  * ```typescript
586
632
  * import { createAgentX } from "agentxjs";
633
+ * import { node } from "@agentxjs/node-platform";
587
634
  *
588
- * const agentx = await createAgentX({
589
- * apiKey: process.env.ANTHROPIC_API_KEY,
590
- * provider: "anthropic",
591
- * });
592
- *
593
- * await agentx.containers.create("my-app");
594
- * const { record: image } = await agentx.images.create({
595
- * containerId: "my-app",
596
- * systemPrompt: "You are helpful",
597
- * });
598
- * const { agentId } = await agentx.agents.create({ imageId: image.imageId });
599
- *
600
- * agentx.on("text_delta", (e) => process.stdout.write(e.data.text));
601
- * await agentx.sessions.send(agentId, "Hello!");
635
+ * const ax = createAgentX(node({ createDriver }));
636
+ * await ax.agent.create({ imageId: "..." });
602
637
  * ```
603
638
  *
604
- * @example Remote mode (WebSocket client)
639
+ * @example Remote mode
605
640
  * ```typescript
606
- * import { createAgentX } from "agentxjs";
641
+ * const ax = createAgentX();
642
+ * const client = await ax.connect("ws://localhost:5200");
643
+ * ```
607
644
  *
608
- * const agentx = await createAgentX({
609
- * serverUrl: "ws://localhost:5200",
610
- * });
645
+ * @example Server mode
646
+ * ```typescript
647
+ * const ax = createAgentX(node({ createDriver }));
648
+ * const server = await ax.serve({ port: 5200 });
611
649
  * ```
612
650
  */
613
651
 
614
652
  /**
615
- * Create an AgentX client
616
- *
617
- * Mode detection:
618
- * - `serverUrl` present → **Remote mode** (WebSocket client)
619
- * - `apiKey` present → **Local mode** (embedded Runtime + MonoDriver)
653
+ * Platform configuration for createAgentX
654
+ */
655
+ interface PlatformConfig {
656
+ platform: AgentXPlatform;
657
+ createDriver: CreateDriver;
658
+ }
659
+ /**
660
+ * Create an AgentX builder
620
661
  *
621
- * @param config - Client configuration
622
- * @returns Connected AgentX client
662
+ * @param config - Platform configuration (optional). Without it, only connect() is available.
663
+ * @returns AgentXBuilder — local AgentX + connect() + serve()
623
664
  */
624
- declare function createAgentX(config: AgentXConfig): Promise<AgentX>;
665
+ declare function createAgentX(config?: PlatformConfig): AgentXBuilder;
625
666
 
626
- export { type AgentCreateResponse, type AgentGetResponse, type AgentInfo, type AgentListResponse, type AgentNamespace, type AgentX, type AgentXConfig, type AssistantConversation, type BaseResponse, type Block, 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 LLMProvider, type MaybeAsync, type MessageSendResponse, Presentation, type PresentationErrorHandler, type PresentationNamespace, type PresentationOptions, type PresentationState, type PresentationUpdateHandler, type SessionNamespace, type TextBlock, type ToolBlock, type UserConversation, addUserConversation, createAgentX, createInitialState, initialPresentationState, messagesToConversations, presentationReducer };
667
+ 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 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 };
package/dist/index.js CHANGED
@@ -1,3 +1,11 @@
1
+ import {
2
+ CommandHandler,
3
+ createServer
4
+ } from "./chunk-ZFL27HK7.js";
5
+
6
+ // src/index.ts
7
+ import { createAgentXRuntime } from "@agentxjs/core/runtime";
8
+
1
9
  // src/LocalClient.ts
2
10
  import { createLogger } from "commonxjs/logger";
3
11
 
@@ -586,7 +594,7 @@ var Presentation = class {
586
594
  this.state = addUserConversation(this.state, content);
587
595
  this.notify();
588
596
  try {
589
- await this.agentx.sessions.send(this.agentId, content);
597
+ await this.agentx.session.send(this.agentId, content);
590
598
  } catch (error) {
591
599
  this.notifyError(error instanceof Error ? error : new Error(String(error)));
592
600
  }
@@ -596,7 +604,7 @@ var Presentation = class {
596
604
  */
597
605
  async interrupt() {
598
606
  try {
599
- await this.agentx.sessions.interrupt(this.agentId);
607
+ await this.agentx.session.interrupt(this.agentId);
600
608
  } catch (error) {
601
609
  this.notifyError(error instanceof Error ? error : new Error(String(error)));
602
610
  }
@@ -658,7 +666,7 @@ var Presentation = class {
658
666
  function createPresentations(agentx) {
659
667
  return {
660
668
  async create(agentId, options) {
661
- const messages = await agentx.sessions.getMessages(agentId);
669
+ const messages = await agentx.session.getMessages(agentId);
662
670
  const conversations = messagesToConversations(messages);
663
671
  return new Presentation(agentx, agentId, options, conversations);
664
672
  }
@@ -712,19 +720,19 @@ var logger = createLogger("agentx/LocalClient");
712
720
  var LocalClient = class {
713
721
  runtime;
714
722
  isDisposed = false;
715
- containers;
716
- images;
717
- agents;
718
- sessions;
719
- presentations;
723
+ container;
724
+ image;
725
+ agent;
726
+ session;
727
+ presentation;
720
728
  constructor(runtime) {
721
729
  this.runtime = runtime;
722
730
  const platform = runtime.platform;
723
- this.containers = createLocalContainers(platform);
724
- this.images = createLocalImages(platform);
725
- this.agents = createLocalAgents(runtime);
726
- this.sessions = createLocalSessions(runtime);
727
- this.presentations = createPresentations(this);
731
+ this.container = createLocalContainers(platform);
732
+ this.image = createLocalImages(platform);
733
+ this.agent = createLocalAgents(runtime);
734
+ this.session = createLocalSessions(runtime);
735
+ this.presentation = createPresentations(this);
728
736
  logger.info("LocalClient initialized");
729
737
  }
730
738
  // ==================== Properties ====================
@@ -763,11 +771,11 @@ var RemoteClient = class {
763
771
  config;
764
772
  eventBus;
765
773
  rpcClient;
766
- containers;
767
- images;
768
- agents;
769
- sessions;
770
- presentations;
774
+ container;
775
+ image;
776
+ agent;
777
+ session;
778
+ presentation;
771
779
  constructor(config) {
772
780
  this.config = config;
773
781
  this.eventBus = new EventBusImpl();
@@ -783,11 +791,11 @@ var RemoteClient = class {
783
791
  logger2.debug("Received stream event", { topic, type: event.type });
784
792
  this.eventBus.emit(event);
785
793
  });
786
- this.containers = createRemoteContainers(this.rpcClient);
787
- this.images = createRemoteImages(this.rpcClient, (sessionId) => this.subscribe(sessionId));
788
- this.agents = createRemoteAgents(this.rpcClient);
789
- this.sessions = createRemoteSessions(this.rpcClient);
790
- this.presentations = createPresentations(this);
794
+ this.container = createRemoteContainers(this.rpcClient);
795
+ this.image = createRemoteImages(this.rpcClient, (sessionId) => this.subscribe(sessionId));
796
+ this.agent = createRemoteAgents(this.rpcClient);
797
+ this.session = createRemoteSessions(this.rpcClient);
798
+ this.presentation = createPresentations(this);
791
799
  }
792
800
  // ==================== Properties ====================
793
801
  get connected() {
@@ -824,77 +832,100 @@ var RemoteClient = class {
824
832
  };
825
833
 
826
834
  // src/index.ts
827
- async function createAgentX(config) {
828
- if (config.serverUrl) {
829
- const resolvedConfig = await resolvePlatformForRemote(config);
830
- const client = new RemoteClient(resolvedConfig);
831
- await client.connect();
832
- return client;
833
- }
834
- if (config.apiKey || config.createDriver || config.customPlatform) {
835
- return createLocalClient(config);
836
- }
837
- throw new Error(
838
- "Invalid AgentX config: provide either 'serverUrl' (remote mode) or 'apiKey' (local mode)"
839
- );
840
- }
841
- async function resolvePlatformForRemote(config) {
842
- if (config.customPlatform?.channelClient) {
843
- return config;
835
+ function createAgentX(config) {
836
+ let localClient = null;
837
+ function getLocalClient() {
838
+ if (localClient) return localClient;
839
+ if (!config) {
840
+ throw new Error(
841
+ "Local mode requires a platform. Pass a PlatformConfig to createAgentX(), or use connect() for remote mode."
842
+ );
843
+ }
844
+ const runtime = createAgentXRuntime(config.platform, config.createDriver);
845
+ localClient = new LocalClient(runtime);
846
+ return localClient;
844
847
  }
845
- if (typeof globalThis !== "undefined" && globalThis.window?.document !== void 0) {
846
- return config;
848
+ if (config) {
849
+ getLocalClient();
847
850
  }
848
- try {
849
- const { createNodeWebSocket } = await import("@agentxjs/node-platform/network");
850
- return {
851
- ...config,
852
- customPlatform: {
853
- ...config.customPlatform,
854
- channelClient: createNodeWebSocket
851
+ return {
852
+ get connected() {
853
+ return localClient?.connected ?? false;
854
+ },
855
+ get events() {
856
+ return getLocalClient().events;
857
+ },
858
+ get container() {
859
+ return getLocalClient().container;
860
+ },
861
+ get image() {
862
+ return getLocalClient().image;
863
+ },
864
+ get agent() {
865
+ return getLocalClient().agent;
866
+ },
867
+ get session() {
868
+ return getLocalClient().session;
869
+ },
870
+ get presentation() {
871
+ return getLocalClient().presentation;
872
+ },
873
+ on(type, handler) {
874
+ return getLocalClient().on(type, handler);
875
+ },
876
+ onAny(handler) {
877
+ return getLocalClient().onAny(handler);
878
+ },
879
+ subscribe(sessionId) {
880
+ getLocalClient().subscribe(sessionId);
881
+ },
882
+ async disconnect() {
883
+ await localClient?.disconnect();
884
+ },
885
+ async dispose() {
886
+ await localClient?.dispose();
887
+ localClient = null;
888
+ },
889
+ async connect(serverUrl, options) {
890
+ const remoteClient = new RemoteClient({
891
+ serverUrl,
892
+ headers: options?.headers,
893
+ context: options?.context,
894
+ timeout: options?.timeout,
895
+ autoReconnect: options?.autoReconnect,
896
+ customPlatform: config?.platform
897
+ });
898
+ await remoteClient.connect();
899
+ return remoteClient;
900
+ },
901
+ async serve(serveConfig) {
902
+ if (!config) {
903
+ throw new Error("serve() requires a platform. Pass a PlatformConfig to createAgentX().");
855
904
  }
856
- };
857
- } catch {
858
- return config;
859
- }
860
- }
861
- async function createLocalClient(config) {
862
- const { createAgentXRuntime } = await import("@agentxjs/core/runtime");
863
- let platform;
864
- if (config.customPlatform) {
865
- platform = config.customPlatform;
866
- } else {
867
- const { createNodePlatform } = await import("@agentxjs/node-platform");
868
- platform = await createNodePlatform({
869
- dataPath: config.dataPath ?? ":memory:",
870
- logLevel: config.logLevel ?? (config.debug ? "debug" : void 0)
871
- });
872
- }
873
- let createDriver = config.createDriver;
874
- if (!createDriver) {
875
- const { createMonoDriver } = await import("@agentxjs/mono-driver");
876
- createDriver = (driverConfig) => {
877
- const existingOptions = driverConfig.options ?? {};
878
- return createMonoDriver({
879
- ...driverConfig,
880
- apiKey: config.apiKey ?? driverConfig.apiKey,
881
- baseUrl: config.baseUrl ?? driverConfig.baseUrl,
882
- model: config.model ?? driverConfig.model,
883
- options: {
884
- ...existingOptions,
885
- provider: config.provider ?? existingOptions.provider ?? "anthropic"
886
- }
905
+ if (!config.platform.channelServer) {
906
+ throw new Error(
907
+ "serve() requires platform.channelServer. Ensure your platform supports server mode."
908
+ );
909
+ }
910
+ const { createServer: createServer2 } = await import("./server-IFVYHIJF.js");
911
+ return createServer2({
912
+ platform: config.platform,
913
+ createDriver: config.createDriver,
914
+ port: serveConfig?.port,
915
+ host: serveConfig?.host,
916
+ server: serveConfig?.server,
917
+ wsPath: serveConfig?.wsPath
887
918
  });
888
- };
889
- }
890
- const runtime = createAgentXRuntime(platform, createDriver);
891
- return new LocalClient(runtime);
919
+ }
920
+ };
892
921
  }
893
922
  export {
923
+ CommandHandler,
894
924
  Presentation,
895
925
  addUserConversation,
896
926
  createAgentX,
897
927
  createInitialState,
928
+ createServer,
898
929
  initialPresentationState,
899
930
  messagesToConversations,
900
931
  presentationReducer