@pwrdrvr/agent-acp 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +33 -5
- package/dist/index.js +93 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -212,6 +212,22 @@ declare function normalizeAcpRuntimeCapabilities(params: {
|
|
|
212
212
|
initialize?: AcpRuntimeCapabilities;
|
|
213
213
|
}): AcpRuntimeCapabilities | undefined;
|
|
214
214
|
declare function acpRuntimeSupportsSessionLoad(capabilities: AcpRuntimeCapabilities | undefined): boolean;
|
|
215
|
+
/** The configOption an agent uses to expose model choice (ACP `category:
|
|
216
|
+
* "model"`, falling back to a literal `model` id). Some agents (e.g. Kimi)
|
|
217
|
+
* advertise the active model HERE rather than via top-level
|
|
218
|
+
* `models.currentModelId`. */
|
|
219
|
+
declare function modelConfigOption(capabilities: AcpRuntimeCapabilities | undefined): AcpRuntimeConfigOption | undefined;
|
|
220
|
+
/** The effective model id the agent will run with, agnostic of HOW it advertises
|
|
221
|
+
* it. Prefers a protocol-confirmed `models.currentModelId`; falls back to the
|
|
222
|
+
* `model` configOption's `currentValue` for agents that expose model choice as a
|
|
223
|
+
* config option (Kimi). Returns undefined when the agent advertises no model at
|
|
224
|
+
* all — callers report that as "no model" rather than inventing one. */
|
|
225
|
+
declare function modelIdFromCapabilities(capabilities: AcpRuntimeCapabilities | undefined): string | undefined;
|
|
226
|
+
/** The full model list a host can render/cache, agnostic of advertisement style.
|
|
227
|
+
* Returns `models.availableModels` when present; otherwise derives the list from
|
|
228
|
+
* the `model` configOption's values (Kimi), preserving labels/descriptions and
|
|
229
|
+
* flagging the current value as default. `[]` when no model is advertised. */
|
|
230
|
+
declare function modelsFromCapabilities(capabilities: AcpRuntimeCapabilities | undefined): AcpRuntimeModel[];
|
|
215
231
|
declare function acpSessionRuntimeStateFromCapabilities(capabilities: AcpRuntimeCapabilities | undefined, now: number): AcpSessionRuntimeState | undefined;
|
|
216
232
|
/** Runtime-state change carried inside a session/update (mode/model/config). */
|
|
217
233
|
declare function acpSessionRuntimeStateFromUpdate(update: Record<string, unknown>, now: number): AcpSessionRuntimeState | undefined;
|
|
@@ -414,10 +430,16 @@ declare class AcpAgentClient implements AgentBackend {
|
|
|
414
430
|
private handlePermissionRequest;
|
|
415
431
|
private setRuntimeOption;
|
|
416
432
|
private setRuntimeOptionOnTransport;
|
|
417
|
-
/** Map a neutral `reasoning` token onto an ACP runtime option.
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
433
|
+
/** Map a neutral `reasoning` token onto an ACP runtime option. ACP has no
|
|
434
|
+
* first-class "reasoning effort" concept, so we map it to whatever the agent
|
|
435
|
+
* exposes, in order:
|
|
436
|
+
* 1. An available MODE whose id/label matches the token (set_mode).
|
|
437
|
+
* 2. A "thinking" config option (`category: "thought_level"`, or id
|
|
438
|
+
* `thinking`) — map low-effort tokens to its OFF-like value and
|
|
439
|
+
* high-effort tokens to its ON-like value (set_config_option). This is
|
|
440
|
+
* what lets a one-shot enrichment turn ("low") disable a reasoning
|
|
441
|
+
* model's thinking pass, which is dramatically faster.
|
|
442
|
+
* If nothing matches we leave it alone — the caller's `.catch` debug-logs. */
|
|
421
443
|
private applyReasoning;
|
|
422
444
|
/** Read an image file and build an ACP `image` content block (base64 + inferred
|
|
423
445
|
* mimeType). Throws on read failure; the caller catches + skips. */
|
|
@@ -429,6 +451,12 @@ declare class AcpAgentClient implements AgentBackend {
|
|
|
429
451
|
/** Whether the agent advertises session/load support (for hosts that resume). */
|
|
430
452
|
supportsSessionLoad(): boolean;
|
|
431
453
|
}
|
|
454
|
+
/** Pick the value to set on a "thinking" config option for a neutral reasoning
|
|
455
|
+
* token: low-effort → the OFF-like value, high-effort → the ON-like value.
|
|
456
|
+
* Returns undefined when the token isn't an effort signal we recognize, or the
|
|
457
|
+
* option has no value of the needed polarity (caller leaves the option alone).
|
|
458
|
+
* Exported for testing. */
|
|
459
|
+
declare function reasoningValueForThoughtLevel(reasoning: string, values: ReadonlyArray<AcpRuntimeConfigOptionValue>): string | undefined;
|
|
432
460
|
|
|
433
461
|
type AcpAgentClientFactory = () => AcpAgentClient;
|
|
434
462
|
type AcpAgentClientPoolOptions = {
|
|
@@ -792,4 +820,4 @@ declare class AcpRegistryService {
|
|
|
792
820
|
declare function evaluateAcpDistributionPolicy(distribution: AcpRegistryDistribution, allowlist: AcpAllowlistDecision): AcpDistributionPolicy;
|
|
793
821
|
declare function normalizeRegistry(raw: unknown): AcpRegistryAgent[];
|
|
794
822
|
|
|
795
|
-
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, normalizeAcpRuntimeCapabilities, normalizeRegistry, qwenStrategy, readAcpContentText, readBoolean, readContentText, readFirstLocationPath, readFirstString, readKind, readNonEmptyString, readNumber, readPromptText, readString, readToolCallId, readToolContentText, readToolOutput, readUpdateText, strategyByBackendId, strategyById, toolCallFromUpdate, wellKnownAgentBinDirs };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -716,6 +716,26 @@ function normalizeAcpRuntimeCapabilities(params) {
|
|
|
716
716
|
function acpRuntimeSupportsSessionLoad(capabilities) {
|
|
717
717
|
return capabilities?.agentCapabilities?.loadSession !== false;
|
|
718
718
|
}
|
|
719
|
+
function modelConfigOption(capabilities) {
|
|
720
|
+
return capabilities?.configOptions?.find(
|
|
721
|
+
(option) => option.category === "model" || option.id === "model"
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
function modelIdFromCapabilities(capabilities) {
|
|
725
|
+
return capabilities?.models?.currentModelId ?? modelConfigOption(capabilities)?.currentValue;
|
|
726
|
+
}
|
|
727
|
+
function modelsFromCapabilities(capabilities) {
|
|
728
|
+
const advertised = capabilities?.models?.availableModels;
|
|
729
|
+
if (advertised !== void 0 && advertised.length > 0) return advertised;
|
|
730
|
+
const option = modelConfigOption(capabilities);
|
|
731
|
+
if (option === void 0) return [];
|
|
732
|
+
return option.values.map((value) => ({
|
|
733
|
+
id: value.value,
|
|
734
|
+
...value.label !== void 0 ? { label: value.label } : {},
|
|
735
|
+
...value.description !== void 0 ? { description: value.description } : {},
|
|
736
|
+
...option.currentValue === value.value ? { isDefault: true } : {}
|
|
737
|
+
}));
|
|
738
|
+
}
|
|
719
739
|
function acpSessionRuntimeStateFromCapabilities(capabilities, now) {
|
|
720
740
|
if (!capabilities) {
|
|
721
741
|
return void 0;
|
|
@@ -1160,7 +1180,7 @@ var AcpAgentClient = class {
|
|
|
1160
1180
|
resumed: options.bindThreadId !== void 0
|
|
1161
1181
|
});
|
|
1162
1182
|
const out = { threadId };
|
|
1163
|
-
const model = runtimeCapabilities
|
|
1183
|
+
const model = modelIdFromCapabilities(runtimeCapabilities);
|
|
1164
1184
|
if (model !== void 0) out.model = model;
|
|
1165
1185
|
out.modelProvider = this.strategy.id;
|
|
1166
1186
|
return out;
|
|
@@ -1508,21 +1528,45 @@ var AcpAgentClient = class {
|
|
|
1508
1528
|
modelId: value
|
|
1509
1529
|
});
|
|
1510
1530
|
}
|
|
1511
|
-
/** Map a neutral `reasoning` token onto an ACP runtime option.
|
|
1512
|
-
*
|
|
1513
|
-
*
|
|
1514
|
-
*
|
|
1531
|
+
/** Map a neutral `reasoning` token onto an ACP runtime option. ACP has no
|
|
1532
|
+
* first-class "reasoning effort" concept, so we map it to whatever the agent
|
|
1533
|
+
* exposes, in order:
|
|
1534
|
+
* 1. An available MODE whose id/label matches the token (set_mode).
|
|
1535
|
+
* 2. A "thinking" config option (`category: "thought_level"`, or id
|
|
1536
|
+
* `thinking`) — map low-effort tokens to its OFF-like value and
|
|
1537
|
+
* high-effort tokens to its ON-like value (set_config_option). This is
|
|
1538
|
+
* what lets a one-shot enrichment turn ("low") disable a reasoning
|
|
1539
|
+
* model's thinking pass, which is dramatically faster.
|
|
1540
|
+
* If nothing matches we leave it alone — the caller's `.catch` debug-logs. */
|
|
1515
1541
|
async applyReasoning(threadId, reasoning) {
|
|
1516
|
-
const modes = this.runtimeCapabilities?.modes?.availableModes ?? [];
|
|
1517
1542
|
const target = reasoning.toLowerCase();
|
|
1518
|
-
const
|
|
1543
|
+
const modes = this.runtimeCapabilities?.modes?.availableModes ?? [];
|
|
1544
|
+
const modeMatch = modes.find(
|
|
1519
1545
|
(mode) => mode.id.toLowerCase() === target || typeof mode.label === "string" && mode.label.toLowerCase() === target
|
|
1520
1546
|
);
|
|
1521
|
-
if (
|
|
1522
|
-
this.
|
|
1547
|
+
if (modeMatch !== void 0) {
|
|
1548
|
+
await this.setMode(threadId, modeMatch.id);
|
|
1523
1549
|
return;
|
|
1524
1550
|
}
|
|
1525
|
-
|
|
1551
|
+
const thinking = this.runtimeCapabilities?.configOptions?.find(
|
|
1552
|
+
(option) => option.category === "thought_level" || option.id === "thinking"
|
|
1553
|
+
);
|
|
1554
|
+
if (thinking !== void 0) {
|
|
1555
|
+
const value = reasoningValueForThoughtLevel(target, thinking.values);
|
|
1556
|
+
if (value === void 0) {
|
|
1557
|
+
this.logger.debug("acp reasoning has no matching thought-level value \u2014 ignored", {
|
|
1558
|
+
reasoning
|
|
1559
|
+
});
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
if (value !== thinking.currentValue) {
|
|
1563
|
+
await this.setConfigOption(threadId, thinking.id, value);
|
|
1564
|
+
}
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
this.logger.debug("acp reasoning has no matching mode or thought-level option \u2014 ignored", {
|
|
1568
|
+
reasoning
|
|
1569
|
+
});
|
|
1526
1570
|
}
|
|
1527
1571
|
/** Read an image file and build an ACP `image` content block (base64 + inferred
|
|
1528
1572
|
* mimeType). Throws on read failure; the caller catches + skips. */
|
|
@@ -1555,7 +1599,7 @@ var AcpAgentClient = class {
|
|
|
1555
1599
|
}
|
|
1556
1600
|
emitThreadSettings(session, capabilities, runtimeState) {
|
|
1557
1601
|
const settings = { threadId: session.threadId };
|
|
1558
|
-
const model = runtimeState?.currentModelId ?? capabilities
|
|
1602
|
+
const model = runtimeState?.currentModelId ?? modelIdFromCapabilities(capabilities);
|
|
1559
1603
|
if (model !== void 0) settings.model = model;
|
|
1560
1604
|
settings.modelProvider = this.strategy.id;
|
|
1561
1605
|
const modeId = runtimeState?.currentModeId ?? capabilities?.modes?.currentModeId;
|
|
@@ -1578,6 +1622,38 @@ var AcpAgentClient = class {
|
|
|
1578
1622
|
return acpRuntimeSupportsSessionLoad(this.runtimeCapabilities);
|
|
1579
1623
|
}
|
|
1580
1624
|
};
|
|
1625
|
+
var LOW_EFFORT_TOKENS = /* @__PURE__ */ new Set([
|
|
1626
|
+
"off",
|
|
1627
|
+
"none",
|
|
1628
|
+
"minimal",
|
|
1629
|
+
"min",
|
|
1630
|
+
"minimum",
|
|
1631
|
+
"low",
|
|
1632
|
+
"fast"
|
|
1633
|
+
]);
|
|
1634
|
+
var HIGH_EFFORT_TOKENS = /* @__PURE__ */ new Set([
|
|
1635
|
+
"on",
|
|
1636
|
+
"high",
|
|
1637
|
+
"medium",
|
|
1638
|
+
"max",
|
|
1639
|
+
"maximum",
|
|
1640
|
+
"full",
|
|
1641
|
+
"think"
|
|
1642
|
+
]);
|
|
1643
|
+
function thoughtLevelPolarity(value) {
|
|
1644
|
+
const haystack = `${value.value} ${value.label ?? ""}`.toLowerCase();
|
|
1645
|
+
if (/\b(off|none|disabled?|no)\b/.test(haystack)) return "off";
|
|
1646
|
+
if (/\b(on|enabled?|high|full|yes)\b/.test(haystack)) return "on";
|
|
1647
|
+
return "other";
|
|
1648
|
+
}
|
|
1649
|
+
function reasoningValueForThoughtLevel(reasoning, values) {
|
|
1650
|
+
const token = reasoning.toLowerCase();
|
|
1651
|
+
const wantOff = LOW_EFFORT_TOKENS.has(token);
|
|
1652
|
+
const wantOn = HIGH_EFFORT_TOKENS.has(token);
|
|
1653
|
+
if (!wantOff && !wantOn) return void 0;
|
|
1654
|
+
const desired = wantOff ? "off" : "on";
|
|
1655
|
+
return values.find((value) => thoughtLevelPolarity(value) === desired)?.value;
|
|
1656
|
+
}
|
|
1581
1657
|
function buildApprovalRequest(args) {
|
|
1582
1658
|
const toolCall = asRecord2(args.params.toolCall) ?? {};
|
|
1583
1659
|
const title = typeof toolCall.title === "string" && toolCall.title.trim() ? toolCall.title.trim() : "ACP tool call";
|
|
@@ -1967,8 +2043,8 @@ var AcpOneShotClient = class {
|
|
|
1967
2043
|
async listModelsInner() {
|
|
1968
2044
|
let models = [];
|
|
1969
2045
|
const unsubscribe = this.client.onRuntimeCapabilities((event) => {
|
|
1970
|
-
const observed = event.runtimeCapabilities
|
|
1971
|
-
if (observed
|
|
2046
|
+
const observed = modelsFromCapabilities(event.runtimeCapabilities);
|
|
2047
|
+
if (observed.length > 0) models = observed;
|
|
1972
2048
|
});
|
|
1973
2049
|
try {
|
|
1974
2050
|
await this.client.startThread();
|
|
@@ -2692,6 +2768,9 @@ export {
|
|
|
2692
2768
|
kimiStrategy,
|
|
2693
2769
|
mergeAcpRuntimeState,
|
|
2694
2770
|
modeLabelFor,
|
|
2771
|
+
modelConfigOption,
|
|
2772
|
+
modelIdFromCapabilities,
|
|
2773
|
+
modelsFromCapabilities,
|
|
2695
2774
|
normalizeAcpRuntimeCapabilities,
|
|
2696
2775
|
normalizeRegistry,
|
|
2697
2776
|
qwenStrategy,
|
|
@@ -2709,6 +2788,7 @@ export {
|
|
|
2709
2788
|
readToolContentText,
|
|
2710
2789
|
readToolOutput,
|
|
2711
2790
|
readUpdateText,
|
|
2791
|
+
reasoningValueForThoughtLevel,
|
|
2712
2792
|
strategyByBackendId,
|
|
2713
2793
|
strategyById,
|
|
2714
2794
|
toolCallFromUpdate,
|