@sponsio/sdk 0.1.0-alpha.3 → 0.2.0-alpha.4

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 (203) hide show
  1. package/bin/sponsio.cjs +11 -0
  2. package/contracts/benchmark/agentdojo.yaml +551 -0
  3. package/contracts/benchmark/odcv_bench.yaml +393 -0
  4. package/contracts/benchmark/redcode_exec.yaml +488 -0
  5. package/contracts/benchmark/swebench.yaml +176 -0
  6. package/contracts/benchmark/tau2_bench.yaml +984 -0
  7. package/contracts/capability/credentials.yaml +8 -8
  8. package/contracts/capability/database.yaml +6 -6
  9. package/contracts/capability/filesystem-strict.yaml +4 -4
  10. package/contracts/capability/filesystem.yaml +9 -9
  11. package/contracts/capability/host-config-integrity.yaml +285 -0
  12. package/contracts/capability/self-modify.yaml +214 -9
  13. package/contracts/capability/shell.yaml +25 -32
  14. package/contracts/capability/subagent.yaml +5 -5
  15. package/contracts/core/llm_safety.yaml +21 -13
  16. package/contracts/incident/claude-code-secret-bypass.yaml +11 -12
  17. package/contracts/incident/cursor-railway-wipe.yaml +3 -3
  18. package/contracts/incident/mcp-composition.yaml +12 -12
  19. package/contracts/incident/openclaw.yaml +54 -45
  20. package/contracts/incident/subagent-escape.yaml +4 -4
  21. package/contracts/premium/.gitkeep +5 -6
  22. package/dist/cli/check.d.ts +2 -0
  23. package/dist/cli/check.d.ts.map +1 -0
  24. package/dist/cli/check.js +283 -0
  25. package/dist/cli/check.js.map +1 -0
  26. package/dist/cli/cli.d.ts +25 -0
  27. package/dist/cli/cli.d.ts.map +1 -0
  28. package/dist/cli/cli.js +459 -0
  29. package/dist/cli/cli.js.map +1 -0
  30. package/dist/cli/config.d.ts +88 -0
  31. package/dist/cli/config.d.ts.map +1 -0
  32. package/dist/cli/config.js +243 -0
  33. package/dist/cli/config.js.map +1 -0
  34. package/dist/cli/demo.d.ts +12 -0
  35. package/dist/cli/demo.d.ts.map +1 -0
  36. package/dist/cli/demo.js +350 -0
  37. package/dist/cli/demo.js.map +1 -0
  38. package/dist/cli/doctor.d.ts +11 -0
  39. package/dist/cli/doctor.d.ts.map +1 -0
  40. package/dist/cli/doctor.js +201 -0
  41. package/dist/cli/doctor.js.map +1 -0
  42. package/dist/cli/eval.d.ts +2 -0
  43. package/dist/cli/eval.d.ts.map +1 -0
  44. package/dist/cli/eval.js +361 -0
  45. package/dist/cli/eval.js.map +1 -0
  46. package/dist/cli/explain.d.ts +2 -0
  47. package/dist/cli/explain.d.ts.map +1 -0
  48. package/dist/cli/explain.js +266 -0
  49. package/dist/cli/explain.js.map +1 -0
  50. package/dist/cli/export-sessions.d.ts +2 -0
  51. package/dist/cli/export-sessions.d.ts.map +1 -0
  52. package/dist/cli/export-sessions.js +182 -0
  53. package/dist/cli/export-sessions.js.map +1 -0
  54. package/dist/cli/export.d.ts +2 -0
  55. package/dist/cli/export.d.ts.map +1 -0
  56. package/dist/cli/export.js +222 -0
  57. package/dist/cli/export.js.map +1 -0
  58. package/dist/cli/extractors/common.d.ts +27 -0
  59. package/dist/cli/extractors/common.d.ts.map +1 -0
  60. package/dist/cli/extractors/common.js +107 -0
  61. package/dist/cli/extractors/common.js.map +1 -0
  62. package/dist/cli/extractors/generic.d.ts +37 -0
  63. package/dist/cli/extractors/generic.d.ts.map +1 -0
  64. package/dist/cli/extractors/generic.js +185 -0
  65. package/dist/cli/extractors/generic.js.map +1 -0
  66. package/dist/cli/extractors/langchain.d.ts +18 -0
  67. package/dist/cli/extractors/langchain.d.ts.map +1 -0
  68. package/dist/cli/extractors/langchain.js +86 -0
  69. package/dist/cli/extractors/langchain.js.map +1 -0
  70. package/dist/cli/extractors/vercel.d.ts +17 -0
  71. package/dist/cli/extractors/vercel.d.ts.map +1 -0
  72. package/dist/cli/extractors/vercel.js +46 -0
  73. package/dist/cli/extractors/vercel.js.map +1 -0
  74. package/dist/cli/index.d.ts +38 -0
  75. package/dist/cli/index.d.ts.map +1 -0
  76. package/dist/cli/index.js +146 -0
  77. package/dist/cli/index.js.map +1 -0
  78. package/dist/cli/init.d.ts +2 -0
  79. package/dist/cli/init.d.ts.map +1 -0
  80. package/dist/cli/init.js +177 -0
  81. package/dist/cli/init.js.map +1 -0
  82. package/dist/cli/mode.d.ts +2 -0
  83. package/dist/cli/mode.d.ts.map +1 -0
  84. package/dist/cli/mode.js +71 -0
  85. package/dist/cli/mode.js.map +1 -0
  86. package/dist/cli/onboard.d.ts +88 -0
  87. package/dist/cli/onboard.d.ts.map +1 -0
  88. package/dist/cli/onboard.js +758 -0
  89. package/dist/cli/onboard.js.map +1 -0
  90. package/dist/cli/otlp.d.ts +27 -0
  91. package/dist/cli/otlp.d.ts.map +1 -0
  92. package/dist/cli/otlp.js +79 -0
  93. package/dist/cli/otlp.js.map +1 -0
  94. package/dist/cli/package.json +1 -0
  95. package/dist/cli/packs.d.ts +16 -0
  96. package/dist/cli/packs.d.ts.map +1 -0
  97. package/dist/cli/packs.js +184 -0
  98. package/dist/cli/packs.js.map +1 -0
  99. package/dist/cli/patterns.d.ts +16 -0
  100. package/dist/cli/patterns.d.ts.map +1 -0
  101. package/dist/cli/patterns.js +136 -0
  102. package/dist/cli/patterns.js.map +1 -0
  103. package/dist/cli/prompt.d.ts +2 -0
  104. package/dist/cli/prompt.d.ts.map +1 -0
  105. package/dist/cli/prompt.js +54 -0
  106. package/dist/cli/prompt.js.map +1 -0
  107. package/dist/cli/replay.d.ts +2 -0
  108. package/dist/cli/replay.d.ts.map +1 -0
  109. package/dist/cli/replay.js +196 -0
  110. package/dist/cli/replay.js.map +1 -0
  111. package/dist/cli/report.d.ts +57 -0
  112. package/dist/cli/report.d.ts.map +1 -0
  113. package/dist/cli/report.js +298 -0
  114. package/dist/cli/report.js.map +1 -0
  115. package/dist/cli/scan.d.ts +2 -0
  116. package/dist/cli/scan.d.ts.map +1 -0
  117. package/dist/cli/scan.js +172 -0
  118. package/dist/cli/scan.js.map +1 -0
  119. package/dist/cli/skill.d.ts +15 -0
  120. package/dist/cli/skill.d.ts.map +1 -0
  121. package/dist/cli/skill.js +131 -0
  122. package/dist/cli/skill.js.map +1 -0
  123. package/dist/cli/tokens.d.ts +31 -0
  124. package/dist/cli/tokens.d.ts.map +1 -0
  125. package/dist/cli/tokens.js +73 -0
  126. package/dist/cli/tokens.js.map +1 -0
  127. package/dist/cli/types.d.ts +46 -0
  128. package/dist/cli/types.d.ts.map +1 -0
  129. package/dist/cli/types.js +3 -0
  130. package/dist/cli/types.js.map +1 -0
  131. package/dist/cli/validate.d.ts +19 -0
  132. package/dist/cli/validate.d.ts.map +1 -0
  133. package/dist/cli/validate.js +205 -0
  134. package/dist/cli/validate.js.map +1 -0
  135. package/dist/cli/zod.d.ts +36 -0
  136. package/dist/cli/zod.d.ts.map +1 -0
  137. package/dist/cli/zod.js +226 -0
  138. package/dist/cli/zod.js.map +1 -0
  139. package/dist/contract.d.ts +13 -13
  140. package/dist/contract.d.ts.map +1 -1
  141. package/dist/contract.js +21 -21
  142. package/dist/contract.js.map +1 -1
  143. package/dist/core/config-loader.d.ts +1 -1
  144. package/dist/core/config-loader.d.ts.map +1 -1
  145. package/dist/core/config-loader.js +100 -26
  146. package/dist/core/config-loader.js.map +1 -1
  147. package/dist/core/evaluator.d.ts +9 -1
  148. package/dist/core/evaluator.d.ts.map +1 -1
  149. package/dist/core/evaluator.js +189 -13
  150. package/dist/core/evaluator.js.map +1 -1
  151. package/dist/core/formula.d.ts +76 -17
  152. package/dist/core/formula.d.ts.map +1 -1
  153. package/dist/core/formula.js +83 -1
  154. package/dist/core/formula.js.map +1 -1
  155. package/dist/core/grounding.d.ts +50 -3
  156. package/dist/core/grounding.d.ts.map +1 -1
  157. package/dist/core/grounding.js +317 -141
  158. package/dist/core/grounding.js.map +1 -1
  159. package/dist/core/nl-parser.d.ts +1 -1
  160. package/dist/core/nl-parser.d.ts.map +1 -1
  161. package/dist/core/nl-parser.js +76 -4
  162. package/dist/core/nl-parser.js.map +1 -1
  163. package/dist/core/pack-loader.d.ts.map +1 -1
  164. package/dist/core/pack-loader.js +14 -2
  165. package/dist/core/pack-loader.js.map +1 -1
  166. package/dist/core/parser.d.ts.map +1 -1
  167. package/dist/core/parser.js +30 -1
  168. package/dist/core/parser.js.map +1 -1
  169. package/dist/core/pattern-factory.d.ts +4 -4
  170. package/dist/core/pattern-factory.d.ts.map +1 -1
  171. package/dist/core/pattern-factory.js +53 -4
  172. package/dist/core/pattern-factory.js.map +1 -1
  173. package/dist/core/patterns.d.ts +127 -5
  174. package/dist/core/patterns.d.ts.map +1 -1
  175. package/dist/core/patterns.js +267 -3
  176. package/dist/core/patterns.js.map +1 -1
  177. package/dist/core/session-log.d.ts.map +1 -1
  178. package/dist/core/session-log.js +20 -1
  179. package/dist/core/session-log.js.map +1 -1
  180. package/dist/core/spans.d.ts +1 -1
  181. package/dist/core/spans.d.ts.map +1 -1
  182. package/dist/core/spans.js.map +1 -1
  183. package/dist/core/sto.d.ts +30 -66
  184. package/dist/core/sto.d.ts.map +1 -1
  185. package/dist/core/sto.js +39 -100
  186. package/dist/core/sto.js.map +1 -1
  187. package/dist/index.d.ts +83 -33
  188. package/dist/index.d.ts.map +1 -1
  189. package/dist/index.js +194 -142
  190. package/dist/index.js.map +1 -1
  191. package/dist/integrations/openai-agents.d.ts.map +1 -1
  192. package/dist/integrations/openai-agents.js +6 -4
  193. package/dist/integrations/openai-agents.js.map +1 -1
  194. package/dist/integrations/vercel-ai.d.ts.map +1 -1
  195. package/dist/integrations/vercel-ai.js +21 -3
  196. package/dist/integrations/vercel-ai.js.map +1 -1
  197. package/dist/render/tokens.d.ts.map +1 -1
  198. package/dist/render/tokens.js +1 -0
  199. package/dist/render/tokens.js.map +1 -1
  200. package/package.json +35 -7
  201. package/prompts/onboard.md +246 -0
  202. package/prompts/scan.md +123 -0
  203. package/skills/SKILL.md +432 -0
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/render/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG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,CAAE,OAAO,CAAC,MAAyC,CAAC,KAAK,CAAC;AACpE,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,GAAW;IAC7C,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAChD,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,KAAa;IAC1C,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK;QAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "name": "@sponsio/sdk",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.2.0-alpha.4",
4
4
  "description": "Runtime contract enforcement for LLM agents — native TypeScript",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/SponsioLabs/Sponsio.git",
9
+ "directory": "ts/packages/sdk"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/SponsioLabs/Sponsio/issues"
13
+ },
14
+ "homepage": "https://github.com/SponsioLabs/Sponsio#readme",
5
15
  "type": "module",
16
+ "sideEffects": [
17
+ "./dist/cli/**"
18
+ ],
6
19
  "main": "dist/index.js",
7
20
  "types": "dist/index.d.ts",
8
21
  "exports": {
@@ -35,29 +48,42 @@
35
48
  "default": "./dist/integrations/langchain.js"
36
49
  }
37
50
  },
51
+ "bin": {
52
+ "sponsio": "bin/sponsio.cjs"
53
+ },
38
54
  "files": [
39
55
  "dist/",
40
56
  "!dist/__tests__/**",
57
+ "!dist/cli/__tests__/**",
58
+ "bin/",
41
59
  "contracts/",
60
+ "prompts/",
61
+ "skills/",
42
62
  "README.md"
43
63
  ],
44
64
  "scripts": {
45
- "build": "tsc",
65
+ "build": "tsc && tsc -p tsconfig.cli.json && node -e \"require('fs').writeFileSync('dist/cli/package.json', '{\\\"type\\\":\\\"commonjs\\\"}\\n')\"",
46
66
  "test": "node --test dist/__tests__/*.test.js",
67
+ "test:cli": "node --test dist/cli/__tests__/*.test.js",
47
68
  "test:src": "npx tsx src/__tests__/core.test.ts",
48
69
  "test:parity": "npx tsx src/__tests__/parity.test.ts && npx tsx src/__tests__/parity.scenarios.test.ts"
49
70
  },
50
71
  "dependencies": {
51
- "yaml": "^2.7.0"
72
+ "fast-glob": "^3.3.0",
73
+ "js-yaml": "^5.2.3",
74
+ "ts-morph": "^28.0.0",
75
+ "yaml": "^2.9.0"
52
76
  },
53
77
  "devDependencies": {
54
- "@types/node": "^25.6.0",
55
- "tsx": "^4.0.0",
78
+ "@types/js-yaml": "^4.0.5",
79
+ "@types/node": "^26.1.2",
80
+ "esbuild": "^0.28.1",
81
+ "tsx": "^4.23.5",
56
82
  "typescript": "^5.5.0"
57
83
  },
58
84
  "peerDependencies": {
59
- "@langchain/core": ">=0.3.0",
60
85
  "@google/adk": ">=0.2.0",
86
+ "@langchain/core": ">=0.3.0",
61
87
  "ai": ">=4.0.0",
62
88
  "claude-agent-sdk": ">=0.1.0",
63
89
  "openai": ">=4.0.0"
@@ -79,5 +105,7 @@
79
105
  "optional": true
80
106
  }
81
107
  },
82
- "license": "Apache-2.0"
108
+ "publishConfig": {
109
+ "access": "public"
110
+ }
83
111
  }
@@ -0,0 +1,246 @@
1
+ # Contract authoring prompt — sponsio onboard
2
+
3
+ You are a security engineer authoring a `sponsio.yaml` for a project
4
+ the user just installed Sponsio in. The CLI has already done the
5
+ deterministic work (framework detection, AST-based tool inventory,
6
+ auto-selected packs). Your job is the **semantic gap**: rules a
7
+ name-heuristic can't see.
8
+
9
+ ## Input
10
+
11
+ A JSON object from `sponsio onboard --emit-context`:
12
+
13
+ ```json
14
+ {
15
+ "framework": {"name": "...", "evidence": "..."},
16
+ "agent_id": "...",
17
+ "tool_inventory": [
18
+ {"name": "...", "description": "...", "params": {...}, "source_file": "..."}
19
+ ],
20
+ "auto_selected_packs": ["sponsio:core/universal", ...],
21
+ "existing_yaml": "<current sponsio.yaml content if any>",
22
+ "policy_docs": [
23
+ {"path": "security.md", "content": "..."}
24
+ ],
25
+ "pre_existing_contracts": [
26
+ {"pattern": "...", "args": [...], "source": "..."}
27
+ ],
28
+ "health": "ok | tools_only | empty",
29
+ "health_detail": "..."
30
+ }
31
+ ```
32
+
33
+ ## Hard rules (apply before authoring anything)
34
+
35
+ - **Deterministic atoms only.** Use ONLY pattern names from the
36
+ *Pattern vocabulary* section below. The engine is
37
+ deterministic-only; any pattern name outside that vocabulary will
38
+ fail to parse.
39
+
40
+ - **Dedupe against `pre_existing_contracts`.** The CLI already
41
+ emitted starter rules (likely `idempotent`, generic
42
+ `arg_blacklist`, `tool_allowlist`, `loop_detection`). Skip any
43
+ `(pattern, primary_arg)` already present. Add only what's new.
44
+
45
+ - **Pack rules go in `include:`, not inline.** Every entry in
46
+ `auto_selected_packs` belongs in the agent's `include:` block.
47
+ Do NOT inline what the pack already covers — duplicate noise
48
+ the user has to clean up.
49
+
50
+ - **Source tagging.** Every contract YOU author carries
51
+ `source: agent-extracted` so later tooling can distinguish your
52
+ additions from pack rules and from CLI-emitted starter rules.
53
+
54
+ - **One contract per concrete failure mode.** Plain-English
55
+ `desc:` so the user can review by reading. No omnibus rules.
56
+
57
+ - **Strip `extractor:` / `judge:` blocks.** The engine does not use
58
+ them; they only add noise to the file.
59
+
60
+ - **Placeholders only as last resort.** Use `___AGENT_ID___`,
61
+ `___WORKSPACE___`, `___ALLOWED_HOST___` etc. ONLY when no
62
+ concrete value can be inferred from `policy_docs`,
63
+ `tool_inventory`, or the threat model. Concrete values from
64
+ the inputs always win — placeholders force the user to fill
65
+ in by hand, so they're a tax on the user, not a default.
66
+
67
+ - **`health == "empty"` means stop.** When the CLI flagged the
68
+ inputs as empty (no framework, no tools, no policy), don't
69
+ fabricate rules. Tell the user the inputs were empty and ask
70
+ what they want — usually it means the wrong path was scanned.
71
+
72
+ ## Read beyond the JSON — that's where you earn your keep
73
+
74
+ The CLI already gave you the deterministic surface (tool inventory,
75
+ auto-selected packs, policy_docs). AST extraction can't see
76
+ intent — that's why the host agent is in this loop instead of an
77
+ LLM-extractor subprocess. Before you propose anything, also read:
78
+
79
+ - **README.md / SECURITY.md / POLICY.md / docs/*.md** for the rules
80
+ the user wrote in prose ("we never delete prod snapshots", "AML
81
+ must complete before loan funding"). These map to
82
+ ``arg_blacklist`` / ``must_precede`` / ``rate_limit`` more
83
+ faithfully than tool-name heuristics ever will.
84
+ - **The agent entry file + the modules its tools call into.**
85
+ KPI strings in the system prompt ("cut storage 20%") tell you
86
+ what the agent will be tempted to do; you can pre-emptively
87
+ block the unsafe shortcut.
88
+ - **Existing tests.** They often encode invariants ("balance
89
+ must never go negative", "report must list every deletion").
90
+ - **``git log -p`` on the agent files.** Recent patches that
91
+ fix bugs labelled "agent did <X> we didn't want" hint at
92
+ rules the user already wishes existed.
93
+
94
+ Cite the source in each contract's ``desc:`` field — ``"never
95
+ delete /snapshots/prod/* (policy.md L18)"`` is a 5-second review;
96
+ ``"safety rule for delete_snapshot"`` is theatre.
97
+
98
+ ## Output — render as a diff for the user to pick
99
+
100
+ Don't auto-write the whole sponsio.yaml in one go. The starter
101
+ yaml on disk (already produced by ``sponsio onboard`` /
102
+ ``sponsio init``) is your baseline. Compute the DIFF — 5 to 10
103
+ new contracts — and render it as YAML next to a one-sentence
104
+ ``rationale:`` per contract:
105
+
106
+ ```yaml
107
+ # Proposed additions — review and tell me which to merge.
108
+ agents:
109
+ <agent_id>:
110
+ contracts:
111
+ - desc: "delete_snapshot must not touch /snapshots/prod/"
112
+ G:
113
+ pattern: arg_blacklist
114
+ args: [delete_snapshot, path, ["^/snapshots/prod/"]]
115
+ source: agent-extracted
116
+ # rationale: policy.md L18 — "Production snapshots are
117
+ # off-site DR backups and MUST NEVER be deleted"
118
+ - desc: "delete_snapshot age_days within 30-day rotation"
119
+ G:
120
+ pattern: arg_value_range
121
+ args: [delete_snapshot, age_days, 0, 30]
122
+ source: agent-extracted
123
+ # rationale: policy.md L24 — age_days <= 30 retention
124
+ ```
125
+
126
+ Then WAIT for the user to pick which proposals to merge into
127
+ ``sponsio.yaml``. Don't auto-write. Onboarding ends when the
128
+ user tells you which ones land.
129
+
130
+ ## What you produce
131
+
132
+ A single YAML document — the new (or revised) `sponsio.yaml`.
133
+ Structure:
134
+
135
+ ```yaml
136
+ version: "1"
137
+ mode: observe
138
+ agents:
139
+ <agent_id>:
140
+ include:
141
+ - <pack from auto_selected_packs>
142
+ - ...
143
+ contracts:
144
+ - desc: "..."
145
+ G:
146
+ pattern: ...
147
+ args: [...]
148
+ A:
149
+ # optional — when conditional
150
+ pattern: ...
151
+ args: [...]
152
+ ```
153
+
154
+ ## Rules of thumb (apply in this order)
155
+
156
+ 1. **Pack first** — every pack in `auto_selected_packs` goes in
157
+ `include:`. Don't try to inline what the pack already covers;
158
+ redundant rules just clutter review.
159
+ 2. **Tool-specific contracts** — for each tool the inventory shows:
160
+ - **Destructive verbs** (`delete_*`, `remove_*`, `transfer_*`,
161
+ `force_*`) → `irreversible_once` if irreversible, otherwise
162
+ tight `rate_limit`.
163
+ - **Outbound side-effects** (`send_email`, `post_*`,
164
+ `create_*_comment`) → `rate_limit` 5–10 + `arg_blacklist` for
165
+ target identifiers if you can constrain them.
166
+ - **Path / URL params** → `arg_blacklist` for sensitive paths
167
+ (`\.env`, `\.aws/credentials`, `\.ssh/`) and internal hosts.
168
+ - **Read tools** → skip unless they touch credentials.
169
+ 3. **Policy doc** — if `policy_docs` is non-empty, lift specific
170
+ rules from them. Each one becomes a contract with
171
+ `source: policy`.
172
+ 4. **Existing YAML** — if `existing_yaml` is non-empty, **merge**:
173
+ keep all user-written contracts intact, add new ones for tools
174
+ that aren't covered. Never silently delete.
175
+
176
+ ## Pattern vocabulary
177
+
178
+ (Same as plugin scan — `arg_blacklist`, `arg_value_range`,
179
+ `arg_length_limit`, `rate_limit`, `loop_detection`,
180
+ `irreversible_once`, `must_precede`. See
181
+ ``sponsio plugin prompt mcp-bare`` for full signatures.)
182
+
183
+ ## Source tagging
184
+
185
+ Every contract YOU author should carry `source: agent-extracted` so
186
+ later tooling knows they were agent-generated. Don't tag
187
+ pack-included rules; those have their own source from the pack.
188
+
189
+ ## What to do after
190
+
191
+ You produce **two** edits, in this order:
192
+
193
+ ### 1. Write `sponsio.yaml`
194
+
195
+ Write the YAML you authored above to the path in `out_path` (default:
196
+ project root). Use the host's Edit/Write tool. If `existing_yaml`
197
+ was non-empty, merge — don't clobber.
198
+
199
+ ### 2. Patch the agent entry file
200
+
201
+ `wrap_snippet` shows the imports and guard construction. Your job is
202
+ to splice those into the actual entry file so Sponsio is wired into
203
+ the runtime, not just printed in the docs.
204
+
205
+ **Locate the entry file** (use `entry_file_candidates` if present in
206
+ the context — the CLI's deterministic scan flagged files that import
207
+ the framework). If absent, fall back to:
208
+
209
+ - Python: files that instantiate the framework's agent class
210
+ (e.g. `Agent(...)`, `LangGraph(...)`, `ClaudeAgent(...)`),
211
+ pointed at by `pyproject.toml`'s entry points or the project's
212
+ run script.
213
+ - TypeScript: files that call `generateText` / construct the
214
+ Anthropic / OpenAI client / build a LangChain ToolNode, pointed
215
+ at by `package.json`'s `main` / `bin` / `scripts.start`.
216
+
217
+ If multiple candidates remain after that filter, **stop and ask the
218
+ user** rather than guessing — picking wrong creates a duplicate
219
+ guard or a partial wire-up that's worse than nothing.
220
+
221
+ **Apply the wrap** (framework-specific):
222
+
223
+ - **Vercel AI SDK**: change every `model: <provider>("...")` site
224
+ to `model: wrapLanguageModel({ model: <provider>("..."),
225
+ middleware: sponsioMiddleware(guard) })`. Add the imports at the
226
+ top.
227
+ - **LangChain / LangGraph**: replace `tools` arrays passed to
228
+ `ToolNode` / `createReactAgent` with `wrapTools(tools, guard)`.
229
+ - **Claude Agent SDK / OpenAI Agents SDK**: wrap the underlying
230
+ client per the snippet.
231
+ - **Bare function-calling loop** (no framework): insert a guard
232
+ call before the tool executes and another after. The API is
233
+ `guard.guardBefore` / `guard.guardAfter` in TypeScript, or
234
+ `guard.guard_before` / `guard.guard_after` in Python — match
235
+ the host project's language. Show the user the diff before
236
+ applying — this path edits more lines.
237
+
238
+ **Always**: keep the original imports intact, add Sponsio's *above*
239
+ the agent entry's existing imports, and re-run the project's type
240
+ check / lint after edit.
241
+
242
+ ### 3. Hand off
243
+
244
+ Show the user a short summary: which contracts you wrote, which file
245
+ you patched (with line range), and the next command to run
246
+ (`sponsio doctor`, then their normal `npm test` / `pytest`).
@@ -0,0 +1,123 @@
1
+ # Contract authoring prompt — sponsio scan
2
+
3
+ You are a security engineer authoring contract entries for a
4
+ `sponsio.yaml`. The CLI has already done the deterministic work
5
+ (AST-based tool inventory, policy doc collection, trace summary).
6
+ Your job is the **semantic gap**: rules a name-heuristic can't see —
7
+ ordering invariants, exfil shapes, irreversible-once destructive
8
+ verbs, rate-limit ceilings, argument blacklists keyed to user intent.
9
+
10
+ ## Input
11
+
12
+ A JSON object from `sponsio scan <paths...> --emit-context`:
13
+
14
+ ```json
15
+ {
16
+ "agent_id": "agent",
17
+ "source_paths": ["src/"],
18
+ "tool_inventory": [
19
+ {"name": "...", "description": "...", "params": {...}, "source_file": "..."}
20
+ ],
21
+ "policy_docs": [
22
+ {"path": "security.md", "content": "..."}
23
+ ],
24
+ "trace_summary": {
25
+ "files": ["..."],
26
+ "total_events": 0
27
+ },
28
+ "existing_yaml": "<current sponsio.yaml content, or empty>",
29
+ "out_path": "sponsio.yaml"
30
+ }
31
+ ```
32
+
33
+ ## What you produce
34
+
35
+ YAML entries to merge into `out_path`'s `agents:<agent_id>:contracts:`
36
+ list. If `existing_yaml` is empty, produce a complete `sponsio.yaml`
37
+ including `version`, `agents`, `tools`, and `contracts`. If non-empty,
38
+ produce **only** the new contract entries — the user (or you, via
39
+ `Edit`) will splice them into the existing file.
40
+
41
+ Each entry is a mapping with `desc:` (one line, human-readable) and an
42
+ `G:` block holding either a `pattern:` reference (preferred) or a raw
43
+ `ltl:`.
44
+
45
+ ```yaml
46
+ - desc: "Block exfil-shape POSTs after env-leak commands"
47
+ A:
48
+ ltl: 'F(arg_field_has(Bash, command, "(printenv|export[ ]+-p)"))'
49
+ G:
50
+ ltl: 'G(!arg_field_has(Bash, command, "curl.*-d.*\\$\\(.*\\)"))'
51
+ source: "scan:bash_envleak_then_exfil"
52
+ ```
53
+
54
+ ## Pattern vocabulary
55
+
56
+ Use ONLY these patterns: `arg_blacklist`, `arg_value_range`,
57
+ `arg_length_limit`, `rate_limit`, `loop_detection`,
58
+ `irreversible_once`, `must_precede`, `must_follow`, `idempotent`,
59
+ `cooldown`. Run ``sponsio plugin prompt mcp-bare`` for the full
60
+ signatures + arg shapes if you need them.
61
+
62
+ ## How to think
63
+
64
+ Be conservative — false positives in observe mode are cheap, but flip
65
+ to enforce and they wedge the agent. For each tool in
66
+ `tool_inventory`:
67
+
68
+ **Destructive verbs** (`delete_*`, `remove_*`, `drop_*`, `transfer_*`,
69
+ `force_*`)
70
+ - Irreversible (e.g. `delete_repository`, `delete_volume`,
71
+ `drop_table`) → `irreversible_once`
72
+ - Recoverable (e.g. `archive_thread`, `disable_user`) → `rate_limit`
73
+ cap of 1–3 per session
74
+
75
+ **Outbound side-effects** (`send_email`, `post_*`, `publish_*`,
76
+ `create_issue_comment`, `notify_*`)
77
+ - `rate_limit` cap of 5–10 per session to prevent runaway loops
78
+ - `arg_blacklist` against target identifiers you can constrain
79
+ (allowed domains / repos / channels)
80
+
81
+ **Path / URL / repo params**
82
+ - `arg_blacklist` against patterns the user's environment shouldn't
83
+ touch — common ones:
84
+ - `\.env(\.|$)`, `\.aws/credentials`, `\.ssh/`, `\.gnupg/`
85
+ - `^/etc/(shadow|sudoers)`
86
+ - internal-network IPs: `^https?://(localhost|127\.|10\.|192\.168\.)`
87
+ - private/internal repo names visible in policy docs
88
+
89
+ **Shell / exec tools** (`Bash`, `Shell`, `exec`, `run_command`, …)
90
+ - Common deny patterns:
91
+ - `rm -rf /` / `rm -rf ~`
92
+ - `curl … | (bash|sh)` (curl-pipe-bash)
93
+ - `chmod 777 /` (broad permissions on root)
94
+ - destructive cloud-control-plane verbs: `curl -X DELETE` against
95
+ `api.<provider>.com`, provider CLIs' `delete` / `destroy` / `down`
96
+ subcommands
97
+
98
+ **Read tools**
99
+ - Skip unless they touch credential paths. Adding rules to every
100
+ read clutters review without much upside.
101
+
102
+ ## Cross-references to weight in
103
+
104
+ - **`policy_docs`**: the user has explicitly written down constraints
105
+ here — take them seriously. A policy doc saying "no destructive
106
+ Railway calls without confirmation" should produce a concrete
107
+ arg_blacklist + irreversible_once pair.
108
+ - Prefer single-event patterns (`arg_blacklist`, `rate_limit`,
109
+ `irreversible_once`) unless the code clearly establishes a required
110
+ ordering; only then reach for sequence-shaped rules.
111
+ - **`existing_yaml`**: don't duplicate rules already there. Read its
112
+ contracts, only emit gaps.
113
+
114
+ ## Output discipline
115
+
116
+ - Stay inside the published pattern vocabulary. If a constraint
117
+ doesn't fit one of those patterns, **describe** it as a `desc:`
118
+ comment and skip the `G:` block — better to flag the gap for human
119
+ review than to invent a pattern that won't compile.
120
+ - Each rule cites its source under `source:` using the convention
121
+ `scan:<short-id>` so reviewers can trace the rule back.
122
+ - After writing, run `sponsio validate --config <out_path>` and fix
123
+ any compilation errors before declaring done.