@sjawhar/claude-envoy 2.7.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,5 +2,5 @@
2
2
  "name": "claude-envoy",
3
3
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
4
4
  "mcpServers": "./.mcp.json",
5
- "version": "2.7.1"
5
+ "version": "2.8.0"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-envoy",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "description": "Put Envoy events into the Claude Code session's own conversation and expose Envoy MCP tools.",
5
5
  "mcpServers": {}
6
6
  }
package/dist/dispatch.js CHANGED
@@ -14945,6 +14945,8 @@ var ArtifactCreatedEventPayloadSchema = object({
14945
14945
  name: artifactFields.name.optional()
14946
14946
  }).optional()
14947
14947
  });
14948
+ var ArtifactRenamedEventPayloadSchema = strictObject({ artifact: ArtifactSchema, previous_name: string2() }).readonly();
14949
+ var ArtifactRemovedEventPayloadSchema = strictObject({ artifact: ArtifactSchema }).readonly();
14948
14950
  var artifactVersionEventPayloadFields = {
14949
14951
  artifact_id: string2(),
14950
14952
  name: string2(),
@@ -15040,15 +15042,16 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
15040
15042
  message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
15041
15043
  };
15042
15044
  }
15043
- var ARTIFACT_SOURCE_RULE = "Exactly one of path or content is required.";
15045
+ var ARTIFACT_SOURCE_RULE = "Give at most one of path and content. A call with neither makes an empty document under the name, which a person or an agent writes in afterwards with dispatch doc-edit.";
15044
15046
  var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
15045
15047
  function brokenParts(parts) {
15046
15048
  const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
15047
15049
  return broken.length === 0 ? undefined : broken.join(" ");
15048
15050
  }
15049
15051
  var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
15052
+ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
15050
15053
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
15051
- var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so with content the name ends in .md or .markdown or has no extension; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
15054
+ var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
15052
15055
  var ARTIFACT_NAME_EXISTS_RULE = "An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. Send the upload again with force (--force) to write the next version.";
15053
15056
  var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
15054
15057
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
@@ -15062,19 +15065,16 @@ function artifactProblem(value) {
15062
15065
  const input = value;
15063
15066
  const ownerOrSourceProblem = brokenParts([
15064
15067
  [artifactOwner.check(value), artifactOwner.message],
15065
- [
15066
- typeof input.path === "string" !== (typeof input.content === "string"),
15067
- ARTIFACT_SOURCE_RULE
15068
- ]
15068
+ [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
15069
15069
  ]);
15070
15070
  if (ownerOrSourceProblem !== undefined)
15071
15071
  return ownerOrSourceProblem;
15072
- if (typeof input.content !== "string" || typeof input.name !== "string")
15072
+ if (typeof input.path === "string" || typeof input.name !== "string")
15073
15073
  return;
15074
15074
  const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
15075
15075
  if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
15076
15076
  return;
15077
- return `${CONTENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; content takes a name ending in .md or .markdown or with no extension.`;
15077
+ return `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
15078
15078
  }
15079
15079
  var documentEditOwner = documentOwnerValidation(true);
15080
15080
  var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
@@ -15625,7 +15625,7 @@ var dispatchToolSpecs = [
15625
15625
  name: "dispatch_artifact",
15626
15626
  example: { issue: "DSP-1", name: "design.md", content: `# Design
15627
15627
  ` },
15628
- 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. Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_NAME_EXISTS_RULE} ` + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "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}`,
15628
+ description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. 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. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force, so a title typed twice never empties the document that holds it. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "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}`,
15629
15629
  arguments: (z) => ({
15630
15630
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
15631
15631
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -19759,8 +19759,9 @@ class DispatchClient {
19759
19759
  return { status: response.status, payload: await this.#response(method, url, response) };
19760
19760
  }
19761
19761
  async#upload(path, input, key) {
19762
- if ("content" in input)
19762
+ if (input.file === undefined) {
19763
19763
  return this.#json("POST", path, input, undefined, undefined, key);
19764
+ }
19764
19765
  const form = new FormData;
19765
19766
  form.set("name", input.name);
19766
19767
  if (input.summary !== undefined)
@@ -23956,13 +23957,17 @@ function withoutFinalLineFeed(text) {
23956
23957
  return text.endsWith(`
23957
23958
  `) ? text.slice(0, -1) : text;
23958
23959
  }
23960
+ var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
23959
23961
  async function artifactCommand(context) {
23960
23962
  const { args, client, actor, input, documentOwner, issue } = context;
23961
23963
  const summary = optionalString(args, "summary");
23962
23964
  const name = stringArg(args, "name");
23963
23965
  const content = optionalString(args, "content");
23966
+ const path = optionalString(args, "path");
23967
+ const options = { name, ...summary === undefined ? {} : { summary }, actor };
23964
23968
  const artifactOwner = documentOwner();
23965
- if (optionalBoolean(args, "force") !== true) {
23969
+ const blank = content === undefined || goBlankPattern.test(content);
23970
+ if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
23966
23971
  const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
23967
23972
  if (held !== undefined) {
23968
23973
  throw new ToolInputError(input.tool, [
@@ -23970,7 +23975,7 @@ async function artifactCommand(context) {
23970
23975
  ]);
23971
23976
  }
23972
23977
  }
23973
- if (content !== undefined) {
23978
+ if (!blank) {
23974
23979
  let stored;
23975
23980
  try {
23976
23981
  stored = await client.markdownRoundTrip(content);
@@ -23983,19 +23988,12 @@ async function artifactCommand(context) {
23983
23988
  throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
23984
23989
  }
23985
23990
  }
23986
- const artifactInput = content === undefined ? {
23987
- name,
23988
- file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
23989
- type: Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))).type
23990
- }),
23991
- ...summary === undefined ? {} : { summary },
23992
- actor
23993
- } : {
23994
- name,
23995
- content,
23996
- ...summary === undefined ? {} : { summary },
23997
- actor
23998
- };
23991
+ const artifactInput = path !== undefined ? {
23992
+ ...options,
23993
+ file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
23994
+ type: Bun.file(resolvePath2(input.cwd, path)).type
23995
+ })
23996
+ } : content !== undefined ? { ...options, content } : options;
23999
23997
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
24000
23998
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
24001
23999
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -24004,7 +24002,7 @@ async function artifactCommand(context) {
24004
24002
  });
24005
24003
  return {
24006
24004
  text: [
24007
- `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
24005
+ path === undefined && content === undefined ? `Made ${result.artifact.name} as an empty document (artifact slug ${result.artifact.slug}; ${artifactRef}). Write in it with dispatch doc-edit.${await notSubscribed(uploadOwner, input.subscriptions)}` : `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
24008
24006
  ...adviceLines
24009
24007
  ].join(`
24010
24008
  `),
@@ -36585,6 +36585,8 @@ var ArtifactCreatedEventPayloadSchema = object({
36585
36585
  name: artifactFields.name.optional()
36586
36586
  }).optional()
36587
36587
  });
36588
+ var ArtifactRenamedEventPayloadSchema = strictObject({ artifact: ArtifactSchema, previous_name: string2() }).readonly();
36589
+ var ArtifactRemovedEventPayloadSchema = strictObject({ artifact: ArtifactSchema }).readonly();
36588
36590
  var artifactVersionEventPayloadFields = {
36589
36591
  artifact_id: string2(),
36590
36592
  name: string2(),
@@ -36680,15 +36682,16 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
36680
36682
  message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
36681
36683
  };
36682
36684
  }
36683
- var ARTIFACT_SOURCE_RULE = "Exactly one of path or content is required.";
36685
+ var ARTIFACT_SOURCE_RULE = "Give at most one of path and content. A call with neither makes an empty document under the name, which a person or an agent writes in afterwards with dispatch doc-edit.";
36684
36686
  var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
36685
36687
  function brokenParts(parts) {
36686
36688
  const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
36687
36689
  return broken.length === 0 ? undefined : broken.join(" ");
36688
36690
  }
36689
36691
  var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
36692
+ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
36690
36693
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
36691
- var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so with content the name ends in .md or .markdown or has no extension; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
36694
+ var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
36692
36695
  var ARTIFACT_NAME_EXISTS_RULE = "An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. Send the upload again with force (--force) to write the next version.";
36693
36696
  var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
36694
36697
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
@@ -36702,19 +36705,16 @@ function artifactProblem(value) {
36702
36705
  const input = value;
36703
36706
  const ownerOrSourceProblem = brokenParts([
36704
36707
  [artifactOwner.check(value), artifactOwner.message],
36705
- [
36706
- typeof input.path === "string" !== (typeof input.content === "string"),
36707
- ARTIFACT_SOURCE_RULE
36708
- ]
36708
+ [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
36709
36709
  ]);
36710
36710
  if (ownerOrSourceProblem !== undefined)
36711
36711
  return ownerOrSourceProblem;
36712
- if (typeof input.content !== "string" || typeof input.name !== "string")
36712
+ if (typeof input.path === "string" || typeof input.name !== "string")
36713
36713
  return;
36714
36714
  const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
36715
36715
  if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
36716
36716
  return;
36717
- return `${CONTENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; content takes a name ending in .md or .markdown or with no extension.`;
36717
+ return `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
36718
36718
  }
36719
36719
  var documentEditOwner = documentOwnerValidation(true);
36720
36720
  var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
@@ -37265,7 +37265,7 @@ var dispatchToolSpecs = [
37265
37265
  name: "dispatch_artifact",
37266
37266
  example: { issue: "DSP-1", name: "design.md", content: `# Design
37267
37267
  ` },
37268
- 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. Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_NAME_EXISTS_RULE} ` + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "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}`,
37268
+ description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. 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. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force, so a title typed twice never empties the document that holds it. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "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}`,
37269
37269
  arguments: (z) => ({
37270
37270
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
37271
37271
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -43604,8 +43604,9 @@ class DispatchClient {
43604
43604
  return { status: response.status, payload: await this.#response(method, url, response) };
43605
43605
  }
43606
43606
  async#upload(path, input, key) {
43607
- if ("content" in input)
43607
+ if (input.file === undefined) {
43608
43608
  return this.#json("POST", path, input, undefined, undefined, key);
43609
+ }
43609
43610
  const form = new FormData;
43610
43611
  form.set("name", input.name);
43611
43612
  if (input.summary !== undefined)
@@ -50778,13 +50779,17 @@ function withoutFinalLineFeed(text) {
50778
50779
  return text.endsWith(`
50779
50780
  `) ? text.slice(0, -1) : text;
50780
50781
  }
50782
+ var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
50781
50783
  async function artifactCommand(context) {
50782
50784
  const { args, client, actor, input, documentOwner, issue } = context;
50783
50785
  const summary = optionalString(args, "summary");
50784
50786
  const name = stringArg(args, "name");
50785
50787
  const content = optionalString(args, "content");
50788
+ const path = optionalString(args, "path");
50789
+ const options = { name, ...summary === undefined ? {} : { summary }, actor };
50786
50790
  const artifactOwner = documentOwner();
50787
- if (optionalBoolean(args, "force") !== true) {
50791
+ const blank = content === undefined || goBlankPattern.test(content);
50792
+ if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
50788
50793
  const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
50789
50794
  if (held !== undefined) {
50790
50795
  throw new ToolInputError(input.tool, [
@@ -50792,7 +50797,7 @@ async function artifactCommand(context) {
50792
50797
  ]);
50793
50798
  }
50794
50799
  }
50795
- if (content !== undefined) {
50800
+ if (!blank) {
50796
50801
  let stored;
50797
50802
  try {
50798
50803
  stored = await client.markdownRoundTrip(content);
@@ -50805,19 +50810,12 @@ async function artifactCommand(context) {
50805
50810
  throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
50806
50811
  }
50807
50812
  }
50808
- const artifactInput = content === undefined ? {
50809
- name,
50810
- file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
50811
- type: Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))).type
50812
- }),
50813
- ...summary === undefined ? {} : { summary },
50814
- actor
50815
- } : {
50816
- name,
50817
- content,
50818
- ...summary === undefined ? {} : { summary },
50819
- actor
50820
- };
50813
+ const artifactInput = path !== undefined ? {
50814
+ ...options,
50815
+ file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
50816
+ type: Bun.file(resolvePath2(input.cwd, path)).type
50817
+ })
50818
+ } : content !== undefined ? { ...options, content } : options;
50821
50819
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
50822
50820
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
50823
50821
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -50826,7 +50824,7 @@ async function artifactCommand(context) {
50826
50824
  });
50827
50825
  return {
50828
50826
  text: [
50829
- `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
50827
+ path === undefined && content === undefined ? `Made ${result.artifact.name} as an empty document (artifact slug ${result.artifact.slug}; ${artifactRef}). Write in it with dispatch doc-edit.${await notSubscribed(uploadOwner, input.subscriptions)}` : `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
50830
50828
  ...adviceLines
50831
50829
  ].join(`
50832
50830
  `),
@@ -56699,7 +56697,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
56699
56697
 
56700
56698
  // package.json
56701
56699
  var name = "@sjawhar/claude-envoy";
56702
- var version2 = "2.7.1";
56700
+ var version2 = "2.8.0";
56703
56701
  var legion = {
56704
56702
  daemonApiVersion: 86
56705
56703
  };
@@ -13932,6 +13932,8 @@ var ArtifactCreatedEventPayloadSchema = object({
13932
13932
  name: artifactFields.name.optional()
13933
13933
  }).optional()
13934
13934
  });
13935
+ var ArtifactRenamedEventPayloadSchema = strictObject({ artifact: ArtifactSchema, previous_name: string2() }).readonly();
13936
+ var ArtifactRemovedEventPayloadSchema = strictObject({ artifact: ArtifactSchema }).readonly();
13935
13937
  var artifactVersionEventPayloadFields = {
13936
13938
  artifact_id: string2(),
13937
13939
  name: string2(),
@@ -14027,15 +14029,16 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
14027
14029
  message: alwaysRequireArtifact ? "Exactly one of issue and project is required; artifact or ref must name the document." : "Exactly one of issue and project is required; with project, artifact names the document."
14028
14030
  };
14029
14031
  }
14030
- var ARTIFACT_SOURCE_RULE = "Exactly one of path or content is required.";
14032
+ var ARTIFACT_SOURCE_RULE = "Give at most one of path and content. A call with neither makes an empty document under the name, which a person or an agent writes in afterwards with dispatch doc-edit.";
14031
14033
  var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
14032
14034
  function brokenParts(parts) {
14033
14035
  const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
14034
14036
  return broken.length === 0 ? undefined : broken.join(" ");
14035
14037
  }
14036
14038
  var CONTENT_IS_MARKDOWN = "content is stored as a Markdown document, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
14039
+ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
14037
14040
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
14038
- var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so with content the name ends in .md or .markdown or has no extension; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
14041
+ var ARTIFACT_CONTENT_NAME_RULE = `${CONTENT_IS_MARKDOWN}, so a document's name ends in .md or .markdown or has no extension, under content and under neither flag alike; upload any other file (.jsonl, .tsv, .json, .txt) with ${PATH_KEEPS_BYTES}.`;
14039
14042
  var ARTIFACT_NAME_EXISTS_RULE = "An upload under the name of a document the owner already holds is refused: it writes that document's next version, over the text it holds. Change a document with dispatch doc-edit. Send the upload again with force (--force) to write the next version.";
14040
14043
  var ARTIFACT_STORED_TEXT_RULE = `content and content-file hold text Dispatch stores as Markdown, and a text the store would write under another spelling is refused. The refusal prints the text Dispatch stores: send that text. A name that does not end in .md or .markdown has a second way out, which keeps the text as it was written: send it as a file with ${PATH_KEEPS_BYTES}.`;
14041
14044
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
@@ -14049,19 +14052,16 @@ function artifactProblem(value) {
14049
14052
  const input = value;
14050
14053
  const ownerOrSourceProblem = brokenParts([
14051
14054
  [artifactOwner.check(value), artifactOwner.message],
14052
- [
14053
- typeof input.path === "string" !== (typeof input.content === "string"),
14054
- ARTIFACT_SOURCE_RULE
14055
- ]
14055
+ [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
14056
14056
  ]);
14057
14057
  if (ownerOrSourceProblem !== undefined)
14058
14058
  return ownerOrSourceProblem;
14059
- if (typeof input.content !== "string" || typeof input.name !== "string")
14059
+ if (typeof input.path === "string" || typeof input.name !== "string")
14060
14060
  return;
14061
14061
  const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
14062
14062
  if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
14063
14063
  return;
14064
- return `${CONTENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; content takes a name ending in .md or .markdown or with no extension.`;
14064
+ return `${DOCUMENT_IS_MARKDOWN}, and ${JSON.stringify(input.name)} is not a Markdown name. Upload the file under the same name with ${PATH_KEEPS_BYTES}; a document takes a name ending in .md or .markdown or with no extension.`;
14065
14065
  }
14066
14066
  var documentEditOwner = documentOwnerValidation(true);
14067
14067
  var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
@@ -14612,7 +14612,7 @@ var dispatchToolSpecs = [
14612
14612
  name: "dispatch_artifact",
14613
14613
  example: { issue: "DSP-1", name: "design.md", content: `# Design
14614
14614
  ` },
14615
- 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. Exactly one of path or content is required; a markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_NAME_EXISTS_RULE} ` + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "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}`,
14615
+ description: "Attach a local file or inline text as an issue artifact or project document, or make an empty document from its name alone. 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. " + `${ARTIFACT_SOURCE_RULE} ` + `${ARTIFACT_NAME_EXISTS_RULE} A call that stores nothing - no path, and content absent or blank - is refused under a held name even with force, so a title typed twice never empties the document that holds it. ` + "A markdown document is at most 1 MiB and any other file at most 25 MiB. " + `${ARTIFACT_CONTENT_NAME_RULE} ${ARTIFACT_STORED_TEXT_RULE} ` + "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}`,
14616
14616
  arguments: (z) => ({
14617
14617
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
14618
14618
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -18763,8 +18763,9 @@ class DispatchClient {
18763
18763
  return { status: response.status, payload: await this.#response(method, url, response) };
18764
18764
  }
18765
18765
  async#upload(path, input, key) {
18766
- if ("content" in input)
18766
+ if (input.file === undefined) {
18767
18767
  return this.#json("POST", path, input, undefined, undefined, key);
18768
+ }
18768
18769
  const form = new FormData;
18769
18770
  form.set("name", input.name);
18770
18771
  if (input.summary !== undefined)
@@ -22960,13 +22961,17 @@ function withoutFinalLineFeed(text) {
22960
22961
  return text.endsWith(`
22961
22962
  `) ? text.slice(0, -1) : text;
22962
22963
  }
22964
+ var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
22963
22965
  async function artifactCommand(context) {
22964
22966
  const { args, client, actor, input, documentOwner, issue } = context;
22965
22967
  const summary = optionalString(args, "summary");
22966
22968
  const name = stringArg(args, "name");
22967
22969
  const content = optionalString(args, "content");
22970
+ const path = optionalString(args, "path");
22971
+ const options = { name, ...summary === undefined ? {} : { summary }, actor };
22968
22972
  const artifactOwner = documentOwner();
22969
- if (optionalBoolean(args, "force") !== true) {
22973
+ const blank = content === undefined || goBlankPattern.test(content);
22974
+ if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
22970
22975
  const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
22971
22976
  if (held !== undefined) {
22972
22977
  throw new ToolInputError(input.tool, [
@@ -22974,7 +22979,7 @@ async function artifactCommand(context) {
22974
22979
  ]);
22975
22980
  }
22976
22981
  }
22977
- if (content !== undefined) {
22982
+ if (!blank) {
22978
22983
  let stored;
22979
22984
  try {
22980
22985
  stored = await client.markdownRoundTrip(content);
@@ -22987,19 +22992,12 @@ async function artifactCommand(context) {
22987
22992
  throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
22988
22993
  }
22989
22994
  }
22990
- const artifactInput = content === undefined ? {
22991
- name,
22992
- file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
22993
- type: Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))).type
22994
- }),
22995
- ...summary === undefined ? {} : { summary },
22996
- actor
22997
- } : {
22998
- name,
22999
- content,
23000
- ...summary === undefined ? {} : { summary },
23001
- actor
23002
- };
22995
+ const artifactInput = path !== undefined ? {
22996
+ ...options,
22997
+ file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
22998
+ type: Bun.file(resolvePath2(input.cwd, path)).type
22999
+ })
23000
+ } : content !== undefined ? { ...options, content } : options;
23003
23001
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
23004
23002
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
23005
23003
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -23008,7 +23006,7 @@ async function artifactCommand(context) {
23008
23006
  });
23009
23007
  return {
23010
23008
  text: [
23011
- `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
23009
+ path === undefined && content === undefined ? `Made ${result.artifact.name} as an empty document (artifact slug ${result.artifact.slug}; ${artifactRef}). Write in it with dispatch doc-edit.${await notSubscribed(uploadOwner, input.subscriptions)}` : `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
23012
23010
  ...adviceLines
23013
23011
  ].join(`
23014
23012
  `),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/claude-envoy",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Claude Code plugin for Legion's Envoy bus",
6
6
  "type": "module",