@lobu/runtime-server 24.5.0 → 24.6.0
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/catalogs/connectors.json +342 -4
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/linkedin-identity.ts +43 -0
- package/dist/connectors/linkedin.ts +154 -3
- package/dist/connectors/x-like-follow.ts +329 -0
- package/dist/connectors/x.ts +709 -80
- package/dist/dependencies.bun.lock +18 -18
- package/dist/owletto/dist/assets/_-DT3E3BmS.js +3 -0
- package/dist/owletto/dist/assets/_-c1xy7bLu.js +2 -0
- package/dist/owletto/dist/assets/_agentId-CTfoi0-7.js +2 -0
- package/dist/owletto/dist/assets/_agentId-DV8utajn.js +2 -0
- package/dist/owletto/dist/assets/_automationId-DvP3qyYL.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-CL5SivCn.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-tnMwC67b.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-DXN_8m88.js +2 -0
- package/dist/owletto/dist/assets/_eventId-SdpFT7jB.js +2 -0
- package/dist/owletto/dist/assets/_name-CM1AMywz.js +2 -0
- package/dist/owletto/dist/assets/_owner-CaGsXXBW.js +3 -0
- package/dist/owletto/dist/assets/_shape-DGAkETDp.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-Dd4ZHPY8.js +2 -0
- package/dist/owletto/dist/assets/_slug-cRvJQtNo.js +2 -0
- package/dist/owletto/dist/assets/_view-B5I7mmkl.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-Bwn0dyLo.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-YjSYD0wc.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-pUl-c1KQ.js → accept-invitation-CQZQ0wwC.js} +2 -2
- package/dist/owletto/dist/assets/{activity-route-view-DN0ZEAzr.js → activity-route-view-CZykJXQp.js} +2 -2
- package/dist/owletto/dist/assets/{agent-card-controls-C5jNWgfq.js → agent-card-controls-DuQJhtqp.js} +2 -2
- package/dist/owletto/dist/assets/{agent-client-setup-list-DbXtJTsO.js → agent-client-setup-list-CpUTAjXf.js} +2 -2
- package/dist/owletto/dist/assets/{agent-connect-pages-DcTuiSt9.js → agent-connect-pages-Br_ycC0z.js} +2 -2
- package/dist/owletto/dist/assets/agent-editor-form-BXQBFHSv.js +2 -0
- package/dist/owletto/dist/assets/{agent-guardrails-route-BJyfalBY.js → agent-guardrails-route-CN7vpC0X.js} +2 -2
- package/dist/owletto/dist/assets/{agent-list-row-rF5LH-3k.js → agent-list-row-BnP6r4pm.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-ClY_O6lb.js → agent-loading-shells-_18OREnx.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-bP1Qihv7.js → agent-permissions-matrix-DSjidWHL.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-BAaGpvfS.js → agent-skill-context-1DBn7Xc_.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-Bv5luNdw.js → agent-skills-route-d5jh3oBR.js} +2 -2
- package/dist/owletto/dist/assets/{agent-tab-intro-ednTs4WF.js → agent-tab-intro-DKrC3SQt.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-WNk2HapT.js → agent-thread-FyEO-y44.js} +3 -3
- package/dist/owletto/dist/assets/agents-kXojozTU.js +2 -0
- package/dist/owletto/dist/assets/{agents-workbench-bPTjdVS1.js → agents-workbench-CDpJmUVN.js} +2 -2
- package/dist/owletto/dist/assets/{app._appId-DrL5H5lB.js → app._appId-DwNeXRJp.js} +2 -2
- package/dist/owletto/dist/assets/{assist-composer-ClfFEVx7.js → assist-composer-Mn9EfX4X.js} +2 -2
- package/dist/owletto/dist/assets/automation-detail-content-Bs3vwAPd.js +2 -0
- package/dist/owletto/dist/assets/{automation-row-DCHM--aD.js → automation-row-B5Q1B10y.js} +2 -2
- package/dist/owletto/dist/assets/automation-source-list-Dhucq1sI.js +2 -0
- package/dist/owletto/dist/assets/automations-kXojozTU.js +2 -0
- package/dist/owletto/dist/assets/{callback-DRABUOha.js → callback-9xSHyA12.js} +2 -2
- package/dist/owletto/dist/assets/{card-Bdi7VEwo.js → card-g4yxo4Hr.js} +2 -2
- package/dist/owletto/dist/assets/{change-summary-PBoM6Asb.js → change-summary-DeuXQEpb.js} +2 -2
- package/dist/owletto/dist/assets/{claim-CUIG1Oc-.js → claim-B98IhDra.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-CXOWB5co.js → client-activity-scopes-BD2HBo-_.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-36VnmgMK.js → client-rows-x_CxeWkP.js} +2 -2
- package/dist/owletto/dist/assets/{clients-BJRcMk1A.js → clients-Cmp0LmOp.js} +2 -2
- package/dist/owletto/dist/assets/connect-menu-CezOH3s7.js +2 -0
- package/dist/owletto/dist/assets/connect-zUot_0kG.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-nsGxe6yO.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-DnclRRXk.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-CDB8atTX.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId.index-jSnGvzYs.js → connected._clientId.index-DBNP2mZo.js} +2 -2
- package/dist/owletto/dist/assets/{connection-q1bdnxCN.js → connection-B6fM2KHN.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-BIlkK0Pd.js → connection-feed-detail-Ckq-qEbD.js} +2 -2
- package/dist/owletto/dist/assets/{connections-browser-V-3td9DB.js → connections-browser-BXsJqieG.js} +2 -2
- package/dist/owletto/dist/assets/{connector-boxes-lFc-WP83.js → connector-boxes-CbqSFeVm.js} +2 -2
- package/dist/owletto/dist/assets/{connector-page-shell-Cs1SjrYB.js → connector-page-shell-Di6XzkVo.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-aJFeeRIC.js → connector-provenance-BrnasBW4.js} +2 -2
- package/dist/owletto/dist/assets/{connector-scope-lists--vNdbOn0.js → connector-scope-lists-dQnZARCD.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-BsvDMdsQ.js → connectors-DnOUxX_U.js} +2 -2
- package/dist/owletto/dist/assets/{consent-DJV78pnz.js → consent-Byli4yMs.js} +2 -2
- package/dist/owletto/dist/assets/{copy-button-DjMWgrBf.js → copy-button-Ddf7lBjZ.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-CQzL3ObT.js → core.esm-BsXtvNoI.js} +2 -2
- package/dist/owletto/dist/assets/create-B34eskZ_.js +2 -0
- package/dist/owletto/dist/assets/create-DLB9sXgU.js +2 -0
- package/dist/owletto/dist/assets/{create-jBEuveV1.js → create-YdAnh3ml.js} +2 -2
- package/dist/owletto/dist/assets/create-automation-form-C9PMX7N8.js +3 -0
- package/dist/owletto/dist/assets/create._connectorKey-Bz4OYRiC.js +2 -0
- package/dist/owletto/dist/assets/definition-comparison-B5WgZILB.js +2 -0
- package/dist/owletto/dist/assets/{device-Ba3RsIgb.js → device-DdCoCj-Q.js} +2 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-B06J7Af1.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-Bh9S4bFp.js +2 -0
- package/dist/owletto/dist/assets/dynamic-schema-form-qWSRtOAv.js +2 -0
- package/dist/owletto/dist/assets/{entity-options-daOOQo7O.js → entity-options-BkU_En_f.js} +2 -2
- package/dist/owletto/dist/assets/entity-page-BPFDHY8q.js +2 -0
- package/dist/owletto/dist/assets/entity-pages-DxgbjLMt.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-D0ghgRgq.js +2 -0
- package/dist/owletto/dist/assets/event-card-CjA_dLzq.js +2 -0
- package/dist/owletto/dist/assets/{event-detail-DkY95e5b.js → event-detail-CmC-DVrK.js} +2 -2
- package/dist/owletto/dist/assets/{events-feed-B9CZHI_P.js → events-feed-CGzA1w3R.js} +2 -2
- package/dist/owletto/dist/assets/filter-bar-CQ_oE7a9.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BqmckkOf.js → full-page-spinner-B5xXnKtV.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-DkXatmea.js +2 -0
- package/dist/owletto/dist/assets/identity-BwJy3ixB.js +2 -0
- package/dist/owletto/dist/assets/{index--ZWegctR.js → index-35ehGReZ.js} +2 -2
- package/dist/owletto/dist/assets/index-B9hYiwBw.js +2 -0
- package/dist/owletto/dist/assets/{index-C186T2Rw.js → index-BDl1_w6U.js} +2 -2
- package/dist/owletto/dist/assets/{index-ijqrJaRB.js → index-BdNR51Ua.js} +2 -2
- package/dist/owletto/dist/assets/{index-DdBTTN3y.js → index-BjcZVe7n.js} +52 -52
- package/dist/owletto/dist/assets/{index-CsrT07TJ.js → index-BqAVebvY.js} +2 -2
- package/dist/owletto/dist/assets/index-BvK1fS1J.js +2 -0
- package/dist/owletto/dist/assets/{index-DdYWarql.css → index-CNEpTkgw.css} +1 -1
- package/dist/owletto/dist/assets/index-CRc73k1t.js +2 -0
- package/dist/owletto/dist/assets/index-CYGaSD3y.js +2 -0
- package/dist/owletto/dist/assets/index-CfZGe-zn.js +2 -0
- package/dist/owletto/dist/assets/{index-B0kw2lFL.js → index-CkiyxW4w.js} +2 -2
- package/dist/owletto/dist/assets/index-CzLDNB2E.js +2 -0
- package/dist/owletto/dist/assets/{index-BKrdVwW9.js → index-D-o5iOVd.js} +2 -2
- package/dist/owletto/dist/assets/index-DjYVV1Ml.js +2 -0
- package/dist/owletto/dist/assets/{index-ikp_mTsf.js → index-TkPy_P_u.js} +2 -2
- package/dist/owletto/dist/assets/index-VyAX-asP.js +2 -0
- package/dist/owletto/dist/assets/json-diff-DtZtra_g.js +28 -0
- package/dist/owletto/dist/assets/{list-skeleton-CXDLkYTg.js → list-skeleton-CIHWCi2a.js} +2 -2
- package/dist/owletto/dist/assets/{login-u6LCgDYG.js → login-TWR0vF4_.js} +2 -2
- package/dist/owletto/dist/assets/{logout-JhmuWJEH.js → logout-BA5kojS0.js} +2 -2
- package/dist/owletto/dist/assets/{manage-gear-D8LMhehh.js → manage-gear-C-0BAMbC.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-4FQ0aanZ.js → member-scope-gate-BQiRAqtx.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-Ba32-vVL.js +74 -0
- package/dist/owletto/dist/assets/{model-jL871x2J.js → model-C2q7WDcS.js} +2 -2
- package/dist/owletto/dist/assets/{model-selector-CgU8SJMF.js → model-selector-B2cjCn0V.js} +2 -2
- package/dist/owletto/dist/assets/models-CZkH5gtj.js +2 -0
- package/dist/owletto/dist/assets/{nav-pill-DrFkuyUQ.js → nav-pill-Bam6s3jj.js} +2 -2
- package/dist/owletto/dist/assets/new-BJst6K0b.js +2 -0
- package/dist/owletto/dist/assets/{new-DgE1pVV0.js → new-Dc5Bbotb.js} +2 -2
- package/dist/owletto/dist/assets/new-DgbivfDe.js +2 -0
- package/dist/owletto/dist/assets/{organization-CKM_oFX3.js → organization-B9U1L-56.js} +2 -2
- package/dist/owletto/dist/assets/peek-pane-content-Cq8P38s3.js +2 -0
- package/dist/owletto/dist/assets/{pending-seed-sml8Uf6e.js → pending-seed-BP3xHM2d.js} +2 -2
- package/dist/owletto/dist/assets/{permissions-BvA9SATv.js → permissions-BVlbeY4u.js} +2 -2
- package/dist/owletto/dist/assets/proposal-review-shell-BED-DO9C.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-Diq15_QW.js +2 -0
- package/dist/owletto/dist/assets/{record-activity-C9gVBbF0.js → record-activity-CTLwq8s1.js} +2 -2
- package/dist/owletto/dist/assets/{record-session-R-uHNuby.js → record-session-DOFgdd43.js} +2 -2
- package/dist/owletto/dist/assets/renderer-CHPS-1vD.js +96 -0
- package/dist/owletto/dist/assets/{reset-password-Mx3baeNc.js → reset-password-BmNM-apc.js} +2 -2
- package/dist/owletto/dist/assets/{run-activity-link-CaIBSRQj.js → run-activity-link-Dh1YyCfk.js} +2 -2
- package/dist/owletto/dist/assets/{run-initiator-BvzQJYW9.js → run-initiator-CCxNv0rK.js} +2 -2
- package/dist/owletto/dist/assets/{runs-fFJ1lPnw.js → runs-BntGAKQG.js} +2 -2
- package/dist/owletto/dist/assets/{runs-panel-DEnZHTa5.js → runs-panel-BwTVaRsE.js} +2 -2
- package/dist/owletto/dist/assets/{runs-table-XGnxJl7S.js → runs-table-CYS1jDdL.js} +2 -2
- package/dist/owletto/dist/assets/{schema-type-editor-panel-C0_9VcSs.js → schema-type-editor-panel-v3nR2Oa2.js} +2 -2
- package/dist/owletto/dist/assets/schema-value-BFb7jCBo.js +3 -0
- package/dist/owletto/dist/assets/settings-DBgT60nY.js +2 -0
- package/dist/owletto/dist/assets/{settings-CP4PjMQA.js → settings-DubSpJfg.js} +2 -2
- package/dist/owletto/dist/assets/skills-DDoeRGhJ.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-Bh0n4gGw.js → source-record-panels-m8gECt82.js} +2 -2
- package/dist/owletto/dist/assets/{status-dot-Cpq63I7p.js → status-dot-BnQPFrcU.js} +2 -2
- package/dist/owletto/dist/assets/{table-BUqshjxa.js → table-DALHuXPE.js} +2 -2
- package/dist/owletto/dist/assets/{use-automations-BLNjxq2K.js → use-automations-D9hKpufo.js} +2 -2
- package/dist/owletto/dist/assets/{use-login-redirect-CmyQW7GT.js → use-login-redirect-ciwfc-7A.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-dn3ws1WB.js → use-mention-search-CJGCatFS.js} +2 -2
- package/dist/owletto/dist/assets/{use-scroll-sentinel-DRyBMueA.js → use-scroll-sentinel-BWCrmNIB.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-CDvwie_f.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-CZ1fvAks.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +5596 -4000
- package/npm-shrinkwrap.json +99 -99
- package/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/contracts/tools/view-host.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/view-host.js +28 -0
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -4
- package/vendor/core/dist/contracts/tools/view-runtime.js +19 -7
- package/vendor/core/package.json +11 -1
- package/vendor/views/dist/api.d.ts +9 -4
- package/vendor/views/dist/api.js +33 -2
- package/vendor/views/dist/bridge.d.ts +8 -0
- package/vendor/views/dist/bridge.js +12 -2
- package/vendor/views/dist/components.d.ts +4 -2
- package/vendor/views/dist/components.js +29 -14
- package/vendor/views/dist/index.d.ts +1 -1
- package/vendor/views/dist/index.js +1 -1
- package/vendor/views/dist/native.d.ts +327 -0
- package/vendor/views/dist/native.js +57 -0
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-CCWuGXtQ.js +0 -2
- package/dist/owletto/dist/assets/_-DOJW1D-I.js +0 -3
- package/dist/owletto/dist/assets/_agentId-CJhQbi6k.js +0 -2
- package/dist/owletto/dist/assets/_agentId-DD4K1i6V.js +0 -2
- package/dist/owletto/dist/assets/_automationId-Cbd7B0mP.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DFpPep9B.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-n3iSDT74.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-B1yGIGA9.js +0 -2
- package/dist/owletto/dist/assets/_eventId-B1H0-vD7.js +0 -2
- package/dist/owletto/dist/assets/_name-D30_V03t.js +0 -2
- package/dist/owletto/dist/assets/_owner-Be8O41u8.js +0 -3
- package/dist/owletto/dist/assets/_shape-C6YbloRh.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-BMPvvoOI.js +0 -2
- package/dist/owletto/dist/assets/_slug-Bc4YIEA2.js +0 -2
- package/dist/owletto/dist/assets/_view-aoFDwEld.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DuNHc3cc.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-rJ7A1zNx.js +0 -2
- package/dist/owletto/dist/assets/agent-editor-form-CdA5vLr8.js +0 -2
- package/dist/owletto/dist/assets/agents-DY2S2SGE.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-dFy1Huas.js +0 -2
- package/dist/owletto/dist/assets/automations-DY2S2SGE.js +0 -2
- package/dist/owletto/dist/assets/calendar-Ck0yOLYu.js +0 -2
- package/dist/owletto/dist/assets/code-editor-DNuRKde1.js +0 -16
- package/dist/owletto/dist/assets/connect-CMcEQWls.js +0 -2
- package/dist/owletto/dist/assets/connect-menu-C-B-1xGR.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-tGipxP5a.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-DSGU78eV.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-CPLbry8R.js +0 -2
- package/dist/owletto/dist/assets/create-BmKx5vq3.js +0 -2
- package/dist/owletto/dist/assets/create-Rt0RbiD4.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-PEmSLMD6.js +0 -3
- package/dist/owletto/dist/assets/create._connectorKey-DcxhYIYC.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-C79KIAIK.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-CIaoq9co.js +0 -2
- package/dist/owletto/dist/assets/entity-avatar-TVKjZxWQ.js +0 -2
- package/dist/owletto/dist/assets/entity-page-BfJXvbxn.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-BLwH6qa7.js +0 -2
- package/dist/owletto/dist/assets/event-card-DVUB8my6.js +0 -2
- package/dist/owletto/dist/assets/filter-bar-wPaR12SS.js +0 -2
- package/dist/owletto/dist/assets/guardrails-Csusrok2.js +0 -2
- package/dist/owletto/dist/assets/identity-Dmg3STO8.js +0 -2
- package/dist/owletto/dist/assets/index-BUBcNNUY.js +0 -2
- package/dist/owletto/dist/assets/index-BUDr4-Yv.js +0 -2
- package/dist/owletto/dist/assets/index-BYPQWVwD.js +0 -2
- package/dist/owletto/dist/assets/index-BfpaPJPj.js +0 -2
- package/dist/owletto/dist/assets/index-BicNFLBW.js +0 -2
- package/dist/owletto/dist/assets/index-Bsdv5aks.js +0 -2
- package/dist/owletto/dist/assets/index-CX0pJ9j9.js +0 -2
- package/dist/owletto/dist/assets/index-JYEIN8nM.js +0 -2
- package/dist/owletto/dist/assets/json-diff-BaLL4Fsu.js +0 -14
- package/dist/owletto/dist/assets/memory-browse-page-CNZJbCJC.js +0 -74
- package/dist/owletto/dist/assets/models-jdemgIZk.js +0 -2
- package/dist/owletto/dist/assets/new-CcJOd5aH.js +0 -2
- package/dist/owletto/dist/assets/new-OWwrYckd.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-D68BjguQ.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-D6KABxah.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-BIVCHQHe.js +0 -2
- package/dist/owletto/dist/assets/renderer-DXfJaCCa.js +0 -97
- package/dist/owletto/dist/assets/settings-CgaUJMHH.js +0 -2
- package/dist/owletto/dist/assets/skills-D-e_h3a9.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-CER47Tlz.js +0 -2
- package/dist/owletto/dist/assets/views-access-required-C_b9itZ2.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{j as s,r as a,aL as Ht,a6 as zt,
|
|
1
|
+
import{j as s,r as a,aL as Ht,a6 as zt,gZ as Wt,g_ as Kt,a3 as tt,Q as Be,a4 as nt,ca as qt,g$ as rt,h0 as Gt,L as gt,i as P,fb as Qt,e5 as bt,e7 as Yt,h1 as Jt,cI as Xt,eb as Zt,h2 as en,az as tn,B as fe,e$ as nn,h3 as rn,h4 as He,X as on,ab as sn,db as ln,dh as Ne,h5 as an,dT as cn,dV as un,h6 as dn,dU as fn,fj as pn,h7 as mn,h8 as hn,eE as gn,W as bn,h9 as xn,ha as vn}from"./index-BjcZVe7n.js";import{D as yn,E as Rn}from"./app-bridge-C4nPtae3.js";import{A as wn,a as Sn,b as Tn,c as Ge,d as xt,e as Cn}from"./agent-loading-shells-_18OREnx.js";import{t as jn,P as Nn}from"./pending-seed-BP3xHM2d.js";import{h as En,t as An,R as In,i as kn,u as _n,M as On,a as Pn}from"./use-mention-search-CJGCatFS.js";import{t as ot,c as Mn}from"./event-card-CjA_dLzq.js";import{E as Ln}from"./events-feed-CGzA1w3R.js";const vt=a.createContext(null);function $n({extension:e,children:t}){return s.jsx(vt.Provider,{value:e??null,children:t})}function Qe(){return a.useContext(vt)}var Ye=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Ye||{});const Dn={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function Un(e){if(typeof e=="string")return Object.values(Ye).includes(e)?e:void 0}const Fn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:Dn,AgentErrorCode:Ye,toAgentErrorCode:Un},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Vn,toAgentErrorCode:Bn}=Fn;function st(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function yt(e,t){const n=Bn(e);if(!n)return null;const r=Vn[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const i=t.provider?`/${o}/connectors/${encodeURIComponent(`${Ht}${t.provider}`)}`:`/${o}/connectors`,c=st(i,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const l=st(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return l?{label:r.ctaLabel??"Open settings",href:l}:null}function Rt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const lt=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Hn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function at(e,t){const n=Hn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function it(e,t,n){try{const r=new URL(t),o=new URL(e,t),l=lt.has(o.hostname)&<.has(r.hostname),i=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&at(o.hostname,n)&&at(r.hostname,n);return o.origin!==r.origin&&(l||i)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const zn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,wt=new Set(["suggest_actions"]),Me="Thinking…";function Wn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,l=[];n===Me&&l.push({type:"reasoning"}),r&&l.push({type:"error",text:r});let i=t;return n&&n!==Me&&(i=t?`${t}
|
|
2
2
|
|
|
3
3
|
${n}`:n),i&&l.push({type:"text",text:i}),l.push(...o),l}const St=[];function Kn(e,t,n){return e?.length?e:n===0?t:[]}const Je=a.createContext(null);function Ee(){const e=a.useContext(Je);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function Uo({messages:e,workspaceSlug:t=null,children:n}){const r=a.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:t,currentSuggestions:null,starters:St}),[e,t]);return s.jsx(Je.Provider,{value:r,children:n})}const Tt=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function ct(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(Tt,"").replace(/\n{3,}/g,`
|
|
4
4
|
|
|
5
|
-
`).trim()}function qn(e){const t=[];for(const n of e.matchAll(Tt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Gn(e,t={}){if(typeof e=="string"){const r=ct(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const l=ct(o.text);l&&n.push({type:"text",text:l})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!wt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function Yn(e){const t=[],n=r=>{for(const{name:o,url:l}of qn(r))t.push({id:`file-${t.length}`,name:o,url:l,isImage:zn.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const l=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${l};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function Qn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Gn(e.content,t),attachments:Yn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Jn=[],Xn=[];function Zn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function er(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=yt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const tr=3e4,nr=3*tr,rr=15e3;function ut(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const be=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function or(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:l}=r;if(typeof o!="string"||typeof l!="string")continue;const i=o.trim(),c=l.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function Fo({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:l,children:i,initialDraft:c}){const u=zt(),d=a.useRef(null),m=a.useRef(null),y=a.useRef(!1),h=a.useRef(o),g=a.useRef(!1),w=a.useRef(null);h.current=o;const{data:E,isLoading:v}=Wt(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),T=E?.messages??Jn,H=E?.interactions??Xn,{data:U}=Kt(e,{enabled:!!e}),K=U?.starters??St,z=!!(U?.showToolCalls??U?.settings?.showToolCalls),[N,L]=a.useState([]),[G,le]=a.useState(!1),[$,q]=a.useState([]),[Y,R]=a.useState(null),S=a.useRef(!1);S.current=G;const C=a.useMemo(()=>T.map(I=>Qn(I,{showToolCalls:z})).filter(I=>I!==null),[T,z]),O=a.useRef(!1);a.useEffect(()=>{if(O.current||v||S.current)return;O.current=!0;const I=er(H,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});L(I?[...C,I]:C),R(Zn(H))},[e,v,C,H,t]);const A=a.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),Z=a.useCallback(async()=>{if(d.current)return d.current;if(m.current)return m.current;if(!e)throw new Error("No agent selected");const I=(async()=>{const M=await tt(`${Be}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!M.ok)throw await nt(M);const V=await M.json(),j=qt(),J={sessionId:V.agentId,sseUrl:it(V.sseUrl,Be,j),messagesUrl:it(V.messagesUrl,Be,j)};return d.current=J,J})();m.current=I;try{return await I}catch(M){throw d.current=null,M}finally{m.current=null}},[e,t,n]),te=a.useCallback(async(I,M,V)=>{const j=crypto.randomUUID(),J=new AbortController;w.current=J;const W=f=>{L(p=>p.map(b=>b.id===V?{...b,parts:f}:b))};let B;try{B=await Z()}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Could not start a session."}`}]);return}let X=await rt(B.sseUrl,{throwOnFailure:!0});const pe=[];let ie=null;const Re=()=>{const f=ie;ie=null,f?.()},we=f=>{pe.push(f),Re()},Se=(f,p)=>{const k=["question","link-button","tool-approval"].includes(f)?p.turnMessageId===j:p.messageId===j||Array.isArray(p.processedMessageIds)&&p.processedMessageIds.includes(j);(f==="closed"||k)&&we({kind:f,payload:p})};let me=!1,Te=null;const Ie=new Promise(f=>{Te=f});let ce=0,he=Date.now();const ue=f=>{he=Date.now();const p=Number(f.lastEventId);Number.isFinite(p)&&p>ce&&(ce=p)},ke=["output","status","complete","closed","agent-error","question","link-button","tool-approval","tool_use"],Ce=f=>{f.addEventListener("open",()=>{me=!0,Te?.()}),f.addEventListener("connected",b=>{ue(b),me||(me=!0,Te?.())}),f.addEventListener("ping",ue);const p=b=>k=>{ue(k);const ee=k;typeof ee.data=="string"&&Se(b,ut(ee))};for(const b of ke)f.addEventListener(b,p(b));f.addEventListener("error",b=>{const k=b;if(typeof k.data=="string"&&k.data){ue(b),Se("error",ut(k));return}f.readyState===EventSource.CLOSED&&we({kind:"error",payload:{error:"Connection closed"}})})};Ce(X);const _e=async()=>{X.close();let f=B.sseUrl;if(ce){const p=new URL(B.sseUrl,window.location.origin);p.searchParams.set("since",String(ce)),f=p.toString()}X=await rt(f,{throwOnFailure:!1}),Ce(X),he=Date.now()};await Promise.race([Ie,new Promise(f=>setTimeout(f,1500))]);const Oe=()=>{X.close(),Re()};J.signal.addEventListener("abort",Oe,{once:!0});try{const f=h.current?.trim(),p=!!f&&!g.current;p&&(g.current=!0);let b;if(M.length>0){const x=new FormData;x.set("content",I),x.set("messageId",j),p&&f&&x.set("ephemeralContext",f);for(const _ of M)x.append("files",_,_.name);b={method:"POST",credentials:"include",body:x,timeoutMs:12e4}}else{const x={content:I,messageId:j};p&&f&&(x.ephemeralContext=f),b={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(x),timeoutMs:2e4}}const k=await tt(B.messagesUrl,b);if(!k.ok)throw d.current=null,await nt(k);let ee="",D=Me,et=null;const ge=[],de=()=>Wn({textOut:ee,statusLine:D,errorText:et,toolCalls:ge});for(W(de());!J.signal.aborted;){if(pe.length===0){let _;const ne=await Promise.race([new Promise(Ve=>{ie=()=>Ve(!0)}),new Promise(Ve=>{_=setTimeout(()=>Ve(!1),rr)})]);_&&clearTimeout(_),!ne&&Date.now()-he>=nr&&(await _e(),A());continue}const x=pe.shift();if(x){if(x.kind==="output")D=null,ee+=String(x.payload.content??"");else if(x.kind==="status")D=Me;else if(x.kind==="complete"){D=null;const _=x.payload.finalText;typeof _=="string"&&_.length>0&&(ee=_);const ne=x.payload.suggestions;ne!==void 0&&R(Array.isArray(ne)?or(ne):null),A(),W(de());return}else if(x.kind==="closed"){d.current=null;const _=x.payload.reason;D=`Session ended${_?`: ${_}`:""}.`,A(),W(de());return}else if(x.kind==="error"||x.kind==="agent-error"){D=null,et=typeof x.payload.error=="string"&&x.payload.error?x.payload.error:"Agent reported an error.";const _=x.payload.errorContext&&typeof x.payload.errorContext=="object"?x.payload.errorContext:void 0,ne=yt(x.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof _?.provider=="string"?_.provider:void 0,model:typeof _?.model=="string"?_.model:void 0});ne&&ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:ne.label,url:ne.href}}),A(),W(de());return}else if(x.kind==="question")ge.push({type:"tool-call",toolCallId:be("q"),toolName:"question",args:{question:x.payload.question??"",options:x.payload.options??[]}});else if(x.kind==="tool_use"){if(D=null,wt.has(x.payload.name??"")){W(de());continue}const _=x.payload.result_summary,ne=Rt(_);if(!z&&!ne){W(de());continue}ge.push({type:"tool-call",toolCallId:x.payload.toolCallId??be("t"),toolName:z?x.payload.name??"tool":"subscription-candidate",args:z?x.payload.input??{}:null,result:_,isError:x.payload.isError})}else if(x.kind==="link-button")ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:x.payload.label??"Open link",url:x.payload.url??""}});else if(x.kind==="tool-approval"){const _=x.payload.runId;if(typeof _!="number")continue;ge.push({type:"tool-call",toolCallId:`run-${_}`,toolName:"tool-approval",args:{runId:_,action:x.payload.action??null,proposal:x.payload.proposal??null,current:x.payload.current??null,fields:x.payload.fields??null,attribution:x.payload.attribution??null,resourceKind:x.payload.resourceKind??null}})}W(de())}}}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Send failed."}`}])}finally{J.signal.removeEventListener("abort",Oe),X.close()}},[e,Z,A,z,t]),re=a.useCallback(I=>{const M=I.trim(),V=$.map(B=>B.file);if(!M&&V.length===0||S.current||!e)return;y.current||(y.current=!0,l?.(M||V[0]?.name||""));const j={id:be("u"),role:"user",parts:M?[{type:"text",text:M}]:[],attachments:$.map(B=>({id:B.id,name:B.name,isImage:B.isImage,imageDataUrl:B.isImage?URL.createObjectURL(B.file):void 0})),createdAt:Date.now()},J=be("asst"),W={id:J,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};L(B=>[...B,j,W]),q([]),le(!0),S.current=!0,te(M,V,J).finally(()=>{le(!1),S.current=!1,w.current=null})},[e,l,$,te]),se=a.useCallback(()=>{w.current?.abort()},[]),ye=a.useCallback(I=>{const M=Array.from(I);q(V=>[...V,...M.map(j=>({id:crypto.randomUUID(),name:j.name,file:j,isImage:j.type.startsWith("image/")}))])},[]),Q=a.useCallback(I=>{q(M=>M.filter(V=>V.id!==I))},[]),ae=a.useRef(!1);a.useEffect(()=>{if(ae.current)return;const I=jn(n);I&&(ae.current=!0,re(I))},[n,re]);const F=a.useMemo(()=>({messages:N,running:G,append:re,cancel:se,pendingAttachments:$,addAttachments:ye,removeAttachment:Q,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:Y,starters:K}),[N,G,re,se,$,ye,Q,c,e,n,t,Y,K]);return r&&v?s.jsx(wn,{}):s.jsx(Je.Provider,{value:F,children:i})}const dt="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function sr({refItem:e}){const t=In[e.kind]??Gt;return kn(e.path)?s.jsxs("span",{className:dt,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(gt,{to:e.path,className:P(dt,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Xe=({text:e,renderText:t})=>En(e)?s.jsx(s.Fragment,{children:An(e).map((n,r)=>n.type==="ref"?s.jsx(sr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),lr=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),Ct=a.createContext(null),jt=()=>{const e=a.useContext(Ct);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Nt=a.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...l})=>{const[i,c]=Yt({prop:t,defaultProp:n,onChange:r}),u=a.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(Ct.Provider,{value:u,children:s.jsx("div",{className:P("not-prose max-w-prose space-y-4",e),...l,children:o})})}),Et=a.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=jt();return s.jsx(bt,{onOpenChange:o,open:r,children:s.jsxs(Qt,{className:P("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Jt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Xt,{className:P("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),At=a.memo(({className:e,icon:t=en,label:n,description:r,status:o="complete",children:l,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:P("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),l]})]})}),It=a.memo(({className:e,children:t,...n})=>{const{isOpen:r}=jt();return s.jsx(bt,{open:r,children:s.jsx(Zt,{className:P("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});Nt.displayName="ChainOfThought";Et.displayName="ChainOfThoughtHeader";At.displayName="ChainOfThoughtStep";It.displayName="ChainOfThoughtContent";function ar(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function ir({ownerSlug:e,eventIds:t}){const n=t.join(","),r=a.useMemo(()=>ar(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(tn,{owner:e,children:({organizationId:o,ownerSlug:l})=>o?s.jsx(Ln,{organizationId:o,ownerSlug:l,filters:r,hideOriginator:!0}):null})}function cr({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let l=ze(ur(r,o),t);if(!n)return a.createElement(e,l);if(typeof n=="function")return n(l,r);if(!a.isValidElement(n))return null;let i=n.props,c={...ze(l,i),ref:Ae(l.ref,i.ref)};return a.cloneElement(n,c)}function ze(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let l=r[o];if(l===void 0)continue;let i=t[o];o==="className"?t[o]=[i,l].filter(Boolean).join(" "):o==="style"?t[o]={...i,...l}:o==="ref"?t[o]=Ae(i,l):fr(o)&&typeof i=="function"&&typeof l=="function"?t[o]=dr(l,i):t[o]=l}}return t}function ur(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],l=t?.[r]?.(o);if(l){Object.assign(n,l);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function dr(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function fr(e){return/^on[A-Z]/.test(e)}function Ae(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var pr=8,mr=64,hr=0,Le=.5,gr=180,br=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),kt={start:!1,end:!1},xr=[],$e={currentAnchorId:null,visibleMessageIds:xr};function vr({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return kt;let o=Ze({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function yr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:l}){if(!e||!o)return $e;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],m=null;for(let y of je(e,r)){let h=y.dataset.messageId;if(!h)continue;let g=y.dataset.scrollAnchor==="true",w=g||u?y.getBoundingClientRect():null;(u&&w?w.bottom>c&&w.top<i.bottom:l.has(h))&&d.push(h),g&&w&&w.top<=c+Le&&(m=h)}return d.length===0&&m===null?$e:{currentAnchorId:m,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function Rr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function wr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function Sr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function Tr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function Cr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>r.top&&l.top<r.bottom)return o}return null}function jr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let l=_t(t,o),i=t.getBoundingClientRect().height,c=Ar(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return l-c.start-(u-i)/2-n}if(e==="end")return l-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=l+i,d=o.scrollTop+c.start,m=o.scrollTop+o.clientHeight-c.end;return l>=d&&u<=m?o.scrollTop:l<d?l-c.start-n:u-o.clientHeight+c.end+n}return l-c.start-n}function _t(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Pe(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Nr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Ze({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Ze({content:e,spacer:t,viewport:n}){let r=je(e,t),o=Ot(e),l=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-l.top+i+o.end)}return c}function Er(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Ot(e){let t=window.getComputedStyle(e);return{end:We(t.paddingBlockEnd||t.paddingBottom),start:We(t.paddingBlockStart||t.paddingTop)}}function Ar(e){let t=e?.parentElement;return t?Ot(t):{end:0,start:0}}function Ir(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return We(n)}function We(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function kr({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:m,messageElementsRef:y,modeRef:h,pendingScrollToMessageRef:g,prependRestoreRef:w,scrollMarginRef:E,scrollPreviousItemPeekRef:v,spacerGapRef:T,spacerHeightRef:H,spacerRef:U,viewportRef:K}=e,z=a.useCallback(R=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==R&&(i.current=R,t()),R&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},gr))},[t]),N=a.useCallback(R=>{let S=U.current;if(!S)return;let C=Math.max(0,Math.ceil(R));H.current!==C&&(H.current=C,S.hidden=C===0,S.style.height=`${C}px`,S.style.marginTop=C>0?`${-T.current}px`:"")},[]),L=a.useCallback((R,{behavior:S="auto",autoscrolling:C=!1}={})=>{let O=K.current;if(!O)return;let A=Math.max(0,R);if(Math.abs(O.scrollTop-A)<=Le){O.scrollTop=A,t();return}C&&z(!0),O.scrollTo({top:A,behavior:S}),n()},[t,n,z]),G=a.useCallback(({behavior:R="auto"}={})=>K.current?(N(0),o.current=null,h.current="free-scrolling",L(0,{behavior:R}),r(),!0):!1,[r,L,N]),le=a.useCallback(({behavior:R="auto"}={})=>{let S=K.current;return S?(N(0),o.current=null,h.current=l.current?"following-bottom":"free-scrolling",L(Er(S),{autoscrolling:!0,behavior:R}),r(),!0):!1},[r,L,N]),$=a.useCallback((R,{align:S="start",behavior:C="auto",scrollMargin:O=E.current}={},{keepPreviousPeek:A=!1}={})=>{let Z=u.current,te=K.current;if(!Z||!te||!Z.contains(R))return!1;let re=jr({align:S,element:R,scrollMargin:A?O+v.current:O,spacer:U.current,viewport:te}),se=Nr({content:Z,scrollTop:re,spacer:U.current,viewport:te});return N(se),w.current={element:R,viewportTop:Pe(R,te)},h.current=A?"anchored-to-message":"settling-jump",o.current=A?R:null,L(re,{behavior:C}),r(),!0},[r,L,N]),q=a.useCallback(()=>{let R=o.current;return!R||!R.isConnected||h.current!=="anchored-to-message"?!1:$(R,{align:"start"},{keepPreviousPeek:!0})},[$]),Y=a.useCallback((R,S)=>{let C=y.current.get(R);return C?(d.current=!0,$(C,S)?(g.current=null,!0):(g.current={messageId:R,options:S},!0)):m.current===0?(g.current={messageId:R,options:S},d.current=!0,!0):!1},[$]);return{flushPendingScrollToMessage:a.useCallback(()=>{let R=g.current;if(!R)return!1;let S=y.current.get(R.messageId);return!S||!$(S,R.options)?!1:(g.current=null,d.current=!0,!0)},[$]),reanchorToAnchoredMessage:q,scrollToElement:$,scrollToEnd:le,scrollToMessage:Y,scrollToStart:G}}function Pt(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(l=>l()))},subscribe:(o,l,i)=>{let c=r.size===0;return r.add(o),c&&l?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function _r(e,t){return Pt(e,t)}function Or(){return Pt($e,Mr)}function Pr(e,t){return e.start===t.start&&e.end===t.end}function Mr(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Lr({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=a.useRef(e),l=a.useRef(!1),i=a.useRef(null),c=a.useRef(!1),u=a.useRef(t),d=a.useRef(0),m=a.useRef(null),y=a.useRef(0),h=a.useRef(e?"following-bottom":"free-scrolling"),g=a.useRef(new Map),w=a.useRef(null),E=a.useRef(null),v=a.useRef(null),T=a.useRef(r),H=a.useRef(!0),U=a.useRef(null),K=a.useRef(n),z=a.useRef(null),N=a.useRef(0),L=a.useRef(0),G=a.useRef(null),le=a.useRef(null),$=a.useRef(null),q=a.useRef(null),Y=a.useRef(null),R=a.useRef(null),S=a.useRef(null),C=a.useRef(null),O=a.useRef(new Set),A=a.useRef(new WeakSet);return $.current===null&&($.current=_r(kt,Pr)),C.current===null&&(C.current=Or()),o.current=e,u.current=t,K.current=n,T.current=r,{autoScrollRef:o,autoscrollingRef:l,autoscrollingTimeoutRef:q,streamingTurnRef:v,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:m,itemCountRef:d,lastScrollTopRef:y,messageElementsRef:g,modeRef:h,pendingScrollFrameRef:z,pendingScrollToMessageRef:w,prependRestoreRef:E,preserveScrollOnPrependRef:H,rootRef:U,scrollEdgeThresholdRef:u,scrollMarginRef:K,scrollPreviousItemPeekRef:T,spacerGapRef:N,spacerHeightRef:L,spacerRef:G,stateFrameRef:le,stateStore:$.current,viewportRef:Y,visibilityFrameRef:R,visibilityObserverRef:S,visibilityStore:C.current,visibleMessageIdsRef:O,handledScrollAnchorsRef:A}}function ft(e,t){return a.useCallback(n=>{e.current=n,n&&t()},[e,t])}function $r({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=pr,scrollPreviousItemPeek:r=mr,scrollMargin:o=hr}){let l=Lr({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:m,defaultScrollPositionAppliedRef:y,firstItemRef:h,itemCountRef:g,lastScrollTopRef:w,messageElementsRef:E,modeRef:v,pendingScrollFrameRef:T,pendingScrollToMessageRef:H,prependRestoreRef:U,preserveScrollOnPrependRef:K,rootRef:z,scrollEdgeThresholdRef:N,scrollMarginRef:L,scrollPreviousItemPeekRef:G,spacerGapRef:le,spacerHeightRef:$,spacerRef:q,stateFrameRef:Y,stateStore:R,viewportRef:S,visibilityFrameRef:C,visibilityObserverRef:O,visibilityStore:A,visibleMessageIdsRef:Z,handledScrollAnchorsRef:te}=l,re=a.useRef(t);re.current!==t&&(re.current=t,y.current=!1);let se=a.useCallback(f=>{let p=z.current,b=S.current,k=[f.start&&"start",f.end&&"end"].filter(Boolean).join(" "),ee=u.current;for(let D of[p,b])D&&(k?D.setAttribute("data-scrollable",k):D.removeAttribute("data-scrollable"),D.toggleAttribute("data-autoscrolling",ee))},[]),ye=a.useCallback(f=>{let p=S.current?.scrollTop??0,b=p<w.current-Le;w.current=p,c.current&&!f.end&&v.current!=="settling-jump"&&v.current!=="anchored-to-message"?v.current="following-bottom":v.current==="following-bottom"&&f.end&&b&&!u.current&&(v.current="free-scrolling")},[]),Q=a.useCallback(()=>{let f=vr({content:m.current,scrollEdgeThreshold:N.current,spacer:q.current,viewport:S.current});ye(f);let p=v.current==="following-bottom"?{...f,end:!1}:f;se(p),R.setSnapshot(p)},[ye,R,se]),ae=a.useCallback(()=>{Y.current===null&&(Y.current=window.requestAnimationFrame(()=>{Y.current=null,Q()}))},[Q]),F=a.useCallback(()=>{A.hasListeners()&&C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,A.hasListeners()&&A.setSnapshot(yr({content:m.current,scrollMargin:L.current,scrollPreviousItemPeek:G.current,spacer:q.current,viewport:S.current,visibleMessageIds:Z.current}))}))},[A]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:M,scrollToElement:V,scrollToEnd:j,scrollToMessage:J,scrollToStart:W}=kr({refs:l,commitScrollState:Q,scheduleStateCommit:ae,scheduleVisibilitySync:F}),B=a.useCallback(()=>{let f=U.current,p=S.current;if(!f||!p||!f.element.isConnected)return!1;let b=Pe(f.element,p)-f.viewportTop;return Math.abs(b)<=Le?!1:(p.scrollTop+=b,f.viewportTop=Pe(f.element,p),ae(),F(),!0)},[ae,F]),X=a.useCallback(()=>{let f=m.current,p=S.current;if(!f||!p){U.current=null;return}let b=Cr({content:f,spacer:q.current,viewport:p});U.current=b?{element:b,viewportTop:Pe(b,p)}:null},[]),pe=a.useCallback(()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,I()&&X()}))},[X,I]),ie=a.useCallback(()=>{if(!t||y.current||g.current===0)return!1;let f=!1;if(t==="last-anchor"){let p=m.current,b=S.current,k=p&&b?Tr(je(p,q.current)):null;if(!p||!b||!k)f=j({behavior:"auto"});else{let ee=_t(k,b);f=Ze({content:p,spacer:q.current,viewport:b})-ee<=b.clientHeight?j({behavior:"auto"}):V(k,{align:"start"},{keepPreviousPeek:!0})}}else f=t==="end"?j({behavior:"auto"}):W({behavior:"auto"});return f?(y.current=!0,!0):!1},[t,V,j,W]),Re=a.useCallback(()=>{let f=m.current;if(!f)return;let p=je(f,q.current),b=g.current,k=h.current;g.current=p.length,h.current=p[0]??null,(()=>{if(I())return;if(b===0){if(ie()||p.length>0&&c.current&&j({behavior:"auto"}))return;Q(),F();return}let ee=k?p.indexOf(k):-1;if(K.current&&ee>0){B();return}if(p.length>b){let D=Rr(p,b);if(D){if(c.current&&v.current==="following-bottom"&&Sr(p,b)){j({behavior:"auto"});return}V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}if(p.length===b){let D=wr(p,te.current);if(D){V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}v.current==="following-bottom"&&c.current?j({behavior:"auto"}):(Q(),F())})(),X()},[ie,X,Q,I,B,F,V,j]),we=a.useCallback(()=>{if(v.current==="following-bottom"&&c.current){j({behavior:"auto"});return}let f=$.current;if(M()){c.current&&f>0&&$.current===0&&j({behavior:"auto"});return}ae(),F()},[M,ae,F,j]),Se=a.useCallback(()=>{let f=S.current;if(!(!f||!A.hasListeners())){if(typeof IntersectionObserver>"u"){F();return}O.current||(O.current=new IntersectionObserver(p=>{for(let b of p){let k=b.target.dataset.messageId;k&&(b.isIntersecting?Z.current.add(k):Z.current.delete(k))}F()},{root:f,rootMargin:`${-(L.current+G.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),E.current.forEach(p=>{O.current?.observe(p)}),F()}},[F,A]),me=a.useCallback(()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),O.current?.disconnect(),O.current=null,Z.current.clear(),A.setSnapshot($e)},[A]),Te=a.useCallback((f,p,b)=>{if(p){E.current.set(f,p),O.current?.observe(p),F(),H.current?.messageId===f&&pe();return}b&&E.current.get(f)===b&&(E.current.delete(f),Z.current.delete(f),O.current?.unobserve(b),F())},[pe,F]),Ie=a.useCallback(()=>{(v.current==="following-bottom"||v.current==="anchored-to-message"||v.current==="settling-jump")&&(i.current=null,v.current="free-scrolling")},[]),ce=a.useCallback(()=>se(R.getSnapshot()),[R,se]),he=ft(z,ce),ue=ft(S,ce),ke=a.useCallback(f=>{m.current=f},[]),Ce=a.useCallback(f=>{q.current=f,le.current=Ir(f?.parentElement??null)},[]),_e=a.useCallback(()=>{Q(),F(),X()},[X,Q,F]),Oe=a.useMemo(()=>({handleContentChange:Re,handleResize:we,observeVisibility:Se,preserveScrollOnPrependRef:K,scrollToEnd:j,scrollToMessage:J,scrollToStart:W,setContentElement:ke,setRootElement:he,setSpacerElement:Ce,setViewportElement:ue,stateStore:R,syncAfterScroll:_e,unobserveVisibility:me,userScrollIntent:Ie,viewportRef:S,visibilityStore:A}),[Re,we,Se,j,J,W,ke,he,Ce,ue,R,_e,me,Ie,A]);return a.useLayoutEffect(()=>{ie()},[ie]),a.useEffect(()=>()=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),O.current?.disconnect(),O.current=null},[]),a.useLayoutEffect(()=>{if(e&&v.current==="following-bottom"&&g.current>0){j({behavior:"auto"});return}Q()},[e,Q,j]),{context:Oe,registerMessage:Te}}function Dr(e){let t=a.useRef(e);return t.current=e,t}var Mt=a.createContext(null),Lt=a.createContext(null);function xe(){let e=a.useContext(Mt);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Ur(){let e=a.useContext(Lt);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function $t(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=xe();return a.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Dt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=xe(),r=a.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return a.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Fr({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:i,registerMessage:c}=$r({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(Mt.Provider,{value:i,children:s.jsx(Lt.Provider,{value:c,children:t})})}function Vr({children:e,...t}){let{setRootElement:n}=xe();return s.jsx("div",{ref:n,...t,children:e})}function Br({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...m}){let{handleResize:y,preserveScrollOnPrependRef:h,setViewportElement:g,syncAfterScroll:w,userScrollIntent:E,viewportRef:v}=xe();h.current=i;let T=a.useCallback(N=>{g(N),Ae(c)?.(N)},[c,g]);function H(N){w(),r?.(N)}function U(N){E(),l?.(N)}function K(N){E(),o?.(N)}function z(N){br.has(N.key)&&E(),n?.(N)}return a.useEffect(()=>{let N=v.current;if(!N||typeof ResizeObserver>"u")return;let L=0,G=new ResizeObserver(()=>{window.cancelAnimationFrame(L),L=window.requestAnimationFrame(y)});return G.observe(N),()=>{window.cancelAnimationFrame(L),G.disconnect()}},[y,v]),s.jsx("div",{ref:T,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:z,onScroll:H,onTouchMove:K,onWheel:U,...m,children:t})}function Hr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...l}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=xe(),m=a.useRef(null),y=a.useCallback(h=>{m.current=h,u(h),Ae(n)?.(h)},[n,u]);return a.useLayoutEffect(()=>{let h=m.current;if(!h||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(h,{childList:!0}),()=>g.disconnect()},[i]),a.useEffect(()=>{let h=m.current;if(!h||typeof ResizeObserver>"u")return;let g=0,w=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return w.observe(h),()=>{window.cancelAnimationFrame(g),w.disconnect()}},[c]),s.jsxs("div",{ref:y,role:r??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function zr({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=Ur(),l=a.useRef(null),i=a.useCallback(c=>{let u=l.current;l.current=c,e&&o(e,c,u),Ae(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Wr({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:l,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:m}=xe(),y=Dr(r),h=a.useCallback(v=>m.subscribe(v),[m]),g=a.useCallback(()=>{let v=m.getSnapshot();return n==="start"?v.start:v.end},[n,m]),w=a.useSyncExternalStore(h,g,g),E=a.useCallback(v=>{w&&(y.current?.(v),v.defaultPrevented||(v.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,w,y,u,d]);return cr({defaultTagName:"button",props:ze({type:i,inert:!w,tabIndex:w?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:E},c),render:o,state:{active:w,direction:n},stateAttributesMapping:{active:v=>({"data-active":v?"true":"false"})}})}var ve={Provider:Fr,Root:Vr,Viewport:Br,Content:Hr,Item:zr,Button:Wr};const Kr=ve.Provider;function qr({className:e,...t}){return s.jsx(ve.Root,{className:P("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Gr({className:e,...t}){return s.jsx(ve.Viewport,{className:P("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function Yr({className:e,...t}){return s.jsx(ve.Content,{className:P("flex h-max min-h-full flex-col",e),...t})}function Qr({className:e,...t}){return s.jsx(ve.Item,{className:P("min-w-0 shrink-0",e),...t})}function Jr({className:e,...t}){return s.jsx(ve.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(fe,{...r,type:"button",variant:"outline",size:"icon",className:P("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(nn,{})}):null,...t})}function Xr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function Zr(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const eo="lobu-spa";function pt(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function De(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const Vo=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:l,agentId:i,conversationId:c}=Ee(),{data:u=[]}=rn(i,{conversationId:c});return s.jsx($n,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(to,{messages:l,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:Sn,children:s.jsx(Io,{})})]})})},to=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(Kr,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(ro,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function no(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const ro=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:l}=Dt(),{scrollToMessage:i}=$t(),c=a.useRef(null);a.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Zr({messageIds:e.map(m=>m.id),scrollTarget:Xr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(qr,{children:[s.jsx(Gr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(Yr,{className:P(Ge,Tn),children:[e.map(d=>{const m=n==="runs"&&o?no(d.id):null;return s.jsx(Qr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===l?"location":void 0,className:P("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===l&&"border-primary"),children:m!=null?s.jsx(xo,{message:d,onClick:()=>o?.(m)}):s.jsx(ao,{message:d})},d.id)}),t.map(d=>s.jsx(so,{trip:d},d.id)),s.jsx(lo,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(oo,{messages:e,mode:n}):null,s.jsx(Jr,{})]})},oo=({messages:e,mode:t})=>{const{scrollToMessage:n}=$t(),{currentAnchorId:r,visibleMessageIds:o}=Dt(),l=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(m=>m.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(cn,{children:[s.jsx(un,{asChild:!0,children:s.jsxs(fe,{type:"button",variant:"outline",size:"icon",className:P("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",l>0&&"w-auto px-3"),"aria-label":l>0?`Open transcript outline, ${l} ${l===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(dn,{}),l>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[l," waiting"]}):null]})}),s.jsxs(fn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(fe,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:P("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},so=({trip:e})=>s.jsxs("div",{className:P(Ge,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(an,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),lo=()=>{const{currentSuggestions:e,starters:t,messages:n,running:r,append:o}=Ee(),l=Kn(e,t,n.length);return r||l.length===0?null:s.jsx(Nn,{prompts:l,className:P(Ge,n.length===0&&"mt-auto"),onPick:i=>o(i)})},ao=({message:e})=>e.role==="user"?s.jsx(io,{message:e}):e.role==="system"?s.jsx(vo,{message:e}):s.jsx(fo,{message:e}),Ut=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return s.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},io=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:xt,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(co,{part:n},De(e,n)))})}):s.jsx("div",{className:Cn,children:s.jsxs("div",{className:P(Ne,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx(Ut,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:n.text,renderText:r=>r})},De(e,n)):null)]})})},co=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:P(Ne,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(pn,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},Ft=new Set(["question","link-button","tool-approval"]),uo="subscription-candidate",fo=({message:e})=>{const t=Ye(),{agentId:n,workspaceSlug:r}=Ee(),o=u=>u.type==="tool-call"&&(Ft.has(u.toolName)||t?.toolNames.has(u.toolName)),l=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==uo),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=Rt(u.result);return d?[d]:[]});return s.jsx("div",{className:xt,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[l.length>0?s.jsx(ho,{tools:l,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(po,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(bo,{part:u},De(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx(Ut,{attachment:u},u.id))}):null]})})},po=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:P(Ne,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(fe,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(gt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(hn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function mo(e){try{return JSON.parse(e)}catch{return null}}function Vt(e){if(Array.isArray(e)){const o=e.flatMap(l=>l?.type==="text"&&typeof l.text=="string"?Vt(l.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?mo(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const l=o&&typeof o=="object"?o.id:null;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?[l]:[]});return r.length>0?r:null}const ho=({tools:e,workspaceSlug:t})=>s.jsxs(Nt,{defaultOpen:!1,children:[s.jsx(Et,{children:e.length===1?ot(e[0].args,e[0].toolName)??e[0].toolName:`${e.length} tool calls`}),s.jsx(It,{children:e.map(n=>{const r=ot(n.args,n.toolName),o=n.args!==void 0&&n.args!==null,l=n.result!==void 0&&n.result!==null,i=Vt(n.result);return s.jsxs(At,{icon:mn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:r??n.toolName}),r?s.jsx("span",{className:"text-muted-foreground",children:n.toolName}):null,n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.args)}):null,l?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.result)}):null,i&&t?s.jsx(ir,{ownerSlug:t,eventIds:i}):null]},n.toolCallId)})})]}),go=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const l=JSON.parse(r[0])?.error?.message;typeof l=="string"&&l.trim()&&(t=l,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(bn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},bo=({part:e})=>{const t=Ye();return e.type==="reasoning"?s.jsx(lr,{}):e.type==="error"?s.jsx(go,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Xe,{text:e.text,renderText:n=>s.jsx(gn,{text:n})}):null:e.type!=="tool-call"?null:Ft.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(Ao,{toolName:e.toolName,args:e.args}):null},xo=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:P(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},vo=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:P(Ne,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:t.text,renderText:n=>n})},De(e,t)):null)})}),yo="/mcp-apps/interaction/index.html";function mt(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const Ro=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const l=a.useRef(null),[i,c]=a.useState(48),u=a.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},a.useEffect(()=>{const d=l.current;if(!d?.contentWindow)return;const m=new yn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});m.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),m.oncalltool=async({name:g,arguments:w})=>{const E=await u.current.onToolCall(g,w??{});return{isError:E,content:[{type:"text",text:E?"Action failed.":"Action completed."}]}},m.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),m.addEventListener("initialized",()=>{(async()=>(await m.sendToolInput({arguments:{}}),await m.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:eo}})))()});const y=new Rn(d.contentWindow,d.contentWindow);m.connect(y).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const h=new MutationObserver(()=>{m.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return h.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{h.disconnect(),y.close()}},[]),s.jsx("iframe",{ref:l,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},wo=new Set(["action"]),So=["name","description","identity_md"];function oe(e){return e==null||e===""?"":typeof e=="string"?e:Fe(e)}function ht(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Fe(e)}function Ue(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Bt=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function Ke(e){return e&&Bt.has(e)?"warning":"default"}function qe(e,t){return e&&Bt.has(e)?{level:"high",reason:t}:{level:"normal"}}function To(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(l=>({label:l,before:oe(e.current?.[l]),after:oe(t[l])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function Co(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},l=Object.keys(o).filter(i=>!wo.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:ht(e.current?.[i])}:{},after:ht(o[i])}));return r.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0}),{title:`${Ue(t)} Automation ${n}`,icon:"automation",impact:qe(e.action,"This archives the Automation and stops future runs."),tone:Ke(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function jo(e){if(e.resourceKind==="automation")return Co(e);if(e.fields&&Object.keys(e.fields).length>0)return To(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return Mn({...e,action:e.action});if(t){const l=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&oe(e.proposal?.[d])!==oe(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:oe(e.current?.[d])}:{},after:oe(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(i)} entity ${l}`,icon:"entity",impact:qe(e.action,"This deletes the entity."),tone:Ke(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${l} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${l} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const l=So.filter(i=>e.proposal?.[i]!==void 0&&oe(e.proposal?.[i])!==oe(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:oe(e.current?.[i])}:{},after:oe(e.proposal?.[i])}));o.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(r)} agent ${n}`,icon:"agent",impact:qe(e.action,"This permanently deletes the agent and its configuration."),tone:Ke(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function No(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function Eo(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const Ao=({toolName:e,args:t})=>{const n=xn(),r=vn(),{append:o}=Ee(),l=Ye(),i=t??{},c=l?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},m=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const y=i.runId,h=typeof i.status=="string"?i.status:"pending",g=h==="pending",w=jo(i),E=h==="confirmed"?"Approved":Ue(h);u=g?w:{...w,title:`${w.title??"Approval"} · ${E}`,tone:h==="failed"?"warning":"default",blocks:[...w.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${h==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${E}.`,muted:!0}],actions:(w.actions??[]).filter(v=>v.terminal===!1)},g&&(d.manage_operations=v=>{if(v.action==="approve")return mt(T=>n.mutate({run_id:y},T));if(v.action==="reject"){const T=typeof v.reason=="string"?v.reason:void 0;return mt(H=>r.mutate({run_id:y,...T?{reason:T}:{}},H))}return Promise.resolve(!0)})}else if(e==="question"){const y=Array.isArray(i.options)?i.options.filter(h=>typeof h=="string"):[];u=No(i),d.answer_question=h=>{const g=typeof h.answer=="string"?h.answer:"";return y.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!pt(i.url))return null;const y=i.url;m.add(y),u=Eo(i,y)}}return u?s.jsx(Ro,{src:yo,title:u.title??"Interaction",renderPayload:u,onToolCall:(y,h)=>d[y]?d[y](h):Promise.resolve(!0),onOpenLink:y=>!m.has(y)||!pt(y)?Promise.resolve(!0):(window.open(y,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Fe(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const Io=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:l,initialDraft:i,currentSuggestions:c}=Ee(),u=ko({suggestions:e?null:c}),[d,m]=a.useState(i??""),y=a.useRef(null),h=a.useRef(null),g=_n(On),w=a.useRef(i??"");a.useEffect(()=>{const T=i??"";if(T===w.current)return;const H=w.current;w.current=T,T!==""&&m(U=>U===""||U===H?T:U)},[i]);const E=a.useRef(d);E.current=d;const v=()=>{e||(t(E.current),m(""),h.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(T=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(He,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:T.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>l(T.id),children:s.jsx(on,{className:"h-3 w-3"})})]},T.id))}):null,s.jsx(Pn,{value:d,onChange:m,onSubmit:v,searchRefs:g,handleRef:h,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:T=>{T.target.files&&o(T.target.files),T.target.value=""}}),s.jsxs(fe,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>y.current?.click(),children:[s.jsx(He,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(fe,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(sn,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(fe,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:v,children:[s.jsx(ln,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function ko({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Vo as A,Fo as L,Uo as R,er as h,Qn as s};
|
|
6
|
-
//# sourceMappingURL=agent-thread-
|
|
5
|
+
`).trim()}function qn(e){const t=[];for(const n of e.matchAll(Tt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Gn(e,t={}){if(typeof e=="string"){const r=ct(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const l=ct(o.text);l&&n.push({type:"text",text:l})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!wt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function Qn(e){const t=[],n=r=>{for(const{name:o,url:l}of qn(r))t.push({id:`file-${t.length}`,name:o,url:l,isImage:zn.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const l=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${l};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function Yn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Gn(e.content,t),attachments:Qn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Jn=[],Xn=[];function Zn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function er(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=yt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const tr=3e4,nr=3*tr,rr=15e3;function ut(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const be=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function or(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:l}=r;if(typeof o!="string"||typeof l!="string")continue;const i=o.trim(),c=l.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function Fo({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:l,children:i,initialDraft:c}){const u=zt(),d=a.useRef(null),m=a.useRef(null),y=a.useRef(!1),h=a.useRef(o),g=a.useRef(!1),w=a.useRef(null);h.current=o;const{data:E,isLoading:v}=Wt(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),T=E?.messages??Jn,H=E?.interactions??Xn,{data:U}=Kt(e,{enabled:!!e}),K=U?.starters??St,z=!!(U?.showToolCalls??U?.settings?.showToolCalls),[N,L]=a.useState([]),[G,le]=a.useState(!1),[$,q]=a.useState([]),[Q,R]=a.useState(null),S=a.useRef(!1);S.current=G;const C=a.useMemo(()=>T.map(I=>Yn(I,{showToolCalls:z})).filter(I=>I!==null),[T,z]),O=a.useRef(!1);a.useEffect(()=>{if(O.current||v||S.current)return;O.current=!0;const I=er(H,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});L(I?[...C,I]:C),R(Zn(H))},[e,v,C,H,t]);const A=a.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),Z=a.useCallback(async()=>{if(d.current)return d.current;if(m.current)return m.current;if(!e)throw new Error("No agent selected");const I=(async()=>{const M=await tt(`${Be}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!M.ok)throw await nt(M);const V=await M.json(),j=qt(),J={sessionId:V.agentId,sseUrl:it(V.sseUrl,Be,j),messagesUrl:it(V.messagesUrl,Be,j)};return d.current=J,J})();m.current=I;try{return await I}catch(M){throw d.current=null,M}finally{m.current=null}},[e,t,n]),te=a.useCallback(async(I,M,V)=>{const j=crypto.randomUUID(),J=new AbortController;w.current=J;const W=f=>{L(p=>p.map(b=>b.id===V?{...b,parts:f}:b))};let B;try{B=await Z()}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Could not start a session."}`}]);return}let X=await rt(B.sseUrl,{throwOnFailure:!0});const pe=[];let ie=null;const Re=()=>{const f=ie;ie=null,f?.()},we=f=>{pe.push(f),Re()},Se=(f,p)=>{const k=["question","link-button","tool-approval"].includes(f)?p.turnMessageId===j:p.messageId===j||Array.isArray(p.processedMessageIds)&&p.processedMessageIds.includes(j);(f==="closed"||k)&&we({kind:f,payload:p})};let me=!1,Te=null;const Ie=new Promise(f=>{Te=f});let ce=0,he=Date.now();const ue=f=>{he=Date.now();const p=Number(f.lastEventId);Number.isFinite(p)&&p>ce&&(ce=p)},ke=["output","status","complete","closed","agent-error","question","link-button","tool-approval","tool_use"],Ce=f=>{f.addEventListener("open",()=>{me=!0,Te?.()}),f.addEventListener("connected",b=>{ue(b),me||(me=!0,Te?.())}),f.addEventListener("ping",ue);const p=b=>k=>{ue(k);const ee=k;typeof ee.data=="string"&&Se(b,ut(ee))};for(const b of ke)f.addEventListener(b,p(b));f.addEventListener("error",b=>{const k=b;if(typeof k.data=="string"&&k.data){ue(b),Se("error",ut(k));return}f.readyState===EventSource.CLOSED&&we({kind:"error",payload:{error:"Connection closed"}})})};Ce(X);const _e=async()=>{X.close();let f=B.sseUrl;if(ce){const p=new URL(B.sseUrl,window.location.origin);p.searchParams.set("since",String(ce)),f=p.toString()}X=await rt(f,{throwOnFailure:!1}),Ce(X),he=Date.now()};await Promise.race([Ie,new Promise(f=>setTimeout(f,1500))]);const Oe=()=>{X.close(),Re()};J.signal.addEventListener("abort",Oe,{once:!0});try{const f=h.current?.trim(),p=!!f&&!g.current;p&&(g.current=!0);let b;if(M.length>0){const x=new FormData;x.set("content",I),x.set("messageId",j),p&&f&&x.set("ephemeralContext",f);for(const _ of M)x.append("files",_,_.name);b={method:"POST",credentials:"include",body:x,timeoutMs:12e4}}else{const x={content:I,messageId:j};p&&f&&(x.ephemeralContext=f),b={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(x),timeoutMs:2e4}}const k=await tt(B.messagesUrl,b);if(!k.ok)throw d.current=null,await nt(k);let ee="",D=Me,et=null;const ge=[],de=()=>Wn({textOut:ee,statusLine:D,errorText:et,toolCalls:ge});for(W(de());!J.signal.aborted;){if(pe.length===0){let _;const ne=await Promise.race([new Promise(Ve=>{ie=()=>Ve(!0)}),new Promise(Ve=>{_=setTimeout(()=>Ve(!1),rr)})]);_&&clearTimeout(_),!ne&&Date.now()-he>=nr&&(await _e(),A());continue}const x=pe.shift();if(x){if(x.kind==="output")D=null,ee+=String(x.payload.content??"");else if(x.kind==="status")D=Me;else if(x.kind==="complete"){D=null;const _=x.payload.finalText;typeof _=="string"&&_.length>0&&(ee=_);const ne=x.payload.suggestions;ne!==void 0&&R(Array.isArray(ne)?or(ne):null),A(),W(de());return}else if(x.kind==="closed"){d.current=null;const _=x.payload.reason;D=`Session ended${_?`: ${_}`:""}.`,A(),W(de());return}else if(x.kind==="error"||x.kind==="agent-error"){D=null,et=typeof x.payload.error=="string"&&x.payload.error?x.payload.error:"Agent reported an error.";const _=x.payload.errorContext&&typeof x.payload.errorContext=="object"?x.payload.errorContext:void 0,ne=yt(x.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof _?.provider=="string"?_.provider:void 0,model:typeof _?.model=="string"?_.model:void 0});ne&&ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:ne.label,url:ne.href}}),A(),W(de());return}else if(x.kind==="question")ge.push({type:"tool-call",toolCallId:be("q"),toolName:"question",args:{question:x.payload.question??"",options:x.payload.options??[]}});else if(x.kind==="tool_use"){if(D=null,wt.has(x.payload.name??"")){W(de());continue}const _=x.payload.result_summary,ne=Rt(_);if(!z&&!ne){W(de());continue}ge.push({type:"tool-call",toolCallId:x.payload.toolCallId??be("t"),toolName:z?x.payload.name??"tool":"subscription-candidate",args:z?x.payload.input??{}:null,result:_,isError:x.payload.isError})}else if(x.kind==="link-button")ge.push({type:"tool-call",toolCallId:be("l"),toolName:"link-button",args:{label:x.payload.label??"Open link",url:x.payload.url??""}});else if(x.kind==="tool-approval"){const _=x.payload.runId;if(typeof _!="number")continue;ge.push({type:"tool-call",toolCallId:`run-${_}`,toolName:"tool-approval",args:{runId:_,action:x.payload.action??null,proposal:x.payload.proposal??null,current:x.payload.current??null,fields:x.payload.fields??null,attribution:x.payload.attribution??null,resourceKind:x.payload.resourceKind??null}})}W(de())}}}catch(f){W([{type:"text",text:`Error: ${f instanceof Error?f.message:"Send failed."}`}])}finally{J.signal.removeEventListener("abort",Oe),X.close()}},[e,Z,A,z,t]),re=a.useCallback(I=>{const M=I.trim(),V=$.map(B=>B.file);if(!M&&V.length===0||S.current||!e)return;y.current||(y.current=!0,l?.(M||V[0]?.name||""));const j={id:be("u"),role:"user",parts:M?[{type:"text",text:M}]:[],attachments:$.map(B=>({id:B.id,name:B.name,isImage:B.isImage,imageDataUrl:B.isImage?URL.createObjectURL(B.file):void 0})),createdAt:Date.now()},J=be("asst"),W={id:J,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};L(B=>[...B,j,W]),q([]),le(!0),S.current=!0,te(M,V,J).finally(()=>{le(!1),S.current=!1,w.current=null})},[e,l,$,te]),se=a.useCallback(()=>{w.current?.abort()},[]),ye=a.useCallback(I=>{const M=Array.from(I);q(V=>[...V,...M.map(j=>({id:crypto.randomUUID(),name:j.name,file:j,isImage:j.type.startsWith("image/")}))])},[]),Y=a.useCallback(I=>{q(M=>M.filter(V=>V.id!==I))},[]),ae=a.useRef(!1);a.useEffect(()=>{if(ae.current)return;const I=jn(n);I&&(ae.current=!0,re(I))},[n,re]);const F=a.useMemo(()=>({messages:N,running:G,append:re,cancel:se,pendingAttachments:$,addAttachments:ye,removeAttachment:Y,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:Q,starters:K}),[N,G,re,se,$,ye,Y,c,e,n,t,Q,K]);return r&&v?s.jsx(wn,{}):s.jsx(Je.Provider,{value:F,children:i})}const dt="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function sr({refItem:e}){const t=In[e.kind]??Gt;return kn(e.path)?s.jsxs("span",{className:dt,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(gt,{to:e.path,className:P(dt,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Xe=({text:e,renderText:t})=>En(e)?s.jsx(s.Fragment,{children:An(e).map((n,r)=>n.type==="ref"?s.jsx(sr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),lr=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),Ct=a.createContext(null),jt=()=>{const e=a.useContext(Ct);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Nt=a.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...l})=>{const[i,c]=Qt({prop:t,defaultProp:n,onChange:r}),u=a.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(Ct.Provider,{value:u,children:s.jsx("div",{className:P("not-prose max-w-prose space-y-4",e),...l,children:o})})}),Et=a.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=jt();return s.jsx(bt,{onOpenChange:o,open:r,children:s.jsxs(Yt,{className:P("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Jt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Xt,{className:P("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),At=a.memo(({className:e,icon:t=en,label:n,description:r,status:o="complete",children:l,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:P("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),l]})]})}),It=a.memo(({className:e,children:t,...n})=>{const{isOpen:r}=jt();return s.jsx(bt,{open:r,children:s.jsx(Zt,{className:P("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});Nt.displayName="ChainOfThought";Et.displayName="ChainOfThoughtHeader";At.displayName="ChainOfThoughtStep";It.displayName="ChainOfThoughtContent";function ar(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function ir({ownerSlug:e,eventIds:t}){const n=t.join(","),r=a.useMemo(()=>ar(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(tn,{owner:e,children:({organizationId:o,ownerSlug:l})=>o?s.jsx(Ln,{organizationId:o,ownerSlug:l,filters:r,hideOriginator:!0}):null})}function cr({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let l=ze(ur(r,o),t);if(!n)return a.createElement(e,l);if(typeof n=="function")return n(l,r);if(!a.isValidElement(n))return null;let i=n.props,c={...ze(l,i),ref:Ae(l.ref,i.ref)};return a.cloneElement(n,c)}function ze(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let l=r[o];if(l===void 0)continue;let i=t[o];o==="className"?t[o]=[i,l].filter(Boolean).join(" "):o==="style"?t[o]={...i,...l}:o==="ref"?t[o]=Ae(i,l):fr(o)&&typeof i=="function"&&typeof l=="function"?t[o]=dr(l,i):t[o]=l}}return t}function ur(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],l=t?.[r]?.(o);if(l){Object.assign(n,l);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function dr(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function fr(e){return/^on[A-Z]/.test(e)}function Ae(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var pr=8,mr=64,hr=0,Le=.5,gr=180,br=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),kt={start:!1,end:!1},xr=[],$e={currentAnchorId:null,visibleMessageIds:xr};function vr({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return kt;let o=Ze({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function yr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:l}){if(!e||!o)return $e;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],m=null;for(let y of je(e,r)){let h=y.dataset.messageId;if(!h)continue;let g=y.dataset.scrollAnchor==="true",w=g||u?y.getBoundingClientRect():null;(u&&w?w.bottom>c&&w.top<i.bottom:l.has(h))&&d.push(h),g&&w&&w.top<=c+Le&&(m=h)}return d.length===0&&m===null?$e:{currentAnchorId:m,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function Rr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function wr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function Sr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function Tr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function Cr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>r.top&&l.top<r.bottom)return o}return null}function jr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let l=_t(t,o),i=t.getBoundingClientRect().height,c=Ar(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return l-c.start-(u-i)/2-n}if(e==="end")return l-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=l+i,d=o.scrollTop+c.start,m=o.scrollTop+o.clientHeight-c.end;return l>=d&&u<=m?o.scrollTop:l<d?l-c.start-n:u-o.clientHeight+c.end+n}return l-c.start-n}function _t(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Pe(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Nr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Ze({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Ze({content:e,spacer:t,viewport:n}){let r=je(e,t),o=Ot(e),l=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-l.top+i+o.end)}return c}function Er(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Ot(e){let t=window.getComputedStyle(e);return{end:We(t.paddingBlockEnd||t.paddingBottom),start:We(t.paddingBlockStart||t.paddingTop)}}function Ar(e){let t=e?.parentElement;return t?Ot(t):{end:0,start:0}}function Ir(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return We(n)}function We(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function kr({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:m,messageElementsRef:y,modeRef:h,pendingScrollToMessageRef:g,prependRestoreRef:w,scrollMarginRef:E,scrollPreviousItemPeekRef:v,spacerGapRef:T,spacerHeightRef:H,spacerRef:U,viewportRef:K}=e,z=a.useCallback(R=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==R&&(i.current=R,t()),R&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},gr))},[t]),N=a.useCallback(R=>{let S=U.current;if(!S)return;let C=Math.max(0,Math.ceil(R));H.current!==C&&(H.current=C,S.hidden=C===0,S.style.height=`${C}px`,S.style.marginTop=C>0?`${-T.current}px`:"")},[]),L=a.useCallback((R,{behavior:S="auto",autoscrolling:C=!1}={})=>{let O=K.current;if(!O)return;let A=Math.max(0,R);if(Math.abs(O.scrollTop-A)<=Le){O.scrollTop=A,t();return}C&&z(!0),O.scrollTo({top:A,behavior:S}),n()},[t,n,z]),G=a.useCallback(({behavior:R="auto"}={})=>K.current?(N(0),o.current=null,h.current="free-scrolling",L(0,{behavior:R}),r(),!0):!1,[r,L,N]),le=a.useCallback(({behavior:R="auto"}={})=>{let S=K.current;return S?(N(0),o.current=null,h.current=l.current?"following-bottom":"free-scrolling",L(Er(S),{autoscrolling:!0,behavior:R}),r(),!0):!1},[r,L,N]),$=a.useCallback((R,{align:S="start",behavior:C="auto",scrollMargin:O=E.current}={},{keepPreviousPeek:A=!1}={})=>{let Z=u.current,te=K.current;if(!Z||!te||!Z.contains(R))return!1;let re=jr({align:S,element:R,scrollMargin:A?O+v.current:O,spacer:U.current,viewport:te}),se=Nr({content:Z,scrollTop:re,spacer:U.current,viewport:te});return N(se),w.current={element:R,viewportTop:Pe(R,te)},h.current=A?"anchored-to-message":"settling-jump",o.current=A?R:null,L(re,{behavior:C}),r(),!0},[r,L,N]),q=a.useCallback(()=>{let R=o.current;return!R||!R.isConnected||h.current!=="anchored-to-message"?!1:$(R,{align:"start"},{keepPreviousPeek:!0})},[$]),Q=a.useCallback((R,S)=>{let C=y.current.get(R);return C?(d.current=!0,$(C,S)?(g.current=null,!0):(g.current={messageId:R,options:S},!0)):m.current===0?(g.current={messageId:R,options:S},d.current=!0,!0):!1},[$]);return{flushPendingScrollToMessage:a.useCallback(()=>{let R=g.current;if(!R)return!1;let S=y.current.get(R.messageId);return!S||!$(S,R.options)?!1:(g.current=null,d.current=!0,!0)},[$]),reanchorToAnchoredMessage:q,scrollToElement:$,scrollToEnd:le,scrollToMessage:Q,scrollToStart:G}}function Pt(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(l=>l()))},subscribe:(o,l,i)=>{let c=r.size===0;return r.add(o),c&&l?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function _r(e,t){return Pt(e,t)}function Or(){return Pt($e,Mr)}function Pr(e,t){return e.start===t.start&&e.end===t.end}function Mr(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Lr({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=a.useRef(e),l=a.useRef(!1),i=a.useRef(null),c=a.useRef(!1),u=a.useRef(t),d=a.useRef(0),m=a.useRef(null),y=a.useRef(0),h=a.useRef(e?"following-bottom":"free-scrolling"),g=a.useRef(new Map),w=a.useRef(null),E=a.useRef(null),v=a.useRef(null),T=a.useRef(r),H=a.useRef(!0),U=a.useRef(null),K=a.useRef(n),z=a.useRef(null),N=a.useRef(0),L=a.useRef(0),G=a.useRef(null),le=a.useRef(null),$=a.useRef(null),q=a.useRef(null),Q=a.useRef(null),R=a.useRef(null),S=a.useRef(null),C=a.useRef(null),O=a.useRef(new Set),A=a.useRef(new WeakSet);return $.current===null&&($.current=_r(kt,Pr)),C.current===null&&(C.current=Or()),o.current=e,u.current=t,K.current=n,T.current=r,{autoScrollRef:o,autoscrollingRef:l,autoscrollingTimeoutRef:q,streamingTurnRef:v,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:m,itemCountRef:d,lastScrollTopRef:y,messageElementsRef:g,modeRef:h,pendingScrollFrameRef:z,pendingScrollToMessageRef:w,prependRestoreRef:E,preserveScrollOnPrependRef:H,rootRef:U,scrollEdgeThresholdRef:u,scrollMarginRef:K,scrollPreviousItemPeekRef:T,spacerGapRef:N,spacerHeightRef:L,spacerRef:G,stateFrameRef:le,stateStore:$.current,viewportRef:Q,visibilityFrameRef:R,visibilityObserverRef:S,visibilityStore:C.current,visibleMessageIdsRef:O,handledScrollAnchorsRef:A}}function ft(e,t){return a.useCallback(n=>{e.current=n,n&&t()},[e,t])}function $r({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=pr,scrollPreviousItemPeek:r=mr,scrollMargin:o=hr}){let l=Lr({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:m,defaultScrollPositionAppliedRef:y,firstItemRef:h,itemCountRef:g,lastScrollTopRef:w,messageElementsRef:E,modeRef:v,pendingScrollFrameRef:T,pendingScrollToMessageRef:H,prependRestoreRef:U,preserveScrollOnPrependRef:K,rootRef:z,scrollEdgeThresholdRef:N,scrollMarginRef:L,scrollPreviousItemPeekRef:G,spacerGapRef:le,spacerHeightRef:$,spacerRef:q,stateFrameRef:Q,stateStore:R,viewportRef:S,visibilityFrameRef:C,visibilityObserverRef:O,visibilityStore:A,visibleMessageIdsRef:Z,handledScrollAnchorsRef:te}=l,re=a.useRef(t);re.current!==t&&(re.current=t,y.current=!1);let se=a.useCallback(f=>{let p=z.current,b=S.current,k=[f.start&&"start",f.end&&"end"].filter(Boolean).join(" "),ee=u.current;for(let D of[p,b])D&&(k?D.setAttribute("data-scrollable",k):D.removeAttribute("data-scrollable"),D.toggleAttribute("data-autoscrolling",ee))},[]),ye=a.useCallback(f=>{let p=S.current?.scrollTop??0,b=p<w.current-Le;w.current=p,c.current&&!f.end&&v.current!=="settling-jump"&&v.current!=="anchored-to-message"?v.current="following-bottom":v.current==="following-bottom"&&f.end&&b&&!u.current&&(v.current="free-scrolling")},[]),Y=a.useCallback(()=>{let f=vr({content:m.current,scrollEdgeThreshold:N.current,spacer:q.current,viewport:S.current});ye(f);let p=v.current==="following-bottom"?{...f,end:!1}:f;se(p),R.setSnapshot(p)},[ye,R,se]),ae=a.useCallback(()=>{Q.current===null&&(Q.current=window.requestAnimationFrame(()=>{Q.current=null,Y()}))},[Y]),F=a.useCallback(()=>{A.hasListeners()&&C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,A.hasListeners()&&A.setSnapshot(yr({content:m.current,scrollMargin:L.current,scrollPreviousItemPeek:G.current,spacer:q.current,viewport:S.current,visibleMessageIds:Z.current}))}))},[A]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:M,scrollToElement:V,scrollToEnd:j,scrollToMessage:J,scrollToStart:W}=kr({refs:l,commitScrollState:Y,scheduleStateCommit:ae,scheduleVisibilitySync:F}),B=a.useCallback(()=>{let f=U.current,p=S.current;if(!f||!p||!f.element.isConnected)return!1;let b=Pe(f.element,p)-f.viewportTop;return Math.abs(b)<=Le?!1:(p.scrollTop+=b,f.viewportTop=Pe(f.element,p),ae(),F(),!0)},[ae,F]),X=a.useCallback(()=>{let f=m.current,p=S.current;if(!f||!p){U.current=null;return}let b=Cr({content:f,spacer:q.current,viewport:p});U.current=b?{element:b,viewportTop:Pe(b,p)}:null},[]),pe=a.useCallback(()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,I()&&X()}))},[X,I]),ie=a.useCallback(()=>{if(!t||y.current||g.current===0)return!1;let f=!1;if(t==="last-anchor"){let p=m.current,b=S.current,k=p&&b?Tr(je(p,q.current)):null;if(!p||!b||!k)f=j({behavior:"auto"});else{let ee=_t(k,b);f=Ze({content:p,spacer:q.current,viewport:b})-ee<=b.clientHeight?j({behavior:"auto"}):V(k,{align:"start"},{keepPreviousPeek:!0})}}else f=t==="end"?j({behavior:"auto"}):W({behavior:"auto"});return f?(y.current=!0,!0):!1},[t,V,j,W]),Re=a.useCallback(()=>{let f=m.current;if(!f)return;let p=je(f,q.current),b=g.current,k=h.current;g.current=p.length,h.current=p[0]??null,(()=>{if(I())return;if(b===0){if(ie()||p.length>0&&c.current&&j({behavior:"auto"}))return;Y(),F();return}let ee=k?p.indexOf(k):-1;if(K.current&&ee>0){B();return}if(p.length>b){let D=Rr(p,b);if(D){if(c.current&&v.current==="following-bottom"&&Sr(p,b)){j({behavior:"auto"});return}V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}if(p.length===b){let D=wr(p,te.current);if(D){V(D,{align:"start"},{keepPreviousPeek:!0}),te.current.add(D);return}}v.current==="following-bottom"&&c.current?j({behavior:"auto"}):(Y(),F())})(),X()},[ie,X,Y,I,B,F,V,j]),we=a.useCallback(()=>{if(v.current==="following-bottom"&&c.current){j({behavior:"auto"});return}let f=$.current;if(M()){c.current&&f>0&&$.current===0&&j({behavior:"auto"});return}ae(),F()},[M,ae,F,j]),Se=a.useCallback(()=>{let f=S.current;if(!(!f||!A.hasListeners())){if(typeof IntersectionObserver>"u"){F();return}O.current||(O.current=new IntersectionObserver(p=>{for(let b of p){let k=b.target.dataset.messageId;k&&(b.isIntersecting?Z.current.add(k):Z.current.delete(k))}F()},{root:f,rootMargin:`${-(L.current+G.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),E.current.forEach(p=>{O.current?.observe(p)}),F()}},[F,A]),me=a.useCallback(()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),O.current?.disconnect(),O.current=null,Z.current.clear(),A.setSnapshot($e)},[A]),Te=a.useCallback((f,p,b)=>{if(p){E.current.set(f,p),O.current?.observe(p),F(),H.current?.messageId===f&&pe();return}b&&E.current.get(f)===b&&(E.current.delete(f),Z.current.delete(f),O.current?.unobserve(b),F())},[pe,F]),Ie=a.useCallback(()=>{(v.current==="following-bottom"||v.current==="anchored-to-message"||v.current==="settling-jump")&&(i.current=null,v.current="free-scrolling")},[]),ce=a.useCallback(()=>se(R.getSnapshot()),[R,se]),he=ft(z,ce),ue=ft(S,ce),ke=a.useCallback(f=>{m.current=f},[]),Ce=a.useCallback(f=>{q.current=f,le.current=Ir(f?.parentElement??null)},[]),_e=a.useCallback(()=>{Y(),F(),X()},[X,Y,F]),Oe=a.useMemo(()=>({handleContentChange:Re,handleResize:we,observeVisibility:Se,preserveScrollOnPrependRef:K,scrollToEnd:j,scrollToMessage:J,scrollToStart:W,setContentElement:ke,setRootElement:he,setSpacerElement:Ce,setViewportElement:ue,stateStore:R,syncAfterScroll:_e,unobserveVisibility:me,userScrollIntent:Ie,viewportRef:S,visibilityStore:A}),[Re,we,Se,j,J,W,ke,he,Ce,ue,R,_e,me,Ie,A]);return a.useLayoutEffect(()=>{ie()},[ie]),a.useEffect(()=>()=>{Q.current!==null&&(window.cancelAnimationFrame(Q.current),Q.current=null),C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),O.current?.disconnect(),O.current=null},[]),a.useLayoutEffect(()=>{if(e&&v.current==="following-bottom"&&g.current>0){j({behavior:"auto"});return}Y()},[e,Y,j]),{context:Oe,registerMessage:Te}}function Dr(e){let t=a.useRef(e);return t.current=e,t}var Mt=a.createContext(null),Lt=a.createContext(null);function xe(){let e=a.useContext(Mt);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Ur(){let e=a.useContext(Lt);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function $t(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=xe();return a.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Dt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=xe(),r=a.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return a.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Fr({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:i,registerMessage:c}=$r({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(Mt.Provider,{value:i,children:s.jsx(Lt.Provider,{value:c,children:t})})}function Vr({children:e,...t}){let{setRootElement:n}=xe();return s.jsx("div",{ref:n,...t,children:e})}function Br({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...m}){let{handleResize:y,preserveScrollOnPrependRef:h,setViewportElement:g,syncAfterScroll:w,userScrollIntent:E,viewportRef:v}=xe();h.current=i;let T=a.useCallback(N=>{g(N),Ae(c)?.(N)},[c,g]);function H(N){w(),r?.(N)}function U(N){E(),l?.(N)}function K(N){E(),o?.(N)}function z(N){br.has(N.key)&&E(),n?.(N)}return a.useEffect(()=>{let N=v.current;if(!N||typeof ResizeObserver>"u")return;let L=0,G=new ResizeObserver(()=>{window.cancelAnimationFrame(L),L=window.requestAnimationFrame(y)});return G.observe(N),()=>{window.cancelAnimationFrame(L),G.disconnect()}},[y,v]),s.jsx("div",{ref:T,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:z,onScroll:H,onTouchMove:K,onWheel:U,...m,children:t})}function Hr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...l}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=xe(),m=a.useRef(null),y=a.useCallback(h=>{m.current=h,u(h),Ae(n)?.(h)},[n,u]);return a.useLayoutEffect(()=>{let h=m.current;if(!h||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(h,{childList:!0}),()=>g.disconnect()},[i]),a.useEffect(()=>{let h=m.current;if(!h||typeof ResizeObserver>"u")return;let g=0,w=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return w.observe(h),()=>{window.cancelAnimationFrame(g),w.disconnect()}},[c]),s.jsxs("div",{ref:y,role:r??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function zr({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=Ur(),l=a.useRef(null),i=a.useCallback(c=>{let u=l.current;l.current=c,e&&o(e,c,u),Ae(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Wr({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:l,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:m}=xe(),y=Dr(r),h=a.useCallback(v=>m.subscribe(v),[m]),g=a.useCallback(()=>{let v=m.getSnapshot();return n==="start"?v.start:v.end},[n,m]),w=a.useSyncExternalStore(h,g,g),E=a.useCallback(v=>{w&&(y.current?.(v),v.defaultPrevented||(v.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,w,y,u,d]);return cr({defaultTagName:"button",props:ze({type:i,inert:!w,tabIndex:w?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:E},c),render:o,state:{active:w,direction:n},stateAttributesMapping:{active:v=>({"data-active":v?"true":"false"})}})}var ve={Provider:Fr,Root:Vr,Viewport:Br,Content:Hr,Item:zr,Button:Wr};const Kr=ve.Provider;function qr({className:e,...t}){return s.jsx(ve.Root,{className:P("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Gr({className:e,...t}){return s.jsx(ve.Viewport,{className:P("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function Qr({className:e,...t}){return s.jsx(ve.Content,{className:P("flex h-max min-h-full flex-col",e),...t})}function Yr({className:e,...t}){return s.jsx(ve.Item,{className:P("min-w-0 shrink-0",e),...t})}function Jr({className:e,...t}){return s.jsx(ve.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(fe,{...r,type:"button",variant:"outline",size:"icon",className:P("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(nn,{})}):null,...t})}function Xr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function Zr(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const eo="lobu-spa";function pt(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function De(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const Vo=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:l,agentId:i,conversationId:c}=Ee(),{data:u=[]}=rn(i,{conversationId:c});return s.jsx($n,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(to,{messages:l,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:Sn,children:s.jsx(Io,{})})]})})},to=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(Kr,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(ro,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function no(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const ro=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:l}=Dt(),{scrollToMessage:i}=$t(),c=a.useRef(null);a.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Zr({messageIds:e.map(m=>m.id),scrollTarget:Xr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(qr,{children:[s.jsx(Gr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(Qr,{className:P(Ge,Tn),children:[e.map(d=>{const m=n==="runs"&&o?no(d.id):null;return s.jsx(Yr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===l?"location":void 0,className:P("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===l&&"border-primary"),children:m!=null?s.jsx(xo,{message:d,onClick:()=>o?.(m)}):s.jsx(ao,{message:d})},d.id)}),t.map(d=>s.jsx(so,{trip:d},d.id)),s.jsx(lo,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(oo,{messages:e,mode:n}):null,s.jsx(Jr,{})]})},oo=({messages:e,mode:t})=>{const{scrollToMessage:n}=$t(),{currentAnchorId:r,visibleMessageIds:o}=Dt(),l=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(m=>m.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(cn,{children:[s.jsx(un,{asChild:!0,children:s.jsxs(fe,{type:"button",variant:"outline",size:"icon",className:P("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",l>0&&"w-auto px-3"),"aria-label":l>0?`Open transcript outline, ${l} ${l===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(dn,{}),l>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[l," waiting"]}):null]})}),s.jsxs(fn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(fe,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:P("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},so=({trip:e})=>s.jsxs("div",{className:P(Ge,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(an,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),lo=()=>{const{currentSuggestions:e,starters:t,messages:n,running:r,append:o}=Ee(),l=Kn(e,t,n.length);return r||l.length===0?null:s.jsx(Nn,{prompts:l,className:P(Ge,n.length===0&&"mt-auto"),onPick:i=>o(i)})},ao=({message:e})=>e.role==="user"?s.jsx(io,{message:e}):e.role==="system"?s.jsx(vo,{message:e}):s.jsx(fo,{message:e}),Ut=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return s.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=s.jsxs(s.Fragment,{children:[s.jsx(He,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},io=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:xt,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(co,{part:n},De(e,n)))})}):s.jsx("div",{className:Cn,children:s.jsxs("div",{className:P(Ne,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx(Ut,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:n.text,renderText:r=>r})},De(e,n)):null)]})})},co=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:P(Ne,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(pn,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},Ft=new Set(["question","link-button","tool-approval"]),uo="subscription-candidate",fo=({message:e})=>{const t=Qe(),{agentId:n,workspaceSlug:r}=Ee(),o=u=>u.type==="tool-call"&&(Ft.has(u.toolName)||t?.toolNames.has(u.toolName)),l=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==uo),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=Rt(u.result);return d?[d]:[]});return s.jsx("div",{className:xt,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[l.length>0?s.jsx(ho,{tools:l,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(po,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(bo,{part:u},De(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx(Ut,{attachment:u},u.id))}):null]})})},po=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:P(Ne,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(fe,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(gt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(hn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function mo(e){try{return JSON.parse(e)}catch{return null}}function Vt(e){if(Array.isArray(e)){const o=e.flatMap(l=>l?.type==="text"&&typeof l.text=="string"?Vt(l.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?mo(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const l=o&&typeof o=="object"?o.id:null;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?[l]:[]});return r.length>0?r:null}const ho=({tools:e,workspaceSlug:t})=>s.jsxs(Nt,{defaultOpen:!1,children:[s.jsx(Et,{children:e.length===1?ot(e[0].args,e[0].toolName)??e[0].toolName:`${e.length} tool calls`}),s.jsx(It,{children:e.map(n=>{const r=ot(n.args,n.toolName),o=n.args!==void 0&&n.args!==null,l=n.result!==void 0&&n.result!==null,i=Vt(n.result);return s.jsxs(At,{icon:mn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:r??n.toolName}),r?s.jsx("span",{className:"text-muted-foreground",children:n.toolName}):null,n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.args)}):null,l?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Fe(n.result)}):null,i&&t?s.jsx(ir,{ownerSlug:t,eventIds:i}):null]},n.toolCallId)})})]}),go=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const l=JSON.parse(r[0])?.error?.message;typeof l=="string"&&l.trim()&&(t=l,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(bn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},bo=({part:e})=>{const t=Qe();return e.type==="reasoning"?s.jsx(lr,{}):e.type==="error"?s.jsx(go,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Xe,{text:e.text,renderText:n=>s.jsx(gn,{text:n})}):null:e.type!=="tool-call"?null:Ft.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(Ao,{toolName:e.toolName,args:e.args}):null},xo=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:P(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},vo=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:P(Ne,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Xe,{text:t.text,renderText:n=>n})},De(e,t)):null)})}),yo="/mcp-apps/interaction/index.html";function mt(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const Ro=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const l=a.useRef(null),[i,c]=a.useState(48),u=a.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},a.useEffect(()=>{const d=l.current;if(!d?.contentWindow)return;const m=new yn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});m.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),m.oncalltool=async({name:g,arguments:w})=>{const E=await u.current.onToolCall(g,w??{});return{isError:E,content:[{type:"text",text:E?"Action failed.":"Action completed."}]}},m.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),m.addEventListener("initialized",()=>{(async()=>(await m.sendToolInput({arguments:{}}),await m.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:eo}})))()});const y=new Rn(d.contentWindow,d.contentWindow);m.connect(y).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const h=new MutationObserver(()=>{m.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return h.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{h.disconnect(),y.close()}},[]),s.jsx("iframe",{ref:l,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},wo=new Set(["action"]),So=["name","description","identity_md"];function oe(e){return e==null||e===""?"":typeof e=="string"?e:Fe(e)}function ht(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Fe(e)}function Ue(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Bt=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function Ke(e){return e&&Bt.has(e)?"warning":"default"}function qe(e,t){return e&&Bt.has(e)?{level:"high",reason:t}:{level:"normal"}}function To(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(l=>({label:l,before:oe(e.current?.[l]),after:oe(t[l])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function Co(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},l=Object.keys(o).filter(i=>!wo.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:ht(e.current?.[i])}:{},after:ht(o[i])}));return r.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0}),{title:`${Ue(t)} Automation ${n}`,icon:"automation",impact:qe(e.action,"This archives the Automation and stops future runs."),tone:Ke(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function jo(e){if(e.resourceKind==="automation")return Co(e);if(e.fields&&Object.keys(e.fields).length>0)return To(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return Mn({...e,action:e.action});if(t){const l=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&oe(e.proposal?.[d])!==oe(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:oe(e.current?.[d])}:{},after:oe(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(i)} entity ${l}`,icon:"entity",impact:qe(e.action,"This deletes the entity."),tone:Ke(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${l} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${l} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const l=So.filter(i=>e.proposal?.[i]!==void 0&&oe(e.proposal?.[i])!==oe(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:oe(e.current?.[i])}:{},after:oe(e.proposal?.[i])}));o.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ue(r)} agent ${n}`,icon:"agent",impact:qe(e.action,"This permanently deletes the agent and its configuration."),tone:Ke(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function No(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function Eo(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const Ao=({toolName:e,args:t})=>{const n=xn(),r=vn(),{append:o}=Ee(),l=Qe(),i=t??{},c=l?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},m=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const y=i.runId,h=typeof i.status=="string"?i.status:"pending",g=h==="pending",w=jo(i),E=h==="confirmed"?"Approved":Ue(h);u=g?w:{...w,title:`${w.title??"Approval"} · ${E}`,tone:h==="failed"?"warning":"default",blocks:[...w.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${h==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${E}.`,muted:!0}],actions:(w.actions??[]).filter(v=>v.terminal===!1)},g&&(d.manage_operations=v=>{if(v.action==="approve")return mt(T=>n.mutate({run_id:y},T));if(v.action==="reject"){const T=typeof v.reason=="string"?v.reason:void 0;return mt(H=>r.mutate({run_id:y,...T?{reason:T}:{}},H))}return Promise.resolve(!0)})}else if(e==="question"){const y=Array.isArray(i.options)?i.options.filter(h=>typeof h=="string"):[];u=No(i),d.answer_question=h=>{const g=typeof h.answer=="string"?h.answer:"";return y.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!pt(i.url))return null;const y=i.url;m.add(y),u=Eo(i,y)}}return u?s.jsx(Ro,{src:yo,title:u.title??"Interaction",renderPayload:u,onToolCall:(y,h)=>d[y]?d[y](h):Promise.resolve(!0),onOpenLink:y=>!m.has(y)||!pt(y)?Promise.resolve(!0):(window.open(y,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Fe(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const Io=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:l,initialDraft:i,currentSuggestions:c}=Ee(),u=ko({suggestions:e?null:c}),[d,m]=a.useState(i??""),y=a.useRef(null),h=a.useRef(null),g=_n(On),w=a.useRef(i??"");a.useEffect(()=>{const T=i??"";if(T===w.current)return;const H=w.current;w.current=T,T!==""&&m(U=>U===""||U===H?T:U)},[i]);const E=a.useRef(d);E.current=d;const v=()=>{e||(t(E.current),m(""),h.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(T=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(He,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:T.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>l(T.id),children:s.jsx(on,{className:"h-3 w-3"})})]},T.id))}):null,s.jsx(Pn,{value:d,onChange:m,onSubmit:v,searchRefs:g,handleRef:h,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:y,type:"file",multiple:!0,className:"hidden",onChange:T=>{T.target.files&&o(T.target.files),T.target.value=""}}),s.jsxs(fe,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>y.current?.click(),children:[s.jsx(He,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(fe,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(sn,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(fe,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:v,children:[s.jsx(ln,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function ko({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Vo as A,Fo as L,Uo as R,er as h,Yn as s};
|
|
6
|
+
//# sourceMappingURL=agent-thread-FyEO-y44.js.map
|
package/dist/owletto/dist/assets/{agents-workbench-bPTjdVS1.js → agents-workbench-CDpJmUVN.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as
|
|
2
|
-
//# sourceMappingURL=agents-workbench-
|
|
1
|
+
import{c as M,w as I,q as L,at as N,bb as w,r as O,hJ as R,hK as W,c5 as E,hL as _,hM as D,j as t,ak as U,al as y,gT as B,L as f,gU as k,O as F,i as G,v as P,eI as q,aq as K}from"./index-BjcZVe7n.js";import{A as z}from"./agent-editor-form-BXQBFHSv.js";import{P as H}from"./proposal-review-shell-BED-DO9C.js";import{n as J}from"./nav-pill-Bam6s3jj.js";const b=[{key:"skills",label:"Skills",icon:R},{key:"guardrails",label:"Guardrails",icon:W},{key:"permissions",label:"Permissions",icon:E,adminOnly:!0},{key:"models",label:"Models",icon:_},{key:"settings",label:"Settings",icon:D}];function T(s){return b.filter(e=>!e.adminOnly||s)}function Q(s,e){if(e===`${s}/conversations`||e.startsWith(`${s}/conversations/`))return null;for(const{key:n}of b)if(e===`${s}/${n}`||e.startsWith(`${s}/${n}/`))return n;return e===`${s}/identity`||e===`${s}/identity/`?"settings":null}function V(s){return s.trim().charAt(0).toUpperCase()||"?"}function X({owner:s,agentId:e,agentName:n,activeDest:a}){const{orgContext:r}=P(),{isAdmin:l}=q(r.organizationId),c=T(!!l);return t.jsxs("div",{className:"flex shrink-0 flex-col items-center gap-2",children:[t.jsxs(f,{to:"/$owner/agents/$agentId/settings",params:{owner:s,agentId:e},search:{run_id:void 0},className:"flex min-w-0 items-center gap-2 rounded-md outline-none transition-colors hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring",title:"Agent settings",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-foreground",children:V(n)}),t.jsx("h1",{className:"min-w-0 truncate text-base font-semibold tracking-tight",children:n})]}),t.jsx("nav",{"aria-label":"Agent sections",className:"flex min-w-0 max-w-full flex-wrap items-center justify-center gap-1",children:c.map(({key:d,label:u,icon:g})=>{const o=d===a;return t.jsxs(f,{to:`/$owner/agents/$agentId/${d}`,params:{owner:s,agentId:e},"aria-current":o?"page":void 0,className:J(o,"shrink-0 gap-1.5 px-2.5 py-1 text-sm"),children:[t.jsx(g,{className:"h-3.5 w-3.5 shrink-0"}),u]},d)})})]})}function ns({owner:s,agentId:e}){const n=M(),{pathname:a}=I(),{isAuthenticated:r}=L(),{isMember:l}=N(),c=r&&l,{data:d=[],isLoading:u}=w({enabled:c}),g=d.find(A=>A.agentId===e)??null,o=!g&&!u&&c,m=`/${s}/agents/${e}`,x=`${m}/conversations`,h=a===x||a.startsWith(`${x}/`),i=Q(m,a);O.useEffect(()=>{o&&n({to:"/$owner",params:{owner:s},replace:!0})},[o,n,s]);const v=g?.name??"Agent",j=b.find(A=>A.key===i)?.label??"Conversations",p=a.slice(m.length+1).split("/")[1],C=i==="settings"&&!p,S=C?v:p?p==="create"?i==="skills"?"Add a skill":"New custom guardrail":i==="skills"?"Skill details":i==="guardrails"?"Guardrail details":"Conversation":j;return t.jsxs(U,{className:"gap-3 overflow-hidden pt-2.5 pb-8",children:[t.jsx(y,{children:t.jsx(B,{crumbs:[t.jsx(f,{to:"/$owner/agents",params:{owner:s},className:k,children:"Agents"},"agents"),...C?[]:[t.jsx(f,{to:"/$owner/agents/$agentId/settings",params:{owner:s,agentId:e},search:{run_id:void 0},className:k,children:v},"agent")],...p&&i?[t.jsx(f,{to:`/$owner/agents/$agentId/${i}`,params:{owner:s,agentId:e},className:k,children:j},"section")]:[]],current:S})}),t.jsx(X,{owner:s,agentId:e,agentName:v,activeDest:i}),t.jsx("div",{className:G("flex min-h-0 min-w-0 flex-1 flex-col",h?"overflow-hidden":"overflow-y-auto"),children:t.jsx(F,{})})]})}function Y({agent:s,tab:e,runId:n}){return t.jsx(y,{className:"pb-6",children:t.jsx(H,{resource:{kind:"agent",agentId:s.agentId},runId:n,children:({reviewMode:a,proposal:r,controlsDisabled:l})=>t.jsx(z,{mode:{kind:"edit",agent:s},section:e,reviewMode:a,reviewProposal:r,reviewControlsDisabled:l},s.agentId)})})}function as({owner:s,agentId:e,tab:n,runId:a}){const{orgContext:r,hasOrgContext:l}=P(),{isLoading:c}=K(`/${s}`,r),{isAuthenticated:d}=L(),{isMember:u,isLoading:g}=N(),o=d&&u,{data:m=[],isLoading:x}=w({enabled:o}),$=o?!l||c||x||g:c||g,h=m.find(i=>i.agentId===e)??null;return $||!h?null:t.jsx(Y,{agent:h,tab:n,runId:a})}export{ns as A,as as a};
|
|
2
|
+
//# sourceMappingURL=agents-workbench-CDpJmUVN.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as c,
|
|
2
|
-
//# sourceMappingURL=app._appId-
|
|
1
|
+
import{r as c,iF as b,aW as w,aG as y,b7 as C,aJ as u,j as e,al as k,L as o,gl as j,B as v,gk as A,iR as P,gi as g,gS as R,gT as B,gU as D,A as $,Y as I,fg as L,iS as M,az as z}from"./index-BjcZVe7n.js";import{C as E}from"./connector-page-shell-Di6XzkVo.js";import{C as O}from"./connections-browser-BXsJqieG.js";import"./connection-label-BobuYiAG.js";import"./status-dot-BnQPFrcU.js";function T({ownerSlug:s,appId:a}){const n=c.useMemo(()=>b(s,a,w()),[s,a]),{data:r=[],isLoading:l,isError:d,refetch:N}=y(),[m,x]=c.useMemo(()=>{const t=n?.devicePlatforms;if(!t?.length)return[[],[]];const h=r.filter(i=>{const f=C(i);return f!=null&&t.includes(f)});return[h.filter(i=>u(i,s)),h.filter(i=>!u(i,s))]},[n,r,s]);if(!n)return e.jsxs(k,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no app by that name."}),e.jsx(o,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const p=(n.devicePlatforms?.length??0)>0;return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(E,{header:e.jsx(R,{breadcrumb:e.jsx(B,{crumbs:[e.jsx(o,{to:"/$owner/connectors",params:{owner:s},search:{},className:D,children:"Connectors"},"connectors")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border text-muted-foreground",children:n.icon}),title:n.name,caption:n.description}),children:[e.jsx("div",{id:"setup",className:"scroll-mt-40",children:e.jsx(j,{title:m.length>0?a==="owletto-chrome"?"Connect another profile":"Connect another device":"Set up",children:e.jsx("div",{className:"space-y-3",children:n.steps.map(t=>e.jsx(_,{step:t},t.label))})})}),p?e.jsx(O,{entries:m.map(t=>({id:t.id,name:g(t),description:P(t,s),tone:t.online?null:"muted",link:A({to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id}})})),isLoading:l,isError:d,onRetry:()=>void N(),action:e.jsx(v,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:"#setup",children:"Add connection"})})}):null,p&&!l&&!d&&x.length>0?e.jsxs(j,{title:"Your devices in other workspaces",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Open a device to connect its capabilities here. Moving it is confirmed first and pauses its connections where it is now."}),e.jsx("ul",{className:"divide-y border-y",children:x.map(t=>e.jsx("li",{children:e.jsxs(o,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id},className:"flex items-center justify-between gap-3 py-2.5 text-sm hover:text-primary",children:[e.jsx("span",{className:"font-medium",children:g(t)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Attached to"," ",t.organization_name??"another workspace"]})]})},t.id))})]}):null]})})}function _({step:s}){const[a,n]=c.useState(!1);if(s.href)return e.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-accent/50",children:[s.label,e.jsx($,{className:"h-3 w-3"})]});const r=s.command??"";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/40 p-2.5",children:[e.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto font-mono text-xs leading-relaxed",children:r}),e.jsxs(v,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},children:[a?e.jsx(I,{className:"h-3.5 w-3.5"}):e.jsx(L,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Copy"})]})]})]})}function H(){const{owner:s,appId:a}=M.useParams();return e.jsx(z,{owner:s,children:({ownerSlug:n})=>e.jsx(T,{ownerSlug:n,appId:a})})}export{H as component};
|
|
2
|
+
//# sourceMappingURL=app._appId-DwNeXRJp.js.map
|
package/dist/owletto/dist/assets/{assist-composer-ClfFEVx7.js → assist-composer-Mn9EfX4X.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as b,bb as k,r as o,
|
|
2
|
-
//# sourceMappingURL=assist-composer-
|
|
1
|
+
import{c as b,bb as k,r as o,jq as v,j as e,L as x,B as M,jr as P,cx as S}from"./index-BjcZVe7n.js";import{u as y,a as R,M as C}from"./use-mention-search-CJGCatFS.js";import{P as I,s as A}from"./pending-seed-BP3xHM2d.js";import{n as E}from"./agent-thread-storage-U6htL3ad.js";import"./index-Vcq4gwWv.js";import"./use-automations-D9hKpufo.js";function $({ownerSlug:i,starters:m,preferredMentionKinds:u,onSent:f}){const g=b(),{data:j=[]}=k(),l=y(C),n=o.useMemo(()=>new Set(u??[]),[u]),N=o.useCallback(async d=>{const t=await l(d);return n.size===0?t:[...t].sort((a,w)=>Number(n.has(w.kind))-Number(n.has(a.kind)))},[n,l]),r=v(j),[s,h]=o.useState(""),p=o.useRef(s);p.current=s;const c=d=>{const t=d.trim();if(!t||!r)return;const a=E();A(a,t),h(""),g(S(i,r.agentId,a)),f?.()};return e.jsxs("div",{className:"rounded-lg border bg-background p-4 transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r?e.jsx(R,{value:s,onChange:h,onSubmit:()=>c(p.current),searchRefs:N,placeholder:"Ask Lobu…",className:"[&_.ProseMirror]:max-h-40 [&_.ProseMirror]:min-h-24 [&_.ProseMirror]:overflow-y-auto"}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Bring your"," ",e.jsx(x,{to:"/$owner/agents/connect",params:{owner:i},className:"text-foreground hover:underline",children:"agent"})," ","or"," ",e.jsx(x,{to:"/$owner/agents/new",params:{owner:i},search:{},className:"text-foreground hover:underline",children:"create a new agent"})," ","to get started."]}),e.jsxs("div",{className:"flex items-end justify-between gap-3 pt-2",children:[r&&m&&!s.trim()?e.jsx(I,{prompts:m,onPick:c}):e.jsx("span",{}),e.jsxs(M,{type:"button",size:"icon",className:"h-10 w-10 shrink-0 rounded-full",disabled:!r||!s.trim(),onClick:()=>c(s),children:[e.jsx(P,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})}export{$ as AssistComposer};
|
|
2
|
+
//# sourceMappingURL=assist-composer-Mn9EfX4X.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{v,j as n,L as N,cp as b,aq as S,q as w,at as D,r as h,cP as R,u as O,hA as T,S as $,cQ as E,bN as F}from"./index-BjcZVe7n.js";import{C as L,A as P}from"./create-automation-form-C9PMX7N8.js";import{P as q}from"./proposal-review-shell-BED-DO9C.js";import{E as J}from"./events-feed-CGzA1w3R.js";import{D as M,a as B}from"./definition-comparison-B5WgZILB.js";import{b as A}from"./use-automations-D9hKpufo.js";import{b as H}from"./model-C2q7WDcS.js";function C({automationId:i}){const{currentOwner:t}=v();return t?n.jsx(N,{to:"/$owner/events",params:{owner:t},search:b({semanticTypes:["change"],eventCategory:"config",resourceKind:"automation",resourceId:i}),className:"text-sm text-primary underline underline-offset-4",children:"View definition history in Events"}):null}function k(i){const{orgContext:t,hasOrgContext:r}=v(),{data:o,isLoading:a}=S(`/${i}`,t),{isAuthenticated:d}=w(),{isMember:u,isLoading:c}=D(),g=d&&u,s=o?.workspace,f=g?!r||a||c:a||c;return{organizationId:s?.id??"",isLoading:f}}function z(i){return k(i)}function K({owner:i,automationId:t,organizationId:r}){const o=Number(t),a=h.useMemo(()=>({producedByAutomationId:o}),[o]),d=O(),u=A(t,void 0,r),c=u.data?.automation?.automation_name?.trim()||null,g=H(u.data?.automation),{data:s}=T(g,t,{orgSlug:i}),f=h.useMemo(()=>(s?.runs??[]).map(e=>({runId:e.runId,status:e.status,completedAt:e.completedAt})),[s]),p=h.useCallback(e=>{d?.open({href:`/${i}/automations/${t}?view=activity&run_id=${e}`,title:c!=null?`${c} · Run #${e}`:`Automation run #${e}`,runId:e})},[d,i,t,c]);return Number.isFinite(o)?n.jsx(J,{organizationId:r,ownerSlug:i,filters:a,groupByRun:!0,onRunSelect:p,runs:f,hideRunAction:!0,hideAttribution:!0,emptyState:n.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"This Automation hasn't written anything yet. Runs appear here with the events they created; clicking a run opens its conversation."})}):null}function Q({agentId:i,automationId:t,runId:r,organizationId:o,onDone:a}){const[d,u]=h.useState({ready:!1,triggers:[]}),c=h.useCallback(l=>{u(m=>JSON.stringify(m)===JSON.stringify(l)?m:l)},[]),g=A(t,void 0,o,{includeVersions:!0}),s=g.data?.automation,{currentOwner:f}=v(),p=R({queryKey:["automations-list",f,"editor",t,s?.status],enabled:!!f&&!!o&&!!s,queryFn:async()=>{const m=(await E("manage_automations",{action:"list",automation_id:t,status:s?.status,include_details:!0,limit:1},{slug:f})).automations.find(y=>y.automation_id===t);if(!m)throw new F("Automation not found",404);return m},staleTime:3e4}),e=p.data,x=h.useMemo(()=>s&&e?{automation_id:s.automation_id,name:e.name,slug:e.slug,description:e.description,prompt:e.prompt,sources:e.sources,reaction_script:s.reaction_script,managed_agent_id:e.managed_agent_id,device_worker_id:e.device_worker_id,agent_kind:e.agent_kind,delivery_target:e.delivery_target??void 0,execution_config:e.execution_config??void 0,model_config:e.model_config,tags:e.tags,keying_config:s.keying_config,reactions_guidance:e.reactions_guidance,triggers:e.triggers}:void 0,[s,e]),_=n.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(l=>n.jsx($,{className:"h-16 w-full rounded-lg"},l))}),j=p.isError?n.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[n.jsx("p",{children:"Could not load the saved Automation definition."}),n.jsx("button",{type:"button",className:"text-primary underline underline-offset-4",onClick:()=>void p.refetch(),children:"Retry"})]}):g.isLoading||s&&p.isPending?_:x?n.jsx(L,{organizationId:o,prefillAgentId:i??void 0,editingAutomation:x,createFields:{triggers:d.triggers},triggerFields:n.jsx(P,{organizationId:o,initialTriggers:x.triggers??[],onChange:c},JSON.stringify(x.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!d.ready,onClose:a}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return i?n.jsxs("div",{className:"space-y-6",children:[n.jsx(q,{resource:{kind:"automation",agentId:i,automationId:t},runId:r,onDone:a,children:({reviewMode:l,proposal:m})=>l==="active"?n.jsx(M,{current:m?.current??null,proposed:{...m?.current??{},...m?.proposedAfter??{}},render:y=>n.jsx(B,{value:y})}):l==="loading"?_:l==="error"?null:j}),n.jsx(C,{automationId:t})]}):n.jsxs("div",{className:"space-y-6",children:[j,n.jsx(C,{automationId:t})]})}function I({owner:i,agentId:t,automationId:r,view:o,runId:a,onDone:d}){const{organizationId:u}=k(i),c=A(r,void 0,u),g=t??c.data?.automation?.managed_agent_id??null;return a||o==="definition"?n.jsx(Q,{agentId:g,automationId:r,runId:a,organizationId:u,onDone:d},`${i}/${r}`):n.jsx(K,{owner:i,automationId:r,organizationId:u})}export{I as A,z as u};
|
|
2
|
+
//# sourceMappingURL=automation-detail-content-Bs3vwAPd.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=automation-row-
|
|
1
|
+
import{fh as b,fi as g,cL as k,j as e,L as j,V as r,b8 as y,W as C,fj as d,fk as A,d1 as $,ek as p,eq as M,ct as I}from"./index-BjcZVe7n.js";const m="bg-muted text-muted-foreground",R={event:{label:"Event",icon:k},schedule:{label:"Schedule",icon:g},manual:{label:"Manual",icon:b}};function S({agentName:n,deviceLabel:s,executorKind:i}){const t=i==="script"?{label:"Script",icon:d}:i==="external"?{label:"External executor",icon:d}:s?{label:s,icon:A}:n?{label:n,icon:$}:{label:"Manual · any client",icon:d},{label:l,icon:c}=t;return e.jsxs(r,{variant:"secondary",className:m,children:[e.jsx(c,{className:"h-3 w-3"}),l]})}function E({lastRunAt:n,nextRunAt:s,repliesToSource:i}){const t=n?`Ran ${p(n)}`:s?`Next run ${p(s)}`:i?"Replies to incoming messages":"Never run";return e.jsxs(r,{variant:"secondary",className:m,children:[e.jsx(M,{className:"h-3 w-3"}),t]})}function L({count:n}){return n<=0?null:e.jsxs(r,{variant:"secondary",className:m,children:[e.jsx(I,{className:"h-3 w-3"}),n," ",n===1?"client":"clients"]})}function B({automation:n,agentName:s,deviceLabel:i,connectorDisplay:t,owner:l,actions:c,rowClass:v,appearance:N="row"}){const a=n.automation,o=a.execution_config?.executor,_=o&&typeof o=="object"?o.kind:void 0,u=a.automation_id,x=R[n.kind],w=a.entity_name&&a.entity_type?`${a.entity_name} · ${a.entity_type}`:null,h=[n.when,w].filter(Boolean).join(" — "),f=a.health==="degraded"?a.health_reasons?.[0]||"Needs attention":null;return N==="inline"?e.jsxs(j,{to:"/$owner/automations/$automationId",params:{owner:l,automationId:u},search:{view:"definition",run_id:void 0},className:"inline-flex items-center gap-1.5 rounded-md bg-accent px-1.5 py-0.5 text-sm font-medium",children:[e.jsx(x.icon,{className:"h-3.5 w-3.5 shrink-0"}),n.does,a.status==="archived"?e.jsx(r,{variant:"outline",children:"Archived"}):null]}):e.jsxs("div",{className:v,children:[e.jsxs(j,{to:"/$owner/automations/$automationId",params:{owner:l,automationId:u},search:{view:"definition",run_id:void 0},className:"flex min-w-0 flex-1 items-center gap-3",children:[t?e.jsx(y,{icon:t.icon,iconUrl:t.iconUrl,name:t.name,faviconDomain:t.faviconDomain,className:"h-7 w-7 shrink-0 rounded-md text-[10px]"}):e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(x.icon,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:n.does}),a.status==="archived"?e.jsx(r,{variant:"outline",children:"Archived"}):null,e.jsx(S,{agentName:s,deviceLabel:i,executorKind:_}),e.jsx(E,{lastRunAt:a.last_run_completed_at??a.last_fired_at??null,nextRunAt:a.next_run_at??null,repliesToSource:n.output.destination==="source"}),e.jsx(L,{count:a.processing_client_count??0}),f?e.jsxs(r,{variant:"secondary",className:"max-w-full whitespace-normal bg-amber-500/10 text-left text-amber-700 dark:text-amber-400",children:[e.jsx(C,{className:"h-3 w-3 shrink-0"}),f]}):null]}),h?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:h}):null]})]}),c]})}export{B as A};
|
|
2
|
+
//# sourceMappingURL=automation-row-B5Q1B10y.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as e,B as l,X as i}from"./index-BjcZVe7n.js";function x({sources:a,onRemove:s,disabled:n,wrap:r=!1}){return e.jsx(e.Fragment,{children:a.length>0?e.jsx("ul",{className:"space-y-2",children:a.map(t=>e.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-mono text-xs font-medium",children:t.name}),e.jsx("div",{className:r?"whitespace-pre-wrap break-words text-xs text-muted-foreground":"truncate text-xs text-muted-foreground",children:t.query})]}),s?e.jsx(l,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${t.name}`,disabled:n,onClick:()=>s?.(t),children:e.jsx(i,{className:"h-3.5 w-3.5"})}):null]},t.query))}):null})}export{x as A};
|
|
2
|
+
//# sourceMappingURL=automation-source-list-Dhucq1sI.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as a,q as i,r as n,j as t}from"./index-
|
|
2
|
-
//# sourceMappingURL=callback-
|
|
1
|
+
import{c as a,q as i,r as n,j as t}from"./index-BjcZVe7n.js";function r(){const s=a(),{isReady:e}=i();return n.useEffect(()=>{e&&setTimeout(()=>{s({to:"/"})},500)},[e,s]),t.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:t.jsx("div",{className:"text-center",children:t.jsx("p",{className:"text-muted-foreground",children:e?"Redirecting...":"Completing sign in..."})})})}export{r as component};
|
|
2
|
+
//# sourceMappingURL=callback-9xSHyA12.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as r,bE as d}from"./index-
|
|
2
|
-
//# sourceMappingURL=card-
|
|
1
|
+
import{j as r,bE as d}from"./index-BjcZVe7n.js";function n({className:a,...t}){return r.jsx("div",{"data-slot":"card",className:`bg-card text-card-foreground flex flex-col gap-6 rounded-2xl border py-6 ${a||""}`,...t})}function i({className:a,...t}){return r.jsx("div",{"data-slot":"card-header",className:`grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] ${a||""}`,...t})}function c({className:a,asChild:t=!1,...s}){const o=t?d:"div";return r.jsx(o,{"data-slot":"card-title",className:`leading-none font-semibold ${a||""}`,...s})}function l({className:a,...t}){return r.jsx("div",{"data-slot":"card-description",className:`mt-1 first:mt-0 text-muted-foreground text-sm ${a||""}`,...t})}function u({className:a,...t}){return r.jsx("div",{"data-slot":"card-content",className:`px-6 ${a||""}`,...t})}export{n as C,i as a,c as b,u as c,l as d};
|
|
2
|
+
//# sourceMappingURL=card-g4yxo4Hr.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,
|
|
2
|
-
//# sourceMappingURL=change-summary-
|
|
1
|
+
import{j as e,ek as i,V as t}from"./index-BjcZVe7n.js";function c({operation:a}){switch(a){case"create":case"created":return e.jsx(t,{variant:"default",children:"Created"});case"update":case"updated":return e.jsx(t,{variant:"secondary",children:"Updated"});case"delete":case"deleted":return e.jsx(t,{variant:"destructive",children:"Deleted"});default:return e.jsx(t,{variant:"outline",children:a||"Change"})}}function x({operation:a,actor:l,createdAt:s,resource:r,changedFields:n,showAttribution:d=!0}){return e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r?e.jsx("span",{className:"break-words text-sm font-medium",children:r}):null,e.jsx(c,{operation:a}),d?e.jsx("time",{dateTime:s,title:s,className:"ml-auto text-xs text-muted-foreground",children:i(s)}):null]}),d?e.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["by ",l||"unknown"]}):null,n?.length?e.jsxs("p",{className:"break-words text-xs text-muted-foreground",children:["Changed: ",n.join(", ")]}):null]})}export{x as C};
|
|
2
|
+
//# sourceMappingURL=change-summary-DeuXQEpb.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{E as e,j as c,F as r}from"./index-
|
|
2
|
-
//# sourceMappingURL=claim-
|
|
1
|
+
import{E as e,j as c,F as r}from"./index-BjcZVe7n.js";function n(){const{team:a}=e({from:"/slack/claim"});return c.jsx(r,{to:"/connector/$name/connection",params:{name:"slack"},search:{ref:a},replace:!0})}export{n as component};
|
|
2
|
+
//# sourceMappingURL=claim-B98IhDra.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{q as m,cP as y,a3 as f,Q as I,
|
|
2
|
-
//# sourceMappingURL=client-activity-scopes-
|
|
1
|
+
import{q as m,cP as y,a3 as f,Q as I,e3 as v}from"./index-BjcZVe7n.js";function w(t){const{session:o,isReady:u}=m(),c=u?o?.user.id:void 0,l=t?.limit??20,i=(t?.clientIds??[]).join(","),a=t?.activityKind??null,d=t?.excludeCommandClients??!1,n=t?.organizationId??null,s=t?.refetchInterval;return y({queryKey:["client-activity-scopes",c,l,i,a,d,n],queryFn:async()=>{const e=new URLSearchParams({limit:String(l)});i&&e.set("client_ids",i),a&&e.set("activity_kind",a),d&&e.set("exclude_command_clients","true"),n&&e.set("organization_id",n);const r=await f(`${I}/api/me/clients/activity-scopes?${e}`,{credentials:"include"});return await v(r,"Failed to load client activity"),(await r.json()).scopes??[]},enabled:!!c&&(t?.enabled??!0),staleTime:15e3,refetchInterval:typeof s=="function"?e=>s((e.state.data?.length??0)>0):s})}export{w as u};
|
|
2
|
+
//# sourceMappingURL=client-activity-scopes-BD2HBo-_.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{cH as c}from"./index-
|
|
2
|
-
//# sourceMappingURL=client-rows-
|
|
1
|
+
import{cH as c}from"./index-BjcZVe7n.js";function a(t){const n=new Map;for(const e of t){if(e.kind!=="mcp")continue;const s=e.title?.trim()||e.identifier||"Unknown app",l=e.registrationGroupKey||e.id,i=n.get(l);if(!i){n.set(l,{key:l,clientId:e.id,title:s,drivenBy:e.drivenBy?.trim()||null,clientIds:[e.id],connected:e.status==="connected",lastSeenAt:e.lastSeenAt??null,linkedUser:e.linkedUserName??e.linkedUserEmail??null,linkedUserEntitySlug:e.linkedUserEntitySlug??null});continue}i.clientIds.push(e.id),i.connected=i.connected||e.status==="connected",(e.lastSeenAt??0)>(i.lastSeenAt??0)&&(i.lastSeenAt=e.lastSeenAt??null,i.drivenBy=e.drivenBy?.trim()||null)}return[...n.values()].sort((e,s)=>(s.lastSeenAt??0)-(e.lastSeenAt??0))}function o(t){const n=[t.linkedUser];return n.push(t.connected?`active ${c(t.lastSeenAt)}`:"disconnected"),t.drivenBy&&t.drivenBy!==t.title&&n.push(`via ${t.drivenBy}`),n.filter(Boolean).join(" · ")}function d(t){return t.title?.trim()||t.clientName?.trim()||(t.activityKind==="session"?"MCP session":"App activity")}export{o as a,d as c,a as g};
|
|
2
|
+
//# sourceMappingURL=client-rows-x_CxeWkP.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{cO as c,cP as u,a6 as d,bX as p,bt as r,a3 as o,
|
|
2
|
-
//# sourceMappingURL=clients-
|
|
1
|
+
import{cO as c,cP as u,a6 as d,bX as p,bt as r,a3 as o,e3 as i,Q as w}from"./index-BjcZVe7n.js";function l(t,s="",e){const n=`${w}/api/${t}/clients${s}`,a=e?.toString();return a?`${n}?${a}`:n}function h(t,s){const e=s?.ownerSlug??c().slug;return u({queryKey:["connected-clients",e,t??null],queryFn:async()=>{if(!e)throw new Error("Workspace required");const n=new URLSearchParams;t&&n.set("agentId",t);const a=await o(l(e,"",n),{credentials:"include"});return await i(a,"Failed to load connected clients"),(await a.json()).clients??[]},enabled:!!e&&(s?.enabled??!0),staleTime:15e3,refetchInterval:s?.refetchInterval})}function y(){const{slug:t}=c(),s=d();return p({mutationFn:async e=>{if(!t)throw new Error("Workspace required");const n=new URLSearchParams;e.scope==="all"&&n.set("scope","all");const a=await o(l(t,`/mcp/${encodeURIComponent(e.clientId)}`,n),{method:"DELETE",credentials:"include"});return await i(a,"Failed to revoke client"),await a.json()},onSuccess:()=>{s.invalidateQueries({queryKey:["connected-clients",t]}),r.success("App access revoked")},onError:e=>{r.error(e.message||"Failed to revoke app access")}})}export{y as a,h as u};
|
|
2
|
+
//# sourceMappingURL=clients-Cmp0LmOp.js.map
|