@songsid/agend 2.3.5-alpha.6 → 2.3.5-alpha.7
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 +11 -0
- package/dist/auth-api.js.map +1 -1
- package/dist/authority/web-authority.d.ts +13 -0
- package/dist/authority/web-authority.js +12 -0
- package/dist/authority/web-authority.js.map +1 -1
- package/dist/backend/claude-code.js +47 -9
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/kiro.js +1 -1
- package/dist/backend/kiro.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/access-manager.d.ts +1 -6
- package/dist/channel/access-manager.js +4 -94
- package/dist/channel/access-manager.js.map +1 -1
- package/dist/channel/adapters/discord.d.ts +0 -2
- package/dist/channel/adapters/discord.js +0 -8
- package/dist/channel/adapters/discord.js.map +1 -1
- package/dist/channel/adapters/telegram.d.ts +0 -3
- package/dist/channel/adapters/telegram.js +1 -30
- package/dist/channel/adapters/telegram.js.map +1 -1
- package/dist/channel/types.d.ts +0 -2
- package/dist/cli.js +1 -19
- package/dist/cli.js.map +1 -1
- package/dist/fleet-manager.d.ts +59 -1
- package/dist/fleet-manager.js +336 -28
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/concepts/SKILL.md +22 -7
- package/dist/general-knowledge/steering/core-rules.md +6 -4
- package/dist/hub/buttons.js +4 -2
- package/dist/hub/buttons.js.map +1 -1
- package/dist/hub/catalog.d.ts +1 -1
- package/dist/hub/catalog.js +82 -15
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/compose/server.d.ts +4 -1
- package/dist/hub/compose/server.js +29 -3
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/directory/directory.d.ts +1 -1
- package/dist/hub/directory/directory.js +32 -23
- package/dist/hub/directory/directory.js.map +1 -1
- package/dist/hub/directory/index.d.ts +1 -1
- package/dist/hub/directory/types.d.ts +8 -2
- package/dist/hub/directory/types.js.map +1 -1
- package/dist/hub/group-policy/admin-context.d.ts +23 -0
- package/dist/hub/group-policy/admin-context.js +52 -0
- package/dist/hub/group-policy/admin-context.js.map +1 -0
- package/dist/hub/group-policy/admin-dto.d.ts +235 -0
- package/dist/hub/group-policy/admin-dto.js +55 -0
- package/dist/hub/group-policy/admin-dto.js.map +1 -0
- package/dist/hub/group-policy/admin-inventory.d.ts +24 -0
- package/dist/hub/group-policy/admin-inventory.js +72 -0
- package/dist/hub/group-policy/admin-inventory.js.map +1 -0
- package/dist/hub/group-policy/admin-read.d.ts +21 -0
- package/dist/hub/group-policy/admin-read.js +90 -0
- package/dist/hub/group-policy/admin-read.js.map +1 -0
- package/dist/hub/group-policy/authorization.d.ts +43 -0
- package/dist/hub/group-policy/authorization.js +170 -0
- package/dist/hub/group-policy/authorization.js.map +1 -0
- package/dist/hub/group-policy/resources.d.ts +9 -1
- package/dist/hub/group-policy/resources.js +30 -5
- package/dist/hub/group-policy/resources.js.map +1 -1
- package/dist/hub/group-policy/store.d.ts +8 -2
- package/dist/hub/group-policy/store.js +9 -3
- package/dist/hub/group-policy/store.js.map +1 -1
- package/dist/hub/http/compose.js +6 -7
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/core.d.ts +23 -3
- package/dist/hub/http/core.js +138 -5
- package/dist/hub/http/core.js.map +1 -1
- package/dist/hub/http/deps.d.ts +3 -0
- package/dist/hub/policy.d.ts +3 -1
- package/dist/hub/policy.js +13 -6
- package/dist/hub/policy.js.map +1 -1
- package/dist/hub/rooms.d.ts +1 -0
- package/dist/hub/rooms.js +76 -26
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/sessions.js +2 -1
- package/dist/hub/sessions.js.map +1 -1
- package/dist/hub/types.d.ts +2 -0
- package/dist/locale.js +26 -20
- package/dist/locale.js.map +1 -1
- package/dist/runtime-api.js +10 -2
- package/dist/runtime-api.js.map +1 -1
- package/dist/settings-api.js +3 -2
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-change.d.ts +10 -0
- package/dist/settings-change.js +17 -1
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-confirmation.d.ts +25 -1
- package/dist/settings-confirmation.js +11 -3
- package/dist/settings-confirmation.js.map +1 -1
- package/dist/settings-effect.js +18 -6
- package/dist/settings-effect.js.map +1 -1
- package/dist/settings-http-confirmation.d.ts +21 -0
- package/dist/settings-http-confirmation.js +74 -3
- package/dist/settings-http-confirmation.js.map +1 -1
- package/dist/structured-signin.js +3 -1
- package/dist/structured-signin.js.map +1 -1
- package/dist/tips.js +4 -4
- package/dist/tips.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.js.map +1 -1
- package/dist/ui/accounts-keepalive.js +4 -3
- package/dist/ui/accounts-manage.js +2 -2
- package/dist/ui/accounts-view.js +18 -7
- package/dist/ui/backend-signin.js +12 -3
- package/dist/ui/general-location.js +28 -14
- package/dist/ui/hub-chat-store.js +2 -1
- package/dist/ui/hub-grant-strings.js +13 -0
- package/dist/ui/hub-owner-strings.js +6 -2
- package/dist/ui/hub-strings.js +4 -2
- package/dist/ui/panel-hub.js +68 -23
- package/dist/ui/panel-log.js +2 -2
- package/dist/ui/panel-runtimes.js +14 -6
- package/dist/ui/panel-settings.js +7 -19
- package/dist/ui/runtime-cli-install.js +24 -4
- package/dist/ui/settings-confirm.js +28 -0
- package/dist/ui/settings-devices.js +6 -10
- package/dist/ui/settings-hub-membership.js +6 -6
- package/dist/ui/settings-hub-section.js +35 -0
- package/dist/ui/settings-hub.js +6 -2
- package/dist/ui/settings-layout.js +6 -2
- package/dist/ui/settings-named-test.js +2 -2
- package/dist/ui/settings-outside.js +1 -1
- package/dist/ui/settings-quota-notice.js +8 -6
- package/dist/ui/settings-registry.js +3 -0
- package/dist/ui/settings-strings.js +6 -6
- package/dist/ui/shared/app-i18n.js +4 -2
- package/dist/ui/shared/app-route.js +1 -1
- package/dist/ui/shared/app-shell.js +102 -5
- package/dist/ui/shared/app.css +16 -0
- package/dist/ui/shared/chat-strings.js +8 -8
- package/dist/ui/shared/hub-owner.css +2 -2
- package/dist/ui/shared/hub-signin.css +24 -0
- package/dist/ui/shared/view-strings.js +4 -4
- package/dist/ui/structured-signin.js +16 -8
- package/dist/usage/providers.d.ts +1 -0
- package/dist/usage/providers.js +13 -9
- package/dist/usage/providers.js.map +1 -1
- package/dist/web-api.d.ts +5 -0
- package/dist/web-api.js +15 -6
- package/dist/web-api.js.map +1 -1
- package/dist/web-remote-access.d.ts +6 -0
- package/dist/web-remote-access.js +10 -1
- package/dist/web-remote-access.js.map +1 -1
- package/dist/web-shell-routes.d.ts +1 -1
- package/dist/web-shell-routes.js +1 -1
- package/dist/web-shell-routes.js.map +1 -1
- package/dist/windows-cli-api.d.ts +8 -0
- package/dist/windows-cli-api.js +10 -0
- package/dist/windows-cli-api.js.map +1 -1
- package/package.json +2 -1
package/dist/fleet-manager.js
CHANGED
|
@@ -335,7 +335,7 @@ import { guestSessionPolicy, localSessionPolicy, sessionVia, tokenEpoch, WebSess
|
|
|
335
335
|
import { WebNotices, WEB_NOTICES_FILE } from "./web-notices.js";
|
|
336
336
|
import { DeviceLoginRequests } from "./web-device-login.js";
|
|
337
337
|
import { isOutsideLinkOwner, OUTSIDE_LINK_OWNER, OUTSIDE_LINK_RETRY_MS, OUTSIDE_OWN_CLOSES, outsideDuration, outsideTimer, TOTP_STEP_SECONDS, WEB_REMOTE_ACCESS_FILE, WebRemoteAccess } from "./web-remote-access.js";
|
|
338
|
-
import { authorityNow, evaluateWebAuthority, HOST_OPERATOR, VERIFIED_SESSION_HOURS, webAuthorityPolicy } from "./authority/web-authority.js";
|
|
338
|
+
import { authorityNow, evaluateWebAuthority, HOST_OPERATOR, hostSessionHere, VERIFIED_SESSION_HOURS, webAuthorityPolicy } from "./authority/web-authority.js";
|
|
339
339
|
import { AuthorityStateStore } from "./authority/authority-state.js";
|
|
340
340
|
import { SessionAuthorizations } from "./authority/session-authorizations.js";
|
|
341
341
|
import { SessionAuthorizationRequests } from "./web-session-authorization.js";
|
|
@@ -2452,6 +2452,8 @@ export class FleetManager {
|
|
|
2452
2452
|
startupDashboard = null;
|
|
2453
2453
|
adapterState = new Map();
|
|
2454
2454
|
adapterRetryInFlight = new Map();
|
|
2455
|
+
/** #3365 review P2: connections whose adapter could not be confirmed stopped — none is admitted for them until a restart. */
|
|
2456
|
+
adapterTeardownUnknown = new Set();
|
|
2455
2457
|
/** Web Settings secret rotation is deliberately separate from reconnect
|
|
2456
2458
|
* recovery: a rotation must build a fresh provider client with the new token,
|
|
2457
2459
|
* and stale callbacks from the old client must not win. */
|
|
@@ -3160,6 +3162,7 @@ export class FleetManager {
|
|
|
3160
3162
|
&& sessions.isCurrent(record, tokenEpoch(this.webToken)) && (!exposure || exposure.isCurrent()) };
|
|
3161
3163
|
}, baseline: () => baselines.read(), snapshot: () => baselines.snapshot(),
|
|
3162
3164
|
selfConfirm: (req, id) => this.settingsSelfConfirmation(store, req, id),
|
|
3165
|
+
totp: { state: (req, id) => this.settingsTotpState(store, req, id), confirm: (req, id, code, digest) => this.settingsTotpConfirm(store, req, id, code, digest) },
|
|
3163
3166
|
directAgentCreation: true,
|
|
3164
3167
|
job: async (id) => {
|
|
3165
3168
|
const settlement = this.settingsJobSettlements.get(id);
|
|
@@ -3195,13 +3198,40 @@ export class FleetManager {
|
|
|
3195
3198
|
const auth = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
3196
3199
|
if (auth.kind !== "ok")
|
|
3197
3200
|
return null;
|
|
3201
|
+
// D3 (decision bcbb541f): on a fleet with a chat connection, a change no General can take a card for would wait for
|
|
3202
|
+
// `agend settings confirm` on the host. The host's own session, used on this computer (hostSessionHere: its code came
|
|
3203
|
+
// from `agend web` here; never bare loopback), carries that same trust — it confirms at Save, with no click added. A
|
|
3204
|
+
// change a General can take keeps its card (D1). Asked again at execution: the same session, still here, still no card.
|
|
3205
|
+
// (A web-only fleet's host operator has its own rule below, with its revocable authorization.) The noSelfConfirm changes
|
|
3206
|
+
// the leader ruled on are included: the outward Hub changes (hostLocalConfirm) and a link option turned on
|
|
3207
|
+
// (hostSessionOnly, cid-d3) — this session is exactly the one those allow.
|
|
3208
|
+
// "No card": none could be posted now, or the one tried could not be (posting failed or ran out — the view says
|
|
3209
|
+
// host_cli; #3362 review N1).
|
|
3210
|
+
const noCard = () => !this.settingsCardPossible(store, id) || store.inspect(id)?.confirmation.kind === "host_cli";
|
|
3211
|
+
if (!this.isWebOnlyFleet() && hostSessionHere(auth.session, req) && noCard()
|
|
3212
|
+
&& (store.selfConfirmable(id) || store.hostLocalConfirmable(id) || store.hostSessionConfirmable(id))) {
|
|
3213
|
+
// A card that could not be posted stays unposted (no card is attached later): fixed now, not re-read at execution,
|
|
3214
|
+
// where the store has already marked the change as confirmed from the web.
|
|
3215
|
+
const handle = auth.session.handle, postFailed = store.inspect(id)?.confirmation.kind === "host_cli";
|
|
3216
|
+
const here = () => {
|
|
3217
|
+
const now = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
3218
|
+
return now.kind === "ok" && now.session.handle === handle && hostSessionHere(now.session, req) && !this.isWebOnlyFleet();
|
|
3219
|
+
};
|
|
3220
|
+
return {
|
|
3221
|
+
label: t("settings_confirm.host_operator_label"),
|
|
3222
|
+
current: () => here() && (postFailed || !this.settingsCardPossible(store, id)),
|
|
3223
|
+
done: view => { this.logger.info({ id: view.id, state: view.state }, "Settings change confirmed from the web by this computer's admin (no General could take it)"); },
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3198
3226
|
// #2453 (§0.2): never over the public link — not even a named-link session that is web-verified there. #3008: except
|
|
3199
3227
|
// this computer's admin signed in from outside (the authenticator's code, over the link connections from outside
|
|
3200
3228
|
// opened): the web-only fleet's owner, judged below by the same authority as here (hostOperator).
|
|
3201
3229
|
if (gatewayRequestContext(req) && auth.session.remote !== "totp")
|
|
3202
3230
|
return null;
|
|
3203
|
-
// …and never a change that turns the named-link option on: that one needs a General's card or the host.
|
|
3204
|
-
|
|
3231
|
+
// …and never a change that turns the named-link option on: that one needs a General's card or the host. B2b (the leader's
|
|
3232
|
+
// ruling on #3352 F1; threat model A 64a289a0): the outward Hub changes (hostLocalConfirm) are the one exception — for
|
|
3233
|
+
// the host operator's own local session only (below).
|
|
3234
|
+
if (!store.selfConfirmable(id) && !store.hostLocalConfirmable(id) && !store.hostSessionConfirmable(id))
|
|
3205
3235
|
return null;
|
|
3206
3236
|
const record = auth.session, gateway = !!gatewayRequestContext(req), peer = webPeerOf(req);
|
|
3207
3237
|
const verified = () => {
|
|
@@ -3216,13 +3246,19 @@ export class FleetManager {
|
|
|
3216
3246
|
// change — the trust `agend settings confirm` has here; there is no account to be an admin of and no General to
|
|
3217
3247
|
// ask. Asked again at execution: still the host operator now (this computer, not revoked or run out), still web-only.
|
|
3218
3248
|
const hostOperator = (a) => !!a && a.adapter_id === HOST_OPERATOR.adapterId && a.user_id === HOST_OPERATOR.userId && this.isWebOnlyFleet();
|
|
3219
|
-
|
|
3249
|
+
// The host operator's own LOCAL session: its host session (the bootstrap or launch link), over loopback with no
|
|
3250
|
+
// forwarding header and no gateway (classifyWebPeer, as #3345). Only that one may Apply-now an outward Hub change, or a
|
|
3251
|
+
// link option turned on (hostSessionOnly — the outside sign-in, a gateway, never may).
|
|
3252
|
+
const hostLocal = () => hostSessionHere(record, req);
|
|
3253
|
+
if (hostOperator(actor) && (store.selfConfirmable(id) || hostLocal())) {
|
|
3220
3254
|
return {
|
|
3221
3255
|
label: t("settings_confirm.host_operator_label"),
|
|
3222
|
-
current: () => hostOperator(verified()),
|
|
3256
|
+
current: () => hostOperator(verified()) && (store.selfConfirmable(id) || hostLocal()),
|
|
3223
3257
|
done: view => { this.logger.info({ id: view.id, state: view.state }, "Settings change confirmed from the web by this computer's admin"); },
|
|
3224
3258
|
};
|
|
3225
3259
|
}
|
|
3260
|
+
if (!store.selfConfirmable(id))
|
|
3261
|
+
return null;
|
|
3226
3262
|
const chat = this.settingsChatAuthority(store, id);
|
|
3227
3263
|
if (!chat)
|
|
3228
3264
|
return null;
|
|
@@ -3244,6 +3280,99 @@ export class FleetManager {
|
|
|
3244
3280
|
done: view => this.settingsWebConfirmedNotice(view, affected, name, chat.platform),
|
|
3245
3281
|
};
|
|
3246
3282
|
}
|
|
3283
|
+
/**
|
|
3284
|
+
* alpha.6 feedback #2c — the user's decision hmsg-468cc290 (option A; decisions 28c2d3a3/0471da59 keep the second factor): on a
|
|
3285
|
+
* web-only fleet, a pending change can be confirmed on THIS computer's own page with the owner's authenticator code, by a
|
|
3286
|
+
* local admin session that is not the host operator (who already has "Apply now"), on this computer or the LAN. Never over
|
|
3287
|
+
* a link (named or quick), never a guest; only a change that can be self-confirmed at all (a named-link opener cannot); the code is checked by
|
|
3288
|
+
* the same store as signing in from outside (#3008): each time step once, the fleet-wide wrong-code limit. Asked again at
|
|
3289
|
+
* execution (`current`): the same session, still an admin here (this computer or the LAN), the fleet still web-only, the
|
|
3290
|
+
* same app still set up (not replaced, nor removed and set up again). Audited by the store under its own label; a correct and a refused use are logged.
|
|
3291
|
+
*/
|
|
3292
|
+
settingsTotpSession(req) {
|
|
3293
|
+
// Who is offered the code (the leader's ruling, (b) — Fable's view; threat model 64a289a0): on a web-only fleet, an admin
|
|
3294
|
+
// session with no chat account, on this computer (loopback, no forwarding header) or on the LAN — any such session not
|
|
3295
|
+
// otherwise allowed (a local non-host session may be another OS user). NEVER over a link, named or quick: "over a link" is
|
|
3296
|
+
// the gateway's own context, never a peer address (both links are tunnels arriving from 127.0.0.1). Never a guest.
|
|
3297
|
+
// The code is the authority; the session only carries it (#3352 security review, point 4).
|
|
3298
|
+
const allowed = () => {
|
|
3299
|
+
if (!this.isWebOnlyFleet())
|
|
3300
|
+
return null;
|
|
3301
|
+
const auth = authorizeSession(req, this.webToken, this.webSessions, { touch: false });
|
|
3302
|
+
if (auth.kind !== "ok")
|
|
3303
|
+
return null;
|
|
3304
|
+
const s = auth.session, gateway = gatewayRequestContext(req);
|
|
3305
|
+
if (s.tier !== "admin" || s.owner)
|
|
3306
|
+
return null;
|
|
3307
|
+
if (gateway)
|
|
3308
|
+
return null;
|
|
3309
|
+
const peer = webPeerOf(req);
|
|
3310
|
+
return s.surface === "local" && (peer === "loopback" || peer === "lan") ? { handle: s.handle } : null;
|
|
3311
|
+
};
|
|
3312
|
+
const first = allowed();
|
|
3313
|
+
if (!first)
|
|
3314
|
+
return null;
|
|
3315
|
+
return { handle: first.handle, current: () => { const now = allowed(); return !!now && now.handle === first.handle && !!this.webRemoteAccess()?.enrolled; } };
|
|
3316
|
+
}
|
|
3317
|
+
settingsTotpState(store, req, id) {
|
|
3318
|
+
// A link option turned on (hostSessionOnly): never a code. On a web-only fleet (no General to send it to), any session
|
|
3319
|
+
// but the host's own here is told in plain words to do it in the browser on the AgEnD computer.
|
|
3320
|
+
if (store.hostSessionConfirmable(id))
|
|
3321
|
+
return this.isWebOnlyFleet() && !this.settingsSelfConfirmation(store, req, id) ? "host_browser" : null;
|
|
3322
|
+
if (!(store.selfConfirmable(id) || store.hostLocalConfirmable(id)))
|
|
3323
|
+
return null;
|
|
3324
|
+
// Over a link (web-only fleet): never a code here — the card says to do it in the host computer's own browser, or in General.
|
|
3325
|
+
if (gatewayRequestContext(req))
|
|
3326
|
+
return this.isWebOnlyFleet() && !this.settingsSelfConfirmation(store, req, id) ? "on_host" : null;
|
|
3327
|
+
if (!this.settingsTotpSession(req))
|
|
3328
|
+
return null;
|
|
3329
|
+
if (this.settingsSelfConfirmation(store, req, id))
|
|
3330
|
+
return null; // "Apply now" already (the host operator here)
|
|
3331
|
+
return this.webRemoteAccess()?.enrolled ? "ready" : "not_set_up";
|
|
3332
|
+
}
|
|
3333
|
+
settingsTotpConfirm(store, req, id, code, digest) {
|
|
3334
|
+
if (!(store.selfConfirmable(id) || store.hostLocalConfirmable(id)) || this.settingsSelfConfirmation(store, req, id))
|
|
3335
|
+
return { error: "not_here" };
|
|
3336
|
+
const local = this.settingsTotpSession(req), access = this.webRemoteAccess();
|
|
3337
|
+
if (!local || !local.current() || !access?.enrolled)
|
|
3338
|
+
return { error: "not_here" };
|
|
3339
|
+
// #3352 security review, point 2: the code confirms exactly the change the page showed — checked before the code is.
|
|
3340
|
+
if (digest !== store.confirmDigest(id))
|
|
3341
|
+
return { error: "changed" };
|
|
3342
|
+
const shown = store.inspectHost(id)?.view.summary ?? [];
|
|
3343
|
+
// #3355 review (Prism P2): the code's authority is the app it came from. Bound to that enrollment through execution — an
|
|
3344
|
+
// app replaced, or removed and set up again, while the change waits ends it, for good (a later match never revives it).
|
|
3345
|
+
const enrollment = access.enrollment;
|
|
3346
|
+
const v = access.verify(code);
|
|
3347
|
+
if (v.kind === "ok") {
|
|
3348
|
+
if (!enrollment)
|
|
3349
|
+
return { error: "not_here" };
|
|
3350
|
+
this.logger.info({ id, handle: local.handle }, "Settings change confirmed on this computer with the authenticator code");
|
|
3351
|
+
let lost = false;
|
|
3352
|
+
const current = () => {
|
|
3353
|
+
if (!lost && !(local.current() && this.webRemoteAccess()?.enrollment === enrollment))
|
|
3354
|
+
lost = true;
|
|
3355
|
+
return !lost;
|
|
3356
|
+
};
|
|
3357
|
+
return { label: t("settings_confirm.totp_label"), current, audit: { confirmed_with: "authenticator_code", summary: shown },
|
|
3358
|
+
done: view => { this.logger.info({ id: view.id, state: view.state }, "Settings change confirmed with the authenticator code: done"); } };
|
|
3359
|
+
}
|
|
3360
|
+
if (v.kind === "paused")
|
|
3361
|
+
return { error: "paused", retryAfterMs: v.retryAfterMs };
|
|
3362
|
+
if (v.kind === "not_enrolled")
|
|
3363
|
+
return { error: "not_here" };
|
|
3364
|
+
if (v.kind === "unavailable")
|
|
3365
|
+
return { error: "unavailable" };
|
|
3366
|
+
if (v.skewSteps !== null)
|
|
3367
|
+
this.logger.warn({ offsetSeconds: v.skewSteps * TOTP_STEP_SECONDS }, "A wrong authenticator code matched a nearby time step: this computer's clock may be off");
|
|
3368
|
+
this.logger.info({ id, handle: local.handle }, "Settings change: a wrong authenticator code was refused");
|
|
3369
|
+
if (v.paused) {
|
|
3370
|
+
this.logger.warn({ waitMs: v.retryAfterMs }, "Authenticator codes paused after wrong codes");
|
|
3371
|
+
this.recordWebNotice("fleet", t("outside.notice_paused", outsideDuration(v.retryAfterMs), v.wrong));
|
|
3372
|
+
return { error: "paused", retryAfterMs: v.retryAfterMs };
|
|
3373
|
+
}
|
|
3374
|
+
return { error: "wrong" };
|
|
3375
|
+
}
|
|
3247
3376
|
/**
|
|
3248
3377
|
* alpha.2 (M-2300; #2973's agent requests, junsion's §6): on a fleet with no chat connection there is no General to
|
|
3249
3378
|
* post an agent's Windows request in — it waited for `agend settings confirm` on the host. Its owner (decision
|
|
@@ -3619,13 +3748,25 @@ export class FleetManager {
|
|
|
3619
3748
|
return updateNativeWindowsInstance(this, name, edit, () => allowed() && sameTarget() && (execution.completed || execution.current()), execution);
|
|
3620
3749
|
} });
|
|
3621
3750
|
}
|
|
3751
|
+
/**
|
|
3752
|
+
* D3: whether a General could take this change's confirmation card now — the same authority and routes
|
|
3753
|
+
* promptSettingsChange posts by. False: it would wait for the host's command (confirmation kind host_cli).
|
|
3754
|
+
*/
|
|
3755
|
+
settingsCardPossible(store, id) {
|
|
3756
|
+
const authority = this.settingsChatAuthority(store, id);
|
|
3757
|
+
if (!authority)
|
|
3758
|
+
return false;
|
|
3759
|
+
const excluded = new Set(store.affectedConnections(id));
|
|
3760
|
+
return Object.keys(this.fleetConfig?.instances ?? {}).some(name => !!this.settingsGeneralRoute(name, authority.platform, excluded));
|
|
3761
|
+
}
|
|
3622
3762
|
async promptSettingsChange(store, view) {
|
|
3623
3763
|
const generation = this.settingsGeneration;
|
|
3624
3764
|
const authority = this.settingsChatAuthority(store, view.id);
|
|
3625
3765
|
if (!authority) {
|
|
3626
3766
|
this.logger.info({ id: view.id }, "Settings authority is unknown or spans platforms; host CLI confirmation required");
|
|
3627
|
-
return;
|
|
3767
|
+
return this.settingsNoCardReason(null, [...store.affectedConnections(view.id), ...(store.authorityOf(view.id)?.connections ?? [])], false);
|
|
3628
3768
|
}
|
|
3769
|
+
let attempted = false;
|
|
3629
3770
|
const excluded = new Set(store.affectedConnections(view.id));
|
|
3630
3771
|
for (const name of Object.keys(this.fleetConfig?.instances ?? {})) {
|
|
3631
3772
|
const route = this.settingsGeneralRoute(name, authority.platform, excluded);
|
|
@@ -3638,6 +3779,7 @@ export class FleetManager {
|
|
|
3638
3779
|
&& route.current() && authority.current();
|
|
3639
3780
|
if (!current())
|
|
3640
3781
|
continue;
|
|
3782
|
+
attempted = true;
|
|
3641
3783
|
try {
|
|
3642
3784
|
const posted = this.postNonceButtonPromptOrThrow({ prefix: "settings-confirm:", alertType: "clear_confirm",
|
|
3643
3785
|
instanceName: name, adapterId, adapter, chatId, threadId: topic,
|
|
@@ -3681,6 +3823,39 @@ export class FleetManager {
|
|
|
3681
3823
|
}
|
|
3682
3824
|
// No platform confirmation was reachable. Host inspection is still required.
|
|
3683
3825
|
this.logger.info({ id: view.id }, "Settings change requires local `agend settings confirm <id>`");
|
|
3826
|
+
return this.settingsNoCardReason(authority.platform, store.affectedConnections(view.id), attempted);
|
|
3827
|
+
}
|
|
3828
|
+
/**
|
|
3829
|
+
* alpha.6 feedback #2c: why no General could take a change's confirm card, so the page says what is missing in plain words
|
|
3830
|
+
* (the user's decision hmsg-77256f66: never "type a host command"). `platform` null: the authority is unknown or spans
|
|
3831
|
+
* platforms. `attempted`: a General route existed and posting to it failed.
|
|
3832
|
+
*/
|
|
3833
|
+
settingsNoCardReason(platform, affected, attempted) {
|
|
3834
|
+
const channels = this.fleetConfig?.channels ?? (this.fleetConfig?.channel ? [this.fleetConfig.channel] : []);
|
|
3835
|
+
if (!channels.length)
|
|
3836
|
+
return "no_chat";
|
|
3837
|
+
if (attempted)
|
|
3838
|
+
return "post_failed";
|
|
3839
|
+
// No General at all comes first: then there is no authority to resolve either (the primary General's is unknown).
|
|
3840
|
+
if (!Object.values(this.fleetConfig?.instances ?? {}).some(cfg => cfg?.general_topic === true))
|
|
3841
|
+
return "no_general";
|
|
3842
|
+
// #3352 review N1: "spans platforms" only when it does — the connections the change touches are on more than one platform.
|
|
3843
|
+
// Any other unresolved authority (a duplicated or missing connection id): no specific reason; the page says the general one.
|
|
3844
|
+
if (!platform) {
|
|
3845
|
+
const touched = new Set(affected);
|
|
3846
|
+
const types = new Set(channels.filter(ch => touched.has(ch.id ?? ch.type)).map(ch => ch.type));
|
|
3847
|
+
return types.size > 1 ? "cross_platform" : undefined;
|
|
3848
|
+
}
|
|
3849
|
+
const excluded = new Set(affected);
|
|
3850
|
+
const generals = Object.keys(this.fleetConfig?.instances ?? {}).filter(name => this.fleetConfig?.instances[name]?.general_topic === true)
|
|
3851
|
+
.filter(name => { const id = this.getInstanceAdapterId(name), adapter = this.getAdapterForInstance(name); return !!id && !!adapter && adapter.type === platform && !excluded.has(id); });
|
|
3852
|
+
if (!generals.length)
|
|
3853
|
+
return "no_general";
|
|
3854
|
+
if (!generals.some(name => this.adapterState.get(this.getInstanceAdapterId(name))?.status === "connected"))
|
|
3855
|
+
return "chat_disconnected";
|
|
3856
|
+
if (!generals.some(name => !!this.getGroupIdForInstance(name) && String(this.fleetConfig?.instances[name]?.topic_id ?? "") !== ""))
|
|
3857
|
+
return "no_topic";
|
|
3858
|
+
return "post_failed";
|
|
3684
3859
|
}
|
|
3685
3860
|
kiroMigrateDeps() {
|
|
3686
3861
|
let token;
|
|
@@ -10368,7 +10543,8 @@ export class FleetManager {
|
|
|
10368
10543
|
// from an earlier start) and no AgEnD tmux server was ever recorded — gets the one own-tmux notice. A cleanly stopped
|
|
10369
10544
|
// 2.3 fleet leaves no window ids (no migration journal), so this, not the journal, is the evidence. Read before any
|
|
10370
10545
|
// agent of this start writes its own.
|
|
10371
|
-
this
|
|
10546
|
+
// Persisted before this start records server.json (see ownTmuxStartDecision).
|
|
10547
|
+
this.ownTmuxUpgradedHome = FleetManager.ownTmuxStartDecision(getAgendHome(), bundled.previous, this.logger);
|
|
10372
10548
|
this.tmuxHold = null;
|
|
10373
10549
|
TmuxManager.setHold(null);
|
|
10374
10550
|
if (bundled) {
|
|
@@ -11339,6 +11515,8 @@ export class FleetManager {
|
|
|
11339
11515
|
const state = this.adapterState.get(adapterId);
|
|
11340
11516
|
if (this.shuttingDown || !state || state.retryTimer || this.adapterRetryInFlight.has(adapterId))
|
|
11341
11517
|
return;
|
|
11518
|
+
if (this.adapterTeardownUnknown.has(adapterId))
|
|
11519
|
+
return; // #3365 review P2: held until a restart, never retried
|
|
11342
11520
|
const delay = Math.min(INITIAL_DELAY_MS * Math.pow(2, Math.min(state.retryCount, 6)), MAX_DELAY_MS);
|
|
11343
11521
|
this.logger.info({ adapterId, attempt: state.retryCount + 1, delay_ms: delay }, "Scheduling adapter retry");
|
|
11344
11522
|
const timer = setTimeout(() => {
|
|
@@ -11593,6 +11771,8 @@ export class FleetManager {
|
|
|
11593
11771
|
assertSettingsLease(`connection:${this.dataDir}:${ownerId}`, operation?.owner);
|
|
11594
11772
|
if (this.shuttingDown || this.settingsGeneration !== generation)
|
|
11595
11773
|
throw new Error("adapter admission superseded");
|
|
11774
|
+
if (this.adapterTeardownUnknown.has(ownerId))
|
|
11775
|
+
throw new Error("an earlier adapter for this connection could not be confirmed stopped — restart AgEnD");
|
|
11596
11776
|
};
|
|
11597
11777
|
check();
|
|
11598
11778
|
const botToken = process.env[channelConfig.bot_token_env];
|
|
@@ -11752,6 +11932,8 @@ export class FleetManager {
|
|
|
11752
11932
|
assertSettingsLease(`connection:${this.dataDir}:${ownerId}`, operation?.owner);
|
|
11753
11933
|
if (this.shuttingDown || this.settingsGeneration !== generation)
|
|
11754
11934
|
throw new Error("adapter admission superseded");
|
|
11935
|
+
if (this.adapterTeardownUnknown.has(ownerId))
|
|
11936
|
+
throw new Error("an earlier adapter for this connection could not be confirmed stopped — restart AgEnD");
|
|
11755
11937
|
};
|
|
11756
11938
|
check();
|
|
11757
11939
|
const botToken = process.env[channelConfig.bot_token_env];
|
|
@@ -16990,19 +17172,47 @@ export class FleetManager {
|
|
|
16990
17172
|
}
|
|
16991
17173
|
return names.some(n => ["output.log", "session-id"].some(f => existsSync(join(instancesDir, n, f))));
|
|
16992
17174
|
}
|
|
17175
|
+
/** Where an upgraded home's not-yet-dispatched own-tmux notice is kept across restarts; only a dispatch clears it. */
|
|
17176
|
+
static ownTmuxPendingPath(agendHome) { return join(agendHome, "tmux", "own-server-notice-pending"); }
|
|
17177
|
+
/**
|
|
17178
|
+
* Fleet start's decision, made before this start records server.json: an upgraded home is persisted as owing the
|
|
17179
|
+
* notice. A restart before the notice is dispatched (a slow first start; alpha.6 leg M on the real Mac) would otherwise
|
|
17180
|
+
* read the just-recorded server as "not an upgrade" and drop it.
|
|
17181
|
+
*/
|
|
17182
|
+
static ownTmuxStartDecision(agendHome, previous, logger) {
|
|
17183
|
+
const upgraded = FleetManager.ownTmuxUpgraded(agendHome, previous);
|
|
17184
|
+
if (upgraded)
|
|
17185
|
+
FleetManager.persistOwnTmuxPending(agendHome, logger);
|
|
17186
|
+
return upgraded;
|
|
17187
|
+
}
|
|
17188
|
+
/** Record that this home owes the own-tmux notice (unless it was already posted). */
|
|
17189
|
+
static persistOwnTmuxPending(agendHome, logger) {
|
|
17190
|
+
if (existsSync(join(agendHome, "tmux", "own-server-announced")))
|
|
17191
|
+
return;
|
|
17192
|
+
try {
|
|
17193
|
+
mkdirSync(join(agendHome, "tmux"), { recursive: true });
|
|
17194
|
+
writeFileSync(FleetManager.ownTmuxPendingPath(agendHome), `${new Date().toISOString()}\n`);
|
|
17195
|
+
}
|
|
17196
|
+
catch (err) {
|
|
17197
|
+
logger?.warn({ err }, "Could not record the pending own-tmux notice");
|
|
17198
|
+
}
|
|
17199
|
+
}
|
|
16993
17200
|
announceOwnTmux() {
|
|
16994
17201
|
const marker = join(getAgendHome(), "tmux", "own-server-announced");
|
|
17202
|
+
const pending = FleetManager.ownTmuxPendingPath(getAgendHome());
|
|
16995
17203
|
if (existsSync(marker))
|
|
16996
17204
|
return;
|
|
16997
17205
|
// Only a home an earlier AgEnD ran its agents in (on the system tmux) has something to be told (Fable #3312 N3):
|
|
16998
17206
|
// agent state from before this start and no recorded AgEnD tmux server (set at fleet start), or a migration journal
|
|
16999
17207
|
// (2.3 window ids found). A fresh home is marked without a notice.
|
|
17000
|
-
|
|
17208
|
+
// A pending notice persisted by an earlier start counts too: that start's server record must not hide the upgrade.
|
|
17209
|
+
const upgraded = this.ownTmuxUpgradedHome || existsSync(pending) || existsSync(join(getAgendHome(), "tmux-migration.json"));
|
|
17001
17210
|
if (upgraded && !this.notifyFleetError(t("tmux.own_server_notice"), { throttle: false }))
|
|
17002
17211
|
return;
|
|
17003
17212
|
try {
|
|
17004
17213
|
mkdirSync(dirname(marker), { recursive: true });
|
|
17005
17214
|
writeFileSync(marker, `${new Date().toISOString()}\n`);
|
|
17215
|
+
rmSync(pending, { force: true });
|
|
17006
17216
|
}
|
|
17007
17217
|
catch (err) {
|
|
17008
17218
|
this.logger.warn({ err }, "Could not record that the own-tmux notice was posted");
|
|
@@ -18617,8 +18827,12 @@ export class FleetManager {
|
|
|
18617
18827
|
const r = store.confirmEnrollment(owner.handle, code);
|
|
18618
18828
|
if (r === "ok") {
|
|
18619
18829
|
this.logger.info({ again: had }, "Authenticator app set up for connections from outside");
|
|
18620
|
-
if (had)
|
|
18830
|
+
if (had) {
|
|
18621
18831
|
this.endOutsideSessions();
|
|
18832
|
+
// #3327: an authenticator set up again is announced where the owner looks (web Notices on a web-only fleet), so a
|
|
18833
|
+
// set-up they did not make is noticed.
|
|
18834
|
+
this.notifyFleetError(t("outside.reenrolled_notice"));
|
|
18835
|
+
}
|
|
18622
18836
|
}
|
|
18623
18837
|
return r;
|
|
18624
18838
|
}
|
|
@@ -18628,8 +18842,11 @@ export class FleetManager {
|
|
|
18628
18842
|
if (!owner || !store || !owner.current())
|
|
18629
18843
|
return "not_here";
|
|
18630
18844
|
// #3008 review (Prism P2 1): shut at once whatever the disk says; say so when it could not be saved (retried).
|
|
18845
|
+
const had = store.enrolled;
|
|
18631
18846
|
const saved = store.remove();
|
|
18632
18847
|
this.closeOutsideLink("outside removed");
|
|
18848
|
+
if (had)
|
|
18849
|
+
this.notifyFleetError(t("outside.removed_notice")); // #3327: as above
|
|
18633
18850
|
this.logger.info({ saved }, "Authenticator app removed; connections from outside off");
|
|
18634
18851
|
return saved ? "ok" : "unsaved";
|
|
18635
18852
|
}
|
|
@@ -22761,7 +22978,11 @@ export class FleetManager {
|
|
|
22761
22978
|
// re-enters this path.
|
|
22762
22979
|
const selfMentionRe = new RegExp(`<@${adapterBotUserId}>`, "g");
|
|
22763
22980
|
const strippedText = text.replace(selfMentionRe, "").trim();
|
|
22764
|
-
|
|
22981
|
+
// A bare @mention says nothing by itself, so it is dropped (unchanged)... unless it is a REPLY that carries the mention: then the
|
|
22982
|
+
// replied-to message is what is being asked about, and it travels as reply_to_text (#3340). Telegram already forwards this shape
|
|
22983
|
+
// ("/chat @bot (you)"). Only with the mention in the text: an empty reply to one of our own messages (addressed through #2551, a
|
|
22984
|
+
// sticker or embed only) stays dropped, never an empty turn quoting our own answer (Fable #3342 F1).
|
|
22985
|
+
if (!strippedText && !msg.attachments?.length && !(msg.replyToText && mentionTag && addressText.includes(mentionTag)))
|
|
22765
22986
|
return;
|
|
22766
22987
|
const selfMarker = mentionWorld?.botUsername ? `@${mentionWorld.botUsername} (you)` : `${mentionTag} (you)`;
|
|
22767
22988
|
const cleanText = text.replace(selfMentionRe, selfMarker).trim();
|
|
@@ -26009,7 +26230,9 @@ export class FleetManager {
|
|
|
26009
26230
|
return {
|
|
26010
26231
|
ok: false,
|
|
26011
26232
|
status: 503,
|
|
26012
|
-
error:
|
|
26233
|
+
error: this.isWebOnlyFleet()
|
|
26234
|
+
? "the restart rate-limit file cannot be read"
|
|
26235
|
+
: "the restart rate-limit file cannot be read — send /restart in General",
|
|
26013
26236
|
};
|
|
26014
26237
|
}
|
|
26015
26238
|
return {
|
|
@@ -26039,7 +26262,7 @@ export class FleetManager {
|
|
|
26039
26262
|
return {
|
|
26040
26263
|
ok: false,
|
|
26041
26264
|
status: 409,
|
|
26042
|
-
error: "no chat channel is available to announce the restart
|
|
26265
|
+
error: "no chat channel is available to announce the restart",
|
|
26043
26266
|
};
|
|
26044
26267
|
}
|
|
26045
26268
|
// Consume the row: it moves to running, which is also what lets the next
|
|
@@ -26867,6 +27090,9 @@ export class FleetManager {
|
|
|
26867
27090
|
let store;
|
|
26868
27091
|
const generation = this.settingsGeneration;
|
|
26869
27092
|
let replaced = false;
|
|
27093
|
+
// S-91: whether an adapter ran before. One that did not is never "restored" by starting it with the old token (the token
|
|
27094
|
+
// that would not start it); a failed start goes back to the background retry instead.
|
|
27095
|
+
const wasRunning = this.adapters.has(job.connectionId);
|
|
26870
27096
|
try {
|
|
26871
27097
|
if (!channel || !envKey || !allowed.has(envKey))
|
|
26872
27098
|
throw new Error("connection is not configured for secret rotation");
|
|
@@ -26916,17 +27142,29 @@ export class FleetManager {
|
|
|
26916
27142
|
else
|
|
26917
27143
|
process.env[envKey] = oldToken;
|
|
26918
27144
|
}
|
|
26919
|
-
|
|
26920
|
-
|
|
26921
|
-
|
|
26922
|
-
|
|
26923
|
-
|
|
26924
|
-
|
|
26925
|
-
|
|
26926
|
-
|
|
26927
|
-
|
|
26928
|
-
|
|
26929
|
-
|
|
27145
|
+
if (!wasRunning) {
|
|
27146
|
+
// S-91: it was not running: the new adapter that did not come up is taken down (never left half-started), and
|
|
27147
|
+
// the connection is the background retry's again, as before the token was entered.
|
|
27148
|
+
if (await this.dropAdapterAfterFailedStart(job.connectionId, message))
|
|
27149
|
+
job.result = "rolled_back";
|
|
27150
|
+
else {
|
|
27151
|
+
job.result = "rollback_failed";
|
|
27152
|
+
job.error = "the new adapter could not be confirmed stopped; restart AgEnD";
|
|
27153
|
+
}
|
|
27154
|
+
}
|
|
27155
|
+
else {
|
|
27156
|
+
// Build a fresh adapter from the restored token. If the old adapter
|
|
27157
|
+
// was stopped already, this is the only safe way to return to the
|
|
27158
|
+
// previous runtime without claiming a disk-only rollback succeeded.
|
|
27159
|
+
const cleanup = { owner: execution?.owner ?? Symbol("secret-cleanup"), assert: () => {
|
|
27160
|
+
if (this.shuttingDown || this.settingsGeneration !== generation)
|
|
27161
|
+
throw new Error("secret cleanup superseded");
|
|
27162
|
+
} };
|
|
27163
|
+
const restored = await this.rebuildAdapterForSecret(job.connectionId, this.secureConnectionChannel(job.connectionId) ?? channel, true, cleanup);
|
|
27164
|
+
if (!restored)
|
|
27165
|
+
throw new Error("adapter rollback did not become connected");
|
|
27166
|
+
job.result = "rolled_back";
|
|
27167
|
+
}
|
|
26930
27168
|
}
|
|
26931
27169
|
catch (rollbackErr) {
|
|
26932
27170
|
this.logger.error({ connectionId: job.connectionId, reason: safeSecretError(rollbackErr, oldToken, [secret]) }, "Settings connection secret rollback failed");
|
|
@@ -26944,6 +27182,57 @@ export class FleetManager {
|
|
|
26944
27182
|
secret = "";
|
|
26945
27183
|
}
|
|
26946
27184
|
}
|
|
27185
|
+
/**
|
|
27186
|
+
* S-91: how a connection stands against what this process set up at start. "same": its adapter start ran (and failed, or
|
|
27187
|
+
* found no token), so starting it now is what the background retry does. "changed": its binding waits for the restart —
|
|
27188
|
+
* never started live, whatever its role (#3365 review P2). "added": #1519 P6's rule.
|
|
27189
|
+
*/
|
|
27190
|
+
startedWithConnection(connectionId, channel) {
|
|
27191
|
+
const started = this.startupFleetConfig;
|
|
27192
|
+
const list = started?.channels ?? (started?.channel ? [started.channel] : []);
|
|
27193
|
+
const then = list.find(item => (item.id ?? item.type) === connectionId);
|
|
27194
|
+
return !then ? "added" : isDeepStrictEqual(then, channel) ? "same" : "changed";
|
|
27195
|
+
}
|
|
27196
|
+
/**
|
|
27197
|
+
* S-91: a token's live start for a connection that was not running did not come up. Whatever adapter it left is taken
|
|
27198
|
+
* down (handlers off, stopped, unregistered), and the connection goes back to the background retry with the error.
|
|
27199
|
+
*/
|
|
27200
|
+
async dropAdapterAfterFailedStart(connectionId, error) {
|
|
27201
|
+
const fresh = this.adapters.get(connectionId);
|
|
27202
|
+
// #3365 review P3: the primary's prune interval goes with it (a later start sets it up again, once).
|
|
27203
|
+
if (this.getPrimaryAdapterId() === connectionId && this.sessionPruneTimer) {
|
|
27204
|
+
clearInterval(this.sessionPruneTimer);
|
|
27205
|
+
this.sessionPruneTimer = null;
|
|
27206
|
+
}
|
|
27207
|
+
let stopped = true;
|
|
27208
|
+
if (fresh) {
|
|
27209
|
+
fresh.removeAllListeners();
|
|
27210
|
+
stopped = await fresh.stop().then(() => true, () => false);
|
|
27211
|
+
if (this.adapters.get(connectionId) === fresh)
|
|
27212
|
+
this.adapters.delete(connectionId);
|
|
27213
|
+
if (this.worlds.get(connectionId)?.adapter === fresh)
|
|
27214
|
+
this.worlds.delete(connectionId);
|
|
27215
|
+
if (this.adapter === fresh)
|
|
27216
|
+
this.adapter = null;
|
|
27217
|
+
}
|
|
27218
|
+
const previous = this.adapterState.get(connectionId);
|
|
27219
|
+
if (previous?.retryTimer)
|
|
27220
|
+
clearTimeout(previous.retryTimer);
|
|
27221
|
+
if (!stopped) {
|
|
27222
|
+
// #3365 review P2: a stop that failed leaves the provider client's end unknown (it may still poll the bot). Said so —
|
|
27223
|
+
// never "rolled back" — and no adapter for this connection is admitted again in this process: no retry, and every
|
|
27224
|
+
// start refuses it (startSingleAdapterOwned / startAdditionalAdapterOwned). A restart of AgEnD clears it.
|
|
27225
|
+
this.adapterTeardownUnknown.add(connectionId);
|
|
27226
|
+
this.adapterState.set(connectionId, { status: "failed", retryCount: previous?.retryCount ?? 0, lastError: "the new adapter could not be confirmed stopped — restart AgEnD" });
|
|
27227
|
+
this.logger.error({ connectionId, reason: error }, "Settings connection secret: the adapter that did not start could not be confirmed stopped");
|
|
27228
|
+
return false;
|
|
27229
|
+
}
|
|
27230
|
+
if (this.shuttingDown || !this.secureConnectionChannel(connectionId))
|
|
27231
|
+
return true;
|
|
27232
|
+
this.adapterState.set(connectionId, { status: "retrying", retryCount: previous?.retryCount ?? 0, lastError: error });
|
|
27233
|
+
this.scheduleAdapterRetry(connectionId);
|
|
27234
|
+
return true;
|
|
27235
|
+
}
|
|
26947
27236
|
/** Stop the old provider client and construct a new one from process.env. */
|
|
26948
27237
|
async rebuildAdapterForSecret(connectionId, channel, force = false, execution) {
|
|
26949
27238
|
const generation = this.settingsGeneration;
|
|
@@ -26951,11 +27240,25 @@ export class FleetManager {
|
|
|
26951
27240
|
const check = () => { execution?.assert(); if (!current())
|
|
26952
27241
|
throw new Error("adapter operation superseded"); };
|
|
26953
27242
|
check();
|
|
27243
|
+
// S-91: never two starts of one connection at once. A background retry in flight finishes first: it read the token
|
|
27244
|
+
// before this one was stored, so it gives way (its own check), or it came up and is replaced below like any adapter.
|
|
27245
|
+
const inFlight = this.adapterRetryInFlight.get(connectionId);
|
|
27246
|
+
if (inFlight) {
|
|
27247
|
+
await inFlight.catch(() => { });
|
|
27248
|
+
check();
|
|
27249
|
+
}
|
|
26954
27250
|
const old = this.adapters.get(connectionId);
|
|
26955
|
-
// No adapter:
|
|
26956
|
-
//
|
|
26957
|
-
|
|
26958
|
-
|
|
27251
|
+
// No adapter: one this process started with, unchanged since (its start failed, or it had no token), starts now — S-91,
|
|
27252
|
+
// the way the background retry starts it, the primary included. One added since starts now when it is not the primary
|
|
27253
|
+
// and the fleet runs connections (#1519 P6). One changed since (its binding pending) never does: the secret is valid on
|
|
27254
|
+
// disk and the next start adopts it with its binding.
|
|
27255
|
+
if (!old && !force) {
|
|
27256
|
+
const since = this.startedWithConnection(connectionId, channel);
|
|
27257
|
+
if (since === "changed")
|
|
27258
|
+
return false;
|
|
27259
|
+
if (since === "added" && (this.getPrimaryAdapterId() === connectionId || this.adapters.size === 0))
|
|
27260
|
+
return false;
|
|
27261
|
+
}
|
|
26959
27262
|
if (!old) {
|
|
26960
27263
|
const pending = this.adapterState.get(connectionId)?.retryTimer;
|
|
26961
27264
|
if (pending)
|
|
@@ -27012,10 +27315,15 @@ export class FleetManager {
|
|
|
27012
27315
|
this.adapterState.set(connectionId, { status: "connected", retryCount: 0 });
|
|
27013
27316
|
return true;
|
|
27014
27317
|
}
|
|
27318
|
+
// S-91: a retry timer set while it was coming up (the in-flight retry's own, giving way) must not start it a second time.
|
|
27319
|
+
const settled = () => { const st = this.adapterState.get(connectionId); if (st?.retryTimer) {
|
|
27320
|
+
clearTimeout(st.retryTimer);
|
|
27321
|
+
st.retryTimer = undefined;
|
|
27322
|
+
} return true; };
|
|
27015
27323
|
while (performance.now() < deadline) {
|
|
27016
27324
|
const health = fresh.getHealthSnapshot?.();
|
|
27017
27325
|
if (health?.status === "connected" || this.adapterState.get(connectionId)?.status === "connected")
|
|
27018
|
-
return
|
|
27326
|
+
return settled();
|
|
27019
27327
|
await new Promise(resolve => setTimeout(resolve, 100));
|
|
27020
27328
|
check();
|
|
27021
27329
|
}
|