@songsid/agend 2.4.0-beta.32 → 2.4.0-beta.35

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.
Files changed (81) hide show
  1. package/dist/build-provenance.json +1 -1
  2. package/dist/delivery-outbox.d.ts +12 -0
  3. package/dist/delivery-outbox.js +26 -2
  4. package/dist/delivery-outbox.js.map +1 -1
  5. package/dist/fleet-context.d.ts +11 -0
  6. package/dist/fleet-manager.d.ts +54 -2
  7. package/dist/fleet-manager.js +324 -49
  8. package/dist/fleet-manager.js.map +1 -1
  9. package/dist/general-knowledge/skills/concepts/SKILL.md +60 -0
  10. package/dist/general-knowledge/skills/hub/SKILL.md +10 -4
  11. package/dist/general-knowledge/skills/web-dashboard/SKILL.md +15 -40
  12. package/dist/hub/client.js +16 -6
  13. package/dist/hub/client.js.map +1 -1
  14. package/dist/hub/compose/member.js +3 -2
  15. package/dist/hub/compose/member.js.map +1 -1
  16. package/dist/hub/compose/server.js +2 -1
  17. package/dist/hub/compose/server.js.map +1 -1
  18. package/dist/hub/group-policy/resources.d.ts +1 -1
  19. package/dist/hub/http/compose.d.ts +2 -0
  20. package/dist/hub/http/compose.js +45 -6
  21. package/dist/hub/http/compose.js.map +1 -1
  22. package/dist/hub/member-reconciliation.d.ts +2 -0
  23. package/dist/hub/member-reconciliation.js +3 -1
  24. package/dist/hub/member-reconciliation.js.map +1 -1
  25. package/dist/hub/protocol.d.ts +8 -8
  26. package/dist/hub/protocol.js +7 -2
  27. package/dist/hub/protocol.js.map +1 -1
  28. package/dist/hub/receipt-reason.d.ts +6 -0
  29. package/dist/hub/receipt-reason.js +12 -0
  30. package/dist/hub/receipt-reason.js.map +1 -0
  31. package/dist/hub/representative.d.ts +2 -0
  32. package/dist/hub/representative.js +7 -3
  33. package/dist/hub/representative.js.map +1 -1
  34. package/dist/hub/rooms/direct-view.js +2 -0
  35. package/dist/hub/rooms/direct-view.js.map +1 -1
  36. package/dist/hub/rooms/types.d.ts +2 -0
  37. package/dist/hub/rooms.d.ts +12 -0
  38. package/dist/hub/rooms.js +14 -3
  39. package/dist/hub/rooms.js.map +1 -1
  40. package/dist/hub/server.js +4 -1
  41. package/dist/hub/server.js.map +1 -1
  42. package/dist/hub/settings-member-address-decision.js +1 -1
  43. package/dist/hub/settings-member-address-decision.js.map +1 -1
  44. package/dist/hub/settings-web-address-decision.js +2 -2
  45. package/dist/hub/settings-web-address-decision.js.map +1 -1
  46. package/dist/instance-lifecycle.d.ts +2 -0
  47. package/dist/instance-lifecycle.js +4 -0
  48. package/dist/instance-lifecycle.js.map +1 -1
  49. package/dist/locale.js +36 -6
  50. package/dist/locale.js.map +1 -1
  51. package/dist/request-context-control-api.d.ts +18 -0
  52. package/dist/request-context-control-api.js +9 -1
  53. package/dist/request-context-control-api.js.map +1 -1
  54. package/dist/settings-effect.js +5 -2
  55. package/dist/settings-effect.js.map +1 -1
  56. package/dist/tips.js +1 -1
  57. package/dist/tips.js.map +1 -1
  58. package/dist/topic-commands.js +10 -1
  59. package/dist/topic-commands.js.map +1 -1
  60. package/dist/turn-reply-guard.js +4 -1
  61. package/dist/turn-reply-guard.js.map +1 -1
  62. package/dist/ui/hub-assistant-admin.js +10 -3
  63. package/dist/ui/hub-assistant-usage-strings.js +8 -0
  64. package/dist/ui/hub-owner-strings.js +2 -2
  65. package/dist/ui/hub-room-composer.js +9 -2
  66. package/dist/ui/hub-room-strings.js +2 -2
  67. package/dist/ui/hub-room-thread.js +37 -9
  68. package/dist/ui/panel-chat.js +3 -3
  69. package/dist/ui/panel-hub.js +1 -1
  70. package/dist/ui/request-context-control.js +72 -12
  71. package/dist/ui/shared/app-update.js +35 -5
  72. package/dist/ui/shared/app.css +21 -0
  73. package/dist/ui/shared/chat-msg-actions.js +1 -1
  74. package/dist/ui/shared/chat-strings.js +2 -2
  75. package/dist/ui/shared/chat-thread.js +1 -1
  76. package/dist/ui/shared/hub-owner.css +12 -0
  77. package/dist/ui/shared/update-card-ui.js +21 -7
  78. package/dist/update-card.d.ts +17 -2
  79. package/dist/update-card.js +58 -9
  80. package/dist/update-card.js.map +1 -1
  81. package/package.json +1 -1
@@ -2,6 +2,7 @@ import { cacheRetainedUnavailable } from "./update-retained.js";
2
2
  import { projectRequestContextWork } from "./request-context-drain-projection.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { RequestContextController } from "./request-context-controller.js";
5
+ import { REQUEST_CONTEXT_UNCERTAIN_LISTED_PAIRS } from "./request-context-control-api.js";
5
6
  import { captureRequestContextEnableOffer } from "./request-context-enable-offer.js";
6
7
  import { acquireRequestContextActivationLease, requestContextUpdateSettled } from "./request-context-update-guard.js";
7
8
  import { installPrefixOf } from "./home-update-lock.js";
@@ -456,6 +457,8 @@ import { verifyDiscordToken, verifyTelegramToken } from "./provider-probe.js";
456
457
  import { PROVIDER_SECRET_SPECS, PUBLIC_TUNNEL_SECRET_SPEC, providerSecretSpec, providerRegistryEnvKeys, isReservedProviderEnvKey, verifyProviderSecret, } from "./provider-secret-registry.js";
457
458
  /** A self-restart is a whole service restart; 120s is the apply budget, not this. */
458
459
  const SELF_RESTART_DEADLINE_MS = 300_000;
460
+ /** M-3964: how long bare `/update` waits for its fresh update check before answering from the stored one. */
461
+ const FRESH_UPDATE_OFFER_WAIT_MS = 10_000;
459
462
  import { APPLY_FLEET_TARGET, ApplyJobStore, viewOf, } from "./apply-job.js";
460
463
  import { kiroHome } from "./backend/kiro-kas-store.js";
461
464
  import { CHAT_PROFILE_LOGIN_BACKENDS, claudeStoreEnded, credentialHomeSpec, credentialProfileHome, credentialProfileLaunch, credentialProfileLogin, credentialProfileLoginCommand, credentialProfileStoreHome, credentialSwitchCarriesConversation, credentialSwitchStartsFresh, instanceCredentialProfile, listConfiguredProfiles, resolveCredentialProfile } from "./backend/credential-profile.js";
@@ -704,6 +707,8 @@ const KIRO_MIGRATE_CALLBACK_PREFIX = "kiro-migrate:";
704
707
  const HUB_UPDATE_CALLBACK_PREFIX = "hub-update:";
705
708
  /** M-3770 1.5: the update card in General's chat ("update-card:" + 32 hex + ":" + its answer). */
706
709
  const UPDATE_CARD_CALLBACK_PREFIX = "update-card:";
710
+ /** M-3967: 立即更新's one question on the chat card ("update-now:" + 32 hex + ":go" / ":keep" = 48 bytes). */
711
+ const UPDATE_NOW_CALLBACK_PREFIX = "update-now:";
707
712
  /** M-3770 1.5: where the chat card's message is (one per fleet), so later states edit it in place across a restart. */
708
713
  const UPDATE_CHAT_CARD_FILE = "update-chat-card.json";
709
714
  /** The chat card's buttons live a week (Not now's own length); a newer card replaces them sooner. */
@@ -729,7 +734,13 @@ export function updateTonightAt(now, tz) {
729
734
  const today = at(day);
730
735
  return today - now >= 30 * 60_000 ? today : at(new Date(Date.parse(`${day}T12:00:00Z`) + 86_400_000).toISOString().slice(0, 10));
731
736
  }
732
- const UPDATE_CHAT_CARD_ALL = ["when-idle", "tonight", "not-now"];
737
+ /** M-3967: an offer's buttons, as on the web's card (立即更新 first). */
738
+ const UPDATE_CHAT_CARD_ALL = ["now", "when-idle", "tonight", "not-now"];
739
+ /** A record from before M-3864 R1 names no buttons: it was posted with these three. */
740
+ const UPDATE_CHAT_CARD_LEGACY_ACTIONS = "when-idle,tonight,not-now";
741
+ const UPDATE_CHAT_CARD_LABEL = {
742
+ now: "update.chatcard.now", "when-idle": "update.chatcard.when_idle", tonight: "update.chatcard.tonight", "not-now": "update.chatcard.not_now", cancel: "update.chatcard.cancel",
743
+ };
733
744
  const HUB_SHARING_CALLBACK_PREFIX = "hub-share:";
734
745
  /** M-3680: a held contact request's card in General ("contact-ticket:" + 32 hex + ":approve" = 55 bytes, under Telegram's 64). */
735
746
  const CONTACT_TICKET_PREFIX = "contact-ticket:";
@@ -3073,6 +3084,8 @@ export class FleetManager {
3073
3084
  updateChatCardAnswered = new Map();
3074
3085
  /** Prism #4584 (1): a press refused while its card was still being posted (the post records it, so it isn't relabelled expired). */
3075
3086
  updateChatCardRefused = new Set();
3087
+ /** M-3967: 立即更新's question is open (its nonce): the card is not posted again until it is answered. */
3088
+ updateChatCardConfirming = null;
3076
3089
  updateChatCardTimer = null;
3077
3090
  readUpdateChatCard() {
3078
3091
  try {
@@ -3111,8 +3124,11 @@ export class FleetManager {
3111
3124
  // The card's own short lines, as on the web (the leader's copy pass); anything else in /update's words.
3112
3125
  // M-3864 R2: the fleet's zone with its offset, as schedules say times (the web shows the person's own zone).
3113
3126
  const at = (ms) => (ms ? formatFleetTime(ms, this.usageZone()) : "");
3114
- if (view?.state === "waiting-idle")
3115
- return t("update.chatcard.state_waiting", view.version);
3127
+ if (view?.state === "waiting-idle") {
3128
+ // M-3967: who it waits for, as the web's card names them.
3129
+ const waiting = t("update.chatcard.state_waiting", view.version);
3130
+ return view.waitingFor?.length ? `${waiting}\n${t("update.chatcard.waiting_for", this.updateChatCardNames(view.waitingFor))}` : waiting;
3131
+ }
3116
3132
  if (view?.state === "scheduled")
3117
3133
  return t("update.chatcard.state_scheduled", view.version, at(view.scheduledAt));
3118
3134
  if (view?.state === "not-now")
@@ -3131,11 +3147,27 @@ export class FleetManager {
3131
3147
  * admin's press (Update when idle) needs pressHere, a picked time (Tonight) a machine that updates itself. No pre-flight
3132
3148
  * result yet: all three (the launch decides, as on the web).
3133
3149
  */
3134
- updateChatCardActions(pre = this.updatePreflight) {
3150
+ updateChatCardActions(state = "offered", pre = this.updatePreflight) {
3151
+ // M-3967: a wait or a picked time keeps 立即更新 (an admin's press) and 取消, as the web's card does.
3152
+ if (state === "waiting-idle" || state === "scheduled")
3153
+ return !pre || preflightAllows(pre, "press") ? ["now", "cancel"] : ["cancel"];
3154
+ if (state !== "offered")
3155
+ return [];
3135
3156
  if (!pre)
3136
3157
  return [...UPDATE_CHAT_CARD_ALL];
3137
3158
  return UPDATE_CHAT_CARD_ALL.filter(a => a === "not-now" || preflightAllows(pre, a === "tonight" ? "unattended" : "press"));
3138
3159
  }
3160
+ /** Two names, then how many more (the web's namesShown). */
3161
+ updateChatCardNames(names) {
3162
+ const list = names.filter(Boolean), sep = t("update.chatcard.names_sep");
3163
+ return list.length <= 2 ? list.join(sep) : `${list.slice(0, 2).join(sep)}${t("update.chatcard.names_more", list.length - 2)}`;
3164
+ }
3165
+ /** M-3967: where a posted card is, as a place to post its next one; null when its adapter is gone. */
3166
+ updateChatCardPlaceOf(posted) {
3167
+ const general = this.updateChatCardPlace();
3168
+ const adapter = this.adapters.get(posted.adapterId) ?? this.worlds.get(posted.adapterId)?.adapter ?? (general && general.adapterId === posted.adapterId ? general.adapter : undefined);
3169
+ return adapter && posted.chatId ? { adapter, adapterId: posted.adapterId, chatId: posted.chatId, ...(posted.threadId ? { threadId: posted.threadId } : {}) } : null;
3170
+ }
3139
3171
  /** General's chat place for the card, or null (no General, no chat: a web-only fleet's banner says it). */
3140
3172
  updateChatCardPlace() {
3141
3173
  if (this.webOnlyPromptPlace())
@@ -3154,13 +3186,15 @@ export class FleetManager {
3154
3186
  * newly qualifies (a new version, or back after Not now) is posted with its buttons; every later state edits that same
3155
3187
  * message (its buttons retired: the adapters cannot swap them). Never throws; one at a time.
3156
3188
  */
3157
- async syncUpdateChatCard() {
3158
- // A call while one runs is not dropped: the running one syncs again when it is done (#4485 review 2).
3189
+ async syncUpdateChatCard(here) {
3190
+ // A call while one runs is not dropped: the running one syncs again when it is done (#4485 review 2). A typed /update
3191
+ // (`here`) is not queued: its caller answers in words instead.
3159
3192
  if (this.shuttingDown)
3160
- return;
3193
+ return false;
3161
3194
  if (this.updateChatCardBusy) {
3162
- this.updateChatCardAgain = true;
3163
- return;
3195
+ if (!here)
3196
+ this.updateChatCardAgain = true;
3197
+ return false;
3164
3198
  }
3165
3199
  this.updateChatCardBusy = true;
3166
3200
  try {
@@ -3176,28 +3210,40 @@ export class FleetManager {
3176
3210
  // a usable card: it is marked expired and one with live buttons is posted.
3177
3211
  const live = !!posted?.nonce && this.pendingNonceButtons.get(posted.nonce)?.prefix === UPDATE_CARD_CALLBACK_PREFIX;
3178
3212
  // M-3864 R1: a card whose buttons the machine no longer allows (or newly allows) is posted again with the right ones.
3179
- const actions = this.updateChatCardActions(), actionsKey = actions.join(",");
3213
+ // M-3967: a wait and a picked time have buttons too (立即更新 / 取消).
3214
+ const actions = this.updateChatCardActions(state), actionsKey = actions.join(",");
3180
3215
  // Prism #4584 (2): and the reason it gives for not updating here (another stop keeps Not now only but must say so).
3181
- const blockingCheck = this.updatePreflight ? preflightBlocking(this.updatePreflight) : null;
3216
+ const blockingCheck = state === "offered" && this.updatePreflight ? preflightBlocking(this.updatePreflight) : null;
3182
3217
  const blockingKey = blockingCheck ? preflightWords(blockingCheck, (key, ...args) => t(key, ...args)) : "";
3183
- const sameActions = (posted?.actions ?? UPDATE_CHAT_CARD_ALL.join(",")) === actionsKey && (posted?.blocking ?? "") === blockingKey;
3184
- if (view && state === "offered" && view.installable && (!posted || posted.version !== view.version || posted.state !== "offered" || !live || !sameActions)) {
3185
- const place = this.updateChatCardPlace();
3218
+ const sameActions = (posted?.actions ?? UPDATE_CHAT_CARD_LEGACY_ACTIONS) === actionsKey && (posted?.blocking ?? "") === blockingKey;
3219
+ const confirming = !!this.updateChatCardConfirming && this.pendingNonceButtons.get(this.updateChatCardConfirming)?.prefix === UPDATE_NOW_CALLBACK_PREFIX;
3220
+ if (view && view.installable && actions.length > 0 && (here || !confirming)
3221
+ && (here || !posted || posted.version !== view.version || posted.state !== state || !live || !sameActions)) {
3222
+ // M-3967: the same version's next card (a wait's, or the card back after 立即更新's Cancel) goes where the card is
3223
+ // (a typed /update may have moved it); a new version, or one with no known place, goes to General.
3224
+ const place = here ?? (posted && posted.version === view.version ? this.updateChatCardPlaceOf(posted) : null) ?? this.updateChatCardPlace();
3186
3225
  if (!place)
3187
- return;
3188
- // A refused press already edited its card to say why; that text stays (it is not called expired).
3189
- if (posted && !(posted.refused && posted.version === view.version && !live)) {
3190
- const old = posted.state === "offered" && posted.version === view.version && !live ? t("update.chatcard.expired")
3191
- : posted.state === "offered" && posted.version === view.version && !sameActions ? t("update.chatcard.replaced", view.version)
3192
- : posted.version === view.version ? t("update.chatcard.cancelled", posted.version) : t("update.chatcard.replaced", view.version);
3193
- await this.editUpdateChatCard(posted, old);
3226
+ return false;
3227
+ const general = ("general" in place ? place.general : undefined) ?? this.findGeneralInstance() ?? "general";
3228
+ if (posted) {
3229
+ // What the old message says now. Left alone: a press already edited it to its answer, or a refusal's words.
3230
+ const pressed = posted.nonce === null && posted.state === state && posted.version === view.version;
3231
+ const keepRefusal = posted.refused && posted.version === view.version && !live;
3232
+ const old = here ? t("update.chatcard.moved")
3233
+ : posted.version !== view.version ? t("update.chatcard.replaced", view.version)
3234
+ : posted.state === state ? (!live ? t("update.chatcard.expired") : t("update.chatcard.replaced", view.version))
3235
+ // The same version in another state: a wait cancelled (offered again), or an answer from the web (its words).
3236
+ : state === "offered" ? t("update.chatcard.cancelled", posted.version) : this.updateChatCardText(view, current);
3237
+ if (here ? posted.nonce !== null : !pressed && !keepRefusal)
3238
+ await this.editUpdateChatCard(posted, old);
3194
3239
  }
3195
3240
  const version = view.version;
3241
+ const message = this.updateChatCardText(view, current);
3196
3242
  const nonce = await this.postNonceButtonPromptOrThrow({
3197
- prefix: UPDATE_CARD_CALLBACK_PREFIX, alertType: "tip", instanceName: place.general, adapter: place.adapter, adapterId: place.adapterId,
3243
+ prefix: UPDATE_CARD_CALLBACK_PREFIX, alertType: "tip", instanceName: general, adapter: place.adapter, adapterId: place.adapterId,
3198
3244
  chatId: place.chatId, ...(place.threadId ? { threadId: place.threadId } : {}),
3199
- message: this.updateChatCardText(view, current),
3200
- choices: actions.map(action => ({ action, label: t(action === "when-idle" ? "update.chatcard.when_idle" : action === "tonight" ? "update.chatcard.tonight" : "update.chatcard.not_now") })),
3245
+ message,
3246
+ choices: actions.map(action => ({ action, label: t(UPDATE_CHAT_CARD_LABEL[action]) })),
3201
3247
  expiredText: t("update.chatcard.expired"),
3202
3248
  timeoutMs: UPDATE_CHAT_CARD_MS,
3203
3249
  // #4485 review 2: the provider's own delivery address, kept per nonce as it is sent — a click may consume the
@@ -3206,10 +3252,13 @@ export class FleetManager {
3206
3252
  // #4485 r2: the buttons' version is bound before anything is sent — a click can come before the platform answers.
3207
3253
  const nonceOf = (choices[0]?.id ?? "").slice(UPDATE_CARD_CALLBACK_PREFIX.length, UPDATE_CARD_CALLBACK_PREFIX.length + 32);
3208
3254
  this.updateChatCardVersion.set(nonceOf, version);
3209
- const shown = this.renderPlaces(place.adapterId, this.updateChatCardText(view, current), place.threadId ? { threadId: place.threadId } : undefined);
3210
- const sent = await place.adapter.notifyAlert(place.chatId, { type: "tip", instanceName: place.general, message: shown.text, choices }, shown.opts);
3211
- const id = choices[0]?.id ?? "";
3212
- this.updateChatCardSent.set(id.slice(UPDATE_CARD_CALLBACK_PREFIX.length, UPDATE_CARD_CALLBACK_PREFIX.length + 32), { version, chatId: sent.chatId, ...(sent.threadId !== undefined ? { threadId: sent.threadId } : {}), messageId: String(sent.messageId ?? "") });
3255
+ const shown = this.renderPlaces(place.adapterId, message, place.threadId ? { threadId: place.threadId } : undefined);
3256
+ // M-3967: a Discord slash /update is answered by its own (public) reply, which then carries the card.
3257
+ const respondButtons = "respondButtons" in place ? place.respondButtons : undefined;
3258
+ const sent = respondButtons
3259
+ ? { chatId: place.chatId, ...(place.threadId ? { threadId: place.threadId } : {}), messageId: (await respondButtons(shown.text, choices)) ?? "" }
3260
+ : await place.adapter.notifyAlert(place.chatId, { type: "tip", instanceName: general, message: shown.text, choices }, shown.opts);
3261
+ this.updateChatCardSent.set(nonceOf, { version, chatId: sent.chatId, ...(sent.threadId !== undefined ? { threadId: sent.threadId } : {}), messageId: String(sent.messageId ?? "") });
3213
3262
  return sent;
3214
3263
  },
3215
3264
  });
@@ -3217,24 +3266,28 @@ export class FleetManager {
3217
3266
  const answered = this.updateChatCardAnswered.get(nonce);
3218
3267
  this.updateChatCardAnswered.delete(nonce);
3219
3268
  const refused = this.updateChatCardRefused.delete(nonce);
3220
- this.writeUpdateChatCard({ version, state: answered ?? "offered", nonce: answered || refused ? null : nonce, messageId: sent?.messageId ?? "",
3269
+ this.writeUpdateChatCard({ version, state: answered ?? state, nonce: answered || refused ? null : nonce, messageId: sent?.messageId ?? "",
3221
3270
  chatId: sent?.chatId ?? place.chatId, ...((sent?.threadId ?? place.threadId) ? { threadId: sent?.threadId ?? place.threadId } : {}),
3222
3271
  adapterId: place.adapterId, at: Date.now(), actions: actionsKey, ...(blockingKey ? { blocking: blockingKey } : {}), ...(refused ? { refused: true } : {}) });
3223
3272
  // The card may have moved on while this was being posted (a newer version, an answer on the web), or a press on it
3224
3273
  // was refused (the machine changed): sync again.
3225
3274
  const after = this.updateOfferView();
3226
- if (refused || !answered && (after?.version !== version || (after?.state ?? "none") !== "offered"))
3275
+ if (refused || !answered && (after?.version !== version || (after?.state ?? "none") !== state))
3227
3276
  this.updateChatCardAgain = true;
3228
- return;
3277
+ return true;
3229
3278
  }
3279
+ if (here)
3280
+ return false;
3230
3281
  if (posted && posted.state !== state) {
3231
3282
  const text = state === "none" && posted.state !== "done" ? t("update.chatcard.cancelled", posted.version) : this.updateChatCardText(view, current);
3232
3283
  await this.editUpdateChatCard(posted, text);
3233
3284
  this.writeUpdateChatCard(state === "none" ? null : { ...posted, state, nonce: null });
3234
3285
  }
3286
+ return false;
3235
3287
  }
3236
3288
  catch (err) {
3237
3289
  this.logger.warn({ err: err.message }, "Update chat card not posted");
3290
+ return false;
3238
3291
  }
3239
3292
  finally {
3240
3293
  this.updateChatCardBusy = false;
@@ -3244,6 +3297,20 @@ export class FleetManager {
3244
3297
  }
3245
3298
  }
3246
3299
  }
3300
+ /**
3301
+ * M-3967: a fleet admin's bare `/update` in a chat: a fresh check, then the one update card with its buttons, posted
3302
+ * where it was typed (General's earlier card says so). Null when the card was posted; otherwise the words to reply
3303
+ * with (a state with no buttons — updating, done, pinned, nothing to offer — or a card that could not be posted).
3304
+ */
3305
+ async showUpdateCard(here) {
3306
+ await this.refreshUpdateOffer();
3307
+ // A sync in progress (the check above just started one) finishes first: it is short.
3308
+ for (let i = 0; this.updateChatCardBusy && i < 100; i++)
3309
+ await new Promise(resolve => setTimeout(resolve, 50));
3310
+ if (await this.syncUpdateChatCard(here))
3311
+ return null;
3312
+ return this.describeUpdateOffer();
3313
+ }
3247
3314
  /** Edit the posted card: retire its buttons if they are still live (with `text`), else edit its text without buttons. */
3248
3315
  async editUpdateChatCard(posted, text) {
3249
3316
  const entry = posted.nonce ? this.pendingNonceButtons.get(posted.nonce) : undefined;
@@ -3267,7 +3334,7 @@ export class FleetManager {
3267
3334
  * same gate as the Hub's Update now). The answer is the web's (the one card); the message is edited to its new state.
3268
3335
  */
3269
3336
  async handleUpdateCardCallback(data, adapterId, adapter) {
3270
- const claimed = this.consumeNonceCallback(UPDATE_CARD_CALLBACK_PREFIX, /^update-card:([0-9a-f]{32}):(when-idle|tonight|not-now)$/, data, adapterId, adapter, undefined, userId => this.fleetAdminGate(userId, adapterId) === "ok");
3337
+ const claimed = this.consumeNonceCallback(UPDATE_CARD_CALLBACK_PREFIX, /^update-card:([0-9a-f]{32}):(now|when-idle|tonight|not-now|cancel)$/, data, adapterId, adapter, undefined, userId => this.fleetAdminGate(userId, adapterId) === "ok");
3271
3338
  if (claimed === null)
3272
3339
  return false;
3273
3340
  if (claimed === "consumed")
@@ -3284,9 +3351,12 @@ export class FleetManager {
3284
3351
  await this.retireNonceButtons(entry, messageId, shownVersion && before && before.version !== shownVersion ? t("update.chatcard.replaced", before.version) : t("update.chatcard.expired"));
3285
3352
  return true;
3286
3353
  }
3354
+ const by = updateAnswerLabel(data.username ?? "");
3355
+ // M-3967: 立即更新 asks once first (naming who works now), in a message of its own; the card waits for that answer.
3356
+ if (action === "now")
3357
+ return await this.askUpdateNow(entry, nonce, messageId, shownVersion, by);
3287
3358
  const tonight = updateTonightAt(Date.now(), this.usageZone());
3288
3359
  const body = action === "tonight" ? { action: "pick-time", at: tonight } : { action: action };
3289
- const by = updateAnswerLabel(data.username ?? "");
3290
3360
  let text;
3291
3361
  try {
3292
3362
  const r = await this.ensureUpdateCard().answer(`chat-${nonce}`, by, body);
@@ -3320,6 +3390,95 @@ export class FleetManager {
3320
3390
  text = t("update.chatcard.refused", err.message);
3321
3391
  }
3322
3392
  await this.retireNonceButtons(entry, messageId, text);
3393
+ // M-3967: a wait or a picked time is a card of its own (立即更新 / 取消): posted now, not at the next minute's sync.
3394
+ void this.syncUpdateChatCard();
3395
+ return true;
3396
+ }
3397
+ /**
3398
+ * M-3967: 立即更新 on the chat card: the card's buttons go (its words stay, with who asked), and one question is posted
3399
+ * under it, naming the agents at work (the web's Update now question). Its answer is the card's Update now.
3400
+ */
3401
+ async askUpdateNow(entry, cardNonce, messageId, version, by) {
3402
+ const view = this.updateOfferView();
3403
+ let current = null;
3404
+ try {
3405
+ current = this.runningAgendVersion();
3406
+ }
3407
+ catch { /* unknown */ }
3408
+ await this.retireNonceButtons(entry, messageId ?? "", `${this.updateChatCardText(view, current)}\n${t("update.chatcard.now_asked", by)}`);
3409
+ const posted = this.readUpdateChatCard();
3410
+ if (posted && posted.nonce === cardNonce)
3411
+ this.writeUpdateChatCard({ ...posted, nonce: null, messageId: posted.messageId || String(messageId ?? "") });
3412
+ const busy = this.updateBusyNames();
3413
+ const body = busy.length ? t("update.chatcard.now_body", busy.length, this.updateChatCardNames(busy)) : t("update.chatcard.now_body_idle");
3414
+ try {
3415
+ const nonce = await this.postNonceButtonPromptOrThrow({
3416
+ prefix: UPDATE_NOW_CALLBACK_PREFIX, alertType: "tip", instanceName: entry.instanceName, adapter: entry.adapter, adapterId: entry.adapterId,
3417
+ chatId: entry.chatId, ...(entry.threadId ? { threadId: entry.threadId } : {}),
3418
+ message: `${t("update.chatcard.now_title", version)}\n${body}`,
3419
+ choices: [{ action: "go", label: t("update.chatcard.now") }, { action: "keep", label: t("update.chatcard.cancel") }],
3420
+ expiredText: t("update.chatcard.expired"),
3421
+ // Bound before it is sent: a press answers for the version it named, never a newer one that came since.
3422
+ deliver: async (choices) => {
3423
+ this.updateChatCardVersion.set((choices[0]?.id ?? "").slice(UPDATE_NOW_CALLBACK_PREFIX.length, UPDATE_NOW_CALLBACK_PREFIX.length + 32), version);
3424
+ const shown = this.renderPlaces(entry.adapterId, `${t("update.chatcard.now_title", version)}\n${body}`, entry.threadId ? { threadId: entry.threadId } : undefined);
3425
+ return await entry.adapter.notifyAlert(entry.chatId, { type: "tip", instanceName: entry.instanceName, message: shown.text, choices }, shown.opts);
3426
+ },
3427
+ });
3428
+ this.updateChatCardConfirming = nonce;
3429
+ }
3430
+ catch (err) {
3431
+ this.logger.warn({ err: err.message }, "Update now question not posted");
3432
+ void this.syncUpdateChatCard();
3433
+ }
3434
+ return true;
3435
+ }
3436
+ /** M-3967: the answer to 立即更新's question: the card's Update now (the web's), or the card back as it was. */
3437
+ async handleUpdateNowCallback(data, adapterId, adapter) {
3438
+ const claimed = this.consumeNonceCallback(UPDATE_NOW_CALLBACK_PREFIX, /^update-now:([0-9a-f]{32}):(go|keep)$/, data, adapterId, adapter, undefined, userId => this.fleetAdminGate(userId, adapterId) === "ok");
3439
+ if (claimed === null)
3440
+ return false;
3441
+ if (claimed === "consumed")
3442
+ return true;
3443
+ const { entry, action } = claimed;
3444
+ const nonce = data.callbackData.slice(UPDATE_NOW_CALLBACK_PREFIX.length, UPDATE_NOW_CALLBACK_PREFIX.length + 32);
3445
+ const messageId = entry.messageId ?? data.messageId;
3446
+ if (this.updateChatCardConfirming === nonce)
3447
+ this.updateChatCardConfirming = null;
3448
+ const by = updateAnswerLabel(data.username ?? "");
3449
+ const before = this.updateOfferView();
3450
+ const shownVersion = this.updateChatCardVersion.get(nonce);
3451
+ let text;
3452
+ if (action === "keep")
3453
+ text = t("update.chatcard.now_kept");
3454
+ else if (!shownVersion || !before || before.version !== shownVersion) {
3455
+ text = shownVersion && before && before.version !== shownVersion ? t("update.chatcard.replaced", before.version) : t("update.chatcard.expired");
3456
+ }
3457
+ else {
3458
+ try {
3459
+ const r = await this.ensureUpdateCard().answer(`chat-now-${nonce}`, by, { action: "now", confirm: "update-agend" });
3460
+ const view = this.updateOfferView();
3461
+ let current = null;
3462
+ try {
3463
+ current = this.runningAgendVersion();
3464
+ }
3465
+ catch { /* unknown */ }
3466
+ const why = r.ok ? "" : ("key" in r.body && r.body.key !== "preflight" ? r.body.key : "error" in r.body ? r.body.error : r.body.key);
3467
+ const preflight = !r.ok && "key" in r.body && r.body.key === "preflight" ? r.body.preflight : null;
3468
+ const refusal = preflight ? preflightRefusal(preflight, "press", (key, ...args) => t(key, ...args)) : null;
3469
+ text = r.ok ? t("update.chatcard.by", this.updateChatCardText(view, current), by) : refusal ?? t("update.chatcard.refused", why || String(r.status));
3470
+ // The card's later states (updating, updated) are told on this message: it is the card now.
3471
+ const posted = this.readUpdateChatCard();
3472
+ if (r.ok && posted)
3473
+ this.writeUpdateChatCard({ ...posted, state: view?.state ?? "none", nonce: null, messageId: String(messageId ?? ""), chatId: entry.chatId,
3474
+ ...(entry.threadId ? { threadId: entry.threadId } : {}), adapterId: entry.adapterId });
3475
+ }
3476
+ catch (err) {
3477
+ text = t("update.chatcard.refused", err.message);
3478
+ }
3479
+ }
3480
+ await this.retireNonceButtons(entry, String(messageId ?? ""), text);
3481
+ void this.syncUpdateChatCard();
3323
3482
  return true;
3324
3483
  }
3325
3484
  hubUpdates = null;
@@ -3347,10 +3506,14 @@ export class FleetManager {
3347
3506
  const worker = this.queueWorkers.get(name);
3348
3507
  if (worker?.busy || worker?.inFlight)
3349
3508
  return false;
3509
+ // M-3960 (Prism #4634): a wake on its way is busy whatever the status reads; a cold wake clears the pause marker
3510
+ // before its daemon exists, so the status reads stopped for that window.
3511
+ if (this.wakeOnItsWay(name))
3512
+ return false;
3350
3513
  const process = this.getInstanceStatus(name);
3351
3514
  if (process === "stopped" || process === "crashed")
3352
3515
  continue;
3353
- if (process === "paused" && ["stopped", "crashed"].includes(this.daemons.get(name)?.getProcessStatus?.() ?? "unknown"))
3516
+ if (process === "paused" && this.pausedAndAsleep(name))
3354
3517
  continue;
3355
3518
  if (process !== "running" || this.getInstanceExecutionState(name) !== "idle")
3356
3519
  return false;
@@ -3359,6 +3522,22 @@ export class FleetManager {
3359
3522
  }
3360
3523
  return true;
3361
3524
  }
3525
+ /**
3526
+ * M-3960: a paused instance that is doing no work, for both idle checks (the Hub-requested update and Update when idle).
3527
+ * A pause persisted across a restart starts no daemon at all ("Persisted paused instance — skipping startup"): before,
3528
+ * that read as an unknown process, counted as busy and held every idle update until it expired. A live daemon is
3529
+ * asleep only once its process has stopped. A wake on its way is checked first, by wakeOnItsWay().
3530
+ */
3531
+ pausedAndAsleep(name) {
3532
+ const daemon = this.daemons.get(name);
3533
+ if (!daemon)
3534
+ return true;
3535
+ return ["stopped", "crashed"].includes(daemon.getProcessStatus?.() ?? "unknown");
3536
+ }
3537
+ /** M-3960: a wake of `name` is under way: its lifecycle flight, or the wake coordinator's admission. Busy for both idle checks. */
3538
+ wakeOnItsWay(name) {
3539
+ return this.lifecycle.wakeInFlight(name) || this.wakeCoordinator?.isWaking(name) === true;
3540
+ }
3362
3541
  async hubUpdateCanInstall() {
3363
3542
  const found = await npmForRunningInstall();
3364
3543
  if ("reason" in found)
@@ -7977,6 +8156,38 @@ export class FleetManager {
7977
8156
  return null;
7978
8157
  } }, canManage: (name, actor) => this.contactAdminOf(name, actor) }).inspect();
7979
8158
  }
8159
+ /**
8160
+ * M-3963: earlier unscoped uncertain deliveries grouped by source → target, newest first. Each group's id binds every
8161
+ * member's exact row image, so the resolve only acknowledges the rows the owner saw; with two or more groups, a first
8162
+ * "all" group binds every member. Ticket-bound ones are settled by their Retire instead.
8163
+ */
8164
+ requestContextUncertainGroups(box, shadow, deliveries = box.requestContextControlInventory().deliveries) {
8165
+ const settledByRetire = new Set(shadow.tickets.filter(row => ["legacy-unconfirmed", "missing-receipt", "malformed"].includes(row.disposition)).map(row => `contact:${row.id}`));
8166
+ const pairs = new Map();
8167
+ for (const row of deliveries.filter(row => !row.root && row.state === "uncertain")) {
8168
+ const delivery = box.get(row.id);
8169
+ if (!delivery || settledByRetire.has(delivery.sourceKey))
8170
+ continue;
8171
+ const key = JSON.stringify([row.source, row.target]), group = pairs.get(key) ?? { pair: [row.source, row.target], latest: 0, members: [] };
8172
+ group.members.push([row.id, box.requestContextLegacyAcknowledgementImage(row.id)]);
8173
+ const at = Date.parse(row.finished ?? "");
8174
+ if (Number.isFinite(at) && at > group.latest)
8175
+ group.latest = at;
8176
+ pairs.set(key, group);
8177
+ }
8178
+ const groups = [...pairs.values()].sort((a, b) => b.latest - a.latest || a.pair.join("\0").localeCompare(b.pair.join("\0"))).map(group => ({
8179
+ id: `legacy-uncertain:${requestContextDigest(group.pair).slice(0, 16)}:${requestContextDigest(group.members)}`, pair: group.pair,
8180
+ members: group.members, latestAt: group.latest ? new Date(group.latest).toISOString() : null, pairs: 1
8181
+ }));
8182
+ // Prism #4638: at most 32 pairs are listed; the older rest is one "more pairs" group (its own Acknowledge, its scope
8183
+ // shown), so Acknowledge all never covers pairs the owner can't see counted. Each acknowledgement lists the next ones.
8184
+ const listed = groups.slice(0, REQUEST_CONTEXT_UNCERTAIN_LISTED_PAIRS), rest = groups.slice(REQUEST_CONTEXT_UNCERTAIN_LISTED_PAIRS);
8185
+ const more = rest.length ? [{ id: `legacy-uncertain-more:${requestContextDigest(rest.map(group => group.id))}`, pair: null, members: rest.flatMap(group => group.members),
8186
+ latestAt: rest[0].latestAt, pairs: rest.length }] : [];
8187
+ if (groups.length < 2)
8188
+ return groups;
8189
+ return [{ id: `legacy-uncertain-all:${requestContextDigest(groups.map(group => group.id))}`, pair: null, members: groups.flatMap(group => group.members), latestAt: null, pairs: groups.length }, ...listed, ...more];
8190
+ }
7980
8191
  requestContextBlockers() {
7981
8192
  const box = this.deliveryOutbox;
7982
8193
  if (!box || !this.fleetConfig)
@@ -8019,14 +8230,33 @@ export class FleetManager {
8019
8230
  const sending = legacy.filter(row => ["delivering", "submission_started"].includes(row.state));
8020
8231
  if (sending.length)
8021
8232
  out.push({ id: "legacy-deliveries", kind: "legacy", labels: sending.map(pair).slice(0, 64) });
8022
- const needsTicketRetirement = new Set(shadow.tickets.filter(row => ["legacy-unconfirmed", "missing-receipt", "malformed"].includes(row.disposition)).map(row => `contact:${row.id}`));
8023
- for (const row of legacy.filter(row => row.state === "uncertain")) {
8024
- const delivery = box.get(row.id);
8025
- if (!delivery || needsTicketRetirement.has(delivery.sourceKey))
8026
- continue;
8027
- out.push({ id: `legacy-uncertain:${row.id}:${box.requestContextLegacyAcknowledgementImage(row.id)}`, kind: "legacy", labels: [`${label(row.source)} → ${label(row.target)}`], action: "acknowledge" });
8028
- }
8029
- const busy = [...this.daemons].filter(([name, daemon]) => { const row = daemon.requestContextLaunchObservation(); return row.observation.processStatus !== "running" || row.observation.executionState !== "idle" || row.pendingCalls || row.responseWaiters || row.queuedInputs || row.transcriptOpen || row.starting || row.stopping || this.requestContextPendingWork.count(name); }).map(([name]) => name);
8233
+ // M-3963: one Acknowledge per pair (newest first) and one for all of them, instead of a line per delivery.
8234
+ for (const group of this.requestContextUncertainGroups(box, shadow, inventory.deliveries))
8235
+ out.push({ id: group.id, kind: "legacy", labels: group.pair ? [`${label(group.pair[0])} → ${label(group.pair[1])}`] : [], count: group.members.length, ...(group.pair ? {} : { pairs: group.pairs }), ...(group.latestAt ? { latestAt: group.latestAt } : {}), action: "acknowledge" });
8236
+ // M-3963: the same busy test as before, now also naming what each agent is still doing (display only).
8237
+ const reasons = new Map();
8238
+ const busy = [...this.daemons].filter(([name, daemon]) => {
8239
+ const row = daemon.requestContextLaunchObservation(), pending = this.requestContextPendingWork.count(name);
8240
+ const why = [];
8241
+ if (row.observation.processStatus !== "running")
8242
+ why.push("not-running");
8243
+ if (row.starting)
8244
+ why.push("starting");
8245
+ if (row.stopping)
8246
+ why.push("stopping");
8247
+ if (row.observation.executionState !== "idle")
8248
+ why.push("turn");
8249
+ else if (row.transcriptOpen)
8250
+ why.push("unconfirmed-end");
8251
+ if (row.pendingCalls || row.responseWaiters)
8252
+ why.push("tool-calls");
8253
+ if (row.queuedInputs || pending)
8254
+ why.push("queued-input");
8255
+ const held = row.observation.processStatus !== "running" || row.observation.executionState !== "idle" || row.pendingCalls || row.responseWaiters || row.queuedInputs || row.transcriptOpen || row.starting || row.stopping || pending;
8256
+ if (held)
8257
+ reasons.set(name, why);
8258
+ return held;
8259
+ }).map(([name]) => name);
8030
8260
  for (const row of WindowsAgents.requestContextOwnersOnDisk(this.dataDir)) {
8031
8261
  const daemon = row.instance ? this.daemons.get(row.instance) : undefined;
8032
8262
  // An owned idle persistent pane participates in the controlled relaunch. An exec or cold orphan does not.
@@ -8035,9 +8265,12 @@ export class FleetManager {
8035
8265
  const name = row.instance ?? row.agentId;
8036
8266
  if (!busy.includes(name))
8037
8267
  busy.push(name);
8268
+ const why = reasons.get(name) ?? [];
8269
+ if (!why.includes("connected-computer"))
8270
+ reasons.set(name, [...why, "connected-computer"]);
8038
8271
  }
8039
8272
  if (busy.length)
8040
- out.push({ id: "busy", kind: "owners", labels: busy.map(label).slice(0, 64), agents: busy.map(id => ({ id, label: label(id) })).slice(0, 64), ownerCause: "work", action: "inspect" });
8273
+ out.push({ id: "busy", kind: "owners", labels: busy.map(label).slice(0, 64), agents: busy.map(id => ({ id, label: label(id), ...(reasons.get(id)?.length ? { reasons: reasons.get(id) } : {}) })).slice(0, 64), ownerCause: "work", action: "inspect" });
8041
8274
  const peers = this.captureRequestContextRuntimeSet(), old = peers.advertised();
8042
8275
  if (old.length)
8043
8276
  out.push({ id: "peers", kind: "peers", labels: peers.labels().filter(row => old.includes(row.id)).map(row => row.label).slice(0, 64), action: "inspect" });
@@ -8298,11 +8531,13 @@ export class FleetManager {
8298
8531
  return;
8299
8532
  }
8300
8533
  const box = this.deliveryOutbox, modes = this.requestContextModes, state = box?.requestContextInstallation().read();
8301
- if (box && !state && blocker.id.startsWith("legacy-uncertain:") && blocker.action === "acknowledge") {
8302
- const match = /^legacy-uncertain:([A-Za-z0-9._:-]{1,128}):([a-f0-9]{64})$/.exec(blocker.id);
8303
- if (!match || !actor.verified || !actor.execution || !current())
8534
+ if (box && !state && /^legacy-uncertain(?:-all|-more)?:/.test(blocker.id) && blocker.action === "acknowledge") {
8535
+ if (!actor.verified || !actor.execution || !current())
8304
8536
  throw Error("stale");
8305
- actor.execution.mutate(() => box.acknowledgeRequestContextLegacyDelivery(match[1], match[2], actor.binding, current));
8537
+ const group = this.requestContextUncertainGroups(box, this.requestContextShadow()).find(row => row.id === blocker.id);
8538
+ if (!group)
8539
+ throw Error("stale");
8540
+ actor.execution.mutate(() => box.acknowledgeRequestContextLegacyDeliveries(group.members, actor.binding, current));
8306
8541
  return;
8307
8542
  }
8308
8543
  if (!box || !modes?.current() || state?.mode !== "draining" || !current())
@@ -10916,7 +11151,15 @@ export class FleetManager {
10916
11151
  }
10917
11152
  // Bare slash /update is the card. `/update now` (options.now) keeps today's immediate path.
10918
11153
  if (data.options?.now !== true) {
10919
- await data.respond(this.describeUpdateOffer());
11154
+ // M-3967: the card with its buttons, as the slash's own public reply; anything else in words.
11155
+ const adapter = this.adapters.get(adapterId) ?? this.adapter;
11156
+ if (adapter && data.respondButtons) {
11157
+ const words = await this.showUpdateCard({ adapter, adapterId, chatId: data.channelId, respondButtons: data.respondButtons });
11158
+ if (words !== null)
11159
+ await data.respond(words);
11160
+ return;
11161
+ }
11162
+ await data.respond(await this.describeFreshUpdateOffer());
10920
11163
  return;
10921
11164
  }
10922
11165
  const refused = this.refuseImmediateUpdate();
@@ -10925,6 +11168,7 @@ export class FleetManager {
10925
11168
  return;
10926
11169
  }
10927
11170
  const messageId = await data.respond(t("update.progress.preparing", 0));
11171
+ await this.refreshUpdateOffer(); // M-3964: the run's label is what it installs
10928
11172
  const adapter = this.adapters.get(adapterId) ?? this.adapter;
10929
11173
  if (messageId && adapter) {
10930
11174
  const chatId = String(this.getChannelConfig(adapterId)?.group_id ?? data.channelId);
@@ -24696,6 +24940,8 @@ export class FleetManager {
24696
24940
  return true;
24697
24941
  if (await this.handleUpdateCardCallback(data, adapterId, adapter))
24698
24942
  return true; // M-3770 1.5
24943
+ if (await this.handleUpdateNowCallback(data, adapterId, adapter))
24944
+ return true; // M-3967
24699
24945
  if (await this.handleKiroReconcileCallback(data, adapterId, adapter))
24700
24946
  return true;
24701
24947
  if (await this.handleOfficePackCallback(data, adapterId, adapter))
@@ -37229,10 +37475,14 @@ export class FleetManager {
37229
37475
  out.push(this.shownInstanceName(name));
37230
37476
  continue;
37231
37477
  }
37478
+ if (this.wakeOnItsWay(name)) {
37479
+ out.push(this.shownInstanceName(name));
37480
+ continue;
37481
+ } // M-3960: before any status skip
37232
37482
  const process = this.getInstanceStatus(name);
37233
37483
  if (process === "stopped" || process === "crashed")
37234
37484
  continue;
37235
- if (process === "paused" && ["stopped", "crashed"].includes(this.daemons.get(name)?.getProcessStatus?.() ?? "unknown"))
37485
+ if (process === "paused" && this.pausedAndAsleep(name))
37236
37486
  continue;
37237
37487
  if (process !== "running" || this.getInstanceExecutionState(name) !== "idle" || this.getInstanceInteraction(name)?.phase === "waiting") {
37238
37488
  out.push(this.shownInstanceName(name));
@@ -37284,6 +37534,28 @@ export class FleetManager {
37284
37534
  const reply = updateOfferReply(this.updateOfferView(), current, pinned, this.usageZone());
37285
37535
  return t(reply.key, ...reply.args);
37286
37536
  }
37537
+ /**
37538
+ * M-3964: bare `/update` answers from a fresh check, not one up to a day old (a fleet that last checked before a new
37539
+ * beta offered the older one). One a minute (checkUpdateNow); a slow npm is cut off at 10 s and the stored check answers.
37540
+ */
37541
+ async describeFreshUpdateOffer() {
37542
+ await this.refreshUpdateOffer();
37543
+ return this.describeUpdateOffer();
37544
+ }
37545
+ /**
37546
+ * M-3964: look again before an unpinned run too, so the card names what `agend update` is about to install (the newest
37547
+ * on the line), not an offer from hours ago. At most 10 s; then the stored check stands.
37548
+ */
37549
+ async refreshUpdateOffer() {
37550
+ let timer;
37551
+ const late = new Promise(resolve => { timer = setTimeout(resolve, FRESH_UPDATE_OFFER_WAIT_MS); timer.unref?.(); });
37552
+ try {
37553
+ await Promise.race([this.checkUpdateNow().catch(() => undefined), late]);
37554
+ }
37555
+ finally {
37556
+ clearTimeout(timer);
37557
+ }
37558
+ }
37287
37559
  refuseImmediateUpdate() {
37288
37560
  return resolveUpdates(this.fleetConfig?.updates).pin ? t("update.offer.pinned") : null;
37289
37561
  }
@@ -37415,6 +37687,9 @@ export class FleetManager {
37415
37687
  * targets no chat message (WEB_UPDATE_ADAPTER); the page reads the stages the updater writes into it.
37416
37688
  */
37417
37689
  async startWebUpdate(person, stillAllowed, pin, hubRequestId) {
37690
+ // M-3964: an unpinned run installs the newest on the line; look again first so the card names that version.
37691
+ if (!pin && !hubRequestId)
37692
+ await this.refreshUpdateOffer();
37418
37693
  if (resolveUpdates(this.fleetConfig?.updates).pin)
37419
37694
  return { ok: false, status: 409, error: "pinned" };
37420
37695
  if (this.shuttingDown)