@sjawhar/pi-legion 19.7.1 → 19.9.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.
Files changed (2) hide show
  1. package/dist/legion.js +105 -113
  2. package/package.json +1 -1
package/dist/legion.js CHANGED
@@ -16649,6 +16649,7 @@ function isPictureType(mime) {
16649
16649
  }
16650
16650
 
16651
16651
  // ../contracts/src/subject.ts
16652
+ var AGENT_TOPIC_PREFIX = "notifications.agent.";
16652
16653
  var ROLE_TOPIC_PREFIX = "notifications.role.";
16653
16654
  var LEGION_NOTICE_TOPIC_PREFIX = "notifications.legion.";
16654
16655
  function legionControllerNoticeSubject(project) {
@@ -16663,6 +16664,7 @@ function dispatchIssueSubject(issueKey, type) {
16663
16664
  function dispatchDocumentSubject(project, slug, type) {
16664
16665
  return `${DISPATCH_DOCUMENT_TOPIC_PREFIX}${project}.${slug}.${type}`;
16665
16666
  }
16667
+ var GHOSTWISPR_TOPIC_PREFIX = "notifications.ghostwispr.";
16666
16668
 
16667
16669
  // ../contracts/src/legion-roles.ts
16668
16670
  var LEGION_ROLES = [
@@ -16968,6 +16970,8 @@ var ArtifactCreatedEventPayloadSchema = object({
16968
16970
  name: artifactFields.name.optional()
16969
16971
  }).optional()
16970
16972
  });
16973
+ var ArtifactRenamedEventPayloadSchema = strictObject({ artifact: ArtifactSchema, previous_name: string2() }).readonly();
16974
+ var ArtifactRemovedEventPayloadSchema = strictObject({ artifact: ArtifactSchema }).readonly();
16971
16975
  var artifactVersionEventPayloadFields = {
16972
16976
  artifact_id: string2(),
16973
16977
  name: string2(),
@@ -17063,15 +17067,16 @@ function documentOwnerValidation(requireArtifact, alwaysRequireArtifact = false)
17063
17067
  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."
17064
17068
  };
17065
17069
  }
17066
- var ARTIFACT_SOURCE_RULE = "Exactly one of path or content is required.";
17070
+ 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.";
17067
17071
  var ARTIFACT_OWNER_AND_SOURCE_RULE = `${ARTIFACT_SOURCE_RULE} Exactly one of issue and project is required; with project, artifact names the document.`;
17068
17072
  function brokenParts(parts) {
17069
17073
  const broken = parts.filter(([kept]) => !kept).map(([, message]) => message);
17070
17074
  return broken.length === 0 ? undefined : broken.join(" ");
17071
17075
  }
17072
17076
  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)";
17077
+ var DOCUMENT_IS_MARKDOWN = "a document holds Markdown, which rewrites other text (a JSONL file's lines come back joined into one paragraph)";
17073
17078
  var PATH_KEEPS_BYTES = "path (--path <file>), which stores a file whose path does not end in .md or .markdown as its bytes, unchanged";
17074
- 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}.`;
17079
+ 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}.`;
17075
17080
  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.";
17076
17081
  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}.`;
17077
17082
  var NAME_EXTENSION = /\.([^\s.]+)$/u;
@@ -17085,19 +17090,16 @@ function artifactProblem(value) {
17085
17090
  const input = value;
17086
17091
  const ownerOrSourceProblem = brokenParts([
17087
17092
  [artifactOwner.check(value), artifactOwner.message],
17088
- [
17089
- typeof input.path === "string" !== (typeof input.content === "string"),
17090
- ARTIFACT_SOURCE_RULE
17091
- ]
17093
+ [typeof input.path !== "string" || typeof input.content !== "string", ARTIFACT_SOURCE_RULE]
17092
17094
  ]);
17093
17095
  if (ownerOrSourceProblem !== undefined)
17094
17096
  return ownerOrSourceProblem;
17095
- if (typeof input.content !== "string" || typeof input.name !== "string")
17097
+ if (typeof input.path === "string" || typeof input.name !== "string")
17096
17098
  return;
17097
17099
  const extension = NAME_EXTENSION.exec(input.name.trim())?.[1];
17098
17100
  if (extension === undefined || MARKDOWN_EXTENSION.test(extension))
17099
17101
  return;
17100
- 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.`;
17102
+ 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.`;
17101
17103
  }
17102
17104
  var documentEditOwner = documentOwnerValidation(true);
17103
17105
  var PRECONDITION_RULE = "A precondition selects exactly one of document or blocks.";
@@ -17648,7 +17650,7 @@ var dispatchToolSpecs = [
17648
17650
  name: "dispatch_artifact",
17649
17651
  example: { issue: "DSP-1", name: "design.md", content: `# Design
17650
17652
  ` },
17651
- 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}`,
17653
+ 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}`,
17652
17654
  arguments: (z) => ({
17653
17655
  issue: z.string().describe(ISSUE_REFERENCE).optional(),
17654
17656
  project: z.string().describe("Project key for an unlinked document.").optional(),
@@ -20834,8 +20836,9 @@ class DispatchClient {
20834
20836
  return { status: response.status, payload: await this.#response(method, url, response) };
20835
20837
  }
20836
20838
  async#upload(path, input, key) {
20837
- if ("content" in input)
20839
+ if (input.file === undefined) {
20838
20840
  return this.#json("POST", path, input, undefined, undefined, key);
20841
+ }
20839
20842
  const form = new FormData;
20840
20843
  form.set("name", input.name);
20841
20844
  if (input.summary !== undefined)
@@ -23476,13 +23479,17 @@ function withoutFinalLineFeed(text) {
23476
23479
  return text.endsWith(`
23477
23480
  `) ? text.slice(0, -1) : text;
23478
23481
  }
23482
+ var goBlankPattern = /^[\t\n\v\f\r \u0085\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]*$/u;
23479
23483
  async function artifactCommand(context) {
23480
23484
  const { args, client, actor, input, documentOwner, issue } = context;
23481
23485
  const summary = optionalString(args, "summary");
23482
23486
  const name = stringArg(args, "name");
23483
23487
  const content = optionalString(args, "content");
23488
+ const path = optionalString(args, "path");
23489
+ const options = { name, ...summary === undefined ? {} : { summary }, actor };
23484
23490
  const artifactOwner = documentOwner();
23485
- if (optionalBoolean(args, "force") !== true) {
23491
+ const blank = content === undefined || goBlankPattern.test(content);
23492
+ if ((path !== undefined || !blank) && optionalBoolean(args, "force") !== true) {
23486
23493
  const held = artifactUnderName(artifactOwner.kind === "project" ? await client.listProjectArtifacts(artifactOwner.project, true) : await client.listIssueArtifacts(issue()), name);
23487
23494
  if (held !== undefined) {
23488
23495
  throw new ToolInputError(input.tool, [
@@ -23490,7 +23497,7 @@ async function artifactCommand(context) {
23490
23497
  ]);
23491
23498
  }
23492
23499
  }
23493
- if (content !== undefined) {
23500
+ if (!blank) {
23494
23501
  let stored;
23495
23502
  try {
23496
23503
  stored = await client.markdownRoundTrip(content);
@@ -23503,19 +23510,12 @@ async function artifactCommand(context) {
23503
23510
  throw new ToolInputError(input.tool, [storedTextProblem(content, stored, name)]);
23504
23511
  }
23505
23512
  }
23506
- const artifactInput = content === undefined ? {
23507
- name,
23508
- file: input.uploadBytes === undefined ? Bun.file(resolvePath(input.cwd, stringArg(args, "path"))) : new Blob([new Uint8Array(input.uploadBytes)], {
23509
- type: Bun.file(resolvePath(input.cwd, stringArg(args, "path"))).type
23510
- }),
23511
- ...summary === undefined ? {} : { summary },
23512
- actor
23513
- } : {
23514
- name,
23515
- content,
23516
- ...summary === undefined ? {} : { summary },
23517
- actor
23518
- };
23513
+ const artifactInput = path !== undefined ? {
23514
+ ...options,
23515
+ file: input.uploadBytes === undefined ? Bun.file(resolvePath(input.cwd, path)) : new Blob([new Uint8Array(input.uploadBytes)], {
23516
+ type: Bun.file(resolvePath(input.cwd, path)).type
23517
+ })
23518
+ } : content !== undefined ? { ...options, content } : options;
23519
23519
  const result = artifactOwner.kind === "project" ? await client.projectArtifact(artifactOwner.project, artifactInput) : await client.artifact(issue(), artifactInput);
23520
23520
  const artifactRef = dispatchDocumentRef(artifactOwner.kind === "project" ? artifactOwner.project : issue(), result.artifact.slug);
23521
23521
  const uploadOwner = artifactOwner.kind === "project" ? documentTopic(result.artifact) : issueTopic(issue());
@@ -23524,7 +23524,7 @@ async function artifactCommand(context) {
23524
23524
  });
23525
23525
  return {
23526
23526
  text: [
23527
- `Uploaded ${result.artifact.name} as version ${result.version.number} (artifact slug ${result.artifact.slug}; ${artifactRef})${await notSubscribed(uploadOwner, input.subscriptions)}`,
23527
+ 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)}`,
23528
23528
  ...adviceLines
23529
23529
  ].join(`
23530
23530
  `),
@@ -25181,8 +25181,34 @@ function sessionEnvoySettings(file, env, options) {
25181
25181
  });
25182
25182
  }
25183
25183
 
25184
+ // ../envoy-client/src/stream-topics.ts
25185
+ var EXCEPTION_TOPIC_PREFIX = "notifications.envoy.exceptions.";
25186
+ var STREAM_SUBJECT_PREFIXES = [
25187
+ AGENT_TOPIC_PREFIX,
25188
+ DISPATCH_TOPIC_PREFIX,
25189
+ "notifications.github.",
25190
+ "notifications.slack.",
25191
+ LEGION_NOTICE_TOPIC_PREFIX,
25192
+ GHOSTWISPR_TOPIC_PREFIX,
25193
+ "notifications.whatsapp.",
25194
+ "notifications.team.",
25195
+ `${EXCEPTION_TOPIC_PREFIX}${AGENT_TOPIC_PREFIX}`,
25196
+ `${EXCEPTION_TOPIC_PREFIX}notifications.team.`
25197
+ ];
25198
+ function streamStores(topic) {
25199
+ return STREAM_SUBJECT_PREFIXES.some((prefix) => topic.length > prefix.length && topic.startsWith(prefix));
25200
+ }
25201
+ function streamDeliversNothing(topic) {
25202
+ return topic.startsWith("notifications.") && !topic.startsWith(ROLE_TOPIC_PREFIX) && !streamStores(topic);
25203
+ }
25204
+ var PRIVATE_STREAM_SUBJECTS = [
25205
+ `${AGENT_TOPIC_PREFIX}>`,
25206
+ `${LEGION_NOTICE_TOPIC_PREFIX}>`,
25207
+ `${EXCEPTION_TOPIC_PREFIX}${AGENT_TOPIC_PREFIX}>`,
25208
+ `${EXCEPTION_TOPIC_PREFIX}notifications.team.>`
25209
+ ];
25210
+
25184
25211
  // ../envoy-client/src/transport.ts
25185
- var REPLAY_TIMEOUT_MS = 1e4;
25186
25212
  var SessionStateSchema = _enum2(["live", "unresponsive", "gone"]);
25187
25213
  var UNRESPONSIVE_RULE = "An unresponsive session is not dead: it keeps its role claims and its issue claims, and a " + "message sent to it is stored until it answers. Start no replacement for it and take no claim " + `from it until it is gone, or until ${ISSUE_CLAIM_UNRESPONSIVE_GRACE_MS / 60000} minutes ` + "have passed since its last_seen, the time of its last registration.";
25188
25214
  var WireStateSchema = SessionStateSchema.default("live");
@@ -25194,16 +25220,13 @@ var InterestWireSchema = object({
25194
25220
  updated_at: number2().int().optional(),
25195
25221
  warnings: array(string2()).optional()
25196
25222
  });
25197
- var DeliveryAnswerWireSchema = discriminatedUnion("mode", [
25198
- object({
25199
- mode: literal("consumer"),
25200
- subject: string2().min(1),
25201
- stream_id: string2(),
25202
- gap: boolean2(),
25203
- consumer_start: number2().int().nonnegative().optional()
25204
- }),
25205
- object({ mode: literal("core"), reason: string2() })
25206
- ]);
25223
+ var DeliveryAnswerWireSchema = object({
25224
+ mode: literal("consumer"),
25225
+ subject: string2().min(1),
25226
+ stream_id: string2(),
25227
+ gap: boolean2(),
25228
+ consumer_start: number2().int().nonnegative().optional()
25229
+ });
25207
25230
  var SessionWireSchema = object({
25208
25231
  session_id: string2(),
25209
25232
  machine_id: string2(),
@@ -25218,7 +25241,8 @@ var SessionWireSchema = object({
25218
25241
  last_seen: number2().int().optional(),
25219
25242
  state: WireStateSchema,
25220
25243
  plugin: string2().optional(),
25221
- plugin_version: string2().optional()
25244
+ plugin_version: string2().optional(),
25245
+ delivery: string2().optional()
25222
25246
  });
25223
25247
  var RoleWireSchema = object({
25224
25248
  role: string2(),
@@ -25238,13 +25262,13 @@ var RoleHeldWireSchema = object({
25238
25262
  var ErrorWireSchema = object({
25239
25263
  error: string2(),
25240
25264
  code: string2().optional(),
25265
+ reason: string2().optional(),
25241
25266
  expected: array(string2()).optional(),
25242
25267
  state: SessionStateSchema.optional(),
25243
25268
  holder: string2().optional(),
25244
25269
  holder_state: SessionStateSchema.optional(),
25245
25270
  last_seen: number2().int().optional(),
25246
- claim_released: boolean2().optional(),
25247
- unresponsive: array(string2()).optional()
25271
+ claim_released: boolean2().optional()
25248
25272
  });
25249
25273
  var EnvelopeResponseSchema = EnvelopeSchema.extend({
25250
25274
  recipient: string2().optional(),
@@ -25252,46 +25276,30 @@ var EnvelopeResponseSchema = EnvelopeSchema.extend({
25252
25276
  holder_state: SessionStateSchema.optional(),
25253
25277
  recipient_state: SessionStateSchema.optional(),
25254
25278
  last_seen: number2().int().optional(),
25255
- unresponsive: array(string2()).optional(),
25256
25279
  duplicate: boolean2().optional()
25257
25280
  });
25258
25281
  var PublishResponseSchema = EnvelopeResponseSchema.extend({
25259
25282
  kept: boolean2().optional(),
25260
25283
  kept_reason: _enum2(["unclaimed", "holder_lapsed"]).optional()
25261
25284
  });
25262
- var ReplayWireSchema = object({
25263
- stream: object({
25264
- id: string2().min(1).optional(),
25265
- created: string2(),
25266
- first_seq: number2().int().nonnegative(),
25267
- last_seq: number2().int().nonnegative()
25268
- }),
25269
- subjects: array(object({
25270
- subject: string2(),
25271
- messages: array(object({
25272
- seq: number2().int().positive(),
25273
- subject: string2(),
25274
- time: string2(),
25275
- data: string2()
25276
- })),
25277
- next_after: number2().int().nonnegative(),
25278
- more: boolean2(),
25279
- refused: string2().optional()
25280
- }))
25281
- });
25282
- var DELIVERY_NOT_ANSWERED = "not_answered";
25283
- var DELIVERY_UNREADABLE = "unreadable_answer";
25285
+ var DeliveryRefusalSchema = object({
25286
+ mode: string2(),
25287
+ reason: string2().optional()
25288
+ });
25289
+ var DELIVERY_UNREADABLE = "answered a delivery field this build cannot read";
25284
25290
  function parseSubscribeAnswer(body) {
25285
25291
  const interest = InterestWireSchema.parse(body);
25286
25292
  const raw = typeof body === "object" && body !== null && "delivery" in body ? body.delivery : undefined;
25287
25293
  if (raw === undefined || raw === null) {
25288
- return { ...interest, delivery: { mode: "core", reason: DELIVERY_NOT_ANSWERED } };
25294
+ throw new Error(`the listener answered no delivery for ${interest.session_id}: it predates session consumers, and a session receives only what its own consumer holds`);
25289
25295
  }
25290
25296
  const delivery = DeliveryAnswerWireSchema.safeParse(raw);
25291
- return {
25292
- ...interest,
25293
- delivery: delivery.success ? delivery.data : { mode: "core", reason: DELIVERY_UNREADABLE }
25294
- };
25297
+ if (!delivery.success) {
25298
+ const named = DeliveryRefusalSchema.safeParse(raw);
25299
+ const said = named.success ? `answered delivery mode ${named.data.mode}${named.data.reason === undefined ? "" : ` (${named.data.reason})`}` : DELIVERY_UNREADABLE;
25300
+ throw new Error(`the listener gave ${interest.session_id} no consumer: it ${said}, and a session receives only what its own consumer holds`);
25301
+ }
25302
+ return { ...interest, delivery: delivery.data };
25295
25303
  }
25296
25304
  function expandSubscriptionTopics(topics) {
25297
25305
  const expanded = new Set;
@@ -25305,27 +25313,20 @@ function expandSubscriptionTopics(topics) {
25305
25313
  if (segments.length < 2 || segments.some((segment) => segment.length === 0)) {
25306
25314
  throw new TypeError(`cannot expand Envoy wildcard topic "${topic}": its concrete base must have at least two non-empty segments`);
25307
25315
  }
25308
- expanded.add(base);
25316
+ if (!streamDeliversNothing(base))
25317
+ expanded.add(base);
25309
25318
  expanded.add(topic);
25310
25319
  }
25311
25320
  return [...expanded];
25312
25321
  }
25313
25322
  function refusalStateText(parsed) {
25314
- const sentences = [];
25315
25323
  const state = parsed.holder_state ?? parsed.state;
25316
- if (state !== undefined) {
25317
- const who = parsed.holder === undefined ? "That session" : `Holder ${parsed.holder}`;
25318
- const seen = parsed.last_seen === undefined || parsed.last_seen <= 0 ? "" : `, last seen ${new Date(parsed.last_seen).toISOString()}`;
25319
- sentences.push(`${who} is ${state}${seen}.`);
25320
- }
25321
- const stored = parsed.unresponsive ?? [];
25322
- if (stored.length > 0) {
25323
- const one = stored.length === 1;
25324
- sentences.push(`Envoy stored the message for ${stored.join(", ")}.`, `${one ? "That session" : "Those sessions"} stopped answering, so ${one ? "it" : "they"} did not fail this send.`);
25325
- }
25326
- if (sentences.length === 0)
25324
+ if (state === undefined)
25327
25325
  return "";
25328
- if (state === "unresponsive" || stored.length > 0)
25326
+ const who = parsed.holder === undefined ? "That session" : `Holder ${parsed.holder}`;
25327
+ const seen = parsed.last_seen === undefined || parsed.last_seen <= 0 ? "" : `, last seen ${new Date(parsed.last_seen).toISOString()}`;
25328
+ const sentences = [`${who} is ${state}${seen}.`];
25329
+ if (state === "unresponsive")
25329
25330
  sentences.push(UNRESPONSIVE_RULE);
25330
25331
  return ` ${sentences.join(" ")}`;
25331
25332
  }
@@ -25335,11 +25336,11 @@ class EnvoyApiError extends Error {
25335
25336
  name = "EnvoyApiError";
25336
25337
  expected;
25337
25338
  code;
25339
+ reason;
25338
25340
  holder;
25339
25341
  sessionState;
25340
25342
  lastSeen;
25341
25343
  claimReleased;
25342
- unresponsive;
25343
25344
  constructor(details) {
25344
25345
  let parsed;
25345
25346
  try {
@@ -25347,15 +25348,15 @@ class EnvoyApiError extends Error {
25347
25348
  if (result.success)
25348
25349
  parsed = result.data;
25349
25350
  } catch {}
25350
- super(parsed === undefined ? `${details.method} ${details.url} failed with ${details.status}: ${details.responseBody}` : `${parsed.error}${parsed.expected === undefined ? "" : ` (expected: ${parsed.expected.join(", ")})`}${refusalStateText(parsed)}`);
25351
+ super(parsed === undefined ? `${details.method} ${details.url} failed with ${details.status}: ${details.responseBody}` : `${parsed.error}${parsed.reason === undefined ? "" : ` (reason: ${parsed.reason})`}${parsed.expected === undefined ? "" : ` (expected: ${parsed.expected.join(", ")})`}${refusalStateText(parsed)}`);
25351
25352
  this.details = details;
25352
25353
  this.expected = parsed?.expected;
25353
25354
  this.code = parsed?.code;
25355
+ this.reason = parsed?.reason;
25354
25356
  this.holder = parsed?.holder;
25355
25357
  this.sessionState = parsed?.holder_state ?? parsed?.state;
25356
25358
  this.lastSeen = parsed?.last_seen;
25357
25359
  this.claimReleased = parsed?.claim_released;
25358
- this.unresponsive = parsed?.unresponsive;
25359
25360
  }
25360
25361
  }
25361
25362
  var mintedDedupeKey2 = new RegExp(MINTED_DEDUPE_KEY_PATTERN);
@@ -25465,23 +25466,24 @@ function createEnvoyClient(config) {
25465
25466
  headers: { "Content-Type": "application/json" },
25466
25467
  body: JSON.stringify(body)
25467
25468
  }, options);
25469
+ const subscribeBody = (input) => ({
25470
+ session_id: input.sessionID,
25471
+ dir: input.directory,
25472
+ topics: expandSubscriptionTopics(input.topics),
25473
+ port: input.port,
25474
+ title: input.title,
25475
+ ...input.capabilities === undefined ? {} : { capabilities: input.capabilities },
25476
+ driving: input.driving,
25477
+ ...input.selfSubscribed === undefined ? {} : { self_subscribed: input.selfSubscribed },
25478
+ delivery: input.delivery,
25479
+ ...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID },
25480
+ host: machineID(),
25481
+ ...input.place === undefined ? {} : { tmux_place: input.place },
25482
+ plugin: input.plugin.name,
25483
+ plugin_version: input.plugin.version
25484
+ });
25468
25485
  return {
25469
- subscribe: async (input) => parseSubscribeAnswer(JSON.parse(await post("/v1/interests/subscribe", {
25470
- session_id: input.sessionID,
25471
- dir: input.directory,
25472
- topics: expandSubscriptionTopics(input.topics),
25473
- port: input.port,
25474
- title: input.title,
25475
- ...input.capabilities === undefined ? {} : { capabilities: input.capabilities },
25476
- driving: input.driving,
25477
- ...input.selfSubscribed === undefined ? {} : { self_subscribed: input.selfSubscribed },
25478
- ...input.delivery === undefined ? {} : { delivery: input.delivery },
25479
- ...input.clientInstanceID === undefined ? {} : { client_instance_id: input.clientInstanceID },
25480
- host: machineID(),
25481
- ...input.place === undefined ? {} : { tmux_place: input.place },
25482
- plugin: input.plugin.name,
25483
- plugin_version: input.plugin.version
25484
- }, { actingSession: input.sessionID }))),
25486
+ subscribe: async (input) => parseSubscribeAnswer(JSON.parse(await post("/v1/interests/subscribe", subscribeBody(input), { actingSession: input.sessionID }))),
25485
25487
  unsubscribe: async (input) => {
25486
25488
  await post("/v1/interests/unsubscribe", {
25487
25489
  session_id: input.sessionID,
@@ -25540,7 +25542,6 @@ function createEnvoyClient(config) {
25540
25542
  envelope: response,
25541
25543
  ...response.holder === undefined ? {} : { holder: response.holder },
25542
25544
  ...response.holder_state === undefined ? {} : { holderState: response.holder_state },
25543
- unresponsive: response.unresponsive ?? [],
25544
25545
  ...response.kept === undefined ? {} : { kept: response.kept },
25545
25546
  ...response.kept_reason === undefined ? {} : { keptReason: response.kept_reason }
25546
25547
  };
@@ -25589,16 +25590,7 @@ function createEnvoyClient(config) {
25589
25590
  search.set("include", input.include);
25590
25591
  const query = search.size === 0 ? "" : `?${search.toString()}`;
25591
25592
  return SessionWireSchema.array().parse(JSON.parse(await request(`/v1/sessions${query}`, {})));
25592
- },
25593
- replay: async (input) => ReplayWireSchema.parse(JSON.parse(await post("/v1/replay", {
25594
- session_id: input.sessionID,
25595
- subjects: input.subjects.map((cursor) => cursor.after === undefined ? { subject: cursor.subject } : { subject: cursor.subject, after: cursor.after }),
25596
- ...input.maxMessages === undefined ? {} : { max_messages: input.maxMessages }
25597
- }, {
25598
- timeoutMs: input.timeoutMs ?? REPLAY_TIMEOUT_MS,
25599
- retry: false,
25600
- actingSession: input.sessionID
25601
- })))
25593
+ }
25602
25594
  };
25603
25595
  }
25604
25596
  function waitForRetry(delayMs) {
@@ -28484,7 +28476,7 @@ import { logger as logger3 } from "@oh-my-pi/pi-utils";
28484
28476
  // package.json
28485
28477
  var package_default = {
28486
28478
  name: "@sjawhar/pi-legion",
28487
- version: "19.7.1",
28479
+ version: "19.9.0",
28488
28480
  license: "Apache-2.0",
28489
28481
  type: "module",
28490
28482
  omp: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion",
3
- "version": "19.7.1",
3
+ "version": "19.9.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "omp": {