@sjawhar/opencode-legion-envoy 1.0.0 → 1.1.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.
@@ -14311,7 +14311,7 @@ function normalizeEnvoyUrl(value) {
14311
14311
  }
14312
14312
 
14313
14313
  // ../envoy-client/src/dispatch-config.ts
14314
- import { readFileSync } from "fs";
14314
+ import { readFileSync as readFileSync2 } from "fs";
14315
14315
  import { homedir } from "os";
14316
14316
  import * as path from "path";
14317
14317
 
@@ -14320,6 +14320,21 @@ function messageFor(error) {
14320
14320
  return error instanceof Error ? error.message : String(error);
14321
14321
  }
14322
14322
 
14323
+ // ../envoy-client/src/secret-file.ts
14324
+ import { readFileSync } from "fs";
14325
+ function readSecretFile(variable, filePath) {
14326
+ let contents;
14327
+ try {
14328
+ contents = readFileSync(filePath, "utf8");
14329
+ } catch (error) {
14330
+ throw new Error(`${variable} names ${filePath}, which could not be read: ${messageFor(error)}`);
14331
+ }
14332
+ const value = contents.trim();
14333
+ if (value.length === 0)
14334
+ throw new Error(`${variable} names ${filePath}, which is empty`);
14335
+ return value;
14336
+ }
14337
+
14323
14338
  // ../envoy-client/src/dispatch-config.ts
14324
14339
  var DEFAULT_SERVER_URL = "http://localhost:8766";
14325
14340
  function normalizeDispatchUrl(url2) {
@@ -14356,7 +14371,7 @@ function describeSchemaIssue(filePath, error) {
14356
14371
  function readEnvoyFile(filePath) {
14357
14372
  let raw;
14358
14373
  try {
14359
- raw = readFileSync(filePath, "utf-8");
14374
+ raw = readFileSync2(filePath, "utf-8");
14360
14375
  } catch {
14361
14376
  return { kind: "absent" };
14362
14377
  }
@@ -14389,8 +14404,22 @@ function resolveDispatchConfig(env, options = {}) {
14389
14404
  };
14390
14405
  const rawUrl = explicitUrl !== undefined ? { value: explicitUrl, source: "DISPATCH_URL" } : merged.enabled === true ? { value: merged.serverUrl ?? DEFAULT_SERVER_URL, source: "dispatch.serverUrl" } : null;
14391
14406
  const url2 = rawUrl ? parsedDispatchUrl(rawUrl.value, rawUrl.source) : { url: null, error: null };
14392
- const token = env.DISPATCH_TOKEN ?? merged.token ?? null;
14393
- const tokenSource = env.DISPATCH_TOKEN === undefined ? "dispatch.token" : "DISPATCH_TOKEN";
14407
+ let token;
14408
+ let tokenSource;
14409
+ if (env.DISPATCH_TOKEN_FILE !== undefined) {
14410
+ tokenSource = "DISPATCH_TOKEN_FILE";
14411
+ try {
14412
+ token = readSecretFile(tokenSource, env.DISPATCH_TOKEN_FILE);
14413
+ } catch (error) {
14414
+ return { enabled: false, url: url2.url, token: null, error: messageFor(error) };
14415
+ }
14416
+ } else if (env.DISPATCH_TOKEN !== undefined) {
14417
+ tokenSource = "DISPATCH_TOKEN";
14418
+ token = env.DISPATCH_TOKEN;
14419
+ } else {
14420
+ tokenSource = "dispatch.token";
14421
+ token = merged.token ?? null;
14422
+ }
14394
14423
  if (url2.error !== null)
14395
14424
  return { enabled: false, url: null, token, error: url2.error };
14396
14425
  if (url2.url === null)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/opencode-legion-envoy",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/src/server.js",
6
6
  "exports": {
@@ -18,8 +18,9 @@ until that PR merges, this skill's contract is not yet runnable on `main`.
18
18
  The Legion extension claims `legion-<project>-controller` and registers controller readiness
19
19
  with the daemon during session startup. Do not handle a wake unless that startup succeeded.
20
20
 
21
- For an interactive takeover, start OMP with `LEGION_CONTROLLER_SECRET` and
22
- `LEGION_DAEMON_URL` in its environment, then run:
21
+ For an interactive takeover, start OMP with `LEGION_CONTROLLER_SECRET` (or
22
+ `LEGION_CONTROLLER_SECRET_FILE`, a path to a file holding it) and `LEGION_DAEMON_URL` in its
23
+ environment, then run:
23
24
 
24
25
  ```text
25
26
  /legion-claim-controller
@@ -19,8 +19,9 @@ until that PR merges, this skill's contract is not yet runnable on `main`.
19
19
 
20
20
  The daemon spawns you as a separate `omp --mode rpc` process (behind `legion worker-shim`,
21
21
  in a tmux pane) with `LEGION_TREE`, `LEGION_ISSUE`, `LEGION_ROLE`, `LEGION_GENERATION`,
22
- `LEGION_BOOT_TOKEN`, `LEGION_DAEMON_URL`, `LEGION_STATE_DIR`, and `LEGION_WORKSPACE` in your
23
- environment (`LEGION_PROJECT` is also supplied, but nothing reads it). The extension
22
+ `LEGION_BOOT_TOKEN_FILE` (a 0600 file under `$LEGION_STATE_DIR/secrets` holding your boot token;
23
+ the extension reads it for you), `LEGION_DAEMON_URL`, `LEGION_STATE_DIR`, and `LEGION_WORKSPACE`
24
+ in your environment (`LEGION_PROJECT` is also supplied, but nothing reads it). The extension
24
25
  completes the boot handshake for you at session start — it registers with the daemon, claims
25
26
  your role, and signals readiness. You never call `envoy_role_set` yourself.
26
27