@sjawhar/pi-envoy 17.6.1 → 17.7.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.
package/README.md CHANGED
@@ -316,10 +316,12 @@ session's subscriptions, as the Envoy listener records them, covers that owner.
316
316
  The shared specs in `@legion/contracts` supply each command's description and flags:
317
317
  `@legion/envoy-client`'s `dispatch-command.ts` derives one command per spec and one flag per field.
318
318
 
319
- `dispatch artifact` takes exactly one upload source: a local `--path`, or inline `--content`. For
320
- example, an architect can post a specification directly, its text on stdin. Every issue is created
321
- with a `spec.md`, and the command refuses an upload under the name of a document the issue already
322
- holds, so this one carries `--force`, which writes the next version of it:
319
+ `dispatch artifact` takes at most one upload source: a local `--path`, or inline `--content`.
320
+ With neither, it makes an empty document under `--name`, which a person or an agent writes in
321
+ afterwards with `dispatch doc-edit`. For example, an architect can post a specification directly,
322
+ its text on stdin. Every issue is created with a `spec.md`, and the command refuses an upload
323
+ under the name of a document the issue already holds, so this one carries `--force`, which writes
324
+ the next version of it:
323
325
 
324
326
  ```sh
325
327
  dispatch artifact --issue LEGION-1 --name spec.md --content-file - --force <<'EOF'
@@ -327,12 +329,12 @@ dispatch artifact --issue LEGION-1 --name spec.md --content-file - --force <<'EO
327
329
  EOF
328
330
  ```
329
331
 
330
- Inline content is stored as a Markdown document, so `--content` and `--content-file` take only a
331
- `--name` that ends in `.md` or `.markdown` or has no extension. The command refuses any other name
332
- (`rows.jsonl`, `sizes.tsv`, `rows.jsonl.1`, `plan v1.2`) before it sends anything and names
333
- `--path`, which stores a file whose path does not end in `.md` or `.markdown` as its bytes,
334
- unchanged, under that name. A document title with a dot near its end takes `--content` once it
335
- ends in `.md`.
332
+ Inline content is stored as a Markdown document, so `--content`, `--content-file` and a call with
333
+ neither flag take only a `--name` that ends in `.md` or `.markdown` or has no extension. The
334
+ command refuses any other name (`rows.jsonl`, `sizes.tsv`, `rows.jsonl.1`, `plan v1.2`) before it
335
+ sends anything and names `--path`, which stores a file whose path does not end in `.md` or
336
+ `.markdown` as its bytes, unchanged, under that name. A document title with a dot near its end
337
+ takes `--content` once it ends in `.md`.
336
338
 
337
339
  `dispatch handoff-write --issue <KEY> --phase <phase> --body-file <path>` records a Legion phase
338
340
  handoff on its issue as this session: the file's text, one JSON object, is stored exactly as
package/dist/dispatch.js CHANGED
@@ -14853,6 +14853,8 @@ var ArtifactCreatedEventPayloadSchema = object({
14853
14853
  name: artifactFields.name.optional()
14854
14854
  }).optional()
14855
14855
  });
14856
+ var ArtifactRenamedEventPayloadSchema = strictObject({ artifact: ArtifactSchema, previous_name: string2() }).readonly();
14857
+ var ArtifactRemovedEventPayloadSchema = strictObject({ artifact: ArtifactSchema }).readonly();
14856
14858
  var artifactVersionEventPayloadFields = {
14857
14859
  artifact_id: string2(),
14858
14860
  name: string2(),
@@ -14948,15 +14950,16 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
14948
14950
  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."
14949
14951
  };
14950
14952
  }
14951
- var ARTIFACT_SOURCE_RULE = "Exactly one of path or content is required.";
14953
+ 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.";
14952
14954
  var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
14953
14955
  function brokenParts(parts) {
14954
14956
  const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
14955
14957
  return broken.length === 0 ? undefined : broken.join(" ");
14956
14958
  }
14957
14959
  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)";
14960
+ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
14958
14961
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
14959
- 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}.`;
14962
+ 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}.`;
14960
14963
  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.";
14961
14964
  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}.`;
14962
14965
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
@@ -14970,19 +14973,16 @@ function artifactProblem(value) {
14970
14973
  const input = value;
14971
14974
  const ownerOrSourceProblem = brokenParts([
14972
14975
  [artifactOwner.check(value), artifactOwner.message],
14973
- [
14974
- typeof input.path === "string" !== (typeof input.content === "string"),
14975
- ARTIFACT_SOURCE_RULE
14976
- ]
14976
+ [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
14977
14977
  ]);
14978
14978
  if (ownerOrSourceProblem !== undefined)
14979
14979
  return ownerOrSourceProblem;
14980
- if (typeof input.content !== "string" || typeof input.name !== "string")
14980
+ if (typeof input.path === "string" || typeof input.name !== "string")
14981
14981
  return;
14982
14982
  const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
14983
14983
  if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
14984
14984
  return;
14985
- 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.`;
14985
+ 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.`;
14986
14986
  }
14987
14987
  var documentEditOwner = documentOwnerValidation(true);
14988
14988
  var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
@@ -15533,7 +15533,7 @@ var dispatchToolSpecs = [
15533
15533
  name: "dispatch_artifact",
15534
15534
  example: { issue: "DSP-1", name: "design.md", content: `# Design
15535
15535
  ` },
15536
- 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}`,
15536
+ 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}`,
15537
15537
  arguments: (z) => ({
15538
15538
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
15539
15539
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -19105,8 +19105,9 @@ class DispatchClient {
19105
19105
  return { status: response.status, payload: await this.#response(method, url, response) };
19106
19106
  }
19107
19107
  async#upload(path, input, key) {
19108
- if ("content" in input)
19108
+ if (input.file === undefined) {
19109
19109
  return this.#json("POST", path, input, undefined, undefined, key);
19110
+ }
19110
19111
  const form = new FormData;
19111
19112
  form.set("name", input.name);
19112
19113
  if (input.summary !== undefined)
@@ -22537,13 +22538,17 @@ function withoutFinalLineFeed(text) {
22537
22538
  return text.endsWith(`
22538
22539
  `) ? text.slice(0, -1) : text;
22539
22540
  }
22541
+ var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
22540
22542
  async function artifactCommand(context) {
22541
22543
  const { args, client, actor, input, documentOwner, issue } = context;
22542
22544
  const summary = optionalString(args, "summary");
22543
22545
  const name = stringArg(args, "name");
22544
22546
  const content = optionalString(args, "content");
22547
+ const path = optionalString(args, "path");
22548
+ const options = { name, ...summary === undefined ? {} : { summary }, actor };
22545
22549
  const artifactOwner = documentOwner();
22546
- if (optionalBoolean(args, "force") !== true) {
22550
+ const blank = content === undefined || goBlankPattern.test(content);
22551
+ if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
22547
22552
  const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
22548
22553
  if (held !== undefined) {
22549
22554
  throw new ToolInputError(input.tool, [
@@ -22551,7 +22556,7 @@ async function artifactCommand(context) {
22551
22556
  ]);
22552
22557
  }
22553
22558
  }
22554
- if (content !== undefined) {
22559
+ if (!blank) {
22555
22560
  let stored;
22556
22561
  try {
22557
22562
  stored = await client.markdownRoundTrip(content);
@@ -22564,19 +22569,12 @@ async function artifactCommand(context) {
22564
22569
  throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
22565
22570
  }
22566
22571
  }
22567
- const artifactInput = content === undefined ? {
22568
- name,
22569
- file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
22570
- type: Bun.file(resolvePath2(input.cwd, stringArg(args, "path"))).type
22571
- }),
22572
- ...summary === undefined ? {} : { summary },
22573
- actor
22574
- } : {
22575
- name,
22576
- content,
22577
- ...summary === undefined ? {} : { summary },
22578
- actor
22579
- };
22572
+ const artifactInput = path !== undefined ? {
22573
+ ...options,
22574
+ file: input.uploadBytes === undefined ? Bun.file(resolvePath2(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
22575
+ type: Bun.file(resolvePath2(input.cwd, path)).type
22576
+ })
22577
+ } : content !== undefined ? { ...options, content } : options;
22580
22578
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
22581
22579
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
22582
22580
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -22585,7 +22583,7 @@ async function artifactCommand(context) {
22585
22583
  });
22586
22584
  return {
22587
22585
  text: [
22588
- `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
22586
+ 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)}`,
22589
22587
  ...adviceLines
22590
22588
  ].join(`
22591
22589
  `),
package/dist/envoy.js CHANGED
@@ -29947,6 +29947,8 @@ var ArtifactCreatedEventPayloadSchema = object({
29947
29947
  name: artifactFields.name.optional()
29948
29948
  }).optional()
29949
29949
  });
29950
+ var ArtifactRenamedEventPayloadSchema = strictObject({ artifact: ArtifactSchema, previous_name: string2() }).readonly();
29951
+ var ArtifactRemovedEventPayloadSchema = strictObject({ artifact: ArtifactSchema }).readonly();
29950
29952
  var artifactVersionEventPayloadFields = {
29951
29953
  artifact_id: string2(),
29952
29954
  name: string2(),
@@ -30042,15 +30044,16 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
30042
30044
  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."
30043
30045
  };
30044
30046
  }
30045
- var ARTIFACT_SOURCE_RULE = "Exactly one of path or content is required.";
30047
+ 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.";
30046
30048
  var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
30047
30049
  function brokenParts(parts) {
30048
30050
  const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
30049
30051
  return broken.length === 0 ? undefined : broken.join(" ");
30050
30052
  }
30051
30053
  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)";
30054
+ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
30052
30055
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
30053
- 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}.`;
30056
+ 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}.`;
30054
30057
  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.";
30055
30058
  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}.`;
30056
30059
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
@@ -30064,19 +30067,16 @@ function artifactProblem(value) {
30064
30067
  const input = value;
30065
30068
  const ownerOrSourceProblem = brokenParts([
30066
30069
  [artifactOwner.check(value), artifactOwner.message],
30067
- [
30068
- typeof input.path === "string" !== (typeof input.content === "string"),
30069
- ARTIFACT_SOURCE_RULE
30070
- ]
30070
+ [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
30071
30071
  ]);
30072
30072
  if (ownerOrSourceProblem !== undefined)
30073
30073
  return ownerOrSourceProblem;
30074
- if (typeof input.content !== "string" || typeof input.name !== "string")
30074
+ if (typeof input.path === "string" || typeof input.name !== "string")
30075
30075
  return;
30076
30076
  const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
30077
30077
  if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
30078
30078
  return;
30079
- 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.`;
30079
+ 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.`;
30080
30080
  }
30081
30081
  var documentEditOwner = documentOwnerValidation(true);
30082
30082
  var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
@@ -30627,7 +30627,7 @@ var dispatchToolSpecs = [
30627
30627
  name: "dispatch_artifact",
30628
30628
  example: { issue: "DSP-1", name: "design.md", content: `# Design
30629
30629
  ` },
30630
- 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}`,
30630
+ 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}`,
30631
30631
  arguments: (z) => ({
30632
30632
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
30633
30633
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -36975,8 +36975,9 @@ class DispatchClient {
36975
36975
  return { status: response.status, payload: await this.#response(method, url, response) };
36976
36976
  }
36977
36977
  async#upload(path, input, key) {
36978
- if ("content" in input)
36978
+ if (input.file === undefined) {
36979
36979
  return this.#json("POST", path, input, undefined, undefined, key);
36980
+ }
36980
36981
  const form = new FormData;
36981
36982
  form.set("name", input.name);
36982
36983
  if (input.summary !== undefined)
@@ -43553,13 +43554,17 @@ function withoutFinalLineFeed(text) {
43553
43554
  return text.endsWith(`
43554
43555
  `) ? text.slice(0, -1) : text;
43555
43556
  }
43557
+ var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
43556
43558
  async function artifactCommand(context) {
43557
43559
  const { args, client, actor, input, documentOwner, issue } = context;
43558
43560
  const summary = optionalString(args, "summary");
43559
43561
  const name = stringArg(args, "name");
43560
43562
  const content = optionalString(args, "content");
43563
+ const path = optionalString(args, "path");
43564
+ const options = { name, ...summary === undefined ? {} : { summary }, actor };
43561
43565
  const artifactOwner = documentOwner();
43562
- if (optionalBoolean(args, "force") !== true) {
43566
+ const blank = content === undefined || goBlankPattern.test(content);
43567
+ if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
43563
43568
  const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
43564
43569
  if (held !== undefined) {
43565
43570
  throw new ToolInputError(input.tool, [
@@ -43567,7 +43572,7 @@ async function artifactCommand(context) {
43567
43572
  ]);
43568
43573
  }
43569
43574
  }
43570
- if (content !== undefined) {
43575
+ if (!blank) {
43571
43576
  let stored;
43572
43577
  try {
43573
43578
  stored = await client.markdownRoundTrip(content);
@@ -43580,19 +43585,12 @@ async function artifactCommand(context) {
43580
43585
  throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
43581
43586
  }
43582
43587
  }
43583
- const artifactInput = content === undefined ? {
43584
- name,
43585
- file: input.uploadBytes === undefined ? Bun.file(resolvePath(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
43586
- type: Bun.file(resolvePath(input.cwd, stringArg(args, "path"))).type
43587
- }),
43588
- ...summary === undefined ? {} : { summary },
43589
- actor
43590
- } : {
43591
- name,
43592
- content,
43593
- ...summary === undefined ? {} : { summary },
43594
- actor
43595
- };
43588
+ const artifactInput = path !== undefined ? {
43589
+ ...options,
43590
+ file: input.uploadBytes === undefined ? Bun.file(resolvePath(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
43591
+ type: Bun.file(resolvePath(input.cwd, path)).type
43592
+ })
43593
+ } : content !== undefined ? { ...options, content } : options;
43596
43594
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
43597
43595
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
43598
43596
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -43601,7 +43599,7 @@ async function artifactCommand(context) {
43601
43599
  });
43602
43600
  return {
43603
43601
  text: [
43604
- `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
43602
+ 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)}`,
43605
43603
  ...adviceLines
43606
43604
  ].join(`
43607
43605
  `),
@@ -47042,7 +47040,7 @@ var import_nats2 = __toESM(require_mod4(), 1);
47042
47040
 
47043
47041
  // package.json
47044
47042
  var name = "@sjawhar/pi-envoy";
47045
- var version2 = "17.6.1";
47043
+ var version2 = "17.7.0";
47046
47044
  var package_default = {
47047
47045
  name,
47048
47046
  version: version2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-envoy",
3
- "version": "17.6.1",
3
+ "version": "17.7.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {