@pwrdrvr/agent-acp 0.12.3 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +71 -17
- package/dist/index.js +243 -159
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client } from '@agentclientprotocol/sdk';
|
|
1
|
+
import { Client, McpServer } from '@agentclientprotocol/sdk';
|
|
2
2
|
import { Logger, AgentBackend, NormalizedThreadEvent, Unsubscribe, AgentBackendToolCallHandler, AgentBackendApprovalHandler, AgentStartThreadOptions, AgentBackendStartThreadResult, AgentStartTurnOptions, NormalizedTokenUsage, NormalizedToolCall } from '@pwrdrvr/agent-core';
|
|
3
3
|
import { JsonRpcId } from '@pwrdrvr/agent-transport';
|
|
4
4
|
|
|
@@ -24,8 +24,8 @@ interface AcpAgentConnection {
|
|
|
24
24
|
setSessionMode(params: Record<string, unknown>): Promise<unknown>;
|
|
25
25
|
setSessionModel(params: Record<string, unknown>): Promise<unknown>;
|
|
26
26
|
authenticate(params: Record<string, unknown>): Promise<unknown>;
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
request(method: string, params: Record<string, unknown>): Promise<unknown>;
|
|
28
|
+
notify(method: string, params: Record<string, unknown>): Promise<void>;
|
|
29
29
|
}
|
|
30
30
|
/** Built connection + a teardown handle (kills the child / closes streams). */
|
|
31
31
|
type AcpAgentConnectionHandle = {
|
|
@@ -178,8 +178,13 @@ type AcpRuntimeAgentInfo = {
|
|
|
178
178
|
title?: string;
|
|
179
179
|
version?: string;
|
|
180
180
|
};
|
|
181
|
+
type AcpRuntimeMcpCapabilities = {
|
|
182
|
+
http?: boolean;
|
|
183
|
+
sse?: boolean;
|
|
184
|
+
};
|
|
181
185
|
type AcpRuntimeAgentCapabilities = {
|
|
182
186
|
loadSession?: boolean;
|
|
187
|
+
mcp?: AcpRuntimeMcpCapabilities;
|
|
183
188
|
sessionHistoryReplay?: boolean;
|
|
184
189
|
session?: {
|
|
185
190
|
close?: boolean;
|
|
@@ -212,6 +217,10 @@ declare function normalizeAcpRuntimeCapabilities(params: {
|
|
|
212
217
|
initialize?: AcpRuntimeCapabilities;
|
|
213
218
|
}): AcpRuntimeCapabilities | undefined;
|
|
214
219
|
declare function acpRuntimeSupportsSessionLoad(capabilities: AcpRuntimeCapabilities | undefined): boolean;
|
|
220
|
+
/** Optional ACP MCP transports are supported only when explicitly advertised. */
|
|
221
|
+
declare function acpRuntimeSupportsHttpMcp(capabilities: AcpRuntimeCapabilities | undefined): boolean;
|
|
222
|
+
/** Optional ACP MCP transports are supported only when explicitly advertised. */
|
|
223
|
+
declare function acpRuntimeSupportsSseMcp(capabilities: AcpRuntimeCapabilities | undefined): boolean;
|
|
215
224
|
/** The configOption an agent uses to expose model choice (ACP `category:
|
|
216
225
|
* "model"`, falling back to a literal `model` id). Some agents (e.g. Kimi)
|
|
217
226
|
* advertise the active model HERE rather than via top-level
|
|
@@ -235,6 +244,43 @@ declare function mergeAcpRuntimeState(existing: AcpSessionRuntimeState | undefin
|
|
|
235
244
|
/** Resolve the human-facing label for a mode id from the capabilities snapshot. */
|
|
236
245
|
declare function modeLabelFor(capabilities: AcpRuntimeCapabilities | undefined, modeId: string): string | undefined;
|
|
237
246
|
|
|
247
|
+
/** ACP key/value entry used by stdio environments and HTTP headers. */
|
|
248
|
+
type AcpMcpKeyValue = {
|
|
249
|
+
name: string;
|
|
250
|
+
value: string;
|
|
251
|
+
};
|
|
252
|
+
/** Host-friendly collection accepted wherever ACP requires key/value entries. */
|
|
253
|
+
type AcpMcpKeyValueCollection = Readonly<Record<string, string>> | readonly AcpMcpKeyValue[];
|
|
254
|
+
/** Backward-compatible stdio MCP configuration. ACP stdio has no `type` field. */
|
|
255
|
+
type AcpStdioMcpServerConfig = {
|
|
256
|
+
name: string;
|
|
257
|
+
command: string;
|
|
258
|
+
args?: readonly string[];
|
|
259
|
+
env?: AcpMcpKeyValueCollection;
|
|
260
|
+
};
|
|
261
|
+
/** Streamable HTTP MCP configuration from the ACP v1 schema. */
|
|
262
|
+
type AcpHttpMcpServerConfig = {
|
|
263
|
+
name: string;
|
|
264
|
+
type: "http";
|
|
265
|
+
url: string;
|
|
266
|
+
headers: AcpMcpKeyValueCollection;
|
|
267
|
+
};
|
|
268
|
+
/** Legacy HTTP+SSE MCP configuration from the ACP v1 schema. */
|
|
269
|
+
type AcpSseMcpServerConfig = {
|
|
270
|
+
name: string;
|
|
271
|
+
type: "sse";
|
|
272
|
+
url: string;
|
|
273
|
+
headers: AcpMcpKeyValueCollection;
|
|
274
|
+
};
|
|
275
|
+
/** Public MCP input accepted by agent-acp session lifecycle methods. */
|
|
276
|
+
type AcpMcpServerConfig = AcpStdioMcpServerConfig | AcpHttpMcpServerConfig | AcpSseMcpServerConfig;
|
|
277
|
+
/** Exact MCP server wire union from the pinned ACP protocol library. */
|
|
278
|
+
type AcpMcpServerWireConfig = McpServer;
|
|
279
|
+
/** Serialize a host-friendly config into the exact ACP v1 wire representation. */
|
|
280
|
+
declare function normalizeAcpMcpServerConfig(server: AcpMcpServerConfig): AcpMcpServerWireConfig;
|
|
281
|
+
/** Serialize a per-session list without retaining mutable caller collections. */
|
|
282
|
+
declare function normalizeAcpMcpServerConfigs(servers: readonly AcpMcpServerConfig[]): AcpMcpServerWireConfig[];
|
|
283
|
+
|
|
238
284
|
type AcpPromptContentBlock = {
|
|
239
285
|
type: "text";
|
|
240
286
|
text: string;
|
|
@@ -243,12 +289,6 @@ type AcpPromptContentBlock = {
|
|
|
243
289
|
mimeType: string;
|
|
244
290
|
data: string;
|
|
245
291
|
};
|
|
246
|
-
type AcpMcpServerConfig = {
|
|
247
|
-
name: string;
|
|
248
|
-
command: string;
|
|
249
|
-
args?: string[];
|
|
250
|
-
env?: Record<string, string>;
|
|
251
|
-
};
|
|
252
292
|
type AcpRuntimeOptionSource = "mode" | "model" | "configOption";
|
|
253
293
|
type AcpAgentClientOptions = {
|
|
254
294
|
/** The transport (real stdio or a fake). */
|
|
@@ -262,7 +302,7 @@ type AcpAgentClientOptions = {
|
|
|
262
302
|
/** Default cwd for `session/new` when `startThread` omits one. */
|
|
263
303
|
cwd?: string;
|
|
264
304
|
/** MCP servers to attach at `session/new` / `session/load`. */
|
|
265
|
-
mcpServers?: AcpMcpServerConfig[];
|
|
305
|
+
mcpServers?: readonly AcpMcpServerConfig[];
|
|
266
306
|
now?: () => number;
|
|
267
307
|
logger?: Logger;
|
|
268
308
|
};
|
|
@@ -274,7 +314,15 @@ type AcpAgentClientOptions = {
|
|
|
274
314
|
type AcpStartThreadOptions = {
|
|
275
315
|
/** Working directory for the agent session. */
|
|
276
316
|
cwd?: string;
|
|
277
|
-
mcpServers?: AcpMcpServerConfig[];
|
|
317
|
+
mcpServers?: readonly AcpMcpServerConfig[];
|
|
318
|
+
};
|
|
319
|
+
/** ACP-native `session/load` options. The protocol session id is the id the
|
|
320
|
+
* agent persisted; `threadId` optionally preserves a separate host-facing id. */
|
|
321
|
+
type AcpLoadThreadOptions = {
|
|
322
|
+
sessionId: string;
|
|
323
|
+
threadId?: string;
|
|
324
|
+
cwd?: string;
|
|
325
|
+
mcpServers?: readonly AcpMcpServerConfig[];
|
|
278
326
|
};
|
|
279
327
|
/** ACP-NATIVE turn/start options. Internal mapping target; the public `startTurn`
|
|
280
328
|
* takes neutral `AgentStartTurnOptions`. */
|
|
@@ -343,6 +391,10 @@ declare class AcpAgentClient implements AgentBackend {
|
|
|
343
391
|
* mapping cwd + dropping Codex-only fields. Exposed for hosts that need
|
|
344
392
|
* ACP-specific control (per-thread `mcpServers`). */
|
|
345
393
|
startThreadNative(options?: AcpStartThreadOptions): Promise<AgentBackendStartThreadResult>;
|
|
394
|
+
/** ACP-native `session/load`. The pinned ACP v1 library has no separate
|
|
395
|
+
* `session/resume` method; loading is the protocol-defined history restore
|
|
396
|
+
* path and receives the same per-thread MCP configuration as `session/new`. */
|
|
397
|
+
loadThreadNative(options: AcpLoadThreadOptions): Promise<AgentBackendStartThreadResult>;
|
|
346
398
|
/**
|
|
347
399
|
* Re-establish a fresh ACP session for a PERSISTED thread id whose underlying
|
|
348
400
|
* session is gone (e.g. resuming a chat after an app restart — the agent
|
|
@@ -362,7 +414,7 @@ declare class AcpAgentClient implements AgentBackend {
|
|
|
362
414
|
* surfaces with different tool sets (library vs sizzle): each surface
|
|
363
415
|
* passes its own servers, so its threads spawn its tools — overriding the
|
|
364
416
|
* client-level default. */
|
|
365
|
-
mcpServers?: AcpMcpServerConfig[];
|
|
417
|
+
mcpServers?: readonly AcpMcpServerConfig[];
|
|
366
418
|
}): Promise<void>;
|
|
367
419
|
/**
|
|
368
420
|
* Mint a thread id WITHOUT spawning the agent or opening a session. The
|
|
@@ -383,6 +435,7 @@ declare class AcpAgentClient implements AgentBackend {
|
|
|
383
435
|
* `bindThreadId` is given (resume), in which case the new ACP session is
|
|
384
436
|
* bound to that existing host thread id. */
|
|
385
437
|
private establishSession;
|
|
438
|
+
private openSession;
|
|
386
439
|
/**
|
|
387
440
|
* Public `AgentBackend.startTurn`: accepts NEUTRAL `AgentStartTurnOptions` and
|
|
388
441
|
* maps them onto ACP prompt content blocks — a leading `text` block from
|
|
@@ -423,10 +476,6 @@ declare class AcpAgentClient implements AgentBackend {
|
|
|
423
476
|
private handleNotification;
|
|
424
477
|
private applySessionUpdate;
|
|
425
478
|
private handleAcpRequest;
|
|
426
|
-
/** Every MCP server name this client knows about — the client-level default
|
|
427
|
-
* plus the per-thread servers of every live session. Used to auto-approve a
|
|
428
|
-
* configured MCP tool regardless of which session's permission request it is. */
|
|
429
|
-
private knownMcpServerNames;
|
|
430
479
|
private handlePermissionRequest;
|
|
431
480
|
private setRuntimeOption;
|
|
432
481
|
private setRuntimeOptionOnTransport;
|
|
@@ -448,8 +497,13 @@ declare class AcpAgentClient implements AgentBackend {
|
|
|
448
497
|
private notifyRuntimeCapabilities;
|
|
449
498
|
private emitThreadSettings;
|
|
450
499
|
private requireSession;
|
|
500
|
+
private assertMcpTransportSupport;
|
|
451
501
|
/** Whether the agent advertises session/load support (for hosts that resume). */
|
|
452
502
|
supportsSessionLoad(): boolean;
|
|
503
|
+
/** Whether the initialize result explicitly advertises streamable HTTP MCP. */
|
|
504
|
+
supportsHttpMcp(): boolean;
|
|
505
|
+
/** Whether the initialize result explicitly advertises legacy HTTP+SSE MCP. */
|
|
506
|
+
supportsSseMcp(): boolean;
|
|
453
507
|
}
|
|
454
508
|
/** Pick the value to set on a "thinking" config option for a neutral reasoning
|
|
455
509
|
* token: low-effort → the OFF-like value, high-effort → the ON-like value.
|
|
@@ -820,4 +874,4 @@ declare class AcpRegistryService {
|
|
|
820
874
|
declare function evaluateAcpDistributionPolicy(distribution: AcpRegistryDistribution, allowlist: AcpAllowlistDecision): AcpDistributionPolicy;
|
|
821
875
|
declare function normalizeRegistry(raw: unknown): AcpRegistryAgent[];
|
|
822
876
|
|
|
823
|
-
export { ACP_REGISTRY_URL, AcpAgentAllowlist, type AcpAgentAllowlistRule, AcpAgentClient, type AcpAgentClientFactory, type AcpAgentClientOptions, AcpAgentClientPool, type AcpAgentClientPoolOptions, type AcpAgentConnection, type AcpAgentConnectionHandle, type AcpAgentInstanceSource, type AcpAgentQuirks, type AcpAgentStrategy, type AcpAllowlistDecision, type AcpApplyContext, type AcpBinaryPlatformDistribution, AcpConnection, type AcpConnectionOptions, type AcpDiscoveryProbe, type AcpDistributionKind, type AcpDistributionPolicy, type AcpJsonRpcTransport, type AcpMcpServerConfig, type AcpNormalizeResult, type AcpNormalizerOptions, AcpOneShotClient, type AcpOneShotClientOptions, type AcpOneShotRequest, type AcpOneShotResponse, type AcpPackageDistribution, type AcpPathExecutableLister, type AcpPromptContentBlock, type AcpRegistryAgent, type AcpRegistryAgentWithPolicy, type AcpRegistryAuthDescriptor, type AcpRegistryAuthMethod, type AcpRegistryDistribution, type AcpRegistryFetch, AcpRegistryService, type AcpRegistryServiceOptions, type AcpRegistrySnapshot, type AcpRuntimeAgentCapabilities, type AcpRuntimeAgentInfo, type AcpRuntimeCapabilities, type AcpRuntimeCapabilitiesHandler, type AcpRuntimeCapabilitiesSource, type AcpRuntimeConfigOption, type AcpRuntimeConfigOptionValue, type AcpRuntimeMode, type AcpRuntimeModel, type AcpRuntimeModels, type AcpRuntimeModes, type AcpRuntimeOptionSource, AcpSessionNormalizer, type AcpSessionRuntimeState, type AcpSpawnSpec, type AcpStartThreadOptions, type AcpStartTurnOptions, type AcpTitleHandler, type AcpVerificationStatus, BANNED_ACP_REGISTRY_IDS, BUILT_IN_ACP_STRATEGIES, DEFAULT_ACP_AGENT_ALLOWLIST, type DiscoveredAcpAgent, type DiscoveredAcpAgentGroup, type DiscoveredAcpAgentInstance, type LocalAcpAgentProbe, type LocalAcpDiscoveryOptions, type LocalAcpProbeResult, acpRuntimeSupportsSessionLoad, acpSessionRuntimeStateFromCapabilities, acpSessionRuntimeStateFromUpdate, asRecord, buildAcpBackendId, buildStrategyTable, defaultAcpAgentAllowlist, defaultQuirks, discoverLocalAcpAgentInstances, discoverLocalAcpAgents, evaluateAcpDistributionPolicy, geminiStrategy, grokStrategy, isBannedAcpRegistryId, kimiStrategy, mergeAcpRuntimeState, modeLabelFor, modelConfigOption, modelIdFromCapabilities, modelsFromCapabilities, normalizeAcpRuntimeCapabilities, normalizeRegistry, qwenStrategy, readAcpContentText, readBoolean, readContentText, readFirstLocationPath, readFirstString, readKind, readNonEmptyString, readNumber, readPromptText, readString, readToolCallId, readToolContentText, readToolOutput, readUpdateText, reasoningValueForThoughtLevel, strategyByBackendId, strategyById, toolCallFromUpdate, wellKnownAgentBinDirs };
|
|
877
|
+
export { ACP_REGISTRY_URL, AcpAgentAllowlist, type AcpAgentAllowlistRule, AcpAgentClient, type AcpAgentClientFactory, type AcpAgentClientOptions, AcpAgentClientPool, type AcpAgentClientPoolOptions, type AcpAgentConnection, type AcpAgentConnectionHandle, type AcpAgentInstanceSource, type AcpAgentQuirks, type AcpAgentStrategy, type AcpAllowlistDecision, type AcpApplyContext, type AcpBinaryPlatformDistribution, AcpConnection, type AcpConnectionOptions, type AcpDiscoveryProbe, type AcpDistributionKind, type AcpDistributionPolicy, type AcpHttpMcpServerConfig, type AcpJsonRpcTransport, type AcpLoadThreadOptions, type AcpMcpKeyValue, type AcpMcpKeyValueCollection, type AcpMcpServerConfig, type AcpMcpServerWireConfig, type AcpNormalizeResult, type AcpNormalizerOptions, AcpOneShotClient, type AcpOneShotClientOptions, type AcpOneShotRequest, type AcpOneShotResponse, type AcpPackageDistribution, type AcpPathExecutableLister, type AcpPromptContentBlock, type AcpRegistryAgent, type AcpRegistryAgentWithPolicy, type AcpRegistryAuthDescriptor, type AcpRegistryAuthMethod, type AcpRegistryDistribution, type AcpRegistryFetch, AcpRegistryService, type AcpRegistryServiceOptions, type AcpRegistrySnapshot, type AcpRuntimeAgentCapabilities, type AcpRuntimeAgentInfo, type AcpRuntimeCapabilities, type AcpRuntimeCapabilitiesHandler, type AcpRuntimeCapabilitiesSource, type AcpRuntimeConfigOption, type AcpRuntimeConfigOptionValue, type AcpRuntimeMcpCapabilities, type AcpRuntimeMode, type AcpRuntimeModel, type AcpRuntimeModels, type AcpRuntimeModes, type AcpRuntimeOptionSource, AcpSessionNormalizer, type AcpSessionRuntimeState, type AcpSpawnSpec, type AcpSseMcpServerConfig, type AcpStartThreadOptions, type AcpStartTurnOptions, type AcpStdioMcpServerConfig, type AcpTitleHandler, type AcpVerificationStatus, BANNED_ACP_REGISTRY_IDS, BUILT_IN_ACP_STRATEGIES, DEFAULT_ACP_AGENT_ALLOWLIST, type DiscoveredAcpAgent, type DiscoveredAcpAgentGroup, type DiscoveredAcpAgentInstance, type LocalAcpAgentProbe, type LocalAcpDiscoveryOptions, type LocalAcpProbeResult, acpRuntimeSupportsHttpMcp, acpRuntimeSupportsSessionLoad, acpRuntimeSupportsSseMcp, acpSessionRuntimeStateFromCapabilities, acpSessionRuntimeStateFromUpdate, asRecord, buildAcpBackendId, buildStrategyTable, defaultAcpAgentAllowlist, defaultQuirks, discoverLocalAcpAgentInstances, discoverLocalAcpAgents, evaluateAcpDistributionPolicy, geminiStrategy, grokStrategy, isBannedAcpRegistryId, kimiStrategy, mergeAcpRuntimeState, modeLabelFor, modelConfigOption, modelIdFromCapabilities, modelsFromCapabilities, normalizeAcpMcpServerConfig, normalizeAcpMcpServerConfigs, normalizeAcpRuntimeCapabilities, normalizeRegistry, qwenStrategy, readAcpContentText, readBoolean, readContentText, readFirstLocationPath, readFirstString, readKind, readNonEmptyString, readNumber, readPromptText, readString, readToolCallId, readToolContentText, readToolOutput, readUpdateText, reasoningValueForThoughtLevel, strategyByBackendId, strategyById, toolCallFromUpdate, wellKnownAgentBinDirs };
|