decocms 4.267.1 → 4.267.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{AlertCircle-CJ9wwmWU.js → AlertCircle-Bh5eyk7E.js} +1 -1
- package/dist/client/assets/{AreaChart-J-_KGvHx.js → AreaChart-CdgOhmeV.js} +1 -1
- package/dist/client/assets/{ArrowLeft-DiMYzkwG.js → ArrowLeft-DPAD_bDB.js} +1 -1
- package/dist/client/assets/{ArrowUp-O_ly97kJ.js → ArrowUp-CsQExObW.js} +1 -1
- package/dist/client/assets/{Check-D6SWnzv9.js → Check-C-fNWBtu.js} +1 -1
- package/dist/client/assets/{CheckCircle-HeUwwC_D.js → CheckCircle-CFZsf0nR.js} +1 -1
- package/dist/client/assets/{ChevronDown-CYw-1MyP.js → ChevronDown-C_fnroAG.js} +1 -1
- package/dist/client/assets/{ChevronRight-Dtf8gLIi.js → ChevronRight-l1PG_VwT.js} +1 -1
- package/dist/client/assets/{ChevronSelectorVertical-D4x6hSSX.js → ChevronSelectorVertical-BzYadQiY.js} +1 -1
- package/dist/client/assets/{ChevronUp-BFVqUCEa.js → ChevronUp-CPK7Ojor.js} +1 -1
- package/dist/client/assets/{Copy01-CDNaKgXg.js → Copy01-BlZkp5Ns.js} +1 -1
- package/dist/client/assets/{CreditCard01-DmiQCmiA.js → CreditCard01-iENL0AXn.js} +1 -1
- package/dist/client/assets/{DotsVertical-DAsyEFvH.js → DotsVertical-DxxkMkoH.js} +1 -1
- package/dist/client/assets/{Download01-3bywBEMV.js → Download01-BPK0JJ5z.js} +1 -1
- package/dist/client/assets/{Eye-BUR8MG0Y.js → Eye-CdCJO-3W.js} +1 -1
- package/dist/client/assets/{FilterLines-DnBTn6f_.js → FilterLines-Bmj7v-ot.js} +1 -1
- package/dist/client/assets/{Globe01-D0TDsB3a.js → Globe01--qhlOJ6B.js} +1 -1
- package/dist/client/assets/{Globe04-CZkEyVz4.js → Globe04-Dh6q8Mvj.js} +1 -1
- package/dist/client/assets/{HardDrive-CYJDZOd9.js → HardDrive-BawAldEC.js} +1 -1
- package/dist/client/assets/{Key01-CfE_26Cu.js → Key01-CMLRnJx8.js} +1 -1
- package/dist/client/assets/{LinkExternal01-N38kQz3j.js → LinkExternal01-CMMKWx57.js} +1 -1
- package/dist/client/assets/{LockUnlocked01-CtKtOau7.js → LockUnlocked01-C1dDmFUo.js} +1 -1
- package/dist/client/assets/{LogOut01-DKWRdcnN.js → LogOut01-Nm23XK3h.js} +1 -1
- package/dist/client/assets/{Monitor01-Dms_jXQP.js → Monitor01-AEemTAZ1.js} +1 -1
- package/dist/client/assets/{Palette-C8ZuaxLo.js → Palette-DNi9VW60.js} +1 -1
- package/dist/client/assets/{Play-C54bY5DK.js → Play-Dau0w8ZO.js} +1 -1
- package/dist/client/assets/{Plus-EqGyKjJh.js → Plus-C5T5cM4h.js} +1 -1
- package/dist/client/assets/{SearchLg-C3tJwOtw.js → SearchLg-DQlLXzHL.js} +1 -1
- package/dist/client/assets/{SearchMd-BkaIlVfN.js → SearchMd-B-NlJ1bi.js} +1 -1
- package/dist/client/assets/{Settings02-Bn5WdDiE.js → Settings02-CwVN1BRS.js} +1 -1
- package/dist/client/assets/{Share07-uLIuLzK5.js → Share07-BlSD-Drt.js} +1 -1
- package/dist/client/assets/{Shield01-CTre_Wbt.js → Shield01-D5XDUf8t.js} +1 -1
- package/dist/client/assets/{Stars01-gJkndlGx.js → Stars01-ByJhyDpp.js} +1 -1
- package/dist/client/assets/{Stars02-H1qOq2Hl.js → Stars02-CmIErHU_.js} +1 -1
- package/dist/client/assets/{Sun-BCplJMqz.js → Sun-DIQ80bYw.js} +1 -1
- package/dist/client/assets/{SwitchHorizontal01-DJyPk3EJ.js → SwitchHorizontal01-Cl5Lv5iH.js} +1 -1
- package/dist/client/assets/{Tool01-C0Bsrct9.js → Tool01-DUx0fv2T.js} +1 -1
- package/dist/client/assets/{Tool02-jO3cHmz2.js → Tool02-BE-ccYln.js} +1 -1
- package/dist/client/assets/{Trash01-C4WHkmHO.js → Trash01-C7rboEHp.js} +1 -1
- package/dist/client/assets/{TrendUp01-BU2HMoKo.js → TrendUp01-4FoplyO7.js} +1 -1
- package/dist/client/assets/{Upload01-R1Ewkrvb.js → Upload01-DjoVo2v3.js} +1 -1
- package/dist/client/assets/{User01-2f2qWx6r.js → User01-BR90VfhO.js} +1 -1
- package/dist/client/assets/{UserSquare-yd4ryQ0C.js → UserSquare-Dwd4DQOP.js} +1 -1
- package/dist/client/assets/{Users01-DBi1KuA6.js → Users01-BE1DUs4E.js} +1 -1
- package/dist/client/assets/{Users03-ySuakE9b.js → Users03-CeE8C-d7.js} +1 -1
- package/dist/client/assets/{XCircle-vXY6EmnO.js → XCircle-DqDyabCl.js} +1 -1
- package/dist/client/assets/{XClose-4W3i_kwZ.js → XClose-CyX_XSv6.js} +1 -1
- package/dist/client/assets/{YAxis-D8O-bwAN.js → YAxis-BxGZVgXn.js} +1 -1
- package/dist/client/assets/{Zap-DGpmQ2Zi.js → Zap-b89xcjwn.js} +1 -1
- package/dist/client/assets/{ZapSquare-DrsGt5pV.js → ZapSquare-Pv2XWcDI.js} +1 -1
- package/dist/client/assets/{access-gate-54YQZIe7.js → access-gate-DacPfb9U.js} +1 -1
- package/dist/client/assets/{agent-icon-BPvMo1Pj.js → agent-icon-CtJufrYT.js} +1 -1
- package/dist/client/assets/{agents-list-A4J2IB6w.js → agents-list-CeNW3qDw.js} +1 -1
- package/dist/client/assets/{ai-providers-8gOr0yRm.js → ai-providers-5Dcdw5qU.js} +1 -1
- package/dist/client/assets/{alert-Vhs6Ltkq.js → alert-2lkA4UzZ.js} +1 -1
- package/dist/client/assets/{alert-dialog-DYKPFY14.js → alert-dialog-BoAsOlul.js} +1 -1
- package/dist/client/assets/{api-keys-zuuq4fqZ.js → api-keys-Cj49m_uR.js} +1 -1
- package/dist/client/assets/{app-editor-C9LPJjBA.js → app-editor-TMsUVNlm.js} +1 -1
- package/dist/client/assets/{auth-Oh-sopr_.js → auth-BXopYCgq.js} +1 -1
- package/dist/client/assets/{auth-catchall-DkWnkS9E.js → auth-catchall-B0bKSImy.js} +1 -1
- package/dist/client/assets/{auth-entry-BWGic6mp.js → auth-entry-mVQq8sNe.js} +1 -1
- package/dist/client/assets/{auth-split-layout-h5D_6R5B.js → auth-split-layout-sVhvS-q9.js} +1 -1
- package/dist/client/assets/{authenticate-and-persist-oauth-DCneWr4S.js → authenticate-and-persist-oauth-ulRcvbLZ.js} +1 -1
- package/dist/client/assets/{automation-list-row-BrFWZND_.js → automation-list-row-CdzYLmNm.js} +1 -1
- package/dist/client/assets/{automation-runs-D_362Vzd.js → automation-runs-CyoL0OT8.js} +1 -1
- package/dist/client/assets/{automations-7ovzf1_n.js → automations-wKp2Kl_b.js} +1 -1
- package/dist/client/assets/{avatar-jOLcRw3-.js → avatar-8seM97b8.js} +1 -1
- package/dist/client/assets/{badge-IVfz4Ye4.js → badge-jrrFxN3_.js} +1 -1
- package/dist/client/assets/{block-document-ClJ5ERrh.js → block-document-BWmFVKc8.js} +1 -1
- package/dist/client/assets/{buckets-DjnIKswd.js → buckets-BumIoFpo.js} +1 -1
- package/dist/client/assets/{bulk-category-panel-9UlbAA3L.js → bulk-category-panel-BWiajq31.js} +1 -1
- package/dist/client/assets/{capability-load-error-Du_j_5c5.js → capability-load-error-DMXJVH0h.js} +1 -1
- package/dist/client/assets/{cards-DEHJJel1.js → cards-BIuzNDM7.js} +1 -1
- package/dist/client/assets/{category-editor-DzTwdhZs.js → category-editor-BdCOHsSR.js} +1 -1
- package/dist/client/assets/{chart-C6t22pIn.js → chart-kkq2bgBY.js} +1 -1
- package/dist/client/assets/{chat-context-DcdiZGES.js → chat-context-D4chPiQt.js} +1 -1
- package/dist/client/assets/{checkbox-Ct2iDcDN.js → checkbox-Dnt403I6.js} +1 -1
- package/dist/client/assets/{choose-editor-DJdxRTjH.js → choose-editor-CBEAn1ul.js} +1 -1
- package/dist/client/assets/{cli-auth-success-BPXHTaI9.js → cli-auth-success-DD_u66rV.js} +1 -1
- package/dist/client/assets/{collection-detail-D_-npsI8.js → collection-detail-Dpv36-Ki.js} +1 -1
- package/dist/client/assets/{collection-display-button-DOaJhx_I.js → collection-display-button-DFp9cQiu.js} +1 -1
- package/dist/client/assets/{collection-search-BQyWV-U9.js → collection-search-B30IDSnZ.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-LAJKgXA_.js → collection-table-wrapper-CG14_mEX.js} +1 -1
- package/dist/client/assets/{collection-tabs-3twtcsg_.js → collection-tabs-5yCqGK6s.js} +1 -1
- package/dist/client/assets/{command-_Kg6Y3bz.js → command-BkkmHFIO.js} +1 -1
- package/dist/client/assets/{commerce-onboarding-qIxqmKNe.js → commerce-onboarding-Dw8rs5k6.js} +1 -1
- package/dist/client/assets/{connect-CFsE1U1F.js → connect-N7BCQzS6.js} +1 -1
- package/dist/client/assets/{connection-C1FC6-dK.js → connection-BswRqtD2.js} +1 -1
- package/dist/client/assets/{connection-card-BwlT8_Hj.js → connection-card-BtjCr6O5.js} +1 -1
- package/dist/client/assets/{connection-detail-Guzp2CYD.js → connection-detail-CuzyLlZ-.js} +1 -1
- package/dist/client/assets/{connection-form-helpers-CS2czT_s.js → connection-form-helpers-DY1qYBUV.js} +1 -1
- package/dist/client/assets/{connections-DtQlGhuW.js → connections-2q0Qs_rp.js} +1 -1
- package/dist/client/assets/{decopilot-sse-pool-CRrEpueL.js → decopilot-sse-pool-C9seNiMP.js} +1 -1
- package/dist/client/assets/{dialog-CQ3kVG84.js → dialog-DZmDsmP_.js} +1 -1
- package/dist/client/assets/{domain-settings-BnyyU92-.js → domain-settings-SHrSqhGa.js} +1 -1
- package/dist/client/assets/{drawer-CwBCBxKC.js → drawer-BtPGjIk3.js} +1 -1
- package/dist/client/assets/{dropdown-menu-CV2Drnki.js → dropdown-menu-D04-Ikyq.js} +1 -1
- package/dist/client/assets/{empty-state-g7mQrC4G.js → empty-state-BKzqYQ6m.js} +1 -1
- package/dist/client/assets/{extract-connection-data-mDr9vDPM.js → extract-connection-data-CLCAoSbd.js} +1 -1
- package/dist/client/assets/{file-explorer-CQKLWA_i.js → file-explorer-DcdkH9N-.js} +1 -1
- package/dist/client/assets/{file-type-icon-wQhnHF5h.js → file-type-icon-Di3amUTj.js} +1 -1
- package/dist/client/assets/{form-DnxVTW4k.js → form-BuHQTvGF.js} +1 -1
- package/dist/client/assets/{general-CrbIPBEw.js → general-PU3-KTYp.js} +1 -1
- package/dist/client/assets/{github-repo-picker-DviAEfjQ.js → github-repo-picker-Bm_IgdMI.js} +1 -1
- package/dist/client/assets/{hooks-BVGAbABw.js → hooks-C4iyf31w.js} +1 -1
- package/dist/client/assets/{index-n_hKaK5i.js → index-B4VJanCn.js} +1 -1
- package/dist/client/assets/{index-BGxzIVA5.js → index-BWM9xKol.js} +1 -1
- package/dist/client/assets/{index-DFFqFRA_.js → index-C3LpEfG5.js} +1 -1
- package/dist/client/assets/{index-DGmZSxFg.js → index-CH2QJwMF.js} +1 -1
- package/dist/client/assets/{index-TmL3dv4s.js → index-CxTmBLCE.js} +1 -1
- package/dist/client/assets/{index-89I-FuJW.js → index-DP3cSVqr.js} +1 -1
- package/dist/client/assets/{index-S5P_Z59E.js → index-DWE4AWSk.js} +5 -5
- package/dist/client/assets/{index-B5t1W_FQ.js → index-Ds_uWlOe.js} +3 -3
- package/dist/client/assets/{index-BHQRv_8j.js → index-Dz1-uVCs.js} +1 -1
- package/dist/client/assets/{index-DiQD7hll.js → index-e2mgQvAh.js} +1 -1
- package/dist/client/assets/{index-redirect-o5Z3mkr1.js → index-redirect-BrUI5yEz.js} +1 -1
- package/dist/client/assets/{infra-billing-BSnRde9j.js → infra-billing-BaETBQJO.js} +1 -1
- package/dist/client/assets/{input-DTvM2_W3.js → input-DEouOEM4.js} +1 -1
- package/dist/client/assets/{integration-icon-DVRAyxbh.js → integration-icon-DvS6hHxI.js} +1 -1
- package/dist/client/assets/{invite-member-dialog-CQui3TBv.js → invite-member-dialog-BlFFHXQk.js} +1 -1
- package/dist/client/assets/{label-DDeSHuib.js → label-CE3-_9EQ.js} +1 -1
- package/dist/client/assets/{layout-Dqhq_mFg.js → layout-DW-NmD7W.js} +1 -1
- package/dist/client/assets/{login-By1qY5M7.js → login-BmYowdFi.js} +1 -1
- package/dist/client/assets/{mcp-oauth-DcXtY0av.js → mcp-oauth-Dbt9SYhY.js} +1 -1
- package/dist/client/assets/{members-DM0-Qu1r.js → members-BbMWilxg.js} +1 -1
- package/dist/client/assets/{monaco-editor-RDB4jCQm.js → monaco-editor-B317q7Ac.js} +1 -1
- package/dist/client/assets/{monitoring-stats-row-BzaptMZg.js → monitoring-stats-row-VtIm-QIa.js} +1 -1
- package/dist/client/assets/{multi-select-DI9QEXgP.js → multi-select-o90f6wd-.js} +1 -1
- package/dist/client/assets/{oauth-callback-C6dt3KtV.js → oauth-callback-OQKqByA1.js} +1 -1
- package/dist/client/assets/{oauth-callback-ai-provider-CY_oQnny.js → oauth-callback-ai-provider-BlghvLrE.js} +1 -1
- package/dist/client/assets/{onboarding-fCzXNSj-.js → onboarding-CrnIFAXa.js} +1 -1
- package/dist/client/assets/{org-layout-BmHA6s0U.js → org-layout-gGsmHstn.js} +1 -1
- package/dist/client/assets/{organization-choice-ry5PXUOi.js → organization-choice-BuIlGQZF.js} +1 -1
- package/dist/client/assets/{orgs-Dl8DYVQV.js → orgs-LrisCces.js} +1 -1
- package/dist/client/assets/{page-seo-form-DVq-ZF22.js → page-seo-form-CWOJ61uy.js} +1 -1
- package/dist/client/assets/{popover-BuQ2Aaif.js → popover-B2_mR6re.js} +1 -1
- package/dist/client/assets/{post-calendar-BMzUzcfy.js → post-calendar-BekZ24RM.js} +1 -1
- package/dist/client/assets/{post-editor-CzKyEr5v.js → post-editor-CidDiszY.js} +1 -1
- package/dist/client/assets/{primitives-CPpgwVn7.js → primitives-DhA_VJ7_.js} +1 -1
- package/dist/client/assets/{profile-DLz5em2n.js → profile-BQM9uoas.js} +1 -1
- package/dist/client/assets/{project-app-view-eia2rSV9.js → project-app-view-Be6gwZ7R.js} +1 -1
- package/dist/client/assets/record-editor-Csja9gIv.js +1 -0
- package/dist/client/assets/{redirect-editor-J6etNx4l.js → redirect-editor-BLDfNuvY.js} +1 -1
- package/dist/client/assets/registry-BR7iasWl.js +2 -0
- package/dist/client/assets/{registry-layout-Bpjz_W8Z.js → registry-layout-e3rHn9Aw.js} +1 -1
- package/dist/client/assets/{reports-wlYGmv6M.js → reports-DojtoZat.js} +1 -1
- package/dist/client/assets/{require-capability-Ctpmcphj.js → require-capability-d0zq3z2S.js} +1 -1
- package/dist/client/assets/{required-auth-layout-BF6_LYOJ.js → required-auth-layout-C_reFmtD.js} +1 -1
- package/dist/client/assets/{reset-password-DaYPVGP3.js → reset-password-CnTLnHKe.js} +1 -1
- package/dist/client/assets/{roles-DVLinAD5.js → roles-C3yuD9f4.js} +1 -1
- package/dist/client/assets/{search-input-QzmgF-65.js → search-input-COF_1sBU.js} +1 -1
- package/dist/client/assets/{secrets-BA90mxZe.js → secrets-BnPEgKYJ.js} +1 -1
- package/dist/client/assets/{sections-editor-DyRnyD9F.js → sections-editor-BAkmJiqf.js} +1 -1
- package/dist/client/assets/{select-BQ5nCEee.js → select-DCIBhUDV.js} +1 -1
- package/dist/client/assets/{select-model-JbZYj5EG.js → select-model-DbCVIOxU.js} +1 -1
- package/dist/client/assets/{self-tool-result-CURzAebA.js → self-tool-result-DSJu3K-X.js} +1 -1
- package/dist/client/assets/{seo-editor-Cmr3UiQB.js → seo-editor-zrcKeD6h.js} +1 -1
- package/dist/client/assets/{settings-layout-C6r9RR8M.js → settings-layout-J4DKx7QH.js} +1 -1
- package/dist/client/assets/{shell-controls-DakmqrxF.js → shell-controls-N8pawHxe.js} +1 -1
- package/dist/client/assets/{shell-layout-BU0mmxv0.js → shell-layout-B4uD5px4.js} +1 -1
- package/dist/client/assets/{spinner-B1bi2Hlr.js → spinner-g8HT-25A.js} +1 -1
- package/dist/client/assets/{sprints-bHejyMUl.js → sprints-DP-r2_-o.js} +1 -1
- package/dist/client/assets/{sso-ByHA8DiU.js → sso-C2-2G3_X.js} +1 -1
- package/dist/client/assets/{store-Tcmnulht.js → store-B8fwfamw.js} +1 -1
- package/dist/client/assets/store-registry-DRIsIXRG.js +2 -0
- package/dist/client/assets/{switch-INuPPcJm.js → switch-CDYIbA5A.js} +1 -1
- package/dist/client/assets/{synced-repos-DyM6z9S0.js → synced-repos-BcVFSgK-.js} +1 -1
- package/dist/client/assets/{tab-id-aVJM0RRI.js → tab-id-Ba-MZcEt.js} +1 -1
- package/dist/client/assets/{table-DBroxVLv.js → table-CKTJOTOn.js} +1 -1
- package/dist/client/assets/{tabs-XdPLLuDf.js → tabs-DFGtc0Jb.js} +1 -1
- package/dist/client/assets/{tasks-DGuFs9e4.js → tasks-BUoDVRCz.js} +1 -1
- package/dist/client/assets/{textarea-5HpnfzUp.js → textarea-DjZ4FeF-.js} +1 -1
- package/dist/client/assets/{toggle-group-B3IDMBf5.js → toggle-group-CylCYITU.js} +1 -1
- package/dist/client/assets/{toolbar-cAr6C3fn.js → toolbar-DzsOLMTt.js} +1 -1
- package/dist/client/assets/{track-CWwWdTHR.js → track-DbC9skEL.js} +1 -1
- package/dist/client/assets/{types-D3deRtLs.js → types-BtngBj2X.js} +1 -1
- package/dist/client/assets/{use-ai-providers-C98NxYyQ.js → use-ai-providers-DvUEyegR.js} +1 -1
- package/dist/client/assets/{use-api-keys-B9u4Fr5P.js → use-api-keys-B5VEMT0B.js} +1 -1
- package/dist/client/assets/{use-automations-BKiK1wBc.js → use-automations-ZILuN1hU.js} +1 -1
- package/dist/client/assets/{use-autosave-CdTPSZZO.js → use-autosave-DvO3ixq4.js} +1 -1
- package/dist/client/assets/{use-clock-tick-CLzUFIF8.js → use-clock-tick-AIAgVj5B.js} +1 -1
- package/dist/client/assets/{use-commerce-diagnostic-CMTBu61E.js → use-commerce-diagnostic-Bv5SzS_W.js} +1 -1
- package/dist/client/assets/{use-connection-awA-8uMM.js → use-connection-BVJIjJ4C.js} +1 -1
- package/dist/client/assets/{use-copy-BPhRUhgy.js → use-copy-TdRNlKZq.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-BSNLXy32.js → use-create-virtual-mcp-BMi0lmIc.js} +1 -1
- package/dist/client/assets/{use-debounced-autosave-CTZCql7-.js → use-debounced-autosave-CxIwvV_w.js} +1 -1
- package/dist/client/assets/{use-debounced-value-CiOTaiJR.js → use-debounced-value-B2kbD2pu.js} +1 -1
- package/dist/client/assets/{use-decopilot-events-CpcxDnb-.js → use-decopilot-events-DNqubiQn.js} +1 -1
- package/dist/client/assets/{use-delete-connection-Cw-NQEg7.js → use-delete-connection-BVp9x3KR.js} +1 -1
- package/dist/client/assets/{use-deployment-admin-DvHu61pX.js → use-deployment-admin-BASEqDiK.js} +1 -1
- package/dist/client/assets/{use-file-configs-ev_HC_0k.js → use-file-configs-JEp8kQGJ.js} +1 -1
- package/dist/client/assets/{use-infinite-scroll-DW4uVh_B.js → use-infinite-scroll-B6YIXqCg.js} +1 -1
- package/dist/client/assets/{use-join-requests-Ceh5l_AF.js → use-join-requests-PuT-TTys.js} +1 -1
- package/dist/client/assets/{use-mcp-client-BK6scNDB.js → use-mcp-client-Bj8K4eKE.js} +1 -1
- package/dist/client/assets/{use-mcp-tools-CHDrZXlN.js → use-mcp-tools-BiJWKd1X.js} +1 -1
- package/dist/client/assets/{use-members-Cf4d-2K4.js → use-members-WqPgSlhr.js} +1 -1
- package/dist/client/assets/{use-navigate-to-agent-BDGXR15r.js → use-navigate-to-agent-3A_qsfym.js} +1 -1
- package/dist/client/assets/{use-org-auth-client-B6AX8Fxp.js → use-org-auth-client-BXhdIN0j.js} +1 -1
- package/dist/client/assets/{use-org-repo-syncs-DcM8Zue8.js → use-org-repo-syncs-CkaNWi0w.js} +1 -1
- package/dist/client/assets/{use-org-sso-B4BxLz6S.js → use-org-sso-CdHOThJg.js} +1 -1
- package/dist/client/assets/{use-organization-roles-B-tgaD4w.js → use-organization-roles-D5zGbhvV.js} +1 -1
- package/dist/client/assets/{use-organization-settings-DcTpQwQj.js → use-organization-settings-Bg7k04lx.js} +1 -1
- package/dist/client/assets/{use-registry-connections-DDv0tqw6.js → use-registry-connections-B11hai6z.js} +1 -1
- package/dist/client/assets/{use-secrets-DzWNQ3oe.js → use-secrets-CLxvJlAK.js} +1 -1
- package/dist/client/assets/{use-section-preview-base-B33n4heT.js → use-section-preview-base-BKRRIZ-B.js} +1 -1
- package/dist/client/assets/{use-status-sounds-PaNHe7Xe.js → use-status-sounds-TaFIrZ2z.js} +1 -1
- package/dist/client/assets/{use-tags-CODnzIy0.js → use-tags-C9M3wQR3.js} +1 -1
- package/dist/client/assets/{use-task-board-items-CZPepz8K.js → use-task-board-items-DEOpHFlj.js} +1 -1
- package/dist/client/assets/{use-view-mode-Cxn9xSMG.js → use-view-mode-BSPEY1eM.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-DxufwI-o.js → use-virtual-mcp-BNiQL6RT.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-b8V4fpGD.js +1 -0
- package/dist/client/assets/useSuspenseInfiniteQuery-BpvFpoz3.js +1 -0
- package/dist/client/assets/{users-yCyg65TE.js → users-DdUBfPF6.js} +1 -1
- package/dist/client/assets/{variant-calendar-eApAo8VS.js → variant-calendar-B_0e579e.js} +1 -1
- package/dist/client/assets/{view-mode-toggle-VWjOvx06.js → view-mode-toggle-aFmZxylk.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +2 -2
- package/dist/server/server.js +2 -2
- package/package.json +1 -1
- package/dist/client/assets/record-editor-BIb_VdAY.js +0 -1
- package/dist/client/assets/registry-D15V5q_Q.js +0 -2
- package/dist/client/assets/store-registry-DjP-xgAD.js +0 -2
- package/dist/client/assets/useInfiniteQuery-C8bQb7en.js +0 -1
- package/dist/client/assets/useSuspenseInfiniteQuery-CYKDX-yI.js +0 -1
package/dist/server/cli.js
CHANGED
|
@@ -1399,7 +1399,7 @@ Usage: deco services <up|down|status>`),process.exit(1)}}var fi1=L(()=>{qf()});f
|
|
|
1399
1399
|
`.execute($);if(Number(W.rows[0]?.cnt)===0){console.warn(`Failed to migrate ${J}/${K}, keeping in old table`);continue}}await ab`
|
|
1400
1400
|
DELETE FROM kysely_migration WHERE name = ${X}
|
|
1401
1401
|
`.execute($)}}async function Nr1($){await Io8($),await qo8($);let Z=new Hr1({db:$,provider:{getMigrations:()=>Promise.resolve(ti0)}}),{error:X,results:Q}=await Z.migrateToLatest(),Y=0;if(Q?.forEach((G)=>{if(G.status==="Success")Y++;else if(G.status==="Error")console.error(`Failed to execute migration "${G.migrationName}"`)}),X)throw console.error("Failed to migrate"),console.error(X),X;return Y}async function Mo8($){let{keepOpen:Z=!1,database:X,skipBetterAuth:Q=!1}=$??{},Y="skipped";if(!Q&&!X)Y=await Kl0();let G=X??Q8(),J=async()=>{if(!Z&&!X)await gB(G).catch((K)=>{console.warn("Warning: Error closing database:",K)})};try{let K=await Nr1(G.db);return await J(),{betterAuth:Y,kysely:K}}catch(K){throw await J(),K}}async function Vo8(){let $=Q8(),Z=new Hr1({db:$.db,provider:{getMigrations:()=>Promise.resolve(ti0)}}),{error:X,results:Q}=await Z.migrateDown();if(Q?.forEach((Y)=>{if(Y.status==="Success")console.log(`\u2705 Migration "${Y.migrationName}" rolled back successfully`);else if(Y.status==="Error")console.error(`\u274C Failed to rollback migration "${Y.migrationName}"`)}),X)throw console.error("Failed to rollback migration"),console.error(X),X}var Br1=L(()=>{Wr1();Wl0();ZX()});async function iZ0($){let Z={...process.env},X=c$0($,Z);console.log(yD1(X.settings.encryptionKey));let Q=X.settings.betterAuthSecret||(X.settings.localMode?Un1(X.settings.dataDir):""),{ensureServices:Y}=await Promise.resolve().then(() => (e90(),s90)),{outputs:G,services:J}=await Y({home:X.settings.dataDir,externalDatabaseUrl:X.externalDatabaseUrl,externalNatsUrl:X.externalNatsUrl});if(!X.skipMigrations){let{migrateBetterAuth:W}=await Promise.resolve().then(() => (Wl0(),On1));await W(G.databaseUrl);let{createDatabase:H}=await Promise.resolve().then(() => (ZX(),Sp1)),{migrateToLatest:F}=await Promise.resolve().then(() => (Br1(),Ur1)),N=H(G.databaseUrl);await F({keepOpen:!0,database:N,skipBetterAuth:!0})}let K={...X.settings,betterAuthSecret:Q,databaseUrl:G.databaseUrl,natsUrls:G.natsUrls,...G.s3?{s3Endpoint:G.s3.endpoint,s3Bucket:G.s3.bucket,s3AccessKeyId:G.s3.accessKeyId,s3SecretAccessKey:G.s3.secretAccessKey,s3ForcePathStyle:G.s3.forcePathStyle}:{}};return bi1(K),{settings:K,services:J.map((W)=>({name:W.name==="PostgreSQL"?"Postgres":W.name,port:W.port})),managedServiceNames:J.filter((W)=>W.owner==="managed").map((W)=>W.name)}}var oi0=L(()=>{qf();Bn1();V$()});var wr1={};Q0(wr1,{updateService:()=>RE,subscribeCliState:()=>si0,setTuiConsoleIntercepted:()=>pZ0,setServerUrl:()=>oi,setMigrationsDone:()=>ti,setDevMode:()=>So8,resetCliStateForTests:()=>ko8,isTuiConsoleIntercepted:()=>nZ0,getCliState:()=>ai0,addLogEntry:()=>mB});function Or1(){return[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}]}function Lr1(){return{services:Or1(),migrationsStatus:"pending",serverUrl:null,logs:[]}}function ko8(){cQ=Lr1()}function ni(){for(let $ of ri0)$()}function ai0(){return cQ}function si0($){return ri0.add($),()=>ri0.delete($)}function RE($){cQ={...cQ,services:cQ.services.map((Z)=>Z.name===$.name?$:Z)},ni()}function ti(){cQ={...cQ,migrationsStatus:"done"},ni()}function oi($){cQ={...cQ,serverUrl:$},ni()}function mB($){let Z=[...cQ.logs,$];cQ={...cQ,logs:Z.length>500?Z.slice(-500):Z},ni()}function So8(){cQ={...cQ,services:[...Or1(),{name:"API",status:"pending",port:0},{name:"Vite",status:"pending",port:0}]},ni()}function pZ0($){Dr1=$}function nZ0(){return Dr1}var cQ,ri0,Dr1=!1;var IE=L(()=>{cQ=Lr1();ri0=new Set});import{createServer as Er1}from"net";function Co8($){return new Promise((Z)=>{let X=Er1();X.once("error",()=>Z(!1)),X.listen($,"0.0.0.0",()=>{X.close(()=>Z(!0))})})}async function ri($){if(await Co8($))return $;let Z=await new Promise((X,Q)=>{let Y=Er1();Y.once("error",Q),Y.listen(0,"0.0.0.0",()=>{let G=Y.address(),J=typeof G==="object"&&G?G.port:0;Y.close(()=>X(J))})});return console.warn(`Port ${$} is in use, using port ${Z} instead.`),Z}var ei0=()=>{};var Zp0={};Q0(Zp0,{startDevServer:()=>vo8,pipeToLogStore:()=>$p0});import{join as _o8}from"path";function $p0($){let Z=$.getReader(),X=new TextDecoder,Q="";function Y(){let G=Q.split(`
|
|
1402
|
-
`);Q=G.pop()??"";for(let J of G){let K=Bun.stripANSI(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;mB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{try{for(;;){let{done:G,value:J}=await Z.read();if(G)break;Q+=X.decode(J,{stream:!0}),Y()}}catch{}if(Q.trim()){let G=Bun.stripANSI(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)mB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function vo8($){let{baseUrl:Z,noTui:X}=$,Q=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=Q?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=Q?await ri(Number(Y)+1):await ri(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await iZ0({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let D of W)RE({name:D.name,status:"ready",port:D.port});ti();let F=_o8(import.meta.dir,"..","..","..","..",".."),N=X===!0,U=Bun.spawn(["bun","run","dev:servers"],{cwd:F,env:{...process.env,PORT:String(K.port),VITE_PORT:String(Y),DATABASE_URL:K.databaseUrl,NATS_URL:K.natsUrls.join(","),NODE_ENV:K.nodeEnv,BASE_URL:G,DECOCMS_LOCAL_MODE:String(K.localMode),DECOCMS_HOME:K.dataDir,DATA_DIR:K.dataDir,DECO_CLI:"1",...K.betterAuthSecret?{BETTER_AUTH_SECRET:K.betterAuthSecret}:{},...K.s3Endpoint?{S3_ENDPOINT:K.s3Endpoint,S3_BUCKET:K.s3Bucket??"",S3_ACCESS_KEY_ID:K.s3AccessKeyId??"",S3_SECRET_ACCESS_KEY:K.s3SecretAccessKey??"",S3_FORCE_PATH_STYLE:String(K.s3ForcePathStyle)}:{},...K.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}},stdio:["inherit",N?"inherit":"pipe",N?"inherit":"pipe"]});if(!N)$p0(U.stdout),$p0(U.stderr);oi(G),RE({name:"Vite",status:"ready",port:Number(Y)}),RE({name:"API",status:"ready",port:Number(K.port)});let O=async(D)=>{if(U.kill(D),await U.exited,H.length>0){let{stopServices:w}=await Promise.resolve().then(() => (e90(),s90));await w(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:U}}var Xp0=L(()=>{oi0();IE();ei0()});var tZ0;var Qp0=L(()=>{tZ0={name:"decocms",version:"4.267.1",description:"Deco CMS \u2014 Self-hostable MCP Gateway for managing AI connections and tools",author:"Deco team",repository:{type:"git",url:"git+https://github.com/decocms/studio.git",directory:"apps/api"},bugs:{url:"https://github.com/decocms/studio/issues"},type:"module",bin:{deco:"./dist/server/cli.js"},files:["dist/**/*"],scripts:{dev:"bun run migrate && bun run dev:server","dev:server":"bun run --cwd=../../packages/sandbox build && NODE_ENV=development bun --env-file=.env --hot run src/index.ts",build:"bun run build:server","build:server":"bun run scripts/bundle-server-script.ts --dist ./dist/server","generate:tool-contracts":"bun run scripts/generate-tool-contracts.ts","db:migrate":"bun run ./dist/server/migrate.js","db:migrate:dbos":"bun run ./dist/server/migrate-dbos.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts","migrate:dbos":"bun run src/database/migrate-dbos.ts",test:"bun test src","better-auth:migrate":"bunx --bun @better-auth/cli migrate -y --config src/auth/index.ts",prepublishOnly:"bun run --cwd=../.. build:studio"},optionalDependencies:{"@duckdb/node-api":"^1.5.0-r.1"},dependencies:{"@ai-sdk/anthropic":"^3.0.85","@ai-sdk/google":"^3.0.83","@ai-sdk/openai":"^3.0.73","@anthropic-ai/sdk":"^0.105.0","@aws-sdk/client-s3":"^3.1013.0","@aws-sdk/client-sts":"^3.1013.0","@aws-sdk/lib-storage":"^3.1013.0","@aws-sdk/s3-request-presigner":"^3.1013.0","@clickhouse/client":"^1.8.1","@dbos-inc/dbos-sdk":"^4.21.6","@inkjs/ui":"^2.0.0","@nats-io/jetstream":"3.4.0","@nats-io/kv":"3.4.0","@nats-io/nats-core":"3.4.0","@nats-io/transport-node":"3.4.0","@openrouter/ai-sdk-provider":"^2.9.1","@opentelemetry/core":"^2.6.0","embedded-postgres":"^18.3.0-beta.16",ink:"^6.8.0",kysely:"^0.28.12","posthog-node":"^5.0.0",react:"^19.2.6","react-dom":"^19.2.6"},devDependencies:{"@ai-sdk/provider":"^3.0.10","@better-auth/sso":"1.4.1","@decocms/better-auth":"1.5.17","@decocms/bindings":"workspace:*","@decocms/mcp-utils":"workspace:*","@decocms/runtime":"workspace:*","@decocms/sandbox":"workspace:*","@decocms/shared":"workspace:*","@jitl/quickjs-wasmfile-release-sync":"0.31.0","@modelcontextprotocol/sdk":"1.29.0","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.211.0","@opentelemetry/exporter-logs-otlp-proto":"^0.211.0","@opentelemetry/exporter-prometheus":"^0.208.0","@opentelemetry/exporter-trace-otlp-proto":"^0.207.0","@opentelemetry/instrumentation-runtime-node":"^0.24.0","@opentelemetry/resources":"^2.6.0","@opentelemetry/sdk-logs":"^0.211.0","@opentelemetry/sdk-metrics":"^2.2.0","@opentelemetry/sdk-node":"^0.207.0","@opentelemetry/sdk-trace-base":"^2.5.0","@types/bun":"^1.3.1","@types/google.maps":"^3.65.2","@types/pg":"^8.15.6","@types/react-syntax-highlighter":"^15.5.13","@vercel/nft":"^1.1.1",ai:"^6.0.208","better-auth":"1.4.22",croner:"^9.1.0",degit:"^2.8.4",hono:"^4.10.7",jose:"^6.0.11",nanoid:"^5.1.6",pg:"^8.16.3",typescript:"^7.0.2",typescript5:"npm:typescript@^5.9.3",zod:"4.3.6"},homepage:"https://github.com/decocms/studio",keywords:["mcp","model-context-protocol","ai","gateway","self-hosted","tools"],license:"MIT",publishConfig:{access:"public"}}});import{Box as fo8,Text as jr1}from"ink";import{jsx as bo8,jsxs as zr1}from"react/jsx-runtime";function Pr1({version:$}){return zr1(fo8,{flexDirection:"column",marginTop:1,children:[PZ0.map((Z,X)=>bo8(jr1,{color:AZ0[X],children:Z},X)),zr1(jr1,{dimColor:!0,children:[" v",$]})]})}var Ar1=L(()=>{bi()});import{Box as qE,Text as iB}from"ink";import{Spinner as yo8}from"@inkjs/ui";import{jsx as eY,jsxs as sb}from"react/jsx-runtime";function Tr1({status:$}){if($==="pending")return eY(yo8,{label:""});return eY(iB,{color:"green",children:"\u2713"})}function go8($){return`${$.name}: ${$.port||"...."}`}function Rr1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return sb(qE,{flexDirection:"column",paddingBottom:1,children:[eY(Pr1,{version:tZ0.version}),eY(qE,{marginBottom:1,children:eY(iB,{dimColor:!0,children:"\u2500".repeat(80)})}),eY(qE,{children:sb(iB,{dimColor:!0,children:["Home: ",X]})}),sb(qE,{gap:2,children:[$.map((Y)=>sb(qE,{gap:1,children:[eY(iB,{children:go8(Y)}),eY(Tr1,{status:Y.status})]},Y.name)),sb(qE,{gap:1,children:[eY(iB,{children:"Migrations"}),eY(Tr1,{status:Z})]})]}),eY(qE,{children:Q?sb(iB,{children:["Open in browser: ",eY(iB,{color:"cyan",children:Q})]}):eY(iB,{dimColor:!0,children:"Starting..."})})]})}var Ir1=L(()=>{Qp0();Ar1()});import{Box as ho8,Text as ai}from"ink";import{jsx as Yp0,jsxs as Gp0}from"react/jsx-runtime";function uo8($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function qr1({logs:$}){return Yp0(ho8,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Yp0(ai,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return Gp0(ai,{children:[Gp0(ai,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Yp0(ai,{color:uo8(Z.status),children:Z.status}),Gp0(ai,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var Mr1=()=>{};var Jp0={};Q0(Jp0,{App:()=>do8});import{Box as co8}from"ink";import{useSyncExternalStore as lo8}from"react";import{jsx as Vr1,jsxs as mo8}from"react/jsx-runtime";function do8({home:$}){let Z=lo8(si0,ai0);return mo8(co8,{flexDirection:"column",children:[Vr1(Rr1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),Vr1(qr1,{logs:Z.logs})]})}var Kp0=L(()=>{Ir1();Mr1();IE()});var b3="thread-gate",$N="decopilot-hosted-harness",ZN="decopilot-hosted-harness-sandboxed",NJ="automations",pB="background-tools",ME="task-board-github-reads",VE="jira-push";var kr1="9";function Sr1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:kr1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var Cr1=()=>{};import io8 from"pg";async function vr1($,Z){let{databaseUrl:X,lockTimeoutMs:Q=po8}=$,Y=$.log??((W)=>console.log(W)),G=new io8.Client({connectionString:X});await G.connect();let J=Date.now(),K=!1;try{while(!K){if(K=(await G.query("SELECT pg_try_advisory_lock($1) AS locked",[_r1.toString()])).rows[0]?.locked===!0,K)break;if(Date.now()-J>=Q)throw Error(`Timed out after ${Q}ms waiting for the DBOS migration lock. Another process is still migrating the dbos schema; this pod will restart and retry.`);await H$(no8)}let W=Date.now()-J;if(W>1000)Y(`[dbos] waited ${W}ms for the migration lock; another process migrated first`);return await Z()}finally{if(K)try{await G.query("SELECT pg_advisory_unlock($1)",[_r1.toString()])}catch{}await G.end().catch(()=>{})}}var _r1=8314027461559302n,po8=600000,no8=500;var xr1=L(()=>{N4()});function to8(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function Wp0($,Z){for(let X=0;X<$.length;X++){let Q=$[X];if(Q===void 0)continue;if(Q===Z)return $[X+1];if(Q.startsWith(`${Z}=`))return Q.slice(Z.length+1)}return}function fr1(){let $=to8();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:Wp0($,"--cpu-prof-dir")??process.cwd(),name:Wp0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(Wp0($,"--cpu-prof-interval")??1000),note:"profile is written on process exit"}));return}if(process.env.CPU_PROFILE)console.warn(JSON.stringify({msg:"cpu-profiling-requested-but-inactive",hint:'CPU profiling is a Bun launch flag. Set BUN_OPTIONS="--cpu-prof --cpu-prof-md --cpu-prof-dir=/tmp" before starting the process.'}))}function br1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=zE();if(!X)return;let Q={};try{let{heapStats:Y}=await import("bun:jsc"),G=Y(),J=Object.entries(G.objectTypeCounts).sort((K,W)=>W[1]-K[1]).slice(0,20);Q={objectCount:G.objectCount,heapSize:G.heapSize,top:Object.fromEntries(J)}}catch{}console.log(JSON.stringify({msg:"heap-watch",ts:new Date().toISOString(),uptimeS:Math.round(process.uptime()),rss:X.rss,heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers,...Q}))};return Z().catch(()=>{}),oZ0=setInterval(()=>void Z().catch(()=>{}),$),oZ0.unref?.(),process.on("SIGUSR2",()=>{try{let X=Bun.generateHeapSnapshot("v8"),Q=typeof X==="string"?X:JSON.stringify(X),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,Q),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(X){console.error("[heap-watch] snapshot failed:",X)}}),()=>{if(oZ0)clearInterval(oZ0)}}var oZ0;var yr1=()=>{};import*as oo8 from"bun:jsc";function gr1(){if(process.env.STALL_WATCHDOG!=="1")return()=>{};let $=Number(process.env.STALL_WATCHDOG_MS??100),Z=Number(process.env.STALL_WATCHDOG_TICK_MS??50);try{ro8()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let X,Q=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-Q;Q=G+Z;let K=[];try{K=ao8()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let F of K){let N=F.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??F.frames[0];if(!N)continue;let U=(N.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${N.name??"?"} @ ${U}:${N.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((F,N)=>N[1]-F[1]).slice(0,8).map(([F,N])=>({frame:F,count:N}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}X=setTimeout(Y,Z),X.unref?.()};return X=setTimeout(Y,Z),X.unref?.(),()=>{if(X)clearTimeout(X)}}var ro8,ao8;var hr1=L(()=>{({startSamplingProfiler:ro8,samplingProfilerStackTraces:ao8}=oo8)});function ur1(){fr1();let $=[br1(),Ap1(),gr1()];return()=>{for(let Z of $)Z()}}var cr1=L(()=>{sc0();yr1();hr1()});var kE=v((lr1)=>{Object.defineProperty(lr1,"__esModule",{value:!0});lr1.RepublishHeaders=lr1.DirectMsgHeaders=lr1.JsHeaders=lr1.AdvisoryKind=void 0;lr1.isOrderedPushConsumerOptions=so8;lr1.isPullConsumer=eo8;lr1.isPushConsumer=$r8;lr1.isBoundPushConsumerOptions=Zr8;function so8($){if($&&typeof $==="object")return"name_prefix"in $||"deliver_subject_prefix"in $||"filter_subjects"in $||"filter_subject"in $||"deliver_policy"in $||"opt_start_seq"in $||"opt_start_time"in $||"replay_policy"in $||"inactive_threshold"in $||"headers_only"in $||"deliver_prefix"in $;return!1}function eo8($){return $.isPullConsumer()}function $r8($){return $.isPushConsumer()}function Zr8($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}lr1.AdvisoryKind={API:"api_audit",StreamAction:"stream_action",ConsumerAction:"consumer_action",SnapshotCreate:"snapshot_create",SnapshotComplete:"snapshot_complete",RestoreCreate:"restore_create",RestoreComplete:"restore_complete",MaxDeliver:"max_deliver",Terminated:"terminated",Ack:"consumer_ack",StreamLeaderElected:"stream_leader_elected",StreamQuorumLost:"stream_quorum_lost",ConsumerLeaderElected:"consumer_leader_elected",ConsumerQuorumLost:"consumer_quorum_lost"};lr1.JsHeaders={StreamSourceHdr:"Nats-Stream-Source",LastConsumerSeqHdr:"Nats-Last-Consumer",LastStreamSeqHdr:"Nats-Last-Stream",ConsumerStalledHdr:"Nats-Consumer-Stalled",MessageSizeHdr:"Nats-Msg-Size",RollupHdr:"Nats-Rollup",RollupValueSubject:"sub",RollupValueAll:"all",PendingMessagesHdr:"Nats-Pending-Messages",PendingBytesHdr:"Nats-Pending-Bytes",RequiredApiLevel:"Nats-Required-Api-Level"};lr1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};lr1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var $G=v((mr1)=>{Object.defineProperty(mr1,"__esModule",{value:!0});mr1.TD=mr1.TE=mr1.Empty=void 0;mr1.encode=Fr8;mr1.decode=Nr8;mr1.Empty=new Uint8Array(0);mr1.TE=new TextEncoder;mr1.TD=new TextDecoder;function Hr8(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}function Fr8(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(mr1.TE.encode($[X]));if(Z.length===0)return mr1.Empty;if(Z.length===1)return Z[0];return Hr8(...Z)}function Nr8($){if(!$||$.length===0)return"";return mr1.TD.decode($)}});var ZG=v((nr1)=>{Object.defineProperty(nr1,"__esModule",{value:!0});nr1.errors=nr1.PermissionViolationError=nr1.NoRespondersError=nr1.TimeoutError=nr1.RequestError=nr1.ProtocolError=nr1.ConnectionError=nr1.DrainingConnectionError=nr1.ClosedConnectionError=nr1.AuthorizationError=nr1.UserAuthenticationExpiredError=nr1.InvalidOperationError=nr1.InvalidArgumentError=nr1.InvalidSubjectError=void 0;class Fp0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}nr1.InvalidSubjectError=Fp0;class rZ0 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,X){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((Q)=>`'${Q}'`),$=$.join(",");else $=`'${$}'`;return new rZ0(`${$} ${Z}`,X)}}nr1.InvalidArgumentError=rZ0;class Np0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}nr1.InvalidOperationError=Np0;class aZ0 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new aZ0($);return null}}nr1.UserAuthenticationExpiredError=aZ0;class sZ0 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],X=$.toLowerCase();for(let Q=0;Q<Z.length;Q++)if(X.indexOf(Z[Q])!==-1)return new sZ0($);return null}}nr1.AuthorizationError=sZ0;class Up0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}nr1.ClosedConnectionError=Up0;class Bp0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}nr1.DrainingConnectionError=Bp0;class Op0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}nr1.ConnectionError=Op0;class Lp0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}nr1.ProtocolError=Lp0;class Dp0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof eZ0}}nr1.RequestError=Dp0;class wp0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}nr1.TimeoutError=wp0;class eZ0 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}nr1.NoRespondersError=eZ0;class $70 extends Error{operation;subject;queue;constructor($,Z,X,Q,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=X,this.queue=Q}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let X="publish",Q="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(X=G[1].toLowerCase(),Q=G[2],X==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new $70($,X,Q,Y)}}nr1.PermissionViolationError=$70;nr1.errors={AuthorizationError:sZ0,ClosedConnectionError:Up0,ConnectionError:Op0,DrainingConnectionError:Bp0,InvalidArgumentError:rZ0,InvalidOperationError:Np0,InvalidSubjectError:Fp0,NoRespondersError:eZ0,PermissionViolationError:$70,ProtocolError:Lp0,RequestError:Dp0,TimeoutError:wp0,UserAuthenticationExpiredError:aZ0}});var y3=v((sr1)=>{Object.defineProperty(sr1,"__esModule",{value:!0});sr1.SimpleMutex=sr1.Perf=void 0;sr1.extend=Vr8;sr1.render=kr8;sr1.timeout=Sr8;sr1.delay=Cr8;sr1.deadline=_r8;sr1.deferred=jp0;sr1.debugDeferred=vr8;sr1.shuffle=xr8;sr1.collect=fr8;sr1.jitter=ar1;sr1.backoff=br8;sr1.nanos=yr8;sr1.millis=gr8;sr1.randomToken=cr8;var Mr8=$G(),Ep0=ZG();function Vr8($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function kr8($){return Mr8.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function Sr8($,Z=!0){let X=Z?new Ep0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new Ep0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function Cr8($=0){let Z,X=new Promise((Q)=>{let Y=setTimeout(()=>{Q()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),Q()}}});return Object.assign(X,Z)}async function _r8($,Z=1000){let X=jp0(),Q=setTimeout(()=>{X.reject(new Ep0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function jp0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function vr8(){let $={},Z=new Promise((X,Q)=>{$={resolve:(Y)=>{console.trace("resolve",Y),X(Y)},reject:(Y)=>{console.trace("reject"),Q(Y)}}});return Object.assign(Z,$)}function xr8($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function fr8($){let Z=[];for await(let X of $)Z.push(X);return Z}class or1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,X){let Q=this.timers.get(Z);if(Q===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(X);if(Y===void 0)throw Error(`${X} is not defined`);this.measures.set($,Y-Q)}getEntries(){let $=[];return this.measures.forEach((Z,X)=>{$.push({name:X,duration:Z})}),$}}sr1.Perf=or1;class rr1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=jp0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}sr1.SimpleMutex=rr1;function ar1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function br8($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(X){return ar1(X>Z?$[Z]:$[X])}}}function yr8($){return $*1e6}function gr8($){return Math.floor($/1e6)}var hr8="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",XN=new Uint8Array(62);for(let $=0;$<62;$++)XN[$]=hr8.charCodeAt($);var ur8=218340105584896;function cr8(){let $=Math.floor(Math.random()*ur8),Z=$%62,X=XN[Z];$=($-Z)/62,Z=$%62;let Q=XN[Z];$=($-Z)/62,Z=$%62;let Y=XN[Z];$=($-Z)/62,Z=$%62;let G=XN[Z];$=($-Z)/62,Z=$%62;let J=XN[Z];$=($-Z)/62,Z=$%62;let K=XN[Z];$=($-Z)/62,Z=$%62;let W=XN[Z];$=($-Z)/62;let H=XN[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var Ja1=v((Ya1)=>{Object.defineProperty(Ya1,"__esModule",{value:!0});Ya1.nuid=Ya1.NuidImpl=void 0;var Qa8="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",nB=62,X70=12,Xa1=10,$a1=33,Ya8=333,Za1=X70+Xa1,Pp0=new Uint8Array(nB);for(let $=0;$<nB;$++)Pp0[$]=Qa8.charCodeAt($);var Z70=4294967296,Qa1=BigInt(nB)**BigInt(Xa1),si=Number(Qa1/(1n<<32n)),zp0=Number(Qa1%(1n<<32n));function Ga8($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function Ja8($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else Ga8($)}class Ap0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(Za1),this.cbuf=new Uint8Array(X70),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(si+1)),this.seqLo=Math.floor(Math.random()*Z70);while($++<8&&this.seqHi===si&&this.seqLo>=zp0);if(this.seqHi===si&&this.seqLo>=zp0)this.seqLo=0;this.inc=Math.random()*(Ya8-$a1)+$a1|0}setPre(){Ja8(this.cbuf);for(let $=0;$<X70;$++)this.buf[$]=Pp0[this.cbuf[$]%nB]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=Za1-1;X>=X70;X--){let Q=Math.floor($/nB),G=($-Q*nB)*Z70+Z,J=Math.floor(G/nB),K=G-J*nB;this.buf[X]=Pp0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=Z70)this.seqLo-=Z70,this.seqHi+=1;if(this.seqHi>si||this.seqHi===si&&this.seqLo>=zp0)this.setPre(),this.initSeqAndInc();this.fillSeq();let $=this.buf;return String.fromCharCode($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],$[8],$[9],$[10],$[11],$[12],$[13],$[14],$[15],$[16],$[17],$[18],$[19],$[20],$[21])}reset(){this.init()}}Ya1.NuidImpl=Ap0;Ya1.nuid=new Ap0});var Fa1=v((Wa1)=>{Object.defineProperty(Wa1,"__esModule",{value:!0});Wa1.nuid=Wa1.Nuid=void 0;var Ka1=Ja1();Wa1.Nuid=Ka1.NuidImpl;Wa1.nuid=Ka1.nuid});var Y70=v((Q70)=>{Object.defineProperty(Q70,"__esModule",{value:!0});Q70.nuid=Q70.Nuid=void 0;var Na1=Fa1();Object.defineProperty(Q70,"Nuid",{enumerable:!0,get:function(){return Na1.Nuid}});Object.defineProperty(Q70,"nuid",{enumerable:!0,get:function(){return Na1.nuid}})});var tB=v((Ua1)=>{Object.defineProperty(Ua1,"__esModule",{value:!0});Ua1.DEFAULT_HOST=Ua1.DEFAULT_PORT=Ua1.Match=void 0;Ua1.syncIterator=Ua8;Ua1.createInbox=Ba8;var Fa8=Y70(),Na8=ZG();Ua1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Ua8($){let Z=$[Symbol.asyncIterator]();return{async next(){let X=await Z.next();if(X.done)return Promise.resolve(null);return Promise.resolve(X.value)}}}function Ba8($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw Na8.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${Fa8.nuid.next()}`}Ua1.DEFAULT_PORT=4222;Ua1.DEFAULT_HOST="127.0.0.1"});var ei=v((Da1)=>{Object.defineProperty(Da1,"__esModule",{value:!0});Da1.DataBuffer=void 0;var Oa1=$G();class La1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}static fromAscii($){if(!$)$="";return Oa1.TE.encode($)}static toAscii($){return Oa1.TD.decode($)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){let $=new Uint8Array(this.byteLength),Z=0;for(let X=0;X<this.buffers.length;X++)$.set(this.buffers[X],Z),Z+=this.buffers[X].length;this.buffers.length=0,this.buffers.push($)}}shift(){if(this.buffers.length){let $=this.buffers.shift();if($)return this.byteLength-=$.length,$}return new Uint8Array(0)}drain($){if(this.buffers.length){this.pack();let Z=this.buffers.pop();if(Z){let X=this.byteLength;if($===void 0||$>X)$=X;let Q=Z.subarray(0,$);if(X>$)this.buffers.push(Z.subarray($));return this.byteLength=X-$,Q}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let X=0;X<Z.length;X++)if(Z[X]&&Z[X].length)this.buffers.push(Z[X]),this.byteLength+=Z[X].length}peek(){if(this.buffers.length)return this.pack(),this.buffers[0];return new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}Da1.DataBuffer=La1});var SE=v((ja1)=>{Object.defineProperty(ja1,"__esModule",{value:!0});ja1.LF=ja1.CR=ja1.CRLF=ja1.CR_LF_LEN=ja1.CR_LF=void 0;ja1.setTransportFactory=Pa8;ja1.defaultPort=Aa8;ja1.getUrlParseFn=Ta8;ja1.newTransport=Ra8;ja1.getResolveFn=Ia8;ja1.protoLen=Ea1;ja1.extractProtocolMessage=qa8;var Ea8=$G(),ja8=tB(),za8=ei(),XG;function Pa8($){XG=$}function Aa8(){return XG!==void 0&&XG.defaultPort!==void 0?XG.defaultPort:ja8.DEFAULT_PORT}function Ta8(){return XG!==void 0&&XG.urlParseFn?XG.urlParseFn:void 0}function Ra8(){if(!XG||typeof XG.factory!=="function")throw Error("transport fn is not set");return XG.factory()}function Ia8(){return XG!==void 0&&XG.dnsResolveFn?XG.dnsResolveFn:void 0}ja1.CR_LF=`\r
|
|
1402
|
+
`);Q=G.pop()??"";for(let J of G){let K=Bun.stripANSI(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;mB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{try{for(;;){let{done:G,value:J}=await Z.read();if(G)break;Q+=X.decode(J,{stream:!0}),Y()}}catch{}if(Q.trim()){let G=Bun.stripANSI(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)mB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function vo8($){let{baseUrl:Z,noTui:X}=$,Q=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=Q?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=Q?await ri(Number(Y)+1):await ri(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await iZ0({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let D of W)RE({name:D.name,status:"ready",port:D.port});ti();let F=_o8(import.meta.dir,"..","..","..","..",".."),N=X===!0,U=Bun.spawn(["bun","run","dev:servers"],{cwd:F,env:{...process.env,PORT:String(K.port),VITE_PORT:String(Y),DATABASE_URL:K.databaseUrl,NATS_URL:K.natsUrls.join(","),NODE_ENV:K.nodeEnv,BASE_URL:G,DECOCMS_LOCAL_MODE:String(K.localMode),DECOCMS_HOME:K.dataDir,DATA_DIR:K.dataDir,DECO_CLI:"1",...K.betterAuthSecret?{BETTER_AUTH_SECRET:K.betterAuthSecret}:{},...K.s3Endpoint?{S3_ENDPOINT:K.s3Endpoint,S3_BUCKET:K.s3Bucket??"",S3_ACCESS_KEY_ID:K.s3AccessKeyId??"",S3_SECRET_ACCESS_KEY:K.s3SecretAccessKey??"",S3_FORCE_PATH_STYLE:String(K.s3ForcePathStyle)}:{},...K.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}},stdio:["inherit",N?"inherit":"pipe",N?"inherit":"pipe"]});if(!N)$p0(U.stdout),$p0(U.stderr);oi(G),RE({name:"Vite",status:"ready",port:Number(Y)}),RE({name:"API",status:"ready",port:Number(K.port)});let O=async(D)=>{if(U.kill(D),await U.exited,H.length>0){let{stopServices:w}=await Promise.resolve().then(() => (e90(),s90));await w(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:U}}var Xp0=L(()=>{oi0();IE();ei0()});var tZ0;var Qp0=L(()=>{tZ0={name:"decocms",version:"4.267.2",description:"Deco CMS \u2014 Self-hostable MCP Gateway for managing AI connections and tools",author:"Deco team",repository:{type:"git",url:"git+https://github.com/decocms/studio.git",directory:"apps/api"},bugs:{url:"https://github.com/decocms/studio/issues"},type:"module",bin:{deco:"./dist/server/cli.js"},files:["dist/**/*"],scripts:{dev:"bun run migrate && bun run dev:server","dev:server":"bun run --cwd=../../packages/sandbox build && NODE_ENV=development bun --env-file=.env --hot run src/index.ts",build:"bun run build:server","build:server":"bun run scripts/bundle-server-script.ts --dist ./dist/server","generate:tool-contracts":"bun run scripts/generate-tool-contracts.ts","db:migrate":"bun run ./dist/server/migrate.js","db:migrate:dbos":"bun run ./dist/server/migrate-dbos.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts","migrate:dbos":"bun run src/database/migrate-dbos.ts",test:"bun test src","better-auth:migrate":"bunx --bun @better-auth/cli migrate -y --config src/auth/index.ts",prepublishOnly:"bun run --cwd=../.. build:studio"},optionalDependencies:{"@duckdb/node-api":"^1.5.0-r.1"},dependencies:{"@ai-sdk/anthropic":"^3.0.85","@ai-sdk/google":"^3.0.83","@ai-sdk/openai":"^3.0.73","@anthropic-ai/sdk":"^0.105.0","@aws-sdk/client-s3":"^3.1013.0","@aws-sdk/client-sts":"^3.1013.0","@aws-sdk/lib-storage":"^3.1013.0","@aws-sdk/s3-request-presigner":"^3.1013.0","@clickhouse/client":"^1.8.1","@dbos-inc/dbos-sdk":"^4.21.6","@inkjs/ui":"^2.0.0","@nats-io/jetstream":"3.4.0","@nats-io/kv":"3.4.0","@nats-io/nats-core":"3.4.0","@nats-io/transport-node":"3.4.0","@openrouter/ai-sdk-provider":"^2.9.1","@opentelemetry/core":"^2.6.0","embedded-postgres":"^18.3.0-beta.16",ink:"^6.8.0",kysely:"^0.28.12","posthog-node":"^5.0.0",react:"^19.2.6","react-dom":"^19.2.6"},devDependencies:{"@ai-sdk/provider":"^3.0.10","@better-auth/sso":"1.4.1","@decocms/better-auth":"1.5.17","@decocms/bindings":"workspace:*","@decocms/mcp-utils":"workspace:*","@decocms/runtime":"workspace:*","@decocms/sandbox":"workspace:*","@decocms/shared":"workspace:*","@jitl/quickjs-wasmfile-release-sync":"0.31.0","@modelcontextprotocol/sdk":"1.29.0","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.211.0","@opentelemetry/exporter-logs-otlp-proto":"^0.211.0","@opentelemetry/exporter-prometheus":"^0.208.0","@opentelemetry/exporter-trace-otlp-proto":"^0.207.0","@opentelemetry/instrumentation-runtime-node":"^0.24.0","@opentelemetry/resources":"^2.6.0","@opentelemetry/sdk-logs":"^0.211.0","@opentelemetry/sdk-metrics":"^2.2.0","@opentelemetry/sdk-node":"^0.207.0","@opentelemetry/sdk-trace-base":"^2.5.0","@types/bun":"^1.3.1","@types/google.maps":"^3.65.2","@types/pg":"^8.15.6","@types/react-syntax-highlighter":"^15.5.13","@vercel/nft":"^1.1.1",ai:"^6.0.208","better-auth":"1.4.22",croner:"^9.1.0",degit:"^2.8.4",hono:"^4.10.7",jose:"^6.0.11",nanoid:"^5.1.6",pg:"^8.16.3",typescript:"^7.0.2",typescript5:"npm:typescript@^5.9.3",zod:"4.3.6"},homepage:"https://github.com/decocms/studio",keywords:["mcp","model-context-protocol","ai","gateway","self-hosted","tools"],license:"MIT",publishConfig:{access:"public"}}});import{Box as fo8,Text as jr1}from"ink";import{jsx as bo8,jsxs as zr1}from"react/jsx-runtime";function Pr1({version:$}){return zr1(fo8,{flexDirection:"column",marginTop:1,children:[PZ0.map((Z,X)=>bo8(jr1,{color:AZ0[X],children:Z},X)),zr1(jr1,{dimColor:!0,children:[" v",$]})]})}var Ar1=L(()=>{bi()});import{Box as qE,Text as iB}from"ink";import{Spinner as yo8}from"@inkjs/ui";import{jsx as eY,jsxs as sb}from"react/jsx-runtime";function Tr1({status:$}){if($==="pending")return eY(yo8,{label:""});return eY(iB,{color:"green",children:"\u2713"})}function go8($){return`${$.name}: ${$.port||"...."}`}function Rr1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return sb(qE,{flexDirection:"column",paddingBottom:1,children:[eY(Pr1,{version:tZ0.version}),eY(qE,{marginBottom:1,children:eY(iB,{dimColor:!0,children:"\u2500".repeat(80)})}),eY(qE,{children:sb(iB,{dimColor:!0,children:["Home: ",X]})}),sb(qE,{gap:2,children:[$.map((Y)=>sb(qE,{gap:1,children:[eY(iB,{children:go8(Y)}),eY(Tr1,{status:Y.status})]},Y.name)),sb(qE,{gap:1,children:[eY(iB,{children:"Migrations"}),eY(Tr1,{status:Z})]})]}),eY(qE,{children:Q?sb(iB,{children:["Open in browser: ",eY(iB,{color:"cyan",children:Q})]}):eY(iB,{dimColor:!0,children:"Starting..."})})]})}var Ir1=L(()=>{Qp0();Ar1()});import{Box as ho8,Text as ai}from"ink";import{jsx as Yp0,jsxs as Gp0}from"react/jsx-runtime";function uo8($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function qr1({logs:$}){return Yp0(ho8,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Yp0(ai,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return Gp0(ai,{children:[Gp0(ai,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Yp0(ai,{color:uo8(Z.status),children:Z.status}),Gp0(ai,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var Mr1=()=>{};var Jp0={};Q0(Jp0,{App:()=>do8});import{Box as co8}from"ink";import{useSyncExternalStore as lo8}from"react";import{jsx as Vr1,jsxs as mo8}from"react/jsx-runtime";function do8({home:$}){let Z=lo8(si0,ai0);return mo8(co8,{flexDirection:"column",children:[Vr1(Rr1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),Vr1(qr1,{logs:Z.logs})]})}var Kp0=L(()=>{Ir1();Mr1();IE()});var b3="thread-gate",$N="decopilot-hosted-harness",ZN="decopilot-hosted-harness-sandboxed",NJ="automations",pB="background-tools",ME="task-board-github-reads",VE="jira-push";var kr1="9";function Sr1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:kr1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var Cr1=()=>{};import io8 from"pg";async function vr1($,Z){let{databaseUrl:X,lockTimeoutMs:Q=po8}=$,Y=$.log??((W)=>console.log(W)),G=new io8.Client({connectionString:X});await G.connect();let J=Date.now(),K=!1;try{while(!K){if(K=(await G.query("SELECT pg_try_advisory_lock($1) AS locked",[_r1.toString()])).rows[0]?.locked===!0,K)break;if(Date.now()-J>=Q)throw Error(`Timed out after ${Q}ms waiting for the DBOS migration lock. Another process is still migrating the dbos schema; this pod will restart and retry.`);await H$(no8)}let W=Date.now()-J;if(W>1000)Y(`[dbos] waited ${W}ms for the migration lock; another process migrated first`);return await Z()}finally{if(K)try{await G.query("SELECT pg_advisory_unlock($1)",[_r1.toString()])}catch{}await G.end().catch(()=>{})}}var _r1=8314027461559302n,po8=600000,no8=500;var xr1=L(()=>{N4()});function to8(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function Wp0($,Z){for(let X=0;X<$.length;X++){let Q=$[X];if(Q===void 0)continue;if(Q===Z)return $[X+1];if(Q.startsWith(`${Z}=`))return Q.slice(Z.length+1)}return}function fr1(){let $=to8();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:Wp0($,"--cpu-prof-dir")??process.cwd(),name:Wp0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(Wp0($,"--cpu-prof-interval")??1000),note:"profile is written on process exit"}));return}if(process.env.CPU_PROFILE)console.warn(JSON.stringify({msg:"cpu-profiling-requested-but-inactive",hint:'CPU profiling is a Bun launch flag. Set BUN_OPTIONS="--cpu-prof --cpu-prof-md --cpu-prof-dir=/tmp" before starting the process.'}))}function br1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=zE();if(!X)return;let Q={};try{let{heapStats:Y}=await import("bun:jsc"),G=Y(),J=Object.entries(G.objectTypeCounts).sort((K,W)=>W[1]-K[1]).slice(0,20);Q={objectCount:G.objectCount,heapSize:G.heapSize,top:Object.fromEntries(J)}}catch{}console.log(JSON.stringify({msg:"heap-watch",ts:new Date().toISOString(),uptimeS:Math.round(process.uptime()),rss:X.rss,heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers,...Q}))};return Z().catch(()=>{}),oZ0=setInterval(()=>void Z().catch(()=>{}),$),oZ0.unref?.(),process.on("SIGUSR2",()=>{try{let X=Bun.generateHeapSnapshot("v8"),Q=typeof X==="string"?X:JSON.stringify(X),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,Q),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(X){console.error("[heap-watch] snapshot failed:",X)}}),()=>{if(oZ0)clearInterval(oZ0)}}var oZ0;var yr1=()=>{};import*as oo8 from"bun:jsc";function gr1(){if(process.env.STALL_WATCHDOG!=="1")return()=>{};let $=Number(process.env.STALL_WATCHDOG_MS??100),Z=Number(process.env.STALL_WATCHDOG_TICK_MS??50);try{ro8()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let X,Q=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-Q;Q=G+Z;let K=[];try{K=ao8()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let F of K){let N=F.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??F.frames[0];if(!N)continue;let U=(N.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${N.name??"?"} @ ${U}:${N.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((F,N)=>N[1]-F[1]).slice(0,8).map(([F,N])=>({frame:F,count:N}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}X=setTimeout(Y,Z),X.unref?.()};return X=setTimeout(Y,Z),X.unref?.(),()=>{if(X)clearTimeout(X)}}var ro8,ao8;var hr1=L(()=>{({startSamplingProfiler:ro8,samplingProfilerStackTraces:ao8}=oo8)});function ur1(){fr1();let $=[br1(),Ap1(),gr1()];return()=>{for(let Z of $)Z()}}var cr1=L(()=>{sc0();yr1();hr1()});var kE=v((lr1)=>{Object.defineProperty(lr1,"__esModule",{value:!0});lr1.RepublishHeaders=lr1.DirectMsgHeaders=lr1.JsHeaders=lr1.AdvisoryKind=void 0;lr1.isOrderedPushConsumerOptions=so8;lr1.isPullConsumer=eo8;lr1.isPushConsumer=$r8;lr1.isBoundPushConsumerOptions=Zr8;function so8($){if($&&typeof $==="object")return"name_prefix"in $||"deliver_subject_prefix"in $||"filter_subjects"in $||"filter_subject"in $||"deliver_policy"in $||"opt_start_seq"in $||"opt_start_time"in $||"replay_policy"in $||"inactive_threshold"in $||"headers_only"in $||"deliver_prefix"in $;return!1}function eo8($){return $.isPullConsumer()}function $r8($){return $.isPushConsumer()}function Zr8($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}lr1.AdvisoryKind={API:"api_audit",StreamAction:"stream_action",ConsumerAction:"consumer_action",SnapshotCreate:"snapshot_create",SnapshotComplete:"snapshot_complete",RestoreCreate:"restore_create",RestoreComplete:"restore_complete",MaxDeliver:"max_deliver",Terminated:"terminated",Ack:"consumer_ack",StreamLeaderElected:"stream_leader_elected",StreamQuorumLost:"stream_quorum_lost",ConsumerLeaderElected:"consumer_leader_elected",ConsumerQuorumLost:"consumer_quorum_lost"};lr1.JsHeaders={StreamSourceHdr:"Nats-Stream-Source",LastConsumerSeqHdr:"Nats-Last-Consumer",LastStreamSeqHdr:"Nats-Last-Stream",ConsumerStalledHdr:"Nats-Consumer-Stalled",MessageSizeHdr:"Nats-Msg-Size",RollupHdr:"Nats-Rollup",RollupValueSubject:"sub",RollupValueAll:"all",PendingMessagesHdr:"Nats-Pending-Messages",PendingBytesHdr:"Nats-Pending-Bytes",RequiredApiLevel:"Nats-Required-Api-Level"};lr1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};lr1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var $G=v((mr1)=>{Object.defineProperty(mr1,"__esModule",{value:!0});mr1.TD=mr1.TE=mr1.Empty=void 0;mr1.encode=Fr8;mr1.decode=Nr8;mr1.Empty=new Uint8Array(0);mr1.TE=new TextEncoder;mr1.TD=new TextDecoder;function Hr8(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}function Fr8(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(mr1.TE.encode($[X]));if(Z.length===0)return mr1.Empty;if(Z.length===1)return Z[0];return Hr8(...Z)}function Nr8($){if(!$||$.length===0)return"";return mr1.TD.decode($)}});var ZG=v((nr1)=>{Object.defineProperty(nr1,"__esModule",{value:!0});nr1.errors=nr1.PermissionViolationError=nr1.NoRespondersError=nr1.TimeoutError=nr1.RequestError=nr1.ProtocolError=nr1.ConnectionError=nr1.DrainingConnectionError=nr1.ClosedConnectionError=nr1.AuthorizationError=nr1.UserAuthenticationExpiredError=nr1.InvalidOperationError=nr1.InvalidArgumentError=nr1.InvalidSubjectError=void 0;class Fp0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}nr1.InvalidSubjectError=Fp0;class rZ0 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,X){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((Q)=>`'${Q}'`),$=$.join(",");else $=`'${$}'`;return new rZ0(`${$} ${Z}`,X)}}nr1.InvalidArgumentError=rZ0;class Np0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}nr1.InvalidOperationError=Np0;class aZ0 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new aZ0($);return null}}nr1.UserAuthenticationExpiredError=aZ0;class sZ0 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],X=$.toLowerCase();for(let Q=0;Q<Z.length;Q++)if(X.indexOf(Z[Q])!==-1)return new sZ0($);return null}}nr1.AuthorizationError=sZ0;class Up0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}nr1.ClosedConnectionError=Up0;class Bp0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}nr1.DrainingConnectionError=Bp0;class Op0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}nr1.ConnectionError=Op0;class Lp0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}nr1.ProtocolError=Lp0;class Dp0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof eZ0}}nr1.RequestError=Dp0;class wp0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}nr1.TimeoutError=wp0;class eZ0 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}nr1.NoRespondersError=eZ0;class $70 extends Error{operation;subject;queue;constructor($,Z,X,Q,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=X,this.queue=Q}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let X="publish",Q="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(X=G[1].toLowerCase(),Q=G[2],X==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new $70($,X,Q,Y)}}nr1.PermissionViolationError=$70;nr1.errors={AuthorizationError:sZ0,ClosedConnectionError:Up0,ConnectionError:Op0,DrainingConnectionError:Bp0,InvalidArgumentError:rZ0,InvalidOperationError:Np0,InvalidSubjectError:Fp0,NoRespondersError:eZ0,PermissionViolationError:$70,ProtocolError:Lp0,RequestError:Dp0,TimeoutError:wp0,UserAuthenticationExpiredError:aZ0}});var y3=v((sr1)=>{Object.defineProperty(sr1,"__esModule",{value:!0});sr1.SimpleMutex=sr1.Perf=void 0;sr1.extend=Vr8;sr1.render=kr8;sr1.timeout=Sr8;sr1.delay=Cr8;sr1.deadline=_r8;sr1.deferred=jp0;sr1.debugDeferred=vr8;sr1.shuffle=xr8;sr1.collect=fr8;sr1.jitter=ar1;sr1.backoff=br8;sr1.nanos=yr8;sr1.millis=gr8;sr1.randomToken=cr8;var Mr8=$G(),Ep0=ZG();function Vr8($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function kr8($){return Mr8.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function Sr8($,Z=!0){let X=Z?new Ep0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new Ep0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function Cr8($=0){let Z,X=new Promise((Q)=>{let Y=setTimeout(()=>{Q()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),Q()}}});return Object.assign(X,Z)}async function _r8($,Z=1000){let X=jp0(),Q=setTimeout(()=>{X.reject(new Ep0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function jp0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function vr8(){let $={},Z=new Promise((X,Q)=>{$={resolve:(Y)=>{console.trace("resolve",Y),X(Y)},reject:(Y)=>{console.trace("reject"),Q(Y)}}});return Object.assign(Z,$)}function xr8($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function fr8($){let Z=[];for await(let X of $)Z.push(X);return Z}class or1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,X){let Q=this.timers.get(Z);if(Q===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(X);if(Y===void 0)throw Error(`${X} is not defined`);this.measures.set($,Y-Q)}getEntries(){let $=[];return this.measures.forEach((Z,X)=>{$.push({name:X,duration:Z})}),$}}sr1.Perf=or1;class rr1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=jp0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}sr1.SimpleMutex=rr1;function ar1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function br8($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(X){return ar1(X>Z?$[Z]:$[X])}}}function yr8($){return $*1e6}function gr8($){return Math.floor($/1e6)}var hr8="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",XN=new Uint8Array(62);for(let $=0;$<62;$++)XN[$]=hr8.charCodeAt($);var ur8=218340105584896;function cr8(){let $=Math.floor(Math.random()*ur8),Z=$%62,X=XN[Z];$=($-Z)/62,Z=$%62;let Q=XN[Z];$=($-Z)/62,Z=$%62;let Y=XN[Z];$=($-Z)/62,Z=$%62;let G=XN[Z];$=($-Z)/62,Z=$%62;let J=XN[Z];$=($-Z)/62,Z=$%62;let K=XN[Z];$=($-Z)/62,Z=$%62;let W=XN[Z];$=($-Z)/62;let H=XN[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var Ja1=v((Ya1)=>{Object.defineProperty(Ya1,"__esModule",{value:!0});Ya1.nuid=Ya1.NuidImpl=void 0;var Qa8="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",nB=62,X70=12,Xa1=10,$a1=33,Ya8=333,Za1=X70+Xa1,Pp0=new Uint8Array(nB);for(let $=0;$<nB;$++)Pp0[$]=Qa8.charCodeAt($);var Z70=4294967296,Qa1=BigInt(nB)**BigInt(Xa1),si=Number(Qa1/(1n<<32n)),zp0=Number(Qa1%(1n<<32n));function Ga8($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function Ja8($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else Ga8($)}class Ap0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(Za1),this.cbuf=new Uint8Array(X70),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(si+1)),this.seqLo=Math.floor(Math.random()*Z70);while($++<8&&this.seqHi===si&&this.seqLo>=zp0);if(this.seqHi===si&&this.seqLo>=zp0)this.seqLo=0;this.inc=Math.random()*(Ya8-$a1)+$a1|0}setPre(){Ja8(this.cbuf);for(let $=0;$<X70;$++)this.buf[$]=Pp0[this.cbuf[$]%nB]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=Za1-1;X>=X70;X--){let Q=Math.floor($/nB),G=($-Q*nB)*Z70+Z,J=Math.floor(G/nB),K=G-J*nB;this.buf[X]=Pp0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=Z70)this.seqLo-=Z70,this.seqHi+=1;if(this.seqHi>si||this.seqHi===si&&this.seqLo>=zp0)this.setPre(),this.initSeqAndInc();this.fillSeq();let $=this.buf;return String.fromCharCode($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],$[8],$[9],$[10],$[11],$[12],$[13],$[14],$[15],$[16],$[17],$[18],$[19],$[20],$[21])}reset(){this.init()}}Ya1.NuidImpl=Ap0;Ya1.nuid=new Ap0});var Fa1=v((Wa1)=>{Object.defineProperty(Wa1,"__esModule",{value:!0});Wa1.nuid=Wa1.Nuid=void 0;var Ka1=Ja1();Wa1.Nuid=Ka1.NuidImpl;Wa1.nuid=Ka1.nuid});var Y70=v((Q70)=>{Object.defineProperty(Q70,"__esModule",{value:!0});Q70.nuid=Q70.Nuid=void 0;var Na1=Fa1();Object.defineProperty(Q70,"Nuid",{enumerable:!0,get:function(){return Na1.Nuid}});Object.defineProperty(Q70,"nuid",{enumerable:!0,get:function(){return Na1.nuid}})});var tB=v((Ua1)=>{Object.defineProperty(Ua1,"__esModule",{value:!0});Ua1.DEFAULT_HOST=Ua1.DEFAULT_PORT=Ua1.Match=void 0;Ua1.syncIterator=Ua8;Ua1.createInbox=Ba8;var Fa8=Y70(),Na8=ZG();Ua1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Ua8($){let Z=$[Symbol.asyncIterator]();return{async next(){let X=await Z.next();if(X.done)return Promise.resolve(null);return Promise.resolve(X.value)}}}function Ba8($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw Na8.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${Fa8.nuid.next()}`}Ua1.DEFAULT_PORT=4222;Ua1.DEFAULT_HOST="127.0.0.1"});var ei=v((Da1)=>{Object.defineProperty(Da1,"__esModule",{value:!0});Da1.DataBuffer=void 0;var Oa1=$G();class La1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}static fromAscii($){if(!$)$="";return Oa1.TE.encode($)}static toAscii($){return Oa1.TD.decode($)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){let $=new Uint8Array(this.byteLength),Z=0;for(let X=0;X<this.buffers.length;X++)$.set(this.buffers[X],Z),Z+=this.buffers[X].length;this.buffers.length=0,this.buffers.push($)}}shift(){if(this.buffers.length){let $=this.buffers.shift();if($)return this.byteLength-=$.length,$}return new Uint8Array(0)}drain($){if(this.buffers.length){this.pack();let Z=this.buffers.pop();if(Z){let X=this.byteLength;if($===void 0||$>X)$=X;let Q=Z.subarray(0,$);if(X>$)this.buffers.push(Z.subarray($));return this.byteLength=X-$,Q}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let X=0;X<Z.length;X++)if(Z[X]&&Z[X].length)this.buffers.push(Z[X]),this.byteLength+=Z[X].length}peek(){if(this.buffers.length)return this.pack(),this.buffers[0];return new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}Da1.DataBuffer=La1});var SE=v((ja1)=>{Object.defineProperty(ja1,"__esModule",{value:!0});ja1.LF=ja1.CR=ja1.CRLF=ja1.CR_LF_LEN=ja1.CR_LF=void 0;ja1.setTransportFactory=Pa8;ja1.defaultPort=Aa8;ja1.getUrlParseFn=Ta8;ja1.newTransport=Ra8;ja1.getResolveFn=Ia8;ja1.protoLen=Ea1;ja1.extractProtocolMessage=qa8;var Ea8=$G(),ja8=tB(),za8=ei(),XG;function Pa8($){XG=$}function Aa8(){return XG!==void 0&&XG.defaultPort!==void 0?XG.defaultPort:ja8.DEFAULT_PORT}function Ta8(){return XG!==void 0&&XG.urlParseFn?XG.urlParseFn:void 0}function Ra8(){if(!XG||typeof XG.factory!=="function")throw Error("transport fn is not set");return XG.factory()}function Ia8(){return XG!==void 0&&XG.dnsResolveFn?XG.dnsResolveFn:void 0}ja1.CR_LF=`\r
|
|
1403
1403
|
`;ja1.CR_LF_LEN=ja1.CR_LF.length;ja1.CRLF=za8.DataBuffer.fromAscii(ja1.CR_LF);ja1.CR=new Uint8Array(ja1.CRLF)[0];ja1.LF=new Uint8Array(ja1.CRLF)[1];function Ea1($){for(let Z=0;Z<$.length;Z++){let X=Z+1;if($.byteLength>X&&$[Z]===ja1.CR&&$[X]===ja1.LF)return X+1}return 0}function qa8($){let Z=Ea1($);if(Z>0){let Q=new Uint8Array($).slice(0,Z);return Ea8.TD.decode(Q)}return""}});var Mp0=v((Ma1)=>{Object.defineProperty(Ma1,"__esModule",{value:!0});Ma1.ipV4=Ra1;Ma1.isIP=ya8;Ma1.parseIP=Ia1;var $p=4,CE=16,G70=48,Ta1=57,Pa1=65,fa8=70,Aa1=97,ba8=102,qp0=16777215;function Ra1($,Z,X,Q){let Y=new Uint8Array(CE);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((J,K)=>{Y[K]=J}),Y[12]=$,Y[13]=Z,Y[14]=X,Y[15]=Q,Y}function ya8($){return Ia1($)!==void 0}function Ia1($){for(let Z=0;Z<$.length;Z++)switch($[Z]){case".":return qa1($);case":":return ga8($)}return}function qa1($){let Z=new Uint8Array($p);for(let X=0;X<$p;X++){if($.length===0)return;if(X>0){if($[0]!==".")return;$=$.substring(1)}let{n:Q,c:Y,ok:G}=ha8($);if(!G||Q>255)return;$=$.substring(Y),Z[X]=Q}return Ra1(Z[0],Z[1],Z[2],Z[3])}function ga8($){let Z=new Uint8Array(CE),X=-1;if($.length>=2&&$[0]===":"&&$[1]===":"){if(X=0,$=$.substring(2),$.length===0)return Z}let Q=0;while(Q<CE){let{n:Y,c:G,ok:J}=ua8($);if(!J||Y>65535)return;if(G<$.length&&$[G]==="."){if(X<0&&Q!=CE-$p)return;if(Q+$p>CE)return;let K=qa1($);if(K===void 0)return;Z[Q]=K[12],Z[Q+1]=K[13],Z[Q+2]=K[14],Z[Q+3]=K[15],$="",Q+=$p;break}if(Z[Q]=Y>>8,Z[Q+1]=Y,Q+=2,$=$.substring(G),$.length===0)break;if($[0]!==":"||$.length==1)return;if($=$.substring(1),$[0]===":"){if(X>=0)return;if(X=Q,$=$.substring(1),$.length===0)break}}if($.length!==0)return;if(Q<CE){if(X<0)return;let Y=CE-Q;for(let G=Q-1;G>=X;G--)Z[G+Y]=Z[G];for(let G=X+Y-1;G>=X;G--)Z[G]=0}else if(X>=0)return;return Z}function ha8($){let Z=0,X=0;for(Z=0;Z<$.length&&G70<=$.charCodeAt(Z)&&$.charCodeAt(Z)<=Ta1;Z++)if(X=X*10+($.charCodeAt(Z)-G70),X>=qp0)return{n:qp0,c:Z,ok:!1};if(Z===0)return{n:0,c:0,ok:!1};return{n:X,c:Z,ok:!0}}function ua8($){let Z=0,X=0;for(X=0;X<$.length;X++){if(G70<=$.charCodeAt(X)&&$.charCodeAt(X)<=Ta1)Z*=16,Z+=$.charCodeAt(X)-G70;else if(Aa1<=$.charCodeAt(X)&&$.charCodeAt(X)<=ba8)Z*=16,Z+=$.charCodeAt(X)-Aa1+10;else if(Pa1<=$.charCodeAt(X)&&$.charCodeAt(X)<=fa8)Z*=16,Z+=$.charCodeAt(X)-Pa1+10;else break;if(Z>=qp0)return{n:0,c:X,ok:!1}}if(X===0)return{n:0,c:X,ok:!1};return{n:Z,c:X,ok:!0}}});var vp0=v((ka1)=>{Object.defineProperty(ka1,"__esModule",{value:!0});ka1.Servers=ka1.ServerImpl=void 0;ka1.isIPV4OrHostname=Va1;ka1.hostPort=_p0;var Vp0=SE(),kp0=y3(),Sp0=Mp0(),ma8=tB(),ia8=ZG();function Va1($){if($.indexOf("[")!==-1||$.indexOf("::")!==-1)return!1;if($.indexOf(".")!==-1)return!0;if($.split(":").length<=2)return!0;return!1}function Cp0($){return!Va1($)}function pa8($){let X=$.toUpperCase().indexOf("::FFFF:");if(X!==-1&&$.indexOf(".")!==-1){let Q=$.substring(X+7);return Q=Q.replace("[",""),Q.replace("]","")}return $}function _p0($){if($=$.trim(),$.match(/^(.*:\/\/)(.*)/m))$=$.replace(/^(.*:\/\/)(.*)/gm,"$2");if($=pa8($),Cp0($)&&$.indexOf("[")===-1)$=`[${$}]`;let Z=Cp0($)?$.match(/(]:)(\d+)/):$.match(/(:)(\d+)/),X=Z&&Z.length===3&&Z[1]&&Z[2]?parseInt(Z[2]):ma8.DEFAULT_PORT,Y=new URL(`${X===80?"https":"http"}://${$}`);Y.port=`${X}`;let G=Y.hostname;if(G.charAt(0)==="[")G=G.substring(1,G.length-1);return{listen:Y.host,hostname:G,port:X}}class eb{src;listen;hostname;port;didConnect;reconnects;lastConnect;gossiped;tlsName;resolves;constructor($,Z=!1){this.src=$,this.tlsName="";let X=_p0($);this.listen=X.listen,this.hostname=X.hostname,this.port=X.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=Z}toString(){return this.listen}async resolve($){if(!$.fn||$.resolve===!1)return[this];let Z=[];if((0,Sp0.isIP)(this.hostname))return[this];else{let X=await $.fn(this.hostname);if($.debug)console.log(`resolve ${this.hostname} = ${X.join(",")}`);for(let Q of X){let Y=this.port===80?"https":"http",G=new URL(`${Y}://${Cp0(Q)?"["+Q+"]":Q}`);G.port=`${this.port}`;let J=new eb(G.host,!1);J.tlsName=this.hostname,Z.push(J)}}if($.randomize)(0,kp0.shuffle)(Z);return this.resolves=Z,Z}}ka1.ServerImpl=eb;class J70{firstSelect;servers;currentServer;tlsName;randomize;constructor($={}){this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=$.randomize||!1}setServers($){if(!Array.isArray($)||$.length===0)throw ia8.InvalidArgumentError.format("servers","cannot be empty");let Z=(0,Vp0.getUrlParseFn)(),X=new Map;for(let Y of this.servers)X.set(Y.listen,Y);let Q=[];for(let Y of $){Y=Z?Z(Y):Y;let{listen:G}=_p0(Y),J=X.get(G);if(J)J.gossiped=!1,Q.push(J);else Q.push(new eb(Y))}if(this.randomize)(0,kp0.shuffle)(Q);if(this.servers=Q,this.currentServer===void 0||!Q.includes(this.currentServer))this.currentServer=Q[0],this.firstSelect=!0}clear(){this.servers.length=0}updateTLSName(){let $=this.getCurrentServer();if(!(0,Sp0.isIP)($.hostname))this.tlsName=$.hostname,this.servers.forEach((Z)=>{if(Z.gossiped)Z.tlsName=this.tlsName})}getCurrentServer(){return this.currentServer}addServer($,Z=!1){let X=(0,Vp0.getUrlParseFn)();$=X?X($):$;let Q=new eb($,Z);if((0,Sp0.isIP)(Q.hostname))Q.tlsName=this.tlsName;this.servers.push(Q)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;let $=this.servers.shift();if($)this.servers.push($),this.currentServer=$;return $}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer($){if($){let Z=this.servers.indexOf($);this.servers.splice(Z,1)}}snapshot(){return J70.freezeAll(this.servers)}snapshotForHandler(){let $=this.currentServer;if(!$)return this.snapshot();let Z=this.servers.indexOf($);if(Z<=0)return this.snapshot();return J70.freezeAll([$,...this.servers.slice(0,Z),...this.servers.slice(Z+1)])}static freezeAll($){return $.map((Z)=>Object.freeze({hostname:Z.hostname,port:Z.port,listen:Z.listen,src:Z.src,tlsName:Z.tlsName,reconnects:Z.reconnects,lastConnect:Z.lastConnect,gossiped:Z.gossiped,didConnect:Z.didConnect}))}find($){return this.servers.find((Z)=>Z.listen===$.listen)}setCurrent($){this.currentServer=$}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update($,Z){let X=[],Q=[],Y=(0,Vp0.getUrlParseFn)(),G=new Map;if($.connect_urls&&$.connect_urls.length>0)$.connect_urls.forEach((K)=>{K=Y?Y(K,Z):K;let W=new eb(K,!0);G.set(K,W)});let J=[];if(this.servers.forEach((K,W)=>{let H=K.listen;if(K.gossiped&&this.currentServer.listen!==H&&G.get(H)===void 0)J.push(W);G.delete(H)}),J.reverse(),J.forEach((K)=>{let W=this.servers.splice(K,1);Q=Q.concat(W[0].listen)}),G.forEach((K,W)=>{this.servers.push(K),X.push(W)}),this.randomize&&X.length>0){let K=this.currentServer,W=this.servers.filter((H)=>H!==K);(0,kp0.shuffle)(W),this.servers=K?[K,...W]:W}return{added:X,deleted:Q}}}ka1.Servers=J70});var K70=v((va1)=>{Object.defineProperty(va1,"__esModule",{value:!0});va1.QueuedIteratorImpl=void 0;var xp0=y3(),Ca1=ZG();class _a1{inflight;processed;received;noIterator;iterClosed;done;signal;yields;filtered;pendingFiltered;ctx;_data;err;time;profile;yielding;didBreak;constructor(){this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=(0,xp0.deferred)(),this.yields=[],this.iterClosed=(0,xp0.deferred)(),this.time=0,this.yielding=!1,this.didBreak=!1,this.profile=!1}[Symbol.asyncIterator](){return this.iterate()}push($){if(this.done)return;if(this.didBreak){if(typeof $==="function"){let Z=$;try{Z()}catch(X){}}return}if(typeof $==="function")this.pendingFiltered++;this.yields.push($),this.signal.resolve()}async*iterate(){if(this.noIterator)throw new Ca1.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new Ca1.InvalidOperationError("iterator is already yielding");this.yielding=!0;try{while(!0){if(this.yields.length===0)await this.signal;if(this.err)throw this.err;let $=this.yields;this.inflight=$.length,this.yields=[];for(let Z=0;Z<$.length;Z++){if(typeof $[Z]==="function"){this.pendingFiltered--;let Q=$[Z];try{Q()}catch(Y){throw Y}if(this.err)throw this.err;continue}this.processed++,this.inflight--;let X=this.profile?Date.now():0;yield $[Z],this.time=this.profile?Date.now()-X:0}if(this.done)break;else if(this.yields.length===0)$.length=0,this.yields=$,this.signal=(0,xp0.deferred)()}}finally{this.didBreak=!0,this.stop()}}stop($){if(this.done)return;this.err=$,this.done=!0,this.signal.resolve(),this.iterClosed.resolve($)}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}va1.QueuedIteratorImpl=_a1});var fp0=v((ya1)=>{Object.defineProperty(ya1,"__esModule",{value:!0});ya1.MuxSubscription=void 0;var ra8=tB(),fa1=ZG();class ba1{baseInbox;reqs;constructor(){this.reqs=new Map}size(){return this.reqs.size}init($){return this.baseInbox=`${(0,ra8.createInbox)($)}.`,this.baseInbox}add($){if(!isNaN($.received))$.received=0;this.reqs.set($.token,$)}get($){return this.reqs.get($)}cancel($){this.reqs.delete($.token)}getToken($){let Z=$.subject||"";if(Z.indexOf(this.baseInbox)===0)return Z.substring(this.baseInbox.length);return null}all(){return Array.from(this.reqs.values())}handleError($,Z){if($)return this.all().forEach((X)=>{X.resolver(Z,{})}),!0;if(Z.operation==="publish"){let X=this.all().find((Q)=>{return Q.requestSubject===Z.subject});if(X)return X.resolver(Z,{}),!0}return!1}dispatcher(){return($,Z)=>{let X=this.getToken(Z);if(X){let Q=this.get(X);if(Q){if($===null)$=Z?.data?.length===0&&Z.headers?.code===503?new fa1.NoRespondersError(Q.requestSubject):null;Q.resolver($,Z)}}}}close(){let $=new fa1.RequestError("connection closed");this.reqs.forEach((Z)=>{Z.resolver($,{})})}}ya1.MuxSubscription=ba1});var bp0=v((ua1)=>{Object.defineProperty(ua1,"__esModule",{value:!0});ua1.Heartbeat=void 0;var aa8=y3();class ha1{ph;interval;maxOut;timer;pendings;constructor($,Z,X){this.ph=$,this.interval=Z,this.maxOut=X,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel($){if(this.timer)clearTimeout(this.timer),this.timer=void 0;if(this._reset(),$)this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:"ping",pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}let $=(0,aa8.deferred)();this.ph.flush($).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push($),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(($)=>{return $.resolve(),!1})}}ua1.Heartbeat=ha1});var hp0=v((ia1)=>{Object.defineProperty(ia1,"__esModule",{value:!0});ia1.DenoBuffer=ia1.MAX_SIZE=ia1.AssertionError=void 0;ia1.assert=da1;ia1.concat=ma1;ia1.append=ea8;ia1.readAll=$s8;ia1.writeAll=Zs8;var sa8=$G();class yp0 extends Error{constructor($){super($);this.name="AssertionError"}}ia1.AssertionError=yp0;function da1($,Z="Assertion failed."){if(!$)throw new yp0(Z)}var la1=32768;ia1.MAX_SIZE=4294967294;function W70($,Z,X=0){let Q=Z.byteLength-X;if($.byteLength>Q)$=$.subarray(0,Q);return Z.set($,X),$.byteLength}function ma1($,Z){if($===void 0&&Z===void 0)return new Uint8Array(0);if($===void 0)return Z;if(Z===void 0)return $;let X=new Uint8Array($.length+Z.length);return X.set($,0),X.set(Z,$.length),X}function ea8($,Z){return ma1($,Uint8Array.of(Z))}class gp0{_buf;_off;constructor($){if(this._off=0,$==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array($)}bytes($={copy:!0}){if($.copy===!1)return this._buf.subarray(this._off);return this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate($){if($===0){this.reset();return}if($<0||$>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+$)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice($){let Z=this._buf.byteLength;if($<=this.capacity-Z)return this._reslice(Z+$),Z;return-1}_reslice($){da1($<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,$)}readByte(){let $=new Uint8Array(1);if(this.read($))return $[0];return null}read($){if(this.empty()){if(this.reset(),$.byteLength===0)return 0;return null}let Z=W70(this._buf.subarray(this._off),$);return this._off+=Z,Z}writeByte($){return this.write(Uint8Array.of($))}writeString($){return this.write(sa8.TE.encode($))}write($){let Z=this._grow($.byteLength);return W70($,this._buf,Z)}_grow($){let Z=this.length;if(Z===0&&this._off!==0)this.reset();let X=this._tryGrowByReslice($);if(X>=0)return X;let Q=this.capacity;if($<=Math.floor(Q/2)-Z)W70(this._buf.subarray(this._off),this._buf);else if(Q+$>ia1.MAX_SIZE)throw Error("The buffer cannot be grown beyond the maximum size.");else{let Y=new Uint8Array(Math.min(2*Q+$,ia1.MAX_SIZE));W70(this._buf.subarray(this._off),Y),this._buf=Y}return this._off=0,this._reslice(Math.min(Z+$,ia1.MAX_SIZE)),Z}grow($){if($<0)throw Error("Buffer._grow: negative count");let Z=this._grow($);this._reslice(Z)}readFrom($){let Z=0,X=new Uint8Array(la1);while(!0){let Q=this.capacity-this.length<la1,Y=Q?X:new Uint8Array(this._buf.buffer,this.length),G=$.read(Y);if(G===null)return Z;if(Q)this.write(Y.subarray(0,G));else this._reslice(this.length+G);Z+=G}}}ia1.DenoBuffer=gp0;function $s8($){let Z=new gp0;return Z.readFrom($),Z.bytes()}function Zs8($,Z){let X=0;while(X<Z.length)X+=$.write(Z.subarray(X))}});var lp0=v((ra1)=>{Object.defineProperty(ra1,"__esModule",{value:!0});ra1.cc=ra1.State=ra1.Parser=ra1.Kind=void 0;ra1.describe=Ws8;var up0=hp0(),cp0=$G();ra1.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function Ws8($){let Z,X="";switch($.kind){case ra1.Kind.MSG:Z="MSG";break;case ra1.Kind.OK:Z="OK";break;case ra1.Kind.ERR:Z="ERR",X=cp0.TD.decode($.data);break;case ra1.Kind.PING:Z="PING";break;case ra1.Kind.PONG:Z="PONG";break;case ra1.Kind.INFO:Z="INFO",X=cp0.TD.decode($.data)}return`${Z}: ${X}`}function na1(){let $={};return $.sid=-1,$.hdr=-1,$.size=-1,$}var ta1=48,Hs8=57,$y=67108864;class oa1{dispatcher;state;as;drop;hdr;ma;argBuf;msgBuf;constructor($){this.dispatcher=$,this.state=ra1.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse($){let Z;for(Z=0;Z<$.length;Z++){let X=$[Z];switch(this.state){case ra1.State.OP_START:switch(X){case ra1.cc.M:case ra1.cc.m:this.state=ra1.State.OP_M,this.hdr=-1,this.ma=na1();break;case ra1.cc.H:case ra1.cc.h:this.state=ra1.State.OP_H,this.hdr=0,this.ma=na1();break;case ra1.cc.P:case ra1.cc.p:this.state=ra1.State.OP_P;break;case ra1.cc.PLUS:this.state=ra1.State.OP_PLUS;break;case ra1.cc.MINUS:this.state=ra1.State.OP_MINUS;break;case ra1.cc.I:case ra1.cc.i:this.state=ra1.State.OP_I;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_H:switch(X){case ra1.cc.M:case ra1.cc.m:this.state=ra1.State.OP_M;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_M:switch(X){case ra1.cc.S:case ra1.cc.s:this.state=ra1.State.OP_MS;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_MS:switch(X){case ra1.cc.G:case ra1.cc.g:this.state=ra1.State.OP_MSG;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_MSG:switch(X){case ra1.cc.SPACE:case ra1.cc.TAB:this.state=ra1.State.OP_MSG_SPC;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_MSG_SPC:switch(X){case ra1.cc.SPACE:case ra1.cc.TAB:continue;default:this.state=ra1.State.MSG_ARG,this.as=Z}break;case ra1.State.MSG_ARG:switch(X){case ra1.cc.CR:this.drop=1;break;case ra1.cc.NL:{let Q=this.argBuf?this.argBuf.bytes():$.subarray(this.as,Z-this.drop);this.processMsgArgs(Q),this.drop=0,this.as=Z+1,this.state=ra1.State.MSG_PAYLOAD,Z=this.as+this.ma.size-1;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;case ra1.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){let Q=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:ra1.Kind.MSG,msg:this.ma,data:Q}),this.argBuf=void 0,this.msgBuf=void 0,this.state=ra1.State.MSG_END}else{let Q=this.ma.size-this.msgBuf.length,Y=$.length-Z;if(Y<Q)Q=Y;if(Q>0)this.msgBuf.write($.subarray(Z,Z+Q)),Z=Z+Q-1;else this.msgBuf.writeByte(X)}else if(Z-this.as>=this.ma.size)this.dispatcher.push({kind:ra1.Kind.MSG,msg:this.ma,data:$.subarray(this.as,Z)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=ra1.State.MSG_END;break;case ra1.State.MSG_END:switch(X){case ra1.cc.NL:this.drop=0,this.as=Z+1,this.state=ra1.State.OP_START;break;default:continue}break;case ra1.State.OP_PLUS:switch(X){case ra1.cc.O:case ra1.cc.o:this.state=ra1.State.OP_PLUS_O;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_PLUS_O:switch(X){case ra1.cc.K:case ra1.cc.k:this.state=ra1.State.OP_PLUS_OK;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_PLUS_OK:switch(X){case ra1.cc.NL:this.dispatcher.push({kind:ra1.Kind.OK}),this.drop=0,this.state=ra1.State.OP_START;break}break;case ra1.State.OP_MINUS:switch(X){case ra1.cc.E:case ra1.cc.e:this.state=ra1.State.OP_MINUS_E;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_MINUS_E:switch(X){case ra1.cc.R:case ra1.cc.r:this.state=ra1.State.OP_MINUS_ER;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_MINUS_ER:switch(X){case ra1.cc.R:case ra1.cc.r:this.state=ra1.State.OP_MINUS_ERR;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_MINUS_ERR:switch(X){case ra1.cc.SPACE:case ra1.cc.TAB:this.state=ra1.State.OP_MINUS_ERR_SPC;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_MINUS_ERR_SPC:switch(X){case ra1.cc.SPACE:case ra1.cc.TAB:continue;default:this.state=ra1.State.MINUS_ERR_ARG,this.as=Z}break;case ra1.State.MINUS_ERR_ARG:switch(X){case ra1.cc.CR:this.drop=1;break;case ra1.cc.NL:{let Q;if(this.argBuf)Q=this.argBuf.bytes(),this.argBuf=void 0;else Q=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:ra1.Kind.ERR,data:Q}),this.drop=0,this.as=Z+1,this.state=ra1.State.OP_START;break}default:if(this.argBuf)this.argBuf.write(Uint8Array.of(X))}break;case ra1.State.OP_P:switch(X){case ra1.cc.I:case ra1.cc.i:this.state=ra1.State.OP_PI;break;case ra1.cc.O:case ra1.cc.o:this.state=ra1.State.OP_PO;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_PO:switch(X){case ra1.cc.N:case ra1.cc.n:this.state=ra1.State.OP_PON;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_PON:switch(X){case ra1.cc.G:case ra1.cc.g:this.state=ra1.State.OP_PONG;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_PONG:switch(X){case ra1.cc.NL:this.dispatcher.push({kind:ra1.Kind.PONG}),this.drop=0,this.state=ra1.State.OP_START;break}break;case ra1.State.OP_PI:switch(X){case ra1.cc.N:case ra1.cc.n:this.state=ra1.State.OP_PIN;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_PIN:switch(X){case ra1.cc.G:case ra1.cc.g:this.state=ra1.State.OP_PING;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_PING:switch(X){case ra1.cc.NL:this.dispatcher.push({kind:ra1.Kind.PING}),this.drop=0,this.state=ra1.State.OP_START;break}break;case ra1.State.OP_I:switch(X){case ra1.cc.N:case ra1.cc.n:this.state=ra1.State.OP_IN;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_IN:switch(X){case ra1.cc.F:case ra1.cc.f:this.state=ra1.State.OP_INF;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_INF:switch(X){case ra1.cc.O:case ra1.cc.o:this.state=ra1.State.OP_INFO;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_INFO:switch(X){case ra1.cc.SPACE:case ra1.cc.TAB:this.state=ra1.State.OP_INFO_SPC;break;default:throw this.fail($.subarray(Z))}break;case ra1.State.OP_INFO_SPC:switch(X){case ra1.cc.SPACE:case ra1.cc.TAB:continue;default:this.state=ra1.State.INFO_ARG,this.as=Z}break;case ra1.State.INFO_ARG:switch(X){case ra1.cc.CR:this.drop=1;break;case ra1.cc.NL:{let Q;if(this.argBuf)Q=this.argBuf.bytes(),this.argBuf=void 0;else Q=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:ra1.Kind.INFO,data:Q}),this.drop=0,this.as=Z+1,this.state=ra1.State.OP_START;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;default:throw this.fail($.subarray(Z))}}if((this.state===ra1.State.MSG_ARG||this.state===ra1.State.MINUS_ERR_ARG||this.state===ra1.State.INFO_ARG)&&!this.argBuf)this.argBuf=new up0.DenoBuffer($.subarray(this.as,Z-this.drop));if(this.state===ra1.State.MSG_PAYLOAD&&!this.msgBuf){if(!this.argBuf)this.cloneMsgArg();this.msgBuf=new up0.DenoBuffer($.subarray(this.as))}}cloneMsgArg(){let $=this.ma.subject.length,Z=this.ma.reply?this.ma.reply.length:0,X=new Uint8Array($+Z);if(X.set(this.ma.subject),this.ma.reply)X.set(this.ma.reply,$);if(this.argBuf=new up0.DenoBuffer(X),this.ma.subject=X.subarray(0,$),this.ma.reply)this.ma.reply=X.subarray($)}processMsgArgs($){if(this.hdr>=0)return this.processHeaderMsgArgs($);let Z=[],X=-1;for(let Q=0;Q<$.length;Q++)switch($[Q]){case ra1.cc.SPACE:case ra1.cc.TAB:case ra1.cc.CR:case ra1.cc.NL:if(X>=0)Z.push($.subarray(X,Q)),X=-1;break;default:if(X<0)X=Q}if(X>=0)Z.push($.subarray(X));switch(Z.length){case 3:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(Z[2],$y);break;case 4:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=Z[2],this.ma.size=this.protoParseInt(Z[3],$y);break;default:throw this.fail($,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail($,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail($,"processMsgArgs Bad or Missing Size Error")}fail($,Z=""){if(!Z)Z=`parse error [${this.state}]`;else Z=`${Z} [${this.state}]`;return Error(`${Z}: ${cp0.TD.decode($)}`)}processHeaderMsgArgs($){let Z=[],X=-1;for(let Q=0;Q<$.length;Q++)switch($[Q]){case ra1.cc.SPACE:case ra1.cc.TAB:case ra1.cc.CR:case ra1.cc.NL:if(X>=0)Z.push($.subarray(X,Q)),X=-1;break;default:if(X<0)X=Q}if(X>=0)Z.push($.subarray(X));switch(Z.length){case 4:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(Z[2],$y),this.ma.size=this.protoParseInt(Z[3],$y);break;case 5:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=Z[2],this.ma.hdr=this.protoParseInt(Z[3],$y),this.ma.size=this.protoParseInt(Z[4],$y);break;default:throw this.fail($,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail($,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail($,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail($,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt($,Z){if($.length===0||$.length>15)return-1;let X=0;for(let Q=0;Q<$.length;Q++){if($[Q]<ta1||$[Q]>Hs8)return-1;X=X*10+($[Q]-ta1)}return Z!==void 0&&X>Z?-1:X}}ra1.Parser=oa1;ra1.State={OP_START:0,OP_PLUS:1,OP_PLUS_O:2,OP_PLUS_OK:3,OP_MINUS:4,OP_MINUS_E:5,OP_MINUS_ER:6,OP_MINUS_ERR:7,OP_MINUS_ERR_SPC:8,MINUS_ERR_ARG:9,OP_M:10,OP_MS:11,OP_MSG:12,OP_MSG_SPC:13,MSG_ARG:14,MSG_PAYLOAD:15,MSG_END:16,OP_H:17,OP_P:18,OP_PI:19,OP_PIN:20,OP_PING:21,OP_PO:22,OP_PON:23,OP_PONG:24,OP_I:25,OP_IN:26,OP_INF:27,OP_INFO:28,OP_INFO_SPC:29,INFO_ARG:30};ra1.cc={CR:13,E:69,e:101,F:70,f:102,G:71,g:103,H:72,h:104,I:73,i:105,K:75,k:107,M:77,m:109,MINUS:45,N:78,n:110,NL:10,O:79,o:111,P:80,p:112,PLUS:43,R:82,r:114,S:83,s:115,SPACE:32,TAB:9}});var N70=v((sa1)=>{Object.defineProperty(sa1,"__esModule",{value:!0});sa1.MsgHdrsImpl=void 0;sa1.canonicalMIMEHeaderKey=mp0;sa1.headers=Us8;var aa1=$G(),g3=tB(),F70=ZG();function mp0($){let F=!0,N=Array($.length);for(let U=0;U<$.length;U++){let B=$.charCodeAt(U);if(B===58||B<33||B>126)throw F70.InvalidArgumentError.format("header",`'${$[U]}' is not a valid character in a header name`);if(F&&97<=B&&B<=122)B-=32;else if(!F&&65<=B&&B<=90)B+=32;N[U]=B,F=B==45}return String.fromCharCode(...N)}function Us8($=0,Z=""){if($===0&&Z!=="")throw F70.InvalidArgumentError.format("code","is required");else if($>0&&Z==="")throw F70.InvalidArgumentError.format("description","is required");return new Zy($,Z)}var dp0="NATS/1.0";class Zy{_code;headers;_description;constructor($=0,Z=""){this._code=$,this._description=Z,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals($){if($&&this.headers.size===$.headers.size&&this._code===$._code){for(let[Z,X]of this.headers){let Q=$.values(Z);if(X.length!==Q.length)return!1;let Y=[...X].sort(),G=[...Q].sort();for(let J=0;J<Y.length;J++)if(Y[J]!==G[J])return!1}return!0}return!1}static decode($){let Z=new Zy,Q=aa1.TD.decode($).split(`\r
|
|
1404
1404
|
`),Y=Q[0];if(Y!==dp0){let G=Y.replace(dp0,"").trim();if(G.length>0){if(Z._code=parseInt(G,10),isNaN(Z._code))Z._code=0;let J=Z._code.toString();G=G.replace(J,""),Z._description=G.trim()}}if(Q.length>=1)Q.slice(1).map((G)=>{if(G){let J=G.indexOf(":");if(J>-1){let K=G.slice(0,J),W=G.slice(J+1).trim();Z.append(K,W)}}});return Z}toString(){if(this.headers.size===0&&this._code===0)return"";let $=dp0;if(this._code>0&&this._description!=="")$+=` ${this._code} ${this._description}`;for(let[Z,X]of this.headers)for(let Q=0;Q<X.length;Q++)$=`${$}\r
|
|
1405
1405
|
${Z}: ${X[Q]}`;return`${$}\r
|
|
@@ -2849,7 +2849,7 @@ ${$.description}
|
|
|
2849
2849
|
`):Z?.feedback?[Z.pr?`A reviewer requested changes on the existing pull request #${Z.pr.number} (${Z.pr.url}):`:"A reviewer requested changes on your previous work:",Z.feedback,Z.pr?`Load the repo, then CHECK OUT that PR's branch (e.g. \`gh pr checkout ${Z.pr.number}\`) before editing, address the feedback, commit, and push to update the SAME pull request \u2014 do NOT open a new one or start a new branch.`:"Address this feedback.",""].join(`
|
|
2850
2850
|
`):Z?.pr?[`This task already has an open pull request #${Z.pr.number} (${Z.pr.url}), and you are already on its branch.`,"Continue that work: commit and push to update the SAME pull request \u2014 do NOT open a new one or start a new branch. If you find it already does everything the task asks, say so and stop rather than changing it.",""].join(`
|
|
2851
2851
|
`):"","How to work:","- First decide whether this task requires changing code in a repository. Some tasks (research, answering a question, planning) don't. If it doesn't, just do the work directly \u2014 don't load a repo or open a PR.",Z?.pr?"- If it DOES need code changes: use the `load_repo` tool to load the relevant repository, make the change, then commit and push to the pull request named above.":"- If it DOES need code changes: use the `load_repo` tool to load the relevant repository, then make the change, commit on a new branch, push, and open a pull request. Only then does a PR apply.","- Prefer the GitHub tool to open the PR. If it errors or targets the wrong repo, fall back to `git push` + the GitHub REST API (the auth token is embedded in the `origin` URL).","- If a dev server is running it hot-reloads your changes \u2014 don't restart it, hunt for its port, or run a full typecheck/build just to verify a small edit.","- Change only what the task needs. Don't trace the definition of a pre-existing symbol that's incidental to your change \u2014 note it in one line and move on. Prefer one or two broad searches over many narrow retries.","- Only if you hit a genuine blocker a human must clear (see above) may you call `user_ask` \u2014 otherwise keep going and finish the task.","",`(task id: ${$.id})`].join(`
|
|
2852
|
-
`)}async function xe4($,Z,X){let Y=(await $.storage.taskBoard.listPrs(Z.id,Z.organizationId).catch(()=>[])).find((G)=>G.number===X);if(!Y)return null;return BC$($,Z.organizationId,Y).catch(()=>null)}async function fe4($,Z){let X=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId).catch(()=>[]);return nB$(X)}function be4($){return $!=="closed"}async function ye4($,Z){let X=await $.storage.taskBoard.listPrs(Z.id,Z.organizationId).catch(()=>[]);for(let Q of X){let{state:Y}=await bu(Z.organizationId,Q);if(be4(Y))return{number:Q.number,url:Q.url}}return}async function yK($,Z,X){let Q=await aB$($,Z,X?.userInitiated?ML():void 0),Y="decopilot";try{let G=y0().taskBoardRerunReusesPrBranch,J=X?.pr??(G?await ye4($,Z):void 0),K=G&&J?await xe4($,Z,J.number):null,W=!X?.feedback&&!X?.resolveConflict,H=J&&W?await fe4($,Z):null,F=J&&J!==X?.pr||H?{...X,...J?{pr:J}:{},...H?{feedback:H}:{}}:X,N=await gA0($,Z.organizationId);if(N){Y="claude-code";let U="repo"in N?N.repo:null;await _a($,Z,{title:`Super Agent: ${Z.title}`,...X?.runClass?{runClass:X.runClass}:{},...K?{pinnedRef:K}:{},prompt:tS$(Z,U,{...F,..."choices"in N?{repoChoices:N.choices}:{}}),temperature:0.5,harnessId:"claude-code",...U?{repo:U}:{}})}else await _a($,Z,{title:`Super Agent: ${Z.title}`,...X?.runClass?{runClass:X.runClass}:{},prompt:ve4(Z,F),temperature:0.5,...K?{pinnedRef:K}:{}})}catch(G){throw await sB$($.storage.organizationBilling,Z.organizationId,Z.id,Q),G}await $.storage.taskBoard.supersedeFailedThreads(Z.id,Z.organizationId).catch((G)=>console.error("[task-board] superseding failed threads failed",G)),NG({event:"task_run_enqueued",organizationId:Z.organizationId,properties:{task_id:Z.id,reports_task:KY(Z),claim:Q,harness:Y,...X?.runClass?{run_class:X.runClass}:{}}})}var vH=L(()=>{B9();xJ();B9();f4();V$();vZ1();tJ();xa();qZ1()});import{z as iK}from"zod";var Pv;var dZ1=L(()=>{k0();o51();vK();r51();vH();qX();q5();Vu();Pv=c({name:"TASK_BOARD_ITEM_CREATE",description:"Create a new task board item for the organization.",annotations:{title:"Create Task Board Item",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:iK.object({title:iK.string().min(1),description:iK.string().nullable().optional(),status:_K.optional(),priority:Xv.optional(),assigneeId:iK.string().nullable().optional(),repo:iK.string().nullable().optional(),dueDate:iK.string().datetime().nullable().optional(),sprint:iK.number().int().min(1).max(vP0).nullable().optional().describe("Sprint to plan this task into (1-based, counted from the org's sprint cadence). Omit or null to leave it in the backlog."),tagIds:iK.array(iK.string()).optional(),prUrl:iK.string().nullable().optional().describe('GitHub pull request URL to link to the new task, e.g. https://github.com/owner/repo/pull/123. Pass this with `status: "in_review"` right after you open a PR so the card lands on the board with its PR already attached for review.')}),outputSchema:iK.object({item:Eu}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=$.prUrl?FD($.prUrl):null;if($.prUrl&&!Q)throw Error(`Not a GitHub pull request URL: ${$.prUrl} (expected https://github.com/<owner>/<repo>/pull/<number>)`);if($.assigneeId)await xP0(Z,X,$.assigneeId);let Y=$.assigneeId===E8;if($.tagIds?.length){let J=await Z.storage.tags.listOrgTags(X),K=new Set(J.map((W)=>W.id));for(let W of $.tagIds)if(!K.has(W))throw Error(`Tag not found: ${W}`)}let G=await Z.storage.taskBoard.create({organizationId:X,title:$.title,description:$.description??null,status:Y?"todo":$.status,priority:$.priority,assigneeId:$.assigneeId??null,assignedBy:$.assigneeId?a0(Z):null,repo:$.repo??null,dueDate:$.dueDate??null,sprint:$.sprint??null,by:a0(Z)});if($.tagIds?.length)await Z.storage.taskBoard.setItemTags(G.id,$.tagIds,a0(Z)),G=await Z.storage.taskBoard.getById(G.id,X);if(Q)await Z.storage.taskBoard.linkPr({taskBoardItemId:G.id,organizationId:X,url:Q.url,prNumber:Q.number,repoOwner:Q.owner,repoName:Q.repo,connectionId:null});return await O6(Z,{taskBoardItemId:G.id,action:"created",actorId:a0(Z),alsoSubscribe:[a0(Z),G.assigneeId===E8?null:G.assigneeId]}),await Z.storage.notifications.notifyMentions({taskBoardItemId:G.id,organizationId:X,actorId:a0(Z),body:G.description??""}),d$(X,G),await BD(Z,G),{item:G}}})});import{z as xv}from"zod";var AX1;var cf$=L(()=>{k0();Vu();q5();Zv();AX1=c({name:"TASK_BOARD_ITEM_PR_LINK",description:"Link the pull request you just opened to this run's task board item. Call this right after `gh pr create` succeeds, with the PR URL it printed. Reviewers (QA, code review) are dispatched from the linked PR, so a task whose PR is not linked never gets reviewed.",annotations:{title:"Link Pull Request to Task",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:xv.object({url:xv.string().describe("The pull request URL, e.g. https://github.com/owner/repo/pull/123")}),outputSchema:xv.object({url:xv.string(),prNumber:xv.number(),taskBoardItemIds:xv.array(xv.string())}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z).id,{threadId:Q}=_P0(),Y=FD($.url);if(!Y)throw Error(`Not a GitHub pull request URL: ${$.url} (expected https://github.com/<owner>/<repo>/pull/<number>)`);let G=await Cu(Z,X,Q);for(let J of G)await Z.storage.taskBoard.linkPr({taskBoardItemId:J,organizationId:X,url:Y.url,prNumber:Y.number,repoOwner:Y.owner,repoName:Y.repo}),await Z.storage.taskBoard.clearSweepBudget(J,X);return{url:Y.url,prNumber:Y.number,taskBoardItemIds:G}}})});function df$($){lf$=$}function _T0($){lf$?.broadcast($)}var lf$=null;import{DBOS as vT0}from"@dbos-inc/dbos-sdk";function ge4($,Z){let X=`thread-run:${Z}:`;if(!$.workflowID.startsWith(X))return null;let Q=$.input?.[0],Y=Q?.request;return{workflowId:$.workflowID,messageId:Y?.messageId??$.workflowID.slice(X.length),status:$.status==="PENDING"?"running":"queued",enqueuedAt:$.createdAt,...Q?.source!==void 0?{source:Q.source}:{}}}async function TX1($){return(await vT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING","ENQUEUED"],loadInput:!0,loadOutput:!1})).map((X)=>ge4(X,$)).filter((X)=>X!==null).sort((X,Q)=>X.enqueuedAt-Q.enqueuedAt)}async function mf$($,Z){if(!Z.startsWith(`thread-run:${$}:`))return!1;return await vT0.cancelWorkflows([Z]),!0}async function au($){let Z=await vT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING"],loadInput:!1,loadOutput:!1});if(Z.length===0)return;await vT0.cancelWorkflows(Z.map((X)=>X.workflowID))}var xT0=()=>{};function ce4($){return/\b405\b/.test($)&&/not allowed on this repository/i.test($)}function de4($,Z={}){if($==="failing")return!0;if($==="pending")return!Z.allowPendingChecks;return!1}async function me4($,Z,X,Q,Y){if(le4.has(Q))return;let J=(await $.storage.taskBoard.listActivity(X,Z).catch(()=>[])).at(-1);if(J?.action==="merge_failed"&&J.data?.reason===Q)return;await O6($,{taskBoardItemId:X,action:"merge_failed",actorId:null,data:{reason:Q,...Y?{detail:Y}:{}}})}function ie4($){if(!$?.isError)return{kind:"merged"};let Z=JSON.stringify($?.content)??"";if(ce4(Z))return{kind:"method_not_allowed",detail:Z};if(mA0(Z))return{kind:"rate_limited",detail:Z};return{kind:"refused",detail:Z}}async function pe4($,Z,X){let Q=await $.callTool({name:"merge_pull_request",arguments:{owner:Z.repoOwner,repo:Z.repoName,pullNumber:Z.number,merge_method:X}},void 0,{timeout:he4});return ie4(Q)}async function Ys($,Z,X,Q={}){let Y=async(N,U)=>{return await me4($,Z,X,N,U),{merged:!1,reason:N,...U?{detail:U}:{}}},G=await $.storage.taskBoard.listPrs(X,Z),J=await LD($,Z,G);if(!J)return console.warn(`[task-board] merge skipped \u2014 no linked PR on ${X}`),Y("no_pr");let K=await FC$($,Z,J);if(de4(K,Q))return console.warn(`[task-board] merge blocked \u2014 checks ${K} on PR #${J.number}`),Y(K==="failing"?"checks_failing":"checks_pending");let W=`${J.repoOwner}/${J.repoName}`,H=await jv($,Z,J.connectionId,{owner:J.repoOwner,name:J.repoName});if(!H)return console.warn("[task-board] merge blocked \u2014 no active GitHub connection for "+`${W} (PR #${J.number})`),Y("no_connection",W);let F=await z5(H,$,!0);try{let N=null;for(let U of ue4){let B=await pe4(F,J,U);if(B.kind==="merged")return YC$(H.id),{merged:!0};if(B.kind==="rate_limited")return console.warn(`[task-board] merge rate-limited on PR #${J.number} \u2014 sweep retries`),Y("rate_limited",B.detail.slice(0,500));if(B.kind==="method_not_allowed"){console.warn(`[task-board] merge method '${U}' not allowed on ${W} \u2014 trying next`),N=B.detail;continue}return console.error(`[task-board] merge refused by GitHub on PR #${J.number}:`,B.detail),Y("refused",B.detail.slice(0,500))}return console.error(`[task-board] no merge method allowed on ${W} (PR #${J.number})`,N),Y("refused",N?.slice(0,500))}catch(N){let U=N instanceof Error?N.message:String(N);if(mA0(N))return Y("rate_limited",U);return console.error("[task-board] merge PR failed",N),Y("error",U)}finally{await F.close().catch(()=>{})}}async function Gs($,Z,X){let Q=await $.storage.organizationSettings.get(Z),Y=fN(Q?.flags),G=await $.storage.taskBoard.listActivity(X,Z);return qL(G,Y,{verifiedOnly:!0})}async function ne4($,Z){let X=await $.storage.organizationSettings.get(Z.organizationId),Q=fN(X?.flags),Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId);if(!pB$(Y,Q))return;await xH($,Z,"every reviewer approved, but an approval could not be verified \u2014 "+"auto-merge is blocked and no reviewer can be re-dispatched this cycle")}function if$($){return!$.merged&&$.reason==="refused"}function RX1($,Z){if($!==null)return $;if(Z===null||!if$(Z))return null;return(Z.detail??"").toLowerCase().includes("merge conflict")?!0:null}async function te4($,Z,X){if(!if$(X))return;let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q),G=await LD($,Q,Y);if(!G)return;await fu($,Q,Z,{pr:{number:G.number,url:G.url},conflict:RX1(await OD($,Q,G),X)}).catch((J)=>{console.error("[task-board] sweep conflict auto-resolve failed",J)})}async function pf$($,Z){let X=Z.organizationId;if(Z.status!=="in_review")return!1;if((await $.storage.organizationSettings.get(X))?.flags?.auto_merge!==!0)return!1;if(await $.storage.taskBoard.hasHumanRejectedDone(Z.id,X))return!1;if(!await Gs($,X,Z.id))return await ne4($,Z),!1;let Y=await Ys($,X,Z.id);if(!Y.merged)return await te4($,Z,Y),!1;let G=await $.storage.taskBoard.update(Z.id,X,{status:"done"},Z.updatedBy);return await O6($,{taskBoardItemId:Z.id,action:"status_changed",actorId:null,data:{from:Z.status,to:"done"}}),d$(X,G),!0}var he4=15000,ue4,le4;var Js=L(()=>{kN();B9();qX();va();tJ();q5();ue4=["merge","squash","rebase"];le4=new Set(["checks_pending"])});import{z as su}from"zod";function re4($){return $.threads.filter((Z)=>Z.status!==null&&!Ia.has(Z.status)).map((Z)=>Z.threadId)}async function ae4($,Z,X){let Q=(G)=>(J)=>console.error("[task-board] rerun takeover step failed",{threadId:Z,step:G,err:J});await $.storage.threads.setCancelRequested(Z,X).catch(Q("cancel-flag")),await mu(Z).catch(Q("background-jobs")),await au(Z).catch(Q("gate-head"));let Y=await $.storage.threads.getRunFence(Z).catch(()=>null);if(Y)await vv(Z,Y).catch(Q("hosted-harness"));_T0(Z)}function se4($,Z){return $===!0&&xZ1(Z)}async function ee4($,Z,X){let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q).catch(()=>[]),G=await LD($,Q,Y).catch(()=>{return});if(!G)return!1;let J=await OD($,Q,G).catch(()=>null);return se4(J,X)}function Z06($,Z){let X=bN($),Q=0;for(let Y of $){if(Y.action!=="review_approved")continue;let G=new Date(Y.occurredAt).getTime();if(G>=X)Q=Math.max(Q,G)}return Z-Q>=$06}async function X06($,Z){if(Z.status!=="in_review")return;if((await $.storage.organizationSettings.get(Z.organizationId))?.flags?.auto_merge!==!0)return;if(!await Gs($,Z.organizationId,Z.id))return;let Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId).catch(()=>[]);if(Z06(Y,Date.now()))return;if(await ee4($,Z,Y))return;throw Error("Every reviewer approved this task and its merge is retrying \u2014 re-running "+"would throw that away and start a new review cycle. Wait for the merge, or use the ship button if the PR needs a nudge.")}var oe4="Superseded by a manual re-run of this task",$06=900000,IX1;var nf$=L(()=>{k0();B9();_H();JU();xT0();iu();qX();q5();vH();Js();tJ();va();xJ();IX1=c({name:"TASK_BOARD_ITEM_RERUN",description:"Re-run a task board item with the Super Agent, whatever lane it is in. Use this to retry a task that stalled, finished without doing the job, or is already assigned to the Super Agent (in which case re-assigning it does nothing). Fails any run still holding the task open, moves it to In Progress, and queues a fresh run.",annotations:{title:"Re-run Task",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:su.object({id:su.string().describe("The task board item to re-run.")}),outputSchema:su.object({status:su.string().describe("The task's lane after the re-run was queued."),supersededThreadIds:su.array(su.string()).describe("Runs that were failed to make room for this one.")}),handler:async({id:$},Z)=>{s(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);if(Q.assigneeId!==E8)throw Error("Only a task assigned to the Super Agent can be re-run. Assign it to "+"the Super Agent instead \u2014 that queues a run by itself.");await X06(Z,Q),await xh(Z,Q,ML());let Y=[];for(let J of re4(Q)){if(!await Z.storage.threads.failIfNotTerminal(J,oe4,"superseded"))continue;Y.push(J),await ae4(Z,J,X)}let G=await Z.storage.taskBoard.update($,X,{status:"in_progress"},a0(Z));return await O6(Z,{taskBoardItemId:$,action:"status_changed",actorId:a0(Z),data:{from:Q.status,to:"in_progress",reason:"rerun"}}),d$(X,G),await yK(Z,G,{userInitiated:!0}),{status:G.status,supersededThreadIds:Y}}})});import{z as Ks}from"zod";var qX1;var tf$=L(()=>{k0();xJ();qX();q5();vH();tJ();qX1=c({name:"TASK_BOARD_RESOLVE_CONFLICT",description:"Hand a task's pull request back to the Super Agent to resolve a merge conflict with its base branch. Use when a reviewed PR can't be shipped because it conflicts. Bounces the task to In Progress and queues a run that checks out the existing PR's branch, merges the base, resolves the conflicts, and pushes to the same PR.",annotations:{title:"Resolve Merge Conflict",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:Ks.object({id:Ks.string().describe("The task board item whose PR conflicts."),prNumber:Ks.number().describe("The conflicting pull request's number, linked to this task.")}),outputSchema:Ks.object({status:Ks.string().describe("The task's lane after the resolution run was queued.")}),handler:async({id:$,prNumber:Z},X)=>{s(X),await X.access.check();let Q=X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let Y=await X.storage.taskBoard.getById($,Q);if(!Y)throw Error(`Task board item not found: ${$}`);let J=(await X.storage.taskBoard.listPrs($,Q)).find((H)=>H.number===Z);if(!J)throw Error(`Pull request #${Z} is not linked to this task.`);if(await OD(X,Q,J).catch(()=>null)!==!0)throw Error("This pull request no longer has a merge conflict \u2014 refresh and try again.");await xh(X,Y,ML());let W=await X.storage.taskBoard.claimConflictResolution($,Q,a0(X));if(!W)throw Error("Couldn't start conflict resolution \u2014 the task may have moved, been "+"reassigned, or already be resolving. Refresh and try again.");d$(Q,W);try{await yK(X,W,{pr:{number:J.number,url:J.url},resolveConflict:!0,runClass:"retry",userInitiated:!0})}catch(H){throw await X.storage.taskBoard.update(W.id,Q,{status:"in_review"},"system").then((F)=>d$(Q,F)).catch((F)=>console.error("[task-board] resolve-conflict status revert failed",F)),H}return await O6(X,{taskBoardItemId:$,action:"merge_conflict_resolution",actorId:null,data:{prNumber:J.number}}),{status:W.status}}})});import{z as TD}from"zod";function Q06($,Z,X){return $!==null&&$.reviewer===Z&&$.cycleAt.getTime()===X}function Y06($,Z){return t$1($).get(Z)==="changes_requested"}var MX1;var of$=L(()=>{k0();B9();vK();qX();q5();vH();Js();tJ();VZ1();va();xJ();MX1=c({name:"TASK_BOARD_REVIEW_DECISION",description:"Record a reviewer's decision for a task under review. `approve` marks the pull request approved by that reviewer (and, once EVERY enabled reviewer has approved, merges it when the org enabled auto-merge, advancing the task to Done); `request_changes` hands the task back to the Super Agent with your notes so it can fix the PR.",annotations:{title:"Review Decision",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:TD.object({taskBoardItemId:TD.string(),reviewer:TD.enum(["qa","code_review"]).describe("Which reviewer you are: `qa` (QA Agent) or `code_review` (Code Reviewer)."),reviewToken:TD.string().optional().describe("The reviewToken from your prompt \u2014 proves you are this reviewer. "+"Pass it through exactly; an approval without a valid token is recorded but does NOT count toward an automatic merge."),decision:TD.enum(["approve","request_changes"]),notes:TD.string().min(1).describe("For approve: a short summary of what you verified. For request_changes: specific, actionable feedback the Super Agent must address.")}),outputSchema:TD.object({status:_K,merged:TD.boolean().describe("True when this approval completed the review and merged the PR.")}),handler:async({taskBoardItemId:$,reviewer:Z,reviewToken:X,decision:Q,notes:Y},G)=>{s(G),await G.access.check();let J=G.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let K=await G.storage.taskBoard.getById($,J);if(!K)throw Error(`Task board item not found: ${$}`);let W=X?bN(await G.storage.taskBoard.listActivity($,J)):0,H=!!X&&(oS$(X,$,Z,new Date(W))||Q06(await G.storage.taskBoard.resolveReviewClaimByToken($,X),Z,W));if(Q==="request_changes"){let j=await G.storage.taskBoard.listActivity($,J);if(Y06(j,Z))return{status:K.status,merged:!1};if(tB$(j))return await O6(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H,bounceLimitReached:!0}}),await xH(G,K,`${o$1} review bounces reached \u2014 the reviewer and the `+"Super Agent are not converging"),{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};let z=await G.storage.taskBoard.claimReviewChangesBounce($,J,K.updatedBy);if(await O6(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!z)return{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};d$(J,z);let A=await G.storage.taskBoard.listPrs($,J),P=await LD(G,J,A);return await yK(G,z,{feedback:`${_h[Z]}: ${Y}`,pr:P?{number:P.number,url:P.url}:void 0}).catch(async(R)=>{if(await xA0(G,z,R)){await G.storage.taskBoard.update(z.id,J,{status:"in_review"},"system").then((M)=>d$(J,M)).catch((M)=>console.error("[task-board] runs-exhausted status revert failed",M));return}if(R instanceof DX)throw R;console.error("[task-board] request_changes re-enqueue failed",R)}),{status:z.status,merged:!1}}if(await O6(G,{taskBoardItemId:$,action:"review_approved",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!await Gs(G,J,$)){let j=await G.storage.taskBoard.getById($,J)??K;return d$(J,j),{status:j.status,merged:!1}}let U=(await G.storage.organizationSettings.get(J))?.flags?.auto_merge===!0,B=await G.storage.taskBoard.hasHumanRejectedDone($,J),O=U&&!B,D=O?await Ys(G,J,$):null;if(D?.merged===!0){let j=await G.storage.taskBoard.update($,J,{status:"done"},K.updatedBy);return await O6(G,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:K.status,to:"done"}}),d$(J,j),{status:j.status,merged:!0}}let E=await G.storage.taskBoard.getById($,J)??K;if(O){let j=await G.storage.taskBoard.listPrs($,J),z=await LD(G,J,j);if(z?await fu(G,J,E,{pr:{number:z.number,url:z.url},conflict:RX1(await OD(G,J,z),D)}).catch((P)=>{if(P instanceof DX)throw P;return console.error("[task-board] conflict auto-resolve failed",P),!1}):!1)return{status:(await G.storage.taskBoard.getById($,J)??E).status,merged:!1}}return d$(J,E),{status:E.status,merged:!1}}})});import{z as fT0}from"zod";function G06($,Z,X){if($!=="in_review")return!1;return X.length===0||qL(Z,X)}var VX1;var rf$=L(()=>{k0();B9();vK();qX();q5();Js();VX1=c({name:"TASK_BOARD_PROMOTE_TO_PRODUCTION",description:"Ship a reviewed task: merge its open pull request and move the task to Done. Used by the board's 'Ship to production' button after the enabled reviewers approved, when auto-merge is off (a human does the final merge).",annotations:{title:"Ship to Production",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:fT0.object({taskBoardItemId:fT0.string()}),outputSchema:fT0.object({status:_K,merged:fT0.boolean().describe("True when the PR was merged.")}),handler:async({taskBoardItemId:$},Z)=>{s(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);let Y=await Z.storage.organizationSettings.get(X),G=fN(Y?.flags),J=await Z.storage.taskBoard.listActivity($,X);if(!G06(Q.status,J,G))throw Error("Task is not ready to ship: it must be In Review with every enabled reviewer approved");if(!(await Ys(Z,X,$,{allowPendingChecks:!0})).merged){let H=await Z.storage.taskBoard.getById($,X)??Q;return d$(X,H),{status:Q.status,merged:!1}}let W=await Z.storage.taskBoard.update($,X,{status:"done"},Q.updatedBy);if(Q.status!=="done")await O6(Z,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:Q.status,to:"done"}});return d$(X,W),{status:W.status,merged:!0}}})});import{z as sJ}from"zod";function af$($){if(!$)throw Error("Organization ID required (no active organization in context)");return $}var J06,kX1,SX1;var sf$=L(()=>{k0();J06=sJ.object({externalKey:sJ.string(),dismissedBy:sJ.string(),dismissedAt:sJ.string()});kX1=c({name:"TASK_BOARD_DISMISSED_LIST",description:"List the diagnostic findings this organization has dismissed by deleting their task board cards. The import skips these until they're restored.",annotations:{title:"List Dismissed Findings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:sJ.object({}),outputSchema:sJ.object({findings:sJ.array(J06)}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=af$(Z.organization?.id);return{findings:await Z.storage.taskBoard.listDismissedFindings(X)}}}),SX1=c({name:"TASK_BOARD_DISMISSED_RESTORE",description:"Un-dismiss diagnostic findings, returning their cards to the board. Omit externalKeys to restore every dismissed finding.",annotations:{title:"Restore Dismissed Findings",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:sJ.object({externalKeys:sJ.array(sJ.string()).optional()}),outputSchema:sJ.object({restored:sJ.number()}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=af$(Z.organization?.id);return{restored:await Z.storage.taskBoard.restoreDismissedFindings(X,$.externalKeys)}}})});import{z as s6}from"zod";function bT0($){let Z=$.organization?.id;if(!Z)throw Error("Organization ID required (no active organization in context)");return Z}function W06($,Z,X){return $.replace(K06,(Q,Y,G,J)=>{let K=encodeURIComponent(`${Z}/${G}`);return`${Y}/api/${encodeURIComponent(X)}/fs/outputs/read?path=${K}${J}`})}var CX1,_X1,K06,vX1,xX1,fX1;var ef$=L(()=>{k0();B9();CA0();Zv();CX1=s6.object({id:s6.string(),taskBoardItemId:s6.string(),parentId:s6.string().nullable(),authorId:s6.string(),body:s6.string(),resolved:s6.boolean(),createdAt:s6.string(),updatedAt:s6.string()});_X1=c({name:"TASK_BOARD_COMMENT_LIST",description:"List a task board item's comments (flat, oldest first; replies carry parentId).",annotations:{title:"List Task Comments",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:s6.object({taskBoardItemId:s6.string()}),outputSchema:s6.object({comments:s6.array(CX1)}),handler:async($,Z)=>{return s(Z),await Z.access.check(),{comments:await Z.storage.taskBoard.listComments($.taskBoardItemId,bT0(Z))}}}),K06=/(!\[[^\]]*\]\()org\/output\/([^)\s]+)(\))/g;vX1=c({name:"TASK_BOARD_COMMENT_CREATE",description:"Post a comment on a task board item, or a reply to one.",annotations:{title:"Create Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:s6.object({taskBoardItemId:s6.string(),body:s6.string().trim().min(1),parentId:s6.string().nullish()}),outputSchema:s6.object({comment:CX1}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=bT0(Z),Q=$v.getStore(),Y=Z.organization?.slug,G=Q?.threadId&&Y?W06($.body,Q.threadId,Y):$.body,J=await Z.storage.taskBoard.createComment({taskBoardItemId:$.taskBoardItemId,organizationId:X,parentId:$.parentId??null,authorId:Q?E8:a0(Z),body:G});if(!J)throw Error("Task board item not found");return await Z.storage.notifications.notify({taskBoardItemId:J.taskBoardItemId,type:"commented",actorId:Q?null:a0(Z),alsoSubscribe:Q?[]:[a0(Z)]}),await Z.storage.notifications.notifyMentions({taskBoardItemId:J.taskBoardItemId,organizationId:X,actorId:Q?null:a0(Z),body:J.body}),await DZ1(Z,{commentId:J.id,taskBoardItemId:J.taskBoardItemId,organizationId:X,authorLabel:Q?"Super Agent":Z.auth?.user?.name??Z.auth?.user?.email??"Studio",body:J.body}),{comment:J}}}),xX1=c({name:"TASK_BOARD_COMMENT_UPDATE",description:"Edit your own comment's body, or resolve/unresolve a comment thread (root only, any org member may toggle it).",annotations:{title:"Update Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:s6.object({id:s6.string(),body:s6.string().trim().min(1).optional(),resolved:s6.boolean().optional()}),outputSchema:s6.object({comment:CX1}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=await Z.storage.taskBoard.updateComment({id:$.id,organizationId:bT0(Z),callerId:a0(Z),body:$.body,resolved:$.resolved});if(!X)throw Error("Comment not found, or you can only edit your own comments");return{comment:X}}}),fX1=c({name:"TASK_BOARD_COMMENT_DELETE",description:"Delete your own comment. Deleting a thread root deletes its replies too.",annotations:{title:"Delete Task Comment",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:s6.object({id:s6.string()}),outputSchema:s6.object({success:s6.boolean()}),handler:async($,Z)=>{return s(Z),await Z.access.check(),{success:await Z.storage.taskBoard.deleteComment($.id,bT0(Z),a0(Z))}}})});var $b$=L(()=>{NM$();dZ1();TZ1();RZ1();IZ1();tJ();cf$();nf$();tf$();of$();rf$();qX();sf$();ef$()});function Ws($){let Z=$.organization?.id;if(!Z)throw Error("Organization ID required (no active organization in context)");return Z}async function bX1($,Z){let X=Ws($);if(!await $.storage.taskBoard.getById(Z,X))throw Error("Task board item not found");return X}import{z as kX}from"zod";var F06,Zb$;var Xb$=L(()=>{k0();LA0();F06=kX.object({id:kX.string(),taskBoardItemId:kX.string(),type:kX.enum(OA0),taskTitle:kX.string(),taskKeySeq:kX.number().nullable(),actorName:kX.string().nullable(),actorImage:kX.string().nullable(),createdAt:kX.string()}),Zb$=c({name:"NOTIFICATION_LIST",description:"List the current user's unread notifications in the current organization, newest first.",annotations:{title:"List Notifications",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:kX.object({cursor:kX.string().optional(),limit:kX.number().int().positive().max(50).optional()}),outputSchema:kX.object({notifications:kX.array(F06),unreadCount:kX.number(),nextCursor:kX.string().nullable()}),handler:async($,Z)=>{s(Z),await Z.access.check();let{notifications:X,unreadCount:Q,nextCursor:Y}=await Z.storage.notifications.listUnread(a0(Z),Ws(Z),{cursor:$.cursor,limit:$.limit});return{notifications:X.map((G)=>({id:G.id,taskBoardItemId:G.taskBoardItemId,type:G.type,taskTitle:G.data.taskTitle,taskKeySeq:G.data.taskKeySeq,actorName:G.data.actorName,actorImage:G.data.actorImage,createdAt:G.createdAt})),unreadCount:Q,nextCursor:Y}}})});import{z as Hs}from"zod";var Qb$;var Yb$=L(()=>{k0();Qb$=c({name:"NOTIFICATION_MARK_READ",description:"Mark notifications read. Omit `ids` to mark all of the current user's unread ones in this organization.",annotations:{title:"Mark Notifications Read",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Hs.object({ids:Hs.array(Hs.string()).optional()}),outputSchema:Hs.object({marked:Hs.number()}),handler:async($,Z)=>{return s(Z),await Z.access.check(),{marked:await Z.storage.notifications.markRead(a0(Z),Ws(Z),$.ids)}}})});import{z as cH}from"zod";var Gb$,Jb$;var Kb$=L(()=>{k0();Gb$=c({name:"NOTIFICATION_SUBSCRIPTION_SET",description:"Follow or unfollow a task board item.",annotations:{title:"Set Notification Subscription",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:cH.object({taskBoardItemId:cH.string(),subscribed:cH.boolean()}),outputSchema:cH.object({subscribed:cH.boolean()}),handler:async($,Z)=>{return s(Z),await Z.access.check(),await bX1(Z,$.taskBoardItemId),await Z.storage.notifications.setSubscribed(a0(Z),$.taskBoardItemId,$.subscribed),{subscribed:$.subscribed}}}),Jb$=c({name:"NOTIFICATION_SUBSCRIPTION_LIST",description:"List the user ids following a task board item.",annotations:{title:"List Notification Subscribers",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:cH.object({taskBoardItemId:cH.string()}),outputSchema:cH.object({userIds:cH.array(cH.string())}),handler:async($,Z)=>{return s(Z),await Z.access.check(),await bX1(Z,$.taskBoardItemId),{userIds:await Z.storage.notifications.listSubscribers($.taskBoardItemId)}}})});var Wb$=L(()=>{Xb$();Yb$();Kb$()});import{z as NU}from"zod";var yX1;var Hb$=L(()=>{k0();yX1=c({name:"TAGS_LIST",description:"List all tags available in the organization.",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:NU.object({}),outputSchema:NU.object({tags:NU.array(NU.object({id:NU.string(),organizationId:NU.string(),name:NU.string(),color:NU.string().nullable(),createdAt:NU.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z);return{tags:(await Z.storage.tags.listOrgTags(X.id)).map((Y)=>({...Y,createdAt:Y.createdAt instanceof Date?Y.createdAt.toISOString():String(Y.createdAt)}))}}})});import{z as lH}from"zod";var gX1;var Fb$=L(()=>{k0();gX1=c({name:"TAGS_CREATE",description:"Create a new tag, usable on organization members and task board items.",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:lH.object({name:lH.string().min(1).max(50).describe("Tag name"),color:lH.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional().describe('Hex color the tag renders its dot with, e.g. "#3b82f6"')}),outputSchema:lH.object({tag:lH.object({id:lH.string(),organizationId:lH.string(),name:lH.string(),color:lH.string().nullable(),createdAt:lH.string().describe("ISO 8601 timestamp")})}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z),Q=await Z.storage.tags.createTag(X.id,$.name,$.color);return{tag:{...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}}}})});import{z as yT0}from"zod";var hX1;var Nb$=L(()=>{k0();hX1=c({name:"TAGS_DELETE",description:"Delete a tag and automatically remove it from all assigned members.",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:yT0.object({tagId:yT0.string().describe("Tag ID to delete")}),outputSchema:yT0.object({success:yT0.boolean()}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z),Q=await Z.storage.tags.getTag($.tagId);if(!Q)throw Error("Tag not found");if(Q.organizationId!==X.id)throw Error("Tag does not belong to this organization");return await Z.storage.tags.deleteTag($.tagId),{success:!0}}})});import{z as dH}from"zod";var uX1;var Ub$=L(()=>{k0();uX1=c({name:"MEMBER_TAGS_GET",description:"Get all tags currently assigned to a specific member.",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:dH.object({memberId:dH.string().describe("Member ID")}),outputSchema:dH.object({tags:dH.array(dH.object({id:dH.string(),organizationId:dH.string(),name:dH.string(),color:dH.string().nullable(),createdAt:dH.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);return{tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});import{z as eJ}from"zod";var cX1;var Bb$=L(()=>{k0();cX1=c({name:"MEMBER_TAGS_SET",description:"Replace all tags on a member with the given set. Pass empty array to clear.",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:eJ.object({memberId:eJ.string().describe("Member ID"),tagIds:eJ.array(eJ.string()).describe("Array of tag IDs to assign")}),outputSchema:eJ.object({success:eJ.boolean(),tags:eJ.array(eJ.object({id:eJ.string(),organizationId:eJ.string(),name:eJ.string(),createdAt:eJ.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);for(let G of $.tagIds){let J=await Z.storage.tags.getTag(G);if(!J)throw Error(`Tag not found: ${G}`);if(J.organizationId!==X.id)throw Error(`Tag does not belong to this organization: ${G}`)}return await Z.storage.tags.setMemberTags($.memberId,$.tagIds),{success:!0,tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var Ob$=L(()=>{Hb$();Fb$();Nb$();Ub$();Bb$()});import{z as Lb$}from"zod";function L06($,Z){let X=$?.[Z];if(!X)return;return Object.entries(X).filter(([,Y])=>(M7 in Y)).sort(([,Y],[,G])=>(G[M7]?.createdAt??0)-(Y[M7]?.createdAt??0))[0]?.[0]}var B06,O06,lX1;var Db$=L(()=>{f4();k0();Wv();Ou();A7();DY();B06=Lb$.object({data:Ak$.describe("Data for the new thread (id is auto-generated if not provided)")}),O06=Lb$.object({item:SH.describe("The created thread entity")});lX1=c({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread for organizing messages and conversations.",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:B06,outputSchema:O06,handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=a0(Z);if(!Q)throw Error("User ID required to create thread");let{data:Y}=$,G=Y.id??L8("thrd"),K=(await NA0(Z.storage.virtualMcps,Y.virtual_mcp_id,X.id)).metadata,W=K?.githubRepo,H=null;if(W)H=Y.branch??L06(K?.sandboxMap,Q)??p30(i30(Z.auth.user));let F=await Z.storage.threads.create({id:G,organization_id:X.id,title:Y.title,description:Y.description,virtual_mcp_id:Y.virtual_mcp_id,branch:H,created_by:Q,metadata:{runtime:Y.runtime??qP0(K)}});if(F.isNew)h1.capture({distinctId:Q,event:"chat_started",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:G,has_title:!!$.data.title,created_via:"tool"}});return{item:iJ(F)}}})});import{z as dX1}from"zod";var D06,w06,mX1;var wb$=L(()=>{f4();k0();Wv();Ou();D06=dX1.object({id:dX1.string().describe("ID of the thread to update"),data:Tk$.describe("Partial thread data to update")}),w06=dX1.object({item:SH.describe("The updated thread entity")}),mX1=c({name:"COLLECTION_THREADS_UPDATE",description:"Update a thread's title, description, or visibility.",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D06,outputSchema:w06,handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=a0(Z);if(!Q)throw Error("User ID required to update thread");let{id:Y,data:G}=$,J=await Z.storage.threads.get(Y);if(!J)throw Error("Thread not found in organization");if(G.virtual_mcp_id!==void 0)await NA0(Z.storage.virtualMcps,G.virtual_mcp_id,X.id);if(G.branch===null&&J.virtual_mcp_id){if((await Z.storage.virtualMcps.findById(J.virtual_mcp_id,X.id))?.metadata?.githubRepo)throw Error("Cannot set branch=null on a github-linked thread (vMCP has githubRepo)")}let K={title:G.title,description:G.description,hidden:G.hidden,updated_by:Q};if(G.status)K.status=G.status;if(G.metadata!==void 0){let H=Sh(G.metadata)??{},F=e_(J.metadata?.runtime),N=e_(H.runtime);if(F&&N&&N!==F)throw Error(`Cannot change a thread's runtime (${F} \u2192 ${N}); it is stamped once at creation. Start a new chat instead.`);let U=J.metadata?.sandboxMap;K.metadata={...H,...F?{runtime:F}:{},...U!==void 0?{sandboxMap:U}:{}}}if(G.branch!==void 0)K.branch=G.branch;if(G.virtual_mcp_id!==void 0)K.virtual_mcp_id=G.virtual_mcp_id;let W=await Z.storage.threads.update(Y,K);if(G.hidden!==void 0&&G.hidden!==J.hidden)h1.capture({distinctId:Q,event:G.hidden?"chat_archived":"chat_unarchived",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:Y}});return{item:iJ(W)}}})});var iX1;var Eb$=L(()=>{kJ();Wv();f4();k0();JU();xT0();iu();iX1=c({name:"COLLECTION_THREADS_DELETE",description:"Permanently delete a thread and all its messages.",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:co,outputSchema:lo(SH),handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=await Z.storage.threads.get($.id);if(!Q)throw Error(`Thread not found: ${$.id}`);if(Q.status==="in_progress"){let G=(K)=>(W)=>console.error("[thread] delete-time run cancel step failed",{threadId:$.id,step:K,err:W});await mu($.id).catch(G("background-jobs")),await au($.id).catch(G("gate-head"));let J=await Z.storage.threads.getRunFence($.id).catch(()=>null);if(J)await vv($.id,J).catch(G("hosted-harness"));_T0($.id)}await Z.storage.threads.delete($.id);let Y=a0(Z);if(Y)h1.capture({distinctId:Y,event:"chat_deleted",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:$.id}});return{item:iJ(Q)}}})});var jb$=L(()=>{Db$();_91();v91();wb$();Eb$();x91()});function j06($){return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:$}]}]}}function z06($){return $.map((Z)=>{let X=Z.metadata;if(X?.tiptapDoc)return Z;let Q=Z.parts.find((Y)=>Y.type==="text"&&typeof Y.text==="string");if(!Q?.text||typeof Q.text!=="string")return Z;return{...Z,metadata:{...X,tiptapDoc:j06(Q.text)}}})}function gT0($){let Z;if(typeof $==="string")try{let X=JSON.parse($);if(Array.isArray(X)&&X.length>0&&X[0]?.role&&Array.isArray(X[0]?.parts))Z=X;else Z=[{role:"user",parts:[{type:"text",text:$}]}]}catch{Z=[{role:"user",parts:[{type:"text",text:$}]}]}else Z=$;return z06(Z)}import{z as e6}from"zod";var pX1;var zb$=L(()=>{f4();k0();UX();pX1=c({name:"AUTOMATION_CREATE",description:"Create an automation that runs an agent thread on trigger fire. Requires virtual_mcp_id + messages.",annotations:{title:"Create Automation",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:e6.object({name:e6.string().min(1).max(255),virtual_mcp_id:e6.string(),messages:e6.union([e6.string(),e6.array(e6.looseObject({id:e6.string().optional(),role:e6.enum(["user","assistant","system"]),parts:e6.array(e6.record(e6.string(),e6.unknown())),metadata:e6.unknown().optional()}))]),models:e6.object({tier:GL,modelId:e6.string().optional(),credentialId:e6.string().optional()}).loose().default({tier:"smart"}),tools:e6.array(e6.string()).nullable().optional(),maxAgentSteps:e6.number().int().min(1).max(100).nullable().optional(),temperature:e6.number().default(0.5),active:e6.boolean().default(!0)}),outputSchema:e6.object({id:e6.string(),name:e6.string(),active:e6.boolean(),created_at:e6.string()}),handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=a0(Z);if(!Q)throw Error("Unable to determine user identity");let Y=gT0($.messages),G=await Z.storage.automations.create({organization_id:X.id,created_by:Q,name:$.name,messages:JSON.stringify(Y),models:JSON.stringify($.models),tools:$.tools===void 0||$.tools===null?null:JSON.stringify($.tools),max_agent_steps:$.maxAgentSteps??null,temperature:$.temperature,active:$.active,virtual_mcp_id:$.virtual_mcp_id});return h1.capture({distinctId:Q,event:"automation_created",groups:{organization:X.id},properties:{organization_id:X.id,automation_id:G.id,virtual_mcp_id:$.virtual_mcp_id,active:G.active,tier:$.models.tier}}),{id:G.id,name:G.name,active:G.active,created_at:G.created_at}}})});import{z as c6}from"zod";var nX1;var Pb$=L(()=>{k0();nX1=c({name:"AUTOMATION_GET",description:"Get an automation's full configuration and triggers by ID.",annotations:{title:"Get Automation",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:c6.object({id:c6.string()}),outputSchema:c6.object({automation:c6.object({id:c6.string(),name:c6.string(),active:c6.boolean(),created_by:c6.string(),created_at:c6.string(),updated_at:c6.string(),virtual_mcp_id:c6.string(),messages:c6.unknown(),models:c6.unknown(),tools:c6.array(c6.string()).nullable(),maxAgentSteps:c6.number().nullable(),temperature:c6.number(),triggers:c6.array(c6.object({id:c6.string(),type:c6.enum(["cron","event","webhook"]),cron_expression:c6.string().nullable(),connection_id:c6.string().nullable(),event_type:c6.string().nullable(),params:c6.unknown().nullable(),last_run_at:c6.string().nullable(),api_key_id:c6.string().nullable(),created_at:c6.string()}))}).nullable()}),handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=await Z.storage.automations.findById($.id,X.id);if(!Q)return{automation:null};let Y=await Z.storage.automations.listTriggers(Q.id);return{automation:{id:Q.id,name:Q.name,active:Q.active,created_by:Q.created_by,created_at:Q.created_at,updated_at:Q.updated_at,virtual_mcp_id:Q.virtual_mcp_id,messages:JSON.parse(Q.messages),models:JSON.parse(Q.models),tools:Q.tools?JSON.parse(Q.tools):null,maxAgentSteps:Q.max_agent_steps,temperature:Q.temperature,triggers:Y.map((G)=>({id:G.id,type:G.type,cron_expression:G.cron_expression,connection_id:G.connection_id,event_type:G.event_type,params:G.params?JSON.parse(G.params):null,last_run_at:G.last_run_at,api_key_id:G.api_key_id,created_at:G.created_at}))}}}})});import{z as SG}from"zod";var tX1;var Ab$=L(()=>{k0();tX1=c({name:"AUTOMATION_LIST",description:"List automations with their status, triggers, and configuration.",annotations:{title:"List Automations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:SG.object({virtual_mcp_id:SG.string().optional().nullable()}),outputSchema:SG.object({automations:SG.array(SG.object({id:SG.string(),name:SG.string(),active:SG.boolean(),created_by:SG.string(),created_at:SG.string(),trigger_count:SG.number(),nearest_next_run_at:SG.string().nullable(),virtual_mcp_id:SG.string()}))}),handler:async($,Z)=>{s(Z);let X=a(Z);return await Z.access.check(),{automations:(await Z.storage.automations.listWithTriggerCounts(X.id,$.virtual_mcp_id)).map((G)=>({id:G.id,name:G.name,active:G.active,created_by:G.created_by,created_at:G.created_at,trigger_count:G.trigger_count,nearest_next_run_at:G.nearest_next_run_at,virtual_mcp_id:G.virtual_mcp_id}))}}})});function A06($){if(!$)return null;try{let Z=JSON.parse($);if(Array.isArray(Z)&&Z.every((X)=>typeof X==="string"))return Z.length>0?Z:null}catch{}return null}function Tb$($){return`${$}:context`}function Rb$($,Z,X,Q,Y){let J=JSON.parse($.messages).map((H,F)=>({...H,id:`${X}:${F}`})),K=Z?{...Y,[bP0]:P06}:Y;return{messages:J,models:{credentialId:Q.credentialId,thinking:Q.thinking,...Q.image?{image:Q.image}:{},...Q.webSearch?{webSearch:Q.webSearch}:{},...Q.deepResearch?{deepResearch:Q.deepResearch}:{}},agent:{id:$.virtual_mcp_id},toolAllowlist:A06($.tools),maxAgentSteps:$.max_agent_steps??void 0,temperature:$.temperature??0.5,toolApprovalLevel:"auto",mode:"default",organizationId:$.organization_id,userId:$.created_by,harnessId:"decopilot",triggerId:Z??void 0,...K?{runMetadata:K}:{},taskId:X}}var P06="new_task";var Ib$=L(()=>{Fa()});function SX($,Z,X,Q,Y,G,J,K){return SX.fromTZ(SX.tp($,Z,X,Q,Y,G,J),K)}function oX1($,Z=new Date){let X=Z.toLocaleString("en-US",{timeZone:$,timeZoneName:"shortOffset"}).split(" ").slice(-1)[0],Q=Z.toLocaleString("en-US").replace(/[\u202f]/," ");return Date.parse(`${Q} GMT`)-Date.parse(`${Q} ${X}`)}function T06($,Z){let X=new Date(Date.parse($));if(isNaN(X))throw Error("minitz: Invalid ISO8601 passed to parser.");let Q=$.substring(9);return $.includes("Z")||Q.includes("-")||Q.includes("+")?SX.tp(X.getUTCFullYear(),X.getUTCMonth()+1,X.getUTCDate(),X.getUTCHours(),X.getUTCMinutes(),X.getUTCSeconds(),"Etc/UTC"):SX.tp(X.getFullYear(),X.getMonth()+1,X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),Z)}function R06($){if($===void 0&&($={}),delete $.name,$.legacyMode=$.legacyMode===void 0?!0:$.legacyMode,$.paused=$.paused===void 0?!1:$.paused,$.maxRuns=$.maxRuns===void 0?1/0:$.maxRuns,$.catch=$.catch===void 0?!1:$.catch,$.interval=$.interval===void 0?0:parseInt($.interval.toString(),10),$.utcOffset=$.utcOffset===void 0?void 0:parseInt($.utcOffset.toString(),10),$.unref=$.unref===void 0?!1:$.unref,$.startAt&&($.startAt=new $3($.startAt,$.timezone)),$.stopAt&&($.stopAt=new $3($.stopAt,$.timezone)),$.interval!==null){if(isNaN($.interval))throw Error("CronOptions: Supplied value for interval is not a number");if($.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if($.utcOffset!==void 0){if(isNaN($.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if($.utcOffset<-870||$.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if($.utcOffset!==void 0&&$.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if($.unref!==!0&&$.unref!==!1)throw Error("CronOptions: Unref should be either true, false or undefined(false).");return $}function Fs($){return Object.prototype.toString.call($)==="[object Function]"||typeof $=="function"||$ instanceof Function}function I06($){return Fs($)}function q06($){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer($):$&&typeof $.unref<"u"&&$.unref()}var rX1=32,Ns,kb$,qb$=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor($,Z){this.pattern=$,this.timezone=Z,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let $=this.pattern.replace(/\s+/g," ").split(" ");if($.length<5||$.length>6)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five or six space separated parts are required.");if($.length===5&&$.unshift("0"),$[3].indexOf("L")>=0&&($[3]=$[3].replace("L",""),this.lastDayOfMonth=!0),$[3]=="*"&&(this.starDOM=!0),$[4].length>=3&&($[4]=this.replaceAlphaMonths($[4])),$[5].length>=3&&($[5]=this.replaceAlphaDays($[5])),$[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0){let Z=new $3(new Date,this.timezone).getDate(!0);$[0]=$[0].replace("?",Z.getSeconds().toString()),$[1]=$[1].replace("?",Z.getMinutes().toString()),$[2]=$[2].replace("?",Z.getHours().toString()),this.starDOM||($[3]=$[3].replace("?",Z.getDate().toString())),$[4]=$[4].replace("?",(Z.getMonth()+1).toString()),this.starDOW||($[5]=$[5].replace("?",Z.getDay().toString()))}this.throwAtIllegalCharacters($),this.partToArray("second",$[0],0,1),this.partToArray("minute",$[1],0,1),this.partToArray("hour",$[2],0,1),this.partToArray("day",$[3],-1,1),this.partToArray("month",$[4],-1,1),this.partToArray("dayOfWeek",$[5],0,Ns),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray($,Z,X,Q){let Y=this[$],G=$==="day"&&this.lastDayOfMonth;if(Z===""&&!G)throw TypeError("CronPattern: configuration entry "+$+" ("+Z+") is empty, check for trailing spaces.");if(Z==="*")return Y.fill(Q);let J=Z.split(",");if(J.length>1)for(let K=0;K<J.length;K++)this.partToArray($,J[K],X,Q);else Z.indexOf("-")!==-1&&Z.indexOf("/")!==-1?this.handleRangeWithStepping(Z,$,X,Q):Z.indexOf("-")!==-1?this.handleRange(Z,$,X,Q):Z.indexOf("/")!==-1?this.handleStepping(Z,$,X,Q):Z!==""&&this.handleNumber(Z,$,X,Q)}throwAtIllegalCharacters($){for(let Z=0;Z<$.length;Z++)if((Z===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test($[Z]))throw TypeError("CronPattern: configuration entry "+Z+" ("+$[Z]+") contains illegal characters.")}handleNumber($,Z,X,Q){let Y=this.extractNth($,Z),G=parseInt(Y[0],10)+X;if(isNaN(G))throw TypeError("CronPattern: "+Z+" is not a number: '"+$+"'");this.setPart(Z,G,Y[1]||Q)}setPart($,Z,X){if(!Object.prototype.hasOwnProperty.call(this,$))throw TypeError("CronPattern: Invalid part specified: "+$);if($==="dayOfWeek"){if(Z===7&&(Z=0),Z<0||Z>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+Z);this.setNthWeekdayOfMonth(Z,X);return}if($==="second"||$==="minute"){if(Z<0||Z>=60)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="hour"){if(Z<0||Z>=24)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="day"){if(Z<0||Z>=31)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="month"&&(Z<0||Z>=12))throw RangeError("CronPattern: Invalid value for "+$+": "+Z);this[$][Z]=X}handleRangeWithStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(G===null)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+$+"'");let[,J,K,W]=G,H=parseInt(J,10)+X,F=parseInt(K,10)+X,N=parseInt(W,10);if(isNaN(H))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(F))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(N))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(N===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(N>this[Z].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[Z].length+")");if(H>F)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let U=H;U<=F;U+=N)this.setPart(Z,U,Y[1]||Q)}extractNth($,Z){let X=$,Q;if(X.includes("#")){if(Z!=="dayOfWeek")throw Error("CronPattern: nth (#) only allowed in day-of-week field");Q=X.split("#")[1],X=X.split("#")[0]}return[X,Q]}handleRange($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("-");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal range: '"+$+"'");let J=parseInt(G[0],10)+X,K=parseInt(G[1],10)+X;if(isNaN(J))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(J>K)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let W=J;W<=K;W++)this.setPart(Z,W,Y[1]||Q)}handleStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("/");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+$+"'");G[0]===""&&(G[0]="*");let J=0;G[0]!=="*"&&(J=parseInt(G[0],10)+X);let K=parseInt(G[1],10);if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(K===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(K>this[Z].length)throw TypeError("CronPattern: Syntax error, max steps for part is ("+this[Z].length+")");for(let W=J;W<this[Z].length;W+=K)this.setPart(Z,W,Y[1]||Q)}replaceAlphaDays($){return $.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths($){return $.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames($){let Z=$.trim().toLowerCase();return Z==="@yearly"||Z==="@annually"?"0 0 1 1 *":Z==="@monthly"?"0 0 1 * *":Z==="@weekly"?"0 0 * * 0":Z==="@daily"?"0 0 * * *":Z==="@hourly"?"0 * * * *":$}setNthWeekdayOfMonth($,Z){if(typeof Z!="number"&&Z==="L")this.dayOfWeek[$]=this.dayOfWeek[$]|rX1;else if(Z===Ns)this.dayOfWeek[$]=Ns;else if(Z<6&&Z>0)this.dayOfWeek[$]=this.dayOfWeek[$]|kb$[Z-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${Z}, Type: ${typeof Z}`)}},Mb$,UU,$3=class ${tz;ms;second;minute;hour;day;month;year;constructor(Z,X){if(this.tz=X,Z&&Z instanceof Date)if(!isNaN(Z))this.fromDate(Z);else throw TypeError("CronDate: Invalid date passed to CronDate constructor");else if(Z===void 0)this.fromDate(new Date);else if(Z&&typeof Z=="string")this.fromString(Z);else if(Z instanceof $)this.fromCronDate(Z);else throw TypeError("CronDate: Invalid type ("+typeof Z+") passed to CronDate constructor")}isNthWeekdayOfMonth(Z,X,Q,Y){let G=new Date(Date.UTC(Z,X,Q)).getUTCDay(),J=0;for(let K=1;K<=Q;K++)new Date(Date.UTC(Z,X,K)).getUTCDay()===G&&J++;if(Y&Ns&&kb$[J-1]&Y)return!0;if(Y&rX1){let K=new Date(Date.UTC(Z,X+1,0)).getUTCDate();for(let W=Q+1;W<=K;W++)if(new Date(Date.UTC(Z,X,W)).getUTCDay()===G)return!1;return!0}return!1}fromDate(Z){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes()+this.tz,this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),this.apply();else{let X=SX.toTZ(Z,this.tz);this.ms=Z.getMilliseconds(),this.second=X.s,this.minute=X.i,this.hour=X.h,this.day=X.d,this.month=X.m-1,this.year=X.y}else this.ms=Z.getMilliseconds(),this.second=Z.getSeconds(),this.minute=Z.getMinutes(),this.hour=Z.getHours(),this.day=Z.getDate(),this.month=Z.getMonth(),this.year=Z.getFullYear()}fromCronDate(Z){this.tz=Z.tz,this.year=Z.year,this.month=Z.month,this.day=Z.day,this.hour=Z.hour,this.minute=Z.minute,this.second=Z.second,this.ms=Z.ms}apply(){if(this.month>11||this.day>Mb$[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let Z=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes(),this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),!0}else return!1}fromString(Z){if(typeof this.tz=="number"){let X=SX.fromTZISO(Z);this.ms=X.getUTCMilliseconds(),this.second=X.getUTCSeconds(),this.minute=X.getUTCMinutes(),this.hour=X.getUTCHours(),this.day=X.getUTCDate(),this.month=X.getUTCMonth(),this.year=X.getUTCFullYear(),this.apply()}else return this.fromDate(SX.fromTZISO(Z,this.tz))}findNext(Z,X,Q,Y){let G=this[X],J;Q.lastDayOfMonth&&(this.month!==1?J=Mb$[this.month]:J=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let K=!Q.starDOW&&X=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let W=this[X]+Y;W<Q[X].length;W++){let H=Q[X][W];if(X==="day"&&Q.lastDayOfMonth&&W-Y==J&&(H=1),X==="day"&&!Q.starDOW){let F=Q.dayOfWeek[(K+(W-Y-1))%7];if(F&&F&Ns)F=this.isNthWeekdayOfMonth(this.year,this.month,W-Y,F)?1:0;else if(F)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${F}`);Z.legacyMode&&!Q.starDOM?H=H||F:H=H&&F}if(H)return this[X]=W-Y,G!==this[X]?2:1}return 3}recurse(Z,X,Q){let Y=this.findNext(X,UU[Q][0],Z,UU[Q][2]);if(Y>1){let G=Q+1;for(;G<UU.length;)this[UU[G][0]]=-UU[G][2],G++;if(Y===3)return this[UU[Q][1]]++,this[UU[Q][0]]=-UU[Q][2],this.apply(),this.recurse(Z,X,0);if(this.apply())return this.recurse(Z,X,Q-1)}return Q+=1,Q>=UU.length?this:this.year>=3000?null:this.recurse(Z,X,Q)}increment(Z,X,Q){return this.second+=X.interval!==void 0&&X.interval>1&&Q?X.interval:1,this.ms=0,this.apply(),this.recurse(Z,X,0)}getDate(Z){return Z||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):SX.fromTZ(SX.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}},Vb$=30000,hT0,uT0=class{name;options;_states;fn;constructor($,Z,X){let Q,Y;if(Fs(Z))Y=Z;else if(typeof Z=="object")Q=Z;else if(Z!==void 0)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(Fs(X))Y=X;else if(typeof X=="object")Q=X;else if(X!==void 0)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=Q?.name,this.options=R06(Q),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:Q?Q.maxRuns:void 0,paused:Q?Q.paused:!1,pattern:new qb$("* * * * *")},$&&($ instanceof Date||typeof $=="string"&&$.indexOf(":")>0)?this._states.once=new $3($,this.options.timezone||this.options.utcOffset):this._states.pattern=new qb$($,this.options.timezone),this.name){if(hT0.find((G)=>G.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");hT0.push(this)}return Y!==void 0&&I06(Y)&&(this.fn=Y,this.schedule()),this}nextRun($){let Z=this._next($);return Z?Z.getDate(!1):null}nextRuns($,Z){this._states.maxRuns!==void 0&&$>this._states.maxRuns&&($=this._states.maxRuns);let X=[],Q=Z||this._states.currentRun||void 0;for(;$--&&(Q=this.nextRun(Q));)X.push(Q);return X}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let $=this.nextRun(this._states.currentRun),Z=!this._states.paused,X=this.fn!==void 0,Q=!this._states.kill;return Z&&X&&Q&&$!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext($){let Z=this._next($);return Z?$ instanceof $3||$ instanceof Date?Z.getTime()-$.getTime():Z.getTime()-new $3($).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let $=hT0.indexOf(this);$>=0&&hT0.splice($,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule($){if($&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");$&&(this.fn=$);let Z=this.msToNext(),X=this.nextRun(this._states.currentRun);return Z==null||isNaN(Z)||X===null?this:(Z>Vb$&&(Z=Vb$),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(X),Z),this._states.currentTimeout&&this.options.unref&&q06(this._states.currentTimeout),this)}async _trigger($){if(this._states.blocking=!0,this._states.currentRun=new $3(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(Z){Fs(this.options.catch)&&this.options.catch(Z,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new $3($,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger($){let Z=new Date,X=!this._states.paused&&Z.getTime()>=$.getTime(),Q=this._states.blocking&&this.options.protect;X&&!Q?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):X&&Q&&Fs(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next($){let Z=!!($||this._states.currentRun),X=!1;!$&&this.options.startAt&&this.options.interval&&([$,Z]=this._calculatePreviousRun($,Z),X=!$),$=new $3($,this.options.timezone||this.options.utcOffset),this.options.startAt&&$&&$.getTime()<this.options.startAt.getTime()&&($=this.options.startAt);let Q=this._states.once||new $3($,this.options.timezone||this.options.utcOffset);return!X&&Q!==this._states.once&&(Q=Q.increment(this._states.pattern,this.options,Z)),this._states.once&&this._states.once.getTime()<=$.getTime()||Q===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&Q.getTime()>=this.options.stopAt.getTime()?null:Q}_calculatePreviousRun($,Z){let X=new $3(void 0,this.options.timezone||this.options.utcOffset),Q=$;if(this.options.startAt.getTime()<=X.getTime()){Q=this.options.startAt;let Y=Q.getTime()+this.options.interval*1000;for(;Y<=X.getTime();)Q=new $3(Q,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),Y=Q.getTime()+this.options.interval*1000;Z=!0}return Q===null&&(Q=void 0),[Q,Z]}};var aX1=L(()=>{SX.fromTZISO=($,Z,X)=>SX.fromTZ(T06($,Z),X);SX.fromTZ=function($,Z){let X=new Date(Date.UTC($.y,$.m-1,$.d,$.h,$.i,$.s)),Q=oX1($.tz,X),Y=new Date(X.getTime()-Q),G=oX1($.tz,Y);if(G-Q===0)return Y;{let J=new Date(X.getTime()-G),K=oX1($.tz,J);if(K-G===0)return J;if(!Z&&K-G>0)return J;if(Z)throw Error("Invalid date passed to fromTZ()");return Y}};SX.toTZ=function($,Z){let X=$.toLocaleString("en-US",{timeZone:Z}).replace(/[\u202f]/," "),Q=new Date(X);return{y:Q.getFullYear(),m:Q.getMonth()+1,d:Q.getDate(),h:Q.getHours(),i:Q.getMinutes(),s:Q.getSeconds(),tz:Z}};SX.tp=($,Z,X,Q,Y,G,J)=>({y:$,m:Z,d:X,h:Q,i:Y,s:G,tz:J});SX.minitz=SX;Ns=31|rX1,kb$=[1,2,4,8,16],Mb$=[31,28,31,30,31,30,31,31,30,31,30,31],UU=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]];hT0=[]});function cT0($,Z){try{return new uT0($,{timezone:"UTC"}).nextRun(Z)??null}catch{return null}}var sX1=L(()=>{aX1()});import{DBOS as C7,SchedulerMode as M06}from"@dbos-inc/dbos-sdk";async function QQ1($){try{let{rows:Z}=await $.query(`SELECT q.name FROM dbos.queues q
|
|
2852
|
+
`)}async function xe4($,Z,X){let Y=(await $.storage.taskBoard.listPrs(Z.id,Z.organizationId).catch(()=>[])).find((G)=>G.number===X);if(!Y)return null;return BC$($,Z.organizationId,Y).catch(()=>null)}async function fe4($,Z){let X=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId).catch(()=>[]);return nB$(X)}function be4($){return $!=="closed"}async function ye4($,Z){let X=await $.storage.taskBoard.listPrs(Z.id,Z.organizationId).catch(()=>[]);for(let Q of X){let{state:Y}=await bu(Z.organizationId,Q);if(be4(Y))return{number:Q.number,url:Q.url}}return}async function yK($,Z,X){let Q=await aB$($,Z,X?.userInitiated?ML():void 0),Y="decopilot";try{let G=y0().taskBoardRerunReusesPrBranch,J=X?.pr??(G?await ye4($,Z):void 0),K=G&&J?await xe4($,Z,J.number):null,W=!X?.feedback&&!X?.resolveConflict,H=J&&W?await fe4($,Z):null,F=J&&J!==X?.pr||H?{...X,...J?{pr:J}:{},...H?{feedback:H}:{}}:X,N=await gA0($,Z.organizationId);if(N){Y="claude-code";let U="repo"in N?N.repo:null;await _a($,Z,{title:`Super Agent: ${Z.title}`,...X?.runClass?{runClass:X.runClass}:{},...K?{pinnedRef:K}:{},prompt:tS$(Z,U,{...F,..."choices"in N?{repoChoices:N.choices}:{}}),temperature:0.5,harnessId:"claude-code",...U?{repo:U}:{}})}else await _a($,Z,{title:`Super Agent: ${Z.title}`,...X?.runClass?{runClass:X.runClass}:{},prompt:ve4(Z,F),temperature:0.5,...K?{pinnedRef:K}:{}})}catch(G){throw await sB$($.storage.organizationBilling,Z.organizationId,Z.id,Q),G}await $.storage.taskBoard.supersedeFailedThreads(Z.id,Z.organizationId).catch((G)=>console.error("[task-board] superseding failed threads failed",G)),NG({event:"task_run_enqueued",organizationId:Z.organizationId,properties:{task_id:Z.id,reports_task:KY(Z),claim:Q,harness:Y,...X?.runClass?{run_class:X.runClass}:{}}})}var vH=L(()=>{B9();xJ();B9();f4();V$();vZ1();tJ();xa();qZ1()});import{z as iK}from"zod";var Pv;var dZ1=L(()=>{k0();o51();vK();r51();vH();qX();q5();Vu();Pv=c({name:"TASK_BOARD_ITEM_CREATE",description:"Create a new task board item for the organization.",annotations:{title:"Create Task Board Item",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:iK.object({title:iK.string().min(1),description:iK.string().nullable().optional(),status:_K.optional(),priority:Xv.optional(),assigneeId:iK.string().nullable().optional(),repo:iK.string().nullable().optional(),dueDate:iK.string().datetime().nullable().optional(),sprint:iK.number().int().min(1).max(vP0).nullable().optional().describe("Sprint to plan this task into (1-based, counted from the org's sprint cadence). Omit or null to leave it in the backlog."),tagIds:iK.array(iK.string()).optional(),prUrl:iK.string().nullable().optional().describe('GitHub pull request URL to link to the new task, e.g. https://github.com/owner/repo/pull/123. Pass this with `status: "in_review"` right after you open a PR so the card lands on the board with its PR already attached for review.')}),outputSchema:iK.object({item:Eu}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=$.prUrl?FD($.prUrl):null;if($.prUrl&&!Q)throw Error(`Not a GitHub pull request URL: ${$.prUrl} (expected https://github.com/<owner>/<repo>/pull/<number>)`);if($.assigneeId)await xP0(Z,X,$.assigneeId);let Y=$.assigneeId===E8;if($.tagIds?.length){let J=await Z.storage.tags.listOrgTags(X),K=new Set(J.map((W)=>W.id));for(let W of $.tagIds)if(!K.has(W))throw Error(`Tag not found: ${W}`)}let G=await Z.storage.taskBoard.create({organizationId:X,title:$.title,description:$.description??null,status:Y?"todo":$.status,priority:$.priority,assigneeId:$.assigneeId??null,assignedBy:$.assigneeId?a0(Z):null,repo:$.repo??null,dueDate:$.dueDate??null,sprint:$.sprint??null,by:a0(Z)});if($.tagIds?.length)await Z.storage.taskBoard.setItemTags(G.id,$.tagIds,a0(Z)),G=await Z.storage.taskBoard.getById(G.id,X);if(Q)await Z.storage.taskBoard.linkPr({taskBoardItemId:G.id,organizationId:X,url:Q.url,prNumber:Q.number,repoOwner:Q.owner,repoName:Q.repo,connectionId:null});return await O6(Z,{taskBoardItemId:G.id,action:"created",actorId:a0(Z),alsoSubscribe:[a0(Z),G.assigneeId===E8?null:G.assigneeId]}),await Z.storage.notifications.notifyMentions({taskBoardItemId:G.id,organizationId:X,actorId:a0(Z),body:G.description??""}),d$(X,G),await BD(Z,G),{item:G}}})});import{z as xv}from"zod";var AX1;var cf$=L(()=>{k0();Vu();q5();Zv();AX1=c({name:"TASK_BOARD_ITEM_PR_LINK",description:"Link the pull request you just opened to this run's task board item. Call this right after `gh pr create` succeeds, with the PR URL it printed. Reviewers (QA, code review) are dispatched from the linked PR, so a task whose PR is not linked never gets reviewed.",annotations:{title:"Link Pull Request to Task",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:xv.object({url:xv.string().describe("The pull request URL, e.g. https://github.com/owner/repo/pull/123")}),outputSchema:xv.object({url:xv.string(),prNumber:xv.number(),taskBoardItemIds:xv.array(xv.string())}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z).id,{threadId:Q}=_P0(),Y=FD($.url);if(!Y)throw Error(`Not a GitHub pull request URL: ${$.url} (expected https://github.com/<owner>/<repo>/pull/<number>)`);let G=await Cu(Z,X,Q);for(let J of G)await Z.storage.taskBoard.linkPr({taskBoardItemId:J,organizationId:X,url:Y.url,prNumber:Y.number,repoOwner:Y.owner,repoName:Y.repo}),await Z.storage.taskBoard.clearSweepBudget(J,X);return{url:Y.url,prNumber:Y.number,taskBoardItemIds:G}}})});function df$($){lf$=$}function _T0($){lf$?.broadcast($)}var lf$=null;import{DBOS as vT0}from"@dbos-inc/dbos-sdk";function ge4($,Z){let X=`thread-run:${Z}:`;if(!$.workflowID.startsWith(X))return null;let Q=$.input?.[0],Y=Q?.request;return{workflowId:$.workflowID,messageId:Y?.messageId??$.workflowID.slice(X.length),status:$.status==="PENDING"?"running":"queued",enqueuedAt:$.createdAt,...Q?.source!==void 0?{source:Q.source}:{}}}async function TX1($){return(await vT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING","ENQUEUED"],loadInput:!0,loadOutput:!1})).map((X)=>ge4(X,$)).filter((X)=>X!==null).sort((X,Q)=>X.enqueuedAt-Q.enqueuedAt)}async function mf$($,Z){if(!Z.startsWith(`thread-run:${$}:`))return!1;return await vT0.cancelWorkflows([Z]),!0}async function au($){let Z=await vT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING"],loadInput:!1,loadOutput:!1});if(Z.length===0)return;await vT0.cancelWorkflows(Z.map((X)=>X.workflowID))}var xT0=()=>{};function ce4($){return/\b405\b/.test($)&&/not allowed on this repository/i.test($)}function de4($,Z={}){if($==="failing")return!0;if($==="pending")return!Z.allowPendingChecks;return!1}async function me4($,Z,X,Q,Y){if(le4.has(Q))return;let J=(await $.storage.taskBoard.listActivity(X,Z).catch(()=>[])).at(-1);if(J?.action==="merge_failed"&&J.data?.reason===Q)return;await O6($,{taskBoardItemId:X,action:"merge_failed",actorId:null,data:{reason:Q,...Y?{detail:Y}:{}}})}function ie4($){if(!$?.isError)return{kind:"merged"};let Z=JSON.stringify($?.content)??"";if(ce4(Z))return{kind:"method_not_allowed",detail:Z};if(mA0(Z))return{kind:"rate_limited",detail:Z};return{kind:"refused",detail:Z}}async function pe4($,Z,X){let Q=await $.callTool({name:"merge_pull_request",arguments:{owner:Z.repoOwner,repo:Z.repoName,pullNumber:Z.number,merge_method:X}},void 0,{timeout:he4});return ie4(Q)}async function Ys($,Z,X,Q={}){let Y=async(N,U)=>{return await me4($,Z,X,N,U),{merged:!1,reason:N,...U?{detail:U}:{}}},G=await $.storage.taskBoard.listPrs(X,Z),J=await LD($,Z,G);if(!J)return console.warn(`[task-board] merge skipped \u2014 no linked PR on ${X}`),Y("no_pr");let K=await FC$($,Z,J);if(de4(K,Q))return console.warn(`[task-board] merge blocked \u2014 checks ${K} on PR #${J.number}`),Y(K==="failing"?"checks_failing":"checks_pending");let W=`${J.repoOwner}/${J.repoName}`,H=await jv($,Z,J.connectionId,{owner:J.repoOwner,name:J.repoName});if(!H)return console.warn("[task-board] merge blocked \u2014 no active GitHub connection for "+`${W} (PR #${J.number})`),Y("no_connection",W);let F=await z5(H,$,!0);try{let N=null;for(let U of ue4){let B=await pe4(F,J,U);if(B.kind==="merged")return YC$(H.id),{merged:!0};if(B.kind==="rate_limited")return console.warn(`[task-board] merge rate-limited on PR #${J.number} \u2014 sweep retries`),Y("rate_limited",B.detail.slice(0,500));if(B.kind==="method_not_allowed"){console.warn(`[task-board] merge method '${U}' not allowed on ${W} \u2014 trying next`),N=B.detail;continue}return console.error(`[task-board] merge refused by GitHub on PR #${J.number}:`,B.detail),Y("refused",B.detail.slice(0,500))}return console.error(`[task-board] no merge method allowed on ${W} (PR #${J.number})`,N),Y("refused",N?.slice(0,500))}catch(N){let U=N instanceof Error?N.message:String(N);if(mA0(N))return Y("rate_limited",U);return console.error("[task-board] merge PR failed",N),Y("error",U)}finally{await F.close().catch(()=>{})}}async function Gs($,Z,X){let Q=await $.storage.organizationSettings.get(Z),Y=fN(Q?.flags),G=await $.storage.taskBoard.listActivity(X,Z);return qL(G,Y,{verifiedOnly:!0})}async function ne4($,Z){let X=await $.storage.organizationSettings.get(Z.organizationId),Q=fN(X?.flags),Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId);if(!pB$(Y,Q))return;await xH($,Z,"every reviewer approved, but an approval could not be verified \u2014 "+"auto-merge is blocked and no reviewer can be re-dispatched this cycle")}function if$($){return!$.merged&&$.reason==="refused"}function RX1($,Z){if($!==null)return $;if(Z===null||!if$(Z))return null;return(Z.detail??"").toLowerCase().includes("merge conflict")?!0:null}async function te4($,Z,X){if(!if$(X))return;let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q),G=await LD($,Q,Y);if(!G)return;await fu($,Q,Z,{pr:{number:G.number,url:G.url},conflict:RX1(await OD($,Q,G),X)}).catch((J)=>{console.error("[task-board] sweep conflict auto-resolve failed",J)})}async function pf$($,Z){let X=Z.organizationId;if(Z.status!=="in_review")return!1;if((await $.storage.organizationSettings.get(X))?.flags?.auto_merge!==!0)return!1;if(await $.storage.taskBoard.hasHumanRejectedDone(Z.id,X))return!1;if(!await Gs($,X,Z.id))return await ne4($,Z),!1;let Y=await Ys($,X,Z.id);if(!Y.merged)return await te4($,Z,Y),!1;let G=await $.storage.taskBoard.update(Z.id,X,{status:"done"},Z.updatedBy);return await O6($,{taskBoardItemId:Z.id,action:"status_changed",actorId:null,data:{from:Z.status,to:"done"}}),d$(X,G),!0}var he4=15000,ue4,le4;var Js=L(()=>{kN();B9();qX();va();tJ();q5();ue4=["merge","squash","rebase"];le4=new Set(["checks_pending"])});import{z as su}from"zod";function re4($){return $.threads.filter((Z)=>Z.status!==null&&!Ia.has(Z.status)).map((Z)=>Z.threadId)}async function ae4($,Z,X){let Q=(G)=>(J)=>console.error("[task-board] rerun takeover step failed",{threadId:Z,step:G,err:J});await $.storage.threads.setCancelRequested(Z,X).catch(Q("cancel-flag")),await mu(Z).catch(Q("background-jobs")),await au(Z).catch(Q("gate-head"));let Y=await $.storage.threads.getRunFence(Z).catch(()=>null);if(Y)await vv(Z,Y).catch(Q("hosted-harness"));_T0(Z)}function se4($,Z){return $===!0&&xZ1(Z)}async function ee4($,Z,X){let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q).catch(()=>[]),G=await LD($,Q,Y).catch(()=>{return});if(!G)return!1;let J=await OD($,Q,G).catch(()=>null);return se4(J,X)}function Z06($,Z){let X=bN($),Q=0;for(let Y of $){if(Y.action!=="review_approved")continue;let G=new Date(Y.occurredAt).getTime();if(G>=X)Q=Math.max(Q,G)}return Z-Q>=$06}async function X06($,Z){if(Z.status!=="in_review")return;if((await $.storage.organizationSettings.get(Z.organizationId))?.flags?.auto_merge!==!0)return;if(!await Gs($,Z.organizationId,Z.id))return;let Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId).catch(()=>[]);if(Z06(Y,Date.now()))return;if(await ee4($,Z,Y))return;throw Error("Every reviewer approved this task and its merge is retrying \u2014 re-running "+"would throw that away and start a new review cycle. Wait for the merge, or use the ship button if the PR needs a nudge.")}var oe4="Superseded by a manual re-run of this task",$06=900000,IX1;var nf$=L(()=>{k0();B9();_H();JU();xT0();iu();qX();q5();vH();Js();tJ();va();xJ();IX1=c({name:"TASK_BOARD_ITEM_RERUN",description:"Re-run a task board item with the Super Agent, whatever lane it is in. Use this to retry a task that stalled, finished without doing the job, or is already assigned to the Super Agent (in which case re-assigning it does nothing). Fails any run still holding the task open, moves it to In Progress, and queues a fresh run.",annotations:{title:"Re-run Task",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:su.object({id:su.string().describe("The task board item to re-run.")}),outputSchema:su.object({status:su.string().describe("The task's lane after the re-run was queued."),supersededThreadIds:su.array(su.string()).describe("Runs that were failed to make room for this one.")}),handler:async({id:$},Z)=>{s(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);if(Q.assigneeId!==E8)throw Error("Only a task assigned to the Super Agent can be re-run. Assign it to "+"the Super Agent instead \u2014 that queues a run by itself.");await X06(Z,Q),await xh(Z,Q,ML());let Y=[];for(let J of re4(Q)){if(!await Z.storage.threads.failIfNotTerminal(J,oe4,"superseded"))continue;Y.push(J),await ae4(Z,J,X)}let G=await Z.storage.taskBoard.update($,X,{status:"in_progress"},a0(Z));return await O6(Z,{taskBoardItemId:$,action:"status_changed",actorId:a0(Z),data:{from:Q.status,to:"in_progress",reason:"rerun"}}),d$(X,G),await yK(Z,G,{userInitiated:!0}),{status:G.status,supersededThreadIds:Y}}})});import{z as Ks}from"zod";var qX1;var tf$=L(()=>{k0();xJ();qX();q5();vH();tJ();qX1=c({name:"TASK_BOARD_RESOLVE_CONFLICT",description:"Hand a task's pull request back to the Super Agent to resolve a merge conflict with its base branch. Use when a reviewed PR can't be shipped because it conflicts. Bounces the task to In Progress and queues a run that checks out the existing PR's branch, merges the base, resolves the conflicts, and pushes to the same PR.",annotations:{title:"Resolve Merge Conflict",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:Ks.object({id:Ks.string().describe("The task board item whose PR conflicts."),prNumber:Ks.number().describe("The conflicting pull request's number, linked to this task.")}),outputSchema:Ks.object({status:Ks.string().describe("The task's lane after the resolution run was queued.")}),handler:async({id:$,prNumber:Z},X)=>{s(X),await X.access.check();let Q=X.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let Y=await X.storage.taskBoard.getById($,Q);if(!Y)throw Error(`Task board item not found: ${$}`);let J=(await X.storage.taskBoard.listPrs($,Q)).find((H)=>H.number===Z);if(!J)throw Error(`Pull request #${Z} is not linked to this task.`);if(await OD(X,Q,J).catch(()=>null)!==!0)throw Error("This pull request no longer has a merge conflict \u2014 refresh and try again.");await xh(X,Y,ML());let W=await X.storage.taskBoard.claimConflictResolution($,Q,a0(X));if(!W)throw Error("Couldn't start conflict resolution \u2014 the task may have moved, been "+"reassigned, or already be resolving. Refresh and try again.");d$(Q,W);try{await yK(X,W,{pr:{number:J.number,url:J.url},resolveConflict:!0,runClass:"retry",userInitiated:!0})}catch(H){throw await X.storage.taskBoard.update(W.id,Q,{status:"in_review"},"system").then((F)=>d$(Q,F)).catch((F)=>console.error("[task-board] resolve-conflict status revert failed",F)),H}return await O6(X,{taskBoardItemId:$,action:"merge_conflict_resolution",actorId:null,data:{prNumber:J.number}}),{status:W.status}}})});import{z as TD}from"zod";function Q06($,Z,X){return $!==null&&$.reviewer===Z&&$.cycleAt.getTime()===X}function Y06($,Z){return t$1($).get(Z)==="changes_requested"}var MX1;var of$=L(()=>{k0();B9();vK();qX();q5();vH();Js();tJ();VZ1();va();xJ();MX1=c({name:"TASK_BOARD_REVIEW_DECISION",description:"Record a reviewer's decision for a task under review. `approve` marks the pull request approved by that reviewer (and, once EVERY enabled reviewer has approved, merges it when the org enabled auto-merge, advancing the task to Done); `request_changes` hands the task back to the Super Agent with your notes so it can fix the PR.",annotations:{title:"Review Decision",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:TD.object({taskBoardItemId:TD.string(),reviewer:TD.enum(["qa","code_review"]).describe("Which reviewer you are: `qa` (QA Agent) or `code_review` (Code Reviewer)."),reviewToken:TD.string().optional().describe("The reviewToken from your prompt \u2014 proves you are this reviewer. "+"Pass it through exactly; an approval without a valid token is recorded but does NOT count toward an automatic merge."),decision:TD.enum(["approve","request_changes"]),notes:TD.string().min(1).describe("For approve: a short summary of what you verified. For request_changes: specific, actionable feedback the Super Agent must address.")}),outputSchema:TD.object({status:_K,merged:TD.boolean().describe("True when this approval completed the review and merged the PR.")}),handler:async({taskBoardItemId:$,reviewer:Z,reviewToken:X,decision:Q,notes:Y},G)=>{s(G),await G.access.check();let J=G.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let K=await G.storage.taskBoard.getById($,J);if(!K)throw Error(`Task board item not found: ${$}`);let W=X?bN(await G.storage.taskBoard.listActivity($,J)):0,H=!!X&&(oS$(X,$,Z,new Date(W))||Q06(await G.storage.taskBoard.resolveReviewClaimByToken($,X),Z,W));if(Q==="request_changes"){let j=await G.storage.taskBoard.listActivity($,J);if(Y06(j,Z))return{status:K.status,merged:!1};if(tB$(j))return await O6(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H,bounceLimitReached:!0}}),await xH(G,K,`${o$1} review bounces reached \u2014 the reviewer and the `+"Super Agent are not converging"),{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};let z=await G.storage.taskBoard.claimReviewChangesBounce($,J,K.updatedBy);if(await O6(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!z)return{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};d$(J,z);let A=await G.storage.taskBoard.listPrs($,J),P=await LD(G,J,A);return await yK(G,z,{feedback:`${_h[Z]}: ${Y}`,pr:P?{number:P.number,url:P.url}:void 0}).catch(async(R)=>{if(await xA0(G,z,R)){await G.storage.taskBoard.update(z.id,J,{status:"in_review"},"system").then((M)=>d$(J,M)).catch((M)=>console.error("[task-board] runs-exhausted status revert failed",M));return}if(R instanceof DX)throw R;console.error("[task-board] request_changes re-enqueue failed",R)}),{status:z.status,merged:!1}}if(await O6(G,{taskBoardItemId:$,action:"review_approved",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!await Gs(G,J,$)){let j=await G.storage.taskBoard.getById($,J)??K;return d$(J,j),{status:j.status,merged:!1}}let U=(await G.storage.organizationSettings.get(J))?.flags?.auto_merge===!0,B=await G.storage.taskBoard.hasHumanRejectedDone($,J),O=U&&!B,D=O?await Ys(G,J,$):null;if(D?.merged===!0){let j=await G.storage.taskBoard.update($,J,{status:"done"},K.updatedBy);return await O6(G,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:K.status,to:"done"}}),d$(J,j),{status:j.status,merged:!0}}let E=await G.storage.taskBoard.getById($,J)??K;if(O){let j=await G.storage.taskBoard.listPrs($,J),z=await LD(G,J,j);if(z?await fu(G,J,E,{pr:{number:z.number,url:z.url},conflict:RX1(await OD(G,J,z),D)}).catch((P)=>{if(P instanceof DX)throw P;return console.error("[task-board] conflict auto-resolve failed",P),!1}):!1)return{status:(await G.storage.taskBoard.getById($,J)??E).status,merged:!1}}return d$(J,E),{status:E.status,merged:!1}}})});import{z as fT0}from"zod";function G06($,Z,X){if($!=="in_review")return!1;return X.length===0||qL(Z,X)}var VX1;var rf$=L(()=>{k0();B9();vK();qX();q5();Js();VX1=c({name:"TASK_BOARD_PROMOTE_TO_PRODUCTION",description:"Ship a reviewed task: merge its open pull request and move the task to Done. Used by the board's 'Ship to production' button after the enabled reviewers approved, when auto-merge is off (a human does the final merge).",annotations:{title:"Ship to Production",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:fT0.object({taskBoardItemId:fT0.string()}),outputSchema:fT0.object({status:_K,merged:fT0.boolean().describe("True when the PR was merged.")}),handler:async({taskBoardItemId:$},Z)=>{s(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);let Y=await Z.storage.organizationSettings.get(X),G=fN(Y?.flags),J=await Z.storage.taskBoard.listActivity($,X);if(!G06(Q.status,J,G))throw Error("Task is not ready to ship: it must be In Review with every enabled reviewer approved");if(!(await Ys(Z,X,$,{allowPendingChecks:!0})).merged){let H=await Z.storage.taskBoard.getById($,X)??Q;return d$(X,H),{status:Q.status,merged:!1}}let W=await Z.storage.taskBoard.update($,X,{status:"done"},Q.updatedBy);if(Q.status!=="done")await O6(Z,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:Q.status,to:"done"}});return d$(X,W),{status:W.status,merged:!0}}})});import{z as sJ}from"zod";function af$($){if(!$)throw Error("Organization ID required (no active organization in context)");return $}var J06,kX1,SX1;var sf$=L(()=>{k0();J06=sJ.object({externalKey:sJ.string(),dismissedBy:sJ.string(),dismissedAt:sJ.string()});kX1=c({name:"TASK_BOARD_DISMISSED_LIST",description:"List the diagnostic findings this organization has dismissed by deleting their task board cards. The import skips these until they're restored.",annotations:{title:"List Dismissed Findings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:sJ.object({}),outputSchema:sJ.object({findings:sJ.array(J06)}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=af$(Z.organization?.id);return{findings:await Z.storage.taskBoard.listDismissedFindings(X)}}}),SX1=c({name:"TASK_BOARD_DISMISSED_RESTORE",description:"Un-dismiss diagnostic findings, returning their cards to the board. Omit externalKeys to restore every dismissed finding.",annotations:{title:"Restore Dismissed Findings",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:sJ.object({externalKeys:sJ.array(sJ.string()).optional()}),outputSchema:sJ.object({restored:sJ.number()}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=af$(Z.organization?.id);return{restored:await Z.storage.taskBoard.restoreDismissedFindings(X,$.externalKeys)}}})});import{z as s6}from"zod";function bT0($){let Z=$.organization?.id;if(!Z)throw Error("Organization ID required (no active organization in context)");return Z}function W06($,Z,X){return $.replace(K06,(Q,Y,G,J)=>{let K=encodeURIComponent(`${Z}/${G}`);return`${Y}/api/${encodeURIComponent(X)}/fs/outputs/read?path=${K}${J}`})}var CX1,_X1,K06,vX1,xX1,fX1;var ef$=L(()=>{k0();B9();CA0();Zv();CX1=s6.object({id:s6.string(),taskBoardItemId:s6.string(),parentId:s6.string().nullable(),authorId:s6.string(),body:s6.string(),resolved:s6.boolean(),createdAt:s6.string(),updatedAt:s6.string()});_X1=c({name:"TASK_BOARD_COMMENT_LIST",description:"List a task board item's comments (flat, oldest first; replies carry parentId).",annotations:{title:"List Task Comments",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:s6.object({taskBoardItemId:s6.string()}),outputSchema:s6.object({comments:s6.array(CX1)}),handler:async($,Z)=>{return s(Z),await Z.access.check(),{comments:await Z.storage.taskBoard.listComments($.taskBoardItemId,bT0(Z))}}}),K06=/(!\[[^\]]*\]\()org\/output\/([^)\s]+)(\))/g;vX1=c({name:"TASK_BOARD_COMMENT_CREATE",description:"Post a comment on a task board item, or a reply to one.",annotations:{title:"Create Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:s6.object({taskBoardItemId:s6.string(),body:s6.string().trim().min(1),parentId:s6.string().nullish()}),outputSchema:s6.object({comment:CX1}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=bT0(Z),Q=$v.getStore(),Y=Z.organization?.slug,G=Q?.threadId&&Y?W06($.body,Q.threadId,Y):$.body,J=await Z.storage.taskBoard.createComment({taskBoardItemId:$.taskBoardItemId,organizationId:X,parentId:$.parentId??null,authorId:Q?E8:a0(Z),body:G});if(!J)throw Error("Task board item not found");return await Z.storage.notifications.notify({taskBoardItemId:J.taskBoardItemId,type:"commented",actorId:Q?null:a0(Z),alsoSubscribe:Q?[]:[a0(Z)]}),await Z.storage.notifications.notifyMentions({taskBoardItemId:J.taskBoardItemId,organizationId:X,actorId:Q?null:a0(Z),body:J.body}),await DZ1(Z,{commentId:J.id,taskBoardItemId:J.taskBoardItemId,organizationId:X,authorLabel:Q?"Super Agent":Z.auth?.user?.name??Z.auth?.user?.email??"Studio",body:J.body}),{comment:J}}}),xX1=c({name:"TASK_BOARD_COMMENT_UPDATE",description:"Edit your own comment's body, or resolve/unresolve a comment thread (root only, any org member may toggle it).",annotations:{title:"Update Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:s6.object({id:s6.string(),body:s6.string().trim().min(1).optional(),resolved:s6.boolean().optional()}),outputSchema:s6.object({comment:CX1}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=await Z.storage.taskBoard.updateComment({id:$.id,organizationId:bT0(Z),callerId:a0(Z),body:$.body,resolved:$.resolved});if(!X)throw Error("Comment not found, or you can only edit your own comments");return{comment:X}}}),fX1=c({name:"TASK_BOARD_COMMENT_DELETE",description:"Delete your own comment. Deleting a thread root deletes its replies too.",annotations:{title:"Delete Task Comment",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:s6.object({id:s6.string()}),outputSchema:s6.object({success:s6.boolean()}),handler:async($,Z)=>{return s(Z),await Z.access.check(),{success:await Z.storage.taskBoard.deleteComment($.id,bT0(Z),a0(Z))}}})});var $b$=L(()=>{NM$();dZ1();TZ1();RZ1();IZ1();tJ();cf$();nf$();tf$();of$();rf$();qX();sf$();ef$()});function Ws($){let Z=$.organization?.id;if(!Z)throw Error("Organization ID required (no active organization in context)");return Z}async function bX1($,Z){let X=Ws($);if(!await $.storage.taskBoard.getById(Z,X))throw Error("Task board item not found");return X}import{z as kX}from"zod";var F06,Zb$;var Xb$=L(()=>{k0();LA0();F06=kX.object({id:kX.string(),taskBoardItemId:kX.string(),type:kX.enum(OA0),taskTitle:kX.string(),taskKeySeq:kX.number().nullable(),actorName:kX.string().nullable(),actorImage:kX.string().nullable(),createdAt:kX.string()}),Zb$=c({name:"NOTIFICATION_LIST",description:"List the current user's unread notifications in the current organization, newest first.",annotations:{title:"List Notifications",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:kX.object({cursor:kX.string().optional(),limit:kX.number().int().positive().max(50).optional()}),outputSchema:kX.object({notifications:kX.array(F06),unreadCount:kX.number(),nextCursor:kX.string().nullable()}),handler:async($,Z)=>{s(Z),await Z.access.check();let{notifications:X,unreadCount:Q,nextCursor:Y}=await Z.storage.notifications.listUnread(a0(Z),Ws(Z),{cursor:$.cursor,limit:$.limit});return{notifications:X.map((G)=>({id:G.id,taskBoardItemId:G.taskBoardItemId,type:G.type,taskTitle:G.data.taskTitle,taskKeySeq:G.data.taskKeySeq,actorName:G.data.actorName,actorImage:G.data.actorImage,createdAt:G.createdAt})),unreadCount:Q,nextCursor:Y}}})});import{z as Hs}from"zod";var Qb$;var Yb$=L(()=>{k0();Qb$=c({name:"NOTIFICATION_MARK_READ",description:"Mark notifications read. Omit `ids` to mark all of the current user's unread ones in this organization.",annotations:{title:"Mark Notifications Read",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Hs.object({ids:Hs.array(Hs.string()).max(1000).optional()}),outputSchema:Hs.object({marked:Hs.number()}),handler:async($,Z)=>{return s(Z),await Z.access.check(),{marked:await Z.storage.notifications.markRead(a0(Z),Ws(Z),$.ids)}}})});import{z as cH}from"zod";var Gb$,Jb$;var Kb$=L(()=>{k0();Gb$=c({name:"NOTIFICATION_SUBSCRIPTION_SET",description:"Follow or unfollow a task board item.",annotations:{title:"Set Notification Subscription",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:cH.object({taskBoardItemId:cH.string(),subscribed:cH.boolean()}),outputSchema:cH.object({subscribed:cH.boolean()}),handler:async($,Z)=>{return s(Z),await Z.access.check(),await bX1(Z,$.taskBoardItemId),await Z.storage.notifications.setSubscribed(a0(Z),$.taskBoardItemId,$.subscribed),{subscribed:$.subscribed}}}),Jb$=c({name:"NOTIFICATION_SUBSCRIPTION_LIST",description:"List the user ids following a task board item.",annotations:{title:"List Notification Subscribers",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:cH.object({taskBoardItemId:cH.string()}),outputSchema:cH.object({userIds:cH.array(cH.string())}),handler:async($,Z)=>{return s(Z),await Z.access.check(),await bX1(Z,$.taskBoardItemId),{userIds:await Z.storage.notifications.listSubscribers($.taskBoardItemId)}}})});var Wb$=L(()=>{Xb$();Yb$();Kb$()});import{z as NU}from"zod";var yX1;var Hb$=L(()=>{k0();yX1=c({name:"TAGS_LIST",description:"List all tags available in the organization.",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:NU.object({}),outputSchema:NU.object({tags:NU.array(NU.object({id:NU.string(),organizationId:NU.string(),name:NU.string(),color:NU.string().nullable(),createdAt:NU.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z);return{tags:(await Z.storage.tags.listOrgTags(X.id)).map((Y)=>({...Y,createdAt:Y.createdAt instanceof Date?Y.createdAt.toISOString():String(Y.createdAt)}))}}})});import{z as lH}from"zod";var gX1;var Fb$=L(()=>{k0();gX1=c({name:"TAGS_CREATE",description:"Create a new tag, usable on organization members and task board items.",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:lH.object({name:lH.string().min(1).max(50).describe("Tag name"),color:lH.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional().describe('Hex color the tag renders its dot with, e.g. "#3b82f6"')}),outputSchema:lH.object({tag:lH.object({id:lH.string(),organizationId:lH.string(),name:lH.string(),color:lH.string().nullable(),createdAt:lH.string().describe("ISO 8601 timestamp")})}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z),Q=await Z.storage.tags.createTag(X.id,$.name,$.color);return{tag:{...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}}}})});import{z as yT0}from"zod";var hX1;var Nb$=L(()=>{k0();hX1=c({name:"TAGS_DELETE",description:"Delete a tag and automatically remove it from all assigned members.",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:yT0.object({tagId:yT0.string().describe("Tag ID to delete")}),outputSchema:yT0.object({success:yT0.boolean()}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z),Q=await Z.storage.tags.getTag($.tagId);if(!Q)throw Error("Tag not found");if(Q.organizationId!==X.id)throw Error("Tag does not belong to this organization");return await Z.storage.tags.deleteTag($.tagId),{success:!0}}})});import{z as dH}from"zod";var uX1;var Ub$=L(()=>{k0();uX1=c({name:"MEMBER_TAGS_GET",description:"Get all tags currently assigned to a specific member.",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:dH.object({memberId:dH.string().describe("Member ID")}),outputSchema:dH.object({tags:dH.array(dH.object({id:dH.string(),organizationId:dH.string(),name:dH.string(),color:dH.string().nullable(),createdAt:dH.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);return{tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});import{z as eJ}from"zod";var cX1;var Bb$=L(()=>{k0();cX1=c({name:"MEMBER_TAGS_SET",description:"Replace all tags on a member with the given set. Pass empty array to clear.",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:eJ.object({memberId:eJ.string().describe("Member ID"),tagIds:eJ.array(eJ.string()).describe("Array of tag IDs to assign")}),outputSchema:eJ.object({success:eJ.boolean(),tags:eJ.array(eJ.object({id:eJ.string(),organizationId:eJ.string(),name:eJ.string(),createdAt:eJ.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{s(Z),await Z.access.check();let X=a(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);for(let G of $.tagIds){let J=await Z.storage.tags.getTag(G);if(!J)throw Error(`Tag not found: ${G}`);if(J.organizationId!==X.id)throw Error(`Tag does not belong to this organization: ${G}`)}return await Z.storage.tags.setMemberTags($.memberId,$.tagIds),{success:!0,tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var Ob$=L(()=>{Hb$();Fb$();Nb$();Ub$();Bb$()});import{z as Lb$}from"zod";function L06($,Z){let X=$?.[Z];if(!X)return;return Object.entries(X).filter(([,Y])=>(M7 in Y)).sort(([,Y],[,G])=>(G[M7]?.createdAt??0)-(Y[M7]?.createdAt??0))[0]?.[0]}var B06,O06,lX1;var Db$=L(()=>{f4();k0();Wv();Ou();A7();DY();B06=Lb$.object({data:Ak$.describe("Data for the new thread (id is auto-generated if not provided)")}),O06=Lb$.object({item:SH.describe("The created thread entity")});lX1=c({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread for organizing messages and conversations.",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:B06,outputSchema:O06,handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=a0(Z);if(!Q)throw Error("User ID required to create thread");let{data:Y}=$,G=Y.id??L8("thrd"),K=(await NA0(Z.storage.virtualMcps,Y.virtual_mcp_id,X.id)).metadata,W=K?.githubRepo,H=null;if(W)H=Y.branch??L06(K?.sandboxMap,Q)??p30(i30(Z.auth.user));let F=await Z.storage.threads.create({id:G,organization_id:X.id,title:Y.title,description:Y.description,virtual_mcp_id:Y.virtual_mcp_id,branch:H,created_by:Q,metadata:{runtime:Y.runtime??qP0(K)}});if(F.isNew)h1.capture({distinctId:Q,event:"chat_started",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:G,has_title:!!$.data.title,created_via:"tool"}});return{item:iJ(F)}}})});import{z as dX1}from"zod";var D06,w06,mX1;var wb$=L(()=>{f4();k0();Wv();Ou();D06=dX1.object({id:dX1.string().describe("ID of the thread to update"),data:Tk$.describe("Partial thread data to update")}),w06=dX1.object({item:SH.describe("The updated thread entity")}),mX1=c({name:"COLLECTION_THREADS_UPDATE",description:"Update a thread's title, description, or visibility.",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:D06,outputSchema:w06,handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=a0(Z);if(!Q)throw Error("User ID required to update thread");let{id:Y,data:G}=$,J=await Z.storage.threads.get(Y);if(!J)throw Error("Thread not found in organization");if(G.virtual_mcp_id!==void 0)await NA0(Z.storage.virtualMcps,G.virtual_mcp_id,X.id);if(G.branch===null&&J.virtual_mcp_id){if((await Z.storage.virtualMcps.findById(J.virtual_mcp_id,X.id))?.metadata?.githubRepo)throw Error("Cannot set branch=null on a github-linked thread (vMCP has githubRepo)")}let K={title:G.title,description:G.description,hidden:G.hidden,updated_by:Q};if(G.status)K.status=G.status;if(G.metadata!==void 0){let H=Sh(G.metadata)??{},F=e_(J.metadata?.runtime),N=e_(H.runtime);if(F&&N&&N!==F)throw Error(`Cannot change a thread's runtime (${F} \u2192 ${N}); it is stamped once at creation. Start a new chat instead.`);let U=J.metadata?.sandboxMap;K.metadata={...H,...F?{runtime:F}:{},...U!==void 0?{sandboxMap:U}:{}}}if(G.branch!==void 0)K.branch=G.branch;if(G.virtual_mcp_id!==void 0)K.virtual_mcp_id=G.virtual_mcp_id;let W=await Z.storage.threads.update(Y,K);if(G.hidden!==void 0&&G.hidden!==J.hidden)h1.capture({distinctId:Q,event:G.hidden?"chat_archived":"chat_unarchived",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:Y}});return{item:iJ(W)}}})});var iX1;var Eb$=L(()=>{kJ();Wv();f4();k0();JU();xT0();iu();iX1=c({name:"COLLECTION_THREADS_DELETE",description:"Permanently delete a thread and all its messages.",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:co,outputSchema:lo(SH),handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=await Z.storage.threads.get($.id);if(!Q)throw Error(`Thread not found: ${$.id}`);if(Q.status==="in_progress"){let G=(K)=>(W)=>console.error("[thread] delete-time run cancel step failed",{threadId:$.id,step:K,err:W});await mu($.id).catch(G("background-jobs")),await au($.id).catch(G("gate-head"));let J=await Z.storage.threads.getRunFence($.id).catch(()=>null);if(J)await vv($.id,J).catch(G("hosted-harness"));_T0($.id)}await Z.storage.threads.delete($.id);let Y=a0(Z);if(Y)h1.capture({distinctId:Y,event:"chat_deleted",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:$.id}});return{item:iJ(Q)}}})});var jb$=L(()=>{Db$();_91();v91();wb$();Eb$();x91()});function j06($){return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:$}]}]}}function z06($){return $.map((Z)=>{let X=Z.metadata;if(X?.tiptapDoc)return Z;let Q=Z.parts.find((Y)=>Y.type==="text"&&typeof Y.text==="string");if(!Q?.text||typeof Q.text!=="string")return Z;return{...Z,metadata:{...X,tiptapDoc:j06(Q.text)}}})}function gT0($){let Z;if(typeof $==="string")try{let X=JSON.parse($);if(Array.isArray(X)&&X.length>0&&X[0]?.role&&Array.isArray(X[0]?.parts))Z=X;else Z=[{role:"user",parts:[{type:"text",text:$}]}]}catch{Z=[{role:"user",parts:[{type:"text",text:$}]}]}else Z=$;return z06(Z)}import{z as e6}from"zod";var pX1;var zb$=L(()=>{f4();k0();UX();pX1=c({name:"AUTOMATION_CREATE",description:"Create an automation that runs an agent thread on trigger fire. Requires virtual_mcp_id + messages.",annotations:{title:"Create Automation",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:e6.object({name:e6.string().min(1).max(255),virtual_mcp_id:e6.string(),messages:e6.union([e6.string(),e6.array(e6.looseObject({id:e6.string().optional(),role:e6.enum(["user","assistant","system"]),parts:e6.array(e6.record(e6.string(),e6.unknown())),metadata:e6.unknown().optional()}))]),models:e6.object({tier:GL,modelId:e6.string().optional(),credentialId:e6.string().optional()}).loose().default({tier:"smart"}),tools:e6.array(e6.string()).nullable().optional(),maxAgentSteps:e6.number().int().min(1).max(100).nullable().optional(),temperature:e6.number().default(0.5),active:e6.boolean().default(!0)}),outputSchema:e6.object({id:e6.string(),name:e6.string(),active:e6.boolean(),created_at:e6.string()}),handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=a0(Z);if(!Q)throw Error("Unable to determine user identity");let Y=gT0($.messages),G=await Z.storage.automations.create({organization_id:X.id,created_by:Q,name:$.name,messages:JSON.stringify(Y),models:JSON.stringify($.models),tools:$.tools===void 0||$.tools===null?null:JSON.stringify($.tools),max_agent_steps:$.maxAgentSteps??null,temperature:$.temperature,active:$.active,virtual_mcp_id:$.virtual_mcp_id});return h1.capture({distinctId:Q,event:"automation_created",groups:{organization:X.id},properties:{organization_id:X.id,automation_id:G.id,virtual_mcp_id:$.virtual_mcp_id,active:G.active,tier:$.models.tier}}),{id:G.id,name:G.name,active:G.active,created_at:G.created_at}}})});import{z as c6}from"zod";var nX1;var Pb$=L(()=>{k0();nX1=c({name:"AUTOMATION_GET",description:"Get an automation's full configuration and triggers by ID.",annotations:{title:"Get Automation",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:c6.object({id:c6.string()}),outputSchema:c6.object({automation:c6.object({id:c6.string(),name:c6.string(),active:c6.boolean(),created_by:c6.string(),created_at:c6.string(),updated_at:c6.string(),virtual_mcp_id:c6.string(),messages:c6.unknown(),models:c6.unknown(),tools:c6.array(c6.string()).nullable(),maxAgentSteps:c6.number().nullable(),temperature:c6.number(),triggers:c6.array(c6.object({id:c6.string(),type:c6.enum(["cron","event","webhook"]),cron_expression:c6.string().nullable(),connection_id:c6.string().nullable(),event_type:c6.string().nullable(),params:c6.unknown().nullable(),last_run_at:c6.string().nullable(),api_key_id:c6.string().nullable(),created_at:c6.string()}))}).nullable()}),handler:async($,Z)=>{s(Z);let X=a(Z);await Z.access.check();let Q=await Z.storage.automations.findById($.id,X.id);if(!Q)return{automation:null};let Y=await Z.storage.automations.listTriggers(Q.id);return{automation:{id:Q.id,name:Q.name,active:Q.active,created_by:Q.created_by,created_at:Q.created_at,updated_at:Q.updated_at,virtual_mcp_id:Q.virtual_mcp_id,messages:JSON.parse(Q.messages),models:JSON.parse(Q.models),tools:Q.tools?JSON.parse(Q.tools):null,maxAgentSteps:Q.max_agent_steps,temperature:Q.temperature,triggers:Y.map((G)=>({id:G.id,type:G.type,cron_expression:G.cron_expression,connection_id:G.connection_id,event_type:G.event_type,params:G.params?JSON.parse(G.params):null,last_run_at:G.last_run_at,api_key_id:G.api_key_id,created_at:G.created_at}))}}}})});import{z as SG}from"zod";var tX1;var Ab$=L(()=>{k0();tX1=c({name:"AUTOMATION_LIST",description:"List automations with their status, triggers, and configuration.",annotations:{title:"List Automations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:SG.object({virtual_mcp_id:SG.string().optional().nullable()}),outputSchema:SG.object({automations:SG.array(SG.object({id:SG.string(),name:SG.string(),active:SG.boolean(),created_by:SG.string(),created_at:SG.string(),trigger_count:SG.number(),nearest_next_run_at:SG.string().nullable(),virtual_mcp_id:SG.string()}))}),handler:async($,Z)=>{s(Z);let X=a(Z);return await Z.access.check(),{automations:(await Z.storage.automations.listWithTriggerCounts(X.id,$.virtual_mcp_id)).map((G)=>({id:G.id,name:G.name,active:G.active,created_by:G.created_by,created_at:G.created_at,trigger_count:G.trigger_count,nearest_next_run_at:G.nearest_next_run_at,virtual_mcp_id:G.virtual_mcp_id}))}}})});function A06($){if(!$)return null;try{let Z=JSON.parse($);if(Array.isArray(Z)&&Z.every((X)=>typeof X==="string"))return Z.length>0?Z:null}catch{}return null}function Tb$($){return`${$}:context`}function Rb$($,Z,X,Q,Y){let J=JSON.parse($.messages).map((H,F)=>({...H,id:`${X}:${F}`})),K=Z?{...Y,[bP0]:P06}:Y;return{messages:J,models:{credentialId:Q.credentialId,thinking:Q.thinking,...Q.image?{image:Q.image}:{},...Q.webSearch?{webSearch:Q.webSearch}:{},...Q.deepResearch?{deepResearch:Q.deepResearch}:{}},agent:{id:$.virtual_mcp_id},toolAllowlist:A06($.tools),maxAgentSteps:$.max_agent_steps??void 0,temperature:$.temperature??0.5,toolApprovalLevel:"auto",mode:"default",organizationId:$.organization_id,userId:$.created_by,harnessId:"decopilot",triggerId:Z??void 0,...K?{runMetadata:K}:{},taskId:X}}var P06="new_task";var Ib$=L(()=>{Fa()});function SX($,Z,X,Q,Y,G,J,K){return SX.fromTZ(SX.tp($,Z,X,Q,Y,G,J),K)}function oX1($,Z=new Date){let X=Z.toLocaleString("en-US",{timeZone:$,timeZoneName:"shortOffset"}).split(" ").slice(-1)[0],Q=Z.toLocaleString("en-US").replace(/[\u202f]/," ");return Date.parse(`${Q} GMT`)-Date.parse(`${Q} ${X}`)}function T06($,Z){let X=new Date(Date.parse($));if(isNaN(X))throw Error("minitz: Invalid ISO8601 passed to parser.");let Q=$.substring(9);return $.includes("Z")||Q.includes("-")||Q.includes("+")?SX.tp(X.getUTCFullYear(),X.getUTCMonth()+1,X.getUTCDate(),X.getUTCHours(),X.getUTCMinutes(),X.getUTCSeconds(),"Etc/UTC"):SX.tp(X.getFullYear(),X.getMonth()+1,X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),Z)}function R06($){if($===void 0&&($={}),delete $.name,$.legacyMode=$.legacyMode===void 0?!0:$.legacyMode,$.paused=$.paused===void 0?!1:$.paused,$.maxRuns=$.maxRuns===void 0?1/0:$.maxRuns,$.catch=$.catch===void 0?!1:$.catch,$.interval=$.interval===void 0?0:parseInt($.interval.toString(),10),$.utcOffset=$.utcOffset===void 0?void 0:parseInt($.utcOffset.toString(),10),$.unref=$.unref===void 0?!1:$.unref,$.startAt&&($.startAt=new $3($.startAt,$.timezone)),$.stopAt&&($.stopAt=new $3($.stopAt,$.timezone)),$.interval!==null){if(isNaN($.interval))throw Error("CronOptions: Supplied value for interval is not a number");if($.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if($.utcOffset!==void 0){if(isNaN($.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if($.utcOffset<-870||$.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if($.utcOffset!==void 0&&$.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if($.unref!==!0&&$.unref!==!1)throw Error("CronOptions: Unref should be either true, false or undefined(false).");return $}function Fs($){return Object.prototype.toString.call($)==="[object Function]"||typeof $=="function"||$ instanceof Function}function I06($){return Fs($)}function q06($){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer($):$&&typeof $.unref<"u"&&$.unref()}var rX1=32,Ns,kb$,qb$=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor($,Z){this.pattern=$,this.timezone=Z,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let $=this.pattern.replace(/\s+/g," ").split(" ");if($.length<5||$.length>6)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five or six space separated parts are required.");if($.length===5&&$.unshift("0"),$[3].indexOf("L")>=0&&($[3]=$[3].replace("L",""),this.lastDayOfMonth=!0),$[3]=="*"&&(this.starDOM=!0),$[4].length>=3&&($[4]=this.replaceAlphaMonths($[4])),$[5].length>=3&&($[5]=this.replaceAlphaDays($[5])),$[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0){let Z=new $3(new Date,this.timezone).getDate(!0);$[0]=$[0].replace("?",Z.getSeconds().toString()),$[1]=$[1].replace("?",Z.getMinutes().toString()),$[2]=$[2].replace("?",Z.getHours().toString()),this.starDOM||($[3]=$[3].replace("?",Z.getDate().toString())),$[4]=$[4].replace("?",(Z.getMonth()+1).toString()),this.starDOW||($[5]=$[5].replace("?",Z.getDay().toString()))}this.throwAtIllegalCharacters($),this.partToArray("second",$[0],0,1),this.partToArray("minute",$[1],0,1),this.partToArray("hour",$[2],0,1),this.partToArray("day",$[3],-1,1),this.partToArray("month",$[4],-1,1),this.partToArray("dayOfWeek",$[5],0,Ns),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray($,Z,X,Q){let Y=this[$],G=$==="day"&&this.lastDayOfMonth;if(Z===""&&!G)throw TypeError("CronPattern: configuration entry "+$+" ("+Z+") is empty, check for trailing spaces.");if(Z==="*")return Y.fill(Q);let J=Z.split(",");if(J.length>1)for(let K=0;K<J.length;K++)this.partToArray($,J[K],X,Q);else Z.indexOf("-")!==-1&&Z.indexOf("/")!==-1?this.handleRangeWithStepping(Z,$,X,Q):Z.indexOf("-")!==-1?this.handleRange(Z,$,X,Q):Z.indexOf("/")!==-1?this.handleStepping(Z,$,X,Q):Z!==""&&this.handleNumber(Z,$,X,Q)}throwAtIllegalCharacters($){for(let Z=0;Z<$.length;Z++)if((Z===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test($[Z]))throw TypeError("CronPattern: configuration entry "+Z+" ("+$[Z]+") contains illegal characters.")}handleNumber($,Z,X,Q){let Y=this.extractNth($,Z),G=parseInt(Y[0],10)+X;if(isNaN(G))throw TypeError("CronPattern: "+Z+" is not a number: '"+$+"'");this.setPart(Z,G,Y[1]||Q)}setPart($,Z,X){if(!Object.prototype.hasOwnProperty.call(this,$))throw TypeError("CronPattern: Invalid part specified: "+$);if($==="dayOfWeek"){if(Z===7&&(Z=0),Z<0||Z>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+Z);this.setNthWeekdayOfMonth(Z,X);return}if($==="second"||$==="minute"){if(Z<0||Z>=60)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="hour"){if(Z<0||Z>=24)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="day"){if(Z<0||Z>=31)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="month"&&(Z<0||Z>=12))throw RangeError("CronPattern: Invalid value for "+$+": "+Z);this[$][Z]=X}handleRangeWithStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(G===null)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+$+"'");let[,J,K,W]=G,H=parseInt(J,10)+X,F=parseInt(K,10)+X,N=parseInt(W,10);if(isNaN(H))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(F))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(N))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(N===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(N>this[Z].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[Z].length+")");if(H>F)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let U=H;U<=F;U+=N)this.setPart(Z,U,Y[1]||Q)}extractNth($,Z){let X=$,Q;if(X.includes("#")){if(Z!=="dayOfWeek")throw Error("CronPattern: nth (#) only allowed in day-of-week field");Q=X.split("#")[1],X=X.split("#")[0]}return[X,Q]}handleRange($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("-");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal range: '"+$+"'");let J=parseInt(G[0],10)+X,K=parseInt(G[1],10)+X;if(isNaN(J))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(J>K)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let W=J;W<=K;W++)this.setPart(Z,W,Y[1]||Q)}handleStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("/");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+$+"'");G[0]===""&&(G[0]="*");let J=0;G[0]!=="*"&&(J=parseInt(G[0],10)+X);let K=parseInt(G[1],10);if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(K===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(K>this[Z].length)throw TypeError("CronPattern: Syntax error, max steps for part is ("+this[Z].length+")");for(let W=J;W<this[Z].length;W+=K)this.setPart(Z,W,Y[1]||Q)}replaceAlphaDays($){return $.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths($){return $.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames($){let Z=$.trim().toLowerCase();return Z==="@yearly"||Z==="@annually"?"0 0 1 1 *":Z==="@monthly"?"0 0 1 * *":Z==="@weekly"?"0 0 * * 0":Z==="@daily"?"0 0 * * *":Z==="@hourly"?"0 * * * *":$}setNthWeekdayOfMonth($,Z){if(typeof Z!="number"&&Z==="L")this.dayOfWeek[$]=this.dayOfWeek[$]|rX1;else if(Z===Ns)this.dayOfWeek[$]=Ns;else if(Z<6&&Z>0)this.dayOfWeek[$]=this.dayOfWeek[$]|kb$[Z-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${Z}, Type: ${typeof Z}`)}},Mb$,UU,$3=class ${tz;ms;second;minute;hour;day;month;year;constructor(Z,X){if(this.tz=X,Z&&Z instanceof Date)if(!isNaN(Z))this.fromDate(Z);else throw TypeError("CronDate: Invalid date passed to CronDate constructor");else if(Z===void 0)this.fromDate(new Date);else if(Z&&typeof Z=="string")this.fromString(Z);else if(Z instanceof $)this.fromCronDate(Z);else throw TypeError("CronDate: Invalid type ("+typeof Z+") passed to CronDate constructor")}isNthWeekdayOfMonth(Z,X,Q,Y){let G=new Date(Date.UTC(Z,X,Q)).getUTCDay(),J=0;for(let K=1;K<=Q;K++)new Date(Date.UTC(Z,X,K)).getUTCDay()===G&&J++;if(Y&Ns&&kb$[J-1]&Y)return!0;if(Y&rX1){let K=new Date(Date.UTC(Z,X+1,0)).getUTCDate();for(let W=Q+1;W<=K;W++)if(new Date(Date.UTC(Z,X,W)).getUTCDay()===G)return!1;return!0}return!1}fromDate(Z){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes()+this.tz,this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),this.apply();else{let X=SX.toTZ(Z,this.tz);this.ms=Z.getMilliseconds(),this.second=X.s,this.minute=X.i,this.hour=X.h,this.day=X.d,this.month=X.m-1,this.year=X.y}else this.ms=Z.getMilliseconds(),this.second=Z.getSeconds(),this.minute=Z.getMinutes(),this.hour=Z.getHours(),this.day=Z.getDate(),this.month=Z.getMonth(),this.year=Z.getFullYear()}fromCronDate(Z){this.tz=Z.tz,this.year=Z.year,this.month=Z.month,this.day=Z.day,this.hour=Z.hour,this.minute=Z.minute,this.second=Z.second,this.ms=Z.ms}apply(){if(this.month>11||this.day>Mb$[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let Z=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes(),this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),!0}else return!1}fromString(Z){if(typeof this.tz=="number"){let X=SX.fromTZISO(Z);this.ms=X.getUTCMilliseconds(),this.second=X.getUTCSeconds(),this.minute=X.getUTCMinutes(),this.hour=X.getUTCHours(),this.day=X.getUTCDate(),this.month=X.getUTCMonth(),this.year=X.getUTCFullYear(),this.apply()}else return this.fromDate(SX.fromTZISO(Z,this.tz))}findNext(Z,X,Q,Y){let G=this[X],J;Q.lastDayOfMonth&&(this.month!==1?J=Mb$[this.month]:J=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let K=!Q.starDOW&&X=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let W=this[X]+Y;W<Q[X].length;W++){let H=Q[X][W];if(X==="day"&&Q.lastDayOfMonth&&W-Y==J&&(H=1),X==="day"&&!Q.starDOW){let F=Q.dayOfWeek[(K+(W-Y-1))%7];if(F&&F&Ns)F=this.isNthWeekdayOfMonth(this.year,this.month,W-Y,F)?1:0;else if(F)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${F}`);Z.legacyMode&&!Q.starDOM?H=H||F:H=H&&F}if(H)return this[X]=W-Y,G!==this[X]?2:1}return 3}recurse(Z,X,Q){let Y=this.findNext(X,UU[Q][0],Z,UU[Q][2]);if(Y>1){let G=Q+1;for(;G<UU.length;)this[UU[G][0]]=-UU[G][2],G++;if(Y===3)return this[UU[Q][1]]++,this[UU[Q][0]]=-UU[Q][2],this.apply(),this.recurse(Z,X,0);if(this.apply())return this.recurse(Z,X,Q-1)}return Q+=1,Q>=UU.length?this:this.year>=3000?null:this.recurse(Z,X,Q)}increment(Z,X,Q){return this.second+=X.interval!==void 0&&X.interval>1&&Q?X.interval:1,this.ms=0,this.apply(),this.recurse(Z,X,0)}getDate(Z){return Z||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):SX.fromTZ(SX.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}},Vb$=30000,hT0,uT0=class{name;options;_states;fn;constructor($,Z,X){let Q,Y;if(Fs(Z))Y=Z;else if(typeof Z=="object")Q=Z;else if(Z!==void 0)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(Fs(X))Y=X;else if(typeof X=="object")Q=X;else if(X!==void 0)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=Q?.name,this.options=R06(Q),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:Q?Q.maxRuns:void 0,paused:Q?Q.paused:!1,pattern:new qb$("* * * * *")},$&&($ instanceof Date||typeof $=="string"&&$.indexOf(":")>0)?this._states.once=new $3($,this.options.timezone||this.options.utcOffset):this._states.pattern=new qb$($,this.options.timezone),this.name){if(hT0.find((G)=>G.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");hT0.push(this)}return Y!==void 0&&I06(Y)&&(this.fn=Y,this.schedule()),this}nextRun($){let Z=this._next($);return Z?Z.getDate(!1):null}nextRuns($,Z){this._states.maxRuns!==void 0&&$>this._states.maxRuns&&($=this._states.maxRuns);let X=[],Q=Z||this._states.currentRun||void 0;for(;$--&&(Q=this.nextRun(Q));)X.push(Q);return X}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let $=this.nextRun(this._states.currentRun),Z=!this._states.paused,X=this.fn!==void 0,Q=!this._states.kill;return Z&&X&&Q&&$!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext($){let Z=this._next($);return Z?$ instanceof $3||$ instanceof Date?Z.getTime()-$.getTime():Z.getTime()-new $3($).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let $=hT0.indexOf(this);$>=0&&hT0.splice($,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule($){if($&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");$&&(this.fn=$);let Z=this.msToNext(),X=this.nextRun(this._states.currentRun);return Z==null||isNaN(Z)||X===null?this:(Z>Vb$&&(Z=Vb$),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(X),Z),this._states.currentTimeout&&this.options.unref&&q06(this._states.currentTimeout),this)}async _trigger($){if(this._states.blocking=!0,this._states.currentRun=new $3(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(Z){Fs(this.options.catch)&&this.options.catch(Z,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new $3($,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger($){let Z=new Date,X=!this._states.paused&&Z.getTime()>=$.getTime(),Q=this._states.blocking&&this.options.protect;X&&!Q?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):X&&Q&&Fs(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next($){let Z=!!($||this._states.currentRun),X=!1;!$&&this.options.startAt&&this.options.interval&&([$,Z]=this._calculatePreviousRun($,Z),X=!$),$=new $3($,this.options.timezone||this.options.utcOffset),this.options.startAt&&$&&$.getTime()<this.options.startAt.getTime()&&($=this.options.startAt);let Q=this._states.once||new $3($,this.options.timezone||this.options.utcOffset);return!X&&Q!==this._states.once&&(Q=Q.increment(this._states.pattern,this.options,Z)),this._states.once&&this._states.once.getTime()<=$.getTime()||Q===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&Q.getTime()>=this.options.stopAt.getTime()?null:Q}_calculatePreviousRun($,Z){let X=new $3(void 0,this.options.timezone||this.options.utcOffset),Q=$;if(this.options.startAt.getTime()<=X.getTime()){Q=this.options.startAt;let Y=Q.getTime()+this.options.interval*1000;for(;Y<=X.getTime();)Q=new $3(Q,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),Y=Q.getTime()+this.options.interval*1000;Z=!0}return Q===null&&(Q=void 0),[Q,Z]}};var aX1=L(()=>{SX.fromTZISO=($,Z,X)=>SX.fromTZ(T06($,Z),X);SX.fromTZ=function($,Z){let X=new Date(Date.UTC($.y,$.m-1,$.d,$.h,$.i,$.s)),Q=oX1($.tz,X),Y=new Date(X.getTime()-Q),G=oX1($.tz,Y);if(G-Q===0)return Y;{let J=new Date(X.getTime()-G),K=oX1($.tz,J);if(K-G===0)return J;if(!Z&&K-G>0)return J;if(Z)throw Error("Invalid date passed to fromTZ()");return Y}};SX.toTZ=function($,Z){let X=$.toLocaleString("en-US",{timeZone:Z}).replace(/[\u202f]/," "),Q=new Date(X);return{y:Q.getFullYear(),m:Q.getMonth()+1,d:Q.getDate(),h:Q.getHours(),i:Q.getMinutes(),s:Q.getSeconds(),tz:Z}};SX.tp=($,Z,X,Q,Y,G,J)=>({y:$,m:Z,d:X,h:Q,i:Y,s:G,tz:J});SX.minitz=SX;Ns=31|rX1,kb$=[1,2,4,8,16],Mb$=[31,28,31,30,31,30,31,31,30,31,30,31],UU=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]];hT0=[]});function cT0($,Z){try{return new uT0($,{timezone:"UTC"}).nextRun(Z)??null}catch{return null}}var sX1=L(()=>{aX1()});import{DBOS as C7,SchedulerMode as M06}from"@dbos-inc/dbos-sdk";async function QQ1($){try{let{rows:Z}=await $.query(`SELECT q.name FROM dbos.queues q
|
|
2853
2853
|
WHERE q.name LIKE $1
|
|
2854
2854
|
AND NOT EXISTS (
|
|
2855
2855
|
SELECT 1 FROM dbos.workflow_status w
|