synabun 2.4.4 → 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.
- package/CHANGELOG.md +42 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +5 -4
- package/docs/whatsapp.md +19 -3
- package/hooks/claude-code/session-start.mjs +21 -18
- package/lib/claude-global-config.js +214 -0
- package/lib/client-config-repair.js +17 -3
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +6 -1
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +1 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +1 -0
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +1 -1
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +18 -3
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +85 -16
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +24 -5
- package/mcp-server/dist/tools/skill-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/skill-tools.js +88 -8
- package/mcp-server/dist/tools/skill-tools.js.map +1 -1
- package/mcp-server/dist/tools/tool-groups.d.ts.map +1 -1
- package/mcp-server/dist/tools/tool-groups.js +19 -4
- package/mcp-server/dist/tools/tool-groups.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/index.ts +6 -1
- package/mcp-server/src/services/neural-interface.ts +2 -1
- package/mcp-server/src/services/tool-catalog.ts +1 -1
- package/mcp-server/src/tools/agents.ts +78 -16
- package/mcp-server/src/tools/skill-tools.ts +82 -9
- package/mcp-server/src/tools/tool-groups.ts +19 -4
- package/neural-interface/i18n/en.json +484 -19
- package/neural-interface/i18n/pt-BR.json +484 -19
- package/neural-interface/lib/agents-studio-api.js +7 -2
- package/neural-interface/lib/antigravity/home.js +43 -8
- package/neural-interface/lib/antigravity/panel-bridge.js +7 -3
- package/neural-interface/lib/antigravity/tool-call.js +14 -0
- package/neural-interface/lib/assistant-brains/antigravity.js +4 -2
- package/neural-interface/lib/assistant-dispatch.js +15 -1
- package/neural-interface/lib/assistant-persona.js +8 -3
- package/neural-interface/lib/assistant-route-gate.js +11 -2
- package/neural-interface/lib/assistant-runtime.js +95 -13
- package/neural-interface/lib/assistant-spilled-output.js +53 -0
- package/neural-interface/lib/assistant-user-context.js +7 -3
- package/neural-interface/lib/browser-default.js +22 -2
- package/neural-interface/lib/browser-extension-bridge.js +50 -3
- package/neural-interface/lib/browser-extension-pin.json +7 -7
- package/neural-interface/lib/browser-extension-protocol.js +30 -1
- package/neural-interface/lib/browser-extension-setup.js +204 -36
- package/neural-interface/lib/claude-agent-bridge.js +13 -2
- package/neural-interface/lib/codex-thread-history.js +144 -7
- package/neural-interface/lib/codex-worker-app-server.js +84 -30
- package/neural-interface/lib/db.js +26 -0
- package/neural-interface/lib/greeting/sources.js +7 -3
- package/neural-interface/lib/jsonl-lines.js +10 -11
- package/neural-interface/lib/line-buffer.js +88 -0
- package/neural-interface/lib/loop-stall.js +15 -1
- package/neural-interface/lib/memory-list-read.js +105 -0
- package/neural-interface/lib/memory-timers.js +4 -1
- package/neural-interface/lib/native-loop-runtime.js +7 -3
- package/neural-interface/lib/provider-panel-api-key-auth.js +33 -6
- package/neural-interface/lib/remote-policy.js +24 -7
- package/neural-interface/lib/skills/api-v2.js +18 -3
- package/neural-interface/lib/skills/bundle.js +2 -2
- package/neural-interface/lib/skills/deploy.js +169 -34
- package/neural-interface/lib/skills/digest.js +57 -3
- package/neural-interface/lib/skills/health.js +55 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +12 -0
- package/neural-interface/lib/skills/runtime-checks.js +7 -4
- package/neural-interface/lib/skills/scan-shell.js +56 -7
- package/neural-interface/lib/skills/scan.js +13 -12
- package/neural-interface/lib/skills/service.js +7 -2
- package/neural-interface/lib/skills/telemetry.js +2 -2
- package/neural-interface/lib/teams/README.md +34 -6
- package/neural-interface/lib/teams/api.js +94 -10
- package/neural-interface/lib/teams/index.js +4 -0
- package/neural-interface/lib/teams/landing.js +195 -75
- package/neural-interface/lib/teams/recovery.js +68 -0
- package/neural-interface/lib/teams/scheduler.js +380 -61
- package/neural-interface/lib/teams/worktrees.js +123 -30
- package/neural-interface/lib/terminal-token-redaction.js +228 -58
- package/neural-interface/lib/terminal-tokens.js +18 -0
- package/neural-interface/lib/whatsapp/brain.js +21 -0
- package/neural-interface/lib/whatsapp/bridge.js +40 -4
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +6 -2
- package/neural-interface/public/index.html +117 -37
- package/neural-interface/public/shared/agents/studio/ax-api.js +27 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +1 -1
- package/neural-interface/public/shared/agents/studio/ax-icons.js +1 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-main.js +127 -41
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +3 -2
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +436 -33
- package/neural-interface/public/shared/agents/studio/ax-teams.js +357 -10
- package/neural-interface/public/shared/agents/studio/ax-ui.js +31 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +67 -69
- package/neural-interface/public/shared/agents/studio/ax-work-answer.js +86 -0
- package/neural-interface/public/shared/agents/studio/ax-work-view.js +305 -0
- package/neural-interface/public/shared/agents/studio/ax-work.css +74 -0
- package/neural-interface/public/shared/agents/studio/ax-work.js +300 -0
- package/neural-interface/public/shared/browser-extension-updates.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-deferred.js +90 -0
- package/neural-interface/public/shared/cdx/cdx-render.js +18 -7
- package/neural-interface/public/shared/cdx/cdx-tabs.js +2 -1
- package/neural-interface/public/shared/extension-setup/es-page.js +23 -4
- package/neural-interface/public/shared/extension-setup/es-view.js +51 -11
- package/neural-interface/public/shared/extension-update-view.js +1 -1
- package/neural-interface/public/shared/loading-diagnostic-entry.js +16 -1
- package/neural-interface/public/shared/settings/settings-ai-browser.js +23 -3
- package/neural-interface/public/shared/settings/settings-browser-extension.js +575 -197
- package/neural-interface/public/shared/settings/settings-extension-diagrams.js +116 -0
- package/neural-interface/public/shared/settings/settings-extension-guide.js +222 -0
- package/neural-interface/public/shared/settings/settings-ia.js +2 -2
- package/neural-interface/public/shared/settings/settings-shell.js +5 -0
- package/neural-interface/public/shared/skills/studio/sx-operations-view.js +5 -0
- package/neural-interface/public/shared/skills/studio/sx-plan.js +42 -3
- package/neural-interface/public/shared/skills/studio/sx-publish-view.js +20 -4
- package/neural-interface/public/shared/styles.css +196 -13
- package/neural-interface/public/shared/ui-settings.js +48 -11
- package/neural-interface/server.js +336 -253
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/skills/skill-forge/SKILL.md +7 -3
|
@@ -430,6 +430,24 @@ export function createTerminalTokenRegistry({
|
|
|
430
430
|
},
|
|
431
431
|
/** For tests and diagnostics: how many runs hold a token, how many ended ones are kept. */
|
|
432
432
|
stats: () => ({ live: live.size, revoked: revoked.size }),
|
|
433
|
+
/**
|
|
434
|
+
* For diagnostics: what the live proofs are, by kind and by the family of their id (a Codex panel's app-server, a
|
|
435
|
+
* Claude panel tab, an automation-window agent, an MCP session, anything else: a run, a loop, a brain's session).
|
|
436
|
+
* Numbers only: never an id or a value. Each live proof is one secret the scrubbers look for.
|
|
437
|
+
*/
|
|
438
|
+
breakdown: () => {
|
|
439
|
+
const kinds = {};
|
|
440
|
+
const families = {};
|
|
441
|
+
for (const [id, held] of live) {
|
|
442
|
+
kinds[held.kind] = (kinds[held.kind] || 0) + 1;
|
|
443
|
+
const family = held.kind === 'mcp-session' ? 'mcp-session'
|
|
444
|
+
: id.startsWith('codex-sp-') ? 'codex-panel'
|
|
445
|
+
: id.startsWith('sidepanel-') ? 'claude-panel'
|
|
446
|
+
: id.startsWith('agent:') ? 'agent' : 'run';
|
|
447
|
+
families[family] = (families[family] || 0) + 1;
|
|
448
|
+
}
|
|
449
|
+
return { kinds, families };
|
|
450
|
+
},
|
|
433
451
|
/** For tests and diagnostics: how many closed MCP sessions are kept refused (their own list, never the runs'). */
|
|
434
452
|
sessionStats: () => ({ revokedSessions: revokedSessions.size }),
|
|
435
453
|
};
|
|
@@ -77,6 +77,9 @@ export function checkBrainChoice(choice, catalog) {
|
|
|
77
77
|
return { ok: true, brain: { provider: clean.provider, model: hit.row.id, effort } };
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
// Providers whose accounts SynaBun keeps (Settings → Accounts).
|
|
81
|
+
const ACCOUNT_PROVIDERS = new Set(['claude-code', 'codex']);
|
|
82
|
+
|
|
80
83
|
/**
|
|
81
84
|
* The brain a WhatsApp conversation runs on now.
|
|
82
85
|
* → { source: 'assistant' | 'choice', brain, fallback }
|
|
@@ -84,6 +87,11 @@ export function checkBrainChoice(choice, catalog) {
|
|
|
84
87
|
* fallback: { reason: 'disabled' | 'unknown', provider, model } when a stored choice
|
|
85
88
|
* could not be used. Only a definite answer falls back: a catalog that is not
|
|
86
89
|
* built yet, or a provider whose list is unavailable, keeps the choice.
|
|
90
|
+
*
|
|
91
|
+
* The account: the panel's (its pinned account, or its Auto) on the panel's provider; a model of
|
|
92
|
+
* another provider names none (its Default). Either way the runtime keeps a WhatsApp conversation
|
|
93
|
+
* on an account that can run (assistant-runtime.js phoneAccountMoves: Default and an exhausted or
|
|
94
|
+
* signed-out account follow usage; an API key and a named subscription with usage left stay).
|
|
87
95
|
*/
|
|
88
96
|
export function resolveBrainChoice(choice, { catalog = null, panelBrain = null } = {}) {
|
|
89
97
|
const base = isPlainObject(panelBrain) ? { ...panelBrain } : {};
|
|
@@ -102,6 +110,19 @@ export function resolveBrainChoice(choice, { catalog = null, panelBrain = null }
|
|
|
102
110
|
return { source: 'choice', brain: { ...kept, provider: clean.provider, model: clean.model, effort: clean.effort || null }, fallback: null };
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
/**
|
|
114
|
+
* The account fields a session switching to `target`'s provider is given (runtime.updateSession):
|
|
115
|
+
* Auto as `accountId: 'auto'` (the runtime resolves it then), the panel's pinned account as is, or
|
|
116
|
+
* nothing (the provider's Default). Only for a provider switch: another model of the same provider
|
|
117
|
+
* keeps the account, and with it the provider's conversation.
|
|
118
|
+
*/
|
|
119
|
+
export function brainAccountPatch(target) {
|
|
120
|
+
const brain = target?.brain || {};
|
|
121
|
+
if (!ACCOUNT_PROVIDERS.has(brain.provider)) return {};
|
|
122
|
+
if (brain.accountId === 'auto' || brain.accountPolicy === 'auto') return { accountId: 'auto' };
|
|
123
|
+
return brain.accountId ? { accountId: String(brain.accountId) } : {};
|
|
124
|
+
}
|
|
125
|
+
|
|
105
126
|
/** What identifies the configured choice: a session switches brain only when this changes. */
|
|
106
127
|
export function brainSignature(target) {
|
|
107
128
|
if (!target || target.source !== 'choice') return 'assistant';
|
|
@@ -60,7 +60,7 @@ import { assistantEventKey } from '../../public/shared/assistant/asst-state.js';
|
|
|
60
60
|
import { abandonedPrograms } from '../../public/shared/shell-stop-view.js';
|
|
61
61
|
import { stripFollowups } from '../../public/shared/assistant/asst-followups.js';
|
|
62
62
|
import { brainCapsLevel, defaultRemotePolicyRegistry, effectiveLevel, remoteBrainNotice } from '../remote-policy.js';
|
|
63
|
-
import { brainSignature, resolveBrainChoice } from './brain.js';
|
|
63
|
+
import { brainAccountPatch, brainSignature, resolveBrainChoice } from './brain.js';
|
|
64
64
|
import { answerCard, cardFromPacket, failClosedResponse, isBareAnswer, randomTag, renderCard } from './cards.js';
|
|
65
65
|
import { HELP_TEXT, SETTINGS_REFUSAL, parseCommand, statusText } from './commands.js';
|
|
66
66
|
|
|
@@ -448,6 +448,15 @@ export function createWhatsAppBridge({
|
|
|
448
448
|
function presence(value) { try { const r = transport.presence?.(value); if (r?.catch) r.catch(() => {}); } catch {} }
|
|
449
449
|
|
|
450
450
|
// ── sessions ───────────────────────────────────────────────────────────────
|
|
451
|
+
/**
|
|
452
|
+
* The panel's Auto that cannot pick now (no signed-in subscription, or every one limited) as a
|
|
453
|
+
* conversation starts or switches provider: the switch still happens, on the provider's Default
|
|
454
|
+
* account, and the runtime decides at the turn (assistant-runtime.js phoneAccountMoves): a key
|
|
455
|
+
* runs, a limited subscription is refused with the soonest reset, never sent the turn.
|
|
456
|
+
*/
|
|
457
|
+
function autoAccountFallsBack(asked, error) {
|
|
458
|
+
return asked?.accountId === 'auto' && ['ACCOUNT_NO_SUBSCRIPTION', 'ACCOUNTS_ALL_LIMITED'].includes(error?.code);
|
|
459
|
+
}
|
|
451
460
|
function defaultBrain() {
|
|
452
461
|
let brain = null;
|
|
453
462
|
try { brain = typeof getDefaultBrain === 'function' ? getDefaultBrain() : null; } catch { brain = null; }
|
|
@@ -483,7 +492,15 @@ export function createWhatsAppBridge({
|
|
|
483
492
|
if (differs && rt?.updateSession) {
|
|
484
493
|
try {
|
|
485
494
|
// "off" is the explicit reset to the model's default effort (a missing effort would keep the old one).
|
|
486
|
-
|
|
495
|
+
const patch = { provider: want.provider, ...(want.model ? { model: want.model } : {}), effort: effortOf(want) || 'off' };
|
|
496
|
+
// Another provider: its account too (brain.js brainAccountPatch), never the old provider's id.
|
|
497
|
+
const account = want.provider !== have.provider ? brainAccountPatch(target) : {};
|
|
498
|
+
try { await rt.updateSession(sessionId, { brain: { ...patch, ...account } }); }
|
|
499
|
+
catch (error) {
|
|
500
|
+
if (!autoAccountFallsBack(account, error)) throw error;
|
|
501
|
+
await rt.updateSession(sessionId, { brain: patch });
|
|
502
|
+
log('whatsapp:bridge', `session ${sessionId}: Auto could not pick a ${want.provider} account (${error.code}); switched on its Default account`);
|
|
503
|
+
}
|
|
487
504
|
log('whatsapp:bridge', `session ${sessionId}: brain set to ${want.provider}${want.model ? `/${want.model}` : ''} (${target.source === 'choice' ? 'the WhatsApp setting' : 'same as the Assistant'})`);
|
|
488
505
|
} catch (error) {
|
|
489
506
|
// Not applied (the model was disabled meanwhile, the runtime refused): the conversation stays on its brain; tried again at the next message.
|
|
@@ -508,10 +525,20 @@ export function createWhatsAppBridge({
|
|
|
508
525
|
const rt = runtime();
|
|
509
526
|
if (!rt?.createSession) throw Object.assign(new Error('The Assistant is not available right now.'), { code: 'RUNTIME_UNAVAILABLE' });
|
|
510
527
|
const target = brainTarget();
|
|
511
|
-
const
|
|
512
|
-
{ brain
|
|
528
|
+
const start = (brain) => rt.createSession(
|
|
529
|
+
{ brain, label: `WhatsApp · ${monthDay(now())}`, fallback: true, channel: 'whatsapp' },
|
|
513
530
|
{ remote: remoteFromConfig() },
|
|
514
531
|
);
|
|
532
|
+
let session;
|
|
533
|
+
try { session = await start(target.brain); }
|
|
534
|
+
catch (error) {
|
|
535
|
+
if (!autoAccountFallsBack(target.brain, error)) throw error;
|
|
536
|
+
const brain = { ...target.brain };
|
|
537
|
+
delete brain.accountId;
|
|
538
|
+
delete brain.accountPolicy;
|
|
539
|
+
session = await start(brain);
|
|
540
|
+
log('whatsapp:bridge', `Auto could not pick a ${brain.provider} account (${error.code}); started on its Default account`);
|
|
541
|
+
}
|
|
515
542
|
state.sessionId = session.id;
|
|
516
543
|
state.brainApplied = { sessionId: session.id, signature: brainSignature(target) };
|
|
517
544
|
state.policySeen.delete(session.id);
|
|
@@ -1498,9 +1525,18 @@ export function createWhatsAppBridge({
|
|
|
1498
1525
|
persistBridgeState();
|
|
1499
1526
|
react(job.sourceIds, 'failed');
|
|
1500
1527
|
if (code === 'SESSION_BUDGET_EXCEEDED' || code === 'BRAIN_SHARE_EXHAUSTED') { await say(budgetText(code, sessionId, result.message), { maxChunks: 1 }); return; }
|
|
1528
|
+
if (code === 'ACCOUNTS_ALL_LIMITED') { await say(limitedText(sessionId, result.resetsAt), { maxChunks: 1 }); return; }
|
|
1501
1529
|
if (code === 'EMPTY_PROMPT') return;
|
|
1502
1530
|
await say(`Could not start that: ${String(result.message || code).slice(0, 400)}`, { maxChunks: 1 });
|
|
1503
1531
|
}
|
|
1532
|
+
/** Every signed-in subscription of the brain's provider is limited: nothing was sent, and when the first is back (local time). */
|
|
1533
|
+
function limitedText(sessionId, resetsAt) {
|
|
1534
|
+
const name = sessionView(sessionId)?.brain?.provider === 'codex' ? 'Codex' : 'Claude';
|
|
1535
|
+
const at = Date.parse(resetsAt || '');
|
|
1536
|
+
const day = (ms) => new Date(ms).toDateString();
|
|
1537
|
+
const when = Number.isFinite(at) ? `The first one is back at ${hhmm(at)}${day(at) === day(now()) ? '' : ` on ${monthDay(at)}`}.` : 'When they reset is not known yet.';
|
|
1538
|
+
return `Not sent: every signed-in ${name} subscription has reached its usage limit. ${when} Send it again then, or choose another model for WhatsApp in SynaBun.`;
|
|
1539
|
+
}
|
|
1504
1540
|
/** Spend against the budget, and the two ways on: /new or a higher budget. Never a silent new session. */
|
|
1505
1541
|
function budgetText(code, sessionId, fallback) {
|
|
1506
1542
|
const view = sessionView(sessionId);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neural-memory-interface",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "neural-memory-interface",
|
|
9
|
-
"version": "2.4.
|
|
9
|
+
"version": "2.4.6",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "Apache-2.0",
|
|
12
12
|
"dependencies": {
|
|
@@ -16,8 +16,12 @@
|
|
|
16
16
|
#es-steps > li[data-step][data-done], #es-extensions-url + #es-copy-url, #es-folder + #es-copy-folder + #es-reveal,
|
|
17
17
|
#es-alternatives, #es-reload, #es-restart, #es-copied, #es-progress (the bytes of the extension's download, while
|
|
18
18
|
the state is "downloading"). The ticket element is the only thing the extension's content script reads; it is
|
|
19
|
-
filled only while the extension is on this page and the server waits for it.
|
|
20
|
-
|
|
19
|
+
filled only while the extension is on this page and the server waits for it.
|
|
20
|
+
Beside the Settings guide (a setup started from Settings → Browser, status `guided`) the page is its companion:
|
|
21
|
+
data-companion="true", one card with the live status and no steps, folder or other browsers; the steps are in
|
|
22
|
+
Settings, and this tab stays open only to pair the extension by itself. Opened on its own (the extension's popup,
|
|
23
|
+
an older flow) it is the four-step page as before. -->
|
|
24
|
+
<main id="es-setup" class="es-setup" data-state="idle" data-layout="result" data-companion="false" aria-busy="true">
|
|
21
25
|
<div class="es-top">
|
|
22
26
|
<p class="es-brand"><img src="/icon-192.png" alt="" width="32" height="32"><span>SynaBun</span></p>
|
|
23
27
|
<p id="es-browser" class="es-browser" hidden><span id="es-browser-label"></span> <strong id="es-browser-name"></strong></p>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<link rel="preload" href="/synabun.png?v=2" as="image">
|
|
26
26
|
<link rel="stylesheet" href="/shared/styles.css">
|
|
27
27
|
<!-- three.js is vendored (scripts/build-vendor.mjs); only the map renderer imports it.
|
|
28
|
-
The import map must come before any module load
|
|
28
|
+
The import map must come before any module load. -->
|
|
29
29
|
<script type="importmap">
|
|
30
30
|
{
|
|
31
31
|
"imports": {
|
|
@@ -33,32 +33,43 @@
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
</script>
|
|
36
|
-
<!-- What the first frame (the loading overlay) needs: variant/3d/main.js and every module it imports
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
<!-- What the first frame (the loading overlay) needs: variant/3d/main.js and every module it imports. The rest of
|
|
37
|
+
the app (variant/3d/app.js) is imported by main.js once the overlay shows.
|
|
38
|
+
No modulepreload hints, on purpose. They were here from 2026-11-15 to 2026-11-28 ("asked for at once instead of
|
|
39
|
+
one import level after another"). In WebKit (the owner's Safari web app) a hinted module whose load fails once,
|
|
40
|
+
because the server was away or a connection dropped, is kept as failed in memory: the next loads of the page
|
|
41
|
+
replay that failure without asking the server, reload after reload, with or without the hints in the later
|
|
42
|
+
documents, while every module answers a plain fetch (tests/startup-recovery.browser.mjs: without the hints the
|
|
43
|
+
very next reload loads). On a local server the hints saved nothing that could be measured (66 against 67 ms to
|
|
44
|
+
the first frame in WebKit, 33 against 35 in Chromium).
|
|
45
|
+
The list below is data, not a hint: what index.html asks for again, plainly, when the first frame's modules
|
|
46
|
+
failed (the probe in startup-recovery). tests/boot-critical-path.test.mjs keeps it equal to main.js's imports. -->
|
|
47
|
+
<script type="application/json" id="first-frame-modules">
|
|
48
|
+
[
|
|
49
|
+
"/shared/page-session.js",
|
|
50
|
+
"/variant/3d/main.js",
|
|
51
|
+
"/shared/storage.js",
|
|
52
|
+
"/shared/registry.js",
|
|
53
|
+
"/shared/html-shell.js",
|
|
54
|
+
"/shared/view-variant.js",
|
|
55
|
+
"/shared/i18n.js",
|
|
56
|
+
"/shared/ui-loading.js",
|
|
57
|
+
"/shared/memory-list.js",
|
|
58
|
+
"/shared/ui-sidepanel-runtime.js",
|
|
59
|
+
"/shared/storage-retry.js",
|
|
60
|
+
"/shared/app-frame.js",
|
|
61
|
+
"/shared/constants.js",
|
|
62
|
+
"/shared/api.js",
|
|
63
|
+
"/shared/state.js",
|
|
64
|
+
"/shared/loading-teardown.js",
|
|
65
|
+
"/shared/start-bridge.js",
|
|
66
|
+
"/shared/server-presence.js",
|
|
67
|
+
"/shared/synabun-mascot.js",
|
|
68
|
+
"/shared/desktop-bridge.js",
|
|
69
|
+
"/shared/synabun-ticker.js",
|
|
70
|
+
"/shared/synabun-mascot-assets.js"
|
|
71
|
+
]
|
|
72
|
+
</script>
|
|
62
73
|
<style>
|
|
63
74
|
/* ═══════════════════════════════════════════
|
|
64
75
|
3D VARIANT — Memory map
|
|
@@ -268,25 +279,70 @@
|
|
|
268
279
|
let sawOffline = false;
|
|
269
280
|
let entryFailed = false;
|
|
270
281
|
let reloadScheduled = false;
|
|
282
|
+
let retryTimer = null;
|
|
283
|
+
let appFailed = false;
|
|
271
284
|
let lastStatus = '';
|
|
272
285
|
function reportStatus(reason) {
|
|
273
286
|
if (lastStatus !== reason) globalThis.synabunLoadingDiagnostics?.record('startup-status', { reason });
|
|
274
287
|
lastStatus = reason;
|
|
275
288
|
}
|
|
289
|
+
// What failed, for the log: every module of the first frame is asked for once more, plainly, and the answer is
|
|
290
|
+
// recorded as counts and one of SynaBun's own file names (shared/loading-diagnostic-entry.js). On 2026-11-28 the
|
|
291
|
+
// owner's web app failed this graph load after load against a healthy server, and nothing said which request.
|
|
292
|
+
let probed = false;
|
|
293
|
+
async function probeEntry() {
|
|
294
|
+
if (probed) return;
|
|
295
|
+
probed = true;
|
|
296
|
+
try {
|
|
297
|
+
const asked = JSON.parse(document.getElementById('first-frame-modules').textContent)
|
|
298
|
+
.filter(href => typeof href === 'string' && /^\/[^/\\]/.test(href)).slice(0, 40);
|
|
299
|
+
const answers = await Promise.all(asked.map(async href => {
|
|
300
|
+
try {
|
|
301
|
+
const response = await fetch(href, { cache: 'no-store', signal: AbortSignal.timeout(8000) });
|
|
302
|
+
if (!response.ok) return { href, reason: 'status', status: response.status };
|
|
303
|
+
if (!/javascript/i.test(response.headers.get('Content-Type') || '')) return { href, reason: 'type', status: response.status };
|
|
304
|
+
await response.arrayBuffer(); // a body cut short is a failure too
|
|
305
|
+
return null;
|
|
306
|
+
} catch (error) {
|
|
307
|
+
return { href, reason: error?.name === 'TimeoutError' ? 'timeout' : 'network', status: 0 };
|
|
308
|
+
}
|
|
309
|
+
}));
|
|
310
|
+
const failed = answers.filter(Boolean);
|
|
311
|
+
const name = failed[0] ? failed[0].href.split('/').pop() : '';
|
|
312
|
+
const navigation = performance.getEntriesByType('navigation')[0];
|
|
313
|
+
record('import-probe', {
|
|
314
|
+
module: 'entry',
|
|
315
|
+
navigation: ['navigate', 'reload', 'back_forward', 'prerender'].includes(navigation?.type) ? navigation.type : 'unknown',
|
|
316
|
+
document: !Number.isFinite(navigation?.transferSize) ? 'unknown' : navigation.transferSize > 0 ? 'network' : 'cache',
|
|
317
|
+
worker: !('serviceWorker' in navigator) ? 'unsupported' : navigator.serviceWorker.controller ? 'controlled' : 'none',
|
|
318
|
+
asked: asked.length, failed: failed.length,
|
|
319
|
+
first: /^[a-z0-9][a-z0-9.-]{0,47}\.js$/.test(name) ? name : '',
|
|
320
|
+
reason: failed[0]?.reason || 'none', status: failed[0]?.status || 0,
|
|
321
|
+
});
|
|
322
|
+
} catch { /* Observation must not interrupt recovery. */ }
|
|
323
|
+
}
|
|
276
324
|
// A module graph that failed to load stays failed in this document, even if
|
|
277
325
|
// the server has already recovered by the time the first probe runs.
|
|
278
326
|
addEventListener('error', event => {
|
|
279
327
|
if (event.target?.getAttribute?.('src') === '/variant/3d/main.js') {
|
|
280
328
|
entryFailed = true;
|
|
281
329
|
globalThis.synabunLoadingDiagnostics?.record('import-failed', { module: 'entry' });
|
|
330
|
+
probeEntry();
|
|
331
|
+
// Nothing of this document's graph is still on its way: the server is asked now, not in twelve seconds.
|
|
332
|
+
if (!adopted && !settled && checkTimer !== null) {
|
|
333
|
+
clearTimeout(checkTimer);
|
|
334
|
+
checkTimer = setTimeout(checkStartup, 1500);
|
|
335
|
+
}
|
|
282
336
|
}
|
|
283
337
|
}, true);
|
|
284
|
-
// Both graphs share one
|
|
285
|
-
//
|
|
338
|
+
// Both graphs share one chain of automatic reloads. A completed boot ends it
|
|
339
|
+
// immediately. Five minutes after its last reload a fresh load starts another.
|
|
286
340
|
addEventListener('synabun:boot-complete', () => {
|
|
341
|
+
clearTimeout(retryTimer);
|
|
342
|
+
retryTimer = null;
|
|
287
343
|
try {
|
|
288
|
-
if (history.state?.startupRetried) {
|
|
289
|
-
const { startupRetried, ...state } = history.state;
|
|
344
|
+
if (history.state?.startupRetried || history.state?.startupRetries) {
|
|
345
|
+
const { startupRetried, startupRetries, ...state } = history.state;
|
|
290
346
|
history.replaceState(state, '');
|
|
291
347
|
}
|
|
292
348
|
} catch {}
|
|
@@ -305,25 +361,49 @@
|
|
|
305
361
|
}
|
|
306
362
|
record('boot-cleanup', { adopted, removed, hidden, aborted });
|
|
307
363
|
});
|
|
364
|
+
// A failed module graph against a healthy server is reloaded by itself, a few times and further apart each time,
|
|
365
|
+
// before the person is asked: on 2026-11-28 the owner's web app failed three loads in a row and loaded on the
|
|
366
|
+
// fourth, forty seconds after the first, and one automatic reload had left a "connection failed" screen over a
|
|
367
|
+
// server that was answering. RETRY_GAPS[n] is the least time since the chain's last reload before its reload
|
|
368
|
+
// n + 1. The chain is kept in the history state: `startupRetried` (when it last reloaded) and `startupRetries`
|
|
369
|
+
// (how often); a legacy boolean, a clock that went back or five quiet minutes start a new one.
|
|
370
|
+
const RETRY_GAPS = [0, 5000, 15000, 30000];
|
|
371
|
+
const RETRY_CHAIN_MS = 300000;
|
|
372
|
+
function retryChain(now) {
|
|
373
|
+
const last = history.state?.startupRetried;
|
|
374
|
+
if (!Number.isFinite(last) || now < last || now - last >= RETRY_CHAIN_MS) return { count: 0, last: 0 };
|
|
375
|
+
const count = history.state?.startupRetries;
|
|
376
|
+
return { count: Number.isInteger(count) && count > 0 ? count : 1, last };
|
|
377
|
+
}
|
|
308
378
|
function retryHealthyStartup() {
|
|
309
|
-
|
|
379
|
+
retryTimer = null;
|
|
380
|
+
// A shell that took the overlay while this waited is booting, unless it said its own module failed.
|
|
381
|
+
if (reloadScheduled || settled || (adopted && !appFailed)) return;
|
|
310
382
|
try {
|
|
311
|
-
const last = history.state?.startupRetried;
|
|
312
383
|
const now = Date.now();
|
|
313
|
-
|
|
314
|
-
|
|
384
|
+
const { count, last } = retryChain(now);
|
|
385
|
+
if (count < RETRY_GAPS.length) {
|
|
386
|
+
const wait = last + RETRY_GAPS[count] - now;
|
|
387
|
+
if (wait > 0) {
|
|
388
|
+
// Too soon after the last reload: it says that it is still trying, and comes back. Retry stays in reach.
|
|
389
|
+
reportStatus('loading');
|
|
390
|
+
render('connecting', 'connectedLoading', true);
|
|
391
|
+
retryTimer = setTimeout(retryHealthyStartup, Math.min(wait, 1000));
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
history.replaceState({ ...history.state, startupRetried: now, startupRetries: count + 1 }, '');
|
|
315
395
|
if (entryFailed) globalThis.synabunLoadingDiagnostics?.record('import-retry', { module: 'entry' });
|
|
316
396
|
globalThis.synabunLoadingDiagnostics?.record('reload-scheduled', { reason: 'startup' });
|
|
317
397
|
reloadScheduled = true;
|
|
318
398
|
location.reload();
|
|
319
399
|
return;
|
|
320
400
|
}
|
|
321
|
-
} catch { /* Manual retry is still available if the
|
|
401
|
+
} catch { /* Manual retry is still available if the chain cannot be saved. */ }
|
|
322
402
|
entryFailed = true;
|
|
323
403
|
reportStatus('manual-retry');
|
|
324
404
|
render('connectionFailed', 'somethingWrong', true);
|
|
325
405
|
}
|
|
326
|
-
addEventListener('synabun:startup-module-failed', retryHealthyStartup);
|
|
406
|
+
addEventListener('synabun:startup-module-failed', () => { appFailed = true; retryHealthyStartup(); });
|
|
327
407
|
async function checkStartup() {
|
|
328
408
|
checkTimer = null;
|
|
329
409
|
if (adopted || settled) return;
|
|
@@ -147,6 +147,17 @@ export function createAgentsApi({ fetch: fetchFn = (...args) => globalThis.fetch
|
|
|
147
147
|
exportAll: ({ scope = null, project = null } = {}) => send('GET', `${base}/export${queryString({ scope, project })}`),
|
|
148
148
|
resolve: (ref, cwd = null) => send('GET', `${base}/resolve${queryString({ ref, cwd })}`),
|
|
149
149
|
runs: async (key, { limit = 50 } = {}) => send('GET', agentUrl(key, '/runs', { limit })),
|
|
150
|
+
workRuns: () => send('GET', '/api/assistant/runs?limit=500'),
|
|
151
|
+
async answerWorkerQuestion(runId, requestId, response) {
|
|
152
|
+
try {
|
|
153
|
+
return await send('POST', `/api/assistant/runs/${encodeURIComponent(runId)}/permission`, {
|
|
154
|
+
body: { ...response, requestId, origin: 'user' },
|
|
155
|
+
});
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (error.status === 409 && ['PERMISSION_ALREADY_RESOLVED', 'NO_PENDING_REQUEST'].includes(error.code)) return { stale: true };
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
},
|
|
150
161
|
// ── checks: nothing is stored ──
|
|
151
162
|
validate: (definition) => send('POST', `${base}/validate`, { body: { definition } }),
|
|
152
163
|
lint: (definition) => send('POST', `${base}/lint`, { body: { definition } }),
|
|
@@ -193,6 +204,22 @@ export function createAgentsApi({ fetch: fetchFn = (...args) => globalThis.fetch
|
|
|
193
204
|
}
|
|
194
205
|
},
|
|
195
206
|
landTeam: async (teamId, body = {}) => send('POST', teamUrl(teamId, '/land'), { body }),
|
|
207
|
+
/**
|
|
208
|
+
* `{ force: true }` also deletes what a discard kept (the owner's word, behind its own question). `{ remove: true }`
|
|
209
|
+
* (capability `teams-quick-discard`): the team's record goes too, in the same step, once the discard left nothing
|
|
210
|
+
* → `teamRemoved`, and `removal` (why it stays) when it does not.
|
|
211
|
+
*/
|
|
196
212
|
discardTeam: async (teamId, body = {}) => send('POST', teamUrl(teamId, '/discard'), { body }),
|
|
213
|
+
/**
|
|
214
|
+
* A ready team whose work is on its base branch already: its worktrees, branches and record, once the server asked
|
|
215
|
+
* git again (capability `teams-on-target`) → { teamRemoved, branch, removed }. The owner's question was answered.
|
|
216
|
+
*/
|
|
217
|
+
cleanupMergedTeam: async (teamId) => send('POST', teamUrl(teamId, '/cleanup-merged'), { body: { userConfirmed: true } }),
|
|
218
|
+
/** A landed team's worktrees and branches (capability `teams-cleanup`). The owner's question was answered: `userConfirmed`. */
|
|
219
|
+
cleanupTeam: async (teamId) => send('POST', teamUrl(teamId, '/cleanup'), { body: { userConfirmed: true } }),
|
|
220
|
+
/** A closed team's record, once nothing of it is left (capability `teams-remove`). */
|
|
221
|
+
removeTeam: async (teamId) => send('DELETE', teamUrl(teamId), { body: {} }),
|
|
222
|
+
/** Every closed team that can go → { removed: [ids], skipped: [{ teamId, code, next, … }] } (capability `teams-remove`). */
|
|
223
|
+
clearFinishedTeams: async () => send('POST', `${base}/teams/clear-finished`, { body: {} }),
|
|
197
224
|
};
|
|
198
225
|
}
|
|
@@ -129,7 +129,7 @@ export function renderCreate(main, ctx, st) {
|
|
|
129
129
|
const step = !mode ? startsHTML(ctx) : mode === 'import' ? importHTML(ctx, st.import) : mode === 'describe' ? describeHTML(ctx, st.describe) : STEP_HTML[mode](ctx);
|
|
130
130
|
setHTML(main, html`<section class="sx-place ax-place" aria-labelledby="ax-create-title">
|
|
131
131
|
<header class="sx-place-head">
|
|
132
|
-
|
|
132
|
+
<button type="button" class="sx-link" data-act="back">${ICONS.back}${t(mode ? 'agentsStudio.rail.create' : 'agentsStudio.rail.library')}</button>
|
|
133
133
|
<h3 class="sx-place-title" id="ax-create-title" tabindex="-1">${mode ? t(`agentsStudio.create.start.${mode}.name`) : t('agentsStudio.create.title')}</h3>
|
|
134
134
|
<p class="sx-place-sub">${mode ? t(`agentsStudio.create.step.${mode}`) : t('agentsStudio.create.sub')}</p>
|
|
135
135
|
</header>
|
|
@@ -70,6 +70,7 @@ export function toneOf(token) {
|
|
|
70
70
|
/** The window's own icons that the Skills Studio set does not have. */
|
|
71
71
|
export const AX_ICONS = Object.freeze({
|
|
72
72
|
mark: svg(AGENT_ICON_PATHS.bot),
|
|
73
|
+
work: svg('<path d="M3 15l3-10h12l3 10v5H3zM3 15h5l2 2h4l2-2h5"/>'),
|
|
73
74
|
teams: svg('<circle cx="9" cy="9" r="3"/><path d="M3.5 19a5.5 5.5 0 0 1 11 0"/><circle cx="17" cy="10" r="2.3"/><path d="M16 14.6a4.5 4.5 0 0 1 4.5 4.4"/>'),
|
|
74
75
|
runs: svg('<circle cx="12" cy="12" r="8.5"/><path d="M10 8.5l5.5 3.5-5.5 3.5z"/>', 14),
|
|
75
76
|
play: svg('<path d="M8 5.5l10 6.5-10 6.5z"/>', 14),
|
|
@@ -13,7 +13,7 @@ import { wireDropdowns } from '../../cc-dropdown.js';
|
|
|
13
13
|
import { filterAgents, sortAgents, providersOf, projectsOf, SORTS, STATUS_FILTERS, DEFAULT_FILTERS } 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, standingLabels, scopeTag, timeTag, dropdown, loadingHTML, errorHTML, emptyHTML, wordOr, downloadText, errorText } from './ax-ui.js';
|
|
16
|
+
import { agentMark, standingLabels, scopeTag, timeTag, dropdown, loadingHTML, errorHTML, emptyHTML, wordOr, downloadText, errorText, agentSections } from './ax-ui.js';
|
|
17
17
|
|
|
18
18
|
let life = null;
|
|
19
19
|
let searchTimer = 0;
|
|
@@ -100,7 +100,7 @@ export function renderLibrary(main, ctx) {
|
|
|
100
100
|
const { t, filters: f } = ctx;
|
|
101
101
|
setHTML(main, html`<section class="sx-place ax-place" aria-labelledby="ax-lib-title">
|
|
102
102
|
<header class="sx-place-head">
|
|
103
|
-
<h3 class="sx-place-title" id="ax-lib-title" tabindex="-1">${t('agentsStudio.rail.
|
|
103
|
+
<h3 class="sx-place-title" id="ax-lib-title" tabindex="-1">${t('agentsStudio.rail.agents')}</h3>
|
|
104
104
|
<span class="sx-search">${ICONS.search}<input type="search" id="ax-lib-search" value="${f.q}" placeholder="${t('agentsStudio.library.search')}" aria-label="${t('agentsStudio.library.search')}" autocomplete="off" spellcheck="false" data-autofocus></span>
|
|
105
105
|
<span class="sx-spacer"></span>
|
|
106
106
|
<span class="sx-seg" role="group" aria-label="${t('agentsStudio.library.layout')}">
|
|
@@ -110,6 +110,7 @@ export function renderLibrary(main, ctx) {
|
|
|
110
110
|
${ctx.caps.has('export') && ctx.agents.length ? html`<button type="button" class="sx-btn" data-act="export-all" title="${t('agentsStudio.library.exportAllHelp')}">${ICONS.download}${t('agentsStudio.library.exportAll')}</button>` : ''}
|
|
111
111
|
${ctx.canDraft ? html`<button type="button" class="sx-btn sx-btn--primary" data-act="new-agent">${ICONS.plus}${t('agentsStudio.library.newAgent')}</button>` : ''}
|
|
112
112
|
</header>
|
|
113
|
+
${agentSections(ctx)}
|
|
113
114
|
<div class="sx-place-head ax-filters" id="ax-lib-filters">${filtersHTML(ctx)}</div>
|
|
114
115
|
<div class="sx-place-scroll" id="ax-lib-list">${listHTML(ctx)}</div>
|
|
115
116
|
</section>`);
|