synabun 2.3.0 → 2.4.0
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 +38 -0
- package/README.md +1 -1
- package/browser-extension/content.js +169 -0
- package/browser-extension/engine.js +477 -0
- package/browser-extension/icons/icon-128.png +0 -0
- package/browser-extension/icons/icon-16.png +0 -0
- package/browser-extension/icons/icon-32.png +0 -0
- package/browser-extension/icons/icon-48.png +0 -0
- package/browser-extension/icons/status-off-16.png +0 -0
- package/browser-extension/icons/status-off-32.png +0 -0
- package/browser-extension/icons/status-off-48.png +0 -0
- package/browser-extension/icons/status-on-16.png +0 -0
- package/browser-extension/icons/status-on-32.png +0 -0
- package/browser-extension/icons/status-on-48.png +0 -0
- package/browser-extension/manifest.json +56 -0
- package/browser-extension/popup-strings.js +244 -0
- package/browser-extension/popup-view.js +151 -0
- package/browser-extension/popup.css +165 -0
- package/browser-extension/popup.html +105 -0
- package/browser-extension/popup.js +347 -0
- package/browser-extension/protocol.js +226 -0
- package/browser-extension/service-worker.js +267 -0
- package/browser-extension/setup-content.js +36 -0
- package/browser-extension/tokens.css +326 -0
- package/docs/browser-extension-bridge.md +84 -0
- package/docs/whatsapp.md +1 -1
- package/mcp-server/dist/http.d.ts +2 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +9 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts +11 -0
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +38 -3
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.js +10 -3
- package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.js +7 -0
- package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +94 -3
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +168 -23
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/team-context.d.ts +18 -0
- package/mcp-server/dist/services/team-context.d.ts.map +1 -0
- package/mcp-server/dist/services/team-context.js +29 -0
- package/mcp-server/dist/services/team-context.js.map +1 -0
- package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
- package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +22 -6
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-list.js +4 -0
- package/mcp-server/dist/services/tool-list.js.map +1 -1
- package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
- package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-runtime.js +18 -1
- package/mcp-server/dist/services/tool-runtime.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
- package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
- package/mcp-server/dist/tools/agent-definition.js +483 -0
- package/mcp-server/dist/tools/agent-definition.js.map +1 -0
- package/mcp-server/dist/tools/agents.d.ts +91 -9
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +161 -20
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +70 -6
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/git-tools.d.ts +4 -2
- package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/git-tools.js +283 -2
- package/mcp-server/dist/tools/git-tools.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts +8 -2
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +22 -5
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/team.d.ts +32 -0
- package/mcp-server/dist/tools/team.d.ts.map +1 -0
- package/mcp-server/dist/tools/team.js +87 -0
- package/mcp-server/dist/tools/team.js.map +1 -0
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +9 -1
- package/mcp-server/src/index.ts +34 -4
- package/mcp-server/src/services/browser-route-flow.ts +12 -5
- package/mcp-server/src/services/codex-config-heal.ts +7 -0
- package/mcp-server/src/services/neural-interface.ts +190 -29
- package/mcp-server/src/services/team-context.ts +27 -0
- package/mcp-server/src/services/tool-catalog.ts +26 -8
- package/mcp-server/src/services/tool-list.ts +4 -0
- package/mcp-server/src/services/tool-runtime.ts +21 -2
- package/mcp-server/src/tools/agent-definition.ts +458 -0
- package/mcp-server/src/tools/agents.ts +175 -19
- package/mcp-server/src/tools/browser-advanced.ts +60 -6
- package/mcp-server/src/tools/git-tools.ts +249 -3
- package/mcp-server/src/tools/morelogin.ts +20 -5
- package/mcp-server/src/tools/team.ts +97 -0
- package/neural-interface/i18n/en.json +1174 -47
- package/neural-interface/i18n/pt-BR.json +1174 -47
- package/neural-interface/lib/account-usage.js +1 -1
- package/neural-interface/lib/agents/density.js +101 -0
- package/neural-interface/lib/agents/forge-host.js +223 -0
- package/neural-interface/lib/agents/native-export-targets.js +190 -0
- package/neural-interface/lib/agents/native-export.js +365 -0
- package/neural-interface/lib/agents/registry.js +840 -0
- package/neural-interface/lib/agents/resolve.js +544 -0
- package/neural-interface/lib/agents/schema.js +642 -0
- package/neural-interface/lib/agents/split.js +37 -0
- package/neural-interface/lib/agents-studio-api.js +591 -0
- package/neural-interface/lib/assistant-api.js +76 -7
- package/neural-interface/lib/assistant-catalog.js +2 -0
- package/neural-interface/lib/assistant-continuity.js +49 -0
- package/neural-interface/lib/assistant-dispatch.js +229 -102
- package/neural-interface/lib/assistant-persona.js +105 -8
- package/neural-interface/lib/assistant-route-gate.js +24 -9
- package/neural-interface/lib/assistant-router.js +384 -42
- package/neural-interface/lib/assistant-run-tail.js +151 -0
- package/neural-interface/lib/assistant-run-wait.js +183 -0
- package/neural-interface/lib/assistant-runtime.js +440 -93
- package/neural-interface/lib/assistant-task-prompt.js +11 -2
- package/neural-interface/lib/assistant-usage.js +3 -2
- package/neural-interface/lib/automation-approval.js +2 -2
- package/neural-interface/lib/browser-close-evidence.js +80 -0
- package/neural-interface/lib/browser-default.js +210 -0
- package/neural-interface/lib/browser-extension-adapter.js +255 -0
- package/neural-interface/lib/browser-extension-bridge.js +418 -0
- package/neural-interface/lib/browser-extension-folder.js +116 -0
- package/neural-interface/lib/browser-extension-setup.js +140 -0
- package/neural-interface/lib/browser-profile-choices.js +3 -3
- package/neural-interface/lib/browser-profiles.js +1 -1
- package/neural-interface/lib/browser-tool-policy.js +1 -1
- package/neural-interface/lib/claude-account-links.js +301 -0
- package/neural-interface/lib/claude-accounts.js +45 -20
- package/neural-interface/lib/claude-agent-bridge.js +142 -10
- package/neural-interface/lib/claude-model-catalog.js +6 -0
- package/neural-interface/lib/claude-panel-session.js +33 -0
- package/neural-interface/lib/cli-install-api.js +23 -0
- package/neural-interface/lib/codex-accounts.js +67 -24
- package/neural-interface/lib/coordination/README.md +384 -0
- package/neural-interface/lib/coordination/service.js +563 -0
- package/neural-interface/lib/coordination/store.js +1138 -0
- package/neural-interface/lib/db.js +22 -1
- package/neural-interface/lib/editor-completion-opencode.js +4 -3
- package/neural-interface/lib/effort-levels.js +10 -1
- package/neural-interface/lib/maritaca/opencode-proxy.js +7 -2
- package/neural-interface/lib/maritaca/opencode.js +35 -0
- package/neural-interface/lib/memory-list-page.js +49 -0
- package/neural-interface/lib/memory-list-stamp.js +60 -0
- package/neural-interface/lib/morelogin-outside-close.js +186 -0
- package/neural-interface/lib/morelogin-profile-failures.js +206 -0
- package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
- package/neural-interface/lib/morelogin.js +219 -7
- package/neural-interface/lib/native-loop-runtime.js +24 -1
- package/neural-interface/lib/opencode-build-preflight.js +116 -0
- package/neural-interface/lib/opencode-launch-error.js +13 -0
- package/neural-interface/lib/opencode-native-boundary.js +800 -84
- package/neural-interface/lib/opencode-serve-probe.js +426 -0
- package/neural-interface/lib/opencode-serve-records.js +14 -9
- package/neural-interface/lib/opencode-serve-scan.js +108 -0
- package/neural-interface/lib/page-session.js +1 -1
- package/neural-interface/lib/peer-identity.js +60 -21
- package/neural-interface/lib/process-identity.js +235 -7
- package/neural-interface/lib/request-gate.js +3 -0
- package/neural-interface/lib/screenshot-location.js +33 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
- package/neural-interface/lib/studio-attention.js +56 -0
- package/neural-interface/lib/teams/README.md +382 -0
- package/neural-interface/lib/teams/api.js +287 -0
- package/neural-interface/lib/teams/brief.js +185 -0
- package/neural-interface/lib/teams/claims.js +315 -0
- package/neural-interface/lib/teams/git.js +293 -0
- package/neural-interface/lib/teams/index.js +122 -0
- package/neural-interface/lib/teams/integration.js +580 -0
- package/neural-interface/lib/teams/landing.js +184 -0
- package/neural-interface/lib/teams/recovery.js +256 -0
- package/neural-interface/lib/teams/scheduler.js +1474 -0
- package/neural-interface/lib/teams/schema.js +559 -0
- package/neural-interface/lib/teams/state.js +181 -0
- package/neural-interface/lib/teams/test-runner.js +86 -0
- package/neural-interface/lib/teams/test-sandbox.js +99 -0
- package/neural-interface/lib/teams/worktrees.js +757 -0
- package/neural-interface/lib/tool-permission-choices.js +226 -0
- package/neural-interface/lib/whatsapp/cards.js +24 -10
- package/neural-interface/lib/worker-confinement.js +206 -6
- package/neural-interface/lib/worker-mcp-channel.js +38 -1
- package/neural-interface/package-lock.json +4 -2
- package/neural-interface/package.json +3 -1
- package/neural-interface/public/extension-setup.html +107 -0
- package/neural-interface/public/index.html +52 -12
- package/neural-interface/public/shared/agent-runtime-options.js +3 -1
- package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
- package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
- package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
- package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
- package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
- package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
- package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
- package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
- package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
- package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
- package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
- package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
- package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
- package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
- package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
- package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
- package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
- package/neural-interface/public/shared/agy/agy-panel.js +142 -28
- package/neural-interface/public/shared/agy/agy-styles.js +25 -5
- package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
- package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
- package/neural-interface/public/shared/assistant/asst-control.js +3 -0
- package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
- package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
- package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
- package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
- package/neural-interface/public/shared/assistant/asst-render.js +36 -6
- package/neural-interface/public/shared/assistant/asst-route.js +78 -12
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
- package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
- package/neural-interface/public/shared/assistant/asst-state.js +66 -1
- package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
- package/neural-interface/public/shared/assistant/route-identity.js +16 -0
- package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
- package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
- package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
- package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
- package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
- package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
- package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
- package/neural-interface/public/shared/code-copy.js +120 -0
- package/neural-interface/public/shared/constants.js +7 -0
- package/neural-interface/public/shared/context-menu-model.js +1 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
- package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
- package/neural-interface/public/shared/cp/cp-styles.js +9 -0
- package/neural-interface/public/shared/dom-change-flag.js +66 -0
- package/neural-interface/public/shared/dom-morph.js +124 -0
- package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
- package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
- package/neural-interface/public/shared/html-shell.js +33 -4
- package/neural-interface/public/shared/i18n.js +14 -1
- package/neural-interface/public/shared/idle-queue.js +78 -0
- package/neural-interface/public/shared/iface-config.js +227 -0
- package/neural-interface/public/shared/lazy-module.js +108 -0
- package/neural-interface/public/shared/memory-list.js +117 -0
- package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
- package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
- package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
- package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
- package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
- package/neural-interface/public/shared/opencode-verify-view.js +175 -0
- package/neural-interface/public/shared/schedules-view.js +2 -2
- package/neural-interface/public/shared/session-project-items.js +11 -0
- package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
- package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
- package/neural-interface/public/shared/settings/settings-ia.js +4 -2
- package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
- package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
- package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
- package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
- package/neural-interface/public/shared/sidepanel-shown.js +73 -0
- package/neural-interface/public/shared/storage.js +6 -1
- package/neural-interface/public/shared/studio-attention.js +83 -0
- package/neural-interface/public/shared/styles.css +713 -61
- package/neural-interface/public/shared/term-browser-tabs.js +34 -0
- package/neural-interface/public/shared/transcript-rows.js +334 -0
- package/neural-interface/public/shared/tray-auto-close.js +106 -0
- package/neural-interface/public/shared/ui-agents.js +97 -0
- package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
- package/neural-interface/public/shared/ui-automation-studio.js +3 -3
- package/neural-interface/public/shared/ui-claude-panel.js +162 -95
- package/neural-interface/public/shared/ui-code-copy.js +256 -0
- package/neural-interface/public/shared/ui-codex-panel.js +14 -10
- package/neural-interface/public/shared/ui-context-menu.js +1 -1
- package/neural-interface/public/shared/ui-file-explorer.js +2 -3
- package/neural-interface/public/shared/ui-games.js +1 -1
- package/neural-interface/public/shared/ui-loading.js +12 -1
- package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
- package/neural-interface/public/shared/ui-menubar.js +23 -0
- package/neural-interface/public/shared/ui-native-loop-router.js +1 -1
- package/neural-interface/public/shared/ui-navbar.js +15 -9
- package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
- package/neural-interface/public/shared/ui-opencode-verify.js +120 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
- package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
- package/neural-interface/public/shared/ui-sessions.js +3 -3
- package/neural-interface/public/shared/ui-settings-entry.js +55 -0
- package/neural-interface/public/shared/ui-settings.js +372 -402
- package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
- package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
- package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
- package/neural-interface/public/shared/ui-styleguide.js +10 -2
- package/neural-interface/public/shared/ui-sync.js +5 -0
- package/neural-interface/public/shared/ui-terminal.js +13 -9
- package/neural-interface/public/shared/ui-tooltip.js +28 -7
- package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
- package/neural-interface/public/shared/ui-tray-columns.js +375 -0
- package/neural-interface/public/shared/ui-whiteboard.js +51 -6
- package/neural-interface/public/shared/ui-worker-end.js +28 -1
- package/neural-interface/public/shared/ui-workspaces.js +13 -0
- package/neural-interface/public/shared/window-keys.js +71 -0
- package/neural-interface/public/variant/2d/main.js +2 -0
- package/neural-interface/public/variant/3d/app.js +620 -0
- package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
- package/neural-interface/public/variant/3d/main.js +21 -544
- package/neural-interface/public/variant/3d/map-controls.js +4 -2
- package/neural-interface/public/vendor/fonts/fonts.css +508 -0
- package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/manifest.json +142 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
- package/neural-interface/scripts/boot-graph.mjs +270 -0
- package/neural-interface/scripts/vendor-fonts.mjs +124 -0
- package/neural-interface/server.js +1164 -157
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -1
- package/skills/agent-forge/SKILL.md +182 -0
- package/skills/agent-forge/evals/evals.json +56 -0
- package/skills/agent-forge/references/definition-fields.md +61 -0
- package/skills/agent-forge/references/examples.md +105 -0
- package/skills/agent-forge/references/instructions.md +51 -0
- package/skills/agent-forge/references/review-and-export.md +84 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun — Run transcripts on disk (agent_read after the run)
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// A dispatched run's transcript tail lived in its live state only: once the worker ended, or the server restarted,
|
|
6
|
+
// agent_read format "tail" had nothing, and format "text" had the first 20,000 characters of the last message with
|
|
7
|
+
// no way to read the rest. This keeps, per run, in <dataDir>/run-tails/:
|
|
8
|
+
//
|
|
9
|
+
// <run>.tail.json the last transcript lines (the dispatcher's ring, bounded by lines and characters), written
|
|
10
|
+
// at most once a second while the run works and once more when it ends
|
|
11
|
+
// <run>.text.json the whole text of the run's last turn (bounded), written when the turn ends
|
|
12
|
+
//
|
|
13
|
+
// Both are plain files beside the registry, written whole through a temporary file and a rename. They are read
|
|
14
|
+
// only when asked (agent_read), never at start. A crash can cost the last second of tail lines, nothing else.
|
|
15
|
+
|
|
16
|
+
import { createHash } from 'node:crypto';
|
|
17
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
|
+
|
|
20
|
+
export const RUN_TAIL_LIMITS = Object.freeze({
|
|
21
|
+
flushMs: 1000,
|
|
22
|
+
// The last turn's text that is kept (a worker's report of several hundred thousand characters is still read whole, in pages).
|
|
23
|
+
textChars: 1_000_000,
|
|
24
|
+
// One answer of agent_read carries at most this much text; the rest is read with `offset`.
|
|
25
|
+
pageChars: 20_000,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9_.-]{0,119}$/;
|
|
29
|
+
/** A run id as a file name: itself when it is a plain name, else its digest (a test's id may hold anything). */
|
|
30
|
+
export function runFileName(runId) {
|
|
31
|
+
const id = String(runId || '');
|
|
32
|
+
return SAFE_ID.test(id) && !id.includes('..') ? id : `x${createHash('sha256').update(id).digest('hex').slice(0, 40)}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One page of a text.
|
|
37
|
+
* Without `offset` the answer is the END of the text, at most `maxChars` (what agent_read always returned); `offset`
|
|
38
|
+
* then says where that page starts, so the part before it can be asked for. With `offset` the page starts there and
|
|
39
|
+
* `nextOffset` is where the following one starts (null at the end).
|
|
40
|
+
* @returns {{ text: string, truncated: boolean, totalChars: number, offset: number, nextOffset: number|null }}
|
|
41
|
+
*/
|
|
42
|
+
export function pageText(value, { offset = null, maxChars = 4000 } = {}) {
|
|
43
|
+
const text = String(value ?? '');
|
|
44
|
+
const total = text.length;
|
|
45
|
+
const cap = Math.max(1, Math.floor(Number(maxChars)) || 4000);
|
|
46
|
+
if (offset === null || offset === undefined || offset === '') {
|
|
47
|
+
const start = Math.max(0, total - cap);
|
|
48
|
+
return { text: text.slice(start), truncated: start > 0, totalChars: total, offset: start, nextOffset: null };
|
|
49
|
+
}
|
|
50
|
+
const start = Math.max(0, Math.min(total, Math.floor(Number(offset)) || 0));
|
|
51
|
+
const page = text.slice(start, start + cap);
|
|
52
|
+
const end = start + page.length;
|
|
53
|
+
return { text: page, truncated: end < total, totalChars: total, offset: start, nextOffset: end < total ? end : null };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {object} options
|
|
58
|
+
* @param {string} options.dir <dataDir>/run-tails
|
|
59
|
+
* @param {object} [options.limits] overrides of RUN_TAIL_LIMITS
|
|
60
|
+
* @param {(tag: string, detail: any) => void} [options.log]
|
|
61
|
+
*/
|
|
62
|
+
export function createRunTailStore({ dir, limits: limitOverrides = {}, log = () => {} } = {}) {
|
|
63
|
+
if (!dir) throw new Error('createRunTailStore requires dir');
|
|
64
|
+
const limits = { ...RUN_TAIL_LIMITS, ...limitOverrides };
|
|
65
|
+
const dirty = new Map(); // runId → () => string[] (the run's ring now)
|
|
66
|
+
let timer = null;
|
|
67
|
+
let ready = false;
|
|
68
|
+
|
|
69
|
+
const tailPath = (runId) => join(dir, `${runFileName(runId)}.tail.json`);
|
|
70
|
+
const textPath = (runId) => join(dir, `${runFileName(runId)}.text.json`);
|
|
71
|
+
function ensureDir() {
|
|
72
|
+
if (ready) return;
|
|
73
|
+
mkdirSync(dir, { recursive: true });
|
|
74
|
+
ready = true;
|
|
75
|
+
}
|
|
76
|
+
function writeWhole(path, value) {
|
|
77
|
+
ensureDir();
|
|
78
|
+
const tmp = `${path}.${process.pid}.tmp`;
|
|
79
|
+
writeFileSync(tmp, JSON.stringify(value), 'utf8');
|
|
80
|
+
renameSync(tmp, path);
|
|
81
|
+
}
|
|
82
|
+
function readWhole(path) {
|
|
83
|
+
try { return existsSync(path) ? JSON.parse(readFileSync(path, 'utf8')) : null; } catch { return null; }
|
|
84
|
+
}
|
|
85
|
+
function writeTail(runId, lines) {
|
|
86
|
+
try { writeWhole(tailPath(runId), { runId: String(runId), updatedAt: new Date().toISOString(), lines: Array.isArray(lines) ? lines : [] }); }
|
|
87
|
+
catch (error) { try { log('assistant:run-tail-error', error?.message || String(error)); } catch { /* nothing to tell */ } }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The run's ring changed: its lines are written soon (once a second at most, however many lines arrive). */
|
|
91
|
+
function touch(runId, lines) {
|
|
92
|
+
if (!runId || typeof lines !== 'function') return;
|
|
93
|
+
dirty.set(String(runId), lines);
|
|
94
|
+
if (timer) return;
|
|
95
|
+
timer = setTimeout(() => { timer = null; flushAll(); }, limits.flushMs);
|
|
96
|
+
timer.unref?.();
|
|
97
|
+
}
|
|
98
|
+
/** Write one run's lines now (it ended, or the server goes down). `lines`: its ring, when the caller has it. */
|
|
99
|
+
function flush(runId, lines = null) {
|
|
100
|
+
const id = String(runId || '');
|
|
101
|
+
const read = dirty.get(id);
|
|
102
|
+
dirty.delete(id);
|
|
103
|
+
const value = Array.isArray(lines) ? lines : (read ? read() : null);
|
|
104
|
+
if (Array.isArray(value)) writeTail(id, value);
|
|
105
|
+
}
|
|
106
|
+
function flushAll() {
|
|
107
|
+
if (timer) { clearTimeout(timer); timer = null; }
|
|
108
|
+
for (const id of [...dirty.keys()]) flush(id);
|
|
109
|
+
}
|
|
110
|
+
/** The lines kept for a run that no longer lives in memory, oldest first ([] when nothing was kept). */
|
|
111
|
+
function readTail(runId) {
|
|
112
|
+
const row = readWhole(tailPath(runId));
|
|
113
|
+
return Array.isArray(row?.lines) ? row.lines.filter((line) => typeof line === 'string') : [];
|
|
114
|
+
}
|
|
115
|
+
/** Keep the whole text of a run's turn (bounded): what agent_read format "text" pages through. */
|
|
116
|
+
function saveText(runId, { turn = null, text = '' } = {}) {
|
|
117
|
+
const whole = String(text ?? '');
|
|
118
|
+
try {
|
|
119
|
+
writeWhole(textPath(runId), {
|
|
120
|
+
runId: String(runId), turn: Number.isFinite(Number(turn)) ? Number(turn) : null, updatedAt: new Date().toISOString(),
|
|
121
|
+
chars: whole.length, cut: whole.length > limits.textChars, text: whole.slice(0, limits.textChars),
|
|
122
|
+
});
|
|
123
|
+
} catch (error) { try { log('assistant:run-tail-error', error?.message || String(error)); } catch { /* nothing to tell */ } }
|
|
124
|
+
}
|
|
125
|
+
/** → { turn, text, chars, cut } or null when no text was kept. */
|
|
126
|
+
function readText(runId) {
|
|
127
|
+
const row = readWhole(textPath(runId));
|
|
128
|
+
return row && typeof row.text === 'string' ? { turn: row.turn ?? null, text: row.text, chars: Number(row.chars) || row.text.length, cut: row.cut === true } : null;
|
|
129
|
+
}
|
|
130
|
+
/** The run left the registry: its files go. */
|
|
131
|
+
function remove(runId) {
|
|
132
|
+
dirty.delete(String(runId || ''));
|
|
133
|
+
for (const path of [tailPath(runId), textPath(runId)]) { try { rmSync(path, { force: true }); } catch { /* gone already */ } }
|
|
134
|
+
}
|
|
135
|
+
/** Files of runs the registry no longer has go (called once at start, with the runs it loaded). */
|
|
136
|
+
function sweep(keep) {
|
|
137
|
+
const names = new Set([...keep].map((runId) => runFileName(runId)));
|
|
138
|
+
let files = [];
|
|
139
|
+
try { files = readdirSync(dir); } catch { return 0; }
|
|
140
|
+
let removed = 0;
|
|
141
|
+
for (const file of files) {
|
|
142
|
+
const match = /^(.+)\.(tail|text)\.json$/.exec(file);
|
|
143
|
+
// A temporary file a crash left behind goes too.
|
|
144
|
+
if (match ? !names.has(match[1]) : /\.tmp$/.test(file)) { try { rmSync(join(dir, file), { force: true }); removed += 1; } catch { /* next start */ } }
|
|
145
|
+
}
|
|
146
|
+
return removed;
|
|
147
|
+
}
|
|
148
|
+
function close() { flushAll(); }
|
|
149
|
+
|
|
150
|
+
return { dir, limits, touch, flush, flushAll, readTail, saveText, readText, remove, sweep, close };
|
|
151
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun — Assistant run waits (agent_wait)
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// The barrier behind agent_wait: block until one run, several runs or a whole workflow are idle, terminal, or
|
|
6
|
+
// have something to say. The dispatcher calls `notify()` after every state change (its emit); nothing polls.
|
|
7
|
+
//
|
|
8
|
+
// until 'idle' / 'terminal' read the runs' state, as they always did.
|
|
9
|
+
// until 'event' waits on typed events of the coordination log (lib/coordination/service.js):
|
|
10
|
+
// run.result, run.needs_input, run.permission, run.failed, run.stalled, … It used to
|
|
11
|
+
// fire on any change of a run's version (a turn starting, a tool list, a memory).
|
|
12
|
+
// The answer carries the events with their seq and a `cursor`; a caller that passes
|
|
13
|
+
// the cursor back as `afterSeq` gets exactly what came after it, also when an
|
|
14
|
+
// answer was lost on the way (the log is read, nothing is consumed).
|
|
15
|
+
//
|
|
16
|
+
// A workflow's wait follows the workflow: its runs are looked up at every check, so a run dispatched into it after
|
|
17
|
+
// the wait began is waited for too.
|
|
18
|
+
|
|
19
|
+
import { RUN_EVENT_KINDS, RUN_WAIT_KINDS } from './coordination/service.js';
|
|
20
|
+
|
|
21
|
+
export const RUN_WAIT_LIMITS = Object.freeze({
|
|
22
|
+
// Runs one wait follows (it used to stop at 20 and silently ignore the rest).
|
|
23
|
+
maxRuns: 200,
|
|
24
|
+
// Events one answer carries; more are read with the cursor.
|
|
25
|
+
maxEvents: 50,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {object} deps
|
|
30
|
+
* @param {Map<string, object>} deps.entries the dispatcher's registry (runId → entry)
|
|
31
|
+
* @param {(entry: object) => object} deps.view an entry as callers see it
|
|
32
|
+
* @param {(entry: object) => boolean} deps.isTerminal ended, and its cause is no longer being judged
|
|
33
|
+
* @param {object} deps.coordination createCoordinationService()
|
|
34
|
+
* @param {() => number} [deps.now]
|
|
35
|
+
* @param {() => number} [deps.waitCapMs] the longest one call may block
|
|
36
|
+
* @param {(code: string, message: string, extra?: object) => Error} deps.fail
|
|
37
|
+
*/
|
|
38
|
+
export function createRunWaits({ entries, view, isTerminal, coordination, now = Date.now, waitCapMs = () => 120_000, fail }) {
|
|
39
|
+
const waiters = new Set(); // { check(): boolean, resolve() }
|
|
40
|
+
|
|
41
|
+
/** A run changed: every wait looks again. */
|
|
42
|
+
function notify() {
|
|
43
|
+
for (const waiter of [...waiters]) {
|
|
44
|
+
try { if (waiter.check()) { waiters.delete(waiter); waiter.resolve(); } } catch { /* a wait that cannot look keeps waiting for its timeout */ }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function satisfies(entry, until) {
|
|
49
|
+
if (!entry) return true;
|
|
50
|
+
// A failed run whose cause is still being judged is not final yet: its 'failed' event (with the cause and the
|
|
51
|
+
// matching escalation) follows within the surface timeout.
|
|
52
|
+
const terminal = isTerminal(entry);
|
|
53
|
+
if (until === 'terminal') return terminal;
|
|
54
|
+
// 'idle' (default): the run is not busy — idle, awaiting a decision (a permission or the user's model choice),
|
|
55
|
+
// or finished.
|
|
56
|
+
return entry.state === 'idle' || entry.state === 'awaiting_permission' || entry.state === 'awaiting_route' || terminal;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function kindsOf(kinds) {
|
|
60
|
+
if (kinds === null || kinds === undefined) return [...RUN_WAIT_KINDS];
|
|
61
|
+
const list = [...new Set((Array.isArray(kinds) ? kinds : [kinds]).map((kind) => String(kind || '').trim()).filter(Boolean))];
|
|
62
|
+
if (!list.length) return [...RUN_WAIT_KINDS];
|
|
63
|
+
const unknown = list.filter((kind) => !RUN_EVENT_KINDS.includes(kind));
|
|
64
|
+
if (unknown.length) throw fail('INVALID_KINDS', `Unknown event kind${unknown.length === 1 ? '' : 's'} ${unknown.join(', ')}. Use: ${RUN_EVENT_KINDS.join(', ')}.`, { status: 400, kinds: RUN_EVENT_KINDS });
|
|
65
|
+
return list;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {object} options
|
|
70
|
+
* @param {string} [options.runId]
|
|
71
|
+
* @param {string[]} [options.runIds]
|
|
72
|
+
* @param {string} [options.workflowId] every run of the workflow, also those added while this waits
|
|
73
|
+
* @param {string} [options.assistantSessionId] narrows a workflow to that session's runs
|
|
74
|
+
* @param {'idle'|'terminal'|'event'} [options.until]
|
|
75
|
+
* @param {'all'|'any'} [options.mode] default: 'any' for until 'event' (the next event of any of the runs), else 'all'
|
|
76
|
+
* @param {number} [options.timeoutMs]
|
|
77
|
+
* @param {number} [options.afterSeq] until 'event': only events after this seq (a cursor from an earlier answer)
|
|
78
|
+
* @param {string[]} [options.kinds] until 'event': only these kinds (default: everything but progress)
|
|
79
|
+
* @param {string} [options.unseenFor] until 'event', no afterSeq: start at the oldest event of these runs
|
|
80
|
+
* this Assistant session has not been told yet (its brain is asking)
|
|
81
|
+
*/
|
|
82
|
+
async function wait({ runId = null, runIds = null, workflowId = null, assistantSessionId = null, until = 'idle', mode: askedMode = null, timeoutMs = 30_000, afterSeq = null, kinds = null, unseenFor = null } = {}) {
|
|
83
|
+
// An event wait asks for the next event of any of its runs unless it says "all"; a state wait is a barrier.
|
|
84
|
+
const mode = askedMode === 'any' || askedMode === 'all' ? askedMode : (until === 'event' ? 'any' : 'all');
|
|
85
|
+
const explicit = [...new Set([...(Array.isArray(runIds) ? runIds : []), ...(runId ? [runId] : [])].filter(Boolean).map(String))];
|
|
86
|
+
if (explicit.length > RUN_WAIT_LIMITS.maxRuns) throw fail('TOO_MANY_RUNS', `One wait follows at most ${RUN_WAIT_LIMITS.maxRuns} runs; wait for a workflow_id instead of listing them.`, { status: 400, limit: RUN_WAIT_LIMITS.maxRuns });
|
|
87
|
+
let overflow = 0;
|
|
88
|
+
// Looked up at every check: a run dispatched into the workflow after the wait began belongs to it.
|
|
89
|
+
const members = () => {
|
|
90
|
+
if (!workflowId) return explicit;
|
|
91
|
+
const flow = [];
|
|
92
|
+
for (const entry of entries.values()) {
|
|
93
|
+
if (entry.workflowId === workflowId && (!assistantSessionId || entry.assistantSessionId === assistantSessionId)) flow.push(entry.runId);
|
|
94
|
+
}
|
|
95
|
+
const all = [...new Set([...explicit, ...flow])];
|
|
96
|
+
overflow = Math.max(0, all.length - RUN_WAIT_LIMITS.maxRuns);
|
|
97
|
+
return all.slice(0, RUN_WAIT_LIMITS.maxRuns);
|
|
98
|
+
};
|
|
99
|
+
let ids = members();
|
|
100
|
+
if (!ids.length) throw fail('RUN_IDS_REQUIRED', 'runId, runIds or workflowId is required');
|
|
101
|
+
for (const id of ids) if (!entries.has(id)) throw fail('RUN_NOT_FOUND', `Unknown run ${id}`, { status: 404 });
|
|
102
|
+
const started = now();
|
|
103
|
+
const budget = Math.max(1000, Math.min(Number(waitCapMs()) || 120_000, Number(timeoutMs) || 30_000));
|
|
104
|
+
|
|
105
|
+
const typed = until === 'event';
|
|
106
|
+
const cursorGiven = typed && afterSeq !== null && afterSeq !== undefined;
|
|
107
|
+
const wanted = typed ? kindsOf(kinds) : null;
|
|
108
|
+
let from = 0;
|
|
109
|
+
if (typed) {
|
|
110
|
+
if (cursorGiven) {
|
|
111
|
+
from = Number(afterSeq);
|
|
112
|
+
if (!Number.isInteger(from) || from < 0) throw fail('INVALID_CURSOR', 'after_seq is a whole number from 0: the cursor of an earlier agent_wait answer.', { status: 400 });
|
|
113
|
+
} else {
|
|
114
|
+
from = lastSeq();
|
|
115
|
+
// The brain itself asks: what it has not been told yet counts, though it happened before this call.
|
|
116
|
+
if (unseenFor) from = Math.min(from, unseenStart(String(unseenFor), ids, from));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const eventsNow = () => {
|
|
120
|
+
if (!typed) return [];
|
|
121
|
+
try { return coordination.runEvents({ runIds: ids, afterSeq: from, kinds: wanted, limit: RUN_WAIT_LIMITS.maxEvents }); }
|
|
122
|
+
catch { return []; }
|
|
123
|
+
};
|
|
124
|
+
const satisfied = (events) => ids.filter((id) => {
|
|
125
|
+
const entry = entries.get(id);
|
|
126
|
+
if (!typed) return satisfies(entry, until);
|
|
127
|
+
if (!entry || isTerminal(entry)) return true;
|
|
128
|
+
// Without a cursor a run that waits for a decision answers at once, as it always did; with one, only what is
|
|
129
|
+
// new does (the request the caller already saw must not make every call return).
|
|
130
|
+
if (!cursorGiven && (entry.state === 'awaiting_permission' || entry.state === 'awaiting_route')) return true;
|
|
131
|
+
return events.some((event) => event.runId === id);
|
|
132
|
+
});
|
|
133
|
+
const check = () => {
|
|
134
|
+
ids = members();
|
|
135
|
+
const done = satisfied(eventsNow());
|
|
136
|
+
return mode === 'any' ? done.length > 0 : done.length === ids.length;
|
|
137
|
+
};
|
|
138
|
+
if (!check()) {
|
|
139
|
+
await new Promise((resolveWait) => {
|
|
140
|
+
const waiter = { check, resolve: () => { clearTimeout(timer); resolveWait(); } };
|
|
141
|
+
const timer = setTimeout(() => { waiters.delete(waiter); resolveWait(); }, budget);
|
|
142
|
+
timer.unref?.();
|
|
143
|
+
waiters.add(waiter);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
ids = members();
|
|
147
|
+
const events = eventsNow();
|
|
148
|
+
const done = satisfied(events);
|
|
149
|
+
const pendingIds = ids.filter((id) => !done.includes(id));
|
|
150
|
+
const timedOut = !(mode === 'any' ? done.length > 0 : done.length === ids.length);
|
|
151
|
+
const out = {
|
|
152
|
+
ok: true, timedOut, waitedMs: now() - started, until, mode,
|
|
153
|
+
done: done.map((id) => view(entries.get(id))),
|
|
154
|
+
pending: pendingIds.map((id) => view(entries.get(id))),
|
|
155
|
+
needsInput: ids.map((id) => entries.get(id)).filter((e) => e?.lastResult?.status === 'needs_input' && e.state === 'idle').map((e) => ({ runId: e.runId, question: e.lastResult.question })),
|
|
156
|
+
permissions: ids.flatMap((id) => (entries.get(id)?.pending || []).map((request) => ({ runId: id, ...request }))),
|
|
157
|
+
};
|
|
158
|
+
if (typed) {
|
|
159
|
+
out.events = events;
|
|
160
|
+
// Pass it back as after_seq to go on from here. A full page stops at its last event: more may follow.
|
|
161
|
+
out.cursor = events.length >= RUN_WAIT_LIMITS.maxEvents ? events[events.length - 1].seq : Math.max(from, lastSeq());
|
|
162
|
+
} else {
|
|
163
|
+
out.cursor = lastSeq();
|
|
164
|
+
}
|
|
165
|
+
if (overflow) out.notWaitedFor = overflow;
|
|
166
|
+
return out;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function lastSeq() {
|
|
170
|
+
try { return Number(coordination.lastSeq()) || 0; } catch { return 0; }
|
|
171
|
+
}
|
|
172
|
+
/** Just before the oldest event of these runs the session's brain was not told yet (`fallback` when there is none). */
|
|
173
|
+
function unseenStart(sessionId, ids, fallback) {
|
|
174
|
+
try {
|
|
175
|
+
const wantedRuns = new Set(ids);
|
|
176
|
+
const { items } = coordination.mailbox.pending(sessionId, { limit: 1000, peek: true });
|
|
177
|
+
const seqs = items.filter((item) => item.run?.runId && wantedRuns.has(String(item.run.runId))).map((item) => Number(item.seq)).filter((seq) => Number.isFinite(seq));
|
|
178
|
+
return seqs.length ? Math.min(...seqs) - 1 : fallback;
|
|
179
|
+
} catch { return fallback; }
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return { wait, notify, satisfies, pending: () => waiters.size };
|
|
183
|
+
}
|