@lucascouts/claude-agent-acp-plus 0.1.0 → 0.2.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/acp-agent.d.ts +108 -35
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +623 -74
- package/dist/model-deprecation.d.ts +30 -0
- package/dist/model-deprecation.d.ts.map +1 -0
- package/dist/model-deprecation.js +58 -0
- package/dist/rewind-command.d.ts +140 -0
- package/dist/rewind-command.d.ts.map +1 -0
- package/dist/rewind-command.js +278 -0
- package/dist/thinking-option.d.ts +85 -0
- package/dist/thinking-option.d.ts.map +1 -0
- package/dist/thinking-option.js +108 -0
- package/package.json +2 -2
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Thinking" session config option (story 006, R1.1/R1.4/R1.5/R1.6): the
|
|
3
|
+
* select-option factory surfaced via `configOptions`, the value resolver for
|
|
4
|
+
* `session/set_config_option`, and the ONE precedence point that combines the
|
|
5
|
+
* session's thinking intent with the legacy `MAX_THINKING_TOKENS` env
|
|
6
|
+
* resolution into the SDK's `thinking` option.
|
|
7
|
+
*
|
|
8
|
+
* Kept self-contained (no import from the daily-churning `acp-agent.ts`,
|
|
9
|
+
* mirroring the `ask-user-question-fallback.ts` precedent) so the logic is
|
|
10
|
+
* unit-testable in isolation; `acp-agent.ts` wires it into
|
|
11
|
+
* `buildConfigOptions`/`setSessionConfigOption`/query creation in sub-tasks
|
|
12
|
+
* 1.2/1.3.
|
|
13
|
+
*/
|
|
14
|
+
/** Stable id for the Thinking session config option. */
|
|
15
|
+
export const THINKING_CONFIG_ID = "thinking";
|
|
16
|
+
/** Select value that turns extended thinking on. */
|
|
17
|
+
export const THINKING_ON = "on";
|
|
18
|
+
/** Select value that turns extended thinking off. */
|
|
19
|
+
export const THINKING_OFF = "off";
|
|
20
|
+
const THINKING_DESCRIPTION = "Extended thinking before responding";
|
|
21
|
+
/**
|
|
22
|
+
* Build the Thinking config option: a two-value "on"/"off" `select` in the
|
|
23
|
+
* exact shape of the Fast mode select fallback (R1.1). Unlike Fast mode there
|
|
24
|
+
* is no boolean variant — the option is select-only from day one.
|
|
25
|
+
*
|
|
26
|
+
* @param enabled Whether extended thinking is currently on for the session;
|
|
27
|
+
* reflected in `currentValue`.
|
|
28
|
+
*/
|
|
29
|
+
export function createThinkingConfigOption(enabled) {
|
|
30
|
+
return {
|
|
31
|
+
id: THINKING_CONFIG_ID,
|
|
32
|
+
name: "Thinking",
|
|
33
|
+
description: THINKING_DESCRIPTION,
|
|
34
|
+
category: "model_config",
|
|
35
|
+
type: "select",
|
|
36
|
+
currentValue: enabled ? THINKING_ON : THINKING_OFF,
|
|
37
|
+
options: [
|
|
38
|
+
{ value: THINKING_ON, name: "On" },
|
|
39
|
+
{ value: THINKING_OFF, name: "Off" },
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Resolve a `session/set_config_option` value for the Thinking option into the
|
|
45
|
+
* session's thinking intent. Only the select values are meaningful: `"on"` →
|
|
46
|
+
* `true`, `"off"` → `false`. Anything else — booleans included, since the
|
|
47
|
+
* option never had a legacy boolean shape (unlike Fast mode) — resolves to
|
|
48
|
+
* `null` (unrecognized).
|
|
49
|
+
*
|
|
50
|
+
* @param value Raw value from the request (untrusted; narrowed here).
|
|
51
|
+
*/
|
|
52
|
+
export function resolveThinkingSelection(value) {
|
|
53
|
+
if (value === THINKING_ON)
|
|
54
|
+
return true;
|
|
55
|
+
if (value === THINKING_OFF)
|
|
56
|
+
return false;
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Translate the legacy `MAX_THINKING_TOKENS` env var into the SDK's `thinking`
|
|
61
|
+
* option: unset → `undefined` (SDK default, adaptive on models that support
|
|
62
|
+
* it); `0` → disabled; a positive integer → a fixed token budget. Anything
|
|
63
|
+
* else is ignored with a logged error, i.e. treated as unset.
|
|
64
|
+
*
|
|
65
|
+
* NOTE: duplicated from the unexported `resolveThinkingConfig` in
|
|
66
|
+
* `acp-agent.ts` (behavior and log message identical); sub-task 1.3 makes
|
|
67
|
+
* `acp-agent.ts` consume this export and removes the duplication.
|
|
68
|
+
*
|
|
69
|
+
* @param raw The raw `MAX_THINKING_TOKENS` value (pass
|
|
70
|
+
* `process.env.MAX_THINKING_TOKENS`).
|
|
71
|
+
* @param logger Sink for the invalid-value error.
|
|
72
|
+
*/
|
|
73
|
+
export function resolveThinkingConfig(raw, logger) {
|
|
74
|
+
if (raw === undefined)
|
|
75
|
+
return undefined;
|
|
76
|
+
const parsed = Number.parseInt(raw, 10);
|
|
77
|
+
if (Number.isNaN(parsed) || parsed < 0) {
|
|
78
|
+
logger.error(`Ignoring MAX_THINKING_TOKENS: expected a non-negative integer, got '${raw}'.`);
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return parsed === 0 ? { type: "disabled" } : { type: "enabled", budgetTokens: parsed };
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The ONE precedence point combining the session's Thinking intent with the
|
|
85
|
+
* legacy `MAX_THINKING_TOKENS` env resolution:
|
|
86
|
+
*
|
|
87
|
+
* - `intent === false` → `{ type: "disabled" }`, the SDK's documented
|
|
88
|
+
* no-extended-thinking value — the option beats the env var (R1.5).
|
|
89
|
+
* - `intent === true` → the env resolution when the env var is set (R1.4);
|
|
90
|
+
* with the env var unset — or invalid, which is logged and treated as unset
|
|
91
|
+
* — the SDK's documented enabled default `{ type: "adaptive" }` ("Claude
|
|
92
|
+
* decides when and how much to think").
|
|
93
|
+
* - `intent === undefined` → exactly today's env-driven behavior, including
|
|
94
|
+
* `undefined` (SDK default) when the env var is unset (R1.6).
|
|
95
|
+
*
|
|
96
|
+
* @param intent The session's Thinking selection: `true`/`false` once the
|
|
97
|
+
* client has set the option, `undefined` while untouched.
|
|
98
|
+
* @param env The raw `MAX_THINKING_TOKENS` value (pass
|
|
99
|
+
* `process.env.MAX_THINKING_TOKENS`).
|
|
100
|
+
* @param logger Sink for the invalid-env error.
|
|
101
|
+
*/
|
|
102
|
+
export function effectiveThinkingConfig(intent, env, logger) {
|
|
103
|
+
if (intent === false)
|
|
104
|
+
return { type: "disabled" };
|
|
105
|
+
if (intent === true)
|
|
106
|
+
return resolveThinkingConfig(env, logger) ?? { type: "adaptive" };
|
|
107
|
+
return resolveThinkingConfig(env, logger);
|
|
108
|
+
}
|
package/package.json
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
7
|
-
"description": "
|
|
6
|
+
"version": "0.2.0",
|
|
7
|
+
"description": "ACP adapter for the Claude Agent SDK with VS Code-parity UX for Zed and other ACP clients — checkbox multi-select questions, refusal consent dialog, dynamic agent name. Fork of claude-agent-acp.",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
10
10
|
"bin": {
|