@oneie/sdk 0.15.0 → 0.15.1

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/dist/receivers.js CHANGED
@@ -974,6 +974,16 @@ export const RECEIVERS = {
974
974
  board: z.literal("marketplace").optional(),
975
975
  slug: z.string().optional(),
976
976
  workspace: z.string().optional(),
977
+ // Rides through unchanged to buildMessage (string field, unaffected)
978
+ // and is what lets an inbox card show a title instead of a bare tid.
979
+ title: z.string().optional(),
980
+ // The structured envelope (`web/src/lib/signal-meta.ts SignalMeta`) —
981
+ // an object, so buildMessage's string/number-only flatten drops it from
982
+ // the text body by construction. Declared loosely here (not the exact
983
+ // shape) because this is the ONE cross-cutting schema every announce
984
+ // caller reuses; a stricter zod object would have to be kept in lockstep
985
+ // with the TS type by hand.
986
+ meta: z.record(z.string(), z.unknown()).optional(),
977
987
  }),
978
988
  response: z.object({ ok: z.boolean(), taskId: z.string().optional(), matched: z.number().optional(), actors: z.array(z.string()).optional() }),
979
989
  effect: "ask",
@@ -1028,6 +1038,11 @@ export const RECEIVERS = {
1028
1038
  name: z.string(),
1029
1039
  tags: z.array(z.string()),
1030
1040
  weight: z.number(),
1041
+ // Shipped by the resolver (subscriptions.ts § tasks:everywhere) and undeclared
1042
+ // until now. The response check is WARN-only (bind-receiver.ts:247), so the
1043
+ // field arrived while the contract denied it — and every reader generated FROM
1044
+ // the contract (metaSchema, the MCP tool schema, OpenAPI) could not see it.
1045
+ priority: z.number().optional().describe("Task priority; the ranking input behind `weight`"),
1031
1046
  notes: z.string().optional(),
1032
1047
  contextDocs: z.array(z.string()).optional(),
1033
1048
  workspace: z.string(),
@@ -1039,6 +1054,10 @@ export const RECEIVERS = {
1039
1054
  offeredByMe: z.boolean(),
1040
1055
  closedAt: z.string().optional(),
1041
1056
  })),
1057
+ // A cap that reports itself (the /api/things standard). The old 200 clamp
1058
+ // was silent: a 595-row queue came back as 200 rows and read as complete.
1059
+ total: z.number().optional().describe("Visible rows before the limit was applied"),
1060
+ truncated: z.boolean().optional().describe("true = more rows exist than were returned; raise limit or use tasks:board"),
1042
1061
  }),
1043
1062
  effect: "ask", idempotent: true,
1044
1063
  }),
@@ -1321,6 +1340,63 @@ export const RECEIVERS = {
1321
1340
  // a dedupe. The RUN row dedupes (INSERT OR IGNORE); the events do not.
1322
1341
  effect: "ask", idempotent: false,
1323
1342
  }),
1343
+ // ── ehc: ───────────────────────────────────────────────────────────────────
1344
+ //
1345
+ // The first member of this namespace, and it sets the convention: an `ehc:`
1346
+ // receiver acts on ONE named child's plan, and the child's address comes from
1347
+ // the case registry (`one.ie/web/src/lib/ehc/address.ts`), never from a string
1348
+ // a caller typed.
1349
+ //
1350
+ // Read the summary as a limit, not a feature list. This door cannot record a
1351
+ // CYP's own words \u2014 it accepts no voice key, so every record it writes is a
1352
+ // proxy record and renders as MARKED INTERPRETATION naming the adult. A child
1353
+ // speaks through the page that minted their credential. An agent-class caller
1354
+ // is refused outright: Section A is what a child said or an adult's marked
1355
+ // account of what a child communicated, and a generated sentence is neither.
1356
+ "ehc:voice-record": receiver({
1357
+ receiver: "ehc:voice-record",
1358
+ summary: "Record what a child or young person communicated into Section A of their EHC plan, as MARKED INTERPRETATION attributed to the attested adult who recorded it. Authorship is derived from the credential and never from the payload; an agent-class caller is refused (machines do not speak for children); a case that is not synthetic is refused pending a data-residency decision (Article 9 special category data)",
1359
+ request: z.object({
1360
+ cyp: z.string(), // case id, e.g. 'cyp-005' \u2014 resolved through the registry
1361
+ body: z.string(), // exactly what was communicated. Never smoothed.
1362
+ proxyRole: z.string().optional(), // 'parent' | 'keyworker' | 'advocate' \u2014 shown to every reader
1363
+ prompt: z.string().optional(), // which portal question this answers
1364
+ }),
1365
+ response: z.object({
1366
+ ok: z.boolean(),
1367
+ id: z.string().optional(),
1368
+ provenance: z.string().optional(), // always 'proxy-observed' from this door
1369
+ saidAt: z.string().optional(),
1370
+ error: z.string().optional(), // 'not_found' | 'residency_undecided' | 'machines_do_not_speak_for_children' | 'no_voice' | 'empty' | 'too_long'
1371
+ detail: z.string().optional(),
1372
+ }),
1373
+ effect: "ask", cost: "free", reversible: false, idempotent: false, auth: "session",
1374
+ }),
1375
+ // The event a provision's `verification.closesOn` names (cases/cyp-001.ts H1).
1376
+ // A receiver cannot be per-child, so the child rides in `cyp` and the instance
1377
+ // name `ehc:<cyp>:meal-served` is what the event row carries. It records a
1378
+ // human tick that a meal was SERVED — never that one was ordered.
1379
+ "ehc:meal-served": receiver({
1380
+ receiver: "ehc:meal-served",
1381
+ summary: "A named adult ticks that a child was served a meal. Writes one event row named by the provision's closesOn (e.g. ehc:cyp-001:meal-served) attributed to the attested caller, never a payload field; refuses an agent-class caller, an unknown case, a non-synthetic case, and a case with no meal provision",
1382
+ request: z.object({
1383
+ cyp: z.string(), // case id, e.g. 'cyp-001' — resolved through the registry
1384
+ meal: z.enum(["breakfast", "lunch", "tea"]),
1385
+ servedOn: z.string().optional(), // YYYY-MM-DD; defaults to today (UTC)
1386
+ }),
1387
+ response: z.object({
1388
+ ok: z.boolean(),
1389
+ id: z.string().optional(),
1390
+ event: z.string().optional(),
1391
+ provision: z.string().optional(),
1392
+ meal: z.string().optional(),
1393
+ servedOn: z.string().optional(),
1394
+ adult: z.string().optional(),
1395
+ error: z.string().optional(),
1396
+ detail: z.string().optional(),
1397
+ }),
1398
+ effect: "signal", cost: "free", reversible: false, idempotent: false, auth: "session",
1399
+ }),
1324
1400
  "story:chain": receiver({
1325
1401
  receiver: "story:chain",
1326
1402
  summary: "The stories, counted: sets of two or more signals sharing one `origin`, read from the D1 lineage ledger (migrations/0244_story_link.sql). A story is a COUNT over a shared origin, not an entity \u2014 zero new types, zero new dimensions. The number moves as a side effect of signals that already flow; nobody types a row. `count` is the whole qualifying population, `stories` a page of at most 50 ordered by members desc \u2014 a capped count would plateau exactly when the substrate got busy. Zero is a real answer, never an error",
@@ -1472,6 +1548,11 @@ export const RECEIVERS = {
1472
1548
  // task. Without it the task is an orphan: on the board, unreachable from any plan.
1473
1549
  // Refused unless the caller has operate access to the parent.
1474
1550
  parent: z.string().optional(),
1551
+ // 0..1, the same fraction tasks:priority stores. Added 2026-09-14: without it this
1552
+ // door could not express a priority, so every row it filed was invisible to the only
1553
+ // sort the board pages by — 407 of 730 on the day it was added. Omit to leave the
1554
+ // attribute ABSENT (never judged), which is distinct from 0 (judged unimportant).
1555
+ priority: z.number().min(0).max(1).optional(),
1475
1556
  // The viewed /u/<slug> workspace to file the task under. Honored only when the
1476
1557
  // caller is authorized for it (attested staff or owner-tree control); otherwise
1477
1558
  // the resolver falls back to the caller's own slug. Reconciles the create tag
@@ -1851,6 +1932,226 @@ export const RECEIVERS = {
1851
1932
  }),
1852
1933
  effect: "ask", idempotent: true, auth: "member",
1853
1934
  }),
1935
+ // tasks:board — the ONE-REQUEST read of a whole board, with the context a planner needs.
1936
+ //
1937
+ // WHY. Measured 2026-09-13: an agent asked for the board, hit a 200-row page
1938
+ // (the MCP tool's documented cap; `tasks:everywhere` clamps to 200), paged by six
1939
+ // tags, found 353 more rows by NAME ONLY, and never learned the real total.
1940
+ // `tasks:list` has no cap but refuses without a `tag`, so the unfiltered
1941
+ // question — "every task in this group" — had no door at all.
1942
+ //
1943
+ // CONTRACT. (1) `total` is the count that matched the filters BEFORE paging, and
1944
+ // is never an estimate; a partial page carries `nextCursor`, and any budget the
1945
+ // underlying read could not honour is named in `truncated` — a short answer
1946
+ // always says it is short. (2) `summary` is computed over ALL matched rows, not
1947
+ // the page, so a planner can reason about 2,000 tasks while reading 0 of them.
1948
+ // (3) Rows are compact by default; `include` widens them. (4) Served from the
1949
+ // edge snapshot (KV memo of the board, `asOf` stamps it) — never a live TypeDB
1950
+ // read per call (CLAUDE.md § The brain and the edge). `fresh: true` asks for a
1951
+ // rebuild and is honoured at most once per memo window.
1952
+ "tasks:board": receiver({
1953
+ receiver: "tasks:board",
1954
+ surfaces: { mcp: true },
1955
+ summary: "The whole task board in ONE request: every task in a group (or its whole subtree with scope:'tree'), filtered in RAM, with `total` before paging, a `nextCursor` when there is more, `truncated` naming any budget that bit, and a `summary` over ALL matched rows — counts by status/tag/assignee/workspace, the ready set, the blocked set, overdue, unassigned, orphans, no-notes. Use this to plan; use tasks:bulk to act on what it shows.",
1956
+ request: z.object({
1957
+ workspace: z.string().optional().describe("Group slug. Omit for your own. Honoured only if you may read it."),
1958
+ scope: z.enum(["own", "tree"]).optional().describe("tree = this group AND every descendant group (the CEO / agency lens). Default own."),
1959
+ status: z.union([z.string(), z.array(z.string())]).optional()
1960
+ .describe("open | blocked | picked | done | verified | failed | dissolved, one or many. 'active' = open+blocked+picked (the default). 'all' = every status."),
1961
+ tags: z.array(z.string()).optional().describe("Row must carry EVERY tag (AND)."),
1962
+ anyTags: z.array(z.string()).optional().describe("Row must carry AT LEAST ONE of these tags (OR)."),
1963
+ assignee: z.string().optional().describe("Actor slug. '' = unassigned only."),
1964
+ parent: z.string().optional().describe("Only direct children of this task id. '' = top-level rows (no parent)."),
1965
+ search: z.string().optional().describe("Case-insensitive substring on the task name."),
1966
+ ready: z.boolean().optional().describe("true = only rows claimable now (open, and every blocker closed). false = only rows that are NOT claimable now (not open, or at least one blocker still open). Omit for both."),
1967
+ include: z.array(z.enum(["notes", "graph", "dates", "thread"])).optional()
1968
+ .describe("Widen each row. notes = the prose goal, CLIPPED to the first 2000 chars per row (read the whole text one task at a time); graph = children + blocks (the reverse edges); dates = startAt/createdAt/closedAt; thread = the task's inbox conversation (id, comment count, last message). Compact rows already carry parent, blockedBy, dueAt."),
1969
+ view: z.enum(["rows", "summary", "both"]).optional().describe("summary = counts and sets only, no rows (cheapest way to see a 2,000-row board). Default both."),
1970
+ sort: z.enum(["priority", "due-at", "updated-at", "created-at", "name"]).optional().describe("Default priority (desc)."),
1971
+ dir: z.enum(["asc", "desc"]).optional(),
1972
+ limit: z.number().int().min(1).max(2000).optional().describe("Rows per page. Default 500, max 2000."),
1973
+ cursor: z.string().optional().describe("The nextCursor from the previous page."),
1974
+ fresh: z.boolean().optional().describe("Rebuild the snapshot instead of reading the memo. Rate-limited to once per memo window."),
1975
+ }),
1976
+ response: z.object({
1977
+ ok: z.boolean(),
1978
+ workspace: z.string().optional(),
1979
+ workspaces: z.array(z.string()).optional().describe("Every group the rows were read from (scope:'tree')."),
1980
+ asOf: z.string().optional().describe("ISO time the snapshot was built. Rows are at most this stale."),
1981
+ cached: z.boolean().optional(),
1982
+ total: z.number().optional().describe("Rows matching the filters, before paging. Exact — UNLESS `truncated.rows` is present, in which case the snapshot itself was capped and total is a floor."),
1983
+ returned: z.number().optional(),
1984
+ nextCursor: z.string().optional().describe("Present iff more rows match. Absent = you have them all."),
1985
+ truncated: z.object({
1986
+ rows: z.number().optional().describe("The snapshot hit its row budget; this many unique rows were read. total is a floor."),
1987
+ edges: z.boolean().optional().describe("parent/blockedBy edges were capped — a row may read as unblocked or orphaned when it is not."),
1988
+ tags: z.number().optional().describe("This many returned rows may be missing tags."),
1989
+ }).optional().describe("Absent = nothing was cut. Present = say so before you plan on it."),
1990
+ summary: z.object({
1991
+ byStatus: z.record(z.string(), z.number()),
1992
+ byTag: z.record(z.string(), z.number()).describe("Bare tags only (no workspace:/slug:/@ namespaces), top 100 by count."),
1993
+ byAssignee: z.record(z.string(), z.number()).describe("'' key = unassigned."),
1994
+ byWorkspace: z.record(z.string(), z.number()),
1995
+ ready: z.number().describe("Open with every blocker closed — claimable now."),
1996
+ blocked: z.number().describe("Has at least one open blocker, or status blocked."),
1997
+ overdue: z.number(),
1998
+ unassigned: z.number(),
1999
+ orphans: z.number().describe("No parent — unreachable from any plan's containment walk."),
2000
+ noNotes: z.number().describe("No prose goal — the rows a puller cannot act on."),
2001
+ readyIds: z.array(z.string()).describe("Top 50 ready rows by priority."),
2002
+ blockedIds: z.array(z.string()).describe("Top 50 blocked rows by priority."),
2003
+ }).optional(),
2004
+ tasks: z.array(z.object({
2005
+ tid: z.string(),
2006
+ name: z.string(),
2007
+ status: z.string(),
2008
+ priority: z.number(),
2009
+ tags: z.array(z.string()).describe("Bare tags; workspace:/@assignee are lifted into their own fields."),
2010
+ assignee: z.string().optional(),
2011
+ workspace: z.string(),
2012
+ parent: z.string().optional(),
2013
+ blockedBy: z.array(z.string()).optional(),
2014
+ openBlockers: z.number().optional().describe("How many of blockedBy are not yet done/verified/dissolved."),
2015
+ ready: z.boolean(),
2016
+ dueAt: z.string().optional(),
2017
+ overdue: z.boolean().optional(),
2018
+ // include: dates
2019
+ startAt: z.string().optional(),
2020
+ createdAt: z.string().optional(),
2021
+ closedAt: z.string().optional(),
2022
+ // include: notes
2023
+ notes: z.string().optional(),
2024
+ // include: graph
2025
+ children: z.array(z.string()).optional(),
2026
+ blocks: z.array(z.string()).optional(),
2027
+ // include: thread — the same D1 conversation tasks:comment writes and /in lists
2028
+ thread: z.object({
2029
+ threadId: z.string().optional().describe("The inbox thread id; absent = nobody has commented yet."),
2030
+ comments: z.number(),
2031
+ lastAt: z.string().optional(),
2032
+ lastAuthor: z.string().optional(),
2033
+ lastBody: z.string().optional().describe("First 280 chars of the latest message."),
2034
+ }).optional(),
2035
+ })).optional(),
2036
+ error: z.string().optional(),
2037
+ }),
2038
+ effect: "ask", idempotent: true, auth: "member",
2039
+ examples: [
2040
+ { workspace: "one", view: "summary" },
2041
+ { workspace: "one", scope: "tree", status: "active", ready: true, limit: 100 },
2042
+ { workspace: "one", anyTags: ["launch", "story"], include: ["notes", "graph"] },
2043
+ ],
2044
+ }),
2045
+ // tasks:bulk — the ONE-REQUEST door for N task mutations.
2046
+ //
2047
+ // Every other task write here takes a single `tid`, so refining a 595-row board
2048
+ // (measured, workspace `one`, 2026-09-11) costs 595+ round trips. That is the
2049
+ // reason the board has never been refined. This takes up to 25 rows and reports
2050
+ // a receipt PER ROW — never a single top-level ok that hides a partial run.
2051
+ //
2052
+ // It reimplements no write: the resolver loops and calls the existing
2053
+ // single-tid resolvers with the SAME attested ctx, so authority, the status
2054
+ // gates and the D1 tag mirror are all inherited rather than re-derived. The
2055
+ // `workspace` field (envelope or per row) is a REQUEST, exactly as on every
2056
+ // single-tid write — effectiveWorkspace downgrades it when the caller is
2057
+ // neither staff nor in control of it.
2058
+ "tasks:bulk": receiver({
2059
+ receiver: "tasks:bulk",
2060
+ surfaces: { mcp: true },
2061
+ summary: "Plan and act on many tasks in ONE request. Three modes, combinable: `creates` files up to 25 new tasks (with `ref` handles so rows in the same call can parent/block each other — a whole plan tree in one call); `edits` changes up to 25 named rows (title/status/priority/notes/assignee/tags/dates/dependencies/parent/comment — `parent` MOVES a row under another, the one door that writes `containment` after birth, and an empty string makes it a root again); `where`+`set` applies ONE edit to every row a tasks:board filter matches (dryRun defaults TRUE — you see the matched tids before anything moves; applies 25 per call and returns `nextCursor` to continue). Returns a receipt PER ROW (ok, per-field reason, retryable) plus total/attempted/applied/failed — a row never attempted says so by name, so a partial run can never read as a success.",
2062
+ request: z.object({
2063
+ edits: z.array(z.object({
2064
+ tid: z.string(),
2065
+ title: z.string().optional(),
2066
+ status: z.string().optional().describe("open | blocked | picked | done | verified | failed | dissolved"),
2067
+ priority: z.number().optional().describe("1-100 slider, same scale as tasks:priority"),
2068
+ notes: z.string().optional().describe("Prose goal; empty string clears"),
2069
+ parent: z.string().optional().describe("MOVE this row under another — the only door that writes a `containment` edge AFTER birth (tasks:create and tasks:subtask write one only at birth, which is why a story could never be made a sub-story of another). An existing task id, or a `ref` created EARLIER in `creates`. EMPTY STRING CLEARS: the row becomes a root again, and clearing a row that already had no parent is a silent success. Refused by name, never silently: `cycle` if the new parent is this row or any row beneath it (walked transitively, and a walk that could not FINISH answers `undetermined` and is refused — never guessed at); `not_found` if the parent does not exist, OR the caller lacks operate access to it, OR the row's CURRENT parent is one the caller cannot operate (detaching changes that tree too) — the same rule, and the same word, tasks:create's `parent` uses; `cross_workspace` if the two ends live in different workspaces and the caller is not staff. CLAIM-GATE CONSEQUENCE — this is not only a tree edit: `tasks:claim` refuses `picked` while an OPEN `containment` child exists, so hanging an open row under a claimable parent makes that parent UNCLAIMABLE, and moving the last open child away makes it claimable again. Deliberately absent from `set`: a filter-driven mass re-parent moves whole subtrees at once — and multiplies that claim-gate consequence by the match count — so this is per-row only."),
2070
+ assignee: z.string().optional().describe("Actor slug; empty string unassigns"),
2071
+ addTags: z.array(z.string()).optional().describe("Bare words only — no ':' and no leading '@'"),
2072
+ removeTags: z.array(z.string()).optional(),
2073
+ dueAt: z.string().nullable().optional().describe("ISO date; null or '' clears. Same semantics as tasks:schedule"),
2074
+ startAt: z.string().nullable().optional(),
2075
+ addBlockedBy: z.array(z.string()).optional().describe("Task ids (or `ref`s from `creates`) this row must wait for — tasks:depend per id"),
2076
+ removeBlockedBy: z.array(z.string()).optional().describe("tasks:undepend per id"),
2077
+ comment: z.string().optional().describe("Post to the task's inbox thread (tasks:comment) — say WHY you changed it, so the humans watching the thread see the decision"),
2078
+ workspace: z.string().optional().describe("Per-row override of the envelope workspace. A request, never a grant."),
2079
+ })).max(25).optional(),
2080
+ creates: z.array(z.object({
2081
+ ref: z.string().optional().describe("A local handle, e.g. 'a'. Other rows in THIS call may name it in parent/blockedBy/addBlockedBy; the receipt maps ref → tid."),
2082
+ title: z.string(),
2083
+ notes: z.string().optional(),
2084
+ tags: z.array(z.string()).optional(),
2085
+ assignee: z.string().optional(),
2086
+ priority: z.number().optional(),
2087
+ parent: z.string().optional().describe("Existing task id or a ref created EARLIER in this array"),
2088
+ blockedBy: z.array(z.string()).optional().describe("Existing task ids or refs created earlier in this array"),
2089
+ dueAt: z.string().optional(),
2090
+ workspace: z.string().optional(),
2091
+ })).max(25).optional(),
2092
+ where: z.object({
2093
+ status: z.union([z.string(), z.array(z.string())]).optional(),
2094
+ tags: z.array(z.string()).optional(),
2095
+ anyTags: z.array(z.string()).optional(),
2096
+ assignee: z.string().optional(),
2097
+ parent: z.string().optional(),
2098
+ search: z.string().optional(),
2099
+ ready: z.boolean().optional(),
2100
+ scope: z.enum(["own", "tree"]).optional(),
2101
+ }).optional().describe("A tasks:board filter. Requires `set`. Matches are read from the same snapshot tasks:board serves."),
2102
+ set: z.object({
2103
+ status: z.string().optional(),
2104
+ priority: z.number().optional(),
2105
+ assignee: z.string().optional(),
2106
+ addTags: z.array(z.string()).optional(),
2107
+ removeTags: z.array(z.string()).optional(),
2108
+ dueAt: z.string().nullable().optional(),
2109
+ comment: z.string().optional(),
2110
+ }).optional().describe("The ONE edit applied to every `where` match. title/notes are deliberately absent — those are per-row."),
2111
+ dryRun: z.boolean().optional().describe("For `where`: defaults TRUE. Pass false to apply. Ignored by edits/creates."),
2112
+ cursor: z.string().optional().describe("For `where`: the nextCursor from the previous call"),
2113
+ workspace: z.string().optional().describe("Workspace to act in, for every row. Honoured only if you are staff or control it."),
2114
+ }).refine((v) => (v.edits?.length ?? 0) + (v.creates?.length ?? 0) > 0 || (!!v.where && !!v.set), {
2115
+ message: "send edits, creates, or where+set",
2116
+ path: ["edits"],
2117
+ }).refine((v) => !v.where === !v.set, { message: "where and set go together", path: ["where"] }),
2118
+ response: z.object({
2119
+ ok: z.boolean().describe("The CALL's outcome, not the rows'. Read applied/failed."),
2120
+ total: z.number().optional(),
2121
+ attempted: z.number().optional(),
2122
+ applied: z.number().optional(),
2123
+ failed: z.number().optional(),
2124
+ notAttempted: z.number().optional(),
2125
+ error: z.string().optional(),
2126
+ detail: z.string().optional(),
2127
+ created: z.record(z.string(), z.string()).optional().describe("ref → tid for every `creates` row that landed"),
2128
+ matched: z.number().optional().describe("`where`: rows the filter matched in total, across all pages"),
2129
+ matchedIds: z.array(z.string()).optional().describe("`where`: the tids this call covers (the ones it would apply, on dryRun)"),
2130
+ dryRun: z.boolean().optional(),
2131
+ nextCursor: z.string().optional().describe("`where`: present iff more matches remain — resend the same call with this cursor"),
2132
+ results: z.array(z.object({
2133
+ tid: z.string(),
2134
+ ref: z.string().optional(),
2135
+ ok: z.boolean(),
2136
+ reason: z.string().optional(),
2137
+ retryable: z.boolean().optional(),
2138
+ fields: z.array(z.object({
2139
+ field: z.string(),
2140
+ ok: z.boolean(),
2141
+ reason: z.string().optional(),
2142
+ detail: z.string().optional(),
2143
+ retryable: z.boolean().optional(),
2144
+ })).optional(),
2145
+ })).optional(),
2146
+ }),
2147
+ effect: "ask", idempotent: false, auth: "member",
2148
+ examples: [
2149
+ { edits: [{ tid: "task:abc", status: "dissolved", comment: "Superseded by task:def" }, { tid: "task:def", notes: "Done when X", addTags: ["planning"] }], workspace: "one" },
2150
+ { creates: [{ ref: "plan", title: "Launch the pricing page" }, { ref: "copy", title: "Write pricing copy", parent: "plan" }, { title: "Ship pricing page", parent: "plan", blockedBy: ["copy"] }], workspace: "one" },
2151
+ { where: { status: "open", tags: ["launch"], assignee: "" }, set: { assignee: "cmo", comment: "Routing unowned launch work to marketing" }, dryRun: true, workspace: "one" },
2152
+ { creates: [{ ref: "arc", title: "The story we are actually telling", tags: ["story"] }], edits: [{ tid: "task:oldstory", parent: "arc", comment: "Nested under the main story" }, { tid: "task:looseplan", parent: "" }], workspace: "one" },
2153
+ ],
2154
+ }),
1854
2155
  "tasks:follow": receiver({
1855
2156
  receiver: "tasks:follow",
1856
2157
  surfaces: { mcp: true },
@@ -2667,6 +2968,10 @@ export const RECEIVERS = {
2667
2968
  // author (resolver-body-actorId-not-identity) and needs an attestation
2668
2969
  // decision, not a schema line.
2669
2970
  role: z.enum(["user", "assistant"]).optional(),
2971
+ // The structured envelope forwarded from `/signal/:group` — see
2972
+ // `web/src/lib/signal-meta.ts SignalMeta`. Loose on purpose (see
2973
+ // tasks:announce's `meta` field for why).
2974
+ meta: z.record(z.string(), z.unknown()).optional(),
2670
2975
  }),
2671
2976
  response: z.object({
2672
2977
  ok: z.boolean(),
@@ -2879,6 +3184,7 @@ export const RECEIVERS = {
2879
3184
  response: z.object({
2880
3185
  ok: z.boolean(),
2881
3186
  delivered: z.string().optional(), // 'web' | 'telegram' | 'discord' | 'failed'
3187
+ deliveryError: z.string().optional(), // present iff delivered==='failed' — the platform's own words; the reply IS still persisted
2882
3188
  kind: z.string().optional(),
2883
3189
  error: z.string().optional(),
2884
3190
  }),
@@ -3659,7 +3965,14 @@ export const RECEIVERS = {
3659
3965
  surfaces: { mcp: true },
3660
3966
  summary: "List a workspace's pages with status",
3661
3967
  request: z.object({ slug: z.string() }),
3662
- response: z.object({ pages: z.array(z.object({ slug: z.string(), title: z.string(), status: z.string() })) }),
3968
+ response: z.object({ pages: z.array(z.object({
3969
+ slug: z.string(),
3970
+ title: z.string(),
3971
+ status: z.string(),
3972
+ url: z.string().optional().describe("The page's public path, /p/<slug>"),
3973
+ updated_at: z.number().optional().describe("Last modified, epoch ms"),
3974
+ views: z.number().nullable().optional().describe("Pageviews from the analytics pixel. NULL means no pageview row exists — render it as '—', NOT as 0. A page live for five minutes with no visitors and a page nothing is measuring must not read the same."),
3975
+ })) }),
3663
3976
  effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "member",
3664
3977
  }),
3665
3978
  "pages:publish": receiver({
@@ -3676,6 +3989,55 @@ export const RECEIVERS = {
3676
3989
  response: z.object({ ok: z.boolean(), published: z.number().optional(), error: z.string().optional() }),
3677
3990
  effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "member",
3678
3991
  }),
3992
+ // WHY THIS IS DECLARED. `pages:delete` shipped as a resolver with no registry
3993
+ // row, so it reached the handler only through the undeclared-receiver escape
3994
+ // hatch — no edge zod parsing, no auth floor. Its two live callers send
3995
+ // `{slug, page}` (`scripts/demo-instantiate-movers.ts`) and
3996
+ // `{slug, actorId, page}` (`channels/src/tools/pages.ts`). `actorId` is NOT
3997
+ // declared here on purpose: `pagesDenyReason` authorizes off `ctx` alone and
3998
+ // has never read it, so declaring it would publish a field nothing consumes
3999
+ // and invite a caller to think it authorizes something.
4000
+ //
4001
+ // `auth: "member"` matches every sibling in this family. A tighter floor
4002
+ // reasoned out fresh would break the channels tool, and the break would look
4003
+ // like a bug in whatever called it.
4004
+ "pages:delete": receiver({
4005
+ receiver: "pages:delete",
4006
+ summary: "Permanently delete a workspace page. NOT REVERSIBLE — pages:restore only UPDATEs an existing row and cannot re-insert a deleted one, so nothing that ships can undo this.",
4007
+ request: z.object({ slug: z.string(), page: z.string() }),
4008
+ response: z.object({ ok: z.boolean(), slug: z.string().optional(), title: z.string().optional(), error: z.string().optional() }),
4009
+ effect: "ask", cost: "free", reversible: false, idempotent: true, auth: "member",
4010
+ }),
4011
+ "pages:unpublish": receiver({
4012
+ receiver: "pages:unpublish",
4013
+ summary: "Take a published page back to draft — the inverse of pages:publish. Writes no version snapshot (no content changes) and leaves published_at as the record of when it last went live.",
4014
+ request: z.object({ slug: z.string(), page: z.string() }),
4015
+ response: z.object({ ok: z.boolean(), slug: z.string().optional(), title: z.string().optional(), url: z.string().optional(), status: z.string().optional(), error: z.string().optional() }),
4016
+ effect: "ask", cost: "free", reversible: true, idempotent: true, auth: "member",
4017
+ }),
4018
+ "pages:bulk": receiver({
4019
+ receiver: "pages:bulk",
4020
+ summary: "Apply ONE op (publish | unpublish | delete) to an EXPLICIT list of pages — one authority walk, one round trip, a per-row answer.",
4021
+ request: z.object({
4022
+ slug: z.string(),
4023
+ op: z.enum(["publish", "unpublish", "delete"]),
4024
+ pages: z.array(z.string()).min(1).max(100).describe("Page slugs, REQUIRED and non-empty. There is deliberately no omitted-means-all case: pages:publish-pack has one, and an implicit whole-workspace scope is exactly what a selection UI must never be able to send. Over 100 is refused BY NAME (`too_many:N>100`), never truncated."),
4025
+ }),
4026
+ response: z.object({
4027
+ ok: z.boolean().describe("Describes THE CALL, not the rows. A run where every row failed still answers ok:true — read `changed` and `failed`, never this, to report what happened."),
4028
+ op: z.string().optional(),
4029
+ requested: z.number().optional().describe("Rows attempted, after de-duplication."),
4030
+ changed: z.number().optional().describe("Rows the op actually changed. This is the number to quote."),
4031
+ failed: z.number().optional().describe("requested - changed. Present even when 0, so a caller cannot miss it."),
4032
+ results: z.array(z.object({
4033
+ slug: z.string(), ok: z.boolean(), title: z.string().optional(), error: z.string().optional(),
4034
+ })).optional().describe("Per-row outcome, in the order attempted. A failed row names its own reason (`not_found`, `no_db`)."),
4035
+ error: z.string().optional(),
4036
+ }),
4037
+ // `reversible: false` because delete is one of the three ops and the
4038
+ // envelope cannot be conditional. publish/unpublish are each other's undo.
4039
+ effect: "ask", cost: "free", reversible: false, idempotent: true, auth: "member",
4040
+ }),
3679
4041
  "pages:fill-pack": receiver({
3680
4042
  receiver: "pages:fill-pack",
3681
4043
  summary: "Fill a pack's instantiated pages with real business facts — one call, still drafts. Never fabricates a testimonial; pricing derives from one rate, not typed per page.",
@@ -4319,7 +4681,7 @@ export const RECEIVERS = {
4319
4681
  receiver: "workflow:runs",
4320
4682
  surfaces: { mcp: true },
4321
4683
  summary: "List recent runs of a workflow (D1 workflow_run) for the monitor + history surfaces",
4322
- request: z.object({ workflowId: z.string(), runId: z.string().optional(), limit: z.number().int().min(1).max(200).optional() }),
4684
+ request: z.object({ workflowId: z.string(), runId: z.string().optional(), limit: z.number().int().min(1).max(200).optional(), stepId: z.string().optional(), stepLimit: z.number().int().min(1).max(100).optional() }),
4323
4685
  response: z.object({
4324
4686
  runs: z.array(z.object({
4325
4687
  id: z.string(), status: z.string(),
@@ -5510,6 +5872,188 @@ export const RECEIVERS = {
5510
5872
  reversible: false, idempotent: false, settles: "none",
5511
5873
  examples: [{ slug: "story:demo", kept: false }],
5512
5874
  }),
5875
+ // ── duty: — provision that was PROMISED, recorded as delivered or missed ──
5876
+ // (resolvers/duty.ts · migrations/0245_duties.sql · lib/ehc/duty.ts)
5877
+ //
5878
+ // The family exists because `promise:*` inverts wrong for a statutory duty:
5879
+ // `promises.ts:96` lets the maker settle its own promise, and `:112` defaults
5880
+ // a missing verdict to KEPT. Here the certifier is a DIFFERENT actor, refused
5881
+ // at write time by `CHECK (certifier <> holder)`, and NO caller supplies a
5882
+ // verdict at all — the state is computed from counts and the clock, so a
5883
+ // window that lapsed with nothing recorded reads as `breached`, not as blank.
5884
+ // Spec: text/ehc-substrate-plan.md §3.1.
5885
+ "duty:make": receiver({
5886
+ receiver: "duty:make",
5887
+ summary: "State a duty you OWE — terms, one observable, an owed count, a due_at, and a certifier who must not be you. The holder is the attested caller, never a body field; certifier === holder is refused by the resolver and by a D1 CHECK",
5888
+ request: z.object({
5889
+ slug: z.string().describe("Stable id, e.g. ehc:cyp-005:H2. [A-Za-z0-9_:/-], max 128"),
5890
+ terms: z.string().describe("What is owed — hashed verbatim into terms_hash"),
5891
+ observable: z.string().describe("What ONE delivery looks like: 'a meal, on a date, received' — not 'a meal service was commissioned'"),
5892
+ certifier: z.string().describe("Who may attest delivery. MUST NOT be the holder — the duty-holder never grades its own homework"),
5893
+ owed: z.number().int().describe("How many deliveries are owed. 0 means not yet quantified and computes to state 'unknown', never 'met'"),
5894
+ due_at: z.number().optional().describe("Epoch ms the window closes. ABSENT IS UNKNOWN, never 'no deadline' — an unwritten window computes to 'unknown', never to on-track"),
5895
+ }),
5896
+ response: z.object({
5897
+ ok: z.boolean(),
5898
+ slug: z.string().optional(),
5899
+ version: z.number().optional(),
5900
+ state: z.enum(["unknown", "owed", "part-met", "met", "breached"]).optional(),
5901
+ terms_hash: z.string().optional(),
5902
+ certifier: z.string().optional(),
5903
+ error: z.string().optional(),
5904
+ }),
5905
+ effect: "ask", cost: "free", auth: "member",
5906
+ reversible: false, idempotent: true, settles: "none",
5907
+ examples: [{ slug: "ehc:cyp-005:H2", terms: "A hot meal every weekday, including school holidays", observable: "A meal, on a date, received", certifier: "ehc-social-worker", owed: 45 }],
5908
+ }),
5909
+ "duty:amend": receiver({
5910
+ receiver: "duty:amend",
5911
+ summary: "Amend by LINEAGE — writes a new row at version+1 with `supersedes`; the prior version is never mutated and never deleted. Holder only today: an amendment against the holder's will needs a tribunal rung that does not exist yet (§3.3 Q3) and is refused by name",
5912
+ request: z.object({
5913
+ slug: z.string(),
5914
+ terms: z.string().optional(),
5915
+ observable: z.string().optional(),
5916
+ certifier: z.string().optional().describe("Still must not equal the holder"),
5917
+ owed: z.number().int().optional(),
5918
+ due_at: z.number().nullable().optional(),
5919
+ }),
5920
+ response: z.object({
5921
+ ok: z.boolean(),
5922
+ slug: z.string().optional(),
5923
+ version: z.number().optional(),
5924
+ supersedes: z.string().nullable().optional(),
5925
+ state: z.enum(["unknown", "owed", "part-met", "met", "breached"]).optional(),
5926
+ terms_hash: z.string().optional(),
5927
+ blocked_on: z.string().optional().describe("'tribunal-rung' — the missing authority, named rather than silently allowed"),
5928
+ error: z.string().optional(),
5929
+ }),
5930
+ effect: "ask", cost: "free", auth: "member",
5931
+ reversible: false, idempotent: false, settles: "none",
5932
+ examples: [{ slug: "ehc:cyp-005:H2", owed: 190, terms: "A hot meal every weekday of the YEAR, holidays included" }],
5933
+ }),
5934
+ "duty:evidence": receiver({
5935
+ receiver: "duty:evidence",
5936
+ summary: "File ONE delivery against the current version — the CERTIFIER only, matched against the persisted certifier from the attested caller. Idempotent by sha256(slug‖version‖ref), so a re-file changes nothing. A new delivery MARKS the holder's path",
5937
+ request: z.object({
5938
+ slug: z.string(),
5939
+ ref: z.string().describe("The delivery, named: 'meal 2026-09-12', 'SLT session note wk37'"),
5940
+ version: z.number().int().optional().describe("Defaults to the current version; an older one is refused, not back-filed quietly"),
5941
+ }),
5942
+ response: z.object({
5943
+ ok: z.boolean(),
5944
+ slug: z.string().optional(),
5945
+ version: z.number().optional(),
5946
+ id: z.string().optional(),
5947
+ evidenced: z.number().optional().describe("A COUNT over duty_evidence, never a stored column"),
5948
+ owed: z.number().optional(),
5949
+ state: z.enum(["unknown", "owed", "part-met", "met", "breached"]).optional(),
5950
+ recorded: z.boolean().optional().describe("false ⇒ this exact delivery was already on record"),
5951
+ error: z.string().optional(),
5952
+ }),
5953
+ effect: "ask", cost: "free", auth: "member",
5954
+ reversible: false, idempotent: true, settles: "none",
5955
+ examples: [{ slug: "ehc:cyp-005:H2", ref: "hot meal received 2026-09-12" }],
5956
+ }),
5957
+ "duty:breach": receiver({
5958
+ receiver: "duty:breach",
5959
+ summary: "Compute the verdict and land it in the record. SILENCE IS BREACH: owed > count(evidence) with the window closed is `breached`, and no caller supplies a verdict. Warns the holder's path on the transition into breach — once, because the TRANSITION is the event. `breached` is NOT terminal: late evidence recomputes to `met`",
5960
+ request: z.object({ slug: z.string() }),
5961
+ response: z.object({
5962
+ ok: z.boolean(),
5963
+ slug: z.string().optional(),
5964
+ version: z.number().optional(),
5965
+ state: z.enum(["unknown", "owed", "part-met", "met", "breached"]).optional(),
5966
+ changed: z.boolean().optional(),
5967
+ owed: z.number().optional(),
5968
+ evidenced: z.number().optional(),
5969
+ due_at: z.number().nullable().optional(),
5970
+ holder: z.string().optional(),
5971
+ breached: z.boolean().optional(),
5972
+ error: z.string().optional(),
5973
+ }),
5974
+ effect: "ask", cost: "free", auth: "member",
5975
+ reversible: true, idempotent: true, settles: "none",
5976
+ examples: [{ slug: "ehc:cyp-005:H2" }],
5977
+ }),
5978
+ "duty:get": receiver({
5979
+ receiver: "duty:get",
5980
+ summary: "Read a duty with its state COMPUTED, writing nothing — the read a plan surface makes. NOT public (a duty names a child): holder, certifier or platform staff only. The family's own rung is not modelled yet",
5981
+ request: z.object({ slug: z.string() }),
5982
+ response: z.object({
5983
+ ok: z.boolean(),
5984
+ slug: z.string().optional(),
5985
+ version: z.number().optional(),
5986
+ supersedes: z.string().nullable().optional(),
5987
+ holder: z.string().optional(),
5988
+ certifier: z.string().optional(),
5989
+ terms: z.string().optional(),
5990
+ observable: z.string().optional(),
5991
+ owed: z.number().optional(),
5992
+ evidenced: z.number().optional(),
5993
+ due_at: z.number().nullable().optional(),
5994
+ state: z.enum(["unknown", "owed", "part-met", "met", "breached"]).optional(),
5995
+ stored_state: z.string().optional().describe("The cached column. It should equal `state`; a divergence means nothing has recomputed since the window closed"),
5996
+ error: z.string().optional(),
5997
+ }),
5998
+ effect: "ask", cost: "free", auth: "member",
5999
+ reversible: true, idempotent: true, settles: "none",
6000
+ examples: [{ slug: "ehc:cyp-005:H2" }],
6001
+ }),
6002
+ // ── ui: — an agent's hand on the operator's own browser ───────────────────
6003
+ //
6004
+ // The ONLY receiver in the registry whose effect is a MOVE OF A HUMAN'S
6005
+ // SCREEN, so it is the only one where "authority off ctx, never the payload"
6006
+ // is not hygiene but the whole feature. Given a target-viewer field, this
6007
+ // receiver is a machine for pushing any actor's reader anywhere — so there is
6008
+ // no such field, and a payload that names one is REFUSED rather than ignored
6009
+ // (silently stripping it would answer ok:true to a caller whose model of the
6010
+ // world is wrong, and teach it the call worked).
6011
+ "ui:navigate": receiver({
6012
+ receiver: "ui:navigate",
6013
+ summary: "Move the CALLER'S OWN reader to a same-origin path. Two independent checks, because one of them runs in code an untrusted caller can reach: (1) the SERVER addresses only the session that made this call — authority comes off the attested ctx, there is NO field naming a principal — `viewer`, `viewerId`, `actorId`, `actor`, `target`, `targetViewer`, `targetActor`, `session`, `sessionId`, `userId`, `uid`, `ownerSlug`, `audience` — and a payload carrying any of them is REFUSED outright rather than silently stripped (`workspace`/`slug` are NOT refused: they scope, they cannot name a reader); (2) the BROWSER independently drops any command that did not arrive on a stream it opened itself, so a command that somehow escaped (1) still moves nobody. Same-origin PATHS only — an absolute URL, a scheme, or a protocol-relative href is refused, never rewritten.",
6014
+ request: z
6015
+ .object({
6016
+ href: z
6017
+ .string()
6018
+ .min(1)
6019
+ .describe("Where to. A SAME-ORIGIN PATH: one leading '/', e.g. '/u/one/in'. Refused, never sanitised: an absolute URL ('https://evil.com/x'), any scheme ('javascript:', 'data:'), a protocol-relative href ('//evil.com'), the backslash form ('/\\evil.com'), a bare host ('evil.com/x'), and any href containing a tab/CR/LF. Measured against node's WHATWG parser: new URL('//evil.com', 'https://one.ie'), new URL('/\\evil.com', …) and new URL('/<TAB>/evil.com', …) ALL resolve to https://evil.com/ — the parser strips tab/CR/LF anywhere in the input, so the tab form is a real bypass of a naive startsWith('/') check. A navigate receiver that accepts arbitrary hrefs is an open redirect with an agent attached."),
6020
+ reason: z
6021
+ .enum(["select", "command", "agent"])
6022
+ .optional()
6023
+ .describe("Why the move happened, for the host's own judgment. Mirrors NavigateRequest.reason in one.ie/web/src/lib/navigate.ts, and is ECHOED back on the response so the transport has something to forward. CALLER-ASSERTED and carrying NO authority: an agent is free to send 'select', which reads as 'an operator clicked'. Nothing gates on it, and a host must not read it as evidence that a human was there."),
6024
+ replace: z
6025
+ .boolean()
6026
+ .optional()
6027
+ .describe("Replace the current history entry instead of pushing a new one. Default false: collapsing the entry deletes the operator's way back, so it is opt-in."),
6028
+ })
6029
+ .describe("There is deliberately no field naming WHO to move. The reader moved is always the caller's own, resolved from the attested session server-side. If you find yourself wanting a target, that is the defect arriving."),
6030
+ response: z.object({
6031
+ ok: z.boolean(),
6032
+ href: z.string().optional().describe("The href as accepted — byte-identical to the request, never a rewritten one"),
6033
+ replace: z.boolean().optional(),
6034
+ reason: z
6035
+ .enum(["select", "command", "agent"])
6036
+ .optional()
6037
+ .describe("The request's `reason`, echoed unchanged. Caller-asserted — never evidence of a human"),
6038
+ audience: z
6039
+ .string()
6040
+ .optional()
6041
+ .describe("The caller's OWN attested slug — echoed so a caller can see whose reader it addressed. Never a value the caller supplied"),
6042
+ delivered: z
6043
+ .boolean()
6044
+ .optional()
6045
+ .describe("Whether the command actually reached a browser. FALSE today for every call: the receiver validates and addresses, and the transport that carries it to the reader is a separate row (task:01a0a3789956c0b2d78d2487). A receiver that reached nobody must say so rather than answer a bare ok:true — the route:to-* namespace is the standing example of what the other choice costs"),
6046
+ note: z.string().optional(),
6047
+ error: z.string().optional(),
6048
+ }),
6049
+ effect: "ask",
6050
+ cost: "free",
6051
+ auth: "session",
6052
+ reversible: true,
6053
+ idempotent: false,
6054
+ settles: "none",
6055
+ examples: [{ href: "/u/one/in", reason: "agent" }],
6056
+ }),
5513
6057
  };
5514
6058
  /**
5515
6059
  * RECIPES — the four agent journeys as typed, ordered receiver sequences (C6).