@sjawhar/pi-envoy 16.9.0 → 16.11.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 +454 -242
- package/dist/envoy.js +429 -211
- package/dist/skills/dispatch/SKILL.md +5 -2
- package/dist/skills/dispatch-first/SKILL.md +2 -2
- package/dist/skills/envoy/SKILL.md +12 -2
- package/dist/skills/envoy/references/legion.md +5 -4
- package/dist/skills/envoy/references/roles.md +4 -4
- package/package.json +1 -1
package/dist/dispatch.js
CHANGED
|
@@ -14571,6 +14571,7 @@ function serviceSubjectLabel(subject) {
|
|
|
14571
14571
|
}
|
|
14572
14572
|
return subject;
|
|
14573
14573
|
}
|
|
14574
|
+
var ISSUE_CLAIM_UNRESPONSIVE_GRACE_MS = 20 * 60 * 1000;
|
|
14574
14575
|
var MAX_ISSUE_BLOCKERS = 20;
|
|
14575
14576
|
var ISSUE_TITLE_MAX = 1000;
|
|
14576
14577
|
var PROJECT_NAME_MAX = 80;
|
|
@@ -14745,6 +14746,8 @@ var CommentEventPayloadSchema = object({
|
|
|
14745
14746
|
project_key: string2().optional(),
|
|
14746
14747
|
artifact_slug: string2().optional(),
|
|
14747
14748
|
body: string2().optional(),
|
|
14749
|
+
body_truncated: boolean2().optional(),
|
|
14750
|
+
payload_omitted: boolean2().optional(),
|
|
14748
14751
|
reply_to: string2().nullish(),
|
|
14749
14752
|
ask_id: string2().nullish(),
|
|
14750
14753
|
ask_question: string2().optional(),
|
|
@@ -14770,6 +14773,8 @@ var CommentEventPayloadSchema = object({
|
|
|
14770
14773
|
var MessageEventPayloadSchema = object({
|
|
14771
14774
|
id: string2().optional(),
|
|
14772
14775
|
body: string2().optional(),
|
|
14776
|
+
body_truncated: boolean2().optional(),
|
|
14777
|
+
payload_omitted: boolean2().optional(),
|
|
14773
14778
|
target: string2().nullish(),
|
|
14774
14779
|
in_reply_to: string2().nullish(),
|
|
14775
14780
|
reply_body: string2().optional(),
|
|
@@ -14896,15 +14901,38 @@ var AGENT_STREAM_LIMITS = {
|
|
|
14896
14901
|
commandDescriptionChars: 200
|
|
14897
14902
|
};
|
|
14898
14903
|
// ../contracts/src/claim-holds.ts
|
|
14899
|
-
|
|
14904
|
+
var HOLDING_OF = {
|
|
14905
|
+
gone: "lapsed",
|
|
14906
|
+
live: "holds",
|
|
14907
|
+
unknown: "unknown",
|
|
14908
|
+
unresponsive: "unresponsive"
|
|
14909
|
+
};
|
|
14910
|
+
function claimHolds(claim, titles, liveness = {}) {
|
|
14900
14911
|
if (claim.actor.kind !== "session") {
|
|
14901
14912
|
return "holds";
|
|
14902
14913
|
}
|
|
14914
|
+
const state = liveness.holder_state;
|
|
14915
|
+
if (state != null) {
|
|
14916
|
+
return HOLDING_OF[state];
|
|
14917
|
+
}
|
|
14903
14918
|
if (titles === undefined) {
|
|
14904
14919
|
return "unknown";
|
|
14905
14920
|
}
|
|
14906
14921
|
return titles.has(claim.actor.id) ? "holds" : "lapsed";
|
|
14907
14922
|
}
|
|
14923
|
+
function claimTakeableAt(liveness, lastSeen = undefined) {
|
|
14924
|
+
if (liveness.takeable_at != null) {
|
|
14925
|
+
return liveness.takeable_at;
|
|
14926
|
+
}
|
|
14927
|
+
if (liveness.holder_state !== "unresponsive") {
|
|
14928
|
+
return null;
|
|
14929
|
+
}
|
|
14930
|
+
const seen = liveness.last_seen == null ? lastSeen : Date.parse(liveness.last_seen);
|
|
14931
|
+
if (seen === undefined || !Number.isFinite(seen) || seen <= 0) {
|
|
14932
|
+
return null;
|
|
14933
|
+
}
|
|
14934
|
+
return new Date(seen + ISSUE_CLAIM_UNRESPONSIVE_GRACE_MS).toISOString();
|
|
14935
|
+
}
|
|
14908
14936
|
// ../contracts/src/dispatch-href.ts
|
|
14909
14937
|
function hasControlCharacter(value) {
|
|
14910
14938
|
return /\p{Cc}/u.test(value);
|
|
@@ -15092,12 +15120,14 @@ function componentsArgument(z) {
|
|
|
15092
15120
|
}).describe("Attach the issue to architecture components. Attach the root before decomposing it; children inherit unless they choose.");
|
|
15093
15121
|
}
|
|
15094
15122
|
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
|
|
15123
|
+
function imagesArgument(z, owner) {
|
|
15124
|
+
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
15125
|
}
|
|
15098
15126
|
var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
15099
|
-
var
|
|
15100
|
-
var
|
|
15127
|
+
var DISPATCH_BLOCK_UNITS = 32000;
|
|
15128
|
+
var DISPATCH_ITEM_BLOCKS = 32768;
|
|
15129
|
+
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.";
|
|
15130
|
+
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
15131
|
var DISPATCH_HANDOFF_BODY_MAX = 262144;
|
|
15102
15132
|
var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
15103
15133
|
var HANDOFF_PHASE_RULE_WORDS = "a lowercase letter, then up to 31 lowercase letters, digits or hyphens, such as implement";
|
|
@@ -15116,16 +15146,12 @@ function handoffProblem(value) {
|
|
|
15116
15146
|
return HANDOFF_PHASE_RULE;
|
|
15117
15147
|
if (typeof body !== "string")
|
|
15118
15148
|
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
15149
|
if (!isJsonObjectText(body)) {
|
|
15124
15150
|
return 'body is not one JSON object: a handoff body is a JSON object such as {"schemaVersion":1}';
|
|
15125
15151
|
}
|
|
15126
15152
|
return;
|
|
15127
15153
|
}
|
|
15128
|
-
var HANDOFF_RULE = `${HANDOFF_PHASE_RULE}; the body is one JSON object
|
|
15154
|
+
var HANDOFF_RULE = `${HANDOFF_PHASE_RULE}; the body is one JSON object.`;
|
|
15129
15155
|
var handoffValidation = {
|
|
15130
15156
|
check: (value) => handoffProblem(value) === undefined,
|
|
15131
15157
|
message: HANDOFF_RULE,
|
|
@@ -15148,7 +15174,12 @@ var ISSUE_STATUSES = [
|
|
|
15148
15174
|
"retro",
|
|
15149
15175
|
"done"
|
|
15150
15176
|
];
|
|
15151
|
-
var ISSUE_ROUTE_STATUSES = [
|
|
15177
|
+
var ISSUE_ROUTE_STATUSES = [
|
|
15178
|
+
"live",
|
|
15179
|
+
"holder_unresponsive",
|
|
15180
|
+
"no_holder",
|
|
15181
|
+
"unknown"
|
|
15182
|
+
];
|
|
15152
15183
|
var DOC_EDIT_OPS = [
|
|
15153
15184
|
"replace",
|
|
15154
15185
|
"delete",
|
|
@@ -15190,7 +15221,7 @@ var dispatchToolSpecs = [
|
|
|
15190
15221
|
arguments: (z) => ({
|
|
15191
15222
|
issue: z.string().describe(ISSUE_REFERENCE),
|
|
15192
15223
|
status: z.enum(ISSUE_STATUSES).describe("New lifecycle status.").optional(),
|
|
15193
|
-
reason: z.string(
|
|
15224
|
+
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
15225
|
title: z.string({ min: 1, max: ISSUE_TITLE_MAX }).describe("Replacement title, at most 1,000 characters.").optional(),
|
|
15195
15226
|
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
15227
|
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 +15267,13 @@ var dispatchToolSpecs = [
|
|
|
15236
15267
|
}
|
|
15237
15268
|
]
|
|
15238
15269
|
},
|
|
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.
|
|
15270
|
+
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
15271
|
arguments: (z) => ({
|
|
15241
15272
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15242
15273
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
15243
15274
|
artifact: z.string().describe("Project document artifact id, slug, or filename.").optional(),
|
|
15244
15275
|
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(
|
|
15276
|
+
question: z.string().describe(`${ASK_QUESTION_CONTRACT} ${ASK_BOUND_RULE}`),
|
|
15246
15277
|
options: z.array(z.object({
|
|
15247
15278
|
label: z.string().describe("Selectable option label."),
|
|
15248
15279
|
description: z.string().optional().describe("What this option costs.")
|
|
@@ -15254,7 +15285,7 @@ var dispatchToolSpecs = [
|
|
|
15254
15285
|
quote: z.string().describe("Exact text the decision concerns."),
|
|
15255
15286
|
occurrence: z.number({ int: true, min: 0 }).describe("Zero-based occurrence of the quote.").optional()
|
|
15256
15287
|
}).describe("Optional document location for the question.").optional(),
|
|
15257
|
-
images: imagesArgument(z, "the issue (or the project document's project)"
|
|
15288
|
+
images: imagesArgument(z, "the issue (or the project document's project)")
|
|
15258
15289
|
}),
|
|
15259
15290
|
validation: documentOwnerValidation(true)
|
|
15260
15291
|
},
|
|
@@ -15277,7 +15308,7 @@ var dispatchToolSpecs = [
|
|
|
15277
15308
|
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
15309
|
arguments: (z) => ({
|
|
15279
15310
|
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(
|
|
15311
|
+
question: z.string().optional().describe(`${ASK_QUESTION_CONTRACT} Replaces the ask's question. ${ASK_BOUND_RULE}`),
|
|
15281
15312
|
options: z.array(z.object({
|
|
15282
15313
|
label: z.string().describe("Selectable option label."),
|
|
15283
15314
|
description: z.string().optional().describe("What this option costs.")
|
|
@@ -15329,7 +15360,7 @@ var dispatchToolSpecs = [
|
|
|
15329
15360
|
{
|
|
15330
15361
|
name: "dispatch_comment",
|
|
15331
15362
|
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.
|
|
15363
|
+
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
15364
|
arguments: (z) => ({
|
|
15334
15365
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15335
15366
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15337,11 +15368,11 @@ var dispatchToolSpecs = [
|
|
|
15337
15368
|
ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
|
|
15338
15369
|
quote: z.string().describe("Optional exact quoted document text.").optional(),
|
|
15339
15370
|
occurrence: z.number({ int: true, min: 0 }).describe("Optional zero-based occurrence of quote.").optional(),
|
|
15340
|
-
body: z.string(
|
|
15371
|
+
body: z.string().describe(`Review comment. ${BODY_BLOCK_RULE}`),
|
|
15341
15372
|
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
15373
|
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
15374
|
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)"
|
|
15375
|
+
images: imagesArgument(z, "the issue (or the project document's project)")
|
|
15345
15376
|
}),
|
|
15346
15377
|
validation: commentValidation
|
|
15347
15378
|
},
|
|
@@ -15353,7 +15384,7 @@ var dispatchToolSpecs = [
|
|
|
15353
15384
|
quote: "old wording",
|
|
15354
15385
|
replace_with: "new wording"
|
|
15355
15386
|
},
|
|
15356
|
-
description: "Propose an exact replacement for quoted document text. Do not use it for general feedback; use " + `dispatch comment instead.
|
|
15387
|
+
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
15388
|
arguments: (z) => ({
|
|
15358
15389
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15359
15390
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15361,7 +15392,7 @@ var dispatchToolSpecs = [
|
|
|
15361
15392
|
ref: z.string().describe("Optional dispatch:// issue or document reference.").optional(),
|
|
15362
15393
|
quote: z.string().describe("Exact document text to replace."),
|
|
15363
15394
|
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(
|
|
15395
|
+
body: z.string().describe(`Optional rationale. ${BODY_BLOCK_RULE}`).optional(),
|
|
15365
15396
|
occurrence: z.number({ int: true, min: 0 }).describe("Optional zero-based occurrence of quote.").optional()
|
|
15366
15397
|
}),
|
|
15367
15398
|
validation: documentOwnerValidation(true, true)
|
|
@@ -15369,12 +15400,12 @@ var dispatchToolSpecs = [
|
|
|
15369
15400
|
{
|
|
15370
15401
|
name: "dispatch_message",
|
|
15371
15402
|
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. " +
|
|
15403
|
+
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
15404
|
arguments: (z) => ({
|
|
15374
15405
|
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(
|
|
15406
|
+
body: z.string().describe(`Update text. ${BODY_BLOCK_RULE}`),
|
|
15376
15407
|
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>)"
|
|
15408
|
+
images: imagesArgument(z, "the issue (a reply to a direct message: your own conversation, dispatch://agent/<your session id>)")
|
|
15378
15409
|
}),
|
|
15379
15410
|
validation: messageValidation
|
|
15380
15411
|
},
|
|
@@ -15573,7 +15604,7 @@ var dispatchToolSpecs = [
|
|
|
15573
15604
|
label: z.string().describe("Optional label filter.").optional(),
|
|
15574
15605
|
priority: z.array(z.number({ int: true, min: 0, max: 3 }).nullable(), { min: 1, max: 5 }).describe("Optional priority filter: one or more of 0 (P0, highest) through 3 (P3, lowest), and null " + "for an issue with no priority; an issue matching any listed value is returned.").optional(),
|
|
15575
15606
|
updated_since: z.string().describe("Optional RFC3339 timestamp; only issues updated at or after it.").optional(),
|
|
15576
|
-
route_status: z.enum(ISSUE_ROUTE_STATUSES).describe("Optional: only open issues whose route is in this state. live: a running session holds " + "the role or is the routed session. no_holder: nobody running holds the role, or the
|
|
15607
|
+
route_status: z.enum(ISSUE_ROUTE_STATUSES).describe("Optional: only open issues whose route is in this state. live: a running session holds " + "the role or is the routed session. holder_unresponsive: that session has missed its " + "heartbeats without ending, so the route still reaches it and its messages wait. " + "no_holder: nobody running holds the role, or the session is gone, right now. " + "unknown: the Envoy listener did not answer.").optional(),
|
|
15577
15608
|
limit: z.number({ int: true, min: 1, max: MAX_ISSUE_PAGE_LIMIT }).describe(`Maximum rows, 1-${MAX_ISSUE_PAGE_LIMIT}; default ${DEFAULT_ISSUE_PAGE_LIMIT}.`).optional(),
|
|
15578
15609
|
offset: z.number({ int: true, min: 0 }).describe("Rows to skip before the page; nonnegative integer; default 0.").optional(),
|
|
15579
15610
|
all: z.boolean().describe("Take every matching issue in one unpaged read, so no row is missed or repeated while " + "the list changes. Refused with limit or offset.").optional()
|
|
@@ -15636,6 +15667,13 @@ var dispatchToolSpecs = [
|
|
|
15636
15667
|
arguments: () => ({}),
|
|
15637
15668
|
strict: true
|
|
15638
15669
|
},
|
|
15670
|
+
{
|
|
15671
|
+
name: "dispatch_limits",
|
|
15672
|
+
example: {},
|
|
15673
|
+
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.",
|
|
15674
|
+
arguments: () => ({}),
|
|
15675
|
+
strict: true
|
|
15676
|
+
},
|
|
15639
15677
|
{
|
|
15640
15678
|
name: "dispatch_handoff_write",
|
|
15641
15679
|
example: {
|
|
@@ -17168,6 +17206,9 @@ class DispatchClient {
|
|
|
17168
17206
|
async whoami() {
|
|
17169
17207
|
return this.#json("GET", ["api", "v1", "whoami"]);
|
|
17170
17208
|
}
|
|
17209
|
+
async limits() {
|
|
17210
|
+
return this.#json("GET", ["api", "v1", "limits"]);
|
|
17211
|
+
}
|
|
17171
17212
|
async inbox(assignee) {
|
|
17172
17213
|
return this.#json("GET", ["api", "v1", "inbox"], undefined, { assignee });
|
|
17173
17214
|
}
|
|
@@ -17847,146 +17888,109 @@ function picturesNewestFirst(texts) {
|
|
|
17847
17888
|
return [...new Set(ordered.flatMap(({ item }) => pictureAddresses(item.text)))];
|
|
17848
17889
|
}
|
|
17849
17890
|
|
|
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);
|
|
17891
|
+
// ../envoy-client/src/human-edit.ts
|
|
17892
|
+
function humanEditHead(edit) {
|
|
17893
|
+
const editors = edit.editors ?? [];
|
|
17894
|
+
const by = editors.length === 0 ? "" : `, edited by ${editors.join(", ")}`;
|
|
17895
|
+
return `${edit.name ?? "document"} v${edit.from_version ?? "?"} to v${edit.to_version ?? "?"}${by}`;
|
|
17874
17896
|
}
|
|
17875
|
-
|
|
17876
|
-
|
|
17877
|
-
|
|
17897
|
+
|
|
17898
|
+
// ../envoy-client/src/delivery.ts
|
|
17899
|
+
var KNOWN_SOURCES = EnvelopeSchema.shape.source.enum;
|
|
17900
|
+
var AskAuthorPayloadSchema = object({
|
|
17901
|
+
author: object({ kind: string2(), id: string2() }).passthrough()
|
|
17902
|
+
});
|
|
17903
|
+
var InboundSenderSchema = object({
|
|
17904
|
+
session_id: string2().optional(),
|
|
17905
|
+
machine: string2().optional(),
|
|
17906
|
+
cwd: string2().optional(),
|
|
17907
|
+
title: string2().optional(),
|
|
17908
|
+
roles: array(string2()).optional()
|
|
17909
|
+
});
|
|
17910
|
+
var InboundEnvelopeSchema = object({
|
|
17911
|
+
event_id: string2().optional(),
|
|
17912
|
+
source: string2(),
|
|
17913
|
+
source_event_id: string2().optional(),
|
|
17914
|
+
source_session: string2().optional(),
|
|
17915
|
+
topic: string2().optional(),
|
|
17916
|
+
dedupe_key: string2().optional(),
|
|
17917
|
+
issued_at: number2().int().optional(),
|
|
17918
|
+
expires_at: number2().int().optional(),
|
|
17919
|
+
kept_at: number2().int().optional(),
|
|
17920
|
+
payload_summary: string2().optional(),
|
|
17921
|
+
payload: string2().optional(),
|
|
17922
|
+
sender: InboundSenderSchema.optional(),
|
|
17923
|
+
in_reply_to: string2().optional(),
|
|
17924
|
+
supersedes: string2().optional(),
|
|
17925
|
+
urgency: string2().optional(),
|
|
17926
|
+
expects_reply: string2().optional()
|
|
17927
|
+
}).passthrough();
|
|
17928
|
+
function tolerantShape(shape) {
|
|
17929
|
+
return Object.fromEntries(Object.entries(shape).map(([key, schema]) => [key, _catch2(schema, undefined)]));
|
|
17878
17930
|
}
|
|
17879
|
-
|
|
17880
|
-
|
|
17881
|
-
|
|
17882
|
-
|
|
17883
|
-
|
|
17884
|
-
|
|
17885
|
-
|
|
17931
|
+
var TolerantInboundEnvelopeSchema = object({
|
|
17932
|
+
...tolerantShape(InboundEnvelopeSchema.shape),
|
|
17933
|
+
source: InboundEnvelopeSchema.shape.source.optional().catch(undefined),
|
|
17934
|
+
sender: object(tolerantShape(InboundSenderSchema.shape)).optional().catch(undefined)
|
|
17935
|
+
}).passthrough();
|
|
17936
|
+
var DedupeIdentitySchema = object({
|
|
17937
|
+
event_id: string2().min(1).optional(),
|
|
17938
|
+
dedupe_key: string2().min(1).optional(),
|
|
17939
|
+
source: string2().optional(),
|
|
17940
|
+
source_event_id: string2().optional()
|
|
17941
|
+
});
|
|
17942
|
+
function isCommentTargetedDelivery(delivery) {
|
|
17943
|
+
return "comment_id" in delivery;
|
|
17944
|
+
}
|
|
17945
|
+
var DispatchTargetedFrameSchema = object({
|
|
17946
|
+
event: DispatchEventSchema,
|
|
17947
|
+
delivery: DispatchTargetedDeliverySchema
|
|
17948
|
+
}).superRefine(({ event, delivery }, context) => {
|
|
17949
|
+
if (event.type === "message.created" && !isCommentTargetedDelivery(delivery) && DispatchTargetedMessagePayloadSchema.safeParse(event.payload).success) {
|
|
17950
|
+
return;
|
|
17886
17951
|
}
|
|
17887
|
-
|
|
17888
|
-
}
|
|
17889
|
-
function shapeOf(schema) {
|
|
17890
|
-
const unwrapped = unwrap(schema);
|
|
17891
|
-
if (unwrapped === undefined)
|
|
17952
|
+
if (event.type === "comment.created" && isCommentTargetedDelivery(delivery) && DispatchTargetedCommentPayloadSchema.safeParse(event.payload).success) {
|
|
17892
17953
|
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
17954
|
}
|
|
17911
|
-
|
|
17955
|
+
context.addIssue({
|
|
17956
|
+
code: "custom",
|
|
17957
|
+
message: event.type === "comment.created" ? "targeted delivery requires a complete comment.created event" : "targeted delivery requires a complete message.created event"
|
|
17958
|
+
});
|
|
17959
|
+
});
|
|
17960
|
+
var RecoverableDispatchDeliveryFailureSchema = object({
|
|
17961
|
+
event: object({
|
|
17962
|
+
type: _enum2(["message.created", "comment.created"]),
|
|
17963
|
+
issue_key: string2().nullable(),
|
|
17964
|
+
payload: object({ id: string2(), body: string2().optional() }).passthrough()
|
|
17965
|
+
}).passthrough(),
|
|
17966
|
+
delivery: DispatchTargetedDeliverySchema
|
|
17967
|
+
}).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" });
|
|
17968
|
+
function carriedItem(event) {
|
|
17969
|
+
const resource = event.type.startsWith("comment.") || event.type.startsWith("suggestion.") ? "comment" : event.type.startsWith("message.") ? "message" : undefined;
|
|
17970
|
+
if (resource === undefined || !isObject2(event.payload))
|
|
17971
|
+
return;
|
|
17972
|
+
const id = event.payload["id"];
|
|
17973
|
+
if (typeof id !== "string" || id === "")
|
|
17974
|
+
return;
|
|
17975
|
+
return { resource, id, issueKey: event.issue_key };
|
|
17912
17976
|
}
|
|
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
|
-
}
|
|
17977
|
+
function bodyWasCut(payload) {
|
|
17978
|
+
return isObject2(payload) && (payload["body_truncated"] === true || payload["payload_omitted"] === true);
|
|
17929
17979
|
}
|
|
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(", ")}}`;
|
|
17980
|
+
async function wholeCarriedBody(client, item, session) {
|
|
17981
|
+
try {
|
|
17982
|
+
if (item.resource === "comment") {
|
|
17983
|
+
const read = await client.getComment(item.id);
|
|
17984
|
+
return [read.comment, ...read.replies].find((comment) => comment.id === item.id)?.body;
|
|
17938
17985
|
}
|
|
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]}]`;
|
|
17986
|
+
const read = item.issueKey === null ? session === undefined ? undefined : await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
|
|
17987
|
+
return read === undefined ? undefined : [read.message, ...read.replies].find((message) => message.id === item.id)?.body;
|
|
17988
|
+
} catch {
|
|
17989
|
+
return;
|
|
17953
17990
|
}
|
|
17954
|
-
const tail = rest.slice(index).map((segment) => /^\d+$/.test(segment) ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
|
|
17955
|
-
return tail === "" ? flag : `${flag} ${tail}`;
|
|
17956
17991
|
}
|
|
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
|
-
});
|
|
17992
|
+
function isObject2(value) {
|
|
17993
|
+
return typeof value === "object" && value !== null;
|
|
17990
17994
|
}
|
|
17991
17995
|
|
|
17992
17996
|
// ../envoy-client/src/dispatch-picture-tools.ts
|
|
@@ -18029,21 +18033,9 @@ async function localPicture(path, cwd) {
|
|
|
18029
18033
|
}
|
|
18030
18034
|
return { path, name: basename(absolute), file: Bun.file(absolute, { type }) };
|
|
18031
18035
|
}
|
|
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) {
|
|
18036
|
+
async function textWithPictures(text, pictures, owner, upload, actor) {
|
|
18037
18037
|
if (pictures.length === 0)
|
|
18038
18038
|
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
18039
|
const lines = [];
|
|
18048
18040
|
const addresses = [];
|
|
18049
18041
|
for (const picture of pictures) {
|
|
@@ -18060,11 +18052,7 @@ async function textWithPictures(tool, text, pictures, limit, owner, upload, acto
|
|
|
18060
18052
|
addresses.push(address);
|
|
18061
18053
|
lines.push(pictureLine(picture.name, address));
|
|
18062
18054
|
}
|
|
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;
|
|
18055
|
+
return withPictureLines(text, lines);
|
|
18068
18056
|
}
|
|
18069
18057
|
var AGENT_ARTIFACT_REF = new RegExp(`^dispatch://agent/(${SESSION_ID_PATTERN})/artifact/([^/@]+)(?:@v(\\d+))?$`, "u");
|
|
18070
18058
|
function parseAgentArtifactRef(ref) {
|
|
@@ -18120,6 +18108,23 @@ function eventTexts(event) {
|
|
|
18120
18108
|
}
|
|
18121
18109
|
return texts.filter((text) => typeof text === "string" && text !== "").map((text) => ({ text, at: event.created_at }));
|
|
18122
18110
|
}
|
|
18111
|
+
async function eventTextsWhole(client, events) {
|
|
18112
|
+
const reads = new Map;
|
|
18113
|
+
const whole = await Promise.all(events.map(async (event) => {
|
|
18114
|
+
const item = bodyWasCut(event.payload) ? carriedItem(event) : undefined;
|
|
18115
|
+
if (item === undefined)
|
|
18116
|
+
return eventTexts(event);
|
|
18117
|
+
const key = `${item.resource}:${item.id}`;
|
|
18118
|
+
let read = reads.get(key);
|
|
18119
|
+
if (read === undefined) {
|
|
18120
|
+
read = wholeCarriedBody(client, item);
|
|
18121
|
+
reads.set(key, read);
|
|
18122
|
+
}
|
|
18123
|
+
const body = await read;
|
|
18124
|
+
return body === undefined ? eventTexts(event) : [{ text: body, at: event.created_at }];
|
|
18125
|
+
}));
|
|
18126
|
+
return whole.flat();
|
|
18127
|
+
}
|
|
18123
18128
|
function shownPictureLine(index, address, name, mimeType, bytes) {
|
|
18124
18129
|
return `- image ${index}: ${address} (${name}, ${mimeType}, ${bytes.toLocaleString("en-US")} bytes)`;
|
|
18125
18130
|
}
|
|
@@ -18273,13 +18278,6 @@ function subscriptionCovers(topic, owner) {
|
|
|
18273
18278
|
return false;
|
|
18274
18279
|
}
|
|
18275
18280
|
|
|
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
18281
|
// ../envoy-client/src/search-answer.ts
|
|
18284
18282
|
function pageSummaryText(offset, count, total) {
|
|
18285
18283
|
return `showing ${offset + 1}-${offset + count} of ${total}`;
|
|
@@ -18588,6 +18586,148 @@ var state = processGlobal[STATE_KEY] ?? {
|
|
|
18588
18586
|
};
|
|
18589
18587
|
processGlobal[STATE_KEY] = state;
|
|
18590
18588
|
|
|
18589
|
+
// ../envoy-client/src/tool-input-errors.ts
|
|
18590
|
+
class ToolInputError extends Error {
|
|
18591
|
+
tool;
|
|
18592
|
+
problems;
|
|
18593
|
+
constructor(tool, problems) {
|
|
18594
|
+
const count = problems.length;
|
|
18595
|
+
const cli = isDispatchTool(tool);
|
|
18596
|
+
const help = cli ? [
|
|
18597
|
+
`Allowed flags: ${commandFlags(tool).join(", ")}`,
|
|
18598
|
+
`Example: ${commandLine(tool, exampleFor(tool))}`
|
|
18599
|
+
] : [];
|
|
18600
|
+
super([
|
|
18601
|
+
`${cli ? `dispatch ${commandName(tool)}` : tool} was not called: ${count} problem${count === 1 ? "" : "s"}`,
|
|
18602
|
+
...problems.map((problem) => `- ${problem}`),
|
|
18603
|
+
...help.map((line) => `- ${line}`)
|
|
18604
|
+
].join(`
|
|
18605
|
+
`));
|
|
18606
|
+
this.name = "ToolInputError";
|
|
18607
|
+
this.tool = tool;
|
|
18608
|
+
this.problems = problems;
|
|
18609
|
+
}
|
|
18610
|
+
}
|
|
18611
|
+
function isDispatchTool(tool) {
|
|
18612
|
+
return dispatchToolSpecs.some((spec) => spec.name === tool);
|
|
18613
|
+
}
|
|
18614
|
+
function exampleFor(tool) {
|
|
18615
|
+
const spec = dispatchToolSpecs.find((candidate) => candidate.name === tool);
|
|
18616
|
+
return { ...spec?.example };
|
|
18617
|
+
}
|
|
18618
|
+
function unwrap(schema) {
|
|
18619
|
+
let current = schema;
|
|
18620
|
+
while (current !== undefined) {
|
|
18621
|
+
const def = current.def;
|
|
18622
|
+
if (!("innerType" in def) || !(def.type === "optional" || def.type === "nullable" || def.type === "default"))
|
|
18623
|
+
break;
|
|
18624
|
+
current = def.innerType;
|
|
18625
|
+
}
|
|
18626
|
+
return current;
|
|
18627
|
+
}
|
|
18628
|
+
function shapeOf(schema) {
|
|
18629
|
+
const unwrapped = unwrap(schema);
|
|
18630
|
+
if (unwrapped === undefined)
|
|
18631
|
+
return;
|
|
18632
|
+
const def = unwrapped.def;
|
|
18633
|
+
return def.type === "object" && "shape" in def ? def.shape : undefined;
|
|
18634
|
+
}
|
|
18635
|
+
function schemaAt(schema, path) {
|
|
18636
|
+
let current = schema;
|
|
18637
|
+
for (const key of path) {
|
|
18638
|
+
const unwrapped = unwrap(current);
|
|
18639
|
+
if (unwrapped === undefined)
|
|
18640
|
+
return;
|
|
18641
|
+
const def = unwrapped.def;
|
|
18642
|
+
if (def.type === "object" && "shape" in def) {
|
|
18643
|
+
current = shapeOf(unwrapped)?.[String(key)];
|
|
18644
|
+
} else if (def.type === "array" && "element" in def) {
|
|
18645
|
+
current = def.element;
|
|
18646
|
+
} else {
|
|
18647
|
+
return;
|
|
18648
|
+
}
|
|
18649
|
+
}
|
|
18650
|
+
return unwrap(current);
|
|
18651
|
+
}
|
|
18652
|
+
function describeInput(value) {
|
|
18653
|
+
if (value === null)
|
|
18654
|
+
return "null";
|
|
18655
|
+
if (Array.isArray(value))
|
|
18656
|
+
return "an array";
|
|
18657
|
+
switch (typeof value) {
|
|
18658
|
+
case "number":
|
|
18659
|
+
case "boolean":
|
|
18660
|
+
return String(value);
|
|
18661
|
+
case "string":
|
|
18662
|
+
return "a string";
|
|
18663
|
+
case "object":
|
|
18664
|
+
return "an object";
|
|
18665
|
+
default:
|
|
18666
|
+
return typeof value;
|
|
18667
|
+
}
|
|
18668
|
+
}
|
|
18669
|
+
function describeExpected(expected, schema) {
|
|
18670
|
+
switch (expected) {
|
|
18671
|
+
case "int":
|
|
18672
|
+
return "an integer";
|
|
18673
|
+
case "object": {
|
|
18674
|
+
const shape = shapeOf(schema);
|
|
18675
|
+
const keys = shape === undefined ? [] : Object.entries(shape).map(([key, field]) => `${key}${field.def.type === "optional" ? "?" : ""}`);
|
|
18676
|
+
return keys.length === 0 ? "an object" : `an object {${keys.join(", ")}}`;
|
|
18677
|
+
}
|
|
18678
|
+
case "array":
|
|
18679
|
+
return "an array";
|
|
18680
|
+
default:
|
|
18681
|
+
return `a ${expected}`;
|
|
18682
|
+
}
|
|
18683
|
+
}
|
|
18684
|
+
function pathText(path, cliTool) {
|
|
18685
|
+
const [head, ...rest] = path.map(String);
|
|
18686
|
+
if (cliTool === undefined || head === undefined)
|
|
18687
|
+
return path.map(String).join(".");
|
|
18688
|
+
let flag = fieldFlag(cliTool, head);
|
|
18689
|
+
let index = 0;
|
|
18690
|
+
for (;index < rest.length && /^\d+$/.test(rest[index]); index++) {
|
|
18691
|
+
flag += `[${rest[index]}]`;
|
|
18692
|
+
}
|
|
18693
|
+
const tail = rest.slice(index).map((segment) => /^\d+$/.test(segment) ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
|
|
18694
|
+
return tail === "" ? flag : `${flag} ${tail}`;
|
|
18695
|
+
}
|
|
18696
|
+
function formatZodIssues(issues, schema, tool) {
|
|
18697
|
+
const cliTool = isDispatchTool(tool) ? tool : undefined;
|
|
18698
|
+
const allowed = Object.keys(shapeOf(schema) ?? {}).join(", ");
|
|
18699
|
+
return issues.flatMap((issue) => {
|
|
18700
|
+
const path = pathText(issue.path, cliTool);
|
|
18701
|
+
switch (issue.code) {
|
|
18702
|
+
case "invalid_type":
|
|
18703
|
+
return issue.input === undefined ? [`${path} is required (${issue.expected})`] : [
|
|
18704
|
+
`${path} must be ${describeExpected(issue.expected, schemaAt(schema, issue.path))}, not ${describeInput(issue.input)}`
|
|
18705
|
+
];
|
|
18706
|
+
case "unrecognized_keys": {
|
|
18707
|
+
if (cliTool !== undefined && issue.path.length === 0) {
|
|
18708
|
+
return issue.keys.map((key) => `unknown flag ${fieldFlag(cliTool, key)}`);
|
|
18709
|
+
}
|
|
18710
|
+
const here = Object.keys(shapeOf(schemaAt(schema, issue.path)) ?? {}).join(", ") || allowed;
|
|
18711
|
+
const where = path === "" ? "" : ` in ${path}`;
|
|
18712
|
+
return issue.keys.map((key) => `unknown field "${key}"${where}; allowed: ${here}`);
|
|
18713
|
+
}
|
|
18714
|
+
case "invalid_value":
|
|
18715
|
+
return [
|
|
18716
|
+
`${path} must be one of ${issue.values.map(String).join("|")}; got ${JSON.stringify(issue.input)}`
|
|
18717
|
+
];
|
|
18718
|
+
case "too_big":
|
|
18719
|
+
if (issue.origin === "array" && Array.isArray(issue.input)) {
|
|
18720
|
+
return [`${path} has ${issue.input.length} items; the limit is ${issue.maximum}`];
|
|
18721
|
+
}
|
|
18722
|
+
return [`${path} ${issue.message}`];
|
|
18723
|
+
case "custom":
|
|
18724
|
+
return [issue.message];
|
|
18725
|
+
default:
|
|
18726
|
+
return [path === "" ? issue.message : `${path}: ${issue.message}`];
|
|
18727
|
+
}
|
|
18728
|
+
});
|
|
18729
|
+
}
|
|
18730
|
+
|
|
18591
18731
|
// ../envoy-client/src/dispatch-execute.ts
|
|
18592
18732
|
function documentTopic(artifact) {
|
|
18593
18733
|
return documentTopicOf(artifact.project, artifact.slug);
|
|
@@ -18716,6 +18856,7 @@ var issueFreeTools = {
|
|
|
18716
18856
|
dispatch_open_asks: true,
|
|
18717
18857
|
dispatch_answers: true,
|
|
18718
18858
|
dispatch_whoami: true,
|
|
18859
|
+
dispatch_limits: true,
|
|
18719
18860
|
dispatch_inbox: true,
|
|
18720
18861
|
dispatch_architecture_sync: true
|
|
18721
18862
|
};
|
|
@@ -18831,17 +18972,13 @@ function askUrgency(args) {
|
|
|
18831
18972
|
const value = args.urgency;
|
|
18832
18973
|
return ASK_URGENCIES.find((urgency) => urgency === value);
|
|
18833
18974
|
}
|
|
18834
|
-
function
|
|
18975
|
+
function askQuestionWithRef(args) {
|
|
18976
|
+
const question = stringArg(args, "question");
|
|
18977
|
+
const ref = optionalString(args, "ref");
|
|
18835
18978
|
return ref === undefined || question.includes(ref) ? question : `${question}
|
|
18836
18979
|
|
|
18837
18980
|
Ref: ${ref}`;
|
|
18838
18981
|
}
|
|
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
18982
|
var pictureSendingTools = {
|
|
18846
18983
|
dispatch_ask: true,
|
|
18847
18984
|
dispatch_comment: true,
|
|
@@ -19034,16 +19171,6 @@ function itemReplyTo(args, field) {
|
|
|
19034
19171
|
function argumentProblems(tool, args) {
|
|
19035
19172
|
const problems = [];
|
|
19036
19173
|
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
19174
|
case "dispatch_edit_ask":
|
|
19048
19175
|
case "dispatch_resolve_ask":
|
|
19049
19176
|
case "dispatch_follow": {
|
|
@@ -19634,22 +19761,50 @@ function componentsLine(components) {
|
|
|
19634
19761
|
return "Components: unassigned";
|
|
19635
19762
|
}
|
|
19636
19763
|
}
|
|
19637
|
-
function claimText(claim,
|
|
19638
|
-
const
|
|
19639
|
-
const
|
|
19764
|
+
function claimText(claim, agents, read = {}) {
|
|
19765
|
+
const titles = agents?.titles;
|
|
19766
|
+
const liveness = holderLiveness(claim, agents, read);
|
|
19767
|
+
const holding = claimHolds(claim, titles, liveness);
|
|
19768
|
+
const takeableAt = claimTakeableAt(liveness);
|
|
19769
|
+
const unresponsive = liveness.holder_state === "unresponsive" && liveness.last_seen != null ? ` \xB7 unresponsive since ${liveness.last_seen}${takeableAt === null ? "" : `, takeable at ${takeableAt}`}` : " \xB7 unresponsive";
|
|
19770
|
+
const marker = holding === "unknown" ? " \xB7 liveness unknown" : holding === "lapsed" ? " \xB7 not running" : holding === "unresponsive" ? unresponsive : "";
|
|
19640
19771
|
return `${actorLabel(claim.actor, titles)} since ${claim.at}${marker}`;
|
|
19641
19772
|
}
|
|
19642
|
-
|
|
19773
|
+
function holderLiveness(claim, agents, read) {
|
|
19774
|
+
if (claim.actor.kind !== "session")
|
|
19775
|
+
return read;
|
|
19776
|
+
const row = agents?.liveness.get(claim.actor.id);
|
|
19777
|
+
if (row === undefined)
|
|
19778
|
+
return read;
|
|
19779
|
+
const holderState = read.holder_state ?? row.holder_state;
|
|
19780
|
+
const lastSeen = read.last_seen ?? row.last_seen;
|
|
19781
|
+
const takeableAt = read.takeable_at ?? row.takeable_at;
|
|
19782
|
+
return {
|
|
19783
|
+
...holderState === undefined ? {} : { holder_state: holderState },
|
|
19784
|
+
...lastSeen === undefined ? {} : { last_seen: lastSeen },
|
|
19785
|
+
...takeableAt === undefined ? {} : { takeable_at: takeableAt }
|
|
19786
|
+
};
|
|
19787
|
+
}
|
|
19788
|
+
async function liveAgents(client, needed) {
|
|
19643
19789
|
if (!needed) {
|
|
19644
19790
|
return;
|
|
19645
19791
|
}
|
|
19646
19792
|
try {
|
|
19647
19793
|
const agents = await client.listAgents();
|
|
19648
|
-
return
|
|
19794
|
+
return {
|
|
19795
|
+
titles: new Map(agents.map((agent) => [agent.session_id, agent.title])),
|
|
19796
|
+
liveness: new Map(agents.map((agent) => [agent.session_id, agentLiveness(agent)]))
|
|
19797
|
+
};
|
|
19649
19798
|
} catch {
|
|
19650
19799
|
return;
|
|
19651
19800
|
}
|
|
19652
19801
|
}
|
|
19802
|
+
function agentLiveness(agent) {
|
|
19803
|
+
return {
|
|
19804
|
+
...agent.state === undefined ? {} : { holder_state: agent.state },
|
|
19805
|
+
...agent.last_seen > 0 ? { last_seen: new Date(agent.last_seen).toISOString() } : {}
|
|
19806
|
+
};
|
|
19807
|
+
}
|
|
19653
19808
|
function holdsSession(claim) {
|
|
19654
19809
|
return claim?.actor.kind === "session";
|
|
19655
19810
|
}
|
|
@@ -19662,8 +19817,9 @@ function routeText(issue, titles) {
|
|
|
19662
19817
|
const holder = issue.route_holder ?? null;
|
|
19663
19818
|
const reach = {
|
|
19664
19819
|
live: routeHeldBySession(issue) && holder !== null ? ` (held by ${titles?.get(holder) ?? holder})` : "",
|
|
19820
|
+
holder_unresponsive: issue.route.startsWith("role:") ? ` (its holder${holder === null ? "" : ` ${titles?.get(holder) ?? holder}`} is unresponsive: messages wait for it)` : " (that session is unresponsive: messages wait for it)",
|
|
19665
19821
|
no_holder: issue.route.startsWith("role:") ? " (nobody holds it right now)" : " (that session is not running right now)",
|
|
19666
|
-
unknown: " (the Envoy listener did not answer, so whether it reaches anyone is unknown)"
|
|
19822
|
+
unknown: issue.route_status_reason === "refilling" ? " (the Envoy listener's agent list is refilling, so whether it reaches anyone is unknown; try again in a moment)" : " (the Envoy listener did not answer, so whether it reaches anyone is unknown)"
|
|
19667
19823
|
};
|
|
19668
19824
|
return issue.route + (issue.route_status == null ? "" : reach[issue.route_status]);
|
|
19669
19825
|
}
|
|
@@ -19721,7 +19877,7 @@ function refuseUnsavedRepository(verb, issue, repo) {
|
|
|
19721
19877
|
const lost = repo === "" ? "the repository was not cleared" : `${repo} was not saved`;
|
|
19722
19878
|
throw new Error(`Dispatch ${verb} ${issue.key} without its repository: this Dispatch server predates repository fields, so ${lost}; upgrade the server`);
|
|
19723
19879
|
}
|
|
19724
|
-
function issueSummary(issue, events, references, graph, linkBase, coverage,
|
|
19880
|
+
function issueSummary(issue, events, references, graph, linkBase, coverage, agents) {
|
|
19725
19881
|
const asks = issue.open_asks;
|
|
19726
19882
|
const spec = issue.artifacts?.find((artifact) => artifact.primary);
|
|
19727
19883
|
const specApproval = spec === undefined ? undefined : approvalLine(spec);
|
|
@@ -19742,11 +19898,11 @@ function issueSummary(issue, events, references, graph, linkBase, coverage, titl
|
|
|
19742
19898
|
`Link: ${new URL(`/issues/${encodeURIComponent(issue.key)}`, linkBase).toString()}`,
|
|
19743
19899
|
`Status: ${issue.status}`,
|
|
19744
19900
|
`Assignee: ${issue.assignee ?? "unassigned"}`,
|
|
19745
|
-
`Claimed by: ${issue.claim === null ? "nobody" : claimText(issue.claim,
|
|
19901
|
+
`Claimed by: ${issue.claim === null ? "nobody" : claimText(issue.claim, agents, issue)}`,
|
|
19746
19902
|
...issue.priority === null ? [] : [`Priority: P${issue.priority}`],
|
|
19747
19903
|
`Labels: ${issue.labels.length === 0 ? "none" : issue.labels.join(", ")}`,
|
|
19748
19904
|
componentsLine(issue.components),
|
|
19749
|
-
`Route: ${routeText(issue, titles)}`,
|
|
19905
|
+
`Route: ${routeText(issue, agents?.titles)}`,
|
|
19750
19906
|
repositoryLine(issue),
|
|
19751
19907
|
`Progress: ${progressText(issue.progress, ", ") || "none"}`,
|
|
19752
19908
|
...specApproval === undefined ? [] : [`Spec ${specApproval.replace(/^Approval/, "approval")}`],
|
|
@@ -20565,6 +20721,25 @@ async function executeDispatchTool(input) {
|
|
|
20565
20721
|
details: { session, owner, service, project }
|
|
20566
20722
|
};
|
|
20567
20723
|
}
|
|
20724
|
+
if (input.tool === "dispatch_limits") {
|
|
20725
|
+
const limits = await dispatchClient().limits();
|
|
20726
|
+
const count = (value) => value.toLocaleString("en-US");
|
|
20727
|
+
return {
|
|
20728
|
+
text: [
|
|
20729
|
+
`One block of a body - a paragraph, list, quote, table or code block: ${count(limits.block_units)} characters (UTF-16 units).`,
|
|
20730
|
+
`Blocks in one body: ${count(limits.item_blocks)}.`,
|
|
20731
|
+
`An ask's question and its options together: ${count(limits.ask_units)} characters (UTF-16 units).`,
|
|
20732
|
+
`Options on one ask: ${count(limits.ask_options)}.`,
|
|
20733
|
+
`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.`,
|
|
20734
|
+
`One request: ${count(limits.request_bytes)} bytes.`,
|
|
20735
|
+
`One markdown document: ${count(limits.document_bytes)} bytes.`,
|
|
20736
|
+
`One handoff body: ${count(limits.handoff_bytes)} bytes.`,
|
|
20737
|
+
"Dispatch holds every write to these bounds and refuses a longer text, naming the block or the field that passed one."
|
|
20738
|
+
].join(`
|
|
20739
|
+
`),
|
|
20740
|
+
details: { ...limits }
|
|
20741
|
+
};
|
|
20742
|
+
}
|
|
20568
20743
|
if (input.tool === "dispatch_inbox") {
|
|
20569
20744
|
const client = dispatchClient();
|
|
20570
20745
|
const pending = client.credentialPending().then((answer) => ({ answer }), (error) => ({ error }));
|
|
@@ -20615,18 +20790,18 @@ async function executeDispatchTool(input) {
|
|
|
20615
20790
|
throw new Error("issue is required");
|
|
20616
20791
|
return owner.issue;
|
|
20617
20792
|
};
|
|
20618
|
-
const postWithPictures = (text,
|
|
20793
|
+
const postWithPictures = (text, owner, upload) => textWithPictures(text, pictures, owner, (picture) => upload(picture).catch((error) => {
|
|
20619
20794
|
if (!(error instanceof DispatchWriteLandedError))
|
|
20620
20795
|
throw error;
|
|
20621
20796
|
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 });
|
|
20622
20797
|
}), actor);
|
|
20623
|
-
const writePictures = (resolved, text
|
|
20798
|
+
const writePictures = (resolved, text) => {
|
|
20624
20799
|
if (resolved?.owner.kind === "project") {
|
|
20625
20800
|
const { project } = resolved.owner;
|
|
20626
|
-
return postWithPictures(text,
|
|
20801
|
+
return postWithPictures(text, project, (upload) => client.projectArtifact(project, upload));
|
|
20627
20802
|
}
|
|
20628
20803
|
const issueKey = issue();
|
|
20629
|
-
return postWithPictures(text,
|
|
20804
|
+
return postWithPictures(text, issueKey, (upload) => client.artifact(issueKey, upload));
|
|
20630
20805
|
};
|
|
20631
20806
|
const hostSession = input.sessionId?.trim();
|
|
20632
20807
|
const shown = hostSession ? shownPictures(hostSession) : undefined;
|
|
@@ -20930,10 +21105,11 @@ async function executeDispatchTool(input) {
|
|
|
20930
21105
|
route: row.route ?? null,
|
|
20931
21106
|
route_status: row.route_status ?? null,
|
|
20932
21107
|
route_holder: row.route_holder ?? null,
|
|
21108
|
+
route_status_reason: row.route_status_reason ?? null,
|
|
20933
21109
|
updated_at: row.updated_at,
|
|
20934
21110
|
progress: row.progress
|
|
20935
21111
|
}));
|
|
20936
|
-
const
|
|
21112
|
+
const agents = await liveAgents(client, rows.some((row) => holdsSession(row.claim)));
|
|
20937
21113
|
const isPartial = offset !== 0 || rows.length !== total;
|
|
20938
21114
|
const showing = !isPartial ? "" : rows.length === 0 ? `showing 0-0 of ${total}` : pageSummaryText(offset, rows.length, total);
|
|
20939
21115
|
return {
|
|
@@ -20941,7 +21117,7 @@ async function executeDispatchTool(input) {
|
|
|
20941
21117
|
`${rows.length} ${rows.length === 1 ? "issue" : "issues"} in ${project}` + (isPartial ? ` (${showing})` : ""),
|
|
20942
21118
|
...rows.map((row) => {
|
|
20943
21119
|
const progress = progressText(row.progress, " \xB7 ");
|
|
20944
|
-
return `${row.key} [${row.status}]${row.priority === null ? "" : ` P${row.priority}`} ${row.title}` + (row.open_asks === 0 ? "" : ` \xB7 ${row.open_asks} open ${row.open_asks === 1 ? "ask" : "asks"}`) + (row.claim === null ? "" : ` \xB7 claimed by ${claimText(row.claim,
|
|
21120
|
+
return `${row.key} [${row.status}]${row.priority === null ? "" : ` P${row.priority}`} ${row.title}` + (row.open_asks === 0 ? "" : ` \xB7 ${row.open_asks} open ${row.open_asks === 1 ? "ask" : "asks"}`) + (row.claim === null ? "" : ` \xB7 claimed by ${claimText(row.claim, agents)}`) + (progress === "" ? "" : ` \xB7 ${progress}`) + (row.route === null || row.route_status === "live" || row.route_status === null ? "" : ` \xB7 route ${routeText(row)}`);
|
|
20945
21121
|
})
|
|
20946
21122
|
].join(`
|
|
20947
21123
|
`),
|
|
@@ -21036,13 +21212,7 @@ async function executeDispatchTool(input) {
|
|
|
21036
21212
|
const multiple = optionalBoolean(args, "multiple");
|
|
21037
21213
|
const urgency = askUrgency(args);
|
|
21038
21214
|
const anchored = anchorArgs && resolved ? anchor(resolved.artifact, anchorArgs) : undefined;
|
|
21039
|
-
const
|
|
21040
|
-
const refAppended = withRef !== stringArg(args, "question");
|
|
21041
|
-
const question = await writePictures(resolved, withRef, {
|
|
21042
|
-
cap: ASK_QUESTION_MAX,
|
|
21043
|
-
text: refAppended ? "question plus ref" : "question",
|
|
21044
|
-
shorten: refAppended ? "shorten the question, drop the ref" : "shorten the question"
|
|
21045
|
-
});
|
|
21215
|
+
const question = await writePictures(resolved, askQuestionWithRef(args));
|
|
21046
21216
|
const askInput = {
|
|
21047
21217
|
question,
|
|
21048
21218
|
...Array.isArray(options) ? { options } : {},
|
|
@@ -21106,11 +21276,7 @@ async function executeDispatchTool(input) {
|
|
|
21106
21276
|
}
|
|
21107
21277
|
const replyToBlock = replyTo?.block ?? replyToAskTarget?.block;
|
|
21108
21278
|
const requestedTurn = optionalString(args, "turn");
|
|
21109
|
-
const body = await writePictures(resolved, stringArg(args, "body")
|
|
21110
|
-
cap: DISPATCH_BODY_MAX,
|
|
21111
|
-
text: "body",
|
|
21112
|
-
shorten: "shorten the body"
|
|
21113
|
-
});
|
|
21279
|
+
const body = await writePictures(resolved, stringArg(args, "body"));
|
|
21114
21280
|
const commentInput = {
|
|
21115
21281
|
body,
|
|
21116
21282
|
...anchored === undefined ? {} : { anchor: anchored },
|
|
@@ -21180,11 +21346,6 @@ async function executeDispatchTool(input) {
|
|
|
21180
21346
|
const target = messageInReplyTo(args);
|
|
21181
21347
|
const inReplyTo = target?.id;
|
|
21182
21348
|
const written = stringArg(args, "body");
|
|
21183
|
-
const bodyLimit = {
|
|
21184
|
-
cap: DISPATCH_BODY_MAX,
|
|
21185
|
-
text: "body",
|
|
21186
|
-
shorten: "shorten the body"
|
|
21187
|
-
};
|
|
21188
21349
|
if (owner === null && inReplyTo !== undefined) {
|
|
21189
21350
|
let body = written;
|
|
21190
21351
|
if (pictures.length > 0) {
|
|
@@ -21192,7 +21353,7 @@ async function executeDispatchTool(input) {
|
|
|
21192
21353
|
if (!sessionId) {
|
|
21193
21354
|
throw new Error("host session id is required to send pictures in a direct-message reply");
|
|
21194
21355
|
}
|
|
21195
|
-
body = await postWithPictures(written,
|
|
21356
|
+
body = await postWithPictures(written, `agent/${sessionId}`, (upload) => client.agentArtifact(sessionId, upload));
|
|
21196
21357
|
}
|
|
21197
21358
|
const reply = await client.messageReply(inReplyTo, { body, attempt: 1, actor }, { followUp: true });
|
|
21198
21359
|
if (reply.duplicate === true && reply.body === body) {
|
|
@@ -21221,7 +21382,7 @@ async function executeDispatchTool(input) {
|
|
|
21221
21382
|
};
|
|
21222
21383
|
}
|
|
21223
21384
|
const issueKey = issue();
|
|
21224
|
-
const body = await postWithPictures(written,
|
|
21385
|
+
const body = await postWithPictures(written, issueKey, (upload) => client.artifact(issueKey, upload));
|
|
21225
21386
|
const message = await client.message(issueKey, {
|
|
21226
21387
|
body,
|
|
21227
21388
|
...inReplyTo === undefined ? {} : { in_reply_to: inReplyTo },
|
|
@@ -21724,7 +21885,7 @@ ${handoff.body}`,
|
|
|
21724
21885
|
};
|
|
21725
21886
|
if (ownerArguments.ref?.kind === "log") {
|
|
21726
21887
|
const read = await client.read(issueKey, readEvents);
|
|
21727
|
-
const pictures = await picturesOf(read.events
|
|
21888
|
+
const pictures = await picturesOf(await eventTextsWhole(client, read.events));
|
|
21728
21889
|
return {
|
|
21729
21890
|
text: [logSummary(read.issue, read.events), ...pictures.lines].join(`
|
|
21730
21891
|
`),
|
|
@@ -21742,18 +21903,18 @@ ${handoff.body}`,
|
|
|
21742
21903
|
const readPromise = client.read(issueKey, readEvents);
|
|
21743
21904
|
const referencesPromise = issueReferencesOrUnavailable(client, issueKey);
|
|
21744
21905
|
const read = await readPromise;
|
|
21745
|
-
const [references, graph,
|
|
21906
|
+
const [references, graph, agents, pictures, coverage] = await Promise.all([
|
|
21746
21907
|
referencesPromise,
|
|
21747
21908
|
graphSections(client, dispatchIssueRef(read.issue.key)),
|
|
21748
|
-
|
|
21909
|
+
liveAgents(client, holdsSession(read.issue.claim) || routeHeldBySession(read.issue)),
|
|
21749
21910
|
picturesOf([
|
|
21750
21911
|
...read.issue.open_asks.map((ask) => ({ text: ask.question, at: ask.created_at })),
|
|
21751
|
-
...read.events
|
|
21912
|
+
...await eventTextsWhole(client, read.events)
|
|
21752
21913
|
]),
|
|
21753
21914
|
issueCoverageOrReason(client, read.issue.key)
|
|
21754
21915
|
]);
|
|
21755
21916
|
return {
|
|
21756
|
-
text: issueSummary(read.issue, read.events, references, [...pictures.lines, ...graph], linkBase, coverage,
|
|
21917
|
+
text: issueSummary(read.issue, read.events, references, [...pictures.lines, ...graph], linkBase, coverage, agents),
|
|
21757
21918
|
details: { issue: read.issue.key },
|
|
21758
21919
|
...showImages(pictures),
|
|
21759
21920
|
...repositoryFieldsWarnings(read.issue)
|
|
@@ -22584,7 +22745,7 @@ function encode4(input) {
|
|
|
22584
22745
|
}
|
|
22585
22746
|
|
|
22586
22747
|
// ../../node_modules/.bun/jose@6.2.9/node_modules/jose/dist/webapi/lib/type_checks.js
|
|
22587
|
-
function
|
|
22748
|
+
function isObject3(input) {
|
|
22588
22749
|
if (typeof input !== "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]") {
|
|
22589
22750
|
return false;
|
|
22590
22751
|
}
|
|
@@ -22612,7 +22773,7 @@ function isDisjoint(...headers) {
|
|
|
22612
22773
|
}
|
|
22613
22774
|
return true;
|
|
22614
22775
|
}
|
|
22615
|
-
var isJWK = (key) =>
|
|
22776
|
+
var isJWK = (key) => isObject3(key) && typeof key.kty === "string";
|
|
22616
22777
|
var isPrivateJWK = (key) => key.kty !== "oct" && (key.kty === "AKP" && typeof key.priv === "string" || typeof key.d === "string");
|
|
22617
22778
|
var isPublicJWK = (key) => key.kty !== "oct" && key.d === undefined && key.priv === undefined;
|
|
22618
22779
|
var isSecretJWK = (key) => key.kty === "oct" && typeof key.k === "string";
|
|
@@ -23031,7 +23192,7 @@ function numericDate(value, label) {
|
|
|
23031
23192
|
class JWTClaimsBuilder {
|
|
23032
23193
|
#payload;
|
|
23033
23194
|
constructor(payload) {
|
|
23034
|
-
if (!
|
|
23195
|
+
if (!isObject3(payload)) {
|
|
23035
23196
|
throw new TypeError("JWT Claims Set MUST be an object");
|
|
23036
23197
|
}
|
|
23037
23198
|
this.#payload = structuredClone(payload);
|
|
@@ -25123,6 +25284,9 @@ function sessionEnvoySettings(file, env, options) {
|
|
|
25123
25284
|
var DEFAULT_TIMEOUT_MS = 5000;
|
|
25124
25285
|
var RETRY_DELAY_MS = 250;
|
|
25125
25286
|
var REPLAY_TIMEOUT_MS = 1e4;
|
|
25287
|
+
var SessionStateSchema = _enum2(["live", "unresponsive", "gone"]);
|
|
25288
|
+
var UNRESPONSIVE_RULE = "An unresponsive session is not dead: it keeps its role claims and its issue claims, and a " + "message sent to it is stored until it answers. Start no replacement for it and take no claim " + `from it until it is gone, or until ${ISSUE_CLAIM_UNRESPONSIVE_GRACE_MS / 60000} minutes ` + "have passed since its last_seen, the time of its last registration.";
|
|
25289
|
+
var WireStateSchema = SessionStateSchema.default("live");
|
|
25126
25290
|
var InterestWireSchema = object({
|
|
25127
25291
|
session_id: string2(),
|
|
25128
25292
|
machine_id: string2(),
|
|
@@ -25152,6 +25316,7 @@ var SessionWireSchema = object({
|
|
|
25152
25316
|
capabilities: array(string2()).optional(),
|
|
25153
25317
|
self_subscribed: boolean2(),
|
|
25154
25318
|
last_seen: number2().int().optional(),
|
|
25319
|
+
state: WireStateSchema,
|
|
25155
25320
|
plugin: string2().optional(),
|
|
25156
25321
|
plugin_version: string2().optional()
|
|
25157
25322
|
});
|
|
@@ -25159,7 +25324,9 @@ var RoleWireSchema = object({
|
|
|
25159
25324
|
role: string2(),
|
|
25160
25325
|
holder: string2(),
|
|
25161
25326
|
host: string2().optional(),
|
|
25162
|
-
last_seen: number2().int()
|
|
25327
|
+
last_seen: number2().int(),
|
|
25328
|
+
state: WireStateSchema,
|
|
25329
|
+
holder_state: SessionStateSchema.optional()
|
|
25163
25330
|
});
|
|
25164
25331
|
var RoleHeldWireSchema = object({
|
|
25165
25332
|
error: string2(),
|
|
@@ -25169,11 +25336,21 @@ var RoleHeldWireSchema = object({
|
|
|
25169
25336
|
var ErrorWireSchema = object({
|
|
25170
25337
|
error: string2(),
|
|
25171
25338
|
code: string2().optional(),
|
|
25172
|
-
expected: array(string2()).optional()
|
|
25339
|
+
expected: array(string2()).optional(),
|
|
25340
|
+
state: SessionStateSchema.optional(),
|
|
25341
|
+
holder: string2().optional(),
|
|
25342
|
+
holder_state: SessionStateSchema.optional(),
|
|
25343
|
+
last_seen: number2().int().optional(),
|
|
25344
|
+
claim_released: boolean2().optional(),
|
|
25345
|
+
unresponsive: array(string2()).optional()
|
|
25173
25346
|
});
|
|
25174
25347
|
var EnvelopeResponseSchema = EnvelopeSchema.extend({
|
|
25175
25348
|
recipient: string2().optional(),
|
|
25176
25349
|
holder: string2().optional(),
|
|
25350
|
+
holder_state: SessionStateSchema.optional(),
|
|
25351
|
+
recipient_state: SessionStateSchema.optional(),
|
|
25352
|
+
last_seen: number2().int().optional(),
|
|
25353
|
+
unresponsive: array(string2()).optional(),
|
|
25177
25354
|
duplicate: boolean2().optional()
|
|
25178
25355
|
});
|
|
25179
25356
|
var PublishResponseSchema = EnvelopeResponseSchema.extend({
|
|
@@ -25231,12 +25408,36 @@ function expandSubscriptionTopics(topics) {
|
|
|
25231
25408
|
}
|
|
25232
25409
|
return [...expanded];
|
|
25233
25410
|
}
|
|
25411
|
+
function refusalStateText(parsed) {
|
|
25412
|
+
const sentences = [];
|
|
25413
|
+
const state = parsed.holder_state ?? parsed.state;
|
|
25414
|
+
if (state !== undefined) {
|
|
25415
|
+
const who = parsed.holder === undefined ? "That session" : `Holder ${parsed.holder}`;
|
|
25416
|
+
const seen = parsed.last_seen === undefined || parsed.last_seen <= 0 ? "" : `, last seen ${new Date(parsed.last_seen).toISOString()}`;
|
|
25417
|
+
sentences.push(`${who} is ${state}${seen}.`);
|
|
25418
|
+
}
|
|
25419
|
+
const stored = parsed.unresponsive ?? [];
|
|
25420
|
+
if (stored.length > 0) {
|
|
25421
|
+
const one = stored.length === 1;
|
|
25422
|
+
sentences.push(`Envoy stored the message for ${stored.join(", ")}.`, `${one ? "That session" : "Those sessions"} stopped answering, so ${one ? "it" : "they"} did not fail this send.`);
|
|
25423
|
+
}
|
|
25424
|
+
if (sentences.length === 0)
|
|
25425
|
+
return "";
|
|
25426
|
+
if (state === "unresponsive" || stored.length > 0)
|
|
25427
|
+
sentences.push(UNRESPONSIVE_RULE);
|
|
25428
|
+
return ` ${sentences.join(" ")}`;
|
|
25429
|
+
}
|
|
25234
25430
|
|
|
25235
25431
|
class EnvoyApiError extends Error {
|
|
25236
25432
|
details;
|
|
25237
25433
|
name = "EnvoyApiError";
|
|
25238
25434
|
expected;
|
|
25239
25435
|
code;
|
|
25436
|
+
holder;
|
|
25437
|
+
sessionState;
|
|
25438
|
+
lastSeen;
|
|
25439
|
+
claimReleased;
|
|
25440
|
+
unresponsive;
|
|
25240
25441
|
constructor(details) {
|
|
25241
25442
|
let parsed;
|
|
25242
25443
|
try {
|
|
@@ -25244,10 +25445,15 @@ class EnvoyApiError extends Error {
|
|
|
25244
25445
|
if (result.success)
|
|
25245
25446
|
parsed = result.data;
|
|
25246
25447
|
} catch {}
|
|
25247
|
-
super(parsed === undefined ? `${details.method} ${details.url} failed with ${details.status}: ${details.responseBody}` : `${parsed.error}${parsed.expected === undefined ? "" : ` (expected: ${parsed.expected.join(", ")})`}`);
|
|
25448
|
+
super(parsed === undefined ? `${details.method} ${details.url} failed with ${details.status}: ${details.responseBody}` : `${parsed.error}${parsed.expected === undefined ? "" : ` (expected: ${parsed.expected.join(", ")})`}${refusalStateText(parsed)}`);
|
|
25248
25449
|
this.details = details;
|
|
25249
25450
|
this.expected = parsed?.expected;
|
|
25250
25451
|
this.code = parsed?.code;
|
|
25452
|
+
this.holder = parsed?.holder;
|
|
25453
|
+
this.sessionState = parsed?.holder_state ?? parsed?.state;
|
|
25454
|
+
this.lastSeen = parsed?.last_seen;
|
|
25455
|
+
this.claimReleased = parsed?.claim_released;
|
|
25456
|
+
this.unresponsive = parsed?.unresponsive;
|
|
25251
25457
|
}
|
|
25252
25458
|
}
|
|
25253
25459
|
var mintedDedupeKey2 = new RegExp(MINTED_DEDUPE_KEY_PATTERN);
|
|
@@ -25403,6 +25609,8 @@ function createEnvoyClient(config) {
|
|
|
25403
25609
|
envelope: response,
|
|
25404
25610
|
recipient: response.recipient ?? input.targetSessionID,
|
|
25405
25611
|
confirmed: response.recipient !== undefined,
|
|
25612
|
+
recipientState: response.recipient_state ?? "live",
|
|
25613
|
+
...response.last_seen === undefined || response.last_seen <= 0 ? {} : { lastSeen: response.last_seen },
|
|
25406
25614
|
duplicate: response.duplicate === true
|
|
25407
25615
|
};
|
|
25408
25616
|
},
|
|
@@ -25421,6 +25629,8 @@ function createEnvoyClient(config) {
|
|
|
25421
25629
|
return {
|
|
25422
25630
|
envelope: response,
|
|
25423
25631
|
...response.holder === undefined ? {} : { holder: response.holder },
|
|
25632
|
+
...response.holder_state === undefined ? {} : { holderState: response.holder_state },
|
|
25633
|
+
unresponsive: response.unresponsive ?? [],
|
|
25424
25634
|
...response.kept === undefined ? {} : { kept: response.kept },
|
|
25425
25635
|
...response.kept_reason === undefined ? {} : { keptReason: response.kept_reason }
|
|
25426
25636
|
};
|
|
@@ -25464,6 +25674,8 @@ function createEnvoyClient(config) {
|
|
|
25464
25674
|
search.set("dir", input.directory);
|
|
25465
25675
|
if (input.title !== undefined)
|
|
25466
25676
|
search.set("title", input.title);
|
|
25677
|
+
if (input.include !== undefined)
|
|
25678
|
+
search.set("include", input.include);
|
|
25467
25679
|
const query = search.size === 0 ? "" : `?${search.toString()}`;
|
|
25468
25680
|
return SessionWireSchema.array().parse(JSON.parse(await request(`/v1/sessions${query}`, {})));
|
|
25469
25681
|
},
|