@aitne-sh/aitne 0.1.9 → 0.1.10

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 (153) hide show
  1. package/README.md +36 -6
  2. package/agent-assets/docs/concepts/agent-day.md +2 -2
  3. package/agent-assets/docs/concepts/costs-and-quotas.md +4 -3
  4. package/agent-assets/docs/concepts/delegated-mode.md +5 -5
  5. package/agent-assets/docs/concepts/memory-model.md +6 -3
  6. package/agent-assets/docs/concepts/safety-model.md +19 -16
  7. package/agent-assets/docs/concepts/skills.md +2 -2
  8. package/agent-assets/docs/features/integrations/browser-history.md +9 -8
  9. package/agent-assets/docs/features/integrations/calendar.md +4 -4
  10. package/agent-assets/docs/features/integrations/mail.md +3 -2
  11. package/agent-assets/docs/features/lifestyle/git.md +3 -3
  12. package/agent-assets/docs/features/lifestyle/reading.md +15 -8
  13. package/agent-assets/docs/features/lifestyle/travel-bookings.md +4 -3
  14. package/agent-assets/docs/features/memory-files/agent-journal.md +30 -12
  15. package/agent-assets/docs/features/memory-files/agent-lessons.md +177 -0
  16. package/agent-assets/docs/features/memory-files/projects.md +6 -4
  17. package/agent-assets/docs/features/memory-files/roadmap.md +17 -14
  18. package/agent-assets/docs/features/messaging/overview.md +5 -5
  19. package/agent-assets/docs/features/messaging/telegram.md +10 -9
  20. package/agent-assets/docs/features/operations/activity-and-conversations.md +5 -4
  21. package/agent-assets/docs/features/operations/approvals.md +6 -5
  22. package/agent-assets/docs/features/operations/managed-chromium.md +3 -2
  23. package/agent-assets/docs/features/operations/quiet-hours.md +4 -3
  24. package/agent-assets/docs/features/routines/custom-routines.md +11 -7
  25. package/agent-assets/docs/features/routines/evening-review.md +10 -2
  26. package/agent-assets/docs/features/routines/morning-routine.md +4 -3
  27. package/agent-assets/docs/features/routines/weekly-review.md +6 -0
  28. package/agent-assets/docs/features/wiki/commands.md +4 -4
  29. package/agent-assets/docs/features/wiki/cost-and-approval.md +4 -3
  30. package/agent-assets/docs/features/wiki/dashboard.md +7 -6
  31. package/agent-assets/docs/features/wiki/overview.md +3 -3
  32. package/agent-assets/docs/features/wiki/search.md +5 -5
  33. package/agent-assets/docs/features/wiki/workspaces.md +2 -2
  34. package/agent-assets/docs/getting-started/02-first-steps.md +5 -3
  35. package/agent-assets/docs/getting-started/04-first-day.md +2 -2
  36. package/agent-assets/docs/glossary.md +4 -4
  37. package/agent-assets/docs/guides/budget-and-cost-for-wiki.md +2 -2
  38. package/agent-assets/docs/guides/connect-a-new-mail-account.md +4 -2
  39. package/agent-assets/docs/guides/explore-with-trace-and-connect.md +5 -4
  40. package/agent-assets/docs/guides/install-and-run.md +2 -2
  41. package/agent-assets/docs/guides/maintain-wiki-health.md +2 -2
  42. package/agent-assets/docs/guides/pause-the-agent.md +9 -5
  43. package/agent-assets/docs/guides/setup-wizard.md +8 -5
  44. package/agent-assets/docs/guides/use-an-existing-obsidian-vault.md +6 -6
  45. package/agent-assets/docs/reference/api.md +15 -5
  46. package/agent-assets/docs/reference/cli-commands.md +3 -3
  47. package/agent-assets/docs/reference/config.md +21 -4
  48. package/agent-assets/docs/reference/disallowed-tools.md +6 -4
  49. package/agent-assets/docs/reference/knowledge-layout.md +11 -2
  50. package/agent-assets/docs/reference/process-keys.md +2 -2
  51. package/agent-assets/docs/reference/skills.md +5 -4
  52. package/agent-assets/docs/troubleshooting/auth-failed.md +9 -8
  53. package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +16 -9
  54. package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +2 -2
  55. package/agent-assets/docs/troubleshooting/quota-exhausted.md +7 -6
  56. package/agent-assets/skills/agent-actions/SKILL.md +23 -39
  57. package/agent-assets/skills/agent-create/SKILL.md +15 -6
  58. package/agent-assets/skills/attach/SKILL.md +8 -27
  59. package/agent-assets/skills/browser-history/SKILL.md +29 -16
  60. package/agent-assets/skills/browser-history-respond/SKILL.md +6 -1
  61. package/agent-assets/skills/browser-task/SKILL.md +22 -27
  62. package/agent-assets/skills/context/SKILL.md +23 -32
  63. package/agent-assets/skills/context/curation.json +12 -12
  64. package/agent-assets/skills/context/references/api.md +17 -17
  65. package/agent-assets/skills/context/references/required-frontmatter.md +10 -9
  66. package/agent-assets/skills/context/references/snapshot-files.md +12 -11
  67. package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +5 -5
  68. package/agent-assets/skills/context/seeds/frontmatter-requirements.seed.json +3 -3
  69. package/agent-assets/skills/docs-search/SKILL.md +19 -31
  70. package/agent-assets/skills/external-services/SKILL.delegated.claude.md +8 -95
  71. package/agent-assets/skills/external-services/SKILL.delegated.codex.md +8 -94
  72. package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +8 -94
  73. package/agent-assets/skills/external-services/SKILL.native.claude.md +2 -2
  74. package/agent-assets/skills/external-services/references/exec-errors.md +32 -0
  75. package/agent-assets/skills/external-services/references/skills-crud.md +5 -5
  76. package/agent-assets/skills/gmail-lifestyle/SKILL.md +3 -2
  77. package/agent-assets/skills/gmail-lifestyle/references/receipts-api.md +4 -0
  78. package/agent-assets/skills/gmail-lifestyle/references/travel-bookings-api.md +9 -0
  79. package/agent-assets/skills/mail/SKILL.delegated.claude.md +13 -25
  80. package/agent-assets/skills/mail/SKILL.delegated.codex.md +3 -2
  81. package/agent-assets/skills/mail/SKILL.delegated.gemini.md +3 -2
  82. package/agent-assets/skills/mail/SKILL.md +10 -18
  83. package/agent-assets/skills/mail/SKILL.native.claude.md +8 -7
  84. package/agent-assets/skills/mail/SKILL.native.codex.md +1 -1
  85. package/agent-assets/skills/mail/SKILL.native.gemini.md +1 -1
  86. package/agent-assets/skills/mail/references/api.md +6 -1
  87. package/agent-assets/skills/mail/references/examples.md +2 -1
  88. package/agent-assets/skills/managed-tasks/SKILL.md +44 -77
  89. package/agent-assets/skills/managed-tasks/references/errors.md +25 -14
  90. package/agent-assets/skills/managed-tasks/references/output-path.md +33 -17
  91. package/agent-assets/skills/managed-tasks/references/recurrence-rule.md +6 -4
  92. package/agent-assets/skills/management-policy/SKILL.md +10 -11
  93. package/agent-assets/skills/management-policy/references/policy-workflow.md +4 -5
  94. package/agent-assets/skills/notify/SKILL.md +11 -13
  95. package/agent-assets/skills/notify/references/priority.md +28 -25
  96. package/agent-assets/skills/notion/SKILL.delegated.claude.md +1 -1
  97. package/agent-assets/skills/notion/SKILL.delegated.codex.md +1 -1
  98. package/agent-assets/skills/notion/SKILL.delegated.gemini.md +1 -1
  99. package/agent-assets/skills/notion/SKILL.md +17 -17
  100. package/agent-assets/skills/notion/SKILL.native.claude.md +1 -1
  101. package/agent-assets/skills/notion/SKILL.native.codex.md +1 -1
  102. package/agent-assets/skills/notion/SKILL.native.gemini.md +1 -1
  103. package/agent-assets/skills/observations/SKILL.md +5 -20
  104. package/agent-assets/skills/observations/references/fetch-fallback.md +22 -0
  105. package/agent-assets/skills/project-doc/SKILL.md +9 -6
  106. package/agent-assets/skills/project-doc/curation.json +3 -3
  107. package/agent-assets/skills/project-doc/seeds/project-shape.seed.json +2 -2
  108. package/agent-assets/skills/project-doc/seeds/slug-grammar.seed.json +3 -3
  109. package/agent-assets/skills/reading/SKILL.md +8 -42
  110. package/agent-assets/skills/reading/references/reading-taste.md +5 -5
  111. package/agent-assets/skills/roadmap/SKILL.md +3 -19
  112. package/agent-assets/skills/roadmap/references/api.md +16 -6
  113. package/agent-assets/skills/roadmap/references/horizon-tags.md +11 -0
  114. package/agent-assets/skills/roadmap/references/migration.md +8 -6
  115. package/agent-assets/skills/roadmap/references/retention.md +18 -0
  116. package/agent-assets/skills/schedule/SKILL.md +9 -26
  117. package/agent-assets/skills/schedule/references/importance.md +23 -0
  118. package/agent-assets/skills/schedule/references/recurrence-rule.md +6 -4
  119. package/agent-assets/skills/scheduled-managed-task/SKILL.md +34 -37
  120. package/agent-assets/skills/today/SKILL.md +20 -79
  121. package/agent-assets/skills/today/references/today-skeleton.md +66 -0
  122. package/agent-assets/skills/today/seeds/agent-notes-flavors.seed.json +1 -1
  123. package/agent-assets/skills/today/seeds/section-shape.seed.json +6 -6
  124. package/agent-assets/skills/user-interview/SKILL.md +15 -90
  125. package/agent-assets/skills/user-interview/references/op-briefing.md +1 -1
  126. package/agent-assets/skills/user-interview/references/op-dm-handler.md +88 -0
  127. package/agent-assets/skills/user-interview/references/op-morning.md +1 -1
  128. package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +1 -1
  129. package/agent-assets/skills/user-profile/SKILL.md +16 -26
  130. package/agent-assets/skills/user-profile/curation.json +3 -3
  131. package/agent-assets/skills/user-profile/references/character-preferences.md +3 -3
  132. package/agent-assets/skills/wiki/wiki-ask/SKILL.md +1 -1
  133. package/agent-assets/skills/wiki/wiki-compile/SKILL.md +5 -4
  134. package/agent-assets/skills/wiki/wiki-connect/SKILL.md +32 -5
  135. package/agent-assets/skills/wiki/wiki-ingest/SKILL.md +6 -50
  136. package/agent-assets/skills/wiki/wiki-ingest/references/curl-errors.md +58 -0
  137. package/agent-assets/skills/wiki/wiki-lint/SKILL.md +20 -14
  138. package/agent-assets/skills/wiki/wiki-trace/SKILL.md +10 -5
  139. package/agent-assets/skills/wiki/wiki-vault-rules/SKILL.md +2 -0
  140. package/agent-assets/task-flows/_partials/feedback-capture.md +30 -0
  141. package/agent-assets/task-flows/message.received.dm.md +4 -0
  142. package/agent-assets/task-flows/message.received.dm_first.md +4 -0
  143. package/agent-assets/task-flows/routine.evening_review.md +80 -0
  144. package/agent-assets/task-flows/routine.monthly_review.md +72 -0
  145. package/agent-assets/task-flows/routine.weekly_review.md +21 -0
  146. package/agent-assets/task-flows/wiki.trace.md +1 -1
  147. package/bin/aitne.mjs +45 -11
  148. package/package.json +4 -4
  149. package/scripts/commands/doctor.mjs +11 -2
  150. package/scripts/lib/process-identity.d.mts +46 -0
  151. package/scripts/lib/process-identity.mjs +193 -0
  152. package/scripts/lib/read-api-token.mjs +1 -1
  153. package/scripts/start.mjs +14 -4
@@ -123,35 +123,18 @@ a paraphrase. The user is the one who can fix auth / quota / install.
123
123
 
124
124
  ### Step 4a — Decide `output_path` (LLM judgment)
125
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.
126
+ Infer the primary L2 directory the recurring fetch will write into:
127
+
128
+ 1. Reuse an existing path if the source already lives somewhere —
129
+ `curl -s "http://localhost:8321/api/entities?source=<app>&limit=5" | jq -r '.items[].path'`;
130
+ if 1+ rows agree on `<domain>/<type-plural>`, that path wins.
131
+ 2. Else pick by the probe sample's data shape (mapping table in the
132
+ reference below).
133
+ 3. Else omit the field (`output_path: null`) — the first scheduled run
134
+ back-fills it.
135
+
136
+ The full grammar (allowed domain / type values, trailing-slash rule,
137
+ `..` rejection, 400 rejection shape, data-shape mapping) is below.
155
138
 
156
139
  {{> ref:output-path }}
157
140
 
@@ -206,15 +189,10 @@ cadence)` collides at the uniqueness check and returns `409
206
189
  duplicate` with the existing `mt_id` — DM the user pointing at it
207
190
  instead of registering twice.
208
191
 
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.
192
+ **Server-side**: the daemon runs the atomic tx (allocate `mt_<n>`,
193
+ INSERT the FK-linked `recurring_schedules` + `managed_tasks`, audit),
194
+ re-renders `policies/management.md`, and snapshots it you do not
195
+ touch the file. On a DB failure you get a 5xx; surface the body.
218
196
 
219
197
  ### Step 7 — Confirm to user
220
198
 
@@ -305,10 +283,8 @@ rename has its own dedicated route
305
283
  disambiguator already routes app-change requests to "stop + re-register"
306
284
  for safety.
307
285
 
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}`).
286
+ **Server-side**: the daemon runs the atomic tx + re-renders the file
287
+ + audits you do not touch the file.
312
288
 
313
289
  `mt_id`, `last_run_at`, `last_result`, and `consecutive_failures`
314
290
  are preserved across PATCH — history is continuous. A cadence change
@@ -374,16 +350,13 @@ so they can make an informed call.
374
350
  curl -sS -X DELETE http://localhost:8321/api/managed-tasks/mt_42
375
351
  ```
376
352
 
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'`).
353
+ **Server-side**: the daemon runs the atomic tx (snapshot the row,
354
+ DELETE `managed_tasks` cascading to `recurring_schedules`, cancel
355
+ pending fires, audit) + re-renders the file — you do not touch it.
382
356
 
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.
357
+ The pre-delete row snapshot (`agent_actions.detail.original_row`)
358
+ plus the `md_file_snapshots` row is the recovery surface — for
359
+ audit / debug only, never the user-facing DM.
387
360
 
388
361
  ### Step 4 — Confirm to user
389
362
 
@@ -407,11 +380,11 @@ modifying the schedule:
407
380
  curl -sS -X POST http://localhost:8321/api/managed-tasks/mt_42/run-now
408
381
  ```
409
382
 
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.
383
+ Success is `202 {status:"queued", mt_id, scheduled_row_id}` — the
384
+ route enqueues a one-shot `agent_schedule` row that runs the same
385
+ task-flow as a scheduled fire; the next regular firing is unaffected.
386
+ There is no in-flight guard, so the fire always enqueues — do not
387
+ fire it in a loop yourself.
415
388
 
416
389
  Confirm to user with one DM after the fire enqueues:
417
390
 
@@ -422,10 +395,10 @@ Confirm to user with one DM after the fire enqueues:
422
395
 
423
396
  ## Error envelope
424
397
 
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
398
+ Every error is the daemon envelope
399
+ (`{ok:false, summary, errors:[…], retryable, error?}`). Verbs (POST /
400
+ PATCH / DELETE / run-now), codes (`validation_error`, `duplicate`,
401
+ `cap_reached`, `invalid_id`, `not_found`, `internal_error`), and the
429
402
  Idempotency-Key contract are in the errors reference below.
430
403
 
431
404
  {{> ref:errors }}
@@ -434,26 +407,20 @@ Idempotency-Key contract are in the errors reference below.
434
407
 
435
408
  ## What this skill does NOT do
436
409
 
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`.
410
+ - Does NOT PUT `policies/management.md` (or INSERT `recurring_schedules`)
411
+ directly — the only legal write is the `/api/managed-tasks` chokepoint;
412
+ the daemon owns the file write and the FK pair.
413
+ - Does NOT mutate `app` through PATCH a different connector is a
414
+ different commitment; stop + re-register.
449
415
  - Does NOT silently re-register on retry — use `Idempotency-Key`
450
416
  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.
417
+ - Does NOT register a task with no probe-passing connector — probe
418
+ failure is a hard stop.
419
+ - Does NOT delete entity files produced by past runs on stop — those
420
+ stay where written; the DELETE only removes the row + its recurring
421
+ schedule.
455
422
  - Does NOT bulk-stop without per-row confirmation. "Stop all gmail
456
- tasks" is a series of DM round-trips, one per row.
423
+ tasks" is one DM round-trip per row.
457
424
 
458
425
  ## API surface
459
426
 
@@ -1,24 +1,32 @@
1
1
  ---
2
2
  kind: reference
3
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).
4
+ description: /api/managed-tasks error envelope — {ok:false, summary, errors[], retryable} plus POST / PATCH / DELETE codes (validation_error, duplicate, cap_reached, invalid_id, not_found, internal_error).
5
5
  ---
6
6
 
7
7
  # /api/managed-tasks error envelope
8
8
 
9
- Every endpoint returns the standard daemon error shape:
9
+ Every error response is the standard daemon envelope:
10
10
 
11
11
  ```jsonc
12
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 */ }
13
+ "ok": false,
14
+ "summary": "<one-line human text — surface verbatim>",
15
+ "errors": [ { "code": "managed_tasks.validation_error", "field": "body", "hint": "..." } ],
16
+ "retryable": false,
17
+ "error": "<legacy machine-code alias — present on single-issue envelopes>"
17
18
  }
18
19
  ```
19
20
 
20
- `body.message` is intended for the user — preserve it verbatim. The
21
- daemon does NOT emit `cron_too_tight`. Note: the recurrence schema
21
+ `summary`, `errors[]`, and `retryable` are ALWAYS present. Each
22
+ `errors[]` issue carries `code` / `field` / `hint`. The top-level
23
+ `error` is a legacy alias for the single issue's code. Legacy aliases
24
+ appear only on specific codes: `item` (the existing row) on `409
25
+ duplicate`, `message` on duplicate / cap, and `details` (the raw
26
+ ZodError) on `validation_error`. Per-verb tables below name the issue
27
+ `code`; surface `body.summary` or the issue `hint`, not a paraphrase.
28
+
29
+ The daemon does NOT emit `cron_too_tight`. Note: the recurrence schema
22
30
  DOES accept `hourly` (the engine supports `hourly`/`daily`/`weekly`/
23
31
  `monthly`), so a sub-daily POST is NOT rejected server-side — it
24
32
  succeeds (201). The daily-or-coarser floor for managed tasks is a
@@ -32,7 +40,7 @@ structured field, so there is no partial-cadence shape to reject).
32
40
 
33
41
  | HTTP | `error` | When | What to do |
34
42
  |---|---|---|---|
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. |
43
+ | 400 | `validation_error` | Body fails Zod (frequency unknown, time malformed, etc.) | Pick the offending field from `body.summary` / the issue `hint` (`details` is a serialized ZodError object, not an array) and ask the user to clarify. |
36
44
  | 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
45
  | 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
46
  | 5xx | `internal_error` | DB / cascade failure | DM "Couldn't register; daemon error. Try again, or check `aitne logs`." |
@@ -42,9 +50,9 @@ structured field, so there is no partial-cadence shape to reject).
42
50
  | HTTP | `error` | When | What to do |
43
51
  |---|---|---|---|
44
52
  | 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. |
53
+ | 400 | `validation_error` | Body fails Zod (empty body, recurrenceRule.daysOfWeek on a `daily`, etc.) | Pin the failing field from `body.summary` / the issue `hint` (`details` is a serialized ZodError object, not an array) and ask for a fix. |
46
54
  | 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`. |
55
+ | 5xx | `internal_error` | DB / cascade failure | Surface `body.summary`; advise `aitne logs`. |
48
56
 
49
57
  ## DELETE /api/managed-tasks/:id
50
58
 
@@ -52,16 +60,19 @@ structured field, so there is no partial-cadence shape to reject).
52
60
  |---|---|---|---|
53
61
  | 400 | `invalid_id` | `:id` didn't match `^mt_[1-9]\d*$` | Ask the user to repeat. |
54
62
  | 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`. |
63
+ | 5xx | `internal_error` | DB / cascade failure | Surface `body.summary`; advise `aitne logs`. |
56
64
 
57
65
  ## POST /api/managed-tasks/:id/run-now
58
66
 
67
+ Success is `202 {status:"queued", mt_id, scheduled_row_id}` — the
68
+ route has no concurrency guard, so a fire enqueues unconditionally
69
+ (there is no `already_running` code). Errors:
70
+
59
71
  | HTTP | `error` | When | What to do |
60
72
  |---|---|---|---|
61
73
  | 400 | `invalid_id` | `:id` didn't match `^mt_[1-9]\d*$` | Ask the user to repeat. |
62
74
  | 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`. |
75
+ | 5xx | `internal_error` | Dispatcher / cascade failure | Surface the issue `hint`. |
65
76
 
66
77
  ## Idempotency on POST
67
78
 
@@ -8,8 +8,10 @@ description: output_path grammar — `<domain>/<type-plural>/` only, trailing sl
8
8
 
9
9
  The `output_path` field on `/api/managed-tasks` is the L2 directory
10
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.
11
+ entity files. The full grammar (domain/type enum, two segments, no
12
+ `..`) is enforced by a Zod `.refine` PRE-insert, so a bad value is
13
+ rejected with **HTTP 400**. The SQL CHECK constraint only guarantees
14
+ the trailing slash (`output_path LIKE '%/'`).
13
15
 
14
16
  ## Format
15
17
 
@@ -28,9 +30,24 @@ at INSERT / UPDATE time.
28
30
  | `<type-plural>` | `meetings`, `trips`, `receipts`, `projects`, `books`, `notes` |
29
31
 
30
32
  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).
33
+ the pair whose semantic prior best fits the fetch's data shape.
34
+
35
+ ## Data shape path mapping
36
+
37
+ When no existing entity path is found for the source (see Register
38
+ Step 4a), pick the `(domain, type)` pair whose semantic prior best
39
+ fits the probe sample:
40
+
41
+ | Probe sample shape | Likely `<domain>/<type-plural>/` |
42
+ |---|---|
43
+ | Recording with attendees + duration | `work/meetings/` |
44
+ | PDF / image with monetary amount | `finance/receipts/` |
45
+ | Travel itinerary / booking | `travel/trips/` |
46
+ | Long-form note / article | `<domain>/notes/` (pick by content topic) |
47
+ | Book metadata / progress | `learning/books/` |
48
+
49
+ If the data shape is genuinely ambiguous (zero rows), omit the field
50
+ (`output_path: null`) — the first scheduled run populates it.
34
51
 
35
52
  ## Examples
36
53
 
@@ -61,15 +78,14 @@ re-register.
61
78
  To clear an existing `output_path` back to "first run decides", send
62
79
  `{"output_path": null}` in the PATCH.
63
80
 
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.
81
+ ## Rejection
82
+
83
+ A bad `output_path` fails Zod and the route returns **HTTP 400** with
84
+ the generic `managed_tasks.validation_error` issue — there is no
85
+ top-level `field` and no per-`output_path` `message`. The raw
86
+ ZodError lives under `legacyFields.details`, but it is a serialized
87
+ ZodError object (`{name:"ZodError", message:"<stringified issues>"}`),
88
+ NOT an array — there is no `details[].path` to read. The offending
89
+ field (`output_path`) is named in `body.summary` and the issue `hint`;
90
+ the raw issues are inside the stringified `details.message`. Surface
91
+ `body.summary` or the issue `hint`. Do not retry the same value.
@@ -8,10 +8,12 @@ description: recurrenceRule grammar — hourly / daily / weekly / monthly. Engin
8
8
 
9
9
  The daemon's recurrence engine accepts four frequencies: `hourly`,
10
10
  `daily`, `weekly`, `monthly`. Each frequency requires its own set of
11
- fields and rejects fields that don't apply — the daemon's Zod
12
- refinements return a `schedule.frequency_field_mismatch` issue (with
13
- the offending field path) when the shape disagrees with the chosen
14
- frequency. Pre-validate to save a round-trip.
11
+ fields and rejects fields that don't apply — the daemon rejects a
12
+ mismatched shape with an HTTP 400 validation error naming the
13
+ frequency/field conflict. The recurring-schedules endpoint (the
14
+ `schedule` skill) surfaces it as a `schedule.frequency_field_mismatch`
15
+ issue with a field path; the managed-tasks endpoint surfaces it as a
16
+ `managed_tasks.validation_error`. Pre-validate to save a round-trip.
15
17
 
16
18
  Times are `HH:MM` 24-hour local; `timezone` is IANA (auto-fills from
17
19
  daemon config when omitted, but explicit is safer so a roaming laptop
@@ -69,8 +69,8 @@ curl -s "http://localhost:8321/api/context/list/policies"
69
69
  ```
70
70
 
71
71
  If the listing and `_index.md` rows disagree, **prefer the listing**
72
- and trust the next reconcile pass to refresh the index. Do **not**
73
- hand-PATCH `_index.md` to fix the drift that just creates more churn.
72
+ and trust the next reconcile pass to refresh the index (`_index.md` is
73
+ reconciler-ownedsee body intro).
74
74
 
75
75
  ### Step 2 — Detect similarity
76
76
 
@@ -156,9 +156,8 @@ the active policies first and ask.
156
156
  frontmatter `enabled: false`, PUT back. The reload hook flips the
157
157
  cron job off automatically.
158
158
 
159
- The policy-index reconciler picks the change up on the FS event and
160
- re-renders both `_index.md` and the management.md section within
161
- ~10 s. Do not PATCH them manually.
159
+ The policy-index reconciler re-renders both `_index.md` and the
160
+ management.md section within ~10 s (reconciler-owned — see body intro).
162
161
 
163
162
  If step 2 fails after step 1 succeeded, **attempt to roll back step 1**
164
163
  (`status` back to `active`). If the rollback itself fails, report the
@@ -190,8 +189,6 @@ is intentionally not whitelisted (see MANAGEMENT-POLICY-CAPTURE-PLAN
190
189
  - Does NOT create rows in the `recurring_schedules` DB table — defer to
191
190
  `policies/routines/custom/` for cron, which gives the user a visible MD file
192
191
  to edit.
193
- - Does NOT migrate existing custom routines into policy files
194
- retroactively. Migration is a separate one-time operation.
195
192
 
196
193
  ## Cross-skill pointers
197
194
 
@@ -223,11 +220,13 @@ skill targets these paths:
223
220
  - `DELETE /api/context/policies/routines/custom/<slug>` (remove only)
224
221
 
225
222
  `policies/management-captures/_index.md` and the `## Active Policies` section in
226
- `policies/management.md` are written by the daemon's policy-index
227
- reconciler — they are NOT in the agent's write surface for this skill.
223
+ `policies/management.md` are reconciler-owned (see body intro) — NOT in
224
+ the agent's write surface for this skill.
228
225
 
229
- Frontmatter validation enforces `kind: policy`, `owner: agent`, and
230
- the slug rules in Step 4. Malformed writes return 422 with the failing
226
+ Frontmatter validation enforces `type: rule`, `kind: policy`,
227
+ `owner: agent`, `status`, `created_at` (YYYY-MM-DD), `origin`,
228
+ `updated` (ISO), an H1, and the slug rules in Step 4 — see 5.3 for the
229
+ full required set. Malformed writes return 422 with the failing
231
230
  field — surface that text to the user verbatim rather than retrying
232
231
  blindly.
233
232
 
@@ -76,11 +76,10 @@ reconciler can resolve them.
76
76
 
77
77
  ## 5.4 _(no manual step required)_
78
78
 
79
- `policies/management-captures/_index.md` is auto-maintained by the daemon's
80
- policy-index reconciler it re-renders within ~10 s of step 5.3's
81
- write. Same for the `## Active Policies` section in
82
- `policies/management.md`. **Do not PATCH or PUT either path manually**;
83
- doing so just races the reconciler and creates snapshot churn.
79
+ Both `policies/management-captures/_index.md` and the `## Active Policies`
80
+ section in `policies/management.md` are reconciler-owned and re-render
81
+ within ~10 s of step 5.3's write (see SKILL.md body intro no manual
82
+ PATCH/PUT).
84
83
 
85
84
  If you need to confirm the index is up to date before replying to the
86
85
  user, GET `policies/management-captures/_index` after a short wait. The
@@ -41,10 +41,9 @@ language-agnostic** — it applies whatever language the agent uses
41
41
  with the user.
42
42
 
43
43
  Anti-examples (non-exhaustive — the positive rule above is
44
- load-bearing, not this list): "Good morning!", "Evening check-in —",
45
- "Morning briefing —", "Summary:", "Done.", "Sent.", "OK.", "Here's
46
- your day:", "Heads-up —", "FYI:", "Quick update:". Near-synonyms of
47
- these in any language also fail the positive rule.
44
+ load-bearing, not this list): "Good morning!", "Summary:", "Done.",
45
+ "Heads-up —". Near-synonyms of these in any language also fail the
46
+ positive rule.
48
47
 
49
48
  ### No internal mechanism names
50
49
 
@@ -56,9 +55,8 @@ user-visible text. Those go in Agent Log only.
56
55
 
57
56
  ### No filler timing commentary
58
57
 
59
- Forbidden — "Just a heads-up", "Still about N hours to go", "About N
60
- hours left", "FYI". If timing matters, the deadline / event time
61
- itself carries it.
58
+ Forbidden — "Just a heads-up", "About N hours left", "FYI". If timing
59
+ matters, the deadline / event time itself carries it.
62
60
 
63
61
  ### No table-of-contents readback
64
62
 
@@ -96,16 +94,16 @@ Notify when **all three** are true: (1) **actionable** or requires awareness, (2
96
94
  - **A pending Agent Plan row / scheduled DM is already set to fire
97
95
  for this item within the next 2 hours** — let the planned channel
98
96
  deliver; don't pre-empt it.
99
- - **Quiet hours (default 22:00-08:00, configurable)** unless `critical` schedule for after instead
100
- - **Over the rate-limit caps (3/hour, 12/day; `critical` bypasses both)** — do NOT spam-retry. The endpoint does NOT signal this: `/api/notify` returns `200 {status:"sent"}` even when quiet-hours or the rate-limit silently drops the message, so a `"sent"` response is not proof of delivery. Self-throttle by checking `<today>` `## Agent Log` before firing; if you suspect suppression, log the skip rather than re-posting. If time-critical, upgrade priority at next opportunity
97
+ - **Already delivered this item** — `/api/notify` sends immediately and a `200 {status:"sent"}` is proof of delivery, so do NOT re-post on a 200. Self-throttle via `<today>` `## Agent Log` before firing and log the skip rather than re-posting. (No endpoint quiet-hours or rate cap gates this for you — noise control is your job.)
101
98
  - **Routine file changes** or **agent internal state** — use Agent Log instead
102
99
  - **When in doubt — prefer silence**
103
100
 
104
101
  ## Priority
105
102
 
106
103
  **Default to `normal`.** Reserve `high` for 8h-delay-matters. Reserve
107
- `critical` for 3am-matters. Full per-level table, examples, and
108
- rate-limit caps are in the priority reference below.
104
+ `critical` for 3am-matters. `priority` is metadata recorded in the
105
+ notification log it does not gate delivery on this endpoint. Full
106
+ per-level table and examples are in the priority reference below.
109
107
 
110
108
  {{> ref:priority }}
111
109
 
@@ -120,5 +118,5 @@ curl -s -X POST http://localhost:8321/api/notify \
120
118
  -H 'Content-Type: application/json' \
121
119
  -d '{"message": "Design review starts in 15 minutes.", "priority": "normal"}'
122
120
  ```
123
- Fields: `message` (required, markdown), `priority` (optional: critical/high/normal/low), `platform` (optional, override target).
124
- Response: `{ "status": "sent", "notificationId": "..." }`. Risk tier: `Autonomous` — the agent decides when to notify; recorded in `notification_log` for the on-demand retrospective.
121
+ Fields: `message` (required, markdown), `priority` (optional: critical/high/normal/low), `platform` (optional, override target) OR `platforms` (optional, array of targets) — mutually exclusive, not both.
122
+ Response: `200 { "status": "sent", "notificationId": "...", "dispatchId": "..." }` = delivered to ≥1 channel; a total delivery failure returns HTTP 500 (not a silent 200-drop). Risk tier: `Autonomous` — the agent decides when to notify; recorded in `notification_log` for the on-demand retrospective.
@@ -1,20 +1,24 @@
1
1
  ---
2
2
  kind: reference
3
3
  name: priority
4
- description: Notification priority levels — critical / high / normal / low — with quiet-hours behavior and per-level examples.
4
+ description: Notification priority levels — critical / high / normal / low — as metadata you set, with per-level usage examples.
5
5
  ---
6
6
 
7
7
  # Notification priority levels
8
8
 
9
- Pick the lowest priority that still preserves the user-visible
10
- behavior the message needs. **Default to `normal`.**
9
+ `priority` is a metadata field you set on the `/api/notify` call. It
10
+ travels into `notification_log` and helps the user (and the
11
+ retrospective) gauge how urgent each message was. It does NOT gate
12
+ delivery on this endpoint — `/api/notify` sends immediately regardless
13
+ of level. Pick the lowest priority that still honestly describes the
14
+ message. **Default to `normal`.**
11
15
 
12
- | Priority | Quiet-hours | Use for |
13
- |---|---|---|
14
- | `critical` | Bypasses | Security alerts (credential leak, account lockout), data-loss risk (about to overwrite without backup, irreversible deletion in flight), system errors blocking the user from working. Wakes the user. |
15
- | `high` | Bypasses | Hard deadlines firing in the next 8 hours, urgent inbound messages from people the user has flagged as priority, "meeting starting now". User wants to see this even during quiet hours but not at 3 am. |
16
- | `normal` | Respects (dropped during quiet hours) | Regular reminders (`15 min until standup`), digest-style summaries, single-recipient FYIs the user opted into. **Default.** |
17
- | `low` | Respects (dropped during quiet hours) | Background updates, observational FYIs the user did not explicitly ask for, optional context. Often better as an Agent Log entry instead of a notification at all. |
16
+ | Priority | Use for |
17
+ |---|---|
18
+ | `critical` | Security alerts (credential leak, account lockout), data-loss risk (about to overwrite without backup, irreversible deletion in flight), system errors blocking the user from working. The "wake the user at 3 am" tier. |
19
+ | `high` | Hard deadlines firing in the next 8 hours, urgent inbound messages from people the user has flagged as priority, "meeting starting now". Important but not 3 am. |
20
+ | `normal` | Regular reminders (`15 min until standup`), digest-style summaries, single-recipient FYIs the user opted into. **Default.** |
21
+ | `low` | Background updates, observational FYIs the user did not explicitly ask for, optional context. Often better as an Agent Log entry instead of a notification at all. |
18
22
 
19
23
  ## Examples by level
20
24
 
@@ -47,19 +51,18 @@ If the next morning would still be soon enough, it is not `high`.
47
51
  If the user did not opt in to receiving this category of update, do not
48
52
  send `low`. Drop it to an Agent Log entry instead.
49
53
 
50
- ## Rate-limit defaults
51
-
52
- 3/hour, 12/day across all priorities (`critical` bypasses both caps).
53
- The agent CANNOT query `notification_log` directly (Approve-tier). Use
54
- `<today>` `## Agent Log` as the authoritative dedup source (look for
55
- `notify sent` / `DM sent` lines).
56
-
57
- `/api/notify` does NOT report rate-limit or quiet-hours suppression
58
- back to you — it returns `200 {status:"sent"}` even when the message is
59
- silently dropped inside the delivery layer. A `"sent"` response is
60
- therefore not proof the user saw it. Do NOT re-post the same item
61
- hoping for delivery; self-throttle by scanning `<today>` `## Agent Log`
62
- first and log `notify skipped (rate_limited)` when you choose to hold.
63
- If the message is time-critical and the next opportunity arises,
64
- upgrade to `high` (or `critical` if the situation has escalated)
65
- rather than re-sending at the same level.
54
+ ## Delivery semantics
55
+
56
+ `/api/notify` delivers immediately there is no quiet-hours gate, no
57
+ per-priority suppression, and no rate cap on this endpoint. A `200
58
+ {status:"sent"}` means the message was delivered to at least one
59
+ channel; a total delivery failure THROWS and surfaces as HTTP 500 (not
60
+ a silent 200-drop). So `"sent"` IS proof of delivery — do NOT re-post
61
+ the same item on a 200.
62
+
63
+ Noise control is YOUR job, not the endpoint's. The agent CANNOT query
64
+ `notification_log` directly (Approve-tier), so use `<today>` `## Agent
65
+ Log` as the authoritative dedup source (look for `notify sent` / `DM
66
+ sent` lines) and self-throttle before firing. Don't re-send the same
67
+ item at the same level; if the situation has genuinely escalated, raise
68
+ the priority metadata to reflect that.
@@ -29,7 +29,7 @@ delegated mode:
29
29
 
30
30
  ```bash
31
31
  curl -s http://localhost:8321/api/notion/databases
32
- # → { databases: { "<label>": { "id": "<uuid>", "title": "..." }, ... } }
32
+ # → { databases: [ { "label": "<label>", "id": "<uuid>" }, ... ] }
33
33
  ```
34
34
 
35
35
  Resolve label → UUID here BEFORE the `/exec` call so your `task`
@@ -26,7 +26,7 @@ delegated mode:
26
26
 
27
27
  ```bash
28
28
  curl -sS http://localhost:8321/api/notion/databases
29
- # → { databases: { "<label>": { "id": "<uuid>", "title": "..." }, ... } }
29
+ # → { databases: [ { "label": "<label>", "id": "<uuid>" }, ... ] }
30
30
  ```
31
31
 
32
32
  Resolve label → UUID here BEFORE the `/exec` call so your `task`
@@ -26,7 +26,7 @@ delegated mode:
26
26
 
27
27
  ```bash
28
28
  curl -sS http://localhost:8321/api/notion/databases
29
- # → { databases: { "<label>": { "id": "<uuid>", "title": "..." }, ... } }
29
+ # → { databases: [ { "label": "<label>", "id": "<uuid>" }, ... ] }
30
30
  ```
31
31
 
32
32
  Resolve label → UUID here BEFORE the `/exec` call so your `task`