@songsid/agend 2.1.5-beta.8 → 2.1.5-beta.9

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.
@@ -473,6 +473,13 @@ export declare class FleetManager implements FleetContext, LifecycleContext, Arc
473
473
  */
474
474
  private startClassicInstanceUnattended;
475
475
  private backendNameOf;
476
+ /**
477
+ * Every configured instance whose backend may share credentials. ClassicBot
478
+ * rows live only in classicBot.yaml, so backend-wide operations must not use
479
+ * fleetConfig.instances as their roster. Set keeps a malformed name collision
480
+ * from restarting the same process twice; backendNameOf defines ownership.
481
+ */
482
+ private configuredBackendInstanceNames;
476
483
  /**
477
484
  * One fleet-level notice per burst, not one per instance: a post-update herd
478
485
  * fails many instances within the same second. Two notices per incident at
@@ -1745,15 +1745,31 @@ export class FleetManager {
1745
1745
  }
1746
1746
  backendNameOf(name) {
1747
1747
  const fleetDefault = this.fleetConfig?.defaults?.backend;
1748
- const configured = this.fleetConfig?.instances[name]?.backend;
1749
- if (configured)
1750
- return configured;
1748
+ const fleetInstance = this.fleetConfig?.instances[name];
1749
+ // A malformed/manual config can give a fleet and Classic entry the same
1750
+ // instance name. Fleet ownership wins, including its inherited default;
1751
+ // otherwise a Classic override could make backend-scoped recovery restart
1752
+ // the shared process under the wrong login result.
1753
+ if (fleetInstance)
1754
+ return fleetInstance.backend ?? fleetDefault ?? "claude-code";
1751
1755
  // ClassicBot channels pick their own backend; the fleet default is only the fallback.
1752
1756
  if (this.classicChannels?.getAll().some(channel => channel.instanceName === name)) {
1753
1757
  return this.classicChannels.getBackendByInstance(name, fleetDefault);
1754
1758
  }
1755
1759
  return fleetDefault ?? "claude-code";
1756
1760
  }
1761
+ /**
1762
+ * Every configured instance whose backend may share credentials. ClassicBot
1763
+ * rows live only in classicBot.yaml, so backend-wide operations must not use
1764
+ * fleetConfig.instances as their roster. Set keeps a malformed name collision
1765
+ * from restarting the same process twice; backendNameOf defines ownership.
1766
+ */
1767
+ configuredBackendInstanceNames() {
1768
+ const names = new Set(Object.keys(this.fleetConfig?.instances ?? {}));
1769
+ for (const channel of this.classicChannels?.getAll() ?? [])
1770
+ names.add(channel.instanceName);
1771
+ return [...names];
1772
+ }
1757
1773
  /**
1758
1774
  * One fleet-level notice per burst, not one per instance: a post-update herd
1759
1775
  * fails many instances within the same second. Two notices per incident at
@@ -7132,8 +7148,8 @@ export class FleetManager {
7132
7148
  /** Post the backend chooser for a bare `/login`. Caller enforces admin. */
7133
7149
  async promptLoginBackends(chat) {
7134
7150
  const configured = new Set();
7135
- for (const [, config] of Object.entries(this.fleetConfig?.instances ?? {})) {
7136
- configured.add(config.backend ?? this.fleetConfig?.defaults?.backend ?? "claude-code");
7151
+ for (const name of this.configuredBackendInstanceNames()) {
7152
+ configured.add(this.backendNameOf(name));
7137
7153
  }
7138
7154
  const choices = Object.keys(LOGIN_FLOWS)
7139
7155
  .filter(backend => configured.size === 0 || configured.has(backend))
@@ -7536,9 +7552,8 @@ export class FleetManager {
7536
7552
  async recoverBackendInstances(backend) {
7537
7553
  const woken = [];
7538
7554
  const restarted = [];
7539
- for (const [name, config] of Object.entries(this.fleetConfig?.instances ?? {})) {
7540
- const effective = config.backend ?? this.fleetConfig?.defaults?.backend ?? "claude-code";
7541
- if (effective !== backend)
7555
+ for (const name of this.configuredBackendInstanceNames()) {
7556
+ if (this.backendNameOf(name) !== backend)
7542
7557
  continue;
7543
7558
  const status = this.getInstanceStatus(name);
7544
7559
  try {