@intutic/gate 1.10.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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +261 -0
  3. package/dist/actions.d.ts +86 -0
  4. package/dist/actions.d.ts.map +1 -0
  5. package/dist/actions.js +239 -0
  6. package/dist/actions.js.map +1 -0
  7. package/dist/client.d.ts +94 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +207 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/dsh.d.ts +162 -0
  12. package/dist/dsh.d.ts.map +1 -0
  13. package/dist/dsh.js +189 -0
  14. package/dist/dsh.js.map +1 -0
  15. package/dist/errors.d.ts +41 -0
  16. package/dist/errors.d.ts.map +1 -0
  17. package/dist/errors.js +53 -0
  18. package/dist/errors.js.map +1 -0
  19. package/dist/eve.d.ts +425 -0
  20. package/dist/eve.d.ts.map +1 -0
  21. package/dist/eve.js +378 -0
  22. package/dist/eve.js.map +1 -0
  23. package/dist/gate.d.ts +113 -0
  24. package/dist/gate.d.ts.map +1 -0
  25. package/dist/gate.js +274 -0
  26. package/dist/gate.js.map +1 -0
  27. package/dist/harness.d.ts +482 -0
  28. package/dist/harness.d.ts.map +1 -0
  29. package/dist/harness.js +504 -0
  30. package/dist/harness.js.map +1 -0
  31. package/dist/headers.d.ts +26 -0
  32. package/dist/headers.d.ts.map +1 -0
  33. package/dist/headers.js +30 -0
  34. package/dist/headers.js.map +1 -0
  35. package/dist/imagecheck.d.ts +93 -0
  36. package/dist/imagecheck.d.ts.map +1 -0
  37. package/dist/imagecheck.js +286 -0
  38. package/dist/imagecheck.js.map +1 -0
  39. package/dist/index.d.ts +26 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +19 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/managedAgents.d.ts +375 -0
  44. package/dist/managedAgents.d.ts.map +1 -0
  45. package/dist/managedAgents.js +446 -0
  46. package/dist/managedAgents.js.map +1 -0
  47. package/dist/mastra.d.ts +175 -0
  48. package/dist/mastra.d.ts.map +1 -0
  49. package/dist/mastra.js +161 -0
  50. package/dist/mastra.js.map +1 -0
  51. package/dist/openai.d.ts +392 -0
  52. package/dist/openai.d.ts.map +1 -0
  53. package/dist/openai.js +658 -0
  54. package/dist/openai.js.map +1 -0
  55. package/dist/shlex.d.ts +16 -0
  56. package/dist/shlex.d.ts.map +1 -0
  57. package/dist/shlex.js +78 -0
  58. package/dist/shlex.js.map +1 -0
  59. package/dist/snapshot.d.ts +111 -0
  60. package/dist/snapshot.d.ts.map +1 -0
  61. package/dist/snapshot.js +243 -0
  62. package/dist/snapshot.js.map +1 -0
  63. package/dist/soprules.d.ts +88 -0
  64. package/dist/soprules.d.ts.map +1 -0
  65. package/dist/soprules.js +176 -0
  66. package/dist/soprules.js.map +1 -0
  67. package/dist/trueforge.d.ts +191 -0
  68. package/dist/trueforge.d.ts.map +1 -0
  69. package/dist/trueforge.js +184 -0
  70. package/dist/trueforge.js.map +1 -0
  71. package/dist/vercel.d.ts +174 -0
  72. package/dist/vercel.d.ts.map +1 -0
  73. package/dist/vercel.js +157 -0
  74. package/dist/vercel.js.map +1 -0
  75. package/dist/workflow.d.ts +209 -0
  76. package/dist/workflow.d.ts.map +1 -0
  77. package/dist/workflow.js +254 -0
  78. package/dist/workflow.js.map +1 -0
  79. package/dist/wrapTools.d.ts +68 -0
  80. package/dist/wrapTools.d.ts.map +1 -0
  81. package/dist/wrapTools.js +95 -0
  82. package/dist/wrapTools.js.map +1 -0
  83. package/package.json +123 -0
package/dist/gate.js ADDED
@@ -0,0 +1,274 @@
1
+ /**
2
+ * The enforcement point.
3
+ *
4
+ * Port of `packages/intutic-clawde/intutic_clawde/gate/gate.py`.
5
+ *
6
+ * Intutic ships PreToolUse hooks for the harnesses it has a native adapter
7
+ * for; frameworks outside that list (Mastra, the Vercel AI SDK, LangChain.js,
8
+ * a hand-rolled loop) have no adapter, and the sync-daemon writes no
9
+ * PreToolUse hook for them. This package is that enforcement point: the
10
+ * missing adapter, written against Intutic's own published gate contract.
11
+ *
12
+ * Four tiers, in order — identical precedence to the Python SDK:
13
+ *
14
+ * A1 policy snapshot port of intuticGate() fails CLOSED
15
+ * A3 SOP rules authored in the product fails OPEN (A2 covers it)
16
+ * A2 image integrity local check fails CLOSED
17
+ * B POST /hook-gate control-plane check fail posture set by GateClient
18
+ *
19
+ * A1 and A2 are load-bearing and local. Tier B contributes the DLP regexes
20
+ * and workspace policy from the control plane; whether an unreachable control
21
+ * plane blocks is the client's `failClosed` setting (default true).
22
+ *
23
+ * Tier A3 applies rules written in the SOP register rather than in code. It
24
+ * runs BEFORE A2 so that a block, when both would fire, is attributed to the
25
+ * authored policy rather than to the hardcoded one. It fails open because A2
26
+ * covers the identical case and fails closed: A3 moves where the policy is
27
+ * *written*, and is not what makes the run safe. See soprules.ts.
28
+ *
29
+ * ## Naming note for callers porting from other Intutic SDKs
30
+ *
31
+ * This is NOT the "static floor" tier the compiled shell/JS gate emitters
32
+ * carry (`staticFloorPatterns()` in
33
+ * `services/sync-daemon/src/harness/protectedPaths.ts`, concatenated ahead of
34
+ * the snapshot's own rules in `gateBody.ts`'s `intuticGate()`). Like the
35
+ * Python SDK it ports, this package's Tier A1 reads ONLY
36
+ * `~/.intutic/hooks/policy-snapshot.rules` — the compiled-in bypass/secret/
37
+ * skill-surface patterns never reach that file (only SOP-authored rules, the
38
+ * destructive-command tier, and the tier-promoted skill-surface rules do, via
39
+ * `buildSnapshotRules` in `services/sync-daemon/src/lib/policySnapshot.ts`).
40
+ * A workspace relying on this SDK for governance therefore gets a strict
41
+ * SUBSET of what a shipped shell/JS harness gate enforces. That gap already
42
+ * exists in the Python SDK this package ports; it is not introduced here. See
43
+ * `src/__tests__/fidelity.test.ts` for the parts of the shipped contract this
44
+ * package's Tier A1 DOES reproduce exactly (the destructive-command and
45
+ * skill-surface pattern tables, as they would arrive via a real snapshot).
46
+ */
47
+ import { existsSync, readFileSync } from 'node:fs';
48
+ import { isDeploy, touchesInfra } from './actions.js';
49
+ import { IntuticGateRefusal } from './errors.js';
50
+ import * as imagecheck from './imagecheck.js';
51
+ import * as snapshot from './snapshot.js';
52
+ import * as soprules from './soprules.js';
53
+ /** Tools that cannot change anything. They still get the local snapshot check
54
+ * (Tier A1), but skip the remote gate call (Tier B). */
55
+ export const READ_ONLY_TOOLS = new Set([
56
+ 'read_file',
57
+ 'list_files',
58
+ 'read',
59
+ 'cat',
60
+ 'view',
61
+ ]);
62
+ function resolveConfig(cfg) {
63
+ return {
64
+ repoRoot: cfg.repoRoot ?? '.',
65
+ workspaceId: cfg.workspaceId ?? '',
66
+ allowlistPath: cfg.allowlistPath ?? '.intutic/image-allowlist.json',
67
+ enforce: cfg.enforce ?? true,
68
+ useHookGate: cfg.useHookGate ?? true,
69
+ useSopRules: cfg.useSopRules ?? true,
70
+ };
71
+ }
72
+ export class Gate {
73
+ cfg;
74
+ client;
75
+ _snapshot = null;
76
+ _snapshotReported = false;
77
+ _policy = null;
78
+ /** `null` = not fetched yet. A failed fetch caches `[]` so one unreachable
79
+ * control plane does not add a timeout to every subsequent tool call. */
80
+ _sopRules = null;
81
+ constructor(cfg = {}, client = null) {
82
+ this.cfg = resolveConfig(cfg);
83
+ this.client = client;
84
+ }
85
+ allowlistAbs() {
86
+ const p = this.cfg.allowlistPath;
87
+ return isAbsolutePath(p) ? p : joinPath(this.cfg.repoRoot, p);
88
+ }
89
+ // ------------------------------------------------------------ loading
90
+ getSnapshot() {
91
+ if (this._snapshot === null) {
92
+ this._snapshot = snapshot.loadSnapshot(this.cfg.workspaceId);
93
+ }
94
+ return this._snapshot;
95
+ }
96
+ /**
97
+ * Load the image allowlist.
98
+ *
99
+ * A missing or malformed allowlist is NOT treated as "allow everything".
100
+ * An empty policy with `require_digest` still refuses every unpinned
101
+ * image, which is the safe direction; a policy we cannot read at all
102
+ * throws, and the caller turns that into a block.
103
+ */
104
+ getPolicy() {
105
+ if (this._policy === null) {
106
+ const path = this.allowlistAbs();
107
+ if (!existsSync(path)) {
108
+ throw new IntuticGateRefusal(`[image-integrity] ${imagecheck.E_MANIFEST_UNPARSEABLE}: image allowlist not found at ` +
109
+ `${path}; refusing to approve an image against a policy that does not exist`, imagecheck.E_MANIFEST_UNPARSEABLE);
110
+ }
111
+ try {
112
+ this._policy = JSON.parse(readFileSync(path, 'utf-8'));
113
+ }
114
+ catch (exc) {
115
+ const name = exc instanceof Error ? exc.constructor.name : 'Error';
116
+ throw new IntuticGateRefusal(`[image-integrity] ${imagecheck.E_MANIFEST_UNPARSEABLE}: image allowlist at ${path} is ` +
117
+ `unreadable (${name})`, imagecheck.E_MANIFEST_UNPARSEABLE);
118
+ }
119
+ }
120
+ return this._policy;
121
+ }
122
+ /**
123
+ * Active SOP rules, fetched once per process.
124
+ *
125
+ * Deliberately not refreshed on a timer: a rule set that changes mid-run
126
+ * makes a verdict depend on when the fetch landed. Construct a new `Gate`
127
+ * (or clear the cache) to refresh.
128
+ */
129
+ async getSopRules() {
130
+ if (this._sopRules === null) {
131
+ let fetched = null;
132
+ if (this.client !== null) {
133
+ fetched = await soprules.fetchRules(this.client.baseUrl, this.client.apiKey, this.cfg.workspaceId);
134
+ }
135
+ if (fetched === null) {
136
+ // Could not read the register. Say so once, then stay quiet — Tier
137
+ // A2 still fails closed on the same condition.
138
+ await this.emit('tool_flagged', 'sop_rules', 'SOP rule register unreachable; SOP-rule tier inactive for this run ' +
139
+ '(image-integrity check unaffected)');
140
+ fetched = [];
141
+ }
142
+ this._sopRules = fetched;
143
+ }
144
+ return this._sopRules;
145
+ }
146
+ // ------------------------------------------------------------ emitting
147
+ async emit(event, tool, reason = '', toolInput, incidentId, filePath) {
148
+ if (this.client !== null) {
149
+ await this.client.emit(event, tool, reason, toolInput, incidentId, filePath);
150
+ }
151
+ }
152
+ /**
153
+ * Report snapshot condition exactly once per process — otherwise these
154
+ * states are computed and never read, and an operator cannot distinguish
155
+ * "snapshot missing on 400 machines" from "snapshot healthy".
156
+ */
157
+ async reportSnapshotHealthOnce(tool) {
158
+ if (this._snapshotReported)
159
+ return;
160
+ this._snapshotReported = true;
161
+ const snap = this.getSnapshot();
162
+ if (snap.state !== 'ok') {
163
+ await this.emit(`snapshot_${snap.state}`, tool, snap.healthMessage);
164
+ }
165
+ }
166
+ // --------------------------------------------------------------- guard
167
+ /** Throws {@link IntuticGateRefusal} if this call must not run. Resolves to allow. */
168
+ async guard(toolName, toolInput) {
169
+ if (!this.cfg.enforce)
170
+ return;
171
+ const target = String(toolInput.path ?? toolInput.file_path ?? '');
172
+ const command = String(toolInput.command ?? '');
173
+ await this.reportSnapshotHealthOnce(toolName);
174
+ // ---- Tier A1: policy snapshot -------------------------------------
175
+ const disabled = snapshot.guardDisabledFromEnv();
176
+ if (disabled) {
177
+ await this.emit('guards_disabled', toolName, 'INTUTIC_GUARD_DISABLE=1 — policy-snapshot rules skipped; built-in protections still active');
178
+ }
179
+ const d = snapshot.evaluate(toolName, target, command, this.getSnapshot(), disabled);
180
+ if (d.severity === snapshot.SEV_BLOCK) {
181
+ await this.emit('tool_blocked', toolName, d.reason, toolInput);
182
+ throw new IntuticGateRefusal(d.reason, 'SNAPSHOT');
183
+ }
184
+ if (d.severity === snapshot.SEV_WARN) {
185
+ await this.emit('tool_flagged', toolName, d.reason, toolInput);
186
+ }
187
+ else if (d.severity === snapshot.SEV_SHADOW) {
188
+ await this.emit('tool_would_block', toolName, d.reason, toolInput);
189
+ }
190
+ // ---- Tier A3: SOP rules authored in the product --------------------
191
+ //
192
+ // Runs before A2 on purpose. When both would fire, the block should be
193
+ // attributed to the policy someone wrote in the register, not to the one
194
+ // hardcoded here.
195
+ if (this.cfg.useSopRules && !READ_ONLY_TOOLS.has(toolName)) {
196
+ const rule = soprules.firstMatch(await this.getSopRules(), toolName, toolInput);
197
+ if (rule !== null) {
198
+ const reason = `[sop:${rule.id}] ${rule.reason}`;
199
+ if (rule.action === soprules.ACTION_BLOCK) {
200
+ await this.emit('tool_blocked', toolName, reason, toolInput);
201
+ throw new IntuticGateRefusal(reason, 'SOP_RULE');
202
+ }
203
+ if (rule.action === soprules.ACTION_APPROVAL) {
204
+ // No human is at the keyboard during an agent run, so an approval
205
+ // that cannot be granted is a block.
206
+ await this.emit('tool_blocked', toolName, `${reason} (approval required; no reviewer in an unattended run)`, toolInput);
207
+ throw new IntuticGateRefusal(reason, 'SOP_RULE_APPROVAL');
208
+ }
209
+ await this.emit('tool_flagged', toolName, reason, toolInput);
210
+ }
211
+ }
212
+ // ---- Tier A2: image integrity -------------------------------------
213
+ if (isDeploy(toolName, toolInput)) {
214
+ const verdict = imagecheck.checkCommand(command, this.cfg.repoRoot, this.getPolicy());
215
+ if (!verdict.ok) {
216
+ const reason = `${imagecheck.verdictReason(verdict)} — policy ${this.cfg.allowlistPath}`;
217
+ await this.emit('tool_blocked', toolName, reason, toolInput);
218
+ throw new IntuticGateRefusal(reason, verdict.code);
219
+ }
220
+ }
221
+ // A write to infrastructure gets the same check one turn earlier, as a
222
+ // flag rather than a block: the dashboard then shows the bad manifest
223
+ // being authored before it is applied.
224
+ if (target && touchesInfra(target) && 'content' in toolInput) {
225
+ const v = imagecheck.checkWrittenManifest(target, String(toolInput.content), this.getPolicy());
226
+ if (!v.ok) {
227
+ await this.emit('tool_flagged', toolName, `${imagecheck.verdictReason(v)} (authoring-time check; the apply will be refused)`, toolInput, undefined, target);
228
+ }
229
+ }
230
+ // ---- Tier B: control plane gate -----------------------------------
231
+ //
232
+ // Skipped for read-only tools — a network round trip whose checks are
233
+ // DLP regexes over the arguments and SOP rules, neither of which can say
234
+ // anything useful about a directory listing.
235
+ if (this.cfg.useHookGate && this.client !== null && !READ_ONLY_TOOLS.has(toolName)) {
236
+ const resp = await this.client.hookGate(toolName, toolInput);
237
+ if (!resp.allowed) {
238
+ await this.emit('tool_blocked', toolName, resp.reason, toolInput, resp.incidentId);
239
+ throw new IntuticGateRefusal(resp.reason, 'HOOK_GATE', resp.incidentId);
240
+ }
241
+ }
242
+ if (!READ_ONLY_TOOLS.has(toolName)) {
243
+ await this.emit('tool_allowed', toolName, '', toolInput);
244
+ }
245
+ }
246
+ }
247
+ function isAbsolutePath(p) {
248
+ return p.startsWith('/') || /^[a-zA-Z]:[\\/]/.test(p);
249
+ }
250
+ function trimTrailingSlashes(s) {
251
+ let end = s.length;
252
+ while (end > 0 && s[end - 1] === '/')
253
+ end--;
254
+ return s.slice(0, end);
255
+ }
256
+ function trimLeadingSlashes(s) {
257
+ let start = 0;
258
+ while (start < s.length && s[start] === '/')
259
+ start++;
260
+ return s.slice(start);
261
+ }
262
+ function joinPath(a, b) {
263
+ return `${trimTrailingSlashes(a)}/${trimLeadingSlashes(b)}`;
264
+ }
265
+ // Module-level active gate, so wrapped tools do not need the instance
266
+ // threaded through every call site.
267
+ let _active = null;
268
+ export function install(gate) {
269
+ _active = gate;
270
+ }
271
+ export function active() {
272
+ return _active;
273
+ }
274
+ //# sourceMappingURL=gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate.js","sourceRoot":"","sources":["../src/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;yDACyD;AACzD,MAAM,CAAC,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IAC1D,WAAW;IACX,YAAY;IACZ,MAAM;IACN,KAAK;IACL,MAAM;CACP,CAAC,CAAA;AAoBF,SAAS,aAAa,CAAC,GAAe;IACpC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