@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
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const NOTIFICATION_EMIT_PATH = '/api/notifications/emit';
|
|
4
|
+
|
|
5
|
+
const RATE_WINDOW_MS = 10_000;
|
|
6
|
+
const RATE_MAX_PER_WINDOW = 10;
|
|
7
|
+
|
|
8
|
+
const optionalText = (max) => z.string().trim().min(1).max(max).optional();
|
|
9
|
+
|
|
10
|
+
const emitBodySchema = z.object({
|
|
11
|
+
title: optionalText(120),
|
|
12
|
+
body: optionalText(500),
|
|
13
|
+
tag: optionalText(128),
|
|
14
|
+
sessionId: optionalText(128),
|
|
15
|
+
directory: optionalText(4096),
|
|
16
|
+
// Opt-in for notices that matter even while OpenChamber is in front.
|
|
17
|
+
showWhenFocused: z.boolean().optional(),
|
|
18
|
+
}).refine((value) => value.title || value.body, { message: 'title or body required' });
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Raises a notification on behalf of a plugin or the agent, through the same
|
|
22
|
+
* live delivery the built-in triggers use. `kind` is always `plugin`, so a
|
|
23
|
+
* caller cannot impersonate kinds the UI treats specially. One rate window is
|
|
24
|
+
* shared by every caller, the HTTP route and the agent tool alike.
|
|
25
|
+
*
|
|
26
|
+
* `emit` resolves to `{ status, body }`: 200 delivered or skipped by settings,
|
|
27
|
+
* 400 invalid input, 429 rate limited (with `retryAfter` seconds).
|
|
28
|
+
*/
|
|
29
|
+
export const createPluginNotificationEmitter = (dependencies) => {
|
|
30
|
+
const {
|
|
31
|
+
readSettingsFromDiskMigrated,
|
|
32
|
+
emitDesktopNotification,
|
|
33
|
+
broadcastUiNotification,
|
|
34
|
+
now = Date.now,
|
|
35
|
+
} = dependencies;
|
|
36
|
+
|
|
37
|
+
let windowStartedAt = 0;
|
|
38
|
+
let windowCount = 0;
|
|
39
|
+
|
|
40
|
+
const takeRateSlot = () => {
|
|
41
|
+
const current = now();
|
|
42
|
+
if (current - windowStartedAt >= RATE_WINDOW_MS) {
|
|
43
|
+
windowStartedAt = current;
|
|
44
|
+
windowCount = 0;
|
|
45
|
+
}
|
|
46
|
+
if (windowCount >= RATE_MAX_PER_WINDOW) {
|
|
47
|
+
return Math.ceil((windowStartedAt + RATE_WINDOW_MS - current) / 1000);
|
|
48
|
+
}
|
|
49
|
+
windowCount += 1;
|
|
50
|
+
return 0;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const emit = async (input) => {
|
|
54
|
+
const parsed = emitBodySchema.safeParse(input);
|
|
55
|
+
if (!parsed.success) {
|
|
56
|
+
return { status: 400, body: { error: parsed.error.issues[0]?.message ?? 'invalid notification' } };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const retryAfter = takeRateSlot();
|
|
60
|
+
if (retryAfter > 0) {
|
|
61
|
+
return { status: 429, retryAfter, body: { error: 'too many notifications' } };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const settings = await readSettingsFromDiskMigrated();
|
|
65
|
+
if (settings.nativeNotificationsEnabled === false) {
|
|
66
|
+
return { status: 200, body: { delivered: false, reason: 'notifications-disabled' } };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const payload = {
|
|
70
|
+
title: parsed.data.title ?? 'OpenChamber',
|
|
71
|
+
body: parsed.data.body,
|
|
72
|
+
tag: parsed.data.tag,
|
|
73
|
+
kind: 'plugin',
|
|
74
|
+
sessionId: parsed.data.sessionId,
|
|
75
|
+
directory: parsed.data.directory,
|
|
76
|
+
requireHidden: parsed.data.showWhenFocused !== true && settings.notificationMode !== 'always',
|
|
77
|
+
};
|
|
78
|
+
const desktopNotificationDelivered = emitDesktopNotification(payload) === true;
|
|
79
|
+
broadcastUiNotification(payload, { desktopNotificationDelivered });
|
|
80
|
+
return { status: 200, body: { delivered: true } };
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return { emit };
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `POST /api/notifications/emit`. Two callers are accepted: a plugin inside
|
|
88
|
+
* the managed OpenCode (the agent-tool bearer token, checked before API auth)
|
|
89
|
+
* and any client that passes the regular API auth.
|
|
90
|
+
*/
|
|
91
|
+
export const registerNotificationEmitRoutes = (app, dependencies) => {
|
|
92
|
+
const { express, isAgentToolRequestAuthorized, emitter } = dependencies;
|
|
93
|
+
|
|
94
|
+
const jsonBody = express.json({ limit: '16kb' });
|
|
95
|
+
|
|
96
|
+
const respond = async (req, res, next) => {
|
|
97
|
+
try {
|
|
98
|
+
const result = await emitter.emit(req.body);
|
|
99
|
+
if (result.retryAfter) res.setHeader('Retry-After', String(result.retryAfter));
|
|
100
|
+
return res.status(result.status).json(result.body);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
return next(error);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
// Registered before API auth: a managed plugin carries no UI session.
|
|
108
|
+
registerPluginRoute: () => {
|
|
109
|
+
app.post(NOTIFICATION_EMIT_PATH, jsonBody, (req, res, next) => (
|
|
110
|
+
isAgentToolRequestAuthorized(req) ? respond(req, res, next) : next()
|
|
111
|
+
));
|
|
112
|
+
},
|
|
113
|
+
// Registered after API auth: everything else is an ordinary API caller.
|
|
114
|
+
registerApiRoute: () => {
|
|
115
|
+
app.post(NOTIFICATION_EMIT_PATH, jsonBody, respond);
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import request from 'supertest';
|
|
4
|
+
import { createPluginNotificationEmitter, registerNotificationEmitRoutes } from './emit-route.js';
|
|
5
|
+
|
|
6
|
+
const PLUGIN_TOKEN = 'Bearer plugin-token';
|
|
7
|
+
const UI_TOKEN = 'Bearer ui-token';
|
|
8
|
+
|
|
9
|
+
const createApp = ({ settings = { nativeNotificationsEnabled: true, notificationMode: 'hidden-only' }, now = () => 0 } = {}) => {
|
|
10
|
+
const delivered = [];
|
|
11
|
+
const app = express();
|
|
12
|
+
const emitter = createPluginNotificationEmitter({
|
|
13
|
+
readSettingsFromDiskMigrated: async () => settings,
|
|
14
|
+
emitDesktopNotification: () => false,
|
|
15
|
+
broadcastUiNotification: (payload, options) => delivered.push({ payload, options }),
|
|
16
|
+
now,
|
|
17
|
+
});
|
|
18
|
+
const routes = registerNotificationEmitRoutes(app, {
|
|
19
|
+
express,
|
|
20
|
+
isAgentToolRequestAuthorized: (req) => req.headers.authorization === PLUGIN_TOKEN,
|
|
21
|
+
emitter,
|
|
22
|
+
});
|
|
23
|
+
routes.registerPluginRoute();
|
|
24
|
+
// Stands in for the server's API auth gate between the two registrations.
|
|
25
|
+
app.use('/api', (req, res, next) => (
|
|
26
|
+
req.headers.authorization === UI_TOKEN ? next() : res.status(401).json({ error: 'UI session missing' })
|
|
27
|
+
));
|
|
28
|
+
routes.registerApiRoute();
|
|
29
|
+
return { app, delivered };
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
describe('POST /api/notifications/emit', () => {
|
|
33
|
+
it('delivers a plugin notification without a UI session', async () => {
|
|
34
|
+
const { app, delivered } = createApp();
|
|
35
|
+
const response = await request(app)
|
|
36
|
+
.post('/api/notifications/emit')
|
|
37
|
+
.set('Authorization', PLUGIN_TOKEN)
|
|
38
|
+
.send({ title: ' Build done ', body: 'Ready', sessionId: 'ses_1' });
|
|
39
|
+
|
|
40
|
+
expect(response.status).toBe(200);
|
|
41
|
+
expect(response.body).toEqual({ delivered: true });
|
|
42
|
+
expect(delivered).toEqual([{
|
|
43
|
+
payload: {
|
|
44
|
+
title: 'Build done',
|
|
45
|
+
body: 'Ready',
|
|
46
|
+
tag: undefined,
|
|
47
|
+
kind: 'plugin',
|
|
48
|
+
sessionId: 'ses_1',
|
|
49
|
+
directory: undefined,
|
|
50
|
+
requireHidden: true,
|
|
51
|
+
},
|
|
52
|
+
options: { desktopNotificationDelivered: false },
|
|
53
|
+
}]);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('accepts an ordinary API caller and rejects an unauthenticated one', async () => {
|
|
57
|
+
const { app, delivered } = createApp();
|
|
58
|
+
await request(app).post('/api/notifications/emit').set('Authorization', UI_TOKEN).send({ body: 'Hi' }).expect(200);
|
|
59
|
+
await request(app).post('/api/notifications/emit').send({ body: 'Hi' }).expect(401);
|
|
60
|
+
await request(app).post('/api/notifications/emit').set('Authorization', 'Bearer wrong').send({ body: 'Hi' }).expect(401);
|
|
61
|
+
expect(delivered.map(({ payload }) => payload.title)).toEqual(['OpenChamber']);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('never lets a caller choose the notification kind', async () => {
|
|
65
|
+
const { app, delivered } = createApp();
|
|
66
|
+
await request(app)
|
|
67
|
+
.post('/api/notifications/emit')
|
|
68
|
+
.set('Authorization', PLUGIN_TOKEN)
|
|
69
|
+
.send({ title: 'x', kind: 'opencode-restart-interrupted' })
|
|
70
|
+
.expect(200);
|
|
71
|
+
expect(delivered[0].payload.kind).toBe('plugin');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('rejects empty and oversized payloads', async () => {
|
|
75
|
+
const { app, delivered } = createApp();
|
|
76
|
+
const post = (body) => request(app).post('/api/notifications/emit').set('Authorization', PLUGIN_TOKEN).send(body);
|
|
77
|
+
await post({}).expect(400);
|
|
78
|
+
await post({ title: ' ' }).expect(400);
|
|
79
|
+
await post({ title: 'x'.repeat(121) }).expect(400);
|
|
80
|
+
await post({ body: 'x'.repeat(501) }).expect(400);
|
|
81
|
+
expect(delivered).toEqual([]);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('limits the rate and recovers after the window', async () => {
|
|
85
|
+
let clock = 0;
|
|
86
|
+
const { app, delivered } = createApp({ now: () => clock });
|
|
87
|
+
const post = () => request(app).post('/api/notifications/emit').set('Authorization', PLUGIN_TOKEN).send({ body: 'tick' });
|
|
88
|
+
for (let index = 0; index < 10; index += 1) await post().expect(200);
|
|
89
|
+
const limited = await post();
|
|
90
|
+
expect(limited.status).toBe(429);
|
|
91
|
+
expect(limited.headers['retry-after']).toBe('10');
|
|
92
|
+
clock = 10_000;
|
|
93
|
+
await post().expect(200);
|
|
94
|
+
expect(delivered).toHaveLength(11);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('follows the notifications setting and the always mode', async () => {
|
|
98
|
+
const off = createApp({ settings: { nativeNotificationsEnabled: false } });
|
|
99
|
+
const skipped = await request(off.app).post('/api/notifications/emit').set('Authorization', PLUGIN_TOKEN).send({ body: 'x' });
|
|
100
|
+
expect(skipped.body).toEqual({ delivered: false, reason: 'notifications-disabled' });
|
|
101
|
+
expect(off.delivered).toEqual([]);
|
|
102
|
+
|
|
103
|
+
const always = createApp({ settings: { nativeNotificationsEnabled: true, notificationMode: 'always' } });
|
|
104
|
+
await request(always.app).post('/api/notifications/emit').set('Authorization', PLUGIN_TOKEN).send({ body: 'x' }).expect(200);
|
|
105
|
+
expect(always.delivered[0].payload.requireHidden).toBe(false);
|
|
106
|
+
|
|
107
|
+
const focused = createApp();
|
|
108
|
+
await request(focused.app).post('/api/notifications/emit').set('Authorization', PLUGIN_TOKEN).send({ body: 'x', showWhenFocused: true }).expect(200);
|
|
109
|
+
expect(focused.delivered[0].payload.requireHidden).toBe(false);
|
|
110
|
+
await request(focused.app).post('/api/notifications/emit').set('Authorization', PLUGIN_TOKEN).send({ body: 'x', showWhenFocused: 'yes' }).expect(400);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -4,6 +4,7 @@ export const createNotificationEmitterRuntime = (dependencies) => {
|
|
|
4
4
|
getDesktopNotifyEnabled,
|
|
5
5
|
desktopNotifyPrefix,
|
|
6
6
|
getUiNotificationClients,
|
|
7
|
+
getOpenChamberEventClients = () => new Set(),
|
|
7
8
|
getBroadcastGlobalUiEvent,
|
|
8
9
|
// Optional: in-process desktop shells (Electron main) inject a callback so
|
|
9
10
|
// notifications are delivered as a direct function call instead of a stdout
|
|
@@ -78,6 +79,20 @@ export const createNotificationEmitterRuntime = (dependencies) => {
|
|
|
78
79
|
},
|
|
79
80
|
};
|
|
80
81
|
|
|
82
|
+
// New clients share the control SSE; older clients retain their dedicated
|
|
83
|
+
// notification SSE. The global broadcaster still owns WebSocket delivery.
|
|
84
|
+
const controlClients = getOpenChamberEventClients();
|
|
85
|
+
if (controlClients.size > 0) {
|
|
86
|
+
const serializedPayload = JSON.stringify(syntheticPayload);
|
|
87
|
+
for (const client of controlClients) {
|
|
88
|
+
try {
|
|
89
|
+
writeSseEvent(client, syntheticPayload, serializedPayload);
|
|
90
|
+
} catch {
|
|
91
|
+
// One disconnected control client must not block other transports.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
81
96
|
const broadcastGlobalUiEvent = typeof getBroadcastGlobalUiEvent === 'function'
|
|
82
97
|
? getBroadcastGlobalUiEvent()
|
|
83
98
|
: null;
|
|
@@ -45,3 +45,35 @@ describe('notification emitter runtime', () => {
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
describe('shared control notification delivery', () => {
|
|
51
|
+
it('writes once to control SSE and once to the legacy/global broadcaster', () => {
|
|
52
|
+
const control = { write: vi.fn() };
|
|
53
|
+
const failed = { write: () => { throw new Error('closed'); } };
|
|
54
|
+
const broadcastGlobalUiEvent = vi.fn();
|
|
55
|
+
const runtime = createRuntime({
|
|
56
|
+
getOpenChamberEventClients: () => new Set([failed, control]),
|
|
57
|
+
getBroadcastGlobalUiEvent: () => broadcastGlobalUiEvent,
|
|
58
|
+
});
|
|
59
|
+
runtime.broadcastUiNotification({ title: 'Done', sessionId: 's1', kind: 'complete' });
|
|
60
|
+
expect(control.write).toHaveBeenCalledTimes(1);
|
|
61
|
+
expect(broadcastGlobalUiEvent).toHaveBeenCalledTimes(1);
|
|
62
|
+
const envelope = broadcastGlobalUiEvent.mock.calls[0][0];
|
|
63
|
+
expect(control.write).toHaveBeenCalledWith(`data: ${JSON.stringify(envelope)}\n\n`);
|
|
64
|
+
expect(envelope.properties.sessionId).toBe('s1');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('preserves legacy notification SSE without a global broadcaster', () => {
|
|
68
|
+
const control = { write: vi.fn() };
|
|
69
|
+
const legacy = { write: vi.fn() };
|
|
70
|
+
const runtime = createRuntime({
|
|
71
|
+
getOpenChamberEventClients: () => new Set([control]),
|
|
72
|
+
getUiNotificationClients: () => new Set([legacy]),
|
|
73
|
+
});
|
|
74
|
+
runtime.broadcastUiNotification({ title: 'Done' });
|
|
75
|
+
expect(control.write).toHaveBeenCalledTimes(1);
|
|
76
|
+
expect(legacy.write).toHaveBeenCalledTimes(1);
|
|
77
|
+
expect(control.write.mock.calls).toEqual(legacy.write.mock.calls);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -15,7 +15,8 @@ export const createPushRuntime = (deps) => {
|
|
|
15
15
|
const {
|
|
16
16
|
fsPromises,
|
|
17
17
|
path,
|
|
18
|
-
|
|
18
|
+
// Resolves the web-push module; it is loaded on first use, not with the server.
|
|
19
|
+
loadWebPush,
|
|
19
20
|
PUSH_SUBSCRIPTIONS_FILE_PATH,
|
|
20
21
|
readSettingsFromDiskMigrated,
|
|
21
22
|
writeSettingsToDisk,
|
|
@@ -86,6 +87,7 @@ export const createPushRuntime = (deps) => {
|
|
|
86
87
|
return { publicKey: existing.publicKey, privateKey: existing.privateKey };
|
|
87
88
|
}
|
|
88
89
|
|
|
90
|
+
const webPush = await loadWebPush();
|
|
89
91
|
const generated = webPush.generateVAPIDKeys();
|
|
90
92
|
const next = {
|
|
91
93
|
...settings,
|
|
@@ -210,6 +212,7 @@ export const createPushRuntime = (deps) => {
|
|
|
210
212
|
};
|
|
211
213
|
|
|
212
214
|
try {
|
|
215
|
+
const webPush = await loadWebPush();
|
|
213
216
|
await webPush.sendNotification(pushSubscription, body);
|
|
214
217
|
} catch (error) {
|
|
215
218
|
const statusCode = typeof error?.statusCode === 'number' ? error.statusCode : null;
|
|
@@ -344,6 +347,7 @@ export const createPushRuntime = (deps) => {
|
|
|
344
347
|
console.warn('[Push] No public origin configured for VAPID; set OPENCHAMBER_VAPID_SUBJECT or enable push once from a real origin.');
|
|
345
348
|
}
|
|
346
349
|
|
|
350
|
+
const webPush = await loadWebPush();
|
|
347
351
|
webPush.setVapidDetails(subject, keys.publicKey, keys.privateKey);
|
|
348
352
|
pushInitialized = true;
|
|
349
353
|
};
|
|
@@ -9,11 +9,11 @@ const createRuntime = () => createPushRuntime({
|
|
|
9
9
|
writeFile: vi.fn(async () => {}),
|
|
10
10
|
},
|
|
11
11
|
path: { dirname: () => '/tmp' },
|
|
12
|
-
|
|
12
|
+
loadWebPush: async () => ({
|
|
13
13
|
generateVAPIDKeys: vi.fn(() => ({ publicKey: 'public', privateKey: 'private' })),
|
|
14
14
|
sendNotification: vi.fn(async () => {}),
|
|
15
15
|
setVapidDetails: vi.fn(),
|
|
16
|
-
},
|
|
16
|
+
}),
|
|
17
17
|
PUSH_SUBSCRIPTIONS_FILE_PATH: '/tmp/push-subscriptions.json',
|
|
18
18
|
readSettingsFromDiskMigrated: vi.fn(async () => ({})),
|
|
19
19
|
writeSettingsToDisk: vi.fn(async () => {}),
|
|
@@ -297,7 +297,7 @@ export const registerNotificationRoutes = (app, dependencies) => {
|
|
|
297
297
|
});
|
|
298
298
|
|
|
299
299
|
// Cross-project seed for clients that do not initialize every directory:
|
|
300
|
-
// live status per session plus the permission and
|
|
300
|
+
// live status per session plus the permission requests and forms still
|
|
301
301
|
// waiting for an answer. Both come from the server's single upstream stream.
|
|
302
302
|
app.get('/api/sessions/status', async (_req, res) => {
|
|
303
303
|
await ensureSessionWatcher();
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { unwrapOpenCodeResponse } from '../opencode/response-envelope.js';
|
|
2
|
+
import { createSessionActivityProbe } from '../opencode/session-activity.js';
|
|
3
|
+
|
|
4
|
+
|
|
1
5
|
export const createNotificationTriggerRuntime = (deps) => {
|
|
2
6
|
const {
|
|
3
7
|
readSettingsFromDisk,
|
|
@@ -14,8 +18,22 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
14
18
|
isAnyInteractiveClientVisible,
|
|
15
19
|
buildOpenCodeUrl,
|
|
16
20
|
getOpenCodeAuthHeaders,
|
|
21
|
+
// OpenChamber's own session metadata (the goal lives there, not on the
|
|
22
|
+
// OpenCode record). Optional: without it no goal can suppress a push.
|
|
23
|
+
readSessionMetadata = null,
|
|
17
24
|
} = deps;
|
|
18
25
|
let getIsSessionAutoAccepting = deps.getIsSessionAutoAccepting;
|
|
26
|
+
const activityProbe = createSessionActivityProbe({ buildOpenCodeUrl, getOpenCodeAuthHeaders, timeoutMs: 2000 });
|
|
27
|
+
|
|
28
|
+
// A parent goes idle while a background subagent still works; OpenCode then
|
|
29
|
+
// hands the result back and the parent runs again. That first idle is a
|
|
30
|
+
// pause, so it announces nothing. When the check cannot be made, the idle is
|
|
31
|
+
// announced as before: a missed "ready" is worse than an early one.
|
|
32
|
+
const isPausedForSubagents = async (sessionId) => {
|
|
33
|
+
const statuses = await activityProbe.fetchActiveSessionStatuses();
|
|
34
|
+
if (!statuses) return false;
|
|
35
|
+
return (await activityProbe.hasWorkingChildren(sessionId, statuses)) === true;
|
|
36
|
+
};
|
|
19
37
|
const setGetIsSessionAutoAccepting = (resolver) => {
|
|
20
38
|
getIsSessionAutoAccepting = typeof resolver === 'function' ? resolver : undefined;
|
|
21
39
|
};
|
|
@@ -157,8 +175,57 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
157
175
|
const getParentIdFromPayload = (payload) => {
|
|
158
176
|
if (!payload || typeof payload !== 'object') return undefined;
|
|
159
177
|
if (payload.type !== 'session.created' && payload.type !== 'session.updated') return undefined;
|
|
160
|
-
const parentID = payload.properties?.info?.parentID
|
|
161
|
-
|
|
178
|
+
const parentID = payload.properties?.info?.parentID;
|
|
179
|
+
if (typeof parentID === 'string' && parentID.length > 0) return parentID;
|
|
180
|
+
// Only the full record from `session.created` proves a session has no
|
|
181
|
+
// parent. `session.updated` also carries partial records (usage, title)
|
|
182
|
+
// without `parentID`, and reading those as "no parent" turned a subagent
|
|
183
|
+
// into a main session, so its finish announced "ready" with subagent
|
|
184
|
+
// notifications turned off.
|
|
185
|
+
return payload.type === 'session.created' ? null : undefined;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// v2 splits one assistant turn over two events: `session.step.started`
|
|
189
|
+
// names the agent and model, `session.step.ended` carries the finish. The
|
|
190
|
+
// translator hands both over as `message.updated` on the same message id,
|
|
191
|
+
// so the start is remembered here and folded into the finish, which is the
|
|
192
|
+
// event the "ready" push is built from. Bounded: a session emits a handful
|
|
193
|
+
// of steps and the map is per process.
|
|
194
|
+
const ASSISTANT_STEP_CACHE_LIMIT = 500;
|
|
195
|
+
const assistantStepMeta = new Map();
|
|
196
|
+
// The reply a turn ended on: the idle event names only the session, so the
|
|
197
|
+
// ready notification borrows this step's id for its agent, model and text.
|
|
198
|
+
const lastAssistantStepBySession = new Map();
|
|
199
|
+
const rememberAssistantStep = (info) => {
|
|
200
|
+
if (!info || info.role !== 'assistant') return;
|
|
201
|
+
const id = String(info.id ?? '');
|
|
202
|
+
const agent = String(info.agent ?? info.mode ?? '');
|
|
203
|
+
const modelID = String(info.modelID ?? '');
|
|
204
|
+
if (!id || (!agent && !modelID)) return;
|
|
205
|
+
assistantStepMeta.delete(id);
|
|
206
|
+
assistantStepMeta.set(id, { agent, modelID });
|
|
207
|
+
const sessionId = String(info.sessionID ?? '');
|
|
208
|
+
if (sessionId) {
|
|
209
|
+
lastAssistantStepBySession.delete(sessionId);
|
|
210
|
+
lastAssistantStepBySession.set(sessionId, id);
|
|
211
|
+
while (lastAssistantStepBySession.size > ASSISTANT_STEP_CACHE_LIMIT) {
|
|
212
|
+
lastAssistantStepBySession.delete(lastAssistantStepBySession.keys().next().value);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
while (assistantStepMeta.size > ASSISTANT_STEP_CACHE_LIMIT) {
|
|
216
|
+
assistantStepMeta.delete(assistantStepMeta.keys().next().value);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const withRememberedStep = (info) => {
|
|
220
|
+
const remembered = info ? assistantStepMeta.get(String(info.id ?? '')) : undefined;
|
|
221
|
+
if (!remembered) return info;
|
|
222
|
+
const merged = { ...info };
|
|
223
|
+
if (!merged.agent && !merged.mode) {
|
|
224
|
+
merged.agent = remembered.agent;
|
|
225
|
+
merged.mode = remembered.agent;
|
|
226
|
+
}
|
|
227
|
+
if (!merged.modelID) merged.modelID = remembered.modelID;
|
|
228
|
+
return merged;
|
|
162
229
|
};
|
|
163
230
|
|
|
164
231
|
const maybeCacheSessionParentFromPayload = (payload) => {
|
|
@@ -177,7 +244,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
177
244
|
if (cached !== undefined) return cached;
|
|
178
245
|
|
|
179
246
|
try {
|
|
180
|
-
const base = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
|
|
247
|
+
const base = buildOpenCodeUrl(`/api/session/${encodeURIComponent(sessionId)}`, '');
|
|
181
248
|
const url = directory ? `${base}?directory=${encodeURIComponent(directory)}` : base;
|
|
182
249
|
const response = await fetch(url, {
|
|
183
250
|
method: 'GET',
|
|
@@ -190,7 +257,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
190
257
|
if (!response.ok) {
|
|
191
258
|
return undefined;
|
|
192
259
|
}
|
|
193
|
-
const session = await response.json().catch(() => null);
|
|
260
|
+
const session = unwrapOpenCodeResponse(await response.json().catch(() => null));
|
|
194
261
|
if (!session || typeof session !== 'object') {
|
|
195
262
|
return undefined;
|
|
196
263
|
}
|
|
@@ -281,19 +348,11 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
281
348
|
// A session with an ACTIVE goal suppresses per-turn ready notifications;
|
|
282
349
|
// the session-goal runtime sends its own notification when the goal
|
|
283
350
|
// settles. Fetch failures fall through to normal notification behavior.
|
|
284
|
-
const hasActiveSessionGoal = async (sessionId
|
|
285
|
-
if (!sessionId) return false;
|
|
351
|
+
const hasActiveSessionGoal = async (sessionId) => {
|
|
352
|
+
if (!sessionId || typeof readSessionMetadata !== 'function') return false;
|
|
286
353
|
try {
|
|
287
|
-
const
|
|
288
|
-
const
|
|
289
|
-
const response = await fetch(url, {
|
|
290
|
-
method: 'GET',
|
|
291
|
-
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
|
292
|
-
signal: AbortSignal.timeout(2000),
|
|
293
|
-
});
|
|
294
|
-
if (!response.ok) return false;
|
|
295
|
-
const session = await response.json().catch(() => null);
|
|
296
|
-
const goal = session?.metadata?.openchamber?.goal;
|
|
354
|
+
const metadata = await readSessionMetadata(sessionId);
|
|
355
|
+
const goal = metadata?.openchamber?.goal;
|
|
297
356
|
return Boolean(goal && typeof goal === 'object' && goal.status === 'active');
|
|
298
357
|
} catch {
|
|
299
358
|
return false;
|
|
@@ -309,7 +368,16 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
309
368
|
|
|
310
369
|
const sessionId = extractSessionIdFromPayload(payload);
|
|
311
370
|
const notificationDirectory = extractDirectoryFromPayload(payload);
|
|
371
|
+
// A user abort arrives as `session.idle` with `aborted: true`: the turn
|
|
372
|
+
// did not finish, so there is nothing to announce as ready.
|
|
373
|
+
if (payload.type === 'session.idle' && payload.properties?.aborted === true) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
|
|
312
377
|
if ((payload.type === 'session.idle' || payload.type === 'session.error') && sessionId) {
|
|
378
|
+
if (payload.type === 'session.idle' && await isPausedForSubagents(sessionId)) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
313
381
|
const error = payload.properties?.error;
|
|
314
382
|
const errorText = typeof error?.message === 'string'
|
|
315
383
|
? error.message
|
|
@@ -319,7 +387,10 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
319
387
|
type: 'message.updated',
|
|
320
388
|
properties: {
|
|
321
389
|
...payload.properties,
|
|
390
|
+
// Only a turn end announces readiness; a step's `stop` does not.
|
|
391
|
+
turnEnded: true,
|
|
322
392
|
info: {
|
|
393
|
+
id: lastAssistantStepBySession.get(sessionId),
|
|
323
394
|
sessionID: sessionId,
|
|
324
395
|
role: 'assistant',
|
|
325
396
|
finish: payload.type === 'session.error' ? 'error' : 'stop',
|
|
@@ -331,8 +402,13 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
331
402
|
}
|
|
332
403
|
|
|
333
404
|
if (payload.type === 'message.updated') {
|
|
334
|
-
|
|
335
|
-
|
|
405
|
+
rememberAssistantStep(payload.properties?.info);
|
|
406
|
+
const info = withRememberedStep(payload.properties?.info);
|
|
407
|
+
// v2 ends every step with a `message.updated`; the last one says `stop`,
|
|
408
|
+
// but the execution can still drain steering input after it. Readiness
|
|
409
|
+
// is announced from the execution's terminal `session.idle` instead.
|
|
410
|
+
if (info?.role === 'assistant' && info?.finish === 'stop' && sessionId && payload.properties?.turnEnded === true) {
|
|
411
|
+
payload = { ...payload, properties: { ...payload.properties, info } };
|
|
336
412
|
const settings = await readSettingsFromDisk();
|
|
337
413
|
|
|
338
414
|
if (settings.notifyOnSubtasks === false) {
|
|
@@ -353,7 +429,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
353
429
|
// While a goal drives the session, per-turn "ready" notifications are
|
|
354
430
|
// noise produced by the goal loop itself — the goal's own settle
|
|
355
431
|
// notification (complete/blocked/budget) is the final word instead.
|
|
356
|
-
if (await hasActiveSessionGoal(sessionId
|
|
432
|
+
if (await hasActiveSessionGoal(sessionId)) {
|
|
357
433
|
return;
|
|
358
434
|
}
|
|
359
435
|
|
|
@@ -504,7 +580,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
504
580
|
return;
|
|
505
581
|
}
|
|
506
582
|
|
|
507
|
-
if (payload.type === '
|
|
583
|
+
if (payload.type === 'form.created' && sessionId) {
|
|
508
584
|
const existingTimer = pushQuestionDebounceTimers.get(sessionId);
|
|
509
585
|
if (existingTimer) {
|
|
510
586
|
clearTimeout(existingTimer);
|
|
@@ -522,9 +598,14 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
522
598
|
return;
|
|
523
599
|
}
|
|
524
600
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
const
|
|
601
|
+
// v2 replaced questions with forms: the form's title is the ask, and
|
|
602
|
+
// the first field carries the detail a question used to put in its body.
|
|
603
|
+
const form = payload.properties?.form;
|
|
604
|
+
const header = typeof form?.title === 'string' ? form.title.trim() : '';
|
|
605
|
+
const firstField = Array.isArray(form?.fields) ? form.fields[0] : null;
|
|
606
|
+
const fieldTitle = typeof firstField?.title === 'string' ? firstField.title.trim() : '';
|
|
607
|
+
const fieldDescription = typeof firstField?.description === 'string' ? firstField.description.trim() : '';
|
|
608
|
+
const questionText = fieldDescription || fieldTitle;
|
|
528
609
|
|
|
529
610
|
let title = /plan\s*mode/i.test(header)
|
|
530
611
|
? 'Switch to plan mode'
|
|
@@ -604,7 +685,15 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
604
685
|
|
|
605
686
|
if (payload.type === 'permission.asked' && sessionId) {
|
|
606
687
|
const requestId = payload.properties?.id ?? payload.properties?.requestID ?? payload.properties?.requestId;
|
|
607
|
-
|
|
688
|
+
// v2 describes a permission request as an action plus the resources it
|
|
689
|
+
// touches; the v1 single `permission` string is gone.
|
|
690
|
+
const permissionAction = typeof payload.properties?.action === 'string' ? payload.properties.action.trim() : '';
|
|
691
|
+
const permissionResource = Array.isArray(payload.properties?.resources)
|
|
692
|
+
? String(payload.properties.resources[0] ?? '').trim()
|
|
693
|
+
: '';
|
|
694
|
+
const permissionMessage = typeof payload.properties?.message === 'string' ? payload.properties.message.trim() : '';
|
|
695
|
+
const permission = permissionMessage
|
|
696
|
+
|| (permissionAction && permissionResource ? `${permissionAction}: ${permissionResource}` : permissionAction);
|
|
608
697
|
const requestKey = typeof requestId === 'string' ? `${sessionId}:${requestId}` : null;
|
|
609
698
|
if (requestKey && notifiedPermissionRequests.has(requestKey)) {
|
|
610
699
|
return;
|
|
@@ -713,7 +802,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
713
802
|
const sendGoalSettlePush = async ({ sessionId, directory, status, title, body }) => {
|
|
714
803
|
let sessionName = '';
|
|
715
804
|
try {
|
|
716
|
-
const base = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
|
|
805
|
+
const base = buildOpenCodeUrl(`/api/session/${encodeURIComponent(sessionId)}`, '');
|
|
717
806
|
const url = directory ? `${base}?directory=${encodeURIComponent(directory)}` : base;
|
|
718
807
|
const response = await fetch(url, {
|
|
719
808
|
method: 'GET',
|
|
@@ -721,7 +810,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
721
810
|
signal: AbortSignal.timeout(2000),
|
|
722
811
|
});
|
|
723
812
|
if (response.ok) {
|
|
724
|
-
const session = await response.json().catch(() => null);
|
|
813
|
+
const session = unwrapOpenCodeResponse(await response.json().catch(() => null));
|
|
725
814
|
if (typeof session?.title === 'string') sessionName = session.title.trim();
|
|
726
815
|
}
|
|
727
816
|
} catch {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { summarizeText as summarizeSharedText } from '../text/summarization.js';
|
|
2
|
+
import { unwrapOpenCodeResponse } from '../opencode/response-envelope.js';
|
|
2
3
|
|
|
3
4
|
export const createNotificationTemplateRuntime = (deps) => {
|
|
4
5
|
const {
|
|
@@ -136,7 +137,7 @@ export const createNotificationTemplateRuntime = (deps) => {
|
|
|
136
137
|
if (!sessionId) return '';
|
|
137
138
|
|
|
138
139
|
try {
|
|
139
|
-
const url = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}/message`, '');
|
|
140
|
+
const url = buildOpenCodeUrl(`/api/session/${encodeURIComponent(sessionId)}/message`, '');
|
|
140
141
|
const response = await fetch(`${url}?limit=5`, {
|
|
141
142
|
method: 'GET',
|
|
142
143
|
headers: {
|
|
@@ -148,26 +149,23 @@ export const createNotificationTemplateRuntime = (deps) => {
|
|
|
148
149
|
|
|
149
150
|
if (!response.ok) return '';
|
|
150
151
|
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
// v2 pages messages as `{ data, cursor }`, newest first, and a message is
|
|
153
|
+
// a flat record: an assistant one carries `content[]`, not `parts`.
|
|
154
|
+
const page = await response.json().catch(() => null);
|
|
155
|
+
const messages = Array.isArray(page?.data) ? page.data : null;
|
|
156
|
+
if (!messages) return '';
|
|
153
157
|
|
|
154
158
|
let target = null;
|
|
155
159
|
if (messageId) {
|
|
156
|
-
target = messages.find((message) => message?.
|
|
160
|
+
target = messages.find((message) => message?.id === messageId && message?.type === 'assistant');
|
|
157
161
|
}
|
|
158
162
|
if (!target) {
|
|
159
|
-
|
|
160
|
-
const message = messages[i];
|
|
161
|
-
if (message?.info?.role === 'assistant' && message?.info?.finish === 'stop') {
|
|
162
|
-
target = message;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
163
|
+
target = messages.find((message) => message?.type === 'assistant' && message?.finish === 'stop') ?? null;
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
if (!target || !Array.isArray(target.
|
|
166
|
+
if (!target || !Array.isArray(target.content)) return '';
|
|
169
167
|
|
|
170
|
-
return extractTextFromParts(target.
|
|
168
|
+
return extractTextFromParts(target.content, maxLength);
|
|
171
169
|
} catch {
|
|
172
170
|
return '';
|
|
173
171
|
}
|
|
@@ -201,7 +199,7 @@ export const createNotificationTemplateRuntime = (deps) => {
|
|
|
201
199
|
}
|
|
202
200
|
|
|
203
201
|
try {
|
|
204
|
-
const url = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
|
|
202
|
+
const url = buildOpenCodeUrl(`/api/session/${encodeURIComponent(sessionId)}`, '');
|
|
205
203
|
const response = await fetch(url, {
|
|
206
204
|
method: 'GET',
|
|
207
205
|
headers: { Accept: 'application/json' },
|
|
@@ -211,7 +209,7 @@ export const createNotificationTemplateRuntime = (deps) => {
|
|
|
211
209
|
console.warn(`[Notification] fetchSessionInfo: ${response.status} for session ${sessionId}`);
|
|
212
210
|
return null;
|
|
213
211
|
}
|
|
214
|
-
const data = await response.json().catch(() => null);
|
|
212
|
+
const data = unwrapOpenCodeResponse(await response.json().catch(() => null));
|
|
215
213
|
if (data && typeof data === 'object') {
|
|
216
214
|
sessionInfoCache.set(sessionId, { data, at: Date.now() });
|
|
217
215
|
return data;
|