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