@sjawhar/pi-envoy 15.0.0 → 15.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/dispatch.js CHANGED
@@ -15328,7 +15328,7 @@ var dispatchToolSpecs = [
15328
15328
  name: "dispatch_artifact",
15329
15329
  example: { issue: "DSP-1", name: "design.md", content: `# Design
15330
15330
  ` },
15331
- description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version. Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
15331
+ description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version, and so does uploading a document's slug (plan-md for plan.md). Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
15332
15332
  arguments: (z) => ({
15333
15333
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
15334
15334
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -15957,7 +15957,8 @@ function fieldKinds(spec) {
15957
15957
  nullable,
15958
15958
  required: required.has(field),
15959
15959
  ...description === undefined ? {} : { description },
15960
- ...values === undefined ? {} : { values }
15960
+ ...values === undefined ? {} : { values },
15961
+ shape: inner === undefined ? [] : shapeLines(inner, "")
15961
15962
  });
15962
15963
  }
15963
15964
  return fields;
@@ -15992,6 +15993,58 @@ function kindOf(field, node) {
15992
15993
  return "json";
15993
15994
  }
15994
15995
  }
15996
+ function withoutNull(node) {
15997
+ const members = (node.anyOf ?? [node]).filter((member) => member.type !== "null");
15998
+ return members.length === 1 ? members[0] : undefined;
15999
+ }
16000
+ function typeName(node) {
16001
+ if (node.anyOf !== undefined)
16002
+ return node.anyOf.map(typeName).join(" or ");
16003
+ if (node.enum !== undefined)
16004
+ return node.enum.map(String).join("|");
16005
+ switch (node.type) {
16006
+ case "string":
16007
+ return "text";
16008
+ case "integer":
16009
+ case "number":
16010
+ case "boolean":
16011
+ case "null":
16012
+ return node.type;
16013
+ case "object":
16014
+ return "object";
16015
+ case "array":
16016
+ return node.items === undefined ? "list" : `list of ${pluralTypeName(node.items)}`;
16017
+ default:
16018
+ return "any JSON";
16019
+ }
16020
+ }
16021
+ function pluralTypeName(node) {
16022
+ if (node.type === "object")
16023
+ return "objects";
16024
+ if (node.type === "integer")
16025
+ return "integers";
16026
+ if (node.type === "number")
16027
+ return "numbers";
16028
+ return typeName(node);
16029
+ }
16030
+ function shapeLines(node, indent) {
16031
+ const item = node.type === "array" ? node.items : undefined;
16032
+ const properties = (item ?? node).properties;
16033
+ if (properties === undefined)
16034
+ return [];
16035
+ const required = new Set((item ?? node).required ?? []);
16036
+ return [
16037
+ `${indent}${item === undefined ? "Its keys:" : "Each item's keys:"}`,
16038
+ ...Object.entries(properties).flatMap(([key, child]) => {
16039
+ const about = [required.has(key) ? "required" : undefined, typeName(child)].filter((part) => part !== undefined).join("; ");
16040
+ const inner = withoutNull(child);
16041
+ return [
16042
+ `${indent} ${key} (${about})${child.description === undefined ? "" : `: ${child.description}`}`,
16043
+ ...inner === undefined ? [] : shapeLines(inner, `${indent} `)
16044
+ ];
16045
+ })
16046
+ ];
16047
+ }
15995
16048
  function singular(field) {
15996
16049
  return field.endsWith("s") ? field.slice(0, -1) : field;
15997
16050
  }
@@ -16039,10 +16092,17 @@ function flagTable(tool, fields) {
16039
16092
  field,
16040
16093
  action: "json",
16041
16094
  value: "<json>",
16042
- text: `Every option as a JSON list of {label, description?}, in place of --${singular(name)}.`
16095
+ text: [`Every option as a JSON list, in place of --${singular(name)}.`, ...info.shape].join(`
16096
+ `)
16043
16097
  });
16044
16098
  } else if (kind === "json") {
16045
- add(`--${name}-json`, { field, action: "json", value: "<json>", text: about });
16099
+ add(`--${name}-json`, {
16100
+ field,
16101
+ action: "json",
16102
+ value: "<json>",
16103
+ text: [about, ...info.shape].filter((line) => line !== "").join(`
16104
+ `)
16105
+ });
16046
16106
  add(`--${name}-json-file`, {
16047
16107
  field,
16048
16108
  action: "json-file",
@@ -16320,7 +16380,8 @@ function commandHelp(tool) {
16320
16380
  surface.spec.description,
16321
16381
  "",
16322
16382
  "Flags:",
16323
- ...commandFlagTable(tool).flatMap((row) => row.text === "" ? [` ${row.flag}`] : [` ${row.flag}`, ` ${row.text}`]),
16383
+ ...commandFlagTable(tool).flatMap((row) => row.text === "" ? [` ${row.flag}`] : [` ${row.flag}`, ...row.text.split(`
16384
+ `).map((line) => ` ${line}`)]),
16324
16385
  "",
16325
16386
  `Example: ${commandLine(tool, surface.spec.example)}`,
16326
16387
  ""
@@ -16593,6 +16654,35 @@ var KEYED_LAYER_MEMORY_MS = 5 * 60000;
16593
16654
  var KEYED_LAYER_SEEN = new Map;
16594
16655
  var KEYED_LAYER_PROBES = new Map;
16595
16656
  var KEY_LAYER_PROBE_MS = 5000;
16657
+ function keyedLayerMemory() {
16658
+ const wall = Date.now();
16659
+ const now = performance.now();
16660
+ const kept = {};
16661
+ for (const [origin, seen] of KEYED_LAYER_SEEN) {
16662
+ const age = now - seen;
16663
+ if (age >= 0 && age < KEYED_LAYER_MEMORY_MS) {
16664
+ kept[origin] = new Date(wall - age).toISOString();
16665
+ }
16666
+ }
16667
+ return kept;
16668
+ }
16669
+ function rememberKeyedLayer(saved) {
16670
+ if (typeof saved !== "object" || saved === null)
16671
+ return;
16672
+ const wall = Date.now();
16673
+ const now = performance.now();
16674
+ for (const [origin, at] of Object.entries(saved)) {
16675
+ if (typeof at !== "string")
16676
+ continue;
16677
+ const age = wall - Date.parse(at);
16678
+ if (!(age >= 0 && age < KEYED_LAYER_MEMORY_MS))
16679
+ continue;
16680
+ const seen = now - age;
16681
+ const known = KEYED_LAYER_SEEN.get(origin);
16682
+ if (known === undefined || known < seen)
16683
+ KEYED_LAYER_SEEN.set(origin, seen);
16684
+ }
16685
+ }
16596
16686
  function keyEchoed(response, key) {
16597
16687
  const echoed = response.headers.get(IDEMPOTENCY_KEY_HEADER)?.trim() ?? "";
16598
16688
  return echoed.replace(/^"(.*)"$/, "$1") === key;
@@ -21094,13 +21184,15 @@ function loadSessionMemory(dir, sessionId) {
21094
21184
  const pictures = shownPictures(sessionId);
21095
21185
  for (const address of stringList(state.pictures))
21096
21186
  pictures.add(address);
21187
+ rememberKeyedLayer(state.keyedLayer);
21097
21188
  return new Set(stringList(state.follows));
21098
21189
  }
21099
21190
  function writeMemory(dir, sessionId, follows) {
21100
21191
  const state = {
21101
21192
  advice: [...adviceMemory()],
21102
21193
  pictures: [...shownPictures(sessionId)],
21103
- follows: [...follows]
21194
+ follows: [...follows],
21195
+ keyedLayer: keyedLayerMemory()
21104
21196
  };
21105
21197
  writeAtomically(join3(dir, "state.json"), `${JSON.stringify(state)}
21106
21198
  `);
package/dist/envoy.js CHANGED
@@ -30448,7 +30448,7 @@ var dispatchToolSpecs = [
30448
30448
  name: "dispatch_artifact",
30449
30449
  example: { issue: "DSP-1", name: "design.md", content: `# Design
30450
30450
  ` },
30451
- description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version. Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
30451
+ description: "Attach a local file or inline text as an issue artifact or project document. Do not use it to edit a live document; use " + "dispatch doc-edit instead. Never upload a document's own name to change it (spec.md replaces the spec whole); edit it with dispatch doc-edit. Uploading the same name again makes its next version, and so does uploading a document's slug (plan-md for plan.md). Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + "Markdown is also refused with 413 CAP_EXCEEDED when it makes more than 65,536 elements (a block weighs 3, and an empty list item, quote, footnote definition or typed block 3 more for the empty paragraph it holds; a table cell 4, a hard line break 3, an image 3, a piece of inline HTML 2, an autolink 2, a footnote reference 2; inline syntax, marks, lines of text and backslash escapes or character references 1 each), or when a new version would leave the document's stored markdown (what its text reads back as) longer than 1 MiB or making more than 65,536 elements, and longer or heavier than before; shorten it or split it across documents. " + "In a table row, write every | in a cell as \\|, in code too: a | after two backslashes ends the cell, and a row with more cells than its table is refused. " + "Markdown holding an ask block whose body breaks its content rule (one or more question paragraphs, then at most one bullet list of options, last) is refused with 400 INVALID_ASK_BLOCK; a new version of a document is held to it only for the asks it writes or changes. " + `${OWNER_REFERENCE}`,
30452
30452
  arguments: (z) => ({
30453
30453
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
30454
30454
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -31747,7 +31747,8 @@ function fieldKinds(spec) {
31747
31747
  nullable,
31748
31748
  required: required.has(field),
31749
31749
  ...description === undefined ? {} : { description },
31750
- ...values === undefined ? {} : { values }
31750
+ ...values === undefined ? {} : { values },
31751
+ shape: inner === undefined ? [] : shapeLines(inner, "")
31751
31752
  });
31752
31753
  }
31753
31754
  return fields;
@@ -31782,6 +31783,58 @@ function kindOf(field, node) {
31782
31783
  return "json";
31783
31784
  }
31784
31785
  }
31786
+ function withoutNull(node) {
31787
+ const members = (node.anyOf ?? [node]).filter((member) => member.type !== "null");
31788
+ return members.length === 1 ? members[0] : undefined;
31789
+ }
31790
+ function typeName(node) {
31791
+ if (node.anyOf !== undefined)
31792
+ return node.anyOf.map(typeName).join(" or ");
31793
+ if (node.enum !== undefined)
31794
+ return node.enum.map(String).join("|");
31795
+ switch (node.type) {
31796
+ case "string":
31797
+ return "text";
31798
+ case "integer":
31799
+ case "number":
31800
+ case "boolean":
31801
+ case "null":
31802
+ return node.type;
31803
+ case "object":
31804
+ return "object";
31805
+ case "array":
31806
+ return node.items === undefined ? "list" : `list of ${pluralTypeName(node.items)}`;
31807
+ default:
31808
+ return "any JSON";
31809
+ }
31810
+ }
31811
+ function pluralTypeName(node) {
31812
+ if (node.type === "object")
31813
+ return "objects";
31814
+ if (node.type === "integer")
31815
+ return "integers";
31816
+ if (node.type === "number")
31817
+ return "numbers";
31818
+ return typeName(node);
31819
+ }
31820
+ function shapeLines(node, indent) {
31821
+ const item = node.type === "array" ? node.items : undefined;
31822
+ const properties = (item ?? node).properties;
31823
+ if (properties === undefined)
31824
+ return [];
31825
+ const required = new Set((item ?? node).required ?? []);
31826
+ return [
31827
+ `${indent}${item === undefined ? "Its keys:" : "Each item's keys:"}`,
31828
+ ...Object.entries(properties).flatMap(([key, child]) => {
31829
+ const about = [required.has(key) ? "required" : undefined, typeName(child)].filter((part) => part !== undefined).join("; ");
31830
+ const inner = withoutNull(child);
31831
+ return [
31832
+ `${indent} ${key} (${about})${child.description === undefined ? "" : `: ${child.description}`}`,
31833
+ ...inner === undefined ? [] : shapeLines(inner, `${indent} `)
31834
+ ];
31835
+ })
31836
+ ];
31837
+ }
31785
31838
  function singular(field) {
31786
31839
  return field.endsWith("s") ? field.slice(0, -1) : field;
31787
31840
  }
@@ -31829,10 +31882,17 @@ function flagTable(tool, fields) {
31829
31882
  field,
31830
31883
  action: "json",
31831
31884
  value: "<json>",
31832
- text: `Every option as a JSON list of {label, description?}, in place of --${singular(name)}.`
31885
+ text: [`Every option as a JSON list, in place of --${singular(name)}.`, ...info.shape].join(`
31886
+ `)
31833
31887
  });
31834
31888
  } else if (kind === "json") {
31835
- add(`--${name}-json`, { field, action: "json", value: "<json>", text: about });
31889
+ add(`--${name}-json`, {
31890
+ field,
31891
+ action: "json",
31892
+ value: "<json>",
31893
+ text: [about, ...info.shape].filter((line) => line !== "").join(`
31894
+ `)
31895
+ });
31836
31896
  add(`--${name}-json-file`, {
31837
31897
  field,
31838
31898
  action: "json-file",
@@ -37062,6 +37122,7 @@ async function readDocumentBlocks(client, target, context) {
37062
37122
  const decoder = new TextDecoder;
37063
37123
  return {
37064
37124
  name: resolved.artifact.name,
37125
+ slug: resolved.artifact.slug,
37065
37126
  blocks: live.blocks.map((block) => ({
37066
37127
  id: block.id,
37067
37128
  text: decoder.decode(live.bytes.subarray(block.from, block.to))
@@ -37992,7 +38053,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
37992
38053
 
37993
38054
  // package.json
37994
38055
  var name = "@sjawhar/pi-envoy";
37995
- var version2 = "15.0.0";
38056
+ var version2 = "15.0.2";
37996
38057
  var package_default = {
37997
38058
  name,
37998
38059
  version: version2,
@@ -41045,7 +41106,7 @@ async function readAsks(deps, call, first) {
41045
41106
  return { asks, textMissing, asksPartial: false };
41046
41107
  }
41047
41108
  const name = uploadName(call.input);
41048
- const currentIds = read !== "not-found" && read.name === name ? new Set(read.blocks.map((block) => block.id)) : undefined;
41109
+ const currentIds = read !== "not-found" && (read.name === name || read.slug === name) ? new Set(read.blocks.map((block) => block.id)) : undefined;
41049
41110
  return {
41050
41111
  asks: first.filter((ask) => ask.id === undefined || currentIds?.has(ask.id) !== true),
41051
41112
  textMissing: false,
@@ -41245,6 +41306,40 @@ var OPERATORS = ["&&", "||", ";;", "|&", ";", "&", "|", "(", ")"];
41245
41306
  var REDIRECT = /^(\d*)(&>>|&>|<<<|<<-|<<|<>|<&|>&|>>|>\||<|>)/;
41246
41307
  var QUOTED_DELIMITER = /^(?:'[A-Za-z_][A-Za-z0-9_]*'|"[A-Za-z_][A-Za-z0-9_]*")$/;
41247
41308
  var EXPANDING = "$`~*?[";
41309
+ function heredocSubstitution(text, from) {
41310
+ if (!text.startsWith("$(", from))
41311
+ return;
41312
+ const opener = /^[^\S\n]*cat[^\S\n]+(?:-[^\S\n]+)?<<(-?)[^\S\n]*(?:'([^']*)'|"([^"\\`]*)")[^\S\n]*\n/.exec(text.slice(from + 2));
41313
+ if (opener === null)
41314
+ return;
41315
+ const delimiter = opener[2] ?? opener[3] ?? "";
41316
+ if (delimiter === "")
41317
+ return;
41318
+ const strip = opener[1] === "-";
41319
+ const body = [];
41320
+ let index = from + 2 + opener[0].length;
41321
+ while (index <= text.length) {
41322
+ const stop = text.indexOf(`
41323
+ `, index);
41324
+ const line = text.slice(index, stop === -1 ? text.length : stop);
41325
+ if ((strip ? line.replace(/^\t+/, "") : line) === delimiter) {
41326
+ const rest = text.slice(stop === -1 ? text.length : stop + 1);
41327
+ const close = /^\s*\)/.exec(rest);
41328
+ if (close === null)
41329
+ return;
41330
+ return {
41331
+ end: (stop === -1 ? text.length : stop + 1) + close[0].length,
41332
+ value: body.join(`
41333
+ `).replace(/\n+$/, "")
41334
+ };
41335
+ }
41336
+ if (stop === -1)
41337
+ break;
41338
+ body.push(strip ? line.replace(/^\t+/, "") : line);
41339
+ index = stop + 1;
41340
+ }
41341
+ return;
41342
+ }
41248
41343
  function expansionEnd(text, from) {
41249
41344
  if (text[from] === "`") {
41250
41345
  let index = from + 1;
@@ -41322,6 +41417,12 @@ function readWord(text, from) {
41322
41417
  while (index < text.length && text[index] !== '"') {
41323
41418
  const inner = text[index];
41324
41419
  if (REFUSED_DOUBLE_QUOTED2.includes(inner)) {
41420
+ const here = inner === "$" ? heredocSubstitution(text, index) : undefined;
41421
+ if (here !== undefined) {
41422
+ value += here.value;
41423
+ index = here.end;
41424
+ continue;
41425
+ }
41325
41426
  unread.push(inner);
41326
41427
  refused = true;
41327
41428
  if (inner === "\\") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-envoy",
3
- "version": "15.0.0",
3
+ "version": "15.0.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {