@astrosheep/keiyaku 4.6.30 → 4.6.31

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 (398) hide show
  1. package/README.md +5 -5
  2. package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
  3. package/build/plugins/claude/skills/keiyaku/SKILL.md +12 -12
  4. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -16
  5. package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +14 -14
  6. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +10 -10
  7. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +15 -15
  8. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +16 -16
  9. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +21 -21
  10. package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
  11. package/build/plugins/codex/skills/keiyaku/SKILL.md +12 -12
  12. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -16
  13. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +14 -14
  14. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +10 -10
  15. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +15 -15
  16. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +16 -16
  17. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +21 -21
  18. package/build/plugins/opencode/package.json +1 -1
  19. package/build/plugins/opencode/skills/keiyaku/SKILL.md +12 -12
  20. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -16
  21. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +14 -14
  22. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +10 -10
  23. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +15 -15
  24. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +16 -16
  25. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +21 -21
  26. package/build/plugins/pi/README.md +5 -5
  27. package/build/plugins/pi/akuma-tools.ts +17 -23
  28. package/build/skills/keiyaku/SKILL.md +12 -12
  29. package/build/skills/keiyaku-akuma/SKILL.md +16 -16
  30. package/build/skills/keiyaku-akuma/references/automation.md +14 -14
  31. package/build/skills/keiyaku-babysit/SKILL.md +10 -10
  32. package/build/skills/keiyaku-bind/SKILL.md +15 -15
  33. package/build/skills/keiyaku-debt/SKILL.md +16 -16
  34. package/build/skills/keiyaku-workflow/SKILL.md +21 -21
  35. package/build/src/akuma/akuma-call.d.ts +1 -1
  36. package/build/src/akuma/akuma-call.js +9 -9
  37. package/build/src/akuma/akuma-errors.d.ts +5 -5
  38. package/build/src/akuma/akuma-instance.d.ts +355 -12
  39. package/build/src/akuma/akuma-instance.js +20 -20
  40. package/build/src/akuma/akuma-observe.d.ts +11 -12
  41. package/build/src/akuma/akuma-observe.js +34 -26
  42. package/build/src/akuma/akuma-owner.d.ts +32 -11
  43. package/build/src/akuma/akuma-owner.js +35 -16
  44. package/build/src/akuma/akuma-probe.d.ts +3 -3
  45. package/build/src/akuma/akuma-probe.js +2 -2
  46. package/build/src/akuma/akuma-selection-execution.d.ts +985 -1
  47. package/build/src/akuma/akuma-selection-execution.js +42 -18
  48. package/build/src/akuma/akuma-stream.d.ts +2 -2
  49. package/build/src/akuma/akuma-stream.js +1 -1
  50. package/build/src/akuma/akuma-wait.d.ts +5 -5
  51. package/build/src/akuma/akuma-wait.js +52 -14
  52. package/build/src/akuma/akuma.d.ts +245 -271
  53. package/build/src/akuma/akuma.js +98 -46
  54. package/build/src/akuma/archetype.d.ts +19 -6
  55. package/build/src/akuma/archetype.js +25 -9
  56. package/build/src/akuma/body-launch.d.ts +2 -2
  57. package/build/src/akuma/body.js +4 -4
  58. package/build/src/akuma/call-initial-tell.d.ts +60 -44
  59. package/build/src/akuma/call-initial-tell.js +41 -2
  60. package/build/src/akuma/caller.d.ts +26 -17
  61. package/build/src/akuma/caller.js +22 -9
  62. package/build/src/akuma/coordinate.d.ts +9 -0
  63. package/build/src/akuma/coordinate.js +13 -0
  64. package/build/src/akuma/detached-body.js +2 -2
  65. package/build/src/akuma/dispatch-association.d.ts +4 -4
  66. package/build/src/akuma/dispatch-association.js +12 -3
  67. package/build/src/akuma/execution-instructions.js +2 -2
  68. package/build/src/akuma/heart/facts.d.ts +29 -7
  69. package/build/src/akuma/heart/facts.js +13 -0
  70. package/build/src/akuma/heart/index.d.ts +0 -3
  71. package/build/src/akuma/heart/index.js +3 -6
  72. package/build/src/akuma/heart/rows.js +2 -2
  73. package/build/src/akuma/heart/soul.js +5 -5
  74. package/build/src/akuma/identity.d.ts +17 -16
  75. package/build/src/akuma/identity.js +20 -19
  76. package/build/src/akuma/index.d.ts +1 -2
  77. package/build/src/akuma/lineage-cache.d.ts +4 -4
  78. package/build/src/akuma/lineage-cache.js +10 -10
  79. package/build/src/akuma/projection-read.d.ts +2 -5
  80. package/build/src/akuma/projection-read.js +34 -47
  81. package/build/src/akuma/projection.d.ts +659 -569
  82. package/build/src/akuma/projection.js +203 -94
  83. package/build/src/akuma/providers/acp/index.js +1 -1
  84. package/build/src/akuma/providers/execution-environment.d.ts +1 -3
  85. package/build/src/akuma/providers/execution-environment.js +0 -4
  86. package/build/src/akuma/publication.d.ts +2 -2
  87. package/build/src/akuma/publication.js +3 -3
  88. package/build/src/akuma/retention.js +2 -2
  89. package/build/src/akuma/selection-observation.d.ts +507 -43
  90. package/build/src/akuma/selection-observation.js +153 -1
  91. package/build/src/akuma/status-projection.d.ts +288 -0
  92. package/build/src/akuma/status-projection.js +154 -0
  93. package/build/src/akuma/turn-drive.js +0 -3
  94. package/build/src/alias/index.d.ts +9 -4
  95. package/build/src/alias/index.js +11 -9
  96. package/build/src/bounded-list.d.ts +8 -0
  97. package/build/src/bounded-list.js +9 -0
  98. package/build/src/cli/commands/akuma-grammar.d.ts +2 -2
  99. package/build/src/cli/commands/akuma-grammar.js +21 -21
  100. package/build/src/cli/commands/akuma.d.ts +1 -2
  101. package/build/src/cli/commands/akuma.js +115 -251
  102. package/build/src/cli/commands/contract-grammar.d.ts +4 -3
  103. package/build/src/cli/commands/contract-grammar.js +39 -22
  104. package/build/src/cli/commands/contract-help.d.ts +3 -1
  105. package/build/src/cli/commands/contract-help.js +4 -3
  106. package/build/src/cli/commands/contract.d.ts +6 -3
  107. package/build/src/cli/commands/contract.js +203 -434
  108. package/build/src/cli/commands/debt.d.ts +2 -3
  109. package/build/src/cli/commands/debt.js +101 -317
  110. package/build/src/cli/commands/report.js +11 -28
  111. package/build/src/cli/commands/whoami.d.ts +3 -43
  112. package/build/src/cli/commands/whoami.js +8 -121
  113. package/build/src/cli/coordinates.d.ts +4 -35
  114. package/build/src/cli/coordinates.js +13 -129
  115. package/build/src/cli/parse.d.ts +0 -6
  116. package/build/src/cli/parse.js +5 -48
  117. package/build/src/cli/render/akuma-activity.d.ts +31 -16
  118. package/build/src/cli/render/akuma-activity.js +157 -149
  119. package/build/src/cli/render/akuma-tool.d.ts +3 -6
  120. package/build/src/cli/render/akuma-tool.js +20 -14
  121. package/build/src/cli/render/akuma.d.ts +25 -26
  122. package/build/src/cli/render/akuma.js +100 -129
  123. package/build/src/cli/render/catalog.d.ts +4 -7
  124. package/build/src/cli/render/catalog.js +52 -99
  125. package/build/src/cli/render/contract-history.d.ts +3 -1
  126. package/build/src/cli/render/contract-history.js +140 -215
  127. package/build/src/cli/render/contract-observation.d.ts +43 -30
  128. package/build/src/cli/render/contract-observation.js +64 -31
  129. package/build/src/cli/render/contract-wait.js +6 -6
  130. package/build/src/cli/render/contract.d.ts +41 -6
  131. package/build/src/cli/render/contract.js +274 -370
  132. package/build/src/cli/render/debt.d.ts +9 -19
  133. package/build/src/cli/render/debt.js +120 -185
  134. package/build/src/cli/render/delivery-preview.d.ts +4 -3
  135. package/build/src/cli/render/delivery-preview.js +68 -96
  136. package/build/src/cli/render/kanshi-akuma.d.ts +4 -4
  137. package/build/src/cli/render/kanshi-akuma.js +70 -59
  138. package/build/src/cli/render/kanshi.d.ts +4 -4
  139. package/build/src/cli/render/kanshi.js +205 -221
  140. package/build/src/cli/render/marks.d.ts +11 -2
  141. package/build/src/cli/render/marks.js +13 -3
  142. package/build/src/cli/render/nuke.d.ts +3 -3
  143. package/build/src/cli/render/nuke.js +13 -16
  144. package/build/src/cli/render/receipt.d.ts +37 -43
  145. package/build/src/cli/render/receipt.js +313 -236
  146. package/build/src/cli/render/reconcile.d.ts +6 -4
  147. package/build/src/cli/render/reconcile.js +53 -137
  148. package/build/src/cli/render/refusal.d.ts +3 -2
  149. package/build/src/cli/render/refusal.js +73 -54
  150. package/build/src/cli/render/region.d.ts +11 -2
  151. package/build/src/cli/render/region.js +17 -23
  152. package/build/src/cli/render/settings.d.ts +0 -1
  153. package/build/src/cli/render/settings.js +8 -17
  154. package/build/src/cli/render/terminal.d.ts +2 -0
  155. package/build/src/cli/render/verbs.d.ts +4 -0
  156. package/build/src/cli/render/verbs.js +312 -0
  157. package/build/src/cli/render/whoami.d.ts +1 -1
  158. package/build/src/cli/render/whoami.js +24 -31
  159. package/build/src/cli/runtime.d.ts +3 -11
  160. package/build/src/cli/runtime.js +96 -79
  161. package/build/src/cli/scan.d.ts +1 -1
  162. package/build/src/cli/streams.js +1 -0
  163. package/build/src/contract-guidance.js +2 -2
  164. package/build/src/contract-worktree.d.ts +2 -15
  165. package/build/src/contract-worktree.js +19 -35
  166. package/build/src/core/facts/observation.d.ts +4 -5
  167. package/build/src/core/facts/observation.js +7 -9
  168. package/build/src/core/verbs/amend.d.ts +0 -1
  169. package/build/src/core/verbs/amend.js +3 -3
  170. package/build/src/core/verbs/bind.d.ts +0 -1
  171. package/build/src/core/verbs/bind.js +5 -5
  172. package/build/src/core/verbs/deliver.d.ts +3 -2
  173. package/build/src/core/verbs/deliver.js +2 -2
  174. package/build/src/core/verbs/placement.d.ts +0 -5
  175. package/build/src/core/verbs/placement.js +4 -6
  176. package/build/src/core/verbs/reintegrate.d.ts +0 -1
  177. package/build/src/core/verbs/reintegrate.js +2 -2
  178. package/build/src/debt/board.d.ts +132 -116
  179. package/build/src/debt/board.js +138 -94
  180. package/build/src/debt/catalog.d.ts +4 -4
  181. package/build/src/debt/catalog.js +2 -18
  182. package/build/src/debt/context.d.ts +15 -3
  183. package/build/src/debt/context.js +12 -1
  184. package/build/src/debt/created-observation.d.ts +5 -17
  185. package/build/src/debt/created-observation.js +14 -6
  186. package/build/src/debt/document.d.ts +20 -15
  187. package/build/src/debt/document.js +18 -1
  188. package/build/src/debt/index.d.ts +346 -23
  189. package/build/src/debt/index.js +68 -22
  190. package/build/src/debt/input.d.ts +2 -1
  191. package/build/src/debt/input.js +14 -0
  192. package/build/src/debt/lifecycle-operations.d.ts +2 -2
  193. package/build/src/debt/lifecycle-operations.js +14 -22
  194. package/build/src/debt/operation-types.d.ts +188 -66
  195. package/build/src/debt/operation-types.js +113 -1
  196. package/build/src/debt/operations.d.ts +11 -10
  197. package/build/src/debt/operations.js +46 -71
  198. package/build/src/debt/query.d.ts +14 -10
  199. package/build/src/debt/query.js +3 -12
  200. package/build/src/debt/store.d.ts +4 -2
  201. package/build/src/debt/store.js +8 -8
  202. package/build/src/debt/view.d.ts +0 -3
  203. package/build/src/debt/view.js +0 -4
  204. package/build/src/dispatch/index.d.ts +22 -5
  205. package/build/src/dispatch/index.js +46 -37
  206. package/build/src/git/admission.d.ts +2 -2
  207. package/build/src/git/admission.js +2 -1
  208. package/build/src/git/hooks.d.ts +14 -35
  209. package/build/src/git/hooks.js +45 -25
  210. package/build/src/git/integration.d.ts +6 -24
  211. package/build/src/git/integration.js +10 -16
  212. package/build/src/git/private-state-seat.d.ts +2 -2
  213. package/build/src/git/private-state-seat.js +2 -1
  214. package/build/src/git/reconcile.d.ts +17 -79
  215. package/build/src/git/reconcile.js +37 -52
  216. package/build/src/git/scratch.d.ts +3 -3
  217. package/build/src/git/scratch.js +4 -1
  218. package/build/src/git/target-placement.d.ts +23 -31
  219. package/build/src/git/target-placement.js +42 -27
  220. package/build/src/git/target.d.ts +2 -2
  221. package/build/src/git/target.js +2 -1
  222. package/build/src/git/tender.d.ts +7 -39
  223. package/build/src/git/tender.js +21 -54
  224. package/build/src/git/terminal-reconcile.js +15 -18
  225. package/build/src/git/terminal-seal.d.ts +2 -4
  226. package/build/src/git/terminal-seal.js +7 -33
  227. package/build/src/git/workspace.d.ts +65 -41
  228. package/build/src/git/workspace.js +45 -14
  229. package/build/src/identity/selector.d.ts +2 -0
  230. package/build/src/identity/selector.js +13 -3
  231. package/build/src/index.d.ts +48 -54
  232. package/build/src/index.js +31 -43
  233. package/build/src/kanshi/counts.d.ts +42 -8
  234. package/build/src/kanshi/counts.js +13 -2
  235. package/build/src/kanshi/index.d.ts +5 -5
  236. package/build/src/kanshi/index.js +4 -3
  237. package/build/src/kanshi/read.d.ts +489 -6
  238. package/build/src/kanshi/read.js +334 -483
  239. package/build/src/kanshi/report.d.ts +2504 -103
  240. package/build/src/kanshi/report.js +165 -1
  241. package/build/src/kanshi/select.d.ts +0 -8
  242. package/build/src/kanshi/select.js +20 -59
  243. package/build/src/library/address.d.ts +8 -8
  244. package/build/src/library/address.js +7 -7
  245. package/build/src/library/akuma-creation.d.ts +690 -84
  246. package/build/src/library/akuma-creation.js +202 -142
  247. package/build/src/library/akuma-retention.d.ts +2 -2
  248. package/build/src/library/akuma-retention.js +2 -2
  249. package/build/src/library/akumas.d.ts +10 -6
  250. package/build/src/library/akumas.js +24 -7
  251. package/build/src/library/bind.d.ts +28 -54
  252. package/build/src/library/bind.js +6 -4
  253. package/build/src/library/continuation.d.ts +197 -479
  254. package/build/src/library/continuation.js +40 -23
  255. package/build/src/library/contract-address.d.ts +6 -5
  256. package/build/src/library/contract-address.js +5 -7
  257. package/build/src/library/contract-composition.d.ts +18 -12
  258. package/build/src/library/contract-composition.js +55 -47
  259. package/build/src/library/contract-creation.d.ts +3 -2
  260. package/build/src/library/contract-creation.js +38 -32
  261. package/build/src/library/contract-execution.js +77 -38
  262. package/build/src/library/contract-outcomes.d.ts +1877 -27
  263. package/build/src/library/contract-outcomes.js +93 -10
  264. package/build/src/library/contract-settings.d.ts +2 -2
  265. package/build/src/library/contract-settings.js +18 -14
  266. package/build/src/library/contract-types.d.ts +238 -61
  267. package/build/src/library/contract-types.js +131 -1
  268. package/build/src/library/contract-wait.d.ts +38 -17
  269. package/build/src/library/contract-wait.js +40 -10
  270. package/build/src/library/delivery.d.ts +588 -36
  271. package/build/src/library/delivery.js +35 -27
  272. package/build/src/library/input.d.ts +1 -1
  273. package/build/src/library/input.js +1 -2
  274. package/build/src/library/invocation.d.ts +11 -7
  275. package/build/src/library/invocation.js +42 -51
  276. package/build/src/library/kei.d.ts +48 -0
  277. package/build/src/library/kei.js +256 -0
  278. package/build/src/library/keiyaku-attribution.d.ts +11 -0
  279. package/build/src/{cli/delivery-identity.js → library/keiyaku-attribution.js} +12 -1
  280. package/build/src/library/keiyaku-classify.d.ts +11 -0
  281. package/build/src/library/keiyaku-classify.js +146 -0
  282. package/build/src/library/keiyaku-coordinates.d.ts +31 -0
  283. package/build/src/library/keiyaku-coordinates.js +103 -0
  284. package/build/src/library/keiyaku-debt.d.ts +142 -0
  285. package/build/src/library/keiyaku-debt.js +188 -0
  286. package/build/src/library/keiyaku-identity.d.ts +58 -0
  287. package/build/src/library/keiyaku-identity.js +176 -0
  288. package/build/src/library/keiyaku-policy.d.ts +27 -0
  289. package/build/src/library/keiyaku-policy.js +44 -0
  290. package/build/src/library/keiyaku-status.d.ts +1487 -0
  291. package/build/src/library/keiyaku-status.js +92 -0
  292. package/build/src/library/keiyaku-verbs.d.ts +6774 -0
  293. package/build/src/library/keiyaku-verbs.js +458 -0
  294. package/build/src/library/keiyaku.d.ts +871 -38
  295. package/build/src/library/keiyaku.js +677 -127
  296. package/build/src/library/nuke.d.ts +22 -0
  297. package/build/src/library/nuke.js +4 -1
  298. package/build/src/library/outcome.d.ts +706 -692
  299. package/build/src/library/outcome.js +582 -167
  300. package/build/src/library/reconcile.d.ts +464 -116
  301. package/build/src/library/reconcile.js +174 -102
  302. package/build/src/library/refusal.d.ts +113 -577
  303. package/build/src/library/refusal.js +64 -51
  304. package/build/src/library/region.d.ts +5 -24
  305. package/build/src/library/region.js +6 -21
  306. package/build/src/library/selection.d.ts +181 -32
  307. package/build/src/library/selection.js +99 -64
  308. package/build/src/mcp/adapter.d.ts +11 -0
  309. package/build/src/mcp/adapter.js +106 -0
  310. package/build/src/mcp/help.d.ts +1 -0
  311. package/build/src/mcp/help.js +26 -0
  312. package/build/src/mcp/index.d.ts +2 -0
  313. package/build/src/mcp/index.js +37 -0
  314. package/build/src/plugin/public.d.ts +1 -1
  315. package/build/src/plugin/runtime.js +17 -14
  316. package/build/src/protocol/arc.d.ts +4 -1
  317. package/build/src/protocol/arc.js +7 -1
  318. package/build/src/protocol/attempt.d.ts +2 -3
  319. package/build/src/protocol/attempt.js +1 -10
  320. package/build/src/protocol/bind.d.ts +6 -7
  321. package/build/src/protocol/bind.js +9 -5
  322. package/build/src/protocol/completion.d.ts +448 -12
  323. package/build/src/protocol/completion.js +164 -26
  324. package/build/src/protocol/deliver.d.ts +26 -24
  325. package/build/src/protocol/deliver.js +24 -52
  326. package/build/src/protocol/delivery-preview.d.ts +97 -247
  327. package/build/src/protocol/delivery-preview.js +132 -128
  328. package/build/src/protocol/execution-observation.d.ts +146 -123
  329. package/build/src/protocol/execution-observation.js +9 -6
  330. package/build/src/protocol/intent.d.ts +9 -48
  331. package/build/src/protocol/intent.js +32 -46
  332. package/build/src/protocol/operations.d.ts +207 -505
  333. package/build/src/protocol/operations.js +81 -134
  334. package/build/src/protocol/placement.d.ts +0 -1
  335. package/build/src/protocol/placement.js +5 -2
  336. package/build/src/protocol/progress.d.ts +7 -97
  337. package/build/src/protocol/progress.js +7 -55
  338. package/build/src/protocol/read/observation.d.ts +13 -6
  339. package/build/src/protocol/read/observation.js +10 -9
  340. package/build/src/protocol/read/status.d.ts +464 -93
  341. package/build/src/protocol/read/status.js +372 -85
  342. package/build/src/protocol/reconcile.d.ts +2 -0
  343. package/build/src/protocol/reconcile.js +12 -11
  344. package/build/src/protocol/reintegrate.d.ts +0 -1
  345. package/build/src/protocol/reintegrate.js +4 -4
  346. package/build/src/protocol/result-leaves.d.ts +528 -0
  347. package/build/src/protocol/result-leaves.js +195 -0
  348. package/build/src/protocol/result-reasons.d.ts +129 -0
  349. package/build/src/protocol/result-reasons.js +87 -0
  350. package/build/src/protocol/review.d.ts +14 -11
  351. package/build/src/protocol/review.js +30 -14
  352. package/build/src/protocol/run.d.ts +4 -4
  353. package/build/src/protocol/run.js +4 -1
  354. package/build/src/protocol/verify.d.ts +359 -30
  355. package/build/src/protocol/verify.js +118 -28
  356. package/build/src/region.d.ts +26 -0
  357. package/build/src/region.js +28 -0
  358. package/build/src/runtime/proc/diagnostic.d.ts +11 -0
  359. package/build/src/runtime/proc/diagnostic.js +20 -0
  360. package/build/src/runtime/proc/windows-launch.exe +0 -0
  361. package/build/src/settings.d.ts +126 -32
  362. package/build/src/settings.js +107 -34
  363. package/build/src/settlement/settle.d.ts +29 -12
  364. package/build/src/settlement/settle.js +22 -15
  365. package/build/src/verification/declaration.d.ts +1 -3
  366. package/build/src/verification/declaration.js +2 -5
  367. package/build/src/verification/execution.d.ts +7 -19
  368. package/build/src/verification/execution.js +37 -16
  369. package/build/src/verification/observation.d.ts +13 -13
  370. package/build/src/verification/observation.js +9 -7
  371. package/build/src/world.d.ts +8 -0
  372. package/build/src/world.js +7 -0
  373. package/package.json +6 -5
  374. package/plugins/paseo/plugin/server/keiyaku.ts +13 -46
  375. package/plugins/paseo/plugin/server/message.ts +8 -30
  376. package/plugins/paseo/plugin/server/mirror.ts +16 -20
  377. package/plugins/paseo/plugin/server/provider.ts +1 -1
  378. package/plugins/paseo/plugin/server/sdk.ts +14 -6
  379. package/plugins/pi/README.md +5 -5
  380. package/plugins/pi/akuma-tools.ts +17 -23
  381. package/skills/keiyaku/SKILL.md +12 -12
  382. package/skills/keiyaku-akuma/SKILL.md +16 -16
  383. package/skills/keiyaku-akuma/references/automation.md +14 -14
  384. package/skills/keiyaku-babysit/SKILL.md +10 -10
  385. package/skills/keiyaku-bind/SKILL.md +15 -15
  386. package/skills/keiyaku-debt/SKILL.md +16 -16
  387. package/skills/keiyaku-workflow/SKILL.md +21 -21
  388. package/build/src/cli/actor.d.ts +0 -10
  389. package/build/src/cli/actor.js +0 -24
  390. package/build/src/cli/akuma-caller.d.ts +0 -3
  391. package/build/src/cli/akuma-caller.js +0 -31
  392. package/build/src/cli/delivery-identity.d.ts +0 -3
  393. package/build/src/cli/render/effects.d.ts +0 -26
  394. package/build/src/cli/render/effects.js +0 -41
  395. package/build/src/cli/selectors.d.ts +0 -10
  396. package/build/src/cli/selectors.js +0 -42
  397. package/build/src/markdown/diff.d.ts +0 -1
  398. package/build/src/markdown/diff.js +0 -4
@@ -1,13 +1,12 @@
1
1
  import { runHookCommands, worktreeHooksFrom } from "../git/hooks.js";
2
2
  import { ScratchMaterializationError } from "../git/scratch.js";
3
3
  import { runProcess } from "../runtime/proc/run.js";
4
+ import { processDiagnostic as executionDiagnostic } from "../runtime/proc/diagnostic.js";
4
5
  const SUMMARY_BYTES = 32 * 1024;
5
- export function capturedOutput(value) {
6
- return {
7
- ...(value.stdout ? { stdout: value.stdout } : {}),
8
- ...(value.stderr ? { stderr: value.stderr } : {}),
9
- ...(value.truncated === true ? { truncated: true } : {}),
10
- };
6
+ function hasCapturedOutput(output) {
7
+ return ((output.stdout !== undefined && output.stdout.length > 0) ||
8
+ (output.stderr !== undefined && output.stderr.length > 0) ||
9
+ output.truncated === true);
11
10
  }
12
11
  function observe(input, event) {
13
12
  try {
@@ -76,9 +75,11 @@ async function observedHooks(input) {
76
75
  return { kind: "ok" };
77
76
  }
78
77
  function nonterminalOutcome(outcome) {
79
- return outcome.kind === "spawn-error"
80
- ? { kind: outcome.kind, diagnostic: outcome.diagnostic, ...capturedOutput(outcome) }
81
- : { kind: outcome.kind, ...capturedOutput(outcome) };
78
+ if (outcome.kind === "spawn-error")
79
+ return { kind: outcome.kind, diagnostic: executionDiagnostic(outcome) };
80
+ return hasCapturedOutput(outcome)
81
+ ? { kind: outcome.kind, diagnostic: executionDiagnostic(outcome) }
82
+ : { kind: outcome.kind };
82
83
  }
83
84
  async function executeDeclaration(input, cwd) {
84
85
  const { declaration, index } = input;
@@ -111,8 +112,6 @@ async function executeDeclaration(input, cwd) {
111
112
  return {
112
113
  kind: "terminal",
113
114
  verdict: satisfied ? "satisfied" : "unsatisfied",
114
- passed: satisfied ? 1 : 0,
115
- total: 1,
116
115
  ...(summary === undefined ? {} : { summary }),
117
116
  };
118
117
  }
@@ -134,7 +133,13 @@ async function materializeScratch(input) {
134
133
  return {
135
134
  outcome: input.signal?.aborted
136
135
  ? { kind: "cancelled" }
137
- : { kind: "candidate-unavailable", diagnostic: error instanceof Error ? error.message : String(error) },
136
+ : {
137
+ kind: "candidate-unavailable",
138
+ diagnostic: executionDiagnostic({
139
+ kind: "candidate-unavailable",
140
+ diagnostic: error instanceof Error ? error.message : String(error),
141
+ }),
142
+ },
138
143
  ...(error instanceof ScratchMaterializationError ? { leak: error.leak } : {}),
139
144
  };
140
145
  }
@@ -152,10 +157,20 @@ async function runScratch(input, scratch) {
152
157
  environment: process.env,
153
158
  });
154
159
  if (readiness.kind === "cancelled")
155
- return { outcome: { kind: "cancelled", ...capturedOutput(readiness) }, destroy: hooks.destroy };
160
+ return {
161
+ outcome: {
162
+ kind: "cancelled",
163
+ ...(hasCapturedOutput(readiness) ? { diagnostic: executionDiagnostic(readiness) } : {}),
164
+ },
165
+ destroy: hooks.destroy,
166
+ };
156
167
  if (readiness.kind === "failed")
157
168
  return {
158
- outcome: { kind: "environment-failure", name: readiness.name, detail: readiness.failure },
169
+ outcome: {
170
+ kind: "environment-failure",
171
+ name: readiness.name,
172
+ diagnostic: executionDiagnostic(readiness.failure),
173
+ },
159
174
  destroy: hooks.destroy,
160
175
  };
161
176
  return {
@@ -167,7 +182,13 @@ async function runScratch(input, scratch) {
167
182
  return {
168
183
  outcome: input.signal?.aborted
169
184
  ? { kind: "cancelled" }
170
- : { kind: "environment-failure", diagnostic: error instanceof Error ? error.message : String(error) },
185
+ : {
186
+ kind: "environment-failure",
187
+ diagnostic: executionDiagnostic({
188
+ kind: "environment-failure",
189
+ diagnostic: error instanceof Error ? error.message : String(error),
190
+ }),
191
+ },
171
192
  };
172
193
  }
173
194
  }
@@ -185,7 +206,7 @@ async function retireScratch(input, scratch, destroy, outcome) {
185
206
  if (result.kind === "cancelled")
186
207
  throw new Error("scratch destroy cancelled without a signal");
187
208
  if (result.kind === "failed")
188
- cleanup = { phase: "destroy", name: result.name, detail: result.failure };
209
+ cleanup = { name: result.name, diagnostic: executionDiagnostic(result.failure) };
189
210
  }
190
211
  const retain = outcome.kind === "terminal" ? outcome.verdict === "unsatisfied" : outcome.kind !== "cancelled";
191
212
  const leak = await scratch.dispose(retain);
@@ -1,45 +1,45 @@
1
1
  import { z } from "zod";
2
- export declare const verificationObservationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
2
+ export declare const verificationObservationSchema: z.ZodDiscriminatedUnion<[z.ZodReadonly<z.ZodObject<{
3
3
  state: z.ZodEnum<{
4
4
  started: "started";
5
5
  finished: "finished";
6
6
  }>;
7
- outcome: z.ZodOptional<z.ZodString>;
8
- elapsedMs: z.ZodOptional<z.ZodNumber>;
7
+ outcome: z.ZodExactOptional<z.ZodString>;
8
+ elapsedMs: z.ZodExactOptional<z.ZodNumber>;
9
9
  phase: z.ZodEnum<{
10
- materialize: "materialize";
11
10
  cleanup: "cleanup";
11
+ materialize: "materialize";
12
12
  setup: "setup";
13
13
  declaration: "declaration";
14
14
  }>;
15
- cwd: z.ZodOptional<z.ZodString>;
16
- name: z.ZodOptional<z.ZodString>;
17
- command: z.ZodOptional<z.ZodString>;
15
+ cwd: z.ZodExactOptional<z.ZodString>;
16
+ name: z.ZodExactOptional<z.ZodString>;
17
+ command: z.ZodExactOptional<z.ZodString>;
18
18
  requirement: z.ZodString;
19
19
  snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
20
20
  index: z.ZodNumber;
21
21
  total: z.ZodNumber;
22
22
  kind: z.ZodLiteral<"phase">;
23
- }, z.core.$strict>, z.ZodObject<{
23
+ }, z.core.$strict>>, z.ZodReadonly<z.ZodObject<{
24
24
  stream: z.ZodEnum<{
25
25
  stdout: "stdout";
26
26
  stderr: "stderr";
27
27
  }>;
28
28
  text: z.ZodString;
29
29
  phase: z.ZodEnum<{
30
- materialize: "materialize";
31
30
  cleanup: "cleanup";
31
+ materialize: "materialize";
32
32
  setup: "setup";
33
33
  declaration: "declaration";
34
34
  }>;
35
- cwd: z.ZodOptional<z.ZodString>;
36
- name: z.ZodOptional<z.ZodString>;
37
- command: z.ZodOptional<z.ZodString>;
35
+ cwd: z.ZodExactOptional<z.ZodString>;
36
+ name: z.ZodExactOptional<z.ZodString>;
37
+ command: z.ZodExactOptional<z.ZodString>;
38
38
  requirement: z.ZodString;
39
39
  snapshot: z.ZodPipe<z.ZodString, z.ZodTransform<import("../core/facts/types.js").SnapshotId, string>>;
40
40
  index: z.ZodNumber;
41
41
  total: z.ZodNumber;
42
42
  kind: z.ZodLiteral<"output">;
43
- }, z.core.$strict>], "kind">;
43
+ }, z.core.$strict>>], "kind">;
44
44
  /** Attempt-local observations, never testimony, liveness, or recovery authority. */
45
45
  export type VerificationObservation = z.infer<typeof verificationObservationSchema>;
@@ -3,9 +3,9 @@ import { snapshotId } from "../core/facts/types.js";
3
3
  const phase = z.enum(["materialize", "setup", "declaration", "cleanup"]);
4
4
  const coordinate = {
5
5
  phase,
6
- cwd: z.string().optional(),
7
- name: z.string().optional(),
8
- command: z.string().optional(),
6
+ cwd: z.string().exactOptional(),
7
+ name: z.string().exactOptional(),
8
+ command: z.string().exactOptional(),
9
9
  requirement: z.string(),
10
10
  snapshot: z.string().transform(snapshotId),
11
11
  index: z.number().int().positive(),
@@ -17,10 +17,11 @@ export const verificationObservationSchema = z.discriminatedUnion("kind", [
17
17
  kind: z.literal("phase"),
18
18
  ...coordinate,
19
19
  state: z.enum(["started", "finished"]),
20
- outcome: z.string().optional(),
21
- elapsedMs: z.number().nonnegative().optional(),
20
+ outcome: z.string().exactOptional(),
21
+ elapsedMs: z.number().nonnegative().exactOptional(),
22
22
  })
23
- .strict(),
23
+ .strict()
24
+ .readonly(),
24
25
  z
25
26
  .object({
26
27
  kind: z.literal("output"),
@@ -28,5 +29,6 @@ export const verificationObservationSchema = z.discriminatedUnion("kind", [
28
29
  stream: z.enum(["stdout", "stderr"]),
29
30
  text: z.string(),
30
31
  })
31
- .strict(),
32
+ .strict()
33
+ .readonly(),
32
34
  ]);
@@ -1,7 +1,15 @@
1
+ import { z } from "zod";
1
2
  declare const WORLD_BRAND: unique symbol;
2
3
  export type WorldRoot = string & {
3
4
  readonly [WORLD_BRAND]: true;
4
5
  };
6
+ export declare const worldRootSchema: z.ZodPipe<z.ZodString, z.ZodTransform<WorldRoot, string>>;
7
+ export declare const worldResolutionSchema: z.ZodReadonly<z.ZodObject<{
8
+ root: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<WorldRoot, string>>>;
9
+ candidate: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<WorldRoot, string>>>;
10
+ }, z.core.$strict>>;
11
+ export declare const worldLocationSchema: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<WorldRoot, string>>>;
12
+ export declare const worldEstablishedSchema: z.ZodBoolean;
5
13
  export type WorldResolutionInput = Readonly<{
6
14
  cwd: string;
7
15
  repositoryRoot?: string;
@@ -1,6 +1,13 @@
1
+ import { z } from "zod";
1
2
  import { lstat, mkdir, realpath, stat } from "node:fs/promises";
2
3
  import { dirname, join, parse, resolve } from "node:path";
3
4
  const WORLD_BRAND = Symbol("keiyaku.world");
5
+ export const worldRootSchema = z.string().transform(brand);
6
+ export const worldResolutionSchema = z
7
+ .strictObject({ root: worldRootSchema.nullable(), candidate: worldRootSchema.nullable() })
8
+ .readonly();
9
+ export const worldLocationSchema = worldRootSchema.nullable();
10
+ export const worldEstablishedSchema = z.boolean();
4
11
  export class WorldError extends Error {
5
12
  kind = "invalid-world";
6
13
  constructor(message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/keiyaku",
3
- "version": "4.6.30",
3
+ "version": "4.6.31",
4
4
  "workspaces": [
5
5
  "plugins/square",
6
6
  "plugins/paseo/forwarder"
@@ -25,7 +25,8 @@
25
25
  },
26
26
  "bin": {
27
27
  "keiyaku": "build/src/cli/index.js",
28
- "kei": "build/src/cli/index.js"
28
+ "kei": "build/src/cli/index.js",
29
+ "keiyaku-mcp": "build/src/mcp/index.js"
29
30
  },
30
31
  "type": "module",
31
32
  "engines": {
@@ -33,7 +34,7 @@
33
34
  },
34
35
  "scripts": {
35
36
  "release": "npm run test:release && npm version patch && npm publish",
36
- "build": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('build', { recursive: true, force: true })\" && tsc -p tsconfig.json && npm run build --workspace @astrosheep/keiyaku-plugin-square && npm run build --workspace @astrosheep/keiyaku-plugin-paseo && node scripts/copy-plugins.js && node scripts/build-windows-launcher.js && node --input-type=module -e \"import { chmodSync } from 'node:fs'; chmodSync('build/src/cli/index.js', 0o755)\"",
37
+ "build": "node --input-type=module -e \"import { rmSync } from 'node:fs'; rmSync('build', { recursive: true, force: true })\" && tsc -p tsconfig.json && npm run build --workspace @astrosheep/keiyaku-plugin-square && npm run build --workspace @astrosheep/keiyaku-plugin-paseo && node scripts/copy-plugins.js && node scripts/build-windows-launcher.js && node --input-type=module -e \"import { chmodSync } from 'node:fs'; chmodSync('build/src/cli/index.js', 0o755); chmodSync('build/src/mcp/index.js', 0o755)\"",
37
38
  "prepack": "node scripts/verify-package.js",
38
39
  "postpack": "node scripts/verify-package.js",
39
40
  "harness:version": "node scripts/update-harness-version.js",
@@ -81,14 +82,14 @@
81
82
  "dependencies": {
82
83
  "@agentclientprotocol/sdk": "^1.3.0",
83
84
  "@anthropic-ai/claude-agent-sdk": "^0.3.226",
84
- "@astrosheep/keiyaku-plugin-square": "0.1.22",
85
+ "@astrosheep/keiyaku-plugin-square": "0.1.23",
85
86
  "@astrosheep/square": "^0.4.1",
86
87
  "@getpaseo/client": "0.14.0",
87
88
  "@getpaseo/protocol": "0.14.0",
89
+ "@modelcontextprotocol/sdk": "^1.32.1",
88
90
  "@opencode/client": "2.0.20",
89
91
  "@opencode/schema": "2.0.20",
90
92
  "cross-spawn": "^7.0.6",
91
- "diff": "^8.0.4",
92
93
  "undici": "8.10.2",
93
94
  "yaml": "^2.9.0",
94
95
  "zod": "^4.5.2"
@@ -1,51 +1,18 @@
1
1
  import { z } from "zod";
2
+ import type { activityHistorySchema } from "@astrosheep/keiyaku";
2
3
 
3
- const count = z.number().int().nonnegative();
4
- const base = z.object({ sequence: count, at: z.string() });
5
- const turnFields = { turnSequence: count };
6
- const input = z.object({ json: z.string(), truncated: z.boolean() });
7
- const call = z.discriminatedUnion("kind", [
8
- z.object({ kind: z.literal("run"), command: z.string() }),
9
- z.object({ kind: z.literal("read"), path: z.string(), offset: count.optional(), limit: count.optional() }),
10
- z.object({ kind: z.literal("search"), query: z.string(), scope: z.enum(["content", "files", "web"]).optional(),
11
- path: z.string().optional(), glob: z.string().optional() }),
12
- z.object({ kind: z.literal("fileChange"), changes: z.array(z.object({
13
- op: z.enum(["add", "update", "delete", "unspecified"]), path: z.string(),
14
- diffstat: z.object({ added: count, removed: count }).optional(), patch: z.string().optional(),
15
- })) }),
16
- z.object({ kind: z.literal("other"), display: z.string(), input: input.optional() }),
17
- ]);
18
- const knownRow = z.union([
19
- base.extend({ kind: z.literal("turn"), ...turnFields, bodySequence: count.optional() }),
20
- base.extend({ kind: z.literal("report"), ...turnFields, bodySequence: count, text: z.string(),
21
- truncated: z.literal(true).optional() }),
22
- base.extend({ kind: z.literal("tell"), tellId: z.string(), text: z.string(), state: z.enum(["pending", "told"]),
23
- deliveries: z.array(z.object({ deliveredAt: z.string(), route: z.enum(["launch", "live"]),
24
- turnSequence: count, receipt: z.enum(["unavailable", "required"]).optional() })).optional() }),
25
- base.extend({ kind: z.literal("outcome"), ...turnFields, outcome: z.discriminatedUnion("kind", [
26
- z.object({ kind: z.literal("answered"), historyId: z.string().optional(), answer: z.string(),
27
- foldedSaidSequence: count.optional() }),
28
- z.object({ kind: z.literal("failed"), historyId: z.string().optional(), diagnostic: z.string() }),
29
- z.object({ kind: z.literal("canceled"), historyId: z.string().optional() }),
30
- ]) }),
31
- base.extend({ kind: z.literal("tool"), ...turnFields, name: z.string(), toolId: z.string().optional(), call,
32
- state: z.union([z.enum(["active", "unsettled"]), z.object({ status: z.enum(["ok", "error"]),
33
- message: z.string().optional(), exitCode: z.number().int().optional(), output: z.string().optional() })]),
34
- durationMs: z.number().nonnegative().optional(), truncated: z.literal(true).optional() }),
35
- base.extend({ kind: z.enum(["said", "thought", "note", "call"]), ...turnFields, text: z.string(),
36
- truncated: z.literal(true).optional() }),
37
- ]);
38
4
  // Identity is the trust boundary. Never copy a rejected payload into the mirror.
39
5
  const identity = z.object({ kind: z.string().min(1), sequence: z.number().int().positive().safe(),
40
6
  at: z.string().refine((value) => Number.isFinite(Date.parse(value))) }).passthrough();
41
- const row = identity.transform((value) => {
42
- const decoded = knownRow.safeParse(value);
43
- if (decoded.success) return decoded.data;
44
- return { kind: "adapter-diagnostic" as const, sequence: value.sequence, at: value.at,
45
- recordKind: value.kind.slice(0, 80).replace(/[^a-zA-Z0-9_.-]/gu, "?") };
46
- });
47
- export const historySchema = z.object({ rows: z.array(row), omitted: count,
48
- hasEarlier: z.boolean(), hasLater: z.boolean(), historyLost: z.boolean(),
49
- lowestRetained: count.nullable(), highest: count.nullable() });
50
- export type Row = z.infer<typeof row>;
51
- export type History = z.infer<typeof historySchema>;
7
+
8
+ export function createHistorySchema(producer: typeof activityHistorySchema) {
9
+ const row = identity.transform((value) => {
10
+ const decoded = producer.unwrap().shape.rows.unwrap().element.safeParse(value);
11
+ if (decoded.success) return decoded.data;
12
+ return { kind: "adapter-diagnostic" as const, sequence: value.sequence, at: value.at,
13
+ recordKind: value.kind.slice(0, 80).replace(/[^a-zA-Z0-9_.-]/gu, "?") };
14
+ });
15
+ return producer.unwrap().omit({ rows: true }).extend({ rows: z.array(row) });
16
+ }
17
+ export type History = z.output<ReturnType<typeof createHistorySchema>>;
18
+ export type Row = History["rows"][number];
@@ -1,26 +1,8 @@
1
1
  import type { ProviderEvent, ProviderPrompt } from "@getpaseo/plugin/server/provider";
2
- import { z } from "zod";
3
-
4
- const sequence = z.number().int().nonnegative();
5
- export const tellReceiptSchema = z.object({
6
- akuma: z.string(),
7
- tell: z.object({
8
- admission: z.object({ fact: z.literal("recorded"), tellId: z.string().min(1) }),
9
- row: z.object({ kind: z.literal("tell"), sequence, at: z.string(), tellId: z.string().min(1), text: z.string(),
10
- state: z.enum(["pending", "told"]), deliveries: z.array(z.object({
11
- route: z.enum(["live", "launch"]), turnSequence: sequence, deliveredAt: z.string(),
12
- receipt: z.enum(["unavailable", "required"]).optional(),
13
- })).optional() }),
14
- wake: z.discriminatedUnion("kind", [
15
- z.object({ kind: z.literal("told") }), z.object({ kind: z.literal("held") }),
16
- z.object({ kind: z.literal("pursuing"), bodySequence: sequence }),
17
- z.object({ kind: z.literal("failed"), diagnostic: z.string() }),
18
- ]),
19
- }),
20
- });
21
- /** One durable Tell admission and the wake it observed, however that wake settled. */
22
- export type TellAdmission = z.infer<typeof tellReceiptSchema>["tell"];
23
- export type AdmittedMessage = TellAdmission["row"];
2
+ import type { AkumaTellResult } from "@astrosheep/keiyaku";
3
+ /** The installed native owner validates this crossing value. */
4
+ export type TellAdmission = AkumaTellResult;
5
+ export type AdmittedMessage = Readonly<{ tellId: string; text: string; sequence?: number; at?: string }>;
24
6
  /** Submit one plain-text Tell and return its admission receipt. */
25
7
  export type Tell = (world: string, akuId: string, signal: AbortSignal, text: string) => Promise<TellAdmission>;
26
8
  type PromptResult = Extract<ProviderEvent, { type: "session.prompt_result" }>["result"];
@@ -49,12 +31,8 @@ export function messageText(prompt: ProviderPrompt): string {
49
31
  * durable input acceptance, never native delivery: the observed Turn is a host
50
32
  * presentation correlation, never a Heart binding.
51
33
  */
52
- export function tellPresentation(admitted: TellAdmission, steerTurnId?: string): { row: AdmittedMessage; result: PromptResult } {
53
- const { row, wake } = admitted;
54
- if (wake.kind === "failed") console.warn(`Keiyaku Tell ${row.tellId} recorded; wake failed: ${wake.diagnostic}`);
55
- if (steerTurnId !== undefined) return { row, result: { type: "steer", turnId: steerTurnId } };
56
- const delivery = row.deliveries?.at(-1);
57
- if (delivery) return { row, result: { type: "turn", turnId: `turn/${delivery.turnSequence}` } };
58
- // The host may complete its send command; no Akuma outcome is manufactured.
59
- return { row, result: { type: "completed" } };
34
+ export function tellPresentation(admitted: TellAdmission, text: string, steerTurnId?: string): { row: AdmittedMessage; result: PromptResult } {
35
+ const row = { tellId: admitted.tellId, text };
36
+ if (admitted.wake?.kind === "failed") console.warn(`Keiyaku Tell ${admitted.tellId} recorded; wake failed: ${admitted.wake.diagnostic}`);
37
+ return { row, result: steerTurnId === undefined ? { type: "completed" } : { type: "steer", turnId: steerTurnId } };
60
38
  }
@@ -14,7 +14,7 @@ export function createMirror(sessionId: string, emit: Emit) {
14
14
  let submissions = 0;
15
15
  let deferred: History | undefined;
16
16
  let deferredReannounce = false;
17
- const displayedTells = new Map<string, number>();
17
+ const displayedTells = new Map<string, number | undefined>();
18
18
  const item = (value: ProviderTimelineItem, timestamp?: string) => emit({
19
19
  type: "timeline.item", sessionId, item: value, ...(timestamp === undefined ? {} : { timestamp }),
20
20
  });
@@ -29,8 +29,11 @@ export function createMirror(sessionId: string, emit: Emit) {
29
29
  emit({ type: "session.turn", sessionId, turnId: `turn/${target.sequence}`, state,
30
30
  ...(message === undefined ? {} : { error: { message } }) });
31
31
  };
32
- const userMessage = (row: Extract<Row, { kind: "tell" }>, clientMessageId?: string) => {
33
- if (displayedTells.has(row.tellId)) return;
32
+ const userMessage = (row: AdmittedMessage, clientMessageId?: string) => {
33
+ if (displayedTells.has(row.tellId)) {
34
+ if (row.sequence !== undefined) displayedTells.set(row.tellId, row.sequence);
35
+ return;
36
+ }
34
37
  displayedTells.set(row.tellId, row.sequence);
35
38
  item({ type: "user_message", id: `keiyaku:tell/${row.tellId}`, text: row.text,
36
39
  ...(clientMessageId === undefined ? {} : { clientMessageId }) }, row.at);
@@ -46,8 +49,8 @@ export function createMirror(sessionId: string, emit: Emit) {
46
49
  }
47
50
  const latest = rows.filter((row) => row.kind === "turn").sort((a, b) => a.sequence - b.sequence).at(-1);
48
51
  if (latest?.kind === "turn") {
49
- turn = { sequence: latest.turnSequence,
50
- closed: rows.some((row) => row.kind === "outcome" && row.turnSequence === latest.turnSequence) };
52
+ turn = { sequence: latest.sequence,
53
+ closed: rows.some((row) => row.kind === "outcome" && row.turnSequence === latest.sequence) };
51
54
  if (!turn.closed) {
52
55
  openTurns.set(turn.sequence, turn);
53
56
  emit({ type: "session.turn", sessionId, turnId: `turn/${turn.sequence}`, state: "started" });
@@ -71,9 +74,9 @@ export function createMirror(sessionId: string, emit: Emit) {
71
74
  refreshedTurnId() {
72
75
  const latest = deferred?.rows.filter((row) => row.kind === "turn").at(-1);
73
76
  if (latest?.kind !== "turn") return mirror.currentTurnId();
74
- if (deferred?.rows.some((row) => row.kind === "outcome" && row.turnSequence === latest.turnSequence)) return undefined;
75
- if (turn?.sequence === latest.turnSequence && turn.closed) return undefined;
76
- return `turn/${latest.turnSequence}`;
77
+ if (deferred?.rows.some((row) => row.kind === "outcome" && row.turnSequence === latest.sequence)) return undefined;
78
+ if (turn?.sequence === latest.sequence && turn.closed) return undefined;
79
+ return `turn/${latest.sequence}`;
77
80
  },
78
81
  admit(row: AdmittedMessage, clientMessageId: string) {
79
82
  userMessage(row, clientMessageId);
@@ -122,21 +125,14 @@ export function createMirror(sessionId: string, emit: Emit) {
122
125
  } else if (row.kind === "turn") {
123
126
  // Publish retained starts even when their outcomes arrive in this read.
124
127
  // Older starts must not reopen a sealed or superseded Turn.
125
- if (!turn || row.turnSequence > turn.sequence) {
126
- turn = { sequence: row.turnSequence, closed: false };
128
+ if (!turn || row.sequence > turn.sequence) {
129
+ turn = { sequence: row.sequence, closed: false };
127
130
  openTurns.set(turn.sequence, turn);
128
131
  emit({ type: "session.turn", sessionId, turnId: `turn/${turn.sequence}`, state: "started" });
129
132
  }
130
133
  } else if (row.kind === "tool") {
131
- // Tool identity comes from the producer, scoped to its Turn. An older
132
- // CLI without it can show settled records, never guessed live pairing.
133
134
  const state = row.state;
134
- const toolIdentity = row.toolId === undefined ? `record/${row.sequence}` : `${row.turnSequence}/${row.toolId}`;
135
- if (typeof state === "string" && row.toolId === undefined) {
136
- item({ type: "notification", id: `keiyaku:tool/${row.sequence}`, level: "info",
137
- message: `${row.name}: ${state === "active" ? "start observed" : "result not witnessed"}. ${JSON.stringify(row.call)}` }, row.at);
138
- continue;
139
- }
135
+ const toolIdentity = `${row.turnSequence}/${row.toolId}`;
140
136
  const result = typeof state === "object" ? state : undefined;
141
137
  // The result's own output is the observed text; its diagnostic message is
142
138
  // only the stand-in an older producer wrote instead, so an honestly empty
@@ -193,11 +189,11 @@ export function createMirror(sessionId: string, emit: Emit) {
193
189
  covered = { high: Math.max(covered?.high ?? 0, input.highest ?? 0),
194
190
  signatures: new Map(rows.map((row) => [row.sequence, JSON.stringify(row)])) };
195
191
  if (lowest !== undefined) for (const [id, sequence] of displayedTells) {
196
- if (sequence < lowest) displayedTells.delete(id);
192
+ if (sequence !== undefined && sequence < lowest) displayedTells.delete(id);
197
193
  }
198
194
  unhealthy = false;
199
195
  const current = turn;
200
- if (reannounce && current && !current.closed && rows.some((row) => row.kind === "turn" && row.turnSequence === current.sequence))
196
+ if (reannounce && current && !current.closed && rows.some((row) => row.kind === "turn" && row.sequence === current.sequence))
201
197
  emit({ type: "session.turn", sessionId, turnId: `turn/${current.sequence}`, state: "started" });
202
198
  },
203
199
  };
@@ -155,7 +155,7 @@ export function createProvider(transport: AkumaTransport, handoff?: Registration
155
155
  const release = mirror.hold();
156
156
  const submission = (async () => {
157
157
  try {
158
- const admitted = tellPresentation(await transport.tell(world, target.akuId, cancellation.signal, text), steerTurnId);
158
+ const admitted = tellPresentation(await transport.tell(world, target.akuId, cancellation.signal, text), text, steerTurnId);
159
159
  // Observe once while publication is held. An idle send may have
160
160
  // started real work even when its receipt still says pending.
161
161
  await session.observe();
@@ -2,8 +2,8 @@ import { readFile, realpath } from "node:fs/promises";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { z } from "zod";
5
- import { historySchema, type History } from "./keiyaku.js";
6
- import { tellReceiptSchema } from "./message.js";
5
+ import { createHistorySchema, type History } from "./keiyaku.js";
6
+ import type { TellAdmission } from "./message.js";
7
7
  import { stopAttempt } from "./stop.js";
8
8
  import type { AkumaTransport } from "./transport.js";
9
9
 
@@ -18,6 +18,8 @@ type PublicAkuma = {
18
18
  stream(options: Readonly<{ signal: AbortSignal }>): AsyncIterable<unknown>;
19
19
  };
20
20
  type KeiyakuSdk = {
21
+ akumaTellResultSchema: { parse(value: unknown): TellAdmission };
22
+ activityHistorySchema: Parameters<typeof createHistorySchema>[0];
21
23
  Akuma: {
22
24
  prototype: { stream: unknown };
23
25
  select(world: string, akuId: string): PublicAkuma;
@@ -105,6 +107,10 @@ function assertSdkSurface(sdk: KeiyakuSdk, version: string): void {
105
107
  throw new Error(`Installed ${PACKAGE_NAME} version ${version} does not expose Akuma.select`);
106
108
  if (typeof sdk.Akuma.prototype?.stream !== "function")
107
109
  throw new Error(`Installed ${PACKAGE_NAME} version ${version} does not expose Akuma.prototype.stream`);
110
+ if (typeof sdk.akumaTellResultSchema?.parse !== "function")
111
+ throw new Error(`Installed ${PACKAGE_NAME} version ${version} does not expose akumaTellResultSchema`);
112
+ if (typeof sdk.activityHistorySchema?.unwrap !== "function")
113
+ throw new Error(`Installed ${PACKAGE_NAME} version ${version} does not expose activityHistorySchema`);
108
114
  }
109
115
 
110
116
  function abortReason(signal: AbortSignal): Error {
@@ -145,6 +151,7 @@ export function createSdkTransport(options: SdkTransportOptions = {}): AkumaTran
145
151
  let closed = false;
146
152
  let sdk: KeiyakuSdk | undefined;
147
153
  let loading: Promise<KeiyakuSdk> | undefined;
154
+ let historySchema: ReturnType<typeof createHistorySchema>;
148
155
  const active = new Set<ActiveScope>();
149
156
 
150
157
  async function loadSdk(): Promise<KeiyakuSdk> {
@@ -154,6 +161,7 @@ export function createSdkTransport(options: SdkTransportOptions = {}): AkumaTran
154
161
  const resolved = await resolveEntry(options.entry);
155
162
  const loaded = await import(pathToFileURL(resolved.entry).href) as KeiyakuSdk;
156
163
  assertSdkSurface(loaded, resolved.version);
164
+ historySchema = createHistorySchema(loaded.activityHistorySchema);
157
165
  sdk = loaded;
158
166
  return loaded;
159
167
  })();
@@ -205,10 +213,10 @@ export function createSdkTransport(options: SdkTransportOptions = {}): AkumaTran
205
213
 
206
214
  const tell: AkumaTransport["tell"] = async (world, akuId, signal, text) => {
207
215
  const value = await request(world, akuId, signal, (akuma, requestSignal) => akuma.tell(text, { signal: requestSignal }));
208
- const decoded = tellReceiptSchema.parse(value);
209
- if (decoded.akuma !== akuId || decoded.tell.admission.tellId !== decoded.tell.row.tellId || decoded.tell.row.text !== text)
210
- throw new Error("Keiyaku Tell outcome is uncertain: the admission receipt did not name the submitted Tell");
211
- return decoded.tell;
216
+ const decoded = (await loadSdk()).akumaTellResultSchema.parse(value);
217
+ if (decoded.akumaId !== akuId)
218
+ throw new Error("Keiyaku Tell outcome is uncertain: the admission receipt did not name the selected Akuma");
219
+ return decoded;
212
220
  };
213
221
 
214
222
  const stop: AkumaTransport["stop"] = async (world, akuId, signal) => {
@@ -35,9 +35,9 @@ data. No native tool shells out to the CLI.
35
35
 
36
36
  | Tool | Parameters |
37
37
  | --- | --- |
38
- | `akuma_call` | `akuma` definition name, `body`; optional `workdir`, `writableDirectories`, `detach`, `bare`, `wait`, `timeoutMs`, `schema` |
38
+ | `akuma_spawn` | `akuma` definition name, `body`; optional `workdir`, `writableDirectories`, `detach`, `bare`, `wait`, `timeoutMs`, `schema` |
39
39
  | `akuma_status` | `akuma`; optional `repo` |
40
- | `akuma_list` | optional `archetype`, `limit` |
40
+ | `akuma_list` | optional `akumaName`, `limit` |
41
41
  | `akuma_definitions` | optional `limit` |
42
42
  | `akuma_tell` | `akuma`, `body`; optional `interrupt`, `detach`, `repo` |
43
43
  | `akuma_ask` | `akuma`, `body`; optional `interrupt`, `detach`, `schema`, `timeoutMs`, `repo` |
@@ -46,12 +46,12 @@ data. No native tool shells out to the CLI.
46
46
  | `akuma_fork` | `akuma`, `at`; optional `detach`, `bare`, `repo` |
47
47
  | `akuma_kill` | `akuma` array; optional `repo` |
48
48
 
49
- `akuma_call` supports every configured provider, not only Pi. Default
49
+ `akuma_spawn` supports every configured provider, not only Pi. Default
50
50
  `detach: false` launches in the calling Pi session's in-process host scope.
51
51
  Default `wait: false` returns after birth and first-input admission; these are
52
52
  **independent choices**. `wait: true` observes the first answer for up to five
53
- minutes by default. `timeoutMs` on call requires `wait: true`.
54
- Call and Fork pass `bare` through to the SDK: it omits only Keiyaku runtime
53
+ minutes by default. `timeoutMs` on spawn requires `wait: true`.
54
+ Spawn and Fork pass `bare` through to the SDK: it omits only Keiyaku runtime
55
55
  instructions and remains frozen through wake and inherited by forks. Providers
56
56
  without a verified runtime-instruction channel retain their explicit refusal
57
57
  unless the caller opts out.