@multi-agent-protocol/sdk 0.0.4 → 0.0.6

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.
@@ -1,3 +1,5 @@
1
+ import { EventEmitter } from 'events';
2
+
1
3
  /**
2
4
  * Multi-Agent Protocol (MAP) Type Definitions - v2
3
5
  *
@@ -94,6 +96,29 @@ interface ParticipantCapabilities {
94
96
  };
95
97
  /** Streaming/backpressure capabilities */
96
98
  streaming?: StreamingCapabilities;
99
+ /**
100
+ * Protocols supported by this participant.
101
+ * Used for protocol capability discovery.
102
+ *
103
+ * @example ['acp', 'mcp']
104
+ */
105
+ protocols?: string[];
106
+ /**
107
+ * ACP (Agent Client Protocol) capability details.
108
+ * Only present if 'acp' is in the protocols array.
109
+ */
110
+ acp?: ACPCapability;
111
+ _meta?: Meta;
112
+ }
113
+ /**
114
+ * ACP capability advertisement.
115
+ * Describes what ACP features an agent supports.
116
+ */
117
+ interface ACPCapability {
118
+ /** ACP protocol version supported (e.g., '2024-10-07') */
119
+ version: string;
120
+ /** ACP features supported by this agent */
121
+ features?: string[];
97
122
  _meta?: Meta;
98
123
  }
99
124
  /** A participant in the MAP protocol */
@@ -408,6 +433,11 @@ interface MessageMeta {
408
433
  priority?: MessagePriority;
409
434
  delivery?: DeliverySemantics;
410
435
  ttlMs?: number;
436
+ /**
437
+ * Protocol identifier for tunneled protocols (e.g., 'acp').
438
+ * Used to identify the protocol of the payload.
439
+ */
440
+ protocol?: string;
411
441
  _meta?: Meta;
412
442
  }
413
443
  /** A message in the multi-agent system */
@@ -532,7 +562,6 @@ declare function createEvent(input: EventInput): Event;
532
562
  * | Field | Within-field | Cross-field | Description |
533
563
  * |-------|--------------|-------------|-------------|
534
564
  * | `eventTypes` | OR | AND | Event type is one of the listed types |
535
- * | `agents` | OR | AND | Event relates to one of the listed agents (legacy) |
536
565
  * | `fromAgents` | OR | AND | Event source is one of the listed agents |
537
566
  * | `fromRoles` | OR | AND | Event source agent has one of the listed roles |
538
567
  * | `roles` | OR | AND | Event relates to agents with one of the listed roles |
@@ -542,11 +571,6 @@ declare function createEvent(input: EventInput): Event;
542
571
  * | `metadataMatch` | AND | AND | Event metadata contains ALL specified key-value pairs |
543
572
  */
544
573
  interface SubscriptionFilter {
545
- /**
546
- * Filter by agents the event relates to.
547
- * @deprecated Use `fromAgents` for clearer semantics
548
- */
549
- agents?: AgentId[];
550
574
  /**
551
575
  * Filter by roles the event relates to.
552
576
  * Matches events where the related agent has one of these roles.
@@ -714,11 +738,77 @@ interface SessionInfo {
714
738
  lastActiveAt?: Timestamp;
715
739
  closedAt?: Timestamp;
716
740
  }
717
- type AuthMethod = 'bearer' | 'api-key' | 'mtls' | 'none';
718
- interface AuthParams {
741
+ /** Standard authentication methods defined by the protocol */
742
+ type StandardAuthMethod = 'bearer' | 'api-key' | 'mtls' | 'none';
743
+ /** Authentication method - standard or custom (x- prefixed) */
744
+ type AuthMethod = StandardAuthMethod | `x-${string}`;
745
+ /** Authentication error codes */
746
+ type AuthErrorCode = 'invalid_credentials' | 'expired' | 'insufficient_scope' | 'method_not_supported' | 'auth_required';
747
+ /**
748
+ * Client-provided authentication credentials.
749
+ * Used in connect requests and authenticate calls.
750
+ */
751
+ interface AuthCredentials {
752
+ /** The authentication method being used */
719
753
  method: AuthMethod;
720
- token?: string;
754
+ /** The credential value (token, API key, etc.) */
755
+ credential?: string;
756
+ /** Method-specific additional data */
757
+ metadata?: Record<string, unknown>;
758
+ }
759
+ /**
760
+ * Server-advertised authentication capabilities.
761
+ * Included in connect response when auth is required.
762
+ */
763
+ interface ServerAuthCapabilities {
764
+ /** Supported authentication methods (in preference order) */
765
+ methods: AuthMethod[];
766
+ /** Is authentication required to proceed? */
767
+ required: boolean;
768
+ /** OAuth2 authorization server metadata URL (RFC 8414) */
769
+ oauth2MetadataUrl?: string;
770
+ /** JWKS URL for local JWT verification (RFC 7517) */
771
+ jwksUrl?: string;
772
+ /** Realm identifier for this server */
773
+ realm?: string;
774
+ }
775
+ /**
776
+ * Authenticated principal information.
777
+ * Returned after successful authentication.
778
+ */
779
+ interface AuthPrincipal {
780
+ /** Unique identifier for this principal */
781
+ id: string;
782
+ /** Token issuer (for federated auth) */
783
+ issuer?: string;
784
+ /** Additional claims from the credential */
785
+ claims?: Record<string, unknown>;
786
+ /** Token expiration timestamp (Unix ms) - from JWT exp claim */
787
+ expiresAt?: number;
788
+ }
789
+ /**
790
+ * Authentication error details.
791
+ */
792
+ interface AuthError {
793
+ /** Error code */
794
+ code: AuthErrorCode;
795
+ /** Human-readable error message */
796
+ message: string;
797
+ }
798
+ /**
799
+ * Result of an authentication attempt.
800
+ */
801
+ interface AuthResult {
802
+ /** Whether authentication succeeded */
803
+ success: boolean;
804
+ /** Authenticated principal (if success) */
805
+ principal?: AuthPrincipal;
806
+ /** Error details (if failure) */
807
+ error?: AuthError;
721
808
  }
809
+ /**
810
+ * Authentication for federated connections.
811
+ */
722
812
  interface FederationAuth {
723
813
  method: 'bearer' | 'api-key' | 'mtls';
724
814
  credentials?: string;
@@ -745,7 +835,8 @@ interface ConnectRequestParams {
745
835
  reclaimAgents?: AgentId[];
746
836
  /** Policy for unexpected disconnect */
747
837
  disconnectPolicy?: DisconnectPolicy;
748
- auth?: AuthParams;
838
+ /** Authentication credentials */
839
+ auth?: AuthCredentials;
749
840
  _meta?: Meta;
750
841
  }
751
842
  interface ConnectRequest extends MAPRequestBase<ConnectRequestParams> {
@@ -767,6 +858,12 @@ interface ConnectResponseResult {
767
858
  reclaimedAgents?: Agent[];
768
859
  /** Currently owned agents */
769
860
  ownedAgents?: AgentId[];
861
+ /** Authenticated principal (if auth succeeded) */
862
+ principal?: AuthPrincipal;
863
+ /** Auth required but not provided - client should authenticate */
864
+ authRequired?: ServerAuthCapabilities;
865
+ /** Token to resume this session later */
866
+ resumeToken?: string;
770
867
  _meta?: Meta;
771
868
  }
772
869
  interface DisconnectRequestParams {
@@ -1114,6 +1211,39 @@ interface AuthRefreshResponseResult {
1114
1211
  refreshToken?: string;
1115
1212
  _meta?: Meta;
1116
1213
  }
1214
+ /**
1215
+ * Parameters for map/authenticate request.
1216
+ * Used when auth negotiation is required after initial connect.
1217
+ */
1218
+ interface AuthenticateRequestParams {
1219
+ /** The authentication method being used */
1220
+ method: AuthMethod;
1221
+ /** The credential value (token, API key, etc.) */
1222
+ credential?: string;
1223
+ /** Method-specific additional data */
1224
+ metadata?: Record<string, unknown>;
1225
+ _meta?: Meta;
1226
+ }
1227
+ interface AuthenticateRequest extends MAPRequestBase<AuthenticateRequestParams> {
1228
+ method: 'map/authenticate';
1229
+ params: AuthenticateRequestParams;
1230
+ }
1231
+ /**
1232
+ * Response from map/authenticate request.
1233
+ */
1234
+ interface AuthenticateResponseResult {
1235
+ /** Whether authentication succeeded */
1236
+ success: boolean;
1237
+ /** Session ID (if auth succeeded) */
1238
+ sessionId?: SessionId;
1239
+ /** Participant ID (if auth succeeded) */
1240
+ participantId?: ParticipantId;
1241
+ /** Authenticated principal (if auth succeeded) */
1242
+ principal?: AuthPrincipal;
1243
+ /** Error details (if auth failed) */
1244
+ error?: AuthError;
1245
+ _meta?: Meta;
1246
+ }
1117
1247
  interface ScopesListRequestParams {
1118
1248
  parent?: ScopeId;
1119
1249
  _meta?: Meta;
@@ -1606,6 +1736,7 @@ declare const SESSION_METHODS: {
1606
1736
  };
1607
1737
  /** Auth methods */
1608
1738
  declare const AUTH_METHODS: {
1739
+ readonly AUTHENTICATE: "map/authenticate";
1609
1740
  readonly AUTH_REFRESH: "map/auth/refresh";
1610
1741
  };
1611
1742
  /** Permission methods */
@@ -1623,12 +1754,15 @@ declare const NOTIFICATION_METHODS: {
1623
1754
  readonly MESSAGE: "map/message";
1624
1755
  /** Client acknowledges received events (for backpressure) */
1625
1756
  readonly SUBSCRIBE_ACK: "map/subscribe.ack";
1757
+ /** Server notifies client that auth is about to expire */
1758
+ readonly AUTH_EXPIRING: "map/auth/expiring";
1626
1759
  };
1627
1760
  /** All MAP methods */
1628
1761
  declare const MAP_METHODS: {
1629
1762
  readonly FEDERATION_CONNECT: "map/federation/connect";
1630
1763
  readonly FEDERATION_ROUTE: "map/federation/route";
1631
1764
  readonly PERMISSIONS_UPDATE: "map/permissions/update";
1765
+ readonly AUTHENTICATE: "map/authenticate";
1632
1766
  readonly AUTH_REFRESH: "map/auth/refresh";
1633
1767
  readonly SESSION_LIST: "map/session/list";
1634
1768
  readonly SESSION_LOAD: "map/session/load";
@@ -1691,6 +1825,9 @@ declare const AUTH_ERROR_CODES: {
1691
1825
  readonly AUTH_FAILED: 1001;
1692
1826
  readonly TOKEN_EXPIRED: 1002;
1693
1827
  readonly PERMISSION_DENIED: 1003;
1828
+ readonly INSUFFICIENT_SCOPE: 1004;
1829
+ readonly METHOD_NOT_SUPPORTED: 1005;
1830
+ readonly INVALID_CREDENTIALS: 1006;
1694
1831
  };
1695
1832
  /** Routing error codes */
1696
1833
  declare const ROUTING_ERROR_CODES: {
@@ -1752,6 +1889,9 @@ declare const ERROR_CODES: {
1752
1889
  readonly AUTH_FAILED: 1001;
1753
1890
  readonly TOKEN_EXPIRED: 1002;
1754
1891
  readonly PERMISSION_DENIED: 1003;
1892
+ readonly INSUFFICIENT_SCOPE: 1004;
1893
+ readonly METHOD_NOT_SUPPORTED: 1005;
1894
+ readonly INVALID_CREDENTIALS: 1006;
1755
1895
  readonly PARSE_ERROR: -32700;
1756
1896
  readonly INVALID_REQUEST: -32600;
1757
1897
  readonly METHOD_NOT_FOUND: -32601;
@@ -1776,6 +1916,108 @@ declare function isBroadcastAddress(address: Address): address is BroadcastAddre
1776
1916
  /** Check if an address is a hierarchical address */
1777
1917
  declare function isHierarchicalAddress(address: Address): address is HierarchicalAddress;
1778
1918
 
1919
+ /**
1920
+ * Agentic-Mesh Stream Adapter
1921
+ *
1922
+ * Wraps agentic-mesh's TunnelStream as a MAP SDK Stream interface.
1923
+ * This enables MAP clients/agents to communicate over encrypted mesh
1924
+ * networks (Nebula, Tailscale, Headscale).
1925
+ *
1926
+ * @module
1927
+ */
1928
+
1929
+ /**
1930
+ * Peer endpoint for mesh connection.
1931
+ * Re-exported from agentic-mesh for convenience.
1932
+ */
1933
+ interface MeshPeerEndpoint {
1934
+ /** Peer identifier */
1935
+ peerId: string;
1936
+ /** Transport-specific address (IP, URL, etc.) */
1937
+ address: string;
1938
+ /** Optional port (for TCP-based transports) */
1939
+ port?: number;
1940
+ /** Additional transport-specific metadata */
1941
+ metadata?: Record<string, unknown>;
1942
+ }
1943
+ /**
1944
+ * Transport adapter interface (subset used by this module).
1945
+ * Full interface is defined in agentic-mesh.
1946
+ */
1947
+ interface MeshTransportAdapter {
1948
+ /** Whether the transport is currently active */
1949
+ readonly active: boolean;
1950
+ /** Start the transport */
1951
+ start(): Promise<void>;
1952
+ /** Connect to a peer endpoint */
1953
+ connect(endpoint: MeshPeerEndpoint): Promise<boolean>;
1954
+ /** Check if connected to a peer */
1955
+ isConnected(peerId: string): boolean;
1956
+ }
1957
+ /**
1958
+ * Configuration for agentic-mesh stream.
1959
+ */
1960
+ interface AgenticMeshStreamConfig {
1961
+ /**
1962
+ * The agentic-mesh transport adapter (Nebula, Tailscale, etc.).
1963
+ *
1964
+ * Create using agentic-mesh factory functions:
1965
+ * - `createNebulaTransport()` for Nebula networks
1966
+ * - `createTailscaleTransport()` for Tailscale networks
1967
+ */
1968
+ transport: MeshTransportAdapter;
1969
+ /**
1970
+ * Remote peer to connect to.
1971
+ */
1972
+ peer: MeshPeerEndpoint;
1973
+ /**
1974
+ * Local peer ID for identification.
1975
+ * Used to generate unique stream IDs.
1976
+ */
1977
+ localPeerId: string;
1978
+ /**
1979
+ * Connection timeout in milliseconds.
1980
+ * @default 10000
1981
+ */
1982
+ timeout?: number;
1983
+ }
1984
+ /**
1985
+ * Creates a MAP Stream over an agentic-mesh tunnel.
1986
+ *
1987
+ * This wraps agentic-mesh's TunnelStream (NDJSON over encrypted transport)
1988
+ * and adapts it to the MAP SDK's Stream interface.
1989
+ *
1990
+ * Requires `agentic-mesh` to be installed as a peer dependency.
1991
+ *
1992
+ * @param config - Stream configuration
1993
+ * @returns Promise resolving to a connected MAP Stream
1994
+ * @throws Error if agentic-mesh is not installed
1995
+ * @throws Error if peer connection fails
1996
+ *
1997
+ * @example
1998
+ * ```typescript
1999
+ * import { createNebulaTransport } from 'agentic-mesh';
2000
+ * import { agenticMeshStream, ClientConnection } from '@multi-agent-protocol/sdk';
2001
+ *
2002
+ * // Create Nebula transport
2003
+ * const transport = createNebulaTransport({
2004
+ * configPath: '/etc/nebula/config.yml',
2005
+ * });
2006
+ *
2007
+ * // Create MAP stream over mesh
2008
+ * const stream = await agenticMeshStream({
2009
+ * transport,
2010
+ * peer: { peerId: 'server', address: '10.0.0.1', port: 4242 },
2011
+ * localPeerId: 'my-client',
2012
+ * });
2013
+ *
2014
+ * // Use with MAP client
2015
+ * const client = new ClientConnection(stream, { name: 'MeshClient' });
2016
+ * await client.connect();
2017
+ * ```
2018
+ */
2019
+ declare function agenticMeshStream(config: AgenticMeshStreamConfig): Promise<Stream>;
2020
+
1779
2021
  /**
1780
2022
  * Stream utilities for MAP protocol transport
1781
2023
  *
@@ -2122,157 +2364,1497 @@ declare class BaseConnection {
2122
2364
  }
2123
2365
 
2124
2366
  /**
2125
- * Client connection for MAP protocol
2367
+ * ACP (Agent Client Protocol) types for ACP-over-MAP tunneling.
2126
2368
  *
2127
- * Used by clients to connect to a MAP system, query agents,
2128
- * subscribe to events, and send messages.
2369
+ * These types are bundled directly in the MAP SDK for simplicity,
2370
+ * enabling ACP semantics to be preserved when routing through MAP.
2371
+ *
2372
+ * @see https://agentclientprotocol.com/
2373
+ * @module
2129
2374
  */
2130
-
2131
2375
  /**
2132
- * Options for automatic reconnection
2376
+ * A unique identifier for a conversation session.
2133
2377
  */
2134
- interface ReconnectionOptions {
2135
- /** Enable automatic reconnection (default: false) */
2136
- enabled: boolean;
2137
- /** Maximum number of retry attempts (default: 10) */
2138
- maxRetries?: number;
2139
- /** Initial delay in milliseconds (default: 1000) */
2140
- baseDelayMs?: number;
2141
- /** Maximum delay in milliseconds (default: 30000) */
2142
- maxDelayMs?: number;
2143
- /** Add jitter to delays (default: true) */
2144
- jitter?: boolean;
2145
- /** Restore subscriptions after reconnect (default: true) */
2146
- restoreSubscriptions?: boolean;
2147
- /** Replay missed events on restore (default: true) */
2148
- replayOnRestore?: boolean;
2149
- /** Maximum events to replay per subscription (default: 1000) */
2150
- maxReplayEventsPerSubscription?: number;
2378
+ type ACPSessionId = string;
2379
+ /**
2380
+ * JSON-RPC request ID.
2381
+ */
2382
+ type ACPRequestId = string | number | null;
2383
+ /**
2384
+ * Protocol version identifier.
2385
+ */
2386
+ type ACPProtocolVersion = number;
2387
+ /**
2388
+ * Unique identifier for a tool call within a session.
2389
+ */
2390
+ type ACPToolCallId = string;
2391
+ /**
2392
+ * Unique identifier for a permission option.
2393
+ */
2394
+ type ACPPermissionOptionId = string;
2395
+ /**
2396
+ * Unique identifier for a session mode.
2397
+ */
2398
+ type ACPSessionModeId = string;
2399
+ /**
2400
+ * ACP JSON-RPC request structure.
2401
+ */
2402
+ interface ACPRequest<TParams = unknown> {
2403
+ jsonrpc: "2.0";
2404
+ id: ACPRequestId;
2405
+ method: string;
2406
+ params?: TParams;
2151
2407
  }
2152
2408
  /**
2153
- * Reconnection event types
2409
+ * ACP JSON-RPC notification structure (no response expected).
2154
2410
  */
2155
- type ReconnectionEventType = 'disconnected' | 'reconnecting' | 'reconnected' | 'reconnectFailed' | 'subscriptionRestored' | 'subscriptionRestoreFailed';
2411
+ interface ACPNotification<TParams = unknown> {
2412
+ jsonrpc: "2.0";
2413
+ method: string;
2414
+ params?: TParams;
2415
+ }
2156
2416
  /**
2157
- * Handler for reconnection events
2417
+ * ACP JSON-RPC success response structure.
2158
2418
  */
2159
- type ReconnectionEventHandler = (event: {
2160
- type: ReconnectionEventType;
2161
- attempt?: number;
2162
- delay?: number;
2163
- error?: Error;
2164
- subscriptionId?: SubscriptionId;
2165
- newSubscriptionId?: SubscriptionId;
2166
- }) => void;
2419
+ interface ACPSuccessResponse<TResult = unknown> {
2420
+ jsonrpc: "2.0";
2421
+ id: ACPRequestId;
2422
+ result: TResult;
2423
+ }
2167
2424
  /**
2168
- * Options for client connection
2425
+ * ACP JSON-RPC error object.
2169
2426
  */
2170
- interface ClientConnectionOptions extends BaseConnectionOptions {
2171
- /** Client name for identification */
2172
- name?: string;
2173
- /** Client capabilities */
2174
- capabilities?: ParticipantCapabilities;
2175
- /** Factory to create new stream for reconnection */
2176
- createStream?: () => Promise<Stream>;
2177
- /** Reconnection options */
2178
- reconnection?: ReconnectionOptions;
2427
+ interface ACPErrorObject {
2428
+ code: ACPErrorCode;
2429
+ message: string;
2430
+ data?: unknown;
2179
2431
  }
2180
2432
  /**
2181
- * Options for ClientConnection.connect() static method
2433
+ * ACP JSON-RPC error response structure.
2182
2434
  */
2183
- interface ClientConnectOptions {
2184
- /** Client name for identification */
2185
- name?: string;
2186
- /** Client capabilities to advertise */
2187
- capabilities?: ParticipantCapabilities;
2188
- /** Authentication credentials */
2189
- auth?: {
2190
- method: 'bearer' | 'api-key' | 'mtls' | 'none';
2191
- token?: string;
2192
- };
2193
- /**
2194
- * Reconnection configuration.
2195
- * - `true` = enable with defaults
2196
- * - `false` or omitted = disabled
2197
- * - `ReconnectionOptions` = enable with custom settings
2198
- */
2199
- reconnection?: boolean | ReconnectionOptions;
2200
- /** Connection timeout in ms (default: 10000) */
2201
- connectTimeout?: number;
2435
+ interface ACPErrorResponse {
2436
+ jsonrpc: "2.0";
2437
+ id: ACPRequestId;
2438
+ error: ACPErrorObject;
2202
2439
  }
2203
2440
  /**
2204
- * Client connection to a MAP system.
2205
- *
2206
- * Provides methods for:
2207
- * - Querying agents and structure
2208
- * - Subscribing to events
2209
- * - Sending messages to agents
2210
- * - (With permissions) Steering agents
2441
+ * Union of all ACP JSON-RPC response types.
2211
2442
  */
2212
- declare class ClientConnection {
2213
- #private;
2214
- constructor(stream: Stream, options?: ClientConnectionOptions);
2215
- /**
2216
- * Connect to a MAP server via WebSocket URL.
2217
- *
2218
- * Handles:
2219
- * - WebSocket creation and connection
2220
- * - Stream wrapping
2221
- * - Auto-configuration of createStream for reconnection
2222
- * - Initial MAP protocol connect handshake
2223
- *
2224
- * @param url - WebSocket URL (ws:// or wss://)
2225
- * @param options - Connection options
2226
- * @returns Connected ClientConnection instance
2227
- *
2228
- * @example
2229
- * ```typescript
2230
- * const client = await ClientConnection.connect('ws://localhost:8080', {
2231
- * name: 'MyClient',
2232
- * reconnection: true
2233
- * });
2234
- *
2235
- * // Already connected, ready to use
2236
- * const agents = await client.listAgents();
2237
- * ```
2238
- */
2239
- static connect(url: string, options?: ClientConnectOptions): Promise<ClientConnection>;
2240
- /**
2241
- * Connect to the MAP system
2242
- */
2243
- connect(options?: {
2244
- sessionId?: SessionId;
2245
- /** Token to resume a previously disconnected session */
2246
- resumeToken?: string;
2247
- auth?: {
2248
- method: 'bearer' | 'api-key' | 'mtls' | 'none';
2249
- token?: string;
2250
- };
2251
- }): Promise<ConnectResponseResult>;
2252
- /**
2253
- * Disconnect from the MAP system
2254
- * @param reason - Optional reason for disconnecting
2255
- * @returns Resume token that can be used to resume this session later
2256
- */
2257
- disconnect(reason?: string): Promise<string | undefined>;
2258
- /**
2259
- * Whether the client is connected
2260
- */
2261
- get isConnected(): boolean;
2262
- /**
2263
- * Current session ID
2264
- */
2265
- get sessionId(): SessionId | null;
2266
- /**
2267
- * Server capabilities
2268
- */
2269
- get serverCapabilities(): ParticipantCapabilities | null;
2443
+ type ACPResponse<TResult = unknown> = ACPSuccessResponse<TResult> | ACPErrorResponse;
2444
+ /**
2445
+ * Union of all ACP JSON-RPC message types.
2446
+ */
2447
+ type ACPMessage = ACPRequest | ACPNotification | ACPSuccessResponse | ACPErrorResponse;
2448
+ /**
2449
+ * Predefined ACP error codes following JSON-RPC specification.
2450
+ */
2451
+ type ACPErrorCode = -32700 | -32600 | -32601 | -32602 | -32603 | -32800 | -32000 | -32002 | number;
2452
+ /**
2453
+ * Standard ACP error codes with semantic names.
2454
+ */
2455
+ declare const ACP_ERROR_CODES: {
2456
+ readonly PARSE_ERROR: -32700;
2457
+ readonly INVALID_REQUEST: -32600;
2458
+ readonly METHOD_NOT_FOUND: -32601;
2459
+ readonly INVALID_PARAMS: -32602;
2460
+ readonly INTERNAL_ERROR: -32603;
2461
+ readonly REQUEST_CANCELLED: -32800;
2462
+ readonly AUTH_REQUIRED: -32000;
2463
+ readonly SESSION_NOT_FOUND: -32002;
2464
+ };
2465
+ /**
2466
+ * Error class for ACP protocol errors.
2467
+ * Preserves the original ACP error code and data.
2468
+ */
2469
+ declare class ACPError extends Error {
2470
+ readonly code: ACPErrorCode;
2471
+ readonly data?: unknown;
2472
+ constructor(code: ACPErrorCode, message: string, data?: unknown);
2270
2473
  /**
2271
- * AbortSignal that triggers when the connection closes
2474
+ * Create an ACPError from an error response.
2272
2475
  */
2273
- get signal(): AbortSignal;
2476
+ static fromResponse(error: ACPErrorObject): ACPError;
2274
2477
  /**
2275
- * Promise that resolves when the connection closes
2478
+ * Convert to JSON-RPC error object.
2479
+ */
2480
+ toErrorObject(): ACPErrorObject;
2481
+ }
2482
+ /**
2483
+ * The _meta property for ACP extensibility.
2484
+ */
2485
+ type ACPMeta = {
2486
+ [key: string]: unknown;
2487
+ } | null;
2488
+ /**
2489
+ * Metadata about the implementation of a client or agent.
2490
+ */
2491
+ interface ACPImplementation {
2492
+ _meta?: ACPMeta;
2493
+ /** Programmatic name of the implementation. */
2494
+ name: string;
2495
+ /** Human-readable title for display. */
2496
+ title?: string | null;
2497
+ /** Version string (e.g., "1.0.0"). */
2498
+ version: string;
2499
+ }
2500
+ /**
2501
+ * File system capabilities supported by the client.
2502
+ */
2503
+ interface ACPFileSystemCapability {
2504
+ _meta?: ACPMeta;
2505
+ /** Whether the client supports fs/read_text_file. */
2506
+ readTextFile?: boolean;
2507
+ /** Whether the client supports fs/write_text_file. */
2508
+ writeTextFile?: boolean;
2509
+ }
2510
+ /**
2511
+ * Capabilities supported by the client.
2512
+ */
2513
+ interface ACPClientCapabilities {
2514
+ _meta?: ACPMeta;
2515
+ /** File system capabilities. */
2516
+ fs?: ACPFileSystemCapability;
2517
+ /** Whether the client supports terminal methods. */
2518
+ terminal?: boolean;
2519
+ }
2520
+ /**
2521
+ * Prompt capabilities supported by the agent.
2522
+ */
2523
+ interface ACPPromptCapabilities {
2524
+ _meta?: ACPMeta;
2525
+ /** Agent supports audio content. */
2526
+ audio?: boolean;
2527
+ /** Agent supports embedded resource context. */
2528
+ embeddedContext?: boolean;
2529
+ /** Agent supports image content. */
2530
+ image?: boolean;
2531
+ }
2532
+ /**
2533
+ * MCP capabilities supported by the agent.
2534
+ */
2535
+ interface ACPMcpCapabilities {
2536
+ _meta?: ACPMeta;
2537
+ /** Agent supports HTTP MCP servers. */
2538
+ http?: boolean;
2539
+ /** Agent supports SSE MCP servers. */
2540
+ sse?: boolean;
2541
+ }
2542
+ /**
2543
+ * Session capabilities supported by the agent.
2544
+ */
2545
+ interface ACPSessionCapabilities {
2546
+ _meta?: ACPMeta;
2547
+ /** Whether the agent supports session/fork. */
2548
+ fork?: {
2549
+ _meta?: ACPMeta;
2550
+ } | null;
2551
+ /** Whether the agent supports session/list. */
2552
+ list?: {
2553
+ _meta?: ACPMeta;
2554
+ } | null;
2555
+ /** Whether the agent supports session/resume. */
2556
+ resume?: {
2557
+ _meta?: ACPMeta;
2558
+ } | null;
2559
+ }
2560
+ /**
2561
+ * Capabilities supported by the agent.
2562
+ */
2563
+ interface ACPAgentCapabilities {
2564
+ _meta?: ACPMeta;
2565
+ /** Whether the agent supports session/load. */
2566
+ loadSession?: boolean;
2567
+ /** MCP capabilities. */
2568
+ mcpCapabilities?: ACPMcpCapabilities;
2569
+ /** Prompt capabilities. */
2570
+ promptCapabilities?: ACPPromptCapabilities;
2571
+ /** Session capabilities. */
2572
+ sessionCapabilities?: ACPSessionCapabilities;
2573
+ }
2574
+ /**
2575
+ * Describes an available authentication method.
2576
+ */
2577
+ interface ACPAuthMethod {
2578
+ _meta?: ACPMeta;
2579
+ /** Unique identifier for this auth method. */
2580
+ id: string;
2581
+ /** Human-readable name. */
2582
+ name: string;
2583
+ /** Optional description. */
2584
+ description?: string | null;
2585
+ }
2586
+ /**
2587
+ * Request parameters for the initialize method.
2588
+ */
2589
+ interface ACPInitializeRequest {
2590
+ _meta?: ACPMeta;
2591
+ /** The latest protocol version supported by the client. */
2592
+ protocolVersion: ACPProtocolVersion;
2593
+ /** Information about the client implementation. */
2594
+ clientInfo?: ACPImplementation | null;
2595
+ /** Capabilities supported by the client. */
2596
+ clientCapabilities?: ACPClientCapabilities;
2597
+ }
2598
+ /**
2599
+ * Response to the initialize method.
2600
+ */
2601
+ interface ACPInitializeResponse {
2602
+ _meta?: ACPMeta;
2603
+ /** The negotiated protocol version. */
2604
+ protocolVersion: ACPProtocolVersion;
2605
+ /** Information about the agent implementation. */
2606
+ agentInfo?: ACPImplementation | null;
2607
+ /** Capabilities supported by the agent. */
2608
+ agentCapabilities?: ACPAgentCapabilities;
2609
+ /** Available authentication methods. */
2610
+ authMethods?: ACPAuthMethod[];
2611
+ }
2612
+ /**
2613
+ * Request parameters for the authenticate method.
2614
+ */
2615
+ interface ACPAuthenticateRequest {
2616
+ _meta?: ACPMeta;
2617
+ /** The ID of the authentication method to use. */
2618
+ methodId: string;
2619
+ }
2620
+ /**
2621
+ * Response to the authenticate method.
2622
+ */
2623
+ interface ACPAuthenticateResponse {
2624
+ _meta?: ACPMeta;
2625
+ }
2626
+ /**
2627
+ * Environment variable for MCP server configuration.
2628
+ */
2629
+ interface ACPEnvVariable {
2630
+ _meta?: ACPMeta;
2631
+ name: string;
2632
+ value: string;
2633
+ }
2634
+ /**
2635
+ * HTTP header for MCP server configuration.
2636
+ */
2637
+ interface ACPHttpHeader {
2638
+ _meta?: ACPMeta;
2639
+ name: string;
2640
+ value: string;
2641
+ }
2642
+ /**
2643
+ * Stdio transport configuration for MCP.
2644
+ */
2645
+ interface ACPMcpServerStdio {
2646
+ _meta?: ACPMeta;
2647
+ name: string;
2648
+ command: string;
2649
+ args: string[];
2650
+ env: ACPEnvVariable[];
2651
+ }
2652
+ /**
2653
+ * HTTP transport configuration for MCP.
2654
+ */
2655
+ interface ACPMcpServerHttp {
2656
+ _meta?: ACPMeta;
2657
+ type: "http";
2658
+ name: string;
2659
+ url: string;
2660
+ headers: ACPHttpHeader[];
2661
+ }
2662
+ /**
2663
+ * SSE transport configuration for MCP.
2664
+ */
2665
+ interface ACPMcpServerSse {
2666
+ _meta?: ACPMeta;
2667
+ type: "sse";
2668
+ name: string;
2669
+ url: string;
2670
+ headers: ACPHttpHeader[];
2671
+ }
2672
+ /**
2673
+ * MCP server configuration (union of all transport types).
2674
+ */
2675
+ type ACPMcpServer = ACPMcpServerStdio | ACPMcpServerHttp | ACPMcpServerSse;
2676
+ /**
2677
+ * A mode the agent can operate in.
2678
+ */
2679
+ interface ACPSessionMode {
2680
+ _meta?: ACPMeta;
2681
+ id: ACPSessionModeId;
2682
+ name: string;
2683
+ description?: string | null;
2684
+ }
2685
+ /**
2686
+ * The set of modes and the currently active one.
2687
+ */
2688
+ interface ACPSessionModeState {
2689
+ _meta?: ACPMeta;
2690
+ availableModes: ACPSessionMode[];
2691
+ currentModeId: ACPSessionModeId;
2692
+ }
2693
+ /**
2694
+ * Request parameters for creating a new session.
2695
+ */
2696
+ interface ACPNewSessionRequest {
2697
+ _meta?: ACPMeta;
2698
+ /** The working directory for this session. */
2699
+ cwd: string;
2700
+ /** List of MCP servers to connect to. */
2701
+ mcpServers: ACPMcpServer[];
2702
+ }
2703
+ /**
2704
+ * Response from creating a new session.
2705
+ */
2706
+ interface ACPNewSessionResponse {
2707
+ _meta?: ACPMeta;
2708
+ /** Unique identifier for the created session. */
2709
+ sessionId: ACPSessionId;
2710
+ /** Initial mode state if supported. */
2711
+ modes?: ACPSessionModeState | null;
2712
+ }
2713
+ /**
2714
+ * Request parameters for loading an existing session.
2715
+ */
2716
+ interface ACPLoadSessionRequest {
2717
+ _meta?: ACPMeta;
2718
+ /** The ID of the session to load. */
2719
+ sessionId: ACPSessionId;
2720
+ /** The working directory for this session. */
2721
+ cwd: string;
2722
+ /** List of MCP servers to connect to. */
2723
+ mcpServers: ACPMcpServer[];
2724
+ }
2725
+ /**
2726
+ * Response from loading an existing session.
2727
+ */
2728
+ interface ACPLoadSessionResponse {
2729
+ _meta?: ACPMeta;
2730
+ /** Mode state if supported. */
2731
+ modes?: ACPSessionModeState | null;
2732
+ }
2733
+ /**
2734
+ * Request parameters for setting a session mode.
2735
+ */
2736
+ interface ACPSetSessionModeRequest {
2737
+ _meta?: ACPMeta;
2738
+ /** The ID of the session. */
2739
+ sessionId: ACPSessionId;
2740
+ /** The ID of the mode to set. */
2741
+ modeId: ACPSessionModeId;
2742
+ }
2743
+ /**
2744
+ * Response to session/set_mode method.
2745
+ */
2746
+ interface ACPSetSessionModeResponse {
2747
+ _meta?: ACPMeta;
2748
+ }
2749
+ /**
2750
+ * Optional annotations for content.
2751
+ */
2752
+ interface ACPAnnotations {
2753
+ _meta?: ACPMeta;
2754
+ audience?: ACPRole[] | null;
2755
+ lastModified?: string | null;
2756
+ priority?: number | null;
2757
+ }
2758
+ /**
2759
+ * Role in a conversation.
2760
+ */
2761
+ type ACPRole = "assistant" | "user";
2762
+ /**
2763
+ * Text content block.
2764
+ */
2765
+ interface ACPTextContent {
2766
+ _meta?: ACPMeta;
2767
+ type: "text";
2768
+ text: string;
2769
+ annotations?: ACPAnnotations | null;
2770
+ }
2771
+ /**
2772
+ * Image content block.
2773
+ */
2774
+ interface ACPImageContent {
2775
+ _meta?: ACPMeta;
2776
+ type: "image";
2777
+ data: string;
2778
+ mimeType: string;
2779
+ annotations?: ACPAnnotations | null;
2780
+ }
2781
+ /**
2782
+ * Audio content block.
2783
+ */
2784
+ interface ACPAudioContent {
2785
+ _meta?: ACPMeta;
2786
+ type: "audio";
2787
+ data: string;
2788
+ mimeType: string;
2789
+ annotations?: ACPAnnotations | null;
2790
+ }
2791
+ /**
2792
+ * Resource link content block.
2793
+ */
2794
+ interface ACPResourceLink {
2795
+ _meta?: ACPMeta;
2796
+ type: "resource_link";
2797
+ uri: string;
2798
+ name: string;
2799
+ title?: string | null;
2800
+ description?: string | null;
2801
+ mimeType?: string | null;
2802
+ size?: number | null;
2803
+ annotations?: ACPAnnotations | null;
2804
+ }
2805
+ /**
2806
+ * Text resource contents.
2807
+ */
2808
+ interface ACPTextResourceContents {
2809
+ _meta?: ACPMeta;
2810
+ uri: string;
2811
+ text: string;
2812
+ mimeType?: string | null;
2813
+ }
2814
+ /**
2815
+ * Binary resource contents.
2816
+ */
2817
+ interface ACPBlobResourceContents {
2818
+ _meta?: ACPMeta;
2819
+ uri: string;
2820
+ blob: string;
2821
+ mimeType?: string | null;
2822
+ }
2823
+ /**
2824
+ * Embedded resource content block.
2825
+ */
2826
+ interface ACPEmbeddedResource {
2827
+ _meta?: ACPMeta;
2828
+ type: "resource";
2829
+ resource: ACPTextResourceContents | ACPBlobResourceContents;
2830
+ annotations?: ACPAnnotations | null;
2831
+ }
2832
+ /**
2833
+ * Union of all content block types.
2834
+ */
2835
+ type ACPContentBlock = ACPTextContent | ACPImageContent | ACPAudioContent | ACPResourceLink | ACPEmbeddedResource;
2836
+ /**
2837
+ * Request parameters for sending a user prompt.
2838
+ */
2839
+ interface ACPPromptRequest {
2840
+ _meta?: ACPMeta;
2841
+ /** The ID of the session. */
2842
+ sessionId: ACPSessionId;
2843
+ /** The content blocks of the user's message. */
2844
+ prompt: ACPContentBlock[];
2845
+ }
2846
+ /**
2847
+ * Reasons why an agent stops processing.
2848
+ */
2849
+ type ACPStopReason = "end_turn" | "max_tokens" | "max_turn_requests" | "refusal" | "cancelled";
2850
+ /**
2851
+ * Response from processing a user prompt.
2852
+ */
2853
+ interface ACPPromptResponse {
2854
+ _meta?: ACPMeta;
2855
+ /** Why the agent stopped processing. */
2856
+ stopReason: ACPStopReason;
2857
+ }
2858
+ /**
2859
+ * Notification to cancel ongoing operations for a session.
2860
+ */
2861
+ interface ACPCancelNotification {
2862
+ _meta?: ACPMeta;
2863
+ /** The ID of the session to cancel operations for. */
2864
+ sessionId: ACPSessionId;
2865
+ }
2866
+ /**
2867
+ * Categories of tools.
2868
+ */
2869
+ type ACPToolKind = "read" | "edit" | "delete" | "move" | "search" | "execute" | "think" | "fetch" | "switch_mode" | "other";
2870
+ /**
2871
+ * Execution status of a tool call.
2872
+ */
2873
+ type ACPToolCallStatus = "pending" | "in_progress" | "completed" | "failed";
2874
+ /**
2875
+ * A file location being accessed by a tool.
2876
+ */
2877
+ interface ACPToolCallLocation {
2878
+ _meta?: ACPMeta;
2879
+ path: string;
2880
+ line?: number | null;
2881
+ }
2882
+ /**
2883
+ * A diff representing file modifications.
2884
+ */
2885
+ interface ACPDiff {
2886
+ _meta?: ACPMeta;
2887
+ path: string;
2888
+ oldText?: string | null;
2889
+ newText: string;
2890
+ }
2891
+ /**
2892
+ * Terminal reference.
2893
+ */
2894
+ interface ACPTerminal {
2895
+ _meta?: ACPMeta;
2896
+ terminalId: string;
2897
+ }
2898
+ /**
2899
+ * Standard content wrapper.
2900
+ */
2901
+ interface ACPContent {
2902
+ _meta?: ACPMeta;
2903
+ content: ACPContentBlock;
2904
+ }
2905
+ /**
2906
+ * Tool call content types.
2907
+ */
2908
+ type ACPToolCallContent = (ACPContent & {
2909
+ type: "content";
2910
+ }) | (ACPDiff & {
2911
+ type: "diff";
2912
+ }) | (ACPTerminal & {
2913
+ type: "terminal";
2914
+ });
2915
+ /**
2916
+ * A tool call requested by the language model.
2917
+ */
2918
+ interface ACPToolCall {
2919
+ _meta?: ACPMeta;
2920
+ toolCallId: ACPToolCallId;
2921
+ title: string;
2922
+ kind?: ACPToolKind;
2923
+ status?: ACPToolCallStatus;
2924
+ rawInput?: unknown;
2925
+ rawOutput?: unknown;
2926
+ content?: ACPToolCallContent[];
2927
+ locations?: ACPToolCallLocation[];
2928
+ }
2929
+ /**
2930
+ * An update to an existing tool call.
2931
+ */
2932
+ interface ACPToolCallUpdate {
2933
+ _meta?: ACPMeta;
2934
+ toolCallId: ACPToolCallId;
2935
+ title?: string | null;
2936
+ kind?: ACPToolKind | null;
2937
+ status?: ACPToolCallStatus | null;
2938
+ rawInput?: unknown;
2939
+ rawOutput?: unknown;
2940
+ content?: ACPToolCallContent[] | null;
2941
+ locations?: ACPToolCallLocation[] | null;
2942
+ }
2943
+ /**
2944
+ * Priority levels for plan entries.
2945
+ */
2946
+ type ACPPlanEntryPriority = "high" | "medium" | "low";
2947
+ /**
2948
+ * Status of a plan entry.
2949
+ */
2950
+ type ACPPlanEntryStatus = "pending" | "in_progress" | "completed";
2951
+ /**
2952
+ * A single entry in the execution plan.
2953
+ */
2954
+ interface ACPPlanEntry {
2955
+ _meta?: ACPMeta;
2956
+ content: string;
2957
+ priority: ACPPlanEntryPriority;
2958
+ status: ACPPlanEntryStatus;
2959
+ }
2960
+ /**
2961
+ * An execution plan.
2962
+ */
2963
+ interface ACPPlan {
2964
+ _meta?: ACPMeta;
2965
+ entries: ACPPlanEntry[];
2966
+ }
2967
+ /**
2968
+ * A streamed chunk of content.
2969
+ */
2970
+ interface ACPContentChunk {
2971
+ _meta?: ACPMeta;
2972
+ content: ACPContentBlock;
2973
+ }
2974
+ /**
2975
+ * Available command input type.
2976
+ */
2977
+ interface ACPUnstructuredCommandInput {
2978
+ _meta?: ACPMeta;
2979
+ }
2980
+ /**
2981
+ * Available command input.
2982
+ */
2983
+ type ACPAvailableCommandInput = ACPUnstructuredCommandInput;
2984
+ /**
2985
+ * Information about an available command.
2986
+ */
2987
+ interface ACPAvailableCommand {
2988
+ _meta?: ACPMeta;
2989
+ name: string;
2990
+ description: string;
2991
+ input?: ACPAvailableCommandInput | null;
2992
+ }
2993
+ /**
2994
+ * Available commands update.
2995
+ */
2996
+ interface ACPAvailableCommandsUpdate {
2997
+ _meta?: ACPMeta;
2998
+ availableCommands: ACPAvailableCommand[];
2999
+ }
3000
+ /**
3001
+ * Current mode update.
3002
+ */
3003
+ interface ACPCurrentModeUpdate {
3004
+ _meta?: ACPMeta;
3005
+ currentModeId: ACPSessionModeId;
3006
+ }
3007
+ /**
3008
+ * Session info update.
3009
+ */
3010
+ interface ACPSessionInfoUpdate {
3011
+ _meta?: ACPMeta;
3012
+ title?: string | null;
3013
+ updatedAt?: string | null;
3014
+ }
3015
+ /**
3016
+ * All session update types.
3017
+ */
3018
+ type ACPSessionUpdate = (ACPContentChunk & {
3019
+ sessionUpdate: "user_message_chunk";
3020
+ }) | (ACPContentChunk & {
3021
+ sessionUpdate: "agent_message_chunk";
3022
+ }) | (ACPContentChunk & {
3023
+ sessionUpdate: "agent_thought_chunk";
3024
+ }) | (ACPToolCall & {
3025
+ sessionUpdate: "tool_call";
3026
+ }) | (ACPToolCallUpdate & {
3027
+ sessionUpdate: "tool_call_update";
3028
+ }) | (ACPPlan & {
3029
+ sessionUpdate: "plan";
3030
+ }) | (ACPAvailableCommandsUpdate & {
3031
+ sessionUpdate: "available_commands_update";
3032
+ }) | (ACPCurrentModeUpdate & {
3033
+ sessionUpdate: "current_mode_update";
3034
+ }) | (ACPSessionInfoUpdate & {
3035
+ sessionUpdate: "session_info_update";
3036
+ });
3037
+ /**
3038
+ * Session notification containing an update.
3039
+ */
3040
+ interface ACPSessionNotification {
3041
+ _meta?: ACPMeta;
3042
+ sessionId: ACPSessionId;
3043
+ update: ACPSessionUpdate;
3044
+ }
3045
+ /**
3046
+ * Permission option kind.
3047
+ */
3048
+ type ACPPermissionOptionKind = "allow_once" | "allow_always" | "reject_once" | "reject_always";
3049
+ /**
3050
+ * A permission option.
3051
+ */
3052
+ interface ACPPermissionOption {
3053
+ _meta?: ACPMeta;
3054
+ optionId: ACPPermissionOptionId;
3055
+ name: string;
3056
+ kind: ACPPermissionOptionKind;
3057
+ }
3058
+ /**
3059
+ * Request for user permission to execute a tool call.
3060
+ */
3061
+ interface ACPRequestPermissionRequest {
3062
+ _meta?: ACPMeta;
3063
+ sessionId: ACPSessionId;
3064
+ toolCall: ACPToolCallUpdate;
3065
+ options: ACPPermissionOption[];
3066
+ }
3067
+ /**
3068
+ * Permission outcome when user selected an option.
3069
+ */
3070
+ interface ACPSelectedPermissionOutcome {
3071
+ _meta?: ACPMeta;
3072
+ outcome: "selected";
3073
+ optionId: ACPPermissionOptionId;
3074
+ }
3075
+ /**
3076
+ * Permission outcome when cancelled.
3077
+ */
3078
+ interface ACPCancelledPermissionOutcome {
3079
+ outcome: "cancelled";
3080
+ }
3081
+ /**
3082
+ * Permission request outcome.
3083
+ */
3084
+ type ACPRequestPermissionOutcome = ACPSelectedPermissionOutcome | ACPCancelledPermissionOutcome;
3085
+ /**
3086
+ * Response to a permission request.
3087
+ */
3088
+ interface ACPRequestPermissionResponse {
3089
+ _meta?: ACPMeta;
3090
+ outcome: ACPRequestPermissionOutcome;
3091
+ }
3092
+ /**
3093
+ * Request to read content from a text file.
3094
+ */
3095
+ interface ACPReadTextFileRequest {
3096
+ _meta?: ACPMeta;
3097
+ sessionId: ACPSessionId;
3098
+ path: string;
3099
+ line?: number | null;
3100
+ limit?: number | null;
3101
+ }
3102
+ /**
3103
+ * Response containing file contents.
3104
+ */
3105
+ interface ACPReadTextFileResponse {
3106
+ _meta?: ACPMeta;
3107
+ content: string;
3108
+ }
3109
+ /**
3110
+ * Request to write content to a text file.
3111
+ */
3112
+ interface ACPWriteTextFileRequest {
3113
+ _meta?: ACPMeta;
3114
+ sessionId: ACPSessionId;
3115
+ path: string;
3116
+ content: string;
3117
+ }
3118
+ /**
3119
+ * Response to write text file.
3120
+ */
3121
+ interface ACPWriteTextFileResponse {
3122
+ _meta?: ACPMeta;
3123
+ }
3124
+ /**
3125
+ * Request to create a new terminal.
3126
+ */
3127
+ interface ACPCreateTerminalRequest {
3128
+ _meta?: ACPMeta;
3129
+ sessionId: ACPSessionId;
3130
+ command: string;
3131
+ args?: string[];
3132
+ cwd?: string | null;
3133
+ env?: ACPEnvVariable[];
3134
+ outputByteLimit?: number | null;
3135
+ }
3136
+ /**
3137
+ * Response containing the terminal ID.
3138
+ */
3139
+ interface ACPCreateTerminalResponse {
3140
+ _meta?: ACPMeta;
3141
+ terminalId: string;
3142
+ }
3143
+ /**
3144
+ * Request to get terminal output.
3145
+ */
3146
+ interface ACPTerminalOutputRequest {
3147
+ _meta?: ACPMeta;
3148
+ sessionId: ACPSessionId;
3149
+ terminalId: string;
3150
+ }
3151
+ /**
3152
+ * Terminal exit status.
3153
+ */
3154
+ interface ACPTerminalExitStatus {
3155
+ _meta?: ACPMeta;
3156
+ exitCode?: number | null;
3157
+ signal?: string | null;
3158
+ }
3159
+ /**
3160
+ * Response containing terminal output.
3161
+ */
3162
+ interface ACPTerminalOutputResponse {
3163
+ _meta?: ACPMeta;
3164
+ output: string;
3165
+ truncated: boolean;
3166
+ exitStatus?: ACPTerminalExitStatus | null;
3167
+ }
3168
+ /**
3169
+ * Request to release a terminal.
3170
+ */
3171
+ interface ACPReleaseTerminalRequest {
3172
+ _meta?: ACPMeta;
3173
+ sessionId: ACPSessionId;
3174
+ terminalId: string;
3175
+ }
3176
+ /**
3177
+ * Response to release terminal.
3178
+ */
3179
+ interface ACPReleaseTerminalResponse {
3180
+ _meta?: ACPMeta;
3181
+ }
3182
+ /**
3183
+ * Request to wait for terminal exit.
3184
+ */
3185
+ interface ACPWaitForTerminalExitRequest {
3186
+ _meta?: ACPMeta;
3187
+ sessionId: ACPSessionId;
3188
+ terminalId: string;
3189
+ }
3190
+ /**
3191
+ * Response with terminal exit status.
3192
+ */
3193
+ interface ACPWaitForTerminalExitResponse {
3194
+ _meta?: ACPMeta;
3195
+ exitCode?: number | null;
3196
+ signal?: string | null;
3197
+ }
3198
+ /**
3199
+ * Request to kill a terminal command.
3200
+ */
3201
+ interface ACPKillTerminalCommandRequest {
3202
+ _meta?: ACPMeta;
3203
+ sessionId: ACPSessionId;
3204
+ terminalId: string;
3205
+ }
3206
+ /**
3207
+ * Response to kill terminal command.
3208
+ */
3209
+ interface ACPKillTerminalCommandResponse {
3210
+ _meta?: ACPMeta;
3211
+ }
3212
+ /**
3213
+ * Context for ACP messages tunneled through MAP.
3214
+ */
3215
+ interface ACPContext {
3216
+ /** Unique identifier for this virtual ACP stream. */
3217
+ streamId: string;
3218
+ /** ACP session ID (null before session/new is called). */
3219
+ sessionId: ACPSessionId | null;
3220
+ /** Direction of message flow. */
3221
+ direction: "client-to-agent" | "agent-to-client";
3222
+ /** Information about a pending client request (for agent→client requests). */
3223
+ pendingClientRequest?: {
3224
+ requestId: ACPRequestId;
3225
+ method: string;
3226
+ timeout?: number;
3227
+ };
3228
+ }
3229
+ /**
3230
+ * Envelope wrapping ACP JSON-RPC messages for transport through MAP.
3231
+ *
3232
+ * This is the payload format used when sending ACP messages via MAP's send().
3233
+ */
3234
+ interface ACPEnvelope {
3235
+ /**
3236
+ * The original ACP JSON-RPC message.
3237
+ */
3238
+ acp: {
3239
+ jsonrpc: "2.0";
3240
+ id?: ACPRequestId;
3241
+ method?: string;
3242
+ params?: unknown;
3243
+ result?: unknown;
3244
+ error?: ACPErrorObject;
3245
+ };
3246
+ /**
3247
+ * ACP-specific routing context.
3248
+ */
3249
+ acpContext: ACPContext;
3250
+ }
3251
+ /**
3252
+ * Handlers that the client provides for agent→client requests.
3253
+ */
3254
+ interface ACPClientHandlers {
3255
+ /**
3256
+ * Handle permission request from agent.
3257
+ */
3258
+ requestPermission(params: ACPRequestPermissionRequest): Promise<ACPRequestPermissionResponse>;
3259
+ /**
3260
+ * Handle session update notification from agent.
3261
+ */
3262
+ sessionUpdate(params: ACPSessionNotification): Promise<void>;
3263
+ /**
3264
+ * Handle read text file request (optional, based on capabilities).
3265
+ */
3266
+ readTextFile?(params: ACPReadTextFileRequest): Promise<ACPReadTextFileResponse>;
3267
+ /**
3268
+ * Handle write text file request (optional, based on capabilities).
3269
+ */
3270
+ writeTextFile?(params: ACPWriteTextFileRequest): Promise<ACPWriteTextFileResponse>;
3271
+ /**
3272
+ * Handle create terminal request (optional, based on capabilities).
3273
+ */
3274
+ createTerminal?(params: ACPCreateTerminalRequest): Promise<ACPCreateTerminalResponse>;
3275
+ /**
3276
+ * Handle terminal output request (optional, based on capabilities).
3277
+ */
3278
+ terminalOutput?(params: ACPTerminalOutputRequest): Promise<ACPTerminalOutputResponse>;
3279
+ /**
3280
+ * Handle release terminal request (optional, based on capabilities).
3281
+ */
3282
+ releaseTerminal?(params: ACPReleaseTerminalRequest): Promise<ACPReleaseTerminalResponse>;
3283
+ /**
3284
+ * Handle wait for terminal exit request (optional, based on capabilities).
3285
+ */
3286
+ waitForTerminalExit?(params: ACPWaitForTerminalExitRequest): Promise<ACPWaitForTerminalExitResponse>;
3287
+ /**
3288
+ * Handle kill terminal command request (optional, based on capabilities).
3289
+ */
3290
+ killTerminal?(params: ACPKillTerminalCommandRequest): Promise<ACPKillTerminalCommandResponse>;
3291
+ }
3292
+ /**
3293
+ * Context passed to agent handlers.
3294
+ */
3295
+ interface ACPAgentContext {
3296
+ /** The stream ID for this ACP session. */
3297
+ streamId: string;
3298
+ /** Current ACP session ID (null before newSession). */
3299
+ sessionId: ACPSessionId | null;
3300
+ /** The MAP participant ID of the client. */
3301
+ clientParticipantId: string;
3302
+ }
3303
+ /**
3304
+ * Handler interface for agents that support ACP.
3305
+ */
3306
+ interface ACPAgentHandler {
3307
+ /**
3308
+ * Handle initialize request.
3309
+ */
3310
+ initialize(params: ACPInitializeRequest, ctx: ACPAgentContext): Promise<ACPInitializeResponse>;
3311
+ /**
3312
+ * Handle authenticate request (optional).
3313
+ */
3314
+ authenticate?(params: ACPAuthenticateRequest, ctx: ACPAgentContext): Promise<ACPAuthenticateResponse>;
3315
+ /**
3316
+ * Handle new session request.
3317
+ */
3318
+ newSession(params: ACPNewSessionRequest, ctx: ACPAgentContext): Promise<ACPNewSessionResponse>;
3319
+ /**
3320
+ * Handle load session request (optional).
3321
+ */
3322
+ loadSession?(params: ACPLoadSessionRequest, ctx: ACPAgentContext): Promise<ACPLoadSessionResponse>;
3323
+ /**
3324
+ * Handle set session mode request (optional).
3325
+ */
3326
+ setSessionMode?(params: ACPSetSessionModeRequest, ctx: ACPAgentContext): Promise<ACPSetSessionModeResponse>;
3327
+ /**
3328
+ * Handle prompt request.
3329
+ */
3330
+ prompt(params: ACPPromptRequest, ctx: ACPAgentContext): Promise<ACPPromptResponse>;
3331
+ /**
3332
+ * Handle cancel notification.
3333
+ */
3334
+ cancel(params: ACPCancelNotification, ctx: ACPAgentContext): Promise<void>;
3335
+ }
3336
+ /**
3337
+ * Current stable ACP protocol version.
3338
+ */
3339
+ declare const ACP_PROTOCOL_VERSION = 20241007;
3340
+ /**
3341
+ * ACP method names.
3342
+ */
3343
+ declare const ACP_METHODS: {
3344
+ readonly INITIALIZE: "initialize";
3345
+ readonly AUTHENTICATE: "authenticate";
3346
+ readonly SESSION_NEW: "session/new";
3347
+ readonly SESSION_LOAD: "session/load";
3348
+ readonly SESSION_SET_MODE: "session/set_mode";
3349
+ readonly SESSION_PROMPT: "session/prompt";
3350
+ readonly SESSION_CANCEL: "session/cancel";
3351
+ readonly SESSION_UPDATE: "session/update";
3352
+ readonly REQUEST_PERMISSION: "request_permission";
3353
+ readonly FS_READ_TEXT_FILE: "fs/read_text_file";
3354
+ readonly FS_WRITE_TEXT_FILE: "fs/write_text_file";
3355
+ readonly TERMINAL_CREATE: "terminal/create";
3356
+ readonly TERMINAL_OUTPUT: "terminal/output";
3357
+ readonly TERMINAL_RELEASE: "terminal/release";
3358
+ readonly TERMINAL_WAIT_FOR_EXIT: "terminal/wait_for_exit";
3359
+ readonly TERMINAL_KILL: "terminal/kill";
3360
+ };
3361
+ /**
3362
+ * Check if a message is an ACP request.
3363
+ */
3364
+ declare function isACPRequest(msg: ACPMessage): msg is ACPRequest;
3365
+ /**
3366
+ * Check if a message is an ACP notification.
3367
+ */
3368
+ declare function isACPNotification(msg: ACPMessage): msg is ACPNotification;
3369
+ /**
3370
+ * Check if a message is an ACP response.
3371
+ */
3372
+ declare function isACPResponse(msg: ACPMessage): msg is ACPResponse;
3373
+ /**
3374
+ * Check if a response is an error response.
3375
+ */
3376
+ declare function isACPErrorResponse(response: ACPResponse): response is ACPErrorResponse;
3377
+ /**
3378
+ * Check if a response is a success response.
3379
+ */
3380
+ declare function isACPSuccessResponse<T>(response: ACPResponse<T>): response is ACPSuccessResponse<T>;
3381
+ /**
3382
+ * Check if a payload is an ACP envelope.
3383
+ */
3384
+ declare function isACPEnvelope(payload: unknown): payload is ACPEnvelope;
3385
+
3386
+ /**
3387
+ * ACPStreamConnection - Client-side virtual ACP connection over MAP.
3388
+ *
3389
+ * Provides a familiar ACP interface while using MAP's send/subscribe
3390
+ * primitives for transport. Supports request/response correlation,
3391
+ * timeout handling, and session lifecycle management.
3392
+ *
3393
+ * @module
3394
+ */
3395
+
3396
+ /**
3397
+ * Options for creating an ACP stream connection.
3398
+ */
3399
+ interface ACPStreamOptions {
3400
+ /** Target agent that will handle ACP requests */
3401
+ targetAgent: AgentId;
3402
+ /** Client-side handlers for agent→client requests */
3403
+ client: ACPClientHandlers;
3404
+ /** Optional: expose MAP events alongside ACP (for observability) */
3405
+ exposeMapEvents?: boolean;
3406
+ /** Request timeout in milliseconds (default: 30000) */
3407
+ timeout?: number;
3408
+ }
3409
+ /**
3410
+ * Events emitted by ACPStreamConnection.
3411
+ */
3412
+ interface ACPStreamEvents {
3413
+ /** Emitted when ACP session is lost after reconnection */
3414
+ sessionLost: (info: {
3415
+ sessionId: ACPSessionId;
3416
+ reason: string;
3417
+ }) => void;
3418
+ /** Emitted when the stream successfully reconnects */
3419
+ reconnected: () => void;
3420
+ /** Emitted when reconnection is in progress */
3421
+ reconnecting: () => void;
3422
+ /** Emitted when the stream is closed */
3423
+ close: () => void;
3424
+ /** Emitted on errors */
3425
+ error: (error: Error) => void;
3426
+ }
3427
+ /**
3428
+ * Virtual ACP connection over MAP.
3429
+ *
3430
+ * Provides the full ACP client interface, routing all requests through
3431
+ * the underlying MAP connection to a target agent.
3432
+ *
3433
+ * @example
3434
+ * ```typescript
3435
+ * const acp = new ACPStreamConnection(mapClient, {
3436
+ * targetAgent: 'coding-agent-1',
3437
+ * client: {
3438
+ * requestPermission: async (req) => ({ outcome: { outcome: 'selected', optionId: 'allow' } }),
3439
+ * sessionUpdate: async (update) => { console.log(update); },
3440
+ * }
3441
+ * });
3442
+ *
3443
+ * await acp.initialize({ protocolVersion: 20241007, clientInfo: { name: 'IDE', version: '1.0' } });
3444
+ * const { sessionId } = await acp.newSession({ cwd: '/project', mcpServers: [] });
3445
+ * const result = await acp.prompt({ sessionId, prompt: [{ type: 'text', text: 'Hello' }] });
3446
+ * ```
3447
+ */
3448
+ declare class ACPStreamConnection extends EventEmitter {
3449
+ #private;
3450
+ /**
3451
+ * Create a new ACP stream connection.
3452
+ *
3453
+ * @param mapClient - The underlying MAP client connection
3454
+ * @param options - Stream configuration options
3455
+ */
3456
+ constructor(mapClient: ClientConnection, options: ACPStreamOptions);
3457
+ /** Unique identifier for this ACP stream */
3458
+ get streamId(): string;
3459
+ /** Target agent this stream connects to */
3460
+ get targetAgent(): AgentId;
3461
+ /** Current ACP session ID (null until newSession called) */
3462
+ get sessionId(): ACPSessionId | null;
3463
+ /** Whether initialize() has been called */
3464
+ get initialized(): boolean;
3465
+ /** Agent capabilities from initialize response */
3466
+ get capabilities(): ACPAgentCapabilities | null;
3467
+ /** Whether the stream is closed */
3468
+ get isClosed(): boolean;
3469
+ /** Last processed event ID (for reconnection support) */
3470
+ get lastEventId(): string | null;
3471
+ /** Whether the stream is currently reconnecting */
3472
+ get isReconnecting(): boolean;
3473
+ /**
3474
+ * Initialize the ACP connection with the target agent.
3475
+ */
3476
+ initialize(params: ACPInitializeRequest): Promise<ACPInitializeResponse>;
3477
+ /**
3478
+ * Authenticate with the agent.
3479
+ */
3480
+ authenticate(params: ACPAuthenticateRequest): Promise<ACPAuthenticateResponse>;
3481
+ /**
3482
+ * Create a new ACP session.
3483
+ */
3484
+ newSession(params: ACPNewSessionRequest): Promise<ACPNewSessionResponse>;
3485
+ /**
3486
+ * Load an existing ACP session.
3487
+ */
3488
+ loadSession(params: ACPLoadSessionRequest): Promise<ACPLoadSessionResponse>;
3489
+ /**
3490
+ * Set the session mode.
3491
+ */
3492
+ setSessionMode(params: ACPSetSessionModeRequest): Promise<ACPSetSessionModeResponse>;
3493
+ /**
3494
+ * Send a prompt to the agent.
3495
+ * Updates are received via the sessionUpdate handler.
3496
+ */
3497
+ prompt(params: ACPPromptRequest): Promise<ACPPromptResponse>;
3498
+ /**
3499
+ * Cancel ongoing operations for the current session.
3500
+ */
3501
+ cancel(params?: Partial<ACPCancelNotification>): Promise<void>;
3502
+ /**
3503
+ * Call an ACP extension method on the target agent.
3504
+ *
3505
+ * Extension methods are prefixed with "_" (e.g., "_macro/spawnAgent").
3506
+ * The agent must support the extension for this to succeed.
3507
+ *
3508
+ * @param method - The extension method name (e.g., "_macro/spawnAgent")
3509
+ * @param params - Parameters to pass to the extension method
3510
+ * @returns The result from the extension method
3511
+ *
3512
+ * @example
3513
+ * ```typescript
3514
+ * const result = await acp.callExtension("_macro/spawnAgent", {
3515
+ * task: "Implement feature X",
3516
+ * cwd: "/project"
3517
+ * });
3518
+ * ```
3519
+ */
3520
+ callExtension<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
3521
+ /**
3522
+ * Close this ACP stream and clean up resources.
3523
+ */
3524
+ close(): Promise<void>;
3525
+ }
3526
+ /**
3527
+ * Create an ACP stream connection from a MAP client.
3528
+ *
3529
+ * @param mapClient - The underlying MAP client connection
3530
+ * @param options - Stream configuration options
3531
+ * @returns A new ACPStreamConnection instance
3532
+ */
3533
+ declare function createACPStream(mapClient: ClientConnection, options: ACPStreamOptions): ACPStreamConnection;
3534
+
3535
+ /**
3536
+ * Client connection for MAP protocol
3537
+ *
3538
+ * Used by clients to connect to a MAP system, query agents,
3539
+ * subscribe to events, and send messages.
3540
+ */
3541
+
3542
+ /**
3543
+ * Options for automatic reconnection
3544
+ */
3545
+ interface ReconnectionOptions {
3546
+ /** Enable automatic reconnection (default: false) */
3547
+ enabled: boolean;
3548
+ /** Maximum number of retry attempts (default: 10) */
3549
+ maxRetries?: number;
3550
+ /** Initial delay in milliseconds (default: 1000) */
3551
+ baseDelayMs?: number;
3552
+ /** Maximum delay in milliseconds (default: 30000) */
3553
+ maxDelayMs?: number;
3554
+ /** Add jitter to delays (default: true) */
3555
+ jitter?: boolean;
3556
+ /** Restore subscriptions after reconnect (default: true) */
3557
+ restoreSubscriptions?: boolean;
3558
+ /** Replay missed events on restore (default: true) */
3559
+ replayOnRestore?: boolean;
3560
+ /** Maximum events to replay per subscription (default: 1000) */
3561
+ maxReplayEventsPerSubscription?: number;
3562
+ }
3563
+ /**
3564
+ * Reconnection event types
3565
+ */
3566
+ type ReconnectionEventType = 'disconnected' | 'reconnecting' | 'reconnected' | 'reconnectFailed' | 'subscriptionRestored' | 'subscriptionRestoreFailed';
3567
+ /**
3568
+ * Handler for reconnection events
3569
+ */
3570
+ type ReconnectionEventHandler = (event: {
3571
+ type: ReconnectionEventType;
3572
+ attempt?: number;
3573
+ delay?: number;
3574
+ error?: Error;
3575
+ subscriptionId?: SubscriptionId;
3576
+ newSubscriptionId?: SubscriptionId;
3577
+ }) => void;
3578
+ /**
3579
+ * Options for client connection
3580
+ */
3581
+ interface ClientConnectionOptions extends BaseConnectionOptions {
3582
+ /** Client name for identification */
3583
+ name?: string;
3584
+ /** Client capabilities */
3585
+ capabilities?: ParticipantCapabilities;
3586
+ /** Factory to create new stream for reconnection */
3587
+ createStream?: () => Promise<Stream>;
3588
+ /** Reconnection options */
3589
+ reconnection?: ReconnectionOptions;
3590
+ }
3591
+ /**
3592
+ * Options for ClientConnection.connect() static method
3593
+ */
3594
+ interface ClientConnectOptions {
3595
+ /** Client name for identification */
3596
+ name?: string;
3597
+ /** Client capabilities to advertise */
3598
+ capabilities?: ParticipantCapabilities;
3599
+ /** Authentication credentials */
3600
+ auth?: {
3601
+ method: 'bearer' | 'api-key' | 'mtls' | 'none';
3602
+ token?: string;
3603
+ };
3604
+ /**
3605
+ * Reconnection configuration.
3606
+ * - `true` = enable with defaults
3607
+ * - `false` or omitted = disabled
3608
+ * - `ReconnectionOptions` = enable with custom settings
3609
+ */
3610
+ reconnection?: boolean | ReconnectionOptions;
3611
+ /** Connection timeout in ms (default: 10000) */
3612
+ connectTimeout?: number;
3613
+ }
3614
+ /**
3615
+ * Options for ClientConnection.connectMesh() static method
3616
+ */
3617
+ interface MeshConnectOptions {
3618
+ /** The agentic-mesh transport adapter (Nebula, Tailscale, etc.) */
3619
+ transport: MeshTransportAdapter;
3620
+ /** Remote peer to connect to */
3621
+ peer: MeshPeerEndpoint;
3622
+ /** Local peer ID for identification */
3623
+ localPeerId: string;
3624
+ /** Client name for identification */
3625
+ name?: string;
3626
+ /** Client capabilities to advertise */
3627
+ capabilities?: ParticipantCapabilities;
3628
+ /** Authentication credentials */
3629
+ auth?: {
3630
+ method: 'bearer' | 'api-key' | 'mtls' | 'none';
3631
+ token?: string;
3632
+ };
3633
+ /**
3634
+ * Reconnection configuration.
3635
+ * - `true` = enable with defaults
3636
+ * - `false` or omitted = disabled
3637
+ * - `ReconnectionOptions` = enable with custom settings
3638
+ */
3639
+ reconnection?: boolean | ReconnectionOptions;
3640
+ /** Connection timeout in ms (default: 10000) */
3641
+ timeout?: number;
3642
+ }
3643
+ /**
3644
+ * Client connection to a MAP system.
3645
+ *
3646
+ * Provides methods for:
3647
+ * - Querying agents and structure
3648
+ * - Subscribing to events
3649
+ * - Sending messages to agents
3650
+ * - (With permissions) Steering agents
3651
+ *
3652
+ * ## Response Shape Patterns
3653
+ *
3654
+ * Methods follow consistent response shape conventions:
3655
+ *
3656
+ * **Create Operations** return the full entity that was created:
3657
+ * - `registerAgent()` → `{ agent: Agent }`
3658
+ * - `createScope()` → `{ scope: Scope }`
3659
+ * - `subscribe()` → `Subscription` (full subscription object)
3660
+ *
3661
+ * **Query Operations** return the requested data:
3662
+ * - `listAgents()` → `{ agents: Agent[] }`
3663
+ * - `getAgent()` → `{ agent: Agent, children?: Agent[] }`
3664
+ * - `getScope()` → `Scope`
3665
+ * - `listScopes()` → `{ scopes: Scope[] }`
3666
+ *
3667
+ * **Action Operations** return confirmation with reference ID:
3668
+ * - `send()` → `{ messageId: string }`
3669
+ * - `inject()` → `{ accepted: boolean }`
3670
+ *
3671
+ * **Lifecycle Operations** return status:
3672
+ * - `connect()` → `ConnectResponseResult` (session info, capabilities, auth status)
3673
+ * - `disconnect()` → `string | undefined` (resume token)
3674
+ * - `authenticate()` → `{ success: boolean, principal?: AuthPrincipal }`
3675
+ */
3676
+ declare class ClientConnection {
3677
+ #private;
3678
+ constructor(stream: Stream, options?: ClientConnectionOptions);
3679
+ /**
3680
+ * Connect to a MAP server via WebSocket URL.
3681
+ *
3682
+ * Handles:
3683
+ * - WebSocket creation and connection
3684
+ * - Stream wrapping
3685
+ * - Auto-configuration of createStream for reconnection
3686
+ * - Initial MAP protocol connect handshake
3687
+ *
3688
+ * @param url - WebSocket URL (ws:// or wss://)
3689
+ * @param options - Connection options
3690
+ * @returns Connected ClientConnection instance
3691
+ *
3692
+ * @example
3693
+ * ```typescript
3694
+ * const client = await ClientConnection.connect('ws://localhost:8080', {
3695
+ * name: 'MyClient',
3696
+ * reconnection: true
3697
+ * });
3698
+ *
3699
+ * // Already connected, ready to use
3700
+ * const agents = await client.listAgents();
3701
+ * ```
3702
+ */
3703
+ static connect(url: string, options?: ClientConnectOptions): Promise<ClientConnection>;
3704
+ /**
3705
+ * Connect to a MAP server via agentic-mesh transport.
3706
+ *
3707
+ * Handles:
3708
+ * - Dynamic import of agentic-mesh (optional peer dependency)
3709
+ * - Stream creation over encrypted mesh tunnel
3710
+ * - Auto-configuration of createStream for reconnection
3711
+ * - Initial MAP protocol connect handshake
3712
+ *
3713
+ * Requires `agentic-mesh` to be installed as a peer dependency.
3714
+ *
3715
+ * @param options - Mesh connection options
3716
+ * @returns Connected ClientConnection instance
3717
+ *
3718
+ * @example
3719
+ * ```typescript
3720
+ * import { createNebulaTransport } from 'agentic-mesh';
3721
+ *
3722
+ * const transport = createNebulaTransport({
3723
+ * configPath: '/etc/nebula/config.yml',
3724
+ * });
3725
+ *
3726
+ * const client = await ClientConnection.connectMesh({
3727
+ * transport,
3728
+ * peer: { peerId: 'server', address: '10.0.0.1', port: 4242 },
3729
+ * localPeerId: 'my-client',
3730
+ * name: 'MeshClient',
3731
+ * reconnection: true
3732
+ * });
3733
+ *
3734
+ * const agents = await client.listAgents();
3735
+ * ```
3736
+ */
3737
+ static connectMesh(options: MeshConnectOptions): Promise<ClientConnection>;
3738
+ /**
3739
+ * Connect to the MAP system
3740
+ *
3741
+ * @param options - Connection options
3742
+ * @param options.sessionId - Specific session ID to use
3743
+ * @param options.resumeToken - Token to resume a previously disconnected session
3744
+ * @param options.auth - Authentication credentials
3745
+ * @param options.onTokenExpiring - Callback invoked before token expires for proactive refresh
3746
+ */
3747
+ connect(options?: {
3748
+ sessionId?: SessionId;
3749
+ /** Token to resume a previously disconnected session */
3750
+ resumeToken?: string;
3751
+ /** Authentication credentials */
3752
+ auth?: {
3753
+ method: 'bearer' | 'api-key' | 'mtls' | 'none';
3754
+ credential?: string;
3755
+ };
3756
+ /** Callback invoked when token is about to expire. Return new credentials to refresh. */
3757
+ onTokenExpiring?: (expiresAt: number) => Promise<{
3758
+ method: string;
3759
+ credential: string;
3760
+ } | void>;
3761
+ }): Promise<ConnectResponseResult>;
3762
+ /**
3763
+ * Get the resume token for this session.
3764
+ * Can be used to reconnect and restore session state after disconnection.
3765
+ *
3766
+ * @returns The resume token, or undefined if not available
3767
+ */
3768
+ getResumeToken(): string | undefined;
3769
+ /**
3770
+ * Reconnect to the server, optionally using a resume token to restore session.
3771
+ *
3772
+ * @param resumeToken - Token to resume previous session. If not provided, uses the last known token.
3773
+ * @returns Connect response result
3774
+ *
3775
+ * @example
3776
+ * ```typescript
3777
+ * // Save token before disconnect
3778
+ * const token = await client.disconnect();
3779
+ *
3780
+ * // Later, reconnect with the token
3781
+ * const result = await client.reconnect(token);
3782
+ * console.log('Reconnected:', result.reconnected);
3783
+ * ```
3784
+ */
3785
+ reconnect(resumeToken?: string): Promise<ConnectResponseResult>;
3786
+ /**
3787
+ * Authenticate with the server after connection.
3788
+ *
3789
+ * Use this when the server returns `authRequired` in the connect response,
3790
+ * indicating that authentication is needed before accessing protected resources.
3791
+ *
3792
+ * @param auth - Authentication credentials
3793
+ * @returns Authentication result with principal if successful
3794
+ *
3795
+ * @example
3796
+ * ```typescript
3797
+ * const connectResult = await client.connect();
3798
+ *
3799
+ * if (connectResult.authRequired) {
3800
+ * const authResult = await client.authenticate({
3801
+ * method: 'api-key',
3802
+ * credential: process.env.API_KEY,
3803
+ * });
3804
+ *
3805
+ * if (authResult.success) {
3806
+ * console.log('Authenticated as:', authResult.principal?.id);
3807
+ * }
3808
+ * }
3809
+ * ```
3810
+ */
3811
+ authenticate(auth: {
3812
+ method: 'bearer' | 'api-key' | 'mtls' | 'none';
3813
+ credential?: string;
3814
+ }): Promise<AuthenticateResponseResult>;
3815
+ /**
3816
+ * Refresh authentication credentials.
3817
+ *
3818
+ * Use this to update credentials before they expire for long-lived connections.
3819
+ *
3820
+ * @param auth - New authentication credentials
3821
+ * @returns Updated principal information
3822
+ */
3823
+ refreshAuth(auth: {
3824
+ method: "bearer" | "api-key" | "mtls" | "none";
3825
+ credential?: string;
3826
+ }): Promise<{
3827
+ success: boolean;
3828
+ principal?: AuthPrincipal;
3829
+ error?: {
3830
+ code: string;
3831
+ message: string;
3832
+ };
3833
+ }>;
3834
+ /**
3835
+ * Disconnect from the MAP system
3836
+ * @param reason - Optional reason for disconnecting
3837
+ * @returns Resume token that can be used to resume this session later
3838
+ */
3839
+ disconnect(reason?: string): Promise<string | undefined>;
3840
+ /**
3841
+ * Whether the client is connected
3842
+ */
3843
+ get isConnected(): boolean;
3844
+ /**
3845
+ * Current session ID
3846
+ */
3847
+ get sessionId(): SessionId | null;
3848
+ /**
3849
+ * Server capabilities
3850
+ */
3851
+ get serverCapabilities(): ParticipantCapabilities | null;
3852
+ /**
3853
+ * AbortSignal that triggers when the connection closes
3854
+ */
3855
+ get signal(): AbortSignal;
3856
+ /**
3857
+ * Promise that resolves when the connection closes
2276
3858
  */
2277
3859
  get closed(): Promise<void>;
2278
3860
  /**
@@ -2346,6 +3928,51 @@ declare class ClientConnection {
2346
3928
  timeout?: number;
2347
3929
  meta?: MessageMeta;
2348
3930
  }): Promise<Message<T>>;
3931
+ /**
3932
+ * Create a virtual ACP stream connection to an agent.
3933
+ *
3934
+ * This allows clients to interact with ACP-compatible agents using the
3935
+ * familiar ACP interface while routing all messages through MAP.
3936
+ *
3937
+ * @param options - Stream configuration options
3938
+ * @returns ACPStreamConnection instance ready for initialize()
3939
+ *
3940
+ * @example
3941
+ * ```typescript
3942
+ * const acp = client.createACPStream({
3943
+ * targetAgent: 'coding-agent-1',
3944
+ * client: {
3945
+ * requestPermission: async (req) => ({
3946
+ * outcome: { outcome: 'selected', optionId: 'allow' }
3947
+ * }),
3948
+ * sessionUpdate: async (update) => {
3949
+ * console.log('Agent update:', update);
3950
+ * }
3951
+ * }
3952
+ * });
3953
+ *
3954
+ * await acp.initialize({
3955
+ * protocolVersion: 20241007,
3956
+ * clientInfo: { name: 'IDE', version: '1.0' }
3957
+ * });
3958
+ * const { sessionId } = await acp.newSession({ cwd: '/project', mcpServers: [] });
3959
+ * const result = await acp.prompt({
3960
+ * sessionId,
3961
+ * prompt: [{ type: 'text', text: 'Hello' }]
3962
+ * });
3963
+ *
3964
+ * await acp.close();
3965
+ * ```
3966
+ */
3967
+ createACPStream(options: Omit<ACPStreamOptions, 'mapClient'>): ACPStreamConnection;
3968
+ /**
3969
+ * Get an active ACP stream by ID.
3970
+ */
3971
+ getACPStream(streamId: string): ACPStreamConnection | undefined;
3972
+ /**
3973
+ * Get all active ACP streams.
3974
+ */
3975
+ get acpStreams(): ReadonlyMap<string, ACPStreamConnection>;
2349
3976
  /**
2350
3977
  * Subscribe to events
2351
3978
  */
@@ -2563,6 +4190,45 @@ interface AgentConnectOptions {
2563
4190
  /** Connection timeout in ms (default: 10000) */
2564
4191
  connectTimeout?: number;
2565
4192
  }
4193
+ /**
4194
+ * Options for AgentConnection.connectMesh() static method
4195
+ */
4196
+ interface AgentMeshConnectOptions {
4197
+ /** The agentic-mesh transport adapter (Nebula, Tailscale, etc.) */
4198
+ transport: MeshTransportAdapter;
4199
+ /** Remote peer to connect to */
4200
+ peer: MeshPeerEndpoint;
4201
+ /** Local peer ID for identification */
4202
+ localPeerId: string;
4203
+ /** Agent name */
4204
+ name?: string;
4205
+ /** Agent role */
4206
+ role?: string;
4207
+ /** Agent capabilities to advertise */
4208
+ capabilities?: ParticipantCapabilities;
4209
+ /** Agent visibility settings */
4210
+ visibility?: AgentVisibility;
4211
+ /** Parent agent ID (for child agents) */
4212
+ parent?: AgentId;
4213
+ /** Initial scopes to join */
4214
+ scopes?: ScopeId[];
4215
+ /** Initial metadata */
4216
+ metadata?: Record<string, unknown>;
4217
+ /** Authentication credentials */
4218
+ auth?: {
4219
+ method: 'bearer' | 'api-key' | 'mtls' | 'none';
4220
+ token?: string;
4221
+ };
4222
+ /**
4223
+ * Reconnection configuration.
4224
+ * - `true` = enable with defaults
4225
+ * - `false` or omitted = disabled
4226
+ * - `AgentReconnectionOptions` = enable with custom settings
4227
+ */
4228
+ reconnection?: boolean | AgentReconnectionOptions;
4229
+ /** Connection timeout in ms (default: 10000) */
4230
+ timeout?: number;
4231
+ }
2566
4232
  /**
2567
4233
  * Agent connection to a MAP system.
2568
4234
  *
@@ -2605,6 +4271,43 @@ declare class AgentConnection {
2605
4271
  * ```
2606
4272
  */
2607
4273
  static connect(url: string, options?: AgentConnectOptions): Promise<AgentConnection>;
4274
+ /**
4275
+ * Connect and register an agent via agentic-mesh transport.
4276
+ *
4277
+ * Handles:
4278
+ * - Dynamic import of agentic-mesh (optional peer dependency)
4279
+ * - Stream creation over encrypted mesh tunnel
4280
+ * - Auto-configuration of createStream for reconnection
4281
+ * - Initial MAP protocol connect handshake
4282
+ * - Agent registration
4283
+ *
4284
+ * Requires `agentic-mesh` to be installed as a peer dependency.
4285
+ *
4286
+ * @param options - Mesh connection and agent options
4287
+ * @returns Connected and registered AgentConnection instance
4288
+ *
4289
+ * @example
4290
+ * ```typescript
4291
+ * import { createNebulaTransport } from 'agentic-mesh';
4292
+ *
4293
+ * const transport = createNebulaTransport({
4294
+ * configPath: '/etc/nebula/config.yml',
4295
+ * });
4296
+ *
4297
+ * const agent = await AgentConnection.connectMesh({
4298
+ * transport,
4299
+ * peer: { peerId: 'server', address: '10.0.0.1', port: 4242 },
4300
+ * localPeerId: 'my-agent',
4301
+ * name: 'MeshWorker',
4302
+ * role: 'processor',
4303
+ * reconnection: true
4304
+ * });
4305
+ *
4306
+ * agent.onMessage(handleMessage);
4307
+ * await agent.busy();
4308
+ * ```
4309
+ */
4310
+ static connectMesh(options: AgentMeshConnectOptions): Promise<AgentConnection>;
2608
4311
  /**
2609
4312
  * Connect and register with the MAP system
2610
4313
  */
@@ -2620,6 +4323,59 @@ declare class AgentConnection {
2620
4323
  connection: ConnectResponseResult;
2621
4324
  agent: Agent;
2622
4325
  }>;
4326
+ /**
4327
+ * Authenticate with the server after connection.
4328
+ *
4329
+ * Use this when the server returns `authRequired` in the connect response,
4330
+ * indicating that authentication is needed before registering or accessing
4331
+ * protected resources.
4332
+ *
4333
+ * @param auth - Authentication credentials
4334
+ * @returns Authentication result with principal if successful
4335
+ *
4336
+ * @example
4337
+ * ```typescript
4338
+ * const agent = new AgentConnection(stream, { name: 'MyAgent' });
4339
+ *
4340
+ * // First connect to get auth requirements
4341
+ * const connectResult = await agent.connectOnly();
4342
+ *
4343
+ * if (connectResult.authRequired) {
4344
+ * const authResult = await agent.authenticate({
4345
+ * method: 'api-key',
4346
+ * token: process.env.AGENT_API_KEY,
4347
+ * });
4348
+ *
4349
+ * if (authResult.success) {
4350
+ * // Now register the agent
4351
+ * await agent.register({ name: 'MyAgent', role: 'worker' });
4352
+ * }
4353
+ * }
4354
+ * ```
4355
+ */
4356
+ authenticate(auth: {
4357
+ method: 'bearer' | 'api-key' | 'mtls' | 'none';
4358
+ token?: string;
4359
+ }): Promise<AuthenticateResponseResult>;
4360
+ /**
4361
+ * Refresh authentication credentials.
4362
+ *
4363
+ * Use this to update credentials before they expire for long-lived connections.
4364
+ *
4365
+ * @param auth - New authentication credentials
4366
+ * @returns Updated principal information
4367
+ */
4368
+ refreshAuth(auth: {
4369
+ method: "bearer" | "api-key" | "mtls" | "none";
4370
+ token?: string;
4371
+ }): Promise<{
4372
+ success: boolean;
4373
+ principal?: AuthPrincipal;
4374
+ error?: {
4375
+ code: string;
4376
+ message: string;
4377
+ };
4378
+ }>;
2623
4379
  /**
2624
4380
  * Disconnect from the MAP system
2625
4381
  * @param reason - Optional reason for disconnecting
@@ -3177,4 +4933,4 @@ declare function canAgentMessageAgent(senderAgent: Agent, targetAgentId: AgentId
3177
4933
  sharedScopes?: ScopeId[];
3178
4934
  }, config?: AgentPermissionConfig): boolean;
3179
4935
 
3180
- export { type AgentLifecycle as $, type AgentId as A, type BaseConnectionOptions as B, type ConnectResponseResult as C, type DisconnectResponseResult as D, type ErrorCategory as E, type FederationBufferConfig as F, type ScopesJoinResponseResult as G, type ScopesLeaveResponseResult as H, type ScopesListResponseResult as I, type MessageId as J, type SendResponseResult as K, type SubscriptionId as L, type MAPError as M, type SubscribeResponseResult as N, AGENT_ERROR_CODES as O, type ParticipantCapabilities as P, AUTH_ERROR_CODES as Q, type RequestId as R, type Stream as S, AUTH_METHODS as T, type UnsubscribeResponseResult as U, type AcceptanceContext as V, type AgentAcceptanceRule as W, type AgentConnectOptions as X, AgentConnection as Y, type AgentConnectionOptions as Z, type AgentIncludeOptions as _, type MAPErrorData as a, FEDERATION_METHODS as a$, type AgentMessagingRule as a0, type AgentPermissionConfig as a1, type AgentPermissions as a2, type AgentReconnectionEventHandler as a3, type AgentReconnectionEventType as a4, type AgentReconnectionOptions as a5, type AgentRelationship as a6, type AgentRelationshipType as a7, type AgentState as a8, type AgentVisibility as a9, type AuthRefreshRequest as aA, type AuthRefreshRequestParams as aB, type AuthRefreshResponseResult as aC, BaseConnection as aD, type BroadcastAddress as aE, CAPABILITY_REQUIREMENTS as aF, CORE_METHODS as aG, type ClientAcceptanceRule as aH, type ClientConnectOptions as aI, ClientConnection as aJ, type ClientConnectionOptions as aK, type ConnectRequest as aL, type ConnectRequestParams as aM, type CorrelationId as aN, DEFAULT_AGENT_PERMISSION_CONFIG as aO, type DeliverySemantics as aP, type DirectAddress as aQ, type DisconnectPolicy as aR, type DisconnectRequest as aS, type DisconnectRequestParams as aT, ERROR_CODES as aU, EVENT_TYPES as aV, EXTENSION_METHODS as aW, type EventInput as aX, type EventNotification as aY, type EventNotificationParams as aZ, FEDERATION_ERROR_CODES as a_, type AgentVisibilityRule as aa, type AgentsGetRequest as ab, type AgentsGetRequestParams as ac, type AgentsListFilter as ad, type AgentsListRequest as ae, type AgentsListRequestParams as af, type AgentsRegisterRequest as ag, type AgentsRegisterRequestParams as ah, type AgentsResumeRequest as ai, type AgentsResumeRequestParams as aj, type AgentsResumeResponseResult as ak, type AgentsSpawnRequest as al, type AgentsSpawnRequestParams as am, type AgentsStopRequest as an, type AgentsStopRequestParams as ao, type AgentsStopResponseResult as ap, type AgentsSuspendRequest as aq, type AgentsSuspendRequestParams as ar, type AgentsSuspendResponseResult as as, type AgentsUnregisterRequest as at, type AgentsUnregisterRequestParams as au, type AgentsUpdateRequest as av, type AgentsUpdateRequestParams as aw, type AnyMessage as ax, type AuthMethod as ay, type AuthParams as az, type FederationEnvelope as b, ROUTING_ERROR_CODES as b$, type FederatedAddress as b0, type FederationAuth as b1, type FederationConnectRequest as b2, type FederationConnectRequestParams as b3, type FederationMetadata as b4, type FederationReplayConfig as b5, type FederationRouteRequest as b6, type FederationRouteRequestParams as b7, type GatewayReconnectionEvent as b8, type GatewayReconnectionEventHandler as b9, type MessagePriority as bA, type MessageRelationship as bB, type MessageSentEventData as bC, type MessageVisibility as bD, type Meta as bE, type MultiAddress as bF, NOTIFICATION_METHODS as bG, type NotificationHandler as bH, OBSERVATION_METHODS as bI, type OverflowHandler as bJ, type OverflowInfo as bK, PERMISSION_METHODS as bL, PROTOCOL_ERROR_CODES as bM, PROTOCOL_VERSION as bN, type Participant as bO, type ParticipantAddress as bP, type PermissionAction as bQ, type PermissionContext as bR, type PermissionParticipant as bS, type PermissionResult as bT, type PermissionSystemConfig as bU, type PermissionsAgentUpdatedEventData as bV, type PermissionsClientUpdatedEventData as bW, type PermissionsUpdateRequest as bX, type PermissionsUpdateRequestParams as bY, type PermissionsUpdateResponseResult as bZ, RESOURCE_ERROR_CODES as b_, type GatewayReconnectionEventType as ba, type GatewayReconnectionOptions as bb, type GraphEdge as bc, type HierarchicalAddress as bd, type InjectDelivery as be, type InjectDeliveryResult as bf, type InjectRequest as bg, type InjectRequestParams as bh, type InjectResponseResult as bi, JSONRPC_VERSION as bj, type JoinPolicy as bk, LIFECYCLE_METHODS as bl, type MAPNotification as bm, type MAPNotificationBase as bn, type MAPRequest as bo, type MAPRequestBase as bp, type MAPResponse as bq, type MAPResponseError as br, type MAPResponseSuccess as bs, MAP_METHODS as bt, type MessageDeliveredEventData as bu, type MessageFailedEventData as bv, type MessageHandler as bw, type MessageMeta as bx, type MessageNotification as by, type MessageNotificationParams as bz, type Message as c, type TransportType as c$, type ReconnectionEventHandler as c0, type ReconnectionEventType as c1, type ReconnectionOptions as c2, type ReplayRequest as c3, type ReplayRequestParams as c4, type ReplayResponseResult as c5, type ReplayedEvent as c6, type RequestHandler as c7, type RoleAddress as c8, SCOPE_METHODS as c9, type SendRequest as cA, type SendRequestParams as cB, type SessionCloseRequest as cC, type SessionCloseRequestParams as cD, type SessionCloseResponseResult as cE, type SessionListRequest as cF, type SessionListRequestParams as cG, type SessionListResponseResult as cH, type SessionLoadRequest as cI, type SessionLoadRequestParams as cJ, type SessionLoadResponseResult as cK, type StateChangeHandler as cL, type StreamingCapabilities as cM, type StructureGraphRequest as cN, type StructureGraphRequestParams as cO, type StructureGraphResponseResult as cP, type StructureVisibilityRule as cQ, type SubscribeRequest as cR, type SubscribeRequestParams as cS, Subscription as cT, type SubscriptionAckNotification as cU, type SubscriptionAckParams as cV, type SubscriptionOptions$1 as cW, type SubscriptionState as cX, type SystemAcceptanceRule as cY, type SystemAddress as cZ, type Timestamp as c_, SESSION_METHODS as ca, STATE_METHODS as cb, STEERING_METHODS as cc, STRUCTURE_METHODS as cd, type ScopeAddress as ce, type ScopeMessagingRule as cf, type ScopeVisibility as cg, type ScopeVisibilityRule as ch, type ScopesCreateRequest as ci, type ScopesCreateRequestParams as cj, type ScopesDeleteRequest as ck, type ScopesDeleteRequestParams as cl, type ScopesDeleteResponseResult as cm, type ScopesGetRequest as cn, type ScopesGetRequestParams as co, type ScopesGetResponseResult as cp, type ScopesJoinRequest as cq, type ScopesJoinRequestParams as cr, type ScopesLeaveRequest as cs, type ScopesLeaveRequestParams as ct, type ScopesListRequest as cu, type ScopesListRequestParams as cv, type ScopesMembersRequest as cw, type ScopesMembersRequestParams as cx, type ScopesMembersResponseResult as cy, type SendPolicy as cz, type FederationRoutingConfig as d, type UnsubscribeRequest as d0, type UnsubscribeRequestParams as d1, canAgentAcceptMessage as d2, canAgentMessageAgent as d3, canAgentSeeAgent as d4, canControlAgent as d5, canJoinScope as d6, canMessageAgent as d7, canPerformAction as d8, canPerformMethod as d9, type SystemExposure as dA, canSeeAgent as da, canSeeScope as db, canSendToScope as dc, createEvent as dd, createStreamPair as de, createSubscription as df, deepMergePermissions as dg, filterVisibleAgents as dh, filterVisibleEvents as di, filterVisibleScopes as dj, hasCapability as dk, isAgentExposed as dl, isBroadcastAddress as dm, isDirectAddress as dn, isEventTypeExposed as dp, isFederatedAddress as dq, isHierarchicalAddress as dr, isOrphanedAgent as ds, isScopeExposed as dt, isSuccessResponse as du, mapVisibilityToRule as dv, ndJsonStream as dw, resolveAgentPermissions as dx, waitForOpen as dy, websocketStream as dz, type EventType as e, type SessionId as f, type FederationConnectResponseResult as g, type FederationRouteResponseResult as h, type ConnectionState as i, type ParticipantId as j, type ParticipantType as k, type ScopeId as l, type Agent as m, type Scope as n, type Address as o, type SubscriptionFilter as p, type Event as q, type AgentsGetResponseResult as r, type AgentsListResponseResult as s, type AgentsRegisterResponseResult as t, type AgentsSpawnResponseResult as u, type AgentsUnregisterResponseResult as v, type AgentsUpdateResponseResult as w, type ProtocolVersion as x, type SessionInfo as y, type ScopesCreateResponseResult as z };
4936
+ export { type ACPReadTextFileRequest as $, type AgentId as A, type BaseConnectionOptions as B, type ConnectResponseResult as C, type DisconnectResponseResult as D, type ErrorCategory as E, type FederationBufferConfig as F, type ScopesJoinResponseResult as G, type ScopesLeaveResponseResult as H, type ScopesListResponseResult as I, type MessageId as J, type SendResponseResult as K, type SubscriptionId as L, type MAPError as M, type SubscribeResponseResult as N, type AgentVisibility as O, type ParticipantCapabilities as P, type ScopeVisibility as Q, type RequestId as R, type Stream as S, type AgentState as T, type UnsubscribeResponseResult as U, type MessageMeta as V, AgentConnection as W, type ACPAgentHandler as X, type ACPSessionNotification as Y, type ACPRequestPermissionRequest as Z, type ACPRequestPermissionResponse as _, type MAPErrorData as a, type ACPPlan as a$, type ACPReadTextFileResponse as a0, type ACPWriteTextFileRequest as a1, type ACPWriteTextFileResponse as a2, type ACPCreateTerminalRequest as a3, type ACPCreateTerminalResponse as a4, type ACPTerminalOutputRequest as a5, type ACPTerminalOutputResponse as a6, type ACPReleaseTerminalRequest as a7, type ACPReleaseTerminalResponse as a8, type ACPWaitForTerminalExitRequest as a9, type ACPEnvVariable as aA, type ACPEnvelope as aB, ACPError as aC, type ACPErrorCode as aD, type ACPErrorObject as aE, type ACPErrorResponse as aF, type ACPFileSystemCapability as aG, type ACPHttpHeader as aH, type ACPImageContent as aI, type ACPImplementation as aJ, type ACPInitializeRequest as aK, type ACPInitializeResponse as aL, type ACPLoadSessionRequest as aM, type ACPLoadSessionResponse as aN, type ACPMcpCapabilities as aO, type ACPMcpServer as aP, type ACPMcpServerHttp as aQ, type ACPMcpServerSse as aR, type ACPMcpServerStdio as aS, type ACPMessage as aT, type ACPMeta as aU, type ACPNewSessionRequest as aV, type ACPNewSessionResponse as aW, type ACPNotification as aX, type ACPPermissionOption as aY, type ACPPermissionOptionId as aZ, type ACPPermissionOptionKind as a_, type ACPWaitForTerminalExitResponse as aa, type ACPKillTerminalCommandRequest as ab, type ACPKillTerminalCommandResponse as ac, type ACPSessionId as ad, type ACPAgentCapabilities as ae, type ACPAgentContext as af, type ACPAnnotations as ag, type ACPAudioContent as ah, type ACPAuthMethod as ai, type ACPAuthenticateRequest as aj, type ACPAuthenticateResponse as ak, type ACPAvailableCommand as al, type ACPAvailableCommandsUpdate as am, type ACPBlobResourceContents as an, type ACPCancelNotification as ao, type ACPCancelledPermissionOutcome as ap, type ACPCapability as aq, type ACPClientCapabilities as ar, type ACPClientHandlers as as, type ACPContent as at, type ACPContentBlock as au, type ACPContentChunk as av, type ACPContext as aw, type ACPCurrentModeUpdate as ax, type ACPDiff as ay, type ACPEmbeddedResource as az, type FederationEnvelope as b, type AgentsListFilter as b$, type ACPPlanEntry as b0, type ACPPlanEntryPriority as b1, type ACPPlanEntryStatus as b2, type ACPPromptCapabilities as b3, type ACPPromptRequest as b4, type ACPPromptResponse as b5, type ACPProtocolVersion as b6, type ACPRequest as b7, type ACPRequestId as b8, type ACPRequestPermissionOutcome as b9, type ACPToolCallUpdate as bA, type ACPToolKind as bB, ACP_ERROR_CODES as bC, ACP_METHODS as bD, ACP_PROTOCOL_VERSION as bE, AGENT_ERROR_CODES as bF, AUTH_ERROR_CODES as bG, AUTH_METHODS as bH, type AcceptanceContext as bI, type AgentAcceptanceRule as bJ, type AgentConnectOptions as bK, type AgentConnectionOptions as bL, type AgentIncludeOptions as bM, type AgentLifecycle as bN, type AgentMeshConnectOptions as bO, type AgentMessagingRule as bP, type AgentPermissionConfig as bQ, type AgentPermissions as bR, type AgentReconnectionEventHandler as bS, type AgentReconnectionEventType as bT, type AgentReconnectionOptions as bU, type AgentRelationship as bV, type AgentRelationshipType as bW, type AgentVisibilityRule as bX, type AgenticMeshStreamConfig as bY, type AgentsGetRequest as bZ, type AgentsGetRequestParams as b_, type ACPResourceLink as ba, type ACPResponse as bb, type ACPRole as bc, type ACPSelectedPermissionOutcome as bd, type ACPSessionCapabilities as be, type ACPSessionInfoUpdate as bf, type ACPSessionMode as bg, type ACPSessionModeId as bh, type ACPSessionModeState as bi, type ACPSessionUpdate as bj, type ACPSetSessionModeRequest as bk, type ACPSetSessionModeResponse as bl, type ACPStopReason as bm, ACPStreamConnection as bn, type ACPStreamEvents as bo, type ACPStreamOptions as bp, type ACPSuccessResponse as bq, type ACPTerminal as br, type ACPTerminalExitStatus as bs, type ACPTextContent as bt, type ACPTextResourceContents as bu, type ACPToolCall as bv, type ACPToolCallContent as bw, type ACPToolCallId as bx, type ACPToolCallLocation as by, type ACPToolCallStatus as bz, type Message as c, type FederationRouteRequest as c$, type AgentsListRequest as c0, type AgentsListRequestParams as c1, type AgentsRegisterRequest as c2, type AgentsRegisterRequestParams as c3, type AgentsResumeRequest as c4, type AgentsResumeRequestParams as c5, type AgentsResumeResponseResult as c6, type AgentsSpawnRequest as c7, type AgentsSpawnRequestParams as c8, type AgentsStopRequest as c9, type ClientAcceptanceRule as cA, type ClientConnectOptions as cB, ClientConnection as cC, type ClientConnectionOptions as cD, type ConnectRequest as cE, type ConnectRequestParams as cF, type CorrelationId as cG, DEFAULT_AGENT_PERMISSION_CONFIG as cH, type DeliverySemantics as cI, type DirectAddress as cJ, type DisconnectPolicy as cK, type DisconnectRequest as cL, type DisconnectRequestParams as cM, ERROR_CODES as cN, EVENT_TYPES as cO, EXTENSION_METHODS as cP, type EventInput as cQ, type EventNotification as cR, type EventNotificationParams as cS, FEDERATION_ERROR_CODES as cT, FEDERATION_METHODS as cU, type FederatedAddress as cV, type FederationAuth as cW, type FederationConnectRequest as cX, type FederationConnectRequestParams as cY, type FederationMetadata as cZ, type FederationReplayConfig as c_, type AgentsStopRequestParams as ca, type AgentsStopResponseResult as cb, type AgentsSuspendRequest as cc, type AgentsSuspendRequestParams as cd, type AgentsSuspendResponseResult as ce, type AgentsUnregisterRequest as cf, type AgentsUnregisterRequestParams as cg, type AgentsUpdateRequest as ch, type AgentsUpdateRequestParams as ci, type AnyMessage as cj, type AuthCredentials as ck, type AuthError as cl, type AuthErrorCode as cm, type AuthMethod as cn, type AuthPrincipal as co, type AuthRefreshRequest as cp, type AuthRefreshRequestParams as cq, type AuthRefreshResponseResult as cr, type AuthResult as cs, type AuthenticateRequest as ct, type AuthenticateRequestParams as cu, type AuthenticateResponseResult as cv, BaseConnection as cw, type BroadcastAddress as cx, CAPABILITY_REQUIREMENTS as cy, CORE_METHODS as cz, type FederationRoutingConfig as d, type ReplayRequest as d$, type FederationRouteRequestParams as d0, type GatewayReconnectionEvent as d1, type GatewayReconnectionEventHandler as d2, type GatewayReconnectionEventType as d3, type GatewayReconnectionOptions as d4, type GraphEdge as d5, type HierarchicalAddress as d6, type InjectDelivery as d7, type InjectDeliveryResult as d8, type InjectRequest as d9, type Meta as dA, type MultiAddress as dB, NOTIFICATION_METHODS as dC, type NotificationHandler as dD, OBSERVATION_METHODS as dE, type OverflowHandler as dF, type OverflowInfo as dG, PERMISSION_METHODS as dH, PROTOCOL_ERROR_CODES as dI, PROTOCOL_VERSION as dJ, type Participant as dK, type ParticipantAddress as dL, type PermissionAction as dM, type PermissionContext as dN, type PermissionParticipant as dO, type PermissionResult as dP, type PermissionSystemConfig as dQ, type PermissionsAgentUpdatedEventData as dR, type PermissionsClientUpdatedEventData as dS, type PermissionsUpdateRequest as dT, type PermissionsUpdateRequestParams as dU, type PermissionsUpdateResponseResult as dV, RESOURCE_ERROR_CODES as dW, ROUTING_ERROR_CODES as dX, type ReconnectionEventHandler as dY, type ReconnectionEventType as dZ, type ReconnectionOptions as d_, type InjectRequestParams as da, type InjectResponseResult as db, JSONRPC_VERSION as dc, type JoinPolicy as dd, LIFECYCLE_METHODS as de, type MAPNotification as df, type MAPNotificationBase as dg, type MAPRequest as dh, type MAPRequestBase as di, type MAPResponse as dj, type MAPResponseError as dk, type MAPResponseSuccess as dl, MAP_METHODS as dm, type MeshConnectOptions as dn, type MeshPeerEndpoint as dp, type MeshTransportAdapter as dq, type MessageDeliveredEventData as dr, type MessageFailedEventData as ds, type MessageHandler as dt, type MessageNotification as du, type MessageNotificationParams as dv, type MessagePriority as dw, type MessageRelationship as dx, type MessageSentEventData as dy, type MessageVisibility as dz, type EventType as e, agenticMeshStream as e$, type ReplayRequestParams as e0, type ReplayResponseResult as e1, type ReplayedEvent as e2, type RequestHandler as e3, type RoleAddress as e4, SCOPE_METHODS as e5, SESSION_METHODS as e6, STATE_METHODS as e7, STEERING_METHODS as e8, STRUCTURE_METHODS as e9, type SessionCloseResponseResult as eA, type SessionListRequest as eB, type SessionListRequestParams as eC, type SessionListResponseResult as eD, type SessionLoadRequest as eE, type SessionLoadRequestParams as eF, type SessionLoadResponseResult as eG, type StandardAuthMethod as eH, type StateChangeHandler as eI, type StreamingCapabilities as eJ, type StructureGraphRequest as eK, type StructureGraphRequestParams as eL, type StructureGraphResponseResult as eM, type StructureVisibilityRule as eN, type SubscribeRequest as eO, type SubscribeRequestParams as eP, Subscription as eQ, type SubscriptionAckNotification as eR, type SubscriptionAckParams as eS, type SubscriptionOptions$1 as eT, type SubscriptionState as eU, type SystemAcceptanceRule as eV, type SystemAddress as eW, type Timestamp as eX, type TransportType as eY, type UnsubscribeRequest as eZ, type UnsubscribeRequestParams as e_, type ScopeAddress as ea, type ScopeMessagingRule as eb, type ScopeVisibilityRule as ec, type ScopesCreateRequest as ed, type ScopesCreateRequestParams as ee, type ScopesDeleteRequest as ef, type ScopesDeleteRequestParams as eg, type ScopesDeleteResponseResult as eh, type ScopesGetRequest as ei, type ScopesGetRequestParams as ej, type ScopesGetResponseResult as ek, type ScopesJoinRequest as el, type ScopesJoinRequestParams as em, type ScopesLeaveRequest as en, type ScopesLeaveRequestParams as eo, type ScopesListRequest as ep, type ScopesListRequestParams as eq, type ScopesMembersRequest as er, type ScopesMembersRequestParams as es, type ScopesMembersResponseResult as et, type SendPolicy as eu, type SendRequest as ev, type SendRequestParams as ew, type ServerAuthCapabilities as ex, type SessionCloseRequest as ey, type SessionCloseRequestParams as ez, type SessionId as f, canAgentAcceptMessage as f0, canAgentMessageAgent as f1, canAgentSeeAgent as f2, canControlAgent as f3, canJoinScope as f4, canMessageAgent as f5, canPerformAction as f6, canPerformMethod as f7, canSeeAgent as f8, canSeeScope as f9, ndJsonStream as fA, resolveAgentPermissions as fB, waitForOpen as fC, websocketStream as fD, type SystemExposure as fE, canSendToScope as fa, createACPStream as fb, createEvent as fc, createStreamPair as fd, createSubscription as fe, deepMergePermissions as ff, filterVisibleAgents as fg, filterVisibleEvents as fh, filterVisibleScopes as fi, hasCapability as fj, isACPEnvelope as fk, isACPErrorResponse as fl, isACPNotification as fm, isACPRequest as fn, isACPResponse as fo, isACPSuccessResponse as fp, isAgentExposed as fq, isBroadcastAddress as fr, isDirectAddress as fs, isEventTypeExposed as ft, isFederatedAddress as fu, isHierarchicalAddress as fv, isOrphanedAgent as fw, isScopeExposed as fx, isSuccessResponse as fy, mapVisibilityToRule as fz, type FederationConnectResponseResult as g, type FederationRouteResponseResult as h, type ConnectionState as i, type ParticipantId as j, type ParticipantType as k, type ScopeId as l, type Agent as m, type Scope as n, type Address as o, type SubscriptionFilter as p, type Event as q, type AgentsGetResponseResult as r, type AgentsListResponseResult as s, type AgentsRegisterResponseResult as t, type AgentsSpawnResponseResult as u, type AgentsUnregisterResponseResult as v, type AgentsUpdateResponseResult as w, type ProtocolVersion as x, type SessionInfo as y, type ScopesCreateResponseResult as z };