synabun 2.4.1 → 2.4.3
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 +50 -0
- package/README.md +1 -1
- package/docs/browser-extension-bridge.md +46 -6
- package/lib/data-home-files.js +4 -2
- package/lib/first-launch-protection.js +8 -2
- package/lib/release-npm-ci.mjs +23 -1
- package/lib/update-snapshot.js +11 -4
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +25 -2
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +62 -17
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-bench.d.ts +22 -22
- package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-maintenance.js +34 -45
- package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
- package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
- package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-copy.js +467 -0
- package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.js +60 -0
- package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-retrieval.js +188 -40
- package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
- package/mcp-server/dist/services/memory-schema.d.ts +58 -2
- package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-schema.js +190 -13
- package/mcp-server/dist/services/memory-schema.js.map +1 -1
- package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-sessions.js +56 -20
- package/mcp-server/dist/services/memory-sessions.js.map +1 -1
- package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-verification.js +8 -5
- package/mcp-server/dist/services/memory-verification.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +5 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +19 -2
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.js +145 -0
- package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
- package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
- package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
- package/mcp-server/dist/services/sqlite-write.js +94 -0
- package/mcp-server/dist/services/sqlite-write.js.map +1 -0
- package/mcp-server/dist/services/sqlite.d.ts +39 -0
- package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
- package/mcp-server/dist/services/sqlite.js +249 -8
- package/mcp-server/dist/services/sqlite.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +32 -10
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe.js +9 -7
- package/mcp-server/dist/services/typesafe.js.map +1 -1
- package/mcp-server/dist/services/vector-cache.d.ts +32 -0
- package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
- package/mcp-server/dist/services/vector-cache.js +161 -8
- package/mcp-server/dist/services/vector-cache.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +11 -7
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +27 -9
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +10 -3
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
- package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-extension-setup.js +29 -0
- package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-interact.js +6 -1
- package/mcp-server/dist/tools/browser-interact.js.map +1 -1
- package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
- package/mcp-server/package-lock.json +5 -5
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +20 -2
- package/mcp-server/src/index.ts +59 -17
- package/mcp-server/src/services/memory-maintenance.ts +31 -28
- package/mcp-server/src/services/memory-migration-copy.ts +419 -0
- package/mcp-server/src/services/memory-migration-worker.ts +55 -0
- package/mcp-server/src/services/memory-retrieval.ts +173 -32
- package/mcp-server/src/services/memory-schema.ts +194 -12
- package/mcp-server/src/services/memory-sessions.ts +54 -21
- package/mcp-server/src/services/memory-verification.ts +7 -4
- package/mcp-server/src/services/neural-interface.ts +22 -2
- package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
- package/mcp-server/src/services/retrieval-reader.ts +131 -0
- package/mcp-server/src/services/sqlite-write.ts +60 -0
- package/mcp-server/src/services/sqlite.ts +246 -8
- package/mcp-server/src/services/typesafe-config.ts +25 -6
- package/mcp-server/src/services/typesafe.ts +9 -7
- package/mcp-server/src/services/vector-cache.ts +154 -9
- package/mcp-server/src/tools/agents.ts +26 -9
- package/mcp-server/src/tools/browser-advanced.ts +10 -3
- package/mcp-server/src/tools/browser-extension-setup.ts +36 -0
- package/mcp-server/src/tools/browser-interact.ts +5 -1
- package/neural-interface/i18n/en.json +313 -2
- package/neural-interface/i18n/pt-BR.json +321 -10
- package/neural-interface/lib/agents/split.js +32 -4
- package/neural-interface/lib/assistant-api.js +52 -8
- package/neural-interface/lib/assistant-brains/claude.js +2 -0
- package/neural-interface/lib/assistant-brains/opencode.js +121 -7
- package/neural-interface/lib/assistant-catalog.js +2 -2
- package/neural-interface/lib/assistant-config.js +0 -7
- package/neural-interface/lib/assistant-dispatch.js +281 -95
- package/neural-interface/lib/assistant-envelope.js +40 -0
- package/neural-interface/lib/assistant-persona.js +16 -4
- package/neural-interface/lib/assistant-pricing.js +65 -14
- package/neural-interface/lib/assistant-router.js +131 -47
- package/neural-interface/lib/assistant-run-wait.js +45 -28
- package/neural-interface/lib/assistant-runtime.js +133 -42
- package/neural-interface/lib/backup-contents.js +158 -0
- package/neural-interface/lib/backup-crypto-io.js +330 -0
- package/neural-interface/lib/backup-crypto-worker.js +130 -0
- package/neural-interface/lib/backup-crypto.js +525 -0
- package/neural-interface/lib/backup-download.js +268 -0
- package/neural-interface/lib/backup-encryption.js +318 -0
- package/neural-interface/lib/backup-groups.js +287 -0
- package/neural-interface/lib/backup-restore-session.js +176 -0
- package/neural-interface/lib/backup-restore-stage.js +60 -0
- package/neural-interface/lib/backup-service.js +788 -233
- package/neural-interface/lib/backup-zip-reader.js +30 -18
- package/neural-interface/lib/backup-zip-writer.js +34 -10
- package/neural-interface/lib/browser-extension-adapter.js +89 -15
- package/neural-interface/lib/browser-extension-archive.js +149 -0
- package/neural-interface/lib/browser-extension-bridge.js +24 -10
- package/neural-interface/lib/browser-extension-folder.js +596 -76
- package/neural-interface/lib/browser-extension-package.js +200 -0
- package/neural-interface/lib/browser-extension-pin.js +84 -0
- package/neural-interface/lib/browser-extension-pin.json +33 -0
- package/{browser-extension/protocol.js → neural-interface/lib/browser-extension-protocol.js} +91 -6
- package/neural-interface/lib/browser-extension-setup.js +105 -18
- package/neural-interface/lib/claude-agent-bridge.js +1 -0
- package/neural-interface/lib/claude-session-cleanup.js +5 -1
- package/neural-interface/lib/cli-install.js +23 -3
- package/neural-interface/lib/cli-update-planner.js +171 -9
- package/neural-interface/lib/client-diagnostics.js +42 -0
- package/neural-interface/lib/confined-fs.js +7 -2
- package/neural-interface/lib/coordination/README.md +8 -2
- package/neural-interface/lib/coordination/contract.js +161 -0
- package/neural-interface/lib/coordination/database.js +999 -0
- package/neural-interface/lib/coordination/operations.js +436 -0
- package/neural-interface/lib/coordination/service.js +68 -537
- package/neural-interface/lib/coordination/storage-worker.js +101 -0
- package/neural-interface/lib/coordination/store.js +219 -1111
- package/neural-interface/lib/db.js +70 -32
- package/neural-interface/lib/health-count.js +37 -0
- package/neural-interface/lib/loop-stall.js +139 -0
- package/neural-interface/lib/maritaca/client.js +2 -2
- package/neural-interface/lib/maritaca/models.js +12 -17
- package/neural-interface/lib/maritaca/opencode.js +4 -2
- package/neural-interface/lib/memory-api.js +9 -1
- package/neural-interface/lib/memory-session-capture.js +42 -10
- package/neural-interface/lib/memory-store-gate.js +313 -0
- package/neural-interface/lib/memory-store-migrate.js +65 -0
- package/neural-interface/lib/memory-timers.js +7 -7
- package/neural-interface/lib/native-loop-providers.js +23 -17
- package/neural-interface/lib/native-loop-runtime.js +48 -9
- package/neural-interface/lib/opencode-build-preflight.js +18 -1
- package/neural-interface/lib/opencode-native-boundary.js +69 -8
- package/neural-interface/lib/opencode-provider-view.js +14 -3
- package/neural-interface/lib/opencode-shell-read.js +107 -0
- package/neural-interface/lib/opencode-stop-failures.js +40 -0
- package/neural-interface/lib/opencode-turn-release.js +173 -0
- package/neural-interface/lib/opencode-v2-client.js +4 -1
- package/neural-interface/lib/opencode-v2-ws-requests.js +65 -1
- package/neural-interface/lib/opencode2-client.js +343 -7
- package/neural-interface/lib/opencode2-translate.js +161 -4
- package/neural-interface/lib/recall-impact.js +122 -0
- package/neural-interface/lib/scratch-evidence.js +420 -0
- package/neural-interface/lib/scratch-process-guard.js +139 -0
- package/neural-interface/lib/scratch-references.js +279 -0
- package/neural-interface/lib/scratch-retention-core.js +385 -0
- package/neural-interface/lib/scratch-retention-worker.js +37 -0
- package/neural-interface/lib/scratch-retention.js +151 -0
- package/neural-interface/lib/session-cache-builder.js +31 -43
- package/neural-interface/lib/session-cache-worker.js +157 -0
- package/neural-interface/lib/session-indexer.js +28 -21
- package/neural-interface/lib/session-search-index.js +85 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
- package/neural-interface/lib/style-guide/store.js +43 -3
- package/neural-interface/lib/system-restore.js +50 -0
- package/neural-interface/lib/teams/api.js +15 -6
- package/neural-interface/lib/teams/claims.js +67 -31
- package/neural-interface/lib/teams/index.js +7 -7
- package/neural-interface/lib/teams/integration.js +40 -40
- package/neural-interface/lib/teams/landing.js +6 -6
- package/neural-interface/lib/teams/recovery.js +24 -23
- package/neural-interface/lib/teams/scheduler.js +194 -95
- package/neural-interface/lib/teams/state.js +14 -14
- package/neural-interface/lib/teams/worktrees.js +27 -27
- package/neural-interface/lib/terminal-token-redaction.js +83 -0
- package/neural-interface/lib/whatsapp/bridge.js +54 -7
- package/neural-interface/lib/worker-confinement.js +47 -2
- package/neural-interface/lib/worker-mcp-channel.js +2 -0
- package/neural-interface/lib/worker-resume.js +5 -0
- package/neural-interface/lib/worker-stop.js +86 -0
- package/neural-interface/package-lock.json +5 -5
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +5 -2
- package/neural-interface/public/index.html +233 -24
- package/neural-interface/public/onboarding.html +259 -34
- package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
- package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
- package/neural-interface/public/shared/agy/agy-options.js +11 -0
- package/neural-interface/public/shared/agy/agy-panel.js +67 -20
- package/neural-interface/public/shared/agy/agy-styles.js +14 -12
- package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
- package/neural-interface/public/shared/api.js +1 -1
- package/neural-interface/public/shared/assistant/asst-api.js +28 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
- package/neural-interface/public/shared/assistant/asst-control.js +2 -0
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
- package/neural-interface/public/shared/assistant/asst-panel.js +87 -3
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +27 -0
- package/neural-interface/public/shared/assistant/asst-render.js +243 -44
- package/neural-interface/public/shared/assistant/asst-route.js +100 -21
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
- package/neural-interface/public/shared/assistant/asst-shell-logic.js +200 -0
- package/neural-interface/public/shared/assistant/asst-shell.js +111 -0
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
- package/neural-interface/public/shared/assistant/asst-state.js +11 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +11 -23
- package/neural-interface/public/shared/assistant/route-identity.js +2 -1
- package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
- package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +54 -9
- package/neural-interface/public/shared/client-diagnostics.js +94 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-styles.js +1 -1
- package/neural-interface/public/shared/effort-i18n.js +118 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +10 -4
- package/neural-interface/public/shared/extension-setup/es-view.js +25 -10
- package/neural-interface/public/shared/html-shell.js +4 -52
- package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
- package/neural-interface/public/shared/memory-store-wait.js +52 -0
- package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
- package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
- package/neural-interface/public/shared/mtc/mtc-panel.js +25 -3
- package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +5 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +152 -8
- package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +53 -4
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +52 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +22 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-block.js +165 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +346 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-shell.js +108 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +49 -3
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +67 -93
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +20 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +7 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +7 -2
- package/neural-interface/public/shared/output-format.js +294 -0
- package/neural-interface/public/shared/provider-icons.js +6 -0
- package/neural-interface/public/shared/schedules-view.js +2 -1
- package/neural-interface/public/shared/server-presence.js +77 -0
- package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
- package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
- package/neural-interface/public/shared/settings/settings-browser-extension.js +54 -12
- package/neural-interface/public/shared/settings/settings-ia.js +1 -1
- package/neural-interface/public/shared/shell-stop-view.js +83 -0
- package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
- package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
- package/neural-interface/public/shared/studio-attention.js +6 -0
- package/neural-interface/public/shared/styles.css +341 -437
- package/neural-interface/public/shared/tour/tour-actor.js +14 -3
- package/neural-interface/public/shared/transcript-rows.js +28 -3
- package/neural-interface/public/shared/tray-auto-close.js +49 -6
- package/neural-interface/public/shared/ui-agents.js +1 -2
- package/neural-interface/public/shared/ui-automation-studio.js +168 -108
- package/neural-interface/public/shared/ui-claude-panel.js +62 -65
- package/neural-interface/public/shared/ui-loading.js +124 -17
- package/neural-interface/public/shared/ui-native-loop-router.js +52 -0
- package/neural-interface/public/shared/ui-navbar.js +2 -1
- package/neural-interface/public/shared/ui-output.js +533 -0
- package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
- package/neural-interface/public/shared/ui-scroll-follow.js +101 -6
- package/neural-interface/public/shared/ui-sessions.js +2 -2
- package/neural-interface/public/shared/ui-settings-entry.js +18 -0
- package/neural-interface/public/shared/ui-settings.js +224 -65
- package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
- package/neural-interface/public/shared/ui-tooltip.js +16 -0
- package/neural-interface/public/shared/ui-tutorial.js +5 -6
- package/neural-interface/public/shared/ui-worker-end.js +27 -8
- package/neural-interface/public/shared/worker-end.js +9 -4
- package/neural-interface/public/variant/2d/main.js +5 -0
- package/neural-interface/public/variant/3d/app.js +10 -0
- package/neural-interface/public/variant/3d/main.js +5 -1
- package/neural-interface/scripts/scratch-retention.mjs +20 -0
- package/neural-interface/server.js +725 -173
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -2
- package/scripts/restore-data-home-from-backup.mjs +175 -8
- package/setup.js +18 -4
- package/browser-extension/content.js +0 -189
- package/browser-extension/engine.js +0 -508
- 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 +0 -56
- package/browser-extension/popup-strings.js +0 -250
- package/browser-extension/popup-view.js +0 -151
- package/browser-extension/popup.css +0 -166
- package/browser-extension/popup.html +0 -108
- package/browser-extension/popup.js +0 -359
- package/browser-extension/service-worker.js +0 -275
- package/browser-extension/setup-content.js +0 -36
- package/browser-extension/tokens.css +0 -326
|
@@ -26,8 +26,11 @@ import { closeMenu, isMenuOpen, openMenu } from './asst-menu.js';
|
|
|
26
26
|
import { decorateControlHead } from './asst-control.js';
|
|
27
27
|
import { accountSummary } from '../account-view.js';
|
|
28
28
|
import { accountUsageText, autoAccountLabel } from '../account-usage.js';
|
|
29
|
+
import { registerLaunchPrefetch } from '../launch-prefetch.js';
|
|
30
|
+
import { createLazyModule } from '../lazy-module.js';
|
|
29
31
|
import {
|
|
30
32
|
DEFAULT_ROUTE_MODE,
|
|
33
|
+
displayProvider,
|
|
31
34
|
fmtConfidence,
|
|
32
35
|
modelShortName,
|
|
33
36
|
normalizeBrain,
|
|
@@ -89,6 +92,40 @@ function tf(t) {
|
|
|
89
92
|
};
|
|
90
93
|
}
|
|
91
94
|
|
|
95
|
+
/**
|
|
96
|
+
* A task class in the user's language, keyed by its id (`assistant.routes.taskClass.<id>`); the server's
|
|
97
|
+
* label (English) is the fallback. `lower` is the sentence form.
|
|
98
|
+
*/
|
|
99
|
+
export function routeClassLabel(taskClass, serverLabel, t, { lower = false } = {}) {
|
|
100
|
+
const tr = tf(t);
|
|
101
|
+
const id = str(taskClass);
|
|
102
|
+
const base = str(serverLabel) || humanizeClass(id);
|
|
103
|
+
const label = id ? tr(`assistant.routes.taskClass.${id}`, base) : base;
|
|
104
|
+
return lower ? label.toLowerCase() : label;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* An effort id in the user's language (`assistant.routes.effortWord.<id>`), for display only: the id that is
|
|
109
|
+
* sent back to the server never changes. A locale that only repeats the id (English), or has no key, and an
|
|
110
|
+
* id nothing names (an OpenCode variant) keep `fallback` (default: the card's own word, "none" → "off").
|
|
111
|
+
*/
|
|
112
|
+
export function routeEffortLabel(effort, t, fallback) {
|
|
113
|
+
const id = str(effort);
|
|
114
|
+
const raw = routeEffortWord(id);
|
|
115
|
+
const base = fallback == null ? raw : fallback;
|
|
116
|
+
if (!id) return base;
|
|
117
|
+
const v = tf(t)(`assistant.routes.effortWord.${id.toLowerCase()}`, '');
|
|
118
|
+
return v && v !== raw ? v : base;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A row's title with its trailing effort word in the user's language (the stored title stays English). */
|
|
122
|
+
export function routeTitleLocalized(o, t) {
|
|
123
|
+
const title = str(o?.title);
|
|
124
|
+
if (!o?.titleEffort || !o?.effort) return title;
|
|
125
|
+
const word = routeEffortLabel(o.effort, t);
|
|
126
|
+
return word === routeEffortWord(o.effort) ? title : `${routeTitleWithoutEffort(title, o.effort)} · ${word}`;
|
|
127
|
+
}
|
|
128
|
+
|
|
92
129
|
function humanizeClass(value) {
|
|
93
130
|
const s = str(value).replace(/[_-]+/g, ' ');
|
|
94
131
|
return s ? s[0].toUpperCase() + s.slice(1) : 'General';
|
|
@@ -197,6 +234,7 @@ export function normalizeRouteRequest(packet) {
|
|
|
197
234
|
needsVision: req.needsVision === true,
|
|
198
235
|
// Image / video creation: the medium the model must generate ('image' | 'video'), always on a worker.
|
|
199
236
|
requires: req.requires === 'image' || req.requires === 'video' ? req.requires : null,
|
|
237
|
+
needsHost: req.needsHost === true || req.sides?.dispatch?.code === 'host_only',
|
|
200
238
|
dispatchOnly: req.dispatchOnly === true,
|
|
201
239
|
// Design: only models that can see.
|
|
202
240
|
visionOnly: req.visionOnly === true,
|
|
@@ -359,6 +397,7 @@ export function routeOptions(n, { brainLabel = '', t = null } = {}) {
|
|
|
359
397
|
}
|
|
360
398
|
const kept = [];
|
|
361
399
|
for (const o of options) {
|
|
400
|
+
if (n.needsHost && o.kind !== 'direct') continue;
|
|
362
401
|
const twin = kept.find(k => sameRouteTarget(k, o));
|
|
363
402
|
if (twin) {
|
|
364
403
|
if (defaultId === o.id) defaultId = twin.id;
|
|
@@ -426,10 +465,13 @@ export function routeCardSides(n, options, { t = null } = {}) {
|
|
|
426
465
|
const usable = list.filter((o) => !o.disabled);
|
|
427
466
|
const said = server?.[kind] || null;
|
|
428
467
|
const out = { kind, options: list, available: usable.length > 0, reason: null, code: null, needsPick: false, defaultId: null };
|
|
468
|
+
if (kind === 'dispatch' && n?.needsHost) {
|
|
469
|
+
return { ...out, options: [], available: false, code: 'host_only', reason: tr('assistant.routes.side.hostOnly', 'This task requires host access in this conversation.') };
|
|
470
|
+
}
|
|
429
471
|
out.defaultId = (usable.find((o) => o.id === n?.defaultOptionId) || usable.find((o) => o.id === n?.defaults?.[kind]) || usable.find((o) => o.selected) || usable[0])?.id || null;
|
|
430
472
|
if (out.available) return out;
|
|
431
473
|
if (kind === 'direct' && n?.dispatchOnly) {
|
|
432
|
-
return { ...out, code: 'worker_only', reason: tr('assistant.routes.side.workerOnly', '{taskClass} always runs on a worker.', { taskClass: n.
|
|
474
|
+
return { ...out, code: 'worker_only', reason: tr('assistant.routes.side.workerOnly', '{taskClass} always runs on a worker.', { taskClass: routeClassLabel(n.taskClass, n.taskClassLabel, t) }) };
|
|
433
475
|
}
|
|
434
476
|
if (kind === 'direct' && (said?.code === 'account_worker' || arr(options).some((o) => o.kind === 'dispatch' && o.accountKind === 'direct'))) {
|
|
435
477
|
return { ...out, code: 'account_worker', reason: tr('assistant.routes.side.accountWorker', "This conversation's account can't take it now, so it runs on a worker.") };
|
|
@@ -448,7 +490,7 @@ export function routeCardSides(n, options, { t = null } = {}) {
|
|
|
448
490
|
const chosen = arr(options).find((o) => o.selected && !o.disabled);
|
|
449
491
|
let initial = chosen ? (chosen.kind === 'direct' ? 'direct' : 'dispatch') : null;
|
|
450
492
|
if (!initial || !sides[initial].available) initial = sides.direct.available && sides.direct.defaultId ? 'direct' : 'dispatch';
|
|
451
|
-
return { initial, sides };
|
|
493
|
+
return { initial: n?.needsHost ? 'direct' : initial, sides };
|
|
452
494
|
}
|
|
453
495
|
|
|
454
496
|
/** control_response payload for a route card. `decline:true` is the Cancel answer. */
|
|
@@ -548,7 +590,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
|
|
|
548
590
|
const tr = tf(t);
|
|
549
591
|
const r = obj(route) || {};
|
|
550
592
|
const target = obj(r.target);
|
|
551
|
-
const cls = firstStr(r.taskClassLabel, r.taskClass) || tr('assistant.routes.task', 'task');
|
|
593
|
+
const cls = (r.taskClass ? routeClassLabel(r.taskClass, firstStr(r.taskClassLabel, r.taskClass), t) : firstStr(r.taskClassLabel)) || tr('assistant.routes.task', 'task');
|
|
552
594
|
const kind = target ? (str(target.kind) || 'direct') : '';
|
|
553
595
|
const effort = target ? str(target.effort) : '';
|
|
554
596
|
const confidence = fmtConfidence(r.confidence);
|
|
@@ -560,6 +602,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
|
|
|
560
602
|
state = str(r.needs) === 'vision' ? tr('assistant.routes.reason.noSeeingModel', 'no model can see images') : tr('assistant.routes.reason.noCapableModel', 'no model can make this');
|
|
561
603
|
}
|
|
562
604
|
else if (str(r.reasonCode) === 'budget_exhausted') state = routeBudgetReason({ dry: r.dry }, t);
|
|
605
|
+
else if (str(r.reasonCode) === 'BUDGET_UNPRICED') state = routeBudgetReason({ provider: r.provider, unpriced: true }, t);
|
|
563
606
|
else if (phase === 'declined') state = tr('assistant.routes.state.declined', 'declined');
|
|
564
607
|
else if (phase === 'cancelled') state = tr('assistant.routes.state.cancelled', 'cancelled');
|
|
565
608
|
let decided = '';
|
|
@@ -576,7 +619,7 @@ export function routeLineParts(route, phase = 'decided', { brainLabel = '', t =
|
|
|
576
619
|
if (r.plannedSplit?.workers) meta.push(tf(t)('assistant.routes.splitWorkers', '{count} workers planned', { count: r.plannedSplit.workers }));
|
|
577
620
|
const accountLabel = routeDisplayAccount(target, t);
|
|
578
621
|
if (accountLabel) meta.push(accountLabel);
|
|
579
|
-
if (effort && effort !== 'off') meta.push(
|
|
622
|
+
if (effort && effort !== 'off') meta.push(routeEffortLabel(effort, t));
|
|
580
623
|
if (confidence) meta.push(confidence);
|
|
581
624
|
return {
|
|
582
625
|
taskClass: cls,
|
|
@@ -607,6 +650,11 @@ function correctionText(c, tr) {
|
|
|
607
650
|
}
|
|
608
651
|
if (c.reason === 'remembered_route') return tr('assistant.routes.correction.remembered', 'your saved route {to} replaced {from}', { to: str(c.to), from: str(c.from) });
|
|
609
652
|
if (c.reason === 'remembered_disabled') return tr('assistant.routes.correction.rememberedDisabled', 'saved route {from} is disabled, kept the pick', { from: str(c.from) });
|
|
653
|
+
if (c.reason === 'remembered_host') return tr('assistant.routes.correction.rememberedHost', 'Skipped the saved route {from} because this task requires host access.', { from: str(c.from) });
|
|
654
|
+
if (c.reason === 'superseded_run_active' && arr(c.runs).length) {
|
|
655
|
+
const runs = c.runs.map(r => [str(r?.runId), str(r?.title)].filter(Boolean).join(' — ')).filter(Boolean).join(', ');
|
|
656
|
+
return tr('assistant.routes.correction.supersededRunActive', 'Workers from the previous dispatch are still active ({runs}).', { runs });
|
|
657
|
+
}
|
|
610
658
|
// A "here" pick that runs on a worker: another account, or another provider than this conversation's.
|
|
611
659
|
if (c.reason === 'account_worker') return tr('assistant.routes.correction.accountWorker', '{to}: runs on a worker, because this conversation belongs to another account', { to: str(c.to) });
|
|
612
660
|
if (c.reason === 'other_provider' && c.provider) return tr('assistant.routes.correction.otherProvider', "{provider} is not this conversation's provider, so it runs on a worker", { provider: providerLabel(c.provider) });
|
|
@@ -718,9 +766,10 @@ export function createRouteLine(route, opts = {}) {
|
|
|
718
766
|
arrow.hidden = !p.targetLabel && !p.pending && !p.kindLabel;
|
|
719
767
|
kindEl.textContent = p.kindLabel;
|
|
720
768
|
kindEl.hidden = !p.kindLabel;
|
|
721
|
-
|
|
769
|
+
const brand = displayProvider(current.route?.target) || p.provider;
|
|
770
|
+
iconEl.innerHTML = p.targetLabel ? providerIconHtml(brand, opts) : '';
|
|
722
771
|
iconEl.hidden = !iconEl.innerHTML;
|
|
723
|
-
if (p.provider) iconEl.style.color = providerColor(
|
|
772
|
+
if (p.provider) iconEl.style.color = providerColor(brand); else iconEl.style.color = '';
|
|
724
773
|
targetEl.textContent = p.targetLabel;
|
|
725
774
|
targetEl.hidden = !p.targetLabel;
|
|
726
775
|
metaEl.textContent = p.meta.length ? `· ${p.meta.join(' · ')}` : '';
|
|
@@ -903,7 +952,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
903
952
|
card.dataset.requestId = n.requestId;
|
|
904
953
|
card.dataset.routeId = n.routeId;
|
|
905
954
|
card.setAttribute('role', 'group');
|
|
906
|
-
const heading = tr('assistant.routes.cardTitle', 'Route this request · {taskClass}', { taskClass: n.taskClassLabel });
|
|
955
|
+
const heading = tr('assistant.routes.cardTitle', 'Route this request · {taskClass}', { taskClass: routeClassLabel(n.taskClass, n.taskClassLabel, hooks.t) });
|
|
907
956
|
card.setAttribute('aria-label', heading);
|
|
908
957
|
|
|
909
958
|
const head = el('div', 'asst-control-head');
|
|
@@ -933,8 +982,9 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
933
982
|
const sidesEl = el('div', 'asst-route-sides');
|
|
934
983
|
sidesEl.setAttribute('role', 'radiogroup');
|
|
935
984
|
sidesEl.setAttribute('aria-label', tr('assistant.routes.side.label', 'Where it runs'));
|
|
985
|
+
const visibleSides = n.needsHost ? ['direct'] : ROUTE_SIDES;
|
|
936
986
|
const sideBtns = {};
|
|
937
|
-
for (const kind of
|
|
987
|
+
for (const kind of visibleSides) {
|
|
938
988
|
const btn = el('button', 'asst-route-side', kind === 'direct' ? tr('assistant.routes.side.here', 'Here') : tr('assistant.routes.side.dispatch', 'Dispatch'));
|
|
939
989
|
btn.type = 'button';
|
|
940
990
|
btn.dataset.side = kind;
|
|
@@ -953,6 +1003,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
953
1003
|
card.appendChild(list);
|
|
954
1004
|
|
|
955
1005
|
function optionRow(o) {
|
|
1006
|
+
const brand = displayProvider(o);
|
|
956
1007
|
const row = el('div', 'asst-route-option');
|
|
957
1008
|
row.setAttribute('role', 'radio');
|
|
958
1009
|
row.dataset.optionId = o.id;
|
|
@@ -960,17 +1011,17 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
960
1011
|
row.setAttribute('aria-disabled', o.disabled ? 'true' : 'false');
|
|
961
1012
|
row.tabIndex = -1;
|
|
962
1013
|
const kindWord = o.kind && o.kind !== 'direct' ? routeKindWord(o.kind, hooks.t) : '';
|
|
963
|
-
const sub = [kindWord, o.agentRef, routeDisplayAccount(o, hooks.t), o.effort && o.effort !== 'off' && !o.titleEffort ?
|
|
1014
|
+
const sub = [kindWord, o.agentRef, routeDisplayAccount(o, hooks.t), o.effort && o.effort !== 'off' && !o.titleEffort ? routeEffortLabel(o.effort, hooks.t) : '', o.price ? priceText(o.price) : '', o.vision ? tr('assistant.brain.vision', 'vision') : '', o.reason].filter(Boolean).join(' · ');
|
|
964
1015
|
row.innerHTML = `
|
|
965
1016
|
<span class="asst-route-num" aria-hidden="true">${esc(o.number)}</span>
|
|
966
|
-
<span class="asst-route-opt-icon asst-icon" aria-hidden="true"${o.provider ? ` style="color:${esc(providerColor(
|
|
1017
|
+
<span class="asst-route-opt-icon asst-icon" aria-hidden="true"${o.provider ? ` style="color:${esc(providerColor(brand))}"` : ''}>${providerIconHtml(brand, hooks)}</span>
|
|
967
1018
|
<span class="asst-route-opt-main">
|
|
968
1019
|
<span class="asst-route-opt-title"></span>
|
|
969
1020
|
${sub ? '<span class="asst-route-opt-sub"></span>' : ''}
|
|
970
1021
|
${o.warning || (o.disabled && o.disabledReason) ? '<span class="asst-route-opt-warn"></span>' : ''}
|
|
971
1022
|
</span>
|
|
972
1023
|
${o.badgeText ? `<span class="asst-route-badge" data-badge="${esc(o.badge || '')}"></span>` : ''}`;
|
|
973
|
-
row.querySelector('.asst-route-opt-title').textContent = o.
|
|
1024
|
+
row.querySelector('.asst-route-opt-title').textContent = routeTitleLocalized(o, hooks.t);
|
|
974
1025
|
if (sub) row.querySelector('.asst-route-opt-sub').textContent = sub;
|
|
975
1026
|
const warn = row.querySelector('.asst-route-opt-warn');
|
|
976
1027
|
if (warn) warn.textContent = o.accountError ? routeAccountError(o.accountError, hooks.t) : o.disabled && o.disabledReason ? o.disabledReason : o.warning;
|
|
@@ -1013,7 +1064,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1013
1064
|
/** The switch, its note (why the other side is unavailable, what a worker side still needs, else what the side means) and the Run label. */
|
|
1014
1065
|
function syncSides() {
|
|
1015
1066
|
card.dataset.side = state.side;
|
|
1016
|
-
for (const kind of
|
|
1067
|
+
for (const kind of visibleSides) {
|
|
1017
1068
|
const btn = sideBtns[kind];
|
|
1018
1069
|
const side = view.sides[kind];
|
|
1019
1070
|
const on = state.side === kind;
|
|
@@ -1078,11 +1129,15 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1078
1129
|
}
|
|
1079
1130
|
function syncFields() {
|
|
1080
1131
|
const target = selected();
|
|
1081
|
-
|
|
1132
|
+
// The router's "Do it here with ‹model›" label reads in the user's language, like the list rows.
|
|
1133
|
+
const targetText = !target ? '' : target.kind === 'direct' && /^do it here with\s+/i.test(str(target.label))
|
|
1134
|
+
? tr('assistant.routes.doHere', 'Do it here with {model}', { model: routeHereModelLabel(target) || modelShortName(target.model) || target.id })
|
|
1135
|
+
: routeTargetLabel(target);
|
|
1136
|
+
setFieldLabel(otherBtn, target ? targetText : tr('assistant.routes.other', 'Other model…'));
|
|
1082
1137
|
otherBtn.setAttribute('aria-label', tr('assistant.brain.model', 'Model'));
|
|
1083
1138
|
otherBtn.disabled = busy();
|
|
1084
1139
|
setFieldLabel(effortBtn, !target?.effort ? tr('assistant.routes.editorEffortAuto', 'Auto')
|
|
1085
|
-
: target.effort === ROUTE_EFFORT_OFF ? tr('assistant.routes.editorEffortOff', 'Off') : target.effort);
|
|
1140
|
+
: target.effort === ROUTE_EFFORT_OFF ? tr('assistant.routes.editorEffortOff', 'Off') : routeEffortLabel(target.effort, hooks.t, target.effort));
|
|
1086
1141
|
effortBtn.setAttribute('aria-label', tr('assistant.brain.effort', 'Thinking effort'));
|
|
1087
1142
|
setFieldLabel(accountBtn, routeDisplayAccount(target, hooks.t) || tr('assistant.routes.account.workersDefault', 'Workers default'));
|
|
1088
1143
|
accountBtn.setAttribute('aria-label', tr('assistant.brain.account', 'Account profile'));
|
|
@@ -1097,7 +1152,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1097
1152
|
const choices = routeEffortChoices(target.provider, catalogModelRow(target.provider, target.model));
|
|
1098
1153
|
openMenu(effortBtn, { title: tr('assistant.brain.effort', 'Thinking effort'), placement: 'auto', items: [
|
|
1099
1154
|
{ kind: 'radio', label: tr('assistant.routes.editorEffortAuto', 'Auto'), selected: !target.effort, onSelect: () => editTarget({ effort: null }) },
|
|
1100
|
-
...choices.map(e => ({ kind: 'radio', label: e.off ? tr('assistant.routes.editorEffortOff', 'Off') : e.label, selected: target.effort === e.id, onSelect: () => editTarget({ effort: e.id }) })),
|
|
1155
|
+
...choices.map(e => ({ kind: 'radio', label: e.off ? tr('assistant.routes.editorEffortOff', 'Off') : routeEffortLabel(e.id, hooks.t, e.label), selected: target.effort === e.id, onSelect: () => editTarget({ effort: e.id }) })),
|
|
1101
1156
|
] });
|
|
1102
1157
|
});
|
|
1103
1158
|
accountBtn.addEventListener('click', async () => {
|
|
@@ -1176,7 +1231,9 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1176
1231
|
rememberInput.type = 'checkbox';
|
|
1177
1232
|
rememberInput.addEventListener('change', () => { state.remember = rememberInput.checked; });
|
|
1178
1233
|
// `remember.label` is the task-class label ("Code"), not a sentence.
|
|
1179
|
-
|
|
1234
|
+
// A key per class carries the whole phrase so the plural noun agrees ("tarefas rápidas"); the generic one is the fallback.
|
|
1235
|
+
const rememberClass = n.remember.taskClass || n.taskClass;
|
|
1236
|
+
const text = tr(`assistant.routes.rememberForClass.${rememberClass}`, '') || tr('assistant.routes.rememberFor', 'Use this choice for {taskClass} tasks', { taskClass: routeClassLabel(rememberClass, n.remember.label || n.taskClassLabel, hooks.t, { lower: true }) });
|
|
1180
1237
|
label.append(rememberInput, el('span', null, text));
|
|
1181
1238
|
if (n.remember.current) label.appendChild(el('span', 'asst-route-remember-current', tr('assistant.routes.rememberCurrent', 'now: {current}', { current: n.remember.current })));
|
|
1182
1239
|
card.appendChild(label);
|
|
@@ -1188,7 +1245,7 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1188
1245
|
card.appendChild(error);
|
|
1189
1246
|
|
|
1190
1247
|
const actions = el('div', 'asst-control-actions');
|
|
1191
|
-
const cancelBtn = el('button', 'asst-btn asst-btn-secondary asst-route-cancel', n.decline.label
|
|
1248
|
+
const cancelBtn = el('button', 'asst-btn asst-btn-secondary asst-route-cancel', (n.decline.label && n.decline.label !== 'Cancel' ? n.decline.label : tr('common.cancel', 'Cancel')));
|
|
1192
1249
|
cancelBtn.type = 'button';
|
|
1193
1250
|
// When the server does not accept a decline, the card can only be answered.
|
|
1194
1251
|
cancelBtn.hidden = !n.decline.allowed;
|
|
@@ -1388,11 +1445,13 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1388
1445
|
return collapse(phase, route);
|
|
1389
1446
|
},
|
|
1390
1447
|
/** ROUTE_INVALID: keep (or re-open) the card with the message. */
|
|
1391
|
-
fail(message) {
|
|
1448
|
+
fail(message, code) {
|
|
1392
1449
|
clearTimers();
|
|
1393
1450
|
restore();
|
|
1394
1451
|
setPending(false, '');
|
|
1395
|
-
error.textContent =
|
|
1452
|
+
error.textContent = n.needsHost && code === 'ROUTE_IS_DIRECT'
|
|
1453
|
+
? view.sides.dispatch.reason
|
|
1454
|
+
: message || tr('assistant.routes.invalid', 'That route is not available. Pick another option.');
|
|
1396
1455
|
error.hidden = false;
|
|
1397
1456
|
if (expires) { tick(); if (!state.expired) state.timer = setInterval(tick, 1000); }
|
|
1398
1457
|
entry.focus();
|
|
@@ -1403,8 +1462,28 @@ export function renderRouteCard(container, input, hooks = {}) {
|
|
|
1403
1462
|
}
|
|
1404
1463
|
|
|
1405
1464
|
// ── Routes editor (draft, modes, task choices) ───────────────────────────────
|
|
1406
|
-
// Its model lists still come only through asst-route-models.js.
|
|
1407
|
-
|
|
1465
|
+
// Its model lists still come only through asst-route-models.js. The module loads in an idle moment after the page
|
|
1466
|
+
// is shown or at the first open, whichever comes first (lazy-module.js), so the page does not wait for it at boot.
|
|
1467
|
+
// A browser keeps a failed module address failed for the life of the page (a server restart can refuse the idle
|
|
1468
|
+
// load), so a later attempt asks under a new address. A failed load never ran, so there is still one editor.
|
|
1469
|
+
let routesEditorAttempts = 0;
|
|
1470
|
+
const routesEditorModule = createLazyModule(() => {
|
|
1471
|
+
const attempt = routesEditorAttempts++;
|
|
1472
|
+
return attempt ? import(`./asst-routes-editor.js?retry=${attempt}`) : import('./asst-routes-editor.js');
|
|
1473
|
+
}, { name: 'Routes editor' });
|
|
1474
|
+
if (typeof document !== 'undefined') registerLaunchPrefetch('assistant-routes-editor', () => routesEditorModule.load(), { order: 16 });
|
|
1475
|
+
|
|
1476
|
+
export function openRoutesEditor(hooks = {}) {
|
|
1477
|
+
const loaded = routesEditorModule.module;
|
|
1478
|
+
if (loaded) return loaded.openRoutesEditor(hooks);
|
|
1479
|
+
// Focus can move during the load: the control that opened the editor is the one it gives focus back to.
|
|
1480
|
+
const opened = { ...hooks, returnTo: hooks.returnTo ?? globalThis.document?.activeElement };
|
|
1481
|
+
return routesEditorModule.load().then(mod => mod.openRoutesEditor(opened), (err) => {
|
|
1482
|
+
const text = hooks.t?.('assistant.routes.loadFailed');
|
|
1483
|
+
hooks.onToast?.(typeof text === 'string' && text !== 'assistant.routes.loadFailed' ? text : 'Could not load model routes');
|
|
1484
|
+
throw err;
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1408
1487
|
|
|
1409
1488
|
// ── Models manager (Assistant → Models…) ───────────────────────────────────
|
|
1410
1489
|
|
|
@@ -96,7 +96,7 @@ export async function openRoutesEditor(hooks = {}) {
|
|
|
96
96
|
if (editor) { editor.focus(); return editor; }
|
|
97
97
|
const tr = translator(hooks.t);
|
|
98
98
|
const id = `asst-routes-${++uid}`;
|
|
99
|
-
const returnTo = document.activeElement;
|
|
99
|
+
const returnTo = hooks.returnTo ?? document.activeElement;
|
|
100
100
|
const overlay = el('div', 'asst-modal-overlay asst-routes-overlay');
|
|
101
101
|
overlay.setAttribute('role', 'dialog'); overlay.setAttribute('aria-modal', 'true'); overlay.setAttribute('aria-labelledby', `${id}-title`);
|
|
102
102
|
const modal = el('div', 'asst-modal asst-routes-modal');
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// SynaBun Assistant — the shell commands of an OpenCode brain (no DOM, no socket)
|
|
3
|
+
//
|
|
4
|
+
// The runtime tells a panel which commands the brain's tool calls started and how
|
|
5
|
+
// they ended (`assistant:shell`, `assistant:shells`). What a command printed is
|
|
6
|
+
// never in those packets: it is read in pages over REST, only while a terminal
|
|
7
|
+
// block shows that command, by the same follower and terminal buffer as the
|
|
8
|
+
// OpenCode side panel (ocp-v2-shell-logic.js). Everything here is display data:
|
|
9
|
+
// nothing of it goes to the model, the transcript, a memory or a meter.
|
|
10
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
import { createShellFollower, formatBytes, shellCardState } from '../ocp-v2/ocp-v2-shell-logic.js';
|
|
13
|
+
|
|
14
|
+
/** How many finished commands keep their read output once no block shows them (the next look reads it again). */
|
|
15
|
+
export const SHELL_KEPT_FINISHED = 12;
|
|
16
|
+
|
|
17
|
+
const GONE_VIEW = Object.freeze({ text: '', from: 0, size: 0, done: true, gone: true, error: '', full: false, capped: false, partial: false });
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* createShellTracker({ read })
|
|
21
|
+
* read({ shellId, cursor, tail, limit }) → { status, data: { output, cursor, size, from } } or { ok: false, status, error }
|
|
22
|
+
* apply / applyList take what the runtime says; open(id) + subscribe(id, fn) follow one command for as long as a
|
|
23
|
+
* block shows it; onChange(fn) hears that a command's state changed.
|
|
24
|
+
*/
|
|
25
|
+
export function createShellTracker({ read, setTimer, clearTimer, kept = SHELL_KEPT_FINISHED } = {}) {
|
|
26
|
+
const shells = new Map(); // shellId → the runtime's view of it
|
|
27
|
+
const byCall = new Map(); // the tool call's id → shellId
|
|
28
|
+
const entries = new Map(); // shellId → { follower, view, usedAt }
|
|
29
|
+
const listeners = new Map(); // shellId → Set of what draws it
|
|
30
|
+
const places = new Map(); // shellId → { follow, top }: where the reader left its block
|
|
31
|
+
const changes = new Set();
|
|
32
|
+
let clock = 0;
|
|
33
|
+
let destroyed = false;
|
|
34
|
+
|
|
35
|
+
const tell = (shellId) => {
|
|
36
|
+
for (const fn of [...(listeners.get(shellId) || [])]) { try { fn(); } catch (err) { console.warn('[asst-shell] draw failed', err); } }
|
|
37
|
+
};
|
|
38
|
+
const changed = (shell) => {
|
|
39
|
+
for (const fn of [...changes]) { try { fn(shell); } catch (err) { console.warn('[asst-shell] update failed', err); } }
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Stop removes a command from OpenCode, so its next read is a 404. What was read up to then is what it printed
|
|
43
|
+
// before it was stopped: nothing to apologise for, unless the start of a long output is out of reach.
|
|
44
|
+
const settledView = (shellId, view) => (view.gone && view.text && !view.partial && shells.get(shellId)?.status === 'killed'
|
|
45
|
+
? { ...view, gone: false, done: true }
|
|
46
|
+
: view);
|
|
47
|
+
|
|
48
|
+
function dropEntry(shellId) {
|
|
49
|
+
entries.get(shellId)?.follower?.stop();
|
|
50
|
+
entries.delete(shellId);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Finished commands nobody looks at keep their text up to `kept`; the oldest goes first. */
|
|
54
|
+
function evict() {
|
|
55
|
+
const idle = [...entries].filter(([id]) => !listeners.get(id)?.size).sort((a, b) => a[1].usedAt - b[1].usedAt);
|
|
56
|
+
while (idle.length > kept) {
|
|
57
|
+
const [id] = idle.shift();
|
|
58
|
+
dropEntry(id);
|
|
59
|
+
places.delete(id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function apply(shell) {
|
|
64
|
+
if (destroyed || !shell?.id) return;
|
|
65
|
+
const known = shells.get(shell.id);
|
|
66
|
+
// Named again after it was lost (a brain that came back to its serve): it is read afresh.
|
|
67
|
+
if (known?.lost) dropEntry(shell.id);
|
|
68
|
+
shells.set(shell.id, shell);
|
|
69
|
+
if (shell.callID) byCall.set(shell.callID, shell.id);
|
|
70
|
+
if (shell.status !== 'running') entries.get(shell.id)?.follower?.poke();
|
|
71
|
+
tell(shell.id);
|
|
72
|
+
changed(shell);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The brain no longer has this command (it was replaced, or its serve ended). What was read stays on screen. */
|
|
76
|
+
function lose(shellId) {
|
|
77
|
+
const shell = shells.get(shellId);
|
|
78
|
+
if (!shell || shell.lost) return;
|
|
79
|
+
const next = { ...shell, lost: true, status: shell.status === 'running' ? 'killed' : shell.status };
|
|
80
|
+
shells.set(shellId, next);
|
|
81
|
+
const entry = entries.get(shellId);
|
|
82
|
+
if (entry) {
|
|
83
|
+
entry.follower?.stop();
|
|
84
|
+
entry.follower = null;
|
|
85
|
+
const view = entry.view;
|
|
86
|
+
// Read to its end, the text on screen is the whole output: nothing is missing from it.
|
|
87
|
+
if (!view) entry.view = { ...GONE_VIEW };
|
|
88
|
+
else if (!view.done || view.partial) entry.view = { ...view, done: true, gone: true };
|
|
89
|
+
}
|
|
90
|
+
tell(shellId);
|
|
91
|
+
changed(next);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The whole list as the runtime knows it now: a command it no longer names is gone. */
|
|
95
|
+
function applyList(list) {
|
|
96
|
+
if (destroyed) return;
|
|
97
|
+
const named = new Set();
|
|
98
|
+
for (const shell of Array.isArray(list) ? list : []) {
|
|
99
|
+
if (!shell?.id) continue;
|
|
100
|
+
named.add(shell.id);
|
|
101
|
+
apply(shell);
|
|
102
|
+
}
|
|
103
|
+
for (const id of [...shells.keys()]) if (!named.has(id)) lose(id);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Start reading a command for a block that shows it. */
|
|
107
|
+
function open(shellId) {
|
|
108
|
+
if (destroyed || !shells.has(shellId)) return;
|
|
109
|
+
let entry = entries.get(shellId);
|
|
110
|
+
if (!entry) {
|
|
111
|
+
entry = { follower: null, view: null, usedAt: 0 };
|
|
112
|
+
entries.set(shellId, entry);
|
|
113
|
+
if (shells.get(shellId).lost) entry.view = { ...GONE_VIEW };
|
|
114
|
+
else {
|
|
115
|
+
const mine = entry;
|
|
116
|
+
const options = {
|
|
117
|
+
api: { shellOutput: ({ shellId: id, cursor, tail, limit }) => read({ shellId: id, cursor, tail, limit }) },
|
|
118
|
+
sessionId: 'assistant', shellId,
|
|
119
|
+
isRunning: () => shells.get(shellId)?.status === 'running',
|
|
120
|
+
onUpdate: (view) => { if (entries.get(shellId) === mine) { mine.view = settledView(shellId, view); tell(shellId); } },
|
|
121
|
+
};
|
|
122
|
+
if (setTimer) options.setTimer = setTimer;
|
|
123
|
+
if (clearTimer) options.clearTimer = clearTimer;
|
|
124
|
+
entry.follower = createShellFollower(options);
|
|
125
|
+
entry.follower.start();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
entry.usedAt = ++clock;
|
|
129
|
+
evict();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function subscribe(shellId, fn) {
|
|
133
|
+
let set = listeners.get(shellId);
|
|
134
|
+
if (!set) { set = new Set(); listeners.set(shellId, set); }
|
|
135
|
+
set.add(fn);
|
|
136
|
+
return () => {
|
|
137
|
+
set.delete(fn);
|
|
138
|
+
if (set.size) return;
|
|
139
|
+
listeners.delete(shellId);
|
|
140
|
+
// Nobody looks: nothing is polled. A command that ended and was read keeps its text for the next look.
|
|
141
|
+
const entry = entries.get(shellId);
|
|
142
|
+
if (entry?.follower && !entry.follower.isDone()) dropEntry(shellId);
|
|
143
|
+
evict();
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
apply,
|
|
149
|
+
applyList,
|
|
150
|
+
open,
|
|
151
|
+
subscribe,
|
|
152
|
+
loadAll(shellId) { entries.get(shellId)?.follower?.loadAll(); },
|
|
153
|
+
forCall: (callId) => shells.get(byCall.get(callId)) || null,
|
|
154
|
+
shell: (shellId) => shells.get(shellId) || null,
|
|
155
|
+
view: (shellId) => entries.get(shellId)?.view || null,
|
|
156
|
+
placeOf(shellId) {
|
|
157
|
+
let place = places.get(shellId);
|
|
158
|
+
if (!place) { place = { follow: true, top: 0 }; places.set(shellId, place); }
|
|
159
|
+
return place;
|
|
160
|
+
},
|
|
161
|
+
onChange(fn) { changes.add(fn); return () => changes.delete(fn); },
|
|
162
|
+
/** For tests: which commands are being read now. */
|
|
163
|
+
reading: () => [...entries].filter(([, entry]) => entry.follower && !entry.follower.isDone()).map(([id]) => id),
|
|
164
|
+
destroy() {
|
|
165
|
+
destroyed = true;
|
|
166
|
+
for (const id of [...entries.keys()]) dropEntry(id);
|
|
167
|
+
listeners.clear();
|
|
168
|
+
changes.clear();
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The word on a call's row for its command ('' when the call's own state says it). */
|
|
174
|
+
export function shellStateLabel(shell, t) {
|
|
175
|
+
if (!shell) return '';
|
|
176
|
+
if (shell.status === 'running') {
|
|
177
|
+
return shell.background ? t('assistant.rack.shell.background', 'in the background') : t('assistant.rack.shell.running', 'running');
|
|
178
|
+
}
|
|
179
|
+
if (shell.status === 'killed') return t('assistant.rack.shell.stopped', 'stopped');
|
|
180
|
+
if (shell.status === 'timeout') return t('assistant.rack.shell.timedOut', 'timed out');
|
|
181
|
+
if (typeof shell.exit === 'number') return t('assistant.rack.shell.exit', 'exit {code}', { code: shell.exit });
|
|
182
|
+
return '';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** A command the model no longer waits for failed after its tool call had already answered. */
|
|
186
|
+
export function shellFailedLate(shell) {
|
|
187
|
+
return shellCardState(shell).status === 'error';
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The line above a terminal block when it does not show everything: '' when it does. */
|
|
191
|
+
export function shellNoteText(view, t) {
|
|
192
|
+
if (!view) return '';
|
|
193
|
+
if (view.gone) return t('assistant.rack.shell.gone', 'OpenCode no longer keeps the output of this command.');
|
|
194
|
+
const shown = formatBytes(view.text.length);
|
|
195
|
+
const size = formatBytes(view.size);
|
|
196
|
+
if (view.capped) return t('assistant.rack.shell.capped', 'Showing the last {shown} of {size}: the whole output is too long to show here.', { shown, size });
|
|
197
|
+
if (view.partial) return t('assistant.rack.shell.partial', 'Showing the last {shown} of {size}.', { shown, size });
|
|
198
|
+
return '';
|
|
199
|
+
}
|
|
200
|
+
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// SynaBun Assistant — a shell call's live terminal block
|
|
3
|
+
//
|
|
4
|
+
// The block itself is the OpenCode panel's (ocp-v2-shell-block.js) in the rack's
|
|
5
|
+
// classes and words; the command's state and output come from the tracker
|
|
6
|
+
// (asst-shell-logic.js). A long test run must not cost the conversation
|
|
7
|
+
// anything: drawing is coalesced to one frame, and a block that is off screen or
|
|
8
|
+
// in a closed panel does no DOM work at all until it is seen again.
|
|
9
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
import { createTerminalBlock } from '../ocp-v2/ocp-v2-shell-block.js';
|
|
12
|
+
import { shellNoteText } from './asst-shell-logic.js';
|
|
13
|
+
|
|
14
|
+
const SHOW_EVENT = 'asst-term-show';
|
|
15
|
+
|
|
16
|
+
const CLASSES = Object.freeze({
|
|
17
|
+
wrap: 'asst-term',
|
|
18
|
+
note: 'asst-term-note',
|
|
19
|
+
noteText: 'asst-term-note-text',
|
|
20
|
+
load: 'asst-tool-more asst-term-load',
|
|
21
|
+
out: 'asst-tool-section asst-term-out',
|
|
22
|
+
foot: 'asst-term-foot',
|
|
23
|
+
state: 'asst-term-state',
|
|
24
|
+
jump: 'asst-tool-more asst-term-jump',
|
|
25
|
+
copy: 'asst-copy asst-term-copy',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* mountShellTerminal(tracker, shellId, { t, onDraw, onGone }) → { el, show(), dispose() }
|
|
30
|
+
* `onDraw`: the block was drawn (its height may have changed); `onGone`: OpenCode no longer has this output.
|
|
31
|
+
*/
|
|
32
|
+
export function mountShellTerminal(tracker, shellId, { t, onDraw = () => {}, onGone = () => {} } = {}) {
|
|
33
|
+
let drawBlock = null;
|
|
34
|
+
let frame = 0;
|
|
35
|
+
let dirty = false;
|
|
36
|
+
let seen = true;
|
|
37
|
+
let disposed = false;
|
|
38
|
+
let wasGone = !!tracker.view(shellId)?.gone;
|
|
39
|
+
let wrap = null;
|
|
40
|
+
|
|
41
|
+
const flush = () => {
|
|
42
|
+
frame = 0;
|
|
43
|
+
if (disposed || !dirty || !seen || !wrap?.isConnected) return;
|
|
44
|
+
dirty = false;
|
|
45
|
+
drawBlock?.();
|
|
46
|
+
onDraw();
|
|
47
|
+
const gone = !!tracker.view(shellId)?.gone;
|
|
48
|
+
if (gone && !wasGone) { wasGone = true; onGone(); }
|
|
49
|
+
};
|
|
50
|
+
const request = () => {
|
|
51
|
+
dirty = true;
|
|
52
|
+
if (frame || !seen) return;
|
|
53
|
+
frame = requestAnimationFrame(flush);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
tracker.open(shellId);
|
|
57
|
+
wrap = createTerminalBlock({
|
|
58
|
+
shellId,
|
|
59
|
+
place: tracker.placeOf(shellId),
|
|
60
|
+
showEvent: SHOW_EVENT,
|
|
61
|
+
read: () => ({ view: tracker.view(shellId), shell: tracker.shell(shellId) }),
|
|
62
|
+
// Told through `request` below, for as long as this mount lives (dispose ends it).
|
|
63
|
+
subscribe: (draw) => {
|
|
64
|
+
drawBlock = draw;
|
|
65
|
+
return () => {};
|
|
66
|
+
},
|
|
67
|
+
loadAll: () => tracker.loadAll(shellId),
|
|
68
|
+
classes: CLASSES,
|
|
69
|
+
words: {
|
|
70
|
+
load: t('assistant.rack.shell.loadFull', 'Load full output'),
|
|
71
|
+
loading: t('assistant.rack.shell.loading', 'Loading…'),
|
|
72
|
+
jump: t('assistant.rack.shell.jump', 'Jump to latest'),
|
|
73
|
+
copy: t('assistant.rack.shell.copy', 'Copy output'),
|
|
74
|
+
copied: t('assistant.rack.shell.copied', 'Copied'),
|
|
75
|
+
label: t('assistant.rack.shell.label', 'Command output'),
|
|
76
|
+
noOutputYet: t('assistant.rack.shell.noOutputYet', 'No output yet'),
|
|
77
|
+
noOutput: t('assistant.rack.shell.noOutput', 'No output'),
|
|
78
|
+
reading: t('assistant.rack.shell.reading', 'Reading the output…'),
|
|
79
|
+
running: t('assistant.rack.shell.runningNow', 'Running'),
|
|
80
|
+
note: (view) => shellNoteText(view, t),
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Not tied to being in the page: a row can be out of it for a moment while it is rebuilt.
|
|
85
|
+
const release = tracker.subscribe(shellId, request);
|
|
86
|
+
const watcher = typeof IntersectionObserver === 'function'
|
|
87
|
+
? new IntersectionObserver((entries) => {
|
|
88
|
+
seen = entries[entries.length - 1].isIntersecting;
|
|
89
|
+
if (seen && dirty && !frame) frame = requestAnimationFrame(flush);
|
|
90
|
+
})
|
|
91
|
+
: null;
|
|
92
|
+
watcher?.observe(wrap);
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
el: wrap,
|
|
96
|
+
/** The block is in the page again (a body rebuilt, a row opened): it measures itself and catches up. */
|
|
97
|
+
show() {
|
|
98
|
+
wrap.dispatchEvent(new Event(SHOW_EVENT));
|
|
99
|
+
request();
|
|
100
|
+
},
|
|
101
|
+
dispose() {
|
|
102
|
+
if (disposed) return;
|
|
103
|
+
disposed = true;
|
|
104
|
+
if (frame) cancelAnimationFrame(frame);
|
|
105
|
+
frame = 0;
|
|
106
|
+
watcher?.disconnect();
|
|
107
|
+
release();
|
|
108
|
+
wrap.remove();
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -30,7 +30,6 @@ import { brainLabel, readStoredBrain, restoredSessionName } from './asst-state.j
|
|
|
30
30
|
import { closeMenu, isMenuOpen, openMenu } from './asst-menu.js';
|
|
31
31
|
import { injectAssistantSidepanelStyles } from './asst-sidepanel-styles.js';
|
|
32
32
|
import { createMascot, mascotCameoSvg } from '../synabun-mascot.js';
|
|
33
|
-
import { createTutorialPreview } from '../ui-tutorial-preview.js';
|
|
34
33
|
|
|
35
34
|
const PANEL_OWNER = 'assistant-sidepanel';
|
|
36
35
|
const HOST_ID = 'sidepanel';
|
|
@@ -652,8 +651,11 @@ export function assistantPanelPeekable() {
|
|
|
652
651
|
* Assistant is blocked. restore() puts back the panel's visibility, the docked
|
|
653
652
|
* peers and the last-active panels, unless the tour ended on its hand-off to a
|
|
654
653
|
* live tab ('done'): then the panel stays and the tab's composer takes the focus.
|
|
654
|
+
* The preview loads here, before anything of the panel changes: only a tour needs it.
|
|
655
655
|
*/
|
|
656
|
-
export function beginAssistantTour({ onPreviewSend = () => {} } = {}) {
|
|
656
|
+
export async function beginAssistantTour({ onPreviewSend = () => {} } = {}) {
|
|
657
|
+
if (assistantBlocked()) return null;
|
|
658
|
+
const { createTutorialPreview } = await import('../ui-tutorial-preview.js');
|
|
657
659
|
if (assistantBlocked()) return null;
|
|
658
660
|
ensurePanel();
|
|
659
661
|
const wasVisible = _visible;
|