@sjawhar/pi-envoy 16.8.0 → 16.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dispatch.js +326 -223
- package/dist/envoy.js +262 -190
- package/dist/skills/dispatch/SKILL.md +2 -1
- package/dist/skills/dispatch-first/SKILL.md +2 -2
- package/package.json +1 -1
package/dist/dispatch.js
CHANGED
|
@@ -14745,6 +14745,8 @@ var CommentEventPayloadSchema = object({
|
|
|
14745
14745
|
project_key: string2().optional(),
|
|
14746
14746
|
artifact_slug: string2().optional(),
|
|
14747
14747
|
body: string2().optional(),
|
|
14748
|
+
body_truncated: boolean2().optional(),
|
|
14749
|
+
payload_omitted: boolean2().optional(),
|
|
14748
14750
|
reply_to: string2().nullish(),
|
|
14749
14751
|
ask_id: string2().nullish(),
|
|
14750
14752
|
ask_question: string2().optional(),
|
|
@@ -14770,6 +14772,8 @@ var CommentEventPayloadSchema = object({
|
|
|
14770
14772
|
var MessageEventPayloadSchema = object({
|
|
14771
14773
|
id: string2().optional(),
|
|
14772
14774
|
body: string2().optional(),
|
|
14775
|
+
body_truncated: boolean2().optional(),
|
|
14776
|
+
payload_omitted: boolean2().optional(),
|
|
14773
14777
|
target: string2().nullish(),
|
|
14774
14778
|
in_reply_to: string2().nullish(),
|
|
14775
14779
|
reply_body: string2().optional(),
|
|
@@ -15092,12 +15096,14 @@ function componentsArgument(z) {
|
|
|
15092
15096
|
}).describe("Attach the issue to architecture components. Attach the root before decomposing it; children inherit unless they choose.");
|
|
15093
15097
|
}
|
|
15094
15098
|
var SPEC_WRITING_POINTER = "Write a spec as skill://dispatch-writing-specs says.";
|
|
15095
|
-
function imagesArgument(z, owner
|
|
15096
|
-
return z.array(z.string({ min: 1 }), { min: 1 }).describe(`Optional local picture files to show inline: PNG, JPEG, GIF or WebP (by their bytes, not their name), each at most 25 MiB. Each is uploaded to ${owner} and appended after a blank line as one  line, in this order; those lines count toward
|
|
15099
|
+
function imagesArgument(z, owner) {
|
|
15100
|
+
return z.array(z.string({ min: 1 }), { min: 1 }).describe(`Optional local picture files to show inline: PNG, JPEG, GIF or WebP (by their bytes, not their name), each at most 25 MiB. Each is uploaded to ${owner} and appended after a blank line as one  line, in this order; those lines count toward the bound Dispatch holds the text to, which it names in its refusal.`).optional();
|
|
15097
15101
|
}
|
|
15098
15102
|
var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
15099
|
-
var
|
|
15100
|
-
var
|
|
15103
|
+
var DISPATCH_BLOCK_UNITS = 32000;
|
|
15104
|
+
var DISPATCH_ITEM_BLOCKS = 32768;
|
|
15105
|
+
var BODY_BLOCK_RULE = `Each block (a paragraph, list, quote, table or code block) holds at most ${DISPATCH_BLOCK_UNITS} ` + `characters and a body at most ${DISPATCH_ITEM_BLOCKS} blocks; Dispatch refuses a longer one and ` + "names it, and `dispatch limits` prints the bounds.";
|
|
15106
|
+
var ASK_BOUND_RULE = "Dispatch bounds an ask's question and its options together, refuses a longer one and names " + "the bound, and `dispatch limits` prints it. An ask is short and asks one thing; its reasoning " + "goes in the document, not in the question.";
|
|
15101
15107
|
var DISPATCH_HANDOFF_BODY_MAX = 262144;
|
|
15102
15108
|
var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
15103
15109
|
var HANDOFF_PHASE_RULE_WORDS = "a lowercase letter, then up to 31 lowercase letters, digits or hyphens, such as implement";
|
|
@@ -15116,16 +15122,12 @@ function handoffProblem(value) {
|
|
|
15116
15122
|
return HANDOFF_PHASE_RULE;
|
|
15117
15123
|
if (typeof body !== "string")
|
|
15118
15124
|
return;
|
|
15119
|
-
const bytes = new TextEncoder().encode(body).length;
|
|
15120
|
-
if (bytes > DISPATCH_HANDOFF_BODY_MAX) {
|
|
15121
|
-
return `body is ${bytes - DISPATCH_HANDOFF_BODY_MAX} bytes over the ${DISPATCH_HANDOFF_BODY_MAX}-byte limit (${bytes}/${DISPATCH_HANDOFF_BODY_MAX})`;
|
|
15122
|
-
}
|
|
15123
15125
|
if (!isJsonObjectText(body)) {
|
|
15124
15126
|
return 'body is not one JSON object: a handoff body is a JSON object such as {"schemaVersion":1}';
|
|
15125
15127
|
}
|
|
15126
15128
|
return;
|
|
15127
15129
|
}
|
|
15128
|
-
var HANDOFF_RULE = `${HANDOFF_PHASE_RULE}; the body is one JSON object
|
|
15130
|
+
var HANDOFF_RULE = `${HANDOFF_PHASE_RULE}; the body is one JSON object.`;
|
|
15129
15131
|
var handoffValidation = {
|
|
15130
15132
|
check: (value) => handoffProblem(value) === undefined,
|
|
15131
15133
|
message: HANDOFF_RULE,
|
|
@@ -15190,7 +15192,7 @@ var dispatchToolSpecs = [
|
|
|
15190
15192
|
arguments: (z) => ({
|
|
15191
15193
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
15192
15194
|
status: z.enum(ISSUE_STATUSES).describe("New lifecycle status.").optional(),
|
|
15193
|
-
reason: z.string(
|
|
15195
|
+
reason: z.string().describe(`Required with status done, and only with it: why the issue is closing. Posted on the issue as a message before it closes. ${BODY_BLOCK_RULE}`).optional(),
|
|
15194
15196
|
title: z.string({ min: 1, max: ISSUE_TITLE_MAX }).describe("Replacement title, at most 1,000 characters.").optional(),
|
|
15195
15197
|
labels: z.array(z.string({ min: 1, max: 40 }), { max: 20 }).describe("Replacement label set, at most 20 labels of up to 40 characters; replaces every existing label.").optional(),
|
|
15196
15198
|
priority: z.number({ int: true, min: 0, max: 3 }).nullable().optional().describe("Coarse priority: 0 is P0 (highest) through 3 is P3 (lowest); null clears it."),
|
|
@@ -15236,13 +15238,13 @@ var dispatchToolSpecs = [
|
|
|
15236
15238
|
}
|
|
15237
15239
|
]
|
|
15238
15240
|
},
|
|
15239
|
-
description: "Open a to-do or permission only a human can give, or a decision that has no document to " + "live in. A question about the design an issue's document records is not this tool: write " + "it into that document as a decision block (dispatch doc-edit inserting an ask block at the " + "end of the section it concerns), at every phase, approved spec or not; the block reaches " + "the Inbox and its answer lands next to its context. Never give an ask an Approve option: a " + "document is approved through dispatch request-approval. Do not use this tool for a status " + "update or discussion; use dispatch message instead. Never create an issue to park a " + "question: the question is an ask on the issue it concerns. " + ASK_QUESTION_CONTRACT + " " + ASK_OPTIONS_CONTRACT + " For an action only a human can perform, state what it changes and risks as constraints. " + "Anything that requires a human to do, including a credential or grant renewal, is an ask, " + "never a message. Measure what you can first, and put the measurement and the size of the " + "population it covers in the question; drop an option that cannot fix most of that " + "population, never offer it cut down, and keep an option not to act (Hold). Set urgency high " + "when your work halts on the answer, and keep working on everything else. " + "Anchor a to-do about a document passage, thread reply_to/reply_to_ask, or cite a dispatch:// " + `reference \u2014 it must be answerable from its own text and anchor alone, never "see above". ` + `A quote anchor is pinned to its block.
|
|
15241
|
+
description: "Open a to-do or permission only a human can give, or a decision that has no document to " + "live in. A question about the design an issue's document records is not this tool: write " + "it into that document as a decision block (dispatch doc-edit inserting an ask block at the " + "end of the section it concerns), at every phase, approved spec or not; the block reaches " + "the Inbox and its answer lands next to its context. Never give an ask an Approve option: a " + "document is approved through dispatch request-approval. Do not use this tool for a status " + "update or discussion; use dispatch message instead. Never create an issue to park a " + "question: the question is an ask on the issue it concerns. " + ASK_QUESTION_CONTRACT + " " + ASK_OPTIONS_CONTRACT + " For an action only a human can perform, state what it changes and risks as constraints. " + "Anything that requires a human to do, including a credential or grant renewal, is an ask, " + "never a message. Measure what you can first, and put the measurement and the size of the " + "population it covers in the question; drop an option that cannot fix most of that " + "population, never offer it cut down, and keep an option not to act (Hold). Set urgency high " + "when your work halts on the answer, and keep working on everything else. " + "Anchor a to-do about a document passage, thread reply_to/reply_to_ask, or cite a dispatch:// " + `reference \u2014 it must be answerable from its own text and anchor alone, never "see above". ` + `A quote anchor is pinned to its block. ${ASK_BOUND_RULE} The lines images appends count ` + `toward that bound, and an ask has at most 8 options. ${RELATED_CHECK_RESULT} ` + `An ask among the related items says whether it is answered, by whom and with which options. ${OWNER_REFERENCE}`,
|
|
15240
15242
|
arguments: (z) => ({
|
|
15241
15243
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15242
15244
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
15243
15245
|
artifact: z.string().describe("Project document artifact id, slug, or filename.").optional(),
|
|
15244
15246
|
ref: z.string().describe("Optional dispatch:// reference (issue, document, block, message, or ask); appended to the question and rendered as a link.").optional(),
|
|
15245
|
-
question: z.string(
|
|
15247
|
+
question: z.string().describe(`${ASK_QUESTION_CONTRACT} ${ASK_BOUND_RULE}`),
|
|
15246
15248
|
options: z.array(z.object({
|
|
15247
15249
|
label: z.string().describe("Selectable option label."),
|
|
15248
15250
|
description: z.string().optional().describe("What this option costs.")
|
|
@@ -15254,7 +15256,7 @@ var dispatchToolSpecs = [
|
|
|
15254
15256
|
quote: z.string().describe("Exact text the decision concerns."),
|
|
15255
15257
|
occurrence: z.number({ int: true, min: 0 }).describe("Zero-based occurrence of the quote.").optional()
|
|
15256
15258
|
}).describe("Optional document location for the question.").optional(),
|
|
15257
|
-
images: imagesArgument(z, "the issue (or the project document's project)"
|
|
15259
|
+
images: imagesArgument(z, "the issue (or the project document's project)")
|
|
15258
15260
|
}),
|
|
15259
15261
|
validation: documentOwnerValidation(true)
|
|
15260
15262
|
},
|
|
@@ -15277,7 +15279,7 @@ var dispatchToolSpecs = [
|
|
|
15277
15279
|
description: "Edit an open question in place. Use it to correct or refine the same decision; retract the " + "old ask and open a new one when the decision itself changes. " + ASK_QUESTION_CONTRACT + " " + ASK_OPTIONS_CONTRACT + " Previous text remains in the event log. Only the asking session can edit it; answered or " + "resolved asks cannot be edited. An ask that lives as an `ask` block in a document is written " + "in the document too, changing only the fields you name - pass urgency alone and the " + "question's wording, formatting, links and comment anchors are untouched - so the edit " + "writes a document version and closes a spec's design gate until that version is approved; " + "text the block cannot carry back unchanged is refused, naming the field - an option label " + 'containing ": ", the separator between a label and its description, is one example.',
|
|
15278
15280
|
arguments: (z) => ({
|
|
15279
15281
|
ask: z.string().describe("Ask id (uuid); an 8+ hex prefix unique among this session's own open asks works too."),
|
|
15280
|
-
question: z.string(
|
|
15282
|
+
question: z.string().optional().describe(`${ASK_QUESTION_CONTRACT} Replaces the ask's question. ${ASK_BOUND_RULE}`),
|
|
15281
15283
|
options: z.array(z.object({
|
|
15282
15284
|
label: z.string().describe("Selectable option label."),
|
|
15283
15285
|
description: z.string().optional().describe("What this option costs.")
|
|
@@ -15329,7 +15331,7 @@ var dispatchToolSpecs = [
|
|
|
15329
15331
|
{
|
|
15330
15332
|
name: "dispatch_comment",
|
|
15331
15333
|
example: { issue: "DSP-1", body: "Looks good." },
|
|
15332
|
-
description: "Add review feedback to an issue or project document quote, or reply to a question asked with dispatch ask. " + "Do not use it for an exact replacement; use " + `dispatch suggest instead. A quote anchor is pinned to its block. A reply under an open ask asks for clarification, not an answer: answer it with reply_to_ask, or reword the ask with dispatch edit-ask, rather than opening a second ask.
|
|
15334
|
+
description: "Add review feedback to an issue or project document quote, or reply to a question asked with dispatch ask. " + "Do not use it for an exact replacement; use " + `dispatch suggest instead. A quote anchor is pinned to its block. A reply under an open ask asks for clarification, not an answer: answer it with reply_to_ask, or reword the ask with dispatch edit-ask, rather than opening a second ask. ${BODY_BLOCK_RULE} The lines images appends count toward it. ${OWNER_REFERENCE}`,
|
|
15333
15335
|
arguments: (z) => ({
|
|
15334
15336
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15335
15337
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15337,11 +15339,11 @@ var dispatchToolSpecs = [
|
|
|
15337
15339
|
ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
|
|
15338
15340
|
quote: z.string().describe("Optional exact quoted document text.").optional(),
|
|
15339
15341
|
occurrence: z.number({ int: true, min: 0 }).describe("Optional zero-based occurrence of quote.").optional(),
|
|
15340
|
-
body: z.string(
|
|
15342
|
+
body: z.string().describe(`Review comment. ${BODY_BLOCK_RULE}`),
|
|
15341
15343
|
reply_to: z.string().describe("A comment id (uuid); replying to any comment in a thread continues that thread (an " + "ask's clarification thread included). A block reference to one block of the comment " + "(dispatch://KEY/comment/<id>#b-<block id>) replies to that comment and names the " + "passage the reply answers. To reply to an ask, use reply_to_ask with the ask id, or " + "with a reference to one of its parts, instead.").optional(),
|
|
15342
15344
|
reply_to_ask: z.string().describe("Optional ask id to reply to, threading this comment under that question. A block " + "reference to one part of the ask (dispatch://KEY/ask/<id>#b-<part id>, the id an " + "option or the answer carries) threads under that ask and names the part the reply " + "answers. Mutually exclusive with reply_to.").optional(),
|
|
15343
15345
|
turn: z.enum(["agent", "human"]).describe("Only with reply_to_ask: who holds the turn after this reply. agent: a progress note - " + "you keep the turn and the ask stays 'Waiting on agents' for the human; human (default): " + "you need the human to act - the ask returns to 'Waiting on you'. human does not " + "apply to an approval request a newer version moved: it stays with you until dispatch " + "request-approval hands it back at the current version.").optional(),
|
|
15344
|
-
images: imagesArgument(z, "the issue (or the project document's project)"
|
|
15346
|
+
images: imagesArgument(z, "the issue (or the project document's project)")
|
|
15345
15347
|
}),
|
|
15346
15348
|
validation: commentValidation
|
|
15347
15349
|
},
|
|
@@ -15353,7 +15355,7 @@ var dispatchToolSpecs = [
|
|
|
15353
15355
|
quote: "old wording",
|
|
15354
15356
|
replace_with: "new wording"
|
|
15355
15357
|
},
|
|
15356
|
-
description: "Propose an exact replacement for quoted document text. Do not use it for general feedback; use " + `dispatch comment instead.
|
|
15358
|
+
description: "Propose an exact replacement for quoted document text. Do not use it for general feedback; use " + `dispatch comment instead. ${BODY_BLOCK_RULE} ${OWNER_REFERENCE}`,
|
|
15357
15359
|
arguments: (z) => ({
|
|
15358
15360
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15359
15361
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15361,7 +15363,7 @@ var dispatchToolSpecs = [
|
|
|
15361
15363
|
ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
|
|
15362
15364
|
quote: z.string().describe("Exact document text to replace."),
|
|
15363
15365
|
replace_with: z.string().describe("Replacement text; a CR LF or a lone carriage return in it is written as a line feed."),
|
|
15364
|
-
body: z.string(
|
|
15366
|
+
body: z.string().describe(`Optional rationale. ${BODY_BLOCK_RULE}`).optional(),
|
|
15365
15367
|
occurrence: z.number({ int: true, min: 0 }).describe("Optional zero-based occurrence of quote.").optional()
|
|
15366
15368
|
}),
|
|
15367
15369
|
validation: documentOwnerValidation(true, true)
|
|
@@ -15369,12 +15371,12 @@ var dispatchToolSpecs = [
|
|
|
15369
15371
|
{
|
|
15370
15372
|
name: "dispatch_message",
|
|
15371
15373
|
example: { issue: "DSP-1", body: "Implementation started." },
|
|
15372
|
-
description: "Post a note humans must read now: a reply to a human's message or a deliverable that landed. A to-do only a human can " + "complete is an ask (dispatch ask), so it reaches their inbox. Never progress or status updates - Dispatch is a high-signal " + "record, not a log. Not a design decision (write it as a decision block in the document) or document feedback (dispatch comment). " + "To answer a human's direct message to this session - one sent from the Agents page, which names no issue - pass that message's bare id as " + "in_reply_to and no issue; the reply lands in that conversation. Another call with the same in_reply_to and new text posts a follow-up, " + "threaded under this session's first reply; the same text again posts nothing. dispatch read --message <id> reads " + "that conversation back. " + "Every other message names its issue; keep --issue whenever the frame you answer gave one. A BTW, Aside or Steer " + "frame carries a reply_with command: answer with it, on that issue. On Oh My Pi an Agents-page Send or Aside " + "arrives as a user message: answer in the conversation, with no dispatch message. " +
|
|
15374
|
+
description: "Post a note humans must read now: a reply to a human's message or a deliverable that landed. A to-do only a human can " + "complete is an ask (dispatch ask), so it reaches their inbox. Never progress or status updates - Dispatch is a high-signal " + "record, not a log. Not a design decision (write it as a decision block in the document) or document feedback (dispatch comment). " + "To answer a human's direct message to this session - one sent from the Agents page, which names no issue - pass that message's bare id as " + "in_reply_to and no issue; the reply lands in that conversation. Another call with the same in_reply_to and new text posts a follow-up, " + "threaded under this session's first reply; the same text again posts nothing. dispatch read --message <id> reads " + "that conversation back. " + "Every other message names its issue; keep --issue whenever the frame you answer gave one. A BTW, Aside or Steer " + "frame carries a reply_with command: answer with it, on that issue. On Oh My Pi an Agents-page Send or Aside " + "arrives as a user message: answer in the conversation, with no dispatch message. " + `${BODY_BLOCK_RULE} The lines images appends count toward it. ${ISSUE_REFERENCE}`,
|
|
15373
15375
|
arguments: (z) => ({
|
|
15374
15376
|
issue: z.string().describe(`${ISSUE_REFERENCE} Omit it only when in_reply_to answers a human's direct message to this session.`).optional(),
|
|
15375
|
-
body: z.string(
|
|
15377
|
+
body: z.string().describe(`Update text. ${BODY_BLOCK_RULE}`),
|
|
15376
15378
|
in_reply_to: z.string().describe("Optional message id or dispatch://KEY/message/<id> reference to reply to, threading " + "this message under it so the reply stays with the original in the Conversation. " + "A block reference to one block of the message (dispatch://KEY/message/<id>#b-<block id>) " + "replies to that message and names the passage the reply answers. " + "A bare id with no issue answers a human's direct message to this session; a " + "dispatch://KEY/message/<id> names the issue its message lives on, so that form is a " + "reply on that issue.").optional(),
|
|
15377
|
-
images: imagesArgument(z, "the issue (a reply to a direct message: your own conversation, dispatch://agent/<your session id>)"
|
|
15379
|
+
images: imagesArgument(z, "the issue (a reply to a direct message: your own conversation, dispatch://agent/<your session id>)")
|
|
15378
15380
|
}),
|
|
15379
15381
|
validation: messageValidation
|
|
15380
15382
|
},
|
|
@@ -15509,7 +15511,7 @@ var dispatchToolSpecs = [
|
|
|
15509
15511
|
{
|
|
15510
15512
|
name: "dispatch_read",
|
|
15511
15513
|
example: { issue: "DSP-1" },
|
|
15512
|
-
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOCUMENT_UNLOADABLE` (the document " + "needs a rebuild) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + "An issue whose spec marks requirements carries one `Coverage:` line per gap, `Coverage: R3 has no check` or " + "`Coverage: R3 has no plan task` (the second only once the issue has a plan document), counting the `check` and " + "`plan_task` blocks of every document of the issue and of its descendants; a spec that marks none reads " + "`Coverage: the spec marks no requirements`. Nothing is refused for a gap. " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Type:` for a block of a document, `Document:`, every attribute a typed block carries " + "(a `check`'s serves, surface, run, when and negative_control; a `plan_task`'s serves and needs), `Changed in version:` " + "and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
|
|
15514
|
+
description: "Read an issue or document summary, targeted ask, or targeted comment reply chain, or the conversation " + "a message belongs to. Do not use it for document contents; use dispatch doc-read instead. Supply ref, issue, " + "issue plus artifact (one of its documents), project plus artifact, or project alone, which lists the project's documents on no issue and nothing more; or message alone, which reads a human's direct message to this session and every " + "reply to it (they belong to no issue). A document summary names its issue, reference, versions and approval. " + "An issue read lists every document, picture and file the issue holds under `Documents:`, each by slug, filename and kind. " + "An anchored comment or ask also says where its quote sits, as `Position:`: the block's path from the top, " + "and in a table the row (0 is the header), the cells before the anchored one, and the column's header; " + "`Position: unavailable (<code>)` when Dispatch could not read the document: `DOC_SERVICE_UNAVAILABLE` " + "(try again shortly), `DOC_SCHEMA` (the document needs repair), `DOCUMENT_UNLOADABLE` (the document " + "needs a rebuild) or `INTERNAL`. " + "An issue read carries a `Progress:` line, `tasks 3/7, children 2/5`: its spec's task-list items " + "(`- [ ]` / `- [x]`, nested lists included) and its direct children, each done of total and each only " + "when it has any (`Progress: none` otherwise). " + "An issue whose spec marks requirements carries one `Coverage:` line per gap, `Coverage: R3 has no check` or " + "`Coverage: R3 has no plan task` (the second only once the issue has a plan document), counting the `check` and " + "`plan_task` blocks of every document of the issue and of its descendants; a spec that marks none reads " + "`Coverage: the spec marks no requirements`. Nothing is refused for a gap. " + `An issue read, and its dispatch://KEY/log, lists the issue's last ${DEFAULT_ISSUE_READ_EVENTS} events, oldest first; ` + "--events N lists the last N, and --all-events every one. " + "A comment reply chain names the comment each nested reply answers as `Answers: <comment id>`. " + "Every read ends with `Referenced by:` (what cites or hangs off this node, each with its dispatch:// address, " + "an excerpt, and when) and `Links:` (what it cites), so tracing provenance is one call. " + "A block read prints `Block:`, `Type:` for a block of a document, `Document:`, every attribute a typed block carries " + "(a `check`'s serves, surface, run, when and negative_control; a `plan_task`'s serves and needs), `Changed in version:` " + "and `Text:`, then those two sections; a pinned one adds " + "the block's text at that version and whether it is unchanged, changed or removed since, and an absent block, unpinned, " + "reads `No block <id> in <document>.` " + "The pictures the shown messages, asks and comments embed come back as images you see, newest first, at most 8 " + "and 10 MiB of them per read, each a PNG, JPEG, GIF or WebP of at most 3,750,000 bytes (5 MB of base64); a `Pictures:` section names each " + "one shown, in order, and the rest by reference, for dispatch doc-read. A picture this session was already shown is named, not sent again " + "(every request carries the session's history, and the provider refuses one over 32 MB); dispatch doc-read shows it again. " + OWNER_REFERENCE,
|
|
15513
15515
|
arguments: (z) => ({
|
|
15514
15516
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15515
15517
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15636,6 +15638,13 @@ var dispatchToolSpecs = [
|
|
|
15636
15638
|
arguments: () => ({}),
|
|
15637
15639
|
strict: true
|
|
15638
15640
|
},
|
|
15641
|
+
{
|
|
15642
|
+
name: "dispatch_limits",
|
|
15643
|
+
example: {},
|
|
15644
|
+
description: "The bounds this Dispatch server holds a write to, read from the server itself: how long one block of a body may be and how many blocks a body may hold, how many options an ask may have and how long an ask's question and options are together, how long a body an event carries whole may be, and how many bytes a request, a document and a handoff body may hold. Dispatch refuses a text over a bound and names the block or the field it passed; no tool and no command cuts or refuses your text before the server reads it, so these numbers are what decides whether a write is taken.",
|
|
15645
|
+
arguments: () => ({}),
|
|
15646
|
+
strict: true
|
|
15647
|
+
},
|
|
15639
15648
|
{
|
|
15640
15649
|
name: "dispatch_handoff_write",
|
|
15641
15650
|
example: {
|
|
@@ -17168,6 +17177,9 @@ class DispatchClient {
|
|
|
17168
17177
|
async whoami() {
|
|
17169
17178
|
return this.#json("GET", ["api", "v1", "whoami"]);
|
|
17170
17179
|
}
|
|
17180
|
+
async limits() {
|
|
17181
|
+
return this.#json("GET", ["api", "v1", "limits"]);
|
|
17182
|
+
}
|
|
17171
17183
|
async inbox(assignee) {
|
|
17172
17184
|
return this.#json("GET", ["api", "v1", "inbox"], undefined, { assignee });
|
|
17173
17185
|
}
|
|
@@ -17847,146 +17859,109 @@ function picturesNewestFirst(texts) {
|
|
|
17847
17859
|
return [...new Set(ordered.flatMap(({ item }) => pictureAddresses(item.text)))];
|
|
17848
17860
|
}
|
|
17849
17861
|
|
|
17850
|
-
// ../envoy-client/src/
|
|
17851
|
-
|
|
17852
|
-
|
|
17853
|
-
|
|
17854
|
-
|
|
17855
|
-
const count = problems.length;
|
|
17856
|
-
const cli = isDispatchTool(tool);
|
|
17857
|
-
const help = cli ? [
|
|
17858
|
-
`Allowed flags: ${commandFlags(tool).join(", ")}`,
|
|
17859
|
-
`Example: ${commandLine(tool, exampleFor(tool))}`
|
|
17860
|
-
] : [];
|
|
17861
|
-
super([
|
|
17862
|
-
`${cli ? `dispatch ${commandName(tool)}` : tool} was not called: ${count} problem${count === 1 ? "" : "s"}`,
|
|
17863
|
-
...problems.map((problem) => `- ${problem}`),
|
|
17864
|
-
...help.map((line) => `- ${line}`)
|
|
17865
|
-
].join(`
|
|
17866
|
-
`));
|
|
17867
|
-
this.name = "ToolInputError";
|
|
17868
|
-
this.tool = tool;
|
|
17869
|
-
this.problems = problems;
|
|
17870
|
-
}
|
|
17871
|
-
}
|
|
17872
|
-
function isDispatchTool(tool) {
|
|
17873
|
-
return dispatchToolSpecs.some((spec) => spec.name === tool);
|
|
17862
|
+
// ../envoy-client/src/human-edit.ts
|
|
17863
|
+
function humanEditHead(edit) {
|
|
17864
|
+
const editors = edit.editors ?? [];
|
|
17865
|
+
const by = editors.length === 0 ? "" : `, edited by ${editors.join(", ")}`;
|
|
17866
|
+
return `${edit.name ?? "document"} v${edit.from_version ?? "?"} to v${edit.to_version ?? "?"}${by}`;
|
|
17874
17867
|
}
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17868
|
+
|
|
17869
|
+
// ../envoy-client/src/delivery.ts
|
|
17870
|
+
var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
|
|
17871
|
+
var AskAuthorPayloadSchema = object({
|
|
17872
|
+
author: object({ kind: string2(), id: string2() }).passthrough()
|
|
17873
|
+
});
|
|
17874
|
+
var InboundSenderSchema = object({
|
|
17875
|
+
session_id: string2().optional(),
|
|
17876
|
+
machine: string2().optional(),
|
|
17877
|
+
cwd: string2().optional(),
|
|
17878
|
+
title: string2().optional(),
|
|
17879
|
+
roles: array(string2()).optional()
|
|
17880
|
+
});
|
|
17881
|
+
var InboundEnvelopeSchema = object({
|
|
17882
|
+
event_id: string2().optional(),
|
|
17883
|
+
source: string2(),
|
|
17884
|
+
source_event_id: string2().optional(),
|
|
17885
|
+
source_session: string2().optional(),
|
|
17886
|
+
topic: string2().optional(),
|
|
17887
|
+
dedupe_key: string2().optional(),
|
|
17888
|
+
issued_at: number2().int().optional(),
|
|
17889
|
+
expires_at: number2().int().optional(),
|
|
17890
|
+
kept_at: number2().int().optional(),
|
|
17891
|
+
payload_summary: string2().optional(),
|
|
17892
|
+
payload: string2().optional(),
|
|
17893
|
+
sender: InboundSenderSchema.optional(),
|
|
17894
|
+
in_reply_to: string2().optional(),
|
|
17895
|
+
supersedes: string2().optional(),
|
|
17896
|
+
urgency: string2().optional(),
|
|
17897
|
+
expects_reply: string2().optional()
|
|
17898
|
+
}).passthrough();
|
|
17899
|
+
function tolerantShape(shape) {
|
|
17900
|
+
return Object.fromEntries(Object.entries(shape).map(([key, schema]) => [key, _catch2(schema, undefined)]));
|
|
17878
17901
|
}
|
|
17879
|
-
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17902
|
+
var TolerantInboundEnvelopeSchema = object({
|
|
17903
|
+
...tolerantShape(InboundEnvelopeSchema.shape),
|
|
17904
|
+
source: InboundEnvelopeSchema.shape.source.optional().catch(undefined),
|
|
17905
|
+
sender: object(tolerantShape(InboundSenderSchema.shape)).optional().catch(undefined)
|
|
17906
|
+
}).passthrough();
|
|
17907
|
+
var DedupeIdentitySchema = object({
|
|
17908
|
+
event_id: string2().min(1).optional(),
|
|
17909
|
+
dedupe_key: string2().min(1).optional(),
|
|
17910
|
+
source: string2().optional(),
|
|
17911
|
+
source_event_id: string2().optional()
|
|
17912
|
+
});
|
|
17913
|
+
function isCommentTargetedDelivery(delivery) {
|
|
17914
|
+
return "comment_id" in delivery;
|
|
17915
|
+
}
|
|
17916
|
+
var DispatchTargetedFrameSchema = object({
|
|
17917
|
+
event: DispatchEventSchema,
|
|
17918
|
+
delivery: DispatchTargetedDeliverySchema
|
|
17919
|
+
}).superRefine(({ event, delivery }, context) => {
|
|
17920
|
+
if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
|
|
17921
|
+
return;
|
|
17886
17922
|
}
|
|
17887
|
-
|
|
17888
|
-
}
|
|
17889
|
-
function shapeOf(schema) {
|
|
17890
|
-
const unwrapped = unwrap(schema);
|
|
17891
|
-
if (unwrapped === undefined)
|
|
17923
|
+
if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
|
|
17892
17924
|
return;
|
|
17893
|
-
const def = unwrapped.def;
|
|
17894
|
-
return def.type === "object" && "shape" in def ? def.shape : undefined;
|
|
17895
|
-
}
|
|
17896
|
-
function schemaAt(schema, path) {
|
|
17897
|
-
let current = schema;
|
|
17898
|
-
for (const key of path) {
|
|
17899
|
-
const unwrapped = unwrap(current);
|
|
17900
|
-
if (unwrapped === undefined)
|
|
17901
|
-
return;
|
|
17902
|
-
const def = unwrapped.def;
|
|
17903
|
-
if (def.type === "object" && "shape" in def) {
|
|
17904
|
-
current = shapeOf(unwrapped)?.[String(key)];
|
|
17905
|
-
} else if (def.type === "array" && "element" in def) {
|
|
17906
|
-
current = def.element;
|
|
17907
|
-
} else {
|
|
17908
|
-
return;
|
|
17909
|
-
}
|
|
17910
17925
|
}
|
|
17911
|
-
|
|
17926
|
+
context.addIssue({
|
|
17927
|
+
code: "custom",
|
|
17928
|
+
message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
|
|
17929
|
+
});
|
|
17930
|
+
});
|
|
17931
|
+
var RecoverableDispatchDeliveryFailureSchema = object({
|
|
17932
|
+
event: object({
|
|
17933
|
+
type: _enum2(["message.created", "comment.created"]),
|
|
17934
|
+
issue_key: string2().nullable(),
|
|
17935
|
+
payload: object({ id: string2(), body: string2().optional() }).passthrough()
|
|
17936
|
+
}).passthrough(),
|
|
17937
|
+
delivery: DispatchTargetedDeliverySchema
|
|
17938
|
+
}).refine(({ event, delivery }) => event.type === "comment.created" ? isCommentTargetedDelivery(delivery) : !isCommentTargetedDelivery(delivery) && DispatchTargetedResourceIDSchema.safeParse(event.payload.id).success, { message: "delivery resource must match its event type" });
|
|
17939
|
+
function carriedItem(event) {
|
|
17940
|
+
const resource = event.type.startsWith("comment.") || event.type.startsWith("suggestion.") ? "comment" : event.type.startsWith("message.") ? "message" : undefined;
|
|
17941
|
+
if (resource === undefined || !isObject2(event.payload))
|
|
17942
|
+
return;
|
|
17943
|
+
const id = event.payload["id"];
|
|
17944
|
+
if (typeof id !== "string" || id === "")
|
|
17945
|
+
return;
|
|
17946
|
+
return { resource, id, issueKey: event.issue_key };
|
|
17912
17947
|
}
|
|
17913
|
-
function
|
|
17914
|
-
|
|
17915
|
-
return "null";
|
|
17916
|
-
if (Array.isArray(value))
|
|
17917
|
-
return "an array";
|
|
17918
|
-
switch (typeof value) {
|
|
17919
|
-
case "number":
|
|
17920
|
-
case "boolean":
|
|
17921
|
-
return String(value);
|
|
17922
|
-
case "string":
|
|
17923
|
-
return "a string";
|
|
17924
|
-
case "object":
|
|
17925
|
-
return "an object";
|
|
17926
|
-
default:
|
|
17927
|
-
return typeof value;
|
|
17928
|
-
}
|
|
17948
|
+
function bodyWasCut(payload) {
|
|
17949
|
+
return isObject2(payload) && (payload["body_truncated"] === true || payload["payload_omitted"] === true);
|
|
17929
17950
|
}
|
|
17930
|
-
function
|
|
17931
|
-
|
|
17932
|
-
|
|
17933
|
-
|
|
17934
|
-
|
|
17935
|
-
const shape = shapeOf(schema);
|
|
17936
|
-
const keys = shape === undefined ? [] : Object.entries(shape).map(([key, field]) => `${key}${field.def.type === "optional" ? "?" : ""}`);
|
|
17937
|
-
return keys.length === 0 ? "an object" : `an object {${keys.join(", ")}}`;
|
|
17951
|
+
async function wholeCarriedBody(client, item, session) {
|
|
17952
|
+
try {
|
|
17953
|
+
if (item.resource === "comment") {
|
|
17954
|
+
const read = await client.getComment(item.id);
|
|
17955
|
+
return [read.comment, ...read.replies].find((comment) => comment.id === item.id)?.body;
|
|
17938
17956
|
}
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
|
|
17942
|
-
|
|
17943
|
-
}
|
|
17944
|
-
}
|
|
17945
|
-
function pathText(path, cliTool) {
|
|
17946
|
-
const [head, ...rest] = path.map(String);
|
|
17947
|
-
if (cliTool === undefined || head === undefined)
|
|
17948
|
-
return path.map(String).join(".");
|
|
17949
|
-
let flag = fieldFlag(cliTool, head);
|
|
17950
|
-
let index = 0;
|
|
17951
|
-
for (;index < rest.length && /^\d+$/.test(rest[index]); index++) {
|
|
17952
|
-
flag += `[${rest[index]}]`;
|
|
17957
|
+
const read = item.issueKey === null ? session === undefined ? undefined : await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
|
|
17958
|
+
return read === undefined ? undefined : [read.message, ...read.replies].find((message) => message.id === item.id)?.body;
|
|
17959
|
+
} catch {
|
|
17960
|
+
return;
|
|
17953
17961
|
}
|
|
17954
|
-
const tail = rest.slice(index).map((segment) => /^\d+$/.test(segment) ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
|
|
17955
|
-
return tail === "" ? flag : `${flag} ${tail}`;
|
|
17956
17962
|
}
|
|
17957
|
-
function
|
|
17958
|
-
|
|
17959
|
-
const allowed = Object.keys(shapeOf(schema) ?? {}).join(", ");
|
|
17960
|
-
return issues.flatMap((issue) => {
|
|
17961
|
-
const path = pathText(issue.path, cliTool);
|
|
17962
|
-
switch (issue.code) {
|
|
17963
|
-
case "invalid_type":
|
|
17964
|
-
return issue.input === undefined ? [`${path} is required (${issue.expected})`] : [
|
|
17965
|
-
`${path} must be ${describeExpected(issue.expected, schemaAt(schema, issue.path))}, not ${describeInput(issue.input)}`
|
|
17966
|
-
];
|
|
17967
|
-
case "unrecognized_keys": {
|
|
17968
|
-
if (cliTool !== undefined && issue.path.length === 0) {
|
|
17969
|
-
return issue.keys.map((key) => `unknown flag ${fieldFlag(cliTool, key)}`);
|
|
17970
|
-
}
|
|
17971
|
-
const here = Object.keys(shapeOf(schemaAt(schema, issue.path)) ?? {}).join(", ") || allowed;
|
|
17972
|
-
const where = path === "" ? "" : ` in ${path}`;
|
|
17973
|
-
return issue.keys.map((key) => `unknown field "${key}"${where}; allowed: ${here}`);
|
|
17974
|
-
}
|
|
17975
|
-
case "invalid_value":
|
|
17976
|
-
return [
|
|
17977
|
-
`${path} must be one of ${issue.values.map(String).join("|")}; got ${JSON.stringify(issue.input)}`
|
|
17978
|
-
];
|
|
17979
|
-
case "too_big":
|
|
17980
|
-
if (issue.origin === "array" && Array.isArray(issue.input)) {
|
|
17981
|
-
return [`${path} has ${issue.input.length} items; the limit is ${issue.maximum}`];
|
|
17982
|
-
}
|
|
17983
|
-
return [`${path} ${issue.message}`];
|
|
17984
|
-
case "custom":
|
|
17985
|
-
return [issue.message];
|
|
17986
|
-
default:
|
|
17987
|
-
return [path === "" ? issue.message : `${path}: ${issue.message}`];
|
|
17988
|
-
}
|
|
17989
|
-
});
|
|
17963
|
+
function isObject2(value) {
|
|
17964
|
+
return typeof value === "object" && value !== null;
|
|
17990
17965
|
}
|
|
17991
17966
|
|
|
17992
17967
|
// ../envoy-client/src/dispatch-picture-tools.ts
|
|
@@ -18029,21 +18004,9 @@ async function localPicture(path, cwd) {
|
|
|
18029
18004
|
}
|
|
18030
18005
|
return { path, name: basename(absolute), file: Bun.file(absolute, { type }) };
|
|
18031
18006
|
}
|
|
18032
|
-
function
|
|
18033
|
-
const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
18034
|
-
return slug === "" ? "artifact" : slug;
|
|
18035
|
-
}
|
|
18036
|
-
async function textWithPictures(tool, text, pictures, limit, owner, upload, actor) {
|
|
18007
|
+
async function textWithPictures(text, pictures, owner, upload, actor) {
|
|
18037
18008
|
if (pictures.length === 0)
|
|
18038
18009
|
return text;
|
|
18039
|
-
const counted = `${limit.text} plus ${pictures.length} ${pictures.length === 1 ? "picture" : "pictures"}`;
|
|
18040
|
-
const fix = `${limit.shorten} or send fewer pictures`;
|
|
18041
|
-
const predicted = withPictureLines(text, pictures.map((picture) => pictureLine(picture.name, `dispatch://${owner}/artifact/${uploadSlug(picture.name)}@v1`)));
|
|
18042
|
-
if (predicted.length > limit.cap) {
|
|
18043
|
-
throw new ToolInputError(tool, [
|
|
18044
|
-
`${counted} ${overCapMessage(predicted.length, limit.cap)}; ${fix}`
|
|
18045
|
-
]);
|
|
18046
|
-
}
|
|
18047
18010
|
const lines = [];
|
|
18048
18011
|
const addresses = [];
|
|
18049
18012
|
for (const picture of pictures) {
|
|
@@ -18060,11 +18023,7 @@ async function textWithPictures(tool, text, pictures, limit, owner, upload, acto
|
|
|
18060
18023
|
addresses.push(address);
|
|
18061
18024
|
lines.push(pictureLine(picture.name, address));
|
|
18062
18025
|
}
|
|
18063
|
-
|
|
18064
|
-
if (posted.length > limit.cap) {
|
|
18065
|
-
throw new Error(`${counted} ${overCapMessage(posted.length, limit.cap)} with the addresses Dispatch gave ` + `the uploads (${addresses.join(", ")}), so nothing was posted; ${fix}.`);
|
|
18066
|
-
}
|
|
18067
|
-
return posted;
|
|
18026
|
+
return withPictureLines(text, lines);
|
|
18068
18027
|
}
|
|
18069
18028
|
var AGENT_ARTIFACT_REF = new RegExp(`^dispatch://agent/(${SESSION_ID_PATTERN})/artifact/([^/@]+)(?:@v(\\d+))?$`, "u");
|
|
18070
18029
|
function parseAgentArtifactRef(ref) {
|
|
@@ -18120,6 +18079,23 @@ function eventTexts(event) {
|
|
|
18120
18079
|
}
|
|
18121
18080
|
return texts.filter((text) => typeof text === "string" && text !== "").map((text) => ({ text, at: event.created_at }));
|
|
18122
18081
|
}
|
|
18082
|
+
async function eventTextsWhole(client, events) {
|
|
18083
|
+
const reads = new Map;
|
|
18084
|
+
const whole = await Promise.all(events.map(async (event) => {
|
|
18085
|
+
const item = bodyWasCut(event.payload) ? carriedItem(event) : undefined;
|
|
18086
|
+
if (item === undefined)
|
|
18087
|
+
return eventTexts(event);
|
|
18088
|
+
const key = `${item.resource}:${item.id}`;
|
|
18089
|
+
let read = reads.get(key);
|
|
18090
|
+
if (read === undefined) {
|
|
18091
|
+
read = wholeCarriedBody(client, item);
|
|
18092
|
+
reads.set(key, read);
|
|
18093
|
+
}
|
|
18094
|
+
const body = await read;
|
|
18095
|
+
return body === undefined ? eventTexts(event) : [{ text: body, at: event.created_at }];
|
|
18096
|
+
}));
|
|
18097
|
+
return whole.flat();
|
|
18098
|
+
}
|
|
18123
18099
|
function shownPictureLine(index, address, name, mimeType, bytes) {
|
|
18124
18100
|
return `- image ${index}: ${address} (${name}, ${mimeType}, ${bytes.toLocaleString("en-US")} bytes)`;
|
|
18125
18101
|
}
|
|
@@ -18273,13 +18249,6 @@ function subscriptionCovers(topic, owner) {
|
|
|
18273
18249
|
return false;
|
|
18274
18250
|
}
|
|
18275
18251
|
|
|
18276
|
-
// ../envoy-client/src/human-edit.ts
|
|
18277
|
-
function humanEditHead(edit) {
|
|
18278
|
-
const editors = edit.editors ?? [];
|
|
18279
|
-
const by = editors.length === 0 ? "" : `, edited by ${editors.join(", ")}`;
|
|
18280
|
-
return `${edit.name ?? "document"} v${edit.from_version ?? "?"} to v${edit.to_version ?? "?"}${by}`;
|
|
18281
|
-
}
|
|
18282
|
-
|
|
18283
18252
|
// ../envoy-client/src/search-answer.ts
|
|
18284
18253
|
function pageSummaryText(offset, count, total) {
|
|
18285
18254
|
return `showing ${offset + 1}-${offset + count} of ${total}`;
|
|
@@ -18588,6 +18557,148 @@ var state = processGlobal[STATE_KEY] ?? {
|
|
|
18588
18557
|
};
|
|
18589
18558
|
processGlobal[STATE_KEY] = state;
|
|
18590
18559
|
|
|
18560
|
+
// ../envoy-client/src/tool-input-errors.ts
|
|
18561
|
+
class ToolInputError extends Error {
|
|
18562
|
+
tool;
|
|
18563
|
+
problems;
|
|
18564
|
+
constructor(tool, problems) {
|
|
18565
|
+
const count = problems.length;
|
|
18566
|
+
const cli = isDispatchTool(tool);
|
|
18567
|
+
const help = cli ? [
|
|
18568
|
+
`Allowed flags: ${commandFlags(tool).join(", ")}`,
|
|
18569
|
+
`Example: ${commandLine(tool, exampleFor(tool))}`
|
|
18570
|
+
] : [];
|
|
18571
|
+
super([
|
|
18572
|
+
`${cli ? `dispatch ${commandName(tool)}` : tool} was not called: ${count} problem${count === 1 ? "" : "s"}`,
|
|
18573
|
+
...problems.map((problem) => `- ${problem}`),
|
|
18574
|
+
...help.map((line) => `- ${line}`)
|
|
18575
|
+
].join(`
|
|
18576
|
+
`));
|
|
18577
|
+
this.name = "ToolInputError";
|
|
18578
|
+
this.tool = tool;
|
|
18579
|
+
this.problems = problems;
|
|
18580
|
+
}
|
|
18581
|
+
}
|
|
18582
|
+
function isDispatchTool(tool) {
|
|
18583
|
+
return dispatchToolSpecs.some((spec) => spec.name === tool);
|
|
18584
|
+
}
|
|
18585
|
+
function exampleFor(tool) {
|
|
18586
|
+
const spec = dispatchToolSpecs.find((candidate) => candidate.name === tool);
|
|
18587
|
+
return { ...spec?.example };
|
|
18588
|
+
}
|
|
18589
|
+
function unwrap(schema) {
|
|
18590
|
+
let current = schema;
|
|
18591
|
+
while (current !== undefined) {
|
|
18592
|
+
const def = current.def;
|
|
18593
|
+
if (!("innerType" in def) || !(def.type === "optional" || def.type === "nullable" || def.type === "default"))
|
|
18594
|
+
break;
|
|
18595
|
+
current = def.innerType;
|
|
18596
|
+
}
|
|
18597
|
+
return current;
|
|
18598
|
+
}
|
|
18599
|
+
function shapeOf(schema) {
|
|
18600
|
+
const unwrapped = unwrap(schema);
|
|
18601
|
+
if (unwrapped === undefined)
|
|
18602
|
+
return;
|
|
18603
|
+
const def = unwrapped.def;
|
|
18604
|
+
return def.type === "object" && "shape" in def ? def.shape : undefined;
|
|
18605
|
+
}
|
|
18606
|
+
function schemaAt(schema, path) {
|
|
18607
|
+
let current = schema;
|
|
18608
|
+
for (const key of path) {
|
|
18609
|
+
const unwrapped = unwrap(current);
|
|
18610
|
+
if (unwrapped === undefined)
|
|
18611
|
+
return;
|
|
18612
|
+
const def = unwrapped.def;
|
|
18613
|
+
if (def.type === "object" && "shape" in def) {
|
|
18614
|
+
current = shapeOf(unwrapped)?.[String(key)];
|
|
18615
|
+
} else if (def.type === "array" && "element" in def) {
|
|
18616
|
+
current = def.element;
|
|
18617
|
+
} else {
|
|
18618
|
+
return;
|
|
18619
|
+
}
|
|
18620
|
+
}
|
|
18621
|
+
return unwrap(current);
|
|
18622
|
+
}
|
|
18623
|
+
function describeInput(value) {
|
|
18624
|
+
if (value === null)
|
|
18625
|
+
return "null";
|
|
18626
|
+
if (Array.isArray(value))
|
|
18627
|
+
return "an array";
|
|
18628
|
+
switch (typeof value) {
|
|
18629
|
+
case "number":
|
|
18630
|
+
case "boolean":
|
|
18631
|
+
return String(value);
|
|
18632
|
+
case "string":
|
|
18633
|
+
return "a string";
|
|
18634
|
+
case "object":
|
|
18635
|
+
return "an object";
|
|
18636
|
+
default:
|
|
18637
|
+
return typeof value;
|
|
18638
|
+
}
|
|
18639
|
+
}
|
|
18640
|
+
function describeExpected(expected, schema) {
|
|
18641
|
+
switch (expected) {
|
|
18642
|
+
case "int":
|
|
18643
|
+
return "an integer";
|
|
18644
|
+
case "object": {
|
|
18645
|
+
const shape = shapeOf(schema);
|
|
18646
|
+
const keys = shape === undefined ? [] : Object.entries(shape).map(([key, field]) => `${key}${field.def.type === "optional" ? "?" : ""}`);
|
|
18647
|
+
return keys.length === 0 ? "an object" : `an object {${keys.join(", ")}}`;
|
|
18648
|
+
}
|
|
18649
|
+
case "array":
|
|
18650
|
+
return "an array";
|
|
18651
|
+
default:
|
|
18652
|
+
return `a ${expected}`;
|
|
18653
|
+
}
|
|
18654
|
+
}
|
|
18655
|
+
function pathText(path, cliTool) {
|
|
18656
|
+
const [head, ...rest] = path.map(String);
|
|
18657
|
+
if (cliTool === undefined || head === undefined)
|
|
18658
|
+
return path.map(String).join(".");
|
|
18659
|
+
let flag = fieldFlag(cliTool, head);
|
|
18660
|
+
let index = 0;
|
|
18661
|
+
for (;index < rest.length && /^\d+$/.test(rest[index]); index++) {
|
|
18662
|
+
flag += `[${rest[index]}]`;
|
|
18663
|
+
}
|
|
18664
|
+
const tail = rest.slice(index).map((segment) => /^\d+$/.test(segment) ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
|
|
18665
|
+
return tail === "" ? flag : `${flag} ${tail}`;
|
|
18666
|
+
}
|
|
18667
|
+
function formatZodIssues(issues, schema, tool) {
|
|
18668
|
+
const cliTool = isDispatchTool(tool) ? tool : undefined;
|
|
18669
|
+
const allowed = Object.keys(shapeOf(schema) ?? {}).join(", ");
|
|
18670
|
+
return issues.flatMap((issue) => {
|
|
18671
|
+
const path = pathText(issue.path, cliTool);
|
|
18672
|
+
switch (issue.code) {
|
|
18673
|
+
case "invalid_type":
|
|
18674
|
+
return issue.input === undefined ? [`${path} is required (${issue.expected})`] : [
|
|
18675
|
+
`${path} must be ${describeExpected(issue.expected, schemaAt(schema, issue.path))}, not ${describeInput(issue.input)}`
|
|
18676
|
+
];
|
|
18677
|
+
case "unrecognized_keys": {
|
|
18678
|
+
if (cliTool !== undefined && issue.path.length === 0) {
|
|
18679
|
+
return issue.keys.map((key) => `unknown flag ${fieldFlag(cliTool, key)}`);
|
|
18680
|
+
}
|
|
18681
|
+
const here = Object.keys(shapeOf(schemaAt(schema, issue.path)) ?? {}).join(", ") || allowed;
|
|
18682
|
+
const where = path === "" ? "" : ` in ${path}`;
|
|
18683
|
+
return issue.keys.map((key) => `unknown field "${key}"${where}; allowed: ${here}`);
|
|
18684
|
+
}
|
|
18685
|
+
case "invalid_value":
|
|
18686
|
+
return [
|
|
18687
|
+
`${path} must be one of ${issue.values.map(String).join("|")}; got ${JSON.stringify(issue.input)}`
|
|
18688
|
+
];
|
|
18689
|
+
case "too_big":
|
|
18690
|
+
if (issue.origin === "array" && Array.isArray(issue.input)) {
|
|
18691
|
+
return [`${path} has ${issue.input.length} items; the limit is ${issue.maximum}`];
|
|
18692
|
+
}
|
|
18693
|
+
return [`${path} ${issue.message}`];
|
|
18694
|
+
case "custom":
|
|
18695
|
+
return [issue.message];
|
|
18696
|
+
default:
|
|
18697
|
+
return [path === "" ? issue.message : `${path}: ${issue.message}`];
|
|
18698
|
+
}
|
|
18699
|
+
});
|
|
18700
|
+
}
|
|
18701
|
+
|
|
18591
18702
|
// ../envoy-client/src/dispatch-execute.ts
|
|
18592
18703
|
function documentTopic(artifact) {
|
|
18593
18704
|
return documentTopicOf(artifact.project, artifact.slug);
|
|
@@ -18716,6 +18827,7 @@ var issueFreeTools = {
|
|
|
18716
18827
|
dispatch_open_asks: true,
|
|
18717
18828
|
dispatch_answers: true,
|
|
18718
18829
|
dispatch_whoami: true,
|
|
18830
|
+
dispatch_limits: true,
|
|
18719
18831
|
dispatch_inbox: true,
|
|
18720
18832
|
dispatch_architecture_sync: true
|
|
18721
18833
|
};
|
|
@@ -18831,17 +18943,13 @@ function askUrgency(args) {
|
|
|
18831
18943
|
const value = args.urgency;
|
|
18832
18944
|
return ASK_URGENCIES.find((urgency) => urgency === value);
|
|
18833
18945
|
}
|
|
18834
|
-
function
|
|
18946
|
+
function askQuestionWithRef(args) {
|
|
18947
|
+
const question = stringArg(args, "question");
|
|
18948
|
+
const ref = optionalString(args, "ref");
|
|
18835
18949
|
return ref === undefined || question.includes(ref) ? question : `${question}
|
|
18836
18950
|
|
|
18837
18951
|
Ref: ${ref}`;
|
|
18838
18952
|
}
|
|
18839
|
-
function askQuestionWithRef(args) {
|
|
18840
|
-
return questionWithRef(stringArg(args, "question"), optionalString(args, "ref"));
|
|
18841
|
-
}
|
|
18842
|
-
function askQuestionProblem(withRef) {
|
|
18843
|
-
return withRef.length > ASK_QUESTION_MAX ? `question plus ref ${overCapMessage(withRef.length, ASK_QUESTION_MAX)}; shorten the question or drop the ref` : undefined;
|
|
18844
|
-
}
|
|
18845
18953
|
var pictureSendingTools = {
|
|
18846
18954
|
dispatch_ask: true,
|
|
18847
18955
|
dispatch_comment: true,
|
|
@@ -19034,16 +19142,6 @@ function itemReplyTo(args, field) {
|
|
|
19034
19142
|
function argumentProblems(tool, args) {
|
|
19035
19143
|
const problems = [];
|
|
19036
19144
|
switch (tool) {
|
|
19037
|
-
case "dispatch_ask": {
|
|
19038
|
-
const question = optionalString(args, "question");
|
|
19039
|
-
const ref = optionalString(args, "ref");
|
|
19040
|
-
if (question !== undefined && ref !== undefined && question.length <= ASK_QUESTION_MAX) {
|
|
19041
|
-
const problem = askQuestionProblem(questionWithRef(question, ref));
|
|
19042
|
-
if (problem !== undefined)
|
|
19043
|
-
problems.push(problem);
|
|
19044
|
-
}
|
|
19045
|
-
break;
|
|
19046
|
-
}
|
|
19047
19145
|
case "dispatch_edit_ask":
|
|
19048
19146
|
case "dispatch_resolve_ask":
|
|
19049
19147
|
case "dispatch_follow": {
|
|
@@ -20129,6 +20227,7 @@ function commentSummary({ comment, replies }, graph) {
|
|
|
20129
20227
|
`${reply.id} \xB7 ${actorText(reply.author)}`,
|
|
20130
20228
|
...anchorLines(reply),
|
|
20131
20229
|
...replyBlockLines(reply),
|
|
20230
|
+
...reply.answers != null && reply.answers !== comment.id ? [`Answers: ${reply.answers}`] : [],
|
|
20132
20231
|
`Body: ${reply.body}`
|
|
20133
20232
|
]);
|
|
20134
20233
|
return [
|
|
@@ -20564,6 +20663,25 @@ async function executeDispatchTool(input) {
|
|
|
20564
20663
|
details: { session, owner, service, project }
|
|
20565
20664
|
};
|
|
20566
20665
|
}
|
|
20666
|
+
if (input.tool === "dispatch_limits") {
|
|
20667
|
+
const limits = await dispatchClient().limits();
|
|
20668
|
+
const count = (value) => value.toLocaleString("en-US");
|
|
20669
|
+
return {
|
|
20670
|
+
text: [
|
|
20671
|
+
`One block of a body - a paragraph, list, quote, table or code block: ${count(limits.block_units)} characters (UTF-16 units).`,
|
|
20672
|
+
`Blocks in one body: ${count(limits.item_blocks)}.`,
|
|
20673
|
+
`An ask's question and its options together: ${count(limits.ask_units)} characters (UTF-16 units).`,
|
|
20674
|
+
`Options on one ask: ${count(limits.ask_options)}.`,
|
|
20675
|
+
`The body an event carries whole: ${count(limits.event_body_units)} characters (UTF-16 units); a longer body reaches a reader cut, and the item itself holds the rest.`,
|
|
20676
|
+
`One request: ${count(limits.request_bytes)} bytes.`,
|
|
20677
|
+
`One markdown document: ${count(limits.document_bytes)} bytes.`,
|
|
20678
|
+
`One handoff body: ${count(limits.handoff_bytes)} bytes.`,
|
|
20679
|
+
"Dispatch holds every write to these bounds and refuses a longer text, naming the block or the field that passed one."
|
|
20680
|
+
].join(`
|
|
20681
|
+
`),
|
|
20682
|
+
details: { ...limits }
|
|
20683
|
+
};
|
|
20684
|
+
}
|
|
20567
20685
|
if (input.tool === "dispatch_inbox") {
|
|
20568
20686
|
const client = dispatchClient();
|
|
20569
20687
|
const pending = client.credentialPending().then((answer) => ({ answer }), (error) => ({ error }));
|
|
@@ -20614,18 +20732,18 @@ async function executeDispatchTool(input) {
|
|
|
20614
20732
|
throw new Error("issue is required");
|
|
20615
20733
|
return owner.issue;
|
|
20616
20734
|
};
|
|
20617
|
-
const postWithPictures = (text,
|
|
20735
|
+
const postWithPictures = (text, owner, upload) => textWithPictures(text, pictures, owner, (picture) => upload(picture).catch((error) => {
|
|
20618
20736
|
if (!(error instanceof DispatchWriteLandedError))
|
|
20619
20737
|
throw error;
|
|
20620
20738
|
throw new Error(`${error.message} That was a picture uploaded before this call's own write, so nothing else was written: run the call again, which uploads it as its next version.`, { cause: error });
|
|
20621
20739
|
}), actor);
|
|
20622
|
-
const writePictures = (resolved, text
|
|
20740
|
+
const writePictures = (resolved, text) => {
|
|
20623
20741
|
if (resolved?.owner.kind === "project") {
|
|
20624
20742
|
const { project } = resolved.owner;
|
|
20625
|
-
return postWithPictures(text,
|
|
20743
|
+
return postWithPictures(text, project, (upload) => client.projectArtifact(project, upload));
|
|
20626
20744
|
}
|
|
20627
20745
|
const issueKey = issue();
|
|
20628
|
-
return postWithPictures(text,
|
|
20746
|
+
return postWithPictures(text, issueKey, (upload) => client.artifact(issueKey, upload));
|
|
20629
20747
|
};
|
|
20630
20748
|
const hostSession = input.sessionId?.trim();
|
|
20631
20749
|
const shown = hostSession ? shownPictures(hostSession) : undefined;
|
|
@@ -21035,13 +21153,7 @@ async function executeDispatchTool(input) {
|
|
|
21035
21153
|
const multiple = optionalBoolean(args, "multiple");
|
|
21036
21154
|
const urgency = askUrgency(args);
|
|
21037
21155
|
const anchored = anchorArgs && resolved ? anchor(resolved.artifact, anchorArgs) : undefined;
|
|
21038
|
-
const
|
|
21039
|
-
const refAppended = withRef !== stringArg(args, "question");
|
|
21040
|
-
const question = await writePictures(resolved, withRef, {
|
|
21041
|
-
cap: ASK_QUESTION_MAX,
|
|
21042
|
-
text: refAppended ? "question plus ref" : "question",
|
|
21043
|
-
shorten: refAppended ? "shorten the question, drop the ref" : "shorten the question"
|
|
21044
|
-
});
|
|
21156
|
+
const question = await writePictures(resolved, askQuestionWithRef(args));
|
|
21045
21157
|
const askInput = {
|
|
21046
21158
|
question,
|
|
21047
21159
|
...Array.isArray(options) ? { options } : {},
|
|
@@ -21105,11 +21217,7 @@ async function executeDispatchTool(input) {
|
|
|
21105
21217
|
}
|
|
21106
21218
|
const replyToBlock = replyTo?.block ?? replyToAskTarget?.block;
|
|
21107
21219
|
const requestedTurn = optionalString(args, "turn");
|
|
21108
|
-
const body = await writePictures(resolved, stringArg(args, "body")
|
|
21109
|
-
cap: DISPATCH_BODY_MAX,
|
|
21110
|
-
text: "body",
|
|
21111
|
-
shorten: "shorten the body"
|
|
21112
|
-
});
|
|
21220
|
+
const body = await writePictures(resolved, stringArg(args, "body"));
|
|
21113
21221
|
const commentInput = {
|
|
21114
21222
|
body,
|
|
21115
21223
|
...anchored === undefined ? {} : { anchor: anchored },
|
|
@@ -21179,11 +21287,6 @@ async function executeDispatchTool(input) {
|
|
|
21179
21287
|
const target = messageInReplyTo(args);
|
|
21180
21288
|
const inReplyTo = target?.id;
|
|
21181
21289
|
const written = stringArg(args, "body");
|
|
21182
|
-
const bodyLimit = {
|
|
21183
|
-
cap: DISPATCH_BODY_MAX,
|
|
21184
|
-
text: "body",
|
|
21185
|
-
shorten: "shorten the body"
|
|
21186
|
-
};
|
|
21187
21290
|
if (owner === null && inReplyTo !== undefined) {
|
|
21188
21291
|
let body = written;
|
|
21189
21292
|
if (pictures.length > 0) {
|
|
@@ -21191,7 +21294,7 @@ async function executeDispatchTool(input) {
|
|
|
21191
21294
|
if (!sessionId) {
|
|
21192
21295
|
throw new Error("host session id is required to send pictures in a direct-message reply");
|
|
21193
21296
|
}
|
|
21194
|
-
body = await postWithPictures(written,
|
|
21297
|
+
body = await postWithPictures(written, `agent/${sessionId}`, (upload) => client.agentArtifact(sessionId, upload));
|
|
21195
21298
|
}
|
|
21196
21299
|
const reply = await client.messageReply(inReplyTo, { body, attempt: 1, actor }, { followUp: true });
|
|
21197
21300
|
if (reply.duplicate === true && reply.body === body) {
|
|
@@ -21220,7 +21323,7 @@ async function executeDispatchTool(input) {
|
|
|
21220
21323
|
};
|
|
21221
21324
|
}
|
|
21222
21325
|
const issueKey = issue();
|
|
21223
|
-
const body = await postWithPictures(written,
|
|
21326
|
+
const body = await postWithPictures(written, issueKey, (upload) => client.artifact(issueKey, upload));
|
|
21224
21327
|
const message = await client.message(issueKey, {
|
|
21225
21328
|
body,
|
|
21226
21329
|
...inReplyTo === undefined ? {} : { in_reply_to: inReplyTo },
|
|
@@ -21723,7 +21826,7 @@ ${handoff.body}`,
|
|
|
21723
21826
|
};
|
|
21724
21827
|
if (ownerArguments.ref?.kind === "log") {
|
|
21725
21828
|
const read = await client.read(issueKey, readEvents);
|
|
21726
|
-
const pictures = await picturesOf(read.events
|
|
21829
|
+
const pictures = await picturesOf(await eventTextsWhole(client, read.events));
|
|
21727
21830
|
return {
|
|
21728
21831
|
text: [logSummary(read.issue, read.events), ...pictures.lines].join(`
|
|
21729
21832
|
`),
|
|
@@ -21747,7 +21850,7 @@ ${handoff.body}`,
|
|
|
21747
21850
|
liveSessionTitles(client, holdsSession(read.issue.claim) || routeHeldBySession(read.issue)),
|
|
21748
21851
|
picturesOf([
|
|
21749
21852
|
...read.issue.open_asks.map((ask) => ({ text: ask.question, at: ask.created_at })),
|
|
21750
|
-
...read.events
|
|
21853
|
+
...await eventTextsWhole(client, read.events)
|
|
21751
21854
|
]),
|
|
21752
21855
|
issueCoverageOrReason(client, read.issue.key)
|
|
21753
21856
|
]);
|
|
@@ -22583,7 +22686,7 @@ function encode4(input) {
|
|
|
22583
22686
|
}
|
|
22584
22687
|
|
|
22585
22688
|
// ../../node_modules/.bun/jose@6.2.9/node_modules/jose/dist/webapi/lib/type_checks.js
|
|
22586
|
-
function
|
|
22689
|
+
function isObject3(input) {
|
|
22587
22690
|
if (typeof input !== "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
22588
22691
|
return false;
|
|
22589
22692
|
}
|
|
@@ -22611,7 +22714,7 @@ function isDisjoint(...headers) {
|
|
|
22611
22714
|
}
|
|
22612
22715
|
return true;
|
|
22613
22716
|
}
|
|
22614
|
-
var isJWK = (key) =>
|
|
22717
|
+
var isJWK = (key) => isObject3(key) && typeof key.kty === "string";
|
|
22615
22718
|
var isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
22616
22719
|
var isPublicJWK = (key) => key.kty !== "oct" && key.d === undefined && key.priv === undefined;
|
|
22617
22720
|
var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
@@ -23030,7 +23133,7 @@ function numericDate(value, label) {
|
|
|
23030
23133
|
class JWTClaimsBuilder {
|
|
23031
23134
|
#payload;
|
|
23032
23135
|
constructor(payload) {
|
|
23033
|
-
if (!
|
|
23136
|
+
if (!isObject3(payload)) {
|
|
23034
23137
|
throw new TypeError("JWT Claims Set MUST be an object");
|
|
23035
23138
|
}
|
|
23036
23139
|
this.#payload = structuredClone(payload);
|