@aiworker/web 1.22.0 → 1.22.2
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/README.md +4 -4
- package/bin/cli.js +7 -4
- package/bin/cli.test.js +165 -73
- package/bin/lib/cli-api-target.js +2 -2
- package/bin/lib/cli-args.js +119 -119
- package/bin/lib/cli-lifecycle.js +9 -9
- package/bin/lib/cli-network.js +3 -3
- package/bin/lib/cli-paths.js +3 -3
- package/bin/lib/cli-ports.js +2 -2
- package/bin/lib/cli-process.js +4 -4
- package/bin/lib/cli-startup.js +64 -15
- package/bin/lib/cli-tunnel-profiles.js +1 -1
- package/bin/lib/cli-tunnel-utils.js +2 -2
- package/bin/lib/commands-connect-url.js +19 -19
- package/bin/lib/commands-lifecycle.js +27 -27
- package/bin/lib/commands-logs.js +5 -5
- package/bin/lib/commands-models.js +1 -1
- package/bin/lib/commands-projects.js +1 -1
- package/bin/lib/commands-schedule.js +1 -1
- package/bin/lib/commands-serve.js +29 -29
- package/bin/lib/commands-session.js +1 -1
- package/bin/lib/commands-startup.js +45 -10
- package/bin/lib/commands-status.js +1 -1
- package/bin/lib/commands-tunnel.js +40 -40
- package/bin/lib/commands-update.js +1 -1
- package/bin/lib/commands-update.test.js +6 -6
- package/dist/assets/{CodeMirrorCommentWidgets-B3u7UIcE.js → CodeMirrorCommentWidgets-CSICpWQD.js} +1 -1
- package/dist/assets/{DiffView-DluiRSla.js → DiffView-hDBKesA_.js} +3 -3
- package/dist/assets/DirtyBranchSwitchDialog-C22HdWj4.js +1 -0
- package/dist/assets/FilesView-CdWzeOp9.js +17 -0
- package/dist/assets/GitView-VQQkYuUw.js +6 -0
- package/dist/assets/{JsonTreeView-B0BdZEHG.js → JsonTreeView-6lrhwD3q.js} +1 -1
- package/dist/assets/LinearIssuesView-Ba6Q9569.js +1 -0
- package/dist/assets/{MarkdownImageGallery-ClOvuZxC.js → MarkdownImageGallery-Czv_mhvS.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-BrMcswiy.js +12 -0
- package/dist/assets/{OnboardingScreen-D2DG7K6b.js → OnboardingScreen-ChxQoAkx.js} +1 -1
- package/dist/assets/{PatchDiff-DvfqDql7.js → PatchDiff-BzcZPlOq.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B7m3f0d7.js → PierreDiffViewer-BchBtZlp.js} +2 -2
- package/dist/assets/PlanView-DyDt_nZ_.js +5 -0
- package/dist/assets/SettingsView-BKf5xBsP.js +28 -0
- package/dist/assets/{SettingsWindow-i45U1Cy1.js → SettingsWindow-DDQYaKWQ.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BTwyh5OF.js → ToolOutputDialog-iYF8Y2bz.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-CdjbOVMM.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-DD8lDVej.js → VirtualizedFileDiff-fFFm2QgH.js} +1 -1
- package/dist/assets/{WalkthroughView-egQgxel3.js → WalkthroughView-DOeCsMju.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-BMIRgMHv.js → computeVirtualFileMetrics-CzgLum_K.js} +2 -2
- package/dist/assets/{contextPanelEmbeddedChat-C3fjDbdg.js → contextPanelEmbeddedChat-C0ZLAepL.js} +1 -1
- package/dist/assets/{de-C1P6X5Rs.js → de-B5JaA3SA.js} +6 -5
- package/dist/assets/{es-CDgaF1_t.js → es-EPIH88ii.js} +6 -5
- package/dist/assets/{fr-Bgxqvvz_.js → fr-CAMfxUdZ.js} +6 -5
- package/dist/assets/{index-CODwDsU_.js → index-Bl3LSbjn.js} +1 -1
- package/dist/assets/index-DF5kMP-i.js +39 -0
- package/dist/assets/index-Dl3xbAB_.css +1 -0
- package/dist/assets/{isDiffPlainText-BqayB8d3.js → isDiffPlainText-Dx-dB_8l.js} +1 -1
- package/dist/assets/{isFilePlainText-QfoiKJNY.js → isFilePlainText-CWFPwmnU.js} +1 -1
- package/dist/assets/{ja-BDRrEcNP.js → ja-CifOE1VN.js} +7 -6
- package/dist/assets/{ko-Ba8sQV79.js → ko-BBDyAyYQ.js} +7 -6
- package/dist/assets/{main-C5DVOxc6.js → main-DnBAoktx.js} +2 -2
- package/dist/assets/main-MhSaOZoB.js +930 -0
- package/dist/assets/{markdownCore-CZwzz5gw.js → markdownCore-BrBwOOMn.js} +2 -2
- package/dist/assets/{miniChat-DUJ4irZc.js → miniChat-BKyvLseN.js} +2 -2
- package/dist/assets/{mobile-CcaxB0n4.js → mobile-DKjeFgMN.js} +2 -2
- package/dist/assets/{patchFileDiff-yNfWXN4E.js → patchFileDiff-o8ms1me8.js} +1 -1
- package/dist/assets/pl-DgEHYfFM.js +16 -0
- package/dist/assets/{pt-BR-DIs6ElwV.js → pt-BR-DuWHojUw.js} +6 -5
- package/dist/assets/{renderElectronMiniChatApp-BcKLHXKe.js → renderElectronMiniChatApp-CDgBwwCS.js} +2 -2
- package/dist/assets/renderMobileApp-DJIKIK1r.js +25 -0
- package/dist/assets/runtimeEndpointReset-CYJ9O_xX.js +17 -0
- package/dist/assets/{scheduledTasksApi-DLW0mkQK.js → scheduledTasksApi-D8yamh1b.js} +1 -1
- package/dist/assets/{shikiHighlight-DYOWuY65.js → shikiHighlight-TEQCmzW8.js} +1 -1
- package/dist/assets/tr-D5m2yIWL.js +7 -0
- package/dist/assets/{uk-ZrCNjM7Y.js → uk-D_q60oog.js} +6 -5
- package/dist/assets/{useAppFontEffects-CjrntdL0.js → useAppFontEffects-D7sNpuL2.js} +161 -190
- package/dist/assets/useInlineCommentController-Brz_cLcQ.js +2 -0
- package/dist/assets/{useRootScrollLock-BHYPkrLv.js → useRootScrollLock-lXEnWlaU.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DFZik9R2.js → vendor-codemirror-language-data-Dp3KMRQG.js} +2 -2
- package/dist/assets/vendor-zod-CK21ihK-.js +39 -0
- package/dist/assets/{web-components-Bhg83tjf.js → web-components-_mNEMjFY.js} +1 -1
- package/dist/assets/{zh-CN-iv_AV4EC.js → zh-CN-D8QvsVeg.js} +6 -5
- package/dist/assets/{zh-TW-CzEUk38j.js → zh-TW-B9t7rQQO.js} +6 -5
- package/dist/index.html +22 -22
- package/dist/mini-chat.html +7 -7
- package/dist/mobile.html +5 -5
- package/package.json +3 -3
- package/server/index.js +118 -85
- package/server/lib/agent-memory/actions.js +2 -2
- package/server/lib/agent-memory/feature-flag.js +1 -1
- package/server/lib/agent-memory/feature-flag.test.js +8 -8
- package/server/lib/agent-memory/routes.js +2 -2
- package/server/lib/agent-tool/runtime.js +37 -54
- package/server/lib/agent-tool/runtime.test.js +59 -59
- package/server/lib/browser-control/broker.js +3 -3
- package/server/lib/browser-control/broker.test.js +1 -1
- package/server/lib/changelog/update-notes.js +82 -0
- package/server/lib/changelog/update-notes.test.js +59 -0
- package/server/lib/client-auth/remote-clients.test.js +5 -5
- package/server/lib/context-obligatory/runtime.js +7 -7
- package/server/lib/context-obligatory/runtime.test.js +5 -5
- package/server/lib/dev-servers/parse.js +2 -2
- package/server/lib/dev-servers/parse.test.js +2 -2
- package/server/lib/dev-servers/routes.js +1 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
- package/server/lib/dev-tunnel/client.js +1 -1
- package/server/lib/dev-tunnel/runtime.js +5 -5
- package/server/lib/dev-tunnel/tunnel.test.js +21 -1
- package/server/lib/dictation/local/model-catalog.js +1 -1
- package/server/lib/dictation/local/worker-process.js +2 -2
- package/server/lib/event-stream/directory-ws-bridge.js +1 -1
- package/server/lib/event-stream/global-ws-bridge.js +1 -1
- package/server/lib/event-stream/protocol.test.js +4 -4
- package/server/lib/event-stream/runtime.test.js +6 -6
- package/server/lib/fs/DOCUMENTATION.md +2 -0
- package/server/lib/fs/routes.js +37 -26
- package/server/lib/fs/routes.test.js +98 -21
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/identity-storage.js +1 -1
- package/server/lib/git/issue-2746-longpaths.test.js +4 -4
- package/server/lib/git/routes.js +17 -1
- package/server/lib/git/service.js +116 -26
- package/server/lib/git/service.test.js +174 -3
- package/server/lib/github/auth.js +8 -8
- package/server/lib/github/pr-status.js +1 -1
- package/server/lib/github/routes.js +2 -2
- package/server/lib/inherited-env.js +1 -1
- package/server/lib/inherited-env.test.js +2 -2
- package/server/lib/linear/auth.js +8 -8
- package/server/lib/linear/auth.test.js +24 -24
- package/server/lib/linear/issues.test.js +6 -6
- package/server/lib/linear/mapping.test.js +4 -4
- package/server/lib/linear/oauth.js +2 -2
- package/server/lib/linear/oauth.test.js +14 -14
- package/server/lib/linear/routes.js +5 -5
- package/server/lib/linear/routes.test.js +16 -16
- package/server/lib/linear/status-runtime.test.js +9 -9
- package/server/lib/linear/status.js +1 -1
- package/server/lib/linear/status.test.js +15 -15
- package/server/lib/linear/teams.test.js +4 -4
- package/server/lib/magic-prompts/routes.js +2 -2
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
- package/server/lib/mcp-reconnect/runtime.js +122 -0
- package/server/lib/mcp-reconnect/runtime.test.js +140 -0
- package/server/lib/message-queue/DOCUMENTATION.md +158 -0
- package/server/lib/message-queue/runtime.js +870 -0
- package/server/lib/message-queue/runtime.test.js +482 -0
- package/server/lib/notifications/apns-runtime.js +17 -17
- package/server/lib/notifications/apns-runtime.test.js +11 -11
- package/server/lib/notifications/emitter-runtime.js +1 -1
- package/server/lib/notifications/emitter-runtime.test.js +1 -1
- package/server/lib/notifications/push-runtime.js +7 -7
- package/server/lib/notifications/routes.js +1 -1
- package/server/lib/notifications/runtime.js +1 -1
- package/server/lib/openchamber-control/action-resolution.test.js +10 -10
- package/server/lib/openchamber-control/actions.js +24 -24
- package/server/lib/openchamber-control/error.js +4 -4
- package/server/lib/openchamber-control/routes.js +2 -2
- package/server/lib/openchamber-control/routes.test.js +5 -5
- package/server/lib/openchamber-control/screenshots.js +1 -1
- package/server/lib/openchamber-control/screenshots.test.js +1 -1
- package/server/lib/openchamber-control/service.js +50 -50
- package/server/lib/openchamber-control/service.test.js +5 -5
- package/server/lib/openchamber-sessions/routes.js +124 -22
- package/server/lib/openchamber-sessions/routes.test.js +99 -11
- package/server/lib/opencode/DOCUMENTATION.md +13 -5
- package/server/lib/opencode/auth.js +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +6 -6
- package/server/lib/opencode/cli-options.js +8 -8
- package/server/lib/opencode/config-paths.test.js +116 -0
- package/server/lib/opencode/core-routes.js +8 -7
- package/server/lib/opencode/core-routes.test.js +11 -11
- package/server/lib/opencode/env-config.js +5 -5
- package/server/lib/opencode/env-config.test.js +7 -7
- package/server/lib/opencode/env-runtime.js +10 -10
- package/server/lib/opencode/env-runtime.test.js +18 -18
- package/server/lib/opencode/feature-routes-runtime.js +17 -12
- package/server/lib/opencode/hmr-state-runtime.js +2 -2
- package/server/lib/opencode/hmr-state-runtime.test.js +1 -1
- package/server/lib/opencode/input-history-scope.js +14 -0
- package/server/lib/opencode/lifecycle.js +8 -8
- package/server/lib/opencode/lifecycle.test.js +4 -4
- package/server/lib/opencode/managed-plugin-config.js +35 -0
- package/server/lib/opencode/managed-process-registry.js +3 -3
- package/server/lib/opencode/mcp-oauth-callback.test.js +2 -2
- package/server/lib/opencode/openchamber-routes.js +15 -15
- package/server/lib/opencode/openchamber-routes.test.js +11 -11
- package/server/lib/opencode/plugins.js +2 -2
- package/server/lib/opencode/plugins.test.js +1 -1
- package/server/lib/opencode/project-icon-routes.js +2 -2
- package/server/lib/opencode/project-icon-routes.test.js +1 -1
- package/server/lib/opencode/providers.js +44 -2
- package/server/lib/opencode/providers.test.js +131 -4
- package/server/lib/opencode/proxy.js +2 -2
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/restart-session-recovery.test.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +4 -4
- package/server/lib/opencode/routes.js +14 -14
- package/server/lib/opencode/server-startup-runtime.js +6 -6
- package/server/lib/opencode/session-runtime.js +3 -3
- package/server/lib/opencode/session-runtime.test.js +6 -6
- package/server/lib/opencode/settings-helpers.js +31 -3
- package/server/lib/opencode/settings-helpers.test.js +189 -12
- package/server/lib/opencode/settings-runtime.js +2 -2
- package/server/lib/opencode/settings-runtime.test.js +29 -0
- package/server/lib/opencode/shared.js +5 -2
- package/server/lib/opencode/shared.test.js +7 -7
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/skill-routes.js +2 -1
- package/server/lib/opencode/snippets.js +1 -2
- package/server/lib/opencode/startup-performance.js +1 -1
- package/server/lib/opencode/startup-performance.test.js +6 -6
- package/server/lib/opencode/static-routes-runtime.js +8 -8
- package/server/lib/opencode/static-routes-runtime.test.js +7 -7
- package/server/lib/opencode/upgrade-capability.js +2 -2
- package/server/lib/opencode/upgrade-capability.test.js +3 -3
- package/server/lib/package-manager.js +17 -42
- package/server/lib/package-manager.test.js +19 -19
- package/server/lib/permission-auto-accept/runtime.js +1 -1
- package/server/lib/project-context/routes.js +1 -1
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/quota/DOCUMENTATION.md +9 -1
- package/server/lib/quota/credentials/providers.js +4 -0
- package/server/lib/quota/credentials/store.js +4 -4
- package/server/lib/quota/credentials/store.test.js +8 -8
- package/server/lib/quota/index.js +1 -0
- package/server/lib/quota/providers/exe-dev.js +75 -0
- package/server/lib/quota/providers/exe-dev.test.js +47 -0
- package/server/lib/quota/providers/hyper.js +118 -0
- package/server/lib/quota/providers/hyper.test.js +126 -0
- package/server/lib/quota/providers/index.js +15 -0
- package/server/lib/quota/providers/ollama-cloud.js +1 -1
- package/server/lib/quota/providers/opencode-go.js +2 -1
- package/server/lib/quota/providers/opencode-go.test.js +9 -5
- package/server/lib/quota/providers/xai.js +1 -1
- package/server/lib/quota/routes.js +2 -0
- package/server/lib/quota/utils/auth.js +1 -1
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/host-client.js +1 -1
- package/server/lib/relay/host-client.test.js +9 -1
- package/server/lib/relay/host-lock.js +1 -1
- package/server/lib/relay/service.js +5 -5
- package/server/lib/relay/tunnel-host.js +3 -1
- package/server/lib/relay/tunnel-host.test.js +9 -1
- package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +2 -2
- package/server/lib/scheduled-tasks/routes.js +5 -5
- package/server/lib/scheduled-tasks/service.js +25 -25
- package/server/lib/scheduled-tasks/service.test.js +1 -1
- package/server/lib/security/bind-host.js +4 -4
- package/server/lib/security/bind-host.test.js +1 -1
- package/server/lib/security/request-security.js +11 -5
- package/server/lib/security/request-security.test.js +14 -14
- package/server/lib/session-assist/runtime.js +10 -9
- package/server/lib/session-folders/routes.js +2 -2
- package/server/lib/session-folders/routes.test.js +8 -8
- package/server/lib/session-goal/DOCUMENTATION.md +20 -7
- package/server/lib/session-goal/create.js +4 -2
- package/server/lib/session-goal/create.test.js +1 -1
- package/server/lib/session-goal/objectives.js +4 -4
- package/server/lib/session-goal/routes.js +1 -1
- package/server/lib/session-goal/runtime.js +88 -22
- package/server/lib/session-goal/runtime.test.js +428 -2
- package/server/lib/session-knowledge/runtime.js +11 -11
- package/server/lib/session-knowledge/runtime.test.js +5 -5
- package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
- package/server/lib/skills-catalog/cache.test.js +2 -2
- package/server/lib/skills-catalog/disk-cache.js +5 -5
- package/server/lib/skills-catalog/github-meta.test.js +2 -2
- package/server/lib/skills-catalog/install.js +3 -2
- package/server/lib/small-model/DOCUMENTATION.md +4 -0
- package/server/lib/small-model/call.js +9 -3
- package/server/lib/small-model/call.test.js +29 -6
- package/server/lib/small-model/index.js +8 -7
- package/server/lib/small-model/index.test.js +1 -1
- package/server/lib/small-model/resolve.js +1 -1
- package/server/lib/small-model/resolve.test.js +1 -1
- package/server/lib/small-model/routes.js +2 -1
- package/server/lib/system-prompt/runtime.js +3 -22
- package/server/lib/system-prompt/runtime.test.js +3 -3
- package/server/lib/terminal/DOCUMENTATION.md +11 -7
- package/server/lib/terminal/runtime.js +180 -26
- package/server/lib/terminal/runtime.test.js +554 -27
- package/server/lib/terminal/shells.js +20 -3
- package/server/lib/terminal/shells.test.js +33 -2
- package/server/lib/tts/base-url.js +3 -3
- package/server/lib/tts/routes.test.js +20 -20
- package/server/lib/ui-auth/ui-auth.js +12 -9
- package/server/lib/ui-auth/ui-auth.test.js +19 -3
- package/server/lib/ui-auth/ui-passkeys.js +7 -7
- package/server/lib/walkthrough/index.js +1 -0
- package/server/lib/walkthrough/jobs.test.js +1 -1
- package/server/lib/walkthrough/language.test.js +1 -1
- package/server/lib/walkthrough/model-settings.js +3 -3
- package/server/lib/walkthrough/model-settings.test.js +1 -1
- package/server/lib/walkthrough/pull-request.test.js +5 -5
- package/server/lib/walkthrough/reproduce-2607.test.js +2 -2
- package/server/lib/walkthrough/routes.test.js +26 -5
- package/server/lib/walkthrough/store.js +3 -3
- package/server/lib/walkthrough/store.test.js +1 -1
- package/server/opencode-proxy.test.js +2 -2
- package/server/proxy-headers.js +1 -1
- package/server/sse-routes.test.js +4 -4
- package/README.md.bak +0 -250
- package/bin/lib/DOCUMENTATION.md.bak +0 -163
- package/dist/assets/CommitSection-SGBCAW0w.js +0 -1
- package/dist/assets/FilesView-Bdq8ppva.js +0 -17
- package/dist/assets/GitView-Znn7VJcP.js +0 -6
- package/dist/assets/LinearIssuesView-jP-hXyac.js +0 -1
- package/dist/assets/MarkdownRendererImpl-Dt9mjTRN.js +0 -12
- package/dist/assets/PlanView-B0F3BtPZ.js +0 -5
- package/dist/assets/SettingsView-BBW-S-gh.js +0 -28
- package/dist/assets/ToolPartDiffPreview-CUNe28U1.js +0 -8
- package/dist/assets/index-C57jT0Sa.css +0 -1
- package/dist/assets/index-DW_E3rnL.js +0 -7
- package/dist/assets/main-Bv5Pkngh.js +0 -928
- package/dist/assets/pl-Dioz29BI.js +0 -15
- package/dist/assets/renderMobileApp-D9yQJy0L.js +0 -25
- package/dist/assets/runtimeEndpointReset-CjhvxLH0.js +0 -16
- package/dist/assets/tr-DFnMlPxY.js +0 -6
- package/dist/assets/useInlineCommentController-CDEuSlPH.js +0 -2
- package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
- package/server/index.d.ts.bak +0 -39
- package/server/lib/agent-tool/DOCUMENTATION.md.bak +0 -119
- package/server/lib/browser-control/DOCUMENTATION.md.bak +0 -50
- package/server/lib/context-obligatory/DOCUMENTATION.md.bak +0 -19
- package/server/lib/dev-tunnel/DOCUMENTATION.md.bak +0 -57
- package/server/lib/dictation/DOCUMENTATION.md.bak +0 -100
- package/server/lib/event-stream/DOCUMENTATION.md.bak +0 -62
- package/server/lib/fs/DOCUMENTATION.md.bak +0 -47
- package/server/lib/git/DOCUMENTATION.md.bak +0 -193
- package/server/lib/github/DOCUMENTATION.md.bak +0 -183
- package/server/lib/linear/DOCUMENTATION.md.bak +0 -97
- package/server/lib/linear/OAUTH-BROKER-HANDOFF.md.bak +0 -91
- package/server/lib/markdown-image-grants/DOCUMENTATION.md.bak +0 -40
- package/server/lib/notifications/APNS.md.bak +0 -135
- package/server/lib/notifications/DOCUMENTATION.md.bak +0 -138
- package/server/lib/openchamber-control/DOCUMENTATION.md.bak +0 -64
- package/server/lib/opencode/DOCUMENTATION.md.bak +0 -431
- package/server/lib/opencode/managed-process-registry.d.ts.bak +0 -13
- package/server/lib/opencode/provider-env-aliases.d.ts.bak +0 -3
- package/server/lib/permission-auto-accept/DOCUMENTATION.md.bak +0 -34
- package/server/lib/project-context/DOCUMENTATION.md.bak +0 -160
- package/server/lib/quota/DOCUMENTATION.md.bak +0 -123
- package/server/lib/relay/DOCUMENTATION.md.bak +0 -100
- package/server/lib/scheduled-tasks/DOCUMENTATION.md.bak +0 -182
- package/server/lib/session-assist/DOCUMENTATION.md.bak +0 -66
- package/server/lib/session-goal/DOCUMENTATION.md.bak +0 -213
- package/server/lib/session-knowledge/DOCUMENTATION.md.bak +0 -89
- package/server/lib/skills-catalog/DOCUMENTATION.md.bak +0 -151
- package/server/lib/small-model/DOCUMENTATION.md.bak +0 -212
- package/server/lib/system-prompt/DOCUMENTATION.md.bak +0 -36
- package/server/lib/terminal/DOCUMENTATION.md.bak +0 -50
- package/server/lib/text/DOCUMENTATION.md.bak +0 -35
- package/server/lib/tts/DOCUMENTATION.md.bak +0 -147
- package/server/lib/tunnels/DOCUMENTATION.md.bak +0 -21
- package/server/lib/ui-auth/DOCUMENTATION.md.bak +0 -44
- package/server/lib/walkthrough/DOCUMENTATION.md.bak +0 -411
package/server/index.js
CHANGED
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
registerCommonRequestMiddleware,
|
|
65
65
|
registerServerStatusRoutes,
|
|
66
66
|
} from './lib/opencode/core-routes.js';
|
|
67
|
-
import {
|
|
67
|
+
import { registerAiWorkerRoutes } from './lib/opencode/openchamber-routes.js';
|
|
68
68
|
import { createServerUtilsRuntime } from './lib/opencode/server-utils-runtime.js';
|
|
69
69
|
import { createStaticRoutesRuntime } from './lib/opencode/static-routes-runtime.js';
|
|
70
70
|
import { createSettingsRuntime } from './lib/opencode/settings-runtime.js';
|
|
@@ -91,6 +91,7 @@ import { createPushRuntime } from './lib/notifications/push-runtime.js';
|
|
|
91
91
|
import { createApnsRuntime } from './lib/notifications/apns-runtime.js';
|
|
92
92
|
import { createNotificationTemplateRuntime } from './lib/notifications/template-runtime.js';
|
|
93
93
|
import { createPermissionAutoAcceptRuntime } from './lib/permission-auto-accept/runtime.js';
|
|
94
|
+
import { createMessageQueueRuntime } from './lib/message-queue/runtime.js';
|
|
94
95
|
import { createGracefulShutdownRuntime } from './lib/opencode/shutdown-runtime.js';
|
|
95
96
|
import { createProjectConfigRuntime } from './lib/projects/project-config.js';
|
|
96
97
|
import { createProjectContextRuntime } from './lib/project-context/runtime.js';
|
|
@@ -110,20 +111,21 @@ import { createDevServerScanner } from './lib/dev-servers/routes.js';
|
|
|
110
111
|
import { createDevTunnelRuntime } from './lib/dev-tunnel/runtime.js';
|
|
111
112
|
import { registerBrowserControlRoutes } from './lib/browser-control/routes.js';
|
|
112
113
|
import { createSystemPromptRuntime } from './lib/system-prompt/runtime.js';
|
|
113
|
-
import {
|
|
114
|
+
import { createMcpReconnectRuntime } from './lib/mcp-reconnect/runtime.js';
|
|
115
|
+
import { createAiWorkerSessionService } from './lib/openchamber-sessions/routes.js';
|
|
114
116
|
import { createScheduledTaskService } from './lib/scheduled-tasks/service.js';
|
|
115
|
-
import {
|
|
116
|
-
import {
|
|
117
|
+
import { createAiWorkerControlService } from './lib/openchamber-control/service.js';
|
|
118
|
+
import { AiWorkerControlError } from './lib/openchamber-control/error.js';
|
|
117
119
|
import webPush from 'web-push';
|
|
118
120
|
|
|
119
121
|
const __filename = fileURLToPath(import.meta.url);
|
|
120
122
|
const __dirname = path.dirname(__filename);
|
|
121
123
|
|
|
122
124
|
const DEFAULT_PORT = 3000;
|
|
123
|
-
const DESKTOP_NOTIFY_PREFIX = '[
|
|
125
|
+
const DESKTOP_NOTIFY_PREFIX = '[AiWorkerDesktopNotify] ';
|
|
124
126
|
const uiNotificationClients = new Set();
|
|
125
127
|
const uiNotificationWsClients = new Set();
|
|
126
|
-
const
|
|
128
|
+
const uiAiWorkerEventClients = new Set();
|
|
127
129
|
const HEALTH_CHECK_INTERVAL = 15000;
|
|
128
130
|
const SHUTDOWN_TIMEOUT = 10000;
|
|
129
131
|
const MODELS_DEV_API_URL = 'https://models.dev/api.json';
|
|
@@ -168,7 +170,7 @@ const SSE_PATH_PREFIXES = [
|
|
|
168
170
|
];
|
|
169
171
|
|
|
170
172
|
function shouldSkipCompression(req, res) {
|
|
171
|
-
if (process.env.
|
|
173
|
+
if (process.env.AIWORKER_RUNTIME === 'desktop') {
|
|
172
174
|
return true;
|
|
173
175
|
}
|
|
174
176
|
|
|
@@ -190,7 +192,7 @@ function shouldSkipCompression(req, res) {
|
|
|
190
192
|
return headerIncludesEventStream(res.getHeader('Content-Type'));
|
|
191
193
|
}
|
|
192
194
|
|
|
193
|
-
const
|
|
195
|
+
const AIWORKER_VERSION = (() => {
|
|
194
196
|
try {
|
|
195
197
|
const packagePath = path.resolve(__dirname, '..', 'package.json');
|
|
196
198
|
const raw = fs.readFileSync(packagePath, 'utf8');
|
|
@@ -218,13 +220,13 @@ const isEnvFlagDisabled = (value) => {
|
|
|
218
220
|
};
|
|
219
221
|
|
|
220
222
|
const shouldSkipApiCompression = () => {
|
|
221
|
-
if (isEnvFlagEnabled(process.env.
|
|
222
|
-
if (isEnvFlagEnabled(process.env.
|
|
223
|
-
if (isEnvFlagDisabled(process.env.
|
|
224
|
-
return process.env.
|
|
223
|
+
if (isEnvFlagEnabled(process.env.AIWORKER_SKIP_API_COMPRESSION)) return true;
|
|
224
|
+
if (isEnvFlagEnabled(process.env.AIWORKER_COMPRESS_API)) return false;
|
|
225
|
+
if (isEnvFlagDisabled(process.env.AIWORKER_COMPRESS_API)) return true;
|
|
226
|
+
return process.env.AIWORKER_RUNTIME === 'desktop';
|
|
225
227
|
};
|
|
226
228
|
|
|
227
|
-
const
|
|
229
|
+
const AIWORKER_VERBOSE_REQUEST_LOGS = isEnvFlagEnabled(process.env.AIWORKER_VERBOSE_REQUEST_LOGS);
|
|
228
230
|
|
|
229
231
|
const PLAN_MODE_EXPERIMENT_ENABLED =
|
|
230
232
|
isEnvFlagEnabled(process.env.OPENCODE_EXPERIMENTAL_PLAN_MODE)
|
|
@@ -264,9 +266,14 @@ const sanitizeModelRefs = (...args) => settingsNormalizationRuntime.sanitizeMode
|
|
|
264
266
|
const sanitizeSkillCatalogs = (...args) => settingsNormalizationRuntime.sanitizeSkillCatalogs(...args);
|
|
265
267
|
const sanitizeProjects = (...args) => settingsNormalizationRuntime.sanitizeProjects(...args);
|
|
266
268
|
|
|
267
|
-
const
|
|
268
|
-
const
|
|
269
|
-
const
|
|
269
|
+
const AIWORKER_USER_CONFIG_ROOT = path.join(os.homedir(), '.config', 'aiworker');
|
|
270
|
+
const AIWORKER_USER_THEMES_DIR = path.join(AIWORKER_USER_CONFIG_ROOT, 'themes');
|
|
271
|
+
const AIWORKER_PROJECTS_CONFIG_DIR = path.join(AIWORKER_USER_CONFIG_ROOT, 'projects');
|
|
272
|
+
// AIWORKER_CHATS_DIR relocates managed chat worktrees — needed when the
|
|
273
|
+
// OpenCode server runs as a separate user that cannot traverse $HOME.
|
|
274
|
+
const AIWORKER_CHATS_DIR = process.env.AIWORKER_CHATS_DIR && process.env.AIWORKER_CHATS_DIR.trim()
|
|
275
|
+
? path.resolve(process.env.AIWORKER_CHATS_DIR.trim())
|
|
276
|
+
: path.join(AIWORKER_USER_CONFIG_ROOT, 'chats');
|
|
270
277
|
|
|
271
278
|
const MAX_THEME_JSON_BYTES = 512 * 1024;
|
|
272
279
|
|
|
@@ -274,7 +281,7 @@ const MAX_THEME_JSON_BYTES = 512 * 1024;
|
|
|
274
281
|
const themeRuntime = createThemeRuntime({
|
|
275
282
|
fsPromises,
|
|
276
283
|
path,
|
|
277
|
-
themesDir:
|
|
284
|
+
themesDir: AIWORKER_USER_THEMES_DIR,
|
|
278
285
|
maxThemeJsonBytes: MAX_THEME_JSON_BYTES,
|
|
279
286
|
logger: console,
|
|
280
287
|
});
|
|
@@ -284,6 +291,7 @@ const readCustomThemesFromDisk = (...args) => themeRuntime.readCustomThemesFromD
|
|
|
284
291
|
let notificationTemplateRuntime = null;
|
|
285
292
|
let agentToolRuntime = null;
|
|
286
293
|
let systemPromptRuntime = null;
|
|
294
|
+
let mcpReconnectRuntime = null;
|
|
287
295
|
|
|
288
296
|
const createTimeoutSignal = (...args) => notificationTemplateRuntime.createTimeoutSignal(...args);
|
|
289
297
|
const formatProjectLabel = (...args) => notificationTemplateRuntime.formatProjectLabel(...args);
|
|
@@ -297,16 +305,16 @@ const maybeCacheSessionInfoFromEvent = (...args) => notificationTemplateRuntime.
|
|
|
297
305
|
const buildTemplateVariables = (...args) => notificationTemplateRuntime.buildTemplateVariables(...args);
|
|
298
306
|
const getCachedZenModels = (...args) => notificationTemplateRuntime.getCachedZenModels(...args);
|
|
299
307
|
|
|
300
|
-
const
|
|
301
|
-
? path.resolve(process.env.
|
|
302
|
-
: path.join(os.homedir(), '.config', '
|
|
303
|
-
const SETTINGS_FILE_PATH = path.join(
|
|
304
|
-
const PUSH_SUBSCRIPTIONS_FILE_PATH = path.join(
|
|
305
|
-
const APNS_TOKENS_FILE_PATH = path.join(
|
|
306
|
-
const REMOTE_CLIENTS_FILE_PATH = path.join(
|
|
307
|
-
const CLIENT_PAIRING_SESSIONS_FILE_PATH = path.join(
|
|
308
|
-
const CLOUDFLARE_MANAGED_REMOTE_TUNNELS_FILE_PATH = path.join(
|
|
309
|
-
const CLOUDFLARE_LEGACY_NAMED_TUNNELS_FILE_PATH = path.join(
|
|
308
|
+
const AIWORKER_DATA_DIR = process.env.AIWORKER_DATA_DIR
|
|
309
|
+
? path.resolve(process.env.AIWORKER_DATA_DIR)
|
|
310
|
+
: path.join(os.homedir(), '.config', 'aiworker');
|
|
311
|
+
const SETTINGS_FILE_PATH = path.join(AIWORKER_DATA_DIR, 'settings.json');
|
|
312
|
+
const PUSH_SUBSCRIPTIONS_FILE_PATH = path.join(AIWORKER_DATA_DIR, 'push-subscriptions.json');
|
|
313
|
+
const APNS_TOKENS_FILE_PATH = path.join(AIWORKER_DATA_DIR, 'apns-tokens.json');
|
|
314
|
+
const REMOTE_CLIENTS_FILE_PATH = path.join(AIWORKER_DATA_DIR, 'remote-clients.json');
|
|
315
|
+
const CLIENT_PAIRING_SESSIONS_FILE_PATH = path.join(AIWORKER_DATA_DIR, 'client-pairing-sessions.json');
|
|
316
|
+
const CLOUDFLARE_MANAGED_REMOTE_TUNNELS_FILE_PATH = path.join(AIWORKER_DATA_DIR, 'cloudflare-managed-remote-tunnels.json');
|
|
317
|
+
const CLOUDFLARE_LEGACY_NAMED_TUNNELS_FILE_PATH = path.join(AIWORKER_DATA_DIR, 'cloudflare-named-tunnels.json');
|
|
310
318
|
const CLOUDFLARE_MANAGED_REMOTE_TUNNELS_VERSION = 1;
|
|
311
319
|
|
|
312
320
|
const managedTunnelConfigRuntime = createManagedTunnelConfigRuntime({
|
|
@@ -479,20 +487,20 @@ const getUpstreamStallTimeoutMs = () => (
|
|
|
479
487
|
const projectConfigRuntime = createProjectConfigRuntime({
|
|
480
488
|
fsPromises,
|
|
481
489
|
path,
|
|
482
|
-
projectsDirPath:
|
|
490
|
+
projectsDirPath: AIWORKER_PROJECTS_CONFIG_DIR,
|
|
483
491
|
});
|
|
484
492
|
|
|
485
493
|
const projectContextRuntime = createProjectContextRuntime({
|
|
486
494
|
fsPromises,
|
|
487
495
|
path,
|
|
488
|
-
projectsDirPath:
|
|
496
|
+
projectsDirPath: AIWORKER_PROJECTS_CONFIG_DIR,
|
|
489
497
|
});
|
|
490
498
|
|
|
491
499
|
const agentMemoryRuntime = createAgentMemoryRuntime({
|
|
492
500
|
fsPromises,
|
|
493
501
|
path,
|
|
494
|
-
projectsDirPath:
|
|
495
|
-
userConfigRoot:
|
|
502
|
+
projectsDirPath: AIWORKER_PROJECTS_CONFIG_DIR,
|
|
503
|
+
userConfigRoot: AIWORKER_USER_CONFIG_ROOT,
|
|
496
504
|
});
|
|
497
505
|
|
|
498
506
|
/**
|
|
@@ -516,7 +524,7 @@ const hmrStateRuntime = createHmrStateRuntime({
|
|
|
516
524
|
globalThisLike: globalThis,
|
|
517
525
|
os,
|
|
518
526
|
processLike: process,
|
|
519
|
-
stateKey: '
|
|
527
|
+
stateKey: '__aiworkerHmrState',
|
|
520
528
|
});
|
|
521
529
|
const hmrState = hmrStateRuntime.getOrCreateHmrState();
|
|
522
530
|
hmrStateRuntime.ensureUserProvidedOpenCodePassword(hmrState);
|
|
@@ -611,13 +619,13 @@ const {
|
|
|
611
619
|
});
|
|
612
620
|
|
|
613
621
|
const ENV_SKIP_OPENCODE_START = process.env.OPENCODE_SKIP_START === 'true' ||
|
|
614
|
-
process.env.
|
|
622
|
+
process.env.AIWORKER_SKIP_OPENCODE_START === 'true';
|
|
615
623
|
const ENV_DESKTOP_NOTIFY = (() => {
|
|
616
|
-
if (process.env.
|
|
624
|
+
if (process.env.AIWORKER_DESKTOP_NOTIFY === 'true') {
|
|
617
625
|
return true;
|
|
618
626
|
}
|
|
619
627
|
|
|
620
|
-
if (process.env.
|
|
628
|
+
if (process.env.AIWORKER_RUNTIME === 'desktop') {
|
|
621
629
|
return true;
|
|
622
630
|
}
|
|
623
631
|
|
|
@@ -672,7 +680,7 @@ const scheduleOpenCodeApiDetection = (...args) => openCodeNetworkRuntime.schedul
|
|
|
672
680
|
configureOpenCodeRuntimeProviders({ buildOpenCodeUrl, getOpenCodeAuthHeaders });
|
|
673
681
|
|
|
674
682
|
const ENV_CONFIGURED_API_PREFIX = normalizeApiPrefix(
|
|
675
|
-
process.env.OPENCODE_API_PREFIX || process.env.
|
|
683
|
+
process.env.OPENCODE_API_PREFIX || process.env.AIWORKER_API_PREFIX || ''
|
|
676
684
|
);
|
|
677
685
|
|
|
678
686
|
if (ENV_CONFIGURED_API_PREFIX && ENV_CONFIGURED_API_PREFIX !== '') {
|
|
@@ -878,6 +886,19 @@ notificationTriggerRuntime.setGetIsSessionAutoAccepting(
|
|
|
878
886
|
(sessionId, directory) => permissionAutoAcceptRuntime.isSessionAutoAccepting(sessionId, directory),
|
|
879
887
|
);
|
|
880
888
|
|
|
889
|
+
// Queued follow-up messages are delivered by the server so a closed tab or a
|
|
890
|
+
// dropped connection no longer strands them (VS Code keeps its UI-side queue).
|
|
891
|
+
const messageQueueRuntime = createMessageQueueRuntime({
|
|
892
|
+
globalEventHub: globalMessageStreamHub,
|
|
893
|
+
buildOpenCodeUrl,
|
|
894
|
+
getOpenCodeAuthHeaders,
|
|
895
|
+
sessionKnowledgeRuntime,
|
|
896
|
+
broadcastGlobalUiEvent,
|
|
897
|
+
onPromptSent: (sessionId) => sessionRuntime.markUserMessageSent(sessionId),
|
|
898
|
+
dataDir: AIWORKER_DATA_DIR,
|
|
899
|
+
});
|
|
900
|
+
messageQueueRuntime.start();
|
|
901
|
+
|
|
881
902
|
const openCodeWatcherRuntime = createOpenCodeWatcherRuntime({
|
|
882
903
|
waitForOpenCodePort: (...args) => waitForOpenCodePort(...args),
|
|
883
904
|
buildOpenCodeUrl,
|
|
@@ -931,7 +952,7 @@ const processForwardedEventPayload = (payload, emitSyntheticEvent) => {
|
|
|
931
952
|
}
|
|
932
953
|
|
|
933
954
|
emitSyntheticEvent({
|
|
934
|
-
type: '
|
|
955
|
+
type: 'aiworker:session-status',
|
|
935
956
|
properties: {
|
|
936
957
|
sessionID: sessionId,
|
|
937
958
|
status,
|
|
@@ -952,7 +973,7 @@ const processForwardedEventPayload = (payload, emitSyntheticEvent) => {
|
|
|
952
973
|
});
|
|
953
974
|
|
|
954
975
|
emitSyntheticEvent({
|
|
955
|
-
type: '
|
|
976
|
+
type: 'aiworker:session-activity',
|
|
956
977
|
properties: {
|
|
957
978
|
sessionId,
|
|
958
979
|
phase: status === 'busy' || status === 'retry' ? 'busy' : 'idle',
|
|
@@ -1044,7 +1065,7 @@ const bootstrapRuntime = createBootstrapRuntime({
|
|
|
1044
1065
|
registerAuthAndAccessRoutes,
|
|
1045
1066
|
registerTtsRoutes,
|
|
1046
1067
|
registerNotificationRoutes,
|
|
1047
|
-
|
|
1068
|
+
registerAiWorkerRoutes,
|
|
1048
1069
|
registerAgentToolRoutes: (app, options) => options.agentToolRuntime.registerRoutes(app, options.express),
|
|
1049
1070
|
express,
|
|
1050
1071
|
});
|
|
@@ -1208,11 +1229,15 @@ const openCodeLifecycleRuntime = createOpenCodeLifecycleRuntime({
|
|
|
1208
1229
|
const managedEnv = includeControl || includeWeb || includeMemory
|
|
1209
1230
|
? await (agentToolRuntime?.prepareManagedOpenCodeEnv({ includeControl, includeWeb, includeMemory }) || {})
|
|
1210
1231
|
: {};
|
|
1211
|
-
if (settings?.optimizeSystemPrompt !== true) return managedEnv;
|
|
1212
1232
|
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1233
|
+
// Each managed plugin appends itself to the config the previous one produced.
|
|
1234
|
+
let configContent = managedEnv.OPENCODE_CONFIG_CONTENT ?? process.env.OPENCODE_CONFIG_CONTENT;
|
|
1235
|
+
if (settings?.optimizeSystemPrompt === true) {
|
|
1236
|
+
({ OPENCODE_CONFIG_CONTENT: configContent } = await systemPromptRuntime.prepareManagedOpenCodeEnv(configContent));
|
|
1237
|
+
}
|
|
1238
|
+
// Always on for managed OpenCode: it only retries servers OpenCode gave up on.
|
|
1239
|
+
const mcpReconnectEnv = await mcpReconnectRuntime.prepareManagedOpenCodeEnv(configContent);
|
|
1240
|
+
return { ...managedEnv, ...mcpReconnectEnv };
|
|
1216
1241
|
},
|
|
1217
1242
|
});
|
|
1218
1243
|
|
|
@@ -1246,10 +1271,10 @@ const scheduledTasksRuntime = createScheduledTasksRuntime({
|
|
|
1246
1271
|
sessionKnowledgeRuntime,
|
|
1247
1272
|
setSessionAutoAccept: (sessionId, enabled, directory) => permissionAutoAcceptRuntime.setSessionPolicy(sessionId, enabled, directory),
|
|
1248
1273
|
emitTaskRunEvent: (event) => {
|
|
1249
|
-
for (const client of
|
|
1274
|
+
for (const client of uiAiWorkerEventClients) {
|
|
1250
1275
|
try {
|
|
1251
1276
|
writeSseEvent(client, {
|
|
1252
|
-
type: '
|
|
1277
|
+
type: 'aiworker:scheduled-task-ran',
|
|
1253
1278
|
properties: {
|
|
1254
1279
|
projectId: event.projectID,
|
|
1255
1280
|
taskId: event.taskID,
|
|
@@ -1259,17 +1284,17 @@ const scheduledTasksRuntime = createScheduledTasksRuntime({
|
|
|
1259
1284
|
},
|
|
1260
1285
|
});
|
|
1261
1286
|
} catch {
|
|
1262
|
-
|
|
1287
|
+
uiAiWorkerEventClients.delete(client);
|
|
1263
1288
|
}
|
|
1264
1289
|
}
|
|
1265
1290
|
},
|
|
1266
1291
|
logger: console,
|
|
1267
1292
|
});
|
|
1268
1293
|
const emitSessionCreatedEvent = (event) => {
|
|
1269
|
-
for (const client of
|
|
1294
|
+
for (const client of uiAiWorkerEventClients) {
|
|
1270
1295
|
try {
|
|
1271
1296
|
writeSseEvent(client, {
|
|
1272
|
-
type: '
|
|
1297
|
+
type: 'aiworker:session-created',
|
|
1273
1298
|
properties: {
|
|
1274
1299
|
sessionId: event.sessionID,
|
|
1275
1300
|
directory: event.directory,
|
|
@@ -1281,7 +1306,7 @@ const emitSessionCreatedEvent = (event) => {
|
|
|
1281
1306
|
},
|
|
1282
1307
|
});
|
|
1283
1308
|
} catch {
|
|
1284
|
-
|
|
1309
|
+
uiAiWorkerEventClients.delete(client);
|
|
1285
1310
|
}
|
|
1286
1311
|
}
|
|
1287
1312
|
};
|
|
@@ -1295,7 +1320,7 @@ const resolveMemoryProjectId = createMemoryProjectResolver({
|
|
|
1295
1320
|
return sanitizeProjects(settings?.projects || []).map((project) => project.path);
|
|
1296
1321
|
},
|
|
1297
1322
|
resolvePrimaryWorktreeRoot,
|
|
1298
|
-
managedProjectRoots: [path.join(
|
|
1323
|
+
managedProjectRoots: [...new Set([path.join(AIWORKER_USER_CONFIG_ROOT, 'chats'), AIWORKER_CHATS_DIR])],
|
|
1299
1324
|
});
|
|
1300
1325
|
|
|
1301
1326
|
/**
|
|
@@ -1303,17 +1328,17 @@ const resolveMemoryProjectId = createMemoryProjectResolver({
|
|
|
1303
1328
|
* stored is visible without reopening anything.
|
|
1304
1329
|
*/
|
|
1305
1330
|
const emitAgentMemoryChangedEvent = (event) => {
|
|
1306
|
-
for (const client of
|
|
1331
|
+
for (const client of uiAiWorkerEventClients) {
|
|
1307
1332
|
try {
|
|
1308
1333
|
writeSseEvent(client, {
|
|
1309
|
-
type: '
|
|
1334
|
+
type: 'aiworker:agent-memory-changed',
|
|
1310
1335
|
properties: {
|
|
1311
1336
|
scope: event.scope,
|
|
1312
1337
|
...(event.projectId ? { projectId: event.projectId } : {}),
|
|
1313
1338
|
},
|
|
1314
1339
|
});
|
|
1315
1340
|
} catch {
|
|
1316
|
-
|
|
1341
|
+
uiAiWorkerEventClients.delete(client);
|
|
1317
1342
|
}
|
|
1318
1343
|
}
|
|
1319
1344
|
};
|
|
@@ -1323,7 +1348,7 @@ const scheduledTaskService = createScheduledTaskService({
|
|
|
1323
1348
|
projectConfigRuntime,
|
|
1324
1349
|
scheduledTasksRuntime,
|
|
1325
1350
|
});
|
|
1326
|
-
const openChamberSessionService =
|
|
1351
|
+
const openChamberSessionService = createAiWorkerSessionService({
|
|
1327
1352
|
readSettingsFromDiskMigrated,
|
|
1328
1353
|
sanitizeProjects,
|
|
1329
1354
|
validateDirectoryPath,
|
|
@@ -1333,7 +1358,7 @@ const openChamberSessionService = createOpenChamberSessionService({
|
|
|
1333
1358
|
emitSessionCreatedEvent,
|
|
1334
1359
|
sessionKnowledgeRuntime,
|
|
1335
1360
|
});
|
|
1336
|
-
// Browser actions are published to whichever
|
|
1361
|
+
// Browser actions are published to whichever AiWorker clients are connected;
|
|
1337
1362
|
// the one owning the browser panel answers. `emitRequest` returns the number of
|
|
1338
1363
|
// clients reached so the broker can fail fast when nobody is listening.
|
|
1339
1364
|
const browserControlBroker = createBrowserControlBroker({
|
|
@@ -1344,11 +1369,11 @@ const browserControlBroker = createBrowserControlBroker({
|
|
|
1344
1369
|
// lets the broker say "not here" instead of timing out.
|
|
1345
1370
|
const needsBrowserView = request.action !== 'browser.open';
|
|
1346
1371
|
let delivered = 0;
|
|
1347
|
-
for (const client of
|
|
1348
|
-
if (needsBrowserView && client.
|
|
1372
|
+
for (const client of uiAiWorkerEventClients) {
|
|
1373
|
+
if (needsBrowserView && client.aiworkerBrowserCapable !== true) continue;
|
|
1349
1374
|
try {
|
|
1350
1375
|
writeSseEvent(client, {
|
|
1351
|
-
type: '
|
|
1376
|
+
type: 'aiworker:browser-control-request',
|
|
1352
1377
|
properties: {
|
|
1353
1378
|
requestId: request.requestId,
|
|
1354
1379
|
action: request.action,
|
|
@@ -1357,14 +1382,14 @@ const browserControlBroker = createBrowserControlBroker({
|
|
|
1357
1382
|
});
|
|
1358
1383
|
delivered += 1;
|
|
1359
1384
|
} catch {
|
|
1360
|
-
|
|
1385
|
+
uiAiWorkerEventClients.delete(client);
|
|
1361
1386
|
}
|
|
1362
1387
|
}
|
|
1363
1388
|
return delivered;
|
|
1364
1389
|
},
|
|
1365
1390
|
});
|
|
1366
1391
|
|
|
1367
|
-
const openChamberControlService =
|
|
1392
|
+
const openChamberControlService = createAiWorkerControlService({
|
|
1368
1393
|
readSettingsFromDiskMigrated,
|
|
1369
1394
|
sanitizeProjects,
|
|
1370
1395
|
buildOpenCodeUrl,
|
|
@@ -1375,7 +1400,7 @@ const openChamberControlService = createOpenChamberControlService({
|
|
|
1375
1400
|
browserControl: browserControlBroker,
|
|
1376
1401
|
agentMemoryActions: createAgentMemoryActions({
|
|
1377
1402
|
agentMemoryRuntime,
|
|
1378
|
-
createError: (message, status) => new
|
|
1403
|
+
createError: (message, status) => new AiWorkerControlError(message, status),
|
|
1379
1404
|
onMemoryChanged: emitAgentMemoryChangedEvent,
|
|
1380
1405
|
isAgentMemoryEnabled,
|
|
1381
1406
|
resolveProjectId: resolveMemoryProjectId,
|
|
@@ -1427,6 +1452,7 @@ const gracefulShutdownRuntime = createGracefulShutdownRuntime({
|
|
|
1427
1452
|
sessionAssistRuntime,
|
|
1428
1453
|
sessionGoalRuntime,
|
|
1429
1454
|
contextObligatoryRuntime,
|
|
1455
|
+
messageQueueRuntime,
|
|
1430
1456
|
sessionRuntime,
|
|
1431
1457
|
getHealthCheckInterval: () => healthCheckInterval,
|
|
1432
1458
|
clearHealthCheckInterval: (value) => clearInterval(value),
|
|
@@ -1465,14 +1491,14 @@ async function main(options = {}) {
|
|
|
1465
1491
|
const port = Number.isFinite(options.port) && options.port >= 0 ? Math.trunc(options.port) : DEFAULT_PORT;
|
|
1466
1492
|
const host = typeof options.host === 'string' && options.host.length > 0 ? options.host : undefined;
|
|
1467
1493
|
const effectiveBindHost = host
|
|
1468
|
-
|| (typeof process.env.
|
|
1469
|
-
? process.env.
|
|
1494
|
+
|| (typeof process.env.AIWORKER_HOST === 'string' && process.env.AIWORKER_HOST.trim().length > 0
|
|
1495
|
+
? process.env.AIWORKER_HOST.trim()
|
|
1470
1496
|
: '127.0.0.1');
|
|
1471
1497
|
agentToolRuntime = createAgentToolRuntime({
|
|
1472
1498
|
crypto,
|
|
1473
1499
|
fsPromises,
|
|
1474
1500
|
path,
|
|
1475
|
-
dataDir:
|
|
1501
|
+
dataDir: AIWORKER_DATA_DIR,
|
|
1476
1502
|
env: process.env,
|
|
1477
1503
|
executeAction: (...args) => openChamberControlService.execute(...args),
|
|
1478
1504
|
getActivePort: () => {
|
|
@@ -1483,7 +1509,12 @@ async function main(options = {}) {
|
|
|
1483
1509
|
systemPromptRuntime = createSystemPromptRuntime({
|
|
1484
1510
|
fsPromises,
|
|
1485
1511
|
path,
|
|
1486
|
-
dataDir:
|
|
1512
|
+
dataDir: AIWORKER_DATA_DIR,
|
|
1513
|
+
});
|
|
1514
|
+
mcpReconnectRuntime = createMcpReconnectRuntime({
|
|
1515
|
+
fsPromises,
|
|
1516
|
+
path,
|
|
1517
|
+
dataDir: AIWORKER_DATA_DIR,
|
|
1487
1518
|
});
|
|
1488
1519
|
|
|
1489
1520
|
// Pairing transports advertised to the create-device dialog. LAN reachability is
|
|
@@ -1564,7 +1595,7 @@ async function main(options = {}) {
|
|
|
1564
1595
|
};
|
|
1565
1596
|
const uiPassword = typeof options.uiPassword === 'string'
|
|
1566
1597
|
? options.uiPassword
|
|
1567
|
-
: (typeof process.env.
|
|
1598
|
+
: (typeof process.env.AIWORKER_UI_PASSWORD === 'string' ? process.env.AIWORKER_UI_PASSWORD : null);
|
|
1568
1599
|
if (
|
|
1569
1600
|
isNetworkExposedBindHost(effectiveBindHost)
|
|
1570
1601
|
&& !(typeof uiPassword === 'string' && uiPassword.trim().length > 0)
|
|
@@ -1573,7 +1604,7 @@ async function main(options = {}) {
|
|
|
1573
1604
|
throw new Error(getUnauthenticatedLanErrorMessage(effectiveBindHost));
|
|
1574
1605
|
}
|
|
1575
1606
|
const tryCfTunnel = options.tryCfTunnel === true;
|
|
1576
|
-
const apiOnly = options.apiOnly === true || isEnvFlagEnabled(process.env.
|
|
1607
|
+
const apiOnly = options.apiOnly === true || isEnvFlagEnabled(process.env.AIWORKER_API_ONLY);
|
|
1577
1608
|
const shouldUseCanonicalTunnelConfig = typeof options.tunnelMode === 'string'
|
|
1578
1609
|
|| typeof options.tunnelProvider === 'string'
|
|
1579
1610
|
|| options.tunnelConfigPath === null
|
|
@@ -1612,7 +1643,7 @@ async function main(options = {}) {
|
|
|
1612
1643
|
? options.getDesktopRuntimeConfig
|
|
1613
1644
|
: null;
|
|
1614
1645
|
|
|
1615
|
-
console.log(`Starting
|
|
1646
|
+
console.log(`Starting AiWorker on port ${port === 0 ? 'auto' : port}`);
|
|
1616
1647
|
|
|
1617
1648
|
// Voice enumeration is independent from route registration. Start it now,
|
|
1618
1649
|
// but do not hold server listen or managed OpenCode startup on `say -v "?"`.
|
|
@@ -1677,8 +1708,8 @@ async function main(options = {}) {
|
|
|
1677
1708
|
|
|
1678
1709
|
const bootstrapResult = bootstrapRuntime.setupBaseRoutes(app, {
|
|
1679
1710
|
process,
|
|
1680
|
-
|
|
1681
|
-
runtimeName: process.env.
|
|
1711
|
+
aiworkerVersion: AIWORKER_VERSION,
|
|
1712
|
+
runtimeName: process.env.AIWORKER_RUNTIME || 'web',
|
|
1682
1713
|
serverStartedAt,
|
|
1683
1714
|
gracefulShutdown,
|
|
1684
1715
|
getHealthSnapshot: () => {
|
|
@@ -1723,7 +1754,7 @@ async function main(options = {}) {
|
|
|
1723
1754
|
return Number.isFinite(port) && port > 0 ? port : null;
|
|
1724
1755
|
},
|
|
1725
1756
|
getTunnelUrl: () => tunnelRuntimeContextHolder?.tunnelService?.getPublicUrl?.() ?? null,
|
|
1726
|
-
verboseRequestLogs:
|
|
1757
|
+
verboseRequestLogs: AIWORKER_VERBOSE_REQUEST_LOGS,
|
|
1727
1758
|
uiPassword,
|
|
1728
1759
|
tunnelAuthController,
|
|
1729
1760
|
remoteClientAuthRuntime,
|
|
@@ -1750,9 +1781,9 @@ async function main(options = {}) {
|
|
|
1750
1781
|
getServerLabel: () => {
|
|
1751
1782
|
try {
|
|
1752
1783
|
const name = os.hostname();
|
|
1753
|
-
return typeof name === 'string' && name.trim().length > 0 ? name.trim() : '
|
|
1784
|
+
return typeof name === 'string' && name.trim().length > 0 ? name.trim() : 'AiWorker';
|
|
1754
1785
|
} catch {
|
|
1755
|
-
return '
|
|
1786
|
+
return 'AiWorker';
|
|
1756
1787
|
}
|
|
1757
1788
|
},
|
|
1758
1789
|
readSettingsFromDiskMigrated,
|
|
@@ -1779,7 +1810,7 @@ async function main(options = {}) {
|
|
|
1779
1810
|
path,
|
|
1780
1811
|
server,
|
|
1781
1812
|
__dirname,
|
|
1782
|
-
|
|
1813
|
+
aiworkerDataDir: AIWORKER_DATA_DIR,
|
|
1783
1814
|
modelsDevApiUrl: MODELS_DEV_API_URL,
|
|
1784
1815
|
modelsMetadataCacheTtl: MODELS_METADATA_CACHE_TTL,
|
|
1785
1816
|
fetchFreeZenModels,
|
|
@@ -1815,18 +1846,18 @@ async function main(options = {}) {
|
|
|
1815
1846
|
// the relay identity (serverId), so concurrent hosts evict each other at
|
|
1816
1847
|
// the relay worker and devices land on a random local instance.
|
|
1817
1848
|
hostLock: createRelayHostLock({
|
|
1818
|
-
lockFilePath: path.join(
|
|
1849
|
+
lockFilePath: path.join(AIWORKER_DATA_DIR, 'relay-host.lock'),
|
|
1819
1850
|
fs,
|
|
1820
1851
|
process,
|
|
1821
1852
|
}),
|
|
1822
1853
|
// Dev/debug instances share the data dir (and thus the relay identity) with
|
|
1823
1854
|
// the production instance, so they must not host the relay on their own —
|
|
1824
|
-
// paired devices would land on them.
|
|
1855
|
+
// paired devices would land on them. AIWORKER_RELAY_HOST=off disables
|
|
1825
1856
|
// passive hosting explicitly (dev scripts set it); the Electron dev shell is
|
|
1826
|
-
// covered via
|
|
1857
|
+
// covered via AIWORKER_ELECTRON_DEV. AIWORKER_RELAY_HOST=on overrides
|
|
1827
1858
|
// both. Explicit enable/pairing on the instance still hosts regardless.
|
|
1828
|
-
allowPassiveHost: process.env.
|
|
1829
|
-
|| (process.env.
|
|
1859
|
+
allowPassiveHost: process.env.AIWORKER_RELAY_HOST === 'on'
|
|
1860
|
+
|| (process.env.AIWORKER_RELAY_HOST !== 'off' && process.env.AIWORKER_ELECTRON_DEV !== '1'),
|
|
1830
1861
|
// Relay demand = any paired device or pending pairing session that uses the
|
|
1831
1862
|
// relay transport. Drives the auto on/off lifecycle.
|
|
1832
1863
|
hasRelayDemand: async () => {
|
|
@@ -1875,8 +1906,9 @@ async function main(options = {}) {
|
|
|
1875
1906
|
spawn,
|
|
1876
1907
|
resolveGitBinaryForSpawn,
|
|
1877
1908
|
createFsSearchRuntime: createFsSearchRuntimeFactory,
|
|
1878
|
-
|
|
1879
|
-
|
|
1909
|
+
aiworkerDataDir: AIWORKER_DATA_DIR,
|
|
1910
|
+
aiworkerUserConfigRoot: AIWORKER_USER_CONFIG_ROOT,
|
|
1911
|
+
managedChatsRoot: AIWORKER_CHATS_DIR,
|
|
1880
1912
|
normalizeDirectoryPath,
|
|
1881
1913
|
resolveProjectDirectory,
|
|
1882
1914
|
resolveOptionalProjectDirectory,
|
|
@@ -1895,7 +1927,7 @@ async function main(options = {}) {
|
|
|
1895
1927
|
buildOpenCodeUrl,
|
|
1896
1928
|
getOpenCodeAuthHeaders,
|
|
1897
1929
|
getOpenCodePort: () => openCodePort,
|
|
1898
|
-
// Dev-server discovery must not offer
|
|
1930
|
+
// Dev-server discovery must not offer AiWorker's own listeners back to
|
|
1899
1931
|
// the user as something to preview.
|
|
1900
1932
|
getOwnPorts: () => [port, openCodePort].filter((value) => Number.isInteger(value) && value > 0),
|
|
1901
1933
|
devServerScanner,
|
|
@@ -1911,9 +1943,10 @@ async function main(options = {}) {
|
|
|
1911
1943
|
openChamberControlService,
|
|
1912
1944
|
waitForOpenCodeReady,
|
|
1913
1945
|
emitSessionCreatedEvent,
|
|
1914
|
-
|
|
1946
|
+
getAiWorkerEventClients: () => uiAiWorkerEventClients,
|
|
1915
1947
|
writeSseEvent,
|
|
1916
1948
|
permissionAutoAcceptRuntime,
|
|
1949
|
+
messageQueueRuntime,
|
|
1917
1950
|
});
|
|
1918
1951
|
|
|
1919
1952
|
const startupPipelineResult = await startupPipelineRuntime.run({
|
|
@@ -1964,7 +1997,7 @@ async function main(options = {}) {
|
|
|
1964
1997
|
tunnelRuntimeContext,
|
|
1965
1998
|
attachSignals,
|
|
1966
1999
|
apiOnly,
|
|
1967
|
-
dictationModelsDir: path.join(
|
|
2000
|
+
dictationModelsDir: path.join(AIWORKER_USER_CONFIG_ROOT, 'speech-models'),
|
|
1968
2001
|
});
|
|
1969
2002
|
terminalRuntime = startupPipelineResult.terminalRuntime;
|
|
1970
2003
|
dictationRuntime = startupPipelineResult.dictationRuntime;
|
|
@@ -1981,7 +2014,7 @@ async function main(options = {}) {
|
|
|
1981
2014
|
// device/session exists, stop it (and clear a stale enabled flag) otherwise.
|
|
1982
2015
|
void relayService.reconcile();
|
|
1983
2016
|
|
|
1984
|
-
// Relay demand can change outside our routes: `
|
|
2017
|
+
// Relay demand can change outside our routes: `aiworker connect-url
|
|
1985
2018
|
// --relay` writes a pending relay session straight to the on-disk store, and
|
|
1986
2019
|
// pending sessions expire without any request hitting us. Poll reconcile so a
|
|
1987
2020
|
// headless instance picks the relay up (or drops it) within a minute.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dispatch for the `memory.*` actions the `
|
|
2
|
+
* Dispatch for the `memory.*` actions the `aiworker_memory` tool calls.
|
|
3
3
|
*
|
|
4
4
|
* Kept beside the store rather than inside the control service, because the
|
|
5
5
|
* control service already owns sessions, schedules and the browser; memory
|
|
@@ -226,7 +226,7 @@ export const createAgentMemoryActions = (dependencies) => {
|
|
|
226
226
|
enabled = false;
|
|
227
227
|
}
|
|
228
228
|
if (!enabled) {
|
|
229
|
-
return fail('Agent memory is switched off in
|
|
229
|
+
return fail('Agent memory is switched off in AiWorker settings', 403);
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
@@ -14,6 +14,6 @@
|
|
|
14
14
|
const TRUTHY = new Set(['1', 'true', 'yes', 'on']);
|
|
15
15
|
|
|
16
16
|
export const isAgentMemoryFeatureAvailable = () => {
|
|
17
|
-
const raw = process.env.
|
|
17
|
+
const raw = process.env.AIWORKER_MEMORY_ENABLE;
|
|
18
18
|
return typeof raw === 'string' && TRUTHY.has(raw.trim().toLowerCase());
|
|
19
19
|
};
|
|
@@ -2,37 +2,37 @@ import { afterEach, describe, expect, test } from 'bun:test';
|
|
|
2
2
|
|
|
3
3
|
import { isAgentMemoryFeatureAvailable } from './feature-flag.js';
|
|
4
4
|
|
|
5
|
-
const original = process.env.
|
|
5
|
+
const original = process.env.AIWORKER_MEMORY_ENABLE;
|
|
6
6
|
|
|
7
7
|
afterEach(() => {
|
|
8
|
-
if (original === undefined) delete process.env.
|
|
9
|
-
else process.env.
|
|
8
|
+
if (original === undefined) delete process.env.AIWORKER_MEMORY_ENABLE;
|
|
9
|
+
else process.env.AIWORKER_MEMORY_ENABLE = original;
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
describe('the unreleased feature gate', () => {
|
|
13
13
|
test('is closed when the variable is unset', () => {
|
|
14
|
-
delete process.env.
|
|
14
|
+
delete process.env.AIWORKER_MEMORY_ENABLE;
|
|
15
15
|
expect(isAgentMemoryFeatureAvailable()).toBe(false);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
test('opens for the usual truthy spellings', () => {
|
|
19
19
|
for (const value of ['1', 'true', 'TRUE', 'yes', 'on', ' true ']) {
|
|
20
|
-
process.env.
|
|
20
|
+
process.env.AIWORKER_MEMORY_ENABLE = value;
|
|
21
21
|
expect(isAgentMemoryFeatureAvailable()).toBe(true);
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('stays closed for anything else, including "false"', () => {
|
|
26
26
|
for (const value of ['', '0', 'false', 'no', 'off', 'maybe']) {
|
|
27
|
-
process.env.
|
|
27
|
+
process.env.AIWORKER_MEMORY_ENABLE = value;
|
|
28
28
|
expect(isAgentMemoryFeatureAvailable()).toBe(false);
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test('is read per call, so a process started with it set is what decides', () => {
|
|
33
|
-
delete process.env.
|
|
33
|
+
delete process.env.AIWORKER_MEMORY_ENABLE;
|
|
34
34
|
expect(isAgentMemoryFeatureAvailable()).toBe(false);
|
|
35
|
-
process.env.
|
|
35
|
+
process.env.AIWORKER_MEMORY_ENABLE = '1';
|
|
36
36
|
expect(isAgentMemoryFeatureAvailable()).toBe(true);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* AiWorker agent memory routes.
|
|
3
3
|
*
|
|
4
4
|
* The scope is a query parameter rather than part of the path, because global
|
|
5
5
|
* and project memory are the same resource with two homes: one set of handlers
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* scope wrong must fail loudly, never silently write the user's global memory
|
|
8
8
|
* from a project-scoped call.
|
|
9
9
|
*
|
|
10
|
-
* Memory is created by the agent through the `
|
|
10
|
+
* Memory is created by the agent through the `aiworker_memory` tool, so
|
|
11
11
|
* there is no create route here; the panel reads, corrects, and deletes.
|
|
12
12
|
*
|
|
13
13
|
* The body parser is attached per route rather than globally: the generic
|