@brutalsystems/muster 0.8.1 → 0.8.2

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/README.md CHANGED
@@ -55,9 +55,22 @@ driver is an unavailable v1 stub.
55
55
 
56
56
  Before launching a Claude session, open Claude normally in the target directory
57
57
  and complete its workspace-trust review yourself, then exit that setup session.
58
- This is a one-time prerequisite for each directory Claude requires you to trust.
59
- Muster never accepts trust prompts or changes trust settings. An untrusted
60
- directory can block startup; Muster times out and cleans up that launch.
58
+ This is a one-time prerequisite for each directory Claude requires you to trust,
59
+ and trust is **not inherited**: accepting `~/Source/arm` says nothing about
60
+ `~/Source/arm/centrumx`, which still stops at its own dialog. Muster never
61
+ accepts trust prompts or changes trust settings. An untrusted directory blocks
62
+ startup; Muster times out and cleans up that launch.
63
+
64
+ A session sitting on that dialog has no registry record at all, so the timeout
65
+ used to look identical to a hung or crashed launch. Muster now reads
66
+ `hasTrustDialogAccepted` for the working directory out of the profile's
67
+ `.claude.json` when a Claude launch times out with nothing registered, and
68
+ either names the untrusted directory and the one-time fix or rules trust out
69
+ and points at the remaining consent screens — a login prompt, or the
70
+ confirmation Claude asks for the first time a profile uses bypass-permissions
71
+ mode. That read happens only on the failure path and only ever reads. A
72
+ `--kind task` launch into the same directory is the cheap discriminator by
73
+ hand: it runs headless and never sees the dialog.
61
74
 
62
75
  ```sh
63
76
  npm ci
@@ -405,6 +418,19 @@ arrive after startup; this v1 is not an enterprise policy-enforcement layer.
405
418
  Claude permissions and its command sandbox are different mechanisms; neither
406
419
  claim implies that every external tool is OS-sandboxed.
407
420
 
421
+ **`workspace-write` does not fence Claude's Write tool, only its Bash.** This
422
+ is measured, not inferred — see "Write/Bash fence asymmetry" in
423
+ [PROBE_RESULTS.md](./PROBE_RESULTS.md). At `--level work` an agent's Bash write
424
+ outside the working tree is refused with `Operation not permitted`, while the
425
+ Write tool creates the same path successfully. The practical consequence is
426
+ that **an agent can create files outside the tree that it cannot then delete**,
427
+ because creation goes through Write and cleanup goes through Bash. No setting
428
+ Muster writes expresses the missing fence: the alternative, `deny`, blocks the
429
+ Write tool everywhere rather than by path, including inside the tree. Treat
430
+ `work` as "Bash is confined to the workspace", not "writes are". If that
431
+ distinction matters for a given launch, the containment that does hold for both
432
+ is `read`.
433
+
408
434
  OpenCode keeps normal provider/model configuration and launches with `--pure`
409
435
  unless plugins are selected, which disables inherited external plugins.
410
436
  Providers declared under `[opencode.provider]` and a model named by
@@ -13,10 +13,73 @@ import { descendants } from "./processes.js";
13
13
  * reporting anything useful.
14
14
  */
15
15
  export function claudeSessionsDir(env) {
16
+ return join(claudeConfigDir(env), "sessions");
17
+ }
18
+ /** The configuration directory itself, which `claudeSessionsDir` and the
19
+ * workspace-trust read below both hang off. Split out so the two cannot drift:
20
+ * a trust decision read from a different directory than the one the launch
21
+ * records its session in would describe a profile nobody is launching. */
22
+ export function claudeConfigDir(env) {
16
23
  const configured = env.CLAUDE_CONFIG_DIR;
17
24
  if (typeof configured === "string" && configured.length)
18
- return join(configured, "sessions");
19
- return join(env.HOME ?? homedir(), ".claude", "sessions");
25
+ return configured;
26
+ return join(env.HOME ?? homedir(), ".claude");
27
+ }
28
+ /**
29
+ * Whether Claude Code has recorded an accepted workspace-trust dialog for one
30
+ * directory, in the profile a launch would use. Trust is per-directory and is
31
+ * NOT inherited from a parent: a trusted `/Source/arm` says nothing about
32
+ * `/Source/arm/centrumx`, and the child still stops at the dialog.
33
+ *
34
+ * This only ever READS. Muster does not accept the dialog on the operator's
35
+ * behalf — `setWorkspaceTrust` writes that flag into an identity copy Muster
36
+ * itself created, never into the live `~/.claude.json`, and this must not
37
+ * become a way around that.
38
+ *
39
+ * Every failure answers `false`, because the only caller is a diagnostic on a
40
+ * launch that has already failed. A missing, unreadable or malformed file
41
+ * means Muster cannot say trust was accepted, which is exactly what `false`
42
+ * reports here; throwing would replace a useful message with a worse one.
43
+ */
44
+ export async function claudeWorkspaceTrusted(env, cwd) {
45
+ let raw;
46
+ try {
47
+ raw = await readFile(join(claudeConfigDir(env), ".claude.json"), "utf8");
48
+ }
49
+ catch {
50
+ return false;
51
+ }
52
+ try {
53
+ const data = JSON.parse(raw);
54
+ return data.projects?.[cwd]?.hasTrustDialogAccepted === true;
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ }
60
+ /**
61
+ * The message a Claude launch dies with when no session ever registered.
62
+ *
63
+ * A session sitting on a consent screen has no registry record at all, so the
64
+ * timeout looks identical to a hung or crashed launch. Several unrelated
65
+ * screens produce it — workspace trust, login, the first use of
66
+ * bypass-permissions mode — and the old message guessed at two of them
67
+ * together. Trust is the one Muster can actually check, so it is either named
68
+ * or ruled out; the rest are listed only once it has been ruled out.
69
+ *
70
+ * A `--kind task` launch into the same directory is the cheap discriminator:
71
+ * it runs headless and never sees the dialog, so it succeeds where a session
72
+ * hangs.
73
+ */
74
+ export function claudeRegistryDiagnostic(trusted, cwd, configDir) {
75
+ if (!trusted)
76
+ return (`no Claude session registry found: workspace trust has not been ` +
77
+ `accepted for ${cwd} in ${configDir} — accept it once with ` +
78
+ `\`cd ${cwd} && claude\`, then retry (trust is per-directory and is ` +
79
+ `not inherited from a parent directory)`);
80
+ return (`no Claude session registry found (${cwd} is trusted, so check the ` +
81
+ `terminal for a login prompt, or for the one-time confirmation Claude ` +
82
+ `asks for the first time a profile uses bypass-permissions mode)`);
20
83
  }
21
84
  export async function resolveClaude(root, env, deadline) {
22
85
  const dir = claudeSessionsDir(env);
package/dist/run.js CHANGED
@@ -16,7 +16,7 @@ import { LaunchLog } from "./log.js";
16
16
  import { hosts, selectHost } from "./hosts/index.js";
17
17
  import { processRef, isSame, stopTree, delay, descendants, ownedGroup, } from "./identity/processes.js";
18
18
  import { resolveCodex } from "./identity/codex.js";
19
- import { resolveClaude } from "./identity/claude.js";
19
+ import { claudeConfigDir, claudeRegistryDiagnostic, claudeWorkspaceTrusted, resolveClaude, } from "./identity/claude.js";
20
20
  import { openCodeEndpointOwnedBy, resolveOpenCode, } from "./identity/opencode.js";
21
21
  import { codexReachable, threadRejection } from "./reach/codex.js";
22
22
  import { claudeReachable } from "./reach/claude.js";
@@ -486,6 +486,10 @@ export class Muster {
486
486
  : req.runtime === "opencode"
487
487
  ? "no OpenCode session matched the launch endpoint, cwd, and creation window"
488
488
  : "no descendant runtime identity found";
489
+ // Kept so the throw below can tell "nothing ever registered" from a
490
+ // diagnosis the loop actually earned. Only the first case can be about a
491
+ // consent screen; anything later means a session existed.
492
+ const neverRegistered = diagnostic;
489
493
  // `resolveEnv`, not `hostEnv`: this connection is how the thread
490
494
  // `resolveCodex` found gets READ — both its `rejectionOf` screen, where a
491
495
  // non-null answer is fatal, and `codexReachable` at readiness. An
@@ -620,6 +624,13 @@ export class Muster {
620
624
  }
621
625
  await delay(Math.min(250, Math.max(0, deadline - Date.now())));
622
626
  }
627
+ // Resolved here rather than before the launch: this reads the operator's
628
+ // live `.claude.json`, and a launch that is going to work should not pay
629
+ // for it. Failing closed is also wrong before a launch — `--kind task`
630
+ // runs headless and never sees the dialog, so refusing an untrusted
631
+ // directory up front would break task launches that work today.
632
+ if (req.runtime === "claude" && diagnostic === neverRegistered)
633
+ diagnostic = claudeRegistryDiagnostic(await claudeWorkspaceTrusted(resolveEnv, req.cwd), req.cwd, claudeConfigDir(resolveEnv));
623
634
  throw new Error(`${diagnostic} after ${this.config.launch_timeout_sec}s`);
624
635
  }
625
636
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brutalsystems/muster",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Launch instructed, reachable local agent sessions",
5
5
  "type": "module",
6
6
  "engines": {