@aitne-sh/aitne 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/README.md +256 -833
  2. package/agent-assets/agent-profiles/_safety.md +52 -20
  3. package/agent-assets/agent-profiles/browser-task.md +108 -0
  4. package/agent-assets/agent-profiles/conversational.md +3 -3
  5. package/agent-assets/agent-profiles/profile-importer.md +3 -3
  6. package/agent-assets/agent-profiles/routine-fetch-window.md +30 -19
  7. package/agent-assets/agent-profiles/routine.md +4 -3
  8. package/agent-assets/agents/context-index-reconcile/agent.md +52 -0
  9. package/agent-assets/agents/evening-review/agent.md +53 -0
  10. package/agent-assets/agents/hourly-check/agent.md +62 -0
  11. package/agent-assets/agents/monthly-review/agent.md +55 -0
  12. package/agent-assets/agents/morning-routine/agent.md +78 -0
  13. package/agent-assets/agents/roadmap-maintenance/agent.md +52 -0
  14. package/agent-assets/agents/skill-curation/agent.md +52 -0
  15. package/agent-assets/agents/user-profile-sweep-evening/agent.md +48 -0
  16. package/agent-assets/agents/user-profile-sweep-morning/agent.md +53 -0
  17. package/agent-assets/agents/weekly-review/agent.md +51 -0
  18. package/agent-assets/docs/concepts/agent-day.md +18 -11
  19. package/agent-assets/docs/concepts/auth-health.md +56 -10
  20. package/agent-assets/docs/concepts/backends-and-tiers.md +110 -41
  21. package/agent-assets/docs/concepts/costs-and-quotas.md +74 -19
  22. package/agent-assets/docs/concepts/delegated-mode.md +193 -75
  23. package/agent-assets/docs/concepts/memory-model.md +79 -34
  24. package/agent-assets/docs/concepts/observations.md +61 -11
  25. package/agent-assets/docs/concepts/process-keys.md +66 -17
  26. package/agent-assets/docs/concepts/routines.md +77 -32
  27. package/agent-assets/docs/concepts/safety-and-execution.md +50 -21
  28. package/agent-assets/docs/concepts/safety-model.md +62 -37
  29. package/agent-assets/docs/concepts/skills.md +38 -17
  30. package/agent-assets/docs/features/integrations/browser-history.md +195 -0
  31. package/agent-assets/docs/features/integrations/calendar.md +40 -30
  32. package/agent-assets/docs/features/integrations/git.md +20 -9
  33. package/agent-assets/docs/features/integrations/github.md +93 -35
  34. package/agent-assets/docs/features/integrations/mail.md +60 -17
  35. package/agent-assets/docs/features/integrations/notion.md +51 -11
  36. package/agent-assets/docs/features/integrations/obsidian.md +35 -7
  37. package/agent-assets/docs/features/lifestyle/git.md +45 -44
  38. package/agent-assets/docs/features/lifestyle/reading.md +50 -22
  39. package/agent-assets/docs/features/lifestyle/receipts.md +66 -21
  40. package/agent-assets/docs/features/lifestyle/travel-bookings.md +91 -14
  41. package/agent-assets/docs/features/memory-files/agent-journal.md +111 -50
  42. package/agent-assets/docs/features/memory-files/projects.md +75 -15
  43. package/agent-assets/docs/features/memory-files/roadmap.md +55 -10
  44. package/agent-assets/docs/features/memory-files/schedule.md +113 -70
  45. package/agent-assets/docs/features/memory-files/today.md +47 -21
  46. package/agent-assets/docs/features/memory-files/user-profile.md +67 -31
  47. package/agent-assets/docs/features/messaging/bang-commands.md +115 -28
  48. package/agent-assets/docs/features/messaging/dashboard-chat.md +43 -21
  49. package/agent-assets/docs/features/messaging/discord.md +46 -4
  50. package/agent-assets/docs/features/messaging/overview.md +40 -19
  51. package/agent-assets/docs/features/messaging/pairing-and-magic-phrase.md +94 -27
  52. package/agent-assets/docs/features/messaging/slack.md +79 -14
  53. package/agent-assets/docs/features/messaging/telegram.md +25 -6
  54. package/agent-assets/docs/features/messaging/whatsapp.md +79 -14
  55. package/agent-assets/docs/features/operations/activity-and-conversations.md +45 -16
  56. package/agent-assets/docs/features/operations/approvals.md +53 -15
  57. package/agent-assets/docs/features/operations/backend-routing.md +75 -16
  58. package/agent-assets/docs/features/operations/cost-tracking.md +90 -17
  59. package/agent-assets/docs/features/operations/managed-chromium.md +221 -0
  60. package/agent-assets/docs/features/operations/notifications.md +58 -11
  61. package/agent-assets/docs/features/operations/quiet-hours.md +63 -40
  62. package/agent-assets/docs/features/operations/schedule-approaching.md +59 -16
  63. package/agent-assets/docs/features/routines/custom-routines.md +97 -23
  64. package/agent-assets/docs/features/routines/evening-review.md +75 -22
  65. package/agent-assets/docs/features/routines/hourly-check.md +150 -30
  66. package/agent-assets/docs/features/routines/morning-routine.md +60 -33
  67. package/agent-assets/docs/features/routines/weekly-review.md +65 -20
  68. package/agent-assets/docs/features/wiki/commands.md +37 -16
  69. package/agent-assets/docs/features/wiki/cost-and-approval.md +240 -0
  70. package/agent-assets/docs/features/wiki/dashboard.md +255 -0
  71. package/agent-assets/docs/features/wiki/overview.md +80 -12
  72. package/agent-assets/docs/features/wiki/search.md +248 -0
  73. package/agent-assets/docs/features/wiki/workspaces.md +254 -0
  74. package/agent-assets/docs/getting-started/01-what-is-this.md +64 -32
  75. package/agent-assets/docs/getting-started/02-first-steps.md +28 -10
  76. package/agent-assets/docs/getting-started/03-what-can-this-do.md +42 -21
  77. package/agent-assets/docs/getting-started/04-first-day.md +52 -20
  78. package/agent-assets/docs/glossary.md +285 -21
  79. package/agent-assets/docs/guides/add-a-custom-routine.md +74 -22
  80. package/agent-assets/docs/guides/backup-and-restore.md +92 -14
  81. package/agent-assets/docs/guides/budget-and-cost-for-wiki.md +62 -25
  82. package/agent-assets/docs/guides/build-your-wiki.md +33 -6
  83. package/agent-assets/docs/guides/change-which-model-handles-x.md +70 -9
  84. package/agent-assets/docs/guides/connect-a-new-mail-account.md +80 -15
  85. package/agent-assets/docs/guides/explore-with-trace-and-connect.md +32 -9
  86. package/agent-assets/docs/guides/import-knowledge-file.md +60 -39
  87. package/agent-assets/docs/guides/install-and-run.md +64 -19
  88. package/agent-assets/docs/guides/maintain-wiki-health.md +41 -10
  89. package/agent-assets/docs/guides/migrate-machines.md +86 -18
  90. package/agent-assets/docs/guides/multiple-wikis-for-multiple-domains.md +119 -59
  91. package/agent-assets/docs/guides/pause-the-agent.md +71 -22
  92. package/agent-assets/docs/guides/reinstall-cleanly.md +102 -17
  93. package/agent-assets/docs/guides/setup-wizard.md +126 -56
  94. package/agent-assets/docs/guides/switch-default-backend.md +72 -17
  95. package/agent-assets/docs/guides/use-an-existing-obsidian-vault.md +31 -10
  96. package/agent-assets/docs/reference/api.md +162 -23
  97. package/agent-assets/docs/reference/cli-commands.md +55 -15
  98. package/agent-assets/docs/reference/config.md +246 -39
  99. package/agent-assets/docs/reference/disallowed-tools.md +42 -10
  100. package/agent-assets/docs/reference/keyboard-shortcuts.md +47 -10
  101. package/agent-assets/docs/reference/knowledge-layout.md +620 -0
  102. package/agent-assets/docs/reference/process-keys.md +126 -20
  103. package/agent-assets/docs/reference/skills.md +62 -18
  104. package/agent-assets/docs/troubleshooting/auth-failed.md +53 -19
  105. package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +96 -22
  106. package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +94 -20
  107. package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +77 -22
  108. package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +87 -22
  109. package/agent-assets/docs/troubleshooting/observation-not-detected.md +85 -21
  110. package/agent-assets/docs/troubleshooting/quota-exhausted.md +36 -6
  111. package/agent-assets/docs/troubleshooting/wiki-ingest-full-blocked.md +128 -51
  112. package/agent-assets/docs/troubleshooting/wiki-write-failed.md +33 -11
  113. package/agent-assets/optimizer-skills/drift-analysis/SKILL.md +1 -1
  114. package/agent-assets/optimizer-skills/knowledge-map/SKILL.md +1 -1
  115. package/agent-assets/optimizer-skills/skill-curation/SKILL.md +2 -2
  116. package/agent-assets/sandbox/linux/aitne-chromium.apparmor +91 -0
  117. package/agent-assets/sandbox/macos/aitne-chromium.sb +156 -0
  118. package/agent-assets/skills/agent-actions/SKILL.md +122 -0
  119. package/agent-assets/skills/agent-create/SKILL.md +149 -0
  120. package/agent-assets/skills/attach/SKILL.md +3 -4
  121. package/agent-assets/skills/browser-history/SKILL.md +198 -0
  122. package/agent-assets/skills/browser-history-respond/SKILL.md +106 -0
  123. package/agent-assets/skills/browser-task/SKILL.md +169 -0
  124. package/agent-assets/skills/context/SKILL.md +45 -463
  125. package/agent-assets/skills/context/curation.json +2 -2
  126. package/agent-assets/skills/context/references/api.md +232 -0
  127. package/agent-assets/skills/context/references/required-frontmatter.md +73 -0
  128. package/agent-assets/skills/context/references/snapshot-files.md +103 -0
  129. package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +4 -4
  130. package/agent-assets/skills/docs-search/SKILL.md +17 -16
  131. package/agent-assets/skills/external-services/SKILL.delegated.claude.md +14 -26
  132. package/agent-assets/skills/external-services/SKILL.delegated.codex.md +14 -26
  133. package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +14 -26
  134. package/agent-assets/skills/external-services/SKILL.md +9 -262
  135. package/agent-assets/skills/external-services/SKILL.native.claude.md +6 -7
  136. package/agent-assets/skills/external-services/SKILL.native.codex.md +8 -9
  137. package/agent-assets/skills/external-services/SKILL.native.gemini.md +5 -6
  138. package/agent-assets/skills/external-services/references/calendar-apple.md +97 -0
  139. package/agent-assets/skills/external-services/references/calendar-google.md +72 -0
  140. package/agent-assets/skills/external-services/references/calendar-outlook.md +36 -0
  141. package/agent-assets/skills/external-services/references/github.md +17 -0
  142. package/agent-assets/skills/external-services/references/obsidian.md +49 -0
  143. package/agent-assets/skills/external-services/references/skills-crud.md +27 -0
  144. package/agent-assets/skills/gmail-lifestyle/SKILL.md +151 -0
  145. package/agent-assets/skills/gmail-lifestyle/references/receipts-api.md +93 -0
  146. package/agent-assets/skills/gmail-lifestyle/references/travel-bookings-api.md +75 -0
  147. package/agent-assets/skills/mail/SKILL.delegated.claude.md +15 -6
  148. package/agent-assets/skills/mail/SKILL.delegated.codex.md +9 -5
  149. package/agent-assets/skills/mail/SKILL.delegated.gemini.md +9 -5
  150. package/agent-assets/skills/mail/SKILL.md +9 -114
  151. package/agent-assets/skills/mail/SKILL.native.claude.md +1 -1
  152. package/agent-assets/skills/mail/SKILL.native.codex.md +1 -1
  153. package/agent-assets/skills/mail/SKILL.native.gemini.md +1 -1
  154. package/agent-assets/skills/mail/references/api.md +110 -0
  155. package/agent-assets/skills/mail/references/examples.md +70 -0
  156. package/agent-assets/skills/mail/references/providers.md +8 -8
  157. package/agent-assets/skills/managed-tasks/SKILL.md +472 -0
  158. package/agent-assets/skills/managed-tasks/references/errors.md +73 -0
  159. package/agent-assets/skills/managed-tasks/references/output-path.md +75 -0
  160. package/agent-assets/skills/managed-tasks/references/recurrence-rule.md +86 -0
  161. package/agent-assets/skills/management-policy/SKILL.md +54 -125
  162. package/agent-assets/skills/management-policy/curation.json +1 -1
  163. package/agent-assets/skills/management-policy/references/policy-workflow.md +101 -0
  164. package/agent-assets/skills/management-policy/seeds/policy-file-shape.seed.json +1 -1
  165. package/agent-assets/skills/notify/SKILL.md +10 -82
  166. package/agent-assets/skills/notify/references/priority.md +65 -0
  167. package/agent-assets/skills/notion/SKILL.delegated.claude.md +2 -2
  168. package/agent-assets/skills/notion/SKILL.delegated.codex.md +2 -2
  169. package/agent-assets/skills/notion/SKILL.delegated.gemini.md +2 -2
  170. package/agent-assets/skills/notion/SKILL.md +6 -10
  171. package/agent-assets/skills/notion/SKILL.native.claude.md +11 -8
  172. package/agent-assets/skills/notion/SKILL.native.codex.md +10 -6
  173. package/agent-assets/skills/notion/SKILL.native.gemini.md +10 -6
  174. package/agent-assets/skills/observations/SKILL.md +25 -14
  175. package/agent-assets/skills/project-doc/SKILL.md +2 -6
  176. package/agent-assets/skills/project-doc/curation.json +3 -3
  177. package/agent-assets/skills/project-doc/seeds/project-shape.seed.json +7 -4
  178. package/agent-assets/skills/project-doc/seeds/slug-grammar.seed.json +3 -3
  179. package/agent-assets/skills/reading/SKILL.md +12 -2
  180. package/agent-assets/skills/reading/references/reading-taste.md +2 -2
  181. package/agent-assets/skills/roadmap/SKILL.md +43 -141
  182. package/agent-assets/skills/roadmap/curation.json +1 -1
  183. package/agent-assets/skills/roadmap/references/api.md +100 -0
  184. package/agent-assets/skills/roadmap/references/cross-check.md +80 -0
  185. package/agent-assets/skills/roadmap/references/migration.md +56 -0
  186. package/agent-assets/skills/roadmap/references/preparation-timeline.md +2 -2
  187. package/agent-assets/skills/roadmap/seeds/entry-types.seed.json +1 -1
  188. package/agent-assets/skills/schedule/SKILL.md +76 -104
  189. package/agent-assets/skills/schedule/references/batch.md +93 -0
  190. package/agent-assets/skills/schedule/references/errors.md +217 -0
  191. package/agent-assets/skills/schedule/references/model-selection.md +96 -0
  192. package/agent-assets/skills/schedule/references/recurrence-rule.md +86 -0
  193. package/agent-assets/skills/scheduled-managed-task/SKILL.md +59 -51
  194. package/agent-assets/skills/today/SKILL.md +32 -62
  195. package/agent-assets/skills/today/curation.json +3 -3
  196. package/agent-assets/skills/today/references/agent-plan-lifecycle.md +114 -0
  197. package/agent-assets/skills/today/seeds/section-shape.seed.json +1 -1
  198. package/agent-assets/skills/user-interview/SKILL.md +23 -67
  199. package/agent-assets/skills/user-interview/references/op-briefing.md +51 -0
  200. package/agent-assets/skills/user-interview/references/op-morning.md +59 -0
  201. package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +9 -1
  202. package/agent-assets/skills/user-profile/SKILL.md +54 -74
  203. package/agent-assets/skills/user-profile/curation.json +2 -2
  204. package/agent-assets/skills/user-profile/references/character-preferences.md +83 -0
  205. package/agent-assets/skills/user-profile/seeds/routing-table.seed.json +8 -8
  206. package/agent-assets/skills/user-profile/seeds/topic-files.seed.json +30 -2
  207. package/agent-assets/skills/wiki/wiki-ask/SKILL.md +0 -1
  208. package/agent-assets/skills/wiki/wiki-compile/SKILL.md +4 -5
  209. package/agent-assets/skills/wiki/wiki-connect/SKILL.md +0 -1
  210. package/agent-assets/skills/wiki/wiki-graduate/SKILL.md +0 -1
  211. package/agent-assets/skills/wiki/wiki-ingest/SKILL.md +0 -1
  212. package/agent-assets/skills/wiki/wiki-lint/SKILL.md +0 -1
  213. package/agent-assets/skills/wiki/wiki-trace/SKILL.md +0 -1
  214. package/agent-assets/skills/wiki/wiki-vault-rules/SKILL.md +0 -1
  215. package/agent-assets/system-prompts/routine-fetch-window.md +78 -0
  216. package/agent-assets/system-prompts/skill-index-instruction.md +26 -0
  217. package/agent-assets/task-flows/_partials/calendar-acquire.google_calendar.md +20 -11
  218. package/agent-assets/task-flows/_partials/calendar-acquire.outlook_calendar.md +18 -9
  219. package/agent-assets/task-flows/_partials/capture-user-info.md +24 -0
  220. package/agent-assets/task-flows/_partials/confirm-subflow.md +68 -0
  221. package/agent-assets/task-flows/_partials/dm-intent.long-horizon.md +35 -0
  222. package/agent-assets/task-flows/_partials/dm-intent.project.md +391 -0
  223. package/agent-assets/task-flows/_partials/mail-acquire.gmail.md +20 -11
  224. package/agent-assets/task-flows/_partials/mail-acquire.outlook_mail.md +18 -9
  225. package/agent-assets/task-flows/_partials/notion-acquire.notion.md +26 -15
  226. package/agent-assets/task-flows/browser_task.md +84 -0
  227. package/agent-assets/task-flows/github.assigned.md +1 -1
  228. package/agent-assets/task-flows/github.pull_request.review_requested.md +2 -2
  229. package/agent-assets/task-flows/github.workflow_run.failed.md +2 -2
  230. package/agent-assets/task-flows/knowledge.import.md +15 -15
  231. package/agent-assets/task-flows/message.received.dm.md +20 -17
  232. package/agent-assets/task-flows/message.received.dm_first.md +11 -15
  233. package/agent-assets/task-flows/routine.custom.md +6 -4
  234. package/agent-assets/task-flows/routine.evening_review.md +46 -170
  235. package/agent-assets/task-flows/routine.fetch_window.md +19 -14
  236. package/agent-assets/task-flows/routine.hourly_check.md +27 -15
  237. package/agent-assets/task-flows/routine.hourly_check.triage.md +1 -1
  238. package/agent-assets/task-flows/routine.monthly_review.md +67 -25
  239. package/agent-assets/task-flows/routine.morning_routine_journal.md +135 -0
  240. package/agent-assets/task-flows/routine.morning_routine_today.md +673 -0
  241. package/agent-assets/task-flows/routine.research_cluster_update.md +35 -0
  242. package/agent-assets/task-flows/routine.research_dispatch.md +38 -0
  243. package/agent-assets/task-flows/routine.research_offer_dm.md +125 -0
  244. package/agent-assets/task-flows/routine.research_wiki_summary.md +53 -0
  245. package/agent-assets/task-flows/routine.roadmap_refresh.md +68 -23
  246. package/agent-assets/task-flows/routine.today_refresh.md +4 -4
  247. package/agent-assets/task-flows/routine.user_profile_sweep.md +19 -20
  248. package/agent-assets/task-flows/routine.weekly_review.md +370 -86
  249. package/agent-assets/task-flows/schedule.approaching.md +0 -1
  250. package/agent-assets/task-flows/scheduled.dm.md +13 -13
  251. package/agent-assets/task-flows/scheduled.task.md +9 -9
  252. package/agent-assets/task-flows/setup.initial.md +171 -251
  253. package/agent-assets/task-flows/setup.update.md +2 -2
  254. package/agent-assets/task-flows/wiki.ingest_url.md +1 -1
  255. package/agent-assets/templates/README.md +27 -20
  256. package/agent-assets/templates/_index.md +42 -26
  257. package/agent-assets/templates/_manifest.json +34 -99
  258. package/agent-assets/templates/{user → identity}/_index.md +1 -1
  259. package/agent-assets/templates/identity/expertise.md +9 -0
  260. package/agent-assets/templates/identity/goals.md +9 -0
  261. package/agent-assets/templates/identity/people.md +13 -0
  262. package/agent-assets/templates/identity/personal.md +9 -0
  263. package/agent-assets/templates/{user → identity}/profile.md +2 -2
  264. package/agent-assets/templates/identity/work.md +9 -0
  265. package/agent-assets/templates/{dossiers → knowledge/dossiers}/_index.md +2 -2
  266. package/agent-assets/templates/{projects → plans/projects}/_active.base +1 -1
  267. package/agent-assets/templates/policies/_index.md +21 -0
  268. package/agent-assets/templates/{rules → policies}/journal-export.md +1 -1
  269. package/agent-assets/templates/policies/journal-format.md +168 -0
  270. package/agent-assets/templates/{rules/policies → policies/management-captures}/_index.md +2 -2
  271. package/agent-assets/templates/{rules → policies}/management.md +3 -3
  272. package/agent-assets/templates/{rules → policies}/mcp.md +1 -1
  273. package/agent-assets/templates/{rules → policies}/redaction.md +1 -1
  274. package/agent-assets/templates/{routines → policies/routines}/_index.md +1 -1
  275. package/agent-assets/templates/{routines → policies/routines}/evening.md +2 -2
  276. package/agent-assets/templates/{routines → policies/routines}/hourly.md +1 -1
  277. package/agent-assets/templates/{routines → policies/routines}/monthly.md +2 -2
  278. package/bin/aitne.mjs +21 -5
  279. package/package.json +5 -4
  280. package/scripts/commands/doctor.mjs +63 -5
  281. package/scripts/commands/run-now.mjs +187 -0
  282. package/scripts/commands/verify.mjs +264 -0
  283. package/scripts/lib/ports.d.mts +27 -0
  284. package/scripts/lib/ports.mjs +36 -0
  285. package/scripts/lib/read-api-token.mjs +176 -0
  286. package/scripts/start.mjs +2 -1
  287. package/agent-assets/docs/features/lifestyle/travel-time.md +0 -52
  288. package/agent-assets/docs/features/routines/monthly-review.md +0 -65
  289. package/agent-assets/skills/management-task-modify/SKILL.md +0 -203
  290. package/agent-assets/skills/management-task-register/SKILL.md +0 -330
  291. package/agent-assets/skills/management-task-stop/SKILL.md +0 -166
  292. package/agent-assets/skills/receipts/SKILL.md +0 -134
  293. package/agent-assets/skills/travel/SKILL.md +0 -132
  294. package/agent-assets/skills/travel-time/SKILL.md +0 -158
  295. package/agent-assets/task-flows/routine.morning_routine.md +0 -322
  296. package/agent-assets/task-flows/routine.morning_routine_initial.md +0 -204
  297. package/agent-assets/templates/context-index.md +0 -42
  298. package/agent-assets/templates/rules/_index.md +0 -19
  299. package/agent-assets/templates/rules/journal-format.md +0 -61
  300. package/agent-assets/templates/user/expertise.md +0 -7
  301. package/agent-assets/templates/user/goals.md +0 -7
  302. package/agent-assets/templates/user/people.md +0 -7
  303. package/agent-assets/templates/user/personal.md +0 -7
  304. package/agent-assets/templates/user/work.md +0 -7
  305. /package/agent-assets/templates/{agent/journal.md → journal/agent.md} +0 -0
  306. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/evening.md +0 -0
  307. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/hourly.md +0 -0
  308. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/monthly.md +0 -0
  309. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/morning.md +0 -0
  310. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/roadmap.md +0 -0
  311. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/weekly.md +0 -0
  312. /package/agent-assets/templates/{projects → plans/projects}/_index.md +0 -0
  313. /package/agent-assets/templates/{roadmap.md → plans/roadmap.md} +0 -0
  314. /package/agent-assets/templates/{routines → policies/routines}/morning.md +0 -0
  315. /package/agent-assets/templates/{routines → policies/routines}/weekly.md +0 -0
  316. /package/agent-assets/templates/{agent → state}/profile-questions.md +0 -0
  317. /package/agent-assets/templates/{today.md → state/today.md} +0 -0
@@ -0,0 +1,472 @@
1
+ ---
2
+ name: managed-tasks
3
+ description: Register / modify / stop / run-now a Managed Task (mt_<n>) — recurring agent fetch against a third-party app (Zoom, Gmail, Drive, Notion, custom MCP). Skip for one-off reminders (schedule), durable no-app rules (management-policy), DM-only cadences (recurring-schedules).
4
+ allowed-tools:
5
+ - Bash(curl *)
6
+ - Read
7
+ ---
8
+
9
+ # Managed Tasks (`mt_<n>`)
10
+
11
+ A **managed task** is a user-delegated commitment: the agent runs a
12
+ recurring fetch against a specific App at a user-specified Cadence and
13
+ writes the resulting entities into a primary L2 directory (the
14
+ `Output path`). Each row lives in `policies/management.md` §B. The
15
+ authoritative store is the `managed_tasks` SQLite table; the file is
16
+ re-rendered from the table after every mutation, so do **not** PUT the
17
+ file yourself — every legal mutation goes through `/api/managed-tasks`
18
+ and the daemon owns the file write.
19
+
20
+ Conditionally loaded — see the `managedTasksActive(db)` predicate in
21
+ `packages/daemon/src/core/skills-manifest.ts`. The predicate fires
22
+ when at least one `managed_tasks` row exists OR the inbound DM
23
+ contains a trigger anchor (`mt_<n>`, "managed task", "recurring
24
+ fetch", or the app-verb pairs in the §"Register" trigger examples).
25
+
26
+ ## When to use this skill
27
+
28
+ | Verb | User said | Section |
29
+ |---|---|---|
30
+ | Register | "check Zoom recordings every day at 10am" / "every Monday at 9 pull new Drive PDFs into receipts" | §Register |
31
+ | Modify | "move the Zoom check to 9am instead of 10am" / "send Drive receipts to `finance/receipts/`" | §Modify |
32
+ | Stop | "stop the daily Zoom check" / "cancel `mt_42`" | §Stop |
33
+ | Run-once | "run `mt_42` now" / "trigger the gmail triage immediately" | §Run once (off-schedule) |
34
+
35
+ ## When NOT to use this skill
36
+
37
+ | Shape | Use instead |
38
+ |---|---|
39
+ | One-off "remind me at 3pm to call the bank" | `schedule` (`/api/schedule/dm`) |
40
+ | Recurring DM with no external-app fetch ("ping me every Monday at 9") | `schedule` recurring-schedules |
41
+ | "From now on, when X happens, do Y" passive rule with no cadence | `management-policy` |
42
+ | Tone / style / single fact about the user | `user-profile` |
43
+ | Source-of-Truth declaration ("notes live in Obsidian") | A-section binding via `PUT /api/sot-bindings` |
44
+ | Change which **app** an existing task targets | §Stop, then §Register (different connector ⇒ different commitment; the probe must run fresh) |
45
+
46
+ If the user already has `mt_<n>` for the same app + cadence, register
47
+ **refuses** with a DM pointing at the existing row — that is the
48
+ dedup contract. Do not register a duplicate.
49
+
50
+ ---
51
+
52
+ ## Register
53
+
54
+ ### Step 1 — Read current state
55
+
56
+ ```bash
57
+ curl -s "http://localhost:8321/api/context/policies/management" | jq -r .content
58
+ ```
59
+
60
+ Extract §B (Managed tasks) and §A (Source-of-Truth bindings). §A
61
+ tells you which app already owns a category (e.g. `tasks → notion`);
62
+ a duplicate-cadence registration against an unrelated app for the
63
+ same category is a smell — confirm with the user before registering.
64
+
65
+ ### Step 2 — Semantic dedup (LLM judgment)
66
+
67
+ For each existing §B row, compare the requested
68
+ `(app_normalized, cadence_semantic, intent_semantic)` against the
69
+ row. Treat a row as a **high-confidence match** when:
70
+
71
+ - `app_normalized` matches case-insensitively (`zoom` ≡ `Zoom`), AND
72
+ - the cadence resolves to the same structured recurrence, AND
73
+ - the intent describes the same fetch shape ("recordings → meeting
74
+ entity" is the same as "new recordings → meeting entity").
75
+
76
+ On a match, DM the user verbatim with the existing row's id, cadence
77
+ and last result, and stop:
78
+
79
+ > Already managed as `mt_42` (daily 10:00 — last run ok 3 new). Modify
80
+ > or stop it via DM.
81
+
82
+ If multiple plausible matches exist, ask the user which one to update
83
+ and end the flow (their reply triggers §Modify).
84
+
85
+ If §B is at the cap (default 100, configurable
86
+ `managementMaxActiveTasks`), refuse with a DM pointing at the cap;
87
+ the user must stop something first.
88
+
89
+ ### Step 3 — Tool selection (LLM judgment, in-session)
90
+
91
+ Enumerate the tools available to this session (`mcp__*`, native
92
+ backend connectors, custom MCP servers the user installed). Ask
93
+ yourself: *"Which of these, if any, lets me read the user-typed app
94
+ label?"*
95
+
96
+ - **Zero plausible** → DM "I don't see a connected tool for `<app>`
97
+ on this backend. Connect one and ask again." Stop.
98
+ - **Multiple plausible** → DM the user with the candidates verbatim
99
+ and ask which one to use. Stop. (The user's reply re-enters this
100
+ flow with the chosen tool as a hint.)
101
+ - **One plausible** → continue.
102
+
103
+ NEVER hardcode tool names or pattern-match against a specific
104
+ namespace prefix. The user may have installed a custom MCP with
105
+ non-standard names — read the tool description and pick by
106
+ **capability**, not by name.
107
+
108
+ ### Step 4 — Read-only probe
109
+
110
+ Invoke the chosen tool with the **smallest** read-only payload that
111
+ proves connectivity and authorization (list the first page with
112
+ `limit: 1`, fetch the user's profile / "me" endpoint, search empty
113
+ string). Do NOT mutate state.
114
+
115
+ On any error — auth failure, network error, schema error,
116
+ out-of-quota — DM the verbatim error message with one line of
117
+ context and stop:
118
+
119
+ > Couldn't reach `<app>`: `<verbatim error from tool>`.
120
+
121
+ The probe failure must surface the connector's own error string, not
122
+ a paraphrase. The user is the one who can fix auth / quota / install.
123
+
124
+ ### Step 4a — Decide `output_path` (LLM judgment)
125
+
126
+ From the probe sample, infer the primary L2 directory the recurring
127
+ fetch will write into. Bias toward existing matches:
128
+
129
+ 1. If the entity-mirror already holds entities with `sources.<app>.*`
130
+ under one `<domain>/<type-plural>/`, reuse that path:
131
+ ```bash
132
+ curl -s "http://localhost:8321/api/entities?source=<app>&limit=5" | jq .
133
+ ```
134
+ Each item's `path` (`<domain>/<type-plural>/<slug>.md`) reveals
135
+ where that source already lives. If 1+ rows agree on
136
+ `<domain>/<type>`, that path wins.
137
+ 2. Otherwise, pick the `(domain, type)` pair whose semantic prior
138
+ best fits the data shape:
139
+
140
+ | Probe sample shape | Likely `<domain>/<type-plural>/` |
141
+ |---|---|
142
+ | Recording with attendees + duration | `work/meetings/` |
143
+ | PDF / image with monetary amount | `finance/receipts/` |
144
+ | Travel itinerary / booking | `travel/trips/` |
145
+ | Long-form note / article | `<domain>/notes/` (pick by content topic) |
146
+ | Book metadata / progress | `learning/books/` |
147
+
148
+ 3. If the data shape is genuinely ambiguous (zero rows), set
149
+ `output_path: null` — the first scheduled run will populate it
150
+ from real data.
151
+
152
+ The full `output_path` grammar (allowed domain / type values,
153
+ trailing-slash rule, `..` rejection, 422 envelope) is in the
154
+ reference below.
155
+
156
+ {{> ref:output-path }}
157
+
158
+ ### Step 5 — Resolve the cadence
159
+
160
+ Translate the user's natural-language cadence into a free-text
161
+ `cadence` string (rendered in §B) AND a structured `recurrenceRule`
162
+ (the scheduler's input). The full grammar — daily / weekly / monthly
163
+ support, sub-daily refusal template, mapping table, daysOfWeek vs
164
+ daysOfMonth rules — is in the reference below.
165
+
166
+ {{> ref:recurrence-rule }}
167
+
168
+ ### Step 6 — POST /api/managed-tasks
169
+
170
+ ```bash
171
+ curl -sS -X POST http://localhost:8321/api/managed-tasks \
172
+ -H 'Content-Type: application/json' \
173
+ -H 'Idempotency-Key: <opaque uuid for this DM>' \
174
+ -d @- <<'JSON'
175
+ {
176
+ "intent": "Zoom recordings → meeting entity",
177
+ "app": "zoom",
178
+ "cadence": "daily 10:00 (Asia/Tokyo)",
179
+ "recurrenceRule": {
180
+ "frequency": "daily",
181
+ "time": "10:00",
182
+ "timezone": "Asia/Tokyo"
183
+ },
184
+ "output_path": "work/meetings/"
185
+ }
186
+ JSON
187
+ ```
188
+
189
+ | Field | Required | Notes |
190
+ |---|---|---|
191
+ | `intent` | yes | ≤ 200 chars, NFC, no newlines, no pipe chars |
192
+ | `app` | yes | ≤ 64 chars, NFC, no newlines, no pipe chars; user-typed label preserved verbatim (case + non-ASCII OK) |
193
+ | `cadence` | yes | Human-readable; rendered in §B (≤ 200 chars) |
194
+ | `recurrenceRule` | yes | See recurrence-rule reference |
195
+ | `output_path` | no | See output-path reference; omit while undecided (first scheduled run back-fills it) |
196
+
197
+ Response: `{status:"created", item:<ManagedTask>, render_status:"ok"|"lock_contended:..."}`.
198
+ On an idempotent replay (same `Idempotency-Key` within 24 h, row
199
+ still exists) you get `{status:"idempotent_replay", item:<ManagedTask>}`
200
+ with HTTP 200 — treat as success.
201
+
202
+ **Idempotency-Key**: generate a stable key per DM (e.g. SHA-256 of
203
+ the inbound message id + app). Concurrent retries collapse to the
204
+ same `mt_<n>`; a different key with the same `(app_normalized,
205
+ cadence)` collides at the uniqueness check and returns `409
206
+ duplicate` with the existing `mt_id` — DM the user pointing at it
207
+ instead of registering twice.
208
+
209
+ **Server-side transaction (atomic)**: the daemon allocates the next
210
+ `mt_<n>` from `managed_task_seq`, INSERTs `recurring_schedules` and
211
+ `managed_tasks` linked by FK, and writes one `agent_actions` row
212
+ (`action_type='management_task.created'`). On any DB failure the
213
+ transaction rolls back and you get a 5xx — surface the body verbatim.
214
+
215
+ **File render**: post-transaction the daemon re-renders
216
+ `policies/management.md` from DB (locked, snapshotted into
217
+ `md_file_snapshots`). You do NOT touch the file.
218
+
219
+ ### Step 7 — Confirm to user
220
+
221
+ DM the user once with `item.id`, `item.output_path`, and
222
+ `item.cadence` from the POST response. The next firing time is owned
223
+ by the scheduler — phrase around the cadence, not a clock time:
224
+
225
+ > Registered as `mt_43` (Zoom · daily 10:00 JST). Output → `work/meetings/`. Starts at the next 10:00 JST slot.
226
+
227
+ Persona / language rules are in `notify` — follow the awareness gate
228
+ and no-ceremony rules. Don't enumerate the steps ("did probe, did
229
+ INSERT, did re-render"); the daemon already audited them.
230
+
231
+ ---
232
+
233
+ ## Modify
234
+
235
+ ### Step 1 — Locate the row
236
+
237
+ Same lookup as Stop. Either the user named the id, or fuzzy-match by
238
+ `(app, cadence, intent)`:
239
+
240
+ ```bash
241
+ # By id when the user said "mt_42":
242
+ curl -s "http://localhost:8321/api/managed-tasks/mt_42" | jq .item
243
+
244
+ # By app fuzzy lookup:
245
+ curl -s "http://localhost:8321/api/managed-tasks" | jq '.items[] | select(.app_normalized == "zoom")'
246
+ ```
247
+
248
+ GET-by-id wraps the row in `{item:<row>}`; the list returns
249
+ `{items:[…], count:N}`.
250
+
251
+ If no row matches, DM:
252
+
253
+ > No managed task for `<app>` is registered. Want me to register one?
254
+
255
+ If multiple rows could match, list them with id + cadence + intent
256
+ and ask the user to pick. Stop until they reply.
257
+
258
+ ### Step 2 — Diff the requested change
259
+
260
+ Map the user's request to one or more of these fields:
261
+
262
+ | User request | PATCH field | Notes |
263
+ |---|---|---|
264
+ | "9am instead of 10am" / "every Monday" | `cadence` + `recurrenceRule` (send both together) | See recurrence-rule reference |
265
+ | "Rename intent" / "describe it as `<text>`" | `intent` | ≤ 200 chars, NFC, no `\n`, no `\|` |
266
+ | "Send to `<dir>/`" | `output_path` | See output-path reference; send `null` to clear |
267
+
268
+ If the request implies an **app change**, stop and route to "stop +
269
+ re-register" — a different connector is a different commitment.
270
+
271
+ ### Step 3 — Confirm before mutating (Notify tier)
272
+
273
+ PATCH on a managed task is **Notify tier**. DM the user verbatim
274
+ with the proposed change and wait for an explicit yes:
275
+
276
+ > `mt_42` Zoom check — change cadence from `daily 10:00 (Asia/Tokyo)`
277
+ > to `daily 09:00 (Asia/Tokyo)`?
278
+
279
+ If they decline or amend, restart Step 2 with the new shape. When
280
+ the confirmation also implies a different output path, include both
281
+ fields in one PATCH so the audit row reflects the user's intent in a
282
+ single transition.
283
+
284
+ ### Step 4 — PATCH /api/managed-tasks/:id
285
+
286
+ ```bash
287
+ curl -sS -X PATCH http://localhost:8321/api/managed-tasks/mt_42 \
288
+ -H 'Content-Type: application/json' \
289
+ -d @- <<'JSON'
290
+ {
291
+ "cadence": "daily 09:00 (Asia/Tokyo)",
292
+ "recurrenceRule": {
293
+ "frequency": "daily",
294
+ "time": "09:00",
295
+ "timezone": "Asia/Tokyo"
296
+ }
297
+ }
298
+ JSON
299
+ ```
300
+
301
+ `app` / `app_normalized` / `last_run_at` / `last_result` /
302
+ `consecutive_failures` are NOT mutable through this PATCH. App
303
+ rename has its own dedicated route
304
+ (`POST /api/managed-tasks/:id/rename-app`) — but Step 1's
305
+ disambiguator already routes app-change requests to "stop + re-register"
306
+ for safety.
307
+
308
+ Server-side transaction: UPDATE `recurring_schedules` (if
309
+ `recurrenceRule` changed) → UPDATE `managed_tasks` → re-render
310
+ `policies/management.md` → INSERT one `agent_actions` row
311
+ (`action_type='management_task.modified', detail={changed, from, to}`).
312
+
313
+ `mt_id`, `last_run_at`, `last_result`, and `consecutive_failures`
314
+ are preserved across PATCH — history is continuous. A cadence change
315
+ cancels any in-flight `agent_schedule` row tied to the old cron; the
316
+ new cron takes effect from the next eligible slot.
317
+
318
+ **Output-path relocation does NOT move existing entity files.** Past
319
+ entities stay where written. For reorganisation: stop, move
320
+ manually, re-register.
321
+
322
+ ### Step 5 — Confirm to user
323
+
324
+ One DM, persona-tone. Read the resolved fields from the PATCH
325
+ response — do NOT echo what you sent in case the daemon normalized
326
+ something:
327
+
328
+ > Updated `mt_42` Zoom check — now daily 09:00 JST. Next run 2026-12-05 09:00 JST.
329
+
330
+ If only `intent` or `output_path` changed (no cadence shift), do not
331
+ announce a "next run" line — the next firing is unchanged.
332
+
333
+ ---
334
+
335
+ ## Stop
336
+
337
+ Hard-deletes the row. The `recurring_schedules` row cascade-deletes
338
+ via FK and any pending `agent_schedule` rows for the old cron are
339
+ cancelled. History is preserved entirely in `agent_actions`
340
+ (`action_type='management_task.deleted'`) and `md_file_snapshots` —
341
+ there is no soft-stop placeholder in the file.
342
+
343
+ ### Step 1 — Locate the row
344
+
345
+ Same lookup as Modify. **Never stop more than one row in a single
346
+ turn.** A bulk stop ("stop all gmail tasks") requires explicit
347
+ confirmation per row.
348
+
349
+ If no row matches, DM:
350
+
351
+ > No managed task for `<app>` is registered.
352
+
353
+ ### Step 2 — Confirm (Notify tier — destructive)
354
+
355
+ DELETE is **Notify tier** AND removes a recurring commitment the
356
+ user themselves set up. Both safety invariants demand a real DM
357
+ confirmation. **Never auto-stop.**
358
+
359
+ > Stop `mt_42` Zoom check (daily 10:00 JST · last run ok 3 new)? It
360
+ > won't auto-resume.
361
+
362
+ If the user declines, stop. If they amend ("actually just make it
363
+ weekly"), route to §Modify instead — do not stop and re-register on
364
+ their behalf.
365
+
366
+ The "last run" line in the confirmation matters: a row that has been
367
+ silently failing (`consecutive_failures ≥ 3`) is exactly the kind
368
+ the user is most likely stopping by mistake. Surface `last_result`
369
+ so they can make an informed call.
370
+
371
+ ### Step 3 — DELETE /api/managed-tasks/:id
372
+
373
+ ```bash
374
+ curl -sS -X DELETE http://localhost:8321/api/managed-tasks/mt_42
375
+ ```
376
+
377
+ Server-side transaction (atomic): snapshot the row's full state into
378
+ `agent_actions.detail` → DELETE `managed_tasks` (cascades to
379
+ `recurring_schedules` via FK) → cancel pending `agent_schedule`
380
+ rows → re-render `policies/management.md` → INSERT one `agent_actions`
381
+ row (`action_type='management_task.deleted'`).
382
+
383
+ The pre-delete row snapshot in `agent_actions`
384
+ (`detail.original_row`) plus the file snapshot in
385
+ `md_file_snapshots` is the recovery surface — surface it in
386
+ audit / debug contexts only, never in the user-facing DM.
387
+
388
+ ### Step 4 — Confirm to user
389
+
390
+ One DM:
391
+
392
+ > Stopped `mt_42` Zoom check. The row is gone from the registry; ask
393
+ > me to register a new one any time.
394
+
395
+ `state/activity/<source>.md`'s "Recently changed (90d)" section
396
+ auto-updates within ~10 s. You do NOT touch that file.
397
+
398
+ ---
399
+
400
+ ## Run once (off-schedule)
401
+
402
+ When the user asks to fire an existing `mt_<n>` immediately ("run
403
+ `mt_42` now", "trigger the gmail triage right away") **without**
404
+ modifying the schedule:
405
+
406
+ ```bash
407
+ curl -sS -X POST http://localhost:8321/api/managed-tasks/mt_42/run-now
408
+ ```
409
+
410
+ The route is implemented at `packages/daemon/src/api/routes/managed-tasks.ts:875`.
411
+ The dispatcher enqueues a one-shot fire that runs the same task-flow
412
+ as a scheduled fire would; the next regular firing is unaffected.
413
+ `409 already_running` means a previous fire is still in flight — do
414
+ not loop.
415
+
416
+ Confirm to user with one DM after the fire enqueues:
417
+
418
+ > Triggered `mt_42` now (off-schedule). It runs alongside the regular
419
+ > 10:00 JST slot.
420
+
421
+ ---
422
+
423
+ ## Error envelope
424
+
425
+ The standard daemon error shape applies to every `/api/managed-tasks`
426
+ call. Verbs (POST / PATCH / DELETE / run-now), codes
427
+ (`validation_error`, `duplicate`, `cap_reached`, `invalid_id`,
428
+ `not_found`, `already_running`, `internal_error`), and the
429
+ Idempotency-Key contract are in the errors reference below.
430
+
431
+ {{> ref:errors }}
432
+
433
+ ---
434
+
435
+ ## What this skill does NOT do
436
+
437
+ - Does NOT hardcode connector tool names — all tool selection is
438
+ LLM-judged.
439
+ - Does NOT PUT `policies/management.md` directly — the daemon owns the
440
+ write. The only legal write is the `/api/managed-tasks` chokepoint.
441
+ - Does NOT INSERT `recurring_schedules` directly. POST
442
+ `/api/managed-tasks` keeps the FK pair consistent.
443
+ - Does NOT pause / disable a task — there is no soft-pause; stop +
444
+ re-register if the user wants a hiatus.
445
+ - Does NOT mutate `app` through PATCH — that is a different
446
+ commitment, stop + re-register.
447
+ - Does NOT touch §A (SoT bindings) — use `PUT /api/sot-bindings`.
448
+ Does NOT touch §C (Active Policies) — owned by `management-policy`.
449
+ - Does NOT silently re-register on retry — use `Idempotency-Key`
450
+ per-DM; conflicts surface the existing `mt_id`.
451
+ - Does NOT register a task that has no probe-passing connector.
452
+ Probe failure is a hard stop.
453
+ - Does NOT delete entity files produced by past runs on stop.
454
+ - Does NOT regenerate `state/activity/<source>.md`. The reconciler does.
455
+ - Does NOT bulk-stop without per-row confirmation. "Stop all gmail
456
+ tasks" is a series of DM round-trips, one per row.
457
+
458
+ ## API surface
459
+
460
+ | Verb + path | Used in |
461
+ |---|---|
462
+ | `GET /api/context/policies/management` | Register Step 1 (read §A + §B) |
463
+ | `GET /api/entities?source=<app>` | Register Step 4a (output-path bias) |
464
+ | `GET /api/managed-tasks` / `/api/managed-tasks/:id` | Locate row (Modify / Stop Step 1; Register Step 1 alternate) |
465
+ | `POST /api/managed-tasks` | Register Step 6 (Notify tier; daemon DMs confirmation) |
466
+ | `PATCH /api/managed-tasks/:id` | Modify Step 4 (Notify tier) |
467
+ | `DELETE /api/managed-tasks/:id` | Stop Step 3 (Notify tier; destructive) |
468
+ | `POST /api/managed-tasks/:id/run-now` | Run once (off-schedule) |
469
+ | `POST /api/notify` | User-facing confirmations (your own DM-to-user replies) |
470
+
471
+ Every state-changing call writes one `agent_actions` row and
472
+ snapshots the file — do NOT post a separate audit event yourself.
@@ -0,0 +1,73 @@
1
+ ---
2
+ kind: reference
3
+ name: errors
4
+ description: /api/managed-tasks error envelope — POST / PATCH / DELETE codes (validation_error, duplicate, cap_reached, invalid_id, not_found, internal_error).
5
+ ---
6
+
7
+ # /api/managed-tasks error envelope
8
+
9
+ Every endpoint returns the standard daemon error shape:
10
+
11
+ ```jsonc
12
+ {
13
+ "error": "<machine code>",
14
+ "message": "<human text — surface verbatim to the user>",
15
+ "details": [ /* Zod issue list when error === "validation_error" */ ],
16
+ "item": { /* present on 409 duplicate — the existing row */ }
17
+ }
18
+ ```
19
+
20
+ `body.message` is intended for the user — preserve it verbatim. The
21
+ daemon does NOT emit `cron_too_tight`. Note: the recurrence schema
22
+ DOES accept `hourly` (the engine supports `hourly`/`daily`/`weekly`/
23
+ `monthly`), so a sub-daily POST is NOT rejected server-side — it
24
+ succeeds (201). The daily-or-coarser floor for managed tasks is a
25
+ **client-side** refusal only: YOU must refuse sub-daily cadences per
26
+ the recurrence-rule reference (`§ Consumer-specific refusal`) before
27
+ POSTing — do not expect the server to 400 an `hourly` rule. The daemon
28
+ also does not emit `cadence_partial` (the recurrence rule is one
29
+ structured field, so there is no partial-cadence shape to reject).
30
+
31
+ ## POST /api/managed-tasks
32
+
33
+ | HTTP | `error` | When | What to do |
34
+ |---|---|---|---|
35
+ | 400 | `validation_error` | Body fails Zod (frequency unknown, time malformed, etc.) | Pick the offending field from `details[].path` and ask the user to clarify. |
36
+ | 409 | `duplicate` | An existing row has the same `(app_normalized, cadence)` | DM `Already managed as <body.item.id>` and stop. The body's `item` is the existing row. |
37
+ | 409 | `cap_reached` | §B already at the active-task cap (default 100) | Surface `body.message` (carries the cap value); user must stop something first. |
38
+ | 5xx | `internal_error` | DB / cascade failure | DM "Couldn't register; daemon error. Try again, or check `aitne logs`." |
39
+
40
+ ## PATCH /api/managed-tasks/:id
41
+
42
+ | HTTP | `error` | When | What to do |
43
+ |---|---|---|---|
44
+ | 400 | `invalid_id` | `:id` didn't match `^mt_[1-9]\d*$` | User typed the id wrong — ask them to repeat. |
45
+ | 400 | `validation_error` | Body fails Zod (empty body, recurrenceRule.daysOfWeek on a `daily`, etc.) | Pin the failing path from `details[].path` and ask for a fix. |
46
+ | 404 | `not_found` | No row for `:id` | DM "I don't have an `mt_<id>` to modify"; offer to register one. |
47
+ | 5xx | `internal_error` | DB / cascade failure | Surface `body.message`; advise `aitne logs`. |
48
+
49
+ ## DELETE /api/managed-tasks/:id
50
+
51
+ | HTTP | `error` | When | What to do |
52
+ |---|---|---|---|
53
+ | 400 | `invalid_id` | `:id` didn't match `^mt_[1-9]\d*$` | Ask the user to repeat. |
54
+ | 404 | `not_found` | No row for `:id` | DM "No managed task with that id"; if you used a fuzzy match, re-list candidates. |
55
+ | 5xx | `internal_error` | DB / cascade failure | Surface `body.message`; advise `aitne logs`. |
56
+
57
+ ## POST /api/managed-tasks/:id/run-now
58
+
59
+ | HTTP | `error` | When | What to do |
60
+ |---|---|---|---|
61
+ | 400 | `invalid_id` | `:id` didn't match `^mt_[1-9]\d*$` | Ask the user to repeat. |
62
+ | 404 | `not_found` | No row for `:id` | Cannot run a stopped task. |
63
+ | 409 | `already_running` | A previous fire is still in flight | Tell the user; do NOT loop. |
64
+ | 5xx | `internal_error` | Dispatcher / cascade failure | Surface `body.message`. |
65
+
66
+ ## Idempotency on POST
67
+
68
+ Per-DM `Idempotency-Key` (recommended: SHA-256 of the inbound message
69
+ id + app). Concurrent retries collapse to the same `mt_<n>`. A
70
+ different key with the same `(app_normalized, cadence)` collides at
71
+ the uniqueness check and the second POST returns `409 duplicate`
72
+ with the existing `mt_id` — DM the user pointing at it rather than
73
+ registering twice.
@@ -0,0 +1,75 @@
1
+ ---
2
+ kind: reference
3
+ name: output-path
4
+ description: output_path grammar — `<domain>/<type-plural>/` only, trailing slash mandatory, no `..`, no leading `context/`. Daemon CHECKs at INSERT/UPDATE.
5
+ ---
6
+
7
+ # output_path grammar
8
+
9
+ The `output_path` field on `/api/managed-tasks` is the L2 directory
10
+ under the primary context vault where the recurring fetch will write
11
+ entity files. The daemon enforces the format with a CHECK constraint
12
+ at INSERT / UPDATE time.
13
+
14
+ ## Format
15
+
16
+ `<domain>/<type-plural>/`
17
+
18
+ - Leading `context/` is **implicit** and must NOT be included; the
19
+ daemon prepends it.
20
+ - The trailing `/` is **mandatory**.
21
+ - No `..` segments. No absolute paths. No leading `/`.
22
+
23
+ ## Allowed values
24
+
25
+ | Position | Allowed |
26
+ |---|---|
27
+ | `<domain>` | `work`, `travel`, `finance`, `personal`, `health`, `learning` |
28
+ | `<type-plural>` | `meetings`, `trips`, `receipts`, `projects`, `books`, `notes` |
29
+
30
+ Not every domain × type combination is meaningful in practice — pick
31
+ the pair whose semantic prior best fits the fetch's data shape (see
32
+ the §"Decide output path" table in the Register section of the skill
33
+ body for the typical mapping).
34
+
35
+ ## Examples
36
+
37
+ | Valid | Invalid | Why invalid |
38
+ |---|---|---|
39
+ | `work/meetings/` | `work/meetings` | Missing trailing `/` |
40
+ | `finance/receipts/` | `/finance/receipts/` | Leading `/` |
41
+ | `travel/trips/` | `context/travel/trips/` | Leading `context/` is implicit |
42
+ | `learning/books/` | `random/dir/` | `<domain>` not in allowed set |
43
+ | `personal/notes/` | `work/agendas/` | `<type-plural>` not in allowed set |
44
+ | (path omitted) | `work/../etc/` | `..` segments rejected |
45
+
46
+ ## When to omit
47
+
48
+ `output_path` is **optional** on POST. Omit when the data shape is
49
+ genuinely ambiguous (e.g. the probe returned zero rows). The first
50
+ scheduled run populates it from real data, and a subsequent PATCH
51
+ back-fills the field if the user wants to pin it.
52
+
53
+ ## When to relocate
54
+
55
+ A `PATCH /api/managed-tasks/:id` with a new `output_path` changes
56
+ only the *future* runs — existing entity files written under the old
57
+ path stay where they were. If the user wants reorganisation, stop
58
+ the task, move the files manually (or ask the user to), and
59
+ re-register.
60
+
61
+ To clear an existing `output_path` back to "first run decides", send
62
+ `{"output_path": null}` in the PATCH.
63
+
64
+ ## 422 envelope on rejection
65
+
66
+ ```json
67
+ {
68
+ "error": "validation_error",
69
+ "message": "output_path 'work/meetings' is missing the trailing slash",
70
+ "field": "output_path"
71
+ }
72
+ ```
73
+
74
+ Surface the daemon's `message` verbatim — it names the exact rule
75
+ that failed. Do not retry the same value.