@paigy/mcp 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-X42EUXML.js → chunk-PRC6GKRN.js} +2113 -647
- package/dist/chunk-UG2FARVV.js +54 -0
- package/dist/chunk-VWVZLPZD.js +143 -0
- package/dist/{chunk-45CIZLCJ.js → chunk-WNE6STMA.js} +668 -463
- package/dist/chunk-XIPO3U6I.js +309 -0
- package/dist/enable.js +3 -2
- package/dist/index.js +110 -349
- package/dist/listen.js +31 -34
- package/dist/onboard.js +59 -42
- package/dist/statusline.js +1 -1
- package/package.json +7 -7
- package/dist/chunk-G2WR7FCJ.js +0 -177
|
@@ -1,16 +1,113 @@
|
|
|
1
1
|
// ../../packages/schema/dist/index.js
|
|
2
|
+
import { z as z2 } from "zod";
|
|
2
3
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
5
|
+
var OPTIONS_MIN = 2;
|
|
6
|
+
var OPTIONS_MAX = 6;
|
|
7
|
+
var MISSED_CALL_PLAN = {
|
|
8
|
+
retry_10m: { kind: "every", minutes: 10 },
|
|
9
|
+
retry_30m: { kind: "every", minutes: 30 },
|
|
10
|
+
retry_60m: { kind: "every", minutes: 60 },
|
|
11
|
+
backoff_gentle: { kind: "at", minutes: [30, 120, 360] },
|
|
12
|
+
backoff_standard: { kind: "at", minutes: [10, 30, 120] },
|
|
13
|
+
backoff_aggressive: { kind: "at", minutes: [5, 15, 45] },
|
|
14
|
+
inbox: { kind: "once" },
|
|
15
|
+
dismiss: { kind: "grace", minutes: 2 }
|
|
16
|
+
};
|
|
17
|
+
function draft2020(node) {
|
|
18
|
+
if (Array.isArray(node)) return node.map(draft2020);
|
|
19
|
+
if (node && typeof node === "object") {
|
|
20
|
+
const o = node;
|
|
21
|
+
for (const [excl, lim] of [["exclusiveMinimum", "minimum"], ["exclusiveMaximum", "maximum"]]) {
|
|
22
|
+
if (typeof o[excl] === "boolean") {
|
|
23
|
+
if (o[excl] === true && typeof o[lim] === "number") {
|
|
24
|
+
o[excl] = o[lim];
|
|
25
|
+
delete o[lim];
|
|
26
|
+
} else delete o[excl];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const k of Object.keys(o)) o[k] = draft2020(o[k]);
|
|
30
|
+
return o;
|
|
31
|
+
}
|
|
32
|
+
return node;
|
|
33
|
+
}
|
|
34
|
+
function mcpInputSchema(s) {
|
|
35
|
+
const schema = zodToJsonSchema(s, { target: "jsonSchema2019-09", $refStrategy: "none" });
|
|
36
|
+
delete schema.$schema;
|
|
37
|
+
return draft2020(schema);
|
|
38
|
+
}
|
|
39
|
+
var CreateGoalSchema = z.object({
|
|
40
|
+
outcome: z.string().trim().min(1).max(1e4),
|
|
41
|
+
ownerParticipant: z.string().trim().min(1).optional(),
|
|
42
|
+
idempotencyKey: z.string().trim().min(1).max(200)
|
|
43
|
+
});
|
|
44
|
+
var CREATE_GOAL_DESCRIPTION = "Create a durable root Goal for an outcome. Admission only: claim it before doing work, then update its state as it advances. Use a stable idempotencyKey so retries do not create duplicates. Returns goalId, state, revision, ownerParticipant, and next claim_goal.";
|
|
45
|
+
var fmtMin = (m) => m >= 60 ? `${m / 60} hr` : `${m} min`;
|
|
46
|
+
var STANDARD_MEANS = (() => {
|
|
47
|
+
const plan = MISSED_CALL_PLAN.backoff_standard;
|
|
48
|
+
const mins = plan.kind === "at" ? plan.minutes : [];
|
|
49
|
+
const parts = mins.map(fmtMin);
|
|
50
|
+
const list = parts.length > 1 ? `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}` : parts[0] ?? "";
|
|
51
|
+
return `Rings again ${list} after the missed call, then leaves it in your inbox`;
|
|
52
|
+
})();
|
|
53
|
+
function contactSchemaFrom(fields) {
|
|
54
|
+
const surface = z.object({
|
|
55
|
+
ask: fields.ask.describe(
|
|
56
|
+
`What to tell the user, or what you need to find out from them. Plain prose \u2014 as long as it needs to be (up to 10k characters); Paigy splits it into topics and reads back a few sentences at a time, so do NOT compress a briefing into one line. May be spoken aloud on a call, so write natural speech and name things (not IDs). Contact at exactly two moments: BLOCKED on a decision only they can make, or DONE (one short report \u2014 what shipped, how you verified it, what you flagged). DONE IS SAID ONCE: "all set", "nothing open on my end", "that thread is complete" are the same report in new words, and each one reaches them separately (live 2026-08-12: three of them in three minutes). After the first, you are finished speaking; if they acknowledge it, stop rather than confirming the acknowledgement. Progress is never a contact: set_work_state carries it, and working narration stays in your own terminal \u2014 the user sees you're working without being interrupted by it.`
|
|
57
|
+
),
|
|
58
|
+
waiting: fields.waiting.describe(
|
|
59
|
+
"What happens to your work while you wait. 'none': you're just informing them. 'soft': you'd like an answer but can keep working. 'hard': you are STOPPED until they answer \u2014 reaches them urgently and escalates to a real phone call if unanswered."
|
|
60
|
+
),
|
|
61
|
+
options: fields.options.describe(
|
|
62
|
+
`The choices the user picks from, when you have them \u2014 ${OPTIONS_MIN} to ${OPTIONS_MAX}, drawn from your own sentence.`
|
|
63
|
+
),
|
|
64
|
+
channel: fields.channel.describe(
|
|
65
|
+
"Relay how the user explicitly said to reach them ('call me' \u2192 'call', 'just message/text me' \u2192 'message'), or use 'call' when promoting the same quiet ask after it becomes a substantial blocker. Omit otherwise; Paigy picks."
|
|
66
|
+
),
|
|
67
|
+
parentId: fields.parentId.describe(
|
|
68
|
+
"To continue an earlier conversation, pass the parentId a previous contact or reply returned. Omit to start a new one."
|
|
69
|
+
),
|
|
70
|
+
workId: fields.workId.describe(
|
|
71
|
+
"The durable Work this contact advances. Pass the workId from check_replies or a prior reply when asking for a decision that blocks that work."
|
|
72
|
+
)
|
|
73
|
+
});
|
|
74
|
+
const out = mcpInputSchema(surface);
|
|
75
|
+
out.required = ["ask"];
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
var CONTACT_DESCRIPTION = `Reach the user through Paigy \u2014 tell them something, or ask and get their answer. State what you need in \`ask\`, say what happens to your work while you wait in \`waiting\`, and Paigy handles the rest (channel, phrasing, answer format). If the user explicitly asks you to CALL them, send waiting:'hard' and say so in the ask. Returns { notificationId, parentId, workId?, decisionId? } \u2014 pass notificationId to the reply path named by the returned \`message\`, and parentId to a later contact to continue the conversation. When it rang, the reply also carries { ifMissed: { mode, means } }: what the user's own policy does with a call they don't take ("${STANDARD_MEANS}"), so a no-answer tells you how long to wait before coming back. THREADING REPLACES: a threaded follow-up SUPERSEDES your earlier pending items on that thread \u2014 right for updates to one ask, WRONG for a checklist (send independent to-dos un-threaded). A threaded re-send with IDENTICAL content escalates the pending ask in place. If a reply comes back as {kind:'clarify', chunks:[...]}, the user wants more detail \u2014 contact again on the SAME parentId with an expanded ask. BLOCKED ON A DECISION for existing work? Pass that work's \`workId\`; the reply returns the same workId plus a decisionId, so the answer resumes the right outcome. ONE ASK, ONE ROW: never restate a still-pending ask's question inside a NEW contact (e.g. weaving it into a briefing) \u2014 the whole answer settles on the new row and the original can never receive it. Keep waiting on the original (a live call reads every pending ask out separately, each answer routes to its own row), and use \`needs\` for a genuinely multi-part NEW ask. ANSWERABLE, NOT JUST ASKED: when the reply comes back carrying \`plan.units[].needs\`, that unit asked for something it gave the user no way to answer \u2014 'options' means it posed a choice with nothing to choose from, 'visuals' means it asked about something to look at with nothing to look at. Send it again on the SAME parentId with ${OPTIONS_MIN}-${OPTIONS_MAX} options (or the image), drawn from your own sentence. Paigy will not add them for you: a shape it guessed wrong cannot be undone, and you are the one who knows what the real alternatives are. \`units\` reports WHAT BECAME OF YOUR PROSE \u2014 { kept, raw, why }: how many topics Paigy compressed for delivery, how many kept your exact words, and the reason when it kept them (e.g. 'no_output' = compression produced nothing usable, so the user got your raw sentence). It needs no action and is not an error \u2014 read it only when the delivered wording matters to you; a high \`raw\` count means the user is hearing you verbatim.`;
|
|
79
|
+
var CHECK_REPLIES_DESCRIPTION = "The catch-up sweep for everything outstanding \u2014 a PURE read, takes no arguments, safe to call as often as you like: nothing here is consumed by reading it. Returns `replies` (answers to notifications you sent), `work` \u2014 durable outcomes currently owned by you \u2014 plus your still-pending notifications and `requests`, requests the user started toward you (each { notificationId, parentId, workId?, text }); replies tied to Work carry workId and decisionId too. Pass workId back to contact when a new decision blocks that outcome. A REQUEST keeps reappearing until you engage with it \u2014 call set_work_state with its workId, or notificationId once when workId is absent, to claim it \u2014 because human-initiated work must never be silently dropped just because you read the list. A REPLY is different: it is acknowledged by being delivered to you, and needs no set_work_state to stop resurfacing \u2014 report state on it only when it starts real follow-up work. Also returns `threads` \u2014 the SAME replies + requests grouped by conversation, oldest thread first, each with a `busy` flag and its `items` in arrival order. WORK ONE THREAD AT A TIME: take the oldest thread whose `busy` is false, handle ALL of its items together in a single turn (one set_work_state), then go to the next \u2014 don't interleave threads item-by-item. A `busy` thread already has a turn in progress; leave it and let its new items ride the next turn. Use check_replies when booting up / starting a session, or when you've been waiting a long time on something else. To wait on an answer to a contact call you just made, use await_reply instead. Also returns owedCallbacks: callbacks now due that you promised \u2014 fulfill each with contact on its parentId. EVERY Paigy reply \u2014 this one, await_reply's, and contact's \u2014 may carry `also`: work assigned to you that no wake could reach, handed to you because you happened to be here. It is NOT what you asked about and it is never urgent: FINISH what you came for first, then take it up. Each entry has a `noteId` and the owner's own words; report on its `parentId` thread when it has one, and call set_work_state with its noteId as the bootstrap notificationId. Ignoring it costs nothing \u2014 it rides your next reply too. Also returns `stalled`: work (either direction) you reported in_progress via set_work_state a while ago and never reported completed \u2014 likely left half-done by this session or a prior one that crashed or went idle. For each, either continue the work and report a real state, or investigate why it stalled. Also returns `you` \u2014 WHICH IDENTITY you are speaking as ({ name, device, tokenId }), the same name and device the user sees on their Agents screen. This is the only safe way to find out (calling `pair` can MINT a new identity instead of telling you about the current one). Use it when the user asks who you are, and to tell whether work addressed to a name is addressed to you. A request may also carry `stranded`: it was addressed to ANOTHER agent on this account (that name) which has not been seen since it landed, so nobody came for it and it is handed to you because you are the session that is here. Take it exactly like your own \u2014 set_work_state claims it, reply with contact on its parentId \u2014 and say whose it was, because the user picked that agent on purpose. Replies may carry `intents`/`transcript`/`covered` (call-mapped answers) \u2014 handle intents exactly as await_reply's description says (defer \u2192 schedule_callback now; delegate \u2192 decide and say so; channel \u2192 honor next contact), and treat a `covered` list missing one of your declared points as that part still unanswered.";
|
|
80
|
+
var SCHEDULE_CALLBACK_DESCRIPTION = "Promise the user a follow-up you'll keep even if you go idle. Use it when they ask you to report back: trigger 'on_done' (when you finish \u2014 fires when you call set_work_state completed), 'on_blocked' (if you hit a blocker \u2014 fires on set_work_state needs_input), or 'scheduled' with dueInSeconds (e.g. 'remind me in 10 min'). Pass the parentId of the conversation and a short note. Fulfill it by calling contact on that parentId; check_replies re-lists due callbacks until you do.";
|
|
81
|
+
var SEARCH_THREADS_DESCRIPTION = `Search your PAST conversations before asking \u2014 "have we discussed this before?". Full-text over your own threads (the asks you sent + the user's answers); returns ranked threads with highlighted snippets, NOT rows: { hits: [{ parentId, at, agentLabel, matches: [{ notificationId, role, snippet }] }] }. The loop this exists for: search first \u2192 get_thread the best hit to rehydrate it \u2192 THEN continue or contact, so you answer with receipts ("last week you said ship it") instead of re-asking. Read-only, safe to call anytime; scoped to your own account's threads.`;
|
|
82
|
+
var SET_WORK_STATE_DESCRIPTION = "Report progress on durable Work. Use workId from check_replies, contact, or a reply. For a new assigned request that has only notificationId, pass that once; the result returns its workId and every later report uses workId. States: in_progress (you started or resumed it), completed (done), or needs_input (you need a human decision \u2014 follow with contact carrying the returned workId). This changes Work progress only; reply delivery and acknowledgement stay on await_reply/check_replies.";
|
|
83
|
+
function serverInstructions(opts) {
|
|
84
|
+
const waits = opts.waits;
|
|
85
|
+
return "On startup, call check_replies once to pick up any replies or pending work you missed while away. A check_replies request whose parentId you don't recognize, or one carrying a contextParentId, means the user is resuming or seeding a past conversation \u2014 call get_thread on it FIRST and treat the transcript as prior conversation, not new input. " + (waits ? "Follow contact's returned message. An inbox delivery is asynchronous: keep working and collect the answer later through check_replies. A call is live: call await_reply with that notificationId; it is scoped, so replies never cross. If a quiet ask later blocks substantial work, resend contact with the same parentId and channel:'call'. " : "You are wake-driven: you cannot wait for an answer in-context. Inbox and call answers return through check_replies. When a reply is handed to you it is LEASED \u2014 act on it, then call ack_reply with its leaseId so it is not handed to you again; a reply you never acknowledge comes back on your next wake. ") + // WHO IS ASKING, AND WHERE ARE THEY (field report, 2026-08-28 — eleven days of total
|
|
86
|
+
// silence on a live pairing). "Never end a turn that still needs the user without
|
|
87
|
+
// contact" is correct for an unattended agent and says NOTHING about the case that
|
|
88
|
+
// actually dominates: the user sitting at the terminal, where ending the turn with the
|
|
89
|
+
// question ALREADY reaches them. So the rule collapsed into two readings — fire on every
|
|
90
|
+
// clarifying question (phone spam, they unpair) or never fire at all — and every session
|
|
91
|
+
// after install day independently chose the second. Sessions start cold, so the same
|
|
92
|
+
// default got re-derived daily with no memory that yesterday did the same, and no session
|
|
93
|
+
// ever thought to ask the user which they wanted. Zero notifications for eleven days,
|
|
94
|
+
// with no error anywhere: indistinguishable from a healthy account having a quiet week.
|
|
95
|
+
//
|
|
96
|
+
// The carve-out is stated rather than left to per-session judgment, because judgment
|
|
97
|
+
// exercised cold, once per session, is not judgment — it is a coin landing the same way.
|
|
98
|
+
"Never end a turn that still needs the user without contact + await_reply \u2014 WHEN THEY ARE NOT THERE TO ASK. In an interactive session with the user at the terminal, the prompt IS the channel: ending your turn with the question already reaches them, faster and richer than a push, so do NOT send one for an ordinary blocked-or-done moment. Reach for Paigy exactly when the terminal is not enough \u2014 work that will run more than a few minutes unattended (a long build, a deploy, a background job, a cloud session), anything you finish or get stuck on while they are away, or when they have said they are stepping out. If you cannot tell which situation you are in, ask them once, in passing, how they want to be reached, and follow that for the rest of the session. When you need a decision or input, WRITE THE QUESTION and Paigy derives the answer shape from it \u2014 there is no shape parameter to set, and passing one is an error. Ask a yes/no question and they get yes/no; ask them to approve an action and they get approve/deny; ask them to pick, and to pick several, and to rank, and each gets the control it needs. So phrase the ask precisely: 'which of these should I do first' and 'should I do this' are different questions and become different answers. The one thing the prose can't supply is the CHOICES themselves \u2014 when you're asking them to pick between concrete alternatives, pass `options` (${OPTIONS_MIN}-${OPTIONS_MAX} of them, drawn from your own sentence), because Paigy will not invent alternatives it can't know. On a { kind: 'clarify' } reply, see contact's own description for how to respond. When you send waiting:'hard' (or the user asked you to call), remember the ask may be spoken aloud \u2014 write it short and conversational, and name things instead of using IDs (e.g. 'the pull request about the agents page', not 'PR #235'). When the user asks you to follow up later \u2014 when you're done, if you're blocked, or at a set time \u2014 record it with schedule_callback so you don't drop it if you go idle. If you're about to start a genuinely long-running or blocking piece of work \u2014 one where the user would otherwise sit and wait \u2014 mention ONCE, in passing, that you can reach them when it's done or if you hit a blocker, instead of them needing to babysit the terminal. Don't offer this for quick tasks, and don't repeat the offer if they've already said yes or no earlier in the conversation. NEVER go quietly idle while something might still be pending for you: whenever you end a turn with any Paigy notification unanswered (or any chance the user replied through the app while you worked), schedule your own ~2-minute wake-up (harness ScheduleWakeup or equivalent) and call check_replies when it fires; if still nothing, re-schedule and keep looping until resolved or the user says stop. For legibility, always use this exact wording \u2014 reason: 'Paigy idle check \u2014 waiting on <thing>', wake-up prompt: 'Paigy idle check: call check_replies and engage with anything unacknowledged; if idle, re-schedule (~2min).' \u2014 so the user can recognize every idle check at a glance. This self-polling in your own live session (full context intact) is the PRIMARY mechanism; the plugin's Stop hooks are only the dead-session safety net.";
|
|
99
|
+
}
|
|
100
|
+
var ContextSchema = z2.object({
|
|
101
|
+
title: z2.string().min(1).describe("One-line headline of what you need (required, non-empty)."),
|
|
102
|
+
description: z2.array(z2.string().min(1)).describe(
|
|
6
103
|
"Semantic chunks of detail (each a standalone, non-empty piece). The user can select chunks to ask you to expand. MAY BE EMPTY: a claim whose whole content is its heading \u2014 a single sentence \u2014 has no body, and saying so beats repeating the heading underneath itself. That repeat is what `min(1)` used to force, at 2x the storage, with every reader subtracting it back out at render time."
|
|
7
104
|
)
|
|
8
105
|
});
|
|
9
|
-
var ParticipantSchema =
|
|
10
|
-
kind:
|
|
11
|
-
id:
|
|
106
|
+
var ParticipantSchema = z2.object({
|
|
107
|
+
kind: z2.enum(["human", "agent"]),
|
|
108
|
+
id: z2.string()
|
|
12
109
|
});
|
|
13
|
-
var TransformSchema =
|
|
110
|
+
var TransformSchema = z2.enum([
|
|
14
111
|
"structure",
|
|
15
112
|
// shape intent into an answer contract; pick channel/urgency — broker `ask`, `select` shapes, `points`
|
|
16
113
|
"request_more",
|
|
@@ -26,25 +123,25 @@ var TransformSchema = z.enum([
|
|
|
26
123
|
"summarize"
|
|
27
124
|
// reduce volume, keep decision value — 30-turn cap, spoken briefing
|
|
28
125
|
]);
|
|
29
|
-
var OptionSchema =
|
|
30
|
-
id:
|
|
31
|
-
label:
|
|
126
|
+
var OptionSchema = z2.object({
|
|
127
|
+
id: z2.string(),
|
|
128
|
+
label: z2.string(),
|
|
32
129
|
// .describe() flows into the MCP contact JSON schema (zodToJsonSchema), so
|
|
33
130
|
// the constraints below are what an agent reads when deciding to use these.
|
|
34
|
-
html:
|
|
131
|
+
html: z2.string().max(16384).describe(
|
|
35
132
|
"Optional sandboxed HTML/CSS preview for a visual 'pick one' (shown in the option card). Untrusted-sandboxed: NO JavaScript, NO external network or images \u2014 inline CSS and data: URIs only; <=16KB. Use for layout/CSS mockups, tables, diffs. For a hosted image use `image` instead."
|
|
36
133
|
).optional(),
|
|
37
|
-
image:
|
|
134
|
+
image: z2.string().url().describe(
|
|
38
135
|
"Optional image URL rendered as the option's preview (plain image, not sandboxed). For agent-generated HTML/CSS mockups, use `html` instead."
|
|
39
136
|
).optional()
|
|
40
137
|
});
|
|
41
|
-
var VisualSchema =
|
|
42
|
-
url:
|
|
43
|
-
label:
|
|
138
|
+
var VisualSchema = z2.object({
|
|
139
|
+
url: z2.string().url(),
|
|
140
|
+
label: z2.string().optional()
|
|
44
141
|
});
|
|
45
|
-
var NotifyLevelSchema =
|
|
46
|
-
var SelectShapeSchema =
|
|
47
|
-
var ReceiptEventSchema =
|
|
142
|
+
var NotifyLevelSchema = z2.enum(["inbox", "push", "banner", "call"]);
|
|
143
|
+
var SelectShapeSchema = z2.enum(["one", "many", "rank", "confirm", "text"]);
|
|
144
|
+
var ReceiptEventSchema = z2.enum([
|
|
48
145
|
"delivered",
|
|
49
146
|
// the bundle reached the recipient at some level
|
|
50
147
|
"seen",
|
|
@@ -74,41 +171,44 @@ var ReceiptEventSchema = z.enum([
|
|
|
74
171
|
// be rewound by a writer that forgot to advance it.
|
|
75
172
|
"restarted"
|
|
76
173
|
]);
|
|
77
|
-
var AttentionSchema =
|
|
174
|
+
var AttentionSchema = z2.object({
|
|
78
175
|
urgency: NotifyLevelSchema,
|
|
79
176
|
/** The required answer shape, or null for a plain notify that asks nothing back. */
|
|
80
177
|
select: SelectShapeSchema.nullable(),
|
|
81
178
|
/** Coverage contract (#396) — points the answer must address; null = none declared. */
|
|
82
|
-
points:
|
|
179
|
+
points: z2.array(z2.string()).nullable(),
|
|
83
180
|
/** Whether the ask blocks the sender — what lets arbitration escalate it on silence. */
|
|
84
|
-
blocking:
|
|
181
|
+
blocking: z2.boolean(),
|
|
85
182
|
/** Reserved (MODEL.md lists it): a response deadline. No row column yet — a later Phase 2
|
|
86
183
|
* slice wires it; optional so today's rows/callers project cleanly. */
|
|
87
|
-
deadline:
|
|
184
|
+
deadline: z2.string().datetime().nullable().optional()
|
|
88
185
|
});
|
|
89
|
-
var
|
|
186
|
+
var NotifyRequestFields = z2.object({
|
|
90
187
|
/** Plaintext message content. Present on the plaintext path (today's shape);
|
|
91
188
|
* ABSENT on the E2EE path, where the sealed `envelope` below carries it. The
|
|
92
189
|
* superRefine at the bottom enforces exactly one of the two. */
|
|
93
190
|
context: ContextSchema.optional(),
|
|
94
|
-
options:
|
|
191
|
+
options: z2.array(OptionSchema.omit({ id: true })).min(OPTIONS_MIN).max(OPTIONS_MAX).optional().describe(
|
|
95
192
|
"The choices, in order \u2014 required when select is 'one'/'many'/'rank', omitted otherwise. Ids are assigned automatically by position ('1', '2', \u2026); the user's answer references them as optionId(s)."
|
|
96
193
|
),
|
|
97
|
-
points:
|
|
194
|
+
points: z2.array(z2.string().min(1)).optional().describe(
|
|
98
195
|
"The distinct things you need answered, each a short phrase \u2014 on a call the broker keeps the conversation going until each is addressed, and the reply reports which were covered, so a half-answer is never silently returned as final. Omit for single-part asks."
|
|
99
196
|
),
|
|
100
|
-
visuals:
|
|
197
|
+
visuals: z2.array(VisualSchema).optional().describe(
|
|
101
198
|
"Images attached to the message itself \u2014 context for the whole question (a screenshot, a chart). For a preview on one selectable choice, use that option's `html`/`image` instead."
|
|
102
199
|
),
|
|
103
200
|
/** Git repo the agent is working in ("owner/name"). Local MCP fills this from the checkout — omit unless overriding. */
|
|
104
|
-
repo:
|
|
201
|
+
repo: z2.string().optional(),
|
|
105
202
|
/** Git branch the agent is on. Local MCP fills this from the checkout — omit unless overriding. */
|
|
106
|
-
branch:
|
|
203
|
+
branch: z2.string().optional(),
|
|
107
204
|
/** Continue an existing conversation — the id of any notification in it (its root
|
|
108
205
|
* is the conversation's identity). Omitted = start a new conversation. Renamed
|
|
109
206
|
* from `parentId` (2026-08-03): one linkage system, the parent; the API edge
|
|
110
207
|
* still accepts the old name from older clients. */
|
|
111
|
-
parentId:
|
|
208
|
+
parentId: z2.string().uuid().optional(),
|
|
209
|
+
/** The durable outcome this contact advances. Optional during the notification-to-Work
|
|
210
|
+
* migration; when present, a blocking ask creates a DecisionNeed for this Work. */
|
|
211
|
+
workId: z2.string().uuid().optional(),
|
|
112
212
|
urgency: NotifyLevelSchema.default("inbox").describe(
|
|
113
213
|
"The level you're requesting \u2014 the user's account permissions + session mode can lower it. 'inbox' (default) = sits silently in the inbox for the user to get to. 'push' = a quiet passive push (lands in Notification Center, no sound) \u2014 a gentle heads-up. 'banner' = a time-sensitive banner/lock-screen push with sound (a 'paige') they tap to open \u2014 use when you need them soon-ish but it's not worth ringing them. 'call' = rings the user's phone now (a CallKit voice call) \u2014 use only when you genuinely need them in the moment (blocked and waiting, time-sensitive). context.title is what they see on the banner/ring, so make it specific."
|
|
114
214
|
),
|
|
@@ -116,7 +216,7 @@ var NotifyRequestSchema = z.object({
|
|
|
116
216
|
* visible and marks it needs_input. Renamed from the old `parentId` (2026-08-03)
|
|
117
217
|
* when `parentId` became the conversation handle: `parentId` says WHERE, this
|
|
118
218
|
* says HOW. */
|
|
119
|
-
clarifies:
|
|
219
|
+
clarifies: z2.string().optional(),
|
|
120
220
|
/** E2EE (text lane): when the pairing is E2EE, the sealed replacements for the
|
|
121
221
|
* plaintext content fields, keyed by field name. FINALIZED wire shape (was
|
|
122
222
|
* provisional in the storage PR): a per-field map `{ context?, options?,
|
|
@@ -129,10 +229,10 @@ var NotifyRequestSchema = z.object({
|
|
|
129
229
|
* notifications.envelope and relays it blindly; it never decrypts. Absent =
|
|
130
230
|
* today's plaintext path (context/options/visuals carry the cleartext).
|
|
131
231
|
* z.lazy because EnvelopeSchema is declared further down (E2EE section). */
|
|
132
|
-
envelope:
|
|
133
|
-
context:
|
|
134
|
-
options:
|
|
135
|
-
visuals:
|
|
232
|
+
envelope: z2.object({
|
|
233
|
+
context: z2.lazy(() => EnvelopeSchema).optional(),
|
|
234
|
+
options: z2.lazy(() => EnvelopeSchema).optional(),
|
|
235
|
+
visuals: z2.lazy(() => EnvelopeSchema).optional()
|
|
136
236
|
}).optional(),
|
|
137
237
|
select: SelectShapeSchema.optional().describe(
|
|
138
238
|
"How the user answers \u2014 required on the fully-shaped form, pick the shape that fits the question: 'one' = pick one option, 'many' = pick several, 'rank' = pick & order (each needs `options`); 'confirm' = yes/no or approve/deny; 'text' = free-form reply only (status updates, open questions). 'confirm' and 'text' take no options. Omit only when sending the simplified `ask` form \u2014 the broker picks the shape."
|
|
@@ -147,20 +247,20 @@ var NotifyRequestSchema = z.object({
|
|
|
147
247
|
// (broker/agenda-design.md) — not by a wire cap the agent has to pre-summarize under.
|
|
148
248
|
// Owner, 2026-07-28: "our actual limitation on how long something is to the user should
|
|
149
249
|
// come from the broker splitting and summarizing." The cap that remains is a size guard.
|
|
150
|
-
ask:
|
|
250
|
+
ask: z2.string().min(1).max(1e4).optional().describe(
|
|
151
251
|
'SIMPLIFIED FORM \u2014 state in plain prose what you need to learn from the user and why it matters now (e.g. "I need to know whether to deploy the auth fix \u2014 tests are green, staging verified"). Write as much as the situation needs (up to 10k characters) \u2014 Paigy breaks it into topics and reads it back a few sentences at a time; do NOT pre-summarize it into one line. Paigy derives the title, answer shape, options, and delivery channel for you. Mutually exclusive with context/select/options \u2014 send one form or the other.'
|
|
152
252
|
),
|
|
153
|
-
needs:
|
|
253
|
+
needs: z2.array(z2.string().min(1)).optional().describe(
|
|
154
254
|
"With `ask` only: the distinct things you need answered when the ask is multi-part \u2014 becomes the coverage contract (`points`), so a half-answer is never silently final."
|
|
155
255
|
),
|
|
156
|
-
urgencyHint:
|
|
256
|
+
urgencyHint: z2.enum(["whenever", "soon", "now"]).optional().describe(
|
|
157
257
|
"With `ask` only: how urgently you need the answer \u2014 'whenever' (inbox), 'soon' (worth a heads-up), 'now' (you're blocked this minute). A hint, not a command: the user's settings still have the final word."
|
|
158
258
|
),
|
|
159
259
|
/** #575: the ONE self-report that replaces urgencyHint + blocking — what happens
|
|
160
260
|
* to the agent's work while it waits. Normalized server-side into those two
|
|
161
261
|
* fields (normalizeWaiting) so everything downstream is untouched; explicit
|
|
162
262
|
* urgencyHint/blocking win when both are sent. */
|
|
163
|
-
waiting:
|
|
263
|
+
waiting: z2.enum(["none", "soft", "hard"]).optional().describe(
|
|
164
264
|
"With `ask`: what happens to your work while you wait. 'none' = you're just informing the user. 'soft' = you'd like an answer but can keep working. 'hard' = you are stopped until they answer (reaches them urgently and escalates to a real phone call if unanswered). Replaces urgencyHint + blocking \u2014 send this one field."
|
|
165
265
|
),
|
|
166
266
|
/** Δ9b (#895): HOLD this claim so the sender can correct the plan before anyone is
|
|
@@ -168,113 +268,123 @@ var NotifyRequestSchema = z.object({
|
|
|
168
268
|
* holding by default would charge every quiet claim that minute before any agent could
|
|
169
269
|
* correct anything. Ignored for `waiting: 'hard'`: a blocking ask rings on what we have,
|
|
170
270
|
* and the enrichment can still land mid-call (#781 re-plans the unspoken tail). */
|
|
171
|
-
confirm:
|
|
271
|
+
confirm: z2.boolean().optional().describe(
|
|
172
272
|
"Hold this one so you can correct the plan before the user is interrupted. The response comes back with `held: true` and the plan; POST the confirm route to release it (with options/visuals/urgency corrections, or nothing at all). If you never do, it is announced anyway a couple of minutes later. Ignored when waiting is 'hard'."
|
|
173
273
|
),
|
|
174
274
|
/** #575: a RELAY of the user's explicitly stated preference, never the agent's
|
|
175
275
|
* choice. Outranks waiting in both directions: 'call' rings even for a
|
|
176
276
|
* waiting:'none' "call me when it's done"; 'message' never rings even for
|
|
177
277
|
* waiting:'hard'. */
|
|
178
|
-
channel:
|
|
278
|
+
channel: z2.enum(["call", "message"]).optional().describe(
|
|
179
279
|
"Only if the user explicitly said how to reach them \u2014 'call me' \u2192 'call', 'just message/text me' \u2192 'message'. Omit otherwise; Paigy picks."
|
|
180
280
|
),
|
|
181
|
-
confirmStyle:
|
|
281
|
+
confirmStyle: z2.enum(["yesno", "approve"]).default("yesno").describe(
|
|
182
282
|
"Labels for a select:'confirm' paige \u2014 'yesno' (Yes/No) or 'approve' (Approve/Deny). Ignored unless select is 'confirm'."
|
|
183
283
|
),
|
|
184
|
-
blocking:
|
|
284
|
+
blocking: z2.boolean().default(false).describe(
|
|
185
285
|
"Set true when real downstream work is stuck behind this specific decision \u2014 you can't make meaningful progress until it's answered. This is the real signal for how urgently the user should be reached; it's what the premier use case (an agent that stays unblocked instead of going idle) depends on. Independent of `urgency`: a `banner`-level question can still be `blocking` (something IS stuck, just not time-critical enough to ring for immediately) \u2014 if it goes unanswered a while, Paigy escalates it to a real call using this flag rather than guessing from how many other things happen to be pending. Leave false for anything you could work around, defer, or where other useful work exists meanwhile."
|
|
186
286
|
)
|
|
187
|
-
})
|
|
287
|
+
});
|
|
288
|
+
var NotifyRequestSchema = NotifyRequestFields.superRefine((r, ctx) => {
|
|
188
289
|
const sealed = !!r.envelope;
|
|
189
290
|
if (sealed) {
|
|
190
291
|
if (!r.envelope?.context)
|
|
191
|
-
ctx.addIssue({ code:
|
|
292
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["envelope", "context"], message: "sealed request must include envelope.context" });
|
|
192
293
|
for (const f of ["context", "options", "visuals"]) {
|
|
193
294
|
if (r[f] !== void 0)
|
|
194
|
-
ctx.addIssue({ code:
|
|
295
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: [f], message: `E2EE request must not carry plaintext ${f} \u2014 it's sealed in envelope.${f}` });
|
|
195
296
|
}
|
|
196
297
|
if (r.points !== void 0)
|
|
197
|
-
ctx.addIssue({ code:
|
|
298
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["points"], message: "E2EE request must not carry plaintext points" });
|
|
198
299
|
if (r.ask !== void 0)
|
|
199
|
-
ctx.addIssue({ code:
|
|
300
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["ask"], message: "E2EE request must not carry a plaintext ask \u2014 derive the shape agent-side and seal it" });
|
|
200
301
|
if (r.needs !== void 0)
|
|
201
|
-
ctx.addIssue({ code:
|
|
302
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["needs"], message: "E2EE request must not carry plaintext needs" });
|
|
202
303
|
return;
|
|
203
304
|
}
|
|
204
305
|
if (r.ask !== void 0) {
|
|
205
306
|
for (const f of ["context", "select", "points"]) {
|
|
206
307
|
if (r[f] !== void 0)
|
|
207
|
-
ctx.addIssue({ code:
|
|
308
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: [f], message: `the simplified \`ask\` form takes no ${f} \u2014 the broker derives the answer shape from your prose. Drop ${f} and say it in \`ask\` instead ("should I\u2026" for approve/deny, "which of these\u2026" for a pick), passing \`options\` when you're offering concrete alternatives.` });
|
|
208
309
|
}
|
|
209
310
|
return;
|
|
210
311
|
}
|
|
211
312
|
if (r.needs !== void 0 || r.urgencyHint !== void 0)
|
|
212
|
-
ctx.addIssue({ code:
|
|
313
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["needs"], message: "needs/urgencyHint belong to the simplified `ask` form \u2014 with a shaped request use points/urgency" });
|
|
213
314
|
if (!r.context)
|
|
214
|
-
ctx.addIssue({ code:
|
|
315
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["context"], message: "context is required (plaintext path)" });
|
|
215
316
|
if (!r.select)
|
|
216
|
-
ctx.addIssue({ code:
|
|
317
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["select"], message: "select is required on the shaped form" });
|
|
217
318
|
const needsOptions = r.select === "one" || r.select === "many" || r.select === "rank";
|
|
218
319
|
if (needsOptions && !r.options?.length)
|
|
219
|
-
ctx.addIssue({ code:
|
|
320
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["options"], message: `select:'${r.select}' requires options` });
|
|
220
321
|
if (!needsOptions && r.options?.length)
|
|
221
|
-
ctx.addIssue({ code:
|
|
322
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["options"], message: `select:'${r.select}' takes no options` });
|
|
222
323
|
});
|
|
223
|
-
var NotifyStatusSchema =
|
|
224
|
-
var AgentStateSchema =
|
|
225
|
-
var SetTaskStateSchema =
|
|
226
|
-
state:
|
|
324
|
+
var NotifyStatusSchema = z2.enum(["pending", "answered", "ignored"]);
|
|
325
|
+
var AgentStateSchema = z2.enum(["idle", "in_progress", "completed", "needs_input"]);
|
|
326
|
+
var SetTaskStateSchema = z2.object({
|
|
327
|
+
state: z2.enum(["in_progress", "completed", "needs_input"])
|
|
227
328
|
});
|
|
228
|
-
var
|
|
229
|
-
|
|
230
|
-
|
|
329
|
+
var SetWorkStateSchema = z2.object({
|
|
330
|
+
workId: z2.string().uuid().optional(),
|
|
331
|
+
notificationId: z2.string().optional(),
|
|
332
|
+
state: SetTaskStateSchema.shape.state
|
|
333
|
+
}).refine((value) => Number(Boolean(value.workId)) + Number(Boolean(value.notificationId)) === 1, {
|
|
334
|
+
message: "exactly one of workId or notificationId is required"
|
|
231
335
|
});
|
|
232
|
-
var
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
336
|
+
var TurnSchema = z2.object({
|
|
337
|
+
prompt: z2.string(),
|
|
338
|
+
reply: z2.string()
|
|
339
|
+
});
|
|
340
|
+
var UserAnswerSchema = z2.discriminatedUnion("kind", [
|
|
341
|
+
z2.object({ kind: z2.literal("option"), optionId: z2.string(), label: z2.string().optional() }),
|
|
342
|
+
z2.object({ kind: z2.literal("text"), text: z2.string() }),
|
|
343
|
+
z2.object({ kind: z2.literal("ignored") }),
|
|
344
|
+
z2.object({ kind: z2.literal("multi"), optionIds: z2.array(z2.string()), labels: z2.array(z2.string()).optional() }),
|
|
345
|
+
z2.object({ kind: z2.literal("ranked"), optionIds: z2.array(z2.string()), labels: z2.array(z2.string()).optional() }),
|
|
346
|
+
z2.object({ kind: z2.literal("clarify"), chunks: z2.array(z2.string()).min(1) }),
|
|
347
|
+
z2.object({ kind: z2.literal("confirm"), approved: z2.boolean() }),
|
|
348
|
+
z2.object({ kind: z2.literal("turns"), turns: z2.array(TurnSchema).min(1) }),
|
|
241
349
|
/** An auto-answer derived from the user's PAST decisions (broker/precedent-design.md §2):
|
|
242
350
|
* delivered through the same settle/await path as a human answer, carrying the judge's
|
|
243
351
|
* derivation and the precedent ids it grew from. Always paired with a visible trail
|
|
244
352
|
* card the user can reply to — the broker never overrides the user. */
|
|
245
|
-
|
|
353
|
+
z2.object({ kind: z2.literal("precedent"), answer: z2.string(), derivation: z2.string(), sources: z2.array(z2.string()).min(1) })
|
|
246
354
|
]);
|
|
247
|
-
var IntentSchema =
|
|
355
|
+
var IntentSchema = z2.object({
|
|
248
356
|
// The full vocabulary the bot's mapper emits (mapper.INTENT_KINDS) — the schema lagged
|
|
249
357
|
// it by two ("detail", "feedback"), and because the settle handler parsed the array
|
|
250
358
|
// all-or-nothing, ONE feedback act silently dropped EVERY intent on the call,
|
|
251
359
|
// questions included. Found auditing five calls' stored feedback, 2026-08-01.
|
|
252
|
-
kind:
|
|
253
|
-
detail:
|
|
254
|
-
/**
|
|
255
|
-
*
|
|
256
|
-
* the
|
|
257
|
-
*
|
|
258
|
-
dueInSeconds:
|
|
360
|
+
kind: z2.enum(["defer", "delegate", "channel", "question", "detail", "feedback", "command", "control"]),
|
|
361
|
+
detail: z2.string(),
|
|
362
|
+
/** Defer only: seconds until the callback the caller asked for, when something upstream
|
|
363
|
+
* already read the time. Nothing sets it today (#397 documented an MCP parser that was
|
|
364
|
+
* never written) — the API reads the defer's `detail` itself with `notes/when.ts`
|
|
365
|
+
* (`parseDelay`, #1292), and a value here simply wins over that reading. */
|
|
366
|
+
dueInSeconds: z2.number().int().positive().optional(),
|
|
259
367
|
/** Feedback only (#812): WHICH failure the complaint names — typed by the mapper that
|
|
260
368
|
* already read the utterance, so `feedback_from_call.kind` stops defaulting to
|
|
261
369
|
* 'other' on every row. A table that records that something was wrong and nothing
|
|
262
370
|
* about what cannot answer "is the bot looping less this week?". */
|
|
263
|
-
fault:
|
|
371
|
+
fault: z2.enum(["loop", "unanswered", "overridden", "misheard", "slow", "other"]).optional()
|
|
264
372
|
});
|
|
265
|
-
var RideAlongSchema =
|
|
373
|
+
var RideAlongSchema = z2.object({
|
|
266
374
|
/** The note this came from — assign/clarify/close it through /api/notes/:id. */
|
|
267
|
-
noteId:
|
|
375
|
+
noteId: z2.string(),
|
|
268
376
|
/** What to do, in the owner's own words (the note's headline). Never model-rewritten. */
|
|
269
|
-
text:
|
|
377
|
+
text: z2.string(),
|
|
270
378
|
/** The thread to report back on, when the note was dispatched over the request rail. */
|
|
271
|
-
parentId:
|
|
379
|
+
parentId: z2.string().nullable()
|
|
272
380
|
});
|
|
273
|
-
var AwaitItemSchema =
|
|
274
|
-
|
|
275
|
-
type:
|
|
276
|
-
parentId:
|
|
277
|
-
notificationId:
|
|
381
|
+
var AwaitItemSchema = z2.discriminatedUnion("type", [
|
|
382
|
+
z2.object({
|
|
383
|
+
type: z2.literal("reply"),
|
|
384
|
+
parentId: z2.string(),
|
|
385
|
+
notificationId: z2.string(),
|
|
386
|
+
workId: z2.string().uuid().optional(),
|
|
387
|
+
decisionId: z2.string().uuid().optional(),
|
|
278
388
|
answer: UserAnswerSchema,
|
|
279
389
|
/** E2EE: present when the answer is sealed. The server relays the opaque answer
|
|
280
390
|
* envelope + the plaintext `ignored` status hint; the receiving agent OPENS it
|
|
@@ -282,126 +392,146 @@ var AwaitItemSchema = z.discriminatedUnion("type", [
|
|
|
282
392
|
* against `ignored` as tampering. Absent = today's plaintext answer (in `answer`).
|
|
283
393
|
* On a sealed reply the plaintext `answer` is a placeholder (kind reflects only
|
|
284
394
|
* the `ignored` bit) — never the real content, which stays sealed. */
|
|
285
|
-
sealed:
|
|
286
|
-
/**
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
|
|
290
|
-
|
|
395
|
+
sealed: z2.lazy(() => SealedAnswerSchema).optional(),
|
|
396
|
+
/** WHAT THE AGENT CANNOT KNOW FROM THE FIELDS BESIDE IT (owner, 2026-09-04, issue
|
|
397
|
+
* #1537). One line, built from the record: the ask and the caller's reply VERBATIM,
|
|
398
|
+
* the notification they belong to, and the `contact` call that reaches the person
|
|
399
|
+
* again, spelled with its real arguments. It restates nothing — deleting the brain's
|
|
400
|
+
* acts deleted the paraphrase, and this is not it coming back: an agent that reads
|
|
401
|
+
* "call me back after you merge" in their own words decides for itself what to do,
|
|
402
|
+
* and now knows exactly which call to make. Absent when either half is missing —
|
|
403
|
+
* a sentence with a hole in it is worse than no sentence. */
|
|
404
|
+
note: z2.string().optional(),
|
|
405
|
+
/** The call record rendered for THIS agent (`voice/record-design.md`): the words the
|
|
406
|
+
* shaped answer was mapped from, filtered to its own claims. There is no second list
|
|
407
|
+
* of labels beside it — the acts went 2026-09-04 and `intents` went with them (owner,
|
|
408
|
+
* 2026-09-04): the agent reads the sentence and decides. */
|
|
409
|
+
transcript: z2.string().optional(),
|
|
291
410
|
/** Coverage report (#396), when the ask declared `points`: which of them this
|
|
292
411
|
* answer addressed. Missing points = re-ask or proceed knowingly partial. */
|
|
293
|
-
covered:
|
|
412
|
+
covered: z2.array(z2.string()).optional(),
|
|
294
413
|
/** Ride-alongs (RideAlongSchema) — pending work for you, attached to the moment you
|
|
295
414
|
* became free. Only `reply` and `idle` carry it: those are the two outcomes that
|
|
296
415
|
* END a wait. `remind`, `superseded` and `turn` are mid-flight, and handing an
|
|
297
416
|
* agent a side-quest while it is still holding the line is how the main thing gets
|
|
298
417
|
* dropped. Absent/empty = nothing owed. */
|
|
299
|
-
also:
|
|
418
|
+
also: z2.array(RideAlongSchema).optional()
|
|
300
419
|
}),
|
|
301
|
-
|
|
302
|
-
type:
|
|
303
|
-
parentId:
|
|
304
|
-
notificationId:
|
|
305
|
-
remindAt:
|
|
420
|
+
z2.object({
|
|
421
|
+
type: z2.literal("remind"),
|
|
422
|
+
parentId: z2.string(),
|
|
423
|
+
notificationId: z2.string(),
|
|
424
|
+
remindAt: z2.string().datetime({ offset: true }),
|
|
306
425
|
/** Seconds until remindAt, server-computed — pass straight to ScheduleWakeup. */
|
|
307
|
-
remindInSeconds:
|
|
426
|
+
remindInSeconds: z2.number()
|
|
308
427
|
}),
|
|
309
428
|
/** The awaited ask was REPLACED by a newer notification on its thread (e.g. a
|
|
310
429
|
* post-feedback revision, #633) — the user will never answer this id. Stop
|
|
311
430
|
* awaiting it; the live ask is the thread's newest turn (await that one, or
|
|
312
431
|
* re-orient via get_thread / check_replies). */
|
|
313
|
-
|
|
314
|
-
type:
|
|
315
|
-
parentId:
|
|
316
|
-
notificationId:
|
|
432
|
+
z2.object({
|
|
433
|
+
type: z2.literal("superseded"),
|
|
434
|
+
parentId: z2.string(),
|
|
435
|
+
notificationId: z2.string()
|
|
317
436
|
}),
|
|
318
437
|
/** A LIVE call's turn, streamed as it lands (#783). PROVISIONAL: the user can still
|
|
319
438
|
* revise any of these until the final reply arrives — partial = intelligence,
|
|
320
439
|
* settled = authorization. Use it to PREPARE (fetch, draft, warm), never to act
|
|
321
440
|
* irreversibly. If `acts` carries a question aimed at you and you know the answer,
|
|
322
441
|
* contact on the same thread right away — the caller hears it on the same call. */
|
|
323
|
-
|
|
324
|
-
type:
|
|
325
|
-
notificationId:
|
|
326
|
-
inFlight:
|
|
327
|
-
turn:
|
|
328
|
-
idx:
|
|
329
|
-
prompt:
|
|
330
|
-
reply:
|
|
331
|
-
acts:
|
|
442
|
+
z2.object({
|
|
443
|
+
type: z2.literal("partial"),
|
|
444
|
+
notificationId: z2.string(),
|
|
445
|
+
inFlight: z2.literal(true),
|
|
446
|
+
turn: z2.object({
|
|
447
|
+
idx: z2.number(),
|
|
448
|
+
prompt: z2.string(),
|
|
449
|
+
reply: z2.string(),
|
|
450
|
+
acts: z2.array(IntentSchema).nullable().optional()
|
|
332
451
|
})
|
|
333
452
|
}),
|
|
334
|
-
|
|
453
|
+
z2.object({ type: z2.literal("idle"), also: z2.array(RideAlongSchema).optional() })
|
|
335
454
|
]);
|
|
336
|
-
var CallbackTriggerSchema =
|
|
337
|
-
var ScheduleCallbackSchema =
|
|
338
|
-
parentId:
|
|
455
|
+
var CallbackTriggerSchema = z2.enum(["on_done", "on_blocked", "scheduled"]);
|
|
456
|
+
var ScheduleCallbackSchema = z2.object({
|
|
457
|
+
parentId: z2.string().describe("The thread to call back on (from a prior contact / reply / request)."),
|
|
339
458
|
trigger: CallbackTriggerSchema,
|
|
340
|
-
dueInSeconds:
|
|
341
|
-
note:
|
|
459
|
+
dueInSeconds: z2.number().int().positive().optional().describe("For 'scheduled' only: how many seconds from now to fire."),
|
|
460
|
+
note: z2.string().optional().describe("What to tell the user when you follow up.")
|
|
342
461
|
});
|
|
343
|
-
var PendingRepliesSchema =
|
|
344
|
-
replies:
|
|
345
|
-
|
|
346
|
-
parentId:
|
|
347
|
-
notificationId:
|
|
462
|
+
var PendingRepliesSchema = z2.object({
|
|
463
|
+
replies: z2.array(
|
|
464
|
+
z2.object({
|
|
465
|
+
parentId: z2.string(),
|
|
466
|
+
notificationId: z2.string(),
|
|
467
|
+
workId: z2.string().uuid().optional(),
|
|
468
|
+
decisionId: z2.string().uuid().optional(),
|
|
348
469
|
answer: UserAnswerSchema,
|
|
349
470
|
/** E2EE: the sealed answer (opaque envelope + plaintext `ignored` hint) when the
|
|
350
471
|
* pairing is E2EE — the agent opens it and re-derives the real answer. Absent =
|
|
351
472
|
* plaintext answer (in `answer`). See AwaitItemSchema's reply variant. */
|
|
352
|
-
sealed:
|
|
353
|
-
/**
|
|
354
|
-
*
|
|
355
|
-
|
|
356
|
-
intents: z.array(IntentSchema).optional(),
|
|
357
|
-
transcript: z.string().optional(),
|
|
473
|
+
sealed: z2.lazy(() => SealedAnswerSchema).optional(),
|
|
474
|
+
/** The call record rendered for THIS agent: the raw words the shaped answer was
|
|
475
|
+
* mapped from, filtered to its own claims. See AwaitItemSchema's reply variant. */
|
|
476
|
+
transcript: z2.string().optional(),
|
|
358
477
|
/** Coverage report (#396): which declared `points` this answer addressed. */
|
|
359
|
-
covered:
|
|
478
|
+
covered: z2.array(z2.string()).optional()
|
|
360
479
|
})
|
|
361
480
|
),
|
|
362
|
-
pending:
|
|
363
|
-
|
|
481
|
+
pending: z2.array(
|
|
482
|
+
z2.object({ parentId: z2.string(), notificationId: z2.string(), createdAt: z2.string() })
|
|
364
483
|
),
|
|
365
484
|
/** WHO YOU ARE on this account (field report 2026-08-28): the name and device the user
|
|
366
485
|
* sees for this session's identity. From inside a session there was no way to find out —
|
|
367
486
|
* `pair` with no arguments can HATCH a fresh identity, so it is not a safe probe — and an
|
|
368
487
|
* agent that cannot tell which agent it is cannot tell whether work addressed to
|
|
369
488
|
* "Reta" was addressed to it. Absent only for a token with no pairing behind it. */
|
|
370
|
-
you:
|
|
489
|
+
you: z2.object({ name: z2.string(), device: z2.string().nullable(), tokenId: z2.string() }).optional(),
|
|
371
490
|
/** User-initiated requests addressed to this agent; act on them and reply via
|
|
372
491
|
* contact on the same parentId. Keeps reappearing until you call
|
|
373
|
-
*
|
|
374
|
-
requests:
|
|
375
|
-
|
|
376
|
-
parentId:
|
|
377
|
-
notificationId:
|
|
378
|
-
|
|
379
|
-
|
|
492
|
+
* set_work_state on its workId (or notificationId once while bootstrapping). */
|
|
493
|
+
requests: z2.array(
|
|
494
|
+
z2.object({
|
|
495
|
+
parentId: z2.string(),
|
|
496
|
+
notificationId: z2.string(),
|
|
497
|
+
workId: z2.string().uuid().optional(),
|
|
498
|
+
text: z2.string(),
|
|
499
|
+
createdAt: z2.string(),
|
|
380
500
|
/** The user seeded this request with a past conversation — call get_thread on it
|
|
381
501
|
* FIRST and treat the transcript as prior context (#57/#251). */
|
|
382
|
-
contextParentId:
|
|
502
|
+
contextParentId: z2.string().optional(),
|
|
383
503
|
/** STRANDED (field report 2026-08-28): this request was addressed to ANOTHER agent on
|
|
384
504
|
* the account — the name here — which has not been seen since it landed, so nobody
|
|
385
505
|
* came for it. Handed to you because you are the session that is here. Take it like
|
|
386
|
-
* any request (
|
|
506
|
+
* any request (set_work_state claims it, reply with contact on its parentId), and say
|
|
387
507
|
* whose it was, because the user chose that agent on purpose. */
|
|
388
|
-
stranded:
|
|
508
|
+
stranded: z2.string().optional()
|
|
389
509
|
})
|
|
390
510
|
),
|
|
511
|
+
/** Durable outcomes currently owned by this agent. This is the Work-native queue; flat
|
|
512
|
+
* notification lists remain during migration so old clients keep their existing view. */
|
|
513
|
+
work: z2.array(z2.object({
|
|
514
|
+
workId: z2.string().uuid(),
|
|
515
|
+
parentId: z2.string().optional(),
|
|
516
|
+
objective: z2.string().nullable(),
|
|
517
|
+
state: z2.enum(["active", "blocked", "waiting_external"]),
|
|
518
|
+
blockedOn: z2.array(z2.string().uuid()),
|
|
519
|
+
updatedAt: z2.string()
|
|
520
|
+
})).optional(),
|
|
391
521
|
/** Callbacks you owe the user that are now DUE (you said you'd follow up when done,
|
|
392
522
|
* if blocked, or at a time that has passed). Re-surfaced every sweep until you
|
|
393
523
|
* fulfill one by calling contact on its parentId. */
|
|
394
524
|
/** Ride-alongs (RideAlongSchema): notes assigned to this agent that no wake could
|
|
395
525
|
* reach. Same array the contact/await replies carry — one queue, every carrier. */
|
|
396
|
-
also:
|
|
397
|
-
owedCallbacks:
|
|
398
|
-
|
|
526
|
+
also: z2.array(RideAlongSchema).optional(),
|
|
527
|
+
owedCallbacks: z2.array(
|
|
528
|
+
z2.object({ parentId: z2.string(), trigger: CallbackTriggerSchema, note: z2.string() })
|
|
399
529
|
),
|
|
400
530
|
/** Work (either direction) you reported in_progress a while ago and never reported
|
|
401
531
|
* completed — likely left half-done by this session or a prior one that crashed or
|
|
402
|
-
* went idle. Report a real state (
|
|
403
|
-
stalled:
|
|
404
|
-
|
|
532
|
+
* went idle. Report a real state (set_work_state) or continue the work. */
|
|
533
|
+
stalled: z2.array(
|
|
534
|
+
z2.object({ parentId: z2.string(), notificationId: z2.string(), title: z2.string().nullable(), startedAt: z2.string() })
|
|
405
535
|
),
|
|
406
536
|
/** The queue rail (#614, pending/design.md): the same replies + requests, grouped by
|
|
407
537
|
* thread and ordered oldest-thread-first, so you work ONE thread at a time — fold all of
|
|
@@ -410,123 +540,125 @@ var PendingRepliesSchema = z.object({
|
|
|
410
540
|
* ride the next turn. `items` are that thread's replies/requests in arrival order; the
|
|
411
541
|
* full payload for each is in the flat `replies`/`requests` arrays (matched by
|
|
412
542
|
* notificationId). Derived, never stored — a crashed agent recomputes it exactly. */
|
|
413
|
-
threads:
|
|
414
|
-
|
|
415
|
-
parentId:
|
|
416
|
-
busy:
|
|
417
|
-
items:
|
|
418
|
-
|
|
419
|
-
kind:
|
|
420
|
-
notificationId:
|
|
421
|
-
at:
|
|
543
|
+
threads: z2.array(
|
|
544
|
+
z2.object({
|
|
545
|
+
parentId: z2.string(),
|
|
546
|
+
busy: z2.boolean(),
|
|
547
|
+
items: z2.array(
|
|
548
|
+
z2.object({
|
|
549
|
+
kind: z2.enum(["reply", "request"]),
|
|
550
|
+
notificationId: z2.string(),
|
|
551
|
+
at: z2.string()
|
|
422
552
|
})
|
|
423
553
|
)
|
|
424
554
|
})
|
|
425
555
|
)
|
|
426
556
|
});
|
|
427
|
-
var NotifyResponseSchema =
|
|
428
|
-
notificationId:
|
|
557
|
+
var NotifyResponseSchema = z2.object({
|
|
558
|
+
notificationId: z2.string(),
|
|
559
|
+
workId: z2.string().uuid().optional(),
|
|
560
|
+
decisionId: z2.string().uuid().optional(),
|
|
429
561
|
status: NotifyStatusSchema,
|
|
430
|
-
createdAt:
|
|
562
|
+
createdAt: z2.string().datetime(),
|
|
431
563
|
answer: UserAnswerSchema.optional(),
|
|
432
|
-
answeredAt:
|
|
564
|
+
answeredAt: z2.string().datetime().optional(),
|
|
433
565
|
/** Ride-alongs for THIS agent — pending work it should pick up when it's done with
|
|
434
566
|
* what it came for. Present on any reply, because an unwakeable agent's only
|
|
435
567
|
* reliable moment is one it initiated. Absent/empty = nothing owed. */
|
|
436
|
-
also:
|
|
568
|
+
also: z2.array(RideAlongSchema).optional()
|
|
437
569
|
});
|
|
438
|
-
var NotifyPlanUnitSchema =
|
|
439
|
-
notificationId:
|
|
570
|
+
var NotifyPlanUnitSchema = z2.object({
|
|
571
|
+
notificationId: z2.string(),
|
|
440
572
|
/** The unit's own heading, so the agent can tell which of its paragraphs this became. */
|
|
441
|
-
title:
|
|
573
|
+
title: z2.string(),
|
|
442
574
|
/** How loudly this unit was arbitrated to arrive — per unit, which is the point of units. */
|
|
443
575
|
level: NotifyLevelSchema,
|
|
444
576
|
/** Answered from something the user already decided: nobody is interrupted, and a trail card
|
|
445
577
|
* says so. The agent should not wait on this one. */
|
|
446
|
-
settled:
|
|
578
|
+
settled: z2.literal(true).optional(),
|
|
447
579
|
/** What this unit would need to be answerable and does not carry (#894). A PROPOSAL to the
|
|
448
580
|
* agent — nothing here changed the ask, and ignoring it costs nothing. */
|
|
449
|
-
needs:
|
|
581
|
+
needs: z2.array(z2.enum(["options", "visuals"])).optional(),
|
|
450
582
|
/** The SHAPE the broker would give this unit, for the agent to ratify (#886/#894). The
|
|
451
583
|
* split layer reads prose and can see that a paragraph is a yes/no or a pick-one — but a
|
|
452
584
|
* broker that DECIDES that destroys the only fact separating a statement from a real ask
|
|
453
585
|
* (#731), so it is offered, never applied: the unit is stored `text` until the agent
|
|
454
586
|
* confirms the shape (POST /notify/:id/confirm). Ignoring it costs nothing. */
|
|
455
|
-
proposal:
|
|
587
|
+
proposal: z2.object({
|
|
456
588
|
select: SelectShapeSchema,
|
|
457
|
-
options:
|
|
589
|
+
options: z2.array(z2.object({ label: z2.string().min(1) })).optional()
|
|
458
590
|
}).optional(),
|
|
459
591
|
/** What the broker READ this unit as wanting from the human (#952 layer 2): a `decision`
|
|
460
592
|
* between alternatives, an `approval` the agent is blocked on, or `knowledge` it just
|
|
461
593
|
* needs to know. Reported so the agent can correct a misread the same way it ratifies a
|
|
462
594
|
* shape — the read RAISES (a decision always asks) and never silences a question the
|
|
463
595
|
* agent declared (#731, #923). */
|
|
464
|
-
wants:
|
|
596
|
+
wants: z2.enum(["decision", "approval", "knowledge"]).optional()
|
|
465
597
|
});
|
|
466
|
-
var NotifyPlanSchema =
|
|
467
|
-
units:
|
|
598
|
+
var NotifyPlanSchema = z2.object({
|
|
599
|
+
units: z2.array(NotifyPlanUnitSchema),
|
|
468
600
|
/** Which unit is this arrival's ONE interruption (units-design.md D23). Absent means nobody
|
|
469
601
|
* was interrupted — every unit was either settled or quiet enough to sit in the inbox. */
|
|
470
|
-
speaks:
|
|
602
|
+
speaks: z2.string().optional()
|
|
471
603
|
});
|
|
472
|
-
var UserResponseSchema =
|
|
473
|
-
requestId:
|
|
604
|
+
var UserResponseSchema = z2.object({
|
|
605
|
+
requestId: z2.string(),
|
|
474
606
|
answer: UserAnswerSchema,
|
|
475
|
-
answeredAt:
|
|
476
|
-
|
|
477
|
-
transcript: z.string().optional(),
|
|
607
|
+
answeredAt: z2.string().datetime(),
|
|
608
|
+
transcript: z2.string().optional(),
|
|
478
609
|
/** E2EE: the sealed answer (opaque envelope + plaintext `ignored` hint) when the item was
|
|
479
610
|
* E2EE-sealed. Present → the server persists it opaquely and branches status on `ignored`;
|
|
480
611
|
* the plaintext `answer` is a placeholder (`{ kind: "ignored" }`) the server ignores for a
|
|
481
612
|
* sealed row. Absent = today's plaintext answer, unchanged. */
|
|
482
|
-
sealed:
|
|
613
|
+
sealed: z2.lazy(() => SealedAnswerSchema).optional(),
|
|
483
614
|
/** Coverage report (#396): which of the ask's declared `points` were addressed. */
|
|
484
|
-
covered:
|
|
615
|
+
covered: z2.array(z2.string()).optional()
|
|
485
616
|
});
|
|
486
|
-
var VoiceKeySchema =
|
|
487
|
-
var AgendaTurnSchema =
|
|
617
|
+
var VoiceKeySchema = z2.enum(["rachel", "george", "jessica", "brian", "lily"]);
|
|
618
|
+
var AgendaTurnSchema = z2.object({
|
|
488
619
|
/** Twin coverage (#1089): sibling claim ids this asking turn's answer ALSO settles —
|
|
489
620
|
* the planner declares duplicates instead of asking them twice. */
|
|
490
|
-
coveredIds:
|
|
621
|
+
coveredIds: z2.array(z2.string()).optional(),
|
|
491
622
|
/** At most three short spoken sentences. Capped because a turn is a breath: a 1031-char
|
|
492
623
|
* line went out on 2026-07-28 and the caller could not answer it at all. */
|
|
493
|
-
info:
|
|
494
|
-
question:
|
|
624
|
+
info: z2.array(z2.string().min(1)).max(3).default([]),
|
|
625
|
+
question: z2.string().min(1).nullable(),
|
|
495
626
|
/** True on the one turn carrying the agent's own declared question. */
|
|
496
|
-
asks:
|
|
627
|
+
asks: z2.boolean().optional(),
|
|
497
628
|
/** The claim this turn belongs to (#781) — the RETURN identity: answers route by it.
|
|
498
629
|
* Absent on a single-claim plan (the session's own claim) and on shared context turns,
|
|
499
630
|
* which route nothing. */
|
|
500
|
-
claimId:
|
|
631
|
+
claimId: z2.string().optional(),
|
|
501
632
|
/** The claim's voice key (#462) — the OUTBOUND identity, audible who-is-asking. */
|
|
502
|
-
voice:
|
|
633
|
+
voice: z2.string().optional(),
|
|
503
634
|
/** The claim's AGENT NAME (#838) — the spoken identity. A voice alone doesn't say
|
|
504
635
|
* whose request this is: an item that folded in from another agent arrived as a bare
|
|
505
636
|
* non-sequitur ("First real production sign-in is yours to make whenever you want.")
|
|
506
637
|
* and the owner answered "What?". The bot names the agent before its first turn. */
|
|
507
|
-
agent:
|
|
638
|
+
agent: z2.string().optional(),
|
|
639
|
+
/** The claim's agent by ID — the pairing's connection id (`notifications.token_id`), the
|
|
640
|
+
* same id a face is minted from. A name is not an identity: two pairings may be called
|
|
641
|
+
* "Claude", and a name cannot be joined on. The record's entries carry it (`agent_id`)
|
|
642
|
+
* so "who said that" survives the call, and it rides PER TURN because a coalesced call
|
|
643
|
+
* speaks for several agents — the turn is the only place that knows which. */
|
|
644
|
+
agentId: z2.string().optional(),
|
|
508
645
|
select: SelectShapeSchema.optional(),
|
|
509
|
-
options:
|
|
510
|
-
/** The seat was satisfied by the call's own ACCOUNT (replan-design.md, user_info): the
|
|
511
|
-
* caller already answered this claim in an earlier utterance, quoted here VERBATIM —
|
|
512
|
-
* the bot speaks the turn's short confirmation, posts these words as the claim's
|
|
513
|
-
* answer, and never re-asks. Grounded at parse time: an invented settle is #796. */
|
|
514
|
-
settle: z.string().optional(),
|
|
646
|
+
options: z2.array(OptionSchema.omit({ id: true })).optional(),
|
|
515
647
|
/** Pacing (#826, owner 2026-08-03: "how fast we move through them ... are parameters"):
|
|
516
648
|
* seconds the floor stays open after this turn speaks. Absent = the bot's defaults
|
|
517
649
|
* (the beat for context, the answer window for asks). Clamped bot-side. */
|
|
518
|
-
pace:
|
|
650
|
+
pace: z2.number().positive().optional(),
|
|
519
651
|
/** Whether the walk WAITS for an answer before moving on. Absent = derived as today
|
|
520
652
|
* (a question blocks, context flows). blocking:false on a question = ask and move
|
|
521
653
|
* on, the claim stays pending; blocking:true on context = hold for a reply. */
|
|
522
|
-
blocking:
|
|
654
|
+
blocking: z2.boolean().optional()
|
|
523
655
|
});
|
|
524
656
|
var CLAIM_STALE_MS = 30 * 6e4;
|
|
525
|
-
var InboxItemSchema =
|
|
526
|
-
id:
|
|
657
|
+
var InboxItemSchema = z2.object({
|
|
658
|
+
id: z2.string(),
|
|
527
659
|
/** The conversation thread + connection this item lives on. Present on the replied
|
|
528
660
|
* detail — they power History's "Continue" / "New session from this" (#57/#251). */
|
|
529
|
-
parentId:
|
|
661
|
+
parentId: z2.string().optional(),
|
|
530
662
|
/** THE ARRIVAL this row is one unit of (`notifications.ask_id` → `asks`). A claim is one
|
|
531
663
|
* arrival and its units are N rows of it, so this — not `parentId` — is what makes a
|
|
532
664
|
* multi-part notification one thing on screen. The thread is the whole CONVERSATION: it
|
|
@@ -534,13 +666,13 @@ var InboxItemSchema = z.object({
|
|
|
534
666
|
* unrelated updates as a single "12-part request". Absent on rows written before the
|
|
535
667
|
* `asks` table, and on anything that never went through `notify` — both fall back to the
|
|
536
668
|
* thread, which is what the client did for all rows until now. */
|
|
537
|
-
askId:
|
|
669
|
+
askId: z2.string().optional(),
|
|
538
670
|
/** WHERE this unit sat in the message it was cut from (`notifications.seq`). The batch
|
|
539
671
|
* shares one `created_at` to the microsecond, so without it the author's order is
|
|
540
672
|
* unrecoverable client-side — a four-paragraph briefing rendered opening-paragraph-last
|
|
541
673
|
* (live 2026-08-10, D35). The API already orders by it; this lets a reader that
|
|
542
674
|
* re-sorts (grouping, filtering) put an arrival back in the order it was written. */
|
|
543
|
-
seq:
|
|
675
|
+
seq: z2.number().int().optional(),
|
|
544
676
|
/** HOW MANY units the arrival was cut into. A device reads a LENS, never the arrival —
|
|
545
677
|
* `/api/inbox` serves `open`, so the units already settled are gone from it — and a client
|
|
546
678
|
* counting what it can see is counting what is LEFT. Walking a three-unit ask on the answer
|
|
@@ -549,13 +681,13 @@ var InboxItemSchema = z.object({
|
|
|
549
681
|
* server that can still see every row states it. Absent on any row with no `askId`: a
|
|
550
682
|
* unit knows WHICH ask it came from and WHERE it sat in it, and how many there were is
|
|
551
683
|
* the one part of its own arrival a single row cannot answer. */
|
|
552
|
-
units:
|
|
553
|
-
tokenId:
|
|
684
|
+
units: z2.number().int().positive().optional(),
|
|
685
|
+
tokenId: z2.string().optional(),
|
|
554
686
|
status: NotifyStatusSchema,
|
|
555
687
|
context: ContextSchema,
|
|
556
|
-
options:
|
|
688
|
+
options: z2.array(OptionSchema).optional(),
|
|
557
689
|
/** The ask's declared coverage points (#396), when the agent sent them. */
|
|
558
|
-
points:
|
|
690
|
+
points: z2.array(z2.string()).optional(),
|
|
559
691
|
/** The call's AGENDA (broker/agenda-design.md): the ordered turns it is made of, built at
|
|
560
692
|
* ring/enqueue time. Replaces the condensed line + index-aligned phrased points, which
|
|
561
693
|
* between them could not express a call as a sequence. `question: null` is a real turn —
|
|
@@ -564,12 +696,12 @@ var InboxItemSchema = z.object({
|
|
|
564
696
|
* `requestAsks` — the agent's own declaration, not a guess. `false` is what earns a card
|
|
565
697
|
* its acknowledge affordance: without it a status update offers a text box and a dismiss,
|
|
566
698
|
* and neither of those is "got it" (owner, 2026-08-10). */
|
|
567
|
-
asks:
|
|
699
|
+
asks: z2.boolean().optional(),
|
|
568
700
|
/** When a live process last pulsed for this row's agent — the liveness input for
|
|
569
701
|
* "working requires a pulse" (#928): the list said "Working…" from agent_state alone
|
|
570
702
|
* while the party called the same dead claim stalled. Absent = no token/no data,
|
|
571
703
|
* which must never CLAIM stalled. */
|
|
572
|
-
lastSeenAt:
|
|
704
|
+
lastSeenAt: z2.string().optional(),
|
|
573
705
|
/** WHEN THE AGENT LAST SAID ANYTHING ABOUT THIS CLAIM — the newest `agent_state` row in
|
|
574
706
|
* the `notification_events` ledger (trigger-written since 20260621010000, so every row a
|
|
575
707
|
* user can see has one). The age input for `CLAIM_STALE_MS`, and it has to be this rather
|
|
@@ -579,56 +711,53 @@ var InboxItemSchema = z.object({
|
|
|
579
711
|
* work. Reading the row's birth as the claim's age brands that "No update in 8h" the
|
|
580
712
|
* instant the agent picks it up (#997). Absent = pre-trigger row; fall back to
|
|
581
713
|
* `createdAt`. */
|
|
582
|
-
agentStateAt:
|
|
583
|
-
agenda:
|
|
584
|
-
|
|
585
|
-
* ("call back after lunch") — shown so they can see the commitment was captured. */
|
|
586
|
-
intents: z.array(IntentSchema).optional(),
|
|
587
|
-
visuals: z.array(VisualSchema).optional(),
|
|
714
|
+
agentStateAt: z2.string().datetime().optional(),
|
|
715
|
+
agenda: z2.array(AgendaTurnSchema).optional(),
|
|
716
|
+
visuals: z2.array(VisualSchema).optional(),
|
|
588
717
|
/** The connected agent's name (the single pairing name — user-typed, or the
|
|
589
718
|
* agent's suggestion, or a default silly name). */
|
|
590
|
-
name:
|
|
719
|
+
name: z2.string(),
|
|
591
720
|
/** The pairing's assigned voice (#462); absent = the default voice. */
|
|
592
721
|
voice: VoiceKeySchema.optional(),
|
|
593
|
-
repo:
|
|
594
|
-
branch:
|
|
595
|
-
createdAt:
|
|
596
|
-
snoozedUntil:
|
|
722
|
+
repo: z2.string().optional(),
|
|
723
|
+
branch: z2.string().optional(),
|
|
724
|
+
createdAt: z2.string().datetime(),
|
|
725
|
+
snoozedUntil: z2.string().datetime().optional(),
|
|
597
726
|
agentState: AgentStateSchema.default("idle"),
|
|
598
727
|
/** Whose action the item is waiting on: "you" = an agent asked you (the default,
|
|
599
728
|
* every agent→user notification); "agent" = you sent a request and it's awaiting the
|
|
600
729
|
* agent (held in the inbox until the agent replies on the thread). */
|
|
601
|
-
turn:
|
|
730
|
+
turn: z2.enum(["you", "agent"]).default("you"),
|
|
602
731
|
/** Hard error reason on an awaiting request (turn="agent") — the wake failed to reach
|
|
603
732
|
* the agent (provider-agnostic; set server-side). Absent = no hard error, though the
|
|
604
733
|
* client may still flag a stall by age. Drives the inbox error badge + Retry. */
|
|
605
|
-
error:
|
|
606
|
-
clarifies:
|
|
734
|
+
error: z2.string().optional(),
|
|
735
|
+
clarifies: z2.string().optional(),
|
|
607
736
|
/** The ring ladder ran out while this was still pending — we tried to reach you and
|
|
608
737
|
* STOPPED trying (`arbitration/arbitrate.ts` `nextRing` → `stop`). Distinct from an
|
|
609
738
|
* agent with nothing to say, which the roster drew identically until now: "nothing to
|
|
610
739
|
* say" and "gave up saying it" are opposite situations wearing the same face
|
|
611
740
|
* (navigation-design.md, gap 1). False for anything that never rang. */
|
|
612
|
-
gaveUp:
|
|
741
|
+
gaveUp: z2.boolean().default(false),
|
|
613
742
|
/** Why this arrived the way it did, read back off the delivery receipt (`notify/why.ts`).
|
|
614
743
|
* Absent for anything never delivered through a push, and for older rows written before
|
|
615
744
|
* the reason was recorded. Deliberately a debug affordance, shown small (owner,
|
|
616
745
|
* 2026-08-07) — its real job is to give "this didn't need a call" something to be
|
|
617
746
|
* feedback ABOUT. */
|
|
618
|
-
why:
|
|
747
|
+
why: z2.object({
|
|
619
748
|
asked: NotifyLevelSchema,
|
|
620
749
|
got: NotifyLevelSchema,
|
|
621
|
-
because:
|
|
622
|
-
line:
|
|
750
|
+
because: z2.enum(["unresponsive", "dismissed", "not_permitted", "silent", "coalesced", "agent_capped", "unplanned", "learned_raise"]).optional(),
|
|
751
|
+
line: z2.string()
|
|
623
752
|
}).optional(),
|
|
624
|
-
select:
|
|
625
|
-
confirmStyle:
|
|
753
|
+
select: z2.enum(["one", "many", "rank", "confirm", "text"]).default("one"),
|
|
754
|
+
confirmStyle: z2.enum(["yesno", "approve"]).default("yesno").describe(
|
|
626
755
|
"Labels for a select:'confirm' paige \u2014 'yesno' (Yes/No) or 'approve' (Approve/Deny). Ignored unless select is 'confirm'."
|
|
627
756
|
),
|
|
628
757
|
/** Real downstream work is stuck behind this one — set by the agent, independent of
|
|
629
758
|
* urgency (see the main README's "premier use case" + notify/states.md). Drives the
|
|
630
759
|
* inbox's blocking badge and the extra confirm step before dismissing it. */
|
|
631
|
-
blocking:
|
|
760
|
+
blocking: z2.boolean().default(false),
|
|
632
761
|
/** The user's locked-in answer; present only for replied items (GET /api/replied/:id). */
|
|
633
762
|
answer: UserAnswerSchema.optional(),
|
|
634
763
|
/** E2EE (text lane): the sealed content this item carries when the pairing is E2EE, in
|
|
@@ -637,39 +766,39 @@ var InboxItemSchema = z.object({
|
|
|
637
766
|
* NotifyRequest.envelope. The native app decrypts it locally via openNotification;
|
|
638
767
|
* web / an un-enrolled device can't and renders a locked placeholder. Absent = today's
|
|
639
768
|
* plaintext item (context carries the cleartext), so plaintext items are unchanged. */
|
|
640
|
-
envelope:
|
|
641
|
-
context:
|
|
642
|
-
options:
|
|
643
|
-
visuals:
|
|
769
|
+
envelope: z2.object({
|
|
770
|
+
context: z2.lazy(() => EnvelopeSchema).optional(),
|
|
771
|
+
options: z2.lazy(() => EnvelopeSchema).optional(),
|
|
772
|
+
visuals: z2.lazy(() => EnvelopeSchema).optional()
|
|
644
773
|
}).optional(),
|
|
645
774
|
/** E2EE: the agent's device X25519 public key to seal the user's answer BACK to (the
|
|
646
775
|
* sender the phone replies to). Sourced server-side from this item's pairing credential.
|
|
647
776
|
* Present only alongside `envelope`; the phone seals via sealAnswer(answer, this, id). */
|
|
648
|
-
agentX25519:
|
|
777
|
+
agentX25519: z2.string().optional()
|
|
649
778
|
});
|
|
650
|
-
var SnoozeRequestSchema =
|
|
651
|
-
requestId:
|
|
652
|
-
until:
|
|
779
|
+
var SnoozeRequestSchema = z2.object({
|
|
780
|
+
requestId: z2.string(),
|
|
781
|
+
until: z2.string().datetime()
|
|
653
782
|
});
|
|
654
783
|
var APNS_TOKEN_RE = /^[0-9a-fA-F]{64}$/;
|
|
655
|
-
var PushTokenSchema =
|
|
656
|
-
voipToken:
|
|
657
|
-
alertToken:
|
|
658
|
-
fcmToken:
|
|
659
|
-
platform:
|
|
784
|
+
var PushTokenSchema = z2.object({
|
|
785
|
+
voipToken: z2.string().min(1).optional(),
|
|
786
|
+
alertToken: z2.string().min(1).optional(),
|
|
787
|
+
fcmToken: z2.string().min(1).optional(),
|
|
788
|
+
platform: z2.enum(["ios", "android"])
|
|
660
789
|
}).superRefine((v, ctx) => {
|
|
661
790
|
if (v.platform !== "ios") return;
|
|
662
791
|
for (const field of ["voipToken", "alertToken"]) {
|
|
663
792
|
const token = v[field];
|
|
664
793
|
if (token === void 0 || APNS_TOKEN_RE.test(token)) continue;
|
|
665
794
|
ctx.addIssue({
|
|
666
|
-
code:
|
|
795
|
+
code: z2.ZodIssueCode.custom,
|
|
667
796
|
path: [field],
|
|
668
797
|
message: `not an APNs device token (want 64 hex chars, got ${token.length})`
|
|
669
798
|
});
|
|
670
799
|
}
|
|
671
800
|
});
|
|
672
|
-
var MissedCallSchema =
|
|
801
|
+
var MissedCallSchema = z2.enum([
|
|
673
802
|
"retry_10m",
|
|
674
803
|
"retry_30m",
|
|
675
804
|
"retry_60m",
|
|
@@ -679,36 +808,32 @@ var MissedCallSchema = z.enum([
|
|
|
679
808
|
"inbox",
|
|
680
809
|
"dismiss"
|
|
681
810
|
]);
|
|
682
|
-
var
|
|
683
|
-
retry_10m: { kind: "every", minutes: 10 },
|
|
684
|
-
retry_30m: { kind: "every", minutes: 30 },
|
|
685
|
-
retry_60m: { kind: "every", minutes: 60 },
|
|
686
|
-
backoff_gentle: { kind: "at", minutes: [30, 120, 360] },
|
|
687
|
-
backoff_standard: { kind: "at", minutes: [10, 30, 120] },
|
|
688
|
-
backoff_aggressive: { kind: "at", minutes: [5, 15, 45] },
|
|
689
|
-
inbox: { kind: "once" },
|
|
690
|
-
dismiss: { kind: "grace", minutes: 2 }
|
|
691
|
-
};
|
|
692
|
-
var BrokerTuningSchema = z.object({
|
|
811
|
+
var BrokerTuningSchema = z2.object({
|
|
693
812
|
/** 'none' = skip the spoken ack after a mapped answer (power users find it slow). */
|
|
694
|
-
ackVerbosity:
|
|
813
|
+
ackVerbosity: z2.enum(["normal", "none"]).optional(),
|
|
695
814
|
/** How readily the mapper asks its one clarification: 'low' = only when truly
|
|
696
815
|
* uninterpretable, 'high' = whenever not fully certain. */
|
|
697
|
-
clarifyEagerness:
|
|
816
|
+
clarifyEagerness: z2.enum(["low", "normal", "high"]).optional(),
|
|
698
817
|
/** The user's own shorthand: when they say `say`, they mean `mean`. */
|
|
699
|
-
phrasebook:
|
|
818
|
+
phrasebook: z2.array(z2.object({ say: z2.string().min(1).max(60), mean: z2.string().min(1).max(120) })).max(24).optional(),
|
|
819
|
+
/** The language calls are PLANNED in, when the account has chosen one (#1272). Absent —
|
|
820
|
+
* which is every account today — means the agent's own words decide, per ask: a call
|
|
821
|
+
* about an English ask opens in English. This is the only thing that overrides that,
|
|
822
|
+
* and a live caller who switches language mid-call still outranks it (broker/lang.ts).
|
|
823
|
+
* Set per user (no UI yet), like `voiceTuning`. */
|
|
824
|
+
language: z2.enum(["en", "es"]).optional()
|
|
700
825
|
});
|
|
701
|
-
var UserSettingsSchema =
|
|
702
|
-
permissions:
|
|
703
|
-
call:
|
|
704
|
-
banner:
|
|
705
|
-
push:
|
|
826
|
+
var UserSettingsSchema = z2.object({
|
|
827
|
+
permissions: z2.object({
|
|
828
|
+
call: z2.boolean(),
|
|
829
|
+
banner: z2.boolean(),
|
|
830
|
+
push: z2.boolean()
|
|
706
831
|
}),
|
|
707
|
-
sessionMode:
|
|
708
|
-
silentPush:
|
|
709
|
-
autoCallback:
|
|
832
|
+
sessionMode: z2.enum(["default", "all_calls", "silent"]),
|
|
833
|
+
silentPush: z2.boolean(),
|
|
834
|
+
autoCallback: z2.boolean(),
|
|
710
835
|
/** Opt-in (default false) to using your content to improve Paigy and train models. */
|
|
711
|
-
improveConsent:
|
|
836
|
+
improveConsent: z2.boolean(),
|
|
712
837
|
missedCall: MissedCallSchema.default("backoff_standard"),
|
|
713
838
|
/** Where voice audio is processed. 'hosted' (default) = Paigy's voice services
|
|
714
839
|
* (ElevenLabs TTS, faster-whisper STT, the call bot); 'on_device' = the phone
|
|
@@ -716,7 +841,7 @@ var UserSettingsSchema = z.object({
|
|
|
716
841
|
* Optional, NOT defaulted: a stale client PATCHing the full settings object
|
|
717
842
|
* must not silently reset this privacy choice. Absent = leave unchanged on
|
|
718
843
|
* write, 'hosted' on read (see store.ts). */
|
|
719
|
-
voiceMode:
|
|
844
|
+
voiceMode: z2.enum(["hosted", "on_device"]).optional(),
|
|
720
845
|
/** Per-user ring budget (#603): calls per rolling day before further calls
|
|
721
846
|
* degrade to banner. Absent = the global default (25). A number, never a
|
|
722
847
|
* bypass — every account keeps a ceiling. No UI; set per user for testing. */
|
|
@@ -724,10 +849,10 @@ var UserSettingsSchema = z.object({
|
|
|
724
849
|
* payload['tuning'] (e.g. { silence_s: 3.5 } — a longer pause window for a
|
|
725
850
|
* slower speaker). No API-side semantics; the bot resolves each key with its
|
|
726
851
|
* own defaults. Set per user (no UI yet); absent = bot defaults. */
|
|
727
|
-
voiceTuning:
|
|
852
|
+
voiceTuning: z2.record(z2.string(), z2.union([z2.number(), z2.string()])).optional(),
|
|
728
853
|
/** Opt-in to real-phone (PSTN) calls when the app can't ring. Optional, not
|
|
729
854
|
* defaulted — an older client PATCHing the full object must not clobber it. */
|
|
730
|
-
pstnCalls:
|
|
855
|
+
pstnCalls: z2.boolean().optional(),
|
|
731
856
|
/** The user's IANA timezone (e.g. "America/Bogota"), recorded by the app — it is the
|
|
732
857
|
* only party that knows it. REMINDERS are why it exists: "remind me at ten" becomes
|
|
733
858
|
* an absolute `due_at` only if we know whose ten. Optional and never defaulted, for
|
|
@@ -736,50 +861,50 @@ var UserSettingsSchema = z.object({
|
|
|
736
861
|
* that failure reads as the reminder rail being unreliable rather than as a missing
|
|
737
862
|
* setting. Absent = a spoken time can't be landed, so the reminder rides the next
|
|
738
863
|
* call — honest about what we know. */
|
|
739
|
-
timezone:
|
|
864
|
+
timezone: z2.string().min(1).max(64).optional(),
|
|
740
865
|
/** Account E2EE state (text lane): 'off' (default) = today's plaintext; 'on' =
|
|
741
866
|
* content is sealed end-to-end between the local agent and the phone. Like
|
|
742
867
|
* voiceMode, OPTIONAL and NOT defaulted so a stale client PATCHing the full
|
|
743
868
|
* settings object without it can't silently flip the account's E2EE state.
|
|
744
869
|
* Absent = leave unchanged on write, 'off' on read (see store.ts). The demo
|
|
745
870
|
* account is plaintext by construction and refuses any non-'off' value. */
|
|
746
|
-
e2eeMode:
|
|
871
|
+
e2eeMode: z2.enum(["off", "on"]).optional(),
|
|
747
872
|
/** Rung-2 broker tuning (#381). Optional and NOT defaulted, same stale-client
|
|
748
873
|
* clobber guard as voiceMode: absent = leave unchanged on write. */
|
|
749
874
|
broker: BrokerTuningSchema.optional()
|
|
750
875
|
});
|
|
751
|
-
var HistoryItemSchema =
|
|
752
|
-
id:
|
|
753
|
-
parentId:
|
|
876
|
+
var HistoryItemSchema = z2.object({
|
|
877
|
+
id: z2.string(),
|
|
878
|
+
parentId: z2.string(),
|
|
754
879
|
/** 'user' = a request you sent; 'agent' = a notification an agent sent you. */
|
|
755
|
-
initiator:
|
|
756
|
-
title:
|
|
880
|
+
initiator: z2.enum(["user", "agent"]),
|
|
881
|
+
title: z2.string(),
|
|
757
882
|
/** The agent on the other end (its name). */
|
|
758
|
-
name:
|
|
759
|
-
createdAt:
|
|
883
|
+
name: z2.string(),
|
|
884
|
+
createdAt: z2.string(),
|
|
760
885
|
/** When the agent fetched your request (user→agent only). */
|
|
761
|
-
agentAckedAt:
|
|
886
|
+
agentAckedAt: z2.string().nullable(),
|
|
762
887
|
/** When you answered the agent's notification (agent→user only). */
|
|
763
|
-
humanAckedAt:
|
|
888
|
+
humanAckedAt: z2.string().nullable()
|
|
764
889
|
});
|
|
765
890
|
var ACTIVITY_LINES = 2;
|
|
766
891
|
var ACTIVITY_LINE_MAX = 80;
|
|
767
|
-
var AgentActivitySchema =
|
|
892
|
+
var AgentActivitySchema = z2.object({
|
|
768
893
|
/** Oldest first, so the newest line is last — the one that replaces in place. */
|
|
769
|
-
lines:
|
|
894
|
+
lines: z2.array(z2.string().max(ACTIVITY_LINE_MAX)).max(ACTIVITY_LINES),
|
|
770
895
|
/** When the harness observed this tail. Its own timestamp, not the heartbeat's: a beat
|
|
771
896
|
* that carries an UNCHANGED tail must not make a stalled agent look like it just moved. */
|
|
772
|
-
at:
|
|
897
|
+
at: z2.string().datetime()
|
|
773
898
|
});
|
|
774
|
-
var ConnectionSummarySchema =
|
|
899
|
+
var ConnectionSummarySchema = z2.object({
|
|
775
900
|
/** The connection = the agent's token id (used to address a request). */
|
|
776
|
-
id:
|
|
777
|
-
device:
|
|
901
|
+
id: z2.string(),
|
|
902
|
+
device: z2.string().nullable(),
|
|
778
903
|
/** The agent's display name (the single pairing name). */
|
|
779
|
-
name:
|
|
904
|
+
name: z2.string(),
|
|
780
905
|
/** For a managed connection, the provider key (e.g. "cma") that agentOrigin maps to a
|
|
781
906
|
* label; null for a local connection. Sourced from the token's provider, not the name. */
|
|
782
|
-
provider:
|
|
907
|
+
provider: z2.string().nullable(),
|
|
783
908
|
/** The pairing's assigned voice (#462); null = the default voice. */
|
|
784
909
|
voice: VoiceKeySchema.nullable(),
|
|
785
910
|
/** The LOUDEST this agent may ever reach you — a ceiling on `NOTIFY_LADDER`, set by the
|
|
@@ -790,19 +915,19 @@ var ConnectionSummarySchema = z.object({
|
|
|
790
915
|
* every surface at once and outranks even `sessionMode: all_calls` — a mode the user
|
|
791
916
|
* set once must not overrule a rule they set about one agent. */
|
|
792
917
|
reach: NotifyLevelSchema.nullable().optional(),
|
|
793
|
-
createdAt:
|
|
918
|
+
createdAt: z2.string().datetime(),
|
|
794
919
|
/** Most recent notification on this connection, either direction. Null = no contact yet.
|
|
795
920
|
* Drives the agents-page recency grouping (Today / This week / …). */
|
|
796
|
-
lastContactAt:
|
|
921
|
+
lastContactAt: z2.string().datetime().nullable(),
|
|
797
922
|
/** Last presence heartbeat from a running agent process (POST /api/presence) — the
|
|
798
923
|
* desktop app while open. Null = never seen; stale = offline. */
|
|
799
|
-
lastSeenAt:
|
|
924
|
+
lastSeenAt: z2.string().datetime().nullable().optional(),
|
|
800
925
|
/** What a live desktop can run (companion.md §2.2), advertised on its heartbeat:
|
|
801
926
|
* harness availabilities + granted workspaces — the option set the phone's
|
|
802
927
|
* "new session" sheet offers. Absent for ordinary MCP agents. */
|
|
803
|
-
runtime:
|
|
804
|
-
harnesses:
|
|
805
|
-
workspaces:
|
|
928
|
+
runtime: z2.object({
|
|
929
|
+
harnesses: z2.array(z2.object({ name: z2.string(), label: z2.string(), status: z2.string() })).optional(),
|
|
930
|
+
workspaces: z2.array(z2.string()).optional()
|
|
806
931
|
}).optional(),
|
|
807
932
|
/** The tail of this agent's working log, when a harness is driving it — the agent page's
|
|
808
933
|
* live strip. Absent for anything the desktop harness isn't running (a hatched identity
|
|
@@ -811,247 +936,307 @@ var ConnectionSummarySchema = z.object({
|
|
|
811
936
|
activity: AgentActivitySchema.optional(),
|
|
812
937
|
/** True = a provider-managed agent running in the provider's cloud (e.g. Anthropic CMA);
|
|
813
938
|
* false = a local MCP connection running on the user's computer (Claude Code/Codex/…). */
|
|
814
|
-
managed:
|
|
939
|
+
managed: z2.boolean()
|
|
815
940
|
});
|
|
816
|
-
var MoveRingSchema =
|
|
817
|
-
var MoveSchema =
|
|
818
|
-
id:
|
|
941
|
+
var MoveRingSchema = z2.enum(["home", "travels", "retired", "quarantined"]);
|
|
942
|
+
var MoveSchema = z2.object({
|
|
943
|
+
id: z2.string(),
|
|
819
944
|
/** The reusable question, as distill normalized it. */
|
|
820
|
-
question:
|
|
945
|
+
question: z2.string(),
|
|
821
946
|
/** The operative ruling. Editable by the user (PATCH) — which resets the ledger. */
|
|
822
|
-
answer:
|
|
947
|
+
answer: z2.string(),
|
|
823
948
|
/** The user's stated reason, when they gave one. Null = inherently narrow: the judge is
|
|
824
949
|
* told so, and the ruling only derives essentially the same question in the same scope. */
|
|
825
|
-
rationale:
|
|
950
|
+
rationale: z2.string().nullable(),
|
|
826
951
|
/** Where the ruling lives: a repo/workspace, or 'global'. */
|
|
827
|
-
scope:
|
|
952
|
+
scope: z2.string(),
|
|
828
953
|
ring: MoveRingSchema,
|
|
829
954
|
/** True = the user pinned it with `always` (travel granted by hand, not by evidence). */
|
|
830
|
-
pinned:
|
|
955
|
+
pinned: z2.boolean(),
|
|
831
956
|
/** True = a pin the user placed was BROKEN by later counter-evidence. Surfaced so the
|
|
832
957
|
* break is visible instead of a pin silently disappearing. */
|
|
833
|
-
pinBroken:
|
|
958
|
+
pinBroken: z2.boolean(),
|
|
834
959
|
/** When the ruling was distilled. */
|
|
835
|
-
learnedAt:
|
|
960
|
+
learnedAt: z2.string(),
|
|
836
961
|
/** Last time it answered an ask. Null = never fired. */
|
|
837
|
-
lastUsedAt:
|
|
962
|
+
lastUsedAt: z2.string().nullable(),
|
|
838
963
|
/** How many asks it has answered. Instrumentation — deliberately NOT an input to the
|
|
839
964
|
* evidence curve: firing says the question keeps arising, not that the ruling is right. */
|
|
840
|
-
usedCount:
|
|
965
|
+
usedCount: z2.number(),
|
|
841
966
|
/** Ledger: outcomes that said it held up. Saturating — the tenth is worth almost nothing. */
|
|
842
|
-
confirms:
|
|
967
|
+
confirms: z2.number(),
|
|
843
968
|
/** Ledger: contradictions, in signal units (a full override = 1, weaker signals less).
|
|
844
969
|
* Linear and priced above the entire confirmation budget, so any full counter wins. */
|
|
845
|
-
counters:
|
|
970
|
+
counters: z2.number(),
|
|
846
971
|
/** The agent that asked the question this move came from, when known. Null for a move
|
|
847
972
|
* distilled from a clarify ruling (those carry no agent) or one whose source rows are gone. */
|
|
848
|
-
learnedFrom:
|
|
973
|
+
learnedFrom: z2.object({ id: z2.string(), name: z2.string() }).nullable()
|
|
849
974
|
});
|
|
850
|
-
var CreateRequestSchema =
|
|
975
|
+
var CreateRequestSchema = z2.object({
|
|
851
976
|
/** The connection (token id) to send to, from GET /api/tokens. */
|
|
852
|
-
tokenId:
|
|
977
|
+
tokenId: z2.string(),
|
|
853
978
|
/** The user's message to the agent. */
|
|
854
|
-
text:
|
|
979
|
+
text: z2.string().min(1),
|
|
855
980
|
/** Land the request on an existing conversation thread (History → "Continue")
|
|
856
981
|
* instead of minting a fresh one. Must belong to the requesting user. */
|
|
857
|
-
parentId:
|
|
982
|
+
parentId: z2.string().optional(),
|
|
858
983
|
/** Point the agent at a past conversation (possibly with a different agent) as
|
|
859
984
|
* starting context (History → "New session from this"). A reference, not a copy —
|
|
860
985
|
* the agent reads it via get_thread. Must belong to the requesting user. */
|
|
861
|
-
contextParentId:
|
|
986
|
+
contextParentId: z2.string().optional()
|
|
862
987
|
});
|
|
863
|
-
var HandoffSchema =
|
|
988
|
+
var HandoffSchema = z2.object({
|
|
989
|
+
/** Move this existing outcome to `target` without reminting it. Requires `target`. */
|
|
990
|
+
workId: z2.string().uuid().optional(),
|
|
864
991
|
/** Land the note on an existing thread; omitted mints a fresh one. */
|
|
865
|
-
parentId:
|
|
992
|
+
parentId: z2.string().uuid().optional(),
|
|
866
993
|
/** One-line headline of the working context handed off. */
|
|
867
|
-
title:
|
|
994
|
+
title: z2.string().min(1),
|
|
868
995
|
/** The brief — standalone notes the successor reads (what was done, what's left, links). */
|
|
869
|
-
notes:
|
|
996
|
+
notes: z2.array(z2.string().min(1)).min(1),
|
|
870
997
|
/** A sibling connection to dispatch directly to (token id or agent nickname). Same-account
|
|
871
998
|
* only; omit to leave the thread for the user to hand off in the app. */
|
|
872
|
-
target:
|
|
999
|
+
target: z2.string().optional(),
|
|
873
1000
|
/** Write the note as a RECAP (kind:'recap', #617): a summary turn that supersedes the
|
|
874
1001
|
* thread's earlier turns for rehydration — get_thread returns the latest recap + only
|
|
875
1002
|
* the turns after it. Handoff-to-a-successor and handoff-to-yourself-later are the
|
|
876
1003
|
* same primitive; a recap is one whose audience includes you. */
|
|
877
|
-
recap:
|
|
1004
|
+
recap: z2.boolean().optional()
|
|
1005
|
+
}).refine((value) => !value.workId || Boolean(value.target), {
|
|
1006
|
+
message: "target is required when handing off Work",
|
|
1007
|
+
path: ["target"]
|
|
878
1008
|
});
|
|
879
|
-
var NoteSourceSchema =
|
|
880
|
-
var NoteStatusSchema =
|
|
881
|
-
var NoteRepeatSchema =
|
|
882
|
-
var DecisionSchema =
|
|
883
|
-
id:
|
|
1009
|
+
var NoteSourceSchema = z2.enum(["app", "call"]);
|
|
1010
|
+
var NoteStatusSchema = z2.enum(["open", "assigned", "in_progress", "done"]);
|
|
1011
|
+
var NoteRepeatSchema = z2.enum(["once", "until_done"]);
|
|
1012
|
+
var DecisionSchema = z2.object({
|
|
1013
|
+
id: z2.string(),
|
|
884
1014
|
/** The note this decision refines; null = recorded on a bare thread (the
|
|
885
1015
|
* extensibility seam — any conversation can accrue decisions). */
|
|
886
|
-
noteId:
|
|
1016
|
+
noteId: z2.string().nullable(),
|
|
887
1017
|
/** What was ambiguous — the broker's (or the user's own) question. */
|
|
888
|
-
question:
|
|
1018
|
+
question: z2.string(),
|
|
889
1019
|
/** The user's ruling; null while the question is open. */
|
|
890
|
-
answer:
|
|
891
|
-
decidedAt:
|
|
892
|
-
createdAt:
|
|
1020
|
+
answer: z2.string().nullable(),
|
|
1021
|
+
decidedAt: z2.string().nullable(),
|
|
1022
|
+
createdAt: z2.string()
|
|
893
1023
|
});
|
|
894
|
-
var NoteSchema =
|
|
895
|
-
id:
|
|
1024
|
+
var NoteSchema = z2.object({
|
|
1025
|
+
id: z2.string(),
|
|
896
1026
|
/** One-line headline (broker-titled; deterministic floor). */
|
|
897
|
-
title:
|
|
1027
|
+
title: z2.string(),
|
|
898
1028
|
/** The original intent, verbatim — assignees always see the user's own words. */
|
|
899
|
-
intent:
|
|
1029
|
+
intent: z2.string(),
|
|
900
1030
|
source: NoteSourceSchema,
|
|
901
1031
|
status: NoteStatusSchema,
|
|
902
1032
|
/** Who it was assigned to (a participant ref, 'agent:<tokenId>'); null = unassigned. */
|
|
903
|
-
assignee:
|
|
1033
|
+
assignee: z2.string().nullable(),
|
|
904
1034
|
/** The request thread minted at assignment; null until assigned. */
|
|
905
|
-
parentId:
|
|
1035
|
+
parentId: z2.string().nullable(),
|
|
906
1036
|
/** REMINDERS (reminders-design.md): the NOT-BEFORE this becomes eligible to ride a
|
|
907
|
-
* call — never a deadline
|
|
1037
|
+
* call — never a deadline. It only ever comes from the user's own words, so when it
|
|
1038
|
+
* passes Paigy rings ONCE (#1293, owner 2026-08-26: a time said out loud is consent to
|
|
1039
|
+
* a ring at that time); after that it rides like any other. Null = "the very next
|
|
908
1040
|
* call", the right reading of "remind me to…" with no time attached. */
|
|
909
1041
|
// Defaulted, not required: a Note from an API deploy older than the reminders
|
|
910
1042
|
// migration has none of these, and the defaults ARE what it means — no not-before,
|
|
911
1043
|
// one ride, never ridden. Parsing must not fail across a rolling deploy.
|
|
912
|
-
dueAt:
|
|
1044
|
+
dueAt: z2.string().nullable().default(null),
|
|
913
1045
|
repeat: NoteRepeatSchema.default("once"),
|
|
914
1046
|
/** How many calls have already carried it — the fatigue cap counts rides, not days. */
|
|
915
|
-
rides:
|
|
916
|
-
lastRideAt:
|
|
917
|
-
createdAt:
|
|
1047
|
+
rides: z2.number().int().default(0),
|
|
1048
|
+
lastRideAt: z2.string().nullable().default(null),
|
|
1049
|
+
createdAt: z2.string()
|
|
918
1050
|
});
|
|
919
|
-
var CreateNoteSchema =
|
|
1051
|
+
var CreateNoteSchema = z2.object({
|
|
920
1052
|
/** The intent, in the user's own words. Stored verbatim; the broker only titles it. */
|
|
921
|
-
text:
|
|
1053
|
+
text: z2.string().min(1).max(4e3),
|
|
922
1054
|
/** Capture it as a REMINDER — a note assigned to the user themselves, which rides
|
|
923
1055
|
* their next call instead of being handed to an agent. Everything else about the
|
|
924
1056
|
* note is identical; this is the one parameter that separates the two. */
|
|
925
|
-
forMe:
|
|
1057
|
+
forMe: z2.boolean().optional(),
|
|
926
1058
|
/** The not-before, when the user already said one. Absent = the very next call. */
|
|
927
|
-
dueAt:
|
|
1059
|
+
dueAt: z2.string().datetime().optional(),
|
|
928
1060
|
repeat: NoteRepeatSchema.optional()
|
|
929
1061
|
});
|
|
930
|
-
var RecordDecisionSchema =
|
|
1062
|
+
var RecordDecisionSchema = z2.object({
|
|
931
1063
|
/** An open decision (from /clarify) to answer. */
|
|
932
|
-
decisionId:
|
|
1064
|
+
decisionId: z2.string().optional(),
|
|
933
1065
|
/** For an ad-hoc decision: what was ambiguous. Required without `decisionId`. */
|
|
934
|
-
question:
|
|
1066
|
+
question: z2.string().min(1).max(500).optional(),
|
|
935
1067
|
/** The ruling. */
|
|
936
|
-
answer:
|
|
1068
|
+
answer: z2.string().min(1).max(2e3)
|
|
937
1069
|
}).refine((d) => d.decisionId || d.question, { message: "decisionId or question required" });
|
|
938
|
-
var AssignNoteSchema =
|
|
1070
|
+
var AssignNoteSchema = z2.object({
|
|
939
1071
|
/** An EXISTING agent: token id or nickname. Omit when spawning fresh. */
|
|
940
|
-
target:
|
|
1072
|
+
target: z2.string().min(1).optional(),
|
|
941
1073
|
/** Spawn a NEW session for this note (companion.md §2.2): the assignee doesn't
|
|
942
1074
|
* exist yet — mint it on a live desktop that advertises the harness+workspace,
|
|
943
1075
|
* named after the note. The brief arrives as its opening request. */
|
|
944
|
-
spawn:
|
|
945
|
-
hostTokenId:
|
|
946
|
-
harness:
|
|
947
|
-
workspace:
|
|
1076
|
+
spawn: z2.object({
|
|
1077
|
+
hostTokenId: z2.string().uuid(),
|
|
1078
|
+
harness: z2.string().min(1),
|
|
1079
|
+
workspace: z2.string().min(1)
|
|
948
1080
|
}).optional()
|
|
949
1081
|
}).refine((a) => !!a.target !== !!a.spawn, { message: "exactly one of target or spawn" });
|
|
950
|
-
var
|
|
1082
|
+
var TriageVerdictSchema = z2.enum(["keep", "stale", "close", "assign"]);
|
|
1083
|
+
var TriageItemSchema = z2.object({
|
|
1084
|
+
noteId: z2.string(),
|
|
1085
|
+
/** The note's headline at run time. */
|
|
1086
|
+
title: z2.string(),
|
|
1087
|
+
/** WHY, in one short human line, evidence first — this is read on a phone underneath
|
|
1088
|
+
* the note's title: "no movement in 34 days", "worked 3 notes in this repo this week".
|
|
1089
|
+
* Never a model's reasoning transcript, never an id. */
|
|
1090
|
+
why: z2.string()
|
|
1091
|
+
});
|
|
1092
|
+
var TriageAssignmentSchema = z2.object({
|
|
1093
|
+
/** The agent's token id — what `dispatchNote` resolves and what a request is addressed to. */
|
|
1094
|
+
agent: z2.string(),
|
|
1095
|
+
/** Its display name at run time (the name on the hatchling's card). Denormalized for the
|
|
1096
|
+
* same reason as `title`: the card must render from the proposal alone. */
|
|
1097
|
+
agentName: z2.string(),
|
|
1098
|
+
notes: z2.array(TriageItemSchema)
|
|
1099
|
+
});
|
|
1100
|
+
var TriageStatusSchema = z2.enum(["open", "superseded", "dismissed"]);
|
|
1101
|
+
var SubmitTriageSchema = z2.object({
|
|
1102
|
+
/** Which runtime judged: "ollama" (inference never left the machine) or a harness the
|
|
1103
|
+
* user already runs under their own credentials ("claude" / "codex" / "agy"). Recorded
|
|
1104
|
+
* so the phone can say where the content went — an unattributed privacy claim is worth
|
|
1105
|
+
* nothing, and #1106's promise is precisely "Paigy's servers never see this". */
|
|
1106
|
+
provider: z2.string().min(1).max(60),
|
|
1107
|
+
/** The concrete model when the provider names one (an ollama tag); null otherwise. */
|
|
1108
|
+
model: z2.string().max(200).nullable().optional(),
|
|
1109
|
+
/** How many open notes the run actually looked at — the denominator on the phone
|
|
1110
|
+
* ("6 of 50"), and the honest answer to "did it read the whole queue?". */
|
|
1111
|
+
reviewed: z2.number().int().min(0).max(1e4).default(0),
|
|
1112
|
+
close: z2.array(TriageItemSchema).max(200).default([]),
|
|
1113
|
+
stale: z2.array(TriageItemSchema).max(200).default([]),
|
|
1114
|
+
assign: z2.array(TriageAssignmentSchema).max(50).default([])
|
|
1115
|
+
});
|
|
1116
|
+
var TriageProposalSchema = SubmitTriageSchema.extend({
|
|
1117
|
+
id: z2.string(),
|
|
1118
|
+
runAt: z2.string(),
|
|
1119
|
+
status: TriageStatusSchema,
|
|
1120
|
+
model: z2.string().nullable().default(null)
|
|
1121
|
+
});
|
|
1122
|
+
var AcceptTriageSchema = z2.discriminatedUnion("group", [
|
|
1123
|
+
z2.object({ group: z2.literal("close"), noteIds: z2.array(z2.string()).max(200).optional() }),
|
|
1124
|
+
z2.object({ group: z2.literal("stale"), noteIds: z2.array(z2.string()).max(200).optional() }),
|
|
1125
|
+
z2.object({
|
|
1126
|
+
group: z2.literal("assign"),
|
|
1127
|
+
agent: z2.string().min(1),
|
|
1128
|
+
noteIds: z2.array(z2.string()).max(200).optional()
|
|
1129
|
+
})
|
|
1130
|
+
]);
|
|
1131
|
+
var AcceptTriageResultSchema = z2.object({
|
|
1132
|
+
accepted: z2.array(z2.string()),
|
|
1133
|
+
failed: z2.array(z2.object({ noteId: z2.string(), reason: z2.string() }))
|
|
1134
|
+
});
|
|
1135
|
+
var DeliveryModeSchema = z2.enum(["poll", "self_hosted"]);
|
|
951
1136
|
var WAKE_EVENT = "wake";
|
|
952
1137
|
var wakeChannel = (tokenId) => `wake:${tokenId}`;
|
|
953
|
-
var RegisterDeliverySchema =
|
|
954
|
-
var OAuthStartSchema =
|
|
955
|
-
provider:
|
|
956
|
-
returnTo:
|
|
1138
|
+
var RegisterDeliverySchema = z2.object({ mode: DeliveryModeSchema });
|
|
1139
|
+
var OAuthStartSchema = z2.object({
|
|
1140
|
+
provider: z2.enum(["cma"]),
|
|
1141
|
+
returnTo: z2.string().min(1)
|
|
957
1142
|
});
|
|
958
|
-
var DeliveryConfigSchema =
|
|
959
|
-
tokenId:
|
|
1143
|
+
var DeliveryConfigSchema = z2.object({
|
|
1144
|
+
tokenId: z2.string(),
|
|
960
1145
|
mode: DeliveryModeSchema,
|
|
961
1146
|
/** null when the server has no SUPABASE_ANON_KEY set — the listener then falls
|
|
962
1147
|
* back to its own PAIGY_SUPABASE_URL / PAIGY_SUPABASE_ANON_KEY env. */
|
|
963
|
-
realtime:
|
|
1148
|
+
realtime: z2.object({ url: z2.string(), anonKey: z2.string() }).nullable()
|
|
964
1149
|
});
|
|
965
|
-
var StatusSchema =
|
|
966
|
-
name:
|
|
967
|
-
sessionMode:
|
|
1150
|
+
var StatusSchema = z2.object({
|
|
1151
|
+
name: z2.string(),
|
|
1152
|
+
sessionMode: z2.enum(["default", "all_calls", "silent"]),
|
|
968
1153
|
/** A phone is registered for push/ring (any push token on the account). */
|
|
969
|
-
phone:
|
|
1154
|
+
phone: z2.boolean()
|
|
970
1155
|
});
|
|
971
|
-
var EnvelopeRecipientSchema =
|
|
972
|
-
keyId:
|
|
973
|
-
epk:
|
|
974
|
-
wnonce:
|
|
975
|
-
wrap:
|
|
1156
|
+
var EnvelopeRecipientSchema = z2.object({
|
|
1157
|
+
keyId: z2.string(),
|
|
1158
|
+
epk: z2.string(),
|
|
1159
|
+
wnonce: z2.string(),
|
|
1160
|
+
wrap: z2.string()
|
|
976
1161
|
});
|
|
977
|
-
var EnvelopeHeaderSchema =
|
|
978
|
-
field:
|
|
979
|
-
kind:
|
|
980
|
-
senderRole:
|
|
981
|
-
recipientKeyIds:
|
|
982
|
-
seq:
|
|
1162
|
+
var EnvelopeHeaderSchema = z2.object({
|
|
1163
|
+
field: z2.enum(["context", "options", "visuals", "answer"]),
|
|
1164
|
+
kind: z2.string(),
|
|
1165
|
+
senderRole: z2.enum(["agent", "user"]),
|
|
1166
|
+
recipientKeyIds: z2.array(z2.string()),
|
|
1167
|
+
seq: z2.number().int().nonnegative()
|
|
983
1168
|
});
|
|
984
|
-
var EnvelopeSchema =
|
|
985
|
-
v:
|
|
986
|
-
alg:
|
|
987
|
-
msgId:
|
|
1169
|
+
var EnvelopeSchema = z2.object({
|
|
1170
|
+
v: z2.literal(1),
|
|
1171
|
+
alg: z2.literal("x25519-xsalsa20poly1305"),
|
|
1172
|
+
msgId: z2.string(),
|
|
988
1173
|
hdr: EnvelopeHeaderSchema,
|
|
989
|
-
recipients:
|
|
990
|
-
nonce:
|
|
991
|
-
ct:
|
|
1174
|
+
recipients: z2.array(EnvelopeRecipientSchema).min(1),
|
|
1175
|
+
nonce: z2.string(),
|
|
1176
|
+
ct: z2.string()
|
|
992
1177
|
});
|
|
993
|
-
var SealedAnswerSchema =
|
|
994
|
-
ignored:
|
|
1178
|
+
var SealedAnswerSchema = z2.object({
|
|
1179
|
+
ignored: z2.boolean(),
|
|
995
1180
|
envelope: EnvelopeSchema
|
|
996
1181
|
});
|
|
997
|
-
var DeviceCredentialSchema =
|
|
998
|
-
deviceId:
|
|
999
|
-
kind:
|
|
1000
|
-
x25519Pub:
|
|
1001
|
-
ed25519Pub:
|
|
1002
|
-
sig:
|
|
1182
|
+
var DeviceCredentialSchema = z2.object({
|
|
1183
|
+
deviceId: z2.string(),
|
|
1184
|
+
kind: z2.enum(["phone", "web", "agent"]),
|
|
1185
|
+
x25519Pub: z2.string(),
|
|
1186
|
+
ed25519Pub: z2.string(),
|
|
1187
|
+
sig: z2.string()
|
|
1003
1188
|
});
|
|
1004
|
-
var DeviceRosterSchema =
|
|
1005
|
-
uikPub:
|
|
1006
|
-
devices:
|
|
1189
|
+
var DeviceRosterSchema = z2.object({
|
|
1190
|
+
uikPub: z2.string(),
|
|
1191
|
+
devices: z2.array(DeviceCredentialSchema)
|
|
1007
1192
|
});
|
|
1008
|
-
var WakeNudgeSchema =
|
|
1009
|
-
kind:
|
|
1010
|
-
notificationId:
|
|
1011
|
-
parentId:
|
|
1193
|
+
var WakeNudgeSchema = z2.object({
|
|
1194
|
+
kind: z2.enum(["reply", "request", "callback"]),
|
|
1195
|
+
notificationId: z2.string().optional(),
|
|
1196
|
+
parentId: z2.string()
|
|
1012
1197
|
});
|
|
1013
|
-
var PairingStatusSchema =
|
|
1014
|
-
var PairingRevealSchema =
|
|
1015
|
-
x25519:
|
|
1016
|
-
ed25519:
|
|
1017
|
-
nonce:
|
|
1198
|
+
var PairingStatusSchema = z2.enum(["pending", "approved", "denied", "expired"]);
|
|
1199
|
+
var PairingRevealSchema = z2.object({
|
|
1200
|
+
x25519: z2.string(),
|
|
1201
|
+
ed25519: z2.string(),
|
|
1202
|
+
nonce: z2.string()
|
|
1018
1203
|
});
|
|
1019
|
-
var DeviceCodeRequestSchema =
|
|
1204
|
+
var DeviceCodeRequestSchema = z2.object({
|
|
1020
1205
|
/** The agent's suggested name for the pairing — the human sees it pre-filled at
|
|
1021
1206
|
* approval and can override. Optional; blank → a default silly name server-side. */
|
|
1022
|
-
suggestedName:
|
|
1207
|
+
suggestedName: z2.string().optional(),
|
|
1023
1208
|
/** Legacy alias for suggestedName (older MCPs sent `agent`). Accepted for
|
|
1024
1209
|
* back-compat; `suggestedName` wins when both are present. ponytail: drop once no
|
|
1025
1210
|
* pre-`name` MCP is in the wild. */
|
|
1026
|
-
agent:
|
|
1027
|
-
device:
|
|
1028
|
-
proto:
|
|
1211
|
+
agent: z2.union([z2.string(), z2.object({ name: z2.string().optional() })]).optional(),
|
|
1212
|
+
device: z2.string().optional(),
|
|
1213
|
+
proto: z2.string().optional(),
|
|
1029
1214
|
// compiled-in tag, e.g. "paigy-pair-v2|sas=24"
|
|
1030
|
-
commitment:
|
|
1215
|
+
commitment: z2.string().optional()
|
|
1031
1216
|
// agent's Ca
|
|
1032
1217
|
});
|
|
1033
|
-
var DeviceCodeSchema =
|
|
1034
|
-
device_code:
|
|
1035
|
-
user_code:
|
|
1036
|
-
verification_uri:
|
|
1037
|
-
verification_uri_complete:
|
|
1038
|
-
interval:
|
|
1039
|
-
expires_in:
|
|
1218
|
+
var DeviceCodeSchema = z2.object({
|
|
1219
|
+
device_code: z2.string(),
|
|
1220
|
+
user_code: z2.string(),
|
|
1221
|
+
verification_uri: z2.string().url(),
|
|
1222
|
+
verification_uri_complete: z2.string().url(),
|
|
1223
|
+
interval: z2.number(),
|
|
1224
|
+
expires_in: z2.number()
|
|
1040
1225
|
});
|
|
1041
|
-
var DeviceInfoSchema =
|
|
1042
|
-
code:
|
|
1226
|
+
var DeviceInfoSchema = z2.object({
|
|
1227
|
+
code: z2.string(),
|
|
1043
1228
|
/** The agent's suggested name (from /device/code) — shown on the approval screen,
|
|
1044
1229
|
* pre-filling the name field the human can edit. */
|
|
1045
|
-
name:
|
|
1230
|
+
name: z2.string(),
|
|
1046
1231
|
/** @deprecated Legacy alias of `name` for the pre-#531 embedded bundle in App Store
|
|
1047
1232
|
* build 35, whose DeviceFlow renders `info.agent.slice(0, 2)` — without this a FRESH
|
|
1048
1233
|
* install crashes on the pairing screen on first launch, before the OTA lands
|
|
1049
1234
|
* (seen live: PAIGY-5T, 2026-07-21). Remove once a newer binary is the floor. */
|
|
1050
|
-
agent:
|
|
1051
|
-
device:
|
|
1235
|
+
agent: z2.string().optional(),
|
|
1236
|
+
device: z2.string().nullable(),
|
|
1052
1237
|
status: PairingStatusSchema,
|
|
1053
|
-
proto:
|
|
1054
|
-
agent_commitment:
|
|
1238
|
+
proto: z2.string().nullable().optional(),
|
|
1239
|
+
agent_commitment: z2.string().nullable().optional(),
|
|
1055
1240
|
// Ca
|
|
1056
1241
|
agent_reveal: PairingRevealSchema.nullable().optional(),
|
|
1057
1242
|
// present once the agent reveals
|
|
@@ -1061,48 +1246,48 @@ var DeviceInfoSchema = z.object({
|
|
|
1061
1246
|
// withheld until e2ee=true) can compute the SAS WITHOUT a token. Public keys — same safety
|
|
1062
1247
|
// class as agent_reveal above. Present only once the phone reveals; null otherwise.
|
|
1063
1248
|
phone_reveal: PairingRevealSchema.nullable().optional(),
|
|
1064
|
-
uik_pub:
|
|
1249
|
+
uik_pub: z2.string().nullable().optional()
|
|
1065
1250
|
});
|
|
1066
|
-
var DeviceTokenRequestSchema =
|
|
1067
|
-
device_code:
|
|
1251
|
+
var DeviceTokenRequestSchema = z2.object({
|
|
1252
|
+
device_code: z2.string(),
|
|
1068
1253
|
reveal: PairingRevealSchema.optional()
|
|
1069
1254
|
// agent's reveal {x25519, ed25519, nonce}
|
|
1070
1255
|
});
|
|
1071
|
-
var DeviceTokenSchema =
|
|
1072
|
-
access_token:
|
|
1256
|
+
var DeviceTokenSchema = z2.object({
|
|
1257
|
+
access_token: z2.string(),
|
|
1073
1258
|
/** The pairing's single name (user-typed at approval, the agent's suggestion, or
|
|
1074
1259
|
* a default silly name). */
|
|
1075
|
-
name:
|
|
1076
|
-
device:
|
|
1260
|
+
name: z2.string(),
|
|
1261
|
+
device: z2.string().nullable(),
|
|
1077
1262
|
/** The pairing's assigned voice, cached so the desktop can seed the SAME face the phone
|
|
1078
1263
|
* draws — voice is the third ingredient of a hatchling's build (party/traits.ts). */
|
|
1079
|
-
voice:
|
|
1264
|
+
voice: z2.string().nullable().optional(),
|
|
1080
1265
|
/** The token's server-side id — the face's COLOUR anchor, and the only seed ingredient
|
|
1081
1266
|
* that survives a rename. Cached by the host's identity beat. */
|
|
1082
|
-
token_id:
|
|
1267
|
+
token_id: z2.string().nullable().optional(),
|
|
1083
1268
|
/** WHERE this identity works — the folder a wake should land it in. Written by the host
|
|
1084
1269
|
* at spawn and by `paigy-harness handoff` from a live terminal. Without it every wake
|
|
1085
1270
|
* landed in the FIRST granted workspace and the agent rediscovered its own repo from
|
|
1086
1271
|
* the thread each time (host.ts, live catch 2026-08-06 — prompt-papered until now). */
|
|
1087
|
-
workspace:
|
|
1272
|
+
workspace: z2.string().nullable().optional(),
|
|
1088
1273
|
phone_reveal: PairingRevealSchema.nullable().optional(),
|
|
1089
1274
|
// present once the phone reveals
|
|
1090
|
-
uik_pub:
|
|
1275
|
+
uik_pub: z2.string().nullable().optional()
|
|
1091
1276
|
});
|
|
1092
|
-
var DeviceCommitRequestSchema =
|
|
1093
|
-
code:
|
|
1094
|
-
commitment:
|
|
1277
|
+
var DeviceCommitRequestSchema = z2.object({
|
|
1278
|
+
code: z2.string(),
|
|
1279
|
+
commitment: z2.string()
|
|
1095
1280
|
// Cb
|
|
1096
1281
|
});
|
|
1097
|
-
var DevicePeerCommitSchema =
|
|
1098
|
-
commitment:
|
|
1282
|
+
var DevicePeerCommitSchema = z2.object({
|
|
1283
|
+
commitment: z2.string().nullable()
|
|
1099
1284
|
});
|
|
1100
|
-
var SupportRequestSchema =
|
|
1101
|
-
email:
|
|
1102
|
-
message:
|
|
1103
|
-
name:
|
|
1285
|
+
var SupportRequestSchema = z2.object({
|
|
1286
|
+
email: z2.string().email().max(320),
|
|
1287
|
+
message: z2.string().trim().min(1).max(5e3),
|
|
1288
|
+
name: z2.string().trim().max(120).optional()
|
|
1104
1289
|
});
|
|
1105
|
-
var NotificationFeedbackKindSchema =
|
|
1290
|
+
var NotificationFeedbackKindSchema = z2.enum([
|
|
1106
1291
|
"break_down",
|
|
1107
1292
|
// "This should be more than one ask — break it down."
|
|
1108
1293
|
"regenerate_options",
|
|
@@ -1116,26 +1301,46 @@ var NotificationFeedbackKindSchema = z.enum([
|
|
|
1116
1301
|
"other"
|
|
1117
1302
|
// anything else — the note carries it.
|
|
1118
1303
|
]);
|
|
1119
|
-
var NotificationFeedbackSchema =
|
|
1120
|
-
notificationId:
|
|
1304
|
+
var NotificationFeedbackSchema = z2.object({
|
|
1305
|
+
notificationId: z2.string(),
|
|
1121
1306
|
kind: NotificationFeedbackKindSchema,
|
|
1122
1307
|
/** Optional free-text elaboration for a preset; required (non-empty) for 'other'. */
|
|
1123
|
-
note:
|
|
1308
|
+
note: z2.string().trim().max(2e3).optional()
|
|
1124
1309
|
}).superRefine((r, ctx) => {
|
|
1125
1310
|
if (r.kind === "other" && !r.note)
|
|
1126
|
-
ctx.addIssue({ code:
|
|
1311
|
+
ctx.addIssue({ code: z2.ZodIssueCode.custom, path: ["note"], message: "note is required for 'other' feedback" });
|
|
1127
1312
|
});
|
|
1128
|
-
var FeedbackResolutionSchema =
|
|
1129
|
-
var FeedbackOutcomeSchema =
|
|
1313
|
+
var FeedbackResolutionSchema = z2.enum(["broker_fixed", "sent_to_agent"]);
|
|
1314
|
+
var FeedbackOutcomeSchema = z2.object({
|
|
1130
1315
|
resolution: FeedbackResolutionSchema,
|
|
1131
1316
|
transform: TransformSchema,
|
|
1132
|
-
message:
|
|
1133
|
-
childIds:
|
|
1317
|
+
message: z2.string(),
|
|
1318
|
+
childIds: z2.array(z2.string()).optional()
|
|
1319
|
+
});
|
|
1320
|
+
var CONTACT_SCHEMA = contactSchemaFrom({
|
|
1321
|
+
ask: NotifyRequestFields.shape.ask,
|
|
1322
|
+
waiting: NotifyRequestFields.shape.waiting,
|
|
1323
|
+
options: NotifyRequestFields.shape.options,
|
|
1324
|
+
channel: NotifyRequestFields.shape.channel,
|
|
1325
|
+
parentId: NotifyRequestFields.shape.parentId,
|
|
1326
|
+
workId: NotifyRequestFields.shape.workId
|
|
1134
1327
|
});
|
|
1135
1328
|
|
|
1136
1329
|
export {
|
|
1137
|
-
|
|
1330
|
+
mcpInputSchema,
|
|
1331
|
+
CreateGoalSchema,
|
|
1332
|
+
CREATE_GOAL_DESCRIPTION,
|
|
1333
|
+
CONTACT_DESCRIPTION,
|
|
1334
|
+
CHECK_REPLIES_DESCRIPTION,
|
|
1335
|
+
SCHEDULE_CALLBACK_DESCRIPTION,
|
|
1336
|
+
SEARCH_THREADS_DESCRIPTION,
|
|
1337
|
+
SET_WORK_STATE_DESCRIPTION,
|
|
1338
|
+
serverInstructions,
|
|
1339
|
+
SetTaskStateSchema,
|
|
1340
|
+
SetWorkStateSchema,
|
|
1341
|
+
ScheduleCallbackSchema,
|
|
1138
1342
|
HandoffSchema,
|
|
1139
1343
|
WAKE_EVENT,
|
|
1140
|
-
wakeChannel
|
|
1344
|
+
wakeChannel,
|
|
1345
|
+
CONTACT_SCHEMA
|
|
1141
1346
|
};
|