@songsid/agend 2.4.0-alpha.1 → 2.4.0-alpha.2

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 (235) hide show
  1. package/README.md +1 -1
  2. package/README.zh-TW.md +1 -1
  3. package/dist/agent-whats-new.js +2 -0
  4. package/dist/agent-whats-new.js.map +1 -1
  5. package/dist/auth-api.js +3 -1
  6. package/dist/auth-api.js.map +1 -1
  7. package/dist/backend/claude-code.js +4 -0
  8. package/dist/backend/claude-code.js.map +1 -1
  9. package/dist/backend/types.d.ts +6 -0
  10. package/dist/backend/types.js.map +1 -1
  11. package/dist/backend-availability.d.ts +1 -1
  12. package/dist/backend-availability.js +28 -1
  13. package/dist/backend-availability.js.map +1 -1
  14. package/dist/browser-backend-signins.d.ts +7 -1
  15. package/dist/browser-backend-signins.js +8 -4
  16. package/dist/browser-backend-signins.js.map +1 -1
  17. package/dist/build-provenance.json +1 -1
  18. package/dist/channel/mcp-tools.js +1 -1
  19. package/dist/channel/mcp-tools.js.map +1 -1
  20. package/dist/config-validator.js +47 -7
  21. package/dist/config-validator.js.map +1 -1
  22. package/dist/daemon.d.ts +3 -0
  23. package/dist/daemon.js +4 -0
  24. package/dist/daemon.js.map +1 -1
  25. package/dist/fleet-manager.d.ts +33 -4
  26. package/dist/fleet-manager.js +143 -61
  27. package/dist/fleet-manager.js.map +1 -1
  28. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +19 -0
  29. package/dist/hub/audit/index.js +12 -5
  30. package/dist/hub/audit/index.js.map +1 -1
  31. package/dist/hub/catalog.d.ts +6 -0
  32. package/dist/hub/catalog.js +14 -4
  33. package/dist/hub/catalog.js.map +1 -1
  34. package/dist/hub/client.js +2 -0
  35. package/dist/hub/client.js.map +1 -1
  36. package/dist/hub/compose/member.d.ts +2 -0
  37. package/dist/hub/compose/member.js +11 -2
  38. package/dist/hub/compose/member.js.map +1 -1
  39. package/dist/hub/compose/server.js +2 -1
  40. package/dist/hub/compose/server.js.map +1 -1
  41. package/dist/hub/enrolment-code.d.ts +126 -0
  42. package/dist/hub/enrolment-code.js +266 -0
  43. package/dist/hub/enrolment-code.js.map +1 -0
  44. package/dist/hub/group-policy/admin-impact.js +4 -2
  45. package/dist/hub/group-policy/admin-impact.js.map +1 -1
  46. package/dist/hub/group-policy/admin-inventory.js +6 -6
  47. package/dist/hub/group-policy/admin-inventory.js.map +1 -1
  48. package/dist/hub/group-policy/authorization.d.ts +16 -2
  49. package/dist/hub/group-policy/authorization.js +69 -5
  50. package/dist/hub/group-policy/authorization.js.map +1 -1
  51. package/dist/hub/group-policy/impact-inventory.js +3 -3
  52. package/dist/hub/group-policy/impact-inventory.js.map +1 -1
  53. package/dist/hub/group-policy/resources.d.ts +40 -1
  54. package/dist/hub/group-policy/resources.js +51 -13
  55. package/dist/hub/group-policy/resources.js.map +1 -1
  56. package/dist/hub/group-policy/store.d.ts +6 -0
  57. package/dist/hub/group-policy/store.js +49 -4
  58. package/dist/hub/group-policy/store.js.map +1 -1
  59. package/dist/hub/http/compose.js +30 -6
  60. package/dist/hub/http/compose.js.map +1 -1
  61. package/dist/hub/init/text.js +2 -2
  62. package/dist/hub/init/text.js.map +1 -1
  63. package/dist/hub/init/web.d.ts +7 -0
  64. package/dist/hub/init/web.js +6 -1
  65. package/dist/hub/init/web.js.map +1 -1
  66. package/dist/hub/join/local.d.ts +27 -0
  67. package/dist/hub/join/local.js +70 -5
  68. package/dist/hub/join/local.js.map +1 -1
  69. package/dist/hub/join/receipt.d.ts +1 -0
  70. package/dist/hub/join/receipt.js +1 -1
  71. package/dist/hub/join/receipt.js.map +1 -1
  72. package/dist/hub/join/service.d.ts +92 -6
  73. package/dist/hub/join/service.js +199 -28
  74. package/dist/hub/join/service.js.map +1 -1
  75. package/dist/hub/join/store.d.ts +2 -1
  76. package/dist/hub/join/store.js +7 -7
  77. package/dist/hub/join/store.js.map +1 -1
  78. package/dist/hub/member/exposure-api.d.ts +2 -0
  79. package/dist/hub/member/exposure-api.js +3 -2
  80. package/dist/hub/member/exposure-api.js.map +1 -1
  81. package/dist/hub/member/exposures.d.ts +4 -0
  82. package/dist/hub/member/exposures.js +12 -2
  83. package/dist/hub/member/exposures.js.map +1 -1
  84. package/dist/hub/member/pairing-notices.js +8 -6
  85. package/dist/hub/member/pairing-notices.js.map +1 -1
  86. package/dist/hub/pairing-notices.d.ts +5 -2
  87. package/dist/hub/pairing-notices.js +38 -13
  88. package/dist/hub/pairing-notices.js.map +1 -1
  89. package/dist/hub/pairing.d.ts +7 -2
  90. package/dist/hub/protocol.d.ts +47 -0
  91. package/dist/hub/protocol.js +3 -1
  92. package/dist/hub/protocol.js.map +1 -1
  93. package/dist/hub/server.js +15 -1
  94. package/dist/hub/server.js.map +1 -1
  95. package/dist/hub/types.d.ts +12 -4
  96. package/dist/hub-pairing-summary.js +1 -1
  97. package/dist/hub-pairing-summary.js.map +1 -1
  98. package/dist/instance-config-impact.js +4 -0
  99. package/dist/instance-config-impact.js.map +1 -1
  100. package/dist/instance-lifecycle.js +4 -0
  101. package/dist/instance-lifecycle.js.map +1 -1
  102. package/dist/locale.js +6 -2
  103. package/dist/locale.js.map +1 -1
  104. package/dist/log-service.d.ts +62 -6
  105. package/dist/log-service.js +135 -28
  106. package/dist/log-service.js.map +1 -1
  107. package/dist/log-steps-agy-grok.d.ts +74 -0
  108. package/dist/log-steps-agy-grok.js +440 -0
  109. package/dist/log-steps-agy-grok.js.map +1 -0
  110. package/dist/log-steps.d.ts +62 -3
  111. package/dist/log-steps.js +188 -22
  112. package/dist/log-steps.js.map +1 -1
  113. package/dist/log-transcript-paths.d.ts +29 -0
  114. package/dist/log-transcript-paths.js +109 -0
  115. package/dist/log-transcript-paths.js.map +1 -0
  116. package/dist/login-controller.d.ts +17 -3
  117. package/dist/login-controller.js +57 -5
  118. package/dist/login-controller.js.map +1 -1
  119. package/dist/login-window-lock.d.ts +20 -8
  120. package/dist/login-window-lock.js +35 -16
  121. package/dist/login-window-lock.js.map +1 -1
  122. package/dist/outbound-handlers.d.ts +14 -0
  123. package/dist/outbound-handlers.js +49 -1
  124. package/dist/outbound-handlers.js.map +1 -1
  125. package/dist/profile-signins.d.ts +2 -0
  126. package/dist/profile-signins.js +1 -1
  127. package/dist/profile-signins.js.map +1 -1
  128. package/dist/settings-api.d.ts +34 -0
  129. package/dist/settings-api.js +184 -6
  130. package/dist/settings-api.js.map +1 -1
  131. package/dist/settings-change.js +38 -1
  132. package/dist/settings-change.js.map +1 -1
  133. package/dist/settings-effect.js +14 -0
  134. package/dist/settings-effect.js.map +1 -1
  135. package/dist/tool-progress.d.ts +7 -0
  136. package/dist/tool-progress.js +21 -9
  137. package/dist/tool-progress.js.map +1 -1
  138. package/dist/types.d.ts +13 -0
  139. package/dist/ui/accounts-view.js +14 -4
  140. package/dist/ui/agent-details-settings.js +2 -2
  141. package/dist/ui/agent-page-strings.js +2 -2
  142. package/dist/ui/backend-signin.js +47 -14
  143. package/dist/ui/chat-activity-groups.js +225 -0
  144. package/dist/ui/chat-activity.js +355 -0
  145. package/dist/ui/chat-popout-header.js +35 -0
  146. package/dist/ui/chat-popout-transport.js +80 -0
  147. package/dist/ui/chat-popout.js +63 -0
  148. package/dist/ui/chat-quote.js +3 -1
  149. package/dist/ui/chat-store.js +45 -4
  150. package/dist/ui/chat-workspace-gestures.js +177 -0
  151. package/dist/ui/chat-workspace-navigation.js +34 -10
  152. package/dist/ui/chat-workspace.js +96 -32
  153. package/dist/ui/host-install.js +2 -2
  154. package/dist/ui/hub-agent-copy.js +7 -7
  155. package/dist/ui/hub-chat-strings.js +3 -3
  156. package/dist/ui/hub-client.js +77 -17
  157. package/dist/ui/hub-company-join-strings.js +12 -10
  158. package/dist/ui/hub-company-join.js +52 -39
  159. package/dist/ui/hub-confirm-place.js +44 -0
  160. package/dist/ui/hub-directory-editor-strings.js +3 -3
  161. package/dist/ui/hub-directory-notice-strings.js +1 -1
  162. package/dist/ui/hub-enrolment-code-strings.js +44 -0
  163. package/dist/ui/hub-enrolment-code.js +159 -0
  164. package/dist/ui/hub-group-search.js +82 -0
  165. package/dist/ui/hub-group-strings.js +8 -8
  166. package/dist/ui/hub-join-approval.js +31 -0
  167. package/dist/ui/hub-join-code-input.js +66 -0
  168. package/dist/ui/hub-join-queue.js +62 -0
  169. package/dist/ui/hub-join-steps.js +231 -0
  170. package/dist/ui/hub-joincode-flow-strings.js +22 -0
  171. package/dist/ui/hub-owner-strings.js +9 -9
  172. package/dist/ui/hub-pairing-progress-strings.js +1 -1
  173. package/dist/ui/hub-quick-pairing.js +8 -4
  174. package/dist/ui/hub-quick-strings.js +11 -11
  175. package/dist/ui/hub-share-refused.js +17 -0
  176. package/dist/ui/hub-strings.js +61 -61
  177. package/dist/ui/hub-this-hub.js +2 -2
  178. package/dist/ui/hub-welcome.js +26 -5
  179. package/dist/ui/image-annotate.js +283 -0
  180. package/dist/ui/image-lightbox.js +26 -6
  181. package/dist/ui/log-row.js +327 -0
  182. package/dist/ui/panel-chat.js +151 -12
  183. package/dist/ui/panel-details.js +14 -6
  184. package/dist/ui/panel-hub.js +42 -13
  185. package/dist/ui/panel-log.js +9 -154
  186. package/dist/ui/panel-settings.js +48 -11
  187. package/dist/ui/search-dialog.js +1 -0
  188. package/dist/ui/settings-access-overview.js +1 -1
  189. package/dist/ui/settings-hub-browser-certificate.js +3 -3
  190. package/dist/ui/settings-hub-company-join.js +41 -30
  191. package/dist/ui/settings-hub-connection.js +8 -5
  192. package/dist/ui/settings-hub-membership.js +3 -3
  193. package/dist/ui/settings-hub-section.js +1 -1
  194. package/dist/ui/settings-hub-setup-strings.js +6 -6
  195. package/dist/ui/settings-hub-setup.js +44 -6
  196. package/dist/ui/settings-hub.js +35 -10
  197. package/dist/ui/settings-layout.js +6 -4
  198. package/dist/ui/settings-public-session-strings.js +37 -0
  199. package/dist/ui/settings-registry.js +4 -0
  200. package/dist/ui/settings-strings.js +2 -2
  201. package/dist/ui/shared/app-shell.js +16 -10
  202. package/dist/ui/shared/app.css +195 -30
  203. package/dist/ui/shared/app.js +8 -1
  204. package/dist/ui/shared/chat-render.js +11 -2
  205. package/dist/ui/shared/chat-thread.js +20 -3
  206. package/dist/ui/shared/chat-work-bar.css +7 -0
  207. package/dist/ui/shared/chat-workspace-model.js +39 -9
  208. package/dist/ui/shared/hub-owner.css +8 -0
  209. package/dist/ui/shared/identity-color.js +9 -3
  210. package/dist/ui/shared/image-annotate.css +45 -0
  211. package/dist/ui/shared/instance-nav.js +59 -22
  212. package/dist/ui/shared/pane-geometry.js +29 -0
  213. package/dist/ui/shared/signin.js +2 -2
  214. package/dist/ui/shared/tokens.css +14 -0
  215. package/dist/ui/shared/ui-menu.js +22 -7
  216. package/dist/ui/signin.html +1 -1
  217. package/dist/ui/structured-signin.js +11 -4
  218. package/dist/web-api.d.ts +1 -0
  219. package/dist/web-api.js +34 -4
  220. package/dist/web-api.js.map +1 -1
  221. package/dist/web-backend-login.d.ts +9 -3
  222. package/dist/web-backend-login.js +7 -4
  223. package/dist/web-backend-login.js.map +1 -1
  224. package/dist/web-chat-history.d.ts +11 -0
  225. package/dist/web-chat-history.js +9 -1
  226. package/dist/web-chat-history.js.map +1 -1
  227. package/dist/web-guest-access.js +2 -2
  228. package/dist/web-guest-access.js.map +1 -1
  229. package/dist/web-session.d.ts +31 -3
  230. package/dist/web-session.js +25 -4
  231. package/dist/web-session.js.map +1 -1
  232. package/dist/web-settings-patch.d.ts +8 -2
  233. package/dist/web-settings-patch.js +22 -10
  234. package/dist/web-settings-patch.js.map +1 -1
  235. package/package.json +1 -1
@@ -9,7 +9,7 @@ import { DEFAULT_REPLY_TRIGGERS } from "./reply-triggers.js";
9
9
  import { PUBLIC_TUNNEL_SECRET_ID, PUBLIC_TUNNEL_TOKEN_HINT } from "./public-tunnel-config.js";
10
10
  import { withSpawnHoldReply } from "./spawn-hold-reply.js";
11
11
  import { normalizeSettingsInstancePatch, removesInstanceOverride } from "./settings-instance-patch.js";
12
- import { instanceCredentialProfile, signedOutCredentialProfile } from "./backend/credential-profile.js";
12
+ import { credentialHomeSpec, credentialProfileHome, instanceCredentialProfile, signedOutCredentialProfile } from "./backend/credential-profile.js";
13
13
  import { isSettingsReplay, settingsRequestExecution, settingsRequestLocalAdmin, settingsRequestLocalAdminCurrent, settingsRequestJoinAuthority, settingsWrite } from "./settings-request-capability.js";
14
14
  import { noteSettingsWrite, settingsUndo, undoSettingsPaths } from "./settings-transaction.js";
15
15
  import { readBoundedWebBody } from "./web-body.js";
@@ -222,6 +222,143 @@ function spliceChangedLines(original, base, edited) {
222
222
  }
223
223
  return out.join("\n");
224
224
  }
225
+ /**
226
+ * #3715 (Prism on #3719): after a failed restart, put the room's account back and bring the room up on it — and say
227
+ * what actually happened. The file goes back through the same leaf writer only where nothing changed it since (a newer
228
+ * edit wins, and nothing is restarted for it); the room is restarted only by this operation's own receipt, never over
229
+ * a runtime someone else has stopped or started meanwhile.
230
+ */
231
+ async function rollBackClassicProfile(ctx, key, instanceName, paths, undo, op, cause) {
232
+ const failed = `The room's restart failed (${cause})`;
233
+ try {
234
+ const retained = undoSettingsPaths(classicPath(ctx), readClassic(ctx), undo);
235
+ if (retained.conflicts) {
236
+ ctx.logger.warn({ key, instanceName }, "update_instance_config: classicBot.yaml changed meanwhile; the newer account is kept");
237
+ return `${failed}. Its account was not put back: classicBot.yaml was changed again meanwhile, and that newer change is kept. Check the room.`;
238
+ }
239
+ writeClassicLeaves(ctx, retained.value, paths);
240
+ }
241
+ catch (rollbackErr) {
242
+ ctx.logger.error({ err: rollbackErr, key }, "update_instance_config: failed to roll back classicBot.yaml");
243
+ return `${failed}, and classicBot.yaml could not be put back (${rollbackErr.message}). The room's backend_options may still name the new account. Check the room.`;
244
+ }
245
+ let recovery;
246
+ try {
247
+ recovery = await op.restore();
248
+ }
249
+ catch (recoveryErr) {
250
+ ctx.logger.error({ err: recoveryErr, instanceName }, "update_instance_config: failed to restore the classic room after rollback");
251
+ return `${failed}. Its account was put back in classicBot.yaml, but starting the room on it failed too (${recoveryErr.message}). Check the room.`;
252
+ }
253
+ return recovery === "restarted" ? `${failed}, so its account was put back and the room was started on it again.`
254
+ : recovery === "not-running" ? `${failed}. Its account was put back in classicBot.yaml; the room was not running.`
255
+ : `${failed}. Its account was put back in classicBot.yaml. The room was not restarted: it was stopped or started by something else meanwhile.`;
256
+ }
257
+ /**
258
+ * #3715 (M-2961): `update_instance_config` on a ClassicBot room may change its AI account and nothing else —
259
+ * `backend_options.<cli>.credential_profile` (a name, or null / "" for the fleet default). The same write as the room's
260
+ * Settings save (#3691, M-2909): only that room's backend_options lines change, comments and other rooms stay as they
261
+ * are; then the room restarts through restartClassicInstanceFromSettings (the #1753 handoff: Claude's conversation is
262
+ * carried, Kiro starts fresh), and the file is put back if that restart fails. Refused, with nothing written: a room this
263
+ * fleet doesn't have, any other key, a backend without accounts, a profile that doesn't exist on this host or isn't
264
+ * signed in (the web's 409, with the login command).
265
+ */
266
+ export async function switchClassicRoomProfile(ctx, instanceName, patch) {
267
+ const record = (v) => !!v && typeof v === "object" && !Array.isArray(v);
268
+ if (!record(patch) || !Object.keys(patch).length)
269
+ return { ok: false, error: "backend_options must map a backend to { credential_profile }" };
270
+ for (const [backend, options] of Object.entries(patch)) {
271
+ if (!KNOWN_BACKENDS.includes(backend) || !credentialHomeSpec(backend))
272
+ return { ok: false, error: `${backend} has no named accounts` };
273
+ if (!record(options) || Object.keys(options).length !== 1 || !Object.hasOwn(options, "credential_profile")) {
274
+ return { ok: false, error: `On a ClassicBot room only backend_options.${backend}.credential_profile can be changed` };
275
+ }
276
+ const value = options.credential_profile;
277
+ if (value === null || value === "")
278
+ continue;
279
+ const { problems } = normalizeBackendOptions({ [backend]: { credential_profile: value } });
280
+ if (typeof value !== "string" || problems.length)
281
+ return { ok: false, error: `backend_options.${backend}.credential_profile: ${problems[0]?.message ?? "must be a profile name"}` };
282
+ if (!existsSync(credentialProfileHome(ctx.dataDir, backend, value)))
283
+ return { ok: false, error: `No ${backend} account named "${value}" on this host` };
284
+ const login = signedOutCredentialProfile(ctx.dataDir, backend, value);
285
+ if (login)
286
+ return { ok: false, error: `The ${backend} account "${value}" is not signed in. Sign it in first`, loginCommand: login.loginCommand };
287
+ }
288
+ let classic;
289
+ try {
290
+ classic = readClassic(ctx);
291
+ }
292
+ catch (err) {
293
+ return { ok: false, error: err.message };
294
+ }
295
+ const channels = record(classic.channels) ? classic.channels : {};
296
+ const key = Object.keys(channels).find(k => record(channels[k]) && channels[k].instanceName === instanceName);
297
+ if (key === undefined)
298
+ return { ok: false, error: `No ClassicBot room runs as '${instanceName}' in classicBot.yaml` };
299
+ const room = channels[key];
300
+ const previous = structuredClone(classic);
301
+ // Per backend, as for an agent: setting one CLI's account keeps the others; null / "" goes back to the default.
302
+ const options = structuredClone(record(room.backend_options) ? room.backend_options : {});
303
+ for (const [backend, o] of Object.entries(patch)) {
304
+ const namespace = { ...(record(options[backend]) ? options[backend] : {}) };
305
+ if (o.credential_profile === null || o.credential_profile === "")
306
+ delete namespace.credential_profile;
307
+ else
308
+ namespace.credential_profile = o.credential_profile;
309
+ if (Object.keys(namespace).length)
310
+ options[backend] = namespace;
311
+ else
312
+ delete options[backend];
313
+ }
314
+ const merged = { ...room };
315
+ if (Object.keys(options).length)
316
+ merged.backend_options = options;
317
+ else
318
+ delete merged.backend_options;
319
+ const cd = record(classic.defaults) ? classic.defaults : {};
320
+ const backend = String(room.backend ?? cd.backend ?? ctx.fleetConfig?.defaults?.backend ?? "claude-code");
321
+ const fleetOptions = ctx.fleetConfig?.defaults?.backend_options;
322
+ const after = classicProfile(normalizeBackendOptions(merged.backend_options).options, fleetOptions, backend);
323
+ // The room lands on the fleet default's account when its own is cleared: that one must be signed in too (web: 409).
324
+ if (after.state === "profile") {
325
+ const login = signedOutCredentialProfile(ctx.dataDir, backend, after.name);
326
+ if (login)
327
+ return { ok: false, error: `The ${backend} account "${after.name}" is not signed in. Sign it in first`, loginCommand: login.loginCommand };
328
+ }
329
+ const profile = after.state === "profile" ? after.name : null;
330
+ if (isDeepStrictEqual(merged.backend_options, room.backend_options))
331
+ return { ok: true, channel: key, backend, profile, changed: false };
332
+ channels[key] = merged;
333
+ const invalidBefore = new Set(validateClassicBotConfig(previous).errors.map(issueKey));
334
+ const introduced = validateClassicBotConfig(classic).errors.filter(e => !invalidBefore.has(issueKey(e)));
335
+ if (introduced.length)
336
+ return { ok: false, error: `Rejected: ${introduced.map(e => `${e.path}: ${e.message}`).join("; ")}` };
337
+ if (!ctx.beginClassicProfileSwitch)
338
+ return { ok: false, error: "This fleet cannot restart a ClassicBot room here" };
339
+ const paths = [["channels", key, "backend_options"]];
340
+ // Owned before the write: the runtime this operation may stop, restart and — if that fails — bring back.
341
+ const op = ctx.beginClassicProfileSwitch(instanceName, ["backend_options"]);
342
+ try {
343
+ writeClassicLeaves(ctx, classic, paths);
344
+ }
345
+ catch (err) {
346
+ op.close();
347
+ ctx.logger.warn({ err, key }, "update_instance_config: failed to write classicBot.yaml");
348
+ return { ok: false, error: "failed to write classicBot.yaml" };
349
+ }
350
+ const undo = settingsUndo(classicPath(ctx), previous, classic, paths);
351
+ try {
352
+ await op.restart();
353
+ }
354
+ catch (err) {
355
+ op.close();
356
+ return { ok: false, error: await rollBackClassicProfile(ctx, key, instanceName, paths, undo, op, err.message) };
357
+ }
358
+ op.close();
359
+ ctx.logger.info({ key, instanceName, backend, profile }, "update_instance_config: switched a ClassicBot room's account");
360
+ return { ok: true, channel: key, backend, profile, changed: true };
361
+ }
225
362
  const issueKey = (i) => i.path + "\u0000" + i.message;
226
363
  /**
227
364
  * #1490 (Fable's 2.2 audit): the connection fields Settings writes. A PUT carries whole connections back, so a field
@@ -1313,7 +1450,10 @@ export function handleSettingsRequest(req, res, url, ctx) {
1313
1450
  json(res, 403, { error: "admin_required" });
1314
1451
  return true;
1315
1452
  }
1316
- json(res, 200, { ok: true, pairing: api.view(), notices: (api.notices?.() ?? []).filter(n => url.searchParams.get("v") === "2" || n.source === "group") });
1453
+ // Keep v=2 on the wire for an older host; only a current code-aware renderer asks for the additive v3 notice DTO.
1454
+ const version = url.searchParams.get("v") === "3" || url.searchParams.get("v") === "2" && url.searchParams.get("notices") === "3" ? 3 : url.searchParams.get("v") === "2" ? 2 : 1;
1455
+ const notices = (api.notices?.() ?? []).filter(n => n.source === "group" || n.source === "manual" && version >= 2 || n.source === "code" && version >= 3);
1456
+ json(res, 200, { ok: true, pairing: api.view(), notices });
1317
1457
  return true;
1318
1458
  }
1319
1459
  if (step === "cancel" && method === "POST") {
@@ -1742,6 +1882,10 @@ export function handleSettingsRequest(req, res, url, ctx) {
1742
1882
  web.log_tab = parsed.logTab;
1743
1883
  changes.push({ path: ["web", "log_tab"], value: parsed.logTab });
1744
1884
  }
1885
+ if (parsed.logThinking !== undefined) {
1886
+ web.log_thinking = parsed.logThinking;
1887
+ changes.push({ path: ["web", "log_thinking"], value: parsed.logThinking });
1888
+ }
1745
1889
  if (parsed.usageOnPublicLink !== undefined) {
1746
1890
  web.usage_report_on_public_link = parsed.usageOnPublicLink;
1747
1891
  changes.push({ path: ["web", "usage_report_on_public_link"], value: parsed.usageOnPublicLink });
@@ -1778,6 +1922,21 @@ export function handleSettingsRequest(req, res, url, ctx) {
1778
1922
  }
1779
1923
  web.session = { ...web.session, local };
1780
1924
  }
1925
+ if (parsed.publicLinkSession) {
1926
+ const pl = { ...web.session?.public_link };
1927
+ for (const [key, value] of Object.entries(parsed.publicLinkSession)) {
1928
+ if (value === null) {
1929
+ delete pl[key];
1930
+ changes.push({ path: ["web", "session", "public_link", key], value: undefined, remove: true });
1931
+ }
1932
+ else {
1933
+ pl[key] = value;
1934
+ changes.push({ path: ["web", "session", "public_link", key], value });
1935
+ }
1936
+ }
1937
+ const { public_link: _old, ...rest } = web.session ?? {};
1938
+ web.session = Object.keys(pl).length ? { ...rest, public_link: pl } : rest;
1939
+ }
1781
1940
  if (terminalPatch) {
1782
1941
  const wt = { ...cfg.web_terminal };
1783
1942
  for (const [key, value] of Object.entries(terminalPatch)) {
@@ -2326,10 +2485,15 @@ export function handleSettingsRequest(req, res, url, ctx) {
2326
2485
  const undo = settingsUndo(classicPath(ctx), previous, classic, Object.keys(body).map(field => ["channels", key, field]));
2327
2486
  const execution = settingsRequestExecution(req);
2328
2487
  const instanceName = typeof merged.instanceName === "string" ? merged.instanceName : undefined;
2329
- const restore = instanceName ? ctx.captureClassicSettingsRestoration?.(instanceName, Object.keys(body), execution) : undefined;
2488
+ // M-2966: the restart and its compensation are one owned operation (as #3719's tool switch): a plain Save's restart is
2489
+ // owned too, so after a failed start the compensation still owns the room and brings it back on what it had.
2490
+ const op = instanceName ? ctx.beginClassicSettingsRestart?.(instanceName, Object.keys(body), execution) : undefined;
2491
+ const restore = !op && instanceName ? ctx.captureClassicSettingsRestoration?.(instanceName, Object.keys(body), execution) : undefined;
2330
2492
  try {
2331
2493
  if (instanceName && ctx.restartClassicInstanceFromSettings) {
2332
- if (execution)
2494
+ if (op)
2495
+ await op.restart();
2496
+ else if (execution)
2333
2497
  await ctx.restartClassicInstanceFromSettings(instanceName, Object.keys(body), execution);
2334
2498
  else
2335
2499
  await ctx.restartClassicInstanceFromSettings(instanceName, Object.keys(body));
@@ -2338,18 +2502,30 @@ export function handleSettingsRequest(req, res, url, ctx) {
2338
2502
  }
2339
2503
  catch (err) {
2340
2504
  // Keep disk and runtime consistent if the requested restart fails.
2505
+ let rolledBack = false;
2341
2506
  try {
2342
2507
  const retained = undoSettingsPaths(classicPath(ctx), readClassic(ctx), undo);
2343
2508
  writeClassicAtomic(ctx, retained.value);
2344
2509
  if (retained.conflicts)
2345
2510
  throw new Error("concurrent Classic edit retained");
2511
+ rolledBack = true;
2346
2512
  }
2347
2513
  catch (rollbackErr) {
2348
2514
  ctx.logger.error({ err: rollbackErr, key }, "settings: failed to roll back classic channel update");
2349
2515
  }
2350
- if (instanceName && ctx.restartClassicInstanceFromSettings) {
2516
+ // M-2966 (Prism on #3721): the owned compensation may start a stopped room, so it runs only on a conflict-free
2517
+ // rollback — never onto a newer edit that undo kept, nor onto a file it couldn't put back (as #3719's tool path).
2518
+ if (op && !rolledBack)
2519
+ ctx.logger.warn({ key, instanceName }, "settings: classic rollback incomplete; the room is not restarted");
2520
+ else if (instanceName && ctx.restartClassicInstanceFromSettings) {
2351
2521
  try {
2352
- if (restore)
2522
+ if (op) {
2523
+ // Never over a runtime someone else stopped or started meanwhile ("superseded"): that one stays as it is.
2524
+ const outcome = await op.restore();
2525
+ if (outcome === "superseded")
2526
+ ctx.logger.warn({ key, instanceName }, "settings: classic room changed meanwhile; not restarted after rollback");
2527
+ }
2528
+ else if (restore)
2353
2529
  await restore();
2354
2530
  else
2355
2531
  await ctx.restartClassicInstanceFromSettings(instanceName, Object.keys(body));
@@ -2358,9 +2534,11 @@ export function handleSettingsRequest(req, res, url, ctx) {
2358
2534
  ctx.logger.error({ err: recoveryErr, key, instanceName }, "settings: failed to restore classic instance after rollback");
2359
2535
  }
2360
2536
  }
2537
+ op?.close();
2361
2538
  ctx.logger.warn({ err, key, instanceName }, "settings: classic channel restart failed; config rolled back");
2362
2539
  return json(res, 409, { error: `classic instance restart failed: ${err.message}` });
2363
2540
  }
2541
+ op?.close();
2364
2542
  execution?.complete();
2365
2543
  ctx.logger.info({ key, instanceName }, "settings: updated classic channel");
2366
2544
  const hotOnly = Object.keys(body).length > 0