@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
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{f as he,r as re,j as s,R as ue}from"./vendor-react-BUCujlKS.js";import{f as pe,h as ce,B as Se,I as ae,b5 as _e,bD as je,y as xe,ab as Le,bS as de,h2 as De,h3 as be,t as Ne,fj as Re}from"./useAppFontEffects-CjrntdL0.js";import{x as Ie,w as Te,v as Ee}from"./runtimeEndpointReset-CjhvxLH0.js";import{a as Me}from"./index-DW_E3rnL.js";const we="inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]";function Ge(t){const e=he.c(61),{draft:i,onEdit:y,onDelete:m,className:E,maxWidth:O}=t,{t:n}=pe(),[N,W]=re.useState(!1),M=i.text;let V;e[0]!==M?(V=M.length>150||M.split(`
|
|
2
|
-
`).length>3,e[0]=M,e[1]=V):V=e[1];const c=V;let f;e[2]!==E?(f=ce("w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-none",E),e[2]=E,e[3]=f):f=e[3];const d=O?`${Math.max(200,Math.floor(O))}px`:void 0;let F;e[4]!==d?(F={maxWidth:d},e[4]=d,e[5]=F):F=e[5];let k;e[6]===Symbol.for("react.memo_cache_sentinel")?(k={backgroundColor:"color-mix(in srgb, var(--surface-mutedForeground) 8%, transparent)"},e[6]=k):k=e[6];let w;e[7]!==i.fileLabel?(w=s.jsx("span",{className:"min-w-0 max-w-[200px] truncate text-xs font-medium text-[var(--surface-foreground)]",title:i.fileLabel,children:i.fileLabel}),e[7]=i.fileLabel,e[8]=w):w=e[8];let C;e[9]===Symbol.for("react.memo_cache_sentinel")?(C=s.jsx("span",{className:"text-xs text-[var(--surface-mutedForeground)]",children:"•"}),e[9]=C):C=e[9];let u;e[10]!==i.endLine||e[11]!==i.startLine||e[12]!==n?(u=n("inlineComment.range.lines",{start:i.startLine,end:i.endLine}),e[10]=i.endLine,e[11]=i.startLine,e[12]=n,e[13]=u):u=e[13];const B=i.side?` (${i.side})`:"";let a;e[14]!==u||e[15]!==B?(a=s.jsxs("span",{className:"min-w-0 flex-1 truncate text-xs text-[var(--surface-mutedForeground)]",children:[u,B]}),e[14]=u,e[15]=B,e[16]=a):a=e[16];let R;e[17]===Symbol.for("react.memo_cache_sentinel")?(R={minHeight:0,minWidth:0},e[17]=R):R=e[17];let p;e[18]!==n?(p=n("inlineComment.actions.editComment"),e[18]=n,e[19]=p):p=e[19];let g;e[20]!==n?(g=n("inlineComment.actions.editComment"),e[20]=n,e[21]=g):g=e[21];let I;e[22]===Symbol.for("react.memo_cache_sentinel")?(I=s.jsx(ae,{name:"pencil",className:"h-3 w-3"}),e[22]=I):I=e[22];let l;e[23]!==y||e[24]!==p||e[25]!==g?(l=s.jsx("button",{type:"button",className:we,style:R,onClick:y,"aria-label":p,title:g,children:I}),e[23]=y,e[24]=p,e[25]=g,e[26]=l):l=e[26];let L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L={minHeight:0,minWidth:0},e[27]=L):L=e[27];let x;e[28]!==n?(x=n("inlineComment.actions.deleteComment"),e[28]=n,e[29]=x):x=e[29];let b;e[30]!==n?(b=n("inlineComment.actions.deleteComment"),e[30]=n,e[31]=b):b=e[31];let $;e[32]===Symbol.for("react.memo_cache_sentinel")?($=s.jsx(ae,{name:"close",className:"h-3 w-3"}),e[32]=$):$=e[32];let S;e[33]!==m||e[34]!==x||e[35]!==b?(S=s.jsx("button",{type:"button",className:we,style:L,onClick:m,"aria-label":x,title:b,children:$}),e[33]=m,e[34]=x,e[35]=b,e[36]=S):S=e[36];let D;e[37]!==a||e[38]!==l||e[39]!==S||e[40]!==w?(D=s.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5",style:k,children:[w,C,a,l,S]}),e[37]=a,e[38]=l,e[39]=S,e[40]=w,e[41]=D):D=e[41];const _=N||!c,z=!N&&c&&"line-clamp-3";let h;e[42]!==z?(h=ce("whitespace-pre-wrap break-words text-sm leading-relaxed text-[var(--surface-foreground)]",z),e[42]=z,e[43]=h):h=e[43];let Y;e[44]!==M||e[45]!==h?(Y=s.jsx("div",{className:h,children:M}),e[44]=M,e[45]=h,e[46]=Y):Y=e[46];let j;e[47]!==c||e[48]!==N||e[49]!==n?(j=c&&s.jsx(Ie,{asChild:!0,children:s.jsx(Se,{variant:"ghost",size:"sm",className:"mt-1 h-6 w-full justify-start px-0 text-xs text-muted-foreground hover:text-foreground",children:N?s.jsxs(s.Fragment,{children:[s.jsx(ae,{name:"arrow-up-s",className:"mr-1 size-3"}),n("inlineComment.actions.showLess")]}):s.jsxs(s.Fragment,{children:[s.jsx(ae,{name:"arrow-down-s",className:"mr-1 size-3"}),n("inlineComment.actions.showMore")]})})}),e[47]=c,e[48]=N,e[49]=n,e[50]=j):j=e[50];let K;e[51]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Te,{}),e[51]=K):K=e[51];let T;e[52]!==_||e[53]!==Y||e[54]!==j?(T=s.jsx("div",{className:"px-3 py-2",children:s.jsxs(Ee,{open:_,onOpenChange:W,children:[Y,j,K]})}),e[52]=_,e[53]=Y,e[54]=j,e[55]=T):T=e[55];let P;return e[56]!==f||e[57]!==D||e[58]!==T||e[59]!==F?(P=s.jsxs("div",{className:f,style:F,"data-comment-card":"true",children:[D,T]}),e[56]=f,e[57]=D,e[58]=T,e[59]=F,e[60]=P):P=e[60],P}function Je(t){const e=he.c(61),{initialText:i,onTextChange:y,onSave:m,onCancel:E,fileLabel:O,lineRange:n,isEditing:N,className:W,maxWidth:M}=t,V=i===void 0?"":i,{t:c}=pe(),{isMobile:f}=_e(),[d,F]=ue.useState(V),k=re.useRef(null),w=je("mod+enter");let C,u;e[0]!==y?(C=o=>{F(o),y?.(o),u()},u=()=>{const o=k.current;o&&(o.style.height="auto",o.style.height=`${Math.min(o.scrollHeight,120)}px`)},e[0]=y,e[1]=C,e[2]=u):(C=e[1],u=e[2]);const B=re.useRef(n);let a,R;e[3]!==n?(a=()=>{n&&(B.current=n)},R=[n],e[3]=n,e[4]=a,e[5]=R):(a=e[4],R=e[5]),re.useEffect(a,R);const p=Ke,g=p(n);let I;e[6]!==f||e[7]!==u?(I=()=>{const o=k.current;if(!o)return;u();const ie=o.closest(".overlay-scrollbar-container"),ge=ie?.scrollTop??window.scrollY,ve=ie?.scrollLeft??window.scrollX;if(f){o.scrollIntoView({behavior:"auto",block:"nearest"});try{o.focus({preventScroll:!0})}catch{o.focus()}return}try{o.focus({preventScroll:!0})}catch{o.focus()}const ye=o.value.length;try{o.setSelectionRange(ye,ye)}catch{}requestAnimationFrame(()=>{ie?(ie.scrollTop=ge,ie.scrollLeft=ve):window.scrollTo({top:ge,left:ve})})},e[6]=f,e[7]=u,e[8]=I):I=e[8];let l;e[9]!==f?(l=[f],e[9]=f,e[10]=l):l=e[10],re.useEffect(I,l);let L;e[11]!==m||e[12]!==d?(L=()=>{d.trim()&&m(d,p(B.current))},e[11]=m,e[12]=d,e[13]=L):L=e[13];const x=L;let b;e[14]!==E||e[15]!==x?(b=o=>{(o.metaKey||o.ctrlKey)&&o.key==="Enter"?(o.preventDefault(),x()):o.key==="Escape"&&(o.preventDefault(),E())},e[14]=E,e[15]=x,e[16]=b):b=e[16];const $=b;let S;e[17]!==x?(S=o=>{o.stopPropagation(),x()},e[17]=x,e[18]=S):S=e[18];const D=S;let _;e[19]!==W?(_=ce("w-full max-w-[min(100%,calc(var(--oc-context-panel-width,100vw)-var(--oc-editor-gutter-width,0px)))] animate-in fade-in zoom-in-95 duration-200",W),e[19]=W,e[20]=_):_=e[20];const z=M?`${Math.max(200,Math.floor(M))}px`:void 0;let h;e[21]!==z?(h={maxWidth:z},e[21]=z,e[22]=h):h=e[22];const Y="true",j=ze,K=$e,T="oc-glass-popover rounded-xl border border-[var(--interactive-border)] shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]",P=O||g?s.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2 text-xs font-medium text-[var(--surface-mutedForeground)] opacity-60",children:[O?s.jsx("span",{className:"max-w-[200px] truncate",children:O}):null,O&&g?s.jsx("span",{children:"•"}):null,g?s.jsx("span",{children:c("inlineComment.range.lines",{start:g.start,end:g.end})}):null]}):null,G="flex items-end gap-2 py-1 pl-3 pr-1",oe=1;let H;e[23]!==C?(H=o=>C(o.target.value),e[23]=C,e[24]=H):H=e[24];const r=f?c("inlineComment.input.placeholderShort"):c("inlineComment.input.placeholder",{shortcut:w}),v=f?"py-1.5 text-base leading-6":"py-1.5";let A;e[25]!==v?(A=ce("min-w-0 flex-1 resize-none bg-transparent text-sm leading-5 text-[var(--surface-foreground)] outline-none placeholder:text-[var(--surface-mutedForeground)] placeholder:opacity-60",v),e[25]=v,e[26]=A):A=e[26];let X;e[27]===Symbol.for("react.memo_cache_sentinel")?(X={minHeight:0,height:"auto"},e[27]=X):X=e[27];let U;e[28]!==$||e[29]!==H||e[30]!==r||e[31]!==A||e[32]!==d?(U=s.jsx("textarea",{ref:k,rows:oe,value:d,onChange:H,onKeyDown:$,placeholder:r,className:A,style:X}),e[28]=$,e[29]=H,e[30]=r,e[31]=A,e[32]=d,e[33]=U):U=e[33];let q;e[34]!==d?(q=d.trim(),e[34]=d,e[35]=q):q=e[35];const J=!q,le=f?"h-9 w-9":"h-8 w-8";let Q;e[36]!==le?(Q=ce("mb-0.5 flex shrink-0 items-center justify-center rounded-full bg-[var(--primary-base)] text-[var(--primary-foreground)] transition-opacity duration-150 hover:opacity-90 disabled:opacity-40",le),e[36]=le,e[37]=Q):Q=e[37];let Z;e[38]!==c?(Z=c("inlineComment.actions.comment"),e[38]=c,e[39]=Z):Z=e[39];let ee;e[40]!==c?(ee=c("inlineComment.actions.comment"),e[40]=c,e[41]=ee):ee=e[41];let me;e[42]===Symbol.for("react.memo_cache_sentinel")?(me=s.jsx(ae,{name:"attachment-2",className:"h-4 w-4"}),e[42]=me):me=e[42];let te;e[43]!==D||e[44]!==J||e[45]!==Q||e[46]!==Z||e[47]!==ee?(te=s.jsx("button",{type:"button",onClick:D,onPointerDown:ke,onTouchStart:Fe,disabled:J,className:Q,"aria-label":Z,title:ee,children:me}),e[43]=D,e[44]=J,e[45]=Q,e[46]=Z,e[47]=ee,e[48]=te):te=e[48];let ne;e[49]!==U||e[50]!==te?(ne=s.jsxs("div",{className:G,children:[U,te]}),e[49]=U,e[50]=te,e[51]=ne):ne=e[51];let se;e[52]!==P||e[53]!==ne?(se=s.jsxs("div",{className:T,children:[P,ne]}),e[52]=P,e[53]=ne,e[54]=se):se=e[54];let fe;return e[55]!==_||e[56]!==h||e[57]!==j||e[58]!==K||e[59]!==se?(fe=s.jsx("div",{className:_,style:h,"data-comment-input":Y,onPointerDown:j,onTouchStart:K,children:se}),e[55]=_,e[56]=h,e[57]=j,e[58]=K,e[59]=se,e[60]=fe):fe=e[60],fe}function Fe(t){return t.stopPropagation()}function ke(t){return t.stopPropagation()}function $e(t){return t.stopPropagation()}function ze(t){return t.stopPropagation()}function Ke(t){if(!t)return;const e=Math.min(t.start,t.end),i=Math.max(t.start,t.end);return{...t,start:e,end:i}}const Pe=t=>{const e=Math.min(t.startLine,t.endLine),i=Math.max(t.startLine,t.endLine);return{...t,startLine:e,endLine:i}},Ce=t=>{const e=Math.min(t.start,t.end),i=Math.max(t.start,t.end);return{...t,start:e,end:i}};function Qe(t){const e=he.c(47),{t:i}=pe(),{source:y,fileLabel:m,language:E,getCodeForRange:O,toStoreRange:n,fromDraftRange:N}=t,W=xe(qe),M=xe(He),V=Le();let c;e[0]!==W?(c=r=>W?r.getDirectoryForSession(W):null,e[0]=W,e[1]=c):c=e[1];const f=xe(c),d=de(We),F=de(Oe),k=de(Ae),[w,C]=ue.useState(null),[u,B]=ue.useState(""),[a,R]=ue.useState(null),p=W??(M?"draft":null),g=f??V;let I;e:{if(!p||!g){I=null;break e}let r;e[2]!==g||e[3]!==p?(r={directory:g,sessionKey:p},e[2]=g,e[3]=p,e[4]=r):r=e[4],I=r}const l=I;let L;e[5]!==l?(L=l?De(Me(),l.directory,l.sessionKey):null,e[5]=l,e[6]=L):L=e[6];const x=L;let b;e[7]!==x?(b=r=>x?r.drafts[x]??be:be,e[7]=x,e[8]=b):b=e[8];const $=de(b);let S;e:{if(!l||!m){let v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=[],e[9]=v):v=e[9],S=v;break e}let r;if(e[10]!==m||e[11]!==$||e[12]!==y){let v;e[14]!==m||e[15]!==y?(v=A=>A.source===y&&A.fileLabel===m,e[14]=m,e[15]=y,e[16]=v):v=e[16],r=$.filter(v),e[10]=m,e[11]=$,e[12]=y,e[13]=r}else r=e[13];S=r}const D=S;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{C(null),B(""),R(null)},e[17]=_):_=e[17];const z=_;let h;e[18]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{z()},e[18]=h):h=e[18];const Y=h;let j;e[19]!==N?(j=r=>{const v=Ce(N(r));C(v),B(r.text),R(r.id)},e[19]=N,e[20]=j):j=e[20];const K=j;let T;e[21]!==a||e[22]!==k||e[23]!==l?(T=r=>{l&&(k(l,r.id),a===r.id&&z())},e[21]=a,e[22]=k,e[23]=l,e[24]=T):T=e[24];const P=T;let G;e[25]!==d||e[26]!==a||e[27]!==m||e[28]!==O||e[29]!==E||e[30]!==w||e[31]!==y||e[32]!==i||e[33]!==l||e[34]!==n||e[35]!==F?(G=(r,v)=>{const A=v??w,X=r.trim();if(!A||!X||!m)return;if(!l){Ne.error(i("inlineComment.toast.selectSessionToSave"));return}const U=Ce(A),q=Pe(n(U)),J=O(U),le=!a;a?F(l,a,{fileLabel:m,startLine:q.startLine,endLine:q.endLine,side:q.side,code:J,language:E,text:X}):d(l,{source:y,fileLabel:m,startLine:q.startLine,endLine:q.endLine,side:q.side,code:J,language:E,text:X}),z(),le&&requestAnimationFrame(Re)},e[25]=d,e[26]=a,e[27]=m,e[28]=O,e[29]=E,e[30]=w,e[31]=y,e[32]=i,e[33]=l,e[34]=n,e[35]=F,e[36]=G):G=e[36];const oe=G;let H;return e[37]!==u||e[38]!==P||e[39]!==D||e[40]!==a||e[41]!==N||e[42]!==oe||e[43]!==w||e[44]!==p||e[45]!==K?(H={sessionKey:p,drafts:D,selection:w,setSelection:C,commentText:u,setCommentText:B,editingDraftId:a,setEditingDraftId:R,reset:z,cancel:Y,startEdit:K,deleteDraft:P,saveComment:oe,fromDraftRange:N},e[37]=u,e[38]=P,e[39]=D,e[40]=a,e[41]=N,e[42]=oe,e[43]=w,e[44]=p,e[45]=K,e[46]=H):H=e[46],H}function Ae(t){return t.removeDraft}function Oe(t){return t.updateDraft}function We(t){return t.addDraft}function He(t){return t.newSessionDraft?.open}function qe(t){return t.currentSessionId}export{Je as I,Ge as a,Ce as n,Qe as u};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
function a(e,t,n){function r(c,u){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:u,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,u);const l=i.prototype,f=Object.keys(l);for(let p=0;p<f.length;p++){const h=f[p];h in c||(c[h]=l[h].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var u;const l=n?.Parent?new s:this;r(l,c),(u=l._zod).deferred??(u.deferred=[]);for(const f of l._zod.deferred)f();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class D extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ae extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Re={};function P(e){return Re}function Ce(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function re(e,t){return typeof t=="bigint"?t.toString():t}function X(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function se(e){return e==null}function ce(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function mt(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const u=r.match(/\d?e-(\d?)/);u?.[1]&&(o=Number.parseInt(u[1]))}const s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const pe=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==pe)return r===void 0&&(r=pe,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function A(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function N(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function de(e){return JSON.stringify(e)}function _t(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const De="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function M(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const gt=X(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function U(e){if(M(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(M(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Ue(e){return U(e)?{...e}:Array.isArray(e)?[...e]:e}const vt=new Set(["string","number","symbol"]);function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function j(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function d(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function zt(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const yt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function bt(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=N(e._zod.def,{get shape(){const i={};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return A(this,"shape",i),i},checks:[]});return j(e,s)}function wt(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=N(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return A(this,"shape",i),i},checks:[]});return j(e,s)}function kt(e,t){if(!U(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=N(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return A(this,"shape",s),s}});return j(e,o)}function $t(e,t){if(!U(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=N(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return A(this,"shape",r),r}});return j(e,n)}function Zt(e,t){const n=N(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return A(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return j(e,n)}function Ot(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=N(t._zod.def,{get shape(){const c=t._zod.def.shape,u={...c};if(n)for(const l in n){if(!(l in c))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(u[l]=e?new e({type:"optional",innerType:c[l]}):c[l])}else for(const l in c)u[l]=e?new e({type:"optional",innerType:c[l]}):c[l];return A(this,"shape",u),u},checks:[]});return j(t,i)}function St(e,t,n){const r=N(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return A(this,"shape",s),s}});return j(t,r)}function R(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function C(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function W(e){return typeof e=="string"?e:e?.message}function T(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=W(e.inst?._zod.def?.error?.(e))??W(t?.error?.(e))??W(n.customError?.(e))??W(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ue(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function L(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Fe=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,re,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},xe=a("$ZodError",Fe),Je=a("$ZodError",Fe,{Parent:Error});function Et(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function It(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c<s.path.length;){const u=s.path[c];c===s.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(s))):i[u]=i[u]||{_errors:[]},i=i[u],c++}}};return r(e),n}const ae=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new D;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(u=>T(u,s,P())));throw De(c,o?.callee),c}return i.value},le=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(u=>T(u,s,P())));throw De(c,o?.callee),c}return i.value},H=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new D;return s.issues.length?{success:!1,error:new(e??xe)(s.issues.map(i=>T(i,o,P())))}:{success:!0,data:s.value}},Pt=H(Je),Q=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>T(i,o,P())))}:{success:!0,data:s.value}},Tt=Q(Je),Nt=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ae(e)(t,n,o)},jt=e=>(t,n,r)=>ae(e)(t,n,r),At=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return le(e)(t,n,o)},Rt=e=>async(t,n,r)=>le(e)(t,n,r),Ct=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return H(e)(t,n,o)},Dt=e=>(t,n,r)=>H(e)(t,n,r),Ut=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Q(e)(t,n,o)},Ft=e=>async(t,n,r)=>Q(e)(t,n,r),xt=/^[cC][^\s-]{8,}$/,Jt=/^[0-9a-z]+$/,Mt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Lt=/^[0-9a-vA-V]{20}$/,Vt=/^[A-Za-z0-9]{27}$/,Wt=/^[a-zA-Z0-9_-]{21}$/,Kt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,he=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Gt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Yt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function qt(){return new RegExp(Yt,"u")}const Xt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ht=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Qt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,en=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Me=/^[A-Za-z0-9_-]*$/,nn=/^\+[1-9]\d{6,14}$/,Le="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",rn=new RegExp(`^${Le}$`);function Ve(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function on(e){return new RegExp(`^${Ve(e)}$`)}function sn(e){const t=Ve({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Le}T(?:${r})$`)}const cn=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},un=/^-?\d+$/,We=/^-?\d+(?:\.\d+)?$/,an=/^[^A-Z]*$/,ln=/^[^a-z]*$/,O=a("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ke={number:"number",bigint:"bigint",object:"date"},Be=a("$ZodCheckLessThan",(e,t)=>{O.init(e,t);const n=Ke[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ge=a("$ZodCheckGreaterThan",(e,t)=>{O.init(e,t);const n=Ke[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fn=a("$ZodCheckMultipleOf",(e,t)=>{O.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):mt(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),pn=a("$ZodCheckNumberFormat",(e,t)=>{O.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=yt[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=un)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),dn=a("$ZodCheckMaxLength",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!se(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=ue(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hn=a("$ZodCheckMinLength",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!se(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=ue(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),mn=a("$ZodCheckLengthEquals",(e,t)=>{var n;O.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!se(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=ue(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ee=a("$ZodCheckStringFormat",(e,t)=>{var n,r;O.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),_n=a("$ZodCheckRegex",(e,t)=>{ee.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),gn=a("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=an),ee.init(e,t)}),vn=a("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ln),ee.init(e,t)}),zn=a("$ZodCheckIncludes",(e,t)=>{O.init(e,t);const n=F(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),yn=a("$ZodCheckStartsWith",(e,t)=>{O.init(e,t);const n=new RegExp(`^${F(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),bn=a("$ZodCheckEndsWith",(e,t)=>{O.init(e,t);const n=new RegExp(`.*${F(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),wn=a("$ZodCheckOverwrite",(e,t)=>{O.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class kn{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
2
|
-
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
|
|
3
|
-
`))}}const $n={major:4,minor:3,patch:6},z=a("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$n;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,u)=>{let l=R(i),f;for(const p of c){if(p._zod.def.when){if(!p._zod.def.when(i))continue}else if(l)continue;const h=i.issues.length,m=p._zod.check(i);if(m instanceof Promise&&u?.async===!1)throw new D;if(f||m instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await m,i.issues.length!==h&&(l||(l=R(i,h)))});else{if(i.issues.length===h)continue;l||(l=R(i,h))}}return f?f.then(()=>i):i},s=(i,c,u)=>{if(R(i))return i.aborted=!0,i;const l=o(c,r,u);if(l instanceof Promise){if(u.async===!1)throw new D;return l.then(f=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(f=>s(f,i,c)):s(l,i,c)}const u=e._zod.parse(i,c);if(u instanceof Promise){if(c.async===!1)throw new D;return u.then(l=>o(l,r,c))}return o(u,r,c)}}_(e,"~standard",()=>({validate:o=>{try{const s=Pt(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Tt(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),fe=a("$ZodString",(e,t)=>{z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??cn(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),g=a("$ZodStringFormat",(e,t)=>{ee.init(e,t),fe.init(e,t)}),Zn=a("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Bt),g.init(e,t)}),On=a("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=he(r))}else t.pattern??(t.pattern=he());g.init(e,t)}),Sn=a("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Gt),g.init(e,t)}),En=a("$ZodURL",(e,t)=>{g.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),In=a("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=qt()),g.init(e,t)}),Pn=a("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Wt),g.init(e,t)}),Tn=a("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=xt),g.init(e,t)}),Nn=a("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jt),g.init(e,t)}),jn=a("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Mt),g.init(e,t)}),An=a("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Lt),g.init(e,t)}),Rn=a("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vt),g.init(e,t)}),Cn=a("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=sn(t)),g.init(e,t)}),Dn=a("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=rn),g.init(e,t)}),Un=a("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=on(t)),g.init(e,t)}),Fn=a("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Kt),g.init(e,t)}),xn=a("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Xt),g.init(e,t),e._zod.bag.format="ipv4"}),Jn=a("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ht),g.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Mn=a("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qt),g.init(e,t)}),Ln=a("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=en),g.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ye(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Vn=a("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tn),g.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ye(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Wn(e){if(!Me.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ye(n)}const Kn=a("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Me),g.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Wn(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Bn=a("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nn),g.init(e,t)});function Gn(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Yn=a("$ZodJWT",(e,t)=>{g.init(e,t),e._zod.check=n=>{Gn(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),qe=a("$ZodNumber",(e,t)=>{z.init(e,t),e._zod.pattern=e._zod.bag.pattern??We,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),qn=a("$ZodNumberFormat",(e,t)=>{pn.init(e,t),qe.init(e,t)}),Xn=a("$ZodUnknown",(e,t)=>{z.init(e,t),e._zod.parse=n=>n}),Hn=a("$ZodNever",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function me(e,t,n){e.issues.length&&t.issues.push(...C(n,e.issues)),t.value[n]=e.value}const Qn=a("$ZodArray",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const c=o[i],u=t.element._zod.run({value:c,issues:[]},r);u instanceof Promise?s.push(u.then(l=>me(l,n,i))):me(u,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function G(e,t,n,r,o){if(e.issues.length){if(o&&!(n in r))return;t.issues.push(...C(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Xe(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=zt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function He(e,t,n,r,o,s){const i=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,f=u.optout==="optional";for(const p in t){if(c.has(p))continue;if(l==="never"){i.push(p);continue}const h=u.run({value:t[p],issues:[]},r);h instanceof Promise?e.push(h.then(m=>G(m,n,p,t,f))):G(h,n,p,t,f)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const er=a("$ZodObject",(e,t)=>{if(z.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...c};return Object.defineProperty(t,"shape",{value:u}),u}})}const r=X(()=>Xe(t));_(e._zod,"propValues",()=>{const c=t.shape,u={};for(const l in c){const f=c[l]._zod;if(f.values){u[l]??(u[l]=new Set);for(const p of f.values)u[l].add(p)}}return u});const o=M,s=t.catchall;let i;e._zod.parse=(c,u)=>{i??(i=r.value);const l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};const f=[],p=i.shape;for(const h of i.keys){const m=p[h],k=m._zod.optout==="optional",w=m._zod.run({value:l[h],issues:[]},u);w instanceof Promise?f.push(w.then(V=>G(V,c,h,l,k))):G(w,c,h,l,k)}return s?He(f,l,c,u,r.value,e):f.length?Promise.all(f).then(()=>c):c}}),tr=a("$ZodObjectJIT",(e,t)=>{er.init(e,t);const n=e._zod.parse,r=X(()=>Xe(t)),o=h=>{const m=new kn(["shape","payload","ctx"]),k=r.value,w=I=>{const Z=de(I);return`shape[${Z}]._zod.run({ value: input[${Z}], issues: [] }, ctx)`};m.write("const input = payload.value;");const V=Object.create(null);let pt=0;for(const I of k.keys)V[I]=`key_${pt++}`;m.write("const newResult = {};");for(const I of k.keys){const Z=V[I],E=de(I),ht=h[I]?._zod?.optout==="optional";m.write(`const ${Z} = ${w(I)};`),ht?m.write(`
|
|
4
|
-
if (${Z}.issues.length) {
|
|
5
|
-
if (${E} in input) {
|
|
6
|
-
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
7
|
-
...iss,
|
|
8
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
9
|
-
})));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (${Z}.value === undefined) {
|
|
14
|
-
if (${E} in input) {
|
|
15
|
-
newResult[${E}] = undefined;
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
newResult[${E}] = ${Z}.value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
`):m.write(`
|
|
22
|
-
if (${Z}.issues.length) {
|
|
23
|
-
payload.issues = payload.issues.concat(${Z}.issues.map(iss => ({
|
|
24
|
-
...iss,
|
|
25
|
-
path: iss.path ? [${E}, ...iss.path] : [${E}]
|
|
26
|
-
})));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (${Z}.value === undefined) {
|
|
30
|
-
if (${E} in input) {
|
|
31
|
-
newResult[${E}] = undefined;
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
newResult[${E}] = ${Z}.value;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const dt=m.compile();return(I,Z)=>dt(h,I,Z)};let s;const i=M,c=!Re.jitless,l=c&>.value,f=t.catchall;let p;e._zod.parse=(h,m)=>{p??(p=r.value);const k=h.value;return i(k)?c&&l&&m?.async===!1&&m.jitless!==!0?(s||(s=o(t.shape)),h=s(h,m),f?He([],k,h,m,p,e):h):n(h,m):(h.issues.push({expected:"object",code:"invalid_type",input:k,inst:e}),h)}});function _e(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!R(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>T(i,r,P())))}),t)}const Qe=a("$ZodUnion",(e,t)=>{z.init(e,t),_(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),_(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),_(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>ce(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const c=[];for(const u of t.options){const l=u._zod.run({value:o.value,issues:[]},s);if(l instanceof Promise)c.push(l),i=!0;else{if(l.issues.length===0)return l;c.push(l)}}return i?Promise.all(c).then(u=>_e(u,o,e,s)):_e(c,o,e,s)}}),nr=a("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qe.init(e,t);const n=e._zod.parse;_(e._zod,"propValues",()=>{const o={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[c,u]of Object.entries(i)){o[c]||(o[c]=new Set);for(const l of u)o[c].add(l)}}return o});const r=X(()=>{const o=t.options,s=new Map;for(const i of o){const c=i._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const u of c){if(s.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);s.set(u,i)}}return s});e._zod.parse=(o,s)=>{const i=o.value;if(!M(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const c=r.value.get(i?.[t.discriminator]);return c?c._zod.run(o,s):t.unionFallback?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),o)}}),rr=a("$ZodIntersection",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([u,l])=>ge(n,u,l)):ge(n,s,i)}});function oe(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(U(e)&&U(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=oe(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=oe(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ge(e,t,n){const r=new Map;let o;for(const c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(const u of c.keys)r.has(u)||r.set(u,{}),r.get(u).l=!0}else e.issues.push(c);for(const c of n.issues)if(c.code==="unrecognized_keys")for(const u of c.keys)r.has(u)||r.set(u,{}),r.get(u).r=!0;else e.issues.push(c);const s=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&o&&e.issues.push({...o,keys:s}),R(e))return e;const i=oe(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const or=a("$ZodRecord",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!U(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const c=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){c.add(typeof l=="number"?l.toString():l);const f=t.valueType._zod.run({value:o[l],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&n.issues.push(...C(l,p.issues)),n.value[l]=p.value})):(f.issues.length&&n.issues.push(...C(l,f.issues)),n.value[l]=f.value)}let u;for(const l in o)c.has(l)||(u=u??[],u.push(l));u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u})}else{n.value={};for(const c of Reflect.ownKeys(o)){if(c==="__proto__")continue;let u=t.keyType._zod.run({value:c,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&We.test(c)&&u.issues.length){const p=t.keyType._zod.run({value:Number(c),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){t.mode==="loose"?n.value[c]=o[c]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>T(p,r,P())),input:c,path:[c],inst:e});continue}const f=t.valueType._zod.run({value:o[c],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&n.issues.push(...C(c,p.issues)),n.value[u.value]=p.value})):(f.issues.length&&n.issues.push(...C(c,f.issues)),n.value[u.value]=f.value)}}return s.length?Promise.all(s).then(()=>n):n}}),ir=a("$ZodEnum",(e,t)=>{z.init(e,t);const n=Ce(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>vt.has(typeof o)).map(o=>typeof o=="string"?F(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),sr=a("$ZodLiteral",(e,t)=>{if(z.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?F(r):r?F(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),cr=a("$ZodTransform",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ae(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new D;return n.value=o,n}});function ve(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const et=a("$ZodOptional",(e,t)=>{z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ce(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>ve(s,n.value)):ve(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),ur=a("$ZodExactOptional",(e,t)=>{et.init(e,t),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ar=a("$ZodNullable",(e,t)=>{z.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ce(n.source)}|null)$`):void 0}),_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),lr=a("$ZodDefault",(e,t)=>{z.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>ze(s,t)):ze(o,t)}});function ze(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const fr=a("$ZodPrefault",(e,t)=>{z.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),pr=a("$ZodNonOptional",(e,t)=>{z.init(e,t),_(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>ye(s,e)):ye(o,e)}});function ye(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const dr=a("$ZodCatch",(e,t)=>{z.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>T(i,r,P()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>T(s,r,P()))},input:n.value}),n.issues=[]),n)}}),hr=a("$ZodPipe",(e,t)=>{z.init(e,t),_(e._zod,"values",()=>t.in._zod.values),_(e._zod,"optin",()=>t.in._zod.optin),_(e._zod,"optout",()=>t.out._zod.optout),_(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>K(i,t.in,r)):K(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>K(s,t.out,r)):K(o,t.out,r)}});function K(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const mr=a("$ZodReadonly",(e,t)=>{z.init(e,t),_(e._zod,"propValues",()=>t.innerType._zod.propValues),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"optin",()=>t.innerType?._zod?.optin),_(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(be):be(o)}});function be(e){return e.value=Object.freeze(e.value),e}const _r=a("$ZodCustom",(e,t)=>{O.init(e,t),z.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>we(s,n,r,e));we(o,n,r,e)}});function we(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(L(o))}}var ke;class gr{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function vr(){return new gr}(ke=globalThis).__zod_globalRegistry??(ke.__zod_globalRegistry=vr());const J=globalThis.__zod_globalRegistry;function zr(e,t){return new e({type:"string",...d(t)})}function yr(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...d(t)})}function $e(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...d(t)})}function br(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...d(t)})}function wr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...d(t)})}function kr(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...d(t)})}function $r(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...d(t)})}function Zr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...d(t)})}function Or(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...d(t)})}function Sr(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...d(t)})}function Er(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...d(t)})}function Ir(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...d(t)})}function Pr(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...d(t)})}function Tr(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...d(t)})}function Nr(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...d(t)})}function jr(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...d(t)})}function Ar(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...d(t)})}function Rr(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...d(t)})}function Cr(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...d(t)})}function Dr(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...d(t)})}function Ur(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...d(t)})}function Fr(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...d(t)})}function xr(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...d(t)})}function Jr(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...d(t)})}function Mr(e,t){return new e({type:"string",format:"date",check:"string_format",...d(t)})}function Lr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...d(t)})}function Vr(e,t){return new e({type:"string",format:"duration",check:"string_format",...d(t)})}function Wr(e,t){return new e({type:"number",checks:[],...d(t)})}function Kr(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...d(t)})}function Br(e){return new e({type:"unknown"})}function Gr(e,t){return new e({type:"never",...d(t)})}function Ze(e,t){return new Be({check:"less_than",...d(t),value:e,inclusive:!1})}function te(e,t){return new Be({check:"less_than",...d(t),value:e,inclusive:!0})}function Oe(e,t){return new Ge({check:"greater_than",...d(t),value:e,inclusive:!1})}function ne(e,t){return new Ge({check:"greater_than",...d(t),value:e,inclusive:!0})}function Se(e,t){return new fn({check:"multiple_of",...d(t),value:e})}function tt(e,t){return new dn({check:"max_length",...d(t),maximum:e})}function Y(e,t){return new hn({check:"min_length",...d(t),minimum:e})}function nt(e,t){return new mn({check:"length_equals",...d(t),length:e})}function Yr(e,t){return new _n({check:"string_format",format:"regex",...d(t),pattern:e})}function qr(e){return new gn({check:"string_format",format:"lowercase",...d(e)})}function Xr(e){return new vn({check:"string_format",format:"uppercase",...d(e)})}function Hr(e,t){return new zn({check:"string_format",format:"includes",...d(t),includes:e})}function Qr(e,t){return new yn({check:"string_format",format:"starts_with",...d(t),prefix:e})}function eo(e,t){return new bn({check:"string_format",format:"ends_with",...d(t),suffix:e})}function x(e){return new wn({check:"overwrite",tx:e})}function to(e){return x(t=>t.normalize(e))}function no(){return x(e=>e.trim())}function ro(){return x(e=>e.toLowerCase())}function oo(){return x(e=>e.toUpperCase())}function io(){return x(e=>_t(e))}function so(e,t,n){return new e({type:"array",element:t,...d(n)})}function co(e,t,n){return new e({type:"custom",check:"custom",fn:t,...d(n)})}function uo(e){const t=ao(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(L(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(L(o))}},e(n.value,n)));return t}function ao(e,t){const n=new O({check:"custom",...d(t)});return n._zod.check=e,n}function rt(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??J,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function b(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,f);else{const h=i.schema,m=t.processors[o.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,h,f)}const p=e._zod.parent;p&&(i.ref||(i.ref=p),b(p,t,f),t.seen.get(p).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(i.schema,u),t.io==="input"&&$(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&i.schema._prefault&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function ot(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const c=e.metadataRegistry.get(i[0])?.id;if(c){const u=r.get(c);if(u&&u!==i[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(c,i[0])}}const o=i=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(i[0])?.id,h=e.external.uri??(k=>k);if(p)return{ref:h(p)};const m=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=m,{defId:m,ref:`${h("__shared")}#/${c}/${m}`}}if(i[1]===n)return{ref:"#"};const l=`#/${c}/`,f=i[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:l+f}},s=i=>{if(i[1].schema.$ref)return;const c=i[1],{ref:u,defId:l}=o(i);c.def={...c.schema},l&&(c.defId=l);const f=c.schema;for(const p in f)delete f[p];f.$ref=u};if(e.cycles==="throw")for(const i of e.seen.entries()){const c=i[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
38
|
-
|
|
39
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const c=i[1];if(t===i[0]){s(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1&&e.reused==="ref"){s(i);continue}}}function it(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=i=>{const c=e.seen.get(i);if(c.ref===null)return;const u=c.def??c.schema,l={...u},f=c.ref;if(c.ref=null,f){r(f);const h=e.seen.get(f),m=h.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),i._zod.parent===f)for(const w in u)w==="$ref"||w==="allOf"||w in l||delete u[w];if(m.$ref&&h.def)for(const w in u)w==="$ref"||w==="allOf"||w in h.def&&JSON.stringify(u[w])===JSON.stringify(h.def[w])&&delete u[w]}const p=i._zod.parent;if(p&&p!==f){r(p);const h=e.seen.get(p);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(const m in u)m==="$ref"||m==="allOf"||m in h.def&&JSON.stringify(u[m])===JSON.stringify(h.def[m])&&delete u[m]}e.override({zodSchema:i,jsonSchema:u,path:c.path??[]})};for(const i of[...e.seen.entries()].reverse())r(i[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const i=e.external.registry.get(t)?.id;if(!i)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(i)}Object.assign(o,n.def??n.schema);const s=e.external?.defs??{};for(const i of e.seen.entries()){const c=i[1];c.def&&c.defId&&(s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const i=JSON.parse(JSON.stringify(o));return Object.defineProperty(i,"~standard",{value:{...t["~standard"],jsonSchema:{input:q(t,"input",e.processors),output:q(t,"output",e.processors)}},enumerable:!1,writable:!1}),i}catch{throw new Error("Error converting schema to JSON.")}}function $(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return $(r.element,n);if(r.type==="set")return $(r.valueType,n);if(r.type==="lazy")return $(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return $(r.innerType,n);if(r.type==="intersection")return $(r.left,n)||$(r.right,n);if(r.type==="record"||r.type==="map")return $(r.keyType,n)||$(r.valueType,n);if(r.type==="pipe")return $(r.in,n)||$(r.out,n);if(r.type==="object"){for(const o in r.shape)if($(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if($(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if($(o,n))return!0;return!!(r.rest&&$(r.rest,n))}return!1}const lo=(e,t={})=>n=>{const r=rt({...n,processors:t});return b(e,r),ot(r,e),it(r,e)},q=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},i=rt({...o??{},target:s,io:t,processors:n});return b(e,i),ot(i,e),it(i,e)},fo={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},po=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:i,format:c,patterns:u,contentEncoding:l}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),c&&(o.format=fo[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),l&&(o.contentEncoding=l),u&&u.size>0){const f=[...u];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},ho=(e,t,n,r)=>{const o=n,{minimum:s,maximum:i,format:c,multipleOf:u,exclusiveMaximum:l,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number",typeof f=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f),typeof s=="number"&&(o.minimum=s,typeof f=="number"&&t.target!=="draft-04"&&(f>=s?delete o.minimum:delete o.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(o.maximum=l,o.exclusiveMaximum=!0):o.exclusiveMaximum=l),typeof i=="number"&&(o.maximum=i,typeof l=="number"&&t.target!=="draft-04"&&(l<=i?delete o.maximum:delete o.exclusiveMaximum)),typeof u=="number"&&(o.multipleOf=u)},mo=(e,t,n,r)=>{n.not={}},_o=(e,t,n,r)=>{},go=(e,t,n,r)=>{const o=e._zod.def,s=Ce(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},vo=(e,t,n,r)=>{const o=e._zod.def,s=[];for(const i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},zo=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},yo=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},bo=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=b(s.element,t,{...r,path:[...r.path,"items"]})},wo=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const l in i)o.properties[l]=b(i[l],t,{...r,path:[...r.path,"properties",l]});const c=new Set(Object.keys(i)),u=new Set([...c].filter(l=>{const f=s.shape[l]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));u.size>0&&(o.required=Array.from(u)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=b(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ko=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,u)=>b(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",u]}));s?n.oneOf=i:n.anyOf=i},$o=(e,t,n,r)=>{const o=e._zod.def,s=b(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=b(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=l=>"allOf"in l&&Object.keys(l).length===1,u=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];n.allOf=u},Zo=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object";const i=s.keyType,u=i._zod.bag?.patterns;if(s.mode==="loose"&&u&&u.size>0){const f=b(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const p of u)o.patternProperties[p.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=b(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=b(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const l=i._zod.values;if(l){const f=[...l].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(o.required=f)}},Oo=(e,t,n,r)=>{const o=e._zod.def,s=b(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},So=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Eo=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Io=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Po=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},To=(e,t,n,r)=>{const o=e._zod.def,s=t.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;b(s,t,r);const i=t.seen.get(e);i.ref=s},No=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},st=(e,t,n,r)=>{const o=e._zod.def;b(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},jo=a("ZodISODateTime",(e,t)=>{Cn.init(e,t),v.init(e,t)});function Ao(e){return Jr(jo,e)}const Ro=a("ZodISODate",(e,t)=>{Dn.init(e,t),v.init(e,t)});function Co(e){return Mr(Ro,e)}const Do=a("ZodISOTime",(e,t)=>{Un.init(e,t),v.init(e,t)});function Uo(e){return Lr(Do,e)}const Fo=a("ZodISODuration",(e,t)=>{Fn.init(e,t),v.init(e,t)});function xo(e){return Vr(Fo,e)}const Jo=(e,t)=>{xe.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>It(e,n)},flatten:{value:n=>Et(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,re,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,re,2)}},isEmpty:{get(){return e.issues.length===0}}})},S=a("ZodError",Jo,{Parent:Error}),Mo=ae(S),Lo=le(S),Vo=H(S),Wo=Q(S),Ko=Nt(S),Bo=jt(S),Go=At(S),Yo=Rt(S),qo=Ct(S),Xo=Dt(S),Ho=Ut(S),Qo=Ft(S),y=a("ZodType",(e,t)=>(z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:q(e,"input"),output:q(e,"output")}}),e.toJSONSchema=lo(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(N(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0}),e.with=e.check,e.clone=(n,r)=>j(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Mo(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Vo(e,n,r),e.parseAsync=async(n,r)=>Lo(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Wo(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Ko(e,n,r),e.decode=(n,r)=>Bo(e,n,r),e.encodeAsync=async(n,r)=>Go(e,n,r),e.decodeAsync=async(n,r)=>Yo(e,n,r),e.safeEncode=(n,r)=>qo(e,n,r),e.safeDecode=(n,r)=>Xo(e,n,r),e.safeEncodeAsync=async(n,r)=>Ho(e,n,r),e.safeDecodeAsync=async(n,r)=>Qo(e,n,r),e.refine=(n,r)=>e.check(Gi(n,r)),e.superRefine=n=>e.check(Yi(n)),e.overwrite=n=>e.check(x(n)),e.optional=()=>Te(e),e.exactOptional=()=>Ri(e),e.nullable=()=>Ne(e),e.nullish=()=>Te(Ne(e)),e.nonoptional=n=>Ji(e,n),e.array=()=>ki(e),e.or=n=>Zi([e,n]),e.and=n=>Ei(e,n),e.transform=n=>je(e,ji(n)),e.default=n=>Ui(e,n),e.prefault=n=>xi(e,n),e.catch=n=>Li(e,n),e.pipe=n=>je(e,n),e.readonly=()=>Ki(e),e.describe=n=>{const r=e.clone();return J.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return J.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return J.get(e);const r=e.clone();return J.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),ct=a("_ZodString",(e,t)=>{fe.init(e,t),y.init(e,t),e._zod.processJSONSchema=(r,o,s)=>po(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(Yr(...r)),e.includes=(...r)=>e.check(Hr(...r)),e.startsWith=(...r)=>e.check(Qr(...r)),e.endsWith=(...r)=>e.check(eo(...r)),e.min=(...r)=>e.check(Y(...r)),e.max=(...r)=>e.check(tt(...r)),e.length=(...r)=>e.check(nt(...r)),e.nonempty=(...r)=>e.check(Y(1,...r)),e.lowercase=r=>e.check(qr(r)),e.uppercase=r=>e.check(Xr(r)),e.trim=()=>e.check(no()),e.normalize=(...r)=>e.check(to(...r)),e.toLowerCase=()=>e.check(ro()),e.toUpperCase=()=>e.check(oo()),e.slugify=()=>e.check(io())}),ei=a("ZodString",(e,t)=>{fe.init(e,t),ct.init(e,t),e.email=n=>e.check(yr(ti,n)),e.url=n=>e.check(Zr(ni,n)),e.jwt=n=>e.check(xr(gi,n)),e.emoji=n=>e.check(Or(ri,n)),e.guid=n=>e.check($e(Ee,n)),e.uuid=n=>e.check(br(B,n)),e.uuidv4=n=>e.check(wr(B,n)),e.uuidv6=n=>e.check(kr(B,n)),e.uuidv7=n=>e.check($r(B,n)),e.nanoid=n=>e.check(Sr(oi,n)),e.guid=n=>e.check($e(Ee,n)),e.cuid=n=>e.check(Er(ii,n)),e.cuid2=n=>e.check(Ir(si,n)),e.ulid=n=>e.check(Pr(ci,n)),e.base64=n=>e.check(Dr(hi,n)),e.base64url=n=>e.check(Ur(mi,n)),e.xid=n=>e.check(Tr(ui,n)),e.ksuid=n=>e.check(Nr(ai,n)),e.ipv4=n=>e.check(jr(li,n)),e.ipv6=n=>e.check(Ar(fi,n)),e.cidrv4=n=>e.check(Rr(pi,n)),e.cidrv6=n=>e.check(Cr(di,n)),e.e164=n=>e.check(Fr(_i,n)),e.datetime=n=>e.check(Ao(n)),e.date=n=>e.check(Co(n)),e.time=n=>e.check(Uo(n)),e.duration=n=>e.check(xo(n))});function Xi(e){return zr(ei,e)}const v=a("ZodStringFormat",(e,t)=>{g.init(e,t),ct.init(e,t)}),ti=a("ZodEmail",(e,t)=>{Sn.init(e,t),v.init(e,t)}),Ee=a("ZodGUID",(e,t)=>{Zn.init(e,t),v.init(e,t)}),B=a("ZodUUID",(e,t)=>{On.init(e,t),v.init(e,t)}),ni=a("ZodURL",(e,t)=>{En.init(e,t),v.init(e,t)}),ri=a("ZodEmoji",(e,t)=>{In.init(e,t),v.init(e,t)}),oi=a("ZodNanoID",(e,t)=>{Pn.init(e,t),v.init(e,t)}),ii=a("ZodCUID",(e,t)=>{Tn.init(e,t),v.init(e,t)}),si=a("ZodCUID2",(e,t)=>{Nn.init(e,t),v.init(e,t)}),ci=a("ZodULID",(e,t)=>{jn.init(e,t),v.init(e,t)}),ui=a("ZodXID",(e,t)=>{An.init(e,t),v.init(e,t)}),ai=a("ZodKSUID",(e,t)=>{Rn.init(e,t),v.init(e,t)}),li=a("ZodIPv4",(e,t)=>{xn.init(e,t),v.init(e,t)}),fi=a("ZodIPv6",(e,t)=>{Jn.init(e,t),v.init(e,t)}),pi=a("ZodCIDRv4",(e,t)=>{Mn.init(e,t),v.init(e,t)}),di=a("ZodCIDRv6",(e,t)=>{Ln.init(e,t),v.init(e,t)}),hi=a("ZodBase64",(e,t)=>{Vn.init(e,t),v.init(e,t)}),mi=a("ZodBase64URL",(e,t)=>{Kn.init(e,t),v.init(e,t)}),_i=a("ZodE164",(e,t)=>{Bn.init(e,t),v.init(e,t)}),gi=a("ZodJWT",(e,t)=>{Yn.init(e,t),v.init(e,t)}),ut=a("ZodNumber",(e,t)=>{qe.init(e,t),y.init(e,t),e._zod.processJSONSchema=(r,o,s)=>ho(e,r,o),e.gt=(r,o)=>e.check(Oe(r,o)),e.gte=(r,o)=>e.check(ne(r,o)),e.min=(r,o)=>e.check(ne(r,o)),e.lt=(r,o)=>e.check(Ze(r,o)),e.lte=(r,o)=>e.check(te(r,o)),e.max=(r,o)=>e.check(te(r,o)),e.int=r=>e.check(Ie(r)),e.safe=r=>e.check(Ie(r)),e.positive=r=>e.check(Oe(0,r)),e.nonnegative=r=>e.check(ne(0,r)),e.negative=r=>e.check(Ze(0,r)),e.nonpositive=r=>e.check(te(0,r)),e.multipleOf=(r,o)=>e.check(Se(r,o)),e.step=(r,o)=>e.check(Se(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Hi(e){return Wr(ut,e)}const vi=a("ZodNumberFormat",(e,t)=>{qn.init(e,t),ut.init(e,t)});function Ie(e){return Kr(vi,e)}const zi=a("ZodUnknown",(e,t)=>{Xn.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_o()});function Pe(){return Br(zi)}const yi=a("ZodNever",(e,t)=>{Hn.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mo(e,n,r)});function bi(e){return Gr(yi,e)}const wi=a("ZodArray",(e,t)=>{Qn.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bo(e,n,r,o),e.element=t.element,e.min=(n,r)=>e.check(Y(n,r)),e.nonempty=n=>e.check(Y(1,n)),e.max=(n,r)=>e.check(tt(n,r)),e.length=(n,r)=>e.check(nt(n,r)),e.unwrap=()=>e.element});function ki(e,t){return so(wi,e,t)}const $i=a("ZodObject",(e,t)=>{tr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wo(e,n,r,o),_(e,"shape",()=>t.shape),e.keyof=()=>Pi(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Pe()}),e.loose=()=>e.clone({...e._zod.def,catchall:Pe()}),e.strict=()=>e.clone({...e._zod.def,catchall:bi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>kt(e,n),e.safeExtend=n=>$t(e,n),e.merge=n=>Zt(e,n),e.pick=n=>bt(e,n),e.omit=n=>wt(e,n),e.partial=(...n)=>Ot(lt,e,n[0]),e.required=(...n)=>St(ft,e,n[0])});function Qi(e,t){const n={type:"object",shape:e??{},...d(t)};return new $i(n)}const at=a("ZodUnion",(e,t)=>{Qe.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ko(e,n,r,o),e.options=t.options});function Zi(e,t){return new at({type:"union",options:e,...d(t)})}const Oi=a("ZodDiscriminatedUnion",(e,t)=>{at.init(e,t),nr.init(e,t)});function es(e,t,n){return new Oi({type:"union",options:t,discriminator:e,...d(n)})}const Si=a("ZodIntersection",(e,t)=>{rr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$o(e,n,r,o)});function Ei(e,t){return new Si({type:"intersection",left:e,right:t})}const Ii=a("ZodRecord",(e,t)=>{or.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zo(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function ts(e,t,n){return new Ii({type:"record",keyType:e,valueType:t,...d(n)})}const ie=a("ZodEnum",(e,t)=>{ir.init(e,t),y.init(e,t),e._zod.processJSONSchema=(r,o,s)=>go(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ie({...t,checks:[],...d(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ie({...t,checks:[],...d(o),entries:s})}});function Pi(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ie({type:"enum",entries:n,...d(t)})}const Ti=a("ZodLiteral",(e,t)=>{sr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vo(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ns(e,t){return new Ti({type:"literal",values:Array.isArray(e)?e:[e],...d(t)})}const Ni=a("ZodTransform",(e,t)=>{cr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yo(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ae(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(L(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(L(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function ji(e){return new Ni({type:"transform",transform:e})}const lt=a("ZodOptional",(e,t)=>{et.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>st(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Te(e){return new lt({type:"optional",innerType:e})}const Ai=a("ZodExactOptional",(e,t)=>{ur.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>st(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ri(e){return new Ai({type:"optional",innerType:e})}const Ci=a("ZodNullable",(e,t)=>{ar.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Oo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ne(e){return new Ci({type:"nullable",innerType:e})}const Di=a("ZodDefault",(e,t)=>{lr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Eo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ui(e,t){return new Di({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Ue(t)}})}const Fi=a("ZodPrefault",(e,t)=>{fr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Io(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xi(e,t){return new Fi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Ue(t)}})}const ft=a("ZodNonOptional",(e,t)=>{pr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>So(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ji(e,t){return new ft({type:"nonoptional",innerType:e,...d(t)})}const Mi=a("ZodCatch",(e,t)=>{dr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Po(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Li(e,t){return new Mi({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Vi=a("ZodPipe",(e,t)=>{hr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>To(e,n,r,o),e.in=t.in,e.out=t.out});function je(e,t){return new Vi({type:"pipe",in:e,out:t})}const Wi=a("ZodReadonly",(e,t)=>{mr.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>No(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ki(e){return new Wi({type:"readonly",innerType:e})}const Bi=a("ZodCustom",(e,t)=>{_r.init(e,t),y.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zo(e,n)});function Gi(e,t={}){return co(Bi,e,t)}function Yi(e){return uo(e)}export{Pi as _,ki as a,es as d,ns as l,Hi as n,Qi as o,ts as r,Xi as s,Pe as u};
|
package/server/index.d.ts.bak
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { Express } from "express";
|
|
2
|
-
import type { Server } from "http";
|
|
3
|
-
|
|
4
|
-
export interface WebUiServerController {
|
|
5
|
-
expressApp: Express;
|
|
6
|
-
httpServer: Server;
|
|
7
|
-
getPort: () => number | null;
|
|
8
|
-
getOpenCodePort: () => number | null;
|
|
9
|
-
isReady: () => boolean;
|
|
10
|
-
restartOpenCode: () => Promise<void>;
|
|
11
|
-
stop: (options?: { exitProcess?: boolean }) => Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface StartWebUiServerOptions {
|
|
15
|
-
port?: number;
|
|
16
|
-
host?: string;
|
|
17
|
-
attachSignals?: boolean;
|
|
18
|
-
exitOnShutdown?: boolean;
|
|
19
|
-
uiPassword?: string | null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export declare function startWebUiServer(
|
|
23
|
-
options?: StartWebUiServerOptions
|
|
24
|
-
): Promise<WebUiServerController>;
|
|
25
|
-
|
|
26
|
-
export declare function gracefulShutdown(options?: { exitProcess?: boolean }): Promise<void>;
|
|
27
|
-
export declare function setupProxy(app: Express): void;
|
|
28
|
-
export declare function restartOpenCode(): Promise<void>;
|
|
29
|
-
export declare function parseArgs(argv?: string[]): {
|
|
30
|
-
port: number;
|
|
31
|
-
host?: string;
|
|
32
|
-
uiPassword: string | null;
|
|
33
|
-
tryCfTunnel: boolean;
|
|
34
|
-
tunnelProvider?: string;
|
|
35
|
-
tunnelMode?: string;
|
|
36
|
-
tunnelConfigPath?: string | null;
|
|
37
|
-
tunnelToken?: string;
|
|
38
|
-
tunnelHostname?: string;
|
|
39
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
# Managed AiWorker Agent Tool
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
|
|
5
|
-
This module exposes AiWorker to agents as typed OpenCode custom tools. There
|
|
6
|
-
are two, because controlling sessions and driving a page are separate intents
|
|
7
|
-
the user can want independently:
|
|
8
|
-
|
|
9
|
-
- `aiworker` — projects, sessions, worktrees, and scheduled tasks. Enabled
|
|
10
|
-
while the persisted `agentControlToolEnabled` setting is not `false`.
|
|
11
|
-
- `aiworker_web` — looking at and interacting with the page in AiWorker's
|
|
12
|
-
browser panel. Enabled while `agentWebToolEnabled` is not `false`.
|
|
13
|
-
|
|
14
|
-
Both default to on, are toggled in Settings → General → OpenCode CLI, and apply
|
|
15
|
-
on the next managed OpenCode restart. Each tool carries only its own actions and
|
|
16
|
-
only the parameters those actions use, so turning one off removes its inputs
|
|
17
|
-
from the schema rather than leaving them visible. The plugin is injected only
|
|
18
|
-
when AiWorker launches and owns the OpenCode process, and not at all when
|
|
19
|
-
both settings are `false`.
|
|
20
|
-
|
|
21
|
-
- The plugin accepts the action's inputs either inside `parameters` or beside
|
|
22
|
-
`action`, because models produce both shapes; an explicit `parameters` object
|
|
23
|
-
wins on a conflict. Rejecting the flattened shape turned a call that plainly
|
|
24
|
-
carried a `url` into "url is required", which reads as a broken tool rather
|
|
25
|
-
than a malformed call.
|
|
26
|
-
|
|
27
|
-
## Runtime flow
|
|
28
|
-
|
|
29
|
-
1. The AiWorker HTTP listener binds and publishes its authoritative port.
|
|
30
|
-
2. `prepareManagedOpenCodeEnv()` materializes the plugin under
|
|
31
|
-
`<openchamber-data-dir>/agent-tool/` and appends its `file://` URL to
|
|
32
|
-
`OPENCODE_CONFIG_CONTENT` without replacing existing plugin entries.
|
|
33
|
-
3. A random per-child token and loopback callback URL are added only to the
|
|
34
|
-
managed OpenCode child environment.
|
|
35
|
-
4. The plugin calls `POST /api/openchamber/agent-tool` with its typed input and
|
|
36
|
-
OpenCode's authoritative session directory.
|
|
37
|
-
5. The route delegates the fixed action allowlist directly to the shared
|
|
38
|
-
AiWorker control service. The CLI uses the same service through its
|
|
39
|
-
authenticated HTTP adapter, so Goal Mode ordering, wait behavior,
|
|
40
|
-
partial-failure reporting, and scheduled-task contracts have one owner.
|
|
41
|
-
6. Each action definition owns a short presentation title and a separate
|
|
42
|
-
agent-facing description. The generated schema uses the description to state
|
|
43
|
-
required inputs or one non-obvious behavior, while completed calls use the
|
|
44
|
-
short title in native tool metadata.
|
|
45
|
-
|
|
46
|
-
## Agent context budget
|
|
47
|
-
|
|
48
|
-
- The tool exposes one shared parameter object rather than repeating parameters
|
|
49
|
-
in a large per-action union. Action descriptions carry only required inputs,
|
|
50
|
-
defaults, or one non-obvious semantic detail.
|
|
51
|
-
- Obvious fields rely on their names and JSON types. Parameter descriptions are
|
|
52
|
-
reserved for formats, dependencies, scope, and behavior that cannot be safely
|
|
53
|
-
inferred from the field name.
|
|
54
|
-
- Session dispatches do not wait by default. Agents are told to set `wait` only
|
|
55
|
-
when the user asks or the next step requires the completed result.
|
|
56
|
-
- The tool exposes only agent-relevant actions
|
|
57
|
-
(`AIWORKER_AGENT_TOOL_ACTIONS`): `schedule.status` stays CLI-only because
|
|
58
|
-
`schedule.list` already returns scheduler status, and enable/disable are one
|
|
59
|
-
`schedule.toggle` action driven by the `disabled` boolean.
|
|
60
|
-
- The tool description frames intent: created sessions and scheduled tasks are
|
|
61
|
-
user-facing work the user follows up with, never a channel for the agent to
|
|
62
|
-
delegate parts of its own current task.
|
|
63
|
-
- Optional behavior switches (`worktree`, `goal`, `agent`, `variant`, `wait`)
|
|
64
|
-
state their default and an explicit "only when the user asks" rule so agents
|
|
65
|
-
do not invent worktrees, goal mode, or waits the user never requested.
|
|
66
|
-
- Detailed combination rules are enforced by the shared control service and
|
|
67
|
-
returned as actionable usage errors only after an invalid call. Per-action
|
|
68
|
-
examples and a repeated per-action parameter schema are intentionally omitted.
|
|
69
|
-
|
|
70
|
-
## Security invariants
|
|
71
|
-
|
|
72
|
-
- The callback accepts loopback requests only and requires the current
|
|
73
|
-
per-child bearer token using a timing-safe comparison.
|
|
74
|
-
- The token is never persisted, logged, returned to the UI, or written into
|
|
75
|
-
the materialized plugin.
|
|
76
|
-
- Inputs map to a fixed action and parameter allowlist. There is no arbitrary
|
|
77
|
-
CLI, shell, route, or URL forwarding.
|
|
78
|
-
- Session/worktree deletion and project-path registration are not exposed.
|
|
79
|
-
- An aborted tool request propagates an abort signal into the shared service.
|
|
80
|
-
|
|
81
|
-
## Result contract
|
|
82
|
-
|
|
83
|
-
Every completed call returns JSON:
|
|
84
|
-
|
|
85
|
-
```json
|
|
86
|
-
{
|
|
87
|
-
"schemaVersion": 1,
|
|
88
|
-
"ok": true,
|
|
89
|
-
"action": "session.create",
|
|
90
|
-
"data": {}
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
Command and operational failures use the same envelope with `ok: false` and
|
|
95
|
-
an `error` object. OpenCode-level cancellation can still produce a native tool
|
|
96
|
-
error state.
|
|
97
|
-
|
|
98
|
-
## Runtime parity
|
|
99
|
-
|
|
100
|
-
- Web and Desktop managed OpenCode: injected automatically.
|
|
101
|
-
- External OpenCode selected with `OPENCODE_HOST` or skip-start: not injected,
|
|
102
|
-
because AiWorker does not control that process environment.
|
|
103
|
-
- VS Code: not injected; the extension owns a separate OpenCode lifecycle.
|
|
104
|
-
- Hosted and Capacitor mobile clients use the server's managed OpenCode tool
|
|
105
|
-
when connected to such a server; no tool runs in the client runtime.
|
|
106
|
-
|
|
107
|
-
## The calling tool is part of the request
|
|
108
|
-
|
|
109
|
-
Each generated tool sends its own name with every callback. Models routinely
|
|
110
|
-
drop the namespace their tool's name appears to supply — `aiworker_memory`
|
|
111
|
-
asked for `memory.read` gets called as `read` — and resolving the bare name
|
|
112
|
-
inside the calling tool's action set makes that unambiguous even where it is not
|
|
113
|
-
globally (`delete` belongs to both schedule and memory).
|
|
114
|
-
|
|
115
|
-
Resolution never reaches outside the tool that asked: `open` from the memory
|
|
116
|
-
tool fails rather than driving the browser. An unresolvable action answers with
|
|
117
|
-
the actions that tool actually has, because an error that only says
|
|
118
|
-
"unsupported" leaves the model to guess a second wrong name — which is exactly
|
|
119
|
-
what happened before this existed.
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Browser Control Broker
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
|
|
5
|
-
This module carries agent browser actions from the server to the client that
|
|
6
|
-
owns the in-app browser view, and the result back. The browser lives in a
|
|
7
|
-
renderer, not in the server process, so the server can never act on a page
|
|
8
|
-
itself; it can only ask and wait.
|
|
9
|
-
|
|
10
|
-
## Boundaries
|
|
11
|
-
|
|
12
|
-
- `broker.js` owns request lifetime: it publishes one action through the
|
|
13
|
-
injected `emitRequest`, holds the pending request, and settles it on a client
|
|
14
|
-
result, a timeout, or an abort signal. It knows nothing about transports.
|
|
15
|
-
- `routes.js` is the result callback (`POST /api/browser-control/result`). It
|
|
16
|
-
validates the envelope and hands the outcome to the broker.
|
|
17
|
-
- `../../index.js` supplies `emitRequest`, which writes the request to the
|
|
18
|
-
AiWorker SSE clients and returns how many were reached.
|
|
19
|
-
- `../openchamber-control/service.js` is the only caller. It maps the
|
|
20
|
-
`browser.*` actions of the `aiworker_web` tool onto `broker.request()` and
|
|
21
|
-
owns their parameter validation.
|
|
22
|
-
- The client half is `packages/ui/src/lib/browser/controlClient.ts`, which
|
|
23
|
-
registers the mounted browser pane as the one responder.
|
|
24
|
-
|
|
25
|
-
## Invariants
|
|
26
|
-
|
|
27
|
-
- Capability belongs to the connection, not to configuration. A client declares
|
|
28
|
-
it can drive a page by opening its event stream with `browser=1`, which only
|
|
29
|
-
a Chromium host does; the flag lives and dies with that connection, so there
|
|
30
|
-
is no setting to enable and no restart to remember.
|
|
31
|
-
- `emitRequest` counts only clients that can serve the action. `browser.open`
|
|
32
|
-
needs any client, because opening a tab is what creates a view; every other
|
|
33
|
-
action needs a declared-capable one.
|
|
34
|
-
- Exactly one client performs a request. The broadcast reaches everyone who
|
|
35
|
-
could serve it, so a client claims the request over
|
|
36
|
-
`POST /api/browser-control/claim` and acts only if granted; the first claim
|
|
37
|
-
wins and every other client does nothing. Deciding by whose result arrives
|
|
38
|
-
first would be too late, because by then each of them has already clicked.
|
|
39
|
-
A claim for a settled request is refused for the same reason.
|
|
40
|
-
- Nobody listening is answered immediately with a 503 describing the
|
|
41
|
-
environment, never by blocking for the full timeout. A blocked wait followed
|
|
42
|
-
by a timeout cannot be told apart from a page that hung.
|
|
43
|
-
- A client that accepted a request and then disappeared still times out.
|
|
44
|
-
Assuming success would report a page interaction that never happened.
|
|
45
|
-
- A result for an unknown request id is accepted with `matched: false`, not an
|
|
46
|
-
error: a client answering after the timeout has behaved correctly.
|
|
47
|
-
- The result route parses its own body. This server has no global body parser,
|
|
48
|
-
and a missing one silently turns every answer into an agent-visible timeout.
|
|
49
|
-
- Request payload limits are sized for a page snapshot (visible text plus every
|
|
50
|
-
interactive element), not for a control message.
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Context Obligatory Messages
|
|
2
|
-
|
|
3
|
-
Messages explicitly pinned by the user are stored under
|
|
4
|
-
`session.metadata.aiworker.context_obligatory_messages` as `{ id, createdAt,
|
|
5
|
-
role }`. The UI uses a fresh-read metadata merge when pinning or unpinning.
|
|
6
|
-
|
|
7
|
-
The server runtime listens for OpenCode's dedicated `session.compacted` event.
|
|
8
|
-
It fetches every pinned message by ID, keeps non-empty text parts, sorts them
|
|
9
|
-
by the stored creation time, and immediately sends one synthetic user part
|
|
10
|
-
through `prompt_async`. OpenCode's session runner serializes this with its own
|
|
11
|
-
post-compaction continuation. Missing individual messages are skipped without
|
|
12
|
-
discarding the remaining context. Ordinary idle events perform no work and
|
|
13
|
-
make no requests.
|
|
14
|
-
|
|
15
|
-
After a successful send, the runtime merge-writes
|
|
16
|
-
`context_obligatory_last_compaction_message_id`. This cursor prevents a
|
|
17
|
-
replayed compaction event from reinjecting the same summary. The runtime is
|
|
18
|
-
owned by the AiWorker web backend and therefore is not available in
|
|
19
|
-
extension-only VS Code mode.
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# Dev Server Tunnel
|
|
2
|
-
|
|
3
|
-
## Purpose
|
|
4
|
-
|
|
5
|
-
This module carries raw TCP bytes between a desktop client and a dev server
|
|
6
|
-
running on the AiWorker host, so a remote dev server can be opened in the
|
|
7
|
-
browser panel without anything being rewritten.
|
|
8
|
-
|
|
9
|
-
The page is served from a real origin at the root of its own host. That is the
|
|
10
|
-
whole design: absolute URLs resolve, cookies scope correctly, HMR sockets
|
|
11
|
-
connect, and developer tools behave as they do locally. No HTML, header, or
|
|
12
|
-
URL is inspected or modified, which is what the previous rewriting proxy did
|
|
13
|
-
and what made it fragile per framework.
|
|
14
|
-
|
|
15
|
-
## Boundaries
|
|
16
|
-
|
|
17
|
-
- `runtime.js` is the host end: it accepts the WebSocket upgrade at
|
|
18
|
-
`/api/dev-tunnel`, authenticates it, opens a TCP socket to the requested
|
|
19
|
-
local port, and pipes the two together.
|
|
20
|
-
- `client.js` is the local end: it binds a loopback listener on the user's
|
|
21
|
-
machine and pipes each accepted connection through one WebSocket. It lives in
|
|
22
|
-
this package because it needs a WebSocket client the package already depends
|
|
23
|
-
on; the desktop shell drives it over IPC.
|
|
24
|
-
- Port discovery is not owned here. `runtime.js` is given the reachable set by
|
|
25
|
-
the same dev-server discovery the user's own list is built from.
|
|
26
|
-
- The browser panel decides when to tunnel; this module never chooses a target.
|
|
27
|
-
`packages/ui/src/lib/browser/devTunnel.ts` owns that decision, including for
|
|
28
|
-
navigations the page starts itself: a tunnelled page that sends the view to
|
|
29
|
-
another loopback port means a port on the host, not on the user's machine.
|
|
30
|
-
|
|
31
|
-
## Invariants
|
|
32
|
-
|
|
33
|
-
- The reachable set is exactly what dev-server discovery offers the user, never
|
|
34
|
-
"any loopback port". Without that restriction an authenticated client could
|
|
35
|
-
dial arbitrary local services on the host — databases, admin panels, the
|
|
36
|
-
OpenCode API — through this socket.
|
|
37
|
-
- Authentication depends on whether the caller is a browser, and this is
|
|
38
|
-
deliberate rather than a relaxation:
|
|
39
|
-
- With an `Origin` header the request came from a browser context, and the
|
|
40
|
-
usual origin allowlist applies unchanged. That check is a CSRF defence: a
|
|
41
|
-
hostile page can make a browser open a WebSocket carrying ambient cookies,
|
|
42
|
-
and the origin is what exposes it.
|
|
43
|
-
- With no `Origin` the request must carry client-token auth. A browser cannot
|
|
44
|
-
reach this path — the WebSocket API always sends an origin and never lets a
|
|
45
|
-
page set an `Authorization` header — so this case is the desktop shell.
|
|
46
|
-
- Concurrency is capped per host, not per page, because one page load opens
|
|
47
|
-
many sockets.
|
|
48
|
-
- A connection that cannot be established fails the socket rather than holding
|
|
49
|
-
it open; a stalled connect is bounded by an explicit timeout, and so is the
|
|
50
|
-
WebSocket handshake. While it is pending the local socket is paused and its
|
|
51
|
-
buffered bytes are capped, so a local process writing into a stalled
|
|
52
|
-
handshake cannot grow the desktop app's memory.
|
|
53
|
-
- A tunnel that cannot be opened is reported to the panel, never replaced by the
|
|
54
|
-
plain loopback URL. On a remote instance that substitution would change which
|
|
55
|
-
machine answers and show local content under a remote address.
|
|
56
|
-
- Closing either end closes the other. A half-open pipe would leave the page
|
|
57
|
-
waiting on bytes that will never arrive.
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# Dictation module
|
|
2
|
-
|
|
3
|
-
Server-authoritative speech-to-text for the chat composer, plus local
|
|
4
|
-
text-to-speech. The client streams 16 kHz mono PCM16 chunks (base64) over a
|
|
5
|
-
WebSocket while the user speaks; the server buffers them and transcribes each
|
|
6
|
-
segment exactly once, when the segment is committed.
|
|
7
|
-
|
|
8
|
-
Transcription is deliberately not incremental. Parakeet is an offline model
|
|
9
|
-
trained on whole utterances, so re-decoding the growing buffer to animate a
|
|
10
|
-
live transcript costs O(n^2) work for a result the final decode replaces. The
|
|
11
|
-
composer shows no text while recording and inserts the full transcript on
|
|
12
|
-
stop.
|
|
13
|
-
|
|
14
|
-
Local TTS (Kokoro and Piper/VITS via sherpa-onnx OfflineTts) runs in the same
|
|
15
|
-
worker process and is exposed as `POST /api/dictation/tts/speak` (JSON
|
|
16
|
-
`{text, speakerId?, speed?, model?, language?, languageSample?}` → WAV bytes; 503 with
|
|
17
|
-
`reasonCode` while the model is downloading). TTS models live in the same
|
|
18
|
-
catalog/downloader as STT models (`local/model-catalog.js`
|
|
19
|
-
`LOCAL_TTS_MODEL_CATALOG`) and are managed by the same status/download/delete
|
|
20
|
-
routes.
|
|
21
|
-
|
|
22
|
-
Each TTS catalog entry declares the `languages` it speaks. With
|
|
23
|
-
`language: 'auto'` the service detects the language of `languageSample` — the
|
|
24
|
-
whole message the chunk belongs to, sent by the client with every chunk — or
|
|
25
|
-
of `text` when no sample is given
|
|
26
|
-
(`../tts/language-detect.js`, script plus function-word scoring, no
|
|
27
|
-
dependencies) and keeps the caller's model when it speaks that language;
|
|
28
|
-
otherwise it switches to the catalog model for the language, downloading it on
|
|
29
|
-
first use like any other model, and starts from that model's default speaker
|
|
30
|
-
(`defaultSpeakerByLanguage`) instead of the caller's speaker id. A language no
|
|
31
|
-
catalog model covers keeps the caller's model, so text is always spoken. The
|
|
32
|
-
response carries `X-Speech-Model` and `X-Speech-Language`.
|
|
33
|
-
|
|
34
|
-
## Ownership
|
|
35
|
-
|
|
36
|
-
- `runtime.js` — registers `GET /api/dictation/status`,
|
|
37
|
-
`POST /api/dictation/models/:modelId/download`, and the
|
|
38
|
-
`/api/dictation/ws` WebSocket endpoint (auth-gated the same way as the
|
|
39
|
-
terminal WS: UI session token or `oc_url_token`, plus origin check).
|
|
40
|
-
Created from the startup pipeline (`startup-pipeline-runtime.js`) before
|
|
41
|
-
the generic OpenCode proxy so routes are not shadowed.
|
|
42
|
-
- `stream-manager.js` — `DictationStreamManager`, one per WS connection.
|
|
43
|
-
Chunk reordering by `seq` + ack, resampling to the provider rate, segment
|
|
44
|
-
splitting, silence suppression by PCM peak, partial-transcript
|
|
45
|
-
concatenation, adaptive finalization timeout.
|
|
46
|
-
- `service.js` — provider resolution and readiness. Providers:
|
|
47
|
-
- `local` (default): sherpa-onnx Parakeet TDT in a forked worker process.
|
|
48
|
-
Models auto-download in the background on first use; while missing, the
|
|
49
|
-
stream fails with `reasonCode: 'model_download_in_progress'` and the
|
|
50
|
-
status route reports per-model install/download state.
|
|
51
|
-
- `openai-compatible`: buffered per-segment transcription against any
|
|
52
|
-
OpenAI-compatible `/v1/audio/transcriptions` endpoint
|
|
53
|
-
(`openai-compatible-session.js`, reuses `../tts/stt.js`).
|
|
54
|
-
- `local/` — worker process + client (IPC, idle shutdown TTL), sherpa
|
|
55
|
-
recognizer engine and segment session (one decode per committed segment),
|
|
56
|
-
model catalog and downloader. The native `sherpa-onnx-node` addon is only
|
|
57
|
-
ever loaded inside the worker process.
|
|
58
|
-
- `audio.js` — PCM16 helpers: format parsing, peak, WAV wrapping, streaming
|
|
59
|
-
linear resampler.
|
|
60
|
-
|
|
61
|
-
## WebSocket protocol (JSON text frames)
|
|
62
|
-
|
|
63
|
-
Client → server: `start {dictationId, format, options}`,
|
|
64
|
-
`chunk {dictationId, seq, audio}`, `finish {dictationId, finalSeq}`,
|
|
65
|
-
`cancel {dictationId}`, `ping`.
|
|
66
|
-
|
|
67
|
-
Server → client: `ready`, `ack {ackSeq}`, `partial {text}`,
|
|
68
|
-
`finish_accepted {timeoutMs}`, `final {text}`,
|
|
69
|
-
`error {error, retryable, reasonCode?}`, `pong`.
|
|
70
|
-
|
|
71
|
-
`options` in `start` carries the client-selected provider config:
|
|
72
|
-
`{ provider: 'local' | 'openai-compatible', language?, localModel?,
|
|
73
|
-
openaiCompatible?: { baseUrl, model, apiKey } }`.
|
|
74
|
-
|
|
75
|
-
## Segmentation
|
|
76
|
-
|
|
77
|
-
A dictation is one segment unless it runs long. Past `segmentMinSeconds`
|
|
78
|
-
(60 s) the manager commits on the first silent chunk, so cuts land at a pause
|
|
79
|
-
rather than mid-word; `segmentMaxSeconds` (90 s) is a hard cap for speech with
|
|
80
|
-
no pause in it. Client chunks are ~1 s, so "silent chunk" is roughly a second
|
|
81
|
-
of silence.
|
|
82
|
-
|
|
83
|
-
The bounds exist because Parakeet is a full-attention conformer: decode cost
|
|
84
|
-
and peak memory grow quadratically with segment length. Measured on Parakeet
|
|
85
|
-
v3 int8 with 2 threads: 60 s took 2.1 s and +90 MB, 180 s took 9.3 s and
|
|
86
|
-
+490 MB, 300 s took 21.3 s and +1.5 GB. Committed segments decode while the
|
|
87
|
-
user is still speaking, so only the tail is left to transcribe on stop.
|
|
88
|
-
|
|
89
|
-
## Invariants
|
|
90
|
-
|
|
91
|
-
- Never load `sherpa-onnx-node` in the main server process.
|
|
92
|
-
- Transcription happens on commit only; sessions never emit non-final
|
|
93
|
-
transcripts. The `partial` messages a client receives are the concatenation
|
|
94
|
-
of already-committed segments, and exist so a dictation that fails partway
|
|
95
|
-
can be salvaged instead of losing minutes of speech.
|
|
96
|
-
- The stream manager acks only the highest contiguous seq; the client is
|
|
97
|
-
expected to retain unacked segments for retry/replay.
|
|
98
|
-
- Silence-only segments (peak < 300) are cleared, never committed, so
|
|
99
|
-
Whisper-style providers do not hallucinate on silence.
|
|
100
|
-
- Model files live under `~/.config/openchamber/speech-models`.
|