@claudexor/cli 3.1.0 → 3.1.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.
Files changed (113) hide show
  1. package/dist/acp-auth-command.d.ts +3 -0
  2. package/dist/acp-auth-command.d.ts.map +1 -0
  3. package/dist/acp-auth-command.js +18 -0
  4. package/dist/acp-auth-command.js.map +1 -0
  5. package/dist/acp-auth.d.ts +13 -0
  6. package/dist/acp-auth.d.ts.map +1 -0
  7. package/dist/acp-auth.js +47 -0
  8. package/dist/acp-auth.js.map +1 -0
  9. package/dist/belt-bridge.d.ts +2 -0
  10. package/dist/belt-bridge.d.ts.map +1 -0
  11. package/dist/belt-bridge.js +31 -0
  12. package/dist/belt-bridge.js.map +1 -0
  13. package/dist/bridge-serve.d.ts +1 -9
  14. package/dist/bridge-serve.d.ts.map +1 -1
  15. package/dist/bridge-serve.js +7 -22
  16. package/dist/bridge-serve.js.map +1 -1
  17. package/dist/capabilities.d.ts.map +1 -1
  18. package/dist/capabilities.js +2 -0
  19. package/dist/capabilities.js.map +1 -1
  20. package/dist/claudexord-entry.d.ts +11 -0
  21. package/dist/claudexord-entry.d.ts.map +1 -0
  22. package/dist/claudexord-entry.js +42 -0
  23. package/dist/claudexord-entry.js.map +1 -0
  24. package/dist/claudexord.d.ts +1 -4
  25. package/dist/claudexord.d.ts.map +1 -1
  26. package/dist/claudexord.js +26 -39
  27. package/dist/claudexord.js.map +1 -1
  28. package/dist/cli.js +15 -17
  29. package/dist/cli.js.map +1 -1
  30. package/dist/command-flags.d.ts +0 -6
  31. package/dist/command-flags.d.ts.map +1 -1
  32. package/dist/command-flags.js +8 -1
  33. package/dist/command-flags.js.map +1 -1
  34. package/dist/command-registry.js +3 -3
  35. package/dist/command-registry.js.map +1 -1
  36. package/dist/control-services.d.ts +22 -10
  37. package/dist/control-services.d.ts.map +1 -1
  38. package/dist/control-services.js +3 -5
  39. package/dist/control-services.js.map +1 -1
  40. package/dist/daemon-run.d.ts +5 -17
  41. package/dist/daemon-run.d.ts.map +1 -1
  42. package/dist/daemon-run.js +49 -76
  43. package/dist/daemon-run.js.map +1 -1
  44. package/dist/delegation-belt-descriptor.d.ts +20 -36
  45. package/dist/delegation-belt-descriptor.d.ts.map +1 -1
  46. package/dist/delegation-belt-descriptor.js +48 -51
  47. package/dist/delegation-belt-descriptor.js.map +1 -1
  48. package/dist/delegation-capability.d.ts +4 -0
  49. package/dist/delegation-capability.d.ts.map +1 -0
  50. package/dist/delegation-capability.js +29 -0
  51. package/dist/delegation-capability.js.map +1 -0
  52. package/dist/delegation-daemon-binding.d.ts +8 -0
  53. package/dist/delegation-daemon-binding.d.ts.map +1 -0
  54. package/dist/delegation-daemon-binding.js +18 -0
  55. package/dist/delegation-daemon-binding.js.map +1 -0
  56. package/dist/delegation-output.d.ts +16 -0
  57. package/dist/delegation-output.d.ts.map +1 -0
  58. package/dist/delegation-output.js +45 -0
  59. package/dist/delegation-output.js.map +1 -0
  60. package/dist/live.d.ts.map +1 -1
  61. package/dist/live.js +4 -0
  62. package/dist/live.js.map +1 -1
  63. package/dist/mcp-run-projections.d.ts +13 -0
  64. package/dist/mcp-run-projections.d.ts.map +1 -0
  65. package/dist/mcp-run-projections.js +74 -0
  66. package/dist/mcp-run-projections.js.map +1 -0
  67. package/dist/mcp-runner.d.ts +19 -1
  68. package/dist/mcp-runner.d.ts.map +1 -1
  69. package/dist/mcp-runner.js +47 -83
  70. package/dist/mcp-runner.js.map +1 -1
  71. package/dist/ops-commands.d.ts +5 -1
  72. package/dist/ops-commands.d.ts.map +1 -1
  73. package/dist/ops-commands.js +4 -2
  74. package/dist/ops-commands.js.map +1 -1
  75. package/dist/repo-asset-authority.d.ts +9 -13
  76. package/dist/repo-asset-authority.d.ts.map +1 -1
  77. package/dist/repo-asset-authority.js +41 -44
  78. package/dist/repo-asset-authority.js.map +1 -1
  79. package/dist/retry-command.d.ts +15 -0
  80. package/dist/retry-command.d.ts.map +1 -1
  81. package/dist/retry-command.js +7 -4
  82. package/dist/retry-command.js.map +1 -1
  83. package/dist/reviewer-options.d.ts +11 -1
  84. package/dist/reviewer-options.d.ts.map +1 -1
  85. package/dist/reviewer-options.js +24 -9
  86. package/dist/reviewer-options.js.map +1 -1
  87. package/dist/run-detail-projections.d.ts +16 -0
  88. package/dist/run-detail-projections.d.ts.map +1 -0
  89. package/dist/run-detail-projections.js +33 -0
  90. package/dist/run-detail-projections.js.map +1 -0
  91. package/dist/run-options.d.ts.map +1 -1
  92. package/dist/run-options.js +13 -1
  93. package/dist/run-options.js.map +1 -1
  94. package/dist/settings-service.d.ts +64 -22
  95. package/dist/settings-service.d.ts.map +1 -1
  96. package/dist/settings-service.js +95 -30
  97. package/dist/settings-service.js.map +1 -1
  98. package/dist/setup-job-store.d.ts +2 -2
  99. package/dist/setup-login-inline.d.ts +2 -0
  100. package/dist/setup-login-inline.d.ts.map +1 -1
  101. package/dist/setup-login-inline.js +4 -3
  102. package/dist/setup-login-inline.js.map +1 -1
  103. package/dist/setup-login-protocol.d.ts +2 -2
  104. package/dist/setup-login-protocol.d.ts.map +1 -1
  105. package/dist/setup-login-protocol.js.map +1 -1
  106. package/dist/thread-delivery.d.ts.map +1 -1
  107. package/dist/thread-delivery.js +4 -3
  108. package/dist/thread-delivery.js.map +1 -1
  109. package/dist/thread-execution-workspace.d.ts +22 -0
  110. package/dist/thread-execution-workspace.d.ts.map +1 -0
  111. package/dist/thread-execution-workspace.js +21 -0
  112. package/dist/thread-execution-workspace.js.map +1 -0
  113. package/package.json +23 -23
@@ -0,0 +1,3 @@
1
+ import type { ParsedArgs } from "./args.js";
2
+ export declare function dispatchAcpCommand(args: ParsedArgs, json: boolean): Promise<number>;
3
+ //# sourceMappingURL=acp-auth-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-auth-command.d.ts","sourceRoot":"","sources":["../src/acp-auth-command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAO5C,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAQzF"}
@@ -0,0 +1,18 @@
1
+ import process from "node:process";
2
+ import { parseArgs } from "./args.js";
3
+ import { ACP_SERVE_USAGE, resolveAcpServeAuthHarness } from "./acp-auth.js";
4
+ import { serveAcpBridge } from "./bridge-serve.js";
5
+ import { printUsageError } from "./cli-io.js";
6
+ import { authCommand } from "./ops-commands.js";
7
+ export async function dispatchAcpCommand(args, json) {
8
+ if (args._[1] !== "serve") {
9
+ return printUsageError(json, `usage: claudexor acp ${ACP_SERVE_USAGE}`);
10
+ }
11
+ if (args._.length === 2)
12
+ return serveAcpBridge();
13
+ const harness = resolveAcpServeAuthHarness(args._, process.platform);
14
+ if (!harness)
15
+ return printUsageError(json, `usage: claudexor acp ${ACP_SERVE_USAGE}`);
16
+ return authCommand(parseArgs(["auth", "login", harness]), false, { acpTerminal: true });
17
+ }
18
+ //# sourceMappingURL=acp-auth-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-auth-command.js","sourceRoot":"","sources":["../src/acp-auth-command.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAgB,EAAE,IAAa;IACtE,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO,eAAe,CAAC,IAAI,EAAE,wBAAwB,eAAe,EAAE,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,cAAc,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrE,IAAI,CAAC,OAAO;QAAE,OAAO,eAAe,CAAC,IAAI,EAAE,wBAAwB,eAAe,EAAE,CAAC,CAAC;IACtF,OAAO,WAAW,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,13 @@
1
+ export type AcpAuthHarness = "codex";
2
+ export declare const ACP_SERVE_USAGE = "serve [auth login codex]";
3
+ export interface AcpTerminalAuthMethod {
4
+ type: "terminal";
5
+ id: string;
6
+ name: string;
7
+ description: string;
8
+ args: string[];
9
+ }
10
+ export declare function acpTerminalAuthMethods(platform: NodeJS.Platform): AcpTerminalAuthMethod[];
11
+ /** Strictly decode the complete positional argv after the shared CLI parser. */
12
+ export declare function resolveAcpServeAuthHarness(positionals: readonly string[], platform: NodeJS.Platform): AcpAuthHarness | null;
13
+ //# sourceMappingURL=acp-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-auth.d.ts","sourceRoot":"","sources":["../src/acp-auth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC;AACrC,eAAO,MAAM,eAAe,6BAA6B,CAAC;AAE1D,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAgCD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,qBAAqB,EAAE,CAYzF;AAED,gFAAgF;AAChF,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,QAAQ,EAAE,MAAM,CAAC,QAAQ,GACxB,cAAc,GAAG,IAAI,CAevB"}
@@ -0,0 +1,47 @@
1
+ export const ACP_SERVE_USAGE = "serve [auth login codex]";
2
+ /**
3
+ * Experimental ACP Terminal Auth projection. Keep this registry narrower than
4
+ * the ordinary CLI login surface: an entry is eligible only when the command
5
+ * can run interactively in the terminal supplied by the ACP client and remain
6
+ * attached until the durable login reaches an honest outcome.
7
+ *
8
+ * Claude and Cursor are intentionally absent for now. Their existing macOS
9
+ * setup jobs launch a second Terminal window and return before the vendor login
10
+ * completes, which does not satisfy ACP Terminal Auth's lifecycle contract.
11
+ */
12
+ const ACP_TERMINAL_AUTH = [
13
+ {
14
+ harness: "codex",
15
+ name: "Sign in to Codex",
16
+ description: "Sign in to an isolated Claudexor Codex subscription profile.",
17
+ platforms: ["darwin", "linux"],
18
+ },
19
+ ];
20
+ function supportedOn(definition, platform) {
21
+ return definition.platforms.includes(platform);
22
+ }
23
+ export function acpTerminalAuthMethods(platform) {
24
+ return ACP_TERMINAL_AUTH.filter((definition) => supportedOn(definition, platform)).map((definition) => ({
25
+ type: "terminal",
26
+ id: definition.harness,
27
+ name: definition.name,
28
+ description: definition.description,
29
+ // ACP clients append these arguments to the configured agent command,
30
+ // e.g. `claudexor acp serve auth login codex`.
31
+ args: ["auth", "login", definition.harness],
32
+ }));
33
+ }
34
+ /** Strictly decode the complete positional argv after the shared CLI parser. */
35
+ export function resolveAcpServeAuthHarness(positionals, platform) {
36
+ if (positionals.length !== 5 ||
37
+ positionals[0] !== "acp" ||
38
+ positionals[1] !== "serve" ||
39
+ positionals[2] !== "auth" ||
40
+ positionals[3] !== "login") {
41
+ return null;
42
+ }
43
+ const harness = positionals[4];
44
+ const definition = ACP_TERMINAL_AUTH.find((candidate) => candidate.harness === harness && supportedOn(candidate, platform));
45
+ return definition?.harness ?? null;
46
+ }
47
+ //# sourceMappingURL=acp-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acp-auth.js","sourceRoot":"","sources":["../src/acp-auth.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AAiB1D;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAyC;IAC9D;QACE,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,8DAA8D;QAC3E,SAAS,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;KAC/B;CACF,CAAC;AAEF,SAAS,WAAW,CAAC,UAAqC,EAAE,QAAyB;IACnF,OAAO,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,QAAyB;IAC9D,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CACpF,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACf,IAAI,EAAE,UAAmB;QACzB,EAAE,EAAE,UAAU,CAAC,OAAO;QACtB,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,WAAW,EAAE,UAAU,CAAC,WAAW;QACnC,sEAAsE;QACtE,+CAA+C;QAC/C,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC;KAC5C,CAAC,CACH,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,0BAA0B,CACxC,WAA8B,EAC9B,QAAyB;IAEzB,IACE,WAAW,CAAC,MAAM,KAAK,CAAC;QACxB,WAAW,CAAC,CAAC,CAAC,KAAK,KAAK;QACxB,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO;QAC1B,WAAW,CAAC,CAAC,CAAC,KAAK,MAAM;QACzB,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,EAC1B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CACvC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,KAAK,OAAO,IAAI,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,CACjF,CAAC;IACF,OAAO,UAAU,EAAE,OAAO,IAAI,IAAI,CAAC;AACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function serveBeltBridge(): Promise<number>;
2
+ //# sourceMappingURL=belt-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"belt-bridge.d.ts","sourceRoot":"","sources":["../src/belt-bridge.ts"],"names":[],"mappings":"AAcA,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAmBvD"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Minimal stdio entry for the scoped delegation belt.
3
+ *
4
+ * Keep this separate from bridge-serve.ts: the packaged daemon self-entry must
5
+ * not initialize the ACP surface merely to expose six belt tools. Starting the
6
+ * server is side-effect-free with respect to daemon state; a tool invocation
7
+ * connects to the already-running parent daemon through the injected discovery
8
+ * env.
9
+ */
10
+ import { armOrphanExit } from "@claudexor/core";
11
+ import { beltClaudexorTools, readDelegationPolicy, serveClaudexorMcp } from "@claudexor/mcp-server";
12
+ import { CLAUDEXOR_VERSION } from "@claudexor/util";
13
+ import { mcpSurfaceRunner } from "./mcp-runner.js";
14
+ export async function serveBeltBridge() {
15
+ const policy = readDelegationPolicy(process.env);
16
+ serveClaudexorMcp({
17
+ version: CLAUDEXOR_VERSION,
18
+ tools: beltClaudexorTools(mcpSurfaceRunner({
19
+ requireExistingDaemon: true,
20
+ delegationParentRunId: policy.parentRunId,
21
+ delegationRepoRoot: policy.repoRoot,
22
+ }), policy),
23
+ transport: { read: process.stdin, write: process.stdout },
24
+ });
25
+ armOrphanExit({
26
+ onOrphaned: () => process.stderr.write("claudexor mcp-belt: host process died; exiting\n"),
27
+ });
28
+ await new Promise((resolve) => process.stdin.once("close", resolve));
29
+ return 0;
30
+ }
31
+ //# sourceMappingURL=belt-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"belt-bridge.js","sourceRoot":"","sources":["../src/belt-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACjD,iBAAiB,CAAC;QAChB,OAAO,EAAE,iBAAiB;QAC1B,KAAK,EAAE,kBAAkB,CACvB,gBAAgB,CAAC;YACf,qBAAqB,EAAE,IAAI;YAC3B,qBAAqB,EAAE,MAAM,CAAC,WAAW;YACzC,kBAAkB,EAAE,MAAM,CAAC,QAAQ;SACpC,CAAC,EACF,MAAM,CACP;QACD,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;KAC1D,CAAC,CAAC;IACH,aAAa,CAAC;QACZ,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC;KAC3F,CAAC,CAAC;IACH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -1,12 +1,4 @@
1
+ export { serveBeltBridge } from "./belt-bridge.js";
1
2
  export declare function serveMcpBridge(): Promise<number>;
2
- /**
3
- * Serve the SCOPED delegation belt (D32) over stdio. Injected into a delegate
4
- * agent run's harness sandbox; it exposes ONLY the six belt tools (ask / plan /
5
- * isolated run / best-of / status / result) and enforces the depth, sub-run-count
6
- * and budget policy read from the injected CLAUDEXOR_DELEGATION_* env. The belt
7
- * crosses the SAME daemon boundary as the public MCP surface (isolated envelope,
8
- * no thread by construction) — there is no apply/decision/thread/settings tool.
9
- */
10
- export declare function serveBeltBridge(): Promise<number>;
11
3
  export declare function serveAcpBridge(): Promise<number>;
12
4
  //# sourceMappingURL=bridge-serve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-serve.d.ts","sourceRoot":"","sources":["../src/bridge-serve.ts"],"names":[],"mappings":"AAuBA,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAYtD;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAUvD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAQtD"}
1
+ {"version":3,"file":"bridge-serve.d.ts","sourceRoot":"","sources":["../src/bridge-serve.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQnD,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAYtD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAStD"}
@@ -5,10 +5,13 @@
5
5
  * a reparent watchdog bounds the bridge's life to its host's.
6
6
  */
7
7
  import { armOrphanExit } from "@claudexor/core";
8
- import { beltClaudexorTools, defaultClaudexorTools, readDelegationPolicy, serveClaudexorMcp, } from "@claudexor/mcp-server";
8
+ import { defaultClaudexorTools, serveClaudexorMcp } from "@claudexor/mcp-server";
9
9
  import { AcpServer } from "@claudexor/acp-server";
10
10
  import { CLAUDEXOR_VERSION } from "@claudexor/util";
11
+ import { acpTerminalAuthMethods } from "./acp-auth.js";
12
+ import { acpSessionQuery } from "./acp-surface-runner.js";
11
13
  import { mcpSurfaceRunner } from "./mcp-runner.js";
14
+ export { serveBeltBridge } from "./belt-bridge.js";
12
15
  function armBridgeWatchdog(label) {
13
16
  armOrphanExit({
14
17
  onOrphaned: () => process.stderr.write(`claudexor ${label}: host process died; exiting\n`),
@@ -19,7 +22,7 @@ export async function serveMcpBridge() {
19
22
  // run started from an MCP host is visible/unblockable like a CLI run.
20
23
  serveClaudexorMcp({
21
24
  version: CLAUDEXOR_VERSION,
22
- tools: defaultClaudexorTools(mcpSurfaceRunner()),
25
+ tools: defaultClaudexorTools(mcpSurfaceRunner({ acpSessionQuery })),
23
26
  transport: { read: process.stdin, write: process.stdout },
24
27
  });
25
28
  armBridgeWatchdog("mcp");
@@ -27,31 +30,13 @@ export async function serveMcpBridge() {
27
30
  await new Promise((resolve) => process.stdin.once("close", resolve));
28
31
  return 0;
29
32
  }
30
- /**
31
- * Serve the SCOPED delegation belt (D32) over stdio. Injected into a delegate
32
- * agent run's harness sandbox; it exposes ONLY the six belt tools (ask / plan /
33
- * isolated run / best-of / status / result) and enforces the depth, sub-run-count
34
- * and budget policy read from the injected CLAUDEXOR_DELEGATION_* env. The belt
35
- * crosses the SAME daemon boundary as the public MCP surface (isolated envelope,
36
- * no thread by construction) — there is no apply/decision/thread/settings tool.
37
- */
38
- export async function serveBeltBridge() {
39
- const policy = readDelegationPolicy(process.env);
40
- serveClaudexorMcp({
41
- version: CLAUDEXOR_VERSION,
42
- tools: beltClaudexorTools(mcpSurfaceRunner(), policy),
43
- transport: { read: process.stdin, write: process.stdout },
44
- });
45
- armBridgeWatchdog("mcp-belt");
46
- await new Promise((resolve) => process.stdin.once("close", resolve));
47
- return 0;
48
- }
49
33
  export async function serveAcpBridge() {
50
34
  armBridgeWatchdog("acp");
51
35
  await new AcpServer({
52
36
  version: CLAUDEXOR_VERSION,
53
- runner: mcpSurfaceRunner(),
37
+ runner: mcpSurfaceRunner({ acpSessionQuery }),
54
38
  transport: { read: process.stdin, write: process.stdout },
39
+ terminalAuthMethods: acpTerminalAuthMethods(process.platform),
55
40
  }).serve();
56
41
  return 0;
57
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"bridge-serve.js","sourceRoot":"","sources":["../src/bridge-serve.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,SAAS,iBAAiB,CAAC,KAAa;IACtC,aAAa,CAAC;QACZ,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,KAAK,gCAAgC,CAAC;KAC3F,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc;IAClC,mEAAmE;IACnE,sEAAsE;IACtE,iBAAiB,CAAC;QAChB,OAAO,EAAE,iBAAiB;QAC1B,KAAK,EAAE,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;QAChD,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;KAC1D,CAAC,CAAC;IACH,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACzB,gEAAgE;IAChE,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE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,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;QACzD,mBAAmB,EAAE,sBAAsB,CAAC,OAAO,CAAC,QAAQ,CAAC;KAC9D,CAAC,CAAC,KAAK,EAAE,CAAC;IACX,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EAUvB,MAAM,mBAAmB,CAAC;AAQ3B,8EAA8E;AAC9E,wBAAgB,YAAY,IAAI,SAAS,MAAM,EAAE,CAEhD;AAKD;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,sBAAsB,CAAC,CA0FnF"}
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EAUvB,MAAM,mBAAmB,CAAC;AAS3B,8EAA8E;AAC9E,wBAAgB,YAAY,IAAI,SAAS,MAAM,EAAE,CAEhD;AAKD;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,sBAAsB,CAAC,CA2FnF"}
@@ -5,6 +5,7 @@ import { defaultClaudexorTools } from "@claudexor/mcp-server";
5
5
  import { CLAUDEXOR_VERSION } from "@claudexor/util";
6
6
  import { CLI_COMMANDS } from "./command-registry.js";
7
7
  import { buildGateway, harnessModels } from "./registry.js";
8
+ import { delegationCapabilityFor } from "./delegation-capability.js";
8
9
  /** MCP tool names from the server's own descriptor producer (noop runner). */
9
10
  export function mcpToolNames() {
10
11
  return defaultClaudexorTools(async () => "").map((t) => t.name);
@@ -61,6 +62,7 @@ export async function buildAgentCapabilityCatalog() {
61
62
  effortLevels: [...(s.manifest?.capabilities.effort_levels ?? [])],
62
63
  accessProfilesSupported: [...(s.manifest?.access_profiles_supported ?? [])],
63
64
  readonlyMechanism: profile?.access_control.readonly_mechanism ?? "none",
65
+ delegation: delegationCapabilityFor(s.manifest),
64
66
  };
65
67
  }));
66
68
  // Run-control keys are DERIVED from the schema shape, minus the keys the
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,QAAQ,EACR,sBAAsB,EACtB,8BAA8B,EAC9B,aAAa,EACb,aAAa,GAGd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE5D,8EAA8E;AAC9E,MAAM,UAAU,YAAY;IAC1B,OAAO,qBAAqB,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,gFAAgF;AAChF,MAAM,eAAe,GAAG,gCAAgC,CAAC;AAEzD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC;IACjG,MAAM,GAAG,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAExC,MAAM,SAAS,GAAqB,MAAM,OAAO,CAAC,GAAG,CACnD,QAAQ,CAAC,GAAG,CAAC,KA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AE,CAAC,CAAC,UAAU;YACxB,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,QAAQ,EAAE,CAAC,CAAC,QAAQ,KAAK,IAAI;SAC9B,CAAC,CAAC;QACH,QAAQ,EAAE,CAAC,GAAG,YAAY,EAAE,CAAC;QAC7B,cAAc,EAAE,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC;KAC3C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Side-effect-free dispatch for the daemon executable's alternate belt role.
3
+ * Kept outside claudexord.ts so the daemon owner remains below its readability
4
+ * ratchet and the entry decision can be tested without daemon initialization.
5
+ */
6
+ export declare function isBeltServeInvocation(argv: readonly string[]): boolean;
7
+ export declare function runBeltServeIfRequested(argv: readonly string[]): Promise<boolean>;
8
+ export declare function dispatchClaudexordEntry(daemonMain: () => Promise<void>, argv?: readonly string[]): void;
9
+ /** Preserve import-side-effect freedom while supporting direct `node dist/claudexord.js`. */
10
+ export declare function runIfDirectEntry(moduleUrl: string, entry: () => void, argv?: readonly string[]): void;
11
+ //# sourceMappingURL=claudexord-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claudexord-entry.d.ts","sourceRoot":"","sources":["../src/claudexord-entry.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEtE;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAKvF;AAED,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC/B,IAAI,GAAE,SAAS,MAAM,EAA0B,GAC9C,IAAI,CAWN;AAED,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,IAAI,EACjB,IAAI,GAAE,SAAS,MAAM,EAAiB,GACrC,IAAI,CAWN"}
@@ -0,0 +1,42 @@
1
+ import { realpathSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ /**
5
+ * Side-effect-free dispatch for the daemon executable's alternate belt role.
6
+ * Kept outside claudexord.ts so the daemon owner remains below its readability
7
+ * ratchet and the entry decision can be tested without daemon initialization.
8
+ */
9
+ export function isBeltServeInvocation(argv) {
10
+ return argv.length === 2 && argv[0] === "mcp" && argv[1] === "serve-belt";
11
+ }
12
+ export async function runBeltServeIfRequested(argv) {
13
+ if (!isBeltServeInvocation(argv))
14
+ return false;
15
+ const { serveBeltBridge } = await import("./belt-bridge.js");
16
+ process.exitCode = await serveBeltBridge();
17
+ return true;
18
+ }
19
+ export function dispatchClaudexordEntry(daemonMain, argv = process.argv.slice(2)) {
20
+ runBeltServeIfRequested(argv)
21
+ .then(async (handled) => {
22
+ if (!handled)
23
+ await daemonMain();
24
+ })
25
+ .catch((error) => {
26
+ process.stderr.write(`claudexord: ${error instanceof Error ? error.message : String(error)}\n`);
27
+ process.exitCode = 1;
28
+ });
29
+ }
30
+ /** Preserve import-side-effect freedom while supporting direct `node dist/claudexord.js`. */
31
+ export function runIfDirectEntry(moduleUrl, entry, argv = process.argv) {
32
+ try {
33
+ if (typeof argv[1] === "string" &&
34
+ realpathSync.native(resolve(argv[1])) === realpathSync.native(fileURLToPath(moduleUrl))) {
35
+ entry();
36
+ }
37
+ }
38
+ catch {
39
+ // A malformed executable path is not direct-entry proof.
40
+ }
41
+ }
42
+ //# sourceMappingURL=claudexord-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claudexord-entry.js","sourceRoot":"","sources":["../src/claudexord-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;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AC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EACvF,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,yDAAyD;IAC3D,CAAC;AACH,CAAC"}
@@ -22,9 +22,6 @@ export declare function runProbeIfRequested(argv: readonly string[]): boolean;
22
22
  * nonzero when a live daemon could not be confirmed dead. */
23
23
  export declare function runStopIfRequested(argv: readonly string[]): Promise<boolean>;
24
24
  export declare function main(): Promise<void>;
25
- /** Boot the daemon and translate a fatal error into a nonzero exit. The npm
26
- * bin wrapper (packages/claudexor/bin/claudexord.js) calls this EXPLICITLY —
27
- * a bare import must never boot the daemon (X228: the probe test's import
28
- * would race the LIVE daemon for the journal writer lease). */
25
+ /** Explicit entry preserves import-side-effect freedom for daemon probes. */
29
26
  export declare function runClaudexordEntry(): void;
30
27
  //# sourceMappingURL=claudexord.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"claudexord.d.ts","sourceRoot":"","sources":["../src/claudexord.ts"],"names":[],"mappings":";AAuCA,OAAO,EAAE,KAAK,YAAY,EAA8B,MAAM,mBAAmB,CAAC;AAclF;;;;6DAI6D;AAC7D,wBAAgB,oBAAoB,IAAI,YAAY,EAAE,CAsBrD;AAED;;;;;iDAKiD;AACjD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAKpE;AAED;;;;;;6DAM6D;AAC7D,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBlF;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuf1C;AAED;;;+DAG+D;AAC/D,wBAAgB,kBAAkB,IAAI,IAAI,CAKzC"}
1
+ {"version":3,"file":"claudexord.d.ts","sourceRoot":"","sources":["../src/claudexord.ts"],"names":[],"mappings":";AAqCA,OAAO,EAAE,KAAK,YAAY,EAA8B,MAAM,mBAAmB,CAAC;AAiBlF;;;;6DAI6D;AAC7D,wBAAgB,oBAAoB,IAAI,YAAY,EAAE,CAsBrD;AAED;;;;;iDAKiD;AACjD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAKpE;AAED;;;;;;6DAM6D;AAC7D,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBlF;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA4f1C;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -1,15 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import { appendFileSync, mkdirSync, writeFileSync } from "node:fs";
3
3
  import { join } from "node:path";
4
- import { pathToFileURL } from "node:url";
5
4
  import { DaemonClient, awaitDaemonTermination, readToken, commandProjection, interactionProjection, operatorDecisionProjection, runEventProjection, JournalManager, DaemonServer, InteractionRegistry, ProjectPartitions, projectProjection, RunEventBus, ResourceStore, quotaProjection, threadHeadPingProjection, threadProjection, daemonDir, defaultSocketPath, acquireDaemonWriterLease, ensureToken, ensureDaemonRuntimeRoot, logPath, socketAlive, } from "@claudexor/daemon";
6
5
  import { DaemonControlApiServer, normalizeRunStartRequest } from "@claudexor/control-api";
7
6
  import { armDaemonLifecycle, logLine, runStartupCrashGc } from "./daemon-lifecycle.js";
8
7
  import { assertPlanImplementReady } from "./plan-implement-readiness.js";
9
8
  import { Orchestrator } from "@claudexor/orchestrator";
10
- import { buildDelegationBeltDescriptor } from "./delegation-belt-descriptor.js";
9
+ import { delegationBeltForRun } from "./delegation-belt-descriptor.js";
11
10
  import { loadConfig, sweepRetiredConfigKeysAtStartup } from "@claudexor/config";
12
- import { ensureThreadWorktree } from "@claudexor/workspace";
13
11
  import { engineBuildIdentity, noProjectRepoRoot, redactSecrets } from "@claudexor/util";
14
12
  import { scheduleStartupRetention } from "./retention-service.js";
15
13
  import { controlServices } from "./control-services.js";
@@ -22,6 +20,9 @@ import { DaemonRuntimeShutdown } from "./daemon-runtime-shutdown.js";
22
20
  import { refreshCodexQuota } from "./codex-quota-source.js";
23
21
  import { refreshClaudeStatuslineQuota } from "./claude-statusline.js";
24
22
  import { refreshClaudeOauthUsageQuota } from "./claude-oauth-usage.js";
23
+ import { resolveThreadExecutionWorkspace } from "./thread-execution-workspace.js";
24
+ import { dispatchClaudexordEntry, runIfDirectEntry } from "./claudexord-entry.js";
25
+ import { createDelegationDaemonBinding } from "./delegation-daemon-binding.js";
25
26
  const NO_PROJECT_ROOT = noProjectRepoRoot();
26
27
  /** The registered quota-subject UNIVERSE (release cut V11a): for each harness,
27
28
  * the engine-default credential (subject null) plus one subject per enabled
@@ -131,6 +132,7 @@ export async function main() {
131
132
  logLine(logPath(), `swept retired config keys from ${sweep.path}: ${sweep.removed.join(", ")}`);
132
133
  }
133
134
  const bus = new RunEventBus();
135
+ const { authority: delegationBudgetAuthority, bind: bindDelegationDaemon } = createDelegationDaemonBinding();
134
136
  const journalManager = new JournalManager(daemonDir());
135
137
  const commandStoreSlot = journalManager.registerProjection(commandProjection());
136
138
  const interactionStoreSlot = journalManager.registerProjection(interactionProjection());
@@ -177,6 +179,7 @@ export async function main() {
177
179
  socketPath,
178
180
  token,
179
181
  commands: threads,
182
+ delegationAuthority: delegationBudgetAuthority,
180
183
  onRunTerminal: (runId, threadId) => {
181
184
  interactions.dropForRun(runId);
182
185
  // Run-terminal is the one W12 path with no thread-store mutation to
@@ -192,10 +195,12 @@ export async function main() {
192
195
  const mode = p.mode;
193
196
  const noProjectAsk = mode === "ask" && p.scope.kind === "none";
194
197
  const repoRoot = p.scope.kind === "project" ? p.scope.root : NO_PROJECT_ROOT;
198
+ const runConfig = loadConfig(repoRoot);
195
199
  if (noProjectAsk)
196
200
  mkdirSync(NO_PROJECT_ROOT, { recursive: true, mode: 0o700 });
197
201
  const orchestrator = new Orchestrator({
198
202
  registry: buildRegistry(),
203
+ delegationBudgetAuthority,
199
204
  routingGoal: p.routingGoal,
200
205
  quotaSnapshots: () => quotaStoreSlot.current().read().snapshots,
201
206
  quotaEventSink: (harnessId, event) => quotaStoreSlot.current().ingest(harnessId, event),
@@ -220,19 +225,14 @@ export async function main() {
220
225
  assertPlanImplementReady(planRef.runId, planRef.path);
221
226
  }
222
227
  }
223
- let executionRoot;
224
- let inPlace = p.execution.isolation === "live";
225
- if (threadId && repoRoot !== NO_PROJECT_ROOT) {
226
- const thread = threads.getThread(threadId);
227
- if (thread?.workspace.mode === "isolated") {
228
- const wt = await ensureThreadWorktree(repoRoot, threadId);
229
- executionRoot = wt.path;
230
- // Only creation owns the base; apply advances it independently.
231
- if (wt.created)
232
- threads.setThreadWorktree(threadId, wt.path, wt.baseSha);
233
- inPlace = true; // isolated turns run in-place WITHIN the worktree
234
- }
235
- }
228
+ const { executionRoot, inPlace } = await resolveThreadExecutionWorkspace({
229
+ threadId,
230
+ repoRoot,
231
+ mode,
232
+ requestedInPlace: p.execution.isolation === "live",
233
+ protectedPaths: runConfig.project.constraints.protected_paths,
234
+ threads,
235
+ });
236
236
  const onRunStart = (info) => {
237
237
  ctx.onRunStart?.(info);
238
238
  if (!threadId)
@@ -306,6 +306,7 @@ export async function main() {
306
306
  deadlineTimer.unref?.();
307
307
  runSignal = ctx.signal ? AbortSignal.any([ctx.signal, deadline.signal]) : deadline.signal;
308
308
  }
309
+ const delegationBelt = delegationBeltForRun(p.delegate === true, p.paidBudget);
309
310
  return orchestrator
310
311
  .run({
311
312
  onEvent: (event) => {
@@ -319,7 +320,7 @@ export async function main() {
319
320
  bus.publish(event);
320
321
  },
321
322
  onInteraction: (ctx2) => interactions.register(ctx2, p),
322
- interactionTimeoutMs: loadConfig(repoRoot).global.interaction_timeout_ms,
323
+ interactionTimeoutMs: runConfig.global.interaction_timeout_ms,
323
324
  threadId,
324
325
  executionRoot,
325
326
  resumeSessions: threadId ? threads.resumeMap(threadId, requestedProfileId) : undefined,
@@ -356,6 +357,9 @@ export async function main() {
356
357
  : undefined,
357
358
  authPreference: p.authPreference,
358
359
  credentialProfileId: requestedProfileId,
360
+ parentRunId: p.parentRunId ?? null,
361
+ delegatedFromRunId: p.delegatedFromRunId ?? null,
362
+ delegationAdmissionId: ctx.jobId,
359
363
  repoRoot,
360
364
  prompt: String(p.prompt ?? ""),
361
365
  planRef: p.planRef && typeof p.planRef === "object"
@@ -390,7 +394,7 @@ export async function main() {
390
394
  // Belt descriptor (D32): built once per delegate run with the parent
391
395
  // budget snapshot; injected into agent lanes whose adapter can host
392
396
  // MCP servers. Null when delegate is off (no belt).
393
- delegationBelt: p.delegate === true ? buildDelegationBeltDescriptor(p.paidBudget) : null,
397
+ delegationBelt,
394
398
  synthesis: p.synthesis,
395
399
  paidBudget: p.paidBudget,
396
400
  access: p.access,
@@ -414,6 +418,7 @@ export async function main() {
414
418
  });
415
419
  },
416
420
  });
421
+ bindDelegationDaemon(server);
417
422
  const authReadiness = new AuthReadinessService(buildGateway({ includeFakes: false }), {
418
423
  cwd: NO_PROJECT_ROOT,
419
424
  });
@@ -531,27 +536,9 @@ export async function main() {
531
536
  writerLease.release();
532
537
  }
533
538
  }
534
- /** Boot the daemon and translate a fatal error into a nonzero exit. The npm
535
- * bin wrapper (packages/claudexor/bin/claudexord.js) calls this EXPLICITLY —
536
- * a bare import must never boot the daemon (X228: the probe test's import
537
- * would race the LIVE daemon for the journal writer lease). */
539
+ /** Explicit entry preserves import-side-effect freedom for daemon probes. */
538
540
  export function runClaudexordEntry() {
539
- main().catch((err) => {
540
- process.stderr.write(`claudexord: ${err instanceof Error ? err.message : String(err)}\n`);
541
- process.exitCode = 1;
542
- });
541
+ dispatchClaudexordEntry(main);
543
542
  }
544
- // Direct execution (node dist/claudexord.js) boots via the entry guard;
545
- // imports (tests, the bin wrapper) get NO side effect and call
546
- // runClaudexordEntry() themselves.
547
- const invokedAsEntry = (() => {
548
- try {
549
- return (typeof process.argv[1] === "string" && import.meta.url === pathToFileURL(process.argv[1]).href);
550
- }
551
- catch {
552
- return false;
553
- }
554
- })();
555
- if (invokedAsEntry)
556
- runClaudexordEntry();
543
+ runIfDirectEntry(import.meta.url, runClaudexordEntry);
557
544
  //# sourceMappingURL=claudexord.js.map