@sjawhar/pi-legion-envoy 5.5.3 → 5.5.5

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/envoy.js CHANGED
@@ -29960,7 +29960,7 @@ function dispatchToolSchema(spec, z2, opts) {
29960
29960
  const schemaOptions = strict === undefined ? undefined : { strict };
29961
29961
  return spec.validation === undefined ? z2.object(shape, schemaOptions) : z2.refineObject(shape, spec.validation.check, spec.validation.message, schemaOptions);
29962
29962
  }
29963
- 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).";
29963
+ 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.";
29964
29964
  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.";
29965
29965
  function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false) {
29966
29966
  return {
@@ -32265,7 +32265,6 @@ class DispatchClient {
32265
32265
  fetchImpl;
32266
32266
  #baseUrl;
32267
32267
  #resolvedIssues = new Map;
32268
- #creatingIssues = new Map;
32269
32268
  #signal;
32270
32269
  constructor(baseUrl, token, fetchImpl = fetch, signal) {
32271
32270
  this.token = token;
@@ -32276,6 +32275,9 @@ class DispatchClient {
32276
32275
  async issue(input) {
32277
32276
  return this.#json("POST", ["api", "v1", "issues"], input);
32278
32277
  }
32278
+ async resolveIssue(issueReference) {
32279
+ return this.#resolveIssue(issueReference);
32280
+ }
32279
32281
  async listIssues(options = {}) {
32280
32282
  return this.#json("GET", ["api", "v1", "issues"], undefined, options);
32281
32283
  }
@@ -32471,43 +32473,6 @@ class DispatchClient {
32471
32473
  ...query.since === undefined ? {} : { since: query.since }
32472
32474
  });
32473
32475
  }
32474
- async ensureIssue(issueReference, actor) {
32475
- if (!issueReference.includes("#"))
32476
- return issueReference;
32477
- try {
32478
- return await this.#resolveIssue(issueReference);
32479
- } catch (error48) {
32480
- if (!(error48 instanceof DispatchServiceError) || error48.status !== 404)
32481
- throw error48;
32482
- }
32483
- let creating = this.#creatingIssues.get(issueReference);
32484
- if (!creating) {
32485
- creating = this.#createExternalIssue(issueReference, actor);
32486
- this.#creatingIssues.set(issueReference, creating);
32487
- }
32488
- try {
32489
- return await creating;
32490
- } finally {
32491
- if (this.#creatingIssues.get(issueReference) === creating) {
32492
- this.#creatingIssues.delete(issueReference);
32493
- }
32494
- }
32495
- }
32496
- async#createExternalIssue(issueReference, actor) {
32497
- try {
32498
- const created = await this.#json("POST", ["api", "v1", "issues"], {
32499
- external: issueReference,
32500
- actor
32501
- });
32502
- this.#resolvedIssues.set(issueReference, Promise.resolve(created.key));
32503
- return created.key;
32504
- } catch (error48) {
32505
- if (error48 instanceof DispatchServiceError && (error48.status === 409 || error48.status === 500)) {
32506
- return this.#resolveIssue(issueReference);
32507
- }
32508
- throw error48;
32509
- }
32510
- }
32511
32476
  async#resolveIssue(issueReference) {
32512
32477
  if (!issueReference.includes("#"))
32513
32478
  return issueReference;
@@ -33685,7 +33650,7 @@ async function executeDispatchTool(input) {
33685
33650
  const client = dispatchClient();
33686
33651
  const owner = ownerArguments.owner?.kind === "issue" ? {
33687
33652
  kind: "issue",
33688
- issue: await ensureIssue(client, ownerArguments.owner.issue, actor)
33653
+ issue: await resolveExistingIssue(client, ownerArguments.owner.issue)
33689
33654
  } : ownerArguments.owner;
33690
33655
  const issue2 = () => {
33691
33656
  if (owner?.kind !== "issue")
@@ -34337,13 +34302,12 @@ ${trailer.join(`
34337
34302
  throw new Error(`Unknown Dispatch tool: ${input.tool}`);
34338
34303
  }
34339
34304
  }
34340
- async function ensureIssue(client, issueReference, actor) {
34305
+ async function resolveExistingIssue(client, issueReference) {
34341
34306
  try {
34342
- return await client.ensureIssue(issueReference, actor);
34307
+ return await client.resolveIssue(issueReference);
34343
34308
  } catch (error48) {
34344
- if (error48 instanceof DispatchServiceError && error48.code === "PROJECT_UNMAPPED") {
34345
- const repository = issueReference.slice(0, issueReference.lastIndexOf("#"));
34346
- throw new Error(`repository ${repository} is not mapped in repository settings and no DISPATCH_DEFAULT_PROJECT is configured`);
34309
+ if (error48 instanceof DispatchServiceError && error48.status === 404) {
34310
+ throw new Error(`no Dispatch issue is linked to ${issueReference}; create it first with ` + `dispatch_issue({ external: "${issueReference}", ... })`);
34347
34311
  }
34348
34312
  throw error48;
34349
34313
  }
package/dist/legion.js CHANGED
@@ -16142,7 +16142,7 @@ import { logger } from "@oh-my-pi/pi-utils";
16142
16142
  // package.json
16143
16143
  var package_default = {
16144
16144
  name: "@sjawhar/pi-legion-envoy",
16145
- version: "5.5.3",
16145
+ version: "5.5.5",
16146
16146
  type: "module",
16147
16147
  omp: {
16148
16148
  extensions: [
@@ -30033,7 +30033,7 @@ function dispatchToolSchema(spec, z2, opts) {
30033
30033
  const schemaOptions = strict === undefined ? undefined : { strict };
30034
30034
  return spec.validation === undefined ? z2.object(shape, schemaOptions) : z2.refineObject(shape, spec.validation.check, spec.validation.message, schemaOptions);
30035
30035
  }
30036
- 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).";
30036
+ 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.";
30037
30037
  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.";
30038
30038
  function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false) {
30039
30039
  return {
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion-envoy",
3
- "version": "5.5.3",
3
+ "version": "5.5.5",
4
4
  "type": "module",
5
5
  "omp": {
6
6
  "extensions": [