@intentic/sandbox-contract 1.316.0 → 1.318.0

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 (362) hide show
  1. package/README.md +12 -4
  2. package/dist/chores/chores.js +1 -1
  3. package/dist/chores/chores.js.map +1 -1
  4. package/dist/chores/probes.js +1 -1
  5. package/dist/chores/probes.js.map +1 -1
  6. package/dist/contracts/accounts.contract.d.ts +75 -0
  7. package/dist/contracts/accounts.contract.d.ts.map +1 -1
  8. package/dist/contracts/accounts.contract.js +10 -1
  9. package/dist/contracts/accounts.contract.js.map +1 -1
  10. package/dist/contracts/agent.contract.d.ts +616 -1
  11. package/dist/contracts/agent.contract.d.ts.map +1 -1
  12. package/dist/contracts/agents.contract.d.ts +1134 -29
  13. package/dist/contracts/agents.contract.d.ts.map +1 -1
  14. package/dist/contracts/agents.contract.js +12 -12
  15. package/dist/contracts/agents.contract.js.map +1 -1
  16. package/dist/contracts/capabilities.contract.d.ts +16 -0
  17. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  18. package/dist/contracts/capabilities.contract.js +10 -1
  19. package/dist/contracts/capabilities.contract.js.map +1 -1
  20. package/dist/contracts/ci.contract.d.ts +22 -4
  21. package/dist/contracts/ci.contract.d.ts.map +1 -1
  22. package/dist/contracts/device.contract.d.ts +39 -0
  23. package/dist/contracts/device.contract.d.ts.map +1 -1
  24. package/dist/contracts/device.contract.js +2 -0
  25. package/dist/contracts/device.contract.js.map +1 -1
  26. package/dist/contracts/endpoints.contract.d.ts +23 -0
  27. package/dist/contracts/endpoints.contract.d.ts.map +1 -1
  28. package/dist/contracts/endpoints.contract.js +6 -1
  29. package/dist/contracts/endpoints.contract.js.map +1 -1
  30. package/dist/contracts/extensions.contract.d.ts +12 -0
  31. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  32. package/dist/contracts/needs.contract.d.ts +534 -0
  33. package/dist/contracts/needs.contract.d.ts.map +1 -0
  34. package/dist/contracts/needs.contract.js +80 -0
  35. package/dist/contracts/needs.contract.js.map +1 -0
  36. package/dist/contracts/providers.contract.d.ts +4 -0
  37. package/dist/contracts/providers.contract.d.ts.map +1 -1
  38. package/dist/contracts/runner.contract.d.ts +193 -2
  39. package/dist/contracts/runner.contract.d.ts.map +1 -1
  40. package/dist/contracts/secrets.contract.d.ts +53 -0
  41. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  42. package/dist/contracts/secrets.contract.js +31 -2
  43. package/dist/contracts/secrets.contract.js.map +1 -1
  44. package/dist/contracts/sessions.contract.d.ts +83 -0
  45. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  46. package/dist/contracts/settings.contract.d.ts +33 -2
  47. package/dist/contracts/settings.contract.d.ts.map +1 -1
  48. package/dist/contracts/settings.contract.js +20 -1
  49. package/dist/contracts/settings.contract.js.map +1 -1
  50. package/dist/contracts/system.contract.d.ts +177 -356
  51. package/dist/contracts/system.contract.d.ts.map +1 -1
  52. package/dist/contracts/system.contract.js +13 -12
  53. package/dist/contracts/system.contract.js.map +1 -1
  54. package/dist/contracts/translator.contract.d.ts +7 -0
  55. package/dist/contracts/translator.contract.d.ts.map +1 -1
  56. package/dist/contracts/translator.contract.js.map +1 -1
  57. package/dist/contracts/webext.contract.d.ts +38 -0
  58. package/dist/contracts/webext.contract.d.ts.map +1 -1
  59. package/dist/contracts/webext.contract.js +3 -0
  60. package/dist/contracts/webext.contract.js.map +1 -1
  61. package/dist/contracts/workspace.contract.d.ts +1 -80
  62. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  63. package/dist/contracts/workspace.contract.js +0 -27
  64. package/dist/contracts/workspace.contract.js.map +1 -1
  65. package/dist/events/agent-events.d.ts +330 -0
  66. package/dist/events/agent-events.d.ts.map +1 -1
  67. package/dist/events/agent-events.js +13 -0
  68. package/dist/events/agent-events.js.map +1 -1
  69. package/dist/events/agent-words.d.ts +1 -0
  70. package/dist/events/agent-words.d.ts.map +1 -1
  71. package/dist/events/agent-words.js +3 -2
  72. package/dist/events/agent-words.js.map +1 -1
  73. package/dist/events/land-breakage.d.ts.map +1 -1
  74. package/dist/events/land-breakage.js.map +1 -1
  75. package/dist/events/need-wake.d.ts +17 -0
  76. package/dist/events/need-wake.d.ts.map +1 -0
  77. package/dist/events/need-wake.js +34 -0
  78. package/dist/events/need-wake.js.map +1 -0
  79. package/dist/events/resume.d.ts +6 -1
  80. package/dist/events/resume.d.ts.map +1 -1
  81. package/dist/events/resume.js +17 -10
  82. package/dist/events/resume.js.map +1 -1
  83. package/dist/events/sandbox-notice.d.ts +183 -0
  84. package/dist/events/sandbox-notice.d.ts.map +1 -0
  85. package/dist/events/sandbox-notice.js +56 -0
  86. package/dist/events/sandbox-notice.js.map +1 -0
  87. package/dist/events/system-events.d.ts +84 -0
  88. package/dist/events/system-events.d.ts.map +1 -1
  89. package/dist/events/system-events.js +2 -0
  90. package/dist/events/system-events.js.map +1 -1
  91. package/dist/events/transcript.d.ts +508 -0
  92. package/dist/events/transcript.d.ts.map +1 -1
  93. package/dist/events/transcript.js +12 -1
  94. package/dist/events/transcript.js.map +1 -1
  95. package/dist/ids/conversation-ids.d.ts +1 -3
  96. package/dist/ids/conversation-ids.d.ts.map +1 -1
  97. package/dist/ids/conversation-ids.js +1 -3
  98. package/dist/ids/conversation-ids.js.map +1 -1
  99. package/dist/ids/project-dir.d.ts +6 -0
  100. package/dist/ids/project-dir.d.ts.map +1 -0
  101. package/dist/ids/project-dir.js +43 -0
  102. package/dist/ids/project-dir.js.map +1 -0
  103. package/dist/index.d.ts +3474 -1163
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +13 -4
  106. package/dist/index.js.map +1 -1
  107. package/dist/models/agent-runtimes.d.ts.map +1 -1
  108. package/dist/models/agent-runtimes.js +2 -2
  109. package/dist/models/agent-runtimes.js.map +1 -1
  110. package/dist/models/model-roles.d.ts +1 -9
  111. package/dist/models/model-roles.d.ts.map +1 -1
  112. package/dist/models/model-roles.js +1 -9
  113. package/dist/models/model-roles.js.map +1 -1
  114. package/dist/policy/command-classes.d.ts.map +1 -1
  115. package/dist/policy/command-classes.js +52 -3
  116. package/dist/policy/command-classes.js.map +1 -1
  117. package/dist/policy/safety-policy.d.ts +7 -1
  118. package/dist/policy/safety-policy.d.ts.map +1 -1
  119. package/dist/policy/safety-policy.js +2 -0
  120. package/dist/policy/safety-policy.js.map +1 -1
  121. package/dist/policy/secret-hosts.d.ts +13 -0
  122. package/dist/policy/secret-hosts.d.ts.map +1 -0
  123. package/dist/policy/secret-hosts.js +41 -0
  124. package/dist/policy/secret-hosts.js.map +1 -0
  125. package/dist/policy/turned-away.d.ts.map +1 -1
  126. package/dist/policy/turned-away.js +1 -0
  127. package/dist/policy/turned-away.js.map +1 -1
  128. package/dist/protocol/raw-routes.d.ts +7 -5
  129. package/dist/protocol/raw-routes.d.ts.map +1 -1
  130. package/dist/protocol/raw-routes.js +4 -1
  131. package/dist/protocol/raw-routes.js.map +1 -1
  132. package/dist/protocol/routes.d.ts +2 -6
  133. package/dist/protocol/routes.d.ts.map +1 -1
  134. package/dist/protocol/routes.js +2 -3
  135. package/dist/protocol/routes.js.map +1 -1
  136. package/dist/protocol/stream-of.d.ts +6 -0
  137. package/dist/protocol/stream-of.d.ts.map +1 -0
  138. package/dist/protocol/stream-of.js +4 -0
  139. package/dist/protocol/stream-of.js.map +1 -0
  140. package/dist/schemas/activity.js +1 -1
  141. package/dist/schemas/activity.js.map +1 -1
  142. package/dist/schemas/agent.d.ts +19 -2
  143. package/dist/schemas/agent.d.ts.map +1 -1
  144. package/dist/schemas/agent.js +2 -1
  145. package/dist/schemas/agent.js.map +1 -1
  146. package/dist/schemas/agents.d.ts +119 -0
  147. package/dist/schemas/agents.d.ts.map +1 -1
  148. package/dist/schemas/agents.js +45 -0
  149. package/dist/schemas/agents.js.map +1 -1
  150. package/dist/schemas/automations.d.ts +37 -0
  151. package/dist/schemas/automations.d.ts.map +1 -1
  152. package/dist/schemas/capabilities.d.ts +21 -0
  153. package/dist/schemas/capabilities.d.ts.map +1 -1
  154. package/dist/schemas/capabilities.js +50 -4
  155. package/dist/schemas/capabilities.js.map +1 -1
  156. package/dist/schemas/ci.d.ts +69 -9
  157. package/dist/schemas/ci.d.ts.map +1 -1
  158. package/dist/schemas/ci.js +29 -8
  159. package/dist/schemas/ci.js.map +1 -1
  160. package/dist/schemas/context-trim.d.ts +5 -1
  161. package/dist/schemas/context-trim.d.ts.map +1 -1
  162. package/dist/schemas/context-trim.js +8 -4
  163. package/dist/schemas/context-trim.js.map +1 -1
  164. package/dist/schemas/devices.d.ts +91 -0
  165. package/dist/schemas/devices.d.ts.map +1 -1
  166. package/dist/schemas/devices.js +23 -1
  167. package/dist/schemas/devices.js.map +1 -1
  168. package/dist/schemas/environment.d.ts +48 -0
  169. package/dist/schemas/environment.d.ts.map +1 -1
  170. package/dist/schemas/environment.js +15 -0
  171. package/dist/schemas/environment.js.map +1 -1
  172. package/dist/schemas/extension-updates.d.ts +24 -0
  173. package/dist/schemas/extension-updates.d.ts.map +1 -1
  174. package/dist/schemas/git/git.d.ts +13 -0
  175. package/dist/schemas/git/git.d.ts.map +1 -1
  176. package/dist/schemas/git/git.js +11 -1
  177. package/dist/schemas/git/git.js.map +1 -1
  178. package/dist/schemas/hosts.d.ts +4 -0
  179. package/dist/schemas/hosts.d.ts.map +1 -1
  180. package/dist/schemas/hosts.js +3 -1
  181. package/dist/schemas/hosts.js.map +1 -1
  182. package/dist/schemas/keep-warm.d.ts +4 -0
  183. package/dist/schemas/keep-warm.d.ts.map +1 -1
  184. package/dist/schemas/keep-warm.js +15 -5
  185. package/dist/schemas/keep-warm.js.map +1 -1
  186. package/dist/schemas/loopback-catch.d.ts +33 -0
  187. package/dist/schemas/loopback-catch.d.ts.map +1 -0
  188. package/dist/schemas/loopback-catch.js +20 -0
  189. package/dist/schemas/loopback-catch.js.map +1 -0
  190. package/dist/schemas/maintenance.js +1 -1
  191. package/dist/schemas/maintenance.js.map +1 -1
  192. package/dist/schemas/needs.d.ts +664 -0
  193. package/dist/schemas/needs.d.ts.map +1 -0
  194. package/dist/schemas/needs.js +203 -0
  195. package/dist/schemas/needs.js.map +1 -0
  196. package/dist/schemas/personas.d.ts.map +1 -1
  197. package/dist/schemas/personas.js +6 -3
  198. package/dist/schemas/personas.js.map +1 -1
  199. package/dist/schemas/providers/provider-oauth.d.ts +87 -0
  200. package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
  201. package/dist/schemas/providers/provider-oauth.js +20 -0
  202. package/dist/schemas/providers/provider-oauth.js.map +1 -1
  203. package/dist/schemas/secrets.d.ts +84 -0
  204. package/dist/schemas/secrets.d.ts.map +1 -1
  205. package/dist/schemas/secrets.js +70 -0
  206. package/dist/schemas/secrets.js.map +1 -1
  207. package/dist/schemas/settings-history.d.ts +1 -1
  208. package/dist/schemas/settings-history.d.ts.map +1 -1
  209. package/dist/schemas/settings-history.js +1 -0
  210. package/dist/schemas/settings-history.js.map +1 -1
  211. package/dist/schemas/settings.d.ts +44 -2
  212. package/dist/schemas/settings.d.ts.map +1 -1
  213. package/dist/schemas/settings.js +30 -4
  214. package/dist/schemas/settings.js.map +1 -1
  215. package/dist/schemas/state-plan.d.ts +1 -0
  216. package/dist/schemas/state-plan.d.ts.map +1 -1
  217. package/dist/schemas/state-plan.js +3 -1
  218. package/dist/schemas/state-plan.js.map +1 -1
  219. package/dist/schemas/system.d.ts +20 -0
  220. package/dist/schemas/system.d.ts.map +1 -1
  221. package/dist/schemas/system.js +7 -0
  222. package/dist/schemas/system.js.map +1 -1
  223. package/dist/schemas/terminal.d.ts +2 -3
  224. package/dist/schemas/terminal.d.ts.map +1 -1
  225. package/dist/schemas/terminal.js +12 -4
  226. package/dist/schemas/terminal.js.map +1 -1
  227. package/dist/schemas/updates.d.ts +39 -0
  228. package/dist/schemas/updates.d.ts.map +1 -0
  229. package/dist/schemas/updates.js +31 -0
  230. package/dist/schemas/updates.js.map +1 -0
  231. package/dist/schemas/webext.d.ts +3 -0
  232. package/dist/schemas/webext.d.ts.map +1 -1
  233. package/dist/schemas/webext.js +1 -0
  234. package/dist/schemas/webext.js.map +1 -1
  235. package/dist/schemas/workflows.js +3 -3
  236. package/dist/schemas/workflows.js.map +1 -1
  237. package/dist/schemas/workspace/workspace-tree.d.ts +2 -0
  238. package/dist/schemas/workspace/workspace-tree.d.ts.map +1 -1
  239. package/dist/schemas/workspace/workspace-tree.js +4 -0
  240. package/dist/schemas/workspace/workspace-tree.js.map +1 -1
  241. package/dist/state/definition.d.ts +28 -4
  242. package/dist/state/definition.d.ts.map +1 -1
  243. package/dist/state/history-state.d.ts.map +1 -1
  244. package/dist/state/history-state.js +10 -0
  245. package/dist/state/history-state.js.map +1 -1
  246. package/dist/state/runtime-state.d.ts +0 -3
  247. package/dist/state/runtime-state.d.ts.map +1 -1
  248. package/dist/state/runtime-state.js +0 -1
  249. package/dist/state/runtime-state.js.map +1 -1
  250. package/dist/state/workspace-state.d.ts +4 -5
  251. package/dist/state/workspace-state.d.ts.map +1 -1
  252. package/dist/state/workspace-state.js +1 -6
  253. package/dist/state/workspace-state.js.map +1 -1
  254. package/dist/text/documents.d.ts +3 -0
  255. package/dist/text/documents.d.ts.map +1 -1
  256. package/dist/text/documents.js +14 -0
  257. package/dist/text/documents.js.map +1 -1
  258. package/dist/text/transcript-fold.d.ts +4 -3
  259. package/dist/text/transcript-fold.d.ts.map +1 -1
  260. package/dist/text/transcript-fold.js +140 -31
  261. package/dist/text/transcript-fold.js.map +1 -1
  262. package/dist/webext/index.d.ts +1 -0
  263. package/dist/webext/index.d.ts.map +1 -1
  264. package/dist/webext/index.js +1 -0
  265. package/dist/webext/index.js.map +1 -1
  266. package/package.json +5 -5
  267. package/src/chores/chores.ts +2 -2
  268. package/src/chores/probes.ts +1 -1
  269. package/src/contracts/accounts.contract.ts +12 -0
  270. package/src/contracts/agents.contract.ts +13 -13
  271. package/src/contracts/capabilities.contract.ts +14 -1
  272. package/src/contracts/device.contract.ts +5 -0
  273. package/src/contracts/endpoints.contract.ts +20 -4
  274. package/src/contracts/needs.contract.ts +103 -0
  275. package/src/contracts/secrets.contract.ts +45 -3
  276. package/src/contracts/settings.contract.ts +29 -0
  277. package/src/contracts/system.contract.ts +19 -14
  278. package/src/contracts/translator.contract.ts +2 -1
  279. package/src/contracts/webext.contract.ts +7 -1
  280. package/src/contracts/workspace.contract.ts +0 -37
  281. package/src/events/agent-events.ts +22 -1
  282. package/src/events/agent-words.ts +6 -2
  283. package/src/events/land-breakage.ts +3 -4
  284. package/src/events/need-wake.test.ts +55 -0
  285. package/src/events/need-wake.ts +71 -0
  286. package/src/events/resume.test.ts +13 -2
  287. package/src/events/resume.ts +25 -12
  288. package/src/events/sandbox-notice.ts +92 -0
  289. package/src/events/system-events.ts +7 -0
  290. package/src/events/transcript.ts +23 -1
  291. package/src/events/verify-nudge.ts +3 -3
  292. package/src/ids/conversation-ids.test.ts +2 -26
  293. package/src/ids/conversation-ids.ts +6 -12
  294. package/src/ids/project-dir.fixture.json +65 -0
  295. package/src/ids/project-dir.test.ts +60 -0
  296. package/src/ids/project-dir.ts +70 -0
  297. package/src/index.ts +18 -4
  298. package/src/models/agent-catalog.test.ts +7 -1
  299. package/src/models/agent-runtimes.ts +7 -5
  300. package/src/models/model-roles.ts +1 -9
  301. package/src/policy/command-classes.test.ts +39 -0
  302. package/src/policy/command-classes.ts +70 -3
  303. package/src/policy/safety-policy.ts +10 -0
  304. package/src/policy/secret-hosts.test.ts +89 -0
  305. package/src/policy/secret-hosts.ts +73 -0
  306. package/src/policy/turned-away.ts +1 -0
  307. package/src/protocol/raw-routes.ts +6 -3
  308. package/src/protocol/routes.test.ts +6 -6
  309. package/src/protocol/routes.ts +2 -9
  310. package/src/protocol/stream-of.ts +13 -0
  311. package/src/schemas/activity.ts +1 -1
  312. package/src/schemas/agent.ts +4 -1
  313. package/src/schemas/agents.ts +72 -5
  314. package/src/schemas/automations.ts +2 -2
  315. package/src/schemas/capabilities.ts +72 -7
  316. package/src/schemas/ci.ts +56 -11
  317. package/src/schemas/context-trim.ts +11 -6
  318. package/src/schemas/devices.ts +55 -2
  319. package/src/schemas/environment.ts +39 -0
  320. package/src/schemas/git/git.ts +20 -2
  321. package/src/schemas/hosts.ts +7 -1
  322. package/src/schemas/keep-warm.ts +19 -6
  323. package/src/schemas/loopback-catch.ts +45 -0
  324. package/src/schemas/maintenance.ts +1 -1
  325. package/src/schemas/needs.ts +301 -0
  326. package/src/schemas/personas.ts +8 -3
  327. package/src/schemas/providers/provider-oauth.ts +35 -0
  328. package/src/schemas/secrets.ts +93 -0
  329. package/src/schemas/settings-history.ts +2 -0
  330. package/src/schemas/settings.test.ts +19 -1
  331. package/src/schemas/settings.ts +66 -9
  332. package/src/schemas/speaker.ts +5 -5
  333. package/src/schemas/state-plan.ts +8 -1
  334. package/src/schemas/system.ts +15 -0
  335. package/src/schemas/terminal.ts +19 -6
  336. package/src/schemas/updates.ts +56 -0
  337. package/src/schemas/webext.ts +3 -0
  338. package/src/schemas/workflows.ts +5 -5
  339. package/src/schemas/workspace/workspace-tree.ts +7 -0
  340. package/src/state/fix-attempt-plan.test.ts +1 -1
  341. package/src/state/fix-stance.ts +1 -1
  342. package/src/state/history-state.ts +19 -0
  343. package/src/state/runtime-state.ts +0 -3
  344. package/src/state/workspace-state.ts +4 -6
  345. package/src/text/documents.test.ts +25 -1
  346. package/src/text/documents.ts +24 -0
  347. package/src/text/title.ts +1 -1
  348. package/src/text/transcript-fold.test.ts +218 -25
  349. package/src/text/transcript-fold.ts +170 -45
  350. package/src/webext/index.ts +1 -0
  351. package/dist/schemas/workspace/push-checks.d.ts +0 -222
  352. package/dist/schemas/workspace/push-checks.d.ts.map +0 -1
  353. package/dist/schemas/workspace/push-checks.js +0 -97
  354. package/dist/schemas/workspace/push-checks.js.map +0 -1
  355. package/dist/state/red-streak.d.ts +0 -7
  356. package/dist/state/red-streak.d.ts.map +0 -1
  357. package/dist/state/red-streak.js +0 -11
  358. package/dist/state/red-streak.js.map +0 -1
  359. package/src/schemas/workspace/push-checks.test.ts +0 -28
  360. package/src/schemas/workspace/push-checks.ts +0 -155
  361. package/src/state/red-streak.test.ts +0 -28
  362. package/src/state/red-streak.ts +0 -28
@@ -0,0 +1,60 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { MEMORY_FILE, PUBLIC_DIR, REFERENCE_DIR, WORKSPACE_ROOT } from "@intentic/constants";
3
+ import { STARTER_REPO } from "../state/starter.js";
4
+ import { isProjectDirName, projectDirNameFor, projectDirNameOf, projectRemoteDir, RESERVED_PROJECT_DIR_NAMES } from "./project-dir.js";
5
+
6
+ // The cases `ic` is held to as well (_sandbox/ic/src/sandbox/project_dir.rs), read from the one file both run.
7
+ interface ProjectDirCases {
8
+ readonly names: readonly { readonly name: string; readonly valid: boolean }[];
9
+ readonly folders: readonly { readonly folder: string; readonly dirName: string }[];
10
+ }
11
+ // SAFETY: the fixture is this repository's own file, written to this shape; one that drifted fails every case below.
12
+ const CASES = JSON.parse(readFileSync(new URL("./project-dir.fixture.json", import.meta.url), "utf8")) as ProjectDirCases;
13
+
14
+ test.each([...CASES.names])("the shared name case $name is valid: $valid", ({ name, valid }) => {
15
+ expect(isProjectDirName(name)).toBe(valid);
16
+ });
17
+
18
+ test.each([...CASES.folders])("the folder $folder syncs into $dirName", ({ folder, dirName }) => {
19
+ expect(projectDirNameFor(folder)).toBe(dirName);
20
+ });
21
+
22
+ test("every folder name the slug produces is one the validation accepts, and slugging it again changes nothing", () => {
23
+ for (const { folder } of CASES.folders) {
24
+ const name = projectDirNameFor(folder);
25
+ expect(isProjectDirName(name)).toBe(true);
26
+ expect(projectDirNameFor(name)).toBe(name);
27
+ }
28
+ });
29
+
30
+ test("the reserved names are the ones the daemon keeps at the workspace root", () => {
31
+ expect([...RESERVED_PROJECT_DIR_NAMES].toSorted()).toEqual(
32
+ [
33
+ PUBLIC_DIR,
34
+ REFERENCE_DIR,
35
+ STARTER_REPO,
36
+ MEMORY_FILE,
37
+ "root",
38
+ "intent",
39
+ "desired-state",
40
+ "app",
41
+ "node_modules",
42
+ "dist",
43
+ "venv",
44
+ "claude.json",
45
+ ].toSorted(),
46
+ );
47
+ });
48
+
49
+ test("a project dir is exactly one valid name under the workspace root", () => {
50
+ expect(projectRemoteDir("my-app")).toBe(`${WORKSPACE_ROOT}/my-app`);
51
+ expect(projectDirNameOf(`${WORKSPACE_ROOT}/my-app`)).toBe("my-app");
52
+ expect(projectDirNameOf(WORKSPACE_ROOT)).toBeUndefined();
53
+ expect(projectDirNameOf(`${WORKSPACE_ROOT}/`)).toBeUndefined();
54
+ expect(projectDirNameOf(`${WORKSPACE_ROOT}/my-app/`)).toBeUndefined();
55
+ expect(projectDirNameOf(`${WORKSPACE_ROOT}/my-app/src`)).toBeUndefined();
56
+ expect(projectDirNameOf(`${WORKSPACE_ROOT}/public`)).toBeUndefined();
57
+ expect(projectDirNameOf(`${WORKSPACE_ROOT}/../etc`)).toBeUndefined();
58
+ expect(projectDirNameOf("/workspace/my-app")).toBeUndefined();
59
+ expect(projectDirNameOf("/srv/work/my-app", "/srv/work")).toBe("my-app");
60
+ });
@@ -0,0 +1,70 @@
1
+ import { MEMORY_FILE, PUBLIC_DIR, REFERENCE_DIR, WORKSPACE_ROOT } from "@intentic/constants";
2
+ import { STARTER_REPO } from "../state/starter.js";
3
+
4
+ // A PROJECT SANDBOX is made for one folder on the owner's computer, synced live into `/work/<name>` rather than into
5
+ // /work itself: the workspace root is the daemon's own, where it keeps its state, seeds its starter repo and serves
6
+ // `public/` to anyone with a link. `<name>` is derived from the folder's name once, on the owner's side, and every
7
+ // later reader (the sync agent, `ic`, the daemon) only validates it. `_sandbox/ic/src/sandbox/project_dir.rs` holds the
8
+ // validation again for the host side; `project-dir.fixture.json` is the one set of cases both run.
9
+
10
+ // Top-level names the daemon treats as its own, so a project can never land on one: the public outbox, the reference
11
+ // shelf, the starter repo seeded on first boot, the root repo's id and the three repo roles repo discovery refuses
12
+ // (`_sandbox/sandbox/src/workspace/layout/repo-discovery.ts`), and the standing-instructions file it writes. Then the
13
+ // names every walk of the workspace skips at any depth (@intentic/workspace-ignore IGNORED_DIRS, and the private file
14
+ // the git scopes leave out), where a project would sync and never be seen; the daemon's tests hold this list to that
15
+ // one. Everything else of either kind starts with a dot (`.intentic`, `.venv`), which the name rule below refuses.
16
+ export const RESERVED_PROJECT_DIR_NAMES: readonly string[] = [
17
+ PUBLIC_DIR,
18
+ REFERENCE_DIR,
19
+ STARTER_REPO,
20
+ "root",
21
+ "intent",
22
+ "desired-state",
23
+ "app",
24
+ MEMORY_FILE,
25
+ "node_modules",
26
+ "dist",
27
+ "venv",
28
+ "claude.json",
29
+ ];
30
+
31
+ // Starts alphanumeric, so no dot-file and no leading dash an argv could read as a flag; no separator, so it is always
32
+ // one path segment; bounded, since it also names a git dir and a folder in every view of the workspace.
33
+ const PROJECT_DIR_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
34
+ const PROJECT_DIR_NAME_MAX = 64;
35
+
36
+ // Used when nothing of the folder's name survives the slug (a name in another script, or only punctuation).
37
+ const FALLBACK_NAME = "project";
38
+
39
+ // Combining marks, which NFKD splits off an accented letter.
40
+ const COMBINING_MARKS = /[\u0300-\u036f]/g;
41
+
42
+ export const isProjectDirName = (name: string): boolean => PROJECT_DIR_NAME.test(name) && !RESERVED_PROJECT_DIR_NAMES.includes(name);
43
+
44
+ // The workspace-relative name for a folder the owner picked, always one `isProjectDirName` accepts. Accents are folded
45
+ // to their base letter first, so `Café` keeps its `e` rather than losing it to a dash.
46
+ export const projectDirNameFor = (folderBasename: string): string => {
47
+ const slug = folderBasename
48
+ .normalize("NFKD")
49
+ .replace(COMBINING_MARKS, "")
50
+ .replace(/[^A-Za-z0-9._-]+/g, "-")
51
+ .replace(/-{2,}/g, "-")
52
+ .replace(/^[._-]+/, "")
53
+ .slice(0, PROJECT_DIR_NAME_MAX)
54
+ .replace(/[.-]+$/, "");
55
+ const name = slug === "" ? FALLBACK_NAME : slug;
56
+ return RESERVED_PROJECT_DIR_NAMES.includes(name) ? `${name}-project` : name;
57
+ };
58
+
59
+ // Where a project folder lands in the sandbox, and the name back out of such a path: exactly `<root>/<name>`, anything
60
+ // else (a deeper path, a trailing slash, a reserved name) is not a project dir.
61
+ export const projectRemoteDir = (name: string): string => `${WORKSPACE_ROOT}/${name}`;
62
+
63
+ export const projectDirNameOf = (remoteDir: string, root: string = WORKSPACE_ROOT): string | undefined => {
64
+ const prefix = `${root}/`;
65
+ if (!remoteDir.startsWith(prefix)) {
66
+ return undefined;
67
+ }
68
+ const name = remoteDir.slice(prefix.length);
69
+ return isProjectDirName(name) ? name : undefined;
70
+ };
package/src/index.ts CHANGED
@@ -32,6 +32,7 @@ import { netdiskContract } from "./contracts/netdisk.contract.js";
32
32
  import { providersContract } from "./contracts/providers.contract.js";
33
33
  import { pushContract } from "./contracts/push.contract.js";
34
34
  import { safetyContract } from "./contracts/safety.contract.js";
35
+ import { needsContract } from "./contracts/needs.contract.js";
35
36
  import { secretsContract } from "./contracts/secrets.contract.js";
36
37
  import { sessionsContract } from "./contracts/sessions.contract.js";
37
38
  import { settingsContract } from "./contracts/settings.contract.js";
@@ -57,6 +58,8 @@ export { choresContract } from "./contracts/chores.contract.js";
57
58
  export { ciContract } from "./contracts/ci.contract.js";
58
59
  export {
59
60
  endpointsContract,
61
+ type LocalModelDevice,
62
+ LocalModelDeviceSchema,
60
63
  LocalModelFitSchema,
61
64
  type LocalModelFitResponse,
62
65
  type LocalModelGpu,
@@ -92,6 +95,7 @@ export { publicContract } from "./contracts/public.contract.js";
92
95
  export { providersContract, type RunnableProviders, RunnableProvidersSchema } from "./contracts/providers.contract.js";
93
96
  export { pushContract } from "./contracts/push.contract.js";
94
97
  export { safetyContract } from "./contracts/safety.contract.js";
98
+ export { needsContract } from "./contracts/needs.contract.js";
95
99
  export { secretsContract } from "./contracts/secrets.contract.js";
96
100
  export { sessionsContract } from "./contracts/sessions.contract.js";
97
101
  export { settingsContract } from "./contracts/settings.contract.js";
@@ -109,12 +113,14 @@ export * from "./events/agent-events.js";
109
113
  export * from "./events/agent-words.js";
110
114
  export * from "./events/requests.js";
111
115
  export * from "./events/resume.js";
116
+ export * from "./events/sandbox-notice.js";
112
117
  export * from "./events/system-events.js";
113
118
  export * from "./events/transcript.js";
114
119
  export * from "./events/land-breakage.js";
115
120
  export * from "./events/land-conflict.js";
116
121
  export * from "./events/verify-nudge.js";
117
122
  export * from "./events/errands.js";
123
+ export * from "./events/need-wake.js";
118
124
  export * from "./events/watch-wake.js";
119
125
  export * from "./policy/request-status.js";
120
126
  export * from "./events/child-run.js";
@@ -136,7 +142,6 @@ export * from "./state/history-state.js";
136
142
  export * from "./state/fix-stance.js";
137
143
  export * from "./state/landed-commit.js";
138
144
  export * from "./state/fix-attempt-plan.js";
139
- export * from "./state/red-streak.js";
140
145
  // Provider vocabulary bottom-up: agent-runtimes, provider-specs, agent-catalog; three modules since the dependency
141
146
  // points one way.
142
147
  export * from "./models/agent-runtimes.js";
@@ -149,6 +154,7 @@ export * from "./policy/safety-policy.js";
149
154
  export * from "./policy/reserved-servers.js";
150
155
  export * from "./policy/credential-material.js";
151
156
  export * from "./policy/capability-secrets.js";
157
+ export * from "./policy/secret-hosts.js";
152
158
  export * from "./ids/conversation-ids.js";
153
159
  export * from "./text/documents.js";
154
160
  export * from "./protocol/host-protocol.js";
@@ -158,6 +164,7 @@ export * from "./protocol/runner-protocol.js";
158
164
  export * from "./protocol/listener-protocol.js";
159
165
  export * from "./protocol/container-requirements.js";
160
166
  export * from "./ids/hostnames.js";
167
+ export * from "./ids/project-dir.js";
161
168
  export * from "./policy/overlay-lint.js";
162
169
  export * from "./models/model-label.js";
163
170
  export * from "./models/model-order.js";
@@ -197,6 +204,7 @@ export * from "./schemas/git/git.js";
197
204
  export * from "./schemas/git/git-history.js";
198
205
  export * from "./schemas/history.js";
199
206
  export * from "./schemas/hosts.js";
207
+ export * from "./schemas/loopback-catch.js";
200
208
  export * from "./schemas/intentic.js";
201
209
  export * from "./schemas/inventory.js";
202
210
  export * from "./schemas/issues.js";
@@ -214,6 +222,7 @@ export * from "./schemas/providers/provider-subscriptions.js";
214
222
  export * from "./schemas/public.js";
215
223
  export * from "./schemas/push.js";
216
224
  export * from "./schemas/git/remote-refs.js";
225
+ export * from "./schemas/needs.js";
217
226
  export * from "./schemas/secrets.js";
218
227
  export * from "./schemas/netdisk.js";
219
228
  export * from "./schemas/sessions.js";
@@ -224,6 +233,7 @@ export * from "./schemas/shared.js";
224
233
  export * from "./schemas/system-prompt.js";
225
234
  export * from "./schemas/system.js";
226
235
  export * from "./schemas/state-plan.js";
236
+ export * from "./schemas/updates.js";
227
237
  export * from "./schemas/terminal.js";
228
238
  export * from "./schemas/turn-break.js";
229
239
  export * from "./schemas/keep-warm.js";
@@ -234,7 +244,6 @@ export * from "./schemas/webext.js";
234
244
  export * from "./schemas/workflows.js";
235
245
  export * from "./schemas/workspace/workspace-repos.js";
236
246
  export * from "./schemas/workspace/workspace-search.js";
237
- export * from "./schemas/workspace/push-checks.js";
238
247
  export * from "./schemas/workspace/workspace-setup.js";
239
248
  export * from "./schemas/workspace/workspace-tree.js";
240
249
  export * from "./state/arrival.js";
@@ -285,6 +294,7 @@ export const sandboxContract = {
285
294
  public: publicContract,
286
295
  providers: providersContract,
287
296
  push: pushContract,
297
+ needs: needsContract,
288
298
  secrets: secretsContract,
289
299
  system: systemContract,
290
300
  translator: translatorContract,
@@ -302,8 +312,12 @@ export const SANDBOX_ROUTES: readonly ContractRoute[] = contractRoutes(sandboxCo
302
312
  export const SANDBOX_ROUTE_NAMES: readonly string[] = SANDBOX_ROUTES.map((route) => route.name);
303
313
 
304
314
  // Each route's shape, for the failure names alone can't describe: a route both builds have, but whose payload only one
305
- // expects. Computed once at load, since it's too expensive to repeat per connection.
306
- export const SANDBOX_ROUTE_SHAPES: Readonly<Record<string, string>> = routeShapes(sandboxContract);
315
+ // expects. Computed on the first ask and kept, since it's too expensive to repeat per connection — and too expensive to
316
+ // pay at load: turning every route's schemas into JSON Schema was a third of a second of a phone's startup at 4× CPU
317
+ // throttle, for a comparison a browser only makes when it has a disagreement to explain (the version card). The daemon
318
+ // asks on its first hello.
319
+ let fingerprints: Readonly<Record<string, string>> | undefined;
320
+ export const sandboxRouteFingerprints = (): Readonly<Record<string, string>> => (fingerprints ??= routeShapes(sandboxContract));
307
321
 
308
322
  // The contract route a concrete browser request belongs to, bound to this build's route table.
309
323
  export const sandboxRouteName = (method: string, pathWithQuery: string): string | undefined =>
@@ -126,6 +126,9 @@ test("the ceiling has nothing to disclose; a floor names what it lacks", () => {
126
126
  expect(grokCaps.steering).toBe(false);
127
127
  expect(grokCaps.isolation).toBe("cwd");
128
128
  expect(limitationsOf(grokCaps).length).toBeGreaterThan(0);
129
+ // The turn's remote servers, as Codex takes them: mounted on the shared OpenCode server per conversation.
130
+ expect(grokCaps.mcp).toBe("http");
131
+ expect(limitationsOf(grokCaps)).toContain("MCP servers only, none of the daemon's own tools, no plugins");
129
132
 
130
133
  const acpCaps = capabilitiesOf("some-installed-agent", "native");
131
134
  expect(acpCaps.mcp).toBe("http");
@@ -178,7 +181,10 @@ test("the safety axes disclose the middle answer differently from the floor", ()
178
181
 
179
182
  expect(codexCaps.rulebook).toBe("approval");
180
183
  expect(piCaps.rulebook).toBe("none");
181
- expect(grokCaps.rulebook).toBe("refuse-only");
184
+ expect(grokCaps.rulebook).toBe("approval");
185
+ // A hold parks on a card now that the turn's watchdog is held while it waits, so nothing says it cannot hold.
186
+ expect(limitationsOf(grokCaps)).toContain("command rules apply only to calls this agent raises");
187
+ expect(limitationsOf(grokCaps)).not.toContain("command rules can refuse but not hold");
182
188
 
183
189
  expect(limitationsOf(claudeCaps).join(" ")).not.toContain("command rules");
184
190
  expect(limitationsOf(claudeCaps).join(" ")).not.toContain("stored secrets");
@@ -102,14 +102,15 @@ export const CODEX: AgentCapabilities = {
102
102
  secrets: "none",
103
103
  };
104
104
 
105
- // OpenCode (the Grok runtime): its own agentic loop, its own tools, allow-all permissions. Takes a model id, a prompt
106
- // and one system message of ours; no effort scale, no tools of ours, no command list.
105
+ // OpenCode (the Grok runtime): its own agentic loop and tools, with the turn's remote MCP servers mounted on the shared
106
+ // server per conversation. Takes a model id, a prompt and one system message of ours; no effort scale, no command list.
107
107
  export const OPENCODE: AgentCapabilities = {
108
108
  runtime: "opencode",
109
109
  steering: false,
110
110
  permissions: "plan",
111
111
  questions: false,
112
- mcp: "none",
112
+ // Added at runtime under the conversation's own names, each prompt showing its session only its own (opencode-mcp.ts).
113
+ mcp: "http",
113
114
  execution: ["shell"],
114
115
  effort: false,
115
116
  fastMode: false,
@@ -121,8 +122,9 @@ export const OPENCODE: AgentCapabilities = {
121
122
  // `system` on the prompt body, per message; adds to OpenCode's own prompt, with no seam to replace it.
122
123
  instructions: "append",
123
124
  skillDiscovery: "prompt",
124
- // refuse-only for its inactivity watchdog, not its protocol: a paused approval reads as a stalled turn.
125
- rulebook: "refuse-only",
125
+ // OpenCode raises its permission asks for the commands its config names; the daemon answers from the rulebook, a
126
+ // hold parked on a card while the turn's inactivity watchdog is held.
127
+ rulebook: "approval",
126
128
  secrets: "none",
127
129
  };
128
130
 
@@ -71,7 +71,7 @@ export const MODEL_ROLES = [
71
71
  {
72
72
  id: "pipeline-fix",
73
73
  label: "Pipeline fixes",
74
- blurb: "The agent started by Fix on a red pipeline.",
74
+ blurb: "The agent started by Fix on a failed pipeline.",
75
75
  kind: "run",
76
76
  trigger: "pressed",
77
77
  icon: "wave-pulse",
@@ -108,14 +108,6 @@ export const MODEL_ROLES = [
108
108
  trigger: "pressed",
109
109
  icon: "list-check",
110
110
  },
111
- {
112
- id: "pre-push-fix",
113
- label: "Pre-push fixes",
114
- blurb: "The fix proposed when a check fails on the way to a push.",
115
- kind: "run",
116
- trigger: "pressed",
117
- icon: "cloud-upload",
118
- },
119
111
  {
120
112
  // Pressed trigger: the owner's approval click starts this turn; the queue between is just machinery.
121
113
  id: "approval-queue",
@@ -40,6 +40,22 @@ describe("git.destructive", () => {
40
40
  test("a -f belonging to the next command in a pipeline is not a force-push", () => {
41
41
  expect(classify("git push origin main | grep -f patterns.txt")).not.toContain("git.destructive");
42
42
  });
43
+
44
+ test("deleting a checkout's .git, or re-initialising the folder it stands in, cuts it off from its history", () => {
45
+ for (const command of ["rm .git", "rm -f .git", "rm -rf ./.git", "rm -rf tabularium/.git", "rm .git && git init -b main"]) {
46
+ expect(classify(command), command).toContain("git.destructive");
47
+ }
48
+ for (const command of ["git init", "git init .", "git init -b main", "git init --initial-branch main -q ."]) {
49
+ expect(classify(command), command).toContain("git.destructive");
50
+ }
51
+ expect(marked("cd /work && rm .git && git init -b main", "git.destructive")).toEqual(["rm .git", "git init -b main"]);
52
+ });
53
+
54
+ test("a new project's git init, and files that merely start with .git, are left alone", () => {
55
+ for (const command of ["git init new-project", "git init -b main tools/cli", "rm .gitignore", "rm -f .github/old.yml", "rm .gitmodules"]) {
56
+ expect(classify(command), command).not.toContain("git.destructive");
57
+ }
58
+ });
43
59
  });
44
60
 
45
61
  describe("files.destructive", () => {
@@ -72,6 +88,27 @@ describe("files.destructive", () => {
72
88
  }
73
89
  });
74
90
 
91
+ test("find deleting what it walks, or handing it to rm, is the same delete as rm -rf", () => {
92
+ for (const command of [
93
+ "find /home/x/PROJECT/cerberus-worktrees/m1-a -depth -delete",
94
+ "find build -name '*.o' -delete",
95
+ "find . -type d -name node_modules -exec rm -rf {} +",
96
+ "find dist -exec /bin/rm -f {} \\;",
97
+ "find tmp -execdir rm {} \\;",
98
+ "find . -name '*.log' -print0 | xargs -0 rm -f",
99
+ "ls old | xargs rm",
100
+ ]) {
101
+ expect(classify(command), command).toContain("files.destructive");
102
+ }
103
+ expect(marked("find build -name '*.o' -delete; echo done", "files.destructive")).toEqual(["find build -name '*.o' -delete"]);
104
+ });
105
+
106
+ test("a find that only lists, and an xargs that runs something else, pass", () => {
107
+ for (const command of ["find . -name '*.ts'", "find . -newer deleted.txt -print", "find src -exec grep -l rm {} +", "ls | xargs wc -l"]) {
108
+ expect(classify(command), command).not.toContain("files.destructive");
109
+ }
110
+ });
111
+
75
112
  test("a script that deletes one file, or nothing, is not recursive deletion", () => {
76
113
  for (const code of ['fs.unlinkSync("tmp.txt")', 'await fs.promises.rm("tmp.txt")', "const rmq = queue.rm(job)"]) {
77
114
  expect(classify(code), code).not.toContain("files.destructive");
@@ -113,6 +150,8 @@ describe("system.destructive", () => {
113
150
  "rm -rf C:\\",
114
151
  'fs.rmSync("/", { recursive: true, force: true })',
115
152
  'rimraf("/work")',
153
+ "find / -delete",
154
+ "find /home -type f -delete",
116
155
  ]) {
117
156
  expect(classify(command), command).toContain("system.destructive");
118
157
  }
@@ -375,6 +375,66 @@ const recursiveForceRms = (command: string): CommandSpan[] =>
375
375
  .filter((invocation) => invocation.recursive && invocation.force)
376
376
  .map((invocation) => invocation.span);
377
377
 
378
+ // The same tree delete spelled without `rm -rf`: `find` deleting what it walks, or handing each hit to `rm`, and a list
379
+ // piped into `rm` through xargs. An agent told `rm -rf` needs a card reaches for exactly these.
380
+ const FIND_INVOCATION = /\bfind\s+([^|;&\n]*)/g;
381
+ const FIND_DELETES = /\s(?:-delete\b|-exec(?:dir)?\s+(?:[^\s|;&]*\/)?rm\b)/;
382
+ const XARGS_RM = /\bxargs\b[^|;&\n]*?\s(?:[^\s|;&]*\/)?rm\b/g;
383
+
384
+ interface FindDelete {
385
+ // The paths find starts walking from: the words before its first expression (`-name`, `(`, `!`).
386
+ readonly starts: readonly string[];
387
+ readonly span: CommandSpan;
388
+ }
389
+
390
+ const parseFindDeletes = (command: string): FindDelete[] =>
391
+ [...command.matchAll(FIND_INVOCATION)].flatMap((invocation) => {
392
+ const args = invocation[1] as string;
393
+ if (!FIND_DELETES.test(` ${args}`)) {
394
+ return [];
395
+ }
396
+ const words = args.trim().split(/\s+/);
397
+ const expression = words.findIndex((word) => /^[-(!]/.test(word));
398
+ const starts = (expression === -1 ? words : words.slice(0, expression)).filter((word) => word !== "").map(unquote);
399
+ return [{ starts, span: { start: invocation.index, end: invocation.index + invocation[0].trimEnd().length } }];
400
+ });
401
+
402
+ const findAndXargsDeletes = (command: string): CommandSpan[] => [
403
+ ...parseFindDeletes(command).map((found) => found.span),
404
+ ...spansOf([XARGS_RM], command),
405
+ ];
406
+
407
+ // What cuts a checkout off from its repository's history: deleting its `.git` (for a worktree, a one-line pointer
408
+ // whose loss strands every commit the checkout was reading), or `git init` over the folder it stands in, which makes
409
+ // a standalone repository sharing nothing with the one it came from. A `git init <new-dir>` for a new project is not
410
+ // this, so only an init of the current folder counts.
411
+ const GIT_POINTER = /(?:^|[/\\])\.git[/\\]?$/;
412
+ const GIT_INIT = /\bgit\s+init\b([^|;&\n]*)/g;
413
+ const GIT_INIT_VALUED = /^(?:-b|--initial-branch|--template|--separate-git-dir|--object-format|--ref-format)$/;
414
+
415
+ const initsHere = (args: string): boolean => {
416
+ const words = args.trim().split(/\s+/).filter((word) => word !== "");
417
+ const operands: string[] = [];
418
+ for (let index = 0; index < words.length; index += 1) {
419
+ const word = words[index] as string;
420
+ if (GIT_INIT_VALUED.test(word)) {
421
+ index += 1;
422
+ } else if (!word.startsWith("-")) {
423
+ operands.push(unquote(word));
424
+ }
425
+ }
426
+ return operands.every((operand) => operand === "." || operand === "./");
427
+ };
428
+
429
+ const checkoutUnlinks = (command: string): CommandSpan[] => [
430
+ ...parseRm(command)
431
+ .filter((invocation) => invocation.operands.some((operand) => GIT_POINTER.test(operand)))
432
+ .map((invocation) => invocation.span),
433
+ ...[...command.matchAll(GIT_INIT)]
434
+ .filter((invocation) => initsHere(invocation[1] as string))
435
+ .map((invocation) => ({ start: invocation.index, end: invocation.index + invocation[0].trimEnd().length })),
436
+ ];
437
+
378
438
  // A recursive delete aimed at a root, in either spelling the gate is handed (shell or script). Which targets count as
379
439
  // roots is the locus's answer.
380
440
  const rootDeletes = (program: string, locus: CommandLocus): CommandSpan[] => [
@@ -384,6 +444,9 @@ const rootDeletes = (program: string, locus: CommandLocus): CommandSpan[] => [
384
444
  ...nodeDeleteTargets(program)
385
445
  .filter((delete_) => isRootTarget(delete_.target, locus))
386
446
  .map((delete_) => delete_.span),
447
+ ...parseFindDeletes(program)
448
+ .filter((found) => found.starts.some((start) => isRootTarget(start, locus)))
449
+ .map((found) => found.span),
387
450
  ];
388
451
 
389
452
  // The g twins, built once at load: a card is minted per command held, classify runs per command typed.
@@ -434,10 +497,10 @@ const credentialReads = (command: string, context: CommandContext): CommandSpan[
434
497
 
435
498
  // One function per class; empty means the command is not in it, so membership and evidence are the same walk.
436
499
  const MATCHES: Readonly<Record<CommandClass, (command: string, context: CommandContext) => CommandSpan[]>> = {
437
- "git.destructive": (command) => spansOf(GIT_DESTRUCTIVE_G, command),
500
+ "git.destructive": (command) => [...spansOf(GIT_DESTRUCTIVE_G, command), ...checkoutUnlinks(command)],
438
501
  // The only class that can answer "not here": in its own copy a conversation's checkout is its own to move.
439
502
  "git.branch-switch": (command, context) => (context.ownCheckout === true ? [] : spansOf(GIT_BRANCH_SWITCH_G, command)),
440
- "files.destructive": (command) => [...recursiveForceRms(command), ...recursiveDeletes(command)],
503
+ "files.destructive": (command) => [...recursiveForceRms(command), ...recursiveDeletes(command), ...findAndXargsDeletes(command)],
441
504
  "system.destructive": (command, context) => [...spansOf(BLOCK_DEVICE_G, command), ...rootDeletes(command, context.locus)],
442
505
  "container.state": (command) => spansOf(CONTAINER_STATE_G, command),
443
506
  "secrets.access": credentialReads,
@@ -489,6 +552,8 @@ export const COMMAND_CLASS_PATTERNS: Readonly<Record<CommandClass, readonly Comm
489
552
  { code: "git clean -f" },
490
553
  { code: "git branch -D" },
491
554
  { code: "git filter-branch" },
555
+ { code: "rm .git", qualifier: "any flags: a checkout's link to its history" },
556
+ { code: "git init", qualifier: "only in the current folder, which may already be a checkout" },
492
557
  ],
493
558
  "git.branch-switch": [
494
559
  { code: "git switch <branch>" },
@@ -498,6 +563,8 @@ export const COMMAND_CLASS_PATTERNS: Readonly<Record<CommandClass, readonly Comm
498
563
  { code: "rm -rf <path>" },
499
564
  { code: "fs.rm(<path>, { recursive: true })", qualifier: "also rmSync, rmdir, rmdirSync" },
500
565
  { code: "rimraf(<path>)" },
566
+ { code: "find <path> -delete", qualifier: "also -exec rm and -execdir rm" },
567
+ { code: "xargs rm" },
501
568
  ],
502
569
  "system.destructive": [
503
570
  { code: "mkfs" },
@@ -507,7 +574,7 @@ export const COMMAND_CLASS_PATTERNS: Readonly<Record<CommandClass, readonly Comm
507
574
  { code: "dd of=/dev/…" },
508
575
  { code: "shred /dev/…" },
509
576
  { code: "> /dev/sda" },
510
- { code: "rm -rf /", qualifier: "only when the target is a root, listed below" },
577
+ { code: "rm -rf /", qualifier: "also find / -delete; only when the target is a root, listed below" },
511
578
  ],
512
579
  "container.state": [
513
580
  { code: "docker volume rm", qualifier: "also remove, prune, and podman for any of these" },
@@ -64,6 +64,15 @@ export const COMMAND_RULE_CATALOG: readonly CommandRule[] = CommandClassSchema.o
64
64
  export const CommandJudgeModeSchema = z.enum(["off", "watch", "on"]);
65
65
  export type CommandJudgeMode = z.infer<typeof CommandJudgeModeSchema>;
66
66
 
67
+ // What an agent's own project-dependency install (`pnpm add`, `npm install`, `uv sync`) does, one answer for every
68
+ // turn. Where the install lands is the sandbox's business, not the owner's: an isolated turn installs into its own copy
69
+ // and a main-tree turn takes the install lane the daemon's own installs take. This only says whether a person is asked:
70
+ // - automatic: it runs
71
+ // - ask: a card in the turn; the turn waits on that one call, and "allow for this conversation" stops the asking
72
+ // - never: refused; the manifest change still lands and the daemon installs it then
73
+ export const ProjectInstallModeSchema = z.enum(["automatic", "ask", "never"]);
74
+ export type ProjectInstallMode = z.infer<typeof ProjectInstallModeSchema>;
75
+
67
76
  // What the judge answers, one instruction per verdict:
68
77
  // - allow: run it, say nothing, the ordinary answer for a triage false positive
69
78
  // - ask: raise the card; the only path to a person, meant to be rare
@@ -122,6 +131,7 @@ Ask me before:
122
131
 
123
132
  - publishing or releasing anything (npm publish, a GitHub release, a container push);
124
133
  - force-pushing, hard-resetting or otherwise discarding commits that are not this turn's own work;
134
+ - deleting a checkout's \`.git\` or running \`git init\` in a folder that already is one: in a worktree that cuts it off from my workspace's history, and its work can no longer come back to me;
125
135
  - moving a checkout onto another branch (\`git checkout <branch>\`, \`git switch\`) — you only ever see this for a tree that is mine as well as yours, never for a copy of your own, so the worktree paragraph above does not cover it;
126
136
  - sending a credential anywhere outside this container.
127
137
 
@@ -0,0 +1,89 @@
1
+ import { hostAllowed, hostMatches, normalizeHost, normalizeHostPattern, tightensHostGuard } from "./secret-hosts.js";
2
+
3
+ // The pattern a person writes against the host a use would reach. Every boundary a limit turns on is pinned by value:
4
+ // the apex a wildcard leaves out, the look-alike that only shares a suffix, and which edits take hosts away.
5
+
6
+ describe("normalizeHostPattern", () => {
7
+ it("reads what a person types or pastes as the host it means", () => {
8
+ expect(normalizeHostPattern(" API.GitHub.com. ")).toBe("api.github.com");
9
+ expect(normalizeHostPattern("https://api.github.com/user?per_page=5")).toBe("api.github.com");
10
+ expect(normalizeHostPattern("api.github.com:443")).toBe("api.github.com");
11
+ expect(normalizeHostPattern("*.githubusercontent.com")).toBe("*.githubusercontent.com");
12
+ expect(normalizeHostPattern("localhost")).toBe("localhost");
13
+ expect(normalizeHostPattern("10.0.0.2")).toBe("10.0.0.2");
14
+ });
15
+
16
+ it("refuses what is not one host or one domain's hosts", () => {
17
+ expect(normalizeHostPattern("*")).toBeUndefined();
18
+ expect(normalizeHostPattern("*.com")).toBeUndefined();
19
+ expect(normalizeHostPattern("api.*.com")).toBeUndefined();
20
+ expect(normalizeHostPattern("api.github.com/user")).toBeUndefined();
21
+ expect(normalizeHostPattern("user@api.github.com")).toBeUndefined();
22
+ expect(normalizeHostPattern("-bad.example.com")).toBeUndefined();
23
+ expect(normalizeHostPattern("")).toBeUndefined();
24
+ expect(normalizeHostPattern(`${"a".repeat(64)}.com`)).toBeUndefined();
25
+ });
26
+ });
27
+
28
+ describe("normalizeHost", () => {
29
+ it("takes a plain host or address and nothing shaped like a pattern or a stray token", () => {
30
+ expect(normalizeHost("API.github.com.")).toBe("api.github.com");
31
+ expect(normalizeHost("*.github.com")).toBeUndefined();
32
+ expect(normalizeHost("[::1]")).toBeUndefined();
33
+ expect(normalizeHost("api.github.com\u0001")).toBeUndefined();
34
+ expect(normalizeHost("$host")).toBeUndefined();
35
+ });
36
+ });
37
+
38
+ describe("hostMatches", () => {
39
+ it("matches an exact host only to itself", () => {
40
+ expect(hostMatches("api.github.com", "api.github.com")).toBe(true);
41
+ expect(hostMatches("api.github.com", "github.com")).toBe(false);
42
+ expect(hostMatches("github.com", "api.github.com")).toBe(false);
43
+ });
44
+
45
+ it("matches a wildcard to every host under the domain, at any depth, and not to the domain itself", () => {
46
+ expect(hostMatches("*.github.com", "api.github.com")).toBe(true);
47
+ expect(hostMatches("*.github.com", "a.b.github.com")).toBe(true);
48
+ expect(hostMatches("*.github.com", "github.com")).toBe(false);
49
+ });
50
+
51
+ it("does not match a host that merely ends in the same letters", () => {
52
+ expect(hostMatches("*.github.com", "evilgithub.com")).toBe(false);
53
+ expect(hostMatches("*.github.com", "github.com.evil.example")).toBe(false);
54
+ });
55
+
56
+ it("allows a host any one pattern in the list matches", () => {
57
+ expect(hostAllowed(["api.github.com", "*.githubusercontent.com"], "raw.githubusercontent.com")).toBe(true);
58
+ expect(hostAllowed(["api.github.com", "*.githubusercontent.com"], "evil.example")).toBe(false);
59
+ expect(hostAllowed([], "api.github.com")).toBe(false);
60
+ });
61
+ });
62
+
63
+ describe("tightensHostGuard", () => {
64
+ const on = (...hosts: string[]) => ({ guard: true, hosts });
65
+ const off = (...hosts: string[]) => ({ guard: false, hosts });
66
+
67
+ it("reads turning the guard on as tightening, whatever the list, and turning it off as loosening", () => {
68
+ expect(tightensHostGuard(undefined, on("api.github.com"))).toBe(true);
69
+ expect(tightensHostGuard(off("api.github.com"), on())).toBe(true);
70
+ expect(tightensHostGuard(on("api.github.com"), off("api.github.com"))).toBe(false);
71
+ expect(tightensHostGuard(undefined, off())).toBe(true);
72
+ expect(tightensHostGuard(off(), off("evil.example"))).toBe(true);
73
+ });
74
+
75
+ it("reads taking a host off a guarded list as tightening, down to none, and adding one as loosening", () => {
76
+ expect(tightensHostGuard(on("api.github.com", "github.com"), on("github.com"))).toBe(true);
77
+ expect(tightensHostGuard(on("api.github.com"), on())).toBe(true);
78
+ expect(tightensHostGuard(on("api.github.com"), on("api.github.com", "evil.example"))).toBe(false);
79
+ expect(tightensHostGuard(on(), on("api.github.com"))).toBe(false);
80
+ expect(tightensHostGuard(on("api.github.com"), on("api.github.com"))).toBe(true);
81
+ });
82
+
83
+ it("counts a host or a deeper wildcard under a held wildcard as covered, and the domain itself as not", () => {
84
+ expect(tightensHostGuard(on("*.github.com"), on("api.github.com"))).toBe(true);
85
+ expect(tightensHostGuard(on("*.github.com"), on("*.api.github.com"))).toBe(true);
86
+ expect(tightensHostGuard(on("*.github.com"), on("github.com"))).toBe(false);
87
+ expect(tightensHostGuard(on("api.github.com"), on("*.api.github.com"))).toBe(false);
88
+ });
89
+ });