kiokuko-dsh 0.2.8 → 0.2.9

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 (430) hide show
  1. package/PERMISSIONS.md +1 -1
  2. package/README.ja.md +35 -10
  3. package/README.ko.md +30 -3
  4. package/README.md +36 -12
  5. package/README.zh-CN.md +30 -3
  6. package/THIRD_PARTY_NOTICES.md +4 -0
  7. package/dist/db/transaction.d.ts +2 -1
  8. package/dist/db/transaction.d.ts.map +1 -1
  9. package/dist/db/transaction.js +44 -7
  10. package/dist/db/transaction.js.map +1 -1
  11. package/dist/deep-planning-config.d.ts +32 -0
  12. package/dist/deep-planning-config.d.ts.map +1 -0
  13. package/dist/deep-planning-config.js +20 -0
  14. package/dist/deep-planning-config.js.map +1 -0
  15. package/dist/deep-thinker/core/contracts.d.ts +1 -29
  16. package/dist/deep-thinker/core/contracts.d.ts.map +1 -1
  17. package/dist/deep-thinker/core/contracts.js +2 -17
  18. package/dist/deep-thinker/core/contracts.js.map +1 -1
  19. package/dist/deep-thinker/memory-finalizer.d.ts.map +1 -1
  20. package/dist/deep-thinker/memory-finalizer.js +1 -114
  21. package/dist/deep-thinker/memory-finalizer.js.map +1 -1
  22. package/dist/deep-thinker/native-executor.d.ts.map +1 -1
  23. package/dist/deep-thinker/native-executor.js +3 -4
  24. package/dist/deep-thinker/native-executor.js.map +1 -1
  25. package/dist/deep-thinker/store.js +1 -2
  26. package/dist/deep-thinker/store.js.map +1 -1
  27. package/dist/dsh/agenticreplay-event-mapper.d.ts +1 -1
  28. package/dist/dsh/agenticreplay-event-mapper.d.ts.map +1 -1
  29. package/dist/dsh/agenticreplay-event-mapper.js +5 -1
  30. package/dist/dsh/agenticreplay-event-mapper.js.map +1 -1
  31. package/dist/dsh/agenticreplay-files.d.ts +1 -0
  32. package/dist/dsh/agenticreplay-files.d.ts.map +1 -1
  33. package/dist/dsh/agenticreplay-files.js +19 -2
  34. package/dist/dsh/agenticreplay-files.js.map +1 -1
  35. package/dist/dsh/agenticreplay-host.js +3 -3
  36. package/dist/dsh/agenticreplay-host.js.map +1 -1
  37. package/dist/dsh/agenticreplay-read-service.d.ts +14 -0
  38. package/dist/dsh/agenticreplay-read-service.d.ts.map +1 -1
  39. package/dist/dsh/agenticreplay-read-service.js +17 -0
  40. package/dist/dsh/agenticreplay-read-service.js.map +1 -1
  41. package/dist/dsh/agenticreplay-recorder.d.ts.map +1 -1
  42. package/dist/dsh/agenticreplay-recorder.js +5 -2
  43. package/dist/dsh/agenticreplay-recorder.js.map +1 -1
  44. package/dist/dsh/answer-review/coordinator.js +2 -1
  45. package/dist/dsh/answer-review/coordinator.js.map +1 -1
  46. package/dist/dsh/auto-memory-review.d.ts.map +1 -1
  47. package/dist/dsh/auto-memory-review.js +10 -193
  48. package/dist/dsh/auto-memory-review.js.map +1 -1
  49. package/dist/dsh/coding-workflow/contracts.d.ts +2 -0
  50. package/dist/dsh/coding-workflow/contracts.d.ts.map +1 -1
  51. package/dist/dsh/coding-workflow/contracts.js.map +1 -1
  52. package/dist/dsh/coding-workflow/intent.d.ts.map +1 -1
  53. package/dist/dsh/coding-workflow/intent.js +5 -2
  54. package/dist/dsh/coding-workflow/intent.js.map +1 -1
  55. package/dist/dsh/coding-workflow/service.d.ts +10 -81
  56. package/dist/dsh/coding-workflow/service.d.ts.map +1 -1
  57. package/dist/dsh/coding-workflow/service.js +52 -1
  58. package/dist/dsh/coding-workflow/service.js.map +1 -1
  59. package/dist/dsh/completion-verifiers.d.ts +6 -0
  60. package/dist/dsh/completion-verifiers.d.ts.map +1 -1
  61. package/dist/dsh/completion-verifiers.js.map +1 -1
  62. package/dist/dsh/composition.d.ts +2 -0
  63. package/dist/dsh/composition.d.ts.map +1 -1
  64. package/dist/dsh/composition.js +3 -0
  65. package/dist/dsh/composition.js.map +1 -1
  66. package/dist/dsh/config.d.ts +1 -1
  67. package/dist/dsh/config.d.ts.map +1 -1
  68. package/dist/dsh/config.js +3 -3
  69. package/dist/dsh/config.js.map +1 -1
  70. package/dist/dsh/core/host.d.ts.map +1 -1
  71. package/dist/dsh/core/host.js +151 -33
  72. package/dist/dsh/core/host.js.map +1 -1
  73. package/dist/dsh/core/tasks.d.ts +5 -2
  74. package/dist/dsh/core/tasks.d.ts.map +1 -1
  75. package/dist/dsh/core/tasks.js +124 -93
  76. package/dist/dsh/core/tasks.js.map +1 -1
  77. package/dist/dsh/decisions/request-intent.d.ts +101 -1
  78. package/dist/dsh/decisions/request-intent.d.ts.map +1 -1
  79. package/dist/dsh/decisions/request-intent.js +77 -15
  80. package/dist/dsh/decisions/request-intent.js.map +1 -1
  81. package/dist/dsh/execution-result.d.ts +1 -0
  82. package/dist/dsh/execution-result.d.ts.map +1 -1
  83. package/dist/dsh/execution-support.d.ts +2 -0
  84. package/dist/dsh/execution-support.d.ts.map +1 -1
  85. package/dist/dsh/execution-support.js +39 -4
  86. package/dist/dsh/execution-support.js.map +1 -1
  87. package/dist/dsh/existing-task-intake.d.ts +22 -0
  88. package/dist/dsh/existing-task-intake.d.ts.map +1 -0
  89. package/dist/dsh/existing-task-intake.js +46 -0
  90. package/dist/dsh/existing-task-intake.js.map +1 -0
  91. package/dist/dsh/finalization-request.d.ts +1 -1
  92. package/dist/dsh/finalization-request.d.ts.map +1 -1
  93. package/dist/dsh/finalization-request.js +1 -1
  94. package/dist/dsh/finalization-request.js.map +1 -1
  95. package/dist/dsh/guardrail/contracts.d.ts +85 -0
  96. package/dist/dsh/guardrail/contracts.d.ts.map +1 -0
  97. package/dist/dsh/guardrail/contracts.js +10 -0
  98. package/dist/dsh/guardrail/contracts.js.map +1 -0
  99. package/dist/dsh/guardrail/engine.d.ts +19 -0
  100. package/dist/dsh/guardrail/engine.d.ts.map +1 -0
  101. package/dist/dsh/guardrail/engine.js +178 -0
  102. package/dist/dsh/guardrail/engine.js.map +1 -0
  103. package/dist/dsh/guardrail/evidence.d.ts +16 -0
  104. package/dist/dsh/guardrail/evidence.d.ts.map +1 -0
  105. package/dist/dsh/guardrail/evidence.js +101 -0
  106. package/dist/dsh/guardrail/evidence.js.map +1 -0
  107. package/dist/dsh/guardrail/service.d.ts +27 -0
  108. package/dist/dsh/guardrail/service.d.ts.map +1 -0
  109. package/dist/dsh/guardrail/service.js +253 -0
  110. package/dist/dsh/guardrail/service.js.map +1 -0
  111. package/dist/dsh/host-adapter/admission.d.ts.map +1 -1
  112. package/dist/dsh/host-adapter/admission.js +143 -144
  113. package/dist/dsh/host-adapter/admission.js.map +1 -1
  114. package/dist/dsh/host-adapter/lifecycle.d.ts.map +1 -1
  115. package/dist/dsh/host-adapter/lifecycle.js +104 -90
  116. package/dist/dsh/host-adapter/lifecycle.js.map +1 -1
  117. package/dist/dsh/host-adapter/routing.d.ts.map +1 -1
  118. package/dist/dsh/host-adapter/routing.js +4 -4
  119. package/dist/dsh/host-adapter/routing.js.map +1 -1
  120. package/dist/dsh/host-adapter/turn-state.d.ts +4 -2
  121. package/dist/dsh/host-adapter/turn-state.d.ts.map +1 -1
  122. package/dist/dsh/host-adapter/turn-state.js +14 -7
  123. package/dist/dsh/host-adapter/turn-state.js.map +1 -1
  124. package/dist/dsh/host-adapter.d.ts.map +1 -1
  125. package/dist/dsh/host-adapter.js +115 -24
  126. package/dist/dsh/host-adapter.js.map +1 -1
  127. package/dist/dsh/intake-clarification.js +2 -2
  128. package/dist/dsh/intake-clarification.js.map +1 -1
  129. package/dist/dsh/intake-gate.js +6 -7
  130. package/dist/dsh/intake-gate.js.map +1 -1
  131. package/dist/dsh/legacy-session-codecs.d.ts +1 -0
  132. package/dist/dsh/legacy-session-codecs.d.ts.map +1 -1
  133. package/dist/dsh/legacy-session-codecs.js +831 -127
  134. package/dist/dsh/legacy-session-codecs.js.map +4 -4
  135. package/dist/dsh/lifecycle-memory.d.ts +30 -29
  136. package/dist/dsh/lifecycle-memory.d.ts.map +1 -1
  137. package/dist/dsh/lifecycle-memory.js +309 -431
  138. package/dist/dsh/lifecycle-memory.js.map +1 -1
  139. package/dist/dsh/lisp/candidate.d.ts +2 -2
  140. package/dist/dsh/lisp/ci.d.ts +2 -1
  141. package/dist/dsh/lisp/ci.d.ts.map +1 -1
  142. package/dist/dsh/lisp/ci.js +15 -2
  143. package/dist/dsh/lisp/ci.js.map +1 -1
  144. package/dist/dsh/lisp/contracts.d.ts +1 -18
  145. package/dist/dsh/lisp/contracts.d.ts.map +1 -1
  146. package/dist/dsh/lisp/contracts.js +1 -10
  147. package/dist/dsh/lisp/contracts.js.map +1 -1
  148. package/dist/dsh/lisp/files.d.ts +1 -1
  149. package/dist/dsh/lisp/files.d.ts.map +1 -1
  150. package/dist/dsh/lisp/files.js +17 -4
  151. package/dist/dsh/lisp/files.js.map +1 -1
  152. package/dist/dsh/lisp/hot-store.d.ts.map +1 -1
  153. package/dist/dsh/lisp/hot-store.js +4 -0
  154. package/dist/dsh/lisp/hot-store.js.map +1 -1
  155. package/dist/dsh/lisp/hot-tools.d.ts +2 -0
  156. package/dist/dsh/lisp/hot-tools.d.ts.map +1 -1
  157. package/dist/dsh/lisp/hot-tools.js +10 -0
  158. package/dist/dsh/lisp/hot-tools.js.map +1 -1
  159. package/dist/dsh/lisp/manager.d.ts +14 -1
  160. package/dist/dsh/lisp/manager.d.ts.map +1 -1
  161. package/dist/dsh/lisp/manager.js +238 -37
  162. package/dist/dsh/lisp/manager.js.map +1 -1
  163. package/dist/dsh/lisp/memory-verification.d.ts +5 -2
  164. package/dist/dsh/lisp/memory-verification.d.ts.map +1 -1
  165. package/dist/dsh/lisp/memory-verification.js +5 -1
  166. package/dist/dsh/lisp/memory-verification.js.map +1 -1
  167. package/dist/dsh/lisp/package-manager.d.ts +1 -1
  168. package/dist/dsh/lisp/package-manager.d.ts.map +1 -1
  169. package/dist/dsh/lisp/package-manager.js +10 -1
  170. package/dist/dsh/lisp/package-manager.js.map +1 -1
  171. package/dist/dsh/lisp/packages.d.ts +1 -1
  172. package/dist/dsh/lisp/packages.d.ts.map +1 -1
  173. package/dist/dsh/lisp/packages.js +15 -5
  174. package/dist/dsh/lisp/packages.js.map +1 -1
  175. package/dist/dsh/lisp/proposal-batch.d.ts +2 -0
  176. package/dist/dsh/lisp/proposal-batch.d.ts.map +1 -1
  177. package/dist/dsh/lisp/proposal-batch.js +17 -3
  178. package/dist/dsh/lisp/proposal-batch.js.map +1 -1
  179. package/dist/dsh/lisp/request-surface.d.ts +12 -0
  180. package/dist/dsh/lisp/request-surface.d.ts.map +1 -1
  181. package/dist/dsh/lisp/store.d.ts +2 -1
  182. package/dist/dsh/lisp/store.d.ts.map +1 -1
  183. package/dist/dsh/lisp/store.js +5 -1
  184. package/dist/dsh/lisp/store.js.map +1 -1
  185. package/dist/dsh/lisp/surface.d.ts.map +1 -1
  186. package/dist/dsh/lisp/surface.js +107 -13
  187. package/dist/dsh/lisp/surface.js.map +1 -1
  188. package/dist/dsh/lisp/task-authority.d.ts +29 -0
  189. package/dist/dsh/lisp/task-authority.d.ts.map +1 -0
  190. package/dist/dsh/lisp/task-authority.js +87 -0
  191. package/dist/dsh/lisp/task-authority.js.map +1 -0
  192. package/dist/dsh/lisp/worker.d.ts +3 -1
  193. package/dist/dsh/lisp/worker.d.ts.map +1 -1
  194. package/dist/dsh/lisp/worker.js +26 -4
  195. package/dist/dsh/lisp/worker.js.map +1 -1
  196. package/dist/dsh/lisp-config.d.ts +21 -0
  197. package/dist/dsh/lisp-config.d.ts.map +1 -0
  198. package/dist/dsh/lisp-config.js +13 -0
  199. package/dist/dsh/lisp-config.js.map +1 -0
  200. package/dist/dsh/memory-application.d.ts +3 -2
  201. package/dist/dsh/memory-application.d.ts.map +1 -1
  202. package/dist/dsh/memory-application.js +31 -22
  203. package/dist/dsh/memory-application.js.map +1 -1
  204. package/dist/dsh/model-handoff.d.ts.map +1 -1
  205. package/dist/dsh/model-handoff.js +2 -1
  206. package/dist/dsh/model-handoff.js.map +1 -1
  207. package/dist/dsh/models/service.d.ts.map +1 -1
  208. package/dist/dsh/models/service.js +13 -2
  209. package/dist/dsh/models/service.js.map +1 -1
  210. package/dist/dsh/native-cancellation-observer.d.ts +13 -0
  211. package/dist/dsh/native-cancellation-observer.d.ts.map +1 -0
  212. package/dist/dsh/native-cancellation-observer.js +54 -0
  213. package/dist/dsh/native-cancellation-observer.js.map +1 -0
  214. package/dist/dsh/native-execution-ownership.d.ts +6 -0
  215. package/dist/dsh/native-execution-ownership.d.ts.map +1 -0
  216. package/dist/dsh/native-execution-ownership.js +34 -0
  217. package/dist/dsh/native-execution-ownership.js.map +1 -0
  218. package/dist/dsh/native-subagent.d.ts +2 -2
  219. package/dist/dsh/native-subagent.d.ts.map +1 -1
  220. package/dist/dsh/native-subagent.js +2 -3
  221. package/dist/dsh/native-subagent.js.map +1 -1
  222. package/dist/dsh/native-task-authority.d.ts +66 -0
  223. package/dist/dsh/native-task-authority.d.ts.map +1 -0
  224. package/dist/dsh/native-task-authority.js +220 -0
  225. package/dist/dsh/native-task-authority.js.map +1 -0
  226. package/dist/dsh/on-demand-intake.d.ts +23 -1
  227. package/dist/dsh/on-demand-intake.d.ts.map +1 -1
  228. package/dist/dsh/on-demand-intake.js +171 -10
  229. package/dist/dsh/on-demand-intake.js.map +1 -1
  230. package/dist/dsh/orchestration/execution-owner.js +1 -1
  231. package/dist/dsh/orchestration/execution-owner.js.map +1 -1
  232. package/dist/dsh/orchestration/managed-agent-executor.d.ts +12 -1
  233. package/dist/dsh/orchestration/managed-agent-executor.d.ts.map +1 -1
  234. package/dist/dsh/orchestration/managed-agent-executor.js +28 -2
  235. package/dist/dsh/orchestration/managed-agent-executor.js.map +1 -1
  236. package/dist/dsh/owned-completion-evidence.d.ts +11 -0
  237. package/dist/dsh/owned-completion-evidence.d.ts.map +1 -0
  238. package/dist/dsh/owned-completion-evidence.js +59 -0
  239. package/dist/dsh/owned-completion-evidence.js.map +1 -0
  240. package/dist/dsh/owned-execution.d.ts +28 -1
  241. package/dist/dsh/owned-execution.d.ts.map +1 -1
  242. package/dist/dsh/owned-execution.js +325 -101
  243. package/dist/dsh/owned-execution.js.map +1 -1
  244. package/dist/dsh/owned-read-owner.d.ts +6 -0
  245. package/dist/dsh/owned-read-owner.d.ts.map +1 -0
  246. package/dist/dsh/owned-read-owner.js +22 -0
  247. package/dist/dsh/owned-read-owner.js.map +1 -0
  248. package/dist/dsh/replay-memory-extract.d.ts +36 -0
  249. package/dist/dsh/replay-memory-extract.d.ts.map +1 -0
  250. package/dist/dsh/replay-memory-extract.js +192 -0
  251. package/dist/dsh/replay-memory-extract.js.map +1 -0
  252. package/dist/dsh/semantic-compaction/coordinator.d.ts.map +1 -1
  253. package/dist/dsh/semantic-compaction/coordinator.js +2 -1
  254. package/dist/dsh/semantic-compaction/coordinator.js.map +1 -1
  255. package/dist/dsh/session-bridge.d.ts +3 -0
  256. package/dist/dsh/session-bridge.d.ts.map +1 -1
  257. package/dist/dsh/session-bridge.js +22 -25
  258. package/dist/dsh/session-bridge.js.map +1 -1
  259. package/dist/dsh/session-history-compatibility.d.ts.map +1 -1
  260. package/dist/dsh/session-history-compatibility.js +15 -1
  261. package/dist/dsh/session-history-compatibility.js.map +1 -1
  262. package/dist/dsh/session-history-lookup.d.ts +1 -1
  263. package/dist/dsh/session-history-lookup.d.ts.map +1 -1
  264. package/dist/dsh/session-history-lookup.js +4 -3
  265. package/dist/dsh/session-history-lookup.js.map +1 -1
  266. package/dist/dsh/session-memory-finalizer.d.ts.map +1 -1
  267. package/dist/dsh/session-memory-finalizer.js +129 -117
  268. package/dist/dsh/session-memory-finalizer.js.map +1 -1
  269. package/dist/dsh/setup.d.ts +1 -1
  270. package/dist/dsh/setup.d.ts.map +1 -1
  271. package/dist/dsh/setup.js +1 -1
  272. package/dist/dsh/skill-prompts.json +1 -1
  273. package/dist/dsh/task-authority-context.d.ts +8 -0
  274. package/dist/dsh/task-authority-context.d.ts.map +1 -0
  275. package/dist/dsh/task-authority-context.js +28 -0
  276. package/dist/dsh/task-authority-context.js.map +1 -0
  277. package/dist/dsh/task-completion-host.d.ts +2 -1
  278. package/dist/dsh/task-completion-host.d.ts.map +1 -1
  279. package/dist/dsh/task-completion-host.js +17 -5
  280. package/dist/dsh/task-completion-host.js.map +1 -1
  281. package/dist/dsh/task-completion.d.ts +13 -0
  282. package/dist/dsh/task-completion.d.ts.map +1 -1
  283. package/dist/dsh/task-completion.js +23 -6
  284. package/dist/dsh/task-completion.js.map +1 -1
  285. package/dist/dsh/task-intake.d.ts.map +1 -1
  286. package/dist/dsh/task-intake.js +7 -16
  287. package/dist/dsh/task-intake.js.map +1 -1
  288. package/dist/dsh/task-source-history.d.ts +33 -0
  289. package/dist/dsh/task-source-history.d.ts.map +1 -0
  290. package/dist/dsh/task-source-history.js +62 -0
  291. package/dist/dsh/task-source-history.js.map +1 -0
  292. package/dist/dsh/task-state-host.d.ts +124 -0
  293. package/dist/dsh/task-state-host.d.ts.map +1 -0
  294. package/dist/dsh/task-state-host.js +403 -0
  295. package/dist/dsh/task-state-host.js.map +1 -0
  296. package/dist/dsh/task-state-surface.d.ts +8 -0
  297. package/dist/dsh/task-state-surface.d.ts.map +1 -0
  298. package/dist/dsh/task-state-surface.js +113 -0
  299. package/dist/dsh/task-state-surface.js.map +1 -0
  300. package/dist/dsh/task-state.d.ts +217 -0
  301. package/dist/dsh/task-state.d.ts.map +1 -0
  302. package/dist/dsh/task-state.js +315 -0
  303. package/dist/dsh/task-state.js.map +1 -0
  304. package/dist/dsh/tool-exposure-config.d.ts +12 -0
  305. package/dist/dsh/tool-exposure-config.d.ts.map +1 -0
  306. package/dist/dsh/tool-exposure-config.js +4 -0
  307. package/dist/dsh/tool-exposure-config.js.map +1 -0
  308. package/dist/dsh/tool-exposure.d.ts +2 -11
  309. package/dist/dsh/tool-exposure.d.ts.map +1 -1
  310. package/dist/dsh/tool-exposure.js +2 -2
  311. package/dist/dsh/tool-exposure.js.map +1 -1
  312. package/dist/dsh/tools.d.ts +2 -2
  313. package/dist/dsh/tools.d.ts.map +1 -1
  314. package/dist/dsh/tools.js +3 -2
  315. package/dist/dsh/tools.js.map +1 -1
  316. package/dist/enno-oduno/memory-verification.d.ts +2 -1
  317. package/dist/enno-oduno/memory-verification.d.ts.map +1 -1
  318. package/dist/enno-oduno/memory-verification.js +42 -30
  319. package/dist/enno-oduno/memory-verification.js.map +1 -1
  320. package/dist/enno-oduno/schemas.d.ts +1 -1
  321. package/dist/enno-oduno/store.d.ts +7 -0
  322. package/dist/enno-oduno/store.d.ts.map +1 -1
  323. package/dist/enno-oduno/store.js +42 -0
  324. package/dist/enno-oduno/store.js.map +1 -1
  325. package/dist/ledger/store.d.ts.map +1 -1
  326. package/dist/ledger/store.js +0 -5
  327. package/dist/ledger/store.js.map +1 -1
  328. package/dist/locale/en.json +1 -1
  329. package/dist/locale/ja.json +1 -1
  330. package/dist/locale/ko.json +1 -1
  331. package/dist/locale/zh-CN.json +1 -1
  332. package/dist/memory/auto-globalization.d.ts.map +1 -1
  333. package/dist/memory/auto-globalization.js +4 -82
  334. package/dist/memory/auto-globalization.js.map +1 -1
  335. package/dist/memory/evolution/contracts.d.ts +3 -1
  336. package/dist/memory/evolution/contracts.d.ts.map +1 -1
  337. package/dist/memory/evolution/contracts.js +1 -1
  338. package/dist/memory/evolution/contracts.js.map +1 -1
  339. package/dist/memory/evolution/store.d.ts +2 -1
  340. package/dist/memory/evolution/store.d.ts.map +1 -1
  341. package/dist/memory/evolution/store.js +75 -34
  342. package/dist/memory/evolution/store.js.map +1 -1
  343. package/dist/memory/evolution/worker.d.ts +1 -0
  344. package/dist/memory/evolution/worker.d.ts.map +1 -1
  345. package/dist/memory/evolution/worker.js +6 -18
  346. package/dist/memory/evolution/worker.js.map +1 -1
  347. package/dist/memory/explain.d.ts.map +1 -1
  348. package/dist/memory/explain.js +2 -2
  349. package/dist/memory/explain.js.map +1 -1
  350. package/dist/memory/forget.d.ts.map +1 -1
  351. package/dist/memory/forget.js +12 -3
  352. package/dist/memory/forget.js.map +1 -1
  353. package/dist/memory/index-reasoning/service.d.ts.map +1 -1
  354. package/dist/memory/index-reasoning/service.js +5 -43
  355. package/dist/memory/index-reasoning/service.js.map +1 -1
  356. package/dist/memory/index-reasoning/worker.d.ts.map +1 -1
  357. package/dist/memory/index-reasoning/worker.js +1 -15
  358. package/dist/memory/index-reasoning/worker.js.map +1 -1
  359. package/dist/memory/lifecycle.d.ts +1 -1
  360. package/dist/memory/lifecycle.d.ts.map +1 -1
  361. package/dist/memory/lifecycle.js +4 -79
  362. package/dist/memory/lifecycle.js.map +1 -1
  363. package/dist/memory/replay-review.d.ts +90 -0
  364. package/dist/memory/replay-review.d.ts.map +1 -0
  365. package/dist/memory/replay-review.js +82 -0
  366. package/dist/memory/replay-review.js.map +1 -0
  367. package/dist/memory/replay-store.d.ts +14 -0
  368. package/dist/memory/replay-store.d.ts.map +1 -0
  369. package/dist/memory/replay-store.js +117 -0
  370. package/dist/memory/replay-store.js.map +1 -0
  371. package/dist/memory/review/adoption.d.ts.map +1 -1
  372. package/dist/memory/review/adoption.js +2 -106
  373. package/dist/memory/review/adoption.js.map +1 -1
  374. package/dist/memory/review/store.d.ts.map +1 -1
  375. package/dist/memory/review/store.js +9 -5
  376. package/dist/memory/review/store.js.map +1 -1
  377. package/dist/memory/review/worker.d.ts.map +1 -1
  378. package/dist/memory/review/worker.js +1 -7
  379. package/dist/memory/review/worker.js.map +1 -1
  380. package/dist/memory/scoped-memory.js +1 -1
  381. package/dist/memory/scoped-memory.js.map +1 -1
  382. package/dist/model-tools/contracts.d.ts +2 -2
  383. package/dist/model-tools/contracts.d.ts.map +1 -1
  384. package/dist/model-tools/contracts.js +1 -11
  385. package/dist/model-tools/contracts.js.map +1 -1
  386. package/dist/model-tools/names.d.ts +4 -0
  387. package/dist/model-tools/names.d.ts.map +1 -0
  388. package/dist/model-tools/names.js +13 -0
  389. package/dist/model-tools/names.js.map +1 -0
  390. package/docs/code-intelligence.md +54 -119
  391. package/docs/dsh-plugin.md +86 -9
  392. package/docs/getting-started.md +10 -0
  393. package/docs/guardrail-licenses/Apache-2.0.txt +73 -0
  394. package/docs/guardrail-licenses/BSD-2-Clause.txt +9 -0
  395. package/docs/guardrail-licenses/COPYRIGHT-Rust.txt +34 -0
  396. package/docs/guardrail-licenses/COPYRIGHT-library.html +29357 -0
  397. package/docs/guardrail-licenses/ISC.txt +7 -0
  398. package/docs/guardrail-licenses/LICENSE-APACHE +176 -0
  399. package/docs/guardrail-licenses/LICENSE-MIT +25 -0
  400. package/docs/guardrail-licenses/LLVM-exception.txt +15 -0
  401. package/docs/guardrail-licenses/MIT.txt +9 -0
  402. package/docs/guardrail-licenses/NCSA.txt +29 -0
  403. package/docs/guardrail-licenses/README.md +7 -0
  404. package/docs/guardrail-licenses/Unicode-3.0.txt +39 -0
  405. package/docs/guardrail-licenses/libunwind-LICENSE.txt +311 -0
  406. package/docs/guardrail-licenses/manifest.json +71 -0
  407. package/docs/guardrail-licenses/musl-COPYRIGHT.txt +193 -0
  408. package/docs/guardrail.md +33 -0
  409. package/docs/lisp.md +33 -9
  410. package/docs/memory-evolution.md +6 -6
  411. package/docs/replay-memory-review.md +26 -0
  412. package/guardrail/aarch64-apple-darwin/kiokuko-guardrail +0 -0
  413. package/guardrail/aarch64-apple-darwin/manifest.json +71 -0
  414. package/guardrail/aarch64-unknown-linux-musl/kiokuko-guardrail +0 -0
  415. package/guardrail/aarch64-unknown-linux-musl/manifest.json +69 -0
  416. package/guardrail/manifest.json +204 -0
  417. package/guardrail/node-runner.mjs +37 -0
  418. package/guardrail/protocols/coding-routine.lisp +33 -0
  419. package/guardrail/x86_64-apple-darwin/kiokuko-guardrail +0 -0
  420. package/guardrail/x86_64-apple-darwin/manifest.json +71 -0
  421. package/guardrail/x86_64-unknown-linux-musl/kiokuko-guardrail +0 -0
  422. package/guardrail/x86_64-unknown-linux-musl/manifest.json +68 -0
  423. package/migrations/040_task_state.sql +45 -0
  424. package/migrations/041_task_source_history.sql +88 -0
  425. package/migrations/042_evolution_source_epochs.sql +148 -0
  426. package/package.json +45 -27
  427. package/scripts/guardrail-artifacts.d.mts +13 -0
  428. package/scripts/guardrail-artifacts.mjs +136 -0
  429. package/skills/kiokuko-lisp/SKILL.md +1 -1
  430. package/skills/kiokuko-soul/SKILL.md +6 -6
@@ -1,3 +1,6 @@
1
+ import { nativeExecutionOwnership } from '../native-execution-ownership.js';
2
+ import { NativeTaskAuthority } from '../native-task-authority.js';
3
+ import { readOwnedIdentity } from '../owned-read-owner.js';
1
4
  import { MemoryRequestFence, MemorySnapshotStale } from '../memory-request-fence.js';
2
5
  import { retainedEvents } from '../context-projection.js';
3
6
  import { readAkinatorSession, readRunIntakeLink } from '../../akinator/store.js';
@@ -7,6 +10,9 @@ import { DshAnswerContext } from '../answer-context.js';
7
10
  import { IntakeModeConfig } from '../intake-mode.js';
8
11
  import { isNativeSubagent } from '../native-subagent.js';
9
12
  import { OnDemandIntake } from '../on-demand-intake.js';
13
+ import { DshTaskWorkflow, TASK_STATE_EVENT, TASK_WORKFLOW_SERVICE } from '../task-state-host.js';
14
+ import { mountTaskWorkflowSurface } from '../task-state-surface.js';
15
+ import { findSessionTask, recordTaskUnresolved, readTaskSnapshot, clearTaskUnresolved, authorizeTaskLease, captureTaskLease, taskCanExecute } from '../task-state.js';
10
16
  import { readExecutionOwner } from '../orchestration/execution-owner.js';
11
17
  import { KiokukoError } from '../../errors.js';
12
18
  import { ObservationPackConfig } from '../observation-pack/policy.js';
@@ -26,7 +32,7 @@ import { mountModelAutoCommand } from '../model-auto/command.js';
26
32
  import { nativeModelCatalog } from '../native-model-catalog.js';
27
33
  import { installDshModelRouting } from '../model-routing.js';
28
34
  import { attachmentTypesFromMessages, nativeContextTokens, projectModelBinding } from '../model-auto/policy.js';
29
- import { LISP_CODING_SERVICE } from '../lisp-service-key.js';
35
+ import { LISP_CODING_SERVICE, LISP_ASSEMBLY_SERVICE } from '../lisp-service-key.js';
30
36
  import { SemanticCompactionConfig } from '../semantic-compaction/contracts.js';
31
37
  import { MemoryReuseConfig } from '../../memory/reuse.js';
32
38
  import { MemoryRetrievalConfig } from '../../memory/retrieval-contracts.js';
@@ -61,7 +67,7 @@ import { LedgerStore } from '../../ledger/store.js';
61
67
  import { resolveProjectWorkspaceReadOnly } from '../../memory/workspaces.js';
62
68
  import { readExecutionFrame } from '../execution-frame.js';
63
69
  import { findSecret } from '../../memory/secrets.js';
64
- import { classifyRequestIntent, createRequestIntentContext, rebindRequestIntentDecision, requestIntentMessageRefs, requestIntentReferenceIds, requestIntentTaskType } from '../decisions/request-intent.js';
70
+ import { classifyRequestIntent, createRequestIntentContext, rebindRequestIntentDecision, requestIntentMessageRefs, requestIntentReferenceIds, requestIntentTaskType, requestIntentIsUnresolved } from '../decisions/request-intent.js';
65
71
  import { assertMemoryOwner, createMemoryOwner } from '../memory-owner.js';
66
72
  import { executionClarification } from '../intake-clarification.js';
67
73
  export const CoreConfig = z.object({
@@ -141,9 +147,10 @@ export async function mountCore(ctx, input = {}, registrations = []) {
141
147
  const facts = await runtime.withDatabase(async (db) => {
142
148
  const project = await resolveProjectWorkspaceReadOnly(db, root, { allowDirectory: true });
143
149
  if (!project)
144
- return { activeGoal: undefined, proposals: [] };
145
- let runId = current?.agent === input.agent && current.task.admitted && !current.failed && !current.checkpointed
146
- && current.task.workspace === project.workspace ? current.task.runId : undefined;
150
+ return { activeGoal: undefined, activeTask: undefined, proposals: [] };
151
+ const activeTask = findSessionTask(db, { sessionId: session.id, repositoryRoot: project.repositoryRoot }, { includeLatestTerminal: true });
152
+ let runId = activeTask?.runId ?? (current?.agent === input.agent && current.task.admitted && !current.failed && !current.checkpointed
153
+ && current.task.workspace === project.workspace ? current.task.runId : undefined);
147
154
  if (!runId) {
148
155
  const owner = readExecutionOwner(db, session.id);
149
156
  const run = owner?.run_id ? new LedgerStore(db).readRun(owner.run_id) : undefined;
@@ -152,7 +159,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
152
159
  }
153
160
  }
154
161
  if (!runId)
155
- return { activeGoal: undefined, proposals: [] };
162
+ return { activeGoal: undefined, activeTask, proposals: [] };
156
163
  const workflow = readCodingWorkflow(db, runId);
157
164
  const definition = workflow && !['completed', 'cancelled', 'superseded'].includes(workflow.state) ? workflow.definition : undefined;
158
165
  const activeGoal = workflow && !['completed', 'cancelled', 'superseded'].includes(workflow.state) ? {
@@ -169,7 +176,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
169
176
  .map(condition => ({ id: `condition-${canonicalContentHash([runId, frame.revision, condition.field, condition.text, condition.planRevision])}`,
170
177
  revision: condition.planRevision ?? frame.revision, digest: canonicalContentHash(condition),
171
178
  text: `${condition.field}: ${condition.text}`, field: condition.field }));
172
- return { activeGoal, proposals };
179
+ return { activeGoal, activeTask, proposals };
173
180
  });
174
181
  const precedingAssistant = [...(session.snapshotEvents?.() ?? [])].reverse().find(event => event.type === 'assistant/message'
175
182
  && (coreEventTurn(event) ?? Number.MAX_SAFE_INTEGER) < input.turn);
@@ -188,22 +195,64 @@ export async function mountCore(ctx, input = {}, registrations = []) {
188
195
  digest: canonicalContentHash(text), text }];
189
196
  }
190
197
  }
191
- return createRequestIntentContext({ task, messageRefs, ...(facts.activeGoal ? { activeGoal: facts.activeGoal } : {}), proposals: proposals.slice(0, 8) });
198
+ return createRequestIntentContext({ task, messageRefs, ...(facts.activeGoal ? { activeGoal: facts.activeGoal } : {}), ...(facts.activeTask ? { activeTask: facts.activeTask } : {}), proposals: proposals.slice(0, 8) });
199
+ };
200
+ const persistRequestIntent = async (requestId, context, decision) => {
201
+ if (!context.activeTask)
202
+ return;
203
+ const identity = context.activeTask, contextDigest = canonicalContentHash(context);
204
+ const snapshot = await runtime.withDatabase(db => {
205
+ if (requestIntentIsUnresolved(decision))
206
+ return recordTaskUnresolved(db, identity, {
207
+ operationId: `intent:${canonicalContentHash([requestId, contextDigest, decision?.unresolvedReason ?? 'request_intent_unresolved'])}`,
208
+ expectedRevision: identity.revision, requestId, contextDigest,
209
+ reason: decision?.unresolvedReason ?? 'request_intent_unresolved', evidence: requestIntentReferenceIds(context),
210
+ });
211
+ const current = readTaskSnapshot(db, identity);
212
+ return current.unresolved?.requestId === requestId && current.unresolved.contextDigest === contextDigest
213
+ ? clearTaskUnresolved(db, identity, { requestId, contextDigest, expectedRevision: identity.revision }) : undefined;
214
+ });
215
+ if (snapshot)
216
+ ctx.emit(TASK_STATE_EVENT, snapshot);
192
217
  };
193
218
  const interpretRequestIntent = async (input, task) => {
194
219
  const context = await requestIntentContextFor(input, task);
195
220
  if (!context)
196
221
  return undefined;
197
- const decision = await classifyRequestIntent(decisions, dshTurnRequestId({ dshSessionId: input.agent.session.id, turn: input.turn }), context, input.signal);
222
+ const requestId = dshTurnRequestId({ dshSessionId: input.agent.session.id, turn: input.turn });
223
+ const decision = await classifyRequestIntent(decisions, requestId, context, input.signal);
224
+ await persistRequestIntent(requestId, context, decision);
198
225
  return decision ? { context, decision } : undefined;
199
226
  };
200
227
  const demand = new OnDemandIntake({
201
228
  answerContext: new DshAnswerContext(runtime, { root, projectOnly: true, memoryRetrieval: config.memoryRetrieval,
202
229
  instructions: (input, task, taskType) => answerSkillContext(input, task, taskType, { skills, prompts, decisions, cwd: root }),
203
230
  }),
231
+ nativeOwnership: async (input) => {
232
+ const agent = input.agent;
233
+ bind(agent);
234
+ const session = agent.session;
235
+ if (!session?.header)
236
+ throw new Error('Native ownership requires the current session header');
237
+ const header = session.header;
238
+ if (header.parentSession || header.isSeeded)
239
+ return 'owned';
240
+ const jobs = get('jobs');
241
+ if (jobs && jobs.list(session.id).some(job => !['completed', 'killed', 'failed'].includes(job.status)))
242
+ return 'owned';
243
+ const current = active.get(session.id);
244
+ const ownership = await runtime.withDatabase(db => nativeExecutionOwnership(db, session.id, current?.task.runId));
245
+ input.signal.throwIfAborted();
246
+ // Retire only the exact completed in-memory projection proven above.
247
+ // Durable history remains intact; no memory lookup or save is involved.
248
+ if (ownership === 'unowned' && current && active.get(session.id) === current)
249
+ active.delete(session.id);
250
+ return ownership;
251
+ },
204
252
  nativeChild: agent => agents?.get(agent.id) === agent && sessions?.get(agent.session?.id) === agent.session && isNativeSubagent(agent),
205
253
  validate: async (input) => {
206
254
  bind(input.agent);
255
+ await discardStaleActive(input.agent);
207
256
  await runtime.withDatabase(db => {
208
257
  for (const id of legacyModuleRequirements(db, input.agent.session.id)) {
209
258
  if (!modules.ids().includes(id))
@@ -244,7 +293,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
244
293
  return;
245
294
  const retainsGoal = (requestIntent?.relation === 'same_scope_continuation' || requestIntent?.relation === 'scope_change')
246
295
  && requestIntent.action !== 'answer'
247
- && requestIntent.evidence.runId === current.task.runId;
296
+ && (requestIntent.evidence.runId === current.task.runId || requestIntent.evidence.taskId === current.task.runId);
248
297
  if (retainsGoal)
249
298
  return;
250
299
  await finishSession(sessionId);
@@ -253,24 +302,21 @@ export async function mountCore(ctx, input = {}, registrations = []) {
253
302
  },
254
303
  existing: async (input, requestIntent) => {
255
304
  const sessionId = input.agent.session.id;
256
- const sameScope = requestIntent?.relation === 'same_scope_continuation'
257
- && requestIntent.action !== 'answer' && requestIntent.action !== 'unknown';
258
- if (!sameScope)
305
+ if (requestIntent?.relation !== 'same_scope_continuation' || ['answer', 'unknown'].includes(requestIntent.action))
259
306
  return false;
260
307
  return runtime.withDatabase(async (db) => {
261
308
  const project = await resolveProjectWorkspaceReadOnly(db, root, { allowDirectory: true });
262
309
  if (!project)
263
310
  return false;
264
- const owner = readExecutionOwner(db, sessionId);
265
- if (!owner?.run_id || owner.mode !== 'normal' || owner.workspace !== project.workspace)
266
- return false;
267
- const run = new LedgerStore(db).readRun(owner.run_id);
268
- if (!run || run.status !== 'active' || run.dshSessionId !== sessionId)
311
+ const task = findSessionTask(db, { sessionId, repositoryRoot: project.repositoryRoot });
312
+ if (!task || !taskCanExecute(task) || requestIntent.evidence.taskId !== task.taskId
313
+ || requestIntent.evidence.taskRevision !== task.revision || requestIntent.evidence.taskGeneration !== task.generation)
269
314
  return false;
270
- if (requestIntent?.evidence.runId !== owner.run_id)
315
+ const owner = readExecutionOwner(db, sessionId);
316
+ if (owner && (owner.run_id !== task.runId || owner.mode !== 'normal' || owner.workspace !== project.workspace))
271
317
  return false;
272
- const workflow = readCodingWorkflow(db, owner.run_id);
273
- return !!workflow && !['completed', 'cancelled', 'superseded'].includes(workflow.state);
318
+ captureTaskLease(db, task);
319
+ return true;
274
320
  });
275
321
  },
276
322
  classify: (input, task) => classifyTaskForIntake(decisions, dshTurnRequestId({ dshSessionId: input.agent.session.id, turn: input.turn }), task, undefined, input.signal),
@@ -284,14 +330,32 @@ export async function mountCore(ctx, input = {}, registrations = []) {
284
330
  return false;
285
331
  const current = active.get(agent.session?.id ?? '');
286
332
  return !!current && current.agent === agent && current.agent.session === agent.session && (turn === undefined || current.turn === turn)
287
- && current.task.admitted && !current.failed && !current.checkpointed && !stopped;
333
+ && current.task.admitted && !current.failed && !current.checkpointed && !current.invalidated && !stopped;
288
334
  },
289
335
  }, { onlyWhenDeferred: config.intakeMode === 'eager' });
336
+ const taskWorkflow = new DshTaskWorkflow({ runtime, demand, agents, sessions, skills, tools,
337
+ lisp: () => get(LISP_ASSEMBLY_SERVICE),
338
+ checkpointSource: async (agent) => { bind(agent); await sessions.flush(agent.session); bind(agent); },
339
+ onCompleted: task => lifecycleMemory?.completed(task.taskId, 'completed', task.sessionId, task),
340
+ emit: task => { ctx.emit(TASK_STATE_EVENT, task); } });
290
341
  const conversationSessions = new WeakSet();
291
342
  function bind(agent) {
292
343
  if (!agent?.session || agents?.get(agent.id) !== agent || sessions?.get(agent.session.id) !== agent.session || realpathSync(agent.session.header.cwd) !== root)
293
344
  throw new Error('Native task identity mismatch');
294
345
  }
346
+ async function discardStaleActive(agent) {
347
+ const current = active.get(agent.session.id);
348
+ if (!current || current.agent !== agent || !current.task.authority)
349
+ return;
350
+ try {
351
+ await runtime.withDatabase(db => authorizeTaskLease(db, current.task.authority));
352
+ }
353
+ catch {
354
+ current.invalidated = true;
355
+ if (active.get(agent.session.id) === current)
356
+ active.delete(agent.session.id);
357
+ }
358
+ }
295
359
  function track(promise) {
296
360
  pending.add(promise);
297
361
  void promise.then(() => pending.delete(promise), () => pending.delete(promise));
@@ -304,6 +368,9 @@ export async function mountCore(ctx, input = {}, registrations = []) {
304
368
  if (current.finishing)
305
369
  return current.finishing;
306
370
  bind(current.agent);
371
+ await discardStaleActive(current.agent);
372
+ if (active.get(sessionId) !== current)
373
+ return;
307
374
  const boundary = [...current.agent.session.snapshotEvents()].reverse().find(event => event.type === 'turn/end' && event.data?.turn === current.turn);
308
375
  const reason = boundary?.data?.reason?.kind;
309
376
  if (!['completed', 'error', 'aborted', 'max-tokens', 'blocked'].includes(reason))
@@ -371,6 +438,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
371
438
  }
372
439
  async function prepareCoreTask(payload, signal, advisoryType, suppliedIntent, suppliedContext) {
373
440
  const key = `${payload.agent.session.id}\u0000${payload.turn}`;
441
+ await discardStaleActive(payload.agent);
374
442
  const existing = active.get(payload.agent.session.id);
375
443
  const newText = humanTask(payload.messages);
376
444
  const steering = existing?.turn === payload.turn && newText.length > 0 && newText !== existing.taskText;
@@ -401,9 +469,11 @@ export async function mountCore(ctx, input = {}, registrations = []) {
401
469
  else if (!exactPreparedRequest && requestIntentContext) {
402
470
  requestIntent = await classifyRequestIntent(decisions, requestId, requestIntentContext, signal);
403
471
  }
472
+ if (requestIntentContext)
473
+ await persistRequestIntent(requestId, requestIntentContext, requestIntent);
404
474
  const intentUnresolved = requestIntent?.relation === 'unknown' || requestIntent?.action === 'unknown';
405
475
  const legacyTaskTypeAllowed = advisoryType !== undefined && advisoryType !== 'chat'
406
- && !requestIntentContext?.activeGoal && (requestIntentContext?.proposals.length ?? 0) === 0;
476
+ && !requestIntentContext?.activeGoal && !requestIntentContext?.activeTask && (requestIntentContext?.proposals.length ?? 0) === 0;
407
477
  if ((intentUnresolved && !legacyTaskTypeAllowed) || requestIntent?.action === 'answer') {
408
478
  throw new KiokukoError('CONFLICT', 'request_intent_unresolved');
409
479
  }
@@ -412,7 +482,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
412
482
  throw new KiokukoError('VALIDATION_ERROR', clarification);
413
483
  if (intentUnresolved && legacyTaskTypeAllowed)
414
484
  requestIntent = undefined;
415
- if (requestIntentContext?.activeGoal && requestIntent === undefined) {
485
+ if ((requestIntentContext?.activeGoal || requestIntentContext?.activeTask) && requestIntent === undefined) {
416
486
  throw new KiokukoError('CONFLICT', 'request_intent_required_for_active_goal');
417
487
  }
418
488
  const resumesScope = requestIntent && (requestIntent.relation === 'same_scope_continuation' || requestIntent.relation === 'scope_change');
@@ -485,7 +555,22 @@ export async function mountCore(ctx, input = {}, registrations = []) {
485
555
  throw new Error('Native capability inventory is incomplete');
486
556
  const schemas = stableLispCapabilities(await tools.schemas(payload.agent), payload.agent);
487
557
  request = { ...request, capabilities: [...snapshot.skills.filter((skill) => skill.invocation?.modelInvocable !== false).map((skill) => ({ kind: 'skill', name: skill.name, ...(skill.description ? { description: skill.description } : {}) })),
488
- ...schemas.map((tool) => ({ kind: 'tool', name: tool.name, ...(tool.description ? { description: tool.description } : {}) }))] };
558
+ ...schemas.map((tool) => ({ kind: 'tool', name: tool.name, ...(tool.description ? { description: tool.description } : {}) }))],
559
+ validateCapabilities: async () => {
560
+ signal.throwIfAborted();
561
+ bind(payload.agent);
562
+ const latest = await skills.snapshot({ scope: payload.agent, cwd: root, signal });
563
+ if (!latest.complete)
564
+ throw new Error('Native capability inventory is incomplete');
565
+ const latestSchemas = stableLispCapabilities(await tools.schemas(payload.agent), payload.agent);
566
+ const capabilities = [...latest.skills.filter((skill) => skill.invocation?.modelInvocable !== false)
567
+ .map((skill) => ({ kind: 'skill', name: skill.name, ...(skill.description ? { description: skill.description } : {}) })),
568
+ ...latestSchemas.map((tool) => ({ kind: 'tool', name: tool.name, ...(tool.description ? { description: tool.description } : {}) }))];
569
+ signal.throwIfAborted();
570
+ bind(payload.agent);
571
+ if (capabilityCatalogDigest(capabilities) !== capabilityCatalogDigest(request.capabilities))
572
+ throw new Error('Native capabilities changed during intake');
573
+ } };
489
574
  const resuming = !!resumesScope;
490
575
  let task = resuming ? await tasks.resume(request) : await tasks.prepare(request);
491
576
  if (resuming && requestIntent?.relation === 'same_scope_continuation' && task.memoryOwner?.kind === 'execution') {
@@ -521,6 +606,11 @@ export async function mountCore(ctx, input = {}, registrations = []) {
521
606
  attachmentTypes: attachmentTypesFromMessages(payload.messages), failed: false, checkpointed: false, contextDelivered: false, memoryRebuildAttempts: 0 });
522
607
  if (!task.admitted)
523
608
  return task;
609
+ const authority = task.authority;
610
+ if (!authority)
611
+ throw new Error('Admitted core task has no repository authority');
612
+ const taskSnapshot = await runtime.withDatabase(db => authorizeTaskLease(db, authority));
613
+ ctx.emit(TASK_STATE_EVENT, taskSnapshot);
524
614
  if (task.profile.taskType === 'chat')
525
615
  conversationSessions.add(payload.agent.session);
526
616
  else
@@ -530,7 +620,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
530
620
  answerReview.bind({ runId: task.runId, workspace: task.workspace, requestId: task.requestId, task: text, catalogDigest: capabilityCatalogDigest(task.capabilities),
531
621
  turn: payload.turn, agent: reviewAgent,
532
622
  current: () => active.get(task.sessionId) === owner && agents?.get(payload.agent.id) === payload.agent && sessions?.get(task.sessionId) === payload.agent.session,
533
- eligible: () => !stopped && owner.task.admitted && !owner.failed && !owner.checkpointed && !reviewAgent.session.header?.parentSession && reviewAgent.session.header?.origin !== 'subagent' && !reviewAgent.session.header?.delegationDepth,
623
+ eligible: () => !stopped && owner.task.admitted && !owner.failed && !owner.checkpointed && !isNativeSubagent(reviewAgent),
534
624
  settled: async () => { if (active.get(task.sessionId) === owner)
535
625
  await finishSession(task.sessionId); },
536
626
  });
@@ -613,7 +703,14 @@ export async function mountCore(ctx, input = {}, registrations = []) {
613
703
  if (!skills?.registerProvider || !skills.snapshot || !tools?.schemas || !tools.guard || !tools.register || !sessions?.get || !sessions.flush || !agents?.get || !systemPrompt?.section)
614
704
  throw new Error('Core requires native Skill, prompt, tool, session and agent services');
615
705
  await runtime.start();
706
+ disposers.push(ctx.on(TASK_STATE_EVENT, (snapshot) => {
707
+ const current = active.get(snapshot.sessionId);
708
+ if (current?.task.authority && current.task.runId === snapshot.taskId
709
+ && (current.task.authority.revision !== snapshot.revision || current.task.authority.generation !== snapshot.generation))
710
+ current.invalidated = true;
711
+ }));
616
712
  lifecycleMemory = new DshLifecycleMemory(ctx, runtime, root);
713
+ lifecycleMemory.connectIntake(demand);
617
714
  await decisions.initialize();
618
715
  const provider = configuredSkillProvider(modules.resources(), prompts);
619
716
  disposers.push(() => provider.dispose());
@@ -631,13 +728,33 @@ export async function mountCore(ctx, input = {}, registrations = []) {
631
728
  throw new Error('Native ingress already has an owner'); claimed = true; },
632
729
  beforeTask(handler) { beforeTask.add(handler); return () => { beforeTask.delete(handler); }; } });
633
730
  if (!claimed) {
634
- const resolveOwned = (execution) => {
731
+ // The native-ingress owner also owns its task-control surface and intake proofs.
732
+ disposers.push(mountTaskWorkflowSurface(ctx, taskWorkflow, demand));
733
+ const resolveParentOwned = (execution) => {
635
734
  if (!execution.agent)
636
735
  return undefined;
637
736
  bind(execution.agent);
638
737
  const current = active.get(execution.agent.session.id);
639
- return current && current.agent === execution.agent && current.task.admitted && !current.failed && !current.checkpointed
640
- ? { ...current.task, repositoryRoot: root, generation: canonicalContentHash({ run: current.task.runId, task: current.taskText }), agent: execution.agent } : undefined;
738
+ return current && current.agent === execution.agent && current.task.admitted && current.task.authority && !current.failed && !current.checkpointed
739
+ ? { ...current.task, repositoryRoot: current.task.authority.repositoryRoot, generation: canonicalContentHash({ run: current.task.runId, task: current.taskText }), agent: execution.agent } : undefined;
740
+ };
741
+ const nativeTaskAuthority = new NativeTaskAuthority({ runtime, repositoryRoot: root, backend: get('subagents'), agents, sessions, resolveParent: resolveParentOwned });
742
+ disposers.push(() => nativeTaskAuthority.dispose());
743
+ const resolveOwned = (execution) => nativeTaskAuthority.resolve(execution) ?? resolveParentOwned(execution);
744
+ const resolveOwnedRead = async (execution) => {
745
+ if (!execution.agent)
746
+ return undefined;
747
+ bind(execution.agent);
748
+ if (isNativeSubagent(execution.agent))
749
+ return nativeTaskAuthority.read(execution);
750
+ const current = resolveParentOwned(execution);
751
+ if (execution.name === 'kioku_read' && current)
752
+ return current;
753
+ return await runtime.withDatabase(async (db) => {
754
+ const project = await resolveProjectWorkspaceReadOnly(db, root, { allowDirectory: true });
755
+ return project ? readOwnedIdentity(db, execution.agent, project.repositoryRoot, execution.name === 'kioku_result' ? execution.arguments?.operationId : undefined) : undefined;
756
+ })
757
+ ?? resolveParentOwned(execution);
641
758
  };
642
759
  disposers.push(mountTaskCompletion({ tools, on: ctx.on.bind(ctx) }, { runtime, resolve: resolveOwned, approve: async () => true }));
643
760
  disposers.push(mountCodingWorkflow({ tools, on: ctx.on.bind(ctx) }, { runtime,
@@ -695,7 +812,9 @@ export async function mountCore(ctx, input = {}, registrations = []) {
695
812
  return memory;
696
813
  },
697
814
  }));
698
- disposers.push(mountOwnedExecution({ tools, on: ctx.on.bind(ctx) }, { runtime, resolve: resolveOwned,
815
+ disposers.push(mountOwnedExecution({ tools, on: ctx.on.bind(ctx) }, { runtime, resolve: resolveOwned, resolveRead: resolveOwnedRead,
816
+ unownedNative: execution => demand?.unownedNative(execution) === true,
817
+ isTaskControl: execution => get(TASK_WORKFLOW_SERVICE)?.isControl(execution) === true,
699
818
  planActive: agent => get('planMode')?.get(agent)?.active === true,
700
819
  async confirm(identity, detail, signal) {
701
820
  if (!questions)
@@ -748,7 +867,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
748
867
  if (mode === 'off')
749
868
  return undefined;
750
869
  if (!owner || owner.agent !== agent || !owner.task.admitted || owner.failed || owner.checkpointed
751
- || agent.session.header.parentSession || agent.session.header.origin === 'subagent' || agent.session.header.delegationDepth)
870
+ || isNativeSubagent(agent))
752
871
  return { kind: 'native' };
753
872
  if (get(LISP_CODING_SERVICE)?.enabled(agent))
754
873
  return { kind: 'native' };
@@ -958,7 +1077,7 @@ export async function mountCore(ctx, input = {}, registrations = []) {
958
1077
  return undefined;
959
1078
  }));
960
1079
  const argumentsSchema = z.object({ outcome: z.enum(['completed', 'failed', 'cancelled']), memories: z.array(z.unknown()).max(100).optional(), evidence: z.unknown().optional() }).strict();
961
- disposers.push(tools.register({ name: 'memory_checkpoint', description: 'Save durable project memory for this admitted request.', modelFacing: true, output: { schema: {}, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] }, parameters: JSON.parse(JSON.stringify(z.toJSONSchema(argumentsSchema))),
1080
+ disposers.push(tools.register({ name: 'memory_checkpoint', description: 'Memory saving requires post-task human review. This legacy tool does not save memories.', modelFacing: true, output: { schema: {}, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] }, parameters: JSON.parse(JSON.stringify(z.toJSONSchema(argumentsSchema))),
962
1081
  execute: (args, execution) => track((async () => {
963
1082
  if (stopped)
964
1083
  throw new Error('Core is stopped');
@@ -967,7 +1086,6 @@ export async function mountCore(ctx, input = {}, registrations = []) {
967
1086
  if (!current || current.agent !== execution.agent || current.checkpointed || execution.name !== 'memory_checkpoint')
968
1087
  throw new Error('No open bound task for memory checkpoint');
969
1088
  const result = await tasks.checkpoint(current.task, argumentsSchema.parse(args), execution.signal);
970
- current.checkpointed = true;
971
1089
  return result;
972
1090
  })()) }));
973
1091
  }