@phyzess/pappra 0.1.0-beta.13 → 0.1.0-beta.18

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 (357) hide show
  1. package/README.md +134 -15
  2. package/assets/integrations/skills/pappra/SKILL.md +28 -7
  3. package/assets/integrations/skills/pappra/references/collaboration.md +633 -0
  4. package/assets/integrations/skills/pappra/references/environment.md +360 -0
  5. package/assets/integrations/skills/pappra/references/hosts.md +20 -0
  6. package/assets/integrations/skills/pappra/references/operations.md +36 -5
  7. package/dist/adapters/pi/recovery-extension.d.ts +65 -0
  8. package/dist/adapters/pi/recovery-extension.js +238 -0
  9. package/dist/adapters/pi/session-transition-extension.d.ts +30 -0
  10. package/dist/adapters/pi/session-transition-extension.js +265 -0
  11. package/dist/app/automatic-handoff-events.d.ts +26 -0
  12. package/dist/app/automatic-handoff-events.js +134 -0
  13. package/dist/app/bounded-file.d.ts +2 -0
  14. package/dist/app/bounded-file.js +2 -0
  15. package/dist/app/capability-evidence/claude.d.ts +37 -0
  16. package/dist/app/capability-evidence/claude.js +206 -0
  17. package/dist/app/capability-evidence/codex.d.ts +35 -0
  18. package/dist/app/capability-evidence/codex.js +193 -0
  19. package/dist/app/capability-evidence/index.d.ts +33 -0
  20. package/dist/app/capability-evidence/index.js +117 -0
  21. package/dist/app/capability-evidence/pi.d.ts +73 -0
  22. package/dist/app/capability-evidence/pi.js +669 -0
  23. package/dist/app/capability-evidence/shared.d.ts +69 -0
  24. package/dist/app/capability-evidence/shared.js +195 -0
  25. package/dist/app/collab-auto-handoff.d.ts +55 -0
  26. package/dist/app/collab-auto-handoff.js +384 -0
  27. package/dist/app/collab-bindings.d.ts +57 -0
  28. package/dist/app/collab-bindings.js +1006 -0
  29. package/dist/app/collab-bootstrap-transport.d.ts +163 -0
  30. package/dist/app/collab-bootstrap-transport.js +769 -0
  31. package/dist/app/collab-bootstrap.d.ts +137 -0
  32. package/dist/app/collab-bootstrap.js +3455 -0
  33. package/dist/app/collab-handoff.d.ts +12 -0
  34. package/dist/app/collab-handoff.js +511 -0
  35. package/dist/app/collab-messages.d.ts +2 -0
  36. package/dist/app/collab-messages.js +2 -0
  37. package/dist/app/collab-notify.d.ts +156 -0
  38. package/dist/app/collab-notify.js +1208 -0
  39. package/dist/app/collab-preflight.d.ts +34 -0
  40. package/dist/app/collab-preflight.js +96 -0
  41. package/dist/app/collab-recovery-executor.d.ts +161 -0
  42. package/dist/app/collab-recovery-executor.js +1153 -0
  43. package/dist/app/collab-recovery-projection.d.ts +103 -0
  44. package/dist/app/collab-recovery-projection.js +659 -0
  45. package/dist/app/collab-recovery.d.ts +25 -0
  46. package/dist/app/collab-recovery.js +429 -0
  47. package/dist/app/collab-resources.d.ts +16 -0
  48. package/dist/app/collab-resources.js +278 -0
  49. package/dist/app/collab-role-events.d.ts +22 -0
  50. package/dist/app/collab-role-events.js +329 -0
  51. package/dist/app/collab-role-orchestration.d.ts +53 -0
  52. package/dist/app/collab-role-orchestration.js +601 -0
  53. package/dist/app/collab-role-plan.d.ts +81 -0
  54. package/dist/app/collab-role-plan.js +504 -0
  55. package/dist/app/collab-role-repair.d.ts +109 -0
  56. package/dist/app/collab-role-repair.js +821 -0
  57. package/dist/app/collab-rollover.d.ts +263 -0
  58. package/dist/app/collab-rollover.js +1112 -0
  59. package/dist/app/collab-route.d.ts +64 -0
  60. package/dist/app/collab-route.js +240 -0
  61. package/dist/app/collab-session-transition.d.ts +221 -0
  62. package/dist/app/collab-session-transition.js +3334 -0
  63. package/dist/app/collab-state.d.ts +7 -0
  64. package/dist/app/collab-state.js +162 -0
  65. package/dist/app/collab-task-store.d.ts +22 -0
  66. package/dist/app/collab-task-store.js +204 -0
  67. package/dist/app/collab-work-execution.d.ts +127 -0
  68. package/dist/app/collab-work-execution.js +1027 -0
  69. package/dist/app/collab-work-plan.d.ts +87 -0
  70. package/dist/app/collab-work-plan.js +437 -0
  71. package/dist/app/collaboration.d.ts +8 -2
  72. package/dist/app/collaboration.js +101 -12
  73. package/dist/app/doctor.js +108 -5
  74. package/dist/app/host-mcp.js +34 -8
  75. package/dist/app/host-probe.js +4 -4
  76. package/dist/app/init.d.ts +58 -4
  77. package/dist/app/init.js +768 -155
  78. package/dist/app/managed-pi-bootstrap-admission.d.ts +14 -0
  79. package/dist/app/managed-pi-bootstrap-admission.js +104 -0
  80. package/dist/app/managed-pi-bootstrap-refresh.d.ts +10 -0
  81. package/dist/app/managed-pi-bootstrap-refresh.js +78 -0
  82. package/dist/app/managed-pi-delivery.d.ts +8 -0
  83. package/dist/app/managed-pi-delivery.js +110 -0
  84. package/dist/app/managed-pi-handoff-receiver.d.ts +15 -0
  85. package/dist/app/managed-pi-handoff-receiver.js +263 -0
  86. package/dist/app/managed-pi-handoff-reference.d.ts +3 -0
  87. package/dist/app/managed-pi-handoff-reference.js +60 -0
  88. package/dist/app/managed-pi-herdr.d.ts +21 -0
  89. package/dist/app/managed-pi-herdr.js +185 -0
  90. package/dist/app/managed-pi-initial-admission.d.ts +28 -0
  91. package/dist/app/managed-pi-initial-admission.js +416 -0
  92. package/dist/app/managed-pi-initial-launch.d.ts +5 -0
  93. package/dist/app/managed-pi-initial-launch.js +61 -0
  94. package/dist/app/managed-pi-native-observation.d.ts +36 -0
  95. package/dist/app/managed-pi-native-observation.js +191 -0
  96. package/dist/app/managed-pi-readiness.d.ts +29 -0
  97. package/dist/app/managed-pi-readiness.js +288 -0
  98. package/dist/app/managed-pi-repair-stop.d.ts +21 -0
  99. package/dist/app/managed-pi-repair-stop.js +371 -0
  100. package/dist/app/managed-pi-resume-admission.d.ts +32 -0
  101. package/dist/app/managed-pi-resume-admission.js +618 -0
  102. package/dist/app/managed-pi-retirement.d.ts +28 -0
  103. package/dist/app/managed-pi-retirement.js +112 -0
  104. package/dist/app/managed-pi-sdk-control.d.ts +7 -0
  105. package/dist/app/managed-pi-sdk-control.js +169 -0
  106. package/dist/app/managed-pi-sdk-runtime.d.ts +3 -0
  107. package/dist/app/managed-pi-sdk-runtime.js +483 -0
  108. package/dist/app/managed-pi-source-admission.d.ts +14 -0
  109. package/dist/app/managed-pi-source-admission.js +323 -0
  110. package/dist/app/managed-pi-transition-host.d.ts +36 -0
  111. package/dist/app/managed-pi-transition-host.js +292 -0
  112. package/dist/app/managed-pi.d.ts +54 -0
  113. package/dist/app/managed-pi.js +248 -0
  114. package/dist/app/shell-readiness.d.ts +66 -0
  115. package/dist/app/shell-readiness.js +368 -0
  116. package/dist/app/task-pin.d.ts +2 -23
  117. package/dist/app/task-pin.js +2 -113
  118. package/dist/cli/commands/collaboration-binding.d.ts +13 -0
  119. package/dist/cli/commands/collaboration-binding.js +118 -0
  120. package/dist/cli/commands/collaboration-bootstrap.d.ts +10 -0
  121. package/dist/cli/commands/collaboration-bootstrap.js +84 -0
  122. package/dist/cli/commands/collaboration-capabilities.d.ts +13 -0
  123. package/dist/cli/commands/collaboration-capabilities.js +127 -0
  124. package/dist/cli/commands/collaboration-handoff.d.ts +13 -0
  125. package/dist/cli/commands/collaboration-handoff.js +102 -0
  126. package/dist/cli/commands/collaboration-message.d.ts +17 -0
  127. package/dist/cli/commands/collaboration-message.js +177 -0
  128. package/dist/cli/commands/collaboration-plan.d.ts +8 -0
  129. package/dist/cli/commands/collaboration-plan.js +108 -0
  130. package/dist/cli/commands/collaboration-preflight.d.ts +10 -0
  131. package/dist/cli/commands/collaboration-preflight.js +167 -0
  132. package/dist/cli/commands/collaboration-recovery-run.d.ts +46 -0
  133. package/dist/cli/commands/collaboration-recovery-run.js +224 -0
  134. package/dist/cli/commands/collaboration-recovery.d.ts +11 -0
  135. package/dist/cli/commands/collaboration-recovery.js +104 -0
  136. package/dist/cli/commands/collaboration-resources.d.ts +11 -0
  137. package/dist/cli/commands/collaboration-resources.js +96 -0
  138. package/dist/cli/commands/collaboration-role-plan.d.ts +9 -0
  139. package/dist/cli/commands/collaboration-role-plan.js +69 -0
  140. package/dist/cli/commands/collaboration-role-run.d.ts +11 -0
  141. package/dist/cli/commands/collaboration-role-run.js +128 -0
  142. package/dist/cli/commands/collaboration-rollover.d.ts +10 -0
  143. package/dist/cli/commands/collaboration-rollover.js +103 -0
  144. package/dist/cli/commands/collaboration-state.d.ts +10 -0
  145. package/dist/cli/commands/collaboration-state.js +96 -0
  146. package/dist/cli/commands/collaboration-transition.d.ts +10 -0
  147. package/dist/cli/commands/collaboration-transition.js +75 -0
  148. package/dist/cli/commands/collaboration-work-run.d.ts +34 -0
  149. package/dist/cli/commands/collaboration-work-run.js +178 -0
  150. package/dist/cli/commands/collaboration.d.ts +4 -0
  151. package/dist/cli/commands/collaboration.js +39 -4
  152. package/dist/cli/commands/continuity.js +2 -6
  153. package/dist/cli/commands/docs.d.ts +2 -0
  154. package/dist/cli/commands/docs.js +89 -15
  155. package/dist/cli/commands/host.d.ts +7 -1
  156. package/dist/cli/commands/host.js +122 -7
  157. package/dist/cli/commands/init.d.ts +20 -3
  158. package/dist/cli/commands/init.js +897 -232
  159. package/dist/cli/commands/mcp.d.ts +1 -0
  160. package/dist/cli/commands/mcp.js +11 -5
  161. package/dist/cli/commands/repair.d.ts +12 -0
  162. package/dist/cli/commands/repair.js +41 -0
  163. package/dist/cli/commands/runtime.d.ts +1 -1
  164. package/dist/cli/commands/runtime.js +139 -38
  165. package/dist/cli/commands/session.d.ts +7 -0
  166. package/dist/cli/commands/session.js +82 -0
  167. package/dist/cli/commands/task.js +19 -5
  168. package/dist/cli/run.js +866 -24
  169. package/dist/code/identity.d.ts +7 -0
  170. package/dist/code/identity.js +7 -3
  171. package/dist/code/registration.js +7 -0
  172. package/dist/code/service.d.ts +9 -0
  173. package/dist/code/service.js +16 -3
  174. package/dist/code/text.js +19 -7
  175. package/dist/collab/admission.d.ts +91 -66
  176. package/dist/collab/admission.js +21 -6
  177. package/dist/collab/canonical.d.ts +1 -1
  178. package/dist/collab/canonical.js +44 -3
  179. package/dist/collab/envelope.d.ts +2 -2
  180. package/dist/collab/envelope.js +12 -12
  181. package/dist/collab/first-work.d.ts +3 -0
  182. package/dist/collab/first-work.js +15 -0
  183. package/dist/collab/handoff.d.ts +16 -0
  184. package/dist/collab/handoff.js +39 -5
  185. package/dist/collab/index.d.ts +97 -1
  186. package/dist/collab/index.js +9 -1
  187. package/dist/collab/messages.js +126 -3
  188. package/dist/collab/persisted-messages.d.ts +123 -0
  189. package/dist/collab/persisted-messages.js +496 -0
  190. package/dist/collab/preflight.d.ts +1 -1
  191. package/dist/collab/resources.d.ts +13 -3
  192. package/dist/collab/resources.js +37 -6
  193. package/dist/collab/rollover.d.ts +311 -0
  194. package/dist/collab/rollover.js +1024 -0
  195. package/dist/collab/store.d.ts +1 -0
  196. package/dist/collab/store.js +1 -4
  197. package/dist/collab/types.d.ts +2 -354
  198. package/dist/collab/validation.d.ts +2 -10
  199. package/dist/collab/validation.js +2 -303
  200. package/dist/collab/work-plan.d.ts +105 -0
  201. package/dist/collab/work-plan.js +843 -0
  202. package/dist/continuity/context.d.ts +11 -2
  203. package/dist/continuity/context.js +100 -13
  204. package/dist/continuity/handoff-bundle.d.ts +296 -0
  205. package/dist/continuity/handoff-bundle.js +477 -0
  206. package/dist/continuity/index.d.ts +2 -0
  207. package/dist/continuity/index.js +1 -0
  208. package/dist/continuity/paths.js +10 -2
  209. package/dist/continuity/service.js +91 -15
  210. package/dist/continuity/task-pin.d.ts +24 -0
  211. package/dist/continuity/task-pin.js +590 -0
  212. package/dist/doctor.d.ts +1 -0
  213. package/dist/doctor.js +6 -0
  214. package/dist/experimental/index.d.ts +13 -0
  215. package/dist/experimental/index.js +25 -0
  216. package/dist/experimental/pi.d.ts +4 -0
  217. package/dist/experimental/pi.js +12 -0
  218. package/dist/hosts/claude/native.js +1 -1
  219. package/dist/hosts/codex/native.js +1 -1
  220. package/dist/hosts/codex/protocol.js +1 -1
  221. package/dist/hosts/integration/bootstrap-config.d.ts +58 -0
  222. package/dist/hosts/integration/bootstrap-config.js +254 -0
  223. package/dist/hosts/integration/bundle-export.d.ts +44 -0
  224. package/dist/hosts/integration/bundle-export.js +366 -3
  225. package/dist/hosts/integration/bundle.js +3 -0
  226. package/dist/hosts/integration/hook.js +36 -9
  227. package/dist/hosts/integration/pappra-bootstrap-extension.mjs +80 -0
  228. package/dist/hosts/integration/pappra-extension-runtime.mjs +59 -24631
  229. package/dist/hosts/integration/pappra-hook.mjs +61 -24749
  230. package/dist/hosts/integration/pappra-recovery-extension.mjs +259 -0
  231. package/dist/hosts/integration/pappra-session-transition-extension.mjs +276 -0
  232. package/dist/hosts/integration/pi-bootstrap-extension.d.ts +36 -0
  233. package/dist/hosts/integration/pi-bootstrap-extension.js +101 -0
  234. package/dist/hosts/integration/pi-bootstrap-guard.d.ts +125 -0
  235. package/dist/hosts/integration/pi-bootstrap-guard.js +438 -0
  236. package/dist/hosts/integration/pi-bootstrap-runtime.d.ts +63 -0
  237. package/dist/hosts/integration/pi-bootstrap-runtime.js +223 -0
  238. package/dist/hosts/integration/pi-native-events.d.ts +112 -0
  239. package/dist/hosts/integration/pi-native-events.js +348 -0
  240. package/dist/hosts/integration/pi-rollover-extension.d.ts +166 -0
  241. package/dist/hosts/integration/pi-rollover-extension.js +431 -0
  242. package/dist/hosts/integration/recovery-config.d.ts +48 -0
  243. package/dist/hosts/integration/recovery-config.js +117 -0
  244. package/dist/hosts/integration/service.d.ts +6 -1
  245. package/dist/hosts/integration/service.js +485 -35
  246. package/dist/hosts/integration/support.d.ts +7 -0
  247. package/dist/hosts/integration/support.js +9 -1
  248. package/dist/hosts/integration/templates.d.ts +3 -0
  249. package/dist/hosts/integration/templates.js +26 -3
  250. package/dist/hosts/pi/managed-host-identity.d.ts +2 -0
  251. package/dist/hosts/pi/managed-host-identity.js +40 -0
  252. package/dist/hosts/pi/managed-provider-diagnostics.d.ts +6 -0
  253. package/dist/hosts/pi/managed-provider-diagnostics.js +184 -0
  254. package/dist/hosts/pi/managed-sdk-session.d.ts +335 -0
  255. package/dist/hosts/pi/managed-sdk-session.js +1639 -0
  256. package/dist/hosts/pi/managed-session-extension.d.ts +20 -0
  257. package/dist/hosts/pi/managed-session-extension.js +84 -0
  258. package/dist/hosts/pi/managed-session.d.ts +177 -0
  259. package/dist/hosts/pi/managed-session.js +1557 -0
  260. package/dist/hosts/pi/protocol.js +1 -1
  261. package/dist/hosts/pi/query-result.js +1 -1
  262. package/dist/hosts/pi/resume-capability.d.ts +41 -0
  263. package/dist/hosts/pi/resume-capability.js +33 -0
  264. package/dist/hosts/pi/rpc.d.ts +182 -134
  265. package/dist/hosts/pi/rpc.js +230 -37
  266. package/dist/hosts/pilot.d.ts +97 -74
  267. package/dist/hosts/pilot.js +5 -1
  268. package/dist/hosts/version.d.ts +3 -0
  269. package/dist/hosts/version.js +18 -0
  270. package/dist/index.d.ts +0 -1
  271. package/dist/index.js +0 -1
  272. package/dist/infra/bounded-file.d.ts +19 -0
  273. package/dist/infra/bounded-file.js +66 -0
  274. package/dist/infra/fs.js +10 -2
  275. package/dist/infra/git.d.ts +29 -0
  276. package/dist/infra/git.js +45 -9
  277. package/dist/infra/json-property.d.ts +2 -0
  278. package/dist/infra/json-property.js +69 -0
  279. package/dist/infra/json.d.ts +4 -0
  280. package/dist/infra/json.js +24 -0
  281. package/dist/infra/owned-process-group.js +1 -1
  282. package/dist/infra/private-lock.d.ts +16 -0
  283. package/dist/infra/private-lock.js +148 -0
  284. package/dist/infra/private-state.d.ts +7 -0
  285. package/dist/infra/private-state.js +146 -0
  286. package/dist/infra/process-identity.d.ts +12 -0
  287. package/dist/infra/process-identity.js +142 -0
  288. package/dist/infra/validation.d.ts +5 -0
  289. package/dist/infra/validation.js +15 -0
  290. package/dist/init.d.ts +1 -0
  291. package/dist/init.js +6 -0
  292. package/dist/install/apply.d.ts +9 -1
  293. package/dist/install/apply.js +176 -12
  294. package/dist/install/dependencies.d.ts +38 -0
  295. package/dist/install/dependencies.js +282 -0
  296. package/dist/install/ownership.js +30 -1
  297. package/dist/install/references.d.ts +31 -0
  298. package/dist/install/references.js +208 -0
  299. package/dist/install/repair.d.ts +37 -0
  300. package/dist/install/repair.js +798 -0
  301. package/dist/install/reset-local.d.ts +16 -0
  302. package/dist/install/reset-local.js +304 -0
  303. package/dist/install/rollback.d.ts +3 -0
  304. package/dist/install/rollback.js +9 -3
  305. package/dist/install/runtime.d.ts +10 -6
  306. package/dist/install/runtime.js +299 -59
  307. package/dist/install/source-fingerprint.d.ts +2 -0
  308. package/dist/install/source-fingerprint.js +103 -0
  309. package/dist/knowledge/catalog.d.ts +1 -0
  310. package/dist/knowledge/catalog.js +143 -10
  311. package/dist/knowledge/journal.js +17 -7
  312. package/dist/knowledge/paths.js +2 -1
  313. package/dist/knowledge/refs.js +4 -0
  314. package/dist/knowledge/register-batch.d.ts +4 -0
  315. package/dist/knowledge/register-batch.js +225 -0
  316. package/dist/knowledge/relocate.d.ts +5 -0
  317. package/dist/knowledge/relocate.js +92 -0
  318. package/dist/knowledge/scan.js +103 -47
  319. package/dist/knowledge/service.d.ts +3 -0
  320. package/dist/knowledge/service.js +33 -1
  321. package/dist/knowledge/write.d.ts +4 -1
  322. package/dist/knowledge/write.js +1 -1
  323. package/dist/mcp/server.d.ts +4 -2
  324. package/dist/mcp/server.js +87 -136
  325. package/dist/schemas/collaboration-state-validation.d.ts +6 -0
  326. package/dist/schemas/collaboration-state-validation.js +342 -0
  327. package/dist/schemas/collaboration-state.d.ts +436 -0
  328. package/dist/schemas/collaboration-state.js +1 -0
  329. package/dist/schemas/collaboration.d.ts +335 -0
  330. package/dist/schemas/collaboration.js +272 -0
  331. package/dist/schemas/continuity.d.ts +8 -0
  332. package/dist/schemas/continuity.js +13 -3
  333. package/dist/schemas/doctor.d.ts +1 -0
  334. package/dist/schemas/doctor.js +1 -0
  335. package/dist/schemas/document.d.ts +61 -0
  336. package/dist/schemas/document.js +9 -0
  337. package/dist/schemas/errors.d.ts +1 -0
  338. package/dist/schemas/errors.js +1 -0
  339. package/dist/schemas/host.d.ts +24 -0
  340. package/dist/schemas/host.js +19 -0
  341. package/dist/schemas/install.d.ts +8 -2
  342. package/dist/schemas/install.js +11 -1
  343. package/dist/schemas/managed-pi-execution.d.ts +16 -0
  344. package/dist/schemas/managed-pi-execution.js +2 -0
  345. package/dist/schemas/outcome.d.ts +9 -5
  346. package/dist/workspace/config-file.js +1 -3
  347. package/dist/workspace/documents.js +12 -2
  348. package/dist/workspace/repositories.d.ts +7 -0
  349. package/dist/workspace/repositories.js +14 -5
  350. package/package.json +35 -35
  351. package/skills/pappra/SKILL.md +28 -7
  352. package/skills/pappra/references/collaboration.md +633 -0
  353. package/skills/pappra/references/environment.md +360 -0
  354. package/skills/pappra/references/hosts.md +20 -0
  355. package/skills/pappra/references/operations.md +36 -5
  356. package/dist/app/collab-from.d.ts +0 -35
  357. package/dist/app/collab-from.js +0 -84
@@ -28,6 +28,7 @@ export declare const resultsDir: (taskRoot: string) => string;
28
28
  export declare const nativeDir: (taskRoot: string) => string;
29
29
  export declare const abortedDir: (taskRoot: string) => string;
30
30
  export declare const brokenLocksDir: (taskRoot: string) => string;
31
+ export declare const notificationsDir: (taskRoot: string) => string;
31
32
  export declare function domainIdOf(domainRoot: string): string;
32
33
  /** Validate the stored shape without inferring native execution facts. */
33
34
  export declare function readRecord(taskRoot: string): TaskRecord | null;
@@ -90,6 +90,7 @@ export const resultsDir = (taskRoot) => path.join(taskRoot, 'results');
90
90
  export const nativeDir = (taskRoot) => path.join(taskRoot, 'native');
91
91
  export const abortedDir = (taskRoot) => path.join(taskRoot, 'aborted');
92
92
  export const brokenLocksDir = (taskRoot) => path.join(taskRoot, 'broken-locks');
93
+ export const notificationsDir = (taskRoot) => path.join(taskRoot, 'notifications');
93
94
  export function domainIdOf(domainRoot) {
94
95
  return `domain:${crypto.createHash('sha256').update(domainRoot).digest('hex').slice(0, 24)}`;
95
96
  }
@@ -377,10 +378,6 @@ export function transact(taskRoot, { actor = 'unattributed', purpose = 'unspecif
377
378
  actor,
378
379
  base_revision: current.state_revision,
379
380
  }, null, 2)}\n`, { flag: 'wx', mode: 0o600 });
380
- if (process.env.PAPPRA_FAULT === 'exit_before_rename') {
381
- // Documented test-only fault injection: leave an uncommitted transaction behind.
382
- process.exit(70);
383
- }
384
381
  fs.renameSync(transactionFile, recordPath(taskRoot));
385
382
  fs.rmSync(metadataFile, { force: true });
386
383
  committed = true;
@@ -1,354 +1,2 @@
1
- /** Legacy protocol data. Unknown extension fields are preserved without being executed. */
2
- export interface Identity {
3
- agent_id: string;
4
- session_id: string;
5
- harness: string | null;
6
- cwd?: string;
7
- }
8
- export interface Coordinator extends Identity {
9
- owner_epoch: number;
10
- since: string;
11
- previous?: Pick<Coordinator, 'agent_id' | 'session_id' | 'owner_epoch'> | null;
12
- }
13
- export interface ResourceInput {
14
- kind?: string;
15
- path?: string;
16
- scope?: string;
17
- port?: number;
18
- value?: string;
19
- label?: string;
20
- origin?: string;
21
- derived?: boolean;
22
- shared?: boolean;
23
- }
24
- export interface Resource {
25
- kind: string;
26
- scope: string;
27
- key: string;
28
- path?: string | null;
29
- port?: number | null;
30
- existing?: boolean;
31
- label: string;
32
- origin?: string;
33
- derived_from?: string | null;
34
- }
35
- export interface Claim extends Resource {
36
- claim_id: string;
37
- access: string;
38
- holder: Identity;
39
- resource_epoch: number;
40
- claimed_at: string;
41
- released_at: string | null;
42
- subtask_id: string | null;
43
- attempt: number | null;
44
- note: string | null;
45
- cancel_pending?: boolean;
46
- released_by?: string;
47
- release_reason?: string | null;
48
- transferred_from?: Identity;
49
- transferred_at?: string;
50
- }
51
- export interface MessageBody {
52
- [key: string]: unknown;
53
- assignment_ref?: string | null;
54
- assignment_digest?: string | null;
55
- input_revision?: string | null;
56
- approval?: {
57
- approved_by: string;
58
- reason: string;
59
- };
60
- status?: string;
61
- kind?: string;
62
- phase?: string;
63
- handoff_id?: string;
64
- resources?: string[];
65
- reason?: string | null;
66
- outputs?: unknown[];
67
- native_ref?: unknown;
68
- evidence_ref?: string | null;
69
- stop_evidence?: unknown;
70
- }
71
- export interface Message {
72
- [key: string]: unknown;
73
- schema: string;
74
- message_id: string;
75
- type: string;
76
- task_id: string;
77
- from: Identity;
78
- to: Identity;
79
- reply_to: string | null;
80
- subtask_id: string | null;
81
- attempt: number | null;
82
- owner_epoch: number | null;
83
- created_at: string;
84
- content_digest: string | null;
85
- body: MessageBody;
86
- }
87
- export type MessageInput = Pick<Message, 'type' | 'task_id' | 'from' | 'to'> & Partial<Pick<Message, 'message_id' | 'reply_to' | 'subtask_id' | 'attempt' | 'owner_epoch' | 'created_at' | 'body'>>;
88
- export interface Transition {
89
- from: string | null;
90
- to: string;
91
- at: string;
92
- actor: string;
93
- reason: string | null;
94
- evidence: unknown;
95
- forced?: boolean | undefined;
96
- }
97
- export interface NativeBinding {
98
- runner: string | null;
99
- session_id: string | null;
100
- run_id: string | null;
101
- mission_id: string | null;
102
- observation: string;
103
- observed_at: string | null;
104
- evidence_ref: string | null;
105
- manager?: string;
106
- launch_kind?: string;
107
- mode?: string;
108
- identity_status?: string;
109
- }
110
- export interface Attempt {
111
- subtask_id: string;
112
- attempt: number;
113
- state: string;
114
- owner_epoch: number | null;
115
- assignee: Identity;
116
- assignment_message_id: string;
117
- assignment_ref: string | null;
118
- assignment_digest: string | null;
119
- input_revision: string | null;
120
- created_at: string;
121
- updated_at: string;
122
- native: NativeBinding;
123
- approval: MessageBody['approval'] | null;
124
- transitions: Transition[];
125
- closed_at?: string;
126
- awaiting?: string;
127
- ownership?: string;
128
- cancel_requested_at?: string;
129
- cwd?: string;
130
- }
131
- export interface ResultEntry {
132
- schema: string;
133
- subtask_id: string;
134
- attempt: number;
135
- status: string;
136
- message_id: string;
137
- input_revision: string | null;
138
- outputs: unknown[];
139
- native_ref: unknown;
140
- recorded_at: string;
141
- evidence_ref: string | null;
142
- classification: string;
143
- reason: string | null;
144
- }
145
- export interface Uncertainty {
146
- uncertainty_id: string;
147
- kind: string;
148
- subtask_id: string | null;
149
- attempt: number | null;
150
- detail: string | null;
151
- evidence_ref: string | null;
152
- resolution_hint: string | null;
153
- opened_at: string;
154
- resolved_at: string | null;
155
- resolution: string | null;
156
- resolution_evidence: unknown;
157
- auto_restart: boolean;
158
- resolved_by?: string;
159
- resolution_source?: string;
160
- }
161
- export interface OwnershipSnapshot {
162
- claim_id: string;
163
- holder?: Identity | null;
164
- resource_epoch?: number | null;
165
- released_at?: string | null;
166
- missing?: boolean;
167
- }
168
- export interface HandoffStep {
169
- [key: string]: unknown;
170
- state: string;
171
- at: string;
172
- actor: string;
173
- }
174
- export interface Handoff {
175
- schema: string;
176
- handoff_id: string;
177
- kind: string;
178
- subtask_id: string | null;
179
- attempt: number | null;
180
- from: Identity;
181
- to: Identity;
182
- resources: string[];
183
- ownership_snapshot: OwnershipSnapshot[];
184
- state: string;
185
- owner_epoch: number;
186
- created_at: string;
187
- updated_at: string;
188
- reason: string | null;
189
- steps: HandoffStep[];
190
- partial_outputs: unknown[];
191
- inflight: unknown[];
192
- pending_approvals: unknown[];
193
- confirmation_message_id: string | null;
194
- snapshot_at?: string;
195
- previous_coordinator?: Coordinator | null;
196
- resource_transfers?: {
197
- claim_id: string;
198
- resource_epoch: number;
199
- from: Identity;
200
- }[];
201
- }
202
- export interface AppliedMessage {
203
- message_id: string;
204
- type: string;
205
- subtask_id: string | null;
206
- attempt: number | null;
207
- from: Identity;
208
- to: Identity | null;
209
- reply_to: string | null;
210
- owner_epoch: number | null;
211
- content_digest: string;
212
- at: string;
213
- applied_at: string;
214
- state: string;
215
- detail: string;
216
- body_kind: string | null;
217
- }
218
- export interface Notification {
219
- schema: string;
220
- kind: string;
221
- origin_session: string;
222
- target_session: string;
223
- depth?: number;
224
- task_id: string;
225
- subtask_id?: string | null;
226
- attempt?: number | null;
227
- event?: unknown;
228
- }
229
- export interface NotificationEntry {
230
- notification_id: string;
231
- key: string;
232
- kind: string;
233
- task_id: string;
234
- subtask_id: string | null;
235
- attempt: number | null;
236
- origin_session: string;
237
- target_session: string;
238
- depth: number;
239
- at: string;
240
- decision: string;
241
- reason: string | null;
242
- }
243
- export interface TaskRecord {
244
- [key: string]: unknown;
245
- schema: string;
246
- task_id: string;
247
- domain_id: string;
248
- domain_root: string;
249
- task_root: string;
250
- created_at: string;
251
- updated_at: string;
252
- state_revision: number;
253
- coordinator: Coordinator | null;
254
- input_revision: string | null;
255
- policy: {
256
- [key: string]: unknown;
257
- };
258
- attempts: Attempt[];
259
- messages: AppliedMessage[];
260
- claims: Claim[];
261
- handoffs: Handoff[];
262
- uncertainty: Uncertainty[];
263
- results: ResultEntry[];
264
- native: unknown[];
265
- dispatch_frozen?: boolean;
266
- dispatch_released_at?: string;
267
- dispatch_released_by?: string;
268
- notifications?: NotificationEntry[];
269
- notifications_trimmed?: number;
270
- launch_reservations?: LaunchReservation[];
271
- }
272
- export interface ReservationInput {
273
- reservation_id: string;
274
- subtask_id: string;
275
- attempt: number;
276
- kind: string;
277
- mode: string;
278
- holder: Identity;
279
- requested_session_id: string | null;
280
- phase?: string;
281
- pid?: number;
282
- resume_selector?: string | null;
283
- transport?: string;
284
- [key: string]: unknown;
285
- }
286
- export interface LaunchReservation extends ReservationInput {
287
- reserved_at: string;
288
- released_at: string | null;
289
- outcome: string | null;
290
- exit_code?: number | null;
291
- session_id?: string | null;
292
- run_id?: string | null;
293
- detail?: string | null;
294
- identity_status?: string;
295
- expected_identity?: string | null;
296
- observed_identity?: string | null;
297
- }
298
- export interface Failure {
299
- ok: false;
300
- reason: string;
301
- record?: never;
302
- result?: never;
303
- commit?: never;
304
- [key: string]: unknown;
305
- }
306
- export interface UnreadableRecord {
307
- task_id: string;
308
- __unreadable: true;
309
- claims: Claim[];
310
- }
311
- export interface Mutation<T = unknown> {
312
- ok?: boolean;
313
- commit?: boolean;
314
- record: TaskRecord;
315
- op?: string;
316
- summary?: unknown;
317
- result?: T;
318
- [key: string]: unknown;
319
- }
320
- export interface MessageEffect {
321
- [key: string]: unknown;
322
- entry?: ResultEntry;
323
- }
324
- export type TransactionResult<T> = {
325
- ok: true;
326
- state_revision: number;
327
- result: T | null;
328
- op: string;
329
- } | {
330
- ok: false;
331
- reason: string;
332
- [key: string]: unknown;
333
- };
334
- export interface LockHolder {
335
- schema: string;
336
- nonce: string;
337
- actor: string;
338
- purpose: string;
339
- pid: number;
340
- hostname: string;
341
- acquired_at: string;
342
- }
343
- export interface TransactionFile {
344
- file: string;
345
- revision: unknown;
346
- purpose: unknown;
347
- actor: unknown;
348
- }
349
- export interface Finding {
350
- code: string;
351
- severity: string;
352
- detail: string;
353
- [key: string]: unknown;
354
- }
1
+ /** Persisted protocol types belong to the shared schema layer. */
2
+ export type * from '../schemas/collaboration-state.js';
@@ -1,10 +1,2 @@
1
- import type { TaskRecord, LockHolder, Message, Notification } from './types.js';
2
- /** Decode external JSON as unknown; protocol validators establish the usable shape. */
3
- export declare function object(value: unknown): value is Record<string, unknown>;
4
- export declare function text(value: unknown): value is string;
5
- export declare function errorCode(error: unknown): string | undefined;
6
- export declare function parseJson(text: string): unknown;
7
- export declare function isTaskRecord(value: unknown): value is TaskRecord;
8
- export declare function isLockHolder(value: unknown): value is LockHolder;
9
- export declare function isMessage(value: unknown): value is Message;
10
- export declare function isNotification(value: unknown): value is Notification;
1
+ /** Domain-specific validation is shared with read-only continuity observations. */
2
+ export * from '../schemas/collaboration-state-validation.js';
@@ -1,303 +1,2 @@
1
- /** Decode external JSON as unknown; protocol validators establish the usable shape. */
2
- export function object(value) {
3
- return value !== null && typeof value === 'object' && !Array.isArray(value);
4
- }
5
- export function text(value) {
6
- return typeof value === 'string' && value.trim().length > 0;
7
- }
8
- export function errorCode(error) {
9
- return object(error) && typeof error['code'] === 'string'
10
- ? error['code']
11
- : undefined;
12
- }
13
- export function parseJson(text) {
14
- return JSON.parse(text);
15
- }
16
- const string = (value) => typeof value === 'string';
17
- const number = (value) => typeof value === 'number' && Number.isSafeInteger(value);
18
- const nullable = (test) => (value) => value === null || test(value);
19
- const optional = (test) => (value) => value === undefined || test(value);
20
- const array = (test) => (value) => Array.isArray(value) && value.every(test);
21
- function shape(value, fields) {
22
- return (object(value) &&
23
- Object.entries(fields).every(([key, test]) => test(value[key])));
24
- }
25
- const identity = (value) => shape(value, {
26
- agent_id: string,
27
- session_id: string,
28
- harness: nullable(string),
29
- cwd: optional(string),
30
- });
31
- const coordinator = (value) => identity(value) &&
32
- shape(value, {
33
- owner_epoch: number,
34
- since: string,
35
- previous: optional(nullable((item) => shape(item, {
36
- agent_id: string,
37
- session_id: string,
38
- owner_epoch: number,
39
- }))),
40
- });
41
- const native = (value) => shape(value, {
42
- runner: nullable(string),
43
- session_id: nullable(string),
44
- run_id: nullable(string),
45
- mission_id: nullable(string),
46
- observation: string,
47
- observed_at: nullable(string),
48
- evidence_ref: nullable(string),
49
- manager: optional(string),
50
- launch_kind: optional(string),
51
- mode: optional(string),
52
- identity_status: optional(string),
53
- });
54
- const transition = (value) => shape(value, {
55
- from: nullable(string),
56
- to: string,
57
- at: string,
58
- actor: string,
59
- reason: nullable(string),
60
- });
61
- const approval = (value) => shape(value, { approved_by: string, reason: string });
62
- const attempt = (value) => shape(value, {
63
- subtask_id: string,
64
- attempt: number,
65
- state: string,
66
- owner_epoch: nullable(number),
67
- assignee: identity,
68
- assignment_message_id: string,
69
- assignment_ref: nullable(string),
70
- assignment_digest: nullable(string),
71
- input_revision: nullable(string),
72
- created_at: string,
73
- updated_at: string,
74
- native,
75
- approval: nullable(approval),
76
- transitions: array(transition),
77
- closed_at: optional(string),
78
- awaiting: optional(string),
79
- ownership: optional(string),
80
- cancel_requested_at: optional(string),
81
- cwd: optional(string),
82
- });
83
- const claim = (value) => shape(value, {
84
- claim_id: string,
85
- key: string,
86
- kind: string,
87
- scope: string,
88
- label: string,
89
- path: optional(nullable(string)),
90
- port: optional(nullable(number)),
91
- origin: optional(string),
92
- derived_from: optional(nullable(string)),
93
- access: string,
94
- holder: identity,
95
- resource_epoch: number,
96
- claimed_at: string,
97
- released_at: nullable(string),
98
- subtask_id: nullable(string),
99
- attempt: nullable(number),
100
- note: nullable(string),
101
- cancel_pending: optional((item) => typeof item === 'boolean'),
102
- released_by: optional(string),
103
- release_reason: optional(nullable(string)),
104
- transferred_from: optional(identity),
105
- transferred_at: optional(string),
106
- });
107
- const appliedMessage = (value) => shape(value, {
108
- message_id: string,
109
- type: string,
110
- subtask_id: nullable(string),
111
- attempt: nullable(number),
112
- from: identity,
113
- to: nullable(identity),
114
- reply_to: nullable(string),
115
- owner_epoch: nullable(number),
116
- content_digest: string,
117
- at: string,
118
- applied_at: string,
119
- state: string,
120
- detail: string,
121
- body_kind: nullable(string),
122
- });
123
- const uncertainty = (value) => shape(value, {
124
- uncertainty_id: string,
125
- kind: string,
126
- subtask_id: nullable(string),
127
- attempt: nullable(number),
128
- detail: nullable(string),
129
- evidence_ref: nullable(string),
130
- resolution_hint: nullable(string),
131
- opened_at: string,
132
- resolved_at: nullable(string),
133
- resolution: nullable(string),
134
- auto_restart: (item) => typeof item === 'boolean',
135
- resolved_by: optional(string),
136
- resolution_source: optional(string),
137
- });
138
- const result = (value) => shape(value, {
139
- schema: string,
140
- subtask_id: string,
141
- attempt: number,
142
- status: string,
143
- message_id: string,
144
- input_revision: nullable(string),
145
- outputs: Array.isArray,
146
- recorded_at: string,
147
- evidence_ref: nullable(string),
148
- classification: string,
149
- reason: nullable(string),
150
- });
151
- const snapshot = (value) => shape(value, {
152
- claim_id: string,
153
- holder: optional(nullable(identity)),
154
- resource_epoch: optional(nullable(number)),
155
- released_at: optional(nullable(string)),
156
- missing: optional((item) => typeof item === 'boolean'),
157
- });
158
- const handoff = (value) => shape(value, {
159
- schema: string,
160
- handoff_id: string,
161
- kind: string,
162
- subtask_id: nullable(string),
163
- attempt: nullable(number),
164
- from: identity,
165
- to: identity,
166
- resources: array(string),
167
- ownership_snapshot: array(snapshot),
168
- state: string,
169
- owner_epoch: number,
170
- created_at: string,
171
- updated_at: string,
172
- reason: nullable(string),
173
- steps: array((item) => shape(item, { state: string, at: string, actor: string })),
174
- partial_outputs: Array.isArray,
175
- inflight: Array.isArray,
176
- pending_approvals: Array.isArray,
177
- confirmation_message_id: nullable(string),
178
- snapshot_at: optional(string),
179
- previous_coordinator: optional(nullable(coordinator)),
180
- resource_transfers: optional(array((item) => shape(item, {
181
- claim_id: string,
182
- resource_epoch: number,
183
- from: identity,
184
- }))),
185
- });
186
- const notificationEntry = (value) => shape(value, {
187
- notification_id: string,
188
- key: string,
189
- kind: string,
190
- task_id: string,
191
- subtask_id: nullable(string),
192
- attempt: nullable(number),
193
- origin_session: string,
194
- target_session: string,
195
- depth: number,
196
- at: string,
197
- decision: string,
198
- reason: nullable(string),
199
- });
200
- const reservation = (value) => shape(value, {
201
- reservation_id: string,
202
- subtask_id: string,
203
- attempt: number,
204
- kind: string,
205
- mode: string,
206
- holder: identity,
207
- requested_session_id: nullable(string),
208
- reserved_at: string,
209
- released_at: nullable(string),
210
- outcome: nullable(string),
211
- phase: optional(string),
212
- pid: optional(number),
213
- resume_selector: optional(nullable(string)),
214
- transport: optional(string),
215
- exit_code: optional(nullable(number)),
216
- session_id: optional(nullable(string)),
217
- run_id: optional(nullable(string)),
218
- detail: optional(nullable(string)),
219
- identity_status: optional(string),
220
- expected_identity: optional(nullable(string)),
221
- observed_identity: optional(nullable(string)),
222
- });
223
- export function isTaskRecord(value) {
224
- return shape(value, {
225
- schema: string,
226
- task_id: string,
227
- domain_id: string,
228
- domain_root: string,
229
- task_root: string,
230
- created_at: string,
231
- updated_at: string,
232
- state_revision: number,
233
- coordinator: nullable(coordinator),
234
- input_revision: nullable(string),
235
- policy: object,
236
- attempts: array(attempt),
237
- messages: array(appliedMessage),
238
- claims: array(claim),
239
- handoffs: array(handoff),
240
- uncertainty: array(uncertainty),
241
- results: array(result),
242
- native: Array.isArray,
243
- dispatch_frozen: optional((item) => typeof item === 'boolean'),
244
- dispatch_released_at: optional(string),
245
- dispatch_released_by: optional(string),
246
- notifications: optional(array(notificationEntry)),
247
- notifications_trimmed: optional(number),
248
- launch_reservations: optional(array(reservation)),
249
- });
250
- }
251
- export function isLockHolder(value) {
252
- return shape(value, {
253
- schema: string,
254
- nonce: string,
255
- actor: string,
256
- purpose: string,
257
- pid: number,
258
- hostname: string,
259
- acquired_at: string,
260
- });
261
- }
262
- export function isMessage(value) {
263
- return shape(value, {
264
- schema: string,
265
- message_id: string,
266
- type: string,
267
- task_id: string,
268
- from: identity,
269
- to: identity,
270
- reply_to: nullable(string),
271
- subtask_id: nullable(string),
272
- attempt: nullable(number),
273
- owner_epoch: nullable(number),
274
- created_at: string,
275
- content_digest: nullable(string),
276
- body: (body) => shape(body, {
277
- assignment_ref: optional(nullable(string)),
278
- assignment_digest: optional(nullable(string)),
279
- input_revision: optional(nullable(string)),
280
- approval: optional(approval),
281
- status: optional(string),
282
- kind: optional(string),
283
- phase: optional(string),
284
- handoff_id: optional(string),
285
- resources: optional(array(string)),
286
- reason: optional(nullable(string)),
287
- outputs: optional(Array.isArray),
288
- evidence_ref: optional(nullable(string)),
289
- }),
290
- });
291
- }
292
- export function isNotification(value) {
293
- return shape(value, {
294
- schema: string,
295
- kind: string,
296
- origin_session: string,
297
- target_session: string,
298
- task_id: string,
299
- depth: optional(number),
300
- subtask_id: optional(nullable(string)),
301
- attempt: optional(nullable(number)),
302
- });
303
- }
1
+ /** Domain-specific validation is shared with read-only continuity observations. */
2
+ export * from '../schemas/collaboration-state-validation.js';