@shumkov/orchestra 0.10.21 → 0.11.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.
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Claude Code 2.1.283 compatibility
|
|
2
|
+
|
|
3
|
+
Orchestra 0.11.0 pins the channels backend to Claude Code 2.1.283. The pin is
|
|
4
|
+
now defined by the Agent SDK: `@anthropic-ai/claude-agent-sdk` 0.3.283 is
|
|
5
|
+
pinned exactly, `CLAUDE_CLI_PINNED_VERSION` must equal its `claudeCodeVersion`
|
|
6
|
+
(a unit test enforces it), and the vendored binary is copied from the SDK's
|
|
7
|
+
per-platform package. On darwin-arm64 that binary is byte-identical to the
|
|
8
|
+
auto-updater's 2.1.283 (SHA-256 `d8cb1e5c…1d21e`, same Anthropic signature).
|
|
9
|
+
|
|
10
|
+
## Behavior changes handled
|
|
11
|
+
|
|
12
|
+
- **Workspace trust dialog.** 2.1.283 lists "❯ No, exit" first and pre-selects
|
|
13
|
+
it; Enter exits claude. The dialog can also render before it accepts input.
|
|
14
|
+
The startup gate now presses Down until "❯ Yes, I trust this folder" is
|
|
15
|
+
visibly selected, then Enter. Not in the upstream changelog; found by a live
|
|
16
|
+
probe.
|
|
17
|
+
- **System prompt recording** (2.1.267+). A conversation records its appended
|
|
18
|
+
system prompt once and replays it on resume until compaction. `CliProcess`
|
|
19
|
+
passes `--system-prompt-snapshot off` when `--help` lists it, so display
|
|
20
|
+
rules and the reply contract rebuilt on each spawn reach resumed chats.
|
|
21
|
+
2.1.220 rejects the flag, so it is feature-detected once per binary. Tool
|
|
22
|
+
definitions stay recorded even with the snapshot off.
|
|
23
|
+
- **Opus 5.5** is what `--model opus` resolves to (2.1.280).
|
|
24
|
+
|
|
25
|
+
## Live probes (2.1.283, real sessions through `CliProcess`)
|
|
26
|
+
|
|
27
|
+
| Probe | Result |
|
|
28
|
+
|---|---|
|
|
29
|
+
| Footer while streaming | `esc to interrupt` present in 14 of 16 mid-turn captures; `STREAMING_HINT_RE` unchanged |
|
|
30
|
+
| Footer with a background shell | `⏵⏵ bypass permissions on · 1 shell`; `BACKGROUND_SHELL_RE` extracts 1 |
|
|
31
|
+
| Dangerous `rm` in bypass mode, 4 triggers | Triggers 1–3 show "Do you want to proceed?" with an auto-deny countdown and are denied after ~2 min (129–148 s); the turn continues and replies. Trigger 4 is denied without a dialog (14 s) after 3 unanswered prompts. No approval card is emitted; the dialog only produces `cli-mid-turn-unknown-prompt` telemetry. |
|
|
32
|
+
| Trust dialog | Handled by the new gate (see above) |
|
|
33
|
+
| Session-age dialog | Option order unchanged ("Resume from summary" first); `CLAUDE_CODE_RESUME_THRESHOLD_MINUTES` still present, so the dialog stays suppressed |
|
|
34
|
+
| Rollback direction | 2.1.220 resumes a session written by 2.1.283 and recalls its context |
|
|
35
|
+
|
|
36
|
+
## Known upstream regression: auto-backgrounded MCP calls (SDK)
|
|
37
|
+
|
|
38
|
+
With `CLAUDE_AUTO_BACKGROUND_TASKS=1`, 2.1.283 moves a slow MCP tool call to
|
|
39
|
+
the background after about 1 s, ends the turn, then reports the background
|
|
40
|
+
task as `failed`; every retry returns "The tool call was interrupted before a
|
|
41
|
+
result was received" (3 of 3 gate runs; 2.1.220 completes it). Without the
|
|
42
|
+
opt-in, which is how production runs, the call stays in the foreground and
|
|
43
|
+
completes (2 of 2 runs plus the authoritative matrix). Do not enable
|
|
44
|
+
`CLAUDE_AUTO_BACKGROUND_TASKS` on this pin. The gate records this cell as a
|
|
45
|
+
known regression for 2.1.283 and keeps gating the foreground path.
|
|
46
|
+
|
|
47
|
+
## Known limitation: long working directories
|
|
48
|
+
|
|
49
|
+
Claude Code truncates the `~/.claude/projects/<encoded-cwd>` directory name at
|
|
50
|
+
about 200 characters and appends a short hash (observed on 2.1.220, e.g.
|
|
51
|
+
`…-workflow-workspace--d9uh4m`). Orchestra's and Polygram's session-log path
|
|
52
|
+
helpers assume the plain encoding, so session-log reading fails for a cwd whose
|
|
53
|
+
encoded name exceeds that length. Production cwds are far shorter; the gate
|
|
54
|
+
must run with a short artifact base.
|
|
55
|
+
|
|
56
|
+
## Compatibility gate
|
|
57
|
+
|
|
58
|
+
Polygram's serial real-Claude matrix (2.1.220 ↔ 2.1.283, run
|
|
59
|
+
`2026-09-26T16-30-19-568Z`) passed all 22 authoritative runs and was accepted:
|
|
60
|
+
|
|
61
|
+
- two independent CLI contract runs per version;
|
|
62
|
+
- direct and failed-reply Workflow completion delivery;
|
|
63
|
+
- delayed MCP completion on the default (foreground) path;
|
|
64
|
+
- SDK PostToolBatch, subagent, resume, manual compact, and tool-less drain;
|
|
65
|
+
- the candidate Opus 5.5 production projection;
|
|
66
|
+
- the candidate system-prompt snapshot cell: with recording forced on the
|
|
67
|
+
resumed session kept the first prompt, and with `--system-prompt-snapshot
|
|
68
|
+
off` it saw the changed prompt, so recording is active for the account and
|
|
69
|
+
the flag is what keeps prompt changes reaching resumed chats.
|
|
70
|
+
|
|
71
|
+
Two cells are waived and listed in every summary: the
|
|
72
|
+
`CLAUDE_AUTO_BACKGROUND_TASKS=1` delayed-MCP path (a 2.1.283 regression, see
|
|
73
|
+
above; intermittent on 2.1.220; unused in production).
|
|
74
|
+
|
|
75
|
+
2.1.283 lifecycle differences the matrix declares per version: an extra
|
|
76
|
+
UserPromptSubmit hook for a prompt folded into a running turn; eight passive
|
|
77
|
+
context attachments recorded once per session (counted, position-free, since
|
|
78
|
+
their order against the first queued message is a race); an `auto_mode`
|
|
79
|
+
attachment in Opus sessions; new `atis-latch` and `cost-state` transcript rows;
|
|
80
|
+
SDK `tool_progress` heartbeats and a variable number of `status` notices.
|
|
81
|
+
`total_tokens_reminder` attachments appear on both versions.
|
|
82
|
+
|
|
83
|
+
Acceptance note: the run's evidence tree held one hook ndjson a late hook had
|
|
84
|
+
recreated as 0644 after the session was torn down (fixed in this release:
|
|
85
|
+
the hook helper now creates files 0600). It was set to 0600 before
|
|
86
|
+
acceptance; its content is outside the evaluated evidence.
|
|
87
|
+
|
|
88
|
+
## Rollback
|
|
89
|
+
|
|
90
|
+
Reinstall the previous Orchestra/Polygram. Boot deletes every vendored version
|
|
91
|
+
except the pin, so preserve the 2.1.220 binary outside the vendor directory
|
|
92
|
+
before deploying and copy it back before restarting the old version.
|
package/lib/claude-bin.js
CHANGED
|
@@ -5,10 +5,15 @@ const os = require('os');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const { execFileSync } = require('child_process');
|
|
8
|
+
const { createRequire } = require('module');
|
|
8
9
|
|
|
9
10
|
// The channels backend consumes Claude Code's private TUI, hook, and session
|
|
10
11
|
// formats. Change this pin only after the real-CLI compatibility gate passes.
|
|
11
|
-
|
|
12
|
+
// It must equal the `claudeCodeVersion` of the exact Agent SDK version in
|
|
13
|
+
// package.json: that SDK's platform package supplies the vendored binary, and
|
|
14
|
+
// a unit test fails when the two drift apart. It stays a literal because
|
|
15
|
+
// consumers that omit optional dependencies have no SDK to derive it from.
|
|
16
|
+
const CLAUDE_CLI_PINNED_VERSION = '2.1.283';
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
19
|
* Resolve + verify the pinned claude CLI binary.
|
|
@@ -108,14 +113,126 @@ function isExecutable(p) {
|
|
|
108
113
|
try { fs.accessSync(p, fs.constants.X_OK); return true; } catch { return false; }
|
|
109
114
|
}
|
|
110
115
|
|
|
111
|
-
//
|
|
112
|
-
function
|
|
116
|
+
// `claude --version` prints e.g. "2.1.283 (Claude Code)".
|
|
117
|
+
function _reportedVersion(bin) {
|
|
118
|
+
const out = execFileSync(bin, ['--version'], { timeout: 30_000, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
119
|
+
return out.trim().split(/\s+/)[0];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Atomic and validated: copy to a unique tmp in the same dir, chmod, check the
|
|
123
|
+
// copy, then rename over. The check matters because the fast path trusts any
|
|
124
|
+
// executable file in the vendor dir forever, and a source can be caught
|
|
125
|
+
// mid-write (`npm i -g` extracts in place while a service may be restarting).
|
|
126
|
+
function _atomicCopyExec(src, dst, version) {
|
|
113
127
|
const tmp = `${dst}.tmp.${process.pid}.${Date.now()}`;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
try {
|
|
129
|
+
fs.copyFileSync(src, tmp);
|
|
130
|
+
fs.chmodSync(tmp, 0o755);
|
|
131
|
+
const srcSize = fs.statSync(src).size;
|
|
132
|
+
const tmpSize = fs.statSync(tmp).size;
|
|
133
|
+
if (srcSize !== tmpSize) {
|
|
134
|
+
throw new Error(`copied ${tmpSize} of ${srcSize} bytes`);
|
|
135
|
+
}
|
|
136
|
+
let reported;
|
|
137
|
+
try { reported = _reportedVersion(tmp); } catch (e) {
|
|
138
|
+
throw new Error(`\`--version\` failed: ${e.message}`);
|
|
139
|
+
}
|
|
140
|
+
if (reported !== version) {
|
|
141
|
+
throw new Error(`\`--version\` reported ${JSON.stringify(reported)}, expected ${version}`);
|
|
142
|
+
}
|
|
143
|
+
fs.renameSync(tmp, dst);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
try { fs.rmSync(tmp, { force: true }); } catch {}
|
|
146
|
+
throw e;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const SDK_PACKAGE = '@anthropic-ai/claude-agent-sdk';
|
|
151
|
+
|
|
152
|
+
// True on Linux hosts without glibc (e.g. Alpine). Same test the SDK uses.
|
|
153
|
+
function _hostPrefersMusl() {
|
|
154
|
+
if (process.platform !== 'linux') return false;
|
|
155
|
+
const report = typeof process.report?.getReport === 'function' ? process.report.getReport() : null;
|
|
156
|
+
return report != null && report.header?.glibcVersionRuntime === undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Locate the claude binary shipped in the Agent SDK's per-platform optional
|
|
161
|
+
* package, resolving it the way the SDK itself does. Resolution starts from
|
|
162
|
+
* the SDK's own directory so a nested SDK copy finds its matching platform
|
|
163
|
+
* package.
|
|
164
|
+
*
|
|
165
|
+
* @param {object} [opts]
|
|
166
|
+
* @param {NodeRequire} [opts.requireFrom] — require used to find the SDK
|
|
167
|
+
* @param {string} [opts.platform] [opts.arch] [opts.preferMusl]
|
|
168
|
+
* @returns {{ ok: boolean, path?: string, claudeCodeVersion?: string, sdkVersion?: string, reason?: string }}
|
|
169
|
+
*/
|
|
170
|
+
function findSdkClaudeBin({
|
|
171
|
+
requireFrom = require,
|
|
172
|
+
platform = process.platform,
|
|
173
|
+
arch = process.arch,
|
|
174
|
+
preferMusl = _hostPrefersMusl(),
|
|
175
|
+
} = {}) {
|
|
176
|
+
let sdkPkgPath;
|
|
177
|
+
try {
|
|
178
|
+
sdkPkgPath = path.join(path.dirname(requireFrom.resolve(SDK_PACKAGE)), 'package.json');
|
|
179
|
+
} catch (e) {
|
|
180
|
+
return { ok: false, reason: `${SDK_PACKAGE} not installed (${e.code || e.message})` };
|
|
181
|
+
}
|
|
182
|
+
let sdkPkg;
|
|
183
|
+
try { sdkPkg = JSON.parse(fs.readFileSync(sdkPkgPath, 'utf8')); } catch (e) {
|
|
184
|
+
return { ok: false, reason: `cannot read ${sdkPkgPath}: ${e.message}` };
|
|
185
|
+
}
|
|
186
|
+
const suffixes = platform === 'linux'
|
|
187
|
+
? (preferMusl ? [`linux-${arch}-musl`, `linux-${arch}`] : [`linux-${arch}`, `linux-${arch}-musl`])
|
|
188
|
+
: [`${platform}-${arch}`];
|
|
189
|
+
const sdkRequire = createRequire(sdkPkgPath);
|
|
190
|
+
for (const suffix of suffixes) {
|
|
191
|
+
let bin;
|
|
192
|
+
try { bin = sdkRequire.resolve(`${SDK_PACKAGE}-${suffix}/claude${platform === 'win32' ? '.exe' : ''}`); } catch { continue; }
|
|
193
|
+
let platformPkg;
|
|
194
|
+
try { platformPkg = JSON.parse(fs.readFileSync(path.join(path.dirname(bin), 'package.json'), 'utf8')); } catch { continue; }
|
|
195
|
+
if (platformPkg.version !== sdkPkg.version) {
|
|
196
|
+
return {
|
|
197
|
+
ok: false,
|
|
198
|
+
reason: `${SDK_PACKAGE}-${suffix}@${platformPkg.version} does not match ${SDK_PACKAGE}@${sdkPkg.version}`,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return { ok: true, path: bin, claudeCodeVersion: sdkPkg.claudeCodeVersion, sdkVersion: sdkPkg.version };
|
|
202
|
+
}
|
|
203
|
+
return { ok: false, reason: `no ${SDK_PACKAGE} platform package for ${platform}/${arch}` };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// `claude --help` costs 0.5–1.5s, so it runs at most once per binary path.
|
|
207
|
+
const _helpTextCache = new Map();
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Whether a claude binary accepts a command-line flag, judged by its --help
|
|
211
|
+
* output. Older binaries reject unknown options at startup, so a flag added in
|
|
212
|
+
* a newer CLI must be feature-detected rather than assumed from the pin
|
|
213
|
+
* (overrides and rollbacks can point at older binaries). Failures report false.
|
|
214
|
+
*
|
|
215
|
+
* @param {string} bin
|
|
216
|
+
* @param {string} flag — e.g. '--system-prompt-snapshot'
|
|
217
|
+
* @param {{ logger?: object }} [opts] — a failed --help is warned about once per binary
|
|
218
|
+
* @returns {boolean}
|
|
219
|
+
*/
|
|
220
|
+
function supportsClaudeFlag(bin, flag, { logger = console } = {}) {
|
|
221
|
+
if (!_helpTextCache.has(bin)) {
|
|
222
|
+
let help = '';
|
|
223
|
+
try {
|
|
224
|
+
help = execFileSync(bin, ['--help'], { timeout: 30_000, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
225
|
+
} catch (e) {
|
|
226
|
+
logger?.warn?.(`[claude-bin] \`${bin} --help\` failed (${e.message}); newer claude flags will not be passed to it`);
|
|
227
|
+
}
|
|
228
|
+
_helpTextCache.set(bin, help);
|
|
229
|
+
}
|
|
230
|
+
const escaped = flag.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
231
|
+
return new RegExp(`(^|\\s)${escaped}(?![\\w-])`, 'm').test(_helpTextCache.get(bin));
|
|
117
232
|
}
|
|
118
233
|
|
|
234
|
+
const STALE_TMP_MS = 10 * 60_000;
|
|
235
|
+
|
|
119
236
|
// Remove vendored binaries (and stale .tmp.*) that aren't the live version.
|
|
120
237
|
function _gcVendored(dir, keepVersion, logger) {
|
|
121
238
|
let entries = [];
|
|
@@ -124,11 +241,20 @@ function _gcVendored(dir, keepVersion, logger) {
|
|
|
124
241
|
if (name === keepVersion) continue;
|
|
125
242
|
// Never delete an in-flight copy: a CONCURRENT boot (multi-bot host shares
|
|
126
243
|
// this dir) may be mid-copy into `<keepVersion>.tmp.<pid>.<ts>`; removing it
|
|
127
|
-
// ENOENTs that boot's rename → it falls back to SDK.
|
|
128
|
-
//
|
|
129
|
-
//
|
|
130
|
-
//
|
|
131
|
-
|
|
244
|
+
// ENOENTs that boot's rename → it falls back to SDK. A copy plus its
|
|
245
|
+
// `--version` check finishes within about a minute, so only temp files
|
|
246
|
+
// untouched for longer than STALE_TMP_MS are orphans (a boot killed
|
|
247
|
+
// mid-copy) and are removed. Defense-in-depth: only GC version-shaped names
|
|
248
|
+
// so a misconfigured vendor dir can't nuke unrelated files.
|
|
249
|
+
if (/^\d+\.\d+\.\d+\.tmp\./.test(name)) {
|
|
250
|
+
try {
|
|
251
|
+
const p = path.join(dir, name);
|
|
252
|
+
if (Date.now() - fs.statSync(p).mtimeMs > STALE_TMP_MS) fs.rmSync(p, { force: true });
|
|
253
|
+
} catch (e) {
|
|
254
|
+
logger?.warn?.(`[claude-bin] vendor GC: could not remove ${name}: ${e.message}`);
|
|
255
|
+
}
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
132
258
|
if (!/^\d+\.\d+\.\d+$/.test(name)) continue;
|
|
133
259
|
try { fs.rmSync(path.join(dir, name), { force: true }); } catch (e) {
|
|
134
260
|
logger?.warn?.(`[claude-bin] vendor GC: could not remove ${name}: ${e.message}`);
|
|
@@ -139,14 +265,14 @@ function _gcVendored(dir, keepVersion, logger) {
|
|
|
139
265
|
/**
|
|
140
266
|
* Ensure a polygram-owned copy of the pinned claude binary exists and return
|
|
141
267
|
* its path. Steady state is a single stat (fast). On a cold/pruned host it
|
|
142
|
-
* obtains the binary once
|
|
143
|
-
*
|
|
268
|
+
* obtains the binary once and caches it forever, trying in order: the Agent
|
|
269
|
+
* SDK's platform package, the system install, then `claude install`.
|
|
144
270
|
*
|
|
145
271
|
* @param {string} version
|
|
146
|
-
* @param {{ logger?: object }} [opts]
|
|
272
|
+
* @param {{ logger?: object, sdk?: object }} [opts] — `sdk` is passed to findSdkClaudeBin
|
|
147
273
|
* @returns {{ ok: boolean, path: string, vendored?: boolean, reason?: string }}
|
|
148
274
|
*/
|
|
149
|
-
function ensureVendoredClaudeBin(version, { logger = console } = {}) {
|
|
275
|
+
function ensureVendoredClaudeBin(version, { logger = console, sdk = {} } = {}) {
|
|
150
276
|
// Explicit override wins, unchanged — non-standard installs / CI / tests.
|
|
151
277
|
const override = process.env.ORCHESTRA_CLAUDE_BIN;
|
|
152
278
|
if (override) {
|
|
@@ -173,10 +299,28 @@ function ensureVendoredClaudeBin(version, { logger = console } = {}) {
|
|
|
173
299
|
|| path.join(os.homedir(), '.local', 'share', 'claude', 'versions');
|
|
174
300
|
const systemPath = path.join(versionsDir, version);
|
|
175
301
|
|
|
302
|
+
// (0) copy from the Agent SDK's platform package when it bundles exactly
|
|
303
|
+
// this version. Any mismatch or failed validation falls through.
|
|
304
|
+
const fromSdk = findSdkClaudeBin(sdk);
|
|
305
|
+
if (fromSdk.ok && fromSdk.claudeCodeVersion !== version) {
|
|
306
|
+
logger?.log?.(`[claude-bin] Agent SDK ${fromSdk.sdkVersion} bundles claude v${fromSdk.claudeCodeVersion}, not v${version}; skipping it`);
|
|
307
|
+
} else if (fromSdk.ok) {
|
|
308
|
+
try {
|
|
309
|
+
_atomicCopyExec(fromSdk.path, vendored, version);
|
|
310
|
+
logger?.log?.(`[claude-bin] vendored claude v${version} ← Agent SDK ${fromSdk.sdkVersion} (${fromSdk.path}) → ${vendored}`);
|
|
311
|
+
_gcVendored(dir, version, logger);
|
|
312
|
+
return { ok: true, path: vendored, vendored: true };
|
|
313
|
+
} catch (e) {
|
|
314
|
+
logger?.warn?.(`[claude-bin] Agent SDK copy of claude v${version} rejected (${e.message}); trying ${systemPath}`);
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
logger?.log?.(`[claude-bin] ${fromSdk.reason}; trying ${systemPath}`);
|
|
318
|
+
}
|
|
319
|
+
|
|
176
320
|
// (a) copy from the system install if present.
|
|
177
321
|
if (isExecutable(systemPath)) {
|
|
178
322
|
try {
|
|
179
|
-
_atomicCopyExec(systemPath, vendored);
|
|
323
|
+
_atomicCopyExec(systemPath, vendored, version);
|
|
180
324
|
logger?.log?.(`[claude-bin] vendored claude v${version} ← ${systemPath} → ${vendored}`);
|
|
181
325
|
} catch (e) {
|
|
182
326
|
return { ok: false, path: vendored, reason: `copy ${systemPath} → ${vendored} failed: ${e.message}` };
|
|
@@ -210,7 +354,7 @@ function ensureVendoredClaudeBin(version, { logger = console } = {}) {
|
|
|
210
354
|
return { ok: false, path: vendored, reason: `claude install ${version} ran but ${systemPath} still missing` };
|
|
211
355
|
}
|
|
212
356
|
try {
|
|
213
|
-
_atomicCopyExec(systemPath, vendored);
|
|
357
|
+
_atomicCopyExec(systemPath, vendored, version);
|
|
214
358
|
logger?.log?.(`[claude-bin] installed + vendored claude v${version} → ${vendored}`);
|
|
215
359
|
} catch (e) {
|
|
216
360
|
return { ok: false, path: vendored, reason: `copy after install failed: ${e.message}` };
|
|
@@ -268,6 +412,8 @@ module.exports = {
|
|
|
268
412
|
resolvePinnedClaudeBin,
|
|
269
413
|
verifyPinnedClaudeBin,
|
|
270
414
|
ensureVendoredClaudeBin,
|
|
415
|
+
findSdkClaudeBin,
|
|
416
|
+
supportsClaudeFlag,
|
|
271
417
|
vendorDir,
|
|
272
418
|
CLAUDE_CLI_PINNED_VERSION,
|
|
273
419
|
checkClaudeAuthHealth,
|
|
@@ -58,6 +58,7 @@ const { DEFAULT_TIMEOUT_MS: QUESTION_TIMEOUT_MS } = require('../questions/store'
|
|
|
58
58
|
// /private/tmp drift — one of the original Music-topic failures).
|
|
59
59
|
const { DEFAULT_ATTACHMENT_BASE } = require('./attachment-base');
|
|
60
60
|
const { resolveCompactionWarnConfig } = require('../compaction-warn');
|
|
61
|
+
const { supportsClaudeFlag } = require('../claude-bin');
|
|
61
62
|
const { readContextTokens, contextPct } = require('../context-usage');
|
|
62
63
|
const { runStartupGate } = require('../tmux/startup-gate');
|
|
63
64
|
const {
|
|
@@ -1014,6 +1015,11 @@ class CliProcess extends Process {
|
|
|
1014
1015
|
`DROPPED — it gets re-sent to you or flagged as a lost message. When unsure,`,
|
|
1015
1016
|
'include the id.',
|
|
1016
1017
|
'',
|
|
1018
|
+
'A <channel> message whose text is a slash command (`/name some args`) is a',
|
|
1019
|
+
'request to run that skill: call the Skill tool with `skill` set to `name` and',
|
|
1020
|
+
'`args` set to only the text after `/name` (here `some args`). Never include the',
|
|
1021
|
+
'command name or its leading slash in `args`.',
|
|
1022
|
+
'',
|
|
1017
1023
|
'### Staying responsive on a long task — HARD CONTRACT',
|
|
1018
1024
|
'',
|
|
1019
1025
|
'The user sees NOTHING while you work — no inline text, no tool output reaches',
|
|
@@ -1187,6 +1193,16 @@ class CliProcess extends Process {
|
|
|
1187
1193
|
'else as documents.',
|
|
1188
1194
|
].join('\n'));
|
|
1189
1195
|
|
|
1196
|
+
// Claude Code records the appended system prompt once per conversation
|
|
1197
|
+
// and replays that record on every --resume until compaction. This block
|
|
1198
|
+
// is rebuilt on every spawn (display rules, richText, reply contract), so
|
|
1199
|
+
// turn the recording off to make changes reach resumed chats. Older
|
|
1200
|
+
// binaries reject the option at startup, hence the --help check. Kept
|
|
1201
|
+
// before the variadic --settings / --mcp-config / --add-dir flags.
|
|
1202
|
+
if (supportsClaudeFlag(this.claudeBin, '--system-prompt-snapshot', { logger: this.logger })) {
|
|
1203
|
+
claudeArgs.push('--system-prompt-snapshot', 'off');
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1190
1206
|
// Parity audit P6: honor isolateUserConfig — mirrors tmux pattern at
|
|
1191
1207
|
// lib/process/tmux-process.js:502-505,543-546. Channels ALWAYS uses
|
|
1192
1208
|
// --strict-mcp-config (the bridge requires it), so the MCP half is
|
|
@@ -1277,12 +1293,24 @@ class CliProcess extends Process {
|
|
|
1277
1293
|
// Dev-channels confirmation — always fires under
|
|
1278
1294
|
// --dangerously-load-development-channels.
|
|
1279
1295
|
{ name: 'dev-channels', regex: /WARNING: Loading development channels/i, key: 'Enter' },
|
|
1280
|
-
// Workspace trust prompt — fires on first-time cwd or untrusted.
|
|
1281
|
-
//
|
|
1282
|
-
//
|
|
1283
|
-
//
|
|
1284
|
-
//
|
|
1285
|
-
|
|
1296
|
+
// Workspace trust prompt — fires on first-time cwd or untrusted. Enter
|
|
1297
|
+
// confirms whatever the ❯ cursor is on, so it is only sent once the
|
|
1298
|
+
// pane shows "Yes, I trust this folder" selected:
|
|
1299
|
+
// - 2.1.283 lists "❯ No, exit" first and pre-selects it. Press Down
|
|
1300
|
+
// until the cursor visibly moves (the dialog can render before it
|
|
1301
|
+
// accepts input and drop the first key), then the Yes-selected
|
|
1302
|
+
// trigger below confirms.
|
|
1303
|
+
// - 2.1.158–2.1.220 pre-select "❯ 1. Yes, I trust this folder" → Enter.
|
|
1304
|
+
// - older builds ask "Do you trust the files in this folder?" with
|
|
1305
|
+
// "Yes" pre-selected → Enter.
|
|
1306
|
+
// The menu wraps, so each key waits for two identical-state captures:
|
|
1307
|
+
// a lagging Down must not be followed by a second Down (back to "No")
|
|
1308
|
+
// or by an Enter while its redraw is pending. Both regexes only match
|
|
1309
|
+
// the newest dialog frame; the capture includes scrollback. The
|
|
1310
|
+
// confirming variants share one name, so only one ever fires.
|
|
1311
|
+
{ name: 'trust-select', regex: /❯\s*(?:\d+\.\s*)?No, exit[^\n]*\n\s*(?:\d+\.\s*)?Yes, I trust this folder(?![\s\S]*I trust this folder)/i, key: 'Down', repeat: true, stablePolls: 2 },
|
|
1312
|
+
{ name: 'trust', regex: /❯\s*(?:\d+\.\s*)?Yes, I trust this folder(?![\s\S]*I trust this folder)/i, key: 'Enter', stablePolls: 2 },
|
|
1313
|
+
{ name: 'trust', regex: /trust the files in this folder/i, key: 'Enter' },
|
|
1286
1314
|
// Review F#12 + 2026-06-11 resume-dialog fix: session-age
|
|
1287
1315
|
// "resume-return" prompt on aged sessions. Bare Enter selects the
|
|
1288
1316
|
// pre-selected "Resume from summary" — which literally runs /compact
|
|
@@ -59,7 +59,9 @@ process.stdin.on('end', () => {
|
|
|
59
59
|
}
|
|
60
60
|
let fd;
|
|
61
61
|
try {
|
|
62
|
-
|
|
62
|
+
// Owner-only on creation: payloads carry prompts and tool inputs, and a
|
|
63
|
+
// late hook can recreate the file after cleanup under claude's umask.
|
|
64
|
+
fd = fs.openSync(outPath, 'a', 0o600);
|
|
63
65
|
fs.writeSync(fd, line + '\n');
|
|
64
66
|
} catch (err) {
|
|
65
67
|
process.stderr.write(`water-hook-append: write failed: ${err.message}\n`);
|
|
@@ -305,6 +305,13 @@ function collectToolReceipts(branch) {
|
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
// Attachment rows that may sit between the Workflow notification and the
|
|
309
|
+
// final text without disqualifying the fallback. Claude Code inserts
|
|
310
|
+
// `total_tokens_reminder` (a context-usage reminder) at points the service
|
|
311
|
+
// chooses. Every other attachment type, e.g. a folded `queued_command`,
|
|
312
|
+
// still fails closed.
|
|
313
|
+
const PASSIVE_ATTACHMENT_TYPES = new Set(['total_tokens_reminder']);
|
|
314
|
+
|
|
308
315
|
async function correlateWorkflowCompletionSnapshot({
|
|
309
316
|
transcriptPath,
|
|
310
317
|
byteSize,
|
|
@@ -445,6 +452,9 @@ async function correlateWorkflowCompletionSnapshot({
|
|
|
445
452
|
break;
|
|
446
453
|
}
|
|
447
454
|
if (!content.toolResultOnly) return result('user-content-empty');
|
|
455
|
+
} else if (row.type === 'attachment' && PASSIVE_ATTACHMENT_TYPES.has(row.attachment?.type)) {
|
|
456
|
+
// Informational context injected by Claude Code; it carries no user
|
|
457
|
+
// input or tool traffic, so it cannot change who owns the final text.
|
|
448
458
|
} else if (row.type !== 'assistant') {
|
|
449
459
|
return result('ancestry-row-ineligible');
|
|
450
460
|
}
|
package/lib/tmux/startup-gate.js
CHANGED
|
@@ -31,7 +31,18 @@
|
|
|
31
31
|
* terminates. When `stallMs` is omitted (default), behavior is the pure
|
|
32
32
|
* `deadlineMs` wall-clock exactly as before.
|
|
33
33
|
*
|
|
34
|
-
* Each trigger is one-shot per gate run (tracked by `name` in a Set)
|
|
34
|
+
* Each trigger is one-shot per gate run (tracked by `name` in a Set),
|
|
35
|
+
* unless it sets `repeat: true`: then it fires on every poll where its regex
|
|
36
|
+
* still matches, up to `maxRepeats` (default 10). Use it for a navigation
|
|
37
|
+
* key the TUI may drop while a dialog is still becoming interactive, and pair
|
|
38
|
+
* it with a one-shot confirming trigger that matches only once the
|
|
39
|
+
* navigation is visible in the pane.
|
|
40
|
+
*
|
|
41
|
+
* `stablePolls: n` (default 1) makes a trigger fire only after its regex has
|
|
42
|
+
* matched n consecutive captures. After any key is sent every trigger's
|
|
43
|
+
* streak restarts, so a key is never sent into a frame that may still be
|
|
44
|
+
* redrawing from the previous one (a wrapping menu can otherwise take a
|
|
45
|
+
* lagging second navigation key back to the option it just left).
|
|
35
46
|
*
|
|
36
47
|
* Caller supplies:
|
|
37
48
|
* - runner: object with `captureWide(tmuxName)` and `sendControl(tmuxName, key)`
|
|
@@ -52,7 +63,7 @@ const DEFAULT_SETTLE_MS = 500;
|
|
|
52
63
|
* @param {object} opts
|
|
53
64
|
* @param {object} opts.runner — tmux runner with captureWide + sendControl
|
|
54
65
|
* @param {string} opts.tmuxName — tmux session name to poll
|
|
55
|
-
* @param {Array<{name:string, regex:RegExp, key
|
|
66
|
+
* @param {Array<{name:string, regex:RegExp, key?:string, keys?:string[], repeat?:boolean, maxRepeats?:number, stablePolls?:number}>} opts.triggers
|
|
56
67
|
* @param {RegExp} opts.readySignal — match → resolve
|
|
57
68
|
* @param {number} [opts.deadlineMs=30000] — absolute backstop
|
|
58
69
|
* @param {number} [opts.stallMs] — if set, fail after this much
|
|
@@ -95,6 +106,8 @@ async function runStartupGate({
|
|
|
95
106
|
const deadline = startedAt + deadlineMs;
|
|
96
107
|
const stallEnabled = Number.isFinite(stallMs) && stallMs > 0;
|
|
97
108
|
const seen = new Set();
|
|
109
|
+
const fireCounts = new Map();
|
|
110
|
+
const streaks = new Map();
|
|
98
111
|
const matchedTriggers = [];
|
|
99
112
|
// rc.4: remember the most recent successful pane snapshot. If the gate
|
|
100
113
|
// fails (deadline OR session-gone), include the snapshot in the error
|
|
@@ -175,11 +188,17 @@ async function runStartupGate({
|
|
|
175
188
|
if (pane !== lastPane) lastActivityAt = Date.now();
|
|
176
189
|
lastPane = pane;
|
|
177
190
|
|
|
178
|
-
//
|
|
191
|
+
// Update every trigger's consecutive-match streak, then walk triggers in
|
|
192
|
+
// declaration order — the first (not yet seen) whose streak is long
|
|
193
|
+
// enough wins.
|
|
194
|
+
for (const trigger of triggers) {
|
|
195
|
+
streaks.set(trigger, trigger.regex.test(pane) ? (streaks.get(trigger) || 0) + 1 : 0);
|
|
196
|
+
}
|
|
179
197
|
let matched = false;
|
|
180
198
|
for (const trigger of triggers) {
|
|
181
199
|
if (seen.has(trigger.name)) continue;
|
|
182
|
-
if (
|
|
200
|
+
if (streaks.get(trigger) < (trigger.stablePolls ?? 1)) continue;
|
|
201
|
+
streaks.clear();
|
|
183
202
|
// `keys: [...]` sends a sequence (dialog navigation — e.g. Down,Enter
|
|
184
203
|
// to pick a non-default option); `key:` remains the single-key form.
|
|
185
204
|
// Sequence keys go as separate send-keys calls with a short delay —
|
|
@@ -193,9 +212,13 @@ async function runStartupGate({
|
|
|
193
212
|
logger.warn?.(`[${label}] sendControl(${keySeq[ki]}) failed for trigger=${trigger.name}: ${err.message}`);
|
|
194
213
|
}
|
|
195
214
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
215
|
+
const fired = (fireCounts.get(trigger.name) || 0) + 1;
|
|
216
|
+
fireCounts.set(trigger.name, fired);
|
|
217
|
+
if (!trigger.repeat || fired >= (trigger.maxRepeats ?? 10)) seen.add(trigger.name);
|
|
218
|
+
if (fired === 1) {
|
|
219
|
+
matchedTriggers.push(trigger.name);
|
|
220
|
+
try { onTrigger?.(trigger.name); } catch { /* telemetry must not break the gate */ }
|
|
221
|
+
}
|
|
199
222
|
matched = true;
|
|
200
223
|
// Sending a key is activity — navigating the TUI counts as progress
|
|
201
224
|
// even if the pre-transition pane text was static (e.g. a dialog we
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shumkov/orchestra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Transport-agnostic session engine for Claude Code and the native Codex app-server: spawn, steer, supervise, observe turns, and recover.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"url": "git+https://github.com/shumkov/orchestra.git"
|
|
44
44
|
},
|
|
45
45
|
"optionalDependencies": {
|
|
46
|
-
"@anthropic-ai/claude-agent-sdk": "0.
|
|
46
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.283",
|
|
47
|
+
"@anthropic-ai/sdk": "0.128.0"
|
|
47
48
|
}
|
|
48
49
|
}
|