@aitne-sh/aitne 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +464 -0
- package/agent-assets/agent-profiles/_safety.md +26 -0
- package/agent-assets/agent-profiles/conversational.md +33 -0
- package/agent-assets/agent-profiles/docs-qa.md +24 -0
- package/agent-assets/agent-profiles/observer.md +28 -0
- package/agent-assets/agent-profiles/profile-importer.md +63 -0
- package/agent-assets/agent-profiles/proxy.md +28 -0
- package/agent-assets/agent-profiles/routine.md +16 -0
- package/agent-assets/agent-profiles/task.md +18 -0
- package/agent-assets/docs/concepts/agent-day.md +88 -0
- package/agent-assets/docs/concepts/auth-health.md +75 -0
- package/agent-assets/docs/concepts/backends-and-tiers.md +126 -0
- package/agent-assets/docs/concepts/costs-and-quotas.md +103 -0
- package/agent-assets/docs/concepts/delegated-mode.md +223 -0
- package/agent-assets/docs/concepts/memory-model.md +118 -0
- package/agent-assets/docs/concepts/observations.md +80 -0
- package/agent-assets/docs/concepts/process-keys.md +89 -0
- package/agent-assets/docs/concepts/routines.md +108 -0
- package/agent-assets/docs/concepts/safety-and-execution.md +109 -0
- package/agent-assets/docs/concepts/safety-model.md +279 -0
- package/agent-assets/docs/concepts/skills.md +100 -0
- package/agent-assets/docs/features/integrations/calendar.md +92 -0
- package/agent-assets/docs/features/integrations/git.md +95 -0
- package/agent-assets/docs/features/integrations/github.md +170 -0
- package/agent-assets/docs/features/integrations/mail.md +106 -0
- package/agent-assets/docs/features/integrations/notion.md +69 -0
- package/agent-assets/docs/features/integrations/obsidian.md +71 -0
- package/agent-assets/docs/features/lifestyle/git.md +178 -0
- package/agent-assets/docs/features/lifestyle/reading.md +93 -0
- package/agent-assets/docs/features/lifestyle/receipts.md +71 -0
- package/agent-assets/docs/features/lifestyle/travel-bookings.md +44 -0
- package/agent-assets/docs/features/lifestyle/travel-time.md +52 -0
- package/agent-assets/docs/features/memory-files/agent-journal.md +105 -0
- package/agent-assets/docs/features/memory-files/projects.md +56 -0
- package/agent-assets/docs/features/memory-files/roadmap.md +61 -0
- package/agent-assets/docs/features/memory-files/schedule.md +112 -0
- package/agent-assets/docs/features/memory-files/today.md +73 -0
- package/agent-assets/docs/features/memory-files/user-profile.md +81 -0
- package/agent-assets/docs/features/messaging/dashboard-chat.md +93 -0
- package/agent-assets/docs/features/messaging/discord.md +50 -0
- package/agent-assets/docs/features/messaging/overview.md +111 -0
- package/agent-assets/docs/features/messaging/pairing-and-magic-phrase.md +69 -0
- package/agent-assets/docs/features/messaging/slack.md +51 -0
- package/agent-assets/docs/features/messaging/telegram.md +63 -0
- package/agent-assets/docs/features/messaging/whatsapp.md +48 -0
- package/agent-assets/docs/features/operations/activity-and-conversations.md +105 -0
- package/agent-assets/docs/features/operations/approvals.md +58 -0
- package/agent-assets/docs/features/operations/backend-routing.md +62 -0
- package/agent-assets/docs/features/operations/cost-tracking.md +59 -0
- package/agent-assets/docs/features/operations/notifications.md +69 -0
- package/agent-assets/docs/features/operations/quiet-hours.md +106 -0
- package/agent-assets/docs/features/operations/schedule-approaching.md +60 -0
- package/agent-assets/docs/features/routines/custom-routines.md +101 -0
- package/agent-assets/docs/features/routines/evening-review.md +81 -0
- package/agent-assets/docs/features/routines/hourly-check.md +85 -0
- package/agent-assets/docs/features/routines/monthly-review.md +65 -0
- package/agent-assets/docs/features/routines/morning-routine.md +123 -0
- package/agent-assets/docs/features/routines/weekly-review.md +70 -0
- package/agent-assets/docs/getting-started/01-what-is-this.md +192 -0
- package/agent-assets/docs/getting-started/02-first-steps.md +80 -0
- package/agent-assets/docs/getting-started/03-what-can-this-do.md +110 -0
- package/agent-assets/docs/getting-started/04-first-day.md +287 -0
- package/agent-assets/docs/glossary.md +116 -0
- package/agent-assets/docs/guides/add-a-custom-routine.md +71 -0
- package/agent-assets/docs/guides/backup-and-restore.md +54 -0
- package/agent-assets/docs/guides/change-which-model-handles-x.md +47 -0
- package/agent-assets/docs/guides/connect-a-new-mail-account.md +59 -0
- package/agent-assets/docs/guides/import-knowledge-file.md +275 -0
- package/agent-assets/docs/guides/install-and-run.md +72 -0
- package/agent-assets/docs/guides/migrate-machines.md +52 -0
- package/agent-assets/docs/guides/pause-the-agent.md +65 -0
- package/agent-assets/docs/guides/reinstall-cleanly.md +52 -0
- package/agent-assets/docs/guides/setup-wizard.md +107 -0
- package/agent-assets/docs/guides/switch-default-backend.md +60 -0
- package/agent-assets/docs/reference/api.md +51 -0
- package/agent-assets/docs/reference/cli-commands.md +121 -0
- package/agent-assets/docs/reference/config.md +74 -0
- package/agent-assets/docs/reference/disallowed-tools.md +76 -0
- package/agent-assets/docs/reference/keyboard-shortcuts.md +39 -0
- package/agent-assets/docs/reference/process-keys.md +59 -0
- package/agent-assets/docs/reference/skills.md +50 -0
- package/agent-assets/docs/troubleshooting/auth-failed.md +57 -0
- package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +55 -0
- package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +54 -0
- package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +53 -0
- package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +75 -0
- package/agent-assets/docs/troubleshooting/observation-not-detected.md +57 -0
- package/agent-assets/docs/troubleshooting/quota-exhausted.md +57 -0
- package/agent-assets/optimizer-skills/drift-analysis/SKILL.md +75 -0
- package/agent-assets/optimizer-skills/knowledge-map/SKILL.md +71 -0
- package/agent-assets/optimizer-skills/skill-curation/SKILL.md +108 -0
- package/agent-assets/project-doc-templates/git-repo.md +21 -0
- package/agent-assets/project-doc-templates/project.md +38 -0
- package/agent-assets/skills/attach/SKILL.md +104 -0
- package/agent-assets/skills/context/SKILL.md +257 -0
- package/agent-assets/skills/context/curation.json +37 -0
- package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +13 -0
- package/agent-assets/skills/context/seeds/frontmatter-requirements.seed.json +40 -0
- package/agent-assets/skills/docs-search/SKILL.md +176 -0
- package/agent-assets/skills/external-services/SKILL.delegated.claude.md +369 -0
- package/agent-assets/skills/external-services/SKILL.delegated.codex.md +349 -0
- package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +347 -0
- package/agent-assets/skills/external-services/SKILL.md +371 -0
- package/agent-assets/skills/mail/SKILL.delegated.claude.md +284 -0
- package/agent-assets/skills/mail/SKILL.delegated.codex.md +261 -0
- package/agent-assets/skills/mail/SKILL.delegated.gemini.md +255 -0
- package/agent-assets/skills/mail/SKILL.md +313 -0
- package/agent-assets/skills/mail/references/errors.md +17 -0
- package/agent-assets/skills/mail/references/providers.md +40 -0
- package/agent-assets/skills/mail/references/query-grammar.md +24 -0
- package/agent-assets/skills/management-policy/SKILL.md +307 -0
- package/agent-assets/skills/management-policy/curation.json +13 -0
- package/agent-assets/skills/management-policy/seeds/policy-file-shape.seed.json +16 -0
- package/agent-assets/skills/management-task-modify/SKILL.md +202 -0
- package/agent-assets/skills/management-task-register/SKILL.md +330 -0
- package/agent-assets/skills/management-task-stop/SKILL.md +166 -0
- package/agent-assets/skills/notify/SKILL.md +196 -0
- package/agent-assets/skills/notion/SKILL.delegated.claude.md +254 -0
- package/agent-assets/skills/notion/SKILL.delegated.codex.md +195 -0
- package/agent-assets/skills/notion/SKILL.delegated.gemini.md +194 -0
- package/agent-assets/skills/notion/SKILL.md +86 -0
- package/agent-assets/skills/observations/SKILL.md +234 -0
- package/agent-assets/skills/observations/curation.json +13 -0
- package/agent-assets/skills/observations/seeds/source-namespacing.seed.json +20 -0
- package/agent-assets/skills/project-doc/SKILL.md +86 -0
- package/agent-assets/skills/project-doc/curation.json +21 -0
- package/agent-assets/skills/project-doc/seeds/project-shape.seed.json +25 -0
- package/agent-assets/skills/project-doc/seeds/slug-grammar.seed.json +20 -0
- package/agent-assets/skills/reading/SKILL.md +198 -0
- package/agent-assets/skills/reading/references/reading-taste.md +197 -0
- package/agent-assets/skills/receipts/SKILL.md +134 -0
- package/agent-assets/skills/roadmap/SKILL.md +276 -0
- package/agent-assets/skills/roadmap/curation.json +13 -0
- package/agent-assets/skills/roadmap/references/horizon-tags.md +40 -0
- package/agent-assets/skills/roadmap/references/preparation-timeline.md +47 -0
- package/agent-assets/skills/roadmap/seeds/entry-types.seed.json +16 -0
- package/agent-assets/skills/schedule/SKILL.md +228 -0
- package/agent-assets/skills/scheduled-managed-task/SKILL.md +392 -0
- package/agent-assets/skills/today/SKILL.md +198 -0
- package/agent-assets/skills/today/curation.json +21 -0
- package/agent-assets/skills/today/seeds/agent-notes-flavors.seed.json +17 -0
- package/agent-assets/skills/today/seeds/section-shape.seed.json +17 -0
- package/agent-assets/skills/travel/SKILL.md +132 -0
- package/agent-assets/skills/travel-time/SKILL.md +149 -0
- package/agent-assets/skills/user-interview/SKILL.md +323 -0
- package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +94 -0
- package/agent-assets/skills/user-profile/SKILL.md +210 -0
- package/agent-assets/skills/user-profile/curation.json +29 -0
- package/agent-assets/skills/user-profile/seeds/learned-context-format.seed.json +14 -0
- package/agent-assets/skills/user-profile/seeds/routing-table.seed.json +53 -0
- package/agent-assets/skills/user-profile/seeds/topic-files.seed.json +27 -0
- package/agent-assets/task-flows/dashboard.docs_qa.md +43 -0
- package/agent-assets/task-flows/default.md +11 -0
- package/agent-assets/task-flows/git.branch.created.md +25 -0
- package/agent-assets/task-flows/git.lifecycle.poll.md +52 -0
- package/agent-assets/task-flows/git.local_ahead.stale.md +34 -0
- package/agent-assets/task-flows/git.merge_to_default.md +30 -0
- package/agent-assets/task-flows/git.project.refresh_architecture.md +100 -0
- package/agent-assets/task-flows/git.project.retemplate.md +73 -0
- package/agent-assets/task-flows/git.push.detected.md +32 -0
- package/agent-assets/task-flows/git.push.force_pushed.md +36 -0
- package/agent-assets/task-flows/git.tag.created.md +24 -0
- package/agent-assets/task-flows/github.assigned.md +43 -0
- package/agent-assets/task-flows/github.pull_request.review_requested.md +57 -0
- package/agent-assets/task-flows/github.security_alert.md +45 -0
- package/agent-assets/task-flows/github.workflow_run.failed.md +57 -0
- package/agent-assets/task-flows/knowledge.import.md +161 -0
- package/agent-assets/task-flows/message.received.dm.md +142 -0
- package/agent-assets/task-flows/message.received.dm_first.md +117 -0
- package/agent-assets/task-flows/message.received.md +14 -0
- package/agent-assets/task-flows/routine.custom.md +38 -0
- package/agent-assets/task-flows/routine.evening_review.md +323 -0
- package/agent-assets/task-flows/routine.hourly_check.delegated.claude.md +405 -0
- package/agent-assets/task-flows/routine.hourly_check.delegated.codex.md +400 -0
- package/agent-assets/task-flows/routine.hourly_check.delegated.gemini.md +404 -0
- package/agent-assets/task-flows/routine.hourly_check.md +184 -0
- package/agent-assets/task-flows/routine.hourly_check.triage.md +93 -0
- package/agent-assets/task-flows/routine.monthly_review.md +250 -0
- package/agent-assets/task-flows/routine.morning_routine.md +300 -0
- package/agent-assets/task-flows/routine.morning_routine_initial.md +184 -0
- package/agent-assets/task-flows/routine.roadmap_refresh.md +275 -0
- package/agent-assets/task-flows/routine.today_refresh.md +172 -0
- package/agent-assets/task-flows/routine.user_profile_sweep.md +242 -0
- package/agent-assets/task-flows/routine.weekly_review.md +247 -0
- package/agent-assets/task-flows/schedule.approaching.md +124 -0
- package/agent-assets/task-flows/scheduled.dm.md +391 -0
- package/agent-assets/task-flows/scheduled.task.md +141 -0
- package/agent-assets/task-flows/setup.initial.md +277 -0
- package/agent-assets/task-flows/setup.update.md +53 -0
- package/agent-assets/templates/README.md +85 -0
- package/agent-assets/templates/_index.md +39 -0
- package/agent-assets/templates/_manifest.json +103 -0
- package/agent-assets/templates/agent/journal.md +10 -0
- package/agent-assets/templates/agent/profile-questions.md +74 -0
- package/agent-assets/templates/context-index.md +42 -0
- package/agent-assets/templates/dossiers/_index.md +22 -0
- package/agent-assets/templates/dossiers/evening.md +23 -0
- package/agent-assets/templates/dossiers/hourly.md +23 -0
- package/agent-assets/templates/dossiers/monthly.md +23 -0
- package/agent-assets/templates/dossiers/morning.md +23 -0
- package/agent-assets/templates/dossiers/roadmap.md +23 -0
- package/agent-assets/templates/dossiers/weekly.md +23 -0
- package/agent-assets/templates/projects/_active.base +14 -0
- package/agent-assets/templates/projects/_index.md +29 -0
- package/agent-assets/templates/roadmap.md +15 -0
- package/agent-assets/templates/routines/_index.md +20 -0
- package/agent-assets/templates/routines/evening.md +22 -0
- package/agent-assets/templates/routines/hourly.md +30 -0
- package/agent-assets/templates/routines/monthly.md +25 -0
- package/agent-assets/templates/routines/morning.md +26 -0
- package/agent-assets/templates/routines/weekly.md +23 -0
- package/agent-assets/templates/rules/_index.md +19 -0
- package/agent-assets/templates/rules/journal-export.md +41 -0
- package/agent-assets/templates/rules/journal-format.md +61 -0
- package/agent-assets/templates/rules/management.md +48 -0
- package/agent-assets/templates/rules/mcp.md +40 -0
- package/agent-assets/templates/rules/policies/_index.md +22 -0
- package/agent-assets/templates/rules/redaction.md +30 -0
- package/agent-assets/templates/today.md +13 -0
- package/agent-assets/templates/user/_index.md +16 -0
- package/agent-assets/templates/user/expertise.md +7 -0
- package/agent-assets/templates/user/goals.md +7 -0
- package/agent-assets/templates/user/people.md +7 -0
- package/agent-assets/templates/user/personal.md +7 -0
- package/agent-assets/templates/user/profile.md +28 -0
- package/agent-assets/templates/user/work.md +7 -0
- package/bin/aitne.mjs +1096 -0
- package/package.json +78 -0
- package/personal-agent.mjs +39 -0
- package/scripts/browser.mjs +99 -0
- package/scripts/check-redaction-coverage.mjs +109 -0
- package/scripts/commands/audit.mjs +309 -0
- package/scripts/commands/doctor.mjs +437 -0
- package/scripts/commands/open.mjs +40 -0
- package/scripts/commands/setup.mjs +21 -0
- package/scripts/commands/uninstall.mjs +114 -0
- package/scripts/commands/update.mjs +96 -0
- package/scripts/commands/version.mjs +62 -0
- package/scripts/commands.md +0 -0
- package/scripts/lib/sqlite-loader.mjs +49 -0
- package/scripts/message-discipline-digest.mjs +535 -0
- package/scripts/poc/google-connector-inheritance/REPORT.md +197 -0
- package/scripts/poc/google-connector-inheritance/claude-sdk-probe.mjs +79 -0
- package/scripts/remint-roadmap-ids.mjs +257 -0
- package/scripts/rm-paths.mjs +22 -0
- package/scripts/run-node.mjs +223 -0
- package/scripts/smoke-obsidian-api.mjs +166 -0
- package/scripts/start.mjs +160 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: notify
|
|
3
|
+
description: Load whenever composing user-facing text — DMs, notifications, briefings, replies, observer alerts. Owns awareness gate + /api/notify.
|
|
4
|
+
when_to_use: Universal message discipline — awareness gate, no ceremony, no readback. Also covers the evening wrap-up contract and quiet-hours flushing.
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Bash(curl *)
|
|
7
|
+
- Read
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Notification Decision Guide
|
|
11
|
+
|
|
12
|
+
A bad notification (noisy, poorly timed, unclear) is worse than no notification.
|
|
13
|
+
|
|
14
|
+
## Universal user-facing message discipline
|
|
15
|
+
|
|
16
|
+
Every user-facing message — `/api/notify` call, `scheduled.dm`
|
|
17
|
+
final-text DM (Morning briefing), `scheduled.task` final-text DM,
|
|
18
|
+
message.received reply, observer alert — must clear the gates below.
|
|
19
|
+
Specific contracts (Evening wrap-up, Morning briefing) layer
|
|
20
|
+
additional rules on top; nothing they say overrides a universal rule.
|
|
21
|
+
|
|
22
|
+
### Awareness gate
|
|
23
|
+
|
|
24
|
+
The user already knows their own calendar, their own course syllabus,
|
|
25
|
+
their own class times, and the events they themselves set up. Do NOT
|
|
26
|
+
read those items back to them. Lead with what the agent learned from
|
|
27
|
+
input the user could not passively see — new mail, new DM, calendar
|
|
28
|
+
delta, observation, conflict the agent detected, missing prep for a
|
|
29
|
+
known event.
|
|
30
|
+
|
|
31
|
+
Profile-specific carve-outs (e.g. how this gate applies to interactive
|
|
32
|
+
DM replies vs. daemon-initiated DMs) live in the matching persona
|
|
33
|
+
file's pointer line — see `agent-profiles/<profile>.md ## Principles`.
|
|
34
|
+
|
|
35
|
+
### No ceremony
|
|
36
|
+
|
|
37
|
+
The first user-visible line must be a specific fact the agent learned
|
|
38
|
+
or decided since the last message — not a greeting, label, routine
|
|
39
|
+
name, time-of-day opener, or summary header. If a line can be deleted
|
|
40
|
+
without losing information, delete it. **This rule is
|
|
41
|
+
language-agnostic** — it applies whatever language the agent uses
|
|
42
|
+
with the user.
|
|
43
|
+
|
|
44
|
+
Anti-examples (non-exhaustive — the positive rule above is
|
|
45
|
+
load-bearing, not this list): "Good morning!", "Evening check-in —",
|
|
46
|
+
"Morning briefing —", "Summary:", "Done.", "Sent.", "OK.", "Here's
|
|
47
|
+
your day:", "Heads-up —", "FYI:", "Quick update:". Near-synonyms of
|
|
48
|
+
these in any language also fail the positive rule.
|
|
49
|
+
|
|
50
|
+
### No internal mechanism names
|
|
51
|
+
|
|
52
|
+
Never mention `today.md`, `user/profile.md`, `roadmap.md`, `## Agent
|
|
53
|
+
Plan`, `## Agent Log`, `## Handoff`, `did-not-fire`, "Morning
|
|
54
|
+
Routine", "Evening Review", "scheduled.task", "scheduled.dm",
|
|
55
|
+
"dm_session", "sub_flow", or any other internal mechanism in
|
|
56
|
+
user-visible text. Those go in Agent Log only.
|
|
57
|
+
|
|
58
|
+
### No filler timing commentary
|
|
59
|
+
|
|
60
|
+
Forbidden — "Just a heads-up", "Still about N hours to go", "About N
|
|
61
|
+
hours left", "FYI". If timing matters, the deadline / event time
|
|
62
|
+
itself carries it.
|
|
63
|
+
|
|
64
|
+
### No table-of-contents readback
|
|
65
|
+
|
|
66
|
+
Forbidden patterns: "Schedule: ...", "Tasks: ...", "Notes: ...",
|
|
67
|
+
"Deadlines: ...". These enumerate the user's own data; they already
|
|
68
|
+
have it. (`scheduled.dm` Morning briefing has a section-labelled
|
|
69
|
+
output of its own — those labels are sanctioned by that contract; the
|
|
70
|
+
rule above bars *introducing* such enumeration in any other surface.)
|
|
71
|
+
|
|
72
|
+
### Language and style
|
|
73
|
+
|
|
74
|
+
Respond in the user's preferred language. Follow `user/profile.md`
|
|
75
|
+
Communication Style and the Character block in your system prompt.
|
|
76
|
+
Keep technical terms in original form.
|
|
77
|
+
|
|
78
|
+
### Compactness
|
|
79
|
+
|
|
80
|
+
Default to the shortest form that conveys the substance — 1–5 short
|
|
81
|
+
lines. No bullet list > 3 items unless the per-message contract
|
|
82
|
+
explicitly allows it (Morning briefing has its own caps).
|
|
83
|
+
|
|
84
|
+
## When to Notify
|
|
85
|
+
|
|
86
|
+
Notify when **all three** are true: (1) **actionable** or requires awareness, (2) **time-sensitive**, (3) user **not already aware** via another channel. Common: meeting reminders (15 min before), deadline alerts, task completions, error alerts, conversational replies. (Recurring DM-tone messages — Morning briefing — are delivered as the final assistant turn via `scheduled.dm`'s Morning briefing contract and do NOT use this API.)
|
|
87
|
+
|
|
88
|
+
## When NOT to Notify
|
|
89
|
+
|
|
90
|
+
- **Already notified on the same item today** — do a pre-flight dedup
|
|
91
|
+
scan of `<today>` `## Agent Log` for `notify sent` / `DM sent` /
|
|
92
|
+
`[cal] ... — reminder sent` referencing the same item within the
|
|
93
|
+
last 4 hours. If the injected log is truncated (`[...N earlier
|
|
94
|
+
entries omitted ...]` marker) and you can't rule out a prior
|
|
95
|
+
notification, `GET /api/context/today` for the full log before
|
|
96
|
+
firing. Duplicate notifications are the #1 cause of noise.
|
|
97
|
+
- **A pending Agent Plan row / scheduled DM is already set to fire
|
|
98
|
+
for this item within the next 2 hours** — let the planned channel
|
|
99
|
+
deliver; don't pre-empt it.
|
|
100
|
+
- **Quiet hours (default 22:00-08:00, configurable)** unless `critical` — schedule for after instead
|
|
101
|
+
- **Rate-limited (429)** — do NOT retry; log skip to Agent Log. If time-critical, upgrade priority at next opportunity
|
|
102
|
+
- **Routine file changes** or **agent internal state** — use Agent Log instead
|
|
103
|
+
- **When in doubt — prefer silence**
|
|
104
|
+
|
|
105
|
+
Rate-limit defaults: 3/hour, 12/day. The agent CANNOT query
|
|
106
|
+
`notification_log` directly (Approve-tier); use `<today>` `## Agent
|
|
107
|
+
Log` as the authoritative dedup source.
|
|
108
|
+
|
|
109
|
+
## Priority
|
|
110
|
+
|
|
111
|
+
| Priority | Use for | Quiet-hours |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `critical` | Security alerts, data-loss risk, system errors | Bypasses |
|
|
114
|
+
| `high` | Hard deadlines, urgent messages, meeting starting now | Bypasses |
|
|
115
|
+
| `normal` | Regular reminders, summaries, evening wrap-up | Respects (dropped) |
|
|
116
|
+
| `low` | Background updates, informational FYI | Respects (dropped) |
|
|
117
|
+
|
|
118
|
+
**Default to `normal`.** Reserve `high` for 8h-delay-matters. Reserve `critical` for 3am-matters.
|
|
119
|
+
|
|
120
|
+
## Style
|
|
121
|
+
|
|
122
|
+
One notification per task, under 5 bullets, lead with the action, follow the Character block. Actionable > informational: "3 emails from boss — 1 asks for Q2 plan by EOD" beats "3 emails from boss".
|
|
123
|
+
|
|
124
|
+
## Evening wrap-up contract
|
|
125
|
+
|
|
126
|
+
Used by `routine.evening_review`. The prompt owns go/no-go (silence is
|
|
127
|
+
the default; see Step 4a's awareness gate). This section owns format
|
|
128
|
+
rules for the rare evening where the gate plus a positive trigger
|
|
129
|
+
clears the bar.
|
|
130
|
+
|
|
131
|
+
### Content (in user's preferred language)
|
|
132
|
+
|
|
133
|
+
1. **The agent-discovered thing the user needs to know** — the
|
|
134
|
+
specific item that cleared the awareness gate. Lead with substance.
|
|
135
|
+
2. **What's still open** — at most 2 carry-overs with brief reason.
|
|
136
|
+
Omit if nothing.
|
|
137
|
+
3. **What's next** — only if the agent learned something new today
|
|
138
|
+
that affects tomorrow. Omit if it's just the user's own calendar
|
|
139
|
+
reading back to them.
|
|
140
|
+
|
|
141
|
+
Optional 4th line: brief acknowledgement if today was emotionally
|
|
142
|
+
significant.
|
|
143
|
+
|
|
144
|
+
### Format — hard limits
|
|
145
|
+
|
|
146
|
+
- **Maximum 4 short lines.** No markdown headers. No bullet list > 2 items.
|
|
147
|
+
- **No ceremony.** Open with substance, not "Evening Review complete",
|
|
148
|
+
"Summary:", or "Evening check-in —". Any opener that announces the
|
|
149
|
+
routine itself rather than the content is forbidden.
|
|
150
|
+
- **No internal names.** Never mention `today.md`, `user/profile.md`, `roadmap.md`, `## Handoff`, `## Agent Plan`, `## Agent Log`, `did-not-fire`, or "Evening Review".
|
|
151
|
+
- **Don't enumerate agent actions.** Surface only what the user would
|
|
152
|
+
forget by morning AND only things the user couldn't already know
|
|
153
|
+
from their own calendar / syllabus / scheduled events.
|
|
154
|
+
- **No filler timing commentary** ("Still about 6 hours to go", "Just
|
|
155
|
+
a heads-up", etc.) — if the timing matters, the deadline itself
|
|
156
|
+
carries it.
|
|
157
|
+
- **Priority `high`.** The awareness gate raises the bar high enough
|
|
158
|
+
that anything reaching the user tonight genuinely deserves to. One
|
|
159
|
+
notification per evening.
|
|
160
|
+
|
|
161
|
+
### Examples
|
|
162
|
+
|
|
163
|
+
**Good** (agent surfaced something from new mail today that the user
|
|
164
|
+
hasn't seen yet):
|
|
165
|
+
```
|
|
166
|
+
Sarah's reply on the API spec landed at 6pm — she's blocking on your call on the auth contract before tomorrow's standup.
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Bad — ceremony + internal-state recap:**
|
|
170
|
+
```
|
|
171
|
+
Evening Review complete. Summary:
|
|
172
|
+
today.md updates: Agent Plan rows closed as did-not-fire, Handoff carried over.
|
|
173
|
+
user/profile.md: Raw Signals cleared.
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Bad — agent reading the user's own calendar back to them** (the
|
|
177
|
+
exact shape the user has flagged as unwanted; every element fails the
|
|
178
|
+
awareness gate or the no-ceremony rule):
|
|
179
|
+
```
|
|
180
|
+
Evening check-in — [408019] Week 3 deadline tonight at 11:59pm PT:
|
|
181
|
+
Procurement Plan, RACI Chart, Resource Plan. Still about 6 hours to go.
|
|
182
|
+
Tomorrow: Agile class 6–9pm @ UCLA Extension Gayley.
|
|
183
|
+
```
|
|
184
|
+
The course assignment deadline is on the user's own syllabus and the
|
|
185
|
+
class is on their own calendar — both fail the awareness gate. The
|
|
186
|
+
correct response is silence + one line in ## Agent Log.
|
|
187
|
+
|
|
188
|
+
## API Reference — POST /api/notify
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
curl -s -X POST http://localhost:8321/api/notify \
|
|
192
|
+
-H 'Content-Type: application/json' \
|
|
193
|
+
-d '{"message": "Design review starts in 15 minutes.", "priority": "normal"}'
|
|
194
|
+
```
|
|
195
|
+
Fields: `message` (required, markdown), `priority` (optional: critical/high/normal/low), `platform` (optional, override target).
|
|
196
|
+
Response: `{ "status": "sent", "notificationId": "..." }`. Risk tier: `Autonomous` — the agent decides when to notify; recorded in `notification_log` for the on-demand retrospective.
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: notion
|
|
3
|
+
description: Load when the task touches Notion and Notion is in cross-backend delegated mode (DM session is Claude Code; `delegatedBackend` is non-Claude). All Notion operations flow through `POST /api/integrations/notion/exec`; `/api/notion/*` write/read endpoints are not active in this configuration. The label-resolution endpoint `GET /api/notion/databases` remains available.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Bash(curl *)
|
|
6
|
+
- Read
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Notion (delegated, cross-backend)
|
|
10
|
+
|
|
11
|
+
Your DM session runs on Claude Code. Notion access has been delegated
|
|
12
|
+
to a *different* backend (Codex or Gemini) whose Notion connector is
|
|
13
|
+
signed in. **You describe Notion intent in natural language; the
|
|
14
|
+
daemon picks the tool.** Tool name divergence between Codex
|
|
15
|
+
(`search`, `notion_create_pages`), Gemini (`notion-search`,
|
|
16
|
+
`notion-create-pages`) and any custom Notion MCP server the user
|
|
17
|
+
installs is invisible to you.
|
|
18
|
+
|
|
19
|
+
To check which backend currently owns Notion, read
|
|
20
|
+
`~/.personal-agent/integrations.md`. The `/exec` body below is
|
|
21
|
+
backend-agnostic.
|
|
22
|
+
|
|
23
|
+
## 1. Label resolution (still direct)
|
|
24
|
+
|
|
25
|
+
Database UUIDs are unstable; the user's labels (e.g. `"projects"`,
|
|
26
|
+
`"meeting-notes"`) map to UUIDs through the daemon's settings store.
|
|
27
|
+
This route is NOT proxied — it returns the configured map even in
|
|
28
|
+
delegated mode:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
curl -s http://localhost:8321/api/notion/databases
|
|
32
|
+
# → { databases: { "<label>": { "id": "<uuid>", "title": "..." }, ... } }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Resolve label → UUID here BEFORE the `/exec` call so your `task`
|
|
36
|
+
prose carries a concrete data-source URL or UUID.
|
|
37
|
+
|
|
38
|
+
## 2. The single call shape
|
|
39
|
+
|
|
40
|
+
Every Notion operation in this mode is one POST:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
curl -s -X POST http://localhost:8321/api/integrations/notion/exec \
|
|
44
|
+
-H 'Content-Type: application/json' \
|
|
45
|
+
-d '{"task": "<natural-language intent>", "outputSchema": { ... }, "cacheable": true}'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The daemon:
|
|
49
|
+
|
|
50
|
+
1. Verifies Notion is in `mode="delegated"`. If not, you get
|
|
51
|
+
`409 mode_mismatch` — re-read `integrations.md` and stop.
|
|
52
|
+
2. Spawns the delegatedBackend in a tempdir, lets it pick the right
|
|
53
|
+
tool against the per-task allowed-tools envelope, validates the
|
|
54
|
+
final JSON against your `outputSchema`, returns it.
|
|
55
|
+
|
|
56
|
+
`outputSchema` is **required** (4 KB cap). Defaults: `maxToolCalls=7`,
|
|
57
|
+
`maxBudgetUsd=0.05`, `timeoutMs=60000`. Bump up to 15 / 0.50 / 300000
|
|
58
|
+
for genuinely larger intents.
|
|
59
|
+
|
|
60
|
+
## 3. Worked examples
|
|
61
|
+
|
|
62
|
+
### Search + structured listing (read)
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
curl -s -X POST http://localhost:8321/api/integrations/notion/exec \
|
|
66
|
+
-H 'Content-Type: application/json' \
|
|
67
|
+
-d '{
|
|
68
|
+
"task": "List the top-level pages in the Tasks database (data source <UUID>). For each page return the title, status (if a Status property exists), and last-edited timestamp. Sort by last-edited descending.",
|
|
69
|
+
"outputSchema": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"required": ["pages"],
|
|
72
|
+
"properties": {
|
|
73
|
+
"pages": {
|
|
74
|
+
"type": "array",
|
|
75
|
+
"items": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"required": ["id", "title", "lastEditedAt"],
|
|
78
|
+
"properties": {
|
|
79
|
+
"id": {"type": "string"},
|
|
80
|
+
"title": {"type": "string"},
|
|
81
|
+
"status": {"type": "string"},
|
|
82
|
+
"lastEditedAt": {"type": "string", "format": "date-time"}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"maxToolCalls": 5,
|
|
89
|
+
"cacheable": true
|
|
90
|
+
}'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Read a page tree (composition)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
curl -s -X POST http://localhost:8321/api/integrations/notion/exec \
|
|
97
|
+
-H 'Content-Type: application/json' \
|
|
98
|
+
-d '{
|
|
99
|
+
"task": "Fetch Notion page <UUID> and recursively walk its child pages and toggle blocks. Return id, title, depth, and a flat array of text content per page.",
|
|
100
|
+
"outputSchema": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"required": ["nodes"],
|
|
103
|
+
"properties": {
|
|
104
|
+
"nodes": {
|
|
105
|
+
"type": "array",
|
|
106
|
+
"items": {
|
|
107
|
+
"type": "object",
|
|
108
|
+
"required": ["id", "title", "depth", "content"],
|
|
109
|
+
"properties": {
|
|
110
|
+
"id": {"type": "string"},
|
|
111
|
+
"title": {"type": "string"},
|
|
112
|
+
"depth": {"type": "integer"},
|
|
113
|
+
"content": {"type": "string"}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"maxToolCalls": 8,
|
|
120
|
+
"cacheable": true
|
|
121
|
+
}'
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Create a page (destructive — confirmation required)
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
curl -s -X POST http://localhost:8321/api/integrations/notion/exec \
|
|
128
|
+
-H 'Content-Type: application/json' \
|
|
129
|
+
-d '{
|
|
130
|
+
"task": "Create a new page under the Projects database (data source <UUID>) titled \"Migration plan — May\". Body: <BODY>. Properties: Status=\"Active\", Owner=<USER_ID>.",
|
|
131
|
+
"outputSchema": {
|
|
132
|
+
"type": "object",
|
|
133
|
+
"required": ["pageId", "url"],
|
|
134
|
+
"properties": {
|
|
135
|
+
"pageId": {"type": "string"},
|
|
136
|
+
"url": {"type": "string"}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"allowDestructive": true
|
|
140
|
+
}'
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## 4. Destructive-confirm two-step (`allowDestructive`)
|
|
144
|
+
|
|
145
|
+
Default is `false`. The subprocess will not run create / update /
|
|
146
|
+
delete / move / duplicate / comment — instead it returns:
|
|
147
|
+
|
|
148
|
+
```jsonc
|
|
149
|
+
{
|
|
150
|
+
"needsConfirmation": true,
|
|
151
|
+
"confirmationPlan": "I will create a new page titled \"Migration plan — May\" under the Projects database with status \"Active\"."
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Surface `confirmationPlan` to the user verbatim. On their explicit OK,
|
|
156
|
+
re-issue the **same `task` verbatim** with `allowDestructive: true`.
|
|
157
|
+
Never set `cacheable: true` on the second call.
|
|
158
|
+
|
|
159
|
+
## 5. `cacheable: true` for read-only Notion lookups
|
|
160
|
+
|
|
161
|
+
Page reads, database queries, and search results are good cache
|
|
162
|
+
candidates — Notion's content rarely changes minute-to-minute and
|
|
163
|
+
follow-up reads are common. 60s TTL. Skip caching when the user
|
|
164
|
+
explicitly asked about a recent edit, and never set on writes or the
|
|
165
|
+
destructive-confirm second call.
|
|
166
|
+
|
|
167
|
+
## 6. Decision rules
|
|
168
|
+
|
|
169
|
+
### Page archive — workaround only
|
|
170
|
+
|
|
171
|
+
Neither hosted connector exposes a page-archive tool. Pre-existing
|
|
172
|
+
direct-mode trash via `DELETE /api/notion/pages/:id` is unavailable
|
|
173
|
+
here. Phrase the intent as one of:
|
|
174
|
+
|
|
175
|
+
1. **Property workaround** (preferred when the page lives in a
|
|
176
|
+
database with a Status property): "Set Status = Archived on page
|
|
177
|
+
<UUID>." The page stays addressable but drops out of default
|
|
178
|
+
views.
|
|
179
|
+
2. **Move to a "Trash" page**: "Move page <UUID> under the top-level
|
|
180
|
+
Trash page (creating Trash if it doesn't exist)." Reversible
|
|
181
|
+
without admin intervention.
|
|
182
|
+
|
|
183
|
+
Tell the user when neither option fits — never silently leave a page
|
|
184
|
+
visible the user asked to remove.
|
|
185
|
+
|
|
186
|
+
### Schema admin — Approve-tier intent
|
|
187
|
+
|
|
188
|
+
Database / view / data-source mutations change workspace structure.
|
|
189
|
+
Surface what you'd do before invoking, and ask the user. Do not
|
|
190
|
+
auto-confirm "this looks right".
|
|
191
|
+
|
|
192
|
+
### Mass-update — ask first
|
|
193
|
+
|
|
194
|
+
The connectors accept up to 100 pages per create call. If the user
|
|
195
|
+
asks for a batch operation that would touch more than ~10 pages,
|
|
196
|
+
summarize the plan and ask before executing.
|
|
197
|
+
|
|
198
|
+
### Structured database filtering
|
|
199
|
+
|
|
200
|
+
When the user asks "what tasks are in status X" or anything that maps
|
|
201
|
+
to `WHERE <property> = ...`, phrase the intent as the WHERE clause
|
|
202
|
+
and let the subprocess pick the right primitive
|
|
203
|
+
(`notion_query_data_sources` SQL on Codex, filtered `notion-search`
|
|
204
|
+
on Gemini, etc.).
|
|
205
|
+
|
|
206
|
+
## 7. Error envelope
|
|
207
|
+
|
|
208
|
+
`/exec` extends the direct-mode envelope with delegated-mode fields.
|
|
209
|
+
Discriminator: `body.mode === "delegated"`.
|
|
210
|
+
|
|
211
|
+
| HTTP | `error` | retry? | What to do |
|
|
212
|
+
|---|---|---|---|
|
|
213
|
+
| 400 | `validation_error` / `schema_too_large` | no | Fix the request body. |
|
|
214
|
+
| 409 | `mode_mismatch` | no | Notion isn't delegated. Re-read `integrations.md` and stop. |
|
|
215
|
+
| 409 | `precondition` | no | Mode/backend flipped during the queue wait. Re-check state. |
|
|
216
|
+
| 429 | `task_quota_exhausted` | no | Daily cap reached. Wait or surface. |
|
|
217
|
+
| 502 | `parse_error` / `schema_violation` | no (daemon already retried once) | Simplify schema. |
|
|
218
|
+
| 502 | `tool_unavailable` | no | No connector tool fits. Surface the gap. |
|
|
219
|
+
| 502 | `tool_failed` | maybe | Connector tool returned an error. Surface verbatim. |
|
|
220
|
+
| 502 | `auth_error` | no | Connector signed out. Re-authenticate. |
|
|
221
|
+
| 502 | `policy_violation` | no | Subprocess attempted an out-of-allowlist tool (anti-injection). |
|
|
222
|
+
| 502 | `loop_aborted` | no | `maxToolCalls` exceeded. Bump or simplify. |
|
|
223
|
+
| 502 | `budget_exhausted` | no | `maxBudgetUsd` exceeded. Caller can raise the cap. |
|
|
224
|
+
| 502 | `post_write_format_failure` | no | Write succeeded; formatting failed. Surface with partial trace. |
|
|
225
|
+
| 503 | `delegated_proxy_busy` | yes | Queue saturated. Backoff and retry once. |
|
|
226
|
+
| 503 | `task_mode_disabled` | no | Operator killed it. Stop. |
|
|
227
|
+
| 504 | `timeout` | yes (1×) | Wall-clock fired. Retry once. |
|
|
228
|
+
| 500 | `subprocess_crashed` | no | Daemon-side defect. Surface and stop. |
|
|
229
|
+
|
|
230
|
+
Always preserve `body.message` verbatim when reporting to the user.
|
|
231
|
+
|
|
232
|
+
## 8. Owner notification (opt-in)
|
|
233
|
+
|
|
234
|
+
The daemon does not auto-DM the owner. When you take an action you
|
|
235
|
+
judge the user wants to know about *now* — archiving a stack of pages,
|
|
236
|
+
moving content out of a long-lived database, posting a public comment
|
|
237
|
+
— call:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
curl -s -X POST http://localhost:8321/api/notify \
|
|
241
|
+
-H 'Content-Type: application/json' \
|
|
242
|
+
-d '{"message": "Archived 7 stale pages under the <db> database."}'
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Do not call `/api/notify` for routine reads or single-page edits.
|
|
246
|
+
|
|
247
|
+
## 9. Cost attribution
|
|
248
|
+
|
|
249
|
+
Every `/exec` writes one row to `agent_actions` with
|
|
250
|
+
`action_type='delegated_task.exec'`, full token + USD breakdown, and
|
|
251
|
+
the parent `event_id` / `processKey` (the daemon attaches both via
|
|
252
|
+
session env vars). Retrospective calls
|
|
253
|
+
(`GET /api/agent/actions?kind=delegated_task.exec`) surface exactly
|
|
254
|
+
what was spent.
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: notion
|
|
3
|
+
description: Load when the task touches Notion and Notion is in cross-backend delegated mode (DM session is Codex CLI; `delegatedBackend` is non-Codex). All Notion operations flow through `POST /api/integrations/notion/exec`; `/api/notion/*` write/read endpoints are not active in this configuration. The label-resolution endpoint `GET /api/notion/databases` remains available.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Notion (delegated, cross-backend)
|
|
7
|
+
|
|
8
|
+
Your DM session runs on Codex CLI. Notion access has been delegated
|
|
9
|
+
to a *different* backend (Claude or Gemini) whose Notion connector is
|
|
10
|
+
signed in. **You describe Notion intent in natural language; the
|
|
11
|
+
daemon picks the tool.** Tool name divergence between Claude
|
|
12
|
+
(`notion-search`, `notion-create-pages`), Gemini (same hyphenated
|
|
13
|
+
form via the user's installed Notion MCP server) and any custom
|
|
14
|
+
Notion MCP server is invisible to you.
|
|
15
|
+
|
|
16
|
+
To check which backend currently owns Notion, read
|
|
17
|
+
`~/.personal-agent/integrations.md`. The `/exec` body below is
|
|
18
|
+
backend-agnostic.
|
|
19
|
+
|
|
20
|
+
## 1. Label resolution (still direct)
|
|
21
|
+
|
|
22
|
+
Database UUIDs are unstable; the user's labels (e.g. `"projects"`,
|
|
23
|
+
`"meeting-notes"`) map to UUIDs through the daemon's settings store.
|
|
24
|
+
This route is NOT proxied — it returns the configured map even in
|
|
25
|
+
delegated mode:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
curl -sS http://localhost:8321/api/notion/databases
|
|
29
|
+
# → { databases: { "<label>": { "id": "<uuid>", "title": "..." }, ... } }
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Resolve label → UUID here BEFORE the `/exec` call so your `task`
|
|
33
|
+
prose carries a concrete data-source URL or UUID.
|
|
34
|
+
|
|
35
|
+
## 2. The single call shape
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
curl -sS -X POST http://localhost:8321/api/integrations/notion/exec \
|
|
39
|
+
-H 'Content-Type: application/json' \
|
|
40
|
+
-d '{"task": "<natural-language intent>", "outputSchema": { ... }, "cacheable": true}'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The daemon:
|
|
44
|
+
|
|
45
|
+
1. Verifies Notion is in `mode="delegated"`. If not, you get
|
|
46
|
+
`409 mode_mismatch` — re-read `integrations.md` and stop.
|
|
47
|
+
2. Spawns the delegatedBackend in a tempdir, lets it pick the right
|
|
48
|
+
tool against the per-task allowed-tools envelope, validates the
|
|
49
|
+
final JSON against your `outputSchema`, returns it.
|
|
50
|
+
|
|
51
|
+
`outputSchema` is **required** (4 KB cap). Defaults: `maxToolCalls=7`,
|
|
52
|
+
`maxBudgetUsd=0.05`, `timeoutMs=60000`. Bump up to 15 / 0.50 / 300000
|
|
53
|
+
for genuinely larger intents.
|
|
54
|
+
|
|
55
|
+
## 3. Worked examples
|
|
56
|
+
|
|
57
|
+
### Search + structured listing (read)
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
curl -sS -X POST http://localhost:8321/api/integrations/notion/exec \
|
|
61
|
+
-H 'Content-Type: application/json' \
|
|
62
|
+
-d '{
|
|
63
|
+
"task": "List the top-level pages in the Tasks database (data source <UUID>). For each page return the title, status (if a Status property exists), and last-edited timestamp. Sort by last-edited descending.",
|
|
64
|
+
"outputSchema": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"required": ["pages"],
|
|
67
|
+
"properties": {
|
|
68
|
+
"pages": {
|
|
69
|
+
"type": "array",
|
|
70
|
+
"items": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"required": ["id", "title", "lastEditedAt"],
|
|
73
|
+
"properties": {
|
|
74
|
+
"id": {"type": "string"},
|
|
75
|
+
"title": {"type": "string"},
|
|
76
|
+
"status": {"type": "string"},
|
|
77
|
+
"lastEditedAt": {"type": "string", "format": "date-time"}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"maxToolCalls": 5,
|
|
84
|
+
"cacheable": true
|
|
85
|
+
}'
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Create a page (destructive — confirmation required)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
curl -sS -X POST http://localhost:8321/api/integrations/notion/exec \
|
|
92
|
+
-H 'Content-Type: application/json' \
|
|
93
|
+
-d '{
|
|
94
|
+
"task": "Create a new page under the Projects database (data source <UUID>) titled \"Migration plan — May\". Body: <BODY>. Properties: Status=\"Active\", Owner=<USER_ID>.",
|
|
95
|
+
"outputSchema": {
|
|
96
|
+
"type": "object",
|
|
97
|
+
"required": ["pageId", "url"],
|
|
98
|
+
"properties": {
|
|
99
|
+
"pageId": {"type": "string"},
|
|
100
|
+
"url": {"type": "string"}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"allowDestructive": true
|
|
104
|
+
}'
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 4. Destructive-confirm two-step (`allowDestructive`)
|
|
108
|
+
|
|
109
|
+
Default is `false`. The subprocess will not run create / update /
|
|
110
|
+
delete / move / duplicate / comment — instead it returns:
|
|
111
|
+
|
|
112
|
+
```jsonc
|
|
113
|
+
{
|
|
114
|
+
"needsConfirmation": true,
|
|
115
|
+
"confirmationPlan": "I will create a new page titled \"Migration plan — May\" under the Projects database with status \"Active\"."
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Surface the plan to the user verbatim. On their explicit OK, re-issue
|
|
120
|
+
the **same `task` verbatim** with `allowDestructive: true`. Never set
|
|
121
|
+
`cacheable: true` on the second call.
|
|
122
|
+
|
|
123
|
+
## 5. `cacheable: true` for read-only Notion lookups
|
|
124
|
+
|
|
125
|
+
60s TTL — well-suited to follow-up reads on the same page tree. Skip
|
|
126
|
+
caching when the user explicitly asked about a recent edit, and never
|
|
127
|
+
on writes or the destructive-confirm second call.
|
|
128
|
+
|
|
129
|
+
## 6. Decision rules
|
|
130
|
+
|
|
131
|
+
### Page archive — workaround only
|
|
132
|
+
|
|
133
|
+
Neither hosted connector exposes a page-archive tool. Phrase the
|
|
134
|
+
intent as one of:
|
|
135
|
+
|
|
136
|
+
1. **Property workaround**: "Set Status = Archived on page <UUID>."
|
|
137
|
+
Page stays addressable but drops out of default views.
|
|
138
|
+
2. **Move to a Trash page**: "Move page <UUID> under the top-level
|
|
139
|
+
Trash page (creating Trash if it doesn't exist)." Reversible.
|
|
140
|
+
|
|
141
|
+
### Schema admin — Approve-tier intent
|
|
142
|
+
|
|
143
|
+
Database / view / data-source mutations change workspace structure.
|
|
144
|
+
Surface what you'd do before invoking, and ask the user.
|
|
145
|
+
|
|
146
|
+
### Mass-update — ask first
|
|
147
|
+
|
|
148
|
+
If the intent would touch more than ~10 pages, summarize the plan and
|
|
149
|
+
ask before executing.
|
|
150
|
+
|
|
151
|
+
### Structured database filtering
|
|
152
|
+
|
|
153
|
+
Phrase property-equality intents as the WHERE clause; the subprocess
|
|
154
|
+
picks the right primitive whichever connector is active.
|
|
155
|
+
|
|
156
|
+
## 7. Error envelope
|
|
157
|
+
|
|
158
|
+
| HTTP | `error` | retry? | What to do |
|
|
159
|
+
|---|---|---|---|
|
|
160
|
+
| 400 | `validation_error` / `schema_too_large` | no | Fix the request body. |
|
|
161
|
+
| 409 | `mode_mismatch` | no | Notion isn't delegated. Re-read `integrations.md` and stop. |
|
|
162
|
+
| 409 | `precondition` | no | Mode/backend flipped during the queue wait. Re-check state. |
|
|
163
|
+
| 429 | `task_quota_exhausted` | no | Daily cap reached. Wait or surface. |
|
|
164
|
+
| 502 | `parse_error` / `schema_violation` | no (daemon already retried once) | Simplify schema. |
|
|
165
|
+
| 502 | `tool_unavailable` | no | No connector tool fits. Surface the gap. |
|
|
166
|
+
| 502 | `tool_failed` | maybe | Connector tool returned an error. Surface verbatim. |
|
|
167
|
+
| 502 | `auth_error` | no | Connector signed out. Re-authenticate. |
|
|
168
|
+
| 502 | `policy_violation` | no | Subprocess attempted an out-of-allowlist tool (anti-injection). |
|
|
169
|
+
| 502 | `loop_aborted` | no | `maxToolCalls` exceeded. Bump or simplify. |
|
|
170
|
+
| 502 | `budget_exhausted` | no | `maxBudgetUsd` exceeded. Caller can raise the cap. |
|
|
171
|
+
| 502 | `post_write_format_failure` | no | Write succeeded; formatting failed. Surface with partial trace. |
|
|
172
|
+
| 503 | `delegated_proxy_busy` | yes | Queue saturated. Backoff and retry once. |
|
|
173
|
+
| 503 | `task_mode_disabled` | no | Operator killed it. Stop. |
|
|
174
|
+
| 504 | `timeout` | yes (1×) | Wall-clock fired. Retry once. |
|
|
175
|
+
| 500 | `subprocess_crashed` | no | Daemon-side defect. Surface and stop. |
|
|
176
|
+
|
|
177
|
+
Always preserve `body.message` verbatim when reporting to the user.
|
|
178
|
+
|
|
179
|
+
## 8. Owner notification (opt-in)
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
curl -sS -X POST http://localhost:8321/api/notify \
|
|
183
|
+
-H 'Content-Type: application/json' \
|
|
184
|
+
-d '{"message": "Archived 7 stale pages under the <db> database."}'
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Do not call `/api/notify` for routine reads or single-page edits.
|
|
188
|
+
|
|
189
|
+
## 9. Cost attribution
|
|
190
|
+
|
|
191
|
+
Every `/exec` writes one row to `agent_actions` with
|
|
192
|
+
`action_type='delegated_task.exec'`, full token + USD breakdown, and
|
|
193
|
+
the parent `event_id` / `processKey`. Retrospective calls
|
|
194
|
+
(`GET /api/agent/actions?kind=delegated_task.exec`) surface exactly
|
|
195
|
+
what was spent.
|