@songsid/agend 2.4.0-beta.21 → 2.4.0-beta.22

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 (157) hide show
  1. package/dist/backend/claude-code.js +3 -0
  2. package/dist/backend/claude-code.js.map +1 -1
  3. package/dist/build-provenance.json +1 -1
  4. package/dist/cache-ledger.d.ts +23 -21
  5. package/dist/cache-ledger.js +70 -6
  6. package/dist/cache-ledger.js.map +1 -1
  7. package/dist/cache-prices.d.ts +8 -6
  8. package/dist/cache-prices.js +12 -5
  9. package/dist/cache-prices.js.map +1 -1
  10. package/dist/cache-service.d.ts +9 -5
  11. package/dist/cache-service.js +202 -50
  12. package/dist/cache-service.js.map +1 -1
  13. package/dist/cli-audited.js +2 -1
  14. package/dist/cli-audited.js.map +1 -1
  15. package/dist/cli.js +4 -1
  16. package/dist/cli.js.map +1 -1
  17. package/dist/contact-auth-policy.js +1 -1
  18. package/dist/contact-auth-policy.js.map +1 -1
  19. package/dist/contact-auth-service.js +8 -2
  20. package/dist/contact-auth-service.js.map +1 -1
  21. package/dist/contact-auth-store.d.ts +3 -0
  22. package/dist/contact-auth-store.js +34 -8
  23. package/dist/contact-auth-store.js.map +1 -1
  24. package/dist/contact-auth-types.d.ts +3 -2
  25. package/dist/contact-auth-types.js.map +1 -1
  26. package/dist/contact-change-proposals.js +3 -2
  27. package/dist/contact-change-proposals.js.map +1 -1
  28. package/dist/daemon.d.ts +31 -0
  29. package/dist/daemon.js +149 -2
  30. package/dist/daemon.js.map +1 -1
  31. package/dist/delivery-outbox.d.ts +10 -0
  32. package/dist/delivery-outbox.js +21 -0
  33. package/dist/delivery-outbox.js.map +1 -1
  34. package/dist/fleet-manager.d.ts +40 -0
  35. package/dist/fleet-manager.js +173 -18
  36. package/dist/fleet-manager.js.map +1 -1
  37. package/dist/general-knowledge/skills/hub/SKILL.md +6 -3
  38. package/dist/hub/agent-pictures-model.d.ts +128 -0
  39. package/dist/hub/agent-pictures-model.js +43 -4
  40. package/dist/hub/agent-pictures-model.js.map +1 -1
  41. package/dist/hub/agent-pictures.d.ts +14 -2
  42. package/dist/hub/agent-pictures.js +65 -12
  43. package/dist/hub/agent-pictures.js.map +1 -1
  44. package/dist/hub/client.d.ts +2 -0
  45. package/dist/hub/client.js +9 -2
  46. package/dist/hub/client.js.map +1 -1
  47. package/dist/hub/compose/member.d.ts +4 -1
  48. package/dist/hub/compose/member.js +18 -6
  49. package/dist/hub/compose/member.js.map +1 -1
  50. package/dist/hub/compose/server.d.ts +5 -5
  51. package/dist/hub/compose/server.js +5 -3
  52. package/dist/hub/compose/server.js.map +1 -1
  53. package/dist/hub/http/compose.d.ts +3 -0
  54. package/dist/hub/http/compose.js +9 -7
  55. package/dist/hub/http/compose.js.map +1 -1
  56. package/dist/hub/http/deps.d.ts +1 -0
  57. package/dist/hub/http/schema.js +2 -1
  58. package/dist/hub/http/schema.js.map +1 -1
  59. package/dist/hub/init/text.js +1 -1
  60. package/dist/hub/mcp/policy.d.ts +1 -1
  61. package/dist/hub/member/agent-pictures.d.ts +34 -1
  62. package/dist/hub/member/agent-pictures.js +80 -9
  63. package/dist/hub/member/agent-pictures.js.map +1 -1
  64. package/dist/hub/member/room-ask.d.ts +22 -1
  65. package/dist/hub/member/room-ask.js +99 -5
  66. package/dist/hub/member/room-ask.js.map +1 -1
  67. package/dist/hub/member/room-asker-store.d.ts +48 -0
  68. package/dist/hub/member/room-asker-store.js +181 -0
  69. package/dist/hub/member/room-asker-store.js.map +1 -0
  70. package/dist/hub/protocol.d.ts +131 -0
  71. package/dist/hub/protocol.js +3 -1
  72. package/dist/hub/protocol.js.map +1 -1
  73. package/dist/hub/representative.d.ts +10 -0
  74. package/dist/hub/representative.js +13 -0
  75. package/dist/hub/representative.js.map +1 -1
  76. package/dist/hub/room-asker-identity-model.d.ts +53 -0
  77. package/dist/hub/room-asker-identity-model.js +14 -0
  78. package/dist/hub/room-asker-identity-model.js.map +1 -0
  79. package/dist/hub/room-asker-identity.d.ts +22 -0
  80. package/dist/hub/room-asker-identity.js +43 -0
  81. package/dist/hub/room-asker-identity.js.map +1 -0
  82. package/dist/hub/rooms/agents.js +16 -0
  83. package/dist/hub/rooms/agents.js.map +1 -1
  84. package/dist/hub/rooms/asker-identity.d.ts +21 -0
  85. package/dist/hub/rooms/asker-identity.js +86 -0
  86. package/dist/hub/rooms/asker-identity.js.map +1 -0
  87. package/dist/hub/rooms/office.d.ts +18 -0
  88. package/dist/hub/rooms/office.js +3 -1
  89. package/dist/hub/rooms/office.js.map +1 -1
  90. package/dist/hub/rooms/service.d.ts +6 -0
  91. package/dist/hub/rooms/service.js +19 -0
  92. package/dist/hub/rooms/service.js.map +1 -1
  93. package/dist/hub/server.js +7 -2
  94. package/dist/hub/server.js.map +1 -1
  95. package/dist/hub/types.d.ts +1 -0
  96. package/dist/hub-character-plan.d.ts +47 -0
  97. package/dist/hub-character-plan.js +70 -0
  98. package/dist/hub-character-plan.js.map +1 -0
  99. package/dist/hub-contact-windows.d.ts +13 -1
  100. package/dist/hub-contact-windows.js +35 -2
  101. package/dist/hub-contact-windows.js.map +1 -1
  102. package/dist/hub-picture-reduce.d.ts +21 -1
  103. package/dist/hub-picture-reduce.js +65 -13
  104. package/dist/hub-picture-reduce.js.map +1 -1
  105. package/dist/hub-picture-worker.js +12 -4
  106. package/dist/hub-picture-worker.js.map +1 -1
  107. package/dist/locale.js +267 -263
  108. package/dist/locale.js.map +1 -1
  109. package/dist/ls-rows.d.ts +2 -0
  110. package/dist/ls-rows.js.map +1 -1
  111. package/dist/needs-you.d.ts +2 -0
  112. package/dist/needs-you.js +1 -1
  113. package/dist/needs-you.js.map +1 -1
  114. package/dist/outbound-handlers.d.ts +4 -0
  115. package/dist/outbound-handlers.js +16 -2
  116. package/dist/outbound-handlers.js.map +1 -1
  117. package/dist/runtime-cli-install.js +4 -4
  118. package/dist/runtime-cli-install.js.map +1 -1
  119. package/dist/tips.js +3 -3
  120. package/dist/ui/agent-export-strings.js +1 -1
  121. package/dist/ui/agent-page-strings.js +5 -5
  122. package/dist/ui/contact-auth-client.js +2 -2
  123. package/dist/ui/fleet-cache.js +5 -5
  124. package/dist/ui/fleet-canvas.js +1 -1
  125. package/dist/ui/fleet-office-card.js +26 -2
  126. package/dist/ui/fleet-office-layout.js +2 -2
  127. package/dist/ui/fleet-office-skin.js +16 -0
  128. package/dist/ui/fleet-office-view.js +32 -0
  129. package/dist/ui/fleet-office.js +80 -24
  130. package/dist/ui/fleet-org.js +3 -3
  131. package/dist/ui/fleet-task-common.js +2 -2
  132. package/dist/ui/fleet-usage.js +6 -6
  133. package/dist/ui/hub-admin-overview.js +1 -1
  134. package/dist/ui/hub-chat-strings.js +1 -1
  135. package/dist/ui/hub-my-agents-strings.js +2 -2
  136. package/dist/ui/hub-my-agents.js +1 -1
  137. package/dist/ui/hub-room-office.js +70 -2
  138. package/dist/ui/hub-room-presence.js +5 -0
  139. package/dist/ui/panel-fleet.js +5 -5
  140. package/dist/ui/panel-log.js +3 -3
  141. package/dist/ui/panel-runtimes.js +2 -2
  142. package/dist/ui/runtime-cli-install.js +1 -1
  143. package/dist/ui/runtime-update-status.js +1 -1
  144. package/dist/ui/settings-access-strings.js +1 -1
  145. package/dist/ui/settings-hub-setup-strings.js +1 -1
  146. package/dist/ui/settings-layout.js +2 -2
  147. package/dist/ui/settings-named-test.js +16 -16
  148. package/dist/ui/settings-public-session-strings.js +2 -2
  149. package/dist/ui/settings-revoke-strings.js +1 -1
  150. package/dist/ui/settings-shared-strings.js +2 -2
  151. package/dist/ui/settings-strings.js +40 -40
  152. package/dist/ui/shared/app-shell.js +1 -1
  153. package/dist/ui/shared/app.css +22 -3
  154. package/dist/ui/shared/chat-strings.js +8 -8
  155. package/dist/ui/shared/instance-nav.js +36 -2
  156. package/dist/ui/shared/view-strings.js +27 -9
  157. package/package.json +1 -1
@@ -23,6 +23,7 @@ import { ContactAuthService } from "./contact-auth-service.js";
23
23
  import { stageContactFiles } from "./contact-auth-files.js";
24
24
  import { ContactOriginClearSchema, ContactPermissionsSchema, sameContactPerson } from "./contact-auth-policy.js";
25
25
  import { CLASSIC_RESTRICTED_TOOLS } from "./contact-auth-types.js";
26
+ import { contactPersonKey, normalizeContactPersonKey } from "./contact-auth-store.js";
26
27
  import { hubSharingNoticeText } from "./hub-sharing-notice.js";
27
28
  import { hubPageSharingSettings } from "./hub-page-sharing-settings.js";
28
29
  import { replyPreviews } from "./reply-preview-spec.js";
@@ -280,7 +281,8 @@ import { ThemeStore } from "./web-theme-store.js";
280
281
  import { OfficeStore, OfficeWriteLimiter } from "./web-office-store.js";
281
282
  import { WebPinStore } from "./web-pin-store.js";
282
283
  import { OfficeSkinStore } from "./web-office-skins.js";
283
- import { OfficeActs } from "./web-office-acts.js";
284
+ import { OfficeActs, officeMembers } from "./web-office-acts.js";
285
+ import { characterPlan, ownCharacter } from "./hub-character-plan.js";
284
286
  import { OFFICE_PACK_TOOLS, OfficePackTools } from "./web-office-pack-tools.js";
285
287
  import { WebAppearance } from "./web-appearance.js";
286
288
  import { effectiveAppearanceLimits } from "./web-appearance-limits.js";
@@ -2798,6 +2800,7 @@ export class FleetManager {
2798
2800
  scratchDir: agent => isSafeInstanceDirName(agent) ? join(this.dataDir, "workspaces", agent, "hub-files") : null },
2799
2801
  attachReports: (handler, failed) => { this.hubReports = handler; this.hubDeliveryFailed = failed; },
2800
2802
  attachPrivateQuestions: read => { this.hubPrivateQuestions = read; },
2803
+ attachQuestionSettled: read => { this.hubQuestionSettled = read; },
2801
2804
  attachReacts: handler => { this.hubReacts = handler; },
2802
2805
  },
2803
2806
  attachAgentIntro: port => { this.hubAgentIntro = port; },
@@ -2987,7 +2990,53 @@ export class FleetManager {
2987
2990
  portrait = { key: person ? `card:${person}` : `agent-card:${own}`, load: () => cardPicture({ dataDir: this.dataDir, themeStore: this.themeStore }, name, "portrait") };
2988
2991
  }
2989
2992
  catch { /* unreadable: no pictures */ }
2990
- return { disc, portrait };
2993
+ let character = null;
2994
+ try {
2995
+ character = this.hubCharacterSource(name);
2996
+ }
2997
+ catch { /* unreadable offices or packs: no character */ }
2998
+ return { disc, portrait, character };
2999
+ }
3000
+ /**
3001
+ * M-3533 R2c: the agent's own character (hub-character-plan.ts ownCharacter): the set its owner gave it by name in
3002
+ * the first of these offices (their own order) holding it, else in the "All" office's pack. The key is that pack's version
3003
+ * and the set's name: a changed pack, set or office changes it; the pictures are read and cut only then.
3004
+ */
3005
+ hubCharacterSource(name) {
3006
+ const list = this.officeStore.list();
3007
+ if (!list.readable)
3008
+ return null;
3009
+ let chart = null;
3010
+ const holds = (office, agent) => {
3011
+ if (!office.members.length)
3012
+ return true;
3013
+ if (office.members.includes(agent))
3014
+ return true;
3015
+ if (!office.members.some(m => m.startsWith("team:")))
3016
+ return false;
3017
+ chart ??= (() => { const c = this.orgChart(); return { names: Object.keys(c.instances), teams: c.teams }; })();
3018
+ return officeMembers({ members: [...office.members] }, chart).includes(agent);
3019
+ };
3020
+ const hit = ownCharacter({ offices: list.offices, autoSkin: list.autoSkin ?? null, holds, pack: id => this.officeSkins.pack(id) }, name);
3021
+ if (!hit)
3022
+ return null;
3023
+ const sha = this.officeSkins.list().packs.find(p => p.id === hit.packId)?.sha;
3024
+ if (!sha)
3025
+ return null;
3026
+ return { key: `${hit.packId}@${sha}:${hit.set}`, load: () => {
3027
+ const pack = this.officeSkins.pack(hit.packId), files = this.officeSkins.get(hit.packId)?.files;
3028
+ const plan = pack && files ? characterPlan(pack.characters[hit.set]) : null;
3029
+ if (!plan)
3030
+ return null;
3031
+ const pictures = new Map();
3032
+ for (const src of plan.sources) {
3033
+ const id = files[src], bytes = id ? this.officeSkins.picture(hit.packId, id) : null;
3034
+ if (!bytes)
3035
+ return null;
3036
+ pictures.set(src, bytes);
3037
+ }
3038
+ return { plan, pictures };
3039
+ } };
2991
3040
  }
2992
3041
  /** The actual launch target, including Classic's own effective backend/folder; never aliases a room to a Fleet topic. */
2993
3042
  hubAgentConfig(agent) {
@@ -3250,7 +3299,80 @@ export class FleetManager {
3250
3299
  contactWindows() {
3251
3300
  return this.hubContactWindows ??= new HubContactWindows(join(this.dataDir, "hub-contact-windows.json"));
3252
3301
  }
3253
- hubContactRestricted(agent) { return this.contactWindows().restricted(agent); }
3302
+ /**
3303
+ * M-3660: each agent's running Hub answer turn as its daemon tells it (re-told on every connect): a correlation id, or
3304
+ * null for "confirmed none". An agent missing here is unknown (this fleet has not heard from its daemon since it
3305
+ * started): nothing settled lifts its windows then — they hold until the daemon says (Prism #4420 P2-1).
3306
+ */
3307
+ hubAnswerTurns = new Map();
3308
+ /**
3309
+ * M-3660: the agent's daemon is about to write a Hub question into its idle pane: the answer turn's window opens (none for
3310
+ * a share that opted out). A window that cannot be saved still holds in memory: fail closed.
3311
+ */
3312
+ hubQuestionInput(agent, correlationId, contactLimit = true) {
3313
+ this.hubAnswerTurns.set(agent, correlationId);
3314
+ if (!contactLimit)
3315
+ return;
3316
+ try {
3317
+ this.contactWindows().begin(agent, correlationId);
3318
+ }
3319
+ catch (err) {
3320
+ this.logger.warn({ err, agent }, "Hub contact window could not be saved; it holds until this fleet restarts or it expires");
3321
+ }
3322
+ }
3323
+ /** M-3660: that answer turn is over (its idle edge, or the next turn's write): the window closes, whatever came of it. */
3324
+ hubQuestionTurnEnded(agent, correlationId) {
3325
+ if (this.hubAnswerTurns.get(agent) === correlationId)
3326
+ this.hubAnswerTurns.set(agent, null);
3327
+ try {
3328
+ this.contactWindows().answered(agent, correlationId);
3329
+ }
3330
+ catch (err) {
3331
+ this.logger.warn({ err, agent }, "Hub contact window could not be closed; it will expire");
3332
+ }
3333
+ }
3334
+ /**
3335
+ * M-3660: what the daemon says on (re)connect — the turn it is answering now, or none. A lost hub_question_input or
3336
+ * hub_question_turn_ended (a stale connection, a fleet or daemon restart) is made good here: with no turn running every
3337
+ * window of the agent ends; with one, that one holds and the rest end.
3338
+ */
3339
+ hubQuestionTurnState(agent, correlationId, contactLimit = true) {
3340
+ try {
3341
+ this.contactWindows().closeAgent(agent, correlationId ?? undefined);
3342
+ }
3343
+ catch (err) {
3344
+ this.logger.warn({ err, agent }, "Hub contact windows could not be reconciled; they will expire");
3345
+ }
3346
+ if (correlationId)
3347
+ this.hubQuestionInput(agent, correlationId, contactLimit);
3348
+ else
3349
+ this.hubAnswerTurns.set(agent, null);
3350
+ }
3351
+ /** M-3660: a daemon's Hub turn signal (from its current connection). "unknown" (an unreadable turn record) changes nothing. */
3352
+ hubTurnSignal(agent, msg) {
3353
+ const cid = typeof msg.correlationId === "string" && /^hub-[A-Za-z0-9-]+$/.test(msg.correlationId) ? msg.correlationId : null;
3354
+ if (msg.type === "hub_question_turn_state") {
3355
+ if (msg.unknown !== true && (cid || msg.correlationId === null))
3356
+ this.hubQuestionTurnState(agent, cid, msg.contactLimit !== false);
3357
+ }
3358
+ else if (cid && msg.type === "hub_question_input")
3359
+ this.hubQuestionInput(agent, cid, msg.contactLimit !== false);
3360
+ else if (cid && msg.type === "hub_question_turn_ended")
3361
+ this.hubQuestionTurnEnded(agent, cid);
3362
+ }
3363
+ /** M-3660: the agent's daemon has told this fleet its current turn, and it is not this question (unknown is never "none"). */
3364
+ hubAnswerTurnKnownNone(agent, correlationId) {
3365
+ return this.hubAnswerTurns.has(agent) && this.hubAnswerTurns.get(agent) !== correlationId;
3366
+ }
3367
+ /** M-3660: a settled question lifts its window only outside its own running answer turn; inside it, the turn's end does. */
3368
+ hubSettledOutsideTurn() {
3369
+ const settled = this.hubQuestionSettled;
3370
+ return settled ? (agent, correlationId) => this.hubAnswerTurnKnownNone(agent, correlationId) && settled(agent, correlationId) : undefined;
3371
+ }
3372
+ /** M-3660: the member side's "this question is no longer being answered" reader (null: no member service attached). */
3373
+ hubQuestionSettled = null;
3374
+ hubContactRestricted(agent) { return this.contactWindows().restricted(agent, this.hubSettledOutsideTurn()); }
3375
+ hubContactQuestion(agent) { return this.contactWindows().restrictingQuestion(agent, this.hubSettledOutsideTurn()); }
3254
3376
  /**
3255
3377
  * M-3313 (#4145 for the Hub): what a Hub question or room notification hands the agent, with this fleet's sign-in
3256
3378
  * access token hidden (exact match, as a chat's). The live one is taken back and replaced, and the sign-in's chat told.
@@ -3305,6 +3427,9 @@ export class FleetManager {
3305
3427
  };
3306
3428
  if (input.roomContextGeneration)
3307
3429
  ipcMeta.hub_room_context_generation = input.roomContextGeneration;
3430
+ // M-3660: the share's opt-out travels with the question; its daemon's hub_question_input then opens no window.
3431
+ if (input.contactLimit === false)
3432
+ ipcMeta.hub_contact_limit = "off";
3308
3433
  const result = await this.deliverToInstance(input.agent, { type: "fleet_inbound", targetSession: input.agent, content: this.screenHubText(input.text), meta: ipcMeta }, { isCrossInstance: true, stillCurrent: input.stillCurrent, beforeInput: async () => {
3309
3434
  const classic = this.isClassicInstance(input.agent);
3310
3435
  // A busy Classic room must finish its public turn first; never force a private question into that turn's queue.
@@ -3323,9 +3448,9 @@ export class FleetManager {
3323
3448
  return false;
3324
3449
  this.classicPrivacy().begin(input.agent, input.correlationId);
3325
3450
  }
3326
- // Before any possible IPC exposure. An uncertain write retains the window, never replays the question.
3327
- if (input.contactLimit !== false)
3328
- this.contactWindows().begin(input.agent, input.correlationId);
3451
+ // M-3660: the window covers only the turn that answers the question. The agent's daemon (Classic rooms' too)
3452
+ // writes it only into an idle pane, as a turn of its own, and says so just before the write (hub_question_input),
3453
+ // so a question waiting behind another turn — or never written — opens nothing.
3329
3454
  return input.stillCurrent();
3330
3455
  } });
3331
3456
  return result !== false;
@@ -3453,7 +3578,8 @@ export class FleetManager {
3453
3578
  if (!result)
3454
3579
  return null;
3455
3580
  return result.then(outcome => {
3456
- if (outcome.ok) {
3581
+ // M-3660: an accepted answer inside its own running answer turn does not lift it: the turn's end does.
3582
+ if (outcome.ok && this.hubAnswerTurnKnownNone(input.caller, input.correlationId)) {
3457
3583
  try {
3458
3584
  this.contactWindows().answered(input.caller, input.correlationId);
3459
3585
  }
@@ -6164,14 +6290,30 @@ export class FleetManager {
6164
6290
  throw Error("unavailable");
6165
6291
  return incarnation;
6166
6292
  }
6293
+ /** Eligible connections share a platform; the current Fleet-admin gate still decides each user's role. */
6294
+ contactAdminAdapterIds(adapter) {
6295
+ const channels = this.fleetConfig?.channels ?? (this.fleetConfig?.channel ? [this.fleetConfig.channel] : []);
6296
+ return [...new Set([adapter.id, ...channels.filter(ch => ch.type === adapter.type).map(ch => ch.id ?? ch.type)])];
6297
+ }
6298
+ /** Contact permissions identify a person by platform/user; sibling bot connections do not create new people. */
6299
+ contactDefaultApprovers(name) {
6300
+ const adapter = this.contactAdapter(name);
6301
+ if (!adapter || (adapter.type !== "discord" && adapter.type !== "telegram"))
6302
+ return [];
6303
+ const people = this.contactAdminAdapterIds(adapter).flatMap(id => (this.adminListOf(id) ?? []).map(userId => ({
6304
+ platform: adapter.type, adapterId: id, userId, label: userId
6305
+ })));
6306
+ return [...new Map(people.map(person => [contactPersonKey(person), person])).values()];
6307
+ }
6167
6308
  contactAdminOf(name, actor) {
6168
6309
  if (actor.platform === "host" && actor.adapterId === "host" && actor.userId === "operator")
6169
6310
  return true;
6170
6311
  const adapter = this.contactAdapter(name);
6171
- if (!adapter || actor.adapterId !== adapter.id || actor.platform !== adapter.type)
6312
+ if (!adapter || actor.platform !== adapter.type)
6172
6313
  return false;
6173
- return this.isFleetAdmin(actor.userId, adapter.id)
6174
- || (!!this.contactRoom(name) && this.classicChannels?.isAdmin(actor.userId) === true);
6314
+ if (this.contactAdminAdapterIds(adapter).some(id => this.isFleetAdmin(actor.userId, id)))
6315
+ return true;
6316
+ return !!this.contactRoom(name) && this.classicChannels?.isAdmin(actor.userId) === true;
6175
6317
  }
6176
6318
  contactService() {
6177
6319
  this.ensureDeliveryOutbox();
@@ -6179,12 +6321,7 @@ export class FleetManager {
6179
6321
  restricted: name => this.contactRoom(name)?.restrictedMode === true,
6180
6322
  legacyClassic: name => !!this.contactRoom(name) && this.contactRoom(name)?.restrictedMode !== true,
6181
6323
  adminOf: (name, actor) => this.contactAdminOf(name, actor),
6182
- defaultApprovers: name => {
6183
- const adapter = this.contactAdapter(name);
6184
- if (!adapter || (adapter.type !== "discord" && adapter.type !== "telegram"))
6185
- return [];
6186
- return (this.adminListOf(adapter.id) ?? []).map(userId => ({ platform: adapter.type, adapterId: adapter.id, userId, label: userId }));
6187
- },
6324
+ defaultApprovers: name => this.contactDefaultApprovers(name),
6188
6325
  generation: name => this.contactGeneration(name),
6189
6326
  hubRestricted: name => this.hubContactRestricted(name),
6190
6327
  delivered: ticket => !!ticket.deliveryId && this.deliveryOutbox.get(ticket.deliveryId)?.state === "delivered",
@@ -6439,7 +6576,7 @@ export class FleetManager {
6439
6576
  const view = service.view(ticket, actor);
6440
6577
  if (filter.status && view.state !== filter.status)
6441
6578
  return [];
6442
- if (filter.person && !view.origin.people.some(person => JSON.stringify([person.platform, person.adapterId, person.userId]) === filter.person))
6579
+ if (filter.person && !view.origin.people.some(person => contactPersonKey(person) === normalizeContactPersonKey(filter.person ?? "")))
6443
6580
  return [];
6444
6581
  return [view];
6445
6582
  }
@@ -7545,6 +7682,15 @@ export class FleetManager {
7545
7682
  clearUpdateMarker(this.dataDir);
7546
7683
  }
7547
7684
  // ── ArchiverContext bridge ────────────────────────────────────────────
7685
+ /** M-3674: the last turn another agent started for `name` (the delivery outbox), ISO or null; never throws. */
7686
+ lastAgentTurnOf(name) {
7687
+ try {
7688
+ return this.deliveryOutbox?.lastAgentTurn(name) ?? null;
7689
+ }
7690
+ catch {
7691
+ return null;
7692
+ }
7693
+ }
7548
7694
  lastActivityMs(name) {
7549
7695
  return this.lastActivity.get(name) ?? 0;
7550
7696
  }
@@ -14780,6 +14926,11 @@ export class FleetManager {
14780
14926
  if (this.instanceIpcClients.get(name) === ipc && typeof msg.generation === "string" && typeof msg.turn === "string")
14781
14927
  void this.hubRoomOwed?.turnEnded(name, msg.generation, msg.turn).catch(err => this.logger.warn({ err }, "Hub room completion notice held"));
14782
14928
  }
14929
+ else if (msg.type === "hub_question_input" || msg.type === "hub_question_turn_ended" || msg.type === "hub_question_turn_state") {
14930
+ // M-3660: only the instance's current daemon speaks for its pane's turns.
14931
+ if (this.instanceIpcClients.get(name) === ipc)
14932
+ this.hubTurnSignal(name, msg);
14933
+ }
14783
14934
  else if (msg.type === "hub_room_input") {
14784
14935
  if (this.instanceIpcClients.get(name) === ipc && typeof msg.correlationId === "string" && typeof msg.generation === "string")
14785
14936
  this.hubRoomInput?.(msg.correlationId, name, msg.generation);
@@ -33446,6 +33597,8 @@ export class FleetManager {
33446
33597
  // User activity is persisted by the daemon, so both the board and
33447
33598
  // auto-pause retain an accurate age across fleet restarts.
33448
33599
  lastActivity,
33600
+ // M-3674: the last turn another agent started (lastActivity is a person's side).
33601
+ lastAgentTurn: inst.classic ? null : this.lastAgentTurnOf(inst.name),
33449
33602
  currentTask,
33450
33603
  idle: this.getInstanceIdle(inst.name),
33451
33604
  ...this.instancePresentation(inst.name),
@@ -33901,7 +34054,7 @@ export class FleetManager {
33901
34054
  model: nativeConfig.model || "default", model_source: nativeConfig.model ? "instance" : "cli-default",
33902
34055
  status: agent && runtime ? runtime.status(name) : "crashed", state: agent && runtime ? runtime.execution(name) : null, execution_state: agent && runtime ? runtime.execution(name) : null,
33903
34056
  interaction: null, interaction_summary: null, context_pct: null, cost: null,
33904
- last_reply: this.webChatHistory.lastAgentReply(name) ?? undefined,
34057
+ last_reply: this.webChatHistory.lastAgentReply(name) ?? undefined, last_agent_turn: this.lastAgentTurnOf(name) ?? undefined,
33905
34058
  avatar: avatarFor({ name, displayName: display_name }),
33906
34059
  capabilities: { chat: true, settings: true, pause: true, cancel: true, teams: true, schedules: true, delegation: true, mcp: nativeProviderMcpSupported(backend), channels: false, terminal: false, attachments: false, usage: false, send_while_busy: false },
33907
34060
  ...(!agent ? { runtime_error: "Windows profile is missing or invalid; restore its saved conversation before using this instance" }
@@ -33987,6 +34140,8 @@ export class FleetManager {
33987
34140
  // #3008 G2: a web-only fleet's General (the agent its owner ticked) — the sidebar pins it first.
33988
34141
  ...(this.isWebOnlyFleet() && this.fleetConfig?.instances[name]?.general_topic === true ? { general: true } : {}),
33989
34142
  last_reply: this.webChatHistory.lastAgentReply(name) ?? undefined, // #2179: its last reply to a person (ISO)
34143
+ // M-3674: its last turn another agent started (a message from another instance it took up), beside last_reply.
34144
+ last_agent_turn: this.lastAgentTurnOf(name) ?? undefined,
33990
34145
  // #2855: its last reply that reached the channel — the only reply time a guest's sidebar gets (guestStatus).
33991
34146
  last_reply_channel: this.webChatHistory.lastAgentReply(name, { channel: true }) ?? undefined,
33992
34147
  // #2855: the web commands a guest may run here — the table's "anyone" cells for this channel (guestWebCommands);