@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
@@ -73,6 +73,8 @@ export function createChatStore(deps) {
73
73
  };
74
74
  }
75
75
  const pastedTexts = new WeakMap();
76
+ const draftVersions = new Map(), draftTickets = new WeakSet();
77
+ const editDraft = name => draftVersions.set(name, (draftVersions.get(name) || 0) + 1);
76
78
  const now = deps.now || (() => (typeof performance !== "undefined" ? performance.now() : Date.now()));
77
79
  const t = deps.t, tf = deps.t;
78
80
  const liveReplies = createLiveAgentReplies(now);
@@ -359,6 +361,7 @@ export function createChatStore(deps) {
359
361
  files: files.map((f) => ({ file: f, name: f.name || "file", size: f.size || 0, type: f.type || "", url: objectUrl(f), loaded: 0, total: f.size || 0, state: "waiting", id: null })),
360
362
  };
361
363
  (s.outgoing[target] = s.outgoing[target] || []).push(e);
364
+ editDraft(target);
362
365
  s.drafts[target] = "";
363
366
  s.pendingFiles[target] = [];
364
367
  if (quote) delete s.replies[target];
@@ -456,6 +459,7 @@ export function createChatStore(deps) {
456
459
  const e = list.find((x) => x.clientId === clientId);
457
460
  if (!e || e.outgoing.state !== "failed") return;
458
461
  const draft = s.drafts[target] || "";
462
+ editDraft(target);
459
463
  s.drafts[target] = e.text ? (draft ? e.text + "\n" + draft : e.text) : draft;
460
464
  for (const f of e.files) freeUrl(f.url);
461
465
  s.outgoing[target] = list.filter((x) => x !== e);
@@ -466,11 +470,12 @@ export function createChatStore(deps) {
466
470
  function addFiles(target, list) {
467
471
  if (!target) return;
468
472
  const res = R().checkFiles(s.pendingFiles[target] || [], [...(list || [])]);
473
+ editDraft(target);
469
474
  s.pendingFiles[target] = res.kept;
470
475
  for (const x of res.rejected) { const why = R().fileRejection(x.reason); deps.toast(`${x.name}: ${t(why.key, ...why.values)}`, false); }
471
476
  changed(target);
472
477
  }
473
- function removeFile(target, index) { (s.pendingFiles[target] || []).splice(index, 1); changed(target); }
478
+ function removeFile(target, index) { editDraft(target); (s.pendingFiles[target] || []).splice(index, 1); changed(target); }
474
479
  /** A long paste as a .txt file when it fits beside what is attached; true when it was attached. */
475
480
  function attachPastedText(target, text) {
476
481
  if (!target) return false;
@@ -487,6 +492,7 @@ export function createChatStore(deps) {
487
492
  function fileBackAsText(target, index) {
488
493
  const f = (s.pendingFiles[target] || [])[index];
489
494
  if (!f || !pastedTexts.has(f)) return;
495
+ editDraft(target);
490
496
  s.pendingFiles[target].splice(index, 1);
491
497
  const draft = s.drafts[target] || "";
492
498
  s.drafts[target] = draft ? `${draft}\n${pastedTexts.get(f)}` : pastedTexts.get(f);
@@ -494,11 +500,45 @@ export function createChatStore(deps) {
494
500
  }
495
501
  const isPasted = (f) => pastedTexts.has(f);
496
502
  /** Typing stays local. */
497
- function setDraft(target, value) { s.drafts[target] = value; }
503
+ function setDraft(target, value) { editDraft(target); s.drafts[target] = value; }
504
+ /** #3637: one page-local, compare-and-clear ticket. No outgoing requests or persistent storage. */
505
+ function captureDraft(name) {
506
+ const ticket = { name, version: draftVersions.get(name) || 0, reply: s.replies[name],
507
+ payload: { text: s.drafts[name] || "", files: [...(s.pendingFiles[name] || [])], reply: s.replies[name] ? { ...s.replies[name] } : null } };
508
+ draftTickets.add(ticket); return ticket;
509
+ }
510
+ function draftCurrent(ticket) {
511
+ return draftTickets.has(ticket) && ticket.version === (draftVersions.get(ticket.name) || 0)
512
+ && ticket.payload.text === (s.drafts[ticket.name] || "") && ticket.reply === s.replies[ticket.name]
513
+ && ticket.payload.files.length === (s.pendingFiles[ticket.name] || []).length
514
+ && ticket.payload.files.every((file, i) => file === s.pendingFiles[ticket.name][i]);
515
+ }
516
+ function clearCapturedDraft(ticket) {
517
+ if (!draftCurrent(ticket)) return false;
518
+ draftTickets.delete(ticket); editDraft(ticket.name);
519
+ s.drafts[ticket.name] = ""; s.pendingFiles[ticket.name] = []; delete s.replies[ticket.name]; changed(ticket.name); return true;
520
+ }
521
+ function acceptDraft(name, data) {
522
+ if (!data || Object.keys(data).sort().join(",") !== "files,reply,text" || typeof data.text !== "string" || data.text.length > 1_000_000
523
+ || !Array.isArray(data.files) || data.files.length > R().fileLimits().maxFiles
524
+ || data.files.some(file => typeof File !== "function" || !(file instanceof File))
525
+ || (s.drafts[name] || "") || (s.pendingFiles[name] || []).length || s.replies[name]) return false;
526
+ const reply = data.reply;
527
+ if (reply !== null && (!reply || Object.keys(reply).some(key => !["boot", "id", "sender", "text", "media"].includes(key))
528
+ || typeof reply.boot !== "string" || reply.boot.length > 128 || !Number.isSafeInteger(reply.id) || reply.id < 0
529
+ || typeof reply.sender !== "string" || reply.sender.length > 1000 || typeof reply.text !== "string" || reply.text.length > 160
530
+ || (reply.media !== undefined && !["photo", "document"].includes(reply.media)))) return false;
531
+ const files = R().checkFiles([], data.files);
532
+ if (files.rejected.length || files.kept.length !== data.files.length) return false;
533
+ editDraft(name); s.drafts[name] = data.text; s.pendingFiles[name] = files.kept;
534
+ if (reply) s.replies[name] = { ...reply };
535
+ changed(name); return true;
536
+ }
498
537
  /** #2911: a line added to the composer for the person to edit (after what is typed, on its own line; never twice). */
499
538
  function addToDraft(target, line) {
500
539
  const d = s.drafts[target] || "";
501
540
  if (!target || !line || d.split("\n").includes(line)) return;
541
+ editDraft(target);
502
542
  s.drafts[target] = d ? `${d.replace(/\n+$/, "")}\n${line}` : line;
503
543
  changed(target);
504
544
  }
@@ -508,11 +548,12 @@ export function createChatStore(deps) {
508
548
  */
509
549
  function startReply(target, m) {
510
550
  if (!target || !m || typeof m.boot !== "string" || typeof m.id !== "number") return;
551
+ editDraft(target);
511
552
  s.replies[target] = { boot: m.boot, id: m.id, sender: String(m.sender || ""), text: String(m.click?.label ?? m.text ?? "").replace(/\s+/g, " ").trim().slice(0, 160),
512
553
  media: (m.attachments || []).length ? ((m.attachments || []).some(a => a.kind === "photo") ? "photo" : "document") : undefined };
513
554
  changed(target);
514
555
  }
515
- function clearReply(target) { if (s.replies[target]) { delete s.replies[target]; changed(target); } }
556
+ function clearReply(target) { if (s.replies[target]) { editDraft(target); delete s.replies[target]; changed(target); } }
516
557
  /**
517
558
  * #2272: the quoted message, drawn for a jump: in what this chat holds, or after reading the longest history the
518
559
  * server keeps for it (the newest 500). false: no longer kept.
@@ -636,7 +677,7 @@ export function createChatStore(deps) {
636
677
  onPrompt, applyPrompts, resolvePrompt, answerPrompt, answerByNonce, holdPrompt, releasePrompt, promptsFor,
637
678
  applyReplyButtons, clickReplyButton,
638
679
  uploadFile, send, retryOutgoing, deleteOutgoing, putBackOutgoing, threadRows, addFiles, removeFile, attachPastedText, fileBackAsText, isPasted, setDraft,
639
- startReply, clearReply, findQuoted, addToDraft,
680
+ startReply, clearReply, findQuoted, addToDraft, captureDraft, draftCurrent, clearCapturedDraft, acceptDraft,
640
681
  cancelReply, isUser, runCommand, dismissCommand, commandFree,
641
682
  allHidden: (name) => s.allHidden.has(name),
642
683
  };
@@ -0,0 +1,177 @@
1
+ import { createStore } from "/assets/app-store.js";
2
+ import { register, t } from "/assets/app-i18n.js";
3
+ import { isSafeInstanceName } from "/assets/app-route.js";
4
+ import { dropBox, dropZone, floatBox, splitSize } from "/assets/pane-geometry.js";
5
+
6
+ register("paneGeometry", {
7
+ en: { float: "Free floating pane", move: "Move floating pane", resize: "Resize floating pane", sash: "Resize chat panes", reset: "Reset to equal halves",
8
+ left: "Dock left", right: "Dock right", top: "Dock above", bottom: "Dock below", center: "Replace this pane", help: "Arrow keys move or resize; Shift makes larger steps. Enter applies, Esc cancels.", changed: "Pane arrangement updated.", resized: "Pane size updated." },
9
+ "zh-TW": { float: "自訂移動", move: "移動浮窗", resize: "調整浮窗大小", sash: "調整對話窗格大小", reset: "重設為各半",
10
+ left: "停靠左側", right: "停靠右側", top: "停靠上方", bottom: "停靠下方", center: "取代此格", help: "用方向鍵移動或調整大小,Shift 加大幅度;Enter 套用,Esc 取消。", changed: "已更新窗格排列。", resized: "已更新窗格大小。" },
11
+ });
12
+ export const geometryText = key => t(`paneGeometry.${key}`);
13
+ const modified = e => e.ctrlKey || e.metaKey || e.altKey || e.isComposing || e.getModifierState?.("AltGraph");
14
+ const sameBounds = (a, b) => ["left", "top", "width", "height"].every(key => a[key] === b[key]);
15
+
16
+ /** Page-local gestures only. One owned native drag or pointer/keyboard operation; never a transport or write runner. */
17
+ export function createWorkspaceGestures({ controller, getRoot, onDrop = (name, target, zone) => controller.dock(name, target, zone) }) {
18
+ const doc = document, win = window;
19
+ const store = createStore({ transient: null, keyboard: null, announcement: "" });
20
+ let alive = true, active = null, overlay = null;
21
+ const usable = () => {
22
+ const root = getRoot(), rect = root?.getBoundingClientRect();
23
+ return alive && root?.isConnected && rect?.width >= 760 && win.innerWidth >= 1200 && !root.classList.contains("ws-compact")
24
+ && !doc.querySelector('dialog[open], [role="dialog"][aria-modal="true"]');
25
+ };
26
+ const valid = a => alive && active === a && controller.stamp() === a.stamp && getRoot() === a.root && usable() && sameBounds(a.bounds, a.root.getBoundingClientRect());
27
+ const hideOverlay = () => { overlay?.remove(); overlay = null; };
28
+ const locate = (x, y) => {
29
+ const w = controller.current(), root = getRoot();
30
+ const ids = w?.layout === "float" ? [w.floating, w.floating === "a" ? "b" : "a"] : ["a", "b"];
31
+ if (!w) return { id: "a", rect: root.getBoundingClientRect() };
32
+ for (const id of ids) {
33
+ const rect = root.querySelector(`[data-pane="${id}"]`)?.getBoundingClientRect();
34
+ if (rect && dropZone(rect, x, y)) return { id, rect };
35
+ }
36
+ return null;
37
+ };
38
+ const preview = (a, x, y, floating = false) => {
39
+ a.target = null;
40
+ const hit = floating ? { id: a.id === "a" ? "b" : "a", rect: a.bounds } : locate(x, y);
41
+ if (!hit) { hideOverlay(); return; }
42
+ const zone = dropZone(hit.rect, x, y);
43
+ if (!zone || (floating && zone === "center")) { hideOverlay(); return; }
44
+ a.target = { id: hit.id, zone };
45
+ // Keep the browser's native drop target alive between dragover and drop.
46
+ if (!overlay) {
47
+ overlay = doc.createElement("div"); overlay.className = "ws-drop-overlay"; overlay.setAttribute("aria-hidden", "true");
48
+ const box = doc.createElement("div"); box.className = "ws-drop-target"; box.appendChild(doc.createElement("span")); overlay.appendChild(box); doc.body.appendChild(overlay);
49
+ }
50
+ const box = overlay.firstElementChild, label = box.firstElementChild, rect = dropBox(hit.rect, zone);
51
+ box.setAttribute("data-zone", zone); box.setAttribute("data-target", hit.id); label.textContent = geometryText(zone);
52
+ // CSSOM follows the preview/sidebar resizers; no CSP-blocked style attribute or user-controlled CSS text.
53
+ for (const [key, value] of Object.entries(a.bounds)) if (["left", "top", "width", "height"].includes(key)) overlay.style.setProperty(key, `${value}px`);
54
+ for (const [key, value] of Object.entries(rect)) box.style.setProperty(key, `${value - (key === "left" ? a.bounds.left : key === "top" ? a.bounds.top : 0)}px`);
55
+ };
56
+ const finish = (commit = false) => {
57
+ const a = active; if (!a) return;
58
+ const accepted = commit && valid(a);
59
+ active = null; a.off?.(); hideOverlay(); a.root.classList.remove("ws-resizing");
60
+ store.set({ transient: null, keyboard: null });
61
+ if (!accepted) return;
62
+ if (a.target) { onDrop(a.name, a.target.id, a.target.zone); store.set({ announcement: geometryText("changed") }); }
63
+ else if (a.change) { controller.geometry(a.change); store.set({ announcement: geometryText("resized") }); }
64
+ };
65
+ const cancel = () => finish(false);
66
+ const make = (kind, id) => {
67
+ if (!usable() || active) return null;
68
+ const root = getRoot(), w = controller.current(), { left, top, width, height } = root.getBoundingClientRect();
69
+ return active = { kind, id, name: w?.[id]?.route.instance, root, bounds: { left, top, width, height }, stamp: controller.stamp(), target: null, change: null };
70
+ };
71
+ const resizeFloat = (bounds, box, dx, dy) => {
72
+ const fit = floatBox(bounds.width - box.x, bounds.height - box.y, { x: 0, y: 0, width: box.width + dx, height: box.height + dy });
73
+ return { ...fit, x: box.x, y: box.y };
74
+ };
75
+ const down = (kind, id, e) => {
76
+ if (e.button !== 0 || modified(e)) return;
77
+ const w = controller.current();
78
+ if (!w || (kind !== "sash" && (w.layout !== "float" || w.floating !== id))) return;
79
+ controller.focus(id || w.focus);
80
+ const a = make(kind, id); if (!a) return;
81
+ e.preventDefault();
82
+ if (kind !== "move") a.root.classList.add("ws-resizing");
83
+ const el = e.currentTarget, pointerId = e.pointerId, x = e.clientX, y = e.clientY;
84
+ const split = splitSize(a.bounds.width, a.bounds.height, w.layout, w.ratio), box = floatBox(a.bounds.width, a.bounds.height, w.rect);
85
+ const owns = ev => ev.pointerId === undefined || ev.pointerId === pointerId;
86
+ const move = ev => {
87
+ if (!owns(ev) || active !== a) return;
88
+ if (!valid(a)) { cancel(); return; }
89
+ const dx = ev.clientX - x, dy = ev.clientY - y;
90
+ if (kind === "move" && !a.change && Math.hypot(dx, dy) < 6) return;
91
+ a.root.classList.add("ws-resizing");
92
+ if (kind === "sash") {
93
+ const total = (w.layout === "stack" ? a.bounds.height : a.bounds.width) - 8;
94
+ a.change = { ratio: splitSize(a.bounds.width, a.bounds.height, w.layout, (split.first + (w.layout === "stack" ? dy : dx)) / total).ratio };
95
+ } else {
96
+ a.change = { rect: kind === "move" ? floatBox(a.bounds.width, a.bounds.height, { ...box, x: box.x + dx, y: box.y + dy }) : resizeFloat(a.bounds, box, dx, dy) };
97
+ if (kind === "move") preview(a, ev.clientX, ev.clientY, true);
98
+ }
99
+ store.set({ transient: a.change });
100
+ };
101
+ const up = ev => { if (owns(ev) && active === a) finish(true); }, stop = ev => { if (owns(ev) && active === a) cancel(); };
102
+ win.addEventListener("pointermove", move); win.addEventListener("pointerup", up); win.addEventListener("pointercancel", stop); el.addEventListener("lostpointercapture", stop);
103
+ a.off = () => {
104
+ win.removeEventListener("pointermove", move); win.removeEventListener("pointerup", up); win.removeEventListener("pointercancel", stop); el.removeEventListener("lostpointercapture", stop);
105
+ try { el.releasePointerCapture(pointerId); } catch { /* not captured */ }
106
+ };
107
+ try { el.setPointerCapture(pointerId); } catch { /* window listeners still own the physical drag */ }
108
+ };
109
+ const over = e => {
110
+ const a = active; if (!a || a.kind !== "dock") return;
111
+ if (!valid(a)) { cancel(); return; }
112
+ preview(a, e.clientX, e.clientY);
113
+ if (a.target) { e.preventDefault(); if (e.dataTransfer) e.dataTransfer.dropEffect = "move"; }
114
+ };
115
+ const dropped = e => {
116
+ const a = active; if (!a || a.kind !== "dock") return;
117
+ over(e);
118
+ if (active !== a) return;
119
+ if (a.target) { e.preventDefault(); e.stopPropagation(); finish(true); } else cancel();
120
+ };
121
+ const key = e => {
122
+ const a = active; if (!a || e.isComposing || modified(e)) return;
123
+ if (!valid(a)) { cancel(); return; }
124
+ if (e.key === "Escape") { e.preventDefault(); e.stopImmediatePropagation(); cancel(); return; }
125
+ if (a.kind !== "keyboard") return;
126
+ if (e.key === "Tab") { cancel(); return; }
127
+ if (e.key === "Enter") { e.preventDefault(); e.stopPropagation(); finish(true); return; }
128
+ const step = e.shiftKey ? 64 : 16;
129
+ const dx = e.key === "ArrowRight" ? step : e.key === "ArrowLeft" ? -step : 0, dy = e.key === "ArrowDown" ? step : e.key === "ArrowUp" ? -step : 0;
130
+ if (!dx && !dy) return;
131
+ e.preventDefault(); e.stopPropagation();
132
+ const box = a.change?.rect || a.box;
133
+ a.change = { rect: a.mode === "move" ? floatBox(a.bounds.width, a.bounds.height, { ...box, x: box.x + dx, y: box.y + dy }) : resizeFloat(a.bounds, box, dx, dy) };
134
+ store.set({ transient: a.change });
135
+ };
136
+ const outside = () => { if (active?.kind === "keyboard") cancel(); };
137
+ const focus = e => { if (active?.kind === "keyboard" && !active.root.querySelector(`[data-pane="${active.id}"]`)?.contains(e.target)) cancel(); };
138
+ const off = controller.subscribe(() => { if (active && !valid(active)) cancel(); });
139
+ doc.addEventListener("dragover", over, true); doc.addEventListener("drop", dropped, true); doc.addEventListener("dragend", cancel, true); doc.addEventListener("keydown", key, true); doc.addEventListener("pointerdown", outside, true); doc.addEventListener("focusin", focus, true);
140
+ win.addEventListener("blur", cancel); win.addEventListener("resize", cancel);
141
+ return {
142
+ store, cancel,
143
+ dragStart(name, e, id) {
144
+ if (!isSafeInstanceName(name) || !e.dataTransfer) return false;
145
+ if (id) controller.focus(id);
146
+ const a = make("dock", id); if (!a) return false;
147
+ a.name = name;
148
+ try { e.dataTransfer.effectAllowed = "move"; e.dataTransfer.setData("application/x-agend-pane", name); } catch { /* source ownership is local, not read from the transfer */ }
149
+ return true;
150
+ },
151
+ dragEnd: cancel,
152
+ sashDown: e => down("sash", null, e),
153
+ floatDown: (kind, id, e) => down(kind, id, e),
154
+ sashKey(e) {
155
+ const w = controller.current(), rect = getRoot()?.getBoundingClientRect();
156
+ if (!w || !rect || modified(e) || !usable() || w.layout === "float") return;
157
+ const size = splitSize(rect.width, rect.height, w.layout, w.ratio), total = size.first + size.second, step = e.shiftKey ? 64 : 16;
158
+ let first;
159
+ if (e.key === "Home") first = size.min; else if (e.key === "End") first = size.max; else if (e.key === "Enter") first = total / 2;
160
+ else if (e.key === (w.layout === "stack" ? "ArrowDown" : "ArrowRight")) first = size.first + step;
161
+ else if (e.key === (w.layout === "stack" ? "ArrowUp" : "ArrowLeft")) first = size.first - step;
162
+ else return;
163
+ e.preventDefault(); controller.geometry({ ratio: splitSize(rect.width, rect.height, w.layout, first / total).ratio }); store.set({ announcement: geometryText("resized") });
164
+ },
165
+ keyboard(mode, id) {
166
+ const w = controller.current(); if (!w || w.layout !== "float" || w.floating !== id || !["move", "resize"].includes(mode)) return;
167
+ controller.focus(id); const a = make("keyboard", id); if (!a) return;
168
+ a.mode = mode; a.box = floatBox(a.bounds.width, a.bounds.height, w.rect);
169
+ store.set({ keyboard: { mode, id } }); a.root.querySelector(`[data-pane="${id}"] h1`)?.focus();
170
+ },
171
+ close() {
172
+ if (!alive) return; cancel(); alive = false; off();
173
+ doc.removeEventListener("dragover", over, true); doc.removeEventListener("drop", dropped, true); doc.removeEventListener("dragend", cancel, true); doc.removeEventListener("keydown", key, true); doc.removeEventListener("pointerdown", outside, true); doc.removeEventListener("focusin", focus, true);
174
+ win.removeEventListener("blur", cancel); win.removeEventListener("resize", cancel);
175
+ },
176
+ };
177
+ }
@@ -1,8 +1,10 @@
1
1
  // #3637: an optional adapter to app-nav, never a second router, popstate listener or history owner.
2
2
  import { parseRoute, routePath } from "/assets/app-route.js";
3
- import { agentRoute, navigatePane, openBeside, readWorkspace, workspacePath } from "/assets/chat-workspace-model.js";
3
+ import { agentRoute, dockWorkspace, navigatePane, openBeside, readWorkspace, workspacePath } from "/assets/chat-workspace-model.js";
4
4
 
5
- export function installWorkspaceNavigation(nav, { beforeLayout = () => {}, onWorkspace = () => {} } = {}) {
5
+ export const workspaceGeometryVersion = 1;
6
+
7
+ export function installWorkspaceNavigation(nav, { beforeLayout = () => {}, onWorkspace = () => {}, geometry = false } = {}) {
6
8
  const guards = new Map(), panes = new Map(), retained = new Map();
7
9
  const dispose = record => {
8
10
  record.alive = false;
@@ -32,13 +34,13 @@ export function installWorkspaceNavigation(nav, { beforeLayout = () => {}, onWor
32
34
  if (!route || route.panel !== record.route.panel || route.instance !== record.route.instance) { dispose(record); retained.delete(key); }
33
35
  }
34
36
  if (b) onWorkspace();
35
- if (a && b && (a.layout !== b.layout || a.flipped !== b.flipped)) beforeLayout();
37
+ if (!!a !== !!b || (a && b && (a.layout !== b.layout || a.flipped !== b.flipped || a.floating !== b.floating))) beforeLayout();
36
38
  },
37
39
  resolve(url, before, { mode, opts }) {
38
40
  let w = null;
39
41
  if (mode === "navigate" && !opts.workspace && before.workspace && agentRoute(parseRoute(url.pathname)) && !url.searchParams.has("compare")) {
40
42
  w = navigatePane(before.workspace, before.workspace.focus, url);
41
- } else w = readWorkspace(url, before.workspace);
43
+ } else w = readWorkspace(url, before.workspace, geometry);
42
44
  return w ? target(w) : { route: parseRoute(url.pathname), workspace: null, path: url.pathname + url.search + url.hash };
43
45
  },
44
46
  refresh(s) {
@@ -85,6 +87,27 @@ export function installWorkspaceNavigation(nav, { beforeLayout = () => {}, onWor
85
87
  }
86
88
  return {
87
89
  current, pane,
90
+ stamp: () => nav.navStore.get(),
91
+ subscribe: fn => nav.navStore.subscribe(fn),
92
+ dock(name, target, zone) {
93
+ if (!["left", "right", "top", "bottom", "center"].includes(zone)) return;
94
+ const w = current();
95
+ if (w) { const next = dockWorkspace(w, target, zone, name); if (next !== w) go(next); return; }
96
+ const route = nav.navStore.get().route;
97
+ if (!agentRoute(route) || name === route.instance) return;
98
+ const next = openBeside(null, route, name, ["top", "bottom"].includes(zone) ? "stack" : "right");
99
+ if (!next) return;
100
+ if (zone === "center") { nav.navigate(routePath({ panel: "chat", instance: name })); return; }
101
+ const url = address(); next.a = { ...next.a, search: url.search, hash: url.hash };
102
+ next.flipped = ["left", "top"].includes(zone); go(next);
103
+ },
104
+ geometry(change) {
105
+ const w = current(); if (!w || !change) return;
106
+ const next = { ...w };
107
+ if (typeof change.ratio === "number" && Number.isFinite(change.ratio)) next.ratio = change.ratio;
108
+ if (w.layout === "float" && change.rect) { const { x, y, width, height } = change.rect; next.rect = { x, y, width, height }; }
109
+ go(next, { replace: true });
110
+ },
88
111
  focusedName: () => nav.navStore.get().route?.instance,
89
112
  open(name, layout = "right") {
90
113
  const before = current(), w = openBeside(before, nav.navStore.get().route, name, layout);
@@ -105,11 +128,12 @@ export function installWorkspaceNavigation(nav, { beforeLayout = () => {}, onWor
105
128
  });
106
129
  }
107
130
  },
108
- layout(layout) {
109
- const w = current(); if (!w || !["right", "stack"].includes(layout) || w.layout === layout) return;
110
- go({ ...w, layout });
131
+ layout(layout, floating = "b") {
132
+ const w = current(); if (!w || !["right", "stack", "float"].includes(layout) || (layout === "float" && !geometry) || (w.layout === layout && (layout !== "float" || w.floating === floating))) return;
133
+ const { floating: oldFloating, rect, ...docked } = w;
134
+ go({ ...docked, layout, ...(layout === "float" ? { floating: floating === "a" ? "a" : "b", rect: rect || null } : {}) });
111
135
  },
112
- swap() { const w = current(); if (w) go({ ...w, flipped: !w.flipped }); },
136
+ swap() { const w = current(); if (w) go({ ...w, ...(w.layout === "float" ? { floating: w.floating === "a" ? "b" : "a" } : { flipped: !w.flipped }) }); },
113
137
  closePane(id) {
114
138
  const w = current(); if (!w) return;
115
139
  const kept = w[id === "a" ? "b" : "a"];
@@ -118,8 +142,8 @@ export function installWorkspaceNavigation(nav, { beforeLayout = () => {}, onWor
118
142
  if (next.workspace || next.route?.instance !== kept.route.instance) return;
119
143
  schedule(() => { if (nav.navStore.get() === next) doc.querySelector("#main .panel-head h1")?.focus(); });
120
144
  },
121
- restore(w) { if (w) go(w, { replace: true }); },
122
- restoreAddress() { const w = readWorkspace(address()); if (w) go(w, { replace: true }); },
145
+ restore(w) { if (w && (w.layout !== "float" || geometry)) go(w, { replace: true }); },
146
+ restoreAddress() { const w = readWorkspace(address(), null, geometry); if (w) go(w, { replace: true }); },
123
147
  close() { if (!alive) return; alive = false; for (const cancel of pending) cancel(); pending.clear(); for (const record of retained.values()) dispose(record); retained.clear(); off(); },
124
148
  };
125
149
  }