synabun 2.4.5 → 2.4.6

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 (95) hide show
  1. package/CHANGELOG.md +25 -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 +135 -10
  31. package/neural-interface/i18n/pt-BR.json +135 -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/claude-agent-bridge.js +13 -2
  37. package/neural-interface/lib/codex-thread-history.js +144 -7
  38. package/neural-interface/lib/codex-worker-app-server.js +84 -30
  39. package/neural-interface/lib/db.js +26 -0
  40. package/neural-interface/lib/greeting/sources.js +7 -3
  41. package/neural-interface/lib/jsonl-lines.js +10 -11
  42. package/neural-interface/lib/line-buffer.js +88 -0
  43. package/neural-interface/lib/loop-stall.js +15 -1
  44. package/neural-interface/lib/memory-list-read.js +105 -0
  45. package/neural-interface/lib/memory-timers.js +4 -1
  46. package/neural-interface/lib/native-loop-runtime.js +7 -3
  47. package/neural-interface/lib/provider-panel-api-key-auth.js +33 -6
  48. package/neural-interface/lib/skills/api-v2.js +18 -3
  49. package/neural-interface/lib/skills/bundle.js +2 -2
  50. package/neural-interface/lib/skills/deploy.js +169 -34
  51. package/neural-interface/lib/skills/digest.js +57 -3
  52. package/neural-interface/lib/skills/health.js +55 -1
  53. package/neural-interface/lib/skills/known-bridge-digests.json +12 -0
  54. package/neural-interface/lib/skills/runtime-checks.js +7 -4
  55. package/neural-interface/lib/skills/scan-shell.js +56 -7
  56. package/neural-interface/lib/skills/scan.js +13 -12
  57. package/neural-interface/lib/skills/service.js +7 -2
  58. package/neural-interface/lib/skills/telemetry.js +2 -2
  59. package/neural-interface/lib/teams/README.md +12 -5
  60. package/neural-interface/lib/teams/api.js +15 -4
  61. package/neural-interface/lib/teams/index.js +2 -0
  62. package/neural-interface/lib/teams/landing.js +195 -75
  63. package/neural-interface/lib/teams/scheduler.js +31 -32
  64. package/neural-interface/lib/terminal-token-redaction.js +228 -58
  65. package/neural-interface/lib/terminal-tokens.js +18 -0
  66. package/neural-interface/lib/whatsapp/brain.js +21 -0
  67. package/neural-interface/lib/whatsapp/bridge.js +40 -4
  68. package/neural-interface/package-lock.json +2 -2
  69. package/neural-interface/package.json +1 -1
  70. package/neural-interface/public/index.html +117 -37
  71. package/neural-interface/public/shared/agents/studio/ax-api.js +11 -0
  72. package/neural-interface/public/shared/agents/studio/ax-create-view.js +1 -1
  73. package/neural-interface/public/shared/agents/studio/ax-icons.js +1 -0
  74. package/neural-interface/public/shared/agents/studio/ax-library-view.js +3 -2
  75. package/neural-interface/public/shared/agents/studio/ax-main.js +127 -41
  76. package/neural-interface/public/shared/agents/studio/ax-review-view.js +3 -2
  77. package/neural-interface/public/shared/agents/studio/ax-teams-view.js +137 -39
  78. package/neural-interface/public/shared/agents/studio/ax-teams.js +219 -4
  79. package/neural-interface/public/shared/agents/studio/ax-ui.js +31 -0
  80. package/neural-interface/public/shared/agents/studio/ax-views.js +67 -69
  81. package/neural-interface/public/shared/agents/studio/ax-work-answer.js +86 -0
  82. package/neural-interface/public/shared/agents/studio/ax-work-view.js +305 -0
  83. package/neural-interface/public/shared/agents/studio/ax-work.css +74 -0
  84. package/neural-interface/public/shared/agents/studio/ax-work.js +300 -0
  85. package/neural-interface/public/shared/cdx/cdx-deferred.js +90 -0
  86. package/neural-interface/public/shared/cdx/cdx-render.js +18 -7
  87. package/neural-interface/public/shared/cdx/cdx-tabs.js +2 -1
  88. package/neural-interface/public/shared/loading-diagnostic-entry.js +16 -1
  89. package/neural-interface/public/shared/skills/studio/sx-operations-view.js +5 -0
  90. package/neural-interface/public/shared/skills/studio/sx-plan.js +42 -3
  91. package/neural-interface/public/shared/skills/studio/sx-publish-view.js +20 -4
  92. package/neural-interface/server.js +316 -252
  93. package/npm-shrinkwrap.json +2 -2
  94. package/package.json +2 -1
  95. package/skills/skill-forge/SKILL.md +7 -3
@@ -20,6 +20,14 @@
20
20
  // one, never one with a live worker) has one quick action beside it: Clean up & remove, Discard & remove (nothing
21
21
  // of the team on disk) or Discard. The decisions are ax-teams.js `quickActionOf` / `teamView`.
22
22
  //
23
+ // Land follows the server's preview of the landing (`landing.preview`): it is drawn only while a landing sent now
24
+ // would be accepted, and otherwise the card says why in the page's words. Its question shows what will move (the
25
+ // target branch, its tip, the integration head, the tests on that head) and the request carries those values; an
26
+ // answer that they no longer hold (LANDING_PREVIEW_STALE) lands nothing and asks again with the fresh ones. When the
27
+ // tests are all that is in the way, Land without tests is a second, plain button with a question of its own, and the
28
+ // only request that carries the owner's override. The decisions are ax-teams.js `landWithPreview` / `landQuestionOf`.
29
+ // A server without the preview is drawn as before.
30
+ //
23
31
  // The routes are the team scheduler's (GET /teams, /teams/:id, POST /teams/:id/land and /discard; with the
24
32
  // capabilities `teams-cleanup` and `teams-remove`, POST /teams/:id/cleanup, DELETE /teams/:id and POST
25
33
  // /teams/clear-finished; with `teams-on-target`, POST /teams/:id/cleanup-merged; with `teams-quick-discard`, the
@@ -28,10 +36,10 @@
28
36
  // needs it.
29
37
 
30
38
  import { html, setHTML, ICONS } from '../../skills/studio/sx-dom.js';
31
- import { teamRows, teamView, splitTeams, clearableTeams, quickActionOf } from './ax-teams.js';
39
+ import { teamRows, teamView, splitTeams, clearableTeams, quickActionOf, landQuestionOf, landWithPreview, landCopy } from './ax-teams.js';
32
40
  import { baseName } from './ax-library.js';
33
41
  import { AX_ICONS } from './ax-icons.js';
34
- import { timeTag, loadingHTML, errorHTML, emptyHTML, errorText, wordOr } from './ax-ui.js';
42
+ import { timeTag, loadingHTML, errorHTML, emptyHTML, errorText, wordOr, shellText } from './ax-ui.js';
35
43
 
36
44
  let life = null;
37
45
  let refreshTimer = 0;
@@ -56,6 +64,48 @@ const shortCommit = (commit) => String(commit || '').slice(0, 9);
56
64
  /** A team's status as a chip: "Already on <branch>" for a ready team whose work is there, its status otherwise. */
57
65
  const statusChip = (t, team) => (team.onTarget ? chip(t('agentsStudio.teams.onTarget', { branch: team.onTarget.branch }), team.tone) : chip(teamState(t, team.status), team.tone));
58
66
 
67
+ /**
68
+ * A string of the landing: the translator's, or the module's own English (ax-teams.js LAND_COPY) when the locale
69
+ * file of this build does not have the key yet. The question that moves the owner's branch never shows a key.
70
+ */
71
+ const say = (t, key, params) => {
72
+ const said = t(key, params);
73
+ return said === key ? landCopy(key, params) || key : said;
74
+ };
75
+
76
+ /**
77
+ * The landing's question in the Studio's dialog (ax-teams.js `landQuestionOf` says what is in it): the lines before,
78
+ * the facts as the page's fact list (a branch and a hash in monospace, a hash whole in its title, the tests as a
79
+ * status chip), the lines after, and Cancel with the keyboard on it. Answers 'go' or 'cancel'.
80
+ */
81
+ function askLanding(ctx, question) {
82
+ const { t } = ctx;
83
+ const lineOf = (line) => {
84
+ const p = document.createElement('p');
85
+ if (line.tone === 'warn') { p.className = 'sx-warn-text'; p.setAttribute('role', 'note'); }
86
+ p.dataset.land = line.id;
87
+ p.textContent = line.key ? say(t, line.key, line.params) : line.text;
88
+ return p;
89
+ };
90
+ let extra = null;
91
+ if (question.facts.length) {
92
+ const facts = document.createElement('dl');
93
+ facts.className = 'ax-facts';
94
+ setHTML(facts, html`${question.facts.map((fact) => html`<div data-land="${fact.id}"><dt>${say(t, fact.label)}</dt><dd${fact.chip ? '' : html` class="sx-mono"`}${fact.value && fact.shown !== fact.value ? html` title="${fact.value}"` : ''}>${fact.chip ? chip(say(t, fact.chip.key), fact.chip.tone) : fact.value ? fact.shown : fact.missing ? say(t, fact.missing) : '—'}</dd></div>`)}`);
95
+ extra = document.createElement('div');
96
+ extra.className = 'ax-dlg-form';
97
+ extra.append(facts, ...question.after.map(lineOf));
98
+ }
99
+ return ctx.ask({
100
+ title: say(t, question.title.key, question.title.params),
101
+ lines: [...question.before.map(lineOf), ...(extra ? [] : question.after.map(lineOf))],
102
+ extra,
103
+ className: 'ax-dlg',
104
+ buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, ...(question.confirm ? [{ id: 'go', label: say(t, question.confirm.key), kind: question.confirm.kind }] : [])],
105
+ focus: 'cancel',
106
+ });
107
+ }
108
+
59
109
  /** A card's quick action: its words and its kind of button (the decision is ax-teams.js `quickActionOf`). */
60
110
  const QUICK = Object.freeze({
61
111
  'cleanup-merged': { label: 'agentsStudio.teams.cleanupMerged', kind: 'primary' },
@@ -203,15 +253,24 @@ function sliceHTML(ctx, slice) {
203
253
 
204
254
  function detailHTML(ctx, st) {
205
255
  const { t } = ctx;
206
- if (st.detailLoading && !st.team) return loadingHTML(t);
256
+ if (!st.team && (st.detailLoading || st.detailFor !== ctx.view.teamId)) return loadingHTML(t);
207
257
  if (st.detailError) return errorHTML(t, st.detailError);
208
258
  if (!st.team) return emptyHTML({ icon: AX_ICONS.teams, title: t('agentsStudio.teams.goneTitle'), lines: [t('agentsStudio.teams.goneHelp')], actions: html`<button type="button" class="sx-btn" data-act="back">${t('agentsStudio.teams.backToList')}</button>` });
209
259
  const team = teamView(st.team);
210
260
  const i = team.integration;
211
261
  const l = team.landing;
212
262
  const tests = i.tests;
213
- // Why Land is not offered: its work is on its base branch already, or the team is not ready yet.
214
- const landHelp = team.onTarget ? t('agentsStudio.teams.onTargetNothingToLand', { branch: team.onTarget.branch }) : t('agentsStudio.teams.landNotReady');
263
+ // What a landing sent now would move (the server's preview; null on a server without it, or for a team that is over).
264
+ const preview = team.landPreview;
265
+ const why = team.landWhy;
266
+ // Why Land is not offered: its work is on its base branch already, the preview's refusal in the page's words (the
267
+ // server's own sentence for a code the page does not know), or, without a preview, that the team is not ready yet.
268
+ const landHelp = team.onTarget ? t('agentsStudio.teams.onTargetNothingToLand', { branch: team.onTarget.branch })
269
+ : why ? (why.key ? say(t, why.key, why.params) : why.text)
270
+ : t('agentsStudio.teams.landNotReady');
271
+ // With a preview Land is drawn only while it can land; without one it is there and disabled, as before.
272
+ const landButton = !preview || team.canLand;
273
+ const busy = st.busy ? html` disabled` : '';
215
274
  return html`<div class="ax-team">
216
275
  <section class="ax-team-summary" aria-label="${t('agentsStudio.teams.summary')}">
217
276
  <dl class="ax-facts">
@@ -246,15 +305,16 @@ function detailHTML(ctx, st) {
246
305
  <h4 class="sx-section-title" id="ax-team-land-title">${ICONS.publish} ${t('agentsStudio.teams.landing')}</h4>
247
306
  <dl class="ax-facts">
248
307
  <div><dt>${t('agentsStudio.teams.status')}</dt><dd>${team.onTarget ? t('agentsStudio.teams.onTarget', { branch: team.onTarget.branch }) : l.state ? wordOr(t, 'agentsStudio.teams.landingState', l.state) : t(team.status === 'merged' || team.status === 'landed' ? 'agentsStudio.teams.landed' : 'agentsStudio.teams.notLanded')}</dd></div>
249
- ${l.targetBranch ? html`<div><dt>${t('agentsStudio.teams.target')}</dt><dd class="sx-mono">${l.targetBranch}</dd></div>` : ''}
308
+ ${preview?.targetBranch ? html`<div><dt>${t('agentsStudio.teams.target')}</dt><dd class="sx-mono"${preview.targetHead ? html` title="${preview.targetHead}"` : ''}>${preview.targetBranch}${preview.targetHead ? ` @ ${shortCommit(preview.targetHead)}` : ''}</dd></div>` : l.targetBranch ? html`<div><dt>${t('agentsStudio.teams.target')}</dt><dd class="sx-mono">${l.targetBranch}</dd></div>` : ''}
250
309
  ${l.commit ? html`<div><dt>${t('agentsStudio.teams.head')}</dt><dd class="sx-mono">${shortCommit(l.commit)}</dd></div>` : ''}
251
310
  ${l.at ? html`<div><dt>${t('agentsStudio.teams.landedAt')}</dt><dd>${timeTag(l.at, ctx.locale)}</dd></div>` : ''}
252
311
  </dl>
253
312
  ${l.error ? html`<p class="sx-field-note sx-err-text">${l.error}</p>` : ''}
254
- ${ctx.owner ? html`<div class="sx-row ax-team-actions">
255
- <button type="button" class="sx-btn sx-btn--primary" data-act="land"${team.canLand && !st.busy ? '' : html` disabled`} title="${team.canLand ? t('agentsStudio.teams.landHelp') : landHelp}">${ICONS.publish}${t('agentsStudio.teams.land')}</button>
313
+ ${ctx.owner ? html`${!team.canLand && why ? html`<p class="sx-field-note${why.tone === 'warn' ? ' sx-warn-text' : ''}" role="note" data-land-why="${why.code || 'other'}">${landHelp}</p>` : ''}<div class="sx-row ax-team-actions">
314
+ ${landButton ? html`<button type="button" class="sx-btn sx-btn--primary" data-act="land"${team.canLand && !st.busy ? '' : html` disabled`} title="${team.canLand ? t('agentsStudio.teams.landHelp') : landHelp}">${ICONS.publish}${t('agentsStudio.teams.land')}</button>` : ''}
315
+ ${team.canLandUntested ? html`<button type="button" class="sx-btn" data-act="land-untested"${busy} title="${say(t, 'agentsStudio.teams.landUntestedHelp')}">${say(t, 'agentsStudio.teams.landUntested')}</button>` : ''}
256
316
  <button type="button" class="sx-btn sx-btn--danger" data-act="discard"${team.canDiscard && !st.busy ? '' : html` disabled`}>${ICONS.trash}${t('agentsStudio.teams.discard')}</button>
257
- </div>${team.canLand ? '' : html`<p class="sx-help">${landHelp}</p>`}` : ''}
317
+ </div>${team.canLand || why ? '' : html`<p class="sx-help">${landHelp}</p>`}` : ''}
258
318
  </section>
259
319
  </div>`}
260
320
  <section aria-labelledby="ax-team-feed-title">
@@ -286,20 +346,21 @@ export async function loadTeams(ctx, st, { teamId = null } = {}) {
286
346
  st.error = error;
287
347
  }
288
348
  st.loading = false;
289
- if (teamId) await loadTeam(ctx, st, teamId);
349
+ if (teamId && ctx.view.teamId === teamId) await loadTeam(ctx, st, teamId);
290
350
  }
291
351
 
292
352
  async function loadTeam(ctx, st, teamId) {
293
353
  const gen = ctx.gen();
354
+ const read = ++st.detailRead;
294
355
  st.detailLoading = true;
295
356
  try {
296
357
  const res = await ctx.api.team(teamId);
297
- if (!ctx.alive(gen)) return;
358
+ if (!ctx.alive(gen) || read !== st.detailRead) return;
298
359
  st.team = res.team;
299
360
  st.teamId = teamId;
300
361
  st.detailError = null;
301
362
  } catch (error) {
302
- if (!ctx.alive(gen)) return;
363
+ if (!ctx.alive(gen) || read !== st.detailRead) return;
303
364
  st.detailError = error;
304
365
  }
305
366
  // Read once for this team: a team that is gone (or a server without the route) is not asked for again by a redraw.
@@ -318,7 +379,7 @@ export function onTeamChanged(ctx, st, teamId) {
318
379
  }
319
380
 
320
381
  export function newTeamsState() {
321
- return { rows: null, available: null, notRunning: false, loading: false, error: null, team: null, teamId: null, detailFor: null, detailLoading: false, detailError: null, busy: false };
382
+ return { rows: null, available: null, notRunning: false, loading: false, error: null, team: null, teamId: null, detailFor: null, detailRead: 0, detailLoading: false, detailError: null, busy: false };
322
383
  }
323
384
 
324
385
  /** Draw Teams in the main area: the list, or one team. */
@@ -328,12 +389,19 @@ export function renderTeams(main, ctx, st) {
328
389
  const { signal } = life;
329
390
  const { t } = ctx;
330
391
  const teamId = ctx.view.teamId;
331
- if (teamId && st.teamId !== teamId) { st.team = null; st.teamId = teamId; st.detailError = null; st.detailFor = null; }
392
+ if (teamId && st.teamId !== teamId) {
393
+ st.detailRead++;
394
+ st.detailLoading = false;
395
+ st.team = null;
396
+ st.teamId = teamId;
397
+ st.detailError = null;
398
+ st.detailFor = null;
399
+ }
332
400
  const row = teamId ? (st.rows || []).find((r) => r.id === teamId) : null;
333
401
  const title = teamId ? (st.team ? teamView(st.team).title : row?.title) || teamId : t('agentsStudio.rail.teams');
334
402
  setHTML(main, html`<section class="sx-place ax-place" aria-labelledby="ax-teams-title">
335
403
  <header class="sx-place-head">
336
- ${teamId ? html`<button type="button" class="sx-link" data-act="back">${ICONS.back}${t('agentsStudio.rail.teams')}</button>` : ''}
404
+ <button type="button" class="sx-link" data-act="back">${ICONS.back}${shellText(t, ctx.view.from === 'manage-teams' ? 'agentsStudio.teams.manage' : 'agentsStudio.rail.work')}</button>
337
405
  <h3 class="sx-place-title" id="ax-teams-title" tabindex="-1"${teamId ? html` data-autofocus` : ''}>${title}</h3>
338
406
  ${teamId ? html`<span class="sx-mono sx-dim">${teamId}</span>` : html`<p class="sx-place-sub">${t('agentsStudio.teams.sub')}</p>`}
339
407
  <span class="sx-spacer"></span>
@@ -349,36 +417,65 @@ export function renderTeams(main, ctx, st) {
349
417
  if (st.rows === null && !st.loading && !st.error) reload();
350
418
  else if (teamId && st.detailFor !== teamId && !st.detailLoading) loadTeam(ctx, st, teamId).then(() => { if (ctx.view.place === 'teams') ctx.render({ keepFocus: true }); });
351
419
 
352
- const decide = async (which) => {
420
+ const gen = ctx.gen();
421
+ const afterWrite = () => {
422
+ if (!ctx.alive(gen)) return;
423
+ ctx.refreshWork?.();
424
+ return reload();
425
+ };
426
+
427
+ /**
428
+ * Land, or Land without tests (`untested`: the owner's own decision, the only request with the override). The
429
+ * question shows what will move and the request carries exactly those values. When the server answers that they
430
+ * no longer hold, nothing was landed and nothing is sent again by itself: the question comes back with the fresh
431
+ * values (or, when they offer nothing any more, with why), for the owner to confirm again or cancel.
432
+ */
433
+ const land = async (untested) => {
434
+ const view = teamView(st.team);
435
+ if (!(untested ? view.canLandUntested : view.canLand)) return;
436
+ const name = view.title || view.id;
437
+ const branch = view.landing.targetBranch || view.baseBranch || t('agentsStudio.teams.yourBranch');
438
+ const failedOn = view.integration.tests?.passed === false ? view.integration.tests.commit : '';
439
+ let done = null;
440
+ try {
441
+ done = await landWithPreview({
442
+ preview: view.landPreview,
443
+ untested,
444
+ ask: ({ preview, offer, stale }) => askLanding(ctx, landQuestionOf({ preview, offer, stale, name, branch, failedOn })),
445
+ send: (body) => { st.busy = true; ctx.render({ keepFocus: true }); return ctx.api.landTeam(view.id, body); },
446
+ });
447
+ if (done.outcome === 'landed') ctx.toast(t('agentsStudio.teams.landedToast'));
448
+ } catch (error) {
449
+ ctx.toast(t('agentsStudio.teams.landFailed', { error: errorText(t, error) }), 'error');
450
+ }
451
+ // Cancelled before anything was asked of the server: the page is as it was.
452
+ if (done && done.outcome !== 'landed' && !done.stale) return;
453
+ st.busy = false;
454
+ await afterWrite();
455
+ };
456
+
457
+ const discard = async () => {
353
458
  const view = teamView(st.team);
354
- const land = which === 'land';
355
459
  const answer = await ctx.ask({
356
- title: t(land ? 'agentsStudio.teams.landTitle' : 'agentsStudio.teams.discardTitle', { name: view.title || view.id }),
357
- lines: land
358
- ? [t('agentsStudio.teams.landAsk', { branch: view.landing.targetBranch || view.baseBranch || t('agentsStudio.teams.yourBranch') }), t('agentsStudio.teams.landRefuses')]
359
- : [t('agentsStudio.teams.discardAsk'), t('agentsStudio.teams.discardKeeps')],
460
+ title: t('agentsStudio.teams.discardTitle', { name: view.title || view.id }),
461
+ lines: [t('agentsStudio.teams.discardAsk'), t('agentsStudio.teams.discardKeeps')],
360
462
  className: 'ax-dlg',
361
- buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t(land ? 'agentsStudio.teams.land' : 'agentsStudio.teams.discard'), kind: land ? 'primary' : 'danger' }],
463
+ buttons: [{ id: 'cancel', label: t('agentsStudio.action.cancel') }, { id: 'go', label: t('agentsStudio.teams.discard'), kind: 'danger' }],
362
464
  focus: 'cancel',
363
465
  });
364
466
  if (answer !== 'go') return;
365
467
  st.busy = true;
366
468
  ctx.render({ keepFocus: true });
367
469
  try {
368
- if (land) {
369
- await ctx.api.landTeam(view.id, {});
370
- ctx.toast(t('agentsStudio.teams.landedToast'));
371
- } else {
372
- const out = await ctx.api.discardTeam(view.id, {});
373
- const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
374
- // What holds work is kept: say so, and where it can be deleted.
375
- ctx.toast(kept ? ctx.tp('agentsStudio.teams.discardKeptToast', kept) : t('agentsStudio.teams.discardedToast'));
376
- }
470
+ const out = await ctx.api.discardTeam(view.id, {});
471
+ const kept = Array.isArray(out?.kept) ? out.kept.length : 0;
472
+ // What holds work is kept: say so, and where it can be deleted.
473
+ ctx.toast(kept ? ctx.tp('agentsStudio.teams.discardKeptToast', kept) : t('agentsStudio.teams.discardedToast'));
377
474
  } catch (error) {
378
- ctx.toast(t(land ? 'agentsStudio.teams.landFailed' : 'agentsStudio.teams.discardFailed', { error: errorText(t, error) }), 'error');
475
+ ctx.toast(t('agentsStudio.teams.discardFailed', { error: errorText(t, error) }), 'error');
379
476
  }
380
477
  st.busy = false;
381
- await reload();
478
+ await afterWrite();
382
479
  };
383
480
 
384
481
  /** The things a question lists: at most ten, then how many more. */
@@ -427,7 +524,7 @@ export function renderTeams(main, ctx, st) {
427
524
  st.rows = (st.rows || []).filter((row) => row.id !== view.id);
428
525
  st.team = null;
429
526
  ctx.go({ type: 'back' });
430
- await reload();
527
+ await afterWrite();
431
528
  return;
432
529
  }
433
530
  } catch (error) {
@@ -435,7 +532,7 @@ export function renderTeams(main, ctx, st) {
435
532
  ctx.toast(t(key, { error: errorText(t, error) }), 'error');
436
533
  }
437
534
  st.busy = false;
438
- await reload();
535
+ await afterWrite();
439
536
  };
440
537
 
441
538
  /** A team that left the list: drawn without it now (the reload confirms), and its detail closed when it was open. */
@@ -469,7 +566,7 @@ export function renderTeams(main, ctx, st) {
469
566
  ctx.toast(t('agentsStudio.teams.cleanupMergedFailed', { error: errorText(t, error) }), 'error');
470
567
  }
471
568
  st.busy = false;
472
- await reload();
569
+ await afterWrite();
473
570
  };
474
571
 
475
572
  /**
@@ -502,7 +599,7 @@ export function renderTeams(main, ctx, st) {
502
599
  ctx.toast(t('agentsStudio.teams.discardFailed', { error: errorText(t, error) }), 'error');
503
600
  }
504
601
  st.busy = false;
505
- await reload();
602
+ await afterWrite();
506
603
  };
507
604
 
508
605
  /** Clear finished: every finished team with nothing left goes; the rest stay, and the toast says how many. */
@@ -529,7 +626,7 @@ export function renderTeams(main, ctx, st) {
529
626
  ctx.toast(t('agentsStudio.teams.clearFailed', { error: errorText(t, error) }), 'error');
530
627
  }
531
628
  st.busy = false;
532
- await reload();
629
+ await afterWrite();
533
630
  };
534
631
 
535
632
  main.addEventListener('click', (e) => {
@@ -540,7 +637,8 @@ export function renderTeams(main, ctx, st) {
540
637
  else if (act === 'back') ctx.go({ type: 'back' });
541
638
  else if (act === 'refresh' || act === 'retry') { st.error = null; st.detailError = null; reload(); }
542
639
  else if (act === 'focus-run') ctx.focusRun(el.dataset.run);
543
- else if (act === 'land' || act === 'discard') decide(act);
640
+ else if (act === 'land' || act === 'land-untested') land(act === 'land-untested');
641
+ else if (act === 'discard') discard();
544
642
  else if (act === 'cleanup' || act === 'force-discard' || act === 'remove') finish(act);
545
643
  else if (act === 'clear-finished') clearFinished();
546
644
  else if (act === 'quick') {
@@ -14,6 +14,14 @@
14
14
  // (lib/teams/api.js `teamDetail`) is read with its parts put back inside the team (ax-api.js `teamDetailOf`): claims
15
15
  // by `glob`, the landing's `landed` / `refused` records, a slice's `lastReport`, an event's `event`, a message's
16
16
  // `fromSlice`, the team's `attention`.
17
+ //
18
+ // A landing is bound to what the owner was shown. The server says what a landing sent now would move
19
+ // (`landing.preview`: the target branch and its tip, the integration head, whether the tests passed on that head,
20
+ // `canLand`, and the refusal's `code` / `reason` when it cannot); the page offers Land only while `canLand`, sends
21
+ // the three values it displayed with the request, and a LANDING_PREVIEW_STALE answer (the branch or the work changed
22
+ // meanwhile) lands nothing and is asked about again with the fresh preview (`landWithPreview`). Landing work no test
23
+ // verified is a second, separate question, and the only request that carries `allowUntested`. A server without the
24
+ // preview is the page as it was: Land for a ready team, an empty request.
17
25
  // No DOM and no imports.
18
26
 
19
27
  export const TEAM_STATES = Object.freeze(['creating', 'planned', 'running', 'integrating', 'ready', 'landing', 'merged', 'completed', 'failed', 'cancelled']);
@@ -243,6 +251,200 @@ export function integrationOf(team) {
243
251
  };
244
252
  }
245
253
 
254
+ /** The answer of a landing whose bound values no longer hold: nothing moved, and `preview` is what holds now. */
255
+ export const LANDING_PREVIEW_STALE = 'LANDING_PREVIEW_STALE';
256
+ /**
257
+ * Why Land is not offered, as the page says it (`agentsStudio.teams.landWhy.*`): the refusal codes of a landing
258
+ * (lib/teams/landing.js), TESTS_NOT_PASSED in two (a team with a test command, and one without: NO_TEST_COMMAND), and
259
+ * `other` for a refusal that came without a sentence. Any other code is said with the server's own `reason`.
260
+ */
261
+ export const LAND_WHY = Object.freeze(['TESTS_NOT_PASSED', 'NO_TEST_COMMAND', 'NOT_FAST_FORWARD', 'NOTHING_TO_LAND', 'TEAM_NOT_READY', 'TARGET_NOT_FOUND', 'other']);
262
+ const LAND_WHY_CODES = new Set(['NOT_FAST_FORWARD', 'NOTHING_TO_LAND', 'TEAM_NOT_READY', 'TARGET_NOT_FOUND']);
263
+
264
+ /**
265
+ * The English of the landing's strings (`agentsStudio.teams.land*` in i18n/en.json must equal it; the contract test
266
+ * compares). The page says a string through its translator and falls back to this one, so the question that moves
267
+ * the owner's branch never shows a key: `public/` reloads at any time, a locale file an older build left does not.
268
+ */
269
+ export const LAND_COPY = Object.freeze({
270
+ 'agentsStudio.teams.landTip': 'Current tip',
271
+ 'agentsStudio.teams.landTipMissing': 'Branch not found',
272
+ 'agentsStudio.teams.landHead': 'Integration head',
273
+ 'agentsStudio.teams.landTests': 'Tests on this head',
274
+ 'agentsStudio.teams.landTestsNotPassed': 'Not passed',
275
+ 'agentsStudio.teams.landNoTestCommand': 'No test command',
276
+ 'agentsStudio.teams.landStale': 'The branch or the team\'s work changed since this dialog opened. Nothing was landed.',
277
+ 'agentsStudio.teams.landStaleAgain': 'These are the values now. Confirm again to land them, or cancel.',
278
+ 'agentsStudio.teams.landUntested': 'Land without tests',
279
+ 'agentsStudio.teams.landUntestedHelp': 'Your own decision: land work that no test verified',
280
+ 'agentsStudio.teams.landUntestedTitle': 'Land "{name}" without tests?',
281
+ 'agentsStudio.teams.landUntestedAsk': '{branch} will be moved to the team\'s integrated result.',
282
+ 'agentsStudio.teams.landUntestedWarn': 'This work was not verified by tests: no test run passed on this head. Landing it is your own decision.',
283
+ 'agentsStudio.teams.landWhy.TESTS_NOT_PASSED': 'Land is not offered: the tests have not passed on the integration head.',
284
+ 'agentsStudio.teams.landWhy.NO_TEST_COMMAND': 'Land is not offered: this team has no test command, so no test verified its work.',
285
+ 'agentsStudio.teams.landWhy.NOT_FAST_FORWARD': 'Land is not offered: {branch} has commits the team\'s work lacks, so it cannot be moved forward to it.',
286
+ 'agentsStudio.teams.landWhy.NOTHING_TO_LAND': 'Nothing to land: {branch} already has everything the team integrated.',
287
+ 'agentsStudio.teams.landWhy.TEAM_NOT_READY': 'Land is not offered yet: not every slice is joined on the integration branch.',
288
+ 'agentsStudio.teams.landWhy.TARGET_NOT_FOUND': 'Land is not offered: the branch {branch} is not in this project.',
289
+ 'agentsStudio.teams.landWhy.other': 'Land is not offered for this team right now.',
290
+ });
291
+
292
+ /** A string of LAND_COPY with its values put in ('' for a key it does not have). */
293
+ export function landCopy(key, params = null) {
294
+ const said = typeof LAND_COPY[key] === 'string' ? LAND_COPY[key] : '';
295
+ return said.replace(/\{(\w+)\}/g, (whole, name) => (params && params[name] !== undefined && params[name] !== null ? String(params[name]) : whole));
296
+ }
297
+
298
+ /** A commit id as the page shows it: its first nine characters. */
299
+ export const shortHash = (commit) => String(commit || '').slice(0, 9);
300
+
301
+ /**
302
+ * What a landing sent now would move (`landing.preview` of a team's answer, or the `preview` of a stale refusal), or
303
+ * null when the answer has none (a server from before it). A commit id is kept whole or not at all: it is sent back
304
+ * as it came. `canLand` holds only with a target branch and both heads, because those are what the request binds.
305
+ */
306
+ export function landingPreviewOf(raw) {
307
+ if (!isObject(raw)) return null;
308
+ const whole = (value, max) => (typeof value === 'string' && value && value.length <= max ? value : null);
309
+ const targetBranch = whole(raw.targetBranch, 300);
310
+ const targetHead = whole(raw.targetHead, 80);
311
+ const integrationHead = whole(raw.integrationHead, 80);
312
+ return {
313
+ targetBranch: targetBranch || '',
314
+ targetHead,
315
+ integrationHead,
316
+ testCommand: (Array.isArray(raw.testCommand) ? raw.testCommand.filter((part) => typeof part === 'string').join(' ').slice(0, 600) : text(raw.testCommand, 600)) || null,
317
+ testsPassedOnHead: raw.testsPassedOnHead === true,
318
+ canLand: raw.canLand === true && !!targetBranch && !!targetHead && !!integrationHead,
319
+ code: text(raw.code, 80) || null,
320
+ reason: text(raw.reason, 600),
321
+ };
322
+ }
323
+
324
+ /**
325
+ * Why a landing with this preview is not offered, or null (no preview, or it can land): the refusal's `code`, the
326
+ * page's sentence for it (`key` with its `params`) or, for a code the page has no sentence for, the server's own
327
+ * (`text`).
328
+ */
329
+ export function landWhyOf(preview) {
330
+ if (!preview || preview.canLand) return null;
331
+ const code = preview.code;
332
+ const word = code === 'TESTS_NOT_PASSED' ? (preview.testCommand ? 'TESTS_NOT_PASSED' : 'NO_TEST_COMMAND')
333
+ : LAND_WHY_CODES.has(code) ? code
334
+ : preview.reason ? null : 'other';
335
+ return {
336
+ code,
337
+ key: word ? `agentsStudio.teams.landWhy.${word}` : null,
338
+ params: { branch: preview.targetBranch },
339
+ text: word ? '' : preview.reason,
340
+ // A team still under way, or one with nothing left to land, is the usual course; the rest is in the owner's way.
341
+ tone: code === 'TEAM_NOT_READY' || code === 'NOTHING_TO_LAND' ? 'info' : 'warn',
342
+ };
343
+ }
344
+
345
+ /**
346
+ * What the owner may confirm with this preview: 'land' (it can land as it is), 'untested' (only when asked for:
347
+ * the one refusal is TESTS_NOT_PASSED and there is a branch and both heads to bind), or null (nothing).
348
+ */
349
+ export function landOfferOf(preview, { untested = false } = {}) {
350
+ if (!preview) return null;
351
+ if (preview.canLand) return 'land';
352
+ if (untested && preview.code === 'TESTS_NOT_PASSED' && preview.targetBranch && preview.targetHead && preview.integrationHead) return 'untested';
353
+ return null;
354
+ }
355
+
356
+ /**
357
+ * The body of the land request for a preview: the branch and the two heads the owner was shown, and `allowUntested`
358
+ * only for the untested offer (never for a preview that can land as it is). null: nothing may be sent.
359
+ */
360
+ export function landRequest(preview, { untested = false } = {}) {
361
+ const offer = landOfferOf(preview, { untested });
362
+ if (!offer) return null;
363
+ const body = { targetBranch: preview.targetBranch, expectedTargetHead: preview.targetHead, expectedIntegrationHead: preview.integrationHead };
364
+ if (offer === 'untested') body.allowUntested = true;
365
+ return body;
366
+ }
367
+
368
+ /** Was this landing refused because what it was bound to no longer holds? */
369
+ export const isStaleLanding = (error) => error?.code === LANDING_PREVIEW_STALE;
370
+ /** The fresh preview a stale refusal carries (`preview` in the refusal's body), or null. */
371
+ export const stalePreviewOf = (error) => (isStaleLanding(error) ? landingPreviewOf(error?.body?.preview ?? error?.preview) : null);
372
+
373
+ /**
374
+ * The question of a landing, as the dialog draws it: its title, the lines before the facts, the facts (the target
375
+ * branch, its tip, the integration head, the tests on that head) and the lines after, and the button that confirms
376
+ * (none when nothing may be confirmed). The facts are the preview's own values: the same ones `landRequest` sends.
377
+ * @param {object} o
378
+ * @param {object|null} o.preview landingPreviewOf(...), or null on a server without one
379
+ * @param {'land'|'untested'|null} o.offer
380
+ * @param {boolean} [o.stale] a landing was just refused as stale: this preview is the fresh one
381
+ * @param {string} [o.name] the team's title
382
+ * @param {string} [o.branch] the branch to name when there is no preview
383
+ * @param {string} [o.failedOn] the commit the last test run failed on (the integration's record), if it failed
384
+ */
385
+ export function landQuestionOf({ preview = null, offer = null, stale = false, name = '', branch = '', failedOn = '' } = {}) {
386
+ // Every key is written out whole: the contract test reads the keys the Studio says from its modules' text.
387
+ const untested = offer === 'untested';
388
+ const line = (id, key, { params = null, text: said = '', tone = null } = {}) => ({ id, key, params, text: said, tone });
389
+ const before = [];
390
+ if (stale) before.push(line('stale', 'agentsStudio.teams.landStale', { tone: 'warn' }));
391
+ if (stale && offer) before.push(line('again', 'agentsStudio.teams.landStaleAgain'));
392
+ if (offer) before.push(line('ask', untested ? 'agentsStudio.teams.landUntestedAsk' : 'agentsStudio.teams.landAsk', { params: { branch: preview?.targetBranch || branch } }));
393
+ const fact = (id, label, value, { shown = value, missing = null, chip = null } = {}) => ({ id, label, value, shown, missing, chip });
394
+ const facts = !preview ? [] : [
395
+ fact('target', 'agentsStudio.teams.target', preview.targetBranch),
396
+ fact('tip', 'agentsStudio.teams.landTip', preview.targetHead, { shown: shortHash(preview.targetHead), missing: 'agentsStudio.teams.landTipMissing' }),
397
+ fact('head', 'agentsStudio.teams.landHead', preview.integrationHead, { shown: shortHash(preview.integrationHead) }),
398
+ fact('tests', 'agentsStudio.teams.landTests', null, {
399
+ shown: '',
400
+ chip: preview.testsPassedOnHead ? { key: 'agentsStudio.teams.testsPassed', tone: 'ok' }
401
+ : !preview.testCommand ? { key: 'agentsStudio.teams.landNoTestCommand', tone: 'warn' }
402
+ : failedOn && failedOn === preview.integrationHead ? { key: 'agentsStudio.teams.testsFailed', tone: 'err' } : { key: 'agentsStudio.teams.landTestsNotPassed', tone: 'warn' },
403
+ }),
404
+ ];
405
+ const after = [];
406
+ if (untested) after.push(line('untested', 'agentsStudio.teams.landUntestedWarn', { tone: 'warn' }));
407
+ else if (offer) after.push(line('refuses', 'agentsStudio.teams.landRefuses'));
408
+ else {
409
+ const why = landWhyOf(preview);
410
+ if (why) after.push(line('why', why.key, { params: why.params, text: why.text, tone: why.tone === 'warn' ? 'warn' : null }));
411
+ }
412
+ return {
413
+ title: { key: untested ? 'agentsStudio.teams.landUntestedTitle' : 'agentsStudio.teams.landTitle', params: { name } },
414
+ before, facts, after,
415
+ confirm: untested ? { key: 'agentsStudio.teams.landUntested', kind: 'danger' } : offer ? { key: 'agentsStudio.teams.land', kind: 'primary' } : null,
416
+ };
417
+ }
418
+
419
+ /**
420
+ * One landing, from its question to its answer. `ask({ preview, offer, stale })` puts the question to the owner and
421
+ * answers 'go' or anything else; `send(body)` posts the request. The request carries exactly the preview that was
422
+ * confirmed. A
423
+ * stale refusal lands nothing and is never sent again by itself: the question is asked again with the fresh preview
424
+ * (which may offer nothing any more: then it only says why). Any other refusal is thrown.
425
+ * @returns {Promise<{ outcome: 'landed'|'cancelled'|'blocked', preview: object|null, stale: boolean, body?: object, out?: object }>}
426
+ */
427
+ export async function landWithPreview({ preview = null, untested = false, ask, send }) {
428
+ let shown = preview;
429
+ let stale = false;
430
+ for (;;) {
431
+ // A server without the preview: Land as it was (never the untested question, which needs values to bind).
432
+ const offer = shown ? landOfferOf(shown, { untested }) : (untested ? null : 'land');
433
+ const answer = await ask({ preview: shown, offer, stale });
434
+ if (!offer) return { outcome: 'blocked', preview: shown, stale };
435
+ if (answer !== 'go') return { outcome: 'cancelled', preview: shown, stale };
436
+ const body = shown ? landRequest(shown, { untested }) : {};
437
+ try {
438
+ return { outcome: 'landed', preview: shown, stale, body, out: await send(body) };
439
+ } catch (error) {
440
+ const fresh = stalePreviewOf(error);
441
+ if (!fresh) throw error;
442
+ shown = fresh;
443
+ stale = true;
444
+ }
445
+ }
446
+ }
447
+
246
448
  /** The landing: whether the team's result reached the owner's branch, and how. */
247
449
  export function landingOf(team) {
248
450
  const l = isObject(team?.landing) ? team.landing : {};
@@ -258,6 +460,8 @@ export function landingOf(team) {
258
460
  commit: text(first(str(l.commit), str(l.head), str(landed.mergeCommit), str(landed.to)), 80),
259
461
  at: text(first(str(l.at), str(l.landedAt), str(l.finishedAt), str(landed.at)), 40),
260
462
  error: text(first(str(l.error), str(l.reason), str(refused.message)), 600),
463
+ // What a landing sent now would move (null: a server from before the preview).
464
+ preview: landingPreviewOf(l.preview),
261
465
  };
262
466
  }
263
467
 
@@ -302,6 +506,10 @@ export function teamView(team) {
302
506
  // A finished team: the server's look at git and the disk (null from a server without it: nothing is offered).
303
507
  const removal = row.finished ? removalOf(team) : null;
304
508
  const leftWith = (next) => !!removal && !removal.removable && removal.next === next && removal.left.length > 0;
509
+ const landing = landingOf(team);
510
+ const preview = landing.preview;
511
+ // A team that can still be landed from here: not read-only, not over, not on its base branch already.
512
+ const landable = !readOnly && !row.finished && !SETTLED_TEAM.has(row.status) && !row.onTarget;
305
513
  return {
306
514
  ...row,
307
515
  slices,
@@ -316,12 +524,19 @@ export function teamView(team) {
316
524
  canRemove: row.finished && removal?.removable === true,
317
525
  baseBranch: text(first(team?.baseBranch, team?.plan?.baseBranch), 300),
318
526
  baseCommit: text(first(team?.baseCommit, team?.plan?.baseCommit), 80),
319
- integration, landing: landingOf(team), claims: claimRows(team), feed: feedItems(team),
527
+ integration, landing, claims: claimRows(team), feed: feedItems(team),
320
528
  // What the scheduler waits on the owner for (status `needs_attention`): its sentence, shown as text.
321
529
  attention: text(isObject(team?.attention) ? first(team.attention.message, team.attention.code) : team?.attention, 600),
322
- // Landing is offered once the integration branch is ready (the server refuses anything else and says why), and
323
- // never for a team whose work is on its base branch already: there is nothing left to land.
324
- canLand: team?.plan?.readOnly !== true && row.status === 'ready' && !row.onTarget,
530
+ // Land follows the server's preview: offered exactly while a landing sent now would be accepted. Without a
531
+ // preview (an older server) it is offered once the team is ready, as before, and the server says why not. Never
532
+ // for a team whose work is on its base branch already: there is nothing left to land.
533
+ canLand: preview ? landable && preview.canLand : !readOnly && row.status === 'ready' && !row.onTarget,
534
+ // The preview of a team that can still be landed from here (null: none, or the team is over or on its branch).
535
+ landPreview: preview && landable ? preview : null,
536
+ // Why Land is not offered, in the page's words (null: it is offered, there is no preview, or the team is over).
537
+ landWhy: preview && landable ? landWhyOf(preview) : null,
538
+ // The tests are all that is in the way: landing untested work is offered apart, as the owner's own decision.
539
+ canLandUntested: !!preview && landable && landOfferOf(preview, { untested: true }) === 'untested',
325
540
  // A team that reached the owner's branch, or is on its way there, is not thrown away from here; neither is one
326
541
  // whose work is on its base branch already (a discard would record its landed work as given up).
327
542
  canDiscard: !!row.id && !SETTLED_TEAM.has(row.status) && team?.removed !== true && !row.onTarget,
@@ -14,6 +14,7 @@ import { dropdownHTML } from '../../cc-dropdown.js';
14
14
  import { agentIcon, toneOf, AX_ICONS } from './ax-icons.js';
15
15
  import { standingOf, scopeLabel, authorKind } from './ax-library.js';
16
16
  import { diffRows, hunksOf, privilegeChanges, privilegeSummary, diffSize } from './ax-diff.js';
17
+ import { WORK_COPY } from './ax-work.js';
17
18
 
18
19
  /** The words the pure modules take (ax-diff.js valueText): the page's strings for values. */
19
20
  export function wordsOf(t, { projects = [], profiles = [] } = {}) {
@@ -30,6 +31,36 @@ export function wordsOf(t, { projects = [], profiles = [] } = {}) {
30
31
  };
31
32
  }
32
33
 
34
+ /** Navigation within Agents. The Library and definition reviews share the same rail entry. */
35
+ export function agentSections(ctx) {
36
+ const sections = [['library', 'agentsStudio.rail.library', ctx.counts.total]];
37
+ if (ctx.caps.has('reviews')) sections.push(['review', 'agentsStudio.rail.review', ctx.counts.review]);
38
+ return html`<nav class="sx-place-head" aria-label="${ctx.t('agentsStudio.rail.agents')}"><span class="sx-seg">
39
+ ${sections.map(([place, label, count]) => html`<button type="button" id="ax-section-${place}" data-act="agents-section" data-place="${place}" aria-pressed="${String(ctx.view.place === place)}">${ctx.t(label)} · ${count}</button>`)}
40
+ </span></nav>`;
41
+ }
42
+
43
+ /**
44
+ * The shell's own English for the strings it added with the Work view (rail, Manage teams). A page loads its locale
45
+ * file once, when it opens; the Studio's code loads when the Studio opens. A page opened before an update therefore
46
+ * runs the new Studio with the old locale file, and these strings must not show their keys there.
47
+ */
48
+ export const SHELL_COPY = Object.freeze({
49
+ 'agentsStudio.rail.work': 'Work',
50
+ 'agentsStudio.rail.agents': 'Agents',
51
+ 'agentsStudio.rail.taskStatus': 'Task status',
52
+ 'agentsStudio.teams.manage': 'Manage teams',
53
+ });
54
+
55
+ /** A shell string: the translator's, else the module's own English (SHELL_COPY, then the Work list's), never a key. */
56
+ export function shellText(t, key, params) {
57
+ const said = t(key, params);
58
+ if (said !== key) return said;
59
+ const own = SHELL_COPY[key] ?? WORK_COPY[key];
60
+ if (typeof own !== 'string') return said;
61
+ return params ? own.replace(/\{(\w+)\}/g, (_, name) => String(params[name] ?? '')) : own;
62
+ }
63
+
33
64
  /** A word of a family, or the value as written when the family has no word for it (a state from a newer server). */
34
65
  export function wordOr(t, family, value) {
35
66
  const key = `${family}.${value}`;