@intutic/gate 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 (95) hide show
  1. package/dist/actions.d.ts +39 -0
  2. package/dist/actions.d.ts.map +1 -1
  3. package/dist/actions.js +139 -0
  4. package/dist/actions.js.map +1 -1
  5. package/dist/client.d.ts +10 -0
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +19 -0
  8. package/dist/client.js.map +1 -1
  9. package/dist/decide.d.ts +269 -0
  10. package/dist/decide.d.ts.map +1 -0
  11. package/dist/decide.js +757 -0
  12. package/dist/decide.js.map +1 -0
  13. package/dist/decideApi.d.ts +24 -0
  14. package/dist/decideApi.d.ts.map +1 -0
  15. package/dist/decideApi.js +32 -0
  16. package/dist/decideApi.js.map +1 -0
  17. package/dist/decideEngine.d.ts +195 -0
  18. package/dist/decideEngine.d.ts.map +1 -0
  19. package/dist/decideEngine.js +707 -0
  20. package/dist/decideEngine.js.map +1 -0
  21. package/dist/decideEvaluate.d.ts +250 -0
  22. package/dist/decideEvaluate.d.ts.map +1 -0
  23. package/dist/decideEvaluate.js +504 -0
  24. package/dist/decideEvaluate.js.map +1 -0
  25. package/dist/decideHostGuard.d.ts +56 -0
  26. package/dist/decideHostGuard.d.ts.map +1 -0
  27. package/dist/decideHostGuard.js +194 -0
  28. package/dist/decideHostGuard.js.map +1 -0
  29. package/dist/decideLog.d.ts +287 -0
  30. package/dist/decideLog.d.ts.map +1 -0
  31. package/dist/decideLog.js +521 -0
  32. package/dist/decideLog.js.map +1 -0
  33. package/dist/decideLogRedaction.d.ts +17 -0
  34. package/dist/decideLogRedaction.d.ts.map +1 -0
  35. package/dist/decideLogRedaction.js +33 -0
  36. package/dist/decideLogRedaction.js.map +1 -0
  37. package/dist/decideRecord.d.ts +128 -0
  38. package/dist/decideRecord.d.ts.map +1 -0
  39. package/dist/decideRecord.js +254 -0
  40. package/dist/decideRecord.js.map +1 -0
  41. package/dist/decideSdk.d.ts +86 -0
  42. package/dist/decideSdk.d.ts.map +1 -0
  43. package/dist/decideSdk.js +146 -0
  44. package/dist/decideSdk.js.map +1 -0
  45. package/dist/dsh.d.ts.map +1 -1
  46. package/dist/dsh.js +6 -1
  47. package/dist/dsh.js.map +1 -1
  48. package/dist/errors.d.ts +26 -2
  49. package/dist/errors.d.ts.map +1 -1
  50. package/dist/errors.js +38 -1
  51. package/dist/errors.js.map +1 -1
  52. package/dist/gate.d.ts +85 -1
  53. package/dist/gate.d.ts.map +1 -1
  54. package/dist/gate.js +314 -18
  55. package/dist/gate.js.map +1 -1
  56. package/dist/gateRuleRecord.d.ts +244 -0
  57. package/dist/gateRuleRecord.d.ts.map +1 -0
  58. package/dist/gateRuleRecord.js +459 -0
  59. package/dist/gateRuleRecord.js.map +1 -0
  60. package/dist/harness.d.ts.map +1 -1
  61. package/dist/harness.js +22 -10
  62. package/dist/harness.js.map +1 -1
  63. package/dist/index.d.ts +14 -5
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +5 -3
  66. package/dist/index.js.map +1 -1
  67. package/dist/lanes.d.ts +94 -0
  68. package/dist/lanes.d.ts.map +1 -0
  69. package/dist/lanes.js +150 -0
  70. package/dist/lanes.js.map +1 -0
  71. package/dist/limits.d.ts +6 -0
  72. package/dist/limits.d.ts.map +1 -1
  73. package/dist/limits.js +6 -0
  74. package/dist/limits.js.map +1 -1
  75. package/dist/refusalDetail.d.ts +58 -0
  76. package/dist/refusalDetail.d.ts.map +1 -0
  77. package/dist/refusalDetail.js +121 -0
  78. package/dist/refusalDetail.js.map +1 -0
  79. package/dist/scopeMatch.d.ts +156 -0
  80. package/dist/scopeMatch.d.ts.map +1 -0
  81. package/dist/scopeMatch.js +438 -0
  82. package/dist/scopeMatch.js.map +1 -0
  83. package/dist/snapshot.d.ts +51 -3
  84. package/dist/snapshot.d.ts.map +1 -1
  85. package/dist/snapshot.js +86 -13
  86. package/dist/snapshot.js.map +1 -1
  87. package/dist/testOutcome.d.ts +164 -0
  88. package/dist/testOutcome.d.ts.map +1 -0
  89. package/dist/testOutcome.js +439 -0
  90. package/dist/testOutcome.js.map +1 -0
  91. package/dist/wrapTools.d.ts +7 -1
  92. package/dist/wrapTools.d.ts.map +1 -1
  93. package/dist/wrapTools.js +30 -2
  94. package/dist/wrapTools.js.map +1 -1
  95. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -10,22 +10,31 @@
10
10
  export { classify, isDeploy, isTest, touchesInfra } from './actions.js';
11
11
  export { GateClient } from './client.js';
12
12
  export type { GateClientOptions, GateResponse } from './client.js';
13
- export { GateError, GateConnectionError, IntuticGateHold, IntuticGateRefusal, GATE_REFUSAL_CODES } from './errors.js';
13
+ export { GateError, GateConnectionError, IntuticGateEscalation, IntuticGateHold, IntuticGateRefusal, GATE_REFUSAL_CODES } from './errors.js';
14
14
  export type { GateRefusalCode } from './errors.js';
15
15
  export { canonicalJson, holdKey, holdMessage } from './hold.js';
16
16
  export { COMMAND_SIZE_LIMIT, ARGUMENTS_SIZE_LIMIT, GATE_DEADLINE_MS } from './limits.js';
17
- export { Gate, READ_ONLY_TOOLS, install, active } from './gate.js';
18
- export type { GateConfig, ToolInput } from './gate.js';
17
+ export { Gate, READ_ONLY_TOOLS, CAN_EVALUATE_RULE_RECORDS, PLAN_CACHE_MS, install, active } from './gate.js';
18
+ export type { GateConfig, ToolInput, ToolOutcome } from './gate.js';
19
+ export type { GateRuleCode, GateRuleKind, GateRuleRecord } from './gateRuleRecord.js';
20
+ export type { RefusalEvidence, RefusalScope } from './refusalDetail.js';
21
+ export type { LaneClass } from './lanes.js';
19
22
  export { intuticHeaders } from './headers.js';
20
23
  export type { IntuticHeadersOptions } from './headers.js';
21
24
  export { checkCommand, checkImages, checkWrittenManifest, isDeployCommand, isPinned, manifestPathsFromCommand, parseImageRef, verdictReason, } from './imagecheck.js';
22
25
  export type { ImagePolicy, ImageRef, ImageRefusalCode, Verdict as ImageVerdict } from './imagecheck.js';
23
26
  export { Snapshot, evaluate, guardDisabledFromEnv, loadSnapshot, snapshotPath, SEV_BLOCK, SEV_HOLD, SEV_SHADOW, SEV_WARN, } from './snapshot.js';
24
- export type { Decision, Rule, RuleSubject, Severity, SnapshotState } from './snapshot.js';
27
+ export type { Decision, LoadSnapshotOptions, Rule, RuleSubject, Severity, SnapshotState } from './snapshot.js';
25
28
  export type { SsoGroupClearance, SsoGroupPolicy, SsoGroupRecord } from './ssoGroups.js';
26
29
  export type { McpAllowlistRecord, McpRegistryRecord } from './mcpRegistryRecord.js';
30
+ export type { DecidePin, DecideRecord, DecideStamp } from './decideRecord.js';
31
+ export type { DecideBand, DecideQuestion, DecideRule } from './decide.js';
32
+ export { decide } from './decideApi.js';
33
+ export { DecideEngineError } from './decideEngine.js';
34
+ export type { DecideEngineConfig, DecideEngineErrorCode } from './decideEngine.js';
35
+ export type { DecideSdkAnswer, DecideSdkOptions, DecideSdkResult } from './decideSdk.js';
27
36
  export { firstMatch, parseRules, ruleMatches, serialiseToolInput, supportsArgPatterns, fetchRules, fetchRegister, parseRegister, ACTION_BLOCK, ACTION_WARN, ACTION_APPROVAL, } from './soprules.js';
28
37
  export type { SopRegister, SopRule } from './soprules.js';
29
- export { wrapTool, wrapTools } from './wrapTools.js';
38
+ export { toolOutcomeOf, wrapTool, wrapTools } from './wrapTools.js';
30
39
  export type { AnyFn, ExecutableTool, WrapToolOptions } from './wrapTools.js';
31
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAElE,OAAO,EAAE,SAAS,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mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEzD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACnE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -9,13 +9,15 @@
9
9
  */
10
10
  export { classify, isDeploy, isTest, touchesInfra } from './actions.js';
11
11
  export { GateClient } from './client.js';
12
- export { GateError, GateConnectionError, IntuticGateHold, IntuticGateRefusal, GATE_REFUSAL_CODES } from './errors.js';
12
+ export { GateError, GateConnectionError, IntuticGateEscalation, IntuticGateHold, IntuticGateRefusal, GATE_REFUSAL_CODES } from './errors.js';
13
13
  export { canonicalJson, holdKey, holdMessage } from './hold.js';
14
14
  export { COMMAND_SIZE_LIMIT, ARGUMENTS_SIZE_LIMIT, GATE_DEADLINE_MS } from './limits.js';
15
- export { Gate, READ_ONLY_TOOLS, install, active } from './gate.js';
15
+ export { Gate, READ_ONLY_TOOLS, CAN_EVALUATE_RULE_RECORDS, PLAN_CACHE_MS, install, active } from './gate.js';
16
16
  export { intuticHeaders } from './headers.js';
17
17
  export { checkCommand, checkImages, checkWrittenManifest, isDeployCommand, isPinned, manifestPathsFromCommand, parseImageRef, verdictReason, } from './imagecheck.js';
18
18
  export { Snapshot, evaluate, guardDisabledFromEnv, loadSnapshot, snapshotPath, SEV_BLOCK, SEV_HOLD, SEV_SHADOW, SEV_WARN, } from './snapshot.js';
19
+ export { decide } from './decideApi.js';
20
+ export { DecideEngineError } from './decideEngine.js';
19
21
  export { firstMatch, parseRules, ruleMatches, serialiseToolInput, supportsArgPatterns, fetchRules, fetchRegister, parseRegister, ACTION_BLOCK, ACTION_WARN, ACTION_APPROVAL, } from './soprules.js';
20
- export { wrapTool, wrapTools } from './wrapTools.js';
22
+ export { toolOutcomeOf, wrapTool, wrapTools } from './wrapTools.js';
21
23
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGrH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAE/D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAExF,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGlE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAG7C,OAAO,EACL,YAAY,EACZ,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,QAAQ,EACR,wBAAwB,EACxB,aAAa,EACb,aAAa,GACd,MAAM,iBAAiB,CAAA;AAGxB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,oBAAoB,EACpB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,GACT,MAAM,eAAe,CAAA;AAOtB,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,GAChB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,QAAQ,EAA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AA;AAGtB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Reversibility lanes: every action token's class, the tokens a
3
+ * set of SOPs and the workspace close, and the hold rules a closed token
4
+ * compiles to.
5
+ *
6
+ * | Class | Tokens |
7
+ * |---|---|
8
+ * | `reversible_contained` | `run_tests`, `secret_read`, `pii_export` |
9
+ * | `reversible_wide` | `deploy`, `release`, `db_write`, `http_post`, `migrate`, `prod_write` |
10
+ * | `irreversible` | `publish`, `destroy`, `force_push`, `payment` |
11
+ *
12
+ * Only `irreversible` and `reversible_wide` can be closed. A closed token is
13
+ * held for a person (the existing hold, decision and bypass path), never
14
+ * refused outright, except with no control plane, where a hold compiles to a
15
+ * block because nobody could approve it.
16
+ *
17
+ * {@link laneHoldTokens} is the rule (`collect_lane_holds` in the proxy's
18
+ * sops.rs mirrors it):
19
+ *
20
+ * 1. each applicable SOP that declares `closed_lanes:` closes the tokens of
21
+ * the classes it lists, plus every `reversible_wide` token when its
22
+ * `risk_tier` is HIGH or CRITICAL, minus its own top-level `open_actions:`;
23
+ * 2. the workspace setting `closedLanes` closes its classes for everyone,
24
+ * and `open_actions:` does not reopen them;
25
+ * 3. the union.
26
+ *
27
+ * `risk_tier` alone closes nothing.
28
+ *
29
+ * Self-contained, so `@intutic/gate` keeps a byte-identical copy. The Python
30
+ * port is in `intutic_clawde/gate/actions.py`; `fixtures/lane-vectors.json`
31
+ * holds the ports and the proxy's `token_class()` equal.
32
+ *
33
+ * @module
34
+ */
35
+ /** A token's reversibility class. */
36
+ export type LaneClass = 'irreversible' | 'reversible_wide' | 'reversible_contained';
37
+ /** The classes `closed_lanes:` and `closedLanes` may name. */
38
+ export type ClosableLane = 'irreversible' | 'reversible_wide';
39
+ export declare const CLOSABLE_LANES: readonly ClosableLane[];
40
+ /** Every action token's class, in the order of `ACTION_TOKENS` (guardrailIr.ts). */
41
+ export declare const TOKEN_CLASS: Readonly<Record<string, LaneClass>>;
42
+ /**
43
+ * The phrases a phrase-subject hold rule matches a token by: the classifier's
44
+ * needles (gate-js `actions.ts`, held equal by a test). A token with none
45
+ * (`secret_read` and `pii_export` read path fragments) is held by its action
46
+ * subject only. `force_push` is a compound (the `git push` phrase and a
47
+ * whole-word `--force` or `-f`); its phrases here are the partial form an
48
+ * older gate can match.
49
+ */
50
+ export declare const LANE_PHRASES: Readonly<Record<string, readonly string[]>>;
51
+ /** A token's class, or null for a tool name or an unknown token. */
52
+ export declare function tokenLane(token: string): LaneClass | null;
53
+ /** The tokens of one class, in {@link TOKEN_CLASS} order. */
54
+ export declare function tokensOfClass(cls: LaneClass): string[];
55
+ /** The strongest class among `tokens` (irreversible, then reversible_wide, then reversible_contained), or null when none has one. The decide log's `lane`. */
56
+ export declare function laneOf(tokens: readonly string[]): LaneClass | null;
57
+ /** One applicable SOP as {@link laneHoldTokens} reads it: its parsed `closed_lanes:`, top-level `open_actions:` and `risk_tier:`. */
58
+ export interface LaneSop {
59
+ closedLanes: readonly string[];
60
+ openActions: readonly string[];
61
+ /** `LOW`, `MEDIUM`, `HIGH` or `CRITICAL` in any case; null or absent when unstated. */
62
+ riskTier?: string | null;
63
+ }
64
+ /**
65
+ * The tokens held for review: each SOP's closed classes (and, at HIGH or
66
+ * CRITICAL, `reversible_wide`) minus its own `open_actions:`, united with
67
+ * the workspace's `closedLanes`. In {@link TOKEN_CLASS} order, each once. An
68
+ * unknown class closes nothing (the parser already reported it).
69
+ */
70
+ export declare function laneHoldTokens(input: {
71
+ sops: readonly LaneSop[];
72
+ workspaceLanes?: readonly string[] | null;
73
+ }): string[];
74
+ /** A lane hold rule's id: `sop.lane.<class>.<token>`. */
75
+ export declare function laneHoldRuleId(token: string): string;
76
+ /** A revert hold rule's id: `revert.<subject>`. */
77
+ export declare function revertHoldRuleId(subject: string): string;
78
+ /** One snapshot rule a token's hold compiles to; the writer adds the id, severity, reason and rationale. */
79
+ export interface HoldPatternSpec {
80
+ subject: 'phrase' | 'action';
81
+ source: string;
82
+ ignoreCase: boolean;
83
+ }
84
+ /**
85
+ * The snapshot rules that hold `token`, all under one id so one approval
86
+ * covers each: the `phrase` rule over its phrases, which every gate since
87
+ * v12 reads (so a gate whose classifier predates the token still holds it);
88
+ * and, for a token whose phrases cannot express it (`force_push`'s
89
+ * compound, `destroy`'s `rm -rf` outside the tree, the path-fragment
90
+ * tokens), an `action` rule a v23 classifier matches. `force_push` lists the
91
+ * action rule first, and its phrase rule is the partial form.
92
+ */
93
+ export declare function laneHoldPatterns(token: string): HoldPatternSpec[];
94
+ //# sourceMappingURL=lanes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../src/lanes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,qCAAqC;AACrC,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,iBAAiB,GAAG,sBAAsB,CAAA;AACnF,8DAA8D;AAC9D,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,iBAAiB,CAAA;AAC7D,eAAO,MAAM,cAAc,EAAE,SAAS,YAAY,EAAwC,CAAA;AAE1F,oFAAoF;AACpF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAc3D,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAYpE,CAAA;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAEzD;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,EAAE,CAEtD;AAED,8JAA8J;AAC9J,wBAAgB,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI,CASlE;AAED,qIAAqI;AACrI,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IAAC,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,EAAE,CAiBvH;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,mDAAmD;AACnD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,4GAA4G;AAC5G,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,EAAE,CAOjE"}
package/dist/lanes.js ADDED
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Reversibility lanes: every action token's class, the tokens a
3
+ * set of SOPs and the workspace close, and the hold rules a closed token
4
+ * compiles to.
5
+ *
6
+ * | Class | Tokens |
7
+ * |---|---|
8
+ * | `reversible_contained` | `run_tests`, `secret_read`, `pii_export` |
9
+ * | `reversible_wide` | `deploy`, `release`, `db_write`, `http_post`, `migrate`, `prod_write` |
10
+ * | `irreversible` | `publish`, `destroy`, `force_push`, `payment` |
11
+ *
12
+ * Only `irreversible` and `reversible_wide` can be closed. A closed token is
13
+ * held for a person (the existing hold, decision and bypass path), never
14
+ * refused outright, except with no control plane, where a hold compiles to a
15
+ * block because nobody could approve it.
16
+ *
17
+ * {@link laneHoldTokens} is the rule (`collect_lane_holds` in the proxy's
18
+ * sops.rs mirrors it):
19
+ *
20
+ * 1. each applicable SOP that declares `closed_lanes:` closes the tokens of
21
+ * the classes it lists, plus every `reversible_wide` token when its
22
+ * `risk_tier` is HIGH or CRITICAL, minus its own top-level `open_actions:`;
23
+ * 2. the workspace setting `closedLanes` closes its classes for everyone,
24
+ * and `open_actions:` does not reopen them;
25
+ * 3. the union.
26
+ *
27
+ * `risk_tier` alone closes nothing.
28
+ *
29
+ * Self-contained, so `@intutic/gate` keeps a byte-identical copy. The Python
30
+ * port is in `intutic_clawde/gate/actions.py`; `fixtures/lane-vectors.json`
31
+ * holds the ports and the proxy's `token_class()` equal.
32
+ *
33
+ * @module
34
+ */
35
+ export const CLOSABLE_LANES = ['irreversible', 'reversible_wide'];
36
+ /** Every action token's class, in the order of `ACTION_TOKENS` (guardrailIr.ts). */
37
+ export const TOKEN_CLASS = {
38
+ 'action:deploy': 'reversible_wide',
39
+ 'action:publish': 'irreversible',
40
+ 'action:release': 'reversible_wide',
41
+ 'action:db_write': 'reversible_wide',
42
+ 'action:secret_read': 'reversible_contained',
43
+ 'action:http_post': 'reversible_wide',
44
+ 'action:pii_export': 'reversible_contained',
45
+ 'action:run_tests': 'reversible_contained',
46
+ 'action:migrate': 'reversible_wide',
47
+ 'action:prod_write': 'reversible_wide',
48
+ 'action:destroy': 'irreversible',
49
+ 'action:force_push': 'irreversible',
50
+ 'action:payment': 'irreversible',
51
+ };
52
+ /**
53
+ * The phrases a phrase-subject hold rule matches a token by: the classifier's
54
+ * needles (gate-js `actions.ts`, held equal by a test). A token with none
55
+ * (`secret_read` and `pii_export` read path fragments) is held by its action
56
+ * subject only. `force_push` is a compound (the `git push` phrase and a
57
+ * whole-word `--force` or `-f`); its phrases here are the partial form an
58
+ * older gate can match.
59
+ */
60
+ export const LANE_PHRASES = {
61
+ 'action:deploy': ['git push', 'kubectl apply', 'kubectl rollout', 'helm upgrade', 'helm install', 'terraform apply', 'docker push', 'serverless deploy', 'fly deploy', 'vercel deploy', 'gcloud run deploy', 'aws deploy', 'aws s3 sync', 'eb deploy'],
62
+ 'action:publish': ['npm publish', 'pnpm publish', 'yarn publish', 'cargo publish', 'twine upload', 'poetry publish', 'gem push', 'docker manifest push'],
63
+ 'action:release': ['gh release create', 'git tag', 'npm version', 'cargo release', 'goreleaser release', 'semantic-release'],
64
+ 'action:db_write': ['insert into', 'update ', 'delete from', 'drop table', 'drop database', 'drop schema', 'truncate ', 'alter table'],
65
+ 'action:http_post': ['curl -x post', 'curl --request post', 'curl -d ', 'curl --data', 'wget --post', 'http post'],
66
+ 'action:run_tests': ['npm test', 'npm run test', 'pnpm test', 'pnpm run test', 'yarn test', 'cargo test', 'go test', 'pytest', 'python -m pytest', 'vitest', 'jest', 'mocha', 'rspec', 'phpunit', 'make test', 'gradle test', 'mvn test', 'dotnet test', 'bazel test', 'tox'],
67
+ 'action:migrate': ['prisma migrate deploy', 'prisma db push', 'alembic upgrade', 'alembic downgrade', 'rails db:migrate', 'rake db:migrate', 'manage.py migrate', 'flyway migrate', 'liquibase update', 'knex migrate:latest', 'sequelize db:migrate'],
68
+ 'action:prod_write': ['--prod', 'rails_env=production', 'node_env=production', '--context prod', '--namespace production', '-n production', '--environment production', '--stage prod'],
69
+ 'action:destroy': ['terraform destroy', 'kubectl delete', 'helm uninstall', 'helm delete', 'drop table', 'drop database', 'drop schema', 'truncate ', 'aws s3 rb', 'aws s3 rm'],
70
+ 'action:force_push': ['git push --force', 'git push -f'],
71
+ 'action:payment': ['api.stripe.com/v1/charges', 'api.stripe.com/v1/payment_intents', 'api.stripe.com/v1/transfers', 'api.stripe.com/v1/payouts', 'api.stripe.com/v1/refunds', 'stripe charges create', 'stripe payment_intents create', 'stripe transfers create', 'stripe payouts create', 'api-m.paypal.com/v2/payments', 'api.paypal.com/v1/payments'],
72
+ };
73
+ /** A token's class, or null for a tool name or an unknown token. */
74
+ export function tokenLane(token) {
75
+ return Object.prototype.hasOwnProperty.call(TOKEN_CLASS, token) ? TOKEN_CLASS[token] : null;
76
+ }
77
+ /** The tokens of one class, in {@link TOKEN_CLASS} order. */
78
+ export function tokensOfClass(cls) {
79
+ return Object.keys(TOKEN_CLASS).filter((t) => TOKEN_CLASS[t] === cls);
80
+ }
81
+ /** The strongest class among `tokens` (irreversible, then reversible_wide, then reversible_contained), or null when none has one. The decide log's `lane`. */
82
+ export function laneOf(tokens) {
83
+ let best = null;
84
+ for (const t of tokens) {
85
+ const c = tokenLane(t);
86
+ if (c === 'irreversible')
87
+ return c;
88
+ if (c === 'reversible_wide')
89
+ best = c;
90
+ else if (c === 'reversible_contained' && best === null)
91
+ best = c;
92
+ }
93
+ return best;
94
+ }
95
+ /**
96
+ * The tokens held for review: each SOP's closed classes (and, at HIGH or
97
+ * CRITICAL, `reversible_wide`) minus its own `open_actions:`, united with
98
+ * the workspace's `closedLanes`. In {@link TOKEN_CLASS} order, each once. An
99
+ * unknown class closes nothing (the parser already reported it).
100
+ */
101
+ export function laneHoldTokens(input) {
102
+ const held = {};
103
+ for (const sop of input.sops) {
104
+ if (sop.closedLanes.length === 0)
105
+ continue;
106
+ const tier = (sop.riskTier ?? '').toUpperCase();
107
+ const classes = sop.closedLanes.slice();
108
+ if (tier === 'HIGH' || tier === 'CRITICAL')
109
+ classes.push('reversible_wide');
110
+ for (const token of Object.keys(TOKEN_CLASS)) {
111
+ const c = TOKEN_CLASS[token];
112
+ if (c !== 'reversible_contained' && classes.indexOf(c) !== -1 && sop.openActions.indexOf(token) === -1)
113
+ held[token] = true;
114
+ }
115
+ }
116
+ for (const token of Object.keys(TOKEN_CLASS)) {
117
+ const c = TOKEN_CLASS[token];
118
+ if (c !== 'reversible_contained' && (input.workspaceLanes ?? []).indexOf(c) !== -1)
119
+ held[token] = true;
120
+ }
121
+ return Object.keys(TOKEN_CLASS).filter((t) => held[t] === true);
122
+ }
123
+ /** A lane hold rule's id: `sop.lane.<class>.<token>`. */
124
+ export function laneHoldRuleId(token) {
125
+ return 'sop.lane.' + (tokenLane(token) ?? 'unknown') + '.' + token;
126
+ }
127
+ /** A revert hold rule's id: `revert.<subject>`. */
128
+ export function revertHoldRuleId(subject) {
129
+ return 'revert.' + subject;
130
+ }
131
+ /**
132
+ * The snapshot rules that hold `token`, all under one id so one approval
133
+ * covers each: the `phrase` rule over its phrases, which every gate since
134
+ * v12 reads (so a gate whose classifier predates the token still holds it);
135
+ * and, for a token whose phrases cannot express it (`force_push`'s
136
+ * compound, `destroy`'s `rm -rf` outside the tree, the path-fragment
137
+ * tokens), an `action` rule a v23 classifier matches. `force_push` lists the
138
+ * action rule first, and its phrase rule is the partial form.
139
+ */
140
+ export function laneHoldPatterns(token) {
141
+ const action = { subject: 'action', source: ' (' + token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ') ', ignoreCase: true };
142
+ const phrases = Object.prototype.hasOwnProperty.call(LANE_PHRASES, token) ? LANE_PHRASES[token] : [];
143
+ const phrase = phrases.length > 0 ? { subject: 'phrase', source: phrases.join('|'), ignoreCase: true } : null;
144
+ if (token === 'action:force_push')
145
+ return [action, phrase];
146
+ if (token === 'action:destroy')
147
+ return [phrase, action];
148
+ return phrase ? [phrase] : [action];
149
+ }
150
+ //# sourceMappingURL=lanes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lanes.js","sourceRoot":"","sources":["../src/lanes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH,MAAM,CAAC,MAAM,cAAc,GAA4B,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAA;AAE1F,oFAAoF;AACpF,MAAM,CAAC,MAAM,WAAW,GAAwC;IAC9D,eAAe,EAAE,iBAAiB;IAClC,gBAAgB,EAAE,cAAc;IAChC,gBAAgB,EAAE,iBAAiB;IACnC,iBAAiB,EAAE,iBAAiB;IACpC,oBAAoB,EAAE,sBAAsB;IAC5C,kBAAkB,EAAE,i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E,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IACrI,IAAI,KAAK,KAAK,mBAAmB;QAAE,OAAO,CAAC,MAAM,EAAE,MAAO,CAAC,CAAA;IAC3D,IAAI,KAAK,KAAK,gBAAgB;QAAE,OAAO,CAAC,MAAO,EAAE,MAAM,CAAC,CAAA;IACxD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC"}
package/dist/limits.d.ts CHANGED
@@ -17,6 +17,12 @@ export declare const HOOK_TIMEOUT_SECONDS = 10;
17
17
  export declare const GATE_DEADLINE_MARGIN_MS = 1000;
18
18
  /** How long the hook script the sandbox bootstrap writes may run, from process start, before it refuses. */
19
19
  export declare const GATE_DEADLINE_MS: number;
20
+ /**
21
+ * How long the decide tier may spend on one call unless
22
+ * `INTUTIC_DECIDE_BUDGET_MS` says otherwise: a JavaScript hook gate's budget
23
+ * under a 10 s timeout (`DECIDE_SDK_BUDGET_MS` in gateLimits.ts).
24
+ */
25
+ export declare const DECIDE_BUDGET_MS = 7300;
20
26
  /**
21
27
  * Why a call is too large to evaluate, or null. Counts the command and the
22
28
  * compact JSON of the arguments in UTF-8 bytes; arguments that do not
@@ -1 +1 @@
1
- {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,QAAa,CAAA;AAE5C,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,QAAc,CAAA;AAE/C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAEtC,uHAAuH;AACvH,eAAO,MAAM,uBAAuB,OAAO,CAAA;AAE3C,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,QAAwD,CAAA;AAErF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAsBjF"}
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,QAAa,CAAA;AAE5C,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,QAAc,CAAA;AAE/C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAA;AAEtC,uHAAuH;AACvH,eAAO,MAAM,uBAAuB,OAAO,CAAA;AAE3C,4GAA4G;AAC5G,eAAO,MAAM,gBAAgB,QAAwD,CAAA;AAErF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAsBjF"}
package/dist/limits.js CHANGED
@@ -17,6 +17,12 @@ export const HOOK_TIMEOUT_SECONDS = 10;
17
17
  export const GATE_DEADLINE_MARGIN_MS = 1000;
18
18
  /** How long the hook script the sandbox bootstrap writes may run, from process start, before it refuses. */
19
19
  export const GATE_DEADLINE_MS = HOOK_TIMEOUT_SECONDS * 1000 - GATE_DEADLINE_MARGIN_MS;
20
+ /**
21
+ * How long the decide tier may spend on one call unless
22
+ * `INTUTIC_DECIDE_BUDGET_MS` says otherwise: a JavaScript hook gate's budget
23
+ * under a 10 s timeout (`DECIDE_SDK_BUDGET_MS` in gateLimits.ts).
24
+ */
25
+ export const DECIDE_BUDGET_MS = 7300;
20
26
  /**
21
27
  * Why a call is too large to evaluate, or null. Counts the command and the
22
28
  * compact JSON of the arguments in UTF-8 bytes; arguments that do not
@@ -1 +1 @@
1
- {"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qEAAq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+ /**
2
+ * What a refusal says about where to retry: its `scope` (the
3
+ * paths, tools, step, detector or rule it concerns) and its `evidence` (what
4
+ * the refuser saw), bounded the same way on every surface.
5
+ *
6
+ * - Each list holds at most {@link REFUSAL_DETAIL_MAX_ITEMS} items, and each
7
+ * string at most {@link REFUSAL_DETAIL_MAX_CHARS} characters (code points),
8
+ * with C0 control characters (U+0000 to U+001F) removed first. A string
9
+ * that is empty after that is dropped; an empty list is left out; a scope
10
+ * with nothing left is null.
11
+ * - In an OPAQUE workspace both are dropped, and so is the stderr retry line:
12
+ * only the refusal code survives, as with the reason
13
+ * (`OPAQUE_REFUSAL_MESSAGE`). SILENT_LOG behaves as TRANSPARENT.
14
+ *
15
+ * Self-contained, so `@intutic/gate` keeps a byte-identical copy. The Python
16
+ * port is `intutic_clawde/gate/refusal_detail.py`, the Rust one is in the
17
+ * proxy's `refusal.rs`; all run `fixtures/refusal-detail-vectors.json`.
18
+ *
19
+ * @module
20
+ */
21
+ /** Where a refusal applies, so a retry can stay out of it. */
22
+ export interface RefusalScope {
23
+ paths?: string[];
24
+ tools?: string[];
25
+ step?: string;
26
+ detector?: string;
27
+ rule?: string;
28
+ }
29
+ /** One thing the refuser saw. */
30
+ export interface RefusalEvidence {
31
+ kind: string;
32
+ detail: string;
33
+ }
34
+ export declare const REFUSAL_DETAIL_MAX_ITEMS = 8;
35
+ export declare const REFUSAL_DETAIL_MAX_CHARS = 256;
36
+ /** The stderr line an exit-code harness prints after the reason. */
37
+ export declare const RETRY_SCOPE_PREFIX = "[Intutic] Retry scope: ";
38
+ /** A scope bounded as the module doc says, keys in a fixed order; null when nothing is left. */
39
+ export declare function boundRefusalScope(scope: unknown): RefusalScope | null;
40
+ /** Evidence bounded: at most 8 items, each with a `kind` and a `detail` that survive bounding. */
41
+ export declare function boundRefusalEvidence(evidence: unknown): RefusalEvidence[];
42
+ /**
43
+ * The detail a refusal carries in `mode` (an intervention mode): nothing in
44
+ * OPAQUE; otherwise the bounded scope and evidence, each left out when empty.
45
+ */
46
+ export declare function refusalDetailForMode(mode: string | null | undefined, scope: unknown, evidence: unknown): {
47
+ scope?: RefusalScope;
48
+ evidence?: RefusalEvidence[];
49
+ };
50
+ /**
51
+ * The stderr line an exit-code harness gets after the reason:
52
+ * `[Intutic] Retry scope: <paths, else tools, comma-separated>`, or null when
53
+ * the scope names neither, or in OPAQUE.
54
+ */
55
+ export declare function retryScopeLine(mode: string | null | undefined, scope: unknown): string | null;
56
+ /** The functions above as JavaScript source, for the hook gates to embed. */
57
+ export declare const REFUSAL_DETAIL_JS_SOURCE: string;
58
+ //# sourceMappingURL=refusalDetail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusalDetail.d.ts","sourceRoot":"","sources":["../src/refusalDetail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,iCAAiC;AACjC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,wBAAwB,IAAI,CAAA;AACzC,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAC3C,oEAAoE;AACpE,eAAO,MAAM,kBAAkB,4BAA4B,CAAA;AAuB3D,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAerE;AAED,kGAAkG;AAClG,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,eAAe,EAAE,CAWzE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG;IAAE,KAAK,CAAC,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAA;CAAE,CAQ/J;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAK7F;AAED,6EAA6E;AAC7E,eAAO,MAAM,wBAAwB,QAExB,CAAA"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * What a refusal says about where to retry: its `scope` (the
3
+ * paths, tools, step, detector or rule it concerns) and its `evidence` (what
4
+ * the refuser saw), bounded the same way on every surface.
5
+ *
6
+ * - Each list holds at most {@link REFUSAL_DETAIL_MAX_ITEMS} items, and each
7
+ * string at most {@link REFUSAL_DETAIL_MAX_CHARS} characters (code points),
8
+ * with C0 control characters (U+0000 to U+001F) removed first. A string
9
+ * that is empty after that is dropped; an empty list is left out; a scope
10
+ * with nothing left is null.
11
+ * - In an OPAQUE workspace both are dropped, and so is the stderr retry line:
12
+ * only the refusal code survives, as with the reason
13
+ * (`OPAQUE_REFUSAL_MESSAGE`). SILENT_LOG behaves as TRANSPARENT.
14
+ *
15
+ * Self-contained, so `@intutic/gate` keeps a byte-identical copy. The Python
16
+ * port is `intutic_clawde/gate/refusal_detail.py`, the Rust one is in the
17
+ * proxy's `refusal.rs`; all run `fixtures/refusal-detail-vectors.json`.
18
+ *
19
+ * @module
20
+ */
21
+ export const REFUSAL_DETAIL_MAX_ITEMS = 8;
22
+ export const REFUSAL_DETAIL_MAX_CHARS = 256;
23
+ /** The stderr line an exit-code harness prints after the reason. */
24
+ export const RETRY_SCOPE_PREFIX = '[Intutic] Retry scope: ';
25
+ /** `s` without C0 control characters, cut to 256 code points; null when nothing is left or it is not a string. */
26
+ function refusalDetailText(s) {
27
+ if (typeof s !== 'string')
28
+ return null;
29
+ // eslint-disable-next-line no-control-regex -- removing control characters is the point
30
+ const clean = Array.from(s.replace(/[\u0000-\u001f]/g, ''));
31
+ if (clean.length === 0)
32
+ return null;
33
+ return clean.slice(0, 256).join('');
34
+ }
35
+ /** A list of strings, bounded: the first 8 that survive {@link refusalDetailText}. */
36
+ function refusalDetailList(v) {
37
+ if (!Array.isArray(v))
38
+ return null;
39
+ const out = [];
40
+ for (const item of v) {
41
+ if (out.length >= 8)
42
+ break;
43
+ const t = refusalDetailText(item);
44
+ if (t !== null)
45
+ out.push(t);
46
+ }
47
+ return out.length > 0 ? out : null;
48
+ }
49
+ /** A scope bounded as the module doc says, keys in a fixed order; null when nothing is left. */
50
+ export function boundRefusalScope(scope) {
51
+ if (scope === null || typeof scope !== 'object' || Array.isArray(scope))
52
+ return null;
53
+ const s = scope;
54
+ const out = {};
55
+ const paths = refusalDetailList(s.paths);
56
+ if (paths)
57
+ out.paths = paths;
58
+ const tools = refusalDetailList(s.tools);
59
+ if (tools)
60
+ out.tools = tools;
61
+ const step = refusalDetailText(s.step);
62
+ if (step !== null)
63
+ out.step = step;
64
+ const detector = refusalDetailText(s.detector);
65
+ if (detector !== null)
66
+ out.detector = detector;
67
+ const rule = refusalDetailText(s.rule);
68
+ if (rule !== null)
69
+ out.rule = rule;
70
+ return Object.keys(out).length > 0 ? out : null;
71
+ }
72
+ /** Evidence bounded: at most 8 items, each with a `kind` and a `detail` that survive bounding. */
73
+ export function boundRefusalEvidence(evidence) {
74
+ const out = [];
75
+ if (!Array.isArray(evidence))
76
+ return out;
77
+ for (const item of evidence) {
78
+ if (out.length >= 8)
79
+ break;
80
+ if (item === null || typeof item !== 'object' || Array.isArray(item))
81
+ continue;
82
+ const kind = refusalDetailText(item.kind);
83
+ const detail = refusalDetailText(item.detail);
84
+ if (kind !== null && detail !== null)
85
+ out.push({ kind, detail });
86
+ }
87
+ return out;
88
+ }
89
+ /**
90
+ * The detail a refusal carries in `mode` (an intervention mode): nothing in
91
+ * OPAQUE; otherwise the bounded scope and evidence, each left out when empty.
92
+ */
93
+ export function refusalDetailForMode(mode, scope, evidence) {
94
+ if (mode === 'OPAQUE')
95
+ return {};
96
+ const out = {};
97
+ const s = boundRefusalScope(scope);
98
+ if (s)
99
+ out.scope = s;
100
+ const e = boundRefusalEvidence(evidence);
101
+ if (e.length > 0)
102
+ out.evidence = e;
103
+ return out;
104
+ }
105
+ /**
106
+ * The stderr line an exit-code harness gets after the reason:
107
+ * `[Intutic] Retry scope: <paths, else tools, comma-separated>`, or null when
108
+ * the scope names neither, or in OPAQUE.
109
+ */
110
+ export function retryScopeLine(mode, scope) {
111
+ if (mode === 'OPAQUE')
112
+ return null;
113
+ const s = boundRefusalScope(scope);
114
+ const items = s?.paths ?? s?.tools;
115
+ return items ? '[Intutic] Retry scope: ' + items.join(', ') : null;
116
+ }
117
+ /** The functions above as JavaScript source, for the hook gates to embed. */
118
+ export const REFUSAL_DETAIL_JS_SOURCE = [refusalDetailText, refusalDetailList, boundRefusalScope, boundRefusalEvidence, refusalDetailForMode, retryScopeLine]
119
+ .map((fn) => fn.toString().replace(/\bexports\./g, ''))
120
+ .join('\n');
121
+ //# sourceMappingURL=refusalDetail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusalDetail.js","sourceRoot":"","sources":["../src/refusalDetail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAiBH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA;AACzC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAC3C,oEAAoE;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAA;AAE3D,kHAAkH;AAClH,SAAS,iBAAiB,CAAC,CAAU;IACnC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IACtC,wFAAwF;IACxF,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CA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