@lobu/runtime-server 24.1.0 → 24.2.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 +151 -37
- package/dist/catalogs/skills.json +2 -2
- package/dist/component.json +1 -1
- package/dist/connectors/google_gmail.ts +70 -41
- package/dist/connectors/google_gmail_references.ts +406 -0
- package/dist/connectors/linkedin-inbox-adapter.js +107 -36
- package/dist/connectors/linkedin-inbox.ts +13 -0
- package/dist/connectors/linkedin.ts +1 -1
- package/dist/connectors/postgres.ts +5 -3
- package/dist/connectors/reddit.ts +171 -5
- package/dist/connectors/whatsapp-web-adapter.js +147 -61
- package/dist/connectors/whatsapp-web-helpers.ts +6 -2
- package/dist/connectors/whatsapp_web.ts +48 -17
- package/dist/connectors/x-dm-adapter.js +252 -35
- package/dist/connectors/x.ts +189 -13
- package/dist/db/migrations/20261020140000_view_attachments_by_page.sql +3 -1
- package/dist/db/migrations/20261024050000_events_source_reference_arrival.sql +27 -0
- package/dist/db/migrations/20261026000000_turn_write_receipts.sql +36 -0
- package/dist/db/migrations/20261026190000_federated_relationship_endpoints.sql +143 -0
- package/dist/dependencies.bun.lock +81 -83
- package/dist/embeddings-server.mjs +81 -11
- package/dist/guest.bundle.js +62 -25
- package/dist/owletto/dist/assets/_-Cjvw31gU.js +2 -0
- package/dist/owletto/dist/assets/_-iToIRRFt.js +3 -0
- package/dist/owletto/dist/assets/_agentId-CLdj0X7j.js +2 -0
- package/dist/owletto/dist/assets/_agentId-D5cAWjrP.js +2 -0
- package/dist/owletto/dist/assets/_automationId-BhEZmkJU.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DZtLc3WW.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-BoYpah_l.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-ML2TjCwN.js +2 -0
- package/dist/owletto/dist/assets/_eventId-BYc3I2EL.js +2 -0
- package/dist/owletto/dist/assets/_name-BsOZmvlH.js +2 -0
- package/dist/owletto/dist/assets/_owner-UuyQLJ-0.js +3 -0
- package/dist/owletto/dist/assets/_shape-BpnVAYWH.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-CYrGvNn-.js +2 -0
- package/dist/owletto/dist/assets/_slug-MHQU8ftJ.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CGAJ1ucr.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-CMkhfs1k.js +2 -0
- package/dist/owletto/dist/assets/accept-invitation-D2T_a2dj.js +2 -0
- package/dist/owletto/dist/assets/activity-route-view-_G_lDz5K.js +2 -0
- package/dist/owletto/dist/assets/agent-card-controls-ColL5rdd.js +2 -0
- package/dist/owletto/dist/assets/{agent-client-setup-list-BlXB4SE5.js → agent-client-setup-list-BgyLhJCo.js} +2 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BryZas7Z.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-DsSoeQeF.js → agent-editor-form-C24p9LLg.js} +2 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-D9PpDgR-.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-B7v6Cffw.js → agent-loading-shells-jkf9DjdO.js} +2 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-C8j8kRB1.js +2 -0
- package/dist/owletto/dist/assets/{agent-skill-context-DFucg4c4.js → agent-skill-context-B9giw2u2.js} +2 -2
- package/dist/owletto/dist/assets/agent-skills-route-BMZ3r1bP.js +2 -0
- package/dist/owletto/dist/assets/agent-subpage-shell-D49f-bzP.js +2 -0
- package/dist/owletto/dist/assets/{agent-thread-D38STyeu.js → agent-thread-BGHYHWDO.js} +4 -4
- package/dist/owletto/dist/assets/agents-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-D1YL3VAB.js +2 -0
- package/dist/owletto/dist/assets/app._appId-A51tx2jU.js +2 -0
- package/dist/owletto/dist/assets/automation-detail-content-DCAZBKle.js +2 -0
- package/dist/owletto/dist/assets/automations-C05k-Xw6.js +2 -0
- package/dist/owletto/dist/assets/callback-WmyCei3R.js +2 -0
- package/dist/owletto/dist/assets/{card-jzhQrMDP.js → card-Cspo-4M6.js} +2 -2
- package/dist/owletto/dist/assets/{claim-B-wq745Q.js → claim-CCKdBtFt.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-CmK3DkSP.js +2 -0
- package/dist/owletto/dist/assets/client-rows-fFuxzFtE.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-CEqoCky-.js → code-editor-C8FJbT2P.js} +3 -3
- package/dist/owletto/dist/assets/connect-BmCUJ3lr.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-B6StGCPK.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-CPiMA6Bx.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-BialEDmu.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-X1wVi6v0.js +2 -0
- package/dist/owletto/dist/assets/{connection-CNm2ukrI.js → connection-DJd9bnEc.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-WcGCA6qY.js → connection-feed-detail-IO6G5QjL.js} +2 -2
- package/dist/owletto/dist/assets/connections-browser-CzdcZeiU.js +2 -0
- package/dist/owletto/dist/assets/{connector-provenance-D-ECOlMJ.js → connector-provenance-bmBJJ9B4.js} +2 -2
- package/dist/owletto/dist/assets/connector-scope-lists-B44Q9W-j.js +2 -0
- package/dist/owletto/dist/assets/{connectors-CH4KBZyT.js → connectors-CTWPDH8f.js} +2 -2
- package/dist/owletto/dist/assets/{consent-C9ZpHb7V.js → consent-C_WBfmQ8.js} +2 -2
- package/dist/owletto/dist/assets/copy-button-kcjg8Giw.js +2 -0
- package/dist/owletto/dist/assets/{core.esm-BupT3V0i.js → core.esm-CoJ5Splc.js} +2 -2
- package/dist/owletto/dist/assets/create-CQE5rD0i.js +2 -0
- package/dist/owletto/dist/assets/create-DQNlRTUX.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-y3tq2QIJ.js +3 -0
- package/dist/owletto/dist/assets/create-lOFSQV_5.js +2 -0
- package/dist/owletto/dist/assets/create._connectorKey-icyNicvn.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-CWImw-kf.js → cronstrue-CeUS_78Q.js} +2 -2
- package/dist/owletto/dist/assets/{device-D-7WBe9E.js → device-Br9JHadR.js} +2 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-7UpeD4Sq.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-DGMmjr01.js +2 -0
- package/dist/owletto/dist/assets/elk-worker.min-BENGc9gn.js +23 -0
- package/dist/owletto/dist/assets/{entity-avatar-mdh7Kq5D.js → entity-avatar-BZIa-7i5.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-BcTafZ2e.js +2 -0
- package/dist/owletto/dist/assets/entity-page-CY7PF3X9.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-BzMZttzh.js +2 -0
- package/dist/owletto/dist/assets/{event-detail-DV_zfWnC.js → event-detail-C25TvOb_.js} +2 -2
- package/dist/owletto/dist/assets/events-feed-C4VrjIc1.js +2 -0
- package/dist/owletto/dist/assets/filter-editors-oNjBX9a2.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BVbcpW3R.js → full-page-spinner-DtmqQmgl.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-Acfam-JF.js +2 -0
- package/dist/owletto/dist/assets/identity-BkK8ggdp.js +2 -0
- package/dist/owletto/dist/assets/index-BhBYXtEN.js +2 -0
- package/dist/owletto/dist/assets/{index-BTlx9K_t.js → index-Bhop_otG.js} +2 -2
- package/dist/owletto/dist/assets/index-Bw5iV_J7.js +2 -0
- package/dist/owletto/dist/assets/index-C3dpyynY.js +2 -0
- package/dist/owletto/dist/assets/index-C3zAbslo.js +2 -0
- package/dist/owletto/dist/assets/index-CGKN_WN_.js +2 -0
- package/dist/owletto/dist/assets/{index-DB1iWI_a.js → index-CgRaCOzW.js} +2 -2
- package/dist/owletto/dist/assets/{index-D7gHOpfg.js → index-DRbaESbJ.js} +2 -2
- package/dist/owletto/dist/assets/index-DfIoxD5Q.js +2 -0
- package/dist/owletto/dist/assets/index-DijuudSs.js +2 -0
- package/dist/owletto/dist/assets/index-Dr7bouPX.css +1 -0
- package/dist/owletto/dist/assets/index-JmEl29py.js +7950 -0
- package/dist/owletto/dist/assets/index-NK2VKPoL.js +2 -0
- package/dist/owletto/dist/assets/index-_5qsmBkt.js +2 -0
- package/dist/owletto/dist/assets/{index-B64PGxQm.js → index-qkOKpRYs.js} +2 -2
- package/dist/owletto/dist/assets/index-wHFQv1aT.js +12 -0
- package/dist/owletto/dist/assets/index-wzYkECAe.js +2 -0
- package/dist/owletto/dist/assets/json-diff-4sMmayDd.js +4 -0
- package/dist/owletto/dist/assets/linked-record-peek-B0_B4PnF.js +97 -0
- package/dist/owletto/dist/assets/{list-skeleton-CepswBka.js → list-skeleton-BafzvpOM.js} +2 -2
- package/dist/owletto/dist/assets/login-XL5XxN6y.js +2 -0
- package/dist/owletto/dist/assets/{logout-Bkzc7J44.js → logout-CMxdhLbM.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-DD4YBFn-.js → member-scope-gate-Dit3MXBQ.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-DTlM_9MY.js +74 -0
- package/dist/owletto/dist/assets/{model-selector-CDrAjH31.js → model-selector-BeFuFH7p.js} +2 -2
- package/dist/owletto/dist/assets/models-BAVaDnKN.js +2 -0
- package/dist/owletto/dist/assets/new-1QLuS1o-.js +2 -0
- package/dist/owletto/dist/assets/{new-ktz9Cs_P.js → new-ChwqLmVY.js} +2 -2
- package/dist/owletto/dist/assets/new-D21LGMl6.js +2 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-lZNZ9gul.js → oauth-workspace-access-D15LYKSe.js} +2 -2
- package/dist/owletto/dist/assets/organization-CoUJYXx7.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-BvkYk72J.js +2 -0
- package/dist/owletto/dist/assets/permissions-C6UFdvz2.js +2 -0
- package/dist/owletto/dist/assets/proposal-review-shell-CmLy1MZf.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-_awBxu2Y.js +2 -0
- package/dist/owletto/dist/assets/record-activity-Doeu5kPO.js +2 -0
- package/dist/owletto/dist/assets/{record-session-Pbr5czGw.js → record-session-CJzFoVKc.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-CzZw6RcC.js → reset-password-Y-WO77iR.js} +2 -2
- package/dist/owletto/dist/assets/runs-B0zVYb-w.js +2 -0
- package/dist/owletto/dist/assets/runs-panel-Dkyybqos.js +2 -0
- package/dist/owletto/dist/assets/{runs-table-B1APZv7d.js → runs-table-9OVdfPXZ.js} +2 -2
- package/dist/owletto/dist/assets/schema-type-editor-panel-DcJqbCrU.js +2 -0
- package/dist/owletto/dist/assets/settings-Cfy9tCOF.js +2 -0
- package/dist/owletto/dist/assets/settings-Dg0D_l_w.js +2 -0
- package/dist/owletto/dist/assets/skills-oxA7P5Fe.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-BeAZeMLy.js +2 -0
- package/dist/owletto/dist/assets/status-dot-_LQZmEIX.js +2 -0
- package/dist/owletto/dist/assets/use-automations-DS3uz3pb.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-Dcunv4L0.js → use-mention-search-CAFbh-Dk.js} +4 -4
- package/dist/owletto/dist/assets/use-scroll-sentinel-BpQ70c28.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-FuOZyjMg.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-CWwlobOd.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +44222 -40683
- package/npm-shrinkwrap.json +389 -402
- package/package.json +1 -1
- package/vendor/connector-sdk/dist/browser-requirement.js +1 -1
- package/vendor/connector-sdk/dist/connector-types.d.ts +5 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/agent-tooling.d.ts +8 -0
- package/vendor/core/dist/agent-tooling.js +9 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +5 -0
- package/vendor/core/dist/contracts/entity-reference.d.ts +3 -0
- package/vendor/core/dist/contracts/entity-reference.js +31 -0
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +3 -0
- package/vendor/core/dist/contracts/tools/manage-automations.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +113 -34
- package/vendor/core/dist/contracts/tools/manage-entity.js +41 -14
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +13 -4
- package/vendor/core/dist/contracts/tools/manage-operations.js +19 -7
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +6 -1
- package/vendor/core/dist/contracts/tools/read-knowledge.js +20 -1
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/view-runtime.d.ts +2 -0
- package/vendor/core/dist/contracts/tools/view-runtime.js +3 -1
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +4 -9
- package/vendor/core/dist/contracts/worker/device-automation.js +10 -15
- package/vendor/core/dist/contracts/worker/protocol.d.ts +20 -0
- package/vendor/core/dist/contracts/worker/protocol.js +20 -0
- package/vendor/core/dist/reserved.d.ts +6 -3
- package/vendor/core/dist/reserved.js +6 -3
- package/vendor/core/dist/worker/auth.d.ts +3 -2
- package/vendor/core/package.json +6 -1
- package/vendor/postgres/cf/src/query.js +3 -1
- package/vendor/postgres/cjs/src/query.js +3 -1
- package/vendor/postgres/src/query.js +3 -1
- package/vendor/views/dist/api.js +31 -7
- package/vendor/views/dist/bridge.d.ts +2 -1
- package/vendor/views/dist/bridge.js +10 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-BorucF19.js +0 -3
- package/dist/owletto/dist/assets/_-CkGyNi0G.js +0 -2
- package/dist/owletto/dist/assets/_agentId-BrhcaxUk.js +0 -2
- package/dist/owletto/dist/assets/_agentId-DgRrCE2B.js +0 -2
- package/dist/owletto/dist/assets/_automationId-DSrZIYcs.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DWxv1uoi.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-BTP5ijdT.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-98Y3RuRO.js +0 -2
- package/dist/owletto/dist/assets/_deploymentId-B1UWPY0i.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BAnr8g8z.js +0 -2
- package/dist/owletto/dist/assets/_name-BUfFO_A0.js +0 -2
- package/dist/owletto/dist/assets/_owner-C79BwQ0I.js +0 -3
- package/dist/owletto/dist/assets/_shape-Ep6JpyFX.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-B24alBfT.js +0 -2
- package/dist/owletto/dist/assets/_slug-DbPdDc-5.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-DDUxjjFD.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-hdpq3RoX.js +0 -2
- package/dist/owletto/dist/assets/accept-invitation-UXU5Fx2G.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-D7ORHntE.js +0 -2
- package/dist/owletto/dist/assets/agent-card-controls-CplnPhbv.js +0 -2
- package/dist/owletto/dist/assets/agent-connect-pages-BmknviTI.js +0 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-TdvvIc_J.js +0 -2
- package/dist/owletto/dist/assets/agent-permissions-matrix-BkZu1LYE.js +0 -2
- package/dist/owletto/dist/assets/agent-skills-route-B3vvvZZe.js +0 -2
- package/dist/owletto/dist/assets/agent-subpage-shell-CZJvnjNC.js +0 -2
- package/dist/owletto/dist/assets/agents-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-DJ67GZ93.js +0 -2
- package/dist/owletto/dist/assets/app._appId-Cp78oEZ9.js +0 -2
- package/dist/owletto/dist/assets/automation-detail-content-DSwbRpbx.js +0 -2
- package/dist/owletto/dist/assets/automations-DAOln24A.js +0 -2
- package/dist/owletto/dist/assets/callback-CBexCo3F.js +0 -2
- package/dist/owletto/dist/assets/client-rows-BYbsXGy9.js +0 -2
- package/dist/owletto/dist/assets/clients-BhNl1tVq.js +0 -2
- package/dist/owletto/dist/assets/connect-wx-qqLir.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-kk0_4Svo.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-QR8o-7M5.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-BqprYeOX.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-DhRoSzBr.js +0 -2
- package/dist/owletto/dist/assets/connections-browser-CrtnAs0Q.js +0 -2
- package/dist/owletto/dist/assets/connector-scope-lists-CRFEpSvk.js +0 -2
- package/dist/owletto/dist/assets/conversations-table-D_HOe1jN.js +0 -2
- package/dist/owletto/dist/assets/create-C4lptGWj.js +0 -2
- package/dist/owletto/dist/assets/create-CCjZxIkK.js +0 -2
- package/dist/owletto/dist/assets/create-DkgUQAbB.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-Bpy92SM5.js +0 -3
- package/dist/owletto/dist/assets/create._connectorKey-D6Kc-YQ3.js +0 -2
- package/dist/owletto/dist/assets/deployments-C5hvipQh.js +0 -2
- package/dist/owletto/dist/assets/deployments-CPpFAd_w.js +0 -2
- package/dist/owletto/dist/assets/deployments-body-DGII20dQ.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-2U0UMu3_.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-Bn37UpWH.js +0 -2
- package/dist/owletto/dist/assets/entity-options-Clz_WXK-.js +0 -2
- package/dist/owletto/dist/assets/entity-page-D3e4iPle.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-DebN1vCM.js +0 -2
- package/dist/owletto/dist/assets/events-feed-DO3IiJO2.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-Bwhqj7lY.js +0 -2
- package/dist/owletto/dist/assets/guardrails-BiJollCA.js +0 -2
- package/dist/owletto/dist/assets/identity-HCFWtdaI.js +0 -2
- package/dist/owletto/dist/assets/index-8wxsyxqt.js +0 -2
- package/dist/owletto/dist/assets/index-9YuSRymd.js +0 -7950
- package/dist/owletto/dist/assets/index-B3c-0eZG.js +0 -2
- package/dist/owletto/dist/assets/index-BSH07yVD.css +0 -1
- package/dist/owletto/dist/assets/index-BX0EA_oB.js +0 -2
- package/dist/owletto/dist/assets/index-CDz3-ieP.js +0 -12
- package/dist/owletto/dist/assets/index-CdJJaQDX.js +0 -2
- package/dist/owletto/dist/assets/index-CfT_W8Vo.js +0 -2
- package/dist/owletto/dist/assets/index-CxF2XXzl.js +0 -2
- package/dist/owletto/dist/assets/index-D3WHeGql.js +0 -2
- package/dist/owletto/dist/assets/index-DMNzF8Lf.js +0 -2
- package/dist/owletto/dist/assets/index-DyB3IzOA.js +0 -2
- package/dist/owletto/dist/assets/index-Vcq4gwWv.js +0 -2
- package/dist/owletto/dist/assets/index-fgAJydgX.js +0 -2
- package/dist/owletto/dist/assets/json-diff-DIN5Jhfx.js +0 -4
- package/dist/owletto/dist/assets/login-DxGYyE4n.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-BnuhLJ6X.css +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-D_UlBa27.js +0 -103
- package/dist/owletto/dist/assets/models-BAVeysNq.js +0 -2
- package/dist/owletto/dist/assets/new-C2av0diq.js +0 -2
- package/dist/owletto/dist/assets/new-snm1ctHn.js +0 -2
- package/dist/owletto/dist/assets/organization-Cb0W823y.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-BNR9ImQY.js +0 -2
- package/dist/owletto/dist/assets/permissions-Dv39zWKt.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-CFhOqCLf.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-DqX8AXfw.js +0 -2
- package/dist/owletto/dist/assets/recent-QhnLDU1_.js +0 -2
- package/dist/owletto/dist/assets/record-activity-ZJntBfN_.js +0 -2
- package/dist/owletto/dist/assets/record-field-peek-Brh1IQGy.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-C0_DNTcq.js +0 -2
- package/dist/owletto/dist/assets/schema-value-normalization-CKdPjdPC.js +0 -97
- package/dist/owletto/dist/assets/settings-CgZ5Z7wD.js +0 -2
- package/dist/owletto/dist/assets/settings-VDNiffKU.js +0 -2
- package/dist/owletto/dist/assets/skills-DgDGscm5.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-BdfOVPWn.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-B0quibBi.js +0 -2
- /package/vendor/postgres/{.bun-tag-2f292c6554a8475e → .bun-tag-22d644c2873790db} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as N,j as e,z as w,I as S,bp as K,bq as X,br as Y,bs as ee,bt as ae,fN as te,B as k,o as P,gj as A,iU as L,iV as O,hb as F,f4 as se,bJ as j,gp as J,bz as ne,bM as re,aR as D,gr as ie,ep as oe,eq as le,er as U,es as E,ev as de,ew as $,P as ue,ir as ce,bB as q,cT as me,Q as R,iS as ge}from"./index-9YuSRymd.js";import{M as he}from"./model-selector-CDrAjH31.js";import{a as xe,A as pe}from"./agent-subpage-shell-CZJvnjNC.js";import{f as be}from"./agent-loading-shells-B7v6Cffw.js";import{A as je}from"./agent-card-controls-CplnPhbv.js";const fe=[{value:"input",label:"Input",hint:"the user message, before the agent runs"},{value:"output",label:"Output",hint:"the agent's reply, before the user sees it"},{value:"pre-tool",label:"Pre-tool",hint:"a tool call, before it executes"},{value:"egress",label:"Egress",hint:"an outbound request to a judged domain"}];function I({initial:a,judgeModelDefault:t,submitLabel:n,submitting:s,onSubmit:o,onCancel:r}){const[i,d]=N.useState(a?.name??""),[h,f]=N.useState(a?.stage??"input"),[p,y]=N.useState(a?.policy??""),[b,C]=N.useState(a?.model??""),[x,u]=N.useState((a?.tools??[]).join(", ")),[l,m]=N.useState((a?.domains??[]).join(", ")),g=a?.kind,v=g==="require-tool",Q=c=>{c.preventDefault();const M=x.split(",").map(T=>T.trim()).filter(Boolean);o({name:i,stage:h,...g?{kind:g}:{},policy:p,model:b.trim()||void 0,tools:(v||h==="pre-tool")&&M.length>0?M:void 0,domains:h==="egress"&&l.trim()?l.split(",").map(T=>T.trim()).filter(Boolean):void 0,enabled:a?.enabled??!0})};return e.jsxs("form",{onSubmit:Q,className:"space-y-5",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-name",children:["Name ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"guardrail-name",value:i,onChange:c=>d(c.target.value),placeholder:"no-competitor-mentions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Shown in the list and on every trip. Must be unique."})]}),v?null:e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-stage",children:"Stage"}),e.jsxs(K,{value:h,onValueChange:c=>f(c),disabled:s,children:[e.jsx(X,{id:"guardrail-stage",children:e.jsx(Y,{})}),e.jsx(ee,{children:fe.map(c=>e.jsxs(ae,{value:c.value,children:[c.label," — ",c.hint]},c.value))})]})]}),v?e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-required-tools",children:["Required tools ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(S,{id:"guardrail-required-tools",value:x,onChange:c=>u(c.target.value),placeholder:"suggest_actions",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated. The turn trips if the agent finishes without calling every one of these. No judge model runs — this is a lookup against the tools the turn actually used."})]}):null,v?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-policy",children:["Policy ",e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(te,{id:"guardrail-policy",rows:5,value:p,onChange:c=>y(c.target.value),placeholder:"Deny any response that names a competitor (Acme, Globex) or quotes their pricing.",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"A judge model reads this and the text at the chosen stage, then allows or denies. Write it as an instruction to a reviewer."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(w,{htmlFor:"guardrail-model",children:["Judge model",t?null:e.jsx("span",{className:"ml-1 text-destructive",children:"*"})]}),e.jsx(he,{value:b,onChange:C,placeholder:t?`Default (${t})`:"Select a model",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t?"Optional. Leave blank to use the gateway's default judge model.":"Required: the gateway has no default judge model (EGRESS_JUDGE_MODEL is unset)."})]})]}),!v&&h==="pre-tool"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-tools",children:"Tool scope"}),e.jsx(S,{id:"guardrail-tools",value:x,onChange:c=>u(c.target.value),placeholder:"github.delete_repo, fs.delete",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Optional, comma-separated. Leave blank to judge every tool call."})]}):null,h==="egress"?e.jsxs("div",{className:"grid gap-2",children:[e.jsx(w,{htmlFor:"guardrail-domains",children:"Domains"}),e.jsx(S,{id:"guardrail-domains",value:l,onChange:c=>m(c.target.value),placeholder:"api.github.com, .slack.com",disabled:s}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Comma-separated hostnames this judge gates — exact (api.github.com) or wildcard (.slack.com). Leave blank to route nothing."})]}):null,e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[r?e.jsx(k,{type:"button",variant:"outline",onClick:r,disabled:s,children:"Cancel"}):null,e.jsx(k,{type:"submit",disabled:s,children:s?"Saving…":n})]})]})}function z(a){return a.kind==="require-tool"}function H(a,t,n,s,o){const r=a.name.trim();return r?/^[a-zA-Z0-9][a-zA-Z0-9 _-]*$/.test(r)?n.includes(r)?`"${r}" is a built-in guardrail name — pick another.`:t.some(d=>d.name===r&&d.name!==o)?`A custom guardrail named "${r}" already exists.`:z(a)?a.stage!=="output"?"A required-tool guardrail only runs at the output stage.":a.tools?.some(d=>d.trim())?null:"List at least one tool that must be used.":a.policy.trim()?!s&&!a.model?.trim()?"Judge model is required — the gateway has no default (EGRESS_JUDGE_MODEL is unset).":null:"Policy is required.":"Name may use letters, numbers, spaces, hyphens, and underscores.":"Name is required."}function V(a){const t=z(a),s=(t||a.stage==="pre-tool")&&a.tools&&a.tools.length>0?a.tools.map(d=>d.trim()).filter(Boolean):void 0,o=a.stage==="egress"&&a.domains&&a.domains.length>0?a.domains.map(d=>d.trim()).filter(Boolean):void 0,r=a.model?.trim()||void 0,i=a.policy.trim();return{name:a.name.trim(),enabled:a.enabled,stage:a.stage,...t?{kind:"require-tool"}:{},...t?i?{policy:i}:{}:{policy:i},...r?{model:r}:{},...s&&s.length>0?{tools:s}:{},...o&&o.length>0?{domains:o}:{}}}function ve(a,t){return[...a,V(t)]}function Ne(a,t,n){return a.map(s=>s.name===t?V(n):s)}function ye(a,t){return a.filter(n=>n.name!==t)}function Ce(a,t,n){return a.map(s=>s.name===t?{...s,enabled:n}:s)}function we({owner:a,agentId:t}){const n=P(),{data:s,isLoading:o}=A(t),{data:r,isLoading:i}=L(t),{data:d=null,isLoading:h}=O(t),f=o||i||h,p=F(t),y=s?.guardrailsInline??[],b=(r??[]).map(u=>u.name),C=async u=>{if(!s){j.error("Still loading agent settings — try again in a moment");return}const l=H(u,y,b,d);if(l){j.error(l);return}try{await p.mutateAsync({guardrailsInline:ve(y,u)}),j.success("Guardrail created"),n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})}catch(m){j.error(m instanceof Error?m.message:"Failed to create guardrail")}},x=()=>void n({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{title:"New custom guardrail",description:"A custom guardrail judges text at one stage against a policy you write.",backLabel:"Guardrails",onBack:x}),f?e.jsx(se,{rows:4}):e.jsx(I,{judgeModelDefault:d,submitLabel:"Create guardrail",submitting:p.isPending,onSubmit:C,onCancel:x})]})}function B(a,t){const n=new Set(a?.guardrails??[]),s=new Set(t.map(i=>i.name)),o=t.map(i=>({name:i.name,stages:i.stages,description:i.description,enabled:n.has(i.name),unknown:!1})),r=(a?.guardrails??[]).filter(i=>!s.has(i)).map(i=>({name:i,stages:[],enabled:!0,unknown:!0}));return[...o,...r]}function ke(a){return a.filter(t=>t.enabled||t.unknown).map(t=>t.name)}function Se(a,t,n){return ke(a.map(s=>s.name===t&&!s.unknown?{...s,enabled:n}:s))}const G={input:"Input",output:"Output","pre-tool":"Pre-tool",egress:"Egress"};function Ge(a){const t=new Date(a);return Number.isNaN(t.getTime())?a:ce(t,{addSuffix:!0})}function Ae({owner:a,agentId:t,name:n}){const{data:s}=A(t),{data:o}=L(t),r=N.useMemo(()=>B(s,o??[]).find(d=>d.name===n)??null,[s,o,n]),i=(s?.guardrailsInline??[]).find(d=>d.name===n);return i?e.jsx(Te,{owner:a,agentId:t,guardrail:i}):r?e.jsx(Le,{agentId:t,name:n,row:r}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Guardrail not found."})}function Le({agentId:a,name:t,row:n}){return e.jsxs("div",{className:"space-y-8",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:n.description??(n.stages.length>0?`Built-in. Short-circuits this agent's ${n.stages.map(s=>G[s].toLowerCase()).join(", ")} stage${n.stages.length>1?"s":""} when it matches.`:"Configured out of band — toggling is managed via lobu apply.")}),e.jsx(W,{agentId:a,guardrail:t})]})}function Te({owner:a,agentId:t,guardrail:n}){const s=P(),{data:o}=A(t),{data:r}=L(t),{data:i=null}=O(t),d=F(t),[h,f]=N.useState(!1),p=o?.guardrailsInline??[],y=(r??[]).map(u=>u.name),b=async(u,l)=>{if(!o)return j.error("Still loading agent settings — try again in a moment"),!1;try{return await d.mutateAsync({guardrailsInline:u}),j.success(l),!0}catch(m){return j.error(m instanceof Error?m.message:"Failed to save guardrail"),!1}},C=async u=>{const l=H(u,p,y,i,n.name);if(l){j.error(l);return}await b(Ne(p,n.name,u),"Guardrail saved")&&u.name.trim()!==n.name&&s({to:"/$owner/agents/$agentId/guardrails/$name",params:{owner:a,agentId:t,name:encodeURIComponent(u.name.trim())}})},x=async()=>{await b(ye(p,n.name),"Guardrail deleted")&&s({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:n.kind==="require-tool"?"Required tools":"Policy"}),e.jsx(I,{initial:n,judgeModelDefault:i,submitLabel:"Save changes",submitting:d.isPending,onSubmit:C})]}),e.jsx("div",{className:"flex justify-end",children:h?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{type:"button",variant:"destructive",onClick:()=>void x(),disabled:d.isPending,children:"Delete guardrail"}),e.jsx(k,{type:"button",variant:"outline",onClick:()=>f(!1),disabled:d.isPending,children:"Cancel"})]}):e.jsxs(k,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>f(!0),children:["Delete ",n.name]})}),e.jsx(W,{agentId:t,guardrail:n.name})]})}function W({agentId:a,guardrail:t}){const{data:n=[],isLoading:s,isError:o}=J(a,{guardrail:t});return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Recent catches"}),s?e.jsx(ne,{label:"catches",variant:"table",rows:4}):o?e.jsx(re,{label:"catches"}):n.length===0?e.jsx(D,{icon:ie,title:"No catches yet",description:"This guardrail hasn't short-circuited anything on this agent."}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:e.jsxs(oe,{children:[e.jsx(le,{children:e.jsxs(U,{children:[e.jsx(E,{className:"w-[180px]",children:"When"}),e.jsx(E,{className:"w-[120px]",children:"Stage"}),e.jsx(E,{children:"Reason"})]})}),e.jsx(de,{children:n.map(r=>e.jsxs(U,{children:[e.jsx($,{className:"text-xs text-muted-foreground",title:r.occurredAt,children:Ge(r.occurredAt)}),e.jsx($,{children:e.jsx(ue,{variant:"outline",className:"text-[10px]",children:G[r.stage]})}),e.jsx($,{className:"text-sm text-muted-foreground",children:r.reason??e.jsx("span",{className:"italic",children:"no reason recorded"})})]},r.id))})]})})]})}function Ee({description:a,action:t}){return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 flex-1 text-center text-sm text-muted-foreground",children:a}),t?e.jsx("div",{className:"shrink-0",children:t}):null]})}function _(a,t){return a.get(t)??0}function $e(a,t,n){const s=a.map(r=>{const i=r.stages.map(d=>G[d]);return r.unknown&&i.push("Unknown"),{id:r.name,name:r.name,kind:"builtin",description:r.description,stages:r.stages,enabled:r.enabled,unknown:r.unknown,badges:i,tripCount:_(n,r.name)}}),o=t.map(r=>{const i=[G[r.stage],"Custom"];return{id:r.name,name:r.name,kind:"custom",description:r.policy,stages:[r.stage],enabled:r.enabled,unknown:!1,badges:i,tripCount:_(n,r.name)}});return[...s,...o]}function Re({owner:a,agentId:t,expandedName:n}){const s=P(),{data:o,isLoading:r}=A(t),{data:i,isLoading:d}=L(t),{data:h=[]}=J(t),f=F(t),p=async(l,m)=>{if(!o){j.error("Still loading agent settings — try again in a moment");return}try{if(l.kind==="custom")await f.mutateAsync({guardrailsInline:Ce(o.guardrailsInline??[],l.name,m)});else{const g=B(o,i??[]);await f.mutateAsync({guardrails:Se(g,l.name,m)})}j.success(m?"Guardrail enabled":"Guardrail disabled")}catch(g){j.error(g instanceof Error?g.message:"Failed to save guardrail")}},y=i===null,b=N.useMemo(()=>{const l=B(o,i??[]),m=o?.guardrailsInline??[],g=new Map;for(const v of h)g.set(v.guardrailName,(g.get(v.guardrailName)??0)+1);return $e(l,m,g)},[o,i,h]),C=l=>{if(l===n){s({to:"/$owner/agents/$agentId/guardrails",params:{owner:a,agentId:t}});return}s({to:"/$owner/agents/$agentId/guardrails/$name",params:{owner:a,agentId:t,name:encodeURIComponent(l)}})},x=()=>{s({to:"/$owner/agents/$agentId/guardrails/create",params:{owner:a,agentId:t}})},u=r||d;return!u&&b.length===0?e.jsx("div",{className:"space-y-6",children:y?e.jsx(D,{icon:q,title:"Guardrails catalog unavailable",description:"Guardrails will appear here once the gateway publishes its catalog.",actionLabel:"New guardrail",onAction:x}):e.jsx(D,{icon:q,title:"No guardrails yet",description:"Enable a built-in in lobu.toml or write a custom policy guardrail.",actionLabel:"New guardrail",onAction:x})}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ee,{description:"Each guardrail short-circuits this agent's input, output, or tool-call stages. Built-ins are toggle-only; add a custom guardrail to judge messages against a policy you write.",action:u?void 0:e.jsxs(k,{type:"button",onClick:x,children:[e.jsx(me,{className:"mr-1.5 h-4 w-4"}),"New guardrail"]})}),u?e.jsx(be,{rows:3}):e.jsx("div",{className:"overflow-hidden rounded-lg border",children:b.map((l,m)=>{const g=l.name===n;return e.jsx(De,{card:l,expanded:g,isLast:m===b.length-1,onToggle:()=>C(l.name),onToggleEnabled:v=>void p(l,v),toggleDisabled:l.unknown||f.isPending,children:g?e.jsx(Ae,{owner:a,agentId:t,name:l.name}):null},l.id)})})]})}function De({card:a,expanded:t,isLast:n,onToggle:s,onToggleEnabled:o,toggleDisabled:r,children:i}){return e.jsxs("div",{className:R("bg-background",!n||t?"border-b":""),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsxs("button",{type:"button",onClick:s,"aria-expanded":t,className:R("flex min-w-0 flex-1 items-center gap-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",!a.enabled&&!a.unknown&&!t&&"opacity-70"),children:[e.jsx(q,{className:"ml-2 h-4 w-4 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:R("truncate text-sm text-foreground",a.unknown&&"font-mono text-xs"),children:a.name}),a.kind==="custom"&&a.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:a.description}):e.jsx("p",{className:"text-xs text-muted-foreground",children:a.tripCount>0?`${a.tripCount} recent ${a.tripCount===1?"catch":"catches"}`:"No recent catches"}),e.jsx(ge,{badges:a.badges})]})]}),e.jsx(je,{enabled:a.enabled,name:a.name,expanded:t,onToggleEnabled:o,toggleDisabled:r,onToggle:s})]}),t&&i?e.jsx("div",{className:"border-t border-border px-4 py-4",children:i}):null]})}function Z({owner:a,agentId:t,children:n,showBack:s}){return e.jsx(pe,{owner:a,agentId:t,showBack:s,backLabel:"Guardrails",backTo:"/$owner/agents/$agentId/guardrails",children:n})}function qe({owner:a,agentId:t,expandedName:n}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(Re,{owner:a,agentId:t,expandedName:n})})}function _e({owner:a,agentId:t}){return e.jsx(Z,{owner:a,agentId:t,children:e.jsx(we,{owner:a,agentId:t})})}function Oe({owner:a,agentId:t,name:n}){return e.jsx(qe,{owner:a,agentId:t,expandedName:decodeURIComponent(n)})}export{qe as A,_e as a,Oe as b};
|
|
2
|
-
//# sourceMappingURL=agent-guardrails-route-TdvvIc_J.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,bC as D,Q as k,dK as K,dL as B,dN as R,fU as J,$ as V,bv as Y,bu as Z,bH as G,fV as ee,bI as P,bJ as L,bK as se,bD as ne,bL as te,bE as re,r as S,fW as ae,fX as ie,bz as le,bM as oe,L as w,fY as de,fZ as ce,cS as W,f_ as ue,f$ as me,g0 as ge,g1 as A,cF as F,X as fe,g2 as q,g3 as z,eE as xe,cT as he,g4 as be,g5 as ye,bP as pe,g6 as ve}from"./index-9YuSRymd.js";const je={auto:"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400",approval:"bg-amber-500/15 text-amber-600 dark:text-amber-400",deny:"bg-red-500/15 text-red-600 dark:text-red-400"};function Ne({options:n,value:t,floor:o,onChange:a,disabled:i,ariaLabel:m,compact:u}){return e.jsx("div",{role:"radiogroup","aria-label":m,className:k("inline-flex shrink-0 items-stretch gap-0.5 rounded-lg border border-border bg-muted/40 p-0.5"),children:n.map(l=>{const b=J({option:l,floor:o}),h=l===t,g=b.disabled&&!h,y=D[l],f=e.jsx("button",{type:"button",role:"radio","aria-checked":h,disabled:i||g,onClick:()=>{!h&&!g&&!i&&a(l)},className:k("inline-flex shrink-0 items-center justify-center whitespace-nowrap font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",u?"min-w-[3rem] rounded-md px-2.5 py-1.5 text-xs leading-none":"min-w-[3.25rem] rounded-md px-3 py-1.5 text-sm leading-none",h?k(je[l],""):"text-muted-foreground hover:bg-background/60 hover:text-foreground",g&&"cursor-not-allowed opacity-40",i&&!g&&"cursor-not-allowed opacity-60"),children:y},l);return g&&b.reason?e.jsxs(K,{children:[e.jsx(B,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:f})}),e.jsx(R,{children:b.reason})]},l):f})})}function M({children:n,controls:t}){return e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2 px-3 py-2",children:[e.jsx("div",{className:"min-w-40 flex-1 text-sm",children:n}),e.jsx("div",{className:"flex shrink-0 items-center gap-2",children:t})]})}const _e=[{resourceClass:"entity",title:"Entities",sub:"Defaults for every entity type."},{resourceClass:"agent_config",title:"Agents",sub:"Defaults for reading and managing agents."}];function Se(n,t,o,a,i=null){const m=q(n.floor,t,o,a,i),u=z(n.floor,t,o,a,i)?m:"auto";return(a!==null||i!==null)&&be(n.agent,t,o)?ye(u,A(n,t,o,null)):u}function ke({label:n,response:t,resourceClass:o,action:a,entityTypeSlug:i,targetAgentId:m=null,dimmed:u,pending:l,onSave:b}){const h=q(t.floor,o,a,i,m),g=z(t.floor,o,a,i,m),y=A(t,o,a,i,m),f=Se(t,o,a,i,m),v=pe(o,a),p=e.jsx("div",{className:k("inline-flex shrink-0",u&&"opacity-45"),children:e.jsx(Ne,{options:v,value:y,floor:f,disabled:l,compact:!0,ariaLabel:n,onChange:b})});return g?e.jsxs(K,{children:[e.jsx(B,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:p})}),e.jsxs(R,{children:["Org floor ",D[h]," — can only go stricter"]})]}):p}function Ae(n,t){const o=i=>i.resource_class===t.resource_class&&(i.entity_type_slug??null)===(t.entity_type_slug??null)&&(i.operation_key??null)===(t.operation_key??null)&&(i.target_agent_id??null)===(t.target_agent_id??null),a=n.map(i=>o(i)?t:i);return a.some(o)?a:[...a,t]}function Ce(n,t,o,a,i,m){const u=ve(n,t,o,a);return u[i]=m,u}const $="font-medium text-foreground hover:text-primary hover:underline";function Ee({type:n}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(W,{icon:n.icon,className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"font-medium",children:n.name}),e.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:n.slug})]})}function Q({label:n,disabled:t,hint:o,searchPlaceholder:a,emptyText:i,children:m}){return t?e.jsxs("div",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:[n,o?` ${o}`:""]}):e.jsx(xe,{contentClassName:"w-[min(100vw-2rem,22rem)]",searchPlaceholder:a,emptyText:i,trigger:u=>e.jsxs("button",{type:"button","aria-expanded":u,className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-xs text-primary hover:bg-muted/50",children:[e.jsx(he,{className:"h-3 w-3"}),n]}),children:u=>m(u)})}function Te({pending:n,onClick:t,label:o}){return e.jsx("button",{type:"button",disabled:n,onClick:t,"aria-label":o,className:"rounded p-0.5 text-muted-foreground hover:bg-red-500/10 hover:text-red-600 disabled:opacity-50 dark:hover:text-red-400",children:e.jsx(fe,{className:"h-3 w-3"})})}function $e({owner:n,agentId:t,variant:o="agent"}){const a=o==="org-floor",i=V(),m=Y(n,t??"",{enabled:!a&&!!t}),u=Z(n,{enabled:a}),{data:l,isLoading:b,isError:h,error:g}=a?u:m,y=a?G(n):ee(n,t??""),f=P({mutationFn:r=>a?se(n,r):ne(n,t??"",r),onSuccess:r=>{i.setQueryData(y,c=>c&&{...c,agent:Ae(c.agent,r)}),i.invalidateQueries({queryKey:y}),a&&i.invalidateQueries({queryKey:["agent-permissions"]})},onError:r=>{L.error(r instanceof Error?r.message:"Failed to save permission")}}),v=P({mutationFn:r=>a?te(n,r):re(n,t??"",r),onSuccess:()=>{i.invalidateQueries({queryKey:y}),a&&i.invalidateQueries({queryKey:["agent-permissions"]})},onError:r=>{L.error(r instanceof Error?r.message:"Failed to remove override")}}),p=f.isPending||v.isPending,C=S.useMemo(()=>l?ae(l):[],[l]),E=S.useMemo(()=>{if(!l)return[];const r=new Set(C.map(c=>c.slug));return l.entity_types.filter(c=>!r.has(c.slug))},[l,C]),j=S.useMemo(()=>l?ie(l):[],[l]),N=S.useMemo(()=>{if(!l)return[];const r=new Set(j.map(c=>c.id));return l.agents.filter(c=>(a||c.id!==t)&&!r.has(c.id))},[l,j,t,a]);if(b)return e.jsx(le,{label:"permissions",variant:"cards",cards:2});if(h||!l)return e.jsx(oe,{label:g instanceof Error?g.message:"permissions"});const x=l,H=(r,c,T,_,s=null)=>{const d=Ce(x,r,c,s,T,_);f.mutate({resource_class:r,effects:d,entity_type_slug:c,target_agent_id:s})},I=x.entity_types.length===0?"— none yet":E.length===0?"— all covered":null,U=N.length===0&&j.length===0?"— no other agents":N.length===0?"— all covered":null;return e.jsxs("div",{className:"space-y-4",children:[a?null:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Manage connector rules and agent restrictions in"," ",e.jsx(w,{to:"/$owner/settings/organization",params:{owner:n},search:{agent:t},hash:"policies",className:$,children:"Organization policies"}),"."]}),_e.map(r=>{const c=r.resourceClass==="entity",T=r.resourceClass==="agent_config",_=[{key:"default",label:"Default",name:"Default",entityTypeSlug:null,targetAgentId:null,owned:!1,diffs:0},...c?C.map(s=>({key:`entity:${s.slug}`,name:s.name,label:e.jsx(w,{to:"/$owner/entity-types/$slug",params:{owner:n,slug:s.slug},className:$,title:`Open ${s.name}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(W,{icon:s.icon,className:"h-3.5 w-3.5 shrink-0"}),s.name]})}),entityTypeSlug:s.slug,targetAgentId:null,owned:ce(x,s.slug),diffs:de(x,s.slug)})):j.map(s=>({key:`agent:${s.id}`,name:s.name,label:e.jsx(w,{to:"/$owner/agents/$agentId/settings",params:{owner:n,agentId:s.id},search:{run_id:void 0},className:$,title:`Open ${s.name}`,children:s.name}),entityTypeSlug:null,targetAgentId:s.id,owned:me(x,s.id),diffs:ue(x,s.id)}))];return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h3",{className:"text-sm font-medium",children:r.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r.sub})]}),e.jsxs("div",{className:"divide-y overflow-hidden rounded-lg border",children:[_.map(s=>e.jsxs("div",{className:"divide-y",children:[_.length>1&&e.jsx("div",{className:"bg-muted/30",children:e.jsx(M,{controls:s.owned?e.jsx(Te,{pending:p,label:`Remove ${s.name} exception`,onClick:()=>v.mutate({resource_class:r.resourceClass,entity_type_slug:s.entityTypeSlug,target_agent_id:s.targetAgentId})}):null,children:e.jsxs("div",{className:"flex items-center gap-2",children:[s.label,s.key!=="default"&&!s.owned?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Organization minimum"}):s.diffs>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[s.diffs," ",s.diffs===1?"change":"changes"]}):null]})})}),e.jsx("div",{className:"divide-y",children:ge[r.resourceClass].filter(d=>!s.targetAgentId||d!=="create").map(d=>{const O=`${d.charAt(0).toUpperCase()+d.slice(1)} ${c?"entities":"agents"}`;return e.jsx(M,{controls:e.jsx(ke,{label:`${s.name}: ${O}`,response:x,resourceClass:r.resourceClass,action:d,entityTypeSlug:s.entityTypeSlug,targetAgentId:s.targetAgentId,dimmed:s.key!=="default"&&A(x,r.resourceClass,d,s.entityTypeSlug,s.targetAgentId)===A(x,r.resourceClass,d,null),pending:p,onSave:X=>H(r.resourceClass,s.entityTypeSlug,d,X,s.targetAgentId)}),children:O},d)})})]},s.key)),e.jsxs("div",{className:"border-t",children:[c?e.jsx(Q,{label:"Add type",disabled:p||E.length===0,hint:I,searchPlaceholder:"Search types…",emptyText:"No matching types.",children:s=>E.map(d=>e.jsx(F,{value:`${d.name} ${d.slug}`,onSelect:()=>{f.mutate({resource_class:"entity",effects:{},entity_type_slug:d.slug}),s()},className:"cursor-pointer",children:e.jsx(Ee,{type:d})},d.slug))}):null,T?e.jsx(Q,{label:"Add agent",disabled:p||N.length===0,hint:U,searchPlaceholder:"Search agents…",emptyText:"No matching agents.",children:s=>N.map(d=>e.jsxs(F,{value:`${d.name} ${d.id}`,onSelect:()=>{f.mutate({resource_class:"agent_config",effects:{},target_agent_id:d.id}),s()},className:"cursor-pointer",children:[e.jsx("span",{className:"font-medium",children:d.name}),e.jsx("span",{className:"ml-1.5 font-mono text-[10px] text-muted-foreground",children:d.id})]},d.id))}):null]})]})]},r.resourceClass)})]})}export{$e as A,Ne as P,M as a};
|
|
2
|
-
//# sourceMappingURL=agent-permissions-matrix-BkZu1LYE.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as w,r as u,j as e,cT as F,z as C,I as K,fN as P,bA as z,B as N,Q as E,af as Q,h0 as G,h1 as H,aR as Y,hi as V,fj as X,iS as q}from"./index-9YuSRymd.js";import{a as J,A as U}from"./agent-subpage-shell-CZJvnjNC.js";import{u as $,b as W,f as Z,s as ee,a as se,S as te,v as ae,c as le}from"./agent-skill-context-DFucg4c4.js";import{f as ne}from"./agent-loading-shells-B7v6Cffw.js";import{u as ie,a as L,m as oe,P as re,D as ce,n as de,C as me}from"./core.esm-BupT3V0i.js";import{A as ue}from"./agent-card-controls-CplnPhbv.js";const T=":";function A(s){const t=s.indexOf("/");return t<0?s:`${s.slice(0,t)}${T}${s.slice(t+1)}`}function B(s){const t=s.indexOf(T);return t<0?s:`${s.slice(0,t)}/${s.slice(t+1)}`}function ge({owner:s,agentId:t,onBack:a,backLabel:n="Skills"}){const o=w(),[i,g]=u.useState(""),[k,h]=u.useState(!1),[r,p]=u.useState(""),[m,v]=u.useState(""),{skillRows:c,catalog:x,isLoading:S,addSkillFromCatalog:y,addCustomSkill:b}=$(),l=u.useMemo(()=>new Set(c.map(d=>d.repo)),[c]),f=u.useMemo(()=>W(x?.catalog??[],l),[x?.catalog,l]),j=u.useMemo(()=>Z(f,i),[f,i]),R=d=>{y(d),o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},O=()=>{const d=b({name:r,instructions:m});d&&o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},_=a?e.jsx(J,{title:"Add a skill",description:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own.",onBack:a,backLabel:n}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Add a skill"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own."})]});return e.jsxs("div",{className:"space-y-6",children:[_,e.jsx("div",{className:E(Q,"w-full"),children:k?e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-name",children:"Name"}),e.jsx(K,{id:"custom-skill-name",value:r,onChange:d=>p(d.target.value),placeholder:"my-skill"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-instructions",children:"Instructions"}),e.jsx(P,{id:"custom-skill-instructions",value:m,onChange:d=>v(d.target.value),placeholder:"Instructions for the agent when this skill is active...",rows:3})]})]}),e.jsx(z,{onCancel:()=>h(!1),children:e.jsx(N,{type:"button",size:"sm",onClick:O,disabled:!r.trim(),children:"Add custom skill"})})]}):e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 p-3 text-left text-muted-foreground transition-colors hover:text-foreground",onClick:()=>h(!0),children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Create custom skill"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define instructions and packages"})]})]})}),S?e.jsx(G,{}):e.jsx(H,{items:j,searchQuery:i,onSearchChange:g,onSelect:d=>R(d.key),searchPlaceholder:"Search skills...",searchAriaLabel:"Search skills",emptyMessage:i.trim()?`No skills match "${i}"`:f.length===0?"All catalog skills are already configured":"No skills available"})]})}function xe({row:s}){const{isSaving:t,updateSkillRow:a}=$(),n=s.system===!0;return e.jsx("div",{className:"space-y-6",children:n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"System skill metadata is managed by Lobu. You can enable or disable it and change its position in the skill list."}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-name",children:"Name"}),e.jsx(K,{id:"skill-name",value:s.name,onChange:o=>a(s.repo,{name:o.target.value}),disabled:t})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-instructions",children:"Instructions"}),e.jsx(P,{id:"skill-instructions",value:s.instructions??"",onChange:o=>{const i=o.target.value;a(s.repo,{instructions:i,content:i.trim()||s.name})},rows:4,disabled:t})]})]})})}function he({owner:s,agentId:t,skillKey:a}){const n=w(),[o,i]=u.useState(!1),g=B(a),{skillRows:k,catalog:h,isSaving:r,saveSkills:p,removeSkillAndSave:m,addSkillFromCatalog:v}=$(),c=k.find(b=>b.repo===g)??null,x=h?.catalog.find(b=>b.repo===g);u.useEffect(()=>{!c&&x&&v(g)},[v,x,g,c]);const S=async()=>{await m(g)&&(i(!1),n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}}))};if(!c)return x?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skill not found."});const y=!c.system;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{row:c}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-end",children:[y?o?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"button",variant:"destructive",onClick:()=>void S(),disabled:r,children:r?"Removing...":"Remove skill"}),e.jsx(N,{type:"button",variant:"outline",onClick:()=>i(!1),disabled:r,children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>i(!0),disabled:r,children:["Remove ",c.name]}):null,e.jsx(N,{type:"button",onClick:()=>void p(),disabled:r||o,children:r?"Saving...":"Save changes"})]})]})}function fe(s){return s.map(t=>{const a=ee(t).map(String);return{id:t.repo,repo:t.repo,name:t.name,description:t.description,badges:a,enabled:t.enabled}})}const D="Skills bundle instructions, tools, and knowledge an agent can reuse. Add one from the catalog or write your own; drag to set which the agent reaches for first.";function M({owner:s,agentId:t,expandedRepo:a}){const n=w(),{skillRows:o,catalog:i,isLoading:g,isSaving:k,reorderSkills:h,setSkillEnabledAndSave:r,addSkillFromCatalog:p}=$();u.useEffect(()=>{a&&(o.some(l=>l.repo===a)||i?.catalog.some(l=>l.repo===a)&&p(a))},[a,o,i,p]);const m=u.useMemo(()=>fe(o),[o]),v=u.useMemo(()=>m.map(l=>l.repo),[m]),c=ie(L(re,{activationConstraint:{distance:8}}),L(oe,{coordinateGetter:se})),x=()=>{n({to:"/$owner/agents/$agentId/skills/create",params:{owner:s,agentId:t}})},S=e.jsxs(N,{type:"button",onClick:x,children:[e.jsx(F,{className:"mr-1.5 h-4 w-4"}),"Add skill"]}),y=l=>{if(l===a){n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}});return}n({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(l)}})},b=l=>{const{active:f,over:j}=l;!j||f.id===j.id||h(String(f.id),String(j.id))};return g?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(ne,{rows:2})]}):m.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(Y,{icon:V,title:"No skills yet",description:"Add a system skill from the catalog or create a custom skill for this agent.",actionLabel:"Add skill",onAction:x})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:D}),S]}),e.jsx(ce,{sensors:c,collisionDetection:de,onDragEnd:b,children:e.jsx(te,{items:v,strategy:ae,children:e.jsx("div",{className:"overflow-hidden rounded-lg border",children:m.map((l,f)=>{const j=l.repo===a;return e.jsx(ke,{card:l,rank:f+1,disabled:k,expanded:j,isLast:f===m.length-1,onToggle:()=>y(l.repo),onToggleEnabled:R=>void r(l.repo,R),toggleDisabled:k,children:j?e.jsx(he,{owner:s,agentId:t,skillKey:A(l.repo)}):null},l.id)})})})})]})}function ke({card:s,rank:t,disabled:a,expanded:n,isLast:o,onToggle:i,onToggleEnabled:g,toggleDisabled:k,children:h}){const r=a||n,{attributes:p,listeners:m,setNodeRef:v,transform:c,transition:x,isDragging:S}=le({id:s.repo,disabled:r}),y={transform:me.Transform.toString(c),transition:x};return e.jsxs("div",{ref:v,style:y,className:E("bg-background",!o||n?"border-b":"",S&&"z-10 bg-card opacity-80 "),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsx("button",{type:"button",className:"flex shrink-0 cursor-grab touch-none items-center px-2 text-muted-foreground hover:text-foreground active:cursor-grabbing disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Reorder ${s.name}`,disabled:r,...p,...m,children:e.jsx(X,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",className:E("flex min-w-0 flex-1 items-center gap-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",!s.enabled&&!n&&"opacity-70"),onClick:i,"aria-expanded":n,children:[e.jsx("span",{className:"w-4 shrink-0 text-center text-xs tabular-nums text-muted-foreground",children:t}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),s.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:s.description}):null,e.jsx(q,{badges:s.badges})]})]}),e.jsx(ue,{enabled:s.enabled,name:s.name,expanded:n,onToggleEnabled:g,toggleDisabled:k,onToggle:i})]}),n&&h?e.jsx("div",{className:"border-t border-border px-4 py-4",children:h}):null]})}function I({owner:s,agentId:t,children:a,showBack:n}){return e.jsx(U,{owner:s,agentId:t,showBack:n,backLabel:"Skills",backTo:"/$owner/agents/$agentId/skills",children:a})}function Ne({owner:s,agentId:t}){return e.jsx(I,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t})})}function Ce({owner:s,agentId:t}){const a=w();return e.jsx(I,{owner:s,agentId:t,children:e.jsx(ge,{owner:s,agentId:t,onBack:()=>{a({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}})}})})}function Ae({owner:s,agentId:t,skillKey:a}){return e.jsx(I,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t,expandedRepo:B(a)})})}export{Ne as A,Ce as a,Ae as b};
|
|
2
|
-
//# sourceMappingURL=agent-skills-route-B3vvvZZe.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as m,j as e,Q as h,B as n,gK as o}from"./index-9YuSRymd.js";function p({owner:t,agentId:a,children:s,showBack:r,backLabel:i,backTo:x,title:c,className:u}){const d=m(),l=()=>{d({to:x,params:{owner:t,agentId:a}})};return e.jsx("div",{className:h("mx-auto w-full max-w-3xl pb-8",u),children:c?e.jsxs(e.Fragment,{children:[e.jsx(j,{title:c,onBack:l,backLabel:i}),s]}):r?e.jsx(g,{onBack:l,backLabel:i,children:s}):s})}function g({onBack:t,backLabel:a,children:s}){return e.jsxs("div",{className:"relative",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"absolute right-full top-0 mr-1 size-8 text-muted-foreground hover:text-foreground","aria-label":`Back to ${a}`,onClick:t,children:e.jsx(o,{className:"h-4 w-4"})}),s]})}function j({title:t,onBack:a,backLabel:s,action:r}){return e.jsx("div",{className:"sticky top-0 z-10 mb-2 bg-background py-2",children:e.jsxs("div",{className:"relative flex items-center justify-center gap-1",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${s}`,onClick:a,children:e.jsx(o,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-base font-semibold",children:t}),r?e.jsx("div",{className:"absolute right-0",children:r}):null]})})}function v({title:t,description:a,onBack:s,backLabel:r}){return e.jsxs("div",{className:"mb-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${r}`,onClick:s,children:e.jsx(o,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-xl font-semibold",children:t})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:a})]})}export{p as A,v as a};
|
|
2
|
-
//# sourceMappingURL=agent-subpage-shell-CZJvnjNC.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as s,he as C,hf as N,d$ as L,Q as x,hg as M,hh as S,o as b,q as I,i as j,bh as k,a_ as w,r as O,O as W,hi as D,hj as P,bS as E,hk as R,hl as _,n as y,e_ as F,L as G,ao as H}from"./index-9YuSRymd.js";import{A as U}from"./agent-editor-form-DsSoeQeF.js";import{P as q}from"./proposal-review-shell-CFhOqCLf.js";function z({identity:e,sections:n,activeSection:t,activeItem:o,onSectionSelect:r,sectionLabel:l,highlightSection:c=!0,className:u}){const a=o??n.find(i=>i.key===t)??n[0];if(!a)return null;const d=a.icon;return s.jsx("div",{className:x("flex shrink-0 flex-col items-center px-4 lg:px-6",u),children:s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center justify-center gap-x-3 gap-y-2",children:[e,s.jsxs(C,{children:[s.jsx(N,{asChild:!0,children:s.jsxs("button",{type:"button",className:x("inline-flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1 text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring",c?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-label":l,children:[s.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),a.label,s.jsx(L,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),s.jsx(M,{align:"center",className:"min-w-[11rem]",children:n.map(({key:i,label:g,icon:m})=>s.jsxs(S,{className:x(i===t&&"bg-accent font-medium"),onSelect:()=>r(i),children:[s.jsx(m,{className:"h-4 w-4"}),s.jsx("span",{children:g})]},i))})]})]})})}const p=[{key:"skills",label:"Skills",icon:D},{key:"guardrails",label:"Guardrails",icon:P},{key:"permissions",label:"Permissions",icon:E,adminOnly:!0},{key:"models",label:"Models",icon:R},{key:"settings",label:"Settings",icon:_}];function Q(e){return p.filter(n=>!n.adminOnly||e)}function T(e,n){if(n===`${e}/conversations`||n.startsWith(`${e}/conversations/`))return null;for(const{key:t}of p)if(n===`${e}/${t}`||n.startsWith(`${e}/${t}/`))return t;return n===`${e}/identity`||n===`${e}/identity/`?"settings":null}function B(e){return e.trim().charAt(0).toUpperCase()||"?"}function J({owner:e,agentId:n,agentName:t,activeDest:o}){const r=b(),{orgContext:l}=y(),{isAdmin:c}=F(l.organizationId),u=Q(!!c),a=o??"settings",d=p.find(i=>i.key===a);return s.jsx(z,{identity:s.jsxs(G,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:n},search:{run_id:void 0},className:"flex min-w-0 items-center gap-2 rounded-md outline-none transition-colors hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring",title:"Agent settings",children:[s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-foreground",children:B(t)}),s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold tracking-tight",children:t})]}),sections:u,activeSection:a,activeItem:d,sectionLabel:"Agent section",highlightSection:o!==null,onSectionSelect:i=>{r({to:`/$owner/agents/$agentId/${i}`,params:{owner:e,agentId:n}})}})}function Z({owner:e,agentId:n}){const t=b(),{pathname:o}=I(),{isAuthenticated:r}=j(),{isMember:l}=k(),c=r&&l,{data:u=[],isLoading:a}=w({enabled:c}),d=u.find($=>$.agentId===n)??null,i=!d&&!a&&c,g=`/${e}/agents/${n}`,m=`${g}/conversations`,f=o===m||o.startsWith(`${m}/`),h=T(g,o);O.useEffect(()=>{i&&t({to:"/$owner",params:{owner:e},replace:!0})},[i,t,e]);const A=d?.name??"Agent";return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden py-4 md:py-6",children:[s.jsx(J,{owner:e,agentId:n,agentName:A,activeDest:h}),s.jsx("div",{className:x("flex min-h-0 min-w-0 flex-1 flex-col px-4 lg:px-6",f?"overflow-hidden":"overflow-y-auto"),children:s.jsx(W,{})})]})}function K({agent:e,tab:n,runId:t}){return s.jsx("div",{className:"mx-auto w-full max-w-3xl pb-6",children:s.jsx(q,{resource:{kind:"agent",agentId:e.agentId},runId:t,children:({reviewMode:o,proposal:r,controlsDisabled:l})=>s.jsx(U,{mode:{kind:"edit",agent:e},section:n,reviewMode:o,reviewProposal:r,reviewControlsDisabled:l},e.agentId)})})}function ee({owner:e,agentId:n,tab:t,runId:o}){const{orgContext:r,hasOrgContext:l}=y(),{isLoading:c}=H(`/${e}`,r),{isAuthenticated:u}=j(),{isMember:a,isLoading:d}=k(),i=u&&a,{data:g=[],isLoading:m}=w({enabled:i}),v=i?!l||c||m||d:c||d,f=g.find(h=>h.agentId===n)??null;return v||!f?null:s.jsx(K,{agent:f,tab:t,runId:o})}export{Z as A,ee as a};
|
|
2
|
-
//# sourceMappingURL=agents-workbench-DJ67GZ93.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as c,io as b,aP as y,aA as C,aV as w,aB as u,j as e,aC as k,L as o,ht as A,hL as j,B as g,hs as P,iB as B,ih as v,g9 as D,ga as L,gb as $,A as I,dy as R,g$ as M,iC as _,ai as E}from"./index-9YuSRymd.js";import{C as O}from"./connections-browser-CrtnAs0Q.js";import"./connection-label-BobuYiAG.js";function T({ownerSlug:s,appId:a}){const n=c.useMemo(()=>b(s,a,y()),[s,a]),{data:r=[],isLoading:l,isError:d,refetch:N}=C(),[m,x]=c.useMemo(()=>{const t=n?.devicePlatforms;if(!t?.length)return[[],[]];const p=r.filter(i=>{const f=w(i);return f!=null&&t.includes(f)});return[p.filter(i=>u(i,s)),p.filter(i=>!u(i,s))]},[n,r,s]);if(!n)return e.jsxs(k,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"There is no app by that name."}),e.jsx(o,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const h=(n.devicePlatforms?.length??0)>0;return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(A,{header:e.jsx(D,{breadcrumb:e.jsx(L,{crumbs:[e.jsx(o,{to:"/$owner/connectors",params:{owner:s},search:{},className:$,children:"Connectors"},"connectors")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border text-muted-foreground",children:n.icon}),title:n.name,caption:n.description}),children:[e.jsx("div",{id:"setup",className:"scroll-mt-40",children:e.jsx(j,{title:m.length>0?a==="owletto-chrome"?"Connect another profile":"Connect another device":"Set up",children:e.jsx("div",{className:"space-y-3",children:n.steps.map(t=>e.jsx(z,{step:t},t.label))})})}),h?e.jsx(O,{entries:m.map(t=>({id:t.id,name:v(t),description:B(t,s),tone:t.online?null:"muted",link:P({to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id}})})),isLoading:l,isError:d,onRetry:()=>void N(),action:e.jsx(g,{asChild:!0,variant:"outline",size:"sm",children:e.jsx("a",{href:"#setup",children:"Add connection"})})}):null,h&&!l&&!d&&x.length>0?e.jsxs(j,{title:"Your devices in other workspaces",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Open a device to connect its capabilities here. Moving it is confirmed first and pauses its connections where it is now."}),e.jsx("ul",{className:"divide-y border-y",children:x.map(t=>e.jsx("li",{children:e.jsxs(o,{to:"/$owner/connectors/device/$deviceId",params:{owner:s,deviceId:t.id},className:"flex items-center justify-between gap-3 py-2.5 text-sm hover:text-primary",children:[e.jsx("span",{className:"font-medium",children:v(t)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Attached to"," ",t.organization_name??"another workspace"]})]})},t.id))})]}):null]})})}function z({step:s}){const[a,n]=c.useState(!1);if(s.href)return e.jsxs("a",{href:s.href,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-accent/50",children:[s.label,e.jsx(I,{className:"h-3 w-3"})]});const r=s.command??"";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label}),e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border bg-muted/40 p-2.5",children:[e.jsx("pre",{className:"min-w-0 flex-1 overflow-x-auto font-mono text-xs leading-relaxed",children:r}),e.jsxs(g,{variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5 text-xs",onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(r).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})},children:[a?e.jsx(R,{className:"h-3.5 w-3.5"}):e.jsx(M,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Copy"})]})]})]})}function H(){const{owner:s,appId:a}=_.useParams();return e.jsx(E,{owner:s,children:({ownerSlug:n})=>e.jsx(T,{ownerSlug:n,appId:a})})}export{H as component};
|
|
2
|
-
//# sourceMappingURL=app._appId-Cp78oEZ9.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as f,j as e,S as p,e7 as y,n as A,ao as _,i as b,bh as C,u as S,h3 as k}from"./index-9YuSRymd.js";import{C as P,A as D}from"./create-automation-form-Bpy92SM5.js";import{P as E}from"./proposal-review-shell-CFhOqCLf.js";import{J as j}from"./json-diff-DIN5Jhfx.js";import{u as R,a as w}from"./deployments-C5hvipQh.js";import{E as F}from"./events-feed-DO3IiJO2.js";const L=20;function N({automationId:a}){const t=R({resourceKind:"automation",resourceId:a}),[d,c]=f.useState(null),s=w(d!=null?String(d):null),o=(t.data?.pages.length??0)>=L&&!!t.hasNextPage,r=!!t.isFetchNextPageError;f.useEffect(()=>{!o&&t.hasNextPage&&!t.isFetchingNextPage&&!t.isError&&!r&&t.fetchNextPage()},[o,t.fetchNextPage,t.hasNextPage,t.isFetchingNextPage,t.isError,r]);const l=f.useMemo(()=>(t.data?.pages??[]).flatMap(x=>x.items).filter(x=>x.type==="change"&&x.resourceKind==="automation"&&x.resourceId===String(a)),[t.data,a]),i=!!t.hasNextPage&&!o,m=typeof t.refetch=="function",h=typeof t.fetchNextPage=="function";return t.isLoading?e.jsx(p,{className:"h-20 w-full rounded-lg"}):t.isError&&!r?e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-error",children:"Definition history unavailable."}),m?e.jsx("button",{type:"button",className:"text-sm underline","data-testid":"automation-definition-history-retry",onClick:()=>void t.refetch(),children:"Retry"}):null]}):e.jsxs("section",{className:"space-y-2","aria-label":"Automation definition history","data-testid":"automation-definition-history",children:[e.jsx("h3",{className:"font-medium text-sm",children:"Definition history"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Runtime and delivery configuration changes with actor and before/after. Content versions (prompt, sources) are listed separately."}),l.length===0&&!i?e.jsx("p",{className:"py-4 text-sm text-muted-foreground","data-testid":"automation-definition-history-empty",children:"No definition changes recorded yet."}):e.jsx("ul",{className:"space-y-1","data-testid":"automation-definition-history-list",children:l.map(n=>{if(n.type!=="change")return null;const g=n.createdBy??n.agentId??n.actorSource??"unknown";return e.jsx("li",{children:e.jsxs("button",{type:"button",className:"flex w-full flex-wrap items-center justify-between gap-2 rounded-lg border border-border/60 px-3 py-2 text-left text-sm hover:bg-muted/50",onClick:()=>c(x=>x===n.id?null:n.id),"data-testid":`automation-definition-history-item-${n.id}`,children:[e.jsx("span",{className:"font-medium",children:n.action??n.op??"change"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:(n.changedFields??[]).join(", ")}),e.jsx("span",{className:"text-xs text-muted-foreground",children:g}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(n.createdAt).toLocaleString()})]})},n.id)})}),i?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-loading-more",children:"Loading more history…"}):null,o?e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-capped",children:"Showing recent definition changes"}):null,r?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground","data-testid":"automation-definition-history-page-error",children:"Couldn't load more history."}),h?e.jsx("button",{type:"button",className:"text-xs underline","data-testid":"automation-definition-history-retry-next",onClick:()=>void t.fetchNextPage(),children:"Retry"}):null]}):null,d!=null?e.jsx("div",{"data-testid":"automation-definition-history-detail",children:s.isLoading?e.jsx(p,{className:"h-24 w-full rounded-lg"}):s.isError?e.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"automation-definition-history-detail-error",children:"Change detail unavailable."}):s.data?e.jsx(j,{before:s.data.before,after:s.data.after}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Change detail unavailable."})}):null]})}function v(a){const{orgContext:t,hasOrgContext:d}=A(),{data:c,isLoading:s}=_(`/${a}`,t),{isAuthenticated:u}=b(),{isMember:o,isLoading:r}=C(),l=u&&o,i=c?.workspace,m=l?!d||s||r:s||r;return{organizationId:i?.id??"",isLoading:m}}function G(a){return v(a)}function O({owner:a,automationId:t,organizationId:d}){const c=Number(t),s=f.useMemo(()=>({producedByAutomationId:c}),[c]),u=S(),o=y(t,void 0,d),r=o.data?.automation?.automation_name?.trim()||null,l=o.data?.automation?.managed_agent_id??null,{data:i}=k(l,t,{orgSlug:a}),m=f.useMemo(()=>(i?.runs??[]).map(n=>({runId:n.runId,status:n.status,completedAt:n.completedAt})),[i]),h=f.useCallback(n=>{u?.open({href:`/${a}/automations/${t}?run_id=${n}`,title:r!=null?`${r} · Run #${n}`:`Automation run #${n}`,runId:n})},[u,a,t,r]);return Number.isFinite(c)?e.jsx(F,{organizationId:d,ownerSlug:a,filters:s,groupByRun:!0,onRunSelect:h,runs:m,hideRunAction:!0,hideAttribution:!0,emptyState:e.jsx("p",{className:"py-6 text-sm text-muted-foreground",children:"This Automation hasn't written anything yet. Runs appear here with the events they created; clicking a run opens its conversation."})}):null}function T({agentId:a,automationId:t,runId:d,organizationId:c,onDone:s}){const[u,o]=f.useState({ready:!1,triggers:[]}),r=f.useCallback(n=>{o(g=>JSON.stringify(g)===JSON.stringify(n)?g:n)},[]),l=y(t,void 0,c,{includeVersions:!0}),i=l.data?.automation,m=e.jsx("div",{className:"flex flex-col gap-4",children:[0,1,2].map(n=>e.jsx(p,{className:"h-16 w-full rounded-lg"},n))}),h=l.isLoading?m:i?e.jsx(P,{organizationId:c,prefillAgentId:a??void 0,editingAutomation:{automation_id:i.automation_id,name:i.automation_name,slug:i.slug,description:i.description,prompt:i.prompt,sources:i.sources,reaction_script:i.reaction_script,managed_agent_id:i.managed_agent_id,device_worker_id:i.device_worker_id,agent_kind:i.agent_kind,delivery_target:i.delivery_target??void 0,execution_config:i.execution_config??void 0,keying_config:i.keying_config,reactions_guidance:i.reactions_guidance,triggers:i.triggers},createFields:{triggers:u.triggers},triggerFields:e.jsx(D,{organizationId:c,initialTriggers:i.triggers??[],onChange:r},JSON.stringify(i.triggers??[])),hideHeader:!0,hideCancel:!0,submitDisabled:!u.ready,onClose:s,onSuccess:s}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automation not found. It may have been removed."});return a?e.jsxs("div",{className:"space-y-6",children:[e.jsx(E,{resource:{kind:"automation",agentId:a,automationId:t},runId:d,onDone:s,children:({reviewMode:n,proposal:g})=>n==="active"?e.jsx(j,{before:g?.current??null,after:{...g?.current??{},...g?.proposedAfter??{}}}):n==="loading"?m:n==="error"?null:h}),e.jsx(N,{automationId:t})]}):e.jsxs("div",{className:"space-y-6",children:[h,e.jsx(N,{automationId:t})]})}function V({owner:a,agentId:t,automationId:d,view:c,runId:s,onDone:u}){const{organizationId:o}=v(a),r=y(d,void 0,o),l=t??r.data?.automation?.managed_agent_id??null;return s||c==="definition"?e.jsx(T,{agentId:l,automationId:d,runId:s,organizationId:o,onDone:u}):e.jsx(O,{owner:a,automationId:d,organizationId:o})}export{V as A,G as u};
|
|
2
|
-
//# sourceMappingURL=automation-detail-content-DSwbRpbx.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as a,i,r as n,j as t}from"./index-9YuSRymd.js";function r(){const s=a(),{isReady:e}=i();return n.useEffect(()=>{e&&setTimeout(()=>{s({to:"/"})},500)},[e,s]),t.jsx("div",{className:"min-h-[calc(100vh-3.5rem)] flex items-center justify-center",children:t.jsx("div",{className:"text-center",children:t.jsx("p",{className:"text-muted-foreground",children:e?"Redirecting...":"Completing sign in..."})})})}export{r as component};
|
|
2
|
-
//# sourceMappingURL=callback-CBexCo3F.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{dE as c}from"./index-9YuSRymd.js";function o(n){const t=new Map;for(const e of n){if(e.kind!=="mcp")continue;const l=e.title?.trim()||e.identifier||"Unknown app",s=e.registrationGroupKey||e.id,i=t.get(s);if(!i){t.set(s,{key:s,clientId:e.id,title:l,drivenBy:e.drivenBy?.trim()||null,clientIds:[e.id],connected:e.status==="connected",lastSeenAt:e.lastSeenAt??null,linkedUser:e.linkedUserName??e.linkedUserEmail??null,linkedUserEntitySlug:e.linkedUserEntitySlug??null});continue}i.clientIds.push(e.id),i.connected=i.connected||e.status==="connected",(e.lastSeenAt??0)>(i.lastSeenAt??0)&&(i.lastSeenAt=e.lastSeenAt??null,i.drivenBy=e.drivenBy?.trim()||null)}return[...t.values()].sort((e,l)=>(l.lastSeenAt??0)-(e.lastSeenAt??0))}function r(n){const t=[n.linkedUser];return t.push(n.connected?`active ${c(n.lastSeenAt)}`:"disconnected"),n.drivenBy&&n.drivenBy!==n.title&&t.push(`via ${n.drivenBy}`),t.filter(Boolean).join(" · ")}export{r as c,o as g};
|
|
2
|
-
//# sourceMappingURL=client-rows-BYbsXGy9.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{cx as c,ch as u,$ as d,bI as p,bJ as r,W as o,dD as i,J as w}from"./index-9YuSRymd.js";function l(t,a="",e){const n=`${w}/api/${t}/clients${a}`,s=e?.toString();return s?`${n}?${s}`:n}function h(t,a){const e=a?.ownerSlug??c().slug;return u({queryKey:["connected-clients",e,t??null],queryFn:async()=>{if(!e)throw new Error("Workspace required");const n=new URLSearchParams;t&&n.set("agentId",t);const s=await o(l(e,"",n),{credentials:"include"});return await i(s,"Failed to load connected clients"),(await s.json()).clients??[]},enabled:!!e&&(a?.enabled??!0),staleTime:15e3,refetchInterval:a?.refetchInterval})}function y(){const{slug:t}=c(),a=d();return p({mutationFn:async e=>{if(!t)throw new Error("Workspace required");const n=new URLSearchParams;e.scope==="all"&&n.set("scope","all");const s=await o(l(t,`/mcp/${encodeURIComponent(e.clientId)}`,n),{method:"DELETE",credentials:"include"});return await i(s,"Failed to revoke client"),await s.json()},onSuccess:()=>{a.invalidateQueries({queryKey:["connected-clients",t]}),r.success("App access revoked")},onError:e=>{r.error(e.message||"Failed to revoke app access")}})}export{y as a,h as u};
|
|
2
|
-
//# sourceMappingURL=clients-BhNl1tVq.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iJ as r,j as t,ai as a}from"./index-9YuSRymd.js";import{a as i}from"./agent-connect-pages-BmknviTI.js";import"./agent-client-setup-list-BlXB4SE5.js";import"./clients-BhNl1tVq.js";import"./client-rows-BYbsXGy9.js";function x(){const{owner:e,clientId:o}=r.useParams();return t.jsx(a,{owner:e,children:({ownerSlug:n})=>t.jsx(i,{owner:n,clientId:o})})}export{x as component};
|
|
2
|
-
//# sourceMappingURL=connect._clientId-kk0_4Svo.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,ai as w,r as N,d8 as y,ht as p,g9 as x,ga as h,L as r,gb as o,x as _,bk as j,aR as L,di as A,B as $,A as k,iX as g}from"./index-9YuSRymd.js";import{c as E}from"./conversations-table-D_HOe1jN.js";import{E as B}from"./events-feed-DO3IiJO2.js";import{u as P}from"./clients-BhNl1tVq.js";import{g as R}from"./client-rows-BYbsXGy9.js";import"./schema-value-normalization-CKdPjdPC.js";import"./card-jzhQrMDP.js";const S="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function D({owner:s,clientId:a,mcpActivityId:t}){return e.jsx("div",{className:S,children:e.jsx(w,{owner:s,children:({organizationId:n,ownerSlug:l})=>e.jsx(T,{ownerSlug:l,organizationId:n,clientId:a,mcpActivityId:t})})})}function T({ownerSlug:s,organizationId:a,clientId:t,mcpActivityId:n}){const{data:l=[],isLoading:f}=P(null),i=N.useMemo(()=>R(l).find(u=>u.clientIds.includes(t)),[t,l]),d=i?.clientIds??[],{data:b=[],isLoading:v}=y({enabled:!!i&&!!a,limit:100,clientIds:d,organizationId:a}),c=n?b.find(u=>u.activityId===n)??null:null,m=i?.title??"Connected agent",C=c?E(c):"Conversation";return!a||f||n&&v?e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents")]}),title:"Conversation"}),children:e.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"Loading…"})}):n&&(!i||!c||c.organizationId===null)?e.jsx(_,{to:"/$owner/events",params:{owner:"me"},search:{client_ids:i?d.join(","):t,mcp_activity_id:n},replace:!0}):i?n?e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents"),e.jsx(r,{to:"/$owner/agents/connected/$clientId",params:{owner:s,clientId:t},className:o,children:m},"app")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(j,{name:c?.clientName??m})}),title:C,meta:e.jsx($,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(r,{to:"/$owner/events",params:{owner:s},search:{client_ids:d.join(","),mcp_activity_id:n},children:["See in Activity",e.jsx(k,{className:"h-3.5 w-3.5"})]})})}),children:e.jsx(B,{organizationId:a,ownerSlug:s,filters:{clientIds:d,mcpActivityId:n,sortBy:"date",sortOrder:"desc"},hideOriginator:!0,foldConsecutiveCalls:!0,emptyState:e.jsx(L,{icon:A,title:"No activity in this conversation yet",description:"Calls this app makes will appear here."})})}):e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents"),e.jsx(r,{to:"/$owner/agents/connected/$clientId",params:{owner:s,clientId:t},className:o,children:m},"app")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(j,{name:m})}),title:"Conversation"}),children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a conversation on this app's page to see its activity."})}):e.jsx(p,{header:e.jsx(x,{breadcrumb:e.jsx(h,{crumbs:[e.jsx(r,{to:"/$owner/agents",params:{owner:s},className:o,children:"Agents"},"agents")]}),title:"Conversation"}),children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This app isn't connected to this workspace, so its activity isn't available."})})}function W(){const{owner:s,clientId:a}=g.useParams(),t=g.useSearch();return e.jsx(D,{owner:s,clientId:a,mcpActivityId:typeof t.mcp_activity_id=="string"?t.mcp_activity_id:null})}export{W as component};
|
|
2
|
-
//# sourceMappingURL=connected._clientId.activity-BqprYeOX.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as E,e_ as z,r as c,d8 as C,j as e,S as N,cA as P,L as I,dE as U,hL as p,B as v,a2 as B,ht as D,g9 as M,bk as _,ga as T,gb as G,iQ as K,ai as Q}from"./index-9YuSRymd.js";import{C as k}from"./conversations-table-D_HOe1jN.js";import{u as S,a as $}from"./clients-BhNl1tVq.js";import{g as A}from"./client-rows-BYbsXGy9.js";function O({ownerSlug:n,clientId:i}){const{orgContext:a}=E(),{isAdmin:f}=z(a.organizationId),{data:l=[],isLoading:d}=S(null),r=$(),[L,u]=c.useState(!1),s=c.useMemo(()=>A(l),[l]).find(t=>t.clientIds.includes(i)),j=s?.clientIds??[],m=C({enabled:!!s,limit:100,clientIds:j,activityKind:"conversation",organizationId:a?.organizationId??null}),x=C({enabled:!!s,limit:100,clientIds:j,activityKind:"session",organizationId:a?.organizationId??null,refetchInterval:t=>t?5e3:!1}),o=m.data??[],g=x.data??[],w=c.useMemo(()=>l.filter(t=>s?.clientIds.includes(t.id)),[l,s]);if(d)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(N,{className:"h-16 w-full rounded-lg"}),e.jsx(N,{className:"h-24 w-full rounded-lg"})]});if(!s)return e.jsx("p",{className:"text-sm text-muted-foreground",children:"This app isn't connected to this workspace, so its details aren't available."});const h=w[0],b=h?.details?.redirectUris??[],y=s.linkedUserEntitySlug?P(n,[{entity_type:"$member",slug:s.linkedUserEntitySlug}]):null,R=[{label:"Registered",value:s.title},{label:s.clientIds.length===1?"Client ID":"Client IDs",value:e.jsx("div",{className:"space-y-1",children:s.clientIds.map(t=>e.jsx("code",{className:"block break-all",children:t},t))})},...s.drivenBy&&s.drivenBy!==s.title?[{label:"Driven by",value:s.drivenBy}]:[],...h?.platform?[{label:"Software",value:h.platform}]:[],...b.length>0?[{label:"Redirects",value:b.join(", ")}]:[],{label:"Granted by",value:y&&s.linkedUser?e.jsx(I,{to:y,className:"font-medium text-primary hover:underline",children:s.linkedUser}):s.linkedUser??"—"},{label:"Last active",value:s.connected?U(s.lastSeenAt):"disconnected"},{label:"Registrations",value:String(s.clientIds.length)}];return e.jsxs("div",{className:"space-y-7",children:[e.jsx(p,{title:"Settings",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"overflow-hidden rounded-lg border text-xs",children:e.jsx("dl",{className:"divide-y",children:R.map(t=>e.jsxs("div",{className:"flex gap-3 px-3 py-2",children:[e.jsx("dt",{className:"w-28 shrink-0 text-muted-foreground",children:t.label}),e.jsx("dd",{className:"min-w-0 flex-1 break-words",children:t.value})]},t.label))})}),f&&s.connected?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Revoking disconnects every registration this app holds",s.clientIds.length>1?` (${s.clientIds.length} of them)`:""," ","and kills its live sessions. It can reconnect by authorizing again."]}),L?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"destructive",size:"sm",className:"h-7 px-2 text-xs",disabled:r.isPending,onClick:()=>r.mutate({clientId:s.clientIds[0],scope:"all"},{onSettled:()=>u(!1)}),children:r.isPending?"Revoking…":"Confirm revoke"}),e.jsx(v,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",disabled:r.isPending,onClick:()=>u(!1),children:"Cancel"})]}):e.jsx(v,{variant:"outline",size:"sm",className:"h-7 px-2 text-xs text-destructive hover:text-destructive",onClick:()=>u(!0),children:"Revoke"})]}):null]})}),e.jsx(p,{title:"Conversations",count:o.length>0?String(o.length):void 0,children:m.isLoading||x.isLoading?e.jsxs("div",{className:"flex items-center py-4 text-xs text-muted-foreground",children:[e.jsx(B,{className:"mr-2"})," Loading client activity…"]}):m.isError||x.isError?e.jsx("p",{className:"py-3 text-xs text-destructive",children:"Could not load this app's activity."}):o.length===0?e.jsx("p",{className:"py-3 text-xs text-muted-foreground",children:"No recent conversations."}):e.jsx(k,{scopes:o,ownerSlug:n})}),g.length>0?e.jsx(p,{title:"Sessions",count:String(g.length),children:e.jsx(k,{scopes:g,ownerSlug:n})}):null]})}const H="flex min-h-0 flex-1 flex-col gap-3 px-4 pt-2.5 pb-8 lg:px-6";function W({owner:n,clientId:i}){const{data:a=[]}=S(null),l=c.useMemo(()=>A(a).find(d=>d.clientIds.includes(i)),[i,a])?.title??"Connected agent";return e.jsx("div",{className:H,children:e.jsx(D,{header:e.jsx(M,{breadcrumb:e.jsx(T,{crumbs:[e.jsx(I,{to:"/$owner/agents",params:{owner:n},className:G,children:"Agents"},"agents")]}),icon:e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border",children:e.jsx(_,{name:l})}),title:l,caption:"An external agent connected to this workspace through Lobu. Review its Lobu conversations, activity, and access."}),children:e.jsx(O,{ownerSlug:n,clientId:i},i)})})}function Y(){const{owner:n,clientId:i}=K.useParams();return e.jsx(Q,{owner:n,children:({ownerSlug:a})=>e.jsx(W,{owner:a,clientId:i})})}export{Y as component};
|
|
2
|
-
//# sourceMappingURL=connected._clientId.index-DhRoSzBr.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{h$ as h,hs as g,j as e,B as u,L as m,cT as j,hL as p,r as f,i5 as v,i6 as N,dF as w}from"./index-9YuSRymd.js";import{c as b}from"./connection-label-BobuYiAG.js";function C(n){return e.jsx(p,{title:"Connections",count:n.isLoading||n.isError?void 0:String(n.entries.length),children:e.jsx(x,{...n})})}function x({entries:n,action:i,isLoading:r,isError:o,onRetry:c}){const[a,d]=f.useState("");if(r)return e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"});if(o)return e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load connections."}),c&&e.jsx(u,{variant:"outline",size:"sm",onClick:c,children:"Retry"})]});const s=n.filter(t=>`${t.name} ${t.description??""}`.toLowerCase().includes(a.trim().toLowerCase())).sort((t,l)=>+!!l.needsAttention-+!!t.needsAttention);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{label:"connections",query:a,onQueryChange:d,count:s.length,action:i}),e.jsx("ul",{className:s.length>0?"overflow-hidden rounded-lg border divide-y":void 0,children:s.map(t=>e.jsx("li",{children:e.jsxs(m,{...t.link,className:"flex items-center justify-between gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e.jsx(N,{tone:t.tone}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-sm font-medium",children:t.name}),t.description&&e.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:t.description})]})]}),e.jsxs("span",{className:"flex min-w-0 max-w-1/2 shrink-0 items-center gap-2",children:[t.status&&e.jsx("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:t.status}),e.jsx(w,{"aria-hidden":"true",className:"size-4 shrink-0 text-muted-foreground"})]})]})},t.id))}),s.length===0&&e.jsx("p",{className:"py-5 text-sm text-muted-foreground",children:a.trim()?"No matches. Try another search.":"No connections yet."})]})}function _({connections:n,connector:i,connectorKey:r,ownerSlug:o,section:c=!1}){const a=n.filter(s=>s.connector_key===r).map(s=>{const t=!!i&&h(i)&&!s.device_worker_id,l=["error","revoked","pending_auth"].includes(s.status);return{id:String(s.id),name:b({...s,connector_name:s.connector_name??i?.name??null}),needsAttention:l||t,tone:s.status==="error"||s.status==="revoked"?"destructive":t||s.status!=="active"?"amber":null,status:t?"Needs a device":l?s.error_message?.trim()||(s.status==="pending_auth"?"needs reconnect":s.status):void 0,link:g({to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:o,connectorKey:r,connectionId:String(s.id)},search:{}})}}),d=c?C:x;return e.jsx(d,{entries:a,action:e.jsx(u,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(m,{to:"/$owner/connectors/create/$connectorKey",params:{owner:o,connectorKey:r},children:[e.jsx(j,{className:"size-3.5"}),"Add connection"]})})})}export{C,_ as a};
|
|
2
|
-
//# sourceMappingURL=connections-browser-CrtnAs0Q.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{cP as y,j as t,S as f,B as p,aR as v,cR as j,L as _,cT as N,i6 as $,bd as b,u as w,hZ as k}from"./index-9YuSRymd.js";function g(e){switch(e.attention){case"needs_auth":return"Needs authentication";case"setup_required":return e.attention_reason?.trim()||"Setup required";case"paused":return"Paused";case"misconfigured":return"Configuration error";case"device_offline":return`Waiting for ${e.device_label||e.device_platform||"device"}`;case"last_attempt_failed":{const r=Number(e.consecutive_failures??0);return e.last_error?.trim()||(r>0?`${r} consecutive sync ${r===1?"failure":"failures"}`:"Last sync failed")}case"overdue":return"Scheduled run overdue";case"no_trigger":return"No schedule — this feed only runs when you sync it";case"never_run":return e.execution_mode==="scheduled"?"Scheduled, not run yet":"Not synced yet";default:return null}}function C(e){switch(e.attention){case"last_attempt_failed":case"misconfigured":return"destructive";case"needs_auth":case"setup_required":case"device_offline":case"overdue":case"no_trigger":case"never_run":return e.attention==="never_run"&&e.execution_mode!=="scheduled"?"muted":"amber";case"paused":return"muted";default:return e.status==="active"?null:e.status==="error"?"destructive":"muted"}}function S(e){return Object.keys(e?.feeds_schema??{}).length>0}function A({connection:e,ownerSlug:r,connectorKey:u,connectorDef:h}){const{data:i=[],isLoading:l,isError:m,refetch:a}=y(e.id),d=S(h),c=e.facets?.chat??!1,o={owner:r,connectorKey:u,connectionId:String(e.id)};return l?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(f,{className:"h-12 w-full rounded-lg"}),t.jsx(f,{className:"h-12 w-full rounded-lg"})]}):m?t.jsxs("div",{role:"alert",className:"space-y-2",children:[t.jsx("p",{children:"Could not load feeds."}),t.jsx(p,{variant:"outline",size:"sm",onClick:()=>void a(),children:"Retry"})]}):i.length===0?t.jsx(v,{icon:j,title:c?"No channels":"No feeds",description:d?c?"Bind a channel to route conversations to this connection.":"Add a feed to start collecting data from this connection.":c?"This chat connection has no bound channels yet.":"This connector doesn't provide any feeds.",children:d?t.jsx(p,{asChild:!0,size:"sm",children:t.jsxs(_,{to:"/$owner/connectors/$connectorKey/$connectionId",params:o,search:{addFeed:!0},children:[t.jsx(N,{className:"h-3.5 w-3.5"}),c?"Add channel":"Add feed"]})}):null}):t.jsx("ul",{className:"flex flex-col gap-2",children:i.map(n=>{const s=n.display_name?.trim()||n.feed_key,x=g(n);return t.jsx("li",{children:t.jsxs(_,{to:"/$owner/connectors/$connectorKey/$connectionId",params:o,search:{feedId:n.id},className:"flex w-full items-center justify-between gap-3 rounded-lg border border-border px-3 py-2.5 text-left transition-colors hover:bg-accent/50",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx($,{tone:C(n)}),t.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:s})]}),t.jsx("span",{className:n.attention==="last_attempt_failed"||n.attention==="misconfigured"?"max-w-[50%] shrink-0 text-right text-xs text-destructive":n.attention&&n.attention!=="healthy"?"max-w-[50%] shrink-0 text-right text-xs text-amber-600 dark:text-amber-400":"shrink-0 text-xs text-muted-foreground",title:x??void 0,children:x??(n.store==="channel_messages"?"chat channel":n.operations.includes("read")&&n.operations.includes("sync")?"synced + live":n.operations.includes("read")?"live":n.last_sync_at?`synced ${b(n.last_sync_at)}`:"not synced yet")})]})},n.id)})})}function F({connection:e,ownerSlug:r,title:u}){const h=w(),{data:i=[],isLoading:l,isError:m}=y(e.id),a=i.filter(s=>["needs_auth","setup_required","misconfigured","last_attempt_failed","device_offline","overdue"].includes(s.attention??"")),d=i.filter(s=>s.status==="paused").length,c=l?e.feed_count:i.length,o=e.facets?.chat?"channels":"feeds",n=l?`Loading ${o}…`:m?`Could not load ${o} — open to retry`:`${c} ${o}${a.length?` · ${a.length} need attention`:""}${d?` · ${d} paused`:""}`;return t.jsxs("div",{className:"space-y-2",children:[t.jsx(k,{title:u,summary:n,onOpen:()=>h?.open({href:"",title:e.facets?.chat?"Channels":"Feeds",connectorPanel:{section:"feeds",connectorKey:e.connector_key,connectionId:e.id,organizationId:e.organization_id,ownerSlug:r}})}),a.length>0&&t.jsxs("ul",{className:"space-y-1 text-xs text-destructive",children:[a.slice(0,3).map(s=>t.jsxs("li",{children:[s.display_name||s.feed_key,": ",g(s)]},s.id)),a.length>3&&t.jsxs("li",{children:[a.length-3," more sources need attention."]})]})]})}export{A as C,F as a,S as c,g as f};
|
|
2
|
-
//# sourceMappingURL=connector-scope-lists-CRFEpSvk.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as t,P as o,o as u,ep as h,eq as v,er as l,es as n,ev as j,ew as s,L as p,bd as y,A as N}from"./index-9YuSRymd.js";function f({isLive:a}){return t.jsx(o,{variant:a?"default":"secondary",className:`shrink-0 text-[10px] ${a?"":"text-muted-foreground"}`,title:a?"Live MCP transport":"No live MCP transport; activity history is retained",children:a?"Active":"Ended"})}function c(a){const i=a.title?.trim();return i||(a.activityKind==="session"?"MCP session":a.clientId)}function b({scopes:a,ownerSlug:i}){const d=u(),r=e=>e.organizationId===null?{to:"/$owner/events",params:{owner:"me"},search:{client_ids:e.clientId,mcp_activity_id:e.activityId}}:{to:"/$owner/agents/connected/$clientId/activity",params:{owner:i,clientId:e.clientId},search:{mcp_activity_id:e.activityId}},x=e=>{d(r(e))};return t.jsx("div",{className:"rounded-lg border",children:t.jsxs(h,{children:[t.jsx(v,{children:t.jsxs(l,{children:[t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Conversation"}),t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Calls"}),t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Last action"}),t.jsx(n,{className:"px-3 py-1.5 text-xs",children:"Last active"}),t.jsx(n,{className:"w-8 px-3 py-1.5"})]})}),t.jsx(j,{children:a.map(e=>t.jsxs(l,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>x(e),children:[t.jsx(s,{className:"max-w-0 px-3 py-2 text-xs font-medium",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(p,{...r(e),onClick:m=>m.stopPropagation(),className:"truncate hover:underline",children:c(e)}),e.activityKind==="session"?t.jsx(f,{isLive:e.isLive}):null,e.unreadNotificationCount>0?t.jsxs(o,{variant:"secondary",className:"shrink-0 text-[10px]",children:[e.unreadNotificationCount," unread"]}):null]})}),t.jsx(s,{className:"px-3 py-2 font-mono text-xs text-muted-foreground",children:e.callCount}),t.jsx(s,{className:"max-w-0 truncate px-3 py-2 text-xs text-muted-foreground",children:e.lastAction||"—"}),t.jsx(s,{className:"px-3 py-2 text-xs text-muted-foreground",children:y(e.lastCallAt)}),t.jsx(s,{className:"px-3 py-2 text-right",children:t.jsx("button",{type:"button","aria-label":`View ${c(e)} activity`,className:"text-muted-foreground hover:text-foreground",tabIndex:-1,children:t.jsx(N,{className:"h-3.5 w-3.5"})})})]},`${e.clientId}:${e.activityId}`))})]})})}export{b as C,c};
|
|
2
|
-
//# sourceMappingURL=conversations-table-D_HOe1jN.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i_ as o,j as e}from"./index-9YuSRymd.js";import{a}from"./agent-guardrails-route-TdvvIc_J.js";import"./model-selector-CDrAjH31.js";import"./agent-subpage-shell-CZJvnjNC.js";import"./agent-loading-shells-B7v6Cffw.js";import"./agent-card-controls-CplnPhbv.js";function g(){const{owner:r,agentId:t}=o.useParams();return e.jsx(a,{owner:r,agentId:t})}export{g as component};
|
|
2
|
-
//# sourceMappingURL=create-C4lptGWj.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as n,ai as t,O as c,d7 as r,aC as i,g9 as l,ag as m,ga as x,L as d,gb as C,gc as u,f4 as j}from"./index-9YuSRymd.js";function p({owner:o,initialConnectorKey:e}){return n.jsx(t,{owner:o,children:a=>n.jsx(g,{ownerSlug:a.ownerSlug,organizationId:a.organizationId,initialConnectorKey:e})})}function g({ownerSlug:o,organizationId:e,initialConnectorKey:a}){const{data:s=[]}=r(e??"");return n.jsxs(i,{className:"flex flex-1 flex-col gap-6",children:[n.jsx(l,{breadcrumb:n.jsx(x,{crumbs:[n.jsx(d,{to:"/$owner/connectors",params:{owner:o},search:{},className:C,children:"Connectors"},"connectors")]}),icon:n.jsx(m.connectors.icon,{className:"h-6 w-6"}),title:"Add a connection",caption:"Pick a connector from the catalog or drop in an MCP URL — Lobu handles auth and brings the data into memory."}),e?n.jsx(u,{ownerSlug:o,organizationId:e,connections:s,initialConnectorKey:a}):n.jsx("div",{className:"max-w-3xl",children:n.jsx(j,{rows:4})})]})}const f=()=>n.jsx(c,{});export{p as ConnectionsCreateRouteContent,f as component};
|
|
2
|
-
//# sourceMappingURL=create-CCjZxIkK.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{iY as r,j as e}from"./index-9YuSRymd.js";import{a as i}from"./agent-skills-route-B3vvvZZe.js";import"./agent-subpage-shell-CZJvnjNC.js";import"./agent-skill-context-DFucg4c4.js";import"./core.esm-BupT3V0i.js";import"./skill-editor-D_W3QlRz.js";import"./agent-loading-shells-B7v6Cffw.js";import"./agent-card-controls-CplnPhbv.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-DkgUQAbB.js.map
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as i,j as e,bp as ie,bq as re,br as ce,bs as le,bt as D,I as oe,B as Q,X as Yt,d7 as gs,cg as ps,cB as Zt,gM as fs,gN as vs,S as Ct,z as k,Q as R,af as Ie,ed as Et,ef as ys,eg as js,fT as _s,d$ as es,eh as Ns,eS as ks,b0 as Ft,gO as bs,eE as st,cF as Ke,dy as tt,eG as yt,a$ as ts,cT as Je,ch as Ss,W as ws,J as Cs,ci as Es,gP as Fs,gQ as As,gR as Os,gS as Ts,gT as Ms,P as Ds,L as Ps,n as ss,gJ as Ls,a_ as Rs,aA as $s,f3 as At,gj as Is,gU as qs,b_ as Ks,fN as Ws,bA as pt,a2 as Bs,gV as zs,gW as Vs,gX as Us,gY as Qs,gZ as Gs,g_ as Js,g$ as Hs,h0 as Xs,h1 as Ys,b1 as Zs,bz as en}from"./index-9YuSRymd.js";import{c as tn}from"./cronstrue-CWImw-kf.js";import{C as sn,f as nn}from"./entity-options-Clz_WXK-.js";import{M as an}from"./model-selector-CDrAjH31.js";import{b as on}from"./skill-editor-D_W3QlRz.js";import{C as ft}from"./code-editor-CEqoCky-.js";import{u as rn,b as Ot,c as Tt,s as cn,o as ln,M as dn,d as un,e as mn,f as hn,v as xn,r as gn}from"./use-mention-search-Dcunv4L0.js";const Ze=[{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 pn(n){const t=n.trim();if(!t)return null;try{return tn.toString(t,{throwExceptionOnParseError:!0})}catch{return null}}function fn({value:n,onChange:t,placeholder:s="No schedule",className:r}){const d=n??"",u=Ze.some(f=>f.value===d),[c,a]=i.useState(!u&&d!==""),x=f=>{f==="custom"?a(!0):(a(!1),t(f))},m=d?pn(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&&!c?e.jsxs(ie,{onValueChange:x,children:[e.jsx(re,{className:r??"w-full",children:e.jsx(ce,{placeholder:s})}),e.jsx(le,{children:Ze.map(f=>e.jsxs(D,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c?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:x,children:[e.jsx(re,{className:r??"w-full flex-1",children:e.jsx(ce,{children:Ze.find(f=>f.value===d)?.label??d})}),e.jsx(le,{children:Ze.map(f=>e.jsxs(D,{value:f.value,children:[f.label,f.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:f.value})]},f.value))})]}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>{a(!1),t("")},children:e.jsx(Yt,{className:"h-4 w-4"})})]}),S]})}const dt="__all_workspace_event_types__",vn=[],yn={};function Mt(n,t,s){const r=new Map;if(!t)for(const[u,c]of Object.entries(s??{}))r.set(u,{key:u,label:Ft(u),description:c.description});const d=[...n].filter(u=>!t||u.slug===t).sort((u,c)=>u.slug.localeCompare(c.slug));for(const u of d)for(const[c,a]of Object.entries(u.event_kinds??{})){const x=r.get(c);if(x){!x.description&&a.description&&(x.description=a.description),JSON.stringify(x.metadataSchema??null)!==JSON.stringify(a.metadataSchema??null)&&(x.metadataSchema=void 0);continue}r.set(c,{key:c,label:Ft(c),description:a.description,metadataSchema:a.metadataSchema})}return[...r.values()].sort((u,c)=>u.label.localeCompare(c.label))}function Dt(n){const t=n[0];if(!t)return;const s=d=>JSON.stringify(Object.keys(d?.properties??{}).sort()),r=s(t);return n.every(d=>s(d)===r)?t:void 0}function Pt(n,t,s){const r=new Set(Object.keys(t.properties??{}));return{...Object.fromEntries(Object.entries(n).filter(([d])=>!r.has(d))),...s}}function $e(n,t,s){return s==="steer"&&(n==="window"||t!=="reply_to_source")?"coalesce":s}function Qe(n,t){return n==="window"?"silent":t}function Lt(n){return Object.fromEntries(Object.entries(n).filter(([t])=>t==="resource_ref"||t==="resource_type"))}function Rt(n,t,s){const r=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)||r.has(u)))}function jn({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(r=>e.jsx("button",{type:"button","aria-pressed":n===r.value,onClick:()=>s(r.value),className:R("rounded px-3 py-1 transition-colors",n===r.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:r.label},r.value))})}function $t({events:n,selectedKeys:t,onToggle:s,ariaLabel:r="Events"}){const d=i.useId(),u=n.filter(a=>t.includes(a.key)).map(a=>a.label),c=u.length===0?"Choose events":u.length===1?u[0]:`${u.length} events selected`;return e.jsx(st,{contentClassName:"w-[var(--radix-popover-trigger-width)] min-w-[280px]",searchPlaceholder:"Filter events...",emptyText:"No events found.",trigger:a=>e.jsxs(Q,{type:"button",variant:"outline",role:"combobox","aria-label":r,"aria-expanded":a,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:R(u.length===0&&"text-muted-foreground"),children:c}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>n.map((a,x)=>{const m=t.includes(a.key),S=`${d}-${x}-state`;return e.jsxs(Ke,{value:`${a.label} ${a.key}`,onSelect:()=>s(a.key),"aria-label":a.label,"aria-describedby":S,className:"cursor-pointer",children:[e.jsx(tt,{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 _n({organizationId:n,initialTrigger:t,onChange:s,allowedKinds:r,showSectionHeader:d=!0,fieldIdPrefix:u="automation-trigger-"}){const c=gs(n,{status:"active",limit:500}),a=ps(n),x=Zt({organizationId:n}),m=fs({organizationId:n}),S=c.data??[],f=a.data??[],I=x.data??vn,h=m.data??yn,j=i.useMemo(()=>I.filter(l=>l.organization_id===n),[I,n]),y=t?.kind==="event"&&t?.source==="workspace",w=y||t===void 0,P=r?.length?[...r]:["event","time","manual"],_=P.join("|"),q=(()=>{const l=t===null?"manual":t?.kind==="schedule"?"time":"event";return P.includes(l)?l:P[0]??"event"})(),[N,K]=i.useState(q),[X,te]=i.useState(y?"workspace":typeof t?.connection_id=="number"?String(t.connection_id):t?.kind==="event"&&t.connector_key?"":"workspace"),b=X==="workspace",C=b?"":X,[g,G]=i.useState(typeof t?.entity_type=="string"?t.entity_type:""),se=i.useMemo(()=>Array.isArray(t?.event_types)?t.event_types:[],[t]),[$,V]=i.useState(()=>se.filter(l=>typeof l=="string")),[Y,he]=i.useState(t?.match&&typeof t.match=="object"&&!Array.isArray(t.match)?t.match:{}),[xe,ke]=i.useState(typeof t?.cron=="string"?t.cron:"0 9 * * 1-5"),be=typeof t?.timezone=="string"?t.timezone:void 0,[M,ge]=i.useState(t?.kind==="schedule"||w&&t?.execution!=="turn"||t?.execution==="window"?"window":"turn"),[ne,Z]=i.useState(Qe(M,t?.output==="reply_to_source"?"reply_to_source":"silent")),[J,ae]=i.useState(t?.kind==="schedule"||w&&t?.active_run!=="queue"?"coalesce":$e(M,ne,t?.active_run==="coalesce"||t?.active_run==="steer"?t.active_run:"queue")),[Se,Fe]=i.useState(t?.skip_if_unchanged!==!1),[we,p]=i.useState(!1);i.useEffect(()=>{const l=_.split("|");if(!l.includes(N)){const v=l[0]??"event";K(v),ge(v==="time"||v==="event"&&b?"window":"turn"),ae(v==="time"||v==="event"&&b?"coalesce":"queue"),Z("silent")}},[_,N,b]);const W=S.find(l=>String(l.id)===C),H=c.isLoading||a.isLoading,pe=x.isLoading,E=typeof t?.connector_key=="string"?t.connector_key:void 0,Ae=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&typeof t.connection_id=="number"&&String(t.connection_id)===C&&!W,ve=N==="event"&&!b&&t?.kind==="event"&&t?.source!=="workspace"&&t.connection_id==null&&E!==void 0&&C==="",Oe=f.find(l=>l.key===(W?.connector_key??(ve?E:void 0))),de=Oe?.automation_events??[],B=de.filter(l=>$.includes(l.key)),ye=B[0],Me=j.find(l=>l.slug===g),Te=[...j.filter(l=>Object.keys(l.event_kinds??{}).length>0||l.slug===g),...g&&!Me?[{slug:g,name:g}]:[]],ue=i.useMemo(()=>Mt(j,g||void 0,h),[j,g,h]),De=ue.filter(l=>$.includes(l.key)),We=De[0],fe=Dt(B.map(l=>l.filterSchema)),me=Dt(De.map(l=>l.metadataSchema)),Be=!!(b&&g&&!Me),Pe=Ae||ve,Ce=(N==="event"?b?$.length>0&&!Be:!!($.length>0&&(C&&W||Pe)):N==="time"?!!xe.trim():!0)&&(N!=="event"||!vs(Y));i.useEffect(()=>{let l;if(Ce&&N==="event"&&!b){const v=Rt(Y,fe,Oe?.automation_events??[]);W||ve?l={kind:"event",source:"connector",connector_key:W?.connector_key??E,...W?{connection_id:Number(C)}:{},event_types:$,...Object.keys(v).length>0?{match:v}:{},execution:M,active_run:$e(M,ne,J),output:Qe(M,ne),skip_if_unchanged:Se}:Ae&&(l=t?{...t,source:"connector"}:void 0)}else if(Ce&&N==="event"&&b){const v=Rt(Y,me,ue.map(F=>({filterSchema:F.metadataSchema})));l={kind:"event",source:"workspace",...g?{entity_type:g}:{},event_types:$,...Object.keys(v).length>0?{match:v}:{},execution:M,active_run:J==="queue"?"queue":"coalesce"}}else Ce&&N==="time"&&(l={kind:"schedule",cron:xe.trim(),...be?{timezone:be}:{},execution:"window",active_run:"coalesce",skip_if_unchanged:Se});s({ready:Ce,kind:N,trigger:l})},[J,C,W,xe,Oe,$,M,Y,N,E,be,t,b,s,ne,Ce,fe,me,Se,g,ue,ve,Ae]);const at=l=>{const v=S.find(A=>String(A.id)===l),F=f.find(A=>A.key===v?.connector_key),ee=$.filter(A=>F?.automation_events?.some(Re=>Re.key===A)),T=F?.automation_events?.find(A=>A.key===ee[0]),je=v?.connector_key!==(W?.connector_key??E);if(te(l),V(ee),!T)he(Lt);else if(je){const A=T.defaults?.execution??"turn",Re=T.defaults?.activeRun??"queue",Ue=Qe(A,T.defaults?.output??"silent");he(Lt),ge(A),ae($e(A,Ue,Re)),Z(Ue)}},ot=l=>{if(l==="workspace"){te("workspace"),V(v=>v.filter(F=>ue.some(ee=>ee.key===F))),he({}),ge("window"),ae("coalesce"),Z("silent");return}at(l)},ze=l=>{const v=$.includes(l)?$.filter(A=>A!==l):de.map(A=>A.key).filter(A=>A===l||$.includes(A));if(V(v),v[0]===$[0])return;const F=de.find(A=>A.key===v[0]),ee=F?.defaults?.execution??"turn",T=F?.defaults?.activeRun??"queue",je=Qe(ee,F?.defaults?.output??"silent");ge(ee),ae($e(ee,je,T)),Z(je)},Xe=l=>{const v=l===dt?"":l,F=j.find(T=>T.slug===v),ee=Mt(j,F?.slug,h);G(v),V(T=>T.filter(je=>ee.some(A=>A.key===je))),he({})},Ve=l=>{V(v=>v.includes(l)?v.filter(F=>F!==l):ue.map(F=>F.key).filter(F=>F===l||v.includes(F)))},Le=[{value:"event",label:"Event"},{value:"time",label:"Schedule"},{value:"manual",label:"Manual"}].filter(l=>P.includes(l.value));return e.jsxs("div",{className:"space-y-4",children:[d?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"When"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose what starts this Automation. Its goal and context stay reusable."})]}):null,Le.length>1?e.jsx(jn,{value:N,options:Le,onChange:l=>{K(l),ge(l==="time"||l==="event"&&b?"window":"turn"),ae(l==="time"||l==="event"&&b?"coalesce":"queue"),Z("silent")}}):null,N==="event"?H||b&&pe?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ct,{className:"h-9 w-full"}),e.jsx(Ct,{className:"h-9 w-full"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Source"}),e.jsx(sn,{connections:S,value:X,onValueChange:ot,disabled:Pe,includeWorkspaceEvents:!0,ariaLabel:"Source",placeholder:"Choose a source"}),Ae?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."}):ve?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:ue.length>1?"Events":"Event"}),ue.length>0?e.jsx($t,{events:ue,selectedKeys:$,onToggle:Ve}):e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:g?"This entity type has no declared Automation events.":"This workspace has no declared Automation events."}),We?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:We.description}):null,Be?e.jsxs("p",{className:"text-xs text-destructive",children:["This trigger filters on entity type “",g,"”, 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."})]}),me?e.jsx(Et,{schema:me,values:Y,onValuesChange:l=>he(v=>Pt(v,me,l)),fieldIdPrefix:`${u}workspace-`},`${g||"workspace"}:${$.join(",")}`):null]}):W||ve?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:de.length>1?"Events":"Event"}),de.length?e.jsx($t,{events:de,selectedKeys:$,onToggle:ze}):e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"This connector has not published subscribable events."}),ye?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:ye.description}):null]}),typeof Y.resource_ref=="string"||fe?e.jsxs("div",{className:"space-y-3",children:[typeof Y.resource_ref=="string"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Resource"}),e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm"),children:Y.resource_ref})]}):null,fe?e.jsx(Et,{schema:fe,values:Y,onValuesChange:l=>he(v=>Pt(v,fe,l)),fieldIdPrefix:u},$.join(",")):null]}):null]}):X?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(fn,{value:xe,onChange:ke}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this Automation explicitly from Lobu, the API, CLI, or MCP."}),N!=="manual"&&!Pe?e.jsxs(ys,{open:we,onOpenChange:p,children:[e.jsx(js,{asChild:!0,children:e.jsxs(Q,{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:["· ",M==="turn"?"Each event":"Window"," ·"," ",N==="time"?"Combine":b?J==="queue"?"Queue":"Combine":J==="queue"?"Queue":J==="coalesce"?"Combine":"Update current run",N==="event"&&!b?` · ${M==="turn"&&ne==="reply_to_source"?"Reply":"Save in Lobu"}`:""]})]}),e.jsx(es,{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:g||dt,onValueChange:Xe,children:[e.jsx(re,{"aria-label":"Entity type filter",children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:dt,children:"All event types"}),Te.map(l=>e.jsx(D,{value:l.slug,children:l.name},l.slug))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Limit selected events to outputs linked to this entity type."})]}):null,N==="event"?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Run"}),e.jsxs(ie,{value:M,onValueChange:l=>{const v=l,F=Qe(v,ne);ge(v),Z(F),ae($e(v,F,J))},children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:"turn",children:"Start a run for each event"}),e.jsx(D,{value:"window",children:"Batch events into a window"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"When busy"}),e.jsxs(ie,{value:J,onValueChange:l=>ae(l),children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:"queue",children:"Queue"}),e.jsx(D,{value:"coalesce",children:"Combine waiting events"}),!b&&M==="turn"&&ne==="reply_to_source"&&ye?.capabilities?.steering?e.jsx(D,{value:"steer",children:"Update the current run"}):null]})]})]})]}):null,M==="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:Se,onCheckedChange:Fe})]}):null,N==="event"&&!b&&M==="turn"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Result"}),e.jsxs(ie,{value:ne,onValueChange:l=>{const v=l;Z(v),ae($e(M,v,J))},children:[e.jsx(re,{children:e.jsx(ce,{})}),e.jsxs(le,{children:[ye?.capabilities?.replyToSource?e.jsx(D,{value:"reply_to_source",children:"Reply where it happened"}):null,e.jsx(D,{value:"silent",children:"Save in Lobu"})]})]}),ye?.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 Nn=16;function qe(){return crypto.randomUUID()}function kn(n){return n===void 0?[{key:qe(),initial:void 0}]:n.length===0?[{key:qe(),initial:null}]:n.map(t=>({key:qe(),initial:t}))}function ns(n){return n?n.kind==="time"||n.trigger?.kind==="schedule":!1}function bn(n,t){return n?n.ready===t.ready&&n.kind===t.kind&&JSON.stringify(n.trigger)===JSON.stringify(t.trigger):!1}function Sn(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(ns).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 r=i.useId(),[d,u]=i.useState(()=>kn(t)),[c,a]=i.useState({}),x=i.useRef("");i.useEffect(()=>{const h=Sn(d,c),j=JSON.stringify(h);j!==x.current&&(x.current=j,s(h))},[d,c,s]);const m=d.find(h=>ns(c[h.key]))?.key??d.find(h=>h.initial&&typeof h.initial=="object"&&h.initial.kind==="schedule"&&!c[h.key])?.key??null,S=i.useCallback((h,j)=>{a(y=>bn(y[h],j)?y:{...y,[h]:j})},[]),f=()=>{const h=d[0],j=h?c[h.key]:void 0;if(d.length===1&&(j?.kind==="manual"||h?.initial===null)){const y=qe();a({}),u([{key:y,initial:void 0}]);return}u(y=>[...y,{key:qe(),initial:void 0}])},I=h=>{if(d.length<=1){const j=qe();a({}),u([{key:j,initial:null}]);return}a(j=>{const y={...j};return delete y[h],y}),u(j=>j.filter(y=>y.key!==h))};return e.jsxs("section",{className:"space-y-4","aria-labelledby":`${r}-heading`,children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{id:`${r}-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((h,j)=>{const y=d.length>1,w=y?m&&m!==h.key?["event"]:["event","time"]:["event","time","manual"],P=c[h.key],_=y||(P?P.kind!=="manual":h.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(Q,{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(h.key),children:e.jsx(ts,{className:"h-3.5 w-3.5"})}):null]}),e.jsx(wn,{slotKey:h.key,organizationId:n,initial:h.initial,kinds:w,fieldIdPrefix:`${r}-${h.key}-`,onChange:S})]},h.key)})}),e.jsxs(Q,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:f,disabled:d.length>=Nn,children:[e.jsx(Je,{className:"mr-1.5 h-3.5 w-3.5"}),"Add another trigger"]})]})}function wn({slotKey:n,organizationId:t,initial:s,kinds:r,fieldIdPrefix:d,onChange:u}){const c=i.useCallback(a=>u(n,a),[u,n]);return e.jsx(_n,{organizationId:t,initialTrigger:s,allowedKinds:r,showSectionHeader:!1,fieldIdPrefix:d,onChange:c})}const Cn=["claude-code","codex","opencode","pi","agy"],En={"claude-code":"Claude Code",codex:"Codex",opencode:"OpenCode",pi:"Pi",agy:"Antigravity (agy)"},Fn=[{kind:"claude-code",binaryName:"claude",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"claude-config-file",flag:"--mcp-config",extraArgs:["--strict-mcp-config","--allowedTools","mcp__lobu__query_sdk,mcp__lobu__run_sdk"]},headlessArgs:[],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:"--permission-mode",budgetFlag:"--max-budget-usd",timeoutFlag:null,trailingArgs:[]},{kind:"agy",binaryName:"agy",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"none"},headlessArgs:["--dangerously-skip-permissions"],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:{flag:"--print-timeout",suffix:"s"},trailingArgs:[]},{kind:"opencode",binaryName:"opencode",promptDelivery:{kind:"positional",subcommand:["run"]},mcpDelivery:{kind:"opencode-config-env",variable:"OPENCODE_CONFIG_CONTENT"},headlessArgs:["--auto","--print-logs","--log-level","ERROR"],modelFlag:"-m",effortFlag:"--variant",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"codex",binaryName:"codex",promptDelivery:{kind:"positional",subcommand:["exec"]},mcpDelivery:{kind:"none"},headlessArgs:["--skip-git-repo-check","--sandbox","workspace-write","-c","sandbox_workspace_write.network_access=true"],modelFlag:"-m",effortFlag:"-c",effortConfigKey:"model_reasoning_effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"pi",binaryName:"pi",promptDelivery:{kind:"positional",subcommand:[]},mcpDelivery:{kind:"none"},headlessArgs:["-p","--no-session","--tools","read,bash,edit,write"],modelFlag:"--model",effortFlag:"--thinking",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]}];new Map(Fn.map(n=>[n.kind,n]));const It={agents:!0,lobuEmbedded:!1};function An(){const{data:n}=Ss({queryKey:["features"],queryFn:async()=>{const t=await ws(`${Cs}/api/features`);return t.ok?t.json():It},staleTime:3e4,refetchInterval:6e4});return n??It}const qt=["slack","imessage"],ut="__none__";function Ge(n){return`${n.connection_id}:${n.feed_key}`}function On(n){const t=n.indexOf(":");if(t<=0)return null;const s=Number(n.slice(0,t)),r=n.slice(t+1);return!Number.isSafeInteger(s)||s<=0||!r?null:{connection_id:s,channel_id:r}}function mt(n){return n?`${n.connection_id}:${n.channel_id}`:""}function et(n){return`${n.display_name||n.feed_key} (${n.feed_key})`}function Tn({organizationId:n,agentId:t,value:s,onChange:r,disabled:d=!1,automationName:u,onPendingChange:c}){const{data:a=[],isLoading:x}=Es(n),m=mt(s),[S,f]=i.useState(null),[I,h]=i.useState(!1),j=i.useRef(t),y=i.useMemo(()=>a.filter(g=>g.store==="channel_messages"&&g.target_agent_id===t&&qt.includes(g.connector_key)),[a,t]);i.useEffect(()=>{if(j.current===t||(j.current=t,f(null),h(!1),s==null))return;const g=mt(s);if(g==="")return;a.some(se=>se.store==="channel_messages"&&se.target_agent_id===t&&qt.includes(se.connector_key)&&Ge(se)===g)||r(null)},[t,a,s,r]);const w=S??m,P=w===""?ut:w,_=y.find(g=>Ge(g)===w),q=S!==null&&S!==""&&S!==m;i.useEffect(()=>{c?.(q)},[q,c]);const N=_??(S?void 0:y.find(g=>Ge(g)===m)),K=g=>{const G=g===ut?"":g;if(G===""){f(null),h(!1),r(null);return}if(G===m){f(null),h(!1);return}f(G),h(!1)},X=g=>{if(h(g),g&&S){const G=On(S);G&&(f(null),r(G))}else!g&&S&&f(null)},b=(s&&mt(s)!==""?s:void 0)??(_?{connection_id:_.connection_id,channel_id:_.feed_key}:void 0),C=(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:P,onValueChange:K,disabled:d||x,children:[e.jsx(re,{id:"automation-delivery-target",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:x?"Loading bound channels…":y.length===0?"No bound Slack or iMessage channels":"No digest — runs stay silent"})}),e.jsxs(le,{children:[e.jsx(D,{value:ut,children:"No digest — runs stay silent"}),y.map(g=>e.jsxs(D,{value:Ge(g),children:[et(g)," · ",g.connector_key]},Ge(g)))]})]}):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&&!x&&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,q&&_?e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:I,onChange:g=>X(g.target.checked),className:"mt-0.5","aria-label":`Confirm digest delivery to ${et(_)}`}),e.jsxs("span",{className:"text-muted-foreground",children:["I confirm posting material-change digests to"," ",e.jsx("span",{className:"font-medium text-foreground",children:et(_)}),". Destination changes are audited."]})]}):null,N||b?e.jsxs("div",{className:R(Ie,"space-y-1.5 px-3 py-2"),children:[e.jsxs("p",{className:"text-xs font-medium",children:["Digest preview →"," ",e.jsx("span",{className:"font-mono font-normal",children:N?`${N.connector_key} ${et(N)} · connection ${N.connection_id}`:`${b?.channel_id} · connection ${b?.connection_id}`})]}),e.jsxs("p",{className:"font-mono text-xs",children:[C," 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 Kt=4096;function Mn({open:n,onOpenChange:t,initial:s,onSubmit:r}){const[d,u]=i.useState(""),[c,a]=i.useState(""),[x,m]=i.useState(null);i.useEffect(()=>{n&&(u(s?.name??""),a(s?.query??""),m(null))},[n,s]);const S=()=>{const I=d.trim(),h=c.trim();if(!I){m("Give the SQL source a name.");return}if(!h){m("Enter a query.");return}if(h.length>Kt){m(`Query is too long (${h.length} chars, max ${Kt}).`);return}r({name:I,query:h}),t(!1)},f=!!s;return e.jsx(Fs,{open:n,onOpenChange:t,children:e.jsxs(As,{className:"max-w-2xl",children:[e.jsxs(Os,{children:[e.jsx(Ts,{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:c,onChange:a,language:"sql",placeholder:"SELECT id, payload_text, occurred_at FROM events ORDER BY occurred_at DESC",minHeight:"160px"})]}),x?e.jsx("p",{className:"text-sm text-destructive",children:x}):null]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(Q,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(Q,{onClick:S,children:f?"Save":"Add source"})]})]})})}const Dn=["skill","feed","connection","connector","metric","entity_type"];function Pn({value:n,onChange:t,library:s,pinned:r,required:d,error:u,owner:c,agentId:a,sources:x,onAddSources:m}){const S=rn(Dn,Ot,{skills:s,skillAgentId:a||null}),f=i.useRef(null),[I,h]=i.useState(null),j=i.useMemo(()=>{if(!x)return[];const _=new Set(x.map(q=>q.query.trim()));return Tt(n).filter(q=>!_.has(q.query.trim()))},[n,x]),y=cn(n),w=ln(r.filter(_=>y.includes(_.name)),s),P=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,"/",Ot," skills"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-background focus-within:ring-1 focus-within:ring-ring",children:e.jsx(dn,{value:n,onChange:t,onSubmit:()=>{},submitOnEnter:!1,searchRefs:S,handleRef:f,onSqlRequest:()=>h({}),onSqlEdit:(_,q)=>h({initial:_,pos:q}),placeholder:P?"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:_=>{_||h(null)},initial:I?.initial,onSubmit:_=>{f.current?.insertSql(_,I?.pos),h(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(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>m(Tt(n,x)),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 q=w.includes(_),N=!s.some(K=>K.name===_);return e.jsxs(Ds,{variant:N?"destructive":"secondary",className:"font-normal",children:[_,N?" · unavailable":q?" · 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,!P&&a?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This agent has no skills yet."," ",e.jsx(Ps,{to:"/$owner/agents/$agentId/skills",params:{owner:c,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:P?"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 Ln=["connection","connector","feed","metric","entity_type"];function Rn({sources:n,onChange:t,disabled:s}){const{currentOwner:r,resolvedOrganizationId:d}=ss(),[u,c]=i.useState(""),{refs:a}=un({owner:r,organizationId:d,kinds:Ln,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(x=>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:x.name}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:x.query})]}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${x.name}`,disabled:s,onClick:()=>t(n.filter(m=>m.query!==x.query)),children:e.jsx(Yt,{className:"h-3.5 w-3.5"})})]},x.query))}):null,e.jsx("div",{className:"flex gap-2",children:e.jsx(st,{searchPlaceholder:"Search feeds, connections, metrics…",emptyText:"No matching reference.",onQueryChange:c,trigger:()=>e.jsxs(Q,{type:"button",variant:"outline",size:"sm",disabled:s,children:[e.jsx(Je,{className:"mr-2 h-3.5 w-3.5"}),"Add source"]}),children:x=>a.map(m=>e.jsxs(Ke,{value:`${m.label} ${m.kind}`,onSelect:()=>{t(mn(m,n)),x()},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:r}){const{data:d=[]}=Ls(n),u=nn(d),c=u.find(a=>a.id===t);return e.jsx(st,{contentClassName:"w-[300px]",searchPlaceholder:"Search entities...",emptyText:"No entities found.",trigger:a=>e.jsxs(Q,{variant:"outline",role:"combobox","aria-expanded":a,className:R("w-full justify-between",r),children:[c?`${c.name} (${c.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(Ke,{value:"all workspace",onSelect:()=>{s(void 0),a()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",t===void 0?"opacity-100":"opacity-0")}),e.jsx("span",{children:"All workspace"})]}),u.map(x=>e.jsxs(Ke,{value:`${x.name} ${x.entityType}`,onSelect:()=>{s(x.id),a()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",t===x.id?"opacity-100":"opacity-0")}),e.jsxs("span",{children:[x.name," ",e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",x.entityType,")"]})]})]},x.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=Cn.map(n=>({value:n,label:En[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 Bt(n){const t=!!(n?.prompt?.trim()||n?.skills?.some(r=>r.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 zt=0;function Wn(){return zt+=1,`field-${zt}`}function as(n={}){return{id:Wn(),name:n.name??"",type:n.type??"text",role:n.role??"plain"}}function He(n){return n.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")}function Bn(n){return n?Object.keys(n).every(t=>["entity_type","entity_path","key_fields","key_output_field"].includes(t)):!0}function Vt(n){return n?Bn(n.keying_config)?"fields":"json":"fields"}function Ut(n){const t=n?.keying_config?.entity_type;return typeof t=="string"?t:""}function Qt(n){const t=n?.keying_config?.entity_path;return typeof t=="string"&&t.trim()?t:"$"}function Gt(n){const t=new Map,s=Array.isArray(n?.keying_config?.key_fields)?n?.keying_config?.key_fields:[];for(const r of s){if(typeof r!="string")continue;const d=He(r);d&&t.set(d,as({name:d,role:"key"}))}return Array.from(t.values())}function _e(n,t){const s=n?.execution_config?.[t];return typeof s=="number"||typeof s=="string"?String(s):""}function Jt(n,t,s){const r=n?.execution_config?.[t];return typeof r=="string"&&s.includes(r)?r:""}function xt(n,t){const s=n.trim();if(!s)return{};const r=Number(s);return Number.isFinite(r)?{value:r}:{error:`${t} must be a number.`}}function Ht({entityType:n,entityPath:t,fields:s}){const d=s.map(a=>({...a,name:He(a.name)})).filter(a=>a.name).filter(a=>a.role==="key").map(a=>a.name),u=He(n),c=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:c,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:r,isSubmitting:d,error:u,isEditing:c,onCancel:a,triggerFields:x,submitLabel:m="Create Automation",submitDisabled:S=!1,triggers:f}){const{lobuEmbedded:I}=An(),{currentOwner:h}=ss(),{data:j=[]}=Rs(),{data:y=[]}=$s(),[w,P]=i.useState(s?.managed_agent_id??""),_=!!s?.managed_agent_id&&!c,[q,N]=i.useState(s?.delivery_target??null),[K,X]=i.useState(!1),[te,b]=i.useState(s?.device_worker_id??""),[C,g]=i.useState(s?.device_worker_id?"device":"agent"),[G,se]=i.useState(s?.agent_kind??""),{data:$=[]}=Zt({organizationId:n}),[V,Y]=i.useState(s?.name??""),[he,xe]=i.useState(s?.slug??""),[ke,be]=i.useState(!!s?.slug),[M,ge]=i.useState(s?.description??""),[ne,Z]=i.useState(s?.prompt??""),[J,ae]=i.useState(!1),Se=s?.skills??[],[Fe,we]=i.useState(s?.sources??[]),[p,W]=i.useState(s?.entity_id??t),[H,pe]=i.useState(s?.reaction_script??""),[E,Ae]=i.useState(()=>Bt(s)),[ve,Oe]=i.useState(s?.keying_config?JSON.stringify(s.keying_config,null,2):""),[de,B]=i.useState(null),[ye,Me]=i.useState(()=>Vt(s)),[Te,ue]=i.useState(()=>Ut(s)),[De,We]=i.useState(()=>Qt(s)),[fe,me]=i.useState(()=>Gt(s)),[Be,Pe]=i.useState(s?.reactions_guidance??""),[nt,Ce]=i.useState(()=>_e(s,"timeout_seconds")),[at,ot]=i.useState(()=>_e(s,"max_budget_usd")),[ze,Xe]=i.useState(()=>_e(s,"model")),[Ve,it]=i.useState(()=>Jt(s,"permission_mode",ht.map(o=>o.value))),[Le,l]=i.useState(()=>_e(s,"effort")),[v,F]=i.useState(()=>_e(s,"finalize_nudges")),[ee,T]=i.useState(null),[je,A]=i.useState(vt(s?.tags).join(", ")),[Re,Ue]=i.useState(""),[rt,jt]=i.useState(!!(c||Xt(s)));i.useEffect(()=>{s&&(Y(s.name??""),xe(s.slug??""),be(!!s.slug),ge(s.description??""),Z(s.prompt??""),ae(!1),we(s.sources??[]),W(s.entity_id??t),b(s.device_worker_id??""),g(s.device_worker_id?"device":"agent"),se(s.agent_kind??""),pe(s.reaction_script??""),Ae(Bt(s)),Oe(s.keying_config?JSON.stringify(s.keying_config,null,2):""),B(null),Me(Vt(s)),ue(Ut(s)),We(Qt(s)),me(Gt(s)),Pe(s.reactions_guidance??""),Ce(_e(s,"timeout_seconds")),ot(_e(s,"max_budget_usd")),Xe(_e(s,"model")),it(Jt(s,"permission_mode",ht.map(o=>o.value))),l(_e(s,"effort")),F(_e(s,"finalize_nudges")),T(null),A(vt(s.tags).join(", ")),Ue(""),P(s.managed_agent_id??""),N(s.delivery_target??null),jt(!!(c||Xt(s))))},[s,t,c]);const os=ke?he:At(V),{data:is}=Is(w||null),{data:rs}=qs(w||null,{enabled:!!w}),ct=on(is??null,rs?.catalog??[]),cs=hn(f),lt=H.trim().length>0,Ye=!c&&E==="code"?"":ne,ls=!c&&E==="agent"?void 0:H.trim()||void 0,_t=(c||E==="code")&<,Nt=xn(Ye,ct,f,_t),ds=J||Ye.trim()!==""?Nt:null,kt=gn(Ye,ct),bt=!c&&E!=="agent",us=C==="device"&&!w.trim(),St=!!V.trim()&&!us&&!Nt&&(!bt||lt)&&!K,ms=cs&&!_t&&kt.length===0,hs=()=>{if(!St)return;let o;if(ye==="fields"){const Ne=Ht({entityType:Te,entityPath:De,fields:fe});if(Ne.error){B(Ne.error);return}o=Ne.keyingConfig,B(null)}else{if(ve.trim())try{const Ne=JSON.parse(ve);if(typeof Ne!="object"||Array.isArray(Ne)){B("Keying config must be a JSON object.");return}o=Ne}catch{B("Invalid JSON. Please check the syntax.");return}B(null)}const O=xt(nt,"Timeout");if(O.error){T(O.error);return}if(O.value!==void 0&&(!Number.isInteger(O.value)||O.value<1)){T("Timeout must be a whole number greater than 0.");return}const z=xt(at,"Budget");if(z.error){T(z.error);return}if(z.value!==void 0&&z.value<0){T("Budget cannot be negative.");return}const L=xt(v,"Finalize nudges");if(L.error){T(L.error);return}if(L.value!==void 0&&(!Number.isInteger(L.value)||L.value<0||L.value>5)){T("Finalize nudges must be a whole number from 0 to 5.");return}const Ee={...O.value!==void 0?{timeout_seconds:O.value}:{},...z.value!==void 0?{max_budget_usd:z.value}:{},...ze.trim()?{model:ze.trim()}:{},...Ve?{permission_mode:Ve}:{},...Le.trim()?{effort:Le.trim()}:{},...L.value!==void 0?{finalize_nudges:L.value}:{}},U=Object.keys(Ee).length>0||c?Ee:void 0;T(null);const xs=je.trim()?je.split(",").map(Ne=>Ne.trim()).filter(Boolean):void 0;r({slug:os,name:V.trim(),description:M.trim()||void 0,prompt:Ye,skills:kt,entity_id:p,sources:Fe,reaction_script:ls,keying_config:o,reactions_guidance:Be.trim()||void 0,execution_config:U,tags:xs,outputs:s?.outputs,change_notes:Re.trim()||void 0,managed_agent_id:C==="manual"?null:w.trim()||null,device_worker_id:C==="device"&&te.trim()||null,agent_kind:C==="device"&&G.trim()||null,delivery_target:q})},wt=e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-reaction",children:["Reaction Script"," ",bt?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),e.jsx(ft,{value:H,onChange:pe,language:"typescript",placeholder:"export default async function reaction(ctx) { ... }",minHeight:"120px"}),c?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:"*"})]}),!c&&e.jsx("button",{type:"button",onClick:()=>be(!ke),className:"text-xs text-muted-foreground hover:text-foreground",children:ke?"Use automatic slug":"Customize slug"})]}),e.jsx(oe,{id:"scratch-name",value:V,onChange:o=>Y(o.target.value),placeholder:"e.g., Escalation signals"}),!c&&ke?e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-slug",children:"Slug"}),e.jsx(oe,{id:"scratch-slug",value:he,onChange:o=>xe(o.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:At(V)||"custom-slug"})]}):null]})}),c?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":E===o.value,onClick:()=>Ae(o.value),className:R("rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors",E===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===E)?.hint})]}),c||E!=="code"?e.jsx(Pn,{value:ne,onChange:o=>{ae(!0),Z(o)},library:ct,pinned:Se,required:ms,error:ds,owner:h??"",agentId:w,sources:c?Fe:void 0,onAddSources:c?we:void 0}):null,!c&&E!=="agent"?wt:null,c?e.jsx(Rn,{sources:Fe,onChange:we,disabled:d}):null,e.jsx("div",{className:"space-y-4",children:x}),e.jsx(Tn,{organizationId:n,agentId:C==="agent"?w.trim():"",value:q,onChange:N,disabled:d,automationName:V,onPendingChange:X}),K?e.jsx("p",{className:"text-xs text-destructive",children:"Confirm the digest destination above before saving — an unconfirmed destination is not sent."}):null,e.jsxs(Q,{type:"button",variant:"ghost",className:"w-full justify-between px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-expanded":rt,"aria-controls":"automation-advanced-settings",onClick:()=>jt(o=>!o),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{className:"h-4 w-4"}),"Advanced settings"]}),e.jsx(es,{className:R("h-4 w-4 transition-transform",rt&&"rotate-180")})]}),e.jsxs("div",{id:"automation-advanced-settings",className:R("space-y-4",!rt&&"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:M,onChange:o=>ge(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:p,onChange:W}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit this automation to one workspace entity."})]}),c?wt: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(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>{if(ye==="fields"){const o=Ht({entityType:Te,entityPath:De,fields:fe});if(o.error){B(o.error);return}Oe(o.keyingConfig?JSON.stringify(o.keyingConfig,null,2):""),Me("json")}else Me("fields");B(null)},children:ye==="fields"?"Edit JSON":"Use fields"})]}),ye==="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(st,{contentClassName:"w-[320px]",searchPlaceholder:"Search or type a new type…",emptyText:"Type a name to create a new entity type.",trigger:o=>e.jsxs(Q,{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",!Te&&"text-muted-foreground"),children:Te||"Select entity type"}),e.jsx(yt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(o,O)=>{const z=He(O),L=$.filter(U=>!U.backing_sql),Ee=L.some(U=>U.slug===z);return e.jsxs(e.Fragment,{children:[L.map(U=>e.jsxs(Ke,{value:`${U.name??U.slug} ${U.slug}`,onSelect:()=>{ue(U.slug),B(null),o()},className:"cursor-pointer",children:[e.jsx(tt,{className:R("mr-2 h-4 w-4",Te===U.slug?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-mono text-sm",children:U.slug}),U.name&&U.name!==U.slug&&e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:U.name})]})]},U.slug)),z&&!Ee&&e.jsxs(Ke,{value:O,onSelect:()=>{ue(z),B(null),o()},className:"cursor-pointer",children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"text-sm",children:["Create"," ",e.jsx("span",{className:"font-mono",children:z})]})]})]})}})]}),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:De,onChange:o=>{We(o.target.value),B(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(Q,{type:"button",variant:"outline",size:"sm",onClick:()=>{me(o=>[...o,as()]),B(null)},children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"Add field"]})]}),fe.length===0?e.jsx("div",{className:R(Ie,"px-3 py-2 text-sm text-muted-foreground"),children:"No output fields configured."}):e.jsx("div",{className:"space-y-2",children:fe.map(o=>e.jsxs("div",{className:R(Ie,"grid gap-2 p-3 sm:grid-cols-[minmax(0,1fr)_128px_minmax(0,240px)_auto]"),children:[e.jsx(oe,{value:o.name,onChange:O=>{const z=He(O.target.value);me(L=>L.map(Ee=>Ee.id===o.id?{...Ee,name:z}:Ee)),B(null)},placeholder:"severity","aria-label":"Output field name",className:"font-mono text-sm"}),e.jsxs(ie,{value:o.type,onValueChange:O=>{me(z=>z.map(L=>L.id===o.id?{...L,type:O}:L))},children:[e.jsx(re,{"aria-label":"Output field type",children:e.jsx(ce,{})}),e.jsx(le,{children:qn.map(O=>e.jsx(D,{value:O,children:O},O))})]}),e.jsx("div",{className:"grid grid-cols-2 rounded-md border border-input bg-background p-1",children:Kn.map(O=>e.jsx("button",{type:"button",onClick:()=>{me(z=>z.map(L=>L.id===o.id?{...L,role:O.value}:L)),B(null)},className:R("rounded-sm px-2 py-1 text-xs transition-colors",o.role===O.value?"bg-muted/70 text-foreground":"text-muted-foreground hover:text-foreground"),children:O.label},O.value))}),e.jsx(Q,{type:"button",variant:"ghost",size:"icon",onClick:()=>{me(O=>O.filter(z=>z.id!==o.id)),B(null)},"aria-label":"Remove output field",children:e.jsx(ts,{className:"h-4 w-4"})})]},o.id))})]}),de&&e.jsx("p",{className:"text-xs text-destructive",children:de})]}):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:ve,onChange:o=>{Oe(o),B(null)},language:"json",placeholder:'{ "entity_type": "topic", "entity_path": "$.items[*]", "key_fields": ["name"], "key_output_field": "entity_key" }',minHeight:"60px"}),de&&e.jsx("p",{className:"text-xs text-destructive",children:de})]})})]}),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:Be,onChange:o=>Pe(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:C,onValueChange:o=>g(o),children:[e.jsx(re,{id:"scratch-runs-on",className:"text-sm",children:e.jsx(ce,{})}),e.jsxs(le,{children:[e.jsx(D,{value:"agent",children:"Managed agent"}),e.jsx(D,{value:"device",children:"On a device"}),e.jsx(D,{value:"manual",children:"Manual-only"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C==="agent"?"Automated runs dispatch to a managed Lobu agent.":C==="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."})]}),!_&&C!=="manual"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(k,{htmlFor:"scratch-agent-id",children:["Agent",C==="device"&&e.jsx("span",{className:"text-destructive",children:" *"})]}),I?e.jsxs(ie,{value:w||"__unselected__",onValueChange:o=>{P(o==="__unselected__"?"":o)},children:[e.jsx(re,{id:"scratch-agent-id",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:"Select a Lobu agent"})}),e.jsx(le,{children:j.map(o=>e.jsxs(D,{value:o.agentId,children:[o.name," (",o.agentId,")"]},o.agentId))})]}):e.jsx(oe,{id:"scratch-agent-id",value:w,onChange:o=>{P(o.target.value)},placeholder:"e.g., agent-123",className:"font-mono text-sm"}),C==="device"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"The device run uses this agent's memory and tools, acting as the agent's owner."})]}),!_&&C==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-id",children:"Device"}),e.jsxs(ie,{value:te||"__unselected__",onValueChange:o=>b(o==="__unselected__"?"":o),children:[e.jsx(re,{id:"scratch-device-id",className:"font-mono text-sm",children:e.jsx(ce,{placeholder:"Select a device worker"})}),e.jsx(le,{children:y.map(o=>e.jsx(D,{value:o.id,children:o.label||o.platform||o.id},o.id))})]})]}),!_&&C==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-device-agent-kind",children:"Runs as"}),e.jsxs(ie,{value:G||"__default__",onValueChange:o=>se(o==="__default__"?"":o),children:[e.jsx(re,{id:"scratch-device-agent-kind",className:"text-sm",children:e.jsx(ce,{placeholder:"Device default"})}),e.jsxs(le,{children:[e.jsx(D,{value:"__default__",children:"Device default"}),In.map(o=>e.jsx(D,{value:o.value,children:o.label},o.value))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Device default uses that device's preferred local agent. Availability is checked again when a run is claimed, so a run stays queued if its selected runtime is no longer available."})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{children:"Model"}),e.jsx(an,{value:ze,onChange:o=>{Xe(o),T(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:nt,onChange:o=>{Ce(o.target.value),T(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:Ve||"__default__",onValueChange:o=>{it(o==="__default__"?"":o),T(null)},children:[e.jsx(re,{id:"scratch-permission-mode",children:e.jsx(ce,{placeholder:"Default"})}),e.jsxs(le,{children:[e.jsx(D,{value:"__default__",children:"Default"}),ht.map(o=>e.jsx(D,{value:o.value,children:o.label},o.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(k,{htmlFor:"scratch-effort",children:"Effort"}),e.jsx(oe,{id:"scratch-effort",value:Le,onChange:o=>{l(o.target.value),T(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:v,onChange:o=>{F(o.target.value),T(null)},placeholder:"Default"})]})]}),ee&&e.jsx("p",{className:"text-xs text-destructive",children:ee})]}),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:je,onChange:o=>A(o.target.value),placeholder:"ops, support, risk"})]}),c&&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:Re,onChange:o=>Ue(o.target.value),placeholder:"What changed in this version?"})]})]})]}),u&&!de&&!ee&&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(Q,{onClick:hs,disabled:!St||d||S,children:d?e.jsxs(e.Fragment,{children:[e.jsx(Bs,{size:"lg",className:"mr-2"}),c?"Saving...":"Creating..."]}):c?"Save Automation":m})})]})}function Un(n,t){const s=n??null,r=t??null;return s===null||r===null?s===r:s.connection_id===r.connection_id&&s.channel_id===r.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:r=!1,organizationId:d,entityId:u,entityName:c,prefillAgentId:a,onSuccess:x,editingAutomation:m,catalogPrefill:S,onDraft:f,triggerFields:I,submitLabel:h,submitDisabled:j,createFields:y,onPrefillTriggers:w}){const P=zs(),_=Vs(),q=Us(),N=Qs(),K=!!m,[X,te]=i.useState(n?"scratch":"template"),[b,C]=i.useState(void 0),[g,G]=i.useState(void 0),{data:se=[],isLoading:$}=Gs(),[V,Y]=i.useState(""),he=i.useMemo(()=>a?{managed_agent_id:a}:void 0,[a]),xe=i.useMemo(()=>se.map(p=>({key:p.id,name:p.name,description:p.description??"",badges:p.detail?.tags??[]})),[se]),ke=i.useMemo(()=>xe.filter(p=>p.name.toLowerCase().includes(V.toLowerCase())||p.description.toLowerCase().includes(V.toLowerCase())),[xe,V]),be=p=>{const W=se.find(pe=>pe.id===p.key);if(!W)return;const H=Qn(W);G(a?{...H,managed_agent_id:a}:H),w?.(H.triggers??[]),te("scratch")},M=()=>{P.reset(),_.reset(),te("template"),C(void 0),G(void 0),t()},ge=K?y?.triggers??m.triggers??[]:y?.triggers??g?.triggers??S?.triggers??[],ne=async p=>{try{if(f){await f(p);return}if(K){const W=y?.triggers??m.triggers??[],H=m.reaction_script??"",pe=p.reaction_script??"";pe&&pe!==H&&await q.mutateAsync({automation_id:m.automation_id,reaction_script:pe}),await _.mutateAsync({automation_id:m.automation_id,name:p.name,description:p.description,prompt:p.prompt,sources:p.sources,set_as_current:!0,triggers:W,keying_config:p.keying_config,reactions_guidance:p.reactions_guidance,change_notes:p.change_notes}),!pe&&H&&await q.mutateAsync({automation_id:m.automation_id,reaction_script:""});const E={};p.model_config!==void 0&&(E.model_config=p.model_config),p.execution_config!==void 0&&(E.execution_config=p.execution_config),p.tags!==void 0&&(E.tags=p.tags),p.delivery_target!==void 0&&!Un(p.delivery_target,m.delivery_target)&&(E.delivery_target=p.delivery_target),p.managed_agent_id!==void 0&&(E.managed_agent_id=p.managed_agent_id||null),p.agent_kind!==void 0&&(E.agent_kind=p.agent_kind||null),p.device_worker_id!==void 0&&(E.device_worker_id=p.device_worker_id||null),Object.keys(E).length>0&&await N.mutateAsync({automation_id:m.automation_id,...E}),M(),x?.(m.automation_id)}else{const W=y?.triggers??g?.triggers??S?.triggers??[],H=await P.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:W});M(),H.automation_id&&x?.(H.automation_id)}}catch{}},Z=K?_:P;let J="Add an automation";K?J="Edit automation configuration (saves as a new version)":c&&(J=`Add an automation for ${c}`);const ae=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,Se=K?"Edit Automation":"Create Automation",Fe=e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:Se}),e.jsx("p",{className:"text-sm text-muted-foreground",children:J})]}),we=e.jsxs("div",{className:"py-6 space-y-6",children:[!K&&e.jsxs("div",{className:"flex flex-wrap justify-start gap-2",children:[e.jsx(gt,{active:X==="template",onClick:()=>te("template"),icon:e.jsx(Js,{className:"h-4 w-4"}),label:"From templates"}),e.jsx(gt,{active:X==="scratch",onClick:()=>{te("scratch"),C(void 0),G(void 0)},icon:e.jsx(Je,{className:"h-4 w-4"}),label:"From scratch"}),e.jsx(gt,{active:X==="clone",onClick:()=>te("clone"),icon:e.jsx(Hs,{className:"h-4 w-4"}),label:"Clone existing"})]}),!K&&X==="template"?e.jsxs(e.Fragment,{children:[$?e.jsx(Xs,{}):e.jsx(Ys,{items:ke,searchQuery:V,onSearchChange:Y,onSelect:be,searchPlaceholder:"Search templates...",searchAriaLabel:"Search automation templates",emptyMessage:xe.length===0?"No automation templates available.":void 0}),r&&!s?e.jsx(pt,{onCancel:M}):null]}):!K&&X==="clone"&&!b?e.jsxs(e.Fragment,{children:[e.jsx(Gn,{organizationId:d,onSelect:p=>{C(p),w?.(p.triggers??[]),te("scratch")}}),r&&!s?e.jsx(pt,{onCancel:M}):null]}):e.jsx(Vn,{organizationId:d,entityId:u,prefill:ae??b??g??S??he,onSubmit:ne,isSubmitting:Z.isPending,error:Z.error?Z.error.message:null,isEditing:K,onCancel:s?void 0:M,triggerFields:I,submitLabel:h,submitDisabled:j,triggers:ge})]});return e.jsxs("div",{className:"flex flex-col",children:[r?null:Fe,we]})}function gt({active:n,onClick:t,icon:s,label:r}){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,r]})}function Gn({organizationId:n,onSelect:t}){const{data:s,isLoading:r}=Zs(n),[d,u]=i.useState(""),c=(s||[]).filter(a=>a.name?.toLowerCase().includes(d.toLowerCase()));return r?e.jsx(en,{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:[c.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)),c.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-Bpy92SM5.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{cx as r,h6 as l,W as i,dD as u,ch as c,J as d}from"./index-9YuSRymd.js";function o(e,n=""){return`${d}/api/${e}/deployments${n}`}const y=50;function f(e){const{slug:n}=r();return l({queryKey:["deployments-feed",n,e?.resourceKind,e?.resourceId],queryFn:async({pageParam:t})=>{const a=new URLSearchParams({limit:String(y)});t!==null&&a.set("before_id",String(t)),e&&(a.set("resource_kind",e.resourceKind),a.set("resource_id",e.resourceId));const s=await i(o(n,`?${a.toString()}`),{credentials:"include"});return s.status===404?{items:[],has_more:!1}:(await u(s,"Failed to fetch deployments"),await s.json())},initialPageParam:null,getNextPageParam:t=>t.has_more?t.items[t.items.length-1]?.id:void 0,enabled:!!n,staleTime:15e3,retry:!1})}function h(e){const{slug:n}=r();return c({queryKey:["deployment-detail",n,e],queryFn:async()=>{const t=await i(o(n,`/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch deployment"),await t.json())},enabled:!!n&&!!e,staleTime:15e3,retry:!1})}function g(e){const{slug:n}=r();return c({queryKey:["deployment-change-detail",n,e],queryFn:async()=>{const t=await i(o(n,`/changes/${e}`),{credentials:"include"});return t.status===404?null:(await u(t,"Failed to fetch change"),(await t.json()).change)},enabled:!!n&&!!e,staleTime:15e3,retry:!1})}export{g as a,h as b,f as u};
|
|
2
|
-
//# sourceMappingURL=deployments-C5hvipQh.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as a,bz as x,bM as p,aR as m,hn as o,B as f,bd as c,L as i,ho as h,P as r}from"./index-9YuSRymd.js";import{u as g}from"./deployments-C5hvipQh.js";function y(e){return e==="partial_failure"?a.jsx(r,{variant:"destructive",children:"Partial failure"}):e==="succeeded"?a.jsx(r,{variant:"secondary",children:"Succeeded"}):null}function j(e){switch(e){case"created":return a.jsx(r,{variant:"default",children:"Created"});case"updated":return a.jsx(r,{variant:"secondary",children:"Updated"});case"deleted":return a.jsx(r,{variant:"destructive",children:"Deleted"});default:return null}}function N(e){if(!e)return null;const t=[e.create?`${e.create} created`:null,e.update?`${e.update} updated`:null,e.delete?`${e.delete} deleted`:null].filter(n=>n!==null);return t.length>0?t.join(" · "):"no changes"}const u="flex items-start gap-3 px-3 py-2.5 transition-colors hover:bg-accent/50";function B({owner:e}){const t=g(),n=t.data?.pages.flatMap(s=>s.items)??[];return t.isLoading?a.jsx("div",{className:"max-w-3xl",children:a.jsx(x,{label:"deployments"})}):t.isError?a.jsx(p,{label:"deployments"}):n.length===0?a.jsx(m,{icon:o,title:"No deployments yet",description:"lobu apply runs and settings edits will appear here as an audit trail."}):a.jsxs("div",{className:"max-w-3xl space-y-3",children:[a.jsx("div",{className:"overflow-hidden rounded-lg border",children:n.map((s,l)=>{const d=l===n.length-1;return s.type==="deployment"?a.jsx(b,{item:s,owner:e,isLast:d},s.id):a.jsx(v,{item:s,owner:e,isLast:d},s.id)})}),t.hasNextPage?a.jsx(f,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:t.isFetchingNextPage,onClick:()=>t.fetchNextPage(),children:t.isFetchingNextPage?"Loading...":"Load more"}):null]})}function b({item:e,owner:t,isLast:n}){const l=[N(e.counts),e.createdBy?`by ${e.createdBy}`:null,c(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:e.applyId??String(e.id)},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(o,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("span",{className:"truncate text-sm font-medium",children:"Deployment"}),y(e.status),e.gitSha?a.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:e.gitSha.slice(0,7)}):null]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:l})]})]})}function v({item:e,owner:t,isLast:n}){const s=[e.actorSource?`via ${e.actorSource}`:null,e.createdBy?`by ${e.createdBy}`:null,c(e.createdAt)].filter(Boolean).join(" · ");return a.jsxs(i,{to:"/$owner/connectors/deployments/$deploymentId",params:{owner:t,deploymentId:`change-${e.id}`},className:`${u} ${n?"":"border-b"}`,children:[a.jsx(h,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsxs("span",{className:"truncate text-sm font-medium",children:[e.resourceKind??"config",e.resourceId?a.jsxs("span",{className:"text-muted-foreground",children:[" ",e.resourceId]}):null]}),j(e.op)]}),a.jsx("p",{className:"truncate text-[11px] text-muted-foreground",children:s})]})]})}export{B as D,j as c,y as d};
|
|
2
|
-
//# sourceMappingURL=deployments-body-DGII20dQ.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,f4 as f,r as v,it as C,iu as k,hL as y,B as A,L,cT as w,iv as E,iw as I,ix as N,u as P,iy as F,hZ as O}from"./index-9YuSRymd.js";import{a as R,R as S}from"./runs-panel-C0_DNTcq.js";import{c as g,C as $,a as b}from"./connector-scope-lists-CRFEpSvk.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]=v.useState(n);v.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||g(t),j=e.jsx(N,{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(y,{title:h,count:s.feed_count===1?"1 source":`${s.feed_count} sources`,action:g(t)?e.jsx(A,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(L,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:p,connectionId:String(m)},search:{addFeed:!0},children:[e.jsx(w,{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(E,{connection:s,ownerSlug:a}):e.jsx(B,{connection:s,ownerSlug:a}))]}),i?e.jsx(I,{title:"Connection settings",summary:"name, visibility, credentials, remove",open:l,onOpenChange:d,children:j}):j,r&&!u&&e.jsx(y,{title:"Recent activity",children:e.jsx(S,{scope:{connectionId:m},ownerSlug:a})})]})}function B({connection:s,ownerSlug:t}){const a=P(),{data:n=[],isLoading:o,isError:r}=F(s.id),i=n.filter(l=>l.readiness==="scope_upgrade_required").length,c=o?"Loading actions…":r?"Could not load actions — open to retry":`${n.length} actions${i?` · ${i} need additional provider access`:" · permissions and approval policy"}`;return e.jsx(O,{title:"Actions",summary:c,onOpen:()=>a?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectionId:s.id,connectorKey:s.connector_key,organizationId:s.organization_id,ownerSlug:t}})})}const T=new Set(["Device was removed","Device was moved to another workspace"]);function H(s){const t=s.error_message??null;return!t||!T.has(t)?t:!!s.device_worker_id&&(s.device_last_seen_at!=null||s.device_worker_handle!=null||s.device_label!=null)?null:t}export{V as C,M as R,H as c};
|
|
2
|
-
//# sourceMappingURL=device-pin-tombstone-2U0UMu3_.js.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{aJ as U,id as ne,ie as V,r as v,j as e,ig as L,B as b,a2 as z,ih as C,d7 as Y,av as te,hL as I,S as A,aV as B,ef as ae,eg as ie,dF as ce,eh as oe,ii as re,U as le,o as de,aA as me,ij as ue,ik as xe,il as he,aB as pe,aw as fe,aC as P,aU as q,L as E,im as ge,io as je,aP as ve,ip as ye,iq as be,ht as Ne,b8 as ke,g9 as _e,ir as K,I as we,a$ as Ce,b9 as Se,ga as $e,gb as O,bd as De,is as F,ai as Pe}from"./index-9YuSRymd.js";import{c as G,C as Le,R as ze}from"./device-pin-tombstone-2U0UMu3_.js";import{R as Ie}from"./runs-panel-C0_DNTcq.js";import{S as Ae,g as Re}from"./runs-table-B1APZv7d.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as M}from"./workspace-label-o_QfBuCM.js";import"./connector-scope-lists-CRFEpSvk.js";import"./filter-editors-Bwhqj7lY.js";function Me(s,n,o){const h=new Set(s.capabilities??[]),m=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key)),r=new Set(J(s,o).map(t=>t.connector_key));return n.filter(t=>U(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function J(s,n){return s.organization_slug===n?s.update_required:[]}function Be(s,n,o){const h=s.organization_slug;if(!h||h===o)return[];const m=new Set(n.map(t=>t.key)),r=new Set(s.connectors.filter(t=>t.organization_slug===o).map(t=>t.connector_key));return s.connectors.filter(t=>t.organization_slug!==h||m.has(t.connector_key)||r.has(t.connector_key)?!1:(r.add(t.connector_key),!0))}function Te({device:s,organizationId:n,ownerSlug:o,connectable:h,unavailable:m}){const r=ne(),t=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 i=>{p(null),N(null),a(i.key);try{x||await t.mutateAsync({deviceWorkerId:s.id,organizationId:n});const w=await r.mutateAsync({connector_key:i.key,device_worker_id:s.id}),S=w.connection_id??w.connection?.id;if(S===void 0)throw new Error(w.instructions??"The connection was not created.");d($=>[...$.filter(D=>D.connectorKey!==i.key),{connectorKey:i.key,name:i.name,connectionId:S,instructions:w.status==="setup_required"?w.instructions:void 0}])}catch(w){N({key:i.key,message:w instanceof Error?w.message:"Could not connect."})}finally{a(null)}},k=new Set(j.map(i=>i.connectorKey)),l=J(s,o),c=h.filter(i=>!k.has(i.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[j.map(i=>e.jsx(qe,{outcome:i,device:s,organizationId:n},i.connectorKey)),c.length>0?e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium",children:"Supported by this device"}),e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:["Not connected in this workspace yet.",x?null:" Connecting one moves the device here; you will be asked to confirm first."]}),e.jsx("div",{className:"divide-y border-y",children:c.map(i=>e.jsxs("div",{className:"space-y-2 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"min-w-0 flex-1 text-sm font-medium",children:[i.name,i.required_capability&&L[i.required_capability]&&L[i.required_capability]!==i.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:L[i.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${i.name}`,disabled:g!==null,onClick:()=>x?void y(i):p(i.key),children:[g===i.key?e.jsx(z,{className:"mr-1.5"}):null,"Connect"]})]}),u===i.key?e.jsx(Q,{device:s,ownerSlug:o,title:"Move device to this workspace",intro:`${C(s)} lives in ${s.organization_name??"another workspace"}. A device serves one workspace at a time, so it has to move here before it can be connected.`,confirmLabel:"Move here and connect",onConfirm:()=>void y(i),onCancel:()=>p(null)}):null,f?.key===i.key?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:f.message}):null]},i.key))})]}):null,l.length>0?e.jsxs("div",{role:"status",children:[e.jsx("p",{className:"text-xs font-medium",children:"Update Lobu on this device"}),e.jsx("ul",{className:"mt-1 space-y-1 text-xs text-muted-foreground",children:l.map(i=>e.jsx("li",{children:`${i.display_name} — this device has ${i.device_version}, this workspace uses ${i.workspace_version}`},i.connector_key))})]}):null,m.length>0?e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:m.map(i=>e.jsx("li",{children:`${i.display_name} — set up on this device in ${s.organization_name??"its home workspace"}, not available in this workspace yet`},i.connector_key))}):null]})}function Q({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const g=s.connector_count,a=s.connectors.filter(f=>f.organization_slug===n).length;return e.jsxs("div",{role:"alertdialog","aria-label":o,className:"space-y-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs",children:[e.jsx("p",{children:h}),e.jsxs("p",{className:"text-muted-foreground",children:[g>0?`Moving pauses and unpins all ${g} connection${g===1?"":"s"} pinned to it${a>0?`, including ${a} in this workspace`:""}. They stay paused until you reconnect them.`:"It has no pinned connections, so nothing is paused.",m?` ${m}`:null]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(z,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function qe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=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=G(r);u.push(`${s.name} is ${r.status}${p?`: ${p}`:"."}`)}return s.instructions&&u.push(s.instructions),n.online||u.push(`${t} is offline. ${s.name} runs once it reconnects.`),e.jsx("div",{role:"status",className:"rounded-lg border px-3 py-2 text-sm",children:u.length===0?e.jsxs("p",{children:[s.name," is ready on ",t,"."]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"font-medium",children:[s.name," connected, not ready yet"]}),e.jsx("ul",{className:"mt-1 list-disc pl-4 text-xs text-muted-foreground",children:u.map(p=>e.jsx("li",{children:p},p))})]})})}function 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}`,k=a.get(y)??{key:y,name:x.name,connections:[]};k.name=L[y]??x.name,k.connections.push(d),a.set(y,k)}const N=Me(s,r,o),j=Be(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{title:"Capabilities",children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Manage the native connections available to this workspace."}),s.online?null:e.jsx("p",{className:"mb-3 text-sm text-muted-foreground",children:"This device is offline. You can edit its settings; actions and sync need it to reconnect."}),!n||t?e.jsx(A,{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(W,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Te,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:j}):null,B(s)==="macos"?e.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Manage macOS permissions in the Lobu app on this device."}):null]}),n&&f.length>0&&!t&&!u?e.jsxs(I,{title:"Apps and sources",count:String(f.length),children:[e.jsx("p",{className:"mb-3 text-xs text-muted-foreground",children:"Apps and sources that use this device."}),e.jsx("div",{className:"divide-y border-y",children:[...new Set(f.map(d=>d.connector_key))].map(d=>e.jsx(W,{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 W({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(ie,{className:"group flex w-full items-center gap-3 py-3 text-left",children:[e.jsx(ce,{className:"size-3.5 shrink-0 text-muted-foreground transition-transform group-data-[state=open]:rotate-90"}),e.jsx("span",{className:"min-w-0 flex-1 text-sm font-medium",children:s.name}),e.jsx("span",{className:"text-right text-xs text-muted-foreground",children:s.connections.some(a=>a.status==="error"||a.status==="revoked")?"Needs attention":s.connections.length>1?`${s.connections.length} connections`:"Configured"})]}),e.jsx(oe,{className:"pb-4 pl-6",children:e.jsx("div",{className:"space-y-5",children:s.connections.map(a=>e.jsx(Ke,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function Ke({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=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?G(a):null;return e.jsxs("section",{id:`connection-${s.connection_id}`,"aria-label":f,className:"scroll-mt-24",children:[a?e.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(A,{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 Oe({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)},k=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}catch(c){a(c instanceof Error?c.message:"Could not move the device.")}};return e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Workspace: "}),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(Q,{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 k(x.id),onCancel:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function Fe({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,k]=v.useState(""),l=he(t,n),c=l&&pe(l,s)?l:void 0,i=c?.id??n,{data:w=[]}=fe(o,{profileKind:"browser_session"}),S=v.useMemo(()=>w.filter(_=>_.device_worker_id===i&&_.status!=="revoked"),[w,i]),$=c?.label?.trim()??"";if(v.useEffect(()=>{d||k($)},[$,d]),u)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-6 w-6 rounded"}),e.jsx(A,{className:"h-5 w-40"})]}),e.jsx(ze,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]})});if(!c&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{platform:B(l),className:"h-5 w-5"}),e.jsx("h1",{className:"text-base font-semibold",children:C(l)})]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This device lives in"," ",l.organization_name??"another workspace",", not this workspace."]}),e.jsx(H,{device:l,organizationId:o,ownerSlug:s})]});if(!c)return e.jsxs(P,{className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"This device isn't in this workspace, so its details aren't available."}),e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(c),R=D?je(s,D,ve()):void 0,X=B(c),Z=ye(c.app_version),ee=be(c,Z),T=()=>{const _=y.trim(),se=c.label?.trim()??"";if(_===se){x(!1);return}f.mutate({deviceWorkerId:c.id,label:_.length===0?null:_},{onSuccess:()=>x(!1)})};return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(Ne,{header:e.jsx(_e,{breadcrumb:e.jsx($e,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:O,children:"Connectors"},"connectors"),...R?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:R.id},className:O,children:R.name},"app")]:[]]}),icon:e.jsx(q,{platform:X,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(we,{"aria-label":"Device name",value:y,onChange:_=>k(_.target.value),placeholder:C({...c,label:null}),maxLength:80,className:"h-9 max-w-sm text-base font-semibold",autoFocus:!0,onKeyDown:_=>{_.key==="Enter"?(_.preventDefault(),N||T()):_.key==="Escape"&&(j(!1),k(c.label?.trim()??""),x(!1))}}),N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-destructive/10 px-3 py-2",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Forgets this device"," ",c.connector_count>0?`and un-pins ${c.connector_count} connector${c.connector_count===1?"":"s"} across every workspace, not just this one.`:"with no pinned connections."]}),e.jsxs(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(c.id,{onSuccess:()=>{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:T,disabled:f.isPending,children:[f.isPending?e.jsx(z,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{k(c.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>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(c),e.jsx(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{j(!1),k(c.label?.trim()??""),x(!0)},children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]}),badge:e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{className:`size-1.5 rounded-full ${c.online?"bg-emerald-500":"bg-muted-foreground/50"}`}),c.online?c.connector_error_count>0?"Needs attention":"Online":"Offline"]}),meta:ee||void 0,caption:`Last seen ${K(new Date(c.last_seen_at),{addSuffix:!0})}${c.last_sync_at?` · Last sync ${K(new Date(c.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Oe,{device:c,ownerSlug:s}),c.connector_error_count>0?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[e.jsx(ke,{className:"h-3.5 w-3.5 shrink-0"}),c.connector_error_count," connector",c.connector_error_count===1?"":"s"," pinned to this device ",c.connector_error_count===1?"is":"are"," erroring."]}):null,e.jsx(H,{device:c,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:i},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(Ae,{status:n.is_expired?"error":Re(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 Ze(){const{owner:s,deviceId:n}=F.useParams(),{connection:o,settings:h}=F.useSearch();return e.jsx(Pe,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(Fe,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{Ze as component};
|
|
2
|
-
//# sourceMappingURL=device._deviceId-Bn37UpWH.js.map
|