@lannguyensi/harness 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/dist/cli/approve/understanding.d.ts +46 -0
  3. package/dist/cli/approve/understanding.js +50 -22
  4. package/dist/cli/approve/understanding.js.map +1 -1
  5. package/dist/cli/audit.d.ts +29 -0
  6. package/dist/cli/audit.js +130 -17
  7. package/dist/cli/audit.js.map +1 -1
  8. package/dist/cli/delegate/index.d.ts +63 -0
  9. package/dist/cli/delegate/index.js +313 -0
  10. package/dist/cli/delegate/index.js.map +1 -0
  11. package/dist/cli/doctor/auto-approve-mode.d.ts +37 -0
  12. package/dist/cli/doctor/auto-approve-mode.js +80 -0
  13. package/dist/cli/doctor/auto-approve-mode.js.map +1 -0
  14. package/dist/cli/doctor/codex-config-drift.d.ts +28 -0
  15. package/dist/cli/doctor/codex-config-drift.js +240 -0
  16. package/dist/cli/doctor/codex-config-drift.js.map +1 -0
  17. package/dist/cli/doctor/format.js +32 -1
  18. package/dist/cli/doctor/format.js.map +1 -1
  19. package/dist/cli/doctor/index.js +51 -7
  20. package/dist/cli/doctor/index.js.map +1 -1
  21. package/dist/cli/doctor/settings-drift.d.ts +6 -0
  22. package/dist/cli/doctor/settings-drift.js +20 -6
  23. package/dist/cli/doctor/settings-drift.js.map +1 -1
  24. package/dist/cli/doctor/types.d.ts +43 -0
  25. package/dist/cli/doctor/types.js.map +1 -1
  26. package/dist/cli/doctor/ug-delegations.d.ts +26 -0
  27. package/dist/cli/doctor/ug-delegations.js +112 -0
  28. package/dist/cli/doctor/ug-delegations.js.map +1 -0
  29. package/dist/cli/doctor/understanding-mode-env.d.ts +2 -0
  30. package/dist/cli/doctor/understanding-mode-env.js +5 -2
  31. package/dist/cli/doctor/understanding-mode-env.js.map +1 -1
  32. package/dist/cli/index.js +89 -1
  33. package/dist/cli/index.js.map +1 -1
  34. package/dist/cli/pack/approve-escape.js +16 -7
  35. package/dist/cli/pack/approve-escape.js.map +1 -1
  36. package/dist/cli/pack/auto-approve-path.d.ts +17 -0
  37. package/dist/cli/pack/auto-approve-path.js +56 -3
  38. package/dist/cli/pack/auto-approve-path.js.map +1 -1
  39. package/dist/cli/pack/hook-pre-tool-use.d.ts +25 -0
  40. package/dist/cli/pack/hook-pre-tool-use.js +336 -3
  41. package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
  42. package/dist/cli/pack/transcript-report-scan.d.ts +71 -0
  43. package/dist/cli/pack/transcript-report-scan.js +359 -0
  44. package/dist/cli/pack/transcript-report-scan.js.map +1 -0
  45. package/dist/cli/smoke/index.d.ts +18 -1
  46. package/dist/cli/smoke/index.js +54 -0
  47. package/dist/cli/smoke/index.js.map +1 -1
  48. package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.d.ts +76 -2
  49. package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js +139 -2
  50. package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js.map +1 -1
  51. package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.d.ts +223 -0
  52. package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js +633 -0
  53. package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js.map +1 -0
  54. package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +2 -1
  55. package/dist/policy-packs/builtin/understanding-before-execution/index.js +9 -1
  56. package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -1
  57. package/dist/policy-packs/builtin/understanding-before-execution.d.ts +19 -0
  58. package/dist/policy-packs/builtin/understanding-before-execution.js +29 -0
  59. package/dist/policy-packs/builtin/understanding-before-execution.js.map +1 -1
  60. package/dist/runtime/approval-signing.js +28 -0
  61. package/dist/runtime/approval-signing.js.map +1 -1
  62. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/smoke/index.ts"],"names":[],"mappings":"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ES: readonly string[];
70
+ /**
71
+ * What `auto_approve.report_scan.max_wait` resolves to when the key is
72
+ * ABSENT: the bound the child's PreToolUse hook waits for its own
73
+ * Understanding Report to reach the session transcript before it blocks
74
+ * (ADR "Report capture under `-p`", slice 3 acceptance criterion 3).
75
+ *
76
+ * The value is measured, not guessed: under `claude -p` the report is
77
+ * absent from the transcript at the instant PreToolUse fires and lands
78
+ * some time later, on a lag that scales with report length, so the
79
+ * bound is set from the real end-to-end runs (a full-length grill_me
80
+ * report), not only the shorter probe reports that first-guessed 500ms.
81
+ * The measurement and the retuning derivation are both in
82
+ * `docs/okf/understanding-gate-auto-mode-signals.md` ("Chosen
83
+ * `report_scan.max_wait` default" section), from
84
+ * `dogfood/ug-auto-mode-signals/`.
85
+ *
86
+ * ONE named constant on purpose: the hook, the schema default and every
87
+ * test read this symbol, so re-tuning the bound against a new
88
+ * measurement is a one-line change with no literal to hunt down.
89
+ */
90
+ export declare const DEFAULT_REPORT_SCAN_MAX_WAIT_MS = 2000;
91
+ /**
92
+ * Hard ceiling for `auto_approve.report_scan.max_wait`. A larger value
93
+ * is a `harness validate` schema error AND a runtime parse failure (which
94
+ * fails the whole `auto_approve` block closed), so no configuration can
95
+ * make a PreToolUse hook sit on a session for an arbitrary time. 5 s is
96
+ * an order of magnitude above the measured worst-case flush, which is
97
+ * generous for a bound whose only job is to cover a transcript write
98
+ * already in flight.
99
+ */
100
+ export declare const REPORT_SCAN_MAX_WAIT_CEILING_MS = 5000;
70
101
  /** Parsed, validated `auto_approve` pack-config block. */
71
102
  export interface AutoApproveConfig {
72
103
  /** Allowlist of `permission_mode` payload literals eligible for auto-approval. */
@@ -78,7 +109,45 @@ export interface AutoApproveConfig {
78
109
  * fails the whole block closed rather than defaulting.
79
110
  */
80
111
  harnesses: string[];
112
+ /**
113
+ * The transcript-poll bound for the slice 3 delegation path. Always
114
+ * present: an absent `report_scan` block resolves to
115
+ * {@link DEFAULT_REPORT_SCAN_MAX_WAIT_MS}, and every malformed shape
116
+ * fails the whole `auto_approve` block closed, like every other key
117
+ * here.
118
+ */
119
+ reportScan: {
120
+ maxWaitMs: number;
121
+ };
81
122
  }
123
+ export type ReportScanMaxWaitParse = {
124
+ ok: true;
125
+ maxWaitMs: number;
126
+ } | {
127
+ ok: false;
128
+ reason: string;
129
+ };
130
+ /**
131
+ * Parse `auto_approve.report_scan.max_wait` into milliseconds.
132
+ *
133
+ * Duration grammar: the pack's SHARED parser
134
+ * ({@link parseDurationSeconds}, the same one `approval_lifecycle.max_age`
135
+ * uses), plus an `<n>ms` shorthand it does not model. The extension is
136
+ * not cosmetic: this bound is a transcript-flush allowance measured in
137
+ * tens of milliseconds, so a second-granularity grammar could not express
138
+ * the values the measurement actually argues for, and widening
139
+ * `parseDurationSeconds` itself would change the grammar of every
140
+ * `within:` / `max_age:` / `--since` value in the repo for one key's sake.
141
+ *
142
+ * Both bounds are errors, never clamps: zero or negative (a bound that
143
+ * would disable the poll while the block still claimed to have one) and
144
+ * anything above {@link REPORT_SCAN_MAX_WAIT_CEILING_MS} (a bound that
145
+ * could park a PreToolUse hook). Returning a RESULT rather than throwing
146
+ * keeps the two consumers symmetric: the zod schema turns it into a
147
+ * `harness validate` diagnostic, the runtime parser into one stderr line
148
+ * and a fail-closed `null`.
149
+ */
150
+ export declare function parseReportScanMaxWait(raw: unknown): ReportScanMaxWaitParse;
82
151
  /**
83
152
  * Parse the optional `auto_approve` pack-config block
84
153
  * (docs/decisions/2026-08-27-ug-auto-mode-approval.md, "Option A").
@@ -114,8 +183,13 @@ export declare function parseAutoApprove(raw: unknown, stderr?: {
114
183
  * folding, no substring, no wildcards. `mode` absent, empty, or not a
115
184
  * string means no auto-approval, and `cfg === null` (block absent or
116
185
  * malformed) means no auto-approval regardless of `mode`.
186
+ *
187
+ * Takes only the `when` slice of the config rather than the whole block:
188
+ * this predicate reads exactly one field, and saying so in the signature
189
+ * keeps it honest as the block grows further keys (`harnesses`,
190
+ * `report_scan`) that have nothing to do with mode membership.
117
191
  */
118
- export declare function permissionModeAllowed(cfg: AutoApproveConfig | null, mode: unknown): boolean;
192
+ export declare function permissionModeAllowed(cfg: Pick<AutoApproveConfig, "when"> | null, mode: unknown): boolean;
119
193
  /**
120
194
  * Per-harness opt-in membership, the same exact-string-equality
121
195
  * discipline {@link permissionModeAllowed} applies to `when`. `cfg ===
@@ -133,4 +207,4 @@ export declare function permissionModeAllowed(cfg: AutoApproveConfig | null, mod
133
207
  * {@link CODEX_HARNESS} which still has exactly one consumer and stays a
134
208
  * direct import.
135
209
  */
136
- export declare function harnessAllowed(cfg: AutoApproveConfig | null, harness: unknown): boolean;
210
+ export declare function harnessAllowed(cfg: Pick<AutoApproveConfig, "harnesses"> | null, harness: unknown): boolean;
@@ -15,6 +15,13 @@
15
15
  // documents. The PreToolUse hook (auto-path condition checks) and
16
16
  // `harness doctor` (auto-approval listing) are the consumers; both
17
17
  // land in later slice-1 tasks and import from here.
18
+ //
19
+ // Slice 3 (agent-tasks 37ad0b05) adds `report_scan.max_wait`: the bound
20
+ // of the child's transcript poll under `claude -p` ("Report capture
21
+ // under `-p`" in the ADR). It lives in this block because it tunes the
22
+ // same opt-in path, and it is parsed here rather than at the hook so
23
+ // the lint-time schema and the runtime hook agree on one parser.
24
+ import { InvalidDurationError, parseDurationSeconds } from "../../../policies/index.js";
18
25
  /**
19
26
  * Prefix every auto-minted marker's `approvedBy` carries, distinguishing
20
27
  * it from a human `harness approve understanding` marker (which carries
@@ -97,7 +104,105 @@ export const AUTO_APPROVE_HARNESS_VALUES = [CLAUDE_CODE_HARNESS, CODEX_HARNESS];
97
104
  * visible config edit.
98
105
  */
99
106
  export const DEFAULT_AUTO_APPROVE_HARNESSES = [CLAUDE_CODE_HARNESS];
100
- const KNOWN_AUTO_APPROVE_KEYS = new Set(["when", "harnesses", "require_report"]);
107
+ /**
108
+ * What `auto_approve.report_scan.max_wait` resolves to when the key is
109
+ * ABSENT: the bound the child's PreToolUse hook waits for its own
110
+ * Understanding Report to reach the session transcript before it blocks
111
+ * (ADR "Report capture under `-p`", slice 3 acceptance criterion 3).
112
+ *
113
+ * The value is measured, not guessed: under `claude -p` the report is
114
+ * absent from the transcript at the instant PreToolUse fires and lands
115
+ * some time later, on a lag that scales with report length, so the
116
+ * bound is set from the real end-to-end runs (a full-length grill_me
117
+ * report), not only the shorter probe reports that first-guessed 500ms.
118
+ * The measurement and the retuning derivation are both in
119
+ * `docs/okf/understanding-gate-auto-mode-signals.md` ("Chosen
120
+ * `report_scan.max_wait` default" section), from
121
+ * `dogfood/ug-auto-mode-signals/`.
122
+ *
123
+ * ONE named constant on purpose: the hook, the schema default and every
124
+ * test read this symbol, so re-tuning the bound against a new
125
+ * measurement is a one-line change with no literal to hunt down.
126
+ */
127
+ export const DEFAULT_REPORT_SCAN_MAX_WAIT_MS = 2_000;
128
+ /**
129
+ * Hard ceiling for `auto_approve.report_scan.max_wait`. A larger value
130
+ * is a `harness validate` schema error AND a runtime parse failure (which
131
+ * fails the whole `auto_approve` block closed), so no configuration can
132
+ * make a PreToolUse hook sit on a session for an arbitrary time. 5 s is
133
+ * an order of magnitude above the measured worst-case flush, which is
134
+ * generous for a bound whose only job is to cover a transcript write
135
+ * already in flight.
136
+ */
137
+ export const REPORT_SCAN_MAX_WAIT_CEILING_MS = 5_000;
138
+ const KNOWN_AUTO_APPROVE_KEYS = new Set([
139
+ "when",
140
+ "harnesses",
141
+ "require_report",
142
+ "report_scan",
143
+ ]);
144
+ /** The only key `auto_approve.report_scan` accepts. */
145
+ const KNOWN_REPORT_SCAN_KEYS = new Set(["max_wait"]);
146
+ /** Sub-second shorthand the shared duration parser does not model. */
147
+ const MILLISECOND_SHORTHAND = /^(\d+)ms$/;
148
+ /**
149
+ * Parse `auto_approve.report_scan.max_wait` into milliseconds.
150
+ *
151
+ * Duration grammar: the pack's SHARED parser
152
+ * ({@link parseDurationSeconds}, the same one `approval_lifecycle.max_age`
153
+ * uses), plus an `<n>ms` shorthand it does not model. The extension is
154
+ * not cosmetic: this bound is a transcript-flush allowance measured in
155
+ * tens of milliseconds, so a second-granularity grammar could not express
156
+ * the values the measurement actually argues for, and widening
157
+ * `parseDurationSeconds` itself would change the grammar of every
158
+ * `within:` / `max_age:` / `--since` value in the repo for one key's sake.
159
+ *
160
+ * Both bounds are errors, never clamps: zero or negative (a bound that
161
+ * would disable the poll while the block still claimed to have one) and
162
+ * anything above {@link REPORT_SCAN_MAX_WAIT_CEILING_MS} (a bound that
163
+ * could park a PreToolUse hook). Returning a RESULT rather than throwing
164
+ * keeps the two consumers symmetric: the zod schema turns it into a
165
+ * `harness validate` diagnostic, the runtime parser into one stderr line
166
+ * and a fail-closed `null`.
167
+ */
168
+ export function parseReportScanMaxWait(raw) {
169
+ if (typeof raw !== "string" || raw.trim().length === 0) {
170
+ return {
171
+ ok: false,
172
+ reason: `expected a duration string like "500ms", "1500ms" or "2s", got ${typeof raw === "string" ? "an empty string" : typeof raw}`,
173
+ };
174
+ }
175
+ const trimmed = raw.trim();
176
+ let maxWaitMs;
177
+ const ms = MILLISECOND_SHORTHAND.exec(trimmed);
178
+ if (ms) {
179
+ maxWaitMs = Number.parseInt(ms[1], 10);
180
+ }
181
+ else {
182
+ try {
183
+ maxWaitMs = parseDurationSeconds(trimmed) * 1_000;
184
+ }
185
+ catch (err) {
186
+ return {
187
+ ok: false,
188
+ reason: err instanceof InvalidDurationError ? err.message : String(err),
189
+ };
190
+ }
191
+ }
192
+ if (!Number.isFinite(maxWaitMs) || maxWaitMs <= 0) {
193
+ return {
194
+ ok: false,
195
+ reason: `must be greater than zero, got ${JSON.stringify(trimmed)}`,
196
+ };
197
+ }
198
+ if (maxWaitMs > REPORT_SCAN_MAX_WAIT_CEILING_MS) {
199
+ return {
200
+ ok: false,
201
+ reason: `must not exceed the ${REPORT_SCAN_MAX_WAIT_CEILING_MS}ms hard ceiling (a PreToolUse hook must never park a session), got ${JSON.stringify(trimmed)}`,
202
+ };
203
+ }
204
+ return { ok: true, maxWaitMs };
205
+ }
101
206
  /**
102
207
  * Parse the optional `auto_approve` pack-config block
103
208
  * (docs/decisions/2026-08-27-ug-auto-mode-approval.md, "Option A").
@@ -176,12 +281,39 @@ export function parseAutoApprove(raw, stderr, label = "harness pack hook") {
176
281
  }
177
282
  harnesses = seen;
178
283
  }
284
+ // `report_scan`: absent means the measured default
285
+ // ({@link DEFAULT_REPORT_SCAN_MAX_WAIT_MS}). Present means an object
286
+ // carrying exactly `max_wait` and nothing else, parsed and
287
+ // range-checked by `parseReportScanMaxWait`. Anything else fails the
288
+ // WHOLE block closed, like every other malformed shape here, so a
289
+ // typo'd bound can never silently fall back to the default while the
290
+ // operator believes they tuned it.
291
+ const reportScanRaw = obj["report_scan"];
292
+ let reportScanMaxWaitMs = DEFAULT_REPORT_SCAN_MAX_WAIT_MS;
293
+ if (reportScanRaw !== undefined) {
294
+ if (reportScanRaw === null || typeof reportScanRaw !== "object" || Array.isArray(reportScanRaw)) {
295
+ stderr?.write(`${label}: config.auto_approve.report_scan ignored (expected object, got ${reportScanRaw === null ? "null" : Array.isArray(reportScanRaw) ? "array" : typeof reportScanRaw})\n`);
296
+ return null;
297
+ }
298
+ const reportScanObj = reportScanRaw;
299
+ const unknownScanKeys = Object.keys(reportScanObj).filter((k) => !KNOWN_REPORT_SCAN_KEYS.has(k));
300
+ if (unknownScanKeys.length > 0) {
301
+ stderr?.write(`${label}: config.auto_approve.report_scan ignored (unknown key(s): ${unknownScanKeys.join(", ")})\n`);
302
+ return null;
303
+ }
304
+ const maxWait = parseReportScanMaxWait(reportScanObj["max_wait"]);
305
+ if (!maxWait.ok) {
306
+ stderr?.write(`${label}: config.auto_approve.report_scan.max_wait ignored (${maxWait.reason})\n`);
307
+ return null;
308
+ }
309
+ reportScanMaxWaitMs = maxWait.maxWaitMs;
310
+ }
179
311
  const requireReport = obj["require_report"];
180
312
  if (requireReport !== true) {
181
313
  stderr?.write(`${label}: config.auto_approve ignored (require_report must be true, got ${requireReport === false ? "false" : typeof requireReport})\n`);
182
314
  return null;
183
315
  }
184
- return { when, harnesses };
316
+ return { when, harnesses, reportScan: { maxWaitMs: reportScanMaxWaitMs } };
185
317
  }
186
318
  /**
187
319
  * ADR "Additional hardening to specify" item 2: `when` is an allowlist
@@ -189,6 +321,11 @@ export function parseAutoApprove(raw, stderr, label = "harness pack hook") {
189
321
  * folding, no substring, no wildcards. `mode` absent, empty, or not a
190
322
  * string means no auto-approval, and `cfg === null` (block absent or
191
323
  * malformed) means no auto-approval regardless of `mode`.
324
+ *
325
+ * Takes only the `when` slice of the config rather than the whole block:
326
+ * this predicate reads exactly one field, and saying so in the signature
327
+ * keeps it honest as the block grows further keys (`harnesses`,
328
+ * `report_scan`) that have nothing to do with mode membership.
192
329
  */
193
330
  export function permissionModeAllowed(cfg, mode) {
194
331
  if (cfg === null)
@@ -1 +1 @@
1
- {"version":3,"file":"auto-approve.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/auto-approve.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,oEAAoE;AACpE,8DAA8D;AAC9D,8DAA8D;AAC9D,oEAAoE;AACpE,oEAAoE;AACpE,EAAE;AACF,iEAAiE;AACjE,gEAAgE;AAChE,sEAAsE;AACtE,qEAAqE;AACrE,kEAAkE;AAClE,mEAAmE;AACnE,oDAAoD;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAEpD,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,IAAY;IAC7D,OAAO,GAAG,uBAAuB,GAAG,OAAO,IAAI,IAAI,EAAE,CAAC;AACxD,CAAC;AAQD;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC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AAC;YACD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACf,CAAC;QACD,SAAS,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5C,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;QAC3B,MAAM,EAAE,KAAK,CACX,GAAG,KAAK,mEACN,aAAa,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,aAC7C,KAAK,CACN,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC7B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,GAA6B,EAAE,IAAa;IAChF,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC/B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAChE,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,GAA6B,EAAE,OAAgB;IAC5E,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtE,OAAO,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC"}
1
+ {"version":3,"file":"auto-approve.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/auto-approve.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,oEAAoE;AACpE,8DAA8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AME = ".delegations";
3
+ /**
4
+ * The signed markerId for a child session: `delegation-<child-sid>`.
5
+ * Binding it into the signed payload is what stops a validly signed
6
+ * delegation from being copied onto another child id, or onto a session
7
+ * marker's id, and still verifying (`task-markers.ts` precedent).
8
+ */
9
+ export declare function delegationMarkerIdFor(childSessionId: string): string;
10
+ /**
11
+ * Filesystem path of a child session's delegation marker. Rejects a
12
+ * malformed session id the same way `approvalMarkerPathFor` does (the
13
+ * value lands in a `path.join` verbatim).
14
+ */
15
+ export declare function delegationMarkerPathFor(generatedDir: string, childSessionId: string): string;
16
+ /**
17
+ * sha256 hex of a filesystem path, canonicalized through `realpathSync`
18
+ * when the path exists and through `path.resolve` when it does not.
19
+ *
20
+ * The canonicalization is the point, not an optimization: the parent
21
+ * writing the delegation and the child reporting its cwd routinely spell
22
+ * the same directory differently (on macOS `os.tmpdir()` hands out
23
+ * `/var/folders/...` while the process reports `/private/var/folders/...`,
24
+ * because `/var` is a symlink), and an uncanonicalized comparison would
25
+ * refuse a perfectly legitimate delegation. Falling back to `resolve` for
26
+ * a non-existent path keeps the function total: a path that cannot be
27
+ * canonicalized still hashes deterministically, and a delegation bound to
28
+ * it simply will not match a cwd that resolves elsewhere.
29
+ *
30
+ * Named for its primary use; the fallback shape hashes the launcher-
31
+ * supplied report file's PATH with the same function, so that WHERE the
32
+ * parent put the report is part of what was signed.
33
+ */
34
+ export declare function hashDelegationCwd(targetPath: string): string;
35
+ /** The bindings packed into a delegation's `approvedBy` string. */
36
+ export interface DelegationApprovedByFields {
37
+ parentSessionId: string;
38
+ /** sha256 of the child's expected cwd, or `null` for a task-only delegation. */
39
+ cwdHash: string | null;
40
+ /** The task id the child is delegated for, or `null` for a cwd-only delegation. */
41
+ taskId: string | null;
42
+ /** ISO-8601 instant at which the delegation stops being valid. */
43
+ expiresAt: string;
44
+ /** sha256 of the launcher-supplied report file's PATH; present only in the fallback shape. */
45
+ reportPathHash?: string;
46
+ }
47
+ /**
48
+ * Build the `approvedBy` string a delegation signs:
49
+ * `delegated:<parent>;cwd=<sha256|->;task=<id|->;expires=<iso>` plus
50
+ * `;report=<sha256>` in the fallback shape.
51
+ *
52
+ * Throws on any input that would corrupt the encoding (an empty value, a
53
+ * value carrying a `;` or `=` delimiter or a control character, a
54
+ * malformed parent session id (`rejectMalformedSessionId`), a cwd/report
55
+ * hash that is not a sha256 digest, a non-ISO expiry, or the literal `-`
56
+ * as a task id, which would round-trip as "no task bound"). A silently
57
+ * mis-encoded delegation would be signed and then read back with
58
+ * different bindings than the caller intended, so this fails loudly at
59
+ * the only place that can still tell the difference.
60
+ */
61
+ export declare function buildDelegationApprovedBy(fields: DelegationApprovedByFields): string;
62
+ /** Bindings read back out of a delegation's `approvedBy` string. */
63
+ export interface ParsedDelegationApprovedBy {
64
+ parentSessionId: string;
65
+ /** `null` when the delegation binds no cwd (`cwd=-`). */
66
+ cwdHash: string | null;
67
+ /** `null` when the delegation binds no task (`task=-`). */
68
+ taskId: string | null;
69
+ expiresAt: string;
70
+ /** Present only in the fallback shape. */
71
+ reportPathHash?: string;
72
+ }
73
+ export type DelegationApprovedByParse = {
74
+ ok: true;
75
+ value: ParsedDelegationApprovedBy;
76
+ } | {
77
+ ok: false;
78
+ reason: string;
79
+ };
80
+ /**
81
+ * Strict inverse of {@link buildDelegationApprovedBy}. All four of
82
+ * `delegated`, `cwd`, `task` and `expires` are required and `report` is
83
+ * optional; a missing, duplicated, unknown, empty or malformed segment is
84
+ * an error RESULT, never a default. Segment order is not enforced (the
85
+ * signature already pins the exact bytes), but every other deviation is
86
+ * refused: this string is the only place a delegation's bindings live, so
87
+ * "read it partially and assume the rest" is the one failure mode that
88
+ * would quietly widen a delegation past what the parent signed.
89
+ */
90
+ export declare function parseDelegationApprovedBy(approvedBy: unknown): DelegationApprovedByParse;
91
+ export interface WriteDelegationMarkerOptions {
92
+ generatedDir: string;
93
+ /** Session id of the `claude -p` child this delegation authorizes. Becomes the file name. */
94
+ childSessionId: string;
95
+ /** Session id of the already-approved parent issuing the delegation. */
96
+ parentSessionId: string;
97
+ /** {@link hashDelegationCwd} of the child's expected cwd, or `null` for a task-only delegation. */
98
+ cwdHash: string | null;
99
+ /** Task id the child is delegated for, or `null` for a cwd-only delegation. */
100
+ taskId: string | null;
101
+ /** ISO-8601 instant the delegation expires at. */
102
+ expiresAt: string;
103
+ /** Fallback shape: {@link hashDelegationCwd} of the launcher-supplied report file's path. */
104
+ reportPathHash?: string;
105
+ /** Fallback shape: sha256 of that file's CONTENT. Omitted (written as `null`) in the base shape. */
106
+ reportContentHash?: string;
107
+ /** Override the issue timestamp for deterministic tests. */
108
+ now?: Date;
109
+ }
110
+ export type WriteDelegationMarkerResult = {
111
+ ok: true;
112
+ filePath: string;
113
+ markerId: string;
114
+ approvedAt: string;
115
+ approvedBy: string;
116
+ } | {
117
+ ok: false;
118
+ reason: "signing-key-absent" | "invalid-input" | "write-failed";
119
+ detail: string;
120
+ };
121
+ /**
122
+ * Write a signed delegation marker through the shared `signMarker` path,
123
+ * under markerId `delegation-<child-sid>`, at
124
+ * `<generatedDir>/.delegations/<child-sid>`. Atomic and mode 0600, like
125
+ * every other marker write.
126
+ *
127
+ * NEVER CREATES THE SIGNING KEY. `signMarker` -> `getOrCreateSigningKey`
128
+ * treats a missing key as a case to REPAIR, generating one and signing
129
+ * with it; key creation is an operator-side act (`harness init`,
130
+ * `harness approve`), and a delegation minted on a machine that never had
131
+ * a key would be a marker signed by whoever asked for it. So this
132
+ * prechecks `signingKeyExists` and returns `signing-key-absent` without
133
+ * reaching the write path at all (ADR threat model (b) item 5, the same
134
+ * rule slice 1's auto path follows).
135
+ *
136
+ * Returns a result rather than throwing, for every failure mode: the
137
+ * callers are a CLI verb and, later, a hook, and both must fail closed
138
+ * with a diagnostic instead of unwinding.
139
+ *
140
+ * Deliberately does NOT refuse a delegation that binds neither cwd nor
141
+ * task. That refusal belongs to the issuing verb (ADR slice 3 acceptance
142
+ * criterion 1) and to `verifyDelegation`, which reports `no_binding`;
143
+ * keeping the writer able to produce one is what lets the test suite
144
+ * exercise that verifier branch against a genuinely signed artifact
145
+ * rather than a hand-rolled fake.
146
+ */
147
+ export declare function writeDelegationMarker(opts: WriteDelegationMarkerOptions): WriteDelegationMarkerResult;
148
+ /**
149
+ * Why a delegation was refused. Every value is reachable and distinct;
150
+ * there is no "unknown" bucket and no branch that falls through to
151
+ * allow.
152
+ */
153
+ export type DelegationRefusalReason =
154
+ /** No delegation file for this child session (also: a child session id that cannot name a file). */
155
+ "missing"
156
+ /** The file exists but its integrity cannot be established right now: symlink, non-regular, I/O error, or an unavailable signing key. Not a claim of tampering. */
157
+ | "unreadable"
158
+ /** A file was there and its signature does not verify against `delegation-<child-sid>`: unsigned, wrong alg, tampered, or copied from another child's delegation. */
159
+ | "forged"
160
+ /** Validly signed, but its `approvedBy` bindings cannot be read in full. */
161
+ | "unparseable" | "expired" | "cwd_mismatch" | "task_mismatch"
162
+ /** Binds neither a cwd nor a task, so it would authorize the child anywhere, for anything. */
163
+ | "no_binding"
164
+ /** Fallback shape: the launcher report is not at the path the parent signed. */
165
+ | "report_path_mismatch"
166
+ /** Fallback shape: the launcher report's content is not what the parent signed (including a report that cannot be read). */
167
+ | "report_content_mismatch";
168
+ export type DelegationVerification = {
169
+ ok: true;
170
+ parentSessionId: string;
171
+ expiresAt: string;
172
+ boundCwdHash: string | null;
173
+ boundTaskId: string | null;
174
+ reportPathHash?: string;
175
+ } | {
176
+ ok: false;
177
+ reason: DelegationRefusalReason;
178
+ detail: string;
179
+ };
180
+ export interface VerifyDelegationOptions {
181
+ generatedDir: string;
182
+ /** The child session whose delegation is being checked. */
183
+ childSessionId: string;
184
+ /** The child's actual cwd, or `null` when the caller has none to offer. */
185
+ cwd: string | null;
186
+ /** The child's actual task id, or `null` when the caller has none to offer. */
187
+ taskId: string | null;
188
+ /** Fallback shape: the launcher-supplied report file the parent bound. */
189
+ launcherReportPath?: string;
190
+ /** Override "now" for deterministic tests. */
191
+ now?: Date;
192
+ }
193
+ /**
194
+ * Gate-side: is there a valid, unexpired, matching delegation for this
195
+ * child session? Checks, in order (ADR slice 3 acceptance criterion 2):
196
+ *
197
+ * 1. the file is present and JSON-readable,
198
+ * 2. its signature verifies against markerId `delegation-<child-sid>`,
199
+ * 3. its `approvedBy` segments parse in full,
200
+ * 4. it binds at least one of cwd / task,
201
+ * 5. it has not expired,
202
+ * 6. the bound cwd hash-matches the caller's cwd,
203
+ * 7. the bound task equals the caller's task,
204
+ * 8. in the fallback shape, the launcher report sits at the bound path
205
+ * AND hashes to the bound content.
206
+ *
207
+ * Reads only `.delegations/`; an artifact in `.approvals/` is `missing`
208
+ * here, whatever it contains.
209
+ *
210
+ * NEVER CREATES THE SIGNING KEY, on the READ path either.
211
+ * `verifyMarkerSignature` obtains the key through
212
+ * `getOrCreateSigningKey`, which treats a missing key as a case to
213
+ * REPAIR and generates one; on a machine the operator never initialized
214
+ * that would make a mere gate-time read perform the operator-side act of
215
+ * minting the key. It cannot make a foreign-signed delegation verify, but
216
+ * it does leave a key behind that every LATER write path would then
217
+ * happily sign with, so the never-create rule applies here exactly as it
218
+ * does to `writeDelegationMarker` and to slice 1's auto path. An absent
219
+ * key is reported as `unreadable` (we could not check, not "we checked
220
+ * and it is a forgery"), the same class `verifyMarkerSignature`'s own
221
+ * `key-unavailable` lands in below.
222
+ */
223
+ export declare function verifyDelegation(opts: VerifyDelegationOptions): DelegationVerification;