@aitne-sh/aitne 0.1.10 → 0.1.12
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 +12 -8
- package/agent-assets/agent-profiles/background-task.md +53 -0
- package/agent-assets/agent-profiles/conversational.md +1 -0
- package/agent-assets/agent-profiles/routine-fetch-window.md +14 -75
- package/agent-assets/agent-profiles/routine.md +1 -1
- package/agent-assets/agents/{hourly-check → activity-scan}/agent.md +22 -17
- package/agent-assets/agents/monthly-review/agent.md +6 -5
- package/agent-assets/agents/morning-routine/agent.md +3 -4
- package/agent-assets/docs/concepts/agent-day.md +4 -5
- package/agent-assets/docs/concepts/auth-health.md +23 -20
- package/agent-assets/docs/concepts/backends-and-tiers.md +25 -18
- package/agent-assets/docs/concepts/costs-and-quotas.md +11 -10
- package/agent-assets/docs/concepts/delegated-mode.md +13 -12
- package/agent-assets/docs/concepts/memory-model.md +13 -9
- package/agent-assets/docs/concepts/observations.md +24 -20
- package/agent-assets/docs/concepts/process-keys.md +10 -9
- package/agent-assets/docs/concepts/routines.md +34 -31
- package/agent-assets/docs/concepts/safety-and-execution.md +11 -7
- package/agent-assets/docs/concepts/safety-model.md +19 -8
- package/agent-assets/docs/concepts/skills.md +10 -8
- package/agent-assets/docs/features/integrations/browser-history.md +14 -10
- package/agent-assets/docs/features/integrations/calendar.md +24 -13
- package/agent-assets/docs/features/integrations/git.md +13 -11
- package/agent-assets/docs/features/integrations/github.md +22 -14
- package/agent-assets/docs/features/integrations/mail.md +22 -20
- package/agent-assets/docs/features/integrations/notion.md +35 -11
- package/agent-assets/docs/features/integrations/obsidian.md +8 -8
- package/agent-assets/docs/features/lifestyle/git.md +24 -20
- package/agent-assets/docs/features/lifestyle/reading.md +5 -3
- package/agent-assets/docs/features/lifestyle/receipts.md +11 -10
- package/agent-assets/docs/features/memory-files/agent-journal.md +25 -16
- package/agent-assets/docs/features/memory-files/agent-lessons.md +7 -6
- package/agent-assets/docs/features/memory-files/projects.md +5 -4
- package/agent-assets/docs/features/memory-files/schedule.md +6 -3
- package/agent-assets/docs/features/memory-files/today.md +10 -7
- package/agent-assets/docs/features/memory-files/user-profile.md +14 -9
- package/agent-assets/docs/features/messaging/bang-commands.md +21 -6
- package/agent-assets/docs/features/messaging/dashboard-chat.md +1 -1
- package/agent-assets/docs/features/messaging/overview.md +12 -9
- package/agent-assets/docs/features/operations/activity-and-conversations.md +1 -1
- package/agent-assets/docs/features/operations/browser-tasks.md +184 -0
- package/agent-assets/docs/features/operations/cost-tracking.md +11 -1
- package/agent-assets/docs/features/operations/managed-chromium.md +1 -0
- package/agent-assets/docs/features/operations/notifications.md +11 -1
- package/agent-assets/docs/features/operations/quiet-hours.md +41 -12
- package/agent-assets/docs/features/operations/schedule-approaching.md +2 -2
- package/agent-assets/docs/features/routines/activity-scan.md +220 -0
- package/agent-assets/docs/features/routines/custom-routines.md +82 -138
- package/agent-assets/docs/features/routines/evening-review.md +14 -12
- package/agent-assets/docs/features/routines/morning-routine.md +5 -4
- package/agent-assets/docs/features/routines/weekly-review.md +18 -3
- package/agent-assets/docs/features/wiki/commands.md +1 -1
- package/agent-assets/docs/features/wiki/dashboard.md +1 -1
- package/agent-assets/docs/getting-started/01-what-is-this.md +4 -4
- package/agent-assets/docs/getting-started/04-first-day.md +27 -30
- package/agent-assets/docs/glossary.md +8 -7
- package/agent-assets/docs/guides/add-a-custom-routine.md +122 -68
- package/agent-assets/docs/guides/budget-and-cost-for-wiki.md +5 -3
- package/agent-assets/docs/guides/change-which-model-handles-x.md +1 -1
- package/agent-assets/docs/guides/multiple-wikis-for-multiple-domains.md +1 -1
- package/agent-assets/docs/guides/pause-the-agent.md +22 -20
- package/agent-assets/docs/guides/reinstall-cleanly.md +2 -0
- package/agent-assets/docs/guides/setup-wizard.md +13 -10
- package/agent-assets/docs/reference/api.md +11 -0
- package/agent-assets/docs/reference/config.md +30 -20
- package/agent-assets/docs/reference/keyboard-shortcuts.md +2 -2
- package/agent-assets/docs/reference/knowledge-layout.md +14 -10
- package/agent-assets/docs/reference/process-keys.md +7 -7
- package/agent-assets/docs/reference/skills.md +5 -2
- package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +32 -16
- package/agent-assets/docs/troubleshooting/observation-not-detected.md +26 -24
- package/agent-assets/docs/troubleshooting/wiki-ingest-full-blocked.md +1 -1
- package/agent-assets/docs/troubleshooting/wiki-write-failed.md +3 -3
- package/agent-assets/playbooks/markdown-note.md +43 -0
- package/agent-assets/playbooks/monitoring.md +29 -0
- package/agent-assets/playbooks/research.md +47 -0
- package/agent-assets/skills/agent-create/SKILL.md +45 -29
- package/agent-assets/skills/agent-create/references/prompt-frame-extended.md +132 -0
- package/agent-assets/skills/agent-create/references/prompt-frame.md +125 -0
- package/agent-assets/skills/background-task/SKILL.md +184 -0
- package/agent-assets/skills/background-task-reply/SKILL.md +100 -0
- package/agent-assets/skills/board/SKILL.md +93 -0
- package/agent-assets/skills/browser-history/SKILL.md +34 -16
- package/agent-assets/skills/browser-history-respond/SKILL.md +3 -3
- package/agent-assets/skills/browser-task/SKILL.md +14 -7
- package/agent-assets/skills/context/SKILL.md +4 -3
- package/agent-assets/skills/context/references/api.md +5 -3
- package/agent-assets/skills/context/references/snapshot-files.md +4 -4
- package/agent-assets/skills/external-services/SKILL.native.claude.md +13 -7
- package/agent-assets/skills/external-services/SKILL.native.codex.md +11 -5
- package/agent-assets/skills/external-services/SKILL.native.gemini.md +11 -5
- package/agent-assets/skills/mail/SKILL.md +2 -2
- package/agent-assets/skills/mail/SKILL.native.claude.md +16 -9
- package/agent-assets/skills/mail/SKILL.native.codex.md +15 -8
- package/agent-assets/skills/mail/SKILL.native.gemini.md +11 -5
- package/agent-assets/skills/managed-tasks/references/recurrence-rule.md +20 -12
- package/agent-assets/skills/management-policy/SKILL.md +26 -17
- package/agent-assets/skills/management-policy/curation.json +1 -1
- package/agent-assets/skills/management-policy/references/policy-workflow.md +26 -13
- package/agent-assets/skills/notify/SKILL.md +10 -5
- package/agent-assets/skills/notify/references/priority.md +30 -17
- package/agent-assets/skills/notion/SKILL.md +1 -1
- package/agent-assets/skills/notion/SKILL.native.claude.md +3 -3
- package/agent-assets/skills/notion/SKILL.native.codex.md +2 -2
- package/agent-assets/skills/notion/SKILL.native.gemini.md +2 -2
- package/agent-assets/skills/observations/SKILL.md +5 -5
- package/agent-assets/skills/roadmap/references/api.md +7 -2
- package/agent-assets/skills/schedule/SKILL.md +26 -15
- package/agent-assets/skills/schedule/references/batch.md +1 -1
- package/agent-assets/skills/schedule/references/model-selection.md +1 -1
- package/agent-assets/skills/schedule/references/prompt-frame.md +125 -0
- package/agent-assets/skills/schedule/references/recurrence-rule.md +20 -12
- package/agent-assets/skills/scheduled-managed-task/SKILL.md +12 -9
- package/agent-assets/skills/task/SKILL.md +79 -0
- package/agent-assets/skills/today/SKILL.md +19 -3
- package/agent-assets/skills/today/references/agent-plan-lifecycle.md +9 -4
- package/agent-assets/skills/today/references/agent-plan-revision.md +28 -0
- package/agent-assets/skills/today/references/today-skeleton.md +5 -5
- package/agent-assets/skills/user-interview/references/op-morning.md +1 -1
- package/agent-assets/system-prompts/routine-research-cluster-update.md +71 -0
- package/agent-assets/task-flows/_partials/notion-acquire.notion.md +47 -21
- package/agent-assets/task-flows/background_task.md +81 -0
- package/agent-assets/task-flows/git.local_ahead.stale.md +1 -1
- package/agent-assets/task-flows/git.push.detected.md +1 -1
- package/agent-assets/task-flows/git.tag.created.md +1 -1
- package/agent-assets/task-flows/github.assigned.md +1 -1
- package/agent-assets/task-flows/github.pull_request.review_requested.md +2 -2
- package/agent-assets/task-flows/github.security_alert.md +1 -1
- package/agent-assets/task-flows/message.received.dm.md +7 -3
- package/agent-assets/task-flows/message.received.dm_first.md +4 -2
- package/agent-assets/task-flows/{routine.hourly_check.md → routine.activity_scan.md} +31 -23
- package/agent-assets/task-flows/{routine.hourly_check.triage.md → routine.activity_scan.triage.md} +3 -3
- package/agent-assets/task-flows/routine.monthly_review.md +9 -8
- package/agent-assets/task-flows/routine.research_cluster_update.md +33 -19
- package/agent-assets/task-flows/routine.roadmap_refresh.md +2 -2
- package/agent-assets/task-flows/routine.today_refresh.md +1 -1
- package/agent-assets/task-flows/routine.weekly_review.md +103 -4
- package/agent-assets/task-flows/schedule.approaching.md +2 -2
- package/agent-assets/task-flows/scheduled.dm.md +96 -12
- package/agent-assets/task-flows/scheduled.task.md +7 -1
- package/agent-assets/templates/_manifest.json +2 -2
- package/agent-assets/templates/knowledge/dossiers/_index.md +1 -1
- package/agent-assets/templates/knowledge/dossiers/{hourly.md → activity-scan.md} +1 -1
- package/agent-assets/templates/policies/journal-format.md +1 -1
- package/agent-assets/templates/policies/mcp.md +1 -1
- package/agent-assets/templates/policies/routines/_index.md +1 -1
- package/agent-assets/templates/policies/routines/{hourly.md → activity-scan.md} +5 -5
- package/package.json +6 -5
- package/agent-assets/docs/features/routines/hourly-check.md +0 -205
|
@@ -90,10 +90,23 @@ Fields:
|
|
|
90
90
|
fires. Only shapes that map are actually run: minute a single value; hour a
|
|
91
91
|
single value or `*` / `*/N`. Pick one explicit, mappable cadence.
|
|
92
92
|
- **`schedule.timezone`** — IANA zone; omit to inherit the daemon default.
|
|
93
|
+
- **`schedule.defer_in_quiet_hours`** — boolean, default `false`. When `true`, a
|
|
94
|
+
firing that lands inside the user's quiet hours is pushed to the window's end
|
|
95
|
+
instead of running — the whole run moves, so the data is fresh at delivery
|
|
96
|
+
time. Mechanical rule: **set `true` whenever the Expected output includes
|
|
97
|
+
DMing the user**; leave it `false` for silent file-writing work deliberately
|
|
98
|
+
scheduled overnight.
|
|
93
99
|
- **`backend`** — optional. `tier` is `lite`/`medium`/`high` (cost/capability knob;
|
|
94
100
|
the standalone control that works). `process_key` defaults to `agent.task`;
|
|
95
101
|
omit unless you know you need another. (Pinning a backend *engine* without a
|
|
96
102
|
`model` is a known no-op — prefer `tier`.)
|
|
103
|
+
- **`playbooks`** — optional array of operating-playbook slugs to inject into the
|
|
104
|
+
Agent's prompt at fire time: `research`, `markdown-note`, `monitoring`. Declaring
|
|
105
|
+
one makes the daemon inject that playbook's full methodology into every run — a
|
|
106
|
+
hard guarantee, and the only way the methodology reaches the Agent (there is no
|
|
107
|
+
separate skill copy). **Declare every playbook you name in the prompt's
|
|
108
|
+
`# Important`** — a bare mention is not injected on its own. An unknown slug is
|
|
109
|
+
rejected as `invalid_definition` on field `playbooks`.
|
|
97
110
|
- **`prompt`** — the Agent's instructions (the Markdown body). **This is the most
|
|
98
111
|
important field. Write it in detail.**
|
|
99
112
|
|
|
@@ -104,43 +117,46 @@ Fields:
|
|
|
104
117
|
> management rules). It does NOT remember this conversation or why you created
|
|
105
118
|
> it. An under-specified prompt produces a vague, drifting Agent.
|
|
106
119
|
|
|
107
|
-
|
|
120
|
+
Author every Agent prompt with the **canonical frame** below, and resolve any
|
|
121
|
+
missing required slot with the user *before* you `POST /api/agents` (clarify-back).
|
|
108
122
|
|
|
109
|
-
|
|
110
|
-
|---|---|
|
|
111
|
-
| **Requirements / preconditions** | What must be true / what inputs to read first (files, APIs, accounts). What to do if a precondition is missing. |
|
|
112
|
-
| **Goal** | The single outcome this Agent exists to produce, stated concretely. |
|
|
113
|
-
| **Process** | The ordered steps to run each firing — specific verbs, endpoints, filenames, decision rules. |
|
|
114
|
-
| **Expected output** | What "done" looks like: which file/section is written, whether/when to DM the user, what NOT to do. |
|
|
123
|
+
{{> ref:prompt-frame }}
|
|
115
124
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
to the Agent Log and exit without DMing.
|
|
125
|
-
|
|
126
|
-
## Process
|
|
127
|
-
1. GET unread mail from the last 24h.
|
|
128
|
-
2. Classify: actionable-today / FYI / ignore (rules: …).
|
|
129
|
-
3. Append a "## Inbox triage" section to state/today.md with the actionable set.
|
|
130
|
-
4. DM the user ONLY if ≥1 item is time-sensitive today.
|
|
131
|
-
|
|
132
|
-
## Output
|
|
133
|
-
- today.md updated with the triage section.
|
|
134
|
-
- At most one DM, sent only for time-sensitive items.
|
|
125
|
+
### Declare the playbooks you reference
|
|
126
|
+
|
|
127
|
+
Whenever the prompt's `# Important` names a playbook, ALSO list its slug in the
|
|
128
|
+
top-level `playbooks` field so the daemon injects that methodology into every
|
|
129
|
+
firing as a hard guarantee — not just a by-reference skill the Agent might skip:
|
|
130
|
+
|
|
131
|
+
```json
|
|
132
|
+
"playbooks": ["research", "markdown-note"]
|
|
135
133
|
```
|
|
136
134
|
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
Valid slugs: `research`, `markdown-note`, `monitoring`. If you name a playbook in
|
|
136
|
+
the prompt but forget to declare it, the create response returns a `warnings[]`
|
|
137
|
+
entry (`playbook_referenced_not_declared`) — read it and add the missing slug.
|
|
138
|
+
|
|
139
|
+
### Operational (state-mutating) Agents — extend the frame
|
|
140
|
+
|
|
141
|
+
Most Agents are content / knowledge agents (research, monitoring, note) and the
|
|
142
|
+
core frame above is the right shape. When the Agent instead **mutates code, files,
|
|
143
|
+
or system state** — the general-purpose archetype — extend the frame with scope,
|
|
144
|
+
a run-time autonomy boundary, and a verification receipt:
|
|
145
|
+
|
|
146
|
+
{{> ref:prompt-frame-extended }}
|
|
147
|
+
|
|
148
|
+
The `# Output` decision feeds one schedule field: if the output contract
|
|
149
|
+
includes DMing the user, also set `schedule.defer_in_quiet_hours: true` so a
|
|
150
|
+
firing inside quiet hours waits for the window's end instead of producing a
|
|
151
|
+
message that would be held anyway.
|
|
139
152
|
|
|
140
153
|
## Responses & errors
|
|
141
154
|
|
|
142
155
|
- `201 { "status": "created", "slug": "…" }` — the Agent is live; its recurring
|
|
143
|
-
schedule is paired and it will fire on the next matching tick.
|
|
156
|
+
schedule is paired and it will fire on the next matching tick. The response may
|
|
157
|
+
also carry `warnings[]` (non-blocking authoring lint — e.g. an empty prompt, a
|
|
158
|
+
missing `# Instruction` section, or a playbook you named but didn't declare);
|
|
159
|
+
the Agent is still created, but fix the flagged issues and re-save its `agent.md`.
|
|
144
160
|
- `400 one_shot_not_supported` — the schedule was not `cron`/`recurring`. Use the
|
|
145
161
|
`schedule` skill for one-time tasks.
|
|
146
162
|
- `400 invalid_recurrence` — a `kind:"recurring"` schedule carried a malformed
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
kind: reference
|
|
3
|
+
name: prompt-frame-extended
|
|
4
|
+
description: The extended prompt frame for operational / state-mutating agents (code, files, system state) — adds Goal / Context / Inputs / Scope / Execution Mode / Requirements / Constraints / Verification and a structured Output receipt on top of the core frame, plus the operational clarify-back slot.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### When to reach for the extended frame
|
|
8
|
+
|
|
9
|
+
Use it when the agent **mutates code, files, or system state**, or runs a
|
|
10
|
+
multi-step engineering-flavored task (the *general-purpose* agents). Content /
|
|
11
|
+
knowledge agents (research, monitoring, note) stay on the **core** frame — their
|
|
12
|
+
verification and output shape come from the playbooks, so they never carry the
|
|
13
|
+
sections below. Forcing this scaffolding onto a content agent is empty boilerplate
|
|
14
|
+
that dilutes the real instruction and eats the 8000-char cap.
|
|
15
|
+
|
|
16
|
+
Add these on top of the core `# Role` / `# Important` / `# Instruction`:
|
|
17
|
+
|
|
18
|
+
```markdown
|
|
19
|
+
# Goal # the outcome this agent exists to produce (fold into # Role if one line)
|
|
20
|
+
# Context # background, why it matters, the spec / state to read first
|
|
21
|
+
# Inputs # concrete artifacts: files, paths, URLs, repos, prior-run note, error logs
|
|
22
|
+
# Role
|
|
23
|
+
Act as a careful <engineer / researcher / reviewer / editor>.
|
|
24
|
+
Prioritize <correctness / minimal change / source-backed claims / maintainability>.
|
|
25
|
+
# Scope # WHERE it may act
|
|
26
|
+
Do: - <in-scope actions / the editable surface>
|
|
27
|
+
Do not: - <areas, files, or data it must not touch>
|
|
28
|
+
# Execution Mode # WHEN to act vs escalate
|
|
29
|
+
Proceed autonomously after reading the relevant context.
|
|
30
|
+
Escalate instead of acting when an action is outward-facing or irreversible
|
|
31
|
+
(send / publish / pay / delete), a data / schema migration, a broad refactor, or
|
|
32
|
+
the requirements are materially contradictory.
|
|
33
|
+
On escalation: if the user is reachable, DM a concise approval request and defer the
|
|
34
|
+
action; if running unattended, record the proposed action + reason and skip it.
|
|
35
|
+
# Requirements # success conditions
|
|
36
|
+
- <condition 1> ...
|
|
37
|
+
# Constraints # behavioral prohibitions not already in Scope / Execution Mode
|
|
38
|
+
- No speculative changes; preserve behavior outside the requested scope; no new
|
|
39
|
+
dependencies unless clearly necessary; do not remove existing tests / validation.
|
|
40
|
+
# Verification
|
|
41
|
+
- Run the checks relevant to what changed: code → tests / typecheck / lint;
|
|
42
|
+
research → cross-check each claim against ≥ 2 sources.
|
|
43
|
+
- Don't claim verification unless the checks passed; if they can't be run, say why.
|
|
44
|
+
# Output # structured receipt for the user to review
|
|
45
|
+
1. Summary of what was done
|
|
46
|
+
2. Files changed / sources used
|
|
47
|
+
3. Checks run + results
|
|
48
|
+
4. Assumptions made
|
|
49
|
+
5. Remaining risks / follow-ups
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Three rules keep the extended frame from sprawling (over-specification — the same
|
|
53
|
+
prohibition restated three times — is its main failure mode):
|
|
54
|
+
|
|
55
|
+
- **One prohibition, one section** — spatial → `# Scope`, risk / timing →
|
|
56
|
+
`# Execution Mode`, behavioral → `# Constraints`. Never restate "don't touch
|
|
57
|
+
unrelated files" in all three.
|
|
58
|
+
- **Fold short sections up** — an empty `# Goal` / `# Context` / `# Constraints` is
|
|
59
|
+
omitted, not left as a stub (`# Goal` folds into `# Role` when it's one line).
|
|
60
|
+
- **Content archetypes stay on the core frame** — never give a research / note
|
|
61
|
+
agent `# Verification` or receipt scaffolding.
|
|
62
|
+
|
|
63
|
+
#### `# Execution Mode` — the run-time autonomy boundary
|
|
64
|
+
|
|
65
|
+
Clarify-back (below, and in the core frame) resolves ambiguity at **authoring**
|
|
66
|
+
time, with the user present. `# Execution Mode` governs the **deployed** agent at
|
|
67
|
+
**run** time, usually with no user present — the gap where an agent that hits a risk
|
|
68
|
+
boundary mid-run has no instruction. Encode the product's posture: act on the safe,
|
|
69
|
+
reversible majority; on the risky minority **defer + flag** (DM an approval request,
|
|
70
|
+
hold the action) when the user is reachable, or **record + skip** when unattended.
|
|
71
|
+
Never guess, never block waiting.
|
|
72
|
+
|
|
73
|
+
### Clarify-back — the operational slot
|
|
74
|
+
|
|
75
|
+
On top of the content-archetype slots in the core frame, an operational agent has
|
|
76
|
+
its own required slots:
|
|
77
|
+
|
|
78
|
+
| Archetype | Required slots (ask only if unknown) | Sensible default |
|
|
79
|
+
|---|---|---|
|
|
80
|
+
| **General / operational** (code, files, system state) | editable surface / scope; what "done" means (success criteria); may it act autonomously or propose-then-confirm; which checks to run | propose-then-confirm for irreversible / outward actions; run the repo's standard checks; deliver as a branch / PR or draft, not a direct commit / send |
|
|
81
|
+
|
|
82
|
+
### Worked example — an operational agent
|
|
83
|
+
|
|
84
|
+
A recurring "keep the repo green" agent, extended frame end-to-end:
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
# Goal
|
|
88
|
+
Keep <repo> free of lint and type errors introduced during the day.
|
|
89
|
+
|
|
90
|
+
# Context
|
|
91
|
+
CI runs lint + typecheck on every PR; errors on `develop` block everyone. You run
|
|
92
|
+
nightly to catch and fix what slipped in.
|
|
93
|
+
|
|
94
|
+
# Inputs
|
|
95
|
+
- Repo: <org/repo>, branch `develop`.
|
|
96
|
+
- Commands: `pnpm lint`, `pnpm typecheck` (project root).
|
|
97
|
+
|
|
98
|
+
# Role
|
|
99
|
+
Act as a careful engineer. Prioritize minimal, behavior-preserving changes.
|
|
100
|
+
|
|
101
|
+
# Scope
|
|
102
|
+
Do: fix lint / type errors in app source under `packages/`.
|
|
103
|
+
Do not: touch test fixtures, generated files, or `*.config.*`; change runtime behavior.
|
|
104
|
+
|
|
105
|
+
# Execution Mode
|
|
106
|
+
Proceed autonomously for mechanical fixes. Escalate (open a draft PR + DM, do not
|
|
107
|
+
merge) if a fix needs a behavior change, touches a public API, or the error count is
|
|
108
|
+
> 30 (likely a systemic cause to confirm first). Running unattended: never merge —
|
|
109
|
+
always deliver as a PR for review.
|
|
110
|
+
|
|
111
|
+
# Requirements
|
|
112
|
+
- `pnpm lint` and `pnpm typecheck` both pass after your changes.
|
|
113
|
+
- One PR titled `nightly: lint+type sweep <YYYY-MM-DD>`.
|
|
114
|
+
|
|
115
|
+
# Constraints
|
|
116
|
+
- No new dependencies; no disabling of rules to silence errors; do not remove tests.
|
|
117
|
+
|
|
118
|
+
# Verification
|
|
119
|
+
- Run `pnpm lint` and `pnpm typecheck`; include the final output in the receipt.
|
|
120
|
+
- If either still fails, leave those errors unfixed and list them — don't claim green.
|
|
121
|
+
|
|
122
|
+
# Output
|
|
123
|
+
1. Summary of what was fixed.
|
|
124
|
+
2. Files changed (+ the PR link).
|
|
125
|
+
3. `pnpm lint` / `pnpm typecheck` results.
|
|
126
|
+
4. Assumptions made.
|
|
127
|
+
5. Remaining errors / follow-ups.
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Bad:** `"Keep the repo green nightly."` — no scope (which files?), no autonomy
|
|
131
|
+
boundary (merge or PR?), no verification contract. An agent with write access and
|
|
132
|
+
no `# Scope` / `# Execution Mode` is how unattended automation does damage.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
kind: reference
|
|
3
|
+
name: prompt-frame
|
|
4
|
+
description: The canonical core prompt frame (# Role / # Important / # Instruction / # Output), the operating-playbook references, and the clarify-back gate the DM agent uses to author a deployed agent's prompt. Shared byte-identical between agent-create and schedule.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### The core frame
|
|
8
|
+
|
|
9
|
+
Author the deployed agent's prompt as this Markdown skeleton. It is classic,
|
|
10
|
+
model-agnostic structure and reads identically under every backend. Keep it well
|
|
11
|
+
under the 8000-char cap — durable methodology lives in the playbooks (below), not
|
|
12
|
+
inlined here.
|
|
13
|
+
|
|
14
|
+
```markdown
|
|
15
|
+
# Role
|
|
16
|
+
You are <agent identity>. Every <cadence> you <the single outcome this agent exists for>.
|
|
17
|
+
|
|
18
|
+
# Important
|
|
19
|
+
- <hard constraints & rules to uphold>
|
|
20
|
+
- Preconditions: read <inputs> first; if <precondition> is missing, <fallback> and do not guess.
|
|
21
|
+
- Do NOT <the things that would make the output wrong or unsafe>.
|
|
22
|
+
- <playbook reference — name the methodology you'll follow, e.g. "Follow the research playbook.">
|
|
23
|
+
|
|
24
|
+
# Instruction
|
|
25
|
+
1. <ordered, concrete step — specific verb + endpoint / filename / decision rule>
|
|
26
|
+
2. <step — include a worked EXAMPLE wherever a step is non-obvious>
|
|
27
|
+
e.g. "Classify each item actionable-today / FYI / ignore — 'PR review requested' → actionable-today; a newsletter → ignore."
|
|
28
|
+
3. ...
|
|
29
|
+
|
|
30
|
+
# Output
|
|
31
|
+
- <format & destination: which file / section, frontmatter, append-vs-new-file, when/whether to DM>
|
|
32
|
+
- <if writing a note, say "follow the markdown-note playbook for structure">
|
|
33
|
+
- (Omit this section only when the task produces no durable artifact and no DM.)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Rules that make the difference between a sharp agent and a drifting one:
|
|
37
|
+
|
|
38
|
+
- **`# Instruction` steps must include concrete examples.** A step the agent could
|
|
39
|
+
read two ways needs a worked example pinning the intended one. Vague steps are
|
|
40
|
+
the #1 cause of a drifting agent.
|
|
41
|
+
- **`# Important` is the guardrail section** — preconditions, fallbacks, the
|
|
42
|
+
explicit "do NOT" list, and the playbook reference all live here. Don't scatter
|
|
43
|
+
guardrails across the other sections.
|
|
44
|
+
- **The deployed agent has no memory of this conversation.** Everything it needs is
|
|
45
|
+
in the prompt or in a playbook it is told to follow — nothing else carries over.
|
|
46
|
+
|
|
47
|
+
Migrating from the old four-element skeleton:
|
|
48
|
+
|
|
49
|
+
| Old element | New home |
|
|
50
|
+
|---|---|
|
|
51
|
+
| Goal | `# Role` (identity + the single outcome) |
|
|
52
|
+
| Requirements / preconditions | `# Important` (preconditions + fallbacks) |
|
|
53
|
+
| Process | `# Instruction` (ordered steps, **with examples**) |
|
|
54
|
+
| Expected output | `# Output` |
|
|
55
|
+
| guardrails / "what NOT to do" | `# Important` |
|
|
56
|
+
|
|
57
|
+
### Operating playbooks (never inline the full text)
|
|
58
|
+
|
|
59
|
+
Durable methodology lives in the operating playbooks, kept central so a single
|
|
60
|
+
update reaches every agent. Do NOT paste a playbook's full content into the prompt
|
|
61
|
+
— that copy would silently go stale. How the methodology reaches the run depends
|
|
62
|
+
on the path:
|
|
63
|
+
|
|
64
|
+
- **Recurring Agent** (agent definition): name the playbook in `# Important` AND
|
|
65
|
+
declare its slug in the top-level `playbooks:` field. The daemon then injects the
|
|
66
|
+
full methodology into every run — the single, guaranteed copy in the prompt.
|
|
67
|
+
- **One-off task** (`/schedule`): there is no `playbooks:` field and no injection.
|
|
68
|
+
Fold the handful of steps you actually need straight into `# Instruction`; a
|
|
69
|
+
run-once task has no staleness concern, so inlining is the right call here.
|
|
70
|
+
|
|
71
|
+
| If the agent's job is… | Name this playbook in `# Important` | Also |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| Research a topic and report | "Follow the **research** playbook." | + markdown-note if it writes a note |
|
|
74
|
+
| Watch something and report changes | "Follow the **monitoring** playbook." | + markdown-note for the rolling note |
|
|
75
|
+
| Produce / update a free-form topic note | "Follow the **markdown-note** playbook." | — |
|
|
76
|
+
|
|
77
|
+
The markdown-note playbook governs *free-form topic notes only* — never the
|
|
78
|
+
structured context-vault files (today.md, journal, roadmap), which keep their own
|
|
79
|
+
schemas.
|
|
80
|
+
|
|
81
|
+
### Clarify-back before you deploy
|
|
82
|
+
|
|
83
|
+
If a required slot for the agent's archetype is unknown from the conversation, ask
|
|
84
|
+
the user **one consolidated question** before creating the agent — never guess. (The
|
|
85
|
+
runtime drops an ambiguous task rather than salvaging it, so ambiguity has to be
|
|
86
|
+
resolved now.) Batch all missing slots into a single message and pair each with a
|
|
87
|
+
sensible **default** the user can accept in one tap. Ask only *missing, required*
|
|
88
|
+
slots — don't interrogate.
|
|
89
|
+
|
|
90
|
+
| Archetype | Required slots (ask only if unknown) | Sensible default |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| **Research** | topic/scope; what you mainly want (a decision? situational awareness? specific sub-questions?); depth (how many angles/sources); output destination (Obsidian note? DM? both); cadence + time | medium depth (3–5 angles); Obsidian note + short DM digest |
|
|
93
|
+
| **Monitoring / digest** | what to watch; what counts as a noteworthy change; where to record; notify threshold (always vs only-on-change) | notify only on material change; record to a rolling note |
|
|
94
|
+
| **Any task writing a note** | destination path; title pattern; append-to-existing vs new-file-per-run | new dated file under the topic folder |
|
|
95
|
+
|
|
96
|
+
### Worked example — a content agent
|
|
97
|
+
|
|
98
|
+
**Good** (research → note; core frame + playbook references):
|
|
99
|
+
|
|
100
|
+
```markdown
|
|
101
|
+
# Role
|
|
102
|
+
You are the user's AI-news researcher. Every morning you produce a verified digest
|
|
103
|
+
of the most important AI developments from the last 24h.
|
|
104
|
+
|
|
105
|
+
# Important
|
|
106
|
+
- Read context/research/ai-news.md for what you already reported; don't repeat it.
|
|
107
|
+
- Follow the **research** playbook for method + source verification, and the
|
|
108
|
+
**markdown-note** playbook for the note's shape.
|
|
109
|
+
- Do NOT include a claim backed by a single source without marking it "(single source)".
|
|
110
|
+
|
|
111
|
+
# Instruction
|
|
112
|
+
1. Pick 3–5 distinct angles not already covered in the existing note.
|
|
113
|
+
2. For each angle, find 2–4 authoritative sources with WebSearch; open the top 1–2
|
|
114
|
+
in full if the agent has page-fetch access (a standard scheduled agent does not).
|
|
115
|
+
e.g. for "model releases" prefer the lab's own post over a news aggregator.
|
|
116
|
+
3. Cross-check every material claim against ≥ 2 sources before including it.
|
|
117
|
+
|
|
118
|
+
# Output
|
|
119
|
+
- Write context/research/ai-news/<YYYY-MM-DD>-digest.md per the markdown-note playbook.
|
|
120
|
+
- DM the user the 2–4 sentence "what matters" summary + the note path.
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Bad:** `"Research the latest AI news every morning and send me a summary."` — no
|
|
124
|
+
preconditions, no method, no source bar, no output contract; the agent improvises
|
|
125
|
+
differently (and shallowly) every day.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: background-task
|
|
3
|
+
description: Hand a long-running or open-ended task (deep research, multi-repo CI audit, monitor X over time, bulk compile) to /api/background-task. Compose a self-contained brief, set the notification policy, POST, ack, end the turn. Read GET /:id for follow-up detail.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Bash(curl *)
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Background Task — long-running work from DM
|
|
9
|
+
|
|
10
|
+
A detached worker runs the task in its own session with its own budget.
|
|
11
|
+
**The daemon delivers the result to the user directly — in your own voice —
|
|
12
|
+
when it finishes or needs input. You are NOT in that delivery path.** Your
|
|
13
|
+
job is the front bookend only: scope the task *now*, compose a
|
|
14
|
+
self-contained **brief**, choose a notification policy, POST it,
|
|
15
|
+
acknowledge in one line, and **end your turn**. The worker's run is
|
|
16
|
+
invisible to you.
|
|
17
|
+
|
|
18
|
+
This is the surface for *generic* long tasks. For an open-ended **browser**
|
|
19
|
+
job (post a tweet, fill a form) use the `browser-task` skill. For a
|
|
20
|
+
*recurring* cadence ("every morning…", "each hour check my PRs") use
|
|
21
|
+
`agent-create` / `schedule` — a background task is a single detached run.
|
|
22
|
+
|
|
23
|
+
## When to background it (triage)
|
|
24
|
+
|
|
25
|
+
Background work that is **long-running or open-ended** so the user can keep
|
|
26
|
+
chatting. No duration guess — decide on the signals:
|
|
27
|
+
|
|
28
|
+
1. **Category** — deep research, a multi-repo / multi-file audit,
|
|
29
|
+
"monitor / watch X", a multi-step web dig, a bulk compile. Strongest
|
|
30
|
+
signal.
|
|
31
|
+
2. **Owner signal** — explicit ("take your time", "report back later") or a
|
|
32
|
+
research-style bang command.
|
|
33
|
+
3. **Scoping reveals size** — if resolving the request shows large or
|
|
34
|
+
genuinely open-ended work, delegate it.
|
|
35
|
+
|
|
36
|
+
**Bias toward backgrounding category-1 work; keep plausibly-quick lookups
|
|
37
|
+
inline** (delivery costs a turn's latency). One task per request: "research
|
|
38
|
+
X AND audit Y" → two POSTs.
|
|
39
|
+
|
|
40
|
+
## Compose the brief — this is the real work
|
|
41
|
+
|
|
42
|
+
The worker sees ONLY your `brief` (it does not inherit the conversation,
|
|
43
|
+
the user profile, or the management rules). An under-specified brief forces
|
|
44
|
+
a clarification round-trip you can avoid by writing it well *this turn*.
|
|
45
|
+
Resolve ambiguity with the user now, then encode all of:
|
|
46
|
+
|
|
47
|
+
- **Objective** — the end state as an outcome ("find which repos have a red
|
|
48
|
+
main build", not "go look at repos").
|
|
49
|
+
- **Scope & inputs** — the concrete inputs the worker can't infer: the repo
|
|
50
|
+
list, what "failing" means, which sites, the date range.
|
|
51
|
+
- **Output language** — the user's language for `result`, `draft`, and any
|
|
52
|
+
clarification.
|
|
53
|
+
- **Persona hints** — a line on the user's voice so the `draft` summary
|
|
54
|
+
reads right if it's sent directly.
|
|
55
|
+
- **Notification policy + criteria** — see below; for `if_significant` the
|
|
56
|
+
criteria MUST be written into the brief in concrete terms.
|
|
57
|
+
- **Expected output** — what a good `result` contains (a per-repo table, a
|
|
58
|
+
ranked list, a one-paragraph verdict).
|
|
59
|
+
|
|
60
|
+
The worker can read owner memory itself to fill in preferences, so you need
|
|
61
|
+
only supply the *task-specific* inputs above. **Promoting an inline task?**
|
|
62
|
+
Also fold in the work you already did (findings, partial results) so the
|
|
63
|
+
worker continues rather than restarting cold.
|
|
64
|
+
|
|
65
|
+
## Notification policy — you author it
|
|
66
|
+
|
|
67
|
+
`notificationPolicy` decides whether the worker's result reaches the user.
|
|
68
|
+
The worker doesn't free-judge; it evaluates the policy you set:
|
|
69
|
+
|
|
70
|
+
- **`always`** (default) — the user asked and wants the answer, even
|
|
71
|
+
"nothing found / 0 issues". The common case; always delivered.
|
|
72
|
+
- **`if_significant`** — delivered **only if** the concrete criteria are
|
|
73
|
+
met. Prefer the structured **`significanceCriteria`** array (below) over
|
|
74
|
+
prose; vague criteria defeat the policy.
|
|
75
|
+
- **`silent`** — never delivered; filed only.
|
|
76
|
+
|
|
77
|
+
A filed (`silent` / unmet-`if_significant`) result is not lost — it surfaces
|
|
78
|
+
in the daily digest and the user can pull it (see "Filed results" below).
|
|
79
|
+
|
|
80
|
+
## Endpoints (localhost only)
|
|
81
|
+
|
|
82
|
+
| Method | Path | Purpose |
|
|
83
|
+
|---|---|---|
|
|
84
|
+
| POST | `/api/background-task` | Create + dispatch, or schedule (`scheduleAt`). |
|
|
85
|
+
| GET | `/api/background-task?state=...` | List (also `notify`, `sinceHours` for the filed pull). |
|
|
86
|
+
| GET | `/api/background-task/:id` | The artifact — verbatim `report`, `draft`, `notify`, clarifications. |
|
|
87
|
+
| POST | `/api/background-task/:id/cancel` | Force-stop. |
|
|
88
|
+
|
|
89
|
+
Clarifications are answered with the **`background-task-reply`** skill.
|
|
90
|
+
|
|
91
|
+
## Hard rules
|
|
92
|
+
|
|
93
|
+
1. **Localhost only.** `http://localhost:8321/api/background-task/*`.
|
|
94
|
+
2. **POST, ack, end the turn. NEVER poll for completion.** After a
|
|
95
|
+
successful POST, reply once and stop. Do NOT GET `/:id` in a loop or
|
|
96
|
+
"wait and check". Ending your turn has zero effect on the detached
|
|
97
|
+
worker — it keeps running and the daemon delivers the result as a DM in
|
|
98
|
+
your voice. The only allowed GET is a single on-demand read answering an
|
|
99
|
+
explicit user question (see "Follow-up detail").
|
|
100
|
+
3. **Never invent `taskId` / `clarificationId`** — uuid v4 minted by the
|
|
101
|
+
daemon; read them from responses.
|
|
102
|
+
4. **The worker has no messaging tool** — it cannot DM the user; it writes
|
|
103
|
+
its artifact and *you* (the daemon, in your voice) deliver.
|
|
104
|
+
5. **One task per request.**
|
|
105
|
+
|
|
106
|
+
## POST — composing a request
|
|
107
|
+
|
|
108
|
+
`POST /api/background-task` with the self-contained brief:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
curl --silent --fail -X POST -H 'Content-Type: application/json' \
|
|
112
|
+
-d '{"brief":"Audit these repos for a red main-branch CI build: aitne/daemon, aitne/web. \"Failing\" = the latest default-branch run concluded failure. Summary in English. Only notify if at least one repo is red. Output: one line per failing repo with the job.","title":"CI audit","notificationPolicy":"if_significant"}' \
|
|
113
|
+
http://localhost:8321/api/background-task
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Body:
|
|
117
|
+
|
|
118
|
+
- `brief` (1..16384) — the self-contained worker prompt above.
|
|
119
|
+
- `title` (1..200, optional) — short human label for status + the DM.
|
|
120
|
+
- `notificationPolicy` — `always` (default) / `if_significant` / `silent`.
|
|
121
|
+
- `significanceCriteria` (optional, `if_significant` only) — up to 12
|
|
122
|
+
atomic conditions (each ≤500 chars), e.g. `["any repo's main build is
|
|
123
|
+
red","spend > $100"]`. Worker notifies iff one is met. Omit otherwise.
|
|
124
|
+
- `tier` (optional) — `lite` / `medium` / `high` budget envelope. Default
|
|
125
|
+
is fine; use `high` only for genuinely heavy research.
|
|
126
|
+
- `maxBudgetUsd` (optional) — override the dollar cap (hard ceiling `15`;
|
|
127
|
+
a larger value is rejected `400`). Prefer `tier` over a raw dollar value.
|
|
128
|
+
- `scheduleAt` (ISO 8601, optional) — defer the *run* to a fire time (the
|
|
129
|
+
worker starts then; it is compute, so it runs even during quiet hours).
|
|
130
|
+
The eventual *result delivery* is what respects quiet hours, not the run.
|
|
131
|
+
`202` with `{ taskId, status:"scheduled", scheduledFor, scheduleRowId }`.
|
|
132
|
+
A time more than 60s in the past is rejected `400`.
|
|
133
|
+
|
|
134
|
+
Immediate response carries `taskId` and `status`. Then ack once and stop
|
|
135
|
+
(Hard rule 2).
|
|
136
|
+
|
|
137
|
+
## Acknowledgement
|
|
138
|
+
|
|
139
|
+
One line, no ceremony, no internal mechanism names (`taskId`, "worker",
|
|
140
|
+
"artifact"); your output language is already governed by your policy.
|
|
141
|
+
Structural examples (English): *"Started the audit in the background — I'll
|
|
142
|
+
report when it's done."* / *"On it. I'll dig into that and come back with
|
|
143
|
+
what I find."* Do NOT promise a specific time; say "when it's done".
|
|
144
|
+
|
|
145
|
+
## Follow-up detail — answer from the artifact, don't guess
|
|
146
|
+
|
|
147
|
+
The delivered DM carries a *summary*. When the user later asks for precise
|
|
148
|
+
detail it didn't include ("what exactly did it find on repo X?", "show me
|
|
149
|
+
the numbers"), do a **single** read and answer from the verbatim `report`:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
curl --silent --fail http://localhost:8321/api/background-task/<taskId>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
`report` is the full, unparaphrased result. Quote from it; don't invent
|
|
156
|
+
detail. If you lack the `taskId`, list `state=completed` and match by
|
|
157
|
+
`title`.
|
|
158
|
+
|
|
159
|
+
## Filed results — the "did that monitor ever run?" pull
|
|
160
|
+
|
|
161
|
+
A `silent` / unmet-`if_significant` result is filed (`notify=false`), not
|
|
162
|
+
pushed. When the user asks whether a backgrounded task ran:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
curl --silent --fail "http://localhost:8321/api/background-task?state=completed¬ify=false&sinceHours=168"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Each row carries `title`, `significance`, and `report`. Summarize
|
|
169
|
+
naturally; offer to pull any in full.
|
|
170
|
+
|
|
171
|
+
## Force-stop — "stop" / "cancel" / "abort"
|
|
172
|
+
|
|
173
|
+
On a clear stop signal, find the task (by `taskId`, or list
|
|
174
|
+
`state=running,awaiting_user,pending` and match the topic), then
|
|
175
|
+
`POST /api/background-task/<taskId>/cancel` with optional
|
|
176
|
+
`{"reason":"user_cancel"}`. `200` = accepted; `404 not_found` = stale id,
|
|
177
|
+
re-read; `409 already_terminal` = too late, report `currentState`
|
|
178
|
+
verbatim. "wait" is NOT a cancel.
|
|
179
|
+
|
|
180
|
+
## Scheduling — `scheduleAt` ≠ the `schedule` skill
|
|
181
|
+
|
|
182
|
+
For "do this research at <time>" use `scheduleAt` in this POST. The
|
|
183
|
+
`schedule` skill is for listing / modifying / cancelling pending schedules;
|
|
184
|
+
a recurring cadence is `agent-create`.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: background-task-reply
|
|
3
|
+
description: |
|
|
4
|
+
When a background task is parked on a clarifying question and the
|
|
5
|
+
owner's DM answers it, relay the answer via
|
|
6
|
+
POST /api/background-task/<taskId>/clarify. Use ONLY when a task is in
|
|
7
|
+
awaiting_user AND the conversation shows the question was just asked.
|
|
8
|
+
allowed-tools:
|
|
9
|
+
- Bash(curl *)
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Background Task — clarification relay
|
|
13
|
+
|
|
14
|
+
A detached background task can pause to ask the owner one question
|
|
15
|
+
(`awaiting_user`). The daemon already DMed that question to the owner, in
|
|
16
|
+
your voice — you did NOT author it and you do not poll for it. You act only
|
|
17
|
+
when the owner comes back with an answer, translating their natural-language
|
|
18
|
+
reply into the structured `/clarify` call that un-parks the worker.
|
|
19
|
+
|
|
20
|
+
This skill does NOT spawn tasks (that's `background-task`) and does NOT
|
|
21
|
+
deliver results (the daemon does that directly).
|
|
22
|
+
|
|
23
|
+
## Hard rule — never cold-call
|
|
24
|
+
|
|
25
|
+
This skill is a no-op unless BOTH hold:
|
|
26
|
+
|
|
27
|
+
1. `GET /api/background-task?state=awaiting_user` returns a non-empty list
|
|
28
|
+
(call this FIRST). Empty → do nothing; the owner's message is not a
|
|
29
|
+
clarification answer.
|
|
30
|
+
2. The conversation shows the agent recently asked that task's question —
|
|
31
|
+
a pending `task_clarification` in your catchup context, or a recent
|
|
32
|
+
assistant DM that posed it. No recent question → the reply is about
|
|
33
|
+
something else; leave the parked task alone (its deadline scanner
|
|
34
|
+
handles a genuine no-answer).
|
|
35
|
+
|
|
36
|
+
Relaying when the owner didn't answer the question is a worse failure than
|
|
37
|
+
missing an ambiguous reply. When unsure whether the message answers the
|
|
38
|
+
question, ask ONE short clarifier rather than guessing.
|
|
39
|
+
|
|
40
|
+
## Endpoints
|
|
41
|
+
|
|
42
|
+
| Method | Path | Purpose |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| GET | `/api/background-task?state=awaiting_user` | List parked tasks. Call FIRST. |
|
|
45
|
+
| GET | `/api/background-task/:id` | Read the open `clarifications` row (`resolved:false`) for its `id` + `question`. |
|
|
46
|
+
| POST | `/api/background-task/:id/clarify` | Relay the answer. |
|
|
47
|
+
|
|
48
|
+
## Resolving which task
|
|
49
|
+
|
|
50
|
+
1. `GET /api/background-task?state=awaiting_user`. Usually exactly one
|
|
51
|
+
parked task; if several, match the owner's reply to the right one by
|
|
52
|
+
topic / `title`, or ask which.
|
|
53
|
+
2. `GET /api/background-task/<taskId>` — read the open `clarifications`
|
|
54
|
+
entry (`resolved:false`) and re-read the `question` so you can confirm
|
|
55
|
+
the owner's message actually answers it. The GET response exposes each
|
|
56
|
+
clarification row's identifier as `id`; to answer, POST `/clarify` with
|
|
57
|
+
that value in the request-body field `clarificationId`.
|
|
58
|
+
|
|
59
|
+
If your catchup context already carries the `clarificationId` in metadata,
|
|
60
|
+
you may use it — but **never surface a `clarificationId` or `taskId` in
|
|
61
|
+
user-visible text** (token hygiene). The GET is the authoritative source.
|
|
62
|
+
|
|
63
|
+
## Relay the answer
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
curl --silent --fail -X POST -H 'Content-Type: application/json' \
|
|
67
|
+
-d '{"clarificationId":"<uuid>","answer":"api first"}' \
|
|
68
|
+
http://localhost:8321/api/background-task/<taskId>/clarify
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- `answer` (1..8192) — the owner's reply, verbatim and faithful. Do not
|
|
72
|
+
re-decide the task on their behalf; pass what they said.
|
|
73
|
+
- `clarificationId` is optional — if you omit it the daemon resolves the
|
|
74
|
+
single open clarification — but prefer passing the explicit id when more
|
|
75
|
+
than one task is parked.
|
|
76
|
+
|
|
77
|
+
Then ack briefly ("Got it, picking that back up.") and end the turn — the
|
|
78
|
+
worker resumes on its own and the daemon delivers the eventual result.
|
|
79
|
+
|
|
80
|
+
Status codes — handle each, don't retry blindly:
|
|
81
|
+
|
|
82
|
+
- `200` — recorded; the worker resumes. Brief ack.
|
|
83
|
+
- `400 validation_error` — `clarificationId` not a uuid, or `answer` empty
|
|
84
|
+
/ > 8192 chars. Re-read with GET and re-send.
|
|
85
|
+
- `409 not_awaiting_user` (carries `currentState`) — the task already moved
|
|
86
|
+
on (finished, cancelled, or the window closed). Tell the owner the state
|
|
87
|
+
plainly; do not re-send.
|
|
88
|
+
- `409 no_open_clarification` — nothing to answer; your state was stale.
|
|
89
|
+
Re-read with GET first.
|
|
90
|
+
- `409 already_resolved` — the question was already answered (a racing
|
|
91
|
+
reply landed first). The worker has resumed; do not re-send. A brief ack
|
|
92
|
+
is enough.
|
|
93
|
+
- `410 expired` — the clarification deadline passed; the worker will time
|
|
94
|
+
out. Apologise briefly and offer to re-run if relevant.
|
|
95
|
+
- `404 not_found` — stale `taskId`; re-read with GET.
|
|
96
|
+
|
|
97
|
+
## Localhost only
|
|
98
|
+
|
|
99
|
+
`http://localhost:8321/api/background-task/*`. JSON body in single quotes
|
|
100
|
+
(project convention) so the daemon hooks classify the payload as data.
|