@sponsio/sdk 0.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/contracts/capability/credentials.yaml +188 -0
  2. package/contracts/capability/database.yaml +141 -0
  3. package/contracts/capability/filesystem-strict.yaml +101 -0
  4. package/contracts/capability/filesystem.yaml +239 -0
  5. package/contracts/capability/self-modify.yaml +152 -0
  6. package/contracts/capability/shell.yaml +246 -0
  7. package/contracts/capability/subagent.yaml +184 -0
  8. package/contracts/core/llm_safety.yaml +130 -0
  9. package/contracts/core/runaway.yaml +43 -0
  10. package/contracts/core/universal.yaml +34 -0
  11. package/contracts/incident/claude-code-secret-bypass.yaml +197 -0
  12. package/contracts/incident/cursor-railway-wipe.yaml +164 -0
  13. package/contracts/incident/mcp-composition.yaml +418 -0
  14. package/contracts/incident/openclaw.yaml +500 -0
  15. package/contracts/incident/subagent-escape.yaml +177 -0
  16. package/contracts/premium/.gitkeep +7 -0
  17. package/dist/contract.d.ts +59 -0
  18. package/dist/contract.d.ts.map +1 -0
  19. package/dist/contract.js +97 -0
  20. package/dist/contract.js.map +1 -0
  21. package/dist/core/config-loader.d.ts +90 -0
  22. package/dist/core/config-loader.d.ts.map +1 -0
  23. package/dist/core/config-loader.js +530 -0
  24. package/dist/core/config-loader.js.map +1 -0
  25. package/dist/core/evaluator.d.ts +15 -0
  26. package/dist/core/evaluator.d.ts.map +1 -0
  27. package/dist/core/evaluator.js +87 -0
  28. package/dist/core/evaluator.js.map +1 -0
  29. package/dist/core/formula.d.ts +103 -0
  30. package/dist/core/formula.d.ts.map +1 -0
  31. package/dist/core/formula.js +167 -0
  32. package/dist/core/formula.js.map +1 -0
  33. package/dist/core/grounding.d.ts +43 -0
  34. package/dist/core/grounding.d.ts.map +1 -0
  35. package/dist/core/grounding.js +269 -0
  36. package/dist/core/grounding.js.map +1 -0
  37. package/dist/core/nl-parser.d.ts +12 -0
  38. package/dist/core/nl-parser.d.ts.map +1 -0
  39. package/dist/core/nl-parser.js +152 -0
  40. package/dist/core/nl-parser.js.map +1 -0
  41. package/dist/core/pack-loader.d.ts +15 -0
  42. package/dist/core/pack-loader.d.ts.map +1 -0
  43. package/dist/core/pack-loader.js +220 -0
  44. package/dist/core/pack-loader.js.map +1 -0
  45. package/dist/core/parser.d.ts +19 -0
  46. package/dist/core/parser.d.ts.map +1 -0
  47. package/dist/core/parser.js +235 -0
  48. package/dist/core/parser.js.map +1 -0
  49. package/dist/core/pattern-factory.d.ts +38 -0
  50. package/dist/core/pattern-factory.d.ts.map +1 -0
  51. package/dist/core/pattern-factory.js +222 -0
  52. package/dist/core/pattern-factory.js.map +1 -0
  53. package/dist/core/patterns.d.ts +67 -0
  54. package/dist/core/patterns.d.ts.map +1 -0
  55. package/dist/core/patterns.js +585 -0
  56. package/dist/core/patterns.js.map +1 -0
  57. package/dist/core/session-log.d.ts +91 -0
  58. package/dist/core/session-log.d.ts.map +1 -0
  59. package/dist/core/session-log.js +196 -0
  60. package/dist/core/session-log.js.map +1 -0
  61. package/dist/core/spans.d.ts +92 -0
  62. package/dist/core/spans.d.ts.map +1 -0
  63. package/dist/core/spans.js +148 -0
  64. package/dist/core/spans.js.map +1 -0
  65. package/dist/core/sto.d.ts +120 -0
  66. package/dist/core/sto.d.ts.map +1 -0
  67. package/dist/core/sto.js +147 -0
  68. package/dist/core/sto.js.map +1 -0
  69. package/dist/index.d.ts +267 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +540 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/integrations/claude-agent.d.ts +29 -0
  74. package/dist/integrations/claude-agent.d.ts.map +1 -0
  75. package/dist/integrations/claude-agent.js +40 -0
  76. package/dist/integrations/claude-agent.js.map +1 -0
  77. package/dist/integrations/google-adk.d.ts +27 -0
  78. package/dist/integrations/google-adk.d.ts.map +1 -0
  79. package/dist/integrations/google-adk.js +81 -0
  80. package/dist/integrations/google-adk.js.map +1 -0
  81. package/dist/integrations/langchain.d.ts +26 -0
  82. package/dist/integrations/langchain.d.ts.map +1 -0
  83. package/dist/integrations/langchain.js +74 -0
  84. package/dist/integrations/langchain.js.map +1 -0
  85. package/dist/integrations/openai-agents.d.ts +45 -0
  86. package/dist/integrations/openai-agents.d.ts.map +1 -0
  87. package/dist/integrations/openai-agents.js +81 -0
  88. package/dist/integrations/openai-agents.js.map +1 -0
  89. package/dist/integrations/openai.d.ts +24 -0
  90. package/dist/integrations/openai.d.ts.map +1 -0
  91. package/dist/integrations/openai.js +77 -0
  92. package/dist/integrations/openai.js.map +1 -0
  93. package/dist/integrations/vercel-ai.d.ts +38 -0
  94. package/dist/integrations/vercel-ai.d.ts.map +1 -0
  95. package/dist/integrations/vercel-ai.js +107 -0
  96. package/dist/integrations/vercel-ai.js.map +1 -0
  97. package/dist/render/components.d.ts +23 -0
  98. package/dist/render/components.d.ts.map +1 -0
  99. package/dist/render/components.js +133 -0
  100. package/dist/render/components.js.map +1 -0
  101. package/dist/render/derive.d.ts +23 -0
  102. package/dist/render/derive.d.ts.map +1 -0
  103. package/dist/render/derive.js +92 -0
  104. package/dist/render/derive.js.map +1 -0
  105. package/dist/render/session-view.d.ts +19 -0
  106. package/dist/render/session-view.d.ts.map +1 -0
  107. package/dist/render/session-view.js +236 -0
  108. package/dist/render/session-view.js.map +1 -0
  109. package/dist/render/tokens.d.ts +44 -0
  110. package/dist/render/tokens.d.ts.map +1 -0
  111. package/dist/render/tokens.js +72 -0
  112. package/dist/render/tokens.js.map +1 -0
  113. package/package.json +83 -0
@@ -0,0 +1,585 @@
1
+ /**
2
+ * Pattern library — pre-built LTL contract patterns.
3
+ *
4
+ * Port of sponsio/patterns/library.py (det patterns).
5
+ * Each function returns a formula AST + description.
6
+ *
7
+ * 36 patterns across 7 categories:
8
+ * Core temporal (14): mustPrecede, alwaysFollowedBy, noReversal,
9
+ * requiresPermission, noDataLeak, mutualExclusion, rateLimit,
10
+ * idempotent, deadline, mustConfirm, cooldown, segregationOfDuty,
11
+ * boundedRetry, loopDetection
12
+ * Argument (5): argBlacklist, argAllowlist, scopeLimit, argLengthLimit, dataIntact
13
+ * OWASP (8): destructiveActionGate, untrustedSourceGate,
14
+ * requiredStepsCompletion, toolAllowlist, dangerousBashCommands,
15
+ * dangerousSqlVerbs, irreversibleOnce, confirmAfterSource
16
+ * Resource (3): tokenBudget, argValueRange, delegationDepthLimit
17
+ * Workflow hygiene (6): dryRunBeforeCommit, backupBeforeDestructive,
18
+ * auditAfter, approvalFreshness, sanitizedBeforeSink, duplicateCallLimit
19
+ */
20
+ import { Atom, Not, And, Or, Implies, G, F, X, U, Le, Ge, Var, Const, } from "./formula.js";
21
+ // --- Helpers ---
22
+ function called(tool) {
23
+ // Supports "tool:pattern" format — produces called_with atom.
24
+ if (tool.includes(":")) {
25
+ const [physical, pattern] = tool.split(":", 2);
26
+ return new Atom("called_with", [physical, pattern]);
27
+ }
28
+ return new Atom("called", [tool]);
29
+ }
30
+ function countVar(tool) {
31
+ if (tool.includes(":")) {
32
+ const [physical, pattern] = tool.split(":", 2);
33
+ return new Var("count_with", physical, pattern);
34
+ }
35
+ return new Var("count", tool);
36
+ }
37
+ function physicalTool(tool) {
38
+ return tool.includes(":") ? tool.split(":", 1)[0] : tool;
39
+ }
40
+ /**
41
+ * Reject empty / whitespace-only tool names at factory time.
42
+ *
43
+ * An empty atom (``called()``) is never emitted by the grounding layer, so
44
+ * the contract silently becomes a no-op. Parity with Python
45
+ * ``_ensure_non_empty`` in ``sponsio/patterns/library.py``.
46
+ */
47
+ function ensureNonEmpty(value, pattern, arg) {
48
+ if (typeof value !== "string" || value.trim() === "") {
49
+ throw new Error(`${pattern}: argument \`${arg}\` must be a non-empty string ` +
50
+ `(got ${JSON.stringify(value)}). An empty tool name silently disables ` +
51
+ `the contract — this is almost never what you want.`);
52
+ }
53
+ }
54
+ /**
55
+ * Reject degenerate ``f(x, x)`` construction.
56
+ *
57
+ * Parity with Python ``_ensure_distinct``. Two-arg temporal patterns
58
+ * (``mustPrecede``, ``alwaysFollowedBy``, ``mutualExclusion``,
59
+ * ``noReversal``, ``deadline``, …) collapse into a tautology or change
60
+ * their meaning entirely when the two tools collide; almost always a
61
+ * user typo. Surface it at construction time.
62
+ */
63
+ function ensureDistinct(a, b, pattern, argA, argB) {
64
+ ensureNonEmpty(a, pattern, argA);
65
+ ensureNonEmpty(b, pattern, argB);
66
+ if (a === b) {
67
+ throw new Error(`${pattern}: \`${argA}\` and \`${argB}\` must refer to different tools ` +
68
+ `(got ${JSON.stringify(a)} for both). A same-tool pattern is either ` +
69
+ `vacuously satisfied or silently degenerates into a different contract — ` +
70
+ `use \`idempotent\` / \`rateLimit\` if you meant 'at most once' / 'at most N times'.`);
71
+ }
72
+ }
73
+ /** Bounded eventually: phi within N steps (parity with Python ``_bounded_eventually``).
74
+ *
75
+ * For ``n = 1`` the result is ``phi`` (current step only); for ``n = 2`` it is
76
+ * ``phi ∨ X(phi)``; and so on. The loop runs ``n - 1`` times — running ``n``
77
+ * times (the previous behavior) gave a strictly weaker contract that admitted
78
+ * a violating step the Python evaluator would have caught.
79
+ */
80
+ function boundedEventually(phi, n) {
81
+ let result = phi;
82
+ for (let i = 0; i < n - 1; i++) {
83
+ result = new Or(phi, new X(result));
84
+ }
85
+ return result;
86
+ }
87
+ /** Bounded never: phi false for next N steps. */
88
+ function boundedNever(phi, n) {
89
+ if (n <= 0)
90
+ return new Not(new Atom("__never__"));
91
+ let result = new Not(phi);
92
+ for (let i = 1; i < n; i++) {
93
+ result = new And(new Not(phi), new X(result));
94
+ }
95
+ return result;
96
+ }
97
+ function nextN(phi, n) {
98
+ let result = phi;
99
+ for (let i = 0; i < n; i++) {
100
+ result = new X(result);
101
+ }
102
+ return result;
103
+ }
104
+ function forbiddenUntil(until, forbidden) {
105
+ return new Or(new U(new Not(forbidden), until), new G(new Not(forbidden)));
106
+ }
107
+ // --- Core temporal patterns ---
108
+ export function mustPrecede(before, after) {
109
+ ensureDistinct(before, after, "mustPrecede", "before", "after");
110
+ const f = new Or(new U(new Not(called(after)), called(before)), new G(new Not(called(after))));
111
+ return {
112
+ formula: f,
113
+ desc: `tool \`${before}\` must precede \`${after}\``,
114
+ patternName: "must_precede",
115
+ liveness: false,
116
+ };
117
+ }
118
+ export function alwaysFollowedBy(trigger, response) {
119
+ ensureDistinct(trigger, response, "alwaysFollowedBy", "trigger", "response");
120
+ const f = new G(new Implies(called(trigger), new F(called(response))));
121
+ return {
122
+ formula: f,
123
+ desc: `\`${trigger}\` must always be followed by \`${response}\``,
124
+ patternName: "always_followed_by",
125
+ liveness: true,
126
+ };
127
+ }
128
+ export function noReversal(commitment, contradiction) {
129
+ ensureDistinct(commitment, contradiction, "noReversal", "commitment", "contradiction");
130
+ const f = new G(new Implies(called(commitment), new G(new Not(called(contradiction)))));
131
+ return {
132
+ formula: f,
133
+ desc: `cannot call \`${contradiction}\` after \`${commitment}\``,
134
+ patternName: "no_reversal",
135
+ liveness: false,
136
+ };
137
+ }
138
+ export function requiresPermission(tool, permission) {
139
+ const f = new G(new Implies(called(tool), new Atom("perm", [permission])));
140
+ return {
141
+ formula: f,
142
+ desc: `\`${tool}\` requires permission \`${permission}\``,
143
+ patternName: "requires_permission",
144
+ liveness: false,
145
+ };
146
+ }
147
+ export function noDataLeak(source, external) {
148
+ ensureDistinct(source, external, "noDataLeak", "source", "external");
149
+ const f = new G(new Implies(new Atom("contains", [source]), new Not(new Atom("flow", [source, external]))));
150
+ return {
151
+ formula: f,
152
+ desc: `no data leak from \`${source}\` to \`${external}\``,
153
+ patternName: "no_data_leak",
154
+ liveness: false,
155
+ };
156
+ }
157
+ export function mutualExclusion(a, b) {
158
+ ensureDistinct(a, b, "mutualExclusion", "a", "b");
159
+ const f = new And(new G(new Implies(called(a), new G(new Not(called(b))))), new G(new Implies(called(b), new G(new Not(called(a))))));
160
+ return {
161
+ formula: f,
162
+ desc: `tools \`${a}\` and \`${b}\` are mutually exclusive`,
163
+ patternName: "mutual_exclusion",
164
+ liveness: false,
165
+ };
166
+ }
167
+ export function rateLimit(tool, maxCalls) {
168
+ const f = new G(new Le(countVar(tool), new Const(maxCalls)));
169
+ return {
170
+ formula: f,
171
+ desc: `tool \`${tool}\` at most ${maxCalls} times`,
172
+ patternName: "rate_limit",
173
+ liveness: false,
174
+ };
175
+ }
176
+ export function idempotent(tool) {
177
+ return { ...rateLimit(tool, 1), patternName: "idempotent", desc: `\`${tool}\` at most once` };
178
+ }
179
+ export function deadline(trigger, action, steps) {
180
+ ensureDistinct(trigger, action, "deadline", "trigger", "action");
181
+ if (!Number.isInteger(steps) || steps < 1) {
182
+ throw new Error(`deadline: 'steps' must be a positive integer (got ${steps}). ` +
183
+ `A non-positive deadline is unsatisfiable.`);
184
+ }
185
+ const f = new G(new Implies(called(trigger), new X(boundedEventually(called(action), steps))));
186
+ return {
187
+ formula: f,
188
+ desc: `\`${action}\` must occur within ${steps} steps of \`${trigger}\``,
189
+ patternName: "deadline",
190
+ liveness: true,
191
+ };
192
+ }
193
+ export function mustConfirm(action) {
194
+ const confirm = `confirm_${action}`;
195
+ const f = new Or(new U(new Not(called(action)), called(confirm)), new G(new Not(called(action))));
196
+ return {
197
+ formula: f,
198
+ desc: `\`${action}\` requires confirmation (\`${confirm}\`)`,
199
+ patternName: "must_confirm",
200
+ liveness: false,
201
+ };
202
+ }
203
+ export function cooldown(action, steps) {
204
+ const f = new G(new Implies(called(action), new X(boundedNever(called(action), steps))));
205
+ return {
206
+ formula: f,
207
+ desc: `\`${action}\` has a cooldown of ${steps} steps`,
208
+ patternName: "cooldown",
209
+ liveness: false,
210
+ };
211
+ }
212
+ export function segregationOfDuty(a, b) {
213
+ // Validation runs inside mutualExclusion; re-raising with a
214
+ // segregation-of-duty pattern name would be nicer, but keeping the
215
+ // message consistent is sufficient and avoids duplicating the check.
216
+ const me = mutualExclusion(a, b);
217
+ return {
218
+ ...me,
219
+ patternName: "segregation_of_duty",
220
+ desc: `\`${a}\` and \`${b}\` must be performed by different agents`,
221
+ };
222
+ }
223
+ export function boundedRetry(action, maxRetries) {
224
+ const f = new G(new Le(countVar(action), new Const(maxRetries)));
225
+ return {
226
+ formula: f,
227
+ desc: `\`${action}\` limited to ${maxRetries} retries`,
228
+ patternName: "bounded_retry",
229
+ liveness: false,
230
+ };
231
+ }
232
+ export function loopDetection(action, maxConsecutive) {
233
+ // G(consecutive_count(action) <= max)
234
+ const f = new G(new Le(new Var("consecutive_count", action), new Const(maxConsecutive)));
235
+ return {
236
+ formula: f,
237
+ desc: `\`${action}\` max ${maxConsecutive} consecutive calls`,
238
+ patternName: "loop_detection",
239
+ liveness: false,
240
+ };
241
+ }
242
+ // --- Workflow hygiene patterns ---
243
+ export function dryRunBeforeCommit(dryRun, commit) {
244
+ const base = mustPrecede(dryRun, commit);
245
+ return {
246
+ ...base,
247
+ desc: `\`${dryRun}\` dry-run must precede \`${commit}\``,
248
+ patternName: "dry_run_before_commit",
249
+ };
250
+ }
251
+ export function backupBeforeDestructive(backup, action) {
252
+ const base = mustPrecede(backup, action);
253
+ return {
254
+ ...base,
255
+ desc: `\`${backup}\` backup must precede destructive action \`${action}\``,
256
+ patternName: "backup_before_destructive",
257
+ };
258
+ }
259
+ export function auditAfter(action, audit) {
260
+ const base = alwaysFollowedBy(action, audit);
261
+ return {
262
+ ...base,
263
+ desc: `\`${action}\` must be followed by audit step \`${audit}\``,
264
+ patternName: "audit_after",
265
+ liveness: true,
266
+ };
267
+ }
268
+ export function approvalFreshness(approval, action, steps) {
269
+ ensureDistinct(approval, action, "approvalFreshness", "approval", "action");
270
+ if (!Number.isInteger(steps) || steps < 1) {
271
+ throw new Error(`approval_freshness: 'steps' must be a positive integer (got ${steps}).`);
272
+ }
273
+ const approvalAtom = called(approval);
274
+ const actionAtom = called(action);
275
+ const closedWindow = forbiddenUntil(approvalAtom, actionAtom);
276
+ const f = new And(closedWindow, new G(new Implies(approvalAtom, nextN(closedWindow, steps + 1))));
277
+ return {
278
+ formula: f,
279
+ desc: `\`${action}\` requires approval \`${approval}\` within ${steps} steps`,
280
+ patternName: "approval_freshness",
281
+ liveness: false,
282
+ };
283
+ }
284
+ export function sanitizedBeforeSink(source, sanitizer, sink) {
285
+ ensureDistinct(source, sanitizer, "sanitizedBeforeSink", "source", "sanitizer");
286
+ ensureDistinct(sanitizer, sink, "sanitizedBeforeSink", "sanitizer", "sink");
287
+ ensureDistinct(source, sink, "sanitizedBeforeSink", "source", "sink");
288
+ const f = new G(new Implies(called(source), new X(forbiddenUntil(called(sanitizer), called(sink)))));
289
+ return {
290
+ formula: f,
291
+ desc: `after \`${source}\`, \`${sanitizer}\` must precede \`${sink}\``,
292
+ patternName: "sanitized_before_sink",
293
+ liveness: false,
294
+ };
295
+ }
296
+ export function duplicateCallLimit(tool, argsPattern, maxCount) {
297
+ ensureNonEmpty(tool, "duplicateCallLimit", "tool");
298
+ ensureNonEmpty(argsPattern, "duplicateCallLimit", "argsPattern");
299
+ if (!Number.isInteger(maxCount) || maxCount < 0) {
300
+ throw new Error(`duplicate_call_limit: 'maxCount' must be a non-negative integer (got ${maxCount}).`);
301
+ }
302
+ const f = new G(new Le(new Var("count_with", tool, argsPattern), new Const(maxCount)));
303
+ return {
304
+ formula: f,
305
+ desc: `\`${tool}\` calls matching ${JSON.stringify(argsPattern)} at most ${maxCount} times`,
306
+ patternName: "duplicate_call_limit",
307
+ liveness: false,
308
+ };
309
+ }
310
+ // --- Argument patterns ---
311
+ export function argBlacklist(tool, field, patterns) {
312
+ const physical = physicalTool(tool);
313
+ let body = new Not(new Atom("arg_field_has", [physical, field, patterns[0]]));
314
+ for (let i = 1; i < patterns.length; i++) {
315
+ body = new And(body, new Not(new Atom("arg_field_has", [physical, field, patterns[i]])));
316
+ }
317
+ const f = new G(new Implies(called(tool), body));
318
+ return {
319
+ formula: f,
320
+ desc: `\`${tool}\`.${field} must not match ${JSON.stringify(patterns)}`,
321
+ patternName: "arg_blacklist",
322
+ liveness: false,
323
+ };
324
+ }
325
+ export function argAllowlist(tool, field, patterns) {
326
+ if (patterns.length === 0) {
327
+ throw new Error("arg_allowlist: 'patterns' must be non-empty. An empty allowlist " +
328
+ "would block every call to the tool. Use tool_allowlist to ban " +
329
+ "the tool itself, or arg_blacklist if you want to forbid specific patterns.");
330
+ }
331
+ const physical = physicalTool(tool);
332
+ let body = new Atom("arg_field_has", [physical, field, patterns[0]]);
333
+ for (let i = 1; i < patterns.length; i++) {
334
+ body = new Or(body, new Atom("arg_field_has", [physical, field, patterns[i]]));
335
+ }
336
+ const f = new G(new Implies(called(tool), body));
337
+ return {
338
+ formula: f,
339
+ desc: `\`${tool}\`.${field} must match one of ${JSON.stringify(patterns)}`,
340
+ patternName: "arg_allowlist",
341
+ liveness: false,
342
+ };
343
+ }
344
+ export function scopeLimit(tool, allowedPaths) {
345
+ const physical = physicalTool(tool);
346
+ const f = new G(new Implies(called(tool), new Atom("arg_paths_within", [physical, ...allowedPaths])));
347
+ return {
348
+ formula: f,
349
+ desc: `\`${tool}\` restricted to paths: ${allowedPaths.join(", ")}`,
350
+ patternName: "scope_limit",
351
+ liveness: false,
352
+ };
353
+ }
354
+ export function argLengthLimit(tool, param, maxChars) {
355
+ const physical = physicalTool(tool);
356
+ const f = new G(new Implies(called(tool), new Not(new Atom("arg_length_exceeds", [physical, param, String(maxChars)]))));
357
+ return {
358
+ formula: f,
359
+ desc: `\`${tool}\`.${param} must not exceed ${maxChars} characters`,
360
+ patternName: "arg_length_limit",
361
+ liveness: false,
362
+ };
363
+ }
364
+ export function dataIntact(boundTool, originalPaths) {
365
+ const f = new G(new Implies(new Atom("arg_has", ["bash", boundTool]), new Atom("arg_paths_within", ["bash", ...originalPaths])));
366
+ return {
367
+ formula: f,
368
+ desc: `\`${boundTool}\` must use only original data from ${originalPaths.join(", ")}`,
369
+ patternName: "data_intact",
370
+ liveness: false,
371
+ };
372
+ }
373
+ // --- OWASP Agentic Security patterns ---
374
+ export function destructiveActionGate(tool, approverRole = "approver") {
375
+ const confirm = `confirm_${tool}`;
376
+ // G(!called(tool)) ∨ ((!called(tool)) U (called(confirm) ∧ perm(role)))
377
+ const f = new Or(new G(new Not(called(tool))), new U(new Not(called(tool)), new And(called(confirm), new Atom("perm", [approverRole]))));
378
+ return {
379
+ formula: f,
380
+ desc: `\`${tool}\` is destructive and requires \`${approverRole}\` approval`,
381
+ patternName: "destructive_action_gate",
382
+ liveness: false,
383
+ };
384
+ }
385
+ export function untrustedSourceGate(source, sink, confirm = "") {
386
+ ensureDistinct(source, sink, "untrustedSourceGate", "source", "sink");
387
+ const confirmAction = confirm || `confirm_${sink}`;
388
+ return {
389
+ assumption: {
390
+ formula: called(source),
391
+ desc: `\`${source}\` has been called (untrusted input)`,
392
+ patternName: "untrusted_source_gate_assumption",
393
+ liveness: false,
394
+ },
395
+ enforcement: mustPrecede(confirmAction, sink),
396
+ };
397
+ }
398
+ export function requiredStepsCompletion(trigger, steps) {
399
+ // Parity with Python:
400
+ // G(called(trigger) → F(called(s1)) ∧ F(called(s2)) ∧ ...)
401
+ // (No outer ``X(...)``: the obligation must be discharged starting from the
402
+ // trigger step, and weak-X at end-of-trace must NOT vacuously satisfy a
403
+ // trigger that fires at the last step before any step has happened.)
404
+ ensureNonEmpty(trigger, "requiredStepsCompletion", "trigger");
405
+ if (!steps || steps.length === 0) {
406
+ throw new Error("requiredStepsCompletion: 'steps' must not be empty. An empty checklist " +
407
+ "is vacuously satisfied for every trigger.");
408
+ }
409
+ const seen = new Set();
410
+ for (const r of steps) {
411
+ ensureNonEmpty(r, "requiredStepsCompletion", "steps");
412
+ if (r === trigger) {
413
+ throw new Error(`requiredStepsCompletion: trigger ${JSON.stringify(trigger)} cannot also ` +
414
+ `appear in steps — the trigger would be its own follow-up, making the ` +
415
+ `constraint trivially satisfied.`);
416
+ }
417
+ if (seen.has(r)) {
418
+ throw new Error(`requiredStepsCompletion: steps contains a duplicate ${JSON.stringify(r)}. ` +
419
+ `Deduplicate before building the contract.`);
420
+ }
421
+ seen.add(r);
422
+ }
423
+ let body = new F(called(steps[0]));
424
+ for (let i = 1; i < steps.length; i++) {
425
+ body = new And(body, new F(called(steps[i])));
426
+ }
427
+ const f = new G(new Implies(called(trigger), body));
428
+ return {
429
+ formula: f,
430
+ desc: `after \`${trigger}\`, all steps must complete: ${steps.join(", ")}`,
431
+ patternName: "required_steps_completion",
432
+ liveness: true,
433
+ };
434
+ }
435
+ export function toolAllowlist(allowedTools) {
436
+ // ``called_any`` is emitted by the grounding layer for every
437
+ // tool_call event (regardless of which tool). Requiring
438
+ // ``G(called_any -> Or(called(a1), ..., called(aN)))`` encodes
439
+ // "whenever any tool runs, it must be one of these".
440
+ if (!Array.isArray(allowedTools) || allowedTools.length === 0) {
441
+ throw new Error("toolAllowlist requires a non-empty list of allowed tool names");
442
+ }
443
+ const disjunction = allowedTools
444
+ .map((t) => called(t))
445
+ .reduce((acc, atom) => (acc ? new Or(acc, atom) : atom), null);
446
+ const formula = new G(new Implies(new Atom("called_any"), disjunction));
447
+ return {
448
+ formula,
449
+ desc: `only allowed tools: ${allowedTools.join(", ")}`,
450
+ patternName: "tool_allowlist",
451
+ liveness: false,
452
+ };
453
+ }
454
+ export function dangerousBashCommands(forbidden) {
455
+ const defaults = [
456
+ "sed -i", "rm -rf", "cp /app/data", "mv /app/data",
457
+ "python -c", "chmod", "> /app", "tee /app",
458
+ ];
459
+ const cmds = forbidden ?? defaults;
460
+ // G(count_with(bash, cmd) <= 0) for each cmd — AND them all
461
+ let body = new Le(new Var("count_with", "bash", cmds[0]), new Const(0));
462
+ for (let i = 1; i < cmds.length; i++) {
463
+ body = new And(body, new Le(new Var("count_with", "bash", cmds[i]), new Const(0)));
464
+ }
465
+ const f = new G(body);
466
+ return {
467
+ formula: f,
468
+ desc: `bash commands [${cmds.join(", ")}] are banned`,
469
+ patternName: "dangerous_bash_commands",
470
+ liveness: false,
471
+ };
472
+ }
473
+ /**
474
+ * Build a JS-regex-compatible case-insensitive pattern from a plain
475
+ * word. JS regex doesn't support inline ``(?i)`` flags, so we expand
476
+ * each letter into a character class (``DROP`` → ``[dD][rR][oO][pP]``).
477
+ * Non-letter characters pass through. This keeps grounding.ts's
478
+ * ``new RegExp(pattern)`` call case-sensitive for ``arg_blacklist``
479
+ * (where the user authors literal regex) while letting safety-net
480
+ * factories like ``dangerous_sql_verbs`` match lowercase too.
481
+ */
482
+ function caseInsensitiveLiteral(word) {
483
+ let out = "";
484
+ for (const ch of word) {
485
+ if (ch >= "a" && ch <= "z")
486
+ out += `[${ch}${ch.toUpperCase()}]`;
487
+ else if (ch >= "A" && ch <= "Z")
488
+ out += `[${ch.toLowerCase()}${ch}]`;
489
+ else if ("\\^$.|?*+()[]{}".includes(ch))
490
+ out += `\\${ch}`;
491
+ else
492
+ out += ch;
493
+ }
494
+ return out;
495
+ }
496
+ export function dangerousSqlVerbs(tool = "execute_sql", forbidden) {
497
+ const defaults = ["DROP", "TRUNCATE", "DELETE", "ALTER"];
498
+ const verbs = forbidden ?? defaults;
499
+ // Wrap each verb in a case-insensitive word pattern so ``drop table``
500
+ // and ``DROP TABLE`` both match — the safety net would be useless
501
+ // case-sensitive since LLMs emit either form.
502
+ const verbPatterns = verbs.map((v) => `\\b${caseInsensitiveLiteral(v)}\\b`);
503
+ let body = new Not(new Atom("arg_field_has", [tool, "query", verbPatterns[0]]));
504
+ for (let i = 1; i < verbPatterns.length; i++) {
505
+ body = new And(body, new Not(new Atom("arg_field_has", [tool, "query", verbPatterns[i]])));
506
+ }
507
+ const f = new G(new Implies(called(tool), body));
508
+ return {
509
+ formula: f,
510
+ desc: `\`${tool}\` must not use SQL verbs [${verbs.join(", ")}]`,
511
+ patternName: "dangerous_sql_verbs",
512
+ liveness: false,
513
+ };
514
+ }
515
+ export function irreversibleOnce(action) {
516
+ const f = new G(new Le(countVar(action), new Const(1)));
517
+ return {
518
+ formula: f,
519
+ desc: `\`${action}\` is irreversible and may be called at most once`,
520
+ patternName: "irreversible_once",
521
+ liveness: false,
522
+ };
523
+ }
524
+ export function confirmAfterSource(source, action) {
525
+ ensureDistinct(source, action, "confirmAfterSource", "source", "action");
526
+ const confirm = `confirm_${action}`;
527
+ return {
528
+ assumption: {
529
+ formula: called(source),
530
+ desc: `\`${source}\` has been called`,
531
+ patternName: "confirm_after_source_assumption",
532
+ liveness: false,
533
+ },
534
+ enforcement: mustPrecede(confirm, action),
535
+ };
536
+ }
537
+ // --- Resource / delegation patterns ---
538
+ export function tokenBudget(maxTokens, scope = "total") {
539
+ const f = new G(new Le(new Var("token_count", scope), new Const(maxTokens)));
540
+ return {
541
+ formula: f,
542
+ desc: `session ${scope} tokens must not exceed ${maxTokens}`,
543
+ patternName: "token_budget",
544
+ liveness: false,
545
+ };
546
+ }
547
+ export function argValueRange(tool, field, minVal, maxVal) {
548
+ if (minVal == null && maxVal == null) {
549
+ throw new Error("argValueRange requires at least minVal or maxVal");
550
+ }
551
+ const physical = physicalTool(tool);
552
+ const v = new Var("arg_numeric", physical, field);
553
+ // Guard with called_with so the range check only fires when the tool is invoked.
554
+ const guardAtom = called(tool);
555
+ const parts = [];
556
+ if (minVal != null)
557
+ parts.push(new Ge(v, new Const(minVal)));
558
+ if (maxVal != null)
559
+ parts.push(new Le(v, new Const(maxVal)));
560
+ const body = parts.length === 1 ? parts[0] : new And(parts[0], parts[1]);
561
+ const f = new G(new Implies(guardAtom, body));
562
+ let rangeStr;
563
+ if (minVal != null && maxVal != null)
564
+ rangeStr = `[${minVal}, ${maxVal}]`;
565
+ else if (minVal != null)
566
+ rangeStr = `>= ${minVal}`;
567
+ else
568
+ rangeStr = `<= ${maxVal}`;
569
+ return {
570
+ formula: f,
571
+ desc: `\`${tool}\`.${field} must be in range ${rangeStr}`,
572
+ patternName: "arg_value_range",
573
+ liveness: false,
574
+ };
575
+ }
576
+ export function delegationDepthLimit(maxDepth) {
577
+ const f = new G(new Le(new Var("delegation_depth"), new Const(maxDepth)));
578
+ return {
579
+ formula: f,
580
+ desc: `delegation chain must not exceed depth ${maxDepth}`,
581
+ patternName: "delegation_depth_limit",
582
+ liveness: false,
583
+ };
584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