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
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// composer attachments, Claude/Codex account management, and the sidepanel tab registry.
|
|
8
8
|
// Mounted from server.js with `app.use('/api/assistant', createAssistantApi(deps))`.
|
|
9
9
|
|
|
10
|
+
import { assistantStopProvenance, pageStopProvenance, personAskedToStop } from './worker-stop.js';
|
|
10
11
|
import { dispatchInput } from './assistant-tools.js';
|
|
11
12
|
import { expandAgentProposals, getAgentResolver } from './agents/resolve.js'; // agents-p1
|
|
12
13
|
import { Router } from 'express';
|
|
@@ -213,7 +214,7 @@ export function createAssistantApi({
|
|
|
213
214
|
// identified (macOS, the lookup failed) never verifies: it is nobody here, and its refusals say 503
|
|
214
215
|
// PEER_UNAVAILABLE (uiOnly, refuseRunRead) rather than a 403 the page could not cure.
|
|
215
216
|
if (pageSession && typeof pageSession.verify === 'function' && !pageSession.verify(req)) return { kind: 'unknown', assistantSessionId: bodySession ? String(bodySession) : null, pin: '', pageless: true };
|
|
216
|
-
return { kind: 'ui', assistantSessionId: bodySession ? String(bodySession) : null };
|
|
217
|
+
return { kind: 'ui', verifiedPage: typeof pageSession?.verify === 'function', assistantSessionId: bodySession ? String(bodySession) : null };
|
|
217
218
|
}
|
|
218
219
|
// The pin counts only with its proof: a forged one names nobody here, not even for attribution.
|
|
219
220
|
let verdict = null;
|
|
@@ -921,9 +922,11 @@ export function createAssistantApi({
|
|
|
921
922
|
if (!assistantSessionId && !workflowId && req.assistantCaller.kind !== 'ui') {
|
|
922
923
|
return res.status(400).json({ ok: false, code: 'SCOPE_REQUIRED', error: 'Pass assistant_session_id (your ASSISTANT_SESSION_ID) or workflow_id to stop runs.' });
|
|
923
924
|
}
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
|
|
925
|
+
const stopProvenance = { ...assistantStopProvenance(req.assistantCaller, body.action), scope: workflowId ? 'workflow' : assistantSessionId ? 'session' : 'all' };
|
|
926
|
+
// 'user' is recorded only for a control a person operated, whatever the request says.
|
|
927
|
+
const reason = body.reason && (body.reason !== 'user' || personAskedToStop(stopProvenance)) ? body.reason : 'kill_all';
|
|
928
|
+
const result = await dispatcher.killAll({ assistantSessionId, workflowId, reason, stopProvenance });
|
|
929
|
+
// Keep the scope in the operational log as well as provenance on each stopped run.
|
|
927
930
|
const caller = req.assistantCaller.kind === 'ui' ? 'the page' : `the brain of ${req.assistantCaller.assistantSessionId || 'an unknown session'}`;
|
|
928
931
|
const scope = [assistantSessionId ? `session ${assistantSessionId}` : null, workflowId ? `workflow ${workflowId}` : null].filter(Boolean).join(', ') || 'every session';
|
|
929
932
|
const stopped = Array.isArray(result?.stopped) ? result.stopped : [];
|
|
@@ -1040,7 +1043,7 @@ export function createAssistantApi({
|
|
|
1040
1043
|
// A run whose provider share is used up: the session's unspent budget is divided again first, then
|
|
1041
1044
|
// sendTurn decides (it refuses with BUDGET_SHARE_EXHAUSTED when no money could move).
|
|
1042
1045
|
try { await dispatcher.coverFollowUp?.(req.params.runId); } catch { /* sendTurn decides on the shares as they are */ }
|
|
1043
|
-
res.json(dispatcher.sendTurn(req.params.runId, body.text ?? body.message, { origin, queue: body.queue !== false }));
|
|
1046
|
+
res.json(await dispatcher.sendTurn(req.params.runId, body.text ?? body.message, { origin, queue: body.queue !== false }));
|
|
1044
1047
|
} catch (error) { sendError(res, error); }
|
|
1045
1048
|
});
|
|
1046
1049
|
router.post('/runs/:runId/permission', orchestrationGuard, (req, res) => {
|
|
@@ -1067,7 +1070,13 @@ export function createAssistantApi({
|
|
|
1067
1070
|
} catch (error) { sendError(res, error); }
|
|
1068
1071
|
});
|
|
1069
1072
|
router.post('/runs/:runId/stop', orchestrationGuard, async (req, res) => {
|
|
1070
|
-
|
|
1073
|
+
const caller = req.assistantCaller;
|
|
1074
|
+
const stopProvenance = assistantStopProvenance(caller, req.body?.action);
|
|
1075
|
+
// 'user' is recorded only for a control a person operated, whatever the request says.
|
|
1076
|
+
const said = typeof req.body?.reason === 'string' ? req.body.reason.trim() : '';
|
|
1077
|
+
const person = personAskedToStop(stopProvenance);
|
|
1078
|
+
const reason = said && (said !== 'user' || person) ? said : person ? 'user' : caller.credentialed ? 'assistant' : 'unknown';
|
|
1079
|
+
try { res.json(await dispatcher.stop(req.params.runId, reason, stopProvenance)); } catch (error) { sendError(res, error); }
|
|
1071
1080
|
});
|
|
1072
1081
|
// Finished runs are cleared from the agents tray by the owner (the page) or the Assistant brain of the run's
|
|
1073
1082
|
// own session; never by a worker (even its own run). A brain's delete is scoped to its session's runs.
|
|
@@ -1102,8 +1111,10 @@ export function createAssistantApi({
|
|
|
1102
1111
|
// The user closed the sidepanel tab of a worker that finished its task: completed, never "stopped
|
|
1103
1112
|
// by the user" (409 RUN_NOT_FINISHED for any other run, which the tab then stops as before).
|
|
1104
1113
|
router.post('/runs/:runId/tab-closed', (req, res) => {
|
|
1105
|
-
|
|
1106
|
-
|
|
1114
|
+
const caller = callerContext(req);
|
|
1115
|
+
if (caller.kind !== 'ui') return uiOnly(req, res, 'Only the sidepanel that closed the tab reports it.');
|
|
1116
|
+
const action = req.body?.action === 'tray_auto_close' ? 'tray_auto_close' : 'tab_close';
|
|
1117
|
+
try { res.json(dispatcher.completeClosedTab(req.params.runId, pageStopProvenance(action, caller.verifiedPage))); } catch (error) { sendError(res, error); }
|
|
1107
1118
|
});
|
|
1108
1119
|
router.post('/runs/:runId/focus', (req, res) => {
|
|
1109
1120
|
const run = dispatcher.get(req.params.runId);
|
|
@@ -1158,6 +1169,39 @@ export function createAssistantApi({
|
|
|
1158
1169
|
res.json({ ok: true, usage: runtime.usageView?.(id, task) ?? usage?.taskView(id, task) ?? null, budget: sessionBudgetView(id) });
|
|
1159
1170
|
} catch (error) { sendError(res, error); }
|
|
1160
1171
|
});
|
|
1172
|
+
// The shell commands of a session's OpenCode brain (which tool call each belongs to, whether it runs, how it
|
|
1173
|
+
// ended) and a page of what one printed: what the panel's terminal blocks show. The owner's page alone reads
|
|
1174
|
+
// them (this boot's page secret, no agent header): what a command printed is display data, so no brain and no
|
|
1175
|
+
// worker gets it here, and with it nothing of it reaches a model's context. The session in the path is the one
|
|
1176
|
+
// whose own brain is asked, and that brain reads only a command it ran itself (runtime.shellOutput).
|
|
1177
|
+
function shellReader(req, res) {
|
|
1178
|
+
const agent = ['x-synabun-terminal', 'x-synabun-assistant', 'x-synabun-role', 'x-synabun-brain-token', 'x-synabun-desktop-grant'].some((name) => req.get(name));
|
|
1179
|
+
if (agent || isGuestRequest(req) || callerContext(req).kind !== 'ui') { uiOnly(req, res, 'A command\'s output is shown in the user\'s own Assistant panel only.'); return false; }
|
|
1180
|
+
// The automation browser verifies as the owner while the owner's setting lets it act as owner; it still never
|
|
1181
|
+
// reads what a command printed (review S4): a page an agent drives would hand it to that agent's model.
|
|
1182
|
+
let fromAutomationBrowser = false;
|
|
1183
|
+
try { fromAutomationBrowser = typeof pageSession?.isAutomationBrowser === 'function' && pageSession.isAutomationBrowser(req) === true; } catch { fromAutomationBrowser = true; }
|
|
1184
|
+
if (fromAutomationBrowser) { res.status(403).json({ ok: false, code: 'WORKER_BROWSER', error: 'A command\'s output is shown in the owner\'s own browser or the app, never in SynaBun\'s automation browser.' }); return false; }
|
|
1185
|
+
return true;
|
|
1186
|
+
}
|
|
1187
|
+
router.get('/sessions/:id/shells', noStore, (req, res) => {
|
|
1188
|
+
if (!requireRuntime(res) || !shellReader(req, res)) return;
|
|
1189
|
+
const shells = typeof runtime.shellList === 'function' ? runtime.shellList(req.params.id) : null;
|
|
1190
|
+
if (!shells) return res.status(404).json({ ok: false, code: 'SESSION_NOT_FOUND', error: `Unknown assistant session ${req.params.id}` });
|
|
1191
|
+
res.json({ ok: true, shells });
|
|
1192
|
+
});
|
|
1193
|
+
router.get('/sessions/:id/shells/:shellId/output', noStore, async (req, res) => {
|
|
1194
|
+
if (!requireRuntime(res) || !shellReader(req, res)) return;
|
|
1195
|
+
if (typeof runtime.shellOutput !== 'function') return res.status(404).json({ ok: false, code: 'SHELL_OUTPUT_GONE', error: 'The output of that command is no longer available.' });
|
|
1196
|
+
const shellId = String(req.params.shellId || '');
|
|
1197
|
+
if (!/^[A-Za-z0-9_-]{1,128}$/.test(shellId)) return res.status(400).json({ ok: false, code: 'SHELL_ID_INVALID', error: 'That is not a command of this conversation.' });
|
|
1198
|
+
const number = (value) => (typeof value === 'string' && /^\d{1,15}$/.test(value) ? Number(value) : undefined);
|
|
1199
|
+
try {
|
|
1200
|
+
const page = await runtime.shellOutput(req.params.id, { shellId, cursor: number(req.query.cursor), tail: number(req.query.tail), limit: number(req.query.limit) });
|
|
1201
|
+
if (!page || page.ok === false) return res.status(Number(page?.status) >= 400 ? Number(page.status) : 502).json({ ok: false, code: page?.code || 'SHELL_OUTPUT_FAILED', error: page?.error || 'The output could not be read.' });
|
|
1202
|
+
res.json({ ok: true, ...page.data });
|
|
1203
|
+
} catch (error) { sendError(res, error); }
|
|
1204
|
+
});
|
|
1161
1205
|
router.get('/sessions/:id', (req, res) => {
|
|
1162
1206
|
if (!requireRuntime(res)) return;
|
|
1163
1207
|
const session = runtime.getSession(req.params.id, { transcript: req.query.transcript !== '0', limit: clampInt(req.query.limit, 1, 2000, 400) });
|
|
@@ -119,6 +119,8 @@ export function createClaudeBrain({ session, sink, deps = {}, persona = '', hook
|
|
|
119
119
|
// are CLI-oriented (greeting, loop driver, stop nudges) and are not loaded.
|
|
120
120
|
settingSources: Array.isArray(deps.settingSources) ? deps.settingSources : ['user'],
|
|
121
121
|
hooks: hooks || undefined,
|
|
122
|
+
// A resumed conversation must discover SynaBun's current tools after a server update.
|
|
123
|
+
synabunDiscoveryCache: false,
|
|
122
124
|
mcpHeaders: {
|
|
123
125
|
'X-Synabun-Role': 'assistant', 'X-Synabun-Terminal': session.id, 'X-Synabun-Memory-Session': session.id,
|
|
124
126
|
...(deps.desktopGrant ? { 'X-Synabun-Desktop-Grant': deps.desktopGrant } : {}),
|
|
@@ -13,9 +13,10 @@ import { dirname, resolve } from 'node:path';
|
|
|
13
13
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
14
14
|
import { normalizeOpenCodeModel } from '../native-loop-providers.js';
|
|
15
15
|
import { agentOf, mcpServersOf, opencodeConfigFilePath, readOpencodeConfigDocument, setAgent, setMcpServer, withPlugin, withoutPlugin } from '../opencode-config.js';
|
|
16
|
-
import { createOpenCodeEnvelopeTranslator, opencodeControlResponse } from '../assistant-envelope.js';
|
|
16
|
+
import { createOpenCodeEnvelopeTranslator, opencodeControlResponse, opencodeShellView } from '../assistant-envelope.js';
|
|
17
17
|
import { opencodePlanPermission, opencodeReadOnlyPermission, planDenyMessage, readOnlyDenyMessage } from '../assistant-plan-permissions.js';
|
|
18
18
|
import { planModeInstructions } from '../assistant-persona.js';
|
|
19
|
+
import { readShellOutputPage, SHELL_OUTPUT_GONE_TEXT } from '../opencode-shell-read.js';
|
|
19
20
|
import { waitForSynabunTools, synabunConfigured, synabunToolsTimeoutText, OPENCODE_MCP_READY_TIMEOUT_MS, OPENCODE_MCP_SETTLE_MS, OPENCODE_MCP_LIST_GRACE_MS } from '../opencode-mcp-ready.js';
|
|
20
21
|
export { synabunMcpState } from '../opencode-mcp-ready.js';
|
|
21
22
|
|
|
@@ -154,6 +155,9 @@ export function patchOpenCodeAssistantConfig(xdgRoot, { persona = '', role = 'as
|
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
|
|
158
|
+
/** How many shell commands of its tool calls a brain remembers (a command still running is never forgotten for a newer one). */
|
|
159
|
+
export const OPENCODE_BRAIN_SHELLS_MAX = 200;
|
|
160
|
+
|
|
157
161
|
/** The assistant's OpenCode approval mode: 'auto' (auto-accept) or 'default'. */
|
|
158
162
|
export function opencodeApprovalMode(mode) {
|
|
159
163
|
return mode === 'auto' || mode === 'acceptEdits' || mode === 'bypassPermissions' ? 'auto' : 'default';
|
|
@@ -208,12 +212,18 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
208
212
|
let startPromise = null;
|
|
209
213
|
let synabunExpected = false;
|
|
210
214
|
let stops = 0;
|
|
215
|
+
// After a "Stop anyway" (a command may still run): what OpenCode does for that command's end (a start the client
|
|
216
|
+
// interrupts, its error) is no turn of the runtime's, and reaches nobody until the next turn of the user's.
|
|
217
|
+
let muted = false;
|
|
211
218
|
let waitingAbort = null;
|
|
212
219
|
let interruptPrompt = null;
|
|
213
220
|
let exited = false;
|
|
214
221
|
const serveExitMessage = 'The isolated OpenCode server stopped during this turn. Send the message again to resume.';
|
|
215
222
|
const serveExitError = () => Object.assign(new Error(serveExitMessage), { code: 'OPENCODE_SERVE_EXITED' });
|
|
216
223
|
const serveExited = () => exited || entry?.proc?.exitCode != null || entry?.proc?.signalCode != null;
|
|
224
|
+
const stopMayFail = () => {
|
|
225
|
+
try { return !!(client && sessionId && client.getClient?.()?.stopNeedsKill?.(sessionId) === true); } catch { return false; }
|
|
226
|
+
};
|
|
217
227
|
function onServeExit() {
|
|
218
228
|
if (disposed) return;
|
|
219
229
|
exited = true;
|
|
@@ -248,8 +258,31 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
248
258
|
if (typeof plan === 'boolean') planMode = plan;
|
|
249
259
|
}
|
|
250
260
|
|
|
261
|
+
// The shell commands of this brain's tool calls, as its event stream told them (shellId → the panel's view of
|
|
262
|
+
// it, assistant-envelope.js opencodeShellView): what a panel is sent when it attaches, and the only commands
|
|
263
|
+
// whose output this brain reads for it. Display data: nothing of it goes to the model, the transcript or a meter.
|
|
264
|
+
const shells = new Map();
|
|
265
|
+
function noteShell(shell) {
|
|
266
|
+
if (!shell?.id) return;
|
|
267
|
+
shells.delete(shell.id);
|
|
268
|
+
shells.set(shell.id, shell);
|
|
269
|
+
if (shells.size <= OPENCODE_BRAIN_SHELLS_MAX) return;
|
|
270
|
+
for (const [id, known] of shells) {
|
|
271
|
+
if (shells.size <= OPENCODE_BRAIN_SHELLS_MAX) break;
|
|
272
|
+
if (known.status !== 'running') shells.delete(id);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
251
276
|
const emit = (packet) => {
|
|
252
277
|
if (disposed) return;
|
|
278
|
+
if (packet.type === 'assistant:shell') { noteShell(packet.shell); sink.send(packet); return; }
|
|
279
|
+
if (muted) {
|
|
280
|
+
// What OpenCode does for an abandoned command's end is no turn of anyone's: its model output goes nowhere. A
|
|
281
|
+
// permission request or a question of it would wait where nobody sees it, so it is refused at once, and every
|
|
282
|
+
// panel of the session says so (review 29cd51fe, finding 3).
|
|
283
|
+
if (packet.type === 'control_request' && client) refuseMuted(packet);
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
253
286
|
const decision = packet.type === 'control_request' && client ? opencodeAutoDecision(packet, { approvalMode: remoteReadOnly ? 'default' : approvalMode, planMode: planning(), readOnly: remoteReadOnly }) : null;
|
|
254
287
|
if (decision) {
|
|
255
288
|
const body = opencodeControlResponse(packet, { behavior: decision });
|
|
@@ -268,6 +301,18 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
268
301
|
};
|
|
269
302
|
sink.send({ type: 'engine', engine: 'opencode', brain: 'opencode' });
|
|
270
303
|
|
|
304
|
+
/** A request asked after a "Stop anyway", before the user's next turn: refused, never left pending, and said. */
|
|
305
|
+
function refuseMuted(packet) {
|
|
306
|
+
const body = opencodeControlResponse(packet, { behavior: 'deny' });
|
|
307
|
+
const tool = packet.request?.tool_name || (body.kind === 'question' ? 'a question' : 'a permission');
|
|
308
|
+
sink.send({ type: 'stderr', text: `Declined ${tool}: OpenCode asked it after Stop anyway, while no turn of yours was running. Send a message to go on.` });
|
|
309
|
+
if (!body.requestID) return;
|
|
310
|
+
const call = body.kind === 'question'
|
|
311
|
+
? client.question.reject({ requestID: body.requestID, directory: cwd })
|
|
312
|
+
: client.permission.reply({ requestID: body.requestID, reply: 'reject', directory: cwd, message: 'The user stopped this turn.' });
|
|
313
|
+
Promise.resolve(call).catch((error) => { if (!serveExited()) sink.send({ type: 'error', message: `OpenCode decline failed: ${error?.message || error}` }); });
|
|
314
|
+
}
|
|
315
|
+
|
|
271
316
|
function bindTranslator() {
|
|
272
317
|
translator = createOpenCodeEnvelopeTranslator({
|
|
273
318
|
sessionId, emit, brain: { cwd, model: brain.model || null }, planTurn: () => turnPlanned,
|
|
@@ -279,6 +324,21 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
279
324
|
unsubscribe = source?.onEvent?.((envelope) => {
|
|
280
325
|
if (!disposed && !serveExited()) translator.handle(envelope?.eventType || '', envelope?.event || {});
|
|
281
326
|
}) || null;
|
|
327
|
+
recallShells();
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// A brain that comes back to a serve already running (a resumed conversation) learns the commands that serve
|
|
331
|
+
// still knows for its session; what the stream says from now on is newer, so a command already noted stays.
|
|
332
|
+
async function recallShells() {
|
|
333
|
+
const asked = sessionId;
|
|
334
|
+
if (!asked || typeof client?.extra?.shell?.list !== 'function') return;
|
|
335
|
+
let listed = null;
|
|
336
|
+
try { listed = await client.extra.shell.list({ sessionID: asked }); } catch { return; }
|
|
337
|
+
if (disposed || asked !== sessionId) return;
|
|
338
|
+
for (const item of Array.isArray(listed?.data) ? listed.data : []) {
|
|
339
|
+
const shell = opencodeShellView(item);
|
|
340
|
+
if (shell?.callID && !shells.has(shell.id)) emit({ type: 'assistant:shell', shell });
|
|
341
|
+
}
|
|
282
342
|
}
|
|
283
343
|
|
|
284
344
|
/** The serve's MCP servers as an `mcp_status` event (the runtime reads whether SynaBun, and so agent_route, is reachable). */
|
|
@@ -331,12 +391,14 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
331
391
|
needsRestart: serveExited,
|
|
332
392
|
start,
|
|
333
393
|
async sendUserTurn({ text, images = [], model = null, effort = null, permissionMode: mode = null, planMode: plan = null } = {}) {
|
|
394
|
+
muted = false;
|
|
334
395
|
const stop = stops;
|
|
335
396
|
await start();
|
|
336
397
|
if (disposed || stops !== stop) return false;
|
|
337
398
|
if (serveExited()) throw serveExitError();
|
|
338
399
|
applyModes(mode, plan);
|
|
339
400
|
turnActive = true;
|
|
401
|
+
translator?.noteTurnStart?.();
|
|
340
402
|
// The runtime passes the effective model/effort on every turn (the record
|
|
341
403
|
// may have changed since this brain started; routed turns override it).
|
|
342
404
|
const parts = [{ type: 'text', text }, ...opencodeImageParts(images)];
|
|
@@ -390,12 +452,31 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
390
452
|
throw serveExited() ? serveExitError() : error;
|
|
391
453
|
} finally { interruptPrompt = null; }
|
|
392
454
|
},
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
455
|
+
/** Could a Stop fail now (a command in the background to end, lib/opencode2-client.js stopNeedsKill)? */
|
|
456
|
+
stopMayFail: () => stopMayFail(),
|
|
457
|
+
/**
|
|
458
|
+
* Stop the turn. A Stop that has a command to end tears nothing down before OpenCode confirmed its end: when it
|
|
459
|
+
* could not (lib/opencode2-client.js abortSession, review B3) the turn goes on, held for the command, and the
|
|
460
|
+
* error (code SHELL_STOP_FAILED, `shells`) says which and why. `force` ("Stop anyway"): the turn ends whatever
|
|
461
|
+
* the command does; → `{ abandoned }`, the commands that may still run.
|
|
462
|
+
*/
|
|
463
|
+
async abort({ force = false } = {}) {
|
|
464
|
+
const mayFail = !force && stopMayFail();
|
|
465
|
+
if (!mayFail) { stops += 1; waitingAbort?.abort(); }
|
|
466
|
+
if (serveExited()) return { abandoned: [] };
|
|
467
|
+
let answer = null;
|
|
468
|
+
try { if (client && sessionId) answer = await client.session.abort({ sessionID: sessionId, directory: cwd, ...(force ? { force: true } : {}) }); } catch (error) {
|
|
469
|
+
if (error?.cause?.name === 'ShellStopFailed' && !serveExited()) {
|
|
470
|
+
error.code = 'SHELL_STOP_FAILED';
|
|
471
|
+
error.shells = Array.isArray(error.data?.shells) ? error.data.shells : [];
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
if (mayFail) { stops += 1; waitingAbort?.abort(); }
|
|
476
|
+
const abandoned = Array.isArray(answer?.data?.abandoned) ? answer.data.abandoned : [];
|
|
398
477
|
if (!serveExited()) emit({ type: 'aborted' });
|
|
478
|
+
if (force) muted = true;
|
|
479
|
+
return { abandoned };
|
|
399
480
|
},
|
|
400
481
|
async setPermissionMode(mode, { planMode: plan = null } = {}) { applyModes(mode, plan); sink.send({ type: 'mode_changed', mode: approvalMode, planMode }); },
|
|
401
482
|
respondControl(requestId, response) {
|
|
@@ -413,9 +494,31 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
413
494
|
async compact() {
|
|
414
495
|
await start();
|
|
415
496
|
turnPlanned = false;
|
|
497
|
+
// A compact is the user's own request: what it says is theirs again, even right after a Stop anyway.
|
|
498
|
+
muted = false;
|
|
416
499
|
await client.session.compact({ sessionID: sessionId, directory: cwd });
|
|
417
500
|
},
|
|
418
501
|
async mcpStatus() { await reportMcpStatus(); },
|
|
502
|
+
/** The shell commands of this brain's tool calls, oldest first (what a panel that attaches is shown). */
|
|
503
|
+
shells: () => [...shells.values()],
|
|
504
|
+
/**
|
|
505
|
+
* A page of what one of those commands printed (stdout and stderr as written, in order), for the panel that
|
|
506
|
+
* shows it: from the byte `cursor`, or the last `tail` bytes. Only a command this brain ran is read, on its
|
|
507
|
+
* own serve. → { status, data: { output, cursor, size, from } } or { ok: false, status, error }. Never throws.
|
|
508
|
+
*/
|
|
509
|
+
async shellOutput({ shellId, cursor, tail, limit } = {}) {
|
|
510
|
+
const id = typeof shellId === 'string' ? shellId : '';
|
|
511
|
+
if (!id || !shells.has(id)) return { ok: false, status: 404, error: 'That command is not one of this conversation.' };
|
|
512
|
+
const api = client?.extra?.shell;
|
|
513
|
+
if (disposed || serveExited() || typeof api?.output !== 'function') return { ok: false, status: 404, error: SHELL_OUTPUT_GONE_TEXT };
|
|
514
|
+
try {
|
|
515
|
+
return await readShellOutputPage(api, { shellID: id, directory: cwd, cursor, tail, limit });
|
|
516
|
+
} catch (error) {
|
|
517
|
+
const status = Number(error?.status);
|
|
518
|
+
// OpenCode keeps a finished command's output for a while only (404); any other failure may pass.
|
|
519
|
+
return { ok: false, status: status >= 400 && status < 600 ? status : 502, error: status === 404 ? SHELL_OUTPUT_GONE_TEXT : (error?.message || 'The output could not be read.') };
|
|
520
|
+
}
|
|
521
|
+
},
|
|
419
522
|
async reconcileUsage(meter) {
|
|
420
523
|
if (!client || !sessionId || !meter || serveExited()) return false;
|
|
421
524
|
let failed = false;
|
|
@@ -441,7 +544,18 @@ export function createOpenCodeBrain({ session, sink, deps = {}, persona = '' } =
|
|
|
441
544
|
return !failed;
|
|
442
545
|
},
|
|
443
546
|
// The session resumed is the conversation now: the usage meter's root follows it.
|
|
444
|
-
async resume(id) {
|
|
547
|
+
async resume(id) {
|
|
548
|
+
if (!id) return;
|
|
549
|
+
// Another provider conversation (/resume): the commands of the one before are not this one's, neither to
|
|
550
|
+
// list nor to read (review S3). The panels hear the new list; the commands its serve knows follow.
|
|
551
|
+
if (id !== sessionId && shells.size) {
|
|
552
|
+
shells.clear();
|
|
553
|
+
if (!disposed) sink.send({ type: 'assistant:shells' });
|
|
554
|
+
}
|
|
555
|
+
sessionId = id;
|
|
556
|
+
deps.onOpenCodeRoot?.(id);
|
|
557
|
+
if (client) bindTranslator();
|
|
558
|
+
},
|
|
445
559
|
async listSessions() { await start(); const rows = await client.session.list({ directory: cwd }).catch(() => null); return Array.isArray(rows?.data) ? rows.data : []; },
|
|
446
560
|
isBusy() { return turnActive || pendingControls.size > 0; },
|
|
447
561
|
identity() { return { providerSessionId: sessionId, providerThreadId: null, accountId: null, model: brain.model || null, effort: null, cwd, costUsd, busy: turnActive, termId }; },
|
|
@@ -27,7 +27,7 @@ import { toolCatalogView } from '../../mcp-server/dist/services/tool-catalog.js'
|
|
|
27
27
|
// never offered. `sources` says how each provider's list was obtained.
|
|
28
28
|
|
|
29
29
|
import { sortEfforts, variantNames } from './effort-levels.js';
|
|
30
|
-
import { listPrice } from './assistant-pricing.js';
|
|
30
|
+
import { applyOpencodeCostOverride, listPrice } from './assistant-pricing.js';
|
|
31
31
|
|
|
32
32
|
export const CATALOG_PROVIDERS = ['claude-code', 'codex', 'opencode', 'antigravity'];
|
|
33
33
|
/**
|
|
@@ -249,7 +249,7 @@ export function parseOpenCodeProviders(data, { filter = null } = {}) {
|
|
|
249
249
|
if (caps.input && typeof caps.input === 'object' && typeof caps.input.image === 'boolean') vision = caps.input.image;
|
|
250
250
|
else if (Array.isArray(model.modalities?.input)) vision = model.modalities.input.includes('image');
|
|
251
251
|
else if (typeof model.attachment === 'boolean' || typeof caps.attachment === 'boolean') { vision = !!(model.attachment ?? caps.attachment); visionSource = 'guess'; }
|
|
252
|
-
const price = priceFrom(model.cost);
|
|
252
|
+
const price = priceFrom(applyOpencodeCostOverride(pid, mid, model.cost));
|
|
253
253
|
const row = {
|
|
254
254
|
provider: 'opencode', id, upstream: pid, label: model.name || mid, family: model.family || null,
|
|
255
255
|
vision, visionSource,
|
|
@@ -25,7 +25,6 @@ export const DEFAULT_ROUTING = Object.freeze({
|
|
|
25
25
|
defaultMode: 'ask-unsure',
|
|
26
26
|
askBelow: 0.75,
|
|
27
27
|
waitSeconds: 45,
|
|
28
|
-
cardTimeoutMinutes: 30,
|
|
29
28
|
preferences: Object.freeze({}),
|
|
30
29
|
ladders: Object.freeze({}),
|
|
31
30
|
catalogFilter: Object.freeze({}),
|
|
@@ -90,11 +89,6 @@ export function validateRoutingPatch(patch = {}, { taskClasses = null } = {}) {
|
|
|
90
89
|
if (!Number.isFinite(n) || n < 0 || n > 110) throw routingError('waitSeconds', 'routing.waitSeconds must be between 0 and 110');
|
|
91
90
|
out.waitSeconds = Math.round(n);
|
|
92
91
|
}
|
|
93
|
-
if ('cardTimeoutMinutes' in patch) {
|
|
94
|
-
const n = Number(patch.cardTimeoutMinutes);
|
|
95
|
-
if (!Number.isFinite(n) || n < 1 || n > 24 * 60) throw routingError('cardTimeoutMinutes', 'routing.cardTimeoutMinutes must be between 1 and 1440');
|
|
96
|
-
out.cardTimeoutMinutes = Math.round(n);
|
|
97
|
-
}
|
|
98
92
|
if ('preferences' in patch) {
|
|
99
93
|
if (!patch.preferences || typeof patch.preferences !== 'object') throw routingError('preferences', 'routing.preferences must be an object');
|
|
100
94
|
out.preferences = {};
|
|
@@ -147,7 +141,6 @@ export function effectiveRouting(raw = {}) {
|
|
|
147
141
|
defaultMode: mode,
|
|
148
142
|
askBelow: num(r.askBelow, DEFAULT_ROUTING.askBelow, 0, 1),
|
|
149
143
|
waitSeconds: Math.round(num(r.waitSeconds, DEFAULT_ROUTING.waitSeconds, 0, 110)),
|
|
150
|
-
cardTimeoutMinutes: Math.round(num(r.cardTimeoutMinutes, DEFAULT_ROUTING.cardTimeoutMinutes, 1, 1440)),
|
|
151
144
|
preferences: r.preferences && typeof r.preferences === 'object' ? { ...r.preferences } : {},
|
|
152
145
|
ladders: r.ladders && typeof r.ladders === 'object' ? { ...r.ladders } : {},
|
|
153
146
|
catalogFilter: r.catalogFilter && typeof r.catalogFilter === 'object' ? { ...r.catalogFilter } : {},
|