@lobu/runtime-server 22.0.0 → 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalogs/connectors.json +1448 -212
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +15 -2
- package/dist/connectors/google_gmail.ts +1 -0
- package/dist/connectors/jira-helpers.ts +313 -0
- package/dist/connectors/jira.ts +29 -221
- package/dist/connectors/linkedin-browser-script.ts +13 -0
- package/dist/connectors/linkedin-draft-page.js +104 -0
- package/dist/connectors/linkedin-drafts.ts +73 -0
- package/dist/connectors/linkedin-identity.ts +32 -0
- package/dist/connectors/linkedin-inbox-adapter.js +1182 -0
- package/dist/connectors/linkedin-inbox.ts +156 -0
- package/dist/connectors/linkedin-like.ts +114 -0
- package/dist/connectors/linkedin-takeout.ts +577 -0
- package/dist/connectors/linkedin.ts +4017 -0
- package/dist/connectors/reddit.ts +92 -20
- package/dist/connectors/slack.ts +1 -0
- package/dist/connectors/takeout-utils.ts +240 -0
- package/dist/connectors/tiktok-inbox-page.js +9 -9
- package/dist/connectors/tiktok-web-page.js +21 -15
- package/dist/connectors/tiktok_web.ts +63 -30
- package/dist/connectors/whatsapp-web-adapter.js +104 -574
- package/dist/connectors/whatsapp-web-helpers.ts +30 -444
- package/dist/connectors/whatsapp-web-identity.ts +20 -6
- package/dist/connectors/whatsapp_web.ts +46 -646
- package/dist/connectors/x-dm-adapter.js +556 -0
- package/dist/connectors/x-identity.ts +33 -2
- package/dist/connectors/x.ts +266 -120
- package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
- package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
- package/dist/db/migrations/20261019120000_retire_identities_of_deleted_entities.sql +21 -0
- package/dist/db/migrations/20261020120000_entities_live_metadata_domain.sql +66 -0
- package/dist/db/migrations/20261020130000_agents_starters.sql +14 -0
- package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +71 -0
- package/dist/dependencies.bun.lock +78 -75
- package/dist/guest.bundle.js +650 -448
- package/dist/owletto/dist/assets/_-CC8cTmRg.js +3 -0
- package/dist/owletto/dist/assets/_-ksFp4zVf.js +2 -0
- package/dist/owletto/dist/assets/_agentId-DWUFSrVp.js +2 -0
- package/dist/owletto/dist/assets/_agentId-MENLoohA.js +2 -0
- package/dist/owletto/dist/assets/_automationId-BnHqdXOC.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-CefXIqy2.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-C1QPGf9E.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-DinuPCUp.js +2 -0
- package/dist/owletto/dist/assets/{_deploymentId-BQfYN1U2.js → _deploymentId-BeyzVjRm.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-3L_qeL_l.js +2 -0
- package/dist/owletto/dist/assets/_name-Dgedji78.js +2 -0
- package/dist/owletto/dist/assets/_owner-DbrKma4e.js +3 -0
- package/dist/owletto/dist/assets/_shape-DtVfRFz_.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-CqLHzm7L.js +2 -0
- package/dist/owletto/dist/assets/_slug-ndDr_CUg.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-3CH5w8mr.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-DHQY9A8u.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-D3OgJG4i.js → accept-invitation-CRKbM2Xy.js} +2 -2
- package/dist/owletto/dist/assets/activity-route-view-CFLNukhD.js +2 -0
- package/dist/owletto/dist/assets/{agent-card-controls-DzRs4Ix9.js → agent-card-controls-Be1Okb2C.js} +2 -2
- package/dist/owletto/dist/assets/{agent-client-setup-list-B2SvH7xD.js → agent-client-setup-list-BA8dU_C6.js} +2 -2
- package/dist/owletto/dist/assets/agent-connect-pages-CAV-yXus.js +2 -0
- package/dist/owletto/dist/assets/agent-editor-form-Bi6WvYX-.js +2 -0
- package/dist/owletto/dist/assets/{agent-guardrails-route-BaV1VpDh.js → agent-guardrails-route-DMOjG1D4.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-CtZJM2Gc.js → agent-loading-shells-De_2d8Lr.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-Ds48KFK9.js → agent-permissions-matrix-gZWl6mAe.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-DPk5r08w.js → agent-skill-context-JLaTamGR.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-DYpB5H1J.js → agent-skills-route-DcK41PWj.js} +2 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-BBJoyTuC.js +2 -0
- package/dist/owletto/dist/assets/agent-thread-Buz3naVF.js +6 -0
- package/dist/owletto/dist/assets/agents-C-ReckCa.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-CqaKGggb.js +2 -0
- package/dist/owletto/dist/assets/app._appId-Cl1fTuIt.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-BMLL4lxO.js +2 -0
- package/dist/owletto/dist/assets/automations-C-ReckCa.js +2 -0
- package/dist/owletto/dist/assets/callback-DTKKsfkz.js +2 -0
- package/dist/owletto/dist/assets/{card-DIF8SF9b.js → card-yU0TmNRH.js} +2 -2
- package/dist/owletto/dist/assets/{claim-DELEa-gH.js → claim-DJfTvlT2.js} +2 -2
- package/dist/owletto/dist/assets/client-rows--FrZfJol.js +2 -0
- package/dist/owletto/dist/assets/{clients-CpG676mg.js → clients-L4K1UT8c.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-V27Z4o3P.js → code-editor-U54Gwjit.js} +2 -2
- package/dist/owletto/dist/assets/connect-4zqtnDHb.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-Dj0SqgbE.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-sgtocSvf.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-DTpSW1Xy.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-h9X5H1x8.js +2 -0
- package/dist/owletto/dist/assets/{connection-DySpRE9x.js → connection-ByvKkyFm.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-C_D68j6d.js → connection-feed-detail-DWM9lTao.js} +2 -2
- package/dist/owletto/dist/assets/connections-browser-CEwYrYqt.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-CNXtzYg5.js → connector-provenance-BocTm__v.js} +2 -2
- package/dist/owletto/dist/assets/connector-scope-lists-OYDOydtz.js +2 -0
- package/dist/owletto/dist/assets/connectors-CyZpcE5f.js +2 -0
- package/dist/owletto/dist/assets/{consent-BVzxrAO9.js → consent-DdfINrVp.js} +2 -2
- package/dist/owletto/dist/assets/{conversations-table-DfZGICl7.js → conversations-table-BSznfdYt.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-DiTpULFl.js → core.esm-Dr7tcIB-.js} +2 -2
- package/dist/owletto/dist/assets/create-CBGwASon.js +2 -0
- package/dist/owletto/dist/assets/create-Cf5hp6Z8.js +2 -0
- package/dist/owletto/dist/assets/create-CwThQtd3.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-9T5WnoUs.js +3 -0
- package/dist/owletto/dist/assets/create._connectorKey-sNHQHNpg.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-DPXl0qA2.js → cronstrue-BWFEyy_P.js} +2 -2
- package/dist/owletto/dist/assets/deployments-DHh9dyzv.js +2 -0
- package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-2xKS8gRo.js} +2 -2
- package/dist/owletto/dist/assets/{deployments-DCQdFdwG.js → deployments-wG_8QzOF.js} +2 -2
- package/dist/owletto/dist/assets/{device-CntqYW65.js → device-6z-xgsoW.js} +2 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-Cwq88RMU.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-BDerBfD9.js +2 -0
- package/dist/owletto/dist/assets/entity-avatar-Cc1CuI-0.js +2 -0
- package/dist/owletto/dist/assets/entity-options-DHdMC1Lx.js +2 -0
- package/dist/owletto/dist/assets/entity-page--OkXmlNP.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-89RoK_-P.js +2 -0
- package/dist/owletto/dist/assets/event-detail-D4YZRtrA.js +2 -0
- package/dist/owletto/dist/assets/events-feed-DsrkV2ix.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-B1_QUpg_.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-KpV2FS2u.js → full-page-spinner-Cqih-8IW.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-B8Rs1be3.js +2 -0
- package/dist/owletto/dist/assets/identity-B0nH4yiC.js +2 -0
- package/dist/owletto/dist/assets/index-4TSkcsth.js +2 -0
- package/dist/owletto/dist/assets/index-BSH07yVD.css +1 -0
- package/dist/owletto/dist/assets/index-BgkhXElB.js +2 -0
- package/dist/owletto/dist/assets/index-CoW4Bz3w.js +2 -0
- package/dist/owletto/dist/assets/index-Codw-Qqi.js +2 -0
- package/dist/owletto/dist/assets/{index-BNh2cidi.js → index-DAOyXG1X.js} +2 -2
- package/dist/owletto/dist/assets/{index-BEvyBdOU.js → index-DKPwCasf.js} +2 -2
- package/dist/owletto/dist/assets/index-DMyXd3bJ.js +2 -0
- package/dist/owletto/dist/assets/index-DYCqXaMf.js +7950 -0
- package/dist/owletto/dist/assets/index-DYYZLcJ0.js +2 -0
- package/dist/owletto/dist/assets/index-DYzWV5_z.js +2 -0
- package/dist/owletto/dist/assets/index-Da6CrGEu.js +2 -0
- package/dist/owletto/dist/assets/{index-DCdkwg9H.js → index-DfyDUpuI.js} +2 -2
- package/dist/owletto/dist/assets/index-DneshLbf.js +2 -0
- package/dist/owletto/dist/assets/index-TgRS2v_F.js +2 -0
- package/dist/owletto/dist/assets/{index-BJXkc60S.js → index-ZNlrDc_f.js} +2 -2
- package/dist/owletto/dist/assets/{json-diff-D_Ym3Uku.js → json-diff-DFvYINBT.js} +3 -3
- package/dist/owletto/dist/assets/{list-skeleton-Bl0OS39L.js → list-skeleton-DFsEqLU1.js} +2 -2
- package/dist/owletto/dist/assets/login-DO0j-AYr.js +2 -0
- package/dist/owletto/dist/assets/{logout-DUccApuZ.js → logout-BmNwoAf7.js} +2 -2
- package/dist/owletto/dist/assets/member-scope-gate-B2LrMWBU.js +2 -0
- package/dist/owletto/dist/assets/memory-browse-page-Cjpl8EbB.js +103 -0
- package/dist/owletto/dist/assets/{model-selector-CB1BDvlW.js → model-selector-TQcA93xm.js} +2 -2
- package/dist/owletto/dist/assets/models-D7aED5Sa.js +2 -0
- package/dist/owletto/dist/assets/new-BMrFy5Qa.js +2 -0
- package/dist/owletto/dist/assets/{new-B5UsLiy6.js → new-ByBhteWA.js} +2 -2
- package/dist/owletto/dist/assets/new-DWp3deoW.js +2 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-PGyTnW2K.js → oauth-workspace-access-D_5uESuz.js} +2 -2
- package/dist/owletto/dist/assets/{organization-BH8PYlVu.js → organization-DTFoYP4V.js} +2 -2
- package/dist/owletto/dist/assets/peek-pane-content-DF5iGC3c.js +2 -0
- package/dist/owletto/dist/assets/{permissions-CwN_YP3u.js → permissions-C_auqxfP.js} +2 -2
- package/dist/owletto/dist/assets/proposal-review-shell-DsNiavG_.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-B2NUI89V.js +2 -0
- package/dist/owletto/dist/assets/{recent-DqdZE_TI.js → recent-3d99S2IE.js} +2 -2
- package/dist/owletto/dist/assets/record-activity-C9KfBkXb.js +2 -0
- package/dist/owletto/dist/assets/record-field-peek-BBZcRuGT.js +2 -0
- package/dist/owletto/dist/assets/record-session-BizRugWs.js +2 -0
- package/dist/owletto/dist/assets/{reset-password-DAvBYkiI.js → reset-password-DqfcSn8M.js} +2 -2
- package/dist/owletto/dist/assets/runs-panel-T1ZxTVz6.js +2 -0
- package/dist/owletto/dist/assets/runs-table-D_8QlCCN.js +2 -0
- package/dist/owletto/dist/assets/schema-value-normalization-CylKX3PK.js +97 -0
- package/dist/owletto/dist/assets/settings-B_ClYztB.js +2 -0
- package/dist/owletto/dist/assets/settings-DgX1-xo7.js +2 -0
- package/dist/owletto/dist/assets/skills-Drw5tcZw.js +2 -0
- package/dist/owletto/dist/assets/{source-record-panels-CRIPMWfN.js → source-record-panels-Cg249m1S.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-DqEykWl_.js → use-mention-search-BYbFvHbJ.js} +2 -2
- package/dist/owletto/dist/assets/view-param-filters-DMSqkN2J.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +14031 -12680
- package/npm-shrinkwrap.json +329 -313
- package/package.json +6 -5
- package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
- package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
- package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
- package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
- package/vendor/connector-sdk/dist/index.d.ts +3 -0
- package/vendor/connector-sdk/dist/index.js +2 -0
- package/vendor/connector-sdk/package.json +9 -1
- package/vendor/core/dist/agent-policy.js +0 -3
- package/vendor/core/dist/agent-tooling.d.ts +1 -1
- package/vendor/core/dist/agent-tooling.js +3 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +0 -1
- package/vendor/core/dist/connector-query-errors.d.ts +32 -0
- package/vendor/core/dist/connector-query-errors.js +41 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +6 -2
- package/vendor/core/dist/contracts/agent-settings.js +12 -1
- package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +53 -234
- package/vendor/core/dist/contracts/tools/manage-views.js +50 -76
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +5 -8
- package/vendor/core/dist/contracts/tools/view-attach.js +14 -31
- package/vendor/core/dist/contracts/tools/view-definition.d.ts +21 -0
- package/vendor/core/dist/contracts/tools/view-definition.js +165 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +47 -133
- package/vendor/core/dist/contracts/worker/protocol.js +33 -62
- package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
- package/vendor/core/dist/device-pin-tombstones.js +57 -0
- package/vendor/core/dist/index.d.ts +3 -2
- package/vendor/core/dist/index.js +3 -1
- package/vendor/core/dist/logger.js +10 -25
- package/vendor/core/dist/suggestions.d.ts +15 -2
- package/vendor/core/dist/suggestions.js +48 -3
- package/vendor/core/dist/types.d.ts +26 -0
- package/vendor/core/dist/types.js +5 -0
- package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
- package/vendor/core/dist/worker/wire.d.ts +0 -10
- package/vendor/core/package.json +16 -10
- package/vendor/postgres/cf/src/connection.js +18 -0
- package/vendor/postgres/cjs/src/connection.js +18 -0
- package/vendor/postgres/src/connection.js +18 -0
- package/vendor/views/dist/api.d.ts +71 -17
- package/vendor/views/dist/api.js +200 -35
- package/vendor/views/dist/bridge.d.ts +3 -0
- package/vendor/views/dist/bridge.js +9 -1
- package/vendor/views/dist/components.d.ts +170 -0
- package/vendor/views/dist/components.js +361 -0
- package/vendor/views/dist/index.d.ts +1 -1
- package/vendor/views/package.json +11 -1
- package/dist/owletto/dist/assets/_-CEPl6gU4.js +0 -3
- package/dist/owletto/dist/assets/_-C_zNZben.js +0 -2
- package/dist/owletto/dist/assets/_agentId-CBC_SadO.js +0 -2
- package/dist/owletto/dist/assets/_agentId-QQW91cHX.js +0 -2
- package/dist/owletto/dist/assets/_automationId-YTTNksw6.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-fK0h7RAp.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-C7TPS598.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-CEhxlTIo.js +0 -2
- package/dist/owletto/dist/assets/_eventId-Cl8GSdjg.js +0 -2
- package/dist/owletto/dist/assets/_name-t3oBJ6Zf.js +0 -2
- package/dist/owletto/dist/assets/_owner-cUtGHqSw.js +0 -3
- package/dist/owletto/dist/assets/_shape-bo2lMVCu.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-Dwm4Q4wI.js +0 -2
- package/dist/owletto/dist/assets/_slug-CU1PuHB9.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-Bh6E_NxA.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-D4jKl-Zf.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-DQglkhXU.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-B6uKvT_X.js +0 -2
- package/dist/owletto/dist/assets/agent-editor-form-oUnIYHd7.js +0 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-B3K_jPYR.js +0 -2
- package/dist/owletto/dist/assets/agent-thread-C8UaUTWc.js +0 -6
- package/dist/owletto/dist/assets/agents-F4mGI2oF.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-CMyk4PI7.js +0 -2
- package/dist/owletto/dist/assets/app._appId-DH1Qutz6.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-CEDNboId.js +0 -2
- package/dist/owletto/dist/assets/automations-F4mGI2oF.js +0 -2
- package/dist/owletto/dist/assets/callback-CU-hb8JB.js +0 -2
- package/dist/owletto/dist/assets/client-rows-EJSKR6z1.js +0 -2
- package/dist/owletto/dist/assets/connect-B2YL6qIK.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-B6LDmDRV.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-D_HaKoI1.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-DQWcUqKM.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-BC3R303A.js +0 -2
- package/dist/owletto/dist/assets/connections-browser-Cnv2iBbZ.js +0 -2
- package/dist/owletto/dist/assets/connector-scope-lists-BKDetNDc.js +0 -2
- package/dist/owletto/dist/assets/connectors-BJnk1z_2.js +0 -2
- package/dist/owletto/dist/assets/create-CUqO6Kfk.js +0 -2
- package/dist/owletto/dist/assets/create-JRFM8mMf.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-_4vUkrls.js +0 -3
- package/dist/owletto/dist/assets/create-iHcxV0xd.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-CCYLEicg.js +0 -2
- package/dist/owletto/dist/assets/deployments-ihkhK1zV.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-Bz4JHHMK.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-D4plO3GM.js +0 -2
- package/dist/owletto/dist/assets/entity-options-UJs64GdQ.js +0 -2
- package/dist/owletto/dist/assets/entity-page-Djz6T50J.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-OznRag6A.js +0 -2
- package/dist/owletto/dist/assets/event-detail-04qOUGIP.js +0 -2
- package/dist/owletto/dist/assets/events-feed-fucGZSJR.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-DCQgGLyR.js +0 -2
- package/dist/owletto/dist/assets/guardrails-molekzAF.js +0 -2
- package/dist/owletto/dist/assets/identity-BJcaG66g.js +0 -2
- package/dist/owletto/dist/assets/index-B04ON9Jv.js +0 -2
- package/dist/owletto/dist/assets/index-BLEcy9-T.css +0 -1
- package/dist/owletto/dist/assets/index-BOsK-K-2.js +0 -2
- package/dist/owletto/dist/assets/index-BOzuAbvi.js +0 -2
- package/dist/owletto/dist/assets/index-Bk1x7A67.js +0 -2
- package/dist/owletto/dist/assets/index-CFnx5huL.js +0 -2
- package/dist/owletto/dist/assets/index-D3s8rhG9.js +0 -2
- package/dist/owletto/dist/assets/index-Dbd1jusf.js +0 -2
- package/dist/owletto/dist/assets/index-DqZuqC08.js +0 -2
- package/dist/owletto/dist/assets/index-Dr-Xg_xO.js +0 -2
- package/dist/owletto/dist/assets/index-KPOvMVa-.js +0 -2
- package/dist/owletto/dist/assets/index-_oPeVpL_.js +0 -7950
- package/dist/owletto/dist/assets/login-QHdxqX-4.js +0 -2
- package/dist/owletto/dist/assets/member-scope-gate-CFbrq1by.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-IrIXuZTF.js +0 -103
- package/dist/owletto/dist/assets/models-DnMb3n-Z.js +0 -2
- package/dist/owletto/dist/assets/new-BWo8_Pms.js +0 -2
- package/dist/owletto/dist/assets/new-DpmDXmFI.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-B2AFNTzP.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-DKKGu4Ww.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-7KYnww6e.js +0 -2
- package/dist/owletto/dist/assets/record-activity-CvgZyCmw.js +0 -2
- package/dist/owletto/dist/assets/renderer-BL6VcwQH.js +0 -97
- package/dist/owletto/dist/assets/runs-BWtc5rmc.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-BO3h5RkS.js +0 -2
- package/dist/owletto/dist/assets/runs-table-DxIiqrSk.js +0 -2
- package/dist/owletto/dist/assets/settings-4Ev-0iNL.js +0 -2
- package/dist/owletto/dist/assets/settings-Crxlwps-.js +0 -2
- package/dist/owletto/dist/assets/skills-D0X430X8.js +0 -2
- package/dist/owletto/dist/assets/status-dot-C5KDvvm9.js +0 -2
- package/dist/owletto/dist/assets/tabs-B4Er9hJj.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-Cylutoy1.js +0 -2
- package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
- package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
- /package/vendor/postgres/{.bun-tag-f39dafdb2305d504 → .bun-tag-2f292c6554a8475e} +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as i,j as e,bn as ie,bo as ce,bp as re,bq as le,br as F,I as oe,B as U,X as Zt,cN as gs,cL as ps,cg as es,gl as fs,gm as vs,S as Et,y as k,P as R,ae as $e,dM as At,dO as ys,dP as js,ft as _s,dv as ts,dQ as Ns,ei as ks,a$ as Ot,gn as bs,fe as nt,ck as qe,dd as st,fg as yt,a_ as ss,cy as Ge,cc as Ss,V as ws,H as Cs,cu as Es,go as As,gp as Os,gq as Fs,gr as Ps,gs as Ms,M as Ts,L as Ls,k as ns,gi as Ds,aZ as Rs,az as $s,gt as Is,ew as Ft,fV as qs,gu as Ks,bY as Bs,f3 as Ws,by as pt,a1 as zs,gv as Vs,gw as Us,gx as Qs,gy as Gs,gz as Js,gA as Hs,gB as Ys,gC as Xs,gD as Zs,gE as en,gF as tn,b0 as sn,bx as nn}from"./index-_oPeVpL_.js";import{c as an}from"./cronstrue-DPXl0qA2.js";import{C as on,f as cn}from"./entity-options-UJs64GdQ.js";import{M as rn}from"./model-selector-CB1BDvlW.js";import{b as ln}from"./skill-editor-D_W3QlRz.js";import{C as ft}from"./code-editor-V27Z4o3P.js";import{u as dn,b as Pt,c as Mt,s as un,o as mn,M as hn,d as xn,e as gn,f as pn,v as fn,r as vn}from"./use-mention-search-DqEykWl_.js";const et=[{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 yn(n){const t=n.trim();if(!t)return null;try{return an.toString(t,{throwExceptionOnParseError:!0})}catch{return null}}function jn({value:n,onChange:t,placeholder:s="No schedule",className:c}){const d=n??"",u=et.some(f=>f.value===d),[l,a]=i.useState(!u&&d!==""),g=f=>{f==="custom"?a(!0):(a(!1),t(f))},m=d?yn(d):null,S=d?e.jsx("p",{className:m?"text-xs text-muted-foreground":"text-xs text-destructive",children:m??"Not a valid cron expression."}):null;return!d&&!l?e.jsxs(ie,{onValueChange:g,children:[e.jsx(ce,{className:c??"w-full",children:e.jsx(re,{placeholder:s})}),e.jsx(le,{children:et.map(f=>e.jsxs(F,{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:[l?e.jsx(oe,{placeholder:"0 */6 * * *",value:d,onChange:f=>t(f.target.value),className:"font-mono text-sm flex-1"}):e.jsxs(ie,{value:d,onValueChange:g,children:[e.jsx(ce,{className:c??"w-full flex-1",children:e.jsx(re,{children:et.find(f=>f.value===d)?.label??d})}),e.jsx(le,{children:et.map(f=>e.jsxs(F,{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(U,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>{a(!1),t("")},children:e.jsx(Zt,{className:"h-4 w-4"})})]}),S]})}const dt="__all_workspace_event_types__",_n=[],Nn={};function Tt(n,t,s){const c=new Map;if(!t)for(const[u,l]of Object.entries(s??{}))c.set(u,{key:u,label:Ot(u),description:l.description});const d=[...n].filter(u=>!t||u.slug===t).sort((u,l)=>u.slug.localeCompare(l.slug));for(const u of d)for(const[l,a]of Object.entries(u.event_kinds??{})){const g=c.get(l);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(l,{key:l,label:Ot(l),description:a.description,metadataSchema:a.metadataSchema})}return[...c.values()].sort((u,l)=>u.label.localeCompare(l.label))}function Lt(n){const t=n[0];if(!t)return;const s=d=>JSON.stringify(Object.keys(d?.properties??{}).sort()),c=s(t);return n.every(d=>s(d)===c)?t:void 0}function Dt(n,t,s){const c=new Set(Object.keys(t.properties??{}));return{...Object.fromEntries(Object.entries(n).filter(([d])=>!c.has(d))),...s}}function Re(n,t,s){return s==="steer"&&(n==="window"||t!=="reply_to_source")?"coalesce":s}function Ue(n,t){return n==="window"?"silent":t}function Rt(n){return Object.fromEntries(Object.entries(n).filter(([t])=>t==="resource_ref"||t==="resource_type"))}function $t(n,t,s){const c=new Set(Object.keys(t?.properties??{})),d=new Set(s.flatMap(u=>Object.keys(u.filterSchema?.properties??{})));return Object.fromEntries(Object.entries(bs(n)).filter(([u])=>u==="resource_ref"||u==="resource_type"||!d.has(u)||c.has(u)))}function kn({value:n,options:t,onChange:s}){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":n===c.value,onClick:()=>s(c.value),className:R("rounded px-3 py-1 transition-colors",n===c.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:c.label},c.value))})}function It({events:n,selectedKeys:t,onToggle:s,ariaLabel:c="Events"}){const d=i.useId(),u=n.filter(a=>t.includes(a.key)).map(a=>a.label),l=u.length===0?"Choose events":u.length===1?u[0]:`${u.length} events selected`;return e.jsx(nt,{contentClassName:"w-[var(--radix-popover-trigger-width)] min-w-[280px]",searchPlaceholder:"Filter events...",emptyText:"No events found.",trigger:a=>e.jsxs(U,{type:"button",variant:"outline",role:"combobox","aria-label":c,"aria-expanded":a,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:R(u.length===0&&"text-muted-foreground"),children:l}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>n.map((a,g)=>{const m=t.includes(a.key),S=`${d}-${g}-state`;return e.jsxs(qe,{value:`${a.label} ${a.key}`,onSelect:()=>s(a.key),"aria-label":a.label,"aria-describedby":S,className:"cursor-pointer",children:[e.jsx(st,{className:R("mr-2 h-4 w-4",m?"opacity-100":"opacity-0")}),a.label,e.jsx("span",{id:S,className:"sr-only",children:m?"Selected":"Not selected"})]},a.key)})})}function bn({organizationId:n,initialTrigger:t,onChange:s,allowedKinds:c,showSectionHeader:d=!0,fieldIdPrefix:u="automation-trigger-"}){const l=gs(n,{status:"active",limit:500}),a=ps(n),g=es({organizationId:n}),m=fs({organizationId:n}),S=l.data??[],f=a.data??[],I=g.data??_n,x=m.data??Nn,j=i.useMemo(()=>I.filter(r=>r.organization_id===n),[I,n]),y=t?.kind==="event"&&t?.source==="workspace",w=y||t===void 0,M=c?.length?[...c]:["event","time","manual"],_=M.join("|"),T=(()=>{const r=t===null?"manual":t?.kind==="schedule"?"time":"event";return M.includes(r)?r:M[0]??"event"})(),[N,q]=i.useState(T),[J,de]=i.useState(y?"workspace":typeof t?.connection_id=="number"?String(t.connection_id):t?.kind==="event"&&t.connector_key?"":"workspace"),b=J==="workspace",H=b?"":J,[h,Q]=i.useState(typeof t?.entity_type=="string"?t.entity_type:""),se=i.useMemo(()=>Array.isArray(t?.event_types)?t.event_types:[],[t]),[L,ue]=i.useState(()=>se.filter(r=>typeof r=="string")),[W,xe]=i.useState(t?.match&&typeof t.match=="object"&&!Array.isArray(t.match)?t.match:{}),[ge,Pe]=i.useState(typeof t?.cron=="string"?t.cron:"0 9 * * 1-5"),fe=typeof t?.timezone=="string"?t.timezone:void 0,[O,pe]=i.useState(t?.kind==="schedule"||w&&t?.execution!=="turn"||t?.execution==="window"?"window":"turn"),[ne,Y]=i.useState(Ue(O,t?.output==="reply_to_source"?"reply_to_source":"silent")),[G,me]=i.useState(t?.kind==="schedule"||w&&t?.active_run!=="queue"?"coalesce":Re(O,ne,t?.active_run==="coalesce"||t?.active_run==="steer"?t.active_run:"queue")),[_e,Ke]=i.useState(t?.skip_if_unchanged!==!1),[we,p]=i.useState(!1);i.useEffect(()=>{const r=_.split("|");if(!r.includes(N)){const v=r[0]??"event";q(v),pe(v==="time"||v==="event"&&b?"window":"turn"),me(v==="time"||v==="event"&&b?"coalesce":"queue"),Y("silent")}},[_,N,b]);const K=S.find(r=>String(r.id)===H),X=l.isLoading||a.isLoading,he=g.isLoading,z=typeof t?.connector_key=="string"?t.connector_key:void 0,Z=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&typeof t.connection_id=="number"&&String(t.connection_id)===H&&!K,Ne=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&t.connection_id==null&&z!==void 0&&H==="",Oe=f.find(r=>r.key===(K?.connector_key??(Ne?z:void 0))),ve=Oe?.automation_events??[],Ce=ve.filter(r=>L.includes(r.key)),P=Ce[0],Fe=j.find(r=>r.slug===h),Be=[...j.filter(r=>Object.keys(r.event_kinds??{}).length>0||r.slug===h),...h&&!Fe?[{slug:h,name:h}]:[]],ee=i.useMemo(()=>Tt(j,h||void 0,x),[j,h,x]),Me=ee.filter(r=>L.includes(r.key)),Te=Me[0],ke=Lt(Ce.map(r=>r.filterSchema)),ye=Lt(Me.map(r=>r.metadataSchema)),be=!!(b&&h&&!Fe),Le=Z||Ne,Ee=(N==="event"?b?L.length>0&&!be:!!(L.length>0&&(H&&K||Le)):N==="time"?!!ge.trim():!0)&&(N!=="event"||!vs(W));i.useEffect(()=>{let r;if(Ee&&N==="event"&&!b){const v=$t(W,ke,Oe?.automation_events??[]);K||Ne?r={kind:"event",source:"connector",connector_key:K?.connector_key??z,...K?{connection_id:Number(H)}:{},event_types:L,...Object.keys(v).length>0?{match:v}:{},execution:O,active_run:Re(O,ne,G),output:Ue(O,ne),skip_if_unchanged:_e}:Z&&(r=t?{...t,source:"connector"}:void 0)}else if(Ee&&N==="event"&&b){const v=$t(W,ye,ee.map(E=>({filterSchema:E.metadataSchema})));r={kind:"event",source:"workspace",...h?{entity_type:h}:{},event_types:L,...Object.keys(v).length>0?{match:v}:{},execution:O,active_run:G==="queue"?"queue":"coalesce"}}else Ee&&N==="time"&&(r={kind:"schedule",cron:ge.trim(),...fe?{timezone:fe}:{},execution:"window",active_run:"coalesce",skip_if_unchanged:_e});s({ready:Ee,kind:N,trigger:r})},[G,H,K,ge,Oe,L,O,W,N,z,fe,t,b,s,ne,Ee,ke,ye,_e,h,ee,Ne,Z]);const He=r=>{const v=S.find(C=>String(C.id)===r),E=f.find(C=>C.key===v?.connector_key),ae=L.filter(C=>E?.automation_events?.some(De=>De.key===C)),te=E?.automation_events?.find(C=>C.key===ae[0]),$=v?.connector_key!==(K?.connector_key??z);if(de(r),ue(ae),!te)xe(Rt);else if($){const C=te.defaults?.execution??"turn",De=te.defaults?.activeRun??"queue",Ve=Ue(C,te.defaults?.output??"silent");xe(Rt),pe(C),me(Re(C,Ve,De)),Y(Ve)}},ot=r=>{if(r==="workspace"){de("workspace"),ue(v=>v.filter(E=>ee.some(ae=>ae.key===E))),xe({}),pe("window"),me("coalesce"),Y("silent");return}He(r)},it=r=>{const v=L.includes(r)?L.filter(C=>C!==r):ve.map(C=>C.key).filter(C=>C===r||L.includes(C));if(ue(v),v[0]===L[0])return;const E=ve.find(C=>C.key===v[0]),ae=E?.defaults?.execution??"turn",te=E?.defaults?.activeRun??"queue",$=Ue(ae,E?.defaults?.output??"silent");pe(ae),me(Re(ae,$,te)),Y($)},We=r=>{const v=r===dt?"":r,E=j.find(te=>te.slug===v),ae=Tt(j,E?.slug,x);Q(v),ue(te=>te.filter($=>ae.some(C=>C.key===$))),xe({})},Ye=r=>{ue(v=>v.includes(r)?v.filter(E=>E!==r):ee.map(E=>E.key).filter(E=>E===r||v.includes(E)))},ze=[{value:"event",label:"Event"},{value:"time",label:"Schedule"},{value:"manual",label:"Manual"}].filter(r=>M.includes(r.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(kn,{value:N,options:ze,onChange:r=>{q(r),pe(r==="time"||r==="event"&&b?"window":"turn"),me(r==="time"||r==="event"&&b?"coalesce":"queue"),Y("silent")}}):null,N==="event"?X||b&&he?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Et,{className:"h-9 w-full"}),e.jsx(Et,{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(on,{connections:S,value:J,onValueChange:ot,disabled:Le,includeWorkspaceEvents:!0,ariaLabel:"Source",placeholder:"Choose a source"}),Z?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."}):Ne?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]}),b?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(It,{events:ee,selectedKeys:L,onToggle:Ye}):e.jsx("div",{className:R($e,"px-3 py-2 text-sm text-muted-foreground"),children:h?"This entity type has no declared Automation events.":"This workspace has no declared Automation events."}),Te?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:Te.description}):null,be?e.jsxs("p",{className:"text-xs text-destructive",children:["This trigger filters on entity type “",h,"”, 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."})]}),ye?e.jsx(At,{schema:ye,values:W,onValuesChange:r=>xe(v=>Dt(v,ye,r)),fieldIdPrefix:`${u}workspace-`},`${h||"workspace"}:${L.join(",")}`):null]}):K||Ne?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:ve.length>1?"Events":"Event"}),ve.length?e.jsx(It,{events:ve,selectedKeys:L,onToggle:it}):e.jsx("div",{className:R($e,"px-3 py-2 text-sm text-muted-foreground"),children:"This connector has not published subscribable events."}),P?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:P.description}):null]}),typeof W.resource_ref=="string"||ke?e.jsxs("div",{className:"space-y-3",children:[typeof W.resource_ref=="string"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Resource"}),e.jsx("div",{className:R($e,"px-3 py-2 text-sm"),children:W.resource_ref})]}):null,ke?e.jsx(At,{schema:ke,values:W,onValuesChange:r=>xe(v=>Dt(v,ke,r)),fieldIdPrefix:u},L.join(",")):null]}):null]}):J?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(jn,{value:ge,onChange:Pe}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this Automation explicitly from Lobu, the API, CLI, or MCP."}),N!=="manual"&&!Le?e.jsxs(ys,{open:we,onOpenChange:p,children:[e.jsx(js,{asChild:!0,children:e.jsxs(U,{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(_s,{className:"h-4 w-4"}),"Trigger options",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",O==="turn"?"Each event":"Window"," ·"," ",N==="time"?"Combine":b?G==="queue"?"Queue":"Combine":G==="queue"?"Queue":G==="coalesce"?"Combine":"Update current run",N==="event"&&!b?` · ${O==="turn"&&ne==="reply_to_source"?"Reply":"Save in Lobu"}`:""]})]}),e.jsx(ts,{className:R("h-4 w-4 transition-transform",we&&"rotate-180")})]})}),e.jsxs(Ns,{className:"space-y-4 pt-3",children:[N==="event"&&b?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Entity type filter"}),e.jsxs(ie,{value:h||dt,onValueChange:We,children:[e.jsx(ce,{"aria-label":"Entity type filter",children:e.jsx(re,{})}),e.jsxs(le,{children:[e.jsx(F,{value:dt,children:"All event types"}),Be.map(r=>e.jsx(F,{value:r.slug,children:r.name},r.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(ie,{value:O,onValueChange:r=>{const v=r,E=Ue(v,ne);pe(v),Y(E),me(Re(v,E,G))},children:[e.jsx(ce,{children:e.jsx(re,{})}),e.jsxs(le,{children:[e.jsx(F,{value:"turn",children:"Start a run for each event"}),e.jsx(F,{value:"window",children:"Batch events into a window"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"When busy"}),e.jsxs(ie,{value:G,onValueChange:r=>me(r),children:[e.jsx(ce,{children:e.jsx(re,{})}),e.jsxs(le,{children:[e.jsx(F,{value:"queue",children:"Queue"}),e.jsx(F,{value:"coalesce",children:"Combine waiting events"}),!b&&O==="turn"&&ne==="reply_to_source"&&P?.capabilities?.steering?e.jsx(F,{value:"steer",children:"Update the current run"}):null]})]})]})]}):null,O==="window"&&(N==="time"||!b)?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(ks,{"aria-label":"Skip unchanged windows",checked:_e,onCheckedChange:Ke})]}):null,N==="event"&&!b&&O==="turn"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Result"}),e.jsxs(ie,{value:ne,onValueChange:r=>{const v=r;Y(v),me(Re(O,v,G))},children:[e.jsx(ce,{children:e.jsx(re,{})}),e.jsxs(le,{children:[P?.capabilities?.replyToSource?e.jsx(F,{value:"reply_to_source",children:"Reply where it happened"}):null,e.jsx(F,{value:"silent",children:"Save in Lobu"})]})]}),P?.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 Sn=16;function Ie(){return crypto.randomUUID()}function wn(n){return n===void 0?[{key:Ie(),initial:void 0}]:n.length===0?[{key:Ie(),initial:null}]:n.map(t=>({key:Ie(),initial:t}))}function as(n){return n?n.kind==="time"||n.trigger?.kind==="schedule":!1}function Cn(n,t){return n?n.ready===t.ready&&n.kind===t.kind&&JSON.stringify(n.trigger)===JSON.stringify(t.trigger):!1}function En(n,t){const s=n.map(a=>t[a.key]??{ready:!1,kind:"event"});if(!(n.length>1)&&s[0]?.kind==="manual")return{ready:s[0].ready,triggers:[]};const d=s.filter(as).length;return{ready:!s.some(a=>a.kind==="manual")&&d<=1&&s.length>0&&s.every(a=>a.ready&&a.trigger),triggers:s.filter(a=>a.trigger).map(a=>a.trigger)}}function na({organizationId:n,initialTriggers:t,onChange:s}){const c=i.useId(),[d,u]=i.useState(()=>wn(t)),[l,a]=i.useState({}),g=i.useRef("");i.useEffect(()=>{const x=En(d,l),j=JSON.stringify(x);j!==g.current&&(g.current=j,s(x))},[d,l,s]);const m=d.find(x=>as(l[x.key]))?.key??d.find(x=>x.initial&&typeof x.initial=="object"&&x.initial.kind==="schedule"&&!l[x.key])?.key??null,S=i.useCallback((x,j)=>{a(y=>Cn(y[x],j)?y:{...y,[x]:j})},[]),f=()=>{const x=d[0],j=x?l[x.key]:void 0;if(d.length===1&&(j?.kind==="manual"||x?.initial===null)){const y=Ie();a({}),u([{key:y,initial:void 0}]);return}u(y=>[...y,{key:Ie(),initial:void 0}])},I=x=>{if(d.length<=1){const j=Ie();a({}),u([{key:j,initial:null}]);return}a(j=>{const y={...j};return delete y[x],y}),u(j=>j.filter(y=>y.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,j)=>{const y=d.length>1,w=y?m&&m!==x.key?["event"]:["event","time"]:["event","time","manual"],M=l[x.key],_=y||(M?M.kind!=="manual":x.initial!==null);return e.jsxs("div",{className:R("space-y-3 rounded-lg border bg-card/40 p-3",y&&"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:y?`Trigger ${j+1}`:"Trigger"}),_?e.jsx(U,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive","aria-label":y?`Remove trigger ${j+1}`:"Clear trigger",onClick:()=>I(x.key),children:e.jsx(ss,{className:"h-3.5 w-3.5"})}):null]}),e.jsx(An,{slotKey:x.key,organizationId:n,initial:x.initial,kinds:w,fieldIdPrefix:`${c}-${x.key}-`,onChange:S})]},x.key)})}),e.jsxs(U,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:f,disabled:d.length>=Sn,children:[e.jsx(Ge,{className:"mr-1.5 h-3.5 w-3.5"}),"Add another trigger"]})]})}function An({slotKey:n,organizationId:t,initial:s,kinds:c,fieldIdPrefix:d,onChange:u}){const l=i.useCallback(a=>u(n,a),[u,n]);return e.jsx(bn,{organizationId:t,initialTrigger:s,allowedKinds:c,showSectionHeader:!1,fieldIdPrefix:d,onChange:l})}const qt={agents:!0,lobuEmbedded:!1};function On(){const{data:n}=Ss({queryKey:["features"],queryFn:async()=>{const t=await ws(`${Cs}/api/features`);return t.ok?t.json():qt},staleTime:3e4,refetchInterval:6e4});return n??qt}const Kt=["slack","imessage"],ut="__none__";function Qe(n){return`${n.connection_id}:${n.feed_key}`}function Fn(n){const t=n.indexOf(":");if(t<=0)return null;const s=Number(n.slice(0,t)),c=n.slice(t+1);return!Number.isSafeInteger(s)||s<=0||!c?null:{connection_id:s,channel_id:c}}function mt(n){return n?`${n.connection_id}:${n.channel_id}`:""}function tt(n){return`${n.display_name||n.feed_key} (${n.feed_key})`}function Pn({organizationId:n,agentId:t,value:s,onChange:c,disabled:d=!1,automationName:u,onPendingChange:l}){const{data:a=[],isLoading:g}=Es(n),m=mt(s),[S,f]=i.useState(null),[I,x]=i.useState(!1),j=i.useRef(t),y=i.useMemo(()=>a.filter(h=>h.store==="channel_messages"&&h.target_agent_id===t&&Kt.includes(h.connector_key)),[a,t]);i.useEffect(()=>{if(j.current===t||(j.current=t,f(null),x(!1),s==null))return;const h=mt(s);if(h==="")return;a.some(se=>se.store==="channel_messages"&&se.target_agent_id===t&&Kt.includes(se.connector_key)&&Qe(se)===h)||c(null)},[t,a,s,c]);const w=S??m,M=w===""?ut:w,_=y.find(h=>Qe(h)===w),T=S!==null&&S!==""&&S!==m;i.useEffect(()=>{l?.(T)},[T,l]);const N=_??(S?void 0:y.find(h=>Qe(h)===m)),q=h=>{const Q=h===ut?"":h;if(Q===""){f(null),x(!1),c(null);return}if(Q===m){f(null),x(!1);return}f(Q),x(!1)},J=h=>{if(x(h),h&&S){const Q=Fn(S);Q&&(f(null),c(Q))}else!h&&S&&f(null)},b=(s&&mt(s)!==""?s:void 0)??(_?{connection_id:_.connection_id,channel_id:_.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(ie,{value:M,onValueChange:q,disabled:d||g,children:[e.jsx(ce,{id:"automation-delivery-target",className:"font-mono text-sm",children:e.jsx(re,{placeholder:g?"Loading bound channels…":y.length===0?"No bound Slack or iMessage channels":"No digest — runs stay silent"})}),e.jsxs(le,{children:[e.jsx(F,{value:ut,children:"No digest — runs stay silent"}),y.map(h=>e.jsxs(F,{value:Qe(h),children:[tt(h)," · ",h.connector_key]},Qe(h)))]})]}):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&&y.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No Slack or iMessage channels are bound to this agent yet. Link a private channel first, then select it here."}):null,T&&_?e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:h=>J(h.target.checked),className:"mt-0.5","aria-label":`Confirm digest delivery to ${tt(_)}`}),e.jsxs("span",{className:"text-muted-foreground",children:["I confirm posting material-change digests to"," ",e.jsx("span",{className:"font-medium text-foreground",children:tt(_)}),". Destination changes are audited."]})]}):null,N||b?e.jsxs("div",{className:R($e,"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} ${tt(N)} · connection ${N.connection_id}`:`${b?.channel_id} · connection ${b?.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 Bt=4096;function Mn({open:n,onOpenChange:t,initial:s,onSubmit:c}){const[d,u]=i.useState(""),[l,a]=i.useState(""),[g,m]=i.useState(null);i.useEffect(()=>{n&&(u(s?.name??""),a(s?.query??""),m(null))},[n,s]);const S=()=>{const I=d.trim(),x=l.trim();if(!I){m("Give the SQL source a name.");return}if(!x){m("Enter a query.");return}if(x.length>Bt){m(`Query is too long (${x.length} chars, max ${Bt}).`);return}c({name:I,query:x}),t(!1)},f=!!s;return e.jsx(As,{open:n,onOpenChange:t,children:e.jsxs(Os,{className:"max-w-2xl",children:[e.jsxs(Fs,{children:[e.jsx(Ps,{children:f?"Edit SQL source":"SQL source"}),e.jsx(Ms,{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(oe,{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(ft,{value:l,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(U,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(U,{onClick:S,children:f?"Save":"Add source"})]})]})})}const Tn=["skill","feed","connection","connector","metric","entity_type"];function Ln({value:n,onChange:t,library:s,pinned:c,required:d,error:u,owner:l,agentId:a,sources:g,onAddSources:m}){const S=dn(Tn,Pt,{skills:s,skillAgentId:a||null}),f=i.useRef(null),[I,x]=i.useState(null),j=i.useMemo(()=>{if(!g)return[];const _=new Set(g.map(T=>T.query.trim()));return Mt(n).filter(T=>!_.has(T.query.trim()))},[n,g]),y=un(n),w=mn(c.filter(_=>y.includes(_.name)),s),M=s.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)"})]}),y.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[y.length,"/",Pt," skills"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-background focus-within:ring-1 focus-within:ring-ring",children:e.jsx(hn,{value:n,onChange:t,onSubmit:()=>{},submitOnEnter:!1,searchRefs:S,handleRef:f,onSqlRequest:()=>x({}),onSqlEdit:(_,T)=>x({initial:_,pos:T}),placeholder:M?"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(Mn,{open:I!==null,onOpenChange:_=>{_||x(null)},initial:I?.initial,onSubmit:_=>{f.current?.insertSql(_,I?.pos),x(null)}}),j.length>0&&m?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:[j.length===1?`"${j[0]?.name}" is referenced in the instructions but is not a source on this Automation.`:`${j.length} references in the instructions are not sources on this Automation.`," ","Editing an Automation does not add them automatically."]}),e.jsx(U,{type:"button",variant:"outline",size:"sm",onClick:()=>m(Mt(n,g)),children:j.length===1?"Add as a source":"Add as sources"})]}):null,y.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:y.map(_=>{const T=w.includes(_),N=!s.some(q=>q.name===_);return e.jsxs(Ts,{variant:N?"destructive":"secondary",className:"font-normal",children:[_,N?" · unavailable":T?" · newer text":null]},_)})}):null,w.length>0?e.jsxs("p",{className:"rounded-lg border border-dashed p-3 text-xs text-muted-foreground",children:[w.length===1?`"${w[0]}" has been edited since this Automation pinned it.`:`${w.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,!M&&a?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This agent has no skills yet."," ",e.jsx(Ls,{to:"/$owner/agents/$agentId/skills",params:{owner:l,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:M?"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 Dn=["connection","connector","feed","metric","entity_type"];function Rn({sources:n,onChange:t,disabled:s}){const{currentOwner:c,resolvedOrganizationId:d}=ns(),[u,l]=i.useState(""),{refs:a}=xn({owner:c,organizationId:d,kinds:Dn,query:u,limitPerKind:10});return e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Sources"}),n.length>0?e.jsx("ul",{className:"space-y-2",children:n.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(U,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${g.name}`,disabled:s,onClick:()=>t(n.filter(m=>m.query!==g.query)),children:e.jsx(Zt,{className:"h-3.5 w-3.5"})})]},g.query))}):null,e.jsx("div",{className:"flex gap-2",children:e.jsx(nt,{searchPlaceholder:"Search feeds, connections, metrics…",emptyText:"No matching reference.",onQueryChange:l,trigger:()=>e.jsxs(U,{type:"button",variant:"outline",size:"sm",disabled:s,children:[e.jsx(Ge,{className:"mr-2 h-3.5 w-3.5"}),"Add source"]}),children:g=>a.map(m=>e.jsxs(qe,{value:`${m.label} ${m.kind}`,onSelect:()=>{t(gn(m,n)),g()},children:[e.jsx("span",{className:"truncate text-sm",children:m.label}),e.jsx("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:m.kind})]},`${m.kind}:${m.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 $n({organizationId:n,value:t,onChange:s,className:c}){const{data:d=[]}=Ds(n),u=cn(d),l=u.find(a=>a.id===t);return e.jsx(nt,{contentClassName:"w-[300px]",searchPlaceholder:"Search entities...",emptyText:"No entities found.",trigger:a=>e.jsxs(U,{variant:"outline",role:"combobox","aria-expanded":a,className:R("w-full justify-between",c),children:[l?`${l.name} (${l.entityType})`:"All workspace",e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:a=>e.jsxs(e.Fragment,{children:[e.jsxs(qe,{value:"all workspace",onSelect:()=>{s(void 0),a()},className:"cursor-pointer",children:[e.jsx(st,{className:R("mr-2 h-4 w-4",t===void 0?"opacity-100":"opacity-0")}),e.jsx("span",{children:"All workspace"})]}),u.map(g=>e.jsxs(qe,{value:`${g.name} ${g.entityType}`,onSelect:()=>{s(g.id),a()},className:"cursor-pointer",children:[e.jsx(st,{className:R("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 vt(n){if(Array.isArray(n))return n;if(typeof n=="string"&&n.startsWith("{")&&n.endsWith("}")){const t=n.slice(1,-1);return t?t.split(",").map(s=>s.trim()):[]}return[]}const In=Vs.map(n=>({value:n,label:Us[n]})),Wt=[{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 zt(n){const t=!!(n?.prompt?.trim()||n?.skills?.some(c=>c.content.trim())),s=!!n?.reaction_script?.trim();return t&&s?"both":s?"code":"agent"}const qn=["text","number","date","boolean","json"],Kn=[{value:"key",label:"Key"},{value:"plain",label:"Plain"}],ht=[{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 Vt=0;function Bn(){return Vt+=1,`field-${Vt}`}function os(n={}){return{id:Bn(),name:n.name??"",type:n.type??"text",role:n.role??"plain"}}function Je(n){return n.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")}function Wn(n){return n?Object.keys(n).every(t=>["entity_type","entity_path","key_fields","key_output_field"].includes(t)):!0}function Ut(n){return n?Wn(n.keying_config)?"fields":"json":"fields"}function Qt(n){const t=n?.keying_config?.entity_type;return typeof t=="string"?t:""}function Gt(n){const t=n?.keying_config?.entity_path;return typeof t=="string"&&t.trim()?t:"$"}function Jt(n){const t=new Map,s=Array.isArray(n?.keying_config?.key_fields)?n?.keying_config?.key_fields:[];for(const c of s){if(typeof c!="string")continue;const d=Je(c);d&&t.set(d,os({name:d,role:"key"}))}return Array.from(t.values())}function je(n,t){const s=n?.execution_config?.[t];return typeof s=="number"||typeof s=="string"?String(s):""}function Ht(n,t,s){const c=n?.execution_config?.[t];return typeof c=="string"&&s.includes(c)?c:""}function xt(n,t){const s=n.trim();if(!s)return{};const c=Number(s);return Number.isFinite(c)?{value:c}:{error:`${t} must be a number.`}}function Yt({entityType:n,entityPath:t,fields:s}){const d=s.map(a=>({...a,name:Je(a.name)})).filter(a=>a.name).filter(a=>a.role==="key").map(a=>a.name),u=Je(n),l=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:l,key_fields:d,key_output_field:`${u}_key`}:void 0})}function zn(n,t){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:n}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t})]})}function Xt(n){return!!(n?.keying_config||n?.reactions_guidance||n?.model_config||n?.execution_config||n?.sources?.length||vt(n?.tags).length)}function Vn({organizationId:n,entityId:t,prefill:s,onSubmit:c,isSubmitting:d,error:u,isEditing:l,onCancel:a,triggerFields:g,submitLabel:m="Create Automation",submitDisabled:S=!1,triggers:f}){const{lobuEmbedded:I}=On(),{currentOwner:x}=ns(),{data:j=[]}=Rs(),{data:y=[]}=$s(),[w,M]=i.useState(s?.managed_agent_id??""),_=!!s?.managed_agent_id&&!l,T=Is(j)?.agentId??"",[N,q]=i.useState(s?.delivery_target??null),[J,de]=i.useState(!1),[b,H]=i.useState(s?.device_worker_id??""),[h,Q]=i.useState(s?.device_worker_id?"device":"agent"),[se,L]=i.useState(s?.agent_kind??""),{data:ue=[]}=es({organizationId:n}),[W,xe]=i.useState(s?.name??""),[ge,Pe]=i.useState(s?.slug??""),[fe,O]=i.useState(!!s?.slug),[pe,ne]=i.useState(s?.description??""),[Y,G]=i.useState(s?.prompt??""),[me,_e]=i.useState(!1),Ke=s?.skills??[],[we,p]=i.useState(s?.sources??[]),[K,X]=i.useState(s?.entity_id??t),[he,z]=i.useState(s?.reaction_script??""),[Z,Ne]=i.useState(()=>zt(s)),[Oe,ve]=i.useState(s?.keying_config?JSON.stringify(s.keying_config,null,2):""),[Ce,P]=i.useState(null),[Fe,Be]=i.useState(()=>Ut(s)),[ee,Me]=i.useState(()=>Qt(s)),[Te,ke]=i.useState(()=>Gt(s)),[ye,be]=i.useState(()=>Jt(s)),[Le,at]=i.useState(s?.reactions_guidance??""),[Ee,He]=i.useState(()=>je(s,"timeout_seconds")),[ot,it]=i.useState(()=>je(s,"max_budget_usd")),[We,Ye]=i.useState(()=>je(s,"model")),[Xe,ze]=i.useState(()=>Ht(s,"permission_mode",ht.map(o=>o.value))),[r,v]=i.useState(()=>je(s,"effort")),[E,ae]=i.useState(()=>je(s,"finalize_nudges")),[te,$]=i.useState(null),[C,De]=i.useState(vt(s?.tags).join(", ")),[Ve,jt]=i.useState(""),[ct,_t]=i.useState(!!(l||Xt(s)));i.useEffect(()=>{s&&(xe(s.name??""),Pe(s.slug??""),O(!!s.slug),ne(s.description??""),G(s.prompt??""),_e(!1),p(s.sources??[]),X(s.entity_id??t),H(s.device_worker_id??""),Q(s.device_worker_id?"device":"agent"),L(s.agent_kind??""),z(s.reaction_script??""),Ne(zt(s)),ve(s.keying_config?JSON.stringify(s.keying_config,null,2):""),P(null),Be(Ut(s)),Me(Qt(s)),ke(Gt(s)),be(Jt(s)),at(s.reactions_guidance??""),He(je(s,"timeout_seconds")),it(je(s,"max_budget_usd")),Ye(je(s,"model")),ze(Ht(s,"permission_mode",ht.map(o=>o.value))),v(je(s,"effort")),ae(je(s,"finalize_nudges")),$(null),De(vt(s.tags).join(", ")),jt(""),M(s.managed_agent_id??""),q(s.delivery_target??null),_t(!!(l||Xt(s))))},[s,t,l]);const is=fe?ge:Ft(W),{data:cs}=qs(w||null),{data:rs}=Ks(w||null,{enabled:!!w}),rt=ln(cs??null,rs?.catalog??[]),ls=pn(f),lt=he.trim().length>0,Ze=!l&&Z==="code"?"":Y,ds=!l&&Z==="agent"?void 0:he.trim()||void 0,Nt=(l||Z==="code")&<,kt=fn(Ze,rt,f,Nt),us=me||Ze.trim()!==""?kt:null,bt=vn(Ze,rt),St=!l&&Z!=="agent",wt=!!W.trim()&&!kt&&(!St||lt)&&!J,ms=ls&&!Nt&&bt.length===0,hs=()=>{if(!wt)return;let o;if(Fe==="fields"){const Se=Yt({entityType:ee,entityPath:Te,fields:ye});if(Se.error){P(Se.error);return}o=Se.keyingConfig,P(null)}else{if(Oe.trim())try{const Se=JSON.parse(Oe);if(typeof Se!="object"||Array.isArray(Se)){P("Keying config must be a JSON object.");return}o=Se}catch{P("Invalid JSON. Please check the syntax.");return}P(null)}const A=xt(Ee,"Timeout");if(A.error){$(A.error);return}if(A.value!==void 0&&(!Number.isInteger(A.value)||A.value<1)){$("Timeout must be a whole number greater than 0.");return}const B=xt(ot,"Budget");if(B.error){$(B.error);return}if(B.value!==void 0&&B.value<0){$("Budget cannot be negative.");return}const D=xt(E,"Finalize nudges");if(D.error){$(D.error);return}if(D.value!==void 0&&(!Number.isInteger(D.value)||D.value<0||D.value>5)){$("Finalize nudges must be a whole number from 0 to 5.");return}const Ae={...A.value!==void 0?{timeout_seconds:A.value}:{},...B.value!==void 0?{max_budget_usd:B.value}:{},...We.trim()?{model:We.trim()}:{},...Xe?{permission_mode:Xe}:{},...r.trim()?{effort:r.trim()}:{},...D.value!==void 0?{finalize_nudges:D.value}:{}},V=Object.keys(Ae).length>0||l?Ae:void 0;$(null);const xs=C.trim()?C.split(",").map(Se=>Se.trim()).filter(Boolean):void 0;c({slug:is,name:W.trim(),description:pe.trim()||void 0,prompt:Ze,skills:bt,entity_id:K,sources:we,reaction_script:ds,keying_config:o,reactions_guidance:Le.trim()||void 0,execution_config:V,tags:xs,outputs:s?.outputs,change_notes:Ve.trim()||void 0,managed_agent_id:h==="agent"?w.trim()||null:h==="device"&&(w.trim()||T)||null,device_worker_id:h==="device"&&b.trim()||null,agent_kind:h==="device"&&se.trim()||null,delivery_target:N})},Ct=e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-reaction",children:["Reaction Script"," ",St?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),e.jsx(ft,{value:he,onChange:z,language:"typescript",placeholder:"export default async function reaction(ctx) { ... }",minHeight:"120px"}),l?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."]})]});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:"*"})]}),!l&&e.jsx("button",{type:"button",onClick:()=>O(!fe),className:"text-xs text-muted-foreground hover:text-foreground",children:fe?"Use automatic slug":"Customize slug"})]}),e.jsx(oe,{id:"scratch-name",value:W,onChange:o=>xe(o.target.value),placeholder:"e.g., Escalation signals"}),!l&&fe?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-slug",children:"Slug"}),e.jsx(oe,{id:"scratch-slug",value:ge,onChange:o=>Pe(o.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:Ft(W)||"custom-slug"})]}):null]})}),l?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:Wt.map(o=>e.jsx("button",{type:"button","aria-pressed":Z===o.value,onClick:()=>Ne(o.value),className:R("rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors",Z===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:Wt.find(o=>o.value===Z)?.hint})]}),l||Z!=="code"?e.jsx(Ln,{value:Y,onChange:o=>{_e(!0),G(o)},library:rt,pinned:Ke,required:ms,error:us,owner:x??"",agentId:w,sources:l?we:void 0,onAddSources:l?p:void 0}):null,!l&&Z!=="agent"?Ct:null,l?e.jsx(Rn,{sources:we,onChange:p,disabled:d}):null,e.jsx("div",{className:"space-y-4",children:g}),e.jsx(Pn,{organizationId:n,agentId:h==="agent"?w.trim():"",value:N,onChange:q,disabled:d,automationName:W,onPendingChange:de}),J?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(U,{type:"button",variant:"ghost",className:"w-full justify-between px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-expanded":ct,"aria-controls":"automation-advanced-settings",onClick:()=>_t(o=>!o),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4"}),"Advanced settings"]}),e.jsx(ts,{className:R("h-4 w-4 transition-transform",ct&&"rotate-180")})]}),e.jsxs("div",{id:"automation-advanced-settings",className:R("space-y-4",!ct&&"hidden"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-description",children:"Description"}),e.jsx(oe,{id:"scratch-description",value:pe,onChange:o=>ne(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($n,{organizationId:n,value:K,onChange:X}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit this automation to one workspace entity."})]}),l?Ct: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(U,{type:"button",variant:"outline",size:"sm",onClick:()=>{if(Fe==="fields"){const o=Yt({entityType:ee,entityPath:Te,fields:ye});if(o.error){P(o.error);return}ve(o.keyingConfig?JSON.stringify(o.keyingConfig,null,2):""),Be("json")}else Be("fields");P(null)},children:Fe==="fields"?"Edit JSON":"Use fields"})]}),Fe==="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(nt,{contentClassName:"w-[320px]",searchPlaceholder:"Search or type a new type…",emptyText:"Type a name to create a new entity type.",trigger:o=>e.jsxs(U,{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:R("truncate",!ee&&"text-muted-foreground"),children:ee||"Select entity type"}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(o,A)=>{const B=Je(A),D=ue.filter(V=>!V.backing_sql),Ae=D.some(V=>V.slug===B);return e.jsxs(e.Fragment,{children:[D.map(V=>e.jsxs(qe,{value:`${V.name??V.slug} ${V.slug}`,onSelect:()=>{Me(V.slug),P(null),o()},className:"cursor-pointer",children:[e.jsx(st,{className:R("mr-2 h-4 w-4",ee===V.slug?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-mono text-sm",children:V.slug}),V.name&&V.name!==V.slug&&e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:V.name})]})]},V.slug)),B&&!Ae&&e.jsxs(qe,{value:A,onSelect:()=>{Me(B),P(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:B})]})]})]})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-output-path",children:"Output path"}),e.jsx(oe,{id:"scratch-output-path",value:Te,onChange:o=>{ke(o.target.value),P(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(U,{type:"button",variant:"outline",size:"sm",onClick:()=>{be(o=>[...o,os()]),P(null)},children:[e.jsx(Ge,{className:"mr-2 h-4 w-4"}),"Add field"]})]}),ye.length===0?e.jsx("div",{className:R($e,"px-3 py-2 text-sm text-muted-foreground"),children:"No output fields configured."}):e.jsx("div",{className:"space-y-2",children:ye.map(o=>e.jsxs("div",{className:R($e,"grid gap-2 p-3 sm:grid-cols-[minmax(0,1fr)_128px_minmax(0,240px)_auto]"),children:[e.jsx(oe,{value:o.name,onChange:A=>{const B=Je(A.target.value);be(D=>D.map(Ae=>Ae.id===o.id?{...Ae,name:B}:Ae)),P(null)},placeholder:"severity","aria-label":"Output field name",className:"font-mono text-sm"}),e.jsxs(ie,{value:o.type,onValueChange:A=>{be(B=>B.map(D=>D.id===o.id?{...D,type:A}:D))},children:[e.jsx(ce,{"aria-label":"Output field type",children:e.jsx(re,{})}),e.jsx(le,{children:qn.map(A=>e.jsx(F,{value:A,children:A},A))})]}),e.jsx("div",{className:"grid grid-cols-2 rounded-md border border-input bg-background p-1",children:Kn.map(A=>e.jsx("button",{type:"button",onClick:()=>{be(B=>B.map(D=>D.id===o.id?{...D,role:A.value}:D)),P(null)},className:R("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(U,{type:"button",variant:"ghost",size:"icon",onClick:()=>{be(A=>A.filter(B=>B.id!==o.id)),P(null)},"aria-label":"Remove output field",children:e.jsx(ss,{className:"h-4 w-4"})})]},o.id))})]}),Ce&&e.jsx("p",{className:"text-xs text-destructive",children:Ce})]}):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(ft,{value:Oe,onChange:o=>{ve(o),P(null)},language:"json",placeholder:'{ "entity_type": "topic", "entity_path": "$.items[*]", "key_fields": ["name"], "key_output_field": "entity_key" }',minHeight:"60px"}),Ce&&e.jsx("p",{className:"text-xs text-destructive",children:Ce})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-reactions-guidance",children:"Reactions Guidance"}),e.jsx(Ws,{id:"scratch-reactions-guidance",value:Le,onChange:o=>at(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:[zn("Run settings","Choose where the automation runs and the budget it can use."),!_&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-runs-on",children:"Runs on"}),e.jsxs(ie,{value:h,onValueChange:o=>Q(o),children:[e.jsx(ce,{id:"scratch-runs-on",className:"text-sm",children:e.jsx(re,{})}),e.jsxs(le,{children:[e.jsx(F,{value:"agent",children:"Managed agent"}),e.jsx(F,{value:"device",children:"On a device"}),e.jsx(F,{value:"manual",children:"Manual-only"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:h==="agent"?"Automated runs dispatch to a managed Lobu agent.":h==="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."})]}),!_&&h!=="manual"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-agent-id",children:"Agent"}),I?e.jsxs(ie,{value:w||(h==="device"?T:"")||"__unselected__",onValueChange:o=>{M(o==="__unselected__"?"":o)},children:[e.jsx(ce,{id:"scratch-agent-id",className:"font-mono text-sm",children:e.jsx(re,{placeholder:"Select a Lobu agent"})}),e.jsx(le,{children:j.map(o=>e.jsxs(F,{value:o.agentId,children:[o.name," (",o.agentId,")"]},o.agentId))})]}):e.jsx(oe,{id:"scratch-agent-id",value:w,onChange:o=>{M(o.target.value)},placeholder:h==="device"&&T?T:"e.g., agent-123",className:"font-mono text-sm"}),h==="device"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"The device run acts as this agent for memory and tools."})]}),!_&&h==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-id",children:"Device"}),e.jsxs(ie,{value:b||"__unselected__",onValueChange:o=>H(o==="__unselected__"?"":o),children:[e.jsx(ce,{id:"scratch-device-id",className:"font-mono text-sm",children:e.jsx(re,{placeholder:"Select a device worker"})}),e.jsx(le,{children:y.map(o=>e.jsx(F,{value:o.id,children:o.label||o.platform||o.id},o.id))})]})]}),!_&&h==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-agent-kind",children:"Runs as"}),e.jsxs(ie,{value:se||"__default__",onValueChange:o=>L(o==="__default__"?"":o),children:[e.jsx(ce,{id:"scratch-device-agent-kind",className:"text-sm",children:e.jsx(re,{placeholder:"Device default"})}),e.jsxs(le,{children:[e.jsx(F,{value:"__default__",children:"Device default"}),In.map(o=>e.jsx(F,{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(rn,{value:We,onChange:o=>{Ye(o),$(null)},placeholder:"Use agent default"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-timeout",children:"Timeout seconds"}),e.jsx(oe,{id:"scratch-timeout",type:"number",min:1,max:86400,value:Ee,onChange:o=>{He(o.target.value),$(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(ie,{value:Xe||"__default__",onValueChange:o=>{ze(o==="__default__"?"":o),$(null)},children:[e.jsx(ce,{id:"scratch-permission-mode",children:e.jsx(re,{placeholder:"Default"})}),e.jsxs(le,{children:[e.jsx(F,{value:"__default__",children:"Default"}),ht.map(o=>e.jsx(F,{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(oe,{id:"scratch-effort",value:r,onChange:o=>{v(o.target.value),$(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(oe,{id:"scratch-finalize-nudges",type:"number",min:0,max:5,value:E,onChange:o=>{ae(o.target.value),$(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(oe,{id:"scratch-tags",value:C,onChange:o=>De(o.target.value),placeholder:"ops, support, risk"})]}),l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-change-notes",children:"Change notes"}),e.jsx(oe,{id:"scratch-change-notes",value:Ve,onChange:o=>jt(o.target.value),placeholder:"What changed in this version?"})]})]})]}),u&&!Ce&&!te&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u}),e.jsx(pt,{onCancel:a,children:e.jsx(U,{onClick:hs,disabled:!wt||d||S,children:d?e.jsxs(e.Fragment,{children:[e.jsx(zs,{size:"lg",className:"mr-2"}),l?"Saving...":"Creating..."]}):l?"Save Automation":m})})]})}function Un(n,t){const s=n??null,c=t??null;return s===null||c===null?s===c:s.connection_id===c.connection_id&&s.channel_id===c.channel_id}function Qn(n){const t=n.detail??{};return{name:n.name,slug:t.slug,description:t.description??n.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 aa({startFromScratch:n=!1,onClose:t,hideCancel:s=!1,hideHeader:c=!1,organizationId:d,entityId:u,entityName:l,prefillAgentId:a,onSuccess:g,editingAutomation:m,catalogPrefill:S,onDraft:f,triggerFields:I,submitLabel:x,submitDisabled:j,createFields:y,onPrefillTriggers:w}){const M=Qs(),_=Gs(),T=Js(),N=Hs(),q=!!m,[J,de]=i.useState(n?"scratch":"template"),[b,H]=i.useState(void 0),[h,Q]=i.useState(void 0),{data:se=[],isLoading:L}=Ys(),[ue,W]=i.useState(""),xe=i.useMemo(()=>a?{managed_agent_id:a}:void 0,[a]),ge=i.useMemo(()=>se.map(p=>({key:p.id,name:p.name,description:p.description??"",badges:p.detail?.tags??[]})),[se]),Pe=i.useMemo(()=>ge.filter(p=>p.name.toLowerCase().includes(ue.toLowerCase())||p.description.toLowerCase().includes(ue.toLowerCase())),[ge,ue]),fe=p=>{const K=se.find(he=>he.id===p.key);if(!K)return;const X=Qn(K);Q(a?{...X,managed_agent_id:a}:X),w?.(X.triggers??[]),de("scratch")},O=()=>{M.reset(),_.reset(),de("template"),H(void 0),Q(void 0),t()},pe=q?y?.triggers??m.triggers??[]:y?.triggers??h?.triggers??S?.triggers??[],ne=async p=>{try{if(f){await f(p);return}if(q){const K=y?.triggers??m.triggers??[],X=m.reaction_script??"",he=p.reaction_script??"";he&&he!==X&&await T.mutateAsync({automation_id:m.automation_id,reaction_script:he}),await _.mutateAsync({automation_id:m.automation_id,name:p.name,description:p.description,prompt:p.prompt,sources:p.sources,set_as_current:!0,triggers:K,keying_config:p.keying_config,reactions_guidance:p.reactions_guidance,change_notes:p.change_notes}),!he&&X&&await T.mutateAsync({automation_id:m.automation_id,reaction_script:""});const z={};p.model_config!==void 0&&(z.model_config=p.model_config),p.execution_config!==void 0&&(z.execution_config=p.execution_config),p.tags!==void 0&&(z.tags=p.tags),p.delivery_target!==void 0&&!Un(p.delivery_target,m.delivery_target)&&(z.delivery_target=p.delivery_target),p.managed_agent_id!==void 0&&(z.managed_agent_id=p.managed_agent_id||null),p.agent_kind!==void 0&&(z.agent_kind=p.agent_kind||null),p.device_worker_id!==void 0&&(z.device_worker_id=p.device_worker_id||null),Object.keys(z).length>0&&await N.mutateAsync({automation_id:m.automation_id,...z}),O(),g?.(m.automation_id)}else{const K=y?.triggers??h?.triggers??S?.triggers??[],X=await M.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:K});O(),X.automation_id&&g?.(X.automation_id)}}catch{}},Y=q?_:M;let G="Add an automation";q?G="Edit automation configuration (saves as a new version)":l&&(G=`Add an automation for ${l}`);const me=m?{entity_id:m.entity_id,name:m.name,slug:m.slug,description:m.description,prompt:m.prompt,sources:m.sources,reaction_script:m.reaction_script,device_worker_id:m.device_worker_id??void 0,agent_kind:m.agent_kind??void 0,keying_config:m.keying_config,reactions_guidance:m.reactions_guidance,model_config:m.model_config,execution_config:m.execution_config,tags:m.tags,managed_agent_id:m.managed_agent_id??void 0,delivery_target:m.delivery_target??void 0}:void 0,_e=q?"Edit Automation":"Create Automation",Ke=e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:_e}),e.jsx("p",{className:"text-sm text-muted-foreground",children:G})]}),we=e.jsxs("div",{className:"py-6 space-y-6",children:[!q&&e.jsxs("div",{className:"flex flex-wrap justify-start gap-2",children:[e.jsx(gt,{active:J==="template",onClick:()=>de("template"),icon:e.jsx(Xs,{className:"h-4 w-4"}),label:"From templates"}),e.jsx(gt,{active:J==="scratch",onClick:()=>{de("scratch"),H(void 0),Q(void 0)},icon:e.jsx(Ge,{className:"h-4 w-4"}),label:"From scratch"}),e.jsx(gt,{active:J==="clone",onClick:()=>de("clone"),icon:e.jsx(Zs,{className:"h-4 w-4"}),label:"Clone existing"})]}),!q&&J==="template"?e.jsxs(e.Fragment,{children:[L?e.jsx(en,{}):e.jsx(tn,{items:Pe,searchQuery:ue,onSearchChange:W,onSelect:fe,searchPlaceholder:"Search templates...",searchAriaLabel:"Search automation templates",emptyMessage:ge.length===0?"No automation templates available.":void 0}),c&&!s?e.jsx(pt,{onCancel:O}):null]}):!q&&J==="clone"&&!b?e.jsxs(e.Fragment,{children:[e.jsx(Gn,{organizationId:d,onSelect:p=>{H(p),w?.(p.triggers??[]),de("scratch")}}),c&&!s?e.jsx(pt,{onCancel:O}):null]}):e.jsx(Vn,{organizationId:d,entityId:u,prefill:me??b??h??S??xe,onSubmit:ne,isSubmitting:Y.isPending,error:Y.error?Y.error.message:null,isEditing:q,onCancel:s?void 0:O,triggerFields:I,submitLabel:x,submitDisabled:j,triggers:pe})]});return e.jsxs("div",{className:"flex flex-col",children:[c?null:Ke,we]})}function gt({active:n,onClick:t,icon:s,label:c}){return e.jsxs("button",{type:"button",onClick:t,className:R("flex items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors",n?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[s,c]})}function Gn({organizationId:n,onSelect:t}){const{data:s,isLoading:c}=sn(n),[d,u]=i.useState(""),l=(s||[]).filter(a=>a.name?.toLowerCase().includes(d.toLowerCase()));return c?e.jsx(nn,{label:"automations",variant:"list-picker",rows:4}):!s||s.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:[l.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)),l.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No automations match your search."})]})]})}export{na as A,aa as C};
|
|
3
|
-
//# sourceMappingURL=create-automation-form-_4vUkrls.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iz as r,j as e}from"./index-_oPeVpL_.js";import{a as i}from"./agent-skills-route-DYpB5H1J.js";import"./agent-subpage-shell-B3K_jPYR.js";import"./agent-skill-context-DPk5r08w.js";import"./core.esm-DiTpULFl.js";import"./skill-editor-D_W3QlRz.js";import"./agent-loading-shells-CtZJM2Gc.js";import"./agent-card-controls-DzRs4Ix9.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-iHcxV0xd.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,ex as f,r as y,i0 as C,i1 as k,hl as g,B as A,L as E,cy as I,i2 as L,i3 as N,i4 as P,u as w,i5 as F,hz as O}from"./index-_oPeVpL_.js";import{a as R,R as S}from"./runs-panel-BO3h5RkS.js";import{c as v,C as $,a as b}from"./connector-scope-lists-BKDetNDc.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(f,{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]=y.useState(n);y.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 z=new Set(["Device was removed","Device was moved to another workspace"]);function H(s){const t=s.error_message??null;return!t||!z.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-Bz4JHHMK.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aI as U,hO as ne,hP as V,r as v,j as e,hQ as L,B as b,a1 as z,hR as C,cN as Y,au as te,hl as I,S as R,aU as T,dO as ae,dP as ce,dj as ie,dQ as oe,hS as re,T as le,m as de,az as me,hT as ue,hU as xe,hV as he,aA as pe,av as fe,aB as P,aT as O,L as E,hW as ge,hX as je,aO as ve,hY as ye,hZ as be,h3 as Ne,b7 as _e,fL as ke,h_ as q,I as we,a_ as Ce,b8 as Se,fM as $e,fN as K,bc as De,h$ as W,ah as Pe}from"./index-_oPeVpL_.js";import{c as Q,C as Le,R as ze}from"./device-pin-tombstone-Bz4JHHMK.js";import{R as Ie}from"./runs-panel-BO3h5RkS.js";import{S as Re,g as Ae}from"./runs-table-DxIiqrSk.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-BKDetNDc.js";import"./status-dot-C5KDvvm9.js";import"./runs-BWtc5rmc.js";import"./filter-editors-DCQgGLyR.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(G(s,o).map(t=>t.connector_key));return n.filter(t=>U(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function G(s,n){return s.organization_slug===n?s.update_required:[]}function Te(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 Be({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=V(),[u,p]=v.useState(null),[g,a]=v.useState(null),[f,N]=v.useState(null),[j,d]=v.useState([]),x=s.organization_id===n,y=async c=>{p(null),N(null),a(c.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:c.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!==c.key),{connectorKey:c.key,name:c.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:c.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},_=new Set(j.map(c=>c.connectorKey)),l=G(s,o),i=h.filter(c=>!_.has(c.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[j.map(c=>e.jsx(Oe,{outcome:c,device:s,organizationId:n},c.connectorKey)),i.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:i.map(c=>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:[c.name,c.required_capability&&L[c.required_capability]&&L[c.required_capability]!==c.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[c.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${c.name}`,disabled:g!==null,onClick:()=>x?void y(c):p(c.key),children:[g===c.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===c.key?e.jsx(X,{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(c),onCancel:()=>p(null)}):null,f?.key===c.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},c.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(c=>e.jsx("li",{children:`${c.display_name} — this device has ${c.device_version}, this workspace uses ${c.workspace_version}`},c.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(c=>e.jsx("li",{children:`${c.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},c.connector_key))}):null]})}function X({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 Oe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=Y(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=Q(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 H({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||!U(x)){f.push(d);continue}const y=x.required_capability??`connector:${x.key}`,_=a.get(y)??{key:y,name:x.name,connections:[]};_.name=L[y]??x.name,_.connections.push(d),a.set(y,_)}const N=Me(s,r,o),j=Te(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(Be,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:j}):null,T(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]=v.useState(u);return v.useEffect(()=>{u&&r!==void 0&&g(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:g,children:[e.jsxs(ce,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ie,{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(qe,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function qe({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=Y(o,{connectionIds:[s.connection_id]}),a=t.find(j=>j.id===s.connection_id&&j.device_worker_id===n),f=m?.name??s.connector_key,N=a?Q(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 Ke({device:s,ownerSlug:n}){const o=v.useId(),{data:h=[]}=le(),m=V(),[r,t]=v.useState(!1),[u,p]=v.useState(null),[g,a]=v.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),j=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)},_=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(i){a(i instanceof Error?i.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: "}),j]}),!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(X,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${j} 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 _(x.id),onCancel:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function We({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,j]=v.useState(!1),[d,x]=v.useState(!1),[y,_]=v.useState(""),l=he(t,n),i=l&&pe(l,s)?l:void 0,c=i?.id??n,{data:w=[]}=fe(o,{profileKind:"browser_session"}),S=v.useMemo(()=>w.filter(k=>k.device_worker_id===c&&k.status!=="revoked"),[w,c]),$=i?.label?.trim()??"";if(v.useEffect(()=>{d||_($)},[$,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(!i&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{platform:T(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(H,{device:l,organizationId:o,ownerSlug:s})]});if(!i)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(i),A=D?je(s,D,ve()):void 0,Z=T(i),J=ye(i.app_version),ee=be(i,J),B=()=>{const k=y.trim(),se=i.label?.trim()??"";if(k===se){x(!1);return}f.mutate({deviceWorkerId:i.id,label:k.length===0?null:k},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(ke,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:K,children:"Connectors"},"connectors"),...A?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:K,children:A.name},"app")]:[]]}),icon:e.jsx(O,{platform:Z,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=>_(k.target.value),placeholder:C({...i,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),N||B()):k.key==="Escape"&&(j(!1),_(i.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"," ",i.connector_count>0?`and un-pins ${i.connector_count} connector${i.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(i.id,{onSuccess:()=>{j(!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:()=>j(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:B,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:()=>{_(i.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:()=>j(!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(i),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{j(!1),_(i.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 ${i.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),i.online?i.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${q(new Date(i.last_seen_at),{addSuffix:!0})}${i.last_sync_at?` · Last sync ${q(new Date(i.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Ke,{device:i,ownerSlug:s}),i.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(_e,{className:"h-3.5 w-3.5 shrink-0"}),i.connector_error_count," connector",i.connector_error_count===1?"":"s"," pinned to this device ",i.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(H,{device:i,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(I,{title:"Browser auth profiles",children:e.jsx(He,{profiles:S})}):null,e.jsx(I,{title:"Runs",children:e.jsx(Ie,{scope:{deviceId:c},ownerSlug:s})})]})})}function He({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 ss(){const{owner:s,deviceId:n}=W.useParams(),{connection:o,settings:h}=W.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(We,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{ss as component};
|
|
2
|
-
//# sourceMappingURL=device._deviceId-D4plO3GM.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{m as x,t as m,j as e,bn as C,bo as _,bp as S,bq as b,br as c,eh as u}from"./index-_oPeVpL_.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:p,placeholder:d="Choose a connection",includeWorkspaceEvents:i=!1,ariaLabel:g="Connection"}){const f=x(),l=m().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;f({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(C,{value:r,onValueChange:j,disabled:p,children:[e.jsx(_,{"aria-label":g,children:e.jsx(S,{placeholder:d})}),e.jsxs(b,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx(c,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(c,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||i?e.jsx(u,{}):null,e.jsx(c,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{y as C,v as f};
|
|
2
|
-
//# sourceMappingURL=entity-options-UJs64GdQ.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{k as ee,iS as re,r as _,j as e,S as M,m as U,iT as oe,M as le,P as te,cd as ce,iU as de,dk as F,v as me,eu as H,iV as J,iW as ue,b_ as X,dY as he,eL as ge,eq as xe,eN as pe,iX as fe,bO as ve,bP as D,ex as ye,bS as je,y as z,I as Q,f3 as be,b7 as _e,B as E,eX as Ne,dN as we,eO as Se,L as ke,gj as Ee}from"./index-_oPeVpL_.js";import{R as Ce}from"./record-activity-CvgZyCmw.js";import{T as Te,a as Pe,b as I,d as L,e as G,c as Z,S as De,D as Ie,E as Fe}from"./tabs-B4Er9hJj.js";import{a as Le}from"./source-record-panels-CRIPMWfN.js";import{V as B,a as K,M as Re,b as $e}from"./view-param-filters-Cylutoy1.js";import{a as Ae}from"./renderer-BL6VcwQH.js";import"./filter-editors-DCQgGLyR.js";import"./connection-label-BobuYiAG.js";import"./runs-BWtc5rmc.js";import"./clients-CpG676mg.js";import"./client-rows-EJSKR6z1.js";import"./events-feed-fucGZSJR.js";import"./conversations-table-DfZGICl7.js";import"./agent-loading-shells-CtZJM2Gc.js";import"./member-scope-gate-CFbrq1by.js";import"./app-bridge-BCm4muqj.js";import"./card-DIF8SF9b.js";function Oe({entityId:t,ownerSlug:s}){const{orgContext:l}=ee(),{data:r,isLoading:m}=re(t,l),a=_.useMemo(()=>{if(!r)return[];const o=new Map;for(const c of r.rows){const d=o.get(c.relationship_type_slug);d?d.rows.push(c):o.set(c.relationship_type_slug,{slug:c.relationship_type_slug,label:c.relationship_type_name,rows:[c]})}return[...o.values()]},[r]);return m?e.jsxs("div",{className:"space-y-2",children:[e.jsx(M,{className:"h-4 w-32"}),e.jsx(M,{className:"h-12 w-full rounded-lg"}),e.jsx(M,{className:"h-12 w-full rounded-lg"})]}):!r||r.rows.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No relationships for this entity yet."}):e.jsx("div",{className:"space-y-3",children:a.map(({slug:o,label:c,rows:d})=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[c,e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:d.length})]}),e.jsx("ul",{className:"space-y-1",children:d.map(x=>e.jsx(Ve,{entityId:t,row:x,ownerSlug:s},x.id))})]},o))})}function Ve({entityId:t,row:s,ownerSlug:l}){const r=U(),{orgContext:m}=ee(),[a,o]=_.useState(!1),[c,d]=_.useState(!1),x=s.from_entity_id===s.to_entity_id,p=s.from_entity_id===t,u=x?"this entity":p?s.to_entity_name??`Entity #${s.to_entity_id}`:s.from_entity_name??`Entity #${s.from_entity_id}`,h=p?s.to_entity_type:s.from_entity_type,N=p?s.to_entity_id:s.from_entity_id,i=h?`${h} · ${u}`:u;async function g(){o(!0),d(!1);try{const b=[],v=new Set;let y=N;for(;y!==null;){if(v.has(y))throw new Error("Cyclic entity ancestry");v.add(y);const{entity:j}=await ce("manage_entity",{action:"get",entity_id:y},de(m));b.unshift({entity_type:j.entity_type,slug:j.slug}),y=j.parent_id}await r({to:F(l,b)})}catch{d(!0)}finally{o(!1)}}return e.jsxs("li",{className:te("flex items-center gap-2 rounded-md border border-border/70 px-2.5 py-1.5"),children:[e.jsx(oe,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),x||!h?e.jsx("span",{className:"min-w-0 flex-1 truncate text-sm",children:i}):e.jsxs("button",{type:"button",onClick:g,disabled:a,"aria-busy":a,className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm hover:underline",children:i}),h?e.jsx(le,{variant:"outline",className:"shrink-0 text-[9px] px-1.5 py-0 h-4 text-muted-foreground",children:h}):null]}),c?e.jsx("span",{role:"alert",className:"text-xs text-destructive",children:"Could not open this record. Try again."}):null]})}function Me(t,s){const l=new Set([...Object.keys(t),...Object.keys(s)]);let r=!1;const m={};for(const a of l){const o=a in t,c=a in s;if(!o&&c){m[a]=s[a];continue}o&&(m[a]=t[a],(!c||JSON.stringify(t[a])!==JSON.stringify(s[a]))&&(r=!0))}return r?m:void 0}function ze({entity:t,entityTypeSlug:s,orgContext:l,onDeleted:r}){const{isAdmin:m,isLoading:a}=xe(l.organizationId),o=m&&!a,{data:c,isLoading:d}=H(s,l),x=pe(),p=fe(),u=c?.metadata_schema,h=t.field_controls,N=_.useMemo(()=>G(t.metadata??{},u),[t.metadata,u]),i=ve(t.id,{name:t.name,slug:t.slug,metadata:N},u),[g,b]=i.field("name"),[v,y]=i.field("slug"),[j,C]=i.field("metadata"),[w,T]=D(t.id,""),[P,n]=D(t.id,null),[se,$]=D(t.id,!1),[W,A]=D(t.id,null),O=_.useMemo(()=>i.hasInvalidInput?void 0:Me(Z(j),Z(i.baseline.metadata)),[i.baseline.metadata,j,i.hasInvalidInput]),V=O!==void 0,ae=g!==i.baseline.name||v!==i.baseline.slug||V,ie=async f=>{if(f.preventDefault(),!(!o||!i.canSubmit)){if(n(null),!g.trim()){n("Name is required");return}try{await x.mutateAsync({entityId:t.id,name:g.trim()!==i.baseline.name.trim()?g.trim():void 0,slug:v,metadata:O,field_note:V&&w.trim()||void 0}),i.accept(i.values,{name:g.trim(),slug:v,metadata:G({...we(i.baseline.metadata),...O},u)}),T("")}catch(q){n(q instanceof Error?q.message:"Failed to update entity")}}},ne=async()=>{if(o){A(null);try{await p.mutateAsync({entityId:t.id}),$(!1),r?.()}catch(f){A(f instanceof Error?f.message:"Failed to delete entity")}}},Y=[t.total_content>0&&`${t.total_content} content item${t.total_content===1?"":"s"}`,t.automations_count>0&&`${t.automations_count} Automation${t.automations_count===1?"":"s"}`,t.active_connections>0&&`${t.active_connections} connector${t.active_connections===1?"":"s"}`].filter(Boolean).join(", ");return d?e.jsx(ye,{rows:6}):e.jsxs("form",{onSubmit:ie,className:"space-y-4",children:[e.jsx(je,{visible:i.hasConflict,onReload:i.reset}),!o&&e.jsx("p",{className:"text-sm text-muted-foreground",role:"status",children:a?"Checking edit permissions…":"You can view this record. Ask a workspace owner or admin to make changes."}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(z,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(Q,{id:"sidebar-name",readOnly:!o,value:g,onChange:f=>b(f.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(Q,{id:"sidebar-slug",readOnly:!o,value:v,onChange:f=>y(f.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),i.revision&&Object.keys(i.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsx(Ie,{schema:i.revision,values:j,onValuesChange:C,readonly:!o,fieldControls:h,orgContext:l})]}),o&&V&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(z,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(be,{id:"sidebar-correction-note",value:w,onChange:f=>T(f.target.value),placeholder:"Why are you changing these fields? Helps Automations respect the correction.",rows:2})]}),P&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:P}),o&&(se?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(_e,{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 "',t.name,'"?']}),Y&&e.jsxs("p",{className:"text-muted-foreground",children:["Removes ",Y,". This cannot be easily undone."]})]})]}),W&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-2.5 py-1.5 text-sm text-destructive",children:W}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(E,{type:"button",variant:"ghost",size:"sm",onClick:()=>{$(!1),A(null)},children:"Cancel"}),e.jsx(E,{type:"button",variant:"destructive",size:"sm",onClick:ne,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${c?.name||"entity"}`})]})]}):e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsx(E,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>$(!0),children:"Delete"}),e.jsx(E,{type:"submit",size:"sm",disabled:!i.canSubmit||!ae||x.isPending||!g.trim(),children:x.isPending?"Saving...":"Save"})]}))]})}function Be({entity:t,schema:s}){const l=new Set(t.measure_columns??[]),r=t.metadata??{},m=Object.keys(r).filter(a=>a!=="id"&&a!=="slug"&&a!=="name"&&s?.properties?.[a]?.const===void 0);return e.jsxs("div",{children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Managed by the source"}),e.jsx("dl",{className:"space-y-2.5 text-sm leading-5",children:m.map(a=>e.jsxs("div",{className:"grid grid-cols-[minmax(0,2fr)_minmax(0,3fr)] items-baseline gap-x-3",children:[e.jsx("dt",{className:"break-words text-muted-foreground",children:String(s?.properties?.[a]?.["x-table-label"]??(l.has(a)?a:he(a.replace(/_/g," "))))}),e.jsx("dd",{className:te("min-w-0 [overflow-wrap:anywhere]",l.has(a)&&"tabular-nums"),children:ge(r[a])})]},a))})]})}const R=":overview",S=":activity",k=":relationships";function Ue({active:t,children:s}){const[l,r]=_.useState(t);return _.useEffect(()=>{t&&r(!0)},[t]),!t&&!l?null:e.jsx(L,{value:R,forceMount:!0,hidden:!t,children:s})}const He={},We=()=>{};function Ye({namespace:t,entity:s,recordUrl:l,viewKey:r,onDeleted:m}){const a=me({strict:!1}),o=U(),c={slug:t.slug,organizationId:t.id},d=Ae(c),{data:x}=H(s.entity_type,c),p=d.data??[],u={type:s.entity_type,id:s.id,slug:s.slug,parentId:s.parent_id},h=J(p,u,"overview"),N=J(p,u,"tab"),i=ue(N,r),g=!r&&a.tab==="relationships",b=!r&&!g&&(h.length===0||a.tab==="activity"),v=!r&&!g&&!b,y=n=>`${l}${Ne(n)}`,j=n=>void o({to:".",search:n,replace:!0}),C={type:s.entity_type,entity:s.is_derived?s.slug:s.id},w=s.is_derived?e.jsx(Be,{entity:s,schema:x?.metadata_schema}):e.jsx(ze,{entity:s,entityTypeSlug:s.entity_type,orgContext:c,onDeleted:m}),T=s.is_derived?e.jsx(Le,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:c}):e.jsx(Oe,{entityId:s.id,ownerSlug:t.slug}),P=e.jsxs(e.Fragment,{children:[d.isError&&e.jsx(B,{onRetry:()=>void d.refetch()}),h.map(n=>e.jsx("section",{className:"mb-4 min-w-0","data-testid":"view-card","data-view":n.key,children:e.jsx(K,{orgSlug:t.slug,viewKey:n.key,scope:C,params:He,onParamsChange:We,contentHash:n.content_hash,title:n.name,minHeight:160})},n.key))]});return r&&d.data===void 0?d.isError?e.jsx(B,{onRetry:()=>void d.refetch()}):null:!r&&!g&&a.tab!=="activity"&&d.data===void 0&&!d.isError?e.jsxs("div",{className:"mt-4 grid gap-6 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsx("aside",{className:"min-w-0 lg:pr-2",children:w}),e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading views…"})]}):i.kind==="missing"?e.jsx(Re,{viewKey:i.key,backTo:l,backLabel:`Back to ${s.name}`}):e.jsxs("div",{className:"mt-4 grid gap-6 lg:grid-cols-[18rem_minmax(0,1fr)]",children:[e.jsx("aside",{className:"min-w-0 lg:pr-2",children:w}),e.jsxs(Te,{className:"min-w-0",value:i.kind==="tab"?i.view.key:g?k:b?S:R,onValueChange:n=>void o({to:n===R||n===S||n===k?l:y(n),search:n===k?{tab:"relationships"}:n===S?{tab:"activity"}:{}}),children:[e.jsxs(Pe,{className:"max-w-full justify-start overflow-x-auto",children:[h.length>0&&e.jsx(I,{value:R,children:h.length===1?h[0].name:"Overview"}),e.jsx(I,{value:S,children:"Activity"}),e.jsx(I,{value:k,children:"Relationships"}),N.map(n=>e.jsx(I,{value:n.key,"data-testid":`tab-${n.key}`,children:n.name},n.key))]}),h.length>0&&e.jsx(Ue,{active:v,children:P},`${t.id}/${s.entity_type}/${s.is_derived?s.slug:s.id}`),e.jsx(L,{value:k,children:T}),e.jsxs(L,{value:S,children:[d.isError&&e.jsx(B,{onRetry:()=>void d.refetch()}),e.jsx(Ce,{entity:s,organizationId:t.id,ownerSlug:t.slug})]}),i.kind==="tab"&&e.jsxs(L,{value:i.view.key,children:[e.jsx($e,{decls:i.view.params,params:X(a),onParamsChange:n=>void o({to:".",search:n})}),e.jsx(K,{orgSlug:t.slug,viewKey:i.view.key,scope:C,params:X(a),onParamsChange:j,contentHash:i.view.content_hash,title:i.view.name,minHeight:320})]})]})]})}function qe(t){return t?.trim()?t:void 0}function mt({namespace:t,path:s,entity:l,viewKey:r}){const m=U(),{data:a}=H(l.entity_type,{slug:t.slug}),o=qe(a?.icon),c=s.map(u=>({entity_type:u.entity_type,slug:u.slug})),d=`/${t.slug}/${Se(l.entity_type)}`,x=F(t.slug,c),p=s.length>1?F(t.slug,c.slice(0,-1)):d;return e.jsxs("div",{className:"mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col gap-4 px-4 py-6 lg:px-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2",children:e.jsx(E,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-7 w-fit px-2 text-muted-foreground hover:text-foreground",children:e.jsxs(ke,{to:p,children:[e.jsx(Ee,{className:"mr-1 h-4 w-4"}),"Back"]})})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{metadata:l.metadata,metadataSchema:a?.metadata_schema,name:l.name,typeIcon:o,className:"h-6 w-6"}),e.jsx("h2",{className:"text-lg font-semibold leading-tight",children:l.name})]})]}),e.jsx(Ye,{namespace:t,entity:l,recordUrl:x,viewKey:r,onDeleted:()=>{const u=s.slice(0,-1);u.length>0?m({to:F(t.slug,u)}):m({to:d})}})]})}export{mt as EntityPage};
|
|
2
|
-
//# sourceMappingURL=entity-page-Djz6T50J.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,M as $,k as W,ed as me,em as xe,eg as Q,bx as ae,r as x,ee as he,ef as pe,d5 as ge,d7 as fe,B as f,cy as V,d6 as je,y as C,bn as q,bo as P,bp as M,bq as I,br as R,I as T,a1 as ve,ep as Ne,e_ as ye,e$ as be,X as H,dv as ne,dj as re,Q as Se,a_ as le,f0 as ie,f1 as we,b7 as oe,f2 as Ce,eS as ke,bO as Ee,bP as Y,bS as _e,f3 as Re,by as Te,f4 as Oe,f5 as De,P as G}from"./index-_oPeVpL_.js";import{J as B}from"./json-diff-D_Ym3Uku.js";import{C as ce}from"./code-editor-V27Z4o3P.js";function Ae(s){switch(s){case"create":return"default";case"update":return"secondary";case"delete":return"destructive";default:return"outline"}}function Fe(s){switch(s){case"create":return"Created";case"update":return"Updated";case"delete":return"Deleted";default:return s}}function ze(s){try{return new Date(s).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"})}catch{return s}}function qe({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{variant:Ae(s.action),children:Fe(s.action)}),s.actor&&e.jsx("span",{className:"text-xs text-muted-foreground",children:s.actor})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ze(s.created_at)}),s.action==="update"&&e.jsx(B,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(B,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(B,{before:s.before_payload,after:null})]})]})}function Pe({entityType:s}){const{orgContext:a}=W(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==Q),d=i.filter(m=>m.purpose===Q),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]}),d.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"Managed by access control"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.length>0&&e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx("h4",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"From public catalogs"}),e.jsx(J,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Le,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function J({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Me,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Me({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=W(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.name]));return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:s.name}),e.jsx("code",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:s.slug}),s.is_symmetric&&e.jsx($,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx($,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Ie,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Ie({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;return e.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-3 rounded-md border border-border bg-muted/30 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:d?"this":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(H,{className:"h-3 w-3"})})})]})}function Le({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=W(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[w,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[D,S]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),S(!1),_(null)},O=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),U=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const K=k.trim()||F(g);if(!K){_("Slug is required");return}l=(await u.mutateAsync({slug:K,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!w){_("Select a target entity type");return}const L=y==="source"?s:w,ue=y==="source"?w:s;await p.mutateAsync({slug:l,source_entity_type_slug:L,target_entity_type_slug:ue}),O(!1)}catch(l){_(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:O,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1.5"}),"Add Relationship Rule"]})}),e.jsx(je,{className:"w-80 p-4",align:"start",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(I,{children:[a.map(l=>e.jsx(R,{value:l.slug,children:l.name},l.slug)),a.length===0&&e.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No relationship types yet. Create one."})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),k||E("")}}),e.jsx(T,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:k,onChange:l=>E(l.target.value)}),e.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:D,onChange:l=>S(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"source",children:"This type → other"}),e.jsx(R,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:w,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(I,{children:r.map(l=>e.jsxs(R,{value:l.slug,children:[l.icon?`${l.icon} `:"",l.name]},l.slug))})]})]}),A&&e.jsx("p",{className:"text-xs text-destructive",children:A}),e.jsx(f,{size:"sm",className:"w-full",onClick:U,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Ve({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,d)=>d!==i))};return e.jsxs("div",{className:"space-y-2 pl-4 border-l-2 border-muted",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((i,o)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-sm px-2 py-0.5 rounded",children:[i,e.jsx("button",{type:"button",onClick:()=>t(o),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},i))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}const Ue=[{value:"string",label:"String"},{value:"number",label:"Number"},{value:"integer",label:"Integer"},{value:"boolean",label:"Boolean"},{value:"enum",label:"Enum"}];function Be({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.trim();t&&!s.includes(t)&&(a([...s,t]),n(""))};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map((t,i)=>e.jsxs("span",{className:"inline-flex items-center gap-1 bg-muted text-xs px-2 py-0.5 rounded",children:[t,e.jsx("button",{type:"button",onClick:()=>a(s.filter((o,d)=>d!==i)),className:"text-muted-foreground hover:text-foreground",children:e.jsx(H,{className:"h-3 w-3"})})]},t))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(T,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}function Je({field:s,onChange:a,onDelete:c}){const[n,r]=x.useState(!!(s.description||s.default||s.role||s.examples&&s.examples.length>0));return e.jsxs("div",{className:"rounded-md border border-border p-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-muted-foreground hover:text-foreground shrink-0",children:n?e.jsx(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(T,{value:s.name,onChange:t=>a({...s,name:t.target.value}),placeholder:"Field name",className:"h-8 flex-1"}),e.jsxs(q,{value:s.type,onValueChange:t=>a({...s,type:t,enumOptions:t==="enum"?s.enumOptions||[]:void 0,role:t==="enum"||s.role!=="workflowState"?s.role:void 0}),children:[e.jsx(P,{className:"h-8 w-32",children:e.jsx(M,{})}),e.jsx(I,{children:Ue.map(t=>e.jsx(R,{value:t.value,children:t.label},t.value))})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground whitespace-nowrap",children:[e.jsx(Se,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Ve,{options:s.enumOptions||[],onChange:t=>a({...s,enumOptions:t})})}),n&&e.jsxs("div",{className:"pl-6 space-y-2 pt-1",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Description"}),e.jsx(T,{value:s.description||"",onChange:t=>a({...s,description:t.target.value||void 0}),placeholder:"Field description",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default"}),e.jsx(T,{value:s.default||"",onChange:t=>a({...s,default:t.target.value||void 0}),placeholder:s.type==="boolean"?"true / false":"Default value",className:"h-7 text-xs mt-0.5"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"View role"}),e.jsxs(q,{value:s.role||"none",onValueChange:t=>a({...s,role:t==="workflowState"||t==="sortRank"?t:void 0}),children:[e.jsx(P,{className:"h-7 text-xs mt-0.5",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"none",children:"None"}),e.jsx(R,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(R,{value:"sortRank",children:"Sort rank"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Examples"}),e.jsx("div",{className:"mt-0.5",children:e.jsx(Be,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function X({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,placeholder:'{ "type": "object", "properties": {} }',minHeight:"200px"}),n&&e.jsx("p",{className:"text-sm text-destructive",children:n})]})}function Z(s){if(s.type!=="object")return!1;const a=s.properties;if(!a||typeof a!="object")return Object.keys(s).length<=1;for(const c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,r=n.type;if(!n.enum&&(!r||!["string","number","integer","boolean"].includes(r)||n.properties||n.items||n.allOf||n.oneOf||n.anyOf))return!1}return!0}function de(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`field-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ee(s){const a=s.properties||{},c=s.required||[];return Object.entries(a).map(([n,r])=>{const t=r["x-lobu"]?.role||r["x-lobu-role"],i=t==="workflowState"?"workflowState":t==="sortRank"?"sortRank":void 0,o={id:de(),name:n,required:c.includes(n),description:r.description||void 0,default:r.default!==void 0?String(r.default):void 0,examples:Array.isArray(r.examples)?r.examples.map(String):void 0,role:i};return r.enum?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function $e(s,a="auto"){const c={},n=[];for(const t of s){if(!t.name.trim())continue;const i={};t.type==="enum"?i.enum=t.enumOptions||[]:i.type=t.type,t.description?.trim()&&(i.description=t.description.trim()),t.default!==void 0&&t.default!==""&&(i.default=se(t.default,t.type)),t.examples&&t.examples.length>0&&(i.examples=t.examples.map(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};return n.length>0&&(r.required=n),a&&a!=="auto"&&(r["x-lobu"]={defaultView:a}),r}function te(s){const a=s["x-lobu"]?.defaultView;return a==="table"||a==="board"?a:"auto"}function We({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[w,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),Z(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=$e(u,p),O=u.some(F=>F.name.trim());m(O?JSON.stringify(v,null,2):""),a(O?v:void 0)},[a]),k=x.useCallback(u=>{i(u),j(u,o)},[j,o]),E=x.useCallback(u=>{d(u),j(t,u)},[j,t]),D=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),Z(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),S=()=>{k([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,k(v)},_=u=>{k(t.filter((p,v)=>v!==u))};return c?e.jsx(X,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(we,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-amber-500/10 text-amber-600 text-xs",children:[e.jsx(oe,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsx("span",{children:"This schema uses advanced features (nested objects, allOf, etc.) that can only be edited in JSON mode."})]}),n==="visual"?e.jsxs("div",{className:"space-y-3",children:[t.map((u,p)=>e.jsx(Je,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:S,className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.name.trim())&&e.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-border p-2.5",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground font-medium",children:"Default view"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/70",children:"Which view this type opens in. Auto picks from your fields (a workflow field → board, otherwise table)."})]}),e.jsxs(q,{value:o,onValueChange:u=>E(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"auto",children:"Auto"}),e.jsx(R,{value:"table",children:"Table"}),e.jsx(R,{value:"board",children:"Board"})]})]})]})]}):e.jsx(X,{value:h,onChange:D,error:w})]})}function He(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ke({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(i,{name:s?.name??"",slug:s?.slug??"",description:s?.description??"",icon:s?.icon??"",color:s?.color??"",metadataSchema:s?.metadata_schema??void 0,backingSql:s?.backing_sql??""}),[d,h]=o.field("name"),[m,w]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,D]=o.field("metadataSchema"),[S,A]=o.field("backingSql"),[_,u]=Y(i,n),[p,v]=Y(i,null),O=S.trim().length>0,F=l=>{h(l),!n&&!_&&w(He(l))},U=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=O?{sql:S.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:E,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:O?void 0:E,backing:l}),c()}catch(L){v(L instanceof Error?L.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(T,{id:"et-name",value:d,onChange:l=>F(l.target.value),placeholder:"e.g. Product"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(T,{id:"et-slug",value:m,onChange:l=>{u(!0),w(l.target.value)},placeholder:"e.g. topic",disabled:n}),n&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Slug cannot be changed after creation."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(l.target.value),placeholder:"Optional description...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(T,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{id:"et-color",value:j,onChange:l=>k(l.target.value),placeholder:"e.g. #6366f1",className:"flex-1"}),j&&e.jsx("div",{className:"h-9 w-9 rounded-md border border-border shrink-0",style:{backgroundColor:j}})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Backing query (SQL)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. A read-only SELECT turns this into a derived (view) type — rows are computed from the query, not stored. Leave empty for a normal stored type. Table references are auto-scoped to your organization."}),e.jsx(ce,{value:S,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),O?e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-muted px-3 py-2 text-sm text-muted-foreground",children:[e.jsx(ie,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("span",{children:"Derived view — columns are computed from the query, so there's no stored-row schema to define."})]}),s?.measure_columns&&s.measure_columns.length>0&&e.jsxs("div",{className:"space-y-1 pt-1",children:[e.jsx(C,{children:"Measure columns"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.measure_columns.map(l=>e.jsx("span",{className:"rounded-md border border-border bg-muted px-2 py-0.5 font-mono text-xs text-muted-foreground",children:l},l))})]})]}):e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Metadata Schema"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define the structure of metadata fields for entities of this type."}),e.jsx(We,{value:E,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(Pe,{entityType:s})]}),p&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:p}),e.jsx(Te,{onCancel:a,cancelDisabled:z,className:"pt-2",children:e.jsx(f,{onClick:U,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Ze({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,w]=x.useState(null),N=Oe(),{data:y,isLoading:b}=De(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,k=async()=>{if(s){w(null);try{await N.mutateAsync(s.slug),a()}catch(S){w(S instanceof Error?S.message:"Failed to delete")}}},E=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",D=t?"Edit entity type configuration.":"Define a new entity type for your workspace.";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:G("space-y-1.5",!t&&!r&&"text-center"),children:[e.jsx("h1",{className:G("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:E}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D})]}),e.jsx("div",{className:"py-4",children:e.jsx(Ke,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"History"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(S=>e.jsx(qe,{entry:S},S.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{className:"h-5 w-5 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium",children:"Cannot delete this entity type"}),e.jsxs("p",{className:"mt-1 text-amber-600/80",children:["There ",g===1?"is":"are"," ",g," entit",g===1?"y":"ies",' of type "',s.name,'". Migrate or delete them first.']})]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:['Are you sure you want to delete "',s.name,'"? This action will soft-delete the entity type. It can be restored by a database administrator.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),w(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:k,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Ze as E};
|
|
2
|
-
//# sourceMappingURL=entity-type-page-OznRag6A.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{g as J,T as Z,r as D,fJ as q,fs as I,j as s,bZ as M,L as Q}from"./index-_oPeVpL_.js";import{u as W,E as X}from"./events-feed-fucGZSJR.js";import{b as Y,a as z,V as K,M as ee}from"./view-param-filters-Cylutoy1.js";const se={},te="calc(100dvh - 120px)";function ie({owner:n,organizationId:o,eventId:c,viewKey:r,params:g,onParamsChange:d,onSelectView:p,dense:m=!1,fullBleed:k=!1}){const{isAuthenticated:y,isReady:E}=J(),{data:T,isLoading:w}=Z(),O=T?.some(t=>t.id===o&&t.is_member),i=n!=="me"&&o!==null&&E&&y&&!w&&O,a=W(i?{slug:n,organizationId:o}:null,c),[j,b]=D.useState(se),[P,L]=D.useState(null),u=q(a.views,r),e=i&&!a.isLoading&&!a.isError&&u.kind==="view"?u.view:null,v=e?`${I(n,e.key)}/${e.content_hash}/${e.eventId}`:null,f=e!==null&&P===v,V=M(n,c),F=n!=="me"&&(!E||y&&(w||a.isLoading)),H=e!==null&&!f&&!F,h=k&&H,U=(k||m)&&H,N=F?s.jsx("div",{role:"status",className:"py-8 text-sm text-muted-foreground",children:"Loading event view…"}):e&&!f?s.jsxs(s.Fragment,{children:[s.jsx(Y,{decls:e.params,params:g??j,onParamsChange:t=>d?d(e.key,t,{replace:!1}):b(t)}),s.jsx(z,{orgSlug:n,viewKey:e.key,scope:{event:e.eventId},params:g??j,onParamsChange:t=>d?d(e.key,t):b(t),onLoadError:()=>L(v),contentHash:e.content_hash,title:e.name,minHeight:m?240:320,fixedHeight:U?te:void 0},v)]}):void 0;return s.jsxs("div",{className:h?"w-full space-y-3":"mx-auto w-full max-w-3xl space-y-3",...h?{"data-testid":"event-view-fullbleed"}:{},children:[i&&a.isError&&s.jsx(K,{onRetry:a.refetch}),(i||n==="me"&&r)&&!a.isLoading&&!a.isError&&u.kind==="missing"&&s.jsx(ee,{viewKey:u.key,backTo:V,backLabel:"Back to the event"}),f&&s.jsxs("div",{role:"alert",className:"rounded-md border p-3 text-sm",children:[s.jsx("p",{children:"The custom view couldn’t load. The event content is shown below."}),s.jsx("button",{type:"button",className:"mt-2 underline",onClick:()=>L(null),children:"Retry custom view"})]}),s.jsx(X,{presentation:"detail",organizationId:o,ownerSlug:n,filters:{contentIds:[c],...n==="me"?{sortBy:"date",sortOrder:"desc"}:{}},dense:m,hideDetails:m,renderDetail:t=>{const x=N!=null&&(t==null||!!r),A=(i?a.views:[]).filter(l=>!x||l.key!==e?.key).map(l=>({key:l.key,name:l.name,href:M(n,c,l.key)})),S=l=>l.length?s.jsx("nav",{"aria-label":"Event views",className:"flex flex-wrap gap-3 text-sm",children:l.map(({key:$,name:C,href:B})=>s.jsx(Q,{to:B,className:"underline",onClick:p?G=>{G.preventDefault(),p(B)}:void 0,children:C},$))}):null,R=[...A],_=[...A];return i&&r&&t!=null&&_.unshift({key:":event",name:"Event details",href:V}),{content:x?N:t,nativeHeading:!x&&t!=null,headingAside:h?S(R):void 0,links:h?null:S(_)}}})]})}export{ie as E};
|
|
2
|
-
//# sourceMappingURL=event-detail-04qOUGIP.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,L as oe,dj as bt,dk as Ye,cd as _t,bw as wt,r as h,dl as Ze,dm as kt,V as Ct,H as St,di as Rt,aR as At,dn as Xe,b6 as et,dp as It,dq as Tt,cr as Et,aV as $t,P as Te,dr as tt,ds as Dt,dt as be,dc as Ce,B as $,du as ve,dv as ye,M as pe,dw as st,dx as ze,dy as nt,d5 as Pt,d7 as Ot,d6 as Ft,dz as Mt,dA as Lt,ce as rt,dB as Bt,dC as zt,m as Ht,u as Vt,k as at,bH as Ue,bZ as qe,Z as Ut,dD as qt,dE as Jt,dF as Kt,dG as it,dH as Qt,dI as Wt,a1 as Se,dJ as Gt,dK as Yt,bO as Zt,dL as Xt,bS as es,dM as ts,dd as ss,dN as ns,X as rs,bi as ot,dO as Ee,dP as $e,dQ as De,cO as as,S as is,aQ as os,cY as ls,g as ds,t as cs,cL as us,cM as ms,cR as ps,cS as xs,dR as hs,dS as fs,dT as gs,dU as vs,bK as ys,dV as js,dW as Fe,bc as Je,ai as Ns}from"./index-_oPeVpL_.js";import{c as bs}from"./conversations-table-DfZGICl7.js";import{a as lt,J as _s}from"./renderer-BL6VcwQH.js";import{u as ws}from"./clients-CpG676mg.js";function ks(s,t){const n=t.parentEntityType&&t.parentEntitySlug?[{entity_type:t.parentEntityType,slug:t.parentEntitySlug},{entity_type:t.entityType,slug:t.entitySlug}]:[{entity_type:t.entityType,slug:t.entitySlug}];return Ye(s,n)}function Cs({ownerSlug:s,entity:t,className:n}){const r=ks(s,t);return e.jsxs(oe,{to:r,className:`flex items-center gap-1 text-primary hover:underline group ${n??""}`,children:[e.jsx("span",{className:"font-medium",children:t.entityName}),e.jsx(bt,{className:"h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity"})]})}function dt(s){const t=Array.isArray(s?.records)?s.records:Array.isArray(s?.current)?s.current:[];return[s?.from_entity_id??s?.entity_id,s?.to_entity_id].map(n=>{const i=t.find(l=>l&&typeof l=="object"&&"id"in l&&l.id===n);return{id:String(n??"unknown"),name:typeof i?.name=="string"?i.name:`Record ${String(n??"unknown")}`}})}function ct(s,t){return t==="rejected"?"The proposed relationship change was rejected. Both records remain available.":t==="failed"?"The relationship change failed. Both records remain available.":t==="completed"?s==="link"?"The records were linked. Both records remain available.":"The relationship was removed. Both records remain available.":t==="approved"||t==="confirmed"?"The relationship change was approved. Both records remain available.":s==="link"?"If approved, these records will be linked. Both records remain available.":"If approved, this relationship will be removed. Both records remain available."}function mn(s){const t=dt(s.proposal);return{title:s.action==="link"?"Link records":"Unlink records",icon:"entity",impact:{level:"normal"},tone:"default",blocks:[...t.map((n,r)=>({type:"text",label:r===0?"From":"To",value:n.name})),{type:"text",label:"Relationship",value:String(s.proposal?.relationship_type??s.proposal?.relationship_type_slug??"Relationship")},{type:"text",value:ct(s.action,typeof s.status=="string"?s.status:void 0),muted:!0},...typeof s.reason=="string"&&s.reason?[{type:"text",label:"Why this needs approval",value:s.reason}]:[]],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",confirm:s.action==="unlink",confirmPrompt:"Remove this relationship? Both records will remain available.",tool:"manage_operations",args:{action:"approve"},resolvedLabel:"Approval submitted."},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this relationship change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:"Relationship change rejected."}]}}function ut(s,t,n){return{queryKey:["event-view-match",s,t.key,t.content_hash,n],queryFn:async()=>{try{const i=(await _t("open_view",{key:t.key,scope:{event:n}},{slug:s})).scope?.event;if(!Number.isSafeInteger(i)||(i??0)<1)throw new Error("The view did not resolve its event subject");return i}catch(r){if(r instanceof wt&&(r.status===400||r.status===404))return null;throw r}},staleTime:6e4}}function pn(s,t){const n=lt(s??{slug:null,organizationId:null}),r=s?.slug??null,i=h.useMemo(()=>r?Ze(n.data??[]):[],[r,n.data]),l=kt({queries:i.map(a=>ut(r,a,t))});return r?{views:i.flatMap((a,u)=>{const N=l[u]?.data;return N?[{...a,eventId:N}]:[]}),isLoading:n.data===void 0?!n.isError:l.some(a=>a.isPending),isError:n.isError||l.some(a=>a.isError),refetch:()=>{n.refetch();for(const a of l)a.isError&&a.refetch()}}:{views:[],isLoading:!1,isError:!1,refetch:()=>{}}}async function Ss(s,t,n,r){const i=await Promise.all(n.map(l=>s.fetchQuery(ut(t,l,r))));return n.find((l,a)=>i[a])??null}async function Rs(s,t,n,r){const i=await Ct(`${St}/api/${encodeURIComponent(s)}/events/${t}/actions/${encodeURIComponent(n.action)}`,{method:"POST",timeoutMs:9e4,credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n.value,interaction_id:r})});return await Rt(i,"Could not record interaction"),i.json()}function z(s){if(typeof s!="string")return;const t=s.trim();return t.length>0?t:void 0}function Me(s){return typeof s=="boolean"?s:void 0}function As(s,t,n){const r=(n??"").toLowerCase();return!!(r==="prepare_comment"||r==="verify_staged_comment"||r.includes("prepare_")||r.includes("verify_staged")||t?.prepared===!0||typeof t?.verified=="boolean"||z(t?.reason_preview)&&z(t?.message)||z(s?.body)&&(z(s?.post_url)||z(s?.activity_id)))}function Is(s,t,n){if(!As(s,t,n))return null;const r=(n??"").toLowerCase(),i=z(t?.body)??z(s?.body),l=z(t?.reason_preview)??z(s?.reason),a=z(t?.post_url)??z(s?.post_url)??(z(s?.activity_id)?`https://www.linkedin.com/feed/update/urn:li:activity:${z(s?.activity_id)}`:void 0),u=Me(t?.prepared),N=Me(t?.verified),j=Me(t?.banner_shown),b=z(t?.message),f=t?.match&&typeof t.match=="object"?t.match:null,m=z(f?.text_preview),v=z(f?.author);let S="generic";r==="verify_staged_comment"||r.includes("verify")||typeof N=="boolean"?S="verify":(r==="prepare_comment"||r.includes("prepare")||u===!0||i&&a)&&(S="prepare");const g=[];return u===!0&&g.push("Staged — not posted"),u===!1&&g.push("Not staged"),N===!0&&g.push("Verified posted"),N===!1&&g.push("Not verified as posted"),j===!0&&g.push("In-page banner"),j===!1&&g.push("No banner"),{kind:S,message:b,reason:l,body:i,postUrl:a,prepared:u,bannerShown:j,verified:N,matchPreview:m,matchAuthor:v,chips:g}}function we(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}function Ts({template:s,data:t,onAction:n}){const[r,i]=h.useState(null),[l,a]=h.useState(!1),[u,N]=h.useState(null),[j,b]=h.useState(!1),f=h.useRef(!1),m=h.useRef(!0);h.useEffect(()=>(m.current=!0,()=>{m.current=!1}),[]);const v=async S=>{if(!(!n||f.current)){f.current=!0,a(!0),N(null),b(!1);try{const g=await n(S);if(!m.current)return;if(we(g)&&g.kind==="sdk"){const _=g.result;if(!we(_)||_.success!==!0){const I=we(_)&&we(_.error)?_.error.message:null;throw new Error(typeof I=="string"?I:"Could not update this event.")}if(_.return_truncated||!we(_.return_value))throw new Error("The update did not return a complete data object.");i(_.return_value),b(!0)}}catch(g){m.current&&N(g instanceof Error?g.message:"Could not update this event.")}finally{f.current=!1,m.current&&a(!1)}}};return e.jsxs("div",{className:"space-y-2",children:[l?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Updating…"}):null,j?e.jsx("p",{role:"status",className:"sr-only",children:"Updated"}):null,u?e.jsxs("p",{role:"alert",className:"text-sm text-destructive",children:[u," Previous data is still shown."]}):null,e.jsx("fieldset",{disabled:!n||l,"aria-busy":l,className:"min-w-0",children:e.jsx(_s,{template:{root:s.root},data:r??t,onAction:n?v:void 0,interactions:s.interactions})})]})}function mt(s){return{audit:s.semantic_type==="audit"&&s.origin_type==="tool_invocation",operation:s.interaction_type==="approval"||s.semantic_type==="operation",changeSet:s.semantic_type==="change_set"}}const Es={};function xe(s){return s.replace(/_/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}const $s={notification:"Notification",tool_invocation:"Action",deployment:"Deployment",config_change:"Config change",message:"Message",msg:"Note",summary:"Summary"};function Ds(s){return s.author_name?s.author_name:s.platform?xe(s.platform):s.origin_type?$s[s.origin_type]??xe(s.origin_type):null}function Ps(s){return s==null?"":typeof s=="string"?s:typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"?String(s):Array.isArray(s)?s.length===0?"":s.every(t=>typeof t!="object")?s.map(t=>String(t)).join(", "):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(s,null,2)}):e.jsx("pre",{className:"overflow-x-auto rounded bg-muted/40 p-2 text-[11px] leading-relaxed whitespace-pre-wrap",children:JSON.stringify(s,null,2)})}const Le=1e5;function Ke({value:s}){const t=JSON.stringify(s,null,2)??"null",n=t.length>Le;return e.jsxs(e.Fragment,{children:[e.jsx("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-md border bg-muted/40 p-3 font-mono text-xs",children:n?t.slice(0,Le):t}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Showing the first ",Le.toLocaleString()," of"," ",t.length.toLocaleString()," characters."]})]})}function Os(s){return Object.entries(s).filter(([,t])=>t==null?!1:typeof t=="string"?t.trim().length>0:Array.isArray(t)?t.length>0:typeof t=="object"?Object.keys(t).length>0:!0).sort(([t],[n])=>t.localeCompare(n))}function Fs({breakdown:s}){if(!s)return null;const t=[{label:"Engagement",value:s.engagement,max:100},{label:"Criticality",value:s.criticality,max:100},{label:"Depth",value:s.depth,max:100},{label:"Authority",value:s.authority,max:100},{label:"Recency",value:s.recency,max:100},{label:"Quality",value:s.quality,max:100}];return e.jsx("div",{className:"space-y-2 text-sm",children:t.map(n=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-20 text-muted-foreground",children:n.label}),e.jsx("div",{className:"flex-1 h-2 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary",style:{width:`${n.value/n.max*100}%`}})}),e.jsx("span",{className:"w-8 text-right",children:n.value})]},n.label))})}function Ms({slug:s,value:t,isManual:n}){return e.jsxs(pe,{variant:"secondary",className:"text-xs",children:[s,": ",t,n&&e.jsx(tt,{className:"ml-1 h-2.5 w-2.5 fill-current"})]})}function Ls(s){if(s&&typeof s=="object"){const t=s;if(Array.isArray(t.values))return{values:t.values.map(n=>String(n)).filter(n=>n.length>0),isManual:t.is_manual===!0};if(t.value!==void 0&&t.value!==null)return{values:[String(t.value)],isManual:t.is_manual===!0};if(typeof t.values=="string"&&t.values.length>0)return{values:[t.values],isManual:t.is_manual===!0}}return typeof s=="string"||typeof s=="number"||typeof s=="boolean"||typeof s=="bigint"?{values:[String(s)],isManual:!1}:{values:[],isManual:!1}}function pt(s,t){if(s)switch(s){case"pending":return"pending_approval";case"approved":return"confirmed";case"rejected":return"rejected";case"completed":return"completed";case"failed":return"failed";default:return s}return t||"pending_approval"}function Be(s){return!s||typeof s!="object"||Array.isArray(s)?null:s}function Qe(s){return s==null||s===""?"Not set":typeof s=="string"?s:JSON.stringify(s,null,2)}function Bs(s){return s.replace(/\s+[—-]\s+pending approval$/i,"")}function Re(s){return s.replace(/^\$/,"").replace(/[_-]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}function xt(s,t,n){return s?.kind==="agent_session"&&s.agent_id?s.client_id?`${s.agent_id} via ${s.client_id}`:s.agent_id:s?.kind==="user"?"a person":t==="agent"?"an agent":n?`Automation ${n}`:"an Automation"}function zs({ownerSlug:s,initiator:t,clientName:n,fallback:r}){const i=t?.client_id??n,{allOrgs:l,isAuthenticated:a}=at(),u=a&&l?.some(v=>v.slug===s),j=ws(void 0,{ownerSlug:s,enabled:!!(i&&u)}).data?.find(v=>v.id===i)?.title,b=t&&t.kind!=="user"?xt(t,void 0,t.automation_id===void 0?void 0:String(t.automation_id)):r,f="font-medium text-foreground",m=`${f} underline-offset-4 hover:underline`;return t?.kind==="automation"&&t.automation_id?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:s,automationId:String(t.automation_id)},search:{view:"definition",run_id:void 0},className:m,children:b}):t?.kind==="agent_session"&&t.agent_id?e.jsx(oe,{to:"/$owner/agents/$agentId",params:{owner:s,agentId:String(t.agent_id)},className:m,children:b}):i?e.jsxs(oe,{to:"/$owner/agents/connected/$clientId",params:{owner:s,clientId:i},className:`${m} inline-flex items-center gap-1 align-middle`,children:[e.jsx(ot,{name:j??n??i}),j??b]}):e.jsx("span",{className:f,children:b})}function Hs(s){const t=Object.keys(s.fields),n=t.map(Re).join(", ")||"field",r=t.length===1?"field":"fields";return`Update ${s.entityType?Re(s.entityType).toLowerCase():"entity"} ${r}: ${n}`}function Vs(s,t){const n=Be(t.fields);if(!n||Object.keys(n).length===0||t.action_key!=="entity_field_change"&&t.tool!=="entity_field_change")return null;const r=Be(t.current)??{},i=s;return{fields:n,current:r,reason:typeof t.reason=="string"?t.reason:void 0,automationId:t.automation_id!=null?String(t.automation_id):void 0,automationName:typeof t.automation_name=="string"?t.automation_name:void 0,automationAgentId:typeof t.automation_agent_id=="string"?t.automation_agent_id:void 0,entityType:typeof t.entity_type=="string"?t.entity_type:void 0,entityName:(typeof t.entity_name=="string"?t.entity_name:void 0)??i.entity_name??void 0,entitySlug:typeof t.entity_slug=="string"?t.entity_slug:void 0,parentSlug:typeof t.parent_slug=="string"?t.parent_slug:void 0,parentEntityType:typeof t.parent_entity_type=="string"?t.parent_entity_type:void 0,attribution:typeof t.attribution=="string"?t.attribution:void 0,initiator:t.initiator&&typeof t.initiator=="object"?t.initiator:void 0}}function Us(s){const t=s.entityType?Re(s.entityType).toLowerCase():"entity";return`${Re(s.operation)} ${t}`}function qs(s,t){if(t.action_key!=="entity_change"&&t.tool!=="entity_change")return null;const n=t.action;if(n!=="create"&&n!=="delete"&&n!=="link"&&n!=="unlink")return null;const r=s;return{operation:n,proposal:Be(t.proposal),reason:typeof t.reason=="string"?t.reason:void 0,automationId:t.automation_id!=null?String(t.automation_id):void 0,automationName:typeof t.automation_name=="string"?t.automation_name:void 0,automationAgentId:typeof t.automation_agent_id=="string"?t.automation_agent_id:void 0,entityType:typeof t.entity_type=="string"?t.entity_type:void 0,entityName:(typeof t.entity_name=="string"?t.entity_name:void 0)??r.entity_name??void 0,entitySlug:typeof t.entity_slug=="string"?t.entity_slug:void 0,parentSlug:typeof t.parent_slug=="string"?t.parent_slug:void 0,parentEntityType:typeof t.parent_entity_type=="string"?t.parent_entity_type:void 0,attribution:typeof t.attribution=="string"?t.attribution:void 0,proposerRationale:typeof t.proposer_rationale=="string"?t.proposer_rationale:void 0,initiator:t.initiator&&typeof t.initiator=="object"?t.initiator:void 0}}function Js(s,t){return!t.entityType||!t.entitySlug?null:Ye(s,t.parentEntityType&&t.parentSlug?[{entity_type:t.parentEntityType,slug:t.parentSlug},{entity_type:t.entityType,slug:t.entitySlug}]:[{entity_type:t.entityType,slug:t.entitySlug}])}function ht({ownerSlug:s,runId:t,details:n}){const i=it(n.automationId,void 0,void 0,{ownerSlug:s,includeVersions:!1}).data?.automation,l=xt(n.initiator,n.attribution,n.automationId),a=i?.automation_name??n.automationName??l;return e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Requested by"," ",n.automationId?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:s,automationId:n.automationId},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:a}):e.jsx("span",{className:"font-medium text-foreground",children:a}),t&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:" · "}),e.jsxs(oe,{to:"/$owner/events",params:{owner:s},search:{run_ids:String(t)},className:"font-medium text-foreground underline-offset-4 hover:underline",children:["Run #",t]})]})]})}function ft({ownerSlug:s,details:t}){const n=Js(s,t);return t.entityName?e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Entity"}),e.jsx("div",{className:"mt-1 text-sm font-medium",children:n?e.jsx(oe,{to:n,className:"underline-offset-4 hover:underline",children:t.entityName}):t.entityName})]}):null}function gt({label:s,before:t,after:n}){return e.jsxs("div",{className:"rounded-md border border-border/70 overflow-hidden",children:[e.jsx("div",{className:"border-b border-border/70 px-3 py-2 text-xs font-medium",children:s}),e.jsxs("div",{className:"grid gap-px bg-border/70 sm:grid-cols-2",children:[e.jsxs("div",{className:"bg-background p-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Current"}),e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:Qe(t)})]}),e.jsxs("div",{className:"bg-background p-3",children:[e.jsx("div",{className:"mb-1 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Proposed"}),e.jsx("div",{className:"whitespace-pre-wrap text-sm leading-relaxed",children:Qe(n)})]})]})]})}function Ks({ownerSlug:s,runId:t,details:n}){return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ht,{ownerSlug:s,runId:t,details:n}),e.jsx(ft,{ownerSlug:s,details:n}),Object.entries(n.fields).map(([r,i])=>e.jsx(gt,{label:Re(r),before:n.current[r],after:i},r)),n.reason&&e.jsxs("div",{className:"rounded-md bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:n.reason})]})]})}function Qs({ownerSlug:s,runId:t,details:n,status:r}){const{operation:i}=n,l=i==="link"||i==="unlink";return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ht,{ownerSlug:s,runId:t,details:n}),!l&&e.jsx(ft,{ownerSlug:s,details:n}),e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Change"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:l?ct(i,r):i==="create"?"Create a new entity after approval.":"Delete this entity after approval."}),l&&e.jsxs("div",{className:"mt-2 space-y-1 text-sm",children:[dt(n.proposal).map((a,u)=>e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:u===0?"From: ":"To: "}),a.name]},a.id)),e.jsxs("div",{className:"text-muted-foreground",children:["Relationship:"," ",String(n.proposal?.relationship_type??n.proposal?.relationship_type_slug??"Relationship")]})]})]}),!l&&n.proposal&&e.jsxs("div",{className:"rounded-lg border border-border/70 p-3",children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Proposal"}),e.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-xs leading-relaxed",children:JSON.stringify(n.proposal,null,2)})]}),n.proposerRationale&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:n.attribution==="agent"?"The agent's reasoning":"The Automation's reasoning"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:n.proposerRationale})]}),n.reason&&e.jsxs("div",{className:"rounded-lg bg-muted/40 px-3 py-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Why this needs approval"}),e.jsx("div",{className:"mt-1 text-sm leading-relaxed",children:n.reason})]})]})}function Ws({summary:s}){return e.jsxs("div",{className:"space-y-2 rounded-md border border-border/70 bg-muted/30 p-3 text-sm",children:[s.chips.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.chips.map(t=>e.jsx(pe,{variant:"outline",className:"text-[10px] font-normal",children:t},t))}),s.message&&e.jsx("p",{className:"leading-relaxed text-foreground",children:s.message}),s.reason&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Why"}),e.jsx("div",{className:"mt-0.5 leading-relaxed",children:s.reason})]}),s.body&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:s.kind==="verify"?"Expected comment":"Draft"}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed",children:s.body})]}),s.matchPreview&&e.jsxs("div",{className:"rounded-md bg-background/80 px-2.5 py-2",children:[e.jsxs("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:["Matched comment",s.matchAuthor?` · ${s.matchAuthor}`:""]}),e.jsx("div",{className:"mt-0.5 whitespace-pre-wrap leading-relaxed text-muted-foreground",children:s.matchPreview})]}),s.postUrl&&e.jsxs("a",{href:s.postUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Open post",e.jsx(rt,{className:"h-3 w-3"})]})]})}function Gs({ownerSlug:s,content:t,batchReview:n}){const r=t.metadata||{},i=t.run_id??void 0,l=Vs(t,r),a=qs(t,r),u=(l?Hs(l):a?Us(a):void 0)||r.operation_name||r.action_name||(t.title?Bs(t.title):void 0)||"Action",N=r.connection_name,j=r.operation_key||r.action_key||null,b=t.interaction_input_schema||r.input_schema||null,f=h.useMemo(()=>t.interaction_input||r.action_input||r.operation_input||Es,[t.interaction_input,r.action_input,r.operation_input]),m=t.interaction_output||r.action_output||void 0,v=Is(f,m??null,j),S=t.interaction_error||r.error_message||void 0,g=pt(t.interaction_status,r.status),_=r.reviewed_by_name||r.reviewed_by_id||void 0,I=r.reject_reason||void 0,H=r.initiator,q=Gt({slug:s}),x=Yt({slug:s}),y=Zt(t.id,Xt(b,f),b),{values:V,setValues:k}=y,[w,J]=h.useState(null),[c,T]=h.useState(!1),[M,P]=h.useState(""),E=g==="pending_approval"&&w?w:g,F=E==="pending_approval",W=typeof r.source_run_id=="number";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(et,{className:"h-4 w-4 text-yellow-500"}),e.jsx("span",{className:"font-medium",children:u}),N&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["on ",N]}),E==="confirmed"&&e.jsx(pe,{variant:"outline",className:"text-blue-700 border-blue-300 bg-blue-50 dark:bg-blue-950/30 text-[10px]",children:"Approved"}),E==="completed"&&e.jsx(pe,{variant:"outline",className:"text-green-700 border-green-300 bg-green-50 dark:bg-green-950/30 text-[10px]",children:"Completed"}),E==="failed"&&e.jsx(pe,{variant:"outline",className:"text-red-700 border-red-300 bg-red-50 dark:bg-red-950/30 text-[10px]",children:"Failed"}),E==="rejected"&&e.jsx(pe,{variant:"outline",className:"text-muted-foreground text-[10px]",children:"Rejected"})]}),!l&&!a&&(t.author_name||_)&&e.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-muted-foreground",children:[t.author_name&&e.jsxs("span",{children:["Requested by"," ",e.jsx(zs,{ownerSlug:s,initiator:H,clientName:t.author_name,fallback:t.author_name})]}),t.author_name&&_&&e.jsx("span",{children:"·"}),_&&e.jsxs("span",{children:[E==="rejected"?"Rejected":"Approved"," by"," ",e.jsx("span",{className:"font-medium text-foreground",children:_})]})]}),l&&e.jsx(Ks,{ownerSlug:s,runId:i,details:l}),!l&&a&&e.jsx(Qs,{ownerSlug:s,runId:i,details:a,status:E}),E==="rejected"&&I&&e.jsxs("div",{className:"rounded-md bg-muted/50 p-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-medium text-foreground",children:"Reason:"})," ",I]}),v&&e.jsx(Ws,{summary:v}),(F?y.revision:b)&&(F||Object.keys(f).length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:v?"Full input":"Input"}),F?e.jsxs(e.Fragment,{children:[e.jsx(es,{visible:y.hasConflict,onReload:y.reset}),e.jsx(ts,{schema:y.revision,values:V,onValuesChange:k,fieldIdPrefix:`action-${t.id}-`},`action-${t.id}`)]}):v?e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw input"}),e.jsx("pre",{className:"mt-1 bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(f,null,2)})]}):e.jsx("pre",{className:"text-xs bg-muted/50 rounded p-2 font-mono overflow-auto max-h-32",children:JSON.stringify(f,null,2)})]}),E==="completed"&&m&&Object.keys(m).length>0&&!v&&e.jsxs("div",{className:"rounded-md bg-green-50 dark:bg-green-950/30 p-3 text-sm space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-green-700 dark:text-green-400 font-medium",children:[e.jsx(ze,{className:"h-3.5 w-3.5"}),"Output"]}),e.jsx("pre",{className:"text-xs text-green-800 dark:text-green-300 font-mono whitespace-pre-wrap",children:JSON.stringify(m,null,2)})]}),E==="completed"&&m&&Object.keys(m).length>0&&v&&e.jsxs("details",{className:"text-xs",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:"Raw output"}),e.jsx("pre",{className:"mt-1 rounded bg-green-50 p-2 font-mono dark:bg-green-950/30 overflow-auto max-h-32",children:JSON.stringify(m,null,2)})]}),E==="failed"&&S&&e.jsxs("div",{className:"rounded-md bg-red-50 dark:bg-red-950/30 p-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-red-700 dark:text-red-400 font-medium",children:[e.jsx(st,{className:"h-3.5 w-3.5"}),"Error"]}),e.jsx("p",{className:"text-xs text-red-800 dark:text-red-300 font-mono mt-1",children:S})]}),F&&!w&&W&&e.jsxs("div",{className:"pt-1 text-xs text-muted-foreground",children:["Review this proposal with the other changes in its Automation run.",n]}),F&&i&&!w&&!W&&e.jsx("div",{className:"flex items-center gap-2 pt-1",children:c?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"Reason (optional)",value:M,onChange:se=>P(se.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>x.mutate({run_id:i,reason:M||void 0},{onSuccess:()=>{J("rejected")}}),disabled:x.isPending,children:[x.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Confirm Reject"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{T(!1),P("")},children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>q.mutate({run_id:i,input:ns(V)},{onSuccess:()=>{J("confirmed")}}),disabled:!y.canSubmit||q.isPending||x.isPending,children:[q.isPending?e.jsx(Se,{size:"sm",className:"mr-1"}):e.jsx(ss,{className:"h-3 w-3 mr-1"}),"Confirm"]}),e.jsxs($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>T(!0),disabled:q.isPending||x.isPending,children:[e.jsx(rs,{className:"h-3 w-3 mr-1"}),"Reject"]})]})})]})}function Ys({content:s,ownerSlug:t}){const n=s.metadata||{},r=n.kind,i=s.run_id??null,l=typeof n.automation_id=="number"?n.automation_id:null,N=it(l!=null?String(l):void 0,void 0,void 0,{includeVersions:!1,ownerSlug:t}).data?.automation?.automation_name??(l!=null?`Automation ${l}`:"An Automation"),j=Qt({slug:t}),b=Wt({slug:t}),[f,m]=h.useState(!1),[v,S]=h.useState(""),[g,_]=h.useState(null);if(r==="automation_batch_reject"){const c=n.reason||void 0;return e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 p-3",children:[e.jsx("div",{className:"text-sm font-medium",children:"Proposals rejected"}),c&&e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:c}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:"Ask the agent to revise its proposals with this feedback."})]})}const I=Array.isArray(n.changes)?n.changes:[],H=typeof n.created_count=="number"?n.created_count:I.filter(c=>c.kind==="created").length,q=typeof n.updated_count=="number"?n.updated_count:I.filter(c=>c.kind==="updated").length,x=typeof n.denied_count=="number"?n.denied_count:I.filter(c=>c.kind==="denied").length,y=I.filter(c=>c.kind==="denied"),V=I.filter(c=>c.kind==="updated"&&Object.keys(c.applied||{}).length>0),k=typeof n.pending_proposal_count=="number"?n.pending_proposal_count:null,w=k==null||k>0,J=w?"proposed":"applied";return e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1",children:[e.jsxs("div",{className:"text-sm font-medium",children:[J==="proposed"?"Proposed":"Applied"," ",H," ","new + ",q," updated",x>0&&e.jsxs(e.Fragment,{children:[" + ",x," denied"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[l!=null?e.jsx(oe,{to:"/$owner/automations/$automationId",params:{owner:t,automationId:String(l)},search:{view:"definition",run_id:void 0},className:"font-medium text-foreground underline-offset-4 hover:underline",children:N}):e.jsx("span",{className:"font-medium text-foreground",children:N}),i!=null&&e.jsxs("span",{children:[" · run #",i]}),k!=null&&k>0&&e.jsxs("span",{children:[" · ",k," pending"]})]})]}),V.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:V.map(c=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:c.name}),Object.entries(c.applied).map(([T,M])=>e.jsx(gt,{label:T,before:M.old,after:M.new},T))]},c.entityId))}),y.length>0&&e.jsx("div",{className:"mt-3 space-y-1.5",children:y.map(c=>e.jsxs("div",{className:"rounded-md border border-destructive/40 bg-destructive/5 px-2.5 py-2",children:[e.jsxs("div",{className:"text-xs font-medium",children:[c.name," — not written"]}),c.denied&&e.jsxs("div",{className:"mt-0.5 text-xs text-muted-foreground",children:[c.denied.reason,e.jsxs("span",{className:"ml-1 opacity-70",children:["(refused by"," ",c.denied.source==="rule"?"a write rule":"org policy",")"]})]})]},`denied-${c.entityId}-${c.name}`))}),i!=null&&g==null&&w&&e.jsx("div",{className:"mt-3 border-t border-border/70 pt-3",children:f?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsx("input",{type:"text",placeholder:"What should the agent change?",value:v,onChange:c=>S(c.target.value),className:"h-7 text-xs border rounded px-2 flex-1 bg-background"}),e.jsxs($,{size:"sm",variant:"destructive",className:"h-7 text-xs",onClick:()=>b.mutate({run_id:i,reason:v||void 0},{onSuccess:()=>_("rejected")}),disabled:b.isPending,children:[b.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Reject all"]}),e.jsx($,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2",onClick:()=>{m(!1),S("")},children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs($,{size:"sm",className:"h-7 text-xs",onClick:()=>j.mutate({run_id:i},{onSuccess:()=>_("approved")}),disabled:j.isPending||b.isPending,children:[j.isPending&&e.jsx(Se,{size:"sm",className:"mr-1"}),"Approve all proposals"]}),e.jsx($,{size:"sm",variant:"outline",className:"h-7 text-xs",onClick:()=>m(!0),disabled:j.isPending||b.isPending,children:"Reject with feedback"})]})}),g==="approved"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals approved."}),g==="rejected"&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"Proposals rejected — ask the agent to revise them."}),i!=null&&g==null&&!w&&e.jsx("div",{className:"mt-3 text-xs text-muted-foreground",children:"All proposals reviewed."})]})}function ke({presentation:s="summary",renderDetail:t,onFiltersChange:n,ownerSlug:r,content:i,isReply:l,showParentContext:a,connectorDefinitions:u,hideOriginator:N=!1,hideRunAction:j=!1,hideAttribution:b=!1,hideDetails:f=!1}){const[m,v]=h.useState(null),S=Ht(),g=s==="detail",_=Vt(),{currentOwner:I,allOrgs:H,isAuthenticated:q}=at(),x=r??I,y=x==="me"?null:x,V=h.useCallback(async p=>{if(!y){Ue.error("Open this event inside a workspace to interact with it.");return}const D=await Rs(y,Number(i.id),p,crypto.randomUUID());return"event_id"in D&&Ue.success("Recorded"),D},[i.id,y]),k=i.payload_data??{},{audit:w,operation:J,changeSet:c}=mt(i),T=w&&(k.request!==void 0||k.request_status==="too_large"),M=w&&Array.isArray(k.sdk_call_trace)&&k.sdk_call_trace.length>0,P=x?qe(x,Number(i.id)):null,E=!g&&q?(H??[]).find(p=>p.slug===y):void 0,F=E?{slug:E.slug,organizationId:E.id}:null,W=lt(F??{slug:null,organizationId:null}),se=F?.slug??null,he=h.useMemo(()=>se&&!w?Ze(W.data??[],i.semantic_type):[],[se,w,W.data,i.semantic_type]),le=Ut(),je=!!(!(J||c)&&F&&he.length>0),K=!g&&!!P,X=qt(_?.item?.href.split(/[?#]/)[0]??""),ne=X?.owner===x&&X?.eventId===Number(i.id),ee=(p,D,O)=>{_?_.open({href:p,title:D,...O==null?{}:{runId:O}}):S({to:p})},de=(p,D)=>{if(!y)return null;const O=`/${y}/events?run_ids=${p}`;return _?.item?.href===O?null:e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>n?n({runIds:[p]}):ee(O,"Run activity",p),title:n?"Filter by this run":"Open run activity",children:[e.jsx(Kt,{className:"h-3.5 w-3.5"}),D]})},ce=i.run_id!=null&&(n||!(_&&y&&i.automation_id!=null))?de(i.run_id,n?"Run":"Open run"):null,U=Jt(i),ue=i.automation_id,Ne=_&&y&&U!=null&&ue!=null?()=>_.open({href:`/${y}/automations/${ue}?run_id=${U}`,title:`${i.automation_name??`Automation ${ue}`} · Run #${U}`,runId:U}):void 0,me=()=>{if(je&&F&&y){const p=Number(i.id);Ss(le,F.slug,he,p).catch(()=>null).then(D=>ee(qe(y,p,D?.key),i.title??"Event"));return}P&&ee(P,i.title??"Event")},re=p=>{const D=p.target;if(!(D instanceof Element))return!1;const O=D.closest('a,button,input,select,textarea,[role="button"],[role="radio"]');return O!==null&&O!==p.currentTarget},Z=p=>{re(p)||me()},ae=p=>{p.key!=="Enter"&&p.key!==" "||re(p)||(p.preventDefault(),me())},fe=i.metadata?.source_run_id,Q=g&&y?c?e.jsx(Ys,{content:i,ownerSlug:y}):J?e.jsx(Gs,{ownerSlug:y,content:i,batchReview:typeof fe=="number"?de(fe,"Review run"):null}):void 0:void 0,ie=g&&t?t(Q):{content:Q,nativeHeading:Q!=null};return e.jsx("div",{className:Te(l?"border-l-2 border-l-muted pl-4":"",K&&"cursor-pointer rounded-lg p-3 transition-colors hover:bg-accent/40",K&&ne&&"bg-accent ring-1 ring-inset ring-primary/20"),...K?{role:"button","aria-current":ne?"true":void 0,tabIndex:0,onClick:Z,onKeyDown:ae}:{},children:e.jsx(en,{primaryContent:ie.content,nativeHeading:ie.nativeHeading,detailLinks:ie.links,headingAside:ie.headingAside,hideDetails:f,onFiltersChange:n,presentation:s,content:i,ownerSlug:x??void 0,showParentContext:a,connectorDefinitions:u,onRenderedAction:y?V:void 0,runAction:j?null:ce,hideOriginator:N,hideAttribution:b,runId:U??i.run_id??null,onRunSelect:Ne,auditDetails:g&&(T||M)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:[{key:"request",label:"Request",available:T},{key:"calls",label:"SDK calls",available:M}].map(p=>p.available?e.jsxs($,{variant:"outline",size:"sm","aria-expanded":m===p.key,onClick:()=>v(D=>D===p.key?null:p.key),children:[m===p.key?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(ye,{className:"h-3.5 w-3.5"}),p.label]},p.key):null)}),m==="request"&&(k.request_status==="too_large"?e.jsxs("p",{className:"text-sm text-muted-foreground",children:["The request was too large to retain",typeof k.request_bytes=="number"?` (${k.request_bytes.toLocaleString()} bytes).`:"."]}):e.jsx(Ke,{value:k.request})),m==="calls"&&e.jsx(Ke,{value:k.sdk_call_trace})]})})})}function Zs(s,t){const n=s.payload_data??{},r=s.metadata??{};if(t.audit&&typeof n.success=="boolean")return n.success?"completed":"failed";if(t.changeSet)return r.kind==="automation_batch_reject"?"rejected":typeof r.pending_proposal_count!="number"?void 0:r.pending_proposal_count>0?"pending_approval":"completed";if(t.operation)return pt(s.interaction_status,typeof r.status=="string"?r.status:void 0)}function Xs(s){return s==="pending_approval"?"Needs approval":s==="confirmed"?"Approved":s?xe(s):null}function en({presentation:s,primaryContent:t,nativeHeading:n=!1,detailLinks:r,headingAside:i,onFiltersChange:l,content:a,ownerSlug:u,showParentContext:N,connectorDefinitions:j,onRenderedAction:b,runAction:f,auditDetails:m,hideOriginator:v=!1,hideAttribution:S=!1,runId:g,onRunSelect:_,hideDetails:I=!1}){const[H,q]=h.useState(!1),x=a.metadata??{},y=typeof a.score=="number"&&Number.isFinite(a.score)?Math.round(a.score):"-",V=a.payload_type||"text",k=a.text_content||"",w=s==="summary",J=s==null&&(V==="text"||V==="markdown")&&k.length>500,c=J&&!H?`${k.slice(0,500)}...`:k,T=a.payload_data??{},M=mt(a),{audit:P,operation:E,changeSet:F}=M,W=Zs(a,M),se=Xs(W),he=w&&P&&typeof T.tool_name=="string"?xe(T.tool_name):a.title,le=P&&T.error&&typeof T.error=="object"?T.error.message:void 0,_e=(typeof le=="string"?le:void 0)??a.interaction_error??(typeof x.error_message=="string"?x.error_message:void 0),je=_e||(P?"":k),[K,X]=h.useState(s!=="summary"&&P&&t==null&&r==null),ne=P?T.duration_ms:x.duration_ms,ee=typeof ne=="number"&&Number.isFinite(ne)&&ne>=0?ne:null,de=P&&typeof T.sdk_call_count=="number"&&Number.isSafeInteger(T.sdk_call_count)&&T.sdk_call_count>=0?T.sdk_call_count:null,ce=x.thumbnail_url||x.thumbnail,U=x.media_url,ue=w?[]:Os(x),Ne=Object.entries(a.classifications||{}).flatMap(([o,d])=>{const R=Ls(d);return R.values.map(A=>({slug:o,value:A,isManual:R.isManual}))}),me=(()=>{const o=a.platform||(typeof x.platform=="string"?x.platform:null),d=a.connection_id!=null?a.connection_id:x.source_connection_id!=null?Number(x.source_connection_id):null;return{...a,platform:o,connection_id:d!=null&&Number.isFinite(d)?d:null}})(),re=(()=>{const o=a.source_url??x.browser_url;if(typeof o!="string"||!URL.canParse(o))return null;const d=new URL(o);return d.protocol==="https:"||d.protocol==="http:"?d:null})(),Z=a.occurred_at?new Date(a.occurred_at):null,ae=me.platform?At(me.platform,j??[]):null,fe=P?Xe:E?et:F?It:a.semantic_type==="notification"?Tt:Et,Q=P?"SDK call":xe(a.semantic_type||a.origin_type||"Event"),ie=e.jsx($t,{plain:!0,name:ae?.name??re?.hostname??Q,icon:ae?.icon,faviconDomain:ae?.faviconDomain??re?.hostname,fallback:e.jsx(fe,{className:"h-4 w-4"}),className:"h-5 w-5 rounded-sm text-xs"}),p=ue.length>0?e.jsx("dl",{className:"grid gap-x-3 gap-y-2 text-sm sm:grid-cols-[minmax(140px,180px)_1fr]",children:ue.map(([o,d])=>e.jsxs("div",{className:"contents",children:[e.jsx("dt",{className:"text-muted-foreground",children:xe(o)}),e.jsx("dd",{className:"min-w-0 break-words font-mono text-xs sm:text-sm",children:Ps(d)})]},o))}):null,D=w?je?e.jsx("p",{className:Te("line-clamp-2 text-sm whitespace-pre-wrap",_e&&"text-destructive"),children:je.slice(0,320)}):null:e.jsxs(e.Fragment,{children:[a.rating&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:[1,2,3,4,5].map(o=>e.jsx(tt,{className:`h-4 w-4 ${o<=Number(a.rating)?"fill-yellow-400 text-yellow-400":"text-muted-foreground"}`},o))}),ce&&e.jsx("a",{href:U||a.source_url||"#",target:"_blank",rel:"noopener noreferrer",className:"block mb-2",children:e.jsx("img",{src:ce,alt:"",className:`rounded-md object-cover ${V==="media"?"max-h-96 w-full":"max-h-48"}`,loading:"lazy"})}),(()=>{switch(V){case"markdown":if(c)return e.jsx("div",{className:"max-w-none text-sm space-y-2",children:e.jsx(Dt,{text:c})});break;case"json_template":{const o=a.payload_template;if(o?.root)return e.jsx(Ts,{template:o,data:a.payload_data||{},onAction:t?void 0:b},`${u}:${a.id}`);if(c)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:c});break}case"media":return e.jsxs("div",{className:"space-y-3",children:[!ce&&U&&e.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate block",children:U}),c&&e.jsx("div",{className:"text-sm whitespace-pre-wrap text-muted-foreground",children:c})]});case"empty":return e.jsxs("div",{className:"space-y-3",children:[m,p??(m?null:e.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No content"}))]});default:if(c)return e.jsx("div",{className:"text-sm whitespace-pre-wrap",children:c});break}return e.jsxs("div",{className:"space-y-3",children:[U&&!ce&&e.jsx("a",{href:U,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-muted-foreground hover:text-foreground truncate block",children:U}),p]})})()]}),O=t!=null||s==="detail"&&P,ge=i!==void 0,Ae=O||r!=null;return h.useEffect(()=>{if(!ge||!K)return;const o=d=>{d.key==="Escape"&&(d.preventDefault(),X(!1))};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[ge,K]),e.jsxs(e.Fragment,{children:[N&&a.parent_context&&e.jsxs("div",{className:"mb-3 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:"Replying to:"}),e.jsx("div",{className:"font-medium",children:a.parent_context.author_name}),e.jsx("div",{className:"text-muted-foreground line-clamp-2",children:a.parent_context.text_content})]}),e.jsxs("div",{className:Te("flex gap-3",s==="detail"&&"mb-5",ge&&"relative"),children:[e.jsx("div",{"aria-hidden":!0,className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:ie}),e.jsxs("div",{className:"min-w-0 flex-1",children:[s==="detail"&&(()=>{const o={semanticTypes:[a.semantic_type],...typeof a.automation_id=="number"?{producedByAutomationId:a.automation_id}:{},...typeof a.run_id=="number"?{runIds:[a.run_id]}:{}},d={semantic_types:a.semantic_type,...typeof a.automation_id=="number"?{produced_by:String(a.automation_id)}:{},...typeof a.run_id=="number"?{run_ids:String(a.run_id)}:{}};return e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[a.semantic_type?l?e.jsx("button",{type:"button",className:"hover:underline",title:`Show all ${Q} events`,onClick:()=>l(o),children:Q}):u?e.jsx(oe,{to:"/$owner/events",params:{owner:u},search:d,className:"hover:underline",title:`Show all ${Q} events`,children:Q}):e.jsx("span",{children:Q}):e.jsx("span",{children:Q}),Z&&e.jsx("time",{dateTime:Z.toISOString(),children:be(Z)})]})})(),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[he&&!n&&e.jsx("h4",{className:Te("min-w-0 font-medium",s==="detail"?"text-xl leading-snug":"line-clamp-2 text-sm"),children:he}),s!=="detail"&&Z&&e.jsx("time",{dateTime:Z.toISOString(),title:be(Z),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Ce(Z,"HH:mm")}),ge&&e.jsxs("div",{className:"flex shrink-0 items-center gap-1 pt-0.5",children:[i,Ae&&e.jsxs($,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 px-2 text-muted-foreground hover:text-foreground","aria-expanded":K,onClick:()=>X(o=>!o),children:["Details",K?e.jsx(ve,{className:"h-3.5 w-3.5"}):e.jsx(ye,{className:"h-3.5 w-3.5"})]})]})]}),w&&e.jsx("div",{className:"mt-1 text-muted-foreground",children:D}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[se&&!n&&e.jsxs(pe,{variant:W==="failed"?"destructive":"secondary",className:"gap-1 text-xs",children:[W==="failed"?e.jsx(st,{className:"h-3 w-3"}):W==="completed"?e.jsx(ze,{className:"h-3 w-3"}):null,se]}),de!=null&&e.jsxs("span",{children:[de," SDK ",de===1?"call":"calls"]}),ee!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"h-3 w-3"}),ee<1e3?`${Math.round(ee)}ms`:`${Number((ee/1e3).toFixed(2))}s`]}),f,y==="-"||w&&(P||E||F)?null:a.score_breakdown?e.jsxs(Pt,{children:[e.jsx(Ot,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 px-2",children:e.jsx("span",{className:"font-medium",children:y})})}),e.jsx(Ft,{className:"w-64",align:"end",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:"Score Breakdown"}),e.jsx(Fs,{breakdown:a.score_breakdown})]})})]}):null,re&&e.jsxs(Mt,{children:[e.jsx(Lt,{asChild:!0,children:e.jsx($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1",asChild:!0,children:e.jsxs("a",{href:re.href,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(rt,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:w?"sr-only":void 0,children:"View original"})]})})}),e.jsx(Bt,{children:"View original"})]})]}),u&&!S&&e.jsx(zt,{owner:u,source:me,connectorDefinitions:j,onFiltersChange:l,variant:"chips",className:"mt-2 text-xs",hideOriginator:v,runId:g,onRunSelect:_}),(a.author_name||!u)&&!(s==="detail"&&E)&&e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:a.author_name||Ds(a)})]}),ge&&K&&Ae&&e.jsxs("div",{className:"absolute inset-x-0 top-full z-20 mt-2 max-h-[65vh] space-y-3 overflow-y-auto rounded-lg border bg-background p-3 shadow-lg",children:[r,O&&D]})]}),!w&&typeof le=="string"&&e.jsx("p",{className:"mb-2 text-sm whitespace-pre-wrap text-destructive",children:le}),t,!w&&!O&&D,(O||r!=null)&&i===void 0&&!(I&&t!=null)&&e.jsxs("details",{className:"mt-5 border-t pt-3",open:K,onToggle:o=>X(o.currentTarget.open),children:[e.jsx("summary",{className:"cursor-pointer text-sm text-muted-foreground",children:"Details"}),K&&e.jsxs("div",{className:"mt-3 space-y-3",children:[r,O&&D]})]}),J&&e.jsx($,{variant:"link",size:"sm",className:"px-0 h-6 mt-1",onClick:()=>q(!H),children:H?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3 w-3 mr-1"})," Show less"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3 w-3 mr-1"})," Show more"]})}),Ne.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:Ne.map(o=>e.jsx(Ms,{slug:o.slug,value:o.value||"",isManual:o.isManual},o.slug))})]})}function tn({toolName:s,count:t,totalDurationMs:n,totalSdkCalls:r,newestAt:i,oldestAt:l,expanded:a,onToggle:u,children:N}){return e.jsx("div",{children:e.jsxs(Ee,{open:a,children:[e.jsx("div",{className:"rounded-lg p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{"aria-hidden":!0,className:"mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:u,children:[e.jsxs("span",{className:"min-w-0 truncate font-medium text-foreground",children:[xe(s)," × ",t]}),a?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(vt,{newestAt:i,oldestAt:l})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[e.jsxs(pe,{variant:"secondary",className:"gap-1 text-xs",children:[e.jsx(ze,{className:"h-3 w-3"}),"Completed"]}),r!=null&&e.jsxs("span",{children:[r," SDK ",r===1?"call":"calls"]}),n!=null&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"h-3 w-3"}),sn(n)]})]})]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:N})]})})}function sn(s){return s<1e3?`${Math.round(s)}ms`:`${Number((s/1e3).toFixed(2))}s`}function vt({newestAt:s,oldestAt:t}){const n=We(s),r=We(t);return n!=null&&r!=null&&n.getTime()-r.getTime()>nn&&r?e.jsxs("time",{dateTime:n.toISOString(),title:`${be(r)} – ${be(n)}`,className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:[Ce(r,"HH:mm"),"–",Ce(n,"HH:mm")]}):n?e.jsx("time",{dateTime:n.toISOString(),title:be(n),className:"shrink-0 pt-0.5 text-xs text-muted-foreground",children:Ce(n,"HH:mm")}):null}const nn=300*1e3;function We(s){if(s==null||s==="")return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:t}function rn({organizationId:s,clientId:t,activityId:n,activityKind:r,callCount:i,newestAt:l,oldestAt:a,expanded:u,onToggle:N,children:j}){const{data:b=[]}=as({limit:100,organizationId:s??null}),f=b.find(S=>S.activityId===n&&(t==null||S.clientId===t))??null,m=f?bs(f):r==="session"?"MCP session":"Conversation",v=f?.clientName??null;return e.jsx("div",{children:e.jsxs(Ee,{open:u,children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border bg-background",children:e.jsx(ot,{name:v})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"h-5 min-w-0 gap-1.5 px-0 text-sm text-muted-foreground",onClick:N,children:[e.jsx("span",{className:"min-w-0 truncate font-medium text-foreground",children:m}),u?e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(ye,{className:"h-3.5 w-3.5 shrink-0"})]})}),e.jsx(vt,{newestAt:l,oldestAt:a})]}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[`${i} ${i===1?"call":"calls"}`,v?` · ${v}`:null]})]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:j})]})})}function an({onIntersect:s,enabled:t,rootMargin:n="400px"}){const r=h.useRef(null),i=h.useRef(s);return i.current=s,h.useEffect(()=>{const l=r.current;if(!l||!t)return;const a=new IntersectionObserver(u=>{u[0]?.isIntersecting&&i.current()},{rootMargin:n});return a.observe(l),()=>a.disconnect()},[t,n]),r}function Ge(s){if(s==null||s==="")return null;const t=new Date(s);return Number.isNaN(t.getTime())?null:Ce(t,"d MMMM yyyy")}function on({items:s,isLoading:t,emptyState:n,dense:r,hasNextPage:i,isFetching:l,isFetchingNextPage:a,onLoadMore:u,autoLoadMore:N=!0,groupByDate:j=!0}){const b=an({onIntersect:u,enabled:N&&i&&!l});return t&&s.length===0?e.jsx("div",{className:"space-y-4",children:["s1","s2","s3"].map(f=>e.jsx(is,{className:"h-32 rounded-lg"},f))}):e.jsxs("div",{className:r?"":"pt-1",children:[s.length===0?n!==void 0?n:e.jsx(os,{icon:ls,title:"Nothing here yet",description:"No events match this view."}):s.map((f,m)=>{const v=Ge(f.occurredAt),S=m>0?Ge(s[m-1].occurredAt):null;return e.jsxs(h.Fragment,{children:[j&&v&&v!==S&&e.jsx("p",{className:"px-3 pb-2 pt-4 text-xs text-muted-foreground",children:v}),e.jsx("div",{className:"mb-1",children:f.content})]},f.key)}),e.jsx("div",{ref:b,className:"h-1"}),a?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(Se,{size:"xl",className:"text-muted-foreground"})}):i&&e.jsx($,{size:"sm",variant:"outline",disabled:l,onClick:u,children:"Load more"})]})}function xn({presentation:s="summary",renderDetail:t,onFiltersChange:n,hideDetails:r=!1,organizationId:i,ownerSlug:l,entityId:a,filters:u,showEntityLinks:N=!1,hideOriginator:j=!1,emptyState:b,dense:f=!1,foldConsecutiveCalls:m=!1,groupByConversation:v=!1,groupByRun:S=!1,onRunSelect:g,runs:_,hideRunAction:I=!1,hideAttribution:H=!1}){const{isAuthenticated:q,isReady:x}=ds(),{isMember:y,isLoading:V}=cs(),k=l==="me",w=!k&&x&&q&&y,J=!k&&x&&(!q||!V&&!y),{data:c=[]}=us(x&&w?i:null),{data:T=[]}=ms(J?l:null),M=w?c:T,P=ps(x&&w?i:null,a,u,l),E=xs(J?l:null,a,u),F=J?E:P,{data:W,isLoading:se,error:he,fetchNextPage:le,hasNextPage:_e,isFetchingNextPage:je}=F,K=h.useMemo(()=>W?.pages.flatMap(o=>o.content)??[],[W]),X=h.useMemo(()=>{const o=hs(K,{foldRunSatellites:!S}),d=o.map(L=>L.head),R=new Map(o.map(L=>[L.head.id,L])),A=fs(d,{groupByRun:S});return Array.from(A.entries()).map(([L,Y])=>{const B=Y.root||Y.replies[0],G=B?R.get(B.id):void 0;return{rootId:L,group:Y,history:G?.history??[],runId:G?.runId??null}})},[K,S]),[ne,ee]=h.useState(new Set),[de,ce]=h.useState(new Set),[U,ue]=h.useState(new Set),[Ne,me]=h.useState(new Set),[re,Z]=h.useState(new Set),ae=(o,d)=>o(R=>{const A=new Set(R);return A.has(d)?A.delete(d):A.add(d),A}),fe=(o,d)=>d.some(R=>o.has(R)),Q=(o,d)=>o(R=>{const A=new Set(R),L=d.some(Y=>A.has(Y));for(const Y of d)L?A.delete(Y):A.add(Y);return A}),ie=m?gs(X):X.map(o=>({kind:"single",node:o})),p=v?vs(ie):ie,D=!k&&(!x||q&&V||w&&F.isPending);if(he)return e.jsx(ys,{label:"events"});const O=o=>{if(o.kind==="fold"){const{fold:C}=o,Ve=C.nodes.map(Pe=>Pe.rootId),Nt=fe(de,Ve);return[{key:C.key,occurredAt:C.newestAt,content:e.jsx(tn,{toolName:C.toolName,count:C.nodes.length,totalDurationMs:C.totalDurationMs,totalSdkCalls:C.totalSdkCalls,newestAt:C.newestAt,oldestAt:C.oldestAt,expanded:Nt,onToggle:()=>Q(ce,Ve),children:C.nodes.map(Pe=>{const Oe=Pe.group.root;return Oe?e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:Oe,renderDetail:t,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H,hideDetails:r},Oe.id):null})})}]}const{rootId:d,group:R,history:A,runId:L}=o.node,Y=R.replies.length>0,B=ne.has(d),G=re.has(d),He=Ne.has(d),yt=R.replies.filter(C=>C.depth<=3),Ie=R.replies.filter(C=>C.depth>3),jt=!R.root&&R.replies.length>0,te=R.root||R.replies[0];return te?[{key:d,occurredAt:te.occurred_at,content:e.jsxs(e.Fragment,{children:[N&&l&&te.entity_name&&te.entity_type&&te.entity_slug&&e.jsx("div",{className:"mb-2",children:e.jsx(Cs,{ownerSlug:l,entity:{entityName:te.entity_name,entityType:te.entity_type,entitySlug:te.entity_slug}})}),e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:te,renderDetail:t,showParentContext:jt&&!!te.parent_context,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H,hideDetails:r}),A.length>0&&e.jsxs(Ee,{open:He,children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-1 h-7 gap-1 text-xs text-muted-foreground",onClick:()=>ae(me,d),children:[e.jsx(Ns,{className:"h-3.5 w-3.5"}),He?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",L!=null?`run #${L} `:"","history"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),L!=null?`Run #${L} · ${A.length===1?"1 earlier step":`${A.length} earlier steps`}`:A.length===1?"1 earlier state":`${A.length} earlier states`]})]})}),e.jsx(De,{className:"mt-2 space-y-3 border-l-2 border-l-muted pl-4",children:A.map(C=>e.jsxs("div",{children:[e.jsx("time",{dateTime:new Date(C.occurred_at).toISOString(),title:be(C.occurred_at),className:"mb-1 block text-xs text-muted-foreground",children:Je(C.occurred_at)}),e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H})]},C.id))})]}),Y&&e.jsxs(Ee,{open:B,children:[e.jsx($e,{asChild:!0,children:e.jsxs($,{variant:"ghost",size:"sm",className:"mt-2 ml-6 gap-1",onClick:()=>ae(ee,d),children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),B?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Hide ",R.replies.length," replies"]}):e.jsxs(e.Fragment,{children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),"Show ",R.replies.length," replies"]})]})}),e.jsxs(De,{className:"space-y-2 mt-2",children:[yt.map(C=>e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,isReply:!0,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H},C.id)),Ie.length>0&&e.jsxs(e.Fragment,{children:[e.jsx($,{variant:"ghost",size:"sm",className:"ml-12",onClick:()=>ae(Z,d),children:G?e.jsxs(e.Fragment,{children:["Hide ",Ie.length," nested replies"]}):e.jsxs(e.Fragment,{children:["Show ",Ie.length," nested replies"]})}),G&&Ie.map(C=>e.jsx(ke,{presentation:s,onFiltersChange:n,ownerSlug:l,content:C,isReply:!0,connectorDefinitions:M,hideOriginator:j,hideRunAction:I,hideAttribution:H},C.id))]})]})]})]})}]:[]},ge=o=>{const d=o.nodes.length;return{key:o.key,occurredAt:o.newestAt,content:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[g?e.jsxs($,{variant:"ghost",size:"sm",className:"h-7 gap-1 px-1 text-xs font-medium",onClick:()=>g(o.runId),title:`Open run #${o.runId} conversation`,children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),"Run #",o.runId]}):e.jsxs("span",{className:"inline-flex h-7 items-center gap-1 px-1 text-xs font-medium",children:[e.jsx(Fe,{className:"h-3.5 w-3.5"}),"Run #",o.runId]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.status!=null?`· ${xe(o.status)} · `:"· ",d===1?"1 event":`${d} events`,o.newestAt!=null?` · ${Je(o.newestAt)}`:""]})]}),e.jsx("div",{className:"mt-2 space-y-2 border-l-2 border-l-muted pl-4",children:o.nodes.flatMap(R=>O({kind:"single",node:R}).map(A=>e.jsx(h.Fragment,{children:A.content},A.key)))})]})}},Ae=o=>{const{block:d}=o,R=d.entries.flatMap(B=>B.kind==="fold"?B.fold.nodes.map(G=>G.rootId):[B.node.rootId]),A=fe(U,R),L=d.entries.flatMap(B=>O(B).map(G=>({key:G.key,content:G.content})));if(L.length===0)return[];const Y=d.entries.reduce((B,G)=>B+(G.kind==="fold"?G.fold.nodes.length:1),0);return[{key:d.key,occurredAt:d.newestAt,content:e.jsx(rn,{organizationId:i,clientId:d.clientId,activityId:d.activityId,activityKind:d.activityKind,callCount:Y,newestAt:d.newestAt,oldestAt:d.oldestAt,expanded:A,onToggle:()=>Q(ue,R),children:L.map(B=>e.jsx(h.Fragment,{children:B.content},B.key))})}]};return e.jsx(on,{groupByDate:s==="summary",dense:f,isLoading:se||D,emptyState:b,hasNextPage:!!_e,isFetching:F.isFetching,isFetchingNextPage:je,onLoadMore:()=>void le(),items:S?js(X,_).map(o=>"nodes"in o?ge(o):O({kind:"single",node:o})[0]).filter(o=>o!=null):p.flatMap(o=>o.kind==="context"?Ae(o):O(o))})}export{xn as E,on as a,en as b,mn as c,pn as u};
|
|
2
|
-
//# sourceMappingURL=events-feed-fucGZSJR.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d4 as T,j as e,B as f,P as g,r as m,d5 as C,X as O,d6 as k,d7 as S,cy as z,C as B,d8 as D,d9 as E,da as F,db as L,cj as $,ck as R,Q as I,dc as j,dd as Q,de as _,df as N,dg as b,I as y,dh as A}from"./index-_oPeVpL_.js";function w(s,t,n){return T(s,-t,n)}const P="w-72";function M({editor:s,close:t,header:n,footer:o}){const[r,a]=m.useState("");return e.jsxs(e.Fragment,{children:[n,s.kind==="list"?e.jsxs(D,{shouldFilter:!s.onQueryChange,children:[e.jsx(E,{autoFocus:!0,placeholder:s.searchPlaceholder,value:r,onValueChange:u=>{a(u),s.onQueryChange?.(u)}}),e.jsxs(F,{children:[e.jsx(L,{children:s.emptyText}),e.jsx($,{children:s.items(t,r)})]})]}):s.render(t),o]})}function H({chip:s,editor:t}){const[n,o]=m.useState(!1),r=s.onRemove!=null,a=[s.label,s.op,s.value].filter(Boolean).join(" "),u=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:s.label}),s.op?e.jsx("span",{className:"text-muted-foreground",children:s.op}):null,e.jsx("span",{className:"min-w-0 truncate font-medium",children:s.value})]}),l=t?e.jsx(S,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":`Edit filter: ${a}`,className:"flex min-w-0 items-center gap-1.5 pl-2.5 pr-1 focus-visible:outline-none",children:u})}):e.jsx("span",{className:"flex min-w-0 items-center gap-1.5 pl-2.5 pr-1",children:u});return e.jsxs(C,{open:n,onOpenChange:o,children:[e.jsxs("div",{"data-filter-chip":s.id,title:s.title,className:g("inline-flex h-8 max-w-full items-stretch rounded-md border text-sm",s.tone==="warning"?"border-amber-500/60 bg-amber-500/10":r?"bg-muted":"border-dashed bg-transparent",n&&"ring-1 ring-ring",!r&&"pr-1.5"),children:[l,r?e.jsx("button",{type:"button","aria-label":`Remove filter: ${a}`,onClick:s.onRemove,className:"flex w-7 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:text-foreground",children:e.jsx(O,{className:"h-3.5 w-3.5"})}):null]}),t?e.jsx(k,{align:"start",className:g("p-0",P,t.className),children:e.jsx(M,{editor:t,close:()=>o(!1),footer:r?e.jsx("div",{className:"border-t p-1",children:e.jsx(f,{variant:"ghost",size:"sm",className:"w-full justify-start text-destructive hover:text-destructive",onClick:()=>{o(!1),s.onRemove?.()},children:"Remove filter"})}):null})}):null]})}function U({fields:s}){const[t,n]=m.useState(!1),[o,r]=m.useState(),a=s.find(i=>i.key===o),u=[...new Set(s.map(i=>i.group??""))],l=()=>{n(!1),r(void 0)};return e.jsxs(C,{open:t,onOpenChange:i=>{n(i),i||r(void 0)},children:[e.jsx(S,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"h-8 border-dashed font-normal text-muted-foreground",children:[e.jsx(z,{className:"mr-1 h-3.5 w-3.5"}),"Filter"]})}),e.jsx(k,{align:"start",className:g("p-0",P,a?.editor.className),children:a?e.jsx(M,{editor:a.editor,close:l,header:e.jsxs("div",{className:"flex items-center gap-1 border-b px-1 py-1 text-sm font-medium",children:[e.jsx(f,{variant:"ghost",size:"icon",className:"h-7 w-7","aria-label":"Back to filters",onClick:()=>r(void 0),children:e.jsx(B,{className:"h-4 w-4"})}),a.label]})},a.key):e.jsxs(D,{children:[e.jsx(E,{autoFocus:!0,placeholder:"Filter by…"}),e.jsxs(F,{children:[e.jsx(L,{children:"No matching filter"}),u.map(i=>e.jsx($,{heading:i||void 0,children:s.filter(d=>(d.group??"")===i).map(d=>e.jsxs(R,{value:`${d.label} ${d.key}`,onSelect:()=>r(d.key),className:"gap-2",children:[d.icon?e.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground",children:d.icon}):null,d.label]},d.key))},i))]})]})})]})}function K({fields:s,chips:t,meta:n,trailing:o,onClearAll:r,hasClearableState:a=!1,className:u,label:l="Filters"}){const i=s.filter(c=>c.inMenu!==!1),d=t.filter(c=>c.onRemove).length;return e.jsxs("div",{role:"search","aria-label":l,className:g("flex min-w-0 flex-wrap items-center gap-2",u),children:[t.map(c=>e.jsx(H,{chip:c,editor:c.editor??s.find(x=>x.key===(c.field??c.id))?.editor},c.id)),i.length>0?e.jsx(U,{fields:i}):null,e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[n?e.jsx("span",{className:"text-sm text-muted-foreground",children:n}):null,r&&(d>0||a)?e.jsx(f,{variant:"ghost",size:"sm",className:"h-8 text-muted-foreground",onClick:r,children:"Clear all"}):null,o]})]})}function V({selected:s}){return e.jsx(Q,{className:g("h-4 w-4 shrink-0",s?"opacity-100":"opacity-0")})}function Y({searchPlaceholder:s,emptyText:t="No options",options:n,selected:o,multiple:r=!1,onSelect:a}){return{kind:"list",searchPlaceholder:s,emptyText:t,items:u=>n.map(l=>{const i=o.includes(l.value);return e.jsxs(R,{value:`${l.label} ${l.keywords??l.value}`,onSelect:()=>{a(l.value),r||u()},className:"gap-2",children:[r?e.jsx(I,{checked:i,className:"mr-1"}):e.jsx(V,{selected:i}),l.icon,e.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.label}),l.count!=null?e.jsx("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:l.count.toLocaleString()}):null]},l.value)})}}function Z([s,t],n,o){return s<=n?`≤ ${t}`:t>=o?`≥ ${s}`:`${s}–${t}`}function q({value:s,min:t,max:n,onApply:o,close:r}){const[a,u]=m.useState(String(s?.[0]??t)),[l,i]=m.useState(String(s?.[1]??n)),[d,c]=m.useState(),x=h=>{h.preventDefault();const v=Number(a),p=Number(l);if(!Number.isFinite(v)||!Number.isFinite(p)){c("Enter a number.");return}if(v<t||p>n){c(`Use values between ${t} and ${n}.`);return}if(v>p){c("The lower bound must not exceed the upper bound.");return}o([v,p]),r()};return e.jsxs("form",{className:"space-y-3 p-3",onSubmit:x,children:[e.jsxs("div",{className:"grid grid-cols-[1fr_auto_1fr] items-center gap-2",children:[e.jsx(y,{"aria-label":"From",type:"number",min:t,max:n,value:a,onChange:h=>u(h.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(y,{"aria-label":"To",type:"number",min:t,max:n,value:l,onChange:h=>i(h.target.value)})]}),d?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:d}):null,e.jsx(f,{type:"submit",size:"sm",className:"w-full",children:"Apply"})]})}function ee(s){return{kind:"custom",render:t=>e.jsx(q,{...s,close:t})}}const G=[{label:"Today",range:()=>[N(new Date),b(new Date)]},{label:"Last 7 days",range:()=>[N(w(new Date,6)),b(new Date)]},{label:"Last 30 days",range:()=>[N(w(new Date,29)),b(new Date)]},{label:"This month",range:()=>[A(new Date),b(new Date)]}];function se([s,t]){return j(s,"yyyy-MM-dd")===j(t,"yyyy-MM-dd")?j(s,"LLL d, y"):`${j(s,"LLL d")} – ${j(t,"LLL d, y")}`}function W({value:s,onApply:t,close:n}){const[o,r]=m.useState(s?{from:s[0],to:s[1]}:void 0);return e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[e.jsx("div",{className:"flex flex-col gap-0.5 border-b p-2 sm:w-36 sm:border-b-0 sm:border-r",children:G.map(a=>e.jsx(f,{variant:"ghost",size:"sm",className:"justify-start font-normal",onClick:()=>{t(a.range()),n()},children:a.label},a.label))}),e.jsx(_,{mode:"range",defaultMonth:o?.from,selected:o,onSelect:a=>{r(a),a?.from&&a.to&&a.from!==a.to&&(t([N(a.from),b(a.to)]),n())},numberOfMonths:1})]})}function te(s){return{kind:"custom",className:"w-auto",render:t=>e.jsx(W,{...s,close:t})}}function X({type:s,label:t,value:n,onApply:o,close:r}){const[a,u]=m.useState(n==null?"":String(n)),[l,i]=m.useState(),d=c=>{if(c.preventDefault(),s==="number"){const x=Number(a);if(a.trim()===""||!Number.isFinite(x)){i("Enter a number.");return}o(x)}else o(a);r()};return e.jsxs("form",{className:"space-y-3 p-3",onSubmit:d,children:[e.jsx(y,{autoFocus:!0,"aria-label":t,type:s,step:s==="number"?"any":void 0,value:a,onChange:c=>u(c.target.value),placeholder:"Enter a value…"}),l?e.jsx("p",{role:"alert",className:"text-xs text-destructive",children:l}):null,e.jsx(f,{type:"submit",size:"sm",className:"w-full",children:"Apply"})]})}function ae(s){return{kind:"custom",render:t=>e.jsx(X,{...s,close:t})}}export{K as F,V as S,Z as a,te as d,se as f,Y as o,ee as r,ae as v};
|
|
2
|
-
//# sourceMappingURL=filter-editors-DCQgGLyR.js.map
|