@sjawhar/claude-envoy 5.18.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.
@@ -17287,6 +17287,7 @@ var PROJECT_NAME_MAX = 80;
17287
17287
  var MAX_ISSUE_PAGE_LIMIT = 250;
17288
17288
  var DEFAULT_ISSUE_PAGE_LIMIT = 50;
17289
17289
  var DEFAULT_ISSUE_READ_EVENTS = 10;
17290
+ var POST_HISTORY_PAGE_LIMIT = 200;
17290
17291
  var ASK_TURNS = ["human", "agent"];
17291
17292
  var DELIVERY_CAPABILITIES = ["aside", "btw", "steer"];
17292
17293
  var DELIVERY_ATTEMPT_STATES = ["pending", "sent", "queued", "failed"];
@@ -17344,10 +17345,29 @@ var replyBlockFields = {
17344
17345
  ref: string2().optional(),
17345
17346
  block_id: string2(),
17346
17347
  text: string2(),
17347
- removed: boolean2()
17348
+ removed: boolean2(),
17349
+ edited_at: string2().optional(),
17350
+ deleted_at: string2().optional()
17348
17351
  };
17349
- var WrittenReplyBlockSchema = strictObject(replyBlockFields).readonly();
17350
- var ReplyBlockSchema = object(replyBlockFields);
17352
+ var DocumentActorSchema = object({
17353
+ kind: string2(),
17354
+ id: string2(),
17355
+ act: object({
17356
+ session: string2().optional(),
17357
+ token_id: string2().optional(),
17358
+ token_name: string2().optional(),
17359
+ scopes: array(string2()).optional()
17360
+ }).optional(),
17361
+ origin: ActorOriginSchema.optional(),
17362
+ owner: string2().optional(),
17363
+ service: string2().optional(),
17364
+ project: string2().optional()
17365
+ });
17366
+ var WrittenReplyBlockSchema = strictObject({ ...replyBlockFields, deleted_by: ActorSchema.optional() }).readonly();
17367
+ var ReplyBlockSchema = object({
17368
+ ...replyBlockFields,
17369
+ deleted_by: DocumentActorSchema.optional()
17370
+ });
17351
17371
 
17352
17372
  // ../contracts/src/dispatch-api-documents.ts
17353
17373
  var versionFields = {
@@ -17672,18 +17692,26 @@ var messageValidation = {
17672
17692
  var readOwner = documentOwnerValidation(false);
17673
17693
  var READ_OWNER_RULE = "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one.";
17674
17694
  var READ_MESSAGE_RULE = "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.";
17695
+ 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.";
17675
17696
  function readProblem(value) {
17676
17697
  const input = value;
17698
+ const historyKept = input.history !== true || typeof input.ref === "string";
17677
17699
  if (typeof input.message !== "string") {
17678
- return readOwner.check(value) ? undefined : READ_OWNER_RULE;
17700
+ return brokenParts([
17701
+ [readOwner.check(value), READ_OWNER_RULE],
17702
+ [historyKept, READ_HISTORY_RULE]
17703
+ ]);
17679
17704
  }
17680
17705
  const alone = input.issue === undefined && input.project === undefined && input.artifact === undefined && input.ref === undefined;
17681
- return alone ? undefined : READ_MESSAGE_RULE;
17706
+ return brokenParts([
17707
+ [alone, READ_MESSAGE_RULE],
17708
+ [historyKept, READ_HISTORY_RULE]
17709
+ ]);
17682
17710
  }
17683
17711
  var readValidation = {
17684
17712
  check: (value) => readProblem(value) === undefined,
17685
- message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`,
17686
- refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`
17713
+ message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`,
17714
+ refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`
17687
17715
  };
17688
17716
  var ISSUE_COMPONENTS_MODES = ["inherit", "explicit", "none"];
17689
17717
  function componentsArgument(z) {
@@ -17703,6 +17731,8 @@ var ASK_URGENCIES = ["low", "med", "high", "blocking"];
17703
17731
  var DISPATCH_BLOCK_UNITS = 32000;
17704
17732
  var DISPATCH_ITEM_BLOCKS = 32768;
17705
17733
  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`.";
17734
+ 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.";
17735
+ 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.";
17706
17736
  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.";
17707
17737
  var DISPATCH_HANDOFF_BODY_MAX = 262144;
17708
17738
  var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
@@ -17974,7 +18004,7 @@ var dispatchToolSpecs = [
17974
18004
  example: { comment: "01234567-0000-4000-8000-000000000001" },
17975
18005
  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.",
17976
18006
  arguments: (z) => ({
17977
- comment: z.string().describe("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.")
18007
+ comment: z.string().describe(COMMENT_ARGUMENT)
17978
18008
  }),
17979
18009
  strict: true
17980
18010
  },
@@ -18029,6 +18059,28 @@ var dispatchToolSpecs = [
18029
18059
  }),
18030
18060
  validation: documentOwnerValidation(true, true)
18031
18061
  },
18062
+ {
18063
+ name: "dispatch_edit_comment",
18064
+ example: {
18065
+ comment: "01234567-0000-4000-8000-000000000001",
18066
+ body: "Corrected: the retry window is 72 hours, not 24."
18067
+ },
18068
+ 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}`,
18069
+ arguments: (z) => ({
18070
+ comment: z.string().describe(COMMENT_ARGUMENT),
18071
+ body: z.string().describe(`The comment's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
18072
+ }),
18073
+ strict: true
18074
+ },
18075
+ {
18076
+ name: "dispatch_delete_comment",
18077
+ example: { comment: "01234567-0000-4000-8000-000000000001" },
18078
+ 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.",
18079
+ arguments: (z) => ({
18080
+ comment: z.string().describe(COMMENT_ARGUMENT)
18081
+ }),
18082
+ strict: true
18083
+ },
18032
18084
  {
18033
18085
  name: "dispatch_message",
18034
18086
  example: { issue: "DSP-1", body: "Implementation started." },
@@ -18041,6 +18093,28 @@ var dispatchToolSpecs = [
18041
18093
  }),
18042
18094
  validation: messageValidation
18043
18095
  },
18096
+ {
18097
+ name: "dispatch_edit_message",
18098
+ example: {
18099
+ message: "01234567-0000-4000-8000-000000000001",
18100
+ body: "Corrected: the export runs at 02:00 UTC, not 02:00 local."
18101
+ },
18102
+ 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}`,
18103
+ arguments: (z) => ({
18104
+ message: z.string().describe(MESSAGE_ARGUMENT),
18105
+ body: z.string().describe(`The message's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
18106
+ }),
18107
+ strict: true
18108
+ },
18109
+ {
18110
+ name: "dispatch_delete_message",
18111
+ example: { message: "01234567-0000-4000-8000-000000000001" },
18112
+ 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.",
18113
+ arguments: (z) => ({
18114
+ message: z.string().describe(MESSAGE_ARGUMENT)
18115
+ }),
18116
+ strict: true
18117
+ },
18044
18118
  {
18045
18119
  name: "dispatch_send_to_agent",
18046
18120
  example: {
@@ -18207,7 +18281,7 @@ var dispatchToolSpecs = [
18207
18281
  {
18208
18282
  name: "dispatch_read",
18209
18283
  example: { issue: "DSP-1" },
18210
- 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,
18284
+ 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,
18211
18285
  arguments: (z) => ({
18212
18286
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
18213
18287
  project: z.string().describe("Project key owning the document.").optional(),
@@ -18215,7 +18289,8 @@ var dispatchToolSpecs = [
18215
18289
  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(),
18216
18290
  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(),
18217
18291
  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(),
18218
- 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()
18292
+ 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(),
18293
+ 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()
18219
18294
  }),
18220
18295
  validation: readValidation
18221
18296
  },
@@ -18753,6 +18828,8 @@ var commentFields = {
18753
18828
  resolved_by: ActorSchema.nullable(),
18754
18829
  resolved_at: string2().nullable(),
18755
18830
  edited_at: string2().nullable(),
18831
+ deleted_at: string2().nullable(),
18832
+ deleted_by: ActorSchema.nullable(),
18756
18833
  suggestion: SuggestionSchema.nullable(),
18757
18834
  created_at: string2(),
18758
18835
  mentions: array(WrittenCommentMentionSchema),
@@ -18764,6 +18841,10 @@ var commentEventPayloadFields = {
18764
18841
  ...commentFields,
18765
18842
  mentions: array(WrittenCommentMentionSchema).optional(),
18766
18843
  deliveries: array(WrittenCommentDeliverySchema).optional(),
18844
+ body: commentFields.body.optional(),
18845
+ suggestion: commentFields.suggestion.optional(),
18846
+ deleted_at: commentFields.deleted_at.optional(),
18847
+ deleted_by: commentFields.deleted_by.optional(),
18767
18848
  artifact_name: string2(),
18768
18849
  project_key: string2().optional(),
18769
18850
  artifact_slug: string2().optional(),
@@ -18771,6 +18852,12 @@ var commentEventPayloadFields = {
18771
18852
  ask_state: askFields.state.optional(),
18772
18853
  ask_waiting_on: _enum2(ASK_TURNS).optional(),
18773
18854
  ask_sessions: array(string2()).optional(),
18855
+ thread_root_id: string2().optional(),
18856
+ renamed_version: strictObject({
18857
+ artifact_id: string2(),
18858
+ number: number2().int().positive(),
18859
+ summary: string2()
18860
+ }).readonly().optional(),
18774
18861
  ...referenceChangesFields,
18775
18862
  ...threadLoginsFields,
18776
18863
  ...carriedBodyFields
@@ -18801,6 +18888,8 @@ var CommentEventPayloadSchema = object({
18801
18888
  suggestion: object({ replace_with: suggestionFields.replace_with.optional() }).nullish(),
18802
18889
  author: InboundActorSchema.optional(),
18803
18890
  created_at: commentFields.created_at.optional(),
18891
+ deleted_at: commentFields.deleted_at.optional(),
18892
+ deleted_by: InboundActorSchema.nullish(),
18804
18893
  mentions: array(CommentMentionSchema).optional(),
18805
18894
  deliveries: array(CommentDeliverySchema).optional(),
18806
18895
  reply_block: ReplyBlockSchema.nullish(),
@@ -18857,6 +18946,7 @@ var EVENT_TYPE_MEMBERS = {
18857
18946
  "comment.anchor_refreshed": true,
18858
18947
  "comment.answered": true,
18859
18948
  "comment.created": true,
18949
+ "comment.deleted": true,
18860
18950
  "comment.delivery": true,
18861
18951
  "comment.edited": true,
18862
18952
  "comment.reopened": true,
@@ -18873,7 +18963,9 @@ var EVENT_TYPE_MEMBERS = {
18873
18963
  "message.accepted": true,
18874
18964
  "message.answered": true,
18875
18965
  "message.created": true,
18966
+ "message.deleted": true,
18876
18967
  "message.delivery": true,
18968
+ "message.edited": true,
18877
18969
  "priority.updated": true,
18878
18970
  "project.created": true,
18879
18971
  "project.updated": true,
@@ -18947,11 +19039,18 @@ var messageFields = {
18947
19039
  broadcast_id: string2().nullable().optional(),
18948
19040
  deliveries: array(MessageDeliverySchema),
18949
19041
  created_at: string2(),
19042
+ edited_at: string2().nullable(),
19043
+ deleted_at: string2().nullable(),
19044
+ deleted_by: ActorSchema.nullable(),
18950
19045
  reply_block: WrittenReplyBlockSchema.nullable().optional()
18951
19046
  };
18952
19047
  var MessageSchema = strictObject(messageFields).readonly();
18953
19048
  var messageEventPayloadFields = {
18954
19049
  ...messageFields,
19050
+ body: messageFields.body.optional(),
19051
+ edited_at: messageFields.edited_at.optional(),
19052
+ deleted_at: messageFields.deleted_at.optional(),
19053
+ deleted_by: messageFields.deleted_by.optional(),
18955
19054
  reply_body: string2().optional(),
18956
19055
  thread_target: string2().optional(),
18957
19056
  ...referenceChangesFields,
@@ -18966,6 +19065,9 @@ var MessageEventPayloadSchema = object({
18966
19065
  in_reply_to: messageFields.in_reply_to.optional(),
18967
19066
  reply_body: messageEventPayloadFields.reply_body,
18968
19067
  thread_target: messageEventPayloadFields.thread_target,
19068
+ edited_at: messageFields.edited_at.optional(),
19069
+ deleted_at: messageFields.deleted_at.optional(),
19070
+ deleted_by: InboundActorSchema.nullish(),
18969
19071
  author: InboundActorSchema.optional(),
18970
19072
  reply_block: ReplyBlockSchema.nullish(),
18971
19073
  thread_logins: threadLoginsFields.thread_logins,
@@ -23143,6 +23245,27 @@ function resolveDecodeOptions(options) {
23143
23245
  };
23144
23246
  }
23145
23247
 
23248
+ // ../envoy-client/src/actor-text.ts
23249
+ function actorText(actor) {
23250
+ if (actor.kind === "user") {
23251
+ return actorActText(`user ${actor.id}`, actor.act);
23252
+ }
23253
+ const service = actor.kind === "session" ? actor.service : undefined;
23254
+ if (service === undefined) {
23255
+ return `${actor.kind} ${actor.id}`;
23256
+ }
23257
+ return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
23258
+ }
23259
+ function deletedMark(at, by) {
23260
+ return `Deleted by ${by == null ? "its author" : actorText(by)} at ${at}`;
23261
+ }
23262
+ function editedMark(at) {
23263
+ return `edited ${at}`;
23264
+ }
23265
+ function withEditedMark(words, at) {
23266
+ return at == null ? words : `${words} \xB7 ${editedMark(at)}`;
23267
+ }
23268
+
23146
23269
  // ../envoy-client/src/ask-answer.ts
23147
23270
  var HEAD_LENGTH = 120;
23148
23271
  function textHead(text, length = HEAD_LENGTH) {
@@ -23861,13 +23984,23 @@ class DispatchWriteLandedError extends Error {
23861
23984
  status;
23862
23985
  name = "DispatchWriteLandedError";
23863
23986
  constructor(code, status, method, shownUrl) {
23864
- const lost = code === IDEMPOTENCY_ANSWER_NOT_KEPT ? "Dispatch kept no copy of its answer, which was too large" : "its answer was lost on the way back";
23987
+ 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";
23865
23988
  const request = `${method} ${shownUrl}`;
23866
23989
  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.");
23867
23990
  this.code = code;
23868
23991
  this.status = status;
23869
23992
  }
23870
23993
  }
23994
+
23995
+ class DispatchAnswerNotKeptError extends Error {
23996
+ status;
23997
+ name = "DispatchAnswerNotKeptError";
23998
+ code = IDEMPOTENCY_ANSWER_NOT_KEPT;
23999
+ constructor(status, method, shownUrl) {
24000
+ 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.");
24001
+ this.status = status;
24002
+ }
24003
+ }
23871
24004
  function asErrorShape(value) {
23872
24005
  return typeof value === "object" && value !== null ? value : {};
23873
24006
  }
@@ -24177,8 +24310,8 @@ class DispatchClient {
24177
24310
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
24178
24311
  }
24179
24312
  async markdownRoundTrip(markdown) {
24180
- const { payload } = await this.#jsonAnswer("POST", ["api", "v1", "markdown", "round-trip"], { markdown }, { writes: false });
24181
- return payload.markdown;
24313
+ const answer = await this.#writingNothing(["api", "v1", "markdown", "round-trip"], { markdown }, { writes: false });
24314
+ return answer.markdown;
24182
24315
  }
24183
24316
  async listProjectArtifacts(project, unlinked = false) {
24184
24317
  return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
@@ -24211,7 +24344,7 @@ class DispatchClient {
24211
24344
  return this.#json("GET", path, undefined, request);
24212
24345
  }
24213
24346
  async related(project, input) {
24214
- return this.#json("POST", ["api", "v1", "projects", project, "related"], input);
24347
+ return this.#writingNothing(["api", "v1", "projects", project, "related"], input);
24215
24348
  }
24216
24349
  async getIssue(issue) {
24217
24350
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue)]);
@@ -24385,10 +24518,7 @@ class DispatchClient {
24385
24518
  async dryRunResult(issue, input) {
24386
24519
  const path = ["api", "v1", "issues", await this.#resolveIssue(issue), "results", "dry-run"];
24387
24520
  try {
24388
- const { payload } = await this.#jsonAnswer("POST", path, input, {
24389
- writes: false
24390
- });
24391
- return payload;
24521
+ return await this.#writingNothing(path, input, { writes: false });
24392
24522
  } catch (error) {
24393
24523
  if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
24394
24524
  throw error;
@@ -24461,7 +24591,19 @@ class DispatchClient {
24461
24591
  ]);
24462
24592
  }
24463
24593
  async getMessageThread(id, session) {
24464
- return this.#json("GET", ["api", "v1", "messages", id], undefined, { session });
24594
+ return this.#json("GET", ["api", "v1", "messages", id], undefined, session === undefined ? undefined : { session });
24595
+ }
24596
+ async editMessage(id, input) {
24597
+ return this.#json("PATCH", ["api", "v1", "messages", id], input);
24598
+ }
24599
+ async deleteMessage(id, actor) {
24600
+ return this.#json("DELETE", ["api", "v1", "messages", id], { actor });
24601
+ }
24602
+ async messageHistory(id, session) {
24603
+ return this.#json("GET", ["api", "v1", "messages", id, "history"], undefined, session === undefined ? undefined : { session });
24604
+ }
24605
+ async issueMessages(issue) {
24606
+ return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "messages"]);
24465
24607
  }
24466
24608
  async acceptMessageDelivery(id, attempt, input) {
24467
24609
  return this.#json("POST", ["api", "v1", "messages", id, "deliveries", String(attempt), "accept"], input);
@@ -24535,6 +24677,15 @@ class DispatchClient {
24535
24677
  async resolveComment(id, actor) {
24536
24678
  return this.#json("POST", ["api", "v1", "comments", id, "resolve"], { actor });
24537
24679
  }
24680
+ async editComment(id, input) {
24681
+ return this.#json("PATCH", ["api", "v1", "comments", id], input);
24682
+ }
24683
+ async deleteComment(id, actor) {
24684
+ return this.#json("DELETE", ["api", "v1", "comments", id], { actor });
24685
+ }
24686
+ async commentHistory(id) {
24687
+ return this.#json("GET", ["api", "v1", "comments", id, "history"]);
24688
+ }
24538
24689
  async getComments(issue) {
24539
24690
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "comments"]);
24540
24691
  }
@@ -24654,6 +24805,20 @@ class DispatchClient {
24654
24805
  }
24655
24806
  return this.#noRoute(async () => this.#response(method, url, await this.#send(method, url, body)));
24656
24807
  }
24808
+ async#writingNothing(path, body, options = {}) {
24809
+ for (let keys = 1;; keys++) {
24810
+ try {
24811
+ return (await this.#jsonAnswer("POST", path, body, options)).payload;
24812
+ } catch (error) {
24813
+ if (!(error instanceof DispatchWriteLandedError) || error.code !== IDEMPOTENCY_ANSWER_NOT_KEPT) {
24814
+ throw error;
24815
+ }
24816
+ if (keys === 2) {
24817
+ throw new DispatchAnswerNotKeptError(error.status, "POST", requestForText(this.#baseUrl, this.#url(path), DISPATCH_URL_SETTING));
24818
+ }
24819
+ }
24820
+ }
24821
+ }
24657
24822
  async#send(method, url, body, accept = "application/json", signal) {
24658
24823
  const sent = await this.#sendOnce(method, url, body, accept, signal);
24659
24824
  if (this.#credential.stale === undefined || !await tokenNotLive(sent.answer)) {
@@ -25344,12 +25509,22 @@ function carriedBodyNote(event) {
25344
25509
  }
25345
25510
  async function wholeCarriedBody(client, item, session) {
25346
25511
  try {
25512
+ let posts;
25347
25513
  if (item.resource === "comment") {
25348
25514
  const read = await client.getComment(item.id);
25349
- return [read.comment, ...read.replies ?? []].find((comment) => comment.id === item.id)?.body;
25515
+ posts = [read.comment, ...read.replies ?? []];
25516
+ } else {
25517
+ if (item.issueKey === null && session === undefined)
25518
+ return;
25519
+ const read = item.issueKey === null ? await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
25520
+ posts = [read.message, ...read.replies ?? []];
25350
25521
  }
25351
- const read = item.issueKey === null ? session === undefined ? undefined : await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
25352
- return read === undefined ? undefined : [read.message, ...read.replies ?? []].find((message) => message.id === item.id)?.body;
25522
+ const post = posts.find((candidate) => candidate.id === item.id);
25523
+ if (post === undefined)
25524
+ return;
25525
+ if (post.deleted_at != null)
25526
+ return deletedMark(post.deleted_at, post.deleted_by);
25527
+ return withEditedMark(post.body, post.edited_at);
25353
25528
  } catch {
25354
25529
  return;
25355
25530
  }
@@ -25389,11 +25564,14 @@ var DISPATCH_PAYLOAD_SCHEMAS = {
25389
25564
  "comment.resolved": CommentEventPayloadSchema,
25390
25565
  "comment.reopened": CommentEventPayloadSchema,
25391
25566
  "comment.edited": CommentEventPayloadSchema,
25567
+ "comment.deleted": CommentEventPayloadSchema,
25392
25568
  "suggestion.accepted": CommentEventPayloadSchema,
25393
25569
  "suggestion.rejected": CommentEventPayloadSchema,
25394
25570
  "message.created": MessageEventPayloadSchema,
25395
25571
  "message.delivery": MessageDeliveryEventPayloadSchema,
25396
25572
  "message.answered": MessageEventPayloadSchema,
25573
+ "message.edited": MessageEventPayloadSchema,
25574
+ "message.deleted": MessageEventPayloadSchema,
25397
25575
  "child.status": ChildStatusEventPayloadSchema
25398
25576
  };
25399
25577
  function topicDocument(topic) {
@@ -25960,8 +26138,9 @@ async function textWithPictures(text, pictures, owner, upload, actor) {
25960
26138
  uploaded = await upload({ name: picture.name, file: picture.file, actor });
25961
26139
  } catch (error) {
25962
26140
  const earlier = addresses.length === 0 ? "" : `; the pictures before it are uploaded (${addresses.join(", ")})`;
26141
+ const landed = error instanceof DispatchWriteLandedError || error instanceof Error && error.cause instanceof DispatchWriteLandedError;
25963
26142
  const refused = error instanceof DispatchGatewayError ? !error.mayHaveReachedDispatch : error instanceof DispatchServiceError && error.status < 500;
25964
- const outcome = refused ? "was not uploaded" : "may or may not have been uploaded";
26143
+ const outcome = landed ? "was uploaded" : refused ? "was not uploaded" : "may or may not have been uploaded";
25965
26144
  throw new Error(`images: ${picture.path} ${outcome}: ${messageFor(error).replace(/\.$/, "")}. Nothing ` + `was posted${earlier}.`);
25966
26145
  }
25967
26146
  const address = `dispatch://${owner}/artifact/${uploaded.artifact.slug}@v${uploaded.version.number}`;
@@ -25982,7 +26161,10 @@ function parseAgentArtifactRef(ref) {
25982
26161
  return { session, slug, ...version === undefined ? {} : { version: Number(version) } };
25983
26162
  }
25984
26163
  function datedBodies(records) {
25985
- return records.map((record) => ({ text: record.body, at: record.created_at }));
26164
+ return records.map((record) => ({
26165
+ text: record.body,
26166
+ at: record.edited_at ?? record.created_at
26167
+ }));
25986
26168
  }
25987
26169
  function askTexts({ ask, replies }) {
25988
26170
  return [
@@ -26017,6 +26199,7 @@ function eventTexts(event) {
26017
26199
  case "suggestion.rejected":
26018
26200
  case "message.created":
26019
26201
  case "message.answered":
26202
+ case "message.edited":
26020
26203
  texts = [event.payload.body];
26021
26204
  break;
26022
26205
  default:
@@ -26492,7 +26675,7 @@ function normalizeUUID(value) {
26492
26675
  return `${compact.slice(0, 8)}-${compact.slice(8, 12)}-${compact.slice(12, 16)}-${compact.slice(16, 20)}-${compact.slice(20)}`.toLowerCase();
26493
26676
  }
26494
26677
  var askIdProblem = "ask must be a bare ask id or a dispatch://.../ask/<id> reference";
26495
- var commentIdProblem = "comment must be a bare comment id or a dispatch://.../comment/<id> reference";
26678
+ 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";
26496
26679
  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>)";
26497
26680
  function askId(args) {
26498
26681
  const ask = stringArg(args, "ask");
@@ -26505,6 +26688,23 @@ function messageIdOf(value) {
26505
26688
  })() : value;
26506
26689
  return id === undefined ? undefined : normalizeUUID(id);
26507
26690
  }
26691
+ var messageArgumentProblem = (argument) => `${argument} must be a full message id (uuid) or a dispatch://KEY/message/<id> reference`;
26692
+ function messageArgumentId(value) {
26693
+ if (!value.startsWith("dispatch://")) {
26694
+ const bare = normalizeUUID(value);
26695
+ return bare === undefined ? undefined : { id: bare };
26696
+ }
26697
+ const ref = parseDispatchRef(value);
26698
+ if (ref?.kind !== "message")
26699
+ return;
26700
+ const full = normalizeUUID(ref.id);
26701
+ const owner = ref.owner;
26702
+ if (owner.kind !== "issue")
26703
+ return full === undefined ? undefined : { id: full };
26704
+ if (full === undefined && !isIdPrefix(ref.id))
26705
+ return;
26706
+ return { id: full ?? ref.id, ref: { ...ref, owner } };
26707
+ }
26508
26708
  function itemBlockOf(value) {
26509
26709
  const ref = parseDispatchRef(value);
26510
26710
  return ref?.item === undefined || ref.block === undefined ? undefined : { ...ref, item: ref.item, block: ref.block };
@@ -26554,7 +26754,7 @@ async function refuseItemOffRef(tool, kind, ref, refText, item, documentId) {
26554
26754
  return;
26555
26755
  }
26556
26756
  }
26557
- const where = item.issue_key === null ? "another document" : `${item.issue_key}; name it dispatch://${item.issue_key}/${kind}/${item.id}`;
26757
+ 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}`;
26558
26758
  throw new ToolInputError(tool, [
26559
26759
  `${refText} names ${kind} ${item.id} on ${refOwnerName(ref)}, but it is on ${where}`
26560
26760
  ]);
@@ -26638,6 +26838,10 @@ var issueFreeTools = {
26638
26838
  dispatch_edit_ask: true,
26639
26839
  dispatch_resolve_ask: true,
26640
26840
  dispatch_resolve_comment: true,
26841
+ dispatch_edit_comment: true,
26842
+ dispatch_delete_comment: true,
26843
+ dispatch_edit_message: true,
26844
+ dispatch_delete_message: true,
26641
26845
  dispatch_follow: true,
26642
26846
  dispatch_search: true,
26643
26847
  dispatch_related: true,
@@ -26684,13 +26888,25 @@ function argumentProblems(tool, args) {
26684
26888
  }
26685
26889
  break;
26686
26890
  }
26687
- case "dispatch_resolve_comment": {
26891
+ case "dispatch_resolve_comment":
26892
+ case "dispatch_edit_comment":
26893
+ case "dispatch_delete_comment": {
26688
26894
  const comment = optionalString(args, "comment");
26689
- if (comment?.startsWith("dispatch://") && parseDispatchRef(comment)?.kind !== "comment") {
26895
+ if (comment !== undefined && !comment.startsWith("dispatch://") && normalizeUUID(comment) === undefined && !isIdPrefix(comment)) {
26896
+ problems.push(commentIdProblem);
26897
+ } else if (comment?.startsWith("dispatch://") && parseDispatchRef(comment)?.kind !== "comment") {
26690
26898
  problems.push(itemRefProblem(comment) ?? commentIdProblem);
26691
26899
  }
26692
26900
  break;
26693
26901
  }
26902
+ case "dispatch_edit_message":
26903
+ case "dispatch_delete_message": {
26904
+ const message = optionalString(args, "message");
26905
+ if (message !== undefined && messageArgumentId(message) === undefined) {
26906
+ problems.push(messageArgumentProblem("message"));
26907
+ }
26908
+ break;
26909
+ }
26694
26910
  case "dispatch_comment": {
26695
26911
  if (optionalString(args, "quote") !== undefined && optionalString(args, "artifact") === undefined) {
26696
26912
  problems.push("artifact is required when quote is supplied");
@@ -26721,7 +26937,12 @@ function argumentProblems(tool, args) {
26721
26937
  case "dispatch_read": {
26722
26938
  const message = optionalString(args, "message");
26723
26939
  if (message !== undefined && messageIdOf(message) === undefined) {
26724
- problems.push("message must be a full message id (uuid) or a dispatch://KEY/message/<id> reference");
26940
+ problems.push(messageArgumentProblem("message"));
26941
+ }
26942
+ const historyRef = optionalBoolean(args, "history") === true ? optionalString(args, "ref") : undefined;
26943
+ const historyKind = historyRef === undefined ? undefined : parseDispatchRef(historyRef)?.kind;
26944
+ if (historyRef !== undefined && historyKind !== "comment" && historyKind !== "message") {
26945
+ 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>");
26725
26946
  }
26726
26947
  const events = optionalNumber(args, "events");
26727
26948
  const allEvents = optionalBoolean(args, "all_events") === true;
@@ -27003,6 +27224,21 @@ function refusalWithCode(error, ...clauses) {
27003
27224
  function dispatchAnswered(error, status) {
27004
27225
  return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
27005
27226
  }
27227
+ var OLDER_COMMENT_EDIT_ACTOR = 'invalid JSON body: json: unknown field "actor"';
27228
+ async function throughPostCorrections(tool, url, call, post) {
27229
+ try {
27230
+ return await call;
27231
+ } catch (error) {
27232
+ 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);
27233
+ if (!(error instanceof DispatchNoRouteError) && !commentEditIsAge) {
27234
+ throw post === undefined ? error : refuseMissingPost(error, post);
27235
+ }
27236
+ 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.");
27237
+ }
27238
+ }
27239
+ function refuseMissingPost(error, post) {
27240
+ return dispatchNotFound(error) ? refusalWithCode(error, `this Dispatch holds no ${post.kind} ${post.id}`) : error;
27241
+ }
27006
27242
  function writeMayHaveLanded(error) {
27007
27243
  if (error instanceof DispatchGatewayError)
27008
27244
  return error.mayHaveReachedDispatch;
@@ -27013,10 +27249,29 @@ function withAccount(error, account) {
27013
27249
  const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
27014
27250
  return new Error(told, { cause: error });
27015
27251
  }
27252
+ function dispatchNotFound(error) {
27253
+ return !(error instanceof DispatchNoRouteError) && dispatchAnswered(error, 404) && error.code === "NOT_FOUND";
27254
+ }
27016
27255
 
27017
- // ../envoy-client/src/dispatch-commands/document-targets.ts
27018
27256
  class DocumentNotFoundError extends Error {
27019
27257
  }
27258
+ async function refuseMissingOfRef(error, kind, id, owner, ownerName, readOwner) {
27259
+ if (!dispatchNotFound(error))
27260
+ return error;
27261
+ const missingOwner = await readOwner().then(() => {
27262
+ return;
27263
+ }, (caught) => {
27264
+ if (owner.kind === "issue" && dispatchNotFound(caught)) {
27265
+ return refusalWithCode(error, `this Dispatch holds no issue ${owner.issue}`);
27266
+ }
27267
+ if (caught instanceof DocumentNotFoundError)
27268
+ return caught;
27269
+ return refusalWithCode(error, `the read of ${ownerName} failed, so this does not say whether ${ownerName} exists or` + ` holds ${kind} ${id}: ${messageFor(caught)}`);
27270
+ });
27271
+ return missingOwner ?? refusalWithCode(error, `${ownerName} holds no ${kind} ${id}`);
27272
+ }
27273
+
27274
+ // ../envoy-client/src/dispatch-commands/document-targets.ts
27020
27275
  function artifactByReference(artifacts, artifactReference, owner, canonical) {
27021
27276
  const bySlug = artifacts.find((candidate) => candidate.slug === artifactReference);
27022
27277
  if (canonical && bySlug !== undefined)
@@ -27212,6 +27467,9 @@ async function resolveExistingIssue(client, issueReference) {
27212
27467
  throw error;
27213
27468
  }
27214
27469
  }
27470
+ function readRefOwner(client, owner, readDocument) {
27471
+ return async () => owner.kind === "issue" ? client.getIssue(owner.issue) : readDocument();
27472
+ }
27215
27473
 
27216
27474
  // ../envoy-client/src/dispatch-commands/command-context.ts
27217
27475
  function toolActor(origin, input) {
@@ -27270,32 +27528,21 @@ async function commandContext(session) {
27270
27528
  };
27271
27529
  }
27272
27530
 
27273
- // ../envoy-client/src/actor-text.ts
27274
- function actorText(actor) {
27275
- if (actor.kind === "user") {
27276
- return actorActText(`user ${actor.id}`, actor.act);
27277
- }
27278
- const service = actor.kind === "session" ? actor.service : undefined;
27279
- if (service === undefined) {
27280
- return `${actor.kind} ${actor.id}`;
27281
- }
27282
- return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
27283
- }
27284
-
27285
27531
  // ../envoy-client/src/search-answer.ts
27286
27532
  function pageSummaryText(offset, count, total) {
27287
27533
  return `showing ${offset + 1}-${offset + count} of ${total}`;
27288
27534
  }
27289
27535
  function searchHitLine(result, linkBase) {
27290
27536
  const href = linkFor(result.href, linkBase);
27537
+ const text = result.deleted_at == null ? withEditedMark(snippetText(result.snippet), result.edited_at) : deletedMark(result.deleted_at, result.deleted_by);
27291
27538
  const { owner } = result;
27292
27539
  if (owner.kind === "document") {
27293
27540
  const reference = dispatchDocumentRef(owner.project ?? "", owner.slug ?? "");
27294
- return `${reference} [document] ${owner.name} - ${result.kind}: ${snippetText(result.snippet)} -> ${href}`;
27541
+ return `${reference} [document] ${owner.name} - ${result.kind}: ${text} -> ${href}`;
27295
27542
  }
27296
27543
  const artifactName = result.artifact ? ` ${result.artifact.name}` : "";
27297
27544
  const label = `${owner.key} [${owner.status}] ${owner.title} - ${result.kind}${artifactName}`;
27298
- return `${label}: ${snippetText(result.snippet)} -> ${href}`;
27545
+ return `${label}: ${text} -> ${href}`;
27299
27546
  }
27300
27547
  function indentedText(text) {
27301
27548
  return text.split(/\r?\n/u).join(`
@@ -27666,7 +27913,8 @@ function isItemKind(kind) {
27666
27913
  }
27667
27914
  function edgeLine(edge) {
27668
27915
  const { node } = edge;
27669
- const excerpt = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
27916
+ const words = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
27917
+ 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 `;
27670
27918
  const block = edge.block === undefined ? "" : ` (block ${edge.block.ref ?? edge.block.id})`;
27671
27919
  const parent = node.parent ?? undefined;
27672
27920
  const item = node.kind === "block" && node.document === undefined && isItemKind(parent?.kind) ? parent : undefined;
@@ -27736,7 +27984,7 @@ function blockLines(node, ref, typed, noun = "Block") {
27736
27984
  ...node.changed_version === undefined ? [] : [`Changed in version: ${node.changed_version}`],
27737
27985
  ...node.text === undefined ? [] : ["Text:", node.text]
27738
27986
  ] : [
27739
- `${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}:`,
27987
+ `${withEditedMark(`${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}`, node.edited_at)}:`,
27740
27988
  ...node.text === undefined ? [] : [node.text]
27741
27989
  ];
27742
27990
  const { pin } = node;
@@ -27899,7 +28147,9 @@ function olderServerWarnings(issue) {
27899
28147
  }
27900
28148
  var STRUCTURAL_EDGES_IN = ["child_of", "blocked_by"];
27901
28149
  function referenceLinkLine({ kinds, node, via }, near) {
27902
- return `- ${(kinds ?? []).join(",")} ${node.kind} ${node.ref ?? node.id} \xB7 ${near} ${via.kind} ${via.id}`;
28150
+ const address = node.ref ?? node.id;
28151
+ const target = node.deleted_at == null ? withEditedMark(address, node.edited_at) : `${address} \xB7 ${deletedMark(node.deleted_at, node.deleted_by)}`;
28152
+ return `- ${(kinds ?? []).join(",")} ${node.kind} ${target} \xB7 ${near} ${via.kind} ${via.id}`;
27903
28153
  }
27904
28154
  function memberLines(references) {
27905
28155
  const members = references.members ?? [];
@@ -27987,6 +28237,13 @@ function logSummary(issue, events) {
27987
28237
  ].join(`
27988
28238
  `);
27989
28239
  }
28240
+ function postEventHead(payload) {
28241
+ if (payload.deleted_at != null)
28242
+ return deletedMark(payload.deleted_at, payload.deleted_by);
28243
+ if (payload.body === undefined)
28244
+ return;
28245
+ return withEditedMark(textHead(payload.body), payload.edited_at);
28246
+ }
27990
28247
  function eventHead(event) {
27991
28248
  switch (event.type) {
27992
28249
  case "ask.opened":
@@ -28007,11 +28264,14 @@ function eventHead(event) {
28007
28264
  case "comment.edited":
28008
28265
  case "comment.resolved":
28009
28266
  case "comment.reopened":
28267
+ case "comment.deleted":
28010
28268
  case "suggestion.accepted":
28011
28269
  case "suggestion.rejected":
28012
28270
  case "message.created":
28013
28271
  case "message.answered":
28014
- return textHead(event.payload.body);
28272
+ case "message.edited":
28273
+ case "message.deleted":
28274
+ return postEventHead(event.payload);
28015
28275
  case "artifact.version":
28016
28276
  return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
28017
28277
  case "artifact.approved":
@@ -28834,7 +29094,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
28834
29094
  const partRef = (id) => `${askRef}#b-${encodeBlockId(id)}`;
28835
29095
  const chain = (replies ?? []).flatMap((reply) => [
28836
29096
  `${reply.id} \xB7 ${actorText(reply.author)}`,
28837
- `Body: ${reply.body}`
29097
+ ...postBodyLines(reply)
28838
29098
  ]);
28839
29099
  const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
28840
29100
  return [
@@ -28942,19 +29202,42 @@ function formatOpenAsksSummary(response, linkBase) {
28942
29202
  ].join(`
28943
29203
  `);
28944
29204
  }
29205
+ function postBodyLines(post) {
29206
+ if (post.deleted_at != null)
29207
+ return [deletedMark(post.deleted_at, post.deleted_by)];
29208
+ return [...post.edited_at == null ? [] : [`Edited: ${post.edited_at}`], `Body: ${post.body}`];
29209
+ }
29210
+ function postHistorySummary(kind, ref, id, read) {
29211
+ const entries = read.entries ?? [];
29212
+ const deleted = read.deleted_at != null;
29213
+ const oldest = entries.at(-1);
29214
+ const route = `/api/v1/${kind === "Comment" ? "comments" : "messages"}/${id}/history`;
29215
+ return [
29216
+ `${kind} history: ${ref}`,
29217
+ ...read.deleted_at == null ? [] : [deletedMark(read.deleted_at, read.deleted_by)],
29218
+ ...entries.length === 0 ? ["- none"] : entries.flatMap((entry) => [
29219
+ `${entry.edited_at} \xB7 ${actorText(entry.edited_by)}`,
29220
+ ...deleted ? [] : [`Body: ${entry.body}`]
29221
+ ]),
29222
+ ...entries.length < POST_HISTORY_PAGE_LIMIT || oldest === undefined ? [] : [
29223
+ `This is the newest page, and a page holds ${POST_HISTORY_PAGE_LIMIT} rows: GET ${route}?before=${oldest.edited_at} reads any older rows.`
29224
+ ]
29225
+ ].join(`
29226
+ `);
29227
+ }
28945
29228
  function commentSummary({ comment, replies }, graph) {
28946
29229
  const root = [
28947
29230
  `${comment.id} \xB7 ${actorText(comment.author)}`,
28948
29231
  ...anchorLines(comment),
28949
29232
  ...replyBlockLines(comment),
28950
- `Body: ${comment.body}`
29233
+ ...postBodyLines(comment)
28951
29234
  ];
28952
29235
  const chain = (replies ?? []).flatMap((reply) => [
28953
29236
  `${reply.id} \xB7 ${actorText(reply.author)}`,
28954
29237
  ...anchorLines(reply),
28955
29238
  ...replyBlockLines(reply),
28956
29239
  ...reply.answers != null && reply.answers !== comment.id ? [`Answers: ${reply.answers}`] : [],
28957
- `Body: ${reply.body}`
29240
+ ...postBodyLines(reply)
28958
29241
  ]);
28959
29242
  return [
28960
29243
  "Comment:",
@@ -28969,8 +29252,13 @@ function replyBlockLines(record) {
28969
29252
  const block = record.reply_block;
28970
29253
  if (block === undefined || block === null)
28971
29254
  return [];
29255
+ if (block.deleted_at != null) {
29256
+ return [
29257
+ `Re: block ${block.block_id} (parent deleted): ${deletedMark(block.deleted_at, block.deleted_by)}`
29258
+ ];
29259
+ }
28972
29260
  return [
28973
- block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}`
29261
+ withEditedMark(block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}`, block.edited_at)
28974
29262
  ];
28975
29263
  }
28976
29264
  function anchorLines(record) {
@@ -28999,12 +29287,12 @@ function messageSummary({ message, replies }, graph) {
28999
29287
  const root = [
29000
29288
  `${message.id} \xB7 ${actorText(message.author)}`,
29001
29289
  ...replyBlockLines(message),
29002
- `Body: ${message.body}`
29290
+ ...postBodyLines(message)
29003
29291
  ];
29004
29292
  const chain = (replies ?? []).flatMap((reply) => [
29005
29293
  `${reply.id} \xB7 ${actorText(reply.author)}`,
29006
29294
  ...replyBlockLines(reply),
29007
- `Body: ${reply.body}`
29295
+ ...postBodyLines(reply)
29008
29296
  ]);
29009
29297
  return [
29010
29298
  "Message:",
@@ -29048,7 +29336,7 @@ async function openAnchoredThreads(client, resolved) {
29048
29336
  const commentThreads = roots.map((root) => [
29049
29337
  `comment ${root.id} \xB7 ${actorText(root.author)} \xB7 ${root.created_at}`,
29050
29338
  ...anchorLines(root),
29051
- `Body: ${root.body}`,
29339
+ ...postBodyLines(root),
29052
29340
  ...threadReplyLines(replies.get(root.id) ?? [])
29053
29341
  ].join(`
29054
29342
  `));
@@ -29057,7 +29345,7 @@ async function openAnchoredThreads(client, resolved) {
29057
29345
  function threadReplyLines(replies) {
29058
29346
  return replies.flatMap((reply) => [
29059
29347
  `reply ${reply.id} \xB7 ${actorText(reply.author)} \xB7 ${reply.created_at}`,
29060
- `Body: ${reply.body}`
29348
+ ...postBodyLines(reply)
29061
29349
  ]);
29062
29350
  }
29063
29351
  function threadRootId(comment, byId) {
@@ -29335,28 +29623,116 @@ async function followCommand(context) {
29335
29623
  }
29336
29624
 
29337
29625
  // ../envoy-client/src/dispatch-commands/conversation.ts
29338
- async function resolveCommentCommand(context) {
29339
- const { args, client, actor, input } = context;
29340
- const reference = stringArg(args, "comment");
29626
+ async function resolveCommentArgument(tool, reference, client) {
29341
29627
  const ref = reference.startsWith("dispatch://") ? parseDispatchRef(reference) : null;
29628
+ if (ref === null)
29629
+ return { id: reference };
29342
29630
  let id = reference;
29343
29631
  let document;
29344
- if (ref?.owner.kind === "issue") {
29632
+ if (ref.owner.kind === "issue") {
29345
29633
  const issueKey = ref.owner.issue;
29346
- id = await resolveIdPrefix(input.tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
29347
- } else if (ref !== null) {
29634
+ id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
29635
+ } else {
29348
29636
  const artifact = (await resolveArtifact(client, ref.owner, ref.artifact, { canonical: true })).artifact;
29349
29637
  document = artifact;
29350
- id = await resolveIdPrefix(input.tool, "comment", ref.id, refOwnerName(ref), () => client.getArtifactComments(artifact.id));
29351
- }
29352
- if (ref !== null) {
29353
- const read = await client.getComment(id);
29354
- await refuseItemOffRef(input.tool, "comment", ref, reference, read.comment, async () => document === undefined ? "" : document.id);
29638
+ id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getArtifactComments(artifact.id));
29355
29639
  }
29356
- const comment = await client.resolveComment(id, actor);
29640
+ const read = await client.getComment(id).catch(async (error) => {
29641
+ throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, async () => document));
29642
+ });
29643
+ await refuseItemOffRef(tool, "comment", ref, reference, read.comment, async () => document === undefined ? "" : document.id);
29644
+ return { id, ...document === undefined ? {} : { document } };
29645
+ }
29646
+ async function resolveMessageArgument(tool, argument, reference, client, session) {
29647
+ const named = messageArgumentId(reference);
29648
+ if (named === undefined)
29649
+ throw new ToolInputError(tool, [messageArgumentProblem(argument)]);
29650
+ const ref = named.ref;
29651
+ if (ref === undefined)
29652
+ return named.id;
29653
+ const issueKey = ref.owner.issue;
29654
+ const id = await resolveIdPrefix(tool, "message", named.id, issueKey, async () => (await client.issueMessages(issueKey)).flatMap((thread) => [
29655
+ thread.message,
29656
+ ...thread.replies ?? []
29657
+ ]));
29658
+ const read = await client.getMessageThread(id, session === "" ? undefined : session).catch(async (error) => {
29659
+ throw await refuseMissingOfRef(error, "message", id, ref.owner, issueKey, () => client.getIssue(issueKey));
29660
+ });
29661
+ await refuseItemOffRef(tool, "message", ref, reference, { id, issue_key: read.message.issue_key }, async () => "");
29662
+ return id;
29663
+ }
29664
+ function messageIssueKey(message) {
29665
+ if (message.issue_key === null)
29666
+ throw new Error("the corrected message names no issue");
29667
+ return message.issue_key;
29668
+ }
29669
+ async function resolveCommentCommand(context) {
29670
+ const { args, client, actor, input } = context;
29671
+ const reference = stringArg(args, "comment");
29672
+ const { id, document } = await resolveCommentArgument(input.tool, reference, client);
29673
+ const comment = await client.resolveComment(id, actor).catch((error) => {
29674
+ throw refuseMissingPost(error, { kind: "comment", id });
29675
+ });
29357
29676
  const { label, details } = await commentOwnerResult(client, comment, document);
29358
29677
  return { text: `Resolved comment ${comment.id} on ${label}.`, details };
29359
29678
  }
29679
+ async function editCommentCommand(context) {
29680
+ const { args, client, actor, input, configUrl } = context;
29681
+ const reference = stringArg(args, "comment");
29682
+ const { id, document } = await resolveCommentArgument(input.tool, reference, client);
29683
+ const comment = await throughPostCorrections(input.tool, configUrl, client.editComment(id, { body: stringArg(args, "body"), actor }), { kind: "comment", id });
29684
+ const { label, details } = await commentOwnerResult(client, comment, document);
29685
+ return { text: `Edited comment ${comment.id} on ${label}.`, details };
29686
+ }
29687
+ 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.";
29688
+ 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.";
29689
+ async function throughDelete(context, call, post) {
29690
+ try {
29691
+ return await throughPostCorrections(context.input.tool, context.configUrl, call, post);
29692
+ } catch (error) {
29693
+ if (dispatchAnswered(error, 409) && error.code === "DELETE_CONTENDED") {
29694
+ throw refusalWithCode(error, `${post.kind} ${post.id} stands: run the same dispatch delete-${post.kind} command again`);
29695
+ }
29696
+ throw error;
29697
+ }
29698
+ }
29699
+ async function deleteCommentCommand(context) {
29700
+ const { args, client, actor, input } = context;
29701
+ const reference = stringArg(args, "comment");
29702
+ const { id, document } = await resolveCommentArgument(input.tool, reference, client);
29703
+ const comment = await throughDelete(context, client.deleteComment(id, actor), {
29704
+ kind: "comment",
29705
+ id
29706
+ });
29707
+ const { label, details } = await commentOwnerResult(client, comment, document);
29708
+ return {
29709
+ text: `Deleted comment ${comment.id} on ${label}. ${DELETED_COMMENT_READS}`,
29710
+ details
29711
+ };
29712
+ }
29713
+ async function editMessageCommand(context) {
29714
+ const { args, client, actor, input, configUrl, hostSession } = context;
29715
+ const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
29716
+ const message = await throughPostCorrections(input.tool, configUrl, client.editMessage(id, { body: stringArg(args, "body"), actor }), { kind: "message", id });
29717
+ const issue = messageIssueKey(message);
29718
+ return {
29719
+ text: `Edited message ${message.id} on ${issue}.`,
29720
+ details: { issue, message: message.id }
29721
+ };
29722
+ }
29723
+ async function deleteMessageCommand(context) {
29724
+ const { args, client, actor, input, hostSession } = context;
29725
+ const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
29726
+ const message = await throughDelete(context, client.deleteMessage(id, actor), {
29727
+ kind: "message",
29728
+ id
29729
+ });
29730
+ const issue = messageIssueKey(message);
29731
+ return {
29732
+ text: `Deleted message ${message.id} on ${issue}. ${DELETED_MESSAGE_READS}`,
29733
+ details: { issue, message: message.id }
29734
+ };
29735
+ }
29360
29736
  async function commentCommand(context) {
29361
29737
  const { args, client, actor, input, documentOwner, resolveDocument, writePictures, issue } = context;
29362
29738
  const artifactReference = optionalString(args, "artifact");
@@ -29946,6 +30322,9 @@ function artifactNameExistsProblem(held, owner) {
29946
30322
  return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
29947
30323
  }
29948
30324
  function storedTextCheckFailed(error, name) {
30325
+ if (error instanceof DispatchAnswerNotKeptError) {
30326
+ 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.`;
30327
+ }
29949
30328
  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)}.`;
29950
30329
  if (!dispatchAnswered(error, 413)) {
29951
30330
  return `${failure} Send the upload again once that call is answered.`;
@@ -30655,9 +31034,12 @@ async function readCommand(context) {
30655
31034
  shown,
30656
31035
  documentOwner,
30657
31036
  resolveDocument,
30658
- issue
31037
+ issue,
31038
+ configUrl,
31039
+ hostSession
30659
31040
  } = context;
30660
31041
  const message = optionalString(args, "message");
31042
+ const history = optionalBoolean(args, "history") === true;
30661
31043
  const picturesOf = (texts) => readPictures(client, picturesNewestFirst(texts), shown);
30662
31044
  const showImages = (pictures) => {
30663
31045
  for (const address of pictures.shown)
@@ -30688,9 +31070,21 @@ async function readCommand(context) {
30688
31070
  refDocumentId ??= resolveDocument(ref.owner, ref.artifact).then((resolved) => resolved.artifact.id);
30689
31071
  return refDocumentId;
30690
31072
  };
31073
+ const deletedPostClause = async (ref) => {
31074
+ const item = ref.item;
31075
+ if (item === undefined || item.kind !== "comment" && item.kind !== "message") {
31076
+ return "";
31077
+ }
31078
+ 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(() => {
31079
+ return;
31080
+ });
31081
+ return deleted == null ? "" : ` This ${item.kind} is deleted.`;
31082
+ };
30691
31083
  if (ownerArguments.ref?.kind === "ask") {
30692
31084
  const ref = ownerArguments.ref;
30693
- 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"));
31085
+ 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) => {
31086
+ throw await refuseMissingOfRef(error, "ask", ref.id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
31087
+ });
30694
31088
  await refuseItemOffRef(input.tool, "ask", ref, stringArg(args, "ref"), askRead.ask, () => documentIdOf(ref));
30695
31089
  const askRef = refTarget(ref, "ask", askRead.ask.id);
30696
31090
  const [pictures, incoming, outgoing] = await Promise.all([
@@ -30707,8 +31101,16 @@ async function readCommand(context) {
30707
31101
  if (ownerArguments.ref?.kind === "comment") {
30708
31102
  const ref = ownerArguments.ref;
30709
31103
  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)));
30710
- const comment = await client.getComment(id);
31104
+ const comment = await client.getComment(id).catch(async (error) => {
31105
+ throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
31106
+ });
30711
31107
  await refuseItemOffRef(input.tool, "comment", ref, stringArg(args, "ref"), comment.comment, () => documentIdOf(ref));
31108
+ if (history) {
31109
+ return {
31110
+ text: postHistorySummary("Comment", refTarget(ref, "comment", id), id, await throughPostCorrections(input.tool, configUrl, client.commentHistory(id))),
31111
+ details: ref.owner.kind === "project" ? { project: ref.owner.project, comment: id } : { issue: comment.comment.issue_key, comment: id }
31112
+ };
31113
+ }
30712
31114
  const commentRef = refTarget(ref, "comment", id);
30713
31115
  const [pictures, graph] = await Promise.all([
30714
31116
  picturesOf(datedBodies([comment.comment, ...comment.replies ?? []])),
@@ -30724,7 +31126,18 @@ async function readCommand(context) {
30724
31126
  if (ownerArguments.ref.owner.kind !== "issue") {
30725
31127
  throw new Error("message references are issue-scoped");
30726
31128
  }
30727
- const messageRead = await client.getMessage(ownerArguments.ref.owner.issue, ownerArguments.ref.id);
31129
+ const messageIssue = ownerArguments.ref.owner.issue;
31130
+ if (history) {
31131
+ const id = await resolveMessageArgument(input.tool, "ref", stringArg(args, "ref"), client, hostSession);
31132
+ return {
31133
+ text: postHistorySummary("Message", dispatchChildRef(dispatchIssueRef(messageIssue), "message", id), id, await throughPostCorrections(input.tool, configUrl, client.messageHistory(id, hostSession === "" ? undefined : hostSession))),
31134
+ details: { issue: messageIssue, message: id }
31135
+ };
31136
+ }
31137
+ const named = ownerArguments.ref;
31138
+ const messageRead = await client.getMessage(messageIssue, named.id).catch(async (error) => {
31139
+ throw await refuseMissingOfRef(error, "message", named.id, { kind: "issue", issue: messageIssue }, messageIssue, () => client.getIssue(messageIssue));
31140
+ });
30728
31141
  const messageRef = dispatchChildRef(dispatchIssueRef(ownerArguments.ref.owner.issue), "message", ownerArguments.ref.id);
30729
31142
  const [pictures, graph] = await Promise.all([
30730
31143
  picturesOf(datedBodies([messageRead.message, ...messageRead.replies ?? []])),
@@ -30744,9 +31157,9 @@ async function readCommand(context) {
30744
31157
  return;
30745
31158
  }) : undefined;
30746
31159
  const [incoming, outgoing, partOf, typed] = await Promise.all([
30747
- client.getReferences({ to: blockRef }).catch((error) => {
31160
+ client.getReferences({ to: blockRef }).catch(async (error) => {
30748
31161
  if (ref.pin === undefined && dispatchAnswered(error, 404)) {
30749
- throw new Error(`No block ${ref.block} in ${holder}.`);
31162
+ throw new Error(`No block ${ref.block} in ${holder}.${await deletedPostClause(ref)}`);
30750
31163
  }
30751
31164
  throw error;
30752
31165
  }),
@@ -30948,7 +31361,9 @@ function renderSessionAnswerItem(item) {
30948
31361
  const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
30949
31362
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
30950
31363
  if (item.edited_at !== undefined)
30951
- head.push(`edited ${item.edited_at}`);
31364
+ head.push(editedMark(item.edited_at));
31365
+ if (item.deleted_at !== undefined)
31366
+ head.push(deletedMark(item.deleted_at, item.deleted_by));
30952
31367
  const owner = item.owner === null ? undefined : ownerTitle(item.owner);
30953
31368
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
30954
31369
  const lines = [head.join(" \xB7 "), where];
@@ -30984,6 +31399,7 @@ function sessionAnswersWords(items) {
30984
31399
  actorActText(item.author.id, item.author.act),
30985
31400
  item.at,
30986
31401
  item.edited_at ?? null,
31402
+ item.deleted_at ?? null,
30987
31403
  item.selected ?? null,
30988
31404
  item.text,
30989
31405
  item.relation
@@ -31336,7 +31752,10 @@ function inboxThreadLine(row, now) {
31336
31752
  return [
31337
31753
  `- ${inboxThreadLabel(row)}`,
31338
31754
  row.kind,
31339
- textHead(row.subject, INBOX_QUESTION_HEAD),
31755
+ ...row.deleted_at == null ? [
31756
+ textHead(row.subject, INBOX_QUESTION_HEAD),
31757
+ ...row.edited_at == null ? [] : [editedMark(row.edited_at)]
31758
+ ] : [deletedMark(row.deleted_at, row.deleted_by)],
31340
31759
  actorText(row.reply.author),
31341
31760
  inboxReplyAge(row.reply.created_at, now),
31342
31761
  row.ref
@@ -31482,6 +31901,10 @@ var dispatchCommands = {
31482
31901
  dispatch_comment: acting(commentCommand),
31483
31902
  dispatch_suggest: acting(suggestCommand),
31484
31903
  dispatch_resolve_comment: acting(resolveCommentCommand),
31904
+ dispatch_edit_comment: acting(editCommentCommand),
31905
+ dispatch_delete_comment: acting(deleteCommentCommand),
31906
+ dispatch_edit_message: acting(editMessageCommand),
31907
+ dispatch_delete_message: acting(deleteMessageCommand),
31485
31908
  dispatch_message: acting(messageCommand),
31486
31909
  dispatch_send_to_agent: acting(sendToAgentCommand),
31487
31910
  dispatch_doc_edit: acting(docEditCommand),