@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.
@@ -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) {
@@ -25882,9 +26060,20 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
25882
26060
  },
25883
26061
  ...unrecognised === undefined ? {} : { unrecognised }
25884
26062
  };
26063
+ let card;
26064
+ let payloadShownAsText;
26065
+ try {
26066
+ card = encode5({ envoy: rendered });
26067
+ } catch (error) {
26068
+ const payloadKey = dispatchRendered ? "dispatch" : "message";
26069
+ if (envelope.payload === undefined || !(payloadKey in rendered))
26070
+ throw error;
26071
+ card = encode5({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
26072
+ payloadShownAsText = messageFor(error);
26073
+ }
25885
26074
  return {
25886
26075
  skip: false,
25887
- content: trailer === "" ? encode5({ envoy: rendered }) : `${encode5({ envoy: rendered })}
26076
+ content: trailer === "" ? card : `${card}
25888
26077
 
25889
26078
  ${trailer}`,
25890
26079
  envelope,
@@ -25893,7 +26082,8 @@ ${trailer}`,
25893
26082
  ...rejectedDelivery === undefined ? {} : { rejectedDelivery },
25894
26083
  ...malformedDelivery ? { malformedDelivery: true } : {},
25895
26084
  ...pictures.length === 0 ? {} : { pictures },
25896
- ...cutItem === undefined ? {} : { cutItem }
26085
+ ...cutItem === undefined ? {} : { cutItem },
26086
+ ...payloadShownAsText === undefined ? {} : { payloadShownAsText }
25897
26087
  };
25898
26088
  }
25899
26089
 
@@ -25948,8 +26138,9 @@ async function textWithPictures(text, pictures, owner, upload, actor) {
25948
26138
  uploaded = await upload({ name: picture.name, file: picture.file, actor });
25949
26139
  } catch (error) {
25950
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;
25951
26142
  const refused = error instanceof DispatchGatewayError ? !error.mayHaveReachedDispatch : error instanceof DispatchServiceError && error.status < 500;
25952
- 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";
25953
26144
  throw new Error(`images: ${picture.path} ${outcome}: ${messageFor(error).replace(/\.$/, "")}. Nothing ` + `was posted${earlier}.`);
25954
26145
  }
25955
26146
  const address = `dispatch://${owner}/artifact/${uploaded.artifact.slug}@v${uploaded.version.number}`;
@@ -25970,7 +26161,10 @@ function parseAgentArtifactRef(ref) {
25970
26161
  return { session, slug, ...version === undefined ? {} : { version: Number(version) } };
25971
26162
  }
25972
26163
  function datedBodies(records) {
25973
- 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
+ }));
25974
26168
  }
25975
26169
  function askTexts({ ask, replies }) {
25976
26170
  return [
@@ -26005,6 +26199,7 @@ function eventTexts(event) {
26005
26199
  case "suggestion.rejected":
26006
26200
  case "message.created":
26007
26201
  case "message.answered":
26202
+ case "message.edited":
26008
26203
  texts = [event.payload.body];
26009
26204
  break;
26010
26205
  default:
@@ -26480,7 +26675,7 @@ function normalizeUUID(value) {
26480
26675
  return `${compact.slice(0, 8)}-${compact.slice(8, 12)}-${compact.slice(12, 16)}-${compact.slice(16, 20)}-${compact.slice(20)}`.toLowerCase();
26481
26676
  }
26482
26677
  var askIdProblem = "ask must be a bare ask id or a dispatch://.../ask/<id> reference";
26483
- 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";
26484
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>)";
26485
26680
  function askId(args) {
26486
26681
  const ask = stringArg(args, "ask");
@@ -26493,6 +26688,23 @@ function messageIdOf(value) {
26493
26688
  })() : value;
26494
26689
  return id === undefined ? undefined : normalizeUUID(id);
26495
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
+ }
26496
26708
  function itemBlockOf(value) {
26497
26709
  const ref = parseDispatchRef(value);
26498
26710
  return ref?.item === undefined || ref.block === undefined ? undefined : { ...ref, item: ref.item, block: ref.block };
@@ -26542,7 +26754,7 @@ async function refuseItemOffRef(tool, kind, ref, refText, item, documentId) {
26542
26754
  return;
26543
26755
  }
26544
26756
  }
26545
- 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}`;
26546
26758
  throw new ToolInputError(tool, [
26547
26759
  `${refText} names ${kind} ${item.id} on ${refOwnerName(ref)}, but it is on ${where}`
26548
26760
  ]);
@@ -26626,6 +26838,10 @@ var issueFreeTools = {
26626
26838
  dispatch_edit_ask: true,
26627
26839
  dispatch_resolve_ask: true,
26628
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,
26629
26845
  dispatch_follow: true,
26630
26846
  dispatch_search: true,
26631
26847
  dispatch_related: true,
@@ -26672,13 +26888,25 @@ function argumentProblems(tool, args) {
26672
26888
  }
26673
26889
  break;
26674
26890
  }
26675
- case "dispatch_resolve_comment": {
26891
+ case "dispatch_resolve_comment":
26892
+ case "dispatch_edit_comment":
26893
+ case "dispatch_delete_comment": {
26676
26894
  const comment = optionalString(args, "comment");
26677
- 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") {
26678
26898
  problems.push(itemRefProblem(comment) ?? commentIdProblem);
26679
26899
  }
26680
26900
  break;
26681
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
+ }
26682
26910
  case "dispatch_comment": {
26683
26911
  if (optionalString(args, "quote") !== undefined && optionalString(args, "artifact") === undefined) {
26684
26912
  problems.push("artifact is required when quote is supplied");
@@ -26709,7 +26937,12 @@ function argumentProblems(tool, args) {
26709
26937
  case "dispatch_read": {
26710
26938
  const message = optionalString(args, "message");
26711
26939
  if (message !== undefined && messageIdOf(message) === undefined) {
26712
- 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>");
26713
26946
  }
26714
26947
  const events = optionalNumber(args, "events");
26715
26948
  const allEvents = optionalBoolean(args, "all_events") === true;
@@ -26991,6 +27224,21 @@ function refusalWithCode(error, ...clauses) {
26991
27224
  function dispatchAnswered(error, status) {
26992
27225
  return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
26993
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
+ }
26994
27242
  function writeMayHaveLanded(error) {
26995
27243
  if (error instanceof DispatchGatewayError)
26996
27244
  return error.mayHaveReachedDispatch;
@@ -27001,10 +27249,29 @@ function withAccount(error, account) {
27001
27249
  const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
27002
27250
  return new Error(told, { cause: error });
27003
27251
  }
27252
+ function dispatchNotFound(error) {
27253
+ return !(error instanceof DispatchNoRouteError) && dispatchAnswered(error, 404) && error.code === "NOT_FOUND";
27254
+ }
27004
27255
 
27005
- // ../envoy-client/src/dispatch-commands/document-targets.ts
27006
27256
  class DocumentNotFoundError extends Error {
27007
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
27008
27275
  function artifactByReference(artifacts, artifactReference, owner, canonical) {
27009
27276
  const bySlug = artifacts.find((candidate) => candidate.slug === artifactReference);
27010
27277
  if (canonical && bySlug !== undefined)
@@ -27200,6 +27467,9 @@ async function resolveExistingIssue(client, issueReference) {
27200
27467
  throw error;
27201
27468
  }
27202
27469
  }
27470
+ function readRefOwner(client, owner, readDocument) {
27471
+ return async () => owner.kind === "issue" ? client.getIssue(owner.issue) : readDocument();
27472
+ }
27203
27473
 
27204
27474
  // ../envoy-client/src/dispatch-commands/command-context.ts
27205
27475
  function toolActor(origin, input) {
@@ -27258,32 +27528,21 @@ async function commandContext(session) {
27258
27528
  };
27259
27529
  }
27260
27530
 
27261
- // ../envoy-client/src/actor-text.ts
27262
- function actorText(actor) {
27263
- if (actor.kind === "user") {
27264
- return actorActText(`user ${actor.id}`, actor.act);
27265
- }
27266
- const service = actor.kind === "session" ? actor.service : undefined;
27267
- if (service === undefined) {
27268
- return `${actor.kind} ${actor.id}`;
27269
- }
27270
- return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
27271
- }
27272
-
27273
27531
  // ../envoy-client/src/search-answer.ts
27274
27532
  function pageSummaryText(offset, count, total) {
27275
27533
  return `showing ${offset + 1}-${offset + count} of ${total}`;
27276
27534
  }
27277
27535
  function searchHitLine(result, linkBase) {
27278
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);
27279
27538
  const { owner } = result;
27280
27539
  if (owner.kind === "document") {
27281
27540
  const reference = dispatchDocumentRef(owner.project ?? "", owner.slug ?? "");
27282
- return `${reference} [document] ${owner.name} - ${result.kind}: ${snippetText(result.snippet)} -> ${href}`;
27541
+ return `${reference} [document] ${owner.name} - ${result.kind}: ${text} -> ${href}`;
27283
27542
  }
27284
27543
  const artifactName = result.artifact ? ` ${result.artifact.name}` : "";
27285
27544
  const label = `${owner.key} [${owner.status}] ${owner.title} - ${result.kind}${artifactName}`;
27286
- return `${label}: ${snippetText(result.snippet)} -> ${href}`;
27545
+ return `${label}: ${text} -> ${href}`;
27287
27546
  }
27288
27547
  function indentedText(text) {
27289
27548
  return text.split(/\r?\n/u).join(`
@@ -27654,7 +27913,8 @@ function isItemKind(kind) {
27654
27913
  }
27655
27914
  function edgeLine(edge) {
27656
27915
  const { node } = edge;
27657
- 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 `;
27658
27918
  const block = edge.block === undefined ? "" : ` (block ${edge.block.ref ?? edge.block.id})`;
27659
27919
  const parent = node.parent ?? undefined;
27660
27920
  const item = node.kind === "block" && node.document === undefined && isItemKind(parent?.kind) ? parent : undefined;
@@ -27724,7 +27984,7 @@ function blockLines(node, ref, typed, noun = "Block") {
27724
27984
  ...node.changed_version === undefined ? [] : [`Changed in version: ${node.changed_version}`],
27725
27985
  ...node.text === undefined ? [] : ["Text:", node.text]
27726
27986
  ] : [
27727
- `${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)}:`,
27728
27988
  ...node.text === undefined ? [] : [node.text]
27729
27989
  ];
27730
27990
  const { pin } = node;
@@ -27887,7 +28147,9 @@ function olderServerWarnings(issue) {
27887
28147
  }
27888
28148
  var STRUCTURAL_EDGES_IN = ["child_of", "blocked_by"];
27889
28149
  function referenceLinkLine({ kinds, node, via }, near) {
27890
- 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}`;
27891
28153
  }
27892
28154
  function memberLines(references) {
27893
28155
  const members = references.members ?? [];
@@ -27975,6 +28237,13 @@ function logSummary(issue, events) {
27975
28237
  ].join(`
27976
28238
  `);
27977
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
+ }
27978
28247
  function eventHead(event) {
27979
28248
  switch (event.type) {
27980
28249
  case "ask.opened":
@@ -27995,11 +28264,14 @@ function eventHead(event) {
27995
28264
  case "comment.edited":
27996
28265
  case "comment.resolved":
27997
28266
  case "comment.reopened":
28267
+ case "comment.deleted":
27998
28268
  case "suggestion.accepted":
27999
28269
  case "suggestion.rejected":
28000
28270
  case "message.created":
28001
28271
  case "message.answered":
28002
- return textHead(event.payload.body);
28272
+ case "message.edited":
28273
+ case "message.deleted":
28274
+ return postEventHead(event.payload);
28003
28275
  case "artifact.version":
28004
28276
  return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
28005
28277
  case "artifact.approved":
@@ -28822,7 +29094,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
28822
29094
  const partRef = (id) => `${askRef}#b-${encodeBlockId(id)}`;
28823
29095
  const chain = (replies ?? []).flatMap((reply) => [
28824
29096
  `${reply.id} \xB7 ${actorText(reply.author)}`,
28825
- `Body: ${reply.body}`
29097
+ ...postBodyLines(reply)
28826
29098
  ]);
28827
29099
  const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
28828
29100
  return [
@@ -28930,19 +29202,42 @@ function formatOpenAsksSummary(response, linkBase) {
28930
29202
  ].join(`
28931
29203
  `);
28932
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
+ }
28933
29228
  function commentSummary({ comment, replies }, graph) {
28934
29229
  const root = [
28935
29230
  `${comment.id} \xB7 ${actorText(comment.author)}`,
28936
29231
  ...anchorLines(comment),
28937
29232
  ...replyBlockLines(comment),
28938
- `Body: ${comment.body}`
29233
+ ...postBodyLines(comment)
28939
29234
  ];
28940
29235
  const chain = (replies ?? []).flatMap((reply) => [
28941
29236
  `${reply.id} \xB7 ${actorText(reply.author)}`,
28942
29237
  ...anchorLines(reply),
28943
29238
  ...replyBlockLines(reply),
28944
29239
  ...reply.answers != null && reply.answers !== comment.id ? [`Answers: ${reply.answers}`] : [],
28945
- `Body: ${reply.body}`
29240
+ ...postBodyLines(reply)
28946
29241
  ]);
28947
29242
  return [
28948
29243
  "Comment:",
@@ -28957,8 +29252,13 @@ function replyBlockLines(record) {
28957
29252
  const block = record.reply_block;
28958
29253
  if (block === undefined || block === null)
28959
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
+ }
28960
29260
  return [
28961
- 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)
28962
29262
  ];
28963
29263
  }
28964
29264
  function anchorLines(record) {
@@ -28987,12 +29287,12 @@ function messageSummary({ message, replies }, graph) {
28987
29287
  const root = [
28988
29288
  `${message.id} \xB7 ${actorText(message.author)}`,
28989
29289
  ...replyBlockLines(message),
28990
- `Body: ${message.body}`
29290
+ ...postBodyLines(message)
28991
29291
  ];
28992
29292
  const chain = (replies ?? []).flatMap((reply) => [
28993
29293
  `${reply.id} \xB7 ${actorText(reply.author)}`,
28994
29294
  ...replyBlockLines(reply),
28995
- `Body: ${reply.body}`
29295
+ ...postBodyLines(reply)
28996
29296
  ]);
28997
29297
  return [
28998
29298
  "Message:",
@@ -29036,7 +29336,7 @@ async function openAnchoredThreads(client, resolved) {
29036
29336
  const commentThreads = roots.map((root) => [
29037
29337
  `comment ${root.id} \xB7 ${actorText(root.author)} \xB7 ${root.created_at}`,
29038
29338
  ...anchorLines(root),
29039
- `Body: ${root.body}`,
29339
+ ...postBodyLines(root),
29040
29340
  ...threadReplyLines(replies.get(root.id) ?? [])
29041
29341
  ].join(`
29042
29342
  `));
@@ -29045,7 +29345,7 @@ async function openAnchoredThreads(client, resolved) {
29045
29345
  function threadReplyLines(replies) {
29046
29346
  return replies.flatMap((reply) => [
29047
29347
  `reply ${reply.id} \xB7 ${actorText(reply.author)} \xB7 ${reply.created_at}`,
29048
- `Body: ${reply.body}`
29348
+ ...postBodyLines(reply)
29049
29349
  ]);
29050
29350
  }
29051
29351
  function threadRootId(comment, byId) {
@@ -29323,28 +29623,116 @@ async function followCommand(context) {
29323
29623
  }
29324
29624
 
29325
29625
  // ../envoy-client/src/dispatch-commands/conversation.ts
29326
- async function resolveCommentCommand(context) {
29327
- const { args, client, actor, input } = context;
29328
- const reference = stringArg(args, "comment");
29626
+ async function resolveCommentArgument(tool, reference, client) {
29329
29627
  const ref = reference.startsWith("dispatch://") ? parseDispatchRef(reference) : null;
29628
+ if (ref === null)
29629
+ return { id: reference };
29330
29630
  let id = reference;
29331
29631
  let document;
29332
- if (ref?.owner.kind === "issue") {
29632
+ if (ref.owner.kind === "issue") {
29333
29633
  const issueKey = ref.owner.issue;
29334
- id = await resolveIdPrefix(input.tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
29335
- } else if (ref !== null) {
29634
+ id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
29635
+ } else {
29336
29636
  const artifact = (await resolveArtifact(client, ref.owner, ref.artifact, { canonical: true })).artifact;
29337
29637
  document = artifact;
29338
- id = await resolveIdPrefix(input.tool, "comment", ref.id, refOwnerName(ref), () => client.getArtifactComments(artifact.id));
29339
- }
29340
- if (ref !== null) {
29341
- const read = await client.getComment(id);
29342
- 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));
29343
29639
  }
29344
- 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
+ });
29345
29676
  const { label, details } = await commentOwnerResult(client, comment, document);
29346
29677
  return { text: `Resolved comment ${comment.id} on ${label}.`, details };
29347
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
+ }
29348
29736
  async function commentCommand(context) {
29349
29737
  const { args, client, actor, input, documentOwner, resolveDocument, writePictures, issue } = context;
29350
29738
  const artifactReference = optionalString(args, "artifact");
@@ -29934,6 +30322,9 @@ function artifactNameExistsProblem(held, owner) {
29934
30322
  return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
29935
30323
  }
29936
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
+ }
29937
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)}.`;
29938
30329
  if (!dispatchAnswered(error, 413)) {
29939
30330
  return `${failure} Send the upload again once that call is answered.`;
@@ -30643,9 +31034,12 @@ async function readCommand(context) {
30643
31034
  shown,
30644
31035
  documentOwner,
30645
31036
  resolveDocument,
30646
- issue
31037
+ issue,
31038
+ configUrl,
31039
+ hostSession
30647
31040
  } = context;
30648
31041
  const message = optionalString(args, "message");
31042
+ const history = optionalBoolean(args, "history") === true;
30649
31043
  const picturesOf = (texts) => readPictures(client, picturesNewestFirst(texts), shown);
30650
31044
  const showImages = (pictures) => {
30651
31045
  for (const address of pictures.shown)
@@ -30676,9 +31070,21 @@ async function readCommand(context) {
30676
31070
  refDocumentId ??= resolveDocument(ref.owner, ref.artifact).then((resolved) => resolved.artifact.id);
30677
31071
  return refDocumentId;
30678
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
+ };
30679
31083
  if (ownerArguments.ref?.kind === "ask") {
30680
31084
  const ref = ownerArguments.ref;
30681
- 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
+ });
30682
31088
  await refuseItemOffRef(input.tool, "ask", ref, stringArg(args, "ref"), askRead.ask, () => documentIdOf(ref));
30683
31089
  const askRef = refTarget(ref, "ask", askRead.ask.id);
30684
31090
  const [pictures, incoming, outgoing] = await Promise.all([
@@ -30695,8 +31101,16 @@ async function readCommand(context) {
30695
31101
  if (ownerArguments.ref?.kind === "comment") {
30696
31102
  const ref = ownerArguments.ref;
30697
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)));
30698
- 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
+ });
30699
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
+ }
30700
31114
  const commentRef = refTarget(ref, "comment", id);
30701
31115
  const [pictures, graph] = await Promise.all([
30702
31116
  picturesOf(datedBodies([comment.comment, ...comment.replies ?? []])),
@@ -30712,7 +31126,18 @@ async function readCommand(context) {
30712
31126
  if (ownerArguments.ref.owner.kind !== "issue") {
30713
31127
  throw new Error("message references are issue-scoped");
30714
31128
  }
30715
- 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
+ });
30716
31141
  const messageRef = dispatchChildRef(dispatchIssueRef(ownerArguments.ref.owner.issue), "message", ownerArguments.ref.id);
30717
31142
  const [pictures, graph] = await Promise.all([
30718
31143
  picturesOf(datedBodies([messageRead.message, ...messageRead.replies ?? []])),
@@ -30732,9 +31157,9 @@ async function readCommand(context) {
30732
31157
  return;
30733
31158
  }) : undefined;
30734
31159
  const [incoming, outgoing, partOf, typed] = await Promise.all([
30735
- client.getReferences({ to: blockRef }).catch((error) => {
31160
+ client.getReferences({ to: blockRef }).catch(async (error) => {
30736
31161
  if (ref.pin === undefined && dispatchAnswered(error, 404)) {
30737
- throw new Error(`No block ${ref.block} in ${holder}.`);
31162
+ throw new Error(`No block ${ref.block} in ${holder}.${await deletedPostClause(ref)}`);
30738
31163
  }
30739
31164
  throw error;
30740
31165
  }),
@@ -30936,7 +31361,9 @@ function renderSessionAnswerItem(item) {
30936
31361
  const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
30937
31362
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
30938
31363
  if (item.edited_at !== undefined)
30939
- 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));
30940
31367
  const owner = item.owner === null ? undefined : ownerTitle(item.owner);
30941
31368
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
30942
31369
  const lines = [head.join(" \xB7 "), where];
@@ -30972,6 +31399,7 @@ function sessionAnswersWords(items) {
30972
31399
  actorActText(item.author.id, item.author.act),
30973
31400
  item.at,
30974
31401
  item.edited_at ?? null,
31402
+ item.deleted_at ?? null,
30975
31403
  item.selected ?? null,
30976
31404
  item.text,
30977
31405
  item.relation
@@ -31324,7 +31752,10 @@ function inboxThreadLine(row, now) {
31324
31752
  return [
31325
31753
  `- ${inboxThreadLabel(row)}`,
31326
31754
  row.kind,
31327
- 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)],
31328
31759
  actorText(row.reply.author),
31329
31760
  inboxReplyAge(row.reply.created_at, now),
31330
31761
  row.ref
@@ -31470,6 +31901,10 @@ var dispatchCommands = {
31470
31901
  dispatch_comment: acting(commentCommand),
31471
31902
  dispatch_suggest: acting(suggestCommand),
31472
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),
31473
31908
  dispatch_message: acting(messageCommand),
31474
31909
  dispatch_send_to_agent: acting(sendToAgentCommand),
31475
31910
  dispatch_doc_edit: acting(docEditCommand),