@byollm/server 0.1.0-alpha.99 → 0.1.1

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/index.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  routeEndpoint,
15
15
  secretsMatch,
16
16
  signatureFrom
17
- } from "./chunk-36Y77FUD.js";
17
+ } from "./chunk-ITQV34KA.js";
18
18
  import {
19
19
  NoRunnerAvailableError,
20
20
  PollingDelivery,
@@ -55,7 +55,7 @@ var RelayUnavailable = class extends Error {
55
55
  }
56
56
  };
57
57
  var EnqueueRefused = class extends Error {
58
- /** `purpose-not-declared` or `slot-unsatisfiable`. */
58
+ /** `purpose-not-declared`, `slot-unsatisfiable` or `slot-waiting`. */
59
59
  code;
60
60
  constructor(message, code) {
61
61
  super(message);
@@ -240,7 +240,14 @@ var CloudLane = class {
240
240
  // values stopped at the relay, which is right: a blind relay acts
241
241
  // on neither. Sealing them carries them past it untouched.
242
242
  backendClass: outcome.ran.backendClass,
243
- model: outcome.ran.model
243
+ model: outcome.ran.model,
244
+ /* B260. `ran` arrives sealed through the relay untouched, and this
245
+ rebuild took two of its fields and left the rest — so a
246
+ cloud-lane site could not tell a truncated answer from a whole
247
+ one. The relay reads none of this; it travels inside the
248
+ envelope. */
249
+ ...outcome.ran.stop === void 0 ? {} : { stop: outcome.ran.stop },
250
+ ...outcome.ran.stopReported === void 0 ? {} : { stopReported: outcome.ran.stopReported }
244
251
  }),
245
252
  now: this.#now()
246
253
  });
@@ -431,7 +438,7 @@ var ByollmApp = class {
431
438
  /**
432
439
  * Enqueue a job.
433
440
  *
434
- * `audience` defaults to `self` — the safe direction. Widening it means the
441
+ * `audience` defaults to `private` — the safe direction. Widening it means the
435
442
  * result comes back marked untrusted (see {@link ByollmApp.result}), and
436
443
  * the app is obliged to disclose that to whoever reads it.
437
444
  */
@@ -527,7 +534,7 @@ var ByollmApp = class {
527
534
  * A job's result with its provenance attached.
528
535
  *
529
536
  * Check `provenance.untrusted` before rendering. It is true for every
530
- * `named`/`public` job, because that text came from someone else's machine
537
+ * `team` job, because that text came from someone else's machine
531
538
  * and the app must not present it as its own AI's answer
532
539
  * ({@link MUSTS.PROVENANCE_NAMES_DEVICE}).
533
540
  */
@@ -564,7 +571,7 @@ var ByollmApp = class {
564
571
  const now = this.#now();
565
572
  const all = await this.#store.listRunners();
566
573
  const live = all.filter(
567
- (runner) => runner.revokedAt === null && !runner.paused && now - runner.lastHeartbeatAt <= this.#livenessMs
574
+ (runner) => runner.revokedAt === null && now - runner.lastHeartbeatAt <= this.#livenessMs
568
575
  );
569
576
  if (all.length === 0) {
570
577
  return { available: false, reason: "no-runner-paired", candidates: 0 };
@@ -690,7 +697,7 @@ function siteKeysFromEnv(variable = "BYOLLM_SITE_KEYS", env = process.env) {
690
697
  const raw = env[variable];
691
698
  if (raw === void 0 || raw === "") {
692
699
  throw new Error(
693
- `${variable} is not set. Generate a site identity once with \`npx @byollm/server keygen\` and set it as ${variable}. Do not generate keys at startup: every instance would get a different identity and daemons would pin one and be refused by another.`
700
+ `${variable} is not set. Generate a site identity once with \`npx --package @byollm/server keygen\` and set it as ${variable}. Do not generate keys at startup: every instance would get a different identity and daemons would pin one and be refused by another.`
694
701
  );
695
702
  }
696
703
  let parsed;
@@ -698,13 +705,13 @@ function siteKeysFromEnv(variable = "BYOLLM_SITE_KEYS", env = process.env) {
698
705
  parsed = JSON.parse(Buffer.from(raw, "base64").toString("utf8"));
699
706
  } catch {
700
707
  throw new Error(
701
- `${variable} is not base64-encoded JSON. It should be exactly what \`npx @byollm/server keygen\` printed.`
708
+ `${variable} is not base64-encoded JSON. It should be exactly what \`npx --package @byollm/server keygen\` printed.`
702
709
  );
703
710
  }
704
711
  const result = StoredKeys.safeParse(parsed);
705
712
  if (!result.success) {
706
713
  throw new Error(
707
- `${variable} does not contain a valid site identity. Regenerate it with \`npx @byollm/server keygen\` \u2014 and if this site has already paired daemons, they will need to pair again.`
714
+ `${variable} does not contain a valid site identity. Regenerate it with \`npx --package @byollm/server keygen\` \u2014 and if this site has already paired daemons, they will need to pair again.`
708
715
  );
709
716
  }
710
717
  return result.data;
@@ -1042,7 +1049,8 @@ var MemoryStore = class {
1042
1049
  #expireDueSync(now) {
1043
1050
  const changed = [];
1044
1051
  for (const job of this.#jobs.values()) {
1045
- if ((job.state === "claimed" || job.state === "running") && job.lease !== null && job.lease.expiresAt <= now) {
1052
+ const adopted = job.lease !== null && job.lease.runnerId === "";
1053
+ if ((job.state === "claimed" || job.state === "running") && job.lease !== null && !adopted && job.lease.expiresAt <= now) {
1046
1054
  const requeued = {
1047
1055
  ...job,
1048
1056
  state: "queued",
@@ -1061,6 +1069,20 @@ var MemoryStore = class {
1061
1069
  changed.push(requeued);
1062
1070
  }
1063
1071
  }
1072
+ for (const job of this.#jobs.values()) {
1073
+ if (job.state !== "claimed" && job.state !== "running") continue;
1074
+ if (job.lease?.runnerId !== "") continue;
1075
+ if (deadlineFor(job, now) > now) continue;
1076
+ const expired = {
1077
+ ...job,
1078
+ state: "expired",
1079
+ lease: null,
1080
+ completedByLeaseId: null,
1081
+ updatedAt: now
1082
+ };
1083
+ this.#write(job.id, expired);
1084
+ changed.push(expired);
1085
+ }
1064
1086
  for (const job of this.#jobs.values()) {
1065
1087
  if (job.state !== "queued") continue;
1066
1088
  const pastDeadline = job.deadlineAt !== null && job.deadlineAt <= now;
@@ -1145,7 +1167,6 @@ var MemoryStore = class {
1145
1167
  platform: pairing.platform,
1146
1168
  daemonVersion: pairing.daemonVersion,
1147
1169
  capabilities: pairing.capabilities,
1148
- paused: false,
1149
1170
  revokedAt: null,
1150
1171
  lastHeartbeatAt: args.now,
1151
1172
  createdAt: args.now
@@ -1192,7 +1213,6 @@ var MemoryStore = class {
1192
1213
  ...runner,
1193
1214
  capabilities: args.capabilities,
1194
1215
  daemonVersion: args.daemonVersion,
1195
- paused: args.paused,
1196
1216
  lastHeartbeatAt: args.now
1197
1217
  };
1198
1218
  this.#runners.set(runner.id, updated);