@intutic/shared-types 2.9.1 → 3.0.1

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 (119) hide show
  1. package/dist/decide.d.ts +269 -0
  2. package/dist/decide.d.ts.map +1 -0
  3. package/dist/decide.js +781 -0
  4. package/dist/decide.js.map +1 -0
  5. package/dist/decideEngine.d.ts +195 -0
  6. package/dist/decideEngine.d.ts.map +1 -0
  7. package/dist/decideEngine.js +720 -0
  8. package/dist/decideEngine.js.map +1 -0
  9. package/dist/decideEvaluate.d.ts +250 -0
  10. package/dist/decideEvaluate.d.ts.map +1 -0
  11. package/dist/decideEvaluate.js +518 -0
  12. package/dist/decideEvaluate.js.map +1 -0
  13. package/dist/decideHostGuard.d.ts +56 -0
  14. package/dist/decideHostGuard.d.ts.map +1 -0
  15. package/dist/decideHostGuard.js +200 -0
  16. package/dist/decideHostGuard.js.map +1 -0
  17. package/dist/decideLog.d.ts +287 -0
  18. package/dist/decideLog.d.ts.map +1 -0
  19. package/dist/decideLog.js +543 -0
  20. package/dist/decideLog.js.map +1 -0
  21. package/dist/decideLogRedaction.d.ts +12 -0
  22. package/dist/decideLogRedaction.d.ts.map +1 -0
  23. package/dist/decideLogRedaction.js +19 -0
  24. package/dist/decideLogRedaction.js.map +1 -0
  25. package/dist/decideRecord.d.ts +128 -0
  26. package/dist/decideRecord.d.ts.map +1 -0
  27. package/dist/decideRecord.js +266 -0
  28. package/dist/decideRecord.js.map +1 -0
  29. package/dist/decideSdk.d.ts +86 -0
  30. package/dist/decideSdk.d.ts.map +1 -0
  31. package/dist/decideSdk.js +151 -0
  32. package/dist/decideSdk.js.map +1 -0
  33. package/dist/errors.d.ts +11 -1
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js +12 -1
  36. package/dist/errors.js.map +1 -1
  37. package/dist/gateLimits.d.ts +27 -0
  38. package/dist/gateLimits.d.ts.map +1 -1
  39. package/dist/gateLimits.js +29 -1
  40. package/dist/gateLimits.js.map +1 -1
  41. package/dist/gateRuleRecord.d.ts +244 -0
  42. package/dist/gateRuleRecord.d.ts.map +1 -0
  43. package/dist/gateRuleRecord.js +474 -0
  44. package/dist/gateRuleRecord.js.map +1 -0
  45. package/dist/guardrailIr.d.ts +301 -10
  46. package/dist/guardrailIr.d.ts.map +1 -1
  47. package/dist/guardrailIr.js +86 -7
  48. package/dist/guardrailIr.js.map +1 -1
  49. package/dist/guardrailRender.d.ts +35 -2
  50. package/dist/guardrailRender.d.ts.map +1 -1
  51. package/dist/guardrailRender.js +133 -7
  52. package/dist/guardrailRender.js.map +1 -1
  53. package/dist/index.d.ts +28 -6
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +162 -8
  56. package/dist/index.js.map +1 -1
  57. package/dist/lanes.d.ts +94 -0
  58. package/dist/lanes.d.ts.map +1 -0
  59. package/dist/lanes.js +160 -0
  60. package/dist/lanes.js.map +1 -0
  61. package/dist/loopVerify.d.ts +49 -0
  62. package/dist/loopVerify.d.ts.map +1 -0
  63. package/dist/loopVerify.js +77 -0
  64. package/dist/loopVerify.js.map +1 -0
  65. package/dist/mcpBudgets.d.ts +8 -8
  66. package/dist/notifications.d.ts +1 -1
  67. package/dist/notifications.d.ts.map +1 -1
  68. package/dist/notifications.js +14 -0
  69. package/dist/notifications.js.map +1 -1
  70. package/dist/providers.d.ts +13 -0
  71. package/dist/providers.d.ts.map +1 -1
  72. package/dist/providers.js +31 -0
  73. package/dist/providers.js.map +1 -1
  74. package/dist/refusalDetail.d.ts +58 -0
  75. package/dist/refusalDetail.d.ts.map +1 -0
  76. package/dist/refusalDetail.js +128 -0
  77. package/dist/refusalDetail.js.map +1 -0
  78. package/dist/responses/decide.d.ts +1858 -0
  79. package/dist/responses/decide.d.ts.map +1 -0
  80. package/dist/responses/decide.js +166 -0
  81. package/dist/responses/decide.js.map +1 -0
  82. package/dist/responses/gateways.d.ts +745 -101
  83. package/dist/responses/gateways.d.ts.map +1 -1
  84. package/dist/responses/gateways.js +34 -2
  85. package/dist/responses/gateways.js.map +1 -1
  86. package/dist/responses/guardrails.d.ts +1434 -144
  87. package/dist/responses/guardrails.d.ts.map +1 -1
  88. package/dist/responses/identity.d.ts +6 -6
  89. package/dist/responses/index.d.ts +1 -0
  90. package/dist/responses/index.d.ts.map +1 -1
  91. package/dist/responses/index.js +1 -0
  92. package/dist/responses/index.js.map +1 -1
  93. package/dist/responses/integrations.d.ts +84 -84
  94. package/dist/responses/observability.d.ts +272 -92
  95. package/dist/responses/observability.d.ts.map +1 -1
  96. package/dist/responses/observability.js +31 -1
  97. package/dist/responses/observability.js.map +1 -1
  98. package/dist/responses/rules.d.ts +1026 -187
  99. package/dist/responses/rules.d.ts.map +1 -1
  100. package/dist/responses/rules.js +47 -1
  101. package/dist/responses/rules.js.map +1 -1
  102. package/dist/scopeMatch.d.ts +156 -0
  103. package/dist/scopeMatch.d.ts.map +1 -0
  104. package/dist/scopeMatch.js +451 -0
  105. package/dist/scopeMatch.js.map +1 -0
  106. package/dist/sopKeySince.d.ts +41 -0
  107. package/dist/sopKeySince.d.ts.map +1 -0
  108. package/dist/sopKeySince.js +81 -0
  109. package/dist/sopKeySince.js.map +1 -0
  110. package/dist/testOutcome.d.ts +164 -0
  111. package/dist/testOutcome.d.ts.map +1 -0
  112. package/dist/testOutcome.js +454 -0
  113. package/dist/testOutcome.js.map +1 -0
  114. package/dist/upstreamRetry.d.ts +2 -2
  115. package/dist/workspaceSettings.d.ts +91 -0
  116. package/dist/workspaceSettings.d.ts.map +1 -1
  117. package/dist/workspaceSettings.js +48 -2
  118. package/dist/workspaceSettings.js.map +1 -1
  119. package/package.json +2 -2
@@ -0,0 +1,451 @@
1
+ "use strict";
2
+ /**
3
+ * Scope and plan semantics, ported from the proxy so every surface answers
4
+ * "is this change inside the scope?" and "is this run on its plan?" the same
5
+ * way.
6
+ *
7
+ * | Function | Port of |
8
+ * |---|---|
9
+ * | {@link isWithinScope} | `is_within_scope`, `plugins/anomaly/detectors.rs` |
10
+ * | {@link collectScopePaths} | `collect_scope_paths`, `sops.rs`, the org ceiling included |
11
+ * | {@link planOffSteps} | `PlanAdherenceDetector`, `detectors.rs`, with {@link PLAN_DEVIATION_TOLERANCE} |
12
+ * | {@link changeTargets} | `manifest_from_invocations`, `manifest.rs`: the mutation entries of one call |
13
+ * | {@link diffChangedPaths} | (new) the paths a unified or git diff changes |
14
+ *
15
+ * Beside them, what only the gates need: {@link scopeRelativePath} makes a
16
+ * gate's target relative to its workspace root (a path outside the root is
17
+ * out of scope), {@link isPlanExemptTool} names the calls `plan_approval:`
18
+ * never refuses, and {@link isFileWriteCall} says whether a call changed files,
19
+ * which makes an earlier passing test run stale (Q1).
20
+ *
21
+ * Self-contained but for `./phrases.ts`, so `@intutic/gate` keeps a
22
+ * byte-identical copy and the JavaScript hook gates embed
23
+ * {@link SCOPE_MATCH_JS_SOURCE} beside the phrase matcher's source. The
24
+ * Python port is `intutic_clawde/gate/scope_match.py`; the proxy's Rust runs
25
+ * the same `fixtures/scope-plan-vectors.json`. `manifestParity.test.ts`
26
+ * holds the tool and key lists to `manifest.rs` and `actions.rs`.
27
+ *
28
+ * @module
29
+ */
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.SCOPE_MATCH_JS_SOURCE = exports.FILE_WRITE_SHELL_PHRASES = exports.PLAN_EXEMPT_TOOLS = exports.SCOPE_TARGET_MAX_BYTES = exports.SCOPE_MOVE_TO_KEYS = exports.SCOPE_MOVE_FROM_KEYS = exports.SCOPE_READ_TOOLS = exports.SCOPE_SHELL_TOOLS = exports.SCOPE_COMMAND_KEYS = exports.SCOPE_PATH_KEYS = exports.SCOPE_EDITOR_TOOLS = exports.SCOPE_MOVE_TOOLS = exports.SCOPE_DELETE_TOOLS = exports.SCOPE_EDIT_TOOLS = exports.SCOPE_WRITE_TOOLS = exports.NARROWED_TO_NOTHING = exports.PLAN_DEVIATION_TOLERANCE = void 0;
32
+ exports.isWithinScope = isWithinScope;
33
+ exports.sopAppliesToRole = sopAppliesToRole;
34
+ exports.collectScopePaths = collectScopePaths;
35
+ exports.collectPlanSteps = collectPlanSteps;
36
+ exports.planOffSteps = planOffSteps;
37
+ exports.changeTargets = changeTargets;
38
+ exports.diffChangedPaths = diffChangedPaths;
39
+ exports.scopeRelativePath = scopeRelativePath;
40
+ exports.isPlanExemptTool = isPlanExemptTool;
41
+ exports.isFileWriteCall = isFileWriteCall;
42
+ const phrases_js_1 = require("./phrases.js");
43
+ /** The share of off-plan steps a plan forgives under `plan_steps_mode: advise` (`PLAN_DEVIATION_TOLERANCE` in detectors.rs). */
44
+ exports.PLAN_DEVIATION_TOLERANCE = 0.4;
45
+ /** What an org ceiling disjoint from the workspace list leaves (`NARROWED_TO_NOTHING`, sops.rs): no path is inside it. */
46
+ exports.NARROWED_TO_NOTHING = '<none: workspace list disjoint from org ceiling>';
47
+ /** `WRITE_TOOLS`, manifest.rs. */
48
+ exports.SCOPE_WRITE_TOOLS = ['write', 'write_file', 'writefile', 'create_file', 'createfile'];
49
+ /** `EDIT_TOOLS`, manifest.rs. */
50
+ exports.SCOPE_EDIT_TOOLS = ['edit', 'edit_file', 'editfile', 'multiedit', 'apply_patch', 'str_replace', 'notebookedit'];
51
+ /** `DELETE_TOOLS`, manifest.rs. */
52
+ exports.SCOPE_DELETE_TOOLS = ['delete_file', 'deletefile', 'remove_file', 'rm_file'];
53
+ /** `MOVE_TOOLS`, manifest.rs. */
54
+ exports.SCOPE_MOVE_TOOLS = ['move_file', 'movefile', 'rename_file', 'rename'];
55
+ /** `EDITOR_TOOLS`, actions.rs: the text editor, whose `command` decides whether it writes. */
56
+ exports.SCOPE_EDITOR_TOOLS = ['str_replace_editor', 'text_editor', 'texteditor', 'str_replace_based_edit_tool'];
57
+ /** `PATH_KEYS`, manifest.rs. */
58
+ exports.SCOPE_PATH_KEYS = ['file_path', 'filepath', 'path', 'filename', 'target_file', 'notebook_path'];
59
+ /** `COMMAND_KEYS`, manifest.rs. */
60
+ exports.SCOPE_COMMAND_KEYS = ['command', 'cmd', 'script'];
61
+ /** `SHELL_TOOLS`, actions.rs. */
62
+ exports.SCOPE_SHELL_TOOLS = ['bash', 'shell', 'run_command', 'runcommand', 'execute_command', 'run_shell_command', 'terminal', 'execute', 'exec'];
63
+ /** `READ_TOOLS`, actions.rs. */
64
+ exports.SCOPE_READ_TOOLS = ['read', 'readfile', 'view', 'cat', 'open_file'];
65
+ /** A move's source and destination keys, manifest.rs. */
66
+ exports.SCOPE_MOVE_FROM_KEYS = ['source', 'source_path', 'from', 'old_path'];
67
+ exports.SCOPE_MOVE_TO_KEYS = ['destination', 'destination_path', 'to', 'new_path'];
68
+ /** A target is cut to this many bytes, and marked with `…` when it was (`TARGET_MAX`, manifest.rs). */
69
+ exports.SCOPE_TARGET_MAX_BYTES = 512;
70
+ /**
71
+ * Tools `plan_approval:` never refuses: the read tools and the search and
72
+ * listing tools an agent needs to write a plan in the first place.
73
+ */
74
+ exports.PLAN_EXEMPT_TOOLS = ['read', 'readfile', 'view', 'cat', 'open_file', 'glob', 'grep', 'ls', 'list_dir', 'search', 'todowrite'];
75
+ /**
76
+ * Shell phrases that change files in the working tree. With the mutation
77
+ * tools ({@link changeTargets}), a call matching one makes an earlier passing
78
+ * test run stale ({@link isFileWriteCall}).
79
+ */
80
+ exports.FILE_WRITE_SHELL_PHRASES = [
81
+ 'sed -i',
82
+ 'perl -i',
83
+ 'perl -pi',
84
+ 'git apply',
85
+ 'git am',
86
+ 'git checkout',
87
+ 'git switch',
88
+ 'git restore',
89
+ 'git reset',
90
+ 'git merge',
91
+ 'git pull',
92
+ 'git rebase',
93
+ 'git cherry-pick',
94
+ 'git revert',
95
+ 'git stash pop',
96
+ 'git stash apply',
97
+ 'patch -p',
98
+ ];
99
+ /** ASCII lower case, as Rust's `to_ascii_lowercase`. */
100
+ function scopeAsciiLower(s) {
101
+ return s.replace(/[A-Z]+/g, (m) => m.toLowerCase());
102
+ }
103
+ /** `tool_is`, actions.rs: the name, lower-cased, is one of `group` or ends with one. */
104
+ function scopeToolIs(name, group) {
105
+ const lower = name.toLowerCase();
106
+ for (const t of group)
107
+ if (lower === t || lower.slice(-t.length) === t)
108
+ return true;
109
+ return false;
110
+ }
111
+ /** The first of `keys` whose value in `input` is a non-empty string. */
112
+ function scopeKeyed(input, keys) {
113
+ if (input === null || typeof input !== 'object' || Array.isArray(input))
114
+ return null;
115
+ const o = input;
116
+ for (const k of keys) {
117
+ const v = o[k];
118
+ if (typeof v === 'string' && v !== '')
119
+ return v;
120
+ }
121
+ return null;
122
+ }
123
+ /** `clip`, manifest.rs: the first {@link SCOPE_TARGET_MAX_BYTES} bytes, and `…` when cut. */
124
+ function scopeClip(s) {
125
+ let bytes = 0;
126
+ let i = 0;
127
+ while (i < s.length) {
128
+ const c = s.charCodeAt(i);
129
+ let n = 3;
130
+ let w = 1;
131
+ if (c < 0x80)
132
+ n = 1;
133
+ else if (c < 0x800)
134
+ n = 2;
135
+ else if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {
136
+ const l = s.charCodeAt(i + 1);
137
+ if (l >= 0xdc00 && l <= 0xdfff) {
138
+ n = 4;
139
+ w = 2;
140
+ }
141
+ }
142
+ if (bytes + n > 512)
143
+ return s.slice(0, i) + '…';
144
+ bytes += n;
145
+ i += w;
146
+ }
147
+ return s;
148
+ }
149
+ /**
150
+ * Is `target` inside any of `scopes`? Segment-prefix match: `packages/proxy`
151
+ * covers `packages/proxy/src/main.rs`, not `packages/proxy-extras/x.rs`.
152
+ * Leading `./` and `/` and trailing `/` are dropped, and the comparison
153
+ * ignores ASCII case. An empty scope covers everything.
154
+ */
155
+ function isWithinScope(target, scopes) {
156
+ const norm = (s) => {
157
+ let t = s;
158
+ while (t.slice(0, 2) === './')
159
+ t = t.slice(2);
160
+ let a = 0;
161
+ while (a < t.length && t.charAt(a) === '/')
162
+ a++;
163
+ t = t.slice(a);
164
+ let b = t.length;
165
+ while (b > 0 && t.charAt(b - 1) === '/')
166
+ b--;
167
+ return scopeAsciiLower(t.slice(0, b));
168
+ };
169
+ const t = norm(target);
170
+ for (const raw of scopes) {
171
+ const s = norm(raw);
172
+ if (s === '' || t === s || t.slice(0, s.length + 1) === s + '/')
173
+ return true;
174
+ }
175
+ return false;
176
+ }
177
+ /** `applies_to`, sops.rs: an unscoped SOP applies to everyone; a scoped one only to its roles, and never to a caller with no role. */
178
+ function sopAppliesToRole(roles, role) {
179
+ if (roles.length === 0)
180
+ return true;
181
+ if (role === '')
182
+ return false;
183
+ return roles.indexOf(scopeAsciiLower(role)) !== -1;
184
+ }
185
+ /**
186
+ * The path scope in force for `role` (`collect_scope_paths`): the workspace
187
+ * SOPs' scopes, narrowed by the org SOPs' (a workspace scope survives when it
188
+ * is inside an org one; none surviving is {@link NARROWED_TO_NOTHING}; no
189
+ * workspace scope takes the org's), sorted and deduplicated. Empty means
190
+ * unrestricted.
191
+ */
192
+ function collectScopePaths(sops, role) {
193
+ const workspace = [];
194
+ const org = [];
195
+ for (const s of sops) {
196
+ if (!sopAppliesToRole(s.roles, role))
197
+ continue;
198
+ for (const p of s.scopePaths)
199
+ (s.scope === 'org' ? org : workspace).push(p);
200
+ }
201
+ let out;
202
+ if (org.length === 0)
203
+ out = workspace;
204
+ else if (workspace.length === 0)
205
+ out = org;
206
+ else {
207
+ out = workspace.filter((w) => isWithinScope(w, org));
208
+ if (out.length === 0)
209
+ out = [exports.NARROWED_TO_NOTHING];
210
+ }
211
+ return out.slice().sort().filter((p, i, all) => i === 0 || all[i - 1] !== p);
212
+ }
213
+ /**
214
+ * The plan in force for `role` (`collect_plan_steps`, sops.rs): the
215
+ * workspace SOPs' steps in order, not deduplicated (a plan is a sequence),
216
+ * narrowed by the org SOPs' steps by membership ignoring ASCII case (none
217
+ * surviving is {@link NARROWED_TO_NOTHING}; no workspace plan takes the
218
+ * org's). Empty means no plan.
219
+ */
220
+ function collectPlanSteps(sops, role) {
221
+ const workspace = [];
222
+ const org = [];
223
+ for (const s of sops) {
224
+ if (!sopAppliesToRole(s.roles, role))
225
+ continue;
226
+ for (const p of s.planSteps)
227
+ (s.scope === 'org' ? org : workspace).push(p);
228
+ }
229
+ if (org.length === 0)
230
+ return workspace;
231
+ if (workspace.length === 0)
232
+ return org;
233
+ const allowed = org.map(scopeAsciiLower);
234
+ const out = workspace.filter((w) => allowed.indexOf(scopeAsciiLower(w)) !== -1);
235
+ return out.length > 0 ? out : [exports.NARROWED_TO_NOTHING];
236
+ }
237
+ /**
238
+ * The off-plan steps of `sequence` against `planSteps` (`PlanAdherenceDetector`):
239
+ * empty when there is no plan or no sequence, or when the off-plan share is
240
+ * at most `tolerance`; otherwise the off-plan names, sorted and deduplicated,
241
+ * with the share. Names compare ignoring ASCII case.
242
+ */
243
+ function planOffSteps(sequence, planSteps, tolerance) {
244
+ if (planSteps.length === 0 || sequence.length === 0)
245
+ return { offPlan: [], ratio: 0 };
246
+ const plan = planSteps.map(scopeAsciiLower);
247
+ const off = sequence.filter((t) => plan.indexOf(scopeAsciiLower(t)) === -1);
248
+ if (off.length === 0)
249
+ return { offPlan: [], ratio: 0 };
250
+ const ratio = off.length / sequence.length;
251
+ if (ratio <= tolerance)
252
+ return { offPlan: [], ratio };
253
+ return { offPlan: off.slice().sort().filter((p, i, all) => i === 0 || all[i - 1] !== p), ratio: Math.min(1, ratio) };
254
+ }
255
+ /**
256
+ * The mutations one tool call makes, as the proxy's change manifest records
257
+ * them: a move's source and destination; a text-editor call unless it is a
258
+ * `view`; a write, edit or delete tool's path. Only path targets that are not
259
+ * empty, each clipped as the manifest clips it. A shell command is never a
260
+ * path, so a shell call has none.
261
+ */
262
+ function changeTargets(tool, input) {
263
+ if (scopeToolIs(tool, ['move_file', 'movefile', 'rename_file', 'rename'])) {
264
+ const from = scopeKeyed(input, ['source', 'source_path', 'from', 'old_path']);
265
+ const to = scopeKeyed(input, ['destination', 'destination_path', 'to', 'new_path']);
266
+ if (from !== null || to !== null) {
267
+ const out = [];
268
+ if (from !== null)
269
+ out.push({ op: 'move', target: scopeClip(from) });
270
+ if (to !== null)
271
+ out.push({ op: 'move', target: scopeClip(to) });
272
+ return out;
273
+ }
274
+ }
275
+ const keys = ['file_path', 'filepath', 'path', 'filename', 'target_file', 'notebook_path'];
276
+ let op = null;
277
+ if (scopeToolIs(tool, ['str_replace_editor', 'text_editor', 'texteditor', 'str_replace_based_edit_tool'])) {
278
+ const o = input !== null && typeof input === 'object' && !Array.isArray(input) ? input : {};
279
+ const command = typeof o.command === 'string' ? scopeAsciiLower(o.command) : '';
280
+ op = command === 'view' ? null : command === 'create' ? 'write' : 'edit';
281
+ if (op === null)
282
+ return [];
283
+ }
284
+ else if (scopeToolIs(tool, ['write', 'write_file', 'writefile', 'create_file', 'createfile']))
285
+ op = 'write';
286
+ else if (scopeToolIs(tool, ['edit', 'edit_file', 'editfile', 'multiedit', 'apply_patch', 'str_replace', 'notebookedit']))
287
+ op = 'edit';
288
+ else if (scopeToolIs(tool, ['delete_file', 'deletefile', 'remove_file', 'rm_file']))
289
+ op = 'delete';
290
+ if (op === null)
291
+ return [];
292
+ const target = scopeKeyed(input, keys);
293
+ return target === null ? [] : [{ op, target: scopeClip(target) }];
294
+ }
295
+ /** One path from a diff header, or null: quotes dropped, a `a/` or `b/` prefix dropped, `/dev/null` and empty refused, anything after a tab cut. */
296
+ function scopeDiffPath(raw, prefix) {
297
+ let p = raw;
298
+ const tab = p.indexOf('\t');
299
+ if (tab !== -1)
300
+ p = p.slice(0, tab);
301
+ // Spaces only (not tabs), trimmed by index: a `/[ ]+$/` backtracks
302
+ // quadratically on a long run of spaces that is not at the end.
303
+ let start = 0;
304
+ let end = p.length;
305
+ while (start < end && p.charCodeAt(start) === 32)
306
+ start++;
307
+ while (end > start && p.charCodeAt(end - 1) === 32)
308
+ end--;
309
+ p = p.slice(start, end);
310
+ if (p.length >= 2 && p.charAt(0) === '"' && p.charAt(p.length - 1) === '"')
311
+ p = p.slice(1, -1);
312
+ if (p === '/dev/null' || p === '')
313
+ return null;
314
+ if (prefix !== '' && p.slice(0, prefix.length) === prefix)
315
+ p = p.slice(prefix.length);
316
+ return p === '' ? null : p;
317
+ }
318
+ /**
319
+ * The paths a diff changes, in the order first seen, each once: from
320
+ * `diff --git a/X b/Y` (both, when it splits unambiguously), `--- a/X`,
321
+ * `+++ b/Y`, `rename from X` and `rename to Y`. `/dev/null` is not a path.
322
+ */
323
+ function diffChangedPaths(diff) {
324
+ const out = [];
325
+ const add = (p) => {
326
+ if (p !== null && out.indexOf(p) === -1)
327
+ out.push(p);
328
+ };
329
+ for (const raw of diff.split('\n')) {
330
+ const line = raw.replace(/\r$/, '');
331
+ if (line.slice(0, 11) === 'diff --git ') {
332
+ const rest = line.slice(11);
333
+ if (rest.slice(0, 2) !== 'a/')
334
+ continue;
335
+ const first = rest.indexOf(' b/');
336
+ if (first === -1)
337
+ continue;
338
+ if (rest.indexOf(' b/', first + 1) === -1) {
339
+ add(scopeDiffPath(rest.slice(0, first), 'a/'));
340
+ add(scopeDiffPath(rest.slice(first + 1), 'b/'));
341
+ }
342
+ else if ((rest.length - 5) % 2 === 0) {
343
+ // `a/P b/P` with ` b/` inside P: the split that names one path twice.
344
+ const n = (rest.length - 5) / 2;
345
+ const a = rest.slice(2, 2 + n);
346
+ if (rest.slice(2 + n, 5 + n) === ' b/' && rest.slice(5 + n) === a)
347
+ add(scopeDiffPath(a, ''));
348
+ }
349
+ }
350
+ else if (line.slice(0, 4) === '--- ')
351
+ add(scopeDiffPath(line.slice(4), 'a/'));
352
+ else if (line.slice(0, 4) === '+++ ')
353
+ add(scopeDiffPath(line.slice(4), 'b/'));
354
+ else if (line.slice(0, 12) === 'rename from ')
355
+ add(scopeDiffPath(line.slice(12), ''));
356
+ else if (line.slice(0, 10) === 'rename to ')
357
+ add(scopeDiffPath(line.slice(10), ''));
358
+ }
359
+ return out;
360
+ }
361
+ /** A POSIX path with `.` and `..` resolved and slashes collapsed; `..` never climbs above `/`. */
362
+ function scopeNormalisePath(p) {
363
+ const parts = [];
364
+ for (const seg of p.split('/')) {
365
+ if (seg === '' || seg === '.')
366
+ continue;
367
+ if (seg === '..')
368
+ parts.pop();
369
+ else
370
+ parts.push(seg);
371
+ }
372
+ return '/' + parts.join('/');
373
+ }
374
+ /**
375
+ * `target` relative to the workspace `root` (both resolved against `cwd`
376
+ * when relative), or null when it is outside the root, names a home
377
+ * directory (`~`), or either path is not absolute after resolving. A gate
378
+ * checks the result with {@link isWithinScope}; null is out of scope.
379
+ */
380
+ function scopeRelativePath(target, cwd, root) {
381
+ if (target === '' || target.charAt(0) === '~' || cwd.charAt(0) !== '/' || root.charAt(0) !== '/')
382
+ return null;
383
+ const abs = scopeNormalisePath(target.charAt(0) === '/' ? target : cwd + '/' + target);
384
+ const base = scopeNormalisePath(root);
385
+ if (abs === base)
386
+ return '';
387
+ const head = base === '/' ? '/' : base + '/';
388
+ return abs.slice(0, head.length) === head ? abs.slice(head.length) : null;
389
+ }
390
+ /** Whether `plan_approval:` lets `tool` run before the plan is approved: one of {@link PLAN_EXEMPT_TOOLS}, ignoring case, bare or as an MCP tool (`mcp__<server>__grep`). */
391
+ function isPlanExemptTool(tool) {
392
+ const lower = tool.toLowerCase();
393
+ for (const t of ['read', 'readfile', 'view', 'cat', 'open_file', 'glob', 'grep', 'ls', 'list_dir', 'search', 'todowrite']) {
394
+ if (lower === t || lower.slice(-(t.length + 2)) === '__' + t)
395
+ return true;
396
+ }
397
+ return false;
398
+ }
399
+ /**
400
+ * Whether the call changed files: a mutation ({@link changeTargets}) or a
401
+ * shell command with one of {@link FILE_WRITE_SHELL_PHRASES} (`sed -i`,
402
+ * `git checkout`, …). An earlier passing test run is stale after one.
403
+ */
404
+ function isFileWriteCall(tool, input) {
405
+ if (changeTargets(tool, input).length > 0)
406
+ return true;
407
+ if (!scopeToolIs(tool, ['bash', 'shell', 'run_command', 'runcommand', 'execute_command', 'run_shell_command', 'terminal', 'execute', 'exec']))
408
+ return false;
409
+ const command = scopeKeyed(input, ['command', 'cmd', 'script']);
410
+ if (command === null)
411
+ return false;
412
+ const words = (0, phrases_js_1.phraseText)(command);
413
+ for (const p of ['sed -i', 'perl -i', 'perl -pi', 'git apply', 'git am', 'git checkout', 'git switch', 'git restore', 'git reset', 'git merge', 'git pull', 'git rebase', 'git cherry-pick', 'git revert', 'git stash pop', 'git stash apply', 'patch -p']) {
414
+ if ((0, phrases_js_1.hasPhrase)(words, p))
415
+ return true;
416
+ }
417
+ return false;
418
+ }
419
+ /**
420
+ * The functions above as JavaScript source, for the hook gates to embed
421
+ * after the phrase matcher's source (`PHRASES_JS_SOURCE`), which
422
+ * {@link isFileWriteCall} calls. The lists the functions read are written
423
+ * into them, so the source needs nothing else; `scopeMatch.test.ts` holds
424
+ * those copies to the exported lists.
425
+ */
426
+ exports.SCOPE_MATCH_JS_SOURCE = [
427
+ scopeAsciiLower,
428
+ scopeToolIs,
429
+ scopeKeyed,
430
+ scopeClip,
431
+ isWithinScope,
432
+ sopAppliesToRole,
433
+ collectScopePaths,
434
+ collectPlanSteps,
435
+ planOffSteps,
436
+ changeTargets,
437
+ scopeDiffPath,
438
+ diffChangedPaths,
439
+ scopeNormalisePath,
440
+ scopeRelativePath,
441
+ isPlanExemptTool,
442
+ isFileWriteCall,
443
+ ]
444
+ .map((fn) => fn
445
+ .toString()
446
+ .replace(/\(0,\s*(?:[\w$]+_js_\d+|__vite_ssr_import_\d+__)\.([\w$]+)\)/g, '$1')
447
+ .replace(/\b(?:[\w$]+_js_\d+|__vite_ssr_import_\d+__)\.([\w$]+)/g, '$1')
448
+ .replace(/\bexports\./g, ''))
449
+ .join('\n')
450
+ .replace(/\bNARROWED_TO_NOTHING\b/g, JSON.stringify(exports.NARROWED_TO_NOTHING));
451
+ //# sourceMappingURL=scopeMatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scopeMatch.js","sourceRoot":"","sources":["../src/scopeMatch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;;;AA4HH,sCAiBC;AAUD,4CAIC;A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GAMG;AACU,QAAA,qBAAqB,GAAG;IACnC,eAAe;IACf,WAAW;IACX,UAAU;IACV,SAAS;IACT,aAAa;IACb,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,aAAa;IACb,gBAAgB;IAChB,kBAAkB;IAClB,iBAAiB;IACjB,gBAAgB;IAChB,eAAe;CAChB;KACE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CACV,EAAE;KACC,QAAQ,EAAE;KACV,OAAO,CAAC,+DAA+D,EAAE,IAAI,CAAC;KAC9E,OAAO,CAAC,wDAAwD,EAAE,IAAI,CAAC;KACvE,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAC/B;KACA,IAAI,CAAC,IAAI,CAAC;KACV,OAAO,CAAC,0BAA0B,EAAE,IAAI,CAAC,SAAS,CAAC,2BAAmB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Which proxy version reads each newer SOP front-matter key.
3
+ *
4
+ * The proxy reads keys as line prefixes and ignores the ones it does not know
5
+ * (`sops.rs`), so an older proxy cannot fail closed on a new key: a
6
+ * `scope_paths_mode: enforce` it does not read stays advisory there, and a
7
+ * `closed_lanes:` holds nothing. Where a SOP is validated, the control plane
8
+ * compares a workspace's `gateways.proxyVersion` with these and warns
9
+ * (`sop_key_needs_newer_gateway`). Hook gates and SDKs fail closed on the
10
+ * keys they evaluate through fallback lines instead (gateRuleRecord.ts).
11
+ *
12
+ * `null`: the proxy never reads the key; it is a gate-only rule
13
+ * (`plan_approval:`), so no proxy version is too old for it.
14
+ *
15
+ * @module
16
+ */
17
+ /** The proxy release that first reads the newer keys. */
18
+ export declare const LOOP_GRAPH_GATE_PROXY_VERSION = "3.0.0";
19
+ /**
20
+ * Each key, as written at the start of its line, and the proxy version that
21
+ * reads it. `requires_before:[ok]` stands for a qualified `requires_before:`
22
+ * (`action:run_tests[ok]` on its left): an older proxy compares the literal,
23
+ * which never appears in a sequence, so it refuses the gated call always.
24
+ */
25
+ export declare const SOP_KEY_SINCE: Readonly<Record<string, string | null>>;
26
+ /** `major.minor.patch` (a `v` prefix and any `-pre` or `+build` suffix ignored) as three numbers, or null. */
27
+ export declare function parseProxyVersion(version: string | null | undefined): [number, number, number] | null;
28
+ /** Whether `version` is older than `since`. An unreadable or unknown version is not known to be older: the caller says it could not tell. */
29
+ export declare function proxyVersionOlder(version: string | null | undefined, since: string): boolean | null;
30
+ /**
31
+ * The keys the SOP's front matter (the text between the fences) uses that a
32
+ * proxy at `proxyVersion` does not read, each with the version that does, in
33
+ * {@link SOP_KEY_SINCE} order. A key is used when a line, at any
34
+ * indentation, starts with it; a qualified `requires_before:` when such a
35
+ * line holds `[ok]`. A proxy whose version is unknown gets every used key.
36
+ */
37
+ export declare function sopKeysNeedingNewerProxy(front: string, proxyVersion: string | null | undefined): Array<{
38
+ key: string;
39
+ since: string;
40
+ }>;
41
+ //# sourceMappingURL=sopKeySince.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sopKeySince.d.ts","sourceRoot":"","sources":["../src/sopKeySince.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,yDAAyD;AACzD,eAAO,MAAM,6BAA6B,UAAU,CAAA;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAWjE,CAAA;AAED,8GAA8G;AAC9G,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAGrG;AAED,6IAA6I;AAC7I,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAMnG;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAatI"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * Which proxy version reads each newer SOP front-matter key.
4
+ *
5
+ * The proxy reads keys as line prefixes and ignores the ones it does not know
6
+ * (`sops.rs`), so an older proxy cannot fail closed on a new key: a
7
+ * `scope_paths_mode: enforce` it does not read stays advisory there, and a
8
+ * `closed_lanes:` holds nothing. Where a SOP is validated, the control plane
9
+ * compares a workspace's `gateways.proxyVersion` with these and warns
10
+ * (`sop_key_needs_newer_gateway`). Hook gates and SDKs fail closed on the
11
+ * keys they evaluate through fallback lines instead (gateRuleRecord.ts).
12
+ *
13
+ * `null`: the proxy never reads the key; it is a gate-only rule
14
+ * (`plan_approval:`), so no proxy version is too old for it.
15
+ *
16
+ * @module
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.SOP_KEY_SINCE = exports.LOOP_GRAPH_GATE_PROXY_VERSION = void 0;
20
+ exports.parseProxyVersion = parseProxyVersion;
21
+ exports.proxyVersionOlder = proxyVersionOlder;
22
+ exports.sopKeysNeedingNewerProxy = sopKeysNeedingNewerProxy;
23
+ /** The proxy release that first reads the newer keys. */
24
+ exports.LOOP_GRAPH_GATE_PROXY_VERSION = '3.0.0';
25
+ /**
26
+ * Each key, as written at the start of its line, and the proxy version that
27
+ * reads it. `requires_before:[ok]` stands for a qualified `requires_before:`
28
+ * (`action:run_tests[ok]` on its left): an older proxy compares the literal,
29
+ * which never appears in a sequence, so it refuses the gated call always.
30
+ */
31
+ exports.SOP_KEY_SINCE = {
32
+ 'requires_before:[ok]': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
33
+ 'scope_paths_mode:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
34
+ 'plan_steps_mode:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
35
+ 'plan_approval:': null,
36
+ 'closed_lanes:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
37
+ 'open_actions:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
38
+ 'on_reask_exhausted:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
39
+ 'context_isolation:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
40
+ 'node_kind:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
41
+ 'node_kind_allow:': exports.LOOP_GRAPH_GATE_PROXY_VERSION,
42
+ };
43
+ /** `major.minor.patch` (a `v` prefix and any `-pre` or `+build` suffix ignored) as three numbers, or null. */
44
+ function parseProxyVersion(version) {
45
+ const m = /^v?(\d{1,6})\.(\d{1,6})\.(\d{1,6})(?:[-+].*)?$/.exec((version ?? '').trim());
46
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
47
+ }
48
+ /** Whether `version` is older than `since`. An unreadable or unknown version is not known to be older: the caller says it could not tell. */
49
+ function proxyVersionOlder(version, since) {
50
+ const v = parseProxyVersion(version);
51
+ const s = parseProxyVersion(since);
52
+ if (!v || !s)
53
+ return null;
54
+ for (let i = 0; i < 3; i++)
55
+ if (v[i] !== s[i])
56
+ return v[i] < s[i];
57
+ return false;
58
+ }
59
+ /**
60
+ * The keys the SOP's front matter (the text between the fences) uses that a
61
+ * proxy at `proxyVersion` does not read, each with the version that does, in
62
+ * {@link SOP_KEY_SINCE} order. A key is used when a line, at any
63
+ * indentation, starts with it; a qualified `requires_before:` when such a
64
+ * line holds `[ok]`. A proxy whose version is unknown gets every used key.
65
+ */
66
+ function sopKeysNeedingNewerProxy(front, proxyVersion) {
67
+ const lines = front.split('\n').map((l) => l.trim());
68
+ const out = [];
69
+ for (const key of Object.keys(exports.SOP_KEY_SINCE)) {
70
+ const since = exports.SOP_KEY_SINCE[key];
71
+ if (since === null || since === undefined)
72
+ continue;
73
+ const used = key === 'requires_before:[ok]'
74
+ ? lines.some((l) => l.startsWith('requires_before:') && l.includes('[ok]'))
75
+ : lines.some((l) => l.startsWith(key));
76
+ if (used && proxyVersionOlder(proxyVersion, since) !== false)
77
+ out.push({ key, since });
78
+ }
79
+ return out;
80
+ }
81
+ //# sourceMappingURL=sopKeySince.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sopKeySince.js","sourceRoot":"","sources":["../src/sopKeySince.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAyBH,8CAGC;AAGD,8CAMC;AASD,4DAaC;AAzDD,yDAAyD;AAC5C,QAAA,6BAA6B,GAAG,OAAO,CAAA;AAEpD;;;;;GAKG;AACU,QAAA,aAAa,GAA4C;IACpE,sBAAsB,EAAE,qCAA6B;IACrD,mBAAmB,EAAE,qCAA6B;IAClD,kBAAkB,EAAE,qCAA6B;IACjD,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,qCAA6B;IAC9C,eAAe,EAAE,qCAA6B;IAC9C,qBAAqB,EAAE,qCAA6B;IACpD,oBAAoB,EAAE,qCAA6B;IACnD,YAAY,EAAE,qCAA6B;IAC3C,kBAAkB,EAAE,qCAA6B;CAClD,CAAA;AAED,8GAA8G;AAC9G,SAAgB,iBAAiB,CAAC,OAAkC;IAClE,MAAM,CAAC,GAAG,gDAAgD,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;IACvF,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC9D,CAAC;AAED,6IAA6I;AAC7I,SAAgB,iBAAiB,CAAC,OAAkC,EAAE,KAAa;IACjF,MAAM,CAAC,GAAG,iBAAiB,C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