@aitne-sh/aitne 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +195 -829
  2. package/agent-assets/agent-profiles/_safety.md +49 -17
  3. package/agent-assets/agent-profiles/profile-importer.md +1 -1
  4. package/agent-assets/agent-profiles/routine.md +4 -3
  5. package/agent-assets/docs/concepts/agent-day.md +6 -1
  6. package/agent-assets/docs/concepts/auth-health.md +10 -1
  7. package/agent-assets/docs/concepts/backends-and-tiers.md +74 -40
  8. package/agent-assets/docs/concepts/costs-and-quotas.md +25 -5
  9. package/agent-assets/docs/concepts/delegated-mode.md +147 -68
  10. package/agent-assets/docs/concepts/memory-model.md +9 -4
  11. package/agent-assets/docs/concepts/observations.md +13 -1
  12. package/agent-assets/docs/concepts/process-keys.md +20 -5
  13. package/agent-assets/docs/concepts/routines.md +38 -20
  14. package/agent-assets/docs/concepts/safety-model.md +30 -13
  15. package/agent-assets/docs/concepts/skills.md +12 -7
  16. package/agent-assets/docs/features/integrations/calendar.md +1 -1
  17. package/agent-assets/docs/features/integrations/git.md +2 -2
  18. package/agent-assets/docs/features/integrations/github.md +9 -2
  19. package/agent-assets/docs/features/integrations/mail.md +1 -1
  20. package/agent-assets/docs/features/integrations/notion.md +34 -6
  21. package/agent-assets/docs/features/integrations/obsidian.md +7 -2
  22. package/agent-assets/docs/features/lifestyle/git.md +4 -7
  23. package/agent-assets/docs/features/lifestyle/receipts.md +17 -2
  24. package/agent-assets/docs/features/lifestyle/travel-bookings.md +15 -0
  25. package/agent-assets/docs/features/lifestyle/travel-time.md +7 -1
  26. package/agent-assets/docs/features/memory-files/agent-journal.md +2 -2
  27. package/agent-assets/docs/features/memory-files/projects.md +6 -0
  28. package/agent-assets/docs/features/memory-files/roadmap.md +5 -0
  29. package/agent-assets/docs/features/memory-files/today.md +1 -0
  30. package/agent-assets/docs/features/memory-files/user-profile.md +6 -0
  31. package/agent-assets/docs/features/messaging/bang-commands.md +20 -10
  32. package/agent-assets/docs/features/messaging/discord.md +12 -1
  33. package/agent-assets/docs/features/messaging/overview.md +10 -7
  34. package/agent-assets/docs/features/messaging/slack.md +13 -1
  35. package/agent-assets/docs/features/messaging/telegram.md +7 -1
  36. package/agent-assets/docs/features/messaging/whatsapp.md +12 -1
  37. package/agent-assets/docs/features/operations/activity-and-conversations.md +2 -2
  38. package/agent-assets/docs/features/operations/approvals.md +6 -0
  39. package/agent-assets/docs/features/operations/backend-routing.md +7 -0
  40. package/agent-assets/docs/features/operations/cost-tracking.md +6 -0
  41. package/agent-assets/docs/features/operations/notifications.md +6 -0
  42. package/agent-assets/docs/features/operations/schedule-approaching.md +22 -9
  43. package/agent-assets/docs/features/routines/custom-routines.md +10 -4
  44. package/agent-assets/docs/features/routines/evening-review.md +1 -1
  45. package/agent-assets/docs/features/routines/hourly-check.md +1 -1
  46. package/agent-assets/docs/features/routines/morning-routine.md +24 -15
  47. package/agent-assets/docs/features/routines/weekly-review.md +38 -12
  48. package/agent-assets/docs/features/wiki/commands.md +11 -0
  49. package/agent-assets/docs/features/wiki/overview.md +13 -3
  50. package/agent-assets/docs/getting-started/01-what-is-this.md +32 -11
  51. package/agent-assets/docs/getting-started/02-first-steps.md +17 -4
  52. package/agent-assets/docs/getting-started/03-what-can-this-do.md +21 -11
  53. package/agent-assets/docs/getting-started/04-first-day.md +14 -0
  54. package/agent-assets/docs/glossary.md +65 -12
  55. package/agent-assets/docs/guides/add-a-custom-routine.md +12 -0
  56. package/agent-assets/docs/guides/backup-and-restore.md +16 -2
  57. package/agent-assets/docs/guides/budget-and-cost-for-wiki.md +6 -0
  58. package/agent-assets/docs/guides/build-your-wiki.md +14 -0
  59. package/agent-assets/docs/guides/change-which-model-handles-x.md +7 -0
  60. package/agent-assets/docs/guides/connect-a-new-mail-account.md +16 -0
  61. package/agent-assets/docs/guides/explore-with-trace-and-connect.md +6 -0
  62. package/agent-assets/docs/guides/import-knowledge-file.md +11 -0
  63. package/agent-assets/docs/guides/install-and-run.md +20 -4
  64. package/agent-assets/docs/guides/maintain-wiki-health.md +6 -0
  65. package/agent-assets/docs/guides/migrate-machines.md +13 -1
  66. package/agent-assets/docs/guides/multiple-wikis-for-multiple-domains.md +9 -0
  67. package/agent-assets/docs/guides/pause-the-agent.md +12 -4
  68. package/agent-assets/docs/guides/reinstall-cleanly.md +19 -4
  69. package/agent-assets/docs/guides/setup-wizard.md +20 -9
  70. package/agent-assets/docs/guides/switch-default-backend.md +10 -1
  71. package/agent-assets/docs/guides/use-an-existing-obsidian-vault.md +5 -0
  72. package/agent-assets/docs/reference/api.md +29 -1
  73. package/agent-assets/docs/reference/cli-commands.md +22 -3
  74. package/agent-assets/docs/reference/config.md +37 -5
  75. package/agent-assets/docs/reference/disallowed-tools.md +13 -0
  76. package/agent-assets/docs/reference/keyboard-shortcuts.md +13 -0
  77. package/agent-assets/docs/reference/process-keys.md +70 -20
  78. package/agent-assets/docs/reference/skills.md +27 -9
  79. package/agent-assets/docs/troubleshooting/auth-failed.md +7 -2
  80. package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +13 -1
  81. package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +10 -0
  82. package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +11 -0
  83. package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +9 -4
  84. package/agent-assets/docs/troubleshooting/observation-not-detected.md +12 -0
  85. package/agent-assets/docs/troubleshooting/quota-exhausted.md +7 -1
  86. package/agent-assets/docs/troubleshooting/wiki-ingest-full-blocked.md +5 -0
  87. package/agent-assets/docs/troubleshooting/wiki-write-failed.md +5 -0
  88. package/agent-assets/optimizer-skills/drift-analysis/SKILL.md +1 -1
  89. package/agent-assets/optimizer-skills/skill-curation/SKILL.md +2 -2
  90. package/agent-assets/skills/agent-actions/SKILL.md +122 -0
  91. package/agent-assets/skills/attach/SKILL.md +1 -2
  92. package/agent-assets/skills/context/SKILL.md +36 -454
  93. package/agent-assets/skills/context/references/api.md +220 -0
  94. package/agent-assets/skills/context/references/required-frontmatter.md +73 -0
  95. package/agent-assets/skills/context/references/snapshot-files.md +103 -0
  96. package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +1 -1
  97. package/agent-assets/skills/docs-search/SKILL.md +13 -13
  98. package/agent-assets/skills/external-services/SKILL.delegated.claude.md +5 -7
  99. package/agent-assets/skills/external-services/SKILL.delegated.codex.md +5 -7
  100. package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +5 -7
  101. package/agent-assets/skills/external-services/SKILL.md +6 -259
  102. package/agent-assets/skills/external-services/SKILL.native.claude.md +1 -2
  103. package/agent-assets/skills/external-services/SKILL.native.codex.md +1 -2
  104. package/agent-assets/skills/external-services/SKILL.native.gemini.md +1 -2
  105. package/agent-assets/skills/external-services/references/calendar-apple.md +97 -0
  106. package/agent-assets/skills/external-services/references/calendar-google.md +72 -0
  107. package/agent-assets/skills/external-services/references/calendar-outlook.md +36 -0
  108. package/agent-assets/skills/external-services/references/github.md +17 -0
  109. package/agent-assets/skills/external-services/references/obsidian.md +49 -0
  110. package/agent-assets/skills/external-services/references/skills-crud.md +27 -0
  111. package/agent-assets/skills/gmail-lifestyle/SKILL.md +224 -0
  112. package/agent-assets/skills/gmail-lifestyle/references/receipts-api.md +93 -0
  113. package/agent-assets/skills/gmail-lifestyle/references/travel-bookings-api.md +75 -0
  114. package/agent-assets/skills/gmail-lifestyle/references/travel-time-api.md +59 -0
  115. package/agent-assets/skills/mail/SKILL.delegated.claude.md +1 -1
  116. package/agent-assets/skills/mail/SKILL.delegated.codex.md +1 -1
  117. package/agent-assets/skills/mail/SKILL.delegated.gemini.md +1 -1
  118. package/agent-assets/skills/mail/SKILL.md +9 -114
  119. package/agent-assets/skills/mail/SKILL.native.claude.md +1 -1
  120. package/agent-assets/skills/mail/SKILL.native.codex.md +1 -1
  121. package/agent-assets/skills/mail/SKILL.native.gemini.md +1 -1
  122. package/agent-assets/skills/mail/references/api.md +108 -0
  123. package/agent-assets/skills/mail/references/examples.md +70 -0
  124. package/agent-assets/skills/mail/references/providers.md +8 -8
  125. package/agent-assets/skills/managed-tasks/SKILL.md +472 -0
  126. package/agent-assets/skills/managed-tasks/references/errors.md +70 -0
  127. package/agent-assets/skills/managed-tasks/references/output-path.md +75 -0
  128. package/agent-assets/skills/managed-tasks/references/recurrence-rule.md +86 -0
  129. package/agent-assets/skills/management-policy/SKILL.md +33 -105
  130. package/agent-assets/skills/management-policy/references/policy-workflow.md +101 -0
  131. package/agent-assets/skills/notify/SKILL.md +6 -78
  132. package/agent-assets/skills/notify/references/priority.md +60 -0
  133. package/agent-assets/skills/notion/SKILL.delegated.claude.md +1 -1
  134. package/agent-assets/skills/notion/SKILL.delegated.codex.md +1 -1
  135. package/agent-assets/skills/notion/SKILL.delegated.gemini.md +1 -1
  136. package/agent-assets/skills/notion/SKILL.md +6 -10
  137. package/agent-assets/skills/notion/SKILL.native.claude.md +1 -2
  138. package/agent-assets/skills/notion/SKILL.native.codex.md +1 -2
  139. package/agent-assets/skills/notion/SKILL.native.gemini.md +1 -2
  140. package/agent-assets/skills/observations/SKILL.md +1 -6
  141. package/agent-assets/skills/project-doc/SKILL.md +1 -5
  142. package/agent-assets/skills/reading/SKILL.md +2 -2
  143. package/agent-assets/skills/roadmap/SKILL.md +37 -135
  144. package/agent-assets/skills/roadmap/references/api.md +100 -0
  145. package/agent-assets/skills/roadmap/references/cross-check.md +73 -0
  146. package/agent-assets/skills/roadmap/references/migration.md +56 -0
  147. package/agent-assets/skills/roadmap/references/preparation-timeline.md +2 -2
  148. package/agent-assets/skills/schedule/SKILL.md +52 -88
  149. package/agent-assets/skills/schedule/references/batch.md +93 -0
  150. package/agent-assets/skills/schedule/references/errors.md +214 -0
  151. package/agent-assets/skills/schedule/references/model-selection.md +96 -0
  152. package/agent-assets/skills/schedule/references/recurrence-rule.md +86 -0
  153. package/agent-assets/skills/schedule/references/recurring.md +185 -0
  154. package/agent-assets/skills/scheduled-managed-task/SKILL.md +13 -15
  155. package/agent-assets/skills/today/SKILL.md +27 -57
  156. package/agent-assets/skills/today/references/agent-plan-lifecycle.md +113 -0
  157. package/agent-assets/skills/user-interview/SKILL.md +12 -59
  158. package/agent-assets/skills/user-interview/references/op-briefing.md +51 -0
  159. package/agent-assets/skills/user-interview/references/op-morning.md +59 -0
  160. package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +1 -1
  161. package/agent-assets/skills/user-profile/SKILL.md +43 -63
  162. package/agent-assets/skills/user-profile/references/character-preferences.md +83 -0
  163. package/agent-assets/skills/user-profile/seeds/topic-files.seed.json +28 -0
  164. package/agent-assets/skills/wiki/wiki-ask/SKILL.md +0 -1
  165. package/agent-assets/skills/wiki/wiki-compile/SKILL.md +0 -1
  166. package/agent-assets/skills/wiki/wiki-connect/SKILL.md +0 -1
  167. package/agent-assets/skills/wiki/wiki-graduate/SKILL.md +0 -1
  168. package/agent-assets/skills/wiki/wiki-ingest/SKILL.md +0 -1
  169. package/agent-assets/skills/wiki/wiki-lint/SKILL.md +0 -1
  170. package/agent-assets/skills/wiki/wiki-trace/SKILL.md +0 -1
  171. package/agent-assets/skills/wiki/wiki-vault-rules/SKILL.md +0 -1
  172. package/agent-assets/system-prompts/routine-fetch-window.md +68 -0
  173. package/agent-assets/system-prompts/skill-index-instruction.md +26 -0
  174. package/agent-assets/task-flows/_partials/calendar-acquire.google_calendar.md +18 -11
  175. package/agent-assets/task-flows/_partials/calendar-acquire.outlook_calendar.md +16 -9
  176. package/agent-assets/task-flows/_partials/capture-user-info.md +24 -0
  177. package/agent-assets/task-flows/_partials/confirm-subflow.md +68 -0
  178. package/agent-assets/task-flows/_partials/dm-intent.long-horizon.md +35 -0
  179. package/agent-assets/task-flows/_partials/dm-intent.project.md +391 -0
  180. package/agent-assets/task-flows/_partials/mail-acquire.gmail.md +20 -11
  181. package/agent-assets/task-flows/_partials/mail-acquire.outlook_mail.md +17 -9
  182. package/agent-assets/task-flows/_partials/notion-acquire.notion.md +18 -12
  183. package/agent-assets/task-flows/knowledge.import.md +1 -1
  184. package/agent-assets/task-flows/message.received.dm.md +13 -15
  185. package/agent-assets/task-flows/message.received.dm_first.md +10 -14
  186. package/agent-assets/task-flows/routine.custom.md +3 -1
  187. package/agent-assets/task-flows/routine.evening_review.md +39 -163
  188. package/agent-assets/task-flows/routine.fetch_window.md +17 -12
  189. package/agent-assets/task-flows/routine.hourly_check.md +16 -8
  190. package/agent-assets/task-flows/routine.hourly_check.triage.md +1 -1
  191. package/agent-assets/task-flows/routine.monthly_review.md +46 -4
  192. package/agent-assets/task-flows/routine.morning_routine_journal.md +113 -0
  193. package/agent-assets/task-flows/routine.morning_routine_today.md +673 -0
  194. package/agent-assets/task-flows/routine.roadmap_refresh.md +60 -15
  195. package/agent-assets/task-flows/routine.user_profile_sweep.md +9 -10
  196. package/agent-assets/task-flows/routine.weekly_review.md +285 -70
  197. package/agent-assets/task-flows/scheduled.dm.md +8 -8
  198. package/agent-assets/task-flows/scheduled.task.md +5 -5
  199. package/agent-assets/task-flows/setup.initial.md +165 -245
  200. package/agent-assets/task-flows/wiki.ingest_url.md +1 -1
  201. package/agent-assets/templates/_manifest.json +7 -7
  202. package/agent-assets/templates/dossiers/_index.md +1 -1
  203. package/agent-assets/templates/rules/journal-format.md +145 -38
  204. package/agent-assets/templates/user/expertise.md +4 -2
  205. package/agent-assets/templates/user/goals.md +4 -2
  206. package/agent-assets/templates/user/people.md +8 -2
  207. package/agent-assets/templates/user/personal.md +4 -2
  208. package/agent-assets/templates/user/work.md +4 -2
  209. package/bin/aitne.mjs +8 -1
  210. package/package.json +4 -4
  211. package/scripts/commands/doctor.mjs +52 -0
  212. package/scripts/commands/run-now.mjs +202 -0
  213. package/scripts/commands/verify.mjs +264 -0
  214. package/agent-assets/docs/features/routines/monthly-review.md +0 -65
  215. package/agent-assets/skills/management-task-modify/SKILL.md +0 -203
  216. package/agent-assets/skills/management-task-register/SKILL.md +0 -330
  217. package/agent-assets/skills/management-task-stop/SKILL.md +0 -166
  218. package/agent-assets/skills/receipts/SKILL.md +0 -134
  219. package/agent-assets/skills/travel/SKILL.md +0 -132
  220. package/agent-assets/skills/travel-time/SKILL.md +0 -158
  221. package/agent-assets/task-flows/routine.morning_routine.md +0 -322
  222. package/agent-assets/task-flows/routine.morning_routine_initial.md +0 -204
@@ -6,18 +6,22 @@ id: delegated-mode
6
6
  aliases:
7
7
  - delegated
8
8
  - direct mode
9
+ - native mode
9
10
  - same-backend
10
11
  - cross-backend
11
12
  - integration delegation
12
13
  category: concepts
13
14
  summary: |
14
- Each integration (Gmail, Google Calendar, …) runs in one of three
15
- modes: direct (the daemon holds OAuth credentials), delegated (the
16
- agent's backend connector holds them), or disabled. Under delegation,
17
- the agent reaches the integration through one of two paths depending
18
- on whether its DM session backend matches the connector's owner —
19
- same-backend (native MCP, no daemon involved) or cross-backend
20
- (`/api/integrations/:key/invoke` proxy).
15
+ Each integration (Gmail, Google Calendar, …) runs in one of four
16
+ modes: direct (the daemon holds OAuth credentials and polls),
17
+ delegated (the agent's backend connector holds them; the daemon syncs
18
+ on opt-in cadences), native (the main backend's MCP connector reaches
19
+ the integration on-demand; no daemon polling and no daemon-side
20
+ proxy), or disabled. Under `delegated`, the agent reaches the
21
+ integration through one of two paths depending on whether its DM
22
+ session backend matches the connector's owner — same-backend (native
23
+ MCP, no daemon involved) or cross-backend
24
+ (`/api/integrations/:key/exec` task-mode proxy).
21
25
  section: integrations
22
26
  tags:
23
27
  - core
@@ -32,16 +36,18 @@ ask_examples:
32
36
  - Why don't I see a SKILL.md for Gmail in my Codex session?
33
37
  locale: en-US
34
38
  created: 2026-04-26
35
- updated: 2026-04-26
39
+ updated: 2026-05-17
36
40
  keywords:
37
41
  - delegated mode
38
42
  - direct mode
43
+ - native mode
39
44
  - same-backend
40
45
  - cross-backend
41
46
  - integrations.md
42
47
  - delegatedBackend
48
+ - nativeBackend
43
49
  - SKILL.delegated
44
- - invoke endpoint
50
+ - exec endpoint
45
51
  related:
46
52
  - concepts/safety-model
47
53
  - concepts/skills
@@ -58,12 +64,13 @@ config_keys:
58
64
 
59
65
  ## TL;DR
60
66
 
61
- Each integration is in one of three modes:
67
+ Each integration is in one of four modes:
62
68
 
63
69
  | Mode | Who holds credentials | What the agent calls |
64
70
  |---|---|---|
65
71
  | `direct` | Daemon (OAuth in macOS Keychain) | `curl /api/mail/*` / `curl /api/calendar/*` |
66
- | `delegated` | The agent's backend connector (claude.ai / ChatGPT / Google) | Native MCP tools or the `/api/integrations/:key/invoke` proxy |
72
+ | `delegated` | The agent's backend connector (claude.ai / ChatGPT / Google) | Native MCP tools (same-backend) or the `/api/integrations/:key/exec` task-mode proxy (cross-backend) |
73
+ | `native` | The main backend's connector (no daemon credentials, no daemon poller) | Native MCP tools on the main backend; observations are POSTed to `/api/observations/batch` for the routine pre-pass |
67
74
  | `disabled` | Nobody | Nothing — the integration is off |
68
75
 
69
76
  Under `delegated`, two sub-cases exist depending on whether the DM session's
@@ -72,9 +79,24 @@ backend is the same as the integration's `delegatedBackend`:
72
79
  - **Same-backend** — DM agent calls the connector's MCP tool directly.
73
80
  The daemon is not involved. No skill body is materialized.
74
81
  - **Cross-backend** — DM agent calls
75
- `POST /api/integrations/:key/invoke {tool, args}`. The daemon spawns
76
- a one-shot subprocess of `delegatedBackend`, runs the tool there,
77
- and returns the raw result.
82
+ `POST /api/integrations/:key/exec` in **task mode** with body
83
+ `{task: "<natural-language description>", outputSchema, maxToolCalls,
84
+ cacheable}`. The daemon spawns a one-shot subprocess of
85
+ `delegatedBackend`, the task-mode planner picks the appropriate tool
86
+ from the integration's registered `capabilityTools`, runs it, and
87
+ returns a structured result conforming to `outputSchema`. The legacy
88
+ RPC route `POST /api/integrations/:key/invoke {tool, args}` was
89
+ retired 2026-05-01 — cross-backend tool-name divergence (Claude
90
+ `search_threads` vs Codex `search_emails` vs Gemini `search`) made
91
+ the RPC shape brittle. See `docs/design/17-delegated-mode-v2.md` §4.2 for the
92
+ retirement rationale and `docs/design/appendices/routine-data-acquisition.md` §8.1
93
+ for the task-mode body shape.
94
+
95
+ `native` has no sub-cases. The integration's `nativeBackend` must equal
96
+ the main DM backend — `BackendRouter.setMainBackend` cascades unmatched
97
+ `native` rows to `disabled`. From the agent's call-site view, `native`
98
+ is indistinguishable from `delegated` same-backend (both are in-session
99
+ MCP); the difference is who polls (no one, for `native`).
78
100
 
79
101
  ## Why This Concept Exists
80
102
 
@@ -97,23 +119,40 @@ that case the daemon spawns the other backend per call.
97
119
  - **`direct`** — daemon holds the credentials (OAuth refresh token in
98
120
  macOS Keychain, app-password for Yahoo / iCloud, …). Pollers run.
99
121
  Full feature set. The operator did the vendor-console setup.
100
- - **`delegated`** — daemon holds nothing for this integration. Pollers
101
- are stopped. The connector running inside the agent's backend (or a
102
- spawned-on-demand backend) does the work.
122
+ - **`delegated`** — daemon holds nothing for this integration. The
123
+ daemon's `delegated-sync-worker` polls on opt-in cadences via the
124
+ delegated backend's connector. Per-DM-turn calls reach the connector
125
+ through the agent's backend (same-backend) or via the daemon's
126
+ `/exec` proxy (cross-backend).
127
+ - **`native`** — daemon holds nothing AND runs no poller. The main
128
+ backend's MCP connector reaches the integration on-demand within the
129
+ agent's own turn (DM, hourly_check, routine pre-pass). The agent
130
+ POSTs results to `/api/observations/batch` so the rest of the
131
+ observation pipeline (summarizer, hourly check) still operates. See
132
+ `docs/design/appendices/native-integration-mode.md` for the full
133
+ spec, including the per-key `runtime_state.integration_flip_lock:<key>`
134
+ drain protocol.
103
135
  - **`disabled`** — nobody holds credentials. The integration is off.
104
136
  - **`delegatedBackend`** — when delegated, which backend's connector
105
137
  serves the calls. `claude` / `codex` / `gemini`. Editable per
106
138
  integration in **Connections → Gmail / Google Calendar**.
107
- - **Same-backend**DM session backend matches `delegatedBackend`. The
108
- daemon is not in the loop; the agent calls native MCP directly. No
109
- skill body is materialized for the integration's slug — the connector
110
- describes its own tools at session-init.
111
- - **Cross-backend** — DM session backend differs from `delegatedBackend`.
112
- The agent reaches the integration through
113
- `POST /api/integrations/:key/invoke` and the daemon spawns
114
- `delegatedBackend` as a subprocess for each call. A
115
- `SKILL.delegated.<sessionBackend>.md` file is materialized into the
116
- session workdir.
139
+ - **`nativeBackend`**when native, which backend's connector is
140
+ expected. Must equal the main DM backend; changing the main backend
141
+ cascades unmatched `native` rows to `disabled` (the cascade is
142
+ triggered by `BackendRouter.setMainBackend` /
143
+ `PUT /api/backends/main`).
144
+ - **Same-backend** DM session backend matches `delegatedBackend` /
145
+ `nativeBackend`. The daemon is not in the loop; the agent calls
146
+ native MCP directly. No skill body is materialized for the
147
+ integration's slug the connector describes its own tools at
148
+ session-init.
149
+ - **Cross-backend** — DM session backend differs from
150
+ `delegatedBackend`. Cross-backend exists only for `delegated` — never
151
+ for `native`, which is locked to the main DM backend. The agent
152
+ reaches the integration through `POST /api/integrations/:key/exec`
153
+ in task mode and the daemon spawns `delegatedBackend` as a
154
+ subprocess for each call. A `SKILL.delegated.<sessionBackend>.md`
155
+ file is materialized into the session workdir.
117
156
  - **`integrations.md`** — daemon-rendered snapshot of every
118
157
  integration's mode at `~/.personal-agent/integrations.md`. The agent
119
158
  reads it to know which path to take.
@@ -123,7 +162,8 @@ that case the daemon spawns the other backend per call.
123
162
  | You want… | Pick |
124
163
  |---|---|
125
164
  | Full feature set (send mail, attachments, full search) and you're comfortable with one-time vendor-console setup | **direct** |
126
- | Zero setup tax, willing to live with whatever the connector exposes (Claude Gmail = draft-only; Codex Gmail = full) | **delegated** |
165
+ | Zero setup tax, with opt-in background polling on the delegated backend's connector cadence | **delegated** |
166
+ | Zero setup tax, on-demand only — main backend reaches the integration when the agent turns up a reason to look (no daemon polling, no proxy spawn) | **native** |
127
167
  | The integration off entirely | **disabled** |
128
168
 
129
169
  When you pick `delegated`, also pick `delegatedBackend`:
@@ -136,28 +176,40 @@ When you pick `delegated`, also pick `delegatedBackend`:
136
176
  connector you want (e.g. Codex's full Gmail) but a different backend
137
177
  is your preferred DM driver (e.g. Claude).
138
178
 
179
+ When you pick `native`, `nativeBackend` is fixed to your main DM
180
+ backend. Flipping the main backend re-targets every `native` row; rows
181
+ whose new `nativeBackend` has no descriptor connector for the
182
+ integration (e.g. `gmail` native on a backend that doesn't ship a Gmail
183
+ connector) cascade to `disabled` and the operator gets a DM.
184
+
139
185
  ## Concrete Examples
140
186
 
141
187
  | Setup | What happens on a Gmail search |
142
188
  |---|---|
143
189
  | Gmail direct | Agent: `curl /api/mail/<acct>/messages?q=...` → daemon hits Gmail API with stored OAuth |
144
190
  | Gmail delegated to Codex × Codex DM (same-backend) | Agent: `mcp__codex_apps__gmail._search_emails(...)` → Codex's connector hits Gmail. No daemon involvement. No skill file. |
145
- | Gmail delegated to Codex × Claude DM (cross-backend) | Agent: `curl -X POST /api/integrations/gmail/invoke -d '{"tool":"search_emails","args":{...}}'` → daemon spawns Codex subprocess with `proxy.md` profile → Codex calls `mcp__codex_apps__gmail._search_emails` → returns raw result through daemon |
191
+ | Gmail delegated to Codex × Claude DM (cross-backend) | Agent: `curl -X POST /api/integrations/gmail/exec -d '{"task":"Search Gmail for newer_than:1d, return id/subject/from/snippet/date for each message","outputSchema":{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","items":{...}}}},"maxToolCalls":3,"cacheable":true}'` → daemon spawns Codex subprocess with `proxy.md` profile → task-mode planner picks `_search_emails` from the registered `capabilityTools` → returns structured `{messages:[…]}` conforming to `outputSchema` |
192
+ | Gmail native on Codex DM | Agent: `mcp__codex_apps__gmail._search_emails(...)` (identical to delegated same-backend) → Codex's connector hits Gmail. No daemon involvement. Daemon poller is OFF; the routine pre-pass POSTs results to `/api/observations/batch`. |
146
193
 
147
194
  ## How the Skill File Resolves
148
195
 
149
- `selectSkillVariantFile(skillSlug, sessionBackend, integrations)` returns
150
- one of three values:
151
-
152
- - `"SKILL.md"` — direct mode, or skill not gated by any integration.
153
- - `null` — every touched integration is delegated and same-backend.
154
- No skill is materialized (the connector self-describes).
155
- - `"SKILL.delegated.<sessionBackend>.md"` at least one touched
156
- integration is delegated cross-backend; one body per session backend
157
- covers every `delegatedBackend` because the API is uniform.
158
-
159
- Mixed states (some same-backend, some cross-backend) fall back to
160
- `SKILL.md`.
196
+ `selectSkillVariantFile(skillSlug, sessionBackend, integrations)`
197
+ returns one of four values, picked by tie-break order
198
+ (`docs/design/appendices/native-integration-mode.md` §5.4.1):
199
+
200
+ 1. `"SKILL.delegated.<sessionBackend>.md"` — at least one touched
201
+ integration is delegated cross-backend. The body documents the
202
+ `/exec` task-mode proxy and any native siblings inline (§7.4
203
+ mixed-mode prompts).
204
+ 2. `"SKILL.native.<sessionBackend>.md"` at least one touched
205
+ integration is `native` (and no cross-backend wins above). Native
206
+ is always explicit-skill-required (§7.5 never drops to `null`).
207
+ 3. `null` — every touched integration is delegated same-backend AND
208
+ each declares the skill in its descriptor's
209
+ `sameBackendDropsSkillBody`. The connector self-describes; no body
210
+ is materialized.
211
+ 4. `"SKILL.md"` — direct mode, mixed states, or skill not gated by any
212
+ integration.
161
213
 
162
214
  ## Where You See It in the Dashboard
163
215
 
@@ -166,52 +218,79 @@ Mixed states (some same-backend, some cross-backend) fall back to
166
218
  - **Settings → Models** — main backend switch. Flipping main flips the
167
219
  same-/cross-backend status of every delegated integration and
168
220
  re-materializes the active DM workdir.
169
- - **Setup wizard** — first-run integration mode picker; delegated mode
170
- is gated on a live probe that confirms the connector reports every
171
- `requiredCapability` for the integration.
221
+ - **Setup wizard** — first-run integration mode picker; both
222
+ `delegated` and `native` are gated on a **live probe** (§4.12.2)
223
+ that confirms three things before the mode is written to
224
+ `integrations.md`: the backend binary is resolvable, backend auth
225
+ is valid, and the connector reports every `requiredCapability` the
226
+ descriptor demands. Cached probe rows are invalidated on mode
227
+ change. `POST /api/integrations/:key/probe` is the chokepoint.
172
228
 
173
229
  ## How `integrations.md` Reflects This
174
230
 
175
231
  `~/.personal-agent/integrations.md` is the operator-readable snapshot the
176
- agent consults at session-init. Example:
232
+ agent consults at session-init. It is rendered as a Markdown table:
177
233
 
178
234
  ```markdown
179
- ## gmail
180
- mode: delegated
181
- delegatedBackend: codex
182
- deniedTools:
183
- - send_email
184
- - delete_emails
185
-
186
- ## google_calendar
187
- mode: delegated
188
- delegatedBackend: claude
189
- deniedTools:
190
- - delete_event
235
+ ## Current state
236
+
237
+ | Integration | Mode | Backend | Sub-tier | Last changed |
238
+ |---|---|---|---|---|
239
+ | gmail | delegated | codex | full-auto | 2026-05-15T07:15:32.911Z |
240
+ | google_calendar | native | codex | — | 2026-05-15T07:15:38.605Z |
241
+ | notion | disabled | — | — | 2026-05-15T07:14:56Z |
191
242
  ```
192
243
 
244
+ The "Backend" column surfaces whichever binding is active for the row —
245
+ `delegatedBackend` for `delegated`, `nativeBackend` for `native`. For
246
+ `direct` and `disabled` rows it is `—`. The "Sub-tier" column annotates
247
+ delegated Gmail rows (`draft-only` for Claude, `full-auto` for Codex)
248
+ and is `—` for everything else. The file also includes the per-backend
249
+ connector support matrix and the `deniedTools` block; both are rendered
250
+ by `renderManagementMd` (`packages/daemon/src/core/management-md.ts`).
251
+
193
252
  A daemon-side write chokepoint guarantees the file matches DB state. The
194
253
  fs-watcher reverts hand-edits that fail validation and DMs the operator.
195
254
 
196
255
  ## Failure Modes
197
256
 
198
257
  - **Cross-backend, connector signed out on `delegatedBackend`** — the
199
- invoke endpoint returns `502 auth_error`. Skill prose tells the agent
200
- to surface this as "re-sign-in to the connector."
201
- - **Same-backend, connector not signed in on the DM backend** — the
202
- agent has no Gmail tools at all. The setup wizard's pre-commit live
203
- probe is the primary defense; if the operator signs out
258
+ `/exec` endpoint returns `502 auth_error`. Skill prose tells the
259
+ agent to surface this as "re-sign-in to the connector."
260
+ - **Cross-backend, daemon's delegated-task queue saturated** — `/exec`
261
+ returns `503 delegated_proxy_busy`. The skill body advises a 3–5s
262
+ backoff with one retry.
263
+ - **Cross-backend, fully-denied surface** — when every tool in the
264
+ integration's `capabilityTools` is in `deniedTools`, the task-mode
265
+ planner has nothing to pick. `/exec` short-circuits with
266
+ `errorClass: "denied_tool"` before spawning a subprocess.
267
+ - **Same-backend or native, connector not signed in on the DM backend**
268
+ — the agent has no Gmail tools at all. The setup wizard's pre-commit
269
+ live probe is the primary defense; if the operator signs out
204
270
  post-setup, the agent will report "no Gmail tools available" until
205
271
  re-signed.
206
- - **Mode flip mid-call** — the invoke endpoint returns
207
- `409 precondition`; agent re-reads `integrations.md` and replans.
272
+ - **Mode flip mid-call** — `/exec` returns `409 precondition`; agent
273
+ re-reads `integrations.md` and replans. `native` rows also flip-lock
274
+ via the per-key `runtime_state.integration_flip_lock:<key>` row —
275
+ observations posted during the drain receive
276
+ `results[*].status = "flip_locked"`; the partial / agent profile
277
+ records the row in `errors[]` and the next routine tick reaps it.
208
278
 
209
279
  ## Related
210
280
 
211
281
  - [Safety Model](safety-model.md) — how the deny list (the primary
212
282
  defense in delegated mode) works.
213
283
  - [Skills](skills.md) — how `selectSkillVariantFile` picks the body.
214
- - Integration Delegation Framework (design) — `docs/design/14-integration-delegation.md`,
215
- the load-bearing spec.
216
- - Delegated Mode v2 (design) `DELEGATED-MODE-V2-DESIGN.md`, the
217
- canonical model for the current behavior.
284
+ - Integration Delegation Framework (design) —
285
+ `docs/design/14-integration-delegation.md`, the load-bearing spec
286
+ (§14.14 covers the four modes and their cascade rules).
287
+ - Delegated Mode v2 (design) — `docs/design/17-delegated-mode-v2.md` §4.2, the
288
+ `/exec` task-mode model that replaced the retired `/invoke` RPC
289
+ route.
290
+ - Native Integration Mode (design) —
291
+ `docs/design/appendices/native-integration-mode.md`, the on-demand
292
+ surface used by `native` rows and its `integration_flip_lock:<key>`
293
+ drain protocol.
294
+ - Routine Data Acquisition (design) — `docs/design/appendices/routine-data-acquisition.md`
295
+ §6.8 / §8.1, the per-(integration, mode) partial schema used by
296
+ `routine.fetch_window`.
@@ -18,14 +18,17 @@ tags:
18
18
  - core
19
19
  - memory
20
20
  - storage
21
+ - knowledge
21
22
  status: stable
22
23
  ask_examples:
23
24
  - Where are my context files stored?
24
25
  - How does the agent edit context files?
25
26
  - What is the difference between context MD and SQLite?
27
+ - Where do management rules and policies live?
28
+ - How does the daemon prevent the agent from writing to disk directly?
26
29
  locale: en-US
27
30
  created: 2026-04-25
28
- updated: 2026-05-04
31
+ updated: 2026-05-15
29
32
  keywords:
30
33
  - context
31
34
  - markdown
@@ -35,6 +38,10 @@ keywords:
35
38
  - roadmap.md
36
39
  - rules/management.md
37
40
  - rules/policies
41
+ - agent journal
42
+ - context API
43
+ - AgentWriteTracker
44
+ - durable memory
38
45
  related:
39
46
  - features/memory-files/today
40
47
  - features/memory-files/user-profile
@@ -42,7 +49,6 @@ related:
42
49
  - features/memory-files/agent-journal
43
50
  - features/memory-files/schedule
44
51
  - features/memory-files/projects
45
- - features/memory-files/management-rules
46
52
  ui_anchors:
47
53
  - /knowledge
48
54
  - /connections/knowledge
@@ -109,8 +115,7 @@ indexes, and configuration.
109
115
  - `projects/<slug>.md` — one file per active project.
110
116
  - `rules/management.md` — the umbrella registry: Source-of-Truth
111
117
  bindings, Managed Tasks, an Active Policies summary. Always
112
- injected into every flow. See
113
- [rules/management.md and rules/policies/](../features/memory-files/management-rules.md).
118
+ injected into every flow.
114
119
  - `rules/policies/<slug>.md` — one file per durable management rule
115
120
  ("from now on, do X"). The daemon auto-maintains a slug index at
116
121
  `rules/policies/_index.md`.
@@ -7,6 +7,8 @@ aliases:
7
7
  - observation
8
8
  - polling
9
9
  - hourly check
10
+ - observation queue
11
+ - phase 9
10
12
  category: concepts
11
13
  summary: |
12
14
  Observations are change records the polling integrations write into
@@ -17,22 +19,32 @@ tags:
17
19
  - core
18
20
  - observations
19
21
  - polling
22
+ - integrations
23
+ - routines
20
24
  status: stable
21
25
  ask_examples:
22
26
  - What is an observation?
23
27
  - Why doesn't the agent message me on every git commit?
24
28
  - How does the hourly check use observations?
29
+ - Where does the routine pre-pass write observations?
25
30
  locale: en-US
26
31
  created: 2026-04-25
27
- updated: 2026-04-25
32
+ updated: 2026-05-15
28
33
  keywords:
29
34
  - observation
35
+ - observations
30
36
  - polling
31
37
  - hourly check
32
38
  - phase 9
39
+ - routine.fetch_window
40
+ - pre-pass
41
+ - AgentWriteTracker
42
+ - contentHash
33
43
  related:
34
44
  - features/routines/hourly-check
45
+ - features/routines/morning-routine
35
46
  - concepts/process-keys
47
+ - concepts/routines
36
48
  ---
37
49
 
38
50
  # Observations
@@ -16,18 +16,28 @@ section: process-keys
16
16
  tags:
17
17
  - core
18
18
  - dispatch
19
+ - backends
20
+ - routing
19
21
  status: stable
20
22
  ask_examples:
21
23
  - What is a ProcessKey?
22
24
  - Where can I see all the ProcessKeys?
23
25
  - How do I change which model handles a ProcessKey?
26
+ - What is the difference between configurable and fixed ProcessKeys?
24
27
  locale: en-US
25
28
  created: 2026-04-25
26
- updated: 2026-04-25
29
+ updated: 2026-05-15
27
30
  keywords:
28
31
  - process key
32
+ - ProcessKey
29
33
  - dispatch
30
34
  - routing
35
+ - CONFIGURABLE_PROCESS_KEYS
36
+ - DEFAULT_PROCESS_TIERS
37
+ - PROCESS_TO_EVENT_TYPE
38
+ - routine.morning_routine
39
+ - message.dm
40
+ - dashboard.chat
31
41
  related:
32
42
  - concepts/backends-and-tiers
33
43
  - concepts/skills
@@ -57,17 +67,22 @@ those subsystems.
57
67
  backend on `/settings/models`.
58
68
  - **REACTIVE_PROCESS_KEYS**: those tied to in-the-loop events (DMs,
59
69
  dashboard chat, docs QA).
60
- - **DEFAULT_PROCESS_TIERS**: the per-key default (heavy or light).
70
+ - **DEFAULT_PROCESS_TIERS**: the per-key default (`lite`, `medium`, or
71
+ `high`).
61
72
  - **PROCESS_TO_EVENT_TYPE**: maps a ProcessKey to the skill manifest
62
73
  key.
63
74
 
64
75
  ## Concrete Examples
65
76
 
66
- - Routines: `routine.morning_routine`, `routine.morning_routine_initial`,
77
+ - Routines: `routine.morning_routine` (parent envelope read by the
78
+ pre-routine gate, plus the Phase 5 split keys
79
+ `routine.morning_routine_today` and `routine.morning_routine_journal`),
67
80
  `routine.evening_review`, `routine.weekly_review`,
68
- `routine.monthly_review`, `routine.hourly_check`,
81
+ `routine.hourly_check`,
69
82
  `routine.roadmap_refresh`, `routine.today_refresh`,
70
- `routine.user_profile_sweep`
83
+ `routine.user_profile_sweep`. `routine.morning_routine_initial` was
84
+ retired by morning-routine-optimization.md Phase 7 (2026-05-16) — the
85
+ first-run branch routes through `routine.morning_routine`.
71
86
  - Routine sub-jobs (lite tier, dispatcher-spawned, not user-facing):
72
87
  `routine.fetch_window` (pre-pass mail/calendar/Notion fetcher that
73
88
  runs before each main routine and POSTs observations) and
@@ -7,29 +7,40 @@ aliases:
7
7
  - autonomous routines
8
8
  - cron
9
9
  - scheduled work
10
+ - routine pre-pass
11
+ - morning routine
12
+ - evening review
10
13
  category: concepts
11
14
  summary: |
12
15
  Routines are the autonomous, scheduled tasks Aitne runs on
13
- its own — morning routine, evening review, hourly check, weekly and
14
- monthly retros, plus any custom routines you define.
16
+ its own — morning routine, evening review, hourly check, weekly
17
+ retro, plus any custom routines you define.
15
18
  section: routines
16
19
  tags:
17
20
  - core
18
- - routine
21
+ - routines
19
22
  - autonomous
23
+ - scheduler
20
24
  status: stable
21
25
  ask_examples:
22
26
  - What routines does the agent run automatically?
23
27
  - How do I disable a routine?
24
28
  - Can I add my own routine?
29
+ - What is the routine pre-pass fetcher?
30
+ - Which routine uses the high tier by default?
25
31
  locale: en-US
26
32
  created: 2026-04-25
27
- updated: 2026-04-25
33
+ updated: 2026-05-15
28
34
  keywords:
29
35
  - routine
36
+ - routines
30
37
  - cron
31
38
  - autonomous
32
39
  - scheduler
40
+ - routine.fetch_window
41
+ - pre-pass
42
+ - dayBoundaryHour
43
+ - hourly check
33
44
  related:
34
45
  - features/routines/morning-routine
35
46
  - features/routines/evening-review
@@ -37,6 +48,7 @@ related:
37
48
  - features/routines/hourly-check
38
49
  - features/routines/custom-routines
39
50
  - concepts/process-keys
51
+ - concepts/observations
40
52
  ui_anchors:
41
53
  - /connections/routines
42
54
  - /settings/routines
@@ -48,9 +60,9 @@ ui_anchors:
48
60
 
49
61
  A routine is a unit of agent work that runs on a schedule, not in
50
62
  response to a message. The morning routine fires once per agent day at
51
- `dayBoundaryHour`; evening / weekly / monthly retros fire on fixed
52
- schedules in code; the hourly check coalesces accumulated observations
53
- on a configurable cadence.
63
+ `dayBoundaryHour`; evening and weekly retros fire on fixed schedules
64
+ in code; the hourly check coalesces accumulated observations on a
65
+ configurable cadence.
54
66
 
55
67
  ## Why This Concept Exists
56
68
 
@@ -73,13 +85,20 @@ DM is who fired the event.
73
85
  - **Catch-up**: if the daemon was offline at the trigger time, the
74
86
  scheduler re-fires the routine on next launch when it is still in
75
87
  the same agent day.
76
- - **Tier policy**: only the one-shot `routine.morning_routine_initial`
77
- runs heavy by default (Opus on Claude, GPT-5.5 on Codex, Gemini 3
78
- Pro on Gemini). Every other recurring routine — morning, evening,
79
- weekly, monthly, hourly check — defaults to **medium** (Sonnet on
80
- Claude). The lite (Haiku) tier is reserved for mechanical
81
- sub-jobs: the hourly-check triage gate and the new pre-pass
82
- fetcher. See [Backends and Tiers](backends-and-tiers.md).
88
+ - **Tier policy**: no routine runs heavy by default. The morning
89
+ routine's first-run branch ran on heavy until
90
+ `docs/design/appendices/morning-routine-optimization.md` Phase 7
91
+ (2026-05-16) retired `routine.morning_routine_initial`; the
92
+ first-run branch now uses the medium-tier parent
93
+ `routine.morning_routine` with a daemon-prepared
94
+ `<roadmap_skeleton>` block. Every recurring routine — morning,
95
+ evening, weekly, hourly check — defaults to **medium**
96
+ (Sonnet on Claude). The morning routine itself is a two-stage
97
+ pipeline: Stage A `routine.morning_routine_today` (medium) runs
98
+ in parallel with Stage B `routine.morning_routine_journal` (lite).
99
+ The lite (Haiku) tier is reserved for Stage B plus mechanical
100
+ sub-jobs (the hourly-check triage gate and the pre-pass fetcher).
101
+ See [Backends and Tiers](backends-and-tiers.md).
83
102
  - **Pre-pass fetcher**: each main routine that needs fresh mail /
84
103
  calendar / Notion data is preceded by a lite-tier
85
104
  `routine.fetch_window` session that fetches the relevant window and
@@ -92,14 +111,14 @@ DM is who fired the event.
92
111
 
93
112
  | ProcessKey | When | Tier |
94
113
  |---|---|---|
95
- | `routine.morning_routine_initial` | First setup day, one-shot | heavy |
96
- | `routine.morning_routine` | `dayBoundaryHour` daily | medium |
114
+ | `routine.morning_routine` | `dayBoundaryHour` daily (parent envelope; first-run branch detected inline from missing `yesterday.md`) | medium |
115
+ | `routine.morning_routine_today` | Stage A of every morning routine (today.md synthesis + roadmap maintenance + schedule fan-out) | medium |
116
+ | `routine.morning_routine_journal` | Stage B of every morning routine (daily/<yesterday>.md authoring) | lite |
97
117
  | `routine.today_refresh` | Every 4h inside the active window | medium |
98
118
  | `routine.evening_review` | 18:00 daily (fixed) | medium |
99
119
  | `routine.hourly_check` | Every `hourlyCheckIntervalMinutes` (default 60) inside the active window | medium |
100
120
  | `routine.weekly_review` | Friday 18:00 (fixed) | medium |
101
- | `routine.monthly_review` | Last day of month, 18:00 (fixed) | medium |
102
- | `routine.fetch_window` | Spawned before each routine above (except monthly) | lite |
121
+ | `routine.fetch_window` | Spawned before each routine above | lite |
103
122
  | `routine.hourly_check.triage` | Stage 2 gate of every hourly check | lite |
104
123
  | `routine.custom.<slug>` | Operator-defined recurrence | configurable |
105
124
 
@@ -107,8 +126,7 @@ DM is who fired the event.
107
126
 
108
127
  - **Settings → Routines** is where the hourly check active window, the
109
128
  hourly check cadence, and any custom routines live. Morning, evening,
110
- weekly, and monthly fire times are fixed in code and not surfaced
111
- here.
129
+ and weekly fire times are fixed in code and not surfaced here.
112
130
  - **Connections → Routines** is the unified view of next-fire times.
113
131
  - **Activity** logs each routine run with its outcome.
114
132