@aitne/daemon 0.1.7 → 0.1.8

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 (959) hide show
  1. package/dist/adapters/dashboard-adapter.d.ts +18 -2
  2. package/dist/adapters/dashboard-adapter.d.ts.map +1 -1
  3. package/dist/adapters/dashboard-adapter.js +101 -51
  4. package/dist/adapters/dashboard-adapter.js.map +1 -1
  5. package/dist/adapters/discord.d.ts +8 -0
  6. package/dist/adapters/discord.d.ts.map +1 -1
  7. package/dist/adapters/discord.js +100 -21
  8. package/dist/adapters/discord.js.map +1 -1
  9. package/dist/adapters/message-hub.d.ts.map +1 -1
  10. package/dist/adapters/message-hub.js +7 -1
  11. package/dist/adapters/message-hub.js.map +1 -1
  12. package/dist/adapters/notification-manager.d.ts +102 -2
  13. package/dist/adapters/notification-manager.d.ts.map +1 -1
  14. package/dist/adapters/notification-manager.js +228 -8
  15. package/dist/adapters/notification-manager.js.map +1 -1
  16. package/dist/adapters/outbound-text.d.ts +16 -0
  17. package/dist/adapters/outbound-text.d.ts.map +1 -1
  18. package/dist/adapters/outbound-text.js +118 -1
  19. package/dist/adapters/outbound-text.js.map +1 -1
  20. package/dist/adapters/primary-platform-resolver.d.ts +69 -0
  21. package/dist/adapters/primary-platform-resolver.d.ts.map +1 -0
  22. package/dist/adapters/primary-platform-resolver.js +55 -0
  23. package/dist/adapters/primary-platform-resolver.js.map +1 -0
  24. package/dist/adapters/slack-adapter.d.ts +28 -0
  25. package/dist/adapters/slack-adapter.d.ts.map +1 -1
  26. package/dist/adapters/slack-adapter.js +134 -35
  27. package/dist/adapters/slack-adapter.js.map +1 -1
  28. package/dist/adapters/telegram-adapter.d.ts +7 -1
  29. package/dist/adapters/telegram-adapter.d.ts.map +1 -1
  30. package/dist/adapters/telegram-adapter.js +49 -18
  31. package/dist/adapters/telegram-adapter.js.map +1 -1
  32. package/dist/adapters/whatsapp-adapter.d.ts +33 -0
  33. package/dist/adapters/whatsapp-adapter.d.ts.map +1 -1
  34. package/dist/adapters/whatsapp-adapter.js +84 -0
  35. package/dist/adapters/whatsapp-adapter.js.map +1 -1
  36. package/dist/api/directory-picker.d.ts.map +1 -1
  37. package/dist/api/directory-picker.js +14 -0
  38. package/dist/api/directory-picker.js.map +1 -1
  39. package/dist/api/env-writer.d.ts.map +1 -1
  40. package/dist/api/env-writer.js +6 -1
  41. package/dist/api/env-writer.js.map +1 -1
  42. package/dist/api/helpers/agent-errors.d.ts +2600 -0
  43. package/dist/api/helpers/agent-errors.d.ts.map +1 -0
  44. package/dist/api/helpers/agent-errors.js +2506 -0
  45. package/dist/api/helpers/agent-errors.js.map +1 -0
  46. package/dist/api/integration-route-gate.d.ts.map +1 -1
  47. package/dist/api/integration-route-gate.js +10 -3
  48. package/dist/api/integration-route-gate.js.map +1 -1
  49. package/dist/api/routes/agent-schedule-plan-match.d.ts +5 -0
  50. package/dist/api/routes/agent-schedule-plan-match.d.ts.map +1 -0
  51. package/dist/api/routes/agent-schedule-plan-match.js +101 -0
  52. package/dist/api/routes/agent-schedule-plan-match.js.map +1 -0
  53. package/dist/api/routes/agent-schedule.d.ts +4 -0
  54. package/dist/api/routes/agent-schedule.d.ts.map +1 -0
  55. package/dist/api/routes/agent-schedule.js +750 -0
  56. package/dist/api/routes/agent-schedule.js.map +1 -0
  57. package/dist/api/routes/agent.d.ts.map +1 -1
  58. package/dist/api/routes/agent.js +209 -366
  59. package/dist/api/routes/agent.js.map +1 -1
  60. package/dist/api/routes/apple-calendar.d.ts.map +1 -1
  61. package/dist/api/routes/apple-calendar.js +109 -27
  62. package/dist/api/routes/apple-calendar.js.map +1 -1
  63. package/dist/api/routes/attachments.d.ts.map +1 -1
  64. package/dist/api/routes/attachments.js +113 -21
  65. package/dist/api/routes/attachments.js.map +1 -1
  66. package/dist/api/routes/backends.d.ts.map +1 -1
  67. package/dist/api/routes/backends.js +100 -4
  68. package/dist/api/routes/backends.js.map +1 -1
  69. package/dist/api/routes/books.d.ts.map +1 -1
  70. package/dist/api/routes/books.js +58 -18
  71. package/dist/api/routes/books.js.map +1 -1
  72. package/dist/api/routes/calendar.d.ts +3 -2
  73. package/dist/api/routes/calendar.d.ts.map +1 -1
  74. package/dist/api/routes/calendar.js +330 -55
  75. package/dist/api/routes/calendar.js.map +1 -1
  76. package/dist/api/routes/commands.d.ts.map +1 -1
  77. package/dist/api/routes/commands.js +20 -1
  78. package/dist/api/routes/commands.js.map +1 -1
  79. package/dist/api/routes/context/index.d.ts +33 -0
  80. package/dist/api/routes/context/index.d.ts.map +1 -0
  81. package/dist/api/routes/context/index.js +193 -0
  82. package/dist/api/routes/context/index.js.map +1 -0
  83. package/dist/api/routes/context/locks.d.ts +4 -0
  84. package/dist/api/routes/context/locks.d.ts.map +1 -0
  85. package/dist/api/routes/context/locks.js +136 -0
  86. package/dist/api/routes/context/locks.js.map +1 -0
  87. package/dist/api/routes/context/path-resolve.d.ts +15 -0
  88. package/dist/api/routes/context/path-resolve.d.ts.map +1 -0
  89. package/dist/api/routes/context/path-resolve.js +109 -0
  90. package/dist/api/routes/context/path-resolve.js.map +1 -0
  91. package/dist/api/routes/context/permissions.d.ts +35 -0
  92. package/dist/api/routes/context/permissions.d.ts.map +1 -0
  93. package/dist/api/routes/context/permissions.js +192 -0
  94. package/dist/api/routes/context/permissions.js.map +1 -0
  95. package/dist/api/routes/context/read.d.ts +4 -0
  96. package/dist/api/routes/context/read.d.ts.map +1 -0
  97. package/dist/api/routes/context/read.js +295 -0
  98. package/dist/api/routes/context/read.js.map +1 -0
  99. package/dist/api/routes/context/repair.d.ts +4 -0
  100. package/dist/api/routes/context/repair.d.ts.map +1 -0
  101. package/dist/api/routes/context/repair.js +114 -0
  102. package/dist/api/routes/context/repair.js.map +1 -0
  103. package/dist/api/routes/context/snapshots.d.ts +4 -0
  104. package/dist/api/routes/context/snapshots.d.ts.map +1 -0
  105. package/dist/api/routes/context/snapshots.js +177 -0
  106. package/dist/api/routes/context/snapshots.js.map +1 -0
  107. package/dist/api/routes/context/write.d.ts +4 -0
  108. package/dist/api/routes/context/write.d.ts.map +1 -0
  109. package/dist/api/routes/context/write.js +570 -0
  110. package/dist/api/routes/context/write.js.map +1 -0
  111. package/dist/api/routes/context.d.ts +2 -43
  112. package/dist/api/routes/context.d.ts.map +1 -1
  113. package/dist/api/routes/context.js +415 -558
  114. package/dist/api/routes/context.js.map +1 -1
  115. package/dist/api/routes/dashboard/config.d.ts +4 -0
  116. package/dist/api/routes/dashboard/config.d.ts.map +1 -0
  117. package/dist/api/routes/dashboard/config.js +499 -0
  118. package/dist/api/routes/dashboard/config.js.map +1 -0
  119. package/dist/api/routes/dashboard/conversations.d.ts +4 -0
  120. package/dist/api/routes/dashboard/conversations.d.ts.map +1 -0
  121. package/dist/api/routes/dashboard/conversations.js +309 -0
  122. package/dist/api/routes/dashboard/conversations.js.map +1 -0
  123. package/dist/api/routes/dashboard/cost-approvals.d.ts +29 -0
  124. package/dist/api/routes/dashboard/cost-approvals.d.ts.map +1 -0
  125. package/dist/api/routes/dashboard/cost-approvals.js +259 -0
  126. package/dist/api/routes/dashboard/cost-approvals.js.map +1 -0
  127. package/dist/api/routes/dashboard/index.d.ts +27 -0
  128. package/dist/api/routes/dashboard/index.d.ts.map +1 -0
  129. package/dist/api/routes/dashboard/index.js +47 -0
  130. package/dist/api/routes/dashboard/index.js.map +1 -0
  131. package/dist/api/routes/dashboard/messaging.d.ts +4 -0
  132. package/dist/api/routes/dashboard/messaging.d.ts.map +1 -0
  133. package/dist/api/routes/dashboard/messaging.js +351 -0
  134. package/dist/api/routes/dashboard/messaging.js.map +1 -0
  135. package/dist/api/routes/dashboard/notifications.d.ts +4 -0
  136. package/dist/api/routes/dashboard/notifications.d.ts.map +1 -0
  137. package/dist/api/routes/dashboard/notifications.js +109 -0
  138. package/dist/api/routes/dashboard/notifications.js.map +1 -0
  139. package/dist/api/routes/dashboard/oauth-google.d.ts +4 -0
  140. package/dist/api/routes/dashboard/oauth-google.d.ts.map +1 -0
  141. package/dist/api/routes/dashboard/oauth-google.js +293 -0
  142. package/dist/api/routes/dashboard/oauth-google.js.map +1 -0
  143. package/dist/api/routes/dashboard/schedule-readonly.d.ts +4 -0
  144. package/dist/api/routes/dashboard/schedule-readonly.d.ts.map +1 -0
  145. package/dist/api/routes/dashboard/schedule-readonly.js +46 -0
  146. package/dist/api/routes/dashboard/schedule-readonly.js.map +1 -0
  147. package/dist/api/routes/dashboard/secrets.d.ts +24 -0
  148. package/dist/api/routes/dashboard/secrets.d.ts.map +1 -0
  149. package/dist/api/routes/dashboard/secrets.js +307 -0
  150. package/dist/api/routes/dashboard/secrets.js.map +1 -0
  151. package/dist/api/routes/dashboard/snapshots.d.ts +4 -0
  152. package/dist/api/routes/dashboard/snapshots.d.ts.map +1 -0
  153. package/dist/api/routes/dashboard/snapshots.js +33 -0
  154. package/dist/api/routes/dashboard/snapshots.js.map +1 -0
  155. package/dist/api/routes/dashboard.d.ts.map +1 -1
  156. package/dist/api/routes/dashboard.js +20 -12
  157. package/dist/api/routes/dashboard.js.map +1 -1
  158. package/dist/api/routes/delegated.d.ts +5 -4
  159. package/dist/api/routes/delegated.d.ts.map +1 -1
  160. package/dist/api/routes/delegated.js +6 -5
  161. package/dist/api/routes/delegated.js.map +1 -1
  162. package/dist/api/routes/docs.d.ts.map +1 -1
  163. package/dist/api/routes/docs.js +72 -9
  164. package/dist/api/routes/docs.js.map +1 -1
  165. package/dist/api/routes/entities.d.ts.map +1 -1
  166. package/dist/api/routes/entities.js +112 -43
  167. package/dist/api/routes/entities.js.map +1 -1
  168. package/dist/api/routes/fs.d.ts.map +1 -1
  169. package/dist/api/routes/fs.js +27 -12
  170. package/dist/api/routes/fs.js.map +1 -1
  171. package/dist/api/routes/git-templates.d.ts.map +1 -1
  172. package/dist/api/routes/git-templates.js +107 -27
  173. package/dist/api/routes/git-templates.js.map +1 -1
  174. package/dist/api/routes/git.d.ts.map +1 -1
  175. package/dist/api/routes/git.js +55 -11
  176. package/dist/api/routes/git.js.map +1 -1
  177. package/dist/api/routes/github.d.ts.map +1 -1
  178. package/dist/api/routes/github.js +110 -17
  179. package/dist/api/routes/github.js.map +1 -1
  180. package/dist/api/routes/integrations/crud-patch.d.ts +17 -0
  181. package/dist/api/routes/integrations/crud-patch.d.ts.map +1 -0
  182. package/dist/api/routes/integrations/crud-patch.js +600 -0
  183. package/dist/api/routes/integrations/crud-patch.js.map +1 -0
  184. package/dist/api/routes/integrations/crud.d.ts +16 -0
  185. package/dist/api/routes/integrations/crud.d.ts.map +1 -0
  186. package/dist/api/routes/integrations/crud.js +158 -0
  187. package/dist/api/routes/integrations/crud.js.map +1 -0
  188. package/dist/api/routes/integrations/exec.d.ts +23 -0
  189. package/dist/api/routes/integrations/exec.d.ts.map +1 -0
  190. package/dist/api/routes/integrations/exec.js +356 -0
  191. package/dist/api/routes/integrations/exec.js.map +1 -0
  192. package/dist/api/routes/integrations/index.d.ts +62 -0
  193. package/dist/api/routes/integrations/index.d.ts.map +1 -0
  194. package/dist/api/routes/integrations/index.js +70 -0
  195. package/dist/api/routes/integrations/index.js.map +1 -0
  196. package/dist/api/routes/integrations/integrations/crud.d.ts +16 -0
  197. package/dist/api/routes/integrations/integrations/crud.d.ts.map +1 -0
  198. package/dist/api/routes/integrations/integrations/crud.js +158 -0
  199. package/dist/api/routes/integrations/integrations/crud.js.map +1 -0
  200. package/dist/api/routes/integrations/integrations/index.d.ts +55 -0
  201. package/dist/api/routes/integrations/integrations/index.d.ts.map +1 -0
  202. package/dist/api/routes/integrations/integrations/index.js +65 -0
  203. package/dist/api/routes/integrations/integrations/index.js.map +1 -0
  204. package/dist/api/routes/integrations/integrations/invoke.d.ts +38 -0
  205. package/dist/api/routes/integrations/integrations/invoke.d.ts.map +1 -0
  206. package/dist/api/routes/integrations/integrations/invoke.js +320 -0
  207. package/dist/api/routes/integrations/integrations/invoke.js.map +1 -0
  208. package/dist/api/routes/integrations/integrations/probe.d.ts +21 -0
  209. package/dist/api/routes/integrations/integrations/probe.d.ts.map +1 -0
  210. package/dist/api/routes/integrations/integrations/probe.js +247 -0
  211. package/dist/api/routes/integrations/integrations/probe.js.map +1 -0
  212. package/dist/api/routes/integrations/invoke.d.ts +38 -0
  213. package/dist/api/routes/integrations/invoke.d.ts.map +1 -0
  214. package/dist/api/routes/integrations/invoke.js +320 -0
  215. package/dist/api/routes/integrations/invoke.js.map +1 -0
  216. package/dist/api/routes/integrations/probe.d.ts +21 -0
  217. package/dist/api/routes/integrations/probe.d.ts.map +1 -0
  218. package/dist/api/routes/integrations/probe.js +247 -0
  219. package/dist/api/routes/integrations/probe.js.map +1 -0
  220. package/dist/api/routes/integrations.d.ts.map +1 -1
  221. package/dist/api/routes/integrations.js +65 -13
  222. package/dist/api/routes/integrations.js.map +1 -1
  223. package/dist/api/routes/knowledge.d.ts.map +1 -1
  224. package/dist/api/routes/knowledge.js +13 -2
  225. package/dist/api/routes/knowledge.js.map +1 -1
  226. package/dist/api/routes/mail/_pa_wip_mail/app-password.d.ts +4 -0
  227. package/dist/api/routes/mail/_pa_wip_mail/app-password.d.ts.map +1 -0
  228. package/dist/api/routes/mail/_pa_wip_mail/app-password.js +192 -0
  229. package/dist/api/routes/mail/_pa_wip_mail/app-password.js.map +1 -0
  230. package/dist/api/routes/mail/_pa_wip_mail/body-helpers.d.ts +55 -0
  231. package/dist/api/routes/mail/_pa_wip_mail/body-helpers.d.ts.map +1 -0
  232. package/dist/api/routes/mail/_pa_wip_mail/body-helpers.js +91 -0
  233. package/dist/api/routes/mail/_pa_wip_mail/body-helpers.js.map +1 -0
  234. package/dist/api/routes/mail/_pa_wip_mail/dependencies.d.ts +36 -0
  235. package/dist/api/routes/mail/_pa_wip_mail/dependencies.d.ts.map +1 -0
  236. package/dist/api/routes/mail/_pa_wip_mail/dependencies.js +2 -0
  237. package/dist/api/routes/mail/_pa_wip_mail/dependencies.js.map +1 -0
  238. package/dist/api/routes/mail/_pa_wip_mail/gating.d.ts +45 -0
  239. package/dist/api/routes/mail/_pa_wip_mail/gating.d.ts.map +1 -0
  240. package/dist/api/routes/mail/_pa_wip_mail/gating.js +98 -0
  241. package/dist/api/routes/mail/_pa_wip_mail/gating.js.map +1 -0
  242. package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.d.ts +4 -0
  243. package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.d.ts.map +1 -0
  244. package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.js +289 -0
  245. package/dist/api/routes/mail/_pa_wip_mail/mail/accounts.js.map +1 -0
  246. package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.d.ts +4 -0
  247. package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.d.ts.map +1 -0
  248. package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.js +192 -0
  249. package/dist/api/routes/mail/_pa_wip_mail/mail/app-password.js.map +1 -0
  250. package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.d.ts +55 -0
  251. package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.d.ts.map +1 -0
  252. package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.js +91 -0
  253. package/dist/api/routes/mail/_pa_wip_mail/mail/body-helpers.js.map +1 -0
  254. package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.d.ts +36 -0
  255. package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.d.ts.map +1 -0
  256. package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.js +2 -0
  257. package/dist/api/routes/mail/_pa_wip_mail/mail/dependencies.js.map +1 -0
  258. package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.d.ts +5 -0
  259. package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.d.ts.map +1 -0
  260. package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.js +139 -0
  261. package/dist/api/routes/mail/_pa_wip_mail/mail/drafts.js.map +1 -0
  262. package/dist/api/routes/mail/_pa_wip_mail/mail/gating.d.ts +45 -0
  263. package/dist/api/routes/mail/_pa_wip_mail/mail/gating.d.ts.map +1 -0
  264. package/dist/api/routes/mail/_pa_wip_mail/mail/gating.js +98 -0
  265. package/dist/api/routes/mail/_pa_wip_mail/mail/gating.js.map +1 -0
  266. package/dist/api/routes/mail/_pa_wip_mail/mail/index.d.ts +18 -0
  267. package/dist/api/routes/mail/_pa_wip_mail/mail/index.d.ts.map +1 -0
  268. package/dist/api/routes/mail/_pa_wip_mail/mail/index.js +40 -0
  269. package/dist/api/routes/mail/_pa_wip_mail/mail/index.js.map +1 -0
  270. package/dist/api/routes/mail/_pa_wip_mail/mail/messages.d.ts +15 -0
  271. package/dist/api/routes/mail/_pa_wip_mail/mail/messages.d.ts.map +1 -0
  272. package/dist/api/routes/mail/_pa_wip_mail/mail/messages.js +239 -0
  273. package/dist/api/routes/mail/_pa_wip_mail/mail/messages.js.map +1 -0
  274. package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.d.ts +4 -0
  275. package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.d.ts.map +1 -0
  276. package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.js +73 -0
  277. package/dist/api/routes/mail/_pa_wip_mail/mail/outlook-config.js.map +1 -0
  278. package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.d.ts +64 -0
  279. package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.d.ts.map +1 -0
  280. package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.js +286 -0
  281. package/dist/api/routes/mail/_pa_wip_mail/mail/provider-resolver.js.map +1 -0
  282. package/dist/api/routes/mail/_pa_wip_mail/mail/providers.d.ts +4 -0
  283. package/dist/api/routes/mail/_pa_wip_mail/mail/providers.d.ts.map +1 -0
  284. package/dist/api/routes/mail/_pa_wip_mail/mail/providers.js +73 -0
  285. package/dist/api/routes/mail/_pa_wip_mail/mail/providers.js.map +1 -0
  286. package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.d.ts +5 -0
  287. package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.d.ts.map +1 -0
  288. package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.js +35 -0
  289. package/dist/api/routes/mail/_pa_wip_mail/mail/tags-folders.js.map +1 -0
  290. package/dist/api/routes/mail/_pa_wip_mail/mail/validators.d.ts +23 -0
  291. package/dist/api/routes/mail/_pa_wip_mail/mail/validators.d.ts.map +1 -0
  292. package/dist/api/routes/mail/_pa_wip_mail/mail/validators.js +131 -0
  293. package/dist/api/routes/mail/_pa_wip_mail/mail/validators.js.map +1 -0
  294. package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.d.ts +64 -0
  295. package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.d.ts.map +1 -0
  296. package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.js +286 -0
  297. package/dist/api/routes/mail/_pa_wip_mail/provider-resolver.js.map +1 -0
  298. package/dist/api/routes/mail/_pa_wip_mail/search-health.d.ts +4 -0
  299. package/dist/api/routes/mail/_pa_wip_mail/search-health.d.ts.map +1 -0
  300. package/dist/api/routes/mail/_pa_wip_mail/search-health.js +131 -0
  301. package/dist/api/routes/mail/_pa_wip_mail/search-health.js.map +1 -0
  302. package/dist/api/routes/mail/_pa_wip_mail/validators.d.ts +23 -0
  303. package/dist/api/routes/mail/_pa_wip_mail/validators.d.ts.map +1 -0
  304. package/dist/api/routes/mail/_pa_wip_mail/validators.js +131 -0
  305. package/dist/api/routes/mail/_pa_wip_mail/validators.js.map +1 -0
  306. package/dist/api/routes/mail/accounts.d.ts +4 -0
  307. package/dist/api/routes/mail/accounts.d.ts.map +1 -0
  308. package/dist/api/routes/mail/accounts.js +289 -0
  309. package/dist/api/routes/mail/accounts.js.map +1 -0
  310. package/dist/api/routes/mail/app-password.d.ts +4 -0
  311. package/dist/api/routes/mail/app-password.d.ts.map +1 -0
  312. package/dist/api/routes/mail/app-password.js +192 -0
  313. package/dist/api/routes/mail/app-password.js.map +1 -0
  314. package/dist/api/routes/mail/body-helpers.d.ts +56 -0
  315. package/dist/api/routes/mail/body-helpers.d.ts.map +1 -0
  316. package/dist/api/routes/mail/body-helpers.js +91 -0
  317. package/dist/api/routes/mail/body-helpers.js.map +1 -0
  318. package/dist/api/routes/mail/dependencies.d.ts +36 -0
  319. package/dist/api/routes/mail/dependencies.d.ts.map +1 -0
  320. package/dist/api/routes/mail/dependencies.js +2 -0
  321. package/dist/api/routes/mail/dependencies.js.map +1 -0
  322. package/dist/api/routes/mail/drafts.d.ts +5 -0
  323. package/dist/api/routes/mail/drafts.d.ts.map +1 -0
  324. package/dist/api/routes/mail/drafts.js +139 -0
  325. package/dist/api/routes/mail/drafts.js.map +1 -0
  326. package/dist/api/routes/mail/gating.d.ts +45 -0
  327. package/dist/api/routes/mail/gating.d.ts.map +1 -0
  328. package/dist/api/routes/mail/gating.js +99 -0
  329. package/dist/api/routes/mail/gating.js.map +1 -0
  330. package/dist/api/routes/mail/index.d.ts +18 -0
  331. package/dist/api/routes/mail/index.d.ts.map +1 -0
  332. package/dist/api/routes/mail/index.js +40 -0
  333. package/dist/api/routes/mail/index.js.map +1 -0
  334. package/dist/api/routes/mail/messages.d.ts +15 -0
  335. package/dist/api/routes/mail/messages.d.ts.map +1 -0
  336. package/dist/api/routes/mail/messages.js +239 -0
  337. package/dist/api/routes/mail/messages.js.map +1 -0
  338. package/dist/api/routes/mail/outlook-config.d.ts +4 -0
  339. package/dist/api/routes/mail/outlook-config.d.ts.map +1 -0
  340. package/dist/api/routes/mail/outlook-config.js +73 -0
  341. package/dist/api/routes/mail/outlook-config.js.map +1 -0
  342. package/dist/api/routes/mail/provider-resolver.d.ts +64 -0
  343. package/dist/api/routes/mail/provider-resolver.d.ts.map +1 -0
  344. package/dist/api/routes/mail/provider-resolver.js +286 -0
  345. package/dist/api/routes/mail/provider-resolver.js.map +1 -0
  346. package/dist/api/routes/mail/providers.d.ts +4 -0
  347. package/dist/api/routes/mail/providers.d.ts.map +1 -0
  348. package/dist/api/routes/mail/providers.js +73 -0
  349. package/dist/api/routes/mail/providers.js.map +1 -0
  350. package/dist/api/routes/mail/search-health.d.ts +4 -0
  351. package/dist/api/routes/mail/search-health.d.ts.map +1 -0
  352. package/dist/api/routes/mail/search-health.js +131 -0
  353. package/dist/api/routes/mail/search-health.js.map +1 -0
  354. package/dist/api/routes/mail/tags-folders.d.ts +5 -0
  355. package/dist/api/routes/mail/tags-folders.d.ts.map +1 -0
  356. package/dist/api/routes/mail/tags-folders.js +35 -0
  357. package/dist/api/routes/mail/tags-folders.js.map +1 -0
  358. package/dist/api/routes/mail/validators.d.ts +23 -0
  359. package/dist/api/routes/mail/validators.d.ts.map +1 -0
  360. package/dist/api/routes/mail/validators.js +131 -0
  361. package/dist/api/routes/mail/validators.js.map +1 -0
  362. package/dist/api/routes/mail.d.ts.map +1 -1
  363. package/dist/api/routes/mail.js +259 -67
  364. package/dist/api/routes/mail.js.map +1 -1
  365. package/dist/api/routes/managed-tasks.d.ts.map +1 -1
  366. package/dist/api/routes/managed-tasks.js +142 -54
  367. package/dist/api/routes/managed-tasks.js.map +1 -1
  368. package/dist/api/routes/mcp.d.ts.map +1 -1
  369. package/dist/api/routes/mcp.js +115 -47
  370. package/dist/api/routes/mcp.js.map +1 -1
  371. package/dist/api/routes/metrics.d.ts +1 -1
  372. package/dist/api/routes/metrics.js +2 -2
  373. package/dist/api/routes/notion.d.ts.map +1 -1
  374. package/dist/api/routes/notion.js +230 -54
  375. package/dist/api/routes/notion.js.map +1 -1
  376. package/dist/api/routes/observations.d.ts.map +1 -1
  377. package/dist/api/routes/observations.js +40 -169
  378. package/dist/api/routes/observations.js.map +1 -1
  379. package/dist/api/routes/obsidian.d.ts.map +1 -1
  380. package/dist/api/routes/obsidian.js +193 -32
  381. package/dist/api/routes/obsidian.js.map +1 -1
  382. package/dist/api/routes/profile-questions.d.ts.map +1 -1
  383. package/dist/api/routes/profile-questions.js +19 -3
  384. package/dist/api/routes/profile-questions.js.map +1 -1
  385. package/dist/api/routes/receipts.d.ts.map +1 -1
  386. package/dist/api/routes/receipts.js +64 -24
  387. package/dist/api/routes/receipts.js.map +1 -1
  388. package/dist/api/routes/recurring-schedules.d.ts.map +1 -1
  389. package/dist/api/routes/recurring-schedules.js +243 -13
  390. package/dist/api/routes/recurring-schedules.js.map +1 -1
  391. package/dist/api/routes/repositories.d.ts.map +1 -1
  392. package/dist/api/routes/repositories.js +278 -104
  393. package/dist/api/routes/repositories.js.map +1 -1
  394. package/dist/api/routes/schedule-model-resolver.d.ts +153 -0
  395. package/dist/api/routes/schedule-model-resolver.d.ts.map +1 -0
  396. package/dist/api/routes/schedule-model-resolver.js +282 -0
  397. package/dist/api/routes/schedule-model-resolver.js.map +1 -0
  398. package/dist/api/routes/schedule-options.d.ts +25 -0
  399. package/dist/api/routes/schedule-options.d.ts.map +1 -0
  400. package/dist/api/routes/schedule-options.js +77 -0
  401. package/dist/api/routes/schedule-options.js.map +1 -0
  402. package/dist/api/routes/schedule-validation.d.ts +146 -0
  403. package/dist/api/routes/schedule-validation.d.ts.map +1 -0
  404. package/dist/api/routes/schedule-validation.js +153 -0
  405. package/dist/api/routes/schedule-validation.js.map +1 -0
  406. package/dist/api/routes/setup.d.ts.map +1 -1
  407. package/dist/api/routes/setup.js +100 -26
  408. package/dist/api/routes/setup.js.map +1 -1
  409. package/dist/api/routes/skills.d.ts.map +1 -1
  410. package/dist/api/routes/skills.js +81 -30
  411. package/dist/api/routes/skills.js.map +1 -1
  412. package/dist/api/routes/sot-bindings.d.ts.map +1 -1
  413. package/dist/api/routes/sot-bindings.js +46 -11
  414. package/dist/api/routes/sot-bindings.js.map +1 -1
  415. package/dist/api/routes/sse.d.ts.map +1 -1
  416. package/dist/api/routes/sse.js +6 -1
  417. package/dist/api/routes/sse.js.map +1 -1
  418. package/dist/api/routes/system.d.ts.map +1 -1
  419. package/dist/api/routes/system.js +15 -2
  420. package/dist/api/routes/system.js.map +1 -1
  421. package/dist/api/routes/travel-bookings.d.ts.map +1 -1
  422. package/dist/api/routes/travel-bookings.js +26 -9
  423. package/dist/api/routes/travel-bookings.js.map +1 -1
  424. package/dist/api/routes/travel-time.d.ts.map +1 -1
  425. package/dist/api/routes/travel-time.js +50 -10
  426. package/dist/api/routes/travel-time.js.map +1 -1
  427. package/dist/api/routes/wiki.d.ts.map +1 -1
  428. package/dist/api/routes/wiki.js +49 -8
  429. package/dist/api/routes/wiki.js.map +1 -1
  430. package/dist/api/server.d.ts +15 -3
  431. package/dist/api/server.d.ts.map +1 -1
  432. package/dist/api/server.js +32 -10
  433. package/dist/api/server.js.map +1 -1
  434. package/dist/bootstrap/adapters.d.ts.map +1 -1
  435. package/dist/bootstrap/adapters.js +7 -4
  436. package/dist/bootstrap/adapters.js.map +1 -1
  437. package/dist/bootstrap/api.d.ts +205 -0
  438. package/dist/bootstrap/api.d.ts.map +1 -0
  439. package/dist/bootstrap/api.js +443 -0
  440. package/dist/bootstrap/api.js.map +1 -0
  441. package/dist/bootstrap/db.d.ts +119 -0
  442. package/dist/bootstrap/db.d.ts.map +1 -0
  443. package/dist/bootstrap/db.js +294 -0
  444. package/dist/bootstrap/db.js.map +1 -0
  445. package/dist/bootstrap/event-pipeline.d.ts +308 -0
  446. package/dist/bootstrap/event-pipeline.d.ts.map +1 -0
  447. package/dist/bootstrap/event-pipeline.js +704 -0
  448. package/dist/bootstrap/event-pipeline.js.map +1 -0
  449. package/dist/bootstrap/observers.d.ts +148 -0
  450. package/dist/bootstrap/observers.d.ts.map +1 -0
  451. package/dist/bootstrap/observers.js +558 -0
  452. package/dist/bootstrap/observers.js.map +1 -0
  453. package/dist/bootstrap/schedule-helpers.d.ts +122 -0
  454. package/dist/bootstrap/schedule-helpers.d.ts.map +1 -1
  455. package/dist/bootstrap/schedule-helpers.js +202 -4
  456. package/dist/bootstrap/schedule-helpers.js.map +1 -1
  457. package/dist/config.d.ts.map +1 -1
  458. package/dist/config.js +20 -3
  459. package/dist/config.js.map +1 -1
  460. package/dist/core/abort-utils.d.ts +14 -0
  461. package/dist/core/abort-utils.d.ts.map +1 -0
  462. package/dist/core/abort-utils.js +36 -0
  463. package/dist/core/abort-utils.js.map +1 -0
  464. package/dist/core/agent-core.d.ts +22 -3
  465. package/dist/core/agent-core.d.ts.map +1 -1
  466. package/dist/core/agent-core.js +3 -1
  467. package/dist/core/agent-core.js.map +1 -1
  468. package/dist/core/backends/auth-health-monitor.js +2 -3
  469. package/dist/core/backends/auth-health-monitor.js.map +1 -1
  470. package/dist/core/backends/backend-router.d.ts +11 -1
  471. package/dist/core/backends/backend-router.d.ts.map +1 -1
  472. package/dist/core/backends/backend-router.js +97 -2
  473. package/dist/core/backends/backend-router.js.map +1 -1
  474. package/dist/core/backends/claude-code-core.d.ts +51 -0
  475. package/dist/core/backends/claude-code-core.d.ts.map +1 -1
  476. package/dist/core/backends/claude-code-core.js +134 -11
  477. package/dist/core/backends/claude-code-core.js.map +1 -1
  478. package/dist/core/backends/claude-tool-collection.js +1 -1
  479. package/dist/core/backends/codex-core.d.ts +13 -1
  480. package/dist/core/backends/codex-core.d.ts.map +1 -1
  481. package/dist/core/backends/codex-core.js +436 -22
  482. package/dist/core/backends/codex-core.js.map +1 -1
  483. package/dist/core/backends/gemini-cli-core.d.ts +5 -1
  484. package/dist/core/backends/gemini-cli-core.d.ts.map +1 -1
  485. package/dist/core/backends/gemini-cli-core.js +298 -15
  486. package/dist/core/backends/gemini-cli-core.js.map +1 -1
  487. package/dist/core/backends/install-methods.d.ts.map +1 -1
  488. package/dist/core/backends/install-methods.js +22 -0
  489. package/dist/core/backends/install-methods.js.map +1 -1
  490. package/dist/core/backends/model-registry.d.ts +9 -4
  491. package/dist/core/backends/model-registry.d.ts.map +1 -1
  492. package/dist/core/backends/model-registry.js +153 -23
  493. package/dist/core/backends/model-registry.js.map +1 -1
  494. package/dist/core/backends/native-skill-discovery-probe.d.ts +80 -0
  495. package/dist/core/backends/native-skill-discovery-probe.d.ts.map +1 -0
  496. package/dist/core/backends/native-skill-discovery-probe.js +175 -0
  497. package/dist/core/backends/native-skill-discovery-probe.js.map +1 -0
  498. package/dist/core/backends/opencode-basic-auth-fetch.d.ts +27 -0
  499. package/dist/core/backends/opencode-basic-auth-fetch.d.ts.map +1 -0
  500. package/dist/core/backends/opencode-basic-auth-fetch.js +40 -0
  501. package/dist/core/backends/opencode-basic-auth-fetch.js.map +1 -0
  502. package/dist/core/backends/opencode-config-builder.d.ts +86 -0
  503. package/dist/core/backends/opencode-config-builder.d.ts.map +1 -0
  504. package/dist/core/backends/opencode-config-builder.js +172 -0
  505. package/dist/core/backends/opencode-config-builder.js.map +1 -0
  506. package/dist/core/backends/opencode-core.d.ts +316 -0
  507. package/dist/core/backends/opencode-core.d.ts.map +1 -0
  508. package/dist/core/backends/opencode-core.js +1502 -0
  509. package/dist/core/backends/opencode-core.js.map +1 -0
  510. package/dist/core/backends/opencode-event-mapper.d.ts +133 -0
  511. package/dist/core/backends/opencode-event-mapper.d.ts.map +1 -0
  512. package/dist/core/backends/opencode-event-mapper.js +198 -0
  513. package/dist/core/backends/opencode-event-mapper.js.map +1 -0
  514. package/dist/core/backends/opencode-mcp.d.ts +82 -0
  515. package/dist/core/backends/opencode-mcp.d.ts.map +1 -0
  516. package/dist/core/backends/opencode-mcp.js +165 -0
  517. package/dist/core/backends/opencode-mcp.js.map +1 -0
  518. package/dist/core/backends/opencode-server-manager.d.ts +114 -0
  519. package/dist/core/backends/opencode-server-manager.d.ts.map +1 -0
  520. package/dist/core/backends/opencode-server-manager.js +222 -0
  521. package/dist/core/backends/opencode-server-manager.js.map +1 -0
  522. package/dist/core/backends/opencode-types.d.ts +46 -0
  523. package/dist/core/backends/opencode-types.d.ts.map +1 -0
  524. package/dist/core/backends/opencode-types.js +14 -0
  525. package/dist/core/backends/opencode-types.js.map +1 -0
  526. package/dist/core/backends/plan-presets.d.ts +18 -5
  527. package/dist/core/backends/plan-presets.d.ts.map +1 -1
  528. package/dist/core/backends/plan-presets.js +144 -23
  529. package/dist/core/backends/plan-presets.js.map +1 -1
  530. package/dist/core/backends/process-config-cascade.d.ts +35 -0
  531. package/dist/core/backends/process-config-cascade.d.ts.map +1 -1
  532. package/dist/core/backends/process-config-cascade.js +35 -1
  533. package/dist/core/backends/process-config-cascade.js.map +1 -1
  534. package/dist/core/backends/prompt-utils.d.ts.map +1 -1
  535. package/dist/core/backends/prompt-utils.js +0 -2
  536. package/dist/core/backends/prompt-utils.js.map +1 -1
  537. package/dist/core/backends/quota-reset-hints.d.ts +44 -0
  538. package/dist/core/backends/quota-reset-hints.d.ts.map +1 -0
  539. package/dist/core/backends/quota-reset-hints.js +117 -0
  540. package/dist/core/backends/quota-reset-hints.js.map +1 -0
  541. package/dist/core/bang-commands/commands-close.d.ts +24 -0
  542. package/dist/core/bang-commands/commands-close.d.ts.map +1 -0
  543. package/dist/core/bang-commands/commands-close.js +24 -0
  544. package/dist/core/bang-commands/commands-close.js.map +1 -0
  545. package/dist/core/bang-commands/commands-cost.d.ts.map +1 -1
  546. package/dist/core/bang-commands/commands-cost.js +13 -0
  547. package/dist/core/bang-commands/commands-cost.js.map +1 -1
  548. package/dist/core/bang-commands/commands-help.d.ts.map +1 -1
  549. package/dist/core/bang-commands/commands-help.js +44 -5
  550. package/dist/core/bang-commands/commands-help.js.map +1 -1
  551. package/dist/core/bang-commands/commands-report.d.ts.map +1 -1
  552. package/dist/core/bang-commands/commands-report.js +1 -0
  553. package/dist/core/bang-commands/commands-report.js.map +1 -1
  554. package/dist/core/bang-commands/commands-stop-start.d.ts.map +1 -1
  555. package/dist/core/bang-commands/commands-stop-start.js +2 -0
  556. package/dist/core/bang-commands/commands-stop-start.js.map +1 -1
  557. package/dist/core/bang-commands/commands-wiki.d.ts.map +1 -1
  558. package/dist/core/bang-commands/commands-wiki.js +12 -1
  559. package/dist/core/bang-commands/commands-wiki.js.map +1 -1
  560. package/dist/core/bang-commands/format-utils.d.ts +13 -1
  561. package/dist/core/bang-commands/format-utils.d.ts.map +1 -1
  562. package/dist/core/bang-commands/format-utils.js +21 -2
  563. package/dist/core/bang-commands/format-utils.js.map +1 -1
  564. package/dist/core/bang-commands/index.d.ts +1 -0
  565. package/dist/core/bang-commands/index.d.ts.map +1 -1
  566. package/dist/core/bang-commands/index.js +3 -0
  567. package/dist/core/bang-commands/index.js.map +1 -1
  568. package/dist/core/bang-commands/registry.d.ts +50 -0
  569. package/dist/core/bang-commands/registry.d.ts.map +1 -1
  570. package/dist/core/bang-commands/registry.js +164 -19
  571. package/dist/core/bang-commands/registry.js.map +1 -1
  572. package/dist/core/channel-timeline.d.ts +18 -1
  573. package/dist/core/channel-timeline.d.ts.map +1 -1
  574. package/dist/core/channel-timeline.js +44 -0
  575. package/dist/core/channel-timeline.js.map +1 -1
  576. package/dist/core/context/activity-view-runner.js +9 -1
  577. package/dist/core/context/activity-view-runner.js.map +1 -1
  578. package/dist/core/context/default-schedules-runner.js +44 -4
  579. package/dist/core/context/default-schedules-runner.js.map +1 -1
  580. package/dist/core/context/domain-index-runner.js +9 -1
  581. package/dist/core/context/domain-index-runner.js.map +1 -1
  582. package/dist/core/context/entity-source-rename.d.ts.map +1 -1
  583. package/dist/core/context/entity-source-rename.js +9 -1
  584. package/dist/core/context/entity-source-rename.js.map +1 -1
  585. package/dist/core/context/policy-index-runner.js +9 -1
  586. package/dist/core/context/policy-index-runner.js.map +1 -1
  587. package/dist/core/context/reconciler-runner.js +9 -1
  588. package/dist/core/context/reconciler-runner.js.map +1 -1
  589. package/dist/core/context-builder.d.ts +97 -2
  590. package/dist/core/context-builder.d.ts.map +1 -1
  591. package/dist/core/context-builder.js +303 -30
  592. package/dist/core/context-builder.js.map +1 -1
  593. package/dist/core/context-frontmatter.d.ts +6 -0
  594. package/dist/core/context-frontmatter.d.ts.map +1 -1
  595. package/dist/core/context-frontmatter.js +120 -8
  596. package/dist/core/context-frontmatter.js.map +1 -1
  597. package/dist/core/context-health.js +21 -9
  598. package/dist/core/context-health.js.map +1 -1
  599. package/dist/core/context-validation/_pa_wip_context_validation/index.d.ts +19 -0
  600. package/dist/core/context-validation/_pa_wip_context_validation/index.d.ts.map +1 -0
  601. package/dist/core/context-validation/_pa_wip_context_validation/index.js +19 -0
  602. package/dist/core/context-validation/_pa_wip_context_validation/index.js.map +1 -0
  603. package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.d.ts +94 -0
  604. package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.d.ts.map +1 -0
  605. package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.js +130 -0
  606. package/dist/core/context-validation/_pa_wip_context_validation/prepare-write.js.map +1 -0
  607. package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.d.ts +60 -0
  608. package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.d.ts.map +1 -0
  609. package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.js +156 -0
  610. package/dist/core/context-validation/_pa_wip_context_validation/routine-rulebook.js.map +1 -0
  611. package/dist/core/context-validation/_pa_wip_context_validation/section.d.ts +41 -0
  612. package/dist/core/context-validation/_pa_wip_context_validation/section.d.ts.map +1 -0
  613. package/dist/core/context-validation/_pa_wip_context_validation/section.js +82 -0
  614. package/dist/core/context-validation/_pa_wip_context_validation/section.js.map +1 -0
  615. package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.d.ts +52 -0
  616. package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.d.ts.map +1 -0
  617. package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.js +110 -0
  618. package/dist/core/context-validation/_pa_wip_context_validation/snapshot-debounce.js.map +1 -0
  619. package/dist/core/context-validation/_pa_wip_context_validation/today.d.ts +85 -0
  620. package/dist/core/context-validation/_pa_wip_context_validation/today.d.ts.map +1 -0
  621. package/dist/core/context-validation/_pa_wip_context_validation/today.js +162 -0
  622. package/dist/core/context-validation/_pa_wip_context_validation/today.js.map +1 -0
  623. package/dist/core/context-validation/index.d.ts +19 -0
  624. package/dist/core/context-validation/index.d.ts.map +1 -0
  625. package/dist/core/context-validation/index.js +19 -0
  626. package/dist/core/context-validation/index.js.map +1 -0
  627. package/dist/core/context-validation/prepare-write.d.ts +95 -0
  628. package/dist/core/context-validation/prepare-write.d.ts.map +1 -0
  629. package/dist/core/context-validation/prepare-write.js +135 -0
  630. package/dist/core/context-validation/prepare-write.js.map +1 -0
  631. package/dist/core/context-validation/routine-rulebook.d.ts +60 -0
  632. package/dist/core/context-validation/routine-rulebook.d.ts.map +1 -0
  633. package/dist/core/context-validation/routine-rulebook.js +156 -0
  634. package/dist/core/context-validation/routine-rulebook.js.map +1 -0
  635. package/dist/core/context-validation/section.d.ts +41 -0
  636. package/dist/core/context-validation/section.d.ts.map +1 -0
  637. package/dist/core/context-validation/section.js +82 -0
  638. package/dist/core/context-validation/section.js.map +1 -0
  639. package/dist/core/context-validation/snapshot-debounce.d.ts +52 -0
  640. package/dist/core/context-validation/snapshot-debounce.d.ts.map +1 -0
  641. package/dist/core/context-validation/snapshot-debounce.js +110 -0
  642. package/dist/core/context-validation/snapshot-debounce.js.map +1 -0
  643. package/dist/core/context-validation/today.d.ts +85 -0
  644. package/dist/core/context-validation/today.d.ts.map +1 -0
  645. package/dist/core/context-validation/today.js +168 -0
  646. package/dist/core/context-validation/today.js.map +1 -0
  647. package/dist/core/daemon-api-cli.d.ts +6 -5
  648. package/dist/core/daemon-api-cli.d.ts.map +1 -1
  649. package/dist/core/daemon-api-cli.js +73 -32
  650. package/dist/core/daemon-api-cli.js.map +1 -1
  651. package/dist/core/dispatcher-error-handling.d.ts +13 -0
  652. package/dist/core/dispatcher-error-handling.d.ts.map +1 -1
  653. package/dist/core/dispatcher-error-handling.js +69 -0
  654. package/dist/core/dispatcher-error-handling.js.map +1 -1
  655. package/dist/core/dispatcher-hourly-check.d.ts +73 -1
  656. package/dist/core/dispatcher-hourly-check.d.ts.map +1 -1
  657. package/dist/core/dispatcher-hourly-check.js +249 -151
  658. package/dist/core/dispatcher-hourly-check.js.map +1 -1
  659. package/dist/core/dispatcher-message-handler.d.ts +11 -1
  660. package/dist/core/dispatcher-message-handler.d.ts.map +1 -1
  661. package/dist/core/dispatcher-message-handler.js +165 -47
  662. package/dist/core/dispatcher-message-handler.js.map +1 -1
  663. package/dist/core/dispatcher-morning-routine.d.ts +38 -30
  664. package/dist/core/dispatcher-morning-routine.d.ts.map +1 -1
  665. package/dist/core/dispatcher-morning-routine.js +162 -104
  666. package/dist/core/dispatcher-morning-routine.js.map +1 -1
  667. package/dist/core/dispatcher-prompt.d.ts +4 -1
  668. package/dist/core/dispatcher-prompt.d.ts.map +1 -1
  669. package/dist/core/dispatcher-prompt.js +18 -2
  670. package/dist/core/dispatcher-prompt.js.map +1 -1
  671. package/dist/core/dispatcher-repository-helpers.d.ts.map +1 -1
  672. package/dist/core/dispatcher-repository-helpers.js +5 -1
  673. package/dist/core/dispatcher-repository-helpers.js.map +1 -1
  674. package/dist/core/dispatcher-result-processor.d.ts.map +1 -1
  675. package/dist/core/dispatcher-result-processor.js +9 -4
  676. package/dist/core/dispatcher-result-processor.js.map +1 -1
  677. package/dist/core/dispatcher-scheduled-tasks.d.ts +1 -1
  678. package/dist/core/dispatcher-scheduled-tasks.d.ts.map +1 -1
  679. package/dist/core/dispatcher-scheduled-tasks.js +79 -16
  680. package/dist/core/dispatcher-scheduled-tasks.js.map +1 -1
  681. package/dist/core/dispatcher-types.d.ts +84 -12
  682. package/dist/core/dispatcher-types.d.ts.map +1 -1
  683. package/dist/core/dispatcher-types.js.map +1 -1
  684. package/dist/core/dispatcher.d.ts +50 -1
  685. package/dist/core/dispatcher.d.ts.map +1 -1
  686. package/dist/core/dispatcher.js +143 -8
  687. package/dist/core/dispatcher.js.map +1 -1
  688. package/dist/core/dm-freshness-metrics.d.ts +6 -5
  689. package/dist/core/dm-freshness-metrics.d.ts.map +1 -1
  690. package/dist/core/dm-freshness-metrics.js +7 -6
  691. package/dist/core/dm-freshness-metrics.js.map +1 -1
  692. package/dist/core/evening-review-verify.d.ts +164 -0
  693. package/dist/core/evening-review-verify.d.ts.map +1 -0
  694. package/dist/core/evening-review-verify.js +637 -0
  695. package/dist/core/evening-review-verify.js.map +1 -0
  696. package/dist/core/fetch-window-prompt-loader.d.ts +47 -0
  697. package/dist/core/fetch-window-prompt-loader.d.ts.map +1 -0
  698. package/dist/core/fetch-window-prompt-loader.js +72 -0
  699. package/dist/core/fetch-window-prompt-loader.js.map +1 -0
  700. package/dist/core/management-md.d.ts.map +1 -1
  701. package/dist/core/management-md.js +23 -9
  702. package/dist/core/management-md.js.map +1 -1
  703. package/dist/core/management-registry.d.ts +13 -21
  704. package/dist/core/management-registry.d.ts.map +1 -1
  705. package/dist/core/management-registry.js +27 -48
  706. package/dist/core/management-registry.js.map +1 -1
  707. package/dist/core/metrics.d.ts +88 -1
  708. package/dist/core/metrics.d.ts.map +1 -1
  709. package/dist/core/metrics.js +78 -2
  710. package/dist/core/metrics.js.map +1 -1
  711. package/dist/core/morning/agent-journal-appender.d.ts +197 -0
  712. package/dist/core/morning/agent-journal-appender.d.ts.map +1 -0
  713. package/dist/core/morning/agent-journal-appender.js +458 -0
  714. package/dist/core/morning/agent-journal-appender.js.map +1 -0
  715. package/dist/core/morning/handoff-parser.d.ts +45 -0
  716. package/dist/core/morning/handoff-parser.d.ts.map +1 -0
  717. package/dist/core/morning/handoff-parser.js +117 -0
  718. package/dist/core/morning/handoff-parser.js.map +1 -0
  719. package/dist/core/morning/journal-skeleton-builder.d.ts +157 -0
  720. package/dist/core/morning/journal-skeleton-builder.d.ts.map +1 -0
  721. package/dist/core/morning/journal-skeleton-builder.js +303 -0
  722. package/dist/core/morning/journal-skeleton-builder.js.map +1 -0
  723. package/dist/core/morning/orchestrator.d.ts +312 -0
  724. package/dist/core/morning/orchestrator.d.ts.map +1 -0
  725. package/dist/core/morning/orchestrator.js +827 -0
  726. package/dist/core/morning/orchestrator.js.map +1 -0
  727. package/dist/core/morning/parent-audit-emitter.d.ts +82 -0
  728. package/dist/core/morning/parent-audit-emitter.d.ts.map +1 -0
  729. package/dist/core/morning/parent-audit-emitter.js +120 -0
  730. package/dist/core/morning/parent-audit-emitter.js.map +1 -0
  731. package/dist/core/morning/roadmap-skeleton-builder.d.ts +159 -0
  732. package/dist/core/morning/roadmap-skeleton-builder.d.ts.map +1 -0
  733. package/dist/core/morning/roadmap-skeleton-builder.js +338 -0
  734. package/dist/core/morning/roadmap-skeleton-builder.js.map +1 -0
  735. package/dist/core/output-language-policy.js +1 -1
  736. package/dist/core/output-language-policy.js.map +1 -1
  737. package/dist/core/policy-files.d.ts +19 -2
  738. package/dist/core/policy-files.d.ts.map +1 -1
  739. package/dist/core/policy-files.js +65 -7
  740. package/dist/core/policy-files.js.map +1 -1
  741. package/dist/core/pre-pass-freshness.d.ts +28 -0
  742. package/dist/core/pre-pass-freshness.d.ts.map +1 -0
  743. package/dist/core/pre-pass-freshness.js +10 -0
  744. package/dist/core/pre-pass-freshness.js.map +1 -0
  745. package/dist/core/previous-week-digest.d.ts +130 -0
  746. package/dist/core/previous-week-digest.d.ts.map +1 -0
  747. package/dist/core/previous-week-digest.js +257 -0
  748. package/dist/core/previous-week-digest.js.map +1 -0
  749. package/dist/core/prompts.js +3 -3
  750. package/dist/core/prompts.js.map +1 -1
  751. package/dist/core/quiet-hours-sync.d.ts.map +1 -1
  752. package/dist/core/quiet-hours-sync.js +7 -0
  753. package/dist/core/quiet-hours-sync.js.map +1 -1
  754. package/dist/core/recurrence.d.ts +13 -0
  755. package/dist/core/recurrence.d.ts.map +1 -1
  756. package/dist/core/recurrence.js +108 -13
  757. package/dist/core/recurrence.js.map +1 -1
  758. package/dist/core/release-assets.d.ts +21 -1
  759. package/dist/core/release-assets.d.ts.map +1 -1
  760. package/dist/core/release-assets.js +58 -3
  761. package/dist/core/release-assets.js.map +1 -1
  762. package/dist/core/repository-management-docs.d.ts.map +1 -1
  763. package/dist/core/repository-management-docs.js +14 -4
  764. package/dist/core/repository-management-docs.js.map +1 -1
  765. package/dist/core/review-context.d.ts.map +1 -1
  766. package/dist/core/review-context.js +29 -1
  767. package/dist/core/review-context.js.map +1 -1
  768. package/dist/core/roadmap-maintenance.d.ts +213 -0
  769. package/dist/core/roadmap-maintenance.d.ts.map +1 -0
  770. package/dist/core/roadmap-maintenance.js +706 -0
  771. package/dist/core/roadmap-maintenance.js.map +1 -0
  772. package/dist/core/roadmap-validate.d.ts +5 -0
  773. package/dist/core/roadmap-validate.d.ts.map +1 -1
  774. package/dist/core/roadmap-validate.js +6 -69
  775. package/dist/core/roadmap-validate.js.map +1 -1
  776. package/dist/core/routine-acquisition-plan.d.ts +43 -7
  777. package/dist/core/routine-acquisition-plan.d.ts.map +1 -1
  778. package/dist/core/routine-acquisition-plan.js +99 -8
  779. package/dist/core/routine-acquisition-plan.js.map +1 -1
  780. package/dist/core/routine-fetch-window-retry.d.ts +41 -2
  781. package/dist/core/routine-fetch-window-retry.d.ts.map +1 -1
  782. package/dist/core/routine-fetch-window-retry.js +91 -8
  783. package/dist/core/routine-fetch-window-retry.js.map +1 -1
  784. package/dist/core/routine-fetch-window-runner.d.ts +55 -21
  785. package/dist/core/routine-fetch-window-runner.d.ts.map +1 -1
  786. package/dist/core/routine-fetch-window-runner.js +258 -35
  787. package/dist/core/routine-fetch-window-runner.js.map +1 -1
  788. package/dist/core/routine-windows.d.ts +17 -13
  789. package/dist/core/routine-windows.d.ts.map +1 -1
  790. package/dist/core/routine-windows.js +78 -36
  791. package/dist/core/routine-windows.js.map +1 -1
  792. package/dist/core/scheduler.d.ts +121 -37
  793. package/dist/core/scheduler.d.ts.map +1 -1
  794. package/dist/core/scheduler.js +359 -80
  795. package/dist/core/scheduler.js.map +1 -1
  796. package/dist/core/session-manager.d.ts +25 -6
  797. package/dist/core/session-manager.d.ts.map +1 -1
  798. package/dist/core/session-manager.js +32 -15
  799. package/dist/core/session-manager.js.map +1 -1
  800. package/dist/core/skeleton.d.ts.map +1 -1
  801. package/dist/core/skeleton.js +23 -23
  802. package/dist/core/skeleton.js.map +1 -1
  803. package/dist/core/skills-compiler.d.ts +275 -25
  804. package/dist/core/skills-compiler.d.ts.map +1 -1
  805. package/dist/core/skills-compiler.js +844 -205
  806. package/dist/core/skills-compiler.js.map +1 -1
  807. package/dist/core/skills-manifest.d.ts +104 -0
  808. package/dist/core/skills-manifest.d.ts.map +1 -1
  809. package/dist/core/skills-manifest.js +350 -39
  810. package/dist/core/skills-manifest.js.map +1 -1
  811. package/dist/core/wiki/git-precompile.d.ts +9 -0
  812. package/dist/core/wiki/git-precompile.d.ts.map +1 -1
  813. package/dist/core/wiki/git-precompile.js +7 -1
  814. package/dist/core/wiki/git-precompile.js.map +1 -1
  815. package/dist/core/workdir.d.ts +30 -1
  816. package/dist/core/workdir.d.ts.map +1 -1
  817. package/dist/core/workdir.js +140 -15
  818. package/dist/core/workdir.js.map +1 -1
  819. package/dist/db/entities-store.d.ts +5 -5
  820. package/dist/db/entities-store.js +5 -5
  821. package/dist/db/hourly-check-signals.d.ts.map +1 -1
  822. package/dist/db/hourly-check-signals.js +121 -35
  823. package/dist/db/hourly-check-signals.js.map +1 -1
  824. package/dist/db/observations.d.ts +1 -1
  825. package/dist/db/observations.js +1 -1
  826. package/dist/db/observations.js.map +1 -1
  827. package/dist/db/recurring-schedules.d.ts +32 -1
  828. package/dist/db/recurring-schedules.d.ts.map +1 -1
  829. package/dist/db/recurring-schedules.js +29 -10
  830. package/dist/db/recurring-schedules.js.map +1 -1
  831. package/dist/db/repositories-store.d.ts +2 -1
  832. package/dist/db/repositories-store.d.ts.map +1 -1
  833. package/dist/db/repositories-store.js +38 -3
  834. package/dist/db/repositories-store.js.map +1 -1
  835. package/dist/db/schema.d.ts.map +1 -1
  836. package/dist/db/schema.js +157 -51
  837. package/dist/db/schema.js.map +1 -1
  838. package/dist/db/wiki-store.d.ts.map +1 -1
  839. package/dist/db/wiki-store.js +3 -0
  840. package/dist/db/wiki-store.js.map +1 -1
  841. package/dist/index.js +308 -1480
  842. package/dist/index.js.map +1 -1
  843. package/dist/messaging/magic-phrase.d.ts +16 -0
  844. package/dist/messaging/magic-phrase.d.ts.map +1 -1
  845. package/dist/messaging/magic-phrase.js +53 -0
  846. package/dist/messaging/magic-phrase.js.map +1 -1
  847. package/dist/messaging/owner-channels.d.ts +24 -0
  848. package/dist/messaging/owner-channels.d.ts.map +1 -1
  849. package/dist/messaging/owner-channels.js +38 -0
  850. package/dist/messaging/owner-channels.js.map +1 -1
  851. package/dist/observers/calendar-poller.d.ts +2 -0
  852. package/dist/observers/calendar-poller.d.ts.map +1 -1
  853. package/dist/observers/calendar-poller.js +76 -54
  854. package/dist/observers/calendar-poller.js.map +1 -1
  855. package/dist/observers/delegated-sync-worker.d.ts +62 -0
  856. package/dist/observers/delegated-sync-worker.d.ts.map +1 -1
  857. package/dist/observers/delegated-sync-worker.js +128 -1
  858. package/dist/observers/delegated-sync-worker.js.map +1 -1
  859. package/dist/observers/git-watcher.d.ts +22 -0
  860. package/dist/observers/git-watcher.d.ts.map +1 -1
  861. package/dist/observers/git-watcher.js +31 -7
  862. package/dist/observers/git-watcher.js.map +1 -1
  863. package/dist/observers/imminent-event-scheduler.d.ts +2 -0
  864. package/dist/observers/imminent-event-scheduler.d.ts.map +1 -1
  865. package/dist/observers/imminent-event-scheduler.js +29 -0
  866. package/dist/observers/imminent-event-scheduler.js.map +1 -1
  867. package/dist/observers/notion-poller.d.ts +2 -0
  868. package/dist/observers/notion-poller.d.ts.map +1 -1
  869. package/dist/observers/notion-poller.js +44 -6
  870. package/dist/observers/notion-poller.js.map +1 -1
  871. package/dist/observers/poll-guard.d.ts +63 -0
  872. package/dist/observers/poll-guard.d.ts.map +1 -0
  873. package/dist/observers/poll-guard.js +89 -0
  874. package/dist/observers/poll-guard.js.map +1 -0
  875. package/dist/safety/absolute-block-audit.d.ts +17 -0
  876. package/dist/safety/absolute-block-audit.d.ts.map +1 -1
  877. package/dist/safety/absolute-block-audit.js +28 -2
  878. package/dist/safety/absolute-block-audit.js.map +1 -1
  879. package/dist/safety/agent-write-tracker.d.ts +42 -1
  880. package/dist/safety/agent-write-tracker.d.ts.map +1 -1
  881. package/dist/safety/agent-write-tracker.js +81 -1
  882. package/dist/safety/agent-write-tracker.js.map +1 -1
  883. package/dist/safety/always-disallowed.d.ts +34 -0
  884. package/dist/safety/always-disallowed.d.ts.map +1 -1
  885. package/dist/safety/always-disallowed.js +114 -7
  886. package/dist/safety/always-disallowed.js.map +1 -1
  887. package/dist/safety/audit.d.ts +20 -0
  888. package/dist/safety/audit.d.ts.map +1 -1
  889. package/dist/safety/audit.js +126 -0
  890. package/dist/safety/audit.js.map +1 -1
  891. package/dist/safety/risk-classifier.d.ts +17 -1
  892. package/dist/safety/risk-classifier.d.ts.map +1 -1
  893. package/dist/safety/risk-classifier.js +75 -7
  894. package/dist/safety/risk-classifier.js.map +1 -1
  895. package/dist/safety/subprocess-block-scanner.d.ts +89 -0
  896. package/dist/safety/subprocess-block-scanner.d.ts.map +1 -0
  897. package/dist/safety/subprocess-block-scanner.js +177 -0
  898. package/dist/safety/subprocess-block-scanner.js.map +1 -0
  899. package/dist/scheduler/hourly-check-gate.d.ts +23 -9
  900. package/dist/scheduler/hourly-check-gate.d.ts.map +1 -1
  901. package/dist/scheduler/hourly-check-gate.js +11 -6
  902. package/dist/scheduler/hourly-check-gate.js.map +1 -1
  903. package/dist/secrets/backend-api-key-env.d.ts.map +1 -1
  904. package/dist/secrets/backend-api-key-env.js +1 -0
  905. package/dist/secrets/backend-api-key-env.js.map +1 -1
  906. package/dist/services/delegated-backend-invoker.d.ts.map +1 -1
  907. package/dist/services/delegated-backend-invoker.js +8 -1
  908. package/dist/services/delegated-backend-invoker.js.map +1 -1
  909. package/dist/services/delegated-invoker-audit.d.ts.map +1 -1
  910. package/dist/services/delegated-invoker-audit.js +5 -1
  911. package/dist/services/delegated-invoker-audit.js.map +1 -1
  912. package/dist/services/delegated-proxy-config.d.ts +3 -2
  913. package/dist/services/delegated-proxy-config.d.ts.map +1 -1
  914. package/dist/services/delegated-proxy-config.js.map +1 -1
  915. package/dist/services/integrations/extract-write-item-id.d.ts +5 -2
  916. package/dist/services/integrations/extract-write-item-id.d.ts.map +1 -1
  917. package/dist/services/integrations/extract-write-item-id.js.map +1 -1
  918. package/dist/services/mcp/generators/index.d.ts +1 -0
  919. package/dist/services/mcp/generators/index.d.ts.map +1 -1
  920. package/dist/services/mcp/generators/index.js +3 -0
  921. package/dist/services/mcp/generators/index.js.map +1 -1
  922. package/dist/services/mcp/sdk-observations-server.d.ts +60 -0
  923. package/dist/services/mcp/sdk-observations-server.d.ts.map +1 -0
  924. package/dist/services/mcp/sdk-observations-server.js +161 -0
  925. package/dist/services/mcp/sdk-observations-server.js.map +1 -0
  926. package/dist/services/mcp/session-materializer.d.ts.map +1 -1
  927. package/dist/services/mcp/session-materializer.js +13 -9
  928. package/dist/services/mcp/session-materializer.js.map +1 -1
  929. package/dist/services/mcp/types.d.ts +1 -0
  930. package/dist/services/mcp/types.d.ts.map +1 -1
  931. package/dist/services/notion.d.ts +19 -1
  932. package/dist/services/notion.d.ts.map +1 -1
  933. package/dist/services/notion.js +41 -2
  934. package/dist/services/notion.js.map +1 -1
  935. package/dist/services/observations-batch.d.ts +100 -0
  936. package/dist/services/observations-batch.d.ts.map +1 -0
  937. package/dist/services/observations-batch.js +258 -0
  938. package/dist/services/observations-batch.js.map +1 -0
  939. package/dist/services/voice/transcriber.d.ts +23 -0
  940. package/dist/services/voice/transcriber.d.ts.map +1 -1
  941. package/dist/services/voice/transcriber.js +55 -0
  942. package/dist/services/voice/transcriber.js.map +1 -1
  943. package/dist/settings/runtime-settings.d.ts +9 -6
  944. package/dist/settings/runtime-settings.d.ts.map +1 -1
  945. package/dist/settings/runtime-settings.js +50 -17
  946. package/dist/settings/runtime-settings.js.map +1 -1
  947. package/package.json +3 -2
  948. package/dist/api/delegated-proxy-helper.d.ts +0 -33
  949. package/dist/api/delegated-proxy-helper.d.ts.map +0 -1
  950. package/dist/api/delegated-proxy-helper.js +0 -54
  951. package/dist/api/delegated-proxy-helper.js.map +0 -1
  952. package/dist/core/roadmap-merge.d.ts +0 -7
  953. package/dist/core/roadmap-merge.d.ts.map +0 -1
  954. package/dist/core/roadmap-merge.js +0 -187
  955. package/dist/core/roadmap-merge.js.map +0 -1
  956. package/dist/db/test-schemas.d.ts +0 -23
  957. package/dist/db/test-schemas.d.ts.map +0 -1
  958. package/dist/db/test-schemas.js +0 -111
  959. package/dist/db/test-schemas.js.map +0 -1
@@ -0,0 +1,162 @@
1
+ import { nowInTimezone } from "@aitne/shared";
2
+ import { extractTodayAgentPlanRows, } from "../today-agent-plan.js";
3
+ /**
4
+ * Validators and shape helpers for the `today.md` context file.
5
+ *
6
+ * `today.md` is the agent's daily working surface. Its line-1 header is
7
+ * the canonical agent-day date; its `## Agent Plan` rows feed the
8
+ * scheduler that fires `→DM` / `→notify` / `→check-in` / `→wake` actions
9
+ * at their listed times. Both halves are parsed by every downstream
10
+ * event handler, so the schema is enforced server-side at write time
11
+ * with explicit messages that the agent can self-correct from.
12
+ */
13
+ /**
14
+ * Canonical `## ` section headers, in document order. The validator
15
+ * walks the file once and requires each to appear after the previous
16
+ * one — extra sections may sit between them but the relative order is
17
+ * fixed.
18
+ */
19
+ export const TODAY_REQUIRED_SECTIONS = [
20
+ "User Schedule",
21
+ "User Tasks",
22
+ "Agent Plan",
23
+ "Agent Notes",
24
+ "Agent Log",
25
+ "Handoff",
26
+ ];
27
+ /**
28
+ * Line 1: `# YYYY-MM-DD (day-of-week)`. Date and dashes are ASCII;
29
+ * only the optional `(...)` weekday may be localized into the user's
30
+ * primary language. The capture group is consulted to compare against
31
+ * the current agent-day date when the route handler passes
32
+ * `expectedAgentDay`.
33
+ */
34
+ export const TODAY_H1_RE = /^# \d{4}-\d{2}-\d{2}(?: \([^)]+\))?$/;
35
+ /**
36
+ * Line 2: `> Day type: Weekday|Weekend | Work focus: on|off | …`.
37
+ * This line is parsed by every event handler — keep the casing,
38
+ * pipe separators, and `> ` prefix exact ASCII.
39
+ */
40
+ export const TODAY_DAY_TYPE_RE = /^> Day type: (Weekday|Weekend) \| Work focus: (on|off) \| Study focus: (on|off) \| Personal focus: (on|off)$/;
41
+ /**
42
+ * Pre-schema legacy form — first line literally `# Today`. Recognized
43
+ * only when the route handler explicitly opts in via
44
+ * `allowLegacyToday`; used to bridge old fixtures during reload paths
45
+ * that don't carry the agent-day context.
46
+ */
47
+ export function isLegacyTodayContent(content) {
48
+ const lines = content.split(/\r?\n/);
49
+ return (lines[0] ?? "").trim() === "# Today";
50
+ }
51
+ /**
52
+ * Validate a `today.md` payload for the canonical schema.
53
+ *
54
+ * Returns a human-readable error message string, or `null` if the
55
+ * content is valid. The caller maps `null` to 200 and any string to
56
+ * 400. Messages echo both the expected and observed shape so the
57
+ * agent gets immediate feedback and can correct the offending line in
58
+ * the same session — see EXECUTION-MODE-DESIGN follow-up
59
+ * §morning-routine for the rationale.
60
+ */
61
+ export function validateTodayContent(content, options = {}) {
62
+ if (options.allowLegacyToday && isLegacyTodayContent(content))
63
+ return null;
64
+ const lines = content.split(/\r?\n/);
65
+ const firstLine = (lines[0] ?? "").trim();
66
+ if (!TODAY_H1_RE.test(firstLine)) {
67
+ return ("today.md line 1 must be `# YYYY-MM-DD (day-of-week)`. " +
68
+ "The date and dashes are ASCII English; only the weekday inside " +
69
+ "`(...)` may be localized. Do NOT translate the literal `# ` prefix " +
70
+ "or change the date separator. See the today skill for the full " +
71
+ "skeleton contract.");
72
+ }
73
+ if (!TODAY_DAY_TYPE_RE.test((lines[1] ?? "").trim())) {
74
+ return ("today.md line 2 must be `> Day type: Weekday|Weekend | Work focus: on|off | Study focus: on|off | Personal focus: on|off`. " +
75
+ "This line is parsed by every downstream event handler — keep it " +
76
+ "exact English ASCII with the casing, pipe separators (` | `), and " +
77
+ "leading `> ` shown above. Do NOT translate `Day type` / `Weekday` / " +
78
+ "`Work focus` / `on` / `off` etc. into the user's primary_language; " +
79
+ "the `<output_language_policy>` skeleton-precedence rule covers this " +
80
+ "line. Example: " +
81
+ "`> Day type: Weekday | Work focus: on | Study focus: on | Personal focus: on`.");
82
+ }
83
+ // Agent-day-date check — rejects wrong-date H1 with a clear error echoing
84
+ // both values. Without this, a wrong-date PUT silently succeeds (regex
85
+ // passes) and the dispatcher's post-run hasCurrentAgentDayTodayMd() check
86
+ // schedules a retry while the same session still has the prompt context
87
+ // loaded, wasting a heavy-tier turn cycle. With this guard the agent gets
88
+ // immediate feedback and corrects in-session.
89
+ if (options.expectedAgentDay) {
90
+ // TODAY_H1_RE already matched, so the YYYY-MM-DD capture is guaranteed.
91
+ // No optional-chain — the regex precondition guarantees `[1]` is set.
92
+ const writtenDate = firstLine.match(/^# (\d{4}-\d{2}-\d{2})/)[1];
93
+ if (writtenDate !== options.expectedAgentDay) {
94
+ return (`today.md line 1 date '${writtenDate}' does not match the current ` +
95
+ `agent-day date '${options.expectedAgentDay}'. ` +
96
+ `Use the date from <current_agent_day date="..."> in your prompt context — ` +
97
+ `the agent-day differs from calendar today before the day-boundary hour.`);
98
+ }
99
+ }
100
+ let previousSectionIndex = 1;
101
+ for (const section of TODAY_REQUIRED_SECTIONS) {
102
+ const index = lines.findIndex((line, lineIndex) => lineIndex > previousSectionIndex && line.trim() === `## ${section}`);
103
+ if (index < 0) {
104
+ return `today.md requires \`## ${section}\` in canonical order.`;
105
+ }
106
+ previousSectionIndex = index;
107
+ }
108
+ const parsed = extractTodayAgentPlanRows(content);
109
+ if (parsed.invalidRows.length > 0) {
110
+ const first = parsed.invalidRows[0];
111
+ return (`today.md Agent Plan line ${first.line} must match ` +
112
+ `\`- [ ] HH:MM <action> [work|study|personal|home] →DM|→notify|→check-in|→wake\`. ` +
113
+ `Got: ${JSON.stringify(first.raw)}`);
114
+ }
115
+ return null;
116
+ }
117
+ /**
118
+ * Project a raw `agent_schedule` row into a `today.md`-reconciliation
119
+ * candidate: derive the local date/time in the caller's timezone, lift
120
+ * the task-context blob into an object, and surface the canonical row
121
+ * id so the route handler can correlate against parsed Agent Plan rows.
122
+ *
123
+ * Returns `null` for rows with an unparseable `scheduled_for`, so the
124
+ * caller can `.filter(Boolean)` past corrupt timestamps without
125
+ * crashing the reconciliation pass.
126
+ */
127
+ export function toTodayScheduleCandidate(row, timezone) {
128
+ const scheduledAt = parseScheduleDate(row.scheduled_for);
129
+ if (Number.isNaN(scheduledAt.getTime()))
130
+ return null;
131
+ const local = nowInTimezone(timezone, scheduledAt);
132
+ const localDate = `${local.year}-${String(local.month).padStart(2, "0")}-${String(local.day).padStart(2, "0")}`;
133
+ const localTime = `${String(local.hours).padStart(2, "0")}:${String(local.minutes).padStart(2, "0")}`;
134
+ return {
135
+ id: row.id,
136
+ scheduledFor: row.scheduled_for,
137
+ localDate,
138
+ localTime,
139
+ taskType: row.task_type,
140
+ status: row.status,
141
+ description: row.task_description,
142
+ taskContext: parseJsonObject(row.task_context),
143
+ };
144
+ }
145
+ function parseScheduleDate(value) {
146
+ return new Date(value.includes("T") ? value : value.replace(" ", "T") + "Z");
147
+ }
148
+ function parseJsonObject(raw) {
149
+ if (!raw)
150
+ return {};
151
+ try {
152
+ const parsed = JSON.parse(raw);
153
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
154
+ return parsed;
155
+ }
156
+ }
157
+ catch {
158
+ // Ignore corrupt metadata for reconciliation diagnostics.
159
+ }
160
+ return {};
161
+ }
162
+ //# sourceMappingURL=today.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"today.js","sourceRoot":"","sources":["../../../../src/core/context-validation/_pa_wip_context_validation/today.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,yBAAyB,GAE1B,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,eAAe;IACf,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,WAAW;IACX,SAAS;CACD,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,sCAAsC,CAAC;AAElE;;;;GAIG;AACH,MAAM,C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,GAAG,CAAY,CAAC;QAC1C,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnE,OAAO,MAAiC,CAAC;QAC3C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,0DAA0D;IAC5D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Context-file write-path validators, extracted from the inline
3
+ * implementation that used to live in `api/routes/context.ts`.
4
+ *
5
+ * Split per `docs/design/appendices/api-route-decomposition.md` §5.3
6
+ * (PR 3) so the route file holds routing + permission gating only and
7
+ * each validator gets its own dedicated unit-test file.
8
+ *
9
+ * Every export here is a pure function or shape type — no Hono, no
10
+ * filesystem, no DB. The route handler composes them; consumers
11
+ * (snapshot restore preflight, future migration tools) can also import
12
+ * them directly without dragging in route-layer dependencies.
13
+ */
14
+ export { normalizeSection, findSection, sumLength, getAvailableSections, } from "./section.js";
15
+ export { SNAPSHOT_DEBOUNCE_MS, parseEntryTimestamp, clearEntriesBefore, trimBulletEntries, } from "./snapshot-debounce.js";
16
+ export { validateBuiltInRoutineRulebook, explainCustomRoutineValidationError, extractRoutineFrontmatter, readRoutineFrontmatterScalar, validateBaseYamlSyntax, } from "./routine-rulebook.js";
17
+ export { TODAY_REQUIRED_SECTIONS, TODAY_H1_RE, TODAY_DAY_TYPE_RE, isLegacyTodayContent, validateTodayContent, toTodayScheduleCandidate, type TodayScheduleCandidate, type AgentPlanScheduleCandidate, } from "./today.js";
18
+ export { validateContextContent, prepareContextContentForWrite, type ResolvedContextTarget, type ContentWriteValidationOptions, type ContextContentValidationError, } from "./prepare-write.js";
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/context-validation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,8BAA8B,EAC9B,mCAAmC,EACnC,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,GAChC,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,GACnC,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Context-file write-path validators, extracted from the inline
3
+ * implementation that used to live in `api/routes/context.ts`.
4
+ *
5
+ * Split per `docs/design/appendices/api-route-decomposition.md` §5.3
6
+ * (PR 3) so the route file holds routing + permission gating only and
7
+ * each validator gets its own dedicated unit-test file.
8
+ *
9
+ * Every export here is a pure function or shape type — no Hono, no
10
+ * filesystem, no DB. The route handler composes them; consumers
11
+ * (snapshot restore preflight, future migration tools) can also import
12
+ * them directly without dragging in route-layer dependencies.
13
+ */
14
+ export { normalizeSection, findSection, sumLength, getAvailableSections, } from "./section.js";
15
+ export { SNAPSHOT_DEBOUNCE_MS, parseEntryTimestamp, clearEntriesBefore, trimBulletEntries, } from "./snapshot-debounce.js";
16
+ export { validateBuiltInRoutineRulebook, explainCustomRoutineValidationError, extractRoutineFrontmatter, readRoutineFrontmatterScalar, validateBaseYamlSyntax, } from "./routine-rulebook.js";
17
+ export { TODAY_REQUIRED_SECTIONS, TODAY_H1_RE, TODAY_DAY_TYPE_RE, isLegacyTodayContent, validateTodayContent, toTodayScheduleCandidate, } from "./today.js";
18
+ export { validateContextContent, prepareContextContentForWrite, } from "./prepare-write.js";
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/context-validation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,8BAA8B,EAC9B,mCAAmC,EACnC,yBAAyB,EACzB,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GAGzB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,sBAAsB,EACtB,6BAA6B,GAI9B,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,95 @@
1
+ import type { LongTermPlanSource } from "../roadmap-horizon.js";
2
+ /**
3
+ * Two-stage write-preparation pipeline for the `/api/context` PUT/PATCH
4
+ * routes.
5
+ *
6
+ * `validateContextContent` is the schema check — it dispatches by
7
+ * resolved target (today.md, roadmap.md, routine rulebooks, `.base`
8
+ * files, frontmatter-bearing markdown) and returns a typed error with
9
+ * the appropriate HTTP status (400 for content shape, 422 for
10
+ * frontmatter shape). It is exposed independently so callers that
11
+ * need to validate without normalizing (e.g. snapshot restore
12
+ * preflight) can use it directly.
13
+ *
14
+ * `prepareContextContentForWrite` is the full pipeline used by the
15
+ * write handlers — for `roadmap.md` it additionally normalizes
16
+ * Long-term Plans (adding default `source:` annotations, etc.) and
17
+ * runs a transition check against the previous content to enforce
18
+ * roadmap state-machine invariants. For every other target it
19
+ * delegates to `validateContextContent`.
20
+ */
21
+ /**
22
+ * A user-supplied context path after extension extraction:
23
+ *
24
+ * - `base` is the path without the trailing `.md` / `.base`
25
+ * - `ext` records which extension was either supplied or chosen by
26
+ * default (`.md`) or required (`.base` for the small set of
27
+ * reserved YAML stems).
28
+ *
29
+ * Produced by the path-resolve layer (currently still in `context.ts`
30
+ * until the PR 4 split); referenced here because every validator
31
+ * dispatches on `target.base`.
32
+ */
33
+ export interface ResolvedContextTarget {
34
+ base: string;
35
+ ext: ".md" | ".base";
36
+ }
37
+ export interface ContentWriteValidationOptions {
38
+ timezone?: string;
39
+ disableRoadmapValidation?: boolean;
40
+ previousRoadmapContent?: string;
41
+ today?: string;
42
+ defaultLongTermPlanSource?: LongTermPlanSource;
43
+ allowLegacyToday?: boolean;
44
+ skipFrontmatterValidation?: boolean;
45
+ /**
46
+ * Expected agent-day date (`YYYY-MM-DD`) for today.md line 1. When set,
47
+ * `validateTodayContent` returns a 400 with an error message that echoes
48
+ * both the written and the expected date string, so the agent can correct
49
+ * in the same session — see EXECUTION-MODE-DESIGN follow-up
50
+ * §morning-routine.
51
+ */
52
+ expectedAgentDay?: string;
53
+ }
54
+ export interface ContextContentValidationError {
55
+ message: string;
56
+ status: 400 | 422;
57
+ path?: string;
58
+ }
59
+ /**
60
+ * Schema-validate a context-file payload. Dispatches by resolved
61
+ * target:
62
+ *
63
+ * - `today` → `validateTodayContent` (400)
64
+ * - `roadmap` → `validateRoadmap` (400 with path hint)
65
+ * - `routines/custom/*` → `parseCustomRoutineSpec` (400)
66
+ * - `routines/*` (excluding `_index`) → `validateBuiltInRoutineRulebook` (400)
67
+ * - everything else → frontmatter validation (422) + `.base` YAML check (400)
68
+ *
69
+ * Returns `null` if the payload is valid. The caller maps `null` to
70
+ * the success branch and the typed error to the matching HTTP status.
71
+ */
72
+ export declare function validateContextContent(target: ResolvedContextTarget, content: string, options?: Pick<ContentWriteValidationOptions, "allowLegacyToday" | "skipFrontmatterValidation" | "expectedAgentDay">): ContextContentValidationError | null;
73
+ /**
74
+ * Full write-pipeline preflight. For roadmap writes, normalizes the
75
+ * Long-term Plans section first (adding default `source:` annotations
76
+ * keyed off the caller — manual via DM vs. dashboard form), validates
77
+ * against the canonical schema, and runs an optional transition check
78
+ * against the previous content. For every other target, delegates to
79
+ * `validateContextContent`.
80
+ *
81
+ * Returns `{ ok: true, content }` where `content` may be the
82
+ * roadmap-normalized form (different from the input) or the verbatim
83
+ * input. On failure, returns `{ ok: false, status, message, path? }`
84
+ * suitable for the API error response.
85
+ */
86
+ export declare function prepareContextContentForWrite(target: ResolvedContextTarget, content: string, options?: ContentWriteValidationOptions): {
87
+ ok: true;
88
+ content: string;
89
+ } | {
90
+ ok: false;
91
+ message: string;
92
+ status: 400 | 422;
93
+ path?: string;
94
+ };
95
+ //# sourceMappingURL=prepare-write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-write.d.ts","sourceRoot":"","sources":["../../../src/core/context-validation/prepare-write.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQhE;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB,CAAC,EAAE,kBAAkB,CAAC;IAC/C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CACZ,6BAA6B,EAC7B,kBAAkB,GAAG,2BAA2B,GAAG,kBAAkB,CACtE,GACA,6BAA6B,GAAG,IAAI,CA8CtC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,6BAA6B,GAErC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAuDnE"}
@@ -0,0 +1,135 @@
1
+ import { parseCustomRoutineSpec } from "../custom-routine-scheduler.js";
2
+ import { validateContextFileFrontmatter } from "../context-frontmatter.js";
3
+ import { normalizeRoadmapForWrite, validateRoadmap, validateRoadmapTransition, } from "../roadmap-validate.js";
4
+ import { explainCustomRoutineValidationError, validateBaseYamlSyntax, validateBuiltInRoutineRulebook, } from "./routine-rulebook.js";
5
+ import { validateTodayContent } from "./today.js";
6
+ /**
7
+ * Schema-validate a context-file payload. Dispatches by resolved
8
+ * target:
9
+ *
10
+ * - `today` → `validateTodayContent` (400)
11
+ * - `roadmap` → `validateRoadmap` (400 with path hint)
12
+ * - `routines/custom/*` → `parseCustomRoutineSpec` (400)
13
+ * - `routines/*` (excluding `_index`) → `validateBuiltInRoutineRulebook` (400)
14
+ * - everything else → frontmatter validation (422) + `.base` YAML check (400)
15
+ *
16
+ * Returns `null` if the payload is valid. The caller maps `null` to
17
+ * the success branch and the typed error to the matching HTTP status.
18
+ */
19
+ export function validateContextContent(target, content, options) {
20
+ if (target.base === "today") {
21
+ const message = validateTodayContent(content, {
22
+ allowLegacyToday: options?.allowLegacyToday ?? false,
23
+ expectedAgentDay: options?.expectedAgentDay,
24
+ });
25
+ return message ? { message, status: 400 } : null;
26
+ }
27
+ if (target.base === "roadmap") {
28
+ const result = validateRoadmap(content);
29
+ if (!result.ok && result.error) {
30
+ return {
31
+ message: formatRoadmapValidationError(result.error),
32
+ status: 400,
33
+ path: result.error.path,
34
+ };
35
+ }
36
+ return null;
37
+ }
38
+ if (target.base.startsWith("routines/custom/")) {
39
+ const slug = target.base.slice("routines/custom/".length);
40
+ const result = parseCustomRoutineSpec(slug, content);
41
+ if (!result.ok) {
42
+ return {
43
+ message: explainCustomRoutineValidationError(result.error),
44
+ status: 400,
45
+ };
46
+ }
47
+ return null;
48
+ }
49
+ if (target.base.startsWith("routines/") && target.base !== "routines/_index") {
50
+ const message = validateBuiltInRoutineRulebook(target.base, content);
51
+ return message ? { message, status: 400 } : null;
52
+ }
53
+ const relativePath = `${target.base}${target.ext}`;
54
+ if (!options?.skipFrontmatterValidation) {
55
+ const frontmatterError = validateContextFileFrontmatter(content, relativePath);
56
+ if (frontmatterError) {
57
+ return { message: frontmatterError.message, status: 422 };
58
+ }
59
+ }
60
+ if (target.ext !== ".base")
61
+ return null;
62
+ const message = validateBaseYamlSyntax(content);
63
+ return message ? { message, status: 400 } : null;
64
+ }
65
+ /**
66
+ * Full write-pipeline preflight. For roadmap writes, normalizes the
67
+ * Long-term Plans section first (adding default `source:` annotations
68
+ * keyed off the caller — manual via DM vs. dashboard form), validates
69
+ * against the canonical schema, and runs an optional transition check
70
+ * against the previous content. For every other target, delegates to
71
+ * `validateContextContent`.
72
+ *
73
+ * Returns `{ ok: true, content }` where `content` may be the
74
+ * roadmap-normalized form (different from the input) or the verbatim
75
+ * input. On failure, returns `{ ok: false, status, message, path? }`
76
+ * suitable for the API error response.
77
+ */
78
+ export function prepareContextContentForWrite(target, content, options) {
79
+ if (target.base !== "roadmap") {
80
+ const contentError = validateContextContent(target, content, {
81
+ allowLegacyToday: options?.allowLegacyToday,
82
+ expectedAgentDay: options?.expectedAgentDay,
83
+ });
84
+ if (contentError) {
85
+ return {
86
+ ok: false,
87
+ message: contentError.message,
88
+ status: contentError.status,
89
+ path: contentError.path,
90
+ };
91
+ }
92
+ return { ok: true, content };
93
+ }
94
+ if (options?.disableRoadmapValidation) {
95
+ return { ok: true, content };
96
+ }
97
+ const normalized = normalizeRoadmapForWrite(content, {
98
+ timezone: options?.timezone,
99
+ defaultLongTermPlanSource: options?.defaultLongTermPlanSource ?? "manual",
100
+ });
101
+ const result = validateRoadmap(normalized.content);
102
+ if (!result.ok && result.error) {
103
+ return {
104
+ ok: false,
105
+ message: formatRoadmapValidationError(result.error),
106
+ status: 400,
107
+ path: result.error.path,
108
+ };
109
+ }
110
+ if (options?.previousRoadmapContent !== undefined) {
111
+ const transition = validateRoadmapTransition(options.previousRoadmapContent, normalized.content, {
112
+ today: options.today,
113
+ timezone: options.timezone,
114
+ });
115
+ if (!transition.ok && transition.error) {
116
+ return {
117
+ ok: false,
118
+ message: formatRoadmapValidationError(transition.error),
119
+ status: 400,
120
+ path: transition.error.path,
121
+ };
122
+ }
123
+ }
124
+ return { ok: true, content: normalized.content };
125
+ }
126
+ function formatRoadmapValidationError(error) {
127
+ // `validateRoadmap` always supplies a line number for row-shape failures
128
+ // the route surfaces; the `error.line` falsy branch fires only for
129
+ // section-missing structural errors. The HTTP route tests exercise this
130
+ // indirectly; the dedicated unit-test fan-out is left to roadmap-validate.test.ts.
131
+ /* c8 ignore next */
132
+ const line = error.line ? `line ${error.line}: ` : "";
133
+ return `${line}${error.message}`;
134
+ }
135
+ //# sourceMappingURL=prepare-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepare-write.js","sourceRoot":"","sources":["../../../src/core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AAI,OAAO,EAAE,sBAAsB,KAAK,SAAS,EAAE,CAAC;QAClD,MAAM,UAAU,GAAG,yBAAyB,CAC1C,OAAO,CAAC,sBAAsB,EAC9B,UAAU,CAAC,OAAO,EAClB;YACE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;SAC3B,CACF,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;YACvC,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,4BAA4B,CAAC,UAAU,CAAC,KAAK,CAAC;gBACvD,MAAM,EAAE,GAAG;gBACX,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI;aAC5B,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;AACnD,CAAC;AAED,SAAS,4BAA4B,CAAC,KAA6B;IACjE,yEAAyE;IACzE,mEAAmE;IACnE,wEAAwE;IACxE,mFAAmF;IACnF,oBAAoB;IACpB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACtD,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { CustomRoutineParseError } from "../custom-routine-scheduler.js";
2
+ /**
3
+ * Pure validators for routine rulebooks and `.base` YAML files.
4
+ *
5
+ * Built-in routine rulebooks (`routines/*.md`, excluding `_index`) drive
6
+ * the morning / evening / weekly task-flow prompts and must declare the
7
+ * canonical frontmatter shape so the loader can dispatch by slug + type.
8
+ *
9
+ * Custom routines (`routines/custom/*.md`) are user-authored and parsed
10
+ * by `parseCustomRoutineSpec`; we only translate the structured error
11
+ * into a human-readable message here so the API can surface a 400
12
+ * response that the agent can self-correct from in-session.
13
+ *
14
+ * `.base` files (today: only `projects/_active.base`) carry the active
15
+ * project list as inline YAML. Validation is deliberately syntactic
16
+ * (no schema check) so the file can evolve without a daemon edit; the
17
+ * loader does the per-row validation when it parses.
18
+ */
19
+ /**
20
+ * Validate the canonical built-in routine rulebook shape:
21
+ * - YAML frontmatter present
22
+ * - `type: rule`
23
+ * - `slug` matches the filename (relative to `routines/`)
24
+ * - `## Checks` section is present in the body
25
+ *
26
+ * Returns a human-readable error message string, or `null` if the file
27
+ * is valid. The caller maps `null` to 200 and any string to 400.
28
+ */
29
+ export declare function validateBuiltInRoutineRulebook(path: string, content: string): string | null;
30
+ /**
31
+ * Translate a structured `CustomRoutineParseError` from
32
+ * `parseCustomRoutineSpec` into a human-readable string suitable for
33
+ * the API error response.
34
+ */
35
+ export declare function explainCustomRoutineValidationError(error: CustomRoutineParseError): string;
36
+ /**
37
+ * Extract the YAML frontmatter body (without the `---` delimiters)
38
+ * from a markdown file, or return `null` if no frontmatter block is
39
+ * present at the start of the file. Accepts both LF and CRLF line
40
+ * endings on the opening delimiter so Windows-edited files do not
41
+ * round-trip as "no frontmatter".
42
+ */
43
+ export declare function extractRoutineFrontmatter(content: string): string | null;
44
+ /**
45
+ * Read a single top-level scalar field from a routine frontmatter
46
+ * block. Quoted strings (single or double) have the quotes stripped;
47
+ * everything else is returned trimmed verbatim. Returns `null` if the
48
+ * field is absent.
49
+ */
50
+ export declare function readRoutineFrontmatterScalar(frontmatter: string, field: string): string | null;
51
+ /**
52
+ * Syntactic gate for `.base` YAML context files.
53
+ *
54
+ * Only rejects files that are obviously broken — tabs in indentation,
55
+ * odd indent counts, non-mapping non-list lines. The schema check (what
56
+ * fields must be present) belongs in the loader; the API gate exists
57
+ * so that a malformed PATCH cannot wedge the project-list reader.
58
+ */
59
+ export declare function validateBaseYamlSyntax(content: string): string | null;
60
+ //# sourceMappingURL=routine-rulebook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routine-rulebook.d.ts","sourceRoot":"","sources":["../../../src/core/context-validation/routine-rulebook.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CA4Bf;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,uBAAuB,GAC7B,MAAM,CAuBR;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQxE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAYf;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoCrE"}