@band-ai/sdk 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{CopilotACPAdapter-B_AVyAl6.d.ts → CursorACPAdapter-7-Jtl1LV.d.ts} +167 -3
- package/dist/{CopilotACPAdapter-Clid9xGR.d.cts → CursorACPAdapter-_YhrXRWq.d.cts} +167 -3
- package/dist/adapters.cjs +733 -205
- package/dist/adapters.d.cts +1 -1
- package/dist/adapters.d.ts +1 -1
- package/dist/adapters.js +13 -1
- package/dist/{chunk-UFO6XMCV.js → chunk-VHYPQAQ5.js} +710 -188
- package/dist/index.cjs +671 -141
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -2
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -388,7 +388,7 @@ pnpm install
|
|
|
388
388
|
cp agent_config.yaml.example agent_config.yaml # add your credentials
|
|
389
389
|
|
|
390
390
|
npx tsx examples/basic/basic-agent.ts
|
|
391
|
-
npx tsx examples/openai/
|
|
391
|
+
npx tsx examples/openai/01_basic_agent.ts
|
|
392
392
|
```
|
|
393
393
|
|
|
394
394
|
## Architecture
|
|
@@ -7,7 +7,8 @@ import { m as ToolModelMessage, n as ToolModelSchema, M as MetadataMap } from '.
|
|
|
7
7
|
import { u as GoogleADKMessages, s as GoogleADKHistoryConverter, e as A2ASessionState, A as A2AAuth, G as GatewaySessionState, a as A2AGatewayAdapterOptions, n as ParlantMessages, P as ParlantHistoryConverter, C as ChatTurn, v as OpencodeSessionState, O as OpencodeHistoryConverter, r as ACPClientSessionState } from './acp-client-DUXyczlF.js';
|
|
8
8
|
import { c as createBandMcpBackend } from './backends-CgsPQa9B.js';
|
|
9
9
|
import { M as McpToolRegistration } from './sdk-Cin80BTC.js';
|
|
10
|
-
import { Client, ClientSideConnection, RequestPermissionRequest, McpServer, ClientCapabilities, SessionMode,
|
|
10
|
+
import { SessionConfigOption, Client, ClientSideConnection, RequestPermissionRequest, McpServer, ClientCapabilities, SessionMode, SessionConfigSelectOption } from '@agentclientprotocol/sdk';
|
|
11
|
+
import { AgentFailure } from '@band-ai/band-sdk-core';
|
|
11
12
|
|
|
12
13
|
type GenericAdapterHandler = (args: {
|
|
13
14
|
message: PlatformMessage;
|
|
@@ -1338,6 +1339,86 @@ declare class ClaudeSDKAdapter extends SimpleAdapter<HistoryProvider, AdapterToo
|
|
|
1338
1339
|
private reportSessionId;
|
|
1339
1340
|
}
|
|
1340
1341
|
|
|
1342
|
+
/** Structured Band failure code when an ACP session config selection cannot be applied. */
|
|
1343
|
+
declare const FAILURE_CODE_SESSION_CONFIG = "session_config";
|
|
1344
|
+
/** Reason when a successful setter omits an array `configOptions` catalog. */
|
|
1345
|
+
declare const MISSING_CONFIG_OPTIONS_REASON = "missing_config_options";
|
|
1346
|
+
interface ACPConfigSelection {
|
|
1347
|
+
configId: string;
|
|
1348
|
+
value: string | undefined;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Session configuration selected by a caller. Use an array when the order is
|
|
1352
|
+
* significant: JavaScript object enumeration sorts array-index property names.
|
|
1353
|
+
* The record form remains supported for existing callers.
|
|
1354
|
+
*/
|
|
1355
|
+
type ACPConfigSelections$1 = readonly ACPConfigSelection[] | Readonly<Record<string, string | undefined>>;
|
|
1356
|
+
/**
|
|
1357
|
+
* Deterministic failure applying ACP session configuration. Carries provider,
|
|
1358
|
+
* option id, and optional ACP JSON-RPC code so callers can report a structured
|
|
1359
|
+
* Band failure instead of silently skipping the selection.
|
|
1360
|
+
*/
|
|
1361
|
+
declare class AcpSessionConfigError extends Error {
|
|
1362
|
+
readonly provider: string;
|
|
1363
|
+
readonly sessionId: string;
|
|
1364
|
+
readonly optionId: string;
|
|
1365
|
+
readonly selectedValue: string | undefined;
|
|
1366
|
+
readonly acpCode: number | undefined;
|
|
1367
|
+
readonly detail: unknown;
|
|
1368
|
+
readonly timedOut: boolean;
|
|
1369
|
+
constructor(input: {
|
|
1370
|
+
provider: string;
|
|
1371
|
+
sessionId: string;
|
|
1372
|
+
optionId: string;
|
|
1373
|
+
message: string;
|
|
1374
|
+
selectedValue?: string;
|
|
1375
|
+
acpCode?: number;
|
|
1376
|
+
detail?: unknown;
|
|
1377
|
+
cause?: unknown;
|
|
1378
|
+
timedOut?: boolean;
|
|
1379
|
+
});
|
|
1380
|
+
toAgentFailure(): AgentFailure;
|
|
1381
|
+
}
|
|
1382
|
+
type SessionConfigOptionSetter = (params: {
|
|
1383
|
+
sessionId: string;
|
|
1384
|
+
configId: string;
|
|
1385
|
+
value: string;
|
|
1386
|
+
}) => Promise<{
|
|
1387
|
+
configOptions?: readonly SessionConfigOption[] | null;
|
|
1388
|
+
}>;
|
|
1389
|
+
interface ApplySessionConfigSelectionsInput {
|
|
1390
|
+
provider: string;
|
|
1391
|
+
sessionId: string;
|
|
1392
|
+
catalog: readonly SessionConfigOption[];
|
|
1393
|
+
selections: ACPConfigSelections$1;
|
|
1394
|
+
setOption: SessionConfigOptionSetter;
|
|
1395
|
+
timeoutMs: number;
|
|
1396
|
+
}
|
|
1397
|
+
interface ApplySessionConfigSelectionsResult {
|
|
1398
|
+
catalog: readonly SessionConfigOption[];
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Applies ACP config selections in caller order. Each successful
|
|
1402
|
+
* `session/set_config_option` response replaces the live catalog used to
|
|
1403
|
+
* validate the next selection. Invalid or rejected selections throw
|
|
1404
|
+
* {@link AcpSessionConfigError} — never silently skip or default.
|
|
1405
|
+
*/
|
|
1406
|
+
declare function applySessionConfigSelections(input: ApplySessionConfigSelectionsInput): Promise<ApplySessionConfigSelectionsResult>;
|
|
1407
|
+
|
|
1408
|
+
interface CollectedChunk {
|
|
1409
|
+
chunkType: "text" | "thought" | "tool_call" | "tool_result" | "plan";
|
|
1410
|
+
content: string;
|
|
1411
|
+
metadata: Record<string, unknown>;
|
|
1412
|
+
streamed: boolean;
|
|
1413
|
+
}
|
|
1414
|
+
interface ACPClientExtensionHandler {
|
|
1415
|
+
extensionSessionId?(): string | null;
|
|
1416
|
+
extMethod?(method: string, params: Record<string, unknown>, context: ACPClientExtensionContext): Promise<Record<string, unknown> | null>;
|
|
1417
|
+
extNotification?(method: string, params: Record<string, unknown>, context: ACPClientExtensionContext): Promise<readonly CollectedChunk[] | void>;
|
|
1418
|
+
}
|
|
1419
|
+
interface ACPClientExtensionContext {
|
|
1420
|
+
sessionId: string | null;
|
|
1421
|
+
}
|
|
1341
1422
|
interface ACPClientConnectionHandle {
|
|
1342
1423
|
connection: ClientSideConnection;
|
|
1343
1424
|
stop(): Promise<void>;
|
|
@@ -1370,8 +1451,10 @@ interface ACPConfigRequest {
|
|
|
1370
1451
|
sessionId: string;
|
|
1371
1452
|
configOptions: readonly SessionConfigOption[];
|
|
1372
1453
|
}
|
|
1373
|
-
type ACPConfigSelections =
|
|
1454
|
+
type ACPConfigSelections = ACPConfigSelections$1;
|
|
1374
1455
|
interface ACPClientAdapterBaseOptions {
|
|
1456
|
+
/** Merged into the first-turn system context (character/persona sections for examples). */
|
|
1457
|
+
customSection?: string;
|
|
1375
1458
|
cwd?: string;
|
|
1376
1459
|
env?: Record<string, string>;
|
|
1377
1460
|
mcpServers?: McpServer[];
|
|
@@ -1381,6 +1464,7 @@ interface ACPClientAdapterBaseOptions {
|
|
|
1381
1464
|
additionalMcpTools?: McpToolRegistration[];
|
|
1382
1465
|
clientCapabilities?: ClientCapabilities;
|
|
1383
1466
|
connectionFactory?: ACPClientConnectionFactory;
|
|
1467
|
+
extensionHandler?: ACPClientExtensionHandler;
|
|
1384
1468
|
resolvePermission?: (request: ACPPermissionRequest, signal: AbortSignal) => Promise<string | undefined>;
|
|
1385
1469
|
permissionTimeoutMs?: number;
|
|
1386
1470
|
turnTimeoutMs?: number;
|
|
@@ -1412,6 +1496,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1412
1496
|
private readonly additionalMcpTools;
|
|
1413
1497
|
private readonly clientCapabilities?;
|
|
1414
1498
|
private readonly connectionFactory?;
|
|
1499
|
+
private readonly extensionHandler?;
|
|
1415
1500
|
private readonly tcpEndpoint;
|
|
1416
1501
|
private readonly roomToSession;
|
|
1417
1502
|
private readonly sessionToRoom;
|
|
@@ -1430,6 +1515,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1430
1515
|
private readonly permissionTimeoutMs;
|
|
1431
1516
|
private readonly turnTimeoutMs;
|
|
1432
1517
|
private readonly logger;
|
|
1518
|
+
private readonly customSection?;
|
|
1433
1519
|
private backend;
|
|
1434
1520
|
private backendPromise;
|
|
1435
1521
|
private client;
|
|
@@ -1440,6 +1526,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1440
1526
|
private started;
|
|
1441
1527
|
private systemPrompt;
|
|
1442
1528
|
private spawnPromise;
|
|
1529
|
+
private readonly connectionRetirements;
|
|
1443
1530
|
private connectionGeneration;
|
|
1444
1531
|
constructor(options: ACPClientAdapterOptions);
|
|
1445
1532
|
onStarted(agentName: string, agentDescription: string): Promise<void>;
|
|
@@ -1448,6 +1535,18 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1448
1535
|
roomId: string;
|
|
1449
1536
|
}): Promise<void>;
|
|
1450
1537
|
private runTurn;
|
|
1538
|
+
protected onAcpTurnStarted(_message: PlatformMessage, _tools: AdapterToolsProtocol, _context: {
|
|
1539
|
+
isSessionBootstrap: boolean;
|
|
1540
|
+
roomId: string;
|
|
1541
|
+
}): Promise<void>;
|
|
1542
|
+
protected onAcpTurnFinished(_message: PlatformMessage, _tools: AdapterToolsProtocol, _context: {
|
|
1543
|
+
isSessionBootstrap: boolean;
|
|
1544
|
+
roomId: string;
|
|
1545
|
+
}): Promise<void>;
|
|
1546
|
+
protected onAcpSessionReady(_message: PlatformMessage, _tools: AdapterToolsProtocol, _context: {
|
|
1547
|
+
isSessionBootstrap: boolean;
|
|
1548
|
+
roomId: string;
|
|
1549
|
+
}, _sessionId: string): Promise<void>;
|
|
1451
1550
|
private abandonTimedOutTurn;
|
|
1452
1551
|
private withRoomTurnLock;
|
|
1453
1552
|
onCleanup(roomId: string): Promise<void>;
|
|
@@ -1458,14 +1557,19 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1458
1557
|
private nextRoomGeneration;
|
|
1459
1558
|
private isCurrentGeneration;
|
|
1460
1559
|
private raceAgainstConnectionClose;
|
|
1560
|
+
private raceAgainstConnectionRetirement;
|
|
1461
1561
|
private unlinkRoom;
|
|
1462
1562
|
private unlinkOwner;
|
|
1463
1563
|
private sessionKey;
|
|
1564
|
+
protected roomIdForSession(sessionId: string): string | undefined;
|
|
1464
1565
|
private ensureConnection;
|
|
1465
1566
|
private spawnConnection;
|
|
1466
1567
|
private getOrCreateSession;
|
|
1467
1568
|
private establishSession;
|
|
1468
1569
|
private configureSessionConfig;
|
|
1570
|
+
private abandonFailedConfigSession;
|
|
1571
|
+
private evictAbandonedSession;
|
|
1572
|
+
private retireConnection;
|
|
1469
1573
|
private linkOrAbandon;
|
|
1470
1574
|
private configureSessionMode;
|
|
1471
1575
|
private configureSessionModel;
|
|
@@ -1510,4 +1614,64 @@ declare class CopilotACPAdapter extends ACPClientAdapter {
|
|
|
1510
1614
|
constructor(options?: CopilotACPAdapterOptions);
|
|
1511
1615
|
}
|
|
1512
1616
|
|
|
1513
|
-
|
|
1617
|
+
declare const DEFAULT_CURSOR_ACP_COMMAND: readonly ["agent", "acp"];
|
|
1618
|
+
type CursorApprovalMode = "manual" | "autoAccept" | "autoDecline";
|
|
1619
|
+
type CursorQuestionMode = "manual" | "autoFirst" | "autoCancel";
|
|
1620
|
+
type CursorPlanMode = "manual" | "autoAccept" | "autoDecline";
|
|
1621
|
+
interface CursorACPAdapterOptions extends Omit<ACPClientStdioOptions, "command" | "authMethod" | "env" | "extensionHandler" | "resolvePermission"> {
|
|
1622
|
+
command?: string | string[];
|
|
1623
|
+
env?: Record<string, string>;
|
|
1624
|
+
apiKey?: string;
|
|
1625
|
+
authToken?: string;
|
|
1626
|
+
approvalMode?: CursorApprovalMode;
|
|
1627
|
+
questionMode?: CursorQuestionMode;
|
|
1628
|
+
planMode?: CursorPlanMode;
|
|
1629
|
+
decisionTimeoutMs?: number;
|
|
1630
|
+
maxPendingDecisions?: number;
|
|
1631
|
+
decisionAuthorizedSenders?: readonly string[];
|
|
1632
|
+
}
|
|
1633
|
+
declare class CursorACPAdapter extends ACPClientAdapter {
|
|
1634
|
+
protected readonly provider = "cursor-acp";
|
|
1635
|
+
private readonly approvalMode;
|
|
1636
|
+
private readonly questionMode;
|
|
1637
|
+
private readonly planMode;
|
|
1638
|
+
private readonly decisionTimeoutMs;
|
|
1639
|
+
private readonly maxPendingDecisions;
|
|
1640
|
+
private readonly authorizedSenders;
|
|
1641
|
+
private readonly decisionLogger;
|
|
1642
|
+
private readonly extensions;
|
|
1643
|
+
private readonly turns;
|
|
1644
|
+
private readonly pending;
|
|
1645
|
+
private activeTurn;
|
|
1646
|
+
private turnTail;
|
|
1647
|
+
constructor(options?: CursorACPAdapterOptions);
|
|
1648
|
+
onMessage(message: PlatformMessage, tools: AdapterToolsProtocol, history: ACPClientSessionState, participantsMessage: string | null, contactsMessage: string | null, context: {
|
|
1649
|
+
isSessionBootstrap: boolean;
|
|
1650
|
+
roomId: string;
|
|
1651
|
+
}): Promise<void>;
|
|
1652
|
+
protected onAcpTurnStarted(message: PlatformMessage, tools: AdapterToolsProtocol, context: {
|
|
1653
|
+
isSessionBootstrap: boolean;
|
|
1654
|
+
roomId: string;
|
|
1655
|
+
}): Promise<void>;
|
|
1656
|
+
protected onAcpSessionReady(message: PlatformMessage, _tools: AdapterToolsProtocol, context: {
|
|
1657
|
+
isSessionBootstrap: boolean;
|
|
1658
|
+
roomId: string;
|
|
1659
|
+
}, sessionId: string): Promise<void>;
|
|
1660
|
+
protected onAcpTurnFinished(message: PlatformMessage, _tools: AdapterToolsProtocol, context: {
|
|
1661
|
+
isSessionBootstrap: boolean;
|
|
1662
|
+
roomId: string;
|
|
1663
|
+
}): Promise<void>;
|
|
1664
|
+
onCleanup(roomId: string): Promise<void>;
|
|
1665
|
+
stop(): Promise<void>;
|
|
1666
|
+
resolveExtension(method: string, params: Record<string, unknown>, sessionId: string | null): Promise<Record<string, unknown>>;
|
|
1667
|
+
resolveCursorPermission(request: ACPPermissionRequest, signal: AbortSignal): Promise<string | undefined>;
|
|
1668
|
+
extensionSessionId(): string | null;
|
|
1669
|
+
private resolveQuestion;
|
|
1670
|
+
private resolvePlan;
|
|
1671
|
+
private waitForDecision;
|
|
1672
|
+
private handleControl;
|
|
1673
|
+
private cancelRoom;
|
|
1674
|
+
private withCursorTurnLock;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
export { OpenAIAdapter as $, A2AAdapter as A, type CopilotACPStdioOptions as B, CODEX_REASONING_EFFORTS as C, type CopilotACPTcpOptions as D, CursorACPAdapter as E, type CursorACPAdapterOptions as F, type CursorApprovalMode as G, type CursorPlanMode as H, type CursorQuestionMode as I, DEFAULT_COPILOT_ACP_COMMAND as J, DEFAULT_CURSOR_ACP_COMMAND as K, DEFAULT_OMP_ACP_COMMAND as L, FAILURE_CODE_SESSION_CONFIG as M, GeminiAdapter as N, type GeminiAdapterOptions as O, GenericAdapter as P, type GenericAdapterHandler as Q, GoogleADKAdapter as R, type GoogleADKAdapterOptions as S, LangGraphAdapter as T, type LangGraphAdapterOptions as U, type LangGraphGraph as V, LettaAdapter as W, type LettaAdapterOptions as X, MISSING_CONFIG_OPTIONS_REASON as Y, OmpACPAdapter as Z, type OmpACPAdapterOptions as _, type A2AAdapterOptions as a, type OpenAIAdapterOptions as a0, OpencodeAdapter as a1, type OpencodeAdapterConfig as a2, type OpencodeApprovalMode as a3, type OpencodeApprovalReply as a4, type OpencodeQuestionMode as a5, ParlantAdapter as a6, type ParlantAdapterOptions as a7, type ToolCallingModel as a8, VercelAISDKAdapter as a9, type LettaClientLike as aA, LettaHistoryConverter as aB, type LettaMessage as aC, type LettaMessageCreateParams as aD, type LettaMessages as aE, type LettaRequestOptions as aF, type LettaResponse as aG, type LettaResponseMessage as aH, type OpenAIClientFactory as aI, OpenAIToolCallingModel as aJ, type OpenAIToolCallingModelOptions as aK, type OpencodeClientLike as aL, type ParlantClientFactory as aM, type ParlantClientLike as aN, type ToolCall as aO, ToolCallingAdapter as aP, type ToolCallingAdapterOptions as aQ, type ToolCallingModelRequest as aR, type ToolCallingResponse as aS, type ToolResult as aT, type TurnStartParams as aU, VercelAISDKToolCallingModel as aV, type VercelAISDKToolCallingModelOptions as aW, runSingleToolRound as aX, type VercelAISDKAdapterOptions as aa, applySessionConfigSelections as ab, type A2AClientFactory as ac, type A2AClientLike as ad, type ACPPermissionAbandonReason as ae, type ACPPermissionEndReason as af, type ACPPermissionRequest as ag, type AnthropicClientFactory as ah, AnthropicToolCallingModel as ai, type AnthropicToolCallingModelOptions as aj, type ClaudeSDKQuery as ak, type ClaudeSDKQueryParams as al, CodexAppServerStdioClient as am, type CodexClientLike as an, CodexJsonRpcError as ao, type DynamicToolCallParams as ap, type DynamicToolCallResponse as aq, type DynamicToolSpec as ar, type GeminiClientFactory as as, GeminiToolCallingModel as at, type GeminiToolCallingModelOptions as au, HttpOpencodeClient as av, type HttpOpencodeClientOptions as aw, HttpStatusError as ax, type LettaAgentCreateParams as ay, type LettaClientFactory as az, A2AGatewayAdapter as b, ACPClientAdapter as c, type ACPClientAdapterBaseOptions as d, type ACPClientAdapterOptions as e, type ACPClientStdioOptions as f, type ACPClientTcpOptions as g, type ACPConfigRequest as h, type ACPConfigSelections as i, AcpSessionConfigError as j, AnthropicAdapter as k, type AnthropicAdapterOptions as l, CODEX_REASONING_SUMMARIES as m, CODEX_WEB_SEARCH_MODES as n, type ClaudePermissionMode as o, ClaudeSDKAdapter as p, type ClaudeSDKAdapterOptions as q, CodexAdapter as r, type CodexAdapterConfig as s, type CodexApprovalPolicy as t, type CodexReasoningEffort as u, type CodexReasoningSummary as v, type CodexSandboxMode as w, type CodexWebSearchMode as x, CopilotACPAdapter as y, type CopilotACPAdapterOptions as z };
|
|
@@ -7,7 +7,8 @@ import { m as ToolModelMessage, n as ToolModelSchema, M as MetadataMap } from '.
|
|
|
7
7
|
import { u as GoogleADKMessages, s as GoogleADKHistoryConverter, e as A2ASessionState, A as A2AAuth, G as GatewaySessionState, a as A2AGatewayAdapterOptions, n as ParlantMessages, P as ParlantHistoryConverter, C as ChatTurn, v as OpencodeSessionState, O as OpencodeHistoryConverter, r as ACPClientSessionState } from './acp-client-D-I_5lK-.cjs';
|
|
8
8
|
import { c as createBandMcpBackend } from './backends-Dh2WXcHQ.cjs';
|
|
9
9
|
import { M as McpToolRegistration } from './sdk-CXNqzoY1.cjs';
|
|
10
|
-
import { Client, ClientSideConnection, RequestPermissionRequest, McpServer, ClientCapabilities, SessionMode,
|
|
10
|
+
import { SessionConfigOption, Client, ClientSideConnection, RequestPermissionRequest, McpServer, ClientCapabilities, SessionMode, SessionConfigSelectOption } from '@agentclientprotocol/sdk';
|
|
11
|
+
import { AgentFailure } from '@band-ai/band-sdk-core';
|
|
11
12
|
|
|
12
13
|
type GenericAdapterHandler = (args: {
|
|
13
14
|
message: PlatformMessage;
|
|
@@ -1338,6 +1339,86 @@ declare class ClaudeSDKAdapter extends SimpleAdapter<HistoryProvider, AdapterToo
|
|
|
1338
1339
|
private reportSessionId;
|
|
1339
1340
|
}
|
|
1340
1341
|
|
|
1342
|
+
/** Structured Band failure code when an ACP session config selection cannot be applied. */
|
|
1343
|
+
declare const FAILURE_CODE_SESSION_CONFIG = "session_config";
|
|
1344
|
+
/** Reason when a successful setter omits an array `configOptions` catalog. */
|
|
1345
|
+
declare const MISSING_CONFIG_OPTIONS_REASON = "missing_config_options";
|
|
1346
|
+
interface ACPConfigSelection {
|
|
1347
|
+
configId: string;
|
|
1348
|
+
value: string | undefined;
|
|
1349
|
+
}
|
|
1350
|
+
/**
|
|
1351
|
+
* Session configuration selected by a caller. Use an array when the order is
|
|
1352
|
+
* significant: JavaScript object enumeration sorts array-index property names.
|
|
1353
|
+
* The record form remains supported for existing callers.
|
|
1354
|
+
*/
|
|
1355
|
+
type ACPConfigSelections$1 = readonly ACPConfigSelection[] | Readonly<Record<string, string | undefined>>;
|
|
1356
|
+
/**
|
|
1357
|
+
* Deterministic failure applying ACP session configuration. Carries provider,
|
|
1358
|
+
* option id, and optional ACP JSON-RPC code so callers can report a structured
|
|
1359
|
+
* Band failure instead of silently skipping the selection.
|
|
1360
|
+
*/
|
|
1361
|
+
declare class AcpSessionConfigError extends Error {
|
|
1362
|
+
readonly provider: string;
|
|
1363
|
+
readonly sessionId: string;
|
|
1364
|
+
readonly optionId: string;
|
|
1365
|
+
readonly selectedValue: string | undefined;
|
|
1366
|
+
readonly acpCode: number | undefined;
|
|
1367
|
+
readonly detail: unknown;
|
|
1368
|
+
readonly timedOut: boolean;
|
|
1369
|
+
constructor(input: {
|
|
1370
|
+
provider: string;
|
|
1371
|
+
sessionId: string;
|
|
1372
|
+
optionId: string;
|
|
1373
|
+
message: string;
|
|
1374
|
+
selectedValue?: string;
|
|
1375
|
+
acpCode?: number;
|
|
1376
|
+
detail?: unknown;
|
|
1377
|
+
cause?: unknown;
|
|
1378
|
+
timedOut?: boolean;
|
|
1379
|
+
});
|
|
1380
|
+
toAgentFailure(): AgentFailure;
|
|
1381
|
+
}
|
|
1382
|
+
type SessionConfigOptionSetter = (params: {
|
|
1383
|
+
sessionId: string;
|
|
1384
|
+
configId: string;
|
|
1385
|
+
value: string;
|
|
1386
|
+
}) => Promise<{
|
|
1387
|
+
configOptions?: readonly SessionConfigOption[] | null;
|
|
1388
|
+
}>;
|
|
1389
|
+
interface ApplySessionConfigSelectionsInput {
|
|
1390
|
+
provider: string;
|
|
1391
|
+
sessionId: string;
|
|
1392
|
+
catalog: readonly SessionConfigOption[];
|
|
1393
|
+
selections: ACPConfigSelections$1;
|
|
1394
|
+
setOption: SessionConfigOptionSetter;
|
|
1395
|
+
timeoutMs: number;
|
|
1396
|
+
}
|
|
1397
|
+
interface ApplySessionConfigSelectionsResult {
|
|
1398
|
+
catalog: readonly SessionConfigOption[];
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Applies ACP config selections in caller order. Each successful
|
|
1402
|
+
* `session/set_config_option` response replaces the live catalog used to
|
|
1403
|
+
* validate the next selection. Invalid or rejected selections throw
|
|
1404
|
+
* {@link AcpSessionConfigError} — never silently skip or default.
|
|
1405
|
+
*/
|
|
1406
|
+
declare function applySessionConfigSelections(input: ApplySessionConfigSelectionsInput): Promise<ApplySessionConfigSelectionsResult>;
|
|
1407
|
+
|
|
1408
|
+
interface CollectedChunk {
|
|
1409
|
+
chunkType: "text" | "thought" | "tool_call" | "tool_result" | "plan";
|
|
1410
|
+
content: string;
|
|
1411
|
+
metadata: Record<string, unknown>;
|
|
1412
|
+
streamed: boolean;
|
|
1413
|
+
}
|
|
1414
|
+
interface ACPClientExtensionHandler {
|
|
1415
|
+
extensionSessionId?(): string | null;
|
|
1416
|
+
extMethod?(method: string, params: Record<string, unknown>, context: ACPClientExtensionContext): Promise<Record<string, unknown> | null>;
|
|
1417
|
+
extNotification?(method: string, params: Record<string, unknown>, context: ACPClientExtensionContext): Promise<readonly CollectedChunk[] | void>;
|
|
1418
|
+
}
|
|
1419
|
+
interface ACPClientExtensionContext {
|
|
1420
|
+
sessionId: string | null;
|
|
1421
|
+
}
|
|
1341
1422
|
interface ACPClientConnectionHandle {
|
|
1342
1423
|
connection: ClientSideConnection;
|
|
1343
1424
|
stop(): Promise<void>;
|
|
@@ -1370,8 +1451,10 @@ interface ACPConfigRequest {
|
|
|
1370
1451
|
sessionId: string;
|
|
1371
1452
|
configOptions: readonly SessionConfigOption[];
|
|
1372
1453
|
}
|
|
1373
|
-
type ACPConfigSelections =
|
|
1454
|
+
type ACPConfigSelections = ACPConfigSelections$1;
|
|
1374
1455
|
interface ACPClientAdapterBaseOptions {
|
|
1456
|
+
/** Merged into the first-turn system context (character/persona sections for examples). */
|
|
1457
|
+
customSection?: string;
|
|
1375
1458
|
cwd?: string;
|
|
1376
1459
|
env?: Record<string, string>;
|
|
1377
1460
|
mcpServers?: McpServer[];
|
|
@@ -1381,6 +1464,7 @@ interface ACPClientAdapterBaseOptions {
|
|
|
1381
1464
|
additionalMcpTools?: McpToolRegistration[];
|
|
1382
1465
|
clientCapabilities?: ClientCapabilities;
|
|
1383
1466
|
connectionFactory?: ACPClientConnectionFactory;
|
|
1467
|
+
extensionHandler?: ACPClientExtensionHandler;
|
|
1384
1468
|
resolvePermission?: (request: ACPPermissionRequest, signal: AbortSignal) => Promise<string | undefined>;
|
|
1385
1469
|
permissionTimeoutMs?: number;
|
|
1386
1470
|
turnTimeoutMs?: number;
|
|
@@ -1412,6 +1496,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1412
1496
|
private readonly additionalMcpTools;
|
|
1413
1497
|
private readonly clientCapabilities?;
|
|
1414
1498
|
private readonly connectionFactory?;
|
|
1499
|
+
private readonly extensionHandler?;
|
|
1415
1500
|
private readonly tcpEndpoint;
|
|
1416
1501
|
private readonly roomToSession;
|
|
1417
1502
|
private readonly sessionToRoom;
|
|
@@ -1430,6 +1515,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1430
1515
|
private readonly permissionTimeoutMs;
|
|
1431
1516
|
private readonly turnTimeoutMs;
|
|
1432
1517
|
private readonly logger;
|
|
1518
|
+
private readonly customSection?;
|
|
1433
1519
|
private backend;
|
|
1434
1520
|
private backendPromise;
|
|
1435
1521
|
private client;
|
|
@@ -1440,6 +1526,7 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1440
1526
|
private started;
|
|
1441
1527
|
private systemPrompt;
|
|
1442
1528
|
private spawnPromise;
|
|
1529
|
+
private readonly connectionRetirements;
|
|
1443
1530
|
private connectionGeneration;
|
|
1444
1531
|
constructor(options: ACPClientAdapterOptions);
|
|
1445
1532
|
onStarted(agentName: string, agentDescription: string): Promise<void>;
|
|
@@ -1448,6 +1535,18 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1448
1535
|
roomId: string;
|
|
1449
1536
|
}): Promise<void>;
|
|
1450
1537
|
private runTurn;
|
|
1538
|
+
protected onAcpTurnStarted(_message: PlatformMessage, _tools: AdapterToolsProtocol, _context: {
|
|
1539
|
+
isSessionBootstrap: boolean;
|
|
1540
|
+
roomId: string;
|
|
1541
|
+
}): Promise<void>;
|
|
1542
|
+
protected onAcpTurnFinished(_message: PlatformMessage, _tools: AdapterToolsProtocol, _context: {
|
|
1543
|
+
isSessionBootstrap: boolean;
|
|
1544
|
+
roomId: string;
|
|
1545
|
+
}): Promise<void>;
|
|
1546
|
+
protected onAcpSessionReady(_message: PlatformMessage, _tools: AdapterToolsProtocol, _context: {
|
|
1547
|
+
isSessionBootstrap: boolean;
|
|
1548
|
+
roomId: string;
|
|
1549
|
+
}, _sessionId: string): Promise<void>;
|
|
1451
1550
|
private abandonTimedOutTurn;
|
|
1452
1551
|
private withRoomTurnLock;
|
|
1453
1552
|
onCleanup(roomId: string): Promise<void>;
|
|
@@ -1458,14 +1557,19 @@ declare class ACPClientAdapter extends SimpleAdapter<ACPClientSessionState, Adap
|
|
|
1458
1557
|
private nextRoomGeneration;
|
|
1459
1558
|
private isCurrentGeneration;
|
|
1460
1559
|
private raceAgainstConnectionClose;
|
|
1560
|
+
private raceAgainstConnectionRetirement;
|
|
1461
1561
|
private unlinkRoom;
|
|
1462
1562
|
private unlinkOwner;
|
|
1463
1563
|
private sessionKey;
|
|
1564
|
+
protected roomIdForSession(sessionId: string): string | undefined;
|
|
1464
1565
|
private ensureConnection;
|
|
1465
1566
|
private spawnConnection;
|
|
1466
1567
|
private getOrCreateSession;
|
|
1467
1568
|
private establishSession;
|
|
1468
1569
|
private configureSessionConfig;
|
|
1570
|
+
private abandonFailedConfigSession;
|
|
1571
|
+
private evictAbandonedSession;
|
|
1572
|
+
private retireConnection;
|
|
1469
1573
|
private linkOrAbandon;
|
|
1470
1574
|
private configureSessionMode;
|
|
1471
1575
|
private configureSessionModel;
|
|
@@ -1510,4 +1614,64 @@ declare class CopilotACPAdapter extends ACPClientAdapter {
|
|
|
1510
1614
|
constructor(options?: CopilotACPAdapterOptions);
|
|
1511
1615
|
}
|
|
1512
1616
|
|
|
1513
|
-
|
|
1617
|
+
declare const DEFAULT_CURSOR_ACP_COMMAND: readonly ["agent", "acp"];
|
|
1618
|
+
type CursorApprovalMode = "manual" | "autoAccept" | "autoDecline";
|
|
1619
|
+
type CursorQuestionMode = "manual" | "autoFirst" | "autoCancel";
|
|
1620
|
+
type CursorPlanMode = "manual" | "autoAccept" | "autoDecline";
|
|
1621
|
+
interface CursorACPAdapterOptions extends Omit<ACPClientStdioOptions, "command" | "authMethod" | "env" | "extensionHandler" | "resolvePermission"> {
|
|
1622
|
+
command?: string | string[];
|
|
1623
|
+
env?: Record<string, string>;
|
|
1624
|
+
apiKey?: string;
|
|
1625
|
+
authToken?: string;
|
|
1626
|
+
approvalMode?: CursorApprovalMode;
|
|
1627
|
+
questionMode?: CursorQuestionMode;
|
|
1628
|
+
planMode?: CursorPlanMode;
|
|
1629
|
+
decisionTimeoutMs?: number;
|
|
1630
|
+
maxPendingDecisions?: number;
|
|
1631
|
+
decisionAuthorizedSenders?: readonly string[];
|
|
1632
|
+
}
|
|
1633
|
+
declare class CursorACPAdapter extends ACPClientAdapter {
|
|
1634
|
+
protected readonly provider = "cursor-acp";
|
|
1635
|
+
private readonly approvalMode;
|
|
1636
|
+
private readonly questionMode;
|
|
1637
|
+
private readonly planMode;
|
|
1638
|
+
private readonly decisionTimeoutMs;
|
|
1639
|
+
private readonly maxPendingDecisions;
|
|
1640
|
+
private readonly authorizedSenders;
|
|
1641
|
+
private readonly decisionLogger;
|
|
1642
|
+
private readonly extensions;
|
|
1643
|
+
private readonly turns;
|
|
1644
|
+
private readonly pending;
|
|
1645
|
+
private activeTurn;
|
|
1646
|
+
private turnTail;
|
|
1647
|
+
constructor(options?: CursorACPAdapterOptions);
|
|
1648
|
+
onMessage(message: PlatformMessage, tools: AdapterToolsProtocol, history: ACPClientSessionState, participantsMessage: string | null, contactsMessage: string | null, context: {
|
|
1649
|
+
isSessionBootstrap: boolean;
|
|
1650
|
+
roomId: string;
|
|
1651
|
+
}): Promise<void>;
|
|
1652
|
+
protected onAcpTurnStarted(message: PlatformMessage, tools: AdapterToolsProtocol, context: {
|
|
1653
|
+
isSessionBootstrap: boolean;
|
|
1654
|
+
roomId: string;
|
|
1655
|
+
}): Promise<void>;
|
|
1656
|
+
protected onAcpSessionReady(message: PlatformMessage, _tools: AdapterToolsProtocol, context: {
|
|
1657
|
+
isSessionBootstrap: boolean;
|
|
1658
|
+
roomId: string;
|
|
1659
|
+
}, sessionId: string): Promise<void>;
|
|
1660
|
+
protected onAcpTurnFinished(message: PlatformMessage, _tools: AdapterToolsProtocol, context: {
|
|
1661
|
+
isSessionBootstrap: boolean;
|
|
1662
|
+
roomId: string;
|
|
1663
|
+
}): Promise<void>;
|
|
1664
|
+
onCleanup(roomId: string): Promise<void>;
|
|
1665
|
+
stop(): Promise<void>;
|
|
1666
|
+
resolveExtension(method: string, params: Record<string, unknown>, sessionId: string | null): Promise<Record<string, unknown>>;
|
|
1667
|
+
resolveCursorPermission(request: ACPPermissionRequest, signal: AbortSignal): Promise<string | undefined>;
|
|
1668
|
+
extensionSessionId(): string | null;
|
|
1669
|
+
private resolveQuestion;
|
|
1670
|
+
private resolvePlan;
|
|
1671
|
+
private waitForDecision;
|
|
1672
|
+
private handleControl;
|
|
1673
|
+
private cancelRoom;
|
|
1674
|
+
private withCursorTurnLock;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
export { OpenAIAdapter as $, A2AAdapter as A, type CopilotACPStdioOptions as B, CODEX_REASONING_EFFORTS as C, type CopilotACPTcpOptions as D, CursorACPAdapter as E, type CursorACPAdapterOptions as F, type CursorApprovalMode as G, type CursorPlanMode as H, type CursorQuestionMode as I, DEFAULT_COPILOT_ACP_COMMAND as J, DEFAULT_CURSOR_ACP_COMMAND as K, DEFAULT_OMP_ACP_COMMAND as L, FAILURE_CODE_SESSION_CONFIG as M, GeminiAdapter as N, type GeminiAdapterOptions as O, GenericAdapter as P, type GenericAdapterHandler as Q, GoogleADKAdapter as R, type GoogleADKAdapterOptions as S, LangGraphAdapter as T, type LangGraphAdapterOptions as U, type LangGraphGraph as V, LettaAdapter as W, type LettaAdapterOptions as X, MISSING_CONFIG_OPTIONS_REASON as Y, OmpACPAdapter as Z, type OmpACPAdapterOptions as _, type A2AAdapterOptions as a, type OpenAIAdapterOptions as a0, OpencodeAdapter as a1, type OpencodeAdapterConfig as a2, type OpencodeApprovalMode as a3, type OpencodeApprovalReply as a4, type OpencodeQuestionMode as a5, ParlantAdapter as a6, type ParlantAdapterOptions as a7, type ToolCallingModel as a8, VercelAISDKAdapter as a9, type LettaClientLike as aA, LettaHistoryConverter as aB, type LettaMessage as aC, type LettaMessageCreateParams as aD, type LettaMessages as aE, type LettaRequestOptions as aF, type LettaResponse as aG, type LettaResponseMessage as aH, type OpenAIClientFactory as aI, OpenAIToolCallingModel as aJ, type OpenAIToolCallingModelOptions as aK, type OpencodeClientLike as aL, type ParlantClientFactory as aM, type ParlantClientLike as aN, type ToolCall as aO, ToolCallingAdapter as aP, type ToolCallingAdapterOptions as aQ, type ToolCallingModelRequest as aR, type ToolCallingResponse as aS, type ToolResult as aT, type TurnStartParams as aU, VercelAISDKToolCallingModel as aV, type VercelAISDKToolCallingModelOptions as aW, runSingleToolRound as aX, type VercelAISDKAdapterOptions as aa, applySessionConfigSelections as ab, type A2AClientFactory as ac, type A2AClientLike as ad, type ACPPermissionAbandonReason as ae, type ACPPermissionEndReason as af, type ACPPermissionRequest as ag, type AnthropicClientFactory as ah, AnthropicToolCallingModel as ai, type AnthropicToolCallingModelOptions as aj, type ClaudeSDKQuery as ak, type ClaudeSDKQueryParams as al, CodexAppServerStdioClient as am, type CodexClientLike as an, CodexJsonRpcError as ao, type DynamicToolCallParams as ap, type DynamicToolCallResponse as aq, type DynamicToolSpec as ar, type GeminiClientFactory as as, GeminiToolCallingModel as at, type GeminiToolCallingModelOptions as au, HttpOpencodeClient as av, type HttpOpencodeClientOptions as aw, HttpStatusError as ax, type LettaAgentCreateParams as ay, type LettaClientFactory as az, A2AGatewayAdapter as b, ACPClientAdapter as c, type ACPClientAdapterBaseOptions as d, type ACPClientAdapterOptions as e, type ACPClientStdioOptions as f, type ACPClientTcpOptions as g, type ACPConfigRequest as h, type ACPConfigSelections as i, AcpSessionConfigError as j, AnthropicAdapter as k, type AnthropicAdapterOptions as l, CODEX_REASONING_SUMMARIES as m, CODEX_WEB_SEARCH_MODES as n, type ClaudePermissionMode as o, ClaudeSDKAdapter as p, type ClaudeSDKAdapterOptions as q, CodexAdapter as r, type CodexAdapterConfig as s, type CodexApprovalPolicy as t, type CodexReasoningEffort as u, type CodexReasoningSummary as v, type CodexSandboxMode as w, type CodexWebSearchMode as x, CopilotACPAdapter as y, type CopilotACPAdapterOptions as z };
|