@sjawhar/pi-legion-envoy 6.0.0 → 6.0.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.
package/dist/envoy.js CHANGED
@@ -30360,13 +30360,13 @@ var dispatchToolSpecs = [
30360
30360
  },
30361
30361
  {
30362
30362
  name: "dispatch_request_approval",
30363
- example: { issue: "DSP-1", summary: "Proposes a live sync in place of the nightly export." },
30364
- description: "Ask a human to approve a document at its current version. Opens an approval ask (Approve / " + "Request changes) in the human's Inbox whose question names the document and version, " + "followed by the summary; the answer pins a review to that version and arrives as " + "artifact.approved or artifact.changes_requested. A later version makes an approval stale, " + "and writing it retracts an open request for an older version; request again for the new " + "one. A repeat at the version an open request names returns that request unchanged. " + "Refused, with nothing sent, while the document holds an open decision block, even when a " + "human asked for approval: the refusal names each block; ask the human to answer or waive " + "it first. " + OWNER_REFERENCE,
30363
+ example: { issue: "DSP-1", summary: "A live sync replaces the nightly export." },
30364
+ description: "Ask a human to approve a document at its current version. Opens an approval ask (Approve / " + "Request changes) in the human's Inbox whose question names the document and version, " + "followed by the summary; the answer pins a review to that version and arrives as " + "artifact.approved or artifact.changes_requested. A later version carries the same open " + "request forward and leaves it waiting on you; once the revision is complete and the human " + "has agreed to every point in it, call this again to hand that request back. The request " + "carries nothing new. A call while it already waits on the human hands nothing back: the " + "same summary changes nothing, and a different one is refused, since it would rewrite the " + "card the human is reading. " + "Refused, with nothing sent, while the document holds an open decision block, even when a " + "human asked for approval: the refusal names each block; ask the human to answer or waive " + "it first. " + OWNER_REFERENCE,
30365
30365
  arguments: (z2) => ({
30366
30366
  issue: z2.string().describe(ISSUE_REFERENCE).optional(),
30367
30367
  project: z2.string().describe("Project key owning the document.").optional(),
30368
30368
  artifact: z2.string().describe("Project document artifact id, slug, or filename; primary document by default for an issue.").optional(),
30369
- summary: z2.string({ min: 1 }).describe("The proposals in this version the human hasn't already agreed to, in one to three sentences.")
30369
+ summary: z2.string({ min: 1 }).describe("What the human is approving, in one to three sentences, and nothing else: no commentary on itself or the conversation, and no question. Request approval only once the human has agreed to every point in the document.")
30370
30370
  }),
30371
30371
  validation: documentOwnerValidation(true)
30372
30372
  },
@@ -31819,6 +31819,7 @@ var DISPATCH_PAYLOAD_SCHEMAS = {
31819
31819
  "ask.opened": AskEventPayloadSchema,
31820
31820
  "ask.anchor_refreshed": AskEventPayloadSchema,
31821
31821
  "ask.edited": AskEditedEventPayloadSchema,
31822
+ "ask.handed_back": AskEventPayloadSchema,
31822
31823
  "ask.answered": AskEventPayloadSchema,
31823
31824
  "ask.resolved": AskEventPayloadSchema,
31824
31825
  "comment.created": CommentEventPayloadSchema,
@@ -32701,7 +32702,8 @@ class DispatchClient {
32701
32702
  return this.#json("POST", ["api", "v1", "asks", id, "resolve"], input);
32702
32703
  }
32703
32704
  async requestApproval(artifactID, input) {
32704
- return this.#json("POST", ["api", "v1", "artifacts", artifactID, "approval-requests"], input);
32705
+ const answer = await this.#jsonAnswer("POST", ["api", "v1", "artifacts", artifactID, "approval-requests"], input);
32706
+ return { ...answer.payload, recorded: answer.status === 201 };
32705
32707
  }
32706
32708
  async editAsk(id, input) {
32707
32709
  return this.#json("PATCH", ["api", "v1", "asks", id], input);
@@ -32846,6 +32848,9 @@ class DispatchClient {
32846
32848
  }
32847
32849
  }
32848
32850
  async#json(method, path2, body, query) {
32851
+ return (await this.#jsonAnswer(method, path2, body, query)).payload;
32852
+ }
32853
+ async#jsonAnswer(method, path2, body, query) {
32849
32854
  const headers = {
32850
32855
  Accept: "application/json",
32851
32856
  Authorization: `Bearer ${this.token}`
@@ -32859,7 +32864,7 @@ class DispatchClient {
32859
32864
  signal: this.#signal,
32860
32865
  ...body === undefined ? {} : { body: JSON.stringify(body) }
32861
32866
  });
32862
- return this.#response(method, url2, response);
32867
+ return { status: response.status, payload: await this.#response(method, url2, response) };
32863
32868
  }
32864
32869
  async#form(method, path2, body) {
32865
32870
  const url2 = this.#url(path2);
@@ -33704,8 +33709,10 @@ function approvalLine(artifact) {
33704
33709
  if (approval === undefined || approval.state === "draft")
33705
33710
  return;
33706
33711
  switch (approval.state) {
33707
- case "awaiting":
33708
- return `Approval: awaiting (requested by ${approval.requested_by?.id ?? "unknown"}, ask ${approval.ask_id ?? "?"})`;
33712
+ case "awaiting": {
33713
+ const turn = approval.waiting_on === undefined ? "" : `, waiting on ${approval.waiting_on}`;
33714
+ return `Approval: awaiting${turn} (requested by ${approval.requested_by?.id ?? "unknown"}, ask ${approval.ask_id ?? "?"})`;
33715
+ }
33709
33716
  case "approved":
33710
33717
  return `Approval: approved v${approval.version} by ${approval.by?.id ?? "unknown"}`;
33711
33718
  case "stale":
@@ -33845,6 +33852,7 @@ function eventHead(event) {
33845
33852
  case "ask.opened":
33846
33853
  case "ask.anchor_refreshed":
33847
33854
  case "ask.edited":
33855
+ case "ask.handed_back":
33848
33856
  case "ask.resolved":
33849
33857
  return textHead(event.payload.question);
33850
33858
  case "ask.answered":
@@ -34592,7 +34600,7 @@ ${followsAsk(askOwner)}`,
34592
34600
  replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
34593
34601
  });
34594
34602
  if (replyToAsk !== undefined) {
34595
- const askState = comment.turn === null ? "" : `; ask now waiting on ${comment.turn}`;
34603
+ const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
34596
34604
  return {
34597
34605
  text: [
34598
34606
  `Replied on ask ${replyToAsk} (comment ${comment.id}${askState}). ${followsAsk(commentOwner2)}`,
@@ -34603,7 +34611,7 @@ ${followsAsk(askOwner)}`,
34603
34611
  ...commentDetails,
34604
34612
  ask: replyToAsk,
34605
34613
  follows: { ask: replyToAsk },
34606
- ...comment.turn === null ? {} : { ask_waiting_on: comment.turn },
34614
+ ...comment.ask_waiting_on === undefined ? {} : { ask_waiting_on: comment.ask_waiting_on },
34607
34615
  ...comment.advice === undefined ? {} : { advice: comment.advice }
34608
34616
  }
34609
34617
  };
@@ -34707,7 +34715,7 @@ ${followsAsk(askOwner)}`,
34707
34715
  const unchangedOps = edited.unchanged_ops ?? [];
34708
34716
  const unchangedText = unchangedOps.length === 0 ? "" : `; ${unchangedOps.length === 1 ? "operation" : "operations"} ${unchangedOps.join(", ")} changed nothing`;
34709
34717
  const lostOps = edited.lost_ops;
34710
- const lostText = lostOps === undefined || lostOps !== null && lostOps.length === 0 ? "" : lostOps === null ? "; could not confirm this edit survived, because the live document is being reloaded \u2014 re-read it" : `; ${versionText} carries text the live document no longer has: a concurrent change removed what ${lostOps.length === 1 ? "operation" : "operations"} ${lostOps.join(", ")} wrote \u2014 re-read the document`;
34718
+ const lostText = lostOps === undefined || lostOps !== null && lostOps.length === 0 ? "" : lostOps === null ? "; could not confirm this edit survived, because the live document is being reloaded or holds a tree too deep to read \u2014 re-read it" : `; ${versionText} carries text the live document no longer has: a concurrent change removed what ${lostOps.length === 1 ? "operation" : "operations"} ${lostOps.join(", ")} wrote \u2014 re-read the document`;
34711
34719
  const applied = `${head}${unchangedText}${lostText}`;
34712
34720
  const adviceLines = renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {});
34713
34721
  const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
@@ -34776,8 +34784,9 @@ ${trailer.join(`
34776
34784
  };
34777
34785
  }
34778
34786
  const details = await followedAskDetails(client, result.ask, resolved.artifact);
34787
+ const outcome = result.recorded ? `Approval requested for ${resolved.artifact.name} (document id ${resolved.artifact.id}) at version ${result.version} (ask ${result.ask.id}).` : `The approval request for ${resolved.artifact.name} (document id ${resolved.artifact.id}) at version ${result.version} (ask ${result.ask.id}) already waits on the human, so this call changed nothing: nothing since it last reached the human (a newer version, a human's reply in its thread, or your progress note) left it waiting on you.`;
34779
34788
  return {
34780
- text: `Approval requested for ${resolved.artifact.name} (document id ${resolved.artifact.id}) at version ${result.version} (ask ${result.ask.id}). The human's Inbox asks: ${JSON.stringify(result.ask.question)}. The answer arrives as artifact.approved or artifact.changes_requested; an edit after approval makes it stale, so request again for the new version.`,
34789
+ text: `${outcome} The human's Inbox asks: ${JSON.stringify(result.ask.question)}. The answer arrives as artifact.approved or artifact.changes_requested; an edit after approval makes it stale, so request again for the new version.`,
34781
34790
  details: { ...details, artifact: resolved.artifact.id, version: result.version }
34782
34791
  };
34783
34792
  }
package/dist/legion.js CHANGED
@@ -14447,13 +14447,13 @@ var dispatchToolSpecs = [
14447
14447
  },
14448
14448
  {
14449
14449
  name: "dispatch_request_approval",
14450
- example: { issue: "DSP-1", summary: "Proposes a live sync in place of the nightly export." },
14451
- description: "Ask a human to approve a document at its current version. Opens an approval ask (Approve / " + "Request changes) in the human's Inbox whose question names the document and version, " + "followed by the summary; the answer pins a review to that version and arrives as " + "artifact.approved or artifact.changes_requested. A later version makes an approval stale, " + "and writing it retracts an open request for an older version; request again for the new " + "one. A repeat at the version an open request names returns that request unchanged. " + "Refused, with nothing sent, while the document holds an open decision block, even when a " + "human asked for approval: the refusal names each block; ask the human to answer or waive " + "it first. " + OWNER_REFERENCE,
14450
+ example: { issue: "DSP-1", summary: "A live sync replaces the nightly export." },
14451
+ description: "Ask a human to approve a document at its current version. Opens an approval ask (Approve / " + "Request changes) in the human's Inbox whose question names the document and version, " + "followed by the summary; the answer pins a review to that version and arrives as " + "artifact.approved or artifact.changes_requested. A later version carries the same open " + "request forward and leaves it waiting on you; once the revision is complete and the human " + "has agreed to every point in it, call this again to hand that request back. The request " + "carries nothing new. A call while it already waits on the human hands nothing back: the " + "same summary changes nothing, and a different one is refused, since it would rewrite the " + "card the human is reading. " + "Refused, with nothing sent, while the document holds an open decision block, even when a " + "human asked for approval: the refusal names each block; ask the human to answer or waive " + "it first. " + OWNER_REFERENCE,
14452
14452
  arguments: (z2) => ({
14453
14453
  issue: z2.string().describe(ISSUE_REFERENCE).optional(),
14454
14454
  project: z2.string().describe("Project key owning the document.").optional(),
14455
14455
  artifact: z2.string().describe("Project document artifact id, slug, or filename; primary document by default for an issue.").optional(),
14456
- summary: z2.string({ min: 1 }).describe("The proposals in this version the human hasn't already agreed to, in one to three sentences.")
14456
+ summary: z2.string({ min: 1 }).describe("What the human is approving, in one to three sentences, and nothing else: no commentary on itself or the conversation, and no question. Request approval only once the human has agreed to every point in the document.")
14457
14457
  }),
14458
14458
  validation: documentOwnerValidation(true)
14459
14459
  },
@@ -15464,7 +15464,8 @@ class DispatchClient {
15464
15464
  return this.#json("POST", ["api", "v1", "asks", id, "resolve"], input);
15465
15465
  }
15466
15466
  async requestApproval(artifactID, input) {
15467
- return this.#json("POST", ["api", "v1", "artifacts", artifactID, "approval-requests"], input);
15467
+ const answer = await this.#jsonAnswer("POST", ["api", "v1", "artifacts", artifactID, "approval-requests"], input);
15468
+ return { ...answer.payload, recorded: answer.status === 201 };
15468
15469
  }
15469
15470
  async editAsk(id, input) {
15470
15471
  return this.#json("PATCH", ["api", "v1", "asks", id], input);
@@ -15609,6 +15610,9 @@ class DispatchClient {
15609
15610
  }
15610
15611
  }
15611
15612
  async#json(method, path2, body, query) {
15613
+ return (await this.#jsonAnswer(method, path2, body, query)).payload;
15614
+ }
15615
+ async#jsonAnswer(method, path2, body, query) {
15612
15616
  const headers = {
15613
15617
  Accept: "application/json",
15614
15618
  Authorization: `Bearer ${this.token}`
@@ -15622,7 +15626,7 @@ class DispatchClient {
15622
15626
  signal: this.#signal,
15623
15627
  ...body === undefined ? {} : { body: JSON.stringify(body) }
15624
15628
  });
15625
- return this.#response(method, url2, response);
15629
+ return { status: response.status, payload: await this.#response(method, url2, response) };
15626
15630
  }
15627
15631
  async#form(method, path2, body) {
15628
15632
  const url2 = this.#url(path2);
@@ -16490,8 +16494,10 @@ function approvalLine(artifact) {
16490
16494
  if (approval === undefined || approval.state === "draft")
16491
16495
  return;
16492
16496
  switch (approval.state) {
16493
- case "awaiting":
16494
- return `Approval: awaiting (requested by ${approval.requested_by?.id ?? "unknown"}, ask ${approval.ask_id ?? "?"})`;
16497
+ case "awaiting": {
16498
+ const turn = approval.waiting_on === undefined ? "" : `, waiting on ${approval.waiting_on}`;
16499
+ return `Approval: awaiting${turn} (requested by ${approval.requested_by?.id ?? "unknown"}, ask ${approval.ask_id ?? "?"})`;
16500
+ }
16495
16501
  case "approved":
16496
16502
  return `Approval: approved v${approval.version} by ${approval.by?.id ?? "unknown"}`;
16497
16503
  case "stale":
@@ -16631,6 +16637,7 @@ function eventHead(event) {
16631
16637
  case "ask.opened":
16632
16638
  case "ask.anchor_refreshed":
16633
16639
  case "ask.edited":
16640
+ case "ask.handed_back":
16634
16641
  case "ask.resolved":
16635
16642
  return textHead(event.payload.question);
16636
16643
  case "ask.answered":
@@ -17378,7 +17385,7 @@ ${followsAsk(askOwner)}`,
17378
17385
  replyToOwnAsk: replyToAsk !== undefined && (comment.advice?.your_open_asks?.some((ask) => ask.id === replyToAsk) ?? false)
17379
17386
  });
17380
17387
  if (replyToAsk !== undefined) {
17381
- const askState = comment.turn === null ? "" : `; ask now waiting on ${comment.turn}`;
17388
+ const askState = comment.ask_waiting_on === undefined ? "" : `; ask now waiting on ${comment.ask_waiting_on}`;
17382
17389
  return {
17383
17390
  text: [
17384
17391
  `Replied on ask ${replyToAsk} (comment ${comment.id}${askState}). ${followsAsk(commentOwner2)}`,
@@ -17389,7 +17396,7 @@ ${followsAsk(askOwner)}`,
17389
17396
  ...commentDetails,
17390
17397
  ask: replyToAsk,
17391
17398
  follows: { ask: replyToAsk },
17392
- ...comment.turn === null ? {} : { ask_waiting_on: comment.turn },
17399
+ ...comment.ask_waiting_on === undefined ? {} : { ask_waiting_on: comment.ask_waiting_on },
17393
17400
  ...comment.advice === undefined ? {} : { advice: comment.advice }
17394
17401
  }
17395
17402
  };
@@ -17493,7 +17500,7 @@ ${followsAsk(askOwner)}`,
17493
17500
  const unchangedOps = edited.unchanged_ops ?? [];
17494
17501
  const unchangedText = unchangedOps.length === 0 ? "" : `; ${unchangedOps.length === 1 ? "operation" : "operations"} ${unchangedOps.join(", ")} changed nothing`;
17495
17502
  const lostOps = edited.lost_ops;
17496
- const lostText = lostOps === undefined || lostOps !== null && lostOps.length === 0 ? "" : lostOps === null ? "; could not confirm this edit survived, because the live document is being reloaded \u2014 re-read it" : `; ${versionText} carries text the live document no longer has: a concurrent change removed what ${lostOps.length === 1 ? "operation" : "operations"} ${lostOps.join(", ")} wrote \u2014 re-read the document`;
17503
+ const lostText = lostOps === undefined || lostOps !== null && lostOps.length === 0 ? "" : lostOps === null ? "; could not confirm this edit survived, because the live document is being reloaded or holds a tree too deep to read \u2014 re-read it" : `; ${versionText} carries text the live document no longer has: a concurrent change removed what ${lostOps.length === 1 ? "operation" : "operations"} ${lostOps.join(", ")} wrote \u2014 re-read the document`;
17497
17504
  const applied = `${head}${unchangedText}${lostText}`;
17498
17505
  const adviceLines = renderAdvice(input.tool, resolvedTopic(resolved).label, edited.advice, {});
17499
17506
  const tokenTrailer = edited.token === undefined ? [] : [`Document token: ${edited.token}`];
@@ -17562,8 +17569,9 @@ ${trailer.join(`
17562
17569
  };
17563
17570
  }
17564
17571
  const details = await followedAskDetails(client, result.ask, resolved.artifact);
17572
+ const outcome = result.recorded ? `Approval requested for ${resolved.artifact.name} (document id ${resolved.artifact.id}) at version ${result.version} (ask ${result.ask.id}).` : `The approval request for ${resolved.artifact.name} (document id ${resolved.artifact.id}) at version ${result.version} (ask ${result.ask.id}) already waits on the human, so this call changed nothing: nothing since it last reached the human (a newer version, a human's reply in its thread, or your progress note) left it waiting on you.`;
17565
17573
  return {
17566
- text: `Approval requested for ${resolved.artifact.name} (document id ${resolved.artifact.id}) at version ${result.version} (ask ${result.ask.id}). The human's Inbox asks: ${JSON.stringify(result.ask.question)}. The answer arrives as artifact.approved or artifact.changes_requested; an edit after approval makes it stale, so request again for the new version.`,
17574
+ text: `${outcome} The human's Inbox asks: ${JSON.stringify(result.ask.question)}. The answer arrives as artifact.approved or artifact.changes_requested; an edit after approval makes it stale, so request again for the new version.`,
17567
17575
  details: { ...details, artifact: resolved.artifact.id, version: result.version }
17568
17576
  };
17569
17577
  }
@@ -17835,7 +17843,7 @@ function endInjectedUserTurns(sessionID) {
17835
17843
  // package.json
17836
17844
  var package_default = {
17837
17845
  name: "@sjawhar/pi-legion-envoy",
17838
- version: "6.0.0",
17846
+ version: "6.0.2",
17839
17847
  type: "module",
17840
17848
  omp: {
17841
17849
  extensions: [
@@ -182,9 +182,10 @@ was written: re-read the document and decide again, as with `PRECONDITION_FAILED
182
182
  `lost_ops` names operations means the version was written and the live document already lacks what
183
183
  those operations wrote, because the deletion landed after the version: re-read before building on
184
184
  it. `lost_ops: []` is the ordinary outcome, and a result that says it could not confirm the edit
185
- survived means the room is reloading — re-read. An operation that only removes text (`delete`,
186
- `delete_row`, `delete_column`, a `replace` that shortens) is never reported lost: a concurrent
187
- deletion cannot undo a removal.
185
+ survived means the room is reloading or holds a tree too deep to read — re-read, and a read that
186
+ answers `DOC_SCHEMA` says which. An operation that only removes text (`delete`, `delete_row`,
187
+ `delete_column`, a `replace` that shortens) is never reported lost: a concurrent deletion cannot
188
+ undo a removal.
188
189
 
189
190
  `retype` turns the paragraph or typed block with `block` into the named typed `type` in place. It keeps the
190
191
  block id, keeps a typed block's body, and uses `attributes` for client-owned typed attributes. Use it when
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion-envoy",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "type": "module",
5
5
  "omp": {
6
6
  "extensions": [