@p4code/cli 0.9.22 → 0.9.23
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/dist/{AcpMcpStdioBridge-DxIZyDJz.mjs → AcpMcpStdioBridge-BNuxv1nx.mjs} +15 -7
- package/dist/AcpMcpStdioBridge-C9Ry_oCI.mjs +3 -0
- package/dist/{Effect-BqRgldaH.mjs → Effect-BrI3bavz.mjs} +1242 -448
- package/dist/{Schema-CkGB1Dgx.mjs → Schema-06GeVid5.mjs} +1626 -1148
- package/dist/{Stream-DZTo5F3N.mjs → Stream-DKSvHopl.mjs} +470 -190
- package/dist/{TraceDiagnostics-DE0N1Yf6.mjs → TraceDiagnostics-DY_cYrzB.mjs} +1961 -531
- package/dist/bin.mjs +2 -2
- package/dist/{binCli-DC5fHnhS.mjs → binCli-Bou3rWgW.mjs} +2302 -1946
- package/dist/claude-history-worker.mjs +1 -1
- package/dist/{claudeHistoryWorker-Cst8OnLH.mjs → claudeHistoryWorker-BZBBGtSw.mjs} +1 -1
- package/dist/{claudeHistoryWorker-r4mV4Dxy.mjs → claudeHistoryWorker-DlhW7K2f.mjs} +2 -2
- package/dist/client/.vite/manifest.json +2155 -2127
- package/dist/client/assets/{2NI2N5EU-CgpeJ5KT.js → 2NI2N5EU-B3GKfpTJ.js} +2 -2
- package/dist/client/assets/{4UO7MD6I-BZfVOqtM.js → 4UO7MD6I-D1jV-2l8.js} +2 -2
- package/dist/client/assets/{5B3SVYGG-B5V3_tzl.js → 5B3SVYGG-CiUCamIk.js} +2 -2
- package/dist/client/assets/{5GK6JWQ2-DRzSVTZ0.js → 5GK6JWQ2-t3RHg90Y.js} +2 -2
- package/dist/client/assets/{5N7A7DKN-BX-IFKkJ.js → 5N7A7DKN-QVdNnUVu.js} +2 -2
- package/dist/client/assets/{5OC2THR4-CGiKcStE.js → 5OC2THR4-CxE7bwzV.js} +2 -2
- package/dist/client/assets/{5S6HY5KT-B5Smgpiz.js → 5S6HY5KT-msIIAX0G.js} +2 -2
- package/dist/client/assets/{6IMQ5BUJ-BSWEueVD.js → 6IMQ5BUJ-BzYnQ5qg.js} +2 -2
- package/dist/client/assets/{6OLKWJ4F-0nUReGo5.js → 6OLKWJ4F-AQyY5TLk.js} +2 -2
- package/dist/client/assets/{74OO7NKP-BZ5SCLUX.js → 74OO7NKP-CCpQBxNH.js} +2 -2
- package/dist/client/assets/{75O6YZUN-NifBwMlS.js → 75O6YZUN-D3WwLu8s.js} +2 -2
- package/dist/client/assets/{77XECAW3-_XJOQitm.js → 77XECAW3-C6PMMrkh.js} +2 -2
- package/dist/client/assets/{ABYRPUBD-B5mFmY4q.js → ABYRPUBD-BmXVPnuD.js} +2 -2
- package/dist/client/assets/AlertDialogRoot-CNpt8h9w.js +2 -0
- package/dist/client/assets/{AnimatedHeight-BoS1RBdk.js → AnimatedHeight-B2j_NXft.js} +2 -2
- package/dist/client/assets/{AuthSurfaceShell-DesOxtee.js → AuthSurfaceShell-DDT8iJWE.js} +2 -2
- package/dist/client/assets/{BB2UYUI2-CxFyfwSJ.js → BB2UYUI2-C_DXRsEF.js} +2 -2
- package/dist/client/assets/{BUM34MOA-Kk83QSsb.js → BUM34MOA-sLk4tJuF.js} +2 -2
- package/dist/client/assets/{CEQABKGZ-DLcBenqs.js → CEQABKGZ-DsLeCUfk.js} +2 -2
- package/dist/client/assets/{CXAC5362-BcvLk6NG.js → CXAC5362-6czpP5mH.js} +2 -2
- package/dist/client/assets/ChatGptUsageButton-BElkMe1K.js +2 -0
- package/dist/client/assets/ChatMarkdown-pRUIhpGi.js +49 -0
- package/dist/client/assets/{CheckboxIndicator-Dj91Im5z.js → CheckboxIndicator-DFCs5GRD.js} +2 -2
- package/dist/client/assets/{ClippedText-CmBRrYNb.js → ClippedText-BIwvWMlV.js} +2 -2
- package/dist/client/assets/CodexSetupSection.logic-3MrEmFzD.js +2 -0
- package/dist/client/assets/{CollapsiblePanel-BwDr-EKA.js → CollapsiblePanel-CsWNZ7jo.js} +2 -2
- package/dist/client/assets/{ComboboxClear-DeqR6c-6.js → ComboboxClear-Cv9NZFNr.js} +2 -2
- package/dist/client/assets/{ComboboxGroupLabel-Dk-MF4sD.js → ComboboxGroupLabel-BPe0M6wJ.js} +2 -2
- package/dist/client/assets/{CommandBlock-C15Q987N.js → CommandBlock-DUs3JB3r.js} +2 -2
- package/dist/client/assets/{CompositeRoot-Cx12XSsh.js → CompositeRoot-RcqGhRAf.js} +2 -2
- package/dist/client/assets/ConnectAgentSurface-BG30oBmC.js +2 -0
- package/dist/client/assets/{ConnectionStatusDot-BnhNFCMA.js → ConnectionStatusDot-DIUevPBM.js} +2 -2
- package/dist/client/assets/{DRLTVNUE-CkNId4Pz.js → DRLTVNUE-CAWKPVio.js} +2 -2
- package/dist/client/assets/{DYY6UVD2-B4516qT_.js → DYY6UVD2-HB9mYAbb.js} +2 -2
- package/dist/client/assets/DevicePanel-BAT6BS-V.js +2 -0
- package/dist/client/assets/DeviceSetup-ClD1wdY1.js +2 -0
- package/dist/client/assets/DialogRoot-Dg58-QOq.js +2 -0
- package/dist/client/assets/DialogTitle-CSaaIBpP.js +2 -0
- package/dist/client/assets/{DiffCommentAnnotation-CSzNea6G.js → DiffCommentAnnotation-BjI2rZNS.js} +3 -3
- package/dist/client/assets/{DiffFileTree-CDnFut1y.js → DiffFileTree-C6VB4VCo.js} +2 -2
- package/dist/client/assets/DiffPanel-pkAdnqL7.js +2 -0
- package/dist/client/assets/{DiffWorkerPoolProvider-zgaFe3TY.js → DiffWorkerPoolProvider-CPwS1D4h.js} +3 -3
- package/dist/client/assets/{EmbeddedDesign-BI3VZqZl.js → EmbeddedDesign-DOevokgh.js} +7 -7
- package/dist/client/assets/{EnvironmentMachineIcon-Lz2YGk0G.js → EnvironmentMachineIcon-DM48TG2x.js} +2 -2
- package/dist/client/assets/{ExpandableText-B034p2kF.js → ExpandableText-CYFNBBpY.js} +2 -2
- package/dist/client/assets/{FNOVOB4O-Uc8FDPv8.js → FNOVOB4O-BkKBPKb-.js} +2 -2
- package/dist/client/assets/{FieldControl-H6iQvC-Q.js → FieldControl-DHSVFpKc.js} +2 -2
- package/dist/client/assets/{FileDiff-B4Yf4fFg.js → FileDiff-CdxU7jjH.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-u1jxtxzb.js → FilePreviewPanel-Bz8HETIa.js} +4 -4
- package/dist/client/assets/{FoldedSettingsSection-DvzfFn5A.js → FoldedSettingsSection-IyrJlpO8.js} +2 -2
- package/dist/client/assets/{HDGCDEEZ-DVkQN-82.js → HDGCDEEZ-BW-K6GhK.js} +2 -2
- package/dist/client/assets/{HSJLKHB7-txH19TCj.js → HSJLKHB7-B8h6fviS.js} +2 -2
- package/dist/client/assets/{Icons-DmQwwfAN.js → Icons-DpgbzNj8.js} +2 -2
- package/dist/client/assets/Input-BT2VVALp.js +2 -0
- package/dist/client/assets/{IntervalSecondsField-xqmFxAii.js → IntervalSecondsField-BaJ1qNX-.js} +2 -2
- package/dist/client/assets/JZOYTAAL-DbSUKTwO.js +1 -0
- package/dist/client/assets/{K3MD6TGW-4d2yDOzZ.js → K3MD6TGW-BTpBxr8x.js} +2 -2
- package/dist/client/assets/{K7RP3OMA-B8vKr81f.js → K7RP3OMA-DcsmGbRM.js} +2 -2
- package/dist/client/assets/{KeybindingsSettings.logic-C6XG7NtX.js → KeybindingsSettings.logic-oAUXQqts.js} +2 -2
- package/dist/client/assets/{LHDIQX7Q-DAyTfuTY.js → LHDIQX7Q-NOcjEUQY.js} +2 -2
- package/dist/client/assets/{LUXOKEGN-C67XJj3F.js → LUXOKEGN-BWJqFZst.js} +2 -2
- package/dist/client/assets/LinkMachineSelect-Dp6FC1LE.js +2 -0
- package/dist/client/assets/{MathTypeset-CMO1aCZc.js → MathTypeset-DHPwWtff.js} +2 -2
- package/dist/client/assets/{ModelLiveLayer-DqW0VhFG.js → ModelLiveLayer-D3x6mJFP.js} +3 -3
- package/dist/client/assets/{N3JZAHOW-Bp1sdK_N.js → N3JZAHOW-oDX5VWgR.js} +2 -2
- package/dist/client/assets/{NUIALGQ3-D427dlgt.js → NUIALGQ3-DbqxE7KO.js} +2 -2
- package/dist/client/assets/{NoProjectsHero-BL0Jsc_V.js → NoProjectsHero-Dk-rv5RI.js} +2 -2
- package/dist/client/assets/{O65XPQGZ-BxqHRP3n.js → O65XPQGZ-Cys4qXjc.js} +2 -2
- package/dist/client/assets/{O7XIQ6OM-CKRD1aP5.js → O7XIQ6OM-aLdTRbRJ.js} +2 -2
- package/dist/client/assets/{OFQON5FD-CzS9a25C.js → OFQON5FD-DpC8rm9Y.js} +2 -2
- package/dist/client/assets/P4ConnectAccountPages-C-GbG9lk.js +2 -0
- package/dist/client/assets/{P4ConnectSidebarSignIn-29st82gY.js → P4ConnectSidebarSignIn-DepXmk4f.js} +2 -2
- package/dist/client/assets/{PJQHF43J-Ww7-2BqY.js → PJQHF43J-CUbFewuD.js} +2 -2
- package/dist/client/assets/PanelLayoutControls-CKWjLO_e.js +218 -0
- package/dist/client/assets/{PierreEntryIcon-UO6zY_i-.js → PierreEntryIcon-CVKV5qfT.js} +2 -2
- package/dist/client/assets/{PopoverHandle-DEcvmS0k.js → PopoverHandle-s36xVlsK.js} +2 -2
- package/dist/client/assets/PreviewPanel-B-ty1_ZL.js +2 -0
- package/dist/client/assets/{ProjectDefaultsSettings-DN1mhFNf.js → ProjectDefaultsSettings-vF_5kxVM.js} +2 -2
- package/dist/client/assets/{ProjectFavicon-CyXd4lSF.js → ProjectFavicon-BEsCcLjN.js} +3 -3
- package/dist/client/assets/{ProjectIconPickerDialog-B_D_9SAb.js → ProjectIconPickerDialog-D1_gSlWW.js} +2 -2
- package/dist/client/assets/{ProjectMonogram-C8btbogu.js → ProjectMonogram-Aw_ZBtDB.js} +2 -2
- package/dist/client/assets/{ProviderAuthTerminal-B0GzUrya.js → ProviderAuthTerminal-cNp7I_XV.js} +2 -2
- package/dist/client/assets/ProviderModelPicker-CCCH-TiQ.js +2 -0
- package/dist/client/assets/{ProviderSettingsForm-DefAmKv_.js → ProviderSettingsForm-CV7sAQy3.js} +2 -2
- package/dist/client/assets/PullRequestCodeTab-DjChxC-1.js +6 -0
- package/dist/client/assets/{RHNBAITX-BsGO-vJB.js → RHNBAITX-CEZ1jYAC.js} +2 -2
- package/dist/client/assets/{ReadOnlySourcePreview-COho36OD.js → ReadOnlySourcePreview-Dw9TzXZ2.js} +2 -2
- package/dist/client/assets/{RedactedSensitiveText-BMXImj30.js → RedactedSensitiveText-bQSbv34p.js} +2 -2
- package/dist/client/assets/RenderErrorBoundary-Dbb6Gs8P.js +23 -0
- package/dist/client/assets/{RightPanelResizeHandle-Cog3JVw0.js → RightPanelResizeHandle-B6vIzqA0.js} +2 -2
- package/dist/client/assets/{SLD4V6NK-BZEKTqDY.js → SLD4V6NK-BXmFkBHB.js} +2 -2
- package/dist/client/assets/ScheduledTasksSettings-TjoGUXvC.js +6 -0
- package/dist/client/assets/{ScopedSwitch-Cq7B0T7B.js → ScopedSwitch-C8qSHRkU.js} +2 -2
- package/dist/client/assets/{ScrollAreaCorner-DFCZuJ0r.js → ScrollAreaCorner-Cn2VDisz.js} +2 -2
- package/dist/client/assets/{SecretInput-CRgvNUgU.js → SecretInput-C6zW-8wI.js} +2 -2
- package/dist/client/assets/{SelectScrollUpArrow-C-MWJdyw.js → SelectScrollUpArrow-C40FP3vq.js} +2 -2
- package/dist/client/assets/{SelfImproveSettingsSection-DZUf-jb0.js → SelfImproveSettingsSection-BhUO-XvV.js} +2 -2
- package/dist/client/assets/{SettingsPanels-Bk_YhHLm.js → SettingsPanels-DFPZUI9O.js} +7 -7
- package/dist/client/assets/{SettingsPanels.logic-UhRGlGN1.js → SettingsPanels.logic-5bLleFhd.js} +2 -2
- package/dist/client/assets/{SettingsScopeNotice-Cja-hHOp.js → SettingsScopeNotice-VgBZL2zg.js} +2 -2
- package/dist/client/assets/{SidebarStageBackdrop-DL1ZzaTz.js → SidebarStageBackdrop-DvPzZM_j.js} +2 -2
- package/dist/client/assets/{T3PCR2KE-D049x5K8.js → T3PCR2KE-bp9TnTiq.js} +2 -2
- package/dist/client/assets/{TKWO2OVW-Du9gxVgn.js → TKWO2OVW-Cyskzdq0.js} +2 -2
- package/dist/client/assets/{TSHNXIZL-pUPHV4Qd.js → TSHNXIZL-Dp3os6bG.js} +2 -2
- package/dist/client/assets/{ThemeEditorPanel-CcFVvJlQ.js → ThemeEditorPanel-B1RklhEA.js} +3 -3
- package/dist/client/assets/{ThreadDetailsItemsMenu-C4wfbepv.js → ThreadDetailsItemsMenu-BOMU-3M3.js} +60 -60
- package/dist/client/assets/ThreadTerminalDrawer-BmwBVDGv.js +5 -0
- package/dist/client/assets/TooltipProvider-DQ0TF9NB.js +2 -0
- package/dist/client/assets/{UQJE5E4I-BN56DsgT.js → UQJE5E4I-DDRoojS_.js} +2 -2
- package/dist/client/assets/{USNYFO5S-DVfAs9Gy.js → USNYFO5S-BvyU-aXY.js} +2 -2
- package/dist/client/assets/{Virtualizer-Cn_zq3uH.js → Virtualizer-DFzJCTxQ.js} +2 -2
- package/dist/client/assets/{WEVWDWVA-Cz36fo-k.js → WEVWDWVA-DTuHUaDF.js} +2 -2
- package/dist/client/assets/{WorkspaceBreadcrumb-Cok6l_SJ.js → WorkspaceBreadcrumb-Dno2N8Xd.js} +2 -2
- package/dist/client/assets/{WorkspacePageContainer-_--jFIZ8.js → WorkspacePageContainer-OLpcgD_f.js} +2 -2
- package/dist/client/assets/{WorkspacePageHeader-CJB6rvZc.js → WorkspacePageHeader-Bn0m4gpR.js} +2 -2
- package/dist/client/assets/{X5RFHQXM-CUB_vKAl.js → X5RFHQXM-D9IKIoIk.js} +2 -2
- package/dist/client/assets/{X62E3GBT-C0wKfqHq.js → X62E3GBT-BBXkOa6O.js} +2 -2
- package/dist/client/assets/{XBNEOJTC-CkYPODhO.js → XBNEOJTC-D743Jp_H.js} +2 -2
- package/dist/client/assets/{YHV2MVVZ-Cf82W2em.js → YHV2MVVZ-DZBsjjLM.js} +2 -2
- package/dist/client/assets/{YURCZMG2-C9tzKn90.js → YURCZMG2-ByezMSr0.js} +2 -2
- package/dist/client/assets/{YVG2LODB-DEZWhxa8.js → YVG2LODB-DrsC56GM.js} +2 -2
- package/dist/client/assets/_chat-BrgTPEvH.js +47 -0
- package/dist/client/assets/_chat.design-CgGDbdSU.js +2 -0
- package/dist/client/assets/{_chat.index-YmI2iiCN.js → _chat.index-BjAR62fj.js} +2 -2
- package/dist/client/assets/{_chat.new-BQY5ktA8.js → _chat.new-SjhrzHWl.js} +3 -3
- package/dist/client/assets/_chat.pull-requests-BixugchU.js +2 -0
- package/dist/client/assets/{alert-D6WJ0q4-.js → alert-CfhQnxcL.js} +2 -2
- package/dist/client/assets/alert-dialog-Dn_PRSFU.js +2 -0
- package/dist/client/assets/{assetUrls-C78a94Xu.js → assetUrls-Bn1N9LX7.js} +2 -2
- package/dist/client/assets/assets-Lf7mgwY7.js +2 -0
- package/dist/client/assets/{browserHistoryStore-DHI-0j5y.js → browserHistoryStore-Ciy-Cygo.js} +2 -2
- package/dist/client/assets/{browserLinkTarget-D8HUAQg-.js → browserLinkTarget-DKVi8qup.js} +2 -2
- package/dist/client/assets/{checkbox-Cw33xyU7.js → checkbox-iFzfBLKr.js} +2 -2
- package/dist/client/assets/{color-picker-Bmtarpj9.js → color-picker-W1NtR7ha.js} +2 -2
- package/dist/client/assets/combobox-B0IMIA-1.js +2 -0
- package/dist/client/assets/command-BdVxwZ8D.js +2 -0
- package/dist/client/assets/{connect-Dl6MuR2C.js → connect-C605Zs89.js} +2 -2
- package/dist/client/assets/connect-agent-Cy1G_UzI.js +2 -0
- package/dist/client/assets/{design-BoZx445P.js → design-BNHLz8I2.js} +2 -2
- package/dist/client/assets/{device-Ku4cbgo-.js → device-CwiofvsD.js} +2 -2
- package/dist/client/assets/dialog-DFlZvvht.js +2 -0
- package/dist/client/assets/dialog-styles-Df-wlHU1.js +2 -0
- package/dist/client/assets/{diffPanelStore-D3ARjaef.js → diffPanelStore-CGdPbp5I.js} +2 -2
- package/dist/client/assets/{diffRendering-yxIsTMie.js → diffRendering-DJnBG6ZN.js} +2 -2
- package/dist/client/assets/{dist-CkH9xVVz.js → dist-D1XCsn7e.js} +3 -3
- package/dist/client/assets/{draft-input-DM7mC5ty.js → draft-input-1HTN8QVo.js} +2 -2
- package/dist/client/assets/{duoViewer-_3Xk2sTq.js → duoViewer-CQpxZewd.js} +2 -2
- package/dist/client/assets/{dynamic-CwQ-caG2.js → dynamic-DHrzmb9Z.js} +2 -2
- package/dist/client/assets/{embeddedScripts-Cn7aGTAj.js → embeddedScripts-D7WC0N_7.js} +2 -2
- package/dist/client/assets/{empty-VkAC9qIO.js → empty-Dn5VI2Xk.js} +2 -2
- package/dist/client/assets/entities-CjoTQlW3.js +2 -0
- package/dist/client/assets/{fileLinks-CJ9SYNL6.js → fileLinks-BZkPwsEY.js} +2 -2
- package/dist/client/assets/{fileTreeExpansion-CdWOFpa-.js → fileTreeExpansion-DHPBKDpm.js} +2 -2
- package/dist/client/assets/{getDiffFileInput-hLtjvhYr.js → getDiffFileInput-D-dpZLfC.js} +2 -2
- package/dist/client/assets/{htmlRender-DYI6n9Xo.js → htmlRender-BdsR_7vV.js} +2 -2
- package/dist/client/assets/{index-etcfxnIt.js → index-Cq59P2HC.js} +3 -3
- package/dist/client/assets/{input-group-DOUsG7P-.js → input-group-B1TOCtDG.js} +2 -2
- package/dist/client/assets/{input-CiPGmOLv.js → input-yaZxaTds.js} +2 -2
- package/dist/client/assets/{kbd-C8opCm5n.js → kbd-R7rkirqT.js} +2 -2
- package/dist/client/assets/{keybindings-CbaDrm2P.js → keybindings-CrlWqd5q.js} +2 -2
- package/dist/client/assets/{lazy--Qcevr63.js → lazy-BH4rgIwO.js} +4 -4
- package/dist/client/assets/{lazyRouteComponent-BZe6tHvz.js → lazyRouteComponent-BxpFJiXB.js} +2 -2
- package/dist/client/assets/{link-BHR6GsRr.js → link-2ZiGGBbw.js} +2 -2
- package/dist/client/assets/{linkedPrompt-D4M9Fbja.js → linkedPrompt-BTa8Gs9-.js} +2 -2
- package/dist/client/assets/main-Rpw_0nEx.css +2 -0
- package/dist/client/assets/main-xhw8F2iL.js +38 -0
- package/dist/client/assets/mediaReference-B7ym_1-U.js +2 -0
- package/dist/client/assets/{mediaSource-B03Ykm6c.js → mediaSource-GtWYcfeZ.js} +2 -2
- package/dist/client/assets/{modelScene-CX8s0IGN.js → modelScene-uWeIf_CC.js} +2 -2
- package/dist/client/assets/number-field-DNna9ps3.js +2 -0
- package/dist/client/assets/{observeResize-BESwMMOy.js → observeResize-Cz6dJUG2.js} +2 -2
- package/dist/client/assets/{onboarding-BZ01kUjR.js → onboarding-CxDppAGc.js} +2 -2
- package/dist/client/assets/openFileInPreview-MLuDI8fu.js +2 -0
- package/dist/client/assets/{p4ProjectFile-y2CDxOaL.js → p4ProjectFile-DlnfrOnm.js} +2 -2
- package/dist/client/assets/{pair-PXvf9qqC.js → pair-BJWvIdrD.js} +2 -2
- package/dist/client/assets/{pendingSendStore-CX8QB7C5.js → pendingSendStore-Cc6n4Xji.js} +2 -2
- package/dist/client/assets/{phoneViewer-F9Wt5VkW.js → phoneViewer-OFK_ThS_.js} +2 -2
- package/dist/client/assets/{pierre-icons-BTVgApcG.js → pierre-icons-BYPQj09G.js} +2 -2
- package/dist/client/assets/popover-DnYfrQly.js +2 -0
- package/dist/client/assets/{preview-DnCP9Q0k.js → preview-Bi-hPWTp.js} +2 -2
- package/dist/client/assets/{preview-5pSBET3P.js → preview-CxFR-vue.js} +2 -2
- package/dist/client/assets/{previewMiniPlayerStore-DByen2Nk.js → previewMiniPlayerStore-W10VSM09.js} +2 -2
- package/dist/client/assets/primary-CCmKskNP.js +2 -0
- package/dist/client/assets/primaryCloudLinkState-DDs0gJOh.js +2 -0
- package/dist/client/assets/{projectFilesQueryState-B6AeAhgL.js → projectFilesQueryState-DzjMtjuq.js} +2 -2
- package/dist/client/assets/projectScriptEditor-C2NTRQLs.js +2 -0
- package/dist/client/assets/{providerSkills-D-ytsJU9.js → providerSkills-gNPMp_MW.js} +2 -2
- package/dist/client/assets/pullRequestDetail.logic-BZNLZTdt.js +10 -0
- package/dist/client/assets/{pullRequestIcons-1lUVOGQJ.js → pullRequestIcons-DwblWS4R.js} +2 -2
- package/dist/client/assets/{pullRequestReviewStore-CUZ0N4F2.js → pullRequestReviewStore-Cc4bHb4o.js} +2 -2
- package/dist/client/assets/{pullRequests-DrQJ8zM2.js → pullRequests-DAMVEVGR.js} +2 -2
- package/dist/client/assets/queries-ckipBW-f.js +2 -0
- package/dist/client/assets/{query-CeIgbVxh.js → query-DFSffMGJ.js} +2 -2
- package/dist/client/assets/{radio-group-C14CASyG.js → radio-group-EK7EPCn2.js} +2 -2
- package/dist/client/assets/relay-BLgoNhyd.js +2 -0
- package/dist/client/assets/relayFailureReason-COnjzJFI.js +2 -0
- package/dist/client/assets/{renderScheduler-eNIG8tB_.js → renderScheduler-BCOEl9SF.js} +2 -2
- package/dist/client/assets/{rightPanelStore-Bt0unAo8.js → rightPanelStore-AjYoRisO.js} +2 -2
- package/dist/client/assets/runtime-CbYvES7U.js +9 -0
- package/dist/client/assets/{runtimeModeConfig-DymGoV55.js → runtimeModeConfig-Oh86kRYJ.js} +2 -2
- package/dist/client/assets/{scheduledTasksSettings.logic-CKzZuci7.js → scheduledTasksSettings.logic-DBMDVdjk.js} +3 -3
- package/dist/client/assets/{scroll-area-D2D-AlvC.js → scroll-area-DhDCLqyU.js} +2 -2
- package/dist/client/assets/{select-CE2f-g-3.js → select-CNcZzYBl.js} +2 -2
- package/dist/client/assets/{selfImproveFindings-Bhi6QF1b.js → selfImproveFindings-CvQXlaMJ.js} +2 -2
- package/dist/client/assets/{server-DthHkqkT.js → server-CEMcTnD1.js} +2 -2
- package/dist/client/assets/{session-CxeYe0sJ.js → session-Ces3Ebxl.js} +2 -2
- package/dist/client/assets/session-logic-DoE1Q_f_.js +27 -0
- package/dist/client/assets/{settings-DAe5Z4UG.js → settings-DfyN3nPg.js} +2 -2
- package/dist/client/assets/{settings.appearance-wfb5oCmC.js → settings.appearance-DKdqiS33.js} +2 -2
- package/dist/client/assets/settings.archived-DDSjJTCo.js +2 -0
- package/dist/client/assets/{settings.computer-use-DJQcngZ4.js → settings.computer-use-B9Lvx9ml.js} +2 -2
- package/dist/client/assets/settings.connections-CeVMC9_Q.js +2 -0
- package/dist/client/assets/{settings.data-controls-DUI06j8l.js → settings.data-controls-C50d8Y1p.js} +2 -2
- package/dist/client/assets/{settings.decisions-BY4z-aRM.js → settings.decisions-IKWdsPJP.js} +2 -2
- package/dist/client/assets/{settings.designs-O0d1vzoU.js → settings.designs-DYK1fORq.js} +2 -2
- package/dist/client/assets/settings.diagnostics-DDQ_8Jca.js +2 -0
- package/dist/client/assets/{settings.general-CAOwfHEb.js → settings.general-c8Ls4Mz6.js} +2 -2
- package/dist/client/assets/settings.integrations-Bx78DSgB.js +2 -0
- package/dist/client/assets/{settings.keybindings-CwvrmKin.js → settings.keybindings-CBhgDtMa.js} +2 -2
- package/dist/client/assets/{settings.open-source-licenses-DCBCu3U3.js → settings.open-source-licenses-CgHCMsAt.js} +2 -2
- package/dist/client/assets/{settings.plugins-8R8eV7IR.js → settings.plugins-1AVunwAZ.js} +4 -4
- package/dist/client/assets/{settings.projects-Cy_93LuA.js → settings.projects-voo-H787.js} +4 -4
- package/dist/client/assets/settings.providers-BWjGRXNt.js +3 -0
- package/dist/client/assets/{settings.scheduled-tasks-CHnjcJx8.js → settings.scheduled-tasks-czvZRhu8.js} +2 -2
- package/dist/client/assets/{settings.secrets-BgQSmFWY.js → settings.secrets-B4BGlz80.js} +2 -2
- package/dist/client/assets/{settings.snap-shot-C0J6pItQ.js → settings.snap-shot-d8VTC1Lv.js} +2 -2
- package/dist/client/assets/{settings.source-control-B3kcm55_.js → settings.source-control-Df0azAck.js} +2 -2
- package/dist/client/assets/settings.storage-CAwfhCbA.js +2 -0
- package/dist/client/assets/settingsLayout-D5Mded9h.js +3 -0
- package/dist/client/assets/sidebar-BUDllWET.js +2 -0
- package/dist/client/assets/{sidebarProjectGrouping-BaiZoO-A.js → sidebarProjectGrouping-Dt_irkWm.js} +2 -2
- package/dist/client/assets/{skeleton-D6RVfMa8.js → skeleton-C6O21cqb.js} +2 -2
- package/dist/client/assets/{sourceControl-j8xaTHat.js → sourceControl-CgxDQG5w.js} +2 -2
- package/dist/client/assets/{sourceControlClients-BxzlzQxJ.js → sourceControlClients-Bg3Of7DX.js} +2 -2
- package/dist/client/assets/{spinner-C-qDE4WQ.js → spinner-m1uNq_wW.js} +2 -2
- package/dist/client/assets/src-DHn7yNZx.js +15 -0
- package/dist/client/assets/terminal-links-C2FjxVhS.js +2 -0
- package/dist/client/assets/terminalSessions-DBYKcIE6.js +2 -0
- package/dist/client/assets/{textarea-CWbMGhL9.js → textarea-xZYMC9X5.js} +2 -2
- package/dist/client/assets/{themePalette-B_fGWNEh.js → themePalette-BcMO2M90.js} +3 -3
- package/dist/client/assets/{threadCheckpoints-B88N2CXf.js → threadCheckpoints-DUorxvL1.js} +2 -2
- package/dist/client/assets/{toggle-CKr6iZUR.js → toggle-DumCe7R7.js} +2 -2
- package/dist/client/assets/{toggle-group-B1WN0Pgy.js → toggle-group-CzE2mG-B.js} +2 -2
- package/dist/client/assets/{tooltip-CCYU8XGM.js → tooltip-BhCWnsdW.js} +2 -2
- package/dist/client/assets/{uiStateStore-CX-sbFiq.js → uiStateStore-B25zCY_s.js} +2 -2
- package/dist/client/assets/usage-DdBC08dx.js +2 -0
- package/dist/client/assets/{usageAccess-B0nqd8U-.js → usageAccess-COKmar79.js} +2 -2
- package/dist/client/assets/{usageFormat-CUSzTPTq.js → usageFormat-2913AogD.js} +2 -2
- package/dist/client/assets/{usageShortcuts-jGu1QJHr.js → usageShortcuts-U_aRtpf7.js} +2 -2
- package/dist/client/assets/{use-atom-command-Bsfu4mja.js → use-atom-command-DWabKYXN.js} +2 -2
- package/dist/client/assets/{useAriaLabelledBy-CJvtvui4.js → useAriaLabelledBy-BiZIzNf7.js} +2 -2
- package/dist/client/assets/useHandleNewThread-DTgcUVdd.js +2 -0
- package/dist/client/assets/{useLocation-KvBZAN7v.js → useLocation-BXwb7I1F.js} +2 -2
- package/dist/client/assets/{useNavigate-DXSBYc-k.js → useNavigate-P1p3Es15.js} +2 -2
- package/dist/client/assets/{useNavigateBack-DzR35iiJ.js → useNavigateBack-D02Al7yk.js} +2 -2
- package/dist/client/assets/{useP4ConnectAuthPrompt-CW-hut92.js → useP4ConnectAuthPrompt-DKYJHISj.js} +2 -2
- package/dist/client/assets/{useParams-D9reDvT8.js → useParams-DsmZTF__.js} +2 -2
- package/dist/client/assets/{usePermissionStatus-C5YvHVz-.js → usePermissionStatus-DeJYBk6u.js} +2 -2
- package/dist/client/assets/{usePopupViewport-D7yp2NvZ.js → usePopupViewport-BBKn7x_4.js} +2 -2
- package/dist/client/assets/usePullRequestActions-BGugTe1S.js +3 -0
- package/dist/client/assets/{useRegisterFieldControl-D-hYtXkm.js → useRegisterFieldControl-DkFmgEzw.js} +2 -2
- package/dist/client/assets/{useScopedModelAvailability-J0i-Sj4p.js → useScopedModelAvailability-LgMepA3M.js} +2 -2
- package/dist/client/assets/useSettings-hYzrsDTp.js +3 -0
- package/dist/client/assets/utils-BVnIIHXP.js +26 -0
- package/dist/client/assets/vcsRefInvalidation-C5gDWck3.js +2 -0
- package/dist/client/assets/welcome-CQrdWD2c.js +2 -0
- package/dist/client/icon-192x192.png +0 -0
- package/dist/client/icon-512x512.png +0 -0
- package/dist/client/index.html +1 -1
- package/dist/client/manifest.webmanifest +12 -0
- package/dist/client/third-party-licenses.json +1 -1
- package/dist/{mcpResponsePayloads-tqyeJD3c.mjs → mcpResponsePayloads-C8W7Qyxk.mjs} +3 -3
- package/dist/{preview-CmCyL-Tc.mjs → preview-C_kKbIjf.mjs} +6741 -3322
- package/dist/{renderer-CswgrCon.mjs → renderer-DKOOIEoX.mjs} +2 -2
- package/dist/resource-monitor/darwin-arm64/p4-resource-monitor +0 -0
- package/dist/{runtime-Bec3_bh8.mjs → runtime-Bm_EVnst.mjs} +3 -3
- package/dist/{runtimeLayer-BnJcJFjY.mjs → runtimeLayer-DQ7pD9BT.mjs} +22626 -21082
- package/dist/{runtimeLayer-DnNbGwAf.mjs → runtimeLayer-Go0xTEaW.mjs} +1 -1
- package/dist/{server-DXfSgbuj.mjs → server-DQ0wuuLG.mjs} +4388 -3021
- package/dist/{sha2-BfCJmkJJ.mjs → sha2-Daa2Fiv1.mjs} +7411 -5229
- package/package.json +1 -1
- package/dist/AcpMcpStdioBridge-DbCGhPmy.mjs +0 -3
- package/dist/client/assets/AlertDialogRoot-COfNlajP.js +0 -2
- package/dist/client/assets/ChatGptUsageButton-C9D5JFWr.js +0 -2
- package/dist/client/assets/ChatMarkdown-Ck4FJs_Q.js +0 -49
- package/dist/client/assets/CodexSetupSection.logic-DzEO1qoo.js +0 -2
- package/dist/client/assets/ConnectAgentSurface-6FVydN17.js +0 -2
- package/dist/client/assets/DevicePanel-B3CR7kGX.js +0 -2
- package/dist/client/assets/DeviceSetup-Lxy9dmqi.js +0 -2
- package/dist/client/assets/DialogTitle-5cBExuFs.js +0 -2
- package/dist/client/assets/DiffPanel-KfudIZct.js +0 -2
- package/dist/client/assets/Input-DWc7cRWt.js +0 -2
- package/dist/client/assets/JZOYTAAL-BqUoPKcz.js +0 -1
- package/dist/client/assets/LinkMachineSelect-DoqwB0AR.js +0 -2
- package/dist/client/assets/P4ConnectAccountPages-Ca1o0JuS.js +0 -2
- package/dist/client/assets/PanelLayoutControls-CoWjUmx7.js +0 -216
- package/dist/client/assets/PreviewPanel-BHj7Mvmn.js +0 -2
- package/dist/client/assets/ProviderModelPicker-DQ3N8RWz.js +0 -2
- package/dist/client/assets/PullRequestCodeTab-BTwbK3zR.js +0 -6
- package/dist/client/assets/RenderErrorBoundary-CYsCxleQ.js +0 -23
- package/dist/client/assets/ScheduledTasksSettings-CpfGXMow.js +0 -6
- package/dist/client/assets/ThreadTerminalDrawer-PkBB7D3Z.js +0 -5
- package/dist/client/assets/TooltipProvider-DiV5KdTq.js +0 -2
- package/dist/client/assets/_chat-PsMoIPUC.js +0 -47
- package/dist/client/assets/_chat.design-CWE-keji.js +0 -2
- package/dist/client/assets/_chat.pull-requests-C90JBKAN.js +0 -2
- package/dist/client/assets/alert-dialog-DsMTn0ZK.js +0 -2
- package/dist/client/assets/assets-5kUNv3CS.js +0 -2
- package/dist/client/assets/combobox-D6RfzdE7.js +0 -2
- package/dist/client/assets/command-1dJ-vX2N.js +0 -2
- package/dist/client/assets/connect-agent-B22xdP4o.js +0 -2
- package/dist/client/assets/dialog-5OaxRXCC.js +0 -2
- package/dist/client/assets/entities-DOpLfnwX.js +0 -2
- package/dist/client/assets/main-C04YJQbN.js +0 -38
- package/dist/client/assets/main-i3nSjwXu.css +0 -2
- package/dist/client/assets/mediaReference-D4rhlY-i.js +0 -2
- package/dist/client/assets/number-field-BkDsfSCt.js +0 -2
- package/dist/client/assets/openFileInPreview-XKgvCQ1z.js +0 -2
- package/dist/client/assets/popover-hyDlWUPU.js +0 -2
- package/dist/client/assets/primary-BXI66byW.js +0 -2
- package/dist/client/assets/primaryCloudLinkState-DswWb__m.js +0 -2
- package/dist/client/assets/projectScriptEditor-DvKvgTs-.js +0 -2
- package/dist/client/assets/pullRequestDetail.logic-DQj9l9DL.js +0 -10
- package/dist/client/assets/queries-BA_altUI.js +0 -2
- package/dist/client/assets/relay-CTdDIWLg.js +0 -2
- package/dist/client/assets/runtime-BvdQMwVb.js +0 -7
- package/dist/client/assets/session-logic-2ZMapwqV.js +0 -27
- package/dist/client/assets/settings.archived-BF0zdtbV.js +0 -2
- package/dist/client/assets/settings.connections-CoxujVuf.js +0 -2
- package/dist/client/assets/settings.diagnostics-CwCeo1mG.js +0 -2
- package/dist/client/assets/settings.integrations-2RsLmeUi.js +0 -2
- package/dist/client/assets/settings.providers-4HI8om0T.js +0 -3
- package/dist/client/assets/settings.storage-Cy6oX7X3.js +0 -2
- package/dist/client/assets/settingsLayout-YTaL8Lym.js +0 -3
- package/dist/client/assets/sidebar-4oe_dr6q.js +0 -2
- package/dist/client/assets/src-R7EkrVcv.js +0 -15
- package/dist/client/assets/terminal-links-BdsGDJ3O.js +0 -2
- package/dist/client/assets/terminalSessions-yZRa64tn.js +0 -2
- package/dist/client/assets/usage-CdxC8YNe.js +0 -2
- package/dist/client/assets/useHandleNewThread-Cv_08eER.js +0 -2
- package/dist/client/assets/usePullRequestActions-BHv9tRFF.js +0 -3
- package/dist/client/assets/useSettings-BhGGZc98.js +0 -3
- package/dist/client/assets/utils-DkKLB01I.js +0 -24
- package/dist/client/assets/vcsRefInvalidation-71d-99uY.js +0 -2
- package/dist/client/assets/welcome-Ytf7jmR7.js +0 -2
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { i as __toESM, r as __require, t as __commonJSMin } from "./rolldown-runtime-CMoAvOD_.mjs";
|
|
4
|
-
import { $ as
|
|
5
|
-
import { $r as
|
|
6
|
-
import { $
|
|
7
|
-
import { $
|
|
8
|
-
import {
|
|
4
|
+
import { $l as equals, $r as addFinalizerExit, $t as runForkWith, Ar as monotonicTimeNanos, At as matchCauseEffectEager, Bc as getOrElse, Bn as withLogger, Bo as make$27, C as catchTag, Ca as pretty, Cc as isFailure, Ci as isDone, Cn as timeoutOrElse, Cs as zero, D as context, Do as tracerLogger$1, Ea as squash, Ei as makeUnsafe$1, Eo as sync, Er as Clock, Es as add, Et as mapError, Fc as flatMap$1, Fl as format, Fr as effect, Ft as onExitPrimitive, G as filterOrFail, Gc as isNone, Gr as succeed$1, Hn as withSpan, Hr as mergeAll, Ht as provide, Hu as flow, I as fail, Ia as causePretty, Is as merge$1, J as flatMap, Jr as sync$1, Jt as repeat, K as findFirst, Ko as Class, Kt as race, Ku as pipe, L as failCause, La as consolePretty$1, Ll as formatJson$1, Ln as withFiber, Lr as effectDiscard, Lt as option, M as die, Mi as failCause$1, Ml as Class$1, Mr as build, Nc as filter, Nn as void_, Ns as getUnsafe, Nt as onError, Oa as ConsoleRef, Oi as succeed$2, Ol as withFiber$1, Or as currentTimeMillis, Os as get, P as ensuring, Ps as make$29, Pt as onExit, Q as fnUntraced$1, Qc as none, Qr as addFinalizer, Qt as runFork, Rc as fromNullishOr, Ri as isSuccess, Ro as Tracer, Rt as orDie, Sn as timeoutOption, St as map$1, T as catch_, Tc as isSuccess$1, Ti as make$30, Tl as isEffect, Tn as try_, Ts as Service, Tt as mapEager, Uo as encode, Ur as provide$1, Us as ensure, Uu as identity, Vc as getOrNull, Vi as void_$1, Vo as nativeTracer, Vr as merge, Vu as dual, Wc as getOrUndefined, Wl as assignProperty, Wn as withTracerEnabled, Wo as random, Wr as provideMerge, Wt as provideService, Xc as map$3, Xi as combine, Xr as unwrap, Xs as flatMapNullishOr, Xt as result, Y as flatMapEager, Ya as fiberEnterUninterruptibleUnsafe, Yo as TaggedError, Z as fn, Zc as match, Zi as die$1, Zr as Scope, Zt as retry, _n as tapCause, _o as reportCauseUnsafe, _s as seconds, _t as logError, a as all, ai as makeUnsafe, an as scope, as as hours, at as forkScoped, ba as makeFailReason, bl as contE, bs as toMillis, bt as logWarning, c as annotateLogs, ca as hasInterruptsOnly, cn as service, cr as forever, ct as gen, d as asSome, dl as make$28, dn as succeed, ds as max, ec as isArrayNonEmpty, ei as close, el as some, et as forEach, f as asVoid, fa as isDieReason, fc as sort, fn as succeedNone, fs as millis, ft as interruptible, g as catchCause, gi as done, gn as tap, gr as spaced, gt as logDebug, h as callback, hn as sync$2, ht as log$1, i as addFinalizer$1, ia as fromReasons, ii as make$31, il as Number$1, io as fnUntraced, is as fromInputUnsafe, it as forkIn, jn as updateContext, jt as matchEffect, ka as CurrentLoggers$1, kn as uninterruptible, kt as matchCauseEffect, li as CurrentLogSpans, lt as ignore, ma as isFailReason, mi as _await, mn as suspend, mr as passthrough, ms as minutes, n as acquireRelease, nn as runSync, o as andThen, oi as provide$2, on as scoped, or as addDelay, os as infinity, p as cached, pn as succeedSome, pt as isEffect$1, pu as hasProperty, qc as isSome, qt as raceFirst, ri as forkUnsafe, s as annotateCurrentSpan, sc as map$2, si as CurrentLogAnnotations, st as fromResult, ti as closeUnsafe, ts as days, tt as forever$1, u as as, un as sleep, uo as loggerMake, ut as ignoreCause, v as catchDefect, vs as sum, w as catchTags, wa as prettyErrors, wn as tryPromise, ws as Reference, wu as isObject, x as catchIf, xc as getOrThrow, xn as timeout, xo as structuredMessage, ya as makeDieReason, yl as contA, yn as tapError, yt as logInfo, za as effectIsExit, zc as fromUndefinedOr, zt as orElseSucceed, zu as constVoid } from "./Effect-BrI3bavz.mjs";
|
|
5
|
+
import { $r as fromInput, A as Number$2, Ai as make$32, At as fromJsonString, B as StringFromUriComponent, Bi as toEpochMillis, Ci as add$1, Cn as inetAddressFromIpString, Di as isGreaterThanOrEqualTo, Ei as isGreaterThan, F as Record, Hi as toUtc, Hr as fromInput$1, Ir as InvalidValue, Jt as isSchemaError, Ki as encode$1, Mt as is, Ni as now, Oi as isLessThan, R as SchemaError, S as Literals, T as Never, Ti as formatIso, Tt as encodeSync, U as TaggedError$1, Ur as redactUrl, V as Struct, Wt as isNonEmpty, bi as toSetCookieHeaders, bt as decodeUnknownOption, c as DateTimeUtc, di as value, ei as fromRecordUnsafe, et as UndefinedOr, gi as isEmpty, ii as parseRetryAfter, ji as makeUnsafe$2, k as NullOr, ki as isLessThanOrEqualTo, kn as unixPathAddress, l as DateTimeUtcFromString, n as ArraySchema, nn as optional, nt as Unknown, oi as retryAfterDelay$1, pt as decodeEffect, r as Boolean$1, ri as merge$2, rn as optionalKey, si as set, tt as Union, u as Defect, vi as parseHeader, vt as decodeUnknownEffect, wt as encodeEffect, x as Literal, y as Int, yt as decodeUnknownExit, z as String$1 } from "./Schema-06GeVid5.mjs";
|
|
6
|
+
import { $i as EnvironmentThemeId, Ad as TypeId$2, Ap as removeHeader, Bd as toPersisted, Bf as authScopeResponse, Cd as tracer, Cf as AuthMcpRegistrationError, Cm as raw, Cp as html, Cs as EnvironmentHttpApi, Dp as omitsBody, Ed as appendPreResponseHandlerUnsafe$1, Em as uint8Array, Fd as MultipartError, Ff as AuthWebSocketTicketUse, Fs as connectReachabilityHelpUrl, Fu as make$33, Gd as ClientAbort, Gp as schemaBodyJson, Hd as make$36, Hp as MaxBodySize, Hr as AgentAsset, Id as TypeId$1, Ip as text, Is as formatConnectReachable, Jd as RequestParseError, Js as RelayProtectedError, Kd as HttpServerError, Lf as MCP_PEER_LINK_SOFTWARE_ID, Lh as DpopFailureReason, Mf as AuthStandardClientScopes, Mh as ClientSurface, Mp as setHeader, Od as HttpServerRequest, Om as FileSystem, Op as raw$1, Pd as toURL, Qi as EnvironmentThemeFile, Qp as bodyJsonUnsafe, Qu as serve, Rf as ServerAuthSessionMethod, Rh as EnvironmentId, Sd as isTracerDisabledUnsafe, Sf as AuthMcpClientAccess, Td as RequestState, Th as AuthSessionId, Ud as Path, Up as TypeId, Vd as decodeField, Vf as mcpClientScopes, Wp as inspect, Xd as ServeError, Xr as PeerLinkError, Yd as ResponseError, Yr as agentAssetTotalBytes, Zd as causeResponse, _d as transform, _f as AuthEnvironmentScopes, _p as isCloseEvent, a as abytes$1, c as anumber, ca as EDITORS, cm as put, cp as SocketError, cu as McpServerConfig, d as concatBytes$1, da as ExternalLauncherEditorSpawnError, dp as SocketReadError, ed as HttpServer, f as randomBytes, fa as ExternalLauncherUnknownEditorError, ff as AuthAccessTokenType, fp as SocketUpgradeError, gd as tapError$1, gf as AuthEnvironmentMaintainScope, gp as fromWebSocket, hd as tap$1, i as Hash, ia as environmentThemeFileHasColors, id as HttpClient, if as layerWeak, im as get$1, jl as RuntimeMode, jp as setBody$1, la as ExternalLauncherBrowserSpawnError, lm as setBody, lu as McpServerId, ma as ExternalLauncherUnsupportedTargetError, md as retryTransient, mf as AuthClientMetadataDeviceType, n as sha384, nf as make$35, nm as compressBody, o as aexists, od as TracerPropagationEnabled, om as post, p as toBytes, pa as ExternalLauncherUnsupportedEditorError, pf as AuthAccessWriteScope, pp as SocketWriteError, qd as InternalError, qr as AgentAssetName, qu as add$2, r as sha512, rd as make$37, rf as layer$23, rm as del, s as ahash, sd as filterStatusOk, sf as ORCHESTRATION_PROTOCOL_HEADER, sp as SocketCloseError, t as sha256, tf as HttpPlatform, tm as bodyUrlParams, u as clean, ua as ExternalLauncherCommandNotFoundError, um as setHeader$1, up as SocketOpenError, vd as transformResponse, wd as CurrentRequestState, wf as AuthMcpTokenError, wm as stream$1, wp as isHttpServerResponse, xm as isHttpClientError, xp as empty, yd as withScope, yp as make$34, zd as makeConfig, zp as filterStatusOk$1 } from "./sha2-Daa2Fiv1.mjs";
|
|
7
|
+
import { $ as mkString, Bn as makeUnsafe$3, Ct as suspend$1, Fn as take, Hn as await_, I as fromQueue, In as unbounded, K as mapArray, Nn as sliding$1, P as fromPubSub, Pn as subscribe, R as fromSubscription, Tn as take$1, U as make$40, Un as getCurrent, Vt as unwrap$1, W as map$4, Yn as runIn, _n as offer, _t as runForEachArray, b as filter$1, c as concat$1, gt as runForEach, in as make$39, kn as publish, l as debounce, mt as runFold, nt as orDie$1, u as decodeText, wn as sliding, xt as splitLines, zn as make$38 } from "./Stream-DKSvHopl.mjs";
|
|
8
|
+
import { $c as run$1, $l as Mac, $n as fromReadable, Ac as Terminal, Ao as readOnly, Ar as version$1, As as RotatingFileSink, Au as fail$1, Cn as layer$29, Co as PersistenceSqlError, Cu as layerWebCrypto$1, Dn as layerIdentity, Do as findOneOption, Dr as isSecretAlreadyExistsError, Ec as UserId, El as makeWith, Eo as findAll, Er as ServerSecretStore, Fc as make$45, Fl as modify, Il as set$1, Iu as WebCrypto, Lc as modifyEffect, Ll as update, Lu as CryptoError, Ml as getAndSet, Ms as OtlpSerialization, Ns as layerJson, Oo as void_$2, Or as isSecretStoreError, Pc as get$4, Pl as make$42, Pr as ServerConfig, Pu as run$2, Qc as make$41, Qn as MaxBytesError, Rl as updateAndGet, Ru as InvalidArgument, Sn as layer$30, So as PersistenceDecodeError, Su as SecureRandom, Tc as Platform, Tn as ServerEnvironmentIdentity, Uc as isSqlError, Vc as SqlClient, Xc as awaitEmpty, Zl as layerWebCrypto$5, _c as Architecture, _l as withDefault, al as NonEmptyString, ar as CLOUD_LINKED_USER_ID, au as timingSafeEqual, bu as layerWebCrypto$2, cc as withPathDirectoryListings, cl as Record$1, dr as RELAY_ISSUER_SECRET, ec as isCommandAvailable, el as runtime, er as pipeThroughDuplex, eu as hmacSha256, fl as all$1, fr as RELAY_URL_SECRET, fu as decode, gl as schema, gn as resolveClaudeConfigDirPath, gu as layerWebCrypto$4, hc as RequestInit, hl as option$1, ic as readPathFromLaunchctl, ir as CLOUD_ENDPOINT_RUNTIME_CONFIG, iu as layerWebCryptoWith, jc as isQuitError, jl as get$2, jr as writeFileStringAtomically, kc as QuitError, ko as layer$24, kr as layer$28, lc as make$44, lr as PUBLISH_AGENT_ACTIVITY_SECRET, lu as sha256$1, ml as mapEffect, mu as encode$2, nc as mergePathEntries, ni as ProjectionMaintenanceV2, nl as ConfigError, no as UNPUBLISHABLE_THEME_IDS, nr as toUint8Array, oc as resolveSpawnCommand, or as CLOUD_LINK_REVOKED, ou as Digest, pl as map$5, pu as decodeString, ql as layerWebCrypto$3, qo as ProcessRunner, rc as readEnvironmentFromLoginShell, ri as layer$25, ro as legacyThreadPullRequestKey, rr as CLOUD_ENDPOINT_CONFIRMED_ORIGIN, ru as key, sc as resolveWindowsEnvironment, si as layer$27, sr as CLOUD_MINT_PUBLIC_KEY, tc as listLoginShellCandidates, tr as toArrayBuffer, uc as ChildProcessSpawner, ul as String$2, ur as RELAY_ENVIRONMENT_CREDENTIAL_SECRET, vl as SourceError, vn as require_dist, vo as layer$26, wn as ServerEnvironment, xc as HomeDirectory, xn as make$43, xu as layerWebCryptoWith$1, yc as Environment, yl as get$3, zl as getType, zn as ServerSettingsService, zu as Unsupported } from "./preview-C_kKbIjf.mjs";
|
|
9
|
+
import { createRequire } from "node:module";
|
|
9
10
|
import * as Fs from "node:fs";
|
|
10
11
|
import * as NodeOS from "node:os";
|
|
11
12
|
import * as NodePath from "node:path";
|
|
12
|
-
import
|
|
13
|
+
import { Buffer as Buffer$1 } from "node:buffer";
|
|
13
14
|
import * as NodeCrypto from "node:crypto";
|
|
14
|
-
import * as
|
|
15
|
-
import { Duplex, Readable, pipeline } from "node:stream";
|
|
15
|
+
import * as NodeSqlite from "node:sqlite";
|
|
16
16
|
import * as NodeFSP from "node:fs/promises";
|
|
17
|
-
import * as
|
|
17
|
+
import * as NodeNet from "node:net";
|
|
18
|
+
import { Duplex, Readable, Transform, finished, pipeline } from "node:stream";
|
|
19
|
+
import * as NodeHttp from "node:http";
|
|
18
20
|
import * as NodeStreamP from "node:stream/promises";
|
|
19
21
|
import { pipeline as pipeline$1 } from "node:stream/promises";
|
|
22
|
+
import * as Tls from "node:tls";
|
|
20
23
|
import * as Zlib from "node:zlib";
|
|
21
|
-
// ../../node_modules/.pnpm/effect@4.
|
|
24
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/http/HttpEffect.js
|
|
22
25
|
/**
|
|
23
26
|
* Runs an HTTP server effect, sends the produced response with the supplied handler, and converts failures into HTTP responses.
|
|
24
27
|
* On handler failure, the request scope closes with the original cause.
|
|
@@ -37,7 +40,7 @@ const toHandled = (self, handleResponse, middleware) => {
|
|
|
37
40
|
return flatMapEager(causeResponse(cause), ([response, cause]) => {
|
|
38
41
|
const fiber = getCurrent();
|
|
39
42
|
reportCauseUnsafe(fiber, cause);
|
|
40
|
-
const handler =
|
|
43
|
+
const handler = frame.preResponseHandler;
|
|
41
44
|
const cont = cause.reasons.length === 0 ? succeed(response) : failCause(cause);
|
|
42
45
|
if (handler === void 0) {
|
|
43
46
|
request[handledSymbol] = true;
|
|
@@ -49,8 +52,9 @@ const toHandled = (self, handleResponse, middleware) => {
|
|
|
49
52
|
}), () => cont);
|
|
50
53
|
});
|
|
51
54
|
};
|
|
52
|
-
const sendResponse = (
|
|
53
|
-
const
|
|
55
|
+
const sendResponse = (frame, response) => {
|
|
56
|
+
const request = frame.request;
|
|
57
|
+
const handler = frame.preResponseHandler;
|
|
54
58
|
if (handler === void 0) {
|
|
55
59
|
request[handledSymbol] = true;
|
|
56
60
|
return mapEager(handleResponse(request, response), (sent) => isHttpServerResponse(sent) ? sent : response);
|
|
@@ -63,7 +67,7 @@ const toHandled = (self, handleResponse, middleware) => {
|
|
|
63
67
|
const withMiddleware = (frame) => {
|
|
64
68
|
const request = frame.request;
|
|
65
69
|
const responded = matchCauseEffect(self, {
|
|
66
|
-
onSuccess: (response) => sendResponse(
|
|
70
|
+
onSuccess: (response) => sendResponse(frame, response),
|
|
67
71
|
onFailure: (cause) => handleCause(frame, cause)
|
|
68
72
|
});
|
|
69
73
|
return middleware === void 0 ? responded : matchCauseEffect(tracer(middleware(responded)), {
|
|
@@ -90,18 +94,19 @@ const toHandled = (self, handleResponse, middleware) => {
|
|
|
90
94
|
if (scopeEjected in frame.scope) return void 0;
|
|
91
95
|
return closeUnsafe(frame.scope, frame.cause === void 0 ? exit : failCause$1(frame.cause));
|
|
92
96
|
}, true);
|
|
93
|
-
class RequestFrame {
|
|
97
|
+
class RequestFrame extends RequestState {
|
|
94
98
|
scope;
|
|
95
99
|
prev;
|
|
96
100
|
request;
|
|
97
101
|
cause;
|
|
98
102
|
constructor(scope, prev, request) {
|
|
103
|
+
super();
|
|
99
104
|
this.scope = scope;
|
|
100
105
|
this.prev = prev;
|
|
101
106
|
this.request = request;
|
|
102
107
|
}
|
|
103
108
|
[contA](response, fiber) {
|
|
104
|
-
const sent = sendResponse(this
|
|
109
|
+
const sent = sendResponse(this, response);
|
|
105
110
|
if (effectIsExit(sent) && sent._tag === "Success") {
|
|
106
111
|
fiber.setContext(this.prev);
|
|
107
112
|
if (scopeEjected in this.scope) return sent;
|
|
@@ -118,7 +123,7 @@ const toHandled = (self, handleResponse, middleware) => {
|
|
|
118
123
|
fiberEnterUninterruptibleUnsafe(fiber);
|
|
119
124
|
const scope = makeUnsafe();
|
|
120
125
|
const frame = new RequestFrame(scope, fiber.context, getUnsafe(fiber.context, HttpServerRequest));
|
|
121
|
-
fiber.setContext(add(frame.prev, Scope, scope));
|
|
126
|
+
fiber.setContext(add(add(frame.prev, Scope, scope), CurrentRequestState, frame));
|
|
122
127
|
const currentTracer = fiber.cache.tracer;
|
|
123
128
|
if (middleware === void 0 && (currentTracer === void 0 || currentTracer === nativeTracer || isTracerDisabledUnsafe(fiber, frame.request))) {
|
|
124
129
|
fiber._stack.push(frame);
|
|
@@ -136,19 +141,28 @@ const scopeEjected = /*#__PURE__*/ Symbol.for("effect/http/HttpEffect/scopeEject
|
|
|
136
141
|
* @category handlers
|
|
137
142
|
* @since 4.0.0
|
|
138
143
|
*/
|
|
139
|
-
const appendPreResponseHandler = (handler) =>
|
|
140
|
-
appendPreResponseHandlerUnsafe(request, handler);
|
|
141
|
-
return void_;
|
|
142
|
-
});
|
|
144
|
+
const appendPreResponseHandler = (handler) => withPreResponseHandler(void_, handler);
|
|
143
145
|
/**
|
|
144
|
-
* Registers a pre-response handler for the
|
|
146
|
+
* Registers a pre-response handler for the HTTP server request that owns the
|
|
147
|
+
* supplied fiber context. Does nothing outside a server request.
|
|
145
148
|
*
|
|
146
149
|
* @stability unstable
|
|
147
150
|
* @category unsafe
|
|
148
151
|
* @since 4.0.0
|
|
149
152
|
*/
|
|
150
153
|
const appendPreResponseHandlerUnsafe = appendPreResponseHandlerUnsafe$1;
|
|
151
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Runs an effect after registering a pre-response handler for the current HTTP server request.
|
|
156
|
+
*
|
|
157
|
+
* @stability unstable
|
|
158
|
+
* @category handlers
|
|
159
|
+
* @since 4.0.0
|
|
160
|
+
*/
|
|
161
|
+
const withPreResponseHandler = /*#__PURE__*/ dual(2, (self, handler) => withFiber((fiber) => {
|
|
162
|
+
appendPreResponseHandlerUnsafe(fiber.context, handler);
|
|
163
|
+
return self;
|
|
164
|
+
}));
|
|
165
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Console.js
|
|
152
166
|
/**
|
|
153
167
|
* Context reference for the current console service in the Effect system, allowing access to the active console implementation from within the Effect context.
|
|
154
168
|
*
|
|
@@ -321,7 +335,7 @@ const log = (...args) => consoleWith((console) => sync(() => {
|
|
|
321
335
|
const warn = (...args) => consoleWith((console) => sync(() => {
|
|
322
336
|
console.warn(...args);
|
|
323
337
|
}));
|
|
324
|
-
// ../../node_modules/.pnpm/effect@4.
|
|
338
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Logger.js
|
|
325
339
|
/**
|
|
326
340
|
* Defines loggers and log-event data for Effect programs.
|
|
327
341
|
*
|
|
@@ -438,7 +452,7 @@ const formatFiberId = (fiberId) => `#${fiberId}`;
|
|
|
438
452
|
* @category constructors
|
|
439
453
|
* @since 2.0.0
|
|
440
454
|
*/
|
|
441
|
-
const make$
|
|
455
|
+
const make$26 = loggerMake;
|
|
442
456
|
/**
|
|
443
457
|
* A `Logger` which outputs logs using a structured format serialized as JSON
|
|
444
458
|
* on a single line.
|
|
@@ -603,12 +617,12 @@ const tracerLogger = tracerLogger$1;
|
|
|
603
617
|
* @category layers
|
|
604
618
|
* @since 4.0.0
|
|
605
619
|
*/
|
|
606
|
-
const layer$
|
|
620
|
+
const layer$22 = (loggers, options) => effect(CurrentLoggers, withFiber$1(fnUntraced(function* (fiber) {
|
|
607
621
|
const currentLoggers = new Set(options?.mergeWithExisting === true ? fiber.getRef(CurrentLoggers$1) : []);
|
|
608
622
|
for (const logger of loggers) currentLoggers.add(isEffect(logger) ? yield* logger : logger);
|
|
609
623
|
return currentLoggers;
|
|
610
624
|
})));
|
|
611
|
-
// ../../node_modules/.pnpm/effect@4.
|
|
625
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Runtime.js
|
|
612
626
|
/**
|
|
613
627
|
* Helpers for turning an `Effect` program into a host application's main entry
|
|
614
628
|
* point. This module is the low-level layer used by platform adapters to run a
|
|
@@ -680,9 +694,9 @@ const defaultTeardown = (exit, onExit) => {
|
|
|
680
694
|
*
|
|
681
695
|
* **Details**
|
|
682
696
|
*
|
|
683
|
-
* The
|
|
684
|
-
*
|
|
685
|
-
*
|
|
697
|
+
* The setup function runs before user code and receives the main fiber and a
|
|
698
|
+
* teardown callback to install platform-specific signal handlers, observers,
|
|
699
|
+
* and exit behavior.
|
|
686
700
|
*
|
|
687
701
|
* Most applications should use a platform-provided runner, such as
|
|
688
702
|
* `NodeRuntime.runMain`, rather than constructing one directly.
|
|
@@ -737,20 +751,24 @@ const defaultTeardown = (exit, onExit) => {
|
|
|
737
751
|
* @since 4.0.0
|
|
738
752
|
*/
|
|
739
753
|
const makeRunMain = (f) => dual((args) => isEffect$1(args[0]), (effect, options) => {
|
|
740
|
-
const
|
|
754
|
+
const main = options?.disableErrorReporting === true ? effect : tapCause(effect, (cause) => {
|
|
741
755
|
if (hasInterruptsOnly(cause)) return void_;
|
|
742
756
|
return getErrorReported(squash(cause)) ? logError(cause) : void_;
|
|
743
|
-
}));
|
|
744
|
-
try {
|
|
745
|
-
const keepAlive = globalThis.setInterval(constVoid, 2147483647);
|
|
746
|
-
fiber.addObserver(() => {
|
|
747
|
-
clearInterval(keepAlive);
|
|
748
|
-
});
|
|
749
|
-
} catch {}
|
|
750
|
-
return f({
|
|
751
|
-
fiber,
|
|
752
|
-
teardown: options?.teardown ?? defaultTeardown
|
|
753
757
|
});
|
|
758
|
+
const teardown = options?.teardown ?? defaultTeardown;
|
|
759
|
+
runFork(withFiber((fiber) => {
|
|
760
|
+
try {
|
|
761
|
+
const keepAlive = globalThis.setInterval(constVoid, 2147483647);
|
|
762
|
+
fiber.addObserver(() => {
|
|
763
|
+
clearInterval(keepAlive);
|
|
764
|
+
});
|
|
765
|
+
} catch {}
|
|
766
|
+
f({
|
|
767
|
+
fiber,
|
|
768
|
+
teardown
|
|
769
|
+
});
|
|
770
|
+
return main;
|
|
771
|
+
}));
|
|
754
772
|
});
|
|
755
773
|
/**
|
|
756
774
|
* Allows associating an exit code with an error for determining the process
|
|
@@ -898,14 +916,14 @@ const getErrorReported = (u) => {
|
|
|
898
916
|
}
|
|
899
917
|
return true;
|
|
900
918
|
};
|
|
901
|
-
// ../../node_modules/.pnpm/effect@4.
|
|
919
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/Version.js
|
|
902
920
|
/**
|
|
903
921
|
* The `effect` package version used in telemetry headers, resources, and scopes.
|
|
904
922
|
*
|
|
905
923
|
* @stability unstable
|
|
906
924
|
* @since 4.0.2
|
|
907
925
|
*/
|
|
908
|
-
let currentVersion = "4.
|
|
926
|
+
let currentVersion = "4.1.2";
|
|
909
927
|
/**
|
|
910
928
|
* Returns the current version of the `effect` package.
|
|
911
929
|
*
|
|
@@ -918,7 +936,7 @@ let currentVersion = "4.0.4";
|
|
|
918
936
|
* @since 4.0.2
|
|
919
937
|
*/
|
|
920
938
|
const getCurrentVersion = () => currentVersion;
|
|
921
|
-
// ../../node_modules/.pnpm/effect@4.
|
|
939
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/observability/OtlpExporter.js
|
|
922
940
|
/**
|
|
923
941
|
* Shared batch exporter for OTLP/HTTP observability modules.
|
|
924
942
|
*
|
|
@@ -931,12 +949,9 @@ const getCurrentVersion = () => currentVersion;
|
|
|
931
949
|
* @since 4.0.0
|
|
932
950
|
*/
|
|
933
951
|
const retryAfterDelay = (value) => {
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
936
|
-
|
|
937
|
-
const timestamp = Date.parse(value);
|
|
938
|
-
if (Number.isNaN(timestamp)) return succeed(seconds(5));
|
|
939
|
-
return map$1(Clock, (clock) => millis(Math.max(timestamp - clock.currentTimeMillisUnsafe(), 1)));
|
|
952
|
+
const retryAfter = value === void 0 ? void 0 : parseRetryAfter(value);
|
|
953
|
+
if (retryAfter === void 0 || isFailure(retryAfter)) return succeed(seconds(5));
|
|
954
|
+
return map$1(Clock, (clock) => retryAfterDelay$1(retryAfter.success, clock.currentTimeMillisUnsafe()));
|
|
940
955
|
};
|
|
941
956
|
const policy = /*#__PURE__*/ forever.pipe(passthrough, /*#__PURE__*/ addDelay(({ output: error }) => {
|
|
942
957
|
if (isHttpClientError(error) && error.reason._tag === "StatusCodeError" && error.reason.response.status === 429) return retryAfterDelay(error.reason.response.headers["retry-after"]);
|
|
@@ -1007,34 +1022,50 @@ const layerFlusher = /*#__PURE__*/ sync$1(Flusher, () => {
|
|
|
1007
1022
|
* after unhandled failures, and flushes during scope finalization up to
|
|
1008
1023
|
* `shutdownTimeout`.
|
|
1009
1024
|
*
|
|
1025
|
+
* The export interval starts with the first push and stops once an export
|
|
1026
|
+
* empties the buffer, so an idle exporter keeps no timer pending. With
|
|
1027
|
+
* `exportEmpty` and batching disabled, it exports on every interval instead.
|
|
1028
|
+
*
|
|
1029
|
+
* Optional gzip compression uses `HttpClientRequest.compressBody` before the
|
|
1030
|
+
* retry loop, so retries reuse the compressed bytes. Bodies smaller than 1KB
|
|
1031
|
+
* remain uncompressed. Compression requires runtime `CompressionStream` support;
|
|
1032
|
+
* compression failures follow the same temporary-disable behavior as transport
|
|
1033
|
+
* failures and do not fail flushing or shutdown.
|
|
1034
|
+
*
|
|
1010
1035
|
* @stability unstable
|
|
1011
1036
|
* @category constructors
|
|
1012
1037
|
* @since 4.0.0
|
|
1013
1038
|
*/
|
|
1014
|
-
const make$
|
|
1039
|
+
const make$25 = /*#__PURE__*/ fnUntraced$1(function* (options) {
|
|
1015
1040
|
const services = yield* context();
|
|
1016
1041
|
const clock = get(services, Clock);
|
|
1017
1042
|
const scope = get(services, Scope);
|
|
1018
1043
|
const exportInterval = max(fromInputUnsafe(options.exportInterval), zero);
|
|
1019
|
-
let disabledUntil = void 0;
|
|
1020
1044
|
const client = get(services, HttpClient).pipe(tap$1((response) => ignore(response.arrayBuffer)), tapError$1((error) => error.response ? ignore(error.response.arrayBuffer) : void_), filterStatusOk, transformResponse(provideService(TracerPropagationEnabled, false)), retryTransient({
|
|
1021
1045
|
schedule: policy,
|
|
1022
1046
|
times: 3
|
|
1023
1047
|
}));
|
|
1024
1048
|
const exporterUserAgent = `OTel-OTLP-Exporter-JavaScript-Effect-${options.label}/${getCurrentVersion()}`;
|
|
1025
|
-
const userHeaders = fromInput
|
|
1049
|
+
const userHeaders = fromInput(options.headers);
|
|
1026
1050
|
const userAgent = userHeaders["user-agent"];
|
|
1027
|
-
const headers = set
|
|
1051
|
+
const headers = set(userHeaders, "user-agent", userAgent ? `${userAgent} ${exporterUserAgent}` : exporterUserAgent);
|
|
1028
1052
|
const request = post(options.url, { headers });
|
|
1053
|
+
const exportsEmpty = options.maxBatchSize === "disabled" && options.exportEmpty === true;
|
|
1029
1054
|
let buffer = [];
|
|
1055
|
+
let disabledUntil = void 0;
|
|
1056
|
+
const isDisabled = () => {
|
|
1057
|
+
if (disabledUntil === void 0) return false;
|
|
1058
|
+
if (clock.currentTimeMillisUnsafe() < disabledUntil) return true;
|
|
1059
|
+
disabledUntil = void 0;
|
|
1060
|
+
return false;
|
|
1061
|
+
};
|
|
1030
1062
|
const runExport = suspend(() => {
|
|
1031
|
-
if (
|
|
1032
|
-
else if (disabledUntil !== void 0) disabledUntil = void 0;
|
|
1033
|
-
if (buffer.length === 0 && (options.maxBatchSize !== "disabled" || options.exportEmpty !== true)) return void_;
|
|
1063
|
+
if (isDisabled() || buffer.length === 0 && !exportsEmpty) return void_;
|
|
1034
1064
|
const items = buffer;
|
|
1035
1065
|
buffer = [];
|
|
1036
1066
|
const [body, onSuccess] = options.body(items);
|
|
1037
|
-
|
|
1067
|
+
const batchRequest = setBody(request, body);
|
|
1068
|
+
return (options.compression === "gzip" ? compressBody(batchRequest, "gzip").pipe(flatMap(client.execute)) : client.execute(batchRequest)).pipe(andThen(onSuccess), asVoid, withTracerEnabled(false));
|
|
1038
1069
|
}).pipe(catchCause((cause) => {
|
|
1039
1070
|
if (disabledUntil !== void 0) return void_;
|
|
1040
1071
|
disabledUntil = clock.currentTimeMillisUnsafe() + 6e4;
|
|
@@ -1044,22 +1075,38 @@ const make$23 = /*#__PURE__*/ fnUntraced$1(function* (options) {
|
|
|
1044
1075
|
package: "@effect/opentelemetry",
|
|
1045
1076
|
module: options.label
|
|
1046
1077
|
}));
|
|
1047
|
-
const exportFibers = yield* make$
|
|
1078
|
+
const exportFibers = yield* make$41();
|
|
1048
1079
|
const runExportFork = yield* runtime(exportFibers)();
|
|
1049
|
-
yield* (yield* Flusher).register(runExport);
|
|
1050
1080
|
yield* addFinalizer(scope, suspend(() => {
|
|
1051
1081
|
if (disabledUntil !== void 0) return void_;
|
|
1052
1082
|
runExportFork(runExport);
|
|
1053
1083
|
return awaitEmpty(exportFibers);
|
|
1054
1084
|
}).pipe(ignore, interruptible, timeoutOption(options.shutdownTimeout)));
|
|
1055
|
-
|
|
1085
|
+
const armed = yield* make$38(exportsEmpty);
|
|
1086
|
+
const wake = yield* make$38();
|
|
1087
|
+
const disarmIfEmpty = sync$2(() => {
|
|
1088
|
+
if (exportsEmpty || buffer.length > 0 || !armed.closeUnsafe()) return;
|
|
1089
|
+
wake.openUnsafe();
|
|
1090
|
+
});
|
|
1091
|
+
yield* gen(function* () {
|
|
1092
|
+
while (true) {
|
|
1093
|
+
wake.closeUnsafe();
|
|
1094
|
+
yield* armed.await;
|
|
1095
|
+
yield* race(sleep(exportInterval), wake.await);
|
|
1096
|
+
yield* await_(yield* run$1(exportFibers, runExport));
|
|
1097
|
+
yield* disarmIfEmpty;
|
|
1098
|
+
}
|
|
1099
|
+
}).pipe(forkIn(scope));
|
|
1100
|
+
const exportNow = andThen(runExport, disarmIfEmpty);
|
|
1101
|
+
yield* (yield* Flusher).register(exportNow);
|
|
1056
1102
|
return { push(data) {
|
|
1057
|
-
if (
|
|
1103
|
+
if (isDisabled()) return;
|
|
1058
1104
|
buffer.push(data);
|
|
1059
|
-
if (options.maxBatchSize !== "disabled" && buffer.length >= options.maxBatchSize) runExportFork(
|
|
1105
|
+
if (options.maxBatchSize !== "disabled" && buffer.length >= options.maxBatchSize) runExportFork(exportNow);
|
|
1106
|
+
else armed.openUnsafe();
|
|
1060
1107
|
} };
|
|
1061
1108
|
});
|
|
1062
|
-
// ../../node_modules/.pnpm/effect@4.
|
|
1109
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/observability/OtlpResource.js
|
|
1063
1110
|
/**
|
|
1064
1111
|
* Builds OTLP resource metadata shared by exported telemetry.
|
|
1065
1112
|
*
|
|
@@ -1085,7 +1132,7 @@ const isBrowser = "window" in globalThis || "importScripts" in globalThis;
|
|
|
1085
1132
|
* @category constructors
|
|
1086
1133
|
* @since 4.0.0
|
|
1087
1134
|
*/
|
|
1088
|
-
const make$
|
|
1135
|
+
const make$24 = (options) => ({
|
|
1089
1136
|
attributes: entriesToAttributes(Object.entries({
|
|
1090
1137
|
"telemetry.sdk.name": "effect",
|
|
1091
1138
|
"telemetry.sdk.language": isBrowser ? "webjs" : "nodejs",
|
|
@@ -1115,12 +1162,22 @@ const make$22 = (options) => ({
|
|
|
1115
1162
|
* precedence over matching attributes in `OTEL_RESOURCE_ATTRIBUTES`. Missing
|
|
1116
1163
|
* required configuration is converted to a defect.
|
|
1117
1164
|
*
|
|
1165
|
+
* Keys and values in `OTEL_RESOURCE_ATTRIBUTES` are trimmed, then
|
|
1166
|
+
* percent-decoded. Entries with an empty value are kept as `""`; entries
|
|
1167
|
+
* without `=` or with an empty key are skipped. When a key is repeated as
|
|
1168
|
+
* written, the last entry wins and the earlier ones are not decoded. Invalid
|
|
1169
|
+
* percent-encoding in the remaining entries is a `ConfigError` and is
|
|
1170
|
+
* converted to a defect.
|
|
1171
|
+
*
|
|
1118
1172
|
* @stability unstable
|
|
1119
1173
|
* @category constructors
|
|
1120
1174
|
* @since 4.0.0
|
|
1121
1175
|
*/
|
|
1122
1176
|
const fromConfig = /*#__PURE__*/ fnUntraced$1(function* (options) {
|
|
1123
|
-
const env = yield* Record$1(StringFromUriComponent, StringFromUriComponent, "OTEL_RESOURCE_ATTRIBUTES"
|
|
1177
|
+
const env = yield* Record$1(StringFromUriComponent, StringFromUriComponent, "OTEL_RESOURCE_ATTRIBUTES", {
|
|
1178
|
+
trim: true,
|
|
1179
|
+
keepEmptyValues: true
|
|
1180
|
+
}).pipe(withDefault(void 0));
|
|
1124
1181
|
const serviceName = options?.serviceName ?? options?.attributes?.["service.name"] ?? (yield* schema(UndefinedOr(String$1), "OTEL_SERVICE_NAME")) ?? env?.["service.name"] ?? (yield* String$2("OTEL_SERVICE_NAME"));
|
|
1125
1182
|
const serviceVersion = options?.serviceVersion ?? options?.attributes?.["service.version"] ?? (yield* schema(UndefinedOr(String$1), "OTEL_SERVICE_VERSION")) ?? env?.["service.version"];
|
|
1126
1183
|
const attributes = {
|
|
@@ -1129,7 +1186,7 @@ const fromConfig = /*#__PURE__*/ fnUntraced$1(function* (options) {
|
|
|
1129
1186
|
};
|
|
1130
1187
|
delete attributes["service.name"];
|
|
1131
1188
|
delete attributes["service.version"];
|
|
1132
|
-
return make$
|
|
1189
|
+
return make$24({
|
|
1133
1190
|
serviceName,
|
|
1134
1191
|
serviceVersion,
|
|
1135
1192
|
attributes
|
|
@@ -1171,13 +1228,16 @@ const entriesToAttributes = (entries) => {
|
|
|
1171
1228
|
});
|
|
1172
1229
|
return attributes;
|
|
1173
1230
|
};
|
|
1231
|
+
const int64Bound = 2 ** 63;
|
|
1174
1232
|
/**
|
|
1175
1233
|
* Converts an arbitrary JavaScript value into an OTLP `AnyValue`.
|
|
1176
1234
|
*
|
|
1177
1235
|
* **Details**
|
|
1178
1236
|
*
|
|
1179
1237
|
* Arrays are converted recursively, primitive values use their matching OTLP
|
|
1180
|
-
* fields, and unsupported values are formatted as strings.
|
|
1238
|
+
* fields, and unsupported values are formatted as strings. Integers outside the
|
|
1239
|
+
* signed 64-bit range fall back to `doubleValue` for numbers and `stringValue`
|
|
1240
|
+
* for bigints.
|
|
1181
1241
|
*
|
|
1182
1242
|
* @stability unstable
|
|
1183
1243
|
* @category attributes
|
|
@@ -1187,13 +1247,13 @@ const unknownToAttributeValue = (value) => {
|
|
|
1187
1247
|
if (Array.isArray(value)) return { arrayValue: { values: value.map(unknownToAttributeValue) } };
|
|
1188
1248
|
switch (typeof value) {
|
|
1189
1249
|
case "string": return { stringValue: value };
|
|
1190
|
-
case "bigint": return { intValue: String(value) };
|
|
1191
|
-
case "number": return Number.isInteger(value) ? { intValue: value } : { doubleValue: value };
|
|
1250
|
+
case "bigint": return BigInt.asIntN(64, value) === value ? { intValue: String(value) } : { stringValue: String(value) };
|
|
1251
|
+
case "number": return Number.isInteger(value) && value >= -int64Bound && value < int64Bound ? { intValue: Number.isSafeInteger(value) ? value : String(BigInt(value)) } : { doubleValue: value };
|
|
1192
1252
|
case "boolean": return { boolValue: value };
|
|
1193
1253
|
default: return { stringValue: format(value) };
|
|
1194
1254
|
}
|
|
1195
1255
|
};
|
|
1196
|
-
// ../../node_modules/.pnpm/effect@4.
|
|
1256
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/observability/OtlpTracer.js
|
|
1197
1257
|
/**
|
|
1198
1258
|
* Exports Effect tracing spans over OTLP/HTTP.
|
|
1199
1259
|
*
|
|
@@ -1219,17 +1279,18 @@ const unknownToAttributeValue = (value) => {
|
|
|
1219
1279
|
* @category constructors
|
|
1220
1280
|
* @since 4.0.0
|
|
1221
1281
|
*/
|
|
1222
|
-
const make$
|
|
1282
|
+
const make$23 = /*#__PURE__*/ fnUntraced$1(function* (options) {
|
|
1223
1283
|
const otelResource = yield* fromConfig(options.resource);
|
|
1224
1284
|
const serialization = yield* OtlpSerialization;
|
|
1225
1285
|
const scope = {
|
|
1226
1286
|
name: "effect",
|
|
1227
1287
|
version: getCurrentVersion()
|
|
1228
1288
|
};
|
|
1229
|
-
const exporter = yield* make$
|
|
1289
|
+
const exporter = yield* make$25({
|
|
1230
1290
|
label: "OtlpTracer",
|
|
1231
1291
|
url: options.url,
|
|
1232
1292
|
headers: options.headers,
|
|
1293
|
+
compression: options.compression,
|
|
1233
1294
|
exportInterval: options.exportInterval ?? seconds(5),
|
|
1234
1295
|
maxBatchSize: options.maxBatchSize ?? 1e3,
|
|
1235
1296
|
body(spans) {
|
|
@@ -1248,7 +1309,7 @@ const make$21 = /*#__PURE__*/ fnUntraced$1(function* (options) {
|
|
|
1248
1309
|
if (!span.sampled) return;
|
|
1249
1310
|
exporter.push(makeOtlpSpan(span));
|
|
1250
1311
|
}
|
|
1251
|
-
return make$
|
|
1312
|
+
return make$27({
|
|
1252
1313
|
span(options) {
|
|
1253
1314
|
return new SpanImpl(options, exportFn);
|
|
1254
1315
|
},
|
|
@@ -1265,7 +1326,7 @@ const make$21 = /*#__PURE__*/ fnUntraced$1(function* (options) {
|
|
|
1265
1326
|
* @category layers
|
|
1266
1327
|
* @since 4.0.0
|
|
1267
1328
|
*/
|
|
1268
|
-
const layer$
|
|
1329
|
+
const layer$21 = /*#__PURE__*/ flow(make$23, /*#__PURE__*/ effect(Tracer), /*#__PURE__*/ provideMerge(layerFlusher));
|
|
1269
1330
|
var SpanImpl = class {
|
|
1270
1331
|
_tag = "Span";
|
|
1271
1332
|
name;
|
|
@@ -1306,6 +1367,7 @@ var SpanImpl = class {
|
|
|
1306
1367
|
return this._events ??= [];
|
|
1307
1368
|
}
|
|
1308
1369
|
end(endTime, exit) {
|
|
1370
|
+
if (this.status._tag === "Ended") return;
|
|
1309
1371
|
this.status = {
|
|
1310
1372
|
_tag: "Ended",
|
|
1311
1373
|
startTime: this.status.startTime,
|
|
@@ -1315,9 +1377,11 @@ var SpanImpl = class {
|
|
|
1315
1377
|
this.export(this);
|
|
1316
1378
|
}
|
|
1317
1379
|
attribute(key, value) {
|
|
1380
|
+
if (this.status._tag === "Ended") return;
|
|
1318
1381
|
this.attributes.set(key, value);
|
|
1319
1382
|
}
|
|
1320
1383
|
event(name, startTime, attributes) {
|
|
1384
|
+
if (this.status._tag === "Ended") return;
|
|
1321
1385
|
this.events.push([
|
|
1322
1386
|
name,
|
|
1323
1387
|
startTime,
|
|
@@ -1325,6 +1389,7 @@ var SpanImpl = class {
|
|
|
1325
1389
|
]);
|
|
1326
1390
|
}
|
|
1327
1391
|
addLinks(links) {
|
|
1392
|
+
if (this.status._tag === "Ended") return;
|
|
1328
1393
|
this.links.push(...links);
|
|
1329
1394
|
}
|
|
1330
1395
|
};
|
|
@@ -1379,14 +1444,14 @@ const makeOtlpSpan = (self) => {
|
|
|
1379
1444
|
for (let i = 0; i < self.links.length; i++) {
|
|
1380
1445
|
const link = self.links[i];
|
|
1381
1446
|
links.push({
|
|
1382
|
-
traceId: link.span.traceId,
|
|
1447
|
+
traceId: link.span.traceId.padStart(32, "0"),
|
|
1383
1448
|
spanId: link.span.spanId,
|
|
1384
1449
|
attributes: entriesToAttributes(Object.entries(link.attributes)),
|
|
1385
1450
|
droppedAttributesCount: 0
|
|
1386
1451
|
});
|
|
1387
1452
|
}
|
|
1388
1453
|
return {
|
|
1389
|
-
traceId: self.traceId,
|
|
1454
|
+
traceId: self.traceId.padStart(32, "0"),
|
|
1390
1455
|
spanId: self.spanId,
|
|
1391
1456
|
parentSpanId: isSome(self.parent) ? self.parent.value.spanId : void 0,
|
|
1392
1457
|
name: self.name,
|
|
@@ -1415,6 +1480,244 @@ const SpanKind = {
|
|
|
1415
1480
|
producer: 4,
|
|
1416
1481
|
consumer: 5
|
|
1417
1482
|
};
|
|
1483
|
+
// src/persistence/DatabaseMaintenance.ts
|
|
1484
|
+
var DatabaseMissingError = class extends TaggedError$1()("DatabaseMissingError", { path: String$1 }) {
|
|
1485
|
+
get message() {
|
|
1486
|
+
return "No existing P4 Code database was found in this data directory.";
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
var DatabaseInUseError = class extends TaggedError$1()("DatabaseInUseError", {
|
|
1490
|
+
path: String$1,
|
|
1491
|
+
cause: Defect()
|
|
1492
|
+
}) {
|
|
1493
|
+
get message() {
|
|
1494
|
+
return "Stop the P4 Code server and desktop app, including any version before 0.1.0, before repairing the database.";
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
var DatabaseProjectionsInvalidError = class extends TaggedError$1()("DatabaseProjectionsInvalidError", { path: String$1 }) {
|
|
1498
|
+
get message() {
|
|
1499
|
+
return "Database projections need repair before compaction. Start P4 Code once so it rebuilds them, then run doctor again. If this CLI is older than the one that wrote the database, update P4 Code first.";
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
var DatabaseInspectError = class extends TaggedError$1()("DatabaseInspectError", {
|
|
1503
|
+
path: String$1,
|
|
1504
|
+
cause: Defect()
|
|
1505
|
+
}) {
|
|
1506
|
+
get message() {
|
|
1507
|
+
return "Could not read the database. Check that this user can open it.";
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
var DatabaseCompactError = class extends TaggedError$1()("DatabaseCompactError", {
|
|
1511
|
+
path: String$1,
|
|
1512
|
+
cause: Defect()
|
|
1513
|
+
}) {
|
|
1514
|
+
get message() {
|
|
1515
|
+
return "Database compaction failed. Check that no other process has the database open and enough disk space is available.";
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
var LegacyDatabaseRemoveError = class extends TaggedError$1()("LegacyDatabaseRemoveError", {
|
|
1519
|
+
path: String$1,
|
|
1520
|
+
cause: Defect()
|
|
1521
|
+
}) {
|
|
1522
|
+
get message() {
|
|
1523
|
+
return "Could not delete the database from before 0.1.0. Check that this user can write to the data directory.";
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
var DiskSpaceCheckError = class extends TaggedError$1()("DiskSpaceCheckError", {
|
|
1527
|
+
path: String$1,
|
|
1528
|
+
cause: Defect()
|
|
1529
|
+
}) {
|
|
1530
|
+
get message() {
|
|
1531
|
+
return "Could not check free disk space.";
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
/** Offline inspection and repair of a P4 state database, for `p4c doctor`. */
|
|
1535
|
+
var DatabaseMaintenance = class extends Service()("@p4code/cli/persistence/DatabaseMaintenance") {};
|
|
1536
|
+
const isDomainError = is(Union([
|
|
1537
|
+
DatabaseMissingError,
|
|
1538
|
+
DatabaseInUseError,
|
|
1539
|
+
DatabaseProjectionsInvalidError
|
|
1540
|
+
]));
|
|
1541
|
+
const readStorage = gen(function* () {
|
|
1542
|
+
const sql = yield* SqlClient;
|
|
1543
|
+
const pages = yield* sql`PRAGMA page_count`;
|
|
1544
|
+
const free = yield* sql`PRAGMA freelist_count`;
|
|
1545
|
+
const size = yield* sql`PRAGMA page_size`;
|
|
1546
|
+
const mode = yield* sql`PRAGMA auto_vacuum`;
|
|
1547
|
+
const pageSize = size[0]?.page_size ?? 0;
|
|
1548
|
+
return {
|
|
1549
|
+
databaseBytes: (pages[0]?.page_count ?? 0) * pageSize,
|
|
1550
|
+
reclaimableBytes: (free[0]?.freelist_count ?? 0) * pageSize,
|
|
1551
|
+
incrementalVacuumEnabled: mode[0]?.auto_vacuum === 2
|
|
1552
|
+
};
|
|
1553
|
+
});
|
|
1554
|
+
/**
|
|
1555
|
+
* Holds an exclusive lock on the connection's database. In WAL mode this is
|
|
1556
|
+
* refused while any other connection has the file open, even an idle one,
|
|
1557
|
+
* which is how a running server or desktop app is detected.
|
|
1558
|
+
*/
|
|
1559
|
+
const lockExclusively = (databasePath) => gen(function* () {
|
|
1560
|
+
const sql = yield* SqlClient;
|
|
1561
|
+
yield* sql`PRAGMA busy_timeout = 0`;
|
|
1562
|
+
yield* sql`PRAGMA locking_mode = EXCLUSIVE`;
|
|
1563
|
+
yield* sql`BEGIN EXCLUSIVE`.pipe(mapError((cause) => isSqlError(cause) && cause.reason._tag === "LockTimeoutError" ? new DatabaseInUseError({
|
|
1564
|
+
path: databasePath,
|
|
1565
|
+
cause
|
|
1566
|
+
}) : cause));
|
|
1567
|
+
yield* sql`COMMIT`;
|
|
1568
|
+
});
|
|
1569
|
+
const make$22 = gen(function* () {
|
|
1570
|
+
const fs = yield* FileSystem;
|
|
1571
|
+
const path = yield* Path;
|
|
1572
|
+
const legacyPath = (databasePath) => path.join(path.dirname(databasePath), "state.sqlite");
|
|
1573
|
+
const locate = fn("DatabaseMaintenance.locate")(function* (databasePath) {
|
|
1574
|
+
if (!(yield* fs.exists(databasePath))) return yield* new DatabaseMissingError({ path: databasePath });
|
|
1575
|
+
});
|
|
1576
|
+
const inspect = fn("DatabaseMaintenance.inspect")(function* (databasePath) {
|
|
1577
|
+
yield* locate(databasePath);
|
|
1578
|
+
const storage = yield* readStorage.pipe(provide(layer$24({
|
|
1579
|
+
filename: databasePath,
|
|
1580
|
+
readonly: true
|
|
1581
|
+
})));
|
|
1582
|
+
const legacy = legacyPath(databasePath);
|
|
1583
|
+
const legacyDatabaseBytes = (yield* fs.exists(legacy)) ? Number((yield* fs.stat(legacy)).size) : null;
|
|
1584
|
+
return {
|
|
1585
|
+
...storage,
|
|
1586
|
+
legacyDatabaseBytes
|
|
1587
|
+
};
|
|
1588
|
+
}, (effect, databasePath) => effect.pipe(mapError((cause) => isDomainError(cause) ? cause : new DatabaseInspectError({
|
|
1589
|
+
path: databasePath,
|
|
1590
|
+
cause
|
|
1591
|
+
}))));
|
|
1592
|
+
const compact = fn("DatabaseMaintenance.compact")(function* (databasePath) {
|
|
1593
|
+
yield* locate(databasePath);
|
|
1594
|
+
const beforeBytes = Number((yield* fs.stat(databasePath)).size);
|
|
1595
|
+
const result = yield* gen(function* () {
|
|
1596
|
+
const sql = yield* SqlClient;
|
|
1597
|
+
yield* lockExclusively(databasePath);
|
|
1598
|
+
const maintenance = yield* ProjectionMaintenanceV2;
|
|
1599
|
+
if (!(yield* maintenance.verify).valid) return yield* new DatabaseProjectionsInvalidError({ path: databasePath });
|
|
1600
|
+
const summary = yield* maintenance.compactEventStore();
|
|
1601
|
+
if (!(yield* maintenance.verify).valid) return yield* new DatabaseProjectionsInvalidError({ path: databasePath });
|
|
1602
|
+
yield* sql`PRAGMA auto_vacuum = INCREMENTAL`;
|
|
1603
|
+
yield* sql`VACUUM`;
|
|
1604
|
+
yield* sql`PRAGMA wal_checkpoint(TRUNCATE)`;
|
|
1605
|
+
return summary;
|
|
1606
|
+
}).pipe(provide(layer$25.pipe(provide$1(merge(layer$26, layer$27)), provideMerge(layer$24({ filename: databasePath })))));
|
|
1607
|
+
return {
|
|
1608
|
+
beforeBytes,
|
|
1609
|
+
afterBytes: Number((yield* fs.stat(databasePath)).size),
|
|
1610
|
+
deletedEventCount: result.deletedEventCount,
|
|
1611
|
+
deletedReceiptCount: result.deletedReceiptCount
|
|
1612
|
+
};
|
|
1613
|
+
}, (effect, databasePath) => effect.pipe(mapError((cause) => isDomainError(cause) ? cause : new DatabaseCompactError({
|
|
1614
|
+
path: databasePath,
|
|
1615
|
+
cause
|
|
1616
|
+
}))));
|
|
1617
|
+
const removeLegacyDatabase = fn("DatabaseMaintenance.removeLegacyDatabase")(function* (databasePath) {
|
|
1618
|
+
const legacy = legacyPath(databasePath);
|
|
1619
|
+
if (!(yield* fs.exists(legacy))) return;
|
|
1620
|
+
const removeFiles = forEach([
|
|
1621
|
+
"",
|
|
1622
|
+
"-wal",
|
|
1623
|
+
"-shm"
|
|
1624
|
+
], (suffix) => fs.remove(legacy + suffix, { force: true }), { discard: true });
|
|
1625
|
+
const connection = layer$24({ filename: legacy });
|
|
1626
|
+
if ((yield* Platform) === "win32") {
|
|
1627
|
+
yield* lockExclusively(legacy).pipe(provide(connection));
|
|
1628
|
+
yield* removeFiles;
|
|
1629
|
+
} else yield* lockExclusively(legacy).pipe(andThen(removeFiles), provide(connection));
|
|
1630
|
+
}, (effect, databasePath) => effect.pipe(mapError((cause) => cause._tag === "DatabaseInUseError" ? cause : new LegacyDatabaseRemoveError({
|
|
1631
|
+
path: legacyPath(databasePath),
|
|
1632
|
+
cause
|
|
1633
|
+
}))));
|
|
1634
|
+
return DatabaseMaintenance.of({
|
|
1635
|
+
inspect,
|
|
1636
|
+
compact,
|
|
1637
|
+
removeLegacyDatabase
|
|
1638
|
+
});
|
|
1639
|
+
});
|
|
1640
|
+
const layer$20 = effect(DatabaseMaintenance, make$22);
|
|
1641
|
+
/** Settings' Reclaim writes the request; the failure stays for Settings until the next request. */
|
|
1642
|
+
const reclaimFiles = (path, databasePath) => ({
|
|
1643
|
+
request: path.join(path.dirname(databasePath), "reclaim-requested"),
|
|
1644
|
+
failure: path.join(path.dirname(databasePath), "reclaim-failed")
|
|
1645
|
+
});
|
|
1646
|
+
/** Runs a repair that Settings requested. The server calls this on exit, once its database is closed. */
|
|
1647
|
+
const runRequestedReclaim = fn("DatabaseMaintenance.runRequestedReclaim")(function* (databasePath) {
|
|
1648
|
+
const fs = yield* FileSystem;
|
|
1649
|
+
const files = reclaimFiles(yield* Path, databasePath);
|
|
1650
|
+
if (!(yield* fs.exists(files.request))) return;
|
|
1651
|
+
yield* fs.remove(files.request, { force: true });
|
|
1652
|
+
yield* logInfo("Reclaiming database space before the restart. This can take minutes.");
|
|
1653
|
+
yield* (yield* DatabaseMaintenance).compact(databasePath).pipe(retry({
|
|
1654
|
+
times: 10,
|
|
1655
|
+
while: (error) => error._tag === "DatabaseInUseError",
|
|
1656
|
+
schedule: spaced("1 second")
|
|
1657
|
+
}), matchEffect({
|
|
1658
|
+
onSuccess: (result) => fs.remove(files.failure, { force: true }).pipe(andThen(logInfo("Reclaimed database space", result))),
|
|
1659
|
+
onFailure: (error) => fs.writeFileString(files.failure, error._tag === "DatabaseInUseError" ? "Another program kept the database open. Close other P4 Code apps and p4c commands on this machine, then try again." : error.message).pipe(andThen(logWarning("Database space reclamation failed", { error })))
|
|
1660
|
+
}));
|
|
1661
|
+
}, catchCause((cause) => logWarning("Database space reclamation failed", { cause })));
|
|
1662
|
+
const sqliteTempDirectory = gen(function* () {
|
|
1663
|
+
if ((yield* Platform) === "win32") return NodeOS.tmpdir();
|
|
1664
|
+
const fs = yield* FileSystem;
|
|
1665
|
+
const env = yield* Environment;
|
|
1666
|
+
for (const directory of [
|
|
1667
|
+
env.SQLITE_TMPDIR,
|
|
1668
|
+
env.TMPDIR,
|
|
1669
|
+
"/var/tmp",
|
|
1670
|
+
"/usr/tmp",
|
|
1671
|
+
"/tmp"
|
|
1672
|
+
]) {
|
|
1673
|
+
if (directory === void 0 || directory === "") continue;
|
|
1674
|
+
const info = yield* fs.stat(directory).pipe(option);
|
|
1675
|
+
if (isNone(info) || info.value.type !== "Directory") continue;
|
|
1676
|
+
if (yield* tryPromise({
|
|
1677
|
+
try: () => NodeFSP.access(directory, NodeFSP.constants.W_OK | NodeFSP.constants.X_OK),
|
|
1678
|
+
catch: (cause) => new DiskSpaceCheckError({
|
|
1679
|
+
path: directory,
|
|
1680
|
+
cause
|
|
1681
|
+
})
|
|
1682
|
+
}).pipe(as(true), orElseSucceed(() => false))) return directory;
|
|
1683
|
+
}
|
|
1684
|
+
return ".";
|
|
1685
|
+
});
|
|
1686
|
+
const freeBytes = (directory) => tryPromise({
|
|
1687
|
+
try: () => NodeFSP.statfs(directory),
|
|
1688
|
+
catch: (cause) => new DiskSpaceCheckError({
|
|
1689
|
+
path: directory,
|
|
1690
|
+
cause
|
|
1691
|
+
})
|
|
1692
|
+
}).pipe(map$1((stats) => stats.bavail * stats.bsize));
|
|
1693
|
+
/**
|
|
1694
|
+
* VACUUM copies the live pages to a temporary file, then writes them again to the WAL.
|
|
1695
|
+
* Returns the free space the repair needs when either file system has less, else null.
|
|
1696
|
+
*/
|
|
1697
|
+
const reclaimSpaceShortfall = fn("DatabaseMaintenance.reclaimSpaceShortfall")(function* (databasePath, liveBytes) {
|
|
1698
|
+
const fs = yield* FileSystem;
|
|
1699
|
+
const databaseDirectory = (yield* Path).dirname(databasePath);
|
|
1700
|
+
const tempDirectory = yield* sqliteTempDirectory;
|
|
1701
|
+
const copyBytes = Math.ceil(liveBytes * 1.1);
|
|
1702
|
+
const [databaseFree, tempFree, databaseDevice, tempDevice] = yield* all([
|
|
1703
|
+
freeBytes(databaseDirectory),
|
|
1704
|
+
freeBytes(tempDirectory),
|
|
1705
|
+
fs.stat(databaseDirectory).pipe(map$1((info) => info.dev)),
|
|
1706
|
+
fs.stat(tempDirectory).pipe(map$1((info) => info.dev))
|
|
1707
|
+
]);
|
|
1708
|
+
if (databaseDevice === tempDevice) return databaseFree < 2 * copyBytes ? {
|
|
1709
|
+
neededBytes: 2 * copyBytes,
|
|
1710
|
+
freeBytes: databaseFree
|
|
1711
|
+
} : null;
|
|
1712
|
+
if (databaseFree < copyBytes) return {
|
|
1713
|
+
neededBytes: copyBytes,
|
|
1714
|
+
freeBytes: databaseFree
|
|
1715
|
+
};
|
|
1716
|
+
return tempFree < copyBytes ? {
|
|
1717
|
+
neededBytes: copyBytes,
|
|
1718
|
+
freeBytes: tempFree
|
|
1719
|
+
} : null;
|
|
1720
|
+
});
|
|
1418
1721
|
// src/os-jank.ts
|
|
1419
1722
|
function logPathHydrationWarning(message, error) {
|
|
1420
1723
|
process.stderr.write(`[server] ${message} ${error instanceof Error ? error.message : error ?? ""}\n`);
|
|
@@ -2343,7 +2646,7 @@ QrCode.Ecc = QrCodeEcc;
|
|
|
2343
2646
|
QrSegment.Mode = QrSegmentMode;
|
|
2344
2647
|
// ../../packages/shared/src/oauthScope.ts
|
|
2345
2648
|
const OAUTH_SCOPE_TOKEN = /^[\u0021\u0023-\u005b\u005d-\u007e]+$/u;
|
|
2346
|
-
var OAuthScopeEncodingError = class extends TaggedError()("OAuthScopeEncodingError", {
|
|
2649
|
+
var OAuthScopeEncodingError = class extends TaggedError$1()("OAuthScopeEncodingError", {
|
|
2347
2650
|
scopes: ArraySchema(String$1),
|
|
2348
2651
|
invalidScopes: ArraySchema(String$1),
|
|
2349
2652
|
duplicateScopes: ArraySchema(String$1)
|
|
@@ -2411,14 +2714,10 @@ function base64UrlEncode(input) {
|
|
|
2411
2714
|
function base64UrlDecodeUtf8(input) {
|
|
2412
2715
|
return getOrThrow(decodeString(input));
|
|
2413
2716
|
}
|
|
2414
|
-
function signPayload(payload, secret) {
|
|
2415
|
-
return NodeCrypto.createHmac("sha256", Buffer.from(secret)).update(payload).digest("base64url");
|
|
2416
|
-
}
|
|
2417
2717
|
function timingSafeEqualBase64Url(left, right) {
|
|
2418
|
-
const
|
|
2419
|
-
const
|
|
2420
|
-
|
|
2421
|
-
return NodeCrypto.timingSafeEqual(leftBuffer, rightBuffer);
|
|
2718
|
+
const leftBytes = decode(left);
|
|
2719
|
+
const rightBytes = decode(right);
|
|
2720
|
+
return isSuccess$1(leftBytes) && isSuccess$1(rightBytes) && timingSafeEqual(leftBytes.success, rightBytes.success);
|
|
2422
2721
|
}
|
|
2423
2722
|
function normalizeNonEmptyString(value) {
|
|
2424
2723
|
if (typeof value !== "string") return;
|
|
@@ -2479,7 +2778,7 @@ function deriveAuthClientMetadata(input) {
|
|
|
2479
2778
|
// src/auth/EnvironmentAuthPolicy.ts
|
|
2480
2779
|
var EnvironmentAuthPolicy = class extends Service()("@p4code/cli/auth/EnvironmentAuthPolicy") {};
|
|
2481
2780
|
/** @public Service construction is part of the canonical Effect module API. */
|
|
2482
|
-
const make$
|
|
2781
|
+
const make$21 = gen(function* () {
|
|
2483
2782
|
const config = yield* ServerConfig;
|
|
2484
2783
|
const serverEnvironment = yield* ServerEnvironmentIdentity;
|
|
2485
2784
|
const isRemoteReachable = isRemoteReachableHost(config.host);
|
|
@@ -2504,7 +2803,7 @@ const make$20 = gen(function* () {
|
|
|
2504
2803
|
};
|
|
2505
2804
|
return EnvironmentAuthPolicy.of({ getDescriptor: () => succeed(descriptor).pipe(withSpan("EnvironmentAuthPolicy.getDescriptor")) });
|
|
2506
2805
|
});
|
|
2507
|
-
const layer$
|
|
2806
|
+
const layer$19 = effect(EnvironmentAuthPolicy, make$21);
|
|
2508
2807
|
// ../../packages/shared/src/desktopBootstrapToken.ts
|
|
2509
2808
|
/**
|
|
2510
2809
|
* The desktop app and the backends it launches share one secret, delivered
|
|
@@ -2519,25 +2818,26 @@ const layer$18 = effect(EnvironmentAuthPolicy, make$20);
|
|
|
2519
2818
|
* was issued.
|
|
2520
2819
|
*/
|
|
2521
2820
|
const DESKTOP_BOOTSTRAP_TOKEN_WINDOW_MS = 432e5;
|
|
2821
|
+
const utf8$1 = (value) => new TextEncoder().encode(value);
|
|
2522
2822
|
function windowIndex(nowMs) {
|
|
2523
2823
|
return Math.floor(nowMs / DESKTOP_BOOTSTRAP_TOKEN_WINDOW_MS);
|
|
2524
2824
|
}
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2825
|
+
const deriveToken = fnUntraced$1(function* (secret, window) {
|
|
2826
|
+
const mac = yield* Mac;
|
|
2827
|
+
const key$3 = yield* key(hmacSha256, utf8$1(secret));
|
|
2828
|
+
return encode(yield* mac.sign(key$3, utf8$1(`p4-desktop-bootstrap:${window}`)));
|
|
2829
|
+
}, orDie);
|
|
2830
|
+
fn("desktopBootstrapToken.current")((secret, nowMs) => deriveToken(secret, windowIndex(nowMs)));
|
|
2831
|
+
const isValidDesktopBootstrapToken = fn("desktopBootstrapToken.isValid")(function* (secret, token, nowMs) {
|
|
2832
|
+
const presented = utf8$1(token);
|
|
2531
2833
|
const current = windowIndex(nowMs);
|
|
2532
|
-
|
|
2834
|
+
for (const window of [
|
|
2533
2835
|
current - 1,
|
|
2534
2836
|
current,
|
|
2535
2837
|
current + 1
|
|
2536
|
-
]
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
});
|
|
2540
|
-
}
|
|
2838
|
+
]) if (timingSafeEqual(utf8$1(yield* deriveToken(secret, window)), presented)) return true;
|
|
2839
|
+
return false;
|
|
2840
|
+
});
|
|
2541
2841
|
// src/persistence/AuthPairingLinks.ts
|
|
2542
2842
|
const AuthPairingLinkRecord = Struct({
|
|
2543
2843
|
id: String$1,
|
|
@@ -2600,7 +2900,7 @@ function toPersistenceSqlOrDecodeError$1(sqlOperation, decodeOperation, correlat
|
|
|
2600
2900
|
});
|
|
2601
2901
|
}
|
|
2602
2902
|
/** @public Service construction is part of the canonical Effect module API. */
|
|
2603
|
-
const make$
|
|
2903
|
+
const make$20 = gen(function* () {
|
|
2604
2904
|
const sql = yield* SqlClient;
|
|
2605
2905
|
const createPairingLinkRow = void_$2({
|
|
2606
2906
|
Request: CreateAuthPairingLinkInput,
|
|
@@ -2749,29 +3049,29 @@ const make$19 = gen(function* () {
|
|
|
2749
3049
|
getByCredential
|
|
2750
3050
|
};
|
|
2751
3051
|
});
|
|
2752
|
-
const layer$
|
|
3052
|
+
const layer$18 = effect(AuthPairingLinkRepository, make$20);
|
|
2753
3053
|
// src/auth/PairingGrantStore.ts
|
|
2754
|
-
var UnknownBootstrapCredentialError = class extends TaggedError()("UnknownBootstrapCredentialError", {}) {
|
|
3054
|
+
var UnknownBootstrapCredentialError = class extends TaggedError$1()("UnknownBootstrapCredentialError", {}) {
|
|
2755
3055
|
get message() {
|
|
2756
3056
|
return "Unknown bootstrap credential.";
|
|
2757
3057
|
}
|
|
2758
3058
|
};
|
|
2759
|
-
var ExpiredBootstrapCredentialError = class extends TaggedError()("ExpiredBootstrapCredentialError", {}) {
|
|
3059
|
+
var ExpiredBootstrapCredentialError = class extends TaggedError$1()("ExpiredBootstrapCredentialError", {}) {
|
|
2760
3060
|
get message() {
|
|
2761
3061
|
return "Bootstrap credential expired.";
|
|
2762
3062
|
}
|
|
2763
3063
|
};
|
|
2764
|
-
var BootstrapCredentialProofKeyMismatchError = class extends TaggedError()("BootstrapCredentialProofKeyMismatchError", {}) {
|
|
3064
|
+
var BootstrapCredentialProofKeyMismatchError = class extends TaggedError$1()("BootstrapCredentialProofKeyMismatchError", {}) {
|
|
2765
3065
|
get message() {
|
|
2766
3066
|
return "Bootstrap credential proof key mismatch.";
|
|
2767
3067
|
}
|
|
2768
3068
|
};
|
|
2769
|
-
var UnavailableBootstrapCredentialError = class extends TaggedError()("UnavailableBootstrapCredentialError", {}) {
|
|
3069
|
+
var UnavailableBootstrapCredentialError = class extends TaggedError$1()("UnavailableBootstrapCredentialError", {}) {
|
|
2770
3070
|
get message() {
|
|
2771
3071
|
return "Bootstrap credential is no longer available.";
|
|
2772
3072
|
}
|
|
2773
3073
|
};
|
|
2774
|
-
var BootstrapCredentialScopeNotGrantedError = class extends TaggedError()("BootstrapCredentialScopeNotGrantedError", {}) {
|
|
3074
|
+
var BootstrapCredentialScopeNotGrantedError = class extends TaggedError$1()("BootstrapCredentialScopeNotGrantedError", {}) {
|
|
2775
3075
|
get message() {
|
|
2776
3076
|
return "The requested authentication scope was not granted.";
|
|
2777
3077
|
}
|
|
@@ -2782,12 +3082,12 @@ const BootstrapCredentialInvalidError = Union([
|
|
|
2782
3082
|
BootstrapCredentialProofKeyMismatchError,
|
|
2783
3083
|
UnavailableBootstrapCredentialError
|
|
2784
3084
|
]);
|
|
2785
|
-
var ActivePairingLinksLoadError = class extends TaggedError()("ActivePairingLinksLoadError", { cause: Defect() }) {
|
|
3085
|
+
var ActivePairingLinksLoadError = class extends TaggedError$1()("ActivePairingLinksLoadError", { cause: Defect() }) {
|
|
2786
3086
|
get message() {
|
|
2787
3087
|
return "Failed to load active pairing links.";
|
|
2788
3088
|
}
|
|
2789
3089
|
};
|
|
2790
|
-
var PairingLinkRevokeError = class extends TaggedError()("PairingLinkRevokeError", {
|
|
3090
|
+
var PairingLinkRevokeError = class extends TaggedError$1()("PairingLinkRevokeError", {
|
|
2791
3091
|
pairingLinkId: String$1,
|
|
2792
3092
|
cause: Defect()
|
|
2793
3093
|
}) {
|
|
@@ -2795,7 +3095,7 @@ var PairingLinkRevokeError = class extends TaggedError()("PairingLinkRevokeError
|
|
|
2795
3095
|
return `Failed to revoke pairing link '${this.pairingLinkId}'.`;
|
|
2796
3096
|
}
|
|
2797
3097
|
};
|
|
2798
|
-
var PairingCredentialIssueError = class extends TaggedError()("PairingCredentialIssueError", {
|
|
3098
|
+
var PairingCredentialIssueError = class extends TaggedError$1()("PairingCredentialIssueError", {
|
|
2799
3099
|
pairingLinkId: String$1,
|
|
2800
3100
|
subject: String$1,
|
|
2801
3101
|
label: optional(String$1),
|
|
@@ -2805,7 +3105,7 @@ var PairingCredentialIssueError = class extends TaggedError()("PairingCredential
|
|
|
2805
3105
|
return `Failed to issue pairing credential '${this.pairingLinkId}' for '${this.subject}'.`;
|
|
2806
3106
|
}
|
|
2807
3107
|
};
|
|
2808
|
-
var PairingCredentialRandomGenerationError = class extends TaggedError()("PairingCredentialRandomGenerationError", {
|
|
3108
|
+
var PairingCredentialRandomGenerationError = class extends TaggedError$1()("PairingCredentialRandomGenerationError", {
|
|
2809
3109
|
operation: Literals(["generate-id", "generate-token"]),
|
|
2810
3110
|
cause: Defect()
|
|
2811
3111
|
}) {
|
|
@@ -2813,17 +3113,17 @@ var PairingCredentialRandomGenerationError = class extends TaggedError()("Pairin
|
|
|
2813
3113
|
return `Failed to generate pairing credential data during '${this.operation}'.`;
|
|
2814
3114
|
}
|
|
2815
3115
|
};
|
|
2816
|
-
var BootstrapCredentialConsumeError = class extends TaggedError()("BootstrapCredentialConsumeError", { cause: Defect() }) {
|
|
3116
|
+
var BootstrapCredentialConsumeError = class extends TaggedError$1()("BootstrapCredentialConsumeError", { cause: Defect() }) {
|
|
2817
3117
|
get message() {
|
|
2818
3118
|
return "Failed to consume bootstrap credential.";
|
|
2819
3119
|
}
|
|
2820
3120
|
};
|
|
2821
|
-
var BootstrapCredentialConsumeAvailableError = class extends TaggedError()("BootstrapCredentialConsumeAvailableError", { cause: Defect() }) {
|
|
3121
|
+
var BootstrapCredentialConsumeAvailableError = class extends TaggedError$1()("BootstrapCredentialConsumeAvailableError", { cause: Defect() }) {
|
|
2822
3122
|
get message() {
|
|
2823
3123
|
return "Failed to atomically consume an available bootstrap credential.";
|
|
2824
3124
|
}
|
|
2825
3125
|
};
|
|
2826
|
-
var BootstrapCredentialLookupError = class extends TaggedError()("BootstrapCredentialLookupError", { cause: Defect() }) {
|
|
3126
|
+
var BootstrapCredentialLookupError = class extends TaggedError$1()("BootstrapCredentialLookupError", { cause: Defect() }) {
|
|
2827
3127
|
get message() {
|
|
2828
3128
|
return "Failed to look up bootstrap credential state.";
|
|
2829
3129
|
}
|
|
@@ -2851,16 +3151,16 @@ const PAIRING_TOKEN_ALPHABET = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
|
|
|
2851
3151
|
const PAIRING_TOKEN_LENGTH = 12;
|
|
2852
3152
|
const PAIRING_TOKEN_REJECTION_LIMIT = Math.floor(8) * 32;
|
|
2853
3153
|
const PAIRING_TOKEN_PATTERN = new RegExp(`^[${PAIRING_TOKEN_ALPHABET}]{${PAIRING_TOKEN_LENGTH}}$`, "i");
|
|
2854
|
-
const make$
|
|
2855
|
-
const
|
|
3154
|
+
const make$19 = gen(function* () {
|
|
3155
|
+
const random = yield* SecureRandom;
|
|
2856
3156
|
const config = yield* ServerConfig;
|
|
2857
3157
|
const pairingLinks = yield* AuthPairingLinkRepository;
|
|
2858
|
-
const seededGrantsRef = yield* make$
|
|
3158
|
+
const seededGrantsRef = yield* make$42(/* @__PURE__ */ new Map());
|
|
2859
3159
|
const changesPubSub = yield* unbounded();
|
|
2860
3160
|
const generatePairingToken = gen(function* () {
|
|
2861
3161
|
let credential = "";
|
|
2862
3162
|
while (credential.length < PAIRING_TOKEN_LENGTH) {
|
|
2863
|
-
const bytes = yield*
|
|
3163
|
+
const bytes = yield* random.randomBytes(PAIRING_TOKEN_LENGTH).pipe(mapError((cause) => new PairingCredentialRandomGenerationError({
|
|
2864
3164
|
operation: "generate-token",
|
|
2865
3165
|
cause
|
|
2866
3166
|
})));
|
|
@@ -2886,20 +3186,21 @@ const make$18 = gen(function* () {
|
|
|
2886
3186
|
id
|
|
2887
3187
|
}).pipe(asVoid);
|
|
2888
3188
|
const desktopBootstrapSecret = config.desktopBootstrapSecret;
|
|
2889
|
-
const
|
|
3189
|
+
const mac = yield* Mac;
|
|
3190
|
+
const consumeRotatingDesktopToken = (credential, nowMs) => desktopBootstrapSecret === void 0 ? succeed(false) : isValidDesktopBootstrapToken(desktopBootstrapSecret, credential, nowMs).pipe(provideService(Mac, mac));
|
|
2890
3191
|
if (config.desktopBootstrapToken && desktopBootstrapSecret === void 0) {
|
|
2891
|
-
const now$
|
|
3192
|
+
const now$9 = yield* now;
|
|
2892
3193
|
yield* seedGrant(config.desktopBootstrapToken, {
|
|
2893
3194
|
method: "desktop-bootstrap",
|
|
2894
3195
|
scopes: AuthStandardClientScopes,
|
|
2895
3196
|
subject: "desktop-bootstrap",
|
|
2896
|
-
expiresAt: add$1(now$
|
|
3197
|
+
expiresAt: add$1(now$9, { milliseconds: toMillis(DESKTOP_BOOTSTRAP_TTL_HOURS) }),
|
|
2897
3198
|
remainingUses: "unbounded"
|
|
2898
3199
|
});
|
|
2899
3200
|
}
|
|
2900
3201
|
const listActive = fn("PairingGrantStore.listActive")(function* () {
|
|
2901
|
-
const now$
|
|
2902
|
-
return (yield* pairingLinks.listActive({ now: now$
|
|
3202
|
+
const now$8 = yield* now;
|
|
3203
|
+
return (yield* pairingLinks.listActive({ now: now$8 })).map((row) => row.label ? {
|
|
2903
3204
|
id: row.id,
|
|
2904
3205
|
scopes: row.scopes,
|
|
2905
3206
|
subject: row.subject,
|
|
@@ -2927,15 +3228,15 @@ const make$18 = gen(function* () {
|
|
|
2927
3228
|
return revoked;
|
|
2928
3229
|
});
|
|
2929
3230
|
const issueOneTimeToken = fn("PairingGrantStore.issueOneTimeToken")(function* (input) {
|
|
2930
|
-
const id = yield*
|
|
3231
|
+
const id = yield* random.uuidV4().pipe(mapError((cause) => new PairingCredentialRandomGenerationError({
|
|
2931
3232
|
operation: "generate-id",
|
|
2932
3233
|
cause
|
|
2933
3234
|
})));
|
|
2934
3235
|
const credential = yield* generatePairingToken;
|
|
2935
3236
|
const isDevStartupToken = config.devUrl !== void 0 && input?.purpose === "startup";
|
|
2936
3237
|
const ttl = input?.ttl ?? (isDevStartupToken ? DEV_STARTUP_TTL_HOURS : DEFAULT_ONE_TIME_TOKEN_TTL_MINUTES);
|
|
2937
|
-
const now$
|
|
2938
|
-
const expiresAt = add$1(now$
|
|
3238
|
+
const now$7 = yield* now;
|
|
3239
|
+
const expiresAt = add$1(now$7, { milliseconds: toMillis(ttl) });
|
|
2939
3240
|
const issued = {
|
|
2940
3241
|
id,
|
|
2941
3242
|
credential,
|
|
@@ -2952,7 +3253,7 @@ const make$18 = gen(function* () {
|
|
|
2952
3253
|
subject,
|
|
2953
3254
|
label: input?.label ?? null,
|
|
2954
3255
|
proofKeyThumbprint: input?.proofKeyThumbprint ?? null,
|
|
2955
|
-
createdAt: now$
|
|
3256
|
+
createdAt: now$7,
|
|
2956
3257
|
expiresAt
|
|
2957
3258
|
}).pipe(mapError((cause) => new PairingCredentialIssueError({
|
|
2958
3259
|
pairingLinkId: id,
|
|
@@ -2965,18 +3266,18 @@ const make$18 = gen(function* () {
|
|
|
2965
3266
|
scopes: input?.scopes ?? AuthStandardClientScopes,
|
|
2966
3267
|
subject: input?.subject ?? "one-time-token",
|
|
2967
3268
|
...input?.label ? { label: input.label } : {},
|
|
2968
|
-
createdAt: now$
|
|
3269
|
+
createdAt: now$7,
|
|
2969
3270
|
expiresAt
|
|
2970
3271
|
});
|
|
2971
3272
|
return issued;
|
|
2972
3273
|
});
|
|
2973
3274
|
const consume = fn("PairingGrantStore.consume")(function* (credential, input) {
|
|
2974
|
-
const now$
|
|
2975
|
-
if (consumeRotatingDesktopToken(credential, now$
|
|
3275
|
+
const now$10 = yield* now;
|
|
3276
|
+
if (yield* consumeRotatingDesktopToken(credential, now$10.epochMilliseconds)) return {
|
|
2976
3277
|
method: "desktop-bootstrap",
|
|
2977
3278
|
scopes: AuthStandardClientScopes,
|
|
2978
3279
|
subject: "desktop-bootstrap",
|
|
2979
|
-
expiresAt: add$1(now$
|
|
3280
|
+
expiresAt: add$1(now$10, { milliseconds: DESKTOP_BOOTSTRAP_TOKEN_WINDOW_MS })
|
|
2980
3281
|
};
|
|
2981
3282
|
const seededResult = yield* modify(seededGrantsRef, (current) => {
|
|
2982
3283
|
const grant = current.get(credential);
|
|
@@ -2986,7 +3287,7 @@ const make$18 = gen(function* () {
|
|
|
2986
3287
|
error: new UnknownBootstrapCredentialError({})
|
|
2987
3288
|
}, current];
|
|
2988
3289
|
const next = new Map(current);
|
|
2989
|
-
if (isGreaterThanOrEqualTo(now$
|
|
3290
|
+
if (isGreaterThanOrEqualTo(now$10, grant.expiresAt)) {
|
|
2990
3291
|
next.delete(credential);
|
|
2991
3292
|
return [{
|
|
2992
3293
|
_tag: "error",
|
|
@@ -3032,8 +3333,8 @@ const make$18 = gen(function* () {
|
|
|
3032
3333
|
proofKeyThumbprint: input?.proofKeyThumbprint ?? null,
|
|
3033
3334
|
...input?.requestedScopes !== void 0 ? { requestedScopes: input.requestedScopes } : {},
|
|
3034
3335
|
...input?.requiredScopes !== void 0 ? { requiredScopes: input.requiredScopes } : {},
|
|
3035
|
-
consumedAt: now$
|
|
3036
|
-
now: now$
|
|
3336
|
+
consumedAt: now$10,
|
|
3337
|
+
now: now$10
|
|
3037
3338
|
}).pipe(mapError((cause) => new BootstrapCredentialConsumeAvailableError({ cause })));
|
|
3038
3339
|
if (isSome(consumed)) {
|
|
3039
3340
|
yield* emitRemoved(consumed.value.id);
|
|
@@ -3050,7 +3351,7 @@ const make$18 = gen(function* () {
|
|
|
3050
3351
|
if (isNone(matching)) return yield* new UnknownBootstrapCredentialError({});
|
|
3051
3352
|
if (matching.value.revokedAt !== null) return yield* new UnavailableBootstrapCredentialError({});
|
|
3052
3353
|
if (matching.value.consumedAt !== null) return yield* new UnknownBootstrapCredentialError({});
|
|
3053
|
-
if (isGreaterThanOrEqualTo(now$
|
|
3354
|
+
if (isGreaterThanOrEqualTo(now$10, matching.value.expiresAt)) return yield* new ExpiredBootstrapCredentialError({});
|
|
3054
3355
|
if (matching.value.proofKeyThumbprint !== null && matching.value.proofKeyThumbprint !== input?.proofKeyThumbprint) return yield* new BootstrapCredentialProofKeyMismatchError({});
|
|
3055
3356
|
if (input?.requestedScopes !== void 0 && !input.requestedScopes.some((scope) => matching.value.scopes.includes(scope)) || input?.requiredScopes !== void 0 && !input.requiredScopes.every((scope) => matching.value.scopes.includes(scope))) return yield* new BootstrapCredentialScopeNotGrantedError({});
|
|
3056
3357
|
return yield* new UnavailableBootstrapCredentialError({});
|
|
@@ -3065,7 +3366,7 @@ const make$18 = gen(function* () {
|
|
|
3065
3366
|
consume
|
|
3066
3367
|
});
|
|
3067
3368
|
});
|
|
3068
|
-
const layer$
|
|
3369
|
+
const layer$17 = effect(PairingGrantStore, make$19).pipe(provideMerge(layer$18));
|
|
3069
3370
|
// src/persistence/AuthSessions.ts
|
|
3070
3371
|
const AuthSessionClientMetadataRecord = Struct({
|
|
3071
3372
|
label: NullOr(String$1),
|
|
@@ -3190,7 +3491,7 @@ function toPersistenceSqlOrDecodeError(sqlOperation, decodeOperation, correlatio
|
|
|
3190
3491
|
});
|
|
3191
3492
|
}
|
|
3192
3493
|
/** @public Service construction is part of the canonical Effect module API. */
|
|
3193
|
-
const make$
|
|
3494
|
+
const make$18 = gen(function* () {
|
|
3194
3495
|
const sql = yield* SqlClient;
|
|
3195
3496
|
const insertSessionRow = (ignoreExisting) => void_$2({
|
|
3196
3497
|
Request: CreateAuthSessionInput,
|
|
@@ -3356,7 +3657,32 @@ const make$17 = gen(function* () {
|
|
|
3356
3657
|
setClientConnection
|
|
3357
3658
|
};
|
|
3358
3659
|
});
|
|
3359
|
-
const layer$
|
|
3660
|
+
const layer$16 = effect(AuthSessionRepository, make$18);
|
|
3661
|
+
// src/auth/PayloadSigner.ts
|
|
3662
|
+
const utf8 = (value) => new TextEncoder().encode(value);
|
|
3663
|
+
const fromKey = (mac, key) => ({
|
|
3664
|
+
sign: (payload) => key.pipe(flatMap((loaded) => mac.sign(loaded, utf8(payload)).pipe(orDie)), map$1(encode$2)),
|
|
3665
|
+
verify: (payload, signature) => {
|
|
3666
|
+
const tag = decode(signature);
|
|
3667
|
+
return isFailure(tag) ? succeed(false) : key.pipe(flatMap((loaded) => mac.verify(loaded, tag.success, utf8(payload)).pipe(orDie)));
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3670
|
+
/** A signer for secret bytes the caller already holds. */
|
|
3671
|
+
const fromSecret = fn("PayloadSigner.fromSecret")(function* (secret) {
|
|
3672
|
+
const mac = yield* Mac;
|
|
3673
|
+
const key$2 = yield* key(hmacSha256, secret).pipe(orDie);
|
|
3674
|
+
return fromKey(mac, succeed(key$2));
|
|
3675
|
+
});
|
|
3676
|
+
/** A signer keyed by a named server secret, loaded on first use so store failures reach callers. */
|
|
3677
|
+
const make$17 = fn("PayloadSigner.make")(function* (secretName) {
|
|
3678
|
+
const secrets = yield* ServerSecretStore;
|
|
3679
|
+
const mac = yield* Mac;
|
|
3680
|
+
let key$1;
|
|
3681
|
+
const loadKey = suspend(() => key$1 !== void 0 ? succeed(key$1) : secrets.getOrCreateRandom(secretName, 32).pipe(flatMap((bytes) => key(hmacSha256, bytes).pipe(orDie)), tap((loaded) => sync$2(() => {
|
|
3682
|
+
key$1 = loaded;
|
|
3683
|
+
}))));
|
|
3684
|
+
return fromKey(mac, loadKey);
|
|
3685
|
+
});
|
|
3360
3686
|
// src/auth/ReusableDevAuth.ts
|
|
3361
3687
|
const REUSABLE_DEV_SESSION_PREFIX = "dev-auth-";
|
|
3362
3688
|
const REUSABLE_DEV_SESSION_EXPIRES_AT = makeUnsafe$2("9999-12-31T23:59:59.999Z");
|
|
@@ -3370,26 +3696,26 @@ function resolveReusableDevAuth(config) {
|
|
|
3370
3696
|
credential: value(token),
|
|
3371
3697
|
sessionId: AuthSessionId.make(`${REUSABLE_DEV_SESSION_PREFIX}${tokenId}`),
|
|
3372
3698
|
cookieName: `p4_dev_session_${tokenId}`,
|
|
3373
|
-
matches: (credential) =>
|
|
3699
|
+
matches: (credential) => timingSafeEqual(hash, NodeCrypto.createHash("sha256").update(credential).digest())
|
|
3374
3700
|
};
|
|
3375
3701
|
}
|
|
3376
3702
|
// src/auth/SessionStore.ts
|
|
3377
|
-
var MalformedSessionTokenError = class extends TaggedError()("MalformedSessionTokenError", {}) {
|
|
3703
|
+
var MalformedSessionTokenError = class extends TaggedError$1()("MalformedSessionTokenError", {}) {
|
|
3378
3704
|
get message() {
|
|
3379
3705
|
return "Malformed session token.";
|
|
3380
3706
|
}
|
|
3381
3707
|
};
|
|
3382
|
-
var InvalidSessionTokenSignatureError = class extends TaggedError()("InvalidSessionTokenSignatureError", {}) {
|
|
3708
|
+
var InvalidSessionTokenSignatureError = class extends TaggedError$1()("InvalidSessionTokenSignatureError", {}) {
|
|
3383
3709
|
get message() {
|
|
3384
3710
|
return "Invalid session token signature.";
|
|
3385
3711
|
}
|
|
3386
3712
|
};
|
|
3387
|
-
var InvalidSessionTokenPayloadError = class extends TaggedError()("InvalidSessionTokenPayloadError", { cause: Defect() }) {
|
|
3713
|
+
var InvalidSessionTokenPayloadError = class extends TaggedError$1()("InvalidSessionTokenPayloadError", { cause: Defect() }) {
|
|
3388
3714
|
get message() {
|
|
3389
3715
|
return "Invalid session token payload.";
|
|
3390
3716
|
}
|
|
3391
3717
|
};
|
|
3392
|
-
var SessionTokenExpiredError = class extends TaggedError()("SessionTokenExpiredError", {
|
|
3718
|
+
var SessionTokenExpiredError = class extends TaggedError$1()("SessionTokenExpiredError", {
|
|
3393
3719
|
sessionId: AuthSessionId,
|
|
3394
3720
|
expiresAt: DateTimeUtc,
|
|
3395
3721
|
observedAt: DateTimeUtc
|
|
@@ -3398,12 +3724,12 @@ var SessionTokenExpiredError = class extends TaggedError()("SessionTokenExpiredE
|
|
|
3398
3724
|
return "Session token expired.";
|
|
3399
3725
|
}
|
|
3400
3726
|
};
|
|
3401
|
-
var UnknownSessionTokenError = class extends TaggedError()("UnknownSessionTokenError", { sessionId: AuthSessionId }) {
|
|
3727
|
+
var UnknownSessionTokenError = class extends TaggedError$1()("UnknownSessionTokenError", { sessionId: AuthSessionId }) {
|
|
3402
3728
|
get message() {
|
|
3403
3729
|
return "Unknown session token.";
|
|
3404
3730
|
}
|
|
3405
3731
|
};
|
|
3406
|
-
var SessionTokenRevokedError = class extends TaggedError()("SessionTokenRevokedError", {
|
|
3732
|
+
var SessionTokenRevokedError = class extends TaggedError$1()("SessionTokenRevokedError", {
|
|
3407
3733
|
sessionId: AuthSessionId,
|
|
3408
3734
|
revokedAt: DateTimeUtc
|
|
3409
3735
|
}) {
|
|
@@ -3411,7 +3737,7 @@ var SessionTokenRevokedError = class extends TaggedError()("SessionTokenRevokedE
|
|
|
3411
3737
|
return "Session token revoked.";
|
|
3412
3738
|
}
|
|
3413
3739
|
};
|
|
3414
|
-
var InvalidSessionExpirationClaimError = class extends TaggedError()("InvalidSessionExpirationClaimError", {
|
|
3740
|
+
var InvalidSessionExpirationClaimError = class extends TaggedError$1()("InvalidSessionExpirationClaimError", {
|
|
3415
3741
|
sessionId: AuthSessionId,
|
|
3416
3742
|
expirationClaim: Number$2
|
|
3417
3743
|
}) {
|
|
@@ -3419,22 +3745,22 @@ var InvalidSessionExpirationClaimError = class extends TaggedError()("InvalidSes
|
|
|
3419
3745
|
return "Invalid `exp` claim";
|
|
3420
3746
|
}
|
|
3421
3747
|
};
|
|
3422
|
-
var MalformedWebSocketTokenError = class extends TaggedError()("MalformedWebSocketTokenError", {}) {
|
|
3748
|
+
var MalformedWebSocketTokenError = class extends TaggedError$1()("MalformedWebSocketTokenError", {}) {
|
|
3423
3749
|
get message() {
|
|
3424
3750
|
return "Malformed websocket token.";
|
|
3425
3751
|
}
|
|
3426
3752
|
};
|
|
3427
|
-
var InvalidWebSocketTokenSignatureError = class extends TaggedError()("InvalidWebSocketTokenSignatureError", {}) {
|
|
3753
|
+
var InvalidWebSocketTokenSignatureError = class extends TaggedError$1()("InvalidWebSocketTokenSignatureError", {}) {
|
|
3428
3754
|
get message() {
|
|
3429
3755
|
return "Invalid websocket token signature.";
|
|
3430
3756
|
}
|
|
3431
3757
|
};
|
|
3432
|
-
var InvalidWebSocketTokenPayloadError = class extends TaggedError()("InvalidWebSocketTokenPayloadError", { cause: Defect() }) {
|
|
3758
|
+
var InvalidWebSocketTokenPayloadError = class extends TaggedError$1()("InvalidWebSocketTokenPayloadError", { cause: Defect() }) {
|
|
3433
3759
|
get message() {
|
|
3434
3760
|
return "Invalid websocket token payload.";
|
|
3435
3761
|
}
|
|
3436
3762
|
};
|
|
3437
|
-
var WebSocketTokenExpiredError = class extends TaggedError()("WebSocketTokenExpiredError", {
|
|
3763
|
+
var WebSocketTokenExpiredError = class extends TaggedError$1()("WebSocketTokenExpiredError", {
|
|
3438
3764
|
sessionId: AuthSessionId,
|
|
3439
3765
|
expiresAt: DateTimeUtc,
|
|
3440
3766
|
observedAt: DateTimeUtc
|
|
@@ -3443,12 +3769,12 @@ var WebSocketTokenExpiredError = class extends TaggedError()("WebSocketTokenExpi
|
|
|
3443
3769
|
return "Websocket token expired.";
|
|
3444
3770
|
}
|
|
3445
3771
|
};
|
|
3446
|
-
var UnknownWebSocketSessionError = class extends TaggedError()("UnknownWebSocketSessionError", { sessionId: AuthSessionId }) {
|
|
3772
|
+
var UnknownWebSocketSessionError = class extends TaggedError$1()("UnknownWebSocketSessionError", { sessionId: AuthSessionId }) {
|
|
3447
3773
|
get message() {
|
|
3448
3774
|
return "Unknown websocket session.";
|
|
3449
3775
|
}
|
|
3450
3776
|
};
|
|
3451
|
-
var WebSocketSessionExpiredError = class extends TaggedError()("WebSocketSessionExpiredError", {
|
|
3777
|
+
var WebSocketSessionExpiredError = class extends TaggedError$1()("WebSocketSessionExpiredError", {
|
|
3452
3778
|
sessionId: AuthSessionId,
|
|
3453
3779
|
expiresAt: DateTimeUtc,
|
|
3454
3780
|
observedAt: DateTimeUtc
|
|
@@ -3457,7 +3783,7 @@ var WebSocketSessionExpiredError = class extends TaggedError()("WebSocketSession
|
|
|
3457
3783
|
return "Websocket session expired.";
|
|
3458
3784
|
}
|
|
3459
3785
|
};
|
|
3460
|
-
var WebSocketSessionRevokedError = class extends TaggedError()("WebSocketSessionRevokedError", {
|
|
3786
|
+
var WebSocketSessionRevokedError = class extends TaggedError$1()("WebSocketSessionRevokedError", {
|
|
3461
3787
|
sessionId: AuthSessionId,
|
|
3462
3788
|
revokedAt: DateTimeUtc
|
|
3463
3789
|
}) {
|
|
@@ -3483,7 +3809,7 @@ const SessionCredentialInvalidError = Union([
|
|
|
3483
3809
|
]);
|
|
3484
3810
|
const isSessionCredentialInvalidError = is(SessionCredentialInvalidError);
|
|
3485
3811
|
const sessionCredentialInternalErrorContext = { cause: Defect() };
|
|
3486
|
-
var SessionClaimsEncodingError = class extends TaggedError()("SessionClaimsEncodingError", {
|
|
3812
|
+
var SessionClaimsEncodingError = class extends TaggedError$1()("SessionClaimsEncodingError", {
|
|
3487
3813
|
sessionId: AuthSessionId,
|
|
3488
3814
|
operation: Literals(["encode_session_claims", "encode_websocket_claims"]),
|
|
3489
3815
|
...sessionCredentialInternalErrorContext
|
|
@@ -3492,7 +3818,7 @@ var SessionClaimsEncodingError = class extends TaggedError()("SessionClaimsEncod
|
|
|
3492
3818
|
return "Failed to encode claims";
|
|
3493
3819
|
}
|
|
3494
3820
|
};
|
|
3495
|
-
var SessionCredentialIssueError = class extends TaggedError()("SessionCredentialIssueError", {
|
|
3821
|
+
var SessionCredentialIssueError = class extends TaggedError$1()("SessionCredentialIssueError", {
|
|
3496
3822
|
sessionId: optional(AuthSessionId),
|
|
3497
3823
|
...sessionCredentialInternalErrorContext
|
|
3498
3824
|
}) {
|
|
@@ -3500,7 +3826,7 @@ var SessionCredentialIssueError = class extends TaggedError()("SessionCredential
|
|
|
3500
3826
|
return "Failed to issue session credential.";
|
|
3501
3827
|
}
|
|
3502
3828
|
};
|
|
3503
|
-
var SessionCredentialVerificationError = class extends TaggedError()("SessionCredentialVerificationError", {
|
|
3829
|
+
var SessionCredentialVerificationError = class extends TaggedError$1()("SessionCredentialVerificationError", {
|
|
3504
3830
|
sessionId: AuthSessionId,
|
|
3505
3831
|
...sessionCredentialInternalErrorContext
|
|
3506
3832
|
}) {
|
|
@@ -3508,7 +3834,7 @@ var SessionCredentialVerificationError = class extends TaggedError()("SessionCre
|
|
|
3508
3834
|
return "Failed to verify session credential.";
|
|
3509
3835
|
}
|
|
3510
3836
|
};
|
|
3511
|
-
var WebSocketTokenIssueError = class extends TaggedError()("WebSocketTokenIssueError", {
|
|
3837
|
+
var WebSocketTokenIssueError = class extends TaggedError$1()("WebSocketTokenIssueError", {
|
|
3512
3838
|
sessionId: AuthSessionId,
|
|
3513
3839
|
...sessionCredentialInternalErrorContext
|
|
3514
3840
|
}) {
|
|
@@ -3516,7 +3842,7 @@ var WebSocketTokenIssueError = class extends TaggedError()("WebSocketTokenIssueE
|
|
|
3516
3842
|
return "Failed to issue websocket token.";
|
|
3517
3843
|
}
|
|
3518
3844
|
};
|
|
3519
|
-
var WebSocketTokenVerificationError = class extends TaggedError()("WebSocketTokenVerificationError", {
|
|
3845
|
+
var WebSocketTokenVerificationError = class extends TaggedError$1()("WebSocketTokenVerificationError", {
|
|
3520
3846
|
sessionId: AuthSessionId,
|
|
3521
3847
|
...sessionCredentialInternalErrorContext
|
|
3522
3848
|
}) {
|
|
@@ -3524,12 +3850,12 @@ var WebSocketTokenVerificationError = class extends TaggedError()("WebSocketToke
|
|
|
3524
3850
|
return "Failed to verify websocket token.";
|
|
3525
3851
|
}
|
|
3526
3852
|
};
|
|
3527
|
-
var ActiveSessionsListError = class extends TaggedError()("ActiveSessionsListError", { ...sessionCredentialInternalErrorContext }) {
|
|
3853
|
+
var ActiveSessionsListError = class extends TaggedError$1()("ActiveSessionsListError", { ...sessionCredentialInternalErrorContext }) {
|
|
3528
3854
|
get message() {
|
|
3529
3855
|
return "Failed to list active sessions.";
|
|
3530
3856
|
}
|
|
3531
3857
|
};
|
|
3532
|
-
var SessionRevocationError = class extends TaggedError()("SessionRevocationError", {
|
|
3858
|
+
var SessionRevocationError = class extends TaggedError$1()("SessionRevocationError", {
|
|
3533
3859
|
sessionId: AuthSessionId,
|
|
3534
3860
|
...sessionCredentialInternalErrorContext
|
|
3535
3861
|
}) {
|
|
@@ -3537,7 +3863,7 @@ var SessionRevocationError = class extends TaggedError()("SessionRevocationError
|
|
|
3537
3863
|
return "Failed to revoke session.";
|
|
3538
3864
|
}
|
|
3539
3865
|
};
|
|
3540
|
-
var OtherSessionsRevocationError = class extends TaggedError()("OtherSessionsRevocationError", {
|
|
3866
|
+
var OtherSessionsRevocationError = class extends TaggedError$1()("OtherSessionsRevocationError", {
|
|
3541
3867
|
currentSessionId: AuthSessionId,
|
|
3542
3868
|
...sessionCredentialInternalErrorContext
|
|
3543
3869
|
}) {
|
|
@@ -3609,13 +3935,13 @@ function toAuthClientSession(input) {
|
|
|
3609
3935
|
};
|
|
3610
3936
|
}
|
|
3611
3937
|
const make$16 = gen(function* () {
|
|
3612
|
-
const
|
|
3938
|
+
const random = yield* SecureRandom;
|
|
3613
3939
|
const serverConfig = yield* ServerConfig;
|
|
3614
3940
|
const serverEnvironment = yield* ServerEnvironmentIdentity;
|
|
3615
3941
|
const secretStore = yield* ServerSecretStore;
|
|
3616
3942
|
const authSessions = yield* AuthSessionRepository;
|
|
3617
|
-
const
|
|
3618
|
-
const connectedSessionsRef = yield* make$
|
|
3943
|
+
const signer = yield* fromSecret(yield* secretStore.getOrCreateRandom(SIGNING_SECRET_NAME, 32));
|
|
3944
|
+
const connectedSessionsRef = yield* make$42(/* @__PURE__ */ new Map());
|
|
3619
3945
|
const changesPubSub = yield* unbounded();
|
|
3620
3946
|
const latestSessionByProofKey = /* @__PURE__ */ new Map();
|
|
3621
3947
|
const cookieInput = {
|
|
@@ -3659,7 +3985,7 @@ const make$16 = gen(function* () {
|
|
|
3659
3985
|
const loadActiveSession = (sessionId) => gen(function* () {
|
|
3660
3986
|
const row = yield* authSessions.getById({ sessionId });
|
|
3661
3987
|
if (isNone(row) || row.value.revokedAt !== null) return none();
|
|
3662
|
-
const connected = (yield* get$
|
|
3988
|
+
const connected = (yield* get$2(connectedSessionsRef)).has(row.value.sessionId);
|
|
3663
3989
|
const now$5 = yield* now;
|
|
3664
3990
|
if (!connected && row.value.expiresAt.epochMilliseconds <= now$5.epochMilliseconds) return none();
|
|
3665
3991
|
return some(toAuthClientSession({
|
|
@@ -3706,7 +4032,7 @@ const make$16 = gen(function* () {
|
|
|
3706
4032
|
}))), withSpan("SessionStore.markDisconnected"));
|
|
3707
4033
|
const encodeClaims = encodeEffect(fromJsonString(SessionClaims));
|
|
3708
4034
|
const issue = fn("SessionStore.issue")(function* (input) {
|
|
3709
|
-
const sessionId = AuthSessionId.make(yield*
|
|
4035
|
+
const sessionId = AuthSessionId.make(yield* random.uuidV4().pipe(mapError((cause) => new SessionCredentialIssueError({ cause }))));
|
|
3710
4036
|
const issuedAt = yield* now;
|
|
3711
4037
|
const expiresAt = add$1(issuedAt, { milliseconds: toMillis(input?.ttl ?? DEFAULT_SESSION_TTL) });
|
|
3712
4038
|
const claims = {
|
|
@@ -3730,7 +4056,7 @@ const make$16 = gen(function* () {
|
|
|
3730
4056
|
cause
|
|
3731
4057
|
})
|
|
3732
4058
|
})));
|
|
3733
|
-
const signature =
|
|
4059
|
+
const signature = yield* signer.sign(encodedPayload);
|
|
3734
4060
|
const client = input?.client ?? createDefaultClientMetadata();
|
|
3735
4061
|
const sessionRecord = {
|
|
3736
4062
|
sessionId,
|
|
@@ -3818,10 +4144,10 @@ const make$16 = gen(function* () {
|
|
|
3818
4144
|
}
|
|
3819
4145
|
const [encodedPayload, signature] = token.split(".");
|
|
3820
4146
|
if (!encodedPayload || !signature) return yield* new MalformedSessionTokenError({});
|
|
3821
|
-
if (!
|
|
4147
|
+
if (!(yield* signer.verify(encodedPayload, signature))) return yield* new InvalidSessionTokenSignatureError({});
|
|
3822
4148
|
const claims = yield* decodeSessionClaims(base64UrlDecodeUtf8(encodedPayload)).pipe(mapError((cause) => new InvalidSessionTokenPayloadError({ cause })));
|
|
3823
4149
|
const observedAt = yield* now;
|
|
3824
|
-
const expiresAt = make$
|
|
4150
|
+
const expiresAt = make$32(claims.exp);
|
|
3825
4151
|
if (isNone(expiresAt)) return yield* new InvalidSessionExpirationClaimError({
|
|
3826
4152
|
sessionId: claims.sid,
|
|
3827
4153
|
expirationClaim: claims.exp
|
|
@@ -3875,18 +4201,18 @@ const make$16 = gen(function* () {
|
|
|
3875
4201
|
})
|
|
3876
4202
|
})));
|
|
3877
4203
|
return {
|
|
3878
|
-
token: `${encodedPayload}.${
|
|
4204
|
+
token: `${encodedPayload}.${yield* signer.sign(encodedPayload)}`,
|
|
3879
4205
|
expiresAt
|
|
3880
4206
|
};
|
|
3881
4207
|
});
|
|
3882
4208
|
const verifyWebSocketToken = fn("SessionStore.verifyWebSocketToken")(function* (token) {
|
|
3883
4209
|
const [encodedPayload, signature] = token.split(".");
|
|
3884
4210
|
if (!encodedPayload || !signature) return yield* new MalformedWebSocketTokenError({});
|
|
3885
|
-
if (!
|
|
4211
|
+
if (!(yield* signer.verify(encodedPayload, signature))) return yield* new InvalidWebSocketTokenSignatureError({});
|
|
3886
4212
|
const claims = yield* decodeWebSocketClaims(base64UrlDecodeUtf8(encodedPayload)).pipe(mapError((cause) => new InvalidWebSocketTokenPayloadError({ cause })));
|
|
3887
4213
|
if (claims.sid.startsWith("dev-auth-") && claims.sid !== devAuth?.sessionId) return yield* new UnknownWebSocketSessionError({ sessionId: claims.sid });
|
|
3888
4214
|
const observedAt = yield* now;
|
|
3889
|
-
const expiresAt = make$
|
|
4215
|
+
const expiresAt = make$32(claims.exp);
|
|
3890
4216
|
if (isNone(expiresAt)) return yield* new InvalidSessionExpirationClaimError({
|
|
3891
4217
|
sessionId: claims.sid,
|
|
3892
4218
|
expirationClaim: claims.exp
|
|
@@ -3924,7 +4250,7 @@ const make$16 = gen(function* () {
|
|
|
3924
4250
|
});
|
|
3925
4251
|
const listActive = fn("SessionStore.listActive")(function* () {
|
|
3926
4252
|
const now$4 = yield* now;
|
|
3927
|
-
const connectedSessions = yield* get$
|
|
4253
|
+
const connectedSessions = yield* get$2(connectedSessionsRef);
|
|
3928
4254
|
return (yield* authSessions.listActive({
|
|
3929
4255
|
now: now$4,
|
|
3930
4256
|
connectedSessionIds: Array.from(connectedSessions.keys())
|
|
@@ -4034,7 +4360,7 @@ const make$16 = gen(function* () {
|
|
|
4034
4360
|
recordClientConnection
|
|
4035
4361
|
});
|
|
4036
4362
|
});
|
|
4037
|
-
const layer$
|
|
4363
|
+
const layer$15 = effect(SessionStore, make$16).pipe(provideMerge(layer$16));
|
|
4038
4364
|
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/hmac.js
|
|
4039
4365
|
/**
|
|
4040
4366
|
* HMAC: RFC2104 message authentication code.
|
|
@@ -6071,6 +6397,13 @@ function verifyDpopProof(input) {
|
|
|
6071
6397
|
};
|
|
6072
6398
|
}
|
|
6073
6399
|
}
|
|
6400
|
+
// src/requestUrl.ts
|
|
6401
|
+
/**
|
|
6402
|
+
* `HttpServerRequest.toURL` that honors `X-Forwarded-Proto: https`. Effect 4.1
|
|
6403
|
+
* stopped reading it, but TLS-terminating proxies in front of the server
|
|
6404
|
+
* (Tailscale Serve, tunnels) rely on it for OAuth, DPoP and pairing URLs.
|
|
6405
|
+
*/
|
|
6406
|
+
const requestUrl = (request) => toURL(request.headers["x-forwarded-proto"] === "https" && request.protocol !== "https" ? request.modify({ protocol: "https" }) : request);
|
|
6074
6407
|
// src/auth/dpop.ts
|
|
6075
6408
|
/** Secret store name prefix of DPoP replay markers. The server prunes expired ones. */
|
|
6076
6409
|
const DPOP_REPLAY_MARKER_PREFIX = "dpop-proof-";
|
|
@@ -6094,7 +6427,7 @@ const mapDpopReplayStoreError = (error) => isSecretAlreadyExistsError(error) ? n
|
|
|
6094
6427
|
}) : new ServerAuthDpopReplayStateRecordError({ cause: error });
|
|
6095
6428
|
const verifyRequestDpopProof = (input) => gen(function* () {
|
|
6096
6429
|
const proof = input.proof ?? input.request.headers.dpop;
|
|
6097
|
-
const url =
|
|
6430
|
+
const url = requestUrl(input.request);
|
|
6098
6431
|
if (isNone(url)) return yield* new ServerAuthInvalidCredentialError({ diagnostic: "Invalid DPoP request URL." });
|
|
6099
6432
|
const now$3 = yield* now;
|
|
6100
6433
|
const result = verifyDpopProof({
|
|
@@ -6113,7 +6446,7 @@ const verifyRequestDpopProof = (input) => gen(function* () {
|
|
|
6113
6446
|
});
|
|
6114
6447
|
}
|
|
6115
6448
|
const secretStore = yield* ServerSecretStore;
|
|
6116
|
-
const replayKey = yield*
|
|
6449
|
+
const replayKey = yield* Digest.pipe(flatMap((digest) => digest.digest(sha256$1, new TextEncoder().encode(`${result.thumbprint}:${result.jti}`))), map$1(encode$2), mapError((cause) => new ServerAuthDpopReplayKeyCalculationError({ cause })));
|
|
6117
6450
|
yield* secretStore.create(`${DPOP_REPLAY_MARKER_PREFIX}${replayKey}`, new TextEncoder().encode([
|
|
6118
6451
|
`thumbprint=${result.thumbprint}`,
|
|
6119
6452
|
`jti=${result.jti}`,
|
|
@@ -6142,6 +6475,18 @@ const browserApiCorsAllowedHeaders = [
|
|
|
6142
6475
|
];
|
|
6143
6476
|
/** Origins of the Electron renderer, packaged and dev. */
|
|
6144
6477
|
const DESKTOP_RENDERER_ORIGINS = ["p4code://app", "p4code-dev://app"];
|
|
6478
|
+
// ../../node_modules/.pnpm/effect@4.1.2/node_modules/effect/dist/sql/Migrator.js
|
|
6479
|
+
/**
|
|
6480
|
+
* Runs SQL migrations with `SqlClient`.
|
|
6481
|
+
*
|
|
6482
|
+
* A migrator loads numbered migration effects, records completed ids in a
|
|
6483
|
+
* migrations table, and runs only pending migrations in a transaction. It
|
|
6484
|
+
* creates the table when needed, detects duplicate ids, treats concurrent runs
|
|
6485
|
+
* as locked, and can dump the schema after successful migrations.
|
|
6486
|
+
*
|
|
6487
|
+
* @stability unstable
|
|
6488
|
+
* @since 4.0.0
|
|
6489
|
+
*/
|
|
6145
6490
|
/**
|
|
6146
6491
|
* Error raised while loading, validating, locking, or running SQL migrations.
|
|
6147
6492
|
*
|
|
@@ -6149,19 +6494,27 @@ const DESKTOP_RENDERER_ORIGINS = ["p4code://app", "p4code-dev://app"];
|
|
|
6149
6494
|
* @category errors
|
|
6150
6495
|
* @since 4.0.0
|
|
6151
6496
|
*/
|
|
6152
|
-
var MigrationError = class extends (/*#__PURE__*/ TaggedError
|
|
6497
|
+
var MigrationError = class extends (/*#__PURE__*/ TaggedError("MigrationError")) {};
|
|
6153
6498
|
/**
|
|
6154
6499
|
* Creates a migrator that ensures the migrations table exists, runs pending
|
|
6155
6500
|
* migrations in a transaction, and optionally dumps the schema after successful
|
|
6156
|
-
* migrations.
|
|
6501
|
+
* migrations. ClickHouse runs without a transaction and records each migration
|
|
6502
|
+
* only after it succeeds.
|
|
6503
|
+
*
|
|
6504
|
+
* **Details**
|
|
6505
|
+
*
|
|
6506
|
+
* `transformWrites` transforms only the effects that create the migrations
|
|
6507
|
+
* table and insert into it, for clients such as ClickHouse that run row-less
|
|
6508
|
+
* statements differently from queries. Reads of the migrations table and the
|
|
6509
|
+
* migrations themselves are not transformed. It defaults to `identity`.
|
|
6157
6510
|
*
|
|
6158
6511
|
* @stability unstable
|
|
6159
6512
|
* @category constructors
|
|
6160
6513
|
* @since 4.0.0
|
|
6161
6514
|
*/
|
|
6162
|
-
const make$15 = ({ dumpSchema = () => void_ }) => ({ loader, schemaDirectory, table = "effect_sql_migrations" }) => gen(function* () {
|
|
6515
|
+
const make$15 = ({ transformWrites = identity, dumpSchema = () => void_ }) => ({ loader, schemaDirectory, table = "effect_sql_migrations" }) => gen(function* () {
|
|
6163
6516
|
const sql = yield* SqlClient;
|
|
6164
|
-
const
|
|
6517
|
+
const createMigrationsTable = transformWrites(sql.onDialectOrElse({
|
|
6165
6518
|
mssql: () => sql`IF OBJECT_ID(N'${sql.literal(table)}', N'U') IS NULL
|
|
6166
6519
|
CREATE TABLE ${sql(table)} (
|
|
6167
6520
|
migration_id INT NOT NULL PRIMARY KEY,
|
|
@@ -6174,22 +6527,32 @@ const make$15 = ({ dumpSchema = () => void_ }) => ({ loader, schemaDirectory, ta
|
|
|
6174
6527
|
name VARCHAR(255) NOT NULL,
|
|
6175
6528
|
PRIMARY KEY (migration_id)
|
|
6176
6529
|
)`,
|
|
6177
|
-
|
|
6530
|
+
clickhouse: () => sql`CREATE TABLE IF NOT EXISTS ${sql(table)} (
|
|
6531
|
+
migration_id Int32,
|
|
6532
|
+
created_at DateTime DEFAULT now(),
|
|
6533
|
+
name String
|
|
6534
|
+
) ENGINE = MergeTree
|
|
6535
|
+
ORDER BY migration_id`,
|
|
6536
|
+
pg: () => sql`CREATE TABLE ${sql(table)} (
|
|
6178
6537
|
migration_id integer primary key,
|
|
6179
6538
|
created_at timestamp with time zone not null default now(),
|
|
6180
6539
|
name text not null
|
|
6181
|
-
)
|
|
6540
|
+
)`,
|
|
6182
6541
|
orElse: () => sql`CREATE TABLE IF NOT EXISTS ${sql(table)} (
|
|
6183
6542
|
migration_id integer PRIMARY KEY NOT NULL,
|
|
6184
6543
|
created_at datetime NOT NULL DEFAULT current_timestamp,
|
|
6185
6544
|
name VARCHAR(255) NOT NULL
|
|
6186
6545
|
)`
|
|
6546
|
+
}));
|
|
6547
|
+
const ensureMigrationsTable = sql.onDialectOrElse({
|
|
6548
|
+
pg: () => flatMap(migrationsTableExists(sql, table), (exists) => exists ? void_ : asVoid(createMigrationsTable).pipe(catch_((error) => flatMap(migrationsTableExists(sql, table), (exists) => exists ? void_ : fail(error))))),
|
|
6549
|
+
orElse: () => createMigrationsTable
|
|
6187
6550
|
});
|
|
6188
|
-
const insertMigrations = (rows) => sql`INSERT INTO ${sql(table)} ${sql.insert(
|
|
6551
|
+
const insertMigrations = (rows) => transformWrites(sql`INSERT INTO ${sql(table)} ${sql.insert(map$2(rows, ([migration_id, name]) => ({
|
|
6189
6552
|
migration_id,
|
|
6190
6553
|
name
|
|
6191
|
-
})))}`.withoutTransform;
|
|
6192
|
-
const latestMigration = map$1(sql`SELECT migration_id, name, created_at FROM ${sql(table)} ORDER BY migration_id DESC`.withoutTransform, (_) => map$
|
|
6554
|
+
})))}`.withoutTransform);
|
|
6555
|
+
const latestMigration = map$1(sql`SELECT migration_id, name, created_at FROM ${sql(table)} ORDER BY migration_id DESC`.withoutTransform, (_) => map$3(fromNullishOr(_[0]), ({ created_at, migration_id, name }) => ({
|
|
6193
6556
|
id: migration_id,
|
|
6194
6557
|
name,
|
|
6195
6558
|
createdAt: created_at
|
|
@@ -6204,11 +6567,15 @@ const make$15 = ({ dumpSchema = () => void_ }) => ({ loader, schemaDirectory, ta
|
|
|
6204
6567
|
kind: "ImportError",
|
|
6205
6568
|
message: `Default export was not an Effect for migration "${id}_${name}"`
|
|
6206
6569
|
})));
|
|
6207
|
-
const runMigration = (id, name, effect) =>
|
|
6570
|
+
const runMigration = (id, name, effect) => mapError(effect, (error) => new MigrationError({
|
|
6208
6571
|
cause: error,
|
|
6209
6572
|
kind: "Failed",
|
|
6210
6573
|
message: `Migration "${id}_${name}" failed`
|
|
6211
|
-
}))
|
|
6574
|
+
}));
|
|
6575
|
+
const transactional = sql.onDialectOrElse({
|
|
6576
|
+
clickhouse: () => false,
|
|
6577
|
+
orElse: () => true
|
|
6578
|
+
});
|
|
6212
6579
|
const run = gen(function* () {
|
|
6213
6580
|
yield* sql.onDialectOrElse({
|
|
6214
6581
|
pg: () => sql`LOCK TABLE ${sql(table)} IN ACCESS EXCLUSIVE MODE`,
|
|
@@ -6232,11 +6599,11 @@ const make$15 = ({ dumpSchema = () => void_ }) => ({ loader, schemaDirectory, ta
|
|
|
6232
6599
|
yield* loadMigration(resolved)
|
|
6233
6600
|
]);
|
|
6234
6601
|
}
|
|
6235
|
-
if (
|
|
6602
|
+
if (transactional && isArrayNonEmpty(required)) yield* pipe(insertMigrations(map$2(required, ([id, name]) => [id, name])), mapError((error) => isConstraintConflict(error) ? new MigrationError({
|
|
6236
6603
|
kind: "Locked",
|
|
6237
6604
|
message: "Migrations already running"
|
|
6238
6605
|
}) : error));
|
|
6239
|
-
yield* forEach(required, ([id, name, effect]) => logDebug(`Running migration`).pipe(flatMap(() => runMigration(id, name, effect)), annotateLogs("migration_id", String(id)), annotateLogs("migration_name", name), withSpan(`Migrator ${id}_${name}`)), { discard: true });
|
|
6606
|
+
yield* forEach(required, ([id, name, effect]) => logDebug(`Running migration`).pipe(flatMap(() => runMigration(id, name, effect)), andThen(transactional ? void_ : insertMigrations([[id, name]])), annotateLogs("migration_id", String(id)), annotateLogs("migration_name", name), withSpan(`Migrator ${id}_${name}`)), { discard: true });
|
|
6240
6607
|
yield* pipe(latestMigration, flatMap(match({
|
|
6241
6608
|
onNone: () => logDebug(`Migrations complete`),
|
|
6242
6609
|
onSome: (_) => logDebug(`Migrations complete`).pipe(annotateLogs("latest_migration_id", _.id.toString()), annotateLogs("latest_migration_name", _.name))
|
|
@@ -6244,7 +6611,7 @@ const make$15 = ({ dumpSchema = () => void_ }) => ({ loader, schemaDirectory, ta
|
|
|
6244
6611
|
return required.map(([id, name]) => [id, name]);
|
|
6245
6612
|
});
|
|
6246
6613
|
yield* ensureMigrationsTable;
|
|
6247
|
-
const completed = yield* pipe(sql.withTransaction(run), catchTag("MigrationError", (_) => _.kind === "Locked" ? as(logDebug(_.message), []) : fail(_)));
|
|
6614
|
+
const completed = yield* pipe(transactional ? sql.withTransaction(run) : run, catchTag("MigrationError", (_) => _.kind === "Locked" ? as(logDebug(_.message), []) : fail(_)));
|
|
6248
6615
|
if (schemaDirectory && completed.length > 0) yield* dumpSchema(`${schemaDirectory}/_schema.sql`, table).pipe(catchCause((cause) => logInfo("Could not dump schema", cause)));
|
|
6249
6616
|
return completed;
|
|
6250
6617
|
});
|
|
@@ -6252,7 +6619,7 @@ const migrationsTableExists = (sql, table) => {
|
|
|
6252
6619
|
const quotedTable = sql`${sql(table)}`.compile(true)[0];
|
|
6253
6620
|
return map$1(sql`SELECT 1 AS found WHERE to_regclass(${quotedTable}) IS NOT NULL`.withoutTransform, (rows) => rows.length > 0);
|
|
6254
6621
|
};
|
|
6255
|
-
const migrationOrder = /*#__PURE__*/ make$
|
|
6622
|
+
const migrationOrder = /*#__PURE__*/ make$28(([a], [b]) => Number$1(a, b));
|
|
6256
6623
|
const isConstraintConflict = (error) => error.reason._tag === "ConstraintError" || error.reason._tag === "UniqueViolation";
|
|
6257
6624
|
/**
|
|
6258
6625
|
* Creates a migration loader from a record of migration effects keyed by
|
|
@@ -6262,7 +6629,7 @@ const isConstraintConflict = (error) => error.reason._tag === "ConstraintError"
|
|
|
6262
6629
|
* @category loaders
|
|
6263
6630
|
* @since 4.0.0
|
|
6264
6631
|
*/
|
|
6265
|
-
const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishOr((_) => _.match(/^(\d+)_(.+)$/)), map$
|
|
6632
|
+
const fromRecord = (migrations) => pipe(Object.keys(migrations), flatMapNullishOr((_) => _.match(/^(\d+)_(.+)$/)), map$2(([key, id, name]) => [
|
|
6266
6633
|
Number(id),
|
|
6267
6634
|
name,
|
|
6268
6635
|
succeed(migrations[key])
|
|
@@ -9630,7 +9997,7 @@ const runMigrations = fn("runMigrations")(function* ({ toMigrationInclusive } =
|
|
|
9630
9997
|
return executedMigrations;
|
|
9631
9998
|
});
|
|
9632
9999
|
// src/persistence/initializeV2Database.ts
|
|
9633
|
-
var V2DatabaseImportError = class extends TaggedError()("V2DatabaseImportError", {
|
|
10000
|
+
var V2DatabaseImportError = class extends TaggedError$1()("V2DatabaseImportError", {
|
|
9634
10001
|
sourcePath: String$1,
|
|
9635
10002
|
destinationPath: String$1,
|
|
9636
10003
|
cause: Defect()
|
|
@@ -9710,7 +10077,7 @@ const layerFromPath = fn("makeSqlitePersistenceLive")(function* (dbPath) {
|
|
|
9710
10077
|
const fs = yield* FileSystem;
|
|
9711
10078
|
const path = yield* Path;
|
|
9712
10079
|
yield* fs.makeDirectory(path.dirname(dbPath), { recursive: true });
|
|
9713
|
-
return provideMerge(layerSetup, layer$
|
|
10080
|
+
return provideMerge(layerSetup, layer$24({
|
|
9714
10081
|
filename: dbPath,
|
|
9715
10082
|
readerWorker: true,
|
|
9716
10083
|
checkpointWorker: true,
|
|
@@ -9720,7 +10087,7 @@ const layerFromPath = fn("makeSqlitePersistenceLive")(function* (dbPath) {
|
|
|
9720
10087
|
}
|
|
9721
10088
|
}));
|
|
9722
10089
|
}, unwrap);
|
|
9723
|
-
provideMerge(layerSetup, layer$
|
|
10090
|
+
provideMerge(layerSetup, layer$24({ filename: ":memory:" }));
|
|
9724
10091
|
const layerConfig = unwrap(gen(function* () {
|
|
9725
10092
|
const { dbPath } = yield* ServerConfig;
|
|
9726
10093
|
yield* initializeV2Database(dbPath);
|
|
@@ -9744,112 +10111,112 @@ const INTERNAL_ADMINISTRATIVE_BOOTSTRAP_SUBJECT = "administrative-bootstrap";
|
|
|
9744
10111
|
const MCP_CLIENT_SUBJECT = "mcp-client";
|
|
9745
10112
|
const MCP_CLIENT_SESSION_TTL = days(30);
|
|
9746
10113
|
const serverAuthInternalErrorContext = { cause: Defect() };
|
|
9747
|
-
var ServerAuthBootstrapCredentialValidationError = class extends TaggedError()("ServerAuthBootstrapCredentialValidationError", { ...serverAuthInternalErrorContext }) {
|
|
10114
|
+
var ServerAuthBootstrapCredentialValidationError = class extends TaggedError$1()("ServerAuthBootstrapCredentialValidationError", { ...serverAuthInternalErrorContext }) {
|
|
9748
10115
|
get message() {
|
|
9749
10116
|
return "Failed to validate bootstrap credential.";
|
|
9750
10117
|
}
|
|
9751
10118
|
};
|
|
9752
|
-
var ServerAuthSessionCredentialValidationError = class extends TaggedError()("ServerAuthSessionCredentialValidationError", { ...serverAuthInternalErrorContext }) {
|
|
10119
|
+
var ServerAuthSessionCredentialValidationError = class extends TaggedError$1()("ServerAuthSessionCredentialValidationError", { ...serverAuthInternalErrorContext }) {
|
|
9753
10120
|
get message() {
|
|
9754
10121
|
return "Failed to validate session credential.";
|
|
9755
10122
|
}
|
|
9756
10123
|
};
|
|
9757
|
-
var ServerAuthAuthenticatedSessionIssueError = class extends TaggedError()("ServerAuthAuthenticatedSessionIssueError", { ...serverAuthInternalErrorContext }) {
|
|
10124
|
+
var ServerAuthAuthenticatedSessionIssueError = class extends TaggedError$1()("ServerAuthAuthenticatedSessionIssueError", { ...serverAuthInternalErrorContext }) {
|
|
9758
10125
|
get message() {
|
|
9759
10126
|
return "Failed to issue authenticated session.";
|
|
9760
10127
|
}
|
|
9761
10128
|
};
|
|
9762
|
-
var ServerAuthAuthenticatedAccessTokenIssueError = class extends TaggedError()("ServerAuthAuthenticatedAccessTokenIssueError", { ...serverAuthInternalErrorContext }) {
|
|
10129
|
+
var ServerAuthAuthenticatedAccessTokenIssueError = class extends TaggedError$1()("ServerAuthAuthenticatedAccessTokenIssueError", { ...serverAuthInternalErrorContext }) {
|
|
9763
10130
|
get message() {
|
|
9764
10131
|
return "Failed to issue authenticated access token.";
|
|
9765
10132
|
}
|
|
9766
10133
|
};
|
|
9767
|
-
var ServerAuthPairingLinkCreationError = class extends TaggedError()("ServerAuthPairingLinkCreationError", { ...serverAuthInternalErrorContext }) {
|
|
10134
|
+
var ServerAuthPairingLinkCreationError = class extends TaggedError$1()("ServerAuthPairingLinkCreationError", { ...serverAuthInternalErrorContext }) {
|
|
9768
10135
|
get message() {
|
|
9769
10136
|
return "Failed to create pairing link.";
|
|
9770
10137
|
}
|
|
9771
10138
|
};
|
|
9772
|
-
var ServerAuthPairingLinksListError = class extends TaggedError()("ServerAuthPairingLinksListError", { ...serverAuthInternalErrorContext }) {
|
|
10139
|
+
var ServerAuthPairingLinksListError = class extends TaggedError$1()("ServerAuthPairingLinksListError", { ...serverAuthInternalErrorContext }) {
|
|
9773
10140
|
get message() {
|
|
9774
10141
|
return "Failed to list pairing links.";
|
|
9775
10142
|
}
|
|
9776
10143
|
};
|
|
9777
|
-
var ServerAuthPairingLinkRevocationError = class extends TaggedError()("ServerAuthPairingLinkRevocationError", { ...serverAuthInternalErrorContext }) {
|
|
10144
|
+
var ServerAuthPairingLinkRevocationError = class extends TaggedError$1()("ServerAuthPairingLinkRevocationError", { ...serverAuthInternalErrorContext }) {
|
|
9778
10145
|
get message() {
|
|
9779
10146
|
return "Failed to revoke pairing link.";
|
|
9780
10147
|
}
|
|
9781
10148
|
};
|
|
9782
|
-
var ServerAuthSessionTokenIssueError = class extends TaggedError()("ServerAuthSessionTokenIssueError", { ...serverAuthInternalErrorContext }) {
|
|
10149
|
+
var ServerAuthSessionTokenIssueError = class extends TaggedError$1()("ServerAuthSessionTokenIssueError", { ...serverAuthInternalErrorContext }) {
|
|
9783
10150
|
get message() {
|
|
9784
10151
|
return "Failed to issue session token.";
|
|
9785
10152
|
}
|
|
9786
10153
|
};
|
|
9787
|
-
var ServerAuthSessionsListError = class extends TaggedError()("ServerAuthSessionsListError", { ...serverAuthInternalErrorContext }) {
|
|
10154
|
+
var ServerAuthSessionsListError = class extends TaggedError$1()("ServerAuthSessionsListError", { ...serverAuthInternalErrorContext }) {
|
|
9788
10155
|
get message() {
|
|
9789
10156
|
return "Failed to list sessions.";
|
|
9790
10157
|
}
|
|
9791
10158
|
};
|
|
9792
|
-
var ServerAuthSessionRevocationError = class extends TaggedError()("ServerAuthSessionRevocationError", { ...serverAuthInternalErrorContext }) {
|
|
10159
|
+
var ServerAuthSessionRevocationError = class extends TaggedError$1()("ServerAuthSessionRevocationError", { ...serverAuthInternalErrorContext }) {
|
|
9793
10160
|
get message() {
|
|
9794
10161
|
return "Failed to revoke session.";
|
|
9795
10162
|
}
|
|
9796
10163
|
};
|
|
9797
|
-
var ServerAuthOtherSessionsRevocationError = class extends TaggedError()("ServerAuthOtherSessionsRevocationError", { ...serverAuthInternalErrorContext }) {
|
|
10164
|
+
var ServerAuthOtherSessionsRevocationError = class extends TaggedError$1()("ServerAuthOtherSessionsRevocationError", { ...serverAuthInternalErrorContext }) {
|
|
9798
10165
|
get message() {
|
|
9799
10166
|
return "Failed to revoke other sessions.";
|
|
9800
10167
|
}
|
|
9801
10168
|
};
|
|
9802
|
-
var ServerAuthWebSocketTokenIssueError = class extends TaggedError()("ServerAuthWebSocketTokenIssueError", { ...serverAuthInternalErrorContext }) {
|
|
10169
|
+
var ServerAuthWebSocketTokenIssueError = class extends TaggedError$1()("ServerAuthWebSocketTokenIssueError", { ...serverAuthInternalErrorContext }) {
|
|
9803
10170
|
get message() {
|
|
9804
10171
|
return "Failed to issue websocket token.";
|
|
9805
10172
|
}
|
|
9806
10173
|
};
|
|
9807
|
-
var ServerAuthDpopReplayStateRecordError = class extends TaggedError()("ServerAuthDpopReplayStateRecordError", { ...serverAuthInternalErrorContext }) {
|
|
10174
|
+
var ServerAuthDpopReplayStateRecordError = class extends TaggedError$1()("ServerAuthDpopReplayStateRecordError", { ...serverAuthInternalErrorContext }) {
|
|
9808
10175
|
get message() {
|
|
9809
10176
|
return "Failed to record DPoP proof replay state.";
|
|
9810
10177
|
}
|
|
9811
10178
|
};
|
|
9812
|
-
var ServerAuthDpopReplayKeyCalculationError = class extends TaggedError()("ServerAuthDpopReplayKeyCalculationError", { ...serverAuthInternalErrorContext }) {
|
|
10179
|
+
var ServerAuthDpopReplayKeyCalculationError = class extends TaggedError$1()("ServerAuthDpopReplayKeyCalculationError", { ...serverAuthInternalErrorContext }) {
|
|
9813
10180
|
get message() {
|
|
9814
10181
|
return "Failed to calculate DPoP replay key.";
|
|
9815
10182
|
}
|
|
9816
10183
|
};
|
|
9817
|
-
var ServerAuthLinkedCloudAccountVerificationError = class extends TaggedError()("ServerAuthLinkedCloudAccountVerificationError", { ...serverAuthInternalErrorContext }) {
|
|
10184
|
+
var ServerAuthLinkedCloudAccountVerificationError = class extends TaggedError$1()("ServerAuthLinkedCloudAccountVerificationError", { ...serverAuthInternalErrorContext }) {
|
|
9818
10185
|
get message() {
|
|
9819
10186
|
return "Could not verify the linked cloud account.";
|
|
9820
10187
|
}
|
|
9821
10188
|
};
|
|
9822
|
-
var ServerAuthLinkedCloudAccountReadError = class extends TaggedError()("ServerAuthLinkedCloudAccountReadError", { ...serverAuthInternalErrorContext }) {
|
|
10189
|
+
var ServerAuthLinkedCloudAccountReadError = class extends TaggedError$1()("ServerAuthLinkedCloudAccountReadError", { ...serverAuthInternalErrorContext }) {
|
|
9823
10190
|
get message() {
|
|
9824
10191
|
return "Could not read the linked cloud account.";
|
|
9825
10192
|
}
|
|
9826
10193
|
};
|
|
9827
|
-
var ServerAuthLinkedCloudAccountMissingError = class extends TaggedError()("ServerAuthLinkedCloudAccountMissingError", {}) {
|
|
10194
|
+
var ServerAuthLinkedCloudAccountMissingError = class extends TaggedError$1()("ServerAuthLinkedCloudAccountMissingError", {}) {
|
|
9828
10195
|
get message() {
|
|
9829
10196
|
return "Cloud linked user is not installed for this environment.";
|
|
9830
10197
|
}
|
|
9831
10198
|
};
|
|
9832
|
-
var ServerAuthCloudLinkJwtSigningError = class extends TaggedError()("ServerAuthCloudLinkJwtSigningError", { ...serverAuthInternalErrorContext }) {
|
|
10199
|
+
var ServerAuthCloudLinkJwtSigningError = class extends TaggedError$1()("ServerAuthCloudLinkJwtSigningError", { ...serverAuthInternalErrorContext }) {
|
|
9833
10200
|
get message() {
|
|
9834
10201
|
return "Failed to sign cloud link JWT.";
|
|
9835
10202
|
}
|
|
9836
10203
|
};
|
|
9837
|
-
var ServerAuthCloudMintPublicKeyMissingError = class extends TaggedError()("ServerAuthCloudMintPublicKeyMissingError", {}) {
|
|
10204
|
+
var ServerAuthCloudMintPublicKeyMissingError = class extends TaggedError$1()("ServerAuthCloudMintPublicKeyMissingError", {}) {
|
|
9838
10205
|
get message() {
|
|
9839
10206
|
return "Cloud mint public key is not installed for this environment.";
|
|
9840
10207
|
}
|
|
9841
10208
|
};
|
|
9842
|
-
var ServerAuthCloudRelayIssuerMissingError = class extends TaggedError()("ServerAuthCloudRelayIssuerMissingError", {}) {
|
|
10209
|
+
var ServerAuthCloudRelayIssuerMissingError = class extends TaggedError$1()("ServerAuthCloudRelayIssuerMissingError", {}) {
|
|
9843
10210
|
get message() {
|
|
9844
10211
|
return "Cloud relay issuer is not installed for this environment.";
|
|
9845
10212
|
}
|
|
9846
10213
|
};
|
|
9847
|
-
var ServerAuthCloudHealthJwtSigningError = class extends TaggedError()("ServerAuthCloudHealthJwtSigningError", { ...serverAuthInternalErrorContext }) {
|
|
10214
|
+
var ServerAuthCloudHealthJwtSigningError = class extends TaggedError$1()("ServerAuthCloudHealthJwtSigningError", { ...serverAuthInternalErrorContext }) {
|
|
9848
10215
|
get message() {
|
|
9849
10216
|
return "Failed to sign cloud health JWT.";
|
|
9850
10217
|
}
|
|
9851
10218
|
};
|
|
9852
|
-
var ServerAuthCloudMintJwtSigningError = class extends TaggedError()("ServerAuthCloudMintJwtSigningError", { ...serverAuthInternalErrorContext }) {
|
|
10219
|
+
var ServerAuthCloudMintJwtSigningError = class extends TaggedError$1()("ServerAuthCloudMintJwtSigningError", { ...serverAuthInternalErrorContext }) {
|
|
9853
10220
|
get message() {
|
|
9854
10221
|
return "Failed to sign cloud mint JWT.";
|
|
9855
10222
|
}
|
|
@@ -9879,12 +10246,12 @@ const ServerAuthInternalError = Union([
|
|
|
9879
10246
|
ServerAuthCloudMintJwtSigningError
|
|
9880
10247
|
]);
|
|
9881
10248
|
const isServerAuthInternalError = is(ServerAuthInternalError);
|
|
9882
|
-
var ServerAuthMissingCredentialError = class extends TaggedError()("ServerAuthMissingCredentialError", {}) {
|
|
10249
|
+
var ServerAuthMissingCredentialError = class extends TaggedError$1()("ServerAuthMissingCredentialError", {}) {
|
|
9883
10250
|
get message() {
|
|
9884
10251
|
return "Server authentication credential is missing.";
|
|
9885
10252
|
}
|
|
9886
10253
|
};
|
|
9887
|
-
var ServerAuthInvalidCredentialError = class extends TaggedError()("ServerAuthInvalidCredentialError", {
|
|
10254
|
+
var ServerAuthInvalidCredentialError = class extends TaggedError$1()("ServerAuthInvalidCredentialError", {
|
|
9888
10255
|
diagnostic: optional(String$1),
|
|
9889
10256
|
dpopFailureReason: optionalKey(DpopFailureReason),
|
|
9890
10257
|
cause: optional(Defect())
|
|
@@ -9897,12 +10264,12 @@ const ServerAuthCredentialError = Union([ServerAuthMissingCredentialError, Serve
|
|
|
9897
10264
|
const isServerAuthCredentialError = is(ServerAuthCredentialError);
|
|
9898
10265
|
const serverAuthCredentialReason = (error) => error._tag === "ServerAuthMissingCredentialError" ? "missing_credential" : "invalid_credential";
|
|
9899
10266
|
const serverAuthDpopFailureReason = (error) => error._tag === "ServerAuthInvalidCredentialError" ? error.dpopFailureReason : void 0;
|
|
9900
|
-
var ServerAuthInvalidScopeError = class extends TaggedError()("ServerAuthInvalidScopeError", {}) {
|
|
10267
|
+
var ServerAuthInvalidScopeError = class extends TaggedError$1()("ServerAuthInvalidScopeError", {}) {
|
|
9901
10268
|
get message() {
|
|
9902
10269
|
return "The requested authentication scope is invalid.";
|
|
9903
10270
|
}
|
|
9904
10271
|
};
|
|
9905
|
-
var ServerAuthScopeNotGrantedError = class extends TaggedError()("ServerAuthScopeNotGrantedError", {}) {
|
|
10272
|
+
var ServerAuthScopeNotGrantedError = class extends TaggedError$1()("ServerAuthScopeNotGrantedError", {}) {
|
|
9906
10273
|
get message() {
|
|
9907
10274
|
return "The requested authentication scope was not granted.";
|
|
9908
10275
|
}
|
|
@@ -9910,7 +10277,7 @@ var ServerAuthScopeNotGrantedError = class extends TaggedError()("ServerAuthScop
|
|
|
9910
10277
|
const ServerAuthInvalidRequestError = Union([ServerAuthInvalidScopeError, ServerAuthScopeNotGrantedError]);
|
|
9911
10278
|
const isServerAuthInvalidRequestError = is(ServerAuthInvalidRequestError);
|
|
9912
10279
|
const serverAuthInvalidRequestReason = (error) => error._tag === "ServerAuthInvalidScopeError" ? "invalid_scope" : "scope_not_granted";
|
|
9913
|
-
var ServerAuthMcpApprovalCodeError = class extends TaggedError()("ServerAuthMcpApprovalCodeError", { reason: Literals([
|
|
10280
|
+
var ServerAuthMcpApprovalCodeError = class extends TaggedError$1()("ServerAuthMcpApprovalCodeError", { reason: Literals([
|
|
9914
10281
|
"unknown_or_used",
|
|
9915
10282
|
"not_a_pairing_code",
|
|
9916
10283
|
"insufficient_scope"
|
|
@@ -9919,13 +10286,12 @@ var ServerAuthMcpApprovalCodeError = class extends TaggedError()("ServerAuthMcpA
|
|
|
9919
10286
|
return this.reason === "insufficient_scope" ? "That pairing code cannot grant this access. It has not been used, so choose an access level it grants, or create a code with the standard scopes." : this.reason === "not_a_pairing_code" ? "That is not a one-time pairing code." : "That pairing code is unknown, expired, or already used.";
|
|
9920
10287
|
}
|
|
9921
10288
|
};
|
|
9922
|
-
var ServerAuthForbiddenOperationError = class extends TaggedError()("ServerAuthForbiddenOperationError", {}) {
|
|
10289
|
+
var ServerAuthForbiddenOperationError = class extends TaggedError$1()("ServerAuthForbiddenOperationError", {}) {
|
|
9923
10290
|
get message() {
|
|
9924
10291
|
return "The current authentication session cannot revoke itself.";
|
|
9925
10292
|
}
|
|
9926
10293
|
};
|
|
9927
10294
|
var EnvironmentAuth = class extends Service()("@p4code/cli/auth/EnvironmentAuth") {};
|
|
9928
|
-
const DPOP_AUTHORIZATION_PREFIX = "DPoP ";
|
|
9929
10295
|
const WEBSOCKET_TICKET_QUERY_PARAM = "wsTicket";
|
|
9930
10296
|
const WEBSOCKET_PROOF_QUERY_PARAM = "dpop";
|
|
9931
10297
|
const bySessionPriority = (left, right) => {
|
|
@@ -9948,7 +10314,7 @@ function parseBearerToken(request) {
|
|
|
9948
10314
|
}
|
|
9949
10315
|
function parseDpopToken(request) {
|
|
9950
10316
|
const header = request.headers["authorization"];
|
|
9951
|
-
if (typeof header !== "string" ||
|
|
10317
|
+
if (typeof header !== "string" || !/^DPoP /i.test(header)) return null;
|
|
9952
10318
|
const token = header.slice(5).trim();
|
|
9953
10319
|
return token.length > 0 ? token : null;
|
|
9954
10320
|
}
|
|
@@ -10009,7 +10375,7 @@ const make$14 = gen(function* () {
|
|
|
10009
10375
|
const bootstrapCredentials = yield* PairingGrantStore;
|
|
10010
10376
|
const sessions = yield* SessionStore;
|
|
10011
10377
|
const secretStore = yield* ServerSecretStore;
|
|
10012
|
-
const
|
|
10378
|
+
const digest = yield* Digest;
|
|
10013
10379
|
const descriptor = yield* policy.getDescriptor();
|
|
10014
10380
|
const config = yield* ServerConfig;
|
|
10015
10381
|
const devAuth = resolveReusableDevAuth(config);
|
|
@@ -10050,7 +10416,7 @@ const make$14 = gen(function* () {
|
|
|
10050
10416
|
request,
|
|
10051
10417
|
expectedThumbprint: session.proofKeyThumbprint,
|
|
10052
10418
|
expectedAccessToken: dpopToken
|
|
10053
|
-
}).pipe(provideService(ServerSecretStore, secretStore), provideService(
|
|
10419
|
+
}).pipe(provideService(ServerSecretStore, secretStore), provideService(Digest, digest), as(session));
|
|
10054
10420
|
}
|
|
10055
10421
|
if (dpopToken) return fail(new ServerAuthInvalidCredentialError({
|
|
10056
10422
|
diagnostic: "DPoP authorization requires a proof-bound access token.",
|
|
@@ -10245,14 +10611,14 @@ const make$14 = gen(function* () {
|
|
|
10245
10611
|
})), withSpan("EnvironmentAuth.issueWebSocketTicket"));
|
|
10246
10612
|
const authenticateHttpRequest = (request) => authenticateRequest(request).pipe(withSpan("EnvironmentAuth.authenticateHttpRequest"));
|
|
10247
10613
|
const authenticateWebSocketUpgrade = fn("EnvironmentAuth.authenticateWebSocketUpgrade")(function* (request, use) {
|
|
10248
|
-
const
|
|
10249
|
-
if (isSome(
|
|
10250
|
-
const websocketTicket =
|
|
10614
|
+
const url = requestUrl(request);
|
|
10615
|
+
if (isSome(url)) {
|
|
10616
|
+
const websocketTicket = url.value.searchParams.get(WEBSOCKET_TICKET_QUERY_PARAM);
|
|
10251
10617
|
if (websocketTicket && websocketTicket.trim().length > 0) {
|
|
10252
10618
|
const session = yield* sessions.verifyWebSocketToken(websocketTicket).pipe(mapSessionVerificationErrors, flatMap(rejectMcpClientAudience));
|
|
10253
10619
|
if (session.audience !== void 0 && session.audience !== use) return yield* new ServerAuthInvalidCredentialError({ diagnostic: `WebSocket ticket was issued for the ${session.audience} route.` });
|
|
10254
10620
|
if (session.proofKeyThumbprint) {
|
|
10255
|
-
const proof = request.headers.dpop ??
|
|
10621
|
+
const proof = request.headers.dpop ?? url.value.searchParams.get(WEBSOCKET_PROOF_QUERY_PARAM) ?? void 0;
|
|
10256
10622
|
if (!proof) return yield* new ServerAuthInvalidCredentialError({
|
|
10257
10623
|
diagnostic: "DPoP-bound WebSocket ticket requires a DPoP proof.",
|
|
10258
10624
|
dpopFailureReason: "invalid_proof"
|
|
@@ -10262,7 +10628,7 @@ const make$14 = gen(function* () {
|
|
|
10262
10628
|
proof,
|
|
10263
10629
|
expectedThumbprint: session.proofKeyThumbprint,
|
|
10264
10630
|
expectedAccessToken: websocketTicket
|
|
10265
|
-
}).pipe(provideService(ServerSecretStore, secretStore), provideService(
|
|
10631
|
+
}).pipe(provideService(ServerSecretStore, secretStore), provideService(Digest, digest));
|
|
10266
10632
|
}
|
|
10267
10633
|
return {
|
|
10268
10634
|
sessionId: session.sessionId,
|
|
@@ -10339,9 +10705,9 @@ const make$14 = gen(function* () {
|
|
|
10339
10705
|
authenticateBrowserSession
|
|
10340
10706
|
});
|
|
10341
10707
|
});
|
|
10342
|
-
const layer$
|
|
10343
|
-
const layerStorage = mergeAll(layer$
|
|
10344
|
-
const layerRuntime = layer$
|
|
10708
|
+
const layer$14 = effect(EnvironmentAuth, make$14).pipe(provideMerge(layer$17), provideMerge(layer$15), provideMerge(layer$19));
|
|
10709
|
+
const layerStorage = mergeAll(layer$28, layerConfig);
|
|
10710
|
+
const layerRuntime = layer$14.pipe(provideMerge(layerStorage), provideMerge(layerIdentity));
|
|
10345
10711
|
// src/startupAccess.ts
|
|
10346
10712
|
const isLoopbackHost = (host) => {
|
|
10347
10713
|
if (!host || host.length === 0) return true;
|
|
@@ -10435,7 +10801,7 @@ const PersistedServerRuntimeState = Struct({
|
|
|
10435
10801
|
*/
|
|
10436
10802
|
serverVersion: optional(String$1)
|
|
10437
10803
|
});
|
|
10438
|
-
var ServerRuntimeStateError = class extends TaggedError()("ServerRuntimeStateError", {
|
|
10804
|
+
var ServerRuntimeStateError = class extends TaggedError$1()("ServerRuntimeStateError", {
|
|
10439
10805
|
operation: Literals([
|
|
10440
10806
|
"persist",
|
|
10441
10807
|
"read",
|
|
@@ -10520,6 +10886,265 @@ const readPersistedServerRuntimeState = (path) => gen(function* () {
|
|
|
10520
10886
|
statePath: error.statePath,
|
|
10521
10887
|
cause: error
|
|
10522
10888
|
}), as(none())) }));
|
|
10889
|
+
/**
|
|
10890
|
+
* Service that derives bytes from a secret.
|
|
10891
|
+
*
|
|
10892
|
+
* **Example** (Deriving a key with HKDF)
|
|
10893
|
+
*
|
|
10894
|
+
* ```ts import.meta.vitest
|
|
10895
|
+
* import { Effect } from "effect"
|
|
10896
|
+
* import { Kdf } from "effect/crypto"
|
|
10897
|
+
*
|
|
10898
|
+
* const program = Effect.gen(function*() {
|
|
10899
|
+
* const kdf = yield* Kdf.Kdf
|
|
10900
|
+
* return yield* kdf.derive(Kdf.hkdfSha256, new Uint8Array(32), {
|
|
10901
|
+
* salt: new Uint8Array(16),
|
|
10902
|
+
* info: new TextEncoder().encode("encryption"),
|
|
10903
|
+
* length: 32
|
|
10904
|
+
* })
|
|
10905
|
+
* })
|
|
10906
|
+
*
|
|
10907
|
+
* const bytes = await Effect.runPromise(program.pipe(Effect.provide(Kdf.layerWebCrypto)))
|
|
10908
|
+
* bytes.length // => 32
|
|
10909
|
+
* ```
|
|
10910
|
+
*
|
|
10911
|
+
* @stability unstable
|
|
10912
|
+
* @category services
|
|
10913
|
+
* @since 4.0.0
|
|
10914
|
+
*/
|
|
10915
|
+
var Kdf = class extends (/*#__PURE__*/ Service()("effect/crypto/Kdf")) {};
|
|
10916
|
+
const invalidArgument = (description) => fail$1("Kdf", "derive", new InvalidArgument({ description }));
|
|
10917
|
+
const isIntegerIn$1 = (n, min, max) => Number.isSafeInteger(n) && n >= min && n <= max;
|
|
10918
|
+
const checkArguments = (algorithm, options) => {
|
|
10919
|
+
if (algorithm._tag !== "Hkdf" && options.info !== void 0) return invalidArgument("info only applies to HKDF");
|
|
10920
|
+
if (algorithm._tag === "Argon2id") return void 0;
|
|
10921
|
+
if (algorithm.hash.name === "MD5") return invalidArgument(`${algorithm._tag} needs a SHA hash, not MD5`);
|
|
10922
|
+
if (algorithm._tag === "Hkdf") {
|
|
10923
|
+
const maxLength = 255 * algorithm.hash.outputLength;
|
|
10924
|
+
return isIntegerIn$1(options.length, 1, maxLength) ? void 0 : invalidArgument(`length must be between 1 and ${maxLength} bytes for ${algorithm.name}`);
|
|
10925
|
+
}
|
|
10926
|
+
if (!isIntegerIn$1(algorithm.iterations, 1, 2147483647)) return invalidArgument("iterations must be between 1 and 2^31 - 1");
|
|
10927
|
+
return isIntegerIn$1(options.length, 1, 536870911) ? void 0 : invalidArgument("length must be between 1 and 2^29 - 1 bytes");
|
|
10928
|
+
};
|
|
10929
|
+
const webCryptoParams = (algorithm, options) => algorithm._tag === "Hkdf" ? {
|
|
10930
|
+
name: "HKDF",
|
|
10931
|
+
hash: algorithm.hash.name,
|
|
10932
|
+
salt: options.salt,
|
|
10933
|
+
info: options.info ?? /* @__PURE__ */ new Uint8Array()
|
|
10934
|
+
} : {
|
|
10935
|
+
name: "PBKDF2",
|
|
10936
|
+
hash: algorithm.hash.name,
|
|
10937
|
+
salt: options.salt,
|
|
10938
|
+
iterations: algorithm.iterations
|
|
10939
|
+
};
|
|
10940
|
+
/**
|
|
10941
|
+
* Layer that provides `Kdf` on the `WebCrypto` reference.
|
|
10942
|
+
*
|
|
10943
|
+
* **Details**
|
|
10944
|
+
*
|
|
10945
|
+
* HKDF and PBKDF2 run on `crypto.subtle`, off the event loop where the runtime
|
|
10946
|
+
* supports it. Argon2id fails with an `Unsupported` reason.
|
|
10947
|
+
*
|
|
10948
|
+
* @stability unstable
|
|
10949
|
+
* @category layers
|
|
10950
|
+
* @since 4.0.0
|
|
10951
|
+
*/
|
|
10952
|
+
const layerWebCrypto = /*#__PURE__*/ effect(Kdf, /*#__PURE__*/ WebCrypto.use((crypto) => succeed(Kdf.of({ derive: (algorithm, secret, options) => suspend(() => {
|
|
10953
|
+
const failure = checkArguments(algorithm, options);
|
|
10954
|
+
if (failure !== void 0) return failure;
|
|
10955
|
+
if (algorithm._tag === "Argon2id") return fail$1("Kdf", "derive", new Unsupported({ description: "Kdf.layerWebCrypto does not provide argon2id" }));
|
|
10956
|
+
const name = algorithm._tag === "Hkdf" ? "HKDF" : "PBKDF2";
|
|
10957
|
+
return run$2("Kdf", "derive", algorithm.name, crypto, async (subtle) => {
|
|
10958
|
+
const handle = await subtle.importKey("raw", secret, name, false, ["deriveBits"]);
|
|
10959
|
+
return new Uint8Array(await subtle.deriveBits(webCryptoParams(algorithm, options), handle, options.length * 8));
|
|
10960
|
+
});
|
|
10961
|
+
}) }))));
|
|
10962
|
+
// ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_bufferutil@4.1.0_effect@4.1.2_utf-8-validate@6.0.6/node_modules/@effect/platform-node-shared/dist/NodeCrypto.js
|
|
10963
|
+
/**
|
|
10964
|
+
* Node.js layers for the `effect/crypto` modules, also used by Bun.
|
|
10965
|
+
*
|
|
10966
|
+
* {@link layerDigest} runs MD5 and SHA on `node:crypto`, {@link layerMac} runs
|
|
10967
|
+
* HMAC on `node:crypto`, {@link layerKdf} adds Argon2id, {@link layerAead}
|
|
10968
|
+
* runs ChaCha20-Poly1305 on `node:crypto`, and {@link layerSecureRandom},
|
|
10969
|
+
* {@link layerCipher}, {@link layerSignature}, {@link layerKeyAgreement}, and
|
|
10970
|
+
* {@link layerKeyWrap} run the core WebCrypto layers. Each Node.js layer
|
|
10971
|
+
* handles only the algorithms and keys it exists for and hands the rest to
|
|
10972
|
+
* the core WebCrypto implementation. Layers that need `SecureRandom` get it
|
|
10973
|
+
* from {@link layerSecureRandom}, so no layer here has requirements.
|
|
10974
|
+
* {@link layer} provides every family at once; provide a family's own layer to
|
|
10975
|
+
* pick services selectively.
|
|
10976
|
+
*
|
|
10977
|
+
* `CryptoKey`-backed keys go through Node.js's `crypto.subtle`, because
|
|
10978
|
+
* `KeyObject.from(cryptoKey)` is deprecated (DEP0204). A `CryptoKey` must
|
|
10979
|
+
* come from the `WebCrypto` reference: Node.js rejects one from another
|
|
10980
|
+
* reference with a `TypeError`, which is a defect.
|
|
10981
|
+
*
|
|
10982
|
+
* @stability unstable
|
|
10983
|
+
* @since 1.0.0
|
|
10984
|
+
*/
|
|
10985
|
+
/**
|
|
10986
|
+
* Layer that provides `SecureRandom` from `getRandomValues` on the `WebCrypto`
|
|
10987
|
+
* reference.
|
|
10988
|
+
*
|
|
10989
|
+
* **Details**
|
|
10990
|
+
*
|
|
10991
|
+
* This is `SecureRandom.layerWebCrypto`, re-exported so that Node.js programs
|
|
10992
|
+
* take every crypto layer from `NodeCrypto`. `node:crypto` adds nothing here.
|
|
10993
|
+
*
|
|
10994
|
+
* @stability unstable
|
|
10995
|
+
* @category layers
|
|
10996
|
+
* @since 4.0.0
|
|
10997
|
+
*/
|
|
10998
|
+
const layerSecureRandom = layerWebCrypto$1;
|
|
10999
|
+
const nodeHashNames = {
|
|
11000
|
+
"MD5": "md5",
|
|
11001
|
+
"SHA-1": "sha1",
|
|
11002
|
+
"SHA-256": "sha256",
|
|
11003
|
+
"SHA-384": "sha384",
|
|
11004
|
+
"SHA-512": "sha512"
|
|
11005
|
+
};
|
|
11006
|
+
const nodeDigest = (algorithm, data) => new Uint8Array(NodeCrypto.createHash(nodeHashNames[algorithm.name]).update(data).digest());
|
|
11007
|
+
/**
|
|
11008
|
+
* Layer that provides `Digest` using `createHash` from `node:crypto`.
|
|
11009
|
+
*
|
|
11010
|
+
* **Details**
|
|
11011
|
+
*
|
|
11012
|
+
* MD5 and the SHA algorithms run synchronously on `node:crypto`. On Node.js,
|
|
11013
|
+
* `crypto.subtle.digest` sends each call to the threadpool, which is
|
|
11014
|
+
* noticeably slower for small inputs. Output is identical to
|
|
11015
|
+
* `Digest.layerWebCrypto`.
|
|
11016
|
+
*
|
|
11017
|
+
* @stability unstable
|
|
11018
|
+
* @category layers
|
|
11019
|
+
* @since 4.0.0
|
|
11020
|
+
*/
|
|
11021
|
+
const layerDigest = /*#__PURE__*/ succeed$1(Digest, {
|
|
11022
|
+
digest: (algorithm, data) => sync$2(() => nodeDigest(algorithm, data)),
|
|
11023
|
+
digestHex: (algorithm, data) => sync$2(() => NodeCrypto.createHash(nodeHashNames[algorithm.name]).update(data).digest("hex"))
|
|
11024
|
+
});
|
|
11025
|
+
const nodeHmac = (hash, key, data) => new Uint8Array(NodeCrypto.createHmac(nodeHashNames[hash], key).update(data).digest());
|
|
11026
|
+
/**
|
|
11027
|
+
* Layer that provides `Mac` using `createHmac` from `node:crypto`.
|
|
11028
|
+
*
|
|
11029
|
+
* **Details**
|
|
11030
|
+
*
|
|
11031
|
+
* Byte-backed keys sign and verify synchronously on `node:crypto`, since
|
|
11032
|
+
* webhook verification is a server hot path. `CryptoKey`-backed keys go
|
|
11033
|
+
* through Node.js's `crypto.subtle`, and generated keys come from
|
|
11034
|
+
* {@link layerSecureRandom}. This is `Mac.layerWebCryptoWith` with a
|
|
11035
|
+
* `node:crypto` primitive, so output and errors are identical to
|
|
11036
|
+
* `Mac.layerWebCrypto`.
|
|
11037
|
+
*
|
|
11038
|
+
* @stability unstable
|
|
11039
|
+
* @category layers
|
|
11040
|
+
* @since 4.0.0
|
|
11041
|
+
*/
|
|
11042
|
+
const layerMac = /*#__PURE__*/ layerWebCryptoWith({ hmac: nodeHmac }).pipe(/*#__PURE__*/ provide$1(layerSecureRandom));
|
|
11043
|
+
const kdfFailure = (reason) => fail(new CryptoError({
|
|
11044
|
+
module: "Kdf",
|
|
11045
|
+
method: "derive",
|
|
11046
|
+
reason
|
|
11047
|
+
}));
|
|
11048
|
+
const argon2Unsupported = (cause) => kdfFailure(new Unsupported({
|
|
11049
|
+
description: "NodeCrypto.layerKdf does not provide argon2id on this runtime",
|
|
11050
|
+
...cause === void 0 ? {} : { cause }
|
|
11051
|
+
}));
|
|
11052
|
+
const argon2Failure = (cause) => typeof cause === "object" && cause !== null && "code" in cause && cause.code === "ERR_CRYPTO_ARGON2_NOT_SUPPORTED" ? argon2Unsupported(cause) : die(cause);
|
|
11053
|
+
const isIntegerIn = (n, min, max) => Number.isSafeInteger(n) && n >= min && n <= max;
|
|
11054
|
+
const argon2Problem = (algorithm, options) => {
|
|
11055
|
+
if (options.info !== void 0) return "info only applies to HKDF";
|
|
11056
|
+
const uint32 = (n) => isIntegerIn(n, 1, 4294967295);
|
|
11057
|
+
if (!uint32(algorithm.passes) || !isIntegerIn(algorithm.parallelism, 1, 16777215)) return "passes must be between 1 and 2^32 - 1 and parallelism between 1 and 2^24 - 1";
|
|
11058
|
+
if (!uint32(algorithm.memory) || algorithm.memory < 8 * algorithm.parallelism) return "memory must be at least 8 KiB per lane and below 2^32 KiB";
|
|
11059
|
+
if (options.salt.length < 8) return "salt must be at least 8 bytes";
|
|
11060
|
+
return isIntegerIn(options.length, 4, 4294967295) ? void 0 : "length must be between 4 and 2^32 - 1 bytes";
|
|
11061
|
+
};
|
|
11062
|
+
const argon2id = (algorithm, secret, options) => callback((resume) => {
|
|
11063
|
+
const problem = argon2Problem(algorithm, options);
|
|
11064
|
+
if (problem !== void 0) return resume(kdfFailure(new InvalidArgument({ description: problem })));
|
|
11065
|
+
if (typeof NodeCrypto.argon2 !== "function") return resume(argon2Unsupported());
|
|
11066
|
+
try {
|
|
11067
|
+
NodeCrypto.argon2("argon2id", {
|
|
11068
|
+
message: secret,
|
|
11069
|
+
nonce: options.salt,
|
|
11070
|
+
memory: algorithm.memory,
|
|
11071
|
+
passes: algorithm.passes,
|
|
11072
|
+
parallelism: algorithm.parallelism,
|
|
11073
|
+
tagLength: options.length
|
|
11074
|
+
}, (cause, key) => {
|
|
11075
|
+
if (cause) resume(argon2Failure(cause));
|
|
11076
|
+
else resume(succeed(new Uint8Array(key.buffer, key.byteOffset, key.length)));
|
|
11077
|
+
});
|
|
11078
|
+
} catch (cause) {
|
|
11079
|
+
resume(argon2Failure(cause));
|
|
11080
|
+
}
|
|
11081
|
+
}).pipe(uninterruptible);
|
|
11082
|
+
/**
|
|
11083
|
+
* Layer that provides `Kdf`, adding Argon2id from `node:crypto`.
|
|
11084
|
+
*
|
|
11085
|
+
* **Details**
|
|
11086
|
+
*
|
|
11087
|
+
* Argon2id runs on `argon2` from `node:crypto`, which needs Node.js 24.7 or
|
|
11088
|
+
* later linked against OpenSSL 3.2, or Bun 1.4. Support is checked at call
|
|
11089
|
+
* time: on other runtimes, deriving with Argon2id fails with an `Unsupported`
|
|
11090
|
+
* reason. HKDF and PBKDF2 go through `Kdf.layerWebCrypto`, which keeps them
|
|
11091
|
+
* off the event loop.
|
|
11092
|
+
*
|
|
11093
|
+
* @stability unstable
|
|
11094
|
+
* @category layers
|
|
11095
|
+
* @since 4.0.0
|
|
11096
|
+
*/
|
|
11097
|
+
const layerKdf = /*#__PURE__*/ effect(Kdf, gen(function* () {
|
|
11098
|
+
const core = yield* Kdf;
|
|
11099
|
+
return Kdf.of({ derive: (algorithm, secret, options) => algorithm._tag === "Argon2id" ? argon2id(algorithm, secret, options) : core.derive(algorithm, secret, options) });
|
|
11100
|
+
})).pipe(/*#__PURE__*/ provide$1(layerWebCrypto));
|
|
11101
|
+
const concat = (parts) => {
|
|
11102
|
+
const output = new Uint8Array(parts.reduce((length, part) => length + part.length, 0));
|
|
11103
|
+
let offset = 0;
|
|
11104
|
+
for (const part of parts) {
|
|
11105
|
+
output.set(part, offset);
|
|
11106
|
+
offset += part.length;
|
|
11107
|
+
part.fill(0);
|
|
11108
|
+
}
|
|
11109
|
+
return output;
|
|
11110
|
+
};
|
|
11111
|
+
/**
|
|
11112
|
+
* Layer that provides every `effect/crypto` service with the Node.js
|
|
11113
|
+
* implementations.
|
|
11114
|
+
*
|
|
11115
|
+
* **Details**
|
|
11116
|
+
*
|
|
11117
|
+
* This merges the family layers of this module, so it requires nothing. It
|
|
11118
|
+
* keeps the `node:crypto` implementations of {@link layerDigest},
|
|
11119
|
+
* {@link layerMac}, {@link layerKdf}, and {@link layerAead}.
|
|
11120
|
+
*
|
|
11121
|
+
* @stability unstable
|
|
11122
|
+
* @category layers
|
|
11123
|
+
* @since 4.0.0
|
|
11124
|
+
*/
|
|
11125
|
+
const layer$13 = /*#__PURE__*/ mergeAll(layerSecureRandom, layerDigest, layerMac, layerKdf, /* @__PURE__ */ layerWebCryptoWith$1(NodeCrypto.getCiphers().includes("chacha20-poly1305") ? { implementations: { chacha20Poly1305: {
|
|
11126
|
+
encrypt: (key, nonce, plaintext, aad) => {
|
|
11127
|
+
const cipher = NodeCrypto.createCipheriv("chacha20-poly1305", key, nonce, { authTagLength: 16 });
|
|
11128
|
+
cipher.setAAD(aad);
|
|
11129
|
+
return concat([
|
|
11130
|
+
cipher.update(plaintext),
|
|
11131
|
+
cipher.final(),
|
|
11132
|
+
cipher.getAuthTag()
|
|
11133
|
+
]);
|
|
11134
|
+
},
|
|
11135
|
+
decrypt: (key, nonce, ciphertext, aad) => {
|
|
11136
|
+
const decipher = NodeCrypto.createDecipheriv("chacha20-poly1305", key, nonce, { authTagLength: 16 });
|
|
11137
|
+
decipher.setAAD(aad);
|
|
11138
|
+
decipher.setAuthTag(ciphertext.subarray(ciphertext.length - 16));
|
|
11139
|
+
const plaintext = decipher.update(ciphertext.subarray(0, ciphertext.length - 16));
|
|
11140
|
+
try {
|
|
11141
|
+
return concat([plaintext, decipher.final()]);
|
|
11142
|
+
} catch {
|
|
11143
|
+
plaintext.fill(0);
|
|
11144
|
+
return;
|
|
11145
|
+
}
|
|
11146
|
+
}
|
|
11147
|
+
} } } : {}).pipe(/*#__PURE__*/ provide$1(layerSecureRandom)), /* @__PURE__ */ layerWebCrypto$2.pipe(/*#__PURE__*/ provide$1(layerSecureRandom)), /* @__PURE__ */ layerWebCrypto$3.pipe(/*#__PURE__*/ provide$1(layerSecureRandom)), /* @__PURE__ */ layerWebCrypto$4.pipe(/*#__PURE__*/ provide$1(layerSecureRandom)), /* @__PURE__ */ layerWebCrypto$5.pipe(/*#__PURE__*/ provide$1(layerSecureRandom)));
|
|
10523
11148
|
// ../../packages/shared/src/hostClassification.ts
|
|
10524
11149
|
const normalizeHostname = (host) => host.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/u, "");
|
|
10525
11150
|
const parseIpv4Address = (host) => {
|
|
@@ -10605,7 +11230,7 @@ const isPrivateNetworkHost = (host) => {
|
|
|
10605
11230
|
return Number.isInteger(firstIpv6Hextet) && ((firstIpv6Hextet & 65024) === 64512 || (firstIpv6Hextet & 65472) === 65152);
|
|
10606
11231
|
};
|
|
10607
11232
|
// src/peer/PeerLinks.ts
|
|
10608
|
-
const PeerHttpApi = make$
|
|
11233
|
+
const PeerHttpApi = make$33(EnvironmentHttpApi.identifier).add(EnvironmentHttpApi.groups.metadata).add(EnvironmentHttpApi.groups.mcpOAuth).annotateMerge(EnvironmentHttpApi.annotations);
|
|
10609
11234
|
/** The redirect registered for a link. Nothing ever listens there: the code comes back in the response. */
|
|
10610
11235
|
const LINK_REDIRECT_URI = "http://127.0.0.1/p4code-peer-link";
|
|
10611
11236
|
/**
|
|
@@ -10613,6 +11238,14 @@ const LINK_REDIRECT_URI = "http://127.0.0.1/p4code-peer-link";
|
|
|
10613
11238
|
* A tailnet or relayed route to a machine that is waking up takes longer.
|
|
10614
11239
|
*/
|
|
10615
11240
|
const probeTimeout = (origin) => isLocalLoopbackHost(new URL(origin).hostname) ? seconds(3) : seconds(10);
|
|
11241
|
+
/** Node's TLS verification code in a failed request's cause chain, if any. */
|
|
11242
|
+
const certificateErrorCode = (error) => {
|
|
11243
|
+
let current = error;
|
|
11244
|
+
for (let depth = 0; depth < 6 && isObject(current); depth++) {
|
|
11245
|
+
if (hasProperty(current, "code") && typeof current.code === "string" && /CERT|SELF_SIGNED|UNABLE_TO_(GET|VERIFY)|INVALID_(CA|PURPOSE)|PATH_LENGTH_EXCEEDED|HOSTNAME_MISMATCH/.test(current.code)) return current.code;
|
|
11246
|
+
current = hasProperty(current, "cause") ? current.cause : void 0;
|
|
11247
|
+
}
|
|
11248
|
+
};
|
|
10616
11249
|
const LINKED_ENVIRONMENTS_OFF = "Linked environments is off on this machine. Turn it on in Settings → Connections.";
|
|
10617
11250
|
/**
|
|
10618
11251
|
* Links from this environment to others. Linking signs this environment in to
|
|
@@ -10652,16 +11285,32 @@ const linkLimitsHold = (peer) => peer.capabilities.mcpModeLimitHeader === true &
|
|
|
10652
11285
|
const make$13 = gen(function* () {
|
|
10653
11286
|
const sql = yield* SqlClient;
|
|
10654
11287
|
const secrets = yield* ServerSecretStore;
|
|
10655
|
-
const
|
|
11288
|
+
const random = yield* SecureRandom;
|
|
11289
|
+
const digest = yield* Digest;
|
|
10656
11290
|
const httpClient = yield* HttpClient;
|
|
10657
11291
|
const environment = yield* ServerEnvironment;
|
|
10658
11292
|
const enabled = (yield* ServerSettingsService).getSettings.pipe(map$1((settings) => settings.linkedEnvironmentsEnabled), orElseSucceed(() => false));
|
|
10659
11293
|
/** A fresh name for one link's token; the row records it. */
|
|
10660
|
-
const newSecretName =
|
|
11294
|
+
const newSecretName = random.randomBytes(16).pipe(map$1((bytes) => `peer-link-${encode(bytes)}`), orDie);
|
|
10661
11295
|
const peerHttpClient = transform(httpClient, (response) => provideService(response, RequestInit, { redirect: "manual" }));
|
|
10662
|
-
const clientFor = (origin) => make$
|
|
10663
|
-
/**
|
|
10664
|
-
|
|
11296
|
+
const clientFor = (origin) => make$43(PeerHttpApi, { baseUrl: origin }).pipe(provideService(HttpClient, peerHttpClient));
|
|
11297
|
+
/**
|
|
11298
|
+
* The environment answering at `origin`, or nothing when it does not answer
|
|
11299
|
+
* as P4 Code. A certificate this machine rejects fails instead, since
|
|
11300
|
+
* the peer may well be there.
|
|
11301
|
+
*/
|
|
11302
|
+
const describe = (origin) => clientFor(origin).pipe(flatMap((client) => client.metadata.descriptor()), timeout(probeTimeout(origin)), asSome, catch_((error) => {
|
|
11303
|
+
const code = certificateErrorCode(error);
|
|
11304
|
+
return code === void 0 ? succeed(none()) : fail(new PeerLinkError({
|
|
11305
|
+
reason: "unreachable",
|
|
11306
|
+
message: `${origin} presented a certificate this machine rejected (${code}).`
|
|
11307
|
+
}));
|
|
11308
|
+
}));
|
|
11309
|
+
/** Whether `url` answers as `environmentId`, counting an untrusted certificate as no. */
|
|
11310
|
+
const answersAs = fn("PeerLinks.answersAs")(function* (url, environmentId) {
|
|
11311
|
+
const found = yield* describe(url).pipe(orElseSucceed(() => none()));
|
|
11312
|
+
return filter(found, (peer) => peer.environmentId === environmentId);
|
|
11313
|
+
});
|
|
10665
11314
|
const toLink = fn("PeerLinks.toLink")(function* (row) {
|
|
10666
11315
|
return {
|
|
10667
11316
|
environmentId: EnvironmentId.make(row.environment_id),
|
|
@@ -10692,9 +11341,9 @@ const make$13 = gen(function* () {
|
|
|
10692
11341
|
reason: "pairing_rejected",
|
|
10693
11342
|
message: `The peer refused to register this environment: ${error.message}`
|
|
10694
11343
|
}))));
|
|
10695
|
-
const verifier = encode$2(yield*
|
|
10696
|
-
const challenge = encode$2(yield*
|
|
10697
|
-
const state = encode$2(yield*
|
|
11344
|
+
const verifier = encode$2(yield* random.randomBytes(32));
|
|
11345
|
+
const challenge = encode$2(yield* digest.digest(sha256$1, new TextEncoder().encode(verifier)).pipe(orDie));
|
|
11346
|
+
const state = encode$2(yield* random.randomBytes(16));
|
|
10698
11347
|
const resource = `${origin}/mcp`;
|
|
10699
11348
|
const decided = yield* client.mcpOAuth.decision({ payload: {
|
|
10700
11349
|
authorization: {
|
|
@@ -10858,7 +11507,7 @@ const make$13 = gen(function* () {
|
|
|
10858
11507
|
enabled: active
|
|
10859
11508
|
};
|
|
10860
11509
|
});
|
|
10861
|
-
const describeUrl = (url) => peerOrigin(url).pipe(flatMap(describe), map$1(map$
|
|
11510
|
+
const describeUrl = (url) => peerOrigin(url).pipe(flatMap(describe), map$1(map$3((peer) => ({
|
|
10862
11511
|
environmentId: peer.environmentId,
|
|
10863
11512
|
label: peer.label
|
|
10864
11513
|
}))), orElseSucceed(() => none()));
|
|
@@ -10876,8 +11525,8 @@ const make$13 = gen(function* () {
|
|
|
10876
11525
|
status: "expired"
|
|
10877
11526
|
};
|
|
10878
11527
|
let label = link.label;
|
|
10879
|
-
const answered = yield* findFirst(link.urls, (url) =>
|
|
10880
|
-
if (isNone(found)
|
|
11528
|
+
const answered = yield* findFirst(link.urls, (url) => answersAs(url, link.environmentId).pipe(map$1((found) => {
|
|
11529
|
+
if (isNone(found)) return false;
|
|
10881
11530
|
label = found.value.label;
|
|
10882
11531
|
return true;
|
|
10883
11532
|
})));
|
|
@@ -10937,8 +11586,8 @@ const make$13 = gen(function* () {
|
|
|
10937
11586
|
});
|
|
10938
11587
|
let fenced = true;
|
|
10939
11588
|
let label = link.label;
|
|
10940
|
-
const url = yield* findFirst(link.urls, (candidate) =>
|
|
10941
|
-
if (isNone(found)
|
|
11589
|
+
const url = yield* findFirst(link.urls, (candidate) => answersAs(candidate, environmentId).pipe(map$1((found) => {
|
|
11590
|
+
if (isNone(found)) return false;
|
|
10942
11591
|
fenced = linkLimitsHold(found.value);
|
|
10943
11592
|
label = found.value.label;
|
|
10944
11593
|
return true;
|
|
@@ -11036,12 +11685,12 @@ const DEBIAN_PACKAGES = [
|
|
|
11036
11685
|
["libasound2t64", "libasound2"],
|
|
11037
11686
|
["libexpat1"]
|
|
11038
11687
|
];
|
|
11039
|
-
var PreviewBrowserSandboxError = class extends TaggedError()("PreviewBrowserSandboxError", { setupCommand: String$1 }) {
|
|
11688
|
+
var PreviewBrowserSandboxError = class extends TaggedError$1()("PreviewBrowserSandboxError", { setupCommand: String$1 }) {
|
|
11040
11689
|
get message() {
|
|
11041
11690
|
return `This host blocks the sandbox P4's browser runs in (AppArmor on Ubuntu 23.10+). Run \`${this.setupCommand}\` on the host once to allow it, then try again.`;
|
|
11042
11691
|
}
|
|
11043
11692
|
};
|
|
11044
|
-
var PreviewBrowserLibrariesError = class extends TaggedError()("PreviewBrowserLibrariesError", {
|
|
11693
|
+
var PreviewBrowserLibrariesError = class extends TaggedError$1()("PreviewBrowserLibrariesError", {
|
|
11045
11694
|
setupCommand: String$1,
|
|
11046
11695
|
libraries: ArraySchema(String$1)
|
|
11047
11696
|
}) {
|
|
@@ -11050,7 +11699,7 @@ var PreviewBrowserLibrariesError = class extends TaggedError()("PreviewBrowserLi
|
|
|
11050
11699
|
}
|
|
11051
11700
|
};
|
|
11052
11701
|
/** Chrome will not start its sandbox as root (crbug.com/638180), which no host setup fixes. */
|
|
11053
|
-
var PreviewBrowserRootError = class extends TaggedError()("PreviewBrowserRootError", {}) {
|
|
11702
|
+
var PreviewBrowserRootError = class extends TaggedError$1()("PreviewBrowserRootError", {}) {
|
|
11054
11703
|
get message() {
|
|
11055
11704
|
return "P4 Code server is running as root; Chrome's sandbox cannot start. Run P4 Code as a nonroot user. Otherwise set `P4CODE_SERVER_BROWSER_SANDBOX=0` in the P4 Code server's environment and restart the server; this disables Chrome's sandbox. Manual: `P4CODE_SERVER_BROWSER_SANDBOX=0 p4c serve`. Systemd: add `Environment=P4CODE_SERVER_BROWSER_SANDBOX=0` under `[Service]`, reload systemd, then restart the service. `p4c browser setup` cannot fix root sandboxing.";
|
|
11056
11705
|
}
|
|
@@ -11081,7 +11730,7 @@ const diagnoseLaunchFailure = fn("PreviewBrowserHost.diagnoseLaunchFailure")(fun
|
|
|
11081
11730
|
*/
|
|
11082
11731
|
const missingLibraries = fn("PreviewBrowserHost.missingLibraries")(function* (executable) {
|
|
11083
11732
|
const spawner = yield* ChildProcessSpawner;
|
|
11084
|
-
const run = (command, args) => spawner.string(make$
|
|
11733
|
+
const run = (command, args) => spawner.string(make$44(command, args, { stdin: "ignore" }), { includeStderr: true }).pipe(timeout("5 seconds"), orElseSucceed(() => ""));
|
|
11085
11734
|
const loaderError = LOADER_ERROR.exec(yield* run(executable, ["--version"]))?.[1];
|
|
11086
11735
|
if (loaderError === void 0) return [];
|
|
11087
11736
|
const listed = [...(yield* run("ldd", [executable])).matchAll(MISSING_LIBRARY)].map((match) => match[1]);
|
|
@@ -11103,8 +11752,8 @@ const CLOUDFLARED_VERSION = "2026.10.4";
|
|
|
11103
11752
|
const CLOUDFLARED_MIN_VERSION = "2025.6.1";
|
|
11104
11753
|
const CLOUDFLARED_PATH_ENV_NAME = "P4CODE_CLOUDFLARED_PATH";
|
|
11105
11754
|
const CLOUDFLARED_DOWNLOAD_TIMEOUT = "10 minutes";
|
|
11106
|
-
var RelayClientInstallError = class extends TaggedError
|
|
11107
|
-
var CloudflaredCommandError = class extends TaggedError
|
|
11755
|
+
var RelayClientInstallError = class extends TaggedError("RelayClientInstallError") {};
|
|
11756
|
+
var CloudflaredCommandError = class extends TaggedError("CloudflaredCommandError") {};
|
|
11108
11757
|
const CLOUDFLARED_RELEASE_ASSETS = {
|
|
11109
11758
|
"darwin-arm64": {
|
|
11110
11759
|
url: "https://github.com/cloudflare/cloudflared/releases/download/2026.10.4/cloudflared-darwin-arm64.tgz",
|
|
@@ -11143,7 +11792,7 @@ const INSTALL_LOCK_LEGACY_STALE_MS = 18e5;
|
|
|
11143
11792
|
const VERSION_PROBE_TIMEOUT = "10 seconds";
|
|
11144
11793
|
const ACTIVATE_RETRY_COUNT = 40;
|
|
11145
11794
|
const ACTIVATE_RETRY_DELAY = "250 millis";
|
|
11146
|
-
const trimmedString = (name) => String$2(name).pipe(option$1, map$
|
|
11795
|
+
const trimmedString = (name) => String$2(name).pipe(option$1, map$5(flatMap$1((value) => {
|
|
11147
11796
|
const trimmed = value.trim();
|
|
11148
11797
|
return trimmed.length > 0 ? some(trimmed) : none();
|
|
11149
11798
|
})));
|
|
@@ -11190,7 +11839,7 @@ function parseCloudflaredVersionOutput(output) {
|
|
|
11190
11839
|
const version = parseVersion(output);
|
|
11191
11840
|
return version ? version.join(".") : null;
|
|
11192
11841
|
}
|
|
11193
|
-
var VersionProbeKey = class extends Class
|
|
11842
|
+
var VersionProbeKey = class extends Class {};
|
|
11194
11843
|
function isLockContention(error) {
|
|
11195
11844
|
const code = error.reason.cause?.code;
|
|
11196
11845
|
return error.reason._tag === "AlreadyExists" || error.reason._tag === "BadResource" || code === "ENOTEMPTY" || isTransientWindowsLock(error);
|
|
@@ -11219,12 +11868,13 @@ const wrapInstallFailure = (reason, message) => (effect) => effect.pipe(mapError
|
|
|
11219
11868
|
cause
|
|
11220
11869
|
})));
|
|
11221
11870
|
const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
11222
|
-
const
|
|
11871
|
+
const random = yield* SecureRandom;
|
|
11872
|
+
const digest = yield* Digest;
|
|
11223
11873
|
const fileSystem = yield* FileSystem;
|
|
11224
11874
|
const httpClient = yield* HttpClient;
|
|
11225
11875
|
const path = yield* Path;
|
|
11226
11876
|
const spawner = yield* ChildProcessSpawner;
|
|
11227
|
-
const installSemaphore = yield* make$
|
|
11877
|
+
const installSemaphore = yield* make$39(1);
|
|
11228
11878
|
const platform = yield* Platform;
|
|
11229
11879
|
const arch = yield* Architecture;
|
|
11230
11880
|
const releaseAsset = options.releaseAsset ?? resolveReleaseAsset(platform, arch);
|
|
@@ -11237,7 +11887,7 @@ const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
|
11237
11887
|
if (isNone(info) || info.value.type !== "File") return false;
|
|
11238
11888
|
return platform === "win32" || (info.value.mode & 73) !== 0;
|
|
11239
11889
|
});
|
|
11240
|
-
const versionCache = yield* makeWith((key) => spawner.string(make$
|
|
11890
|
+
const versionCache = yield* makeWith((key) => spawner.string(make$44(key.executablePath, ["version"], {
|
|
11241
11891
|
stdin: "ignore",
|
|
11242
11892
|
stderr: "ignore"
|
|
11243
11893
|
})).pipe(map$1(parseCloudflaredVersionOutput), timeoutOption(VERSION_PROBE_TIMEOUT), map$1(getOrNull), orElseSucceed(() => null)), {
|
|
@@ -11248,7 +11898,7 @@ const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
|
11248
11898
|
const info = yield* fileSystem.stat(executablePath).pipe(option);
|
|
11249
11899
|
if (isNone(info) || info.value.type !== "File") return null;
|
|
11250
11900
|
if (platform !== "win32" && (info.value.mode & 73) === 0) return null;
|
|
11251
|
-
return yield* get$
|
|
11901
|
+
return yield* get$3(versionCache, new VersionProbeKey({
|
|
11252
11902
|
executablePath,
|
|
11253
11903
|
size: Number(info.value.size),
|
|
11254
11904
|
mtimeMillis: getOrUndefined(info.value.mtime)?.getTime() ?? 0
|
|
@@ -11335,7 +11985,7 @@ const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
|
11335
11985
|
while: (error) => platform === "win32" && isTransientWindowsLock(error)
|
|
11336
11986
|
}));
|
|
11337
11987
|
const runCommand = fn("cloudflared.runCommand")(function* (command, args) {
|
|
11338
|
-
const child = yield* spawner.spawn(make$
|
|
11988
|
+
const child = yield* spawner.spawn(make$44(command, args, {
|
|
11339
11989
|
shell: false,
|
|
11340
11990
|
stdout: "ignore",
|
|
11341
11991
|
stderr: "ignore"
|
|
@@ -11348,7 +11998,7 @@ const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
|
11348
11998
|
});
|
|
11349
11999
|
const downloadAsset = fn("cloudflared.downloadAsset")(function* (asset, report) {
|
|
11350
12000
|
yield* report("downloading");
|
|
11351
|
-
const response = yield* httpClient.execute(get$
|
|
12001
|
+
const response = yield* httpClient.execute(get$1(asset.url)).pipe(timeout(CLOUDFLARED_DOWNLOAD_TIMEOUT), flatMap(filterStatusOk$1), mapError((cause) => new RelayClientInstallError({
|
|
11352
12002
|
reason: "download_failed",
|
|
11353
12003
|
message: "Could not download the relay client.",
|
|
11354
12004
|
cause
|
|
@@ -11359,7 +12009,7 @@ const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
|
11359
12009
|
cause
|
|
11360
12010
|
}))));
|
|
11361
12011
|
yield* report("verifying");
|
|
11362
|
-
const checksum = yield*
|
|
12012
|
+
const checksum = yield* digest.digest(sha256$1, bytes).pipe(mapError((cause) => new RelayClientInstallError({
|
|
11363
12013
|
reason: "validation_failed",
|
|
11364
12014
|
message: "Could not verify the downloaded relay client checksum.",
|
|
11365
12015
|
cause
|
|
@@ -11376,7 +12026,7 @@ const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
|
11376
12026
|
yield* removeEmptyLock(lockPath);
|
|
11377
12027
|
});
|
|
11378
12028
|
const acquireInstallLock = fn("cloudflared.acquireInstallLock")(function* (lockPath) {
|
|
11379
|
-
const owner = `${process.pid}-${yield*
|
|
12029
|
+
const owner = `${process.pid}-${yield* random.uuidV4()}`;
|
|
11380
12030
|
const candidate = yield* acquireRelease(fileSystem.makeTempDirectory({
|
|
11381
12031
|
directory: path.dirname(lockPath),
|
|
11382
12032
|
prefix: ".lock-"
|
|
@@ -11469,7 +12119,7 @@ const makeCloudflaredRelayClient = fn("cloudflared.make")(function* (options) {
|
|
|
11469
12119
|
reason: "validation_failed",
|
|
11470
12120
|
message: installedVersion === null ? "The downloaded relay client binary did not run." : `The downloaded relay client reports version ${installedVersion}, not ${CLOUDFLARED_VERSION}.`
|
|
11471
12121
|
});
|
|
11472
|
-
const stagedPath = `${managedPath}.${yield*
|
|
12122
|
+
const stagedPath = `${managedPath}.${yield* random.uuidV4()}.tmp`;
|
|
11473
12123
|
yield* report("activating");
|
|
11474
12124
|
yield* renameWhenUnlocked(executablePath, stagedPath).pipe(wrapInstallFailure("write_failed", "Could not stage the relay client."));
|
|
11475
12125
|
yield* renameWhenUnlocked(stagedPath, managedPath).pipe(wrapInstallFailure("write_failed", "Could not activate the relay client."), ensuring(fileSystem.remove(stagedPath, { force: true }).pipe(ignore)));
|
|
@@ -11553,7 +12203,7 @@ function traceSafeExit(exit) {
|
|
|
11553
12203
|
})));
|
|
11554
12204
|
}
|
|
11555
12205
|
function nonInterferingTracer(delegate) {
|
|
11556
|
-
return make$
|
|
12206
|
+
return make$27({
|
|
11557
12207
|
span(options) {
|
|
11558
12208
|
const span = delegate.span(options);
|
|
11559
12209
|
const end = span.end.bind(span);
|
|
@@ -11569,7 +12219,7 @@ function nonInterferingTracer(delegate) {
|
|
|
11569
12219
|
}
|
|
11570
12220
|
function layer$11(config, resource) {
|
|
11571
12221
|
if (config === null) return succeed$1(RelayClientTracer, none());
|
|
11572
|
-
const layerTracer = layer$
|
|
12222
|
+
const layerTracer = layer$21({
|
|
11573
12223
|
url: config.tracesUrl,
|
|
11574
12224
|
headers: {
|
|
11575
12225
|
Authorization: `Bearer ${config.tracesToken}`,
|
|
@@ -11585,8 +12235,8 @@ function layer$11(config, resource) {
|
|
|
11585
12235
|
"p4.client.surface": resource.client
|
|
11586
12236
|
}
|
|
11587
12237
|
}
|
|
11588
|
-
}).pipe(provide(layerJson));
|
|
11589
|
-
return effect(RelayClientTracer, Tracer.pipe(map$1(nonInterferingTracer), asSome)).pipe(provide(layerTracer));
|
|
12238
|
+
}).pipe(provide$1(layerJson));
|
|
12239
|
+
return effect(RelayClientTracer, Tracer.pipe(map$1(nonInterferingTracer), asSome)).pipe(provide$1(layerTracer));
|
|
11590
12240
|
}
|
|
11591
12241
|
// src/cloud/CliState.ts
|
|
11592
12242
|
const CLOUD_CLI_DESIRED_LINK_SECRET = "cloud-cli-desired-link";
|
|
@@ -11639,7 +12289,393 @@ const clearPersistedCloudLink = gen(function* () {
|
|
|
11639
12289
|
secrets.remove(CLOUD_LINK_REVOKED)
|
|
11640
12290
|
], { concurrency: "unbounded" });
|
|
11641
12291
|
});
|
|
11642
|
-
|
|
12292
|
+
const http = /*#__PURE__*/ (/* @__PURE__ */ createRequire(typeof __filename === "string" ? __filename : import.meta.url))("node:http");
|
|
12293
|
+
// ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_bufferutil@4.1.0_effect@4.1.2_utf-8-validate@6.0.6/node_modules/@effect/platform-node-shared/dist/NodeSocket.js
|
|
12294
|
+
/**
|
|
12295
|
+
* Node socket adapters for Effect sockets.
|
|
12296
|
+
*
|
|
12297
|
+
* This module opens `node:net` or `node:tls` connections, or wraps existing
|
|
12298
|
+
* Node `Duplex` streams, and presents them as `Socket.Socket` values, socket
|
|
12299
|
+
* channels, or layers. It also exposes the `NetSocket` service tag for the
|
|
12300
|
+
* underlying Node socket.
|
|
12301
|
+
*
|
|
12302
|
+
* @stability unstable
|
|
12303
|
+
* @since 4.0.0
|
|
12304
|
+
*/
|
|
12305
|
+
const isDeno = "Deno" in globalThis;
|
|
12306
|
+
const readAvailable = (conn, chunkSize) => {
|
|
12307
|
+
const first = conn.read();
|
|
12308
|
+
if (first === null) return void 0;
|
|
12309
|
+
const out = [first];
|
|
12310
|
+
let chunk;
|
|
12311
|
+
while (out.length < chunkSize && (chunk = conn.read()) !== null) out.push(chunk);
|
|
12312
|
+
return out;
|
|
12313
|
+
};
|
|
12314
|
+
const toBuffers = (input) => map$2(ensure(input), (value) => Buffer$1.from(value));
|
|
12315
|
+
/**
|
|
12316
|
+
* Adapts a Node `Duplex` into a `Socket.Socket`.
|
|
12317
|
+
*
|
|
12318
|
+
* **Details**
|
|
12319
|
+
*
|
|
12320
|
+
* Reader acquisition opens the duplex and keeps it paused: each pull reads at
|
|
12321
|
+
* most `chunkSize` chunks (default 4096) with `stream.read()`. On Node 26+ that
|
|
12322
|
+
* yields each buffered chunk as a separate batch element with no copy. Earlier Node
|
|
12323
|
+
* concatenates the buffer into one chunk. The stream is never resumed, so once
|
|
12324
|
+
* Node's buffer reaches its `highWaterMark` the kernel receive window closes
|
|
12325
|
+
* and the peer blocks: backpressure is end-to-end with no buffering above
|
|
12326
|
+
* Node's own.
|
|
12327
|
+
*
|
|
12328
|
+
* Writes use `write()` return-value backpressure, awaiting one `drain` when
|
|
12329
|
+
* the internal buffer is full. `writeAll` corks the stream around the batch.
|
|
12330
|
+
* Releasing the writer scope half-closes the stream (`end()`).
|
|
12331
|
+
*
|
|
12332
|
+
* @stability unstable
|
|
12333
|
+
* @category constructors
|
|
12334
|
+
* @since 4.0.0
|
|
12335
|
+
*/
|
|
12336
|
+
const fromDuplex = (open, options) => withFiber((fiber) => {
|
|
12337
|
+
let currentSocket;
|
|
12338
|
+
const latch = makeUnsafe$3(false);
|
|
12339
|
+
const openServices = fiber.context;
|
|
12340
|
+
const isServer = options?.tlsServer === true;
|
|
12341
|
+
const requestedChunkSize = options?.chunkSize ?? 4096;
|
|
12342
|
+
const chunkSize = requestedChunkSize === Infinity || Number.isSafeInteger(requestedChunkSize) && requestedChunkSize > 0 ? requestedChunkSize : 4096;
|
|
12343
|
+
const secureEvent = isServer ? "secure" : "secureConnect";
|
|
12344
|
+
const reader = gen(function* () {
|
|
12345
|
+
const scope$3 = yield* scope;
|
|
12346
|
+
let conn = yield* provide$2(open, scope$3).pipe(options?.openTimeout !== void 0 ? timeoutOrElse({
|
|
12347
|
+
duration: options.openTimeout,
|
|
12348
|
+
orElse: () => fail(new SocketError({ reason: new SocketOpenError({
|
|
12349
|
+
kind: "Timeout",
|
|
12350
|
+
cause: /* @__PURE__ */ new Error("Connection timed out")
|
|
12351
|
+
}) }))
|
|
12352
|
+
}) : identity);
|
|
12353
|
+
let error;
|
|
12354
|
+
let waiter;
|
|
12355
|
+
let pending;
|
|
12356
|
+
let reading = false;
|
|
12357
|
+
let closed = false;
|
|
12358
|
+
let upgradeAvailable = true;
|
|
12359
|
+
function drain() {
|
|
12360
|
+
if (waiter === void 0 || reading) return;
|
|
12361
|
+
let chunk = pending;
|
|
12362
|
+
pending = void 0;
|
|
12363
|
+
if (chunk === void 0 && !closed) {
|
|
12364
|
+
reading = true;
|
|
12365
|
+
try {
|
|
12366
|
+
chunk = readAvailable(conn, chunkSize);
|
|
12367
|
+
} finally {
|
|
12368
|
+
reading = false;
|
|
12369
|
+
}
|
|
12370
|
+
}
|
|
12371
|
+
if (closed) chunk = void 0;
|
|
12372
|
+
if (waiter === void 0) {
|
|
12373
|
+
pending = chunk;
|
|
12374
|
+
return;
|
|
12375
|
+
}
|
|
12376
|
+
const result = chunk !== void 0 ? succeed(chunk) : error !== void 0 ? fail(error) : void 0;
|
|
12377
|
+
if (result === void 0) return;
|
|
12378
|
+
const resume = waiter;
|
|
12379
|
+
waiter = void 0;
|
|
12380
|
+
resume(result);
|
|
12381
|
+
}
|
|
12382
|
+
function end(err) {
|
|
12383
|
+
error ??= err;
|
|
12384
|
+
drain();
|
|
12385
|
+
}
|
|
12386
|
+
function close(err) {
|
|
12387
|
+
error ??= err;
|
|
12388
|
+
closed = true;
|
|
12389
|
+
pending = void 0;
|
|
12390
|
+
drain();
|
|
12391
|
+
}
|
|
12392
|
+
function onEnd() {
|
|
12393
|
+
end(new SocketError({ reason: new SocketCloseError({ code: 1e3 }) }));
|
|
12394
|
+
}
|
|
12395
|
+
function onError(cause) {
|
|
12396
|
+
close(new SocketError({ reason: new SocketReadError({ cause }) }));
|
|
12397
|
+
}
|
|
12398
|
+
function onClose(hadError) {
|
|
12399
|
+
const err = new SocketError({ reason: new SocketCloseError({ code: hadError ? 1006 : 1e3 }) });
|
|
12400
|
+
if (hadError) close(err);
|
|
12401
|
+
else end(err);
|
|
12402
|
+
}
|
|
12403
|
+
function attachReadListeners(conn) {
|
|
12404
|
+
conn.on("readable", drain);
|
|
12405
|
+
conn.on("end", onEnd);
|
|
12406
|
+
conn.on("error", onError);
|
|
12407
|
+
conn.on("close", onClose);
|
|
12408
|
+
}
|
|
12409
|
+
function detachReadListeners(conn) {
|
|
12410
|
+
conn.off("readable", drain);
|
|
12411
|
+
conn.off("end", onEnd);
|
|
12412
|
+
conn.off("error", onError);
|
|
12413
|
+
conn.off("close", onClose);
|
|
12414
|
+
}
|
|
12415
|
+
if (!isDeno) conn.pause();
|
|
12416
|
+
attachReadListeners(conn);
|
|
12417
|
+
yield* addFinalizer(scope$3, sync$2(() => {
|
|
12418
|
+
close(new SocketError({ reason: new SocketCloseError({ code: 1006 }) }));
|
|
12419
|
+
detachReadListeners(conn);
|
|
12420
|
+
latch.closeUnsafe();
|
|
12421
|
+
currentSocket = void 0;
|
|
12422
|
+
upgradeAvailable = false;
|
|
12423
|
+
}));
|
|
12424
|
+
currentSocket = conn;
|
|
12425
|
+
latch.openUnsafe();
|
|
12426
|
+
const pull = callback((resume) => {
|
|
12427
|
+
waiter = resume;
|
|
12428
|
+
drain();
|
|
12429
|
+
if (waiter !== resume) return;
|
|
12430
|
+
return sync$2(() => {
|
|
12431
|
+
if (waiter === resume) waiter = void 0;
|
|
12432
|
+
});
|
|
12433
|
+
});
|
|
12434
|
+
const upgrade = (upgradeOptions = {}) => suspend(() => {
|
|
12435
|
+
if (!upgradeAvailable) return fail(new SocketError({ reason: new SocketUpgradeError({ cause: /* @__PURE__ */ new Error("socket is already upgraded or closed") }) }));
|
|
12436
|
+
const hasKey = upgradeOptions.key !== void 0;
|
|
12437
|
+
const hasCert = upgradeOptions.cert !== void 0;
|
|
12438
|
+
if (isServer && (!hasKey || !hasCert) || hasKey !== hasCert) return fail(new SocketError({ reason: new SocketUpgradeError({ cause: /* @__PURE__ */ new Error(isServer ? "server TLS upgrade requires both key and cert" : "TLS upgrade credentials must include both key and cert") }) }));
|
|
12439
|
+
return callback((resume) => {
|
|
12440
|
+
const raw = conn;
|
|
12441
|
+
detachReadListeners(raw);
|
|
12442
|
+
let tls;
|
|
12443
|
+
try {
|
|
12444
|
+
const tlsOptions = {
|
|
12445
|
+
secureContext: Tls.createSecureContext({
|
|
12446
|
+
key: upgradeOptions.key === void 0 ? void 0 : map$2(ensure(upgradeOptions.key), (value$1) => Buffer$1.from(value(value$1))),
|
|
12447
|
+
cert: upgradeOptions.cert === void 0 ? void 0 : toBuffers(upgradeOptions.cert),
|
|
12448
|
+
ca: upgradeOptions.ca === void 0 ? void 0 : toBuffers(upgradeOptions.ca),
|
|
12449
|
+
passphrase: upgradeOptions.passphrase === void 0 ? void 0 : value(upgradeOptions.passphrase)
|
|
12450
|
+
}),
|
|
12451
|
+
ALPNProtocols: upgradeOptions.alpnProtocols === void 0 ? void 0 : [...upgradeOptions.alpnProtocols],
|
|
12452
|
+
requestCert: upgradeOptions.requestCert,
|
|
12453
|
+
rejectUnauthorized: upgradeOptions.rejectUnauthorized
|
|
12454
|
+
};
|
|
12455
|
+
tls = isServer ? new Tls.TLSSocket(raw, {
|
|
12456
|
+
...tlsOptions,
|
|
12457
|
+
isServer: true
|
|
12458
|
+
}) : Tls.connect({
|
|
12459
|
+
...tlsOptions,
|
|
12460
|
+
servername: upgradeOptions.servername,
|
|
12461
|
+
socket: raw
|
|
12462
|
+
});
|
|
12463
|
+
} catch (cause) {
|
|
12464
|
+
attachReadListeners(raw);
|
|
12465
|
+
resume(fail(new SocketError({ reason: new SocketUpgradeError({ cause }) })));
|
|
12466
|
+
return;
|
|
12467
|
+
}
|
|
12468
|
+
conn = tls;
|
|
12469
|
+
currentSocket = tls;
|
|
12470
|
+
tls.pause();
|
|
12471
|
+
function cleanup() {
|
|
12472
|
+
tls.off(secureEvent, succeed);
|
|
12473
|
+
tls.off("error", failUpgrade);
|
|
12474
|
+
tls.off("close", onUpgradeClose);
|
|
12475
|
+
}
|
|
12476
|
+
function succeed() {
|
|
12477
|
+
cleanup();
|
|
12478
|
+
upgradeAvailable = false;
|
|
12479
|
+
attachReadListeners(tls);
|
|
12480
|
+
resume(void_);
|
|
12481
|
+
}
|
|
12482
|
+
function failUpgrade(cause) {
|
|
12483
|
+
cleanup();
|
|
12484
|
+
const upgradeError = new SocketError({ reason: new SocketUpgradeError({ cause }) });
|
|
12485
|
+
close(upgradeError);
|
|
12486
|
+
resume(fail(upgradeError));
|
|
12487
|
+
}
|
|
12488
|
+
function onUpgradeClose() {
|
|
12489
|
+
failUpgrade(/* @__PURE__ */ new Error("socket closed during TLS upgrade"));
|
|
12490
|
+
}
|
|
12491
|
+
tls.once(secureEvent, succeed);
|
|
12492
|
+
tls.once("error", failUpgrade);
|
|
12493
|
+
tls.once("close", onUpgradeClose);
|
|
12494
|
+
return sync$2(() => {
|
|
12495
|
+
cleanup();
|
|
12496
|
+
close(new SocketError({ reason: new SocketCloseError({ code: 1006 }) }));
|
|
12497
|
+
tls.destroy();
|
|
12498
|
+
});
|
|
12499
|
+
});
|
|
12500
|
+
});
|
|
12501
|
+
return {
|
|
12502
|
+
pull,
|
|
12503
|
+
upgrade
|
|
12504
|
+
};
|
|
12505
|
+
}).pipe(updateContext((input) => merge$1(openServices, input)));
|
|
12506
|
+
const awaitDrain = (conn) => callback((resume) => {
|
|
12507
|
+
function cleanup() {
|
|
12508
|
+
conn.off("drain", onDrain);
|
|
12509
|
+
conn.off("error", onError);
|
|
12510
|
+
conn.off("close", onClose);
|
|
12511
|
+
}
|
|
12512
|
+
function onDrain() {
|
|
12513
|
+
cleanup();
|
|
12514
|
+
resume(void_);
|
|
12515
|
+
}
|
|
12516
|
+
function onError(cause) {
|
|
12517
|
+
cleanup();
|
|
12518
|
+
resume(fail(new SocketError({ reason: new SocketWriteError({ cause }) })));
|
|
12519
|
+
}
|
|
12520
|
+
function onClose() {
|
|
12521
|
+
cleanup();
|
|
12522
|
+
resume(fail(new SocketError({ reason: new SocketWriteError({ cause: /* @__PURE__ */ new Error("socket closed") }) })));
|
|
12523
|
+
}
|
|
12524
|
+
conn.on("drain", onDrain);
|
|
12525
|
+
conn.on("error", onError);
|
|
12526
|
+
conn.on("close", onClose);
|
|
12527
|
+
return sync$2(cleanup);
|
|
12528
|
+
});
|
|
12529
|
+
const write = (chunk) => suspend(() => {
|
|
12530
|
+
const conn = currentSocket;
|
|
12531
|
+
if (conn === void 0) return latch.whenOpen(write(chunk));
|
|
12532
|
+
if (isCloseEvent(chunk)) {
|
|
12533
|
+
conn.destroy(chunk.code > 1e3 ? /* @__PURE__ */ new Error(`closed with code ${chunk.code}`) : void 0);
|
|
12534
|
+
return void_;
|
|
12535
|
+
}
|
|
12536
|
+
try {
|
|
12537
|
+
return conn.write(chunk) ? void_ : awaitDrain(conn);
|
|
12538
|
+
} catch (cause) {
|
|
12539
|
+
return fail(new SocketError({ reason: new SocketWriteError({ cause }) }));
|
|
12540
|
+
}
|
|
12541
|
+
});
|
|
12542
|
+
const writeAll = (chunks) => suspend(() => {
|
|
12543
|
+
const conn = currentSocket;
|
|
12544
|
+
if (conn === void 0) return latch.whenOpen(writeAll(chunks));
|
|
12545
|
+
let needsDrain = false;
|
|
12546
|
+
try {
|
|
12547
|
+
if (chunks.length === 1) needsDrain = !conn.write(chunks[0]);
|
|
12548
|
+
else {
|
|
12549
|
+
conn.cork();
|
|
12550
|
+
try {
|
|
12551
|
+
for (let i = 0; i < chunks.length; i++) needsDrain = !conn.write(chunks[i]) || needsDrain;
|
|
12552
|
+
} finally {
|
|
12553
|
+
conn.uncork();
|
|
12554
|
+
}
|
|
12555
|
+
}
|
|
12556
|
+
} catch (cause) {
|
|
12557
|
+
return fail(new SocketError({ reason: new SocketWriteError({ cause }) }));
|
|
12558
|
+
}
|
|
12559
|
+
return needsDrain ? awaitDrain(conn) : void_;
|
|
12560
|
+
});
|
|
12561
|
+
const writer = acquireRelease(succeed({
|
|
12562
|
+
write,
|
|
12563
|
+
writeAll
|
|
12564
|
+
}), () => sync$2(() => {
|
|
12565
|
+
if (!currentSocket || currentSocket.writableEnded) return;
|
|
12566
|
+
currentSocket.end();
|
|
12567
|
+
}));
|
|
12568
|
+
return succeed(make$34({
|
|
12569
|
+
reader,
|
|
12570
|
+
writer
|
|
12571
|
+
}));
|
|
12572
|
+
});
|
|
12573
|
+
// ../../node_modules/.pnpm/@effect+platform-node@4.1.2_bufferutil@4.1.0_effect@4.1.2_redis@6.2.1_utf-8-validate@6.0.6/node_modules/@effect/platform-node/dist/internal/upgrade.js
|
|
12574
|
+
/**
|
|
12575
|
+
* Wraps an upgraded connection. Acquiring the reader runs `open`; releasing
|
|
12576
|
+
* its scope closes the connection.
|
|
12577
|
+
*
|
|
12578
|
+
* No `data` listener is attached before acquisition, so early bytes stay buffered.
|
|
12579
|
+
*
|
|
12580
|
+
* @internal
|
|
12581
|
+
*/
|
|
12582
|
+
const toSocket = (conn, open = void_) => fromDuplex(acquireRelease(suspend(() => conn.destroyed ? fail(openError("The upgraded connection closed before it was read")) : as(open, conn)), (conn) => sync$2(() => {
|
|
12583
|
+
if (conn.destroyed) return;
|
|
12584
|
+
if ("destroySoon" in conn) conn.destroySoon();
|
|
12585
|
+
else conn.destroy();
|
|
12586
|
+
})));
|
|
12587
|
+
const openError = (cause) => new SocketError({ reason: new SocketOpenError({
|
|
12588
|
+
kind: "Unknown",
|
|
12589
|
+
cause: typeof cause === "string" ? new Error(cause) : cause
|
|
12590
|
+
}) });
|
|
12591
|
+
/**
|
|
12592
|
+
* Node 25 and older stop parsing at the head of an upgrade request, leaving
|
|
12593
|
+
* the body in `head` and on the connection. Reads a `Content-Length` body
|
|
12594
|
+
* from them on demand and returns the bytes after it.
|
|
12595
|
+
*
|
|
12596
|
+
* @internal
|
|
12597
|
+
*/
|
|
12598
|
+
const frameBody = (conn, head, length) => {
|
|
12599
|
+
if (head.length >= length) return {
|
|
12600
|
+
body: Readable.from(length === 0 ? [] : [head.subarray(0, length)], { objectMode: false }),
|
|
12601
|
+
rest: head.subarray(length)
|
|
12602
|
+
};
|
|
12603
|
+
let remaining = length - head.length;
|
|
12604
|
+
let reading = false;
|
|
12605
|
+
const stop = () => {
|
|
12606
|
+
conn.off("readable", onReadable);
|
|
12607
|
+
conn.off("end", onEnd);
|
|
12608
|
+
};
|
|
12609
|
+
const onReadable = () => {
|
|
12610
|
+
while (remaining > 0) {
|
|
12611
|
+
let chunk = conn.read();
|
|
12612
|
+
if (chunk === null) return;
|
|
12613
|
+
if (chunk.length > remaining) {
|
|
12614
|
+
conn.unshift(chunk.subarray(remaining));
|
|
12615
|
+
chunk = chunk.subarray(0, remaining);
|
|
12616
|
+
}
|
|
12617
|
+
remaining -= chunk.length;
|
|
12618
|
+
if (!body.push(chunk) && remaining > 0) return;
|
|
12619
|
+
}
|
|
12620
|
+
stop();
|
|
12621
|
+
body.push(null);
|
|
12622
|
+
};
|
|
12623
|
+
const onEnd = () => {
|
|
12624
|
+
stop();
|
|
12625
|
+
body.destroy(/* @__PURE__ */ new Error("The connection closed before the request body ended"));
|
|
12626
|
+
};
|
|
12627
|
+
const body = new Readable({
|
|
12628
|
+
read() {
|
|
12629
|
+
if (reading) return onReadable();
|
|
12630
|
+
reading = true;
|
|
12631
|
+
if (head.length > 0) this.push(head);
|
|
12632
|
+
if (conn.readableEnded) return onEnd();
|
|
12633
|
+
conn.on("readable", onReadable);
|
|
12634
|
+
conn.on("end", onEnd);
|
|
12635
|
+
},
|
|
12636
|
+
destroy(error, callback) {
|
|
12637
|
+
stop();
|
|
12638
|
+
callback(error);
|
|
12639
|
+
}
|
|
12640
|
+
});
|
|
12641
|
+
body.on("error", () => {});
|
|
12642
|
+
return {
|
|
12643
|
+
body,
|
|
12644
|
+
rest: Buffer.alloc(0)
|
|
12645
|
+
};
|
|
12646
|
+
};
|
|
12647
|
+
/**
|
|
12648
|
+
* Waits for the request body to end before the `101` is written, discarding
|
|
12649
|
+
* any of it the handler did not read, up to `maxBytes`.
|
|
12650
|
+
*
|
|
12651
|
+
* @internal
|
|
12652
|
+
*/
|
|
12653
|
+
const drainBody = (body, maxBytes) => callback((resume) => {
|
|
12654
|
+
if (body.readableEnded) return resume(void_);
|
|
12655
|
+
let bytes = 0;
|
|
12656
|
+
const cleanup = finished(body, {
|
|
12657
|
+
readable: true,
|
|
12658
|
+
writable: false
|
|
12659
|
+
}, (error) => {
|
|
12660
|
+
done();
|
|
12661
|
+
resume(error ? fail(openError(error)) : void_);
|
|
12662
|
+
});
|
|
12663
|
+
function onData(chunk) {
|
|
12664
|
+
bytes += chunk.length;
|
|
12665
|
+
if (maxBytes !== void 0 && bytes > maxBytes) {
|
|
12666
|
+
done();
|
|
12667
|
+
resume(fail(openError("The request body exceeds the maximum body size")));
|
|
12668
|
+
}
|
|
12669
|
+
}
|
|
12670
|
+
function done() {
|
|
12671
|
+
body.off("data", onData);
|
|
12672
|
+
cleanup();
|
|
12673
|
+
}
|
|
12674
|
+
body.on("data", onData);
|
|
12675
|
+
body.resume();
|
|
12676
|
+
return sync$2(done);
|
|
12677
|
+
});
|
|
12678
|
+
// ../../node_modules/.pnpm/@effect+platform-node@4.1.2_bufferutil@4.1.0_effect@4.1.2_redis@6.2.1_utf-8-validate@6.0.6/node_modules/@effect/platform-node/dist/NodeHttpIncomingMessage.js
|
|
11643
12679
|
/**
|
|
11644
12680
|
* Adapter base for exposing Node `http.IncomingMessage` values as Effect HTTP
|
|
11645
12681
|
* incoming messages.
|
|
@@ -11655,6 +12691,7 @@ const clearPersistedCloudLink = gen(function* () {
|
|
|
11655
12691
|
* @since 4.0.0
|
|
11656
12692
|
*/
|
|
11657
12693
|
const textDecoder = /*#__PURE__*/ new TextDecoder();
|
|
12694
|
+
const formDecoder = /*#__PURE__*/ new TextDecoder("utf-8", { ignoreBOM: true });
|
|
11658
12695
|
/**
|
|
11659
12696
|
* Adapts a Node `IncomingMessage` to Effect HTTP incoming messages.
|
|
11660
12697
|
*
|
|
@@ -11672,7 +12709,7 @@ const textDecoder = /*#__PURE__*/ new TextDecoder();
|
|
|
11672
12709
|
* @category constructors
|
|
11673
12710
|
* @since 4.0.0
|
|
11674
12711
|
*/
|
|
11675
|
-
var NodeHttpIncomingMessage = class extends Class {
|
|
12712
|
+
var NodeHttpIncomingMessage = class extends Class$1 {
|
|
11676
12713
|
/**
|
|
11677
12714
|
* Marks this value as an HTTP incoming message for runtime guards.
|
|
11678
12715
|
*
|
|
@@ -11682,6 +12719,8 @@ var NodeHttpIncomingMessage = class extends Class {
|
|
|
11682
12719
|
source;
|
|
11683
12720
|
onError;
|
|
11684
12721
|
remoteAddressOverride;
|
|
12722
|
+
destroyOnOverflow = true;
|
|
12723
|
+
closeOnDone = true;
|
|
11685
12724
|
constructor(source, onError, remoteAddressOverride) {
|
|
11686
12725
|
super();
|
|
11687
12726
|
this[TypeId] = TypeId;
|
|
@@ -11690,7 +12729,7 @@ var NodeHttpIncomingMessage = class extends Class {
|
|
|
11690
12729
|
this.remoteAddressOverride = remoteAddressOverride;
|
|
11691
12730
|
}
|
|
11692
12731
|
get headers() {
|
|
11693
|
-
return fromInput
|
|
12732
|
+
return fromInput(this.source.headers);
|
|
11694
12733
|
}
|
|
11695
12734
|
get remoteAddress() {
|
|
11696
12735
|
return this.remoteAddressOverride ?? fromNullishOr(this.source.socket?.remoteAddress);
|
|
@@ -11714,29 +12753,38 @@ var NodeHttpIncomingMessage = class extends Class {
|
|
|
11714
12753
|
return runSync(this.json);
|
|
11715
12754
|
}
|
|
11716
12755
|
get urlParamsBody() {
|
|
11717
|
-
return flatMap(this.
|
|
11718
|
-
try: () => fromInput(new URLSearchParams(
|
|
12756
|
+
return flatMap(this.arrayBuffer, (bytes) => try_({
|
|
12757
|
+
try: () => fromInput$1(new URLSearchParams(formDecoder.decode(bytes).replace(/^\?/, "%3F"))),
|
|
11719
12758
|
catch: this.onError
|
|
11720
12759
|
}));
|
|
11721
12760
|
}
|
|
12761
|
+
/**
|
|
12762
|
+
* The readable the body is read from, `source` unless a subclass reads the
|
|
12763
|
+
* body from elsewhere.
|
|
12764
|
+
*/
|
|
12765
|
+
get bodySource() {
|
|
12766
|
+
return this.source;
|
|
12767
|
+
}
|
|
11722
12768
|
get stream() {
|
|
11723
12769
|
return fromReadable({
|
|
11724
|
-
evaluate: () => this.
|
|
11725
|
-
onError: this.onError
|
|
12770
|
+
evaluate: () => this.bodySource,
|
|
12771
|
+
onError: this.onError,
|
|
12772
|
+
closeOnDone: this.closeOnDone
|
|
11726
12773
|
});
|
|
11727
12774
|
}
|
|
11728
12775
|
arrayBufferEffect;
|
|
11729
12776
|
get arrayBuffer() {
|
|
11730
12777
|
if (this.arrayBufferEffect) return this.arrayBufferEffect;
|
|
11731
|
-
this.arrayBufferEffect = withFiber((fiber) => toArrayBuffer(() => this.
|
|
12778
|
+
this.arrayBufferEffect = withFiber((fiber) => toArrayBuffer(() => this.bodySource, {
|
|
11732
12779
|
onError: this.onError,
|
|
12780
|
+
destroyOnOverflow: this.destroyOnOverflow,
|
|
11733
12781
|
maxBytes: fiber.getRef(MaxBodySize)
|
|
11734
12782
|
})).pipe(cached, runSync);
|
|
11735
12783
|
this.textEffect = map$1(this.arrayBufferEffect, (_) => textDecoder.decode(_));
|
|
11736
12784
|
return this.arrayBufferEffect;
|
|
11737
12785
|
}
|
|
11738
12786
|
};
|
|
11739
|
-
// ../../node_modules/.pnpm/@effect+platform-node-shared@4.
|
|
12787
|
+
// ../../node_modules/.pnpm/@effect+platform-node-shared@4.1.2_bufferutil@4.1.0_effect@4.1.2_utf-8-validate@6.0.6/node_modules/@effect/platform-node-shared/dist/NodeHttpCompression.js
|
|
11740
12788
|
/**
|
|
11741
12789
|
* HTTP response compression backed by `node:zlib`, shared by the Node.js, Bun,
|
|
11742
12790
|
* and Deno platforms.
|
|
@@ -11838,7 +12886,7 @@ const compressTransform = (algorithm, options) => {
|
|
|
11838
12886
|
});
|
|
11839
12887
|
}
|
|
11840
12888
|
};
|
|
11841
|
-
// ../../node_modules/.pnpm/@effect+platform-node@4.
|
|
12889
|
+
// ../../node_modules/.pnpm/@effect+platform-node@4.1.2_bufferutil@4.1.0_effect@4.1.2_redis@6.2.1_utf-8-validate@6.0.6/node_modules/@effect/platform-node/dist/NodeHttpPlatform.js
|
|
11842
12890
|
/**
|
|
11843
12891
|
* Node.js implementation of the Effect HTTP platform service.
|
|
11844
12892
|
*
|
|
@@ -11888,7 +12936,7 @@ const compressedBody = (response, body) => removeHeader(setBody$1(response, body
|
|
|
11888
12936
|
* @category constructors
|
|
11889
12937
|
* @since 4.0.0
|
|
11890
12938
|
*/
|
|
11891
|
-
const make$11 = /*#__PURE__*/ make$
|
|
12939
|
+
const make$11 = /*#__PURE__*/ make$35({
|
|
11892
12940
|
platform: "node",
|
|
11893
12941
|
compression: /* @__PURE__ */ make$12({
|
|
11894
12942
|
algorithms,
|
|
@@ -11928,7 +12976,7 @@ const make$11 = /*#__PURE__*/ make$37({
|
|
|
11928
12976
|
},
|
|
11929
12977
|
fileWebResponse(file, status, statusText, headers, _options) {
|
|
11930
12978
|
return raw$1(lazyReadable(() => Readable.fromWeb(file.stream())), {
|
|
11931
|
-
headers: merge(headers, fromRecordUnsafe({
|
|
12979
|
+
headers: merge$2(headers, fromRecordUnsafe({
|
|
11932
12980
|
"content-type": headers["content-type"] ?? (file.type === "" ? getOrElse(getType(file.name), () => "application/octet-stream") : file.type),
|
|
11933
12981
|
"content-length": file.size.toString()
|
|
11934
12982
|
})),
|
|
@@ -11945,8 +12993,14 @@ const make$11 = /*#__PURE__*/ make$37({
|
|
|
11945
12993
|
* @category layers
|
|
11946
12994
|
* @since 4.0.0
|
|
11947
12995
|
*/
|
|
11948
|
-
const layer$10 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$11), /*#__PURE__*/ provide(layer$
|
|
11949
|
-
// ../../node_modules/.pnpm/@effect+platform-node@4.
|
|
12996
|
+
const layer$10 = /*#__PURE__*/ pipe(/*#__PURE__*/ effect(HttpPlatform)(make$11), /*#__PURE__*/ provide$1(layer$29), /*#__PURE__*/ provide$1(layer$23));
|
|
12997
|
+
// ../../node_modules/.pnpm/@effect+platform-node@4.1.2_bufferutil@4.1.0_effect@4.1.2_redis@6.2.1_utf-8-validate@6.0.6/node_modules/@effect/platform-node/dist/NodeMultipartParser.js
|
|
12998
|
+
/**
|
|
12999
|
+
* Node.js streams adapter for the low-level multipart parser.
|
|
13000
|
+
*
|
|
13001
|
+
* @stability unstable
|
|
13002
|
+
* @since 4.0.0
|
|
13003
|
+
*/
|
|
11950
13004
|
/**
|
|
11951
13005
|
* A Node.js duplex stream that parses multipart input.
|
|
11952
13006
|
*
|
|
@@ -11958,11 +13012,12 @@ var MultipartStream = class extends Duplex {
|
|
|
11958
13012
|
_parser;
|
|
11959
13013
|
_canWrite = true;
|
|
11960
13014
|
_writeCallback;
|
|
13015
|
+
_currentFile;
|
|
11961
13016
|
constructor(config) {
|
|
11962
13017
|
super({ readableObjectMode: true });
|
|
11963
13018
|
let currentError;
|
|
11964
|
-
let
|
|
11965
|
-
this._parser = make$
|
|
13019
|
+
let initialized = false;
|
|
13020
|
+
this._parser = make$36({
|
|
11966
13021
|
...config,
|
|
11967
13022
|
onField: (info, value) => {
|
|
11968
13023
|
if (currentError !== void 0) return;
|
|
@@ -11977,27 +13032,30 @@ var MultipartStream = class extends Duplex {
|
|
|
11977
13032
|
onFile: (info) => {
|
|
11978
13033
|
if (currentError !== void 0) return (_) => {};
|
|
11979
13034
|
const file = new FileStream(info, this);
|
|
11980
|
-
|
|
13035
|
+
this._currentFile = file;
|
|
11981
13036
|
this.push(file);
|
|
11982
13037
|
this.emit("file", file);
|
|
11983
13038
|
return (chunk) => {
|
|
11984
13039
|
if (currentError !== void 0) return;
|
|
11985
13040
|
this._canWrite = file.push(chunk);
|
|
11986
13041
|
if (chunk === null && !this._canWrite) {
|
|
11987
|
-
|
|
13042
|
+
this._currentFile = void 0;
|
|
11988
13043
|
this._resume();
|
|
11989
13044
|
}
|
|
11990
13045
|
};
|
|
11991
13046
|
},
|
|
11992
13047
|
onError: (error) => {
|
|
11993
|
-
this.emit("error", error);
|
|
11994
|
-
currentFile?.emit("error", error);
|
|
11995
13048
|
currentError = error;
|
|
13049
|
+
if (!initialized) return;
|
|
13050
|
+
this.emit("error", error);
|
|
13051
|
+
this._failCurrentFile(error);
|
|
11996
13052
|
},
|
|
11997
13053
|
onDone: () => {
|
|
11998
13054
|
this.push(null);
|
|
11999
13055
|
}
|
|
12000
13056
|
});
|
|
13057
|
+
initialized = true;
|
|
13058
|
+
if (currentError !== void 0) this.destroy(currentError);
|
|
12001
13059
|
}
|
|
12002
13060
|
_resume() {
|
|
12003
13061
|
this._canWrite = true;
|
|
@@ -12008,6 +13066,17 @@ var MultipartStream = class extends Duplex {
|
|
|
12008
13066
|
}
|
|
12009
13067
|
}
|
|
12010
13068
|
_read(_size) {}
|
|
13069
|
+
_destroy(error, callback) {
|
|
13070
|
+
if (error) this._failCurrentFile(error);
|
|
13071
|
+
callback(error);
|
|
13072
|
+
}
|
|
13073
|
+
_failCurrentFile(error) {
|
|
13074
|
+
const file = this._currentFile;
|
|
13075
|
+
if (file === void 0) return;
|
|
13076
|
+
this._currentFile = void 0;
|
|
13077
|
+
file.on("error", constVoid);
|
|
13078
|
+
file.destroy(error);
|
|
13079
|
+
}
|
|
12011
13080
|
_write(chunk, encoding, callback) {
|
|
12012
13081
|
this._parser.write(chunk instanceof Uint8Array ? chunk : Buffer.from(chunk, encoding));
|
|
12013
13082
|
if (this._canWrite) callback();
|
|
@@ -12048,7 +13117,7 @@ var FileStream = class extends Readable {
|
|
|
12048
13117
|
if (this._parent._canWrite === false) this._parent._resume();
|
|
12049
13118
|
}
|
|
12050
13119
|
};
|
|
12051
|
-
// ../../node_modules/.pnpm/@effect+platform-node@4.
|
|
13120
|
+
// ../../node_modules/.pnpm/@effect+platform-node@4.1.2_bufferutil@4.1.0_effect@4.1.2_redis@6.2.1_utf-8-validate@6.0.6/node_modules/@effect/platform-node/dist/NodeMultipart.js
|
|
12052
13121
|
/**
|
|
12053
13122
|
* Node.js multipart parsing for HTTP `multipart/form-data` request bodies.
|
|
12054
13123
|
*
|
|
@@ -12074,11 +13143,18 @@ var FileStream = class extends Readable {
|
|
|
12074
13143
|
const stream = (source, headers) => makeConfig(headers).pipe(map$1((config) => fromReadable({
|
|
12075
13144
|
evaluate() {
|
|
12076
13145
|
const parser = make$10(config);
|
|
13146
|
+
const cleanup = finished(source, {
|
|
13147
|
+
readable: true,
|
|
13148
|
+
writable: false
|
|
13149
|
+
}, (error) => {
|
|
13150
|
+
cleanup();
|
|
13151
|
+
if (error) parser.destroy(error);
|
|
13152
|
+
});
|
|
12077
13153
|
source.pipe(parser);
|
|
12078
13154
|
return parser;
|
|
12079
13155
|
},
|
|
12080
13156
|
onError: (error) => convertError(error)
|
|
12081
|
-
})), unwrap$1, map$
|
|
13157
|
+
})), unwrap$1, map$4(convertPart));
|
|
12082
13158
|
/**
|
|
12083
13159
|
* Parses multipart data from a Node readable request body and persists file
|
|
12084
13160
|
* parts using the current `FileSystem`, `Path`, and `Scope` services.
|
|
@@ -12092,7 +13168,7 @@ const persisted = (source, headers) => toPersisted(stream(source, headers), (pat
|
|
|
12092
13168
|
catch: (cause) => MultipartError.fromReason("InternalError", cause)
|
|
12093
13169
|
}));
|
|
12094
13170
|
const convertPart = (part) => part._tag === "Field" ? new FieldImpl(part.info, part.value) : new FileImpl(part);
|
|
12095
|
-
var PartBase = class extends Class {
|
|
13171
|
+
var PartBase = class extends Class$1 {
|
|
12096
13172
|
[TypeId$1];
|
|
12097
13173
|
constructor() {
|
|
12098
13174
|
super();
|
|
@@ -15739,48 +16815,109 @@ require_permessage_deflate();
|
|
|
15739
16815
|
require_receiver();
|
|
15740
16816
|
require_sender();
|
|
15741
16817
|
require_subprotocol();
|
|
15742
|
-
|
|
16818
|
+
require_websocket();
|
|
15743
16819
|
var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server(), 1);
|
|
15744
|
-
// ../../node_modules/.pnpm/@effect+platform-node@4.
|
|
16820
|
+
// ../../node_modules/.pnpm/@effect+platform-node@4.1.2_bufferutil@4.1.0_effect@4.1.2_redis@6.2.1_utf-8-validate@6.0.6/node_modules/@effect/platform-node/dist/NodeHttpServer.js
|
|
15745
16821
|
/**
|
|
15746
16822
|
* Node.js implementation of the Effect `HttpServer`.
|
|
15747
16823
|
*
|
|
15748
|
-
* This module adapts a supplied Node `http.Server` into
|
|
15749
|
-
* platform-independent HTTP server service. It starts the server with
|
|
15750
|
-
* `listen` options, converts `request` events into `HttpServerRequest`
|
|
15751
|
-
* writes `HttpServerResponse` bodies through Node's `ServerResponse`,
|
|
15752
|
-
* handles `upgrade` events by exposing the upgraded socket through
|
|
16824
|
+
* This module adapts a supplied Node `http.Server` or `node:http2` server into
|
|
16825
|
+
* Effect's platform-independent HTTP server service. It starts the server with
|
|
16826
|
+
* Node `listen` options, converts `request` events into `HttpServerRequest`
|
|
16827
|
+
* values, writes `HttpServerResponse` bodies through Node's `ServerResponse`,
|
|
16828
|
+
* and handles `upgrade` events by exposing the upgraded socket through
|
|
15753
16829
|
* `HttpServerRequest.upgrade`. It also exports request and upgrade handler
|
|
15754
16830
|
* constructors plus layers for the server alone, HTTP support services, the
|
|
15755
16831
|
* combined server, configurable options, and tests.
|
|
15756
16832
|
*
|
|
16833
|
+
* **HTTP/2**
|
|
16834
|
+
*
|
|
16835
|
+
* Pass `Http2.createServer()` for cleartext HTTP/2 (h2c), or
|
|
16836
|
+
* `Http2.createSecureServer({ key, cert, allowHTTP1: true })` to negotiate
|
|
16837
|
+
* HTTP/2 over TLS and fall back to HTTP/1.1 for clients that do not support
|
|
16838
|
+
* it. The protocol is detected per request, so the application sees the same
|
|
16839
|
+
* `HttpServerRequest` either way:
|
|
16840
|
+
*
|
|
16841
|
+
* - pseudo-headers are removed from `headers`, and `host` is taken from
|
|
16842
|
+
* `:authority`
|
|
16843
|
+
* - `originalUrl` and `HttpServerRequest.toURL` use the `:scheme` the client
|
|
16844
|
+
* sent, which a client can set as freely as `x-forwarded-proto`
|
|
16845
|
+
* - connection-specific response headers that HTTP/2 forbids, such as
|
|
16846
|
+
* `connection`, `keep-alive` and `transfer-encoding`, are dropped silently
|
|
16847
|
+
* - a response that fails after its headers were sent resets the stream with
|
|
16848
|
+
* `INTERNAL_ERROR`, so clients do not mistake a truncated body for a
|
|
16849
|
+
* complete one
|
|
16850
|
+
*
|
|
16851
|
+
* WebSockets and other upgrades only work over HTTP/1.1, which needs
|
|
16852
|
+
* `allowHTTP1` on a TLS server. Trailers are only available through the Node
|
|
16853
|
+
* objects from `NodeHttpServerRequest`. Tune HTTP/2 limits, such as
|
|
16854
|
+
* `maxSessionMemory` and `settings.maxConcurrentStreams`, through the Node
|
|
16855
|
+
* server options.
|
|
16856
|
+
*
|
|
15757
16857
|
* @stability unstable
|
|
15758
16858
|
* @since 4.0.0
|
|
15759
16859
|
*/
|
|
15760
16860
|
/**
|
|
15761
|
-
* Creates a scoped `HttpServer` from a Node `http.Server
|
|
15762
|
-
* with the supplied options, registers request and
|
|
15763
|
-
* the server during scope finalization with
|
|
16861
|
+
* Creates a scoped `HttpServer` from a Node `http.Server` or `node:http2`
|
|
16862
|
+
* server, starts listening with the supplied options, registers request and
|
|
16863
|
+
* upgrade handling, and closes the server during scope finalization with
|
|
16864
|
+
* optional graceful-shutdown control.
|
|
16865
|
+
*
|
|
16866
|
+
* **Details**
|
|
16867
|
+
*
|
|
16868
|
+
* Node's own timeouts are set on the server you create, for example
|
|
16869
|
+
* `createServer({ requestTimeout: 0, headersTimeout: 60_000 })`:
|
|
16870
|
+
*
|
|
16871
|
+
* - `requestTimeout` (default 300 seconds) bounds receiving the whole request,
|
|
16872
|
+
* headers and body. On expiry Node answers `408`, or closes the connection
|
|
16873
|
+
* if the response has started. It is checked every
|
|
16874
|
+
* `connectionsCheckingInterval` (default 30 seconds). `0` disables it.
|
|
16875
|
+
* - `headersTimeout` (default 60 seconds) bounds receiving the headers. Left
|
|
16876
|
+
* unset, it is lowered to a smaller `requestTimeout`, so `requestTimeout: 0`
|
|
16877
|
+
* alone disables both. When both are nonzero it may not exceed
|
|
16878
|
+
* `requestTimeout`.
|
|
16879
|
+
* - `keepAliveTimeout` (default 5 seconds) closes connections idle between
|
|
16880
|
+
* requests.
|
|
16881
|
+
* - `server.timeout`, socket inactivity, is off by default, so a quiet
|
|
16882
|
+
* response stream is never cut once the request is received.
|
|
16883
|
+
*
|
|
16884
|
+
* Use `Stream` and `Effect` timeouts in handlers or middleware for per-route
|
|
16885
|
+
* limits on reading the body or producing the response.
|
|
16886
|
+
*
|
|
16887
|
+
* **Gotchas**
|
|
16888
|
+
*
|
|
16889
|
+
* A request counts as received once Node has parsed the whole body, so a
|
|
16890
|
+
* handler that streams a response without reading a large body is still under
|
|
16891
|
+
* `requestTimeout` and is cut when it expires.
|
|
15764
16892
|
*
|
|
15765
16893
|
* @stability unstable
|
|
15766
16894
|
* @category constructors
|
|
15767
16895
|
* @since 4.0.0
|
|
15768
16896
|
*/
|
|
15769
16897
|
const make$9 = /*#__PURE__*/ fnUntraced$1(function* (evaluate, options) {
|
|
15770
|
-
const scope$
|
|
16898
|
+
const scope$2 = yield* scope;
|
|
15771
16899
|
const server = evaluate();
|
|
16900
|
+
let closing = false;
|
|
16901
|
+
const sessions = /* @__PURE__ */ new Set();
|
|
16902
|
+
server.on("session", (session) => {
|
|
16903
|
+
if (closing) return session.close();
|
|
16904
|
+
sessions.add(session);
|
|
16905
|
+
session.once("close", () => sessions.delete(session));
|
|
16906
|
+
});
|
|
15772
16907
|
const shutdown = yield* callback((resume) => {
|
|
15773
16908
|
if (!server.listening) return resume(void_);
|
|
15774
16909
|
server.close((error) => {
|
|
15775
16910
|
if (error) resume(die(error));
|
|
15776
16911
|
else resume(void_);
|
|
15777
16912
|
});
|
|
16913
|
+
closing = true;
|
|
16914
|
+
for (const session of sessions) session.close();
|
|
15778
16915
|
}).pipe(cached);
|
|
15779
16916
|
const preemptiveShutdown = options.disablePreemptiveShutdown ? void_ : timeoutOrElse(shutdown, {
|
|
15780
16917
|
duration: options.gracefulShutdownTimeout ?? seconds(20),
|
|
15781
16918
|
orElse: () => void_
|
|
15782
16919
|
});
|
|
15783
|
-
yield* addFinalizer(scope$
|
|
16920
|
+
yield* addFinalizer(scope$2, shutdown);
|
|
15784
16921
|
yield* callback((resume) => {
|
|
15785
16922
|
function onError(cause) {
|
|
15786
16923
|
resume(fail(new ServeError({ cause })));
|
|
@@ -15798,25 +16935,31 @@ const make$9 = /*#__PURE__*/ fnUntraced$1(function* (evaluate, options) {
|
|
|
15798
16935
|
noServer: true
|
|
15799
16936
|
})), (wss) => callback((resume) => {
|
|
15800
16937
|
wss.close(() => resume(void_));
|
|
15801
|
-
})).pipe(provide$
|
|
15802
|
-
return make$
|
|
16938
|
+
})).pipe(provide$2(scope$2), cached);
|
|
16939
|
+
return make$37({
|
|
15803
16940
|
address: boundAddress,
|
|
15804
16941
|
serve: fnUntraced$1(function* (httpApp, middleware) {
|
|
15805
16942
|
const serveScope = yield* scope;
|
|
15806
|
-
const scope$
|
|
16943
|
+
const scope$1 = forkUnsafe(serveScope, "parallel");
|
|
15807
16944
|
const handler = yield* makeHandler(httpApp, {
|
|
15808
16945
|
middleware,
|
|
15809
|
-
scope: scope$
|
|
16946
|
+
scope: scope$1
|
|
15810
16947
|
});
|
|
15811
16948
|
const upgradeHandler = yield* makeUpgradeHandler(wss, httpApp, {
|
|
15812
16949
|
middleware,
|
|
15813
|
-
scope: scope$
|
|
16950
|
+
scope: scope$1
|
|
15814
16951
|
});
|
|
16952
|
+
const checkContinueHandler = (request, response) => {
|
|
16953
|
+
pendingContinue.add(request);
|
|
16954
|
+
handler(request, response);
|
|
16955
|
+
};
|
|
15815
16956
|
yield* addFinalizerExit(serveScope, () => ensuring(preemptiveShutdown, sync$2(() => {
|
|
15816
16957
|
server.off("request", handler);
|
|
16958
|
+
server.off("checkContinue", checkContinueHandler);
|
|
15817
16959
|
server.off("upgrade", upgradeHandler);
|
|
15818
16960
|
})));
|
|
15819
16961
|
server.on("request", handler);
|
|
16962
|
+
server.on("checkContinue", checkContinueHandler);
|
|
15820
16963
|
server.on("upgrade", upgradeHandler);
|
|
15821
16964
|
})
|
|
15822
16965
|
});
|
|
@@ -15824,7 +16967,8 @@ const make$9 = /*#__PURE__*/ fnUntraced$1(function* (evaluate, options) {
|
|
|
15824
16967
|
/**
|
|
15825
16968
|
* Creates a Node `request` event handler for an Effect HTTP application,
|
|
15826
16969
|
* injecting a `HttpServerRequest` and interrupting the request fiber if the
|
|
15827
|
-
* client closes the response before it finishes.
|
|
16970
|
+
* client closes the response before it finishes. It accepts both HTTP/1.1 and
|
|
16971
|
+
* HTTP/2 compatibility requests.
|
|
15828
16972
|
*
|
|
15829
16973
|
* @stability unstable
|
|
15830
16974
|
* @category handlers
|
|
@@ -15834,7 +16978,10 @@ const makeHandler = (httpEffect, options) => {
|
|
|
15834
16978
|
const handled = toHandled(httpEffect, handleResponse, options.middleware);
|
|
15835
16979
|
return withFiber((parent) => {
|
|
15836
16980
|
const services = parent.context;
|
|
15837
|
-
return succeed(function handler(
|
|
16981
|
+
return succeed(function handler(request, response) {
|
|
16982
|
+
const nodeRequest = request;
|
|
16983
|
+
const nodeResponse = response;
|
|
16984
|
+
if (nodeRequest.httpVersionMajor === 1) nodeResponse.prependListener("finish", () => teardownBody(nodeRequest, nodeResponse));
|
|
15838
16985
|
const context = add(services, HttpServerRequest, new ServerRequestImpl(nodeRequest, nodeResponse));
|
|
15839
16986
|
const fiber = runIn(runForkWith(context)(handled), options.scope);
|
|
15840
16987
|
if (fiber.pollUnsafe() === void 0) nodeResponse.on("close", () => {
|
|
@@ -15845,9 +16992,25 @@ const makeHandler = (httpEffect, options) => {
|
|
|
15845
16992
|
};
|
|
15846
16993
|
/**
|
|
15847
16994
|
* Creates a Node `upgrade` event handler for an Effect HTTP application,
|
|
15848
|
-
* exposing the upgraded
|
|
16995
|
+
* exposing the upgraded connection as the request's `upgrade` effect and
|
|
15849
16996
|
* interrupting the request fiber when the socket closes early.
|
|
15850
16997
|
*
|
|
16998
|
+
* **Details**
|
|
16999
|
+
*
|
|
17000
|
+
* `Upgrade: websocket` requests complete the WebSocket handshake. Any other
|
|
17001
|
+
* protocol answers `101 Switching Protocols` with the requested protocol and
|
|
17002
|
+
* the headers given to `upgradeWith`, and exposes the raw connection, with
|
|
17003
|
+
* bytes the client sent after the request body first on the reader. Either
|
|
17004
|
+
* response is sent when the socket's reader is acquired. A handler that never
|
|
17005
|
+
* asks for `upgrade` answers with its response as usual.
|
|
17006
|
+
*
|
|
17007
|
+
* The request body can be read before the upgrade. The `101` waits for the
|
|
17008
|
+
* body to end, discarding any unread rest up to the maximum body size. Node 25
|
|
17009
|
+
* and older do not parse the body of an upgrade request, so it is read from
|
|
17010
|
+
* the connection with `Content-Length`; chunked bodies get
|
|
17011
|
+
* `411 Length Required` there. `Expect: 100-continue` is not answered on
|
|
17012
|
+
* upgrade requests.
|
|
17013
|
+
*
|
|
15851
17014
|
* @stability unstable
|
|
15852
17015
|
* @category handlers
|
|
15853
17016
|
* @since 4.0.0
|
|
@@ -15857,11 +17020,24 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
|
|
|
15857
17020
|
return withFiber((parent) => {
|
|
15858
17021
|
const services = parent.context;
|
|
15859
17022
|
return succeed(function handler(nodeRequest, socket, head) {
|
|
17023
|
+
const protocol = nodeRequest.headers.upgrade;
|
|
17024
|
+
const isWebSocket = protocol === void 0 || protocol.toLowerCase() === "websocket";
|
|
17025
|
+
let body;
|
|
17026
|
+
if (!isWebSocket && legacyUpgradeBody) {
|
|
17027
|
+
if (nodeRequest.headers["transfer-encoding"] !== void 0) {
|
|
17028
|
+
socket.on("error", () => {});
|
|
17029
|
+
socket.end("HTTP/1.1 411 Length Required\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
|
|
17030
|
+
return;
|
|
17031
|
+
}
|
|
17032
|
+
const framed = frameBody(socket, head, Number(nodeRequest.headers["content-length"] ?? 0));
|
|
17033
|
+
body = framed.body;
|
|
17034
|
+
head = framed.rest;
|
|
17035
|
+
}
|
|
15860
17036
|
let nodeResponse_ = void 0;
|
|
15861
17037
|
const nodeResponse = () => {
|
|
15862
17038
|
if (nodeResponse_ === void 0) {
|
|
15863
|
-
nodeResponse_ = new
|
|
15864
|
-
if (
|
|
17039
|
+
nodeResponse_ = new http.ServerResponse(nodeRequest);
|
|
17040
|
+
if (state.response !== void 0 || socket.destroyed) nodeResponse_.end();
|
|
15865
17041
|
else {
|
|
15866
17042
|
nodeResponse_.assignSocket(socket);
|
|
15867
17043
|
nodeResponse_.on("finish", () => {
|
|
@@ -15871,7 +17047,7 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
|
|
|
15871
17047
|
}
|
|
15872
17048
|
return nodeResponse_;
|
|
15873
17049
|
};
|
|
15874
|
-
const
|
|
17050
|
+
const webSocketUpgrade = fromWebSocket(flatMap(lazyWss, (wss) => acquireRelease(callback((resume) => {
|
|
15875
17051
|
const onClose = () => resume(fail(new SocketError({ reason: new SocketOpenError({
|
|
15876
17052
|
kind: "Unknown",
|
|
15877
17053
|
cause: /* @__PURE__ */ new Error("The socket closed before the upgrade")
|
|
@@ -15880,10 +17056,38 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
|
|
|
15880
17056
|
socket.once("close", onClose);
|
|
15881
17057
|
wss.handleUpgrade(nodeRequest, socket, head, (ws) => {
|
|
15882
17058
|
socket.off("close", onClose);
|
|
15883
|
-
|
|
17059
|
+
state.response = upgradedResponse;
|
|
15884
17060
|
resume(succeed(ws));
|
|
15885
17061
|
});
|
|
15886
|
-
}), (ws, exit) => sync$2(() => ws.close(closeCode(exit))))))
|
|
17062
|
+
}), (ws, exit) => sync$2(() => ws.close(closeCode(exit))))));
|
|
17063
|
+
const state = {
|
|
17064
|
+
body,
|
|
17065
|
+
response: void 0,
|
|
17066
|
+
upgradeWith(request, headers) {
|
|
17067
|
+
if (isWebSocket) return Object.keys(headers).length === 0 ? webSocketUpgrade : fail(upgradeError(request, "WebSocket upgrades do not support custom response headers"));
|
|
17068
|
+
const invalid = validateUpgradeHeaders(request, headers);
|
|
17069
|
+
if (invalid !== void 0) return fail(invalid);
|
|
17070
|
+
return toSocket(socket, withFiber((fiber) => {
|
|
17071
|
+
const maxBytes = fiber.getRef(MaxBodySize);
|
|
17072
|
+
return drainBody(body ?? nodeRequest, maxBytes === void 0 ? void 0 : Number(maxBytes));
|
|
17073
|
+
}).pipe(andThen(sync$2(() => {
|
|
17074
|
+
if (state.response !== void 0) return;
|
|
17075
|
+
state.response = empty({
|
|
17076
|
+
status: 101,
|
|
17077
|
+
headers: {
|
|
17078
|
+
...headers,
|
|
17079
|
+
connection: "Upgrade",
|
|
17080
|
+
upgrade: protocol
|
|
17081
|
+
}
|
|
17082
|
+
});
|
|
17083
|
+
if (head.length > 0) socket.unshift(head);
|
|
17084
|
+
let responseHead = `HTTP/1.1 101 Switching Protocols\r\nConnection: Upgrade\r\nUpgrade: ${protocol}\r\n`;
|
|
17085
|
+
for (const name in headers) responseHead += `${name}: ${headers[name]}\r\n`;
|
|
17086
|
+
socket.write(responseHead + "\r\n", "latin1");
|
|
17087
|
+
}))));
|
|
17088
|
+
}
|
|
17089
|
+
};
|
|
17090
|
+
const request = new ServerRequestImpl(nodeRequest, nodeResponse, state);
|
|
15887
17091
|
const context = add(services, HttpServerRequest, request);
|
|
15888
17092
|
const fiber = runIn(runForkWith(context)(handledApp), options.scope);
|
|
15889
17093
|
socket.on("error", () => {});
|
|
@@ -15893,23 +17097,86 @@ const makeUpgradeHandler = (lazyWss, httpEffect, options) => {
|
|
|
15893
17097
|
});
|
|
15894
17098
|
});
|
|
15895
17099
|
};
|
|
17100
|
+
const legacyUpgradeBody = /*#__PURE__*/ Number((/*#__PURE__*/ process.versions.node.split("."))[0]) < 26;
|
|
17101
|
+
const reservedUpgradeHeaders = /*#__PURE__*/ new Set([
|
|
17102
|
+
"connection",
|
|
17103
|
+
"upgrade",
|
|
17104
|
+
"content-length",
|
|
17105
|
+
"transfer-encoding"
|
|
17106
|
+
]);
|
|
17107
|
+
const validateUpgradeHeaders = (request, headers) => {
|
|
17108
|
+
for (const name in headers) {
|
|
17109
|
+
if (reservedUpgradeHeaders.has(name)) return upgradeError(request, `Upgrade responses cannot set the ${name} header`);
|
|
17110
|
+
try {
|
|
17111
|
+
http.validateHeaderName(name);
|
|
17112
|
+
http.validateHeaderValue(name, headers[name]);
|
|
17113
|
+
} catch (cause) {
|
|
17114
|
+
return upgradeError(request, `Invalid upgrade response header: ${name}`, cause);
|
|
17115
|
+
}
|
|
17116
|
+
}
|
|
17117
|
+
};
|
|
17118
|
+
const upgradeError = (request, description, cause) => new HttpServerError({ reason: new InternalError({
|
|
17119
|
+
request,
|
|
17120
|
+
description,
|
|
17121
|
+
cause
|
|
17122
|
+
}) });
|
|
17123
|
+
const isHttp2 = (request) => request?.httpVersionMajor === 2;
|
|
17124
|
+
const requestHeaders = (source) => {
|
|
17125
|
+
if (!isHttp2(source)) return source.headers;
|
|
17126
|
+
const headers = {};
|
|
17127
|
+
for (const name in source.headers) if (name[0] !== ":") headers[name] = source.headers[name];
|
|
17128
|
+
const authority = source.headers[":authority"];
|
|
17129
|
+
if (typeof authority === "string") headers.host = authority;
|
|
17130
|
+
return headers;
|
|
17131
|
+
};
|
|
17132
|
+
const absoluteTarget = (url) => {
|
|
17133
|
+
if (!/^https?:\/\//i.test(url)) return;
|
|
17134
|
+
try {
|
|
17135
|
+
return new URL(url);
|
|
17136
|
+
} catch {
|
|
17137
|
+
return;
|
|
17138
|
+
}
|
|
17139
|
+
};
|
|
17140
|
+
const pendingContinue = /*#__PURE__*/ new WeakSet();
|
|
17141
|
+
const bodyBytesRead = /*#__PURE__*/ new WeakMap();
|
|
15896
17142
|
var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage {
|
|
17143
|
+
destroyOnOverflow = false;
|
|
17144
|
+
closeOnDone = false;
|
|
15897
17145
|
[TypeId$2];
|
|
15898
17146
|
response;
|
|
15899
|
-
|
|
15900
|
-
upgraded = false;
|
|
17147
|
+
upgradeState;
|
|
15901
17148
|
url;
|
|
15902
17149
|
headersOverride;
|
|
15903
|
-
|
|
17150
|
+
peerAddressOverride;
|
|
17151
|
+
protocol;
|
|
17152
|
+
constructor(source, response, upgradeState, url, headersOverride, remoteAddressOverride, peerAddressOverride, protocol) {
|
|
15904
17153
|
super(source, (cause) => new HttpServerError({ reason: new RequestParseError({
|
|
15905
17154
|
request: this,
|
|
17155
|
+
reason: cause instanceof MaxBytesError ? "BodyTooLarge" : "Parse",
|
|
15906
17156
|
cause
|
|
15907
17157
|
}) }), remoteAddressOverride);
|
|
15908
17158
|
this[TypeId$2] = TypeId$2;
|
|
15909
17159
|
this.response = response;
|
|
15910
|
-
this.
|
|
17160
|
+
this.upgradeState = upgradeState;
|
|
17161
|
+
if (url === void 0) {
|
|
17162
|
+
const target = absoluteTarget(source.url);
|
|
17163
|
+
if (target === void 0) url = source.url;
|
|
17164
|
+
else {
|
|
17165
|
+
url = target.pathname + target.search;
|
|
17166
|
+
const headers = {
|
|
17167
|
+
...requestHeaders(source),
|
|
17168
|
+
host: target.host
|
|
17169
|
+
};
|
|
17170
|
+
headersOverride = fromInput(headers);
|
|
17171
|
+
}
|
|
17172
|
+
}
|
|
15911
17173
|
this.url = url;
|
|
15912
17174
|
this.headersOverride = headersOverride;
|
|
17175
|
+
this.peerAddressOverride = peerAddressOverride;
|
|
17176
|
+
this.protocol = protocol;
|
|
17177
|
+
}
|
|
17178
|
+
get peerAddress() {
|
|
17179
|
+
return this.peerAddressOverride ?? this.remoteAddress;
|
|
15913
17180
|
}
|
|
15914
17181
|
cachedCookies;
|
|
15915
17182
|
get cookies() {
|
|
@@ -15919,49 +17186,95 @@ var ServerRequestImpl = class ServerRequestImpl extends NodeHttpIncomingMessage
|
|
|
15919
17186
|
get resolvedResponse() {
|
|
15920
17187
|
return typeof this.response === "function" ? this.response() : this.response;
|
|
15921
17188
|
}
|
|
17189
|
+
writeContinue() {
|
|
17190
|
+
if (pendingContinue.delete(this.source) && !this.resolvedResponse.headersSent) this.resolvedResponse.writeContinue();
|
|
17191
|
+
}
|
|
17192
|
+
get stream() {
|
|
17193
|
+
return suspend$1(() => {
|
|
17194
|
+
this.writeContinue();
|
|
17195
|
+
const source = this.source;
|
|
17196
|
+
return mapArray(super.stream, (chunk) => {
|
|
17197
|
+
let bytes = bodyBytesRead.get(source) ?? 0;
|
|
17198
|
+
for (const item of chunk) bytes += item.length;
|
|
17199
|
+
bodyBytesRead.set(source, bytes);
|
|
17200
|
+
return chunk;
|
|
17201
|
+
});
|
|
17202
|
+
});
|
|
17203
|
+
}
|
|
17204
|
+
get arrayBuffer() {
|
|
17205
|
+
return suspend(() => {
|
|
17206
|
+
this.writeContinue();
|
|
17207
|
+
return super.arrayBuffer;
|
|
17208
|
+
});
|
|
17209
|
+
}
|
|
15922
17210
|
modify(options) {
|
|
15923
|
-
return new ServerRequestImpl(this.source, this.response, this.
|
|
17211
|
+
return new ServerRequestImpl(this.source, this.response, this.upgradeState, options.url ?? this.url, options.headers ?? this.headersOverride, "remoteAddress" in options ? options.remoteAddress : this.remoteAddressOverride, options.peerAddress ?? this.peerAddressOverride, options.protocol ?? this.protocol);
|
|
15924
17212
|
}
|
|
15925
17213
|
get originalUrl() {
|
|
15926
|
-
|
|
17214
|
+
const url = this.source.url;
|
|
17215
|
+
const headers = this.source.headers;
|
|
17216
|
+
const http2 = isHttp2(this.source);
|
|
17217
|
+
const host = (http2 ? headers[":authority"] : void 0) ?? headers.host;
|
|
17218
|
+
if (url[0] !== "/" || host === void 0) return url;
|
|
17219
|
+
const scheme = http2 ? headers[":scheme"] : void 0;
|
|
17220
|
+
const encrypted = this.source.socket?.encrypted;
|
|
17221
|
+
return `${scheme ?? (encrypted ? "https" : "http")}://${host}${url}`;
|
|
15927
17222
|
}
|
|
15928
17223
|
cachedMethod;
|
|
15929
17224
|
get method() {
|
|
15930
17225
|
return this.cachedMethod ??= this.source.method.toUpperCase();
|
|
15931
17226
|
}
|
|
15932
17227
|
get headers() {
|
|
15933
|
-
this.headersOverride ??= this.source
|
|
17228
|
+
this.headersOverride ??= fromInput(requestHeaders(this.source));
|
|
15934
17229
|
return this.headersOverride;
|
|
15935
17230
|
}
|
|
15936
17231
|
multipartEffect;
|
|
15937
17232
|
get multipart() {
|
|
15938
17233
|
if (this.multipartEffect) return this.multipartEffect;
|
|
15939
|
-
this.multipartEffect = runSync(cached(
|
|
17234
|
+
this.multipartEffect = runSync(cached(suspend(() => {
|
|
17235
|
+
this.writeContinue();
|
|
17236
|
+
return persisted(this.bodySource, this.source.headers);
|
|
17237
|
+
})));
|
|
15940
17238
|
return this.multipartEffect;
|
|
15941
17239
|
}
|
|
15942
17240
|
get multipartStream() {
|
|
15943
|
-
return
|
|
17241
|
+
return suspend$1(() => {
|
|
17242
|
+
this.writeContinue();
|
|
17243
|
+
return stream(this.bodySource, this.source.headers);
|
|
17244
|
+
});
|
|
15944
17245
|
}
|
|
15945
17246
|
get upgrade() {
|
|
15946
|
-
return this.
|
|
17247
|
+
return this.upgradeWith({});
|
|
17248
|
+
}
|
|
17249
|
+
upgradeWith(options) {
|
|
17250
|
+
const state = this.upgradeState;
|
|
17251
|
+
if (state === void 0) return fail(new HttpServerError({ reason: new RequestParseError({
|
|
15947
17252
|
request: this,
|
|
15948
17253
|
description: "not an upgradeable ServerRequest"
|
|
15949
17254
|
}) }));
|
|
17255
|
+
return state.upgradeWith(this, fromInput(options.headers));
|
|
17256
|
+
}
|
|
17257
|
+
get upgradedResponse() {
|
|
17258
|
+
return this.upgradeState?.response;
|
|
17259
|
+
}
|
|
17260
|
+
get bodySource() {
|
|
17261
|
+
return this.upgradeState?.body ?? this.source;
|
|
15950
17262
|
}
|
|
15951
17263
|
toString() {
|
|
15952
|
-
return `ServerRequest(${this.method} ${this.url})`;
|
|
17264
|
+
return `ServerRequest(${this.method} ${redactUrl(this.url)})`;
|
|
15953
17265
|
}
|
|
15954
17266
|
toJSON() {
|
|
15955
17267
|
return inspect(this, {
|
|
15956
17268
|
_id: "HttpServerRequest",
|
|
15957
17269
|
method: this.method,
|
|
15958
|
-
url: this.originalUrl
|
|
17270
|
+
url: redactUrl(this.originalUrl)
|
|
15959
17271
|
});
|
|
15960
17272
|
}
|
|
15961
17273
|
};
|
|
15962
17274
|
/**
|
|
15963
17275
|
* Provides an `HttpServer` by creating and managing a scoped Node
|
|
15964
|
-
* `http.Server` with the supplied listen and shutdown
|
|
17276
|
+
* `http.Server` or `node:http2` server with the supplied listen and shutdown
|
|
17277
|
+
* options.
|
|
15965
17278
|
*
|
|
15966
17279
|
* @stability unstable
|
|
15967
17280
|
* @category layers
|
|
@@ -15976,56 +17289,67 @@ const layerServer = /*#__PURE__*/ flow(make$9, /*#__PURE__*/ effect(HttpServer))
|
|
|
15976
17289
|
* @category layers
|
|
15977
17290
|
* @since 4.0.0
|
|
15978
17291
|
*/
|
|
15979
|
-
const layerHttpServices = /*#__PURE__*/ mergeAll(layer$10, layerWeak, layer$
|
|
17292
|
+
const layerHttpServices = /*#__PURE__*/ mergeAll(layer$10, layerWeak, layer$30);
|
|
15980
17293
|
/**
|
|
15981
17294
|
* Provides a Node `HttpServer` together with the Node HTTP platform, ETag, and
|
|
15982
17295
|
* core platform services required to serve requests.
|
|
15983
17296
|
*
|
|
17297
|
+
* **Details**
|
|
17298
|
+
*
|
|
17299
|
+
* Node's timeouts are set on the server returned by `evaluate`; see `make`.
|
|
17300
|
+
*
|
|
15984
17301
|
* @stability unstable
|
|
15985
17302
|
* @category layers
|
|
15986
17303
|
* @since 4.0.0
|
|
15987
17304
|
*/
|
|
15988
17305
|
const layer$9 = (evaluate, options) => mergeAll(layerServer(evaluate, options), layerHttpServices);
|
|
17306
|
+
http.createServer;
|
|
15989
17307
|
const closeCode = (exit) => isSuccess(exit) ? 1e3 : hasInterruptsOnly(exit.cause) ? 1001 : 1011;
|
|
15990
17308
|
const upgradedResponse = /*#__PURE__*/ empty({ status: 101 });
|
|
15991
17309
|
const handleResponse = (request, response) => {
|
|
15992
|
-
|
|
17310
|
+
const upgraded = request.upgradedResponse;
|
|
17311
|
+
if (upgraded !== void 0) return succeed(upgraded);
|
|
15993
17312
|
const nodeResponse = request.resolvedResponse;
|
|
15994
17313
|
if (nodeResponse.writableEnded) return void_;
|
|
15995
17314
|
let headers = response.headers;
|
|
17315
|
+
if (response.status === 204 || response.status === 205) {
|
|
17316
|
+
const { "content-length": _, ...rest } = headers;
|
|
17317
|
+
headers = rest;
|
|
17318
|
+
}
|
|
15996
17319
|
if (!isEmpty(response.cookies)) {
|
|
15997
17320
|
headers = { ...headers };
|
|
15998
17321
|
const toSet = toSetCookieHeaders(response.cookies);
|
|
15999
17322
|
if (headers["set-cookie"] !== void 0) toSet.push(headers["set-cookie"]);
|
|
16000
17323
|
headers["set-cookie"] = toSet;
|
|
16001
17324
|
}
|
|
17325
|
+
try {
|
|
17326
|
+
return writeResponse(request, response, nodeResponse, headers);
|
|
17327
|
+
} catch (defect) {
|
|
17328
|
+
return andThen(cancelResponseBody(response.body), handleCause(nodeResponse, response)(die$1(defect)));
|
|
17329
|
+
}
|
|
17330
|
+
};
|
|
17331
|
+
const writeResponse = (request, response, nodeResponse, headers) => {
|
|
17332
|
+
if (nodeResponse.destroyed) return cancelResponseBody(response.body);
|
|
16002
17333
|
if (request.method === "HEAD") {
|
|
16003
|
-
|
|
16004
|
-
return andThen(cancelResponseBody(response.body),
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
resume(void_);
|
|
16011
|
-
};
|
|
16012
|
-
nodeResponse.once("close", done);
|
|
16013
|
-
nodeResponse.end(done);
|
|
16014
|
-
}));
|
|
17334
|
+
writeHead(nodeResponse, response, headers);
|
|
17335
|
+
return andThen(cancelResponseBody(response.body), endAndAwait(nodeResponse));
|
|
17336
|
+
}
|
|
17337
|
+
if (omitsBody(response)) {
|
|
17338
|
+
writeHead(nodeResponse, response, headers);
|
|
17339
|
+
nodeResponse.end();
|
|
17340
|
+
return cancelResponseBody(response.body);
|
|
16015
17341
|
}
|
|
17342
|
+
nodeResponse.strictContentLength = true;
|
|
16016
17343
|
const body = response.body;
|
|
16017
17344
|
switch (body._tag) {
|
|
16018
17345
|
case "Empty":
|
|
16019
|
-
|
|
16020
|
-
|
|
16021
|
-
|
|
16022
|
-
|
|
16023
|
-
|
|
16024
|
-
if (
|
|
16025
|
-
try: (signal) =>
|
|
16026
|
-
signal,
|
|
16027
|
-
end: true
|
|
16028
|
-
}),
|
|
17346
|
+
writeHead(nodeResponse, response, headers);
|
|
17347
|
+
return end(nodeResponse, response);
|
|
17348
|
+
case "Raw": {
|
|
17349
|
+
const piped = typeof body.body === "object" && body.body !== null && "pipe" in body.body && typeof body.body.pipe === "function";
|
|
17350
|
+
writeHead(nodeResponse, response, headers, piped);
|
|
17351
|
+
if (piped) return tryPromise({
|
|
17352
|
+
try: (signal) => pipeTo(body.body, nodeResponse, headers, signal),
|
|
16029
17353
|
catch: (cause) => new HttpServerError({ reason: new ResponseError({
|
|
16030
17354
|
request,
|
|
16031
17355
|
response,
|
|
@@ -16033,39 +17357,31 @@ const handleResponse = (request, response) => {
|
|
|
16033
17357
|
cause
|
|
16034
17358
|
}) })
|
|
16035
17359
|
}).pipe(interruptible, tapCause(handleCause(nodeResponse, response)));
|
|
16036
|
-
return
|
|
16037
|
-
|
|
16038
|
-
});
|
|
17360
|
+
return endAndAwait(nodeResponse, body.body).pipe(tapCause(handleCause(nodeResponse, response)));
|
|
17361
|
+
}
|
|
16039
17362
|
case "Uint8Array":
|
|
16040
|
-
|
|
16041
|
-
if (body.contentLength < 1048576)
|
|
16042
|
-
|
|
16043
|
-
|
|
16044
|
-
}
|
|
16045
|
-
return callback((resume) => {
|
|
16046
|
-
nodeResponse.end(body.text ?? body.body, () => resume(void_));
|
|
16047
|
-
});
|
|
16048
|
-
case "FormData": return suspend(() => {
|
|
17363
|
+
writeHead(nodeResponse, response, headers);
|
|
17364
|
+
if (body.contentLength < 1048576) return end(nodeResponse, response, body.text ?? body.body);
|
|
17365
|
+
return endAndAwait(nodeResponse, body.text ?? body.body).pipe(tapCause(handleCause(nodeResponse, response)));
|
|
17366
|
+
case "FormData": {
|
|
16049
17367
|
const r = new globalThis.Response(body.formData);
|
|
16050
|
-
|
|
17368
|
+
const formHeaders = {
|
|
16051
17369
|
...headers,
|
|
16052
17370
|
...Object.fromEntries(r.headers)
|
|
16053
|
-
}
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
|
|
16058
|
-
|
|
16059
|
-
|
|
16060
|
-
|
|
16061
|
-
|
|
16062
|
-
})
|
|
16063
|
-
resume(void_);
|
|
16064
|
-
});
|
|
17371
|
+
};
|
|
17372
|
+
writeHead(nodeResponse, response, formHeaders);
|
|
17373
|
+
return tryPromise({
|
|
17374
|
+
try: (signal) => pipeTo(Readable.fromWeb(r.body), nodeResponse, formHeaders, signal),
|
|
17375
|
+
catch: (cause) => new HttpServerError({ reason: new ResponseError({
|
|
17376
|
+
request,
|
|
17377
|
+
response,
|
|
17378
|
+
description: "Error writing FormData response",
|
|
17379
|
+
cause
|
|
17380
|
+
}) })
|
|
16065
17381
|
}).pipe(interruptible, tapCause(handleCause(nodeResponse, response)));
|
|
16066
|
-
}
|
|
17382
|
+
}
|
|
16067
17383
|
case "Stream": {
|
|
16068
|
-
|
|
17384
|
+
writeHead(nodeResponse, response, headers, true);
|
|
16069
17385
|
const drainLatch = makeUnsafe$3();
|
|
16070
17386
|
nodeResponse.on("drain", () => drainLatch.openUnsafe());
|
|
16071
17387
|
return body.stream.pipe(orDie$1, runForEachArray((array) => {
|
|
@@ -16074,30 +17390,142 @@ const handleResponse = (request, response) => {
|
|
|
16074
17390
|
drainLatch.closeUnsafe();
|
|
16075
17391
|
return drainLatch.await;
|
|
16076
17392
|
}), interruptible, matchCauseEffect({
|
|
16077
|
-
onSuccess: () =>
|
|
17393
|
+
onSuccess: () => end(nodeResponse, response),
|
|
16078
17394
|
onFailure: handleCause(nodeResponse, response)
|
|
16079
17395
|
}));
|
|
16080
17396
|
}
|
|
16081
17397
|
}
|
|
16082
17398
|
};
|
|
17399
|
+
const isFinalStatus = (status) => status >= 200 && status <= 599;
|
|
17400
|
+
const internalServerError = /*#__PURE__*/ empty({ status: 500 });
|
|
17401
|
+
const invalidStatusError = (status) => /* @__PURE__ */ new RangeError(`Invalid final response status: ${status}`);
|
|
17402
|
+
const writeHead = (nodeResponse, response, headers, streaming = false) => {
|
|
17403
|
+
if (!isFinalStatus(response.status)) throw invalidStatusError(response.status);
|
|
17404
|
+
if (isHttp2(nodeResponse.req)) {
|
|
17405
|
+
nodeResponse.writeHead(response.status, withoutConnectionHeaders(headers));
|
|
17406
|
+
return;
|
|
17407
|
+
}
|
|
17408
|
+
nodeResponse.writeHead(response.status, response.statusText, closesConnection(nodeResponse.req, streaming) ? {
|
|
17409
|
+
...headers,
|
|
17410
|
+
connection: "close"
|
|
17411
|
+
} : headers);
|
|
17412
|
+
};
|
|
17413
|
+
const connectionHeaders = /*#__PURE__*/ new Set([
|
|
17414
|
+
"connection",
|
|
17415
|
+
"keep-alive",
|
|
17416
|
+
"proxy-connection",
|
|
17417
|
+
"transfer-encoding",
|
|
17418
|
+
"upgrade",
|
|
17419
|
+
"http2-settings"
|
|
17420
|
+
]);
|
|
17421
|
+
const withoutConnectionHeaders = (headers) => {
|
|
17422
|
+
let result;
|
|
17423
|
+
for (const name in headers) if (connectionHeaders.has(name) || name === "te" && headers[name] !== "trailers") {
|
|
17424
|
+
result ??= { ...headers };
|
|
17425
|
+
delete result[name];
|
|
17426
|
+
}
|
|
17427
|
+
return result ?? headers;
|
|
17428
|
+
};
|
|
17429
|
+
const maxDrainBytes = 262144;
|
|
17430
|
+
const closeGracePeriod = 500;
|
|
17431
|
+
const closesConnection = (request, streaming) => {
|
|
17432
|
+
if (request === void 0 || request.httpVersionMajor !== 1 || request.complete) return false;
|
|
17433
|
+
if (pendingContinue.has(request)) return true;
|
|
17434
|
+
const contentLength = request.headers["content-length"];
|
|
17435
|
+
return !streaming && contentLength !== void 0 && Number(contentLength) - (bodyBytesRead.get(request) ?? 0) > maxDrainBytes;
|
|
17436
|
+
};
|
|
17437
|
+
const teardownBody = (request, response) => {
|
|
17438
|
+
if (request.complete || request.destroyed) return;
|
|
17439
|
+
const socket = request.socket;
|
|
17440
|
+
if (response._last) {
|
|
17441
|
+
request._consuming = true;
|
|
17442
|
+
response._last = false;
|
|
17443
|
+
return closeSocket(socket);
|
|
17444
|
+
}
|
|
17445
|
+
let bytes = 0;
|
|
17446
|
+
request.on("data", (chunk) => {
|
|
17447
|
+
bytes += chunk.length;
|
|
17448
|
+
if (bytes > maxDrainBytes) {
|
|
17449
|
+
request.pause();
|
|
17450
|
+
closeSocket(socket);
|
|
17451
|
+
}
|
|
17452
|
+
});
|
|
17453
|
+
request.resume();
|
|
17454
|
+
};
|
|
17455
|
+
const closeSocket = (socket) => {
|
|
17456
|
+
if (socket.destroyed) return;
|
|
17457
|
+
socket.end();
|
|
17458
|
+
const timer = setTimeout(() => socket.destroy(), closeGracePeriod);
|
|
17459
|
+
socket.once("close", () => clearTimeout(timer));
|
|
17460
|
+
};
|
|
16083
17461
|
const cancelResponseBody = (body) => {
|
|
16084
17462
|
const stream = body._tag === "Raw" ? body.body : void 0;
|
|
16085
17463
|
if (stream instanceof Readable) return sync$2(() => stream.destroy());
|
|
16086
17464
|
return void_;
|
|
16087
17465
|
};
|
|
17466
|
+
const endAndAwait = (nodeResponse, chunk) => callback((resume) => {
|
|
17467
|
+
if (nodeResponse.destroyed) return resume(void_);
|
|
17468
|
+
let completed = false;
|
|
17469
|
+
const done = () => {
|
|
17470
|
+
if (completed) return;
|
|
17471
|
+
completed = true;
|
|
17472
|
+
nodeResponse.off("close", done);
|
|
17473
|
+
resume(void_);
|
|
17474
|
+
};
|
|
17475
|
+
nodeResponse.once("close", done);
|
|
17476
|
+
if (chunk === void 0) nodeResponse.end(done);
|
|
17477
|
+
else nodeResponse.end(chunk, done);
|
|
17478
|
+
});
|
|
17479
|
+
const end = (nodeResponse, response, chunk) => {
|
|
17480
|
+
try {
|
|
17481
|
+
nodeResponse.end(chunk);
|
|
17482
|
+
return void_;
|
|
17483
|
+
} catch (defect) {
|
|
17484
|
+
return handleCause(nodeResponse, response)(die$1(defect));
|
|
17485
|
+
}
|
|
17486
|
+
};
|
|
17487
|
+
const pipeTo = (readable, nodeResponse, headers, signal) => {
|
|
17488
|
+
const contentLength = headers["content-length"];
|
|
17489
|
+
if (typeof contentLength !== "string") return pipeline$1(readable, nodeResponse, { signal });
|
|
17490
|
+
let remaining = Number(contentLength);
|
|
17491
|
+
const mismatch = () => /* @__PURE__ */ new Error(`Response body doesn't match content-length of ${contentLength}`);
|
|
17492
|
+
return pipeline$1(readable, new Transform({
|
|
17493
|
+
transform(chunk, _encoding, callback) {
|
|
17494
|
+
remaining -= chunk.length;
|
|
17495
|
+
callback(remaining < 0 ? mismatch() : null, chunk);
|
|
17496
|
+
},
|
|
17497
|
+
flush(callback) {
|
|
17498
|
+
callback(remaining > 0 ? mismatch() : null);
|
|
17499
|
+
}
|
|
17500
|
+
}), nodeResponse, { signal });
|
|
17501
|
+
};
|
|
16088
17502
|
const handleCause = (nodeResponse, originalResponse) => (originalCause) => flatMap(causeResponse(originalCause), ([response, cause]) => {
|
|
16089
17503
|
const headersSent = nodeResponse.headersSent;
|
|
16090
|
-
|
|
16091
|
-
if (!
|
|
17504
|
+
let abort = headersSent;
|
|
17505
|
+
if (!headersSent) {
|
|
17506
|
+
if (!isFinalStatus(response.status)) {
|
|
17507
|
+
cause = combine(cause, die$1(invalidStatusError(response.status)));
|
|
17508
|
+
response = internalServerError;
|
|
17509
|
+
}
|
|
17510
|
+
try {
|
|
17511
|
+
writeHead(nodeResponse, response, {});
|
|
17512
|
+
} catch {
|
|
17513
|
+
abort = true;
|
|
17514
|
+
}
|
|
17515
|
+
}
|
|
17516
|
+
if (!nodeResponse.writableEnded) {
|
|
17517
|
+
if (abort) nodeResponse.destroy(isHttp2(nodeResponse.req) ? /* @__PURE__ */ new Error("The response was aborted") : void 0);
|
|
17518
|
+
else nodeResponse.end();
|
|
17519
|
+
}
|
|
16092
17520
|
return failCause(headersSent ? combine(originalCause, die$1(originalResponse)) : cause);
|
|
16093
17521
|
});
|
|
16094
17522
|
// ../../packages/shared/src/remote.ts
|
|
16095
|
-
var RemoteBackendUrlMissingError = class extends TaggedError()("RemoteBackendUrlMissingError", {}) {
|
|
17523
|
+
var RemoteBackendUrlMissingError = class extends TaggedError$1()("RemoteBackendUrlMissingError", {}) {
|
|
16096
17524
|
get message() {
|
|
16097
17525
|
return "Enter a backend URL.";
|
|
16098
17526
|
}
|
|
16099
17527
|
};
|
|
16100
|
-
var RemotePairingUrlInvalidError = class extends TaggedError()("RemotePairingUrlInvalidError", {
|
|
17528
|
+
var RemotePairingUrlInvalidError = class extends TaggedError$1()("RemotePairingUrlInvalidError", {
|
|
16101
17529
|
cause: optional(Defect()),
|
|
16102
17530
|
protocol: optional(String$1)
|
|
16103
17531
|
}) {
|
|
@@ -16105,7 +17533,7 @@ var RemotePairingUrlInvalidError = class extends TaggedError()("RemotePairingUrl
|
|
|
16105
17533
|
return "Pairing URL is invalid.";
|
|
16106
17534
|
}
|
|
16107
17535
|
};
|
|
16108
|
-
var RemoteBackendUrlInvalidError = class extends TaggedError()("RemoteBackendUrlInvalidError", {
|
|
17536
|
+
var RemoteBackendUrlInvalidError = class extends TaggedError$1()("RemoteBackendUrlInvalidError", {
|
|
16109
17537
|
source: Literals(["direct-host", "hosted-pairing-host"]),
|
|
16110
17538
|
cause: optional(Defect()),
|
|
16111
17539
|
protocol: optional(String$1)
|
|
@@ -16114,12 +17542,12 @@ var RemoteBackendUrlInvalidError = class extends TaggedError()("RemoteBackendUrl
|
|
|
16114
17542
|
return "Backend URL is invalid.";
|
|
16115
17543
|
}
|
|
16116
17544
|
};
|
|
16117
|
-
var RemotePairingTokenMissingError = class extends TaggedError()("RemotePairingTokenMissingError", { host: String$1 }) {
|
|
17545
|
+
var RemotePairingTokenMissingError = class extends TaggedError$1()("RemotePairingTokenMissingError", { host: String$1 }) {
|
|
16118
17546
|
get message() {
|
|
16119
17547
|
return "Pairing URL is missing its token.";
|
|
16120
17548
|
}
|
|
16121
17549
|
};
|
|
16122
|
-
var RemotePairingCodeMissingError = class extends TaggedError()("RemotePairingCodeMissingError", { host: String$1 }) {
|
|
17550
|
+
var RemotePairingCodeMissingError = class extends TaggedError$1()("RemotePairingCodeMissingError", { host: String$1 }) {
|
|
16123
17551
|
get message() {
|
|
16124
17552
|
return "Enter a pairing code.";
|
|
16125
17553
|
}
|
|
@@ -16322,7 +17750,7 @@ const BrowserLaunchEnvConfig = all$1({
|
|
|
16322
17750
|
container: String$2("container").pipe(option$1),
|
|
16323
17751
|
DISPLAY: String$2("DISPLAY").pipe(option$1),
|
|
16324
17752
|
WAYLAND_DISPLAY: String$2("WAYLAND_DISPLAY").pipe(option$1)
|
|
16325
|
-
}).pipe(map$
|
|
17753
|
+
}).pipe(map$5(compactEnv));
|
|
16326
17754
|
const CommandLookupEnvConfig = all$1({
|
|
16327
17755
|
PATH: String$2("PATH").pipe(option$1),
|
|
16328
17756
|
Path: String$2("Path").pipe(option$1),
|
|
@@ -16334,7 +17762,7 @@ const CommandLookupEnvConfig = all$1({
|
|
|
16334
17762
|
ProgramW6432: String$2("ProgramW6432").pipe(option$1),
|
|
16335
17763
|
XDG_DATA_HOME: String$2("XDG_DATA_HOME").pipe(option$1),
|
|
16336
17764
|
"ProgramFiles(x86)": String$2("ProgramFiles(x86)").pipe(option$1)
|
|
16337
|
-
}).pipe(map$
|
|
17765
|
+
}).pipe(map$5(compactEnv));
|
|
16338
17766
|
const readBrowserLaunchEnv = BrowserLaunchEnvConfig.pipe(orElseSucceed(() => ({})));
|
|
16339
17767
|
const readCommandLookupEnv = CommandLookupEnvConfig.pipe(orElseSucceed(() => ({})));
|
|
16340
17768
|
function parseTargetPathAndPosition(target) {
|
|
@@ -16416,7 +17844,7 @@ function fileManagerCommandForPlatform(platform, env) {
|
|
|
16416
17844
|
const LINUX_DIRECTORY_HANDLER_PROBE_TIMEOUT = "2 seconds";
|
|
16417
17845
|
const hasUsableLinuxDirectoryHandler = fn("externalLauncher.hasUsableLinuxDirectoryHandler")(function* (env) {
|
|
16418
17846
|
if (!(yield* isCommandAvailable("xdg-mime", { env }))) return false;
|
|
16419
|
-
return yield* (yield* ChildProcessSpawner).spawn(make$
|
|
17847
|
+
return yield* (yield* ChildProcessSpawner).spawn(make$44("xdg-mime", [
|
|
16420
17848
|
"query",
|
|
16421
17849
|
"default",
|
|
16422
17850
|
"inode/directory"
|
|
@@ -16606,7 +18034,7 @@ const decodeManagerEnvironment = decodeUnknownEffect(fromJsonString(Struct({ dat
|
|
|
16606
18034
|
const readGraphicalSessionEnv = fn("externalLauncher.readGraphicalSessionEnv")(function* () {
|
|
16607
18035
|
const hostEnv = yield* Environment;
|
|
16608
18036
|
if ((yield* Platform) !== "linux" || hasGraphicalLinuxSession(hostEnv)) return {};
|
|
16609
|
-
const output = yield* (yield* ChildProcessSpawner).string(make$
|
|
18037
|
+
const output = yield* (yield* ChildProcessSpawner).string(make$44("busctl", [
|
|
16610
18038
|
"--user",
|
|
16611
18039
|
"--json=short",
|
|
16612
18040
|
"get-property",
|
|
@@ -16628,7 +18056,7 @@ const readGraphicalSessionEnv = fn("externalLauncher.readGraphicalSessionEnv")(f
|
|
|
16628
18056
|
const launchAndUnref = fn("externalLauncher.launchAndUnref")(function* (launch, onError) {
|
|
16629
18057
|
const spawner = yield* ChildProcessSpawner;
|
|
16630
18058
|
const env = yield* Environment;
|
|
16631
|
-
const command = make$
|
|
18059
|
+
const command = make$44(launch.command, launch.args, {
|
|
16632
18060
|
...launch.options,
|
|
16633
18061
|
env: {
|
|
16634
18062
|
...env,
|
|
@@ -16681,7 +18109,7 @@ const make$8 = gen(function* () {
|
|
|
16681
18109
|
const path = yield* Path;
|
|
16682
18110
|
const provideCommandResolutionServices = (effect) => effect.pipe(provideService(FileSystem, fileSystem), provideService(Path, path));
|
|
16683
18111
|
const scope = yield* Scope;
|
|
16684
|
-
const editorDiscoveryCache = yield* make$
|
|
18112
|
+
const editorDiscoveryCache = yield* make$42(none());
|
|
16685
18113
|
const runEditorDiscovery = (scan) => provideCommandResolutionServices(resolveAvailableEditors()).pipe(provideService(ChildProcessSpawner, spawner), onExit((exit) => gen(function* () {
|
|
16686
18114
|
const expiresAtNanos = (yield* monotonicTimeNanos) + EDITOR_DISCOVERY_CACHE_TTL_NANOS;
|
|
16687
18115
|
yield* update(editorDiscoveryCache, (current) => isNone(current) || current.value.scan !== scan ? current : isSuccess(exit) ? some({
|
|
@@ -16718,7 +18146,7 @@ const ClerkPublishableKeyPrefix = Literals([
|
|
|
16718
18146
|
"pk_live",
|
|
16719
18147
|
"unknown"
|
|
16720
18148
|
]);
|
|
16721
|
-
var ClerkPublishableKeyDecodeError = class extends TaggedError()("ClerkPublishableKeyDecodeError", {
|
|
18149
|
+
var ClerkPublishableKeyDecodeError = class extends TaggedError$1()("ClerkPublishableKeyDecodeError", {
|
|
16722
18150
|
keyPrefix: ClerkPublishableKeyPrefix,
|
|
16723
18151
|
cause: Defect()
|
|
16724
18152
|
}) {
|
|
@@ -16726,7 +18154,7 @@ var ClerkPublishableKeyDecodeError = class extends TaggedError()("ClerkPublishab
|
|
|
16726
18154
|
return `Failed to decode Clerk publishable key (${this.keyPrefix}).`;
|
|
16727
18155
|
}
|
|
16728
18156
|
};
|
|
16729
|
-
var ClerkPublishableKeyFrontendApiError = class extends TaggedError()("ClerkPublishableKeyFrontendApiError", {
|
|
18157
|
+
var ClerkPublishableKeyFrontendApiError = class extends TaggedError$1()("ClerkPublishableKeyFrontendApiError", {
|
|
16730
18158
|
keyPrefix: ClerkPublishableKeyPrefix,
|
|
16731
18159
|
frontendApi: String$1,
|
|
16732
18160
|
reason: Literals([
|
|
@@ -16853,7 +18281,7 @@ function validateHostedAppUrl(value) {
|
|
|
16853
18281
|
}
|
|
16854
18282
|
function makePublicValueConfig(name, fallback) {
|
|
16855
18283
|
const runtimeConfig = NonEmptyString(name);
|
|
16856
|
-
return (fallback ? runtimeConfig.pipe(withDefault(fallback)) : runtimeConfig).pipe(map$
|
|
18284
|
+
return (fallback ? runtimeConfig.pipe(withDefault(fallback)) : runtimeConfig).pipe(map$5((value) => value.trim()));
|
|
16857
18285
|
}
|
|
16858
18286
|
function makeCloudCliOAuthConfig({ clerkPublishableKeyFallback = buildTimeClerkPublishableKey, clerkCliOAuthClientIdFallback = buildTimeClerkCliOAuthClientId } = {}) {
|
|
16859
18287
|
return all$1({
|
|
@@ -17116,32 +18544,32 @@ function idTokenIdentity(idToken) {
|
|
|
17116
18544
|
]) if (typeof value === "string" && value.length > 0) return value;
|
|
17117
18545
|
return null;
|
|
17118
18546
|
}
|
|
17119
|
-
var CloudCliCredentialRemovalError = class extends TaggedError()("CloudCliCredentialRemovalError", { cause: Defect() }) {
|
|
18547
|
+
var CloudCliCredentialRemovalError = class extends TaggedError$1()("CloudCliCredentialRemovalError", { cause: Defect() }) {
|
|
17120
18548
|
get message() {
|
|
17121
18549
|
return "Could not remove the stored P4 Connect CLI credential.";
|
|
17122
18550
|
}
|
|
17123
18551
|
};
|
|
17124
|
-
var CloudCliCredentialRefreshError = class extends TaggedError()("CloudCliCredentialRefreshError", { cause: Defect() }) {
|
|
18552
|
+
var CloudCliCredentialRefreshError = class extends TaggedError$1()("CloudCliCredentialRefreshError", { cause: Defect() }) {
|
|
17125
18553
|
get message() {
|
|
17126
18554
|
return "Could not refresh the P4 Connect CLI credential.";
|
|
17127
18555
|
}
|
|
17128
18556
|
};
|
|
17129
|
-
var CloudCliCredentialReadError = class extends TaggedError()("CloudCliCredentialReadError", { cause: Defect() }) {
|
|
18557
|
+
var CloudCliCredentialReadError = class extends TaggedError$1()("CloudCliCredentialReadError", { cause: Defect() }) {
|
|
17130
18558
|
get message() {
|
|
17131
18559
|
return "Could not read the stored P4 Connect CLI credential.";
|
|
17132
18560
|
}
|
|
17133
18561
|
};
|
|
17134
|
-
var CloudCliAuthorizationError = class extends TaggedError()("CloudCliAuthorizationError", { cause: Defect() }) {
|
|
18562
|
+
var CloudCliAuthorizationError = class extends TaggedError$1()("CloudCliAuthorizationError", { cause: Defect() }) {
|
|
17135
18563
|
get message() {
|
|
17136
18564
|
return "Could not authorize the P4 Connect CLI.";
|
|
17137
18565
|
}
|
|
17138
18566
|
};
|
|
17139
|
-
var CloudCliAuthorizationTimeoutError = class extends TaggedError()("CloudCliAuthorizationTimeoutError", { cause: Defect() }) {
|
|
18567
|
+
var CloudCliAuthorizationTimeoutError = class extends TaggedError$1()("CloudCliAuthorizationTimeoutError", { cause: Defect() }) {
|
|
17140
18568
|
get message() {
|
|
17141
18569
|
return "Timed out waiting for P4 Connect authorization.";
|
|
17142
18570
|
}
|
|
17143
18571
|
};
|
|
17144
|
-
var CloudCliAuthorizationDeniedError = class extends TaggedError()("CloudCliAuthorizationDeniedError", {}) {
|
|
18572
|
+
var CloudCliAuthorizationDeniedError = class extends TaggedError$1()("CloudCliAuthorizationDeniedError", {}) {
|
|
17145
18573
|
get message() {
|
|
17146
18574
|
return "P4 Connect authorization was denied in the browser.";
|
|
17147
18575
|
}
|
|
@@ -17180,12 +18608,13 @@ const exchangeToken = fn("cloud.cli_token.exchange")(function* (metadata, params
|
|
|
17180
18608
|
return yield* post(metadata.tokenEndpoint).pipe(bodyUrlParams(params), httpClient.execute, flatMap((response) => readTokenResponse(response, params)), timeout(OAUTH_REQUEST_TIMEOUT));
|
|
17181
18609
|
});
|
|
17182
18610
|
const makePkceRequest = gen(function* () {
|
|
17183
|
-
const
|
|
17184
|
-
const
|
|
18611
|
+
const random = yield* SecureRandom;
|
|
18612
|
+
const digest = yield* Digest;
|
|
18613
|
+
const verifier = encode$2(yield* random.randomBytes(32));
|
|
17185
18614
|
return {
|
|
17186
18615
|
verifier,
|
|
17187
|
-
challenge: encode$2(yield*
|
|
17188
|
-
state: encode$2(yield*
|
|
18616
|
+
challenge: encode$2(yield* digest.digest(sha256$1, new TextEncoder().encode(verifier))),
|
|
18617
|
+
state: encode$2(yield* random.randomBytes(16))
|
|
17189
18618
|
};
|
|
17190
18619
|
});
|
|
17191
18620
|
const isTransportError = (error) => isHttpClientError(error) && error.reason._tag === "TransportError";
|
|
@@ -17251,13 +18680,14 @@ const deviceAuthorizationLogin = fn("cloud.cli_token.device_authorization_login"
|
|
|
17251
18680
|
});
|
|
17252
18681
|
/** @public Service construction is part of the canonical Effect module API. */
|
|
17253
18682
|
const make$7 = gen(function* () {
|
|
17254
|
-
const
|
|
18683
|
+
const digest = yield* Digest;
|
|
18684
|
+
const random = yield* SecureRandom;
|
|
17255
18685
|
const httpClient = yield* HttpClient;
|
|
17256
|
-
const services = make$
|
|
18686
|
+
const services = make$29(SecureRandom, random).pipe(add(Digest, digest), add(HttpClient, httpClient));
|
|
17257
18687
|
const secrets = yield* ServerSecretStore;
|
|
17258
18688
|
const terminal = yield* Terminal;
|
|
17259
18689
|
const externalLauncher = yield* ExternalLauncher;
|
|
17260
|
-
const semaphore = yield* make$
|
|
18690
|
+
const semaphore = yield* make$39(1);
|
|
17261
18691
|
const persist = fn("cloud.cli_token.persist")(function* (token) {
|
|
17262
18692
|
const encoded = yield* encodePersistedToken(token);
|
|
17263
18693
|
yield* secrets.set(CLOUD_CLI_OAUTH_TOKEN_SECRET, stringToBytes(encoded));
|
|
@@ -17285,7 +18715,7 @@ const make$7 = gen(function* () {
|
|
|
17285
18715
|
const metadata = yield* cloudCliOAuthConfig;
|
|
17286
18716
|
const hostedAppUrl = yield* hostedAppUrlConfig;
|
|
17287
18717
|
const { verifier, challenge, state } = yield* makePkceRequest;
|
|
17288
|
-
const callback = yield* make$
|
|
18718
|
+
const callback = yield* make$30();
|
|
17289
18719
|
const layerCallbackRoute = add$2("GET", "/callback", gen(function* () {
|
|
17290
18720
|
const request = yield* HttpServerRequest;
|
|
17291
18721
|
const url = new URL(request.originalUrl, metadata.redirectUri);
|
|
@@ -17297,7 +18727,7 @@ const make$7 = gen(function* () {
|
|
|
17297
18727
|
yield* serve(layerCallbackRoute, {
|
|
17298
18728
|
disableListenLog: true,
|
|
17299
18729
|
disableLogger: true
|
|
17300
|
-
}).pipe(provide(layer$9(
|
|
18730
|
+
}).pipe(provide$1(layer$9(NodeHttp.createServer, {
|
|
17301
18731
|
host: "127.0.0.1",
|
|
17302
18732
|
port: metadata.loopbackPort,
|
|
17303
18733
|
disablePreemptiveShutdown: true
|
|
@@ -17335,7 +18765,7 @@ const make$7 = gen(function* () {
|
|
|
17335
18765
|
if (token.value.expiresAtEpochMs - CLOUD_CLI_OAUTH_REFRESH_EARLY_MS > now) return token;
|
|
17336
18766
|
return some(yield* refresh(token.value).pipe(flatMap(persist)));
|
|
17337
18767
|
});
|
|
17338
|
-
const getExisting = semaphore.withPermits(1)(getExistingNoLock().pipe(mapError((cause) => new CloudCliCredentialRefreshError({ cause })), provide
|
|
18768
|
+
const getExisting = semaphore.withPermits(1)(getExistingNoLock().pipe(mapError((cause) => new CloudCliCredentialRefreshError({ cause })), provide(services)));
|
|
17339
18769
|
const hasCredential = semaphore.withPermits(1)(read().pipe(map$1(isSome), mapError((cause) => new CloudCliCredentialReadError({ cause }))));
|
|
17340
18770
|
const get = semaphore.withPermits(1)(gen(function* () {
|
|
17341
18771
|
const token = yield* getExistingNoLock().pipe(orElseSucceed(() => none()));
|
|
@@ -17348,7 +18778,7 @@ const make$7 = gen(function* () {
|
|
|
17348
18778
|
_tag: "Authorized",
|
|
17349
18779
|
token: yield* persist(authorization.token)
|
|
17350
18780
|
} : authorization;
|
|
17351
|
-
}).pipe(mapError((cause) => isQuitError(cause) ? cause : new CloudCliAuthorizationError({ cause })), provide
|
|
18781
|
+
}).pipe(mapError((cause) => isQuitError(cause) ? cause : new CloudCliAuthorizationError({ cause })), provide(services)));
|
|
17352
18782
|
const store = fn("cloud.cli_token.store")(function* (token) {
|
|
17353
18783
|
yield* semaphore.withPermits(1)(persist(token).pipe(asVoid, mapError((cause) => new CloudCliAuthorizationError({ cause }))));
|
|
17354
18784
|
});
|
|
@@ -17402,7 +18832,7 @@ const stderrDiagnosticOf = (stderr) => {
|
|
|
17402
18832
|
if (stderr.trim().length === 0) return;
|
|
17403
18833
|
return STDERR_DIAGNOSTIC_PATTERNS.find(([pattern]) => pattern.test(stderr))?.[1] ?? "unknown";
|
|
17404
18834
|
};
|
|
17405
|
-
var TailscaleCommandSpawnError = class extends TaggedError()("TailscaleCommandSpawnError", {
|
|
18835
|
+
var TailscaleCommandSpawnError = class extends TaggedError$1()("TailscaleCommandSpawnError", {
|
|
17406
18836
|
...TailscaleCommandContext,
|
|
17407
18837
|
cause: Defect()
|
|
17408
18838
|
}) {
|
|
@@ -17410,7 +18840,7 @@ var TailscaleCommandSpawnError = class extends TaggedError()("TailscaleCommandSp
|
|
|
17410
18840
|
return `Failed to spawn tailscale ${this.subcommand}.`;
|
|
17411
18841
|
}
|
|
17412
18842
|
};
|
|
17413
|
-
var TailscaleCommandOutputError = class extends TaggedError()("TailscaleCommandOutputError", {
|
|
18843
|
+
var TailscaleCommandOutputError = class extends TaggedError$1()("TailscaleCommandOutputError", {
|
|
17414
18844
|
...TailscaleCommandContext,
|
|
17415
18845
|
cause: Defect()
|
|
17416
18846
|
}) {
|
|
@@ -17418,7 +18848,7 @@ var TailscaleCommandOutputError = class extends TaggedError()("TailscaleCommandO
|
|
|
17418
18848
|
return `Failed to read output from tailscale ${this.subcommand}.`;
|
|
17419
18849
|
}
|
|
17420
18850
|
};
|
|
17421
|
-
var TailscaleCommandExitError = class extends TaggedError()("TailscaleCommandExitError", {
|
|
18851
|
+
var TailscaleCommandExitError = class extends TaggedError$1()("TailscaleCommandExitError", {
|
|
17422
18852
|
...TailscaleCommandContext,
|
|
17423
18853
|
exitCode: Number$2,
|
|
17424
18854
|
stdoutLength: optional(Number$2),
|
|
@@ -17429,7 +18859,7 @@ var TailscaleCommandExitError = class extends TaggedError()("TailscaleCommandExi
|
|
|
17429
18859
|
return `tailscale ${this.subcommand} exited with code ${this.exitCode}.`;
|
|
17430
18860
|
}
|
|
17431
18861
|
};
|
|
17432
|
-
var TailscaleCommandTimeoutError = class extends TaggedError()("TailscaleCommandTimeoutError", {
|
|
18862
|
+
var TailscaleCommandTimeoutError = class extends TaggedError$1()("TailscaleCommandTimeoutError", {
|
|
17433
18863
|
...TailscaleCommandContext,
|
|
17434
18864
|
timeoutMs: Number$2,
|
|
17435
18865
|
cause: Defect()
|
|
@@ -17438,7 +18868,7 @@ var TailscaleCommandTimeoutError = class extends TaggedError()("TailscaleCommand
|
|
|
17438
18868
|
return `tailscale ${this.subcommand} timed out after ${this.timeoutMs}ms.`;
|
|
17439
18869
|
}
|
|
17440
18870
|
};
|
|
17441
|
-
var TailscaleStatusParseError = class extends TaggedError()("TailscaleStatusParseError", { cause: Defect() }) {
|
|
18871
|
+
var TailscaleStatusParseError = class extends TaggedError$1()("TailscaleStatusParseError", { cause: Defect() }) {
|
|
17442
18872
|
get message() {
|
|
17443
18873
|
return "Failed to decode tailscale status JSON.";
|
|
17444
18874
|
}
|
|
@@ -17490,7 +18920,7 @@ const readTailscaleOutput = (subcommand, args) => gen(function* () {
|
|
|
17490
18920
|
subcommand,
|
|
17491
18921
|
argumentCount: args.length
|
|
17492
18922
|
};
|
|
17493
|
-
const command = make$
|
|
18923
|
+
const command = make$44(executable, [...args], { forceKillAfter: TAILSCALE_KILL_GRACE });
|
|
17494
18924
|
return yield* gen(function* () {
|
|
17495
18925
|
const child = yield* spawner.spawn(command).pipe(mapError((cause) => new TailscaleCommandSpawnError({
|
|
17496
18926
|
...commandContext,
|
|
@@ -17576,7 +19006,7 @@ const runTailscaleCommand = (args, timeoutInput) => gen(function* () {
|
|
|
17576
19006
|
};
|
|
17577
19007
|
const timeout$1 = fromInputUnsafe(timeoutInput);
|
|
17578
19008
|
return yield* gen(function* () {
|
|
17579
|
-
const child = yield* spawner.spawn(make$
|
|
19009
|
+
const child = yield* spawner.spawn(make$44(executable, args, { forceKillAfter: TAILSCALE_KILL_GRACE })).pipe(mapError((cause) => new TailscaleCommandSpawnError({
|
|
17580
19010
|
...commandContext,
|
|
17581
19011
|
cause
|
|
17582
19012
|
})), catchDefect((cause) => fail(new TailscaleCommandSpawnError({
|
|
@@ -17622,7 +19052,7 @@ const probeTailscaleHttpsEndpoint = (input) => gen(function* () {
|
|
|
17622
19052
|
const client = yield* HttpClient;
|
|
17623
19053
|
const response = yield* gen(function* () {
|
|
17624
19054
|
const url = new URL("/.well-known/p4/environment", input.baseUrl);
|
|
17625
|
-
const request = get$
|
|
19055
|
+
const request = get$1(url.toString());
|
|
17626
19056
|
return yield* client.execute(request);
|
|
17627
19057
|
}).pipe(timeoutOption(input.timeout ?? TAILSCALE_PROBE_TIMEOUT));
|
|
17628
19058
|
return match(response, {
|
|
@@ -17699,25 +19129,25 @@ const make$6 = gen(function* () {
|
|
|
17699
19129
|
const relayClient = yield* RelayClient;
|
|
17700
19130
|
const secrets = yield* ServerSecretStore;
|
|
17701
19131
|
const httpClient = withScope(yield* HttpClient);
|
|
17702
|
-
const activeRef = yield* make$
|
|
17703
|
-
const desiredConfigRef = yield* make$
|
|
19132
|
+
const activeRef = yield* make$42(null);
|
|
19133
|
+
const desiredConfigRef = yield* make$42(null);
|
|
17704
19134
|
const recoveryRequests = yield* sliding(1);
|
|
17705
19135
|
const tunnelConnections = yield* sliding(1);
|
|
17706
19136
|
const readinessChanges = yield* sliding(1);
|
|
17707
|
-
const reconcileSemaphore = yield* make$
|
|
17708
|
-
const restartDelayRef = yield* make$
|
|
17709
|
-
const linkStateSemaphore = yield* make$
|
|
19137
|
+
const reconcileSemaphore = yield* make$39(1);
|
|
19138
|
+
const restartDelayRef = yield* make$42(0);
|
|
19139
|
+
const linkStateSemaphore = yield* make$39(1);
|
|
17710
19140
|
const runtimeScope = yield* scope;
|
|
17711
|
-
const installInFlightRef = yield* make$
|
|
17712
|
-
const lastInstallFailureAtRef = yield* make$
|
|
17713
|
-
const prunedRef = yield* make$
|
|
17714
|
-
const retryLoopRunningRef = yield* make$
|
|
17715
|
-
const notReadyChecksBeforeRestartRef = yield* make$
|
|
19141
|
+
const installInFlightRef = yield* make$42(false);
|
|
19142
|
+
const lastInstallFailureAtRef = yield* make$42(null);
|
|
19143
|
+
const prunedRef = yield* make$42(false);
|
|
19144
|
+
const retryLoopRunningRef = yield* make$42(false);
|
|
19145
|
+
const notReadyChecksBeforeRestartRef = yield* make$42(CONNECTOR_NOT_READY_CHECKS_BEFORE_RESTART);
|
|
17716
19146
|
const transportChosenByUser = process.env.TUNNEL_TRANSPORT_PROTOCOL !== void 0;
|
|
17717
19147
|
const previousFallback = transportChosenByUser ? none() : yield* secrets.get(HTTP2_FALLBACK_STATE).pipe(map$1(flatMap$1((bytes) => decodeHttp2Fallback(new TextDecoder().decode(bytes)))), orElseSucceed(() => none()));
|
|
17718
19148
|
const now = yield* currentTimeMillis;
|
|
17719
|
-
const http2Ref = yield* make$
|
|
17720
|
-
const quicStallsRef = yield* make$
|
|
19149
|
+
const http2Ref = yield* make$42(isSome(previousFallback) && now >= previousFallback.value.fellBackAt && now - previousFallback.value.fellBackAt < HTTP2_FALLBACK_TTL_MS);
|
|
19150
|
+
const quicStallsRef = yield* make$42([]);
|
|
17721
19151
|
let reconcileConfig;
|
|
17722
19152
|
const { logsDir } = yield* ServerConfig;
|
|
17723
19153
|
const relayClientLogPath = (yield* Path).join(logsDir, RELAY_CLIENT_LOG_FILE);
|
|
@@ -17728,7 +19158,7 @@ const make$6 = gen(function* () {
|
|
|
17728
19158
|
maxBytes: 1048576,
|
|
17729
19159
|
maxFiles: 2,
|
|
17730
19160
|
throwOnError: true
|
|
17731
|
-
})).pipe(map$1((sink) => make$
|
|
19161
|
+
})).pipe(map$1((sink) => make$26((options) => {
|
|
17732
19162
|
try {
|
|
17733
19163
|
const entry = formatJson.log(options);
|
|
17734
19164
|
const bytes = Buffer.byteLength(entry) + 1;
|
|
@@ -17758,7 +19188,7 @@ const make$6 = gen(function* () {
|
|
|
17758
19188
|
});
|
|
17759
19189
|
const superviseConnector = (connector) => gen(function* () {
|
|
17760
19190
|
const result$1 = yield* result(connector.child.exitCode);
|
|
17761
|
-
const activeAtExit = yield* get$
|
|
19191
|
+
const activeAtExit = yield* get$2(activeRef);
|
|
17762
19192
|
if (activeAtExit?.child.pid !== connector.child.pid || activeAtExit.configKey !== connector.configKey) return;
|
|
17763
19193
|
const uptimeMillis = (yield* currentTimeMillis) - connector.startedAtMillis;
|
|
17764
19194
|
const restartDelayMillis = yield* modify(restartDelayRef, (current) => {
|
|
@@ -17776,11 +19206,11 @@ const make$6 = gen(function* () {
|
|
|
17776
19206
|
yield* sleep(millis(restartDelayMillis));
|
|
17777
19207
|
}
|
|
17778
19208
|
yield* reconcileSemaphore.withPermits(1)(gen(function* () {
|
|
17779
|
-
const active = yield* get$
|
|
19209
|
+
const active = yield* get$2(activeRef);
|
|
17780
19210
|
if (active?.child.pid !== connector.child.pid || active.configKey !== connector.configKey) return;
|
|
17781
|
-
yield* set(activeRef, null);
|
|
19211
|
+
yield* set$1(activeRef, null);
|
|
17782
19212
|
yield* stopConnector(connector);
|
|
17783
|
-
const desiredConfig = yield* get$
|
|
19213
|
+
const desiredConfig = yield* get$2(desiredConfigRef);
|
|
17784
19214
|
if (!desiredConfig || desiredConfig.providerKind !== "cloudflare_tunnel" || runtimeConfigKey(desiredConfig) !== connector.configKey) return;
|
|
17785
19215
|
yield* logWarning("Relay client exited; restarting", {
|
|
17786
19216
|
pid: Number(connector.child.pid),
|
|
@@ -17795,10 +19225,10 @@ const make$6 = gen(function* () {
|
|
|
17795
19225
|
const installPinnedRelayClient = gen(function* () {
|
|
17796
19226
|
if (yield* getAndSet(installInFlightRef, true)) return;
|
|
17797
19227
|
yield* logInfo("Installing the pinned relay client", { version: CLOUDFLARED_VERSION });
|
|
17798
|
-
yield* relayClient.install.pipe(tap(() => set(lastInstallFailureAtRef, null)), flatMap((installed) => reconcileSemaphore.withPermits(1)(gen(function* () {
|
|
17799
|
-
const desiredConfig = yield* get$
|
|
19228
|
+
yield* relayClient.install.pipe(tap(() => set$1(lastInstallFailureAtRef, null)), flatMap((installed) => reconcileSemaphore.withPermits(1)(gen(function* () {
|
|
19229
|
+
const desiredConfig = yield* get$2(desiredConfigRef);
|
|
17800
19230
|
if (!desiredConfig || desiredConfig.providerKind !== "cloudflare_tunnel") return;
|
|
17801
|
-
const active = yield* get$
|
|
19231
|
+
const active = yield* get$2(activeRef);
|
|
17802
19232
|
if (active?.executable.executablePath === installed.executablePath && active.executable.version === installed.version) return;
|
|
17803
19233
|
const resolved = yield* relayClient.resolve;
|
|
17804
19234
|
if (resolved.status !== "available" || resolved.executablePath !== installed.executablePath || resolved.version !== installed.version) return;
|
|
@@ -17808,11 +19238,11 @@ const make$6 = gen(function* () {
|
|
|
17808
19238
|
});
|
|
17809
19239
|
const previous = yield* getAndSet(activeRef, null);
|
|
17810
19240
|
const status = yield* reconcileConfig(desiredConfig);
|
|
17811
|
-
const next = yield* get$
|
|
19241
|
+
const next = yield* get$2(activeRef);
|
|
17812
19242
|
if (!next) {
|
|
17813
19243
|
yield* logWarning("Relay client did not start after the update", status);
|
|
17814
19244
|
const previousRunning = previous ? yield* previous.child.isRunning.pipe(orElseSucceed(() => false)) : false;
|
|
17815
|
-
if (previous && previousRunning) yield* set(activeRef, previous);
|
|
19245
|
+
if (previous && previousRunning) yield* set$1(activeRef, previous);
|
|
17816
19246
|
else {
|
|
17817
19247
|
yield* stopConnector(previous);
|
|
17818
19248
|
yield* offer(recoveryRequests, desiredConfig);
|
|
@@ -17820,28 +19250,28 @@ const make$6 = gen(function* () {
|
|
|
17820
19250
|
return;
|
|
17821
19251
|
}
|
|
17822
19252
|
if (previous) yield* _await(next.registered).pipe(ensuring(stopConnector(previous)), forkIn(next.scope));
|
|
17823
|
-
}))), catchTags({ RelayClientInstallError: (error) => currentTimeMillis.pipe(flatMap((failedAt) => set(lastInstallFailureAtRef, failedAt)), andThen(logWarning("Could not install the pinned relay client", {
|
|
19253
|
+
}))), catchTags({ RelayClientInstallError: (error) => currentTimeMillis.pipe(flatMap((failedAt) => set$1(lastInstallFailureAtRef, failedAt)), andThen(logWarning("Could not install the pinned relay client", {
|
|
17824
19254
|
reason: error.reason,
|
|
17825
19255
|
message: error.message,
|
|
17826
19256
|
cause: error.cause
|
|
17827
|
-
}))) }), ensuring(set(installInFlightRef, false)));
|
|
19257
|
+
}))) }), ensuring(set$1(installInFlightRef, false)));
|
|
17828
19258
|
});
|
|
17829
19259
|
const ensurePinnedRelayClient = gen(function* () {
|
|
17830
19260
|
const now = yield* currentTimeMillis;
|
|
17831
|
-
const lastFailureAt = yield* get$
|
|
19261
|
+
const lastFailureAt = yield* get$2(lastInstallFailureAtRef);
|
|
17832
19262
|
if (lastFailureAt !== null && now - lastFailureAt < RELAY_CLIENT_INSTALL_RETRY_INTERVAL_MS) return;
|
|
17833
19263
|
yield* installPinnedRelayClient;
|
|
17834
19264
|
}).pipe(forkIn(runtimeScope), asVoid);
|
|
17835
19265
|
const retryPinnedRelayClientInstall = gen(function* () {
|
|
17836
19266
|
while (true) {
|
|
17837
19267
|
yield* sleep(millis(RELAY_CLIENT_INSTALL_RETRY_INTERVAL_MS));
|
|
17838
|
-
const desiredConfig = yield* get$
|
|
19268
|
+
const desiredConfig = yield* get$2(desiredConfigRef);
|
|
17839
19269
|
if (!desiredConfig || desiredConfig.providerKind !== "cloudflare_tunnel") return;
|
|
17840
|
-
const active = yield* get$
|
|
19270
|
+
const active = yield* get$2(activeRef);
|
|
17841
19271
|
if (active && !needsPinnedRelayClient(active.executable)) return;
|
|
17842
19272
|
yield* installPinnedRelayClient;
|
|
17843
19273
|
}
|
|
17844
|
-
}).pipe(ensuring(set(retryLoopRunningRef, false)));
|
|
19274
|
+
}).pipe(ensuring(set$1(retryLoopRunningRef, false)));
|
|
17845
19275
|
const startPinnedRelayClientRetries = gen(function* () {
|
|
17846
19276
|
if (yield* getAndSet(retryLoopRunningRef, true)) return;
|
|
17847
19277
|
yield* forkIn(retryPinnedRelayClientInstall, runtimeScope);
|
|
@@ -17872,15 +19302,15 @@ const make$6 = gen(function* () {
|
|
|
17872
19302
|
}
|
|
17873
19303
|
if (status.value === 200) {
|
|
17874
19304
|
notReadyChecks = 0;
|
|
17875
|
-
yield* set(notReadyChecksBeforeRestartRef, CONNECTOR_NOT_READY_CHECKS_BEFORE_RESTART);
|
|
19305
|
+
yield* set$1(notReadyChecksBeforeRestartRef, CONNECTOR_NOT_READY_CHECKS_BEFORE_RESTART);
|
|
17876
19306
|
continue;
|
|
17877
19307
|
}
|
|
17878
19308
|
if (status.value !== 503) continue;
|
|
17879
19309
|
notReadyChecks += 1;
|
|
17880
|
-
const threshold = yield* get$
|
|
19310
|
+
const threshold = yield* get$2(notReadyChecksBeforeRestartRef);
|
|
17881
19311
|
if (notReadyChecks < threshold) continue;
|
|
17882
19312
|
notReadyChecks = 0;
|
|
17883
|
-
yield* set(notReadyChecksBeforeRestartRef, Math.min(threshold * 2, CONNECTOR_NOT_READY_CHECKS_MAX));
|
|
19313
|
+
yield* set$1(notReadyChecksBeforeRestartRef, Math.min(threshold * 2, CONNECTOR_NOT_READY_CHECKS_MAX));
|
|
17884
19314
|
yield* logWarning("Relay client has no tunnel connection; restarting it", {
|
|
17885
19315
|
pid: Number(connector.child.pid),
|
|
17886
19316
|
notReadyChecks: threshold,
|
|
@@ -17891,10 +19321,10 @@ const make$6 = gen(function* () {
|
|
|
17891
19321
|
}
|
|
17892
19322
|
});
|
|
17893
19323
|
const switchToHttp2 = fnUntraced$1(function* (connector) {
|
|
17894
|
-
const active = yield* get$
|
|
17895
|
-
const desiredConfig = yield* get$
|
|
17896
|
-
if ((yield* get$
|
|
17897
|
-
yield* set(http2Ref, true);
|
|
19324
|
+
const active = yield* get$2(activeRef);
|
|
19325
|
+
const desiredConfig = yield* get$2(desiredConfigRef);
|
|
19326
|
+
if ((yield* get$2(http2Ref)) || active !== connector || !desiredConfig) return;
|
|
19327
|
+
yield* set$1(http2Ref, true);
|
|
17898
19328
|
yield* secrets.set(HTTP2_FALLBACK_STATE, new TextEncoder().encode(encodeHttp2Fallback({ fellBackAt: yield* currentTimeMillis }))).pipe(catch_(() => logWarning("Could not persist the relay client HTTP/2 fallback")));
|
|
17899
19329
|
yield* logWarning("Relay client keeps losing QUIC connections; switching to HTTP/2", {
|
|
17900
19330
|
pid: Number(connector.child.pid),
|
|
@@ -17905,15 +19335,15 @@ const make$6 = gen(function* () {
|
|
|
17905
19335
|
if ((yield* reconcileConfig(desiredConfig)).status !== "running") yield* offer(recoveryRequests, desiredConfig);
|
|
17906
19336
|
}, reconcileSemaphore.withPermits(1));
|
|
17907
19337
|
const noteQuicStall = fnUntraced$1(function* (connector) {
|
|
17908
|
-
if (transportChosenByUser || (yield* get$
|
|
19338
|
+
if (transportChosenByUser || (yield* get$2(http2Ref))) return;
|
|
17909
19339
|
const now = yield* currentTimeMillis;
|
|
17910
|
-
if ((yield* get$
|
|
19340
|
+
if ((yield* get$2(activeRef)) !== connector) return;
|
|
17911
19341
|
if ((yield* updateAndGet(quicStallsRef, (previous) => [...previous.filter((at) => now - at < QUIC_STALL_WINDOW_MS), now])).length < QUIC_STALLS_BEFORE_HTTP2) return;
|
|
17912
19342
|
yield* forkIn(switchToHttp2(connector), runtimeScope);
|
|
17913
19343
|
});
|
|
17914
19344
|
const observeConnectorOutput = (connector) => {
|
|
17915
19345
|
let rejectedRegistrations = 0;
|
|
17916
|
-
return connector.child.all.pipe(decodeText(), splitLines, map$
|
|
19346
|
+
return connector.child.all.pipe(decodeText(), splitLines, map$4((line) => line.trim()), filter$1((line) => line.length > 0), runForEach((line) => {
|
|
17917
19347
|
const output = line.replaceAll(connector.config.connectorToken, "<redacted>");
|
|
17918
19348
|
const attributes = {
|
|
17919
19349
|
pid: Number(connector.child.pid),
|
|
@@ -17924,7 +19354,7 @@ const make$6 = gen(function* () {
|
|
|
17924
19354
|
switch (classifyRelayClientOutput(line)) {
|
|
17925
19355
|
case "connected":
|
|
17926
19356
|
rejectedRegistrations = 0;
|
|
17927
|
-
return succeed$2(connector.registered, void 0).pipe(andThen(set(connector.protocol, RELAY_CLIENT_PROTOCOL.exec(line)?.[1] ?? null)), andThen(logInfo("Relay client tunnel connection registered", attributes)), andThen(offer(tunnelConnections, void 0)), andThen(offer(readinessChanges, void 0)), andThen(isPinnedManagedRelayClient(connector.executable) ? getAndSet(prunedRef, true).pipe(flatMap((pruned) => pruned ? void_ : relayClient.pruneManagedVersions)) : void_), asVoid);
|
|
19357
|
+
return succeed$2(connector.registered, void 0).pipe(andThen(set$1(connector.protocol, RELAY_CLIENT_PROTOCOL.exec(line)?.[1] ?? null)), andThen(logInfo("Relay client tunnel connection registered", attributes)), andThen(offer(tunnelConnections, void 0)), andThen(offer(readinessChanges, void 0)), andThen(isPinnedManagedRelayClient(connector.executable) ? getAndSet(prunedRef, true).pipe(flatMap((pruned) => pruned ? void_ : relayClient.pruneManagedVersions)) : void_), asVoid);
|
|
17928
19358
|
case "unregistered": return logInfo("Relay client tunnel connection unregistered", attributes);
|
|
17929
19359
|
case "warning":
|
|
17930
19360
|
if (/\btimeout: no recent network activity\b/u.test(line)) return noteQuicStall(connector).pipe(andThen(logWarning("Relay client reported a transport warning", attributes)));
|
|
@@ -17957,7 +19387,7 @@ const make$6 = gen(function* () {
|
|
|
17957
19387
|
} : { status: "disabled" };
|
|
17958
19388
|
}
|
|
17959
19389
|
const nextConfigKey = runtimeConfigKey(config);
|
|
17960
|
-
const active = yield* get$
|
|
19390
|
+
const active = yield* get$2(activeRef);
|
|
17961
19391
|
if (active?.configKey === nextConfigKey) {
|
|
17962
19392
|
if (yield* active.child.isRunning.pipe(orElseSucceed(() => false))) return {
|
|
17963
19393
|
status: "running",
|
|
@@ -17981,9 +19411,9 @@ const make$6 = gen(function* () {
|
|
|
17981
19411
|
...config.tunnelId ? { tunnelId: config.tunnelId } : {},
|
|
17982
19412
|
...config.tunnelName ? { tunnelName: config.tunnelName } : {}
|
|
17983
19413
|
};
|
|
17984
|
-
const http2 = yield* get$
|
|
17985
|
-
const connectorScope = yield* make$
|
|
17986
|
-
const child = yield* spawner.spawn(make$
|
|
19414
|
+
const http2 = yield* get$2(http2Ref);
|
|
19415
|
+
const connectorScope = yield* make$31("sequential");
|
|
19416
|
+
const child = yield* spawner.spawn(make$44(executable.executablePath, [
|
|
17987
19417
|
"tunnel",
|
|
17988
19418
|
"--no-autoupdate",
|
|
17989
19419
|
"--loglevel",
|
|
@@ -18031,11 +19461,11 @@ const make$6 = gen(function* () {
|
|
|
18031
19461
|
configKey: nextConfigKey,
|
|
18032
19462
|
config,
|
|
18033
19463
|
startedAtMillis: yield* currentTimeMillis,
|
|
18034
|
-
registered: yield* make$
|
|
18035
|
-
metricsAddress: yield* make$
|
|
18036
|
-
protocol: yield* make$
|
|
19464
|
+
registered: yield* make$30(),
|
|
19465
|
+
metricsAddress: yield* make$30(),
|
|
19466
|
+
protocol: yield* make$42(null)
|
|
18037
19467
|
};
|
|
18038
|
-
yield* set(activeRef, connector);
|
|
19468
|
+
yield* set$1(activeRef, connector);
|
|
18039
19469
|
yield* forkIn(observeConnectorOutput(connector), connectorScope);
|
|
18040
19470
|
yield* forkIn(superviseConnector(connector), connectorScope);
|
|
18041
19471
|
yield* forkIn(watchConnectorRegistration(connector), connectorScope);
|
|
@@ -18058,13 +19488,13 @@ const make$6 = gen(function* () {
|
|
|
18058
19488
|
};
|
|
18059
19489
|
});
|
|
18060
19490
|
const applyConfig = fn("CloudManagedEndpointRuntime.applyConfig")((config) => reconcileSemaphore.withPermits(1)(gen(function* () {
|
|
18061
|
-
const desired = yield* get$
|
|
18062
|
-
if (!(desired !== null && config !== null && runtimeConfigKey(desired) === runtimeConfigKey(config))) yield* set(restartDelayRef, 0);
|
|
18063
|
-
yield* set(desiredConfigRef, config);
|
|
19491
|
+
const desired = yield* get$2(desiredConfigRef);
|
|
19492
|
+
if (!(desired !== null && config !== null && runtimeConfigKey(desired) === runtimeConfigKey(config))) yield* set$1(restartDelayRef, 0);
|
|
19493
|
+
yield* set$1(desiredConfigRef, config);
|
|
18064
19494
|
return yield* reconcileConfig(config);
|
|
18065
19495
|
})), withRelayClientLog);
|
|
18066
19496
|
const restartConnector = fn("CloudManagedEndpointRuntime.restartConnector")(function* (pid, stillDead) {
|
|
18067
|
-
const active = yield* get$
|
|
19497
|
+
const active = yield* get$2(activeRef);
|
|
18068
19498
|
if (!active || Number(active.child.pid) !== pid || !(yield* stillDead)) return false;
|
|
18069
19499
|
yield* logWarning("Cloudflare has no live connection from the relay client; restarting it", {
|
|
18070
19500
|
pid,
|
|
@@ -18075,10 +19505,10 @@ const make$6 = gen(function* () {
|
|
|
18075
19505
|
}, reconcileSemaphore.withPermits(1));
|
|
18076
19506
|
const readMetrics = (url, schema) => httpClient.get(url).pipe(flatMap(schemaBodyJson(schema)), scoped, withTracerEnabled(false), timeoutOption(CONNECTOR_READINESS_REQUEST_TIMEOUT), map$1(getOrNull), orElseSucceed(() => null));
|
|
18077
19507
|
const inspectConnector = gen(function* () {
|
|
18078
|
-
const active = yield* get$
|
|
19508
|
+
const active = yield* get$2(activeRef);
|
|
18079
19509
|
if (!active || !(yield* active.child.isRunning.pipe(orElseSucceed(() => false)))) return null;
|
|
18080
19510
|
const pid = Number(active.child.pid);
|
|
18081
|
-
const protocol = yield* get$
|
|
19511
|
+
const protocol = yield* get$2(active.protocol);
|
|
18082
19512
|
if (!(yield* isDone(active.metricsAddress))) return {
|
|
18083
19513
|
pid,
|
|
18084
19514
|
readyConnections: null,
|
|
@@ -18193,10 +19623,10 @@ const make$5 = gen(function* () {
|
|
|
18193
19623
|
const runtime = yield* CloudManagedEndpointRuntime;
|
|
18194
19624
|
const secrets = yield* ServerSecretStore;
|
|
18195
19625
|
const httpClient = yield* HttpClient;
|
|
18196
|
-
const latestRef = yield* make$
|
|
18197
|
-
const checkCounter = yield* make$
|
|
18198
|
-
const lastHealthyOrder = yield* make$
|
|
18199
|
-
const deadConnectorRef = yield* make$
|
|
19626
|
+
const latestRef = yield* make$42(none());
|
|
19627
|
+
const checkCounter = yield* make$42(0);
|
|
19628
|
+
const lastHealthyOrder = yield* make$42(0);
|
|
19629
|
+
const deadConnectorRef = yield* make$45({
|
|
18200
19630
|
streak: null,
|
|
18201
19631
|
restartAfterMillis: toMillis(DEAD_CONNECTOR_RESTART_AFTER),
|
|
18202
19632
|
restartOrder: 0
|
|
@@ -18242,13 +19672,13 @@ const make$5 = gen(function* () {
|
|
|
18242
19672
|
exitNode
|
|
18243
19673
|
};
|
|
18244
19674
|
});
|
|
18245
|
-
const isLatest = (order) => get$
|
|
19675
|
+
const isLatest = (order) => get$2(latestRef).pipe(map$1((latest) => isNone(latest) || latest.value.order <= order));
|
|
18246
19676
|
const restartDeadConnector = fnUntraced$1(function* (facts, result, order) {
|
|
18247
19677
|
const now = yield* currentTimeMillis;
|
|
18248
19678
|
const { connector } = facts;
|
|
18249
19679
|
const dead = result.status === "unreachable" && result.cause === "no_connector" && connector !== null && (connector.readyConnections ?? 0) > 0 ? connector : null;
|
|
18250
19680
|
return yield* modifyEffect(deadConnectorRef, (current) => gen(function* () {
|
|
18251
|
-
const healthy = yield* get$
|
|
19681
|
+
const healthy = yield* get$2(lastHealthyOrder);
|
|
18252
19682
|
const state = {
|
|
18253
19683
|
streak: current.streak && current.streak.order > healthy ? current.streak : null,
|
|
18254
19684
|
restartAfterMillis: current.restartOrder > healthy ? current.restartAfterMillis : toMillis(DEAD_CONNECTOR_RESTART_AFTER),
|
|
@@ -18277,7 +19707,7 @@ const make$5 = gen(function* () {
|
|
|
18277
19707
|
const streakOrder = state.streak.order;
|
|
18278
19708
|
const stillDead = gen(function* () {
|
|
18279
19709
|
if (!(yield* isLatest(order))) return false;
|
|
18280
|
-
return (yield* get$
|
|
19710
|
+
return (yield* get$2(lastHealthyOrder)) < streakOrder;
|
|
18281
19711
|
});
|
|
18282
19712
|
if (!(yield* runtime.restartConnector(dead.pid, stillDead))) return [null, state];
|
|
18283
19713
|
return [null, {
|
|
@@ -18299,7 +19729,7 @@ const make$5 = gen(function* () {
|
|
|
18299
19729
|
if (previous === null) return result;
|
|
18300
19730
|
const started = yield* restartDeadConnector(facts, result, order);
|
|
18301
19731
|
if (started !== null) {
|
|
18302
|
-
const confirm = get$
|
|
19732
|
+
const confirm = get$4(deadConnectorRef).pipe(flatMap(({ streak }) => streak?.order === started.order ? suspend(() => check) : void_));
|
|
18303
19733
|
yield* sleep(started.after).pipe(andThen(confirm), forkIn(scope));
|
|
18304
19734
|
}
|
|
18305
19735
|
if (!match(previous, {
|
|
@@ -18314,7 +19744,7 @@ const make$5 = gen(function* () {
|
|
|
18314
19744
|
yield* sleep(RECHECK_INTERVAL).pipe(andThen(check), forever$1, forkScoped);
|
|
18315
19745
|
return ConnectReachability.of({
|
|
18316
19746
|
check,
|
|
18317
|
-
latest: get$
|
|
19747
|
+
latest: get$2(latestRef).pipe(map$1(map$3(({ result }) => result)))
|
|
18318
19748
|
});
|
|
18319
19749
|
});
|
|
18320
19750
|
const layer$5 = effect(ConnectReachability, make$5);
|
|
@@ -18324,7 +19754,7 @@ const layer$5 = effect(ConnectReachability, make$5);
|
|
|
18324
19754
|
* retry; the relay refused the other kinds. The description is safe to show:
|
|
18325
19755
|
* it carries the relay's own explanation and trace ID, never request details.
|
|
18326
19756
|
*/
|
|
18327
|
-
var RelayRequestError = class extends TaggedError()("RelayRequestError", {
|
|
19757
|
+
var RelayRequestError = class extends TaggedError$1()("RelayRequestError", {
|
|
18328
19758
|
rejection: Literals([
|
|
18329
19759
|
"unauthorized",
|
|
18330
19760
|
"forbidden",
|
|
@@ -18531,7 +19961,7 @@ const readSkillDirectory = fn("skillDirectory.readSkillDirectory")(function* (sk
|
|
|
18531
19961
|
});
|
|
18532
19962
|
const isSymlink = (target) => FileSystem.pipe(flatMap((fileSystem) => fileSystem.readLink(target)), as(true), orElseSucceed(() => false));
|
|
18533
19963
|
/** A skill linked to a checkout is the user's; replacing it would discard the link. */
|
|
18534
|
-
var LinkedSkillDirectory = class extends TaggedError
|
|
19964
|
+
var LinkedSkillDirectory = class extends TaggedError("LinkedSkillDirectory") {};
|
|
18535
19965
|
/**
|
|
18536
19966
|
* Move what the reader skips (`.git`, `node_modules`, `.venv`, dotfiles) from
|
|
18537
19967
|
* the old directory into the staged one. Those never reach the hub, so
|
|
@@ -18783,7 +20213,7 @@ function shouldRemoveMirror(input) {
|
|
|
18783
20213
|
const HUB_LINK_SECRET_NAME = "hub-link";
|
|
18784
20214
|
var HubLink = class extends Service()("@p4code/cli/sync/HubLink") {};
|
|
18785
20215
|
/** The submitted URL or token could not make a usable link. */
|
|
18786
|
-
var InvalidHubLink = class extends TaggedError()("InvalidHubLink", { detail: String$1 }) {
|
|
20216
|
+
var InvalidHubLink = class extends TaggedError$1()("InvalidHubLink", { detail: String$1 }) {
|
|
18787
20217
|
get message() {
|
|
18788
20218
|
return this.detail;
|
|
18789
20219
|
}
|
|
@@ -18927,13 +20357,13 @@ const HUB_REQUEST_TIMEOUT_MS = 15e3;
|
|
|
18927
20357
|
* Distinct from a conflict: this says nothing about who won, only that we do
|
|
18928
20358
|
* not know. A sync that hits this leaves the disk exactly as it found it.
|
|
18929
20359
|
*/
|
|
18930
|
-
var HubUnavailable = class extends TaggedError
|
|
20360
|
+
var HubUnavailable = class extends TaggedError("HubUnavailable") {};
|
|
18931
20361
|
/** The compare-and-set lost. `current` is absent when the row is gone. */
|
|
18932
|
-
var HubAssetConflict = class extends TaggedError
|
|
20362
|
+
var HubAssetConflict = class extends TaggedError("HubAssetConflict") {};
|
|
18933
20363
|
/** The hub refused the write as invalid, for example over the size limit. Retrying cannot help. */
|
|
18934
|
-
var HubAssetRejected = class extends TaggedError
|
|
20364
|
+
var HubAssetRejected = class extends TaggedError("HubAssetRejected") {};
|
|
18935
20365
|
/** No hub is configured on this server, so there is nothing to talk to. */
|
|
18936
|
-
var HubNotConfigured = class extends TaggedError
|
|
20366
|
+
var HubNotConfigured = class extends TaggedError("HubNotConfigured") {};
|
|
18937
20367
|
const AssetListPage = Struct({ assets: ArraySchema(AgentAsset) });
|
|
18938
20368
|
const ConflictBody = Struct({ current: NullOr(AgentAsset) });
|
|
18939
20369
|
const decodeAssetListPage = decodeUnknownEffect(AssetListPage);
|
|
@@ -18981,7 +20411,7 @@ const make$3 = gen(function* () {
|
|
|
18981
20411
|
const query = kind === void 0 ? "" : `?kind=${encodeURIComponent(kind)}`;
|
|
18982
20412
|
const url = `${settings.baseUrl}/assets${query}`;
|
|
18983
20413
|
const last = lastLists.get(url);
|
|
18984
|
-
const request = get$
|
|
20414
|
+
const request = get$1(url);
|
|
18985
20415
|
const response = yield* send("list", settings, last === void 0 ? request : setHeader$1(request, "if-none-match", last.etag));
|
|
18986
20416
|
if (response.status === 304 && last !== void 0) return last.assets;
|
|
18987
20417
|
if (response.status !== 200) return yield* new HubUnavailable({
|
|
@@ -19932,8 +21362,8 @@ const EMPTY_REPORT = {
|
|
|
19932
21362
|
unavailable: null
|
|
19933
21363
|
};
|
|
19934
21364
|
/** A chosen resolution could not be applied; `detail` is shown to the user. */
|
|
19935
|
-
var AssetResolveFailed = class extends TaggedError
|
|
19936
|
-
var AssetUnpublishFailed = class extends TaggedError
|
|
21365
|
+
var AssetResolveFailed = class extends TaggedError("AssetResolveFailed") {};
|
|
21366
|
+
var AssetUnpublishFailed = class extends TaggedError("AssetUnpublishFailed") {};
|
|
19937
21367
|
const isAssetName = is(AgentAssetName);
|
|
19938
21368
|
const describeHubFailure = (label, error) => {
|
|
19939
21369
|
switch (error._tag) {
|
|
@@ -19949,7 +21379,7 @@ const make$2 = gen(function* () {
|
|
|
19949
21379
|
const link = yield* HubLink;
|
|
19950
21380
|
const config = yield* ServerConfig;
|
|
19951
21381
|
const settings = yield* ServerSettingsService;
|
|
19952
|
-
const
|
|
21382
|
+
const random = yield* SecureRandom;
|
|
19953
21383
|
const path = yield* Path;
|
|
19954
21384
|
const sharedMemoryRoot = path.join(NodeOS.homedir(), ".agent-memory");
|
|
19955
21385
|
const services = yield* context();
|
|
@@ -20039,7 +21469,7 @@ const make$2 = gen(function* () {
|
|
|
20039
21469
|
read: () => settings.getSettings.pipe(map$1((current) => readMcpServerAssets(current.mcpServers)), orDie),
|
|
20040
21470
|
write: ({ name, files }) => gen(function* () {
|
|
20041
21471
|
const current = yield* settings.getSettings;
|
|
20042
|
-
const newId = McpServerId.make(yield*
|
|
21472
|
+
const newId = McpServerId.make(yield* random.uuidV4());
|
|
20043
21473
|
const patch = mcpServerWritePatch({
|
|
20044
21474
|
servers: current.mcpServers,
|
|
20045
21475
|
name,
|
|
@@ -20314,28 +21744,28 @@ const make$2 = gen(function* () {
|
|
|
20314
21744
|
refused,
|
|
20315
21745
|
unavailable: null
|
|
20316
21746
|
};
|
|
20317
|
-
}).pipe(provide
|
|
21747
|
+
}).pipe(provide(services), catchCause((cause) => logWarning("asset sync failed", { cause }).pipe(as(EMPTY_REPORT))));
|
|
20318
21748
|
const forget = writeSkillManifest(manifestPath, {
|
|
20319
21749
|
version: 1,
|
|
20320
21750
|
directories: {}
|
|
20321
|
-
}).pipe(andThen(sync$2(() => rejectedWrites.clear())), provide
|
|
21751
|
+
}).pipe(andThen(sync$2(() => rejectedWrites.clear())), provide(services), orDie);
|
|
20322
21752
|
const resolve = (input) => gen(function* () {
|
|
20323
|
-
const fail$
|
|
21753
|
+
const fail$3 = (detail) => fail(new AssetResolveFailed({ detail }));
|
|
20324
21754
|
const state = yield* link.current;
|
|
20325
|
-
if (isNone(state.settings)) return yield* fail$
|
|
21755
|
+
if (isNone(state.settings)) return yield* fail$3("No hub is linked.");
|
|
20326
21756
|
const driver = drivers.find((entry) => entry.kind === input.kind);
|
|
20327
|
-
if (driver === void 0) return yield* fail$
|
|
21757
|
+
if (driver === void 0) return yield* fail$3(`${input.kind} assets do not sync.`);
|
|
20328
21758
|
const { root } = yield* driver.resolveRoot;
|
|
20329
|
-
if (root === null) return yield* fail$
|
|
21759
|
+
if (root === null) return yield* fail$3(`This machine has no folder for ${input.kind} assets.`);
|
|
20330
21760
|
const hub = yield* client.list(input.kind).pipe(mapError(() => new AssetResolveFailed({ detail: "The hub is unreachable." })));
|
|
20331
21761
|
const hubAsset = hub.find((asset) => asset.name === input.name);
|
|
20332
21762
|
const local = yield* driver.read(root);
|
|
20333
|
-
if (local.refused.some((entry) => entry.name === input.name)) return yield* fail$
|
|
21763
|
+
if (local.refused.some((entry) => entry.name === input.name)) return yield* fail$3("The local copy cannot be synced, so there is no side to pick.");
|
|
20334
21764
|
const localAsset = local.skills.find((asset) => asset.name === input.name);
|
|
20335
21765
|
const previous = entriesFor(yield* readSkillManifest(manifestPath), root).find((entry) => entry.name === input.name);
|
|
20336
21766
|
let settled;
|
|
20337
21767
|
if (input.resolution === "keep-local") {
|
|
20338
|
-
if (localAsset === void 0) return yield* fail$
|
|
21768
|
+
if (localAsset === void 0) return yield* fail$3("There is no local copy to keep.");
|
|
20339
21769
|
settled = yield* client.write({
|
|
20340
21770
|
kind: input.kind,
|
|
20341
21771
|
name: input.name,
|
|
@@ -20343,12 +21773,12 @@ const make$2 = gen(function* () {
|
|
|
20343
21773
|
...hubAsset === void 0 ? {} : { expectedVersion: hubAsset.version }
|
|
20344
21774
|
}).pipe(mapError((error) => new AssetResolveFailed({ detail: error._tag === "HubAssetConflict" ? "The hub changed again. Sync and try once more." : "The hub is unreachable." })));
|
|
20345
21775
|
} else {
|
|
20346
|
-
if (hubAsset === void 0) return yield* fail$
|
|
21776
|
+
if (hubAsset === void 0) return yield* fail$3("The hub no longer has this asset.");
|
|
20347
21777
|
if ((yield* driver.write({
|
|
20348
21778
|
root,
|
|
20349
21779
|
name: input.name,
|
|
20350
21780
|
files: hubAsset.files
|
|
20351
|
-
})) !== "written") return yield* fail$
|
|
21781
|
+
})) !== "written") return yield* fail$3("The hub copy could not be written here.");
|
|
20352
21782
|
yield* mirrorWrite({
|
|
20353
21783
|
driver,
|
|
20354
21784
|
name: input.name,
|
|
@@ -20364,17 +21794,17 @@ const make$2 = gen(function* () {
|
|
|
20364
21794
|
version: settled.version,
|
|
20365
21795
|
digest: digestSkillFiles(settled.files)
|
|
20366
21796
|
}])).pipe(mapError(() => new AssetResolveFailed({ detail: "The sync record could not be saved." })));
|
|
20367
|
-
}).pipe(provide
|
|
21797
|
+
}).pipe(provide(services));
|
|
20368
21798
|
const unpublish = (input) => gen(function* () {
|
|
20369
21799
|
const label = `${input.kind}:${input.name}`;
|
|
20370
|
-
const fail$
|
|
20371
|
-
if (!isAssetName(input.name)) return yield* fail$
|
|
21800
|
+
const fail$2 = (detail) => fail(new AssetUnpublishFailed({ detail }));
|
|
21801
|
+
if (!isAssetName(input.name)) return yield* fail$2(`${input.name} is not an asset name.`);
|
|
20372
21802
|
const state = yield* link.current;
|
|
20373
|
-
if (isNone(state.settings)) return yield* fail$
|
|
21803
|
+
if (isNone(state.settings)) return yield* fail$2("No hub is linked. Run `p4c hub connect`.");
|
|
20374
21804
|
const driver = drivers.find((entry) => entry.kind === input.kind);
|
|
20375
|
-
if (driver === void 0) return yield* fail$
|
|
21805
|
+
if (driver === void 0) return yield* fail$2(`${input.kind} assets do not sync.`);
|
|
20376
21806
|
const { root } = yield* driver.resolveRoot;
|
|
20377
|
-
if (root === null) return yield* fail$
|
|
21807
|
+
if (root === null) return yield* fail$2(`This machine has no folder for ${input.kind} assets.`);
|
|
20378
21808
|
const hub = yield* client.list(input.kind).pipe(mapError((error) => new AssetUnpublishFailed({ detail: describeHubFailure(label, error) })));
|
|
20379
21809
|
const hubAsset = hub.find((asset) => asset.name === input.name);
|
|
20380
21810
|
const local = yield* driver.read(root);
|
|
@@ -20386,10 +21816,10 @@ const make$2 = gen(function* () {
|
|
|
20386
21816
|
directories: {}
|
|
20387
21817
|
}));
|
|
20388
21818
|
const entry = entriesFor(yield* ownedManifest, root).find((row) => row.name === input.name);
|
|
20389
|
-
if (local.refused.some((row) => row.name === input.name)) return yield* fail$
|
|
20390
|
-
if (hubAsset === void 0 && entry === void 0) return yield* fail$
|
|
21819
|
+
if (local.refused.some((row) => row.name === input.name)) return yield* fail$2(`This machine's copy of ${label} cannot be synced, so it is not removed. Delete it by hand first.`);
|
|
21820
|
+
if (hubAsset === void 0 && entry === void 0) return yield* fail$2(localAsset === void 0 ? `No ${input.kind} named ${input.name} is on the hub or synced to this machine.` : `${label} is not on the hub. This machine's copy was never synced, so it is left alone.`);
|
|
20391
21821
|
const localDigest = localAsset === void 0 ? void 0 : digestSkillFiles(localAsset.files);
|
|
20392
|
-
if (localDigest !== void 0 && localDigest !== entry?.digest && (hubAsset === void 0 || localDigest !== digestSkillFiles(hubAsset.files))) return yield* fail$
|
|
21822
|
+
if (localDigest !== void 0 && localDigest !== entry?.digest && (hubAsset === void 0 || localDigest !== digestSkillFiles(hubAsset.files))) return yield* fail$2(`This machine's copy of ${label} has changes the hub does not. Run \`p4c hub sync\`, or delete the copy here, then try again.`);
|
|
20393
21823
|
if (hubAsset !== void 0) yield* client.remove({
|
|
20394
21824
|
kind: input.kind,
|
|
20395
21825
|
name: input.name,
|
|
@@ -20415,7 +21845,7 @@ const make$2 = gen(function* () {
|
|
|
20415
21845
|
digest: localDigest
|
|
20416
21846
|
}])).pipe(ignore);
|
|
20417
21847
|
}
|
|
20418
|
-
return yield* fail$
|
|
21848
|
+
return yield* fail$2(`${label} was removed from the hub, but this machine's copy could not be deleted. Delete it by hand.`);
|
|
20419
21849
|
}
|
|
20420
21850
|
}
|
|
20421
21851
|
const latest = yield* ownedManifest;
|
|
@@ -20424,7 +21854,7 @@ const make$2 = gen(function* () {
|
|
|
20424
21854
|
removedFromHub: hubAsset !== void 0,
|
|
20425
21855
|
removedLocally: localAsset !== void 0
|
|
20426
21856
|
};
|
|
20427
|
-
}).pipe(provide
|
|
21857
|
+
}).pipe(provide(services));
|
|
20428
21858
|
return {
|
|
20429
21859
|
run,
|
|
20430
21860
|
forget,
|
|
@@ -20434,13 +21864,13 @@ const make$2 = gen(function* () {
|
|
|
20434
21864
|
});
|
|
20435
21865
|
const layer$2 = effect(AssetSync, make$2);
|
|
20436
21866
|
// src/serverOwnership.ts
|
|
20437
|
-
var ServerAlreadyRunningError = class extends TaggedError()("ServerAlreadyRunningError", { stateDir: String$1 }) {
|
|
21867
|
+
var ServerAlreadyRunningError = class extends TaggedError$1()("ServerAlreadyRunningError", { stateDir: String$1 }) {
|
|
20438
21868
|
[errorExitCode] = 78;
|
|
20439
21869
|
get message() {
|
|
20440
21870
|
return `A P4 Code server already owns ${this.stateDir}. Stop that server, or use a separate P4 home and pair with it, then retry. No server was stopped. server-owner.sqlite is the ownership lock; do not delete it while a server is running.`;
|
|
20441
21871
|
}
|
|
20442
21872
|
};
|
|
20443
|
-
var ServerOwnershipError = class extends TaggedError()("ServerOwnershipError", {
|
|
21873
|
+
var ServerOwnershipError = class extends TaggedError$1()("ServerOwnershipError", {
|
|
20444
21874
|
stateDir: String$1,
|
|
20445
21875
|
cause: Defect()
|
|
20446
21876
|
}) {
|
|
@@ -20491,7 +21921,7 @@ const legacyOwnerIsLive = fn("legacyOwnerIsLive")(function* (state) {
|
|
|
20491
21921
|
*/
|
|
20492
21922
|
const acquireServerOwnership = fn("acquireServerOwnership")(function* (statePath) {
|
|
20493
21923
|
const stateDir = NodePath.dirname(statePath);
|
|
20494
|
-
const ownerId = yield* (yield*
|
|
21924
|
+
const ownerId = yield* (yield* SecureRandom).uuidV4().pipe(mapError((cause) => new ServerOwnershipError({
|
|
20495
21925
|
stateDir,
|
|
20496
21926
|
cause
|
|
20497
21927
|
})));
|
|
@@ -20663,7 +22093,7 @@ const readThemeFileGuarded = (filePath, maxBytes) => {
|
|
|
20663
22093
|
if (read <= 0) break;
|
|
20664
22094
|
offset += read;
|
|
20665
22095
|
}
|
|
20666
|
-
return contents.subarray(0, offset)
|
|
22096
|
+
return new TextDecoder().decode(contents.subarray(0, offset));
|
|
20667
22097
|
} catch {
|
|
20668
22098
|
return null;
|
|
20669
22099
|
} finally {
|
|
@@ -20750,7 +22180,7 @@ const make$1 = gen(function* () {
|
|
|
20750
22180
|
* colors.
|
|
20751
22181
|
*/
|
|
20752
22182
|
const changes = yield* sliding$1(1);
|
|
20753
|
-
const published = yield* make$
|
|
22183
|
+
const published = yield* make$42({
|
|
20754
22184
|
seq: 0,
|
|
20755
22185
|
themes: []
|
|
20756
22186
|
});
|
|
@@ -20761,8 +22191,8 @@ const make$1 = gen(function* () {
|
|
|
20761
22191
|
* sequence -- which the subscriber filter, ordering publications rather than
|
|
20762
22192
|
* observations, could not then drop.
|
|
20763
22193
|
*/
|
|
20764
|
-
const refreshSemaphore = yield* make$
|
|
20765
|
-
const watcherScope = yield* make$
|
|
22194
|
+
const refreshSemaphore = yield* make$39(1);
|
|
22195
|
+
const watcherScope = yield* make$31("sequential");
|
|
20766
22196
|
yield* addFinalizer$1(() => close(watcherScope, void_$1));
|
|
20767
22197
|
const refresh = refreshSemaphore.withPermits(1)(gen(function* () {
|
|
20768
22198
|
const themes = yield* readPublishedThemes(environmentThemesDir).pipe(provideService(FileSystem, fs));
|
|
@@ -20787,14 +22217,14 @@ const make$1 = gen(function* () {
|
|
|
20787
22217
|
return unwrap$1(gen(function* () {
|
|
20788
22218
|
const subscription = yield* subscribe(changes);
|
|
20789
22219
|
const snapshot = yield* refresh;
|
|
20790
|
-
return concat(make$
|
|
22220
|
+
return concat$1(make$40(snapshot.themes), fromSubscription(subscription).pipe(filter$1((update) => update.seq > snapshot.seq), map$4((update) => update.themes)));
|
|
20791
22221
|
}));
|
|
20792
22222
|
}
|
|
20793
22223
|
};
|
|
20794
22224
|
});
|
|
20795
22225
|
const layer$1 = effect(EnvironmentThemeService, make$1);
|
|
20796
22226
|
// src/diagnostics/TraceDiagnostics.ts
|
|
20797
|
-
var TraceFileReadError = class extends TaggedError()("TraceFileReadError", {
|
|
22227
|
+
var TraceFileReadError = class extends TaggedError$1()("TraceFileReadError", {
|
|
20798
22228
|
traceFilePath: String$1,
|
|
20799
22229
|
causeTag: String$1,
|
|
20800
22230
|
cause: Defect()
|
|
@@ -20826,7 +22256,7 @@ function unixNanoToDateTime(value) {
|
|
|
20826
22256
|
if (!text) return null;
|
|
20827
22257
|
try {
|
|
20828
22258
|
const millis = Number(BigInt(text) / 1000000n);
|
|
20829
|
-
return getOrNull(make$
|
|
22259
|
+
return getOrNull(make$32(millis));
|
|
20830
22260
|
} catch {
|
|
20831
22261
|
return null;
|
|
20832
22262
|
}
|
|
@@ -21087,6 +22517,6 @@ function readTraceDiagnostics(options) {
|
|
|
21087
22517
|
return yield* (yield* TraceDiagnostics).read(options);
|
|
21088
22518
|
});
|
|
21089
22519
|
}
|
|
21090
|
-
export {
|
|
22520
|
+
export { setCliDesiredCloudLink as $, serverAuthCredentialReason as $t, layer$6 as A, entriesToAttributes as An, isLoopbackHost as At, deviceAuthorizationLogin as B, consolePretty as Bn, ServerAuthCloudMintPublicKeyMissingError as Bt, shouldRetryRelayRequest as C, resolveBaseDir as Cn, clearPersistedServerRuntimeState as Ct, CloudManagedEndpointRuntime as D, reclaimSpaceShortfall as Dn, buildPairingUrl as Dt, layer$5 as E, reclaimFiles as En, readPersistedServerRuntimeState as Et, readTailscaleSshEnabled as F, make$25 as Fn, EnvironmentAuth as Ft, ExternalLauncher as G, log as Gn, isBrowserCookieCredential as Gt, hasCloudPublicConfig as H, make$26 as Hn, ServerAuthLinkedCloudAccountMissingError as Ht, readTailscaleStatus as I, getCurrentVersion as In, INTERNAL_ADMINISTRATIVE_BOOTSTRAP_SUBJECT as It, import_websocket_server as J, appendPreResponseHandlerUnsafe as Jn, isServerAuthInvalidRequestError as Jt, layer$8 as K, warn as Kn, isServerAuthCredentialError as Kt, CloudCliAuthorizationError as L, errorExitCode as Ln, ServerAuthCloudHealthJwtSigningError as Lt, disableTailscaleServe as M, serviceNameUnsafe as Mn, issueHeadlessServeAccessInfo as Mt, ensureTailscaleServe as N, unknownToAttributeValue as Nn, renderTerminalQrCode as Nt, RELAY_CLIENT_LOG_FILE as O, runRequestedReclaim as On, formatHeadlessServeOutput as Ot, probeTailscaleHttpsEndpoint as P, layerFlusher as Pn, resolveHeadlessConnectionString as Pt, readCliDesiredLinkMode as Q, selectRequestCredential as Qt, CloudCliTokenManager as R, errorReported as Rn, ServerAuthCloudLinkJwtSigningError as Rt, relayRequestError as S, fixPath as Sn, layer$13 as St, formatReachabilityFailure as T, layer$20 as Tn, makePersistedServerRuntimeState as Tt, relayUrlConfig as U, tracerLogger as Un, ServerAuthLinkedCloudAccountReadError as Ut, layer$7 as V, layer$22 as Vn, ServerAuthCloudRelayIssuerMissingError as Vt, isSecureRelayUrl as W, error as Wn, ServerAuthLinkedCloudAccountVerificationError as Wt, dropRevokedCloudLink as X, layerRuntime as Xt, clearPersistedCloudLink as Y, layer$14 as Yt, readCliDesiredCloudLink as Z, parseBearerToken as Zt, layer$4 as _, deriveAuthClientMetadata as _n, LINKED_ENVIRONMENTS_OFF as _t, EnvironmentThemeService as a, DESKTOP_RENDERER_ORIGINS as an, APPARMOR_PROFILE as at, layerServerRelayBroker as b, parseOAuthScope as bn, isPrivateNetworkHost as bt, readPublishedThemes as c, DPOP_REPLAY_MARKER_PREFIX as cn, NO_SANDBOX_SIGNATURE as ct, projectMutationOperation as d, SessionStore as dn, PreviewBrowserSandboxError as dt, serverAuthDpopFailureReason as en, RelayClientTracer as et, acquireServerOwnership as f, fromSecret as fn, SETUP_SUBCOMMAND as ft, HubLink as g, base64UrlEncode as gn, sandboxDisabled as gt, layer$3 as h, base64UrlDecodeUtf8 as hn, sandboxBlocked as ht, toRotatedTracePaths as i, make$15 as in, layerCloudflared as it, buildTailscaleHttpsBaseUrl as j, fromConfig as jn, isWildcardHost as jt, isRetryableManagedEndpointRuntimeStatus as k, make$23 as kn, formatHostForUrl as kt, readThemeFileGuarded as l, verifyRequestDpopProof as ln, PreviewBrowserLibrariesError as lt, layer$2 as m, PairingGrantStore as mn, missingLibraries as mt, readTraceDiagnostics as n, layerConfig as nn, withRelayClientTracing as nt, MAX_THEME_FILE_BYTES as o, browserApiCorsAllowedHeaders as on, APPARMOR_PROFILE_PATH as ot, AssetSync as p, make$17 as pn, diagnoseLaunchFailure as pt, layer$9 as q, appendPreResponseHandler as qn, isServerAuthInternalError as qt, streamTraceFileLines as r, fromRecord as rn, RelayClient as rt, layer$1 as s, browserApiCorsAllowedMethods as sn, DEBIAN_PACKAGES as st, layer as t, serverAuthInvalidRequestReason as tn, withLocalTracing as tt, mutateProjectWithClone as u, requestUrl as un, PreviewBrowserRootError as ut, writeSkillDirectory as v, timingSafeEqualBase64Url as vn, PeerLinks as vt, ConnectReachability as w, DatabaseMaintenance as wn, isProcessAlive as wt, filterRelayResponse as x, expandHomePath as xn, isTailnetHost as xt, layerHeadlessRelayClient as y, encodeOAuthScope as yn, layer$12 as yt, CloudCliTokenManagerError as z, makeRunMain as zn, ServerAuthCloudMintJwtSigningError as zt };
|
|
21091
22521
|
|
|
21092
|
-
//# sourceMappingURL=TraceDiagnostics-
|
|
22522
|
+
//# sourceMappingURL=TraceDiagnostics-DY_cYrzB.mjs.map
|