@lobu/runtime-server 24.4.0 → 24.5.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/skills.json +2 -2
- package/dist/component.json +1 -1
- package/dist/connectors/postgres.ts +77 -48
- package/dist/dependencies.bun.lock +86 -117
- package/dist/owletto/dist/assets/_-CCWuGXtQ.js +2 -0
- package/dist/owletto/dist/assets/_-DOJW1D-I.js +3 -0
- package/dist/owletto/dist/assets/_agentId-CJhQbi6k.js +2 -0
- package/dist/owletto/dist/assets/_agentId-DD4K1i6V.js +2 -0
- package/dist/owletto/dist/assets/_automationId-Cbd7B0mP.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DFpPep9B.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-n3iSDT74.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-B1yGIGA9.js +2 -0
- package/dist/owletto/dist/assets/_eventId-B1H0-vD7.js +2 -0
- package/dist/owletto/dist/assets/_name-D30_V03t.js +2 -0
- package/dist/owletto/dist/assets/_owner-Be8O41u8.js +3 -0
- package/dist/owletto/dist/assets/_shape-C6YbloRh.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-BMPvvoOI.js +2 -0
- package/dist/owletto/dist/assets/_slug-Bc4YIEA2.js +2 -0
- package/dist/owletto/dist/assets/_view-aoFDwEld.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-DuNHc3cc.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-rJ7A1zNx.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-pUl-c1KQ.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-DN0ZEAzr.js +2 -0
- package/dist/owletto/dist/assets/{agent-card-controls-99mG6H5k.js → agent-card-controls-C5jNWgfq.js} +2 -2
- package/dist/owletto/dist/assets/{agent-client-setup-list-kMmqQSrf.js → agent-client-setup-list-DbXtJTsO.js} +2 -2
- package/dist/owletto/dist/assets/agent-connect-pages-DcTuiSt9.js +2 -0
- package/dist/owletto/dist/assets/agent-editor-form-CdA5vLr8.js +2 -0
- package/dist/owletto/dist/assets/agent-guardrails-route-BJyfalBY.js +2 -0
- package/dist/owletto/dist/assets/agent-list-row-rF5LH-3k.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-Dnmb6W5Y.js → agent-loading-shells-ClY_O6lb.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-CbhXlbgY.js → agent-permissions-matrix-bP1Qihv7.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-V__2i6Vl.js → agent-skill-context-BAaGpvfS.js} +2 -2
- package/dist/owletto/dist/assets/agent-skills-route-Bv5luNdw.js +2 -0
- package/dist/owletto/dist/assets/agent-tab-intro-ednTs4WF.js +2 -0
- package/dist/owletto/dist/assets/agent-thread-WNk2HapT.js +6 -0
- package/dist/owletto/dist/assets/agent-thread-storage-U6htL3ad.js +2 -0
- package/dist/owletto/dist/assets/agents-DY2S2SGE.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-bPTjdVS1.js +2 -0
- package/dist/owletto/dist/assets/app._appId-DrL5H5lB.js +2 -0
- package/dist/owletto/dist/assets/assist-composer-ClfFEVx7.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-dFy1Huas.js +2 -0
- package/dist/owletto/dist/assets/automation-row-DCHM--aD.js +2 -0
- package/dist/owletto/dist/assets/automations-DY2S2SGE.js +2 -0
- package/dist/owletto/dist/assets/{calendar-DMq3Dtqy.js → calendar-Ck0yOLYu.js} +2 -2
- package/dist/owletto/dist/assets/{callback-B-CAz-bK.js → callback-DRABUOha.js} +2 -2
- package/dist/owletto/dist/assets/{card-SFtxv9f2.js → card-Bdi7VEwo.js} +2 -2
- package/dist/owletto/dist/assets/change-summary-PBoM6Asb.js +2 -0
- package/dist/owletto/dist/assets/{claim-DrxIRWKt.js → claim-CUIG1Oc-.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-boZOHuPW.js → client-activity-scopes-CXOWB5co.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-BJ2PxM4J.js → client-rows-36VnmgMK.js} +2 -2
- package/dist/owletto/dist/assets/{clients-C7Lnuc3S.js → clients-BJRcMk1A.js} +2 -2
- package/dist/owletto/dist/assets/code-editor-DNuRKde1.js +16 -0
- package/dist/owletto/dist/assets/connect-CMcEQWls.js +2 -0
- package/dist/owletto/dist/assets/connect-menu-C-B-1xGR.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-tGipxP5a.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-DSGU78eV.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-CPLbry8R.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-jSnGvzYs.js +2 -0
- package/dist/owletto/dist/assets/{connection-feed-detail-D7pnWaFB.js → connection-feed-detail-BIlkK0Pd.js} +2 -2
- package/dist/owletto/dist/assets/connection-q1bdnxCN.js +2 -0
- package/dist/owletto/dist/assets/{connections-browser-DDJQh8Na.js → connections-browser-V-3td9DB.js} +2 -2
- package/dist/owletto/dist/assets/{connector-boxes-DDX7Ebc4.js → connector-boxes-lFc-WP83.js} +2 -2
- package/dist/owletto/dist/assets/connector-page-shell-Cs1SjrYB.js +2 -0
- package/dist/owletto/dist/assets/connector-provenance-aJFeeRIC.js +2 -0
- package/dist/owletto/dist/assets/{connector-scope-lists-BibdzKl1.js → connector-scope-lists--vNdbOn0.js} +2 -2
- package/dist/owletto/dist/assets/connectors-BsvDMdsQ.js +2 -0
- package/dist/owletto/dist/assets/consent-DJV78pnz.js +2 -0
- package/dist/owletto/dist/assets/copy-button-DjMWgrBf.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-CHnfRiEM.js → core.esm-CQzL3ObT.js} +3 -3
- package/dist/owletto/dist/assets/create-BmKx5vq3.js +2 -0
- package/dist/owletto/dist/assets/create-Rt0RbiD4.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-PEmSLMD6.js +3 -0
- package/dist/owletto/dist/assets/create-jBEuveV1.js +2 -0
- package/dist/owletto/dist/assets/create._connectorKey-DcxhYIYC.js +2 -0
- package/dist/owletto/dist/assets/device-Ba3RsIgb.js +2 -0
- package/dist/owletto/dist/assets/device-pin-tombstone-C79KIAIK.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-CIaoq9co.js +2 -0
- package/dist/owletto/dist/assets/{entity-avatar-HloBoalJ.js → entity-avatar-TVKjZxWQ.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-daOOQo7O.js +2 -0
- package/dist/owletto/dist/assets/entity-page-BfJXvbxn.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-BLwH6qa7.js +2 -0
- package/dist/owletto/dist/assets/event-card-DVUB8my6.js +2 -0
- package/dist/owletto/dist/assets/event-detail-DkY95e5b.js +2 -0
- package/dist/owletto/dist/assets/{events-feed-BysC9HgU.js → events-feed-B9CZHI_P.js} +2 -2
- package/dist/owletto/dist/assets/filter-bar-wPaR12SS.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BMiXl54z.js → full-page-spinner-BqmckkOf.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-Csusrok2.js +2 -0
- package/dist/owletto/dist/assets/identity-Dmg3STO8.js +2 -0
- package/dist/owletto/dist/assets/index--ZWegctR.js +2 -0
- package/dist/owletto/dist/assets/{index-CzoK57xp.js → index-B0kw2lFL.js} +2 -2
- package/dist/owletto/dist/assets/index-BKrdVwW9.js +2 -0
- package/dist/owletto/dist/assets/index-BUBcNNUY.js +2 -0
- package/dist/owletto/dist/assets/index-BUDr4-Yv.js +2 -0
- package/dist/owletto/dist/assets/index-BYPQWVwD.js +2 -0
- package/dist/owletto/dist/assets/index-BfpaPJPj.js +2 -0
- package/dist/owletto/dist/assets/index-BicNFLBW.js +2 -0
- package/dist/owletto/dist/assets/index-Bsdv5aks.js +2 -0
- package/dist/owletto/dist/assets/index-C186T2Rw.js +53 -0
- package/dist/owletto/dist/assets/index-CX0pJ9j9.js +2 -0
- package/dist/owletto/dist/assets/{index-B4wXJwQY.js → index-CsrT07TJ.js} +2 -2
- package/dist/owletto/dist/assets/index-DdBTTN3y.js +7899 -0
- package/dist/owletto/dist/assets/index-DdYWarql.css +1 -0
- package/dist/owletto/dist/assets/index-JYEIN8nM.js +2 -0
- package/dist/owletto/dist/assets/index-Vcq4gwWv.js +2 -0
- package/dist/owletto/dist/assets/{index-C-WaHj1Y.js → index-ijqrJaRB.js} +2 -2
- package/dist/owletto/dist/assets/{index-D4-uel59.js → index-ikp_mTsf.js} +2 -2
- package/dist/owletto/dist/assets/json-diff-BaLL4Fsu.js +14 -0
- package/dist/owletto/dist/assets/{list-skeleton-Bp4HNgJ9.js → list-skeleton-CXDLkYTg.js} +2 -2
- package/dist/owletto/dist/assets/login-u6LCgDYG.js +2 -0
- package/dist/owletto/dist/assets/{logout-DxmfsVKD.js → logout-JhmuWJEH.js} +2 -2
- package/dist/owletto/dist/assets/manage-gear-D8LMhehh.js +2 -0
- package/dist/owletto/dist/assets/{member-scope-gate-vp3FihBD.js → member-scope-gate-4FQ0aanZ.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-CNZJbCJC.js +74 -0
- package/dist/owletto/dist/assets/model-jL871x2J.js +2 -0
- package/dist/owletto/dist/assets/model-selector-CgU8SJMF.js +2 -0
- package/dist/owletto/dist/assets/models-jdemgIZk.js +2 -0
- package/dist/owletto/dist/assets/nav-pill-DrFkuyUQ.js +2 -0
- package/dist/owletto/dist/assets/new-CcJOd5aH.js +2 -0
- package/dist/owletto/dist/assets/{new-CvX8_gIb.js → new-DgE1pVV0.js} +2 -2
- package/dist/owletto/dist/assets/new-OWwrYckd.js +2 -0
- package/dist/owletto/dist/assets/organization-CKM_oFX3.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-D68BjguQ.js +2 -0
- package/dist/owletto/dist/assets/pending-seed-sml8Uf6e.js +2 -0
- package/dist/owletto/dist/assets/permissions-BvA9SATv.js +2 -0
- package/dist/owletto/dist/assets/{proposal-review-shell-B4CSiyLB.js → proposal-review-shell-D6KABxah.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-BIVCHQHe.js +2 -0
- package/dist/owletto/dist/assets/record-activity-C9gVBbF0.js +2 -0
- package/dist/owletto/dist/assets/{record-session-CWXnCVln.js → record-session-R-uHNuby.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-7EGgTVX0.js → renderer-DXfJaCCa.js} +23 -23
- package/dist/owletto/dist/assets/{reset-password-CFUzxH7m.js → reset-password-Mx3baeNc.js} +2 -2
- package/dist/owletto/dist/assets/run-activity-link-CaIBSRQj.js +2 -0
- package/dist/owletto/dist/assets/run-initiator-BvzQJYW9.js +2 -0
- package/dist/owletto/dist/assets/{runs-BPtQBTRN.js → runs-fFJ1lPnw.js} +2 -2
- package/dist/owletto/dist/assets/runs-panel-DEnZHTa5.js +2 -0
- package/dist/owletto/dist/assets/runs-table-XGnxJl7S.js +2 -0
- package/dist/owletto/dist/assets/{schema-type-editor-panel-CAhOB648.js → schema-type-editor-panel-C0_9VcSs.js} +2 -2
- package/dist/owletto/dist/assets/settings-CP4PjMQA.js +2 -0
- package/dist/owletto/dist/assets/settings-CgaUJMHH.js +2 -0
- package/dist/owletto/dist/assets/skills-D-e_h3a9.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-Bh5F4C5K.js → source-record-panels-Bh0n4gGw.js} +2 -2
- package/dist/owletto/dist/assets/{status-dot-D3FoDRcc.js → status-dot-Cpq63I7p.js} +2 -2
- package/dist/owletto/dist/assets/{table-DFcJRNk7.js → table-BUqshjxa.js} +2 -2
- package/dist/owletto/dist/assets/{use-automations-BHoV0dLs.js → use-automations-BLNjxq2K.js} +2 -2
- package/dist/owletto/dist/assets/use-login-redirect-CmyQW7GT.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-C3rWLuKm.js → use-mention-search-dn3ws1WB.js} +3 -3
- package/dist/owletto/dist/assets/use-scroll-sentinel-DRyBMueA.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-CER47Tlz.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-DHrDO333.js → views-access-required-C_b9itZ2.js} +2 -2
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +53989 -51632
- package/dist/server.bundle.mjs +5 -5
- package/dist/verify.mjs +1 -1
- package/npm-shrinkwrap.json +183 -217
- package/package.json +3 -4
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
- package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
- package/vendor/core/dist/contracts/agent-settings.js +10 -7
- package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
- package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
- package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
- package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
- package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
- package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
- package/vendor/core/dist/error-report.d.ts +73 -0
- package/vendor/core/dist/error-report.js +346 -0
- package/vendor/core/dist/index.d.ts +3 -1
- package/vendor/core/dist/index.js +4 -1
- package/vendor/core/dist/logger.js +7 -4
- package/vendor/core/dist/otel-fetch.d.ts +19 -0
- package/vendor/core/dist/otel-fetch.js +96 -0
- package/vendor/core/dist/otel.d.ts +9 -0
- package/vendor/core/dist/otel.js +28 -7
- package/vendor/core/dist/reserved.d.ts +1 -1
- package/vendor/core/dist/reserved.js +6 -4
- package/vendor/core/dist/tool-result.d.ts +8 -0
- package/vendor/core/dist/tool-result.js +61 -0
- package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
- package/vendor/core/dist/worker/auth.js +4 -0
- package/vendor/core/package.json +6 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-DIK0ae_S.js +0 -2
- package/dist/owletto/dist/assets/_-gTbcArpS.js +0 -3
- package/dist/owletto/dist/assets/_agentId-DOmcJZfk.js +0 -2
- package/dist/owletto/dist/assets/_agentId-DW6wRCVC.js +0 -2
- package/dist/owletto/dist/assets/_automationId-B9IcDYBu.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-C6PmMPTA.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-BrJ8Pzze.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-BpJAeYYW.js +0 -2
- package/dist/owletto/dist/assets/_eventId-DarQJo0G.js +0 -2
- package/dist/owletto/dist/assets/_name-DtmNTcUm.js +0 -2
- package/dist/owletto/dist/assets/_owner-Db8at3hk.js +0 -3
- package/dist/owletto/dist/assets/_shape-6iFA8A86.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-CXkHn3Nl.js +0 -2
- package/dist/owletto/dist/assets/_slug-DBOuBLoX.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DC27aIN9.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DuYDieln.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-BbDCVvur.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-V4ftmSN7.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-B-NPTFs6.js +0 -2
- package/dist/owletto/dist/assets/agent-editor-form-DfMTSIvj.js +0 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-BvGgfd-h.js +0 -2
- package/dist/owletto/dist/assets/agent-skills-route-DFXr_bHp.js +0 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-DWzljvFb.js +0 -2
- package/dist/owletto/dist/assets/agent-thread-DQIr20H-.js +0 -6
- package/dist/owletto/dist/assets/agents-CLbeiqTR.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-C8bTa2rv.js +0 -2
- package/dist/owletto/dist/assets/app._appId-Bsq40nak.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-C9Cgr5Zj.js +0 -2
- package/dist/owletto/dist/assets/automations-CLbeiqTR.js +0 -2
- package/dist/owletto/dist/assets/code-editor-rX0t1g5C.js +0 -16
- package/dist/owletto/dist/assets/connect-BcwgytDV.js +0 -2
- package/dist/owletto/dist/assets/connect-menu-BF-AlunU.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-sDypRDeN.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-C9OkW1tv.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-Dc6HYr55.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-C6qbqgwF.js +0 -2
- package/dist/owletto/dist/assets/connection-88YzIBK9.js +0 -2
- package/dist/owletto/dist/assets/connector-provenance-Th8ymGec.js +0 -2
- package/dist/owletto/dist/assets/connectors-BqwgLUUK.js +0 -2
- package/dist/owletto/dist/assets/consent-BR5U7dwb.js +0 -2
- package/dist/owletto/dist/assets/copy-button-2swYh4jb.js +0 -2
- package/dist/owletto/dist/assets/create-BsPVnRpG.js +0 -2
- package/dist/owletto/dist/assets/create-CVPYVOR5.js +0 -2
- package/dist/owletto/dist/assets/create-QFjmhOEU.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-DmCOFbRT.js +0 -3
- package/dist/owletto/dist/assets/create._connectorKey-DLDDVtLS.js +0 -2
- package/dist/owletto/dist/assets/cronstrue-CKwjNYgj.js +0 -2
- package/dist/owletto/dist/assets/device-CKup7kvB.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-xGhCTU5_.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-B1H_ivDT.js +0 -2
- package/dist/owletto/dist/assets/entity-options-BSW_EG0W.js +0 -2
- package/dist/owletto/dist/assets/entity-page-D-WDWrAe.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-BCBdFndu.js +0 -2
- package/dist/owletto/dist/assets/event-card-Mcxv56DG.js +0 -2
- package/dist/owletto/dist/assets/event-detail-DXifj49J.js +0 -2
- package/dist/owletto/dist/assets/filter-bar-BQm-ubB1.js +0 -2
- package/dist/owletto/dist/assets/guardrails-D7W80sJO.js +0 -2
- package/dist/owletto/dist/assets/identity-N0cAO9BR.js +0 -2
- package/dist/owletto/dist/assets/index-4gCDI7m4.js +0 -7950
- package/dist/owletto/dist/assets/index-BNaI5GpS.js +0 -2
- package/dist/owletto/dist/assets/index-BUUrHuJJ.js +0 -2
- package/dist/owletto/dist/assets/index-BqrvJmLh.js +0 -2
- package/dist/owletto/dist/assets/index-CnvQEA5V.js +0 -2
- package/dist/owletto/dist/assets/index-Cq7P2c_E.js +0 -2
- package/dist/owletto/dist/assets/index-D3omC3Us.js +0 -2
- package/dist/owletto/dist/assets/index-DDGdlQrt.css +0 -1
- package/dist/owletto/dist/assets/index-DFEW7hMg.js +0 -2
- package/dist/owletto/dist/assets/index-DVV-WWuT.js +0 -2
- package/dist/owletto/dist/assets/index-DduQ_e9q.js +0 -2
- package/dist/owletto/dist/assets/index-DutlI1d-.js +0 -2
- package/dist/owletto/dist/assets/index-wHFQv1aT.js +0 -12
- package/dist/owletto/dist/assets/json-diff-E5D-NGYT.js +0 -4
- package/dist/owletto/dist/assets/login-7F48UJGx.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-CfDmjhDl.js +0 -74
- package/dist/owletto/dist/assets/model-Dn40BUzs.js +0 -2
- package/dist/owletto/dist/assets/model-selector-88PJnyTq.js +0 -2
- package/dist/owletto/dist/assets/models-BBK_n2RP.js +0 -2
- package/dist/owletto/dist/assets/new-4ruWHLR5.js +0 -2
- package/dist/owletto/dist/assets/new-gMD1PHTL.js +0 -2
- package/dist/owletto/dist/assets/oauth-workspace-access-D9BNmyMY.js +0 -2
- package/dist/owletto/dist/assets/organization-BHcp5Pzg.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-0sa10jER.js +0 -2
- package/dist/owletto/dist/assets/permissions-hhxosugv.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-CsenJeXa.js +0 -2
- package/dist/owletto/dist/assets/record-activity-D7bRaMk2.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-Bj63_hb9.js +0 -2
- package/dist/owletto/dist/assets/settings-Dg6nxKyw.js +0 -2
- package/dist/owletto/dist/assets/settings-KJJ6WihO.js +0 -2
- package/dist/owletto/dist/assets/skills-ayt06_o2.js +0 -2
- package/dist/owletto/dist/assets/use-scroll-sentinel-Ct-jt7O0.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-mKoqDsaD.js +0 -2
- /package/vendor/@better-auth-kysely-adapter/{.bun-tag-abf95749a412716 → .bun-tag-654b3a002b271269} +0 -0
- /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,V as R,v as U,L as b,bo as $,A as _,t as M,em as D,r as u,S as I,cK as K,cA as G,fZ as f,B as y,aa as H,hq as O,gk as Q,bu as V,gl as q,gm as W,iL as Z,aA as F}from"./index-4gCDI7m4.js";import{T as J,a as X,b as S,c as d,d as Y,e as x}from"./table-DFcJRNk7.js";import{a as w,g as P}from"./client-rows-BJ2PxM4J.js";import{u as A}from"./client-activity-scopes-boZOHuPW.js";import{u as B,a as ee}from"./clients-C7Lnuc3S.js";function se({isLive:n}){return e.jsx(R,{variant:n?"default":"secondary",className:`shrink-0 text-[10px] ${n?"":"text-muted-foreground"}`,title:n?"Live MCP transport":"No live MCP transport; activity history is retained",children:n?"Active":"Ended"})}function L({scopes:n,ownerSlug:i}){const l=U(),o=s=>s.organizationId===null?{to:"/$owner/events",params:{owner:"me"},search:{client_ids:s.clientId,mcp_activity_id:s.activityId}}:{to:"/$owner/agents/connected/$clientId/activity",params:{owner:i,clientId:s.clientId},search:{mcp_activity_id:s.activityId}},r=s=>{l(o(s))};return e.jsx("div",{className:"rounded-lg border",children:e.jsxs(J,{children:[e.jsx(X,{children:e.jsxs(S,{children:[e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Conversation"}),e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Calls"}),e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Last action"}),e.jsx(d,{className:"px-3 py-1.5 text-xs",children:"Last active"}),e.jsx(d,{className:"w-8 px-3 py-1.5"})]})}),e.jsx(Y,{children:n.map(s=>e.jsxs(S,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>r(s),children:[e.jsx(x,{className:"max-w-0 px-3 py-2 text-xs font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{...o(s),onClick:c=>c.stopPropagation(),className:"truncate hover:underline",children:w(s)}),s.activityKind==="session"?e.jsx(se,{isLive:s.isLive}):null,s.unreadNotificationCount>0?e.jsxs(R,{variant:"secondary",className:"shrink-0 text-[10px]",children:[s.unreadNotificationCount," unread"]}):null]})}),e.jsx(x,{className:"px-3 py-2 font-mono text-xs text-muted-foreground",children:s.callCount}),e.jsx(x,{className:"max-w-0 truncate px-3 py-2 text-xs text-muted-foreground",children:s.lastAction||"—"}),e.jsx(x,{className:"px-3 py-2 text-xs text-muted-foreground",children:$(s.lastCallAt)}),e.jsx(x,{className:"px-3 py-2 text-right",children:e.jsx("button",{type:"button","aria-label":`View ${w(s)} activity`,className:"text-muted-foreground hover:text-foreground",tabIndex:-1,children:e.jsx(_,{className:"h-3.5 w-3.5"})})})]},`${s.clientId}:${s.activityId}`))})]})})}function te({ownerSlug:n,clientId:i}){const{orgContext:l}=M(),{isAdmin:o}=D(l.organizationId),{data:r=[],isLoading:s}=B(null),c=ee(),[T,h]=u.useState(!1),t=u.useMemo(()=>P(r),[r]).find(a=>a.clientIds.includes(i)),N=t?.clientIds??[],g=A({enabled:!!t,limit:100,clientIds:N,activityKind:"conversation",organizationId:l?.organizationId??null}),p=A({enabled:!!t,limit:100,clientIds:N,activityKind:"session",organizationId:l?.organizationId??null,refetchInterval:a=>a?5e3:!1}),m=g.data??[],v=p.data??[],z=u.useMemo(()=>r.filter(a=>t?.clientIds.includes(a.id)),[r,t]);if(s)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(I,{className:"h-16 w-full rounded-lg"}),e.jsx(I,{className:"h-24 w-full rounded-lg"})]});if(!t)return e.jsx("p",{className:"text-sm text-muted-foreground",children:"This app isn't connected to this workspace, so its details aren't available."});const j=z[0],C=j?.details?.redirectUris??[],k=t.linkedUserEntitySlug?K(n,[{entity_type:"$member",slug:t.linkedUserEntitySlug}]):null,E=[{label:"Registered",value:t.title},{label:t.clientIds.length===1?"Client ID":"Client IDs",value:e.jsx("div",{className:"space-y-1",children:t.clientIds.map(a=>e.jsx("code",{className:"block break-all",children:a},a))})},...t.drivenBy&&t.drivenBy!==t.title?[{label:"Driven by",value:t.drivenBy}]:[],...j?.platform?[{label:"Software",value:j.platform}]:[],...C.length>0?[{label:"Redirects",value:C.join(", ")}]:[],{label:"Granted by",value:k&&t.linkedUser?e.jsx(b,{to:k,className:"font-medium text-primary hover:underline",children:t.linkedUser}):t.linkedUser??"—"},{label:"Last active",value:t.connected?G(t.lastSeenAt):"disconnected"},{label:"Registrations",value:String(t.clientIds.length)}];return e.jsxs("div",{className:"space-y-7",children:[e.jsx(f,{title:"Settings",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"overflow-hidden rounded-lg border text-xs",children:e.jsx("dl",{className:"divide-y",children:E.map(a=>e.jsxs("div",{className:"flex gap-3 px-3 py-2",children:[e.jsx("dt",{className:"w-28 shrink-0 text-muted-foreground",children:a.label}),e.jsx("dd",{className:"min-w-0 flex-1 break-words",children:a.value})]},a.label))})}),o&&t.connected?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Revoking disconnects every registration this app holds",t.clientIds.length>1?` (${t.clientIds.length} of them)`:""," ","and kills its live sessions. It can reconnect by authorizing again."]}),T?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"destructive",size:"sm",className:"h-7 px-2 text-xs",disabled:c.isPending,onClick:()=>c.mutate({clientId:t.clientIds[0],scope:"all"},{onSettled:()=>h(!1)}),children:c.isPending?"Revoking…":"Confirm revoke"}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:c.isPending,onClick:()=>h(!1),children:"Cancel"})]}):e.jsx(y,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs text-destructive hover:text-destructive",onClick:()=>h(!0),children:"Revoke"})]}):null]})}),e.jsx(f,{title:"Conversations",count:m.length>0?String(m.length):void 0,children:g.isLoading||p.isLoading?e.jsxs("div",{className:"flex items-center py-4 text-xs text-muted-foreground",children:[e.jsx(H,{className:"mr-2"})," Loading client activity…"]}):g.isError||p.isError?e.jsx("p",{className:"py-3 text-xs text-destructive",children:"Could not load this app's activity."}):m.length===0?e.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No recent conversations."}):e.jsx(L,{scopes:m,ownerSlug:n})}),v.length>0?e.jsx(f,{title:"Sessions",count:String(v.length),children:e.jsx(L,{scopes:v,ownerSlug:n})}):null]})}const ne="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function ae({owner:n,clientId:i}){const{data:l=[]}=B(null),r=u.useMemo(()=>P(l).find(s=>s.clientIds.includes(i)),[i,l])?.title??"Connected agent";return e.jsx("div",{className:ne,children:e.jsx(O,{header:e.jsx(Q,{breadcrumb:e.jsx(q,{crumbs:[e.jsx(b,{to:"/$owner/agents",params:{owner:n},className:W,children:"Agents"},"agents")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(V,{name:r})}),title:r,caption:"An external agent connected to this workspace through Lobu. Review its Lobu conversations, activity, and access."}),children:e.jsx(te,{ownerSlug:n,clientId:i},i)})})}function xe(){const{owner:n,clientId:i}=Z.useParams();return e.jsx(F,{owner:n,children:({ownerSlug:l})=>e.jsx(ae,{owner:l,clientId:i})})}export{xe as component};
|
|
2
|
-
//# sourceMappingURL=connected._clientId.index-C6qbqgwF.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{by as W,E as F,r as l,a2 as z,Q as R,j as e,aa as N,B as f,bz as V,bA as q,bB as B,bC as D,bD as E,I as M,x as Y,ab as G,ag as J,a4 as K,ad as H,J as Q}from"./index-4gCDI7m4.js";import{C as X,a as Z,b as ee,c as ne}from"./card-SFtxv9f2.js";const C="__new_org__";function te(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function w(r){return G.find(i=>i.provider===r)?.name??r}function re(r,i){return`${window.location.origin}/connector/${encodeURIComponent(r)}/connection?${new URLSearchParams({ref:i})}`}function ie(r,i){return r==="account_already_linked_to_different_user"?`This ${i} account belongs to a different Lobu account than the one you are signed in to. Sign out, then continue with ${i} to finish setup as that account.`:`We couldn’t verify your ${i} account for this setup. Sign out, then continue with ${i} to try again.`}function oe(r,i){const[s,n]=l.useState({}),o=i?`${i}:${r}`:null;return l.useEffect(()=>{if(!o||!i||o in s)return;let c=!1;return Y(i).then(h=>h.find(g=>g.key===r)?.name??null).catch(()=>null).then(h=>{c||n(g=>({...g,[o]:h}))}),()=>{c=!0}},[o,r,s,i]),o?s[o]??null:null}function I(r,i,s){if(!r)return"/";const n=`/${encodeURIComponent(r)}/`;if(s?.startsWith(n)){const o=new URL(s,window.location.origin);if(o.origin===window.location.origin&&o.pathname.startsWith(n))return o.pathname+o.search}return`${n}connectors/${encodeURIComponent(i)}?connected=1`}function se(r,i){return r==="not_admin"?`You must be an admin or owner to connect ${i} to Lobu.`:`You don't have permission to connect ${i} to Lobu.`}function T(r,i,s){switch(r){case"not_authorized":return se(i,s);case"no_pending":return`No Lobu install was found for ${s}. Add Lobu from the marketplace to get started.`;case"no_org":return`Your account has no Lobu organization to connect ${s} to.`;default:return`Something went wrong while connecting ${s}. Please try again.`}}function le(){const{name:r}=W({from:"/connector/$name/connection"}),{ref:i,error:s}=F({from:"/connector/$name/connection"}),[n,o]=l.useState({kind:"loading"}),[c,h]=l.useState(""),[g,O]=l.useState(""),[x,_]=l.useState(!1),[$,p]=l.useState(null),[j,k]=l.useState(null),u=oe(r,n.kind==="confirm"?n.orgs[0]?.slug??null:n.kind==="already_connected"?n.orgSlug:null),m=n.kind==="confirm"&&n.subjectKind||"connection",S=n.kind==="confirm"&&n.subjectName?n.subjectName:u?`this ${u} ${m}`:`this ${m}`,P=l.useCallback(async()=>{if(!i){o({kind:"error",message:"This connection link is missing its reference."});return}o({kind:"loading"});try{const t=await(await z(`${R}/api/connector/${encodeURIComponent(r)}/connection/claim-context?ref=${encodeURIComponent(i)}`,{credentials:"include"})).json();if("error"in t){if(t.error==="unauthenticated"){o({kind:"signin",signinProvider:t.signinProvider??r,linkAccount:!1});return}if(t.error==="signin_required"){o(s?{kind:"link_failed",signinProvider:t.signinProvider??r,error:s}:{kind:"signin",signinProvider:t.signinProvider??r,linkAccount:!0});return}o({kind:"error",message:T(t.error,t.code,"this connection")});return}if("alreadyConnected"in t){o({kind:"already_connected",orgSlug:t.orgSlug,nextUrl:t.nextUrl});return}h(t.orgs[0]?.slug??""),o({kind:"confirm",subjectKind:t.subjectKind,subjectName:t.subjectName,orgs:t.orgs})}catch{o({kind:"error",message:"We couldn’t load this connection link. Please try again."})}},[r,i,s]);l.useEffect(()=>{P()},[P]);const L=async d=>{if(!i)return;const t=re(r,i);if(n.kind==="signin"&&n.linkAccount){const y=await J.linkSocial({provider:d,callbackURL:t,errorCallbackURL:t});y.error&&o({kind:"error",message:y.error.message??"Couldn’t verify this account."});return}n.kind==="link_failed"&&await K(),await H.social({provider:d,callbackURL:t,errorCallbackURL:t})},U=async(d=!1)=>{if(!(!i||!c)){_(!0),p(null),k(null);try{let t=c;if(c===C){const b=g.trim();if(!b){p("Enter a name for the new organization.");return}const v=await Q.create({name:b,slug:te(b)});if(v.error||!v.data){p(v.error?.message??"Couldn’t create the organization.");return}t=v.data.slug}const a=await(await z(`${R}/api/connector/${encodeURIComponent(r)}/connection/claim`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({ref:i,org:t,confirmMove:d})})).json();if("error"in a){if(a.error==="signin_required"||a.error==="unauthenticated"){o({kind:"signin",signinProvider:a.signinProvider??r,linkAccount:a.error==="signin_required"});return}if((a.error==="already_connected_elsewhere"||a.error==="enterprise_scope_overlap")&&a.existing){k({kind:a.error,existing:a.existing});return}p(T(a.error,a.code,S));return}window.location.href=I(a.orgSlug,r,a.nextUrl)}catch{p(`Something went wrong while connecting this ${m}. Please try again.`)}finally{_(!1)}}},A=n.kind==="signin"?"Sign in to continue":n.kind==="link_failed"?"Use a different account":n.kind==="error"?`Can’t connect this ${m}`:n.kind==="already_connected"?"Already connected":u?`Connect ${u} to Lobu`:"Connect to Lobu";return e.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:e.jsx("div",{className:"w-full max-w-md p-8",children:e.jsxs(X,{children:[e.jsx(Z,{children:e.jsx(ee,{asChild:!0,children:e.jsx("h1",{children:A})})}),e.jsxs(ne,{children:[n.kind==="loading"&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground",children:[e.jsx(N,{size:"lg"}),e.jsx("span",{children:"Checking this connection link…"})]}),n.kind==="error"&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:n.message}),n.kind==="already_connected"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This ",u?`${u} `:"",m," is already connected to Lobu."]}),e.jsx(f,{className:"w-full",asChild:!0,children:e.jsx("a",{href:I(n.orgSlug,r,n.nextUrl),children:n.nextUrl?"Choose an agent":"Open Lobu"})})]}),n.kind==="signin"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sign in with ",w(n.signinProvider)," to verify you can connect this ",m,"."]}),e.jsxs(f,{className:"w-full",onClick:()=>L(n.signinProvider),children:["Sign in with ",w(n.signinProvider)]})]}),n.kind==="link_failed"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{role:"alert",className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:ie(n.error,w(n.signinProvider))}),e.jsxs(f,{className:"w-full",onClick:()=>L(n.signinProvider),children:["Sign out and continue with"," ",w(n.signinProvider)]})]}),n.kind==="confirm"&&(()=>{const d=n.subjectName||S;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Connecting"," ",e.jsx("strong",{className:"font-medium text-foreground",children:d}),". Choose the organization to connect it to:"]}),e.jsxs(V,{value:c,onValueChange:t=>{k(null),h(t)},children:[e.jsx(q,{children:e.jsx(B,{placeholder:"Select an organization"})}),e.jsxs(D,{children:[n.orgs.map(t=>e.jsxs(E,{value:t.slug,children:[t.name,t.isPersonal&&e.jsx("span",{className:"ml-1 text-muted-foreground",children:"(personal)"})]},t.id)),e.jsx(E,{value:C,children:"+ New organization"})]})]}),c===C&&e.jsx(M,{autoFocus:!0,value:g,onChange:t=>O(t.target.value),placeholder:"New organization name","aria-label":"New organization name"}),$&&e.jsx("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:$}),j&&(()=>{const t=j.existing.orgName??j.existing.orgSlug??"another organization";return j.kind==="already_connected_elsewhere"?e.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-muted/40 px-3 py-3",children:[e.jsxs("p",{className:"text-sm text-foreground",children:[d," is already connected in"," ",e.jsx("strong",{className:"font-medium",children:t}),". Move it here?"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{className:"flex-1",onClick:()=>U(!0),disabled:x,children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Moving…"})]}):"Move it here"}),e.jsx(f,{className:"flex-1",variant:"outline",onClick:()=>k(null),disabled:x,children:"Cancel"})]})]}):e.jsxs("div",{className:"rounded-lg bg-destructive/10 px-3 py-2 text-sm text-destructive",children:["This ",u?`${u} `:"","Enterprise Grid is already connected in"," ",e.jsx("strong",{className:"font-medium",children:t}),"; ","connecting this ",m," here may change how its messages route. Contact support to move it."]})})(),e.jsx(f,{className:"w-full",onClick:()=>U(),disabled:x||j!==null||!c||c===C&&!g.trim(),children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:"lg"}),e.jsx("span",{className:"ml-2",children:"Connecting…"})]}):`Connect ${d}`})]})})()]})]})})})}export{le as component};
|
|
2
|
-
//# sourceMappingURL=connection-88YzIBK9.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,dx as m,dz as u,dy as h,$ as v,V as x,L as c}from"./index-4gCDI7m4.js";function N({connectorDef:s,connectorKey:t,ownerSlug:n,deviceWorkerId:i,deviceLabel:o}){return s?e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1.5 text-[11.5px] text-muted-foreground",children:[e.jsx("span",{children:"Runs on"}),e.jsx(c,{to:"/$owner/connectors/$connectorKey",params:{owner:n,connectorKey:t},className:"underline underline-offset-2 hover:text-foreground",children:s.name}),e.jsx(f,{deviceWorkerId:i,deviceLabel:o,connectorDef:s,ownerSlug:n})]}):null}function f({connectorDef:s,ownerSlug:t,deviceWorkerId:n,deviceLabel:i}){return e.jsxs(m,{children:[e.jsxs(u,{className:"rounded border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground transition-colors hover:border-muted-foreground hover:text-foreground",children:["v",s.version||"unknown"]}),e.jsx(h,{align:"start",className:"w-80 p-0",children:e.jsx(j,{connectorDef:s,ownerSlug:t,deviceWorkerId:n,deviceLabel:i})})]})}function j({connectorDef:s,ownerSlug:t,deviceWorkerId:n,deviceLabel:i}){const o=s.runtime?.platforms??[],d=s.runtime?.scopes??[],r=s.source_uri?.trim()||null,p=!!r&&(r.startsWith("http://")||r.startsWith("https://")),l=[{label:"Key",value:e.jsx("span",{className:"font-mono",children:s.key})},{label:"Version",value:e.jsx("span",{className:"font-mono",children:s.version?`v${s.version}`:"unknown"})}];return s.catalog_origin&&l.push({label:"Origin",value:s.catalog_origin==="org"?e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"Built in this workspace"}):e.jsx("span",{children:"Lobu catalog"})}),r&&l.push({label:"Source",value:p?e.jsxs("a",{href:r,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full items-start gap-1 break-all font-mono text-primary hover:underline",children:[r,e.jsx(v,{className:"mt-0.5 h-3 w-3 shrink-0"})]}):e.jsx("span",{className:"break-all font-mono",children:r})}),o.length>0&&l.push({label:"Platforms",value:e.jsx("span",{className:"flex flex-wrap gap-1",children:o.map(a=>e.jsx(x,{variant:"secondary",className:"h-4 px-1 py-0 font-mono text-[10px]",children:a},a))})}),s.required_capability&&l.push({label:"Capability",value:e.jsx("span",{className:"font-mono",children:s.required_capability})}),d.length>0&&l.push({label:"Scopes",value:e.jsx("span",{className:"flex flex-wrap gap-1",children:d.map(a=>e.jsx(x,{variant:"secondary",className:"h-4 px-1 py-0 font-mono text-[10px]",children:a},a))})}),e.jsxs("div",{className:"text-xs",children:[e.jsx("dl",{className:"divide-y",children:l.map(a=>e.jsxs("div",{className:"flex gap-3 px-3 py-2",children:[e.jsx("dt",{className:"w-20 shrink-0 text-muted-foreground",children:a.label}),e.jsx("dd",{className:"min-w-0 flex-1",children:a.value})]},a.label))}),o.length>0?e.jsx("div",{className:"border-t px-3 py-2 text-muted-foreground",children:n?e.jsxs(e.Fragment,{children:["Runs on"," ",e.jsx(c,{to:"/$owner/connectors/device/$deviceId",params:{owner:t,deviceId:n},className:"text-primary hover:underline",children:i||"this device"}),"."]}):"Runs on a linked device."}):null]})}export{f as C,N as a};
|
|
2
|
-
//# sourceMappingURL=connector-provenance-Th8ymGec.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,O as l}from"./index-4gCDI7m4.js";function n(){return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6",children:e.jsx("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:e.jsx(l,{})})})}export{n as component};
|
|
2
|
-
//# sourceMappingURL=connectors-BqwgLUUK.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{T as D,o as F,r,j as e,B as q,Q as H,U as Q}from"./index-4gCDI7m4.js";import{u as G,b as J,a as K,s as V,g as X,A as U,W as Y}from"./oauth-workspace-access-D9BNmyMY.js";import{C as Z,a as ee,b as se,c as te}from"./card-SFtxv9f2.js";const re=["client_id","redirect_uri","scope","code_challenge","code_challenge_method"];function ae(){const s=D.useSearch(),g=s.workspace_grants==="1",{session:v,isReady:O}=F(),A=!O,{orgList:x,workspaceAccess:E,setWorkspaceAccess:W,selectedOrgIds:c,toggleSelectedOrgId:z,orgsLoading:$,orgsError:k,retryOrgs:I,workspaceSelectionReady:S}=G({allowMultiple:g}),[n,N]=r.useState(null),[C,u]=r.useState(null);J(!!v,A);const f=r.useMemo(()=>re.filter(t=>!s[t]||s[t]?.length===0),[s]),i=f.length===0,R=s.client_name?.trim()||null,l=r.useMemo(()=>Array.from(new Set((s.scope||"").split(" ").map(t=>t.trim()).filter(Boolean))),[s.scope]),w=K(l),[d,y]=r.useState(w);r.useEffect(()=>{y(w)},[w]);const m=r.useMemo(()=>V(l,d),[d,l]),M=r.useMemo(()=>m.some(t=>t.startsWith("mcp:")),[m]),j=d,b=r.useMemo(()=>X(s.resource),[s.resource]),o=M&&!b,h=r.useMemo(()=>x.filter(t=>c.includes(t.id)).map(t=>t.name),[x,c]),_=o?h.length===0?"Nothing will be granted access.":`${h.length<=2?h.join(", "):`${h.length} workspaces`} will be granted access.`:null,T=n==="approve"?"Approving...":o&&g&&c.length>0?`Approve ${c.length} ${c.length===1?"workspace":"workspaces"}`:"Approve",B=()=>{const t=new URL("/auth/login",window.location.origin);t.searchParams.set("callbackUrl",window.location.href),window.location.href=t.toString()},L=async t=>{if(!i){u(`Missing required query params: ${f.join(", ")}`);return}if(t&&o&&!S){u(k?"Workspaces could not be loaded. Retry before approving.":"Choose at least one workspace before approving.");return}N(t?"approve":"deny"),u(null);try{const a=await fetch(`${H}/oauth/authorize/consent`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({client_id:s.client_id,redirect_uri:s.redirect_uri,scope:t?m.join(" "):s.scope,state:s.state??"",code_challenge:s.code_challenge,code_challenge_method:s.code_challenge_method,client_name:s.client_name,resource:s.resource,authorization_intent:s.authorization_intent,approved:t,...t&&o?{workspace_access:E,organization_ids:c}:{}})}),p=await a.json().catch(()=>null);if(a.status===401){B();return}if(!a.ok)throw new Error(p?.error_description||p?.message||p?.error||`Failed to ${t?"approve":"deny"} OAuth consent`);const P=Q(p?.redirect_url);if(!P)throw new Error("Consent response did not include a valid redirect URL");window.location.href=P}catch(a){N(null),u(a instanceof Error?a.message:"Unexpected error while submitting consent")}};return A||!v?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking authentication..."})}):e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(Z,{className:o?"w-full max-w-4xl":"w-full max-w-lg",children:[e.jsx(ee,{children:e.jsx(se,{asChild:!0,children:e.jsx("h1",{children:"Authorize application"})})}),e.jsxs(te,{className:"space-y-5","aria-busy":n!==null,children:[o?e.jsxs("div",{className:"grid gap-6 md:grid-cols-[minmax(0,1fr)_300px]",children:[e.jsx("div",{className:"min-w-0",children:e.jsx(U,{idPrefix:"oauth-consent",clientName:R,requestedScopes:l,accessLevel:d,onAccessLevelChange:y,disabled:n!==null,resource:s.resource,logoUri:s.logo_uri,clientUri:s.client_uri})}),e.jsx("div",{className:"min-w-0",children:e.jsx(Y,{idPrefix:"oauth-consent",allowMultiple:g,orgList:x,selectedOrgIds:c,onWorkspaceAccessChange:W,onSelectedOrgChange:z,orgsLoading:$,orgsError:k,onRetry:I,disabled:n!==null||!i})})]}):e.jsx(U,{idPrefix:"oauth-consent",clientName:R,requestedScopes:l,accessLevel:d,onAccessLevelChange:y,disabled:n!==null,resource:s.resource,logoUri:s.logo_uri,clientUri:s.client_uri}),M&&b&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-2",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",b]}),e.jsxs("ul",{className:"space-y-1 text-muted-foreground",children:[e.jsx("li",{children:"If this workspace is public, the app can read public data immediately after approval."}),j==="write"&&e.jsx("li",{children:"If you are not already a member, this connection will stay read-only. Ask an organization admin to grant write access, then reconnect the MCP client."}),j==="admin"&&e.jsx("li",{children:"If you are not already an admin or owner, elevated actions will stay blocked. Ask an organization owner to grant the required role, then reconnect the MCP client."}),j==="read"&&e.jsx("li",{children:"Public read access does not require membership."})]})]}),C&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:C}),!i&&e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:["Missing required query params: ",f.join(", ")]}),e.jsxs("div",{className:`flex flex-wrap items-center gap-3 ${_?"justify-between":"justify-end"} border-t pt-4`,children:[_&&e.jsx("p",{className:"text-sm text-muted-foreground",children:_}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{type:"button",variant:"outline",onClick:()=>L(!1),disabled:n!==null||!i,children:n==="deny"?"Denying...":"Deny"}),e.jsx(q,{type:"button",onClick:()=>L(!0),disabled:n!==null||!i||m.length===0||o&&!S,children:T})]})]})]})]})})}export{ae as component};
|
|
2
|
-
//# sourceMappingURL=consent-BR5U7dwb.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as s,j as a,B as p,du as n,eY as d,bT as i}from"./index-4gCDI7m4.js";function m({text:u,label:o,iconOnly:e=!1}){const[r,c]=s.useState(!1),t=s.useRef(void 0);return s.useEffect(()=>()=>clearTimeout(t.current),[]),a.jsxs(p,{type:"button",variant:e?"ghost":"outline",size:e?"icon":"sm",className:e?"h-6 w-6 shrink-0":"h-8 text-xs","aria-label":e?`Copy ${o}`:void 0,onClick:async()=>{try{await navigator.clipboard.writeText(u),c(!0),i.success("Copied to clipboard"),clearTimeout(t.current),t.current=setTimeout(()=>c(!1),1500)}catch{i.error("Could not copy. Please select and copy the text.")}},children:[r?a.jsx(n,{className:"h-3.5 w-3.5"}):a.jsx(d,{className:"h-3.5 w-3.5"}),!e&&(r?"Copied":o)]})}export{m as C};
|
|
2
|
-
//# sourceMappingURL=copy-button-2swYh4jb.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as n,aA as t,O as c,aI as r,aL as i,gk as l,b5 as m,gl as x,L as d,gm as u,gn as C,fg as g}from"./index-4gCDI7m4.js";function p({owner:a,initialConnectorKey:e}){return n.jsx(t,{owner:a,children:o=>n.jsx(j,{ownerSlug:o.ownerSlug,organizationId:o.organizationId,initialConnectorKey:e})})}function j({ownerSlug:a,organizationId:e,initialConnectorKey:o}){const{data:s=[]}=r(e??"");return n.jsxs(i,{className:"flex flex-1 flex-col gap-6",children:[n.jsx(l,{breadcrumb:n.jsx(x,{crumbs:[n.jsx(d,{to:"/$owner/connectors",params:{owner:a},search:{},className:u,children:"Connectors"},"connectors")]}),icon:n.jsx(m.connectors.icon,{className:"h-6 w-6"}),title:"Add a connection",caption:"Pick a connector from the catalog or drop in an MCP URL — Lobu handles auth and brings the data into memory."}),e?n.jsx(C,{ownerSlug:a,organizationId:e,connections:s,initialConnectorKey:o},o??"catalog"):n.jsx("div",{className:"max-w-3xl",children:n.jsx(g,{rows:4})})]})}const f=()=>n.jsx(c,{});export{p as ConnectionsCreateRouteContent,f as component};
|
|
2
|
-
//# sourceMappingURL=create-BsPVnRpG.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iT as r,j as e}from"./index-4gCDI7m4.js";import{a as i}from"./agent-skills-route-DFXr_bHp.js";import"./agent-skill-context-V__2i6Vl.js";import"./core.esm-CHnfRiEM.js";import"./skill-editor-D_W3QlRz.js";import"./agent-subpage-shell-DWzljvFb.js";import"./agent-loading-shells-Dnmb6W5Y.js";import"./agent-card-controls-99mG6H5k.js";function x(){const{owner:t,agentId:o}=r.useParams();return e.jsx(i,{owner:t,agentId:o})}export{x as component};
|
|
2
|
-
//# sourceMappingURL=create-CVPYVOR5.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iV as o,j as e}from"./index-4gCDI7m4.js";import{a}from"./agent-guardrails-route-BvGgfd-h.js";import"./model-selector-88PJnyTq.js";import"./agent-subpage-shell-DWzljvFb.js";import"./table-DFcJRNk7.js";import"./agent-loading-shells-Dnmb6W5Y.js";import"./agent-card-controls-99mG6H5k.js";function x(){const{owner:r,agentId:t}=o.useParams();return e.jsx(a,{owner:r,agentId:t})}export{x as component};
|
|
2
|
-
//# sourceMappingURL=create-QFjmhOEU.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as i,j as e,bz as ae,bA as oe,bB as ie,bC as ce,bD as D,I as ne,B as G,X as ns,aI as _s,aC as Ns,k as as,gV as bs,gW as ks,S as Dt,H as k,h as $,d9 as Ie,ev as Tt,dH as Ss,dJ as ws,fV as Cs,cB as os,dN as Es,f7 as Fs,g0 as Mt,gX as As,eI as at,cN as Ke,du as nt,eK as _t,be as is,c_ as Ge,cI as Os,a2 as Ds,Q as Ts,aJ as Ms,gY as Ps,gZ as Ls,g_ as Rs,g$ as $s,h0 as Is,V as qs,L as Ks,t as cs,gT as Bs,bd as Ws,aH as Vs,ff as Pt,gt as zs,h1 as Us,c9 as Qs,ep as Js,bK as vt,aa as Gs,h2 as Hs,eY as Ys,h3 as Xs,h4 as Zs,bJ as en}from"./index-4gCDI7m4.js";import{c as tn}from"./cronstrue-CKwjNYgj.js";import{C as sn,f as nn}from"./entity-options-BSW_EG0W.js";import{c as an,d as on,e as cn,f as rn,g as ln,u as dn}from"./use-automations-BHoV0dLs.js";import{M as un}from"./model-selector-88PJnyTq.js";import{b as mn}from"./skill-editor-D_W3QlRz.js";import{C as yt}from"./code-editor-rX0t1g5C.js";import{u as hn,b as Lt,c as Rt,s as xn,o as gn,M as pn,d as fn,e as vn,f as yn,v as jn,r as _n}from"./use-mention-search-C3rWLuKm.js";const tt=[{value:"*/15 * * * *",label:"Every 15 minutes"},{value:"0 * * * *",label:"Every hour"},{value:"0 */6 * * *",label:"Every 6 hours"},{value:"0 9 * * *",label:"Daily at 9:00 AM"},{value:"0 18 * * *",label:"Daily at 6:00 PM"},{value:"0 9 * * 1-5",label:"Weekdays at 9:00 AM"},{value:"0 9 * * 1",label:"Weekly · Monday 9:00 AM"},{value:"0 9 1 * *",label:"Monthly · 1st at 9:00 AM"},{value:"custom",label:"Custom cron…"}];function Nn(s){const t=s.trim();if(!t)return null;try{return tn.toString(t,{throwExceptionOnParseError:!0})}catch{return null}}function bn({value:s,onChange:t,placeholder:n="No schedule",className:c}){const d=s??"",u=tt.some(f=>f.value===d),[r,a]=i.useState(!u&&d!==""),g=f=>{f==="custom"?a(!0):(a(!1),t(f))},j=d?Nn(d):null,h=d?e.jsx("p",{className:j?"text-xs text-muted-foreground":"text-xs text-destructive",children:j??"Not a valid cron expression."}):null;return!d&&!r?e.jsxs(ae,{onValueChange:g,children:[e.jsx(oe,{className:c??"w-full",children:e.jsx(ie,{placeholder:n})}),e.jsx(ce,{children:tt.map(f=>e.jsxs(D,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[r?e.jsx(ne,{placeholder:"0 */6 * * *",value:d,onChange:f=>t(f.target.value),className:"font-mono text-sm flex-1"}):e.jsxs(ae,{value:d,onValueChange:g,children:[e.jsx(oe,{className:c??"w-full flex-1",children:e.jsx(ie,{children:tt.find(f=>f.value===d)?.label??d})}),e.jsx(ce,{children:tt.map(f=>e.jsxs(D,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>{a(!1),t("")},children:e.jsx(ns,{className:"h-4 w-4"})})]}),h]})}const mt="__all_workspace_event_types__",kn=[],Sn={};function $t(s,t,n){const c=new Map;if(!t)for(const[u,r]of Object.entries(n??{}))c.set(u,{key:u,label:Mt(u),description:r.description});const d=[...s].filter(u=>!t||u.slug===t).sort((u,r)=>u.slug.localeCompare(r.slug));for(const u of d)for(const[r,a]of Object.entries(u.event_kinds??{})){const g=c.get(r);if(g){!g.description&&a.description&&(g.description=a.description),JSON.stringify(g.metadataSchema??null)!==JSON.stringify(a.metadataSchema??null)&&(g.metadataSchema=void 0);continue}c.set(r,{key:r,label:Mt(r),description:a.description,metadataSchema:a.metadataSchema})}return[...c.values()].sort((u,r)=>u.label.localeCompare(r.label))}function It(s){const t=s[0];if(!t)return;const n=d=>JSON.stringify(Object.keys(d?.properties??{}).sort()),c=n(t);return s.every(d=>n(d)===c)?t:void 0}function qt(s,t,n){const c=new Set(Object.keys(t.properties??{}));return{...Object.fromEntries(Object.entries(s).filter(([d])=>!c.has(d))),...n}}function $e(s,t,n){return n==="steer"&&(s==="window"||t!=="reply_to_source")?"coalesce":n}function Qe(s,t){return s==="window"?"silent":t}function Kt(s){return Object.fromEntries(Object.entries(s).filter(([t])=>t==="resource_ref"||t==="resource_type"))}function Bt(s,t,n){const c=new Set(Object.keys(t?.properties??{})),d=new Set(n.flatMap(u=>Object.keys(u.filterSchema?.properties??{})));return Object.fromEntries(Object.entries(As(s)).filter(([u])=>u==="resource_ref"||u==="resource_type"||!d.has(u)||c.has(u)))}function wn({value:s,options:t,onChange:n}){return e.jsx("div",{className:"inline-flex rounded-md border bg-muted/30 p-0.5 text-sm",children:t.map(c=>e.jsx("button",{type:"button","aria-pressed":s===c.value,onClick:()=>n(c.value),className:$("rounded px-3 py-1 transition-colors",s===c.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:c.label},c.value))})}function Wt({events:s,selectedKeys:t,onToggle:n,ariaLabel:c="Events"}){const d=i.useId(),u=s.filter(a=>t.includes(a.key)).map(a=>a.label),r=u.length===0?"Choose events":u.length===1?u[0]:`${u.length} events selected`;return e.jsx(at,{contentClassName:"w-[var(--radix-popover-trigger-width)] min-w-[280px]",searchPlaceholder:"Filter events...",emptyText:"No events found.",trigger:a=>e.jsxs(G,{type:"button",variant:"outline",role:"combobox","aria-label":c,"aria-expanded":a,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:$(u.length===0&&"text-muted-foreground"),children:r}),e.jsx(_t,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>s.map((a,g)=>{const j=t.includes(a.key),h=`${d}-${g}-state`;return e.jsxs(Ke,{value:`${a.label} ${a.key}`,onSelect:()=>n(a.key),"aria-label":a.label,"aria-describedby":h,className:"cursor-pointer",children:[e.jsx(nt,{className:$("mr-2 h-4 w-4",j?"opacity-100":"opacity-0")}),a.label,e.jsx("span",{id:h,className:"sr-only",children:j?"Selected":"Not selected"})]},a.key)})})}function Cn({organizationId:s,initialTrigger:t,onChange:n,allowedKinds:c,showSectionHeader:d=!0,fieldIdPrefix:u="automation-trigger-"}){const r=_s(s,{status:"active",limit:500}),a=Ns(s),g=as({organizationId:s}),j=bs({organizationId:s}),h=r.data??[],f=a.data??[],I=g.data??kn,x=j.data??Sn,_=i.useMemo(()=>I.filter(l=>l.organization_id===s),[I,s]),v=t?.kind==="event"&&t?.source==="workspace",M=v||t===void 0,w=c?.length?[...c]:["event","time","manual"],b=w.join("|"),O=(()=>{const l=t===null?"manual":t?.kind==="schedule"?"time":"event";return w.includes(l)?l:w[0]??"event"})(),[N,me]=i.useState(O),[K,he]=i.useState(v?"workspace":typeof t?.connection_id=="number"?String(t.connection_id):t?.kind==="event"&&t.connector_key?"":"workspace"),S=K==="workspace",H=S?"":K,[m,z]=i.useState(typeof t?.entity_type=="string"?t.entity_type:""),je=i.useMemo(()=>Array.isArray(t?.event_types)?t.event_types:[],[t]),[C,_e]=i.useState(()=>je.filter(l=>typeof l=="string")),[P,xe]=i.useState(t?.match&&typeof t.match=="object"&&!Array.isArray(t.match)?t.match:{}),[re,De]=i.useState(typeof t?.cron=="string"?t.cron:"0 9 * * 1-5"),le=typeof t?.timezone=="string"?t.timezone:void 0,[B,ge]=i.useState(t?.kind==="schedule"||M&&t?.execution!=="turn"||t?.execution==="window"?"window":"turn"),[Q,de]=i.useState(Qe(B,t?.output==="reply_to_source"?"reply_to_source":"silent")),[Y,X]=i.useState(t?.kind==="schedule"||M&&t?.active_run!=="queue"?"coalesce":$e(B,Q,t?.active_run==="coalesce"||t?.active_run==="steer"?t.active_run:"queue")),[pe,Be]=i.useState(t?.skip_if_unchanged!==!1),[Se,Fe]=i.useState(!1);i.useEffect(()=>{const l=b.split("|");if(!l.includes(N)){const y=l[0]??"event";me(y),ge(y==="time"||y==="event"&&S?"window":"turn"),X(y==="time"||y==="event"&&S?"coalesce":"queue"),de("silent")}},[b,N,S]);const Z=h.find(l=>String(l.id)===H),p=r.isLoading||a.isLoading,ue=g.isLoading,U=typeof t?.connector_key=="string"?t.connector_key:void 0,L=N==="event"&&!S&&t?.kind==="event"&&t?.source!=="workspace"&&typeof t.connection_id=="number"&&String(t.connection_id)===H&&!Z,W=N==="event"&&!S&&t?.kind==="event"&&t?.source!=="workspace"&&t.connection_id==null&&U!==void 0&&H==="",Ae=f.find(l=>l.key===(Z?.connector_key??(W?U:void 0))),fe=Ae?.automation_events??[],we=fe.filter(l=>C.includes(l.key)),T=we[0],Oe=_.find(l=>l.slug===m),We=[..._.filter(l=>Object.keys(l.event_kinds??{}).length>0||l.slug===m),...m&&!Oe?[{slug:m,name:m}]:[]],ee=i.useMemo(()=>$t(_,m||void 0,x),[_,m,x]),Te=ee.filter(l=>C.includes(l.key)),Me=Te[0],Ne=It(we.map(l=>l.filterSchema)),ve=It(Te.map(l=>l.metadataSchema)),be=!!(S&&m&&!Oe),Pe=L||W,Ce=(N==="event"?S?C.length>0&&!be:!!(C.length>0&&(H&&Z||Pe)):N==="time"?!!re.trim():!0)&&(N!=="event"||!ks(P));i.useEffect(()=>{let l;if(Ce&&N==="event"&&!S){const y=Bt(P,Ne,Ae?.automation_events??[]);Z||W?l={kind:"event",source:"connector",connector_key:Z?.connector_key??U,...Z?{connection_id:Number(H)}:{},event_types:C,...Object.keys(y).length>0?{match:y}:{},execution:B,active_run:$e(B,Q,Y),output:Qe(B,Q),skip_if_unchanged:pe}:L&&(l=t?{...t,source:"connector"}:void 0)}else if(Ce&&N==="event"&&S){const y=Bt(P,ve,ee.map(F=>({filterSchema:F.metadataSchema})));l={kind:"event",source:"workspace",...m?{entity_type:m}:{},event_types:C,...Object.keys(y).length>0?{match:y}:{},execution:B,active_run:Y==="queue"?"queue":"coalesce"}}else Ce&&N==="time"&&(l={kind:"schedule",cron:re.trim(),...le?{timezone:le}:{},execution:"window",active_run:"coalesce",skip_if_unchanged:pe});n({ready:Ce,kind:N,trigger:l})},[Y,H,Z,re,Ae,C,B,P,N,U,le,t,S,n,Q,Ce,Ne,ve,pe,m,ee,W,L]);const Ye=l=>{const y=h.find(E=>String(E.id)===l),F=f.find(E=>E.key===y?.connector_key),se=C.filter(E=>F?.automation_events?.some(Le=>Le.key===E)),te=F?.automation_events?.find(E=>E.key===se[0]),q=y?.connector_key!==(Z?.connector_key??U);if(he(l),_e(se),!te)xe(Kt);else if(q){const E=te.defaults?.execution??"turn",Le=te.defaults?.activeRun??"queue",Ue=Qe(E,te.defaults?.output??"silent");xe(Kt),ge(E),X($e(E,Ue,Le)),de(Ue)}},it=l=>{if(l==="workspace"){he("workspace"),_e(y=>y.filter(F=>ee.some(se=>se.key===F))),xe({}),ge("window"),X("coalesce"),de("silent");return}Ye(l)},ct=l=>{const y=C.includes(l)?C.filter(E=>E!==l):fe.map(E=>E.key).filter(E=>E===l||C.includes(E));if(_e(y),y[0]===C[0])return;const F=fe.find(E=>E.key===y[0]),se=F?.defaults?.execution??"turn",te=F?.defaults?.activeRun??"queue",q=Qe(se,F?.defaults?.output??"silent");ge(se),X($e(se,q,te)),de(q)},Ve=l=>{const y=l===mt?"":l,F=_.find(te=>te.slug===y),se=$t(_,F?.slug,x);z(y),_e(te=>te.filter(q=>se.some(E=>E.key===q))),xe({})},Xe=l=>{_e(y=>y.includes(l)?y.filter(F=>F!==l):ee.map(F=>F.key).filter(F=>F===l||y.includes(F)))},ze=[{value:"event",label:"Event"},{value:"time",label:"Schedule"},{value:"manual",label:"Manual"}].filter(l=>w.includes(l.value));return e.jsxs("div",{className:"space-y-4",children:[d?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"When"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose what starts this Automation. Its goal and context stay reusable."})]}):null,ze.length>1?e.jsx(wn,{value:N,options:ze,onChange:l=>{me(l),ge(l==="time"||l==="event"&&S?"window":"turn"),X(l==="time"||l==="event"&&S?"coalesce":"queue"),de("silent")}}):null,N==="event"?p||S&&ue?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Dt,{className:"h-9 w-full"}),e.jsx(Dt,{className:"h-9 w-full"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Source"}),e.jsx(sn,{connections:h,value:K,onValueChange:it,disabled:Pe,includeWorkspaceEvents:!0,ariaLabel:"Source",placeholder:"Choose a source"}),L?e.jsx("p",{className:"text-xs text-muted-foreground",children:"This shared connection is managed outside this organization. Other Automation fields can still be edited."}):W?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This Automation listens across all"," ",String(t?.connector_key)," connections. Other Automation fields can still be edited."]}):null]}),S?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:ee.length>1?"Events":"Event"}),ee.length>0?e.jsx(Wt,{events:ee,selectedKeys:C,onToggle:Xe}):e.jsx("div",{className:$(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:m?"This entity type has no declared Automation events.":"This workspace has no declared Automation events."}),Me?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:Me.description}):null,be?e.jsxs("p",{className:"text-xs text-destructive",children:["This trigger filters on entity type “",m,"”, which no longer exists in this workspace. Clear the Entity type filter under Trigger options to save."]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only declared Automation outputs in the current workspace can trigger this Automation. Ordinary saved events remain data."})]}),ve?e.jsx(Tt,{schema:ve,values:P,onValuesChange:l=>xe(y=>qt(y,ve,l)),fieldIdPrefix:`${u}workspace-`},`${m||"workspace"}:${C.join(",")}`):null]}):Z||W?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:fe.length>1?"Events":"Event"}),fe.length?e.jsx(Wt,{events:fe,selectedKeys:C,onToggle:ct}):e.jsx("div",{className:$(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"This connector has not published subscribable events."}),T?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:T.description}):null]}),typeof P.resource_ref=="string"||Ne?e.jsxs("div",{className:"space-y-3",children:[typeof P.resource_ref=="string"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Resource"}),e.jsx("div",{className:$(Ie,"px-3 py-2 text-sm"),children:P.resource_ref})]}):null,Ne?e.jsx(Tt,{schema:Ne,values:P,onValuesChange:l=>xe(y=>qt(y,Ne,l)),fieldIdPrefix:u},C.join(",")):null]}):null]}):K?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose workspace events or a connected app as the source."})]}):N==="time"?e.jsx(bn,{value:re,onChange:De}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this Automation explicitly from Lobu, the API, CLI, or MCP."}),N!=="manual"&&!Pe?e.jsxs(Ss,{open:Se,onOpenChange:Fe,children:[e.jsx(ws,{asChild:!0,children:e.jsxs(G,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 py-1 text-muted-foreground hover:bg-transparent hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Cs,{className:"h-4 w-4"}),"Trigger options",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",B==="turn"?"Each event":"Window"," ·"," ",N==="time"?"Combine":S?Y==="queue"?"Queue":"Combine":Y==="queue"?"Queue":Y==="coalesce"?"Combine":"Update current run",N==="event"&&!S?` · ${B==="turn"&&Q==="reply_to_source"?"Reply":"Save in Lobu"}`:""]})]}),e.jsx(os,{className:$("h-4 w-4 transition-transform",Se&&"rotate-180")})]})}),e.jsxs(Es,{className:"space-y-4 pt-3",children:[N==="event"&&S?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Entity type filter"}),e.jsxs(ae,{value:m||mt,onValueChange:Ve,children:[e.jsx(oe,{"aria-label":"Entity type filter",children:e.jsx(ie,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:mt,children:"All event types"}),We.map(l=>e.jsx(D,{value:l.slug,children:l.name},l.slug))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Limit selected events to outputs linked to this entity type."})]}):null,N==="event"?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Run"}),e.jsxs(ae,{value:B,onValueChange:l=>{const y=l,F=Qe(y,Q);ge(y),de(F),X($e(y,F,Y))},children:[e.jsx(oe,{children:e.jsx(ie,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:"turn",children:"Start a run for each event"}),e.jsx(D,{value:"window",children:"Batch events into a window"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"When busy"}),e.jsxs(ae,{value:Y,onValueChange:l=>X(l),children:[e.jsx(oe,{children:e.jsx(ie,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:"queue",children:"Queue"}),e.jsx(D,{value:"coalesce",children:"Combine waiting events"}),!S&&B==="turn"&&Q==="reply_to_source"&&T?.capabilities?.steering?e.jsx(D,{value:"steer",children:"Update the current run"}):null]})]})]})]}):null,B==="window"&&(N==="time"||!S)?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Skip unchanged windows"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No source changes means no agent run or LLM call."})]}),e.jsx(Fs,{"aria-label":"Skip unchanged windows",checked:pe,onCheckedChange:Be})]}):null,N==="event"&&!S&&B==="turn"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Result"}),e.jsxs(ae,{value:Q,onValueChange:l=>{const y=l;de(y),X($e(B,y,Y))},children:[e.jsx(oe,{children:e.jsx(ie,{})}),e.jsxs(ce,{children:[T?.capabilities?.replyToSource?e.jsx(D,{value:"reply_to_source",children:"Reply where it happened"}):null,e.jsx(D,{value:"silent",children:"Save in Lobu"})]})]}),T?.capabilities?.replyToSource?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Messages matching this trigger run the Automation; anything else in the conversation stays with the connected agent."}):null]}):null]})]}):null]})}const En=16;function qe(){return crypto.randomUUID()}function Fn(s){return s===void 0?[{key:qe(),initial:void 0}]:s.length===0?[{key:qe(),initial:null}]:s.map(t=>({key:qe(),initial:t}))}function rs(s){return s?s.kind==="time"||s.trigger?.kind==="schedule":!1}function An(s,t){return s?s.ready===t.ready&&s.kind===t.kind&&JSON.stringify(s.trigger)===JSON.stringify(t.trigger):!1}function On(s,t){const n=s.map(a=>t[a.key]??{ready:!1,kind:"event"});if(!(s.length>1)&&n[0]?.kind==="manual")return{ready:n[0].ready,triggers:[]};const d=n.filter(rs).length;return{ready:!n.some(a=>a.kind==="manual")&&d<=1&&n.length>0&&n.every(a=>a.ready&&a.trigger),triggers:n.filter(a=>a.trigger).map(a=>a.trigger)}}function ua({organizationId:s,initialTriggers:t,onChange:n}){const c=i.useId(),[d,u]=i.useState(()=>Fn(t)),[r,a]=i.useState({}),g=i.useRef("");i.useEffect(()=>{const x=On(d,r),_=JSON.stringify(x);_!==g.current&&(g.current=_,n(x))},[d,r,n]);const j=d.find(x=>rs(r[x.key]))?.key??d.find(x=>x.initial&&typeof x.initial=="object"&&x.initial.kind==="schedule"&&!r[x.key])?.key??null,h=i.useCallback((x,_)=>{a(v=>An(v[x],_)?v:{...v,[x]:_})},[]),f=()=>{const x=d[0],_=x?r[x.key]:void 0;if(d.length===1&&(_?.kind==="manual"||x?.initial===null)){const v=qe();a({}),u([{key:v,initial:void 0}]);return}u(v=>[...v,{key:qe(),initial:void 0}])},I=x=>{if(d.length<=1){const _=qe();a({}),u([{key:_,initial:null}]);return}a(_=>{const v={..._};return delete v[x],v}),u(_=>_.filter(v=>v.key!==x))};return e.jsxs("section",{className:"space-y-4","aria-labelledby":`${c}-heading`,children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{id:`${c}-heading`,className:"text-sm font-medium",children:"When"}),d.length>1?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Each trigger can start this Automation independently (OR). At most one schedule. If several match the same event, the first listed wins for run options."}):null]}),e.jsx("div",{className:"space-y-3",children:d.map((x,_)=>{const v=d.length>1,M=v?j&&j!==x.key?["event"]:["event","time"]:["event","time","manual"],w=r[x.key],b=v||(w?w.kind!=="manual":x.initial!==null);return e.jsxs("div",{className:$("space-y-3 rounded-lg border bg-card/40 p-3",v&&"relative"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:v?`Trigger ${_+1}`:"Trigger"}),b?e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive","aria-label":v?`Remove trigger ${_+1}`:"Clear trigger",onClick:()=>I(x.key),children:e.jsx(is,{className:"h-3.5 w-3.5"})}):null]}),e.jsx(Dn,{slotKey:x.key,organizationId:s,initial:x.initial,kinds:M,fieldIdPrefix:`${c}-${x.key}-`,onChange:h})]},x.key)})}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:f,disabled:d.length>=En,children:[e.jsx(Ge,{className:"mr-1.5 h-3.5 w-3.5"}),"Add another trigger"]})]})}function Dn({slotKey:s,organizationId:t,initial:n,kinds:c,fieldIdPrefix:d,onChange:u}){const r=i.useCallback(a=>u(s,a),[u,s]);return e.jsx(Cn,{organizationId:t,initialTrigger:n,allowedKinds:c,showSectionHeader:!1,fieldIdPrefix:d,onChange:r})}const Tn=["claude-code","codex","opencode","pi","agy"],Mn={"claude-code":"Claude Code",codex:"Codex",opencode:"OpenCode",pi:"Pi",agy:"Antigravity (agy)"},Pn=[{kind:"claude-code",binaryName:"claude",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"claude-config-file",flag:"--mcp-config",extraArgs:["--strict-mcp-config","--allowedTools","mcp__lobu__query_sdk,mcp__lobu__run_sdk"]},headlessArgs:[],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:"--permission-mode",budgetFlag:"--max-budget-usd",timeoutFlag:null,trailingArgs:[]},{kind:"agy",binaryName:"agy",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"none"},headlessArgs:["--dangerously-skip-permissions"],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:{flag:"--print-timeout",suffix:"s"},trailingArgs:[]},{kind:"opencode",binaryName:"opencode",promptDelivery:{kind:"positional",subcommand:["run"]},mcpDelivery:{kind:"opencode-config-env",variable:"OPENCODE_CONFIG_CONTENT"},headlessArgs:["--auto","--print-logs","--log-level","ERROR"],modelFlag:"-m",effortFlag:"--variant",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"codex",binaryName:"codex",promptDelivery:{kind:"positional",subcommand:["exec"]},mcpDelivery:{kind:"none"},headlessArgs:["--skip-git-repo-check","--sandbox","workspace-write","-c","sandbox_workspace_write.network_access=true"],modelFlag:"-m",effortFlag:"-c",effortConfigKey:"model_reasoning_effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"pi",binaryName:"pi",promptDelivery:{kind:"positional",subcommand:[]},mcpDelivery:{kind:"none"},headlessArgs:["-p","--no-session","--tools","read,bash,edit,write"],modelFlag:"--model",effortFlag:"--thinking",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]}];new Map(Pn.map(s=>[s.kind,s]));const Vt={agents:!0,lobuEmbedded:!1};function Ln(){const{data:s}=Os({queryKey:["features"],queryFn:async()=>{const t=await Ds(`${Ts}/api/features`);return t.ok?t.json():Vt},staleTime:3e4,refetchInterval:6e4});return s??Vt}const ht="__none__";function Je(s){return`${s.connection_id}:${s.feed_key}`}function Rn(s){const t=s.indexOf(":");if(t<=0)return null;const n=Number(s.slice(0,t)),c=s.slice(t+1);return!Number.isSafeInteger(n)||n<=0||!c?null:{connection_id:n,channel_id:c}}function xt(s){return s?`${s.connection_id}:${s.channel_id}`:""}function st(s){return`${s.display_name||s.feed_key} (${s.feed_key})`}function $n(s){return s.connection_name?`connection ${s.connection_id} (${s.connection_name})`:`connection ${s.connection_id}`}function zt(s,t){return s.store==="channel_messages"&&s.target_agent_id===t&&s.connection_status==="active"}function In({organizationId:s,agentId:t,value:n,onChange:c,disabled:d=!1,automationName:u,onPendingChange:r}){const{data:a=[],isLoading:g}=Ms(s),j=xt(n),[h,f]=i.useState(null),[I,x]=i.useState(!1),_=i.useRef(t),v=i.useMemo(()=>a.filter(m=>zt(m,t)),[a,t]);i.useEffect(()=>{if(_.current===t)return;const m=_.current;if(_.current=t,f(null),x(!1),!m||n==null)return;const z=xt(n);if(z==="")return;a.some(C=>zt(C,t)&&Je(C)===z)||c(null)},[t,a,n,c]);const M=h??j,w=M===""?ht:M,b=v.find(m=>Je(m)===M),O=h!==null&&h!==""&&h!==j;i.useEffect(()=>{r?.(O)},[O,r]);const N=b??(h?void 0:v.find(m=>Je(m)===j)),me=m=>{const z=m===ht?"":m;if(z===""){f(null),x(!1),c(null);return}if(z===j){f(null),x(!1);return}f(z),x(!1)},K=m=>{if(x(m),m&&h){const z=Rn(h);z&&(f(null),c(z))}else!m&&h&&f(null)},S=(n&&xt(n)!==""?n:void 0)??(b?{connection_id:b.connection_id,channel_id:b.feed_key}:void 0),H=(u??"").trim()||"This automation";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"automation-delivery-target",children:["Digest destination"," ",e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),t?e.jsxs(ae,{value:w,onValueChange:me,disabled:d||g,children:[e.jsx(oe,{id:"automation-delivery-target",className:"font-mono text-sm",children:e.jsx(ie,{placeholder:g?"Loading bound channels…":v.length===0?"No bound chat channels":"No digest — runs stay silent"})}),e.jsxs(ce,{children:[e.jsx(D,{value:ht,children:"No digest — runs stay silent"}),v.map(m=>e.jsxs(D,{value:Je(m),children:[st(m)," · ",m.connector_key]},Je(m)))]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a managed agent first — only channels bound to that agent can receive digests."}),t&&!g&&v.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No active chat channels are bound to this agent yet. Link a private channel first, then select it here."}):null,O&&b?e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:m=>K(m.target.checked),className:"mt-0.5","aria-label":`Confirm digest delivery to ${st(b)}`}),e.jsxs("span",{className:"text-muted-foreground",children:["I confirm posting material-change digests to"," ",e.jsx("span",{className:"font-medium text-foreground",children:st(b)}),". Destination changes are audited."]})]}):null,N||S?e.jsxs("div",{className:$(Ie,"space-y-1.5 px-3 py-2"),children:[e.jsxs("p",{className:"text-xs font-medium",children:["Digest preview →"," ",e.jsx("span",{className:"font-mono font-normal",children:N?`${N.connector_key} ${st(N)} · ${$n(N)}`:`${S?.channel_id} · connection ${S?.connection_id}`})]}),e.jsxs("p",{className:"font-mono text-xs",children:[H," applied 2 new + 1 updated"]}),e.jsx("p",{className:"whitespace-pre-line font-mono text-xs text-muted-foreground",children:`+ Example task (#12)
|
|
2
|
-
~ Follow-up item (#34)`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sends only after a successful run with material changes. Runs with zero changes send nothing. Retries reuse the same notification and delivery receipts dedupe channel posts, but provider acceptance with a lost receipt can still duplicate."})]}):null]})}const Ut=4096;function qn({open:s,onOpenChange:t,initial:n,onSubmit:c}){const[d,u]=i.useState(""),[r,a]=i.useState(""),[g,j]=i.useState(null);i.useEffect(()=>{s&&(u(n?.name??""),a(n?.query??""),j(null))},[s,n]);const h=()=>{const I=d.trim(),x=r.trim();if(!I){j("Give the SQL source a name.");return}if(!x){j("Enter a query.");return}if(x.length>Ut){j(`Query is too long (${x.length} chars, max ${Ut}).`);return}c({name:I,query:x}),t(!1)},f=!!n;return e.jsx(Ps,{open:s,onOpenChange:t,children:e.jsxs(Ls,{className:"max-w-2xl",children:[e.jsxs(Rs,{children:[e.jsx($s,{children:f?"Edit SQL source":"SQL source"}),e.jsx(Is,{children:"Write a query the automation runs each period. It becomes a reference in the prompt — the query travels with the chip."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"sql-source-name",children:"Name"}),e.jsx(ne,{id:"sql-source-name",value:d,onChange:I=>u(I.target.value),placeholder:"recent_cancellations",autoFocus:!f}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The output-field name this source fills."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"sql-source-query",children:"Query"}),e.jsx(yt,{value:r,onChange:a,language:"sql",placeholder:"SELECT id, payload_text, occurred_at FROM events ORDER BY occurred_at DESC",minHeight:"160px"})]}),g?e.jsx("p",{className:"text-sm text-destructive",children:g}):null]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(G,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(G,{onClick:h,children:f?"Save":"Add source"})]})]})})}const Kn=["skill","feed","connection","connector","metric","entity_type"];function Bn({value:s,onChange:t,library:n,pinned:c,required:d,error:u,owner:r,agentId:a,sources:g,onAddSources:j}){const h=hn(Kn,Lt,{skills:n,skillAgentId:a||null}),f=i.useRef(null),[I,x]=i.useState(null),_=i.useMemo(()=>{if(!g)return[];const b=new Set(g.map(O=>O.query.trim()));return Rt(s).filter(O=>!b.has(O.query.trim()))},[s,g]),v=xn(s),M=gn(c.filter(b=>v.includes(b.name)),n),w=n.length>0;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(k,{htmlFor:"automation-prompt",children:["Instructions"," ",d?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),v.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[v.length,"/",Lt," skills"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-background focus-within:ring-1 focus-within:ring-ring",children:e.jsx(pn,{value:s,onChange:t,onSubmit:()=>{},submitOnEnter:!1,searchRefs:h,handleRef:f,onSqlRequest:()=>x({}),onSqlEdit:(b,O)=>x({initial:b,pos:O}),placeholder:w?"What should this Automation do? Type @ to pull in a skill or a data source.":"What should this Automation do? Type @ to pull in a data source.",className:"[&_.ProseMirror]:min-h-[7rem] [&_.ProseMirror]:max-h-72 [&_.ProseMirror]:overflow-y-auto"})}),e.jsx(qn,{open:I!==null,onOpenChange:b=>{b||x(null)},initial:I?.initial,onSubmit:b=>{f.current?.insertSql(b,I?.pos),x(null)}}),_.length>0&&j?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-dashed p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.length===1?`"${_[0]?.name}" is referenced in the instructions but is not a source on this Automation.`:`${_.length} references in the instructions are not sources on this Automation.`," ","Editing an Automation does not add them automatically."]}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>j(Rt(s,g)),children:_.length===1?"Add as a source":"Add as sources"})]}):null,v.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:v.map(b=>{const O=M.includes(b),N=!n.some(me=>me.name===b);return e.jsxs(qs,{variant:N?"destructive":"secondary",className:"font-normal",children:[b,N?" · unavailable":O?" · newer text":null]},b)})}):null,M.length>0?e.jsxs("p",{className:"rounded-lg border border-dashed p-3 text-xs text-muted-foreground",children:[M.length===1?`"${M[0]}" has been edited since this Automation pinned it.`:`${M.length} skills have been edited since this Automation pinned them.`," ","This Automation keeps running the pinned text until you save it again."]}):null,u?e.jsx("p",{className:"text-xs text-destructive",children:u}):null,!w&&a?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This agent has no skills yet."," ",e.jsx(Ks,{to:"/$owner/agents/$agentId/skills",params:{owner:r,agentId:a},className:"font-medium text-foreground underline underline-offset-2",children:"Add one"})," ","to reuse instructions across Automations."]}):u?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:w?"Type @ to pull in a skill, a feed, connection, connector, metric, entity type, or a SQL query. Skill text is saved with this version, so later edits to the skill do not change this Automation until you update it.":"Type @ to pull in a feed, connection, connector, metric, entity type, or a SQL query this Automation should read."})]})}const Wn=["connection","connector","feed","metric","entity_type"];function Vn({sources:s,onChange:t,disabled:n}){const{currentOwner:c,resolvedOrganizationId:d}=cs(),[u,r]=i.useState(""),{refs:a}=fn({owner:c,organizationId:d,kinds:Wn,query:u,limitPerKind:10});return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Sources"}),s.length>0?e.jsx("ul",{className:"space-y-2",children:s.map(g=>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:g.name}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:g.query})]}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${g.name}`,disabled:n,onClick:()=>t(s.filter(j=>j.query!==g.query)),children:e.jsx(ns,{className:"h-3.5 w-3.5"})})]},g.query))}):null,e.jsx("div",{className:"flex gap-2",children:e.jsx(at,{searchPlaceholder:"Search feeds, connections, metrics…",emptyText:"No matching reference.",onQueryChange:r,trigger:()=>e.jsxs(G,{type:"button",variant:"outline",size:"sm",disabled:n,children:[e.jsx(Ge,{className:"mr-2 h-3.5 w-3.5"}),"Add source"]}),children:g=>a.map(j=>e.jsxs(Ke,{value:`${j.label} ${j.kind}`,onSelect:()=>{t(vn(j,s)),g()},children:[e.jsx("span",{className:"truncate text-sm",children:j.label}),e.jsx("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:j.kind})]},`${j.kind}:${j.id}`))})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Data handed to the agent alongside its instructions, and what change detection is measured against. Editing an Automation does not re-read the instructions for these — this list is what runs. To add a SQL source, write it with @ in the instructions above. Automation-owned; skills never add or remove sources."})]})}function zn({organizationId:s,value:t,onChange:n,className:c}){const{data:d=[]}=Bs(s),u=nn(d),r=u.find(a=>a.id===t);return e.jsx(at,{contentClassName:"w-[300px]",searchPlaceholder:"Search entities...",emptyText:"No entities found.",trigger:a=>e.jsxs(G,{variant:"outline",role:"combobox","aria-expanded":a,className:$("w-full justify-between",c),children:[r?`${r.name} (${r.entityType})`:"All workspace",e.jsx(_t,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:a=>e.jsxs(e.Fragment,{children:[e.jsxs(Ke,{value:"all workspace",onSelect:()=>{n(void 0),a()},className:"cursor-pointer",children:[e.jsx(nt,{className:$("mr-2 h-4 w-4",t===void 0?"opacity-100":"opacity-0")}),e.jsx("span",{children:"All workspace"})]}),u.map(g=>e.jsxs(Ke,{value:`${g.name} ${g.entityType}`,onSelect:()=>{n(g.id),a()},className:"cursor-pointer",children:[e.jsx(nt,{className:$("mr-2 h-4 w-4",t===g.id?"opacity-100":"opacity-0")}),e.jsxs("span",{children:[g.name," ",e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",g.entityType,")"]})]})]},g.id))]})})}function jt(s){if(Array.isArray(s))return s;if(typeof s=="string"&&s.startsWith("{")&&s.endsWith("}")){const t=s.slice(1,-1);return t?t.split(",").map(n=>n.trim()):[]}return[]}const Un=Tn.map(s=>({value:s,label:Mn[s]})),Qt=[{value:"agent",label:"Agent",hint:"An agent reads the window and follows your instructions."},{value:"code",label:"Code",hint:"A deterministic script processes each completed window."},{value:"both",label:"Agent + code",hint:"An agent extracts per your instructions, then the script runs."}];function Jt(s){const t=!!(s?.prompt?.trim()||s?.skills?.some(c=>c.content.trim())),n=!!s?.reaction_script?.trim();return t&&n?"both":n?"code":"agent"}const Qn=["text","number","date","boolean","json"],Jn=[{value:"key",label:"Key"},{value:"plain",label:"Plain"}],gt=[{value:"plan",label:"Plan first"},{value:"auto",label:"Auto"},{value:"acceptEdits",label:"Accept edits"},{value:"dontAsk",label:"Don't ask"},{value:"bypassPermissions",label:"Bypass permissions"}];let Gt=0;function Gn(){return Gt+=1,`field-${Gt}`}function ls(s={}){return{id:Gn(),name:s.name??"",type:s.type??"text",role:s.role??"plain"}}function He(s){return s.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")}function Hn(s){return s?Object.keys(s).every(t=>["entity_type","entity_path","key_fields","key_output_field"].includes(t)):!0}function Ht(s){return s?Hn(s.keying_config)?"fields":"json":"fields"}function Yt(s){const t=s?.keying_config?.entity_type;return typeof t=="string"?t:""}function Xt(s){const t=s?.keying_config?.entity_path;return typeof t=="string"&&t.trim()?t:"$"}function Zt(s){const t=new Map,n=Array.isArray(s?.keying_config?.key_fields)?s?.keying_config?.key_fields:[];for(const c of n){if(typeof c!="string")continue;const d=He(c);d&&t.set(d,ls({name:d,role:"key"}))}return Array.from(t.values())}function ye(s,t){const n=s?.execution_config?.[t];return typeof n=="number"||typeof n=="string"?String(n):""}function es(s,t,n){const c=s?.execution_config?.[t];return typeof c=="string"&&n.includes(c)?c:""}function pt(s,t){const n=s.trim();if(!n)return{};const c=Number(n);return Number.isFinite(c)?{value:c}:{error:`${t} must be a number.`}}function ts({entityType:s,entityPath:t,fields:n}){const d=n.map(a=>({...a,name:He(a.name)})).filter(a=>a.name).filter(a=>a.role==="key").map(a=>a.name),u=He(s),r=t.trim()||"$";return d.length>0&&!u?{error:"Key fields need an output entity type."}:(d.length>0,{keyingConfig:d.length>0?{entity_type:u,entity_path:r,key_fields:d,key_output_field:`${u}_key`}:void 0})}function Yn(s,t){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:s}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})}function ss(s){return!!(s?.keying_config||s?.reactions_guidance||s?.model_config||s?.execution_config||s?.sources?.length||jt(s?.tags).length)}function Xn({organizationId:s,entityId:t,prefill:n,onSubmit:c,isSubmitting:d,error:u,isEditing:r,onCancel:a,triggerFields:g,submitLabel:j="Create Automation",submitDisabled:h=!1,triggers:f,agentFirst:I=!1}){const{lobuEmbedded:x}=Ln(),{currentOwner:_}=cs(),{data:v=[]}=Ws(),{data:M=[]}=Vs(),[w,b]=i.useState(n?.managed_agent_id??""),O=!!n?.managed_agent_id&&!r,[N,me]=i.useState(n?.delivery_target??null),[K,he]=i.useState(!1),[S,H]=i.useState(n?.device_worker_id??""),[m,z]=i.useState(n?.device_worker_id?"device":"agent"),[je,C]=i.useState(n?.agent_kind??""),{data:_e=[]}=as({organizationId:s}),[P,xe]=i.useState(n?.name??""),[re,De]=i.useState(n?.slug??""),[le,B]=i.useState(!!n?.slug),[ge,Q]=i.useState(n?.description??""),[de,Y]=i.useState(n?.prompt??""),[X,pe]=i.useState(!1),Be=n?.skills??[],[Se,Fe]=i.useState(n?.sources??[]),[Z,p]=i.useState(n?.entity_id??t),[ue,U]=i.useState(n?.reaction_script??""),[L,W]=i.useState(()=>Jt(n)),[Ae,fe]=i.useState(n?.keying_config?JSON.stringify(n.keying_config,null,2):""),[we,T]=i.useState(null),[Oe,We]=i.useState(()=>Ht(n)),[ee,Te]=i.useState(()=>Yt(n)),[Me,Ne]=i.useState(()=>Xt(n)),[ve,be]=i.useState(()=>Zt(n)),[Pe,ot]=i.useState(n?.reactions_guidance??""),[Ce,Ye]=i.useState(()=>ye(n,"timeout_seconds")),[it,ct]=i.useState(()=>ye(n,"max_budget_usd")),[Ve,Xe]=i.useState(()=>ye(n,"model")),[Ze,ze]=i.useState(()=>es(n,"permission_mode",gt.map(o=>o.value))),[l,y]=i.useState(()=>ye(n,"effort")),[F,se]=i.useState(()=>ye(n,"finalize_nudges")),[te,q]=i.useState(null),[E,Le]=i.useState(jt(n?.tags).join(", ")),[Ue,Nt]=i.useState(""),[rt,bt]=i.useState(!!(r||ss(n)));i.useEffect(()=>{n&&(xe(n.name??""),De(n.slug??""),B(!!n.slug),Q(n.description??""),Y(n.prompt??""),pe(!1),Fe(n.sources??[]),p(n.entity_id??t),H(n.device_worker_id??""),z(n.device_worker_id?"device":"agent"),C(n.agent_kind??""),U(n.reaction_script??""),W(Jt(n)),fe(n.keying_config?JSON.stringify(n.keying_config,null,2):""),T(null),We(Ht(n)),Te(Yt(n)),Ne(Xt(n)),be(Zt(n)),ot(n.reactions_guidance??""),Ye(ye(n,"timeout_seconds")),ct(ye(n,"max_budget_usd")),Xe(ye(n,"model")),ze(es(n,"permission_mode",gt.map(o=>o.value))),y(ye(n,"effort")),se(ye(n,"finalize_nudges")),q(null),Le(jt(n.tags).join(", ")),Nt(""),b(n.managed_agent_id??""),me(n.delivery_target??null),bt(!!(r||ss(n))))},[n,t,r]);const ds=le?re:Pt(P),{data:us}=zs(w||null),{data:ms}=Us(w||null,{enabled:!!w}),lt=mn(us??null,ms?.catalog??[]),hs=yn(f),dt=ue.trim().length>0,et=!r&&L==="code"?"":de,xs=!r&&L==="agent"?void 0:ue.trim()||void 0,kt=(r||L==="code")&&dt,St=jn(et,lt,f,kt),gs=X||et.trim()!==""?St:null,wt=_n(et,lt),Ct=!r&&L!=="agent",Re=I&&!r,Et=m==="device"||Re&&m==="agent",ps=Et&&!w.trim(),ut=v.length===1?v[0]?.agentId:void 0;i.useEffect(()=>{Re&&m==="agent"&&!w&&ut&&b(ut)},[Re,m,w,ut]);const Ft=!!P.trim()&&!ps&&!St&&(!Ct||dt)&&!K,fs=hs&&!kt&&wt.length===0,vs=()=>{if(!Ft)return;let o;if(Oe==="fields"){const ke=ts({entityType:ee,entityPath:Me,fields:ve});if(ke.error){T(ke.error);return}o=ke.keyingConfig,T(null)}else{if(Ae.trim())try{const ke=JSON.parse(Ae);if(typeof ke!="object"||Array.isArray(ke)){T("Keying config must be a JSON object.");return}o=ke}catch{T("Invalid JSON. Please check the syntax.");return}T(null)}const A=pt(Ce,"Timeout");if(A.error){q(A.error);return}if(A.value!==void 0&&(!Number.isInteger(A.value)||A.value<1)){q("Timeout must be a whole number greater than 0.");return}const V=pt(it,"Budget");if(V.error){q(V.error);return}if(V.value!==void 0&&V.value<0){q("Budget cannot be negative.");return}const R=pt(F,"Finalize nudges");if(R.error){q(R.error);return}if(R.value!==void 0&&(!Number.isInteger(R.value)||R.value<0||R.value>5)){q("Finalize nudges must be a whole number from 0 to 5.");return}const Ee={...A.value!==void 0?{timeout_seconds:A.value}:{},...V.value!==void 0?{max_budget_usd:V.value}:{},...Ve.trim()?{model:Ve.trim()}:{},...Ze?{permission_mode:Ze}:{},...l.trim()?{effort:l.trim()}:{},...R.value!==void 0?{finalize_nudges:R.value}:{}},J=Object.keys(Ee).length>0||r?Ee:void 0;q(null);const js=E.trim()?E.split(",").map(ke=>ke.trim()).filter(Boolean):void 0;c({slug:ds,name:P.trim(),description:ge.trim()||void 0,prompt:et,skills:wt,entity_id:Z,sources:Se,reaction_script:xs,keying_config:o,reactions_guidance:Pe.trim()||void 0,execution_config:J,tags:js,outputs:n?.outputs,change_notes:Ue.trim()||void 0,managed_agent_id:m==="manual"?null:w.trim()||null,device_worker_id:m==="device"&&S.trim()||null,agent_kind:m==="device"&&je.trim()||null,delivery_target:N})},At=e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-reaction",children:["Reaction Script"," ",Ct?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),e.jsx(yt,{value:ue,onChange:U,language:"typescript",placeholder:"export default async function reaction(ctx) { ... }",minHeight:"120px"}),r?null:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Runs deterministically on every completed window, after agent extraction. Declare an ",e.jsx("code",{children:"input"})," export to set the window's extraction contract."]})]}),Ot=!O&&m!=="manual"?e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-agent-id",children:["Agent",Et&&e.jsx("span",{className:"text-destructive",children:" *"})]}),x?e.jsxs(ae,{value:w,onValueChange:b,disabled:v.length===0,children:[e.jsx(oe,{id:"scratch-agent-id",className:"font-mono text-sm",children:e.jsx(ie,{placeholder:v.length===0?"No agents yet":"Select a Lobu agent"})}),e.jsx(ce,{children:v.map(o=>e.jsxs(D,{value:o.agentId,children:[o.name," (",o.agentId,")"]},o.agentId))})]}):e.jsx(ne,{id:"scratch-agent-id",value:w,onChange:o=>{b(o.target.value)},placeholder:"e.g., agent-123",className:"font-mono text-sm"}),m==="device"?e.jsx("p",{className:"text-xs text-muted-foreground",children:"The device run uses this agent's memory and tools, acting as the agent's owner."}):Re?e.jsx("p",{className:"text-xs text-muted-foreground",children:"This agent answers the conversation's messages."}):null]}):null,ys=v.find(o=>o.agentId===w)?.name??w;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(k,{htmlFor:"scratch-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),!r&&e.jsx("button",{type:"button",onClick:()=>B(!le),className:"text-xs text-muted-foreground hover:text-foreground",children:le?"Use automatic slug":"Customize slug"})]}),e.jsx(ne,{id:"scratch-name",value:P,onChange:o=>xe(o.target.value),placeholder:"e.g., Escalation signals"}),!r&&le?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-slug",children:"Slug"}),e.jsx(ne,{id:"scratch-slug",value:re,onChange:o=>De(o.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:Pt(P)||"custom-slug"})]}):null]})}),Re?O?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Agent"}),e.jsx("p",{className:"text-sm",children:ys})]}):Ot:null,r?null:e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"How does this run?"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Qt.map(o=>e.jsx("button",{type:"button","aria-pressed":L===o.value,onClick:()=>W(o.value),className:$("rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors",L===o.value?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:o.label},o.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Qt.find(o=>o.value===L)?.hint})]}),r||L!=="code"?e.jsx(Bn,{value:de,onChange:o=>{pe(!0),Y(o)},library:lt,pinned:Be,required:fs,error:gs,owner:_??"",agentId:w,sources:r?Se:void 0,onAddSources:r?Fe:void 0}):null,!r&&L!=="agent"?At:null,r?e.jsx(Vn,{sources:Se,onChange:Fe,disabled:d}):null,e.jsx("div",{className:"space-y-4",children:g}),e.jsx(In,{organizationId:s,agentId:m==="agent"?w.trim():"",value:N,onChange:me,disabled:d,automationName:P,onPendingChange:he}),K?e.jsx("p",{className:"text-xs text-destructive",children:"Confirm the digest destination above before saving — an unconfirmed destination is not sent."}):null,e.jsxs(G,{type:"button",variant:"ghost",className:"w-full justify-between px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-expanded":rt,"aria-controls":"automation-advanced-settings",onClick:()=>bt(o=>!o),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Qs,{className:"h-4 w-4"}),"Advanced settings"]}),e.jsx(os,{className:$("h-4 w-4 transition-transform",rt&&"rotate-180")})]}),e.jsxs("div",{id:"automation-advanced-settings",className:$("space-y-4",!rt&&"hidden"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-description",children:"Description"}),e.jsx(ne,{id:"scratch-description",value:ge,onChange:o=>Q(o.target.value),placeholder:"What this automation does"})]}),!t&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Entity scope"}),e.jsx(zn,{organizationId:s,value:Z,onChange:p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit this automation to one workspace entity."})]}),r?At:null,e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(k,{children:"Output fields"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Key fields become stable entity keys."})]}),e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{if(Oe==="fields"){const o=ts({entityType:ee,entityPath:Me,fields:ve});if(o.error){T(o.error);return}fe(o.keyingConfig?JSON.stringify(o.keyingConfig,null,2):""),We("json")}else We("fields");T(null)},children:Oe==="fields"?"Edit JSON":"Use fields"})]}),Oe==="fields"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-output-entity-type",children:"Output entity type"}),e.jsx(at,{contentClassName:"w-[320px]",searchPlaceholder:"Search or type a new type…",emptyText:"Type a name to create a new entity type.",trigger:o=>e.jsxs(G,{type:"button",variant:"outline",role:"combobox","aria-expanded":o,id:"scratch-output-entity-type",className:"w-full justify-between font-mono text-sm font-normal",children:[e.jsx("span",{className:$("truncate",!ee&&"text-muted-foreground"),children:ee||"Select entity type"}),e.jsx(_t,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(o,A)=>{const V=He(A),R=_e.filter(J=>!J.backing_sql),Ee=R.some(J=>J.slug===V);return e.jsxs(e.Fragment,{children:[R.map(J=>e.jsxs(Ke,{value:`${J.name??J.slug} ${J.slug}`,onSelect:()=>{Te(J.slug),T(null),o()},className:"cursor-pointer",children:[e.jsx(nt,{className:$("mr-2 h-4 w-4",ee===J.slug?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-mono text-sm",children:J.slug}),J.name&&J.name!==J.slug&&e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:J.name})]})]},J.slug)),V&&!Ee&&e.jsxs(Ke,{value:A,onSelect:()=>{Te(V),T(null),o()},className:"cursor-pointer",children:[e.jsx(Ge,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"text-sm",children:["Create"," ",e.jsx("span",{className:"font-mono",children:V})]})]})]})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-output-path",children:"Output path"}),e.jsx(ne,{id:"scratch-output-path",value:Me,onChange:o=>{Ne(o.target.value),T(null)},placeholder:"$.items[*]",className:"font-mono text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(k,{children:"Fields"}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{be(o=>[...o,ls()]),T(null)},children:[e.jsx(Ge,{className:"mr-2 h-4 w-4"}),"Add field"]})]}),ve.length===0?e.jsx("div",{className:$(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"No output fields configured."}):e.jsx("div",{className:"space-y-2",children:ve.map(o=>e.jsxs("div",{className:$(Ie,"grid gap-2 p-3 sm:grid-cols-[minmax(0,1fr)_128px_minmax(0,240px)_auto]"),children:[e.jsx(ne,{value:o.name,onChange:A=>{const V=He(A.target.value);be(R=>R.map(Ee=>Ee.id===o.id?{...Ee,name:V}:Ee)),T(null)},placeholder:"severity","aria-label":"Output field name",className:"font-mono text-sm"}),e.jsxs(ae,{value:o.type,onValueChange:A=>{be(V=>V.map(R=>R.id===o.id?{...R,type:A}:R))},children:[e.jsx(oe,{"aria-label":"Output field type",children:e.jsx(ie,{})}),e.jsx(ce,{children:Qn.map(A=>e.jsx(D,{value:A,children:A},A))})]}),e.jsx("div",{className:"grid grid-cols-2 rounded-md border border-input bg-background p-1",children:Jn.map(A=>e.jsx("button",{type:"button",onClick:()=>{be(V=>V.map(R=>R.id===o.id?{...R,role:A.value}:R)),T(null)},className:$("rounded-sm px-2 py-1 text-xs transition-colors",o.role===A.value?"bg-muted/70 text-foreground":"text-muted-foreground hover:text-foreground"),children:A.label},A.value))}),e.jsx(G,{type:"button",variant:"ghost",size:"icon",onClick:()=>{be(A=>A.filter(V=>V.id!==o.id)),T(null)},"aria-label":"Remove output field",children:e.jsx(is,{className:"h-4 w-4"})})]},o.id))})]}),we&&e.jsx("p",{className:"text-xs text-destructive",children:we})]}):e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-keying-config",children:"Keying Config (JSON)"}),e.jsx(yt,{value:Ae,onChange:o=>{fe(o),T(null)},language:"json",placeholder:'{ "entity_type": "topic", "entity_path": "$.items[*]", "key_fields": ["name"], "key_output_field": "entity_key" }',minHeight:"60px"}),we&&e.jsx("p",{className:"text-xs text-destructive",children:we})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-reactions-guidance",children:"Reactions Guidance"}),e.jsx(Js,{id:"scratch-reactions-guidance",value:Pe,onChange:o=>ot(o.target.value),placeholder:"Guidance text for the reaction system (e.g., when to alert, severity thresholds)...",className:"font-mono text-xs min-h-[80px]"})]}),e.jsxs("div",{className:"space-y-4",children:[Yn("Run settings","Choose where the automation runs and the budget it can use."),!O&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-runs-on",children:"Runs on"}),e.jsxs(ae,{value:m,onValueChange:o=>z(o),children:[e.jsx(oe,{id:"scratch-runs-on",className:"text-sm",children:e.jsx(ie,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:"agent",children:"Managed agent"}),e.jsx(D,{value:"device",children:"On a device"}),e.jsx(D,{value:"manual",children:"Manual-only"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m==="agent"?"Automated runs dispatch to a managed Lobu agent.":m==="device"?"Automated runs are claimed and executed locally by a device worker (Mac app, remote worker).":"No executor — this automation runs only when started manually by a connected client."})]}),!Re&&Ot,!O&&m==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-id",children:"Device"}),e.jsxs(ae,{value:S||"__unselected__",onValueChange:o=>H(o==="__unselected__"?"":o),children:[e.jsx(oe,{id:"scratch-device-id",className:"font-mono text-sm",children:e.jsx(ie,{placeholder:"Select a device worker"})}),e.jsx(ce,{children:M.map(o=>e.jsx(D,{value:o.id,children:o.label||o.platform||o.id},o.id))})]})]}),!O&&m==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-agent-kind",children:"Runs as"}),e.jsxs(ae,{value:je||"__default__",onValueChange:o=>C(o==="__default__"?"":o),children:[e.jsx(oe,{id:"scratch-device-agent-kind",className:"text-sm",children:e.jsx(ie,{placeholder:"Device default"})}),e.jsxs(ce,{children:[e.jsx(D,{value:"__default__",children:"Device default"}),Un.map(o=>e.jsx(D,{value:o.value,children:o.label},o.value))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Device default uses that device's preferred local agent. Availability is checked again when a run is claimed, so a run stays queued if its selected runtime is no longer available."})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Model"}),e.jsx(un,{value:Ve,onChange:o=>{Xe(o),q(null)},placeholder:"Use agent default"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-timeout",children:"Timeout seconds"}),e.jsx(ne,{id:"scratch-timeout",type:"number",min:1,max:86400,value:Ce,onChange:o=>{Ye(o.target.value),q(null)},placeholder:"600"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-permission-mode",children:"Permission mode"}),e.jsxs(ae,{value:Ze||"__default__",onValueChange:o=>{ze(o==="__default__"?"":o),q(null)},children:[e.jsx(oe,{id:"scratch-permission-mode",children:e.jsx(ie,{placeholder:"Default"})}),e.jsxs(ce,{children:[e.jsx(D,{value:"__default__",children:"Default"}),gt.map(o=>e.jsx(D,{value:o.value,children:o.label},o.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-effort",children:"Effort"}),e.jsx(ne,{id:"scratch-effort",value:l,onChange:o=>{y(o.target.value),q(null)},placeholder:"Default","aria-describedby":"scratch-effort-help"}),e.jsx("p",{id:"scratch-effort-help",className:"text-xs text-muted-foreground",children:"For device runs, use a value supported by the selected CLI and model. Leave empty for its default."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-finalize-nudges",children:"Finalize nudges"}),e.jsx(ne,{id:"scratch-finalize-nudges",type:"number",min:0,max:5,value:F,onChange:o=>{se(o.target.value),q(null)},placeholder:"Default"})]})]}),te&&e.jsx("p",{className:"text-xs text-destructive",children:te})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-tags",children:"Tags"}),e.jsx(ne,{id:"scratch-tags",value:E,onChange:o=>Le(o.target.value),placeholder:"ops, support, risk"})]}),r&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-change-notes",children:"Change notes"}),e.jsx(ne,{id:"scratch-change-notes",value:Ue,onChange:o=>Nt(o.target.value),placeholder:"What changed in this version?"})]})]})]}),u&&!we&&!te&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}),e.jsx(vt,{onCancel:a,children:e.jsx(G,{onClick:vs,disabled:!Ft||d||h,children:d?e.jsxs(e.Fragment,{children:[e.jsx(Gs,{size:"lg",className:"mr-2"}),r?"Saving...":"Creating..."]}):r?"Save Automation":j})})]})}function Zn(s,t){const n=s??null,c=t??null;return n===null||c===null?n===c:n.connection_id===c.connection_id&&n.channel_id===c.channel_id}function ea(s){const t=s.detail??{};return{name:s.name,slug:t.slug,description:t.description??s.description??void 0,prompt:t.prompt,triggers:t.triggers,sources:t.sources,keying_config:t.keying_config,reactions_guidance:t.reactions_guidance,reaction_script:t.reaction_script,model_config:t.model_config,execution_config:t.execution_config,tags:t.tags,outputs:t.outputs}}function ma({startFromScratch:s=!1,onClose:t,hideCancel:n=!1,hideHeader:c=!1,organizationId:d,entityId:u,entityName:r,prefillAgentId:a,conversationSetup:g,onSuccess:j,editingAutomation:h,catalogPrefill:f,onDraft:I,triggerFields:x,submitLabel:_,submitDisabled:v,createFields:M,onPrefillTriggers:w}){const b=an(),O=on(),N=cn(),me=rn(),K=!!h,[he,S]=i.useState(s?"scratch":"template"),[H,m]=i.useState(void 0),[z,je]=i.useState(void 0),{data:C=[],isLoading:_e}=ln(),[P,xe]=i.useState(""),re=g?.name,De=i.useMemo(()=>a||re?{...re?{name:re}:{},...a?{managed_agent_id:a}:{}}:void 0,[a,re]),le=i.useMemo(()=>C.map(p=>({key:p.id,name:p.name,description:p.description??"",badges:p.detail?.tags??[]})),[C]),B=i.useMemo(()=>le.filter(p=>p.name.toLowerCase().includes(P.toLowerCase())||p.description.toLowerCase().includes(P.toLowerCase())),[le,P]),ge=p=>{const ue=C.find(L=>L.id===p.key);if(!ue)return;const U=ea(ue);je(a?{...U,managed_agent_id:a}:U),w?.(U.triggers??[]),S("scratch")},Q=()=>{b.reset(),O.reset(),S("template"),m(void 0),je(void 0),t()},de=K?M?.triggers??h.triggers??[]:M?.triggers??z?.triggers??f?.triggers??[],Y=async p=>{try{if(I){await I(p);return}if(K){const ue=M?.triggers??h.triggers??[],U=h.reaction_script??"",L=p.reaction_script??"";L&&L!==U&&await N.mutateAsync({automation_id:h.automation_id,reaction_script:L}),await O.mutateAsync({automation_id:h.automation_id,name:p.name,description:p.description,prompt:p.prompt,sources:p.sources,set_as_current:!0,triggers:ue,keying_config:p.keying_config,reactions_guidance:p.reactions_guidance,change_notes:p.change_notes}),!L&&U&&await N.mutateAsync({automation_id:h.automation_id,reaction_script:""});const W={};p.model_config!==void 0&&(W.model_config=p.model_config),p.execution_config!==void 0&&(W.execution_config=p.execution_config),p.tags!==void 0&&(W.tags=p.tags),p.delivery_target!==void 0&&!Zn(p.delivery_target,h.delivery_target)&&(W.delivery_target=p.delivery_target),p.managed_agent_id!==void 0&&(W.managed_agent_id=p.managed_agent_id||null),p.agent_kind!==void 0&&(W.agent_kind=p.agent_kind||null),p.device_worker_id!==void 0&&(W.device_worker_id=p.device_worker_id||null),Object.keys(W).length>0&&await me.mutateAsync({automation_id:h.automation_id,...W}),Q(),j?.(h.automation_id)}else{const ue=M?.triggers??z?.triggers??f?.triggers??[],U=await b.mutateAsync({...p,managed_agent_id:p.managed_agent_id??void 0,device_worker_id:p.device_worker_id??void 0,agent_kind:p.agent_kind??void 0,delivery_target:p.delivery_target??void 0,triggers:ue});Q(),U.automation_id&&j?.(U.automation_id)}}catch{}},X=K?O:b;let pe="Add an automation";K?pe="Edit automation configuration (saves as a new version)":r&&(pe=`Add an automation for ${r}`);const Be=h?{entity_id:h.entity_id,name:h.name,slug:h.slug,description:h.description,prompt:h.prompt,sources:h.sources,reaction_script:h.reaction_script,device_worker_id:h.device_worker_id??void 0,agent_kind:h.agent_kind??void 0,keying_config:h.keying_config,reactions_guidance:h.reactions_guidance,model_config:h.model_config,execution_config:h.execution_config,tags:h.tags,managed_agent_id:h.managed_agent_id??void 0,delivery_target:h.delivery_target??void 0}:void 0,Se=K?"Edit Automation":"Create Automation",Fe=e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:Se}),e.jsx("p",{className:"text-sm text-muted-foreground",children:pe})]}),Z=e.jsxs("div",{className:"py-6 space-y-6",children:[!K&&e.jsxs("div",{className:"flex flex-wrap justify-start gap-2",children:[e.jsx(ft,{active:he==="template",onClick:()=>S("template"),icon:e.jsx(Hs,{className:"h-4 w-4"}),label:"From templates"}),e.jsx(ft,{active:he==="scratch",onClick:()=>{S("scratch"),m(void 0),je(void 0)},icon:e.jsx(Ge,{className:"h-4 w-4"}),label:"From scratch"}),e.jsx(ft,{active:he==="clone",onClick:()=>S("clone"),icon:e.jsx(Ys,{className:"h-4 w-4"}),label:"Clone existing"})]}),!K&&he==="template"?e.jsxs(e.Fragment,{children:[_e?e.jsx(Xs,{}):e.jsx(Zs,{items:B,searchQuery:P,onSearchChange:xe,onSelect:ge,searchPlaceholder:"Search templates...",searchAriaLabel:"Search automation templates",emptyMessage:le.length===0?"No automation templates available.":void 0}),c&&!n?e.jsx(vt,{onCancel:Q}):null]}):!K&&he==="clone"&&!H?e.jsxs(e.Fragment,{children:[e.jsx(ta,{organizationId:d,onSelect:p=>{m(p),w?.(p.triggers??[]),S("scratch")}}),c&&!n?e.jsx(vt,{onCancel:Q}):null]}):e.jsx(Xn,{organizationId:d,entityId:u,prefill:Be??H??z??f??De,onSubmit:Y,isSubmitting:X.isPending,error:X.error?X.error.message:null,isEditing:K,onCancel:n?void 0:Q,triggerFields:x,submitLabel:_,submitDisabled:v,triggers:de,agentFirst:!!g})]});return e.jsxs("div",{className:"flex flex-col",children:[c?null:Fe,Z]})}function ft({active:s,onClick:t,icon:n,label:c}){return e.jsxs("button",{type:"button",onClick:t,className:$("flex items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors",s?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[n,c]})}function ta({organizationId:s,onSelect:t}){const{data:n,isLoading:c}=dn(s),[d,u]=i.useState(""),r=(n||[]).filter(a=>a.name?.toLowerCase().includes(d.toLowerCase()));return c?e.jsx(en,{label:"automations",variant:"list-picker",rows:4}):!n||n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No existing automations to clone."}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",value:d,onChange:a=>u(a.target.value),placeholder:"Search automations...",className:"w-full rounded-md border px-3 py-2 text-sm bg-background"}),e.jsxs("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:[r.map(a=>e.jsxs("button",{type:"button",onClick:()=>t({name:`${a.name} (copy)`,slug:`${a.slug||a.automation_id}-copy`,prompt:a.prompt,keying_config:a.keying_config,triggers:a.triggers,sources:a.sources,outputs:a.outputs}),className:"w-full text-left rounded-md border p-3 hover:border-primary/50 hover:bg-primary/5 transition-colors",children:[e.jsx("p",{className:"text-sm font-medium",children:a.name}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[a.entity_name||"Space-level"," · v",a.version??"?"]})]},a.automation_id)),r.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No automations match your search."})]})]})}export{ua as A,ma as C};
|
|
3
|
-
//# sourceMappingURL=create-automation-form-DmCOFbRT.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{f0 as U}from"./index-4gCDI7m4.js";var M={exports:{}},A;function H(){return A||(A=1,(function(L,C){(function(w,_){L.exports=_()})(globalThis,()=>(()=>{var D={949(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.CronParser=void 0;var i=v(515),y=(function(){function l(e,t,r){t===void 0&&(t=!0),r===void 0&&(r=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=r}return l.prototype.parse=function(){var e,t,r=(e=this.expression)!==null&&e!==void 0?e:"";if(r==="@reboot")return t=["@reboot","","","","","",""],t;if(r.startsWith("@")){var n=this.parseSpecial(this.expression);t=this.extractParts(n)}else t=this.extractParts(this.expression);return this.normalize(t),this.validate(t),t},l.prototype.parseSpecial=function(e){var t={"@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *","@reboot":"@reboot"},r=t[e];if(!r)throw new Error("Unknown special expression.");return r},l.prototype.extractParts=function(e){if(!this.expression)throw new Error("cron expression is empty");for(var t=e.trim().split(/[ ]+/),r=0;r<t.length;r++)if(t[r].includes(",")){var n=t[r].split(",").map(function(a){return a.trim()}).filter(function(a){return a!==""}).map(function(a){return isNaN(Number(a))?a:Number(a)}).filter(function(a){return a!==null&&a!==""});n.length===0&&n.push("*"),n.sort(function(a,u){return a!==null&&u!==null?a-u:0}),t[r]=n.map(function(a){return a!==null?a.toString():""}).join(",")}if(t.length<5)throw new Error("Expression has only ".concat(t.length," part").concat(t.length==1?"":"s",". At least 5 parts are required."));if(t.length==5)t.unshift(""),t.push("");else if(t.length==6){var o=/\d{4}$/.test(t[5])||t[4]=="?"||t[2]=="?";o?t.unshift(""):t.push("")}else if(t.length>7)throw new Error("Expression has ".concat(t.length," parts; too many!"));return t},l.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),e[2]=e[2].replace("?","*"),e[0].indexOf("0/")==0&&(e[0]=e[0].replace("0/","*/")),e[1].indexOf("0/")==0&&(e[1]=e[1].replace("0/","*/")),e[2].indexOf("0/")==0&&(e[2]=e[2].replace("0/","*/")),e[3].indexOf("1/")==0&&(e[3]=e[3].replace("1/","*/")),e[4].indexOf("1/")==0&&(e[4]=e[4].replace("1/","*/")),e[6].indexOf("1/")==0&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(c){var d=c.replace(/\D/,""),f=d;return t.dayOfWeekStartIndexZero?d=="7"&&(f="0"):f=(parseInt(d)-1).toString(),c.replace(d,f)}),e[5]=="L"&&(e[5]="6"),e[3]=="?"&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var r={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var n in r)e[5]=e[5].replace(new RegExp(n,"gi"),r[n].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(c){var d=c.replace(/\D/,""),f=d;return t.monthStartIndexZero&&(f=(parseInt(d)+1).toString()),c.replace(d,f)});var o={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in o)e[4]=e[4].replace(new RegExp(a,"gi"),o[a].toString());e[0]=="0"&&(e[0]=""),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+="-".concat(e[2]));for(var u=0;u<e.length;u++)if(e[u].indexOf(",")!=-1&&(e[u]=e[u].split(",").filter(function(c){return c!==""}).join(",")||"*"),e[u]=="*/1"&&(e[u]="*"),e[u].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[u])){var s=null;switch(u){case 4:s="12";break;case 5:s="6";break;case 6:s="9999";break;default:s=null;break}if(s!==null){var h=e[u].split("/");e[u]="".concat(h[0],"-").concat(s,"/").concat(h[1])}}},l.prototype.validate=function(e){var t="0-9,\\-*/";this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],"0-9,\\-*/LW"),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],"0-9,\\-*/L#"),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},l.prototype.validateAnyRanges=function(e){i.default.secondRange(e[0]),i.default.minuteRange(e[1]),i.default.hourRange(e[2]),i.default.dayOfMonthRange(e[3]),i.default.monthRange(e[4],this.monthStartIndexZero),i.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},l.prototype.validateOnlyExpectedCharactersFound=function(e,t){var r=e.match(new RegExp("[^".concat(t,"]+"),"gi"));if(r&&r.length)throw new Error("Expression contains invalid values: '".concat(r.toString(),"'"))},l})();p.CronParser=y},333(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.ExpressionDescriptor=void 0;var i=v(823),y=v(949),l=(function(){function e(t,r){if(this.expression=t,this.options=r,this.expressionParts=new Array(5),!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var n=Object.keys(e.locales)[0];console.warn("Locale '".concat(this.options.locale,"' could not be found; falling back to '").concat(n,"'.")),this.options.locale=n}this.i18n=e.locales[this.options.locale],r.use24HourTimeFormat===void 0&&(r.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,r){var n=r===void 0?{}:r,o=n.throwExceptionOnParseError,a=o===void 0?!0:o,u=n.verbose,s=u===void 0?!1:u,h=n.dayOfWeekStartIndexZero,c=h===void 0?!0:h,d=n.monthStartIndexZero,f=d===void 0?!1:d,O=n.use24HourTimeFormat,T=n.trimHoursLeadingZero,m=T===void 0?!1:T,b=n.locale,E=b===void 0?null:b,X=n.logicalAndDayFields,x=X===void 0?!1:X,S={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:c,monthStartIndexZero:f,use24HourTimeFormat:O,trimHoursLeadingZero:m,locale:E,logicalAndDayFields:x};S.tzOffset&&console.warn("'tzOffset' option has been deprecated and is no longer supported.");var I=new e(t,S);return I.getFullDescription()},e.initialize=function(t,r){r===void 0&&(r="en"),e.specialCharacters=["/","-",",","*"],e.defaultLocale=r,t.load(e.locales)},e.prototype.getFullDescription=function(){var t,r,n="";try{var o=new y.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=o.parse(),this.expressionParts[0]==="@reboot")return((r=(t=this.i18n).atReboot)===null||r===void 0?void 0:r.call(t))||"Run once, at startup";var a=this.getTimeOfDayDescription(),u=this.getDayOfMonthDescription(),s=this.getMonthDescription(),h=this.getDayOfWeekDescription(),c=this.getYearDescription();n+=a+u+h+s+c,n=this.transformVerbosity(n,!!this.options.verbose),n=n.charAt(0).toLocaleUpperCase()+n.substr(1)}catch(d){if(!this.options.throwExceptionOnParseError)n=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw"".concat(d)}return n},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],r=this.expressionParts[1],n=this.expressionParts[2],o="";if(!i.StringUtilities.containsAny(r,e.specialCharacters)&&!i.StringUtilities.containsAny(n,e.specialCharacters)&&!i.StringUtilities.containsAny(t,e.specialCharacters))o+=this.i18n.atSpace()+this.formatTime(n,r,t);else if(!t&&r.indexOf("-")>-1&&!(r.indexOf(",")>-1)&&!(r.indexOf("/")>-1)&&!i.StringUtilities.containsAny(n,e.specialCharacters)){var a=r.split("-");o+=i.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(n,a[0],""),this.formatTime(n,a[1],""))}else if(!t&&n.indexOf(",")>-1&&n.indexOf("-")==-1&&n.indexOf("/")==-1&&!i.StringUtilities.containsAny(r,e.specialCharacters)){var u=n.split(",");o+=this.i18n.at();for(var s=0;s<u.length;s++)o&&(o+=" "),o+=this.formatTime(u[s],r,""),s<u.length-2&&(o+=","),s==u.length-2&&(o+=this.i18n.spaceAnd())}else{var h=this.getSecondsDescription(),c=this.getMinutesDescription(),d=this.getHoursDescription();if(o+=h,o&&c&&(o+=", "),o+=c,c===d)return o;o&&d&&(o+=", "),o+=d}return o},e.prototype.getSecondsDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(n){return n},function(n){return i.StringUtilities.format(t.i18n.everyX0Seconds(n),n)},function(n){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(n){return n=="0"?"":parseInt(n)<20?t.i18n.atX0SecondsPastTheMinute(n):t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute(n)});return r},e.prototype.getMinutesDescription=function(){var t=this,r=this.expressionParts[0],n=this.expressionParts[2],o=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(a){return a},function(a){return i.StringUtilities.format(t.i18n.everyX0Minutes(a),a)},function(a){return t.i18n.minutesX0ThroughX1PastTheHour()},function(a){var u,s;try{return a=="0"&&n.indexOf("/")==-1&&r==""?t.i18n.everyHour():a=="0"?((s=(u=t.i18n).onTheHour)===null||s===void 0?void 0:s.call(u))||t.i18n.atX0MinutesPastTheHour(a):parseInt(a)<20?t.i18n.atX0MinutesPastTheHour(a):t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour(a)}catch{return t.i18n.atX0MinutesPastTheHour(a)}});return o},e.prototype.getHoursDescription=function(){var t=this,r=this.expressionParts[2],n=0,o=[];r.split("/")[0].split(",").forEach(function(s){var h=s.split("-");h.length===2&&o.push({value:h[1],index:n+1}),n+=h.length});var a=0,u=this.getSegmentDescription(r,this.i18n.everyHour(),function(s){var h=o.find(function(d){return d.value===s&&d.index===a}),c=h&&t.expressionParts[1]!=="0";return a++,c?t.formatTime(s,"59",""):t.formatTime(s,"0","")},function(s){return i.StringUtilities.format(t.i18n.everyX0Hours(s),s)},function(s){return t.i18n.betweenX0AndX1()},function(s){return t.i18n.atX0()});return u},e.prototype.getDayOfWeekDescription=function(){var t=this,r=this.i18n.daysOfTheWeek(),n=null;return this.expressionParts[5]=="*"?n="":n=this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(o,a){var u=o;o.indexOf("#")>-1?u=o.substring(0,o.indexOf("#")):o.indexOf("L")>-1&&(u=u.replace("L",""));var s=parseInt(u),h=t.i18n.daysOfTheWeekInCase?t.i18n.daysOfTheWeekInCase(a)[s]:r[s];if(o.indexOf("#")>-1){var c=null,d=o.substring(o.indexOf("#")+1),f=o.substring(0,o.indexOf("#"));switch(d){case"1":c=t.i18n.first(f);break;case"2":c=t.i18n.second(f);break;case"3":c=t.i18n.third(f);break;case"4":c=t.i18n.fourth(f);break;case"5":c=t.i18n.fifth(f);break}h=c+" "+h}return h},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0DaysOfTheWeek(o),o)},function(o){var a=o.substring(0,o.indexOf("-")),u=t.expressionParts[3]!="*";return u?t.i18n.commaAndX0ThroughX1(a):t.i18n.commaX0ThroughX1(a)},function(o){var a=null;if(o.indexOf("#")>-1){var u=o.substring(o.indexOf("#")+1),s=o.substring(0,o.indexOf("#"));a=t.i18n.commaOnThe(u,s).trim()+t.i18n.spaceX0OfTheMonth()}else if(o.indexOf("L")>-1)a=t.i18n.commaOnTheLastX0OfTheMonth(o.replace("L",""));else{var h=t.expressionParts[3]!="*";h?t.options.logicalAndDayFields?a=t.i18n.commaOnlyOnX0(o):a=t.i18n.commaAndOnX0():a=t.i18n.commaOnlyOnX0(o)}return a}),n},e.prototype.getMonthDescription=function(){var t=this,r=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(o,a){return a&&t.i18n.monthsOfTheYearInCase?t.i18n.monthsOfTheYearInCase(a)[parseInt(o)-1]:r[parseInt(o)-1]},function(o){return parseInt(o)==1?"":i.StringUtilities.format(t.i18n.commaEveryX0Months(o),o)},function(o){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(o){return t.i18n.commaOnlyInMonthX0?t.i18n.commaOnlyInMonthX0():t.i18n.commaOnlyInX0()});return n},e.prototype.getDayOfMonthDescription=function(){var t=this,r=null,n=this.expressionParts[3];switch(n){case"L":r=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":r=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var o=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(o){var a=parseInt(o[0].replace("W","")),u=a==1?this.i18n.firstWeekday():i.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());r=i.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),u);break}else{var s=n.match(/L-(\d{1,2})/);if(s){var h=s[1];r=i.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(h),h);break}else{if(n=="*"&&this.expressionParts[5]!="*")return"";r=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(c){return c=="L"?t.i18n.lastDay():t.i18n.dayX0?i.StringUtilities.format(t.i18n.dayX0(),c):c},function(c){return c=="1"?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days(c)},function(c){return t.i18n.commaBetweenDayX0AndX1OfTheMonth(c)},function(c){return t.i18n.commaOnDayX0OfTheMonth(c)})}break}}return r},e.prototype.getYearDescription=function(){var t=this,r=this.getSegmentDescription(this.expressionParts[6],"",function(n){return/^\d+$/.test(n)?new Date(parseInt(n),1).getFullYear().toString():n},function(n){return i.StringUtilities.format(t.i18n.commaEveryX0Years(n),n)},function(n){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(n){return t.i18n.commaOnlyInYearX0?t.i18n.commaOnlyInYearX0():t.i18n.commaOnlyInX0()});return r},e.prototype.getSegmentDescription=function(t,r,n,o,a,u){var s=null,h=t.indexOf("/")>-1,c=t.indexOf("-")>-1,d=t.indexOf(",")>-1;if(!t)s="";else if(t==="*")s=r;else if(!h&&!c&&!d)s=i.StringUtilities.format(u(t),n(t));else if(d){for(var f=t.split(","),O="",T=this.i18n.spaceAnd(),m=0;m<f.length;m++)if(m>0&&f.length>2&&(O+=",",m<f.length-1&&(O+=" ")),m>0&&f.length>1&&(m==f.length-1||f.length==2)&&(O+=T==","&&f.length>2?" ":"".concat(T," ")),f[m].indexOf("/")>-1||f[m].indexOf("-")>-1){var b=f[m].indexOf("-")>-1&&f[m].indexOf("/")==-1,E=this.getSegmentDescription(f[m],r,n,o,b?this.i18n.commaX0ThroughX1:a,u);b&&(E=E.replace(", ","")),O+=E}else if(!h)O+=n(f[m]);else{var X=this.getSegmentDescription(f[m],r,n,o,a,u);X&&X.startsWith(", ")&&(X=X.substring(2)),O+=X}h?s=O:s=i.StringUtilities.format(u(t),O)}else if(h){var f=t.split("/");if(s=i.StringUtilities.format(o(f[1]),f[1]),f[0].indexOf("-")>-1){var x=this.generateRangeSegmentDescription(f[0],a,n);x.indexOf(", ")!=0&&(s+=", "),s+=x}else if(f[0].indexOf("*")==-1){var S=i.StringUtilities.format(u(f[0]),n(f[0]));S=S.replace(", ",""),s+=i.StringUtilities.format(this.i18n.commaStartingX0(),S)}}else c&&(s=this.generateRangeSegmentDescription(t,a,n));return s},e.prototype.generateRangeSegmentDescription=function(t,r,n){var o="",a=t.split("-"),u=n(a[0],1),s=n(a[1],2),h=r(t);return o+=i.StringUtilities.format(h,u,s),o},e.prototype.formatTime=function(t,r,n){var o=0,a=0,u=parseInt(t)+o,s=parseInt(r)+a;s>=60?(s-=60,u+=1):s<0&&(s+=60,u-=1),u>=24?u=u-24:u<0&&(u=24+u);var h="",c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),h=c?"".concat(this.getPeriod(u)," "):" ".concat(this.getPeriod(u)),u>12&&(u-=12),u===0&&(u=12));var d="";n&&(d=":".concat(("00"+n).substring(n.length)));var f=u.toString(),O=("00"+f).substring(f.length),T=s.toString(),m=("00"+T).substring(T.length),b=this.options.trimHoursLeadingZero?f:O;return"".concat(c?h:"").concat(b,":").concat(m).concat(d).concat(c?"":h)},e.prototype.transformVerbosity=function(t,r){if(!r&&(t=t.replace(new RegExp(", ".concat(this.i18n.everyMinute()),"g"),""),t=t.replace(new RegExp(", ".concat(this.i18n.everyHour()),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),""),t=t.replace(/\, ?$/,""),this.i18n.conciseVerbosityReplacements))for(var n=0,o=Object.entries(this.i18n.conciseVerbosityReplacements());n<o.length;n++){var a=o[n],u=a[0],s=a[1];t=t.replace(new RegExp(u,"g"),s)}return t},e.prototype.getPeriod=function(t){return t>=12?this.i18n.pm&&this.i18n.pm()||"PM":this.i18n.am&&this.i18n.am()||"AM"},e.locales={},e})();p.ExpressionDescriptor=l},747(g,p,v){Object.defineProperty(p,"__esModule",{value:!0}),p.enLocaleLoader=void 0;var i=v(486),y=(function(){function l(){}return l.prototype.load=function(e){e.en=new i.en},l})();p.enLocaleLoader=y},486(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.en=void 0;var v=(function(){function i(){}return i.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},i.prototype.atX0MinutesPastTheHourGt20=function(){return null},i.prototype.commaMonthX0ThroughMonthX1=function(){return null},i.prototype.commaYearX0ThroughYearX1=function(){return null},i.prototype.use24HourTimeFormatByDefault=function(){return!1},i.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occurred when generating the expression description. Check the cron expression syntax."},i.prototype.everyMinute=function(){return"every minute"},i.prototype.everyHour=function(){return"every hour"},i.prototype.atSpace=function(){return"At "},i.prototype.everyMinuteBetweenX0AndX1=function(){return"Every minute between %s and %s"},i.prototype.at=function(){return"At"},i.prototype.spaceAnd=function(){return" and"},i.prototype.everySecond=function(){return"every second"},i.prototype.everyX0Seconds=function(){return"every %s seconds"},i.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},i.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},i.prototype.everyX0Minutes=function(){return"every %s minutes"},i.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},i.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},i.prototype.everyX0Hours=function(){return"every %s hours"},i.prototype.betweenX0AndX1=function(){return"between %s and %s"},i.prototype.atX0=function(){return"at %s"},i.prototype.commaEveryDay=function(){return", every day"},i.prototype.commaEveryX0DaysOfTheWeek=function(){return", every %s days of the week"},i.prototype.commaX0ThroughX1=function(){return", %s through %s"},i.prototype.commaAndX0ThroughX1=function(){return", %s through %s"},i.prototype.first=function(){return"first"},i.prototype.second=function(){return"second"},i.prototype.third=function(){return"third"},i.prototype.fourth=function(){return"fourth"},i.prototype.fifth=function(){return"fifth"},i.prototype.commaOnThe=function(){return", on the "},i.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},i.prototype.lastDay=function(){return"the last day"},i.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},i.prototype.commaOnlyOnX0=function(){return", only on %s"},i.prototype.commaAndOnX0=function(){return", and on %s"},i.prototype.commaEveryX0Months=function(){return", every %s months"},i.prototype.commaOnlyInX0=function(){return", only in %s"},i.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},i.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},i.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return", %s days before the last day of the month"},i.prototype.firstWeekday=function(){return"first weekday"},i.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},i.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},i.prototype.commaEveryX0Days=function(){return", every %s days in a month"},i.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},i.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},i.prototype.commaEveryHour=function(){return", every hour"},i.prototype.commaEveryX0Years=function(){return", every %s years"},i.prototype.commaStartingX0=function(){return", starting %s"},i.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},i.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},i.prototype.atReboot=function(){return"Run once, at startup"},i.prototype.onTheHour=function(){return"on the hour"},i})();p.en=v},515(g,p){Object.defineProperty(p,"__esModule",{value:!0});function v(y,l){if(!y)throw new Error(l)}var i=(function(){function y(){}return y.secondRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"seconds part must be >= 0 and <= 59")}},y.minuteRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=59,"minutes part must be >= 0 and <= 59")}},y.hourRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=0&&r<=23,"hours part must be >= 0 and <= 23")}},y.dayOfMonthRange=function(l){for(var e=l.split(","),t=0;t<e.length;t++)if(!isNaN(parseInt(e[t],10))){var r=parseInt(e[t],10);v(r>=1&&r<=31,"DOM part must be >= 1 and <= 31")}},y.monthRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=1&&n<=12,e?"month part must be >= 0 and <= 11":"month part must be >= 1 and <= 12")}},y.dayOfWeekRange=function(l,e){for(var t=l.split(","),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var n=parseInt(t[r],10);v(n>=0&&n<=6,e?"DOW part must be >= 0 and <= 6":"DOW part must be >= 1 and <= 7")}},y})();p.default=i},823(g,p){Object.defineProperty(p,"__esModule",{value:!0}),p.StringUtilities=void 0;var v=(function(){function i(){}return i.format=function(y){for(var l=[],e=1;e<arguments.length;e++)l[e-1]=arguments[e];return y.replace(/%s/g,function(t){return l.shift()})},i.containsAny=function(y,l){return l.some(function(e){return y.indexOf(e)>-1})},i})();p.StringUtilities=v}},w={};function _(g){var p=w[g];if(p!==void 0)return p.exports;var v=w[g]={exports:{}};return D[g](v,v.exports,_),v.exports}var k={};return(()=>{var g=k;Object.defineProperty(g,"__esModule",{value:!0}),g.toString=void 0;var p=_(333),v=_(747);p.ExpressionDescriptor.initialize(new v.enLocaleLoader),g.default=p.ExpressionDescriptor;var i=p.ExpressionDescriptor.toString;g.toString=i})(),k})())})(M)),M.exports}var R=H();const F=U(R);export{F as c};
|
|
2
|
-
//# sourceMappingURL=cronstrue-CKwjNYgj.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{M as we,o as ye,r as c,P as be,j as e,I as je,B as _,Q as ce}from"./index-4gCDI7m4.js";import{s as ke,g as Ce,u as Ne,a as Se,b as Ae,A as _e,W as Re}from"./oauth-workspace-access-D9BNmyMY.js";import{C as oe,a as re,b as ne,d as ie,c as H}from"./card-SFtxv9f2.js";import{w as ae}from"./workspace-label-o_QfBuCM.js";function M(s){return s.trim().toUpperCase()}const Le=15e3;async function Te(s){const i=new AbortController,j=window.setTimeout(()=>i.abort(),Le);try{const d=await fetch(`${ce}/oauth/device/info?user_code=${encodeURIComponent(s)}`,{credentials:"include",signal:i.signal}),x=await d.json().catch(()=>null);return{response:d,data:x}}catch(d){throw i.signal.aborted?new Error("Verification timed out. Check your connection and try again."):d}finally{window.clearTimeout(j)}}function q(s,i){return typeof s?.error_description=="string"&&s.error_description||typeof s?.error=="string"&&s.error||i}function ze(){const s=we.useSearch(),{session:i,isReady:j}=ye(),d=!j,[x,R]=c.useState(s.user_code||""),[r,m]=c.useState(null),[h,o]=c.useState(null),[a,le]=c.useState(null),[F,L]=c.useState(null),[T,U]=c.useState(null),[D,E]=c.useState(!1),[de,V]=c.useState(null),w=c.useRef(0),k=be(s.return_to),B=k?"app":"terminal",ue=!!s.user_code,N=M(x),l=F?.code===N?F:null,g=l!==null,C=l?.scopes??[],me=c.useMemo(()=>ke(C,T),[T,C]),$=C.some(t=>t.startsWith("mcp:")),G=C.includes("device_worker:run"),he=C.includes("connections:token"),Y=G||he,S=Ce(l?.resource),I=g&&$&&!S,J=l?.multiWorkspaceGrantsEnabled===!0,y=g&&G&&!S,{orgList:W,workspaceAccess:pe,setWorkspaceAccess:fe,selectedOrgIds:Q,toggleSelectedOrgId:ge,resetWorkspaceSelection:ve,deviceHomeOrgId:z,orgsLoading:O,orgsError:A,retryOrgs:K,workspaceSelectionReady:xe}=Ne({requireDeviceHome:y,deviceHomeOrgId:de,allowMultiple:J}),b=W.find(t=>t.id===z)??null,X=I?xe:!y||!O&&!A&&b!==null,P=c.useCallback(async t=>{const p=++w.current;m("verify"),o(null),E(!1);try{const{response:v,data:n}=await Te(t);if(p!==w.current)return;if(v.status===401){const f=new URL("/auth/login",window.location.origin);f.searchParams.set("callbackUrl",window.location.href),window.location.href=f.toString();return}if(!v.ok||!n)throw new Error(q(n,"Failed to verify device authorization code"));const u=Array.isArray(n.scopes)?n.scopes:[];L({code:t,clientName:n.client_name??null,logoUri:typeof n.logo_uri=="string"?n.logo_uri:null,clientUri:typeof n.client_uri=="string"?n.client_uri:null,scopes:u,resource:typeof n.resource=="string"?n.resource:null,multiWorkspaceGrantsEnabled:n.multi_workspace_grants_enabled===!0}),U(Se(u))}catch(v){if(p!==w.current)return;L(null),o(v instanceof Error?v.message:"Unexpected error")}finally{p===w.current&&m(null)}},[]);Ae(!!i,d),c.useEffect(()=>{if(!(d||!i||!s.user_code))return P(M(s.user_code)),()=>{w.current+=1}},[i,d,s.user_code,P]);const Z=async t=>{const p=N;if(!p){o(`Please enter the code shown in your ${B}.`);return}if(!g){o("Verify the device code before approving or denying access.");return}if(t&&Y&&!D){o("Confirm that you initiated this request and that the device code matches.");return}if(t&&!X){o(A?"Workspaces could not be loaded. Retry before approving.":y&&!b?"Choose a workspace for this device before approving.":"Choose at least one workspace before approving.");return}const v=l?.clientName??null,n=y&&b?ae(b):null;m(t?"approve":"deny"),o(null);try{const u=await fetch(`${ce}/oauth/device/approve`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({user_code:p,approved:t,...t?{scope:me.join(" ")}:{},...t&&I?{workspace_access:pe,organization_ids:Q}:{},...t&&y&&b?{organization_id:b.id}:{}})}),f=await u.json().catch(()=>null);if(u.status===401){const se=new URL("/auth/login",window.location.origin);se.searchParams.set("callbackUrl",window.location.href),window.location.href=se.toString();return}if(!u.ok)throw new Error(q(f,"Failed to process device authorization"));const ee=t?"approved":"denied";if(f?.status!==ee)throw new Error(q(f,t?"The server did not confirm this approval. The device is still waiting — try again.":"The server did not confirm this denial. Try again."));const te=typeof f.user_code=="string"?M(f.user_code):null;if(te!==null&&te!==p)throw new Error("The server confirmed a different device code. Re-check the code shown on your device.");m(null),le({outcome:ee,code:p,clientName:v,deviceHomeLabel:n})}catch(u){m(null),o(u instanceof Error?u.message:"Unexpected error")}};return c.useEffect(()=>{if(a?.outcome!=="approved"||!k)return;const t=window.setTimeout(()=>{window.location.href=k},600);return()=>window.clearTimeout(t)},[a,k]),d||!i?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking authentication..."})}):a?e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(oe,{className:"w-full max-w-lg",role:"status","aria-live":"polite",children:[e.jsxs(re,{children:[e.jsx(ne,{children:a.outcome==="approved"?ue?"Access Authorized":"Device Authorized":"Authorization Denied"}),e.jsx(ie,{children:a.outcome==="approved"?k?"You can close this tab and return to the Lobu app.":"You can close this tab and return to your terminal.":"The device was not authorized. You can close this tab."})]}),a.outcome==="approved"&&a.deviceHomeLabel?e.jsxs(H,{className:"text-sm text-muted-foreground",children:["This device now lives in ",a.deviceHomeLabel,". Change its workspace or share its connections from the device page under Connectors."]}):null,e.jsx(H,{className:"text-sm",children:e.jsxs("dl",{className:"space-y-1",children:[e.jsx("dt",{className:"text-muted-foreground",children:a.outcome==="approved"?"Approved code":"Denied code"}),e.jsx("dd",{className:"font-mono text-base tracking-widest text-foreground",children:a.code}),a.clientName?e.jsxs(e.Fragment,{children:[e.jsx("dt",{className:"text-muted-foreground",children:"Requested by"}),e.jsx("dd",{className:"text-foreground",children:a.clientName})]}):null]})})]})}):e.jsx("main",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center p-4",children:e.jsxs(oe,{className:"w-full max-w-lg",children:[e.jsxs(re,{children:[e.jsx(ne,{asChild:!0,children:e.jsx("h1",{children:g?"Authorize application":"Connect a device"})}),!g&&e.jsx(ie,{children:`Enter the code shown in your ${B}.`})]}),e.jsxs(H,{className:"space-y-5","aria-busy":r!==null,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"user-code",className:"text-sm font-medium",children:"Device code"}),e.jsx(je,{id:"user-code",value:x,disabled:r==="approve"||r==="deny",onChange:t=>{w.current+=1,R(t.target.value.toUpperCase()),L(null),U(null),ve(),V(null),E(!1),m(null),o(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!s.user_code})]}),y&&e.jsx(Ue,{deviceName:l?.clientName??null,orgList:W,deviceHomeOrgId:z,onChange:V,orgsLoading:O,orgsError:A,onRetry:K,disabled:r!==null}),l&&e.jsx(_e,{idPrefix:"oauth-device",clientName:l.clientName,requestedScopes:l.scopes,accessLevel:T,onAccessLevelChange:U,sensitiveScopesAcknowledged:D,onSensitiveScopesAcknowledgedChange:E,disabled:r!==null,resource:l.resource,logoUri:l.logoUri,clientUri:l.clientUri}),I&&e.jsx(Re,{idPrefix:"oauth-device",allowMultiple:J,orgList:W,selectedOrgIds:Q,onWorkspaceAccessChange:fe,onSelectedOrgChange:ge,orgsLoading:O,orgsError:A,onRetry:K,disabled:r!==null,deviceHomeOrgId:z}),g&&$&&S&&e.jsxs("section",{className:"rounded-md border border-primary/20 bg-primary/5 p-3 text-sm space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:["Workspace access: only ",S]}),e.jsx("p",{className:"text-muted-foreground",children:"This request is fixed to the workspace in the MCP resource URL."})]}),h&&e.jsx("p",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}),e.jsx("div",{className:"flex items-center justify-end gap-3",children:g?e.jsxs(e.Fragment,{children:[e.jsx(_,{type:"button",variant:"outline",onClick:()=>Z(!1),disabled:r!==null,children:r==="deny"?"Denying...":"Deny"}),e.jsx(_,{type:"button",onClick:()=>Z(!0),disabled:r!==null||!X||Y&&!D,children:r==="approve"?"Approving...":"Approve"})]}):e.jsx(_,{type:"button",onClick:()=>P(N),disabled:r!==null||!N,children:r==="verify"?"Verifying...":"Continue"})})]})]})})}function Ue({deviceName:s,orgList:i,deviceHomeOrgId:j,onChange:d,orgsLoading:x,orgsError:R,onRetry:r,disabled:m}){const h=i.find(o=>o.id===j)??null;return e.jsxs("section",{className:"space-y-2 rounded-md border border-primary/20 bg-primary/5 p-3 text-sm",children:[e.jsx("label",{htmlFor:"oauth-device-home",className:"block font-medium text-foreground",children:"Device workspace"}),x?e.jsx("p",{role:"status","aria-live":"polite",className:"text-muted-foreground",children:"Loading your workspaces..."}):R?e.jsxs("div",{role:"alert",className:"space-y-2 text-destructive",children:[e.jsx("p",{children:"Workspaces could not be loaded. Approval is unavailable until they load."}),e.jsx(_,{type:"button",variant:"outline",size:"sm",onClick:r,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("select",{id:"oauth-device-home",value:h?.id??"",disabled:m,onChange:o=>d(o.target.value),className:"flex h-9 w-full rounded-md border border-input bg-background px-3 text-sm focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[h?null:e.jsx("option",{value:"",disabled:!0,children:"Choose a workspace"}),i.map(o=>e.jsx("option",{value:o.id,children:ae(o)},o.id))]}),h&&!h.isPersonal?e.jsxs("p",{role:"note",className:"rounded-md bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-400",children:[s??"This device"," will be added to ",h.name,". Its Shell and Browser connections will be private to you — teammates can't use them unless you share them from the device page."]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"This applies to a newly paired device. A device that is already paired keeps its workspace; change it from the Devices page."})]})]})}export{ze as component};
|
|
2
|
-
//# sourceMappingURL=device-CKup7kvB.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,fg as y,r as f,ih as C,ii as k,fZ as g,B as A,L as E,c_ as I,ij as L,ik as N,il as P,u as w,im as F,f$ as O}from"./index-4gCDI7m4.js";import{a as R,R as S}from"./runs-panel-Bj63_hb9.js";import{c as v,C as $,b}from"./connector-scope-lists-BibdzKl1.js";function M({formRows:s=5}){return e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsx(R,{}),e.jsx(y,{rows:s})]})}function V({connection:s,connectorDef:t,ownerSlug:a,openSettings:n=!1,authResult:o,showActivity:r=!0,embedded:i=!1,showShare:c=!0}){const[l,d]=f.useState(n);f.useEffect(()=>{n&&d(!0)},[n]);const m=s.id,p=s.connector_key,u=s.facets?.chat??!1,h=u?"Channels":"Feeds",x=s.has_operations===!0,_=s.feed_count>0||v(t),j=e.jsx(P,{connection:s,connectorDef:t,ownerSlug:a,showShare:c});return e.jsxs("div",{className:"space-y-6",children:[o&&e.jsx(C,{result:o}),s.auth_profile_kind==="oauth_account"&&e.jsx(k,{connection:s,connectorDef:t,onReview:()=>{d(!0),requestAnimationFrame(()=>document.getElementById("connection-auth")?.scrollIntoView({block:"nearest"}))}}),(_||x)&&e.jsxs("div",{className:i?"space-y-6":"grid grid-cols-1 items-start gap-3 sm:grid-cols-2",children:[_&&(i?e.jsx(g,{title:h,count:s.feed_count===1?"1 source":`${s.feed_count} sources`,action:v(t)?e.jsx(A,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(E,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:p,connectionId:String(m)},search:{addFeed:!0},children:[e.jsx(I,{className:"h-3.5 w-3.5"}),u?"Add channel":"Add source"]})}):null,children:e.jsx($,{connection:s,ownerSlug:a,connectorKey:p,connectorDef:t})}):e.jsx(b,{connection:s,ownerSlug:a,title:h})),x&&(i?e.jsx(L,{connection:s,ownerSlug:a}):e.jsx(B,{connection:s,ownerSlug:a}))]}),i?e.jsx(N,{title:"Connection settings",summary:"name, visibility, credentials, remove",open:l,onOpenChange:d,children:j}):j,r&&!u&&e.jsx(g,{title:"Recent activity",children:e.jsx(S,{scope:{connectionId:m},ownerSlug:a})})]})}function B({connection:s,ownerSlug:t}){const a=w(),{data:n=[],isLoading:o,isError:r}=F(s.id),i=n.filter(l=>l.readiness==="scope_upgrade_required").length,c=o?"Loading actions…":r?"Could not load actions — open to retry":`${n.length} actions${i?` · ${i} need additional provider access`:" · permissions and approval policy"}`;return e.jsx(O,{title:"Actions",summary:c,onOpen:()=>a?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectionId:s.id,connectorKey:s.connector_key,organizationId:s.organization_id,ownerSlug:t}})})}const T=new Set(["Device was removed","Device was moved to another workspace"]);function H(s){const t=s.error_message??null;return!t||!T.has(t)?t:!!s.device_worker_id&&(s.device_last_seen_at!=null||s.device_worker_handle!=null||s.device_label!=null)?null:t}export{V as C,M as R,H as c};
|
|
2
|
-
//# sourceMappingURL=device-pin-tombstone-xGhCTU5_.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aS as Y,i3 as ne,i4 as U,r as j,j as e,i5 as L,B as b,aa as z,fW as C,aI as V,aC as te,fZ as I,S as R,b9 as B,dH as ae,dJ as ie,C as ce,dN as oe,i6 as re,a0 as le,v as de,aH as me,i7 as ue,i8 as xe,i9 as he,aK as pe,aD as fe,aL as P,b8 as q,L as E,ia as ge,ib as ve,aY as je,ic as ye,id as be,hq as Ne,W as ke,gk as _e,ie as K,I as we,be as Ce,bk as Se,gl as $e,gm as H,bo as De,ig as O,aA as Pe}from"./index-4gCDI7m4.js";import{c as G,C as Le,R as ze}from"./device-pin-tombstone-xGhCTU5_.js";import{R as Ie,S as Re,g as Ae}from"./runs-panel-Bj63_hb9.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-BibdzKl1.js";import"./status-dot-D3FoDRcc.js";import"./use-scroll-sentinel-Ct-jt7O0.js";import"./use-automations-BHoV0dLs.js";import"./clients-C7Lnuc3S.js";import"./runs-BPtQBTRN.js";import"./filter-bar-BQm-ubB1.js";import"./calendar-DMq3Dtqy.js";import"./table-DFcJRNk7.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(J(s,o).map(t=>t.connector_key));return n.filter(t=>Y(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function J(s,n){return s.organization_slug===n?s.update_required:[]}function Be(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Te({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=U(),[u,p]=j.useState(null),[g,a]=j.useState(null),[f,N]=j.useState(null),[v,d]=j.useState([]),x=s.organization_id===n,y=async i=>{p(null),N(null),a(i.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:i.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==i.key),{connectorKey:i.key,name:i.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:i.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},k=new Set(v.map(i=>i.connectorKey)),l=J(s,o),c=h.filter(i=>!k.has(i.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[v.map(i=>e.jsx(qe,{outcome:i,device:s,organizationId:n},i.connectorKey)),c.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:c.map(i=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[i.name,i.required_capability&&L[i.required_capability]&&L[i.required_capability]!==i.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[i.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${i.name}`,disabled:g!==null,onClick:()=>x?void y(i):p(i.key),children:[g===i.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===i.key?e.jsx(Z,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void y(i),onCancel:()=>p(null)}):null,f?.key===i.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},i.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(i=>e.jsx("li",{children:`${i.display_name} — this device has ${i.device_version}, this workspace uses ${i.workspace_version}`},i.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(i=>e.jsx("li",{children:`${i.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},i.connector_key))}):null]})}function Z({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const g=s.connector_count,a=s.connectors.filter(f=>f.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[g>0?`Moving pauses and unpins all ${g} connection${g===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(z,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function qe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=V(o,{connectionIds:[s.connectionId]}),r=h.find(p=>p.id===s.connectionId),t=C(n);if(m)return e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Checking ",s.name,"…"]});const u=[];if(!r)u.push(`${s.name} was created but could not be loaded yet.`);else if(r.status!=="active"){const p=G(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function W({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),g=new Map(r.map(d=>[d.key,d])),a=new Map,f=[];for(const d of s.connectors){if(d.organization_slug!==o)continue;const x=g.get(d.connector_key);if(!x||!Y(x)){f.push(d);continue}const y=x.required_capability??`connector:${x.key}`,k=a.get(y)??{key:y,name:x.name,connections:[]};k.name=L[y]??x.name,k.connections.push(d),a.set(y,k)}const N=Me(s,r,o),v=Be(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(R,{className:"h-24 w-full"}):u?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load capability settings."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void p(),children:"Retry"})]}):a.size===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No native connections on this device in this workspace."}):e.jsx("div",{className:"divide-y border-y",children:[...a.values()].map(d=>e.jsx(F,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Te,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:v}):null,B(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&f.length>0&&!t&&!u?e.jsxs(I,{title:"Apps and sources",count:String(f.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(f.map(d=>d.connector_key))].map(d=>e.jsx(F,{group:{key:d,name:g.get(d)?.name??d,connections:f.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d))})]}):null]})}function F({group:s,deviceId:n,organizationId:o,ownerSlug:h,definitionsByKey:m,selectedConnection:r,openSettings:t}){const u=s.connections.some(a=>a.connection_id===r),[p,g]=j.useState(u);return j.useEffect(()=>{u&&r!==void 0&&g(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:g,children:[e.jsxs(ie,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ce,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(Ke,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function Ke({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=V(o,{connectionIds:[s.connection_id]}),a=t.find(v=>v.id===s.connection_id&&v.device_worker_id===n),f=m?.name??s.connector_key,N=a?G(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":f,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(R,{className:"h-24 w-full"}):p?e.jsxs("div",{role:"alert",className:"space-y-2 text-sm",children:[e.jsx("p",{children:"Could not load this connection."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]}):a?e.jsxs(e.Fragment,{children:[N?e.jsx("p",{role:"alert",className:"mb-4 text-sm text-destructive",children:N}):null,e.jsx("div",{className:"mb-4",children:e.jsx(re,{connection:a})}),e.jsx(Le,{connection:a,connectorDef:m,ownerSlug:h,openSettings:r,showActivity:!1,showShare:!1,embedded:!0})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This connection is no longer available on this device."})]})}function He({device:s,ownerSlug:n}){const o=j.useId(),{data:h=[]}=le(),m=U(),[r,t]=j.useState(!1),[u,p]=j.useState(null),[g,a]=j.useState(null),f=h.filter(l=>l.is_member).map(l=>({id:l.id,name:l.name,isPersonal:l.is_personal===!0})),N=f.find(l=>l.id===s.organization_id),v=N?M(N):s.organization_name??"No workspace",d=f.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,y=()=>{t(!1),p(null)},k=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(c){a(c instanceof Error?c.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),v]}),!r&&d.length>0?e.jsx(b,{size:"sm",variant:"outline",onClick:()=>{a(null),t(!0)},children:"Change workspace"}):null]}),r?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("label",{htmlFor:o,className:"text-xs text-muted-foreground",children:"Move to"}),e.jsxs("select",{id:o,value:u??"",disabled:m.isPending,onChange:l=>p(l.target.value||null),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[e.jsx("option",{value:"",children:"Choose a workspace"}),d.map(l=>e.jsx("option",{value:l.id,children:M(l)},l.id))]}),x?null:e.jsx(b,{size:"sm",variant:"ghost",onClick:y,children:"Cancel"})]}):null,x?e.jsx(Z,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${v} to ${M(x)}?`,aftermath:`It is set up fresh in ${x.name}, with its connections there private to you until you share them.`,confirmLabel:"Move device",pending:m.isPending,onConfirm:()=>void k(x.id),onCancel:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function Oe({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=de(),{data:t=[],isLoading:u,isError:p,refetch:g}=me(),a=ue(),f=xe(),[N,v]=j.useState(!1),[d,x]=j.useState(!1),[y,k]=j.useState(""),l=he(t,n),c=l&&pe(l,s)?l:void 0,i=c?.id??n,{data:w=[]}=fe(o,{profileKind:"browser_session"}),S=j.useMemo(()=>w.filter(_=>_.device_worker_id===i&&_.status!=="revoked"),[w,i]),$=c?.label?.trim()??"";if(j.useEffect(()=>{d||k($)},[$,d]),u)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-6 w-6 rounded"}),e.jsx(R,{className:"h-5 w-40"})]}),e.jsx(ze,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]})});if(!c&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{platform:B(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(W,{device:l,organizationId:o,ownerSlug:s})]});if(!c)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(c),A=D?ve(s,D,je()):void 0,Q=B(c),X=ye(c.app_version),ee=be(c,X),T=()=>{const _=y.trim(),se=c.label?.trim()??"";if(_===se){x(!1);return}f.mutate({deviceWorkerId:c.id,label:_.length===0?null:_},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(_e,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:H,children:"Connectors"},"connectors"),...A?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:H,children:A.name},"app")]:[]]}),icon:e.jsx(q,{platform:Q,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:y,onChange:_=>k(_.target.value),placeholder:C({...c,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:_=>{_.key==="Enter"?(_.preventDefault(),N||T()):_.key==="Escape"&&(v(!1),k(c.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",c.connector_count>0?`and un-pins ${c.connector_count} connector${c.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(c.id,{onSuccess:()=>{v(!1),r({to:"/$owner/connectors",params:{owner:s},search:{}})}}),children:[a.isPending?e.jsx(z,{className:"mr-1.5"}):null,a.isPending?"Removing...":"Confirm remove"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>v(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:T,disabled:f.isPending,children:[f.isPending?e.jsx(z,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{k(c.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>v(!0),children:[e.jsx(Ce,{className:"mr-1.5 h-3.5 w-3.5"}),"Remove device"]})]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:[C(c),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{v(!1),k(c.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${c.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),c.online?c.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${K(new Date(c.last_seen_at),{addSuffix:!0})}${c.last_sync_at?` · Last sync ${K(new Date(c.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(He,{device:c,ownerSlug:s}),c.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0"}),c.connector_error_count," connector",c.connector_error_count===1?"":"s"," pinned to this device ",c.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(W,{device:c,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(I,{title:"Browser auth profiles",children:e.jsx(We,{profiles:S})}):null,e.jsx(I,{title:"Runs",children:e.jsx(Ie,{scope:{deviceId:i},ownerSlug:s})})]})})}function We({profiles:s}){return s.length===0?null:e.jsx("div",{className:"rounded-lg border",children:e.jsx("ul",{className:"divide-y",children:s.map(n=>e.jsxs("li",{className:"space-y-2 px-3 py-2.5 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-medium",children:n.display_name}),e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:n.connector_key??"Any connector"}),n.browser_kind?e.jsxs("span",{children:["· ",n.browser_kind]}):null,n.captured_at?e.jsxs("span",{title:n.captured_at,children:["· captured ",De(n.captured_at)]}):null,typeof n.cookie_count=="number"?e.jsxs("span",{children:["· ",n.cookie_count," cookie",n.cookie_count===1?"":"s"]}):null]})]}),e.jsx(Re,{status:n.is_expired?"error":Ae(n.status),showDot:!0,children:n.is_expired?"expired":n.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Refresh the session using the connector’s authorization instructions."})]},n.id))})})}function is(){const{owner:s,deviceId:n}=O.useParams(),{connection:o,settings:h}=O.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(Oe,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{is as component};
|
|
2
|
-
//# sourceMappingURL=device._deviceId-B1H_ivDT.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{v as x,au as C,j as e,bz as m,bA as _,bB as S,bC as b,bD as o,f6 as u}from"./index-4gCDI7m4.js";import{c as v}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:d,placeholder:p="Choose a connection",includeWorkspaceEvents:c=!1,ariaLabel:f="Connection"}){const g=x(),l=C().org?.slug,i=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;g({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(m,{value:r,onValueChange:j,disabled:d,children:[e.jsx(_,{"aria-label":f,children:e.jsx(S,{placeholder:p})}),e.jsxs(b,{children:[c?e.jsxs(e.Fragment,{children:[e.jsx(o,{value:"workspace",children:"Current workspace"}),i.length>0?e.jsx(u,{}):null]}):null,i.map(t=>e.jsx(o,{value:String(t.id),children:v(t)},t.id)),l?e.jsxs(e.Fragment,{children:[i.length>0||c?e.jsx(u,{}):null,e.jsx(o,{value:h,children:"Connect an app…"})]}):null]})]})}function w(s){const r=[];for(const n of s)typeof n.id=="number"&&r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...w(n.children));return r}export{y as C,w as f};
|
|
2
|
-
//# sourceMappingURL=entity-options-BSW_EG0W.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{db as ke,r as F,b_ as Ne,ji as R,fA as we,ec as se,j as e,B as w,u as Y,jc as Se,S as ae,fI as he,jj as Re,E as Fe,v as pe,b as Ee,b$ as B,au as De,i as Ce,ee as G,em as Le,jd as Be,jk as Pe,bk as $e,cb as ne,eM as Ie,fu as Me,fg as Ve,gY as Oe,gZ as Te,g_ as Ae,g$ as ze,h0 as Ue,jl as He,c2 as Ke,H,I as ie,ep as We,W as qe,fy as re,dG as K,gl as Ge,L as W,gm as q}from"./index-4gCDI7m4.js";import{R as Xe}from"./record-activity-D7bRaMk2.js";import{m as Ye,o as X,j as Qe,q as oe,h as Q,R as xe,r as Ze,t as Je,D as et,S as tt}from"./renderer-7EGgTVX0.js";import{r as st,V as at}from"./views-access-required-DHrDO333.js";import{S as nt,E as it}from"./entity-avatar-HloBoalJ.js";import{a as fe,V as le,M as rt,b as ot}from"./view-param-filters-mKoqDsaD.js";import{a as lt}from"./source-record-panels-Bh5F4C5K.js";import{r as ct,R as ce,b as dt}from"./event-card-Mcxv56DG.js";import{a as ut}from"./record-session-CWXnCVln.js";import"./filter-bar-BQm-ubB1.js";import"./calendar-DMq3Dtqy.js";import"./connection-label-BobuYiAG.js";import"./runs-BPtQBTRN.js";import"./clients-C7Lnuc3S.js";import"./client-activity-scopes-boZOHuPW.js";import"./client-rows-BJ2PxM4J.js";import"./events-feed-BysC9HgU.js";import"./use-scroll-sentinel-Ct-jt7O0.js";import"./use-automations-BHoV0dLs.js";import"./agent-loading-shells-Dnmb6W5Y.js";import"./member-scope-gate-vp3FihBD.js";import"./table-DFcJRNk7.js";import"./card-SFtxv9f2.js";import"./app-bridge-C4nPtae3.js";import"./json-diff-E5D-NGYT.js";import"./index-wHFQv1aT.js";import"./copy-button-2swYh4jb.js";function mt(t,s){if(t===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in t)return t;if(typeof t=="function")return{shouldBlockFn:async()=>await t(),enableBeforeUnload:!0,withResolver:!1};const i=!!(t.condition??!0),n=t.blockerFn;return{shouldBlockFn:async()=>i&&n!==void 0?await n():i,enableBeforeUnload:i,withResolver:n===void 0}}function ht(t,s){const{shouldBlockFn:i,enableBeforeUnload:n=!0,disabled:a=!1,withResolver:c=!1}=mt(t),r=ke(),{history:o}=r,[u,g]=F.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return F.useEffect(()=>{const p=async x=>{function l(f){const j=r.parseLocation(f),y=r.getMatchedRoutes(j.pathname);return y.foundRoute===void 0?{routeId:"__notFound__",fullPath:j.pathname,pathname:j.pathname,params:y.routeParams,search:r.options.parseSearch(f.search)}:{routeId:y.foundRoute.id,fullPath:y.foundRoute.fullPath,pathname:j.pathname,params:y.routeParams,search:r.options.parseSearch(f.search)}}const m=l(x.currentLocation),d=l(x.nextLocation);if(m.routeId==="__notFound__"&&d.routeId!=="__notFound__")return!1;const h=await i({action:x.action,current:m,next:d});if(!c)return h;if(!h)return!1;const N=await new Promise(f=>{g({status:"blocked",current:m,next:d,action:x.action,proceed:()=>f(!1),reset:()=>f(!0)})});return g({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),N};return a?void 0:o.block({blockerFn:p,enableBeforeUnload:n})},[i,n,a,c,o,r]),u}function A(t,s){return se(X(t))===se(X(s))}function pt(t,s){const i={};for(const n of new Set([...Object.keys(t),...Object.keys(s)]))A(t[n],s[n])||(i[n]=X(t[n])??null);return Object.keys(i).length>0?i:void 0}function xt(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(i=>{try{return!A(t[i],s[i])}catch{return!0}})}function de(t,s){return{name:t.name,slug:t.slug,metadata:Ye(t.metadata??{},s)}}function ft(t,s,i){const n=new Set(i),a={},c={},r=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const o of r){const u=n.has(o),g=u?t.values.metadata[o]:t.baseline.metadata[o],p=A(g,s.metadata[o])?g:s.metadata[o];p!==void 0&&(a[o]=p);let x=!1;if(!u)try{x=!A(t.values.metadata[o],t.baseline.metadata[o])}catch{x=!0}const l=x?t.values.metadata[o]:p;l!==void 0&&(c[o]=l)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:c}}}function gt({entity:t,schema:s,orgContext:i}){const n=F.useMemo(()=>de(t,s),[t,s]),a=Ne(R(t),n,s),c=we(i),{values:r,baseline:o,commit:u}=a,g=F.useMemo(()=>xt(r.metadata,o.metadata),[r.metadata,o.metadata]),p=r.name!==o.name||r.slug!==o.slug,x=F.useCallback((m,d)=>a.setValues(h=>({...h,metadata:{...h.metadata,[m]:d}})),[a.setValues]),l=async({note:m}={})=>{if(typeof t.id!="number")throw new Error("Source records are read-only");if(!a.canSubmit)return null;const d=pt(r.metadata,o.metadata),h=r.name.trim()!==o.name.trim();if(!d&&!p)return null;const N=await c.mutateAsync({entityId:t.id,name:h?r.name.trim():void 0,slug:r.slug,metadata:d,field_note:d&&m?.trim()||void 0}),f=de(N.entity,s);return u(j=>ft(j,f,Object.keys(d??{})),f),{held:N.blocked_fields??[],approvalUrl:N.approval_url}};return{values:r,baseline:o,revision:a.revision,setValues:a.setValues,setMetadataField:x,reset:a.reset,save:l,saving:c.isPending,dirtyKeys:g,identityDirty:p,isDirty:p||g.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const vt=3,jt=50;function ge(t){const s=F.useRef(null);return F.useEffect(()=>{t&&(s.current?.scrollIntoView?.({block:"start"}),s.current?.focus())},[t]),s}function I({headingRef:t,children:s}){return e.jsx("h3",{ref:t,tabIndex:-1,className:"text-xs font-medium uppercase tracking-wide text-muted-foreground outline-none",children:s})}function yt({entityId:t,entityName:s,ownerSlug:i,orgContext:n,focus:a,collapsed:c=!1}){const r=Y(),o=ge(a),{data:u,isLoading:g,isError:p,refetch:x}=Se(t,n,{limit:jt});if(t===void 0)return null;if(g)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx(ae,{className:"h-4 w-24"}),e.jsx(ae,{className:"h-6 w-full rounded-md"})]});if(p||!u)return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Could not load this record's links."," ",e.jsx("button",{type:"button",className:"underline",onClick:()=>void x(),children:"Retry"})]})]});if(u.countsByType.length===0&&!u.hasMore&&!u.failures?.length)return a?e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No links to other records yet."})]}):null;if(c){const l=u.countsByType.flatMap(m=>{const d=m.count===1?u.rows.find(h=>h.relationship_type_slug===m.relationship_type_slug):void 0;return d?[ct(d,m.relationship_type_name)]:[m.relationship_type_name,String(m.count)]});return e.jsxs("section",{className:"space-y-1","aria-label":"Linked records",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx(ce,{count:u.failures?.length??0,onRetry:()=>void x()}),e.jsx("p",{"data-testid":"linked-summary",className:"truncate text-sm text-muted-foreground",children:l.join(" · ")})]})}return e.jsxs("section",{className:"space-y-3","aria-label":"Linked records",children:[e.jsx(I,{headingRef:o,children:"Linked"}),e.jsx(ce,{count:u.failures?.length??0,onRetry:()=>void x()}),u.hasMore&&r?e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:()=>r.open({href:"",key:`record-links:${t}`,title:"Linked records",recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,label:"Linked records"}}),children:"Browse linked records"}):null,u.countsByType.map(l=>{const m=u.rows.filter(h=>h.relationship_type_slug===l.relationship_type_slug).slice(0,vt),d=l.count>m.length;return e.jsxs("div",{className:"space-y-1 text-sm",children:[d||m.length===0?e.jsxs("p",{className:"text-muted-foreground",children:[l.relationship_type_name,d?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",l.count,u.countsScope==="page"?" shown":""]}):null]}):null,e.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-1",children:[m.map(h=>e.jsx(dt,{row:h,label:l.relationship_type_name,entityId:t,ownerSlug:i,orgContext:n},h.id)),d&&r?e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>r.open({href:"",key:`record-links:${t}:${l.relationship_type_slug}`,title:`${l.relationship_type_name} · ${l.count}`,recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,relationshipType:l.relationship_type_slug,label:l.relationship_type_name}}),children:["Show all ",l.count]}):null]})]},l.relationship_type_slug)})]})}function bt({record:t,ownerSlug:s,orgContext:i,focus:n}){const[a,c]=F.useState(n),r=ge(n);return e.jsxs("section",{className:"space-y-2",children:[e.jsx(I,{headingRef:r,children:"Linked"}),a?e.jsx(lt,{record:t,ownerSlug:s,orgContext:i}):e.jsx(w,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>c(!0),children:"Find linked records"})]})}const _t="$name";function ve({outcome:t,schema:s}){if(!t||t.held.length===0)return null;const i=s?.properties??{},n=t.held.map(a=>a===_t?"Name":Qe(a,i[a]??{}));return e.jsxs("div",{role:"status",className:"rounded-md bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300",children:[n.join(", ")," ",n.length===1?"needs":"need"," approval before ",n.length===1?"it changes":"they change",".",t.approvalUrl?e.jsxs(e.Fragment,{children:[" ",e.jsx("a",{href:t.approvalUrl,className:"underline",children:"Review"})]}):null]})}const kt=320,Nt={},wt=()=>{};function St({view:t,orgSlug:s,recordUrl:i,scope:n}){const a=Y(),c=`${i}${he(t.key)}`,r=a?()=>a.open({href:c,title:t.name}):void 0;return e.jsxs("section",{className:"min-w-0 rounded-lg border","data-testid":"view-card","data-view":t.key,children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-4 pt-3 pb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-sm font-medium",children:t.name}),t.description?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description}):null]}),r?e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":`Open ${t.name}`,children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),"Open"]}):null]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(fe,{orgSlug:s,viewKey:t.key,scope:n,params:Nt,onParamsChange:wt,contentHash:t.content_hash,title:t.name,minHeight:64,displayMode:"inline",maxHeight:kt,onRequestDisplayMode:r?o=>{o==="fullscreen"&&r()}:void 0})})]})}function Rt({recordUrl:t,dirty:s,onDiscard:i}){const n=ht({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:c})=>c.pathname!==t&&!c.pathname.startsWith(`${t}${he("")}`)}),a=n.status==="blocked";return e.jsx(Oe,{open:a,onOpenChange:c=>{!c&&a&&n.reset()},children:e.jsxs(Te,{className:"max-w-sm",children:[e.jsxs(Ae,{children:[e.jsx(ze,{children:"Discard unsaved changes?"}),e.jsx(Ue,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{type:"button",variant:"ghost",onClick:()=>a&&n.reset(),children:"Keep editing"}),e.jsx(w,{type:"button",variant:"destructive",onClick:()=>{a&&(i(),n.proceed())},children:"Discard"})]})]})})}const ue=6;function Ft({entity:t,ownerSlug:s,orgContext:i,recordUrl:n,schema:a,entityTypeName:c,isTypeLoading:r,record:o,canEdit:u,editing:g,onEditingChange:p,outcome:x,onSaved:l,formId:m,fieldLimit:d,onDeleted:h}){const N=g&&u,f=Y(),j={entity:{id:R(t),name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:i,schema:a,record:o,editing:N};ut(j);const y=f?.item?.recordField,S={ownerSlug:s,orgContext:i,controls:t.field_controls,dirtyKeys:o.dirtyKeys,openField:f?E=>f.open(st(j,E.key)):void 0,openFieldKey:y?.entityId===R(t)?y.field:void 0},D=e.jsx(Rt,{recordUrl:n,dirty:N&&o.isDirty,onDiscard:()=>{o.reset(),p(!1)}});if(r)return e.jsx(Ve,{rows:6});if(N)return e.jsxs(e.Fragment,{children:[D,e.jsx(Et,{formId:m,entity:t,entityTypeName:c,schema:a,record:o,orgContext:i,renderControl:(E,b,C)=>Ze(b)?e.jsx(Je,{field:{key:E,prop:b},value:C,context:S}):void 0,onSaved:l,onDeleted:h,onDone:()=>p(!1)})]});const M=Q(o.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ve,{outcome:x,schema:a}),e.jsx(xe,{fields:M,fieldLimit:d,values:o.values.metadata,context:S})]})}function Et({formId:t,entity:s,entityTypeName:i,schema:n,record:a,orgContext:c,renderControl:r,onSaved:o,onDeleted:u,onDone:g}){const p=He(),x=s.field_controls,{name:l,slug:m,metadata:d}=a.values,h=v=>a.setValues(_=>({..._,name:v})),N=v=>a.setValues(_=>({..._,slug:v})),f=v=>a.setValues(_=>({..._,metadata:v})),[j,y]=B(R(s),""),[S,D]=B(R(s),null),[M,E]=B(R(s),null),[b,C]=B(R(s),!1),[P,$]=B(R(s),null),z=a.dirtyKeys.length>0,U=async v=>{if(v.preventDefault(),!!a.canSubmit){if(D(null),!l.trim()){D("Name is required");return}try{const _=await a.save({note:j});E(_),o(_),y(""),_?.held.length||g()}catch(_){D(_ instanceof Error?_.message:"Failed to update entity")}}},T=async()=>{$(null);try{if(typeof s.id!="number")throw new Error("Source records are read-only");await p.mutateAsync({entityId:s.id}),C(!1),u?.()}catch(v){$(v instanceof Error?v.message:"Failed to delete entity")}},L=[s.total_content>0&&`${s.total_content} content item${s.total_content===1?"":"s"}`,s.automations_count>0&&`${s.automations_count} Automation${s.automations_count===1?"":"s"}`,s.active_connections>0&&`${s.active_connections} connector${s.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return e.jsxs("form",{id:t,onSubmit:U,className:"space-y-4",children:[e.jsx(Ke,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(H,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ie,{id:"sidebar-name",value:l,onChange:v=>h(v.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(H,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(ie,{id:"sidebar-slug",value:m,onChange:v=>N(v.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(nt,{}),e.jsx(et,{schema:a.revision,values:d,onValuesChange:f,fieldControls:x,orgContext:c,renderControl:r})]}),z&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(H,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(We,{id:"sidebar-correction-note",value:j,onChange:v=>y(v.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),S&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:S}),e.jsx(ve,{outcome:M,schema:n}),b?e.jsxs("div",{className:"space-y-3 rounded-lg border border-destructive/40 bg-destructive/5 p-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5 text-sm",children:[e.jsx(qe,{className:"h-4 w-4 shrink-0 text-destructive mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-foreground",children:['Delete "',s.name,'"?']}),L&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",L,". This cannot be easily undone."]})]})]}),P&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:P}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:()=>{C(!1),$(null)},children:"Cancel"}),e.jsx(w,{type:"button",variant:"destructive",size:"sm",onClick:T,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${i||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(w,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>C(!0),children:"Delete"})})]})}function je(t,s){const i=new Set(t.measure_columns??[]),n=s?.properties??{};return Object.keys(t.metadata??{}).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&!Ie(n[a])&&n[a]?.const===void 0).map(a=>({key:a,prop:n[a]??{},label:n[a]?.["x-table-label"]??(i.has(a)?a:Me(a.replace(/_/g," "))),numeric:i.has(a)}))}function Dt({entity:t,schema:s,ownerSlug:i,fieldLimit:n}){const a=je(t,s);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx(xe,{fields:a,fieldLimit:n,values:t.metadata??{},context:{ownerSlug:i}})]})}const Ct=720,me="owletto:record-details-expanded";function Lt(){const[t,s]=F.useState(()=>{try{return window.localStorage.getItem(me)==="1"}catch{return!1}});return[t,n=>{s(n);try{window.localStorage.setItem(me,n?"1":"0")}catch{}}]}function Bt({schema:t,metadata:s}){const i=Q(t).filter(({key:n,prop:a})=>a["x-table-column"]===!0&&!a["x-image"]&&s[n]!==void 0&&s[n]!==null&&s[n]!=="");return i.length===0?null:e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:i.map(({key:n,prop:a},c)=>e.jsxs("span",{children:[c>0?" · ":null,e.jsx(tt,{value:s[n],prop:a})]},n))})}function Pt({namespace:t,entity:s,recordUrl:i,viewKey:n,title:a,onDeleted:c}){const r=Fe({strict:!1}),o=pe(),u=F.useRef(null),g=Ee(u,Ct),[p,x]=Lt(),[l,m]=B(R(s),!1),d={slug:t.slug,organizationId:t.id},{isMember:h,isLoading:N}=De(t.slug),f=Ce({...d,organizationId:h?t.id:null}),{data:j,isLoading:y}=G(s.entity_type,d),S=j?.metadata_schema,{isAdmin:D,isLoading:M}=Le(h?d.organizationId:void 0),E=h&&D&&!M&&!s.is_derived,b=gt({entity:s,schema:S,orgContext:d}),[C,P]=B(R(s),null),$=`record-form-${s.id}`,z=l&&E,U=h?f.data??[]:[],T=Be(U,{type:s.entity_type,id:R(s)}),L=Pe(T,n),v=!n&&r.tab==="relationships",_=k=>void o({to:".",search:k,replace:!0}),Z={type:s.entity_type,entity:s.is_derived?s.slug:s.id??s.slug},V=g&&!p&&!l&&!v,J=s.is_derived?oe(je(s,S),s.metadata??{}).length:oe(Q(b.revision),b.values.metadata).length,ee=V?ue:void 0,te=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx(Dt,{entity:s,schema:S,ownerSlug:t.slug,fieldLimit:ee}),e.jsx(bt,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:d,focus:v})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ft,{entity:s,ownerSlug:t.slug,orgContext:d,recordUrl:i,schema:S,entityTypeName:j?.name,isTypeLoading:y,record:b,canEdit:E,editing:l,onEditingChange:m,outcome:C,onSaved:P,formId:$,fieldLimit:ee,onDeleted:c}),e.jsx(yt,{entityId:typeof s.id=="number"?s.id:void 0,entityName:s.name,ownerSlug:t.slug,orgContext:d,focus:v,collapsed:V})]}),g&&!l&&!v?e.jsx(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!V,onClick:()=>x(V),children:V?J>ue?`Show all ${J} fields`:"Show all details":"Show fewer"}):null]}),ye=k=>e.jsx("div",{ref:u,className:"min-w-0 space-y-4",children:g?e.jsxs(e.Fragment,{children:[e.jsx(Bt,{schema:S,metadata:s.metadata??{}}),e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:te}),k]}):e.jsxs("div",{className:"grid grid-cols-[18rem_minmax(0,1fr)] gap-6",children:[e.jsx("aside",{className:"sticky top-12 max-h-[calc(100dvh-7rem)] min-w-0 self-start overflow-y-auto overscroll-contain pr-2 pb-16",children:te}),k]})}),be=z?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:()=>{b.reset(),P(null),m(!1)},children:"Cancel"}),e.jsx(w,{type:"submit",form:$,size:"sm",disabled:!b.canSubmit||!b.isDirty||b.saving||!b.values.name.trim(),children:b.saving?"Saving...":"Save"})]}):E&&!y?e.jsxs(w,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{P(null),m(!0)},children:[e.jsx($e,{className:"h-3.5 w-3.5"}),"Edit"]}):null,O=k=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"record-header",className:"sticky top-0 z-30 -mx-4 flex h-12 items-center justify-between gap-3 bg-background px-4 lg:-mx-6 lg:px-6",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-2",children:a}),be]}),k]});if(n&&!h)return O(N?null:e.jsx(at,{}));if(n&&f.data===void 0)return O(f.isError?e.jsx(le,{onRetry:()=>void f.refetch()}):null);if(L.kind==="missing")return O(e.jsx(rt,{viewKey:L.key,backTo:i,backLabel:`Back to ${s.name}`}));if(L.kind==="view"){const{view:k}=L;return O(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(ot,{decls:k.params,params:ne(r),onParamsChange:_e=>void o({to:".",search:_e})}),e.jsx(fe,{orgSlug:t.slug,viewKey:k.key,scope:Z,params:ne(r),onParamsChange:_,contentHash:k.content_hash,title:k.name,minHeight:320})]}))}return O(ye(e.jsxs("div",{className:"min-w-0 space-y-4",children:[h&&f.isError&&e.jsx(le,{onRetry:()=>void f.refetch()}),T.map(k=>e.jsx(St,{view:k,orgSlug:t.slug,recordUrl:i,scope:Z},k.key)),e.jsxs("section",{"aria-labelledby":"record-activity-heading",className:"min-w-0",children:[e.jsx("h2",{id:"record-activity-heading",className:"mb-2 text-sm font-medium text-muted-foreground",children:"Activity"}),e.jsx(Xe,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function $t(t){return t?.trim()?t:void 0}function cs({namespace:t,path:s,entity:i,viewKey:n}){const a=pe(),{data:c}=G(i.entity_type,{slug:t.slug}),r=s[0]?.entity_type??i.entity_type,{data:o}=G(r,{slug:t.slug}),u=$t(c?.icon),g=s.map(l=>({entity_type:l.entity_type,slug:l.slug})),p=`/${t.slug}/${re(i.entity_type)}`,x=K(t.slug,g);return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 pt-2.5 pb-8 lg:px-6",children:[e.jsx(Ge,{crumbs:[...r==="$member"?[]:[e.jsx(W,{to:"/$owner/data",params:{owner:t.slug},className:q,children:"Memory"},"memory")],e.jsx(W,{to:`/${t.slug}/${re(r)}`,className:q,children:r==="$member"?"Team":o?.name??r},"type"),...s.slice(0,-1).map((l,m)=>e.jsx(W,{to:K(t.slug,g.slice(0,m+1)),className:q,children:l.name},l.id))],current:i.name}),e.jsx(Pt,{namespace:t,entity:i,recordUrl:x,viewKey:n,title:e.jsxs(e.Fragment,{children:[e.jsx(it,{metadata:i.metadata,metadataSchema:c?.metadata_schema,name:i.name,typeIcon:u,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:i.name})]}),onDeleted:()=>{const l=s.slice(0,-1);l.length>0?a({to:K(t.slug,l)}):a({to:p})}})]})}export{cs as EntityPage};
|
|
2
|
-
//# sourceMappingURL=entity-page-D-WDWrAe.js.map
|