synabun 2.4.5 → 2.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/docs/whatsapp.md +17 -1
  4. package/hooks/claude-code/session-start.mjs +21 -18
  5. package/lib/claude-global-config.js +214 -0
  6. package/lib/client-config-repair.js +17 -3
  7. package/mcp-server/dist/index.d.ts.map +1 -1
  8. package/mcp-server/dist/index.js +6 -1
  9. package/mcp-server/dist/index.js.map +1 -1
  10. package/mcp-server/dist/services/tool-catalog.js +1 -1
  11. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  12. package/mcp-server/dist/tools/agents.d.ts +2 -0
  13. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  14. package/mcp-server/dist/tools/agents.js +11 -5
  15. package/mcp-server/dist/tools/agents.js.map +1 -1
  16. package/mcp-server/dist/tools/skill-tools.d.ts +24 -5
  17. package/mcp-server/dist/tools/skill-tools.d.ts.map +1 -1
  18. package/mcp-server/dist/tools/skill-tools.js +88 -8
  19. package/mcp-server/dist/tools/skill-tools.js.map +1 -1
  20. package/mcp-server/dist/tools/tool-groups.d.ts.map +1 -1
  21. package/mcp-server/dist/tools/tool-groups.js +19 -4
  22. package/mcp-server/dist/tools/tool-groups.js.map +1 -1
  23. package/mcp-server/package-lock.json +2 -2
  24. package/mcp-server/package.json +1 -1
  25. package/mcp-server/src/index.ts +6 -1
  26. package/mcp-server/src/services/tool-catalog.ts +1 -1
  27. package/mcp-server/src/tools/agents.ts +11 -5
  28. package/mcp-server/src/tools/skill-tools.ts +82 -9
  29. package/mcp-server/src/tools/tool-groups.ts +19 -4
  30. package/neural-interface/i18n/en.json +153 -10
  31. package/neural-interface/i18n/pt-BR.json +153 -10
  32. package/neural-interface/lib/antigravity/panel-bridge.js +7 -3
  33. package/neural-interface/lib/assistant-dispatch.js +15 -1
  34. package/neural-interface/lib/assistant-runtime.js +79 -8
  35. package/neural-interface/lib/assistant-user-context.js +7 -3
  36. package/neural-interface/lib/browser-background-tab.js +12 -0
  37. package/neural-interface/lib/browser-guard-cdp.js +2 -1
  38. package/neural-interface/lib/browser-network-guard.js +140 -3
  39. package/neural-interface/lib/browser-own-targets.js +350 -0
  40. package/neural-interface/lib/claude-agent-bridge.js +13 -2
  41. package/neural-interface/lib/codex-thread-history.js +144 -7
  42. package/neural-interface/lib/codex-worker-app-server.js +84 -30
  43. package/neural-interface/lib/db.js +26 -0
  44. package/neural-interface/lib/greeting/sources.js +7 -3
  45. package/neural-interface/lib/jsonl-lines.js +10 -11
  46. package/neural-interface/lib/launch-block-api.js +86 -0
  47. package/neural-interface/lib/line-buffer.js +88 -0
  48. package/neural-interface/lib/loop-stall.js +15 -1
  49. package/neural-interface/lib/memory-list-read.js +105 -0
  50. package/neural-interface/lib/memory-timers.js +4 -1
  51. package/neural-interface/lib/morelogin-launch-recovery.js +506 -0
  52. package/neural-interface/lib/morelogin-profile-failures.js +48 -1
  53. package/neural-interface/lib/morelogin.js +16 -2
  54. package/neural-interface/lib/native-loop-runtime.js +7 -3
  55. package/neural-interface/lib/provider-panel-api-key-auth.js +33 -6
  56. package/neural-interface/lib/skills/api-v2.js +18 -3
  57. package/neural-interface/lib/skills/bundle.js +2 -2
  58. package/neural-interface/lib/skills/deploy.js +169 -34
  59. package/neural-interface/lib/skills/digest.js +57 -3
  60. package/neural-interface/lib/skills/health.js +55 -1
  61. package/neural-interface/lib/skills/known-bridge-digests.json +12 -0
  62. package/neural-interface/lib/skills/runtime-checks.js +7 -4
  63. package/neural-interface/lib/skills/scan-shell.js +56 -7
  64. package/neural-interface/lib/skills/scan.js +13 -12
  65. package/neural-interface/lib/skills/service.js +7 -2
  66. package/neural-interface/lib/skills/telemetry.js +2 -2
  67. package/neural-interface/lib/teams/README.md +12 -5
  68. package/neural-interface/lib/teams/api.js +15 -4
  69. package/neural-interface/lib/teams/index.js +2 -0
  70. package/neural-interface/lib/teams/landing.js +195 -75
  71. package/neural-interface/lib/teams/scheduler.js +31 -32
  72. package/neural-interface/lib/terminal-token-redaction.js +228 -58
  73. package/neural-interface/lib/terminal-tokens.js +18 -0
  74. package/neural-interface/lib/whatsapp/brain.js +21 -0
  75. package/neural-interface/lib/whatsapp/bridge.js +40 -4
  76. package/neural-interface/package-lock.json +2 -2
  77. package/neural-interface/package.json +1 -1
  78. package/neural-interface/public/index.html +117 -37
  79. package/neural-interface/public/shared/agents/studio/ax-api.js +11 -0
  80. package/neural-interface/public/shared/agents/studio/ax-create-view.js +1 -1
  81. package/neural-interface/public/shared/agents/studio/ax-icons.js +1 -0
  82. package/neural-interface/public/shared/agents/studio/ax-library-view.js +3 -2
  83. package/neural-interface/public/shared/agents/studio/ax-main.js +127 -41
  84. package/neural-interface/public/shared/agents/studio/ax-review-view.js +3 -2
  85. package/neural-interface/public/shared/agents/studio/ax-teams-view.js +137 -39
  86. package/neural-interface/public/shared/agents/studio/ax-teams.js +219 -4
  87. package/neural-interface/public/shared/agents/studio/ax-ui.js +31 -0
  88. package/neural-interface/public/shared/agents/studio/ax-views.js +67 -69
  89. package/neural-interface/public/shared/agents/studio/ax-work-answer.js +86 -0
  90. package/neural-interface/public/shared/agents/studio/ax-work-view.js +305 -0
  91. package/neural-interface/public/shared/agents/studio/ax-work.css +74 -0
  92. package/neural-interface/public/shared/agents/studio/ax-work.js +300 -0
  93. package/neural-interface/public/shared/cdx/cdx-deferred.js +90 -0
  94. package/neural-interface/public/shared/cdx/cdx-render.js +18 -7
  95. package/neural-interface/public/shared/cdx/cdx-tabs.js +2 -1
  96. package/neural-interface/public/shared/launch-block-view.js +124 -0
  97. package/neural-interface/public/shared/loading-diagnostic-entry.js +16 -1
  98. package/neural-interface/public/shared/skills/studio/sx-operations-view.js +5 -0
  99. package/neural-interface/public/shared/skills/studio/sx-plan.js +42 -3
  100. package/neural-interface/public/shared/skills/studio/sx-publish-view.js +20 -4
  101. package/neural-interface/public/shared/styles.css +17 -0
  102. package/neural-interface/public/shared/ui-launch-block-notice.js +155 -0
  103. package/neural-interface/public/shared/ui-navbar.js +11 -0
  104. package/neural-interface/public/shared/ui-sync.js +2 -0
  105. package/neural-interface/server.js +745 -270
  106. package/npm-shrinkwrap.json +2 -2
  107. package/package.json +2 -1
  108. package/skills/skill-forge/SKILL.md +7 -3
@@ -6,7 +6,7 @@
6
6
  // Studio's sibling and behaves as it does (it carries that window's classes, so its chrome, its docking, its
7
7
  // resizing and its narrow layouts are the same rules of styles.css): non-modal unless the owner dims the
8
8
  // background, dockable beside the side panels, opened where it was left at the size it had, with a rail of places
9
- // (Library · Create · Review · Teams) and, from a place, one agent with its tabs (Edit · Revisions · Runs · Test
9
+ // (Work · Agents) and, from a place, one agent with its tabs (Edit · Revisions · Runs · Test
10
10
  // run). One view machine (ax-views.js) and one render switch; every place listens on the one main area and ends
11
11
  // its listeners when another is drawn.
12
12
  //
@@ -21,7 +21,7 @@
21
21
 
22
22
  import { t, tp, getLocale } from '../../i18n.js';
23
23
  import { storage } from '../../storage.js';
24
- import { emit } from '../../state.js';
24
+ import { emit, on } from '../../state.js';
25
25
  import { isGuest, showGuestToast } from '../../ui-sync.js';
26
26
  import { KEYS } from '../../constants.js';
27
27
  import { createUnloadGuard } from '../../editor/editor-safety.js';
@@ -31,11 +31,11 @@ import { frameRect } from '../../app-frame.js';
31
31
  import { initialRect, openRect } from '../../skills/studio/sx-geometry.js';
32
32
  import { html, setHTML, ICONS, inTextField, focusableIn, trapIndex } from '../../skills/studio/sx-dom.js';
33
33
  import { createAgentsApi } from './ax-api.js';
34
- import { parseOpen, initialView, viewToSave, navigate, railModel, agentKeyText, capsFailure, PLACES } from './ax-views.js';
35
- import { cleanFilters, countAgents, STATUSES } from './ax-library.js';
36
- import { activeTeams } from './ax-teams.js';
34
+ import { parseOpen, initialView, viewToSave, navigate, railModel, runDestination, agentKeyText, capsFailure, PLACES } from './ax-views.js';
35
+ import { cleanFilters, countAgents } from './ax-library.js';
36
+ import { renderWork, newWorkState, leaveWork, stopWork, onWorkChanged, loadWork, workNeedsYou } from './ax-work-view.js';
37
37
  import { AX_ICONS } from './ax-icons.js';
38
- import { errorText, emptyHTML } from './ax-ui.js';
38
+ import { errorText, emptyHTML, loadingHTML, shellText } from './ax-ui.js';
39
39
  import { renderLibrary, leaveLibrary } from './ax-library-view.js';
40
40
  import { renderReview, leaveReview, forgetReview } from './ax-review-view.js';
41
41
  import { renderCreate, leaveCreate, newCreateState } from './ax-create-view.js';
@@ -49,7 +49,7 @@ const RAIL_KEY = 'agents-studio-rail-collapsed';
49
49
  const VIEW_KEY = 'agents-studio-view';
50
50
  const FILTERS_KEY = 'agents-studio-filters';
51
51
  const MAC = /Mac|iPhone|iPad/.test(globalThis.navigator?.platform || '');
52
- const RAIL_ICONS = { library: ICONS.library, create: ICONS.create, review: ICONS.review, teams: AX_ICONS.teams };
52
+ const RAIL_ICONS = { work: AX_ICONS.work, agents: AX_ICONS.mark };
53
53
 
54
54
  // ── State ──
55
55
 
@@ -58,12 +58,13 @@ const S = {
58
58
  caps: null, info: null, capsFailed: false,
59
59
  agents: [], counts: countAgents([]), loading: null, loadError: null, loaded: false,
60
60
  view: initialView(null), filters: cleanFilters(null),
61
- ed: null, create: newCreateState(), teams: newTeamsState(),
61
+ ed: null, create: newCreateState(), teams: newTeamsState(), work: newWorkState(),
62
62
  sources: newSources(),
63
63
  docked: false, dim: false, changeTimer: 0, awaitingDraft: false, reading: null, readWanted: false,
64
64
  };
65
65
  let _capsPromise = null;
66
66
  const api = createAgentsApi();
67
+ const runsOnlyApi = { ...api, teams: async () => ({ available: false, teams: [] }), team: async () => ({ available: false, team: null }) };
67
68
 
68
69
  function newSources() {
69
70
  return { models: null, modelsState: 'idle', accounts: {}, toolCatalog: null, toolsState: 'idle', profiles: [], profilesState: 'idle', skills: [], skillsState: 'idle', categories: [], categoriesState: 'idle', efforts: null };
@@ -183,6 +184,7 @@ export async function openStudio(detail = {}) {
183
184
  S.view = initialView(readJson(VIEW_KEY, null));
184
185
  S.create = newCreateState();
185
186
  S.teams = newTeamsState();
187
+ S.work = newWorkState();
186
188
  S.sources = newSources();
187
189
  S.ed = null;
188
190
  if (want.explicit) S.view = navigate(S.view, { type: 'open', want });
@@ -208,23 +210,25 @@ export async function openStudio(detail = {}) {
208
210
  S.unload = createUnloadGuard({ target: window, isDirty: () => editorDirty(S.ed) });
209
211
  S.unload.install();
210
212
  const gen = S.gen;
213
+ const library = loadData().catch(() => {});
211
214
  enterView();
212
215
  render();
213
216
  requestAnimationFrame(() => { S.backdrop?.classList.add('open'); S.panel?.classList.add('open'); });
214
217
  panel.focus({ preventScroll: true });
215
218
  emit('agents:window', { open: true });
216
219
  try {
217
- await loadData();
218
- } catch { /* the place says what failed */ }
220
+ await capabilities();
221
+ if (gen !== S.gen || !S.panel) return;
222
+ enterView();
223
+ render({ keepFocus: true });
224
+ } catch { /* the shell shows the capability error */ }
225
+ await library;
219
226
  if (gen !== S.gen || !S.panel) return;
220
- // The editor's lists are asked for only from a server that answered: one that refused this caller, or has no
221
- // Agents routes, is asked for nothing more.
222
- if (S.caps) loadSources();
223
227
  // The agent the window was left on may be gone: the Library then.
224
228
  if (S.view.place === 'agent' && S.loaded && !S.agents.some((a) => agentKeyText(a) === agentKeyText(S.view.agent))) { dropEditor(); S.view = navigate(S.view, { type: 'place', place: 'library' }); }
225
229
  enterView();
226
230
  render({ keepFocus: true });
227
- focusPlace();
231
+ if (document.activeElement === panel) focusPlace();
228
232
  }
229
233
 
230
234
  function placeWindow(floating = null) {
@@ -276,6 +280,7 @@ export function closeStudio() {
276
280
  closeDialog();
277
281
  leavePlaces();
278
282
  stopTeams();
283
+ stopWork();
279
284
  dropEditor();
280
285
  forgetReview();
281
286
  S.life?.abort();
@@ -304,7 +309,7 @@ function dropEditor() {
304
309
  }
305
310
 
306
311
  function leavePlaces() {
307
- leaveLibrary(); leaveReview(); leaveCreate(); leaveTeams(); leaveAgent();
312
+ leaveLibrary(); leaveReview(); leaveCreate(); leaveTeams(); leaveWork(); leaveAgent();
308
313
  }
309
314
 
310
315
  // ── The shell ──
@@ -336,15 +341,24 @@ function wireShell() {
336
341
  // The header and the rail (the places listen on the main area themselves).
337
342
  S.panel.addEventListener('click', (e) => {
338
343
  const el = e.target.closest?.('[data-act]');
339
- if (!el || !S.panel.contains(el) || el.disabled || el.closest('#ax-main')) return;
344
+ if (!el || !S.panel.contains(el) || el.disabled) return;
340
345
  const act = el.dataset.act;
346
+ if (el.closest('#ax-main') && act !== 'agents-section') return;
347
+ if (act === 'agents-section') { go({ type: 'place', place: el.dataset.place }); return; }
341
348
  if (act === 'close') requestCloseStudio();
342
349
  else if (act === 'dock') toggleDock();
343
350
  else if (act === 'dim') toggleDim();
344
351
  else if (act === 'toggle-rail') toggleRail();
345
- else if (act === 'place') go({ type: 'place', place: el.dataset.place }).then((moved) => { if (moved) focusPlace(); });
346
- else if (act === 'status-view') { S.filters = { ...S.filters, status: el.dataset.status, scope: 'all', provider: 'all', q: '' }; saveFilters(); go({ type: 'place', place: 'library' }); }
352
+ else if (act === 'place') go({ type: 'place', place: el.dataset.place });
353
+ else if (act === 'work-group') {
354
+ const heading = S.panel.querySelector('#ax-work-h-' + el.dataset.group);
355
+ if (heading) { heading.tabIndex = -1; heading.focus({ preventScroll: true }); heading.scrollIntoView({ block: 'nearest' }); }
356
+ }
347
357
  }, { signal });
358
+ for (const name of ['dispatch', 'run-removed', 'permission-request', 'permission-resolved']) {
359
+ const off = on('sync:assistant:' + name, () => { if (S.caps) onWorkChanged(ctx(), S.work); });
360
+ signal.addEventListener('abort', off, { once: true });
361
+ }
348
362
  // Keys only while the focus is in the Studio: the window is not modal, and the page beside it keeps its own.
349
363
  document.addEventListener('keydown', onKeydown, { signal });
350
364
  window.addEventListener('resize', () => { if (!S.docked) placeWithinViewport(); }, { signal });
@@ -433,6 +447,20 @@ function toggleRail() {
433
447
 
434
448
  /** What the view needs before it is drawn (the editor's state of the agent it names). */
435
449
  function enterView() {
450
+ if (S.caps) {
451
+ const cap = { review: 'reviews', create: 'drafts' }[S.view.place];
452
+ if (cap && !S.caps.has(cap)) S.view = navigate(S.view, { type: 'place', place: 'agents' });
453
+ if (S.view.place === 'teams' && !S.caps.has('teams')) S.view = navigate(S.view, { type: 'place', place: 'work' });
454
+ if (S.view.place === 'create' || S.view.place === 'agent') loadSources();
455
+ if (!S.work.model && !S.work.loading) {
456
+ const gen = S.gen;
457
+ loadWork(ctx(), S.work).then(() => {
458
+ if (gen !== S.gen || !S.panel) return;
459
+ if (S.view.place === 'work') render({ keepFocus: true });
460
+ else refreshRail();
461
+ });
462
+ }
463
+ }
436
464
  const v = S.view;
437
465
  if (v.place === 'agent' && v.agent) {
438
466
  if (!S.ed || S.ed.mode !== 'agent' || agentKeyText(S.ed.key) !== agentKeyText(v.agent)) {
@@ -454,22 +482,41 @@ function enterView() {
454
482
  */
455
483
  async function go(action, { force = false } = {}) {
456
484
  if (!S.panel) return false;
485
+ if (action.type === 'run') {
486
+ if (action.agent && S.loading) {
487
+ const origin = S.view;
488
+ const opener = S.work.returnTo;
489
+ await S.loading.catch(() => {});
490
+ if (!S.panel || origin !== S.view) return false;
491
+ S.work.returnTo = opener;
492
+ }
493
+ action = runDestination(action, S.loaded && !S.loadError ? S.agents : null, S.caps);
494
+ if (action.type === 'focus-run') {
495
+ S.work.returnTo = null;
496
+ await focusRun(action.runId);
497
+ return false;
498
+ }
499
+ }
457
500
  const next = navigate(S.view, action);
458
501
  if (next === S.view) return false;
459
502
  const leavesEditor = S.ed && !(next.place === 'agent' && S.ed.mode === 'agent' && agentKeyText(next.agent) === agentKeyText(S.ed.key));
460
503
  if (leavesEditor && !force && !(await mayLeaveEditor())) return false;
461
504
  if (!S.panel) return false;
462
505
  if (leavesEditor) dropEditor();
506
+ if (action.type === 'place' || action.type === 'open') S.work.returnTo = null;
507
+ const restoreRow = next.place === 'work' && S.work.returnTo;
463
508
  S.view = next;
464
509
  storage.setItem(VIEW_KEY, JSON.stringify(viewToSave(S.view)));
465
510
  enterView();
466
511
  render();
467
- focusPlace();
512
+ if (!restoreRow) focusPlace();
468
513
  return true;
469
514
  }
470
515
 
471
516
  function focusPlace() {
517
+ const view = S.view;
472
518
  requestAnimationFrame(() => {
519
+ if (S.view !== view) return;
473
520
  const target = S.panel?.querySelector('#ax-main [data-autofocus]') || S.panel?.querySelector('#ax-main h3, #ax-main h2');
474
521
  if (!target) return;
475
522
  if (!target.hasAttribute('tabindex') && !/^(INPUT|TEXTAREA|BUTTON)$/.test(target.tagName)) target.tabIndex = -1;
@@ -480,16 +527,23 @@ function focusPlace() {
480
527
  // ── Rendering ──
481
528
 
482
529
  function railHTML() {
483
- const items = railModel(S.view, { total: S.loaded ? S.counts.total : null, review: S.counts.review, teams: S.teams.rows ? activeTeams(S.teams.rows) : null }, S.caps);
484
- const status = S.view.place === 'library' ? S.filters.status : null;
530
+ const items = railModel(S.view, { needsYou: workNeedsYou(S.work), review: S.counts.review }, S.caps);
531
+ const groups = S.view.place === 'work' && S.work.model?.groups;
532
+ const groupKeys = { 'needs-you': 'needsYou', active: 'active', 'in-review': 'inReview', finished: 'finished' };
485
533
  return html`
486
- <ul class="sx-rail-list">${items.map((item) => html`<li><button type="button" class="sx-rail-item" data-act="place" data-place="${item.place}"${item.current ? html` aria-current="page"` : ''} title="${t(`agentsStudio.rail.${item.place}`)}">
487
- <span class="sx-rail-icon">${RAIL_ICONS[item.place]}</span><span class="sx-rail-label">${t(`agentsStudio.rail.${item.place}`)}</span>${item.count !== null ? html`<span class="sx-rail-count${item.place === 'review' ? ' ax-rail-count--review' : ''}">${item.count}${item.place === 'review' ? html`<span class="sx-sr"> ${t('agentsStudio.rail.waiting')}</span>` : ''}</span>` : ''}</button></li>`)}</ul>
488
- <div class="sx-rail-groups">
489
- <p class="sx-rail-group-label" id="ax-rail-status">${t('agentsStudio.rail.byStatus')}</p>
490
- <ul class="sx-rail-list" aria-labelledby="ax-rail-status">${STATUSES.map((s) => html`<li><button type="button" class="sx-rail-view" data-act="status-view" data-status="${s}"${status === s ? html` aria-current="true"` : ''}>
491
- <span class="sx-rail-label">${t(`agentsStudio.status.${s}`)}</span>${S.loaded ? html`<span class="sx-rail-count">${S.counts.byStatus[s] ?? 0}</span>` : ''}</button></li>`)}</ul>
492
- </div>`;
534
+ <ul class="sx-rail-list">${items.map(item => html`<li><button type="button" id="ax-rail-${item.place}" class="sx-rail-item" data-act="place" data-place="${item.place}"${item.current ? html` aria-current="page"` : ''} title="${shellText(t, `agentsStudio.rail.${item.place}`)}">
535
+ <span class="sx-rail-icon">${RAIL_ICONS[item.place]}</span><span class="sx-rail-label">${shellText(t, `agentsStudio.rail.${item.place}`)}</span>${item.count ? html`<span class="sx-rail-count${item.place === 'agents' ? ' ax-rail-count--review' : ' sx-warn-text'}">${item.count}<span class="sx-sr"> ${shellText(t, item.place === 'agents' ? 'agentsStudio.rail.waiting' : 'agentsStudio.work.needsYou')}</span></span>` : ''}</button></li>`)}</ul>
536
+ ${groups ? html`<div class="sx-rail-groups"><p class="sx-rail-group-label" id="ax-rail-status">${shellText(t, 'agentsStudio.rail.taskStatus')}</p>
537
+ <ul class="sx-rail-list" aria-labelledby="ax-rail-status">${groups.map(g => html`<li><button type="button" id="ax-rail-${g.id}" class="sx-rail-view" data-act="work-group" data-group="${g.id}">
538
+ <span class="sx-rail-label">${t(`agentsStudio.work.${groupKeys[g.id]}`)}</span><span class="sx-rail-count">${g.tasks.length}</span></button></li>`)}</ul></div>` : ''}`;
539
+ }
540
+
541
+ function refreshRail() {
542
+ const rail = S.panel?.querySelector('#ax-rail');
543
+ if (!rail) return;
544
+ const active = rail.contains(document.activeElement) && document.activeElement.id;
545
+ setHTML(rail, railHTML());
546
+ if (active) document.getElementById(active)?.focus({ preventScroll: true });
493
547
  }
494
548
 
495
549
  function headNote() {
@@ -500,6 +554,31 @@ function headNote() {
500
554
  else setHTML(note, '');
501
555
  }
502
556
 
557
+ function renderWorkPlace(main, c) {
558
+ if (!S.caps) { setHTML(main, loadingHTML(t, shellText(t, 'agentsStudio.work.loading'))); return; }
559
+ const st = S.work;
560
+ const manageId = 'ax-manage-teams';
561
+ const returningTo = st.returnTo;
562
+ renderWork(main, c, st);
563
+ const finished = main.querySelector('#ax-work-finished');
564
+ if (!finished || !st.teams?.length || st.offline) return;
565
+
566
+ // The existing management screen keeps batch cleanup and team shortcuts under Finished.
567
+ const button = document.createElement('button');
568
+ button.type = 'button';
569
+ button.id = manageId;
570
+ button.className = 'sx-btn sx-btn--sm';
571
+ button.textContent = shellText(t, 'agentsStudio.teams.manage');
572
+ button.addEventListener('click', () => {
573
+ st.scrollTop = finished.closest('.ax-work-scroll').scrollTop;
574
+ st.returnTo = manageId;
575
+ go({ type: 'manage-teams' });
576
+ });
577
+ finished.append(button);
578
+ if (returningTo) finished.closest('.ax-work-scroll').scrollTop = st.scrollTop;
579
+ if (returningTo === manageId) button.focus({ preventScroll: true });
580
+ }
581
+
503
582
  /** Draw the current place (keeping where the keyboard was when asked). */
504
583
  export function render({ keepFocus = false } = {}) {
505
584
  if (!S.panel) return;
@@ -509,7 +588,7 @@ export function render({ keepFocus = false } = {}) {
509
588
  const scroller = keepFocus ? S.panel.querySelector('#ax-main .ax-form, #ax-main .sx-place-scroll, #ax-main .sx-versions') : null;
510
589
  const scrolled = scroller ? { selector: scroller.classList.contains('ax-form') ? '.ax-form' : scroller.classList.contains('sx-versions') ? '.sx-versions' : '.sx-place-scroll', top: scroller.scrollTop } : null;
511
590
  const caret = activeId && typeof active.selectionStart === 'number' ? [active.selectionStart, active.selectionEnd] : null;
512
- setHTML(S.panel.querySelector('#ax-rail'), railHTML());
591
+ refreshRail();
513
592
  headNote();
514
593
  const main = S.panel.querySelector('#ax-main');
515
594
  const c = ctx();
@@ -518,10 +597,12 @@ export function render({ keepFocus = false } = {}) {
518
597
  leavePlaces();
519
598
  if (S.capsFailed && !S.caps) { renderOlderServer(main); return; }
520
599
  const v = S.view;
521
- if (v.place === 'agent' && S.ed) renderAgent(main, c, S.ed);
600
+ if (v.place === 'work') renderWorkPlace(main, c);
601
+ else if (v.place === 'agent' && S.ed) renderAgent(main, c, S.ed);
522
602
  else if (v.place === 'create' && S.ed?.mode === 'new') renderAgent(main, c, S.ed);
523
603
  else if (v.place === 'create') renderCreate(main, c, S.create);
524
604
  else if (v.place === 'review') renderReview(main, c);
605
+ else if (v.place === 'teams' && !S.caps) setHTML(main, loadingHTML(t));
525
606
  else if (v.place === 'teams') renderTeams(main, c, S.teams);
526
607
  else renderLibrary(main, c);
527
608
  if (scrolled) { const again = main.querySelector(scrolled.selector); if (again) again.scrollTop = scrolled.top; }
@@ -549,7 +630,7 @@ function renderOlderServer(main) {
549
630
  main.dataset.failure = why;
550
631
  setHTML(main, emptyHTML({ ...words, actions: html`<button type="button" class="sx-btn" id="ax-retry-caps">${t('agentsStudio.state.retry')}</button>` }));
551
632
  main.querySelector('#ax-retry-caps')?.addEventListener('click', async () => {
552
- try { await loadData(); loadSources(); } catch { /* still not there */ }
633
+ try { await loadData(); } catch { /* still not there */ }
553
634
  enterView();
554
635
  render();
555
636
  });
@@ -581,12 +662,13 @@ export function onAgentsChanged(msg = {}) {
581
662
  if (gen !== S.gen || S.ed !== ed) return;
582
663
  // What this window just wrote comes back as an event too: nothing new, nothing drawn again.
583
664
  if (was !== `${ed.etag}|${ed.agent?.status}|${ed.agent?.draft?.status}|${ed.agent?.approvedRevision}` || ed.error) render({ keepFocus: true });
584
- else setHTML(S.panel.querySelector('#ax-rail'), railHTML());
585
- } else setHTML(S.panel.querySelector('#ax-rail'), railHTML());
665
+ else refreshRail();
666
+ } else refreshRail();
586
667
  return;
587
668
  }
588
- if (S.view.place === 'create') { setHTML(S.panel.querySelector('#ax-rail'), railHTML()); if (S.create.describe.sent && !S.ed) render({ keepFocus: true }); return; }
589
- render({ keepFocus: true });
669
+ if (S.view.place === 'create') { refreshRail(); if (S.create.describe.sent && !S.ed) render({ keepFocus: true }); return; }
670
+ if (S.view.place === 'work' || S.view.place === 'teams') refreshRail();
671
+ else render({ keepFocus: true });
590
672
  }, 300);
591
673
  }
592
674
 
@@ -607,14 +689,17 @@ function readAgain() {
607
689
  S.reading = null;
608
690
  if (gen !== S.gen || !S.panel) return;
609
691
  if (S.view.place === 'library' || S.view.place === 'review') render({ keepFocus: true });
610
- else setHTML(S.panel.querySelector('#ax-rail'), railHTML());
692
+ else refreshRail();
611
693
  })();
612
694
  }
613
695
 
614
696
  /** A team changed (`assistant:team-changed` { teamId }). */
615
697
  export function onTeamChanged(msg = {}) {
616
- if (!S.panel) return;
617
- teamChanged(ctx(), S.teams, typeof msg?.teamId === 'string' ? msg.teamId : (typeof msg?.event?.teamId === 'string' ? msg.event.teamId : null));
698
+ if (!S.panel || !S.caps?.has('teams')) return;
699
+ const teamId = msg.teamId || msg.event?.teamId;
700
+ onWorkChanged(ctx(), S.work, { type: 'assistant:team-changed', teamId });
701
+ if (S.view.place === 'teams') teamChanged(ctx(), S.teams, teamId);
702
+ else { S.teams.rows = null; S.teams.detailFor = null; }
618
703
  }
619
704
 
620
705
  // ── Messages ──
@@ -652,7 +737,7 @@ async function focusRun(runId) {
652
737
  function ctx() {
653
738
  const guest = isGuest();
654
739
  return {
655
- t, tp, locale: getLocale(), mac: MAC, api, storage, emit,
740
+ t, tp, locale: getLocale(), mac: MAC, api: S.caps && !S.caps.has('teams') ? runsOnlyApi : api, storage, emit,
656
741
  get caps() { return S.caps || new Set(); },
657
742
  // Whether the server has said what it can do: until then nothing is said to be missing from it.
658
743
  get capsKnown() { return !!S.caps; },
@@ -671,14 +756,15 @@ function ctx() {
671
756
  get awaitingDraft() { return S.awaitingDraft; },
672
757
  gen: () => S.gen,
673
758
  alive: (gen) => gen === S.gen && !!S.panel,
674
- render, go, toast, announce, ask, focusRun,
759
+ render, go, toast, announce, ask, focusRun, refreshWorkBadge: refreshRail,
760
+ refreshWork: () => onWorkChanged(ctx(), S.work, { type: 'assistant:team-changed' }),
675
761
  saveFilters,
676
762
  /** Read the library again; `quiet` leaves the place as it is drawn (the caller draws). */
677
763
  reload: async ({ quiet = false } = {}) => {
678
764
  const gen = S.gen;
679
765
  try { await loadData(); } catch (error) { if (gen === S.gen && !quiet) toast(t('agentsStudio.toast.loadFailed', { error: errorText(t, error) }), 'error'); }
680
766
  if (gen !== S.gen || !S.panel) return;
681
- if (!quiet) render({ keepFocus: true }); else setHTML(S.panel.querySelector('#ax-rail'), railHTML());
767
+ if (!quiet) render({ keepFocus: true }); else refreshRail();
682
768
  },
683
769
  /** Something this window wrote: the list and the rail follow (the server's event arrives too). */
684
770
  changed: () => { forgetReview(); readAgain(); },
@@ -13,7 +13,7 @@ import { html, setHTML, ICONS } from '../../skills/studio/sx-dom.js';
13
13
  import { reviewQueue } from './ax-library.js';
14
14
  import { keyOf, agentKeyText } from './ax-views.js';
15
15
  import { AX_ICONS } from './ax-icons.js';
16
- import { agentMark, scopeTag, timeTag, authorText, loadingHTML, errorHTML, emptyHTML, errorText, diffHTML, wordsOf } from './ax-ui.js';
16
+ import { agentMark, scopeTag, timeTag, authorText, loadingHTML, errorHTML, emptyHTML, errorText, diffHTML, wordsOf, agentSections } from './ax-ui.js';
17
17
  import { confirmApproval } from './ax-agent-view.js';
18
18
 
19
19
  let life = null;
@@ -88,9 +88,10 @@ export function renderReview(main, ctx) {
88
88
  : html`<ul class="sx-cards ax-review-cards" aria-label="${t('agentsStudio.rail.review')}">${queue.map((agent) => cardHTML(ctx, agent))}</ul>`;
89
89
  setHTML(main, html`<section class="sx-place ax-place" aria-labelledby="ax-review-title">
90
90
  <header class="sx-place-head">
91
- <h3 class="sx-place-title" id="ax-review-title" tabindex="-1" data-autofocus>${t('agentsStudio.rail.review')}</h3>
91
+ <h3 class="sx-place-title" id="ax-review-title" tabindex="-1" data-autofocus>${t('agentsStudio.rail.agents')}</h3>
92
92
  <p class="sx-place-sub">${queue.length ? ctx.tp('agentsStudio.review.waiting', queue.length) : t('agentsStudio.review.sub')}</p>
93
93
  </header>
94
+ ${agentSections(ctx)}
94
95
  ${ctx.awaitingDraft ? html`<div class="sx-place-notices"><div class="sx-notice sx-notice--info">${AX_ICONS.send}<span class="sx-notice-text">${t('agentsStudio.review.awaiting')}</span></div></div>` : ''}
95
96
  <div class="sx-place-scroll" id="ax-review-list">${body}</div>
96
97
  </section>`);