@paigy/mcp 0.40.39 → 0.40.40
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 +11 -12
- package/dist/{chunk-PMZBYLLJ.js → chunk-6FG3PZR2.js} +30 -7
- package/dist/{chunk-QE33A5XK.js → chunk-H2EBILBE.js} +750 -535
- package/dist/{chunk-4IAK4ATB.js → chunk-PKJJSHLW.js} +41 -44
- package/dist/{chunk-X4UIGUEX.js → chunk-V4OVLFMP.js} +644 -527
- package/dist/{dist-DOFR2565.js → dist-EJWDUF5J.js} +3 -1
- package/dist/enable.js +3 -3
- package/dist/index.js +45 -21
- package/dist/listen.js +32 -6
- package/dist/onboard.js +18 -6
- package/dist/slot.js +1 -1
- package/dist/stalled.js +10 -5
- package/dist/statusline.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ../../packages/schema/dist/index.js
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z12 } from "zod";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { z as z3 } from "zod";
|
|
5
5
|
import { z as z2 } from "zod";
|
|
@@ -16,6 +16,8 @@ import { z as z9 } from "zod";
|
|
|
16
16
|
import { zodToJsonSchema as zodToJsonSchema5 } from "zod-to-json-schema";
|
|
17
17
|
import { z as z10 } from "zod";
|
|
18
18
|
import { zodToJsonSchema as zodToJsonSchema6 } from "zod-to-json-schema";
|
|
19
|
+
import { z as z11 } from "zod";
|
|
20
|
+
import { zodToJsonSchema as zodToJsonSchema7 } from "zod-to-json-schema";
|
|
19
21
|
var OPTIONS_MIN = 2;
|
|
20
22
|
var OPTIONS_MAX = 6;
|
|
21
23
|
var OPTION_LABEL_MAX = 50;
|
|
@@ -45,7 +47,7 @@ var OptionInputSchema = z.object({
|
|
|
45
47
|
imgUrl: OptionSchema.shape.image
|
|
46
48
|
}).strict();
|
|
47
49
|
var NIGHT = { from: 23, to: 7 };
|
|
48
|
-
var ASK_MAX =
|
|
50
|
+
var ASK_MAX = 80;
|
|
49
51
|
var UNITS_MAX = 12;
|
|
50
52
|
var UNIT_TITLE_MAX = 50;
|
|
51
53
|
var UNIT_BODY_MAX = 200;
|
|
@@ -110,15 +112,15 @@ var CompletionSchema = z3.object({
|
|
|
110
112
|
}).strict();
|
|
111
113
|
var CompleteChangeSchema = CompletionSchema.extend({ kind: z3.literal("complete") });
|
|
112
114
|
var ASKING_RULES = `HOW TO ASK:
|
|
113
|
-
1.
|
|
114
|
-
2.
|
|
115
|
-
3. \`workItBlocks\` only
|
|
116
|
-
4.
|
|
117
|
-
5. One question, one row
|
|
118
|
-
6. Read the Goal
|
|
119
|
-
7.
|
|
120
|
-
8. A diagnosis says when, why and how it happens, then proposes one fix.
|
|
121
|
-
9.
|
|
115
|
+
1. One question per object in \`questions\`, so each is answered on its own.
|
|
116
|
+
2. \`goalId\` names the existing Goal it is about (create one with manage_goals first); the answer comes back there.
|
|
117
|
+
3. \`workItBlocks\` only when you are truly blocked: it asks for a call.
|
|
118
|
+
4. No while-loops. While any Call is open, even one your question joined from their items, keep receiving through empty windows; otherwise stop at one: the answer reaches you on the Goal. Yield only with a listener or wakeup.
|
|
119
|
+
5. One question, one row: never re-send one still waiting; take back one that no longer matters with \`withdrawQuestionIds\`.
|
|
120
|
+
6. Read the Goal before asking; never re-ask what was answered or shipped. \`replied\` means they chose no option: it is still yours to settle.
|
|
121
|
+
7. Give options when you have them. Each label names its choice in full (never "Option 2"); never add "Other". \`pickMode\`: one (default), many, rank.
|
|
122
|
+
8. A diagnosis says when, why and how it happens, then proposes one fix.
|
|
123
|
+
9. Give a report its \`reply\`: one line in THEIR voice for THAT report, so you learn whether they verified it or only received it. Required when it reaches them or completes a Goal.`;
|
|
122
124
|
function draft2020(node) {
|
|
123
125
|
if (Array.isArray(node)) return node.map(draft2020);
|
|
124
126
|
if (node && typeof node === "object") {
|
|
@@ -161,7 +163,7 @@ var userExplicitlyRequested = z4.enum(["any", "call"]).optional().describe(
|
|
|
161
163
|
`Only what the person said about THIS message, in so many words: "any" when they asked you to send it to them ("send it to my phone", "message me the result"), "call" when they asked to be called about it. It is then delivered (a call rings for the whole contact, and carries everything waiting on them); omitted, an update is only recorded as the Goal's progress unless the person needs it. Never set it to make a message louder.`
|
|
162
164
|
);
|
|
163
165
|
var units = z4.array(UnitInputSchema).optional().describe(
|
|
164
|
-
`The context this message needs, as up to ${UNITS_MAX} units in reading order, each {title, body}: a title of at most ${UNIT_TITLE_MAX} characters and a body of at most ${UNIT_BODY_MAX}. One idea per unit. Leave it out when the main text says it all.`
|
|
166
|
+
`The context this message needs, as up to ${UNITS_MAX} units in reading order, each {title, body}: a title of at most ${UNIT_TITLE_MAX} characters and a body of at most ${UNIT_BODY_MAX}. One idea per unit. Leave it out when the main text says it all. Over a cap is refused by name (ask_too_long, too_many_units, unit_title_too_long, unit_body_too_long) and nothing is sent.`
|
|
165
167
|
);
|
|
166
168
|
var UpdateInputSchema = z4.object({
|
|
167
169
|
message: z4.string().trim().min(1).describe(`The one point, at most ${ASK_MAX} characters; the context goes in units.`),
|
|
@@ -216,7 +218,7 @@ var questionFields = {
|
|
|
216
218
|
),
|
|
217
219
|
goalId: z4.string().uuid().describe("The Goal the question is about, which must exist (create it with manage_goals first). Its answer comes back there."),
|
|
218
220
|
units,
|
|
219
|
-
options: z4.array(OptionInputSchema).min(1).max(6).optional().describe("The choices, when you have them. Each label stands on its own, at most 50 characters; a hint, at most 200."),
|
|
221
|
+
options: z4.array(OptionInputSchema).min(1).max(6).optional().describe("The choices, when you have them. Each label stands on its own, at most 50 characters; a hint, at most 200. They can always answer in their own words, so no 'Other' or 'None of these'."),
|
|
220
222
|
// HOW THE OPTIONS ARE ANSWERED, SAID BY THE AGENT (owner, 2026-10-02: "one and many makes sense";
|
|
221
223
|
// brain_prompts.md §1: structured agent questions need no model). The app draws all three.
|
|
222
224
|
pickMode: z4.enum(["one", "many", "rank"]).optional().describe(
|
|
@@ -258,7 +260,9 @@ var QuestionDependencySchema = z4.object({
|
|
|
258
260
|
reason: reason.optional()
|
|
259
261
|
}).strict().refine(actionFits, ACTION_FITS);
|
|
260
262
|
var sendFields = {
|
|
261
|
-
completions: z4.array(CompletionSchema).min(1).max(20).optional().describe(
|
|
263
|
+
completions: z4.array(CompletionSchema).min(1).max(20).optional().describe(
|
|
264
|
+
"COMPLETIONS close and report in one operation, the same contract as manage_goals kind:complete: closure and the report commit together or neither does. Required children and dependencies must already be finished. options suggest next steps: a tap acknowledges the report and requests that step, and never reopens the Goal (follow-up work needs a new one). No reviewer rejudges it: say only what your evidence supports. Ordinary updates never close a Goal."
|
|
265
|
+
),
|
|
262
266
|
updates: z4.array(UpdateInputSchema).min(1).max(20).optional().describe(
|
|
263
267
|
"News: progress, findings, a result. An update asks nothing. It reaches the person only when they asked for it (userExplicitlyRequested), when it answers something they said, or once its Goal is done; otherwise it is recorded as the Goal's progress and nobody is notified."
|
|
264
268
|
),
|
|
@@ -272,7 +276,7 @@ var sendFields = {
|
|
|
272
276
|
};
|
|
273
277
|
var ContactSchema = z4.object({
|
|
274
278
|
...sendFields,
|
|
275
|
-
questions: z4.array(QuestionInputSchema).min(1).max(20).optional().describe("Questions for the person, one per object."),
|
|
279
|
+
questions: z4.array(QuestionInputSchema).min(1).max(20).optional().describe("Questions for the person, one per object, each sent exactly as written, with no reading in between."),
|
|
276
280
|
/** RECEIVING (2I, I2; brain_prompts.md §2.2): the events this agent handled. */
|
|
277
281
|
ackEventIds: z4.array(z4.string().uuid()).min(1).max(100).optional().describe(
|
|
278
282
|
"The exact eventIds of the events you have handled: an acknowledgment (ACK). Reading alone acknowledges nothing, so an event comes back until you acknowledge it; after that the next batch can come. Each recipient acknowledges separately, for itself only. A Question you owe is answered (answers), never acknowledged away."
|
|
@@ -288,15 +292,13 @@ var ContactWireSchema = z4.object({
|
|
|
288
292
|
questions: z4.array(QuestionWireSchema).min(1).max(20).optional()
|
|
289
293
|
}).strict().refine(sendsAnything, "a contact sends at least one update, question, answer, withdrawal or question dependency");
|
|
290
294
|
var CONTACT_SCHEMA = { type: "object", ...mcpInputSchema(ContactSchema) };
|
|
291
|
-
var CONTACT_DESCRIPTION = "Send to and receive from the person: completions, updates, questions, answers to questions addressed to you, withdrawals
|
|
295
|
+
var CONTACT_DESCRIPTION = "Send to and receive from the person: completions, updates, questions, answers to questions addressed to you, withdrawals, and what a question holds up. Every Goal named must exist: an unknown one refuses the whole contact. Each item applies on its own: read `results`, where a failed one names why.\n\n" + ASKING_RULES + `
|
|
292
296
|
|
|
293
|
-
|
|
297
|
+
LENGTH: the question, message or answer is the one point, at most ${ASK_MAX} characters; the rest goes in \`units\`, one idea each. Over a cap is refused by name and nothing is sent. Several results are several updates.
|
|
294
298
|
|
|
295
|
-
UPDATES ask nothing
|
|
299
|
+
UPDATES ask nothing. One reaches the person only when they asked for it, it answers something they said, or its Goal is done; else it is kept as progress. One that reaches them joins an open report card or a live call.
|
|
296
300
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
RECEIVING: a contact that sends nothing returns \`events\`, a limited batch of what is addressed to you (not a history page): \`question\`, a Question you owe (answer it in answers, with its questionId); \`update\`, something new on one of your Goals (a reply, an answer: read it with get_goals); \`instruction\`, a request or note sent to you. \`hasMore\` says more are waiting. Reading acknowledges nothing: once you have handled events, confirm their eventIds with contact({ackEventIds}), and the next batch can come. contact({}) waits up to about 45 seconds for something to arrive; contact({wait:false}) returns at once. It also lists work given to you that nobody has started (\`assigned\`; your first write to it starts it) and your work gone quiet (\`stalled\`).`;
|
|
301
|
+
RECEIVING: contact({}) waits ~45 s; contact({wait:false}) returns \`events\` at once. Confirm the ones you handled with contact({ackEventIds}).`;
|
|
300
302
|
var CreateGoalSchema = z5.object({
|
|
301
303
|
outcome: z5.string().trim().min(1).max(1e4),
|
|
302
304
|
/** The work's NAME (#2115) — one to five words, how a person refers to it out loud ("the night
|
|
@@ -430,8 +432,8 @@ var AGENT_TOOLS = [
|
|
|
430
432
|
];
|
|
431
433
|
var AGENT_TOOL_NAMES = AGENT_TOOLS.map((t) => t.name);
|
|
432
434
|
function serverInstructions(opts) {
|
|
433
|
-
const waits = opts.waits ? "contact({
|
|
434
|
-
return `On startup and after a wake,
|
|
435
|
+
const waits = opts.waits ? "contact({wait:true}) waits ~45 s for a reply to what you sent; contact({}) for anything addressed to you." : "A contact here returns after one read; answers wake you, and contact({wait:false}) collects them.";
|
|
436
|
+
return `On startup and after a wake, contact({wait:false}) returns your events. They repeat until you acknowledge them with contact({ackEventIds}); reading acknowledges nothing. get_goals reads a Goal and its conversation; your first write to one puts you on it, and every Goal of your person is open to you. manage_goals creates, assigns and organizes work; to follow up later, defer the Goal with manage_goals (you're woken when due). Complete and report in one step: contact.completions or manage_goals kind:complete. Every read ends in \`next\`: your next step. ${waits} Report progress as a contact update; one they don't need yet stays on the Goal. An open Call is not proof it rang. Your user is remote: reach them only through Paigy, never the terminal; ask decisions with options.
|
|
435
437
|
|
|
436
438
|
${ASKING_RULES}`;
|
|
437
439
|
}
|
|
@@ -520,11 +522,22 @@ var BrainMessageSchema = z6.union([
|
|
|
520
522
|
// A MESSAGE TO THE PERSON KEEPS ITS SENTENCES (turns.md): the talker writes them one by one, and each is
|
|
521
523
|
// its own unit of speech (`<cycle>:<key>:<n>`). `text` is the same words joined, for every reader of a
|
|
522
524
|
// message's words. Absent on results written before sentences.
|
|
523
|
-
z6.object({
|
|
525
|
+
z6.object({
|
|
526
|
+
...messageBase,
|
|
527
|
+
to: z6.object({ kind: z6.literal("user") }).strict(),
|
|
528
|
+
sentences: z6.array(z6.string().min(1)).min(1).optional(),
|
|
529
|
+
// THE REPORTS IT TELLS, BY THEIR OWN IDENTITY (call 9d1c096c, 2026-10-15): the talker's message names the report
|
|
530
|
+
// Entries it speaks of, so the plan's line names that report rather than re-finding it by its Goal. Absent on
|
|
531
|
+
// results written before it.
|
|
532
|
+
tells: z6.array(z6.object({ id }).strict()).optional()
|
|
533
|
+
}).strict(),
|
|
524
534
|
z6.object({
|
|
525
535
|
...messageBase,
|
|
526
536
|
to: z6.object({ kind: z6.literal("agent"), agentId: z6.string().regex(/^agent:(?!paigy$)\S+$/) }).strict(),
|
|
527
537
|
call: z6.object({ callId: id, listen: z6.literal(true) }).strict().optional(),
|
|
538
|
+
// WHAT IT ASKS THE AGENT, IN UNDER TEN WORDS (owner, 2026-10-15: "Yes, add the summary"): the talker's own, stored
|
|
539
|
+
// as the sent Entry's summary, which the recap's "Sent to <agent>: …" row shows. Absent on results written before it.
|
|
540
|
+
summary: z6.string().optional(),
|
|
528
541
|
// THE PERSON ASKED TO BE CALLED BACK ONCE THIS AGENT'S WORK IS DONE (turns.md, step 0): the agent owes
|
|
529
542
|
// the call, and its next contact about it rings them (`public.callbacks`).
|
|
530
543
|
callback: z6.literal(true).optional()
|
|
@@ -551,95 +564,97 @@ var BrainResultSchema = z6.object({
|
|
|
551
564
|
next: BrainNextSchema,
|
|
552
565
|
search: BrainSearchSchema.optional()
|
|
553
566
|
}).strict();
|
|
554
|
-
var
|
|
567
|
+
var str2 = z6.string();
|
|
555
568
|
var strs = z6.array(z6.string());
|
|
556
569
|
var CompactResultSchema = z6.object({
|
|
557
|
-
next: z6.object({ say: strs, then: z6.enum(["listen", "hold", "end", "none"]), waitFor: strs, reason:
|
|
558
|
-
messages: z6.array(z6.object({ key:
|
|
559
|
-
entries: z6.array(z6.object({ key:
|
|
560
|
-
answers: z6.array(z6.object({ question:
|
|
570
|
+
next: z6.object({ say: strs, then: z6.enum(["listen", "hold", "end", "none"]), waitFor: strs, reason: str2, instructions: strs }).strict(),
|
|
571
|
+
messages: z6.array(z6.object({ key: str2, to: str2, text: str2, about: strs, entries: strs, owed: strs, inviteToCall: z6.boolean() }).strict()),
|
|
572
|
+
entries: z6.array(z6.object({ key: str2, from: str2, on: strs }).strict()),
|
|
573
|
+
answers: z6.array(z6.object({ question: str2, entries: strs, summary: str2, picked: strs }).strict()),
|
|
561
574
|
changes: z6.array(z6.object({
|
|
562
|
-
key:
|
|
575
|
+
key: str2,
|
|
563
576
|
what: z6.enum(["goal", "question", "lesson"]),
|
|
564
577
|
op: z6.enum(["create", "edit", "assign", "open", "complete", "cancel", "defer", "move", "block", "unblock", "withdraw", "remember", "revise"]),
|
|
565
|
-
id:
|
|
566
|
-
text:
|
|
567
|
-
title:
|
|
568
|
-
who:
|
|
569
|
-
under:
|
|
578
|
+
id: str2,
|
|
579
|
+
text: str2,
|
|
580
|
+
title: str2,
|
|
581
|
+
who: str2,
|
|
582
|
+
under: str2,
|
|
570
583
|
gate: z6.enum(["start", "complete", "answer", "none"]),
|
|
571
|
-
options: z6.array(z6.object({ id:
|
|
584
|
+
options: z6.array(z6.object({ id: str2, label: str2 }).strict()),
|
|
572
585
|
pick: z6.enum(["one", "many", "rank", "words"]),
|
|
573
586
|
entries: strs
|
|
574
587
|
}).strict()),
|
|
575
588
|
feedback: z6.array(strs),
|
|
576
|
-
search: z6.object({ query:
|
|
589
|
+
search: z6.object({ query: str2, within: strs, goal: str2 }).strict()
|
|
577
590
|
}).strict();
|
|
578
591
|
var COMPACT_RESULT_JSON_SCHEMA = (({ $schema: _, ...rest }) => rest)(
|
|
579
592
|
zodToJsonSchema2(CompactResultSchema, { $refStrategy: "none" })
|
|
580
593
|
);
|
|
581
|
-
var
|
|
594
|
+
var str3 = z7.string();
|
|
582
595
|
var strs2 = z7.array(z7.string());
|
|
583
596
|
var TalkerReplySchema = z7.object({
|
|
584
597
|
/** What to say and send, messages to the person first: spoken in the order written. `to` is "user"
|
|
585
598
|
* or an agent's handle; `sentences` is what a message to the person says, one short sentence each
|
|
586
|
-
* ([] to an agent); `text` is what a message to an agent says ("" to the person); `
|
|
599
|
+
* ([] to an agent); `text` is what a message to an agent says ("" to the person); `summary` is what it
|
|
600
|
+
* asks the agent, in under ten words, as the person would put it ("" to the person; owner, 2026-10-15:
|
|
601
|
+
* "Yes, add the summary"), which the recap's "Sent to <agent>: …" row shows; `about` names
|
|
587
602
|
* handles; `blocks` is the item a question to an agent must be answered before ("" for none);
|
|
588
603
|
* `callback` is true on a message to the agent doing work the person asked to be called back about
|
|
589
604
|
* once it is done (false otherwise): that agent then owes the call (turns.md, step 0). */
|
|
590
|
-
messages: z7.array(z7.object({ key:
|
|
605
|
+
messages: z7.array(z7.object({ key: str3, to: str3, sentences: strs2, text: str3, summary: str3, about: strs2, blocks: str3, callback: z7.boolean() }).strict()),
|
|
591
606
|
/** What the call does next: listen, hold (the person asked for a moment) or end (they asked to). */
|
|
592
607
|
then: z7.enum(["listen", "hold", "end"]),
|
|
593
608
|
/** The person's replies to items (replies, owner 2026-10-07): the item's handle, the chosen option
|
|
594
609
|
* IDs, the line handles, how they replied in under ten words (keeping any condition), and `defer`:
|
|
595
610
|
* "" when their words settle the item, else what a reply that puts it off waits for -- "call" (the
|
|
596
611
|
* end of this call), a question's handle (that question's answer) or an ISO time. */
|
|
597
|
-
replies: z7.array(z7.object({ item:
|
|
612
|
+
replies: z7.array(z7.object({ item: str3, options: strs2, lines: strs2, summary: str3, defer: str3 }).strict()),
|
|
598
613
|
/** The line handles that tell the talker how to run this call; they last until it ends and reach no agent. */
|
|
599
614
|
instruction: strs2,
|
|
600
615
|
/** The line handles the filer acts on, and the only ones it reads (3e): new work, a change to existing
|
|
601
616
|
* work, feedback on Paigy, anything said to an agent, and any rule meant to outlast the call. */
|
|
602
617
|
file: strs2,
|
|
603
618
|
/** Evidence to fetch for a second round: a search, an item's full text, or an agent by name. */
|
|
604
|
-
need: z7.object({ kind: z7.enum(["search", "item", "agent", ""]), text:
|
|
619
|
+
need: z7.object({ kind: z7.enum(["search", "item", "agent", ""]), text: str3 }).strict(),
|
|
605
620
|
/** The handle of the item to explain ("" for none). */
|
|
606
|
-
explain:
|
|
621
|
+
explain: str3
|
|
607
622
|
}).strict();
|
|
608
623
|
var TALKER_REPLY_JSON_SCHEMA = (({ $schema: _, ...rest }) => rest)(
|
|
609
624
|
zodToJsonSchema3(TalkerReplySchema, { $refStrategy: "none" })
|
|
610
625
|
);
|
|
611
|
-
var
|
|
626
|
+
var str4 = z8.string();
|
|
612
627
|
var strs3 = z8.array(z8.string());
|
|
613
628
|
var FilerReplySchema = z8.object({
|
|
614
629
|
/** Which Goals each new line goes on: a line's handle, Goal handles (or keys of new Goals), and what
|
|
615
630
|
* the line says in at most ten words. */
|
|
616
|
-
filed: z8.array(z8.object({ line:
|
|
631
|
+
filed: z8.array(z8.object({ line: str4, goals: strs3, summary: str4 }).strict()),
|
|
617
632
|
goals: z8.array(z8.object({
|
|
618
633
|
op: z8.enum(["create", "edit", "complete", "cancel", "reopen", "assign", "defer", "move", "block", "unblock"]),
|
|
619
|
-
key:
|
|
620
|
-
goal:
|
|
621
|
-
title:
|
|
622
|
-
outcome:
|
|
623
|
-
owner:
|
|
624
|
-
under:
|
|
625
|
-
until:
|
|
626
|
-
on:
|
|
634
|
+
key: str4,
|
|
635
|
+
goal: str4,
|
|
636
|
+
title: str4,
|
|
637
|
+
outcome: str4,
|
|
638
|
+
owner: str4,
|
|
639
|
+
under: str4,
|
|
640
|
+
until: str4,
|
|
641
|
+
on: str4,
|
|
627
642
|
gate: z8.enum(["start", "complete", "answer", ""]),
|
|
628
|
-
why:
|
|
643
|
+
why: str4
|
|
629
644
|
}).strict()),
|
|
630
645
|
questions: z8.array(z8.object({
|
|
631
646
|
op: z8.enum(["create", "edit", "assign", "withdraw"]),
|
|
632
|
-
key:
|
|
633
|
-
question:
|
|
634
|
-
text:
|
|
635
|
-
summary:
|
|
636
|
-
to:
|
|
637
|
-
goal:
|
|
638
|
-
options: z8.array(z8.object({ id:
|
|
647
|
+
key: str4,
|
|
648
|
+
question: str4,
|
|
649
|
+
text: str4,
|
|
650
|
+
summary: str4,
|
|
651
|
+
to: str4,
|
|
652
|
+
goal: str4,
|
|
653
|
+
options: z8.array(z8.object({ id: str4, label: str4 }).strict()),
|
|
639
654
|
pick: z8.enum(["one", "many", "rank", "words", ""]),
|
|
640
|
-
blocks:
|
|
655
|
+
blocks: str4
|
|
641
656
|
}).strict()),
|
|
642
|
-
lessons: z8.array(z8.object({ op: z8.enum(["remember", "revise", "withdraw"]), lesson:
|
|
657
|
+
lessons: z8.array(z8.object({ op: z8.enum(["remember", "revise", "withdraw"]), lesson: str4, text: str4, scope: str4 }).strict()),
|
|
643
658
|
/** Line handles whose words comment on Paigy itself. */
|
|
644
659
|
feedback: strs3
|
|
645
660
|
}).strict();
|
|
@@ -700,6 +715,27 @@ var TidyReplySchema = z10.object({
|
|
|
700
715
|
var TIDY_REPLY_JSON_SCHEMA = (({ $schema: _, ...rest }) => rest)(
|
|
701
716
|
zodToJsonSchema6(TidyReplySchema, { $refStrategy: "none" })
|
|
702
717
|
);
|
|
718
|
+
var HandoutReplySchema = z11.object({
|
|
719
|
+
assign: z11.array(z11.object({
|
|
720
|
+
/** The Goal's handle (G). */
|
|
721
|
+
goal: z11.string(),
|
|
722
|
+
/** The agent's handle (A). */
|
|
723
|
+
to: z11.string(),
|
|
724
|
+
/** At most ten words, naming the Goal of theirs it is most like: the reason the hand-out records. */
|
|
725
|
+
why: z11.string()
|
|
726
|
+
}).strict()),
|
|
727
|
+
/** The Goals no listed agent's work is even loosely like: Paigy starts a session for them (owner, 2026-10-24,
|
|
728
|
+
* Goal 37603006, "One per family of related Goals"). */
|
|
729
|
+
new: z11.array(z11.object({
|
|
730
|
+
/** The Goal's handle (G). */
|
|
731
|
+
goal: z11.string(),
|
|
732
|
+
/** At most ten words: why nothing active fits it. */
|
|
733
|
+
why: z11.string()
|
|
734
|
+
}).strict())
|
|
735
|
+
}).strict();
|
|
736
|
+
var HANDOUT_REPLY_JSON_SCHEMA = (({ $schema: _, ...rest }) => rest)(
|
|
737
|
+
zodToJsonSchema7(HandoutReplySchema, { $refStrategy: "none" })
|
|
738
|
+
);
|
|
703
739
|
function entryWords(entry) {
|
|
704
740
|
const content = entry.content;
|
|
705
741
|
if (content && "sealed" in content) return "";
|
|
@@ -728,20 +764,20 @@ var LIVE_MS = 3 * 6e4;
|
|
|
728
764
|
var WORKING_MS = 60 * 6e4;
|
|
729
765
|
var WORKING_TIER_MS = 2 * 60 * 6e4;
|
|
730
766
|
var RECENT_TIER_MS = 24 * 60 * 6e4;
|
|
731
|
-
var ContextSchema =
|
|
732
|
-
title:
|
|
733
|
-
description:
|
|
767
|
+
var ContextSchema = z12.object({
|
|
768
|
+
title: z12.string().min(1).describe("One-line headline of what you need (required, non-empty)."),
|
|
769
|
+
description: z12.array(z12.string().min(1)).describe(
|
|
734
770
|
"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."
|
|
735
771
|
),
|
|
736
772
|
/** THE ASK'S UNITS (3c): its context as titled units, in order. The app lists the titles and opens
|
|
737
773
|
* a body on a tap. Absent on an ask sent without units, which renders as before. */
|
|
738
|
-
units:
|
|
774
|
+
units: z12.array(z12.object({ title: z12.string(), body: z12.string() })).optional()
|
|
739
775
|
});
|
|
740
|
-
var ParticipantSchema =
|
|
741
|
-
kind:
|
|
742
|
-
id:
|
|
776
|
+
var ParticipantSchema = z12.object({
|
|
777
|
+
kind: z12.enum(["human", "agent"]),
|
|
778
|
+
id: z12.string()
|
|
743
779
|
});
|
|
744
|
-
var TransformSchema =
|
|
780
|
+
var TransformSchema = z12.enum([
|
|
745
781
|
"structure",
|
|
746
782
|
// shape intent into an answer contract; pick channel/urgency — broker `ask`, `select` shapes, `points`
|
|
747
783
|
"request_more",
|
|
@@ -757,13 +793,13 @@ var TransformSchema = z11.enum([
|
|
|
757
793
|
"summarize"
|
|
758
794
|
// reduce volume, keep decision value — 30-turn cap, spoken briefing
|
|
759
795
|
]);
|
|
760
|
-
var VisualSchema =
|
|
761
|
-
url:
|
|
762
|
-
label:
|
|
796
|
+
var VisualSchema = z12.object({
|
|
797
|
+
url: z12.string().url(),
|
|
798
|
+
label: z12.string().optional()
|
|
763
799
|
});
|
|
764
|
-
var NotifyLevelSchema =
|
|
765
|
-
var SelectShapeSchema =
|
|
766
|
-
var ReceiptEventSchema =
|
|
800
|
+
var NotifyLevelSchema = z12.enum(["inbox", "push", "banner", "call"]);
|
|
801
|
+
var SelectShapeSchema = z12.enum(["one", "many", "rank", "confirm", "text"]);
|
|
802
|
+
var ReceiptEventSchema = z12.enum([
|
|
767
803
|
"delivered",
|
|
768
804
|
// the bundle reached the recipient at some level
|
|
769
805
|
"seen",
|
|
@@ -793,47 +829,47 @@ var ReceiptEventSchema = z11.enum([
|
|
|
793
829
|
// be rewound by a writer that forgot to advance it.
|
|
794
830
|
"restarted"
|
|
795
831
|
]);
|
|
796
|
-
var AttentionSchema =
|
|
832
|
+
var AttentionSchema = z12.object({
|
|
797
833
|
urgency: NotifyLevelSchema,
|
|
798
834
|
/** The required answer shape, or null for a plain notify that asks nothing back. */
|
|
799
835
|
select: SelectShapeSchema.nullable(),
|
|
800
836
|
/** Coverage contract (#396) — points the answer must address; null = none declared. */
|
|
801
|
-
points:
|
|
837
|
+
points: z12.array(z12.string()).nullable(),
|
|
802
838
|
/** Whether the ask blocks the sender — what lets arbitration escalate it on silence. */
|
|
803
|
-
blocking:
|
|
839
|
+
blocking: z12.boolean(),
|
|
804
840
|
/** Reserved (docs/model/model.md lists it): a response deadline. No row column yet — a later Phase 2
|
|
805
841
|
* slice wires it; optional so today's rows/callers project cleanly. */
|
|
806
|
-
deadline:
|
|
842
|
+
deadline: z12.string().datetime().nullable().optional()
|
|
807
843
|
});
|
|
808
|
-
var NotifyRequestFields =
|
|
844
|
+
var NotifyRequestFields = z12.object({
|
|
809
845
|
/** Plaintext message content. Present on the plaintext path (today's shape);
|
|
810
846
|
* ABSENT on the E2EE path, where the sealed `envelope` below carries it. The
|
|
811
847
|
* superRefine at the bottom enforces exactly one of the two. */
|
|
812
848
|
context: ContextSchema.optional(),
|
|
813
|
-
options:
|
|
849
|
+
options: z12.array(OptionSchema.omit({ id: true }).extend({ label: z12.string().trim().min(1).max(1e3) }).strict()).min(OPTIONS_MIN).max(OPTIONS_MAX).optional().describe(
|
|
814
850
|
"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)."
|
|
815
851
|
),
|
|
816
|
-
points:
|
|
852
|
+
points: z12.array(z12.string().min(1)).optional().describe(
|
|
817
853
|
"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."
|
|
818
854
|
),
|
|
819
|
-
visuals:
|
|
855
|
+
visuals: z12.array(VisualSchema).optional().describe(
|
|
820
856
|
"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."
|
|
821
857
|
),
|
|
822
858
|
/** Git repo the agent is working in ("owner/name"). Local MCP fills this from the checkout — omit unless overriding. */
|
|
823
|
-
repo:
|
|
859
|
+
repo: z12.string().optional(),
|
|
824
860
|
/** Git branch the agent is on. Local MCP fills this from the checkout — omit unless overriding. */
|
|
825
|
-
branch:
|
|
861
|
+
branch: z12.string().optional(),
|
|
826
862
|
/** Continue an existing conversation — the id of any notification in it (its root
|
|
827
863
|
* is the conversation's identity). Omitted = start a new conversation. Renamed
|
|
828
864
|
* from `parentId` (2026-08-03): one linkage system, the parent; the API edge
|
|
829
865
|
* still accepts the old name from older clients. */
|
|
830
|
-
parentId:
|
|
866
|
+
parentId: z12.string().uuid().optional(),
|
|
831
867
|
/** The durable outcome this contact advances. Optional during the notification-to-Work
|
|
832
868
|
* migration; when present, a blocking ask creates a DecisionNeed for this Work. */
|
|
833
|
-
workId:
|
|
869
|
+
workId: z12.string().uuid().optional(),
|
|
834
870
|
/** Target Goal scope. During staged migration this is accepted by the shared contract but
|
|
835
871
|
* target delivery activation remains model-gated; workId and goalId are mutually exclusive. */
|
|
836
|
-
goalId:
|
|
872
|
+
goalId: z12.string().uuid().optional(),
|
|
837
873
|
urgency: NotifyLevelSchema.default("inbox").describe(
|
|
838
874
|
"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."
|
|
839
875
|
),
|
|
@@ -841,7 +877,7 @@ var NotifyRequestFields = z11.object({
|
|
|
841
877
|
* visible and marks it needs_input. Renamed from the old `parentId` (2026-08-03)
|
|
842
878
|
* when `parentId` became the conversation handle: `parentId` says WHERE, this
|
|
843
879
|
* says HOW. */
|
|
844
|
-
clarifies:
|
|
880
|
+
clarifies: z12.string().optional(),
|
|
845
881
|
select: SelectShapeSchema.optional().describe(
|
|
846
882
|
"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."
|
|
847
883
|
),
|
|
@@ -855,20 +891,20 @@ var NotifyRequestFields = z11.object({
|
|
|
855
891
|
// (docs/brain/broker/agenda-design.md) — not by a wire cap the agent has to pre-summarize under.
|
|
856
892
|
// Owner, 2026-07-28: "our actual limitation on how long something is to the user should
|
|
857
893
|
// come from the broker splitting and summarizing." The cap that remains is a size guard.
|
|
858
|
-
ask:
|
|
894
|
+
ask: z12.string().min(1).max(1e4).optional().describe(
|
|
859
895
|
'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.'
|
|
860
896
|
),
|
|
861
|
-
needs:
|
|
897
|
+
needs: z12.array(z12.string().min(1)).optional().describe(
|
|
862
898
|
"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."
|
|
863
899
|
),
|
|
864
|
-
urgencyHint:
|
|
900
|
+
urgencyHint: z12.enum(["whenever", "soon", "now"]).optional().describe(
|
|
865
901
|
"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."
|
|
866
902
|
),
|
|
867
903
|
/** #575: the ONE self-report that replaces urgencyHint + blocking — what happens
|
|
868
904
|
* to the agent's work while it waits. Normalized server-side into those two
|
|
869
905
|
* fields (normalizeWaiting) so everything downstream is untouched; explicit
|
|
870
906
|
* urgencyHint/blocking win when both are sent. */
|
|
871
|
-
waiting:
|
|
907
|
+
waiting: z12.enum(["none", "soft", "hard"]).optional().describe(
|
|
872
908
|
"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."
|
|
873
909
|
),
|
|
874
910
|
/** Δ9b (#895): HOLD this claim so the sender can correct the plan before anyone is
|
|
@@ -876,98 +912,98 @@ var NotifyRequestFields = z11.object({
|
|
|
876
912
|
* holding by default would charge every quiet claim that minute before any agent could
|
|
877
913
|
* correct anything. Ignored for `waiting: 'hard'`: a blocking ask rings on what we have,
|
|
878
914
|
* and the enrichment can still land mid-call (#781 re-plans the unspoken tail). */
|
|
879
|
-
confirm:
|
|
915
|
+
confirm: z12.boolean().optional().describe(
|
|
880
916
|
"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'."
|
|
881
917
|
),
|
|
882
918
|
/** #575: a RELAY of the user's explicitly stated preference, never the agent's
|
|
883
919
|
* choice. Outranks waiting in both directions: 'call' rings even for a
|
|
884
920
|
* waiting:'none' "call me when it's done"; 'message' never rings even for
|
|
885
921
|
* waiting:'hard'. */
|
|
886
|
-
channel:
|
|
922
|
+
channel: z12.enum(["call", "message"]).optional().describe(
|
|
887
923
|
"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."
|
|
888
924
|
),
|
|
889
|
-
confirmStyle:
|
|
925
|
+
confirmStyle: z12.enum(["yesno", "approve"]).default("yesno").describe(
|
|
890
926
|
"Labels for a select:'confirm' paige \u2014 'yesno' (Yes/No) or 'approve' (Approve/Deny). Ignored unless select is 'confirm'."
|
|
891
927
|
),
|
|
892
|
-
blocking:
|
|
928
|
+
blocking: z12.boolean().default(false).describe(
|
|
893
929
|
"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."
|
|
894
930
|
)
|
|
895
931
|
});
|
|
896
932
|
var NotifyRequestSchema = NotifyRequestFields.superRefine((r, ctx) => {
|
|
897
|
-
if (r.workId && r.goalId) ctx.addIssue({ code:
|
|
933
|
+
if (r.workId && r.goalId) ctx.addIssue({ code: z12.ZodIssueCode.custom, path: ["goalId"], message: "pass goalId or workId, not both" });
|
|
898
934
|
if (r.ask !== void 0) {
|
|
899
935
|
for (const f of ["context", "select", "points"]) {
|
|
900
936
|
if (r[f] !== void 0)
|
|
901
|
-
ctx.addIssue({ code:
|
|
937
|
+
ctx.addIssue({ code: z12.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.` });
|
|
902
938
|
}
|
|
903
939
|
return;
|
|
904
940
|
}
|
|
905
941
|
if (r.needs !== void 0 || r.urgencyHint !== void 0)
|
|
906
|
-
ctx.addIssue({ code:
|
|
942
|
+
ctx.addIssue({ code: z12.ZodIssueCode.custom, path: ["needs"], message: "needs/urgencyHint belong to the simplified `ask` form \u2014 with a shaped request use points/urgency" });
|
|
907
943
|
if (!r.context)
|
|
908
|
-
ctx.addIssue({ code:
|
|
944
|
+
ctx.addIssue({ code: z12.ZodIssueCode.custom, path: ["context"], message: "context is required (plaintext path)" });
|
|
909
945
|
if (!r.select)
|
|
910
|
-
ctx.addIssue({ code:
|
|
946
|
+
ctx.addIssue({ code: z12.ZodIssueCode.custom, path: ["select"], message: "select is required on the shaped form" });
|
|
911
947
|
const needsOptions = r.select === "one" || r.select === "many" || r.select === "rank";
|
|
912
948
|
if (needsOptions && !r.options?.length)
|
|
913
|
-
ctx.addIssue({ code:
|
|
949
|
+
ctx.addIssue({ code: z12.ZodIssueCode.custom, path: ["options"], message: `select:'${r.select}' requires options` });
|
|
914
950
|
if (!needsOptions && r.options?.length)
|
|
915
|
-
ctx.addIssue({ code:
|
|
951
|
+
ctx.addIssue({ code: z12.ZodIssueCode.custom, path: ["options"], message: `select:'${r.select}' takes no options` });
|
|
916
952
|
});
|
|
917
|
-
var NotifyStatusSchema =
|
|
918
|
-
var AgentStateSchema =
|
|
919
|
-
var TurnSchema =
|
|
920
|
-
prompt:
|
|
921
|
-
reply:
|
|
953
|
+
var NotifyStatusSchema = z12.enum(["pending", "answered", "ignored"]);
|
|
954
|
+
var AgentStateSchema = z12.enum(["idle", "in_progress", "completed", "needs_input"]);
|
|
955
|
+
var TurnSchema = z12.object({
|
|
956
|
+
prompt: z12.string(),
|
|
957
|
+
reply: z12.string()
|
|
922
958
|
});
|
|
923
|
-
var UserAnswerSchema =
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
959
|
+
var UserAnswerSchema = z12.discriminatedUnion("kind", [
|
|
960
|
+
z12.object({ kind: z12.literal("option"), optionId: z12.string(), label: z12.string().optional() }),
|
|
961
|
+
z12.object({ kind: z12.literal("text"), text: z12.string() }),
|
|
962
|
+
z12.object({ kind: z12.literal("ignored") }),
|
|
963
|
+
z12.object({ kind: z12.literal("multi"), optionIds: z12.array(z12.string()), labels: z12.array(z12.string()).optional() }),
|
|
964
|
+
z12.object({ kind: z12.literal("ranked"), optionIds: z12.array(z12.string()), labels: z12.array(z12.string()).optional() }),
|
|
965
|
+
z12.object({ kind: z12.literal("clarify"), chunks: z12.array(z12.string()).min(1) }),
|
|
966
|
+
z12.object({ kind: z12.literal("confirm"), approved: z12.boolean() }),
|
|
967
|
+
z12.object({ kind: z12.literal("turns"), turns: z12.array(TurnSchema).min(1) }),
|
|
932
968
|
/** An auto-answer derived from the user's PAST decisions (docs/brain/broker/precedent-design.md §2):
|
|
933
969
|
* delivered through the same settle/await path as a human answer, carrying the judge's
|
|
934
970
|
* derivation and the precedent ids it grew from. Always paired with a visible trail
|
|
935
971
|
* card the user can reply to — the broker never overrides the user. */
|
|
936
|
-
|
|
972
|
+
z12.object({ kind: z12.literal("precedent"), answer: z12.string(), derivation: z12.string(), sources: z12.array(z12.string()).min(1) })
|
|
937
973
|
]);
|
|
938
|
-
var IntentSchema =
|
|
974
|
+
var IntentSchema = z12.object({
|
|
939
975
|
// The full vocabulary the bot's mapper emits (mapper.INTENT_KINDS) — the schema lagged
|
|
940
976
|
// it by two ("detail", "feedback"), and because the settle handler parsed the array
|
|
941
977
|
// all-or-nothing, ONE feedback act silently dropped EVERY intent on the call,
|
|
942
978
|
// questions included. Found auditing five calls' stored feedback, 2026-08-01.
|
|
943
|
-
kind:
|
|
944
|
-
detail:
|
|
979
|
+
kind: z12.enum(["defer", "delegate", "channel", "question", "detail", "feedback", "command", "control"]),
|
|
980
|
+
detail: z12.string(),
|
|
945
981
|
/** Defer only: seconds until the callback the caller asked for, when something upstream
|
|
946
982
|
* already read the time. Nothing sets it today (#397 documented an MCP parser that was
|
|
947
983
|
* never written) — the API reads the defer's `detail` itself with `notes/when.ts`
|
|
948
984
|
* (`parseDelay`, #1292), and a value here simply wins over that reading. */
|
|
949
|
-
dueInSeconds:
|
|
985
|
+
dueInSeconds: z12.number().int().positive().optional(),
|
|
950
986
|
/** Feedback only (#812): WHICH failure the complaint names — typed by the mapper that
|
|
951
987
|
* already read the utterance, so `signals.kind` stops defaulting to
|
|
952
988
|
* 'other' on every row. A table that records that something was wrong and nothing
|
|
953
989
|
* about what cannot answer "is the bot looping less this week?". */
|
|
954
|
-
fault:
|
|
990
|
+
fault: z12.enum(["loop", "unanswered", "overridden", "misheard", "slow", "other"]).optional()
|
|
955
991
|
});
|
|
956
|
-
var RideAlongSchema =
|
|
992
|
+
var RideAlongSchema = z12.object({
|
|
957
993
|
/** The note this came from — assign/clarify/close it through /api/notes/:id. */
|
|
958
|
-
noteId:
|
|
994
|
+
noteId: z12.string(),
|
|
959
995
|
/** What to do, in the owner's own words (the note's headline). Never model-rewritten. */
|
|
960
|
-
text:
|
|
996
|
+
text: z12.string(),
|
|
961
997
|
/** The thread to report back on, when the note was dispatched over the request rail. */
|
|
962
|
-
parentId:
|
|
998
|
+
parentId: z12.string().nullable()
|
|
963
999
|
});
|
|
964
|
-
var AwaitItemSchema =
|
|
965
|
-
|
|
966
|
-
type:
|
|
967
|
-
parentId:
|
|
968
|
-
notificationId:
|
|
969
|
-
workId:
|
|
970
|
-
decisionId:
|
|
1000
|
+
var AwaitItemSchema = z12.discriminatedUnion("type", [
|
|
1001
|
+
z12.object({
|
|
1002
|
+
type: z12.literal("reply"),
|
|
1003
|
+
parentId: z12.string(),
|
|
1004
|
+
notificationId: z12.string(),
|
|
1005
|
+
workId: z12.string().uuid().optional(),
|
|
1006
|
+
decisionId: z12.string().uuid().optional(),
|
|
971
1007
|
answer: UserAnswerSchema,
|
|
972
1008
|
/** WHAT THE AGENT CANNOT KNOW FROM THE FIELDS BESIDE IT (owner, 2026-09-04, issue
|
|
973
1009
|
* #1537). One line, built from the record: the ask and the caller's reply VERBATIM,
|
|
@@ -977,111 +1013,126 @@ var AwaitItemSchema = z11.discriminatedUnion("type", [
|
|
|
977
1013
|
* "call me back after you merge" in their own words decides for itself what to do,
|
|
978
1014
|
* and now knows exactly which call to make. Absent when either half is missing —
|
|
979
1015
|
* a sentence with a hole in it is worse than no sentence. */
|
|
980
|
-
note:
|
|
1016
|
+
note: z12.string().optional(),
|
|
981
1017
|
/** The call record rendered for THIS agent (`docs/brain/voice/record-design.md`): the words the
|
|
982
1018
|
* shaped answer was mapped from, filtered to its own claims. There is no second list
|
|
983
1019
|
* of labels beside it — the acts went 2026-09-04 and `intents` went with them (owner,
|
|
984
1020
|
* 2026-09-04): the agent reads the sentence and decides. */
|
|
985
|
-
transcript:
|
|
1021
|
+
transcript: z12.string().optional(),
|
|
986
1022
|
/** Coverage report (#396), when the ask declared `points`: which of them this
|
|
987
1023
|
* answer addressed. Missing points = re-ask or proceed knowingly partial. */
|
|
988
|
-
covered:
|
|
1024
|
+
covered: z12.array(z12.string()).optional(),
|
|
989
1025
|
/** Ride-alongs (RideAlongSchema) — pending work for you, attached to the moment you
|
|
990
1026
|
* became free. Only `reply` and `idle` carry it: those are the two outcomes that
|
|
991
1027
|
* END a wait. `remind`, `superseded` and `turn` are mid-flight, and handing an
|
|
992
1028
|
* agent a side-quest while it is still holding the line is how the main thing gets
|
|
993
1029
|
* dropped. Absent/empty = nothing owed. */
|
|
994
|
-
also:
|
|
1030
|
+
also: z12.array(RideAlongSchema).optional()
|
|
995
1031
|
}),
|
|
996
|
-
|
|
997
|
-
type:
|
|
998
|
-
parentId:
|
|
999
|
-
notificationId:
|
|
1000
|
-
remindAt:
|
|
1032
|
+
z12.object({
|
|
1033
|
+
type: z12.literal("remind"),
|
|
1034
|
+
parentId: z12.string(),
|
|
1035
|
+
notificationId: z12.string(),
|
|
1036
|
+
remindAt: z12.string().datetime({ offset: true }),
|
|
1001
1037
|
/** Seconds until remindAt, server-computed — pass straight to ScheduleWakeup. */
|
|
1002
|
-
remindInSeconds:
|
|
1038
|
+
remindInSeconds: z12.number()
|
|
1003
1039
|
}),
|
|
1004
1040
|
/** The awaited ask was REPLACED by a newer notification on its thread (e.g. a
|
|
1005
1041
|
* post-feedback revision, #633) — the user will never answer this id. Stop
|
|
1006
1042
|
* awaiting it; the live ask is the thread's newest turn (await that one, or
|
|
1007
1043
|
* re-orient via contact({})). */
|
|
1008
|
-
|
|
1009
|
-
type:
|
|
1010
|
-
parentId:
|
|
1011
|
-
notificationId:
|
|
1044
|
+
z12.object({
|
|
1045
|
+
type: z12.literal("superseded"),
|
|
1046
|
+
parentId: z12.string(),
|
|
1047
|
+
notificationId: z12.string()
|
|
1012
1048
|
}),
|
|
1013
1049
|
/** A LIVE call's turn, streamed as it lands (#783). PROVISIONAL: the user can still
|
|
1014
1050
|
* revise any of these until the final reply arrives — partial = intelligence,
|
|
1015
1051
|
* settled = authorization. Use it to PREPARE (fetch, draft, warm), never to act
|
|
1016
1052
|
* irreversibly. If `acts` carries a question aimed at you and you know the answer,
|
|
1017
1053
|
* contact on the same thread right away — the caller hears it on the same call. */
|
|
1018
|
-
|
|
1019
|
-
type:
|
|
1020
|
-
notificationId:
|
|
1021
|
-
inFlight:
|
|
1022
|
-
turn:
|
|
1023
|
-
idx:
|
|
1024
|
-
prompt:
|
|
1025
|
-
reply:
|
|
1026
|
-
acts:
|
|
1054
|
+
z12.object({
|
|
1055
|
+
type: z12.literal("partial"),
|
|
1056
|
+
notificationId: z12.string(),
|
|
1057
|
+
inFlight: z12.literal(true),
|
|
1058
|
+
turn: z12.object({
|
|
1059
|
+
idx: z12.number(),
|
|
1060
|
+
prompt: z12.string(),
|
|
1061
|
+
reply: z12.string(),
|
|
1062
|
+
acts: z12.array(IntentSchema).nullable().optional()
|
|
1027
1063
|
})
|
|
1028
1064
|
}),
|
|
1029
|
-
|
|
1030
|
-
type:
|
|
1031
|
-
also:
|
|
1065
|
+
z12.object({
|
|
1066
|
+
type: z12.literal("idle"),
|
|
1067
|
+
also: z12.array(RideAlongSchema).optional(),
|
|
1032
1068
|
/** Is a call live for this agent's user right now? The SDK polls the partial stream
|
|
1033
1069
|
* (#783) between idle ticks ONLY while this is not `false` — a partial can only exist
|
|
1034
1070
|
* during a live call, and polling for one on a banner/message was a wasted HTTP call +
|
|
1035
1071
|
* 3 queries on every idle tick of every waiting agent (~80% of all traffic at scale).
|
|
1036
1072
|
* Absent = an older API → the SDK keeps polling, exactly as before. */
|
|
1037
|
-
inFlight:
|
|
1073
|
+
inFlight: z12.boolean().optional()
|
|
1038
1074
|
})
|
|
1039
1075
|
]);
|
|
1040
|
-
var VoiceKeySchema =
|
|
1041
|
-
var AgendaTurnSchema =
|
|
1076
|
+
var VoiceKeySchema = z12.enum(["rachel", "george", "jessica", "brian", "lily"]);
|
|
1077
|
+
var AgendaTurnSchema = z12.object({
|
|
1042
1078
|
/** THE TURN'S IDENTITY (the first-sentence stream, 2026-09-09): the brain call that wrote
|
|
1043
1079
|
* it and its place in that reply — `<brainCallId>:<index>`, with `:p` on the first
|
|
1044
1080
|
* sentence a re-plan publishes ahead of the rest. A turn is spoken once, by this id: the
|
|
1045
1081
|
* completion of a streamed re-plan carries the published sentence again, and the walk
|
|
1046
1082
|
* drops what it already said by identity, never by the API's guess of what was polled.
|
|
1047
1083
|
* Absent on plans nothing streams (a ring plan, a floor). */
|
|
1048
|
-
id:
|
|
1084
|
+
id: z12.string().optional(),
|
|
1049
1085
|
/** Twin coverage (#1089): sibling claim ids this asking turn's answer ALSO settles —
|
|
1050
1086
|
* the planner declares duplicates instead of asking them twice. */
|
|
1051
|
-
coveredIds:
|
|
1087
|
+
coveredIds: z12.array(z12.string()).optional(),
|
|
1052
1088
|
/** The spoken sentences of the turn, in order. No count: how long a turn is is the brain's call
|
|
1053
1089
|
* (owner, 2026-09-25), and a count here refused whole plans. */
|
|
1054
|
-
info:
|
|
1090
|
+
info: z12.array(z12.string().min(1)).default([]),
|
|
1055
1091
|
/** THE ID OF EACH SENTENCE, when the plan names them (turns.md): a talker message's sentences are its
|
|
1056
1092
|
* `info`, one piece each, and `units[i]` is the id the bot's line receipt carries for `info[i]`
|
|
1057
1093
|
* (`<cycle>:<key>:<n>`), so what was heard is known per sentence. Absent on every other turn. */
|
|
1058
|
-
units:
|
|
1059
|
-
question:
|
|
1094
|
+
units: z12.array(z12.string().min(1)).optional(),
|
|
1095
|
+
question: z12.string().min(1).nullable(),
|
|
1060
1096
|
/** True on the one turn carrying the agent's own declared question. */
|
|
1061
|
-
asks:
|
|
1097
|
+
asks: z12.boolean().optional(),
|
|
1062
1098
|
/** The claim this turn belongs to (#781) — the RETURN identity: answers route by it.
|
|
1063
1099
|
* Absent on a single-claim plan (the session's own claim) and on shared context turns,
|
|
1064
1100
|
* which route nothing. */
|
|
1065
|
-
claimId:
|
|
1101
|
+
claimId: z12.string().optional(),
|
|
1066
1102
|
/** The claim's voice key (#462) — the OUTBOUND identity, audible who-is-asking. */
|
|
1067
|
-
voice:
|
|
1103
|
+
voice: z12.string().optional(),
|
|
1068
1104
|
/** The claim's AGENT NAME (#838) — the spoken identity. A voice alone doesn't say
|
|
1069
1105
|
* whose request this is: an item that folded in from another agent arrived as a bare
|
|
1070
1106
|
* non-sequitur ("First real production sign-in is yours to make whenever you want.")
|
|
1071
1107
|
* and the owner answered "What?". The bot names the agent before its first turn. */
|
|
1072
|
-
agent:
|
|
1108
|
+
agent: z12.string().optional(),
|
|
1073
1109
|
/** The claim's agent by ID — the pairing's connection id (`notifications.token_id`), the
|
|
1074
1110
|
* same id a face is minted from. A name is not an identity: two pairings may be called
|
|
1075
1111
|
* "Claude", and a name cannot be joined on. The record's entries carry it (`agent_id`)
|
|
1076
1112
|
* so "who said that" survives the call, and it rides PER TURN because a coalesced call
|
|
1077
1113
|
* speaks for several agents — the turn is the only place that knows which. */
|
|
1078
|
-
agentId:
|
|
1114
|
+
agentId: z12.string().optional(),
|
|
1079
1115
|
/** ITS QUESTION IS ON THE TABLE (#3292): a talker line about a question the person owes. The walk tells
|
|
1080
1116
|
* the phone (`asking`, so the agenda goes gold and its options show) without treating the line as a
|
|
1081
1117
|
* question turn — the talker owns re-asking and the waits, so `question` stays null. */
|
|
1082
|
-
onTable:
|
|
1118
|
+
onTable: z12.boolean().optional(),
|
|
1119
|
+
/** THE CARRIED ITEM THIS LINE TELLS (Goal 2a1e50eb, owner 2026-10-14: "Build the whole design") — a
|
|
1120
|
+
* request the Call carries that asks NOTHING: a report, a progress note, another agent's waiting news.
|
|
1121
|
+
* Its request Entry id, so the phone can make that agenda row the current one while it is read
|
|
1122
|
+
* (`telling` on the `turn` topic, `docs/clients/app/walk/design.md` §11).
|
|
1123
|
+
*
|
|
1124
|
+
* A FIELD OF ITS OWN, NEVER `claimId`: the claim is the RETURN identity — answers route by it and the
|
|
1125
|
+
* record tags the line with it (`workId`) — and an answer must never route to an Entry that asks
|
|
1126
|
+
* nothing. Absent on a turn speaking for a question (`claimId` says that) and on one speaking for no
|
|
1127
|
+
* carried item at all (an opener, a sign-off, Paigy's own line). */
|
|
1128
|
+
telling: z12.string().optional(),
|
|
1129
|
+
/** PAIGY'S OWN LINE (owner, 2026-10-15; calls ed2cbdce, ad50ad25): a turn that speaks for no item -- an
|
|
1130
|
+
* opener, a sign-off, a reply about nothing an agent asked or told -- is recorded as Paigy's, not as the
|
|
1131
|
+
* agent that rang. Absent on every turn that speaks for an item (`agentId` names whose), and on plans
|
|
1132
|
+
* from before it: a bot that does not know it records the ringing agent, as before. */
|
|
1133
|
+
speaksFor: z12.literal("paigy").optional(),
|
|
1083
1134
|
select: SelectShapeSchema.optional(),
|
|
1084
|
-
options:
|
|
1135
|
+
options: z12.array(OptionSchema.omit({ id: true })).optional(),
|
|
1085
1136
|
/* `pace` STOOD HERE (#826). A turn could carry seconds and the model chose them. The walk
|
|
1086
1137
|
paces itself now — a short beat between the sentences of a turn, the longer one at its end
|
|
1087
1138
|
(owner, 2026-09-30: "remove the bot deciding pace") — and it does that where the words are
|
|
@@ -1090,58 +1141,58 @@ var AgendaTurnSchema = z11.object({
|
|
|
1090
1141
|
/** Whether the walk WAITS for an answer before moving on. Absent = derived as today
|
|
1091
1142
|
* (a question blocks, context flows). blocking:false on a question = ask and move
|
|
1092
1143
|
* on, the claim stays pending; blocking:true on context = hold for a reply. */
|
|
1093
|
-
blocking:
|
|
1144
|
+
blocking: z12.boolean().optional(),
|
|
1094
1145
|
/** SPOKEN ONLY IF THEY SAY NOTHING (owner, 2026-10-01, call 812de935: "you're gonna re-ask, but it
|
|
1095
1146
|
* shouldn't be the same words … more like, hey, are you still there, or are you able to answer, or
|
|
1096
1147
|
* would you need more information"). The walk holds this turn out of its queue; at the queue's end it
|
|
1097
1148
|
* listens for the last word, and only if that listen is silent is this turn said and asked. If they
|
|
1098
1149
|
* speak, it is dropped and their words are taken like any reply. */
|
|
1099
|
-
ifSilent:
|
|
1150
|
+
ifSilent: z12.boolean().optional()
|
|
1100
1151
|
});
|
|
1101
1152
|
var CLAIM_STALE_MS = 30 * 6e4;
|
|
1102
|
-
var CallQuestionSchema =
|
|
1103
|
-
id:
|
|
1104
|
-
entryId:
|
|
1105
|
-
title:
|
|
1106
|
-
state:
|
|
1107
|
-
answer:
|
|
1153
|
+
var CallQuestionSchema = z12.object({
|
|
1154
|
+
id: z12.string(),
|
|
1155
|
+
entryId: z12.string(),
|
|
1156
|
+
title: z12.string(),
|
|
1157
|
+
state: z12.enum(["open", "answered"]),
|
|
1158
|
+
answer: z12.string().nullable(),
|
|
1108
1159
|
/** WHO ASKED IT (owner, 2026-09-23, Goal a345e906: each agenda row wears its agent's face) — the
|
|
1109
1160
|
* request Entry's author, as the same three facts the item's own `tokenId`/`name`/`voice`
|
|
1110
1161
|
* carry for the call's one agent, so the phone draws it with the same seed. Absent when the
|
|
1111
1162
|
* author is not an agent this account holds (unpaired since, or a person). */
|
|
1112
|
-
agent:
|
|
1163
|
+
agent: z12.object({ tokenId: z12.string(), name: z12.string(), voice: VoiceKeySchema.optional() }).optional(),
|
|
1113
1164
|
/** ITS OPTIONS, WHEN THERE IS SOMETHING TO SEE (owner, 2026-09-25: "Yes, add it"): the options
|
|
1114
1165
|
* its need offers, exactly as its own card carries them, present only when one of them has a
|
|
1115
1166
|
* preview (`html` or `image`). The call screen opens them from the agenda row, so a preview is
|
|
1116
1167
|
* never re-sent as a second card to be seen mid-call. Words-only options are `choices`. */
|
|
1117
|
-
options:
|
|
1168
|
+
options: z12.array(OptionSchema).optional(),
|
|
1118
1169
|
/** ITS OPTIONS WHEN THEY ARE WORDS (owner, 2026-10-02, on a call: "whenever there are pre-made
|
|
1119
1170
|
* options … now for a checklist, we should also show them on the screen"; design C, 2026-10-08):
|
|
1120
1171
|
* numbered chips above the call's controls, so a checklist is never only something read aloud. A
|
|
1121
1172
|
* field of its own so `options` keeps meaning "previews": a phone on an older bundle opens the
|
|
1122
1173
|
* preview layout for any `options`, and must see exactly what it did. */
|
|
1123
|
-
choices:
|
|
1174
|
+
choices: z12.array(OptionSchema).optional(),
|
|
1124
1175
|
/** HOW MANY MAY BE PICKED, beside its `choices`: one, any (`many`) or an order (`rank`). */
|
|
1125
|
-
select:
|
|
1176
|
+
select: z12.enum(["one", "many", "rank"]).optional()
|
|
1126
1177
|
});
|
|
1127
|
-
var InboxItemSchema =
|
|
1128
|
-
id:
|
|
1129
|
-
tokenId:
|
|
1178
|
+
var InboxItemSchema = z12.object({
|
|
1179
|
+
id: z12.string(),
|
|
1180
|
+
tokenId: z12.string().optional(),
|
|
1130
1181
|
status: NotifyStatusSchema,
|
|
1131
1182
|
context: ContextSchema,
|
|
1132
|
-
options:
|
|
1183
|
+
options: z12.array(OptionSchema).optional(),
|
|
1133
1184
|
/** The ask's declared coverage points (#396), when the agent sent them. */
|
|
1134
|
-
points:
|
|
1185
|
+
points: z12.array(z12.string()).optional(),
|
|
1135
1186
|
/** Does this claim want an ANSWER, or is it telling you something? Written per row from
|
|
1136
1187
|
* `requestAsks` — the agent's own declaration, not a guess. `false` is what earns a card
|
|
1137
1188
|
* its acknowledge affordance: without it a status update offers a text box and a dismiss,
|
|
1138
1189
|
* and neither of those is "got it" (owner, 2026-08-10). */
|
|
1139
|
-
asks:
|
|
1190
|
+
asks: z12.boolean().optional(),
|
|
1140
1191
|
/** When a live process last pulsed for this row's agent — the liveness input for
|
|
1141
1192
|
* "working requires a pulse" (#928): the list said "Working…" from agent_state alone
|
|
1142
1193
|
* while the party called the same dead claim stalled. Absent = no token/no data,
|
|
1143
1194
|
* which must never CLAIM stalled. */
|
|
1144
|
-
lastSeenAt:
|
|
1195
|
+
lastSeenAt: z12.string().optional(),
|
|
1145
1196
|
/** WHEN THE AGENT LAST SAID ANYTHING ABOUT THIS CLAIM — the newest `agent_state` row in
|
|
1146
1197
|
* the `notification_events` ledger (trigger-written since 20260621010000, so every row a
|
|
1147
1198
|
* user can see has one). The age input for `CLAIM_STALE_MS`, and it has to be this rather
|
|
@@ -1151,7 +1202,7 @@ var InboxItemSchema = z11.object({
|
|
|
1151
1202
|
* work. Reading the row's birth as the claim's age brands that "No update in 8h" the
|
|
1152
1203
|
* instant the agent picks it up (#997). Absent = pre-trigger row; fall back to
|
|
1153
1204
|
* `createdAt`. */
|
|
1154
|
-
agentStateAt:
|
|
1205
|
+
agentStateAt: z12.string().datetime().optional(),
|
|
1155
1206
|
/** THE QUESTIONS A CALL CARRIES — the call screen's agenda spine (docs/clients/app/walk/design.md §11, owner
|
|
1156
1207
|
* 2026-09-22). One per DecisionNeed on the Call, in the Call's order, answered or open (a
|
|
1157
1208
|
* superseded or cancelled need is no longer a question anyone is asked). Present only on a
|
|
@@ -1165,40 +1216,40 @@ var InboxItemSchema = z11.object({
|
|
|
1165
1216
|
* `turn` topic (`asking`, `settled`), because the bot never sees a DecisionNeed id. `title` is
|
|
1166
1217
|
* the card's own concise heading; `answer` the accepted answer in words, null while open. It
|
|
1167
1218
|
* REPLACED `agenda` (turns), which nothing ever filled. */
|
|
1168
|
-
questions:
|
|
1219
|
+
questions: z12.array(CallQuestionSchema).optional(),
|
|
1169
1220
|
/** The same call carrying order, including request Entries with no DecisionNeed as reports.
|
|
1170
1221
|
* Additive: questions stays decision-only for every other surface and older bundles. */
|
|
1171
|
-
callItems:
|
|
1172
|
-
visuals:
|
|
1222
|
+
callItems: z12.array(CallQuestionSchema.extend({ state: z12.enum(["open", "answered", "report"]), acknowledged: z12.boolean().optional() })).optional(),
|
|
1223
|
+
visuals: z12.array(VisualSchema).optional(),
|
|
1173
1224
|
/** The connected agent's name (the single pairing name — user-typed, or the
|
|
1174
1225
|
* agent's suggestion, or a default silly name). */
|
|
1175
|
-
name:
|
|
1226
|
+
name: z12.string(),
|
|
1176
1227
|
/** The pairing's assigned voice (#462); absent = the default voice. */
|
|
1177
1228
|
voice: VoiceKeySchema.optional(),
|
|
1178
|
-
repo:
|
|
1179
|
-
branch:
|
|
1180
|
-
createdAt:
|
|
1181
|
-
snoozedUntil:
|
|
1229
|
+
repo: z12.string().optional(),
|
|
1230
|
+
branch: z12.string().optional(),
|
|
1231
|
+
createdAt: z12.string().datetime(),
|
|
1232
|
+
snoozedUntil: z12.string().datetime().optional(),
|
|
1182
1233
|
agentState: AgentStateSchema.default("idle"),
|
|
1183
1234
|
/** Whose action the item is waiting on: "you" = an agent asked you (the default,
|
|
1184
1235
|
* every agent→user notification); "agent" = you sent a request and it's awaiting the
|
|
1185
1236
|
* agent (held in the inbox until the agent replies on the thread). */
|
|
1186
|
-
turn:
|
|
1237
|
+
turn: z12.enum(["you", "agent"]).default("you"),
|
|
1187
1238
|
/** Hard error reason on an awaiting request (turn="agent") — the wake failed to reach
|
|
1188
1239
|
* the agent (provider-agnostic; set server-side). Absent = no hard error. Drives the inbox
|
|
1189
1240
|
* error badge + Retry. */
|
|
1190
|
-
error:
|
|
1241
|
+
error: z12.string().optional(),
|
|
1191
1242
|
/** WHEN THIS AGENT WORK WENT QUIET (turn="agent"), by the one rule (`coldSince`: three days
|
|
1192
1243
|
* with nothing said), or absent while it is not stalled. The inbox's stalled badge reads
|
|
1193
1244
|
* this and nothing else (2026-09-23: a 3-minute age rule badged every live Goal stalled,
|
|
1194
1245
|
* and "dismiss the stalled ones" cancelled 37 pieces of live work). */
|
|
1195
|
-
cold:
|
|
1196
|
-
clarifies:
|
|
1246
|
+
cold: z12.string().datetime().optional(),
|
|
1247
|
+
clarifies: z12.string().optional(),
|
|
1197
1248
|
/** THIS CARD'S QUESTION IS ON A LIVE CALL (owner, 2026-09-24: "Mark it while the call is
|
|
1198
1249
|
* live"). Present only while an open Call Delivery carries the card's request Entry — read
|
|
1199
1250
|
* off the same open list the card came from, so it clears when the Call does. A card is the
|
|
1200
1251
|
* backup for a call not taken; while the call has it, the call is where it is answered. */
|
|
1201
|
-
onCall:
|
|
1252
|
+
onCall: z12.literal(true).optional(),
|
|
1202
1253
|
/** THE RING, ON THE ITEM (docs/clients/app/walk/design.md §12 §17, #2251): the last ring on this card was
|
|
1203
1254
|
* declined, and what the ladder will do next — read off the cron's own row, never computed
|
|
1204
1255
|
* on the phone. Present only while a `declined` receipt stands on the card's last Call.
|
|
@@ -1208,31 +1259,46 @@ var InboxItemSchema = z11.object({
|
|
|
1208
1259
|
* It replaced `gaveUp` (deleted 2026-09-22): "the ladder spent" was a boolean the projection
|
|
1209
1260
|
* never set, and it is `nextRingAt === null` here — the party's *Missed you* (`party/dress.ts`)
|
|
1210
1261
|
* and the roster's `unreached` read `declinedAt`, and stand while it does. */
|
|
1211
|
-
ring:
|
|
1212
|
-
declinedAt:
|
|
1213
|
-
anchorAt:
|
|
1214
|
-
nextRingAt:
|
|
1215
|
-
step:
|
|
1262
|
+
ring: z12.object({
|
|
1263
|
+
declinedAt: z12.string().datetime(),
|
|
1264
|
+
anchorAt: z12.string().datetime(),
|
|
1265
|
+
nextRingAt: z12.string().datetime().nullable(),
|
|
1266
|
+
step: z12.number().int()
|
|
1216
1267
|
}).optional(),
|
|
1217
1268
|
/** Why this arrived the way it did, read back off the delivery receipt (`notify/why.ts`).
|
|
1218
1269
|
* Absent for anything never delivered through a push, and for older rows written before
|
|
1219
1270
|
* the reason was recorded. Deliberately a debug affordance, shown small (owner,
|
|
1220
1271
|
* 2026-08-07) — its real job is to give "this didn't need a call" something to be
|
|
1221
1272
|
* feedback ABOUT. */
|
|
1222
|
-
why:
|
|
1273
|
+
why: z12.object({
|
|
1223
1274
|
asked: NotifyLevelSchema,
|
|
1224
1275
|
got: NotifyLevelSchema,
|
|
1225
|
-
because:
|
|
1226
|
-
line:
|
|
1276
|
+
because: z12.enum(["unresponsive", "dismissed", "not_permitted", "silent", "coalesced", "agent_capped", "unplanned", "learned_raise"]).optional(),
|
|
1277
|
+
line: z12.string()
|
|
1227
1278
|
}).optional(),
|
|
1228
|
-
select:
|
|
1229
|
-
confirmStyle:
|
|
1279
|
+
select: z12.enum(["one", "many", "rank", "confirm", "text"]).default("one"),
|
|
1280
|
+
confirmStyle: z12.enum(["yesno", "approve"]).default("yesno").describe(
|
|
1230
1281
|
"Labels for a select:'confirm' paige \u2014 'yesno' (Yes/No) or 'approve' (Approve/Deny). Ignored unless select is 'confirm'."
|
|
1231
1282
|
),
|
|
1232
1283
|
/** Real downstream work is stuck behind this one — set by the agent, independent of
|
|
1233
1284
|
* urgency (see the main README's "premier use case" + docs/delivery/notify/states.md). Drives the
|
|
1234
1285
|
* inbox's blocking badge and the extra confirm step before dismissing it. */
|
|
1235
|
-
blocking:
|
|
1286
|
+
blocking: z12.boolean().default(false),
|
|
1287
|
+
/** WHAT FREED THIS QUESTION (owner, 2026-10-16, Goal 2383ef14: "we don't really show the question
|
|
1288
|
+
* at the top until the question it could reply to with is resolved. And then we show it again
|
|
1289
|
+
* with the context of the other thing that was resolved"; asked how it should carry that, "The
|
|
1290
|
+
* answer above it"). A question they answered with a question of their own waits for theirs
|
|
1291
|
+
* (`private.ask_back`) and drops out of the front while it waits; when it comes back, the card
|
|
1292
|
+
* draws their question and the answer it got ABOVE the ask, as one card. Absent on a question
|
|
1293
|
+
* nothing ever held back. */
|
|
1294
|
+
freedBy: z12.object({
|
|
1295
|
+
questionId: z12.string(),
|
|
1296
|
+
asked: z12.string(),
|
|
1297
|
+
answer: z12.string(),
|
|
1298
|
+
answeredAt: z12.string(),
|
|
1299
|
+
/** The answer in ten words, when the talker wrote one beside it. */
|
|
1300
|
+
summary: z12.string().optional()
|
|
1301
|
+
}).optional(),
|
|
1236
1302
|
/** The user's locked-in answer; present only for replied items (GET /api/replied/:id). */
|
|
1237
1303
|
answer: UserAnswerSchema.optional(),
|
|
1238
1304
|
/** THE TARGET FACTS A CARD RENDERS (#1796 point 5, 2026-09-11): the Delivery it is a view of,
|
|
@@ -1240,17 +1306,17 @@ var InboxItemSchema = z11.object({
|
|
|
1240
1306
|
* for a request that asks nothing), whether its content is sealed, and that Goal's state. The
|
|
1241
1307
|
* answer writer (`POST /api/entries`) and the disposition (`close_delivery`) take their ids from
|
|
1242
1308
|
* here. The server projects it (`apps/api/src/inbox/project.ts`); a client never builds it. */
|
|
1243
|
-
communication:
|
|
1244
|
-
deliveryId:
|
|
1245
|
-
kind:
|
|
1246
|
-
entryId:
|
|
1247
|
-
goalIds:
|
|
1248
|
-
decisionNeedId:
|
|
1249
|
-
sealed:
|
|
1250
|
-
goalState:
|
|
1309
|
+
communication: z12.object({
|
|
1310
|
+
deliveryId: z12.string(),
|
|
1311
|
+
kind: z12.enum(["notification", "call"]),
|
|
1312
|
+
entryId: z12.string(),
|
|
1313
|
+
goalIds: z12.array(z12.string()),
|
|
1314
|
+
decisionNeedId: z12.string().optional(),
|
|
1315
|
+
sealed: z12.boolean(),
|
|
1316
|
+
goalState: z12.string().optional(),
|
|
1251
1317
|
/** THAT GOAL'S NAME (#2416) — what Activity's row is headed by, since a row there is one Goal
|
|
1252
1318
|
* and the cards it holds sit behind it. Stamped by the same read as `goalState`. */
|
|
1253
|
-
goalTitle:
|
|
1319
|
+
goalTitle: z12.string().optional()
|
|
1254
1320
|
}).optional(),
|
|
1255
1321
|
/** WHAT THIS CARD IS, IN TWELVE CHARACTERS (#3019) — the hash of every other field on it, stamped
|
|
1256
1322
|
* by the one read that serves the open list (`apps/api/src/inbox/project.ts` `inboxFor`). It is
|
|
@@ -1262,27 +1328,27 @@ var InboxItemSchema = z11.object({
|
|
|
1262
1328
|
* own moves (its Goal's state and name, how cold the work behind it has gone, whether a ring is
|
|
1263
1329
|
* live). Optional, so a fixture, the demo and the archive lens need not spell one, and a card
|
|
1264
1330
|
* with no rev is simply always re-sent. */
|
|
1265
|
-
rev:
|
|
1331
|
+
rev: z12.string().optional()
|
|
1266
1332
|
});
|
|
1267
1333
|
var APNS_TOKEN_RE = /^[0-9a-fA-F]{64}$/;
|
|
1268
|
-
var PushTokenSchema =
|
|
1269
|
-
voipToken:
|
|
1270
|
-
alertToken:
|
|
1271
|
-
fcmToken:
|
|
1272
|
-
platform:
|
|
1334
|
+
var PushTokenSchema = z12.object({
|
|
1335
|
+
voipToken: z12.string().min(1).optional(),
|
|
1336
|
+
alertToken: z12.string().min(1).optional(),
|
|
1337
|
+
fcmToken: z12.string().min(1).optional(),
|
|
1338
|
+
platform: z12.enum(["ios", "android"])
|
|
1273
1339
|
}).superRefine((v, ctx) => {
|
|
1274
1340
|
if (v.platform !== "ios") return;
|
|
1275
1341
|
for (const field of ["voipToken", "alertToken"]) {
|
|
1276
1342
|
const token = v[field];
|
|
1277
1343
|
if (token === void 0 || APNS_TOKEN_RE.test(token)) continue;
|
|
1278
1344
|
ctx.addIssue({
|
|
1279
|
-
code:
|
|
1345
|
+
code: z12.ZodIssueCode.custom,
|
|
1280
1346
|
path: [field],
|
|
1281
1347
|
message: `not an APNs device token (want 64 hex chars, got ${token.length})`
|
|
1282
1348
|
});
|
|
1283
1349
|
}
|
|
1284
1350
|
});
|
|
1285
|
-
var MissedCallSchema =
|
|
1351
|
+
var MissedCallSchema = z12.enum([
|
|
1286
1352
|
"retry_10m",
|
|
1287
1353
|
"retry_30m",
|
|
1288
1354
|
"retry_60m",
|
|
@@ -1294,31 +1360,31 @@ var MissedCallSchema = z11.enum([
|
|
|
1294
1360
|
]);
|
|
1295
1361
|
var clock = (h) => h === 0 ? "midnight" : h === 12 ? "noon" : h < 12 ? `${h} am` : `${h - 12} pm`;
|
|
1296
1362
|
var QUIET = ` Nothing rings from ${clock(NIGHT.from)} to ${clock(NIGHT.to)} your time; the count waits for morning.`;
|
|
1297
|
-
var BrokerTuningSchema =
|
|
1363
|
+
var BrokerTuningSchema = z12.object({
|
|
1298
1364
|
/** 'none' = skip the spoken ack after a mapped answer (power users find it slow). */
|
|
1299
|
-
ackVerbosity:
|
|
1365
|
+
ackVerbosity: z12.enum(["normal", "none"]).optional(),
|
|
1300
1366
|
/** How readily the mapper asks its one clarification: 'low' = only when truly
|
|
1301
1367
|
* uninterpretable, 'high' = whenever not fully certain. */
|
|
1302
|
-
clarifyEagerness:
|
|
1368
|
+
clarifyEagerness: z12.enum(["low", "normal", "high"]).optional(),
|
|
1303
1369
|
/** The user's own shorthand: when they say `say`, they mean `mean`. */
|
|
1304
|
-
phrasebook:
|
|
1370
|
+
phrasebook: z12.array(z12.object({ say: z12.string().min(1).max(60), mean: z12.string().min(1).max(120) })).max(24).optional(),
|
|
1305
1371
|
/** The language calls are PLANNED in, when the account has chosen one (#1272). Absent —
|
|
1306
1372
|
* which is every account today — means the agent's own words decide, per ask: a call
|
|
1307
1373
|
* about an English ask opens in English. This is the only thing that overrides that,
|
|
1308
1374
|
* and a live caller who switches language mid-call still outranks it (broker/lang.ts).
|
|
1309
1375
|
* Set per user (no UI yet), like `voiceTuning`. */
|
|
1310
|
-
language:
|
|
1376
|
+
language: z12.enum(["en", "es"]).optional()
|
|
1311
1377
|
});
|
|
1312
|
-
var UserSettingsSchema =
|
|
1313
|
-
permissions:
|
|
1314
|
-
call:
|
|
1315
|
-
banner:
|
|
1316
|
-
push:
|
|
1378
|
+
var UserSettingsSchema = z12.object({
|
|
1379
|
+
permissions: z12.object({
|
|
1380
|
+
call: z12.boolean(),
|
|
1381
|
+
banner: z12.boolean(),
|
|
1382
|
+
push: z12.boolean()
|
|
1317
1383
|
}),
|
|
1318
1384
|
/** LockedIn / Default / DateNight on screen; the stored words are unchanged on purpose —
|
|
1319
1385
|
* they are an enum on a live column across every account, and the rename is a rename of
|
|
1320
1386
|
* what people read (owner, 2026-09-30). */
|
|
1321
|
-
sessionMode:
|
|
1387
|
+
sessionMode: z12.enum(["default", "all_calls", "silent"]),
|
|
1322
1388
|
/** `silentPush` lived here until #2813 and is now GONE, field and column both. It was kept as an
|
|
1323
1389
|
* optional long after DateNight stopped reading it, on the theory that a phone on an older
|
|
1324
1390
|
* bundle PATCHing the whole settings object would be REFUSED for sending a key we had stopped
|
|
@@ -1327,7 +1393,7 @@ var UserSettingsSchema = z11.object({
|
|
|
1327
1393
|
* an old bundle's `silentPush` is accepted and ignored. Worth remembering before keeping the
|
|
1328
1394
|
* next dead field for the same reason. */
|
|
1329
1395
|
/** Opt-in (default false) to using your content to improve Paigy and train models. */
|
|
1330
|
-
improveConsent:
|
|
1396
|
+
improveConsent: z12.boolean(),
|
|
1331
1397
|
missedCall: MissedCallSchema.default("backoff_standard"),
|
|
1332
1398
|
/** Where voice audio is processed. 'hosted' (default) = Paigy's voice services
|
|
1333
1399
|
* (ElevenLabs TTS, faster-whisper STT, the call bot); 'on_device' = the phone
|
|
@@ -1335,17 +1401,17 @@ var UserSettingsSchema = z11.object({
|
|
|
1335
1401
|
* Optional, NOT defaulted: a stale client PATCHing the full settings object
|
|
1336
1402
|
* must not silently reset this privacy choice. Absent = leave unchanged on
|
|
1337
1403
|
* write, 'hosted' on read (see store.ts). */
|
|
1338
|
-
voiceMode:
|
|
1404
|
+
voiceMode: z12.enum(["hosted", "on_device"]).optional(),
|
|
1339
1405
|
/** Talk — after you answer, the next step is read aloud (docs/clients/app/walk/design.md §6). ALWAYS ON until
|
|
1340
1406
|
* turned off (owner, 2026-09-18, #2249): a setting, not a per-walk toggle. Optional, NOT
|
|
1341
1407
|
* defaulted, for the same reason `voiceMode` is: a stale client PATCHing the full settings
|
|
1342
1408
|
* object must not silently turn it back on. Absent = leave unchanged on write, true on
|
|
1343
1409
|
* read (see store.ts). */
|
|
1344
|
-
talk:
|
|
1410
|
+
talk: z12.boolean().optional(),
|
|
1345
1411
|
/** CALL DIAGNOSTICS (owner, 2026-10-01): the call report carries each listen and the bot's own
|
|
1346
1412
|
* load timings. SERVER-SET, no UI — on for every account that existed on 2026-10-01, off for
|
|
1347
1413
|
* newer ones (migration 20261001132859). Read-only here: the settings PATCH never writes it. */
|
|
1348
|
-
callDiagnostics:
|
|
1414
|
+
callDiagnostics: z12.boolean().optional(),
|
|
1349
1415
|
/** Per-user ring budget (#603): calls per rolling day before further calls
|
|
1350
1416
|
* degrade to banner. Absent = the global default (25). A number, never a
|
|
1351
1417
|
* bypass — every account keeps a ceiling. No UI; set per user for testing. */
|
|
@@ -1353,7 +1419,7 @@ var UserSettingsSchema = z11.object({
|
|
|
1353
1419
|
* payload['tuning'] (e.g. { silence_s: 3.5 } — a longer pause window for a
|
|
1354
1420
|
* slower speaker). No API-side semantics; the bot resolves each key with its
|
|
1355
1421
|
* own defaults. Set per user (no UI yet); absent = bot defaults. */
|
|
1356
|
-
voiceTuning:
|
|
1422
|
+
voiceTuning: z12.record(z12.string(), z12.union([z12.number(), z12.string()])).optional(),
|
|
1357
1423
|
/** The user's IANA timezone (e.g. "America/Bogota"), recorded by the app — it is the
|
|
1358
1424
|
* only party that knows it. REMINDERS are why it exists: "remind me at ten" becomes
|
|
1359
1425
|
* an absolute `due_at` only if we know whose ten. Optional and never defaulted, for
|
|
@@ -1362,70 +1428,70 @@ var UserSettingsSchema = z11.object({
|
|
|
1362
1428
|
* that failure reads as the reminder rail being unreliable rather than as a missing
|
|
1363
1429
|
* setting. Absent = a spoken time can't be landed, so the reminder rides the next
|
|
1364
1430
|
* call — honest about what we know. */
|
|
1365
|
-
timezone:
|
|
1431
|
+
timezone: z12.string().min(1).max(64).optional(),
|
|
1366
1432
|
/** Rung-2 broker tuning (#381). Optional and NOT defaulted, same stale-client
|
|
1367
1433
|
* clobber guard as voiceMode: absent = leave unchanged on write. */
|
|
1368
1434
|
broker: BrokerTuningSchema.optional()
|
|
1369
1435
|
});
|
|
1370
|
-
var GoalLatestSchema =
|
|
1371
|
-
from:
|
|
1372
|
-
said:
|
|
1373
|
-
at:
|
|
1374
|
-
entryId:
|
|
1436
|
+
var GoalLatestSchema = z12.object({
|
|
1437
|
+
from: z12.enum(["person", "agent"]),
|
|
1438
|
+
said: z12.string(),
|
|
1439
|
+
at: z12.string(),
|
|
1440
|
+
entryId: z12.string(),
|
|
1375
1441
|
/** ITS SUMMARY IN AT MOST TEN WORDS (owner, 2026-10-08: "the same switch to the more summarized sources
|
|
1376
1442
|
* at the work tab top level screen too"): what the talker or filer wrote on the Entry; absent when
|
|
1377
1443
|
* none was. The Work row reads it before `said`. */
|
|
1378
|
-
summary:
|
|
1444
|
+
summary: z12.string().optional(),
|
|
1379
1445
|
/** AN AGENT'S UPDATE OR QUESTION AS ITS UNITS' TITLES (owner, 2026-10-08: "send the 50 chars from the title
|
|
1380
1446
|
* of each unit"): each at most 50 characters, in order; absent when it has none. */
|
|
1381
|
-
titles:
|
|
1447
|
+
titles: z12.array(z12.string()).optional(),
|
|
1382
1448
|
/** A PROGRESS NOTE'S ONE POINT ("An agent's progress note -> maybe let's cap it at 200 chars"): the
|
|
1383
1449
|
* update's own line, before its units; the row caps it at 200. Absent on anything else. */
|
|
1384
|
-
line:
|
|
1450
|
+
line: z12.string().optional()
|
|
1385
1451
|
});
|
|
1386
|
-
var HistoryWorkSchema =
|
|
1387
|
-
id:
|
|
1388
|
-
title:
|
|
1389
|
-
state:
|
|
1452
|
+
var HistoryWorkSchema = z12.object({
|
|
1453
|
+
id: z12.string(),
|
|
1454
|
+
title: z12.string(),
|
|
1455
|
+
state: z12.enum(["done", "cancelled"]),
|
|
1390
1456
|
/** Who held it (`agent:<tokenId>` or `human:<userId>`). */
|
|
1391
|
-
assignee:
|
|
1457
|
+
assignee: z12.string(),
|
|
1392
1458
|
latest: GoalLatestSchema.nullable().optional()
|
|
1393
1459
|
});
|
|
1394
|
-
var HistoryEntrySchema =
|
|
1395
|
-
|
|
1396
|
-
|
|
1460
|
+
var HistoryEntrySchema = z12.union([
|
|
1461
|
+
z12.object({ at: z12.string(), card: InboxItemSchema }),
|
|
1462
|
+
z12.object({ at: z12.string(), work: HistoryWorkSchema })
|
|
1397
1463
|
]);
|
|
1398
|
-
var HistoryPageSchema =
|
|
1399
|
-
entries:
|
|
1400
|
-
next:
|
|
1464
|
+
var HistoryPageSchema = z12.object({
|
|
1465
|
+
entries: z12.array(HistoryEntrySchema),
|
|
1466
|
+
next: z12.string().nullable()
|
|
1401
1467
|
});
|
|
1402
1468
|
var ACTIVITY_LINES = 2;
|
|
1403
1469
|
var ACTIVITY_LINE_MAX = 80;
|
|
1404
|
-
var AgentActivitySchema =
|
|
1470
|
+
var AgentActivitySchema = z12.object({
|
|
1405
1471
|
/** Oldest first, so the newest line is last — the one that replaces in place. */
|
|
1406
|
-
lines:
|
|
1472
|
+
lines: z12.array(z12.string().max(ACTIVITY_LINE_MAX)).max(ACTIVITY_LINES),
|
|
1407
1473
|
/** When the harness observed this tail. Its own timestamp, not the heartbeat's: a beat
|
|
1408
1474
|
* that carries an UNCHANGED tail must not make a stalled agent look like it just moved. */
|
|
1409
|
-
at:
|
|
1475
|
+
at: z12.string().datetime()
|
|
1410
1476
|
});
|
|
1411
|
-
var ConnectionSummarySchema =
|
|
1477
|
+
var ConnectionSummarySchema = z12.object({
|
|
1412
1478
|
/** The connection = the agent's token id (used to address a request). */
|
|
1413
|
-
id:
|
|
1479
|
+
id: z12.string(),
|
|
1414
1480
|
/** The credential kind: "device" = a paired machine (mint-only — it hosts and mints, it
|
|
1415
1481
|
* never talks); "agent" = an identity that sends. The roster and devices surfaces split
|
|
1416
1482
|
* on this. Optional/absent reads as "agent" (a row predating the kind column). See
|
|
1417
1483
|
* docs/server/tokens/devices-vs-agents-design.md. */
|
|
1418
|
-
kind:
|
|
1484
|
+
kind: z12.enum(["device", "agent"]).optional(),
|
|
1419
1485
|
/** For an agent, the token id of the DEVICE that minted it — so agents group under their
|
|
1420
1486
|
* machine, and revoking a device cascades to them. Null on devices, and on unlinked
|
|
1421
1487
|
* agents (phone-launched, provider-managed, or minted before the link existed). */
|
|
1422
|
-
mintedByDevice:
|
|
1423
|
-
device:
|
|
1488
|
+
mintedByDevice: z12.string().nullable().optional(),
|
|
1489
|
+
device: z12.string().nullable(),
|
|
1424
1490
|
/** The agent's display name (the single pairing name). */
|
|
1425
|
-
name:
|
|
1491
|
+
name: z12.string(),
|
|
1426
1492
|
/** For a managed connection, the provider key (e.g. "cma") that agentOrigin maps to a
|
|
1427
1493
|
* label; null for a local connection. Sourced from the token's provider, not the name. */
|
|
1428
|
-
provider:
|
|
1494
|
+
provider: z12.string().nullable(),
|
|
1429
1495
|
/** The pairing's assigned voice (#462); null = the default voice. */
|
|
1430
1496
|
voice: VoiceKeySchema.nullable(),
|
|
1431
1497
|
/** The LOUDEST this agent may ever reach you — a ceiling on `NOTIFY_LADDER`, set by the
|
|
@@ -1436,34 +1502,34 @@ var ConnectionSummarySchema = z11.object({
|
|
|
1436
1502
|
* every surface at once and outranks even `sessionMode: all_calls` — a mode the user
|
|
1437
1503
|
* set once must not overrule a rule they set about one agent. */
|
|
1438
1504
|
reach: NotifyLevelSchema.nullable().optional(),
|
|
1439
|
-
createdAt:
|
|
1505
|
+
createdAt: z12.string().datetime(),
|
|
1440
1506
|
/** Most recent notification on this connection, either direction. Null = no contact yet.
|
|
1441
1507
|
* Drives the agents-page recency grouping (Today / This week / …). */
|
|
1442
|
-
lastContactAt:
|
|
1508
|
+
lastContactAt: z12.string().datetime().nullable(),
|
|
1443
1509
|
/** Last presence heartbeat from a running agent process (POST /api/presence) — the
|
|
1444
1510
|
* desktop app while open. Null = never seen; stale = offline. */
|
|
1445
|
-
lastSeenAt:
|
|
1511
|
+
lastSeenAt: z12.string().datetime().nullable().optional(),
|
|
1446
1512
|
/** WORKING, NOT JUST CONNECTED (owner, 2026-09-30): the last time the agent itself acted on one of
|
|
1447
1513
|
* its Goals — wrote on one or recorded an operation (`tokens.last_worked_at`). Within
|
|
1448
1514
|
* `WORKING_MS` it is working; otherwise it is connected but idle. Null = not seen working yet. */
|
|
1449
|
-
lastWorkedAt:
|
|
1515
|
+
lastWorkedAt: z12.string().datetime().nullable().optional(),
|
|
1450
1516
|
/** The oldest of its Goals that is `ready` for it — work handed to it that nobody has started.
|
|
1451
1517
|
* With no work of its own for `WORKING_MS`, an agent sitting on this is not taking its work. */
|
|
1452
|
-
oldestReadyAt:
|
|
1518
|
+
oldestReadyAt: z12.string().datetime().nullable().optional(),
|
|
1453
1519
|
/** What a live desktop can run (docs/clients/desktop/companion.md §2.2), advertised on its heartbeat:
|
|
1454
1520
|
* harness availabilities + granted workspaces — the option set the phone's
|
|
1455
1521
|
* "new session" sheet offers. Absent for ordinary MCP agents. */
|
|
1456
|
-
runtime:
|
|
1522
|
+
runtime: z12.object({
|
|
1457
1523
|
/** The @paigy/harness this host is running — a machine the self-update has not reached
|
|
1458
1524
|
* shows its age here (`apps/desktop/src/update.ts`). */
|
|
1459
|
-
version:
|
|
1460
|
-
harnesses:
|
|
1461
|
-
workspaces:
|
|
1525
|
+
version: z12.string().optional(),
|
|
1526
|
+
harnesses: z12.array(z12.object({ name: z12.string(), label: z12.string(), status: z12.string(), models: z12.array(z12.string()).optional() })).optional(),
|
|
1527
|
+
workspaces: z12.array(z12.string()).optional(),
|
|
1462
1528
|
/** THE GIT REPOS IN THOSE FOLDERS (2026-10-01, Goal 26982211): each granted folder that is a
|
|
1463
1529
|
* repo, and each repo directly inside one, with its `origin` remote. A session started for
|
|
1464
1530
|
* work on `mauurda/paigy` opens in that repo rather than the folder above it, where the repo's
|
|
1465
1531
|
* own AGENTS.md is never read (`workspaceForRepo`). Absent on hosts that predate it. */
|
|
1466
|
-
repos:
|
|
1532
|
+
repos: z12.array(z12.object({ path: z12.string(), remote: z12.string() })).optional()
|
|
1467
1533
|
}).optional(),
|
|
1468
1534
|
/** The tail of this agent's working log, when a harness is driving it — the agent page's
|
|
1469
1535
|
* live strip. Absent for anything the desktop harness isn't running (a hatched identity
|
|
@@ -1472,145 +1538,145 @@ var ConnectionSummarySchema = z11.object({
|
|
|
1472
1538
|
activity: AgentActivitySchema.optional(),
|
|
1473
1539
|
/** True = a provider-managed agent running in the provider's cloud (e.g. Anthropic CMA);
|
|
1474
1540
|
* false = a local MCP connection running on the user's computer (Claude Code/Codex/…). */
|
|
1475
|
-
managed:
|
|
1541
|
+
managed: z12.boolean()
|
|
1476
1542
|
});
|
|
1477
|
-
var LedgerItemSchema =
|
|
1478
|
-
var AgentLedgerSchema =
|
|
1543
|
+
var LedgerItemSchema = z12.object({ id: z12.string(), parentId: z12.string(), title: z12.string(), createdAt: z12.string() });
|
|
1544
|
+
var AgentLedgerSchema = z12.object({
|
|
1479
1545
|
/** Null when the agent has not named itself yet — never a placeholder (owner, 2026-10-01). */
|
|
1480
|
-
agent:
|
|
1546
|
+
agent: z12.object({ id: z12.string(), name: z12.string().nullable(), revokedAt: z12.string().nullable() }),
|
|
1481
1547
|
/** Its own questions you have not answered. */
|
|
1482
|
-
asks:
|
|
1548
|
+
asks: z12.array(LedgerItemSchema),
|
|
1483
1549
|
/** Its questions you answered that nobody acted on — still owed to somebody. */
|
|
1484
|
-
answered:
|
|
1550
|
+
answered: z12.array(LedgerItemSchema),
|
|
1485
1551
|
/** Requests you sent it that it never took. */
|
|
1486
|
-
requests:
|
|
1487
|
-
goals:
|
|
1488
|
-
callbacks:
|
|
1552
|
+
requests: z12.array(LedgerItemSchema),
|
|
1553
|
+
goals: z12.array(z12.object({ id: z12.string(), outcome: z12.string(), state: z12.string() })),
|
|
1554
|
+
callbacks: z12.array(z12.object({ id: z12.string(), parentId: z12.string(), trigger: z12.string(), note: z12.string(), dueAt: z12.string().nullable() }))
|
|
1489
1555
|
});
|
|
1490
|
-
var ReassignResultSchema =
|
|
1491
|
-
moved:
|
|
1492
|
-
parentId:
|
|
1556
|
+
var ReassignResultSchema = z12.object({
|
|
1557
|
+
moved: z12.object({ asks: z12.number(), answered: z12.number(), requests: z12.number(), goals: z12.number(), callbacks: z12.number() }),
|
|
1558
|
+
parentId: z12.string().nullable()
|
|
1493
1559
|
});
|
|
1494
|
-
var LessonStateSchema =
|
|
1495
|
-
var LessonViewSchema =
|
|
1496
|
-
id:
|
|
1497
|
-
text:
|
|
1560
|
+
var LessonStateSchema = z12.enum(["active", "proposed", "retired"]);
|
|
1561
|
+
var LessonViewSchema = z12.object({
|
|
1562
|
+
id: z12.string(),
|
|
1563
|
+
text: z12.string(),
|
|
1498
1564
|
state: LessonStateSchema,
|
|
1499
1565
|
/** The Goal it is scoped to; null = the whole account. */
|
|
1500
|
-
scopeGoalId:
|
|
1501
|
-
goalTitle:
|
|
1502
|
-
version:
|
|
1503
|
-
pinned:
|
|
1566
|
+
scopeGoalId: z12.string().nullable(),
|
|
1567
|
+
goalTitle: z12.string().nullable(),
|
|
1568
|
+
version: z12.number(),
|
|
1569
|
+
pinned: z12.boolean(),
|
|
1504
1570
|
/** When the person last wrote its text themselves. */
|
|
1505
|
-
editedAt:
|
|
1506
|
-
createdAt:
|
|
1507
|
-
updatedAt:
|
|
1571
|
+
editedAt: z12.string().nullable(),
|
|
1572
|
+
createdAt: z12.string(),
|
|
1573
|
+
updatedAt: z12.string(),
|
|
1508
1574
|
/** The Entries it came from, oldest first; `words` is null when an Entry has none to show (sealed). */
|
|
1509
|
-
sources:
|
|
1575
|
+
sources: z12.array(z12.object({ entryId: z12.string(), words: z12.string().nullable(), at: z12.string() }))
|
|
1510
1576
|
});
|
|
1511
|
-
var QueueQuestionSchema =
|
|
1577
|
+
var QueueQuestionSchema = z12.object({
|
|
1512
1578
|
/** The decision need's id — what an answer is accepted against. */
|
|
1513
|
-
id:
|
|
1579
|
+
id: z12.string(),
|
|
1514
1580
|
/** The words that were asked, from the request Entry that asked them. */
|
|
1515
|
-
question:
|
|
1581
|
+
question: z12.string(),
|
|
1516
1582
|
/** Where it was asked — which is where the ruling goes (`POST /api/entries`). Null only
|
|
1517
1583
|
* for a need whose request Entry is carried by no interactive Delivery, which nothing
|
|
1518
1584
|
* can answer. */
|
|
1519
|
-
deliveryId:
|
|
1585
|
+
deliveryId: z12.string().nullable().default(null),
|
|
1520
1586
|
/** The Entry the ruling is about. */
|
|
1521
|
-
aboutId:
|
|
1587
|
+
aboutId: z12.string().nullable().default(null),
|
|
1522
1588
|
/** Empty for a free-text question. */
|
|
1523
|
-
options:
|
|
1524
|
-
select:
|
|
1525
|
-
askedAt:
|
|
1589
|
+
options: z12.array(OptionSchema).default([]),
|
|
1590
|
+
select: z12.enum(["one", "many", "rank", "confirm", "text"]).default("text"),
|
|
1591
|
+
askedAt: z12.string(),
|
|
1526
1592
|
/** Null while the question is open — which is how the page tells the two apart. */
|
|
1527
|
-
answeredAt:
|
|
1593
|
+
answeredAt: z12.string().nullable().default(null),
|
|
1528
1594
|
/** The ruling in the person's own words, from the contribution that replied — not the
|
|
1529
1595
|
* option id, which is not something anyone reads back. Null while it is open, and null
|
|
1530
1596
|
* for a settled question whose reply carried nothing readable. */
|
|
1531
|
-
answer:
|
|
1597
|
+
answer: z12.string().nullable().default(null),
|
|
1532
1598
|
/** The Goal this question belongs to — a step knows its Goal on its own, not only through
|
|
1533
1599
|
* an `InboxItem`'s `communication.goalIds[0]` (docs/clients/app/walk/design.md §12 item 3).
|
|
1534
1600
|
* READ BY `apps/client/src/walk/order.ts`, which stamps it onto every `WalkStep`: the walk's
|
|
1535
1601
|
* order, its route, home's trees and the list of steps all take a step's Goal from here, so
|
|
1536
1602
|
* this is the field they agree through rather than each re-deriving it from the row it
|
|
1537
1603
|
* arrived under. Required because the API projects it on every need it sends. */
|
|
1538
|
-
goalId:
|
|
1604
|
+
goalId: z12.string(),
|
|
1539
1605
|
/** True only while an unmet START gate holds the Goal — a Goal that merely waits to
|
|
1540
1606
|
* *finish* does not stop a person from answering (owner, 2026-09-16: "per need gate from
|
|
1541
1607
|
* the API"; §4's dashed node). Not the same fact as `QueueItem.blocked`, which counts any
|
|
1542
1608
|
* gate at all. */
|
|
1543
|
-
blocked:
|
|
1609
|
+
blocked: z12.boolean().default(false)
|
|
1544
1610
|
});
|
|
1545
|
-
var QueueReplySchema =
|
|
1611
|
+
var QueueReplySchema = z12.object({
|
|
1546
1612
|
/** The card this note was (`deliveryId:requestEntryId`, minted by the server like every card
|
|
1547
1613
|
* id) — so the phone can tell a reply it just sent from one the queue already carries, and the
|
|
1548
1614
|
* walk can name it in its zoom. */
|
|
1549
|
-
id:
|
|
1615
|
+
id: z12.string(),
|
|
1550
1616
|
/** The Goal the note is on. */
|
|
1551
|
-
goalId:
|
|
1617
|
+
goalId: z12.string(),
|
|
1552
1618
|
/** What the note said. */
|
|
1553
|
-
note:
|
|
1619
|
+
note: z12.string(),
|
|
1554
1620
|
/** Where it was carried — where a second reply goes (`POST /api/entries`, #2252). */
|
|
1555
|
-
deliveryId:
|
|
1556
|
-
requestEntryId:
|
|
1557
|
-
askedAt:
|
|
1621
|
+
deliveryId: z12.string(),
|
|
1622
|
+
requestEntryId: z12.string(),
|
|
1623
|
+
askedAt: z12.string(),
|
|
1558
1624
|
/** When the person last replied — the window's start. */
|
|
1559
|
-
repliedAt:
|
|
1625
|
+
repliedAt: z12.string(),
|
|
1560
1626
|
/** The person's latest words about it; null when there is nothing readable in them. */
|
|
1561
|
-
reply:
|
|
1627
|
+
reply: z12.string().nullable()
|
|
1562
1628
|
});
|
|
1563
|
-
var QueueItemSchema =
|
|
1564
|
-
id:
|
|
1629
|
+
var QueueItemSchema = z12.object({
|
|
1630
|
+
id: z12.string(),
|
|
1565
1631
|
/** One-line headline — the first sentence of the outcome. */
|
|
1566
|
-
title:
|
|
1632
|
+
title: z12.string(),
|
|
1567
1633
|
/** The outcome in full, verbatim: the person's own words are what an assignee sees. */
|
|
1568
|
-
intent:
|
|
1634
|
+
intent: z12.string(),
|
|
1569
1635
|
/** `ready` | `active` | `waiting` | `done` | `cancelled`, straight off the Goal. */
|
|
1570
|
-
state:
|
|
1636
|
+
state: z12.string(),
|
|
1571
1637
|
/** Who holds it (a participant ref); null when nobody does yet. */
|
|
1572
|
-
assignee:
|
|
1638
|
+
assignee: z12.string().nullable().default(null),
|
|
1573
1639
|
/** What the agent last said it was doing; null if it has said nothing. */
|
|
1574
|
-
progress:
|
|
1640
|
+
progress: z12.string().nullable().default(null),
|
|
1575
1641
|
/** HOME'S LINE FOR THAT NOTE (owner, 2026-09-23): a few plain words one read wrote from `progress`,
|
|
1576
1642
|
* served only while it was written for the current note. Null means show the Goal's name. */
|
|
1577
|
-
progressLine:
|
|
1578
|
-
reviewPending:
|
|
1579
|
-
dueAt:
|
|
1643
|
+
progressLine: z12.string().nullable().optional(),
|
|
1644
|
+
reviewPending: z12.boolean().default(false),
|
|
1645
|
+
dueAt: z12.string().nullable().default(null),
|
|
1580
1646
|
/** WHEN ITS OWNER SAID DONE WHILE CHILDREN WERE OPEN (#2704): its own work is finished and it closes
|
|
1581
1647
|
* with its last open child. Null otherwise; optional, so hand-built queues need not spell it. */
|
|
1582
|
-
finishedAt:
|
|
1648
|
+
finishedAt: z12.string().nullable().optional(),
|
|
1583
1649
|
/** The Goal this one was opened under; null at the root. */
|
|
1584
|
-
parentGoalId:
|
|
1650
|
+
parentGoalId: z12.string().nullable().default(null),
|
|
1585
1651
|
/** Goals opened under this one — only those the same list holds. */
|
|
1586
|
-
childGoalIds:
|
|
1652
|
+
childGoalIds: z12.array(z12.string()).default([]),
|
|
1587
1653
|
/** Goals this one waits on (start or finish gates). */
|
|
1588
|
-
dependencyGoalIds:
|
|
1654
|
+
dependencyGoalIds: z12.array(z12.string()).default([]),
|
|
1589
1655
|
/** True while any gate is on a Goal that is not done — the walk draws it dashed. */
|
|
1590
|
-
blocked:
|
|
1656
|
+
blocked: z12.boolean().default(false),
|
|
1591
1657
|
/** Its questions: every OPEN one, and at most ten settled, newest settled first
|
|
1592
1658
|
* (20260929133308) — the page decides which of them to show. NOT the whole set: `asked` and
|
|
1593
1659
|
* `answered` are, and a settled one's words are a line (280 characters), its body read when the
|
|
1594
1660
|
* question is opened. */
|
|
1595
|
-
questions:
|
|
1661
|
+
questions: z12.array(QueueQuestionSchema).default([]),
|
|
1596
1662
|
/** HOW MANY QUESTIONS THIS WORK HAS ASKED, and how many are answered — the Goal's own totals,
|
|
1597
1663
|
* bounded at 100 server-side. A tally counted off `questions` is a wrong number that looks
|
|
1598
1664
|
* right once the cap bites (`walk/trees.ts` `tallyOf`). Optional, and defaulted from the array
|
|
1599
1665
|
* by the projection, so hand-built queues (fixtures, the demo) need not spell them. */
|
|
1600
|
-
asked:
|
|
1601
|
-
answered:
|
|
1666
|
+
asked: z12.number().optional(),
|
|
1667
|
+
answered: z12.number().optional(),
|
|
1602
1668
|
/** Every note on it the person replied to (`QueueReplySchema`) — the page decides which to show.
|
|
1603
1669
|
* Optional, not defaulted: absent is none, and every hand-built queue (fixtures, the demo) need
|
|
1604
1670
|
* not spell an empty list. */
|
|
1605
|
-
replies:
|
|
1671
|
+
replies: z12.array(QueueReplySchema).optional(),
|
|
1606
1672
|
/** The repository or project identifier this Goal belongs to (#2280), null if untracked. */
|
|
1607
|
-
repo:
|
|
1608
|
-
createdAt:
|
|
1609
|
-
updatedAt:
|
|
1673
|
+
repo: z12.string().nullable().optional(),
|
|
1674
|
+
createdAt: z12.string(),
|
|
1675
|
+
updatedAt: z12.string().nullable().default(null),
|
|
1610
1676
|
/** When its owner last SAID something about it (the newest `progress` Entry: a contact update kept
|
|
1611
1677
|
* as progress). `updatedAt` moves for reasons nobody chose — a
|
|
1612
1678
|
* state recomputed, a review flag — so it cannot tell work in hand from work gone quiet. */
|
|
1613
|
-
lastProgressAt:
|
|
1679
|
+
lastProgressAt: z12.string().nullable().optional(),
|
|
1614
1680
|
/** THE GOAL'S NEWEST WORD, FROM EITHER SIDE (owner, 2026-09-27): the newest Entry on it, of any
|
|
1615
1681
|
* kind — what the person added ("Add to this"), their reply, the agent's ask or its progress
|
|
1616
1682
|
* note. A progress note is an Entry, so this is already the newer of the two: the person's note
|
|
@@ -1629,7 +1695,7 @@ var QueueItemSchema = z11.object({
|
|
|
1629
1695
|
* minute after the person speaks erases their instant from it, and the durable traces the client
|
|
1630
1696
|
* can see (`replies`, `questions[].answeredAt`) miss a spontaneous note entirely — a `request`
|
|
1631
1697
|
* Entry with no `about_id` is in neither. */
|
|
1632
|
-
lastPersonAt:
|
|
1698
|
+
lastPersonAt: z12.string().nullable().optional(),
|
|
1633
1699
|
/** EACH SIDE'S NEWEST WORD IN THE LAST DAY (owner, 2026-10-13, the Work tab's order): the person's
|
|
1634
1700
|
* (`yours`) and the agents' (`theirs`), each null when that side wrote nothing on it in 24 hours.
|
|
1635
1701
|
* `latest` holds one Entry, so whichever side wrote first is hidden there; Work orders a Goal by
|
|
@@ -1647,40 +1713,40 @@ var QueueItemSchema = z11.object({
|
|
|
1647
1713
|
* the row shows that no `updated_at` moves for (`active` lapsing, a dependency's state, a
|
|
1648
1714
|
* sibling appearing in `childGoalIds`) cannot go unnoticed. Optional because a hand-built
|
|
1649
1715
|
* queue (a fixture, the demo) spells none, and a row with no rev is simply always re-sent. */
|
|
1650
|
-
rev:
|
|
1716
|
+
rev: z12.string().optional()
|
|
1651
1717
|
});
|
|
1652
|
-
var QueueDeltaSchema =
|
|
1653
|
-
ids:
|
|
1654
|
-
items:
|
|
1718
|
+
var QueueDeltaSchema = z12.object({
|
|
1719
|
+
ids: z12.array(z12.string()),
|
|
1720
|
+
items: z12.array(QueueItemSchema)
|
|
1655
1721
|
});
|
|
1656
1722
|
var COLD_AFTER_MS = 3 * 24 * 60 * 60 * 1e3;
|
|
1657
|
-
var NoteSourceSchema =
|
|
1658
|
-
var NoteStatusSchema =
|
|
1659
|
-
var NoteRepeatSchema =
|
|
1660
|
-
var DecisionSchema =
|
|
1661
|
-
id:
|
|
1723
|
+
var NoteSourceSchema = z12.enum(["app", "call"]);
|
|
1724
|
+
var NoteStatusSchema = z12.enum(["open", "assigned", "in_progress", "done"]);
|
|
1725
|
+
var NoteRepeatSchema = z12.enum(["once", "until_done"]);
|
|
1726
|
+
var DecisionSchema = z12.object({
|
|
1727
|
+
id: z12.string(),
|
|
1662
1728
|
/** The note this decision refines; null = recorded on a bare thread (the
|
|
1663
1729
|
* extensibility seam — any conversation can accrue decisions). */
|
|
1664
|
-
noteId:
|
|
1730
|
+
noteId: z12.string().nullable(),
|
|
1665
1731
|
/** What was ambiguous — the broker's (or the user's own) question. */
|
|
1666
|
-
question:
|
|
1732
|
+
question: z12.string(),
|
|
1667
1733
|
/** The user's ruling; null while the question is open. */
|
|
1668
|
-
answer:
|
|
1669
|
-
decidedAt:
|
|
1670
|
-
createdAt:
|
|
1734
|
+
answer: z12.string().nullable(),
|
|
1735
|
+
decidedAt: z12.string().nullable(),
|
|
1736
|
+
createdAt: z12.string()
|
|
1671
1737
|
});
|
|
1672
|
-
var NoteSchema =
|
|
1673
|
-
id:
|
|
1738
|
+
var NoteSchema = z12.object({
|
|
1739
|
+
id: z12.string(),
|
|
1674
1740
|
/** One-line headline (broker-titled; deterministic floor). */
|
|
1675
|
-
title:
|
|
1741
|
+
title: z12.string(),
|
|
1676
1742
|
/** The original intent, verbatim — assignees always see the user's own words. */
|
|
1677
|
-
intent:
|
|
1743
|
+
intent: z12.string(),
|
|
1678
1744
|
source: NoteSourceSchema,
|
|
1679
1745
|
status: NoteStatusSchema,
|
|
1680
1746
|
/** Who it was assigned to (a participant ref, 'agent:<tokenId>'); null = unassigned. */
|
|
1681
|
-
assignee:
|
|
1747
|
+
assignee: z12.string().nullable(),
|
|
1682
1748
|
/** The request thread minted at assignment; null until assigned. */
|
|
1683
|
-
parentId:
|
|
1749
|
+
parentId: z12.string().nullable(),
|
|
1684
1750
|
/** REMINDERS (docs/model/notes/reminders-design.md): the NOT-BEFORE this becomes eligible to ride a
|
|
1685
1751
|
* call — never a deadline. It only ever comes from the user's own words, so when it
|
|
1686
1752
|
* passes Paigy rings ONCE (#1293, owner 2026-08-26: a time said out loud is consent to
|
|
@@ -1689,100 +1755,100 @@ var NoteSchema = z11.object({
|
|
|
1689
1755
|
// Defaulted, not required: a Note from an API deploy older than the reminders
|
|
1690
1756
|
// migration has none of these, and the defaults ARE what it means — no not-before,
|
|
1691
1757
|
// one ride, never ridden. Parsing must not fail across a rolling deploy.
|
|
1692
|
-
dueAt:
|
|
1758
|
+
dueAt: z12.string().nullable().default(null),
|
|
1693
1759
|
repeat: NoteRepeatSchema.default("once"),
|
|
1694
1760
|
/** How many calls have already carried it — the fatigue cap counts rides, not days. */
|
|
1695
|
-
rides:
|
|
1696
|
-
lastRideAt:
|
|
1697
|
-
createdAt:
|
|
1761
|
+
rides: z12.number().int().default(0),
|
|
1762
|
+
lastRideAt: z12.string().nullable().default(null),
|
|
1763
|
+
createdAt: z12.string()
|
|
1698
1764
|
});
|
|
1699
|
-
var DeliveryModeSchema =
|
|
1700
|
-
var RegisterDeliverySchema =
|
|
1701
|
-
var OAuthStartSchema =
|
|
1702
|
-
provider:
|
|
1703
|
-
returnTo:
|
|
1765
|
+
var DeliveryModeSchema = z12.enum(["poll", "self_hosted"]);
|
|
1766
|
+
var RegisterDeliverySchema = z12.object({ mode: DeliveryModeSchema });
|
|
1767
|
+
var OAuthStartSchema = z12.object({
|
|
1768
|
+
provider: z12.enum(["cma"]),
|
|
1769
|
+
returnTo: z12.string().min(1)
|
|
1704
1770
|
});
|
|
1705
|
-
var DeliveryConfigSchema =
|
|
1706
|
-
tokenId:
|
|
1771
|
+
var DeliveryConfigSchema = z12.object({
|
|
1772
|
+
tokenId: z12.string(),
|
|
1707
1773
|
mode: DeliveryModeSchema,
|
|
1708
1774
|
/** null when the deployment has no anon key configured. `self_hosted` is then REFUSED
|
|
1709
1775
|
* (503 `self_hosted_unavailable`) rather than registered, so a self_hosted config always
|
|
1710
1776
|
* carries credentials; only a `poll` registration can come back with null here. */
|
|
1711
|
-
realtime:
|
|
1777
|
+
realtime: z12.object({ url: z12.string(), anonKey: z12.string() }).nullable()
|
|
1712
1778
|
});
|
|
1713
|
-
var HostDecisionSchema =
|
|
1779
|
+
var HostDecisionSchema = z12.object({
|
|
1714
1780
|
/** The agent's token id: the row's `recipient`. */
|
|
1715
|
-
agent:
|
|
1716
|
-
decision:
|
|
1781
|
+
agent: z12.string().uuid(),
|
|
1782
|
+
decision: z12.enum(["stood_back", "took_over"]),
|
|
1717
1783
|
/** The work it was about: the Goal waiting on that agent next (`claimable` on its `contact({})` read). */
|
|
1718
|
-
goalId:
|
|
1784
|
+
goalId: z12.string().uuid().nullable().optional(),
|
|
1719
1785
|
/** When the server last heard from the agent, as the host read it: the presence it stood back for. */
|
|
1720
|
-
seenAt:
|
|
1786
|
+
seenAt: z12.string().datetime().nullable().optional(),
|
|
1721
1787
|
/** When that work last moved (`claimable.since` on an agent's `contact({})` read), the fact the bound is judged on. */
|
|
1722
|
-
since:
|
|
1788
|
+
since: z12.string().datetime().nullable().optional(),
|
|
1723
1789
|
/** What the host said, in its log's own words: why it stood back, or what the take-over did. */
|
|
1724
|
-
said:
|
|
1790
|
+
said: z12.string().max(300).optional()
|
|
1725
1791
|
});
|
|
1726
|
-
var WakeNudgeSchema =
|
|
1727
|
-
kind:
|
|
1728
|
-
notificationId:
|
|
1729
|
-
parentId:
|
|
1792
|
+
var WakeNudgeSchema = z12.object({
|
|
1793
|
+
kind: z12.enum(["reply", "request", "callback"]),
|
|
1794
|
+
notificationId: z12.string().optional(),
|
|
1795
|
+
parentId: z12.string()
|
|
1730
1796
|
});
|
|
1731
|
-
var PairingStatusSchema =
|
|
1732
|
-
var DeviceCodeSchema =
|
|
1733
|
-
device_code:
|
|
1734
|
-
user_code:
|
|
1735
|
-
verification_uri:
|
|
1736
|
-
verification_uri_complete:
|
|
1737
|
-
interval:
|
|
1738
|
-
expires_in:
|
|
1797
|
+
var PairingStatusSchema = z12.enum(["pending", "approved", "denied", "expired"]);
|
|
1798
|
+
var DeviceCodeSchema = z12.object({
|
|
1799
|
+
device_code: z12.string(),
|
|
1800
|
+
user_code: z12.string(),
|
|
1801
|
+
verification_uri: z12.string().url(),
|
|
1802
|
+
verification_uri_complete: z12.string().url(),
|
|
1803
|
+
interval: z12.number(),
|
|
1804
|
+
expires_in: z12.number()
|
|
1739
1805
|
});
|
|
1740
|
-
var DeviceInfoSchema =
|
|
1741
|
-
code:
|
|
1806
|
+
var DeviceInfoSchema = z12.object({
|
|
1807
|
+
code: z12.string(),
|
|
1742
1808
|
/** The agent's suggested name (from /device/code) — shown on the approval screen,
|
|
1743
1809
|
* pre-filling the name field the human can edit. */
|
|
1744
|
-
name:
|
|
1810
|
+
name: z12.string(),
|
|
1745
1811
|
/** @deprecated Legacy alias of `name` for the pre-#531 embedded bundle in App Store
|
|
1746
1812
|
* build 35, whose DeviceFlow renders `info.agent.slice(0, 2)` — without this a FRESH
|
|
1747
1813
|
* install crashes on the pairing screen on first launch, before the OTA lands
|
|
1748
1814
|
* (seen live: PAIGY-5T, 2026-07-21). Remove once a newer binary is the floor. */
|
|
1749
|
-
agent:
|
|
1750
|
-
device:
|
|
1815
|
+
agent: z12.string().optional(),
|
|
1816
|
+
device: z12.string().nullable(),
|
|
1751
1817
|
status: PairingStatusSchema
|
|
1752
1818
|
});
|
|
1753
|
-
var DeviceTokenSchema =
|
|
1754
|
-
access_token:
|
|
1819
|
+
var DeviceTokenSchema = z12.object({
|
|
1820
|
+
access_token: z12.string(),
|
|
1755
1821
|
/** The pairing's single name (user-typed at approval, the agent's suggestion, or
|
|
1756
1822
|
* a default silly name). */
|
|
1757
|
-
name:
|
|
1758
|
-
device:
|
|
1823
|
+
name: z12.string(),
|
|
1824
|
+
device: z12.string().nullable(),
|
|
1759
1825
|
/** The pairing's assigned voice, cached so the desktop can seed the SAME face the phone
|
|
1760
1826
|
* draws — voice is the third ingredient of a hatchling's build (party/traits.ts). */
|
|
1761
|
-
voice:
|
|
1827
|
+
voice: z12.string().nullable().optional(),
|
|
1762
1828
|
/** The token's server-side id — the face's COLOUR anchor, and the only seed ingredient
|
|
1763
1829
|
* that survives a rename. Cached by the host's identity beat. */
|
|
1764
|
-
token_id:
|
|
1830
|
+
token_id: z12.string().nullable().optional(),
|
|
1765
1831
|
/** WHERE this identity works — the folder a wake should land it in. Written by the host
|
|
1766
1832
|
* at spawn and by `paigy-harness handoff` from a live terminal. Without it every wake
|
|
1767
1833
|
* landed in the FIRST granted workspace and the agent rediscovered its own repo from
|
|
1768
1834
|
* the thread each time (host.ts, live catch 2026-08-06 — prompt-papered until now). */
|
|
1769
|
-
workspace:
|
|
1835
|
+
workspace: z12.string().nullable().optional(),
|
|
1770
1836
|
/** Local host recovery must preserve the launch's runtime and Paigy identity. */
|
|
1771
|
-
harness:
|
|
1772
|
-
session_id:
|
|
1837
|
+
harness: z12.enum(["claude", "codex", "agy"]).optional(),
|
|
1838
|
+
session_id: z12.string().uuid().optional(),
|
|
1773
1839
|
/** A conversation the host must not resume: its context is full, so every turn fails
|
|
1774
1840
|
* ("Prompt is too long"). Written when a run hits it (`run.ts` `onFull`); the host skips a slot
|
|
1775
1841
|
* whose resumable session is this one, so its Goals reach the dead-agent handoff instead of a
|
|
1776
1842
|
* copy that types the person's words into a turn that cannot run (Calls, 2026-10-06). */
|
|
1777
|
-
full_session:
|
|
1778
|
-
uik_pub:
|
|
1843
|
+
full_session: z12.string().optional(),
|
|
1844
|
+
uik_pub: z12.string().nullable().optional()
|
|
1779
1845
|
});
|
|
1780
|
-
var SupportRequestSchema =
|
|
1781
|
-
email:
|
|
1782
|
-
message:
|
|
1783
|
-
name:
|
|
1846
|
+
var SupportRequestSchema = z12.object({
|
|
1847
|
+
email: z12.string().email().max(320),
|
|
1848
|
+
message: z12.string().trim().min(1).max(5e3),
|
|
1849
|
+
name: z12.string().trim().max(120).optional()
|
|
1784
1850
|
});
|
|
1785
|
-
var NotificationFeedbackKindSchema =
|
|
1851
|
+
var NotificationFeedbackKindSchema = z12.enum([
|
|
1786
1852
|
"break_down",
|
|
1787
1853
|
// "This should be more than one ask — break it down."
|
|
1788
1854
|
"regenerate_options",
|
|
@@ -1797,131 +1863,131 @@ var NotificationFeedbackKindSchema = z11.enum([
|
|
|
1797
1863
|
// anything else — the note carries it.
|
|
1798
1864
|
]);
|
|
1799
1865
|
var SlimOptionSchema = OptionSchema.omit({ html: true });
|
|
1800
|
-
var QuestionRowSchema =
|
|
1866
|
+
var QuestionRowSchema = z12.object({
|
|
1801
1867
|
/** The card's id (`deliveryId:needId`, or `deliveryId:entryId` for an update), as the inbox mints it. */
|
|
1802
|
-
id:
|
|
1803
|
-
deliveryId:
|
|
1804
|
-
entryId:
|
|
1868
|
+
id: z12.string(),
|
|
1869
|
+
deliveryId: z12.string(),
|
|
1870
|
+
entryId: z12.string(),
|
|
1805
1871
|
/** The decision it waits on; null for an update, which asks nothing. */
|
|
1806
|
-
needId:
|
|
1807
|
-
goalIds:
|
|
1872
|
+
needId: z12.string().nullable(),
|
|
1873
|
+
goalIds: z12.array(z12.string()),
|
|
1808
1874
|
/** The name of the work it is about, when the read could word it. */
|
|
1809
|
-
goalTitle:
|
|
1810
|
-
tokenId:
|
|
1811
|
-
name:
|
|
1812
|
-
title:
|
|
1813
|
-
body:
|
|
1814
|
-
select:
|
|
1815
|
-
options:
|
|
1816
|
-
hasPreview:
|
|
1817
|
-
blocking:
|
|
1818
|
-
askedAt:
|
|
1875
|
+
goalTitle: z12.string().optional(),
|
|
1876
|
+
tokenId: z12.string().optional(),
|
|
1877
|
+
name: z12.string(),
|
|
1878
|
+
title: z12.string(),
|
|
1879
|
+
body: z12.string(),
|
|
1880
|
+
select: z12.enum(["one", "many", "rank", "confirm", "text"]),
|
|
1881
|
+
options: z12.array(SlimOptionSchema),
|
|
1882
|
+
hasPreview: z12.boolean(),
|
|
1883
|
+
blocking: z12.boolean(),
|
|
1884
|
+
askedAt: z12.string().datetime(),
|
|
1819
1885
|
ring: InboxItemSchema.shape.ring,
|
|
1820
|
-
onCall:
|
|
1821
|
-
sealed:
|
|
1886
|
+
onCall: z12.literal(true).optional(),
|
|
1887
|
+
sealed: z12.boolean()
|
|
1822
1888
|
});
|
|
1823
|
-
var WorkStateSchema =
|
|
1824
|
-
var WorkRowSchema =
|
|
1825
|
-
id:
|
|
1826
|
-
parentId:
|
|
1827
|
-
title:
|
|
1889
|
+
var WorkStateSchema = z12.enum(["ready", "active", "waiting", "done", "cancelled"]);
|
|
1890
|
+
var WorkRowSchema = z12.object({
|
|
1891
|
+
id: z12.string(),
|
|
1892
|
+
parentId: z12.string().nullable(),
|
|
1893
|
+
title: z12.string(),
|
|
1828
1894
|
/** Straight off the Goal. */
|
|
1829
1895
|
state: WorkStateSchema,
|
|
1830
|
-
owner:
|
|
1831
|
-
revision:
|
|
1896
|
+
owner: z12.string().nullable(),
|
|
1897
|
+
revision: z12.number().int(),
|
|
1832
1898
|
/** Open questions on it, counted to 100. */
|
|
1833
|
-
waiting:
|
|
1899
|
+
waiting: z12.number().int(),
|
|
1834
1900
|
/** Held by a gate on work that is not done. */
|
|
1835
|
-
blocked:
|
|
1836
|
-
lastProgressAt:
|
|
1901
|
+
blocked: z12.boolean(),
|
|
1902
|
+
lastProgressAt: z12.string().datetime().nullable(),
|
|
1837
1903
|
/** The line written for its newest progress note, else that note's first words. */
|
|
1838
|
-
line:
|
|
1904
|
+
line: z12.string().nullable(),
|
|
1839
1905
|
/** Work directly under it, counted to 100; the list carries up to 12 of them. */
|
|
1840
|
-
children:
|
|
1841
|
-
createdAt:
|
|
1842
|
-
updatedAt:
|
|
1906
|
+
children: z12.number().int(),
|
|
1907
|
+
createdAt: z12.string().datetime(),
|
|
1908
|
+
updatedAt: z12.string().datetime(),
|
|
1843
1909
|
/** When anything at or under it last moved — the order the list is in. */
|
|
1844
|
-
activeAt:
|
|
1910
|
+
activeAt: z12.string().datetime(),
|
|
1845
1911
|
/** A sealed outcome has no title here; the work's page opens it. */
|
|
1846
|
-
sealed:
|
|
1912
|
+
sealed: z12.boolean()
|
|
1847
1913
|
});
|
|
1848
1914
|
var ComputerRowSchema = ConnectionSummarySchema.omit({ activity: true });
|
|
1849
1915
|
var AgentRowSchema = ComputerRowSchema.extend({
|
|
1850
1916
|
/** Open questions it is asking the person, over every open card; null when that read failed. */
|
|
1851
|
-
asking:
|
|
1852
|
-
oldestAskAt:
|
|
1917
|
+
asking: z12.number().int().nullable(),
|
|
1918
|
+
oldestAskAt: z12.string().datetime().nullable(),
|
|
1853
1919
|
/** Up to three of the live Goals it holds, oldest first (the order it picks them up), and how
|
|
1854
1920
|
* many in all among the account's 200 most recently active agent-held live Goals
|
|
1855
1921
|
* (`agent_holds`); null when that read failed. */
|
|
1856
|
-
holds:
|
|
1857
|
-
held:
|
|
1922
|
+
holds: z12.array(z12.object({ id: z12.string(), title: z12.string() })).nullable(),
|
|
1923
|
+
held: z12.number().int().nullable(),
|
|
1858
1924
|
/** The earliest instant any Goal it holds went quiet, by the one rule (`coldSince`); null
|
|
1859
1925
|
* while none has, or when that read failed. */
|
|
1860
|
-
cold:
|
|
1926
|
+
cold: z12.string().datetime().nullable(),
|
|
1861
1927
|
/** The newest line of its working log, and when the harness saw it. */
|
|
1862
|
-
line:
|
|
1863
|
-
lineAt:
|
|
1928
|
+
line: z12.string().nullable(),
|
|
1929
|
+
lineAt: z12.string().datetime().nullable()
|
|
1864
1930
|
});
|
|
1865
|
-
var SnapshotSchema =
|
|
1931
|
+
var SnapshotSchema = z12.object({
|
|
1866
1932
|
/** The API's clock, taken before the first read: what a later delta will start from. */
|
|
1867
|
-
at:
|
|
1868
|
-
questions:
|
|
1933
|
+
at: z12.string().datetime(),
|
|
1934
|
+
questions: z12.object({
|
|
1869
1935
|
/** The newest 30 open cards, questions before updates. */
|
|
1870
|
-
items:
|
|
1936
|
+
items: z12.array(QuestionRowSchema),
|
|
1871
1937
|
/** Every open question, and apart from them every update, and what was put off. */
|
|
1872
|
-
total:
|
|
1873
|
-
updates:
|
|
1874
|
-
putOff:
|
|
1938
|
+
total: z12.number().int(),
|
|
1939
|
+
updates: z12.number().int(),
|
|
1940
|
+
putOff: z12.number().int()
|
|
1875
1941
|
}).nullable(),
|
|
1876
|
-
agents:
|
|
1942
|
+
agents: z12.object({
|
|
1877
1943
|
/** Up to 60, most recently seen first. */
|
|
1878
|
-
items:
|
|
1879
|
-
more:
|
|
1944
|
+
items: z12.array(AgentRowSchema),
|
|
1945
|
+
more: z12.boolean()
|
|
1880
1946
|
}).nullable(),
|
|
1881
|
-
work:
|
|
1947
|
+
work: z12.object({
|
|
1882
1948
|
/** The 60 most recently active roots, each followed by up to 12 children; 240 rows at most. */
|
|
1883
|
-
items:
|
|
1949
|
+
items: z12.array(WorkRowSchema),
|
|
1884
1950
|
/** How much work is behind each of the Work tab's four filters, each counted to 100, read with
|
|
1885
1951
|
* the rows. `work_list` (20260928023533) owns the predicates: Live is `ready`, `active` or
|
|
1886
1952
|
* `waiting`; Waiting on you is live work with an open question or an unmet gate; Not started
|
|
1887
1953
|
* is `ready`; Done is `done` or `cancelled`. */
|
|
1888
|
-
counts:
|
|
1954
|
+
counts: z12.object({ live: z12.number().int(), waiting: z12.number().int(), notStarted: z12.number().int(), done: z12.number().int() })
|
|
1889
1955
|
}).nullable(),
|
|
1890
|
-
you:
|
|
1956
|
+
you: z12.object({
|
|
1891
1957
|
settings: UserSettingsSchema,
|
|
1892
|
-
callable:
|
|
1958
|
+
callable: z12.boolean(),
|
|
1893
1959
|
/** Up to 20 paired computers; null when the roster read failed. */
|
|
1894
|
-
computers:
|
|
1960
|
+
computers: z12.array(ComputerRowSchema).nullable()
|
|
1895
1961
|
}).nullable()
|
|
1896
1962
|
});
|
|
1897
|
-
var CallRecapSchema =
|
|
1898
|
-
call:
|
|
1899
|
-
status:
|
|
1900
|
-
startedAt:
|
|
1901
|
-
durationMs:
|
|
1963
|
+
var CallRecapSchema = z12.object({
|
|
1964
|
+
call: z12.object({
|
|
1965
|
+
status: z12.string(),
|
|
1966
|
+
startedAt: z12.string(),
|
|
1967
|
+
durationMs: z12.number().nullable(),
|
|
1902
1968
|
/** Bot-clock pickup offset; absent before the timestamp release, null before its report lands. */
|
|
1903
|
-
pickupMs:
|
|
1904
|
-
agents:
|
|
1969
|
+
pickupMs: z12.number().nullable().optional(),
|
|
1970
|
+
agents: z12.array(z12.object({ id: z12.string(), name: z12.string().nullable() }))
|
|
1905
1971
|
}),
|
|
1906
|
-
topics:
|
|
1907
|
-
goalId:
|
|
1908
|
-
title:
|
|
1909
|
-
owner:
|
|
1910
|
-
state:
|
|
1972
|
+
topics: z12.array(z12.object({
|
|
1973
|
+
goalId: z12.string().uuid(),
|
|
1974
|
+
title: z12.string(),
|
|
1975
|
+
owner: z12.string(),
|
|
1976
|
+
state: z12.string(),
|
|
1911
1977
|
/** Presented Entry content and its author, separately from the current Goal owner. */
|
|
1912
|
-
items:
|
|
1978
|
+
items: z12.array(z12.object({ entryId: z12.string(), author: z12.string(), text: z12.string(), summary: z12.string().nullable(), acknowledged: z12.boolean().optional() })).optional(),
|
|
1913
1979
|
/** Whether the call put it to the person. An item it carried and never said has no row on the
|
|
1914
1980
|
* review (owner, 2026-10-08: "why do we get the third one when it didn't happen in the call?"). */
|
|
1915
|
-
presented:
|
|
1981
|
+
presented: z12.boolean(),
|
|
1916
1982
|
/** Whether THIS call created it — the third way a call touches work, beside carrying a request
|
|
1917
1983
|
* there and filing words there (owner, 2026-10-08, Goal `5b4b1a0a`: "Show the new work, keep my
|
|
1918
1984
|
* words under it"). Created work is never carried, so it is never `presented`; without this the
|
|
1919
1985
|
* row is dropped by the "only what happened on the call" filter. False on a database before
|
|
1920
1986
|
* 20261013080133. */
|
|
1921
|
-
created:
|
|
1987
|
+
created: z12.boolean(),
|
|
1922
1988
|
/** `request` is the Entry that asked it — what a line's `about` names when the line answered or put
|
|
1923
1989
|
* it off. Optional: an older API sent none. */
|
|
1924
|
-
questions:
|
|
1990
|
+
questions: z12.array(z12.object({ id: z12.string().uuid(), state: z12.string(), title: z12.string(), request: z12.string().optional() })),
|
|
1925
1991
|
/** `words` is always what they SAID, verbatim — the record, never replaced. `summary` is what
|
|
1926
1992
|
* the line says in ten words (owner, 2026-10-07): the filer's, or the talker's for the answer it
|
|
1927
1993
|
* gave, so the row scans like a chosen option and their own words stay under it. Absent when
|
|
@@ -1931,33 +1997,70 @@ var CallRecapSchema = z11.object({
|
|
|
1931
1997
|
/** `reply` is the reply the line makes up (an answer, an ok, a deferral), so one reply is one row
|
|
1932
1998
|
* however many lines it cites; `at` is the call lines it came from, so a filed line an answer already
|
|
1933
1999
|
* said is not drawn again (owner, 2026-10-07: "fix them all"); `replyKind` says which replies are answers. */
|
|
1934
|
-
lines:
|
|
1935
|
-
entryId:
|
|
1936
|
-
words:
|
|
1937
|
-
summary:
|
|
1938
|
-
about:
|
|
1939
|
-
reply:
|
|
1940
|
-
replyKind:
|
|
1941
|
-
at:
|
|
2000
|
+
lines: z12.array(z12.object({
|
|
2001
|
+
entryId: z12.string().uuid(),
|
|
2002
|
+
words: z12.string(),
|
|
2003
|
+
summary: z12.string().optional(),
|
|
2004
|
+
about: z12.string().nullable().optional(),
|
|
2005
|
+
reply: z12.string().nullable().optional(),
|
|
2006
|
+
replyKind: z12.string().nullable().optional(),
|
|
2007
|
+
at: z12.array(z12.number()).optional()
|
|
1942
2008
|
}))
|
|
1943
2009
|
})),
|
|
1944
|
-
unfiled:
|
|
2010
|
+
unfiled: z12.array(z12.object({ lineId: z12.string().uuid(), words: z12.string(), atMs: z12.number() })),
|
|
1945
2011
|
/** THE PUBLIC TRANSCRIPT — every line said on the call, in the order it was said, and WHO SAID IT
|
|
1946
2012
|
* (owner, 2026-10-08: "the public view should only have the lines and who said them, and that's
|
|
1947
2013
|
* it"; `docs/brain/phase-three/modular.md` build step 3). `speaker` is the role: "user" is the
|
|
1948
2014
|
* person, "agent" an agent speaking, named in `agent`. The timeline's action lines are ours, not
|
|
1949
2015
|
* theirs, and are not here; nor is a sealed line, which the server has no words for. It stands
|
|
1950
2016
|
* BESIDE `topics` and `unfiled` — what the call did with the words — never instead of them. */
|
|
1951
|
-
said:
|
|
1952
|
-
lineId:
|
|
1953
|
-
speaker:
|
|
1954
|
-
agent:
|
|
1955
|
-
words:
|
|
1956
|
-
atMs:
|
|
2017
|
+
said: z12.array(z12.object({
|
|
2018
|
+
lineId: z12.string().uuid(),
|
|
2019
|
+
speaker: z12.enum(["user", "agent"]),
|
|
2020
|
+
agent: z12.object({ id: z12.string().nullable(), name: z12.string().nullable() }).nullable(),
|
|
2021
|
+
words: z12.string(),
|
|
2022
|
+
atMs: z12.number()
|
|
1957
2023
|
})),
|
|
1958
|
-
more:
|
|
2024
|
+
more: z12.object({ lines: z12.number(), entries: z12.number(), topics: z12.number() }),
|
|
1959
2025
|
/** Last stored position on this page when another exists; absent before paging shipped. */
|
|
1960
|
-
next:
|
|
2026
|
+
next: z12.number().int().nonnegative().nullable().optional(),
|
|
2027
|
+
/** THE CALL AS ONE LIST OF ROWS (owner, 2026-10-14: "we only really want a thing like transcript but
|
|
2028
|
+
* built from the summaries", then "the transcript tabs should show the same but with full words").
|
|
2029
|
+
* Both tabs draw these rows, in this order: Summary from `summary`, Transcript from `words`.
|
|
2030
|
+
* - `put`: an item put to the person, at the first agent line that voiced it. Paigy's sentences
|
|
2031
|
+
* that voiced it are folded into `spoken`, never rows of their own.
|
|
2032
|
+
* - `said`: the person's words, one row per reply or per filed line no reply covers.
|
|
2033
|
+
* - `did`: what Paigy did ("Sent to Mouth: …", "Recorded: …", "Filed on …").
|
|
2034
|
+
* `by` is the row's real author, never inferred from `kind`: a relay Paigy sent to an agent is
|
|
2035
|
+
* Paigy's, not the person's. Optional and additive (owner: "make sure whatever you do is backward
|
|
2036
|
+
* compatible"): an API before it sends none, and the screen falls back to `topics` and `said`. */
|
|
2037
|
+
timeline: z12.array(z12.object({
|
|
2038
|
+
id: z12.string(),
|
|
2039
|
+
position: z12.number(),
|
|
2040
|
+
atMs: z12.number(),
|
|
2041
|
+
kind: z12.enum(["put", "said", "did"]),
|
|
2042
|
+
by: z12.object({ participant: z12.string().nullable(), agentId: z12.string().nullable(), name: z12.string().nullable() }),
|
|
2043
|
+
goalId: z12.string().uuid().nullable(),
|
|
2044
|
+
requestId: z12.string().nullable(),
|
|
2045
|
+
summary: z12.string().nullable(),
|
|
2046
|
+
words: z12.string(),
|
|
2047
|
+
/** Paigy's sentences folded into this row: on a `put` row, what it said putting the item to the
|
|
2048
|
+
* person (before their next row); on a `said` row, what it said in reply (until their next row).
|
|
2049
|
+
* `atMs` is when each was said; optional, absent before 2026-10-14's fix. */
|
|
2050
|
+
spoken: z12.array(z12.object({ lineId: z12.string(), words: z12.string(), atMs: z12.number().optional() })),
|
|
2051
|
+
/** On a `said` row: the work these words were filed on, and whether they answered (recorded) a
|
|
2052
|
+
* question. They replace the "Filed on ..." and "Recorded: ..." rows that repeated the person's own
|
|
2053
|
+
* summary (Brain, 2026-10-14). Optional: absent from an API before it. */
|
|
2054
|
+
filedOn: z12.array(z12.object({ goalId: z12.string().uuid(), title: z12.string() })).optional(),
|
|
2055
|
+
recorded: z12.boolean().optional(),
|
|
2056
|
+
settled: z12.object({ requestId: z12.string(), answer: z12.string() }).nullable().optional(),
|
|
2057
|
+
acknowledged: z12.boolean().optional(),
|
|
2058
|
+
/** On a `put` row: still waiting for the person's answer (not settled, not answered, not put off).
|
|
2059
|
+
* The server's judgement; the screen draws "Still waiting for your answer" from it. Optional: absent
|
|
2060
|
+
* from an API before it, where the screen falls back to its own reading. */
|
|
2061
|
+
waiting: z12.boolean().optional(),
|
|
2062
|
+
lineIds: z12.array(z12.string())
|
|
2063
|
+
})).optional()
|
|
1961
2064
|
});
|
|
1962
2065
|
|
|
1963
2066
|
// src/listening.ts
|
|
@@ -1978,14 +2081,21 @@ function sessionStartHook() {
|
|
|
1978
2081
|
[ -f "\${HOME}/.paigy/token.json" ] || exit 0 # not paired on this machine: nothing to listen as
|
|
1979
2082
|
cat <<'PAIGY'
|
|
1980
2083
|
Paigy: nothing pushes answers into a session started in a terminal \u2014 an answer waits for your
|
|
1981
|
-
next contact({ wait: false }). Start your own listener now
|
|
1982
|
-
|
|
2084
|
+
next contact({ wait: false }). Start your own listener now with your harness's MONITOR tool, the kind
|
|
2085
|
+
that wakes you on every line it prints (in Claude Code: Monitor, not a background Bash command, which
|
|
2086
|
+
only tells you when it exits). When the monitor expires, start it again:
|
|
1983
2087
|
|
|
1984
|
-
npx -y -p @paigy/mcp@latest paigy-listen
|
|
2088
|
+
npx -y -p @paigy/mcp@latest paigy-listen --brief
|
|
1985
2089
|
|
|
1986
2090
|
Each line it prints is a Delivery waiting for you: read the Goal, and reply with contact when
|
|
1987
|
-
the answer needs a decision.
|
|
1988
|
-
|
|
2091
|
+
the answer needs a decision.
|
|
2092
|
+
|
|
2093
|
+
ONE LISTENER PER SESSION, AND ANOTHER SESSION'S IS NOT YOURS. Identities here are per session, so
|
|
2094
|
+
a paigy-listen you find in ps is almost certainly another session listening as itself, and
|
|
2095
|
+
starting yours takes nothing from it. Never decide this from ps: the listen tool reads the mark
|
|
2096
|
+
for YOUR OWN slot and answers in one call. Ask it, or just start the listener above; only a
|
|
2097
|
+
second one for the same slot is the mistake. Then call contact({ wait: false }) once: work handed
|
|
2098
|
+
to you before this session started waits there.
|
|
1989
2099
|
PAIGY
|
|
1990
2100
|
exit 0
|
|
1991
2101
|
`;
|
|
@@ -2021,7 +2131,7 @@ function decideListen(f) {
|
|
|
2021
2131
|
return {
|
|
2022
2132
|
status: "start",
|
|
2023
2133
|
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`,
|
|
2024
|
-
how: "Run this command NOW
|
|
2134
|
+
how: "Run this command NOW with your harness's MONITOR tool, the kind that wakes you on every line it prints (in Claude Code: Monitor, not a background Bash command, which only tells you when it exits); start it again when the monitor expires. Each line it prints is a Delivery waiting for you: read the Goal it names with get_goals, and answer with contact. Start it once."
|
|
2025
2135
|
};
|
|
2026
2136
|
}
|
|
2027
2137
|
function listenMark(slot, home = homedir()) {
|
|
@@ -2037,6 +2147,12 @@ function writeListenMark(slot, pid, home = homedir()) {
|
|
|
2037
2147
|
function removeListenMark(slot, home = homedir()) {
|
|
2038
2148
|
rmSync(listenMark(slot, home), { force: true });
|
|
2039
2149
|
}
|
|
2150
|
+
function clear(path) {
|
|
2151
|
+
try {
|
|
2152
|
+
rmSync(path, { force: true });
|
|
2153
|
+
} catch {
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2040
2156
|
function listenerAlive(slot, home = homedir()) {
|
|
2041
2157
|
const path = listenMark(slot, home);
|
|
2042
2158
|
let pid;
|
|
@@ -2046,7 +2162,7 @@ function listenerAlive(slot, home = homedir()) {
|
|
|
2046
2162
|
return null;
|
|
2047
2163
|
}
|
|
2048
2164
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
2049
|
-
|
|
2165
|
+
clear(path);
|
|
2050
2166
|
return null;
|
|
2051
2167
|
}
|
|
2052
2168
|
try {
|
|
@@ -2054,7 +2170,7 @@ function listenerAlive(slot, home = homedir()) {
|
|
|
2054
2170
|
return pid;
|
|
2055
2171
|
} catch (e) {
|
|
2056
2172
|
if (e.code === "EPERM") return pid;
|
|
2057
|
-
|
|
2173
|
+
clear(path);
|
|
2058
2174
|
return null;
|
|
2059
2175
|
}
|
|
2060
2176
|
}
|
|
@@ -2067,6 +2183,100 @@ function wakeStatusPath(slot, home = homedir()) {
|
|
|
2067
2183
|
function existingListener(slot, env, home = homedir()) {
|
|
2068
2184
|
return listenerAlive(listenerKey(slot, env), home) ?? (env.CODEX_THREAD_ID ? listenerAlive(slot, home) : null);
|
|
2069
2185
|
}
|
|
2186
|
+
var UNLISTENED_EVERY_MS = 10 * 6e4;
|
|
2187
|
+
var WATCHING_CLIENTS = /* @__PURE__ */ new Set(["claude-code"]);
|
|
2188
|
+
var NON_WATCHING_CLIENTS = /* @__PURE__ */ new Set(["claude-ai", "cursor", "cursor-vscode", "windsurf", "cline", "roo-cline", "continue", "vscode", "visual studio code", "zed", "antigravity"]);
|
|
2189
|
+
function canWatch(f) {
|
|
2190
|
+
if (harnessDriven(f.env) || f.env.PAIGY_ON_WAKE || f.env.CODEX_THREAD_ID) return "yes";
|
|
2191
|
+
const c = f.client?.toLowerCase();
|
|
2192
|
+
if (c && WATCHING_CLIENTS.has(c)) return "yes";
|
|
2193
|
+
if (c && NON_WATCHING_CLIENTS.has(c)) return "no";
|
|
2194
|
+
return "unknown";
|
|
2195
|
+
}
|
|
2196
|
+
function unlistenedNote(f, _now) {
|
|
2197
|
+
if (harnessDriven(f.env) || f.pidAlive) return null;
|
|
2198
|
+
const decision = decideListen(f);
|
|
2199
|
+
if (decision.status !== "start") return null;
|
|
2200
|
+
const head = `NOTHING CAN REACH THIS SESSION WHILE IT RESTS. No listener runs for your slot (${f.slot}) and no harness pump delivers to it`;
|
|
2201
|
+
switch (canWatch(f)) {
|
|
2202
|
+
case "no":
|
|
2203
|
+
return { unlistened: `${head}, and this host cannot run a listener. Work reaches you only as you act \u2014 it rides your tool calls, as it did this one \u2014 so call contact({ wait: false }) before you stop.` };
|
|
2204
|
+
case "yes":
|
|
2205
|
+
return { unlistened: `${head}. Start the listener below as a watched background task; a listener you see in ps belongs to another session's slot, never to yours.`, listen_command: decision.command };
|
|
2206
|
+
default:
|
|
2207
|
+
return { unlistened: `${head}. If this host can run a watched background task, start the listener below; if it cannot, work reaches you only as you act, so call contact({ wait: false }) before you stop.`, listen_command: decision.command };
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
var ReachTeller = class {
|
|
2211
|
+
constructor(every = UNLISTENED_EVERY_MS) {
|
|
2212
|
+
this.every = every;
|
|
2213
|
+
}
|
|
2214
|
+
every;
|
|
2215
|
+
checked = /* @__PURE__ */ new Map();
|
|
2216
|
+
async note(slot, tool, d) {
|
|
2217
|
+
const now = d.now();
|
|
2218
|
+
const last = this.checked.get(slot);
|
|
2219
|
+
if (last !== void 0 && now - last < this.every) return null;
|
|
2220
|
+
this.checked.set(slot, now);
|
|
2221
|
+
let note;
|
|
2222
|
+
try {
|
|
2223
|
+
note = unlistenedNote(d.facts(), now);
|
|
2224
|
+
} catch {
|
|
2225
|
+
return null;
|
|
2226
|
+
}
|
|
2227
|
+
if (!note) return null;
|
|
2228
|
+
let waiting = null;
|
|
2229
|
+
if (tool !== "contact") {
|
|
2230
|
+
try {
|
|
2231
|
+
waiting = waitingSummary(await d.poll());
|
|
2232
|
+
} catch {
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return { paigy_reach: { ...note, ...waiting ?? {} } };
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
function withReach(shaped, reach) {
|
|
2239
|
+
if (!reach || !shaped || typeof shaped !== "object" || Array.isArray(shaped)) return shaped;
|
|
2240
|
+
return { ...reach, ...shaped };
|
|
2241
|
+
}
|
|
2242
|
+
var HOOKED_HARNESSES = "Claude Code and Codex";
|
|
2243
|
+
function listenBlock(decision, f, stale) {
|
|
2244
|
+
const block = {
|
|
2245
|
+
listen: decision,
|
|
2246
|
+
listen_permanent: `\`${ENABLE_LISTEN_COMMAND}\` installs the SessionStart hook for ${HOOKED_HARNESSES}, so every future session there is told this at its start. Other hosts are not hooked; their sessions learn it as they act.`
|
|
2247
|
+
};
|
|
2248
|
+
if (decision.status === "start") {
|
|
2249
|
+
block.listen_prompt = canWatch(f) === "no" ? "This host cannot run a listener, so nothing reaches this session while it rests. Work arrives with your tool calls; call contact({ wait: false }) before you stop." : "Start your own listener NOW, as described in `listen` \u2014 a watched background task, left running for this session. Without it, every answer waits until you call contact({ wait: false }).";
|
|
2250
|
+
}
|
|
2251
|
+
if (stale) {
|
|
2252
|
+
block.hook_refresh = `The SessionStart hook on this machine is an older text. Ask the user to re-run \`${ENABLE_LISTEN_COMMAND}\` to refresh it \u2014 the old one tells a session to skip its listener when it sees another session's.`;
|
|
2253
|
+
}
|
|
2254
|
+
return block;
|
|
2255
|
+
}
|
|
2256
|
+
var ENABLE_LISTEN_COMMAND = "npx -y -p @paigy/mcp@latest paigy-enable-tools";
|
|
2257
|
+
function hookStale(home = homedir()) {
|
|
2258
|
+
try {
|
|
2259
|
+
return readFileSync(join(home, ".paigy", "hooks", "session-start.sh"), "utf8") !== sessionStartHook();
|
|
2260
|
+
} catch {
|
|
2261
|
+
return false;
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
function waitingSummary(received) {
|
|
2265
|
+
const r = received ?? {};
|
|
2266
|
+
const events = Array.isArray(r.events) ? r.events : [];
|
|
2267
|
+
const ids = events.map((e) => String(e?.eventId ?? "")).filter(Boolean);
|
|
2268
|
+
const claimable = r.claimable && typeof r.claimable === "object" ? String(r.claimable.title ?? "") : "";
|
|
2269
|
+
if (!ids.length && !claimable) return null;
|
|
2270
|
+
const kinds = events.map((e) => String(e?.kind ?? "event")).join(", ");
|
|
2271
|
+
const parts = [
|
|
2272
|
+
ids.length ? `${ids.length} event${ids.length === 1 ? "" : "s"} addressed to you (${kinds})` : "",
|
|
2273
|
+
claimable ? `work waiting: ${claimable}` : ""
|
|
2274
|
+
].filter(Boolean);
|
|
2275
|
+
return {
|
|
2276
|
+
waiting: `${parts.join("; ")}. Nothing acknowledged them \u2014 handle them with contact, and acknowledge with contact({ ackEventIds }) so they stop repeating. Read a Goal with get_goals before acting on a summary of it.`,
|
|
2277
|
+
...ids.length ? { waiting_events: ids } : {}
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2070
2280
|
|
|
2071
2281
|
export {
|
|
2072
2282
|
mcpInputSchema,
|
|
@@ -2082,5 +2292,10 @@ export {
|
|
|
2082
2292
|
removeListenMark,
|
|
2083
2293
|
listenerKey,
|
|
2084
2294
|
wakeStatusPath,
|
|
2085
|
-
existingListener
|
|
2295
|
+
existingListener,
|
|
2296
|
+
ReachTeller,
|
|
2297
|
+
withReach,
|
|
2298
|
+
listenBlock,
|
|
2299
|
+
ENABLE_LISTEN_COMMAND,
|
|
2300
|
+
hookStale
|
|
2086
2301
|
};
|