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
@@ -0,0 +1,74 @@
1
+ .ax .ax-work-scroll {
2
+ container-type: inline-size;
3
+ padding: 12px 16px 24px;
4
+ overflow-wrap: anywhere;
5
+ }
6
+ .ax .ax-work-grid {
7
+ display: grid;
8
+ grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.25fr) minmax(0, .65fr) minmax(0, .8fr);
9
+ align-items: center;
10
+ gap: 12px;
11
+ padding: 8px 12px;
12
+ }
13
+ .ax .ax-work-cols, .ax .ax-work-group small, .ax .ax-work-option small {
14
+ color: var(--t-secondary);
15
+ font-size: var(--fs-xs);
16
+ font-weight: 400;
17
+ }
18
+ .ax .ax-work-group { margin-block: 12px; }
19
+ .ax .ax-work-group h4 { margin-block-end: 6px; }
20
+ .ax .ax-work-group h4::before {
21
+ display: inline-block;
22
+ content: '';
23
+ inline-size: 6px;
24
+ block-size: 6px;
25
+ margin-inline-end: 8px;
26
+ border-radius: 50%;
27
+ vertical-align: middle;
28
+ background: var(--sx-info);
29
+ }
30
+ .ax #ax-work-needs-you h4::before { background: var(--sx-warn); }
31
+ .ax #ax-work-active h4::before { background: var(--sx-focus); }
32
+ .ax #ax-work-finished h4::before { background: var(--sx-ok); }
33
+ .ax #ax-work-needs-you li:first-child { border-inline-start: 2px solid var(--sx-warn); }
34
+ .ax .ax-work-group ul {
35
+ margin: 0;
36
+ padding: 0;
37
+ list-style: none;
38
+ background: var(--s-subtle);
39
+ border: 1px solid var(--b-light);
40
+ border-radius: var(--r-md);
41
+ }
42
+ .ax .ax-work-item + .ax-work-item { border-block-start: 1px solid var(--b-light); }
43
+ .ax .ax-work-item:focus-within { background: var(--s-light); }
44
+ .ax .ax-work-title {
45
+ color: var(--t-bright);
46
+ text-align: start;
47
+ font-weight: 600;
48
+ justify-self: start;
49
+ }
50
+ .ax .ax-work-grid button { white-space: normal; overflow-wrap: anywhere; height: auto; min-height: 28px; }
51
+ .ax .ax-work-grid > .sx-btn { justify-self: end; }
52
+ .ax .ax-work-who small, .ax .ax-work-option small { display: block; }
53
+ .ax .ax-work-answer {
54
+ display: grid;
55
+ gap: 12px;
56
+ padding: 12px;
57
+ border-block-start: 1px solid var(--b-light);
58
+ }
59
+ .ax .ax-work-answer legend, .ax .ax-work-answer p { margin: 0 0 4px; }
60
+ .ax .ax-work-option { display: flex; align-items: baseline; gap: 8px; }
61
+ .ax .ax-work-custom { display: grid; gap: 4px; color: var(--t-secondary); }
62
+ .ax .ax-work-answer .sx-btn { justify-self: start; }
63
+ .ax .ax-work-scroll :is(button, input):focus-visible, .ax .ax-work-scroll:focus-visible {
64
+ outline: 2px solid var(--sx-focus);
65
+ outline-offset: -2px;
66
+ }
67
+ @container (max-width: 620px) {
68
+ .ax .ax-work-cols { display: none; }
69
+ .ax .ax-work-item .ax-work-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
70
+ }
71
+ @container (max-width: 360px) {
72
+ .ax .ax-work-item .ax-work-grid { grid-template-columns: minmax(0, 1fr); gap: 4px; }
73
+ .ax .ax-work-grid > .sx-btn { justify-self: start; }
74
+ }
@@ -0,0 +1,300 @@
1
+ import { keyOf } from './ax-views.js';
2
+ import { isTerminal } from './ax-runs.js';
3
+ import { teamDetailOf } from './ax-api.js';
4
+
5
+ const prefix = 'agentsStudio.work.';
6
+ export const WORK_COPY = Object.freeze({
7
+ 'agentsStudio.work.title': 'Work',
8
+ 'agentsStudio.work.needsYou': 'Needs you',
9
+ 'agentsStudio.work.active': 'Active',
10
+ 'agentsStudio.work.inReview': 'In review',
11
+ 'agentsStudio.work.finished': 'Finished',
12
+ 'agentsStudio.work.task': 'Task',
13
+ 'agentsStudio.work.progress': 'Progress',
14
+ 'agentsStudio.work.who': 'Project / workers',
15
+ 'agentsStudio.work.oneWorker': '1 worker',
16
+ 'agentsStudio.work.teamOf': 'Team of {count}',
17
+ 'agentsStudio.work.noWorkers': 'No workers',
18
+ 'agentsStudio.work.noProject': 'Project unavailable',
19
+ 'agentsStudio.work.untitled': 'Untitled task',
20
+ 'agentsStudio.work.answer': 'Answer',
21
+ 'agentsStudio.work.openTask': 'Open task',
22
+ 'agentsStudio.work.viewProgress': 'View progress',
23
+ 'agentsStudio.work.reviewLand': 'Review and land on {branch}',
24
+ 'agentsStudio.work.readReport': 'Read report',
25
+ 'agentsStudio.work.viewOutcome': 'View outcome',
26
+ 'agentsStudio.work.waiting': 'Waiting for your answer.',
27
+ 'agentsStudio.work.waitingOn': 'Waiting for your answer on {subject}.',
28
+ 'agentsStudio.work.permission': 'A worker needs your permission.',
29
+ 'agentsStudio.work.decision': 'A worker is waiting for your decision.',
30
+ 'agentsStudio.work.failedPart': '{part} could not finish.',
31
+ 'agentsStudio.work.failedTests': '{part} tests failed.',
32
+ 'agentsStudio.work.failedTestsSafe': '{part} tests failed. {other} changes are safe.',
33
+ 'agentsStudio.work.failedTask': 'The worker could not finish.',
34
+ 'agentsStudio.work.teamFailed': 'The team could not finish.',
35
+ 'agentsStudio.work.noCommand': '{count} parts joined. No test command set.',
36
+ 'agentsStudio.work.noCommandOne': '1 part joined. No test command set.',
37
+ 'agentsStudio.work.noCommandUnknown': 'No test command set.',
38
+ 'agentsStudio.work.noPass': 'Current commit has no passing check.',
39
+ 'agentsStudio.work.branchMissing': 'The destination branch {branch} is missing.',
40
+ 'agentsStudio.work.branchMoved': 'The destination branch {branch} has moved.',
41
+ 'agentsStudio.work.landingBlocked': 'The team cannot land its changes yet.',
42
+ 'agentsStudio.work.previewMissing': 'Landing checks are unavailable.',
43
+ 'agentsStudio.work.attention': 'The team needs your attention.',
44
+ 'agentsStudio.work.partial': '{arrived} reports arrived. {missing} reviewers returned none.',
45
+ 'agentsStudio.work.partialOneMissing': '{arrived} reports arrived. 1 reviewer returned none.',
46
+ 'agentsStudio.work.partialOneArrived': '1 report arrived. {missing} reviewers returned none.',
47
+ 'agentsStudio.work.partialOneEach': '1 report arrived. 1 reviewer returned none.',
48
+ 'agentsStudio.work.reportsUnknown': 'Review finished. Report availability is unconfirmed.',
49
+ 'agentsStudio.work.reportsReady': 'Review finished. All {count} reports available.',
50
+ 'agentsStudio.work.reportReady': 'Review finished. The report is available.',
51
+ 'agentsStudio.work.onBranch': 'Changes are on {branch}. Check the remaining work.',
52
+ 'agentsStudio.work.landedCheck': 'Changes landed. Check whether anything remains.',
53
+ 'agentsStudio.work.copies': 'Landed on {branch}. {count} working copies remain.',
54
+ 'agentsStudio.work.copy': 'Landed on {branch}. 1 working copy remains.',
55
+ 'agentsStudio.work.dirty': '{part} has {count} uncommitted files.',
56
+ 'agentsStudio.work.dirtyOne': '{part} has 1 uncommitted file.',
57
+ 'agentsStudio.work.landed': 'Changes landed and working copies were removed.',
58
+ 'agentsStudio.work.discarded': 'The task was discarded.',
59
+ 'agentsStudio.work.discardedCheck': 'The task was discarded. Check whether anything remains.',
60
+ 'agentsStudio.work.working': 'Work is in progress.',
61
+ 'agentsStudio.work.workingPart': '{part} is in progress.',
62
+ 'agentsStudio.work.workingJoined': '{count} parts joined. {part} in progress.',
63
+ 'agentsStudio.work.workingJoinedOne': '1 part joined. {part} in progress.',
64
+ 'agentsStudio.work.ready': 'Checks passed. Ready to land on {branch}.',
65
+ 'agentsStudio.work.queued': 'Waiting for a worker to start.',
66
+ 'agentsStudio.work.paused': 'Work is paused.',
67
+ 'agentsStudio.work.idle': 'The worker is waiting for more work.',
68
+ 'agentsStudio.work.stopped': 'Work stopped.',
69
+ 'agentsStudio.work.completed': 'Work finished.',
70
+ 'agentsStudio.work.reportKept': 'Work finished. The report is available.',
71
+ 'agentsStudio.work.loading': 'Loading tasks',
72
+ 'agentsStudio.work.empty': 'Nothing needs an answer or review',
73
+ 'agentsStudio.work.missingTeams': 'Team tasks are unavailable.',
74
+ 'agentsStudio.work.missingRuns': 'Worker tasks and questions are unavailable.',
75
+ 'agentsStudio.work.missingDetails': 'Some team details are unavailable.',
76
+ 'agentsStudio.work.offline': 'Connection lost. Reconnect to update tasks.',
77
+ 'agentsStudio.work.retry': 'Retry connection',
78
+ 'agentsStudio.work.refresh': 'Refresh tasks',
79
+ 'agentsStudio.work.capped': 'Showing the latest 500 worker records. Earlier tasks may be missing.',
80
+ 'agentsStudio.work.freeText': 'Your answer',
81
+ 'agentsStudio.work.custom': 'Another answer',
82
+ 'agentsStudio.work.yes': 'Yes',
83
+ 'agentsStudio.work.no': 'No',
84
+ 'agentsStudio.work.submit': 'Send answer',
85
+ 'agentsStudio.work.sent': 'Answer sent.',
86
+ 'agentsStudio.work.stale': 'This question was answered elsewhere or closed.',
87
+ 'agentsStudio.work.answerFailed': 'The answer could not be sent. Try again.',
88
+ 'agentsStudio.work.answerUnsupported': 'This server cannot accept an answer here.',
89
+ 'agentsStudio.work.required': 'Answer each required question.',
90
+ });
91
+
92
+ const groups = ['needs-you', 'active', 'in-review', 'finished'];
93
+ // Priority within Needs you. The request time breaks ties across teams and workers.
94
+ const rank = { question: 0, permission: 0, decision: 0, failed: 1, verification: 2, blocked: 2, partial: 3, housekeeping: 4 };
95
+ const text = value => typeof value === 'string' ? value.trim() : '';
96
+ const date = value => typeof value === 'number' ? value : Date.parse(value) || 0;
97
+ const terminal = run => run?.terminal === true || isTerminal(run?.state);
98
+ const memberTeam = run => run.team?.teamId || run.teamId;
99
+ const byCreated = (a, b) => date(a.createdAt) - date(b.createdAt);
100
+ const nameOf = part => part.title || part.id;
101
+ const joined = part => part.phase === 'integrated' || part.status === 'integrated';
102
+
103
+ function decision(group, state, reason, action, params = {}, at = null) {
104
+ return { group, state, reason: { key: prefix + reason, params }, primary: { action: action === 'answer' ? 'answer' : 'open', key: prefix + action }, at };
105
+ }
106
+ const needs = (state, reason, params, at, action = 'openTask') => decision('needs-you', state, reason, action, params, at);
107
+ const active = (reason, params) => decision('active', 'working', reason, 'viewProgress', params);
108
+ const review = (state, reason, action, params) => decision('in-review', state, reason, action, params);
109
+ const finished = reason => decision('finished', 'settled', reason, 'viewOutcome');
110
+
111
+ function waiting(runs, now) {
112
+ const requests = [];
113
+ for (const run of runs) {
114
+ if (terminal(run)) continue;
115
+ for (const p of run.pending || []) {
116
+ if (!p?.requestId || (p.expiresAt && date(p.expiresAt) && date(p.expiresAt) <= now)) continue;
117
+ requests.push({ run, p, createdAt: p.createdAt || run.createdAt });
118
+ }
119
+ }
120
+ const first = requests.sort(byCreated)[0];
121
+ if (first) {
122
+ const { run, p, createdAt } = first;
123
+ if (p.kind !== 'question') return needs('permission', 'permission', {}, createdAt);
124
+ const q = p.questions?.[0] || p.input?.questions?.[0] || Object.values(p.input?.requestedSchema?.properties || {})[0];
125
+ const subject = text(q?.header || q?.title || q?.question || q?.text).replace(/[.?!]+$/, '');
126
+ return { ...needs('question', subject ? 'waitingOn' : 'waiting', { subject }, createdAt, 'answer'),
127
+ question: { runId: run.runId, provider: run.provider, pending: p } };
128
+ }
129
+ const pending = runs.find(run => !terminal(run) && (run.state === 'awaiting_permission' || run.state === 'awaiting_route'
130
+ || run.turnState === 'needs_input' || (run.state === 'idle' && ['needs_input', 'blocked'].includes(run.outcome || run.lastResult?.status))));
131
+ return pending ? needs('decision', 'decision', {}, pending.turns?.at(-1)?.endedAt) : null;
132
+ }
133
+
134
+ function hasReport(run) {
135
+ const result = run?.lastResult || run?.turns?.at(-1)?.result;
136
+ const outcome = result?.status || run?.outcome;
137
+ const final = outcome === 'done' || (!outcome && run?.state === 'completed');
138
+ return final && !!(text(result?.summary || run?.summary) || result?.json != null || result?.files?.length);
139
+ }
140
+
141
+ function runDecision(run, now) {
142
+ const wait = waiting([run], now);
143
+ if (wait) return wait;
144
+ switch (run.state) {
145
+ case 'failed':
146
+ case 'interrupted': return needs('failed', 'failedTask', {}, run.finishedAt);
147
+ case 'stopped': return finished('stopped');
148
+ case 'completed': return finished(hasReport(run) ? 'reportKept' : 'completed');
149
+ case 'idle': return hasReport(run) ? finished('reportKept') : active('idle');
150
+ case 'queued': return active('queued');
151
+ case 'suspended': return active('paused');
152
+ default: return active('working');
153
+ }
154
+ }
155
+
156
+ // A closed read-only team has no per-part projection in the list. Count only
157
+ // identifiable final workers. Missing history cannot prove that a report never arrived.
158
+ function reports(team, parts, members, workers) {
159
+ const closed = team.status === 'completed';
160
+ if (!closed && !team.plan?.readOnly) return null;
161
+ let observations;
162
+ if (parts.length) {
163
+ observations = parts.map(part => {
164
+ const run = members.find(r => r.runId === part.runId) || part.run;
165
+ if (run && terminal(run)) return hasReport(run);
166
+ if (!part.runId && part.phase === 'failed') return false;
167
+ return undefined;
168
+ });
169
+ if (!closed && parts.some(p => !['failed', 'completed', 'cancelled'].includes(p.phase) && !terminal(p.run))) return null;
170
+ } else if (closed) {
171
+ const byPart = new Map();
172
+ for (const r of members) {
173
+ const id = r.team?.sliceId;
174
+ if (id) byPart.set(id, byPart.has(id) ? null : r);
175
+ }
176
+ observations = [...byPart.values()].map(r => r && terminal(r) ? hasReport(r) : undefined);
177
+ } else return null;
178
+ if (!workers || observations.length !== workers || observations.includes(undefined)) {
179
+ return closed ? review('report', 'reportsUnknown', 'readReport') : needs('partial', 'reportsUnknown', {}, team.attention?.at, 'readReport');
180
+ }
181
+ const arrived = observations.filter(Boolean).length;
182
+ const missing = workers - arrived;
183
+ if (!missing) return review('report', workers === 1 ? 'reportReady' : 'reportsReady', 'readReport', { count: workers });
184
+ const key = arrived === 1 ? (missing === 1 ? 'partialOneEach' : 'partialOneArrived') : (missing === 1 ? 'partialOneMissing' : 'partial');
185
+ return needs('partial', key, { arrived, missing }, team.attention?.at, 'readReport');
186
+ }
187
+
188
+ function landing(team, parts) {
189
+ const target = team.alreadyOnTarget;
190
+ const branch = target?.branch || team.landing?.landed?.targetBranch || team.baseBranch;
191
+ const dirty = target?.dirty?.find(item => item.files?.length);
192
+ if (dirty) {
193
+ const part = parts.find(p => p.id === dirty.sliceId);
194
+ // The scheduler returns at most 50 file names.
195
+ if (part && dirty.files.length < 50) return needs('housekeeping', dirty.files.length === 1 ? 'dirtyOne' : 'dirty', { part: nameOf(part), count: dirty.files.length });
196
+ }
197
+ if (team.removable || team.removal?.removable || team.landing?.cleanup?.complete || (target && team.left === 0)) return finished('landed');
198
+ const left = team.removal?.left || [];
199
+ const copies = left.filter(item => item.worktree).length;
200
+ if (branch && copies) return needs('housekeeping', copies === 1 ? 'copy' : 'copies', { branch, count: copies }, team.landing?.landed?.at);
201
+ return needs('housekeeping', branch ? 'onBranch' : 'landedCheck', { branch }, team.landing?.landed?.at);
202
+ }
203
+
204
+ function ready(team, parts) {
205
+ const p = team.landing?.preview;
206
+ if (!p) return needs('blocked', 'previewMissing');
207
+ const branch = p.targetBranch;
208
+ // Older previews checked the commit but not the command. Both are visible in the detail.
209
+ const checked = team.integration?.tests;
210
+ const differentCommand = checked && checked.command !== undefined && JSON.stringify(checked.command) !== JSON.stringify(p.testCommand);
211
+ if (p.canLand === true && p.testsPassedOnHead === true && p.testCommand && !differentCommand && branch) {
212
+ return review('ready', 'ready', 'reviewLand', { branch });
213
+ }
214
+ if (p.code === 'TEAM_NOT_READY') return active('working');
215
+ if (p.code === 'TESTS_NOT_PASSED' || p.code === 'NO_TEST_COMMAND' || p.canLand === true) {
216
+ const count = parts.filter(joined).length;
217
+ const reason = p.testCommand ? 'noPass' : count === 1 ? 'noCommandOne' : count ? 'noCommand' : 'noCommandUnknown';
218
+ const at = team.events?.findLast(e => e.event === 'team_ready')?.at;
219
+ return needs('verification', reason, { count }, at);
220
+ }
221
+ const reason = { NOT_FAST_FORWARD: 'branchMoved', TARGET_NOT_FOUND: 'branchMissing', NOTHING_TO_LAND: 'onBranch' }[p.code];
222
+ return needs('blocked', (branch && reason) || 'landingBlocked', { branch });
223
+ }
224
+
225
+ function teamDecision(team, parts, members, workers, now) {
226
+ const wait = waiting(members, now);
227
+ if (wait) return wait;
228
+ if (['landed', 'merged'].includes(team.status) || team.alreadyOnTarget?.branch) return landing(team, parts);
229
+ if (['discarded', 'cancelled'].includes(team.status)) return team.removable === false ? needs('housekeeping', 'discardedCheck') : finished('discarded');
230
+ const report = reports(team, parts, members, workers);
231
+ if (report) return report;
232
+ if (team.status === 'needs_attention' || team.status === 'failed') {
233
+ const failed = parts.find(p => ['tests_failed', 'tests-failed'].includes(p.phase) || p.status === 'tests-failed') ||
234
+ parts.find(p => p.id === team.attention?.sliceId || ['failed', 'rejected', 'conflict'].includes(p.phase));
235
+ if (!failed) return needs('failed', team.status === 'failed' ? 'teamFailed' : 'attention', {}, team.attention?.at);
236
+ const tests = failed.phase === 'tests_failed' || failed.status === 'tests-failed' || failed.lastReport?.code === 'TESTS_FAILED';
237
+ const rollback = failed.lastReport?.report;
238
+ const integration = team.integration;
239
+ const expected = rollback?.before || integration?.lastGood;
240
+ const restored = rollback?.clean !== false && !integration?.moved &&
241
+ (integration?.head && expected ? integration.head === expected : rollback?.clean === true);
242
+ const other = restored ? parts.find(p => p !== failed && joined(p)) : null;
243
+ return needs('failed', tests ? (other ? 'failedTestsSafe' : 'failedTests') : 'failedPart',
244
+ { part: nameOf(failed), other: other && nameOf(other) }, failed.lastReport?.at || team.attention?.at);
245
+ }
246
+ if (team.status === 'ready') return ready(team, parts);
247
+ const work = parts.find(p => ['working', 'finishing', 'dispatched'].includes(p.phase));
248
+ if (!work) return active('working');
249
+ const count = team.plan?.readOnly ? 0 : parts.filter(joined).length;
250
+ return active(count === 1 ? 'workingJoinedOne' : count ? 'workingJoined' : 'workingPart', { count, part: nameOf(work) });
251
+ }
252
+
253
+ export function buildWork({ teams, teamDetails = {}, runs, now = 0 } = {}) {
254
+ const time = typeof now === 'string' ? Date.parse(now) : Number(now);
255
+ const grouped = groups.map(id => ({ id, tasks: [] }));
256
+ teams = Array.isArray(teams) ? teams : null;
257
+ runs = Array.isArray(runs) ? runs : null;
258
+ const missing = [...(teams ? [] : ['teams']), ...(runs ? [] : ['runs'])];
259
+ const memberOfPart = new Map();
260
+ const members = new Map();
261
+ function add(base, result) {
262
+ const { group, at, ...fields } = result;
263
+ grouped.find(g => g.id === group).tasks.push({ ...base, ...fields, at: at || base.createdAt });
264
+ }
265
+ const details = new Map();
266
+ for (const [id, raw] of teamDetails instanceof Map ? teamDetails : Object.entries(teamDetails || {})) {
267
+ const detail = raw?.team ? teamDetailOf(raw) : raw;
268
+ details.set(id, detail);
269
+ for (const part of Array.isArray(detail?.slices) ? detail.slices : []) if (part.runId) memberOfPart.set(part.runId, id);
270
+ }
271
+ for (const r of runs || []) {
272
+ if (!r?.runId) continue;
273
+ const owner = memberTeam(r) || memberOfPart.get(r.runId);
274
+ if (owner) {
275
+ if (!members.has(owner)) members.set(owner, []);
276
+ members.get(owner).push(r);
277
+ continue;
278
+ }
279
+ add({ id: 'run-' + r.runId, kind: 'run', title: r.title || text(r.task).split('\n')[0], project: r.project || r.cwd || '',
280
+ workers: 1, createdAt: r.createdAt || '', open: { type: 'run', runId: r.runId, agent: keyOf(r.agentPin) } }, runDecision(r, time));
281
+ }
282
+ for (const row of teams || []) {
283
+ if (!row?.id) continue;
284
+ const team = { ...row, ...details.get(row.id) };
285
+ team.left ??= row.left;
286
+ const parts = Array.isArray(team.slices) ? team.slices : [];
287
+ const workers = Array.isArray(team.slices) ? parts.length : Number.isInteger(row.slices) ? row.slices : 0;
288
+ const current = members.get(row.id) || [];
289
+ const known = new Set(current.map(r => r.runId));
290
+ // A detail can still see its current worker after it falls outside the roster.
291
+ const projected = parts.flatMap(p => p.run && !known.has(p.run.runId) ? [p.run] : []);
292
+ add({ id: 'team-' + row.id, kind: 'team', title: row.title || '', project: row.project || '', workers, createdAt: row.createdAt || '',
293
+ open: { type: 'team', teamId: row.id } }, teamDecision(team, parts, [...current, ...projected], workers, time));
294
+ }
295
+ for (const g of grouped) {
296
+ g.tasks.sort((a, b) => (g.id === 'needs-you' ? rank[a.state] - rank[b.state] || date(a.at) - date(b.at) : date(b.at) - date(a.at))
297
+ || byCreated(a, b) || a.id.localeCompare(b.id));
298
+ }
299
+ return { groups: grouped, counts: { needsYou: grouped[0].tasks.length }, coverage: { runsCapped: (runs?.length || 0) >= 500, missing } };
300
+ }
@@ -0,0 +1,90 @@
1
+ // ── Data a history left out of an item, fetched when the item is opened ──
2
+ //
3
+ // A generated image arrives from Codex as megabytes of base64 inside its item (`imageGeneration.result`). A history
4
+ // of such a thread used to reach the page whole (171 MB for one thread on 2026-11-29), through the server's own
5
+ // thread. The server now leaves that data out of the history and marks the item (lib/codex-thread-history.js
6
+ // deferCodexInlineImage): `item._synabunDeferred = { turnId, fields: { result: { chars, head } } }`. The card is
7
+ // drawn as before; when somebody opens it, the page asks for the item (`thread_item_payload`) and shows the data
8
+ // exactly where it always was. What is fetched is kept with the card only, never with the saved transcript.
9
+ //
10
+ // No imports and no DOM: what a card shows is decided here (`node --test` loads this file), cdx-render.js draws it.
11
+
12
+ /** The mark's name on an item (the server's CODEX_DEFERRED_KEY). */
13
+ export const DEFERRED_KEY = '_synabunDeferred';
14
+
15
+ /** `{ chars, head }` when `field` of `item` was left out by the server, else null. */
16
+ export function deferredField(item, field = 'result') {
17
+ const mark = item?.[DEFERRED_KEY]?.fields?.[field];
18
+ return mark && typeof mark === 'object' && Number(mark.chars) > 0 ? { chars: Number(mark.chars), head: typeof mark.head === 'string' ? mark.head : '' } : null;
19
+ }
20
+
21
+ /** What names the item in a card's head: its data as before, or the beginning the server kept of what it left out. */
22
+ export function deferredHeadlineText(item, field = 'result') {
23
+ const own = item?.[field];
24
+ if (typeof own === 'string' && own) return own;
25
+ return deferredField(item, field)?.head || '';
26
+ }
27
+
28
+ /** `1.5 MB`, `640 KB`: the size of what waits to be fetched. */
29
+ export function deferredSizeLabel(chars) {
30
+ const n = Number(chars) || 0;
31
+ if (n >= 1048576) return `${(n / 1048576).toFixed(1)} MB`;
32
+ return `${Math.max(1, Math.round(n / 1024))} KB`;
33
+ }
34
+
35
+ /**
36
+ * The text of an image-generation card's body. With the data in the item (a live turn, an older server) or fetched
37
+ * (`loaded`), it is what the card always showed; while it is being fetched, or when that failed, the Result section
38
+ * says so in one line.
39
+ * @param {object} item
40
+ * @param {{ loaded?: string|null, error?: string, failureText?: (failure: any) => string }} [state]
41
+ */
42
+ export function imageGenerationBodyText(item, { loaded = null, error = '', failureText = (failure) => String(failure) } = {}) {
43
+ const waiting = deferredField(item, 'result');
44
+ const result = typeof loaded === 'string' && loaded ? loaded : (typeof item?.result === 'string' ? item.result : '');
45
+ let resultSection = '';
46
+ if (result) resultSection = `Result\n${result}`;
47
+ else if (waiting && error) resultSection = `Result\nThe image data (${deferredSizeLabel(waiting.chars)}) could not be loaded: ${error} Close and open this card to try again.`;
48
+ else if (waiting) resultSection = `Result\nLoading the image data (${deferredSizeLabel(waiting.chars)})…`;
49
+ return [
50
+ item?.revisedPrompt ? `Prompt\n${item.revisedPrompt}` : '',
51
+ item?.savedPath ? `Saved path\n${item.savedPath}` : '',
52
+ resultSection,
53
+ item?.failure ? `Failure\n${failureText(item.failure)}` : '',
54
+ item?.transparentBackground != null ? `Transparent background: ${item.transparentBackground ? 'yes' : 'no'}` : '',
55
+ ].filter(Boolean).join('\n\n');
56
+ }
57
+
58
+ /**
59
+ * Fetch what was left out of `item` for one card, once. `state` is the card's own state (the fetched data stays on
60
+ * it as `_deferredPayload`, never on the item, which is what a transcript saves); `request(type, payload)` sends the
61
+ * panel's request and resolves with the server's answer; `done()` is called when the answer (or the failure) is in,
62
+ * so the card can be drawn again. Returns whether a request went out.
63
+ */
64
+ export function loadDeferredItem(state, item, { threadId, request, done = () => {} }) {
65
+ if (!state || state._deferredPayload || state._deferredRequest) return false;
66
+ const turnId = item?.[DEFERRED_KEY]?.turnId;
67
+ if (!deferredField(item, 'result') || !threadId || !turnId || !item?.id || typeof request !== 'function') {
68
+ if (deferredField(item, 'result') && !state._deferredError) state._deferredError = 'this tab has no thread to ask.';
69
+ return false;
70
+ }
71
+ state._deferredError = '';
72
+ const pending = Promise.resolve()
73
+ .then(() => request('thread_item_payload', { threadId, turnId, itemId: item.id }))
74
+ .then((reply) => {
75
+ const result = reply?.item?.result;
76
+ if (typeof result !== 'string' || !result) throw new Error('Codex returned the item without its data.');
77
+ state._deferredPayload = { result };
78
+ })
79
+ .catch((error) => {
80
+ const message = String(error?.message || error || 'the request failed').replace(/\s+$/, '');
81
+ state._deferredError = /[.!?]$/.test(message) ? message : `${message}.`;
82
+ })
83
+ .finally(() => {
84
+ // A failure can be tried again (the card is drawn again when it is next opened); a success never asks twice.
85
+ if (state._deferredRequest === pending) state._deferredRequest = null;
86
+ try { done(); } catch { /* the card's own failure */ }
87
+ });
88
+ state._deferredRequest = pending;
89
+ return true;
90
+ }
@@ -15,6 +15,7 @@ import { buildCodexPlanRevisionPrompt, codexGenericCardHead, codexReadableValue,
15
15
  import { getPlanMarkdown, approvePlan, extractProposedPlan, syncPlanMirrors, isRecordedPlanTurn, isPlanMessageCandidate, selectPlanAdoptionMessage } from './cdx-plan.js';
16
16
  import { bindExpandableCard, setCardExpanded } from './cdx-cards.js';
17
17
  import { mountMcpAppCard } from './cdx-mcp-app-host.js';
18
+ import { deferredField, imageGenerationBodyText, loadDeferredItem } from './cdx-deferred.js';
18
19
  import { OUTPUT_LIMITS, boundedText, jsonAnswer, prettyJsonFences, readableStructuredValue, fileChangeDiffs, parseUnifiedDiff, deduplicateTurnDiff } from './cdx-output-model.js';
19
20
  import { renderReadableOutput, renderReadableBlock, cleanOutputBlocks, hydrateOutputControls, observeOutputBlocks, renderDiffView, restoreDiffViews } from './cdx-output.js';
20
21
  import { fileLinkTitle, fillFileLinkCopy, isInsideRoots, parseFileLinkTarget, readFileLink } from '../file-links.js';
@@ -1933,6 +1934,8 @@ export function bindCardHead(card) {
1933
1934
  bindExpandableCard(card, (node, expanded) => {
1934
1935
  node.dataset.userCollapsed = expanded ? '0' : '1';
1935
1936
  const state = expanded && node.dataset.itemId ? _ctx.items.get(node.dataset.itemId) : null;
1937
+ // Opening a card whose left-out data could not be fetched tries once more (cdx-deferred.js).
1938
+ if (state?._deferredError) { state._deferredError = ''; state._bodyDirty = true; }
1936
1939
  if (state) flushCardBody(state);
1937
1940
  _ctx.scheduleThreadSnapshotSave(_ctx.boundTab);
1938
1941
  _ctx.saveTabs();
@@ -3206,13 +3209,21 @@ export function updateItemFromData(item) {
3206
3209
  }
3207
3210
  if (state.pillEl) state.pillEl.textContent = item.status || 'complete';
3208
3211
  if (state.preEl) {
3209
- state.preEl.textContent = [
3210
- item.revisedPrompt ? `Prompt\n${item.revisedPrompt}` : '',
3211
- item.savedPath ? `Saved path\n${item.savedPath}` : '',
3212
- item.result ? `Result\n${item.result}` : '',
3213
- item.failure ? `Failure\n${codexReadableValue(item.failure)}` : '',
3214
- item.transparentBackground != null ? `Transparent background: ${item.transparentBackground ? 'yes' : 'no'}` : '',
3215
- ].filter(Boolean).join('\n\n');
3212
+ // A history leaves the image's data out of the item (cdx-deferred.js): it is asked for here, which is only
3213
+ // reached once the card is open, and the card is drawn again when the answer is in.
3214
+ if (deferredField(item, 'result') && !state._deferredPayload && !state._deferredError) {
3215
+ const tab = _ctx.boundTab;
3216
+ loadDeferredItem(state, item, {
3217
+ threadId: tab?.threadId || null,
3218
+ request: (type, payload) => _ctx.requestForTab(tab, type, payload),
3219
+ done: () => _ctx.withTab(tab, () => { if (state.el?.isConnected && state._lastItem) updateItemFromData(state._lastItem); }),
3220
+ });
3221
+ }
3222
+ state.preEl.textContent = imageGenerationBodyText(item, {
3223
+ loaded: state._deferredPayload?.result || null,
3224
+ error: state._deferredError || '',
3225
+ failureText: codexReadableValue,
3226
+ });
3216
3227
  }
3217
3228
  break;
3218
3229
  case 'hookPrompt':
@@ -2,6 +2,7 @@ import { sessionProjectItems } from '../session-project-items.js';
2
2
  import { answerWorkerQuestion } from '../worker-questions.js';
3
3
  import { cxpText, cxpSessionLabel } from './cdx-copy.js';
4
4
  import { codexWantsRolloutPreview, rolloutPreviewApplies } from './cdx-preview.js';
5
+ import { deferredHeadlineText } from './cdx-deferred.js';
5
6
  import { mountCodexSettings } from './cdx-settings.js';
6
7
  import { t } from '../i18n.js';
7
8
  import { codexEffortDesc, codexEffortLabel, translatedEffortWord } from '../effort-i18n.js';
@@ -2065,7 +2066,7 @@ function itemHeadline(item) {
2065
2066
  case 'imageGeneration':
2066
2067
  return {
2067
2068
  title: 'Generating image',
2068
- detail: cleanPreview(item.revisedPrompt || item.result || 'Image generation'),
2069
+ detail: cleanPreview(item.revisedPrompt || deferredHeadlineText(item, 'result') || 'Image generation'),
2069
2070
  };
2070
2071
  case 'imageView':
2071
2072
  return {
@@ -1,5 +1,6 @@
1
1
  // The complete wire format. Neither a health body, a translated subtitle, a URL,
2
- // nor an exception/refusal message belongs in the trail or the server log.
2
+ // nor an exception/refusal message belongs in the trail or the server log. The one
3
+ // name it carries is a file name of SynaBun's own first frame (`import-probe`).
3
4
  export const DIAGNOSTIC_BATCH = 20;
4
5
  const loadingTitles = [
5
6
  'loading.serverOffline', 'loading.connectionFailed', 'loading.health.databaseUnreachable.title',
@@ -8,6 +9,7 @@ const loadingTitles = [
8
9
 
9
10
  const bool = value => typeof value === 'boolean';
10
11
  const count = value => Number.isInteger(value) && value >= 1 && value <= 20;
12
+ const upTo = max => value => Number.isInteger(value) && value >= 0 && value <= max;
11
13
  const oneOf = (...values) => value => values.includes(value);
12
14
  const states = oneOf('idle', 'launching', 'starting', 'waiting', 'stalled', 'failed', 'online', 'restarting', 'refused');
13
15
  const moduleName = oneOf('entry', 'app');
@@ -40,6 +42,19 @@ const events = {
40
42
  'probe-answered': { misses: count, seconds: value => Number.isInteger(value) && value >= 0 && value <= 3600 },
41
43
  'import-failed': { module: moduleName },
42
44
  'import-retry': { module: moduleName },
45
+ // What index.html found when it asked again, plainly, for every module of a first frame that failed to load: how
46
+ // the document came (and whether from the network), whether a service worker controls it, how many of the modules
47
+ // could not be fetched and the first of them (its file name, never an address), with why.
48
+ 'import-probe': {
49
+ module: moduleName,
50
+ navigation: oneOf('navigate', 'reload', 'back_forward', 'prerender', 'unknown'),
51
+ document: oneOf('network', 'cache', 'unknown'),
52
+ worker: oneOf('controlled', 'none', 'unsupported'),
53
+ asked: upTo(40), failed: upTo(40),
54
+ first: value => value === '' || (typeof value === 'string' && /^[a-z0-9][a-z0-9.-]{0,47}\.js$/.test(value)),
55
+ reason: oneOf('none', 'network', 'timeout', 'status', 'type'),
56
+ status: upTo(599),
57
+ },
43
58
  };
44
59
 
45
60
  function matches(object, fields) {
@@ -74,6 +74,9 @@ export async function renderOperationsPlace(host, ctx, place) {
74
74
  }
75
75
  function healthHTML(data, usage, settings, scanners) {
76
76
  const nameOf = (id) => ctx.data?.skills?.find((s) => s.skillId === id)?.name || id;
77
+ // Per runtime (health.js runtimeVerification): which are not confirmed yet, which have no listing to ask.
78
+ const runtimeNames = (list) => list.map((rt) => (['claude', 'codex', 'opencode', 'antigravity'].includes(rt) ? ctx.t(`skillsStudio.runtime.${rt}`) : rt)).join(', ');
79
+ const staticOnly = (r) => Object.entries(r.runtimes || {}).filter(([, v]) => v?.verification === 'static-only').map(([rt]) => rt);
77
80
  return html`<div class="sx-ops-grid"><section class="sx-ops-card">
78
81
  <h4 class="sx-section-title">${t('collection')}</h4><label class="sx-choice"><input type="checkbox" id="sx-usage-enabled"${attr('checked', settings.telemetryEnabled)}${attr('disabled', ctx.guest)}> ${t('collect')}</label>
79
82
  <label class="sx-field-label" for="sx-retention">${t('retention')}</label><input class="sx-input" type="number" id="sx-retention" min="1" max="365" value="${settings.retentionDays}"${attr('disabled', ctx.guest)}>
@@ -89,6 +92,8 @@ export async function renderOperationsPlace(host, ctx, place) {
89
92
  <h4 class="sx-section-title">${t('usage')}</h4>${usage.rows.length ? html`<div class="sx-ops-grid">${usage.rows.map((r) => html`<article class="sx-ops-card"><strong>${nameOf(r.skillId)} · ${r.runtime}</strong><p class="sx-help">${r.revisionId}</p><p>${t('counts', r)}</p></article>`)}</div>` : html`<p class="sx-help">${t('noUsage')}</p>`}
90
93
  <h4 class="sx-section-title">${t('installations')}</h4>${data.rows.length ? html`<div class="sx-ops-grid">${data.rows.map((r) => html`<article class="sx-ops-card"><strong>${r.name || nameOf(r.skillId)} · ${r.runtime}</strong>
91
94
  <p class="sx-help">${r.revisionId}</p><p class="${r.issues.length ? 'sx-warn-text' : 'sx-help'}">${t(`state_${r.status}`)}</p>
95
+ ${r.unverifiedRuntimes?.length ? html`<p class="sx-help">${t('unverifiedRuntimes', { runtimes: runtimeNames(r.unverifiedRuntimes) })}</p>` : ''}
96
+ ${staticOnly(r).length ? html`<p class="sx-help">${t('staticOnlyRuntimes', { runtimes: runtimeNames(staticOnly(r)) })}</p>` : ''}
92
97
  <ul class="sx-plain-list">${r.issues.map((i) => html`<li>${t(`issue_${i}`)}</li>`)}</ul>
93
98
  ${r.scan ? html`<p class="sx-help">${r.scan.engine} ${r.scan.engineVersion} · ${r.scan.policy}</p><ul class="sx-plain-list">${r.scan.findings.slice(0, 12).map((f) => html`<li>${f.severity} · ${f.ruleId} · ${f.file || ''}${f.line ? `:${f.line}` : ''} — ${scanFindingText(t, f)}</li>`)}</ul>` : ''}
94
99
  </article>`)}</div>` : html`<p class="sx-help">${t('noChecks')}</p>`}