@paigy/mcp 0.40.22 → 0.40.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/dist/{chunk-2ED4GL4N.js → chunk-J7T3EB5Y.js} +11 -9
- package/dist/chunk-RK5LT7NH.js +110 -0
- package/dist/{chunk-BFN2GJ42.js → chunk-TP7DM2MP.js} +1 -1
- package/dist/{chunk-WDZ67U4G.js → chunk-VUKR2E24.js} +688 -505
- package/dist/{chunk-KSXJCZ2L.js → chunk-WR2M3RME.js} +762 -535
- package/dist/{dist-YAKVSYVQ.js → dist-EKLTLANV.js} +13 -3
- package/dist/enable.js +3 -3
- package/dist/index.js +18 -7
- package/dist/listen.js +83 -15
- package/dist/onboard.js +4 -4
- package/dist/slot.js +1 -1
- package/dist/stalled.js +1 -1
- package/dist/statusline.js +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// ../../packages/schema/dist/index.js
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z5 } from "zod";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { z as z3 } from "zod";
|
|
5
5
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
6
6
|
import { z as z2 } from "zod";
|
|
7
|
+
import { z as z4 } from "zod";
|
|
8
|
+
import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
|
|
7
9
|
var OPTIONS_MIN = 2;
|
|
8
10
|
var OPTIONS_MAX = 6;
|
|
9
11
|
var OptionSchema = z.object({
|
|
@@ -54,34 +56,31 @@ function mcpInputSchema(s) {
|
|
|
54
56
|
}
|
|
55
57
|
var AskInputSchema = z2.object({
|
|
56
58
|
id: z2.string().optional().describe("Optional idempotency key or client-side ID for this specific ask."),
|
|
57
|
-
parentId: z2.string().uuid().optional().describe("The Goal this question is about \u2014 usually the one you are working on. The question goes onto that Goal and its answer comes back there. Omit it and
|
|
59
|
+
parentId: z2.string().uuid().optional().describe("The Goal this question is about \u2014 usually the one you are working on. The question goes onto that Goal and its answer comes back there. Omit it and the question starts a new Goal of yours."),
|
|
58
60
|
repo: z2.string().optional().describe("Optional repository context."),
|
|
59
61
|
ask: z2.string().trim().min(1).max(1e4).describe(
|
|
60
|
-
"ONE question, and only what is needed to answer it. Several questions are several asks in the array, one each: an answer settles the one ask it was given in the shape that ask declares, so a person who answers the part of a bundled ask that interested them settles nothing and is asked again. Paigy
|
|
62
|
+
"ONE question, and only what is needed to answer it. Several questions are several asks in the array, one each: an answer settles the one ask it was given in the shape that ask declares, so a person who answers the part of a bundled ask that interested them settles nothing and is asked again. Paigy sends each ask exactly as you wrote it: a bundled ask arrives as one card. News, progress and findings are their own contact; ANY contact for a person already on a call JOINS that call, whatever channel you asked for, so several arrive as one call."
|
|
61
63
|
),
|
|
62
64
|
options: z2.array(OptionInputSchema).min(1).max(6).optional(),
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
// as "All three / 1 and 3 only / Just log it", which the person could not read without the text and
|
|
68
|
-
// could not answer as the ticks he wanted. "many" is the one shape an agent knows and the read does
|
|
69
|
-
// not: whether its own options exclude each other.
|
|
65
|
+
// HOW THE OPTIONS ARE ANSWERED, SAID BY THE AGENT (owner, 2026-10-02: "one and many makes sense";
|
|
66
|
+
// brain_prompts.md §1: structured agent questions need no model). Every card was pick-one while no
|
|
67
|
+
// agent sent this; no read reshapes cards any more, so this is the card's shape, and the
|
|
68
|
+
// description says so plainly.
|
|
70
69
|
select: z2.enum(["one", "many"]).optional().describe(
|
|
71
|
-
'How the options are answered: "
|
|
70
|
+
'How the options are answered: "many" makes a checklist (they may want several, e.g. independent fixes), "one" (the default) a pick (choosing one rules out the others). Send "many" whenever more than one option could be wanted at once. The person can always answer in their own words as well. Ignored without options.'
|
|
72
71
|
),
|
|
73
72
|
answers: z2.string().trim().regex(/^[0-9a-fA-F-]{8,36}$/).optional().describe(
|
|
74
|
-
"Your reply answers a question the person asked you: the id the conversation shows for it (8 characters or whole). Their question closes with this reply as its answer, and any decision of yours it was holding back goes back to them.
|
|
73
|
+
"Your reply answers a question the person asked you: the id the conversation shows for it (8 characters or whole). Their question closes with this reply as its answer, and any decision of yours it was holding back goes back to them. parentId is optional here: the question's own Goal is used. The reply is sent to them as it is; to also ask something new, send that as its own ask."
|
|
75
74
|
)
|
|
76
75
|
}).strict();
|
|
77
76
|
var StartContactSchema = z2.object({
|
|
78
|
-
asks: z2.array(AskInputSchema).min(1).describe("The questions to pose, one per object. An ask with a parentId is filed on that Goal as it is;
|
|
77
|
+
asks: z2.array(AskInputSchema).min(1).describe("The questions to pose, one per object. An ask with a parentId is filed on that Goal as it is; an ask naming no Goal starts a new Goal of yours."),
|
|
79
78
|
waiting: z2.enum(["none", "hard"]).default("none").describe("hard requests a call even when channel is notification; user permissions and ring cooldowns still apply."),
|
|
80
79
|
channel: z2.enum(["notification", "call"]).default("notification")
|
|
81
80
|
}).strict();
|
|
82
81
|
var ContactSchema = z2.union([StartContactSchema, z2.object({ deliveryId: z2.string().uuid() }).strict()]);
|
|
83
82
|
var CONTACT_SCHEMA = { type: "object", ...mcpInputSchema(ContactSchema) };
|
|
84
|
-
var CONTACT_DESCRIPTION = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'select', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. An ask that names a Goal (parentId) goes onto that Goal; one that names none
|
|
83
|
+
var CONTACT_DESCRIPTION = "Contact the user with one or more asks/questions. Pass an array of asks (each with 'ask', optional 'options', 'select', 'id', 'parentId', 'repo'), plus channel:'notification'|'call', and waiting:'none'|'hard'. An ask that names a Goal (parentId) goes onto that Goal; one that names none starts a new Goal of yours. Notification returns immediately; collect durable answers with check_replies. On stdio, a Call holds one cancellable ~45s window; continue with ONLY {deliveryId}. One question per 'ask'; several questions are several objects in 'asks'. Each ask is sent exactly as written, with no reading in between: a bundled ask arrives as one card, so separate questions are separate asks. An ask with no options that is not blocking is a report, and a report is an UPDATE, never a claim on them: it reaches them and is listed apart from what waits on them, so no answer is owed and none should be awaited. On a Goal whose report card is still open it is added to that card, with no new push; Where your work stands while under way is progress: report it with update_goal, not contact. Send options (or waiting:'hard') when you actually need an answer. Each option's label must stand on its own \u2014 the person may see only the labels \u2014 so never a label that points into your text ('All three', 'Option 2', '1 and 3 only'). select:'many' makes the card a checklist, for independent options they may want several of; select:'one' (the default) a pick, for alternatives. The person can always answer in their own words, so never add an 'Other' option. If the person is already on a call, your contact joins that call automatically \u2014 whatever channel you asked for, with no ring \u2014 and the Delivery it returns IS that call: reread it with contact({deliveryId}) to see everything answered on it so far, and contact again while it is live to add information or a further question to the same call.";
|
|
85
84
|
var CreateGoalSchema = z3.object({
|
|
86
85
|
outcome: z3.string().trim().min(1).max(1e4),
|
|
87
86
|
/** The work's NAME (#2115) — one to five words, how a person refers to it out loud ("the night
|
|
@@ -104,7 +103,7 @@ var CreateGoalSchema = z3.object({
|
|
|
104
103
|
var CreateGoalToolSchema = CreateGoalSchema.extend({
|
|
105
104
|
idempotencyKey: CreateGoalSchema.shape.idempotencyKey.optional().describe("Optional. One is minted per call; pass your own only so a retry lands on the same Goal.")
|
|
106
105
|
}).strict();
|
|
107
|
-
var CREATE_GOAL_DESCRIPTION = 'Create a durable Goal for an outcome. Without parentGoalId it is placed against your open Goals: if one already IS this work, that Goal comes back (existing: true) and nothing new is created \u2014 continue it; if the work belongs under one, it is created there (parentGoalId in the receipt); otherwise it is a root. Pass parentGoalId yourself to put it under a specific Goal. Pass repo to anchor the work to a specific repository ("owner/repo" or repo name); delegated children inherit it. Pass title to name it in one to five words, as a person would refer to it out loud ("the night rings") \u2014 it heads every list and is spoken on a call; without one the brain writes it. Admission only:
|
|
106
|
+
var CREATE_GOAL_DESCRIPTION = 'Create a durable Goal for an outcome. Without parentGoalId it is placed against your open Goals: if one already IS this work, that Goal comes back (existing: true) and nothing new is created \u2014 continue it; if the work belongs under one, it is created there (parentGoalId in the receipt); otherwise it is a root. Pass parentGoalId yourself to put it under a specific Goal. Pass repo to anchor the work to a specific repository ("owner/repo" or repo name); delegated children inherit it. Pass title to name it in one to five words, as a person would refer to it out loud ("the night rings") \u2014 it heads every list and is spoken on a call; without one the brain writes it. Admission only: claim it before doing work, then update it as it advances. Returns an admission receipt with goalId, current state, revision, ownerParticipant, and the next step; no Goal content or execution lease.';
|
|
108
107
|
var UpdateGoalSchema = z3.object({
|
|
109
108
|
revision: z3.number().int().positive(),
|
|
110
109
|
changes: z3.object({
|
|
@@ -140,12 +139,13 @@ var GetGoalSchema = z3.object({
|
|
|
140
139
|
* between two of them named. Off by default; `docs/model/goal/diagnose-design.md`. */
|
|
141
140
|
diagnose: z3.boolean().optional()
|
|
142
141
|
}).strict();
|
|
143
|
-
var GET_GOAL_DESCRIPTION = "Read one Goal without claiming it: its outcome, state, revision, progress, blockers, the conversation on it (each question with its options and what was decided), `next`, the one step to take, and `more`, where to read further. A question in that conversation reads `open` (nothing yet), `answered` (a choice was made, and `answer` carries it), `replied` (they said something and the read settled the question on their words \u2014 NO option of yours was chosen, and the words are the reply line beside it, so read that before you act), or `closed`. The conversation carries everything the person said, every open question and your newest entry; your older entries are left out and counted \u2014 history: true reads every entry in full.
|
|
144
|
-
var UPDATE_GOAL_DESCRIPTION = `Update
|
|
145
|
-
var CLAIM_GOAL_DESCRIPTION = "Claim the oldest runnable or review-pending Goal you own
|
|
142
|
+
var GET_GOAL_DESCRIPTION = "Read one Goal without claiming it, including others (the ten most recent other contributors, with names, latest entry headlines and times): its outcome, state, revision, progress, blockers, the conversation on it (each question with its options and what was decided), `next`, the one step to take, and `more`, where to read further. A question in that conversation reads `open` (nothing yet), `answered` (a choice was made, and `answer` carries it), `replied` (they said something and the read settled the question on their words \u2014 NO option of yours was chosen, and the words are the reply line beside it, so read that before you act), or `closed`. The conversation carries everything the person said, every open question and your newest entry; your older entries are left out and counted \u2014 history: true reads every entry in full. Every Goal of your person is readable, whichever of their agents owns it; another account's Goals are not disclosed.\n\ndiagnose: true is for when a read has CONFUSED you \u2014 not for the working loop. It adds `diagnosis`, which asks every reader that already answers a question about your work and NAMES the reader behind every value, so you never guess which of two places to look: what state your work is really in (the stored `goals.state` beside the derived `goal_execution_state`, which can differ); whether anything is armed to ring and when (`ladder_candidates`, with the ladder's own last decision); whether a wake fired for you and what it did (durable `wake.*` events, beside when your process was last heard from); and what has reached you (`list_waiting` \u2014 review flags, unstarted work, open questions, the person's newest words). Read `diagnosis.disagreements` FIRST: each one is two readers giving different values for the same fact, with both values and both sources, and it never chooses between them \u2014 that is yours to do, from the Goal's own history. `diagnosis.looked` names every reader asked, including any that could not answer, so an empty answer is never confused with a broken one.";
|
|
143
|
+
var UPDATE_GOAL_DESCRIPTION = `Update a Goal you are on at an exact revision. You are on a Goal you own, or one you have written on (an update with progress, or a contact on it); any of your person's agents may write on any of their Goals, and one that never touched a Goal is refused (409 goal_not_joined). State, ownership, dependencies, children, progress, title, and review acknowledgement are explicit; stale revisions are rejected. A CONTACT ON THIS GOAL MOVES ITS REVISION: a question filed on a Goal is a change to it, so an update prepared before a contact and sent after it is refused as stale (409 goal_revision_conflict) \u2014 re-read the Goal, then write. title is the work's name in one to five words, as a person would refer to it out loud (it is spoken on a call and heads every list); null clears it. reviewed: true acknowledges new evidence and closes the Deliveries addressed to you on that Goal, never over an open decision. dueAt (an ISO instant, or null) makes the Goal wait until then; when it passes you are woken for it \u2014 use it for a promise to follow up later. withdraw: [questionId] takes back a question YOU asked on this Goal that is still open \u2014 because you acted on it yourself, it no longer matters, or you asked it wrongly (e.g. waiting: hard when nothing was blocked): it is cancelled, not answered, its card closes and it stops ringing; the id is the one the conversation shows. state: done means the work was accomplished, and it can be reopened: when the person says it is not done ("it's not working"), set state: active on that same Goal instead of starting a new one; its parent reopens with it. state: done while children are still open records your part as done: the Goal waits and closes by itself when its last open child closes. cancelled is final. Returns the Goal as get_goal reads it, at its new revision.`;
|
|
144
|
+
var CLAIM_GOAL_DESCRIPTION = "Claim a pending answer to your question or the oldest runnable or review-pending Goal you own. Pass goalId to join any Goal of your person; its assignment stays unchanged. Read others before overlapping another agent\u2019s work. Joining lets you contribute and change its state; use update_goal with ownerParticipant when the assignment itself should change. Returns the Goal as get_goal reads it, and marks you as on it, which never shuts another agent out: other agents of your person may write on it and change it too, and two changes at once are told apart by revision (409 goal_revision_conflict).";
|
|
146
145
|
var CHECK_REPLIES_DESCRIPTION = "What is waiting for you: your open Deliveries (a request the user started toward you, a handoff), one row each with its Goals, how many decisions are still open, and the newest words in brief; `assigned`, your Goals nobody has started yet, however they became yours (claim_goal({goalId}) starts one); and `review`, your Goals with something new on them \u2014 the user's answers and notes are Entries on the Goal, not Deliveries. A pure read with no arguments: nothing is consumed, acknowledged or claimed by reading it, so call it on startup, after a long wait, or whenever you want to know what is outstanding. To act on one, claim its Goal (claim_goal) or reread a Delivery in full with contact({deliveryId}). Once you have acted on what arrived, update_goal with reviewed: true clears the Goal from `review` and closes the Deliveries addressed to you on it.";
|
|
147
146
|
var CheckRepliesSchema = z3.object({}).strict();
|
|
148
147
|
var AGENT_TOOLS = [
|
|
148
|
+
{ name: "who_is_working", description: "Read your person's agents that contributed in the last 24 hours, newest first: at most 30 agents and their five most recently touched Goals, with their latest entry headline and time. Use get_goal to read a Goal and its other contributors before starting overlapping work. Read-only; no arguments.", inputSchema: mcpInputSchema(CheckRepliesSchema) },
|
|
149
149
|
{ name: "contact", description: CONTACT_DESCRIPTION, inputSchema: CONTACT_SCHEMA },
|
|
150
150
|
{ name: "check_replies", description: CHECK_REPLIES_DESCRIPTION, inputSchema: mcpInputSchema(CheckRepliesSchema) },
|
|
151
151
|
{ name: "create_goal", description: CREATE_GOAL_DESCRIPTION, inputSchema: mcpInputSchema(CreateGoalToolSchema) },
|
|
@@ -156,7 +156,7 @@ var AGENT_TOOLS = [
|
|
|
156
156
|
var AGENT_TOOL_NAMES = AGENT_TOOLS.map((t) => t.name);
|
|
157
157
|
function serverInstructions(opts) {
|
|
158
158
|
const calls = opts.waits ? "A Call holds one bounded window here; continue with contact({deliveryId}) to hold the next or reread that exact Delivery." : "A Call returns after one read; continue with contact({deliveryId}) to reread that exact Delivery.";
|
|
159
|
-
return `On startup and after a wake, call check_replies for the open Deliveries addressed to you, and claim_goal for your runnable or review-pending Goal and the conversation on it. get_goal rereads it without claiming. Every read ends in \`next\`, the one step to take. Notifications return immediately: keep working and collect answers through claim_goal/get_goal. ${calls} Evidence can repeat: reads do not acknowledge or hide it. Report progress and acknowledge review with update_goal, never as a contact. Never infer ringing from an open Call Delivery. Soft waiting and re-presentation are unsupported. Your user is remote. Always interact with the user through Paigy. For decisions, approvals, or questions, contact them with structured options. Never assume anyone is reading the terminal stdout.
|
|
159
|
+
return `On startup and after a wake, call check_replies for the open Deliveries addressed to you, and claim_goal for your runnable or review-pending Goal and the conversation on it. get_goal rereads it without claiming. Every Goal of your person is open to you, whichever of their agents owns it: read it with get_goal, write on it (contact with its id as parentId, or update_goal progress), and once you have written on it you may change it too. Every read ends in \`next\`, the one step to take. Notifications return immediately: keep working and collect answers through claim_goal/get_goal. ${calls} Evidence can repeat: reads do not acknowledge or hide it. Report progress and acknowledge review with update_goal, never as a contact. Never infer ringing from an open Call Delivery. Soft waiting and re-presentation are unsupported. Your user is remote. Always interact with the user through Paigy. For decisions, approvals, or questions, contact them with structured options. Never assume anyone is reading the terminal stdout.
|
|
160
160
|
|
|
161
161
|
HOW TO ASK:
|
|
162
162
|
1. One question per ask. Five questions are five objects in \`asks\`, in one contact, so each can be answered on its own; one question with five parts settles nothing until all five are answered.
|
|
@@ -165,9 +165,156 @@ HOW TO ASK:
|
|
|
165
165
|
4. Never hold the process open with while-loops. For an open Call with a pending decision, follow its \`next\` with another bounded \`contact({deliveryId})\` tool call; a returned wait window is not a completed conversation. STOP REREADING when a window comes back with nothing new said \u2014 they are not typing, the question stays open, and its answer reaches you on the Goal. Otherwise, yield only with a working listener or scheduled wakeup, and collect answers with \`check_replies\` or \`claim_goal\` on that wake.
|
|
166
166
|
5. One ask, one row. Never restate a question that is still waiting inside a new contact: keep waiting on the original, or the answer lands on one copy and the other stays open.
|
|
167
167
|
6. Read the Goal's conversation before asking. Never ask again what was answered or already shipped \u2014 and tell its states apart: \`answered\` carries the choice in \`answer\`, while \`replied\` means they said something and chose none of your options, so that question is still yours to settle and their words are the line beside it.
|
|
168
|
-
7. A question carries its options. Without them it reaches the person as a bare title nobody can answer. Each option names its choice in full -- never \`All three\` or \`Option 2\`
|
|
168
|
+
7. A question carries its options. Without them it reaches the person as a bare title nobody can answer. Each option names its choice in full -- never \`All three\` or \`Option 2\`. \`select: "many"\` makes the card a checklist (options they may want several of); \`"one"\`, the default, a pick (one rules out the others). Your ask is sent exactly as you wrote it. They can always answer in their own words, so no "Other" option.
|
|
169
169
|
8. A diagnosis says when, why and how it happens, then proposes one fix. Never options first.`;
|
|
170
170
|
}
|
|
171
|
+
var id = z4.string().uuid();
|
|
172
|
+
var key = z4.string().min(1).max(40);
|
|
173
|
+
var participant = z4.string().regex(/^(human|agent):.+$/, "a participant ID such as agent:<uuid>");
|
|
174
|
+
var SourceSchema = z4.object({ entryId: id }).strict();
|
|
175
|
+
var ResultRefSchema = z4.union([z4.object({ id }).strict(), z4.object({ local: key }).strict()]);
|
|
176
|
+
var NodeRefSchema = z4.object({ type: z4.enum(["goal", "question"]), id }).strict();
|
|
177
|
+
var DependencySchema = z4.object({
|
|
178
|
+
blocker: NodeRefSchema,
|
|
179
|
+
blocked: NodeRefSchema,
|
|
180
|
+
action: z4.enum(["start", "complete", "answer"]),
|
|
181
|
+
reason: z4.string().max(500).optional()
|
|
182
|
+
}).strict();
|
|
183
|
+
var goalState = z4.enum(["open", "completed", "canceled"]);
|
|
184
|
+
var existingGoalChanges = [
|
|
185
|
+
z4.object({ kind: z4.literal("edit"), goalId: id, title: z4.string().min(1).max(120).optional(), outcome: z4.string().min(1).optional() }).strict().refine((c) => c.title !== void 0 || c.outcome !== void 0, "an edit changes the title or the outcome"),
|
|
186
|
+
z4.object({ kind: z4.literal("state"), goalId: id, state: goalState }).strict(),
|
|
187
|
+
z4.object({ kind: z4.literal("assign"), goalId: id, ownerId: participant }).strict(),
|
|
188
|
+
z4.object({ kind: z4.literal("defer"), goalId: id, until: z4.string().datetime().nullable() }).strict(),
|
|
189
|
+
z4.object({ kind: z4.literal("move"), goalId: id, parentGoalId: id.nullable() }).strict(),
|
|
190
|
+
z4.object({
|
|
191
|
+
kind: z4.literal("dependency"),
|
|
192
|
+
change: z4.enum(["add", "remove"]),
|
|
193
|
+
goalId: id,
|
|
194
|
+
dependsOnGoalId: id,
|
|
195
|
+
action: z4.enum(["start", "complete"]),
|
|
196
|
+
reason: z4.string().max(500).optional()
|
|
197
|
+
}).strict()
|
|
198
|
+
];
|
|
199
|
+
var GoalChangeSchema = z4.union([
|
|
200
|
+
z4.object({
|
|
201
|
+
kind: z4.literal("create"),
|
|
202
|
+
title: z4.string().min(1).max(120),
|
|
203
|
+
outcome: z4.string().min(1),
|
|
204
|
+
ownerId: participant,
|
|
205
|
+
parentGoalId: id.optional(),
|
|
206
|
+
sourceEntryIds: z4.array(id)
|
|
207
|
+
}).strict(),
|
|
208
|
+
...existingGoalChanges
|
|
209
|
+
]);
|
|
210
|
+
var BrainGoalChangeSchema = z4.union([
|
|
211
|
+
// newSession: Paigy starts a session to own it (owner, 2026-10-06); until it has, the person owns it.
|
|
212
|
+
z4.object({
|
|
213
|
+
kind: z4.literal("create"),
|
|
214
|
+
outcome: z4.string().min(1),
|
|
215
|
+
title: z4.string().min(1).max(120),
|
|
216
|
+
ownerId: participant,
|
|
217
|
+
parentGoal: ResultRefSchema.nullable(),
|
|
218
|
+
newSession: z4.literal(true).optional()
|
|
219
|
+
}).strict(),
|
|
220
|
+
...existingGoalChanges
|
|
221
|
+
]);
|
|
222
|
+
var option = z4.object({ id: z4.string().min(1).max(40), label: z4.string().min(1), hint: z4.string().optional() }).strict();
|
|
223
|
+
var QuestionChangeSchema = z4.union([
|
|
224
|
+
z4.object({
|
|
225
|
+
kind: z4.literal("create"),
|
|
226
|
+
text: z4.string().min(1),
|
|
227
|
+
answererId: participant,
|
|
228
|
+
goal: ResultRefSchema.optional(),
|
|
229
|
+
blocks: z4.array(z4.object({ question: ResultRefSchema }).strict()),
|
|
230
|
+
options: z4.array(option).min(2).optional(),
|
|
231
|
+
pickMode: z4.enum(["one", "many", "rank"]).optional()
|
|
232
|
+
}).strict().refine((c) => c.options === void 0 === (c.pickMode === void 0), "options and pickMode come together"),
|
|
233
|
+
z4.object({ kind: z4.literal("edit"), questionId: id, text: z4.string().min(1) }).strict(),
|
|
234
|
+
z4.object({ kind: z4.literal("assign"), questionId: id, answererId: participant }).strict(),
|
|
235
|
+
z4.object({ kind: z4.literal("withdraw"), questionId: id }).strict(),
|
|
236
|
+
z4.object({ kind: z4.literal("dependency"), change: z4.enum(["add", "remove"]), edge: DependencySchema }).strict()
|
|
237
|
+
]);
|
|
238
|
+
var lessonScope = z4.union([
|
|
239
|
+
z4.object({ kind: z4.literal("user") }).strict(),
|
|
240
|
+
z4.object({ kind: z4.literal("goal"), goal: ResultRefSchema }).strict()
|
|
241
|
+
]);
|
|
242
|
+
var LessonChangeSchema = z4.union([
|
|
243
|
+
z4.object({ kind: z4.literal("remember"), text: z4.string().min(1), scope: lessonScope }).strict(),
|
|
244
|
+
z4.object({ kind: z4.literal("revise"), lessonId: id, text: z4.string().min(1), scope: lessonScope }).strict(),
|
|
245
|
+
z4.object({ kind: z4.literal("withdraw"), lessonId: id }).strict()
|
|
246
|
+
]);
|
|
247
|
+
var BrainNextSchema = z4.object({
|
|
248
|
+
instructions: z4.array(z4.object({ entryKeys: z4.array(key).min(1) }).strict()),
|
|
249
|
+
say: z4.array(key),
|
|
250
|
+
then: z4.enum(["listen", "hold", "end", "none"]),
|
|
251
|
+
waitFor: z4.array(ResultRefSchema),
|
|
252
|
+
reason: z4.string()
|
|
253
|
+
}).strict();
|
|
254
|
+
var messageBase = {
|
|
255
|
+
key,
|
|
256
|
+
text: z4.string().min(1),
|
|
257
|
+
goals: z4.array(ResultRefSchema),
|
|
258
|
+
questions: z4.array(ResultRefSchema),
|
|
259
|
+
entryKeys: z4.array(key),
|
|
260
|
+
obligationIds: z4.array(id)
|
|
261
|
+
};
|
|
262
|
+
var BrainMessageSchema = z4.union([
|
|
263
|
+
z4.object({ ...messageBase, to: z4.object({ kind: z4.literal("user") }).strict() }).strict(),
|
|
264
|
+
z4.object({
|
|
265
|
+
...messageBase,
|
|
266
|
+
to: z4.object({ kind: z4.literal("agent"), agentId: z4.string().regex(/^agent:(?!paigy$)\S+$/) }).strict(),
|
|
267
|
+
call: z4.object({ callId: id, listen: z4.literal(true) }).strict().optional()
|
|
268
|
+
}).strict()
|
|
269
|
+
]);
|
|
270
|
+
var BrainSearchSchema = z4.object({
|
|
271
|
+
query: z4.string().min(1).max(500),
|
|
272
|
+
within: z4.array(z4.enum(["entries", "goals", "answers"])).min(1),
|
|
273
|
+
goalId: id.optional()
|
|
274
|
+
}).strict();
|
|
275
|
+
var BrainResultSchema = z4.object({
|
|
276
|
+
messages: z4.array(BrainMessageSchema),
|
|
277
|
+
entries: z4.array(z4.object({ key, sources: z4.array(SourceSchema).min(1), goals: z4.array(ResultRefSchema) }).strict()),
|
|
278
|
+
questions: z4.array(z4.object({ key, entryKeys: z4.array(key), change: QuestionChangeSchema }).strict()),
|
|
279
|
+
answers: z4.array(z4.object({
|
|
280
|
+
question: ResultRefSchema,
|
|
281
|
+
entryKeys: z4.array(key).min(1),
|
|
282
|
+
summary: z4.string().min(1),
|
|
283
|
+
selectedOptionIds: z4.array(z4.string().min(1)).optional()
|
|
284
|
+
}).strict()),
|
|
285
|
+
goals: z4.array(z4.object({ key, entryKeys: z4.array(key), change: BrainGoalChangeSchema }).strict()),
|
|
286
|
+
feedback: z4.array(z4.object({ entryKeys: z4.array(key).min(1) }).strict()),
|
|
287
|
+
lessons: z4.array(z4.object({ entryKeys: z4.array(key).min(1), change: LessonChangeSchema }).strict()),
|
|
288
|
+
next: BrainNextSchema,
|
|
289
|
+
search: BrainSearchSchema.optional()
|
|
290
|
+
}).strict();
|
|
291
|
+
var str = z4.string();
|
|
292
|
+
var strs = z4.array(z4.string());
|
|
293
|
+
var CompactResultSchema = z4.object({
|
|
294
|
+
next: z4.object({ say: strs, then: z4.enum(["listen", "hold", "end", "none"]), waitFor: strs, reason: str, instructions: strs }).strict(),
|
|
295
|
+
messages: z4.array(z4.object({ key: str, to: str, text: str, about: strs, entries: strs, owed: strs, inviteToCall: z4.boolean() }).strict()),
|
|
296
|
+
entries: z4.array(z4.object({ key: str, from: str, on: strs }).strict()),
|
|
297
|
+
answers: z4.array(z4.object({ question: str, entries: strs, summary: str, picked: strs }).strict()),
|
|
298
|
+
changes: z4.array(z4.object({
|
|
299
|
+
key: str,
|
|
300
|
+
what: z4.enum(["goal", "question", "lesson"]),
|
|
301
|
+
op: z4.enum(["create", "edit", "assign", "open", "complete", "cancel", "defer", "move", "block", "unblock", "withdraw", "remember", "revise"]),
|
|
302
|
+
id: str,
|
|
303
|
+
text: str,
|
|
304
|
+
title: str,
|
|
305
|
+
who: str,
|
|
306
|
+
under: str,
|
|
307
|
+
gate: z4.enum(["start", "complete", "answer", "none"]),
|
|
308
|
+
options: z4.array(z4.object({ id: str, label: str }).strict()),
|
|
309
|
+
pick: z4.enum(["one", "many", "rank", "words"]),
|
|
310
|
+
entries: strs
|
|
311
|
+
}).strict()),
|
|
312
|
+
feedback: z4.array(strs),
|
|
313
|
+
search: z4.object({ query: str, within: strs, goal: str }).strict()
|
|
314
|
+
}).strict();
|
|
315
|
+
var COMPACT_RESULT_JSON_SCHEMA = (({ $schema: _, ...rest }) => rest)(
|
|
316
|
+
zodToJsonSchema2(CompactResultSchema, { $refStrategy: "none" })
|
|
317
|
+
);
|
|
171
318
|
function entryWords(entry) {
|
|
172
319
|
const content = entry.content;
|
|
173
320
|
if (content && "sealed" in content) return "";
|
|
@@ -180,22 +327,24 @@ function entryWords(entry) {
|
|
|
180
327
|
const description = plain.description;
|
|
181
328
|
const parts = [title, ...Array.isArray(description) ? description : []].filter((v) => typeof v === "string");
|
|
182
329
|
if (parts.length) return parts.join("\n\n");
|
|
330
|
+
const line = plain.line;
|
|
331
|
+
if (typeof line === "string" && line.trim()) return line;
|
|
183
332
|
}
|
|
184
333
|
return entry.sources.map((source) => source.text).join("\n");
|
|
185
334
|
}
|
|
186
335
|
var LIVE_MS = 3 * 6e4;
|
|
187
|
-
var WORKING_MS =
|
|
188
|
-
var ContextSchema =
|
|
189
|
-
title:
|
|
190
|
-
description:
|
|
336
|
+
var WORKING_MS = 60 * 6e4;
|
|
337
|
+
var ContextSchema = z5.object({
|
|
338
|
+
title: z5.string().min(1).describe("One-line headline of what you need (required, non-empty)."),
|
|
339
|
+
description: z5.array(z5.string().min(1)).describe(
|
|
191
340
|
"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."
|
|
192
341
|
)
|
|
193
342
|
});
|
|
194
|
-
var ParticipantSchema =
|
|
195
|
-
kind:
|
|
196
|
-
id:
|
|
343
|
+
var ParticipantSchema = z5.object({
|
|
344
|
+
kind: z5.enum(["human", "agent"]),
|
|
345
|
+
id: z5.string()
|
|
197
346
|
});
|
|
198
|
-
var TransformSchema =
|
|
347
|
+
var TransformSchema = z5.enum([
|
|
199
348
|
"structure",
|
|
200
349
|
// shape intent into an answer contract; pick channel/urgency — broker `ask`, `select` shapes, `points`
|
|
201
350
|
"request_more",
|
|
@@ -211,13 +360,13 @@ var TransformSchema = z4.enum([
|
|
|
211
360
|
"summarize"
|
|
212
361
|
// reduce volume, keep decision value — 30-turn cap, spoken briefing
|
|
213
362
|
]);
|
|
214
|
-
var VisualSchema =
|
|
215
|
-
url:
|
|
216
|
-
label:
|
|
363
|
+
var VisualSchema = z5.object({
|
|
364
|
+
url: z5.string().url(),
|
|
365
|
+
label: z5.string().optional()
|
|
217
366
|
});
|
|
218
|
-
var NotifyLevelSchema =
|
|
219
|
-
var SelectShapeSchema =
|
|
220
|
-
var ReceiptEventSchema =
|
|
367
|
+
var NotifyLevelSchema = z5.enum(["inbox", "push", "banner", "call"]);
|
|
368
|
+
var SelectShapeSchema = z5.enum(["one", "many", "rank", "confirm", "text"]);
|
|
369
|
+
var ReceiptEventSchema = z5.enum([
|
|
221
370
|
"delivered",
|
|
222
371
|
// the bundle reached the recipient at some level
|
|
223
372
|
"seen",
|
|
@@ -247,47 +396,47 @@ var ReceiptEventSchema = z4.enum([
|
|
|
247
396
|
// be rewound by a writer that forgot to advance it.
|
|
248
397
|
"restarted"
|
|
249
398
|
]);
|
|
250
|
-
var AttentionSchema =
|
|
399
|
+
var AttentionSchema = z5.object({
|
|
251
400
|
urgency: NotifyLevelSchema,
|
|
252
401
|
/** The required answer shape, or null for a plain notify that asks nothing back. */
|
|
253
402
|
select: SelectShapeSchema.nullable(),
|
|
254
403
|
/** Coverage contract (#396) — points the answer must address; null = none declared. */
|
|
255
|
-
points:
|
|
404
|
+
points: z5.array(z5.string()).nullable(),
|
|
256
405
|
/** Whether the ask blocks the sender — what lets arbitration escalate it on silence. */
|
|
257
|
-
blocking:
|
|
406
|
+
blocking: z5.boolean(),
|
|
258
407
|
/** Reserved (docs/model/model.md lists it): a response deadline. No row column yet — a later Phase 2
|
|
259
408
|
* slice wires it; optional so today's rows/callers project cleanly. */
|
|
260
|
-
deadline:
|
|
409
|
+
deadline: z5.string().datetime().nullable().optional()
|
|
261
410
|
});
|
|
262
|
-
var NotifyRequestFields =
|
|
411
|
+
var NotifyRequestFields = z5.object({
|
|
263
412
|
/** Plaintext message content. Present on the plaintext path (today's shape);
|
|
264
413
|
* ABSENT on the E2EE path, where the sealed `envelope` below carries it. The
|
|
265
414
|
* superRefine at the bottom enforces exactly one of the two. */
|
|
266
415
|
context: ContextSchema.optional(),
|
|
267
|
-
options:
|
|
416
|
+
options: z5.array(OptionInputSchema).min(OPTIONS_MIN).max(OPTIONS_MAX).optional().describe(
|
|
268
417
|
"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)."
|
|
269
418
|
),
|
|
270
|
-
points:
|
|
419
|
+
points: z5.array(z5.string().min(1)).optional().describe(
|
|
271
420
|
"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."
|
|
272
421
|
),
|
|
273
|
-
visuals:
|
|
422
|
+
visuals: z5.array(VisualSchema).optional().describe(
|
|
274
423
|
"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."
|
|
275
424
|
),
|
|
276
425
|
/** Git repo the agent is working in ("owner/name"). Local MCP fills this from the checkout — omit unless overriding. */
|
|
277
|
-
repo:
|
|
426
|
+
repo: z5.string().optional(),
|
|
278
427
|
/** Git branch the agent is on. Local MCP fills this from the checkout — omit unless overriding. */
|
|
279
|
-
branch:
|
|
428
|
+
branch: z5.string().optional(),
|
|
280
429
|
/** Continue an existing conversation — the id of any notification in it (its root
|
|
281
430
|
* is the conversation's identity). Omitted = start a new conversation. Renamed
|
|
282
431
|
* from `parentId` (2026-08-03): one linkage system, the parent; the API edge
|
|
283
432
|
* still accepts the old name from older clients. */
|
|
284
|
-
parentId:
|
|
433
|
+
parentId: z5.string().uuid().optional(),
|
|
285
434
|
/** The durable outcome this contact advances. Optional during the notification-to-Work
|
|
286
435
|
* migration; when present, a blocking ask creates a DecisionNeed for this Work. */
|
|
287
|
-
workId:
|
|
436
|
+
workId: z5.string().uuid().optional(),
|
|
288
437
|
/** Target Goal scope. During staged migration this is accepted by the shared contract but
|
|
289
438
|
* target delivery activation remains model-gated; workId and goalId are mutually exclusive. */
|
|
290
|
-
goalId:
|
|
439
|
+
goalId: z5.string().uuid().optional(),
|
|
291
440
|
urgency: NotifyLevelSchema.default("inbox").describe(
|
|
292
441
|
"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."
|
|
293
442
|
),
|
|
@@ -295,7 +444,7 @@ var NotifyRequestFields = z4.object({
|
|
|
295
444
|
* visible and marks it needs_input. Renamed from the old `parentId` (2026-08-03)
|
|
296
445
|
* when `parentId` became the conversation handle: `parentId` says WHERE, this
|
|
297
446
|
* says HOW. */
|
|
298
|
-
clarifies:
|
|
447
|
+
clarifies: z5.string().optional(),
|
|
299
448
|
select: SelectShapeSchema.optional().describe(
|
|
300
449
|
"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."
|
|
301
450
|
),
|
|
@@ -309,20 +458,20 @@ var NotifyRequestFields = z4.object({
|
|
|
309
458
|
// (docs/brain/broker/agenda-design.md) — not by a wire cap the agent has to pre-summarize under.
|
|
310
459
|
// Owner, 2026-07-28: "our actual limitation on how long something is to the user should
|
|
311
460
|
// come from the broker splitting and summarizing." The cap that remains is a size guard.
|
|
312
|
-
ask:
|
|
461
|
+
ask: z5.string().min(1).max(1e4).optional().describe(
|
|
313
462
|
'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.'
|
|
314
463
|
),
|
|
315
|
-
needs:
|
|
464
|
+
needs: z5.array(z5.string().min(1)).optional().describe(
|
|
316
465
|
"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."
|
|
317
466
|
),
|
|
318
|
-
urgencyHint:
|
|
467
|
+
urgencyHint: z5.enum(["whenever", "soon", "now"]).optional().describe(
|
|
319
468
|
"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."
|
|
320
469
|
),
|
|
321
470
|
/** #575: the ONE self-report that replaces urgencyHint + blocking — what happens
|
|
322
471
|
* to the agent's work while it waits. Normalized server-side into those two
|
|
323
472
|
* fields (normalizeWaiting) so everything downstream is untouched; explicit
|
|
324
473
|
* urgencyHint/blocking win when both are sent. */
|
|
325
|
-
waiting:
|
|
474
|
+
waiting: z5.enum(["none", "soft", "hard"]).optional().describe(
|
|
326
475
|
"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."
|
|
327
476
|
),
|
|
328
477
|
/** Δ9b (#895): HOLD this claim so the sender can correct the plan before anyone is
|
|
@@ -330,98 +479,98 @@ var NotifyRequestFields = z4.object({
|
|
|
330
479
|
* holding by default would charge every quiet claim that minute before any agent could
|
|
331
480
|
* correct anything. Ignored for `waiting: 'hard'`: a blocking ask rings on what we have,
|
|
332
481
|
* and the enrichment can still land mid-call (#781 re-plans the unspoken tail). */
|
|
333
|
-
confirm:
|
|
482
|
+
confirm: z5.boolean().optional().describe(
|
|
334
483
|
"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'."
|
|
335
484
|
),
|
|
336
485
|
/** #575: a RELAY of the user's explicitly stated preference, never the agent's
|
|
337
486
|
* choice. Outranks waiting in both directions: 'call' rings even for a
|
|
338
487
|
* waiting:'none' "call me when it's done"; 'message' never rings even for
|
|
339
488
|
* waiting:'hard'. */
|
|
340
|
-
channel:
|
|
489
|
+
channel: z5.enum(["call", "message"]).optional().describe(
|
|
341
490
|
"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."
|
|
342
491
|
),
|
|
343
|
-
confirmStyle:
|
|
492
|
+
confirmStyle: z5.enum(["yesno", "approve"]).default("yesno").describe(
|
|
344
493
|
"Labels for a select:'confirm' paige \u2014 'yesno' (Yes/No) or 'approve' (Approve/Deny). Ignored unless select is 'confirm'."
|
|
345
494
|
),
|
|
346
|
-
blocking:
|
|
495
|
+
blocking: z5.boolean().default(false).describe(
|
|
347
496
|
"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."
|
|
348
497
|
)
|
|
349
498
|
});
|
|
350
499
|
var NotifyRequestSchema = NotifyRequestFields.superRefine((r, ctx) => {
|
|
351
|
-
if (r.workId && r.goalId) ctx.addIssue({ code:
|
|
500
|
+
if (r.workId && r.goalId) ctx.addIssue({ code: z5.ZodIssueCode.custom, path: ["goalId"], message: "pass goalId or workId, not both" });
|
|
352
501
|
if (r.ask !== void 0) {
|
|
353
502
|
for (const f of ["context", "select", "points"]) {
|
|
354
503
|
if (r[f] !== void 0)
|
|
355
|
-
ctx.addIssue({ code:
|
|
504
|
+
ctx.addIssue({ code: z5.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.` });
|
|
356
505
|
}
|
|
357
506
|
return;
|
|
358
507
|
}
|
|
359
508
|
if (r.needs !== void 0 || r.urgencyHint !== void 0)
|
|
360
|
-
ctx.addIssue({ code:
|
|
509
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: ["needs"], message: "needs/urgencyHint belong to the simplified `ask` form \u2014 with a shaped request use points/urgency" });
|
|
361
510
|
if (!r.context)
|
|
362
|
-
ctx.addIssue({ code:
|
|
511
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: ["context"], message: "context is required (plaintext path)" });
|
|
363
512
|
if (!r.select)
|
|
364
|
-
ctx.addIssue({ code:
|
|
513
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: ["select"], message: "select is required on the shaped form" });
|
|
365
514
|
const needsOptions = r.select === "one" || r.select === "many" || r.select === "rank";
|
|
366
515
|
if (needsOptions && !r.options?.length)
|
|
367
|
-
ctx.addIssue({ code:
|
|
516
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: ["options"], message: `select:'${r.select}' requires options` });
|
|
368
517
|
if (!needsOptions && r.options?.length)
|
|
369
|
-
ctx.addIssue({ code:
|
|
518
|
+
ctx.addIssue({ code: z5.ZodIssueCode.custom, path: ["options"], message: `select:'${r.select}' takes no options` });
|
|
370
519
|
});
|
|
371
|
-
var NotifyStatusSchema =
|
|
372
|
-
var AgentStateSchema =
|
|
373
|
-
var TurnSchema =
|
|
374
|
-
prompt:
|
|
375
|
-
reply:
|
|
520
|
+
var NotifyStatusSchema = z5.enum(["pending", "answered", "ignored"]);
|
|
521
|
+
var AgentStateSchema = z5.enum(["idle", "in_progress", "completed", "needs_input"]);
|
|
522
|
+
var TurnSchema = z5.object({
|
|
523
|
+
prompt: z5.string(),
|
|
524
|
+
reply: z5.string()
|
|
376
525
|
});
|
|
377
|
-
var UserAnswerSchema =
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
526
|
+
var UserAnswerSchema = z5.discriminatedUnion("kind", [
|
|
527
|
+
z5.object({ kind: z5.literal("option"), optionId: z5.string(), label: z5.string().optional() }),
|
|
528
|
+
z5.object({ kind: z5.literal("text"), text: z5.string() }),
|
|
529
|
+
z5.object({ kind: z5.literal("ignored") }),
|
|
530
|
+
z5.object({ kind: z5.literal("multi"), optionIds: z5.array(z5.string()), labels: z5.array(z5.string()).optional() }),
|
|
531
|
+
z5.object({ kind: z5.literal("ranked"), optionIds: z5.array(z5.string()), labels: z5.array(z5.string()).optional() }),
|
|
532
|
+
z5.object({ kind: z5.literal("clarify"), chunks: z5.array(z5.string()).min(1) }),
|
|
533
|
+
z5.object({ kind: z5.literal("confirm"), approved: z5.boolean() }),
|
|
534
|
+
z5.object({ kind: z5.literal("turns"), turns: z5.array(TurnSchema).min(1) }),
|
|
386
535
|
/** An auto-answer derived from the user's PAST decisions (docs/brain/broker/precedent-design.md §2):
|
|
387
536
|
* delivered through the same settle/await path as a human answer, carrying the judge's
|
|
388
537
|
* derivation and the precedent ids it grew from. Always paired with a visible trail
|
|
389
538
|
* card the user can reply to — the broker never overrides the user. */
|
|
390
|
-
|
|
539
|
+
z5.object({ kind: z5.literal("precedent"), answer: z5.string(), derivation: z5.string(), sources: z5.array(z5.string()).min(1) })
|
|
391
540
|
]);
|
|
392
|
-
var IntentSchema =
|
|
541
|
+
var IntentSchema = z5.object({
|
|
393
542
|
// The full vocabulary the bot's mapper emits (mapper.INTENT_KINDS) — the schema lagged
|
|
394
543
|
// it by two ("detail", "feedback"), and because the settle handler parsed the array
|
|
395
544
|
// all-or-nothing, ONE feedback act silently dropped EVERY intent on the call,
|
|
396
545
|
// questions included. Found auditing five calls' stored feedback, 2026-08-01.
|
|
397
|
-
kind:
|
|
398
|
-
detail:
|
|
546
|
+
kind: z5.enum(["defer", "delegate", "channel", "question", "detail", "feedback", "command", "control"]),
|
|
547
|
+
detail: z5.string(),
|
|
399
548
|
/** Defer only: seconds until the callback the caller asked for, when something upstream
|
|
400
549
|
* already read the time. Nothing sets it today (#397 documented an MCP parser that was
|
|
401
550
|
* never written) — the API reads the defer's `detail` itself with `notes/when.ts`
|
|
402
551
|
* (`parseDelay`, #1292), and a value here simply wins over that reading. */
|
|
403
|
-
dueInSeconds:
|
|
552
|
+
dueInSeconds: z5.number().int().positive().optional(),
|
|
404
553
|
/** Feedback only (#812): WHICH failure the complaint names — typed by the mapper that
|
|
405
|
-
* already read the utterance, so `
|
|
554
|
+
* already read the utterance, so `signals.kind` stops defaulting to
|
|
406
555
|
* 'other' on every row. A table that records that something was wrong and nothing
|
|
407
556
|
* about what cannot answer "is the bot looping less this week?". */
|
|
408
|
-
fault:
|
|
557
|
+
fault: z5.enum(["loop", "unanswered", "overridden", "misheard", "slow", "other"]).optional()
|
|
409
558
|
});
|
|
410
|
-
var RideAlongSchema =
|
|
559
|
+
var RideAlongSchema = z5.object({
|
|
411
560
|
/** The note this came from — assign/clarify/close it through /api/notes/:id. */
|
|
412
|
-
noteId:
|
|
561
|
+
noteId: z5.string(),
|
|
413
562
|
/** What to do, in the owner's own words (the note's headline). Never model-rewritten. */
|
|
414
|
-
text:
|
|
563
|
+
text: z5.string(),
|
|
415
564
|
/** The thread to report back on, when the note was dispatched over the request rail. */
|
|
416
|
-
parentId:
|
|
565
|
+
parentId: z5.string().nullable()
|
|
417
566
|
});
|
|
418
|
-
var AwaitItemSchema =
|
|
419
|
-
|
|
420
|
-
type:
|
|
421
|
-
parentId:
|
|
422
|
-
notificationId:
|
|
423
|
-
workId:
|
|
424
|
-
decisionId:
|
|
567
|
+
var AwaitItemSchema = z5.discriminatedUnion("type", [
|
|
568
|
+
z5.object({
|
|
569
|
+
type: z5.literal("reply"),
|
|
570
|
+
parentId: z5.string(),
|
|
571
|
+
notificationId: z5.string(),
|
|
572
|
+
workId: z5.string().uuid().optional(),
|
|
573
|
+
decisionId: z5.string().uuid().optional(),
|
|
425
574
|
answer: UserAnswerSchema,
|
|
426
575
|
/** WHAT THE AGENT CANNOT KNOW FROM THE FIELDS BESIDE IT (owner, 2026-09-04, issue
|
|
427
576
|
* #1537). One line, built from the record: the ask and the caller's reply VERBATIM,
|
|
@@ -431,103 +580,103 @@ var AwaitItemSchema = z4.discriminatedUnion("type", [
|
|
|
431
580
|
* "call me back after you merge" in their own words decides for itself what to do,
|
|
432
581
|
* and now knows exactly which call to make. Absent when either half is missing —
|
|
433
582
|
* a sentence with a hole in it is worse than no sentence. */
|
|
434
|
-
note:
|
|
583
|
+
note: z5.string().optional(),
|
|
435
584
|
/** The call record rendered for THIS agent (`docs/brain/voice/record-design.md`): the words the
|
|
436
585
|
* shaped answer was mapped from, filtered to its own claims. There is no second list
|
|
437
586
|
* of labels beside it — the acts went 2026-09-04 and `intents` went with them (owner,
|
|
438
587
|
* 2026-09-04): the agent reads the sentence and decides. */
|
|
439
|
-
transcript:
|
|
588
|
+
transcript: z5.string().optional(),
|
|
440
589
|
/** Coverage report (#396), when the ask declared `points`: which of them this
|
|
441
590
|
* answer addressed. Missing points = re-ask or proceed knowingly partial. */
|
|
442
|
-
covered:
|
|
591
|
+
covered: z5.array(z5.string()).optional(),
|
|
443
592
|
/** Ride-alongs (RideAlongSchema) — pending work for you, attached to the moment you
|
|
444
593
|
* became free. Only `reply` and `idle` carry it: those are the two outcomes that
|
|
445
594
|
* END a wait. `remind`, `superseded` and `turn` are mid-flight, and handing an
|
|
446
595
|
* agent a side-quest while it is still holding the line is how the main thing gets
|
|
447
596
|
* dropped. Absent/empty = nothing owed. */
|
|
448
|
-
also:
|
|
597
|
+
also: z5.array(RideAlongSchema).optional()
|
|
449
598
|
}),
|
|
450
|
-
|
|
451
|
-
type:
|
|
452
|
-
parentId:
|
|
453
|
-
notificationId:
|
|
454
|
-
remindAt:
|
|
599
|
+
z5.object({
|
|
600
|
+
type: z5.literal("remind"),
|
|
601
|
+
parentId: z5.string(),
|
|
602
|
+
notificationId: z5.string(),
|
|
603
|
+
remindAt: z5.string().datetime({ offset: true }),
|
|
455
604
|
/** Seconds until remindAt, server-computed — pass straight to ScheduleWakeup. */
|
|
456
|
-
remindInSeconds:
|
|
605
|
+
remindInSeconds: z5.number()
|
|
457
606
|
}),
|
|
458
607
|
/** The awaited ask was REPLACED by a newer notification on its thread (e.g. a
|
|
459
608
|
* post-feedback revision, #633) — the user will never answer this id. Stop
|
|
460
609
|
* awaiting it; the live ask is the thread's newest turn (await that one, or
|
|
461
610
|
* re-orient via check_replies). */
|
|
462
|
-
|
|
463
|
-
type:
|
|
464
|
-
parentId:
|
|
465
|
-
notificationId:
|
|
611
|
+
z5.object({
|
|
612
|
+
type: z5.literal("superseded"),
|
|
613
|
+
parentId: z5.string(),
|
|
614
|
+
notificationId: z5.string()
|
|
466
615
|
}),
|
|
467
616
|
/** A LIVE call's turn, streamed as it lands (#783). PROVISIONAL: the user can still
|
|
468
617
|
* revise any of these until the final reply arrives — partial = intelligence,
|
|
469
618
|
* settled = authorization. Use it to PREPARE (fetch, draft, warm), never to act
|
|
470
619
|
* irreversibly. If `acts` carries a question aimed at you and you know the answer,
|
|
471
620
|
* contact on the same thread right away — the caller hears it on the same call. */
|
|
472
|
-
|
|
473
|
-
type:
|
|
474
|
-
notificationId:
|
|
475
|
-
inFlight:
|
|
476
|
-
turn:
|
|
477
|
-
idx:
|
|
478
|
-
prompt:
|
|
479
|
-
reply:
|
|
480
|
-
acts:
|
|
621
|
+
z5.object({
|
|
622
|
+
type: z5.literal("partial"),
|
|
623
|
+
notificationId: z5.string(),
|
|
624
|
+
inFlight: z5.literal(true),
|
|
625
|
+
turn: z5.object({
|
|
626
|
+
idx: z5.number(),
|
|
627
|
+
prompt: z5.string(),
|
|
628
|
+
reply: z5.string(),
|
|
629
|
+
acts: z5.array(IntentSchema).nullable().optional()
|
|
481
630
|
})
|
|
482
631
|
}),
|
|
483
|
-
|
|
484
|
-
type:
|
|
485
|
-
also:
|
|
632
|
+
z5.object({
|
|
633
|
+
type: z5.literal("idle"),
|
|
634
|
+
also: z5.array(RideAlongSchema).optional(),
|
|
486
635
|
/** Is a call live for this agent's user right now? The SDK polls the partial stream
|
|
487
636
|
* (#783) between idle ticks ONLY while this is not `false` — a partial can only exist
|
|
488
637
|
* during a live call, and polling for one on a banner/message was a wasted HTTP call +
|
|
489
638
|
* 3 queries on every idle tick of every waiting agent (~80% of all traffic at scale).
|
|
490
639
|
* Absent = an older API → the SDK keeps polling, exactly as before. */
|
|
491
|
-
inFlight:
|
|
640
|
+
inFlight: z5.boolean().optional()
|
|
492
641
|
})
|
|
493
642
|
]);
|
|
494
|
-
var VoiceKeySchema =
|
|
495
|
-
var AgendaTurnSchema =
|
|
643
|
+
var VoiceKeySchema = z5.enum(["rachel", "george", "jessica", "brian", "lily"]);
|
|
644
|
+
var AgendaTurnSchema = z5.object({
|
|
496
645
|
/** THE TURN'S IDENTITY (the first-sentence stream, 2026-09-09): the brain call that wrote
|
|
497
646
|
* it and its place in that reply — `<brainCallId>:<index>`, with `:p` on the first
|
|
498
647
|
* sentence a re-plan publishes ahead of the rest. A turn is spoken once, by this id: the
|
|
499
648
|
* completion of a streamed re-plan carries the published sentence again, and the walk
|
|
500
649
|
* drops what it already said by identity, never by the API's guess of what was polled.
|
|
501
650
|
* Absent on plans nothing streams (a ring plan, a floor). */
|
|
502
|
-
id:
|
|
651
|
+
id: z5.string().optional(),
|
|
503
652
|
/** Twin coverage (#1089): sibling claim ids this asking turn's answer ALSO settles —
|
|
504
653
|
* the planner declares duplicates instead of asking them twice. */
|
|
505
|
-
coveredIds:
|
|
654
|
+
coveredIds: z5.array(z5.string()).optional(),
|
|
506
655
|
/** The spoken sentences of the turn, in order. No count: how long a turn is is the brain's call
|
|
507
656
|
* (owner, 2026-09-25), and a count here refused whole plans. */
|
|
508
|
-
info:
|
|
509
|
-
question:
|
|
657
|
+
info: z5.array(z5.string().min(1)).default([]),
|
|
658
|
+
question: z5.string().min(1).nullable(),
|
|
510
659
|
/** True on the one turn carrying the agent's own declared question. */
|
|
511
|
-
asks:
|
|
660
|
+
asks: z5.boolean().optional(),
|
|
512
661
|
/** The claim this turn belongs to (#781) — the RETURN identity: answers route by it.
|
|
513
662
|
* Absent on a single-claim plan (the session's own claim) and on shared context turns,
|
|
514
663
|
* which route nothing. */
|
|
515
|
-
claimId:
|
|
664
|
+
claimId: z5.string().optional(),
|
|
516
665
|
/** The claim's voice key (#462) — the OUTBOUND identity, audible who-is-asking. */
|
|
517
|
-
voice:
|
|
666
|
+
voice: z5.string().optional(),
|
|
518
667
|
/** The claim's AGENT NAME (#838) — the spoken identity. A voice alone doesn't say
|
|
519
668
|
* whose request this is: an item that folded in from another agent arrived as a bare
|
|
520
669
|
* non-sequitur ("First real production sign-in is yours to make whenever you want.")
|
|
521
670
|
* and the owner answered "What?". The bot names the agent before its first turn. */
|
|
522
|
-
agent:
|
|
671
|
+
agent: z5.string().optional(),
|
|
523
672
|
/** The claim's agent by ID — the pairing's connection id (`notifications.token_id`), the
|
|
524
673
|
* same id a face is minted from. A name is not an identity: two pairings may be called
|
|
525
674
|
* "Claude", and a name cannot be joined on. The record's entries carry it (`agent_id`)
|
|
526
675
|
* so "who said that" survives the call, and it rides PER TURN because a coalesced call
|
|
527
676
|
* speaks for several agents — the turn is the only place that knows which. */
|
|
528
|
-
agentId:
|
|
677
|
+
agentId: z5.string().optional(),
|
|
529
678
|
select: SelectShapeSchema.optional(),
|
|
530
|
-
options:
|
|
679
|
+
options: z5.array(OptionSchema.omit({ id: true })).optional(),
|
|
531
680
|
/* `pace` STOOD HERE (#826). A turn could carry seconds and the model chose them. The walk
|
|
532
681
|
paces itself now — a short beat between the sentences of a turn, the longer one at its end
|
|
533
682
|
(owner, 2026-09-30: "remove the bot deciding pace") — and it does that where the words are
|
|
@@ -536,27 +685,33 @@ var AgendaTurnSchema = z4.object({
|
|
|
536
685
|
/** Whether the walk WAITS for an answer before moving on. Absent = derived as today
|
|
537
686
|
* (a question blocks, context flows). blocking:false on a question = ask and move
|
|
538
687
|
* on, the claim stays pending; blocking:true on context = hold for a reply. */
|
|
539
|
-
blocking:
|
|
688
|
+
blocking: z5.boolean().optional(),
|
|
689
|
+
/** SPOKEN ONLY IF THEY SAY NOTHING (owner, 2026-10-01, call 812de935: "you're gonna re-ask, but it
|
|
690
|
+
* shouldn't be the same words … more like, hey, are you still there, or are you able to answer, or
|
|
691
|
+
* would you need more information"). The walk holds this turn out of its queue; at the queue's end it
|
|
692
|
+
* listens for the last word, and only if that listen is silent is this turn said and asked. If they
|
|
693
|
+
* speak, it is dropped and their words are taken like any reply. */
|
|
694
|
+
ifSilent: z5.boolean().optional()
|
|
540
695
|
});
|
|
541
696
|
var CLAIM_STALE_MS = 30 * 6e4;
|
|
542
|
-
var InboxItemSchema =
|
|
543
|
-
id:
|
|
544
|
-
tokenId:
|
|
697
|
+
var InboxItemSchema = z5.object({
|
|
698
|
+
id: z5.string(),
|
|
699
|
+
tokenId: z5.string().optional(),
|
|
545
700
|
status: NotifyStatusSchema,
|
|
546
701
|
context: ContextSchema,
|
|
547
|
-
options:
|
|
702
|
+
options: z5.array(OptionSchema).optional(),
|
|
548
703
|
/** The ask's declared coverage points (#396), when the agent sent them. */
|
|
549
|
-
points:
|
|
704
|
+
points: z5.array(z5.string()).optional(),
|
|
550
705
|
/** Does this claim want an ANSWER, or is it telling you something? Written per row from
|
|
551
706
|
* `requestAsks` — the agent's own declaration, not a guess. `false` is what earns a card
|
|
552
707
|
* its acknowledge affordance: without it a status update offers a text box and a dismiss,
|
|
553
708
|
* and neither of those is "got it" (owner, 2026-08-10). */
|
|
554
|
-
asks:
|
|
709
|
+
asks: z5.boolean().optional(),
|
|
555
710
|
/** When a live process last pulsed for this row's agent — the liveness input for
|
|
556
711
|
* "working requires a pulse" (#928): the list said "Working…" from agent_state alone
|
|
557
712
|
* while the party called the same dead claim stalled. Absent = no token/no data,
|
|
558
713
|
* which must never CLAIM stalled. */
|
|
559
|
-
lastSeenAt:
|
|
714
|
+
lastSeenAt: z5.string().optional(),
|
|
560
715
|
/** WHEN THE AGENT LAST SAID ANYTHING ABOUT THIS CLAIM — the newest `agent_state` row in
|
|
561
716
|
* the `notification_events` ledger (trigger-written since 20260621010000, so every row a
|
|
562
717
|
* user can see has one). The age input for `CLAIM_STALE_MS`, and it has to be this rather
|
|
@@ -566,7 +721,7 @@ var InboxItemSchema = z4.object({
|
|
|
566
721
|
* work. Reading the row's birth as the claim's age brands that "No update in 8h" the
|
|
567
722
|
* instant the agent picks it up (#997). Absent = pre-trigger row; fall back to
|
|
568
723
|
* `createdAt`. */
|
|
569
|
-
agentStateAt:
|
|
724
|
+
agentStateAt: z5.string().datetime().optional(),
|
|
570
725
|
/** THE QUESTIONS A CALL CARRIES — the call screen's agenda spine (docs/clients/app/walk/design.md §11, owner
|
|
571
726
|
* 2026-09-22). One per DecisionNeed on the Call, in the Call's order, answered or open (a
|
|
572
727
|
* superseded or cancelled need is no longer a question anyone is asked). Present only on a
|
|
@@ -580,54 +735,54 @@ var InboxItemSchema = z4.object({
|
|
|
580
735
|
* `turn` topic (`asking`, `settled`), because the bot never sees a DecisionNeed id. `title` is
|
|
581
736
|
* the card's own concise heading; `answer` the accepted answer in words, null while open. It
|
|
582
737
|
* REPLACED `agenda` (turns), which nothing ever filled. */
|
|
583
|
-
questions:
|
|
584
|
-
id:
|
|
585
|
-
entryId:
|
|
586
|
-
title:
|
|
587
|
-
state:
|
|
588
|
-
answer:
|
|
738
|
+
questions: z5.array(z5.object({
|
|
739
|
+
id: z5.string(),
|
|
740
|
+
entryId: z5.string(),
|
|
741
|
+
title: z5.string(),
|
|
742
|
+
state: z5.enum(["open", "answered"]),
|
|
743
|
+
answer: z5.string().nullable(),
|
|
589
744
|
/** WHO ASKED IT (owner, 2026-09-23, Goal a345e906: each agenda row wears its agent's face) — the
|
|
590
745
|
* request Entry's author, as the same three facts the item's own `tokenId`/`name`/`voice`
|
|
591
746
|
* carry for the call's one agent, so the phone draws it with the same seed. Absent when the
|
|
592
747
|
* author is not an agent this account holds (unpaired since, or a person). */
|
|
593
|
-
agent:
|
|
748
|
+
agent: z5.object({ tokenId: z5.string(), name: z5.string(), voice: VoiceKeySchema.optional() }).optional(),
|
|
594
749
|
/** ITS OPTIONS, WHEN THERE IS SOMETHING TO SEE (owner, 2026-09-25: "Yes, add it"): the options
|
|
595
750
|
* its need offers, exactly as its own card carries them, present only when one of them has a
|
|
596
751
|
* preview (`html` or `image`). The call screen opens them from the agenda row, so a preview is
|
|
597
752
|
* never re-sent as a second card to be seen mid-call. Words-only options are absent — the bot
|
|
598
753
|
* says those, and the list stays small (an `html` is up to 16 KB). */
|
|
599
|
-
options:
|
|
754
|
+
options: z5.array(OptionSchema).optional()
|
|
600
755
|
})).optional(),
|
|
601
|
-
visuals:
|
|
756
|
+
visuals: z5.array(VisualSchema).optional(),
|
|
602
757
|
/** The connected agent's name (the single pairing name — user-typed, or the
|
|
603
758
|
* agent's suggestion, or a default silly name). */
|
|
604
|
-
name:
|
|
759
|
+
name: z5.string(),
|
|
605
760
|
/** The pairing's assigned voice (#462); absent = the default voice. */
|
|
606
761
|
voice: VoiceKeySchema.optional(),
|
|
607
|
-
repo:
|
|
608
|
-
branch:
|
|
609
|
-
createdAt:
|
|
610
|
-
snoozedUntil:
|
|
762
|
+
repo: z5.string().optional(),
|
|
763
|
+
branch: z5.string().optional(),
|
|
764
|
+
createdAt: z5.string().datetime(),
|
|
765
|
+
snoozedUntil: z5.string().datetime().optional(),
|
|
611
766
|
agentState: AgentStateSchema.default("idle"),
|
|
612
767
|
/** Whose action the item is waiting on: "you" = an agent asked you (the default,
|
|
613
768
|
* every agent→user notification); "agent" = you sent a request and it's awaiting the
|
|
614
769
|
* agent (held in the inbox until the agent replies on the thread). */
|
|
615
|
-
turn:
|
|
770
|
+
turn: z5.enum(["you", "agent"]).default("you"),
|
|
616
771
|
/** Hard error reason on an awaiting request (turn="agent") — the wake failed to reach
|
|
617
772
|
* the agent (provider-agnostic; set server-side). Absent = no hard error. Drives the inbox
|
|
618
773
|
* error badge + Retry. */
|
|
619
|
-
error:
|
|
774
|
+
error: z5.string().optional(),
|
|
620
775
|
/** WHEN THIS AGENT WORK WENT QUIET (turn="agent"), by the one rule (`coldSince`: three days
|
|
621
776
|
* with nothing said), or absent while it is not stalled. The inbox's stalled badge reads
|
|
622
777
|
* this and nothing else (2026-09-23: a 3-minute age rule badged every live Goal stalled,
|
|
623
778
|
* and "dismiss the stalled ones" cancelled 37 pieces of live work). */
|
|
624
|
-
cold:
|
|
625
|
-
clarifies:
|
|
779
|
+
cold: z5.string().datetime().optional(),
|
|
780
|
+
clarifies: z5.string().optional(),
|
|
626
781
|
/** THIS CARD'S QUESTION IS ON A LIVE CALL (owner, 2026-09-24: "Mark it while the call is
|
|
627
782
|
* live"). Present only while an open Call Delivery carries the card's request Entry — read
|
|
628
783
|
* off the same open list the card came from, so it clears when the Call does. A card is the
|
|
629
784
|
* backup for a call not taken; while the call has it, the call is where it is answered. */
|
|
630
|
-
onCall:
|
|
785
|
+
onCall: z5.literal(true).optional(),
|
|
631
786
|
/** THE RING, ON THE ITEM (docs/clients/app/walk/design.md §12 §17, #2251): the last ring on this card was
|
|
632
787
|
* declined, and what the ladder will do next — read off the cron's own row, never computed
|
|
633
788
|
* on the phone. Present only while a `declined` receipt stands on the card's last Call.
|
|
@@ -637,31 +792,31 @@ var InboxItemSchema = z4.object({
|
|
|
637
792
|
* It replaced `gaveUp` (deleted 2026-09-22): "the ladder spent" was a boolean the projection
|
|
638
793
|
* never set, and it is `nextRingAt === null` here — the party's *Missed you* (`party/dress.ts`)
|
|
639
794
|
* and the roster's `unreached` read `declinedAt`, and stand while it does. */
|
|
640
|
-
ring:
|
|
641
|
-
declinedAt:
|
|
642
|
-
anchorAt:
|
|
643
|
-
nextRingAt:
|
|
644
|
-
step:
|
|
795
|
+
ring: z5.object({
|
|
796
|
+
declinedAt: z5.string().datetime(),
|
|
797
|
+
anchorAt: z5.string().datetime(),
|
|
798
|
+
nextRingAt: z5.string().datetime().nullable(),
|
|
799
|
+
step: z5.number().int()
|
|
645
800
|
}).optional(),
|
|
646
801
|
/** Why this arrived the way it did, read back off the delivery receipt (`notify/why.ts`).
|
|
647
802
|
* Absent for anything never delivered through a push, and for older rows written before
|
|
648
803
|
* the reason was recorded. Deliberately a debug affordance, shown small (owner,
|
|
649
804
|
* 2026-08-07) — its real job is to give "this didn't need a call" something to be
|
|
650
805
|
* feedback ABOUT. */
|
|
651
|
-
why:
|
|
806
|
+
why: z5.object({
|
|
652
807
|
asked: NotifyLevelSchema,
|
|
653
808
|
got: NotifyLevelSchema,
|
|
654
|
-
because:
|
|
655
|
-
line:
|
|
809
|
+
because: z5.enum(["unresponsive", "dismissed", "not_permitted", "silent", "coalesced", "agent_capped", "unplanned", "learned_raise"]).optional(),
|
|
810
|
+
line: z5.string()
|
|
656
811
|
}).optional(),
|
|
657
|
-
select:
|
|
658
|
-
confirmStyle:
|
|
812
|
+
select: z5.enum(["one", "many", "rank", "confirm", "text"]).default("one"),
|
|
813
|
+
confirmStyle: z5.enum(["yesno", "approve"]).default("yesno").describe(
|
|
659
814
|
"Labels for a select:'confirm' paige \u2014 'yesno' (Yes/No) or 'approve' (Approve/Deny). Ignored unless select is 'confirm'."
|
|
660
815
|
),
|
|
661
816
|
/** Real downstream work is stuck behind this one — set by the agent, independent of
|
|
662
817
|
* urgency (see the main README's "premier use case" + docs/delivery/notify/states.md). Drives the
|
|
663
818
|
* inbox's blocking badge and the extra confirm step before dismissing it. */
|
|
664
|
-
blocking:
|
|
819
|
+
blocking: z5.boolean().default(false),
|
|
665
820
|
/** The user's locked-in answer; present only for replied items (GET /api/replied/:id). */
|
|
666
821
|
answer: UserAnswerSchema.optional(),
|
|
667
822
|
/** THE TARGET FACTS A CARD RENDERS (#1796 point 5, 2026-09-11): the Delivery it is a view of,
|
|
@@ -669,38 +824,49 @@ var InboxItemSchema = z4.object({
|
|
|
669
824
|
* for a request that asks nothing), whether its content is sealed, and that Goal's state. The
|
|
670
825
|
* answer writer (`POST /api/entries`) and the disposition (`close_delivery`) take their ids from
|
|
671
826
|
* here. The server projects it (`apps/api/src/inbox/project.ts`); a client never builds it. */
|
|
672
|
-
communication:
|
|
673
|
-
deliveryId:
|
|
674
|
-
kind:
|
|
675
|
-
entryId:
|
|
676
|
-
goalIds:
|
|
677
|
-
decisionNeedId:
|
|
678
|
-
sealed:
|
|
679
|
-
goalState:
|
|
827
|
+
communication: z5.object({
|
|
828
|
+
deliveryId: z5.string(),
|
|
829
|
+
kind: z5.enum(["notification", "call"]),
|
|
830
|
+
entryId: z5.string(),
|
|
831
|
+
goalIds: z5.array(z5.string()),
|
|
832
|
+
decisionNeedId: z5.string().optional(),
|
|
833
|
+
sealed: z5.boolean(),
|
|
834
|
+
goalState: z5.string().optional(),
|
|
680
835
|
/** THAT GOAL'S NAME (#2416) — what Activity's row is headed by, since a row there is one Goal
|
|
681
836
|
* and the cards it holds sit behind it. Stamped by the same read as `goalState`. */
|
|
682
|
-
goalTitle:
|
|
683
|
-
}).optional()
|
|
837
|
+
goalTitle: z5.string().optional()
|
|
838
|
+
}).optional(),
|
|
839
|
+
/** WHAT THIS CARD IS, IN TWELVE CHARACTERS (#3019) — the hash of every other field on it, stamped
|
|
840
|
+
* by the one read that serves the open list (`apps/api/src/inbox/project.ts` `inboxFor`). It is
|
|
841
|
+
* how the incremental read knows a card has not moved: the phone echoes back the revs it holds
|
|
842
|
+
* (`POST /api/inbox/changes`) and is sent only the cards whose rev differs.
|
|
843
|
+
*
|
|
844
|
+
* THE PAYLOAD'S OWN HASH, NEVER A STAMP ON THE WORK — the same mechanism as `QueueItem.rev`
|
|
845
|
+
* (#2928) and an entry's (#3018), for the same reason: a card shows facts no `updated_at` of its
|
|
846
|
+
* own moves (its Goal's state and name, how cold the work behind it has gone, whether a ring is
|
|
847
|
+
* live). Optional, so a fixture, the demo and the archive lens need not spell one, and a card
|
|
848
|
+
* with no rev is simply always re-sent. */
|
|
849
|
+
rev: z5.string().optional()
|
|
684
850
|
});
|
|
685
851
|
var APNS_TOKEN_RE = /^[0-9a-fA-F]{64}$/;
|
|
686
|
-
var PushTokenSchema =
|
|
687
|
-
voipToken:
|
|
688
|
-
alertToken:
|
|
689
|
-
fcmToken:
|
|
690
|
-
platform:
|
|
852
|
+
var PushTokenSchema = z5.object({
|
|
853
|
+
voipToken: z5.string().min(1).optional(),
|
|
854
|
+
alertToken: z5.string().min(1).optional(),
|
|
855
|
+
fcmToken: z5.string().min(1).optional(),
|
|
856
|
+
platform: z5.enum(["ios", "android"])
|
|
691
857
|
}).superRefine((v, ctx) => {
|
|
692
858
|
if (v.platform !== "ios") return;
|
|
693
859
|
for (const field of ["voipToken", "alertToken"]) {
|
|
694
860
|
const token = v[field];
|
|
695
861
|
if (token === void 0 || APNS_TOKEN_RE.test(token)) continue;
|
|
696
862
|
ctx.addIssue({
|
|
697
|
-
code:
|
|
863
|
+
code: z5.ZodIssueCode.custom,
|
|
698
864
|
path: [field],
|
|
699
865
|
message: `not an APNs device token (want 64 hex chars, got ${token.length})`
|
|
700
866
|
});
|
|
701
867
|
}
|
|
702
868
|
});
|
|
703
|
-
var MissedCallSchema =
|
|
869
|
+
var MissedCallSchema = z5.enum([
|
|
704
870
|
"retry_10m",
|
|
705
871
|
"retry_30m",
|
|
706
872
|
"retry_60m",
|
|
@@ -712,31 +878,31 @@ var MissedCallSchema = z4.enum([
|
|
|
712
878
|
]);
|
|
713
879
|
var clock = (h) => h === 0 ? "midnight" : h === 12 ? "noon" : h < 12 ? `${h} am` : `${h - 12} pm`;
|
|
714
880
|
var QUIET = ` Nothing rings from ${clock(NIGHT.from)} to ${clock(NIGHT.to)} your time; the count waits for morning.`;
|
|
715
|
-
var BrokerTuningSchema =
|
|
881
|
+
var BrokerTuningSchema = z5.object({
|
|
716
882
|
/** 'none' = skip the spoken ack after a mapped answer (power users find it slow). */
|
|
717
|
-
ackVerbosity:
|
|
883
|
+
ackVerbosity: z5.enum(["normal", "none"]).optional(),
|
|
718
884
|
/** How readily the mapper asks its one clarification: 'low' = only when truly
|
|
719
885
|
* uninterpretable, 'high' = whenever not fully certain. */
|
|
720
|
-
clarifyEagerness:
|
|
886
|
+
clarifyEagerness: z5.enum(["low", "normal", "high"]).optional(),
|
|
721
887
|
/** The user's own shorthand: when they say `say`, they mean `mean`. */
|
|
722
|
-
phrasebook:
|
|
888
|
+
phrasebook: z5.array(z5.object({ say: z5.string().min(1).max(60), mean: z5.string().min(1).max(120) })).max(24).optional(),
|
|
723
889
|
/** The language calls are PLANNED in, when the account has chosen one (#1272). Absent —
|
|
724
890
|
* which is every account today — means the agent's own words decide, per ask: a call
|
|
725
891
|
* about an English ask opens in English. This is the only thing that overrides that,
|
|
726
892
|
* and a live caller who switches language mid-call still outranks it (broker/lang.ts).
|
|
727
893
|
* Set per user (no UI yet), like `voiceTuning`. */
|
|
728
|
-
language:
|
|
894
|
+
language: z5.enum(["en", "es"]).optional()
|
|
729
895
|
});
|
|
730
|
-
var UserSettingsSchema =
|
|
731
|
-
permissions:
|
|
732
|
-
call:
|
|
733
|
-
banner:
|
|
734
|
-
push:
|
|
896
|
+
var UserSettingsSchema = z5.object({
|
|
897
|
+
permissions: z5.object({
|
|
898
|
+
call: z5.boolean(),
|
|
899
|
+
banner: z5.boolean(),
|
|
900
|
+
push: z5.boolean()
|
|
735
901
|
}),
|
|
736
902
|
/** LockedIn / Default / DateNight on screen; the stored words are unchanged on purpose —
|
|
737
903
|
* they are an enum on a live column across every account, and the rename is a rename of
|
|
738
904
|
* what people read (owner, 2026-09-30). */
|
|
739
|
-
sessionMode:
|
|
905
|
+
sessionMode: z5.enum(["default", "all_calls", "silent"]),
|
|
740
906
|
/** `silentPush` lived here until #2813 and is now GONE, field and column both. It was kept as an
|
|
741
907
|
* optional long after DateNight stopped reading it, on the theory that a phone on an older
|
|
742
908
|
* bundle PATCHing the whole settings object would be REFUSED for sending a key we had stopped
|
|
@@ -745,7 +911,7 @@ var UserSettingsSchema = z4.object({
|
|
|
745
911
|
* an old bundle's `silentPush` is accepted and ignored. Worth remembering before keeping the
|
|
746
912
|
* next dead field for the same reason. */
|
|
747
913
|
/** Opt-in (default false) to using your content to improve Paigy and train models. */
|
|
748
|
-
improveConsent:
|
|
914
|
+
improveConsent: z5.boolean(),
|
|
749
915
|
missedCall: MissedCallSchema.default("backoff_standard"),
|
|
750
916
|
/** Where voice audio is processed. 'hosted' (default) = Paigy's voice services
|
|
751
917
|
* (ElevenLabs TTS, faster-whisper STT, the call bot); 'on_device' = the phone
|
|
@@ -753,17 +919,17 @@ var UserSettingsSchema = z4.object({
|
|
|
753
919
|
* Optional, NOT defaulted: a stale client PATCHing the full settings object
|
|
754
920
|
* must not silently reset this privacy choice. Absent = leave unchanged on
|
|
755
921
|
* write, 'hosted' on read (see store.ts). */
|
|
756
|
-
voiceMode:
|
|
922
|
+
voiceMode: z5.enum(["hosted", "on_device"]).optional(),
|
|
757
923
|
/** Talk — after you answer, the next step is read aloud (docs/clients/app/walk/design.md §6). ALWAYS ON until
|
|
758
924
|
* turned off (owner, 2026-09-18, #2249): a setting, not a per-walk toggle. Optional, NOT
|
|
759
925
|
* defaulted, for the same reason `voiceMode` is: a stale client PATCHing the full settings
|
|
760
926
|
* object must not silently turn it back on. Absent = leave unchanged on write, true on
|
|
761
927
|
* read (see store.ts). */
|
|
762
|
-
talk:
|
|
928
|
+
talk: z5.boolean().optional(),
|
|
763
929
|
/** CALL DIAGNOSTICS (owner, 2026-10-01): the call report carries each listen and the bot's own
|
|
764
930
|
* load timings. SERVER-SET, no UI — on for every account that existed on 2026-10-01, off for
|
|
765
931
|
* newer ones (migration 20261001132859). Read-only here: the settings PATCH never writes it. */
|
|
766
|
-
callDiagnostics:
|
|
932
|
+
callDiagnostics: z5.boolean().optional(),
|
|
767
933
|
/** Per-user ring budget (#603): calls per rolling day before further calls
|
|
768
934
|
* degrade to banner. Absent = the global default (25). A number, never a
|
|
769
935
|
* bypass — every account keeps a ceiling. No UI; set per user for testing. */
|
|
@@ -771,7 +937,7 @@ var UserSettingsSchema = z4.object({
|
|
|
771
937
|
* payload['tuning'] (e.g. { silence_s: 3.5 } — a longer pause window for a
|
|
772
938
|
* slower speaker). No API-side semantics; the bot resolves each key with its
|
|
773
939
|
* own defaults. Set per user (no UI yet); absent = bot defaults. */
|
|
774
|
-
voiceTuning:
|
|
940
|
+
voiceTuning: z5.record(z5.string(), z5.union([z5.number(), z5.string()])).optional(),
|
|
775
941
|
/** The user's IANA timezone (e.g. "America/Bogota"), recorded by the app — it is the
|
|
776
942
|
* only party that knows it. REMINDERS are why it exists: "remind me at ten" becomes
|
|
777
943
|
* an absolute `due_at` only if we know whose ten. Optional and never defaulted, for
|
|
@@ -780,53 +946,53 @@ var UserSettingsSchema = z4.object({
|
|
|
780
946
|
* that failure reads as the reminder rail being unreliable rather than as a missing
|
|
781
947
|
* setting. Absent = a spoken time can't be landed, so the reminder rides the next
|
|
782
948
|
* call — honest about what we know. */
|
|
783
|
-
timezone:
|
|
949
|
+
timezone: z5.string().min(1).max(64).optional(),
|
|
784
950
|
/** Rung-2 broker tuning (#381). Optional and NOT defaulted, same stale-client
|
|
785
951
|
* clobber guard as voiceMode: absent = leave unchanged on write. */
|
|
786
952
|
broker: BrokerTuningSchema.optional()
|
|
787
953
|
});
|
|
788
|
-
var HistoryWorkSchema =
|
|
789
|
-
id:
|
|
790
|
-
title:
|
|
791
|
-
state:
|
|
954
|
+
var HistoryWorkSchema = z5.object({
|
|
955
|
+
id: z5.string(),
|
|
956
|
+
title: z5.string(),
|
|
957
|
+
state: z5.enum(["done", "cancelled"]),
|
|
792
958
|
/** Who held it (`agent:<tokenId>` or `human:<userId>`). */
|
|
793
|
-
assignee:
|
|
959
|
+
assignee: z5.string()
|
|
794
960
|
});
|
|
795
|
-
var HistoryEntrySchema =
|
|
796
|
-
|
|
797
|
-
|
|
961
|
+
var HistoryEntrySchema = z5.union([
|
|
962
|
+
z5.object({ at: z5.string(), card: InboxItemSchema }),
|
|
963
|
+
z5.object({ at: z5.string(), work: HistoryWorkSchema })
|
|
798
964
|
]);
|
|
799
|
-
var HistoryPageSchema =
|
|
800
|
-
entries:
|
|
801
|
-
next:
|
|
965
|
+
var HistoryPageSchema = z5.object({
|
|
966
|
+
entries: z5.array(HistoryEntrySchema),
|
|
967
|
+
next: z5.string().nullable()
|
|
802
968
|
});
|
|
803
969
|
var ACTIVITY_LINES = 2;
|
|
804
970
|
var ACTIVITY_LINE_MAX = 80;
|
|
805
|
-
var AgentActivitySchema =
|
|
971
|
+
var AgentActivitySchema = z5.object({
|
|
806
972
|
/** Oldest first, so the newest line is last — the one that replaces in place. */
|
|
807
|
-
lines:
|
|
973
|
+
lines: z5.array(z5.string().max(ACTIVITY_LINE_MAX)).max(ACTIVITY_LINES),
|
|
808
974
|
/** When the harness observed this tail. Its own timestamp, not the heartbeat's: a beat
|
|
809
975
|
* that carries an UNCHANGED tail must not make a stalled agent look like it just moved. */
|
|
810
|
-
at:
|
|
976
|
+
at: z5.string().datetime()
|
|
811
977
|
});
|
|
812
|
-
var ConnectionSummarySchema =
|
|
978
|
+
var ConnectionSummarySchema = z5.object({
|
|
813
979
|
/** The connection = the agent's token id (used to address a request). */
|
|
814
|
-
id:
|
|
980
|
+
id: z5.string(),
|
|
815
981
|
/** The credential kind: "device" = a paired machine (mint-only — it hosts and mints, it
|
|
816
982
|
* never talks); "agent" = an identity that sends. The roster and devices surfaces split
|
|
817
983
|
* on this. Optional/absent reads as "agent" (a row predating the kind column). See
|
|
818
984
|
* docs/server/tokens/devices-vs-agents-design.md. */
|
|
819
|
-
kind:
|
|
985
|
+
kind: z5.enum(["device", "agent"]).optional(),
|
|
820
986
|
/** For an agent, the token id of the DEVICE that minted it — so agents group under their
|
|
821
987
|
* machine, and revoking a device cascades to them. Null on devices, and on unlinked
|
|
822
988
|
* agents (phone-launched, provider-managed, or minted before the link existed). */
|
|
823
|
-
mintedByDevice:
|
|
824
|
-
device:
|
|
989
|
+
mintedByDevice: z5.string().nullable().optional(),
|
|
990
|
+
device: z5.string().nullable(),
|
|
825
991
|
/** The agent's display name (the single pairing name). */
|
|
826
|
-
name:
|
|
992
|
+
name: z5.string(),
|
|
827
993
|
/** For a managed connection, the provider key (e.g. "cma") that agentOrigin maps to a
|
|
828
994
|
* label; null for a local connection. Sourced from the token's provider, not the name. */
|
|
829
|
-
provider:
|
|
995
|
+
provider: z5.string().nullable(),
|
|
830
996
|
/** The pairing's assigned voice (#462); null = the default voice. */
|
|
831
997
|
voice: VoiceKeySchema.nullable(),
|
|
832
998
|
/** The LOUDEST this agent may ever reach you — a ceiling on `NOTIFY_LADDER`, set by the
|
|
@@ -837,34 +1003,34 @@ var ConnectionSummarySchema = z4.object({
|
|
|
837
1003
|
* every surface at once and outranks even `sessionMode: all_calls` — a mode the user
|
|
838
1004
|
* set once must not overrule a rule they set about one agent. */
|
|
839
1005
|
reach: NotifyLevelSchema.nullable().optional(),
|
|
840
|
-
createdAt:
|
|
1006
|
+
createdAt: z5.string().datetime(),
|
|
841
1007
|
/** Most recent notification on this connection, either direction. Null = no contact yet.
|
|
842
1008
|
* Drives the agents-page recency grouping (Today / This week / …). */
|
|
843
|
-
lastContactAt:
|
|
1009
|
+
lastContactAt: z5.string().datetime().nullable(),
|
|
844
1010
|
/** Last presence heartbeat from a running agent process (POST /api/presence) — the
|
|
845
1011
|
* desktop app while open. Null = never seen; stale = offline. */
|
|
846
|
-
lastSeenAt:
|
|
1012
|
+
lastSeenAt: z5.string().datetime().nullable().optional(),
|
|
847
1013
|
/** WORKING, NOT JUST CONNECTED (owner, 2026-09-30): the last time the agent itself acted on one of
|
|
848
1014
|
* its Goals — took its lease or recorded an operation (`tokens.last_worked_at`). Within
|
|
849
1015
|
* `WORKING_MS` it is working; otherwise it is connected but idle. Null = not seen working yet. */
|
|
850
|
-
lastWorkedAt:
|
|
1016
|
+
lastWorkedAt: z5.string().datetime().nullable().optional(),
|
|
851
1017
|
/** The oldest of its Goals that is `ready` for it — work handed to it that nobody has started.
|
|
852
1018
|
* With no work of its own for `WORKING_MS`, an agent sitting on this is not taking its work. */
|
|
853
|
-
oldestReadyAt:
|
|
1019
|
+
oldestReadyAt: z5.string().datetime().nullable().optional(),
|
|
854
1020
|
/** What a live desktop can run (docs/clients/desktop/companion.md §2.2), advertised on its heartbeat:
|
|
855
1021
|
* harness availabilities + granted workspaces — the option set the phone's
|
|
856
1022
|
* "new session" sheet offers. Absent for ordinary MCP agents. */
|
|
857
|
-
runtime:
|
|
1023
|
+
runtime: z5.object({
|
|
858
1024
|
/** The @paigy/harness this host is running — a machine the self-update has not reached
|
|
859
1025
|
* shows its age here (`apps/desktop/src/update.ts`). */
|
|
860
|
-
version:
|
|
861
|
-
harnesses:
|
|
862
|
-
workspaces:
|
|
1026
|
+
version: z5.string().optional(),
|
|
1027
|
+
harnesses: z5.array(z5.object({ name: z5.string(), label: z5.string(), status: z5.string() })).optional(),
|
|
1028
|
+
workspaces: z5.array(z5.string()).optional(),
|
|
863
1029
|
/** THE GIT REPOS IN THOSE FOLDERS (2026-10-01, Goal 26982211): each granted folder that is a
|
|
864
1030
|
* repo, and each repo directly inside one, with its `origin` remote. A session started for
|
|
865
1031
|
* work on `mauurda/paigy` opens in that repo rather than the folder above it, where the repo's
|
|
866
1032
|
* own AGENTS.md is never read (`workspaceForRepo`). Absent on hosts that predate it. */
|
|
867
|
-
repos:
|
|
1033
|
+
repos: z5.array(z5.object({ path: z5.string(), remote: z5.string() })).optional()
|
|
868
1034
|
}).optional(),
|
|
869
1035
|
/** The tail of this agent's working log, when a harness is driving it — the agent page's
|
|
870
1036
|
* live strip. Absent for anything the desktop harness isn't running (a hatched identity
|
|
@@ -873,173 +1039,156 @@ var ConnectionSummarySchema = z4.object({
|
|
|
873
1039
|
activity: AgentActivitySchema.optional(),
|
|
874
1040
|
/** True = a provider-managed agent running in the provider's cloud (e.g. Anthropic CMA);
|
|
875
1041
|
* false = a local MCP connection running on the user's computer (Claude Code/Codex/…). */
|
|
876
|
-
managed:
|
|
1042
|
+
managed: z5.boolean()
|
|
877
1043
|
});
|
|
878
|
-
var LedgerItemSchema =
|
|
879
|
-
var AgentLedgerSchema =
|
|
1044
|
+
var LedgerItemSchema = z5.object({ id: z5.string(), parentId: z5.string(), title: z5.string(), createdAt: z5.string() });
|
|
1045
|
+
var AgentLedgerSchema = z5.object({
|
|
880
1046
|
/** Null when the agent has not named itself yet — never a placeholder (owner, 2026-10-01). */
|
|
881
|
-
agent:
|
|
1047
|
+
agent: z5.object({ id: z5.string(), name: z5.string().nullable(), revokedAt: z5.string().nullable() }),
|
|
882
1048
|
/** Its own questions you have not answered. */
|
|
883
|
-
asks:
|
|
1049
|
+
asks: z5.array(LedgerItemSchema),
|
|
884
1050
|
/** Its questions you answered that nobody acted on — still owed to somebody. */
|
|
885
|
-
answered:
|
|
1051
|
+
answered: z5.array(LedgerItemSchema),
|
|
886
1052
|
/** Requests you sent it that it never took. */
|
|
887
|
-
requests:
|
|
888
|
-
goals:
|
|
889
|
-
callbacks:
|
|
1053
|
+
requests: z5.array(LedgerItemSchema),
|
|
1054
|
+
goals: z5.array(z5.object({ id: z5.string(), outcome: z5.string(), state: z5.string() })),
|
|
1055
|
+
callbacks: z5.array(z5.object({ id: z5.string(), parentId: z5.string(), trigger: z5.string(), note: z5.string(), dueAt: z5.string().nullable() }))
|
|
890
1056
|
});
|
|
891
|
-
var ReassignResultSchema =
|
|
892
|
-
moved:
|
|
893
|
-
parentId:
|
|
1057
|
+
var ReassignResultSchema = z5.object({
|
|
1058
|
+
moved: z5.object({ asks: z5.number(), answered: z5.number(), requests: z5.number(), goals: z5.number(), callbacks: z5.number() }),
|
|
1059
|
+
parentId: z5.string().nullable()
|
|
894
1060
|
});
|
|
895
|
-
var
|
|
896
|
-
var
|
|
897
|
-
id:
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
/** The
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
/**
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
* break is visible instead of a pin silently disappearing. */
|
|
912
|
-
pinBroken: z4.boolean(),
|
|
913
|
-
/** When the ruling was distilled. */
|
|
914
|
-
learnedAt: z4.string(),
|
|
915
|
-
/** Last time it answered an ask. Null = never fired. */
|
|
916
|
-
lastUsedAt: z4.string().nullable(),
|
|
917
|
-
/** How many asks it has answered. Instrumentation — deliberately NOT an input to the
|
|
918
|
-
* evidence curve: firing says the question keeps arising, not that the ruling is right. */
|
|
919
|
-
usedCount: z4.number(),
|
|
920
|
-
/** Ledger: outcomes that said it held up. Saturating — the tenth is worth almost nothing. */
|
|
921
|
-
confirms: z4.number(),
|
|
922
|
-
/** Ledger: contradictions, in signal units (a full override = 1, weaker signals less).
|
|
923
|
-
* Linear and priced above the entire confirmation budget, so any full counter wins. */
|
|
924
|
-
counters: z4.number(),
|
|
925
|
-
/** The agent that asked the question this move came from, when known. Null for a move
|
|
926
|
-
* distilled from a clarify ruling (those carry no agent) or one whose source rows are gone. */
|
|
927
|
-
learnedFrom: z4.object({ id: z4.string(), name: z4.string() }).nullable()
|
|
1061
|
+
var LessonStateSchema = z5.enum(["active", "proposed", "retired"]);
|
|
1062
|
+
var LessonViewSchema = z5.object({
|
|
1063
|
+
id: z5.string(),
|
|
1064
|
+
text: z5.string(),
|
|
1065
|
+
state: LessonStateSchema,
|
|
1066
|
+
/** The Goal it is scoped to; null = the whole account. */
|
|
1067
|
+
scopeGoalId: z5.string().nullable(),
|
|
1068
|
+
goalTitle: z5.string().nullable(),
|
|
1069
|
+
version: z5.number(),
|
|
1070
|
+
pinned: z5.boolean(),
|
|
1071
|
+
/** When the person last wrote its text themselves. */
|
|
1072
|
+
editedAt: z5.string().nullable(),
|
|
1073
|
+
createdAt: z5.string(),
|
|
1074
|
+
updatedAt: z5.string(),
|
|
1075
|
+
/** The Entries it came from, oldest first; `words` is null when an Entry has none to show (sealed). */
|
|
1076
|
+
sources: z5.array(z5.object({ entryId: z5.string(), words: z5.string().nullable(), at: z5.string() }))
|
|
928
1077
|
});
|
|
929
|
-
var QueueQuestionSchema =
|
|
1078
|
+
var QueueQuestionSchema = z5.object({
|
|
930
1079
|
/** The decision need's id — what an answer is accepted against. */
|
|
931
|
-
id:
|
|
1080
|
+
id: z5.string(),
|
|
932
1081
|
/** The words that were asked, from the request Entry that asked them. */
|
|
933
|
-
question:
|
|
1082
|
+
question: z5.string(),
|
|
934
1083
|
/** Where it was asked — which is where the ruling goes (`POST /api/entries`). Null only
|
|
935
1084
|
* for a need whose request Entry is carried by no interactive Delivery, which nothing
|
|
936
1085
|
* can answer. */
|
|
937
|
-
deliveryId:
|
|
1086
|
+
deliveryId: z5.string().nullable().default(null),
|
|
938
1087
|
/** The Entry the ruling is about. */
|
|
939
|
-
aboutId:
|
|
1088
|
+
aboutId: z5.string().nullable().default(null),
|
|
940
1089
|
/** Empty for a free-text question. */
|
|
941
|
-
options:
|
|
942
|
-
select:
|
|
943
|
-
askedAt:
|
|
1090
|
+
options: z5.array(OptionSchema).default([]),
|
|
1091
|
+
select: z5.enum(["one", "many", "rank", "confirm", "text"]).default("text"),
|
|
1092
|
+
askedAt: z5.string(),
|
|
944
1093
|
/** Null while the question is open — which is how the page tells the two apart. */
|
|
945
|
-
answeredAt:
|
|
1094
|
+
answeredAt: z5.string().nullable().default(null),
|
|
946
1095
|
/** The ruling in the person's own words, from the contribution that replied — not the
|
|
947
1096
|
* option id, which is not something anyone reads back. Null while it is open, and null
|
|
948
1097
|
* for a settled question whose reply carried nothing readable. */
|
|
949
|
-
answer:
|
|
1098
|
+
answer: z5.string().nullable().default(null),
|
|
950
1099
|
/** The Goal this question belongs to — a step knows its Goal on its own, not only through
|
|
951
1100
|
* an `InboxItem`'s `communication.goalIds[0]` (docs/clients/app/walk/design.md §12 item 3).
|
|
952
1101
|
* READ BY `apps/client/src/walk/order.ts`, which stamps it onto every `WalkStep`: the walk's
|
|
953
1102
|
* order, its route, home's trees and the list of steps all take a step's Goal from here, so
|
|
954
1103
|
* this is the field they agree through rather than each re-deriving it from the row it
|
|
955
1104
|
* arrived under. Required because the API projects it on every need it sends. */
|
|
956
|
-
goalId:
|
|
1105
|
+
goalId: z5.string(),
|
|
957
1106
|
/** True only while an unmet START gate holds the Goal — a Goal that merely waits to
|
|
958
1107
|
* *finish* does not stop a person from answering (owner, 2026-09-16: "per need gate from
|
|
959
1108
|
* the API"; §4's dashed node). Not the same fact as `QueueItem.blocked`, which counts any
|
|
960
1109
|
* gate at all. */
|
|
961
|
-
blocked:
|
|
1110
|
+
blocked: z5.boolean().default(false)
|
|
962
1111
|
});
|
|
963
|
-
var QueueReplySchema =
|
|
1112
|
+
var QueueReplySchema = z5.object({
|
|
964
1113
|
/** The card this note was (`deliveryId:requestEntryId`, minted by the server like every card
|
|
965
1114
|
* id) — so the phone can tell a reply it just sent from one the queue already carries, and the
|
|
966
1115
|
* walk can name it in its zoom. */
|
|
967
|
-
id:
|
|
1116
|
+
id: z5.string(),
|
|
968
1117
|
/** The Goal the note is on. */
|
|
969
|
-
goalId:
|
|
1118
|
+
goalId: z5.string(),
|
|
970
1119
|
/** What the note said. */
|
|
971
|
-
note:
|
|
1120
|
+
note: z5.string(),
|
|
972
1121
|
/** Where it was carried — where a second reply goes (`POST /api/entries`, #2252). */
|
|
973
|
-
deliveryId:
|
|
974
|
-
requestEntryId:
|
|
975
|
-
askedAt:
|
|
1122
|
+
deliveryId: z5.string(),
|
|
1123
|
+
requestEntryId: z5.string(),
|
|
1124
|
+
askedAt: z5.string(),
|
|
976
1125
|
/** When the person last replied — the window's start. */
|
|
977
|
-
repliedAt:
|
|
1126
|
+
repliedAt: z5.string(),
|
|
978
1127
|
/** The person's latest words about it; null when there is nothing readable in them. */
|
|
979
|
-
reply:
|
|
1128
|
+
reply: z5.string().nullable()
|
|
980
1129
|
});
|
|
981
|
-
var QueueItemSchema =
|
|
982
|
-
id:
|
|
1130
|
+
var QueueItemSchema = z5.object({
|
|
1131
|
+
id: z5.string(),
|
|
983
1132
|
/** One-line headline — the first sentence of the outcome. */
|
|
984
|
-
title:
|
|
1133
|
+
title: z5.string(),
|
|
985
1134
|
/** The outcome in full, verbatim: the person's own words are what an assignee sees. */
|
|
986
|
-
intent:
|
|
1135
|
+
intent: z5.string(),
|
|
987
1136
|
/** `ready` | `active` | `waiting` | `done` | `cancelled`, straight off the Goal. */
|
|
988
|
-
state:
|
|
1137
|
+
state: z5.string(),
|
|
989
1138
|
/** Who holds it (a participant ref); null when nobody does yet. */
|
|
990
|
-
assignee:
|
|
1139
|
+
assignee: z5.string().nullable().default(null),
|
|
991
1140
|
/** What the agent last said it was doing; null if it has said nothing. */
|
|
992
|
-
progress:
|
|
1141
|
+
progress: z5.string().nullable().default(null),
|
|
993
1142
|
/** HOME'S LINE FOR THAT NOTE (owner, 2026-09-23): a few plain words one read wrote from `progress`,
|
|
994
1143
|
* served only while it was written for the current note. Null means show the Goal's name. */
|
|
995
|
-
progressLine:
|
|
996
|
-
reviewPending:
|
|
997
|
-
dueAt:
|
|
1144
|
+
progressLine: z5.string().nullable().optional(),
|
|
1145
|
+
reviewPending: z5.boolean().default(false),
|
|
1146
|
+
dueAt: z5.string().nullable().default(null),
|
|
998
1147
|
/** WHEN ITS OWNER SAID DONE WHILE CHILDREN WERE OPEN (#2704): its own work is finished and it closes
|
|
999
1148
|
* with its last open child. Null otherwise; optional, so hand-built queues need not spell it. */
|
|
1000
|
-
finishedAt:
|
|
1149
|
+
finishedAt: z5.string().nullable().optional(),
|
|
1001
1150
|
/** The Goal this one was opened under; null at the root. */
|
|
1002
|
-
parentGoalId:
|
|
1151
|
+
parentGoalId: z5.string().nullable().default(null),
|
|
1003
1152
|
/** Goals opened under this one — only those the same list holds. */
|
|
1004
|
-
childGoalIds:
|
|
1153
|
+
childGoalIds: z5.array(z5.string()).default([]),
|
|
1005
1154
|
/** Goals this one waits on (start or finish gates). */
|
|
1006
|
-
dependencyGoalIds:
|
|
1155
|
+
dependencyGoalIds: z5.array(z5.string()).default([]),
|
|
1007
1156
|
/** True while any gate is on a Goal that is not done — the walk draws it dashed. */
|
|
1008
|
-
blocked:
|
|
1157
|
+
blocked: z5.boolean().default(false),
|
|
1009
1158
|
/** Its questions: every OPEN one, and at most ten settled, newest settled first
|
|
1010
1159
|
* (20260929133308) — the page decides which of them to show. NOT the whole set: `asked` and
|
|
1011
1160
|
* `answered` are, and a settled one's words are a line (280 characters), its body read when the
|
|
1012
1161
|
* question is opened. */
|
|
1013
|
-
questions:
|
|
1162
|
+
questions: z5.array(QueueQuestionSchema).default([]),
|
|
1014
1163
|
/** HOW MANY QUESTIONS THIS WORK HAS ASKED, and how many are answered — the Goal's own totals,
|
|
1015
1164
|
* bounded at 100 server-side. A tally counted off `questions` is a wrong number that looks
|
|
1016
1165
|
* right once the cap bites (`walk/trees.ts` `tallyOf`). Optional, and defaulted from the array
|
|
1017
1166
|
* by the projection, so hand-built queues (fixtures, the demo) need not spell them. */
|
|
1018
|
-
asked:
|
|
1019
|
-
answered:
|
|
1167
|
+
asked: z5.number().optional(),
|
|
1168
|
+
answered: z5.number().optional(),
|
|
1020
1169
|
/** Every note on it the person replied to (`QueueReplySchema`) — the page decides which to show.
|
|
1021
1170
|
* Optional, not defaulted: absent is none, and every hand-built queue (fixtures, the demo) need
|
|
1022
1171
|
* not spell an empty list. */
|
|
1023
|
-
replies:
|
|
1172
|
+
replies: z5.array(QueueReplySchema).optional(),
|
|
1024
1173
|
/** The repository or project identifier this Goal belongs to (#2280), null if untracked. */
|
|
1025
|
-
repo:
|
|
1026
|
-
createdAt:
|
|
1027
|
-
updatedAt:
|
|
1174
|
+
repo: z5.string().nullable().optional(),
|
|
1175
|
+
createdAt: z5.string(),
|
|
1176
|
+
updatedAt: z5.string().nullable().default(null),
|
|
1028
1177
|
/** When its owner last SAID something about it (`goals.last_progress_at`, written by every
|
|
1029
1178
|
* `update_goal` that changes `progress`). `updatedAt` moves for reasons nobody chose — a
|
|
1030
1179
|
* state recomputed, a review flag — so it cannot tell work in hand from work gone quiet. */
|
|
1031
|
-
lastProgressAt:
|
|
1180
|
+
lastProgressAt: z5.string().nullable().optional(),
|
|
1032
1181
|
/** THE GOAL'S NEWEST WORD, FROM EITHER SIDE (owner, 2026-09-27): the newest Entry on it, of any
|
|
1033
1182
|
* kind — what the person added ("Add to this"), their reply, the agent's ask or its progress
|
|
1034
1183
|
* note. A progress note is an Entry, so this is already the newer of the two: the person's note
|
|
1035
1184
|
* shows the moment it is written, and the agent's reply or next note replaces it by being newer.
|
|
1036
1185
|
* `said` is bounded to 280 characters server-side (a line, not the conversation). Null when the
|
|
1037
1186
|
* Goal carries no readable Entry; optional, so hand-built queues need not spell it. */
|
|
1038
|
-
latest:
|
|
1039
|
-
from:
|
|
1040
|
-
said:
|
|
1041
|
-
at:
|
|
1042
|
-
entryId:
|
|
1187
|
+
latest: z5.object({
|
|
1188
|
+
from: z5.enum(["person", "agent"]),
|
|
1189
|
+
said: z5.string(),
|
|
1190
|
+
at: z5.string(),
|
|
1191
|
+
entryId: z5.string()
|
|
1043
1192
|
}).nullable().optional(),
|
|
1044
1193
|
/** WHEN THIS PERSON LAST PUT A HAND ON IT THEMSELVES (owner, Paigy Goal 16d18f51, 2026-09-30):
|
|
1045
1194
|
* the newest Entry on the Goal they wrote, of any kind — a line they added, a reply to a note, an
|
|
@@ -1052,36 +1201,51 @@ var QueueItemSchema = z4.object({
|
|
|
1052
1201
|
* minute after the person speaks erases their instant from it, and the durable traces the client
|
|
1053
1202
|
* can see (`replies`, `questions[].answeredAt`) miss a spontaneous note entirely — a `request`
|
|
1054
1203
|
* Entry with no `about_id` is in neither. */
|
|
1055
|
-
lastPersonAt:
|
|
1204
|
+
lastPersonAt: z5.string().nullable().optional(),
|
|
1205
|
+
/** WHAT THIS ROW IS, IN TWELVE CHARACTERS (#2928) — the hash of every other field on it, stamped
|
|
1206
|
+
* by the one projection that builds the row (`apps/api/src/goal/queue.ts`). It is how the
|
|
1207
|
+
* incremental read knows a row has not moved: the phone echoes back the revs it holds
|
|
1208
|
+
* (`POST /api/goals/changes`) and is sent only the rows whose rev differs.
|
|
1209
|
+
*
|
|
1210
|
+
* IT IS THE PAYLOAD'S OWN HASH, NEVER A STAMP ON THE WORK. Nothing here reasons about which
|
|
1211
|
+
* writes change which field — the comparison is over the bytes the phone is holding, so a fact
|
|
1212
|
+
* the row shows that no `updated_at` moves for (a lease lapsing, a dependency's state, a
|
|
1213
|
+
* sibling appearing in `childGoalIds`) cannot go unnoticed. Optional because a hand-built
|
|
1214
|
+
* queue (a fixture, the demo) spells none, and a row with no rev is simply always re-sent. */
|
|
1215
|
+
rev: z5.string().optional()
|
|
1216
|
+
});
|
|
1217
|
+
var QueueDeltaSchema = z5.object({
|
|
1218
|
+
ids: z5.array(z5.string()),
|
|
1219
|
+
items: z5.array(QueueItemSchema)
|
|
1056
1220
|
});
|
|
1057
1221
|
var COLD_AFTER_MS = 3 * 24 * 60 * 60 * 1e3;
|
|
1058
|
-
var NoteSourceSchema =
|
|
1059
|
-
var NoteStatusSchema =
|
|
1060
|
-
var NoteRepeatSchema =
|
|
1061
|
-
var DecisionSchema =
|
|
1062
|
-
id:
|
|
1222
|
+
var NoteSourceSchema = z5.enum(["app", "call"]);
|
|
1223
|
+
var NoteStatusSchema = z5.enum(["open", "assigned", "in_progress", "done"]);
|
|
1224
|
+
var NoteRepeatSchema = z5.enum(["once", "until_done"]);
|
|
1225
|
+
var DecisionSchema = z5.object({
|
|
1226
|
+
id: z5.string(),
|
|
1063
1227
|
/** The note this decision refines; null = recorded on a bare thread (the
|
|
1064
1228
|
* extensibility seam — any conversation can accrue decisions). */
|
|
1065
|
-
noteId:
|
|
1229
|
+
noteId: z5.string().nullable(),
|
|
1066
1230
|
/** What was ambiguous — the broker's (or the user's own) question. */
|
|
1067
|
-
question:
|
|
1231
|
+
question: z5.string(),
|
|
1068
1232
|
/** The user's ruling; null while the question is open. */
|
|
1069
|
-
answer:
|
|
1070
|
-
decidedAt:
|
|
1071
|
-
createdAt:
|
|
1233
|
+
answer: z5.string().nullable(),
|
|
1234
|
+
decidedAt: z5.string().nullable(),
|
|
1235
|
+
createdAt: z5.string()
|
|
1072
1236
|
});
|
|
1073
|
-
var NoteSchema =
|
|
1074
|
-
id:
|
|
1237
|
+
var NoteSchema = z5.object({
|
|
1238
|
+
id: z5.string(),
|
|
1075
1239
|
/** One-line headline (broker-titled; deterministic floor). */
|
|
1076
|
-
title:
|
|
1240
|
+
title: z5.string(),
|
|
1077
1241
|
/** The original intent, verbatim — assignees always see the user's own words. */
|
|
1078
|
-
intent:
|
|
1242
|
+
intent: z5.string(),
|
|
1079
1243
|
source: NoteSourceSchema,
|
|
1080
1244
|
status: NoteStatusSchema,
|
|
1081
1245
|
/** Who it was assigned to (a participant ref, 'agent:<tokenId>'); null = unassigned. */
|
|
1082
|
-
assignee:
|
|
1246
|
+
assignee: z5.string().nullable(),
|
|
1083
1247
|
/** The request thread minted at assignment; null until assigned. */
|
|
1084
|
-
parentId:
|
|
1248
|
+
parentId: z5.string().nullable(),
|
|
1085
1249
|
/** REMINDERS (docs/model/notes/reminders-design.md): the NOT-BEFORE this becomes eligible to ride a
|
|
1086
1250
|
* call — never a deadline. It only ever comes from the user's own words, so when it
|
|
1087
1251
|
* passes Paigy rings ONCE (#1293, owner 2026-08-26: a time said out loud is consent to
|
|
@@ -1090,147 +1254,152 @@ var NoteSchema = z4.object({
|
|
|
1090
1254
|
// Defaulted, not required: a Note from an API deploy older than the reminders
|
|
1091
1255
|
// migration has none of these, and the defaults ARE what it means — no not-before,
|
|
1092
1256
|
// one ride, never ridden. Parsing must not fail across a rolling deploy.
|
|
1093
|
-
dueAt:
|
|
1257
|
+
dueAt: z5.string().nullable().default(null),
|
|
1094
1258
|
repeat: NoteRepeatSchema.default("once"),
|
|
1095
1259
|
/** How many calls have already carried it — the fatigue cap counts rides, not days. */
|
|
1096
|
-
rides:
|
|
1097
|
-
lastRideAt:
|
|
1098
|
-
createdAt:
|
|
1260
|
+
rides: z5.number().int().default(0),
|
|
1261
|
+
lastRideAt: z5.string().nullable().default(null),
|
|
1262
|
+
createdAt: z5.string()
|
|
1099
1263
|
});
|
|
1100
|
-
var TriageItemSchema =
|
|
1101
|
-
noteId:
|
|
1264
|
+
var TriageItemSchema = z5.object({
|
|
1265
|
+
noteId: z5.string(),
|
|
1102
1266
|
/** The note's headline at run time. */
|
|
1103
|
-
title:
|
|
1267
|
+
title: z5.string(),
|
|
1104
1268
|
/** WHY, in one short human line, evidence first — this is read on a phone underneath
|
|
1105
1269
|
* the note's title: "no movement in 34 days", "worked 3 notes in this repo this week".
|
|
1106
1270
|
* Never a model's reasoning transcript, never an id. */
|
|
1107
|
-
why:
|
|
1271
|
+
why: z5.string()
|
|
1108
1272
|
});
|
|
1109
|
-
var TriageAssignmentSchema =
|
|
1273
|
+
var TriageAssignmentSchema = z5.object({
|
|
1110
1274
|
/** The agent's token id — what `dispatchNote` resolves and what a request is addressed to. */
|
|
1111
|
-
agent:
|
|
1275
|
+
agent: z5.string(),
|
|
1112
1276
|
/** Its display name at run time (the name on the hatchling's card). Denormalized for the
|
|
1113
1277
|
* same reason as `title`: the card must render from the proposal alone. */
|
|
1114
|
-
agentName:
|
|
1115
|
-
notes:
|
|
1278
|
+
agentName: z5.string(),
|
|
1279
|
+
notes: z5.array(TriageItemSchema)
|
|
1116
1280
|
});
|
|
1117
|
-
var TriageStatusSchema =
|
|
1118
|
-
var SubmitTriageSchema =
|
|
1281
|
+
var TriageStatusSchema = z5.enum(["open", "superseded", "dismissed"]);
|
|
1282
|
+
var SubmitTriageSchema = z5.object({
|
|
1119
1283
|
/** Which runtime judged: "ollama" (inference never left the machine) or a harness the
|
|
1120
1284
|
* user already runs under their own credentials ("claude" / "codex" / "agy"). Recorded
|
|
1121
1285
|
* so the phone can say where the content went — an unattributed privacy claim is worth
|
|
1122
1286
|
* nothing, and #1106's promise is precisely "Paigy's servers never see this". */
|
|
1123
|
-
provider:
|
|
1287
|
+
provider: z5.string().min(1).max(60),
|
|
1124
1288
|
/** The concrete model when the provider names one (an ollama tag); null otherwise. */
|
|
1125
|
-
model:
|
|
1289
|
+
model: z5.string().max(200).nullable().optional(),
|
|
1126
1290
|
/** How many open notes the run actually looked at — the denominator on the phone
|
|
1127
1291
|
* ("6 of 50"), and the honest answer to "did it read the whole queue?". */
|
|
1128
|
-
reviewed:
|
|
1129
|
-
close:
|
|
1130
|
-
stale:
|
|
1131
|
-
assign:
|
|
1292
|
+
reviewed: z5.number().int().min(0).max(1e4).default(0),
|
|
1293
|
+
close: z5.array(TriageItemSchema).max(200).default([]),
|
|
1294
|
+
stale: z5.array(TriageItemSchema).max(200).default([]),
|
|
1295
|
+
assign: z5.array(TriageAssignmentSchema).max(50).default([])
|
|
1132
1296
|
});
|
|
1133
1297
|
var TriageProposalSchema = SubmitTriageSchema.extend({
|
|
1134
|
-
id:
|
|
1135
|
-
runAt:
|
|
1298
|
+
id: z5.string(),
|
|
1299
|
+
runAt: z5.string(),
|
|
1136
1300
|
status: TriageStatusSchema,
|
|
1137
|
-
model:
|
|
1301
|
+
model: z5.string().nullable().default(null)
|
|
1138
1302
|
});
|
|
1139
|
-
var AcceptTriageSchema =
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
group:
|
|
1144
|
-
agent:
|
|
1145
|
-
noteIds:
|
|
1303
|
+
var AcceptTriageSchema = z5.discriminatedUnion("group", [
|
|
1304
|
+
z5.object({ group: z5.literal("close"), noteIds: z5.array(z5.string()).max(200).optional() }),
|
|
1305
|
+
z5.object({ group: z5.literal("stale"), noteIds: z5.array(z5.string()).max(200).optional() }),
|
|
1306
|
+
z5.object({
|
|
1307
|
+
group: z5.literal("assign"),
|
|
1308
|
+
agent: z5.string().min(1),
|
|
1309
|
+
noteIds: z5.array(z5.string()).max(200).optional()
|
|
1146
1310
|
})
|
|
1147
1311
|
]);
|
|
1148
|
-
var AcceptTriageResultSchema =
|
|
1149
|
-
accepted:
|
|
1150
|
-
failed:
|
|
1312
|
+
var AcceptTriageResultSchema = z5.object({
|
|
1313
|
+
accepted: z5.array(z5.string()),
|
|
1314
|
+
failed: z5.array(z5.object({ noteId: z5.string(), reason: z5.string() }))
|
|
1151
1315
|
});
|
|
1152
|
-
var DeliveryModeSchema =
|
|
1153
|
-
var RegisterDeliverySchema =
|
|
1154
|
-
var OAuthStartSchema =
|
|
1155
|
-
provider:
|
|
1156
|
-
returnTo:
|
|
1316
|
+
var DeliveryModeSchema = z5.enum(["poll", "self_hosted"]);
|
|
1317
|
+
var RegisterDeliverySchema = z5.object({ mode: DeliveryModeSchema });
|
|
1318
|
+
var OAuthStartSchema = z5.object({
|
|
1319
|
+
provider: z5.enum(["cma"]),
|
|
1320
|
+
returnTo: z5.string().min(1)
|
|
1157
1321
|
});
|
|
1158
|
-
var DeliveryConfigSchema =
|
|
1159
|
-
tokenId:
|
|
1322
|
+
var DeliveryConfigSchema = z5.object({
|
|
1323
|
+
tokenId: z5.string(),
|
|
1160
1324
|
mode: DeliveryModeSchema,
|
|
1161
1325
|
/** null when the deployment has no anon key configured. `self_hosted` is then REFUSED
|
|
1162
1326
|
* (503 `self_hosted_unavailable`) rather than registered, so a self_hosted config always
|
|
1163
1327
|
* carries credentials; only a `poll` registration can come back with null here. */
|
|
1164
|
-
realtime:
|
|
1328
|
+
realtime: z5.object({ url: z5.string(), anonKey: z5.string() }).nullable()
|
|
1165
1329
|
});
|
|
1166
|
-
var HostDecisionSchema =
|
|
1330
|
+
var HostDecisionSchema = z5.object({
|
|
1167
1331
|
/** The agent's token id: the row's `recipient`. */
|
|
1168
|
-
agent:
|
|
1169
|
-
decision:
|
|
1332
|
+
agent: z5.string().uuid(),
|
|
1333
|
+
decision: z5.enum(["stood_back", "took_over"]),
|
|
1170
1334
|
/** The work it was about: the Goal `claim_goal` would hand that agent next. */
|
|
1171
|
-
goalId:
|
|
1335
|
+
goalId: z5.string().uuid().nullable().optional(),
|
|
1172
1336
|
/** When the server last heard from the agent, as the host read it: the presence it stood back for. */
|
|
1173
|
-
seenAt:
|
|
1337
|
+
seenAt: z5.string().datetime().nullable().optional(),
|
|
1174
1338
|
/** When that work last moved (`claimable.since` on `check_replies`), the fact the bound is judged on. */
|
|
1175
|
-
since:
|
|
1339
|
+
since: z5.string().datetime().nullable().optional(),
|
|
1176
1340
|
/** What the host said, in its log's own words: why it stood back, or what the take-over did. */
|
|
1177
|
-
said:
|
|
1341
|
+
said: z5.string().max(300).optional()
|
|
1178
1342
|
});
|
|
1179
|
-
var WakeNudgeSchema =
|
|
1180
|
-
kind:
|
|
1181
|
-
notificationId:
|
|
1182
|
-
parentId:
|
|
1343
|
+
var WakeNudgeSchema = z5.object({
|
|
1344
|
+
kind: z5.enum(["reply", "request", "callback"]),
|
|
1345
|
+
notificationId: z5.string().optional(),
|
|
1346
|
+
parentId: z5.string()
|
|
1183
1347
|
});
|
|
1184
|
-
var PairingStatusSchema =
|
|
1185
|
-
var DeviceCodeSchema =
|
|
1186
|
-
device_code:
|
|
1187
|
-
user_code:
|
|
1188
|
-
verification_uri:
|
|
1189
|
-
verification_uri_complete:
|
|
1190
|
-
interval:
|
|
1191
|
-
expires_in:
|
|
1348
|
+
var PairingStatusSchema = z5.enum(["pending", "approved", "denied", "expired"]);
|
|
1349
|
+
var DeviceCodeSchema = z5.object({
|
|
1350
|
+
device_code: z5.string(),
|
|
1351
|
+
user_code: z5.string(),
|
|
1352
|
+
verification_uri: z5.string().url(),
|
|
1353
|
+
verification_uri_complete: z5.string().url(),
|
|
1354
|
+
interval: z5.number(),
|
|
1355
|
+
expires_in: z5.number()
|
|
1192
1356
|
});
|
|
1193
|
-
var DeviceInfoSchema =
|
|
1194
|
-
code:
|
|
1357
|
+
var DeviceInfoSchema = z5.object({
|
|
1358
|
+
code: z5.string(),
|
|
1195
1359
|
/** The agent's suggested name (from /device/code) — shown on the approval screen,
|
|
1196
1360
|
* pre-filling the name field the human can edit. */
|
|
1197
|
-
name:
|
|
1361
|
+
name: z5.string(),
|
|
1198
1362
|
/** @deprecated Legacy alias of `name` for the pre-#531 embedded bundle in App Store
|
|
1199
1363
|
* build 35, whose DeviceFlow renders `info.agent.slice(0, 2)` — without this a FRESH
|
|
1200
1364
|
* install crashes on the pairing screen on first launch, before the OTA lands
|
|
1201
1365
|
* (seen live: PAIGY-5T, 2026-07-21). Remove once a newer binary is the floor. */
|
|
1202
|
-
agent:
|
|
1203
|
-
device:
|
|
1366
|
+
agent: z5.string().optional(),
|
|
1367
|
+
device: z5.string().nullable(),
|
|
1204
1368
|
status: PairingStatusSchema
|
|
1205
1369
|
});
|
|
1206
|
-
var DeviceTokenSchema =
|
|
1207
|
-
access_token:
|
|
1370
|
+
var DeviceTokenSchema = z5.object({
|
|
1371
|
+
access_token: z5.string(),
|
|
1208
1372
|
/** The pairing's single name (user-typed at approval, the agent's suggestion, or
|
|
1209
1373
|
* a default silly name). */
|
|
1210
|
-
name:
|
|
1211
|
-
device:
|
|
1374
|
+
name: z5.string(),
|
|
1375
|
+
device: z5.string().nullable(),
|
|
1212
1376
|
/** The pairing's assigned voice, cached so the desktop can seed the SAME face the phone
|
|
1213
1377
|
* draws — voice is the third ingredient of a hatchling's build (party/traits.ts). */
|
|
1214
|
-
voice:
|
|
1378
|
+
voice: z5.string().nullable().optional(),
|
|
1215
1379
|
/** The token's server-side id — the face's COLOUR anchor, and the only seed ingredient
|
|
1216
1380
|
* that survives a rename. Cached by the host's identity beat. */
|
|
1217
|
-
token_id:
|
|
1381
|
+
token_id: z5.string().nullable().optional(),
|
|
1218
1382
|
/** WHERE this identity works — the folder a wake should land it in. Written by the host
|
|
1219
1383
|
* at spawn and by `paigy-harness handoff` from a live terminal. Without it every wake
|
|
1220
1384
|
* landed in the FIRST granted workspace and the agent rediscovered its own repo from
|
|
1221
1385
|
* the thread each time (host.ts, live catch 2026-08-06 — prompt-papered until now). */
|
|
1222
|
-
workspace:
|
|
1386
|
+
workspace: z5.string().nullable().optional(),
|
|
1223
1387
|
/** Local host recovery must preserve the launch's runtime and Paigy identity. */
|
|
1224
|
-
harness:
|
|
1225
|
-
session_id:
|
|
1226
|
-
|
|
1388
|
+
harness: z5.enum(["claude", "codex", "agy"]).optional(),
|
|
1389
|
+
session_id: z5.string().uuid().optional(),
|
|
1390
|
+
/** A conversation the host must not resume: its context is full, so every turn fails
|
|
1391
|
+
* ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
|
|
1392
|
+
* whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
|
|
1393
|
+
* copy that types the person's words into a turn that cannot run (Calls, 2026-10-06). */
|
|
1394
|
+
full_session: z5.string().optional(),
|
|
1395
|
+
uik_pub: z5.string().nullable().optional()
|
|
1227
1396
|
});
|
|
1228
|
-
var SupportRequestSchema =
|
|
1229
|
-
email:
|
|
1230
|
-
message:
|
|
1231
|
-
name:
|
|
1397
|
+
var SupportRequestSchema = z5.object({
|
|
1398
|
+
email: z5.string().email().max(320),
|
|
1399
|
+
message: z5.string().trim().min(1).max(5e3),
|
|
1400
|
+
name: z5.string().trim().max(120).optional()
|
|
1232
1401
|
});
|
|
1233
|
-
var NotificationFeedbackKindSchema =
|
|
1402
|
+
var NotificationFeedbackKindSchema = z5.enum([
|
|
1234
1403
|
"break_down",
|
|
1235
1404
|
// "This should be more than one ask — break it down."
|
|
1236
1405
|
"regenerate_options",
|
|
@@ -1245,116 +1414,116 @@ var NotificationFeedbackKindSchema = z4.enum([
|
|
|
1245
1414
|
// anything else — the note carries it.
|
|
1246
1415
|
]);
|
|
1247
1416
|
var SlimOptionSchema = OptionSchema.omit({ html: true });
|
|
1248
|
-
var QuestionRowSchema =
|
|
1417
|
+
var QuestionRowSchema = z5.object({
|
|
1249
1418
|
/** The card's id (`deliveryId:needId`, or `deliveryId:entryId` for an update), as the inbox mints it. */
|
|
1250
|
-
id:
|
|
1251
|
-
deliveryId:
|
|
1252
|
-
entryId:
|
|
1419
|
+
id: z5.string(),
|
|
1420
|
+
deliveryId: z5.string(),
|
|
1421
|
+
entryId: z5.string(),
|
|
1253
1422
|
/** The decision it waits on; null for an update, which asks nothing. */
|
|
1254
|
-
needId:
|
|
1255
|
-
goalIds:
|
|
1423
|
+
needId: z5.string().nullable(),
|
|
1424
|
+
goalIds: z5.array(z5.string()),
|
|
1256
1425
|
/** The name of the work it is about, when the read could word it. */
|
|
1257
|
-
goalTitle:
|
|
1258
|
-
tokenId:
|
|
1259
|
-
name:
|
|
1260
|
-
title:
|
|
1261
|
-
body:
|
|
1262
|
-
select:
|
|
1263
|
-
options:
|
|
1264
|
-
hasPreview:
|
|
1265
|
-
blocking:
|
|
1266
|
-
askedAt:
|
|
1426
|
+
goalTitle: z5.string().optional(),
|
|
1427
|
+
tokenId: z5.string().optional(),
|
|
1428
|
+
name: z5.string(),
|
|
1429
|
+
title: z5.string(),
|
|
1430
|
+
body: z5.string(),
|
|
1431
|
+
select: z5.enum(["one", "many", "rank", "confirm", "text"]),
|
|
1432
|
+
options: z5.array(SlimOptionSchema),
|
|
1433
|
+
hasPreview: z5.boolean(),
|
|
1434
|
+
blocking: z5.boolean(),
|
|
1435
|
+
askedAt: z5.string().datetime(),
|
|
1267
1436
|
ring: InboxItemSchema.shape.ring,
|
|
1268
|
-
onCall:
|
|
1269
|
-
sealed:
|
|
1437
|
+
onCall: z5.literal(true).optional(),
|
|
1438
|
+
sealed: z5.boolean()
|
|
1270
1439
|
});
|
|
1271
|
-
var WorkStateSchema =
|
|
1272
|
-
var WorkRowSchema =
|
|
1273
|
-
id:
|
|
1274
|
-
parentId:
|
|
1275
|
-
title:
|
|
1440
|
+
var WorkStateSchema = z5.enum(["ready", "active", "waiting", "done", "cancelled"]);
|
|
1441
|
+
var WorkRowSchema = z5.object({
|
|
1442
|
+
id: z5.string(),
|
|
1443
|
+
parentId: z5.string().nullable(),
|
|
1444
|
+
title: z5.string(),
|
|
1276
1445
|
/** Straight off the Goal. */
|
|
1277
1446
|
state: WorkStateSchema,
|
|
1278
|
-
owner:
|
|
1279
|
-
revision:
|
|
1447
|
+
owner: z5.string().nullable(),
|
|
1448
|
+
revision: z5.number().int(),
|
|
1280
1449
|
/** Open questions on it, counted to 100. */
|
|
1281
|
-
waiting:
|
|
1450
|
+
waiting: z5.number().int(),
|
|
1282
1451
|
/** Held by a gate on work that is not done. */
|
|
1283
|
-
blocked:
|
|
1284
|
-
lastProgressAt:
|
|
1452
|
+
blocked: z5.boolean(),
|
|
1453
|
+
lastProgressAt: z5.string().datetime().nullable(),
|
|
1285
1454
|
/** The line written for its newest progress note, else that note's first words. */
|
|
1286
|
-
line:
|
|
1455
|
+
line: z5.string().nullable(),
|
|
1287
1456
|
/** Work directly under it, counted to 100; the list carries up to 12 of them. */
|
|
1288
|
-
children:
|
|
1289
|
-
createdAt:
|
|
1290
|
-
updatedAt:
|
|
1457
|
+
children: z5.number().int(),
|
|
1458
|
+
createdAt: z5.string().datetime(),
|
|
1459
|
+
updatedAt: z5.string().datetime(),
|
|
1291
1460
|
/** When anything at or under it last moved — the order the list is in. */
|
|
1292
|
-
activeAt:
|
|
1461
|
+
activeAt: z5.string().datetime(),
|
|
1293
1462
|
/** A sealed outcome has no title here; the work's page opens it. */
|
|
1294
|
-
sealed:
|
|
1463
|
+
sealed: z5.boolean()
|
|
1295
1464
|
});
|
|
1296
1465
|
var ComputerRowSchema = ConnectionSummarySchema.omit({ activity: true });
|
|
1297
1466
|
var AgentRowSchema = ComputerRowSchema.extend({
|
|
1298
1467
|
/** Open questions it is asking the person, over every open card; null when that read failed. */
|
|
1299
|
-
asking:
|
|
1300
|
-
oldestAskAt:
|
|
1468
|
+
asking: z5.number().int().nullable(),
|
|
1469
|
+
oldestAskAt: z5.string().datetime().nullable(),
|
|
1301
1470
|
/** Up to three of the live Goals it holds, oldest first (the order it picks them up), and how
|
|
1302
1471
|
* many in all among the account's 200 most recently active agent-held live Goals
|
|
1303
1472
|
* (`agent_holds`); null when that read failed. */
|
|
1304
|
-
holds:
|
|
1305
|
-
held:
|
|
1473
|
+
holds: z5.array(z5.object({ id: z5.string(), title: z5.string() })).nullable(),
|
|
1474
|
+
held: z5.number().int().nullable(),
|
|
1306
1475
|
/** The earliest instant any Goal it holds went quiet, by the one rule (`coldSince`); null
|
|
1307
1476
|
* while none has, or when that read failed. */
|
|
1308
|
-
cold:
|
|
1477
|
+
cold: z5.string().datetime().nullable(),
|
|
1309
1478
|
/** The newest line of its working log, and when the harness saw it. */
|
|
1310
|
-
line:
|
|
1311
|
-
lineAt:
|
|
1479
|
+
line: z5.string().nullable(),
|
|
1480
|
+
lineAt: z5.string().datetime().nullable()
|
|
1312
1481
|
});
|
|
1313
|
-
var SnapshotSchema =
|
|
1482
|
+
var SnapshotSchema = z5.object({
|
|
1314
1483
|
/** The API's clock, taken before the first read: what a later delta will start from. */
|
|
1315
|
-
at:
|
|
1316
|
-
questions:
|
|
1484
|
+
at: z5.string().datetime(),
|
|
1485
|
+
questions: z5.object({
|
|
1317
1486
|
/** The newest 30 open cards, questions before updates. */
|
|
1318
|
-
items:
|
|
1487
|
+
items: z5.array(QuestionRowSchema),
|
|
1319
1488
|
/** Every open question, and apart from them every update, and what was put off. */
|
|
1320
|
-
total:
|
|
1321
|
-
updates:
|
|
1322
|
-
putOff:
|
|
1489
|
+
total: z5.number().int(),
|
|
1490
|
+
updates: z5.number().int(),
|
|
1491
|
+
putOff: z5.number().int()
|
|
1323
1492
|
}).nullable(),
|
|
1324
|
-
agents:
|
|
1493
|
+
agents: z5.object({
|
|
1325
1494
|
/** Up to 60, most recently seen first. */
|
|
1326
|
-
items:
|
|
1327
|
-
more:
|
|
1495
|
+
items: z5.array(AgentRowSchema),
|
|
1496
|
+
more: z5.boolean()
|
|
1328
1497
|
}).nullable(),
|
|
1329
|
-
work:
|
|
1498
|
+
work: z5.object({
|
|
1330
1499
|
/** The 60 most recently active roots, each followed by up to 12 children; 240 rows at most. */
|
|
1331
|
-
items:
|
|
1500
|
+
items: z5.array(WorkRowSchema),
|
|
1332
1501
|
/** How much work is behind each of the Work tab's four filters, each counted to 100, read with
|
|
1333
1502
|
* the rows. `work_list` (20260928023533) owns the predicates: Live is `ready`, `active` or
|
|
1334
1503
|
* `waiting`; Waiting on you is live work with an open question or an unmet gate; Not started
|
|
1335
1504
|
* is `ready`; Done is `done` or `cancelled`. */
|
|
1336
|
-
counts:
|
|
1505
|
+
counts: z5.object({ live: z5.number().int(), waiting: z5.number().int(), notStarted: z5.number().int(), done: z5.number().int() })
|
|
1337
1506
|
}).nullable(),
|
|
1338
|
-
you:
|
|
1507
|
+
you: z5.object({
|
|
1339
1508
|
settings: UserSettingsSchema,
|
|
1340
|
-
callable:
|
|
1509
|
+
callable: z5.boolean(),
|
|
1341
1510
|
/** Up to 20 paired computers; null when the roster read failed. */
|
|
1342
|
-
computers:
|
|
1511
|
+
computers: z5.array(ComputerRowSchema).nullable()
|
|
1343
1512
|
}).nullable()
|
|
1344
1513
|
});
|
|
1345
|
-
var CallRecapSchema =
|
|
1346
|
-
call:
|
|
1347
|
-
status:
|
|
1348
|
-
startedAt:
|
|
1349
|
-
durationMs:
|
|
1350
|
-
agents:
|
|
1514
|
+
var CallRecapSchema = z5.object({
|
|
1515
|
+
call: z5.object({
|
|
1516
|
+
status: z5.string(),
|
|
1517
|
+
startedAt: z5.string(),
|
|
1518
|
+
durationMs: z5.number().nullable(),
|
|
1519
|
+
agents: z5.array(z5.object({ id: z5.string(), name: z5.string().nullable() }))
|
|
1351
1520
|
}),
|
|
1352
|
-
topics:
|
|
1353
|
-
goalId:
|
|
1354
|
-
title:
|
|
1355
|
-
owner:
|
|
1356
|
-
state:
|
|
1357
|
-
questions:
|
|
1521
|
+
topics: z5.array(z5.object({
|
|
1522
|
+
goalId: z5.string().uuid(),
|
|
1523
|
+
title: z5.string(),
|
|
1524
|
+
owner: z5.string(),
|
|
1525
|
+
state: z5.string(),
|
|
1526
|
+
questions: z5.array(z5.object({ id: z5.string().uuid(), state: z5.string(), title: z5.string() })),
|
|
1358
1527
|
/** `words` is always what they SAID, verbatim — the record, never replaced. `headline` is
|
|
1359
1528
|
* their answer on one line when the call's read wrote one (owner, 2026-10-01: "render them
|
|
1360
1529
|
* summarized like a pre-made option is"), so the row scans like a chosen option and their
|
|
@@ -1362,17 +1531,18 @@ var CallRecapSchema = z4.object({
|
|
|
1362
1531
|
* anything that is not an answer. */
|
|
1363
1532
|
/** `about` is the request the line answered (its question), null for words that answered none —
|
|
1364
1533
|
* the key the screen groups on, so one question is one row however many times it was answered. */
|
|
1365
|
-
lines:
|
|
1534
|
+
lines: z5.array(z5.object({ entryId: z5.string().uuid(), words: z5.string(), headline: z5.string().optional(), about: z5.string().nullable().optional() }))
|
|
1366
1535
|
})),
|
|
1367
|
-
unfiled:
|
|
1368
|
-
more:
|
|
1536
|
+
unfiled: z5.array(z5.object({ lineId: z5.string().uuid(), words: z5.string(), atMs: z5.number() })),
|
|
1537
|
+
more: z5.object({ lines: z5.number(), entries: z5.number(), topics: z5.number() })
|
|
1369
1538
|
});
|
|
1370
1539
|
|
|
1371
1540
|
// src/listening.ts
|
|
1541
|
+
import { createHash } from "crypto";
|
|
1372
1542
|
import { chmodSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
1373
1543
|
import { homedir } from "os";
|
|
1374
1544
|
import { dirname, join } from "path";
|
|
1375
|
-
var HARNESS_MARKS = ["PAIGY_HARNESS"
|
|
1545
|
+
var HARNESS_MARKS = ["PAIGY_HARNESS"];
|
|
1376
1546
|
function harnessDriven(env) {
|
|
1377
1547
|
return HARNESS_MARKS.some((mark) => !!env[mark]);
|
|
1378
1548
|
}
|
|
@@ -1428,11 +1598,12 @@ function decideListen(f) {
|
|
|
1428
1598
|
};
|
|
1429
1599
|
}
|
|
1430
1600
|
if (f.pidAlive && f.pid !== void 0) {
|
|
1431
|
-
|
|
1601
|
+
const connected = f.wake?.ready === true && (f.wake.target.kind !== "codex" || f.wake.target.thread === f.env.CODEX_THREAD_ID);
|
|
1602
|
+
return { status: connected ? "listening" : "receiving", via: "daemon", pid: f.pid, ...f.wake ? { wake: f.wake } : {}, message: connected ? `Listener running (pid ${f.pid}); wake adapter ready. A queued message is not proof the agent handled it.` : `Listener running (pid ${f.pid}), but automatic session resume is not confirmed${f.wake?.lastError ? `: ${f.wake.lastError}` : ". Watch its output or configure a supported wake adapter"}. Do not start a second listener.` };
|
|
1432
1603
|
}
|
|
1433
1604
|
return {
|
|
1434
1605
|
status: "start",
|
|
1435
|
-
command: `PAIGY_AGENT=${word(f.slot)} PAIGY_SESSION_ID=${word(f.session)} ${word(f.execPath)} ${word(f.listenJs)} --brief`,
|
|
1606
|
+
command: `PAIGY_AGENT=${word(f.slot)} PAIGY_SESSION_ID=${word(f.session)} ${f.env.CODEX_THREAD_ID ? `CODEX_THREAD_ID=${word(f.env.CODEX_THREAD_ID)} ` : ""}${f.env.PAIGY_ON_WAKE ? `PAIGY_ON_WAKE=${word(f.env.PAIGY_ON_WAKE)} ` : ""}${word(f.execPath)} ${word(f.listenJs)} --brief`,
|
|
1436
1607
|
how: "Run this command NOW as a watched background task (your harness's background-task/monitor tool), and leave it running for this session. Each line it prints is a Delivery waiting for you: claim_goal the Goal it names, read it, and answer with contact. Start it once."
|
|
1437
1608
|
};
|
|
1438
1609
|
}
|
|
@@ -1470,16 +1641,28 @@ function listenerAlive(slot, home = homedir()) {
|
|
|
1470
1641
|
return null;
|
|
1471
1642
|
}
|
|
1472
1643
|
}
|
|
1644
|
+
function listenerKey(slot, env) {
|
|
1645
|
+
return env.CODEX_THREAD_ID ? `${slot}-${createHash("sha256").update(env.CODEX_THREAD_ID).digest("hex")}` : slot;
|
|
1646
|
+
}
|
|
1647
|
+
function wakeStatusPath(slot, home = homedir()) {
|
|
1648
|
+
return `${listenMark(slot, home)}.wake.json`;
|
|
1649
|
+
}
|
|
1650
|
+
function existingListener(slot, env, home = homedir()) {
|
|
1651
|
+
return listenerAlive(listenerKey(slot, env), home) ?? (env.CODEX_THREAD_ID ? listenerAlive(slot, home) : null);
|
|
1652
|
+
}
|
|
1473
1653
|
|
|
1474
1654
|
export {
|
|
1475
1655
|
mcpInputSchema,
|
|
1476
1656
|
AGENT_TOOLS,
|
|
1477
1657
|
serverInstructions,
|
|
1478
1658
|
entryWords,
|
|
1659
|
+
harnessDriven,
|
|
1479
1660
|
sessionStartHook,
|
|
1480
1661
|
withSessionStartHook,
|
|
1481
1662
|
decideListen,
|
|
1482
1663
|
writeListenMark,
|
|
1483
1664
|
removeListenMark,
|
|
1484
|
-
|
|
1665
|
+
listenerKey,
|
|
1666
|
+
wakeStatusPath,
|
|
1667
|
+
existingListener
|
|
1485
1668
|
};
|