@sjawhar/opencode-legion-envoy 3.2.5 → 3.2.7

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.
@@ -13865,7 +13865,7 @@ function dispatchToolSchema(spec, z2, opts) {
13865
13865
  const schemaOptions = strict === undefined ? undefined : { strict };
13866
13866
  return spec.validation === undefined ? z2.object(shape, schemaOptions) : z2.refineObject(shape, spec.validation.check, spec.validation.message, schemaOptions);
13867
13867
  }
13868
- var ISSUE_REFERENCE = "An issue is a native KEY or external owner/repo#n reference; an external reference creates its native issue in the repository's dashboard-configured project or, failing that, the default project (DISPATCH_DEFAULT_PROJECT).";
13868
+ var ISSUE_REFERENCE = "An issue is a native KEY or external owner/repo#n reference. An external reference addresses an existing Dispatch issue, including one linked to that GitHub pull request; only dispatch_issue with external creates a native issue.";
13869
13869
  var OWNER_REFERENCE = "Exactly one of issue and project is required. An issue is a native KEY or external owner/repo#n reference; a project is a project key such as CORE and addresses an unlinked project document named by artifact.";
13870
13870
  function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false) {
13871
13871
  return {
@@ -15054,7 +15054,6 @@ class DispatchClient {
15054
15054
  fetchImpl;
15055
15055
  #baseUrl;
15056
15056
  #resolvedIssues = new Map;
15057
- #creatingIssues = new Map;
15058
15057
  #signal;
15059
15058
  constructor(baseUrl, token, fetchImpl = fetch, signal) {
15060
15059
  this.token = token;
@@ -15065,6 +15064,9 @@ class DispatchClient {
15065
15064
  async issue(input) {
15066
15065
  return this.#json("POST", ["api", "v1", "issues"], input);
15067
15066
  }
15067
+ async resolveIssue(issueReference) {
15068
+ return this.#resolveIssue(issueReference);
15069
+ }
15068
15070
  async listIssues(options = {}) {
15069
15071
  return this.#json("GET", ["api", "v1", "issues"], undefined, options);
15070
15072
  }
@@ -15260,43 +15262,6 @@ class DispatchClient {
15260
15262
  ...query.since === undefined ? {} : { since: query.since }
15261
15263
  });
15262
15264
  }
15263
- async ensureIssue(issueReference, actor) {
15264
- if (!issueReference.includes("#"))
15265
- return issueReference;
15266
- try {
15267
- return await this.#resolveIssue(issueReference);
15268
- } catch (error48) {
15269
- if (!(error48 instanceof DispatchServiceError) || error48.status !== 404)
15270
- throw error48;
15271
- }
15272
- let creating = this.#creatingIssues.get(issueReference);
15273
- if (!creating) {
15274
- creating = this.#createExternalIssue(issueReference, actor);
15275
- this.#creatingIssues.set(issueReference, creating);
15276
- }
15277
- try {
15278
- return await creating;
15279
- } finally {
15280
- if (this.#creatingIssues.get(issueReference) === creating) {
15281
- this.#creatingIssues.delete(issueReference);
15282
- }
15283
- }
15284
- }
15285
- async#createExternalIssue(issueReference, actor) {
15286
- try {
15287
- const created = await this.#json("POST", ["api", "v1", "issues"], {
15288
- external: issueReference,
15289
- actor
15290
- });
15291
- this.#resolvedIssues.set(issueReference, Promise.resolve(created.key));
15292
- return created.key;
15293
- } catch (error48) {
15294
- if (error48 instanceof DispatchServiceError && (error48.status === 409 || error48.status === 500)) {
15295
- return this.#resolveIssue(issueReference);
15296
- }
15297
- throw error48;
15298
- }
15299
- }
15300
15265
  async#resolveIssue(issueReference) {
15301
15266
  if (!issueReference.includes("#"))
15302
15267
  return issueReference;
@@ -16497,7 +16462,7 @@ async function executeDispatchTool(input) {
16497
16462
  const client = dispatchClient();
16498
16463
  const owner = ownerArguments.owner?.kind === "issue" ? {
16499
16464
  kind: "issue",
16500
- issue: await ensureIssue(client, ownerArguments.owner.issue, actor)
16465
+ issue: await resolveExistingIssue(client, ownerArguments.owner.issue)
16501
16466
  } : ownerArguments.owner;
16502
16467
  const issue2 = () => {
16503
16468
  if (owner?.kind !== "issue")
@@ -17149,13 +17114,12 @@ ${trailer.join(`
17149
17114
  throw new Error(`Unknown Dispatch tool: ${input.tool}`);
17150
17115
  }
17151
17116
  }
17152
- async function ensureIssue(client, issueReference, actor) {
17117
+ async function resolveExistingIssue(client, issueReference) {
17153
17118
  try {
17154
- return await client.ensureIssue(issueReference, actor);
17119
+ return await client.resolveIssue(issueReference);
17155
17120
  } catch (error48) {
17156
- if (error48 instanceof DispatchServiceError && error48.code === "PROJECT_UNMAPPED") {
17157
- const repository = issueReference.slice(0, issueReference.lastIndexOf("#"));
17158
- throw new Error(`repository ${repository} is not mapped in repository settings and no DISPATCH_DEFAULT_PROJECT is configured`);
17121
+ if (error48 instanceof DispatchServiceError && error48.status === 404) {
17122
+ throw new Error(`no Dispatch issue is linked to ${issueReference}; create it first with ` + `dispatch_issue({ external: "${issueReference}", ... })`);
17159
17123
  }
17160
17124
  throw error48;
17161
17125
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/opencode-legion-envoy",
3
- "version": "3.2.5",
3
+ "version": "3.2.7",
4
4
  "type": "module",
5
5
  "main": "dist/src/server.js",
6
6
  "exports": {
@@ -147,8 +147,9 @@ See [Typed blocks](#typed-blocks) for the syntax and [Before you ask](#before-yo
147
147
  Every session works on an issue or project document. Legion pre-fills `issue` from `LEGION_ISSUE`: use a native issue key such as
148
148
  `LEGION-3`, an external `owner/repo#n` reference, or a bare positive number (resolved against the cwd repository). Otherwise pass
149
149
  exactly one owner to every owner-scoped tool: `issue` for an issue, or `project` and `artifact` for an unlinked project document (see
150
- [References](#references) for the resulting ref shape). On first use, an external issue reference creates its native issue in the
151
- project configured for that repository in Dispatch Settings, then falls back to `DISPATCH_DEFAULT_PROJECT`.
150
+ [References](#references) for the resulting ref shape). An external issue reference addresses the existing Dispatch issue linked to
151
+ that GitHub issue or pull request. Only `dispatch_issue` with `external` creates a native issue; if no issue is linked, call
152
+ `dispatch_issue({ external: "owner/repo#n", project: "<project>", title: "<title>" })` before addressing it.
152
153
 
153
154
  Issue reads include `rank`, the server-owned ordering key used by project boards; reorder through `PATCH /api/v1/issues/{key}` with neighboring issue keys. They also include nullable coarse priority (`P0` highest through `P3` lowest) and `assignee`: the lowercase GitHub login of the human who answers the issue's asks, or `null` when nobody holds it. `dispatch_read` of an issue prints it as `Assignee: <login>` or `Assignee: unassigned`.
154
155