@xopcai/xopc 0.0.460 → 0.0.462

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 (264) hide show
  1. package/dist/browser-ext/dist/assets/{pcm-capture-worklet-CGN9Mlhg.js → pcm-capture-worklet-Df5TcFw4.js} +4 -2
  2. package/dist/browser-ext/dist/sidepanel.js +3 -2
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agents-CGUdvmIT.js → agents-DC0lHtl5.js} +3 -3
  6. package/dist/gateway/static/root/assets/{apps-page-M2XD1Pzu.js → apps-page-QLOYw2QR.js} +1 -1
  7. package/dist/gateway/static/root/assets/{automation-task-card-CiJmJ7_h.js → automation-task-card-CJbIHRxN.js} +1 -1
  8. package/dist/gateway/static/root/assets/{automations-page-CVjgENMO.js → automations-page-DpKnqajR.js} +1 -1
  9. package/dist/gateway/static/root/assets/{automations-workspace-CGPWyL0P.js → automations-workspace-BXT_EDON.js} +2 -2
  10. package/dist/gateway/static/root/assets/{block-editor-CmnkluMF.js → block-editor-DrZyRQQ0.js} +5 -5
  11. package/dist/gateway/static/root/assets/{capabilities-DDqDvCBs.js → capabilities-Dr-vvMez.js} +1 -1
  12. package/dist/gateway/static/root/assets/capabilities-hSb-qEgL.js +1 -0
  13. package/dist/gateway/static/root/assets/capabilities-page-CnU0htlO.js +2 -0
  14. package/dist/gateway/static/root/assets/{capabilities-settings-panel-CvF8VRTv.js → capabilities-settings-panel-B08mjrGB.js} +1 -1
  15. package/dist/gateway/static/root/assets/{channels-BDVQ6Z7A.js → channels-B--IHNs4.js} +1 -1
  16. package/dist/gateway/static/root/assets/{chat-chart-block-stPJEZ90.js → chat-chart-block-ClCZyIi0.js} +1 -1
  17. package/dist/gateway/static/root/assets/chat-page-U2a7d6wP.js +71 -0
  18. package/dist/gateway/static/root/assets/{chat-terminal-dock-B4uA_W6R.js → chat-terminal-dock-eneTvxV3.js} +1 -1
  19. package/dist/gateway/static/root/assets/{connectors-page-DyzDVVfz.js → connectors-page-Bs29RvXz.js} +1 -1
  20. package/dist/gateway/static/root/assets/constants-Bg1wM2nv.js +1 -0
  21. package/dist/gateway/static/root/assets/diagnostics-Bo0Z42P_.js +1 -0
  22. package/dist/gateway/static/root/assets/{extension-debug-page-BPwRrP3L.js → extension-debug-page-Bn_5xu_M.js} +1 -1
  23. package/dist/gateway/static/root/assets/{extension-iframe-host-DIH4TcdH.js → extension-iframe-host-Vs6USa0c.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-message-router-C9JDpo_7.js → extension-message-router-GIekDj_w.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-page-CLDoL5N8.js → extension-page-C_3bIjSB.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-provider-BPIoHw4r.js → extension-provider-D-LolObs.js} +1 -1
  27. package/dist/gateway/static/root/assets/{extension-settings-page-BO_UKeG8.js → extension-settings-page-BV51dk16.js} +1 -1
  28. package/dist/gateway/static/root/assets/home-page-DefKShSW.js +8 -0
  29. package/dist/gateway/static/root/assets/index-CChzK_5b.css +1 -0
  30. package/dist/gateway/static/root/assets/index-CEBDMkde.js +11 -0
  31. package/dist/gateway/static/root/assets/{local-app-workbench-page-D8oqDDAn.js → local-app-workbench-page-CfnixDO3.js} +1 -1
  32. package/dist/gateway/static/root/assets/{markdown-view-BlxIaCCQ.js → markdown-view-CNJaAdNN.js} +39 -39
  33. package/dist/gateway/static/root/assets/note-detail-panel-D_l5jkV9.js +7 -0
  34. package/dist/gateway/static/root/assets/note-image-lightbox-D6mvMSKr.js +1 -0
  35. package/dist/gateway/static/root/assets/{notes-api-CdXA-g9r.js → notes-api-BOIM9Q_D.js} +1 -1
  36. package/dist/gateway/static/root/assets/notes-page-R4uJroeD.js +8 -0
  37. package/dist/gateway/static/root/assets/{page-context-capture-button-Dibmspef.js → page-context-capture-button-B_Vdo2Ai.js} +1 -1
  38. package/dist/gateway/static/root/assets/pcm-capture-worklet-CpXsv44v.js +1 -0
  39. package/dist/gateway/static/root/assets/{personal-page-BwfyW7Hx.js → personal-page-BsONyPfQ.js} +1 -1
  40. package/dist/gateway/static/root/assets/{personal-profile-settings-CQhZjoK6.js → personal-profile-settings-C4CxmQLQ.js} +1 -1
  41. package/dist/gateway/static/root/assets/{personal-settings-panel-peD05ktj.js → personal-settings-panel-CnxI2TL0.js} +1 -1
  42. package/dist/gateway/static/root/assets/{product-automation-feedback-D51I7Lg3.js → product-automation-feedback-CGso8wGv.js} +1 -1
  43. package/dist/gateway/static/root/assets/{product-preview-content-WkF2j_c-.js → product-preview-content-Dgtb4LF7.js} +1 -1
  44. package/dist/gateway/static/root/assets/product-preview-modal-C35EWUps.js +2 -0
  45. package/dist/gateway/static/root/assets/project-detail-page-xNSy6SAv.js +7 -0
  46. package/dist/gateway/static/root/assets/recording-upload-CFX7CANT.js +1 -0
  47. package/dist/gateway/static/root/assets/route-preload-Dwb_N8L-.js +2 -0
  48. package/dist/gateway/static/root/assets/routine-panel-KH1VaEdC.js +2 -0
  49. package/dist/gateway/static/root/assets/session-manager-63NaXb1s.js +25 -0
  50. package/dist/gateway/static/root/assets/{settings-page-BHImcF1q.js → settings-page-8MiJzbbl.js} +1 -1
  51. package/dist/gateway/static/root/assets/{share-preview-page-fV5USZb1.js → share-preview-page-Cqy-7-rd.js} +1 -1
  52. package/dist/gateway/static/root/assets/{shares-settings-sl40lqND.js → shares-settings-BDr50uTV.js} +1 -1
  53. package/dist/gateway/static/root/assets/{skills-page-FTd0Z7Ey.js → skills-page-DReUQ4Ug.js} +1 -1
  54. package/dist/gateway/static/root/assets/star-CnYNmpLd.js +1 -0
  55. package/dist/gateway/static/root/assets/task-detail-page-DxKXoBbE.js +3 -0
  56. package/dist/gateway/static/root/assets/{task-result-evidence-CSJeB9AH.js → task-result-evidence-CW_tN93T.js} +1 -1
  57. package/dist/gateway/static/root/assets/{use-composer-attachments-CO7XLI4x.js → use-composer-attachments-Xn6eUus2.js} +1 -1
  58. package/dist/gateway/static/root/assets/{use-file-preview-expanded-BXXeXnT0.js → use-file-preview-expanded-D0IBFhM9.js} +1 -1
  59. package/dist/gateway/static/root/assets/use-realtime-voice-B5IsKrRW.js +1 -0
  60. package/dist/gateway/static/root/assets/{use-workspace-tree-D27u-eoX.js → use-workspace-tree-7X2ydgS8.js} +1 -1
  61. package/dist/gateway/static/root/assets/{voice-settings-BiqJ0tlf.js → voice-settings-57pwZeKD.js} +1 -1
  62. package/dist/gateway/static/root/assets/workspace-api-Dd_UDfeo.js +2 -0
  63. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-NffP-UXC.js → workspace-file-preview-dialog-Clj9hMj5.js} +1 -1
  64. package/dist/gateway/static/root/assets/{workspace-preview-store-Do31QQH5.js → workspace-preview-store-imhtuEIP.js} +1 -1
  65. package/dist/gateway/static/root/index.html +27 -26
  66. package/dist/package.js +1 -1
  67. package/dist/packages/gateway-contract/src/follow-ups.js +97 -0
  68. package/dist/packages/gateway-contract/src/home.js +1 -0
  69. package/dist/packages/gateway-contract/src/index.js +4 -0
  70. package/dist/packages/gateway-contract/src/observation-starters.js +95 -0
  71. package/dist/packages/gateway-contract/src/observation.js +7 -0
  72. package/dist/packages/gateway-contract/src/task-research-result.js +3 -0
  73. package/dist/src/agent/agent-manager.d.ts +1 -1
  74. package/dist/src/agent/background-review/prompts.d.ts +1 -0
  75. package/dist/src/agent/background-review/prompts.js +7 -1
  76. package/dist/src/agent/background-review/run-background-review.js +85 -7
  77. package/dist/src/agent/coding/run-verification.d.ts +14 -7
  78. package/dist/src/agent/coding/run-verification.js +28 -6
  79. package/dist/src/agent/context/coordinator.js +1 -1
  80. package/dist/src/agent/context/deep-recall.js +1 -1
  81. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
  82. package/dist/src/agent/embedded/execution-tool-policy.js +4 -2
  83. package/dist/src/agent/embedded/run-for-session.d.ts +2 -0
  84. package/dist/src/agent/embedded/run-for-session.js +9 -0
  85. package/dist/src/agent/embedded/run-turn.js +63 -14
  86. package/dist/src/agent/embedded/types.d.ts +2 -0
  87. package/dist/src/agent/inbound/turn-dispatcher.d.ts +1 -0
  88. package/dist/src/agent/inbound/turn-dispatcher.js +1 -0
  89. package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -0
  90. package/dist/src/agent/service/direct-turn-helpers.js +17 -2
  91. package/dist/src/agent/service/process-direct-streaming.d.ts +1 -0
  92. package/dist/src/agent/service/process-direct-streaming.js +1 -0
  93. package/dist/src/agent/service.d.ts +1 -1
  94. package/dist/src/agent/tasks/task-judge-service.js +1 -0
  95. package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
  96. package/dist/src/agent/tool-manuals/browser.js +3 -1
  97. package/dist/src/agent/tools/factory.d.ts +1 -1
  98. package/dist/src/agent/tools/factory.js +1 -1
  99. package/dist/src/agent/tools/personal-request-tool.js +36 -4
  100. package/dist/src/agent/tools/personal-task-tool.d.ts +7 -1
  101. package/dist/src/agent/tools/personal-task-tool.js +68 -3
  102. package/dist/src/agent/tools/session-search-tool.js +1 -1
  103. package/dist/src/agent/tools/task-collaboration-tool.d.ts +1 -1
  104. package/dist/src/agent/tools/task-collaboration-tool.js +54 -3
  105. package/dist/src/agent/tools/task-result-tool.js +31 -0
  106. package/dist/src/agent/tools/xopc-use-tool.js +50 -19
  107. package/dist/src/automations/capabilities/write.d.ts +2 -2
  108. package/dist/src/automations/domain/validation.d.ts +4 -4
  109. package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -1
  110. package/dist/src/browser/drivers/browser-driver.d.ts +1 -0
  111. package/dist/src/browser/drivers/create-driver.js +2 -11
  112. package/dist/src/browser/drivers/playwright-driver.d.ts +5 -2
  113. package/dist/src/browser/drivers/playwright-driver.js +83 -38
  114. package/dist/src/browser/runtime/browser-runtime.d.ts +5 -0
  115. package/dist/src/browser/runtime/browser-runtime.js +71 -9
  116. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  117. package/dist/src/computer/diagnostics.d.ts +4 -4
  118. package/dist/src/computer/errors.d.ts +4 -4
  119. package/dist/src/computer/evaluation.d.ts +3 -3
  120. package/dist/src/computer/flows.d.ts +1 -1
  121. package/dist/src/computer/runtime.d.ts +3 -3
  122. package/dist/src/config/schema.d.ts +6 -2
  123. package/dist/src/config/schema.js +3 -0
  124. package/dist/src/connectors/connected-source-understanding.js +11 -3
  125. package/dist/src/connectors/learning-coordinator.js +45 -11
  126. package/dist/src/discussions/recording.js +13 -6
  127. package/dist/src/endpoint-tools/device-host.d.ts +2 -2
  128. package/dist/src/gateway/hono/lib/config-payload.d.ts +4 -0
  129. package/dist/src/gateway/hono/routes/home.js +52 -1
  130. package/dist/src/gateway/hono/routes/projects.js +1 -1
  131. package/dist/src/gateway/hono/routes/session-command-handler.js +15 -1
  132. package/dist/src/gateway/hono/routes/user-model.js +1 -1
  133. package/dist/src/gateway/service/agent-runner.d.ts +2 -8
  134. package/dist/src/gateway/service/agent-runner.js +1 -0
  135. package/dist/src/gateway/service/config-coordinator.d.ts +5 -1
  136. package/dist/src/gateway/service/run-gateway-agent.d.ts +13 -8
  137. package/dist/src/gateway/service/run-gateway-agent.js +5 -2
  138. package/dist/src/gateway/service/session-input-coordinator.d.ts +4 -0
  139. package/dist/src/gateway/service/session-input-coordinator.js +6 -1
  140. package/dist/src/gateway/service.d.ts +1 -0
  141. package/dist/src/gateway/service.js +8 -1
  142. package/dist/src/home-intelligence/follow-ups.d.ts +36 -0
  143. package/dist/src/home-intelligence/follow-ups.js +496 -0
  144. package/dist/src/home-intelligence/host.d.ts +80 -4
  145. package/dist/src/home-intelligence/host.js +122 -2
  146. package/dist/src/home-intelligence/observation-starters.d.ts +3 -0
  147. package/dist/src/home-intelligence/observation-starters.js +27 -0
  148. package/dist/src/home-intelligence/observation.d.ts +1 -1
  149. package/dist/src/home-intelligence/observation.js +16 -4
  150. package/dist/src/local-apps/automation-proposals.d.ts +4 -4
  151. package/dist/src/local-apps/capabilities/projections.d.ts +38 -38
  152. package/dist/src/memory-learning/choice-observations.d.ts +9 -0
  153. package/dist/src/memory-learning/choice-observations.js +155 -0
  154. package/dist/src/memory-learning/evidence-repair.d.ts +12 -0
  155. package/dist/src/memory-learning/evidence-repair.js +31 -0
  156. package/dist/src/memory-learning/repository.d.ts +1 -0
  157. package/dist/src/memory-learning/repository.js +43 -5
  158. package/dist/src/memory-learning/source-learning.js +52 -7
  159. package/dist/src/memory-learning/task-receipts.js +19 -10
  160. package/dist/src/memory-learning/transcript-source.js +7 -0
  161. package/dist/src/memory-learning/work-candidate.d.ts +14 -0
  162. package/dist/src/memory-learning/work-candidate.js +17 -2
  163. package/dist/src/memory-learning/work-capture.d.ts +1 -0
  164. package/dist/src/memory-learning/work-capture.js +28 -10
  165. package/dist/src/memory-learning/work-review.d.ts +46 -0
  166. package/dist/src/memory-learning/work-review.js +209 -0
  167. package/dist/src/notes/agent-context.js +1 -1
  168. package/dist/src/personal-agent/communication.d.ts +1 -1
  169. package/dist/src/personal-agent/communication.js +1 -1
  170. package/dist/src/personal-agent/default-style.d.ts +1 -1
  171. package/dist/src/personal-agent/default-style.js +1 -1
  172. package/dist/src/personal-agent/proactivity/repository.d.ts +1 -1
  173. package/dist/src/personal-agent/prompts.js +4 -4
  174. package/dist/src/personal-agent/reply-composer.d.ts +1 -1
  175. package/dist/src/personal-agent/reply-composer.js +52 -34
  176. package/dist/src/personal-agent/reply-style.d.ts +2 -2
  177. package/dist/src/personal-agent/reply-style.js +3 -2
  178. package/dist/src/personal-agent/request-repository.d.ts +3 -0
  179. package/dist/src/personal-agent/request-service.d.ts +2 -0
  180. package/dist/src/personal-agent/request-service.js +8 -2
  181. package/dist/src/phone/contracts.d.ts +1 -1
  182. package/dist/src/projects/capabilities/write.js +1 -1
  183. package/dist/src/projects/index.js +1 -1
  184. package/dist/src/projects/project-service.js +1 -1
  185. package/dist/src/storage/sqlite/schema.d.ts +2 -2
  186. package/dist/src/storage/sqlite/schema.js +7 -7
  187. package/dist/src/storage/sqlite/schema.sql +22 -0
  188. package/dist/src/storage/sqlite/upgrades/274_home_followups.sql +21 -0
  189. package/dist/src/tasks/capabilities/management.d.ts +3 -3
  190. package/dist/src/tasks/capabilities/relations.d.ts +3 -3
  191. package/dist/src/tasks/capabilities/write.d.ts +4 -4
  192. package/dist/src/tasks/capabilities/write.js +2 -0
  193. package/dist/src/tasks/home-query-service.js +4 -2
  194. package/dist/src/tasks/task-allocation-service.js +10 -2
  195. package/dist/src/tasks/task-application-service.d.ts +4 -0
  196. package/dist/src/tasks/task-application-service.js +6 -1
  197. package/dist/src/tasks/task-context-assembler.js +7 -2
  198. package/dist/src/tasks/task-contract-planner.js +3 -3
  199. package/dist/src/tasks/task-conversation-summary.d.ts +64 -0
  200. package/dist/src/tasks/task-conversation-summary.js +105 -0
  201. package/dist/src/tasks/task-delay-notice.d.ts +4 -0
  202. package/dist/src/tasks/task-delay-notice.js +113 -0
  203. package/dist/src/tasks/task-deletion-service.js +6 -1
  204. package/dist/src/tasks/task-handoff.d.ts +21 -0
  205. package/dist/src/tasks/task-handoff.js +77 -1
  206. package/dist/src/tasks/task-json-acceptance.d.ts +22 -0
  207. package/dist/src/tasks/task-json-acceptance.js +96 -0
  208. package/dist/src/tasks/task-main-update-decision-service.js +17 -21
  209. package/dist/src/tasks/task-main-update-delivery.js +34 -7
  210. package/dist/src/tasks/task-notification-preference.d.ts +16 -0
  211. package/dist/src/tasks/task-notification-preference.js +42 -0
  212. package/dist/src/tasks/task-origin-repository.d.ts +1 -0
  213. package/dist/src/tasks/task-origin-repository.js +3 -0
  214. package/dist/src/tasks/task-read-model-projector.js +1 -1
  215. package/dist/src/tasks/task-repository.js +1 -0
  216. package/dist/src/tasks/task-research-repair.d.ts +19 -1
  217. package/dist/src/tasks/task-research-repair.js +14 -4
  218. package/dist/src/tasks/task-research-result.d.ts +12 -0
  219. package/dist/src/tasks/task-research-result.js +5 -0
  220. package/dist/src/tasks/task-result-delivery-repository.d.ts +4 -1
  221. package/dist/src/tasks/task-result-delivery-repository.js +8 -5
  222. package/dist/src/tasks/task-result-delivery-service.js +9 -1
  223. package/dist/src/tasks/task-run-coordinator.js +45 -10
  224. package/dist/src/usage/cloud-wire.d.ts +1 -0
  225. package/dist/src/user-context/config.d.ts +8 -0
  226. package/dist/src/user-context/config.js +10 -0
  227. package/dist/src/user-model/capture/evidence-policy.d.ts +2 -0
  228. package/dist/src/user-model/capture/evidence-policy.js +8 -1
  229. package/dist/src/user-model/capture/executor.js +16 -4
  230. package/dist/src/user-model/capture/semantic.d.ts +4 -0
  231. package/dist/src/user-model/capture/semantic.js +3 -0
  232. package/dist/src/user-model/index.js +1 -1
  233. package/dist/src/user-model/observation-repository.d.ts +6 -0
  234. package/dist/src/user-model/observation-repository.js +12 -0
  235. package/dist/src/user-model/repository.js +10 -1
  236. package/dist/src/voice/realtime/agentEngine.js +29 -7
  237. package/dist/src/voice/realtime/pcmPlaybackEcho.d.ts +10 -0
  238. package/dist/src/voice/realtime/pcmPlaybackEcho.js +56 -0
  239. package/dist/src/voice/realtime/playback-echo.d.ts +3 -0
  240. package/dist/src/voice/realtime/playback-echo.js +35 -5
  241. package/dist/src/voice/realtime/runtime.js +6 -1
  242. package/dist/src/voice/realtime/turnPolicy.js +1 -1
  243. package/package.json +14 -8
  244. package/dist/gateway/static/root/assets/capabilities-DB713nRi.js +0 -1
  245. package/dist/gateway/static/root/assets/capabilities-page-D2hq4cgE.js +0 -2
  246. package/dist/gateway/static/root/assets/chat-page-BhPw56Vc.js +0 -71
  247. package/dist/gateway/static/root/assets/constants-DpkUgykJ.js +0 -1
  248. package/dist/gateway/static/root/assets/discussion-annotation-sync-fwPPMPv9.js +0 -1
  249. package/dist/gateway/static/root/assets/home-page-BPPe4JXB.js +0 -7
  250. package/dist/gateway/static/root/assets/index-DjzrnmBA.js +0 -11
  251. package/dist/gateway/static/root/assets/index-YQxumvaS.css +0 -1
  252. package/dist/gateway/static/root/assets/note-detail-panel-BbHlfAju.js +0 -7
  253. package/dist/gateway/static/root/assets/note-image-lightbox-CqK_uJ6Y.js +0 -1
  254. package/dist/gateway/static/root/assets/notes-page-8w2Stfak.js +0 -8
  255. package/dist/gateway/static/root/assets/pcm-capture-worklet-uW_SEACy.js +0 -1
  256. package/dist/gateway/static/root/assets/product-preview-modal-DMHOKocl.js +0 -2
  257. package/dist/gateway/static/root/assets/project-detail-page-CNFuzmRr.js +0 -7
  258. package/dist/gateway/static/root/assets/recording-upload-CyZSl2DJ.js +0 -1
  259. package/dist/gateway/static/root/assets/route-preload-CuxNu-LB.js +0 -2
  260. package/dist/gateway/static/root/assets/routine-panel-CXs4PjW0.js +0 -2
  261. package/dist/gateway/static/root/assets/session-manager-D2LaQymu.js +0 -25
  262. package/dist/gateway/static/root/assets/task-detail-page-_5TEldtl.js +0 -3
  263. package/dist/gateway/static/root/assets/use-realtime-voice-C7iWQuUv.js +0 -1
  264. package/dist/gateway/static/root/assets/workspace-api-LghfbP5g.js +0 -2
@@ -21,6 +21,7 @@ import { defineTaskContract } from "./task-contract-definition.js";
21
21
  import { personalCapabilities } from "../personal-agent/capability-service.js";
22
22
  import { assessTaskExecutor, captureExecutionRequirements, taskExecutionRequirements } from "./task-execution-capabilities.js";
23
23
  import { ModelTaskContractPlanner } from "./task-contract-planner.js";
24
+ import { taskJsonAcceptance } from "./task-json-acceptance.js";
24
25
  import { supersededTaskInstructionIds } from "./task-research-result.js";
25
26
  import { AgentSelectionRepository, selectionRequestHash } from "../agent-matching/selection-repository.js";
26
27
  import { z } from "zod";
@@ -191,8 +192,15 @@ var TaskAllocationDispatcher = class {
191
192
  return;
192
193
  }
193
194
  const fallback = defineTaskContract(task.contract?.objective ?? task.title, resolveTaskLocale(task));
194
- if (task.contract && (this.deps.planner || !this.deps.decide) && !requirements.connector) {
195
- const planned = await (this.deps.planner ?? new ModelTaskContractPlanner()).plan({
195
+ const jsonAcceptance = !activeDirections.length && taskJsonAcceptance(task, handoff);
196
+ const useJsonAcceptance = jsonAcceptance && JSON.stringify(task.contract?.acceptanceCriteria) === JSON.stringify(fallback.acceptanceCriteria) && JSON.stringify(task.contract?.expectedOutputs) === JSON.stringify(fallback.expectedOutputs);
197
+ if (task.contract && (useJsonAcceptance || this.deps.planner || !this.deps.decide) && !requirements.connector) {
198
+ const planned = useJsonAcceptance ? {
199
+ ...fallback,
200
+ expectedOutputs: [jsonAcceptance.file],
201
+ acceptanceCriteria: jsonAcceptance.criteria,
202
+ requiredCapabilities: ["publish_files"]
203
+ } : await (this.deps.planner ?? new ModelTaskContractPlanner()).plan({
196
204
  objective: task.contract.objective,
197
205
  taskContext,
198
206
  locale: resolveTaskLocale(task),
@@ -48,6 +48,10 @@ export declare class TaskApplicationService {
48
48
  terminalMessage?: string;
49
49
  suppressAttention?: boolean;
50
50
  resultText?: string;
51
+ hostArtifact?: {
52
+ id: string;
53
+ sha256?: string;
54
+ };
51
55
  }): TaskApplicationResult;
52
56
  private start;
53
57
  private lifecycle;
@@ -705,7 +705,7 @@ var TaskApplicationService = class {
705
705
  body: input.receipt.summary?.slice(0, 8e3) || (resolveTaskLocale(task) === "zh" ? input.receipt.status === "succeeded" ? "任务执行完成" : "任务执行失败" : input.receipt.status === "succeeded" ? "TaskRun completed" : "TaskRun failed"),
706
706
  idempotencyKey: `task-run-receipt:${run.id}`
707
707
  });
708
- if (input.receipt.status === "succeeded" || input.receipt.status === "failed") new TaskResultDeliveryRepository().enqueue(run.id, input.receipt.summary, input.receipt.status, input.resultText);
708
+ if (input.receipt.status === "succeeded" || input.receipt.status === "failed") new TaskResultDeliveryRepository().enqueue(run.id, input.receipt.summary, input.receipt.status, input.resultText, input.hostArtifact);
709
709
  if (!this.#tasks.runPhaseUnchanged(task.id, run.id) || task.phase === "closed") {
710
710
  enqueueTaskChangedEvent(db, {
711
711
  taskId: task.id,
@@ -806,6 +806,11 @@ var TaskApplicationService = class {
806
806
  ok: false,
807
807
  reason: "not_found"
808
808
  };
809
+ if (getSqliteDatabase().prepare("SELECT 1 FROM home_followups WHERE root_task_id=?").get(taskId)) return {
810
+ ok: false,
811
+ reason: "invalid_transition",
812
+ model: this.#projector.project(task)
813
+ };
809
814
  if (options.actor.kind !== "user" && !this.#tasks.automaticStartAllowed(taskId)) return {
810
815
  ok: false,
811
816
  reason: "blocked",
@@ -10,6 +10,8 @@ import { TaskOriginRepository } from "./task-origin-repository.js";
10
10
  import { TaskConversationRepository } from "./task-conversation-repository.js";
11
11
  import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
12
12
  import { TaskContextRepository } from "./task-context-repository.js";
13
+ import { getTaskHandoff } from "./task-handoff.js";
14
+ import { currentTaskJsonAcceptance } from "./task-json-acceptance.js";
13
15
  //#region src/tasks/task-context-assembler.ts
14
16
  init_src();
15
17
  init_task_repository();
@@ -128,7 +130,7 @@ function buildTaskExecutionDirective(conversationId) {
128
130
  const handoffPayload = handoff?.toConversationId === conversationId ? JSON.stringify(handoff.payload).slice(0, 12e3) : "";
129
131
  const contract = task.contract;
130
132
  const contextEdges = new TaskContextRepository().list(task.id);
131
- const contextReferences = contextEdges.filter((edge) => typeof edge.metadata.userAnswer !== "string").slice(0, 40).map((edge) => {
133
+ const contextReferences = contextEdges.filter((edge) => typeof edge.metadata.userAnswer !== "string" && edge.metadata.kind !== "task_notification_preference").slice(0, 40).map((edge) => {
132
134
  const title = edge.title?.trim() ? ` (${edge.title.trim()})` : "";
133
135
  return `- [${edge.role}] ${edge.targetKind}: ${edge.targetId.slice(0, 4e3)}${title}`;
134
136
  });
@@ -137,6 +139,7 @@ function buildTaskExecutionDirective(conversationId) {
137
139
  const board = new TaskCollaborationRepository();
138
140
  const superseded = new Set(getSqliteDatabase().prepare("SELECT supersedes_json FROM task_work_revisions WHERE task_id = ?").all(task.id).flatMap((row) => JSON.parse(row.supersedes_json)));
139
141
  const collaboration = [...new Map([...board.recent(task.id, void 0, 12), ...board.coordination(task.id).filter((entry) => ["answer", "instruction"].includes(entry.kind))].map((entry) => [entry.id, entry])).values()].sort((left, right) => left.sequence - right.sequence);
142
+ const verifyJson = !connected && !collaboration.some((entry) => ["answer", "instruction"].includes(entry.kind)) && contract.expectedOutputs.length === 1 && /^[A-Za-z0-9_.-]+\.json$/i.test(contract.expectedOutputs[0] ?? "") && currentTaskJsonAcceptance(task, getTaskHandoff(task.id));
140
143
  return [
141
144
  "<xopc_task_execution>",
142
145
  "This conversation is executing a durable task.",
@@ -150,7 +153,9 @@ function buildTaskExecutionDirective(conversationId) {
150
153
  criterionIndex,
151
154
  criterion
152
155
  })))}`,
153
- "For research or evidence-based conclusions, use publish_task_result before finishing when that tool is available. Cite exact excerpts from successful reads in this TaskRun, link each claim to source ids, and distinguish facts, inferences and recommendations. Publish required files first, then supply finalArtifactIds selecting only the final deliverables from their publication receipts; do not include intermediate or obsolete files. Read its per-criterion review; correct unsupported claims or explicitly disclose unmet/unverified criteria. Never replace missing evidence with a self-declared pass. Use task_collaboration get section evidence to recover real toolCallIds and exact excerpts. If the chat reply itself is a deliverable, include the exact reply in finalText, including any required limitations, links and formatting. The host will review that text and deliver it verbatim. Keep it within the requested limits and amend finalText if the review finds gaps. Do not cite it as a source or create a separate file to prove its wording. A source quote match proves provenance, not factual truth. Keep the final reply concise; full evidence belongs in the result and report.",
156
+ verifyJson ? "For this exact JSON-only request, the host directly checks the published file against every criterion. Publish only the requested final JSON file, then finish. This check replaces publish_task_result for this request." : "",
157
+ verifyJson ? "" : "For research or evidence-based conclusions, use publish_task_result before finishing when that tool is available. Cite exact excerpts from successful reads in this TaskRun, link each claim to source ids, and distinguish facts, inferences and recommendations. Publish required files first, then supply finalArtifactIds selecting only the final deliverables from their publication receipts; do not include intermediate or obsolete files. Read its per-criterion review; correct unsupported claims or explicitly disclose unmet/unverified criteria. Never replace missing evidence with a self-declared pass. Use task_collaboration get section evidence to recover real toolCallIds and exact excerpts. If the chat reply itself is a deliverable, include the exact reply in finalText, including any required limitations, links and formatting. The host will review that text and deliver it verbatim. Keep it within the requested limits and amend finalText if the review finds gaps. Do not cite it as a source or create a separate file to prove its wording. A source quote match proves provenance, not factual truth. Keep the final reply concise; full evidence belongs in the result and report.",
158
+ "For chat delivery, lead with the result and keep the evidence, material changes, and limitations that affect use. Use the shortest form that covers what the user asked for. General brevity is an editorial preference. Apply numerical length limits only when requested. When files contain the full report, leave methodology and repeated detail there unless requested.",
154
159
  `Acceptance policy: ${contract.acceptancePolicy}. Automatic tasks close after verified completion. Request user input only for a real missing decision or authorization; do not ask for routine acceptance.`,
155
160
  contract.constraints.length ? `Constraints: ${contract.constraints.join("; ")}` : "",
156
161
  contract.assumptions.length ? `Assumptions: ${contract.assumptions.join("; ")}` : "",
@@ -92,8 +92,8 @@ var ModelTaskContractPlanner = class {
92
92
  "acceptancePolicy defaults to verified_auto. Return manual only if the human explicitly requires personal acceptance or sign-off. A generic approval for an external action is not a request for manual task acceptance.",
93
93
  "Acceptance criteria must describe externally checkable finished states, not activities.",
94
94
  "Write boundaries and prohibitions on unrelated actions belong in constraints, not criteria requiring proof that no unobserved action ever occurred. Criteria may check the actual delivered output paths and unchanged supplied input bytes. Never remove an explicit scope restriction.",
95
- "Keep each criterion concise and concrete; do not repeat the full brief. Include all required deliverable conditions without splitting trivial wording into unnecessary items.",
96
- "Define criteria for the deliverables requested by the user. When the requested answer is a chat reply, list it explicitly in expectedOutputs and preserve its concrete requirements, including language and character limits. Keep source support, calculations, completeness and requested limitations as separate criteria. Do not create self-referential criteria about calling publish_task_result, receiving this review or wording a routine delivery acknowledgement.",
95
+ "Keep each criterion concise and concrete. For simple work use the fewest checks that cover all explicit deliverables and material constraints. Prefer observable checks such as the required file, format, fields or count. Treat optional analysis, extra conclusions and aesthetic improvements as optional unless the user requires them. Do not invent work to make the contract more elaborate.",
96
+ "Define criteria for the deliverables requested by the user. When the requested answer is a chat reply, list it explicitly in expectedOutputs and preserve its concrete requirements, including language and any length limits the user actually set. Treat general brevity or “keep it short” as a presentation preference. Do not turn it into a word or character quota or an acceptance check. Keep source support, calculations, completeness and requested limitations as separate criteria. Do not create self-referential criteria about calling publish_task_result, receiving this review or wording a routine delivery acknowledgement.",
97
97
  "requiredCapabilities is a minimal subset of read_input, execute_code, publish_files, web_research, browser, generate_image. Include only operations necessary for the requested inputs/outputs; this list selects registered tools and grants no permissions. Do not require browser when ordinary web fetch suffices. Preserve explicit executor/Skill and scope constraints.",
98
98
  "List assumptions explicitly. Put only irreversible, external, financial, privacy, or permission decisions in approvalRequired.",
99
99
  "Return one JSON object only. Every array contains flat strings, never objects or nested arrays. Schema example: {\"objective\":\"Deliver the requested work\",\"expectedOutputs\":[\"report.md\"],\"acceptanceCriteria\":[\"report.md contains the requested evidence\"],\"constraints\":[],\"approvalRequired\":[],\"assumptions\":[],\"risks\":[],\"requiredCapabilities\":[\"read_input\",\"publish_files\"]}. Capabilities must use the allowed enum values.",
@@ -130,7 +130,7 @@ var ModelTaskContractPlanner = class {
130
130
  if (attempt === 0) messages.push({
131
131
  role: "user",
132
132
  timestamp: Date.now(),
133
- content: `${wrongLanguage ? "Your previous response used the wrong language. Translate the user-facing prose while preserving every requirement and all technical identifiers. " : ""}${languageInstruction} Your previous response must satisfy both the language requirement and the required schema. Return the same task contract as one JSON object. expectedOutputs, acceptanceCriteria, constraints, approvalRequired, assumptions and risks must be flat string arrays, never objects. requiredCapabilities must be an array drawn only from read_input, execute_code, publish_files, web_research, browser, generate_image. Keep all user constraints and preserve concrete requirements for a requested chat deliverable. Do not invent criteria for a routine delivery acknowledgement. Return no commentary. Previous response (data to repair): ${raw}`
133
+ content: `${wrongLanguage ? "Your previous response used the wrong language. Translate the user-facing prose while preserving every requirement and all technical identifiers. " : ""}${languageInstruction} Your previous response must satisfy both the language requirement and the required schema. Return the same task contract as one JSON object. expectedOutputs, acceptanceCriteria, constraints, approvalRequired, assumptions and risks must be flat string arrays, never objects. requiredCapabilities must be an array drawn only from read_input, execute_code, publish_files, web_research, browser, generate_image. Keep all user constraints and preserve concrete requirements for a requested chat deliverable. Do not invent word or character limits, or criteria for a routine delivery acknowledgement. Return no commentary. Previous response (data to repair): ${raw}`
134
134
  });
135
135
  }
136
136
  throw new Error("Task planning response did not contain a verifiable contract and operation requirements");
@@ -0,0 +1,64 @@
1
+ /** Shared facts for status answers and proactive replies in the originating chat. */
2
+ export declare function taskConversationSummary(taskId: string, conversationId: string): {
3
+ taskId: string;
4
+ title: string;
5
+ createdAt: number;
6
+ dueAt: number;
7
+ notificationPreference: "default" | "final_only" | "updates";
8
+ phase: "review" | "backlog" | "ready" | "active" | "closed";
9
+ resolution: "cancelled" | "done" | "duplicate" | "wont_do";
10
+ operationalState: "queued" | "cancelled" | "waiting" | "failed" | "allocating" | "idle" | "running" | "verifying" | "blocked";
11
+ allocation: {
12
+ id: string;
13
+ taskId: string;
14
+ status: "cancelled" | "failed" | "pending" | "blocked" | "selecting" | "assigned";
15
+ attempts: number;
16
+ updatedAt: number;
17
+ selectedAgentId?: string;
18
+ selectionReason?: string;
19
+ reasonCode?: string;
20
+ };
21
+ run: {
22
+ status: "queued" | "cancelled" | "waiting" | "failed" | "succeeded" | "running" | "verifying";
23
+ queuedAt: number;
24
+ startedAt: number;
25
+ };
26
+ waits: {
27
+ kind: "approval" | "paused" | "dependency" | "user_input" | "external_event" | "scheduled_time" | "retry_backoff";
28
+ reason: string;
29
+ questionId: unknown;
30
+ }[];
31
+ attention: {
32
+ kind: "allocation_blocked" | "allocation_failed" | "input_required" | "approval_required" | "dependency_blocked" | "run_failed" | "verification_failed" | "overdue" | "stale";
33
+ summary: string;
34
+ }[];
35
+ workerProgress: {
36
+ text: string;
37
+ at: number;
38
+ };
39
+ receipt: {
40
+ verdict: "partial" | "achieved" | "not_achieved";
41
+ verification: "passed" | "failed" | "unverified";
42
+ summary: string;
43
+ remaining: string[];
44
+ needsUser: boolean;
45
+ nextAction: string;
46
+ };
47
+ fileDelivery: {
48
+ status: "not_delivered" | "pending" | "delivered" | "stale" | "failed";
49
+ availableFileCount: number;
50
+ resultId?: string;
51
+ };
52
+ replyDelivery: {
53
+ resultId: string;
54
+ status: string;
55
+ };
56
+ lastDeliveredUpdate: {
57
+ entryId: string;
58
+ text: string;
59
+ };
60
+ lastDeliveredReply: {
61
+ resultId: string;
62
+ text: string;
63
+ };
64
+ };
@@ -0,0 +1,105 @@
1
+ import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
2
+ import { extractFtsContent, init_row_mappers } from "../storage/sqlite/row-mappers.js";
3
+ import { TaskRunRepository, init_task_run_repository } from "./task-run-repository.js";
4
+ import { TaskReadModelProjector } from "./task-read-model-projector.js";
5
+ import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
6
+ import { taskInstructionSequence } from "./task-instruction-sequence.js";
7
+ import { TaskResultDeliveryRepository } from "./task-result-delivery-repository.js";
8
+ import { getTaskNotificationPreference } from "./task-notification-preference.js";
9
+ //#region src/tasks/task-conversation-summary.ts
10
+ init_row_mappers();
11
+ init_transaction();
12
+ init_task_run_repository();
13
+ /** Shared facts for status answers and proactive replies in the originating chat. */
14
+ function taskConversationSummary(taskId, conversationId) {
15
+ const model = new TaskReadModelProjector().get(taskId);
16
+ if (!model) return void 0;
17
+ const runs = new TaskRunRepository();
18
+ const run = runs.getActiveRoot(taskId) ?? runs.getLatestRoot(taskId);
19
+ const current = run?.contractVersion === model.task.latestContractVersion ? run : void 0;
20
+ const receipt = current && runs.getReceipt(current.id);
21
+ const waits = runs.listActiveWaits(taskId);
22
+ const progress = new TaskCollaborationRepository().recent(taskId, void 0, 10).findLast((entry) => entry.kind === "progress" && current && entry.taskRunId === current.id);
23
+ const db = getSqliteDatabase();
24
+ const previous = db.prepare(`SELECT delivery.delivery_id,
25
+ substr(json_extract(entry.payload_json, '$.content'), 1, 600) AS text
26
+ FROM task_result_deliveries delivery
27
+ JOIN sessions session ON session.conversation_id = delivery.conversation_id
28
+ JOIN transcript_entries entry ON entry.entry_id = delivery.reply_message_entry_id
29
+ AND entry.transcript_id = session.active_transcript_id
30
+ WHERE delivery.conversation_id = ? AND delivery.task_run_id IN
31
+ (SELECT run_id FROM task_runs WHERE task_id = ?) AND delivery.reply_status = 'delivered'
32
+ ORDER BY entry.seq DESC LIMIT 1`).get(conversationId, taskId);
33
+ const latestDelivery = current && db.prepare(`SELECT delivery.delivery_id, delivery.status, delivery.reply_status,
34
+ json_extract(delivery.payload_json, '$.instructionSequence') AS instruction_sequence,
35
+ EXISTS (SELECT 1 FROM transcript_entries entry JOIN sessions session ON session.active_transcript_id = entry.transcript_id
36
+ WHERE entry.entry_id = delivery.reply_message_entry_id AND session.conversation_id = delivery.conversation_id) AS replyVisible
37
+ FROM task_result_deliveries delivery WHERE delivery.task_run_id = ? AND delivery.conversation_id = ?`).get(current.id, conversationId);
38
+ const outdatedReply = latestDelivery?.instruction_sequence != null && latestDelivery.instruction_sequence !== taskInstructionSequence(taskId);
39
+ const previousUpdate = db.prepare(`SELECT update_entry.entry_id, message.payload_json
40
+ FROM task_collaboration_entries update_entry
41
+ JOIN task_main_update_deliveries delivery ON delivery.entry_id = update_entry.entry_id
42
+ JOIN sessions session ON session.conversation_id = delivery.conversation_id
43
+ JOIN session_inputs input ON input.conversation_id = session.conversation_id AND input.status = 'completed'
44
+ AND json_extract(input.origin_json, '$.type') = 'system'
45
+ AND json_extract(input.origin_json, '$.source') = 'task_update'
46
+ AND (input.client_message_id = 'task-main-update:' || update_entry.entry_id
47
+ OR input.client_message_id GLOB 'task-main-update:' || update_entry.entry_id || ':retry:*')
48
+ JOIN transcript_entries message ON message.transcript_id = session.active_transcript_id AND message.role = 'assistant'
49
+ AND json_extract(message.payload_json, '$.turnId') = input.run_id
50
+ WHERE update_entry.task_id = ? AND delivery.conversation_id = ?
51
+ AND COALESCE(json_extract(message.payload_json, '$.metadata.hiddenFromClient'), 0) != 1
52
+ ORDER BY message.seq DESC LIMIT 8`).all(taskId, conversationId).map((row) => ({
53
+ entryId: row.entry_id,
54
+ text: extractFtsContent(JSON.parse(row.payload_json)).slice(0, 500).trim()
55
+ })).find((update) => update.text && update.text !== "NO_REPLY");
56
+ return {
57
+ taskId,
58
+ title: model.task.title,
59
+ createdAt: model.task.createdAt,
60
+ dueAt: model.task.dueAt,
61
+ notificationPreference: getTaskNotificationPreference(taskId, conversationId),
62
+ phase: model.task.phase,
63
+ resolution: model.task.resolution,
64
+ operationalState: model.operationalState,
65
+ allocation: model.allocation,
66
+ run: current && {
67
+ status: current.status,
68
+ queuedAt: current.queuedAt,
69
+ startedAt: current.startedAt
70
+ },
71
+ waits: waits.slice(0, 4).map((wait) => ({
72
+ kind: wait.kind,
73
+ reason: wait.reason.slice(0, 500),
74
+ questionId: wait.condition.collaborationEntryId
75
+ })),
76
+ attention: model.attention.slice(0, 4).map((item) => ({
77
+ kind: item.kind,
78
+ summary: item.summary.slice(0, 500)
79
+ })),
80
+ workerProgress: progress && {
81
+ text: progress.body.slice(0, 600),
82
+ at: progress.createdAt
83
+ },
84
+ receipt: receipt && {
85
+ verdict: receipt.completionVerdict,
86
+ verification: receipt.verification.status,
87
+ summary: receipt.summary.slice(0, 700),
88
+ remaining: receipt.remainingWork.slice(0, 5).map((item) => item.slice(0, 300)),
89
+ needsUser: receipt.needsUser,
90
+ nextAction: receipt.nextAction?.slice(0, 500)
91
+ },
92
+ fileDelivery: new TaskResultDeliveryRepository().fileDeliveryState(taskId, conversationId),
93
+ replyDelivery: latestDelivery && {
94
+ resultId: latestDelivery.delivery_id,
95
+ status: outdatedReply ? "stale" : latestDelivery.status !== "delivered" ? latestDelivery.status : latestDelivery.replyVisible ? "delivered" : latestDelivery.reply_status === "delivered" ? "stale" : latestDelivery.reply_status
96
+ },
97
+ lastDeliveredUpdate: previousUpdate,
98
+ lastDeliveredReply: previous && {
99
+ resultId: previous.delivery_id,
100
+ text: previous.text
101
+ }
102
+ };
103
+ }
104
+ //#endregion
105
+ export { taskConversationSummary };
@@ -0,0 +1,4 @@
1
+ import { type TaskCollaborationEntry } from './task-collaboration-repository.js';
2
+ export declare function enqueueTaskDelayNotices(now?: number): number;
3
+ export declare function isTaskDelayNotice(entry: TaskCollaborationEntry): boolean;
4
+ export declare function isCurrentTaskDelayNotice(entry: TaskCollaborationEntry, conversationId: string, now?: number): boolean;
@@ -0,0 +1,113 @@
1
+ import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
2
+ import { personalAgentId } from "../personal-agent/repository.js";
3
+ import { TaskCollaborationRepository } from "./task-collaboration-repository.js";
4
+ import { getTaskNotificationPreference } from "./task-notification-preference.js";
5
+ //#region src/tasks/task-delay-notice.ts
6
+ init_transaction();
7
+ const QUEUE_DELAY_MS = 5 * 6e4;
8
+ const EXECUTION_INACTIVITY_MS = 20 * 6e4;
9
+ const AUTHOR = "task-delay-monitor";
10
+ const eligibleTasks = `WITH active AS (
11
+ SELECT t.task_id, t.due_at, t.locale, o.conversation_id,
12
+ max(o.created_at, coalesce((SELECT max(revision.created_at) FROM task_work_revisions revision
13
+ WHERE revision.task_id = t.task_id), o.created_at)) AS created_at,
14
+ r.run_id, r.status,
15
+ CASE WHEN r.status = 'queued' THEN max(r.queued_at, coalesce(r.scheduled_at, r.queued_at))
16
+ ELSE coalesce(r.started_at, r.queued_at) END AS run_since,
17
+ max(
18
+ coalesce((SELECT max(e.created_at) FROM task_collaboration_entries e
19
+ WHERE e.task_id = t.task_id AND e.created_at >= r.queued_at
20
+ AND ((e.task_run_id = r.run_id AND e.author_kind = 'worker_agent' AND e.kind = 'progress')
21
+ OR (e.author_kind IN ('user','main_agent') AND e.kind IN ('instruction','answer')))), 0),
22
+ coalesce((SELECT max(w.resolved_at) FROM task_waits w
23
+ WHERE w.task_id = t.task_id AND w.task_run_id = r.run_id AND w.status = 'resolved'), 0)
24
+ ) AS progress_at
25
+ FROM task_origin_links o JOIN tasks t ON t.task_id = o.task_id
26
+ JOIN sessions s ON s.conversation_id = o.conversation_id AND s.active_transcript_id = o.origin_transcript_id
27
+ LEFT JOIN task_allocations a ON a.task_id = t.task_id
28
+ LEFT JOIN task_runs r ON r.run_id = (
29
+ SELECT candidate.run_id FROM task_runs candidate WHERE candidate.task_id = t.task_id AND candidate.parent_run_id IS NULL
30
+ AND candidate.contract_version = t.latest_contract_version
31
+ ORDER BY candidate.queued_at DESC, candidate.rowid DESC LIMIT 1)
32
+ WHERE s.agent_id = ? AND json_extract(s.custom_data_json, '$.personalAgent') = 1 AND t.phase != 'closed'
33
+ AND NOT EXISTS (SELECT 1 FROM task_waits w WHERE w.task_id = t.task_id AND w.status = 'active')
34
+ AND ((r.run_id IS NULL AND a.status IN ('pending','selecting')) OR r.status IN ('queued','running','verifying'))
35
+ ), delays AS (
36
+ SELECT *, CASE WHEN due_at <= @now AND (status IS NOT 'queued' OR run_since <= @now) THEN 'overdue'
37
+ WHEN status IS NULL AND created_at <= @queueCutoff THEN 'allocation'
38
+ WHEN status = 'queued' AND run_since <= @queueCutoff THEN 'queue'
39
+ WHEN status IN ('running','verifying') AND max(run_since, coalesce(progress_at, run_since)) <= @executionCutoff THEN 'execution'
40
+ END AS reason FROM active
41
+ )`;
42
+ function delayParameters(now) {
43
+ return {
44
+ now,
45
+ queueCutoff: now - QUEUE_DELAY_MS,
46
+ executionCutoff: now - EXECUTION_INACTIVITY_MS
47
+ };
48
+ }
49
+ const messages = {
50
+ overdue: {
51
+ zh: "已过任务截止时间,结果还没有交付。",
52
+ en: "The task deadline has passed and the result is still pending."
53
+ },
54
+ allocation: {
55
+ zh: "任务提交超过五分钟,仍在等待分配执行者。",
56
+ en: "The task has been waiting for an executor for over five minutes."
57
+ },
58
+ queue: {
59
+ zh: "任务已在执行队列中等待超过五分钟。",
60
+ en: "The task has been in the execution queue for over five minutes."
61
+ },
62
+ execution: {
63
+ zh: "任务已超过二十分钟没有新的进度记录。",
64
+ en: "The task has had no new progress recorded for over twenty minutes."
65
+ }
66
+ };
67
+ function delayKey(row) {
68
+ return `task-delay:${row.reason}:${row.run_id ?? "allocation"}:${row.progress_at || row.run_since || row.created_at}`;
69
+ }
70
+ function enqueueTaskDelayNotices(now = Date.now()) {
71
+ return runSqliteWriteTransaction((db) => {
72
+ const rows = db.prepare(`${eligibleTasks} SELECT * FROM delays d WHERE reason IS NOT NULL
73
+ AND NOT EXISTS (SELECT 1 FROM task_collaboration_entries e JOIN task_main_update_deliveries m ON m.entry_id = e.entry_id
74
+ WHERE e.task_id = d.task_id AND e.author_kind = 'system' AND e.author_id = @author
75
+ AND (m.status = 'pending' OR m.decision = 'notify'
76
+ OR e.idempotency_key = 'task-delay:' || d.reason || ':' || coalesce(d.run_id,'allocation')
77
+ || ':' || coalesce(nullif(d.progress_at,0),d.run_since,d.created_at)))
78
+ AND coalesce(
79
+ (SELECT json_extract(edge.metadata_json, '$.preference') FROM context_edges edge
80
+ WHERE edge.owner_kind = 'task' AND edge.owner_id = d.task_id AND edge.target_kind = 'source'
81
+ AND edge.target_id = 'task-notifications:' || d.conversation_id AND edge.role = 'reference'
82
+ AND json_extract(edge.metadata_json, '$.kind') = 'task_notification_preference'),
83
+ (SELECT json_extract(request.parameters_json, '$.notificationPreference') FROM personal_requests request
84
+ WHERE request.task_id = d.task_id),
85
+ 'default') != 'final_only'
86
+ ORDER BY d.due_at IS NULL, d.due_at, d.created_at LIMIT 20`).all({
87
+ ...delayParameters(now),
88
+ author: AUTHOR
89
+ }, personalAgentId("local-owner"));
90
+ const board = new TaskCollaborationRepository();
91
+ for (const row of rows) board.append({
92
+ taskId: row.task_id,
93
+ taskRunId: row.run_id ?? void 0,
94
+ authorKind: "system",
95
+ authorId: AUTHOR,
96
+ kind: "progress",
97
+ body: messages[row.reason][row.locale === "zh" ? "zh" : "en"],
98
+ idempotencyKey: delayKey(row)
99
+ });
100
+ return rows.length;
101
+ });
102
+ }
103
+ function isTaskDelayNotice(entry) {
104
+ return entry.authorKind === "system" && entry.authorId === AUTHOR && entry.kind === "progress";
105
+ }
106
+ function isCurrentTaskDelayNotice(entry, conversationId, now = Date.now()) {
107
+ if (getTaskNotificationPreference(entry.taskId, conversationId) === "final_only") return false;
108
+ const db = getSqliteDatabase();
109
+ const row = db.prepare(`${eligibleTasks} SELECT * FROM delays WHERE task_id = ? AND conversation_id = ? AND reason IS NOT NULL`).get(delayParameters(now), personalAgentId("local-owner"), entry.taskId, conversationId);
110
+ return !!row && !!db.prepare("SELECT 1 FROM task_collaboration_entries WHERE entry_id = ? AND idempotency_key = ?").get(entry.id, delayKey(row));
111
+ }
112
+ //#endregion
113
+ export { enqueueTaskDelayNotices, isCurrentTaskDelayNotice, isTaskDelayNotice };
@@ -1,6 +1,8 @@
1
+ import { getSqliteDatabase, init_transaction } from "../storage/sqlite/transaction.js";
1
2
  import { TaskRepository, init_task_repository } from "./task-repository.js";
2
3
  import { TaskRunRepository, init_task_run_repository } from "./task-run-repository.js";
3
4
  //#region src/tasks/task-deletion-service.ts
5
+ init_transaction();
4
6
  init_task_repository();
5
7
  init_task_run_repository();
6
8
  var TaskDeletionService = class {
@@ -14,7 +16,10 @@ var TaskDeletionService = class {
14
16
  ok: false,
15
17
  reason: "not_found"
16
18
  };
17
- const run = this.runs.getActiveRoot(taskId);
19
+ const related = getSqliteDatabase().prepare(`SELECT run.run_id FROM task_runs run JOIN home_followup_steps s ON s.task_id=run.task_id
20
+ JOIN home_followups g ON g.id=s.followup_id WHERE (g.root_task_id=? OR g.id=(SELECT followup_id FROM home_followup_steps WHERE task_id=?))
21
+ AND run.parent_run_id IS NULL AND run.status IN ('queued','running','waiting','verifying') LIMIT 1`).get(taskId, taskId);
22
+ const run = this.runs.getActiveRoot(taskId) ?? (related ? this.runs.get(related.run_id) : void 0);
18
23
  return run ? {
19
24
  ok: false,
20
25
  reason: "active_run",
@@ -1,12 +1,19 @@
1
1
  import { type TurnContextRef } from '../agent/source-context/types.js';
2
2
  import type { Config } from '../config/schema.js';
3
3
  import { type PersonalResultInput } from '../personal-agent/result-reader.js';
4
+ interface ConversationExcerpt {
5
+ entryId: string;
6
+ start: number;
7
+ length: number;
8
+ contentHash: string;
9
+ }
4
10
  export interface TaskHandoff {
5
11
  version: 1;
6
12
  conversationId: string;
7
13
  transcriptId: string;
8
14
  inputId?: string;
9
15
  originalRequest?: string;
16
+ conversationExcerpts?: ConversationExcerpt[];
10
17
  interpretation: string;
11
18
  baseline: {
12
19
  contractVersion: number;
@@ -34,6 +41,19 @@ export interface TaskHandoff {
34
41
  }
35
42
  /** Normalize model-facing references without fetching any source on the submission path. */
36
43
  export declare function parseTaskHandoffReferences(raw: unknown): TurnContextRef[] | null;
44
+ /** Pin an exact, visible passage without copying the rest of its message into the Task. */
45
+ export declare function parseTaskConversationExcerpts(conversationId: string | undefined, raw: unknown, config?: Config): ConversationExcerpt[] | null;
46
+ export declare function readTaskConversationExcerpts(handoff: TaskHandoff, config?: Config): ({
47
+ entryId: string;
48
+ role: "user" | "assistant";
49
+ text: string;
50
+ unavailable?: undefined;
51
+ } | {
52
+ entryId: string;
53
+ unavailable: boolean;
54
+ role?: undefined;
55
+ text?: undefined;
56
+ })[];
37
57
  /** Called inside task.create's transaction; no discovery, parsing or remote IO. */
38
58
  export declare function captureTaskHandoff(taskId: string, conversationId: string, interpretation: string, references?: TurnContextRef[]): void;
39
59
  export declare function getTaskHandoff(taskId: string): TaskHandoff | undefined;
@@ -54,3 +74,4 @@ export declare function materializeTaskHandoffFile(taskId: string, sourceIndex:
54
74
  scope: string;
55
75
  }>;
56
76
  export declare function assertTaskHandoffExecutorAccess(taskId: string, agentId: string): void;
77
+ export {};
@@ -5,10 +5,15 @@ import { init_src } from "../../packages/gateway-contract/src/index.js";
5
5
  import { init_session_instance_repository, readCurrentTranscriptId } from "../storage/sqlite/session-instance-repository.js";
6
6
  import { getSessionInputById, init_session_input_repository } from "../storage/sqlite/session-input-repository.js";
7
7
  import { init_types, parseTurnContextRefs } from "../agent/source-context/types.js";
8
+ import { init_voice_transcript, isVoiceConversationMessage } from "../session/voice-transcript.js";
9
+ import { extractFtsContent, init_row_mappers } from "../storage/sqlite/row-mappers.js";
8
10
  import { TaskRepository, init_task_repository } from "./task-repository.js";
9
11
  import { getSessionMetadata } from "../storage/sqlite/session-read-repository.js";
10
12
  import { init_session_repository } from "../storage/sqlite/session-repository.js";
11
13
  import { getSessionConfig } from "../storage/sqlite/config-repository.js";
14
+ import { forgottenHistoryEntries, projectUnadmittedForgottenFields } from "../memory-learning/forgotten-history.js";
15
+ import { stripRuntimeContextFromUserMessage } from "../session/user-message-display.js";
16
+ import { canRecallHistoryEntry } from "../session/history-recall-policy.js";
12
17
  import { effectiveWorkspacePathForSession } from "../session/session-workspace.js";
13
18
  import { getProjectForSession } from "../projects/workspace.js";
14
19
  import { resolveMediaReference } from "../media/media-reference.js";
@@ -26,6 +31,8 @@ import { mkdir, open, realpath, stat, unlink } from "node:fs/promises";
26
31
  //#region src/tasks/task-handoff.ts
27
32
  init_src();
28
33
  init_types();
34
+ init_voice_transcript();
35
+ init_row_mappers();
29
36
  init_session_repository();
30
37
  init_task_repository();
31
38
  init_session_input_repository();
@@ -53,6 +60,73 @@ function parseTaskHandoffReferences(raw) {
53
60
  };
54
61
  }));
55
62
  }
63
+ function conversationExcerptSource(conversationId, entryId, config) {
64
+ if (config?.userContext.enabled === false || (getSessionConfig(conversationId)?.userContextMode ?? "enabled") !== "enabled") return void 0;
65
+ const row = getSqliteDatabase().prepare(`SELECT e.payload_json, e.role, t.cwd, s.agent_id, s.project_id
66
+ FROM sessions s JOIN transcripts t ON t.transcript_id = s.active_transcript_id
67
+ JOIN transcript_entries e ON e.transcript_id = t.transcript_id
68
+ WHERE s.conversation_id = ? AND e.entry_id = ? AND e.role IN ('user', 'assistant')
69
+ AND json_extract(e.payload_json, '$.type') IS NULL
70
+ AND json_extract(e.payload_json, '$.customType') IS NULL
71
+ AND COALESCE(json_extract(e.payload_json, '$.metadata.hiddenFromClient'), 0) != 1
72
+ AND COALESCE(json_extract(e.payload_json, '$.droppable'), 0) != 1`).get(conversationId, entryId);
73
+ if (!row) return void 0;
74
+ const message = JSON.parse(row.payload_json);
75
+ if (isVoiceConversationMessage(message)) return void 0;
76
+ const raw = extractFtsContent(message);
77
+ const content = row.role === "user" ? stripRuntimeContextFromUserMessage(raw) : raw;
78
+ if (!content.trim() || content.trim() === "NO_REPLY" || /(?:only|just).{0,20}this (?:chat|conversation|session)/iu.test(content)) return void 0;
79
+ const context = {
80
+ conversationId,
81
+ agentId: row.agent_id,
82
+ workspaceId: row.cwd,
83
+ projectId: row.project_id ?? void 0
84
+ };
85
+ const forgotten = forgottenHistoryEntries(context);
86
+ if (forgotten.has(`${conversationId}:*`) || forgotten.has(`${conversationId}:${entryId}`) || !canRecallHistoryEntry({
87
+ conversationId: "",
88
+ agentId: "",
89
+ workspaceId: ""
90
+ }, conversationId, entryId, content) || projectUnadmittedForgottenFields(content, context) !== content) return void 0;
91
+ return {
92
+ content,
93
+ role: row.role
94
+ };
95
+ }
96
+ /** Pin an exact, visible passage without copying the rest of its message into the Task. */
97
+ function parseTaskConversationExcerpts(conversationId, raw, config) {
98
+ if (raw === void 0) return [];
99
+ if (!conversationId || !Array.isArray(raw) || raw.length > 3) return null;
100
+ const excerpts = [];
101
+ for (const value of raw) {
102
+ const { entryId, quote } = value ?? {};
103
+ if (typeof entryId !== "string" || !entryId || entryId.length > 100 || typeof quote !== "string" || !quote.trim() || quote.length > 800 || excerpts.some((excerpt) => excerpt.entryId === entryId)) return null;
104
+ const start = conversationExcerptSource(conversationId, entryId, config)?.content.indexOf(quote) ?? -1;
105
+ if (start < 0) return null;
106
+ excerpts.push({
107
+ entryId,
108
+ start,
109
+ length: quote.length,
110
+ contentHash: hash(quote)
111
+ });
112
+ }
113
+ return excerpts;
114
+ }
115
+ function readTaskConversationExcerpts(handoff, config) {
116
+ assertTaskHandoffAccess(handoff);
117
+ return (handoff.conversationExcerpts ?? []).map((excerpt) => {
118
+ const source = conversationExcerptSource(handoff.conversationId, excerpt.entryId, config);
119
+ const text = source?.content.slice(excerpt.start, excerpt.start + excerpt.length);
120
+ return source && text && hash(text) === excerpt.contentHash ? {
121
+ entryId: excerpt.entryId,
122
+ role: source.role,
123
+ text
124
+ } : {
125
+ entryId: excerpt.entryId,
126
+ unavailable: true
127
+ };
128
+ });
129
+ }
56
130
  /** Called inside task.create's transaction; no discovery, parsing or remote IO. */
57
131
  function captureTaskHandoff(taskId, conversationId, interpretation, references) {
58
132
  const db = getSqliteDatabase();
@@ -87,6 +161,7 @@ function captureTaskHandoff(taskId, conversationId, interpretation, references)
87
161
  });
88
162
  }
89
163
  const requestedSources = references ?? new TaskContextRepository().list(taskId).filter((edge) => edge.metadata.kind === "task_reference_request").flatMap((edge) => parseTurnContextRefs([edge.metadata.ref]) ?? []);
164
+ const conversationExcerpts = new TaskContextRepository().list(taskId).filter((edge) => edge.metadata.kind === "task_conversation_excerpt").slice(0, 3).map((edge) => edge.metadata.excerpt).filter((excerpt) => Boolean(excerpt && typeof excerpt.entryId === "string" && Number.isSafeInteger(excerpt.start) && excerpt.start >= 0 && Number.isSafeInteger(excerpt.length) && excerpt.length > 0 && excerpt.length <= 800 && /^[a-f0-9]{64}$/.test(excerpt.contentHash ?? "")));
90
165
  const handoff = {
91
166
  version: 1,
92
167
  conversationId,
@@ -96,6 +171,7 @@ function captureTaskHandoff(taskId, conversationId, interpretation, references)
96
171
  interpretation,
97
172
  sources,
98
173
  requestedSources,
174
+ ...conversationExcerpts.length ? { conversationExcerpts } : {},
99
175
  baseline: {
100
176
  contractVersion: new TaskRepository().require(taskId).latestContractVersion,
101
177
  assignmentEpoch: Number(db.prepare("SELECT assignment_epoch FROM task_conversation_state WHERE task_id = ?").get(taskId)?.assignment_epoch ?? 0),
@@ -506,4 +582,4 @@ function assertTaskHandoffExecutorAccess(taskId, agentId) {
506
582
  }
507
583
  }
508
584
  //#endregion
509
- export { assertTaskHandoffAccess, assertTaskHandoffExecutorAccess, captureTaskHandoff, getTaskHandoff, materializeTaskHandoffFile, parseTaskHandoffReferences, readTaskHandoffSource, resolveTaskHandoffReferences };
585
+ export { assertTaskHandoffAccess, assertTaskHandoffExecutorAccess, captureTaskHandoff, getTaskHandoff, materializeTaskHandoffFile, parseTaskConversationExcerpts, parseTaskHandoffReferences, readTaskConversationExcerpts, readTaskHandoffSource, resolveTaskHandoffReferences };
@@ -0,0 +1,22 @@
1
+ import type { TaskEvidence, TaskRunReceipt } from '@xopcai/gateway-contract';
2
+ import { type TaskHandoff } from './task-handoff.js';
3
+ import type { TaskAggregate } from './task-repository.js';
4
+ import type { inspectTaskPublications } from './task-research-repair.js';
5
+ export declare function taskJsonAcceptance(task: TaskAggregate, handoff: TaskHandoff | undefined): {
6
+ file: string;
7
+ count: number;
8
+ fields: string[];
9
+ criteria: string[];
10
+ };
11
+ export declare function currentTaskJsonAcceptance(task: TaskAggregate, handoff: TaskHandoff | undefined): {
12
+ file: string;
13
+ count: number;
14
+ fields: string[];
15
+ criteria: string[];
16
+ };
17
+ export declare function verifyTaskJsonPublication(spec: NonNullable<ReturnType<typeof taskJsonAcceptance>>, item: ReturnType<typeof inspectTaskPublications>['latestPublishedArtifacts'][number], zh: boolean): {
18
+ sha256: string;
19
+ evidence: TaskEvidence;
20
+ checks: TaskRunReceipt['verification']['checks'];
21
+ summary: string;
22
+ } | undefined;