@sjawhar/codex-envoy 5.1.0 → 5.1.2

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.
@@ -38219,6 +38219,20 @@ var DispatchEventSchema = object({
38219
38219
  actor: object({ kind: string2(), id: string2().optional() }).passthrough(),
38220
38220
  payload: object({}).passthrough()
38221
38221
  });
38222
+ // ../contracts/src/dispatch-api-graph.ts
38223
+ function graphNodeKey(node) {
38224
+ return node.ref ?? `${node.kind} ${node.id}`;
38225
+ }
38226
+ function issueReferenceSections(answer) {
38227
+ const links = answer.links ?? [];
38228
+ const linkedFrom = answer.linked_from ?? [];
38229
+ const linked = new Set(links.map((row) => graphNodeKey(row.node)));
38230
+ const linking = new Set(linkedFrom.map((row) => graphNodeKey(row.node)));
38231
+ return {
38232
+ references: links.map((row) => ({ row, alsoReferences: linking.has(graphNodeKey(row.node)) })),
38233
+ referencedBy: linkedFrom.filter((row) => !linked.has(graphNodeKey(row.node)))
38234
+ };
38235
+ }
38222
38236
  // ../contracts/src/dispatch-api-inbox.ts
38223
38237
  function inboxThreadRow(row) {
38224
38238
  return row.kind === "agent" ? row : row;
@@ -50709,6 +50723,124 @@ async function otherAdviceLines(render) {
50709
50723
  }
50710
50724
  }
50711
50725
 
50726
+ // ../envoy-client/src/dispatch-commands/render-graph.ts
50727
+ function referenceLines(read) {
50728
+ if (typeof read === "string")
50729
+ return [`- ${read}`];
50730
+ const edges = read.edges ?? [];
50731
+ if (edges.length === 0)
50732
+ return ["- none"];
50733
+ return edges.map(edgeLine);
50734
+ }
50735
+ function isItemKind(kind) {
50736
+ return ITEM_KINDS.some((item) => item === kind);
50737
+ }
50738
+ function edgeLine(edge) {
50739
+ const { node } = edge;
50740
+ const excerpt = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
50741
+ const block = edge.block === undefined ? "" : ` (block ${edge.block.ref ?? edge.block.id})`;
50742
+ const parent = node.parent ?? undefined;
50743
+ const item = node.kind === "block" && node.document === undefined && isItemKind(parent?.kind) ? parent : undefined;
50744
+ const source = item === undefined ? `${node.kind} ${node.ref ?? node.id}` : `${item.kind} ${item.ref ?? item.id} block ${node.block_id ?? node.id}`;
50745
+ return `- ${edge.kind} ${source} (${excerpt}${edge.created_at})${block}`;
50746
+ }
50747
+ function unavailableReason(error) {
50748
+ return dispatchAnswered(error, 404) ? "unavailable" : `unavailable: ${messageFor(error)}`;
50749
+ }
50750
+ async function graphReferences(client, query) {
50751
+ try {
50752
+ return await client.getReferences(query);
50753
+ } catch (error) {
50754
+ return unavailableReason(error);
50755
+ }
50756
+ }
50757
+ async function issueReferencesOrUnavailable(client, key) {
50758
+ try {
50759
+ return await client.getIssueReferences(key);
50760
+ } catch (error) {
50761
+ return unavailableReason(error);
50762
+ }
50763
+ }
50764
+ async function issueCoverageOrReason(client, key) {
50765
+ try {
50766
+ return await client.issueCoverage(key);
50767
+ } catch (error) {
50768
+ return unavailableReason(error);
50769
+ }
50770
+ }
50771
+ async function graphSections(client, ref) {
50772
+ const [incoming, outgoing] = await Promise.all([
50773
+ graphReferences(client, { to: ref }),
50774
+ graphReferences(client, { from: ref })
50775
+ ]);
50776
+ return graphSectionLines(incoming, outgoing);
50777
+ }
50778
+ function graphSectionLines(incoming, outgoing, referencedBy = referenceLines(incoming)) {
50779
+ return [
50780
+ ...typeof incoming === "string" ? [] : nodeLine(incoming.node),
50781
+ "Referenced by:",
50782
+ ...referencedBy,
50783
+ "Links:",
50784
+ ...referenceLines(outgoing)
50785
+ ];
50786
+ }
50787
+ function nodeLine(node) {
50788
+ if (node.made_by === undefined)
50789
+ return [];
50790
+ const fact = (by, time) => `${by == null || by.length === 0 ? "nobody recorded" : by.map(actorText).join(", ")}${time == null ? "" : ` at ${time}`}`;
50791
+ const made = fact(node.made_by, node.made_at);
50792
+ const changed = fact(node.changed_by, node.changed_at);
50793
+ const { parent } = node;
50794
+ const partOf = parent == null ? "" : ` \xB7 part of ${parent.ref ?? `${parent.kind} ${parent.id}`}${node.parent_version == null ? "" : ` (${isItemKind(parent.kind) ? "revision" : "version"} ${node.parent_version})`}`;
50795
+ return [
50796
+ `Node: ${node.kind} ${node.ref ?? node.id} \xB7 made by ${made} \xB7 changed by ${changed}${partOf}`
50797
+ ];
50798
+ }
50799
+ function blockLines(node, ref, typed, noun = "Block") {
50800
+ const unit = ref.item === undefined ? "version" : "revision";
50801
+ const blockID = node.block_id ?? ref.block;
50802
+ const head = ref.item === undefined ? [
50803
+ `Block: ${blockID}`,
50804
+ ...typed === undefined ? [] : [`Type: ${typed.type}`],
50805
+ `Document: ${node.document ?? ref.document}`,
50806
+ ...(typed?.attributes ?? []).map((attribute) => `${attribute.name}: ${attribute.value === "" ? "(empty)" : attribute.value}`),
50807
+ ...node.changed_version === undefined ? [] : [`Changed in version: ${node.changed_version}`],
50808
+ ...node.text === undefined ? [] : ["Text:", node.text]
50809
+ ] : [
50810
+ `${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}:`,
50811
+ ...node.text === undefined ? [] : [node.text]
50812
+ ];
50813
+ const { pin } = node;
50814
+ if (pin === undefined)
50815
+ return head;
50816
+ const state = pin.state === "unchanged" ? `Unchanged since ${unit} ${pin.version}.` : pin.state === "changed" ? `Changed since ${unit} ${pin.version}; last changed in ${unit} ${node.changed_version}.` : `Removed in ${unit} ${pin.removed_version}.`;
50817
+ return [
50818
+ ...head,
50819
+ `Pinned to ${unit}: ${pin.version}`,
50820
+ state,
50821
+ `Text at ${unit} ${pin.version}:`,
50822
+ pin.text
50823
+ ];
50824
+ }
50825
+ async function typedBlockOf(client, ref) {
50826
+ if (ref.item !== undefined || ref.block === undefined)
50827
+ return;
50828
+ try {
50829
+ const blocks = ref.owner.kind === "project" ? await client.projectArtifactBlocks(ref.owner.project, ref.id) : await client.issueArtifactBlocks(ref.owner.issue, ref.id);
50830
+ return blocks.find((block) => block.id === ref.block);
50831
+ } catch {
50832
+ return;
50833
+ }
50834
+ }
50835
+ function askPartNoun(ask, node, blockID) {
50836
+ if (ask.answer?.id === blockID)
50837
+ return "Answer";
50838
+ if ((ask.options ?? []).some((option) => option.id === blockID))
50839
+ return "Option";
50840
+ const placed = (ask.revision ?? 0) > 0 && (ask.options ?? []).every((option) => option.id !== undefined) && (ask.answer === null || ask.answer.id !== undefined);
50841
+ return placed && node.pin?.state !== "removed" ? "Question" : "Part";
50842
+ }
50843
+
50712
50844
  // ../envoy-client/src/dispatch-commands/render-issue.ts
50713
50845
  function componentsLine(components) {
50714
50846
  const ids = components.ids ?? [];
@@ -50836,11 +50968,44 @@ function olderServerWarnings(issue) {
50836
50968
  ];
50837
50969
  return warnings.length === 0 ? {} : { warnings };
50838
50970
  }
50839
- function issueSummary(issue, events, references, graph, linkBase, coverage, agents) {
50971
+ var STRUCTURAL_EDGES_IN = ["child_of", "blocked_by"];
50972
+ function referenceLinkLine({ kinds, node, via }, near) {
50973
+ return `- ${(kinds ?? []).join(",")} ${node.kind} ${node.ref ?? node.id} \xB7 ${near} ${via.kind} ${via.id}`;
50974
+ }
50975
+ function memberLines(references) {
50976
+ const members = references.members ?? [];
50977
+ return [
50978
+ ...members.length === 0 ? ["- none"] : members.map(({ artifact, depth, via }) => `- ${artifact.project}/${artifact.slug} \xB7 depth ${depth} via ${via.kind} ${via.id}`),
50979
+ ...references.truncated ? ["- more references beyond 8 hops"] : []
50980
+ ];
50981
+ }
50982
+ function referenceSections(references, incoming, outgoing) {
50983
+ if (typeof references === "string")
50984
+ return { references: [`- ${references}`] };
50985
+ if (references.links === undefined)
50986
+ return { references: memberLines(references) };
50987
+ const sections = issueReferenceSections(references);
50988
+ const structural = typeof incoming === "string" ? [] : (incoming.edges ?? []).filter((edge) => STRUCTURAL_EDGES_IN.includes(edge.kind));
50989
+ const outgoingEdges = typeof outgoing === "string" ? [] : outgoing.edges ?? [];
50990
+ const elsewhere = new Set([...outgoingEdges, ...structural].map((edge) => graphNodeKey(edge.node)));
50991
+ const referencesLines = sections.references.filter(({ row }) => !elsewhere.has(graphNodeKey(row.node))).map(({ alsoReferences, row }) => {
50992
+ const also = alsoReferences ? " \xB7 also references this issue" : "";
50993
+ return `${referenceLinkLine(row, "via")}${also}`;
50994
+ });
50995
+ const referencedBy = [
50996
+ ...sections.referencedBy.map((row) => referenceLinkLine(row, "to")),
50997
+ ...typeof incoming === "string" ? [`- ${incoming}`] : structural.map(edgeLine)
50998
+ ];
50999
+ return {
51000
+ references: referencesLines.length === 0 ? ["- none"] : referencesLines,
51001
+ referencedBy: referencedBy.length === 0 ? ["- none"] : referencedBy
51002
+ };
51003
+ }
51004
+ function issueSummary(issue, events, references, pictures, graph, linkBase, coverage, agents) {
50840
51005
  const asks = issue.open_asks ?? [];
50841
51006
  const labels = issue.labels ?? [];
50842
51007
  const links = issue.external_links ?? [];
50843
- const members = typeof references === "string" ? [] : references.members ?? [];
51008
+ const sections = referenceSections(references, graph.incoming, graph.outgoing);
50844
51009
  const spec = issue.artifacts?.find((artifact) => artifact.primary);
50845
51010
  const specApproval = spec === undefined ? undefined : approvalLine(spec, typeof issue.closed_at === "string");
50846
51011
  if (issue.priority === undefined)
@@ -50877,11 +51042,11 @@ function issueSummary(issue, events, references, graph, linkBase, coverage, agen
50877
51042
  "Open asks:",
50878
51043
  ...asks.length === 0 ? ["- none"] : asks.map((ask) => `- ${ask.id}: ${ask.question}`),
50879
51044
  "References:",
50880
- ...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}`),
50881
- ...typeof references === "string" || !references.truncated ? [] : ["- more references beyond 8 hops"],
51045
+ ...sections.references,
50882
51046
  "Events:",
50883
51047
  ...events.length === 0 ? ["- none"] : events.map(eventLine),
50884
- ...graph
51048
+ ...pictures,
51049
+ ...graphSectionLines(graph.incoming, graph.outgoing, sections.referencedBy)
50885
51050
  ].join(`
50886
51051
  `);
50887
51052
  }
@@ -51732,124 +51897,6 @@ async function resultsCommand(context) {
51732
51897
  };
51733
51898
  }
51734
51899
 
51735
- // ../envoy-client/src/dispatch-commands/render-graph.ts
51736
- function referenceLines(read) {
51737
- if (typeof read === "string")
51738
- return [`- ${read}`];
51739
- const edges = read.edges ?? [];
51740
- if (edges.length === 0)
51741
- return ["- none"];
51742
- return edges.map(edgeLine);
51743
- }
51744
- function isItemKind(kind) {
51745
- return ITEM_KINDS.some((item) => item === kind);
51746
- }
51747
- function edgeLine(edge) {
51748
- const { node } = edge;
51749
- const excerpt = edge.excerpt === undefined ? "" : `${textHead(edge.excerpt.text)} \xB7 `;
51750
- const block = edge.block === undefined ? "" : ` (block ${edge.block.ref ?? edge.block.id})`;
51751
- const parent = node.parent ?? undefined;
51752
- const item = node.kind === "block" && node.document === undefined && isItemKind(parent?.kind) ? parent : undefined;
51753
- const source = item === undefined ? `${node.kind} ${node.ref ?? node.id}` : `${item.kind} ${item.ref ?? item.id} block ${node.block_id ?? node.id}`;
51754
- return `- ${edge.kind} ${source} (${excerpt}${edge.created_at})${block}`;
51755
- }
51756
- function unavailableReason(error) {
51757
- return dispatchAnswered(error, 404) ? "unavailable" : `unavailable: ${messageFor(error)}`;
51758
- }
51759
- async function graphReferences(client, query) {
51760
- try {
51761
- return await client.getReferences(query);
51762
- } catch (error) {
51763
- return unavailableReason(error);
51764
- }
51765
- }
51766
- async function issueReferencesOrUnavailable(client, key) {
51767
- try {
51768
- return await client.getIssueReferences(key);
51769
- } catch (error) {
51770
- return unavailableReason(error);
51771
- }
51772
- }
51773
- async function issueCoverageOrReason(client, key) {
51774
- try {
51775
- return await client.issueCoverage(key);
51776
- } catch (error) {
51777
- return unavailableReason(error);
51778
- }
51779
- }
51780
- async function graphSections(client, ref) {
51781
- const [incoming, outgoing] = await Promise.all([
51782
- graphReferences(client, { to: ref }),
51783
- graphReferences(client, { from: ref })
51784
- ]);
51785
- return graphSectionLines(incoming, outgoing);
51786
- }
51787
- function graphSectionLines(incoming, outgoing) {
51788
- return [
51789
- ...typeof incoming === "string" ? [] : nodeLine(incoming.node),
51790
- "Referenced by:",
51791
- ...referenceLines(incoming),
51792
- "Links:",
51793
- ...referenceLines(outgoing)
51794
- ];
51795
- }
51796
- function nodeLine(node) {
51797
- if (node.made_by === undefined)
51798
- return [];
51799
- const fact = (by, time) => `${by == null || by.length === 0 ? "nobody recorded" : by.map(actorText).join(", ")}${time == null ? "" : ` at ${time}`}`;
51800
- const made = fact(node.made_by, node.made_at);
51801
- const changed = fact(node.changed_by, node.changed_at);
51802
- const { parent } = node;
51803
- const partOf = parent == null ? "" : ` \xB7 part of ${parent.ref ?? `${parent.kind} ${parent.id}`}${node.parent_version == null ? "" : ` (${isItemKind(parent.kind) ? "revision" : "version"} ${node.parent_version})`}`;
51804
- return [
51805
- `Node: ${node.kind} ${node.ref ?? node.id} \xB7 made by ${made} \xB7 changed by ${changed}${partOf}`
51806
- ];
51807
- }
51808
- function blockLines(node, ref, typed, noun = "Block") {
51809
- const unit = ref.item === undefined ? "version" : "revision";
51810
- const blockID = node.block_id ?? ref.block;
51811
- const head = ref.item === undefined ? [
51812
- `Block: ${blockID}`,
51813
- ...typed === undefined ? [] : [`Type: ${typed.type}`],
51814
- `Document: ${node.document ?? ref.document}`,
51815
- ...(typed?.attributes ?? []).map((attribute) => `${attribute.name}: ${attribute.value === "" ? "(empty)" : attribute.value}`),
51816
- ...node.changed_version === undefined ? [] : [`Changed in version: ${node.changed_version}`],
51817
- ...node.text === undefined ? [] : ["Text:", node.text]
51818
- ] : [
51819
- `${noun} ${blockID} of ${ref.item.kind} ${ref.item.id}${node.changed_version === undefined ? "" : ` (changed in revision ${node.changed_version})`}:`,
51820
- ...node.text === undefined ? [] : [node.text]
51821
- ];
51822
- const { pin } = node;
51823
- if (pin === undefined)
51824
- return head;
51825
- const state = pin.state === "unchanged" ? `Unchanged since ${unit} ${pin.version}.` : pin.state === "changed" ? `Changed since ${unit} ${pin.version}; last changed in ${unit} ${node.changed_version}.` : `Removed in ${unit} ${pin.removed_version}.`;
51826
- return [
51827
- ...head,
51828
- `Pinned to ${unit}: ${pin.version}`,
51829
- state,
51830
- `Text at ${unit} ${pin.version}:`,
51831
- pin.text
51832
- ];
51833
- }
51834
- async function typedBlockOf(client, ref) {
51835
- if (ref.item !== undefined || ref.block === undefined)
51836
- return;
51837
- try {
51838
- const blocks = ref.owner.kind === "project" ? await client.projectArtifactBlocks(ref.owner.project, ref.id) : await client.issueArtifactBlocks(ref.owner.issue, ref.id);
51839
- return blocks.find((block) => block.id === ref.block);
51840
- } catch {
51841
- return;
51842
- }
51843
- }
51844
- function askPartNoun(ask, node, blockID) {
51845
- if (ask.answer?.id === blockID)
51846
- return "Answer";
51847
- if ((ask.options ?? []).some((option) => option.id === blockID))
51848
- return "Option";
51849
- const placed = (ask.revision ?? 0) > 0 && (ask.options ?? []).every((option) => option.id !== undefined) && (ask.answer === null || ask.answer.id !== undefined);
51850
- return placed && node.pin?.state !== "removed" ? "Question" : "Part";
51851
- }
51852
-
51853
51900
  // ../envoy-client/src/dispatch-commands/render-item.ts
51854
51901
  function askSummary({ ask, replies, answers }, askRef, pictures, incoming, outgoing) {
51855
51902
  const answer = ask.answer;
@@ -53518,9 +53565,11 @@ async function readCommand(context) {
53518
53565
  const readPromise = client.read(issueKey, readEvents);
53519
53566
  const referencesPromise = issueReferencesOrUnavailable(client, issueKey);
53520
53567
  const read = await readPromise;
53521
- const [references, graph, agents, pictures, coverage] = await Promise.all([
53568
+ const issueRef = dispatchIssueRef(read.issue.key);
53569
+ const [references, incoming, outgoing, agents, pictures, coverage] = await Promise.all([
53522
53570
  referencesPromise,
53523
- graphSections(client, dispatchIssueRef(read.issue.key)),
53571
+ graphReferences(client, { to: issueRef }),
53572
+ graphReferences(client, { from: issueRef }),
53524
53573
  liveAgents(client, holdsSession(read.issue.claim) || routeHeldBySession(read.issue)),
53525
53574
  picturesOf([
53526
53575
  ...(read.issue.open_asks ?? []).map((ask) => ({ text: ask.question, at: ask.created_at })),
@@ -53529,7 +53578,7 @@ async function readCommand(context) {
53529
53578
  issueCoverageOrReason(client, read.issue.key)
53530
53579
  ]);
53531
53580
  return {
53532
- text: issueSummary(read.issue, read.events, references, [...pictures.lines, ...graph], linkBase, coverage, agents),
53581
+ text: issueSummary(read.issue, read.events, references, pictures.lines, { incoming, outgoing }, linkBase, coverage, agents),
53533
53582
  details: { issue: read.issue.key },
53534
53583
  ...showImages(pictures),
53535
53584
  ...olderServerWarnings(read.issue)
@@ -60432,7 +60481,7 @@ var import_nats5 = __toESM(require_mod4(), 1);
60432
60481
 
60433
60482
  // package.json
60434
60483
  var name2 = "@sjawhar/claude-envoy";
60435
- var version2 = "5.1.0";
60484
+ var version2 = "5.1.2";
60436
60485
  var legion = {
60437
60486
  daemonApiVersion: 205
60438
60487
  };