@sjawhar/claude-envoy 5.17.0 → 5.19.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/.claude-plugin/plugin.json +1 -1
- package/.omp-plugin/plugin.json +1 -1
- package/dist/codex-hook.js +513 -78
- package/dist/dispatch.js +517 -78
- package/dist/envoy-channel.js +578 -105
- package/dist/session-hook.js +513 -78
- package/package.json +1 -1
- package/src/codex/codex-user-turns.ts +13 -12
- package/src/envoy-channel-server.ts +13 -3
- package/src/user-turn-router.ts +112 -17
package/dist/envoy-channel.js
CHANGED
|
@@ -36637,6 +36637,7 @@ var PROJECT_NAME_MAX = 80;
|
|
|
36637
36637
|
var MAX_ISSUE_PAGE_LIMIT = 250;
|
|
36638
36638
|
var DEFAULT_ISSUE_PAGE_LIMIT = 50;
|
|
36639
36639
|
var DEFAULT_ISSUE_READ_EVENTS = 10;
|
|
36640
|
+
var POST_HISTORY_PAGE_LIMIT = 200;
|
|
36640
36641
|
var ASK_TURNS = ["human", "agent"];
|
|
36641
36642
|
var DELIVERY_CAPABILITIES = ["aside", "btw", "steer"];
|
|
36642
36643
|
var DELIVERY_ATTEMPT_STATES = ["pending", "sent", "queued", "failed"];
|
|
@@ -36694,10 +36695,29 @@ var replyBlockFields = {
|
|
|
36694
36695
|
ref: string2().optional(),
|
|
36695
36696
|
block_id: string2(),
|
|
36696
36697
|
text: string2(),
|
|
36697
|
-
removed: boolean2()
|
|
36698
|
+
removed: boolean2(),
|
|
36699
|
+
edited_at: string2().optional(),
|
|
36700
|
+
deleted_at: string2().optional()
|
|
36698
36701
|
};
|
|
36699
|
-
var
|
|
36700
|
-
|
|
36702
|
+
var DocumentActorSchema = object({
|
|
36703
|
+
kind: string2(),
|
|
36704
|
+
id: string2(),
|
|
36705
|
+
act: object({
|
|
36706
|
+
session: string2().optional(),
|
|
36707
|
+
token_id: string2().optional(),
|
|
36708
|
+
token_name: string2().optional(),
|
|
36709
|
+
scopes: array(string2()).optional()
|
|
36710
|
+
}).optional(),
|
|
36711
|
+
origin: ActorOriginSchema.optional(),
|
|
36712
|
+
owner: string2().optional(),
|
|
36713
|
+
service: string2().optional(),
|
|
36714
|
+
project: string2().optional()
|
|
36715
|
+
});
|
|
36716
|
+
var WrittenReplyBlockSchema = strictObject({ ...replyBlockFields, deleted_by: ActorSchema.optional() }).readonly();
|
|
36717
|
+
var ReplyBlockSchema = object({
|
|
36718
|
+
...replyBlockFields,
|
|
36719
|
+
deleted_by: DocumentActorSchema.optional()
|
|
36720
|
+
});
|
|
36701
36721
|
|
|
36702
36722
|
// ../contracts/src/dispatch-api-documents.ts
|
|
36703
36723
|
var versionFields = {
|
|
@@ -37022,18 +37042,26 @@ var messageValidation = {
|
|
|
37022
37042
|
var readOwner = documentOwnerValidation(false);
|
|
37023
37043
|
var READ_OWNER_RULE = "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one.";
|
|
37024
37044
|
var READ_MESSAGE_RULE = "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.";
|
|
37045
|
+
var READ_HISTORY_RULE = "history reads each body an edit or the delete of one post replaced, so it needs a ref naming one comment or one issue message: message stands alone and names a whole conversation, which keeps no history of its own.";
|
|
37025
37046
|
function readProblem(value) {
|
|
37026
37047
|
const input = value;
|
|
37048
|
+
const historyKept = input.history !== true || typeof input.ref === "string";
|
|
37027
37049
|
if (typeof input.message !== "string") {
|
|
37028
|
-
return
|
|
37050
|
+
return brokenParts([
|
|
37051
|
+
[readOwner.check(value), READ_OWNER_RULE],
|
|
37052
|
+
[historyKept, READ_HISTORY_RULE]
|
|
37053
|
+
]);
|
|
37029
37054
|
}
|
|
37030
37055
|
const alone = input.issue === undefined && input.project === undefined && input.artifact === undefined && input.ref === undefined;
|
|
37031
|
-
return
|
|
37056
|
+
return brokenParts([
|
|
37057
|
+
[alone, READ_MESSAGE_RULE],
|
|
37058
|
+
[historyKept, READ_HISTORY_RULE]
|
|
37059
|
+
]);
|
|
37032
37060
|
}
|
|
37033
37061
|
var readValidation = {
|
|
37034
37062
|
check: (value) => readProblem(value) === undefined,
|
|
37035
|
-
message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`,
|
|
37036
|
-
refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`
|
|
37063
|
+
message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`,
|
|
37064
|
+
refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`
|
|
37037
37065
|
};
|
|
37038
37066
|
var ISSUE_COMPONENTS_MODES = ["inherit", "explicit", "none"];
|
|
37039
37067
|
function componentsArgument(z) {
|
|
@@ -37053,6 +37081,8 @@ var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
|
37053
37081
|
var DISPATCH_BLOCK_UNITS = 32000;
|
|
37054
37082
|
var DISPATCH_ITEM_BLOCKS = 32768;
|
|
37055
37083
|
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. A body holding a decision block (`:::ask`) " + "is refused however short it is, since nobody can answer a question put in a comment or a " + "message: ask the question in the issue's own document, as a decision block there, or open an " + "ask with `dispatch ask`.";
|
|
37084
|
+
var COMMENT_ARGUMENT = "Comment id (uuid), or a dispatch://KEY/comment/<id> or " + "dispatch://PROJECT/artifact/<slug>/comment/<id> reference; a reference accepts an " + "8+ character id prefix that is unique on its owner.";
|
|
37085
|
+
var MESSAGE_ARGUMENT = "Message id (uuid), or a dispatch://KEY/message/<id> reference; a reference accepts an " + "8+ character id prefix that is unique on its owner.";
|
|
37056
37086
|
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.";
|
|
37057
37087
|
var DISPATCH_HANDOFF_BODY_MAX = 262144;
|
|
37058
37088
|
var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
@@ -37324,7 +37354,7 @@ var dispatchToolSpecs = [
|
|
|
37324
37354
|
example: { comment: "01234567-0000-4000-8000-000000000001" },
|
|
37325
37355
|
description: "Resolve a review comment thread once it has been addressed - typically your own comment " + "after the document was fixed. Any session or human may resolve any open comment on an " + "open issue or project document. To reopen a resolved comment, the credential must hold " + "the person scope: a browser sign-in, or a personal token that holds it. " + "Not for asks: use dispatch resolve-ask.",
|
|
37326
37356
|
arguments: (z) => ({
|
|
37327
|
-
comment: z.string().describe(
|
|
37357
|
+
comment: z.string().describe(COMMENT_ARGUMENT)
|
|
37328
37358
|
}),
|
|
37329
37359
|
strict: true
|
|
37330
37360
|
},
|
|
@@ -37379,6 +37409,28 @@ var dispatchToolSpecs = [
|
|
|
37379
37409
|
}),
|
|
37380
37410
|
validation: documentOwnerValidation(true, true)
|
|
37381
37411
|
},
|
|
37412
|
+
{
|
|
37413
|
+
name: "dispatch_edit_comment",
|
|
37414
|
+
example: {
|
|
37415
|
+
comment: "01234567-0000-4000-8000-000000000001",
|
|
37416
|
+
body: "Corrected: the retry window is 72 hours, not 24."
|
|
37417
|
+
},
|
|
37418
|
+
description: "Replace the body of a comment or a suggestion you wrote, to correct it. The author alone " + "may edit a comment: every other caller is refused 403 NOT_AUTHOR. The comment keeps its " + "id, its place in its thread and its anchor, and every read of it carries the time of the " + "edit. A Dispatch of this release keeps the body you replace: " + "dispatch read --ref dispatch://KEY/comment/<id> --history lists each earlier body with the " + "actor that replaced it and the time. Use it to correct what you wrote, never to answer: a " + "new point is a reply (dispatch comment --reply-to), which the thread shows in its own " + "place. A comment of a closed issue is edited too, and a deleted comment is refused 409 " + `POST_DELETED. ${BODY_BLOCK_RULE}`,
|
|
37419
|
+
arguments: (z) => ({
|
|
37420
|
+
comment: z.string().describe(COMMENT_ARGUMENT),
|
|
37421
|
+
body: z.string().describe(`The comment's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
|
|
37422
|
+
}),
|
|
37423
|
+
strict: true
|
|
37424
|
+
},
|
|
37425
|
+
{
|
|
37426
|
+
name: "dispatch_delete_comment",
|
|
37427
|
+
example: { comment: "01234567-0000-4000-8000-000000000001" },
|
|
37428
|
+
description: "Withdraw a comment or a suggestion you wrote, where the text itself should not stand. The " + "author alone may delete a comment: every other caller is refused 403 NOT_AUTHOR. The " + "comment keeps its id and its place in its thread, and no read of it gives any part of its " + "body again: each read of it marks it deleted and names who deleted it and when. The " + "events of a reply's creation and of each edit of the reply written before the delete keep " + "the preview of it they carried, and the document's events written " + "before the delete keep the name an accepted suggestion gave its version, which the delete " + "renames. Its " + "replies keep their own text and their own places, a suggestion's replacement text goes " + "from the comment with the body (an accepted one's stays in the document as its own text), " + "the document's margin mark holds no text, each mention delivery still waiting is failed, " + "and search stops matching it. A suggestion of it still waiting is rejected out of the " + "document before the body goes, so the text an insert suggestion put there goes with it. " + "Every block of it loses the text each revision recorded, so a reference pinned to a block " + "of the comment reads none either. A Dispatch of this release keeps the body: " + "dispatch read --ref dispatch://KEY/comment/<id> --history then marks the comment deleted " + "and lists no body. Correct a wording with dispatch edit-comment instead, and close an " + "addressed thread with dispatch resolve-comment. A comment of a closed issue is deleted " + "too, and a second delete is refused 409 POST_DELETED. A mention delivery its sender moves " + "while the delete is being written is 409 DELETE_CONTENDED, with nothing written: run the " + "same command again.",
|
|
37429
|
+
arguments: (z) => ({
|
|
37430
|
+
comment: z.string().describe(COMMENT_ARGUMENT)
|
|
37431
|
+
}),
|
|
37432
|
+
strict: true
|
|
37433
|
+
},
|
|
37382
37434
|
{
|
|
37383
37435
|
name: "dispatch_message",
|
|
37384
37436
|
example: { issue: "DSP-1", body: "Implementation started." },
|
|
@@ -37391,6 +37443,28 @@ var dispatchToolSpecs = [
|
|
|
37391
37443
|
}),
|
|
37392
37444
|
validation: messageValidation
|
|
37393
37445
|
},
|
|
37446
|
+
{
|
|
37447
|
+
name: "dispatch_edit_message",
|
|
37448
|
+
example: {
|
|
37449
|
+
message: "01234567-0000-4000-8000-000000000001",
|
|
37450
|
+
body: "Corrected: the export runs at 02:00 UTC, not 02:00 local."
|
|
37451
|
+
},
|
|
37452
|
+
description: "Replace the body of an issue message you wrote, to correct it. The author alone may edit a " + "message: every other caller is refused 403 NOT_AUTHOR. Only a message on an issue is " + "edited; a message of a direct conversation, which names no issue, is refused 409 " + "NOT_AN_ISSUE_MESSAGE. The message keeps its id and its place in its thread, and every read " + "of it carries the time of the edit. A Dispatch of this release keeps the body you replace: " + "dispatch read --ref dispatch://KEY/message/<id> --history lists each earlier body with the " + "actor that replaced it and the time. Use it to correct what you wrote, never to answer: a " + "new point is a reply (dispatch message --in-reply-to). The block ids follow the new text, " + "so a reply that names a block of this message may name a block the edit removed. A message " + `of a closed issue is edited too, and a deleted message is refused 409 POST_DELETED. ${BODY_BLOCK_RULE}`,
|
|
37453
|
+
arguments: (z) => ({
|
|
37454
|
+
message: z.string().describe(MESSAGE_ARGUMENT),
|
|
37455
|
+
body: z.string().describe(`The message's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
|
|
37456
|
+
}),
|
|
37457
|
+
strict: true
|
|
37458
|
+
},
|
|
37459
|
+
{
|
|
37460
|
+
name: "dispatch_delete_message",
|
|
37461
|
+
example: { message: "01234567-0000-4000-8000-000000000001" },
|
|
37462
|
+
description: "Withdraw an issue message you wrote, where the text itself should not stand. The author " + "alone may delete a message: every other caller is refused 403 NOT_AUTHOR. Only a message on " + "an issue is deleted; a message of a direct conversation, which names no issue, is refused " + "409 NOT_AN_ISSUE_MESSAGE. The message keeps its id and its place in its thread, and no read " + "of it gives any part of its body again: each read of it marks it deleted and names who " + "deleted it and when, and the events of a reply's creation and of each edit of the reply " + "written before the delete keep the preview of it they carried. " + "Its replies keep their own text, each send still waiting is failed, and search stops " + "matching it. A Dispatch of this release keeps the body: dispatch read --ref " + "dispatch://KEY/message/<id> " + "--history then marks the message deleted and lists no body. Correct a wording with " + "dispatch edit-message instead. A message of a closed issue is deleted too, and a second " + "delete is refused 409 POST_DELETED. A send its sender moves while the delete is being " + "written is 409 DELETE_CONTENDED, with nothing written: run the same command again.",
|
|
37463
|
+
arguments: (z) => ({
|
|
37464
|
+
message: z.string().describe(MESSAGE_ARGUMENT)
|
|
37465
|
+
}),
|
|
37466
|
+
strict: true
|
|
37467
|
+
},
|
|
37394
37468
|
{
|
|
37395
37469
|
name: "dispatch_send_to_agent",
|
|
37396
37470
|
example: {
|
|
@@ -37557,7 +37631,7 @@ var dispatchToolSpecs = [
|
|
|
37557
37631
|
{
|
|
37558
37632
|
name: "dispatch_read",
|
|
37559
37633
|
example: { issue: "DSP-1" },
|
|
37560
|
-
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), `DOC_NEWER_CONTENT` (this Dispatch " + "build cannot read an element of the document; try again in one minute), `DOCUMENT_UNLOADABLE` (the " + "document's stored history cannot load; a person decides whether to rebuild it) 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, negative_control and ci_check; 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,
|
|
37634
|
+
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), `DOC_NEWER_CONTENT` (this Dispatch " + "build cannot read an element of the document; try again in one minute), `DOCUMENT_UNLOADABLE` (the " + "document's stored history cannot load; a person decides whether to rebuild it) 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>`. " + "An edited post reads with the time of its edit, and a deleted one with who deleted it and when, in place of its body; " + "--history, with a ref naming that comment or message, lists the post's history newest first: each body an edit or the delete replaced, with the actor and the time, and of a deleted post each entry's actor and time with no body. " + "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, negative_control and ci_check; 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,
|
|
37561
37635
|
arguments: (z) => ({
|
|
37562
37636
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
37563
37637
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -37565,7 +37639,8 @@ var dispatchToolSpecs = [
|
|
|
37565
37639
|
ref: z.string().describe("Optional dispatch:// reference: dispatch://KEY, dispatch://KEY/spec, " + "dispatch://KEY/artifact/<slug>[@vN], dispatch://KEY/ask/<id>, dispatch://KEY/comment/<id>, " + "dispatch://KEY/message/<id>, dispatch://PROJECT/artifact/<slug>[@vN], and its " + "/ask/<id> and /comment/<id>; or the dashboard URL of one. A block: " + "dispatch://KEY/spec#b-<block id>[@vN], dispatch://KEY/artifact/<slug>#b-<block id>[@vN] or " + "dispatch://PROJECT/artifact/<slug>#b-<block id>[@vN], the id percent-encoded except ASCII " + "letters, digits and -.").optional(),
|
|
37566
37640
|
message: z.string().describe("A message id (uuid): reads the conversation it belongs to, the root message and every " + "reply. Name nothing else with it.").optional(),
|
|
37567
37641
|
events: z.number({ int: true, min: 1 }).describe(`How many of the issue's newest events an issue read or its dispatch://KEY/log lists, oldest first; default ${DEFAULT_ISSUE_READ_EVENTS}. Name no --all-events with it.`).optional(),
|
|
37568
|
-
all_events: z.boolean().describe(`List every one of the issue's events, oldest first, on an issue read or its dispatch://KEY/log, in place of the last ${DEFAULT_ISSUE_READ_EVENTS}. Name no --events with it.`).optional()
|
|
37642
|
+
all_events: z.boolean().describe(`List every one of the issue's events, oldest first, on an issue read or its dispatch://KEY/log, in place of the last ${DEFAULT_ISSUE_READ_EVENTS}. Name no --events with it.`).optional(),
|
|
37643
|
+
history: z.boolean().describe("With ref naming one comment or issue message, list that post's history in place " + "of the post itself, newest first: each body an edit or the delete replaced, with " + "the actor that replaced it and the time. A post nobody edited or deleted lists " + "nothing; a deleted post is marked deleted, and each of its entries gives its " + "actor and time and no body. Name it with ref alone.").optional()
|
|
37569
37644
|
}),
|
|
37570
37645
|
validation: readValidation
|
|
37571
37646
|
},
|
|
@@ -38103,6 +38178,8 @@ var commentFields = {
|
|
|
38103
38178
|
resolved_by: ActorSchema.nullable(),
|
|
38104
38179
|
resolved_at: string2().nullable(),
|
|
38105
38180
|
edited_at: string2().nullable(),
|
|
38181
|
+
deleted_at: string2().nullable(),
|
|
38182
|
+
deleted_by: ActorSchema.nullable(),
|
|
38106
38183
|
suggestion: SuggestionSchema.nullable(),
|
|
38107
38184
|
created_at: string2(),
|
|
38108
38185
|
mentions: array(WrittenCommentMentionSchema),
|
|
@@ -38114,6 +38191,10 @@ var commentEventPayloadFields = {
|
|
|
38114
38191
|
...commentFields,
|
|
38115
38192
|
mentions: array(WrittenCommentMentionSchema).optional(),
|
|
38116
38193
|
deliveries: array(WrittenCommentDeliverySchema).optional(),
|
|
38194
|
+
body: commentFields.body.optional(),
|
|
38195
|
+
suggestion: commentFields.suggestion.optional(),
|
|
38196
|
+
deleted_at: commentFields.deleted_at.optional(),
|
|
38197
|
+
deleted_by: commentFields.deleted_by.optional(),
|
|
38117
38198
|
artifact_name: string2(),
|
|
38118
38199
|
project_key: string2().optional(),
|
|
38119
38200
|
artifact_slug: string2().optional(),
|
|
@@ -38121,6 +38202,12 @@ var commentEventPayloadFields = {
|
|
|
38121
38202
|
ask_state: askFields.state.optional(),
|
|
38122
38203
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
38123
38204
|
ask_sessions: array(string2()).optional(),
|
|
38205
|
+
thread_root_id: string2().optional(),
|
|
38206
|
+
renamed_version: strictObject({
|
|
38207
|
+
artifact_id: string2(),
|
|
38208
|
+
number: number2().int().positive(),
|
|
38209
|
+
summary: string2()
|
|
38210
|
+
}).readonly().optional(),
|
|
38124
38211
|
...referenceChangesFields,
|
|
38125
38212
|
...threadLoginsFields,
|
|
38126
38213
|
...carriedBodyFields
|
|
@@ -38151,6 +38238,8 @@ var CommentEventPayloadSchema = object({
|
|
|
38151
38238
|
suggestion: object({ replace_with: suggestionFields.replace_with.optional() }).nullish(),
|
|
38152
38239
|
author: InboundActorSchema.optional(),
|
|
38153
38240
|
created_at: commentFields.created_at.optional(),
|
|
38241
|
+
deleted_at: commentFields.deleted_at.optional(),
|
|
38242
|
+
deleted_by: InboundActorSchema.nullish(),
|
|
38154
38243
|
mentions: array(CommentMentionSchema).optional(),
|
|
38155
38244
|
deliveries: array(CommentDeliverySchema).optional(),
|
|
38156
38245
|
reply_block: ReplyBlockSchema.nullish(),
|
|
@@ -38207,6 +38296,7 @@ var EVENT_TYPE_MEMBERS = {
|
|
|
38207
38296
|
"comment.anchor_refreshed": true,
|
|
38208
38297
|
"comment.answered": true,
|
|
38209
38298
|
"comment.created": true,
|
|
38299
|
+
"comment.deleted": true,
|
|
38210
38300
|
"comment.delivery": true,
|
|
38211
38301
|
"comment.edited": true,
|
|
38212
38302
|
"comment.reopened": true,
|
|
@@ -38223,7 +38313,9 @@ var EVENT_TYPE_MEMBERS = {
|
|
|
38223
38313
|
"message.accepted": true,
|
|
38224
38314
|
"message.answered": true,
|
|
38225
38315
|
"message.created": true,
|
|
38316
|
+
"message.deleted": true,
|
|
38226
38317
|
"message.delivery": true,
|
|
38318
|
+
"message.edited": true,
|
|
38227
38319
|
"priority.updated": true,
|
|
38228
38320
|
"project.created": true,
|
|
38229
38321
|
"project.updated": true,
|
|
@@ -38297,11 +38389,18 @@ var messageFields = {
|
|
|
38297
38389
|
broadcast_id: string2().nullable().optional(),
|
|
38298
38390
|
deliveries: array(MessageDeliverySchema),
|
|
38299
38391
|
created_at: string2(),
|
|
38392
|
+
edited_at: string2().nullable(),
|
|
38393
|
+
deleted_at: string2().nullable(),
|
|
38394
|
+
deleted_by: ActorSchema.nullable(),
|
|
38300
38395
|
reply_block: WrittenReplyBlockSchema.nullable().optional()
|
|
38301
38396
|
};
|
|
38302
38397
|
var MessageSchema = strictObject(messageFields).readonly();
|
|
38303
38398
|
var messageEventPayloadFields = {
|
|
38304
38399
|
...messageFields,
|
|
38400
|
+
body: messageFields.body.optional(),
|
|
38401
|
+
edited_at: messageFields.edited_at.optional(),
|
|
38402
|
+
deleted_at: messageFields.deleted_at.optional(),
|
|
38403
|
+
deleted_by: messageFields.deleted_by.optional(),
|
|
38305
38404
|
reply_body: string2().optional(),
|
|
38306
38405
|
thread_target: string2().optional(),
|
|
38307
38406
|
...referenceChangesFields,
|
|
@@ -38316,6 +38415,9 @@ var MessageEventPayloadSchema = object({
|
|
|
38316
38415
|
in_reply_to: messageFields.in_reply_to.optional(),
|
|
38317
38416
|
reply_body: messageEventPayloadFields.reply_body,
|
|
38318
38417
|
thread_target: messageEventPayloadFields.thread_target,
|
|
38418
|
+
edited_at: messageFields.edited_at.optional(),
|
|
38419
|
+
deleted_at: messageFields.deleted_at.optional(),
|
|
38420
|
+
deleted_by: InboundActorSchema.nullish(),
|
|
38319
38421
|
author: InboundActorSchema.optional(),
|
|
38320
38422
|
reply_block: ReplyBlockSchema.nullish(),
|
|
38321
38423
|
thread_logins: threadLoginsFields.thread_logins,
|
|
@@ -45387,13 +45489,23 @@ class DispatchWriteLandedError extends Error {
|
|
|
45387
45489
|
status;
|
|
45388
45490
|
name = "DispatchWriteLandedError";
|
|
45389
45491
|
constructor(code, status, method, shownUrl) {
|
|
45390
|
-
const lost = code === IDEMPOTENCY_ANSWER_NOT_KEPT ? "Dispatch
|
|
45492
|
+
const lost = code === IDEMPOTENCY_ANSWER_NOT_KEPT ? "Dispatch gives no copy of its answer, which was too large to keep or holds a comment " + "or a message that was deleted, or a document version name a delete replaced" : "its answer was lost on the way back";
|
|
45391
45493
|
const request = `${method} ${shownUrl}`;
|
|
45392
45494
|
super(`${request} was made, but ${lost} (${code}), so this command cannot print what it ` + "made: read it back with `dispatch read`, or with the matching list for something it created.");
|
|
45393
45495
|
this.code = code;
|
|
45394
45496
|
this.status = status;
|
|
45395
45497
|
}
|
|
45396
45498
|
}
|
|
45499
|
+
|
|
45500
|
+
class DispatchAnswerNotKeptError extends Error {
|
|
45501
|
+
status;
|
|
45502
|
+
name = "DispatchAnswerNotKeptError";
|
|
45503
|
+
code = IDEMPOTENCY_ANSWER_NOT_KEPT;
|
|
45504
|
+
constructor(status, method, shownUrl) {
|
|
45505
|
+
super(`${method} ${shownUrl} wrote nothing, and Dispatch kept no copy of its answer ` + `(${IDEMPOTENCY_ANSWER_NOT_KEPT}), so this command has no answer to print: run it again, ` + "which asks under a new key.");
|
|
45506
|
+
this.status = status;
|
|
45507
|
+
}
|
|
45508
|
+
}
|
|
45397
45509
|
function asErrorShape(value) {
|
|
45398
45510
|
return typeof value === "object" && value !== null ? value : {};
|
|
45399
45511
|
}
|
|
@@ -45703,8 +45815,8 @@ class DispatchClient {
|
|
|
45703
45815
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
|
|
45704
45816
|
}
|
|
45705
45817
|
async markdownRoundTrip(markdown) {
|
|
45706
|
-
const
|
|
45707
|
-
return
|
|
45818
|
+
const answer = await this.#writingNothing(["api", "v1", "markdown", "round-trip"], { markdown }, { writes: false });
|
|
45819
|
+
return answer.markdown;
|
|
45708
45820
|
}
|
|
45709
45821
|
async listProjectArtifacts(project, unlinked = false) {
|
|
45710
45822
|
return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
|
|
@@ -45737,7 +45849,7 @@ class DispatchClient {
|
|
|
45737
45849
|
return this.#json("GET", path, undefined, request);
|
|
45738
45850
|
}
|
|
45739
45851
|
async related(project, input) {
|
|
45740
|
-
return this.#
|
|
45852
|
+
return this.#writingNothing(["api", "v1", "projects", project, "related"], input);
|
|
45741
45853
|
}
|
|
45742
45854
|
async getIssue(issue) {
|
|
45743
45855
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue)]);
|
|
@@ -45911,10 +46023,7 @@ class DispatchClient {
|
|
|
45911
46023
|
async dryRunResult(issue, input) {
|
|
45912
46024
|
const path = ["api", "v1", "issues", await this.#resolveIssue(issue), "results", "dry-run"];
|
|
45913
46025
|
try {
|
|
45914
|
-
|
|
45915
|
-
writes: false
|
|
45916
|
-
});
|
|
45917
|
-
return payload;
|
|
46026
|
+
return await this.#writingNothing(path, input, { writes: false });
|
|
45918
46027
|
} catch (error) {
|
|
45919
46028
|
if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
|
|
45920
46029
|
throw error;
|
|
@@ -45987,7 +46096,19 @@ class DispatchClient {
|
|
|
45987
46096
|
]);
|
|
45988
46097
|
}
|
|
45989
46098
|
async getMessageThread(id, session) {
|
|
45990
|
-
return this.#json("GET", ["api", "v1", "messages", id], undefined, { session });
|
|
46099
|
+
return this.#json("GET", ["api", "v1", "messages", id], undefined, session === undefined ? undefined : { session });
|
|
46100
|
+
}
|
|
46101
|
+
async editMessage(id, input) {
|
|
46102
|
+
return this.#json("PATCH", ["api", "v1", "messages", id], input);
|
|
46103
|
+
}
|
|
46104
|
+
async deleteMessage(id, actor) {
|
|
46105
|
+
return this.#json("DELETE", ["api", "v1", "messages", id], { actor });
|
|
46106
|
+
}
|
|
46107
|
+
async messageHistory(id, session) {
|
|
46108
|
+
return this.#json("GET", ["api", "v1", "messages", id, "history"], undefined, session === undefined ? undefined : { session });
|
|
46109
|
+
}
|
|
46110
|
+
async issueMessages(issue) {
|
|
46111
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "messages"]);
|
|
45991
46112
|
}
|
|
45992
46113
|
async acceptMessageDelivery(id, attempt, input) {
|
|
45993
46114
|
return this.#json("POST", ["api", "v1", "messages", id, "deliveries", String(attempt), "accept"], input);
|
|
@@ -46061,6 +46182,15 @@ class DispatchClient {
|
|
|
46061
46182
|
async resolveComment(id, actor) {
|
|
46062
46183
|
return this.#json("POST", ["api", "v1", "comments", id, "resolve"], { actor });
|
|
46063
46184
|
}
|
|
46185
|
+
async editComment(id, input) {
|
|
46186
|
+
return this.#json("PATCH", ["api", "v1", "comments", id], input);
|
|
46187
|
+
}
|
|
46188
|
+
async deleteComment(id, actor) {
|
|
46189
|
+
return this.#json("DELETE", ["api", "v1", "comments", id], { actor });
|
|
46190
|
+
}
|
|
46191
|
+
async commentHistory(id) {
|
|
46192
|
+
return this.#json("GET", ["api", "v1", "comments", id, "history"]);
|
|
46193
|
+
}
|
|
46064
46194
|
async getComments(issue) {
|
|
46065
46195
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "comments"]);
|
|
46066
46196
|
}
|
|
@@ -46180,6 +46310,20 @@ class DispatchClient {
|
|
|
46180
46310
|
}
|
|
46181
46311
|
return this.#noRoute(async () => this.#response(method, url, await this.#send(method, url, body)));
|
|
46182
46312
|
}
|
|
46313
|
+
async#writingNothing(path, body, options = {}) {
|
|
46314
|
+
for (let keys = 1;; keys++) {
|
|
46315
|
+
try {
|
|
46316
|
+
return (await this.#jsonAnswer("POST", path, body, options)).payload;
|
|
46317
|
+
} catch (error) {
|
|
46318
|
+
if (!(error instanceof DispatchWriteLandedError) || error.code !== IDEMPOTENCY_ANSWER_NOT_KEPT) {
|
|
46319
|
+
throw error;
|
|
46320
|
+
}
|
|
46321
|
+
if (keys === 2) {
|
|
46322
|
+
throw new DispatchAnswerNotKeptError(error.status, "POST", requestForText(this.#baseUrl, this.#url(path), DISPATCH_URL_SETTING));
|
|
46323
|
+
}
|
|
46324
|
+
}
|
|
46325
|
+
}
|
|
46326
|
+
}
|
|
46183
46327
|
async#send(method, url, body, accept = "application/json", signal) {
|
|
46184
46328
|
const sent = await this.#sendOnce(method, url, body, accept, signal);
|
|
46185
46329
|
if (this.#credential.stale === undefined || !await tokenNotLive(sent.answer)) {
|
|
@@ -46568,6 +46712,10 @@ var ALWAYS_GATED = {
|
|
|
46568
46712
|
dispatch_message: true,
|
|
46569
46713
|
dispatch_edit_ask: true,
|
|
46570
46714
|
dispatch_comment: true,
|
|
46715
|
+
dispatch_edit_comment: true,
|
|
46716
|
+
dispatch_delete_comment: true,
|
|
46717
|
+
dispatch_edit_message: true,
|
|
46718
|
+
dispatch_delete_message: true,
|
|
46571
46719
|
dispatch_doc_edit: true,
|
|
46572
46720
|
dispatch_request_approval: true
|
|
46573
46721
|
};
|
|
@@ -49422,6 +49570,27 @@ function resolveDecodeOptions(options) {
|
|
|
49422
49570
|
};
|
|
49423
49571
|
}
|
|
49424
49572
|
|
|
49573
|
+
// ../envoy-client/src/actor-text.ts
|
|
49574
|
+
function actorText(actor) {
|
|
49575
|
+
if (actor.kind === "user") {
|
|
49576
|
+
return actorActText(`user ${actor.id}`, actor.act);
|
|
49577
|
+
}
|
|
49578
|
+
const service = actor.kind === "session" ? actor.service : undefined;
|
|
49579
|
+
if (service === undefined) {
|
|
49580
|
+
return `${actor.kind} ${actor.id}`;
|
|
49581
|
+
}
|
|
49582
|
+
return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
|
|
49583
|
+
}
|
|
49584
|
+
function deletedMark(at, by) {
|
|
49585
|
+
return `Deleted by ${by == null ? "its author" : actorText(by)} at ${at}`;
|
|
49586
|
+
}
|
|
49587
|
+
function editedMark(at) {
|
|
49588
|
+
return `edited ${at}`;
|
|
49589
|
+
}
|
|
49590
|
+
function withEditedMark(words, at) {
|
|
49591
|
+
return at == null ? words : `${words} \xB7 ${editedMark(at)}`;
|
|
49592
|
+
}
|
|
49593
|
+
|
|
49425
49594
|
// ../envoy-client/src/dispatch-pictures.ts
|
|
49426
49595
|
var PICTURE_UPLOAD_MAX_BYTES = 25 * 1024 * 1024;
|
|
49427
49596
|
var PICTURE_SHOWN_MAX_BYTES = 3750000;
|
|
@@ -49798,12 +49967,22 @@ function carriedBodyNote(event) {
|
|
|
49798
49967
|
}
|
|
49799
49968
|
async function wholeCarriedBody(client, item, session) {
|
|
49800
49969
|
try {
|
|
49970
|
+
let posts;
|
|
49801
49971
|
if (item.resource === "comment") {
|
|
49802
49972
|
const read = await client.getComment(item.id);
|
|
49803
|
-
|
|
49973
|
+
posts = [read.comment, ...read.replies ?? []];
|
|
49974
|
+
} else {
|
|
49975
|
+
if (item.issueKey === null && session === undefined)
|
|
49976
|
+
return;
|
|
49977
|
+
const read = item.issueKey === null ? await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
|
|
49978
|
+
posts = [read.message, ...read.replies ?? []];
|
|
49804
49979
|
}
|
|
49805
|
-
const
|
|
49806
|
-
|
|
49980
|
+
const post = posts.find((candidate) => candidate.id === item.id);
|
|
49981
|
+
if (post === undefined)
|
|
49982
|
+
return;
|
|
49983
|
+
if (post.deleted_at != null)
|
|
49984
|
+
return deletedMark(post.deleted_at, post.deleted_by);
|
|
49985
|
+
return withEditedMark(post.body, post.edited_at);
|
|
49807
49986
|
} catch {
|
|
49808
49987
|
return;
|
|
49809
49988
|
}
|
|
@@ -49843,11 +50022,14 @@ var DISPATCH_PAYLOAD_SCHEMAS = {
|
|
|
49843
50022
|
"comment.resolved": CommentEventPayloadSchema,
|
|
49844
50023
|
"comment.reopened": CommentEventPayloadSchema,
|
|
49845
50024
|
"comment.edited": CommentEventPayloadSchema,
|
|
50025
|
+
"comment.deleted": CommentEventPayloadSchema,
|
|
49846
50026
|
"suggestion.accepted": CommentEventPayloadSchema,
|
|
49847
50027
|
"suggestion.rejected": CommentEventPayloadSchema,
|
|
49848
50028
|
"message.created": MessageEventPayloadSchema,
|
|
49849
50029
|
"message.delivery": MessageDeliveryEventPayloadSchema,
|
|
49850
50030
|
"message.answered": MessageEventPayloadSchema,
|
|
50031
|
+
"message.edited": MessageEventPayloadSchema,
|
|
50032
|
+
"message.deleted": MessageEventPayloadSchema,
|
|
49851
50033
|
"child.status": ChildStatusEventPayloadSchema
|
|
49852
50034
|
};
|
|
49853
50035
|
function topicDocument(topic) {
|
|
@@ -50336,9 +50518,20 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
50336
50518
|
},
|
|
50337
50519
|
...unrecognised === undefined ? {} : { unrecognised }
|
|
50338
50520
|
};
|
|
50521
|
+
let card;
|
|
50522
|
+
let payloadShownAsText;
|
|
50523
|
+
try {
|
|
50524
|
+
card = encode5({ envoy: rendered });
|
|
50525
|
+
} catch (error) {
|
|
50526
|
+
const payloadKey = dispatchRendered ? "dispatch" : "message";
|
|
50527
|
+
if (envelope.payload === undefined || !(payloadKey in rendered))
|
|
50528
|
+
throw error;
|
|
50529
|
+
card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
|
|
50530
|
+
payloadShownAsText = messageFor(error);
|
|
50531
|
+
}
|
|
50339
50532
|
return {
|
|
50340
50533
|
skip: false,
|
|
50341
|
-
content: trailer === "" ?
|
|
50534
|
+
content: trailer === "" ? card : `${card}
|
|
50342
50535
|
|
|
50343
50536
|
${trailer}`,
|
|
50344
50537
|
envelope,
|
|
@@ -50347,7 +50540,8 @@ ${trailer}`,
|
|
|
50347
50540
|
...rejectedDelivery === undefined ? {} : { rejectedDelivery },
|
|
50348
50541
|
...malformedDelivery ? { malformedDelivery: true } : {},
|
|
50349
50542
|
...pictures.length === 0 ? {} : { pictures },
|
|
50350
|
-
...cutItem === undefined ? {} : { cutItem }
|
|
50543
|
+
...cutItem === undefined ? {} : { cutItem },
|
|
50544
|
+
...payloadShownAsText === undefined ? {} : { payloadShownAsText }
|
|
50351
50545
|
};
|
|
50352
50546
|
}
|
|
50353
50547
|
|
|
@@ -50402,8 +50596,9 @@ async function textWithPictures(text, pictures, owner, upload, actor) {
|
|
|
50402
50596
|
uploaded = await upload({ name: picture.name, file: picture.file, actor });
|
|
50403
50597
|
} catch (error) {
|
|
50404
50598
|
const earlier = addresses.length === 0 ? "" : `; the pictures before it are uploaded (${addresses.join(", ")})`;
|
|
50599
|
+
const landed = error instanceof DispatchWriteLandedError || error instanceof Error && error.cause instanceof DispatchWriteLandedError;
|
|
50405
50600
|
const refused = error instanceof DispatchGatewayError ? !error.mayHaveReachedDispatch : error instanceof DispatchServiceError && error.status < 500;
|
|
50406
|
-
const outcome = refused ? "was not uploaded" : "may or may not have been uploaded";
|
|
50601
|
+
const outcome = landed ? "was uploaded" : refused ? "was not uploaded" : "may or may not have been uploaded";
|
|
50407
50602
|
throw new Error(`images: ${picture.path} ${outcome}: ${messageFor(error).replace(/\.$/, "")}. Nothing ` + `was posted${earlier}.`);
|
|
50408
50603
|
}
|
|
50409
50604
|
const address = `dispatch://${owner}/artifact/${uploaded.artifact.slug}@v${uploaded.version.number}`;
|
|
@@ -50424,7 +50619,10 @@ function parseAgentArtifactRef(ref) {
|
|
|
50424
50619
|
return { session, slug, ...version === undefined ? {} : { version: Number(version) } };
|
|
50425
50620
|
}
|
|
50426
50621
|
function datedBodies(records) {
|
|
50427
|
-
return records.map((record) => ({
|
|
50622
|
+
return records.map((record) => ({
|
|
50623
|
+
text: record.body,
|
|
50624
|
+
at: record.edited_at ?? record.created_at
|
|
50625
|
+
}));
|
|
50428
50626
|
}
|
|
50429
50627
|
function askTexts({ ask, replies }) {
|
|
50430
50628
|
return [
|
|
@@ -50459,6 +50657,7 @@ function eventTexts(event) {
|
|
|
50459
50657
|
case "suggestion.rejected":
|
|
50460
50658
|
case "message.created":
|
|
50461
50659
|
case "message.answered":
|
|
50660
|
+
case "message.edited":
|
|
50462
50661
|
texts = [event.payload.body];
|
|
50463
50662
|
break;
|
|
50464
50663
|
default:
|
|
@@ -50934,7 +51133,7 @@ function normalizeUUID(value) {
|
|
|
50934
51133
|
return `${compact.slice(0, 8)}-${compact.slice(8, 12)}-${compact.slice(12, 16)}-${compact.slice(16, 20)}-${compact.slice(20)}`.toLowerCase();
|
|
50935
51134
|
}
|
|
50936
51135
|
var askIdProblem = "ask must be a bare ask id or a dispatch://.../ask/<id> reference";
|
|
50937
|
-
var commentIdProblem = "comment must be a bare comment id or a dispatch://.../comment/<id> reference";
|
|
51136
|
+
var commentIdProblem = "comment must be a bare comment id - a whole uuid, or a prefix of at least 8 hex characters - " + "or a dispatch://.../comment/<id> reference";
|
|
50938
51137
|
var messageIdProblem = "in_reply_to must be a full message id (uuid), a dispatch://KEY/message/<id> reference, or a block of one (dispatch://KEY/message/<id>#b-<block id>)";
|
|
50939
51138
|
function askId(args) {
|
|
50940
51139
|
const ask = stringArg(args, "ask");
|
|
@@ -50947,6 +51146,23 @@ function messageIdOf(value) {
|
|
|
50947
51146
|
})() : value;
|
|
50948
51147
|
return id === undefined ? undefined : normalizeUUID(id);
|
|
50949
51148
|
}
|
|
51149
|
+
var messageArgumentProblem = (argument) => `${argument} must be a full message id (uuid) or a dispatch://KEY/message/<id> reference`;
|
|
51150
|
+
function messageArgumentId(value) {
|
|
51151
|
+
if (!value.startsWith("dispatch://")) {
|
|
51152
|
+
const bare = normalizeUUID(value);
|
|
51153
|
+
return bare === undefined ? undefined : { id: bare };
|
|
51154
|
+
}
|
|
51155
|
+
const ref = parseDispatchRef(value);
|
|
51156
|
+
if (ref?.kind !== "message")
|
|
51157
|
+
return;
|
|
51158
|
+
const full = normalizeUUID(ref.id);
|
|
51159
|
+
const owner = ref.owner;
|
|
51160
|
+
if (owner.kind !== "issue")
|
|
51161
|
+
return full === undefined ? undefined : { id: full };
|
|
51162
|
+
if (full === undefined && !isIdPrefix(ref.id))
|
|
51163
|
+
return;
|
|
51164
|
+
return { id: full ?? ref.id, ref: { ...ref, owner } };
|
|
51165
|
+
}
|
|
50950
51166
|
function itemBlockOf(value) {
|
|
50951
51167
|
const ref = parseDispatchRef(value);
|
|
50952
51168
|
return ref?.item === undefined || ref.block === undefined ? undefined : { ...ref, item: ref.item, block: ref.block };
|
|
@@ -50996,7 +51212,7 @@ async function refuseItemOffRef(tool, kind, ref, refText, item, documentId) {
|
|
|
50996
51212
|
return;
|
|
50997
51213
|
}
|
|
50998
51214
|
}
|
|
50999
|
-
const where = item.issue_key === null ? "another document" : `${item.issue_key}; name it dispatch://${item.issue_key}/${kind}/${item.id}`;
|
|
51215
|
+
const where = item.issue_key === null ? kind === "message" ? "no issue: it is a message of a direct conversation" : "another document" : `${item.issue_key}; name it dispatch://${item.issue_key}/${kind}/${item.id}`;
|
|
51000
51216
|
throw new ToolInputError(tool, [
|
|
51001
51217
|
`${refText} names ${kind} ${item.id} on ${refOwnerName(ref)}, but it is on ${where}`
|
|
51002
51218
|
]);
|
|
@@ -51080,6 +51296,10 @@ var issueFreeTools = {
|
|
|
51080
51296
|
dispatch_edit_ask: true,
|
|
51081
51297
|
dispatch_resolve_ask: true,
|
|
51082
51298
|
dispatch_resolve_comment: true,
|
|
51299
|
+
dispatch_edit_comment: true,
|
|
51300
|
+
dispatch_delete_comment: true,
|
|
51301
|
+
dispatch_edit_message: true,
|
|
51302
|
+
dispatch_delete_message: true,
|
|
51083
51303
|
dispatch_follow: true,
|
|
51084
51304
|
dispatch_search: true,
|
|
51085
51305
|
dispatch_related: true,
|
|
@@ -51126,13 +51346,25 @@ function argumentProblems(tool, args) {
|
|
|
51126
51346
|
}
|
|
51127
51347
|
break;
|
|
51128
51348
|
}
|
|
51129
|
-
case "dispatch_resolve_comment":
|
|
51349
|
+
case "dispatch_resolve_comment":
|
|
51350
|
+
case "dispatch_edit_comment":
|
|
51351
|
+
case "dispatch_delete_comment": {
|
|
51130
51352
|
const comment = optionalString(args, "comment");
|
|
51131
|
-
if (comment
|
|
51353
|
+
if (comment !== undefined && !comment.startsWith("dispatch://") && normalizeUUID(comment) === undefined && !isIdPrefix(comment)) {
|
|
51354
|
+
problems.push(commentIdProblem);
|
|
51355
|
+
} else if (comment?.startsWith("dispatch://") && parseDispatchRef(comment)?.kind !== "comment") {
|
|
51132
51356
|
problems.push(itemRefProblem(comment) ?? commentIdProblem);
|
|
51133
51357
|
}
|
|
51134
51358
|
break;
|
|
51135
51359
|
}
|
|
51360
|
+
case "dispatch_edit_message":
|
|
51361
|
+
case "dispatch_delete_message": {
|
|
51362
|
+
const message = optionalString(args, "message");
|
|
51363
|
+
if (message !== undefined && messageArgumentId(message) === undefined) {
|
|
51364
|
+
problems.push(messageArgumentProblem("message"));
|
|
51365
|
+
}
|
|
51366
|
+
break;
|
|
51367
|
+
}
|
|
51136
51368
|
case "dispatch_comment": {
|
|
51137
51369
|
if (optionalString(args, "quote") !== undefined && optionalString(args, "artifact") === undefined) {
|
|
51138
51370
|
problems.push("artifact is required when quote is supplied");
|
|
@@ -51163,7 +51395,12 @@ function argumentProblems(tool, args) {
|
|
|
51163
51395
|
case "dispatch_read": {
|
|
51164
51396
|
const message = optionalString(args, "message");
|
|
51165
51397
|
if (message !== undefined && messageIdOf(message) === undefined) {
|
|
51166
|
-
problems.push("message
|
|
51398
|
+
problems.push(messageArgumentProblem("message"));
|
|
51399
|
+
}
|
|
51400
|
+
const historyRef = optionalBoolean(args, "history") === true ? optionalString(args, "ref") : undefined;
|
|
51401
|
+
const historyKind = historyRef === undefined ? undefined : parseDispatchRef(historyRef)?.kind;
|
|
51402
|
+
if (historyRef !== undefined && historyKind !== "comment" && historyKind !== "message") {
|
|
51403
|
+
problems.push("--history lists the bodies an edit of one comment or issue message replaced, so --ref must name one: dispatch://KEY/comment/<id> or dispatch://KEY/message/<id>");
|
|
51167
51404
|
}
|
|
51168
51405
|
const events = optionalNumber(args, "events");
|
|
51169
51406
|
const allEvents = optionalBoolean(args, "all_events") === true;
|
|
@@ -51445,6 +51682,21 @@ function refusalWithCode(error, ...clauses) {
|
|
|
51445
51682
|
function dispatchAnswered(error, status) {
|
|
51446
51683
|
return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
|
|
51447
51684
|
}
|
|
51685
|
+
var OLDER_COMMENT_EDIT_ACTOR = 'invalid JSON body: json: unknown field "actor"';
|
|
51686
|
+
async function throughPostCorrections(tool, url, call, post) {
|
|
51687
|
+
try {
|
|
51688
|
+
return await call;
|
|
51689
|
+
} catch (error) {
|
|
51690
|
+
const commentEditIsAge = tool === "dispatch_edit_comment" && (dispatchAnswered(error, 403) && error.code === "OAUTH_SCOPE_REQUIRED" || dispatchAnswered(error, 400) && error.code === "INVALID_JSON" && error.message === OLDER_COMMENT_EDIT_ACTOR);
|
|
51691
|
+
if (!(error instanceof DispatchNoRouteError) && !commentEditIsAge) {
|
|
51692
|
+
throw post === undefined ? error : refuseMissingPost(error, post);
|
|
51693
|
+
}
|
|
51694
|
+
throw new Error(`This Dispatch (${url}) predates post corrections: it has no route by which an agent edits ` + "or deletes a post or reads the bodies one replaced. Until it is deployed with this " + "release's server, a correction is one more post saying what changed.");
|
|
51695
|
+
}
|
|
51696
|
+
}
|
|
51697
|
+
function refuseMissingPost(error, post) {
|
|
51698
|
+
return dispatchNotFound(error) ? refusalWithCode(error, `this Dispatch holds no ${post.kind} ${post.id}`) : error;
|
|
51699
|
+
}
|
|
51448
51700
|
function writeMayHaveLanded(error) {
|
|
51449
51701
|
if (error instanceof DispatchGatewayError)
|
|
51450
51702
|
return error.mayHaveReachedDispatch;
|
|
@@ -51455,10 +51707,29 @@ function withAccount(error, account) {
|
|
|
51455
51707
|
const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
|
|
51456
51708
|
return new Error(told, { cause: error });
|
|
51457
51709
|
}
|
|
51710
|
+
function dispatchNotFound(error) {
|
|
51711
|
+
return !(error instanceof DispatchNoRouteError) && dispatchAnswered(error, 404) && error.code === "NOT_FOUND";
|
|
51712
|
+
}
|
|
51458
51713
|
|
|
51459
|
-
// ../envoy-client/src/dispatch-commands/document-targets.ts
|
|
51460
51714
|
class DocumentNotFoundError extends Error {
|
|
51461
51715
|
}
|
|
51716
|
+
async function refuseMissingOfRef(error, kind, id, owner, ownerName, readOwner) {
|
|
51717
|
+
if (!dispatchNotFound(error))
|
|
51718
|
+
return error;
|
|
51719
|
+
const missingOwner = await readOwner().then(() => {
|
|
51720
|
+
return;
|
|
51721
|
+
}, (caught) => {
|
|
51722
|
+
if (owner.kind === "issue" && dispatchNotFound(caught)) {
|
|
51723
|
+
return refusalWithCode(error, `this Dispatch holds no issue ${owner.issue}`);
|
|
51724
|
+
}
|
|
51725
|
+
if (caught instanceof DocumentNotFoundError)
|
|
51726
|
+
return caught;
|
|
51727
|
+
return refusalWithCode(error, `the read of ${ownerName} failed, so this does not say whether ${ownerName} exists or` + ` holds ${kind} ${id}: ${messageFor(caught)}`);
|
|
51728
|
+
});
|
|
51729
|
+
return missingOwner ?? refusalWithCode(error, `${ownerName} holds no ${kind} ${id}`);
|
|
51730
|
+
}
|
|
51731
|
+
|
|
51732
|
+
// ../envoy-client/src/dispatch-commands/document-targets.ts
|
|
51462
51733
|
function artifactByReference(artifacts, artifactReference, owner, canonical) {
|
|
51463
51734
|
const bySlug = artifacts.find((candidate) => candidate.slug === artifactReference);
|
|
51464
51735
|
if (canonical && bySlug !== undefined)
|
|
@@ -51654,6 +51925,9 @@ async function resolveExistingIssue(client, issueReference) {
|
|
|
51654
51925
|
throw error;
|
|
51655
51926
|
}
|
|
51656
51927
|
}
|
|
51928
|
+
function readRefOwner(client, owner, readDocument) {
|
|
51929
|
+
return async () => owner.kind === "issue" ? client.getIssue(owner.issue) : readDocument();
|
|
51930
|
+
}
|
|
51657
51931
|
|
|
51658
51932
|
// ../envoy-client/src/dispatch-commands/command-context.ts
|
|
51659
51933
|
function toolActor(origin, input) {
|
|
@@ -51712,32 +51986,21 @@ async function commandContext(session) {
|
|
|
51712
51986
|
};
|
|
51713
51987
|
}
|
|
51714
51988
|
|
|
51715
|
-
// ../envoy-client/src/actor-text.ts
|
|
51716
|
-
function actorText(actor) {
|
|
51717
|
-
if (actor.kind === "user") {
|
|
51718
|
-
return actorActText(`user ${actor.id}`, actor.act);
|
|
51719
|
-
}
|
|
51720
|
-
const service = actor.kind === "session" ? actor.service : undefined;
|
|
51721
|
-
if (service === undefined) {
|
|
51722
|
-
return `${actor.kind} ${actor.id}`;
|
|
51723
|
-
}
|
|
51724
|
-
return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
|
|
51725
|
-
}
|
|
51726
|
-
|
|
51727
51989
|
// ../envoy-client/src/search-answer.ts
|
|
51728
51990
|
function pageSummaryText(offset, count, total) {
|
|
51729
51991
|
return `showing ${offset + 1}-${offset + count} of ${total}`;
|
|
51730
51992
|
}
|
|
51731
51993
|
function searchHitLine(result, linkBase) {
|
|
51732
51994
|
const href = linkFor(result.href, linkBase);
|
|
51995
|
+
const text = result.deleted_at == null ? withEditedMark(snippetText(result.snippet), result.edited_at) : deletedMark(result.deleted_at, result.deleted_by);
|
|
51733
51996
|
const { owner } = result;
|
|
51734
51997
|
if (owner.kind === "document") {
|
|
51735
51998
|
const reference = dispatchDocumentRef(owner.project ?? "", owner.slug ?? "");
|
|
51736
|
-
return `${reference} [document] ${owner.name} - ${result.kind}: ${
|
|
51999
|
+
return `${reference} [document] ${owner.name} - ${result.kind}: ${text} -> ${href}`;
|
|
51737
52000
|
}
|
|
51738
52001
|
const artifactName = result.artifact ? ` ${result.artifact.name}` : "";
|
|
51739
52002
|
const label = `${owner.key} [${owner.status}] ${owner.title} - ${result.kind}${artifactName}`;
|
|
51740
|
-
return `${label}: ${
|
|
52003
|
+
return `${label}: ${text} -> ${href}`;
|
|
51741
52004
|
}
|
|
51742
52005
|
function indentedText(text) {
|
|
51743
52006
|
return text.split(/\r?\n/u).join(`
|
|
@@ -52108,7 +52371,8 @@ function isItemKind(kind) {
|
|
|
52108
52371
|
}
|
|
52109
52372
|
function edgeLine(edge) {
|
|
52110
52373
|
const { node } = edge;
|
|
52111
|
-
const
|
|
52374
|
+
const words = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
|
|
52375
|
+
const excerpt = node.deleted_at == null ? node.edited_at == null ? words : `${words}${editedMark(node.edited_at)} \xB7 ` : `${deletedMark(node.deleted_at, node.deleted_by)} \xB7 `;
|
|
52112
52376
|
const block = edge.block === undefined ? "" : ` (block ${edge.block.ref ?? edge.block.id})`;
|
|
52113
52377
|
const parent = node.parent ?? undefined;
|
|
52114
52378
|
const item = node.kind === "block" && node.document === undefined && isItemKind(parent?.kind) ? parent : undefined;
|
|
@@ -52178,7 +52442,7 @@ function blockLines(node, ref, typed, noun = "Block") {
|
|
|
52178
52442
|
...node.changed_version === undefined ? [] : [`Changed in version: ${node.changed_version}`],
|
|
52179
52443
|
...node.text === undefined ? [] : ["Text:", node.text]
|
|
52180
52444
|
] : [
|
|
52181
|
-
`${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}:`,
|
|
52445
|
+
`${withEditedMark(`${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}`, node.edited_at)}:`,
|
|
52182
52446
|
...node.text === undefined ? [] : [node.text]
|
|
52183
52447
|
];
|
|
52184
52448
|
const { pin } = node;
|
|
@@ -52341,7 +52605,9 @@ function olderServerWarnings(issue) {
|
|
|
52341
52605
|
}
|
|
52342
52606
|
var STRUCTURAL_EDGES_IN = ["child_of", "blocked_by"];
|
|
52343
52607
|
function referenceLinkLine({ kinds, node, via }, near) {
|
|
52344
|
-
|
|
52608
|
+
const address = node.ref ?? node.id;
|
|
52609
|
+
const target = node.deleted_at == null ? withEditedMark(address, node.edited_at) : `${address} \xB7 ${deletedMark(node.deleted_at, node.deleted_by)}`;
|
|
52610
|
+
return `- ${(kinds ?? []).join(",")} ${node.kind} ${target} \xB7 ${near} ${via.kind} ${via.id}`;
|
|
52345
52611
|
}
|
|
52346
52612
|
function memberLines(references) {
|
|
52347
52613
|
const members = references.members ?? [];
|
|
@@ -52429,6 +52695,13 @@ function logSummary(issue, events) {
|
|
|
52429
52695
|
].join(`
|
|
52430
52696
|
`);
|
|
52431
52697
|
}
|
|
52698
|
+
function postEventHead(payload) {
|
|
52699
|
+
if (payload.deleted_at != null)
|
|
52700
|
+
return deletedMark(payload.deleted_at, payload.deleted_by);
|
|
52701
|
+
if (payload.body === undefined)
|
|
52702
|
+
return;
|
|
52703
|
+
return withEditedMark(textHead(payload.body), payload.edited_at);
|
|
52704
|
+
}
|
|
52432
52705
|
function eventHead(event) {
|
|
52433
52706
|
switch (event.type) {
|
|
52434
52707
|
case "ask.opened":
|
|
@@ -52449,11 +52722,14 @@ function eventHead(event) {
|
|
|
52449
52722
|
case "comment.edited":
|
|
52450
52723
|
case "comment.resolved":
|
|
52451
52724
|
case "comment.reopened":
|
|
52725
|
+
case "comment.deleted":
|
|
52452
52726
|
case "suggestion.accepted":
|
|
52453
52727
|
case "suggestion.rejected":
|
|
52454
52728
|
case "message.created":
|
|
52455
52729
|
case "message.answered":
|
|
52456
|
-
|
|
52730
|
+
case "message.edited":
|
|
52731
|
+
case "message.deleted":
|
|
52732
|
+
return postEventHead(event.payload);
|
|
52457
52733
|
case "artifact.version":
|
|
52458
52734
|
return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
|
|
52459
52735
|
case "artifact.approved":
|
|
@@ -53276,7 +53552,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
|
|
|
53276
53552
|
const partRef = (id) => `${askRef}#b-${encodeBlockId(id)}`;
|
|
53277
53553
|
const chain = (replies ?? []).flatMap((reply) => [
|
|
53278
53554
|
`${reply.id} \xB7 ${actorText(reply.author)}`,
|
|
53279
|
-
|
|
53555
|
+
...postBodyLines(reply)
|
|
53280
53556
|
]);
|
|
53281
53557
|
const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
|
|
53282
53558
|
return [
|
|
@@ -53384,19 +53660,42 @@ function formatOpenAsksSummary(response, linkBase) {
|
|
|
53384
53660
|
].join(`
|
|
53385
53661
|
`);
|
|
53386
53662
|
}
|
|
53663
|
+
function postBodyLines(post) {
|
|
53664
|
+
if (post.deleted_at != null)
|
|
53665
|
+
return [deletedMark(post.deleted_at, post.deleted_by)];
|
|
53666
|
+
return [...post.edited_at == null ? [] : [`Edited: ${post.edited_at}`], `Body: ${post.body}`];
|
|
53667
|
+
}
|
|
53668
|
+
function postHistorySummary(kind, ref, id, read) {
|
|
53669
|
+
const entries = read.entries ?? [];
|
|
53670
|
+
const deleted = read.deleted_at != null;
|
|
53671
|
+
const oldest = entries.at(-1);
|
|
53672
|
+
const route = `/api/v1/${kind === "Comment" ? "comments" : "messages"}/${id}/history`;
|
|
53673
|
+
return [
|
|
53674
|
+
`${kind} history: ${ref}`,
|
|
53675
|
+
...read.deleted_at == null ? [] : [deletedMark(read.deleted_at, read.deleted_by)],
|
|
53676
|
+
...entries.length === 0 ? ["- none"] : entries.flatMap((entry) => [
|
|
53677
|
+
`${entry.edited_at} \xB7 ${actorText(entry.edited_by)}`,
|
|
53678
|
+
...deleted ? [] : [`Body: ${entry.body}`]
|
|
53679
|
+
]),
|
|
53680
|
+
...entries.length < POST_HISTORY_PAGE_LIMIT || oldest === undefined ? [] : [
|
|
53681
|
+
`This is the newest page, and a page holds ${POST_HISTORY_PAGE_LIMIT} rows: GET ${route}?before=${oldest.edited_at} reads any older rows.`
|
|
53682
|
+
]
|
|
53683
|
+
].join(`
|
|
53684
|
+
`);
|
|
53685
|
+
}
|
|
53387
53686
|
function commentSummary({ comment, replies }, graph) {
|
|
53388
53687
|
const root = [
|
|
53389
53688
|
`${comment.id} \xB7 ${actorText(comment.author)}`,
|
|
53390
53689
|
...anchorLines(comment),
|
|
53391
53690
|
...replyBlockLines(comment),
|
|
53392
|
-
|
|
53691
|
+
...postBodyLines(comment)
|
|
53393
53692
|
];
|
|
53394
53693
|
const chain = (replies ?? []).flatMap((reply) => [
|
|
53395
53694
|
`${reply.id} \xB7 ${actorText(reply.author)}`,
|
|
53396
53695
|
...anchorLines(reply),
|
|
53397
53696
|
...replyBlockLines(reply),
|
|
53398
53697
|
...reply.answers != null && reply.answers !== comment.id ? [`Answers: ${reply.answers}`] : [],
|
|
53399
|
-
|
|
53698
|
+
...postBodyLines(reply)
|
|
53400
53699
|
]);
|
|
53401
53700
|
return [
|
|
53402
53701
|
"Comment:",
|
|
@@ -53411,8 +53710,13 @@ function replyBlockLines(record) {
|
|
|
53411
53710
|
const block = record.reply_block;
|
|
53412
53711
|
if (block === undefined || block === null)
|
|
53413
53712
|
return [];
|
|
53713
|
+
if (block.deleted_at != null) {
|
|
53714
|
+
return [
|
|
53715
|
+
`Re: block ${block.block_id} (parent deleted): ${deletedMark(block.deleted_at, block.deleted_by)}`
|
|
53716
|
+
];
|
|
53717
|
+
}
|
|
53414
53718
|
return [
|
|
53415
|
-
block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}
|
|
53719
|
+
withEditedMark(block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}`, block.edited_at)
|
|
53416
53720
|
];
|
|
53417
53721
|
}
|
|
53418
53722
|
function anchorLines(record) {
|
|
@@ -53441,12 +53745,12 @@ function messageSummary({ message, replies }, graph) {
|
|
|
53441
53745
|
const root = [
|
|
53442
53746
|
`${message.id} \xB7 ${actorText(message.author)}`,
|
|
53443
53747
|
...replyBlockLines(message),
|
|
53444
|
-
|
|
53748
|
+
...postBodyLines(message)
|
|
53445
53749
|
];
|
|
53446
53750
|
const chain = (replies ?? []).flatMap((reply) => [
|
|
53447
53751
|
`${reply.id} \xB7 ${actorText(reply.author)}`,
|
|
53448
53752
|
...replyBlockLines(reply),
|
|
53449
|
-
|
|
53753
|
+
...postBodyLines(reply)
|
|
53450
53754
|
]);
|
|
53451
53755
|
return [
|
|
53452
53756
|
"Message:",
|
|
@@ -53490,7 +53794,7 @@ async function openAnchoredThreads(client, resolved) {
|
|
|
53490
53794
|
const commentThreads = roots.map((root) => [
|
|
53491
53795
|
`comment ${root.id} \xB7 ${actorText(root.author)} \xB7 ${root.created_at}`,
|
|
53492
53796
|
...anchorLines(root),
|
|
53493
|
-
|
|
53797
|
+
...postBodyLines(root),
|
|
53494
53798
|
...threadReplyLines(replies.get(root.id) ?? [])
|
|
53495
53799
|
].join(`
|
|
53496
53800
|
`));
|
|
@@ -53499,7 +53803,7 @@ async function openAnchoredThreads(client, resolved) {
|
|
|
53499
53803
|
function threadReplyLines(replies) {
|
|
53500
53804
|
return replies.flatMap((reply) => [
|
|
53501
53805
|
`reply ${reply.id} \xB7 ${actorText(reply.author)} \xB7 ${reply.created_at}`,
|
|
53502
|
-
|
|
53806
|
+
...postBodyLines(reply)
|
|
53503
53807
|
]);
|
|
53504
53808
|
}
|
|
53505
53809
|
function threadRootId(comment, byId) {
|
|
@@ -53777,28 +54081,116 @@ async function followCommand(context) {
|
|
|
53777
54081
|
}
|
|
53778
54082
|
|
|
53779
54083
|
// ../envoy-client/src/dispatch-commands/conversation.ts
|
|
53780
|
-
async function
|
|
53781
|
-
const { args, client, actor, input } = context;
|
|
53782
|
-
const reference = stringArg(args, "comment");
|
|
54084
|
+
async function resolveCommentArgument(tool, reference, client) {
|
|
53783
54085
|
const ref = reference.startsWith("dispatch://") ? parseDispatchRef(reference) : null;
|
|
54086
|
+
if (ref === null)
|
|
54087
|
+
return { id: reference };
|
|
53784
54088
|
let id = reference;
|
|
53785
54089
|
let document;
|
|
53786
|
-
if (ref
|
|
54090
|
+
if (ref.owner.kind === "issue") {
|
|
53787
54091
|
const issueKey = ref.owner.issue;
|
|
53788
|
-
id = await resolveIdPrefix(
|
|
53789
|
-
} else
|
|
54092
|
+
id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
|
|
54093
|
+
} else {
|
|
53790
54094
|
const artifact = (await resolveArtifact(client, ref.owner, ref.artifact, { canonical: true })).artifact;
|
|
53791
54095
|
document = artifact;
|
|
53792
|
-
id = await resolveIdPrefix(
|
|
54096
|
+
id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getArtifactComments(artifact.id));
|
|
53793
54097
|
}
|
|
53794
|
-
|
|
53795
|
-
|
|
53796
|
-
|
|
53797
|
-
|
|
53798
|
-
|
|
54098
|
+
const read = await client.getComment(id).catch(async (error) => {
|
|
54099
|
+
throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, async () => document));
|
|
54100
|
+
});
|
|
54101
|
+
await refuseItemOffRef(tool, "comment", ref, reference, read.comment, async () => document === undefined ? "" : document.id);
|
|
54102
|
+
return { id, ...document === undefined ? {} : { document } };
|
|
54103
|
+
}
|
|
54104
|
+
async function resolveMessageArgument(tool, argument, reference, client, session) {
|
|
54105
|
+
const named = messageArgumentId(reference);
|
|
54106
|
+
if (named === undefined)
|
|
54107
|
+
throw new ToolInputError(tool, [messageArgumentProblem(argument)]);
|
|
54108
|
+
const ref = named.ref;
|
|
54109
|
+
if (ref === undefined)
|
|
54110
|
+
return named.id;
|
|
54111
|
+
const issueKey = ref.owner.issue;
|
|
54112
|
+
const id = await resolveIdPrefix(tool, "message", named.id, issueKey, async () => (await client.issueMessages(issueKey)).flatMap((thread) => [
|
|
54113
|
+
thread.message,
|
|
54114
|
+
...thread.replies ?? []
|
|
54115
|
+
]));
|
|
54116
|
+
const read = await client.getMessageThread(id, session === "" ? undefined : session).catch(async (error) => {
|
|
54117
|
+
throw await refuseMissingOfRef(error, "message", id, ref.owner, issueKey, () => client.getIssue(issueKey));
|
|
54118
|
+
});
|
|
54119
|
+
await refuseItemOffRef(tool, "message", ref, reference, { id, issue_key: read.message.issue_key }, async () => "");
|
|
54120
|
+
return id;
|
|
54121
|
+
}
|
|
54122
|
+
function messageIssueKey(message) {
|
|
54123
|
+
if (message.issue_key === null)
|
|
54124
|
+
throw new Error("the corrected message names no issue");
|
|
54125
|
+
return message.issue_key;
|
|
54126
|
+
}
|
|
54127
|
+
async function resolveCommentCommand(context) {
|
|
54128
|
+
const { args, client, actor, input } = context;
|
|
54129
|
+
const reference = stringArg(args, "comment");
|
|
54130
|
+
const { id, document } = await resolveCommentArgument(input.tool, reference, client);
|
|
54131
|
+
const comment = await client.resolveComment(id, actor).catch((error) => {
|
|
54132
|
+
throw refuseMissingPost(error, { kind: "comment", id });
|
|
54133
|
+
});
|
|
53799
54134
|
const { label, details } = await commentOwnerResult(client, comment, document);
|
|
53800
54135
|
return { text: `Resolved comment ${comment.id} on ${label}.`, details };
|
|
53801
54136
|
}
|
|
54137
|
+
async function editCommentCommand(context) {
|
|
54138
|
+
const { args, client, actor, input, configUrl } = context;
|
|
54139
|
+
const reference = stringArg(args, "comment");
|
|
54140
|
+
const { id, document } = await resolveCommentArgument(input.tool, reference, client);
|
|
54141
|
+
const comment = await throughPostCorrections(input.tool, configUrl, client.editComment(id, { body: stringArg(args, "body"), actor }), { kind: "comment", id });
|
|
54142
|
+
const { label, details } = await commentOwnerResult(client, comment, document);
|
|
54143
|
+
return { text: `Edited comment ${comment.id} on ${label}.`, details };
|
|
54144
|
+
}
|
|
54145
|
+
var DELETED_MESSAGE_READS = "No read of it gives its body again; the events of a reply's creation and of each edit of the " + "reply written before the delete keep the preview of it they carried.";
|
|
54146
|
+
var DELETED_COMMENT_READS = "No read of it gives its body again; the events of a reply's creation and of each edit of the " + "reply written before the delete keep the preview of it they carried, and the document's " + "events written before the delete keep the name an accepted suggestion gave its version.";
|
|
54147
|
+
async function throughDelete(context, call, post) {
|
|
54148
|
+
try {
|
|
54149
|
+
return await throughPostCorrections(context.input.tool, context.configUrl, call, post);
|
|
54150
|
+
} catch (error) {
|
|
54151
|
+
if (dispatchAnswered(error, 409) && error.code === "DELETE_CONTENDED") {
|
|
54152
|
+
throw refusalWithCode(error, `${post.kind} ${post.id} stands: run the same dispatch delete-${post.kind} command again`);
|
|
54153
|
+
}
|
|
54154
|
+
throw error;
|
|
54155
|
+
}
|
|
54156
|
+
}
|
|
54157
|
+
async function deleteCommentCommand(context) {
|
|
54158
|
+
const { args, client, actor, input } = context;
|
|
54159
|
+
const reference = stringArg(args, "comment");
|
|
54160
|
+
const { id, document } = await resolveCommentArgument(input.tool, reference, client);
|
|
54161
|
+
const comment = await throughDelete(context, client.deleteComment(id, actor), {
|
|
54162
|
+
kind: "comment",
|
|
54163
|
+
id
|
|
54164
|
+
});
|
|
54165
|
+
const { label, details } = await commentOwnerResult(client, comment, document);
|
|
54166
|
+
return {
|
|
54167
|
+
text: `Deleted comment ${comment.id} on ${label}. ${DELETED_COMMENT_READS}`,
|
|
54168
|
+
details
|
|
54169
|
+
};
|
|
54170
|
+
}
|
|
54171
|
+
async function editMessageCommand(context) {
|
|
54172
|
+
const { args, client, actor, input, configUrl, hostSession } = context;
|
|
54173
|
+
const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
|
|
54174
|
+
const message = await throughPostCorrections(input.tool, configUrl, client.editMessage(id, { body: stringArg(args, "body"), actor }), { kind: "message", id });
|
|
54175
|
+
const issue = messageIssueKey(message);
|
|
54176
|
+
return {
|
|
54177
|
+
text: `Edited message ${message.id} on ${issue}.`,
|
|
54178
|
+
details: { issue, message: message.id }
|
|
54179
|
+
};
|
|
54180
|
+
}
|
|
54181
|
+
async function deleteMessageCommand(context) {
|
|
54182
|
+
const { args, client, actor, input, hostSession } = context;
|
|
54183
|
+
const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
|
|
54184
|
+
const message = await throughDelete(context, client.deleteMessage(id, actor), {
|
|
54185
|
+
kind: "message",
|
|
54186
|
+
id
|
|
54187
|
+
});
|
|
54188
|
+
const issue = messageIssueKey(message);
|
|
54189
|
+
return {
|
|
54190
|
+
text: `Deleted message ${message.id} on ${issue}. ${DELETED_MESSAGE_READS}`,
|
|
54191
|
+
details: { issue, message: message.id }
|
|
54192
|
+
};
|
|
54193
|
+
}
|
|
53802
54194
|
async function commentCommand(context) {
|
|
53803
54195
|
const { args, client, actor, input, documentOwner, resolveDocument, writePictures, issue } = context;
|
|
53804
54196
|
const artifactReference = optionalString(args, "artifact");
|
|
@@ -54388,6 +54780,9 @@ function artifactNameExistsProblem(held, owner) {
|
|
|
54388
54780
|
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
|
|
54389
54781
|
}
|
|
54390
54782
|
function storedTextCheckFailed(error, name) {
|
|
54783
|
+
if (error instanceof DispatchAnswerNotKeptError) {
|
|
54784
|
+
return `Dispatch could not say how it would store this text, so nothing was uploaded: POST /api/v1/markdown/round-trip wrote nothing, and Dispatch kept no copy of its answer (${error.code}). Send the upload again, which asks it under a new key.`;
|
|
54785
|
+
}
|
|
54391
54786
|
const failure = `Dispatch could not say how it would store this text, so nothing was uploaded: POST /api/v1/markdown/round-trip failed with ${messageFor(error)}.`;
|
|
54392
54787
|
if (!dispatchAnswered(error, 413)) {
|
|
54393
54788
|
return `${failure} Send the upload again once that call is answered.`;
|
|
@@ -55097,9 +55492,12 @@ async function readCommand(context) {
|
|
|
55097
55492
|
shown,
|
|
55098
55493
|
documentOwner,
|
|
55099
55494
|
resolveDocument,
|
|
55100
|
-
issue
|
|
55495
|
+
issue,
|
|
55496
|
+
configUrl,
|
|
55497
|
+
hostSession
|
|
55101
55498
|
} = context;
|
|
55102
55499
|
const message = optionalString(args, "message");
|
|
55500
|
+
const history = optionalBoolean(args, "history") === true;
|
|
55103
55501
|
const picturesOf = (texts) => readPictures(client, picturesNewestFirst(texts), shown);
|
|
55104
55502
|
const showImages = (pictures) => {
|
|
55105
55503
|
for (const address of pictures.shown)
|
|
@@ -55130,9 +55528,21 @@ async function readCommand(context) {
|
|
|
55130
55528
|
refDocumentId ??= resolveDocument(ref.owner, ref.artifact).then((resolved) => resolved.artifact.id);
|
|
55131
55529
|
return refDocumentId;
|
|
55132
55530
|
};
|
|
55531
|
+
const deletedPostClause = async (ref) => {
|
|
55532
|
+
const item = ref.item;
|
|
55533
|
+
if (item === undefined || item.kind !== "comment" && item.kind !== "message") {
|
|
55534
|
+
return "";
|
|
55535
|
+
}
|
|
55536
|
+
const deleted = await (item.kind === "comment" ? client.getComment(item.id).then((read) => read.comment.deleted_at) : ref.owner.kind === "issue" ? client.getMessage(ref.owner.issue, item.id).then((read) => read.message.deleted_at) : Promise.resolve(undefined)).catch(() => {
|
|
55537
|
+
return;
|
|
55538
|
+
});
|
|
55539
|
+
return deleted == null ? "" : ` This ${item.kind} is deleted.`;
|
|
55540
|
+
};
|
|
55133
55541
|
if (ownerArguments.ref?.kind === "ask") {
|
|
55134
55542
|
const ref = ownerArguments.ref;
|
|
55135
|
-
const askRead = await readAskRef(input.tool, ref.id, refOwnerName(ref), client, async () => ref.owner.kind === "issue" ? client.listIssueAsks(ref.owner.issue) : client.getArtifactAsks(await documentIdOf(ref), "all"))
|
|
55543
|
+
const askRead = await readAskRef(input.tool, ref.id, refOwnerName(ref), client, async () => ref.owner.kind === "issue" ? client.listIssueAsks(ref.owner.issue) : client.getArtifactAsks(await documentIdOf(ref), "all")).catch(async (error) => {
|
|
55544
|
+
throw await refuseMissingOfRef(error, "ask", ref.id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
|
|
55545
|
+
});
|
|
55136
55546
|
await refuseItemOffRef(input.tool, "ask", ref, stringArg(args, "ref"), askRead.ask, () => documentIdOf(ref));
|
|
55137
55547
|
const askRef = refTarget(ref, "ask", askRead.ask.id);
|
|
55138
55548
|
const [pictures, incoming, outgoing] = await Promise.all([
|
|
@@ -55149,8 +55559,16 @@ async function readCommand(context) {
|
|
|
55149
55559
|
if (ownerArguments.ref?.kind === "comment") {
|
|
55150
55560
|
const ref = ownerArguments.ref;
|
|
55151
55561
|
const id = await resolveIdPrefix(input.tool, "comment", ref.id, refOwnerName(ref), async () => ref.owner.kind === "issue" ? client.getComments(ref.owner.issue) : client.getArtifactComments(await documentIdOf(ref)));
|
|
55152
|
-
const comment = await client.getComment(id)
|
|
55562
|
+
const comment = await client.getComment(id).catch(async (error) => {
|
|
55563
|
+
throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
|
|
55564
|
+
});
|
|
55153
55565
|
await refuseItemOffRef(input.tool, "comment", ref, stringArg(args, "ref"), comment.comment, () => documentIdOf(ref));
|
|
55566
|
+
if (history) {
|
|
55567
|
+
return {
|
|
55568
|
+
text: postHistorySummary("Comment", refTarget(ref, "comment", id), id, await throughPostCorrections(input.tool, configUrl, client.commentHistory(id))),
|
|
55569
|
+
details: ref.owner.kind === "project" ? { project: ref.owner.project, comment: id } : { issue: comment.comment.issue_key, comment: id }
|
|
55570
|
+
};
|
|
55571
|
+
}
|
|
55154
55572
|
const commentRef = refTarget(ref, "comment", id);
|
|
55155
55573
|
const [pictures, graph] = await Promise.all([
|
|
55156
55574
|
picturesOf(datedBodies([comment.comment, ...comment.replies ?? []])),
|
|
@@ -55166,7 +55584,18 @@ async function readCommand(context) {
|
|
|
55166
55584
|
if (ownerArguments.ref.owner.kind !== "issue") {
|
|
55167
55585
|
throw new Error("message references are issue-scoped");
|
|
55168
55586
|
}
|
|
55169
|
-
const
|
|
55587
|
+
const messageIssue = ownerArguments.ref.owner.issue;
|
|
55588
|
+
if (history) {
|
|
55589
|
+
const id = await resolveMessageArgument(input.tool, "ref", stringArg(args, "ref"), client, hostSession);
|
|
55590
|
+
return {
|
|
55591
|
+
text: postHistorySummary("Message", dispatchChildRef(dispatchIssueRef(messageIssue), "message", id), id, await throughPostCorrections(input.tool, configUrl, client.messageHistory(id, hostSession === "" ? undefined : hostSession))),
|
|
55592
|
+
details: { issue: messageIssue, message: id }
|
|
55593
|
+
};
|
|
55594
|
+
}
|
|
55595
|
+
const named = ownerArguments.ref;
|
|
55596
|
+
const messageRead = await client.getMessage(messageIssue, named.id).catch(async (error) => {
|
|
55597
|
+
throw await refuseMissingOfRef(error, "message", named.id, { kind: "issue", issue: messageIssue }, messageIssue, () => client.getIssue(messageIssue));
|
|
55598
|
+
});
|
|
55170
55599
|
const messageRef = dispatchChildRef(dispatchIssueRef(ownerArguments.ref.owner.issue), "message", ownerArguments.ref.id);
|
|
55171
55600
|
const [pictures, graph] = await Promise.all([
|
|
55172
55601
|
picturesOf(datedBodies([messageRead.message, ...messageRead.replies ?? []])),
|
|
@@ -55186,9 +55615,9 @@ async function readCommand(context) {
|
|
|
55186
55615
|
return;
|
|
55187
55616
|
}) : undefined;
|
|
55188
55617
|
const [incoming, outgoing, partOf, typed] = await Promise.all([
|
|
55189
|
-
client.getReferences({ to: blockRef }).catch((error) => {
|
|
55618
|
+
client.getReferences({ to: blockRef }).catch(async (error) => {
|
|
55190
55619
|
if (ref.pin === undefined && dispatchAnswered(error, 404)) {
|
|
55191
|
-
throw new Error(`No block ${ref.block} in ${holder}
|
|
55620
|
+
throw new Error(`No block ${ref.block} in ${holder}.${await deletedPostClause(ref)}`);
|
|
55192
55621
|
}
|
|
55193
55622
|
throw error;
|
|
55194
55623
|
}),
|
|
@@ -55360,7 +55789,9 @@ function renderSessionAnswerItem(item) {
|
|
|
55360
55789
|
const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
|
|
55361
55790
|
const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
|
|
55362
55791
|
if (item.edited_at !== undefined)
|
|
55363
|
-
head.push(
|
|
55792
|
+
head.push(editedMark(item.edited_at));
|
|
55793
|
+
if (item.deleted_at !== undefined)
|
|
55794
|
+
head.push(deletedMark(item.deleted_at, item.deleted_by));
|
|
55364
55795
|
const owner = item.owner === null ? undefined : ownerTitle(item.owner);
|
|
55365
55796
|
const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
|
|
55366
55797
|
const lines = [head.join(" \xB7 "), where];
|
|
@@ -55396,6 +55827,7 @@ function sessionAnswersWords(items) {
|
|
|
55396
55827
|
actorActText(item.author.id, item.author.act),
|
|
55397
55828
|
item.at,
|
|
55398
55829
|
item.edited_at ?? null,
|
|
55830
|
+
item.deleted_at ?? null,
|
|
55399
55831
|
item.selected ?? null,
|
|
55400
55832
|
item.text,
|
|
55401
55833
|
item.relation
|
|
@@ -55748,7 +56180,10 @@ function inboxThreadLine(row, now) {
|
|
|
55748
56180
|
return [
|
|
55749
56181
|
`- ${inboxThreadLabel(row)}`,
|
|
55750
56182
|
row.kind,
|
|
55751
|
-
|
|
56183
|
+
...row.deleted_at == null ? [
|
|
56184
|
+
textHead(row.subject, INBOX_QUESTION_HEAD),
|
|
56185
|
+
...row.edited_at == null ? [] : [editedMark(row.edited_at)]
|
|
56186
|
+
] : [deletedMark(row.deleted_at, row.deleted_by)],
|
|
55752
56187
|
actorText(row.reply.author),
|
|
55753
56188
|
inboxReplyAge(row.reply.created_at, now),
|
|
55754
56189
|
row.ref
|
|
@@ -55894,6 +56329,10 @@ var dispatchCommands = {
|
|
|
55894
56329
|
dispatch_comment: acting(commentCommand),
|
|
55895
56330
|
dispatch_suggest: acting(suggestCommand),
|
|
55896
56331
|
dispatch_resolve_comment: acting(resolveCommentCommand),
|
|
56332
|
+
dispatch_edit_comment: acting(editCommentCommand),
|
|
56333
|
+
dispatch_delete_comment: acting(deleteCommentCommand),
|
|
56334
|
+
dispatch_edit_message: acting(editMessageCommand),
|
|
56335
|
+
dispatch_delete_message: acting(deleteMessageCommand),
|
|
55897
56336
|
dispatch_message: acting(messageCommand),
|
|
55898
56337
|
dispatch_send_to_agent: acting(sendToAgentCommand),
|
|
55899
56338
|
dispatch_doc_edit: acting(docEditCommand),
|
|
@@ -62276,7 +62715,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
|
|
|
62276
62715
|
|
|
62277
62716
|
// package.json
|
|
62278
62717
|
var name2 = "@sjawhar/claude-envoy";
|
|
62279
|
-
var version2 = "5.
|
|
62718
|
+
var version2 = "5.19.0";
|
|
62280
62719
|
var legion = {
|
|
62281
62720
|
daemonApiVersion: 228
|
|
62282
62721
|
};
|
|
@@ -67400,7 +67839,7 @@ async function acceptUserTurn(options) {
|
|
|
67400
67839
|
}
|
|
67401
67840
|
return { delivery, turn };
|
|
67402
67841
|
} catch (error) {
|
|
67403
|
-
options.warn({ delivery, error, reason: "failed" });
|
|
67842
|
+
options.warn(error instanceof DispatchWriteLandedError ? { delivery, error, reason: "landed" } : { delivery, error, reason: "failed" });
|
|
67404
67843
|
return;
|
|
67405
67844
|
}
|
|
67406
67845
|
}
|
|
@@ -67451,6 +67890,43 @@ function modelPicked(model) {
|
|
|
67451
67890
|
function thinkingPicked(effort) {
|
|
67452
67891
|
return `The session's thinking level is now ${effort}.`;
|
|
67453
67892
|
}
|
|
67893
|
+
function acceptLanded(messageId, error) {
|
|
67894
|
+
return `Dispatch recorded this session's accept of message ${messageId} and gave no copy of its answer (${error.message}), so no turn follows; it arrives as a card`;
|
|
67895
|
+
}
|
|
67896
|
+
function mayHaveBeenPosted(error) {
|
|
67897
|
+
return error instanceof DispatchWriteUnsettledError || error instanceof DispatchServiceError && error.status >= 500;
|
|
67898
|
+
}
|
|
67899
|
+
function replyWarning(messageId, error) {
|
|
67900
|
+
if (error instanceof DispatchWriteLandedError) {
|
|
67901
|
+
return `a reply to message ${messageId} landed on Dispatch, which gave no copy of its answer \u2014 ${error.message}`;
|
|
67902
|
+
}
|
|
67903
|
+
if (mayHaveBeenPosted(error)) {
|
|
67904
|
+
return `a reply to message ${messageId} may or may not have been posted \u2014 ${messageFor(error)}`;
|
|
67905
|
+
}
|
|
67906
|
+
return `a reply to message ${messageId} was not posted \u2014 ${messageFor(error)}`;
|
|
67907
|
+
}
|
|
67908
|
+
function btwAnswerWarning(messageId, error) {
|
|
67909
|
+
if (error instanceof DispatchWriteLandedError) {
|
|
67910
|
+
return `a BTW answer to message ${messageId} landed on Dispatch, which gave no copy of its answer \u2014 ${error.message}`;
|
|
67911
|
+
}
|
|
67912
|
+
if (mayHaveBeenPosted(error)) {
|
|
67913
|
+
return `a BTW answer to message ${messageId} may or may not have been posted \u2014 ${messageFor(error)}`;
|
|
67914
|
+
}
|
|
67915
|
+
return `a BTW answer to message ${messageId} was not posted \u2014 ${messageFor(error)}`;
|
|
67916
|
+
}
|
|
67917
|
+
function answerBtw(delivery, ask, reply, warn) {
|
|
67918
|
+
(async () => {
|
|
67919
|
+
try {
|
|
67920
|
+
await reply(delivery, { body: await ask(delivery.body) });
|
|
67921
|
+
} catch (error) {
|
|
67922
|
+
if (error instanceof DispatchWriteLandedError)
|
|
67923
|
+
throw error;
|
|
67924
|
+
await reply(delivery, { error: messageFor(error) });
|
|
67925
|
+
}
|
|
67926
|
+
})().catch((error) => {
|
|
67927
|
+
warn(btwAnswerWarning(delivery.id, error));
|
|
67928
|
+
});
|
|
67929
|
+
}
|
|
67454
67930
|
function rowText(content) {
|
|
67455
67931
|
const pieces = [];
|
|
67456
67932
|
for (const block of content) {
|
|
@@ -67509,6 +67985,10 @@ function createUserTurnRouter(options) {
|
|
|
67509
67985
|
warn(`Dispatch accepted message ${delivery.id} without the stored body to inject; it arrives as a card`);
|
|
67510
67986
|
return;
|
|
67511
67987
|
}
|
|
67988
|
+
if (refusal.reason === "landed") {
|
|
67989
|
+
warn(acceptLanded(delivery.id, refusal.error));
|
|
67990
|
+
return;
|
|
67991
|
+
}
|
|
67512
67992
|
warn(`Dispatch did not accept message ${delivery.id} as this session's turn (${messageFor(refusal.error)}); it arrives as a card`);
|
|
67513
67993
|
}
|
|
67514
67994
|
});
|
|
@@ -67550,7 +68030,7 @@ function createUserTurnRouter(options) {
|
|
|
67550
68030
|
if (body === undefined)
|
|
67551
68031
|
return;
|
|
67552
68032
|
await post(delivery, { body }).catch((error) => {
|
|
67553
|
-
warn(
|
|
68033
|
+
warn(replyWarning(delivery.id, error));
|
|
67554
68034
|
});
|
|
67555
68035
|
};
|
|
67556
68036
|
const pickModel = async (value) => {
|
|
@@ -67604,19 +68084,11 @@ function createUserTurnRouter(options) {
|
|
|
67604
68084
|
await answer(delivery, said);
|
|
67605
68085
|
};
|
|
67606
68086
|
const runBtw = (delivery) => {
|
|
67607
|
-
(async () => {
|
|
67608
|
-
if (!session.connected())
|
|
67609
|
-
|
|
67610
|
-
|
|
67611
|
-
|
|
67612
|
-
try {
|
|
67613
|
-
await reply(delivery, { body: await session.fork(delivery.body) });
|
|
67614
|
-
} catch (error) {
|
|
67615
|
-
await reply(delivery, { error: messageFor(error) });
|
|
67616
|
-
}
|
|
67617
|
-
})().catch((error) => {
|
|
67618
|
-
warn(`a BTW answer did not reach Dispatch \u2014 ${messageFor(error)}`);
|
|
67619
|
-
});
|
|
68087
|
+
answerBtw(delivery, async (question) => {
|
|
68088
|
+
if (!session.connected())
|
|
68089
|
+
throw new Error("this session has no link to Claude Code");
|
|
68090
|
+
return session.fork(question);
|
|
68091
|
+
}, reply, warn);
|
|
67620
68092
|
};
|
|
67621
68093
|
return {
|
|
67622
68094
|
async route(rendered) {
|
|
@@ -67832,7 +68304,8 @@ function createChannelDelivery(input) {
|
|
|
67832
68304
|
return postDispatchReply(input.identity, input.configFile, rejected, {
|
|
67833
68305
|
error: "Invalid Dispatch targeted delivery frame"
|
|
67834
68306
|
}).then(() => false, (error) => {
|
|
67835
|
-
process.stderr.write(`envoy-channel:
|
|
68307
|
+
process.stderr.write(error instanceof DispatchWriteLandedError ? `envoy-channel: the report of the rejected delivery landed on Dispatch, which gave no copy of its answer \u2014 ${error.message}
|
|
68308
|
+
` : `envoy-channel: could not report the rejected delivery to Dispatch \u2014 ${messageFor(error)}
|
|
67836
68309
|
`);
|
|
67837
68310
|
return false;
|
|
67838
68311
|
});
|
|
@@ -67844,6 +68317,10 @@ function createChannelDelivery(input) {
|
|
|
67844
68317
|
}
|
|
67845
68318
|
if (late === true && passOverLateBtw(rendered))
|
|
67846
68319
|
return tail.then(() => false);
|
|
68320
|
+
if (rendered.payloadShownAsText !== undefined) {
|
|
68321
|
+
process.stderr.write(`envoy-channel: message ${rendered.envelope?.event_id ?? "unknown"}'s payload is shown as its text; the card could not lay it out (${rendered.payloadShownAsText})
|
|
68322
|
+
`);
|
|
68323
|
+
}
|
|
67847
68324
|
return queued(async () => {
|
|
67848
68325
|
const routed = await input.router?.()?.route(rendered);
|
|
67849
68326
|
if (routed === true) {
|
|
@@ -70581,15 +71058,7 @@ var CODEX_COMMAND_REFUSAL = "a Codex session runs only the commands typed at its
|
|
|
70581
71058
|
function createCodexUserTurnRouter(options) {
|
|
70582
71059
|
const { state, warn } = options;
|
|
70583
71060
|
const runBtw = (delivery) => {
|
|
70584
|
-
(
|
|
70585
|
-
try {
|
|
70586
|
-
await options.reply(delivery, { body: await options.ask(delivery.body) });
|
|
70587
|
-
} catch (error) {
|
|
70588
|
-
await options.reply(delivery, { error: messageFor(error) });
|
|
70589
|
-
}
|
|
70590
|
-
})().catch((error) => {
|
|
70591
|
-
warn(`a BTW answer did not reach Dispatch \u2014 ${messageFor(error)}`);
|
|
70592
|
-
});
|
|
71061
|
+
answerBtw(delivery, options.ask, options.reply, warn);
|
|
70593
71062
|
};
|
|
70594
71063
|
return {
|
|
70595
71064
|
async route(rendered) {
|
|
@@ -70605,6 +71074,10 @@ function createCodexUserTurnRouter(options) {
|
|
|
70605
71074
|
handled: state.handled,
|
|
70606
71075
|
rendered,
|
|
70607
71076
|
warn: (refusal) => {
|
|
71077
|
+
if (refusal.reason === "landed") {
|
|
71078
|
+
warn(acceptLanded(refusal.delivery.id, refusal.error));
|
|
71079
|
+
return;
|
|
71080
|
+
}
|
|
70608
71081
|
warn(`Dispatch message ${refusal.delivery.id} arrives as a card (${refusal.reason === "failed" ? messageFor(refusal.error) : refusal.reason})`);
|
|
70609
71082
|
}
|
|
70610
71083
|
});
|
|
@@ -70615,7 +71088,7 @@ function createCodexUserTurnRouter(options) {
|
|
|
70615
71088
|
const said = typedInputReply(turn.body, { error: CODEX_COMMAND_REFUSAL });
|
|
70616
71089
|
if (said !== undefined) {
|
|
70617
71090
|
options.reply(delivery, { body: said }).catch((error) => {
|
|
70618
|
-
warn(
|
|
71091
|
+
warn(replyWarning(delivery.id, error));
|
|
70619
71092
|
});
|
|
70620
71093
|
}
|
|
70621
71094
|
return true;
|