@openchamber/web 1.24.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/commands-connect-url.js +3 -8
- package/bin/lib/commands-tunnel.js +3 -0
- package/dist/assets/{CodeMirrorCommentWidgets-B_vBPQYm.js → CodeMirrorCommentWidgets-zm3C1FvM.js} +1 -1
- package/dist/assets/DiffView-DNExNi1z.js +4 -0
- package/dist/assets/FilesView-DUCLmHBi.js +17 -0
- package/dist/assets/{GitView-k0hUF8KB.js → GitView-Bz9z6gZA.js} +4 -4
- package/dist/assets/{GuestAttachDialog-DIf2U85Z.js → GuestAttachDialog-UGp4KDlK.js} +1 -1
- package/dist/assets/GuestSurfacePane-B3pdB_2u.js +1 -0
- package/dist/assets/{JsonTreeView-4AnJ04Pw.js → JsonTreeView-7lVecnZl.js} +1 -1
- package/dist/assets/LinearIssuesView-CTGRS9Vq.js +1 -0
- package/dist/assets/MarkdownImageGallery-DQk5adUs.js +1 -0
- package/dist/assets/MarkdownRendererImpl-DPF8fZpX.js +12 -0
- package/dist/assets/OnboardingScreen-CBx6cXPP.js +1 -0
- package/dist/assets/{PatchDiff-DpGmHRnV.js → PatchDiff-D7VVpR_l.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CgLl_tp7.js → PierreDiffViewer-Gbfks1pk.js} +3 -3
- package/dist/assets/PlanView-CPSK0x97.js +5 -0
- package/dist/assets/PluginPane-BIGsUx69.js +3 -0
- package/dist/assets/SettingsView-Dql7z6Ww.js +30 -0
- package/dist/assets/SettingsWindow-D6oi-UmV.js +1 -0
- package/dist/assets/SubmoduleDiffSummary-BXA0FAWj.js +1 -0
- package/dist/assets/ToolOutputDialog-BQJsSbDm.js +15 -0
- package/dist/assets/ToolPartDiffPreview-FY9w0TVT.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-BK4aU5qJ.js → VirtualizedFileDiff-B9YhAya5.js} +4 -4
- package/dist/assets/{WalkthroughView-Bk6TPNFw.js → WalkthroughView-CmFgOUFN.js} +2 -2
- package/dist/assets/appThemeRegistry-BebxalUt.js +1 -0
- package/dist/assets/changesTree-CePHbFcj.js +1 -0
- package/dist/assets/commitAndPush-Wfxng_IK.js +1 -0
- package/dist/assets/{computeVirtualFileMetrics-BVTujWSX.js → computeVirtualFileMetrics-BCOqgixN.js} +2 -2
- package/dist/assets/de-CMA45TC-.js +10 -0
- package/dist/assets/es-DPL4fBtl.js +16 -0
- package/dist/assets/fr-OHBKBseP.js +14 -0
- package/dist/assets/index-3TiDNtfN.js +1 -0
- package/dist/assets/index-BLUZa5u0.js +41 -0
- package/dist/assets/index-Cm2rrq69.css +1 -0
- package/dist/assets/{isDiffPlainText-D3yX_vx4.js → isDiffPlainText-DnDYQmWK.js} +1 -1
- package/dist/assets/{isFilePlainText-CZR9TcHV.js → isFilePlainText-BA_AHX7d.js} +1 -1
- package/dist/assets/ja-DvX4WSRf.js +16 -0
- package/dist/assets/ko-BUcLd8YZ.js +16 -0
- package/dist/assets/main-B_jri4i-.js +896 -0
- package/dist/assets/main-DtUmJp9B.js +2 -0
- package/dist/assets/{markdown-shiki.worker-CahLvHIq.js → markdown-shiki.worker-Bg8SoAJJ.js} +8 -5
- package/dist/assets/markdownCore-BSnlUXBf.js +7 -0
- package/dist/assets/miniChat-BYfLUnDK.js +2 -0
- package/dist/assets/mobile-DH3hI6gd.js +2 -0
- package/dist/assets/patchFileDiff--L7lt_GZ.js +13 -0
- package/dist/assets/pl-BkI_xHqz.js +16 -0
- package/dist/assets/pt-BR-7wFtQlV9.js +16 -0
- package/dist/assets/renderElectronMiniChatApp-C7kpNW_-.js +2 -0
- package/dist/assets/renderMobileApp-i0nq7Dwy.js +25 -0
- package/dist/assets/runtimeEndpointReset-CfEYbcCc.js +27 -0
- package/dist/assets/scheduledTasksApi-Cy7uZCaI.js +1 -0
- package/dist/assets/{shikiHighlight-BfjuB3CD.js → shikiHighlight-D4vxipfr.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-BP60t9SX.js → textMateThemeFromAppTheme-BYAHtJwQ.js} +1 -1
- package/dist/assets/tr-TsD-AqEH.js +7 -0
- package/dist/assets/uk-B-qspCmD.js +16 -0
- package/dist/assets/useAppFontEffects-DHZ9-L30.js +7338 -0
- package/dist/assets/useInlineCommentController-CvpOMK-R.js +2 -0
- package/dist/assets/useRootScrollLock-DzNFi-fn.js +2 -0
- package/dist/assets/{vendor-codemirror-language-data-BFm1Ju2w.js → vendor-codemirror-language-data-j3fhlwUM.js} +2 -2
- package/dist/assets/vendor-cron-parser-CjvYVigk.js +2 -0
- package/dist/assets/vendor-opencode-client-DYdsLbCM.js +12 -0
- package/dist/assets/{vendor-remixicon-react-BDmGmFCA.js → vendor-remixicon-react-D6dZ0UwF.js} +1 -1
- package/dist/assets/vendor-zod-BSoePkpP.js +39 -0
- package/dist/assets/{web-components-2vo9YsZc.js → web-components-BvHNFSEG.js} +2 -2
- package/dist/assets/zh-CN-DYuPJV5i.js +16 -0
- package/dist/assets/zh-TW-BX_2D_lV.js +16 -0
- package/dist/index.html +13 -7
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +6 -5
- package/server/index.d.ts +1 -0
- package/server/index.js +264 -91
- package/server/lib/agent-tool/DOCUMENTATION.md +38 -16
- package/server/lib/agent-tool/runtime.js +167 -58
- package/server/lib/agent-tool/runtime.test.js +170 -87
- package/server/lib/browser-control/DOCUMENTATION.md +51 -4
- package/server/lib/browser-control/provider.js +217 -0
- package/server/lib/browser-control/provider.test.js +251 -0
- package/server/lib/context-obligatory/runtime.js +61 -50
- package/server/lib/context-obligatory/runtime.test.js +62 -162
- package/server/lib/event-stream/DOCUMENTATION.md +12 -1
- package/server/lib/event-stream/delta-coalescer.js +0 -0
- package/server/lib/event-stream/delta-coalescer.test.js +68 -57
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-hub.js +10 -1
- package/server/lib/event-stream/global-hub.test.js +27 -26
- package/server/lib/event-stream/index.js +6 -0
- package/server/lib/event-stream/protocol.js +26 -19
- package/server/lib/event-stream/protocol.test.js +18 -7
- package/server/lib/event-stream/rebind.test.js +5 -5
- package/server/lib/event-stream/runtime.test.js +17 -15
- package/server/lib/event-stream/translate-v2.js +313 -0
- package/server/lib/event-stream/translate-v2.test.js +209 -0
- package/server/lib/event-stream/upstream-reader.test.js +16 -16
- package/server/lib/fs/DOCUMENTATION.md +4 -2
- package/server/lib/fs/byte-range.js +35 -0
- package/server/lib/fs/byte-range.test.js +31 -0
- package/server/lib/fs/routes.js +47 -42
- package/server/lib/fs/routes.test.js +123 -18
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +34 -0
- package/server/lib/git/service.test.js +8 -0
- package/server/lib/github/DOCUMENTATION.md +1 -1
- package/server/lib/github/pr-status.js +22 -2
- package/server/lib/github/pr-status.test.js +27 -14
- package/server/lib/guests/DOCUMENTATION.md +16 -2
- package/server/lib/guests/catalog.js +31 -1
- package/server/lib/guests/catalog.test.js +55 -0
- package/server/lib/guests/html-styles.js +5 -3
- package/server/lib/guests/html-styles.test.js +3 -1
- package/server/lib/guests/routes.js +21 -4
- package/server/lib/guests/service.js +197 -14
- package/server/lib/guests/service.test.js +201 -1
- package/server/lib/guests/surface.js +676 -0
- package/server/lib/guests/surface.test.js +536 -0
- package/server/lib/markdown-image-grants/routes.js +18 -5
- package/server/lib/markdown-image-grants/routes.test.js +9 -6
- package/server/lib/message-queue/DOCUMENTATION.md +33 -22
- package/server/lib/message-queue/runtime.js +155 -100
- package/server/lib/message-queue/runtime.test.js +168 -82
- package/server/lib/notifications/DOCUMENTATION.md +38 -0
- package/server/lib/notifications/control-stream.http.test.js +68 -0
- package/server/lib/notifications/emit-route.js +118 -0
- package/server/lib/notifications/emit-route.test.js +112 -0
- package/server/lib/notifications/emitter-runtime.js +15 -0
- package/server/lib/notifications/emitter-runtime.test.js +32 -0
- package/server/lib/notifications/push-runtime.js +5 -1
- package/server/lib/notifications/push-runtime.test.js +2 -2
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +115 -26
- package/server/lib/notifications/template-runtime.js +13 -15
- package/server/lib/notifications/template-runtime.test.js +16 -9
- package/server/lib/notifications/trigger-runtime.test.js +187 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +10 -0
- package/server/lib/openchamber-control/actions.js +19 -4
- package/server/lib/openchamber-control/error.js +1 -1
- package/server/lib/openchamber-control/file-open.js +59 -0
- package/server/lib/openchamber-control/file-open.test.js +57 -0
- package/server/lib/openchamber-control/routes.test.js +12 -0
- package/server/lib/openchamber-control/service.js +125 -49
- package/server/lib/openchamber-control/service.test.js +115 -44
- package/server/lib/openchamber-sessions/archive-store.js +224 -0
- package/server/lib/openchamber-sessions/archive-store.test.js +187 -0
- package/server/lib/openchamber-sessions/fork-inheritance.js +103 -0
- package/server/lib/openchamber-sessions/fork-inheritance.test.js +69 -0
- package/server/lib/openchamber-sessions/opencode-client.js +22 -0
- package/server/lib/openchamber-sessions/routes.js +409 -328
- package/server/lib/openchamber-sessions/routes.test.js +795 -740
- package/server/lib/openchamber-sessions/session-metadata-store.js +285 -0
- package/server/lib/openchamber-sessions/session-metadata-store.test.js +259 -0
- package/server/lib/opencode/DOCUMENTATION.md +458 -29
- package/server/lib/opencode/agents.js +233 -327
- package/server/lib/opencode/auth.js +41 -44
- package/server/lib/opencode/auth.test.js +92 -0
- package/server/lib/opencode/bootstrap-runtime.js +12 -0
- package/server/lib/opencode/cli-upgrade.d.ts +4 -0
- package/server/lib/opencode/cli-upgrade.js +18 -0
- package/server/lib/opencode/cli-upgrade.test.js +36 -0
- package/server/lib/opencode/commands.js +164 -145
- package/server/lib/opencode/compatibility.d.ts +16 -0
- package/server/lib/opencode/compatibility.js +91 -0
- package/server/lib/opencode/compatibility.test.js +70 -0
- package/server/lib/opencode/config-entity-routes.js +58 -29
- package/server/lib/opencode/config-entity-v2.test.js +290 -0
- package/server/lib/opencode/config-mutation-response.js +17 -7
- package/server/lib/opencode/config-mutation-response.test.js +4 -7
- package/server/lib/opencode/config-paths.test.js +2 -2
- package/server/lib/opencode/config-v2.d.ts +185 -0
- package/server/lib/opencode/config-v2.js +843 -0
- package/server/lib/opencode/config-v2.test.js +483 -0
- package/server/lib/opencode/core-routes.js +3 -0
- package/server/lib/opencode/core-routes.test.js +15 -0
- package/server/lib/opencode/credential-db.js +144 -0
- package/server/lib/opencode/credential-db.test.js +104 -0
- package/server/lib/opencode/env-runtime.js +47 -15
- package/server/lib/opencode/env-runtime.test.js +45 -0
- package/server/lib/opencode/feature-routes-runtime.js +16 -5
- package/server/lib/opencode/lifecycle-process.test.js +7 -4
- package/server/lib/opencode/lifecycle.js +113 -30
- package/server/lib/opencode/lifecycle.test.js +107 -8
- package/server/lib/opencode/login-shell-env.js +27 -0
- package/server/lib/opencode/managed-config-file.js +131 -0
- package/server/lib/opencode/managed-config-file.test.js +168 -0
- package/server/lib/opencode/managed-plugin-config.js +33 -13
- package/server/lib/opencode/mcp.js +43 -149
- package/server/lib/opencode/network-runtime.js +6 -7
- package/server/lib/opencode/openchamber-routes.js +29 -11
- package/server/lib/opencode/openchamber-routes.test.js +18 -1
- package/server/lib/opencode/plugin-routes.js +3 -3
- package/server/lib/opencode/plugin-routes.test.js +6 -24
- package/server/lib/opencode/plugins.js +91 -40
- package/server/lib/opencode/plugins.test.js +28 -15
- package/server/lib/opencode/provider-source-route.test.js +59 -0
- package/server/lib/opencode/providers.js +66 -83
- package/server/lib/opencode/providers.test.js +190 -59
- package/server/lib/opencode/proxy-agent-wiring.test.js +4 -2
- package/server/lib/opencode/proxy.js +179 -129
- package/server/lib/opencode/pwa-manifest-routes.js +4 -2
- package/server/lib/opencode/pwa-manifest-routes.test.js +3 -2
- package/server/lib/opencode/response-envelope.js +14 -0
- package/server/lib/opencode/response-envelope.test.js +23 -0
- package/server/lib/opencode/routes-upgrade.test.js +73 -116
- package/server/lib/opencode/routes.js +138 -428
- package/server/lib/opencode/server-utils-runtime.js +10 -4
- package/server/lib/opencode/session-activity.js +78 -0
- package/server/lib/opencode/session-runtime.js +21 -10
- package/server/lib/opencode/session-runtime.test.js +9 -9
- package/server/lib/opencode/settings-helpers.js +15 -8
- package/server/lib/opencode/settings-helpers.test.js +7 -12
- package/server/lib/opencode/settings-registry.json +20 -8
- package/server/lib/opencode/settings-runtime.js +19 -1
- package/server/lib/opencode/settings-runtime.test.js +31 -2
- package/server/lib/opencode/shared.js +86 -24
- package/server/lib/opencode/shared.test.js +87 -5
- package/server/lib/opencode/shutdown-runtime.js +54 -7
- package/server/lib/opencode/shutdown-runtime.test.js +224 -30
- package/server/lib/opencode/skill-routes.js +51 -36
- package/server/lib/opencode/skill-routes.test.js +121 -1
- package/server/lib/opencode/skills.js +7 -5
- package/server/lib/opencode/tunnel-wiring-runtime.js +2 -1
- package/server/lib/opencode/upgrade-capability.js +0 -14
- package/server/lib/opencode/upgrade-capability.test.js +1 -1
- package/server/lib/opencode/v1-migration-topup.js +294 -0
- package/server/lib/opencode/v1-migration-topup.test.js +274 -0
- package/server/lib/opencode/v2-install.d.ts +9 -0
- package/server/lib/opencode/v2-install.js +159 -0
- package/server/lib/opencode/v2-install.test.js +133 -0
- package/server/lib/opencode/watcher.js +10 -3
- package/server/lib/opencode/watcher.test.js +17 -21
- package/server/lib/opencode/websearch-config.js +78 -0
- package/server/lib/permission-auto-accept/runtime.js +38 -22
- package/server/lib/permission-auto-accept/runtime.test.js +39 -17
- package/server/lib/quota/DOCUMENTATION.md +4 -0
- package/server/lib/quota/providers/kimi.js +1 -1
- package/server/lib/quota/providers/xai.js +4 -4
- package/server/lib/relay/tunnel-host.js +4 -1
- package/server/lib/relay/tunnel-host.test.js +7 -0
- package/server/lib/routing/DOCUMENTATION.md +52 -21
- package/server/lib/routing/defaults.js +23 -6
- package/server/lib/routing/jev.js +17 -7
- package/server/lib/routing/routes.http.test.js +68 -33
- package/server/lib/routing/routes.js +65 -22
- package/server/lib/routing/runtime.js +145 -48
- package/server/lib/routing/runtime.test.js +79 -55
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +4 -0
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +51 -46
- package/server/lib/scheduled-tasks/runtime.js +81 -74
- package/server/lib/scheduled-tasks/runtime.test.js +53 -1
- package/server/lib/session-assist/DOCUMENTATION.md +25 -8
- package/server/lib/session-assist/context.js +122 -46
- package/server/lib/session-assist/context.test.js +117 -49
- package/server/lib/session-assist/runtime.js +71 -24
- package/server/lib/session-assist/runtime.test.js +153 -173
- package/server/lib/session-goal/DOCUMENTATION.md +34 -15
- package/server/lib/session-goal/create.js +9 -12
- package/server/lib/session-goal/create.test.js +27 -28
- package/server/lib/session-goal/runtime.js +164 -77
- package/server/lib/session-goal/runtime.test.js +271 -519
- package/server/lib/session-knowledge/DOCUMENTATION.md +5 -0
- package/server/lib/session-knowledge/runtime.js +59 -41
- package/server/lib/session-knowledge/runtime.test.js +90 -20
- package/server/lib/small-model/DOCUMENTATION.md +154 -208
- package/server/lib/small-model/client.js +113 -0
- package/server/lib/small-model/index.js +296 -158
- package/server/lib/small-model/index.test.js +423 -256
- package/server/lib/small-model/routes.js +1 -1
- package/server/lib/spaces/DOCUMENTATION.md +807 -0
- package/server/lib/spaces/code-in-bait.js +185 -0
- package/server/lib/spaces/code-in.js +641 -0
- package/server/lib/spaces/code-in.test.js +1048 -0
- package/server/lib/spaces/errors.js +8 -0
- package/server/lib/spaces/exec-http.js +94 -0
- package/server/lib/spaces/gatekeeper-channel.js +202 -0
- package/server/lib/spaces/gatekeeper-channel.test.js +215 -0
- package/server/lib/spaces/gatekeeper-program.cjs +914 -0
- package/server/lib/spaces/gatekeeper-program.test.js +1391 -0
- package/server/lib/spaces/hardening.js +457 -0
- package/server/lib/spaces/hardening.test.js +368 -0
- package/server/lib/spaces/host-git.js +127 -0
- package/server/lib/spaces/host-git.test.js +137 -0
- package/server/lib/spaces/labels.js +234 -0
- package/server/lib/spaces/labels.test.js +219 -0
- package/server/lib/spaces/layout.js +184 -0
- package/server/lib/spaces/layout.test.js +30 -0
- package/server/lib/spaces/manager.js +82 -0
- package/server/lib/spaces/manager.test.js +114 -0
- package/server/lib/spaces/places/code-in.docker.live.test.js +216 -0
- package/server/lib/spaces/places/contract-suite.js +156 -0
- package/server/lib/spaces/places/contract.docker.live.test.js +7 -0
- package/server/lib/spaces/places/contract.test.js +6 -0
- package/server/lib/spaces/places/docker-engine.js +126 -0
- package/server/lib/spaces/places/docker-live-support.js +202 -0
- package/server/lib/spaces/places/docker-tools.js +186 -0
- package/server/lib/spaces/places/docker.js +587 -0
- package/server/lib/spaces/places/docker.test.js +1610 -0
- package/server/lib/spaces/places/escape-suite.js +1018 -0
- package/server/lib/spaces/places/escape.docker.live.test.js +7 -0
- package/server/lib/spaces/places/fake-docker.js +375 -0
- package/server/lib/spaces/places/memory-place.js +103 -0
- package/server/lib/spaces/places/packed.docker.live.test.js +77 -0
- package/server/lib/spaces/places/registry.js +43 -0
- package/server/lib/spaces/places/registry.test.js +50 -0
- package/server/lib/spaces/places/server.docker.live.test.js +225 -0
- package/server/lib/spaces/run-command.js +261 -0
- package/server/lib/spaces/run-command.test.js +396 -0
- package/server/lib/spaces/space-server.js +190 -0
- package/server/lib/spaces/space-server.test.js +335 -0
- package/server/lib/spaces/tools-filler.js +82 -0
- package/server/lib/spaces/tools-filler.test.js +148 -0
- package/server/lib/spaces/tools-pack.js +49 -0
- package/server/lib/spaces/tools-pack.test.js +57 -0
- package/server/lib/spaces/tools.js +137 -0
- package/server/lib/spaces/tools.test.js +153 -0
- package/server/lib/tts/openai-sdk.js +11 -0
- package/server/lib/tts/service.js +7 -5
- package/server/lib/tts/stt.js +3 -2
- package/server/lib/tunnels/DOCUMENTATION.md +2 -0
- package/server/lib/tunnels/routes.js +7 -0
- package/server/lib/tunnels/routes.test.js +55 -0
- package/server/lib/ui-auth/ui-auth.js +38 -2
- package/server/lib/ui-auth/ui-auth.test.js +42 -0
- package/server/lib/ui-auth/ui-passkeys.js +12 -10
- package/server/lib/walkthrough/DOCUMENTATION.md +10 -1
- package/server/lib/walkthrough/pull-request.js +61 -8
- package/server/lib/walkthrough/pull-request.test.js +54 -1
- package/server/lib/walkthrough/routes.js +20 -0
- package/server/lib/walkthrough/routes.test.js +19 -0
- package/server/opencode-proxy.test.js +190 -166
- package/server/opencode-worktree-readiness.test.js +5 -4
- package/dist/assets/DiffView-Ce0oBXXQ.js +0 -4
- package/dist/assets/FilesView-DtXueAWP.js +0 -13
- package/dist/assets/LinearIssuesView-z_9p2GuO.js +0 -1
- package/dist/assets/MarkdownImageGallery-BC-BNN-s.js +0 -1
- package/dist/assets/MarkdownRendererImpl-DyaBTUbH.js +0 -12
- package/dist/assets/OnboardingScreen-DKU_yTb6.js +0 -1
- package/dist/assets/PlanView-CrfB4qqY.js +0 -5
- package/dist/assets/PluginPane-B5cn-jPy.js +0 -3
- package/dist/assets/SettingsView-DMKKwezx.js +0 -29
- package/dist/assets/SettingsWindow-DwbnVzOC.js +0 -1
- package/dist/assets/SubmoduleDiffSummary-hkGcvs0E.js +0 -1
- package/dist/assets/ToolOutputDialog-DuoIOc0j.js +0 -15
- package/dist/assets/ToolPartDiffPreview-t1Bvq_2Y.js +0 -8
- package/dist/assets/appThemeRegistry-DnOVbJjF.js +0 -1
- package/dist/assets/commitAndPush-DLWNZkkY.js +0 -1
- package/dist/assets/de-zEHaAIi3.js +0 -10
- package/dist/assets/es-CBDgEzgk.js +0 -16
- package/dist/assets/fr-DjiTptT_.js +0 -14
- package/dist/assets/index-AgOdanig.css +0 -1
- package/dist/assets/index-B-2_X4DD.js +0 -40
- package/dist/assets/index-CkA4p2IK.js +0 -1
- package/dist/assets/ja-CerMgj3r.js +0 -16
- package/dist/assets/ko-DHYDAze5.js +0 -16
- package/dist/assets/main-BDka4W43.js +0 -896
- package/dist/assets/main-Dl7Dyge_.js +0 -2
- package/dist/assets/markdownCore-DFmr0rUR.js +0 -5
- package/dist/assets/miniChat-CLKQPPpO.js +0 -2
- package/dist/assets/mobile--giD2Q1L.js +0 -2
- package/dist/assets/patchFileDiff-DRh-AQvd.js +0 -13
- package/dist/assets/pl-BTB_93bq.js +0 -16
- package/dist/assets/pt-BR-BwA3oyCK.js +0 -16
- package/dist/assets/renderElectronMiniChatApp-DmB7zpVK.js +0 -2
- package/dist/assets/renderMobileApp-pMfOuQfl.js +0 -25
- package/dist/assets/runtimeEndpointReset-Gqhmkm3U.js +0 -25
- package/dist/assets/scheduledTasksApi-CeRAIUmW.js +0 -1
- package/dist/assets/tr-CcPsJoNM.js +0 -7
- package/dist/assets/uk-B68WibXi.js +0 -16
- package/dist/assets/useAppFontEffects-DcdrFv2Z.js +0 -7333
- package/dist/assets/useInlineCommentController-Cq4SUjsA.js +0 -2
- package/dist/assets/useRootScrollLock-CSdR6Wnm.js +0 -2
- package/dist/assets/vendor-cron-parser-CUcP7OfX.js +0 -2
- package/dist/assets/vendor-opencode-sdk-BJ73u-bH.js +0 -7
- package/dist/assets/vendor-zod-CgAdXWZO.js +0 -39
- package/dist/assets/zh-CN-DbFHYXwP.js +0 -16
- package/dist/assets/zh-TW-DmXAwdty.js +0 -16
- package/server/lib/opencode/mcp-oauth-callback.test.js +0 -111
- package/server/lib/routing/feature-flag.js +0 -11
- package/server/lib/small-model/call.js +0 -851
- package/server/lib/small-model/call.test.js +0 -1292
- package/server/lib/small-model/catalog.js +0 -13
- package/server/lib/small-model/resolve.js +0 -131
- package/server/lib/small-model/resolve.test.js +0 -197
- package/server/lib/small-model/runtime-providers.js +0 -164
- package/server/lib/small-model/runtime-providers.test.js +0 -118
- package/server/lib/system-prompt/DOCUMENTATION.md +0 -36
- package/server/lib/system-prompt/runtime.js +0 -49
- package/server/lib/system-prompt/runtime.test.js +0 -76
- package/server/lib/walkthrough/reproduce-2607.test.js +0 -148
|
@@ -6,13 +6,23 @@ This module exposes OpenChamber to agents as typed OpenCode custom tools. There
|
|
|
6
6
|
are two, because controlling sessions and driving a page are separate intents
|
|
7
7
|
the user can want independently:
|
|
8
8
|
|
|
9
|
-
- `openchamber` — projects, sessions, worktrees,
|
|
10
|
-
|
|
9
|
+
- `openchamber` — projects, sessions, worktrees, scheduled tasks, and showing
|
|
10
|
+
a file to the user (`file.open`). Enabled while the persisted
|
|
11
|
+
`agentControlToolEnabled` setting is not `false`.
|
|
11
12
|
- `openchamber_web` — looking at and interacting with the page in OpenChamber's
|
|
12
13
|
browser panel. Enabled while `agentWebToolEnabled` is not `false`.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
- `openchamber_notify` — `notify.send`, a notification to the user through
|
|
15
|
+
`lib/notifications/emit-route.js` (same limits and rate window as
|
|
16
|
+
`POST /api/notifications/emit`). Off by default: enabled only while
|
|
17
|
+
`agentNotifyToolEnabled` is `true`, and the control service refuses the
|
|
18
|
+
action when the setting is off, so a stale plugin cannot keep paging.
|
|
19
|
+
|
|
20
|
+
Both default to on, are toggled in Settings → General → OpenCode CLI, and take
|
|
21
|
+
effect in the running OpenCode within a couple of seconds — OpenChamber rewrites
|
|
22
|
+
the managed config file OpenCode watches (see
|
|
23
|
+
`lib/opencode/managed-config-file.js`). Installs where the user's own
|
|
24
|
+
environment sets `OPENCODE_CONFIG` fall back to `OPENCODE_CONFIG_CONTENT` and
|
|
25
|
+
still need a restart for a toggle. Each tool carries only its own actions and
|
|
16
26
|
only the parameters those actions use, so turning one off removes its inputs
|
|
17
27
|
from the schema rather than leaving them visible. The plugin is injected only
|
|
18
28
|
when OpenChamber launches and owns the OpenCode process, and not at all when
|
|
@@ -27,15 +37,19 @@ both settings are `false`.
|
|
|
27
37
|
## Runtime flow
|
|
28
38
|
|
|
29
39
|
1. The OpenChamber HTTP listener binds and publishes its authoritative port.
|
|
30
|
-
2. `
|
|
31
|
-
`<openchamber-data-dir>/agent-tool/` and
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
2. `materializePlugin()` writes the plugin under
|
|
41
|
+
`<openchamber-data-dir>/agent-tool/` and returns its directory; the managed
|
|
42
|
+
config layer lists that directory in `<data-dir>/opencode.managed.json` and
|
|
43
|
+
rewrites the file whenever a tool setting changes.
|
|
44
|
+
3. `createChildEnv()` adds a random per-child token and the callback URL to the
|
|
45
|
+
managed OpenCode child environment. They are present even while every tool
|
|
46
|
+
is off, so a tool switched on later can call back without a restart. The URL
|
|
47
|
+
points at loopback, except when the listener is bound to one concrete
|
|
48
|
+
address (`--host <ip>`): that socket does not answer on loopback, so the URL
|
|
49
|
+
uses the bound address instead.
|
|
37
50
|
4. The plugin calls `POST /api/openchamber/agent-tool` with its typed input and
|
|
38
|
-
OpenCode
|
|
51
|
+
the session id OpenCode gives the tool; OpenChamber resolves the session's
|
|
52
|
+
directory on its own side.
|
|
39
53
|
5. The route delegates the fixed action allowlist directly to the shared
|
|
40
54
|
OpenChamber control service. The CLI uses the same service through its
|
|
41
55
|
authenticated HTTP adapter, so Goal Mode ordering, wait behavior,
|
|
@@ -63,8 +77,11 @@ both settings are `false`.
|
|
|
63
77
|
`schedule.list` already returns scheduler status, and enable/disable are one
|
|
64
78
|
`schedule.toggle` action driven by the `disabled` boolean.
|
|
65
79
|
- The tool description frames intent: created sessions and scheduled tasks are
|
|
66
|
-
user-facing work the user follows up with
|
|
67
|
-
delegate parts of its
|
|
80
|
+
user-facing work the user follows up with. The agent must not decide on its
|
|
81
|
+
own to delegate parts of its current task, but an explicit user request to
|
|
82
|
+
create, send, or schedule always wins, even when it relates to the current
|
|
83
|
+
task (strict models otherwise read the old unconditional "never delegate" as
|
|
84
|
+
a hard ban and refused user-requested sends).
|
|
68
85
|
- Optional behavior switches (`worktree`, `goal`, `agent`, `variant`, `wait`)
|
|
69
86
|
state their default and an explicit "only when the user asks" rule so agents
|
|
70
87
|
do not invent worktrees, goal mode, or waits the user never requested.
|
|
@@ -89,7 +106,12 @@ both settings are `false`.
|
|
|
89
106
|
- Inputs map to a fixed action and parameter allowlist. There is no arbitrary
|
|
90
107
|
CLI, shell, route, or URL forwarding.
|
|
91
108
|
- Session/worktree deletion and project-path registration are not exposed.
|
|
92
|
-
-
|
|
109
|
+
- A cancelled turn aborts the session's in-flight actions. OpenCode 2 gives a
|
|
110
|
+
plugin tool no abort signal and the plugin's request stays open, so the
|
|
111
|
+
server tracks in-flight actions per session and `abortSession(sessionID)` is
|
|
112
|
+
called from the event dispatch in `server/index.js` when the stream reports
|
|
113
|
+
`session.idle` with `aborted: true`; the abort signal then reaches the
|
|
114
|
+
shared service as before. A dropped HTTP request still aborts as well.
|
|
93
115
|
|
|
94
116
|
## Result contract
|
|
95
117
|
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import { pathToFileURL } from 'node:url';
|
|
2
|
-
import { appendManagedPlugin } from '../opencode/managed-plugin-config.js';
|
|
3
1
|
import {
|
|
4
2
|
OPENCHAMBER_AGENT_TOOL_ACTION_DEFINITIONS,
|
|
5
3
|
OPENCHAMBER_AGENT_TOOL_ACTIONS,
|
|
6
4
|
OPENCHAMBER_MEMORY_ACTION_DEFINITIONS,
|
|
7
5
|
OPENCHAMBER_MEMORY_ACTIONS,
|
|
6
|
+
OPENCHAMBER_NOTIFY_ACTION_DEFINITIONS,
|
|
7
|
+
OPENCHAMBER_NOTIFY_ACTIONS,
|
|
8
8
|
resolveAgentToolAction,
|
|
9
9
|
OPENCHAMBER_WEB_ACTION_DEFINITIONS,
|
|
10
10
|
OPENCHAMBER_WEB_ACTIONS,
|
|
11
11
|
} from '../openchamber-control/actions.js';
|
|
12
12
|
|
|
13
13
|
const TOOL_SCHEMA_VERSION = 1;
|
|
14
|
+
const PLUGIN_ID = 'openchamber-agent-tool';
|
|
14
15
|
// Everything either managed tool may ask for; the agent allowlist stays
|
|
15
16
|
// narrower than the full control surface.
|
|
16
|
-
const ACTIONS = new Set([
|
|
17
|
+
const ACTIONS = new Set([
|
|
18
|
+
...OPENCHAMBER_AGENT_TOOL_ACTIONS,
|
|
19
|
+
...OPENCHAMBER_WEB_ACTIONS,
|
|
20
|
+
...OPENCHAMBER_MEMORY_ACTIONS,
|
|
21
|
+
...OPENCHAMBER_NOTIFY_ACTIONS,
|
|
22
|
+
]);
|
|
17
23
|
const AGENT_TOOL_ACTION_TITLES = Object.fromEntries(
|
|
18
24
|
[
|
|
19
25
|
...OPENCHAMBER_AGENT_TOOL_ACTION_DEFINITIONS,
|
|
20
26
|
...OPENCHAMBER_WEB_ACTION_DEFINITIONS,
|
|
21
27
|
...OPENCHAMBER_MEMORY_ACTION_DEFINITIONS,
|
|
28
|
+
...OPENCHAMBER_NOTIFY_ACTION_DEFINITIONS,
|
|
22
29
|
].map(({ action, title }) => [action, title]),
|
|
23
30
|
);
|
|
24
31
|
|
|
@@ -29,7 +36,7 @@ const AGENT_TOOL_ACTION_TITLES = Object.fromEntries(
|
|
|
29
36
|
* in the other tool's schema, which is both misleading and paid for in context
|
|
30
37
|
* on every call.
|
|
31
38
|
*/
|
|
32
|
-
const WEB_PARAMETER_NAMES = ['url', 'selector', 'text', 'value', 'submit', 'direction', 'viewport', 'label'];
|
|
39
|
+
const WEB_PARAMETER_NAMES = ['url', 'selector', 'text', 'value', 'submit', 'direction', 'viewport', 'label', 'tabId'];
|
|
33
40
|
// `title` is shared with the control tool, so it is not listed here — only the
|
|
34
41
|
// names memory alone introduces are kept out of the other schemas.
|
|
35
42
|
const MEMORY_ONLY_PARAMETER_NAMES = ['body', 'scope', 'memoryId', 'type'];
|
|
@@ -79,6 +86,7 @@ const ALL_PARAMETER_PROPERTIES = {
|
|
|
79
86
|
cron: { type: 'string', description: 'Cron expression' },
|
|
80
87
|
timezone: { type: 'string', description: 'IANA timezone' },
|
|
81
88
|
disabled: { type: 'boolean', description: 'true disables and false enables; required for schedule.toggle' },
|
|
89
|
+
path: { type: 'string', description: 'File to show for file.open; absolute, or relative to the session directory' },
|
|
82
90
|
url: { type: 'string', description: 'http(s) URL for browser.open' },
|
|
83
91
|
selector: { type: 'string', description: 'CSS selector from a browser.snapshot result' },
|
|
84
92
|
text: { type: 'string', description: 'Visible label to match when no selector is given' },
|
|
@@ -87,6 +95,7 @@ const ALL_PARAMETER_PROPERTIES = {
|
|
|
87
95
|
direction: { type: 'string', enum: ['up', 'down', 'top', 'bottom'], description: 'Scroll direction for browser.scroll' },
|
|
88
96
|
viewport: { type: 'string', enum: ['mobile', 'tablet', 'desktop', 'fill'], description: 'Page layout size; snapshots report which one is in effect' },
|
|
89
97
|
label: { type: 'string', description: 'Short name for a browser.capture image, such as before-fix' },
|
|
98
|
+
tabId: { type: 'string', description: 'Browser tab to act on, an id from the tabs a browser.snapshot lists. Omit to use the tab the user is looking at' },
|
|
90
99
|
body: { type: 'string', description: 'Full text of the memory; state it so it still makes sense in a session that has none of this conversation' },
|
|
91
100
|
scope: { type: 'string', enum: ['global', 'project', 'both'], description: 'global is about the user and applies everywhere; project is about this codebase. both is only valid for memory.list' },
|
|
92
101
|
memoryId: { type: 'string', description: 'Memory ID from a memory.list or memory.read result' },
|
|
@@ -108,11 +117,21 @@ const MEMORY_PARAMETER_PROPERTIES = {
|
|
|
108
117
|
...MEMORY_PARAMETER_OVERRIDES,
|
|
109
118
|
};
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
// Its own names, not the shared map: `title` and `body` mean something else in
|
|
121
|
+
// the control and memory tools.
|
|
122
|
+
const NOTIFY_PARAMETER_PROPERTIES = {
|
|
123
|
+
title: { type: 'string', description: 'Short headline the user reads first, up to 120 characters' },
|
|
124
|
+
body: { type: 'string', description: 'One or two sentences of detail, up to 500 characters' },
|
|
125
|
+
showWhenFocused: { type: 'boolean', description: 'Show it even while the user is looking at OpenChamber. Only for something that cannot wait' },
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const CONTROL_TOOL_DESCRIPTION = "Control OpenChamber projects, sessions, and scheduled tasks on the user's behalf. Sessions and scheduled tasks you create are for the user to follow and interact with. Do not decide on your own to hand parts of your current task to another session; when the user asks you to create a session, send a prompt to one, or schedule a task, do it, including when the work relates to your current task. Use one action per call. Scope with projectId or directory; omit both to use the current session directory. Session dispatches return immediately by default and you receive no notification when a dispatched session finishes, so never promise to report back on it; the user follows it in OpenChamber; a dispatched session needs no follow-up from you. If the user later asks how it went, use session.messages (add wait to block until it is idle, lastAssistant for just the final answer) — session.send always sends a NEW prompt and never just waits. Set wait only when the user asks or the next step requires the completed result. Session and worktree deletion are unavailable.";
|
|
112
129
|
|
|
113
130
|
const WEB_TOOL_DESCRIPTION = "Look at and interact with a web page in OpenChamber's browser panel, so you can check your own work rather than describing what you expect. Use one action per call. Open a page, snapshot it to read its text and its interactive elements, then click, type or scroll using the selectors the snapshot returned; snapshots also report any errors the page logged. Pass a selector to browser.snapshot to read one part of a long page. browser.inspect returns computed styles when the question is how something renders. Set viewport to check a layout at mobile, tablet or desktop size. The page runs with the user's real logins, so treat what you see as their live session.";
|
|
114
131
|
|
|
115
|
-
const MEMORY_TOOL_DESCRIPTION = "Keep what you learn across sessions, so the user does not have to explain the same thing twice. Use one action per call. The session already lists the titles of what is stored. A title is an abbreviation, not the memory: read the entry with memory.read before acting on it, because titles leave out the conditions and exceptions that decide how the memory applies, and the ones that look self-explanatory hide them most often. Save something only when it will still be true in a later session — a stable preference, a project convention, a decision and its reason, or a hard-won pointer. Do not save one-off task state, anything you can read from the code, secrets or credentials, or anything the user asked you not to keep. Choose the scope deliberately: global is about the user and reaches every project, so put a project's conventions in project scope.
|
|
132
|
+
const MEMORY_TOOL_DESCRIPTION = "Keep what you learn across sessions, so the user does not have to explain the same thing twice. Use one action per call. The session already lists the titles of what is stored. A title is an abbreviation, not the memory: read the entry with memory.read once before acting on it (it then stays in your context; do not re-read it on later turns), because titles leave out the conditions and exceptions that decide how the memory applies, and the ones that look self-explanatory hide them most often. Save something only when it will still be true in a later session — a stable preference, a project convention, a decision and its reason, or a hard-won pointer. Do not save one-off task state, anything you can read from the code, secrets or credentials, or anything the user asked you not to keep; when the user explicitly asks you to remember something, save it, unless it is a secret or credential. Choose the scope deliberately: global is about the user and reaches every project, so put a project's conventions in project scope. Save in the moment, without asking first, when the user corrects how you work or states a preference, confirms that a non-obvious approach worked, or when you learn a project fact that took real effort to find. One fact per entry. The user can review and remove what you save, so save when it fits and mention it briefly.";
|
|
133
|
+
|
|
134
|
+
const NOTIFY_TOOL_DESCRIPTION = "Send the user a notification through OpenChamber, so they learn about something without watching the session. Use it when you finish work that took long enough for the user to step away, when you are blocked on something only the user can resolve, or when the user asked to be told about something. Do not use it for routine progress, for every finished step, or to repeat what your reply already says to a user who is present. Keep the title short and put detail in the body.";
|
|
116
135
|
|
|
117
136
|
const asNonEmptyString = (value) => {
|
|
118
137
|
if (typeof value !== 'string') return null;
|
|
@@ -157,16 +176,29 @@ const resolveConcreteBoundAddress = (value) => {
|
|
|
157
176
|
* keeps the transport, metadata and failure handling identical, which is what
|
|
158
177
|
* the caller depends on.
|
|
159
178
|
*
|
|
179
|
+
* OpenCode 2 takes a tool's `input` as plain JSON Schema, so the generated file
|
|
180
|
+
* needs no imports at all — which it must not have, because OpenCode loads the
|
|
181
|
+
* entrypoint with a bare dynamic import and nothing resolves from the generated
|
|
182
|
+
* directory.
|
|
183
|
+
*
|
|
160
184
|
* The action schema carries `oneOf` only. A node combining `enum` and `oneOf`
|
|
161
185
|
* is valid JSON Schema, but some OpenAI-compatible gateways reject it and
|
|
162
186
|
* answer with an empty completion instead of an error, and the `oneOf` branches
|
|
163
187
|
* are what carry the per-action descriptions the model reads.
|
|
164
188
|
*/
|
|
165
|
-
const createToolEntry = ({ name, description, definitions, parameters }) => String.raw`
|
|
189
|
+
const createToolEntry = ({ name, description, definitions, parameters }) => String.raw` tools.add({
|
|
190
|
+
name: ${JSON.stringify(name)},
|
|
166
191
|
description: ${JSON.stringify(description)},
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
192
|
+
input: {
|
|
193
|
+
type: "object",
|
|
194
|
+
properties: {
|
|
195
|
+
action: { type: "string", oneOf: ${JSON.stringify(definitions.map((entry) => ({ const: entry.action, description: entry.description })))}, description: "OpenChamber action to perform" },
|
|
196
|
+
parameters: { type: "object", properties: ${JSON.stringify(parameters)}, additionalProperties: false, description: "Inputs for the action; use an empty object when none are needed" },
|
|
197
|
+
},
|
|
198
|
+
required: ["action"],
|
|
199
|
+
// Models routinely put the inputs next to the action; the schema has to
|
|
200
|
+
// let that reach execute() instead of rejecting the call.
|
|
201
|
+
additionalProperties: true,
|
|
170
202
|
},
|
|
171
203
|
async execute(input, context) {
|
|
172
204
|
// Models routinely put the inputs next to the action instead of inside
|
|
@@ -177,21 +209,22 @@ const createToolEntry = ({ name, description, definitions, parameters }) => Stri
|
|
|
177
209
|
const args = { ...flattened, ...(parameters ?? {}), action: requestedAction }
|
|
178
210
|
const actionTitles = ${JSON.stringify(AGENT_TOOL_ACTION_TITLES)}
|
|
179
211
|
const title = Object.hasOwn(actionTitles, args.action) ? actionTitles[args.action] : args.action
|
|
180
|
-
context.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
description: title,
|
|
187
|
-
},
|
|
212
|
+
const progress = (extra) => context.progress({
|
|
213
|
+
${name}: {
|
|
214
|
+
schemaVersion: ${TOOL_SCHEMA_VERSION},
|
|
215
|
+
action: args.action,
|
|
216
|
+
description: title,
|
|
217
|
+
...extra,
|
|
188
218
|
},
|
|
189
219
|
})
|
|
220
|
+
await progress()
|
|
190
221
|
const endpoint = process.env.OPENCHAMBER_AGENT_TOOL_URL
|
|
191
222
|
const token = process.env.OPENCHAMBER_AGENT_TOOL_TOKEN
|
|
223
|
+
// No output schema is declared, so a result must never carry an output
|
|
224
|
+
// field: OpenCode rejects that with "Tool result declared output
|
|
225
|
+
// without an output schema". The envelope travels as text content.
|
|
192
226
|
const failure = (payload) => ({
|
|
193
|
-
|
|
194
|
-
output: JSON.stringify(payload),
|
|
227
|
+
content: JSON.stringify(payload),
|
|
195
228
|
metadata: { openchamber: { schemaVersion: ${TOOL_SCHEMA_VERSION}, action: args.action, description: title, ok: false } },
|
|
196
229
|
})
|
|
197
230
|
if (!endpoint || !token) {
|
|
@@ -205,35 +238,28 @@ const createToolEntry = ({ name, description, definitions, parameters }) => Stri
|
|
|
205
238
|
authorization: "Bearer " + token,
|
|
206
239
|
"content-type": "application/json",
|
|
207
240
|
},
|
|
208
|
-
|
|
209
|
-
|
|
241
|
+
// OpenCode 2 no longer hands a tool its session directory, so the
|
|
242
|
+
// session id goes over instead and OpenChamber resolves the
|
|
243
|
+
// directory on its own side. The signal fires when the session is
|
|
244
|
+
// aborted, so the OpenChamber side stops the action too.
|
|
245
|
+
body: JSON.stringify({ input: args, sessionID: context.sessionID, tool: ${JSON.stringify(name)} }),
|
|
246
|
+
signal: context.signal,
|
|
210
247
|
})
|
|
211
|
-
const
|
|
248
|
+
const content = await response.text()
|
|
212
249
|
let result = null
|
|
213
|
-
try { result = JSON.parse(
|
|
250
|
+
try { result = JSON.parse(content) } catch {}
|
|
214
251
|
const valid = result?.schemaVersion === ${TOOL_SCHEMA_VERSION} && typeof result?.ok === "boolean" && typeof result?.action === "string"
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
metadata: {
|
|
218
|
-
${name}: {
|
|
219
|
-
schemaVersion: ${TOOL_SCHEMA_VERSION},
|
|
220
|
-
action: args.action,
|
|
221
|
-
description: title,
|
|
222
|
-
ok: valid && result.ok === true,
|
|
223
|
-
},
|
|
224
|
-
},
|
|
225
|
-
})
|
|
226
|
-
if (valid) return { title, output, metadata: { openchamber: { schemaVersion: ${TOOL_SCHEMA_VERSION}, action: args.action, description: title, ok: result.ok === true } } }
|
|
252
|
+
await progress({ ok: valid && result.ok === true })
|
|
253
|
+
if (valid) return { content, metadata: { openchamber: { schemaVersion: ${TOOL_SCHEMA_VERSION}, action: args.action, description: title, ok: result.ok === true } } }
|
|
227
254
|
return failure({ schemaVersion: ${TOOL_SCHEMA_VERSION}, ok: false, action: args.action, error: { message: "OpenChamber returned an invalid response", kind: "runtime", status: response.status } })
|
|
228
255
|
} catch (error) {
|
|
229
|
-
if (context.abort.aborted) throw error
|
|
230
256
|
return failure({ schemaVersion: ${TOOL_SCHEMA_VERSION}, ok: false, action: args.action, error: { message: error instanceof Error ? error.message : String(error), kind: "runtime" } })
|
|
231
257
|
}
|
|
232
258
|
},
|
|
233
|
-
}
|
|
259
|
+
})
|
|
234
260
|
`;
|
|
235
261
|
|
|
236
|
-
const createPluginSource = ({ includeControl, includeWeb, includeMemory }) => {
|
|
262
|
+
const createPluginSource = ({ includeControl, includeWeb, includeMemory, includeNotify }) => {
|
|
237
263
|
const entries = [];
|
|
238
264
|
if (includeControl) {
|
|
239
265
|
entries.push(createToolEntry({
|
|
@@ -259,6 +285,14 @@ const createPluginSource = ({ includeControl, includeWeb, includeMemory }) => {
|
|
|
259
285
|
parameters: MEMORY_PARAMETER_PROPERTIES,
|
|
260
286
|
}));
|
|
261
287
|
}
|
|
288
|
+
if (includeNotify) {
|
|
289
|
+
entries.push(createToolEntry({
|
|
290
|
+
name: 'openchamber_notify',
|
|
291
|
+
description: NOTIFY_TOOL_DESCRIPTION,
|
|
292
|
+
definitions: OPENCHAMBER_NOTIFY_ACTION_DEFINITIONS,
|
|
293
|
+
parameters: NOTIFY_PARAMETER_PROPERTIES,
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
262
296
|
|
|
263
297
|
// The callback carries the per-child token over plain HTTP. With a proxy in
|
|
264
298
|
// the child's environment, fetch would hand a non-loopback callback, token
|
|
@@ -275,16 +309,27 @@ const createPluginSource = ({ includeControl, includeWeb, includeMemory }) => {
|
|
|
275
309
|
}
|
|
276
310
|
}
|
|
277
311
|
|
|
278
|
-
export
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
312
|
+
export default {
|
|
313
|
+
id: ${JSON.stringify(PLUGIN_ID)},
|
|
314
|
+
setup: async (ctx) => {
|
|
315
|
+
exemptCallbackFromProxy()
|
|
316
|
+
await ctx.tool.transform((tools) => {
|
|
317
|
+
${entries.join('')} })
|
|
318
|
+
},
|
|
284
319
|
}
|
|
285
320
|
`;
|
|
286
321
|
};
|
|
287
322
|
|
|
323
|
+
// A configured plugin has to be a directory carrying a package.json that
|
|
324
|
+
// resolves an entrypoint; OpenCode skips a plain .js path.
|
|
325
|
+
const PLUGIN_PACKAGE_JSON = `${JSON.stringify({
|
|
326
|
+
name: 'openchamber-agent-tool',
|
|
327
|
+
version: '0.0.0',
|
|
328
|
+
private: true,
|
|
329
|
+
type: 'module',
|
|
330
|
+
exports: { '.': './index.js' },
|
|
331
|
+
}, null, 2)}\n`;
|
|
332
|
+
|
|
288
333
|
export const createAgentToolRuntime = (dependencies) => {
|
|
289
334
|
const {
|
|
290
335
|
crypto,
|
|
@@ -294,30 +339,51 @@ export const createAgentToolRuntime = (dependencies) => {
|
|
|
294
339
|
getActivePort,
|
|
295
340
|
getActiveHost = () => null,
|
|
296
341
|
executeAction,
|
|
297
|
-
|
|
342
|
+
resolveSessionDirectory,
|
|
298
343
|
} = dependencies;
|
|
299
|
-
const
|
|
300
|
-
const
|
|
344
|
+
const pluginRoot = path.join(dataDir, 'agent-tool');
|
|
345
|
+
const pluginDirectory = path.join(pluginRoot, PLUGIN_ID);
|
|
346
|
+
const pluginPath = path.join(pluginDirectory, 'index.js');
|
|
347
|
+
const pluginManifestPath = path.join(pluginDirectory, 'package.json');
|
|
301
348
|
let activeToken = null;
|
|
302
349
|
|
|
303
350
|
const getConcreteBoundAddress = () => resolveConcreteBoundAddress(getActiveHost());
|
|
304
351
|
|
|
305
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Write the plugin for the requested tool set and return its directory.
|
|
354
|
+
*
|
|
355
|
+
* Called both before a managed child starts and whenever the tool settings
|
|
356
|
+
* change while it runs, so the source on disk always matches the settings —
|
|
357
|
+
* the running OpenCode reloads the directory it already has configured.
|
|
358
|
+
*/
|
|
359
|
+
const materializePlugin = async ({ includeControl = true, includeWeb = true, includeMemory = true, includeNotify = false } = {}) => {
|
|
360
|
+
if (!includeControl && !includeWeb && !includeMemory && !includeNotify) {
|
|
361
|
+
throw new Error('At least one OpenChamber managed tool must be enabled to inject the plugin');
|
|
362
|
+
}
|
|
363
|
+
await fsPromises.mkdir(pluginDirectory, { recursive: true });
|
|
364
|
+
await fsPromises.writeFile(pluginManifestPath, PLUGIN_PACKAGE_JSON, { mode: 0o600 });
|
|
365
|
+
await fsPromises.writeFile(pluginPath, createPluginSource({ includeControl, includeWeb, includeMemory, includeNotify }), { mode: 0o600 });
|
|
366
|
+
return pluginDirectory;
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Callback URL and a fresh per-child token for a managed OpenCode process.
|
|
371
|
+
*
|
|
372
|
+
* These are always part of the child environment, including when every tool
|
|
373
|
+
* is currently off: a tool switched on later reaches a process that already
|
|
374
|
+
* knows where and how to call back, so the toggle needs no restart.
|
|
375
|
+
*/
|
|
376
|
+
const createChildEnv = () => {
|
|
306
377
|
const port = getActivePort();
|
|
307
378
|
if (!Number.isInteger(port) || port <= 0) {
|
|
308
379
|
throw new Error('OpenChamber listener port is unavailable for managed tool injection');
|
|
309
380
|
}
|
|
310
|
-
if (!includeControl && !includeWeb && !includeMemory) {
|
|
311
|
-
throw new Error('At least one OpenChamber managed tool must be enabled to inject the plugin');
|
|
312
|
-
}
|
|
313
|
-
await fsPromises.mkdir(pluginDirectory, { recursive: true });
|
|
314
|
-
await fsPromises.writeFile(pluginPath, createPluginSource({ includeControl, includeWeb, includeMemory }), { mode: 0o600 });
|
|
315
381
|
activeToken = crypto.randomBytes(32).toString('base64url');
|
|
316
|
-
|
|
382
|
+
// A listener bound to one concrete address does not answer on loopback,
|
|
383
|
+
// so the callback has to point at the bound address instead.
|
|
317
384
|
const callbackAddress = getConcreteBoundAddress() || '127.0.0.1';
|
|
318
385
|
const callbackHost = callbackAddress.includes(':') ? `[${callbackAddress}]` : callbackAddress;
|
|
319
386
|
return {
|
|
320
|
-
OPENCODE_CONFIG_CONTENT: appendManagedPlugin(env.OPENCODE_CONFIG_CONTENT, pluginUrl, 'managed tool'),
|
|
321
387
|
OPENCHAMBER_AGENT_TOOL_URL: `http://${callbackHost}:${port}/api/openchamber/agent-tool`,
|
|
322
388
|
OPENCHAMBER_AGENT_TOOL_TOKEN: activeToken,
|
|
323
389
|
};
|
|
@@ -357,8 +423,22 @@ export const createAgentToolRuntime = (dependencies) => {
|
|
|
357
423
|
if (typeof executeAction !== 'function') {
|
|
358
424
|
return createResult({ ok: false, action, error: { message: 'OpenChamber control service is unavailable', kind: 'runtime' } });
|
|
359
425
|
}
|
|
426
|
+
// OpenCode 2 tools no longer receive a directory, so the plugin sends the
|
|
427
|
+
// session id and the directory is resolved here. An unresolvable session
|
|
428
|
+
// falls through with no directory, exactly like the old "no directory" path.
|
|
429
|
+
let contextDirectory = asNonEmptyString(payload.contextDirectory) ?? undefined;
|
|
430
|
+
const sessionID = asNonEmptyString(payload.sessionID);
|
|
431
|
+
if (!contextDirectory && sessionID && typeof resolveSessionDirectory === 'function') {
|
|
432
|
+
contextDirectory = await Promise.resolve(resolveSessionDirectory(sessionID))
|
|
433
|
+
.then((value) => asNonEmptyString(value) ?? undefined)
|
|
434
|
+
.catch(() => undefined);
|
|
435
|
+
}
|
|
360
436
|
try {
|
|
361
|
-
|
|
437
|
+
// The calling session scopes browser actions to that session's page.
|
|
438
|
+
const contextSessionId = asNonEmptyString(payload.contextSessionId) ?? sessionID;
|
|
439
|
+
const data = await executeAction(action, { ...payload.input, action }, contextDirectory, contextSessionId
|
|
440
|
+
? { ...options, contextSessionId }
|
|
441
|
+
: options);
|
|
362
442
|
return createResult({ ok: true, action, data });
|
|
363
443
|
} catch (error) {
|
|
364
444
|
return createResult({
|
|
@@ -378,6 +458,29 @@ export const createAgentToolRuntime = (dependencies) => {
|
|
|
378
458
|
}
|
|
379
459
|
};
|
|
380
460
|
|
|
461
|
+
// In-flight actions per session. The plugin forwards OpenCode's abort
|
|
462
|
+
// signal (2.0.12+), which closes its request and aborts the action here.
|
|
463
|
+
// Before that release the request stayed open after the user cancelled the
|
|
464
|
+
// turn, so the server also listens for the cancel on the event stream
|
|
465
|
+
// (`session.idle` with `aborted: true`) and aborts the actions itself.
|
|
466
|
+
const inflightBySession = new Map();
|
|
467
|
+
const trackInflight = (sessionID, controller) => {
|
|
468
|
+
if (!sessionID) return () => {};
|
|
469
|
+
const set = inflightBySession.get(sessionID) ?? new Set();
|
|
470
|
+
set.add(controller);
|
|
471
|
+
inflightBySession.set(sessionID, set);
|
|
472
|
+
return () => {
|
|
473
|
+
set.delete(controller);
|
|
474
|
+
if (set.size === 0) inflightBySession.delete(sessionID);
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
const abortSession = (sessionID) => {
|
|
478
|
+
const set = inflightBySession.get(asNonEmptyString(sessionID));
|
|
479
|
+
if (!set) return 0;
|
|
480
|
+
for (const controller of set) controller.abort();
|
|
481
|
+
return set.size;
|
|
482
|
+
};
|
|
483
|
+
|
|
381
484
|
const registerRoutes = (app, express) => {
|
|
382
485
|
app.post('/api/openchamber/agent-tool', express.json({ limit: '1mb' }), async (req, res) => {
|
|
383
486
|
if (!authorize(req)) return res.status(401).json({ error: 'Unauthorized' });
|
|
@@ -387,6 +490,7 @@ export const createAgentToolRuntime = (dependencies) => {
|
|
|
387
490
|
};
|
|
388
491
|
req.once('aborted', abortOnDisconnect);
|
|
389
492
|
res.once('close', abortOnDisconnect);
|
|
493
|
+
const untrack = trackInflight(asNonEmptyString(req.body?.sessionID), controller);
|
|
390
494
|
try {
|
|
391
495
|
return res.json(await execute(req.body, { signal: controller.signal }));
|
|
392
496
|
} catch (error) {
|
|
@@ -396,6 +500,7 @@ export const createAgentToolRuntime = (dependencies) => {
|
|
|
396
500
|
error: { message: error instanceof Error ? error.message : String(error), kind: 'runtime' },
|
|
397
501
|
}));
|
|
398
502
|
} finally {
|
|
503
|
+
untrack();
|
|
399
504
|
req.off('aborted', abortOnDisconnect);
|
|
400
505
|
res.off('close', abortOnDisconnect);
|
|
401
506
|
}
|
|
@@ -403,8 +508,12 @@ export const createAgentToolRuntime = (dependencies) => {
|
|
|
403
508
|
};
|
|
404
509
|
|
|
405
510
|
return {
|
|
406
|
-
|
|
511
|
+
pluginDirectory,
|
|
512
|
+
materializePlugin,
|
|
513
|
+
createChildEnv,
|
|
514
|
+
authorizeRequest: authorize,
|
|
407
515
|
registerRoutes,
|
|
408
516
|
execute,
|
|
517
|
+
abortSession,
|
|
409
518
|
};
|
|
410
519
|
};
|