@sjawhar/pi-envoy 16.35.0 → 16.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dispatch.js CHANGED
@@ -14578,6 +14578,9 @@ var PROJECT_NAME_MAX = 80;
14578
14578
  var MAX_ISSUE_PAGE_LIMIT = 250;
14579
14579
  var DEFAULT_ISSUE_PAGE_LIMIT = 50;
14580
14580
  var ASK_TURNS = ["human", "agent"];
14581
+ function inboxThreadRow(row) {
14582
+ return row.kind === "agent" ? row : row;
14583
+ }
14581
14584
  var DELIVERY_CAPABILITIES = ["aside", "btw", "steer"];
14582
14585
  var IDEMPOTENCY_KEY_HEADER = "Idempotency-Key";
14583
14586
  var IDEMPOTENCY_REPLAYED_HEADER = "Idempotency-Replayed";
@@ -14908,12 +14911,15 @@ var HOLDING_OF = {
14908
14911
  unknown: "unknown",
14909
14912
  unresponsive: "unresponsive"
14910
14913
  };
14914
+ function isHolderState(state) {
14915
+ return Object.hasOwn(HOLDING_OF, state);
14916
+ }
14911
14917
  function claimHolds(claim, titles, liveness = {}) {
14912
14918
  if (claim.actor.kind !== "session") {
14913
14919
  return "holds";
14914
14920
  }
14915
14921
  const state = liveness.holder_state;
14916
- if (state != null) {
14922
+ if (state != null && isHolderState(state)) {
14917
14923
  return HOLDING_OF[state];
14918
14924
  }
14919
14925
  if (titles === undefined) {
@@ -16805,8 +16811,9 @@ function relatedCheckFormOf(suggestions) {
16805
16811
  return { form: "not_made", reason: missing ?? "the server gave no reason", searchQuery };
16806
16812
  }
16807
16813
  const mode = relatedCheckModeWords(suggestions);
16808
- if (suggestions.related.length > 0) {
16809
- return { form: "items", mode, related: suggestions.related };
16814
+ const related = suggestions.related ?? [];
16815
+ if (related.length > 0) {
16816
+ return { form: "items", mode, related };
16810
16817
  }
16811
16818
  if (outcome === undefined) {
16812
16819
  return {
@@ -18496,7 +18503,12 @@ function documentLabel(project, slug) {
18496
18503
  return `${project}/${slug}`;
18497
18504
  }
18498
18505
  function ownerTitle(owner) {
18499
- return "issue" in owner ? `${owner.issue.key}: ${owner.issue.title}` : `${owner.document.project} / ${owner.document.name}`;
18506
+ const { issue, document } = owner;
18507
+ if (issue !== undefined)
18508
+ return `${issue.key}: ${issue.title}`;
18509
+ if (document !== undefined)
18510
+ return `${document.project} / ${document.name}`;
18511
+ return "";
18500
18512
  }
18501
18513
  function issueTopic(key) {
18502
18514
  return { label: key, topic: dispatchIssueSubject(key, ">") };
@@ -18759,10 +18771,10 @@ async function wholeCarriedBody(client, item, session) {
18759
18771
  try {
18760
18772
  if (item.resource === "comment") {
18761
18773
  const read = await client.getComment(item.id);
18762
- return [read.comment, ...read.replies].find((comment) => comment.id === item.id)?.body;
18774
+ return [read.comment, ...read.replies ?? []].find((comment) => comment.id === item.id)?.body;
18763
18775
  }
18764
18776
  const read = item.issueKey === null ? session === undefined ? undefined : await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
18765
- return read === undefined ? undefined : [read.message, ...read.replies].find((message) => message.id === item.id)?.body;
18777
+ return read === undefined ? undefined : [read.message, ...read.replies ?? []].find((message) => message.id === item.id)?.body;
18766
18778
  } catch {
18767
18779
  return;
18768
18780
  }
@@ -18851,7 +18863,7 @@ function askTexts({ ask, replies }) {
18851
18863
  { text: ask.question, at: ask.created_at },
18852
18864
  ...ask.answer?.text ? [{ text: ask.answer.text, at: ask.answer.at }] : [],
18853
18865
  ...ask.resolution === undefined ? [] : [{ text: ask.resolution.reason, at: ask.resolution.at }],
18854
- ...datedBodies(replies)
18866
+ ...datedBodies(replies ?? [])
18855
18867
  ];
18856
18868
  }
18857
18869
  function eventTexts(event) {
@@ -18974,7 +18986,7 @@ async function readPictures(client, addresses, shown) {
18974
18986
  artifacts.set(target.key, read);
18975
18987
  }
18976
18988
  const artifact = await read;
18977
- const version = artifact.versions.find((candidate) => candidate.number === target.version);
18989
+ const version = (artifact.versions ?? []).find((candidate) => candidate.number === target.version);
18978
18990
  if (version === undefined) {
18979
18991
  skip(`${artifact.name} has no version ${target.version}`);
18980
18992
  continue;
@@ -19064,7 +19076,7 @@ function searchHitLine(result, baseUrl) {
19064
19076
  const href = new URL(result.href, baseUrl).toString();
19065
19077
  const { owner } = result;
19066
19078
  if (owner.kind === "document") {
19067
- const reference = dispatchDocumentRef(owner.project, owner.slug);
19079
+ const reference = dispatchDocumentRef(owner.project ?? "", owner.slug ?? "");
19068
19080
  return `${reference} [document] ${owner.name} - ${result.kind}: ${snippetText(result.snippet)} -> ${href}`;
19069
19081
  }
19070
19082
  const artifactName = result.artifact ? ` ${result.artifact.name}` : "";
@@ -19076,7 +19088,8 @@ function indentedText(text) {
19076
19088
  `);
19077
19089
  }
19078
19090
  function answerLines(lead, answer) {
19079
- const selected = answer.selected.length === 0 ? "none" : answer.selected.join(", ");
19091
+ const chosen = answer.selected ?? [];
19092
+ const selected = chosen.length === 0 ? "none" : chosen.join(", ");
19080
19093
  const text = answer.text === null || answer.text === "" ? "none" : indentedText(answer.text);
19081
19094
  return [
19082
19095
  ` ${lead} by ${actorActText(answer.user, answer.act)} at ${answer.at} \xB7 options chosen: ${selected}`,
@@ -19090,16 +19103,21 @@ function askStateLines(ask) {
19090
19103
  if (ask === undefined) {
19091
19104
  return [" Answer state not reported by this Dispatch; open the link to read the ask."];
19092
19105
  }
19106
+ const resolution = ask.resolution;
19107
+ const closed = resolution === undefined ? "closed, and this Dispatch did not say by whom" : resolutionText(resolution);
19093
19108
  switch (ask.state) {
19094
19109
  case "open":
19095
19110
  return [" Open: no answer yet."];
19096
19111
  case "answered":
19097
- return answerLines("Answered", ask.answer);
19112
+ return ask.answer === undefined ? [" Answered; this Dispatch did not carry the answer. Open the link to read it."] : answerLines("Answered", ask.answer);
19098
19113
  case "resolved":
19099
- return ask.answer === undefined ? [` Closed with no answer: ${resolutionText(ask.resolution)}`] : [
19100
- ` Closed after an answer: ${resolutionText(ask.resolution)}`,
19101
- ...answerLines("Last answer", ask.answer)
19114
+ return ask.answer === undefined ? [` Closed with no answer: ${closed}`] : [` Closed after an answer: ${closed}`, ...answerLines("Last answer", ask.answer)];
19115
+ default: {
19116
+ const unreportedState = ask.state;
19117
+ return [
19118
+ ` Answer state "${String(unreportedState)}" is newer than this client; open the link to read the ask.`
19102
19119
  ];
19120
+ }
19103
19121
  }
19104
19122
  }
19105
19123
  function searchResultLine(result, baseUrl) {
@@ -19108,7 +19126,7 @@ function searchResultLine(result, baseUrl) {
19108
19126
  `) : line;
19109
19127
  }
19110
19128
  function searchAnswer(search, query, offset, configUrl) {
19111
- const results = search.results;
19129
+ const results = search.results ?? [];
19112
19130
  const count = results.length;
19113
19131
  const lines = results.map((result) => searchResultLine(result, configUrl));
19114
19132
  const noun = count === 1 ? "result" : "results";
@@ -19324,11 +19342,15 @@ var RELATION_PHRASES = {
19324
19342
  sent_you_a_message: "sent you a message",
19325
19343
  replied_to_your_message: "replied to your message"
19326
19344
  };
19345
+ function isSessionAnswerRelation(value) {
19346
+ return Object.hasOwn(RELATION_PHRASES, value);
19347
+ }
19327
19348
  function isNoAnswersRoute(error) {
19328
19349
  return isNoRoute(error);
19329
19350
  }
19330
19351
  function renderSessionAnswerItem(item) {
19331
- const relation = `${RELATION_PHRASES[item.relation]}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
19352
+ const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
19353
+ const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
19332
19354
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
19333
19355
  if (item.edited_at !== undefined)
19334
19356
  head.push(`edited ${item.edited_at}`);
@@ -19541,20 +19563,21 @@ function adviceMemory() {
19541
19563
  function renderAdvice(tool, key, advice, opts) {
19542
19564
  if (advice === undefined)
19543
19565
  return [];
19544
- const hasIssueAdvice = advice.issue_status !== undefined;
19545
- const openAsks = advice.your_open_asks;
19546
- const writesSinceHuman = advice.session_writes_since_human;
19566
+ const issueAdvice = "issue_status" in advice ? advice : undefined;
19567
+ const hasIssueAdvice = issueAdvice !== undefined;
19568
+ const openAsks = issueAdvice?.your_open_asks ?? undefined;
19569
+ const writesSinceHuman = issueAdvice?.session_writes_since_human;
19547
19570
  const lines = [];
19548
19571
  const unparsed = advice.unparsed_openers;
19549
19572
  if (unparsed !== undefined && unparsed.count > 0 && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
19550
- const quoted = unparsed.examples.map((example) => JSON.stringify(example)).join(", ");
19573
+ const quoted = (unparsed.examples ?? []).map((example) => JSON.stringify(example)).join(", ");
19551
19574
  const subject = unparsed.count === 1 ? "1 typed-block opening in this document is text, not a block" : `${unparsed.count} typed-block openings in this document are text, not blocks`;
19552
19575
  lines.push(`${subject}: ${quoted}. An opening like \`:::ask{\u2026}\` makes a block only as a line of its own, so as text it asks nobody. Mentioning the syntax on purpose? Put it in code. See the \`dispatch-writing-specs\` skill, "Questions".`);
19553
19576
  }
19554
19577
  if (advice.decision_blocks === 0 && opts.isPrimarySpec === true && (tool === "dispatch_issue" || tool === "dispatch_artifact")) {
19555
19578
  lines.push("This spec holds no ask blocks. A person does not watch your chat. They see that you need them only through an open ask or a spec that waits for their approval. If the design needs a person's choice, add an ask block. If it does not, request approval with `dispatch request-approval`.");
19556
19579
  }
19557
- if (advice.issue_status === "triage" && advice.legion_managed_status !== true && tool !== "dispatch_issue" && !(tool === "dispatch_issue_update" && opts.setsStatus === true) && !triageAdviceShown.has(key)) {
19580
+ if (issueAdvice?.issue_status === "triage" && issueAdvice.legion_managed_status !== true && tool !== "dispatch_issue" && !(tool === "dispatch_issue_update" && opts.setsStatus === true) && !triageAdviceShown.has(key)) {
19558
19581
  triageAdviceShown.add(key);
19559
19582
  lines.push(`${key} is still in triage \u2014 nobody can see its development status. See the \`dispatch\` skill, "Issue status is yours to move".`);
19560
19583
  }
@@ -19705,17 +19728,19 @@ function optionalComponents(args, name) {
19705
19728
  function componentsChange(input, after) {
19706
19729
  switch (input.mode) {
19707
19730
  case "explicit":
19708
- return `components -> explicit [${after.ids.join(", ")}]`;
19731
+ return `components -> explicit [${(after.ids ?? []).join(", ")}]`;
19709
19732
  case "none":
19710
19733
  return `components -> none (${after.reason ?? input.reason ?? ""})`;
19711
19734
  case "inherit":
19712
19735
  return "components -> inherit";
19736
+ default:
19737
+ return `components -> ${input.mode}`;
19713
19738
  }
19714
19739
  }
19715
19740
  var architectureComponentsAction = 'Review the `dispatch` skill, "Architecture components", to attach it to the parts it changes or mark it as non-architectural with a reason.';
19716
19741
  var LEGION_OWNS_STATUS = "Legion's daemon moves this issue's status on an issue it runs, so leave it alone \u2014 a status written here is undone.";
19717
19742
  async function architectureGuidance(client, project, components) {
19718
- if (components.mode === "none" || components.ids.length > 0)
19743
+ if (components.mode === "none" || (components.ids ?? []).length > 0)
19719
19744
  return;
19720
19745
  try {
19721
19746
  if ((await client.listArchitectureSources(project)).length === 0)
@@ -19906,7 +19931,7 @@ async function sessionOpenAsks(client, sessionId) {
19906
19931
  const session = sessionId?.trim();
19907
19932
  if (!session)
19908
19933
  throw new Error("host session id is required to read this session's open asks");
19909
- return (await client.openAsks(session)).asks;
19934
+ return (await client.openAsks(session)).asks ?? [];
19910
19935
  }
19911
19936
  function openAskHints(asks) {
19912
19937
  if (asks.length === 0)
@@ -20379,14 +20404,15 @@ async function resolveArtifact(client, owner, artifactReference, { canonical = f
20379
20404
  };
20380
20405
  }
20381
20406
  const issue = await client.getIssue(owner.issue);
20407
+ const issueArtifacts = issue.artifacts ?? [];
20382
20408
  let artifact;
20383
20409
  if (artifactReference === undefined || artifactReference === "spec") {
20384
- artifact = issue.artifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
20410
+ artifact = issueArtifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
20385
20411
  } else {
20386
- artifact = artifactByReference(issue.artifacts, artifactReference, { kind: "issue", issue: issue.key }, canonical);
20412
+ artifact = artifactByReference(issueArtifacts, artifactReference, { kind: "issue", issue: issue.key }, canonical);
20387
20413
  }
20388
20414
  if (!artifact) {
20389
- throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, {
20415
+ throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issueArtifacts, {
20390
20416
  kind: "issue",
20391
20417
  issue: issue.key
20392
20418
  }));
@@ -20492,7 +20518,7 @@ async function movedApprovalLine(client, askID) {
20492
20518
  async function invalidReplyToAskProblem(client, owner, resolved) {
20493
20519
  if (owner.kind === "issue") {
20494
20520
  const issue = resolved?.issue ?? await client.getIssue(owner.issue);
20495
- return askIDInputProblem(issue.open_asks, "this issue's");
20521
+ return askIDInputProblem(issue.open_asks ?? [], "this issue's");
20496
20522
  }
20497
20523
  if (resolved === undefined)
20498
20524
  throw new Error("project document is missing its resolved artifact");
@@ -20532,18 +20558,24 @@ function approvalLine(artifact) {
20532
20558
  return `Approval: approved v${approval.version} by ${approval.by?.id ?? "unknown"}, changed since (now v${approval.latest_version}) - the human's own answer to a decision block carries the approval when that answer is the whole change since v${approval.version}; for any other change, request approval again once the human has agreed to every point in this version, with a --summary naming what changed since v${approval.version}${content}`;
20533
20559
  case "changes_requested":
20534
20560
  return `Approval: changes requested on v${approval.version} by ${approval.by?.id ?? "unknown"}: ${approval.reason ?? ""}${content}`;
20561
+ default:
20562
+ return `Approval: ${approval.state} on v${approval.version}${content}`;
20535
20563
  }
20536
20564
  }
20537
20565
  function componentsLine(components) {
20566
+ const ids = components.ids ?? [];
20567
+ const unknown = components.unknown ?? [];
20538
20568
  const inherited = components.inherited_from === null ? "" : ` (inherited from ${components.inherited_from})`;
20539
- const retired = components.unknown.length === 0 ? "" : ` (retired: ${components.unknown.join(", ")})`;
20569
+ const retired = unknown.length === 0 ? "" : ` (retired: ${unknown.join(", ")})`;
20540
20570
  switch (components.mode) {
20541
20571
  case "explicit":
20542
- return `Components: ${components.ids.length === 0 ? "none live" : components.ids.join(", ")}${inherited}${retired}`;
20572
+ return `Components: ${ids.length === 0 ? "none live" : ids.join(", ")}${inherited}${retired}`;
20543
20573
  case "none":
20544
20574
  return `Components: none \u2014 ${components.reason ?? ""}${inherited}`;
20545
20575
  case "inherit":
20546
20576
  return "Components: unassigned";
20577
+ default:
20578
+ return `Components: ${components.mode}${inherited}${retired}`;
20547
20579
  }
20548
20580
  }
20549
20581
  function claimText(claim, agents, read = {}) {
@@ -20593,6 +20625,9 @@ function agentLiveness(agent) {
20593
20625
  function holdsSession(claim) {
20594
20626
  return claim?.actor.kind === "session";
20595
20627
  }
20628
+ function isRouteStatus(value) {
20629
+ return ISSUE_ROUTE_STATUSES.some((status) => status === value);
20630
+ }
20596
20631
  function routeHeldBySession(issue) {
20597
20632
  return issue.route_status === "live" && issue.route?.startsWith("role:") === true;
20598
20633
  }
@@ -20606,7 +20641,8 @@ function routeText(issue, titles) {
20606
20641
  no_holder: issue.route.startsWith("role:") ? " (nobody holds it right now)" : " (that session is not running right now)",
20607
20642
  unknown: issue.route_status_reason === "refilling" ? " (the Envoy listener's agent list is refilling, so whether it reaches anyone is unknown; try again in a moment)" : " (the Envoy listener did not answer, so whether it reaches anyone is unknown)"
20608
20643
  };
20609
- return issue.route + (issue.route_status == null ? "" : reach[issue.route_status]);
20644
+ const status = issue.route_status;
20645
+ return issue.route + (status != null && isRouteStatus(status) ? reach[status] : "");
20610
20646
  }
20611
20647
  function progressText(progress, sep) {
20612
20648
  if (progress === undefined)
@@ -20623,12 +20659,13 @@ function formatCheckResults(results) {
20623
20659
  if (results.verification_artifact_id === "") {
20624
20660
  return `${results.issue} has no Verification document, so it has no checks. Write one (verification.md) with a check block per thing that must be proved.`;
20625
20661
  }
20626
- if (results.checks.length === 0) {
20662
+ const checks = results.checks ?? [];
20663
+ if (checks.length === 0) {
20627
20664
  return `${results.issue}'s Verification document holds no check blocks.`;
20628
20665
  }
20629
- const lines = results.checks.map((check) => {
20666
+ const lines = checks.map((check) => {
20630
20667
  const head = `- ${check.block_id} (${check.when}): `;
20631
- const latest = check.results[0];
20668
+ const latest = (check.results ?? [])[0];
20632
20669
  if (latest === undefined) {
20633
20670
  return `${head}no result yet. ${check.text}`;
20634
20671
  }
@@ -20663,7 +20700,10 @@ function refuseUnsavedRepository(verb, issue, repo) {
20663
20700
  throw new Error(`Dispatch ${verb} ${issue.key} without its repository: this Dispatch server predates repository fields, so ${lost}; upgrade the server`);
20664
20701
  }
20665
20702
  function issueSummary(issue, events, references, graph, linkBase, coverage, agents) {
20666
- const asks = issue.open_asks;
20703
+ const asks = issue.open_asks ?? [];
20704
+ const labels = issue.labels ?? [];
20705
+ const links = issue.external_links ?? [];
20706
+ const members = typeof references === "string" ? [] : references.members ?? [];
20667
20707
  const spec = issue.artifacts?.find((artifact) => artifact.primary);
20668
20708
  const specApproval = spec === undefined ? undefined : approvalLine(spec);
20669
20709
  if (issue.priority === undefined)
@@ -20685,21 +20725,21 @@ function issueSummary(issue, events, references, graph, linkBase, coverage, agen
20685
20725
  `Assignee: ${issue.assignee ?? "unassigned"}`,
20686
20726
  `Claimed by: ${issue.claim === null ? "nobody" : claimText(issue.claim, agents, issue)}`,
20687
20727
  ...issue.priority === null ? [] : [`Priority: P${issue.priority}`],
20688
- `Labels: ${issue.labels.length === 0 ? "none" : issue.labels.join(", ")}`,
20728
+ `Labels: ${labels.length === 0 ? "none" : labels.join(", ")}`,
20689
20729
  componentsLine(issue.components),
20690
20730
  `Route: ${routeText(issue, agents?.titles)}`,
20691
20731
  repositoryLine(issue),
20692
20732
  `Progress: ${progressText(issue.progress, ", ") || "none"}`,
20693
20733
  ...specApproval === undefined ? [] : [`Spec ${specApproval.replace(/^Approval/, "approval")}`],
20694
- ...typeof coverage === "string" ? [`Coverage: ${coverage}`] : coverage.gaps.map((gap) => `Coverage: ${gap}`),
20734
+ ...typeof coverage === "string" ? [`Coverage: ${coverage}`] : (coverage.gaps ?? []).map((gap) => `Coverage: ${gap}`),
20695
20735
  "External links:",
20696
- ...issue.external_links.length === 0 ? ["- none"] : issue.external_links.map((link) => `- ${link.url}${link.kind === undefined ? "" : ` (${link.kind})`}`),
20736
+ ...links.length === 0 ? ["- none"] : links.map((link) => `- ${link.url}${link.kind === undefined ? "" : ` (${link.kind})`}`),
20697
20737
  "Documents:",
20698
20738
  ...documentListLines(issue.artifacts ?? []),
20699
20739
  "Open asks:",
20700
20740
  ...asks.length === 0 ? ["- none"] : asks.map((ask) => `- ${ask.id}: ${ask.question}`),
20701
20741
  "References:",
20702
- ...typeof references === "string" ? [`- ${references}`] : references.members.length === 0 ? ["- none"] : references.members.map(({ artifact, depth, via }) => `- ${artifact.project}/${artifact.slug} \xB7 depth ${depth} via ${via.kind} ${via.id}`),
20742
+ ...typeof references === "string" ? [`- ${references}`] : members.length === 0 ? ["- none"] : members.map(({ artifact, depth, via }) => `- ${artifact.project}/${artifact.slug} \xB7 depth ${depth} via ${via.kind} ${via.id}`),
20703
20743
  ...typeof references === "string" || !references.truncated ? [] : ["- more references beyond 8 hops"],
20704
20744
  "Events:",
20705
20745
  ...events.length === 0 ? ["- none"] : events.map(eventLine),
@@ -20710,9 +20750,10 @@ function issueSummary(issue, events, references, graph, linkBase, coverage, agen
20710
20750
  function referenceLines(read) {
20711
20751
  if (typeof read === "string")
20712
20752
  return [`- ${read}`];
20713
- if (read.edges.length === 0)
20753
+ const edges = read.edges ?? [];
20754
+ if (edges.length === 0)
20714
20755
  return ["- none"];
20715
- return read.edges.map(edgeLine);
20756
+ return edges.map(edgeLine);
20716
20757
  }
20717
20758
  function isItemKind(kind) {
20718
20759
  return ITEM_KINDS.some((item) => item === kind);
@@ -20769,7 +20810,7 @@ function graphSectionLines(incoming, outgoing) {
20769
20810
  function nodeLine(node) {
20770
20811
  if (node.made_by === undefined)
20771
20812
  return [];
20772
- const fact = (by, time) => `${by === undefined || by.length === 0 ? "nobody recorded" : by.map(actorText).join(", ")}${time == null ? "" : ` at ${time}`}`;
20813
+ const fact = (by, time) => `${by == null || by.length === 0 ? "nobody recorded" : by.map(actorText).join(", ")}${time == null ? "" : ` at ${time}`}`;
20773
20814
  const made = fact(node.made_by, node.made_at);
20774
20815
  const changed = fact(node.changed_by, node.changed_at);
20775
20816
  const { parent } = node;
@@ -20817,9 +20858,9 @@ async function typedBlockOf(client, ref) {
20817
20858
  function askPartNoun(ask, node, blockID) {
20818
20859
  if (ask.answer?.id === blockID)
20819
20860
  return "Answer";
20820
- if (ask.options.some((option) => option.id === blockID))
20861
+ if ((ask.options ?? []).some((option) => option.id === blockID))
20821
20862
  return "Option";
20822
- const placed = (ask.revision ?? 0) > 0 && ask.options.every((option) => option.id !== undefined) && (ask.answer === null || ask.answer.id !== undefined);
20863
+ const placed = (ask.revision ?? 0) > 0 && (ask.options ?? []).every((option) => option.id !== undefined) && (ask.answer === null || ask.answer.id !== undefined);
20823
20864
  return placed && node.pin?.state !== "removed" ? "Question" : "Part";
20824
20865
  }
20825
20866
  function logSummary(issue, events) {
@@ -20892,16 +20933,16 @@ function childrenSummary(issue) {
20892
20933
  return [
20893
20934
  `Key: ${issue.key}`,
20894
20935
  "Children:",
20895
- ...issue.children.length === 0 ? ["- none"] : issue.children.map((child) => `- ${child.key}: ${child.title} (${child.status})`)
20936
+ ...(issue.children ?? []).length === 0 ? ["- none"] : (issue.children ?? []).map((child) => `- ${child.key}: ${child.title} (${child.status})`)
20896
20937
  ].join(`
20897
20938
  `);
20898
20939
  }
20899
20940
  function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgoing) {
20900
20941
  const answer = ask.answer;
20901
- const earlierAnswers = answers.slice(0, -1);
20942
+ const earlierAnswers = (answers ?? []).slice(0, -1);
20902
20943
  const parts = askPartEdges(ask, incoming);
20903
20944
  const partRef = (id) => `${askRef}#b-${encodeBlockId(id)}`;
20904
- const chain = replies.flatMap((reply) => [
20945
+ const chain = (replies ?? []).flatMap((reply) => [
20905
20946
  `${reply.id} \xB7 ${actorText(reply.author)}`,
20906
20947
  `Body: ${reply.body}`
20907
20948
  ]);
@@ -20909,7 +20950,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
20909
20950
  `Question: ${ask.question}`,
20910
20951
  ...anchorLines(ask),
20911
20952
  "Options:",
20912
- ...ask.options.length === 0 ? ["- none"] : ask.options.flatMap((option) => [
20953
+ ...(ask.options ?? []).length === 0 ? ["- none"] : (ask.options ?? []).flatMap((option) => [
20913
20954
  `- ${option.label}${option.description ? ` \u2014 ${option.description}` : ""}${option.id === undefined ? "" : ` (${partRef(option.id)})`}`,
20914
20955
  ...partReferenceLines(parts.at, option.id)
20915
20956
  ]),
@@ -20918,7 +20959,7 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
20918
20959
  "Answer:",
20919
20960
  ...answer === null ? ["- none"] : [
20920
20961
  `- By: ${actorActText(answer.user, answer.act)}`,
20921
- `- Selected: ${answer.selected.length === 0 ? "none" : answer.selected.join(", ")}`,
20962
+ `- Selected: ${(answer.selected ?? []).length === 0 ? "none" : (answer.selected ?? []).join(", ")}`,
20922
20963
  ...answer.text === null ? [] : [`- Text: ${answer.text}`],
20923
20964
  ...answer.id === undefined ? [] : [`- Reference: ${partRef(answer.id)}`],
20924
20965
  ...partReferenceLines(parts.at, answer.id)
@@ -20941,12 +20982,12 @@ function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgo
20941
20982
  `);
20942
20983
  }
20943
20984
  function askPartEdges(ask, incoming) {
20944
- const ids = new Set([...ask.options.map((option) => option.id), ask.answer?.id].filter((id) => id !== undefined));
20985
+ const ids = new Set([...(ask.options ?? []).map((option) => option.id), ask.answer?.id].filter((id) => id !== undefined));
20945
20986
  const at = new Map;
20946
20987
  if (typeof incoming === "string" || ids.size === 0)
20947
20988
  return { at, rest: incoming };
20948
20989
  const rest = [];
20949
- for (const edge of incoming.edges) {
20990
+ for (const edge of incoming.edges ?? []) {
20950
20991
  const part = edge.block?.block_id;
20951
20992
  if (part === undefined || !ids.has(part)) {
20952
20993
  rest.push(edge);
@@ -20990,8 +21031,8 @@ function formatOpenAsksSummary(response, baseUrl) {
20990
21031
  return ["There are no unanswered asks for this session.", `Scope: ${scope}.`].join(`
20991
21032
  `);
20992
21033
  }
20993
- const waitingOnHuman = response.asks.filter((ask) => ask.waiting_on === "human");
20994
- const waitingOnAgent = response.asks.filter((ask) => ask.waiting_on === "agent");
21034
+ const waitingOnHuman = (response.asks ?? []).filter((ask) => ask.waiting_on === "human");
21035
+ const waitingOnAgent = (response.asks ?? []).filter((ask) => ask.waiting_on === "agent");
20995
21036
  return [
20996
21037
  `${response.count} unanswered ${response.count === 1 ? "ask" : "asks"} you authored on active issues and project documents.`,
20997
21038
  "",
@@ -21004,7 +21045,7 @@ function formatOpenAsksSummary(response, baseUrl) {
21004
21045
  `);
21005
21046
  }
21006
21047
  function whoamiPerson(identity) {
21007
- return identity.kind === "agent" ? identity.owner : identity.login.toLowerCase();
21048
+ return identity.kind === "user" ? identity.login.toLowerCase() : identity.owner;
21008
21049
  }
21009
21050
  var INBOX_QUESTION_HEAD = 80;
21010
21051
  function inboxSnoozed(row, now) {
@@ -21016,7 +21057,8 @@ function inboxSnoozed(row, now) {
21016
21057
  function inboxSection(row, now) {
21017
21058
  if (inboxSnoozed(row, now))
21018
21059
  return "later";
21019
- return row.waiting_on;
21060
+ const waiting = row.waiting_on;
21061
+ return waiting === "agent" || waiting === "human" ? waiting : undefined;
21020
21062
  }
21021
21063
  function inboxAskOwner(row) {
21022
21064
  const key = row.issue?.key ?? row.issue_key;
@@ -21038,9 +21080,10 @@ function inboxAskLine(row) {
21038
21080
  return `- ${label} \xB7 ${priority} \xB7 ${row.kind} \xB7 ${textHead(row.question, INBOX_QUESTION_HEAD)} \xB7 ${ref}`;
21039
21081
  }
21040
21082
  function inboxThreadLabel(row) {
21041
- if (row.kind === "agent")
21042
- return row.session.name;
21043
- return row.issue?.key ?? row.document?.slug ?? row.thread_id;
21083
+ const thread = inboxThreadRow(row);
21084
+ if (thread.kind === "agent")
21085
+ return thread.session.name;
21086
+ return thread.issue?.key ?? thread.document?.slug ?? thread.thread_id;
21044
21087
  }
21045
21088
  function inboxReplyAge(at, now) {
21046
21089
  const minutes = Math.floor(Math.max(0, now - Date.parse(at)) / 60000);
@@ -21067,7 +21110,7 @@ function credentialRequestLine(request) {
21067
21110
  const session = request.session ?? null;
21068
21111
  return [
21069
21112
  `- ${request.kind}`,
21070
- request.identifiers.join(", "),
21113
+ (request.identifiers ?? []).join(", "),
21071
21114
  request.requested_at,
21072
21115
  ...session === null ? [] : [`session request=${session.request ?? "-"}, enrollment=${session.enrollment ?? "-"}`],
21073
21116
  ...request.approve_url === undefined ? [] : [request.approve_url]
@@ -21108,7 +21151,7 @@ function commentSummary({ comment, replies }, graph) {
21108
21151
  ...replyBlockLines(comment),
21109
21152
  `Body: ${comment.body}`
21110
21153
  ];
21111
- const chain = replies.flatMap((reply) => [
21154
+ const chain = (replies ?? []).flatMap((reply) => [
21112
21155
  `${reply.id} \xB7 ${actorText(reply.author)}`,
21113
21156
  ...anchorLines(reply),
21114
21157
  ...replyBlockLines(reply),
@@ -21141,10 +21184,10 @@ function anchorLines(record) {
21141
21184
  }
21142
21185
  function positionText(block) {
21143
21186
  const { table, path } = block;
21144
- const segments = path.map((entry) => `${entry.type}[${entry.index}]`);
21187
+ const segments = (path ?? []).map((entry) => `${entry.type}[${entry.index}]`);
21145
21188
  if (table === undefined || table.row === null)
21146
21189
  return segments.join(" \u203A ");
21147
- const tableAt = path.findIndex((entry) => entry.type === "table");
21190
+ const tableAt = (path ?? []).findIndex((entry) => entry.type === "table");
21148
21191
  const cells = table.cells ?? [];
21149
21192
  const label = (table.column === null ? cells : cells.slice(0, table.column)).map((cell) => cell.trim()).filter((cell) => cell !== "" && !/^\d+$/.test(cell)).join(" \xB7 ");
21150
21193
  const row = label === "" ? `row ${table.row}` : `row ${table.row} (${label})`;
@@ -21160,7 +21203,7 @@ function messageSummary({ message, replies }, graph) {
21160
21203
  ...replyBlockLines(message),
21161
21204
  `Body: ${message.body}`
21162
21205
  ];
21163
- const chain = replies.flatMap((reply) => [
21206
+ const chain = (replies ?? []).flatMap((reply) => [
21164
21207
  `${reply.id} \xB7 ${actorText(reply.author)}`,
21165
21208
  ...replyBlockLines(reply),
21166
21209
  `Body: ${reply.body}`
@@ -21238,7 +21281,8 @@ async function blockAsks(client, resolved, state) {
21238
21281
  return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
21239
21282
  }
21240
21283
  async function readUploadedFile(client, artifact, details, requested, owner, shown) {
21241
- const latest = Math.max(0, ...artifact.versions.map((version) => version.number));
21284
+ const versions = artifact.versions ?? [];
21285
+ const latest = Math.max(0, ...versions.map((version) => version.number));
21242
21286
  const number = requested ?? latest;
21243
21287
  const of = number === latest ? "" : ` of ${latest}`;
21244
21288
  const bytesRoute = `GET /api/v1/artifacts/${artifact.id}/versions/${number} serves its bytes.`;
@@ -21246,7 +21290,7 @@ async function readUploadedFile(client, artifact, details, requested, owner, sho
21246
21290
  text: `${oversizePictureText(artifact.name, bytes)}, so dispatch doc-read cannot show this ` + `uploaded ${mime} picture (version ${number}${of}). ${bytesRoute}`,
21247
21291
  details
21248
21292
  });
21249
- const stated = artifact.versions.find((version) => version.number === number);
21293
+ const stated = versions.find((version) => version.number === number);
21250
21294
  if (artifact.kind === "image" && stated?.size !== undefined && stated.size > PICTURE_SHOWN_MAX_BYTES) {
21251
21295
  return tooLarge(stated.mime ?? "image", stated.size);
21252
21296
  }
@@ -21313,9 +21357,9 @@ async function listDocumentBlocks(client, artifact) {
21313
21357
  if (block.table === undefined) {
21314
21358
  lines.push(`${indent} This Dispatch does not report table rows yet, so no row or column index is listed.`);
21315
21359
  } else {
21316
- for (const row of block.table.rows) {
21360
+ for (const row of block.table.rows ?? []) {
21317
21361
  lines.push(`${indent} row ${row.index}, ${row.id === "" ? "no id yet" : `id ${row.id}`}`);
21318
- for (const cell of row.cells) {
21362
+ for (const cell of row.cells ?? []) {
21319
21363
  const under = cell.header === "" ? "" : `, under ${JSON.stringify(cell.header)}`;
21320
21364
  lines.push(`${indent} row ${cell.row} column ${cell.column}, ${cell.id === "" ? "no id yet" : `id ${cell.id}`}${under}: ${cell.text === "" ? "(empty)" : cell.text}`);
21321
21365
  }
@@ -21536,7 +21580,7 @@ async function executeDispatchTool(input) {
21536
21580
  throw error;
21537
21581
  }
21538
21582
  return {
21539
- text: renderSessionAnswersList(response.items, { now: Date.now() }),
21583
+ text: renderSessionAnswersList(response.items ?? [], { now: Date.now() }),
21540
21584
  details: { session: sessionId, since: response.since, total: response.total }
21541
21585
  };
21542
21586
  }
@@ -21547,9 +21591,10 @@ async function executeDispatchTool(input) {
21547
21591
  const client = dispatchClient();
21548
21592
  const identity = await client.whoami();
21549
21593
  const owner = whoamiPerson(identity);
21550
- const service = identity.kind === "agent" ? identity.service ?? null : null;
21551
- const proved = identity.kind === "agent" ? identity.session ?? null : null;
21552
- const project = identity.kind === "agent" ? identity.project ?? null : null;
21594
+ const agent = identity.kind === "agent" ? identity : undefined;
21595
+ const service = agent?.service ?? null;
21596
+ const proved = agent?.session ?? null;
21597
+ const project = agent?.project ?? null;
21553
21598
  const session = proved ?? sessionId;
21554
21599
  const unowned = "no owner, so an issue you create without an assignee takes its parent's assignee, else the project's default assignee, else nobody.";
21555
21600
  const signInNeeded = owner === null && service !== null && proved !== null;
@@ -21759,9 +21804,10 @@ async function executeDispatchTool(input) {
21759
21804
  throw withAccount(error, told);
21760
21805
  }
21761
21806
  }
21762
- const linked = before.external_links.map((link) => link.url);
21807
+ const existingLinks = before.external_links ?? [];
21808
+ const linked = existingLinks.map((link) => link.url);
21763
21809
  const newLinks = requestedLinks?.filter((url) => !linked.includes(url)) ?? [];
21764
- const sentLinks = requestedLinks === undefined ? undefined : requestedLinks.length === 0 ? [] : [...before.external_links, ...newLinks.map((url) => ({ url }))];
21810
+ const sentLinks = requestedLinks === undefined ? undefined : requestedLinks.length === 0 ? [] : [...existingLinks, ...newLinks.map((url) => ({ url }))];
21765
21811
  const rank = rankBefore === undefined && rankAfter === undefined ? undefined : {
21766
21812
  ...rankBefore === undefined ? {} : { before: rankBefore },
21767
21813
  ...rankAfter === undefined ? {} : { after: rankAfter }
@@ -21796,12 +21842,15 @@ async function executeDispatchTool(input) {
21796
21842
  throw withAccount(error, landed);
21797
21843
  }
21798
21844
  refuseUnsavedRepository("updated", after, repo);
21799
- const linkCount = `(${after.external_links.length} ${after.external_links.length === 1 ? "link" : "links"})`;
21845
+ const links = after.external_links ?? [];
21846
+ const linkCount = `(${links.length} ${links.length === 1 ? "link" : "links"})`;
21800
21847
  const changes = [
21801
21848
  ...closingNote === undefined ? [] : [`reason posted as message ${closingNote.id} (${closingNote.ref})`],
21802
21849
  ...status === undefined ? [] : [`status ${before.status} -> ${after.status}`],
21803
21850
  ...title === undefined ? [] : [`title "${after.title}"`],
21804
- ...labels === undefined ? [] : [after.labels.length === 0 ? "labels cleared" : `labels ${after.labels.join(", ")}`],
21851
+ ...labels === undefined ? [] : [
21852
+ (after.labels ?? []).length === 0 ? "labels cleared" : `labels ${(after.labels ?? []).join(", ")}`
21853
+ ],
21805
21854
  ...priority === undefined ? [] : [after.priority === null ? "priority cleared" : `priority -> P${after.priority}`],
21806
21855
  ...rank === undefined ? [] : [
21807
21856
  `rank -> ${[
@@ -21815,7 +21864,7 @@ async function executeDispatchTool(input) {
21815
21864
  ...route === undefined ? [] : [after.route === null ? "route cleared" : `route ${after.route}`],
21816
21865
  ...parent === undefined ? [] : [after.parent === null ? "parent cleared" : `parent -> ${after.parent}`],
21817
21866
  ...blockedBy === undefined ? [] : [
21818
- after.blocked_by.length === 0 ? "blocked_by cleared" : `blocked by ${after.blocked_by.join(", ")}`
21867
+ (after.blocked_by ?? []).length === 0 ? "blocked_by cleared" : `blocked by ${(after.blocked_by ?? []).join(", ")}`
21819
21868
  ],
21820
21869
  ...components === undefined ? [] : [componentsChange(components, after.components)],
21821
21870
  ...repo === undefined ? [] : [
@@ -21834,7 +21883,7 @@ async function executeDispatchTool(input) {
21834
21883
  details: {
21835
21884
  issue: after.key,
21836
21885
  status: after.status,
21837
- external_links: after.external_links.map((link) => link.url),
21886
+ external_links: (after.external_links ?? []).map((link) => link.url),
21838
21887
  ...closingNote === undefined ? {} : { message: closingNote.id },
21839
21888
  ...after.advice === undefined ? {} : { advice: after.advice }
21840
21889
  }
@@ -21930,7 +21979,7 @@ async function executeDispatchTool(input) {
21930
21979
  offset: optionalNumber(args, "offset") ?? 0
21931
21980
  });
21932
21981
  const { total, limit, offset } = page;
21933
- const rows = page.issues.map((row) => ({
21982
+ const rows = (page.issues ?? []).map((row) => ({
21934
21983
  key: row.key,
21935
21984
  title: row.title,
21936
21985
  status: row.status,
@@ -22449,7 +22498,7 @@ ${recorded.line}`,
22449
22498
  const results = await client.issueResults(issue);
22450
22499
  return {
22451
22500
  text: formatCheckResults(results),
22452
- details: { issue, checks: results.checks.length }
22501
+ details: { issue, checks: (results.checks ?? []).length }
22453
22502
  };
22454
22503
  }
22455
22504
  case "dispatch_artifact": {
@@ -22581,7 +22630,7 @@ ${handoff.body}`,
22581
22630
  const thread = await client.getMessageThread(messageIdOf(message), sessionId);
22582
22631
  const issueKey = thread.message.issue_key;
22583
22632
  const [pictures, graph] = await Promise.all([
22584
- picturesOf(datedBodies([thread.message, ...thread.replies])),
22633
+ picturesOf(datedBodies([thread.message, ...thread.replies ?? []])),
22585
22634
  issueKey === null ? [] : graphSections(client, dispatchChildRef(dispatchIssueRef(issueKey), "message", thread.message.id))
22586
22635
  ]);
22587
22636
  return {
@@ -22621,7 +22670,7 @@ ${handoff.body}`,
22621
22670
  await refuseItemOffRef(input.tool, "comment", ref, stringArg(args, "ref"), comment.comment, () => documentIdOf(ref));
22622
22671
  const commentRef = refTarget(ref, "comment", id);
22623
22672
  const [pictures, graph] = await Promise.all([
22624
- picturesOf(datedBodies([comment.comment, ...comment.replies])),
22673
+ picturesOf(datedBodies([comment.comment, ...comment.replies ?? []])),
22625
22674
  graphSections(client, commentRef)
22626
22675
  ]);
22627
22676
  return {
@@ -22637,7 +22686,7 @@ ${handoff.body}`,
22637
22686
  const messageRead = await client.getMessage(ownerArguments.ref.owner.issue, ownerArguments.ref.id);
22638
22687
  const messageRef = dispatchChildRef(dispatchIssueRef(ownerArguments.ref.owner.issue), "message", ownerArguments.ref.id);
22639
22688
  const [pictures, graph] = await Promise.all([
22640
- picturesOf(datedBodies([messageRead.message, ...messageRead.replies])),
22689
+ picturesOf(datedBodies([messageRead.message, ...messageRead.replies ?? []])),
22641
22690
  graphSections(client, messageRef)
22642
22691
  ]);
22643
22692
  return {
@@ -22705,7 +22754,7 @@ ${handoff.body}`,
22705
22754
  `Issue: ${resolved.issue.key} [${resolved.issue.status}] ${resolved.issue.title}`
22706
22755
  ],
22707
22756
  `Reference: ${documentRef}`,
22708
- `Versions: ${artifact.versions.length}`,
22757
+ `Versions: ${(artifact.versions ?? []).length}`,
22709
22758
  ...approval === undefined ? [] : [approval],
22710
22759
  ...await graphSections(client, documentRef)
22711
22760
  ].join(`
@@ -22745,7 +22794,10 @@ ${handoff.body}`,
22745
22794
  graphSections(client, dispatchIssueRef(read.issue.key)),
22746
22795
  liveAgents(client, holdsSession(read.issue.claim) || routeHeldBySession(read.issue)),
22747
22796
  picturesOf([
22748
- ...read.issue.open_asks.map((ask) => ({ text: ask.question, at: ask.created_at })),
22797
+ ...(read.issue.open_asks ?? []).map((ask) => ({
22798
+ text: ask.question,
22799
+ at: ask.created_at
22800
+ })),
22749
22801
  ...await eventTextsWhole(client, read.events)
22750
22802
  ]),
22751
22803
  issueCoverageOrReason(client, read.issue.key)
package/dist/envoy.js CHANGED
@@ -29668,6 +29668,7 @@ var ISSUE_TITLE_MAX = 1000;
29668
29668
  var PROJECT_NAME_MAX = 80;
29669
29669
  var MAX_ISSUE_PAGE_LIMIT = 250;
29670
29670
  var DEFAULT_ISSUE_PAGE_LIMIT = 50;
29671
+ var TMUX_LAYOUT_MAX = 2000;
29671
29672
  var ASK_TURNS = ["human", "agent"];
29672
29673
  var DELIVERY_CAPABILITIES = ["aside", "btw", "steer"];
29673
29674
  var IDEMPOTENCY_KEY_HEADER = "Idempotency-Key";
@@ -29687,7 +29688,6 @@ function answerNotKept(status, replayed, body) {
29687
29688
  var IDEMPOTENCY_KEY_TTL_MS = 24 * 60 * 60 * 1000;
29688
29689
  var IDEMPOTENCY_LEASE_MS = 60 * 1000;
29689
29690
  var DELIVERY_DUPLICATE_WINDOW_MS = 72 * 60 * 60 * 1000;
29690
- var TMUX_LAYOUT_MAX = 2000;
29691
29691
  var IssueDeployedEventPayloadSchema = strictObject({
29692
29692
  repo: string2(),
29693
29693
  number: number2().int().positive(),
@@ -36299,7 +36299,12 @@ class DispatchClient {
36299
36299
 
36300
36300
  // ../envoy-client/src/dispatch-owner.ts
36301
36301
  function ownerTitle(owner) {
36302
- return "issue" in owner ? `${owner.issue.key}: ${owner.issue.title}` : `${owner.document.project} / ${owner.document.name}`;
36302
+ const { issue, document } = owner;
36303
+ if (issue !== undefined)
36304
+ return `${issue.key}: ${issue.title}`;
36305
+ if (document !== undefined)
36306
+ return `${document.project} / ${document.name}`;
36307
+ return "";
36303
36308
  }
36304
36309
  function dispatchIssueRef(key) {
36305
36310
  return `dispatch://${key}`;
@@ -36756,10 +36761,10 @@ async function wholeCarriedBody(client, item, session) {
36756
36761
  try {
36757
36762
  if (item.resource === "comment") {
36758
36763
  const read = await client.getComment(item.id);
36759
- return [read.comment, ...read.replies].find((comment) => comment.id === item.id)?.body;
36764
+ return [read.comment, ...read.replies ?? []].find((comment) => comment.id === item.id)?.body;
36760
36765
  }
36761
36766
  const read = item.issueKey === null ? session === undefined ? undefined : await client.getMessageThread(item.id, session) : await client.getMessage(item.issueKey, item.id);
36762
- return read === undefined ? undefined : [read.message, ...read.replies].find((message) => message.id === item.id)?.body;
36767
+ return read === undefined ? undefined : [read.message, ...read.replies ?? []].find((message) => message.id === item.id)?.body;
36763
36768
  } catch {
36764
36769
  return;
36765
36770
  }
@@ -40038,7 +40043,7 @@ async function readPictures(client, addresses, shown) {
40038
40043
  artifacts.set(target.key, read);
40039
40044
  }
40040
40045
  const artifact = await read;
40041
- const version = artifact.versions.find((candidate) => candidate.number === target.version);
40046
+ const version = (artifact.versions ?? []).find((candidate) => candidate.number === target.version);
40042
40047
  if (version === undefined) {
40043
40048
  skip(`${artifact.name} has no version ${target.version}`);
40044
40049
  continue;
@@ -40149,6 +40154,9 @@ var RELATION_PHRASES = {
40149
40154
  sent_you_a_message: "sent you a message",
40150
40155
  replied_to_your_message: "replied to your message"
40151
40156
  };
40157
+ function isSessionAnswerRelation(value) {
40158
+ return Object.hasOwn(RELATION_PHRASES, value);
40159
+ }
40152
40160
  function isSessionAnswersText(text) {
40153
40161
  return text.startsWith(SESSION_ANSWERS_MARKER) || text.startsWith(FAILURE_MARKER);
40154
40162
  }
@@ -40156,7 +40164,8 @@ function isNoAnswersRoute(error) {
40156
40164
  return isNoRoute(error);
40157
40165
  }
40158
40166
  function renderSessionAnswerItem(item) {
40159
- const relation = `${RELATION_PHRASES[item.relation]}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
40167
+ const phrase = isSessionAnswerRelation(item.relation) ? RELATION_PHRASES[item.relation] : item.relation;
40168
+ const relation = `${phrase}${item.replaced === true ? " (replaces an earlier answer)" : ""}`;
40160
40169
  const head = [item.at, actorActText(`user ${item.author.id}`, item.author.act), relation];
40161
40170
  if (item.edited_at !== undefined)
40162
40171
  head.push(`edited ${item.edited_at}`);
@@ -40901,14 +40910,15 @@ async function resolveArtifact(client, owner, artifactReference, { canonical = f
40901
40910
  };
40902
40911
  }
40903
40912
  const issue = await client.getIssue(owner.issue);
40913
+ const issueArtifacts = issue.artifacts ?? [];
40904
40914
  let artifact;
40905
40915
  if (artifactReference === undefined || artifactReference === "spec") {
40906
- artifact = issue.artifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
40916
+ artifact = issueArtifacts.find((candidate) => candidate.primary || candidate.id === issue.primary_artifact_id);
40907
40917
  } else {
40908
- artifact = artifactByReference(issue.artifacts, artifactReference, { kind: "issue", issue: issue.key }, canonical);
40918
+ artifact = artifactByReference(issueArtifacts, artifactReference, { kind: "issue", issue: issue.key }, canonical);
40909
40919
  }
40910
40920
  if (!artifact) {
40911
- throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issue.artifacts, {
40921
+ throw new DocumentNotFoundError(documentReferenceProblem(artifactReference ?? "spec", issueArtifacts, {
40912
40922
  kind: "issue",
40913
40923
  issue: issue.key
40914
40924
  }));
@@ -42650,7 +42660,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
42650
42660
 
42651
42661
  // package.json
42652
42662
  var name = "@sjawhar/pi-envoy";
42653
- var version2 = "16.35.0";
42663
+ var version2 = "16.36.1";
42654
42664
  var package_default = {
42655
42665
  name,
42656
42666
  version: version2,
@@ -50042,7 +50052,7 @@ ${REPLAYED_BTW_NOTE}`, frame.envelope, "inert");
50042
50052
  const abort = new AbortController;
50043
50053
  askCheckAbort = abort;
50044
50054
  const answered = ask({
50045
- prompt: ASK_SELF_CHECK_PROMPT(open.asks),
50055
+ prompt: ASK_SELF_CHECK_PROMPT(open.asks ?? []),
50046
50056
  signal: abort.signal
50047
50057
  }).then((reply) => reply.replyText, (error) => {
50048
50058
  if (!abort.signal.aborted)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-envoy",
3
- "version": "16.35.0",
3
+ "version": "16.36.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {