@mnemom/mnemom 0.17.34-next.1 → 0.17.34-next.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.
Files changed (236) hide show
  1. package/dist/base-url-proxy.mjs +18 -4
  2. package/dist/commands/agent-config.js +5 -1
  3. package/dist/commands/agent-doctor.d.ts +9 -0
  4. package/dist/commands/agent-doctor.js +4 -0
  5. package/dist/commands/agent-run.d.ts +14 -6
  6. package/dist/commands/agent-run.js +44 -27
  7. package/dist/commands/agent-session.d.ts +1 -2
  8. package/dist/commands/agent-session.js +1 -2
  9. package/dist/commands/agent-setup.d.ts +6 -0
  10. package/dist/commands/agent-setup.js +12 -1
  11. package/dist/commands/agent-share-test-issuer.d.ts +67 -0
  12. package/dist/commands/agent-share-test-issuer.js +139 -0
  13. package/dist/commands/agent-share.d.ts +7 -1
  14. package/dist/commands/agent-share.js +14 -4
  15. package/dist/commands/agent.d.ts +18 -5
  16. package/dist/commands/agent.js +186 -59
  17. package/dist/commands/durable-doctor.d.ts +50 -0
  18. package/dist/commands/durable-doctor.js +186 -0
  19. package/dist/commands/durable-lock.d.ts +261 -0
  20. package/dist/commands/durable-lock.js +600 -0
  21. package/dist/commands/durable-sessions.d.ts +87 -0
  22. package/dist/commands/durable-sessions.js +303 -0
  23. package/dist/commands/durable-verbs.d.ts +116 -0
  24. package/dist/commands/durable-verbs.js +393 -0
  25. package/dist/commands/scan.d.ts +12 -1
  26. package/dist/commands/scan.js +22 -3
  27. package/dist/commands/wrap.js +1 -1
  28. package/dist/durable/adopt-live.js +5 -8
  29. package/dist/durable/adopt.d.ts +8 -0
  30. package/dist/durable/adopt.js +27 -6
  31. package/dist/durable/cwd-rule.d.ts +9 -1
  32. package/dist/durable/cwd-rule.js +18 -0
  33. package/dist/durable/flock.d.ts +26 -0
  34. package/dist/durable/flock.js +80 -0
  35. package/dist/durable/launch-spec.d.ts +9 -1
  36. package/dist/durable/launch-spec.js +11 -4
  37. package/dist/durable/seat-proxy-entry.d.ts +11 -0
  38. package/dist/durable/seat-proxy-entry.js +25 -0
  39. package/dist/durable/seat-proxy.d.ts +107 -0
  40. package/dist/durable/seat-proxy.js +599 -0
  41. package/dist/durable/seat-socket.d.ts +46 -0
  42. package/dist/durable/seat-socket.js +179 -0
  43. package/dist/durable/seat-spec-validator.d.ts +28 -0
  44. package/dist/durable/seat-spec-validator.js +59 -0
  45. package/dist/durable/test-mode.mjs +105 -0
  46. package/dist/durable/turn-chain.d.ts +55 -0
  47. package/dist/durable/turn-chain.js +178 -0
  48. package/dist/host/auto-continue.d.ts +67 -0
  49. package/dist/host/auto-continue.js +118 -0
  50. package/dist/host/bootid.d.ts +13 -0
  51. package/dist/host/bootid.js +41 -0
  52. package/dist/host/client.d.ts +125 -0
  53. package/dist/host/client.js +171 -0
  54. package/dist/host/commands.d.ts +2 -0
  55. package/dist/host/commands.js +122 -0
  56. package/dist/host/control.d.ts +33 -0
  57. package/dist/host/control.js +144 -0
  58. package/dist/host/daemon.d.ts +221 -0
  59. package/dist/host/daemon.js +616 -0
  60. package/dist/host/gate.d.ts +46 -0
  61. package/dist/host/gate.js +82 -0
  62. package/dist/host/grant.d.ts +24 -0
  63. package/dist/host/grant.js +24 -0
  64. package/dist/host/instance.d.ts +35 -0
  65. package/dist/host/instance.js +62 -0
  66. package/dist/host/integrity.d.ts +35 -0
  67. package/dist/host/integrity.js +115 -0
  68. package/dist/host/launchd.d.ts +16 -0
  69. package/dist/host/launchd.js +45 -0
  70. package/dist/host/lock.d.ts +20 -0
  71. package/dist/host/lock.js +63 -0
  72. package/dist/host/owner.d.ts +58 -0
  73. package/dist/host/owner.js +123 -0
  74. package/dist/host/plist.d.ts +16 -0
  75. package/dist/host/plist.js +85 -0
  76. package/dist/host/procs.d.ts +27 -0
  77. package/dist/host/procs.js +105 -0
  78. package/dist/host/run.d.ts +65 -0
  79. package/dist/host/run.js +299 -0
  80. package/dist/host/runtime.d.ts +8 -0
  81. package/dist/host/runtime.js +22 -0
  82. package/dist/host/s1-names.d.ts +23 -0
  83. package/dist/host/s1-names.js +22 -0
  84. package/dist/host/seat-credential.d.ts +27 -0
  85. package/dist/host/seat-credential.js +41 -0
  86. package/dist/host/seat-launch-main.d.ts +1 -0
  87. package/dist/host/seat-launch-main.js +59 -0
  88. package/dist/host/seat-launch.d.ts +116 -0
  89. package/dist/host/seat-launch.js +302 -0
  90. package/dist/host/seat.d.ts +48 -0
  91. package/dist/host/seat.js +149 -0
  92. package/dist/host/state.d.ts +33 -0
  93. package/dist/host/state.js +117 -0
  94. package/dist/host/status.d.ts +101 -0
  95. package/dist/host/status.js +307 -0
  96. package/dist/host/tmux.d.ts +56 -0
  97. package/dist/host/tmux.js +182 -0
  98. package/dist/host/transcript.d.ts +30 -0
  99. package/dist/host/transcript.js +130 -0
  100. package/dist/host/verbs.d.ts +52 -0
  101. package/dist/host/verbs.js +282 -0
  102. package/dist/index.d.ts +8 -6
  103. package/dist/index.js +209 -43
  104. package/dist/lib/agent.d.ts +13 -29
  105. package/dist/lib/agent.js +17 -29
  106. package/dist/lib/claude-bin.d.ts +6 -0
  107. package/dist/lib/claude-bin.js +26 -0
  108. package/dist/lib/claude-plugin.d.ts +11 -2
  109. package/dist/lib/claude-plugin.js +10 -1
  110. package/dist/lib/commit-report.d.ts +5 -4
  111. package/dist/lib/commit-report.js +6 -9
  112. package/dist/lib/config.d.ts +8 -1
  113. package/dist/lib/config.js +28 -0
  114. package/dist/lib/durable/api.d.ts +136 -0
  115. package/dist/lib/durable/api.js +220 -0
  116. package/dist/lib/durable/codes.d.ts +8 -0
  117. package/dist/lib/durable/codes.js +2 -0
  118. package/dist/lib/durable/gate.d.ts +48 -0
  119. package/dist/lib/durable/gate.js +122 -0
  120. package/dist/lib/durable/handover.d.ts +101 -0
  121. package/dist/lib/durable/handover.js +175 -0
  122. package/dist/lib/durable/launch.d.ts +199 -0
  123. package/dist/lib/durable/launch.js +461 -0
  124. package/dist/lib/durable/launching.d.ts +15 -0
  125. package/dist/lib/durable/launching.js +70 -0
  126. package/dist/lib/durable/live.d.ts +190 -0
  127. package/dist/lib/durable/live.js +633 -0
  128. package/dist/lib/durable/refusal.d.ts +57 -0
  129. package/dist/lib/durable/refusal.js +78 -0
  130. package/dist/lib/durable/view.d.ts +83 -0
  131. package/dist/lib/durable/view.js +244 -0
  132. package/dist/lib/experimental.d.ts +0 -9
  133. package/dist/lib/experimental.js +18 -17
  134. package/dist/lib/launcher-config.d.ts +13 -0
  135. package/dist/lib/launcher-config.js +32 -0
  136. package/dist/lib/runner/exec-append.d.ts +15 -0
  137. package/dist/lib/runner/exec-append.js +2 -0
  138. package/dist/lib/runner/executor-client.d.ts +2 -1
  139. package/dist/lib/runner/executor-state.d.ts +10 -0
  140. package/dist/lib/runner/executor-state.js +24 -0
  141. package/dist/lib/runner/github-base.d.ts +24 -0
  142. package/dist/lib/runner/github-base.js +27 -0
  143. package/dist/lib/runner/job.d.ts +9 -4
  144. package/dist/lib/runner/job.js +43 -15
  145. package/dist/lib/runner/oidc.d.ts +3 -2
  146. package/dist/lib/runner/oidc.js +7 -4
  147. package/dist/lib/runner/options.d.ts +6 -0
  148. package/dist/lib/runner/options.js +19 -1
  149. package/dist/lib/runner/phases.d.ts +7 -4
  150. package/dist/lib/runner/phases.js +8 -4
  151. package/dist/lib/runner/proxy.d.ts +5 -1
  152. package/dist/lib/runner/proxy.js +7 -1
  153. package/dist/lib/scan/cost-per-pr.d.ts +93 -0
  154. package/dist/lib/scan/cost-per-pr.js +101 -0
  155. package/dist/lib/scan/record.d.ts +27 -1
  156. package/dist/lib/scan/record.js +114 -16
  157. package/dist/lib/scan/report-email.d.ts +26 -6
  158. package/dist/lib/scan/report-email.js +32 -3
  159. package/dist/lib/scan/scan.d.ts +3 -0
  160. package/dist/lib/scan/scan.js +13 -1
  161. package/dist/lib/subscription-login.d.ts +15 -0
  162. package/dist/lib/subscription-login.js +28 -1
  163. package/dist/vendor/durable-contract/index.js +240 -18
  164. package/dist/vendor/shared/durable-contract/admission.d.ts +240 -0
  165. package/dist/vendor/shared/durable-contract/admission.js +533 -0
  166. package/dist/vendor/shared/durable-contract/arm.d.ts +51 -0
  167. package/dist/vendor/shared/durable-contract/arm.js +133 -0
  168. package/dist/vendor/shared/durable-contract/canonical.d.ts +29 -0
  169. package/dist/vendor/shared/durable-contract/canonical.js +98 -0
  170. package/dist/vendor/shared/durable-contract/cell-id.d.ts +22 -0
  171. package/dist/vendor/shared/durable-contract/cell-id.js +38 -0
  172. package/dist/vendor/shared/durable-contract/cli-output.d.ts +342 -0
  173. package/dist/vendor/shared/durable-contract/cli-output.js +201 -0
  174. package/dist/vendor/shared/durable-contract/cli-surface.d.ts +119 -0
  175. package/dist/vendor/shared/durable-contract/cli-surface.js +270 -0
  176. package/dist/vendor/shared/durable-contract/codes.d.ts +537 -0
  177. package/dist/vendor/shared/durable-contract/codes.js +475 -0
  178. package/dist/vendor/shared/durable-contract/constants.d.ts +153 -0
  179. package/dist/vendor/shared/durable-contract/constants.js +179 -0
  180. package/dist/vendor/shared/durable-contract/doors.d.ts +119 -0
  181. package/dist/vendor/shared/durable-contract/doors.js +249 -0
  182. package/dist/vendor/shared/durable-contract/envelope.d.ts +103 -0
  183. package/dist/vendor/shared/durable-contract/envelope.js +317 -0
  184. package/dist/vendor/shared/durable-contract/events.d.ts +147 -0
  185. package/dist/vendor/shared/durable-contract/events.js +630 -0
  186. package/dist/vendor/shared/durable-contract/executor-state.d.ts +41 -0
  187. package/dist/vendor/shared/durable-contract/executor-state.js +32 -0
  188. package/dist/vendor/shared/durable-contract/fixlines.d.ts +318 -0
  189. package/dist/vendor/shared/durable-contract/fixlines.js +483 -0
  190. package/dist/vendor/shared/durable-contract/freeze-record.d.ts +787 -0
  191. package/dist/vendor/shared/durable-contract/freeze-record.js +361 -0
  192. package/dist/vendor/shared/durable-contract/index.d.ts +36 -0
  193. package/dist/vendor/shared/durable-contract/index.js +37 -0
  194. package/dist/vendor/shared/durable-contract/journal-approvals.d.ts +29 -0
  195. package/dist/vendor/shared/durable-contract/journal-approvals.js +60 -0
  196. package/dist/vendor/shared/durable-contract/keys.d.ts +24 -0
  197. package/dist/vendor/shared/durable-contract/keys.js +66 -0
  198. package/dist/vendor/shared/durable-contract/lock.d.ts +128 -0
  199. package/dist/vendor/shared/durable-contract/lock.js +151 -0
  200. package/dist/vendor/shared/durable-contract/names.d.ts +25 -0
  201. package/dist/vendor/shared/durable-contract/names.js +78 -0
  202. package/dist/vendor/shared/durable-contract/owner-verbs.d.ts +175 -0
  203. package/dist/vendor/shared/durable-contract/owner-verbs.js +403 -0
  204. package/dist/vendor/shared/durable-contract/paths.d.ts +23 -0
  205. package/dist/vendor/shared/durable-contract/paths.js +35 -0
  206. package/dist/vendor/shared/durable-contract/pure-fn.d.ts +48 -0
  207. package/dist/vendor/shared/durable-contract/pure-fn.js +89 -0
  208. package/dist/vendor/shared/durable-contract/routes.d.ts +205 -0
  209. package/dist/vendor/shared/durable-contract/routes.js +315 -0
  210. package/dist/vendor/shared/durable-contract/schema.d.ts +126 -0
  211. package/dist/vendor/shared/durable-contract/schema.js +441 -0
  212. package/dist/vendor/shared/durable-contract/seal.d.ts +54 -0
  213. package/dist/vendor/shared/durable-contract/seal.js +99 -0
  214. package/dist/vendor/shared/durable-contract/secret-scope.d.ts +28 -0
  215. package/dist/vendor/shared/durable-contract/secret-scope.js +76 -0
  216. package/dist/vendor/shared/durable-contract/session-id.d.ts +21 -0
  217. package/dist/vendor/shared/durable-contract/session-id.js +58 -0
  218. package/dist/vendor/shared/durable-contract/spec.d.ts +162 -0
  219. package/dist/vendor/shared/durable-contract/spec.js +286 -0
  220. package/dist/vendor/shared/durable-contract/states.d.ts +96 -0
  221. package/dist/vendor/shared/durable-contract/states.js +218 -0
  222. package/dist/vendor/shared/durable-contract/telemetry.d.ts +94 -0
  223. package/dist/vendor/shared/durable-contract/telemetry.js +180 -0
  224. package/dist/vendor/shared/durable-contract/test-mode.d.ts +62 -0
  225. package/dist/vendor/shared/durable-contract/test-mode.js +140 -0
  226. package/dist/vendor/shared/durable-contract/turn.d.ts +57 -0
  227. package/dist/vendor/shared/durable-contract/turn.js +81 -0
  228. package/dist/vendor/shared/durable-contract/vectors.d.ts +191 -0
  229. package/dist/vendor/shared/durable-contract/vectors.js +208 -0
  230. package/package.json +3 -2
  231. package/plugins/integrity-manifest.json +35 -0
  232. package/plugins/mnemom/hooks/hooks.json +15 -1
  233. package/plugins/mnemom/hooks/register.tsx +60 -2
  234. package/plugins/mnemom/hooks/seat-hello.mjs +116 -0
  235. package/dist/commands/agent-implicit-notice.d.ts +0 -31
  236. package/dist/commands/agent-implicit-notice.js +0 -73
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import { protectionShowCommand, protectionPublishCommand, protectionValidateComm
15
15
  import { agentsListCommand, agentsClaimCommand, agentsMoveCommand } from "./commands/agents.js";
16
16
  import { agentExportCommand, liveExportDeps } from "./commands/agent-export.js";
17
17
  import { agentShareCommand, liveAgentShareDeps } from "./commands/agent-share.js";
18
- import { agentShareFixtureEnabled, fixtureAgentShareParts, } from "./commands/agent-share-fixture.js";
18
+ import { selectAgentShareDeps } from "./commands/agent-share-test-issuer.js";
19
19
  import { agentSessionsCommand, agentShowCommand, liveSessionDeps, } from "./commands/agent-sessions.js";
20
20
  import { agentGoalPinCommand, agentGoalResetCommand, agentGoalShowCommand, liveGoalDeps, } from "./commands/agent-goal.js";
21
21
  import { agentFuelCommand, liveFuelDeps } from "./commands/agent-fuel.js";
@@ -37,14 +37,13 @@ import { agentDoctorCommand } from "./commands/agent-doctor.js";
37
37
  import { agentSetupCommand, parseGovernanceFlag } from "./commands/agent-setup.js";
38
38
  import { agentInviteCommand, runAgentInvocation } from "./commands/agent-invite.js";
39
39
  import { agentFirstRunCommand, offerFirstRunOnLaunch } from "./commands/agent-first-run.js";
40
- import { showImplicitDefaultNoticeOnce } from "./commands/agent-implicit-notice.js";
41
- import { isPrerelease } from "./lib/update/semver.js";
42
- import { applyConfigToEnv, launcherEntries, loadLauncherConfig, withoutDisabledExperimental, } from "./lib/launcher-config.js";
43
- import { loadExperimentalState } from "./lib/cli-config.js";
44
- import { assertEnabled, availableFeatures, EXPERIMENTAL_CONTRACT, gateCheck, ignoredSettingLines, reportCliError, } from "./lib/experimental.js";
40
+ import { applyConfigToEnv, durableLauncherKey, launcherEntries, loadLauncherConfig, withoutDisabledExperimental, } from "./lib/launcher-config.js";
41
+ import { loadCliConfig, loadExperimentalState } from "./lib/cli-config.js";
42
+ import { isSeatProxyArgv, runSeatProxyEntry } from "./durable/seat-proxy-entry.js";
43
+ import { assertEnabled, EXPERIMENTAL_CONTRACT, gateCheck, ignoredSettingLines, reportCliError, } from "./lib/experimental.js";
45
44
  import { durableVerbOffLines } from "./durable/gate.js";
46
45
  import { experimentalDisableCommand, experimentalEnableCommand, experimentalListCommand, runExperimentalMigration, } from "./commands/experimental.js";
47
- import { parseCompactAt, parseContextProfile, passthroughIsPrint, resolveImplicitSource, selectLaunchAgent, splitSessionArg, } from "./lib/agent.js";
46
+ import { parseCompactAt, parseContextProfile, resolveImplicit, selectLaunchAgent, splitSessionArg, } from "./lib/agent.js";
48
47
  import { wrapCommand } from "./commands/wrap.js";
49
48
  import { onboardCommand } from "./commands/onboard.js";
50
49
  import { skillsListCommand, skillsDescribeCommand } from "./commands/skills.js";
@@ -54,6 +53,16 @@ import { updateCommand } from "./commands/update.js";
54
53
  import { runAction } from "./lib/update/action.js";
55
54
  import { configListCommand, configGetCommand, configSetCommand, configUnsetCommand, } from "./commands/config.js";
56
55
  import { defaultStartupDeps, maybeRunUpdateHook } from "./lib/update/startup.js";
56
+ import { durableActionGate, durableGate, durableOn, optionShapesOf, } from "./lib/durable/gate.js";
57
+ import { durableSessionsCommand, durableShowCommand } from "./commands/durable-sessions.js";
58
+ import { durablePreflight } from "./lib/durable/launch.js";
59
+ import { durableRefusalExit } from "./lib/durable/refusal.js";
60
+ import { liveDoctorDurableLines, liveLockVerbDeps, liveSessionsReadDeps, liveVerbDeps, } from "./lib/durable/live.js";
61
+ import { amendCommand, containmentCommand, ownerVerbCommand, unlockCommand, } from "./commands/durable-verbs.js";
62
+ import { lockCommand } from "./commands/durable-lock.js";
63
+ import { registerHostCommands } from "./host/commands.js";
64
+ import { hostArgvGate } from "./host/gate.js";
65
+ import { homedir } from "node:os";
57
66
  program
58
67
  .name("mnemom")
59
68
  .description("Transparent AI agent tracing")
@@ -122,14 +131,11 @@ program
122
131
  // ── experimental features (lib/experimental.ts) ── While a feature is off its flags and
123
132
  // commands are hidden from --help (decided once, at load) and using one fails with a
124
133
  // pointer to `mnemom experimental enable <id>` (decided per invocation, in the action).
125
- // A prerelease (`next`) build also makes PRERELEASE_AVAILABLE usable (door one's T16).
126
- const PRERELEASE_BUILD = isPrerelease(CLI_VERSION);
127
- const loadAvailableFeatures = () => availableFeatures(loadExperimentalState().enabled, PRERELEASE_BUILD);
128
- const experimentalAtLoad = loadAvailableFeatures();
134
+ const experimentalAtLoad = loadExperimentalState().enabled;
129
135
  const hiddenUnless = (id) => !experimentalAtLoad.includes(id);
130
136
  /** preAction guard for a gated command: print the guidance and exit 2 while `id` is off. */
131
137
  function requireExperimental(what, id) {
132
- const message = gateCheck(what, id, loadAvailableFeatures());
138
+ const message = gateCheck(what, id, loadExperimentalState().enabled);
133
139
  if (message) {
134
140
  console.error(message);
135
141
  process.exit(2);
@@ -153,6 +159,8 @@ function printAgentHelp(verb) {
153
159
  : undefined;
154
160
  (sub ?? agentCmd).outputHelp();
155
161
  }
162
+ // `agent --new` is a durable option: held here so DURABLE_GATED_OPTIONS can name it.
163
+ const agentNewOption = new Option("--new", "EXPERIMENTAL (`mnemom experimental enable durable`): start a fresh session under this name; never continue one").hideHelp(hiddenUnless("durable"));
156
164
  const agentCmd = program
157
165
  .command("agent [session] [passthrough...]")
158
166
  .description("Launch your governed agent (Claude Code in v1) through the Mnemom gateway — governed identity + optional sealed goal contract. Plain `mnemom agent` asks for a session name. " +
@@ -172,7 +180,7 @@ const agentCmd = program
172
180
  "platform cards (strictest wins). See `mnemom protection` for that mode.")
173
181
  .option("--lead-directed", "Seal the standard lead-directed requirement: own-branch push and draft/ready PR creation, " +
174
182
  "from a git worktree, on the lead's direction — not merging. Requires --goal; idempotent.")
175
- .addOption(new Option("--implicit", "EXPERIMENTAL (`mnemom experimental enable implicit`): implicit goal alignment — the gateway infers the goal from your messages and revises it as you steer (the default while the feature is on, and on a `next` build for every launch but `-p`; not combinable with --goal/--requirement/--allow/--forbid/--goal-id/--mode/--lead-directed; the guardrail ceilings still apply)").hideHelp(hiddenUnless("implicit")))
183
+ .addOption(new Option("--implicit", "EXPERIMENTAL (`mnemom experimental enable implicit`): implicit goal alignment — the gateway infers the goal from your messages and revises it as you steer (the default while the feature is on; not combinable with --goal/--requirement/--allow/--forbid/--goal-id/--mode/--lead-directed; the guardrail ceilings still apply)").hideHelp(hiddenUnless("implicit")))
176
184
  .option("--no-implicit", "Turn implicit goal alignment OFF for this launch (overrides launcher.toml goal_mode = implicit)")
177
185
  .option("--conversation-id <id>", "x-mnemom-conversation-id (default: auto-generated)")
178
186
  .option("--cli <name|path>", "Coding-agent CLI to launch: a name or full path (default: claude)")
@@ -234,6 +242,7 @@ const agentCmd = program
234
242
  }
235
243
  return v;
236
244
  }))
245
+ .addOption(agentNewOption)
237
246
  .addOption(new Option("--context-handoff", "EXPERIMENTAL (`mnemom experimental enable context-handoff`): register the `handoff(note)` MCP tool and tell the gateway to turn on the context-handoff capability for this session").hideHelp(hiddenUnless("context-handoff")))
238
247
  .option("--no-context-handoff", "Keep context handoff off for this launch even when launcher.toml (context_handoff = true) or MNEMOM_AGENT_CONTEXT_HANDOFF turns it on")
239
248
  .option("--compaction-intercept", "Turn the compaction intercept on for this launch even when launcher.toml (compaction_intercept = false) or MNEMOM_AGENT_COMPACTION_INTERCEPT=0 turns it off. On by default: the gateway reports the real context size (so Claude Code compacts at its own threshold) and answers the compaction at once from its fold")
@@ -264,14 +273,18 @@ const agentCmd = program
264
273
  });
265
274
  }
266
275
  catch (error) {
276
+ const durableExit = durableRefusalExit(error, {
277
+ out: (l) => process.stdout.write(`${l}\n`),
278
+ err: (l) => console.error(l),
279
+ });
280
+ if (durableExit !== null)
281
+ process.exit(durableExit);
267
282
  const report = reportCliError(error);
268
283
  console.error(...report.args);
269
284
  process.exit(report.code);
270
285
  }
271
286
  async function launchAgent(scenario) {
272
287
  const experimental = loadExperimentalState().enabled;
273
- // What a flag, key or command may use: the enabled features, plus implicit on `next`.
274
- const available = availableFeatures(experimental, PRERELEASE_BUILD);
275
288
  // The one place the flag's raw string becomes `number | null` (see the argParser's
276
289
  // comment for why commander can't carry `null` through parseArg directly). Already
277
290
  // validated by the argParser, so this never throws.
@@ -279,7 +292,7 @@ const agentCmd = program
279
292
  // Sub-verb: `mnemom agent config …` manages persistent settings and never
280
293
  // launches. (A scenario literally named "config" is reserved for this.)
281
294
  if (scenario === "config") {
282
- await agentConfigCommand(passthrough, { enabled: available });
295
+ await agentConfigCommand(passthrough, { enabled: experimental });
283
296
  return;
284
297
  }
285
298
  // Sub-verb: `mnemom agent slack …` posts/receives Slack messages as this
@@ -299,7 +312,8 @@ const agentCmd = program
299
312
  used: opts.contextHandoff === true,
300
313
  },
301
314
  { what: "--implicit", id: "implicit", used: opts.implicit === true },
302
- ], available);
315
+ { what: "--new", id: "durable", used: opts.new === true },
316
+ ], experimental);
303
317
  if (opts.gateway)
304
318
  process.env.MNEMOM_AGENT_GATEWAY = opts.gateway;
305
319
  // Persistent settings (~/.mnemom/launcher.toml) sit UNDER env and flags:
@@ -312,11 +326,11 @@ const agentCmd = program
312
326
  for (const line of ignoredSettingLines({
313
327
  entries: launcherEntries(rawCfg),
314
328
  env: process.env,
315
- enabled: available,
329
+ enabled: experimental,
316
330
  })) {
317
331
  console.error(line);
318
332
  }
319
- const cfg = withoutDisabledExperimental(rawCfg, available);
333
+ const cfg = withoutDisabledExperimental(rawCfg, experimental);
320
334
  applyConfigToEnv(cfg, process.env);
321
335
  // Sub-verb: `mnemom agent doctor` runs a read-only preflight and never
322
336
  // launches. Placed after config load so it reports the effective settings.
@@ -326,7 +340,11 @@ const agentCmd = program
326
340
  return;
327
341
  }
328
342
  if (scenario === "doctor") {
329
- await agentDoctorCommand({ cli: opts.cli, agent: program.opts().agent ?? cfg.agent });
343
+ await agentDoctorCommand({
344
+ cli: opts.cli,
345
+ agent: program.opts().agent ?? cfg.agent,
346
+ ...(experimental.includes("durable") ? { durable: liveDoctorDurableLines } : {}),
347
+ });
330
348
  return;
331
349
  }
332
350
  // Validated up front so a typo fails before any sign-in or provisioning.
@@ -337,6 +355,7 @@ const agentCmd = program
337
355
  await agentSetupCommand({
338
356
  ...selectLaunchAgent({
339
357
  flag: program.opts().agent,
358
+ env: process.env.MNEMOM_AGENT,
340
359
  configAgent: cfg.agent,
341
360
  configAgentId: cfg.agentId,
342
361
  }),
@@ -349,22 +368,14 @@ const agentCmd = program
349
368
  const numToStr = (n) => n === undefined ? undefined : String(n);
350
369
  // Implicit mode: --implicit / --no-implicit win; a --goal statement seals
351
370
  // (the standing config default never overrides it); else launcher.toml
352
- // `goal_mode`; else implicit while the `implicit` feature is on; else, on a
353
- // `next` build, implicit unless the launch is headless `-p` (T16); else off.
354
- // Pure + unit-tested in lib/agent.ts.
355
- const goalMode = resolveImplicitSource({
371
+ // `goal_mode`; else implicit while the `implicit` feature is on, off while it is
372
+ // off. Pure + unit-tested in lib/agent.ts.
373
+ const implicit = resolveImplicit({
356
374
  goal: opts.goal,
357
375
  implicit: opts.implicit,
358
376
  configGoalMode: cfg.goalMode,
359
377
  experimentalOn: experimental.includes("implicit"),
360
- prerelease: PRERELEASE_BUILD,
361
- print: passthroughIsPrint(passthrough),
362
378
  });
363
- const implicit = goalMode.implicit;
364
- // The T16 default tells the user once, the first time it applies.
365
- if (implicit && goalMode.source === "prerelease") {
366
- showImplicitDefaultNoticeOnce({ dryRun: opts.dryRun });
367
- }
368
379
  // Config guardrails apply only when goal alignment is actually intended (a
369
380
  // --goal is present, or implicit mode — where they ride on the mode header),
370
381
  // so a saved ceiling never forces an unrequested contract (which would
@@ -374,6 +385,21 @@ const agentCmd = program
374
385
  // shadows a subcommand `--agent` under commander@12 — the MNE-238 class),
375
386
  // exactly as status/logs/onboard read it.
376
387
  const parentOpts = program.opts();
388
+ // Durable (gate on only, BACKBONE C1): refusals decided before any registry call or spawn
389
+ // (nested launch, --server, the S1 name grammar); the registry plan runs in agentCommand.
390
+ const durableOn = experimental.includes("durable");
391
+ // MNEMOM_AGENT_DURABLE wins over launcher.toml `durable` for this launch.
392
+ const durableKey = durableLauncherKey(process.env, cfg.durable);
393
+ if (durableOn) {
394
+ const refusal = durablePreflight({
395
+ name: scenario,
396
+ env: process.env,
397
+ server: opts.server === true,
398
+ launcherKey: durableKey,
399
+ });
400
+ if (refusal !== null)
401
+ throw refusal;
402
+ }
377
403
  // First interactive launch only: offer (opt-in) the local look at what Mnemom
378
404
  // would have saved. Tracked in ~/.mnemom/first-run.json; never blocks the launch.
379
405
  await offerFirstRunOnLaunch({ dryRun: opts.dryRun });
@@ -389,9 +415,10 @@ const agentCmd = program
389
415
  maxTurns: opts.maxTurns ?? (contractIntended ? numToStr(cfg.guardrails?.maxTurns) : undefined),
390
416
  stall: opts.stall ?? (contractIntended ? numToStr(cfg.guardrails?.stallTurns) : undefined),
391
417
  mode: opts.mode,
392
- // --agent wins; else launcher.toml agent_id (a pin) over agent (a name).
418
+ // --agent wins, then MNEMOM_AGENT; else launcher.toml agent_id (a pin) over agent (a name).
393
419
  ...selectLaunchAgent({
394
420
  flag: parentOpts.agent,
421
+ env: process.env.MNEMOM_AGENT,
395
422
  configAgent: cfg.agent,
396
423
  configAgentId: cfg.agentId,
397
424
  }),
@@ -423,6 +450,9 @@ const agentCmd = program
423
450
  keySource: cfg.keySource,
424
451
  passthrough,
425
452
  dryRun: opts.dryRun,
453
+ ...(durableOn
454
+ ? { durable: { launcherKey: durableKey, newSession: opts.new === true } }
455
+ : {}),
426
456
  });
427
457
  }
428
458
  });
@@ -848,6 +878,7 @@ policyCmd
848
878
  // ============================================================================
849
879
  // Agent management — sub-verbs of `mnemom agent` (the launcher above): list / claim / move.
850
880
  // ============================================================================
881
+ const agentHostCmd = registerHostCommands(agentCmd, hiddenUnless("durable"));
851
882
  agentCmd
852
883
  .command("list")
853
884
  .description("List the agents in your active org (set with `mnemom org use`), or every org you belong to if none is set (ADR-062 org-scoped)")
@@ -918,10 +949,11 @@ agentCmd
918
949
  .action(async (idOrName, opts) => {
919
950
  process.exitCode = await agentExportCommand(idOrName, opts, liveExportDeps);
920
951
  });
921
- // Hidden until MNEMOM_AGENT_SHARE=1 (MNE-9037): with the flag off the command behaves as unknown.
952
+ // Hidden from help; runnable only with MNEMOM_AGENT_SHARE=1 (MNE-9037) or when the CLI targets the
953
+ // test cell (MNEMOM_RING=test / test API + website): otherwise it behaves as unknown.
922
954
  agentCmd
923
955
  .command("share", { hidden: true })
924
- .description("Build a shareable card from lines of your signed statements and print the share-page link (card in the URL fragment; nothing is posted). Needs MNEMOM_AGENT_SHARE=1")
956
+ .description("Build a shareable card from lines of your signed statements and print the share-page link (card in the URL fragment; nothing is posted). Needs MNEMOM_AGENT_SHARE=1 (not needed on the test ring)")
925
957
  .option("--lines <ids>", "Comma-separated line ids to include (skips the picker)")
926
958
  .option("--period", "Period card: always include reverts (refused if none are available)")
927
959
  .option("--list", "List the lines available to share and exit")
@@ -929,9 +961,9 @@ agentCmd
929
961
  .action(async (opts) => {
930
962
  // MNEMOM_AGENT_SHARE_FIXTURE=1 (with MNEMOM_AGENT_SHARE=1) swaps in the test-only fixture
931
963
  // source/issuer; otherwise the not-yet-connected live deps are used, unchanged.
932
- const deps = agentShareFixtureEnabled()
933
- ? { ...liveAgentShareDeps, ...fixtureAgentShareParts }
934
- : liveAgentShareDeps;
964
+ // Against the TEST cell the test-key issuer is selected by the target, not a flag; the
965
+ // fixture flag is refused anywhere else (agent-share-test-issuer.ts).
966
+ const deps = selectAgentShareDeps(liveAgentShareDeps, process.env);
935
967
  process.exitCode = await agentShareCommand(opts, deps);
936
968
  });
937
969
  const agentSessionsCmd = agentCmd
@@ -941,13 +973,25 @@ const agentSessionsCmd = agentCmd
941
973
  .option("--json", "Output the rows as JSON instead of a table")
942
974
  .action(async (opts) => {
943
975
  try {
944
- await agentSessionsCommand({ all: opts.all, json: opts.json }, liveSessionDeps);
976
+ const ledger = async () => {
977
+ await agentSessionsCommand({ all: opts.all, json: opts.json }, liveSessionDeps);
978
+ return 0;
979
+ };
980
+ // Durable on: the server registry (C01-R12); off: the ledger, exactly as before.
981
+ if (durableOn(loadExperimentalState().enabled))
982
+ process.exitCode = await durableSessionsCommand(opts, liveSessionsReadDeps(), ledger);
983
+ else
984
+ await ledger();
945
985
  }
946
986
  catch (error) {
947
987
  console.error("Error:", error instanceof Error ? error.message : error);
948
988
  process.exit(1);
949
989
  }
950
990
  });
991
+ // `sessions` has no subcommands before M1: its usage line is captured here, before any durable
992
+ // sub-verb (C4 `adopt`, C1 `unlock`) is added, and restored once they are all registered while
993
+ // durable is off (commander counts hidden subcommands in `[command]`; C17-R09).
994
+ const agentSessionsPreM1Usage = agentSessionsCmd.usage();
951
995
  /** preAction (and --help) guard for a durable verb: while durable is off it does not exist (C14-R22). */
952
996
  function requireDurableVerb(word, what) {
953
997
  const lines = durableVerbOffLines(word, what, loadExperimentalState().enabled);
@@ -987,11 +1031,14 @@ const agentSessionsAdoptCmd = agentSessionsCmd
987
1031
  }
988
1032
  });
989
1033
  /**
990
- * The durable-gated commands (BACKBONE Flags/CLI: off lists no durable verb). The committed
991
- * command-tree.json leaves them out whatever the generating machine's experimental state
992
- * (scripts/gen-command-tree.mjs); a piece that registers another durable verb adds it here.
1034
+ * The durable-gated commands and options (BACKBONE Flags/CLI: off lists no durable verb). The
1035
+ * committed command-tree.json leaves them out whatever the generating machine's experimental
1036
+ * state (scripts/gen-command-tree.mjs); --help shows them only once durable is enabled. A piece
1037
+ * that registers another durable verb or option adds it here.
993
1038
  */
994
- export const DURABLE_GATED_COMMANDS = new Set([agentSessionsAdoptCmd]);
1039
+ const durableGatedCommands = new Set([agentHostCmd, agentSessionsAdoptCmd]);
1040
+ export const DURABLE_GATED_COMMANDS = durableGatedCommands;
1041
+ export const DURABLE_GATED_OPTIONS = new Set([agentNewOption]);
995
1042
  // commander answers --help before preAction: gate the help too, so the verb does not exist while off.
996
1043
  const adoptOutputHelp = agentSessionsAdoptCmd.outputHelp.bind(agentSessionsAdoptCmd);
997
1044
  agentSessionsAdoptCmd.outputHelp = ((...args) => {
@@ -1017,13 +1064,92 @@ agentCmd
1017
1064
  }
1018
1065
  followIntervalMs = seconds * 1000;
1019
1066
  }
1020
- await agentShowCommand(ref, { json: opts.json, follow: opts.follow, followIntervalMs }, liveSessionDeps);
1067
+ const ledger = async () => {
1068
+ await agentShowCommand(ref, { json: opts.json, follow: opts.follow, followIntervalMs }, liveSessionDeps);
1069
+ return 0;
1070
+ };
1071
+ // Durable on: resolve the name through the registry (C01-R12, R24); --follow and a ref
1072
+ // the registry does not know stay on the ledger view.
1073
+ if (durableOn(loadExperimentalState().enabled) && !opts.follow)
1074
+ process.exitCode = await durableShowCommand(ref, { json: opts.json }, liveSessionsReadDeps(), ledger);
1075
+ else
1076
+ await ledger();
1021
1077
  }
1022
1078
  catch (error) {
1023
1079
  console.error("Error:", error instanceof Error ? error.message : error);
1024
1080
  process.exit(1);
1025
1081
  }
1026
1082
  });
1083
+ /**
1084
+ * Read an option value the user typed on this parse from `cmd`, then clear it: commander keeps
1085
+ * option values on the command object across parses, so a value left behind would carry into the
1086
+ * next parse of the same program (another amend, or a launch that reads the guardrail).
1087
+ */
1088
+ function takeParentOption(cmd, key) {
1089
+ if (cmd.getOptionValueSource(key) !== "cli")
1090
+ return undefined;
1091
+ const v = cmd.getOptionValue(key);
1092
+ cmd.setOptionValueWithSource(key, undefined, "default");
1093
+ return v;
1094
+ }
1095
+ // ── durable verbs (BACKBONE C1; EXPERIMENTAL `durable`) ── hidden while durable is off, and
1096
+ // unreachable then: runEntrypoint's durable gate exits 2 on these words before commander parses.
1097
+ // Each handler returns its exit status (refusals rendered by lib/durable/refusal.ts).
1098
+ {
1099
+ const hidden = hiddenUnless("durable");
1100
+ // The action-level gate (C17): while durable is off the action exits 2 with the pointer before it
1101
+ // builds any client, for any argv shape that got past runEntrypoint's scan.
1102
+ const exitWith = async (what, run) => {
1103
+ const gated = durableActionGate(what, loadExperimentalState().enabled);
1104
+ if (gated !== null) {
1105
+ console.error(gated);
1106
+ process.exitCode = 2;
1107
+ return;
1108
+ }
1109
+ process.exitCode = await run();
1110
+ };
1111
+ const gate = (cmd) => {
1112
+ durableGatedCommands.add(cmd);
1113
+ return cmd;
1114
+ };
1115
+ gate(agentCmd.command("lock <name>", { hidden }))
1116
+ .description("EXPERIMENTAL (durable): lock a session so the host daemon keeps it running")
1117
+ .option("--own-agent", "Lock even though other sessions share the agent (they are locked too)")
1118
+ .option("--json", "Output the answer as JSON")
1119
+ .action((name, o) => exitWith("`mnemom agent lock`", () => lockCommand(name, o, liveLockVerbDeps())));
1120
+ for (const verb of ["pause", "resume", "done", "kill"]) {
1121
+ gate(agentCmd.command(`${verb} <name>`, { hidden }))
1122
+ .description(`EXPERIMENTAL (durable): ${verb} a session`)
1123
+ .option("--json", "Output the answer as JSON")
1124
+ .action((name, o) => exitWith(`\`mnemom agent ${verb}\``, () => ownerVerbCommand(verb, name, o, liveVerbDeps())));
1125
+ }
1126
+ gate(agentCmd.command("amend <name>", { hidden }))
1127
+ .description("EXPERIMENTAL (durable): lower a session's limits, or raise its budget (approved by device step)")
1128
+ .option("--budget <usd>", "New budget in USD")
1129
+ .option("--turns <n>", "New turn ceiling (lowering only)")
1130
+ .option("--json", "Output the answer as JSON")
1131
+ .action((name, o) => {
1132
+ // `agent` has its own --budget (the launch guardrail), and commander hands an option the
1133
+ // parent knows to the parent wherever it sits in argv: amend's --budget lands there.
1134
+ const budget = takeParentOption(agentCmd, "budget");
1135
+ return exitWith("`mnemom agent amend`", () => amendCommand(name, { ...o, budget }, liveVerbDeps()));
1136
+ });
1137
+ const containmentCmd = gate(agentCmd.command("containment", { hidden })).description("EXPERIMENTAL (durable): org admin containment of an agent (pause | resume)");
1138
+ for (const verb of ["pause", "resume"]) {
1139
+ containmentCmd
1140
+ .command(`${verb} <agent>`)
1141
+ .description(`${verb} every session of an agent (org admin, signed in)`)
1142
+ .action((agent) => exitWith(`\`mnemom agent containment ${verb}\``, () => containmentCommand(verb, agent, liveVerbDeps())));
1143
+ }
1144
+ // `sessions` has no subcommands before M1: keep its usage line byte-identical (commander
1145
+ // counts hidden subcommands in `[command]`). Captured before C4's `adopt` was added too.
1146
+ const sessionsUsage = agentSessionsPreM1Usage;
1147
+ gate(agentSessionsCmd.command("unlock <name>", { hidden }))
1148
+ .description("EXPERIMENTAL (durable): unlock a locked session back to tracked (device step)")
1149
+ .action((name) => exitWith("`mnemom agent sessions unlock`", () => unlockCommand(name, liveVerbDeps())));
1150
+ if (hidden)
1151
+ agentSessionsCmd.usage(sessionsUsage);
1152
+ }
1027
1153
  // `mnemom agent run --watch|--once` — the thin runner (ruling 34.12; Doors W-L13): claim served-phase
1028
1154
  // jobs from the org's ready pool and run their signed phases. Exit 0 done/no_job, 1 failed,
1029
1155
  // 2 usage, 3 refused.
@@ -2291,6 +2417,13 @@ export { program };
2291
2417
  // Parse argv only when invoked as the CLI entrypoint — not when imported.
2292
2418
  // The symlink-safe guard lives in ./lib/entrypoint so it can be unit-tested
2293
2419
  // without executing this module's top-level parse().
2420
+ /**
2421
+ * The value-taking options of the program, `agent` and `agent sessions`: the durable gate steps over
2422
+ * them (and their values) to find the verb word, as commander does before it dispatches.
2423
+ */
2424
+ export function agentOptionShapes() {
2425
+ return optionShapesOf([program, agentCmd, agentSessionsCmd]);
2426
+ }
2294
2427
  /**
2295
2428
  * The entrypoint dispatch. `mnemom agent slack …` owns its own flags (--thread,
2296
2429
  * --channel, …), which the `agent` launcher options would otherwise reject as
@@ -2298,8 +2431,41 @@ export { program };
2298
2431
  * verbatim. Exported (not auto-run) so the bypass is unit-testable.
2299
2432
  */
2300
2433
  export function runEntrypoint(argv = process.argv.slice(2), migrate = runExperimentalMigration) {
2434
+ // The durable seat proxy (C3) is spawned by the host daemon; its stdout carries only READY, so it
2435
+ // runs before the migration and the update hook (durable/seat-proxy-entry.ts holds the gate).
2436
+ if (isSeatProxyArgv(argv)) {
2437
+ runSeatProxyEntry(argv, {
2438
+ stored: () => loadCliConfig().experimental,
2439
+ stderr: (line) => void process.stderr.write(line),
2440
+ exit: (code) => process.exit(code),
2441
+ run: async (rest) => (await import("./durable/seat-proxy.js")).seatProxyMain(rest),
2442
+ });
2443
+ return;
2444
+ }
2301
2445
  // First run after the upgrade that introduced experimental features: keep on whatever
2302
2446
  // launcher.toml already uses (commands/experimental.ts; never throws).
2447
+ // `mnemom agent host …` with durable off: gated before commander's help/usage paths and before
2448
+ // the one-time migration below can write config.json (C17-R10: no HOME write). C2 owns the
2449
+ // `host` word (config.json-only gate for `host run`, C12-R25/R39), so the C1 verb-word gate
2450
+ // below steps aside for it (integration r1: the C1 gate documents "until C2 registers its handler").
2451
+ const hostGate = hostArgvGate(argv, { env: process.env, home: homedir() });
2452
+ if (hostGate) {
2453
+ console.error(hostGate.message);
2454
+ process.exit(hostGate.code);
2455
+ return;
2456
+ }
2457
+ // Durable verb words while `durable` is off: exit 2 with the pointer before commander can
2458
+ // answer --help, and before the one-time migration below can write config.json (BACKBONE
2459
+ // Flags/CLI: no HTTP, no HOME write, no process).
2460
+ const hostArgv = argv[0] === "agent" && argv[1] === "host";
2461
+ const durableGateMessage = hostArgv
2462
+ ? null
2463
+ : durableGate(argv, loadExperimentalState().enabled, agentOptionShapes());
2464
+ if (durableGateMessage !== null) {
2465
+ console.error(durableGateMessage);
2466
+ process.exit(2);
2467
+ return;
2468
+ }
2303
2469
  migrate();
2304
2470
  if (argv[0] === "agent" && argv[1] === "slack") {
2305
2471
  requireExperimental("`mnemom agent slack`", "slack");
@@ -171,13 +171,15 @@ export type AgentRef = {
171
171
  */
172
172
  export declare function parseAgentRef(raw: string): AgentRef;
173
173
  /**
174
- * Which agent a launch asks for, from the three places it can be named. `--agent` (flag) wins
174
+ * Which agent a launch asks for, from the four places it can be named. `--agent` (flag) wins
175
175
  * outright — an id there pins, a name there launches by name even when launcher.toml pins;
176
- * otherwise launcher.toml `agent_id` pins, and wins over launcher.toml `agent`. Returns the
177
- * `--agent`-shaped value (`agent`) and the config pin (`agentId`) for AgentOptions.
176
+ * then MNEMOM_AGENT (env), read exactly as the flag (the global `--agent`'s documented
177
+ * alternative); otherwise launcher.toml `agent_id` pins, and wins over launcher.toml `agent`.
178
+ * Returns the `--agent`-shaped value (`agent`) and the config pin (`agentId`) for AgentOptions.
178
179
  */
179
180
  export declare function selectLaunchAgent(sources: {
180
181
  flag?: string;
182
+ env?: string;
181
183
  configAgent?: string;
182
184
  configAgentId?: string;
183
185
  }): {
@@ -925,47 +927,29 @@ export declare function buildHandoffMcpConfigJson(p: HandoffMcpParams): string;
925
927
  * per-session statement, so it is always a per-launch `--goal`.
926
928
  */
927
929
  export type GoalModeDefault = "implicit" | "off";
928
- /**
929
- * Where a launch's goal mode came from (`resolveImplicitSource`). `prerelease` is door
930
- * one's T16 default (decisions 12 and 22): implicit by default on a `-next.N` build with
931
- * nothing configured. It is the only source that shows the one-time notice.
932
- */
933
- export type ImplicitSource = "flag" | "goal" | "config" | "experimental" | "prerelease" | "default";
934
- /** Does a Claude Code passthrough run headless (`-p` / `--print`)? */
935
- export declare function passthroughIsPrint(passthrough: readonly string[]): boolean;
936
930
  /**
937
931
  * Is this launch implicit-mode? Precedence, highest wins:
938
932
  * 1. an explicit flag — `--implicit` (true) or `--no-implicit` (false);
939
933
  * 2. a `--goal` statement — a sealed contract is a per-launch choice that the
940
- * standing config default must never silently override, so a launch never
941
- * runs both modes;
934
+ * standing config default must never silently override;
942
935
  * 3. the config default `goal_mode` — `"off"` turns alignment off, `"implicit"`
943
936
  * keeps it implicit;
944
- * 4. with the `implicit` experimental feature ON, IMPLICIT (as before T16);
945
- * 5. on a prerelease (`next`) build, IMPLICIT for an interactive or Remote Control
946
- * launch and OFF for a headless `-p` one (OD-13: T16 never covers `-p`);
947
- * 6. otherwise OFF — stable without the experimental feature behaves as today.
937
+ * 4. with the `implicit` experimental feature ON, IMPLICIT: the gateway infers
938
+ * the goal from the user's own messages (turn it off for a launch with
939
+ * `--no-implicit`, or standing with `goal_mode = "off"`); with it OFF (the
940
+ * default), OFF.
948
941
  * Pure so every arm is unit-tested; the caller passes the resolved value on to
949
942
  * `assembleContract` / `buildGoalModeHeader` (which still refuse `--implicit`
950
943
  * combined with a contract flag — that conflict is EXPLICIT and is reported).
951
944
  */
952
- export declare function resolveImplicitSource(opts: {
945
+ export declare function resolveImplicit(opts: {
953
946
  goal?: string;
954
947
  implicit?: boolean;
955
948
  configGoalMode?: GoalModeDefault;
956
949
  /**
957
950
  * Is the `implicit` experimental feature on? Off ⇒ the default is OFF and
958
951
  * `goal_mode = implicit` is ignored (`--implicit` is refused upstream, before
959
- * this runs), unless this is a prerelease build. Omitted ⇒ on.
952
+ * this runs). Omitted ⇒ on.
960
953
  */
961
954
  experimentalOn?: boolean;
962
- /** Is this a prerelease (`-next.N`) CLI build? `isPrerelease(CLI_VERSION)`. Omitted ⇒ no. */
963
- prerelease?: boolean;
964
- /** Does the launch run Claude Code headless (`-p`)? `passthroughIsPrint`. */
965
- print?: boolean;
966
- }): {
967
- implicit: boolean;
968
- source: ImplicitSource;
969
- };
970
- /** `resolveImplicitSource(opts).implicit`. */
971
- export declare function resolveImplicit(opts: Parameters<typeof resolveImplicitSource>[0]): boolean;
955
+ }): boolean;
package/dist/lib/agent.js CHANGED
@@ -150,14 +150,17 @@ export function parseAgentRef(raw) {
150
150
  return { kind: "name", name: v };
151
151
  }
152
152
  /**
153
- * Which agent a launch asks for, from the three places it can be named. `--agent` (flag) wins
153
+ * Which agent a launch asks for, from the four places it can be named. `--agent` (flag) wins
154
154
  * outright — an id there pins, a name there launches by name even when launcher.toml pins;
155
- * otherwise launcher.toml `agent_id` pins, and wins over launcher.toml `agent`. Returns the
156
- * `--agent`-shaped value (`agent`) and the config pin (`agentId`) for AgentOptions.
155
+ * then MNEMOM_AGENT (env), read exactly as the flag (the global `--agent`'s documented
156
+ * alternative); otherwise launcher.toml `agent_id` pins, and wins over launcher.toml `agent`.
157
+ * Returns the `--agent`-shaped value (`agent`) and the config pin (`agentId`) for AgentOptions.
157
158
  */
158
159
  export function selectLaunchAgent(sources) {
159
160
  if (sources.flag?.trim())
160
161
  return { agent: sources.flag };
162
+ if (sources.env?.trim())
163
+ return { agent: sources.env };
161
164
  if (sources.configAgentId?.trim())
162
165
  return { agentId: sources.configAgentId };
163
166
  return sources.configAgent?.trim() ? { agent: sources.configAgent } : {};
@@ -1353,42 +1356,27 @@ export function buildHandoffMcpConfig(p) {
1353
1356
  export function buildHandoffMcpConfigJson(p) {
1354
1357
  return JSON.stringify(buildHandoffMcpConfig(p));
1355
1358
  }
1356
- /** Does a Claude Code passthrough run headless (`-p` / `--print`)? */
1357
- export function passthroughIsPrint(passthrough) {
1358
- return passthrough.some((a) => a === "-p" || a === "--print" || a.startsWith("--print="));
1359
- }
1360
1359
  /**
1361
1360
  * Is this launch implicit-mode? Precedence, highest wins:
1362
1361
  * 1. an explicit flag — `--implicit` (true) or `--no-implicit` (false);
1363
1362
  * 2. a `--goal` statement — a sealed contract is a per-launch choice that the
1364
- * standing config default must never silently override, so a launch never
1365
- * runs both modes;
1363
+ * standing config default must never silently override;
1366
1364
  * 3. the config default `goal_mode` — `"off"` turns alignment off, `"implicit"`
1367
1365
  * keeps it implicit;
1368
- * 4. with the `implicit` experimental feature ON, IMPLICIT (as before T16);
1369
- * 5. on a prerelease (`next`) build, IMPLICIT for an interactive or Remote Control
1370
- * launch and OFF for a headless `-p` one (OD-13: T16 never covers `-p`);
1371
- * 6. otherwise OFF — stable without the experimental feature behaves as today.
1366
+ * 4. with the `implicit` experimental feature ON, IMPLICIT: the gateway infers
1367
+ * the goal from the user's own messages (turn it off for a launch with
1368
+ * `--no-implicit`, or standing with `goal_mode = "off"`); with it OFF (the
1369
+ * default), OFF.
1372
1370
  * Pure so every arm is unit-tested; the caller passes the resolved value on to
1373
1371
  * `assembleContract` / `buildGoalModeHeader` (which still refuse `--implicit`
1374
1372
  * combined with a contract flag — that conflict is EXPLICIT and is reported).
1375
1373
  */
1376
- export function resolveImplicitSource(opts) {
1374
+ export function resolveImplicit(opts) {
1377
1375
  if (opts.implicit !== undefined)
1378
- return { implicit: opts.implicit, source: "flag" };
1376
+ return opts.implicit;
1379
1377
  if (hasText(opts.goal))
1380
- return { implicit: false, source: "goal" };
1381
- const experimentalOn = opts.experimentalOn !== false;
1382
- if (!experimentalOn && !opts.prerelease)
1383
- return { implicit: false, source: "default" };
1384
- if (opts.configGoalMode !== undefined) {
1385
- return { implicit: opts.configGoalMode === "implicit", source: "config" };
1386
- }
1387
- if (experimentalOn)
1388
- return { implicit: true, source: "experimental" };
1389
- return { implicit: !opts.print, source: opts.print ? "default" : "prerelease" };
1390
- }
1391
- /** `resolveImplicitSource(opts).implicit`. */
1392
- export function resolveImplicit(opts) {
1393
- return resolveImplicitSource(opts).implicit;
1378
+ return false;
1379
+ if (opts.experimentalOn === false)
1380
+ return false;
1381
+ return opts.configGoalMode !== "off";
1394
1382
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Which claude to run, shared by the host (seats) and `agent run` (served phases) so both pick
3
+ * the same binary. Kept apart from host/run.ts so the runner does not load the host daemon.
4
+ */
5
+ /** The pinned claude: MNEMOM_AGENT_CLI when absolute, else `claude` on PATH, else null. */
6
+ export declare function resolveClaudeBin(env: Readonly<Record<string, string | undefined>>): string | null;