synabun 2.4.0 → 2.4.1

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 (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +25 -5
  4. package/browser-extension/engine.js +44 -13
  5. package/browser-extension/manifest.json +2 -2
  6. package/browser-extension/popup-strings.js +10 -4
  7. package/browser-extension/popup-view.js +1 -1
  8. package/browser-extension/popup.css +1 -0
  9. package/browser-extension/popup.html +4 -1
  10. package/browser-extension/popup.js +22 -10
  11. package/browser-extension/protocol.js +11 -5
  12. package/browser-extension/service-worker.js +8 -0
  13. package/docs/browser-extension-bridge.md +2 -2
  14. package/lib/data-home-files.js +45 -0
  15. package/lib/data-home-migration.js +34 -58
  16. package/mcp-server/dist/services/neural-interface.d.ts +1 -0
  17. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  18. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  19. package/mcp-server/dist/tools/agents.d.ts +3 -2
  20. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  21. package/mcp-server/dist/tools/agents.js +9 -7
  22. package/mcp-server/dist/tools/agents.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/services/neural-interface.ts +1 -0
  26. package/mcp-server/src/tools/agents.ts +8 -6
  27. package/neural-interface/i18n/en.json +3 -1
  28. package/neural-interface/i18n/pt-BR.json +3 -1
  29. package/neural-interface/lib/agents/builtins.json +207 -0
  30. package/neural-interface/lib/agents/registry.js +60 -15
  31. package/neural-interface/lib/agents/resolve.js +69 -10
  32. package/neural-interface/lib/assistant-brains/opencode.js +60 -11
  33. package/neural-interface/lib/assistant-dispatch.js +127 -24
  34. package/neural-interface/lib/assistant-persona.js +1 -1
  35. package/neural-interface/lib/assistant-router.js +50 -7
  36. package/neural-interface/lib/assistant-runtime.js +9 -1
  37. package/neural-interface/lib/backup-service.js +64 -105
  38. package/neural-interface/lib/browser-extension-adapter.js +24 -15
  39. package/neural-interface/lib/browser-extension-bridge.js +27 -4
  40. package/neural-interface/lib/native-loop-runtime.js +6 -7
  41. package/neural-interface/lib/opencode-build-preflight.js +12 -7
  42. package/neural-interface/lib/peer-identity.js +13 -8
  43. package/neural-interface/lib/session-cache-builder.js +41 -3
  44. package/neural-interface/lib/teams/scheduler.js +2 -2
  45. package/neural-interface/lib/teams/schema.js +1 -1
  46. package/neural-interface/package-lock.json +2 -2
  47. package/neural-interface/package.json +1 -1
  48. package/neural-interface/public/index.html +51 -0
  49. package/neural-interface/public/offline.html +4 -3
  50. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +2 -2
  51. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +1 -1
  52. package/neural-interface/public/shared/agents/studio/ax-ui.js +2 -2
  53. package/neural-interface/public/shared/api.js +2 -1
  54. package/neural-interface/public/shared/assistant/asst-render.js +1 -0
  55. package/neural-interface/public/shared/assistant/asst-route.js +3 -1
  56. package/neural-interface/public/shared/cc-dropdown.js +21 -15
  57. package/neural-interface/public/shared/html-shell.js +1 -0
  58. package/neural-interface/public/shared/owner-authority-view.js +4 -10
  59. package/neural-interface/public/shared/page-session.js +1 -1
  60. package/neural-interface/public/shared/settings/settings-ai-browser.js +5 -5
  61. package/neural-interface/public/shared/start-bridge.js +2 -2
  62. package/neural-interface/public/shared/styles.css +13 -1
  63. package/neural-interface/public/shared/ui-loading.js +72 -19
  64. package/neural-interface/public/shared/ui-native-loop-router.js +49 -20
  65. package/neural-interface/public/shared/ui-owner-authority.js +48 -25
  66. package/neural-interface/public/shared/ui-settings.js +10 -2
  67. package/neural-interface/public/shared/ui-sync.js +1 -0
  68. package/neural-interface/public/sw.js +4 -3
  69. package/neural-interface/public/variant/3d/main.js +13 -4
  70. package/neural-interface/server.js +34 -25
  71. package/npm-shrinkwrap.json +2 -2
  72. package/package.json +2 -1
@@ -1,6 +1,6 @@
1
1
  // Bump when offline.html changes shape: the new worker drops the old cache and
2
2
  // stores the page again (v13: a restart read from the supervisor's report).
3
- const CACHE_NAME = 'synabun-offline-v14';
3
+ const CACHE_NAME = 'synabun-offline-v15';
4
4
  const OFFLINE_URL = '/offline.html';
5
5
 
6
6
  self.addEventListener('install', (event) => {
@@ -22,11 +22,12 @@ self.addEventListener('activate', (event) => {
22
22
  self.addEventListener('fetch', (event) => {
23
23
  if (event.request.mode !== 'navigate') return;
24
24
  event.respondWith(
25
- fetch(event.request).then((response) => {
25
+ fetch(event.request, { signal: AbortSignal.timeout(12000) }).then(async (response) => {
26
+ if (response.status >= 500) return await caches.match(OFFLINE_URL) || response;
26
27
  // Server is up — silently refresh cached offline.html so it's always current
27
28
  caches.open(CACHE_NAME).then((cache) =>
28
29
  cache.add(new Request(OFFLINE_URL, { cache: 'reload' }))
29
- );
30
+ ).catch(() => {});
30
31
  return response;
31
32
  }).catch(() => caches.match(OFFLINE_URL))
32
33
  );
@@ -16,6 +16,7 @@ import { registerVariant } from '../../shared/registry.js';
16
16
  import { injectSharedHTML } from '../../shared/html-shell.js';
17
17
  import { migrateViewPreferences, normalizeViewUrl } from '../../shared/view-variant.js';
18
18
  import { initI18n, t } from '../../shared/i18n.js';
19
+ import { fetchHealth } from '../../shared/api.js';
19
20
  import { initLoading, showLoadingError } from '../../shared/ui-loading.js';
20
21
  import { loadMemoryList } from '../../shared/memory-list.js';
21
22
 
@@ -53,13 +54,21 @@ injectSharedHTML();
53
54
  // 3. THE LOADING OVERLAY, THEN THE APP
54
55
  // ═══════════════════════════════════════════
55
56
 
56
- // The overlay is the first frame. Its retry and Start Server buttons boot the app again once it has loaded; before
57
- // that (the app's modules could not be fetched: the server went away mid-load) the page loads again.
57
+ // The first frame in index.html owns the bounded retry for a failed module graph.
58
58
  let app = null;
59
- initLoading({ onInit: () => (app ? app.boot() : window.location.reload()) });
59
+ let moduleFailed = false;
60
+ const retryModule = () => window.dispatchEvent(new Event('synabun:startup-module-failed'));
61
+ initLoading({ onInit: () => {
62
+ if (app) app.boot();
63
+ else if (moduleFailed) retryModule();
64
+ // While the import is pending, app.js will run its own first boot.
65
+ } });
60
66
 
61
- import('./app.js').then((module) => { app = module; }, (err) => {
67
+ import('./app.js').then((module) => { app = module; }, async (err) => {
68
+ moduleFailed = true;
62
69
  console.error('Init error:', err);
70
+ const health = await fetchHealth().catch(() => null);
71
+ if (health?.ok === true && !health.restarting) { retryModule(); return; }
63
72
  showLoadingError(t('loading.serverOffline'), t('loading.serverNotRunning'), false, true);
64
73
  });
65
74
 
@@ -243,8 +243,10 @@ const nativeServeBoundary = createNativeServeBoundary({
243
243
  const cfg = loadBrowserConfig();
244
244
  const profiles = new Map(normalizeAgentProfiles(cfg).map(p => [p.envId, p]));
245
245
  const defaultId = moreLoginDefaultEnvId(cfg);
246
- if (defaultId) profiles.set(String(defaultId), { envId: String(defaultId) });
247
- for (const envId of nativePreflightProfiles) profiles.set(envId, { envId });
246
+ if (defaultId && !profiles.has(String(defaultId))) profiles.set(String(defaultId), { envId: String(defaultId) });
247
+ for (const envId of nativePreflightProfiles) {
248
+ if (!profiles.has(envId)) profiles.set(envId, { envId });
249
+ }
248
250
  const remote = [...profiles.values()].filter(p => !moreLogin.isLocalProfileId(p.envId));
249
251
  const liveProfiles = remote.length ? await reconcilePreflightProfiles(remote,
250
252
  () => moreLogin.listCompleteProfiles({ savedCfg: cfg, firstPageTimeout: 5000 }),
@@ -8387,6 +8389,7 @@ let _ocpVersion = null;
8387
8389
  let _ocpPassword = null;
8388
8390
  let _ocpProblem = null;
8389
8391
  let _ocpHistoryClearInProgress = false;
8392
+ let _ocpSessionCacheWarmup = null;
8390
8393
 
8391
8394
  // ── OpenCode V2 (clean-slate sidepanel) — client set & bridge ──
8392
8395
  const _ocpV2WsClients = new Set(); // all connected /ws/opencode-v2 clients
@@ -10495,6 +10498,9 @@ app.delete('/api/opencode/history', async (req, res) => {
10495
10498
  try { result.databaseBytesAfter = getOpenCodeHistoryStats({ dbPath, dataRoot: dirname(dbPath) }).databaseBytes; } catch { result.databaseBytesAfter = before.databaseBytes; }
10496
10499
 
10497
10500
  try {
10501
+ // A startup scan may still hold session rows it read before deletion.
10502
+ // Finish that pass before clearing the index so none can be put back.
10503
+ if (_ocpSessionCacheWarmup) await _ocpSessionCacheWarmup.catch(() => {});
10498
10504
  result.resumeCache = clearSessionCacheProvider('opencode');
10499
10505
  } catch (error) {
10500
10506
  result.warnings.push(`OpenCode Resume cache could not be cleared: ${error.message}`);
@@ -22596,6 +22602,7 @@ let _codexSessionCatalogRefresh = null;
22596
22602
  function getCodexSessionCatalogRefresh() {
22597
22603
  if (!_codexSessionCatalogRefresh) {
22598
22604
  _codexSessionCatalogRefresh = memoCache(() => rebuildCodexCache({
22605
+ background: true,
22599
22606
  accounts: loadCodexAccounts().accounts,
22600
22607
  projects: loadHookProjects(),
22601
22608
  }), { ttlMs: 15000 });
@@ -24640,11 +24647,12 @@ registerSkillEvalRoutes(app, {
24640
24647
  // and the routes of Agents Studio under /api/agents-studio/v1 (lib/agents-studio-api.js: approving, deleting and test
24641
24648
  // runs are the owner's page only, as the Skills Service's installs are). The older /api/agents routes above (isolated
24642
24649
  // agent processes) are another thing and stay as they are.
24643
- import { createAgentRegistry } from './lib/agents/registry.js';
24650
+ import { createAgentRegistry, loadBuiltinAgents } from './lib/agents/registry.js';
24644
24651
  import { createAgentResolver, setAgentResolver } from './lib/agents/resolve.js';
24645
24652
  import { registerStudioAttention } from './lib/studio-attention.js';
24646
24653
  import { registerAgentsStudioRoutes } from './lib/agents-studio-api.js';
24647
24654
  const agentDefinitions = createAgentRegistry({
24655
+ builtins: loadBuiltinAgents(),
24648
24656
  dir: resolve(DATA_HOME, 'data', 'agents'),
24649
24657
  // Every page of the owner hears of a change; invite guests do not (broadcastSync keeps `assistant:` to the owner).
24650
24658
  emit: (event) => { try { broadcastSync({ type: 'assistant:agents-changed', event }); } catch { /* no page is listening */ } },
@@ -26866,7 +26874,7 @@ app.get('/api/health', (req, res) => {
26866
26874
  // page showing the restart tells this one from the one that replaces it.
26867
26875
  bootId: SERVER_BOOT_ID,
26868
26876
  ...(_restartRequestedAt && !_stopOverridesRestart ? { restarting: true } : {}),
26869
- // Whether the owner's authority can be checked (lib/peer-identity.js): ok / degraded (macOS, the lookup fails:
26877
+ // Whether the owner's authority can be checked (lib/peer-identity.js): pending at boot / ok / degraded (macOS, the lookup fails:
26870
26878
  // the owner's actions answer 503 until it works) / unsupported (no lookup on this platform) / off
26871
26879
  // (SYNABUN_PEER_IDENTITY=off). The page's banner reads it (public/shared/ui-owner-authority.js).
26872
26880
  ownerAuthority: _peerIdentity.authorityState(),
@@ -29842,6 +29850,7 @@ function noteMoreLoginContextClose(session, sessionId, context = session?.contex
29842
29850
  // DeepSeek-Harness-style routing: the brain proposes, the router enforces the
29843
29851
  // session's route mode. Sinks reach the runtime/dispatcher lazily.
29844
29852
  const assistantRouter = createAssistantRouter({
29853
+ agents: agentDefinitionResolver,
29845
29854
  accountUsage,
29846
29855
  budget: assistantBudget,
29847
29856
  catalog: assistantCatalog,
@@ -29861,7 +29870,7 @@ function noteMoreLoginContextClose(session, sessionId, context = session?.contex
29861
29870
  computerApproved: (sessionId, payload) => _assistantRuntime?.routerComputerApproved?.(sessionId, payload),
29862
29871
  startHeld: (runId, target, meta) => _assistantDispatcher?.resolveRoute?.(runId, { target, ...meta }),
29863
29872
  // Asked before a card's pick is approved: a held run that would refuse it keeps the card open.
29864
- checkHeld: (runId, target) => _assistantDispatcher?.heldRouteRefusal?.(runId, target) || null,
29873
+ checkHeld: (runId, target, role) => _assistantDispatcher?.heldRouteRefusal?.(runId, target, role) || null,
29865
29874
  declineHeld: (runId, reason) => _assistantDispatcher?.declineRoute?.(runId, { reason }),
29866
29875
  },
29867
29876
  log: (tag, message) => assistantLog(tag, message),
@@ -33418,6 +33427,7 @@ async function acquireSharedBrowserTab({ requestedBrowserSessionId = null, owner
33418
33427
  }
33419
33428
 
33420
33429
  if (!browserSessionId) {
33430
+ if (createError?.sharedPreflight) return createError;
33421
33431
  // The run's own profile (its pin, else the MoreLogin default) failed to start or connect in this run: from now on
33422
33432
  // it may not move to another profile (POST /api/morelogin/use answers 409 PROFILE_FAILED_NO_SWITCH) until that
33423
33433
  // profile connects again for it (below), the owner moves it, or it ends (lib/morelogin-profile-failures.js).
@@ -34941,6 +34951,10 @@ async function protectNativeServeContext(ctx, { deadline = Infinity, signal = nu
34941
34951
  // the serves it names (narrowed: never a token or a whole record).
34942
34952
  function browserStartFailure(err) {
34943
34953
  const out = { error: err?.message || String(err) };
34954
+ if (err?.sharedPreflight) {
34955
+ return { error: `Shared OpenCode build verification blocked browser acquisition. ${out.error}`,
34956
+ sharedPreflight: true, code: err.code, offenders: err.offenders.map(({ envId, reason }) => ({ envId, reason })) };
34957
+ }
34944
34958
  if (err?.code === 'NATIVE_SERVE_UNVERIFIED') { out.code = err.code; out.offenders = narrowOffenders(err.offenders); }
34945
34959
  if (err?.code === 'MORELOGIN_NOT_CHROMIUM' || err?.code === 'MORELOGIN_NOT_DEVTOOLS') out.code = err.code;
34946
34960
  // MoreLogin refused the start (a plan limit, …): the user has to act, a retry or another run hits the same answer.
@@ -39643,31 +39657,29 @@ const httpServer = app.listen(PORT, async () => {
39643
39657
  }, 2500);
39644
39658
 
39645
39659
  // Warm the session_cache + session_fts tables so the hybrid search has data
39646
- // on first keystroke. Each pass is synchronous and holds the main thread, so
39647
- // they run one per tick (requests are answered in between), and each only
39648
- // re-reads sessions that changed since the last start.
39649
- setTimeout(() => {
39660
+ // on first keystroke. The large history scans yield between sessions, and
39661
+ // a Codex catalog request shares the same refresh with this startup pass.
39662
+ setTimeout(async () => {
39650
39663
  const passes = [
39651
- () => {
39664
+ async () => {
39652
39665
  try {
39653
- const claude = rebuildClaudeCache();
39666
+ const claude = await rebuildClaudeCache({ background: true });
39654
39667
  if (claude.updated > 0) console.log(` Session cache (claude): indexed ${claude.updated}/${claude.sessions}`);
39655
39668
  } catch (err) { console.warn(' Session cache (claude) error:', err.message); }
39656
39669
  },
39657
- () => {
39670
+ async () => {
39658
39671
  try {
39659
- const codex = rebuildCodexCache({
39660
- accounts: loadCodexAccounts().accounts,
39661
- projects: loadHookProjects(),
39662
- });
39672
+ const codex = await refreshCodexSessionCatalog();
39663
39673
  if (codex.updated > 0) console.log(` Session cache (codex): indexed ${codex.updated}/${codex.sessions}`);
39664
39674
  } catch (err) { console.warn(' Session cache (codex) error:', err.message); }
39665
39675
  },
39666
- () => {
39676
+ async () => {
39667
39677
  try {
39668
- const oc = rebuildOpencodeCache({ getOpencodeDb });
39678
+ _ocpSessionCacheWarmup = rebuildOpencodeCache({ getOpencodeDb, background: true });
39679
+ const oc = await _ocpSessionCacheWarmup;
39669
39680
  if (oc.updated > 0) console.log(` Session cache (opencode): indexed ${oc.updated}/${oc.sessions}`);
39670
39681
  } catch (err) { console.warn(' Session cache (opencode) error:', err.message); }
39682
+ finally { _ocpSessionCacheWarmup = null; }
39671
39683
  },
39672
39684
  () => {
39673
39685
  const agy = refreshAntigravityCatalog({ force: true });
@@ -39676,13 +39688,10 @@ const httpServer = app.listen(PORT, async () => {
39676
39688
  setInterval(() => refreshAntigravityCatalog({ force: true }), 5 * 60 * 1000).unref?.();
39677
39689
  },
39678
39690
  ];
39679
- const next = () => {
39680
- const pass = passes.shift();
39681
- if (!pass) return;
39682
- pass();
39683
- setImmediate(next);
39684
- };
39685
- next();
39691
+ for (const pass of passes) {
39692
+ await new Promise(resolve => setImmediate(resolve));
39693
+ await pass();
39694
+ }
39686
39695
  }, 2000);
39687
39696
 
39688
39697
  // Auto-sync OpenClaw bridge if enabled
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "synabun",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "synabun",
9
- "version": "2.4.0",
9
+ "version": "2.4.1",
10
10
  "hasInstallScript": true,
11
11
  "license": "Apache-2.0",
12
12
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synabun",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "mcpName": "io.github.danilokhury/synabun",
5
5
  "description": "Local-first persistent vector memory, MCP tooling, and multi-agent workflows for AI assistants",
6
6
  "license": "Apache-2.0",
@@ -77,6 +77,7 @@
77
77
  "lib/external-tools.js",
78
78
  "lib/paths.d.ts",
79
79
  "lib/data-home-migration.js",
80
+ "lib/data-home-files.js",
80
81
  "lib/first-launch-protection.js",
81
82
  "lib/update-snapshot.js",
82
83
  "lib/runtime-dependencies.js",