@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.
@@ -13837,6 +13837,7 @@ var PROJECT_NAME_MAX = 80;
13837
13837
  var MAX_ISSUE_PAGE_LIMIT = 250;
13838
13838
  var DEFAULT_ISSUE_PAGE_LIMIT = 50;
13839
13839
  var DEFAULT_ISSUE_READ_EVENTS = 10;
13840
+ var POST_HISTORY_PAGE_LIMIT = 200;
13840
13841
  var ASK_TURNS = ["human", "agent"];
13841
13842
  var DELIVERY_CAPABILITIES = ["aside", "btw", "steer"];
13842
13843
  var DELIVERY_ATTEMPT_STATES = ["pending", "sent", "queued", "failed"];
@@ -13894,10 +13895,29 @@ var replyBlockFields = {
13894
13895
  ref: string2().optional(),
13895
13896
  block_id: string2(),
13896
13897
  text: string2(),
13897
- removed: boolean2()
13898
+ removed: boolean2(),
13899
+ edited_at: string2().optional(),
13900
+ deleted_at: string2().optional()
13898
13901
  };
13899
- var WrittenReplyBlockSchema = strictObject(replyBlockFields).readonly();
13900
- var ReplyBlockSchema = object(replyBlockFields);
13902
+ var DocumentActorSchema = object({
13903
+ kind: string2(),
13904
+ id: string2(),
13905
+ act: object({
13906
+ session: string2().optional(),
13907
+ token_id: string2().optional(),
13908
+ token_name: string2().optional(),
13909
+ scopes: array(string2()).optional()
13910
+ }).optional(),
13911
+ origin: ActorOriginSchema.optional(),
13912
+ owner: string2().optional(),
13913
+ service: string2().optional(),
13914
+ project: string2().optional()
13915
+ });
13916
+ var WrittenReplyBlockSchema = strictObject({ ...replyBlockFields, deleted_by: ActorSchema.optional() }).readonly();
13917
+ var ReplyBlockSchema = object({
13918
+ ...replyBlockFields,
13919
+ deleted_by: DocumentActorSchema.optional()
13920
+ });
13901
13921
 
13902
13922
  // ../contracts/src/dispatch-api-documents.ts
13903
13923
  var versionFields = {
@@ -14222,18 +14242,26 @@ var messageValidation = {
14222
14242
  var readOwner = documentOwnerValidation(false);
14223
14243
  var READ_OWNER_RULE = "Exactly one of issue and project is required; project alone lists its documents, and with artifact names one.";
14224
14244
  var READ_MESSAGE_RULE = "message stands alone: it names the conversation, so name no issue, project, artifact, or ref with it.";
14245
+ 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.";
14225
14246
  function readProblem(value) {
14226
14247
  const input = value;
14248
+ const historyKept = input.history !== true || typeof input.ref === "string";
14227
14249
  if (typeof input.message !== "string") {
14228
- return readOwner.check(value) ? undefined : READ_OWNER_RULE;
14250
+ return brokenParts([
14251
+ [readOwner.check(value), READ_OWNER_RULE],
14252
+ [historyKept, READ_HISTORY_RULE]
14253
+ ]);
14229
14254
  }
14230
14255
  const alone = input.issue === undefined && input.project === undefined && input.artifact === undefined && input.ref === undefined;
14231
- return alone ? undefined : READ_MESSAGE_RULE;
14256
+ return brokenParts([
14257
+ [alone, READ_MESSAGE_RULE],
14258
+ [historyKept, READ_HISTORY_RULE]
14259
+ ]);
14232
14260
  }
14233
14261
  var readValidation = {
14234
14262
  check: (value) => readProblem(value) === undefined,
14235
- message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`,
14236
- refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE}`
14263
+ message: `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`,
14264
+ refusal: (value) => readProblem(value) ?? `${READ_OWNER_RULE} ${READ_MESSAGE_RULE} ${READ_HISTORY_RULE}`
14237
14265
  };
14238
14266
  var ISSUE_COMPONENTS_MODES = ["inherit", "explicit", "none"];
14239
14267
  function componentsArgument(z) {
@@ -14253,6 +14281,8 @@ var ASK_URGENCIES = ["low", "med", "high", "blocking"];
14253
14281
  var DISPATCH_BLOCK_UNITS = 32000;
14254
14282
  var DISPATCH_ITEM_BLOCKS = 32768;
14255
14283
  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`.";
14284
+ 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.";
14285
+ 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.";
14256
14286
  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.";
14257
14287
  var DISPATCH_HANDOFF_BODY_MAX = 262144;
14258
14288
  var HANDOFF_PHASE_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
@@ -14524,7 +14554,7 @@ var dispatchToolSpecs = [
14524
14554
  example: { comment: "01234567-0000-4000-8000-000000000001" },
14525
14555
  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.",
14526
14556
  arguments: (z) => ({
14527
- 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.")
14557
+ comment: z.string().describe(COMMENT_ARGUMENT)
14528
14558
  }),
14529
14559
  strict: true
14530
14560
  },
@@ -14579,6 +14609,28 @@ var dispatchToolSpecs = [
14579
14609
  }),
14580
14610
  validation: documentOwnerValidation(true, true)
14581
14611
  },
14612
+ {
14613
+ name: "dispatch_edit_comment",
14614
+ example: {
14615
+ comment: "01234567-0000-4000-8000-000000000001",
14616
+ body: "Corrected: the retry window is 72 hours, not 24."
14617
+ },
14618
+ 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}`,
14619
+ arguments: (z) => ({
14620
+ comment: z.string().describe(COMMENT_ARGUMENT),
14621
+ body: z.string().describe(`The comment's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
14622
+ }),
14623
+ strict: true
14624
+ },
14625
+ {
14626
+ name: "dispatch_delete_comment",
14627
+ example: { comment: "01234567-0000-4000-8000-000000000001" },
14628
+ 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.",
14629
+ arguments: (z) => ({
14630
+ comment: z.string().describe(COMMENT_ARGUMENT)
14631
+ }),
14632
+ strict: true
14633
+ },
14582
14634
  {
14583
14635
  name: "dispatch_message",
14584
14636
  example: { issue: "DSP-1", body: "Implementation started." },
@@ -14591,6 +14643,28 @@ var dispatchToolSpecs = [
14591
14643
  }),
14592
14644
  validation: messageValidation
14593
14645
  },
14646
+ {
14647
+ name: "dispatch_edit_message",
14648
+ example: {
14649
+ message: "01234567-0000-4000-8000-000000000001",
14650
+ body: "Corrected: the export runs at 02:00 UTC, not 02:00 local."
14651
+ },
14652
+ 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}`,
14653
+ arguments: (z) => ({
14654
+ message: z.string().describe(MESSAGE_ARGUMENT),
14655
+ body: z.string().describe(`The message's new body, which replaces the old one whole. ${BODY_BLOCK_RULE}`)
14656
+ }),
14657
+ strict: true
14658
+ },
14659
+ {
14660
+ name: "dispatch_delete_message",
14661
+ example: { message: "01234567-0000-4000-8000-000000000001" },
14662
+ 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.",
14663
+ arguments: (z) => ({
14664
+ message: z.string().describe(MESSAGE_ARGUMENT)
14665
+ }),
14666
+ strict: true
14667
+ },
14594
14668
  {
14595
14669
  name: "dispatch_send_to_agent",
14596
14670
  example: {
@@ -14757,7 +14831,7 @@ var dispatchToolSpecs = [
14757
14831
  {
14758
14832
  name: "dispatch_read",
14759
14833
  example: { issue: "DSP-1" },
14760
- 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,
14834
+ 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,
14761
14835
  arguments: (z) => ({
14762
14836
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
14763
14837
  project: z.string().describe("Project key owning the document.").optional(),
@@ -14765,7 +14839,8 @@ var dispatchToolSpecs = [
14765
14839
  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(),
14766
14840
  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(),
14767
14841
  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(),
14768
- 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()
14842
+ 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(),
14843
+ 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()
14769
14844
  }),
14770
14845
  validation: readValidation
14771
14846
  },
@@ -15303,6 +15378,8 @@ var commentFields = {
15303
15378
  resolved_by: ActorSchema.nullable(),
15304
15379
  resolved_at: string2().nullable(),
15305
15380
  edited_at: string2().nullable(),
15381
+ deleted_at: string2().nullable(),
15382
+ deleted_by: ActorSchema.nullable(),
15306
15383
  suggestion: SuggestionSchema.nullable(),
15307
15384
  created_at: string2(),
15308
15385
  mentions: array(WrittenCommentMentionSchema),
@@ -15314,6 +15391,10 @@ var commentEventPayloadFields = {
15314
15391
  ...commentFields,
15315
15392
  mentions: array(WrittenCommentMentionSchema).optional(),
15316
15393
  deliveries: array(WrittenCommentDeliverySchema).optional(),
15394
+ body: commentFields.body.optional(),
15395
+ suggestion: commentFields.suggestion.optional(),
15396
+ deleted_at: commentFields.deleted_at.optional(),
15397
+ deleted_by: commentFields.deleted_by.optional(),
15317
15398
  artifact_name: string2(),
15318
15399
  project_key: string2().optional(),
15319
15400
  artifact_slug: string2().optional(),
@@ -15321,6 +15402,12 @@ var commentEventPayloadFields = {
15321
15402
  ask_state: askFields.state.optional(),
15322
15403
  ask_waiting_on: _enum2(ASK_TURNS).optional(),
15323
15404
  ask_sessions: array(string2()).optional(),
15405
+ thread_root_id: string2().optional(),
15406
+ renamed_version: strictObject({
15407
+ artifact_id: string2(),
15408
+ number: number2().int().positive(),
15409
+ summary: string2()
15410
+ }).readonly().optional(),
15324
15411
  ...referenceChangesFields,
15325
15412
  ...threadLoginsFields,
15326
15413
  ...carriedBodyFields
@@ -15351,6 +15438,8 @@ var CommentEventPayloadSchema = object({
15351
15438
  suggestion: object({ replace_with: suggestionFields.replace_with.optional() }).nullish(),
15352
15439
  author: InboundActorSchema.optional(),
15353
15440
  created_at: commentFields.created_at.optional(),
15441
+ deleted_at: commentFields.deleted_at.optional(),
15442
+ deleted_by: InboundActorSchema.nullish(),
15354
15443
  mentions: array(CommentMentionSchema).optional(),
15355
15444
  deliveries: array(CommentDeliverySchema).optional(),
15356
15445
  reply_block: ReplyBlockSchema.nullish(),
@@ -15407,6 +15496,7 @@ var EVENT_TYPE_MEMBERS = {
15407
15496
  "comment.anchor_refreshed": true,
15408
15497
  "comment.answered": true,
15409
15498
  "comment.created": true,
15499
+ "comment.deleted": true,
15410
15500
  "comment.delivery": true,
15411
15501
  "comment.edited": true,
15412
15502
  "comment.reopened": true,
@@ -15423,7 +15513,9 @@ var EVENT_TYPE_MEMBERS = {
15423
15513
  "message.accepted": true,
15424
15514
  "message.answered": true,
15425
15515
  "message.created": true,
15516
+ "message.deleted": true,
15426
15517
  "message.delivery": true,
15518
+ "message.edited": true,
15427
15519
  "priority.updated": true,
15428
15520
  "project.created": true,
15429
15521
  "project.updated": true,
@@ -15497,11 +15589,18 @@ var messageFields = {
15497
15589
  broadcast_id: string2().nullable().optional(),
15498
15590
  deliveries: array(MessageDeliverySchema),
15499
15591
  created_at: string2(),
15592
+ edited_at: string2().nullable(),
15593
+ deleted_at: string2().nullable(),
15594
+ deleted_by: ActorSchema.nullable(),
15500
15595
  reply_block: WrittenReplyBlockSchema.nullable().optional()
15501
15596
  };
15502
15597
  var MessageSchema = strictObject(messageFields).readonly();
15503
15598
  var messageEventPayloadFields = {
15504
15599
  ...messageFields,
15600
+ body: messageFields.body.optional(),
15601
+ edited_at: messageFields.edited_at.optional(),
15602
+ deleted_at: messageFields.deleted_at.optional(),
15603
+ deleted_by: messageFields.deleted_by.optional(),
15505
15604
  reply_body: string2().optional(),
15506
15605
  thread_target: string2().optional(),
15507
15606
  ...referenceChangesFields,
@@ -15516,6 +15615,9 @@ var MessageEventPayloadSchema = object({
15516
15615
  in_reply_to: messageFields.in_reply_to.optional(),
15517
15616
  reply_body: messageEventPayloadFields.reply_body,
15518
15617
  thread_target: messageEventPayloadFields.thread_target,
15618
+ edited_at: messageFields.edited_at.optional(),
15619
+ deleted_at: messageFields.deleted_at.optional(),
15620
+ deleted_by: InboundActorSchema.nullish(),
15519
15621
  author: InboundActorSchema.optional(),
15520
15622
  reply_block: ReplyBlockSchema.nullish(),
15521
15623
  thread_logins: threadLoginsFields.thread_logins,
@@ -19896,6 +19998,27 @@ function resolveDecodeOptions(options) {
19896
19998
  };
19897
19999
  }
19898
20000
 
20001
+ // ../envoy-client/src/actor-text.ts
20002
+ function actorText(actor) {
20003
+ if (actor.kind === "user") {
20004
+ return actorActText(`user ${actor.id}`, actor.act);
20005
+ }
20006
+ const service = actor.kind === "session" ? actor.service : undefined;
20007
+ if (service === undefined) {
20008
+ return `${actor.kind} ${actor.id}`;
20009
+ }
20010
+ return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
20011
+ }
20012
+ function deletedMark(at, by) {
20013
+ return `Deleted by ${by == null ? "its author" : actorText(by)} at ${at}`;
20014
+ }
20015
+ function editedMark(at) {
20016
+ return `edited ${at}`;
20017
+ }
20018
+ function withEditedMark(words, at) {
20019
+ return at == null ? words : `${words} \xB7 ${editedMark(at)}`;
20020
+ }
20021
+
19899
20022
  // ../envoy-client/src/ask-answer.ts
19900
20023
  var HEAD_LENGTH = 120;
19901
20024
  function textHead(text, length = HEAD_LENGTH) {
@@ -21061,13 +21184,23 @@ class DispatchWriteLandedError extends Error {
21061
21184
  status;
21062
21185
  name = "DispatchWriteLandedError";
21063
21186
  constructor(code, status, method, shownUrl) {
21064
- 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";
21187
+ 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";
21065
21188
  const request = `${method} ${shownUrl}`;
21066
21189
  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.");
21067
21190
  this.code = code;
21068
21191
  this.status = status;
21069
21192
  }
21070
21193
  }
21194
+
21195
+ class DispatchAnswerNotKeptError extends Error {
21196
+ status;
21197
+ name = "DispatchAnswerNotKeptError";
21198
+ code = IDEMPOTENCY_ANSWER_NOT_KEPT;
21199
+ constructor(status, method, shownUrl) {
21200
+ 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.");
21201
+ this.status = status;
21202
+ }
21203
+ }
21071
21204
  function asErrorShape(value) {
21072
21205
  return typeof value === "object" && value !== null ? value : {};
21073
21206
  }
@@ -21377,8 +21510,8 @@ class DispatchClient {
21377
21510
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "artifacts"]);
21378
21511
  }
21379
21512
  async markdownRoundTrip(markdown) {
21380
- const { payload } = await this.#jsonAnswer("POST", ["api", "v1", "markdown", "round-trip"], { markdown }, { writes: false });
21381
- return payload.markdown;
21513
+ const answer = await this.#writingNothing(["api", "v1", "markdown", "round-trip"], { markdown }, { writes: false });
21514
+ return answer.markdown;
21382
21515
  }
21383
21516
  async listProjectArtifacts(project, unlinked = false) {
21384
21517
  return this.#json("GET", ["api", "v1", "projects", project, "artifacts"], undefined, unlinked ? { unlinked: "true" } : undefined);
@@ -21411,7 +21544,7 @@ class DispatchClient {
21411
21544
  return this.#json("GET", path, undefined, request);
21412
21545
  }
21413
21546
  async related(project, input) {
21414
- return this.#json("POST", ["api", "v1", "projects", project, "related"], input);
21547
+ return this.#writingNothing(["api", "v1", "projects", project, "related"], input);
21415
21548
  }
21416
21549
  async getIssue(issue) {
21417
21550
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue)]);
@@ -21585,10 +21718,7 @@ class DispatchClient {
21585
21718
  async dryRunResult(issue, input) {
21586
21719
  const path = ["api", "v1", "issues", await this.#resolveIssue(issue), "results", "dry-run"];
21587
21720
  try {
21588
- const { payload } = await this.#jsonAnswer("POST", path, input, {
21589
- writes: false
21590
- });
21591
- return payload;
21721
+ return await this.#writingNothing(path, input, { writes: false });
21592
21722
  } catch (error) {
21593
21723
  if (!(error instanceof DispatchNoRouteError) && !isNoRoute(error))
21594
21724
  throw error;
@@ -21661,7 +21791,19 @@ class DispatchClient {
21661
21791
  ]);
21662
21792
  }
21663
21793
  async getMessageThread(id, session) {
21664
- return this.#json("GET", ["api", "v1", "messages", id], undefined, { session });
21794
+ return this.#json("GET", ["api", "v1", "messages", id], undefined, session === undefined ? undefined : { session });
21795
+ }
21796
+ async editMessage(id, input) {
21797
+ return this.#json("PATCH", ["api", "v1", "messages", id], input);
21798
+ }
21799
+ async deleteMessage(id, actor) {
21800
+ return this.#json("DELETE", ["api", "v1", "messages", id], { actor });
21801
+ }
21802
+ async messageHistory(id, session) {
21803
+ return this.#json("GET", ["api", "v1", "messages", id, "history"], undefined, session === undefined ? undefined : { session });
21804
+ }
21805
+ async issueMessages(issue) {
21806
+ return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "messages"]);
21665
21807
  }
21666
21808
  async acceptMessageDelivery(id, attempt, input) {
21667
21809
  return this.#json("POST", ["api", "v1", "messages", id, "deliveries", String(attempt), "accept"], input);
@@ -21735,6 +21877,15 @@ class DispatchClient {
21735
21877
  async resolveComment(id, actor) {
21736
21878
  return this.#json("POST", ["api", "v1", "comments", id, "resolve"], { actor });
21737
21879
  }
21880
+ async editComment(id, input) {
21881
+ return this.#json("PATCH", ["api", "v1", "comments", id], input);
21882
+ }
21883
+ async deleteComment(id, actor) {
21884
+ return this.#json("DELETE", ["api", "v1", "comments", id], { actor });
21885
+ }
21886
+ async commentHistory(id) {
21887
+ return this.#json("GET", ["api", "v1", "comments", id, "history"]);
21888
+ }
21738
21889
  async getComments(issue) {
21739
21890
  return this.#json("GET", ["api", "v1", "issues", await this.#resolveIssue(issue), "comments"]);
21740
21891
  }
@@ -21854,6 +22005,20 @@ class DispatchClient {
21854
22005
  }
21855
22006
  return this.#noRoute(async () => this.#response(method, url, await this.#send(method, url, body)));
21856
22007
  }
22008
+ async#writingNothing(path, body, options = {}) {
22009
+ for (let keys = 1;; keys++) {
22010
+ try {
22011
+ return (await this.#jsonAnswer("POST", path, body, options)).payload;
22012
+ } catch (error) {
22013
+ if (!(error instanceof DispatchWriteLandedError) || error.code !== IDEMPOTENCY_ANSWER_NOT_KEPT) {
22014
+ throw error;
22015
+ }
22016
+ if (keys === 2) {
22017
+ throw new DispatchAnswerNotKeptError(error.status, "POST", requestForText(this.#baseUrl, this.#url(path), DISPATCH_URL_SETTING));
22018
+ }
22019
+ }
22020
+ }
22021
+ }
21857
22022
  async#send(method, url, body, accept = "application/json", signal) {
21858
22023
  const sent = await this.#sendOnce(method, url, body, accept, signal);
21859
22024
  if (this.#credential.stale === undefined || !await tokenNotLive(sent.answer)) {
@@ -22544,12 +22709,22 @@ function carriedBodyNote(event) {
22544
22709
  }
22545
22710
  async function wholeCarriedBody(client, item, session) {
22546
22711
  try {
22712
+ let posts;
22547
22713
  if (item.resource === "comment") {
22548
22714
  const read = await client.getComment(item.id);
22549
- return [read.comment, ...read.replies ?? []].find((comment) => comment.id === item.id)?.body;
22715
+ posts = [read.comment, ...read.replies ?? []];
22716
+ } else {
22717
+ if (item.issueKey === null && session === undefined)
22718
+ return;
22719
+ const read = item.issueKey === null ? await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
22720
+ posts = [read.message, ...read.replies ?? []];
22550
22721
  }
22551
- const read = item.issueKey === null ? session === undefined ? undefined : await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
22552
- return read === undefined ? undefined : [read.message, ...read.replies ?? []].find((message) => message.id === item.id)?.body;
22722
+ const post = posts.find((candidate) => candidate.id === item.id);
22723
+ if (post === undefined)
22724
+ return;
22725
+ if (post.deleted_at != null)
22726
+ return deletedMark(post.deleted_at, post.deleted_by);
22727
+ return withEditedMark(post.body, post.edited_at);
22553
22728
  } catch {
22554
22729
  return;
22555
22730
  }
@@ -22589,11 +22764,14 @@ var DISPATCH_PAYLOAD_SCHEMAS = {
22589
22764
  "comment.resolved": CommentEventPayloadSchema,
22590
22765
  "comment.reopened": CommentEventPayloadSchema,
22591
22766
  "comment.edited": CommentEventPayloadSchema,
22767
+ "comment.deleted": CommentEventPayloadSchema,
22592
22768
  "suggestion.accepted": CommentEventPayloadSchema,
22593
22769
  "suggestion.rejected": CommentEventPayloadSchema,
22594
22770
  "message.created": MessageEventPayloadSchema,
22595
22771
  "message.delivery": MessageDeliveryEventPayloadSchema,
22596
22772
  "message.answered": MessageEventPayloadSchema,
22773
+ "message.edited": MessageEventPayloadSchema,
22774
+ "message.deleted": MessageEventPayloadSchema,
22597
22775
  "child.status": ChildStatusEventPayloadSchema
22598
22776
  };
22599
22777
  function topicDocument(topic) {
@@ -23082,9 +23260,20 @@ function renderInbound(raw, sessionID, subject, wholeBody) {
23082
23260
  },
23083
23261
  ...unrecognised === undefined ? {} : { unrecognised }
23084
23262
  };
23263
+ let card;
23264
+ let payloadShownAsText;
23265
+ try {
23266
+ card = encode3({ envoy: rendered });
23267
+ } catch (error) {
23268
+ const payloadKey = dispatchRendered ? "dispatch" : "message";
23269
+ if (envelope.payload === undefined || !(payloadKey in rendered))
23270
+ throw error;
23271
+ card = encode3({ envoy: { ...rendered, [payloadKey]: envelope.payload } });
23272
+ payloadShownAsText = messageFor(error);
23273
+ }
23085
23274
  return {
23086
23275
  skip: false,
23087
- content: trailer === "" ? encode3({ envoy: rendered }) : `${encode3({ envoy: rendered })}
23276
+ content: trailer === "" ? card : `${card}
23088
23277
 
23089
23278
  ${trailer}`,
23090
23279
  envelope,
@@ -23093,7 +23282,8 @@ ${trailer}`,
23093
23282
  ...rejectedDelivery === undefined ? {} : { rejectedDelivery },
23094
23283
  ...malformedDelivery ? { malformedDelivery: true } : {},
23095
23284
  ...pictures.length === 0 ? {} : { pictures },
23096
- ...cutItem === undefined ? {} : { cutItem }
23285
+ ...cutItem === undefined ? {} : { cutItem },
23286
+ ...payloadShownAsText === undefined ? {} : { payloadShownAsText }
23097
23287
  };
23098
23288
  }
23099
23289
 
@@ -23148,8 +23338,9 @@ async function textWithPictures(text, pictures, owner, upload, actor) {
23148
23338
  uploaded = await upload({ name: picture.name, file: picture.file, actor });
23149
23339
  } catch (error) {
23150
23340
  const earlier = addresses.length === 0 ? "" : `; the pictures before it are uploaded (${addresses.join(", ")})`;
23341
+ const landed = error instanceof DispatchWriteLandedError || error instanceof Error && error.cause instanceof DispatchWriteLandedError;
23151
23342
  const refused = error instanceof DispatchGatewayError ? !error.mayHaveReachedDispatch : error instanceof DispatchServiceError && error.status < 500;
23152
- const outcome = refused ? "was not uploaded" : "may or may not have been uploaded";
23343
+ const outcome = landed ? "was uploaded" : refused ? "was not uploaded" : "may or may not have been uploaded";
23153
23344
  throw new Error(`images: ${picture.path} ${outcome}: ${messageFor(error).replace(/\.$/, "")}. Nothing ` + `was posted${earlier}.`);
23154
23345
  }
23155
23346
  const address = `dispatch://${owner}/artifact/${uploaded.artifact.slug}@v${uploaded.version.number}`;
@@ -23170,7 +23361,10 @@ function parseAgentArtifactRef(ref) {
23170
23361
  return { session, slug, ...version === undefined ? {} : { version: Number(version) } };
23171
23362
  }
23172
23363
  function datedBodies(records) {
23173
- return records.map((record) => ({ text: record.body, at: record.created_at }));
23364
+ return records.map((record) => ({
23365
+ text: record.body,
23366
+ at: record.edited_at ?? record.created_at
23367
+ }));
23174
23368
  }
23175
23369
  function askTexts({ ask, replies }) {
23176
23370
  return [
@@ -23205,6 +23399,7 @@ function eventTexts(event) {
23205
23399
  case "suggestion.rejected":
23206
23400
  case "message.created":
23207
23401
  case "message.answered":
23402
+ case "message.edited":
23208
23403
  texts = [event.payload.body];
23209
23404
  break;
23210
23405
  default:
@@ -23680,7 +23875,7 @@ function normalizeUUID(value) {
23680
23875
  return `${compact.slice(0, 8)}-${compact.slice(8, 12)}-${compact.slice(12, 16)}-${compact.slice(16, 20)}-${compact.slice(20)}`.toLowerCase();
23681
23876
  }
23682
23877
  var askIdProblem = "ask must be a bare ask id or a dispatch://.../ask/<id> reference";
23683
- var commentIdProblem = "comment must be a bare comment id or a dispatch://.../comment/<id> reference";
23878
+ 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";
23684
23879
  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>)";
23685
23880
  function askId(args) {
23686
23881
  const ask = stringArg(args, "ask");
@@ -23693,6 +23888,23 @@ function messageIdOf(value) {
23693
23888
  })() : value;
23694
23889
  return id === undefined ? undefined : normalizeUUID(id);
23695
23890
  }
23891
+ var messageArgumentProblem = (argument) => `${argument} must be a full message id (uuid) or a dispatch://KEY/message/<id> reference`;
23892
+ function messageArgumentId(value) {
23893
+ if (!value.startsWith("dispatch://")) {
23894
+ const bare = normalizeUUID(value);
23895
+ return bare === undefined ? undefined : { id: bare };
23896
+ }
23897
+ const ref = parseDispatchRef(value);
23898
+ if (ref?.kind !== "message")
23899
+ return;
23900
+ const full = normalizeUUID(ref.id);
23901
+ const owner = ref.owner;
23902
+ if (owner.kind !== "issue")
23903
+ return full === undefined ? undefined : { id: full };
23904
+ if (full === undefined && !isIdPrefix(ref.id))
23905
+ return;
23906
+ return { id: full ?? ref.id, ref: { ...ref, owner } };
23907
+ }
23696
23908
  function itemBlockOf(value) {
23697
23909
  const ref = parseDispatchRef(value);
23698
23910
  return ref?.item === undefined || ref.block === undefined ? undefined : { ...ref, item: ref.item, block: ref.block };
@@ -23742,7 +23954,7 @@ async function refuseItemOffRef(tool, kind, ref, refText, item, documentId) {
23742
23954
  return;
23743
23955
  }
23744
23956
  }
23745
- const where = item.issue_key === null ? "another document" : `${item.issue_key}; name it dispatch://${item.issue_key}/${kind}/${item.id}`;
23957
+ 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}`;
23746
23958
  throw new ToolInputError(tool, [
23747
23959
  `${refText} names ${kind} ${item.id} on ${refOwnerName(ref)}, but it is on ${where}`
23748
23960
  ]);
@@ -23826,6 +24038,10 @@ var issueFreeTools = {
23826
24038
  dispatch_edit_ask: true,
23827
24039
  dispatch_resolve_ask: true,
23828
24040
  dispatch_resolve_comment: true,
24041
+ dispatch_edit_comment: true,
24042
+ dispatch_delete_comment: true,
24043
+ dispatch_edit_message: true,
24044
+ dispatch_delete_message: true,
23829
24045
  dispatch_follow: true,
23830
24046
  dispatch_search: true,
23831
24047
  dispatch_related: true,
@@ -23872,13 +24088,25 @@ function argumentProblems(tool, args) {
23872
24088
  }
23873
24089
  break;
23874
24090
  }
23875
- case "dispatch_resolve_comment": {
24091
+ case "dispatch_resolve_comment":
24092
+ case "dispatch_edit_comment":
24093
+ case "dispatch_delete_comment": {
23876
24094
  const comment = optionalString(args, "comment");
23877
- if (comment?.startsWith("dispatch://") && parseDispatchRef(comment)?.kind !== "comment") {
24095
+ if (comment !== undefined && !comment.startsWith("dispatch://") && normalizeUUID(comment) === undefined && !isIdPrefix(comment)) {
24096
+ problems.push(commentIdProblem);
24097
+ } else if (comment?.startsWith("dispatch://") && parseDispatchRef(comment)?.kind !== "comment") {
23878
24098
  problems.push(itemRefProblem(comment) ?? commentIdProblem);
23879
24099
  }
23880
24100
  break;
23881
24101
  }
24102
+ case "dispatch_edit_message":
24103
+ case "dispatch_delete_message": {
24104
+ const message = optionalString(args, "message");
24105
+ if (message !== undefined && messageArgumentId(message) === undefined) {
24106
+ problems.push(messageArgumentProblem("message"));
24107
+ }
24108
+ break;
24109
+ }
23882
24110
  case "dispatch_comment": {
23883
24111
  if (optionalString(args, "quote") !== undefined && optionalString(args, "artifact") === undefined) {
23884
24112
  problems.push("artifact is required when quote is supplied");
@@ -23909,7 +24137,12 @@ function argumentProblems(tool, args) {
23909
24137
  case "dispatch_read": {
23910
24138
  const message = optionalString(args, "message");
23911
24139
  if (message !== undefined && messageIdOf(message) === undefined) {
23912
- problems.push("message must be a full message id (uuid) or a dispatch://KEY/message/<id> reference");
24140
+ problems.push(messageArgumentProblem("message"));
24141
+ }
24142
+ const historyRef = optionalBoolean(args, "history") === true ? optionalString(args, "ref") : undefined;
24143
+ const historyKind = historyRef === undefined ? undefined : parseDispatchRef(historyRef)?.kind;
24144
+ if (historyRef !== undefined && historyKind !== "comment" && historyKind !== "message") {
24145
+ 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>");
23913
24146
  }
23914
24147
  const events = optionalNumber(args, "events");
23915
24148
  const allEvents = optionalBoolean(args, "all_events") === true;
@@ -24191,6 +24424,21 @@ function refusalWithCode(error, ...clauses) {
24191
24424
  function dispatchAnswered(error, status) {
24192
24425
  return error instanceof DispatchServiceError && error.fromDispatch && error.status === status;
24193
24426
  }
24427
+ var OLDER_COMMENT_EDIT_ACTOR = 'invalid JSON body: json: unknown field "actor"';
24428
+ async function throughPostCorrections(tool, url, call, post) {
24429
+ try {
24430
+ return await call;
24431
+ } catch (error) {
24432
+ 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);
24433
+ if (!(error instanceof DispatchNoRouteError) && !commentEditIsAge) {
24434
+ throw post === undefined ? error : refuseMissingPost(error, post);
24435
+ }
24436
+ 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.");
24437
+ }
24438
+ }
24439
+ function refuseMissingPost(error, post) {
24440
+ return dispatchNotFound(error) ? refusalWithCode(error, `this Dispatch holds no ${post.kind} ${post.id}`) : error;
24441
+ }
24194
24442
  function writeMayHaveLanded(error) {
24195
24443
  if (error instanceof DispatchGatewayError)
24196
24444
  return error.mayHaveReachedDispatch;
@@ -24201,10 +24449,29 @@ function withAccount(error, account) {
24201
24449
  const told = /[.!?]$/.test(message) ? `${message} ${account.charAt(0).toUpperCase()}${account.slice(1)}` : `${message}; ${account}`;
24202
24450
  return new Error(told, { cause: error });
24203
24451
  }
24452
+ function dispatchNotFound(error) {
24453
+ return !(error instanceof DispatchNoRouteError) && dispatchAnswered(error, 404) && error.code === "NOT_FOUND";
24454
+ }
24204
24455
 
24205
- // ../envoy-client/src/dispatch-commands/document-targets.ts
24206
24456
  class DocumentNotFoundError extends Error {
24207
24457
  }
24458
+ async function refuseMissingOfRef(error, kind, id, owner, ownerName, readOwner) {
24459
+ if (!dispatchNotFound(error))
24460
+ return error;
24461
+ const missingOwner = await readOwner().then(() => {
24462
+ return;
24463
+ }, (caught) => {
24464
+ if (owner.kind === "issue" && dispatchNotFound(caught)) {
24465
+ return refusalWithCode(error, `this Dispatch holds no issue ${owner.issue}`);
24466
+ }
24467
+ if (caught instanceof DocumentNotFoundError)
24468
+ return caught;
24469
+ return refusalWithCode(error, `the read of ${ownerName} failed, so this does not say whether ${ownerName} exists or` + ` holds ${kind} ${id}: ${messageFor(caught)}`);
24470
+ });
24471
+ return missingOwner ?? refusalWithCode(error, `${ownerName} holds no ${kind} ${id}`);
24472
+ }
24473
+
24474
+ // ../envoy-client/src/dispatch-commands/document-targets.ts
24208
24475
  function artifactByReference(artifacts, artifactReference, owner, canonical) {
24209
24476
  const bySlug = artifacts.find((candidate) => candidate.slug === artifactReference);
24210
24477
  if (canonical && bySlug !== undefined)
@@ -24400,6 +24667,9 @@ async function resolveExistingIssue(client, issueReference) {
24400
24667
  throw error;
24401
24668
  }
24402
24669
  }
24670
+ function readRefOwner(client, owner, readDocument) {
24671
+ return async () => owner.kind === "issue" ? client.getIssue(owner.issue) : readDocument();
24672
+ }
24403
24673
 
24404
24674
  // ../envoy-client/src/dispatch-commands/command-context.ts
24405
24675
  function toolActor(origin, input) {
@@ -24458,32 +24728,21 @@ async function commandContext(session) {
24458
24728
  };
24459
24729
  }
24460
24730
 
24461
- // ../envoy-client/src/actor-text.ts
24462
- function actorText(actor) {
24463
- if (actor.kind === "user") {
24464
- return actorActText(`user ${actor.id}`, actor.act);
24465
- }
24466
- const service = actor.kind === "session" ? actor.service : undefined;
24467
- if (service === undefined) {
24468
- return `${actor.kind} ${actor.id}`;
24469
- }
24470
- return `${actor.kind} ${actor.id} (as ${serviceSubjectLabel(service)})`;
24471
- }
24472
-
24473
24731
  // ../envoy-client/src/search-answer.ts
24474
24732
  function pageSummaryText(offset, count, total) {
24475
24733
  return `showing ${offset + 1}-${offset + count} of ${total}`;
24476
24734
  }
24477
24735
  function searchHitLine(result, linkBase) {
24478
24736
  const href = linkFor(result.href, linkBase);
24737
+ const text = result.deleted_at == null ? withEditedMark(snippetText(result.snippet), result.edited_at) : deletedMark(result.deleted_at, result.deleted_by);
24479
24738
  const { owner } = result;
24480
24739
  if (owner.kind === "document") {
24481
24740
  const reference = dispatchDocumentRef(owner.project ?? "", owner.slug ?? "");
24482
- return `${reference} [document] ${owner.name} - ${result.kind}: ${snippetText(result.snippet)} -> ${href}`;
24741
+ return `${reference} [document] ${owner.name} - ${result.kind}: ${text} -> ${href}`;
24483
24742
  }
24484
24743
  const artifactName = result.artifact ? ` ${result.artifact.name}` : "";
24485
24744
  const label = `${owner.key} [${owner.status}] ${owner.title} - ${result.kind}${artifactName}`;
24486
- return `${label}: ${snippetText(result.snippet)} -> ${href}`;
24745
+ return `${label}: ${text} -> ${href}`;
24487
24746
  }
24488
24747
  function indentedText(text) {
24489
24748
  return text.split(/\r?\n/u).join(`
@@ -24854,7 +25113,8 @@ function isItemKind(kind) {
24854
25113
  }
24855
25114
  function edgeLine(edge) {
24856
25115
  const { node } = edge;
24857
- const excerpt = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
25116
+ const words = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
25117
+ 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 `;
24858
25118
  const block = edge.block === undefined ? "" : ` (block ${edge.block.ref ?? edge.block.id})`;
24859
25119
  const parent = node.parent ?? undefined;
24860
25120
  const item = node.kind === "block" && node.document === undefined && isItemKind(parent?.kind) ? parent : undefined;
@@ -24924,7 +25184,7 @@ function blockLines(node, ref, typed, noun = "Block") {
24924
25184
  ...node.changed_version === undefined ? [] : [`Changed in version: ${node.changed_version}`],
24925
25185
  ...node.text === undefined ? [] : ["Text:", node.text]
24926
25186
  ] : [
24927
- `${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}:`,
25187
+ `${withEditedMark(`${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}`, node.edited_at)}:`,
24928
25188
  ...node.text === undefined ? [] : [node.text]
24929
25189
  ];
24930
25190
  const { pin } = node;
@@ -25087,7 +25347,9 @@ function olderServerWarnings(issue) {
25087
25347
  }
25088
25348
  var STRUCTURAL_EDGES_IN = ["child_of", "blocked_by"];
25089
25349
  function referenceLinkLine({ kinds, node, via }, near) {
25090
- return `- ${(kinds ?? []).join(",")} ${node.kind} ${node.ref ?? node.id} \xB7 ${near} ${via.kind} ${via.id}`;
25350
+ const address = node.ref ?? node.id;
25351
+ const target = node.deleted_at == null ? withEditedMark(address, node.edited_at) : `${address} \xB7 ${deletedMark(node.deleted_at, node.deleted_by)}`;
25352
+ return `- ${(kinds ?? []).join(",")} ${node.kind} ${target} \xB7 ${near} ${via.kind} ${via.id}`;
25091
25353
  }
25092
25354
  function memberLines(references) {
25093
25355
  const members = references.members ?? [];
@@ -25175,6 +25437,13 @@ function logSummary(issue, events) {
25175
25437
  ].join(`
25176
25438
  `);
25177
25439
  }
25440
+ function postEventHead(payload) {
25441
+ if (payload.deleted_at != null)
25442
+ return deletedMark(payload.deleted_at, payload.deleted_by);
25443
+ if (payload.body === undefined)
25444
+ return;
25445
+ return withEditedMark(textHead(payload.body), payload.edited_at);
25446
+ }
25178
25447
  function eventHead(event) {
25179
25448
  switch (event.type) {
25180
25449
  case "ask.opened":
@@ -25195,11 +25464,14 @@ function eventHead(event) {
25195
25464
  case "comment.edited":
25196
25465
  case "comment.resolved":
25197
25466
  case "comment.reopened":
25467
+ case "comment.deleted":
25198
25468
  case "suggestion.accepted":
25199
25469
  case "suggestion.rejected":
25200
25470
  case "message.created":
25201
25471
  case "message.answered":
25202
- return textHead(event.payload.body);
25472
+ case "message.edited":
25473
+ case "message.deleted":
25474
+ return postEventHead(event.payload);
25203
25475
  case "artifact.version":
25204
25476
  return textHead(`${event.payload.name} v${event.payload.version.number}${event.payload.version.summary ? `: ${event.payload.version.summary}` : ""}`);
25205
25477
  case "artifact.approved":
@@ -26022,7 +26294,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
26022
26294
  const partRef = (id) => `${askRef}#b-${encodeBlockId(id)}`;
26023
26295
  const chain = (replies ?? []).flatMap((reply) => [
26024
26296
  `${reply.id} \xB7 ${actorText(reply.author)}`,
26025
- `Body: ${reply.body}`
26297
+ ...postBodyLines(reply)
26026
26298
  ]);
26027
26299
  const resolutionWords = dispatchWordsText(ask.resolution?.dispatch_words);
26028
26300
  return [
@@ -26130,19 +26402,42 @@ function formatOpenAsksSummary(response, linkBase) {
26130
26402
  ].join(`
26131
26403
  `);
26132
26404
  }
26405
+ function postBodyLines(post) {
26406
+ if (post.deleted_at != null)
26407
+ return [deletedMark(post.deleted_at, post.deleted_by)];
26408
+ return [...post.edited_at == null ? [] : [`Edited: ${post.edited_at}`], `Body: ${post.body}`];
26409
+ }
26410
+ function postHistorySummary(kind, ref, id, read) {
26411
+ const entries = read.entries ?? [];
26412
+ const deleted = read.deleted_at != null;
26413
+ const oldest = entries.at(-1);
26414
+ const route = `/api/v1/${kind === "Comment" ? "comments" : "messages"}/${id}/history`;
26415
+ return [
26416
+ `${kind} history: ${ref}`,
26417
+ ...read.deleted_at == null ? [] : [deletedMark(read.deleted_at, read.deleted_by)],
26418
+ ...entries.length === 0 ? ["- none"] : entries.flatMap((entry) => [
26419
+ `${entry.edited_at} \xB7 ${actorText(entry.edited_by)}`,
26420
+ ...deleted ? [] : [`Body: ${entry.body}`]
26421
+ ]),
26422
+ ...entries.length < POST_HISTORY_PAGE_LIMIT || oldest === undefined ? [] : [
26423
+ `This is the newest page, and a page holds ${POST_HISTORY_PAGE_LIMIT} rows: GET ${route}?before=${oldest.edited_at} reads any older rows.`
26424
+ ]
26425
+ ].join(`
26426
+ `);
26427
+ }
26133
26428
  function commentSummary({ comment, replies }, graph) {
26134
26429
  const root = [
26135
26430
  `${comment.id} \xB7 ${actorText(comment.author)}`,
26136
26431
  ...anchorLines(comment),
26137
26432
  ...replyBlockLines(comment),
26138
- `Body: ${comment.body}`
26433
+ ...postBodyLines(comment)
26139
26434
  ];
26140
26435
  const chain = (replies ?? []).flatMap((reply) => [
26141
26436
  `${reply.id} \xB7 ${actorText(reply.author)}`,
26142
26437
  ...anchorLines(reply),
26143
26438
  ...replyBlockLines(reply),
26144
26439
  ...reply.answers != null && reply.answers !== comment.id ? [`Answers: ${reply.answers}`] : [],
26145
- `Body: ${reply.body}`
26440
+ ...postBodyLines(reply)
26146
26441
  ]);
26147
26442
  return [
26148
26443
  "Comment:",
@@ -26157,8 +26452,13 @@ function replyBlockLines(record) {
26157
26452
  const block = record.reply_block;
26158
26453
  if (block === undefined || block === null)
26159
26454
  return [];
26455
+ if (block.deleted_at != null) {
26456
+ return [
26457
+ `Re: block ${block.block_id} (parent deleted): ${deletedMark(block.deleted_at, block.deleted_by)}`
26458
+ ];
26459
+ }
26160
26460
  return [
26161
- block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}`
26461
+ withEditedMark(block.removed ? `Re: block ${block.block_id} (removed)` : `Re: block ${block.block_id}: ${textHead(block.text)}`, block.edited_at)
26162
26462
  ];
26163
26463
  }
26164
26464
  function anchorLines(record) {
@@ -26187,12 +26487,12 @@ function messageSummary({ message, replies }, graph) {
26187
26487
  const root = [
26188
26488
  `${message.id} \xB7 ${actorText(message.author)}`,
26189
26489
  ...replyBlockLines(message),
26190
- `Body: ${message.body}`
26490
+ ...postBodyLines(message)
26191
26491
  ];
26192
26492
  const chain = (replies ?? []).flatMap((reply) => [
26193
26493
  `${reply.id} \xB7 ${actorText(reply.author)}`,
26194
26494
  ...replyBlockLines(reply),
26195
- `Body: ${reply.body}`
26495
+ ...postBodyLines(reply)
26196
26496
  ]);
26197
26497
  return [
26198
26498
  "Message:",
@@ -26236,7 +26536,7 @@ async function openAnchoredThreads(client, resolved) {
26236
26536
  const commentThreads = roots.map((root) => [
26237
26537
  `comment ${root.id} \xB7 ${actorText(root.author)} \xB7 ${root.created_at}`,
26238
26538
  ...anchorLines(root),
26239
- `Body: ${root.body}`,
26539
+ ...postBodyLines(root),
26240
26540
  ...threadReplyLines(replies.get(root.id) ?? [])
26241
26541
  ].join(`
26242
26542
  `));
@@ -26245,7 +26545,7 @@ async function openAnchoredThreads(client, resolved) {
26245
26545
  function threadReplyLines(replies) {
26246
26546
  return replies.flatMap((reply) => [
26247
26547
  `reply ${reply.id} \xB7 ${actorText(reply.author)} \xB7 ${reply.created_at}`,
26248
- `Body: ${reply.body}`
26548
+ ...postBodyLines(reply)
26249
26549
  ]);
26250
26550
  }
26251
26551
  function threadRootId(comment, byId) {
@@ -26523,28 +26823,116 @@ async function followCommand(context) {
26523
26823
  }
26524
26824
 
26525
26825
  // ../envoy-client/src/dispatch-commands/conversation.ts
26526
- async function resolveCommentCommand(context) {
26527
- const { args, client, actor, input } = context;
26528
- const reference = stringArg(args, "comment");
26826
+ async function resolveCommentArgument(tool, reference, client) {
26529
26827
  const ref = reference.startsWith("dispatch://") ? parseDispatchRef(reference) : null;
26828
+ if (ref === null)
26829
+ return { id: reference };
26530
26830
  let id = reference;
26531
26831
  let document;
26532
- if (ref?.owner.kind === "issue") {
26832
+ if (ref.owner.kind === "issue") {
26533
26833
  const issueKey = ref.owner.issue;
26534
- id = await resolveIdPrefix(input.tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
26535
- } else if (ref !== null) {
26834
+ id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getComments(issueKey));
26835
+ } else {
26536
26836
  const artifact = (await resolveArtifact(client, ref.owner, ref.artifact, { canonical: true })).artifact;
26537
26837
  document = artifact;
26538
- id = await resolveIdPrefix(input.tool, "comment", ref.id, refOwnerName(ref), () => client.getArtifactComments(artifact.id));
26539
- }
26540
- if (ref !== null) {
26541
- const read = await client.getComment(id);
26542
- await refuseItemOffRef(input.tool, "comment", ref, reference, read.comment, async () => document === undefined ? "" : document.id);
26838
+ id = await resolveIdPrefix(tool, "comment", ref.id, refOwnerName(ref), () => client.getArtifactComments(artifact.id));
26543
26839
  }
26544
- const comment = await client.resolveComment(id, actor);
26840
+ const read = await client.getComment(id).catch(async (error) => {
26841
+ throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, async () => document));
26842
+ });
26843
+ await refuseItemOffRef(tool, "comment", ref, reference, read.comment, async () => document === undefined ? "" : document.id);
26844
+ return { id, ...document === undefined ? {} : { document } };
26845
+ }
26846
+ async function resolveMessageArgument(tool, argument, reference, client, session) {
26847
+ const named = messageArgumentId(reference);
26848
+ if (named === undefined)
26849
+ throw new ToolInputError(tool, [messageArgumentProblem(argument)]);
26850
+ const ref = named.ref;
26851
+ if (ref === undefined)
26852
+ return named.id;
26853
+ const issueKey = ref.owner.issue;
26854
+ const id = await resolveIdPrefix(tool, "message", named.id, issueKey, async () => (await client.issueMessages(issueKey)).flatMap((thread) => [
26855
+ thread.message,
26856
+ ...thread.replies ?? []
26857
+ ]));
26858
+ const read = await client.getMessageThread(id, session === "" ? undefined : session).catch(async (error) => {
26859
+ throw await refuseMissingOfRef(error, "message", id, ref.owner, issueKey, () => client.getIssue(issueKey));
26860
+ });
26861
+ await refuseItemOffRef(tool, "message", ref, reference, { id, issue_key: read.message.issue_key }, async () => "");
26862
+ return id;
26863
+ }
26864
+ function messageIssueKey(message) {
26865
+ if (message.issue_key === null)
26866
+ throw new Error("the corrected message names no issue");
26867
+ return message.issue_key;
26868
+ }
26869
+ async function resolveCommentCommand(context) {
26870
+ const { args, client, actor, input } = context;
26871
+ const reference = stringArg(args, "comment");
26872
+ const { id, document } = await resolveCommentArgument(input.tool, reference, client);
26873
+ const comment = await client.resolveComment(id, actor).catch((error) => {
26874
+ throw refuseMissingPost(error, { kind: "comment", id });
26875
+ });
26545
26876
  const { label, details } = await commentOwnerResult(client, comment, document);
26546
26877
  return { text: `Resolved comment ${comment.id} on ${label}.`, details };
26547
26878
  }
26879
+ async function editCommentCommand(context) {
26880
+ const { args, client, actor, input, configUrl } = context;
26881
+ const reference = stringArg(args, "comment");
26882
+ const { id, document } = await resolveCommentArgument(input.tool, reference, client);
26883
+ const comment = await throughPostCorrections(input.tool, configUrl, client.editComment(id, { body: stringArg(args, "body"), actor }), { kind: "comment", id });
26884
+ const { label, details } = await commentOwnerResult(client, comment, document);
26885
+ return { text: `Edited comment ${comment.id} on ${label}.`, details };
26886
+ }
26887
+ 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.";
26888
+ 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.";
26889
+ async function throughDelete(context, call, post) {
26890
+ try {
26891
+ return await throughPostCorrections(context.input.tool, context.configUrl, call, post);
26892
+ } catch (error) {
26893
+ if (dispatchAnswered(error, 409) && error.code === "DELETE_CONTENDED") {
26894
+ throw refusalWithCode(error, `${post.kind} ${post.id} stands: run the same dispatch delete-${post.kind} command again`);
26895
+ }
26896
+ throw error;
26897
+ }
26898
+ }
26899
+ async function deleteCommentCommand(context) {
26900
+ const { args, client, actor, input } = context;
26901
+ const reference = stringArg(args, "comment");
26902
+ const { id, document } = await resolveCommentArgument(input.tool, reference, client);
26903
+ const comment = await throughDelete(context, client.deleteComment(id, actor), {
26904
+ kind: "comment",
26905
+ id
26906
+ });
26907
+ const { label, details } = await commentOwnerResult(client, comment, document);
26908
+ return {
26909
+ text: `Deleted comment ${comment.id} on ${label}. ${DELETED_COMMENT_READS}`,
26910
+ details
26911
+ };
26912
+ }
26913
+ async function editMessageCommand(context) {
26914
+ const { args, client, actor, input, configUrl, hostSession } = context;
26915
+ const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
26916
+ const message = await throughPostCorrections(input.tool, configUrl, client.editMessage(id, { body: stringArg(args, "body"), actor }), { kind: "message", id });
26917
+ const issue = messageIssueKey(message);
26918
+ return {
26919
+ text: `Edited message ${message.id} on ${issue}.`,
26920
+ details: { issue, message: message.id }
26921
+ };
26922
+ }
26923
+ async function deleteMessageCommand(context) {
26924
+ const { args, client, actor, input, hostSession } = context;
26925
+ const id = await resolveMessageArgument(input.tool, "message", stringArg(args, "message"), client, hostSession);
26926
+ const message = await throughDelete(context, client.deleteMessage(id, actor), {
26927
+ kind: "message",
26928
+ id
26929
+ });
26930
+ const issue = messageIssueKey(message);
26931
+ return {
26932
+ text: `Deleted message ${message.id} on ${issue}. ${DELETED_MESSAGE_READS}`,
26933
+ details: { issue, message: message.id }
26934
+ };
26935
+ }
26548
26936
  async function commentCommand(context) {
26549
26937
  const { args, client, actor, input, documentOwner, resolveDocument, writePictures, issue } = context;
26550
26938
  const artifactReference = optionalString(args, "artifact");
@@ -27134,6 +27522,9 @@ function artifactNameExistsProblem(held, owner) {
27134
27522
  return `${owner} already holds ${held.name} (slug ${held.slug}, kind ${held.kind}) at version ${newest.number}, which ${wroteIt} wrote. ${ARTIFACT_NAME_EXISTS_RULE}`;
27135
27523
  }
27136
27524
  function storedTextCheckFailed(error, name) {
27525
+ if (error instanceof DispatchAnswerNotKeptError) {
27526
+ 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.`;
27527
+ }
27137
27528
  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)}.`;
27138
27529
  if (!dispatchAnswered(error, 413)) {
27139
27530
  return `${failure} Send the upload again once that call is answered.`;
@@ -27843,9 +28234,12 @@ async function readCommand(context) {
27843
28234
  shown,
27844
28235
  documentOwner,
27845
28236
  resolveDocument,
27846
- issue
28237
+ issue,
28238
+ configUrl,
28239
+ hostSession
27847
28240
  } = context;
27848
28241
  const message = optionalString(args, "message");
28242
+ const history = optionalBoolean(args, "history") === true;
27849
28243
  const picturesOf = (texts) => readPictures(client, picturesNewestFirst(texts), shown);
27850
28244
  const showImages = (pictures) => {
27851
28245
  for (const address of pictures.shown)
@@ -27876,9 +28270,21 @@ async function readCommand(context) {
27876
28270
  refDocumentId ??= resolveDocument(ref.owner, ref.artifact).then((resolved) => resolved.artifact.id);
27877
28271
  return refDocumentId;
27878
28272
  };
28273
+ const deletedPostClause = async (ref) => {
28274
+ const item = ref.item;
28275
+ if (item === undefined || item.kind !== "comment" && item.kind !== "message") {
28276
+ return "";
28277
+ }
28278
+ 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(() => {
28279
+ return;
28280
+ });
28281
+ return deleted == null ? "" : ` This ${item.kind} is deleted.`;
28282
+ };
27879
28283
  if (ownerArguments.ref?.kind === "ask") {
27880
28284
  const ref = ownerArguments.ref;
27881
- 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"));
28285
+ 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) => {
28286
+ throw await refuseMissingOfRef(error, "ask", ref.id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
28287
+ });
27882
28288
  await refuseItemOffRef(input.tool, "ask", ref, stringArg(args, "ref"), askRead.ask, () => documentIdOf(ref));
27883
28289
  const askRef = refTarget(ref, "ask", askRead.ask.id);
27884
28290
  const [pictures, incoming, outgoing] = await Promise.all([
@@ -27895,8 +28301,16 @@ async function readCommand(context) {
27895
28301
  if (ownerArguments.ref?.kind === "comment") {
27896
28302
  const ref = ownerArguments.ref;
27897
28303
  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)));
27898
- const comment = await client.getComment(id);
28304
+ const comment = await client.getComment(id).catch(async (error) => {
28305
+ throw await refuseMissingOfRef(error, "comment", id, ref.owner, refOwnerName(ref), readRefOwner(client, ref.owner, () => documentIdOf(ref)));
28306
+ });
27899
28307
  await refuseItemOffRef(input.tool, "comment", ref, stringArg(args, "ref"), comment.comment, () => documentIdOf(ref));
28308
+ if (history) {
28309
+ return {
28310
+ text: postHistorySummary("Comment", refTarget(ref, "comment", id), id, await throughPostCorrections(input.tool, configUrl, client.commentHistory(id))),
28311
+ details: ref.owner.kind === "project" ? { project: ref.owner.project, comment: id } : { issue: comment.comment.issue_key, comment: id }
28312
+ };
28313
+ }
27900
28314
  const commentRef = refTarget(ref, "comment", id);
27901
28315
  const [pictures, graph] = await Promise.all([
27902
28316
  picturesOf(datedBodies([comment.comment, ...comment.replies ?? []])),
@@ -27912,7 +28326,18 @@ async function readCommand(context) {
27912
28326
  if (ownerArguments.ref.owner.kind !== "issue") {
27913
28327
  throw new Error("message references are issue-scoped");
27914
28328
  }
27915
- const messageRead = await client.getMessage(ownerArguments.ref.owner.issue, ownerArguments.ref.id);
28329
+ const messageIssue = ownerArguments.ref.owner.issue;
28330
+ if (history) {
28331
+ const id = await resolveMessageArgument(input.tool, "ref", stringArg(args, "ref"), client, hostSession);
28332
+ return {
28333
+ text: postHistorySummary("Message", dispatchChildRef(dispatchIssueRef(messageIssue), "message", id), id, await throughPostCorrections(input.tool, configUrl, client.messageHistory(id, hostSession === "" ? undefined : hostSession))),
28334
+ details: { issue: messageIssue, message: id }
28335
+ };
28336
+ }
28337
+ const named = ownerArguments.ref;
28338
+ const messageRead = await client.getMessage(messageIssue, named.id).catch(async (error) => {
28339
+ throw await refuseMissingOfRef(error, "message", named.id, { kind: "issue", issue: messageIssue }, messageIssue, () => client.getIssue(messageIssue));
28340
+ });
27916
28341
  const messageRef = dispatchChildRef(dispatchIssueRef(ownerArguments.ref.owner.issue), "message", ownerArguments.ref.id);
27917
28342
  const [pictures, graph] = await Promise.all([
27918
28343
  picturesOf(datedBodies([messageRead.message, ...messageRead.replies ?? []])),
@@ -27932,9 +28357,9 @@ async function readCommand(context) {
27932
28357
  return;
27933
28358
  }) : undefined;
27934
28359
  const [incoming, outgoing, partOf, typed] = await Promise.all([
27935
- client.getReferences({ to: blockRef }).catch((error) => {
28360
+ client.getReferences({ to: blockRef }).catch(async (error) => {
27936
28361
  if (ref.pin === undefined && dispatchAnswered(error, 404)) {
27937
- throw new Error(`No block ${ref.block} in ${holder}.`);
28362
+ throw new Error(`No block ${ref.block} in ${holder}.${await deletedPostClause(ref)}`);
27938
28363
  }
27939
28364
  throw error;
27940
28365
  }),
@@ -28136,7 +28561,9 @@ function renderSessionAnswerItem(item) {
28136
28561
  const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
28137
28562
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
28138
28563
  if (item.edited_at !== undefined)
28139
- head.push(`edited ${item.edited_at}`);
28564
+ head.push(editedMark(item.edited_at));
28565
+ if (item.deleted_at !== undefined)
28566
+ head.push(deletedMark(item.deleted_at, item.deleted_by));
28140
28567
  const owner = item.owner === null ? undefined : ownerTitle(item.owner);
28141
28568
  const where = item.ref === null ? `Direct message ${item.id}, on no issue` : owner === undefined ? item.ref : `${item.ref} \xB7 ${owner}`;
28142
28569
  const lines = [head.join(" \xB7 "), where];
@@ -28172,6 +28599,7 @@ function sessionAnswersWords(items) {
28172
28599
  actorActText(item.author.id, item.author.act),
28173
28600
  item.at,
28174
28601
  item.edited_at ?? null,
28602
+ item.deleted_at ?? null,
28175
28603
  item.selected ?? null,
28176
28604
  item.text,
28177
28605
  item.relation
@@ -28524,7 +28952,10 @@ function inboxThreadLine(row, now) {
28524
28952
  return [
28525
28953
  `- ${inboxThreadLabel(row)}`,
28526
28954
  row.kind,
28527
- textHead(row.subject, INBOX_QUESTION_HEAD),
28955
+ ...row.deleted_at == null ? [
28956
+ textHead(row.subject, INBOX_QUESTION_HEAD),
28957
+ ...row.edited_at == null ? [] : [editedMark(row.edited_at)]
28958
+ ] : [deletedMark(row.deleted_at, row.deleted_by)],
28528
28959
  actorText(row.reply.author),
28529
28960
  inboxReplyAge(row.reply.created_at, now),
28530
28961
  row.ref
@@ -28670,6 +29101,10 @@ var dispatchCommands = {
28670
29101
  dispatch_comment: acting(commentCommand),
28671
29102
  dispatch_suggest: acting(suggestCommand),
28672
29103
  dispatch_resolve_comment: acting(resolveCommentCommand),
29104
+ dispatch_edit_comment: acting(editCommentCommand),
29105
+ dispatch_delete_comment: acting(deleteCommentCommand),
29106
+ dispatch_edit_message: acting(editMessageCommand),
29107
+ dispatch_delete_message: acting(deleteMessageCommand),
28673
29108
  dispatch_message: acting(messageCommand),
28674
29109
  dispatch_send_to_agent: acting(sendToAgentCommand),
28675
29110
  dispatch_doc_edit: acting(docEditCommand),