@sjawhar/opencode-legion-envoy 5.2.1 → 5.2.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.
@@ -14238,7 +14238,7 @@ var dispatchToolSpecs = [
14238
14238
  {
14239
14239
  name: "dispatch_doc_read",
14240
14240
  example: { issue: "DSP-1" },
14241
- description: "Read a live document or a named document version. Do not use it for issue status, asks, or events; " + "use dispatch_read instead. Supply ref, issue, or project plus artifact; issue plus an omitted artifact reads the primary document. " + "A live read returns its document token for an optional dispatch_doc_edit precondition; use /blocks for per-block tokens. " + OWNER_REFERENCE,
14241
+ description: "Read a live document or a named document version, or the text of an uploaded file at its latest or named version. " + "Do not use it for issue status, asks, or events; " + "use dispatch_read instead. Supply ref, issue, or project plus artifact; issue plus an omitted artifact reads the primary document. " + "A live read returns its document token for an optional dispatch_doc_edit precondition; use /blocks for per-block tokens. " + "A file that is not UTF-8 text is described, with the route that serves its bytes. " + OWNER_REFERENCE,
14242
14242
  arguments: (z2) => ({
14243
14243
  issue: z2.string().describe(ISSUE_REFERENCE).optional(),
14244
14244
  project: z2.string().describe("Project key owning the document.").optional(),
@@ -15026,6 +15026,20 @@ class DispatchClient {
15026
15026
  async docRead(id, version2) {
15027
15027
  return version2 === undefined ? this.#json("GET", ["api", "v1", "artifacts", id, "text"]) : this.#json("GET", ["api", "v1", "artifacts", id, "versions", String(version2)]);
15028
15028
  }
15029
+ async fileVersion(id, version2) {
15030
+ const url2 = this.#url(["api", "v1", "artifacts", id, "versions", String(version2)]);
15031
+ const response = await this.fetchImpl(url2, {
15032
+ method: "GET",
15033
+ headers: { Accept: "*/*", Authorization: `Bearer ${this.token}` },
15034
+ signal: this.#signal
15035
+ });
15036
+ if (!response.ok)
15037
+ return this.#response("GET", url2, response);
15038
+ return {
15039
+ mime: response.headers.get("Content-Type") ?? "application/octet-stream",
15040
+ bytes: new Uint8Array(await response.arrayBuffer())
15041
+ };
15042
+ }
15029
15043
  async artifactBlocks(id) {
15030
15044
  return this.#json("GET", ["api", "v1", "artifacts", id, "blocks"]);
15031
15045
  }
@@ -16308,6 +16322,30 @@ async function blockAsks(client, resolved, state) {
16308
16322
  const asks = await (resolved.issue === undefined ? client.getArtifactAsks(resolved.artifact.id, state) : client.listIssueAsks(resolved.issue.key, state));
16309
16323
  return asks.filter((ask) => typeof ask.block_id === "string" && ask.block_artifact?.id === resolved.artifact.id);
16310
16324
  }
16325
+ async function readUploadedFile(client, resolved, requested) {
16326
+ const { artifact } = resolved;
16327
+ const latest = Math.max(0, ...artifact.versions.map((version2) => version2.number));
16328
+ const number4 = requested ?? latest;
16329
+ const file2 = await client.fileVersion(artifact.id, number4);
16330
+ const of = number4 === latest ? "" : ` of ${latest}`;
16331
+ const size = `${file2.bytes.length.toLocaleString("en-US")} bytes`;
16332
+ const details = resolved.owner.kind === "project" ? { project: artifact.project, document: documentLabel(artifact.project, artifact.slug) } : { issue: resolved.issue?.key };
16333
+ let text;
16334
+ try {
16335
+ text = new TextDecoder("utf-8", { fatal: true }).decode(file2.bytes);
16336
+ } catch {
16337
+ return {
16338
+ text: `${artifact.name} is an uploaded ${file2.mime} file (version ${number4}${of}, ${size}) that is not ` + `UTF-8 text, so dispatch_doc_read cannot show it. GET /api/v1/artifacts/${artifact.id}/versions/${number4} serves its bytes.`,
16339
+ details
16340
+ };
16341
+ }
16342
+ return {
16343
+ text: `File ${artifact.name}: ${file2.mime}, version ${number4}${of}, ${size}.
16344
+
16345
+ ${text}`,
16346
+ details
16347
+ };
16348
+ }
16311
16349
  async function refuseOpenDecisionBlocks(client, tool, resolved) {
16312
16350
  const artifact = resolved.artifact;
16313
16351
  const latest = artifact.approval?.latest_version;
@@ -17005,6 +17043,9 @@ ${followsAsk(askOwner)}`,
17005
17043
  const artifactReference = optionalString(args, "artifact") ?? (ownerArguments.ref?.kind === "spec" || ownerArguments.ref?.kind === "artifact" ? ownerArguments.ref.id : undefined);
17006
17044
  const resolved = await resolveDocument(documentOwner(), artifactReference);
17007
17045
  const version2 = optionalNumber(args, "version") ?? ownerArguments.ref?.version;
17046
+ if (resolved.artifact.kind === "file" || resolved.artifact.kind === "image") {
17047
+ return readUploadedFile(client, resolved, version2);
17048
+ }
17008
17049
  const documentPromise = client.docRead(resolved.artifact.id, version2);
17009
17050
  const marksPromise = openArtifactMarks(client, resolved);
17010
17051
  const marksResultPromise = marksPromise.then((value) => ({ status: "fulfilled", value }), (reason) => ({ status: "rejected", reason }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/opencode-legion-envoy",
3
- "version": "5.2.1",
3
+ "version": "5.2.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/src/server.js",
@@ -418,10 +418,10 @@ Read the current document before changing it:
418
418
  ```ts
419
419
  dispatch_doc_read({ issue?, project?, artifact?, version?, ref? })
420
420
  ```
421
- It returns live or versioned markdown with open marks. A live read ends with a document token; `issue` with an
422
- omitted `artifact` reads the issue specification; a project needs `artifact`; and a
423
- `dispatch://PROJECT/artifact/<document-ref>` ref supplies both, where `document-ref` is the slug (an id or a
424
- filename resolves when no document has that slug).
421
+ It returns live or versioned markdown with open marks. A live read ends with a document token; `issue` with an omitted
422
+ `artifact` reads the issue specification; a project needs `artifact`; and a `dispatch://PROJECT/artifact/<document-ref>`
423
+ ref supplies both, where `document-ref` is the slug (an id or a filename resolves when no document has that slug). A file
424
+ `dispatch_artifact` uploaded reads its text at the latest or named version, or a description when it is not UTF-8 text.
425
425
 
426
426
  Editing one is [Editing a document](skill://dispatch/references/document-edits.md): the shape of `dispatch_doc_edit`,
427
427
  how to quote the text you mean, one `replace` per paragraph, preconditions against a stale edit, and