@aitne-sh/aitne 0.1.0

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 (249) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +464 -0
  3. package/agent-assets/agent-profiles/_safety.md +26 -0
  4. package/agent-assets/agent-profiles/conversational.md +33 -0
  5. package/agent-assets/agent-profiles/docs-qa.md +24 -0
  6. package/agent-assets/agent-profiles/observer.md +28 -0
  7. package/agent-assets/agent-profiles/profile-importer.md +63 -0
  8. package/agent-assets/agent-profiles/proxy.md +28 -0
  9. package/agent-assets/agent-profiles/routine.md +16 -0
  10. package/agent-assets/agent-profiles/task.md +18 -0
  11. package/agent-assets/docs/concepts/agent-day.md +88 -0
  12. package/agent-assets/docs/concepts/auth-health.md +75 -0
  13. package/agent-assets/docs/concepts/backends-and-tiers.md +126 -0
  14. package/agent-assets/docs/concepts/costs-and-quotas.md +103 -0
  15. package/agent-assets/docs/concepts/delegated-mode.md +223 -0
  16. package/agent-assets/docs/concepts/memory-model.md +118 -0
  17. package/agent-assets/docs/concepts/observations.md +80 -0
  18. package/agent-assets/docs/concepts/process-keys.md +89 -0
  19. package/agent-assets/docs/concepts/routines.md +108 -0
  20. package/agent-assets/docs/concepts/safety-and-execution.md +109 -0
  21. package/agent-assets/docs/concepts/safety-model.md +279 -0
  22. package/agent-assets/docs/concepts/skills.md +100 -0
  23. package/agent-assets/docs/features/integrations/calendar.md +92 -0
  24. package/agent-assets/docs/features/integrations/git.md +95 -0
  25. package/agent-assets/docs/features/integrations/github.md +170 -0
  26. package/agent-assets/docs/features/integrations/mail.md +106 -0
  27. package/agent-assets/docs/features/integrations/notion.md +69 -0
  28. package/agent-assets/docs/features/integrations/obsidian.md +71 -0
  29. package/agent-assets/docs/features/lifestyle/git.md +178 -0
  30. package/agent-assets/docs/features/lifestyle/reading.md +93 -0
  31. package/agent-assets/docs/features/lifestyle/receipts.md +71 -0
  32. package/agent-assets/docs/features/lifestyle/travel-bookings.md +44 -0
  33. package/agent-assets/docs/features/lifestyle/travel-time.md +52 -0
  34. package/agent-assets/docs/features/memory-files/agent-journal.md +105 -0
  35. package/agent-assets/docs/features/memory-files/projects.md +56 -0
  36. package/agent-assets/docs/features/memory-files/roadmap.md +61 -0
  37. package/agent-assets/docs/features/memory-files/schedule.md +112 -0
  38. package/agent-assets/docs/features/memory-files/today.md +73 -0
  39. package/agent-assets/docs/features/memory-files/user-profile.md +81 -0
  40. package/agent-assets/docs/features/messaging/dashboard-chat.md +93 -0
  41. package/agent-assets/docs/features/messaging/discord.md +50 -0
  42. package/agent-assets/docs/features/messaging/overview.md +111 -0
  43. package/agent-assets/docs/features/messaging/pairing-and-magic-phrase.md +69 -0
  44. package/agent-assets/docs/features/messaging/slack.md +51 -0
  45. package/agent-assets/docs/features/messaging/telegram.md +63 -0
  46. package/agent-assets/docs/features/messaging/whatsapp.md +48 -0
  47. package/agent-assets/docs/features/operations/activity-and-conversations.md +105 -0
  48. package/agent-assets/docs/features/operations/approvals.md +58 -0
  49. package/agent-assets/docs/features/operations/backend-routing.md +62 -0
  50. package/agent-assets/docs/features/operations/cost-tracking.md +59 -0
  51. package/agent-assets/docs/features/operations/notifications.md +69 -0
  52. package/agent-assets/docs/features/operations/quiet-hours.md +106 -0
  53. package/agent-assets/docs/features/operations/schedule-approaching.md +60 -0
  54. package/agent-assets/docs/features/routines/custom-routines.md +101 -0
  55. package/agent-assets/docs/features/routines/evening-review.md +81 -0
  56. package/agent-assets/docs/features/routines/hourly-check.md +85 -0
  57. package/agent-assets/docs/features/routines/monthly-review.md +65 -0
  58. package/agent-assets/docs/features/routines/morning-routine.md +123 -0
  59. package/agent-assets/docs/features/routines/weekly-review.md +70 -0
  60. package/agent-assets/docs/getting-started/01-what-is-this.md +192 -0
  61. package/agent-assets/docs/getting-started/02-first-steps.md +80 -0
  62. package/agent-assets/docs/getting-started/03-what-can-this-do.md +110 -0
  63. package/agent-assets/docs/getting-started/04-first-day.md +287 -0
  64. package/agent-assets/docs/glossary.md +116 -0
  65. package/agent-assets/docs/guides/add-a-custom-routine.md +71 -0
  66. package/agent-assets/docs/guides/backup-and-restore.md +54 -0
  67. package/agent-assets/docs/guides/change-which-model-handles-x.md +47 -0
  68. package/agent-assets/docs/guides/connect-a-new-mail-account.md +59 -0
  69. package/agent-assets/docs/guides/import-knowledge-file.md +275 -0
  70. package/agent-assets/docs/guides/install-and-run.md +72 -0
  71. package/agent-assets/docs/guides/migrate-machines.md +52 -0
  72. package/agent-assets/docs/guides/pause-the-agent.md +65 -0
  73. package/agent-assets/docs/guides/reinstall-cleanly.md +52 -0
  74. package/agent-assets/docs/guides/setup-wizard.md +107 -0
  75. package/agent-assets/docs/guides/switch-default-backend.md +60 -0
  76. package/agent-assets/docs/reference/api.md +51 -0
  77. package/agent-assets/docs/reference/cli-commands.md +121 -0
  78. package/agent-assets/docs/reference/config.md +74 -0
  79. package/agent-assets/docs/reference/disallowed-tools.md +76 -0
  80. package/agent-assets/docs/reference/keyboard-shortcuts.md +39 -0
  81. package/agent-assets/docs/reference/process-keys.md +59 -0
  82. package/agent-assets/docs/reference/skills.md +50 -0
  83. package/agent-assets/docs/troubleshooting/auth-failed.md +57 -0
  84. package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +55 -0
  85. package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +54 -0
  86. package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +53 -0
  87. package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +75 -0
  88. package/agent-assets/docs/troubleshooting/observation-not-detected.md +57 -0
  89. package/agent-assets/docs/troubleshooting/quota-exhausted.md +57 -0
  90. package/agent-assets/optimizer-skills/drift-analysis/SKILL.md +75 -0
  91. package/agent-assets/optimizer-skills/knowledge-map/SKILL.md +71 -0
  92. package/agent-assets/optimizer-skills/skill-curation/SKILL.md +108 -0
  93. package/agent-assets/project-doc-templates/git-repo.md +21 -0
  94. package/agent-assets/project-doc-templates/project.md +38 -0
  95. package/agent-assets/skills/attach/SKILL.md +104 -0
  96. package/agent-assets/skills/context/SKILL.md +257 -0
  97. package/agent-assets/skills/context/curation.json +37 -0
  98. package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +13 -0
  99. package/agent-assets/skills/context/seeds/frontmatter-requirements.seed.json +40 -0
  100. package/agent-assets/skills/docs-search/SKILL.md +176 -0
  101. package/agent-assets/skills/external-services/SKILL.delegated.claude.md +369 -0
  102. package/agent-assets/skills/external-services/SKILL.delegated.codex.md +349 -0
  103. package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +347 -0
  104. package/agent-assets/skills/external-services/SKILL.md +371 -0
  105. package/agent-assets/skills/mail/SKILL.delegated.claude.md +284 -0
  106. package/agent-assets/skills/mail/SKILL.delegated.codex.md +261 -0
  107. package/agent-assets/skills/mail/SKILL.delegated.gemini.md +255 -0
  108. package/agent-assets/skills/mail/SKILL.md +313 -0
  109. package/agent-assets/skills/mail/references/errors.md +17 -0
  110. package/agent-assets/skills/mail/references/providers.md +40 -0
  111. package/agent-assets/skills/mail/references/query-grammar.md +24 -0
  112. package/agent-assets/skills/management-policy/SKILL.md +307 -0
  113. package/agent-assets/skills/management-policy/curation.json +13 -0
  114. package/agent-assets/skills/management-policy/seeds/policy-file-shape.seed.json +16 -0
  115. package/agent-assets/skills/management-task-modify/SKILL.md +202 -0
  116. package/agent-assets/skills/management-task-register/SKILL.md +330 -0
  117. package/agent-assets/skills/management-task-stop/SKILL.md +166 -0
  118. package/agent-assets/skills/notify/SKILL.md +196 -0
  119. package/agent-assets/skills/notion/SKILL.delegated.claude.md +254 -0
  120. package/agent-assets/skills/notion/SKILL.delegated.codex.md +195 -0
  121. package/agent-assets/skills/notion/SKILL.delegated.gemini.md +194 -0
  122. package/agent-assets/skills/notion/SKILL.md +86 -0
  123. package/agent-assets/skills/observations/SKILL.md +234 -0
  124. package/agent-assets/skills/observations/curation.json +13 -0
  125. package/agent-assets/skills/observations/seeds/source-namespacing.seed.json +20 -0
  126. package/agent-assets/skills/project-doc/SKILL.md +86 -0
  127. package/agent-assets/skills/project-doc/curation.json +21 -0
  128. package/agent-assets/skills/project-doc/seeds/project-shape.seed.json +25 -0
  129. package/agent-assets/skills/project-doc/seeds/slug-grammar.seed.json +20 -0
  130. package/agent-assets/skills/reading/SKILL.md +198 -0
  131. package/agent-assets/skills/reading/references/reading-taste.md +197 -0
  132. package/agent-assets/skills/receipts/SKILL.md +134 -0
  133. package/agent-assets/skills/roadmap/SKILL.md +276 -0
  134. package/agent-assets/skills/roadmap/curation.json +13 -0
  135. package/agent-assets/skills/roadmap/references/horizon-tags.md +40 -0
  136. package/agent-assets/skills/roadmap/references/preparation-timeline.md +47 -0
  137. package/agent-assets/skills/roadmap/seeds/entry-types.seed.json +16 -0
  138. package/agent-assets/skills/schedule/SKILL.md +228 -0
  139. package/agent-assets/skills/scheduled-managed-task/SKILL.md +392 -0
  140. package/agent-assets/skills/today/SKILL.md +198 -0
  141. package/agent-assets/skills/today/curation.json +21 -0
  142. package/agent-assets/skills/today/seeds/agent-notes-flavors.seed.json +17 -0
  143. package/agent-assets/skills/today/seeds/section-shape.seed.json +17 -0
  144. package/agent-assets/skills/travel/SKILL.md +132 -0
  145. package/agent-assets/skills/travel-time/SKILL.md +149 -0
  146. package/agent-assets/skills/user-interview/SKILL.md +323 -0
  147. package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +94 -0
  148. package/agent-assets/skills/user-profile/SKILL.md +210 -0
  149. package/agent-assets/skills/user-profile/curation.json +29 -0
  150. package/agent-assets/skills/user-profile/seeds/learned-context-format.seed.json +14 -0
  151. package/agent-assets/skills/user-profile/seeds/routing-table.seed.json +53 -0
  152. package/agent-assets/skills/user-profile/seeds/topic-files.seed.json +27 -0
  153. package/agent-assets/task-flows/dashboard.docs_qa.md +43 -0
  154. package/agent-assets/task-flows/default.md +11 -0
  155. package/agent-assets/task-flows/git.branch.created.md +25 -0
  156. package/agent-assets/task-flows/git.lifecycle.poll.md +52 -0
  157. package/agent-assets/task-flows/git.local_ahead.stale.md +34 -0
  158. package/agent-assets/task-flows/git.merge_to_default.md +30 -0
  159. package/agent-assets/task-flows/git.project.refresh_architecture.md +100 -0
  160. package/agent-assets/task-flows/git.project.retemplate.md +73 -0
  161. package/agent-assets/task-flows/git.push.detected.md +32 -0
  162. package/agent-assets/task-flows/git.push.force_pushed.md +36 -0
  163. package/agent-assets/task-flows/git.tag.created.md +24 -0
  164. package/agent-assets/task-flows/github.assigned.md +43 -0
  165. package/agent-assets/task-flows/github.pull_request.review_requested.md +57 -0
  166. package/agent-assets/task-flows/github.security_alert.md +45 -0
  167. package/agent-assets/task-flows/github.workflow_run.failed.md +57 -0
  168. package/agent-assets/task-flows/knowledge.import.md +161 -0
  169. package/agent-assets/task-flows/message.received.dm.md +142 -0
  170. package/agent-assets/task-flows/message.received.dm_first.md +117 -0
  171. package/agent-assets/task-flows/message.received.md +14 -0
  172. package/agent-assets/task-flows/routine.custom.md +38 -0
  173. package/agent-assets/task-flows/routine.evening_review.md +323 -0
  174. package/agent-assets/task-flows/routine.hourly_check.delegated.claude.md +405 -0
  175. package/agent-assets/task-flows/routine.hourly_check.delegated.codex.md +400 -0
  176. package/agent-assets/task-flows/routine.hourly_check.delegated.gemini.md +404 -0
  177. package/agent-assets/task-flows/routine.hourly_check.md +184 -0
  178. package/agent-assets/task-flows/routine.hourly_check.triage.md +93 -0
  179. package/agent-assets/task-flows/routine.monthly_review.md +250 -0
  180. package/agent-assets/task-flows/routine.morning_routine.md +300 -0
  181. package/agent-assets/task-flows/routine.morning_routine_initial.md +184 -0
  182. package/agent-assets/task-flows/routine.roadmap_refresh.md +275 -0
  183. package/agent-assets/task-flows/routine.today_refresh.md +172 -0
  184. package/agent-assets/task-flows/routine.user_profile_sweep.md +242 -0
  185. package/agent-assets/task-flows/routine.weekly_review.md +247 -0
  186. package/agent-assets/task-flows/schedule.approaching.md +124 -0
  187. package/agent-assets/task-flows/scheduled.dm.md +391 -0
  188. package/agent-assets/task-flows/scheduled.task.md +141 -0
  189. package/agent-assets/task-flows/setup.initial.md +277 -0
  190. package/agent-assets/task-flows/setup.update.md +53 -0
  191. package/agent-assets/templates/README.md +85 -0
  192. package/agent-assets/templates/_index.md +39 -0
  193. package/agent-assets/templates/_manifest.json +103 -0
  194. package/agent-assets/templates/agent/journal.md +10 -0
  195. package/agent-assets/templates/agent/profile-questions.md +74 -0
  196. package/agent-assets/templates/context-index.md +42 -0
  197. package/agent-assets/templates/dossiers/_index.md +22 -0
  198. package/agent-assets/templates/dossiers/evening.md +23 -0
  199. package/agent-assets/templates/dossiers/hourly.md +23 -0
  200. package/agent-assets/templates/dossiers/monthly.md +23 -0
  201. package/agent-assets/templates/dossiers/morning.md +23 -0
  202. package/agent-assets/templates/dossiers/roadmap.md +23 -0
  203. package/agent-assets/templates/dossiers/weekly.md +23 -0
  204. package/agent-assets/templates/projects/_active.base +14 -0
  205. package/agent-assets/templates/projects/_index.md +29 -0
  206. package/agent-assets/templates/roadmap.md +15 -0
  207. package/agent-assets/templates/routines/_index.md +20 -0
  208. package/agent-assets/templates/routines/evening.md +22 -0
  209. package/agent-assets/templates/routines/hourly.md +30 -0
  210. package/agent-assets/templates/routines/monthly.md +25 -0
  211. package/agent-assets/templates/routines/morning.md +26 -0
  212. package/agent-assets/templates/routines/weekly.md +23 -0
  213. package/agent-assets/templates/rules/_index.md +19 -0
  214. package/agent-assets/templates/rules/journal-export.md +41 -0
  215. package/agent-assets/templates/rules/journal-format.md +61 -0
  216. package/agent-assets/templates/rules/management.md +48 -0
  217. package/agent-assets/templates/rules/mcp.md +40 -0
  218. package/agent-assets/templates/rules/policies/_index.md +22 -0
  219. package/agent-assets/templates/rules/redaction.md +30 -0
  220. package/agent-assets/templates/today.md +13 -0
  221. package/agent-assets/templates/user/_index.md +16 -0
  222. package/agent-assets/templates/user/expertise.md +7 -0
  223. package/agent-assets/templates/user/goals.md +7 -0
  224. package/agent-assets/templates/user/people.md +7 -0
  225. package/agent-assets/templates/user/personal.md +7 -0
  226. package/agent-assets/templates/user/profile.md +28 -0
  227. package/agent-assets/templates/user/work.md +7 -0
  228. package/bin/aitne.mjs +1096 -0
  229. package/package.json +78 -0
  230. package/personal-agent.mjs +39 -0
  231. package/scripts/browser.mjs +99 -0
  232. package/scripts/check-redaction-coverage.mjs +109 -0
  233. package/scripts/commands/audit.mjs +309 -0
  234. package/scripts/commands/doctor.mjs +437 -0
  235. package/scripts/commands/open.mjs +40 -0
  236. package/scripts/commands/setup.mjs +21 -0
  237. package/scripts/commands/uninstall.mjs +114 -0
  238. package/scripts/commands/update.mjs +96 -0
  239. package/scripts/commands/version.mjs +62 -0
  240. package/scripts/commands.md +0 -0
  241. package/scripts/lib/sqlite-loader.mjs +49 -0
  242. package/scripts/message-discipline-digest.mjs +535 -0
  243. package/scripts/poc/google-connector-inheritance/REPORT.md +197 -0
  244. package/scripts/poc/google-connector-inheritance/claude-sdk-probe.mjs +79 -0
  245. package/scripts/remint-roadmap-ids.mjs +257 -0
  246. package/scripts/rm-paths.mjs +22 -0
  247. package/scripts/run-node.mjs +223 -0
  248. package/scripts/smoke-obsidian-api.mjs +166 -0
  249. package/scripts/start.mjs +160 -0
@@ -0,0 +1,391 @@
1
+ {context}
2
+
3
+ ## Task: Scheduled DM-tone session
4
+
5
+ You are running on the conversational agent profile. The user knows
6
+ this voice from regular DMs — your final assistant turn IS the DM
7
+ that the daemon will deliver. Compose accordingly.
8
+
9
+ Origin: {event_data[source]}
10
+ Task: {event_data[task]}
11
+
12
+ <task_context>
13
+ {event_data[task_context]}
14
+ </task_context>
15
+
16
+ ## Context blocks you receive
17
+
18
+ - `<today>` — today.md (User Schedule, User Tasks, Agent Plan, Agent
19
+ Notes, Handoff)
20
+ - `<calendar_today>` — live 1-day calendar fetch at fire time
21
+ - `<recent_dm_messages window="60min">` — owner's inbound DMs in the
22
+ last hour. Empty/missing means the user has been quiet.
23
+ - `<recent_dm_conversation>` — last 20 turns of DM history (rolling
24
+ topic context)
25
+ - `<task_origin>` — what triggered this run (recurring schedule id,
26
+ source)
27
+
28
+ ## Conversation-state framing (universal — every dm_session)
29
+
30
+ Detect state from `<recent_dm_messages>`:
31
+
32
+ - **asleep** — block empty, or oldest message > 60 min old
33
+ - **active** — inbound user DM in the last 30 min
34
+ - **very-recent** — inbound user DM in the last 5 min
35
+
36
+ The state controls the framing of your DM:
37
+
38
+ - **asleep** → Variant A: standard DM with greeting opener
39
+ - **active** or **very-recent** → Variant B: conversational weave,
40
+ NO greeting, acknowledge the interruption, reference the recent
41
+ topic if extractable, hand the floor back at the end
42
+
43
+ Content blocks (Schedule / Tasks / Overnight / At-risk) are identical
44
+ across both variants. Only the opener and closer differ.
45
+
46
+ ## Persona compliance — IMPORTANT, NON-NEGOTIABLE
47
+
48
+ **The example phrasings throughout this document illustrate STRUCTURE,
49
+ not TONE.** The actual voice, register, language, formality, and
50
+ emoji policy MUST come from:
51
+
52
+ 1. `agent-profiles/<active>.md` — the configured agent persona, already
53
+ in your system prompt. Voice rules, character traits, speech
54
+ patterns all live there.
55
+ 2. The `## Character (user-defined)` block in your system prompt
56
+ (see `docs/design/15-character.md`) — the user's preferred tone,
57
+ language, formality, register, emoji policy, and verbosity. Present
58
+ when set; absent when empty. The Character block overlays — it
59
+ never overrides — persona voice rules or safety invariants.
60
+
61
+ If the configured persona is formal, do NOT use the casual phrasings
62
+ in the examples. Match the user's language and register from the
63
+ Character block (when set), `<settings primary_language>`, and prior
64
+ turns — if they write in a non-English language, reply in that
65
+ language. If the user prefers no emoji, omit them. The examples teach
66
+ you what to put WHERE — not how to sound.
67
+
68
+ Voice drift here is high-impact: dm_session is the most
69
+ persona-load-bearing daemon-initiated touchpoint. The user
70
+ experiences a voice mismatch as "the agent feels like a different
71
+ person at 9am than during the day."
72
+
73
+ ## Sub-flow routing
74
+
75
+ The specific dm_session task is selected by `{event_data[task]}`
76
+ prefix matching. Find the matching sub-flow below and follow its
77
+ content rules.
78
+
79
+ - starts with `morning briefing` → see `## Morning briefing` below
80
+ - starts with `profile_interview:` → see `## Profile interview` below
81
+ - (future sub-flows added here)
82
+
83
+ If no sub-flow matches:
84
+
85
+ 1. Append a one-line warning to today.md `## Agent Log` (PATCH append,
86
+ section=agent_log) using the `today` skill:
87
+ ```
88
+ - HH:MM [dm_session] unrecognized task: "<task description>" — skipped
89
+ ```
90
+ 2. End the turn with NO assistant text — the daemon's notification
91
+ path skips zero-length outputs, so no DM is sent.
92
+
93
+ Do NOT emit a placeholder line like `(unrecognized ...)` as the final
94
+ text. shouldNotify is unconditional for `scheduled.dm` (any non-empty
95
+ final text is delivered as a DM), so a placeholder would reach the
96
+ user verbatim — defeating the skip.
97
+
98
+ ---
99
+
100
+ ## Morning briefing
101
+
102
+ Triggered by `{event_data[task]}` starting with `morning briefing`.
103
+
104
+ > Universal rules from the notify skill § Universal user-facing
105
+ > message discipline apply on top of the contract below — particularly
106
+ > the awareness gate (lead with what the agent learned overnight, not
107
+ > calendar readback), the no-ceremony / no-internal-mechanism-names
108
+ > rules, and compactness.
109
+
110
+ Goal: give the user a single integrated view of today, plus anything
111
+ new the agent learned overnight, plus a closing note calibrated to
112
+ the day's shape. Always send — even on empty days, the briefing is
113
+ the daily greeting.
114
+
115
+ ### Sources to gather
116
+
117
+ 1. `<today>` ## User Schedule — today's calendar events
118
+ 2. `<today>` ## User Tasks — already merged from Notion / mail /
119
+ roadmap by the morning routine at 04:00
120
+ 3. **Overnight delta (since 04:00 today)** — re-query at fire time:
121
+ - Mail: per active account in mail skill's accounts.md, fetch the
122
+ 10 most recent messages and keep items received between 04:00 and
123
+ now. The wire surface depends on Gmail's mode in
124
+ `<integration_modes>`:
125
+ <!-- mode:direct:gmail -->
126
+ Use the `mail` skill — `GET /api/mail/:accountId/messages?limit=10`
127
+ for every account (Gmail, Outlook, iCloud, Yahoo, IMAP — same wire surface).
128
+ <!-- /mode:direct:gmail -->
129
+ <!-- mode:delegated-same:gmail -->
130
+ Non-Gmail accounts (iCloud / Outlook / Yahoo / IMAP): use the
131
+ `mail` skill as in direct mode. Gmail accounts: the `/api/mail/*`
132
+ per-account gate returns 410 — use your session backend's native
133
+ Gmail MCP tool with a "10 most recent inbox" query (`q=in:inbox`,
134
+ limit/maxResults `10`). The `mail` skill body lists the
135
+ per-backend tool names; this session is same-backend so no daemon
136
+ proxy is involved.
137
+ <!-- /mode:delegated-same:gmail -->
138
+ <!-- mode:delegated-cross:gmail -->
139
+ Non-Gmail accounts: use the `mail` skill as in direct mode.
140
+ Gmail accounts: call
141
+ `POST http://localhost:8321/api/integrations/gmail/exec` with a
142
+ natural-language `task` (e.g. "Search Gmail for the 10 most
143
+ recent inbox messages, return from / subject / snippet / ts") and
144
+ a small `outputSchema`. The cross-backend `mail` skill variant
145
+ (`SKILL.delegated.<session-backend>.md`, materialized for this
146
+ session) carries the worked schema templates. Do NOT call
147
+ `/api/mail/:gmail-account/*` (returns 410), and do NOT fall back
148
+ to your own backend's native Gmail MCP tools — that connector
149
+ reads a different account than the user's delegated one.
150
+ <!-- /mode:delegated-cross:gmail -->
151
+ <!-- mode:disabled:gmail -->
152
+ Gmail is disabled — skip Gmail accounts entirely. Continue with
153
+ the remaining accounts (iCloud / Outlook / Yahoo / IMAP) via the
154
+ `mail` skill.
155
+ <!-- /mode:disabled:gmail -->
156
+ - DMs: covered by `<recent_dm_messages>` already
157
+ - Calendar updates: events in today→+7d window with updated_at
158
+ >= today 04:00
159
+ - Pending observations: `GET /api/observations?pending=true&actor=user`
160
+ 4. **At-risk items** — schedule conflicts, missing prep for known
161
+ events, unanswered RSVPs. Derive by cross-referencing 1+2+3.
162
+
163
+ ### Output structure (omit empty sections entirely)
164
+
165
+ Plain text. No markdown headers — most messaging platforms strip
166
+ them. Section labels are simple `Label:` lines. Order is fixed:
167
+
168
+ ```
169
+ <persona greeting line> (Variant A only)
170
+ <persona bridge line> (Variant B only)
171
+
172
+ Schedule:
173
+ - HH:MM title
174
+
175
+ Tasks:
176
+ - [ ] item
177
+
178
+ Overnight:
179
+ - (mail) summary
180
+ - (calendar) summary
181
+ - (dm) summary
182
+
183
+ At-risk:
184
+ - conflict / prep gap
185
+
186
+ <persona closer — one sentence calibrated to today's shape>
187
+ ```
188
+
189
+ ### Bridge-line rules (Variant B, non-negotiable)
190
+
191
+ - NEVER greet ("morning", "good morning", or any locale equivalent).
192
+ The user is awake and conversing; greeting them is unnatural.
193
+ - Acknowledge the interruption ("sorry to break in", "mid-thought
194
+ but...", or persona-equivalent).
195
+ - Reference the conversation topic if extractable from the recent
196
+ messages. Adds significant naturalness.
197
+ - State the trigger briefly ("it's 9", "9 o'clock came up").
198
+ - Exactly one sentence, in persona voice.
199
+
200
+ Structural examples (TONE FROM PERSONA, not from these — these are
201
+ casual English; if your persona is formal or speaks a different
202
+ language, adapt accordingly):
203
+
204
+ - "Sorry, mid-thought but it's 9 — let me drop today's plan first
205
+ then we'll come back to <topic>."
206
+ - "Quick break: it's 9, here's today's plan, then back to <topic>."
207
+ - "9 o'clock — let me share today's shape, then we keep going on
208
+ <topic>."
209
+
210
+ ### Closer rules
211
+
212
+ Variant A — orienting note about today's shape (calibrate to actual
213
+ day, never generic):
214
+
215
+ - "Three meetings today — leave space between them or the afternoon
216
+ will be tight."
217
+ - "Open day — good window for the A draft."
218
+ - "Travel day — pack the charger and a book before you head out."
219
+
220
+ Variant B — hand the floor back to the conversation:
221
+
222
+ - "Back to <topic>?"
223
+ - "Now, where were we on <topic>?"
224
+ - "That's the shape — let's pick up <topic>."
225
+
226
+ ### Closer rules — forbidden across both variants
227
+
228
+ - Empty cheerleading ("have a great day", "good luck", "you got
229
+ this") — zero information, persona-disrespecting.
230
+ - Generic openers / closers ("here's your day", "today you have N
231
+ items") — readback patterns the user already knows.
232
+ - Saccharine padding, gratuitous emoji, exclamation chains.
233
+
234
+ ### Empty-day fallback
235
+
236
+ When Schedule, Tasks, Overnight, At-risk are ALL empty:
237
+
238
+ Variant A — asleep:
239
+ ```
240
+ <persona greeting>
241
+
242
+ Today is open — looks like a quiet one. <persona-voice "take it easy"
243
+ closer>
244
+ ```
245
+
246
+ Variant B — active:
247
+ ```
248
+ <persona bridge>
249
+
250
+ No schedule, no tasks queued — looks open today. <persona-voice
251
+ closer that returns to chat>
252
+ ```
253
+
254
+ Even on empty days, the briefing IS the daily greeting. Persona
255
+ voice carries the whole message.
256
+
257
+ ### Hard limits
258
+
259
+ - Maximum ~25 lines total (briefing fits one mobile screen).
260
+ - Schedule list: cap 8, append `...and N more` if over.
261
+ - Tasks list: cap 10, append `...and N more` if over.
262
+ - Overnight: cap 5 per category (mail / dm / calendar).
263
+ - No internal names ("Morning Routine", "Agent Plan",
264
+ "scheduled.dm", "today.md") in user-facing text.
265
+ - Forbidden openers across all variants: "Morning briefing —",
266
+ "Morning briefing delivered", "Here's your day".
267
+
268
+ ### Delivery channel — final text only, NOT `/api/notify`
269
+
270
+ The briefing is delivered as the final assistant turn of this
271
+ session. Do NOT call `POST /api/notify` for it — that path applies
272
+ the `notify` skill's evening wrap-up contract (silent-by-default,
273
+ priority `high`) which has the wrong semantics for a daily DM.
274
+ Compose the briefing as your final assistant turn; the daemon DMs
275
+ it automatically.
276
+
277
+ ### Bookkeeping (silent — never visible to the user)
278
+
279
+ Append one line to today.md `## Agent Log` (PATCH append,
280
+ section=agent_log) using the `today` skill:
281
+
282
+ ```
283
+ - HH:MM [dm_session] morning briefing — DM sent
284
+ ```
285
+
286
+ The user-visible final text is the briefing itself. The Agent Log
287
+ entry is internal bookkeeping.
288
+
289
+ ### Latent profile-question piggyback (optional, at most one per briefing)
290
+
291
+ The morning routine sometimes lays a `(latent)` profile-interview row
292
+ into today.md ## Agent Notes. The briefing is one of the few naturally-
293
+ occurring outgoing-DM opportunities to slip a question in without it
294
+ feeling cold. Use the **user-interview** skill's "Operation 3 — Latent
295
+ piggyback" recipe:
296
+
297
+ 1. GET `agent/profile-questions.md` ## In Progress. If no entry has
298
+ `state=latent`, skip this section entirely.
299
+ 1.5 **Slot-filled pre-check.** GET
300
+ `/api/profile-questions/slot-filled?path=<target>&section=<section?>&anchor=<anchor?>`.
301
+ If `filled: true`, resolve the row (tick Pending, remove In
302
+ Progress, append `(reconciled:opportunity)` to Answered, remove the
303
+ `Profile question (latent):` line from today.md ## Agent Notes)
304
+ and **skip the piggyback**. The slot was filled between 04:00
305
+ morning routine and the briefing fire — asking would re-ask a
306
+ known fact.
307
+ 2. Compare the briefing's main content (Schedule / Tasks / Overnight)
308
+ against the latent question's domain. Examples of natural fits:
309
+ - day full of work meetings + latent `employer_role` / `tech_stack` →
310
+ fit
311
+ - quiet personal day + latent `hobbies` / `location` → fit
312
+ - day full of personal items + latent `family` → fit
313
+ 3. If the fit is real, weave ONE question into the briefing's closer
314
+ line (Variant A) or bridge-out line (Variant B). NO separate
315
+ paragraph. NO "by the way", NO meta-prefix. The question reads as a
316
+ natural side comment at the end.
317
+ 4. After composing (final text ready), PATCH the In Progress entry to
318
+ `state=asked :: asked_at=<HH:MM>`. Update the today.md ## Agent Notes
319
+ parenthetical from `(latent)` to `(asked HH:MM)`.
320
+
321
+ If no fit, leave the latent entry untouched. The DM-handler opportunity
322
+ check (Operation 2) and the eventual evening-sweep fallback (Operation
323
+ 5B) will handle it later.
324
+
325
+ The piggyback question DOES NOT get its own briefing-section. Hard limit
326
+ above ("Maximum ~25 lines total") still binds — the question lives
327
+ inside the closer line.
328
+
329
+ ---
330
+
331
+ ## Profile interview
332
+
333
+ Triggered by `{event_data[task]}` starting with `profile_interview:<id>
334
+ — <ask-hint>`. This is the **fallback** path — the morning routine
335
+ normally just lays the row latent and waits for an opportunity in DM /
336
+ briefing. The evening sweep promotes a row to a scheduled DM only after
337
+ 3 days of no opportunity AND the user has been actively DMing.
338
+
339
+ Follow the **user-interview** skill's "Operation 6 — Fallback DM"
340
+ recipe:
341
+
342
+ ### Step 1 — Fire-time abort (Layer 3)
343
+
344
+ GET `agent/profile-questions.md` and the row's `<target_path>`. Call:
345
+
346
+ ```bash
347
+ curl -s "http://localhost:8321/api/profile-questions/slot-filled?path=<target>&section=<section?>&anchor=<anchor?>"
348
+ ```
349
+
350
+ If `filled: true` OR the matching ## Pending row is no longer `[ ]`:
351
+
352
+ 1. Tick the Pending row to `[x]` if still `[ ]` (read-rebuild + replace).
353
+ 2. Append `- [x] <today> → <id> (reconciled:fire-time)` to ## Answered.
354
+ 3. Remove the In Progress entry.
355
+ 4. Append a one-line entry to today.md ## Agent Log:
356
+ `- HH:MM [profile-interview] aborted <id>: target already filled`
357
+ 5. **End the turn with NO assistant text.** `shouldNotify` is
358
+ unconditional for `scheduled.dm` — empty turn = no DM sent. Do NOT
359
+ emit a placeholder string.
360
+
361
+ ### Step 2 — Compose the question
362
+
363
+ Send a single short DM in `<settings primary_language>` whose body is
364
+ naturally phrased around `<ask-hint>`. The hint is in English; render
365
+ the actual question in the user's language. DO NOT mention the queue,
366
+ the id, the schedule, or the word "interview". Treat skipped / "later"
367
+ replies cleanly — no follow-up DM the same day.
368
+
369
+ Examples (English; adapt to the user's language and persona):
370
+
371
+ - hint: `current employer and role (or freelance / student)` →
372
+ *"Realised I never asked — what do you do for work? (or are you
373
+ freelancing / studying right now?)"*
374
+ - hint: `city / region where the user lives (affects weather, time, recommendations)` →
375
+ *"Where are you based these days? Useful for scheduling and
376
+ weather/maps stuff."*
377
+
378
+ ### Step 3 — Transition state
379
+
380
+ After the final assistant text is ready (so the daemon will dispatch
381
+ the DM), PATCH the In Progress entry to:
382
+
383
+ ```
384
+ - <id> :: state=asked :: asked_at=<current_time>
385
+ ```
386
+
387
+ Read-rebuild the In Progress section body, replace the matching line,
388
+ preserve any other entries byte-for-byte, PATCH `mode=replace`. Without
389
+ this transition, the DM-handler queue-flip (Operation 4) will see
390
+ `state=scheduled` and treat the user's reply as unrelated, leaving the
391
+ row open.
@@ -0,0 +1,141 @@
1
+ {context}
2
+
3
+ ## Scheduled Task
4
+ Origin: {event_data[source]}
5
+ Task: {event_data[task]}
6
+
7
+ <task_context>
8
+ {event_data[task_context]}
9
+ </task_context>
10
+
11
+ This session MUST close the Agent Plan loop before returning. Follow the
12
+ context skill "Agent Plan lifecycle — scheduled tasks MUST close the
13
+ loop" section for the exact read-before-write recipe and failure annotations.
14
+
15
+ ## Output contract — your final text becomes a DM
16
+
17
+ Scheduled tasks forward your final assistant text to the user as a DM
18
+ (routine events do not). Anything you write at end-of-turn is a chat
19
+ message the user reads — plan the closing turn accordingly.
20
+
21
+ - **Default: empty.** Bookkeeping (Agent Plan flip, Agent Log entry) is
22
+ invisible by design — end the turn with no text, no "Done" / "OK",
23
+ no recap of what you wrote to disk. If `/api/notify` already carried
24
+ the user-facing content, the final response MUST also stay empty: a
25
+ follow-up "Sent" / "Closed" line is a duplicate.
26
+ - **Non-empty only when** the task's job is to deliver a short message
27
+ AND you did not call `/api/notify`. Write the message itself, not a
28
+ meta-report about it.
29
+ - **Never name internal mechanisms** in the final text: no `today.md`,
30
+ `## Agent Plan`, `## Agent Log`, `did-not-fire`, "DM sent", "logged",
31
+ "closed the row" — those go in Agent Log only. The same rule applies
32
+ in whatever language you respond to the user; no status-word openers
33
+ ("Done", "OK", "Sent") in any language.
34
+
35
+ ### Bad — the exact noise to avoid
36
+ ```
37
+ Done.
38
+ - Sent the morning briefing as a WhatsApp notification.
39
+ - Closed the `10:00 morning briefing` row in Agent Plan as `[x]`.
40
+ - Logged `17:16 [agent_plan] morning briefing — DM sent` to Agent Log.
41
+ ```
42
+
43
+ ### Good — reminder task, no /api/notify call
44
+ ```
45
+ 14:00 design review in 15 min — Sarah, Mike, API v2 breaking changes.
46
+ ```
47
+
48
+ ## Provisional roadmap reminder contract
49
+
50
+ If `{event_data[task]}` or `<task_context>` contains
51
+ `[provisional ...]`, the roadmap item came from a Long-term Plans
52
+ review and is not yet a confirmed instruction. User-facing text must
53
+ ask for confirmation before treating the plan as definite.
54
+
55
+ - Good: `Assuming you're going to LA next month, OK to start ESTA prep?`
56
+ - Bad: `Start the ESTA application today.`
57
+
58
+ Keep the message short, use the user's preferred language at runtime,
59
+ and preserve the uncertainty unless the task context includes a later
60
+ confirmation.
61
+
62
+ > **DM-tone scheduled tasks live elsewhere.** Morning briefing,
63
+ > evening summary, and any other session that should run under the
64
+ > conversational profile and deliver as a DM flow through
65
+ > `scheduled.dm.md` (event type `scheduled.dm`, task_type
66
+ > `dm_session`). This file is for non-DM-tone scheduled work only.
67
+
68
+ ### Step 1: Locate the originating Agent Plan row
69
+ 1. GET /api/context/today. Scan ## Agent Plan for a row whose HH:MM and action
70
+ text match this scheduled task. If multiple rows share the HH:MM, prefer the
71
+ one whose trigger (→DM / →notify / ...) matches the task's kind.
72
+ 2. Extract the row's `[category]` tag — this determines whether the filter
73
+ applies to this action.
74
+ 3. If no matching row exists (the user hand-edited today.md or the row was
75
+ never written): skip the flip later, but still execute the action and log
76
+ to ## Agent Log as usual. Do not re-create the row.
77
+ 4. **DM-originated tasks — reconcile the roadmap `Scheduled:` entry.**
78
+ When the `Origin:` line at the top of this prompt reports `dm` (i.e.
79
+ the task was registered through `POST /api/schedule/dm` or a DM
80
+ long-horizon intent), reconcile the roadmap entry per the steps
81
+ below. **The dispatcher does NOT inject `<roadmap_write_lock_id>`
82
+ for `scheduled.task` events**, so you must acquire the lock
83
+ explicitly before the first write and release it after the final
84
+ write, or concurrent roadmap_refresh sessions will race.
85
+
86
+ Recipe:
87
+ 1. `POST /api/context/lock/roadmap` → read back the `lockId` field.
88
+ If the response is 409 (another session holds the lock), back
89
+ off 30 s and retry up to 3 times. If still held, **skip the
90
+ roadmap flip entirely** — the next refresh reconciles — and
91
+ proceed to Step 3 below so the task still executes.
92
+ 2. `GET /api/context/roadmap` and locate the matching
93
+ `### Scheduled: ... (task #<id>) <!-- id: rm-... -->` entry.
94
+ Flip only its Status line to `▶ running` via `PATCH`
95
+ `section=agent_action_plan` `mode=replace` (include
96
+ `X-Lock-Id: <lockId>`). Preserve the heading ID marker and any
97
+ `✓ completed ...` Preparation Timeline rows byte-for-byte.
98
+ Follow the **roadmap** skill for the exact entry shape.
99
+ 3. Execute the task body (the remaining steps in this prompt).
100
+ 4. After Step 4 closes the loop, PATCH the entry Status to
101
+ `✓ completed` / `✗ failed` (`X-Lock-Id: <lockId>`), then
102
+ `DELETE /api/context/lock/roadmap` with `{"lockId": "<lockId>"}`
103
+ — always release even on failure paths.
104
+
105
+ If no matching entry exists in Phase 1's GET, do not create one
106
+ here — release the lock immediately and let the next
107
+ `routine.roadmap_refresh` reconcile.
108
+
109
+ ### Step 2: Apply the day-type filter
110
+ 4. Read the day-type header on line 2 of <today>. Map the row's category
111
+ to its focus dimension (see the skill's "Category → focus-dimension
112
+ mapping"). If that focus is now `off`, this is a skip:
113
+ - Do NOT execute the action.
114
+ - Proceed to Step 4 to close the loop with outcome `skipped (focus off)`.
115
+
116
+ ### Step 3: Execute (only if not skipped)
117
+ 5. Execute the task. Use Daemon API (curl) as needed.
118
+ Use <today> for day state and <calendar_today> for live calendar events.
119
+ If the task description is unclear or lacks critical details (who, what,
120
+ when, why), do NOT guess — log `ambiguous task — skipped` to Agent Log
121
+ and proceed to Step 4 with outcome `skipped (ambiguous)`.
122
+
123
+ ### Step 4: Close the loop (MANDATORY — every path reaches here)
124
+ 6. Append one line to ## Agent Log (PATCH append, section=agent_log):
125
+ `- HH:MM [agent_plan] <action summary> — <outcome>`
126
+ Outcome taxonomy: DM sent / notify sent / check-in scheduled /
127
+ skipped (focus off) / skipped (quiet hours) / skipped (user in meeting) /
128
+ skipped (ambiguous) / failed: <reason>.
129
+ 7. If Step 1 found a matching Agent Plan row, flip it to `- [x]` via the
130
+ lifecycle recipe in the context skill (GET → edit body → PATCH
131
+ replace section=agent_plan). Annotate per the skill's outcome table:
132
+ success = no annotation, skip = `⚠ skipped: <reason>`, failure =
133
+ `⚠ failed: <reason>`. Never leave a past-HH:MM row as `[ ]`.
134
+ 8. If the PATCH returns 409 (Morning Routine lock), follow the skill's
135
+ "retry 3 times, else log deferred" guidance. Do not drop silently.
136
+
137
+ ### Step 5: Follow-up (optional)
138
+ 9. Register follow-up wake-ups if the action produced new work (schedule skill).
139
+ 10. For additional context if needed:
140
+ - GET /api/context/roadmap — long-term goals and milestones
141
+ - GET /api/context/projects/_active — active projects summary