@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/dispatch.js
CHANGED
|
@@ -1278,6 +1278,10 @@ var ALWAYS_GATED = {
|
|
|
1278
1278
|
dispatch_message: true,
|
|
1279
1279
|
dispatch_edit_ask: true,
|
|
1280
1280
|
dispatch_comment: true,
|
|
1281
|
+
dispatch_edit_comment: true,
|
|
1282
|
+
dispatch_delete_comment: true,
|
|
1283
|
+
dispatch_edit_message: true,
|
|
1284
|
+
dispatch_delete_message: true,
|
|
1281
1285
|
dispatch_doc_edit: true,
|
|
1282
1286
|
dispatch_request_approval: true
|
|
1283
1287
|
};
|
|
@@ -14437,6 +14441,7 @@ var PROJECT_NAME_MAX = 80;
|
|
|
14437
14441
|
var MAX_ISSUE_PAGE_LIMIT = 250;
|
|
14438
14442
|
var DEFAULT_ISSUE_PAGE_LIMIT = 50;
|
|
14439
14443
|
var DEFAULT_ISSUE_READ_EVENTS = 10;
|
|
14444
|
+
var POST_HISTORY_PAGE_LIMIT = 200;
|
|
14440
14445
|
var ASK_TURNS = ["human", "agent"];
|
|
14441
14446
|
var DELIVERY_CAPABILITIES = ["aside", "btw", "steer"];
|
|
14442
14447
|
var DELIVERY_ATTEMPT_STATES = ["pending", "sent", "queued", "failed"];
|
|
@@ -14494,10 +14499,29 @@ var replyBlockFields = {
|
|
|
14494
14499
|
ref: string2().optional(),
|
|
14495
14500
|
block_id: string2(),
|
|
14496
14501
|
text: string2(),
|
|
14497
|
-
removed: boolean2()
|
|
14502
|
+
removed: boolean2(),
|
|
14503
|
+
edited_at: string2().optional(),
|
|
14504
|
+
deleted_at: string2().optional()
|
|
14498
14505
|
};
|
|
14499
|
-
var
|
|
14500
|
-
|
|
14506
|
+
var DocumentActorSchema = object({
|
|
14507
|
+
kind: string2(),
|
|
14508
|
+
id: string2(),
|
|
14509
|
+
act: object({
|
|
14510
|
+
session: string2().optional(),
|
|
14511
|
+
token_id: string2().optional(),
|
|
14512
|
+
token_name: string2().optional(),
|
|
14513
|
+
scopes: array(string2()).optional()
|
|
14514
|
+
}).optional(),
|
|
14515
|
+
origin: ActorOriginSchema.optional(),
|
|
14516
|
+
owner: string2().optional(),
|
|
14517
|
+
service: string2().optional(),
|
|
14518
|
+
project: string2().optional()
|
|
14519
|
+
});
|
|
14520
|
+
var WrittenReplyBlockSchema = strictObject({ ...replyBlockFields, deleted_by: ActorSchema.optional() }).readonly();
|
|
14521
|
+
var ReplyBlockSchema = object({
|
|
14522
|
+
...replyBlockFields,
|
|
14523
|
+
deleted_by: DocumentActorSchema.optional()
|
|
14524
|
+
});
|
|
14501
14525
|
|
|
14502
14526
|
// ../contracts/src/dispatch-api-documents.ts
|
|
14503
14527
|
var versionFields = {
|
|
@@ -14822,18 +14846,26 @@ var messageValidation = {
|
|
|
14822
14846
|
var readOwner = documentOwnerValidation(false);
|
|
14823
14847
|
var READ_OWNER_RULE = "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one.";
|
|
14824
14848
|
var READ_MESSAGE_RULE = "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.";
|
|
14849
|
+
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.";
|
|
14825
14850
|
function readProblem(value) {
|
|
14826
14851
|
const input = value;
|
|
14852
|
+
const historyKept = input.history !== true || typeof input.ref === "string";
|
|
14827
14853
|
if (typeof input.message !== "string") {
|
|
14828
|
-
return
|
|
14854
|
+
return brokenParts([
|
|
14855
|
+
[readOwner.check(value), READ_OWNER_RULE],
|
|
14856
|
+
[historyKept, READ_HISTORY_RULE]
|
|
14857
|
+
]);
|
|
14829
14858
|
}
|
|
14830
14859
|
const alone = input.issue === undefined && input.project === undefined && input.artifact === undefined && input.ref === undefined;
|
|
14831
|
-
return
|
|
14860
|
+
return brokenParts([
|
|
14861
|
+
[alone, READ_MESSAGE_RULE],
|
|
14862
|
+
[historyKept, READ_HISTORY_RULE]
|
|
14863
|
+
]);
|
|
14832
14864
|
}
|
|
14833
14865
|
var readValidation = {
|
|
14834
14866
|
check: (value) => readProblem(value) === undefined,
|
|
14835
|
-
message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`,
|
|
14836
|
-
refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`
|
|
14867
|
+
message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`,
|
|
14868
|
+
refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`
|
|
14837
14869
|
};
|
|
14838
14870
|
var ISSUE_COMPONENTS_MODES = ["inherit", "explicit", "none"];
|
|
14839
14871
|
function componentsArgument(z) {
|
|
@@ -14853,6 +14885,8 @@ var ASK_URGENCIES = ["low", "med", "high", "blocking"];
|
|
|
14853
14885
|
var DISPATCH_BLOCK_UNITS = 32000;
|
|
14854
14886
|
var DISPATCH_ITEM_BLOCKS = 32768;
|
|
14855
14887
|
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`.";
|
|
14888
|
+
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.";
|
|
14889
|
+
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.";
|
|
14856
14890
|
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.";
|
|
14857
14891
|
var DISPATCH_HANDOFF_BODY_MAX = 262144;
|
|
14858
14892
|
var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
@@ -15124,7 +15158,7 @@ var dispatchToolSpecs = [
|
|
|
15124
15158
|
example: { comment: "01234567-0000-4000-8000-000000000001" },
|
|
15125
15159
|
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.",
|
|
15126
15160
|
arguments: (z) => ({
|
|
15127
|
-
comment: z.string().describe(
|
|
15161
|
+
comment: z.string().describe(COMMENT_ARGUMENT)
|
|
15128
15162
|
}),
|
|
15129
15163
|
strict: true
|
|
15130
15164
|
},
|
|
@@ -15179,6 +15213,28 @@ var dispatchToolSpecs = [
|
|
|
15179
15213
|
}),
|
|
15180
15214
|
validation: documentOwnerValidation(true, true)
|
|
15181
15215
|
},
|
|
15216
|
+
{
|
|
15217
|
+
name: "dispatch_edit_comment",
|
|
15218
|
+
example: {
|
|
15219
|
+
comment: "01234567-0000-4000-8000-000000000001",
|
|
15220
|
+
body: "Corrected: the retry window is 72 hours, not 24."
|
|
15221
|
+
},
|
|
15222
|
+
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}`,
|
|
15223
|
+
arguments: (z) => ({
|
|
15224
|
+
comment: z.string().describe(COMMENT_ARGUMENT),
|
|
15225
|
+
body: z.string().describe(`The comment's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
|
|
15226
|
+
}),
|
|
15227
|
+
strict: true
|
|
15228
|
+
},
|
|
15229
|
+
{
|
|
15230
|
+
name: "dispatch_delete_comment",
|
|
15231
|
+
example: { comment: "01234567-0000-4000-8000-000000000001" },
|
|
15232
|
+
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.",
|
|
15233
|
+
arguments: (z) => ({
|
|
15234
|
+
comment: z.string().describe(COMMENT_ARGUMENT)
|
|
15235
|
+
}),
|
|
15236
|
+
strict: true
|
|
15237
|
+
},
|
|
15182
15238
|
{
|
|
15183
15239
|
name: "dispatch_message",
|
|
15184
15240
|
example: { issue: "DSP-1", body: "Implementation started." },
|
|
@@ -15191,6 +15247,28 @@ var dispatchToolSpecs = [
|
|
|
15191
15247
|
}),
|
|
15192
15248
|
validation: messageValidation
|
|
15193
15249
|
},
|
|
15250
|
+
{
|
|
15251
|
+
name: "dispatch_edit_message",
|
|
15252
|
+
example: {
|
|
15253
|
+
message: "01234567-0000-4000-8000-000000000001",
|
|
15254
|
+
body: "Corrected: the export runs at 02:00 UTC, not 02:00 local."
|
|
15255
|
+
},
|
|
15256
|
+
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}`,
|
|
15257
|
+
arguments: (z) => ({
|
|
15258
|
+
message: z.string().describe(MESSAGE_ARGUMENT),
|
|
15259
|
+
body: z.string().describe(`The message's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
|
|
15260
|
+
}),
|
|
15261
|
+
strict: true
|
|
15262
|
+
},
|
|
15263
|
+
{
|
|
15264
|
+
name: "dispatch_delete_message",
|
|
15265
|
+
example: { message: "01234567-0000-4000-8000-000000000001" },
|
|
15266
|
+
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.",
|
|
15267
|
+
arguments: (z) => ({
|
|
15268
|
+
message: z.string().describe(MESSAGE_ARGUMENT)
|
|
15269
|
+
}),
|
|
15270
|
+
strict: true
|
|
15271
|
+
},
|
|
15194
15272
|
{
|
|
15195
15273
|
name: "dispatch_send_to_agent",
|
|
15196
15274
|
example: {
|
|
@@ -15357,7 +15435,7 @@ var dispatchToolSpecs = [
|
|
|
15357
15435
|
{
|
|
15358
15436
|
name: "dispatch_read",
|
|
15359
15437
|
example: { issue: "DSP-1" },
|
|
15360
|
-
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,
|
|
15438
|
+
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,
|
|
15361
15439
|
arguments: (z) => ({
|
|
15362
15440
|
issue: z.string().describe(ISSUE_REFERENCE).optional(),
|
|
15363
15441
|
project: z.string().describe("Project key owning the document.").optional(),
|
|
@@ -15365,7 +15443,8 @@ var dispatchToolSpecs = [
|
|
|
15365
15443
|
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(),
|
|
15366
15444
|
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(),
|
|
15367
15445
|
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(),
|
|
15368
|
-
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()
|
|
15446
|
+
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(),
|
|
15447
|
+
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()
|
|
15369
15448
|
}),
|
|
15370
15449
|
validation: readValidation
|
|
15371
15450
|
},
|
|
@@ -15903,6 +15982,8 @@ var commentFields = {
|
|
|
15903
15982
|
resolved_by: ActorSchema.nullable(),
|
|
15904
15983
|
resolved_at: string2().nullable(),
|
|
15905
15984
|
edited_at: string2().nullable(),
|
|
15985
|
+
deleted_at: string2().nullable(),
|
|
15986
|
+
deleted_by: ActorSchema.nullable(),
|
|
15906
15987
|
suggestion: SuggestionSchema.nullable(),
|
|
15907
15988
|
created_at: string2(),
|
|
15908
15989
|
mentions: array(WrittenCommentMentionSchema),
|
|
@@ -15914,6 +15995,10 @@ var commentEventPayloadFields = {
|
|
|
15914
15995
|
...commentFields,
|
|
15915
15996
|
mentions: array(WrittenCommentMentionSchema).optional(),
|
|
15916
15997
|
deliveries: array(WrittenCommentDeliverySchema).optional(),
|
|
15998
|
+
body: commentFields.body.optional(),
|
|
15999
|
+
suggestion: commentFields.suggestion.optional(),
|
|
16000
|
+
deleted_at: commentFields.deleted_at.optional(),
|
|
16001
|
+
deleted_by: commentFields.deleted_by.optional(),
|
|
15917
16002
|
artifact_name: string2(),
|
|
15918
16003
|
project_key: string2().optional(),
|
|
15919
16004
|
artifact_slug: string2().optional(),
|
|
@@ -15921,6 +16006,12 @@ var commentEventPayloadFields = {
|
|
|
15921
16006
|
ask_state: askFields.state.optional(),
|
|
15922
16007
|
ask_waiting_on: _enum2(ASK_TURNS).optional(),
|
|
15923
16008
|
ask_sessions: array(string2()).optional(),
|
|
16009
|
+
thread_root_id: string2().optional(),
|
|
16010
|
+
renamed_version: strictObject({
|
|
16011
|
+
artifact_id: string2(),
|
|
16012
|
+
number: number2().int().positive(),
|
|
16013
|
+
summary: string2()
|
|
16014
|
+
}).readonly().optional(),
|
|
15924
16015
|
...referenceChangesFields,
|
|
15925
16016
|
...threadLoginsFields,
|
|
15926
16017
|
...carriedBodyFields
|
|
@@ -15951,6 +16042,8 @@ var CommentEventPayloadSchema = object({
|
|
|
15951
16042
|
suggestion: object({ replace_with: suggestionFields.replace_with.optional() }).nullish(),
|
|
15952
16043
|
author: InboundActorSchema.optional(),
|
|
15953
16044
|
created_at: commentFields.created_at.optional(),
|
|
16045
|
+
deleted_at: commentFields.deleted_at.optional(),
|
|
16046
|
+
deleted_by: InboundActorSchema.nullish(),
|
|
15954
16047
|
mentions: array(CommentMentionSchema).optional(),
|
|
15955
16048
|
deliveries: array(CommentDeliverySchema).optional(),
|
|
15956
16049
|
reply_block: ReplyBlockSchema.nullish(),
|
|
@@ -16007,6 +16100,7 @@ var EVENT_TYPE_MEMBERS = {
|
|
|
16007
16100
|
"comment.anchor_refreshed": true,
|
|
16008
16101
|
"comment.answered": true,
|
|
16009
16102
|
"comment.created": true,
|
|
16103
|
+
"comment.deleted": true,
|
|
16010
16104
|
"comment.delivery": true,
|
|
16011
16105
|
"comment.edited": true,
|
|
16012
16106
|
"comment.reopened": true,
|
|
@@ -16023,7 +16117,9 @@ var EVENT_TYPE_MEMBERS = {
|
|
|
16023
16117
|
"message.accepted": true,
|
|
16024
16118
|
"message.answered": true,
|
|
16025
16119
|
"message.created": true,
|
|
16120
|
+
"message.deleted": true,
|
|
16026
16121
|
"message.delivery": true,
|
|
16122
|
+
"message.edited": true,
|
|
16027
16123
|
"priority.updated": true,
|
|
16028
16124
|
"project.created": true,
|
|
16029
16125
|
"project.updated": true,
|
|
@@ -16097,11 +16193,18 @@ var messageFields = {
|
|
|
16097
16193
|
broadcast_id: string2().nullable().optional(),
|
|
16098
16194
|
deliveries: array(MessageDeliverySchema),
|
|
16099
16195
|
created_at: string2(),
|
|
16196
|
+
edited_at: string2().nullable(),
|
|
16197
|
+
deleted_at: string2().nullable(),
|
|
16198
|
+
deleted_by: ActorSchema.nullable(),
|
|
16100
16199
|
reply_block: WrittenReplyBlockSchema.nullable().optional()
|
|
16101
16200
|
};
|
|
16102
16201
|
var MessageSchema = strictObject(messageFields).readonly();
|
|
16103
16202
|
var messageEventPayloadFields = {
|
|
16104
16203
|
...messageFields,
|
|
16204
|
+
body: messageFields.body.optional(),
|
|
16205
|
+
edited_at: messageFields.edited_at.optional(),
|
|
16206
|
+
deleted_at: messageFields.deleted_at.optional(),
|
|
16207
|
+
deleted_by: messageFields.deleted_by.optional(),
|
|
16105
16208
|
reply_body: string2().optional(),
|
|
16106
16209
|
thread_target: string2().optional(),
|
|
16107
16210
|
...referenceChangesFields,
|
|
@@ -16116,6 +16219,9 @@ var MessageEventPayloadSchema = object({
|
|
|
16116
16219
|
in_reply_to: messageFields.in_reply_to.optional(),
|
|
16117
16220
|
reply_body: messageEventPayloadFields.reply_body,
|
|
16118
16221
|
thread_target: messageEventPayloadFields.thread_target,
|
|
16222
|
+
edited_at: messageFields.edited_at.optional(),
|
|
16223
|
+
deleted_at: messageFields.deleted_at.optional(),
|
|
16224
|
+
deleted_by: InboundActorSchema.nullish(),
|
|
16119
16225
|
author: InboundActorSchema.optional(),
|
|
16120
16226
|
reply_block: ReplyBlockSchema.nullish(),
|
|
16121
16227
|
thread_logins: threadLoginsFields.thread_logins,
|
|
@@ -20174,13 +20280,23 @@ class DispatchWriteLandedError extends Error {
|
|
|
20174
20280
|
status;
|
|
20175
20281
|
name = "DispatchWriteLandedError";
|
|
20176
20282
|
constructor(code, status, method, shownUrl) {
|
|
20177
|
-
const lost = code === IDEMPOTENCY_ANSWER_NOT_KEPT ? "Dispatch
|
|
20283
|
+
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";
|
|
20178
20284
|
const request = `${method} ${shownUrl}`;
|
|
20179
20285
|
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.");
|
|
20180
20286
|
this.code = code;
|
|
20181
20287
|
this.status = status;
|
|
20182
20288
|
}
|
|
20183
20289
|
}
|
|
20290
|
+
|
|
20291
|
+
class DispatchAnswerNotKeptError extends Error {
|
|
20292
|
+
status;
|
|
20293
|
+
name = "DispatchAnswerNotKeptError";
|
|
20294
|
+
code = IDEMPOTENCY_ANSWER_NOT_KEPT;
|
|
20295
|
+
constructor(status, method, shownUrl) {
|
|
20296
|
+
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.");
|
|
20297
|
+
this.status = status;
|
|
20298
|
+
}
|
|
20299
|
+
}
|
|
20184
20300
|
function asErrorShape(value) {
|
|
20185
20301
|
return typeof value === "object" && value !== null ? value : {};
|
|
20186
20302
|
}
|
|
@@ -20490,8 +20606,8 @@ class DispatchClient {
|
|
|
20490
20606
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
|
|
20491
20607
|
}
|
|
20492
20608
|
async markdownRoundTrip(markdown) {
|
|
20493
|
-
const
|
|
20494
|
-
return
|
|
20609
|
+
const answer = await this.#writingNothing(["api", "v1", "markdown", "round-trip"], { markdown }, { writes: false });
|
|
20610
|
+
return answer.markdown;
|
|
20495
20611
|
}
|
|
20496
20612
|
async listProjectArtifacts(project, unlinked = false) {
|
|
20497
20613
|
return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
|
|
@@ -20524,7 +20640,7 @@ class DispatchClient {
|
|
|
20524
20640
|
return this.#json("GET", path, undefined, request);
|
|
20525
20641
|
}
|
|
20526
20642
|
async related(project, input) {
|
|
20527
|
-
return this.#
|
|
20643
|
+
return this.#writingNothing(["api", "v1", "projects", project, "related"], input);
|
|
20528
20644
|
}
|
|
20529
20645
|
async getIssue(issue) {
|
|
20530
20646
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue)]);
|
|
@@ -20698,10 +20814,7 @@ class DispatchClient {
|
|
|
20698
20814
|
async dryRunResult(issue, input) {
|
|
20699
20815
|
const path = ["api", "v1", "issues", await this.#resolveIssue(issue), "results", "dry-run"];
|
|
20700
20816
|
try {
|
|
20701
|
-
|
|
20702
|
-
writes: false
|
|
20703
|
-
});
|
|
20704
|
-
return payload;
|
|
20817
|
+
return await this.#writingNothing(path, input, { writes: false });
|
|
20705
20818
|
} catch (error) {
|
|
20706
20819
|
if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
|
|
20707
20820
|
throw error;
|
|
@@ -20774,7 +20887,19 @@ class DispatchClient {
|
|
|
20774
20887
|
]);
|
|
20775
20888
|
}
|
|
20776
20889
|
async getMessageThread(id, session) {
|
|
20777
|
-
return this.#json("GET", ["api", "v1", "messages", id], undefined, { session });
|
|
20890
|
+
return this.#json("GET", ["api", "v1", "messages", id], undefined, session === undefined ? undefined : { session });
|
|
20891
|
+
}
|
|
20892
|
+
async editMessage(id, input) {
|
|
20893
|
+
return this.#json("PATCH", ["api", "v1", "messages", id], input);
|
|
20894
|
+
}
|
|
20895
|
+
async deleteMessage(id, actor) {
|
|
20896
|
+
return this.#json("DELETE", ["api", "v1", "messages", id], { actor });
|
|
20897
|
+
}
|
|
20898
|
+
async messageHistory(id, session) {
|
|
20899
|
+
return this.#json("GET", ["api", "v1", "messages", id, "history"], undefined, session === undefined ? undefined : { session });
|
|
20900
|
+
}
|
|
20901
|
+
async issueMessages(issue) {
|
|
20902
|
+
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "messages"]);
|
|
20778
20903
|
}
|
|
20779
20904
|
async acceptMessageDelivery(id, attempt, input) {
|
|
20780
20905
|
return this.#json("POST", ["api", "v1", "messages", id, "deliveries", String(attempt), "accept"], input);
|
|
@@ -20848,6 +20973,15 @@ class DispatchClient {
|
|
|
20848
20973
|
async resolveComment(id, actor) {
|
|
20849
20974
|
return this.#json("POST", ["api", "v1", "comments", id, "resolve"], { actor });
|
|
20850
20975
|
}
|
|
20976
|
+
async editComment(id, input) {
|
|
20977
|
+
return this.#json("PATCH", ["api", "v1", "comments", id], input);
|
|
20978
|
+
}
|
|
20979
|
+
async deleteComment(id, actor) {
|
|
20980
|
+
return this.#json("DELETE", ["api", "v1", "comments", id], { actor });
|
|
20981
|
+
}
|
|
20982
|
+
async commentHistory(id) {
|
|
20983
|
+
return this.#json("GET", ["api", "v1", "comments", id, "history"]);
|
|
20984
|
+
}
|
|
20851
20985
|
async getComments(issue) {
|
|
20852
20986
|
return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "comments"]);
|
|
20853
20987
|
}
|
|
@@ -20967,6 +21101,20 @@ class DispatchClient {
|
|
|
20967
21101
|
}
|
|
20968
21102
|
return this.#noRoute(async () => this.#response(method, url, await this.#send(method, url, body)));
|
|
20969
21103
|
}
|
|
21104
|
+
async#writingNothing(path, body, options = {}) {
|
|
21105
|
+
for (let keys = 1;; keys++) {
|
|
21106
|
+
try {
|
|
21107
|
+
return (await this.#jsonAnswer("POST", path, body, options)).payload;
|
|
21108
|
+
} catch (error) {
|
|
21109
|
+
if (!(error instanceof DispatchWriteLandedError) || error.code !== IDEMPOTENCY_ANSWER_NOT_KEPT) {
|
|
21110
|
+
throw error;
|
|
21111
|
+
}
|
|
21112
|
+
if (keys === 2) {
|
|
21113
|
+
throw new DispatchAnswerNotKeptError(error.status, "POST", requestForText(this.#baseUrl, this.#url(path), DISPATCH_URL_SETTING));
|
|
21114
|
+
}
|
|
21115
|
+
}
|
|
21116
|
+
}
|
|
21117
|
+
}
|
|
20970
21118
|
async#send(method, url, body, accept = "application/json", signal) {
|
|
20971
21119
|
const sent = await this.#sendOnce(method, url, body, accept, signal);
|
|
20972
21120
|
if (this.#credential.stale === undefined || !await tokenNotLive(sent.answer)) {
|
|
@@ -27457,6 +27605,27 @@ function resolveDecodeOptions(options) {
|
|
|
27457
27605
|
};
|
|
27458
27606
|
}
|
|
27459
27607
|
|
|
27608
|
+
// ../envoy-client/src/actor-text.ts
|
|
27609
|
+
function actorText(actor) {
|
|
27610
|
+
if (actor.kind === "user") {
|
|
27611
|
+
return actorActText(`user ${actor.id}`, actor.act);
|
|
27612
|
+
}
|
|
27613
|
+
const service = actor.kind === "session" ? actor.service : undefined;
|
|
27614
|
+
if (service === undefined) {
|
|
27615
|
+
return `${actor.kind} ${actor.id}`;
|
|
27616
|
+
}
|
|
27617
|
+
return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
|
|
27618
|
+
}
|
|
27619
|
+
function deletedMark(at, by) {
|
|
27620
|
+
return `Deleted by ${by == null ? "its author" : actorText(by)} at ${at}`;
|
|
27621
|
+
}
|
|
27622
|
+
function editedMark(at) {
|
|
27623
|
+
return `edited ${at}`;
|
|
27624
|
+
}
|
|
27625
|
+
function withEditedMark(words, at) {
|
|
27626
|
+
return at == null ? words : `${words} \xB7 ${editedMark(at)}`;
|
|
27627
|
+
}
|
|
27628
|
+
|
|
27460
27629
|
// ../envoy-client/src/dispatch-pictures.ts
|
|
27461
27630
|
var PICTURE_UPLOAD_MAX_BYTES = 25 * 1024 * 1024;
|
|
27462
27631
|
var PICTURE_SHOWN_MAX_BYTES = 3750000;
|
|
@@ -27833,12 +28002,22 @@ function carriedBodyNote(event) {
|
|
|
27833
28002
|
}
|
|
27834
28003
|
async function wholeCarriedBody(client, item, session) {
|
|
27835
28004
|
try {
|
|
28005
|
+
let posts;
|
|
27836
28006
|
if (item.resource === "comment") {
|
|
27837
28007
|
const read = await client.getComment(item.id);
|
|
27838
|
-
|
|
28008
|
+
posts = [read.comment, ...read.replies ?? []];
|
|
28009
|
+
} else {
|
|
28010
|
+
if (item.issueKey === null && session === undefined)
|
|
28011
|
+
return;
|
|
28012
|
+
const read = item.issueKey === null ? await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
|
|
28013
|
+
posts = [read.message, ...read.replies ?? []];
|
|
27839
28014
|
}
|
|
27840
|
-
const
|
|
27841
|
-
|
|
28015
|
+
const post = posts.find((candidate) => candidate.id === item.id);
|
|
28016
|
+
if (post === undefined)
|
|
28017
|
+
return;
|
|
28018
|
+
if (post.deleted_at != null)
|
|
28019
|
+
return deletedMark(post.deleted_at, post.deleted_by);
|
|
28020
|
+
return withEditedMark(post.body, post.edited_at);
|
|
27842
28021
|
} catch {
|
|
27843
28022
|
return;
|
|
27844
28023
|
}
|
|
@@ -27878,11 +28057,14 @@ var DISPATCH_PAYLOAD_SCHEMAS = {
|
|
|
27878
28057
|
"comment.resolved": CommentEventPayloadSchema,
|
|
27879
28058
|
"comment.reopened": CommentEventPayloadSchema,
|
|
27880
28059
|
"comment.edited": CommentEventPayloadSchema,
|
|
28060
|
+
"comment.deleted": CommentEventPayloadSchema,
|
|
27881
28061
|
"suggestion.accepted": CommentEventPayloadSchema,
|
|
27882
28062
|
"suggestion.rejected": CommentEventPayloadSchema,
|
|
27883
28063
|
"message.created": MessageEventPayloadSchema,
|
|
27884
28064
|
"message.delivery": MessageDeliveryEventPayloadSchema,
|
|
27885
28065
|
"message.answered": MessageEventPayloadSchema,
|
|
28066
|
+
"message.edited": MessageEventPayloadSchema,
|
|
28067
|
+
"message.deleted": MessageEventPayloadSchema,
|
|
27886
28068
|
"child.status": ChildStatusEventPayloadSchema
|
|
27887
28069
|
};
|
|
27888
28070
|
function topicDocument(topic) {
|
|
@@ -28371,9 +28553,20 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
|
|
|
28371
28553
|
},
|
|
28372
28554
|
...unrecognised === undefined ? {} : { unrecognised }
|
|
28373
28555
|
};
|
|
28556
|
+
let card;
|
|
28557
|
+
let payloadShownAsText;
|
|
28558
|
+
try {
|
|
28559
|
+
card = encode5({ envoy: rendered });
|
|
28560
|
+
} catch (error) {
|
|
28561
|
+
const payloadKey = dispatchRendered ? "dispatch" : "message";
|
|
28562
|
+
if (envelope.payload === undefined || !(payloadKey in rendered))
|
|
28563
|
+
throw error;
|
|
28564
|
+
card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
|
|
28565
|
+
payloadShownAsText = messageFor(error);
|
|
28566
|
+
}
|
|
28374
28567
|
return {
|
|
28375
28568
|
skip: false,
|
|
28376
|
-
content: trailer === "" ?
|
|
28569
|
+
content: trailer === "" ? card : `${card}
|
|
28377
28570
|
|
|
28378
28571
|
${trailer}`,
|
|
28379
28572
|
envelope,
|
|
@@ -28382,7 +28575,8 @@ ${trailer}`,
|
|
|
28382
28575
|
...rejectedDelivery === undefined ? {} : { rejectedDelivery },
|
|
28383
28576
|
...malformedDelivery ? { malformedDelivery: true } : {},
|
|
28384
28577
|
...pictures.length === 0 ? {} : { pictures },
|
|
28385
|
-
...cutItem === undefined ? {} : { cutItem }
|
|
28578
|
+
...cutItem === undefined ? {} : { cutItem },
|
|
28579
|
+
...payloadShownAsText === undefined ? {} : { payloadShownAsText }
|
|
28386
28580
|
};
|
|
28387
28581
|
}
|
|
28388
28582
|
|
|
@@ -28437,8 +28631,9 @@ async function textWithPictures(text, pictures, owner, upload, actor) {
|
|
|
28437
28631
|
uploaded = await upload({ name: picture.name, file: picture.file, actor });
|
|
28438
28632
|
} catch (error) {
|
|
28439
28633
|
const earlier = addresses.length === 0 ? "" : `; the pictures before it are uploaded (${addresses.join(", ")})`;
|
|
28634
|
+
const landed = error instanceof DispatchWriteLandedError || error instanceof Error && error.cause instanceof DispatchWriteLandedError;
|
|
28440
28635
|
const refused = error instanceof DispatchGatewayError ? !error.mayHaveReachedDispatch : error instanceof DispatchServiceError && error.status < 500;
|
|
28441
|
-
const outcome = refused ? "was not uploaded" : "may or may not have been uploaded";
|
|
28636
|
+
const outcome = landed ? "was uploaded" : refused ? "was not uploaded" : "may or may not have been uploaded";
|
|
28442
28637
|
throw new Error(`images: ${picture.path} ${outcome}: ${messageFor(error).replace(/\.$/, "")}. Nothing ` + `was posted${earlier}.`);
|
|
28443
28638
|
}
|
|
28444
28639
|
const address = `dispatch://${owner}/artifact/${uploaded.artifact.slug}@v${uploaded.version.number}`;
|
|
@@ -28459,7 +28654,10 @@ function parseAgentArtifactRef(ref) {
|
|
|
28459
28654
|
return { session, slug, ...version === undefined ? {} : { version: Number(version) } };
|
|
28460
28655
|
}
|
|
28461
28656
|
function datedBodies(records) {
|
|
28462
|
-
return records.map((record) => ({
|
|
28657
|
+
return records.map((record) => ({
|
|
28658
|
+
text: record.body,
|
|
28659
|
+
at: record.edited_at ?? record.created_at
|
|
28660
|
+
}));
|
|
28463
28661
|
}
|
|
28464
28662
|
function askTexts({ ask, replies }) {
|
|
28465
28663
|
return [
|
|
@@ -28494,6 +28692,7 @@ function eventTexts(event) {
|
|
|
28494
28692
|
case "suggestion.rejected":
|
|
28495
28693
|
case "message.created":
|
|
28496
28694
|
case "message.answered":
|
|
28695
|
+
case "message.edited":
|
|
28497
28696
|
texts = [event.payload.body];
|
|
28498
28697
|
break;
|
|
28499
28698
|
default:
|
|
@@ -28791,7 +28990,7 @@ function normalizeUUID(value) {
|
|
|
28791
28990
|
return `${compact.slice(0, 8)}-${compact.slice(8, 12)}-${compact.slice(12, 16)}-${compact.slice(16, 20)}-${compact.slice(20)}`.toLowerCase();
|
|
28792
28991
|
}
|
|
28793
28992
|
var askIdProblem = "ask must be a bare ask id or a dispatch://.../ask/<id> reference";
|
|
28794
|
-
var commentIdProblem = "comment must be a bare comment id or a dispatch://.../comment/<id> reference";
|
|
28993
|
+
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";
|
|
28795
28994
|
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>)";
|
|
28796
28995
|
function askId(args) {
|
|
28797
28996
|
const ask = stringArg(args, "ask");
|
|
@@ -28804,6 +29003,23 @@ function messageIdOf(value) {
|
|
|
28804
29003
|
})() : value;
|
|
28805
29004
|
return id === undefined ? undefined : normalizeUUID(id);
|
|
28806
29005
|
}
|
|
29006
|
+
var messageArgumentProblem = (argument) => `${argument} must be a full message id (uuid) or a dispatch://KEY/message/<id> reference`;
|
|
29007
|
+
function messageArgumentId(value) {
|
|
29008
|
+
if (!value.startsWith("dispatch://")) {
|
|
29009
|
+
const bare = normalizeUUID(value);
|
|
29010
|
+
return bare === undefined ? undefined : { id: bare };
|
|
29011
|
+
}
|
|
29012
|
+
const ref = parseDispatchRef(value);
|
|
29013
|
+
if (ref?.kind !== "message")
|
|
29014
|
+
return;
|
|
29015
|
+
const full = normalizeUUID(ref.id);
|
|
29016
|
+
const owner = ref.owner;
|
|
29017
|
+
if (owner.kind !== "issue")
|
|
29018
|
+
return full === undefined ? undefined : { id: full };
|
|
29019
|
+
if (full === undefined && !isIdPrefix(ref.id))
|
|
29020
|
+
return;
|
|
29021
|
+
return { id: full ?? ref.id, ref: { ...ref, owner } };
|
|
29022
|
+
}
|
|
28807
29023
|
function itemBlockOf(value) {
|
|
28808
29024
|
const ref = parseDispatchRef(value);
|
|
28809
29025
|
return ref?.item === undefined || ref.block === undefined ? undefined : { ...ref, item: ref.item, block: ref.block };
|
|
@@ -28853,7 +29069,7 @@ async function refuseItemOffRef(tool, kind, ref, refText, item, documentId) {
|
|
|
28853
29069
|
return;
|
|
28854
29070
|
}
|
|
28855
29071
|
}
|
|
28856
|
-
const where = item.issue_key === null ? "another document" : `${item.issue_key}; name it dispatch://${item.issue_key}/${kind}/${item.id}`;
|
|
29072
|
+
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}`;
|
|
28857
29073
|
throw new ToolInputError(tool, [
|
|
28858
29074
|
`${refText} names ${kind} ${item.id} on ${refOwnerName(ref)}, but it is on ${where}`
|
|
28859
29075
|
]);
|
|
@@ -28937,6 +29153,10 @@ var issueFreeTools = {
|
|
|
28937
29153
|
dispatch_edit_ask: true,
|
|
28938
29154
|
dispatch_resolve_ask: true,
|
|
28939
29155
|
dispatch_resolve_comment: true,
|
|
29156
|
+
dispatch_edit_comment: true,
|
|
29157
|
+
dispatch_delete_comment: true,
|
|
29158
|
+
dispatch_edit_message: true,
|
|
29159
|
+
dispatch_delete_message: true,
|
|
28940
29160
|
dispatch_follow: true,
|
|
28941
29161
|
dispatch_search: true,
|
|
28942
29162
|
dispatch_related: true,
|
|
@@ -28983,13 +29203,25 @@ function argumentProblems(tool, args) {
|
|
|
28983
29203
|
}
|
|
28984
29204
|
break;
|
|
28985
29205
|
}
|
|
28986
|
-
case "dispatch_resolve_comment":
|
|
29206
|
+
case "dispatch_resolve_comment":
|
|
29207
|
+
case "dispatch_edit_comment":
|
|
29208
|
+
case "dispatch_delete_comment": {
|
|
28987
29209
|
const comment = optionalString(args, "comment");
|
|
28988
|
-
if (comment
|
|
29210
|
+
if (comment !== undefined && !comment.startsWith("dispatch://") && normalizeUUID(comment) === undefined && !isIdPrefix(comment)) {
|
|
29211
|
+
problems.push(commentIdProblem);
|
|
29212
|
+
} else if (comment?.startsWith("dispatch://") && parseDispatchRef(comment)?.kind !== "comment") {
|
|
28989
29213
|
problems.push(itemRefProblem(comment) ?? commentIdProblem);
|
|
28990
29214
|
}
|
|
28991
29215
|
break;
|
|
28992
29216
|
}
|
|
29217
|
+
case "dispatch_edit_message":
|
|
29218
|
+
case "dispatch_delete_message": {
|
|
29219
|
+
const message = optionalString(args, "message");
|
|
29220
|
+
if (message !== undefined && messageArgumentId(message) === undefined) {
|
|
29221
|
+
problems.push(messageArgumentProblem("message"));
|
|
29222
|
+
}
|
|
29223
|
+
break;
|
|
29224
|
+
}
|
|
28993
29225
|
case "dispatch_comment": {
|
|
28994
29226
|
if (optionalString(args, "quote") !== undefined && optionalString(args, "artifact") === undefined) {
|
|
28995
29227
|
problems.push("artifact is required when quote is supplied");
|
|
@@ -29020,7 +29252,12 @@ function argumentProblems(tool, args) {
|
|
|
29020
29252
|
case "dispatch_read": {
|
|
29021
29253
|
const message = optionalString(args, "message");
|
|
29022
29254
|
if (message !== undefined && messageIdOf(message) === undefined) {
|
|
29023
|
-
problems.push("message
|
|
29255
|
+
problems.push(messageArgumentProblem("message"));
|
|
29256
|
+
}
|
|
29257
|
+
const historyRef = optionalBoolean(args, "history") === true ? optionalString(args, "ref") : undefined;
|
|
29258
|
+
const historyKind = historyRef === undefined ? undefined : parseDispatchRef(historyRef)?.kind;
|
|
29259
|
+
if (historyRef !== undefined && historyKind !== "comment" && historyKind !== "message") {
|
|
29260
|
+
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>");
|
|
29024
29261
|
}
|
|
29025
29262
|
const events = optionalNumber(args, "events");
|
|
29026
29263
|
const allEvents = optionalBoolean(args, "all_events") === true;
|
|
@@ -29302,6 +29539,21 @@ function refusalWithCode(error, ...clauses) {
|
|
|
29302
29539
|
function dispatchAnswered(error, status) {
|
|
29303
29540
|
return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
|
|
29304
29541
|
}
|
|
29542
|
+
var OLDER_COMMENT_EDIT_ACTOR = 'invalid JSON body: json: unknown field "actor"';
|
|
29543
|
+
async function throughPostCorrections(tool, url, call, post) {
|
|
29544
|
+
try {
|
|
29545
|
+
return await call;
|
|
29546
|
+
} catch (error) {
|
|
29547
|
+
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);
|
|
29548
|
+
if (!(error instanceof DispatchNoRouteError) && !commentEditIsAge) {
|
|
29549
|
+
throw post === undefined ? error : refuseMissingPost(error, post);
|
|
29550
|
+
}
|
|
29551
|
+
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.");
|
|
29552
|
+
}
|
|
29553
|
+
}
|
|
29554
|
+
function refuseMissingPost(error, post) {
|
|
29555
|
+
return dispatchNotFound(error) ? refusalWithCode(error, `this Dispatch holds no ${post.kind} ${post.id}`) : error;
|
|
29556
|
+
}
|
|
29305
29557
|
function writeMayHaveLanded(error) {
|
|
29306
29558
|
if (error instanceof DispatchGatewayError)
|
|
29307
29559
|
return error.mayHaveReachedDispatch;
|
|
@@ -29312,10 +29564,29 @@ function withAccount(error, account) {
|
|
|
29312
29564
|
const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
|
|
29313
29565
|
return new Error(told, { cause: error });
|
|
29314
29566
|
}
|
|
29567
|
+
function dispatchNotFound(error) {
|
|
29568
|
+
return !(error instanceof DispatchNoRouteError) && dispatchAnswered(error, 404) && error.code === "NOT_FOUND";
|
|
29569
|
+
}
|
|
29315
29570
|
|
|
29316
|
-
// ../envoy-client/src/dispatch-commands/document-targets.ts
|
|
29317
29571
|
class DocumentNotFoundError extends Error {
|
|
29318
29572
|
}
|
|
29573
|
+
async function refuseMissingOfRef(error, kind, id, owner, ownerName, readOwner) {
|
|
29574
|
+
if (!dispatchNotFound(error))
|
|
29575
|
+
return error;
|
|
29576
|
+
const missingOwner = await readOwner().then(() => {
|
|
29577
|
+
return;
|
|
29578
|
+
}, (caught) => {
|
|
29579
|
+
if (owner.kind === "issue" && dispatchNotFound(caught)) {
|
|
29580
|
+
return refusalWithCode(error, `this Dispatch holds no issue ${owner.issue}`);
|
|
29581
|
+
}
|
|
29582
|
+
if (caught instanceof DocumentNotFoundError)
|
|
29583
|
+
return caught;
|
|
29584
|
+
return refusalWithCode(error, `the read of ${ownerName} failed, so this does not say whether ${ownerName} exists or` + ` holds ${kind} ${id}: ${messageFor(caught)}`);
|
|
29585
|
+
});
|
|
29586
|
+
return missingOwner ?? refusalWithCode(error, `${ownerName} holds no ${kind} ${id}`);
|
|
29587
|
+
}
|
|
29588
|
+
|
|
29589
|
+
// ../envoy-client/src/dispatch-commands/document-targets.ts
|
|
29319
29590
|
function artifactByReference(artifacts, artifactReference, owner, canonical) {
|
|
29320
29591
|
const bySlug = artifacts.find((candidate) => candidate.slug === artifactReference);
|
|
29321
29592
|
if (canonical && bySlug !== undefined)
|
|
@@ -29511,6 +29782,9 @@ async function resolveExistingIssue(client, issueReference) {
|
|
|
29511
29782
|
throw error;
|
|
29512
29783
|
}
|
|
29513
29784
|
}
|
|
29785
|
+
function readRefOwner(client, owner, readDocument) {
|
|
29786
|
+
return async () => owner.kind === "issue" ? client.getIssue(owner.issue) : readDocument();
|
|
29787
|
+
}
|
|
29514
29788
|
|
|
29515
29789
|
// ../envoy-client/src/dispatch-commands/command-context.ts
|
|
29516
29790
|
function toolActor(origin, input) {
|
|
@@ -29569,32 +29843,21 @@ async function commandContext(session) {
|
|
|
29569
29843
|
};
|
|
29570
29844
|
}
|
|
29571
29845
|
|
|
29572
|
-
// ../envoy-client/src/actor-text.ts
|
|
29573
|
-
function actorText(actor) {
|
|
29574
|
-
if (actor.kind === "user") {
|
|
29575
|
-
return actorActText(`user ${actor.id}`, actor.act);
|
|
29576
|
-
}
|
|
29577
|
-
const service = actor.kind === "session" ? actor.service : undefined;
|
|
29578
|
-
if (service === undefined) {
|
|
29579
|
-
return `${actor.kind} ${actor.id}`;
|
|
29580
|
-
}
|
|
29581
|
-
return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
|
|
29582
|
-
}
|
|
29583
|
-
|
|
29584
29846
|
// ../envoy-client/src/search-answer.ts
|
|
29585
29847
|
function pageSummaryText(offset, count, total) {
|
|
29586
29848
|
return `showing ${offset + 1}-${offset + count} of ${total}`;
|
|
29587
29849
|
}
|
|
29588
29850
|
function searchHitLine(result, linkBase) {
|
|
29589
29851
|
const href = linkFor(result.href, linkBase);
|
|
29852
|
+
const text = result.deleted_at == null ? withEditedMark(snippetText(result.snippet), result.edited_at) : deletedMark(result.deleted_at, result.deleted_by);
|
|
29590
29853
|
const { owner } = result;
|
|
29591
29854
|
if (owner.kind === "document") {
|
|
29592
29855
|
const reference = dispatchDocumentRef(owner.project ?? "", owner.slug ?? "");
|
|
29593
|
-
return `${reference} [document] ${owner.name} - ${result.kind}: ${
|
|
29856
|
+
return `${reference} [document] ${owner.name} - ${result.kind}: ${text} -> ${href}`;
|
|
29594
29857
|
}
|
|
29595
29858
|
const artifactName = result.artifact ? ` ${result.artifact.name}` : "";
|
|
29596
29859
|
const label = `${owner.key} [${owner.status}] ${owner.title} - ${result.kind}${artifactName}`;
|
|
29597
|
-
return `${label}: ${
|
|
29860
|
+
return `${label}: ${text} -> ${href}`;
|
|
29598
29861
|
}
|
|
29599
29862
|
function indentedText(text) {
|
|
29600
29863
|
return text.split(/\r?\n/u).join(`
|
|
@@ -29965,7 +30228,8 @@ function isItemKind(kind) {
|
|
|
29965
30228
|
}
|
|
29966
30229
|
function edgeLine(edge) {
|
|
29967
30230
|
const { node } = edge;
|
|
29968
|
-
const
|
|
30231
|
+
const words = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
|
|
30232
|
+
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 `;
|
|
29969
30233
|
const block = edge.block === undefined ? "" : ` (block ${edge.block.ref ?? edge.block.id})`;
|
|
29970
30234
|
const parent = node.parent ?? undefined;
|
|
29971
30235
|
const item = node.kind === "block" && node.document === undefined && isItemKind(parent?.kind) ? parent : undefined;
|
|
@@ -30035,7 +30299,7 @@ function blockLines(node, ref, typed, noun = "Block") {
|
|
|
30035
30299
|
...node.changed_version === undefined ? [] : [`Changed in version: ${node.changed_version}`],
|
|
30036
30300
|
...node.text === undefined ? [] : ["Text:", node.text]
|
|
30037
30301
|
] : [
|
|
30038
|
-
`${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}:`,
|
|
30302
|
+
`${withEditedMark(`${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}`, node.edited_at)}:`,
|
|
30039
30303
|
...node.text === undefined ? [] : [node.text]
|
|
30040
30304
|
];
|
|
30041
30305
|
const { pin } = node;
|
|
@@ -30198,7 +30462,9 @@ function olderServerWarnings(issue) {
|
|
|
30198
30462
|
}
|
|
30199
30463
|
var STRUCTURAL_EDGES_IN = ["child_of", "blocked_by"];
|
|
30200
30464
|
function referenceLinkLine({ kinds, node, via }, near) {
|
|
30201
|
-
|
|
30465
|
+
const address = node.ref ?? node.id;
|
|
30466
|
+
const target = node.deleted_at == null ? withEditedMark(address, node.edited_at) : `${address} \xB7 ${deletedMark(node.deleted_at, node.deleted_by)}`;
|
|
30467
|
+
return `- ${(kinds ?? []).join(",")} ${node.kind} ${target} \xB7 ${near} ${via.kind} ${via.id}`;
|
|
30202
30468
|
}
|
|
30203
30469
|
function memberLines(references) {
|
|
30204
30470
|
const members = references.members ?? [];
|
|
@@ -30286,6 +30552,13 @@ function logSummary(issue, events) {
|
|
|
30286
30552
|
].join(`
|
|
30287
30553
|
`);
|
|
30288
30554
|
}
|
|
30555
|
+
function postEventHead(payload) {
|
|
30556
|
+
if (payload.deleted_at != null)
|
|
30557
|
+
return deletedMark(payload.deleted_at, payload.deleted_by);
|
|
30558
|
+
if (payload.body === undefined)
|
|
30559
|
+
return;
|
|
30560
|
+
return withEditedMark(textHead(payload.body), payload.edited_at);
|
|
30561
|
+
}
|
|
30289
30562
|
function eventHead(event) {
|
|
30290
30563
|
switch (event.type) {
|
|
30291
30564
|
case "ask.opened":
|
|
@@ -30306,11 +30579,14 @@ function eventHead(event) {
|
|
|
30306
30579
|
case "comment.edited":
|
|
30307
30580
|
case "comment.resolved":
|
|
30308
30581
|
case "comment.reopened":
|
|
30582
|
+
case "comment.deleted":
|
|
30309
30583
|
case "suggestion.accepted":
|
|
30310
30584
|
case "suggestion.rejected":
|
|
30311
30585
|
case "message.created":
|
|
30312
30586
|
case "message.answered":
|
|
30313
|
-
|
|
30587
|
+
case "message.edited":
|
|
30588
|
+
case "message.deleted":
|
|
30589
|
+
return postEventHead(event.payload);
|
|
30314
30590
|
case "artifact.version":
|
|
30315
30591
|
return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
|
|
30316
30592
|
case "artifact.approved":
|
|
@@ -31133,7 +31409,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
|
|
|
31133
31409
|
const partRef = (id) => `${askRef}#b-${encodeBlockId(id)}`;
|
|
31134
31410
|
const chain = (replies ?? []).flatMap((reply) => [
|
|
31135
31411
|
`${reply.id} \xB7 ${actorText(reply.author)}`,
|
|
31136
|
-
|
|
31412
|
+
...postBodyLines(reply)
|
|
31137
31413
|
]);
|
|
31138
31414
|
const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
|
|
31139
31415
|
return [
|
|
@@ -31241,19 +31517,42 @@ function formatOpenAsksSummary(response, linkBase) {
|
|
|
31241
31517
|
].join(`
|
|
31242
31518
|
`);
|
|
31243
31519
|
}
|
|
31520
|
+
function postBodyLines(post) {
|
|
31521
|
+
if (post.deleted_at != null)
|
|
31522
|
+
return [deletedMark(post.deleted_at, post.deleted_by)];
|
|
31523
|
+
return [...post.edited_at == null ? [] : [`Edited: ${post.edited_at}`], `Body: ${post.body}`];
|
|
31524
|
+
}
|
|
31525
|
+
function postHistorySummary(kind, ref, id, read) {
|
|
31526
|
+
const entries = read.entries ?? [];
|
|
31527
|
+
const deleted = read.deleted_at != null;
|
|
31528
|
+
const oldest = entries.at(-1);
|
|
31529
|
+
const route = `/api/v1/${kind === "Comment" ? "comments" : "messages"}/${id}/history`;
|
|
31530
|
+
return [
|
|
31531
|
+
`${kind} history: ${ref}`,
|
|
31532
|
+
...read.deleted_at == null ? [] : [deletedMark(read.deleted_at, read.deleted_by)],
|
|
31533
|
+
...entries.length === 0 ? ["- none"] : entries.flatMap((entry) => [
|
|
31534
|
+
`${entry.edited_at} \xB7 ${actorText(entry.edited_by)}`,
|
|
31535
|
+
...deleted ? [] : [`Body: ${entry.body}`]
|
|
31536
|
+
]),
|
|
31537
|
+
...entries.length < POST_HISTORY_PAGE_LIMIT || oldest === undefined ? [] : [
|
|
31538
|
+
`This is the newest page, and a page holds ${POST_HISTORY_PAGE_LIMIT} rows: GET ${route}?before=${oldest.edited_at} reads any older rows.`
|
|
31539
|
+
]
|
|
31540
|
+
].join(`
|
|
31541
|
+
`);
|
|
31542
|
+
}
|
|
31244
31543
|
function commentSummary({ comment, replies }, graph) {
|
|
31245
31544
|
const root = [
|
|
31246
31545
|
`${comment.id} \xB7 ${actorText(comment.author)}`,
|
|
31247
31546
|
...anchorLines(comment),
|
|
31248
31547
|
...replyBlockLines(comment),
|
|
31249
|
-
|
|
31548
|
+
...postBodyLines(comment)
|
|
31250
31549
|
];
|
|
31251
31550
|
const chain = (replies ?? []).flatMap((reply) => [
|
|
31252
31551
|
`${reply.id} \xB7 ${actorText(reply.author)}`,
|
|
31253
31552
|
...anchorLines(reply),
|
|
31254
31553
|
...replyBlockLines(reply),
|
|
31255
31554
|
...reply.answers != null && reply.answers !== comment.id ? [`Answers: ${reply.answers}`] : [],
|
|
31256
|
-
|
|
31555
|
+
...postBodyLines(reply)
|
|
31257
31556
|
]);
|
|
31258
31557
|
return [
|
|
31259
31558
|
"Comment:",
|
|
@@ -31268,8 +31567,13 @@ function replyBlockLines(record) {
|
|
|
31268
31567
|
const block = record.reply_block;
|
|
31269
31568
|
if (block === undefined || block === null)
|
|
31270
31569
|
return [];
|
|
31570
|
+
if (block.deleted_at != null) {
|
|
31571
|
+
return [
|
|
31572
|
+
`Re: block ${block.block_id} (parent deleted): ${deletedMark(block.deleted_at, block.deleted_by)}`
|
|
31573
|
+
];
|
|
31574
|
+
}
|
|
31271
31575
|
return [
|
|
31272
|
-
block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}
|
|
31576
|
+
withEditedMark(block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}`, block.edited_at)
|
|
31273
31577
|
];
|
|
31274
31578
|
}
|
|
31275
31579
|
function anchorLines(record) {
|
|
@@ -31298,12 +31602,12 @@ function messageSummary({ message, replies }, graph) {
|
|
|
31298
31602
|
const root = [
|
|
31299
31603
|
`${message.id} \xB7 ${actorText(message.author)}`,
|
|
31300
31604
|
...replyBlockLines(message),
|
|
31301
|
-
|
|
31605
|
+
...postBodyLines(message)
|
|
31302
31606
|
];
|
|
31303
31607
|
const chain = (replies ?? []).flatMap((reply) => [
|
|
31304
31608
|
`${reply.id} \xB7 ${actorText(reply.author)}`,
|
|
31305
31609
|
...replyBlockLines(reply),
|
|
31306
|
-
|
|
31610
|
+
...postBodyLines(reply)
|
|
31307
31611
|
]);
|
|
31308
31612
|
return [
|
|
31309
31613
|
"Message:",
|
|
@@ -31347,7 +31651,7 @@ async function openAnchoredThreads(client, resolved) {
|
|
|
31347
31651
|
const commentThreads = roots.map((root) => [
|
|
31348
31652
|
`comment ${root.id} \xB7 ${actorText(root.author)} \xB7 ${root.created_at}`,
|
|
31349
31653
|
...anchorLines(root),
|
|
31350
|
-
|
|
31654
|
+
...postBodyLines(root),
|
|
31351
31655
|
...threadReplyLines(replies.get(root.id) ?? [])
|
|
31352
31656
|
].join(`
|
|
31353
31657
|
`));
|
|
@@ -31356,7 +31660,7 @@ async function openAnchoredThreads(client, resolved) {
|
|
|
31356
31660
|
function threadReplyLines(replies) {
|
|
31357
31661
|
return replies.flatMap((reply) => [
|
|
31358
31662
|
`reply ${reply.id} \xB7 ${actorText(reply.author)} \xB7 ${reply.created_at}`,
|
|
31359
|
-
|
|
31663
|
+
...postBodyLines(reply)
|
|
31360
31664
|
]);
|
|
31361
31665
|
}
|
|
31362
31666
|
function threadRootId(comment, byId) {
|
|
@@ -31634,28 +31938,116 @@ async function followCommand(context) {
|
|
|
31634
31938
|
}
|
|
31635
31939
|
|
|
31636
31940
|
// ../envoy-client/src/dispatch-commands/conversation.ts
|
|
31637
|
-
async function
|
|
31638
|
-
const { args, client, actor, input } = context;
|
|
31639
|
-
const reference = stringArg(args, "comment");
|
|
31941
|
+
async function resolveCommentArgument(tool, reference, client) {
|
|
31640
31942
|
const ref = reference.startsWith("dispatch://") ? parseDispatchRef(reference) : null;
|
|
31943
|
+
if (ref === null)
|
|
31944
|
+
return { id: reference };
|
|
31641
31945
|
let id = reference;
|
|
31642
31946
|
let document;
|
|
31643
|
-
if (ref
|
|
31947
|
+
if (ref.owner.kind === "issue") {
|
|
31644
31948
|
const issueKey = ref.owner.issue;
|
|
31645
|
-
id = await resolveIdPrefix(
|
|
31646
|
-
} else
|
|
31949
|
+
id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
|
|
31950
|
+
} else {
|
|
31647
31951
|
const artifact = (await resolveArtifact(client, ref.owner, ref.artifact, { canonical: true })).artifact;
|
|
31648
31952
|
document = artifact;
|
|
31649
|
-
id = await resolveIdPrefix(
|
|
31953
|
+
id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getArtifactComments(artifact.id));
|
|
31650
31954
|
}
|
|
31651
|
-
|
|
31652
|
-
|
|
31653
|
-
|
|
31654
|
-
|
|
31655
|
-
|
|
31955
|
+
const read = await client.getComment(id).catch(async (error) => {
|
|
31956
|
+
throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, async () => document));
|
|
31957
|
+
});
|
|
31958
|
+
await refuseItemOffRef(tool, "comment", ref, reference, read.comment, async () => document === undefined ? "" : document.id);
|
|
31959
|
+
return { id, ...document === undefined ? {} : { document } };
|
|
31960
|
+
}
|
|
31961
|
+
async function resolveMessageArgument(tool, argument, reference, client, session) {
|
|
31962
|
+
const named = messageArgumentId(reference);
|
|
31963
|
+
if (named === undefined)
|
|
31964
|
+
throw new ToolInputError(tool, [messageArgumentProblem(argument)]);
|
|
31965
|
+
const ref = named.ref;
|
|
31966
|
+
if (ref === undefined)
|
|
31967
|
+
return named.id;
|
|
31968
|
+
const issueKey = ref.owner.issue;
|
|
31969
|
+
const id = await resolveIdPrefix(tool, "message", named.id, issueKey, async () => (await client.issueMessages(issueKey)).flatMap((thread) => [
|
|
31970
|
+
thread.message,
|
|
31971
|
+
...thread.replies ?? []
|
|
31972
|
+
]));
|
|
31973
|
+
const read = await client.getMessageThread(id, session === "" ? undefined : session).catch(async (error) => {
|
|
31974
|
+
throw await refuseMissingOfRef(error, "message", id, ref.owner, issueKey, () => client.getIssue(issueKey));
|
|
31975
|
+
});
|
|
31976
|
+
await refuseItemOffRef(tool, "message", ref, reference, { id, issue_key: read.message.issue_key }, async () => "");
|
|
31977
|
+
return id;
|
|
31978
|
+
}
|
|
31979
|
+
function messageIssueKey(message) {
|
|
31980
|
+
if (message.issue_key === null)
|
|
31981
|
+
throw new Error("the corrected message names no issue");
|
|
31982
|
+
return message.issue_key;
|
|
31983
|
+
}
|
|
31984
|
+
async function resolveCommentCommand(context) {
|
|
31985
|
+
const { args, client, actor, input } = context;
|
|
31986
|
+
const reference = stringArg(args, "comment");
|
|
31987
|
+
const { id, document } = await resolveCommentArgument(input.tool, reference, client);
|
|
31988
|
+
const comment = await client.resolveComment(id, actor).catch((error) => {
|
|
31989
|
+
throw refuseMissingPost(error, { kind: "comment", id });
|
|
31990
|
+
});
|
|
31656
31991
|
const { label, details } = await commentOwnerResult(client, comment, document);
|
|
31657
31992
|
return { text: `Resolved comment ${comment.id} on ${label}.`, details };
|
|
31658
31993
|
}
|
|
31994
|
+
async function editCommentCommand(context) {
|
|
31995
|
+
const { args, client, actor, input, configUrl } = context;
|
|
31996
|
+
const reference = stringArg(args, "comment");
|
|
31997
|
+
const { id, document } = await resolveCommentArgument(input.tool, reference, client);
|
|
31998
|
+
const comment = await throughPostCorrections(input.tool, configUrl, client.editComment(id, { body: stringArg(args, "body"), actor }), { kind: "comment", id });
|
|
31999
|
+
const { label, details } = await commentOwnerResult(client, comment, document);
|
|
32000
|
+
return { text: `Edited comment ${comment.id} on ${label}.`, details };
|
|
32001
|
+
}
|
|
32002
|
+
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.";
|
|
32003
|
+
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.";
|
|
32004
|
+
async function throughDelete(context, call, post) {
|
|
32005
|
+
try {
|
|
32006
|
+
return await throughPostCorrections(context.input.tool, context.configUrl, call, post);
|
|
32007
|
+
} catch (error) {
|
|
32008
|
+
if (dispatchAnswered(error, 409) && error.code === "DELETE_CONTENDED") {
|
|
32009
|
+
throw refusalWithCode(error, `${post.kind} ${post.id} stands: run the same dispatch delete-${post.kind} command again`);
|
|
32010
|
+
}
|
|
32011
|
+
throw error;
|
|
32012
|
+
}
|
|
32013
|
+
}
|
|
32014
|
+
async function deleteCommentCommand(context) {
|
|
32015
|
+
const { args, client, actor, input } = context;
|
|
32016
|
+
const reference = stringArg(args, "comment");
|
|
32017
|
+
const { id, document } = await resolveCommentArgument(input.tool, reference, client);
|
|
32018
|
+
const comment = await throughDelete(context, client.deleteComment(id, actor), {
|
|
32019
|
+
kind: "comment",
|
|
32020
|
+
id
|
|
32021
|
+
});
|
|
32022
|
+
const { label, details } = await commentOwnerResult(client, comment, document);
|
|
32023
|
+
return {
|
|
32024
|
+
text: `Deleted comment ${comment.id} on ${label}. ${DELETED_COMMENT_READS}`,
|
|
32025
|
+
details
|
|
32026
|
+
};
|
|
32027
|
+
}
|
|
32028
|
+
async function editMessageCommand(context) {
|
|
32029
|
+
const { args, client, actor, input, configUrl, hostSession } = context;
|
|
32030
|
+
const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
|
|
32031
|
+
const message = await throughPostCorrections(input.tool, configUrl, client.editMessage(id, { body: stringArg(args, "body"), actor }), { kind: "message", id });
|
|
32032
|
+
const issue = messageIssueKey(message);
|
|
32033
|
+
return {
|
|
32034
|
+
text: `Edited message ${message.id} on ${issue}.`,
|
|
32035
|
+
details: { issue, message: message.id }
|
|
32036
|
+
};
|
|
32037
|
+
}
|
|
32038
|
+
async function deleteMessageCommand(context) {
|
|
32039
|
+
const { args, client, actor, input, hostSession } = context;
|
|
32040
|
+
const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
|
|
32041
|
+
const message = await throughDelete(context, client.deleteMessage(id, actor), {
|
|
32042
|
+
kind: "message",
|
|
32043
|
+
id
|
|
32044
|
+
});
|
|
32045
|
+
const issue = messageIssueKey(message);
|
|
32046
|
+
return {
|
|
32047
|
+
text: `Deleted message ${message.id} on ${issue}. ${DELETED_MESSAGE_READS}`,
|
|
32048
|
+
details: { issue, message: message.id }
|
|
32049
|
+
};
|
|
32050
|
+
}
|
|
31659
32051
|
async function commentCommand(context) {
|
|
31660
32052
|
const { args, client, actor, input, documentOwner, resolveDocument, writePictures, issue } = context;
|
|
31661
32053
|
const artifactReference = optionalString(args, "artifact");
|
|
@@ -32075,6 +32467,9 @@ function artifactNameExistsProblem(held, owner) {
|
|
|
32075
32467
|
return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
|
|
32076
32468
|
}
|
|
32077
32469
|
function storedTextCheckFailed(error, name) {
|
|
32470
|
+
if (error instanceof DispatchAnswerNotKeptError) {
|
|
32471
|
+
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.`;
|
|
32472
|
+
}
|
|
32078
32473
|
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)}.`;
|
|
32079
32474
|
if (!dispatchAnswered(error, 413)) {
|
|
32080
32475
|
return `${failure} Send the upload again once that call is answered.`;
|
|
@@ -32784,9 +33179,12 @@ async function readCommand(context) {
|
|
|
32784
33179
|
shown,
|
|
32785
33180
|
documentOwner,
|
|
32786
33181
|
resolveDocument,
|
|
32787
|
-
issue
|
|
33182
|
+
issue,
|
|
33183
|
+
configUrl,
|
|
33184
|
+
hostSession
|
|
32788
33185
|
} = context;
|
|
32789
33186
|
const message = optionalString(args, "message");
|
|
33187
|
+
const history = optionalBoolean(args, "history") === true;
|
|
32790
33188
|
const picturesOf = (texts) => readPictures(client, picturesNewestFirst(texts), shown);
|
|
32791
33189
|
const showImages = (pictures) => {
|
|
32792
33190
|
for (const address of pictures.shown)
|
|
@@ -32817,9 +33215,21 @@ async function readCommand(context) {
|
|
|
32817
33215
|
refDocumentId ??= resolveDocument(ref.owner, ref.artifact).then((resolved) => resolved.artifact.id);
|
|
32818
33216
|
return refDocumentId;
|
|
32819
33217
|
};
|
|
33218
|
+
const deletedPostClause = async (ref) => {
|
|
33219
|
+
const item = ref.item;
|
|
33220
|
+
if (item === undefined || item.kind !== "comment" && item.kind !== "message") {
|
|
33221
|
+
return "";
|
|
33222
|
+
}
|
|
33223
|
+
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(() => {
|
|
33224
|
+
return;
|
|
33225
|
+
});
|
|
33226
|
+
return deleted == null ? "" : ` This ${item.kind} is deleted.`;
|
|
33227
|
+
};
|
|
32820
33228
|
if (ownerArguments.ref?.kind === "ask") {
|
|
32821
33229
|
const ref = ownerArguments.ref;
|
|
32822
|
-
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"))
|
|
33230
|
+
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) => {
|
|
33231
|
+
throw await refuseMissingOfRef(error, "ask", ref.id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
|
|
33232
|
+
});
|
|
32823
33233
|
await refuseItemOffRef(input.tool, "ask", ref, stringArg(args, "ref"), askRead.ask, () => documentIdOf(ref));
|
|
32824
33234
|
const askRef = refTarget(ref, "ask", askRead.ask.id);
|
|
32825
33235
|
const [pictures, incoming, outgoing] = await Promise.all([
|
|
@@ -32836,8 +33246,16 @@ async function readCommand(context) {
|
|
|
32836
33246
|
if (ownerArguments.ref?.kind === "comment") {
|
|
32837
33247
|
const ref = ownerArguments.ref;
|
|
32838
33248
|
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)));
|
|
32839
|
-
const comment = await client.getComment(id)
|
|
33249
|
+
const comment = await client.getComment(id).catch(async (error) => {
|
|
33250
|
+
throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
|
|
33251
|
+
});
|
|
32840
33252
|
await refuseItemOffRef(input.tool, "comment", ref, stringArg(args, "ref"), comment.comment, () => documentIdOf(ref));
|
|
33253
|
+
if (history) {
|
|
33254
|
+
return {
|
|
33255
|
+
text: postHistorySummary("Comment", refTarget(ref, "comment", id), id, await throughPostCorrections(input.tool, configUrl, client.commentHistory(id))),
|
|
33256
|
+
details: ref.owner.kind === "project" ? { project: ref.owner.project, comment: id } : { issue: comment.comment.issue_key, comment: id }
|
|
33257
|
+
};
|
|
33258
|
+
}
|
|
32841
33259
|
const commentRef = refTarget(ref, "comment", id);
|
|
32842
33260
|
const [pictures, graph] = await Promise.all([
|
|
32843
33261
|
picturesOf(datedBodies([comment.comment, ...comment.replies ?? []])),
|
|
@@ -32853,7 +33271,18 @@ async function readCommand(context) {
|
|
|
32853
33271
|
if (ownerArguments.ref.owner.kind !== "issue") {
|
|
32854
33272
|
throw new Error("message references are issue-scoped");
|
|
32855
33273
|
}
|
|
32856
|
-
const
|
|
33274
|
+
const messageIssue = ownerArguments.ref.owner.issue;
|
|
33275
|
+
if (history) {
|
|
33276
|
+
const id = await resolveMessageArgument(input.tool, "ref", stringArg(args, "ref"), client, hostSession);
|
|
33277
|
+
return {
|
|
33278
|
+
text: postHistorySummary("Message", dispatchChildRef(dispatchIssueRef(messageIssue), "message", id), id, await throughPostCorrections(input.tool, configUrl, client.messageHistory(id, hostSession === "" ? undefined : hostSession))),
|
|
33279
|
+
details: { issue: messageIssue, message: id }
|
|
33280
|
+
};
|
|
33281
|
+
}
|
|
33282
|
+
const named = ownerArguments.ref;
|
|
33283
|
+
const messageRead = await client.getMessage(messageIssue, named.id).catch(async (error) => {
|
|
33284
|
+
throw await refuseMissingOfRef(error, "message", named.id, { kind: "issue", issue: messageIssue }, messageIssue, () => client.getIssue(messageIssue));
|
|
33285
|
+
});
|
|
32857
33286
|
const messageRef = dispatchChildRef(dispatchIssueRef(ownerArguments.ref.owner.issue), "message", ownerArguments.ref.id);
|
|
32858
33287
|
const [pictures, graph] = await Promise.all([
|
|
32859
33288
|
picturesOf(datedBodies([messageRead.message, ...messageRead.replies ?? []])),
|
|
@@ -32873,9 +33302,9 @@ async function readCommand(context) {
|
|
|
32873
33302
|
return;
|
|
32874
33303
|
}) : undefined;
|
|
32875
33304
|
const [incoming, outgoing, partOf, typed] = await Promise.all([
|
|
32876
|
-
client.getReferences({ to: blockRef }).catch((error) => {
|
|
33305
|
+
client.getReferences({ to: blockRef }).catch(async (error) => {
|
|
32877
33306
|
if (ref.pin === undefined && dispatchAnswered(error, 404)) {
|
|
32878
|
-
throw new Error(`No block ${ref.block} in ${holder}
|
|
33307
|
+
throw new Error(`No block ${ref.block} in ${holder}.${await deletedPostClause(ref)}`);
|
|
32879
33308
|
}
|
|
32880
33309
|
throw error;
|
|
32881
33310
|
}),
|
|
@@ -33077,7 +33506,9 @@ function renderSessionAnswerItem(item) {
|
|
|
33077
33506
|
const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
|
|
33078
33507
|
const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
|
|
33079
33508
|
if (item.edited_at !== undefined)
|
|
33080
|
-
head.push(
|
|
33509
|
+
head.push(editedMark(item.edited_at));
|
|
33510
|
+
if (item.deleted_at !== undefined)
|
|
33511
|
+
head.push(deletedMark(item.deleted_at, item.deleted_by));
|
|
33081
33512
|
const owner = item.owner === null ? undefined : ownerTitle(item.owner);
|
|
33082
33513
|
const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
|
|
33083
33514
|
const lines = [head.join(" \xB7 "), where];
|
|
@@ -33113,6 +33544,7 @@ function sessionAnswersWords(items) {
|
|
|
33113
33544
|
actorActText(item.author.id, item.author.act),
|
|
33114
33545
|
item.at,
|
|
33115
33546
|
item.edited_at ?? null,
|
|
33547
|
+
item.deleted_at ?? null,
|
|
33116
33548
|
item.selected ?? null,
|
|
33117
33549
|
item.text,
|
|
33118
33550
|
item.relation
|
|
@@ -33465,7 +33897,10 @@ function inboxThreadLine(row, now) {
|
|
|
33465
33897
|
return [
|
|
33466
33898
|
`- ${inboxThreadLabel(row)}`,
|
|
33467
33899
|
row.kind,
|
|
33468
|
-
|
|
33900
|
+
...row.deleted_at == null ? [
|
|
33901
|
+
textHead(row.subject, INBOX_QUESTION_HEAD),
|
|
33902
|
+
...row.edited_at == null ? [] : [editedMark(row.edited_at)]
|
|
33903
|
+
] : [deletedMark(row.deleted_at, row.deleted_by)],
|
|
33469
33904
|
actorText(row.reply.author),
|
|
33470
33905
|
inboxReplyAge(row.reply.created_at, now),
|
|
33471
33906
|
row.ref
|
|
@@ -33611,6 +34046,10 @@ var dispatchCommands = {
|
|
|
33611
34046
|
dispatch_comment: acting(commentCommand),
|
|
33612
34047
|
dispatch_suggest: acting(suggestCommand),
|
|
33613
34048
|
dispatch_resolve_comment: acting(resolveCommentCommand),
|
|
34049
|
+
dispatch_edit_comment: acting(editCommentCommand),
|
|
34050
|
+
dispatch_delete_comment: acting(deleteCommentCommand),
|
|
34051
|
+
dispatch_edit_message: acting(editMessageCommand),
|
|
34052
|
+
dispatch_delete_message: acting(deleteMessageCommand),
|
|
33614
34053
|
dispatch_message: acting(messageCommand),
|
|
33615
34054
|
dispatch_send_to_agent: acting(sendToAgentCommand),
|
|
33616
34055
|
dispatch_doc_edit: acting(docEditCommand),
|