@songsid/agend 2.4.0-beta.7 → 2.4.0-beta.8
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/auth-api.js +1 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/antigravity.d.ts +9 -2
- package/dist/backend/antigravity.js +24 -6
- package/dist/backend/antigravity.js.map +1 -1
- package/dist/backend/cli-env-probe.js +1 -1
- package/dist/backend/cli-env-probe.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/daemon.d.ts +13 -0
- package/dist/daemon.js +64 -1
- package/dist/daemon.js.map +1 -1
- package/dist/dispatcher-liveness.d.ts +51 -1
- package/dist/dispatcher-liveness.js +92 -2
- package/dist/dispatcher-liveness.js.map +1 -1
- package/dist/fleet-manager.d.ts +55 -0
- package/dist/fleet-manager.js +232 -16
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +6 -0
- package/dist/hub/catalog.d.ts +6 -4
- package/dist/hub/catalog.js +14 -7
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/group-policy/admin-impact.d.ts +32 -3
- package/dist/hub/group-policy/admin-impact.js +14 -2
- package/dist/hub/group-policy/admin-impact.js.map +1 -1
- package/dist/hub/group-policy/impact-inventory.d.ts +1 -1
- package/dist/hub/group-policy/impact-inventory.js.map +1 -1
- package/dist/hub/http/compose.js +70 -6
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.js +3 -0
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +1 -0
- package/dist/hub/join/service.d.ts +1 -1
- package/dist/hub/join/service.js.map +1 -1
- package/dist/hub/mcp/auth-schema.d.ts +7 -0
- package/dist/hub/mcp/auth-schema.js +31 -0
- package/dist/hub/mcp/auth-schema.js.map +1 -0
- package/dist/hub/mcp/auth.d.ts +86 -0
- package/dist/hub/mcp/auth.js +364 -0
- package/dist/hub/mcp/auth.js.map +1 -0
- package/dist/hub/personal/owner-host.d.ts +64 -0
- package/dist/hub/personal/owner-host.js +190 -0
- package/dist/hub/personal/owner-host.js.map +1 -0
- package/dist/hub/personal/schema.d.ts +2 -0
- package/dist/hub/personal/schema.js +48 -0
- package/dist/hub/personal/schema.js.map +1 -0
- package/dist/hub/personal/types.d.ts +42 -0
- package/dist/hub/personal/types.js +2 -0
- package/dist/hub/personal/types.js.map +1 -0
- package/dist/hub/policy.js +2 -0
- package/dist/hub/policy.js.map +1 -1
- package/dist/hub/quota.js +3 -1
- package/dist/hub/quota.js.map +1 -1
- package/dist/hub/roles/admin-control.d.ts +29 -0
- package/dist/hub/roles/admin-control.js +134 -0
- package/dist/hub/roles/admin-control.js.map +1 -0
- package/dist/hub/roles/admin-types.d.ts +49 -0
- package/dist/hub/roles/admin-types.js +2 -0
- package/dist/hub/roles/admin-types.js.map +1 -0
- package/dist/hub/roles/resource-effects.d.ts +16 -0
- package/dist/hub/roles/resource-effects.js +62 -0
- package/dist/hub/roles/resource-effects.js.map +1 -0
- package/dist/hub/roles/writer.d.ts +6 -1
- package/dist/hub/roles/writer.js +10 -2
- package/dist/hub/roles/writer.js.map +1 -1
- package/dist/hub/rooms/agents.js +5 -2
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms.d.ts +1 -1
- package/dist/hub/rooms.js +12 -8
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/sessions.js +20 -2
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/sharing.js +2 -2
- package/dist/hub/sharing.js.map +1 -1
- package/dist/hub/types.d.ts +15 -3
- package/dist/locale.js +3 -0
- package/dist/locale.js.map +1 -1
- package/dist/native-model-catalog.d.ts +15 -0
- package/dist/native-model-catalog.js +43 -3
- package/dist/native-model-catalog.js.map +1 -1
- package/dist/runtime-build-info.js +1 -0
- package/dist/runtime-build-info.js.map +1 -1
- package/dist/runtime-cli.js +31 -5
- package/dist/runtime-cli.js.map +1 -1
- package/dist/runtime-client-store.d.ts +5 -0
- package/dist/runtime-client-store.js +28 -0
- package/dist/runtime-client-store.js.map +1 -1
- package/dist/runtime-client.d.ts +4 -0
- package/dist/runtime-client.js +33 -10
- package/dist/runtime-client.js.map +1 -1
- package/dist/runtime-coordinator.d.ts +4 -2
- package/dist/runtime-coordinator.js +28 -6
- package/dist/runtime-coordinator.js.map +1 -1
- package/dist/runtime-install.d.ts +3 -0
- package/dist/runtime-install.js +7 -1
- package/dist/runtime-install.js.map +1 -1
- package/dist/runtime-personal-answer.d.ts +1 -0
- package/dist/runtime-personal-answer.js +2 -1
- package/dist/runtime-personal-answer.js.map +1 -1
- package/dist/runtime-personal-preflight.d.ts +5 -0
- package/dist/runtime-personal-preflight.js +57 -0
- package/dist/runtime-personal-preflight.js.map +1 -0
- package/dist/runtime-personal-profile.d.ts +3 -1
- package/dist/runtime-personal-profile.js +13 -4
- package/dist/runtime-personal-profile.js.map +1 -1
- package/dist/runtime-personal-protocol.d.ts +7 -0
- package/dist/runtime-personal-protocol.js +11 -0
- package/dist/runtime-personal-protocol.js.map +1 -0
- package/dist/runtime-personal-stage.d.ts +36 -0
- package/dist/runtime-personal-stage.js +163 -0
- package/dist/runtime-personal-stage.js.map +1 -0
- package/dist/runtime-protocol.d.ts +2 -0
- package/dist/ui/chat-store.js +39 -2
- package/dist/ui/hub-client.js +14 -0
- package/dist/ui/hub-roles-strings.js +15 -0
- package/dist/ui/hub-roles.js +48 -0
- package/dist/ui/hub-switcher.js +2 -2
- package/dist/ui/hub-this-hub.js +2 -2
- package/dist/ui/model-picker.js +4 -1
- package/dist/ui/panel-hub.js +15 -9
- package/dist/ui/panel-settings.js +2 -3
- package/dist/ui/settings-catalog.js +22 -0
- package/dist/ui/settings-hub-setup.js +2 -1
- package/dist/ui/settings-strings.js +2 -0
- package/dist/ui/shared/app-shell.js +19 -7
- package/dist/ui/shared/app-stream.js +3 -1
- package/dist/ui/shared/app.css +18 -8
- package/dist/ui/shared/hub-roles.css +27 -0
- package/dist/ui/shared/hub.css +11 -3
- package/dist/ui/shared/usage-dialog.js +67 -12
- package/dist/ui/shared/view-strings.js +8 -0
- package/dist/web-api.d.ts +4 -0
- package/dist/web-api.js +39 -23
- package/dist/web-api.js.map +1 -1
- package/dist/windows-cli-worker.d.ts +7 -0
- package/dist/windows-cli-worker.js +80 -14
- package/dist/windows-cli-worker.js.map +1 -1
- package/dist/windows-cli.d.ts +9 -1
- package/dist/windows-cli.js +43 -13
- package/dist/windows-cli.js.map +1 -1
- package/package.json +1 -1
package/dist/fleet-manager.js
CHANGED
|
@@ -135,7 +135,7 @@ import { routeToolCall } from "./channel/tool-router.js";
|
|
|
135
135
|
import { Scheduler } from "./scheduler/index.js";
|
|
136
136
|
import { boardActivity, boardCardLimit, boardToolAction } from "./task-board-tool.js";
|
|
137
137
|
import { TaskBoardWaker, namesCard } from "./task-board-waker.js";
|
|
138
|
-
import { DispatcherLiveness, LIVENESS_STARTUP_GRACE_MS, livenessSettings } from "./dispatcher-liveness.js";
|
|
138
|
+
import { DispatcherLiveness, LIVENESS_STARTUP_GRACE_MS, livenessSettings, questionNotices, turnQuestion } from "./dispatcher-liveness.js";
|
|
139
139
|
import { TaskBoardError, waitsForPerson, wrapUpGap } from "./scheduler/task-board.js";
|
|
140
140
|
import { escapeTelegramHtml, scheduleClock, scheduleRetryLabel } from "./scheduler/retry-label.js";
|
|
141
141
|
import { DEFAULT_SCHEDULER_CONFIG } from "./scheduler/index.js";
|
|
@@ -229,7 +229,7 @@ import { RuntimeWindowsBridge } from "./runtime-windows-bridge.js";
|
|
|
229
229
|
import { FleetWindowsRuntime } from "./fleet-windows-runtime.js";
|
|
230
230
|
import { NativeMcpSessions } from "./native-mcp.js";
|
|
231
231
|
import { nativeProviderMcpSupported } from "./windows-cli-providers.js";
|
|
232
|
-
import { cachedNativeModelCatalog } from "./native-model-catalog.js";
|
|
232
|
+
import { cachedNativeModelCatalog, refreshNativeModelCatalogAfterSignIn } from "./native-model-catalog.js";
|
|
233
233
|
import { shapeWebModelCatalog } from "./web-model-groups.js";
|
|
234
234
|
import { isWindowsInstance, isNativePaneInstance, isNativeExecInstance, WINDOWS_CONFIG_REFUSED, nativeCredentialProfile } from "./native-instance-registry.js";
|
|
235
235
|
import { createNativeWindowsInstance, updateNativeWindowsInstance } from "./native-instance-api.js";
|
|
@@ -693,6 +693,13 @@ const NONCE_RETIRE_BUDGET_MS = 5_000;
|
|
|
693
693
|
* so nothing re-probed and `/model` kept serving a list up to 24h old.
|
|
694
694
|
*/
|
|
695
695
|
const CLI_ENV_FRESH_MS = 60 * 60 * 1000;
|
|
696
|
+
/**
|
|
697
|
+
* How long a menu that opens on an empty model list waits for its one discovery, and how long an attempt that
|
|
698
|
+
* found nothing (a CLI not signed in, offline) is not repeated by the next open. Shorter than CLI_ENV_PROBE_DEADLINE_MS: a
|
|
699
|
+
* slower probe finishes behind the menu and the page reads again (the `models` event).
|
|
700
|
+
*/
|
|
701
|
+
const MODEL_OPEN_PROBE_WAIT_MS = 12_000;
|
|
702
|
+
const MODEL_OPEN_PROBE_COOLDOWN_MS = 60_000;
|
|
696
703
|
/**
|
|
697
704
|
* Upper bound on a live probe driven by `/model`.
|
|
698
705
|
*
|
|
@@ -3137,6 +3144,8 @@ export class FleetManager {
|
|
|
3137
3144
|
livenessGone = new Map();
|
|
3138
3145
|
/** #3647: when each instance last showed working (after the startup grace): activity for "quiet". */
|
|
3139
3146
|
lastWorkingAt = new Map();
|
|
3147
|
+
/** M-3239: the instances whose progress is read from their transcript (see cacheInstanceExecutionState). */
|
|
3148
|
+
livenessTurnEvidence = new Set();
|
|
3140
3149
|
dispatcherLiveness = null;
|
|
3141
3150
|
/** Adapters whose last slash command registration failed and General was told (#1131). */
|
|
3142
3151
|
slashRegistrationFailed = new Set();
|
|
@@ -5808,6 +5817,39 @@ export class FleetManager {
|
|
|
5808
5817
|
claimedAt: Math.max(ms(board.lastChangeAt(c.uuid)), ms(c.startedAt)), updatedAt: ms(c.updatedAt),
|
|
5809
5818
|
}));
|
|
5810
5819
|
}
|
|
5820
|
+
/**
|
|
5821
|
+
* M-3239: a tool call or an answer in the agent's transcript. Unlike the pane's spinner it counts from the fleet's start
|
|
5822
|
+
* (the boot shows working; a transcript line is real work, and the monitor starts at the transcript's end).
|
|
5823
|
+
*/
|
|
5824
|
+
noteTurnActivity(name, at) {
|
|
5825
|
+
if (!Number.isFinite(at) || at > Date.now() + 60_000 || at < this.startedAt)
|
|
5826
|
+
return;
|
|
5827
|
+
if (at > (this.lastWorkingAt.get(name) ?? 0))
|
|
5828
|
+
this.lastWorkingAt.set(name, at);
|
|
5829
|
+
}
|
|
5830
|
+
/**
|
|
5831
|
+
* M-3239: an agent ended a turn without messaging anyone. If its final text asks a question and it holds a card
|
|
5832
|
+
* another agent handed it, that dispatcher is told, quoting the question — otherwise the question sits on the agent's
|
|
5833
|
+
* own screen and the card stalls (a beta.7 rehearsal waited 1.5 h on one).
|
|
5834
|
+
*/
|
|
5835
|
+
onTurnEndedQuietly(name, startedAt, text) {
|
|
5836
|
+
if (this.shuttingDown || this.isPlannedRestart() || !livenessSettings(this.fleetConfig).enabled)
|
|
5837
|
+
return;
|
|
5838
|
+
const question = turnQuestion(text);
|
|
5839
|
+
if (!question)
|
|
5840
|
+
return;
|
|
5841
|
+
const outbox = this.deliveryOutbox;
|
|
5842
|
+
if (!outbox?.isOpen)
|
|
5843
|
+
return;
|
|
5844
|
+
const sent = outbox.latestSentAt(name);
|
|
5845
|
+
if (sent !== null && sent >= startedAt)
|
|
5846
|
+
return; // it did tell someone during the turn
|
|
5847
|
+
const isAgent = (d) => (this.fleetConfig?.instances?.[d] != null || this.isClassicInstance(d)) && !taskBoardOffIn(this.fleetConfig, d);
|
|
5848
|
+
for (const n of questionNotices(this.livenessCards(), name, question, startedAt, isAgent)) {
|
|
5849
|
+
this.admitTaskBoardNotice(n.dispatcher, n.message, n.key);
|
|
5850
|
+
this.logger.info({ assignee: name, dispatcher: n.dispatcher }, "Dispatcher told: assignee ended its turn on a question it sent no one");
|
|
5851
|
+
}
|
|
5852
|
+
}
|
|
5811
5853
|
/** #3647: what the fleet knows about an assignee now; null when it is not an instance here. */
|
|
5812
5854
|
livenessFacts(name) {
|
|
5813
5855
|
if (this.fleetConfig?.instances?.[name] == null)
|
|
@@ -5837,6 +5879,9 @@ export class FleetManager {
|
|
|
5837
5879
|
usageHold: this.daemons.get(name)?.usageHold?.() ?? null,
|
|
5838
5880
|
execution: exec ? { state: exec.state, since: exec.stateChangedAt } : null,
|
|
5839
5881
|
lastWorkingAt: this.lastWorkingAt.get(name) ?? null,
|
|
5882
|
+
turnEvidence: this.livenessTurnEvidence.has(name),
|
|
5883
|
+
// M-3239 (Fable F1): a restart forgets the transcript's progress; its quiet clock starts no earlier than the fleet.
|
|
5884
|
+
quietFloor: this.livenessTurnEvidence.has(name) ? this.startedAt : null,
|
|
5840
5885
|
prompt: p.state === "awaiting_input" && p.interaction?.since ? { since: p.interaction.since } : null,
|
|
5841
5886
|
waitingOn,
|
|
5842
5887
|
// Asked only when it could be quiet (one indexed read per idle assignee).
|
|
@@ -7513,8 +7558,16 @@ export class FleetManager {
|
|
|
7513
7558
|
// asks "is anyone still reporting", which only the receiver can date.
|
|
7514
7559
|
receivedAt: now,
|
|
7515
7560
|
});
|
|
7516
|
-
// #3647: activity, for "quiet" — not the boot itself (every agent shows working while it starts).
|
|
7517
|
-
|
|
7561
|
+
// #3647: activity, for "quiet" — not the boot itself (every agent shows working while it starts). M-3239: an agent
|
|
7562
|
+
// whose transcript tells its turns (Claude, Codex) shows progress by its tool calls and answers, not by its pane's
|
|
7563
|
+
// spinner — Claude compacting its context on its own, idle, held off a stalled card's notice.
|
|
7564
|
+
if (msg.turnEvidence === true)
|
|
7565
|
+
this.livenessTurnEvidence.add(name);
|
|
7566
|
+
else if (msg.turnEvidence === false)
|
|
7567
|
+
this.livenessTurnEvidence.delete(name);
|
|
7568
|
+
if (typeof msg.turnActivityAt === "number")
|
|
7569
|
+
this.noteTurnActivity(name, msg.turnActivityAt);
|
|
7570
|
+
if (state === "working" && !this.livenessTurnEvidence.has(name) && now - this.startedAt >= LIVENESS_STARTUP_GRACE_MS)
|
|
7518
7571
|
this.lastWorkingAt.set(name, now);
|
|
7519
7572
|
// The dashboard's "working" line and its Stop button follow the edges, not the heartbeat.
|
|
7520
7573
|
if (previous?.state !== state)
|
|
@@ -13547,6 +13600,14 @@ export class FleetManager {
|
|
|
13547
13600
|
waiter(msg);
|
|
13548
13601
|
}
|
|
13549
13602
|
}
|
|
13603
|
+
else if (msg.type === "turn_activity") {
|
|
13604
|
+
if (typeof msg.at === "number")
|
|
13605
|
+
this.noteTurnActivity(name, msg.at);
|
|
13606
|
+
}
|
|
13607
|
+
else if (msg.type === "turn_ended") {
|
|
13608
|
+
if (typeof msg.startedAt === "number" && typeof msg.text === "string")
|
|
13609
|
+
this.onTurnEndedQuietly(name, msg.startedAt, msg.text);
|
|
13610
|
+
}
|
|
13550
13611
|
else if (msg.type === "instance_state" || msg.type === "instance_state_response") {
|
|
13551
13612
|
this.cacheInstanceExecutionState(name, msg);
|
|
13552
13613
|
if (msg.type === "instance_state_response") {
|
|
@@ -21080,6 +21141,9 @@ export class FleetManager {
|
|
|
21080
21141
|
return { current: catalog.current_model, options: catalog.models.map(m => ({ id: m.id, label: m.label })), actions: ["refresh"] };
|
|
21081
21142
|
}
|
|
21082
21143
|
const backend = this.backendNameForInstance(instance);
|
|
21144
|
+
// Opened on an empty list, the menu waits for one bounded discovery ("loading") instead of showing nothing.
|
|
21145
|
+
if (!more)
|
|
21146
|
+
await this.ensureModelCatalog(backend, instance);
|
|
21083
21147
|
const env = this.webModelEnv(backend, instance);
|
|
21084
21148
|
const current = this.resolveInstanceModel(instance).model;
|
|
21085
21149
|
const models = more ? this.modelCatalogFor(backend, instance) : env?.models ?? [];
|
|
@@ -21149,7 +21213,11 @@ export class FleetManager {
|
|
|
21149
21213
|
const refusal = this.backendCommandRefusal(instance);
|
|
21150
21214
|
if (refusal)
|
|
21151
21215
|
return { error: refusal };
|
|
21152
|
-
// The cached model lists
|
|
21216
|
+
// The cached model lists, as the web's /model; an empty one is discovered once, bounded (moving to a CLI
|
|
21217
|
+
// never signed in at startup, or probed before it was installed, must not offer an empty list).
|
|
21218
|
+
const wanted = backendArgs(args)[0];
|
|
21219
|
+
if (wanted && KNOWN_BACKENDS.includes(wanted))
|
|
21220
|
+
await this.ensureModelCatalog(wanted, instance);
|
|
21153
21221
|
const step = await backendStep({ ...this.backendCommandDeps(instance, { live: false }), models: async (backend) => this.modelCatalogFor(backend, instance) }, instance, backendArgs(args));
|
|
21154
21222
|
if (step.kind === "refuse")
|
|
21155
21223
|
return step.noop ? { text: step.text } : { error: step.text };
|
|
@@ -22553,6 +22621,7 @@ export class FleetManager {
|
|
|
22553
22621
|
// #2072: a sign-in just finished — the pickers learn it now, not at the next pass.
|
|
22554
22622
|
if (!profile)
|
|
22555
22623
|
void this.backendAvailability.refresh([backend], { force: true });
|
|
22624
|
+
this.modelsAfterSignIn(backend, profile ?? null); // Chat /login and the dashboard's terminal sign-in
|
|
22556
22625
|
return this.recoverBackendInstances(backend, undefined, profile ?? null);
|
|
22557
22626
|
},
|
|
22558
22627
|
claimWindow: backend => this.loginWindow.tryClaim("web", backend),
|
|
@@ -22588,7 +22657,7 @@ export class FleetManager {
|
|
|
22588
22657
|
reported: (id, profile, backend) => this.machineAccounts.profileState(id, profile, backend),
|
|
22589
22658
|
reportedDefault: (id, backend) => this.machineAccounts.reportedDefault(id, backend),
|
|
22590
22659
|
readiness: (id, backend, named) => this.machineAccounts.readiness(id, backend, named),
|
|
22591
|
-
actor: owner =>
|
|
22660
|
+
actor: owner => this.machineSignInActor(owner),
|
|
22592
22661
|
changed: (event, owner) => {
|
|
22593
22662
|
// Safe fields only: the computer, the CLI, the profile name (none for Antigravity's default login), a phase and a fixed reason. Never a URL, a code, output or an e-mail address.
|
|
22594
22663
|
this.logger.info({ machine: event.machine, backend: event.backend, ...(event.profile ? { profile: event.profile } : {}), phase: event.phase, ...(event.reason ? { reason: event.reason } : {}), by: owner.label }, "Computer account sign-in from Settings → Accounts");
|
|
@@ -22596,11 +22665,44 @@ export class FleetManager {
|
|
|
22596
22665
|
// Only the computer's OWN login (no profile) is remembered here: a named account's sign-in is reported by its Runtime's inventory, which it sends before the sign-in ends.
|
|
22597
22666
|
if (event.phase === "done" && event.profile === undefined)
|
|
22598
22667
|
this.machineAccounts.noteDefaultLogin(event.machine, event.backend, true);
|
|
22668
|
+
// That computer's Runtime lists models in its own inventory (never a host probe): pages read it again now,
|
|
22669
|
+
// and the Runtime is asked once, for the admin who finished the sign-in, to list them as this account.
|
|
22670
|
+
if (event.phase === "done") {
|
|
22671
|
+
this.announceModels(event.backend);
|
|
22672
|
+
void this.nativeModelsAfterSignIn(event, owner);
|
|
22673
|
+
}
|
|
22599
22674
|
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
22600
22675
|
this.needsYou?.poke();
|
|
22601
22676
|
},
|
|
22602
22677
|
});
|
|
22603
22678
|
}
|
|
22679
|
+
/**
|
|
22680
|
+
* A paired computer's sign-in ended — ask its Runtime once (`models.refresh`, as the admin who finished the
|
|
22681
|
+
* sign-in) for the list as this account, so the next read of its agents' and the create dialog's list has it without the
|
|
22682
|
+
* Refresh button. Once per sign-in; never on a read (M-2239 P1-2). A Runtime without the capability, a refused account or any
|
|
22683
|
+
* failure is skipped quietly: the sign-in is done either way.
|
|
22684
|
+
*/
|
|
22685
|
+
/** The name a paired computer's audit log records for the admin session that signed in on it (`admin:<handle>`); null refuses. */
|
|
22686
|
+
machineSignInActor(owner) {
|
|
22687
|
+
const handle = owner.handle;
|
|
22688
|
+
return typeof handle === "string" && /^[a-f0-9]{16}$/.test(handle) ? `admin:${handle}` : null;
|
|
22689
|
+
}
|
|
22690
|
+
async nativeModelsAfterSignIn(event, owner) {
|
|
22691
|
+
try {
|
|
22692
|
+
const actor = this.machineSignInActor(owner);
|
|
22693
|
+
if (!actor || this.shuttingDown || !this.browserSignInOwnerCurrent(owner))
|
|
22694
|
+
return;
|
|
22695
|
+
const refreshed = await refreshNativeModelCatalogAfterSignIn(this, {
|
|
22696
|
+
backend: event.backend, machineId: event.machine, ...(event.profile ? { profile: event.profile } : {}), actor,
|
|
22697
|
+
stillAdmin: () => !this.shuttingDown && this.browserSignInOwnerCurrent(owner),
|
|
22698
|
+
});
|
|
22699
|
+
if (refreshed)
|
|
22700
|
+
this.announceModels(event.backend);
|
|
22701
|
+
}
|
|
22702
|
+
catch (err) {
|
|
22703
|
+
this.logger.debug({ backend: event.backend, err }, "Model refresh after a computer's sign-in skipped");
|
|
22704
|
+
}
|
|
22705
|
+
}
|
|
22604
22706
|
machineAccountsInstance = null;
|
|
22605
22707
|
/** #3190 Part 3c: a paired computer's accounts in Settings → Accounts (machine-accounts.ts). */
|
|
22606
22708
|
get machineAccounts() {
|
|
@@ -22649,6 +22751,7 @@ export class FleetManager {
|
|
|
22649
22751
|
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
22650
22752
|
if (event.phase === "done") {
|
|
22651
22753
|
this.forgetSignInIdentities(); // a sign-in may be a different account now
|
|
22754
|
+
this.modelsAfterSignIn(event.backend, null); // The list read before this sign-in (a signed-out CLI answers none) is not this account's
|
|
22652
22755
|
this.keepAliveAfterSignIn(event.backend, null); // its file changed, whoever is watching: a "needs sign-in" left from before is no longer the answer
|
|
22653
22756
|
this.usageAfterSignIn(); // the usage read before this sign-in is not this account's
|
|
22654
22757
|
}
|
|
@@ -22704,6 +22807,7 @@ export class FleetManager {
|
|
|
22704
22807
|
broadcastSseEvent(this.sseClients, "backend_login", {}, err => this.logger.debug({ err }, "backend_login event failed"));
|
|
22705
22808
|
if (event.phase === "done") {
|
|
22706
22809
|
this.forgetSignInIdentities(); // a sign-in may be a different account now
|
|
22810
|
+
this.modelsAfterSignIn(event.backend, event.profile);
|
|
22707
22811
|
this.keepAliveAfterSignIn(event.backend, event.profile);
|
|
22708
22812
|
this.usageAfterSignIn();
|
|
22709
22813
|
}
|
|
@@ -25915,6 +26019,8 @@ export class FleetManager {
|
|
|
25915
26019
|
/** Preserve the existing cache merge rules for worker probes. */
|
|
25916
26020
|
persistCliEnvProbeResult(backend, probed, profile = null) {
|
|
25917
26021
|
const env = { backend, probedAt: Date.now(), ...probed };
|
|
26022
|
+
const listed = (e) => (e?.models ?? []).map(m => m.id).join("\0");
|
|
26023
|
+
const before = listed(this.readCliEnv(backend, profile));
|
|
25918
26024
|
// An empty result must never overwrite a catalog we already have. Some
|
|
25919
26025
|
// probes hit the network (`agy models` fetches, 5s cap), so a slow moment
|
|
25920
26026
|
// returns [] — and writing that would blank the list for the whole 24h
|
|
@@ -25945,6 +26051,8 @@ export class FleetManager {
|
|
|
25945
26051
|
const path = this.cliEnvPath(backend, profile);
|
|
25946
26052
|
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
25947
26053
|
writeFileSync(path, JSON.stringify(env, null, 2));
|
|
26054
|
+
if (listed(env) !== before)
|
|
26055
|
+
this.announceModels(backend); // An open /model or Settings page reads the new list
|
|
25948
26056
|
return env;
|
|
25949
26057
|
}
|
|
25950
26058
|
/** Background-probe every distinct backend in use at startup (non-blocking). */
|
|
@@ -25966,6 +26074,105 @@ export class FleetManager {
|
|
|
25966
26074
|
void this.probeBackendBounded(b);
|
|
25967
26075
|
this.probeChangedCliEnvs(null);
|
|
25968
26076
|
}
|
|
26077
|
+
/**
|
|
26078
|
+
* Whether a named account's catalog can be discovered without publishing another account's models under its name
|
|
26079
|
+
* (#3526 / D7). A CLI whose profile is a variable the probe inherits (codex, kiro, claude) is. A CLI told its account by an
|
|
26080
|
+
* argument (agy, `launch-argument`) is too, since AGEND-278: the probe is run with the account's own folder
|
|
26081
|
+
* (backend/antigravity.ts `listModels`), and it answers nothing for a folder with no sign-in. Never a profile on a
|
|
26082
|
+
* backend that has no credential home at all.
|
|
26083
|
+
*/
|
|
26084
|
+
modelDiscoverable(backend, binding) {
|
|
26085
|
+
return !binding.profile || !!credentialHomeSpec(backend);
|
|
26086
|
+
}
|
|
26087
|
+
/** One model discovery for a binding — the scoped (own config) or the shared per-backend/profile cache — or null when fenced. */
|
|
26088
|
+
discoverModels(backend, name, binding = this.webModelBinding(backend, name), opts = {}) {
|
|
26089
|
+
if (!binding || !this.modelDiscoverable(backend, binding))
|
|
26090
|
+
return null;
|
|
26091
|
+
// A scoped read resolves its binding again (publication and current checks included), so it is handed the selection the
|
|
26092
|
+
// binding came from: without it the agent's saved/default account would be probed and populated instead.
|
|
26093
|
+
return binding.scoped
|
|
26094
|
+
? this.refreshModelCatalogFor(backend, name, opts.selection, opts.afterSignIn ? { afterSignIn: true } : {})
|
|
26095
|
+
: this.probeBackendBounded(backend, { profile: binding.profile, ...(opts.refreshVendorCatalog ? { refreshVendorCatalog: true } : {}) });
|
|
26096
|
+
}
|
|
26097
|
+
/** The `models` stream event: a backend's model list changed — an open page reads it again (no details, as `backend_login`). */
|
|
26098
|
+
announceModels(backend) {
|
|
26099
|
+
try {
|
|
26100
|
+
broadcastSseEvent(this.sseClients, "models", { backend }, err => this.logger.debug({ err }, "models event failed"));
|
|
26101
|
+
}
|
|
26102
|
+
catch { /* best effort */ }
|
|
26103
|
+
}
|
|
26104
|
+
modelOpenProbes = new Map();
|
|
26105
|
+
/**
|
|
26106
|
+
* The list a menu opens on. Cached and fresh: nothing to do. Empty (never discovered: the CLI was signed out
|
|
26107
|
+
* at startup, or the agent just moved to this CLI): one bounded discovery that the caller waits for — so `/model` and
|
|
26108
|
+
* Settings show "loading" instead of an empty list. Stale: the list stands and is refreshed behind it. Both join a
|
|
26109
|
+
* discovery already running, and an attempt that found nothing is not repeated for MODEL_OPEN_PROBE_COOLDOWN_MS.
|
|
26110
|
+
* Never throws; a Windows Runtime's catalog is its inventory's and is not a host probe.
|
|
26111
|
+
*/
|
|
26112
|
+
async ensureModelCatalog(backend, instance, selection) {
|
|
26113
|
+
try {
|
|
26114
|
+
const binding = this.webModelBinding(backend, instance, selection);
|
|
26115
|
+
if (!binding || this.shuttingDown)
|
|
26116
|
+
return;
|
|
26117
|
+
const env = this.webModelEnv(backend, instance, selection);
|
|
26118
|
+
const empty = !env?.models?.length;
|
|
26119
|
+
if (!empty && !this.cliEnvNeedsRefresh(env))
|
|
26120
|
+
return;
|
|
26121
|
+
this.modelOpenProbes ??= new Map();
|
|
26122
|
+
const last = this.modelOpenProbes.get(binding.key);
|
|
26123
|
+
if (last !== undefined && Date.now() - last < MODEL_OPEN_PROBE_COOLDOWN_MS)
|
|
26124
|
+
return;
|
|
26125
|
+
const work = this.discoverModels(backend, instance, binding, { selection });
|
|
26126
|
+
if (!work)
|
|
26127
|
+
return;
|
|
26128
|
+
const done = work.catch(err => { this.logger.debug({ backend, instance, err }, "Model discovery on open failed"); }).then(() => {
|
|
26129
|
+
const after = this.webModelEnv(backend, instance, selection);
|
|
26130
|
+
if (!after?.models?.length || this.cliEnvNeedsRefresh(after))
|
|
26131
|
+
this.modelOpenProbes.set(binding.key, Date.now());
|
|
26132
|
+
else
|
|
26133
|
+
this.modelOpenProbes.delete(binding.key);
|
|
26134
|
+
});
|
|
26135
|
+
if (!empty)
|
|
26136
|
+
return;
|
|
26137
|
+
let timer;
|
|
26138
|
+
await Promise.race([done, new Promise(resolve => { timer = setTimeout(resolve, MODEL_OPEN_PROBE_WAIT_MS); timer.unref?.(); })]);
|
|
26139
|
+
if (timer)
|
|
26140
|
+
clearTimeout(timer);
|
|
26141
|
+
}
|
|
26142
|
+
catch (err) {
|
|
26143
|
+
this.logger.debug({ backend, instance, err }, "Model discovery on open failed");
|
|
26144
|
+
}
|
|
26145
|
+
}
|
|
26146
|
+
/**
|
|
26147
|
+
* A sign-in just ended, so the CLI can now answer `models` as this account — whatever started the sign-in
|
|
26148
|
+
* (Settings → Accounts, a named account, chat `/login`, the dashboard's terminal). The account's list is read again now,
|
|
26149
|
+
* not at the next startup or by hand. The default account: the backend's shared cache. A named account: its own store
|
|
26150
|
+
* (claude's profile catalog), or each agent's scoped one (the other CLIs, agy included: its probe runs with the account's folder).
|
|
26151
|
+
* A provider-bound agent does not depend on the sign-in. Background; each page is told when the list changed.
|
|
26152
|
+
*/
|
|
26153
|
+
modelsAfterSignIn(backend, profile) {
|
|
26154
|
+
if (this.shuttingDown || !KNOWN_BACKENDS.includes(backend) || backend === "mock")
|
|
26155
|
+
return;
|
|
26156
|
+
(this.modelOpenProbes ??= new Map()).clear(); // a cooldown from before the sign-in said "nothing to find": it no longer does
|
|
26157
|
+
const settle = (work) => {
|
|
26158
|
+
void work?.catch(err => this.logger.debug({ backend, profile, err }, "Model discovery after sign-in failed"));
|
|
26159
|
+
};
|
|
26160
|
+
if (profile === null) {
|
|
26161
|
+
settle(this.discoverModels(backend, null, undefined, { refreshVendorCatalog: true }));
|
|
26162
|
+
return;
|
|
26163
|
+
}
|
|
26164
|
+
if (backend === "claude-code") {
|
|
26165
|
+
settle(this.probeBackendBounded(backend, { profile, refreshVendorCatalog: true }));
|
|
26166
|
+
return;
|
|
26167
|
+
}
|
|
26168
|
+
for (const name of this.configuredBackendInstanceNames()) {
|
|
26169
|
+
if (this.backendNameOf(name) !== backend || this.credentialProfileOf(name, backend) !== profile)
|
|
26170
|
+
continue;
|
|
26171
|
+
const binding = this.webModelBinding(backend, name);
|
|
26172
|
+
if (binding?.scoped)
|
|
26173
|
+
settle(this.discoverModels(backend, name, binding, { afterSignIn: true }));
|
|
26174
|
+
}
|
|
26175
|
+
}
|
|
25969
26176
|
/** Maintain discovery after committed config changes; a model-field read remains passive. */
|
|
25970
26177
|
probeChangedCliEnvs(previous) {
|
|
25971
26178
|
const signature = (fleet, name) => {
|
|
@@ -25980,11 +26187,7 @@ export class FleetManager {
|
|
|
25980
26187
|
continue;
|
|
25981
26188
|
const backend = this.backendNameForInstance(name);
|
|
25982
26189
|
const binding = this.webModelBinding(backend, name);
|
|
25983
|
-
|
|
25984
|
-
// never publish the ambient account's models under that profile (#3526 / D7). (AGEND-119: agy now HAS
|
|
25985
|
-
// named accounts, but `agy models` is not run with the account's folder, so its answer would still be the
|
|
25986
|
-
// default account's: only a CLI whose profile is a variable the probe inherits is discovered under one.)
|
|
25987
|
-
if (!binding || (binding.profile && (!credentialHomeSpec(backend) || credentialHomeSpec(backend).kind === "launch-argument")))
|
|
26190
|
+
if (!binding || !this.modelDiscoverable(backend, binding))
|
|
25988
26191
|
continue;
|
|
25989
26192
|
// A description/defaults save can retire a scoped answer's full binding even
|
|
25990
26193
|
// though its account signature is unchanged. Keep the conservative fence and
|
|
@@ -25992,10 +26195,8 @@ export class FleetManager {
|
|
|
25992
26195
|
if (previous && signature(previous, name) === signature(this.fleetConfig, name)
|
|
25993
26196
|
&& (!binding.scoped || this.webModelEnv(backend, name) || this.webModelRefreshes.has(binding.key)))
|
|
25994
26197
|
continue;
|
|
25995
|
-
const work = binding
|
|
25996
|
-
|
|
25997
|
-
: this.probeBackendBounded(backend, { profile: binding.profile });
|
|
25998
|
-
void work.catch(err => this.logger.debug({ backend, name, err }, "Background model discovery failed"));
|
|
26198
|
+
const work = this.discoverModels(backend, name, binding);
|
|
26199
|
+
void work?.catch(err => this.logger.debug({ backend, name, err }, "Background model discovery failed"));
|
|
25999
26200
|
}
|
|
26000
26201
|
}
|
|
26001
26202
|
/** Best-effort model list for `/model`: cached CLI env first, else live probe. Never throws. */
|
|
@@ -27209,11 +27410,22 @@ export class FleetManager {
|
|
|
27209
27410
|
return shapeWebModelCatalog(backend, env?.models ?? [], env?.apiModels ?? []);
|
|
27210
27411
|
}
|
|
27211
27412
|
/** Explicit, bounded vendor rediscovery. Never publish an answer under a different account/config/instance. */
|
|
27212
|
-
async refreshModelCatalogFor(backend, instance, selection) {
|
|
27413
|
+
async refreshModelCatalogFor(backend, instance, selection, opts = {}) {
|
|
27213
27414
|
const binding = this.webModelBinding(backend, instance, selection);
|
|
27214
27415
|
if (!binding || this.shuttingDown)
|
|
27215
27416
|
return { models: [], refreshed: false };
|
|
27216
27417
|
const pending = this.webModelRefreshes.get(binding.key);
|
|
27418
|
+
if (pending && opts.afterSignIn) {
|
|
27419
|
+
// A sign-in changes the credentials, not the binding key, so a flight started before it is answering as the signed-out
|
|
27420
|
+
// account. Join it for admission (the worker limit), then read once more as the signed-in one; sign-ins that land on the
|
|
27421
|
+
// same flight meet in that one read (the second finds the first's flight).
|
|
27422
|
+
return pending.catch(() => null).then(() => {
|
|
27423
|
+
const next = this.webModelBinding(backend, instance, selection);
|
|
27424
|
+
if (next?.key !== binding.key)
|
|
27425
|
+
return { models: [], refreshed: false };
|
|
27426
|
+
return this.refreshModelCatalogFor(backend, instance, selection);
|
|
27427
|
+
});
|
|
27428
|
+
}
|
|
27217
27429
|
if (pending)
|
|
27218
27430
|
return pending;
|
|
27219
27431
|
const epoch = this.cliEnvProbeEpoch;
|
|
@@ -27231,7 +27443,11 @@ export class FleetManager {
|
|
|
27231
27443
|
return { models: this.modelCatalogFor(backend, instance, selection), refreshed: false };
|
|
27232
27444
|
if (this.webModelCatalogs.size >= 64)
|
|
27233
27445
|
this.webModelCatalogs.delete(this.webModelCatalogs.keys().next().value);
|
|
27446
|
+
const listed = (models) => models.map(m => m.id).join("\0");
|
|
27447
|
+
const before = listed(this.webModelEnv(backend, instance, selection)?.models ?? []);
|
|
27234
27448
|
this.webModelCatalogs.set(binding.key, { ...result, backend, probedAt: Date.now() });
|
|
27449
|
+
if (listed(result.models) !== before)
|
|
27450
|
+
this.announceModels(backend);
|
|
27235
27451
|
return { models: this.modelCatalogFor(backend, instance, selection), refreshed: true };
|
|
27236
27452
|
}).finally(() => { if (this.webModelRefreshes.get(binding.key) === work)
|
|
27237
27453
|
this.webModelRefreshes.delete(binding.key); });
|