@0perator/operator 0.1.321 → 0.1.322

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/cli.js CHANGED
@@ -822,7 +822,9 @@ function Root() {
822
822
  let reports = [];
823
823
  try {
824
824
  const preflight = await import("./services/preflight.js");
825
- const auroraCfg = { base: settings.endpoints.aurora.base, ...settings.services?.aurora };
825
+ const bootBase = settings.endpoints.aurora.base; // "" sentinel until the gateway's published port resolves
826
+ const bootKeyBefore = settings.endpoints.aurora.apiKey;
827
+ const auroraCfg = { base: bootBase, ...settings.services?.aurora };
826
828
  reports = await preflight.ensureServices({
827
829
  aurora: auroraCfg,
828
830
  autopilot: settings.services?.autopilot,
@@ -839,6 +841,13 @@ function Root() {
839
841
  const bootKey = auroraCfg.apiKey;
840
842
  if (bootKey && !settings.endpoints.aurora.apiKey)
841
843
  settings.endpoints.aurora.apiKey = bootKey;
844
+ // The Session — and its router — were built at first render, while aurora.base was still the ""
845
+ // sentinel. Mutating settings alone leaves that router probing a blank base ("Can't reach Operator"
846
+ // with the gateway up, 0.1.321). Rebuild the chain from the resolved settings and swap it in — the
847
+ // order the headless factory gets for free (ensureServices, THEN buildRouterFromSettings).
848
+ if (settings.endpoints.aurora.base !== bootBase || settings.endpoints.aurora.apiKey !== bootKeyBefore) {
849
+ session.useRouter(buildRouter());
850
+ }
842
851
  // If the lever COLD-STARTED Aurora, prime it (fire-and-forget) so the first real turn doesn't
843
852
  // eat the graph/Metal warmup. Skipped when Aurora was already up (state "up").
844
853
  if (reports.find((r) => r.name === "aurora")?.state === "started") {
package/dist/session.js CHANGED
@@ -303,6 +303,7 @@ export class Session {
303
303
  convo = new Conversation();
304
304
  inner; // was readonly — /model rebuilds it for a "single" profile switch
305
305
  router; // rebuilt alongside inner (setModel)
306
+ chain; // the endpoint chain the shell built (cfg.router / useRouter) — what the default local model routes through
306
307
  registry; // /model's choices — built-ins + any settings.models
307
308
  moaConfig;
308
309
  fastStartConfig;
@@ -422,6 +423,7 @@ export class Session {
422
423
  this.localSchemas = toSchemas(reg);
423
424
  this.inner = cfg.router ?? new AuroraRouter();
424
425
  this.router = engineRouter(this.inner);
426
+ this.chain = cfg.router;
425
427
  this.registry = modelRegistry(cfg.models);
426
428
  this.isOwner = (cfg.eventActor?.tier ?? "admin") === "admin"; // set before the startup setModel so a persisted owner-only activeModel resolves for the owner
427
429
  this.moaConfig = cfg.moa;
@@ -738,7 +740,14 @@ export class Session {
738
740
  if (profile.kind === "orchestrated" && !this.moaConfig?.proposers?.length) {
739
741
  return { ok: false, error: `MOA needs a "moa" block (proposers + aggregator) in settings.json — see MOA-DESIGN.md` };
740
742
  }
741
- if (profile.kind === "single" && (profile.endpoint || profile.endpoints?.length)) {
743
+ if (profile.kind === "single" && profile.id === DEFAULT_MODEL_ID && this.chain) {
744
+ // The default local model IS the shell's endpoint chain (the gateway's published port + its failover
745
+ // legs). Restore it rather than rebuilding from the profile's static :8097 endpoint, which no longer
746
+ // answers on a gateway box — otherwise /model away-and-back lands on a dead port.
747
+ this.inner = this.chain;
748
+ this.router = engineRouter(this.inner);
749
+ }
750
+ else if (profile.kind === "single" && (profile.endpoint || profile.endpoints?.length)) {
742
751
  // BYO connectors carry their vendor bearer (never the Operator token — see authHeaders scoping);
743
752
  // selectModel already refused the id if the key is not connected, so resolution can't miss here.
744
753
  const token = profile.byo ? getByoToken(profile.byo) : undefined;
@@ -764,6 +773,17 @@ export class Session {
764
773
  this.modelId = profile.id;
765
774
  return { ok: true };
766
775
  }
776
+ /** Re-point this session at a freshly built endpoint chain. The interactive shell constructs the Session at
777
+ * first render, BEFORE the boot lever has resolved the gateway's dynamic port (server.json) — the chain must
778
+ * follow that resolution or health() and every turn probe the "" sentinel. Same swap setModel does. A
779
+ * non-default /model pick keeps owning routing; the chain then waits for `/model operator-1m`. */
780
+ useRouter(router) {
781
+ this.chain = router;
782
+ if (this.modelId !== DEFAULT_MODEL_ID)
783
+ return;
784
+ this.inner = router;
785
+ this.router = engineRouter(this.inner);
786
+ }
767
787
  /** The full conversation, for persistence (auto-save / --resume). */
768
788
  snapshot() {
769
789
  return this.convo.all.map((m) => ({ ...m }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.321",
3
+ "version": "0.1.322",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "operator": "dist/cli.js",