@lucascouts/claude-agent-tui 0.10.1 → 0.10.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/dist/acp-agent.d.ts +14 -0
- package/dist/acp-agent.js +57 -1
- package/dist/model-catalog.d.ts +19 -0
- package/dist/model-catalog.js +31 -0
- package/package.json +8 -8
package/dist/acp-agent.d.ts
CHANGED
|
@@ -880,6 +880,20 @@ export declare class ClaudeAcpAgent implements Agent {
|
|
|
880
880
|
* reason (loaded==live for usage). Only dedup and the billing guard-rail stay with the callers.
|
|
881
881
|
*/
|
|
882
882
|
private emitTurnUpdates;
|
|
883
|
+
/**
|
|
884
|
+
* Story 081 — align the `model` configOption with the model a turn ACTUALLY ran on.
|
|
885
|
+
*
|
|
886
|
+
* Same compare-then-rebuild-then-emit-only-on-change shape as {@link refreshFastMode}: an
|
|
887
|
+
* unresolvable id leaves the current seed alone (R2.1), and an id denoting the model already
|
|
888
|
+
* selected emits NOTHING (R1.3). That silence matters — this runs on the LIVE pump as well as the
|
|
889
|
+
* `session/load` replay, so an unguarded version would emit a config_option_update every turn.
|
|
890
|
+
*
|
|
891
|
+
* `default` and `opus` are the SAME model (`model-catalog.ts` — "`default` resolves to the
|
|
892
|
+
* recommended Opus"), so they compare EQUAL here: a `default` seed facing a `claude-opus-*`
|
|
893
|
+
* transcript is already correct, and rewriting it to `opus` would change the visible label without
|
|
894
|
+
* any model having changed.
|
|
895
|
+
*/
|
|
896
|
+
private reconcileModelSelector;
|
|
883
897
|
/**
|
|
884
898
|
* Story 041 (R2.1, R2.2) — build the ACP `tool_call_update`(s) that render ONE nested sub-agent
|
|
885
899
|
* row UNDER its spawning Task tool_call. The nested row's `parent_tool_use_id` is the SPAWNING
|
package/dist/acp-agent.js
CHANGED
|
@@ -24,7 +24,7 @@ import { guardEvent } from "./billing/entrypoint-guard.js";
|
|
|
24
24
|
import { usageUpdatesFor } from "./usage.js";
|
|
25
25
|
import { createTurnResolver } from "./end-of-turn.js";
|
|
26
26
|
import { sendPrompt } from "./engine-pty.js";
|
|
27
|
-
import { MODEL_CATALOG, MODEL_CONTEXT_WINDOWS, MODEL_ID_CONTEXT_WINDOWS, modelSelectorDescription, DEFAULT_MODEL_INFO, isFastModeCapableModel, classifyFastModeSignal, FAST_MODE_CONFIG_ID, FAST_MODE_ON, FAST_MODE_OFF, createFastModeConfigOption, clientSupportsBooleanConfigOptions, resolveFastModeEnabled, ULTRACODE_EFFORT, ULTRACODE_EFFORT_LEVEL, ULTRACODE_EFFORT_LABEL, } from "./model-catalog.js";
|
|
27
|
+
import { MODEL_CATALOG, MODEL_CONTEXT_WINDOWS, MODEL_ID_CONTEXT_WINDOWS, modelSelectorDescription, DEFAULT_MODEL_INFO, resolveCatalogValueFromModelId, isFastModeCapableModel, classifyFastModeSignal, FAST_MODE_CONFIG_ID, FAST_MODE_ON, FAST_MODE_OFF, createFastModeConfigOption, clientSupportsBooleanConfigOptions, resolveFastModeEnabled, ULTRACODE_EFFORT, ULTRACODE_EFFORT_LEVEL, ULTRACODE_EFFORT_LABEL, } from "./model-catalog.js";
|
|
28
28
|
// Story 060 (R2.2/R2.3/R3.2) — the declarative spawn-time complement to the live ultracode keyword:
|
|
29
29
|
// toggle the {ultracode,ultracodeKeywordTrigger} keys in the gate's per-session scratch settings file
|
|
30
30
|
// (preserving the hook + every other key). Lives in the gate's settings-writer so it reuses durableWrite.
|
|
@@ -896,6 +896,18 @@ export class ClaudeAcpAgent {
|
|
|
896
896
|
* authenticate() (R4); active sessions are untouched (R6).
|
|
897
897
|
*/
|
|
898
898
|
async logout(_params) {
|
|
899
|
+
// Story 062 live-proof seam. The unit suite calls this method DIRECTLY and can only
|
|
900
|
+
// SIMULATE the SDK bind (acp.js:999), so it cannot prove the real client reaches the
|
|
901
|
+
// handler over the wire — the one risk Task 2.1 recorded ("the name must be exactly
|
|
902
|
+
// `logout` for SDK dispatch"). This opt-in probe makes that dispatch observable: run
|
|
903
|
+
// the agent with FORK_AUTH_PROBE=1 and the line below appears iff the client actually
|
|
904
|
+
// called it. OFF by default, so production and the hermetic suite stay silent.
|
|
905
|
+
//
|
|
906
|
+
// stderr, never stdout — stdout is the ACP wire (same rule as agent-catalog.ts). The
|
|
907
|
+
// payload is NEVER logged: `_params` may carry gateway credentials.
|
|
908
|
+
if (process.env.FORK_AUTH_PROBE === "1") {
|
|
909
|
+
process.stderr.write("[auth-probe] logout dispatched by the client\n");
|
|
910
|
+
}
|
|
899
911
|
this.gatewayAuthRequest = undefined;
|
|
900
912
|
}
|
|
901
913
|
async prompt(params) {
|
|
@@ -1850,6 +1862,50 @@ export class ClaudeAcpAgent {
|
|
|
1850
1862
|
}
|
|
1851
1863
|
}
|
|
1852
1864
|
}
|
|
1865
|
+
// Story 081 (R1.1) — reseed the model selector from the turn's REAL model, so a RESUMED session
|
|
1866
|
+
// stops advertising `Default` when its transcript ran on another alias. Reads the SAME JSONL
|
|
1867
|
+
// `model` story 069 reads three lines up (R3.1 — no new seam); kept OUTSIDE the usage block on
|
|
1868
|
+
// purpose, since the selector has nothing to do with whether usage_update is latched off.
|
|
1869
|
+
if (session) {
|
|
1870
|
+
const modelCarrier = turn.message.message ?? {};
|
|
1871
|
+
await this.reconcileModelSelector(sessionId, session, modelCarrier.model);
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Story 081 — align the `model` configOption with the model a turn ACTUALLY ran on.
|
|
1876
|
+
*
|
|
1877
|
+
* Same compare-then-rebuild-then-emit-only-on-change shape as {@link refreshFastMode}: an
|
|
1878
|
+
* unresolvable id leaves the current seed alone (R2.1), and an id denoting the model already
|
|
1879
|
+
* selected emits NOTHING (R1.3). That silence matters — this runs on the LIVE pump as well as the
|
|
1880
|
+
* `session/load` replay, so an unguarded version would emit a config_option_update every turn.
|
|
1881
|
+
*
|
|
1882
|
+
* `default` and `opus` are the SAME model (`model-catalog.ts` — "`default` resolves to the
|
|
1883
|
+
* recommended Opus"), so they compare EQUAL here: a `default` seed facing a `claude-opus-*`
|
|
1884
|
+
* transcript is already correct, and rewriting it to `opus` would change the visible label without
|
|
1885
|
+
* any model having changed.
|
|
1886
|
+
*/
|
|
1887
|
+
async reconcileModelSelector(sessionId, session, rawModel) {
|
|
1888
|
+
if (typeof rawModel !== "string" || rawModel.length === 0)
|
|
1889
|
+
return;
|
|
1890
|
+
const resolved = resolveCatalogValueFromModelId(rawModel);
|
|
1891
|
+
if (resolved === null)
|
|
1892
|
+
return; // unknown family → keep the existing seed (R2.1)
|
|
1893
|
+
const modelOpt = session.configOptions.find((o) => o.id === "model");
|
|
1894
|
+
const current = typeof modelOpt?.currentValue === "string" ? modelOpt.currentValue : undefined;
|
|
1895
|
+
if (current === undefined)
|
|
1896
|
+
return;
|
|
1897
|
+
// `default` is an ALIAS for opus — normalise before comparing so the two never fight (R1.3).
|
|
1898
|
+
const family = (v) => (v === "default" ? "opus" : v);
|
|
1899
|
+
if (family(current) === family(resolved))
|
|
1900
|
+
return; // same model → nothing visible changed
|
|
1901
|
+
session.configOptions = this.rebuildConfigOptionsPreserving(session, resolved);
|
|
1902
|
+
// The session may have been torn down mid-await — same guard refreshFastMode uses.
|
|
1903
|
+
if (!this.sessions[sessionId])
|
|
1904
|
+
return;
|
|
1905
|
+
await this.client.sessionUpdate({
|
|
1906
|
+
sessionId,
|
|
1907
|
+
update: { sessionUpdate: "config_option_update", configOptions: session.configOptions },
|
|
1908
|
+
});
|
|
1853
1909
|
}
|
|
1854
1910
|
/**
|
|
1855
1911
|
* Story 041 (R2.1, R2.2) — build the ACP `tool_call_update`(s) that render ONE nested sub-agent
|
package/dist/model-catalog.d.ts
CHANGED
|
@@ -58,6 +58,25 @@ export declare const MODEL_CONTEXT_WINDOWS: Record<string, number>;
|
|
|
58
58
|
* `inferContextWindowFromModelId`; this table is the exact-ID source of truth for today's gateway IDs.
|
|
59
59
|
*/
|
|
60
60
|
export declare const MODEL_ID_CONTEXT_WINDOWS: Record<string, number>;
|
|
61
|
+
/**
|
|
62
|
+
* Story 081 (R1.2) — map a turn's REAL model id (the JSONL `model`) onto a catalog `value`, so a
|
|
63
|
+
* RESUMED session can seed its model selector from the transcript instead of the static `default`.
|
|
64
|
+
*
|
|
65
|
+
* Deliberately the same shape as {@link inferContextWindowFromModelId}: match by FAMILY (not exact
|
|
66
|
+
* id) so dated snapshots (`claude-sonnet-4-5-20250929`) and the `[1m]` long-context suffix resolve,
|
|
67
|
+
* and return `null` for anything unplaceable. `null` is meaningful — it routes the caller to leave
|
|
68
|
+
* the existing seed untouched (R2.1), mirroring 069's `?? session.contextWindowSize`.
|
|
69
|
+
*
|
|
70
|
+
* TOTAL FUNCTION: never throws, whatever it is handed. Every returned string is a `value` present in
|
|
71
|
+
* {@link MODEL_CATALOG}; returning anything else would make the selector advertise an entry the
|
|
72
|
+
* client cannot select (asserted in `test/resumed-model.test.ts`).
|
|
73
|
+
*
|
|
74
|
+
* NOTE the asymmetry with the catalog's `default` entry: `default` and `opus` denote the SAME model
|
|
75
|
+
* (see the `MODEL_CATALOG` comment at `value: "default"`), so a `claude-opus-*` id resolves to
|
|
76
|
+
* `opus` here and the CALLER is responsible for treating a `default` seed as already-correct (R1.3)
|
|
77
|
+
* — that equivalence is a UI concern, not a catalog one.
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveCatalogValueFromModelId(id: string): string | null;
|
|
61
80
|
/**
|
|
62
81
|
* Story 072 — the version/context PREFIX the claude `/model` picker now shows before the static tagline
|
|
63
82
|
* (e.g. "Opus 4.8 with 1M context · Best for everyday, complex tasks"). Keyed by catalog `value`.
|
package/dist/model-catalog.js
CHANGED
|
@@ -121,6 +121,37 @@ export const MODEL_ID_CONTEXT_WINDOWS = {
|
|
|
121
121
|
"claude-sonnet-4-20250514": 200_000,
|
|
122
122
|
"claude-haiku-4-5": 200_000,
|
|
123
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Story 081 (R1.2) — map a turn's REAL model id (the JSONL `model`) onto a catalog `value`, so a
|
|
126
|
+
* RESUMED session can seed its model selector from the transcript instead of the static `default`.
|
|
127
|
+
*
|
|
128
|
+
* Deliberately the same shape as {@link inferContextWindowFromModelId}: match by FAMILY (not exact
|
|
129
|
+
* id) so dated snapshots (`claude-sonnet-4-5-20250929`) and the `[1m]` long-context suffix resolve,
|
|
130
|
+
* and return `null` for anything unplaceable. `null` is meaningful — it routes the caller to leave
|
|
131
|
+
* the existing seed untouched (R2.1), mirroring 069's `?? session.contextWindowSize`.
|
|
132
|
+
*
|
|
133
|
+
* TOTAL FUNCTION: never throws, whatever it is handed. Every returned string is a `value` present in
|
|
134
|
+
* {@link MODEL_CATALOG}; returning anything else would make the selector advertise an entry the
|
|
135
|
+
* client cannot select (asserted in `test/resumed-model.test.ts`).
|
|
136
|
+
*
|
|
137
|
+
* NOTE the asymmetry with the catalog's `default` entry: `default` and `opus` denote the SAME model
|
|
138
|
+
* (see the `MODEL_CATALOG` comment at `value: "default"`), so a `claude-opus-*` id resolves to
|
|
139
|
+
* `opus` here and the CALLER is responsible for treating a `default` seed as already-correct (R1.3)
|
|
140
|
+
* — that equivalence is a UI concern, not a catalog one.
|
|
141
|
+
*/
|
|
142
|
+
export function resolveCatalogValueFromModelId(id) {
|
|
143
|
+
if (typeof id !== "string" || id.length === 0)
|
|
144
|
+
return null;
|
|
145
|
+
if (/claude-opus/.test(id))
|
|
146
|
+
return "opus";
|
|
147
|
+
if (/claude-fable/.test(id))
|
|
148
|
+
return "fable5";
|
|
149
|
+
if (/claude-sonnet/.test(id))
|
|
150
|
+
return "sonnet";
|
|
151
|
+
if (/claude-haiku/.test(id))
|
|
152
|
+
return "haiku";
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
124
155
|
/**
|
|
125
156
|
* Story 072 — the version/context PREFIX the claude `/model` picker now shows before the static tagline
|
|
126
157
|
* (e.g. "Opus 4.8 with 1M context · Best for everyday, complex tasks"). Keyed by catalog `value`.
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.10.
|
|
6
|
+
"version": "0.10.3",
|
|
7
7
|
"description": "Run the official Claude Code TUI in Zed's agent panel on your Claude Pro/Max subscription — an ACP-over-PTY bridge created for Anthropic's billing split (paused June 15; see README).",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@agentclientprotocol/sdk": "1.3.0",
|
|
67
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
67
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.226",
|
|
68
68
|
"node-pty": "1.1.0",
|
|
69
69
|
"zod": "^3.25.0 || ^4.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@anthropic-ai/sdk": "0.
|
|
72
|
+
"@anthropic-ai/sdk": "0.117.1",
|
|
73
73
|
"@eslint/js": "10.0.1",
|
|
74
|
-
"@types/node": "26.
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
76
|
-
"@typescript-eslint/parser": "8.
|
|
77
|
-
"eslint": "10.8.
|
|
74
|
+
"@types/node": "26.2.0",
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "8.67.0",
|
|
76
|
+
"@typescript-eslint/parser": "8.67.0",
|
|
77
|
+
"eslint": "10.8.1",
|
|
78
78
|
"eslint-config-prettier": "10.1.8",
|
|
79
|
-
"globals": "17.
|
|
79
|
+
"globals": "17.11.0",
|
|
80
80
|
"prettier": "3.9.6",
|
|
81
81
|
"ts-node": "10.9.2",
|
|
82
82
|
"typescript": "6.0.3"
|