@lobu/runtime-server 24.2.0 → 24.4.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 +24 -2
- package/dist/catalogs/skills.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/gchat.ts +31 -1
- package/dist/connectors/postgres.ts +9 -5
- package/dist/db/migrations/20261101010000_public_source_type_references.sql +157 -0
- package/dist/dependencies.bun.lock +117 -178
- package/dist/owletto/dist/assets/_-DIK0ae_S.js +2 -0
- package/dist/owletto/dist/assets/_-gTbcArpS.js +3 -0
- package/dist/owletto/dist/assets/_agentId-DOmcJZfk.js +2 -0
- package/dist/owletto/dist/assets/_agentId-DW6wRCVC.js +2 -0
- package/dist/owletto/dist/assets/_automationId-B9IcDYBu.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey._connectionId-C6PmMPTA.js +2 -0
- package/dist/owletto/dist/assets/_connectorKey.index-BrJ8Pzze.js +2 -0
- package/dist/owletto/dist/assets/_conversationId-BpJAeYYW.js +2 -0
- package/dist/owletto/dist/assets/_eventId-DarQJo0G.js +2 -0
- package/dist/owletto/dist/assets/_name-DtmNTcUm.js +2 -0
- package/dist/owletto/dist/assets/_owner-Db8at3hk.js +3 -0
- package/dist/owletto/dist/assets/_shape-6iFA8A86.js +2 -0
- package/dist/owletto/dist/assets/_skillKey-CXkHn3Nl.js +2 -0
- package/dist/owletto/dist/assets/{_slug-MHQU8ftJ.js → _slug-DBOuBLoX.js} +2 -2
- package/dist/owletto/dist/assets/_viewKey-DC27aIN9.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-DuYDieln.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-D2T_a2dj.js → accept-invitation-BbDCVvur.js} +2 -2
- package/dist/owletto/dist/assets/activity-route-view-V4ftmSN7.js +2 -0
- package/dist/owletto/dist/assets/{agent-card-controls-ColL5rdd.js → agent-card-controls-99mG6H5k.js} +2 -2
- package/dist/owletto/dist/assets/agent-client-setup-list-kMmqQSrf.js +4 -0
- package/dist/owletto/dist/assets/agent-connect-pages-B-NPTFs6.js +2 -0
- package/dist/owletto/dist/assets/{agent-editor-form-C24p9LLg.js → agent-editor-form-DfMTSIvj.js} +2 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-BvGgfd-h.js +2 -0
- package/dist/owletto/dist/assets/{agent-loading-shells-jkf9DjdO.js → agent-loading-shells-Dnmb6W5Y.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-C8j8kRB1.js → agent-permissions-matrix-CbhXlbgY.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-B9giw2u2.js → agent-skill-context-V__2i6Vl.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skills-route-BMZ3r1bP.js → agent-skills-route-DFXr_bHp.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-D49f-bzP.js → agent-subpage-shell-DWzljvFb.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-BGHYHWDO.js → agent-thread-DQIr20H-.js} +4 -4
- package/dist/owletto/dist/assets/agents-CLbeiqTR.js +2 -0
- package/dist/owletto/dist/assets/agents-workbench-C8bTa2rv.js +2 -0
- package/dist/owletto/dist/assets/app-bridge-C4nPtae3.js +121 -0
- package/dist/owletto/dist/assets/{app._appId-A51tx2jU.js → app._appId-Bsq40nak.js} +2 -2
- package/dist/owletto/dist/assets/{automation-detail-content-DCAZBKle.js → automation-detail-content-C9Cgr5Zj.js} +2 -2
- package/dist/owletto/dist/assets/automations-CLbeiqTR.js +2 -0
- package/dist/owletto/dist/assets/calendar-DMq3Dtqy.js +2 -0
- package/dist/owletto/dist/assets/{callback-WmyCei3R.js → callback-B-CAz-bK.js} +2 -2
- package/dist/owletto/dist/assets/{card-Cspo-4M6.js → card-SFtxv9f2.js} +2 -2
- package/dist/owletto/dist/assets/{claim-CCKdBtFt.js → claim-DrxIRWKt.js} +2 -2
- package/dist/owletto/dist/assets/client-activity-scopes-boZOHuPW.js +2 -0
- package/dist/owletto/dist/assets/client-rows-BJ2PxM4J.js +2 -0
- package/dist/owletto/dist/assets/clients-C7Lnuc3S.js +2 -0
- package/dist/owletto/dist/assets/{code-editor-C8FJbT2P.js → code-editor-rX0t1g5C.js} +2 -2
- package/dist/owletto/dist/assets/connect-BcwgytDV.js +2 -0
- package/dist/owletto/dist/assets/connect-menu-BF-AlunU.js +2 -0
- package/dist/owletto/dist/assets/connect._clientId-sDypRDeN.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId-C9OkW1tv.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.activity-Dc6HYr55.js +2 -0
- package/dist/owletto/dist/assets/connected._clientId.index-C6qbqgwF.js +2 -0
- package/dist/owletto/dist/assets/connection-88YzIBK9.js +2 -0
- package/dist/owletto/dist/assets/connection-feed-detail-D7pnWaFB.js +2 -0
- package/dist/owletto/dist/assets/connections-browser-DDJQh8Na.js +2 -0
- package/dist/owletto/dist/assets/connector-boxes-DDX7Ebc4.js +2 -0
- package/dist/owletto/dist/assets/connector-provenance-Th8ymGec.js +2 -0
- package/dist/owletto/dist/assets/{connector-scope-lists-B44Q9W-j.js → connector-scope-lists-BibdzKl1.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-CTWPDH8f.js → connectors-BqwgLUUK.js} +2 -2
- package/dist/owletto/dist/assets/consent-BR5U7dwb.js +2 -0
- package/dist/owletto/dist/assets/{copy-button-kcjg8Giw.js → copy-button-2swYh4jb.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-CoJ5Splc.js → core.esm-CHnfRiEM.js} +2 -2
- package/dist/owletto/dist/assets/{create-CQE5rD0i.js → create-BsPVnRpG.js} +2 -2
- package/dist/owletto/dist/assets/create-CVPYVOR5.js +2 -0
- package/dist/owletto/dist/assets/create-QFjmhOEU.js +2 -0
- package/dist/owletto/dist/assets/create-automation-form-DmCOFbRT.js +3 -0
- package/dist/owletto/dist/assets/create._connectorKey-DLDDVtLS.js +2 -0
- package/dist/owletto/dist/assets/{cronstrue-CeUS_78Q.js → cronstrue-CKwjNYgj.js} +2 -2
- package/dist/owletto/dist/assets/device-CKup7kvB.js +2 -0
- package/dist/owletto/dist/assets/device-pin-tombstone-xGhCTU5_.js +2 -0
- package/dist/owletto/dist/assets/device._deviceId-B1H_ivDT.js +2 -0
- package/dist/owletto/dist/assets/{entity-avatar-BZIa-7i5.js → entity-avatar-HloBoalJ.js} +2 -2
- package/dist/owletto/dist/assets/entity-options-BSW_EG0W.js +2 -0
- package/dist/owletto/dist/assets/entity-page-D-WDWrAe.js +2 -0
- package/dist/owletto/dist/assets/entity-type-page-BCBdFndu.js +2 -0
- package/dist/owletto/dist/assets/event-card-Mcxv56DG.js +2 -0
- package/dist/owletto/dist/assets/event-detail-DXifj49J.js +2 -0
- package/dist/owletto/dist/assets/events-feed-BysC9HgU.js +2 -0
- package/dist/owletto/dist/assets/feed-event-kinds-BYuZCoU4.js +2 -0
- package/dist/owletto/dist/assets/filter-bar-BQm-ubB1.js +2 -0
- package/dist/owletto/dist/assets/{full-page-spinner-DtmqQmgl.js → full-page-spinner-BMiXl54z.js} +2 -2
- package/dist/owletto/dist/assets/guardrails-D7W80sJO.js +2 -0
- package/dist/owletto/dist/assets/identity-N0cAO9BR.js +2 -0
- package/dist/owletto/dist/assets/index-4gCDI7m4.js +7950 -0
- package/dist/owletto/dist/assets/index-B4wXJwQY.js +2 -0
- package/dist/owletto/dist/assets/index-BNaI5GpS.js +2 -0
- package/dist/owletto/dist/assets/index-BUUrHuJJ.js +2 -0
- package/dist/owletto/dist/assets/index-BqrvJmLh.js +2 -0
- package/dist/owletto/dist/assets/{index-DRbaESbJ.js → index-C-WaHj1Y.js} +2 -2
- package/dist/owletto/dist/assets/index-CnvQEA5V.js +2 -0
- package/dist/owletto/dist/assets/index-Cq7P2c_E.js +2 -0
- package/dist/owletto/dist/assets/{index-BhBYXtEN.js → index-CzoK57xp.js} +2 -2
- package/dist/owletto/dist/assets/index-D3omC3Us.js +2 -0
- package/dist/owletto/dist/assets/{index-Bhop_otG.js → index-D4-uel59.js} +2 -2
- package/dist/owletto/dist/assets/index-DDGdlQrt.css +1 -0
- package/dist/owletto/dist/assets/index-DFEW7hMg.js +2 -0
- package/dist/owletto/dist/assets/index-DVV-WWuT.js +2 -0
- package/dist/owletto/dist/assets/index-DduQ_e9q.js +2 -0
- package/dist/owletto/dist/assets/index-DutlI1d-.js +2 -0
- package/dist/owletto/dist/assets/{json-diff-4sMmayDd.js → json-diff-E5D-NGYT.js} +4 -4
- package/dist/owletto/dist/assets/{list-skeleton-BafzvpOM.js → list-skeleton-Bp4HNgJ9.js} +2 -2
- package/dist/owletto/dist/assets/login-7F48UJGx.js +2 -0
- package/dist/owletto/dist/assets/logout-DxmfsVKD.js +2 -0
- package/dist/owletto/dist/assets/{member-scope-gate-Dit3MXBQ.js → member-scope-gate-vp3FihBD.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-CfDmjhDl.js +74 -0
- package/dist/owletto/dist/assets/model-Dn40BUzs.js +2 -0
- package/dist/owletto/dist/assets/{model-selector-BeFuFH7p.js → model-selector-88PJnyTq.js} +2 -2
- package/dist/owletto/dist/assets/models-BBK_n2RP.js +2 -0
- package/dist/owletto/dist/assets/new-4ruWHLR5.js +2 -0
- package/dist/owletto/dist/assets/{new-ChwqLmVY.js → new-CvX8_gIb.js} +2 -2
- package/dist/owletto/dist/assets/new-gMD1PHTL.js +2 -0
- package/dist/owletto/dist/assets/oauth-workspace-access-D9BNmyMY.js +2 -0
- package/dist/owletto/dist/assets/organization-BHcp5Pzg.js +2 -0
- package/dist/owletto/dist/assets/peek-pane-content-0sa10jER.js +2 -0
- package/dist/owletto/dist/assets/{permissions-C6UFdvz2.js → permissions-hhxosugv.js} +2 -2
- package/dist/owletto/dist/assets/proposal-review-shell-B4CSiyLB.js +2 -0
- package/dist/owletto/dist/assets/public-shell-ready-CsenJeXa.js +2 -0
- package/dist/owletto/dist/assets/record-activity-D7bRaMk2.js +2 -0
- package/dist/owletto/dist/assets/{record-session-CJzFoVKc.js → record-session-CWXnCVln.js} +2 -2
- package/dist/owletto/dist/assets/{linked-record-peek-B0_B4PnF.js → renderer-7EGgTVX0.js} +30 -30
- package/dist/owletto/dist/assets/reset-password-CFUzxH7m.js +2 -0
- package/dist/owletto/dist/assets/runs-BPtQBTRN.js +2 -0
- package/dist/owletto/dist/assets/runs-panel-Bj63_hb9.js +2 -0
- package/dist/owletto/dist/assets/{schema-type-editor-panel-DcJqbCrU.js → schema-type-editor-panel-CAhOB648.js} +2 -2
- package/dist/owletto/dist/assets/{settings-Dg0D_l_w.js → settings-Dg6nxKyw.js} +2 -2
- package/dist/owletto/dist/assets/settings-KJJ6WihO.js +2 -0
- package/dist/owletto/dist/assets/skills-ayt06_o2.js +2 -0
- package/dist/owletto/dist/assets/source-record-panels-Bh5F4C5K.js +2 -0
- package/dist/owletto/dist/assets/{status-dot-_LQZmEIX.js → status-dot-D3FoDRcc.js} +2 -2
- package/dist/owletto/dist/assets/table-DFcJRNk7.js +2 -0
- package/dist/owletto/dist/assets/use-automations-BHoV0dLs.js +2 -0
- package/dist/owletto/dist/assets/{use-mention-search-CAFbh-Dk.js → use-mention-search-C3rWLuKm.js} +2 -2
- package/dist/owletto/dist/assets/use-scroll-sentinel-Ct-jt7O0.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-mKoqDsaD.js +2 -0
- package/dist/owletto/dist/assets/views-access-required-DHrDO333.js +2 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +100623 -98589
- package/npm-shrinkwrap.json +615 -960
- package/package.json +7 -10
- package/vendor/@better-auth-kysely-adapter/.bun-tag-abf95749a412716 +0 -0
- package/vendor/@better-auth-kysely-adapter/LICENSE.md +20 -0
- package/vendor/@better-auth-kysely-adapter/README.md +17 -0
- package/vendor/@better-auth-kysely-adapter/dist/bun-sqlite-dialect-DoOVo4ja.mjs +123 -0
- package/vendor/@better-auth-kysely-adapter/dist/d1-sqlite-dialect-Cru74LbR.mjs +133 -0
- package/vendor/@better-auth-kysely-adapter/dist/index.d.mts +116 -0
- package/vendor/@better-auth-kysely-adapter/dist/index.mjs +719 -0
- package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.d.mts +27 -0
- package/vendor/@better-auth-kysely-adapter/dist/node-sqlite-dialect.mjs +123 -0
- package/vendor/@better-auth-kysely-adapter/dist/sqlite-introspector-DSCAP82F.mjs +90 -0
- package/vendor/@better-auth-kysely-adapter/package.json +52 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +29 -0
- package/vendor/connector-sdk/dist/index.d.ts +3 -1
- package/vendor/connector-sdk/dist/index.js +4 -0
- package/vendor/connector-sdk/dist/redact.d.ts +10 -0
- package/vendor/connector-sdk/dist/redact.js +130 -0
- package/vendor/connector-sdk/dist/types.d.ts +2 -1
- package/vendor/connector-sdk/package.json +6 -1
- package/vendor/core/dist/connector-query-errors.d.ts +6 -0
- package/vendor/core/dist/connector-query-errors.js +4 -0
- package/vendor/core/dist/contracts/tools/manage-automations.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 +49 -20
- package/vendor/core/dist/contracts/tools/manage-entity.js +23 -5
- package/vendor/core/dist/contracts/worker/device-automation.d.ts +1 -1
- package/vendor/core/dist/contracts/worker/device-automation.js +1 -1
- package/vendor/core/dist/errors.d.ts +0 -20
- package/vendor/core/dist/errors.js +1 -25
- package/vendor/core/dist/index.d.ts +1 -0
- package/vendor/core/dist/index.js +4 -1
- package/vendor/core/dist/logger.js +8 -2
- package/vendor/core/dist/otel.d.ts +13 -2
- package/vendor/core/dist/otel.js +98 -44
- package/vendor/core/dist/trace-context.d.ts +12 -0
- package/vendor/core/dist/trace-context.js +50 -0
- package/vendor/core/dist/utils/ajv.js +3 -1
- package/vendor/core/package.json +26 -5
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-Cjvw31gU.js +0 -2
- package/dist/owletto/dist/assets/_-iToIRRFt.js +0 -3
- package/dist/owletto/dist/assets/_agentId-CLdj0X7j.js +0 -2
- package/dist/owletto/dist/assets/_agentId-D5cAWjrP.js +0 -2
- package/dist/owletto/dist/assets/_automationId-BhEZmkJU.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey._connectionId-DZtLc3WW.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-BoYpah_l.js +0 -2
- package/dist/owletto/dist/assets/_conversationId-ML2TjCwN.js +0 -2
- package/dist/owletto/dist/assets/_eventId-BYc3I2EL.js +0 -2
- package/dist/owletto/dist/assets/_name-BsOZmvlH.js +0 -2
- package/dist/owletto/dist/assets/_owner-UuyQLJ-0.js +0 -3
- package/dist/owletto/dist/assets/_shape-BpnVAYWH.js +0 -2
- package/dist/owletto/dist/assets/_skillKey-CYrGvNn-.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-CGAJ1ucr.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-CMkhfs1k.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-_G_lDz5K.js +0 -2
- package/dist/owletto/dist/assets/agent-client-setup-list-BgyLhJCo.js +0 -5
- package/dist/owletto/dist/assets/agent-connect-pages-BryZas7Z.js +0 -2
- package/dist/owletto/dist/assets/agent-guardrails-route-D9PpDgR-.js +0 -2
- package/dist/owletto/dist/assets/agents-C05k-Xw6.js +0 -2
- package/dist/owletto/dist/assets/agents-workbench-D1YL3VAB.js +0 -2
- package/dist/owletto/dist/assets/app-bridge-BCm4muqj.js +0 -128
- package/dist/owletto/dist/assets/automations-C05k-Xw6.js +0 -2
- package/dist/owletto/dist/assets/client-activity-scopes-CmK3DkSP.js +0 -2
- package/dist/owletto/dist/assets/client-rows-fFuxzFtE.js +0 -2
- package/dist/owletto/dist/assets/connect-BmCUJ3lr.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-B6StGCPK.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId-CPiMA6Bx.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.activity-BialEDmu.js +0 -2
- package/dist/owletto/dist/assets/connected._clientId.index-X1wVi6v0.js +0 -2
- package/dist/owletto/dist/assets/connection-DJd9bnEc.js +0 -2
- package/dist/owletto/dist/assets/connection-feed-detail-IO6G5QjL.js +0 -2
- package/dist/owletto/dist/assets/connections-browser-CzdcZeiU.js +0 -2
- package/dist/owletto/dist/assets/connector-provenance-bmBJJ9B4.js +0 -2
- package/dist/owletto/dist/assets/consent-C_WBfmQ8.js +0 -2
- package/dist/owletto/dist/assets/create-DQNlRTUX.js +0 -2
- package/dist/owletto/dist/assets/create-automation-form-y3tq2QIJ.js +0 -3
- package/dist/owletto/dist/assets/create-lOFSQV_5.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-icyNicvn.js +0 -2
- package/dist/owletto/dist/assets/device-Br9JHadR.js +0 -2
- package/dist/owletto/dist/assets/device-pin-tombstone-7UpeD4Sq.js +0 -2
- package/dist/owletto/dist/assets/device._deviceId-DGMmjr01.js +0 -2
- package/dist/owletto/dist/assets/entity-options-BcTafZ2e.js +0 -2
- package/dist/owletto/dist/assets/entity-page-CY7PF3X9.js +0 -2
- package/dist/owletto/dist/assets/entity-type-page-BzMZttzh.js +0 -2
- package/dist/owletto/dist/assets/event-detail-C25TvOb_.js +0 -2
- package/dist/owletto/dist/assets/events-feed-C4VrjIc1.js +0 -2
- package/dist/owletto/dist/assets/filter-editors-oNjBX9a2.js +0 -2
- package/dist/owletto/dist/assets/guardrails-Acfam-JF.js +0 -2
- package/dist/owletto/dist/assets/identity-BkK8ggdp.js +0 -2
- package/dist/owletto/dist/assets/index-Bw5iV_J7.js +0 -2
- package/dist/owletto/dist/assets/index-C3dpyynY.js +0 -2
- package/dist/owletto/dist/assets/index-C3zAbslo.js +0 -2
- package/dist/owletto/dist/assets/index-CGKN_WN_.js +0 -2
- package/dist/owletto/dist/assets/index-CgRaCOzW.js +0 -2
- package/dist/owletto/dist/assets/index-DfIoxD5Q.js +0 -2
- package/dist/owletto/dist/assets/index-DijuudSs.js +0 -2
- package/dist/owletto/dist/assets/index-Dr7bouPX.css +0 -1
- package/dist/owletto/dist/assets/index-JmEl29py.js +0 -7950
- package/dist/owletto/dist/assets/index-NK2VKPoL.js +0 -2
- package/dist/owletto/dist/assets/index-_5qsmBkt.js +0 -2
- package/dist/owletto/dist/assets/index-qkOKpRYs.js +0 -2
- package/dist/owletto/dist/assets/index-wzYkECAe.js +0 -2
- package/dist/owletto/dist/assets/login-XL5XxN6y.js +0 -2
- package/dist/owletto/dist/assets/logout-CMxdhLbM.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-DTlM_9MY.js +0 -74
- package/dist/owletto/dist/assets/models-BAVaDnKN.js +0 -2
- package/dist/owletto/dist/assets/new-1QLuS1o-.js +0 -2
- package/dist/owletto/dist/assets/new-D21LGMl6.js +0 -2
- package/dist/owletto/dist/assets/oauth-workspace-access-D15LYKSe.js +0 -2
- package/dist/owletto/dist/assets/organization-CoUJYXx7.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-BvkYk72J.js +0 -2
- package/dist/owletto/dist/assets/proposal-review-shell-CmLy1MZf.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-_awBxu2Y.js +0 -2
- package/dist/owletto/dist/assets/record-activity-Doeu5kPO.js +0 -2
- package/dist/owletto/dist/assets/reset-password-Y-WO77iR.js +0 -2
- package/dist/owletto/dist/assets/runs-B0zVYb-w.js +0 -2
- package/dist/owletto/dist/assets/runs-panel-Dkyybqos.js +0 -2
- package/dist/owletto/dist/assets/runs-table-9OVdfPXZ.js +0 -2
- package/dist/owletto/dist/assets/settings-Cfy9tCOF.js +0 -2
- package/dist/owletto/dist/assets/skills-oxA7P5Fe.js +0 -2
- package/dist/owletto/dist/assets/source-record-panels-BeAZeMLy.js +0 -2
- package/dist/owletto/dist/assets/use-automations-DS3uz3pb.js +0 -2
- package/dist/owletto/dist/assets/use-scroll-sentinel-BpQ70c28.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-FuOZyjMg.js +0 -2
- package/dist/owletto/dist/assets/views-access-required-CWwlobOd.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,
|
|
2
|
-
//# sourceMappingURL=agent-permissions-matrix-
|
|
1
|
+
import{j as e,bM as R,h as k,b1 as B,b2 as D,b3 as K,g3 as J,a5 as V,bF as X,bE as G,bR as Y,g4 as ee,bS as P,bT as F,bU as se,bN as ne,bV as te,bO as re,r as S,g5 as ae,g6 as ie,bJ as le,bW as oe,L as w,g7 as de,g8 as ce,cZ as W,g9 as ue,ga as me,gb as ge,gc as A,cN as L,X as fe,gd as q,ge as z,eI as xe,c_ as he,gf as be,gg as ye,bZ as pe,gh as je}from"./index-4gCDI7m4.js";const ve={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=R[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(ve[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(B,{children:[e.jsx(D,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:f})}),e.jsx(K,{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),j=pe(o,a),p=e.jsx("div",{className:k("inline-flex shrink-0",u&&"opacity-45"),children:e.jsx(Ne,{options:j,value:y,floor:f,disabled:l,compact:!0,ariaLabel:n,onChange:b})});return g?e.jsxs(B,{children:[e.jsx(D,{asChild:!0,children:e.jsx("span",{className:"inline-flex shrink-0",children:p})}),e.jsxs(K,{children:["Org floor ",R[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=je(n,t,o,a);return u[i]=m,u}const O="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 Oe({owner:n,agentId:t,variant:o="agent"}){const a=o==="org-floor",i=V(),m=X(n,t??"",{enabled:!a&&!!t}),u=G(n,{enabled:a}),{data:l,isLoading:b,isError:h,error:g}=a?u:m,y=a?Y(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=>{F.error(r instanceof Error?r.message:"Failed to save permission")}}),j=P({mutationFn:r=>a?te(n,r):re(n,t??"",r),onSuccess:()=>{i.invalidateQueries({queryKey:y}),a&&i.invalidateQueries({queryKey:["agent-permissions"]})},onError:r=>{F.error(r instanceof Error?r.message:"Failed to remove override")}}),p=f.isPending||j.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]),v=S.useMemo(()=>l?ie(l):[],[l]),N=S.useMemo(()=>{if(!l)return[];const r=new Set(v.map(c=>c.id));return l.agents.filter(c=>(a||c.id!==t)&&!r.has(c.id))},[l,v,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,I=(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})},H=x.entity_types.length===0?"— none yet":E.length===0?"— all covered":null,U=N.length===0&&v.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:O,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:O,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)})):v.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:O,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:()=>j.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 $=`${d.charAt(0).toUpperCase()+d.slice(1)} ${c?"entities":"agents"}`;return e.jsx(M,{controls:e.jsx(ke,{label:`${s.name}: ${$}`,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:Z=>I(r.resourceClass,s.entityTypeSlug,d,Z,s.targetAgentId)}),children:$},d)})})]},s.key)),e.jsxs("div",{className:"border-t",children:[c?e.jsx(Q,{label:"Add type",disabled:p||E.length===0,hint:H,searchPlaceholder:"Search types…",emptyText:"No matching types.",children:s=>E.map(d=>e.jsx(L,{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(L,{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{Oe as A,Ne as P,M as a};
|
|
2
|
+
//# sourceMappingURL=agent-permissions-matrix-CbhXlbgY.js.map
|
package/dist/owletto/dist/assets/{agent-skill-context-B9giw2u2.js → agent-skill-context-V__2i6Vl.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as p,
|
|
2
|
-
//# sourceMappingURL=agent-skill-context-
|
|
1
|
+
import{r as p,e7 as G,gt as ge,h1 as pe,hc as be,bT as F,j as ve}from"./index-4gCDI7m4.js";import{K as E,d as me,g as he,e as xe,s as Ce,f as Ie,h as Se,i as Y,b as ke,c as ye,j as we,k as Re,C as H,l as Ae}from"./core.esm-CHnfRiEM.js";import{s as De,b as Ee}from"./skill-editor-D_W3QlRz.js";function K(e,n,t){const r=e.slice();return r.splice(t<0?r.length+t:t,0,r.splice(n,1)[0]),r}function Le(e,n){return e.reduce((t,r,s)=>{const u=n.get(r);return u&&(t[s]=u),t},Array(e.length))}function P(e){return e!==null&&e>=0}function Te(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function Ne(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const V=e=>{let{rects:n,activeIndex:t,overIndex:r,index:s}=e;const u=K(n,r,t),o=n[s],i=u[s];return!i||!o?null:{x:i.left-o.left,y:i.top-o.top,scaleX:i.width/o.width,scaleY:i.height/o.height}},M={scaleX:1,scaleY:1},We=e=>{var n;let{activeIndex:t,activeNodeRect:r,index:s,rects:u,overIndex:o}=e;const i=(n=u[t])!=null?n:r;if(!i)return null;if(s===t){const f=u[o];return f?{x:0,y:t<o?f.top+f.height-(i.top+i.height):f.top-i.top,...M}:null}const m=Oe(u,s,t);return s>t&&s<=o?{x:0,y:-i.height-m,...M}:s<t&&s>=o?{x:0,y:i.height+m,...M}:{x:0,y:0,...M}};function Oe(e,n,t){const r=e[n],s=e[n-1],u=e[n+1];return r?t<n?s?r.top-(s.top+s.height):u?u.top-(r.top+r.height):0:u?u.top-(r.top+r.height):s?r.top-(s.top+s.height):0:0}const W="Sortable",J=G.createContext({activeIndex:-1,containerId:W,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:V,disabled:{draggable:!1,droppable:!1}});function Je(e){let{children:n,id:t,items:r,strategy:s=V,disabled:u=!1}=e;const{active:o,dragOverlay:i,droppableRects:m,over:f,measureDroppableContainers:a}=Ie(),l=Se(W,t),b=i.rect!==null,h=p.useMemo(()=>r.map(d=>typeof d=="object"&&"id"in d?d.id:d),[r]),k=o!=null,w=o?h.indexOf(o.id):-1,C=f?h.indexOf(f.id):-1,R=p.useRef(h),I=!Te(h,R.current),S=C!==-1&&w===-1||I,c=Ne(u);Y(()=>{I&&k&&a(h)},[I,h,k,a]),p.useEffect(()=>{R.current=h},[h]);const g=p.useMemo(()=>({activeIndex:w,containerId:l,disabled:c,disableTransforms:S,items:h,overIndex:C,useDragOverlay:b,sortedRects:Le(h,m),strategy:s}),[w,l,c.draggable,c.droppable,S,h,C,m,b,s]);return G.createElement(J.Provider,{value:g},n)}const Pe=e=>{let{id:n,items:t,activeIndex:r,overIndex:s}=e;return K(t,r,s).indexOf(n)},Me=e=>{let{containerId:n,isSorting:t,wasDragging:r,index:s,items:u,newIndex:o,previousItems:i,previousContainerId:m,transition:f}=e;return!f||!r||i!==u&&s===o?!1:t?!0:o!==s&&n===m},je={duration:200,easing:"ease"},Q="transform",$e=H.Transition.toString({property:Q,duration:0,easing:"linear"}),ze={roleDescription:"sortable"};function Fe(e){let{disabled:n,index:t,node:r,rect:s}=e;const[u,o]=p.useState(null),i=p.useRef(t);return Y(()=>{if(!n&&t!==i.current&&r.current){const m=s.current;if(m){const f=Ae(r.current,{ignoreTransform:!0}),a={x:m.left-f.left,y:m.top-f.top,scaleX:m.width/f.width,scaleY:m.height/f.height};(a.x||a.y)&&o(a)}}t!==i.current&&(i.current=t)},[n,t,r,s]),p.useEffect(()=>{u&&o(null)},[u]),u}function Qe(e){let{animateLayoutChanges:n=Me,attributes:t,disabled:r,data:s,getNewIndex:u=Pe,id:o,strategy:i,resizeObserverConfig:m,transition:f=je}=e;const{items:a,containerId:l,activeIndex:b,disabled:h,disableTransforms:k,sortedRects:w,overIndex:C,useDragOverlay:R,strategy:I}=p.useContext(J),S=Ke(r,h),c=a.indexOf(o),g=p.useMemo(()=>({sortable:{containerId:l,index:c,items:a},...s}),[l,s,c,a]),d=p.useMemo(()=>a.slice(a.indexOf(o)),[a,o]),{rect:v,node:y,isOver:A,setNodeRef:L}=ke({id:o,data:g,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:d,...m}}),{active:D,activatorEvent:te,activeNodeRect:ne,attributes:re,setNodeRef:U,listeners:se,isDragging:$,over:oe,setActivatorNodeRef:ie,transform:ae}=ye({id:o,data:g,attributes:{...ze,...t},disabled:S.draggable}),le=we(L,U),T=!!D,X=T&&!k&&P(b)&&P(C),_=!R&&$,q=_&&X?ae:null,ce=X?q??(i??I)({rects:w,activeNodeRect:ne,activeIndex:b,overIndex:C,index:c}):null,O=P(b)&&P(C)?u({id:o,items:a,activeIndex:b,overIndex:C}):c,N=D?.id,x=p.useRef({activeId:N,items:a,newIndex:O,containerId:l}),ue=a!==x.current.items,B=n({active:D,containerId:l,isDragging:$,isSorting:T,id:o,index:c,items:a,newIndex:x.current.newIndex,previousItems:x.current.items,previousContainerId:x.current.containerId,transition:f,wasDragging:x.current.activeId!=null}),z=Fe({disabled:!B,index:c,node:y,rect:v});return p.useEffect(()=>{T&&x.current.newIndex!==O&&(x.current.newIndex=O),l!==x.current.containerId&&(x.current.containerId=l),a!==x.current.items&&(x.current.items=a)},[T,O,l,a]),p.useEffect(()=>{if(N===x.current.activeId)return;if(N!=null&&x.current.activeId==null){x.current.activeId=N;return}const fe=setTimeout(()=>{x.current.activeId=N},50);return()=>clearTimeout(fe)},[N]),{active:D,activeIndex:b,attributes:re,data:g,rect:v,index:c,newIndex:O,items:a,isOver:A,isSorting:T,isDragging:$,listeners:se,node:y,overIndex:C,over:oe,setNodeRef:le,setActivatorNodeRef:ie,setDroppableNodeRef:L,setDraggableNodeRef:U,transform:z??ce,transition:de()};function de(){if(z||ue&&x.current.newIndex===c)return $e;if(!(_&&!Re(te)||!f)&&(T||B))return H.Transition.toString({...f,property:Q})}}function Ke(e,n){var t,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(t=e?.draggable)!=null?t:n.draggable,droppable:(r=e?.droppable)!=null?r:n.droppable}}function j(e){if(!e)return!1;const n=e.data.current;return!!(n&&"sortable"in n&&typeof n.sortable=="object"&&"containerId"in n.sortable&&"items"in n.sortable&&"index"in n.sortable)}const Ue=[E.Down,E.Right,E.Up,E.Left],Ze=(e,n)=>{let{context:{active:t,collisionRect:r,droppableRects:s,droppableContainers:u,over:o,scrollableAncestors:i}}=n;if(Ue.includes(e.code)){if(e.preventDefault(),!t||!r)return;const m=[];u.getEnabled().forEach(l=>{if(!l||l!=null&&l.disabled)return;const b=s.get(l.id);if(b)switch(e.code){case E.Down:r.top<b.top&&m.push(l);break;case E.Up:r.top>b.top&&m.push(l);break;case E.Left:r.left>b.left&&m.push(l);break;case E.Right:r.left<b.left&&m.push(l);break}});const f=me({collisionRect:r,droppableRects:s,droppableContainers:m});let a=he(f,"id");if(a===o?.id&&f.length>1&&(a=f[1].id),a!=null){const l=u.get(t.id),b=u.get(a),h=b?s.get(b.id):null,k=b?.node.current;if(k&&h&&l&&b){const C=xe(k).some((d,v)=>i[v]!==d),R=Z(l,b),I=Xe(l,b),S=C||!R?{x:0,y:0}:{x:I?r.width-h.width:0,y:I?r.height-h.height:0},c={x:h.left,y:h.top};return S.x&&S.y?c:Ce(c,S)}}}};function Z(e,n){return!j(e)||!j(n)?!1:e.data.current.sortable.containerId===n.data.current.sortable.containerId}function Xe(e,n){return!j(e)||!j(n)||!Z(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function _e(e){return{skillsConfig:De(e)}}function qe(e){return e.repo.startsWith("system/")?["System"]:[]}function et(e,n){return e.filter(t=>!t.hidden&&!n.has(t.repo)).map(t=>({key:t.repo,name:t.name,description:t.description||t.instructions||"Add this skill to give the agent tools and capabilities.",badges:qe(t)}))}function tt(e,n){const t=n.trim().toLowerCase();return t?e.filter(r=>r.name.toLowerCase().includes(t)||r.description.toLowerCase().includes(t)||r.key.toLowerCase().includes(t)):e}function Be(e){const n=e.instructions?.trim();return{repo:e.repo,skillId:e.skillId,name:e.name,description:e.description,instructions:n,content:n||e.name,enabled:!0,system:e.repo.startsWith("system/")}}const ee=p.createContext(null);function nt({agentId:e,children:n}){const{data:t,isLoading:r}=ge(e),{data:s,isLoading:u}=pe(e),o=be(e),i=p.useMemo(()=>t?Ee(t,s?.catalog??[]):[],[t,s]),[m,f]=p.useState(null),a=m??i,l=p.useCallback(async(c,g)=>{if(!t)return F.error("Still loading agent settings — try again in a moment"),!1;try{const d=_e(c);return await o.mutateAsync(d),F.success(g),!0}catch(d){return F.error(d instanceof Error?d.message:"Failed to save skills"),!1}},[t,o]),b=p.useCallback(c=>{const g=s?.catalog.find(d=>d.repo===c);g&&f(d=>{const v=d??i;return v.some(y=>y.repo===c)?v:[...v,Be(g)]})},[i,s?.catalog]),h=p.useCallback(c=>{const g=c.name.trim();if(!g)return null;const d=`custom/${g.toLowerCase().replace(/[^a-z0-9-]/g,"-")}`,v=c.instructions.trim();return f(y=>{const A=y??i;return A.some(L=>L.repo===d)?A:[...A,{repo:d,skillId:g,name:g,instructions:v||void 0,content:v||g,enabled:!0}]}),d},[i]),k=p.useCallback((c,g)=>{f(d=>(d??i).map(v=>v.repo===c?{...v,...g}:v))},[i]),w=p.useCallback((c,g)=>{f(d=>{const v=d??i,y=v.findIndex(D=>D.repo===c),A=v.findIndex(D=>D.repo===g);if(y<0||A<0||y===A)return v;const L=K(v,y,A);return l(L,"Skill order updated"),L})},[l,i]),C=p.useCallback(async c=>{const g=a.filter(d=>d.repo!==c);return f(g),l(g,"Skill removed")},[l,a]),R=p.useCallback(async(c,g)=>{const d=a.map(v=>v.repo===c?{...v,enabled:g}:v);return f(d),l(d,g?"Skill enabled":"Skill disabled")},[l,a]),I=p.useCallback(async()=>{await l(a,"Skills saved")},[l,a]),S=p.useMemo(()=>({agentId:e,skillRows:a,catalog:s,isLoading:r||u,isSaving:o.isPending,addSkillFromCatalog:b,addCustomSkill:h,updateSkillRow:k,reorderSkills:w,removeSkillAndSave:C,setSkillEnabledAndSave:R,saveSkills:I}),[h,b,e,u,r,w,C,R,I,a,s,o.isPending,k]);return ve.jsx(ee.Provider,{value:S,children:n})}function rt(){const e=p.useContext(ee);if(!e)throw new Error("useAgentSkillEditor must be used within AgentSkillEditorProvider");return e}export{nt as A,Je as S,Ze as a,et as b,Qe as c,tt as f,qe as s,rt as u,We as v};
|
|
2
|
+
//# sourceMappingURL=agent-skill-context-V__2i6Vl.js.map
|
package/dist/owletto/dist/assets/{agent-skills-route-BMZ3r1bP.js → agent-skills-route-DFXr_bHp.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=agent-skills-route-
|
|
1
|
+
import{v as D,r as g,j as e,c_ as K,H as C,I as L,ep as P,bK as O,B as N,h as R,d9 as _,h3 as H,h4 as z,b4 as G,hj as Q,fv as Y,iN as V}from"./index-4gCDI7m4.js";import{u as A,b as X,f as q,s as J,a as U,S as W,v as Z,c as ee}from"./agent-skill-context-V__2i6Vl.js";import{a as se,A as E}from"./agent-subpage-shell-DWzljvFb.js";import{f as te}from"./agent-loading-shells-Dnmb6W5Y.js";import{u as ae,a as F,m as ne,P as le,D as ie,n as oe,C as re}from"./core.esm-CHnfRiEM.js";import{A as ce}from"./agent-card-controls-99mG6H5k.js";const T=":";function w(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 de({owner:s,agentId:t}){const a=D(),[n,i]=g.useState(""),[o,d]=g.useState(!1),[x,k]=g.useState(""),[r,v]=g.useState(""),{skillRows:m,catalog:p,isLoading:u,addSkillFromCatalog:h,addCustomSkill:S}=A(),b=g.useMemo(()=>new Set(m.map(c=>c.repo)),[m]),f=g.useMemo(()=>X(p?.catalog??[],b),[p?.catalog,b]),l=g.useMemo(()=>q(f,n),[f,n]),y=c=>{h(c),a({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:w(c)}})},j=()=>{const c=S({name:x,instructions:r});c&&a({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:w(c)}})},$=e.jsx(se,{title:"Add a skill",description:"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:R(_,"w-full"),children:o?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(L,{id:"custom-skill-name",value:x,onChange:c=>k(c.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:r,onChange:c=>v(c.target.value),placeholder:"Instructions for the agent when this skill is active...",rows:3})]})]}),e.jsx(O,{onCancel:()=>d(!1),children:e.jsx(N,{type:"button",size:"sm",onClick:j,disabled:!x.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:()=>d(!0),children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(K,{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"})]})]})}),u?e.jsx(H,{}):e.jsx(z,{items:l,searchQuery:n,onSearchChange:i,onSelect:c=>y(c.key),searchPlaceholder:"Search skills...",searchAriaLabel:"Search skills",emptyMessage:n.trim()?`No skills match "${n}"`:f.length===0?"All catalog skills are already configured":"No skills available"})]})}function me({row:s}){const{isSaving:t,updateSkillRow:a}=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(L,{id:"skill-name",value:s.name,onChange:i=>a(s.repo,{name:i.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:i=>{const o=i.target.value;a(s.repo,{instructions:o,content:o.trim()||s.name})},rows:4,disabled:t})]})]})})}function ue({owner:s,agentId:t,skillKey:a}){const n=D(),[i,o]=g.useState(!1),d=B(a),{skillRows:x,catalog:k,isSaving:r,saveSkills:v,removeSkillAndSave:m,addSkillFromCatalog:p}=A(),u=x.find(f=>f.repo===d)??null,h=k?.catalog.find(f=>f.repo===d);g.useEffect(()=>{!u&&h&&p(d)},[p,h,d,u]);const S=async()=>{await m(d)&&(o(!1),n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}}))};if(!u)return h?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skill not found."});const b=!u.system;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(me,{row:u}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-end",children:[b?i?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:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(!0),disabled:r,children:["Remove ",u.name]}):null,e.jsx(N,{type:"button",onClick:()=>void v(),disabled:r||i,children:r?"Saving...":"Save changes"})]})]})}function ge(s){return s.map(t=>{const a=J(t).map(String);return{id:t.repo,repo:t.repo,name:t.name,description:t.description,badges:a,enabled:t.enabled}})}const I="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=D(),{skillRows:i,catalog:o,isLoading:d,isSaving:x,reorderSkills:k,setSkillEnabledAndSave:r,addSkillFromCatalog:v}=A();g.useEffect(()=>{a&&(i.some(l=>l.repo===a)||o?.catalog.some(l=>l.repo===a)&&v(a))},[a,i,o,v]);const m=g.useMemo(()=>ge(i),[i]),p=g.useMemo(()=>m.map(l=>l.repo),[m]),u=ae(F(le,{activationConstraint:{distance:8}}),F(ne,{coordinateGetter:U})),h=()=>{n({to:"/$owner/agents/$agentId/skills/create",params:{owner:s,agentId:t}})},S=e.jsxs(N,{type:"button",onClick:h,children:[e.jsx(K,{className:"mr-1.5 h-4 w-4"}),"Add skill"]}),b=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:w(l)}})},f=l=>{const{active:y,over:j}=l;!j||y.id===j.id||k(String(y.id),String(j.id))};return d?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:I}),e.jsx(te,{rows:2})]}):m.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:I}),e.jsx(G,{icon:Q,title:"No skills yet",description:"Add a system skill from the catalog or create a custom skill for this agent.",actionLabel:"Add skill",onAction:h})]}):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:I}),S]}),e.jsx(ie,{sensors:u,collisionDetection:oe,onDragEnd:f,children:e.jsx(W,{items:p,strategy:Z,children:e.jsx("div",{className:"overflow-hidden rounded-lg border",children:m.map((l,y)=>{const j=l.repo===a;return e.jsx(xe,{card:l,rank:y+1,disabled:x,expanded:j,isLast:y===m.length-1,onToggle:()=>b(l.repo),onToggleEnabled:$=>void r(l.repo,$),toggleDisabled:x,children:j?e.jsx(ue,{owner:s,agentId:t,skillKey:w(l.repo)}):null},l.id)})})})})]})}function xe({card:s,rank:t,disabled:a,expanded:n,isLast:i,onToggle:o,onToggleEnabled:d,toggleDisabled:x,children:k}){const r=a||n,{attributes:v,listeners:m,setNodeRef:p,transform:u,transition:h,isDragging:S}=ee({id:s.repo,disabled:r}),b={transform:re.Transform.toString(u),transition:h};return e.jsxs("div",{ref:p,style:b,className:R("bg-background",!i||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,...v,...m,children:e.jsx(Y,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",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",!s.enabled&&!n&&"opacity-70"),onClick:o,"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(V,{badges:s.badges})]})]}),e.jsx(ce,{enabled:s.enabled,name:s.name,expanded:n,onToggleEnabled:d,toggleDisabled:x,onToggle:o})]}),n&&k?e.jsx("div",{className:"border-t border-border px-4 py-4",children:k}):null]})}function je({owner:s,agentId:t}){return e.jsx(E,{children:e.jsx(M,{owner:s,agentId:t})})}function Se({owner:s,agentId:t}){return e.jsx(E,{children:e.jsx(de,{owner:s,agentId:t})})}function ye({owner:s,agentId:t,skillKey:a}){return e.jsx(E,{children:e.jsx(M,{owner:s,agentId:t,expandedRepo:B(a)})})}export{je as A,Se as a,ye as b};
|
|
2
|
+
//# sourceMappingURL=agent-skills-route-DFXr_bHp.js.map
|
package/dist/owletto/dist/assets/{agent-subpage-shell-D49f-bzP.js → agent-subpage-shell-DWzljvFb.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,
|
|
2
|
-
//# sourceMappingURL=agent-subpage-shell-
|
|
1
|
+
import{j as e,h as a}from"./index-4gCDI7m4.js";function r({children:t,className:s}){return e.jsx("div",{className:a("mx-auto w-full max-w-3xl pb-8",s),children:t})}function x({title:t,description:s}){return e.jsxs("div",{className:"mb-2 space-y-1",children:[e.jsx("h1",{className:"text-center text-xl font-semibold",children:t}),e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:s})]})}export{r as A,x as a};
|
|
2
|
+
//# sourceMappingURL=agent-subpage-shell-DWzljvFb.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{j as s,r as a,
|
|
1
|
+
import{j as s,r as a,aN as Vt,a5 as Bt,gs as Ht,gt as zt,a2 as Ze,Q as Ve,a3 as et,c5 as Wt,gu as tt,gv as Kt,gw as qt,L as mt,h as P,gx as Gt,dH as ht,dJ as Qt,gy as Jt,cB as Yt,dN as Xt,gz as Zt,aA as en,B as pe,eQ as tn,gA as nn,gB as Be,X as rn,aa as on,d3 as sn,d9 as Ne,gC as ln,gD as an,dx as cn,dz as un,gE as dn,dy as fn,bn as pn,gF as mn,gG as hn,ei as gn,W as bn,gH as xn,gI as vn}from"./index-4gCDI7m4.js";import{D as yn,E as Rn}from"./app-bridge-C4nPtae3.js";import{A as wn,a as Sn,b as Cn,c as qe,d as gt,e as Tn}from"./agent-loading-shells-Dnmb6W5Y.js";import{h as jn,t as Nn,R as En,i as An,u as kn,M as In,a as _n}from"./use-mention-search-C3rWLuKm.js";import{t as nt,c as On}from"./event-card-Mcxv56DG.js";import{E as Pn}from"./events-feed-BysC9HgU.js";const bt=a.createContext(null);function Mn({extension:e,children:t}){return s.jsx(bt.Provider,{value:e??null,children:t})}function Ge(){return a.useContext(bt)}var Qe=(e=>(e.PROVIDER_QUOTA_EXHAUSTED="PROVIDER_QUOTA_EXHAUSTED",e.PROVIDER_AUTH="PROVIDER_AUTH",e.PROVIDER_UNKNOWN_MODEL="PROVIDER_UNKNOWN_MODEL",e.PROVIDER_BASE_URL_UNRESOLVED="PROVIDER_BASE_URL_UNRESOLVED",e.NO_MODEL_CONFIGURED="NO_MODEL_CONFIGURED",e.WORKER_UNRESPONSIVE="WORKER_UNRESPONSIVE",e.WORKER_DIED="WORKER_DIED",e.WORKER_STARTUP_FAILED="WORKER_STARTUP_FAILED",e.PROVIDER_TOOL_CALL_FAILED="PROVIDER_TOOL_CALL_FAILED",e.SESSION_TIMEOUT="SESSION_TIMEOUT",e))(Qe||{});const Ln={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function $n(e){if(typeof e=="string")return Object.values(Qe).includes(e)?e:void 0}const Dn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:Ln,AgentErrorCode:Qe,toAgentErrorCode:$n},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Un,toAgentErrorCode:Fn}=Dn;function rt(e,t){if(!t)return null;try{const n=new URL(t);return n.protocol!=="http:"&&n.protocol!=="https:"?null:new URL(e,`${n.origin}/`).toString()}catch{return null}}function xt(e,t){const n=Fn(e);if(!n)return null;const r=Un[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const i=t.provider?`/${o}/connectors/${encodeURIComponent(`${Vt}${t.provider}`)}`:`/${o}/connectors`,c=rt(i,t.webOrigin);if(!c)return null;const u=new URL(c);return t.provider&&t.model&&u.searchParams.set("model",t.model),{label:r.ctaLabel??"Connect a provider",href:u.toString()}}if(!t.agentId)return null;const l=rt(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return l?{label:r.ctaLabel??"Open settings",href:l}:null}function vt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.subscribable;if(!t||typeof t!="object"||Array.isArray(t))return null;const n=t;if(typeof n.connector_key!="string"||!n.connector_key||typeof n.resource_type!="string"||!n.resource_type||typeof n.resource_ref!="string"||!n.resource_ref||typeof n.label!="string"||!n.label)return null;const r=Array.isArray(n.suggested_event_keys)?n.suggested_event_keys.filter(o=>typeof o=="string"&&!!o):void 0;return{connector_key:n.connector_key,resource_type:n.resource_type,resource_ref:n.resource_ref,label:n.label,...r?.length?{suggested_event_keys:r}:{}}}const ot=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Vn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function st(e,t){const n=Vn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function lt(e,t,n){try{const r=new URL(t),o=new URL(e,t),l=ot.has(o.hostname)&&ot.has(r.hostname),i=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&st(o.hostname,n)&&st(r.hostname,n);return o.origin!==r.origin&&(l||i)&&(o.protocol=r.protocol,o.host=r.host),o.origin===r.origin&&o.pathname.startsWith("/api/v1/agents")&&(o.pathname=`/lobu${o.pathname}`),o.toString()}catch{return e}}const Bn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,yt=new Set(["suggest_actions"]),Pe="Thinking…";function Hn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,l=[];n===Pe&&l.push({type:"reasoning"}),r&&l.push({type:"error",text:r});let i=t;return n&&n!==Pe&&(i=t?`${t}
|
|
2
2
|
|
|
3
|
-
${n}`:n),i&&l.push({type:"text",text:i}),l.push(...o),l}const Rt=[];function zn(e,t,n){return e?.length?e:n===0?t:[]}const Je=a.createContext(null);function Ee(){const e=a.useContext(Je);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function
|
|
3
|
+
${n}`:n),i&&l.push({type:"text",text:i}),l.push(...o),l}const Rt=[];function zn(e,t,n){return e?.length?e:n===0?t:[]}const Je=a.createContext(null);function Ee(){const e=a.useContext(Je);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function Lo({messages:e,workspaceSlug:t=null,children:n}){const r=a.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:t,currentSuggestions:null,starters:Rt}),[e,t]);return s.jsx(Je.Provider,{value:r,children:n})}const wt=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function at(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(wt,"").replace(/\n{3,}/g,`
|
|
4
4
|
|
|
5
|
-
`).trim()}function Kn(e){const t=[];for(const n of e.matchAll(wt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Wn(e,t={}){if(typeof e=="string"){const r=at(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const l=at(o.text);l&&n.push({type:"text",text:l})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!yt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function qn(e){const t=[],n=r=>{for(const{name:o,url:l}of Kn(r))t.push({id:`file-${t.length}`,name:o,url:l,isImage:Bn.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const l=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${l};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function Gn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Wn(e.content,t),attachments:qn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Yn=[],Jn=[];function Qn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function Xn(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=xt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const Zn=3e4,er=3*Zn,tr=15e3;function it(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const ye=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function nr(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:l}=r;if(typeof o!="string"||typeof l!="string")continue;const i=o.trim(),c=l.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function Lo({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:l,children:i,initialDraft:c}){const u=Bt(),d=a.useRef(null),p=a.useRef(null),v=a.useRef(!1),m=a.useRef(o),g=a.useRef(!1),R=a.useRef(null);m.current=o;const{data:A,isLoading:x}=Ht(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),C=A?.messages??Yn,K=A?.interactions??Jn,{data:U}=zt(e,{enabled:!!e}),G=U?.starters??Rt,W=!!(U?.showToolCalls??U?.settings?.showToolCalls),[E,$]=a.useState([]),[J,ae]=a.useState(!1),[D,Y]=a.useState([]),[Q,y]=a.useState(null),w=a.useRef(!1);w.current=J;const j=a.useMemo(()=>C.map(I=>Gn(I,{showToolCalls:W})).filter(I=>I!==null),[C,W]),O=a.useRef(!1);a.useEffect(()=>{if(O.current||x||w.current)return;O.current=!0;const I=Xn(K,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});$(I?[...j,I]:j),y(Qn(K))},[e,x,j,K,t]);const k=a.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),Z=a.useCallback(async()=>{if(d.current)return d.current;if(p.current)return p.current;if(!e)throw new Error("No agent selected");const I=(async()=>{const M=await Ze(`${Ve}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!M.ok)throw await et(M);const V=await M.json(),N=Kt(),z={sessionId:V.agentId,sseUrl:lt(V.sseUrl,Ve,N),messagesUrl:lt(V.messagesUrl,Ve,N)};return d.current=z,z})();p.current=I;try{return await I}catch(M){throw d.current=null,M}finally{p.current=null}},[e,t,n]),te=a.useCallback(async(I,M,V)=>{const N=new AbortController;R.current=N;const z=S=>{$(q=>q.map(f=>f.id===V?{...f,parts:S}:f))};let ee;try{ee=await Z()}catch(S){z([{type:"text",text:`Error: ${S instanceof Error?S.message:"Could not start a session."}`}]);return}let B=await tt(ee.sseUrl,{throwOnFailure:!0});const oe=[];let me=null;const ue=()=>{const S=me;me=null,S?.()},he=S=>{oe.push(S),ue()};let ge=!1,be=null;const ke=new Promise(S=>{be=S});let xe=0,ve=Date.now();const de=S=>{ve=Date.now();const q=Number(S.lastEventId);Number.isFinite(q)&&q>xe&&(xe=q)},Ie=["output","status","complete","closed","agent-error","question","link-button","tool-approval","tool_use"],Te=S=>{S.addEventListener("open",()=>{ge=!0,be?.()}),S.addEventListener("connected",f=>{de(f),ge||(ge=!0,be?.())}),S.addEventListener("ping",de);const q=f=>h=>{de(h);const T=h;typeof T.data=="string"&&he({kind:f,payload:it(T)})};for(const f of Ie)S.addEventListener(f,q(f));S.addEventListener("error",f=>{const h=f;if(typeof h.data=="string"&&h.data){de(f),he({kind:"error",payload:it(h)});return}S.readyState===EventSource.CLOSED&&he({kind:"error",payload:{error:"Connection closed"}})})};Te(B);const _e=async()=>{B.close();let S=ee.sseUrl;if(xe){const q=new URL(ee.sseUrl,window.location.origin);q.searchParams.set("since",String(xe)),S=q.toString()}B=await tt(S,{throwOnFailure:!1}),Te(B),ve=Date.now()};await Promise.race([ke,new Promise(S=>setTimeout(S,1500))]);const Ce=()=>{B.close(),ue()};N.signal.addEventListener("abort",Ce,{once:!0});try{const S=m.current?.trim(),q=!!S&&!g.current;q&&(g.current=!0);let f;if(M.length>0){const b=new FormData;b.set("content",I),q&&S&&b.set("ephemeralContext",S);for(const _ of M)b.append("files",_,_.name);f={method:"POST",credentials:"include",body:b,timeoutMs:12e4}}else{const b={content:I};q&&S&&(b.ephemeralContext=S),f={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(b),timeoutMs:2e4}}const h=await Ze(ee.messagesUrl,f);if(!h.ok)throw d.current=null,await et(h);let T="",L=Pe,ce=null;const H=[],fe=()=>Hn({textOut:T,statusLine:L,errorText:ce,toolCalls:H});for(z(fe());!N.signal.aborted;){if(oe.length===0){let _;const ne=await Promise.race([new Promise(Fe=>{me=()=>Fe(!0)}),new Promise(Fe=>{_=setTimeout(()=>Fe(!1),tr)})]);_&&clearTimeout(_),!ne&&Date.now()-ve>=er&&(await _e(),k());continue}const b=oe.shift();if(b){if(b.kind==="output")L=null,T+=String(b.payload.content??"");else if(b.kind==="status")L=Pe;else if(b.kind==="complete"){L=null;const _=b.payload.finalText;typeof _=="string"&&_.length>0&&(T=_);const ne=b.payload.suggestions;ne!==void 0&&y(Array.isArray(ne)?nr(ne):null),k(),z(fe());return}else if(b.kind==="closed"){d.current=null;const _=b.payload.reason;L=`Session ended${_?`: ${_}`:""}.`,k(),z(fe());return}else if(b.kind==="error"||b.kind==="agent-error"){L=null,ce=typeof b.payload.error=="string"&&b.payload.error?b.payload.error:"Agent reported an error.";const _=b.payload.errorContext&&typeof b.payload.errorContext=="object"?b.payload.errorContext:void 0,ne=xt(b.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof _?.provider=="string"?_.provider:void 0,model:typeof _?.model=="string"?_.model:void 0});ne&&H.push({type:"tool-call",toolCallId:ye("l"),toolName:"link-button",args:{label:ne.label,url:ne.href}}),k(),z(fe());return}else if(b.kind==="question")H.push({type:"tool-call",toolCallId:ye("q"),toolName:"question",args:{question:b.payload.question??"",options:b.payload.options??[]}});else if(b.kind==="tool_use"){if(L=null,yt.has(b.payload.name??"")){z(fe());continue}const _=b.payload.result_summary,ne=vt(_);if(!W&&!ne){z(fe());continue}H.push({type:"tool-call",toolCallId:b.payload.toolCallId??ye("t"),toolName:W?b.payload.name??"tool":"subscription-candidate",args:W?b.payload.input??{}:null,result:_,isError:b.payload.isError})}else if(b.kind==="link-button")H.push({type:"tool-call",toolCallId:ye("l"),toolName:"link-button",args:{label:b.payload.label??"Open link",url:b.payload.url??""}});else if(b.kind==="tool-approval"){const _=b.payload.runId;if(typeof _!="number")continue;H.push({type:"tool-call",toolCallId:`run-${_}`,toolName:"tool-approval",args:{runId:_,action:b.payload.action??null,proposal:b.payload.proposal??null,current:b.payload.current??null,fields:b.payload.fields??null,attribution:b.payload.attribution??null,resourceKind:b.payload.resourceKind??null}})}z(fe())}}}catch(S){z([{type:"text",text:`Error: ${S instanceof Error?S.message:"Send failed."}`}])}finally{N.signal.removeEventListener("abort",Ce),B.close()}},[e,Z,k,W,t]),re=a.useCallback(I=>{const M=I.trim(),V=D.map(B=>B.file);if(!M&&V.length===0||w.current||!e)return;v.current||(v.current=!0,l?.(M||V[0]?.name||""));const N={id:ye("u"),role:"user",parts:M?[{type:"text",text:M}]:[],attachments:D.map(B=>({id:B.id,name:B.name,isImage:B.isImage,imageDataUrl:B.isImage?URL.createObjectURL(B.file):void 0})),createdAt:Date.now()},z=ye("asst"),ee={id:z,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};$(B=>[...B,N,ee]),Y([]),ae(!0),w.current=!0,te(M,V,z).finally(()=>{ae(!1),w.current=!1,R.current=null})},[e,l,D,te]),le=a.useCallback(()=>{R.current?.abort()},[]),Se=a.useCallback(I=>{const M=Array.from(I);Y(V=>[...V,...M.map(N=>({id:crypto.randomUUID(),name:N.name,file:N,isImage:N.type.startsWith("image/")}))])},[]),X=a.useCallback(I=>{Y(M=>M.filter(V=>V.id!==I))},[]),ie=a.useRef(!1);a.useEffect(()=>{if(ie.current)return;const I=Wt(n);I&&(ie.current=!0,re(I))},[n,re]);const F=a.useMemo(()=>({messages:E,running:J,append:re,cancel:le,pendingAttachments:D,addAttachments:Se,removeAttachment:X,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:Q,starters:G}),[E,J,re,le,D,Se,X,c,e,n,t,Q,G]);return r&&x?s.jsx(wn,{}):s.jsx(Je.Provider,{value:F,children:i})}const ct="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function rr({refItem:e}){const t=En[e.kind]??qt;return An(e.path)?s.jsxs("span",{className:ct,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(mt,{to:e.path,className:P(ct,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Qe=({text:e,renderText:t})=>jn(e)?s.jsx(s.Fragment,{children:Nn(e).map((n,r)=>n.type==="ref"?s.jsx(rr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),or=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),St=a.createContext(null),Tt=()=>{const e=a.useContext(St);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Ct=a.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...l})=>{const[i,c]=Gt({prop:t,defaultProp:n,onChange:r}),u=a.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(St.Provider,{value:u,children:s.jsx("div",{className:P("not-prose max-w-prose space-y-4",e),...l,children:o})})}),jt=a.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=Tt();return s.jsx(ht,{onOpenChange:o,open:r,children:s.jsxs(Yt,{className:P("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Jt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Qt,{className:P("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),Nt=a.memo(({className:e,icon:t=Zt,label:n,description:r,status:o="complete",children:l,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:P("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),l]})]})}),Et=a.memo(({className:e,children:t,...n})=>{const{isOpen:r}=Tt();return s.jsx(ht,{open:r,children:s.jsx(Xt,{className:P("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});Ct.displayName="ChainOfThought";jt.displayName="ChainOfThoughtHeader";Nt.displayName="ChainOfThoughtStep";Et.displayName="ChainOfThoughtContent";function sr(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function lr({ownerSlug:e,eventIds:t}){const n=t.join(","),r=a.useMemo(()=>sr(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(en,{owner:e,children:({organizationId:o,ownerSlug:l})=>o?s.jsx(On,{organizationId:o,ownerSlug:l,filters:r,hideOriginator:!0}):null})}function ar({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let l=He(ir(r,o),t);if(!n)return a.createElement(e,l);if(typeof n=="function")return n(l,r);if(!a.isValidElement(n))return null;let i=n.props,c={...He(l,i),ref:Ae(l.ref,i.ref)};return a.cloneElement(n,c)}function He(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let l=r[o];if(l===void 0)continue;let i=t[o];o==="className"?t[o]=[i,l].filter(Boolean).join(" "):o==="style"?t[o]={...i,...l}:o==="ref"?t[o]=Ae(i,l):ur(o)&&typeof i=="function"&&typeof l=="function"?t[o]=cr(l,i):t[o]=l}}return t}function ir(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],l=t?.[r]?.(o);if(l){Object.assign(n,l);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function cr(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function ur(e){return/^on[A-Z]/.test(e)}function Ae(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var dr=8,fr=64,pr=0,Me=.5,mr=180,hr=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),At={start:!1,end:!1},gr=[],Le={currentAnchorId:null,visibleMessageIds:gr};function br({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return At;let o=Xe({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function xr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:l}){if(!e||!o)return Le;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],p=null;for(let v of je(e,r)){let m=v.dataset.messageId;if(!m)continue;let g=v.dataset.scrollAnchor==="true",R=g||u?v.getBoundingClientRect():null;(u&&R?R.bottom>c&&R.top<i.bottom:l.has(m))&&d.push(m),g&&R&&R.top<=c+Me&&(p=m)}return d.length===0&&p===null?Le:{currentAnchorId:p,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function vr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function yr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function Rr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function wr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function Sr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>r.top&&l.top<r.bottom)return o}return null}function Tr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let l=kt(t,o),i=t.getBoundingClientRect().height,c=Nr(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return l-c.start-(u-i)/2-n}if(e==="end")return l-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=l+i,d=o.scrollTop+c.start,p=o.scrollTop+o.clientHeight-c.end;return l>=d&&u<=p?o.scrollTop:l<d?l-c.start-n:u-o.clientHeight+c.end+n}return l-c.start-n}function kt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Oe(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Cr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Xe({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Xe({content:e,spacer:t,viewport:n}){let r=je(e,t),o=It(e),l=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-l.top+i+o.end)}return c}function jr(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function It(e){let t=window.getComputedStyle(e);return{end:ze(t.paddingBlockEnd||t.paddingBottom),start:ze(t.paddingBlockStart||t.paddingTop)}}function Nr(e){let t=e?.parentElement;return t?It(t):{end:0,start:0}}function Er(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return ze(n)}function ze(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Ar({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:p,messageElementsRef:v,modeRef:m,pendingScrollToMessageRef:g,prependRestoreRef:R,scrollMarginRef:A,scrollPreviousItemPeekRef:x,spacerGapRef:C,spacerHeightRef:K,spacerRef:U,viewportRef:G}=e,W=a.useCallback(y=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==y&&(i.current=y,t()),y&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},mr))},[t]),E=a.useCallback(y=>{let w=U.current;if(!w)return;let j=Math.max(0,Math.ceil(y));K.current!==j&&(K.current=j,w.hidden=j===0,w.style.height=`${j}px`,w.style.marginTop=j>0?`${-C.current}px`:"")},[]),$=a.useCallback((y,{behavior:w="auto",autoscrolling:j=!1}={})=>{let O=G.current;if(!O)return;let k=Math.max(0,y);if(Math.abs(O.scrollTop-k)<=Me){O.scrollTop=k,t();return}j&&W(!0),O.scrollTo({top:k,behavior:w}),n()},[t,n,W]),J=a.useCallback(({behavior:y="auto"}={})=>G.current?(E(0),o.current=null,m.current="free-scrolling",$(0,{behavior:y}),r(),!0):!1,[r,$,E]),ae=a.useCallback(({behavior:y="auto"}={})=>{let w=G.current;return w?(E(0),o.current=null,m.current=l.current?"following-bottom":"free-scrolling",$(jr(w),{autoscrolling:!0,behavior:y}),r(),!0):!1},[r,$,E]),D=a.useCallback((y,{align:w="start",behavior:j="auto",scrollMargin:O=A.current}={},{keepPreviousPeek:k=!1}={})=>{let Z=u.current,te=G.current;if(!Z||!te||!Z.contains(y))return!1;let re=Tr({align:w,element:y,scrollMargin:k?O+x.current:O,spacer:U.current,viewport:te}),le=Cr({content:Z,scrollTop:re,spacer:U.current,viewport:te});return E(le),R.current={element:y,viewportTop:Oe(y,te)},m.current=k?"anchored-to-message":"settling-jump",o.current=k?y:null,$(re,{behavior:j}),r(),!0},[r,$,E]),Y=a.useCallback(()=>{let y=o.current;return!y||!y.isConnected||m.current!=="anchored-to-message"?!1:D(y,{align:"start"},{keepPreviousPeek:!0})},[D]),Q=a.useCallback((y,w)=>{let j=v.current.get(y);return j?(d.current=!0,D(j,w)?(g.current=null,!0):(g.current={messageId:y,options:w},!0)):p.current===0?(g.current={messageId:y,options:w},d.current=!0,!0):!1},[D]);return{flushPendingScrollToMessage:a.useCallback(()=>{let y=g.current;if(!y)return!1;let w=v.current.get(y.messageId);return!w||!D(w,y.options)?!1:(g.current=null,d.current=!0,!0)},[D]),reanchorToAnchoredMessage:Y,scrollToElement:D,scrollToEnd:ae,scrollToMessage:Q,scrollToStart:J}}function _t(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(l=>l()))},subscribe:(o,l,i)=>{let c=r.size===0;return r.add(o),c&&l?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function kr(e,t){return _t(e,t)}function Ir(){return _t(Le,Or)}function _r(e,t){return e.start===t.start&&e.end===t.end}function Or(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Pr({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=a.useRef(e),l=a.useRef(!1),i=a.useRef(null),c=a.useRef(!1),u=a.useRef(t),d=a.useRef(0),p=a.useRef(null),v=a.useRef(0),m=a.useRef(e?"following-bottom":"free-scrolling"),g=a.useRef(new Map),R=a.useRef(null),A=a.useRef(null),x=a.useRef(null),C=a.useRef(r),K=a.useRef(!0),U=a.useRef(null),G=a.useRef(n),W=a.useRef(null),E=a.useRef(0),$=a.useRef(0),J=a.useRef(null),ae=a.useRef(null),D=a.useRef(null),Y=a.useRef(null),Q=a.useRef(null),y=a.useRef(null),w=a.useRef(null),j=a.useRef(null),O=a.useRef(new Set),k=a.useRef(new WeakSet);return D.current===null&&(D.current=kr(At,_r)),j.current===null&&(j.current=Ir()),o.current=e,u.current=t,G.current=n,C.current=r,{autoScrollRef:o,autoscrollingRef:l,autoscrollingTimeoutRef:Y,streamingTurnRef:x,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:p,itemCountRef:d,lastScrollTopRef:v,messageElementsRef:g,modeRef:m,pendingScrollFrameRef:W,pendingScrollToMessageRef:R,prependRestoreRef:A,preserveScrollOnPrependRef:K,rootRef:U,scrollEdgeThresholdRef:u,scrollMarginRef:G,scrollPreviousItemPeekRef:C,spacerGapRef:E,spacerHeightRef:$,spacerRef:J,stateFrameRef:ae,stateStore:D.current,viewportRef:Q,visibilityFrameRef:y,visibilityObserverRef:w,visibilityStore:j.current,visibleMessageIdsRef:O,handledScrollAnchorsRef:k}}function ut(e,t){return a.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Mr({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=dr,scrollPreviousItemPeek:r=fr,scrollMargin:o=pr}){let l=Pr({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:p,defaultScrollPositionAppliedRef:v,firstItemRef:m,itemCountRef:g,lastScrollTopRef:R,messageElementsRef:A,modeRef:x,pendingScrollFrameRef:C,pendingScrollToMessageRef:K,prependRestoreRef:U,preserveScrollOnPrependRef:G,rootRef:W,scrollEdgeThresholdRef:E,scrollMarginRef:$,scrollPreviousItemPeekRef:J,spacerGapRef:ae,spacerHeightRef:D,spacerRef:Y,stateFrameRef:Q,stateStore:y,viewportRef:w,visibilityFrameRef:j,visibilityObserverRef:O,visibilityStore:k,visibleMessageIdsRef:Z,handledScrollAnchorsRef:te}=l,re=a.useRef(t);re.current!==t&&(re.current=t,v.current=!1);let le=a.useCallback(f=>{let h=W.current,T=w.current,L=[f.start&&"start",f.end&&"end"].filter(Boolean).join(" "),ce=u.current;for(let H of[h,T])H&&(L?H.setAttribute("data-scrollable",L):H.removeAttribute("data-scrollable"),H.toggleAttribute("data-autoscrolling",ce))},[]),Se=a.useCallback(f=>{let h=w.current?.scrollTop??0,T=h<R.current-Me;R.current=h,c.current&&!f.end&&x.current!=="settling-jump"&&x.current!=="anchored-to-message"?x.current="following-bottom":x.current==="following-bottom"&&f.end&&T&&!u.current&&(x.current="free-scrolling")},[]),X=a.useCallback(()=>{let f=br({content:p.current,scrollEdgeThreshold:E.current,spacer:Y.current,viewport:w.current});Se(f);let h=x.current==="following-bottom"?{...f,end:!1}:f;le(h),y.setSnapshot(h)},[Se,y,le]),ie=a.useCallback(()=>{Q.current===null&&(Q.current=window.requestAnimationFrame(()=>{Q.current=null,X()}))},[X]),F=a.useCallback(()=>{k.hasListeners()&&j.current===null&&(j.current=window.requestAnimationFrame(()=>{j.current=null,k.hasListeners()&&k.setSnapshot(xr({content:p.current,scrollMargin:$.current,scrollPreviousItemPeek:J.current,spacer:Y.current,viewport:w.current,visibleMessageIds:Z.current}))}))},[k]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:M,scrollToElement:V,scrollToEnd:N,scrollToMessage:z,scrollToStart:ee}=Ar({refs:l,commitScrollState:X,scheduleStateCommit:ie,scheduleVisibilitySync:F}),B=a.useCallback(()=>{let f=U.current,h=w.current;if(!f||!h||!f.element.isConnected)return!1;let T=Oe(f.element,h)-f.viewportTop;return Math.abs(T)<=Me?!1:(h.scrollTop+=T,f.viewportTop=Oe(f.element,h),ie(),F(),!0)},[ie,F]),oe=a.useCallback(()=>{let f=p.current,h=w.current;if(!f||!h){U.current=null;return}let T=Sr({content:f,spacer:Y.current,viewport:h});U.current=T?{element:T,viewportTop:Oe(T,h)}:null},[]),me=a.useCallback(()=>{C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,I()&&oe()}))},[oe,I]),ue=a.useCallback(()=>{if(!t||v.current||g.current===0)return!1;let f=!1;if(t==="last-anchor"){let h=p.current,T=w.current,L=h&&T?wr(je(h,Y.current)):null;if(!h||!T||!L)f=N({behavior:"auto"});else{let ce=kt(L,T);f=Xe({content:h,spacer:Y.current,viewport:T})-ce<=T.clientHeight?N({behavior:"auto"}):V(L,{align:"start"},{keepPreviousPeek:!0})}}else f=t==="end"?N({behavior:"auto"}):ee({behavior:"auto"});return f?(v.current=!0,!0):!1},[t,V,N,ee]),he=a.useCallback(()=>{let f=p.current;if(!f)return;let h=je(f,Y.current),T=g.current,L=m.current;g.current=h.length,m.current=h[0]??null,(()=>{if(I())return;if(T===0){if(ue()||h.length>0&&c.current&&N({behavior:"auto"}))return;X(),F();return}let ce=L?h.indexOf(L):-1;if(G.current&&ce>0){B();return}if(h.length>T){let H=vr(h,T);if(H){if(c.current&&x.current==="following-bottom"&&Rr(h,T)){N({behavior:"auto"});return}V(H,{align:"start"},{keepPreviousPeek:!0}),te.current.add(H);return}}if(h.length===T){let H=yr(h,te.current);if(H){V(H,{align:"start"},{keepPreviousPeek:!0}),te.current.add(H);return}}x.current==="following-bottom"&&c.current?N({behavior:"auto"}):(X(),F())})(),oe()},[ue,oe,X,I,B,F,V,N]),ge=a.useCallback(()=>{if(x.current==="following-bottom"&&c.current){N({behavior:"auto"});return}let f=D.current;if(M()){c.current&&f>0&&D.current===0&&N({behavior:"auto"});return}ie(),F()},[M,ie,F,N]),be=a.useCallback(()=>{let f=w.current;if(!(!f||!k.hasListeners())){if(typeof IntersectionObserver>"u"){F();return}O.current||(O.current=new IntersectionObserver(h=>{for(let T of h){let L=T.target.dataset.messageId;L&&(T.isIntersecting?Z.current.add(L):Z.current.delete(L))}F()},{root:f,rootMargin:`${-($.current+J.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),A.current.forEach(h=>{O.current?.observe(h)}),F()}},[F,k]),ke=a.useCallback(()=>{j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),O.current?.disconnect(),O.current=null,Z.current.clear(),k.setSnapshot(Le)},[k]),xe=a.useCallback((f,h,T)=>{if(h){A.current.set(f,h),O.current?.observe(h),F(),K.current?.messageId===f&&me();return}T&&A.current.get(f)===T&&(A.current.delete(f),Z.current.delete(f),O.current?.unobserve(T),F())},[me,F]),ve=a.useCallback(()=>{(x.current==="following-bottom"||x.current==="anchored-to-message"||x.current==="settling-jump")&&(i.current=null,x.current="free-scrolling")},[]),de=a.useCallback(()=>le(y.getSnapshot()),[y,le]),Ie=ut(W,de),Te=ut(w,de),_e=a.useCallback(f=>{p.current=f},[]),Ce=a.useCallback(f=>{Y.current=f,ae.current=Er(f?.parentElement??null)},[]),S=a.useCallback(()=>{X(),F(),oe()},[oe,X,F]),q=a.useMemo(()=>({handleContentChange:he,handleResize:ge,observeVisibility:be,preserveScrollOnPrependRef:G,scrollToEnd:N,scrollToMessage:z,scrollToStart:ee,setContentElement:_e,setRootElement:Ie,setSpacerElement:Ce,setViewportElement:Te,stateStore:y,syncAfterScroll:S,unobserveVisibility:ke,userScrollIntent:ve,viewportRef:w,visibilityStore:k}),[he,ge,be,N,z,ee,_e,Ie,Ce,Te,y,S,ke,ve,k]);return a.useLayoutEffect(()=>{ue()},[ue]),a.useEffect(()=>()=>{Q.current!==null&&(window.cancelAnimationFrame(Q.current),Q.current=null),j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),O.current?.disconnect(),O.current=null},[]),a.useLayoutEffect(()=>{if(e&&x.current==="following-bottom"&&g.current>0){N({behavior:"auto"});return}X()},[e,X,N]),{context:q,registerMessage:xe}}function Lr(e){let t=a.useRef(e);return t.current=e,t}var Ot=a.createContext(null),Pt=a.createContext(null);function Re(){let e=a.useContext(Ot);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function $r(){let e=a.useContext(Pt);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Mt(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=Re();return a.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Lt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=Re(),r=a.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return a.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Dr({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:i,registerMessage:c}=Mr({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(Ot.Provider,{value:i,children:s.jsx(Pt.Provider,{value:c,children:t})})}function Ur({children:e,...t}){let{setRootElement:n}=Re();return s.jsx("div",{ref:n,...t,children:e})}function Fr({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...p}){let{handleResize:v,preserveScrollOnPrependRef:m,setViewportElement:g,syncAfterScroll:R,userScrollIntent:A,viewportRef:x}=Re();m.current=i;let C=a.useCallback(E=>{g(E),Ae(c)?.(E)},[c,g]);function K(E){R(),r?.(E)}function U(E){A(),l?.(E)}function G(E){A(),o?.(E)}function W(E){hr.has(E.key)&&A(),n?.(E)}return a.useEffect(()=>{let E=x.current;if(!E||typeof ResizeObserver>"u")return;let $=0,J=new ResizeObserver(()=>{window.cancelAnimationFrame($),$=window.requestAnimationFrame(v)});return J.observe(E),()=>{window.cancelAnimationFrame($),J.disconnect()}},[v,x]),s.jsx("div",{ref:C,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:W,onScroll:K,onTouchMove:G,onWheel:U,...p,children:t})}function Vr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...l}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=Re(),p=a.useRef(null),v=a.useCallback(m=>{p.current=m,u(m),Ae(n)?.(m)},[n,u]);return a.useLayoutEffect(()=>{let m=p.current;if(!m||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(m,{childList:!0}),()=>g.disconnect()},[i]),a.useEffect(()=>{let m=p.current;if(!m||typeof ResizeObserver>"u")return;let g=0,R=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return R.observe(m),()=>{window.cancelAnimationFrame(g),R.disconnect()}},[c]),s.jsxs("div",{ref:v,role:r??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function Br({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=$r(),l=a.useRef(null),i=a.useCallback(c=>{let u=l.current;l.current=c,e&&o(e,c,u),Ae(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Hr({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:l,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:p}=Re(),v=Lr(r),m=a.useCallback(x=>p.subscribe(x),[p]),g=a.useCallback(()=>{let x=p.getSnapshot();return n==="start"?x.start:x.end},[n,p]),R=a.useSyncExternalStore(m,g,g),A=a.useCallback(x=>{R&&(v.current?.(x),x.defaultPrevented||(x.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,R,v,u,d]);return ar({defaultTagName:"button",props:He({type:i,inert:!R,tabIndex:R?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:A},c),render:o,state:{active:R,direction:n},stateAttributesMapping:{active:x=>({"data-active":x?"true":"false"})}})}var we={Provider:Dr,Root:Ur,Viewport:Fr,Content:Vr,Item:Br,Button:Hr};const zr=we.Provider;function Kr({className:e,...t}){return s.jsx(we.Root,{className:P("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Wr({className:e,...t}){return s.jsx(we.Viewport,{className:P("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function qr({className:e,...t}){return s.jsx(we.Content,{className:P("flex h-max min-h-full flex-col",e),...t})}function Gr({className:e,...t}){return s.jsx(we.Item,{className:P("min-w-0 shrink-0",e),...t})}function Yr({className:e,...t}){return s.jsx(we.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(pe,{...r,type:"button",variant:"outline",size:"icon",className:P("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(tn,{})}):null,...t})}function Jr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function Qr(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const Xr="lobu-spa";function dt(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function $e(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const $o=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:l,agentId:i,conversationId:c}=Ee(),{data:u=[]}=nn(i,{conversationId:c});return s.jsx(Mn,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(Zr,{messages:l,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:Sn,children:s.jsx(Eo,{})})]})})},Zr=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(zr,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(to,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function eo(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const to=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:l}=Lt(),{scrollToMessage:i}=Mt(),c=a.useRef(null);a.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Qr({messageIds:e.map(p=>p.id),scrollTarget:Jr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(Kr,{children:[s.jsx(Wr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(qr,{className:P(qe,Tn),children:[e.map(d=>{const p=n==="runs"&&o?eo(d.id):null;return s.jsx(Gr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===l?"location":void 0,className:P("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===l&&"border-primary"),children:p!=null?s.jsx(go,{message:d,onClick:()=>o?.(p)}):s.jsx(so,{message:d})},d.id)}),t.map(d=>s.jsx(ro,{trip:d},d.id)),s.jsx(oo,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(no,{messages:e,mode:n}):null,s.jsx(Yr,{})]})},no=({messages:e,mode:t})=>{const{scrollToMessage:n}=Mt(),{currentAnchorId:r,visibleMessageIds:o}=Lt(),l=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(p=>p.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(cn,{children:[s.jsx(un,{asChild:!0,children:s.jsxs(pe,{type:"button",variant:"outline",size:"icon",className:P("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",l>0&&"w-auto px-3"),"aria-label":l>0?`Open transcript outline, ${l} ${l===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(dn,{}),l>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[l," waiting"]}):null]})}),s.jsxs(fn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(pe,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:P("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},ro=({trip:e})=>s.jsxs("div",{className:P(qe,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(ln,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),oo=()=>{const{currentSuggestions:e,starters:t,messages:n,running:r,append:o}=Ee(),l=zn(e,t,n.length);return r||l.length===0?null:s.jsx(an,{prompts:l,className:P(qe,n.length===0&&"mt-auto"),onPick:i=>o(i)})},so=({message:e})=>e.role==="user"?s.jsx(lo,{message:e}):e.role==="system"?s.jsx(bo,{message:e}):s.jsx(co,{message:e}),$t=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return s.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=s.jsxs(s.Fragment,{children:[s.jsx(Be,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},lo=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:gt,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(ao,{part:n},$e(e,n)))})}):s.jsx("div",{className:Cn,children:s.jsxs("div",{className:P(Ne,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx($t,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Qe,{text:n.text,renderText:r=>r})},$e(e,n)):null)]})})},ao=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:P(Ne,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(pn,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},Dt=new Set(["question","link-button","tool-approval"]),io="subscription-candidate",co=({message:e})=>{const t=Ge(),{agentId:n,workspaceSlug:r}=Ee(),o=u=>u.type==="tool-call"&&(Dt.has(u.toolName)||t?.toolNames.has(u.toolName)),l=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==io),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=vt(u.result);return d?[d]:[]});return s.jsx("div",{className:gt,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[l.length>0?s.jsx(po,{tools:l,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(uo,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(ho,{part:u},$e(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx($t,{attachment:u},u.id))}):null]})})},uo=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:P(Ne,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(pe,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(mt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(hn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function fo(e){try{return JSON.parse(e)}catch{return null}}function Ut(e){if(Array.isArray(e)){const o=e.flatMap(l=>l?.type==="text"&&typeof l.text=="string"?Ut(l.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?fo(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const l=o&&typeof o=="object"?o.id:null;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?[l]:[]});return r.length>0?r:null}const po=({tools:e,workspaceSlug:t})=>s.jsxs(Ct,{defaultOpen:!1,children:[s.jsx(jt,{children:e.length===1?nt(e[0].args,e[0].toolName)??e[0].toolName:`${e.length} tool calls`}),s.jsx(Et,{children:e.map(n=>{const r=nt(n.args,n.toolName),o=n.args!==void 0&&n.args!==null,l=n.result!==void 0&&n.result!==null,i=Ut(n.result);return s.jsxs(Nt,{icon:mn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:r??n.toolName}),r?s.jsx("span",{className:"text-muted-foreground",children:n.toolName}):null,n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ue(n.args)}):null,l?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ue(n.result)}):null,i&&t?s.jsx(lr,{ownerSlug:t,eventIds:i}):null]},n.toolCallId)})})]}),mo=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const l=JSON.parse(r[0])?.error?.message;typeof l=="string"&&l.trim()&&(t=l,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(bn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},ho=({part:e})=>{const t=Ge();return e.type==="reasoning"?s.jsx(or,{}):e.type==="error"?s.jsx(mo,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Qe,{text:e.text,renderText:n=>s.jsx(gn,{text:n})}):null:e.type!=="tool-call"?null:Dt.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(No,{toolName:e.toolName,args:e.args}):null},go=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:P(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},bo=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:P(Ne,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Qe,{text:t.text,renderText:n=>n})},$e(e,t)):null)})}),xo="/mcp-apps/interaction/index.html";function ft(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const vo=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const l=a.useRef(null),[i,c]=a.useState(48),u=a.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},a.useEffect(()=>{const d=l.current;if(!d?.contentWindow)return;const p=new yn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});p.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),p.oncalltool=async({name:g,arguments:R})=>{const A=await u.current.onToolCall(g,R??{});return{isError:A,content:[{type:"text",text:A?"Action failed.":"Action completed."}]}},p.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),p.addEventListener("initialized",()=>{(async()=>(await p.sendToolInput({arguments:{}}),await p.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:Xr}})))()});const v=new Rn(d.contentWindow,d.contentWindow);p.connect(v).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const m=new MutationObserver(()=>{p.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return m.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{m.disconnect(),v.close()}},[]),s.jsx("iframe",{ref:l,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},yo=new Set(["action"]),Ro=["name","description","identity_md"];function se(e){return e==null||e===""?"":typeof e=="string"?e:Ue(e)}function pt(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Ue(e)}function De(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Ft=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function Ke(e){return e&&Ft.has(e)?"warning":"default"}function We(e,t){return e&&Ft.has(e)?{level:"high",reason:t}:{level:"normal"}}function wo(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(l=>({label:l,before:se(e.current?.[l]),after:se(t[l])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function So(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},l=Object.keys(o).filter(i=>!yo.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:pt(e.current?.[i])}:{},after:pt(o[i])}));return r.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0}),{title:`${De(t)} Automation ${n}`,icon:"automation",impact:We(e.action,"This archives the Automation and stops future runs."),tone:Ke(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function To(e){if(e.resourceKind==="automation")return So(e);if(e.fields&&Object.keys(e.fields).length>0)return wo(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return Pn({...e,action:e.action});if(t){const l=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&se(e.proposal?.[d])!==se(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:se(e.current?.[d])}:{},after:se(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${De(i)} entity ${l}`,icon:"entity",impact:We(e.action,"This deletes the entity."),tone:Ke(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${l} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${l} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const l=Ro.filter(i=>e.proposal?.[i]!==void 0&&se(e.proposal?.[i])!==se(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:se(e.current?.[i])}:{},after:se(e.proposal?.[i])}));o.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${De(r)} agent ${n}`,icon:"agent",impact:We(e.action,"This permanently deletes the agent and its configuration."),tone:Ke(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function Co(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function jo(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const No=({toolName:e,args:t})=>{const n=xn(),r=vn(),{append:o}=Ee(),l=Ge(),i=t??{},c=l?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},p=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const v=i.runId,m=typeof i.status=="string"?i.status:"pending",g=m==="pending",R=To(i),A=m==="confirmed"?"Approved":De(m);u=g?R:{...R,title:`${R.title??"Approval"} · ${A}`,tone:m==="failed"?"warning":"default",blocks:[...R.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${m==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${A}.`,muted:!0}],actions:(R.actions??[]).filter(x=>x.terminal===!1)},g&&(d.manage_operations=x=>{if(x.action==="approve")return ft(C=>n.mutate({run_id:v},C));if(x.action==="reject"){const C=typeof x.reason=="string"?x.reason:void 0;return ft(K=>r.mutate({run_id:v,...C?{reason:C}:{}},K))}return Promise.resolve(!0)})}else if(e==="question"){const v=Array.isArray(i.options)?i.options.filter(m=>typeof m=="string"):[];u=Co(i),d.answer_question=m=>{const g=typeof m.answer=="string"?m.answer:"";return v.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!dt(i.url))return null;const v=i.url;p.add(v),u=jo(i,v)}}return u?s.jsx(vo,{src:xo,title:u.title??"Interaction",renderPayload:u,onToolCall:(v,m)=>d[v]?d[v](m):Promise.resolve(!0),onOpenLink:v=>!p.has(v)||!dt(v)?Promise.resolve(!0):(window.open(v,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Ue(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const Eo=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:l,initialDraft:i,currentSuggestions:c}=Ee(),u=Ao({suggestions:e?null:c}),[d,p]=a.useState(i??""),v=a.useRef(null),m=a.useRef(null),g=kn(_n),R=a.useRef(i??"");a.useEffect(()=>{const C=i??"";if(C===R.current)return;const K=R.current;R.current=C,C!==""&&p(U=>U===""||U===K?C:U)},[i]);const A=a.useRef(d);A.current=d;const x=()=>{e||(t(A.current),p(""),m.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(C=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(Be,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:C.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>l(C.id),children:s.jsx(rn,{className:"h-3 w-3"})})]},C.id))}):null,s.jsx(In,{value:d,onChange:p,onSubmit:x,searchRefs:g,handleRef:m,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:C=>{C.target.files&&o(C.target.files),C.target.value=""}}),s.jsxs(pe,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>v.current?.click(),children:[s.jsx(Be,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(pe,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(on,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(pe,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:x,children:[s.jsx(sn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function Ao({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{$o as A,Lo as L,Mo as R,Xn as h,Gn as s};
|
|
6
|
-
//# sourceMappingURL=agent-thread-
|
|
5
|
+
`).trim()}function Wn(e){const t=[];for(const n of e.matchAll(wt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function Kn(e,t={}){if(typeof e=="string"){const r=at(e);return r?[{type:"text",text:r}]:[]}if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="text"&&typeof o.text=="string"){const l=at(o.text);l&&n.push({type:"text",text:l})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!yt.has(o.name)?n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{},...o.result!==void 0?{result:o.result}:{}}):t.showToolCalls&&o.type==="tool_use"&&typeof o.name=="string"&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.input??{},...o.result!==void 0?{result:o.result}:{}})}return n}function qn(e){const t=[],n=r=>{for(const{name:o,url:l}of Wn(r))t.push({id:`file-${t.length}`,name:o,url:l,isImage:Bn.test(o)})};if(typeof e=="string")return n(e),t.length>0?t:void 0;if(Array.isArray(e)){for(const r of e){if(!r||typeof r!="object")continue;const o=r;if(o.type==="image"&&typeof o.data=="string"){const l=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${l};base64,${o.data}`,isImage:!0})}else o.type==="text"&&typeof o.text=="string"&&n(o.text)}return t.length>0?t:void 0}}function Gn(e,t){if(e.type==="bashExecution"){const r=e.content??{},o=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:"user",parts:[{type:"bash",command:r.command??"",output:r.output??"",exitCode:r.exitCode,cancelled:r.cancelled??!1}],createdAt:o&&!Number.isNaN(o)?o:void 0}}if(e.type!=="message"||e.isVerbose||e.role!=="assistant"&&e.role!=="user"&&e.role!=="system")return null;const n=e.timestamp?new Date(e.timestamp).getTime():void 0;return{id:e.id,role:e.role,parts:Kn(e.content,t),attachments:qn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Qn=[],Jn=[];function Yn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function Xn(e,t){if(e.length===0)return null;const n=[];for(const r of e)if(r.type!=="suggestion"){if(r.type==="agent-error"){n.push({type:"error",text:String(r.error??"Agent reported an error.")});const o=xt(r.errorCode,{...t,provider:r.errorContext?.provider,model:r.errorContext?.model});o&&n.push({type:"tool-call",toolCallId:`error-run-${r.runId}`,toolName:"link-button",args:{label:o.label,url:o.href}});continue}n.push({type:"tool-call",toolCallId:`approval-event-${r.eventId}`,toolName:"tool-approval",args:{runId:r.runId,action:r.action,proposal:r.proposal,current:r.current,fields:r.fields??null,attribution:r.attribution??null,resourceKind:r.resourceKind??null,reason:r.reason??null,status:r.status??"pending",reviewedByName:r.reviewedByName??null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const Zn=3e4,er=3*Zn,tr=15e3;function it(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const ye=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function nr(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:l}=r;if(typeof o!="string"||typeof l!="string")continue;const i=o.trim(),c=l.trim();if(i.length===0||c.length===0)continue;const u=`${i}\0${c}`;n.has(u)||(n.add(u),t.push({title:i,message:c}))}return t.length>0?t:null}function $o({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:l,children:i,initialDraft:c}){const u=Bt(),d=a.useRef(null),p=a.useRef(null),v=a.useRef(!1),m=a.useRef(o),g=a.useRef(!1),R=a.useRef(null);m.current=o;const{data:A,isLoading:x}=Ht(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),T=A?.messages??Qn,W=A?.interactions??Jn,{data:U}=zt(e,{enabled:!!e}),G=U?.starters??Rt,K=!!(U?.showToolCalls??U?.settings?.showToolCalls),[E,$]=a.useState([]),[J,ae]=a.useState(!1),[D,Q]=a.useState([]),[Y,y]=a.useState(null),w=a.useRef(!1);w.current=J;const j=a.useMemo(()=>T.map(I=>Gn(I,{showToolCalls:K})).filter(I=>I!==null),[T,K]),O=a.useRef(!1);a.useEffect(()=>{if(O.current||x||w.current)return;O.current=!0;const I=Xn(W,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});$(I?[...j,I]:j),y(Yn(W))},[e,x,j,W,t]);const k=a.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),Z=a.useCallback(async()=>{if(d.current)return d.current;if(p.current)return p.current;if(!e)throw new Error("No agent selected");const I=(async()=>{const M=await Ze(`${Ve}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n}),timeoutMs:2e4});if(!M.ok)throw await et(M);const V=await M.json(),N=Wt(),z={sessionId:V.agentId,sseUrl:lt(V.sseUrl,Ve,N),messagesUrl:lt(V.messagesUrl,Ve,N)};return d.current=z,z})();p.current=I;try{return await I}catch(M){throw d.current=null,M}finally{p.current=null}},[e,t,n]),te=a.useCallback(async(I,M,V)=>{const N=new AbortController;R.current=N;const z=S=>{$(q=>q.map(f=>f.id===V?{...f,parts:S}:f))};let ee;try{ee=await Z()}catch(S){z([{type:"text",text:`Error: ${S instanceof Error?S.message:"Could not start a session."}`}]);return}let B=await tt(ee.sseUrl,{throwOnFailure:!0});const oe=[];let me=null;const ue=()=>{const S=me;me=null,S?.()},he=S=>{oe.push(S),ue()};let ge=!1,be=null;const ke=new Promise(S=>{be=S});let xe=0,ve=Date.now();const de=S=>{ve=Date.now();const q=Number(S.lastEventId);Number.isFinite(q)&&q>xe&&(xe=q)},Ie=["output","status","complete","closed","agent-error","question","link-button","tool-approval","tool_use"],Ce=S=>{S.addEventListener("open",()=>{ge=!0,be?.()}),S.addEventListener("connected",f=>{de(f),ge||(ge=!0,be?.())}),S.addEventListener("ping",de);const q=f=>h=>{de(h);const C=h;typeof C.data=="string"&&he({kind:f,payload:it(C)})};for(const f of Ie)S.addEventListener(f,q(f));S.addEventListener("error",f=>{const h=f;if(typeof h.data=="string"&&h.data){de(f),he({kind:"error",payload:it(h)});return}S.readyState===EventSource.CLOSED&&he({kind:"error",payload:{error:"Connection closed"}})})};Ce(B);const _e=async()=>{B.close();let S=ee.sseUrl;if(xe){const q=new URL(ee.sseUrl,window.location.origin);q.searchParams.set("since",String(xe)),S=q.toString()}B=await tt(S,{throwOnFailure:!1}),Ce(B),ve=Date.now()};await Promise.race([ke,new Promise(S=>setTimeout(S,1500))]);const Te=()=>{B.close(),ue()};N.signal.addEventListener("abort",Te,{once:!0});try{const S=m.current?.trim(),q=!!S&&!g.current;q&&(g.current=!0);let f;if(M.length>0){const b=new FormData;b.set("content",I),q&&S&&b.set("ephemeralContext",S);for(const _ of M)b.append("files",_,_.name);f={method:"POST",credentials:"include",body:b,timeoutMs:12e4}}else{const b={content:I};q&&S&&(b.ephemeralContext=S),f={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(b),timeoutMs:2e4}}const h=await Ze(ee.messagesUrl,f);if(!h.ok)throw d.current=null,await et(h);let C="",L=Pe,ce=null;const H=[],fe=()=>Hn({textOut:C,statusLine:L,errorText:ce,toolCalls:H});for(z(fe());!N.signal.aborted;){if(oe.length===0){let _;const ne=await Promise.race([new Promise(Fe=>{me=()=>Fe(!0)}),new Promise(Fe=>{_=setTimeout(()=>Fe(!1),tr)})]);_&&clearTimeout(_),!ne&&Date.now()-ve>=er&&(await _e(),k());continue}const b=oe.shift();if(b){if(b.kind==="output")L=null,C+=String(b.payload.content??"");else if(b.kind==="status")L=Pe;else if(b.kind==="complete"){L=null;const _=b.payload.finalText;typeof _=="string"&&_.length>0&&(C=_);const ne=b.payload.suggestions;ne!==void 0&&y(Array.isArray(ne)?nr(ne):null),k(),z(fe());return}else if(b.kind==="closed"){d.current=null;const _=b.payload.reason;L=`Session ended${_?`: ${_}`:""}.`,k(),z(fe());return}else if(b.kind==="error"||b.kind==="agent-error"){L=null,ce=typeof b.payload.error=="string"&&b.payload.error?b.payload.error:"Agent reported an error.";const _=b.payload.errorContext&&typeof b.payload.errorContext=="object"?b.payload.errorContext:void 0,ne=xt(b.payload.errorCode,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin,provider:typeof _?.provider=="string"?_.provider:void 0,model:typeof _?.model=="string"?_.model:void 0});ne&&H.push({type:"tool-call",toolCallId:ye("l"),toolName:"link-button",args:{label:ne.label,url:ne.href}}),k(),z(fe());return}else if(b.kind==="question")H.push({type:"tool-call",toolCallId:ye("q"),toolName:"question",args:{question:b.payload.question??"",options:b.payload.options??[]}});else if(b.kind==="tool_use"){if(L=null,yt.has(b.payload.name??"")){z(fe());continue}const _=b.payload.result_summary,ne=vt(_);if(!K&&!ne){z(fe());continue}H.push({type:"tool-call",toolCallId:b.payload.toolCallId??ye("t"),toolName:K?b.payload.name??"tool":"subscription-candidate",args:K?b.payload.input??{}:null,result:_,isError:b.payload.isError})}else if(b.kind==="link-button")H.push({type:"tool-call",toolCallId:ye("l"),toolName:"link-button",args:{label:b.payload.label??"Open link",url:b.payload.url??""}});else if(b.kind==="tool-approval"){const _=b.payload.runId;if(typeof _!="number")continue;H.push({type:"tool-call",toolCallId:`run-${_}`,toolName:"tool-approval",args:{runId:_,action:b.payload.action??null,proposal:b.payload.proposal??null,current:b.payload.current??null,fields:b.payload.fields??null,attribution:b.payload.attribution??null,resourceKind:b.payload.resourceKind??null}})}z(fe())}}}catch(S){z([{type:"text",text:`Error: ${S instanceof Error?S.message:"Send failed."}`}])}finally{N.signal.removeEventListener("abort",Te),B.close()}},[e,Z,k,K,t]),re=a.useCallback(I=>{const M=I.trim(),V=D.map(B=>B.file);if(!M&&V.length===0||w.current||!e)return;v.current||(v.current=!0,l?.(M||V[0]?.name||""));const N={id:ye("u"),role:"user",parts:M?[{type:"text",text:M}]:[],attachments:D.map(B=>({id:B.id,name:B.name,isImage:B.isImage,imageDataUrl:B.isImage?URL.createObjectURL(B.file):void 0})),createdAt:Date.now()},z=ye("asst"),ee={id:z,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};$(B=>[...B,N,ee]),Q([]),ae(!0),w.current=!0,te(M,V,z).finally(()=>{ae(!1),w.current=!1,R.current=null})},[e,l,D,te]),le=a.useCallback(()=>{R.current?.abort()},[]),Se=a.useCallback(I=>{const M=Array.from(I);Q(V=>[...V,...M.map(N=>({id:crypto.randomUUID(),name:N.name,file:N,isImage:N.type.startsWith("image/")}))])},[]),X=a.useCallback(I=>{Q(M=>M.filter(V=>V.id!==I))},[]),ie=a.useRef(!1);a.useEffect(()=>{if(ie.current)return;const I=Kt(n);I&&(ie.current=!0,re(I))},[n,re]);const F=a.useMemo(()=>({messages:E,running:J,append:re,cancel:le,pendingAttachments:D,addAttachments:Se,removeAttachment:X,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:Y,starters:G}),[E,J,re,le,D,Se,X,c,e,n,t,Y,G]);return r&&x?s.jsx(wn,{}):s.jsx(Je.Provider,{value:F,children:i})}const ct="mx-0.5 inline-flex items-center gap-1 rounded-md bg-accent px-1.5 py-0.5 align-baseline font-medium text-[0.9em] text-accent-foreground no-underline";function rr({refItem:e}){const t=En[e.kind]??qt;return An(e.path)?s.jsxs("span",{className:ct,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(mt,{to:e.path,className:P(ct,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const Ye=({text:e,renderText:t})=>jn(e)?s.jsx(s.Fragment,{children:Nn(e).map((n,r)=>n.type==="ref"?s.jsx(rr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),or=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),St=a.createContext(null),Ct=()=>{const e=a.useContext(St);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},Tt=a.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...l})=>{const[i,c]=Gt({prop:t,defaultProp:n,onChange:r}),u=a.useMemo(()=>({isOpen:i,setIsOpen:c}),[i,c]);return s.jsx(St.Provider,{value:u,children:s.jsx("div",{className:P("not-prose max-w-prose space-y-4",e),...l,children:o})})}),jt=a.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=Ct();return s.jsx(ht,{onOpenChange:o,open:r,children:s.jsxs(Qt,{className:P("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(Jt,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(Yt,{className:P("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),Nt=a.memo(({className:e,icon:t=Zt,label:n,description:r,status:o="complete",children:l,...i})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:P("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[s.jsxs("div",{className:"relative mt-0.5",children:[s.jsx(t,{className:"size-4"}),s.jsx("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-hidden",children:[s.jsx("div",{children:n}),r&&s.jsx("div",{className:"text-muted-foreground text-xs",children:r}),l]})]})}),Et=a.memo(({className:e,children:t,...n})=>{const{isOpen:r}=Ct();return s.jsx(ht,{open:r,children:s.jsx(Xt,{className:P("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})});Tt.displayName="ChainOfThought";jt.displayName="ChainOfThoughtHeader";Nt.displayName="ChainOfThoughtStep";Et.displayName="ChainOfThoughtContent";function sr(e){return{contentIds:e.filter(n=>Number.isSafeInteger(n)&&n>0),sortBy:"date",sortOrder:"asc"}}function lr({ownerSlug:e,eventIds:t}){const n=t.join(","),r=a.useMemo(()=>sr(n.split(",").map(Number)),[n]);return r.contentIds.length===0?null:s.jsx(en,{owner:e,children:({organizationId:o,ownerSlug:l})=>o?s.jsx(Pn,{organizationId:o,ownerSlug:l,filters:r,hideOriginator:!0}):null})}function ar({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let l=He(ir(r,o),t);if(!n)return a.createElement(e,l);if(typeof n=="function")return n(l,r);if(!a.isValidElement(n))return null;let i=n.props,c={...He(l,i),ref:Ae(l.ref,i.ref)};return a.cloneElement(n,c)}function He(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let l=r[o];if(l===void 0)continue;let i=t[o];o==="className"?t[o]=[i,l].filter(Boolean).join(" "):o==="style"?t[o]={...i,...l}:o==="ref"?t[o]=Ae(i,l):ur(o)&&typeof i=="function"&&typeof l=="function"?t[o]=cr(l,i):t[o]=l}}return t}function ir(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],l=t?.[r]?.(o);if(l){Object.assign(n,l);continue}if(r==="slot"){n["data-slot"]=o;continue}let i=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[i]=o?"":void 0:o!=null&&(n[i]=String(o))}return n}function cr(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function ur(e){return/^on[A-Z]/.test(e)}function Ae(...e){let t=e.filter(Boolean);if(t.length!==0)return n=>{for(let r of t)typeof r=="function"?r(n):r&&(r.current=n)}}var dr=8,fr=64,pr=0,Me=.5,mr=180,hr=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),At={start:!1,end:!1},gr=[],Le={currentAnchorId:null,visibleMessageIds:gr};function br({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return At;let o=Xe({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function xr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:l}){if(!e||!o)return Le;let i=o.getBoundingClientRect(),c=i.top+t+n,u=typeof IntersectionObserver>"u",d=[],p=null;for(let v of je(e,r)){let m=v.dataset.messageId;if(!m)continue;let g=v.dataset.scrollAnchor==="true",R=g||u?v.getBoundingClientRect():null;(u&&R?R.bottom>c&&R.top<i.bottom:l.has(m))&&d.push(m),g&&R&&R.top<=c+Me&&(p=m)}return d.length===0&&p===null?Le:{currentAnchorId:p,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function vr(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function yr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function Rr(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor==="true"&&(n+=1,n>1))return!0;return!1}function wr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor==="true")return n}return null}function Sr({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let o of je(e,t)){if(!o.dataset.messageId)continue;let l=o.getBoundingClientRect();if(l.bottom>r.top&&l.top<r.bottom)return o}return null}function Cr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let l=kt(t,o),i=t.getBoundingClientRect().height,c=Nr(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return l-c.start-(u-i)/2-n}if(e==="end")return l-o.clientHeight+i+c.end+n;if(e==="nearest"){let u=l+i,d=o.scrollTop+c.start,p=o.scrollTop+o.clientHeight-c.end;return l>=d&&u<=p?o.scrollTop:l<d?l-c.start-n:u-o.clientHeight+c.end+n}return l-c.start-n}function kt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Oe(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Tr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=Xe({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function Xe({content:e,spacer:t,viewport:n}){let r=je(e,t),o=It(e),l=n.getBoundingClientRect(),i=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-l.top+i+o.end)}return c}function jr(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function It(e){let t=window.getComputedStyle(e);return{end:ze(t.paddingBlockEnd||t.paddingBottom),start:ze(t.paddingBlockStart||t.paddingTop)}}function Nr(e){let t=e?.parentElement;return t?It(t):{end:0,start:0}}function Er(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return ze(n)}function ze(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Ar({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:l,autoscrollingRef:i,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:p,messageElementsRef:v,modeRef:m,pendingScrollToMessageRef:g,prependRestoreRef:R,scrollMarginRef:A,scrollPreviousItemPeekRef:x,spacerGapRef:T,spacerHeightRef:W,spacerRef:U,viewportRef:G}=e,K=a.useCallback(y=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),i.current!==y&&(i.current=y,t()),y&&(c.current=window.setTimeout(()=>{c.current=null,i.current=!1,t()},mr))},[t]),E=a.useCallback(y=>{let w=U.current;if(!w)return;let j=Math.max(0,Math.ceil(y));W.current!==j&&(W.current=j,w.hidden=j===0,w.style.height=`${j}px`,w.style.marginTop=j>0?`${-T.current}px`:"")},[]),$=a.useCallback((y,{behavior:w="auto",autoscrolling:j=!1}={})=>{let O=G.current;if(!O)return;let k=Math.max(0,y);if(Math.abs(O.scrollTop-k)<=Me){O.scrollTop=k,t();return}j&&K(!0),O.scrollTo({top:k,behavior:w}),n()},[t,n,K]),J=a.useCallback(({behavior:y="auto"}={})=>G.current?(E(0),o.current=null,m.current="free-scrolling",$(0,{behavior:y}),r(),!0):!1,[r,$,E]),ae=a.useCallback(({behavior:y="auto"}={})=>{let w=G.current;return w?(E(0),o.current=null,m.current=l.current?"following-bottom":"free-scrolling",$(jr(w),{autoscrolling:!0,behavior:y}),r(),!0):!1},[r,$,E]),D=a.useCallback((y,{align:w="start",behavior:j="auto",scrollMargin:O=A.current}={},{keepPreviousPeek:k=!1}={})=>{let Z=u.current,te=G.current;if(!Z||!te||!Z.contains(y))return!1;let re=Cr({align:w,element:y,scrollMargin:k?O+x.current:O,spacer:U.current,viewport:te}),le=Tr({content:Z,scrollTop:re,spacer:U.current,viewport:te});return E(le),R.current={element:y,viewportTop:Oe(y,te)},m.current=k?"anchored-to-message":"settling-jump",o.current=k?y:null,$(re,{behavior:j}),r(),!0},[r,$,E]),Q=a.useCallback(()=>{let y=o.current;return!y||!y.isConnected||m.current!=="anchored-to-message"?!1:D(y,{align:"start"},{keepPreviousPeek:!0})},[D]),Y=a.useCallback((y,w)=>{let j=v.current.get(y);return j?(d.current=!0,D(j,w)?(g.current=null,!0):(g.current={messageId:y,options:w},!0)):p.current===0?(g.current={messageId:y,options:w},d.current=!0,!0):!1},[D]);return{flushPendingScrollToMessage:a.useCallback(()=>{let y=g.current;if(!y)return!1;let w=v.current.get(y.messageId);return!w||!D(w,y.options)?!1:(g.current=null,d.current=!0,!0)},[D]),reanchorToAnchoredMessage:Q,scrollToElement:D,scrollToEnd:ae,scrollToMessage:Y,scrollToStart:J}}function _t(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(l=>l()))},subscribe:(o,l,i)=>{let c=r.size===0;return r.add(o),c&&l?.(),()=>{r.delete(o),r.size===0&&i?.()}}}}function kr(e,t){return _t(e,t)}function Ir(){return _t(Le,Or)}function _r(e,t){return e.start===t.start&&e.end===t.end}function Or(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((n,r)=>n===t.visibleMessageIds[r])}function Pr({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let o=a.useRef(e),l=a.useRef(!1),i=a.useRef(null),c=a.useRef(!1),u=a.useRef(t),d=a.useRef(0),p=a.useRef(null),v=a.useRef(0),m=a.useRef(e?"following-bottom":"free-scrolling"),g=a.useRef(new Map),R=a.useRef(null),A=a.useRef(null),x=a.useRef(null),T=a.useRef(r),W=a.useRef(!0),U=a.useRef(null),G=a.useRef(n),K=a.useRef(null),E=a.useRef(0),$=a.useRef(0),J=a.useRef(null),ae=a.useRef(null),D=a.useRef(null),Q=a.useRef(null),Y=a.useRef(null),y=a.useRef(null),w=a.useRef(null),j=a.useRef(null),O=a.useRef(new Set),k=a.useRef(new WeakSet);return D.current===null&&(D.current=kr(At,_r)),j.current===null&&(j.current=Ir()),o.current=e,u.current=t,G.current=n,T.current=r,{autoScrollRef:o,autoscrollingRef:l,autoscrollingTimeoutRef:Q,streamingTurnRef:x,contentRef:i,defaultScrollPositionAppliedRef:c,firstItemRef:p,itemCountRef:d,lastScrollTopRef:v,messageElementsRef:g,modeRef:m,pendingScrollFrameRef:K,pendingScrollToMessageRef:R,prependRestoreRef:A,preserveScrollOnPrependRef:W,rootRef:U,scrollEdgeThresholdRef:u,scrollMarginRef:G,scrollPreviousItemPeekRef:T,spacerGapRef:E,spacerHeightRef:$,spacerRef:J,stateFrameRef:ae,stateStore:D.current,viewportRef:Y,visibilityFrameRef:y,visibilityObserverRef:w,visibilityStore:j.current,visibleMessageIdsRef:O,handledScrollAnchorsRef:k}}function ut(e,t){return a.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Mr({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=dr,scrollPreviousItemPeek:r=fr,scrollMargin:o=pr}){let l=Pr({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:i,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:p,defaultScrollPositionAppliedRef:v,firstItemRef:m,itemCountRef:g,lastScrollTopRef:R,messageElementsRef:A,modeRef:x,pendingScrollFrameRef:T,pendingScrollToMessageRef:W,prependRestoreRef:U,preserveScrollOnPrependRef:G,rootRef:K,scrollEdgeThresholdRef:E,scrollMarginRef:$,scrollPreviousItemPeekRef:J,spacerGapRef:ae,spacerHeightRef:D,spacerRef:Q,stateFrameRef:Y,stateStore:y,viewportRef:w,visibilityFrameRef:j,visibilityObserverRef:O,visibilityStore:k,visibleMessageIdsRef:Z,handledScrollAnchorsRef:te}=l,re=a.useRef(t);re.current!==t&&(re.current=t,v.current=!1);let le=a.useCallback(f=>{let h=K.current,C=w.current,L=[f.start&&"start",f.end&&"end"].filter(Boolean).join(" "),ce=u.current;for(let H of[h,C])H&&(L?H.setAttribute("data-scrollable",L):H.removeAttribute("data-scrollable"),H.toggleAttribute("data-autoscrolling",ce))},[]),Se=a.useCallback(f=>{let h=w.current?.scrollTop??0,C=h<R.current-Me;R.current=h,c.current&&!f.end&&x.current!=="settling-jump"&&x.current!=="anchored-to-message"?x.current="following-bottom":x.current==="following-bottom"&&f.end&&C&&!u.current&&(x.current="free-scrolling")},[]),X=a.useCallback(()=>{let f=br({content:p.current,scrollEdgeThreshold:E.current,spacer:Q.current,viewport:w.current});Se(f);let h=x.current==="following-bottom"?{...f,end:!1}:f;le(h),y.setSnapshot(h)},[Se,y,le]),ie=a.useCallback(()=>{Y.current===null&&(Y.current=window.requestAnimationFrame(()=>{Y.current=null,X()}))},[X]),F=a.useCallback(()=>{k.hasListeners()&&j.current===null&&(j.current=window.requestAnimationFrame(()=>{j.current=null,k.hasListeners()&&k.setSnapshot(xr({content:p.current,scrollMargin:$.current,scrollPreviousItemPeek:J.current,spacer:Q.current,viewport:w.current,visibleMessageIds:Z.current}))}))},[k]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:M,scrollToElement:V,scrollToEnd:N,scrollToMessage:z,scrollToStart:ee}=Ar({refs:l,commitScrollState:X,scheduleStateCommit:ie,scheduleVisibilitySync:F}),B=a.useCallback(()=>{let f=U.current,h=w.current;if(!f||!h||!f.element.isConnected)return!1;let C=Oe(f.element,h)-f.viewportTop;return Math.abs(C)<=Me?!1:(h.scrollTop+=C,f.viewportTop=Oe(f.element,h),ie(),F(),!0)},[ie,F]),oe=a.useCallback(()=>{let f=p.current,h=w.current;if(!f||!h){U.current=null;return}let C=Sr({content:f,spacer:Q.current,viewport:h});U.current=C?{element:C,viewportTop:Oe(C,h)}:null},[]),me=a.useCallback(()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,I()&&oe()}))},[oe,I]),ue=a.useCallback(()=>{if(!t||v.current||g.current===0)return!1;let f=!1;if(t==="last-anchor"){let h=p.current,C=w.current,L=h&&C?wr(je(h,Q.current)):null;if(!h||!C||!L)f=N({behavior:"auto"});else{let ce=kt(L,C);f=Xe({content:h,spacer:Q.current,viewport:C})-ce<=C.clientHeight?N({behavior:"auto"}):V(L,{align:"start"},{keepPreviousPeek:!0})}}else f=t==="end"?N({behavior:"auto"}):ee({behavior:"auto"});return f?(v.current=!0,!0):!1},[t,V,N,ee]),he=a.useCallback(()=>{let f=p.current;if(!f)return;let h=je(f,Q.current),C=g.current,L=m.current;g.current=h.length,m.current=h[0]??null,(()=>{if(I())return;if(C===0){if(ue()||h.length>0&&c.current&&N({behavior:"auto"}))return;X(),F();return}let ce=L?h.indexOf(L):-1;if(G.current&&ce>0){B();return}if(h.length>C){let H=vr(h,C);if(H){if(c.current&&x.current==="following-bottom"&&Rr(h,C)){N({behavior:"auto"});return}V(H,{align:"start"},{keepPreviousPeek:!0}),te.current.add(H);return}}if(h.length===C){let H=yr(h,te.current);if(H){V(H,{align:"start"},{keepPreviousPeek:!0}),te.current.add(H);return}}x.current==="following-bottom"&&c.current?N({behavior:"auto"}):(X(),F())})(),oe()},[ue,oe,X,I,B,F,V,N]),ge=a.useCallback(()=>{if(x.current==="following-bottom"&&c.current){N({behavior:"auto"});return}let f=D.current;if(M()){c.current&&f>0&&D.current===0&&N({behavior:"auto"});return}ie(),F()},[M,ie,F,N]),be=a.useCallback(()=>{let f=w.current;if(!(!f||!k.hasListeners())){if(typeof IntersectionObserver>"u"){F();return}O.current||(O.current=new IntersectionObserver(h=>{for(let C of h){let L=C.target.dataset.messageId;L&&(C.isIntersecting?Z.current.add(L):Z.current.delete(L))}F()},{root:f,rootMargin:`${-($.current+J.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),A.current.forEach(h=>{O.current?.observe(h)}),F()}},[F,k]),ke=a.useCallback(()=>{j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),O.current?.disconnect(),O.current=null,Z.current.clear(),k.setSnapshot(Le)},[k]),xe=a.useCallback((f,h,C)=>{if(h){A.current.set(f,h),O.current?.observe(h),F(),W.current?.messageId===f&&me();return}C&&A.current.get(f)===C&&(A.current.delete(f),Z.current.delete(f),O.current?.unobserve(C),F())},[me,F]),ve=a.useCallback(()=>{(x.current==="following-bottom"||x.current==="anchored-to-message"||x.current==="settling-jump")&&(i.current=null,x.current="free-scrolling")},[]),de=a.useCallback(()=>le(y.getSnapshot()),[y,le]),Ie=ut(K,de),Ce=ut(w,de),_e=a.useCallback(f=>{p.current=f},[]),Te=a.useCallback(f=>{Q.current=f,ae.current=Er(f?.parentElement??null)},[]),S=a.useCallback(()=>{X(),F(),oe()},[oe,X,F]),q=a.useMemo(()=>({handleContentChange:he,handleResize:ge,observeVisibility:be,preserveScrollOnPrependRef:G,scrollToEnd:N,scrollToMessage:z,scrollToStart:ee,setContentElement:_e,setRootElement:Ie,setSpacerElement:Te,setViewportElement:Ce,stateStore:y,syncAfterScroll:S,unobserveVisibility:ke,userScrollIntent:ve,viewportRef:w,visibilityStore:k}),[he,ge,be,N,z,ee,_e,Ie,Te,Ce,y,S,ke,ve,k]);return a.useLayoutEffect(()=>{ue()},[ue]),a.useEffect(()=>()=>{Y.current!==null&&(window.cancelAnimationFrame(Y.current),Y.current=null),j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null),O.current?.disconnect(),O.current=null},[]),a.useLayoutEffect(()=>{if(e&&x.current==="following-bottom"&&g.current>0){N({behavior:"auto"});return}X()},[e,X,N]),{context:q,registerMessage:xe}}function Lr(e){let t=a.useRef(e);return t.current=e,t}var Ot=a.createContext(null),Pt=a.createContext(null);function Re(){let e=a.useContext(Ot);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function $r(){let e=a.useContext(Pt);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Mt(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=Re();return a.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Lt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=Re(),r=a.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return a.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Dr({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l}){let{context:i,registerMessage:c}=Mr({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:l});return s.jsx(Ot.Provider,{value:i,children:s.jsx(Pt.Provider,{value:c,children:t})})}function Ur({children:e,...t}){let{setRootElement:n}=Re();return s.jsx("div",{ref:n,...t,children:e})}function Fr({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:l,preserveScrollOnPrepend:i=!0,ref:c,role:u,tabIndex:d,...p}){let{handleResize:v,preserveScrollOnPrependRef:m,setViewportElement:g,syncAfterScroll:R,userScrollIntent:A,viewportRef:x}=Re();m.current=i;let T=a.useCallback(E=>{g(E),Ae(c)?.(E)},[c,g]);function W(E){R(),r?.(E)}function U(E){A(),l?.(E)}function G(E){A(),o?.(E)}function K(E){hr.has(E.key)&&A(),n?.(E)}return a.useEffect(()=>{let E=x.current;if(!E||typeof ResizeObserver>"u")return;let $=0,J=new ResizeObserver(()=>{window.cancelAnimationFrame($),$=window.requestAnimationFrame(v)});return J.observe(E),()=>{window.cancelAnimationFrame($),J.disconnect()}},[v,x]),s.jsx("div",{ref:T,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:K,onScroll:W,onTouchMove:G,onWheel:U,...p,children:t})}function Vr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...l}){let{handleContentChange:i,handleResize:c,setContentElement:u,setSpacerElement:d}=Re(),p=a.useRef(null),v=a.useCallback(m=>{p.current=m,u(m),Ae(n)?.(m)},[n,u]);return a.useLayoutEffect(()=>{let m=p.current;if(!m||(i(),typeof MutationObserver>"u"))return;let g=new MutationObserver(()=>{i()});return g.observe(m,{childList:!0}),()=>g.disconnect()},[i]),a.useEffect(()=>{let m=p.current;if(!m||typeof ResizeObserver>"u")return;let g=0,R=new ResizeObserver(()=>{window.cancelAnimationFrame(g),g=window.requestAnimationFrame(c)});return R.observe(m),()=>{window.cancelAnimationFrame(g),R.disconnect()}},[c]),s.jsxs("div",{ref:v,role:r??"log","aria-relevant":e??"additions",...l,children:[t,s.jsx("div",{ref:d,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:!0,className:o})]})}function Br({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let o=$r(),l=a.useRef(null),i=a.useCallback(c=>{let u=l.current;l.current=c,e&&o(e,c,u),Ae(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:i,"data-message-id":e,"data-scroll-anchor":n?"true":"false",...r})}function Hr({behavior:e="smooth",children:t,direction:n="end",onClick:r,render:o,tabIndex:l,type:i="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:p}=Re(),v=Lr(r),m=a.useCallback(x=>p.subscribe(x),[p]),g=a.useCallback(()=>{let x=p.getSnapshot();return n==="start"?x.start:x.end},[n,p]),R=a.useSyncExternalStore(m,g,g),A=a.useCallback(x=>{R&&(v.current?.(x),x.defaultPrevented||(x.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,R,v,u,d]);return ar({defaultTagName:"button",props:He({type:i,inert:!R,tabIndex:R?l:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:A},c),render:o,state:{active:R,direction:n},stateAttributesMapping:{active:x=>({"data-active":x?"true":"false"})}})}var we={Provider:Dr,Root:Ur,Viewport:Fr,Content:Vr,Item:Br,Button:Hr};const zr=we.Provider;function Wr({className:e,...t}){return s.jsx(we.Root,{className:P("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function Kr({className:e,...t}){return s.jsx(we.Viewport,{className:P("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function qr({className:e,...t}){return s.jsx(we.Content,{className:P("flex h-max min-h-full flex-col",e),...t})}function Gr({className:e,...t}){return s.jsx(we.Item,{className:P("min-w-0 shrink-0",e),...t})}function Qr({className:e,...t}){return s.jsx(we.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(pe,{...r,type:"button",variant:"outline",size:"icon",className:P("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(tn,{})}):null,...t})}function Jr(e){if(!e)return"";const t=e.startsWith("?")?e.slice(1):e,n=new URLSearchParams(t);return n.get("message_id")?.trim()||n.get("message")?.trim()||""}function Yr(e){const t=e.scrollTarget.trim();return t?e.alreadyScrolledTo===t?{scroll:!1}:e.messageIds.includes(t)?{scroll:!0,id:t}:{scroll:!1}:{scroll:!1}}const Xr="lobu-spa";function dt(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function $e(e,t){return t.type==="tool-call"?`tc-${t.toolCallId}`:t.type==="reasoning"?`${e.id}-reasoning`:t.type==="bash"?`${e.id}-bash-${t.command.slice(0,24)}`:t.type==="error"?`${e.id}-error`:`${e.id}-text-${t.text.slice(0,24)}`}const Do=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:l,agentId:i,conversationId:c}=Ee(),{data:u=[]}=nn(i,{conversationId:c});return s.jsx(Mn,{extension:r,children:s.jsxs("div",{"data-agent-thread":!0,className:"flex min-h-0 flex-1 flex-col",children:[s.jsx(Zr,{messages:l,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:Sn,children:s.jsx(Eo,{})})]})})},Zr=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>s.jsx(zr,{autoScroll:!0,defaultScrollPosition:n==="runs"?"last-anchor":"end",scrollPreviousItemPeek:48,children:s.jsx(to,{messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})});function eo(e){if(!e.startsWith("sep:"))return null;const t=Number(e.slice(4));return Number.isFinite(t)&&t>0?t:null}const to=({messages:e,trips:t,mode:n,afterMessagesContent:r,onRunSelect:o})=>{const{currentAnchorId:l}=Lt(),{scrollToMessage:i}=Mt(),c=a.useRef(null);a.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Yr({messageIds:e.map(p=>p.id),scrollTarget:Jr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,i(d.id,{align:"start",behavior:"smooth"}))},[e,i]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(Wr,{children:[s.jsx(Kr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(qr,{className:P(qe,Cn),children:[e.map(d=>{const p=n==="runs"&&o?eo(d.id):null;return s.jsx(Gr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===l?"location":void 0,className:P("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===l&&"border-primary"),children:p!=null?s.jsx(go,{message:d,onClick:()=>o?.(p)}):s.jsx(so,{message:d})},d.id)}),t.map(d=>s.jsx(ro,{trip:d},d.id)),s.jsx(oo,{}),r?s.jsx("div",{className:"mt-auto shrink-0 py-2",children:r}):null]})}),e.length>0?s.jsx(no,{messages:e,mode:n}):null,s.jsx(Qr,{})]})},no=({messages:e,mode:t})=>{const{scrollToMessage:n}=Mt(),{currentAnchorId:r,visibleMessageIds:o}=Lt(),l=t==="runs"?e.flatMap(c=>c.parts).filter(c=>c.type==="tool-call"&&c.toolName==="tool-approval"&&c.args!==null&&typeof c.args=="object"&&c.args.status==="pending").length:0,i=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(p=>p.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return i.length===0?null:s.jsxs(cn,{children:[s.jsx(un,{asChild:!0,children:s.jsxs(pe,{type:"button",variant:"outline",size:"icon",className:P("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",l>0&&"w-auto px-3"),"aria-label":l>0?`Open transcript outline, ${l} ${l===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(dn,{}),l>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[l," waiting"]}):null]})}),s.jsxs(fn,{side:"left",align:"center",className:"w-80 space-y-3 p-3",children:[s.jsxs("div",{className:"px-1",children:[s.jsx("p",{className:"text-sm font-medium",children:"Transcript outline"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:t==="runs"?"Track and jump between Automation runs.":"Track and jump between your messages."})]}),s.jsx("div",{className:"max-h-80 space-y-1 overflow-y-auto",children:i.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(pe,{type:"button",variant:u?"secondary":"ghost",className:"h-auto w-full justify-start gap-2 px-2 py-2 text-left text-xs font-normal","aria-current":u?"location":void 0,onClick:()=>n(c.id,{align:"start",behavior:"smooth"}),children:[s.jsx("span",{className:P("size-1.5 shrink-0 rounded-full bg-muted-foreground/30",d&&"bg-primary/60",u&&"bg-primary")}),s.jsx("span",{className:"line-clamp-2",children:c.label})]},c.id)})})]})]})},ro=({trip:e})=>s.jsxs("div",{className:P(qe,"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive"),children:[s.jsx(ln,{className:"mt-0.5 size-4 shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"font-medium",children:["Guardrail blocked: ",e.guardrailName," ",s.jsxs("span",{className:"font-normal opacity-70",children:["(",e.stage,")"]})]}),e.reason?s.jsx("div",{className:"mt-0.5 break-words opacity-80",children:e.reason}):null]})]}),oo=()=>{const{currentSuggestions:e,starters:t,messages:n,running:r,append:o}=Ee(),l=zn(e,t,n.length);return r||l.length===0?null:s.jsx(an,{prompts:l,className:P(qe,n.length===0&&"mt-auto"),onPick:i=>o(i)})},so=({message:e})=>e.role==="user"?s.jsx(lo,{message:e}):e.role==="system"?s.jsx(bo,{message:e}):s.jsx(co,{message:e}),$t=({attachment:e})=>{const t=e.isImage?e.imageDataUrl??e.url:void 0;if(t)return s.jsx("a",{href:e.url??t,target:"_blank",rel:"noreferrer",children:s.jsx("img",{src:t,alt:e.name,className:"max-h-64 rounded-lg border object-contain"})});const n=s.jsxs(s.Fragment,{children:[s.jsx(Be,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},lo=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:gt,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(ao,{part:n},$e(e,n)))})}):s.jsx("div",{className:Tn,children:s.jsxs("div",{className:P(Ne,"px-3 py-2 text-sm"),children:[e.attachments&&e.attachments.length>0?s.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:e.attachments.map(n=>s.jsx($t,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Ye,{text:n.text,renderText:r=>r})},$e(e,n)):null)]})})},ao=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:P(Ne,"overflow-hidden text-xs"),children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-border/60 border-b px-3 py-1.5",children:[s.jsx(pn,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-foreground/90",children:e.command}),e.cancelled?s.jsx("span",{className:"rounded bg-muted px-1.5 py-0.5 font-medium text-[10px] text-muted-foreground",children:"cancelled"}):t?s.jsxs("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:["exit ",e.exitCode]}):null]}),e.output.trim()?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-foreground/80",children:e.output}):null]})},Dt=new Set(["question","link-button","tool-approval"]),io="subscription-candidate",co=({message:e})=>{const t=Ge(),{agentId:n,workspaceSlug:r}=Ee(),o=u=>u.type==="tool-call"&&(Dt.has(u.toolName)||t?.toolNames.has(u.toolName)),l=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==io),i=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=vt(u.result);return d?[d]:[]});return s.jsx("div",{className:gt,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[l.length>0?s.jsx(po,{tools:l,workspaceSlug:r}):null,n&&r?c.map(u=>s.jsx(uo,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,i.map(u=>s.jsx(ho,{part:u},$e(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx($t,{attachment:u},u.id))}):null]})})},uo=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:P(Ne,"flex items-center justify-between gap-3 p-3"),children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"truncate text-sm font-medium",children:e.label}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this agent when the resource changes."})]}),s.jsx(pe,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(mt,{to:"/$owner/automations/new",params:{owner:n},search:{agent:t,platform:e.connector_key,resource_type:e.resource_type,resource:e.resource_ref,events:e.suggested_event_keys?.join(","),label:e.label},children:[s.jsx(hn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]});function fo(e){try{return JSON.parse(e)}catch{return null}}function Ut(e){if(Array.isArray(e)){const o=e.flatMap(l=>l?.type==="text"&&typeof l.text=="string"?Ut(l.text)??[]:[]);return o.length>0?[...new Set(o)]:null}const t=typeof e=="string"&&e.trimStart().startsWith("{")?fo(e):e;if(!t||typeof t!="object")return null;const n=t.events_persisted;if(!Array.isArray(n))return null;const r=n.flatMap(o=>{const l=o&&typeof o=="object"?o.id:null;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?[l]:[]});return r.length>0?r:null}const po=({tools:e,workspaceSlug:t})=>s.jsxs(Tt,{defaultOpen:!1,children:[s.jsx(jt,{children:e.length===1?nt(e[0].args,e[0].toolName)??e[0].toolName:`${e.length} tool calls`}),s.jsx(Et,{children:e.map(n=>{const r=nt(n.args,n.toolName),o=n.args!==void 0&&n.args!==null,l=n.result!==void 0&&n.result!==null,i=Ut(n.result);return s.jsxs(Nt,{icon:mn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:r??n.toolName}),r?s.jsx("span",{className:"text-muted-foreground",children:n.toolName}):null,n.isError?s.jsx("span",{className:"rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-[10px] text-destructive",children:"error"}):null]}),status:n.isError?"active":"complete",children:[o?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ue(n.args)}):null,l?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ue(n.result)}):null,i&&t?s.jsx(lr,{ownerSlug:t,eventIds:i}):null]},n.toolCallId)})})]}),mo=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const l=JSON.parse(r[0])?.error?.message;typeof l=="string"&&l.trim()&&(t=l,n=e)}catch{}return s.jsxs("div",{className:"flex gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm",children:[s.jsx(bn,{className:"mt-0.5 size-4 shrink-0 text-destructive"}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx("p",{className:"text-foreground/80",children:t}),n&&s.jsxs("details",{className:"text-xs text-muted-foreground",children:[s.jsx("summary",{className:"cursor-pointer select-none hover:text-foreground",children:"Technical details"}),s.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:n})]})]})]})},ho=({part:e})=>{const t=Ge();return e.type==="reasoning"?s.jsx(or,{}):e.type==="error"?s.jsx(mo,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(Ye,{text:e.text,renderText:n=>s.jsx(gn,{text:n})}):null:e.type!=="tool-call"?null:Dt.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(No,{toolName:e.toolName,args:e.args}):null},go=({message:e,onClick:t})=>{const n=e.parts.find(r=>r.type==="text");return s.jsx("button",{type:"button",onClick:t,className:P(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},bo=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:P(Ne,"px-3 py-2 text-xs text-muted-foreground"),children:e.parts.map(t=>t.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(Ye,{text:t.text,renderText:n=>n})},$e(e,t)):null)})}),xo="/mcp-apps/interaction/index.html";function ft(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const vo=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const l=a.useRef(null),[i,c]=a.useState(48),u=a.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},a.useEffect(()=>{const d=l.current;if(!d?.contentWindow)return;const p=new yn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});p.addEventListener("sizechange",({height:g})=>{typeof g=="number"&&c(Math.max(32,Math.ceil(g)))}),p.oncalltool=async({name:g,arguments:R})=>{const A=await u.current.onToolCall(g,R??{});return{isError:A,content:[{type:"text",text:A?"Action failed.":"Action completed."}]}},p.onopenlink=async({url:g})=>({isError:await u.current.onOpenLink(g)}),p.addEventListener("initialized",()=>{(async()=>(await p.sendToolInput({arguments:{}}),await p.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:Xr}})))()});const v=new Rn(d.contentWindow,d.contentWindow);p.connect(v).catch(g=>{console.error("[mcp-app-host] failed to initialize",g)});const m=new MutationObserver(()=>{p.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return m.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{m.disconnect(),v.close()}},[]),s.jsx("iframe",{ref:l,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:i,border:"none",display:"block"}})},yo=new Set(["action"]),Ro=["name","description","identity_md"];function se(e){return e==null||e===""?"":typeof e=="string"?e:Ue(e)}function pt(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Ue(e)}function De(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Ft=new Set(["delete","disconnect","remove","remove_rule","reset","revoke"]);function We(e){return e&&Ft.has(e)?"warning":"default"}function Ke(e,t){return e&&Ft.has(e)?{level:"high",reason:t}:{level:"normal"}}function wo(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(l=>({label:l,before:se(e.current?.[l]),after:se(t[l])}));return{title:`${n} proposes a change`,icon:"entity",impact:{level:"normal"},tone:"default",blocks:o.length>0?[{type:"diff",fields:o}]:[{type:"text",value:"No field changes.",muted:!0}],actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r.join(", ")} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r.join(", ")} was not applied.`}]}}function So(e){const t=e.action??"change",n=e.proposal?.slug??e.proposal?.name??(e.proposal?.automation_id!=null?String(e.proposal.automation_id):void 0)??e.current?.slug??e.current?.name??"automation",r=[];e.action==="delete"&&r.push({type:"text",value:"This will archive the Automation.",muted:!0});const o=e.proposal??{},l=Object.keys(o).filter(i=>!yo.has(i)&&o[i]!==void 0).map(i=>({label:i,...e.action==="update"&&e.current?.[i]!==void 0?{before:pt(e.current?.[i])}:{},after:pt(o[i])}));return r.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0}),{title:`${De(t)} Automation ${n}`,icon:"automation",impact:Ke(e.action,"This archives the Automation and stops future runs."),tone:We(e.action),blocks:r,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${t} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${t} ${n} was not applied.`}]}}function Co(e){if(e.resourceKind==="automation")return So(e);if(e.fields&&Object.keys(e.fields).length>0)return wo(e,e.fields);const t=e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0;if(t&&(e.action==="link"||e.action==="unlink"))return On({...e,action:e.action});if(t){const l=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",i=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&se(e.proposal?.[d])!==se(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:se(e.current?.[d])}:{},after:se(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${De(i)} entity ${l}`,icon:"entity",impact:Ke(e.action,"This deletes the entity."),tone:We(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${i} ${l} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${i} ${l} was not applied.`}]}}const n=e.proposal?.agent_id??e.current?.id??"agent",r=e.action??"change",o=[];if(e.action==="delete")o.push({type:"text",value:"This will permanently delete the agent.",muted:!0});else{const l=Ro.filter(i=>e.proposal?.[i]!==void 0&&se(e.proposal?.[i])!==se(e.current?.[i])).map(i=>({label:i,...e.action==="update"?{before:se(e.current?.[i])}:{},after:se(e.proposal?.[i])}));o.push(l.length>0?{type:"diff",fields:l}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${De(r)} agent ${n}`,icon:"agent",impact:Ke(e.action,"This permanently deletes the agent and its configuration."),tone:We(e.action),blocks:o,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${r} ${n} is being applied.`},{id:"reject",label:"Reject",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Reject this change?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:`Rejected — ${r} ${n} was not applied.`}]}}function To(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function jo(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const No=({toolName:e,args:t})=>{const n=xn(),r=vn(),{append:o}=Ee(),l=Ge(),i=t??{},c=l?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},p=new Set;if(!c){if(e==="tool-approval"&&typeof i.runId=="number"&&Number.isSafeInteger(i.runId)&&i.runId>0){const v=i.runId,m=typeof i.status=="string"?i.status:"pending",g=m==="pending",R=Co(i),A=m==="confirmed"?"Approved":De(m);u=g?R:{...R,title:`${R.title??"Approval"} · ${A}`,tone:m==="failed"?"warning":"default",blocks:[...R.blocks??[],{type:"text",value:typeof i.reviewedByName=="string"?`${m==="rejected"?"Rejected":"Approved"} by ${i.reviewedByName}.`:`${A}.`,muted:!0}],actions:(R.actions??[]).filter(x=>x.terminal===!1)},g&&(d.manage_operations=x=>{if(x.action==="approve")return ft(T=>n.mutate({run_id:v},T));if(x.action==="reject"){const T=typeof x.reason=="string"?x.reason:void 0;return ft(W=>r.mutate({run_id:v,...T?{reason:T}:{}},W))}return Promise.resolve(!0)})}else if(e==="question"){const v=Array.isArray(i.options)?i.options.filter(m=>typeof m=="string"):[];u=To(i),d.answer_question=m=>{const g=typeof m.answer=="string"?m.answer:"";return v.includes(g)?(o(g),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!dt(i.url))return null;const v=i.url;p.add(v),u=jo(i,v)}}return u?s.jsx(vo,{src:xo,title:u.title??"Interaction",renderPayload:u,onToolCall:(v,m)=>d[v]?d[v](m):Promise.resolve(!0),onOpenLink:v=>!p.has(v)||!dt(v)?Promise.resolve(!0):(window.open(v,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Ue(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const Eo=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:l,initialDraft:i,currentSuggestions:c}=Ee(),u=Ao({suggestions:e?null:c}),[d,p]=a.useState(i??""),v=a.useRef(null),m=a.useRef(null),g=kn(_n),R=a.useRef(i??"");a.useEffect(()=>{const T=i??"";if(T===R.current)return;const W=R.current;R.current=T,T!==""&&p(U=>U===""||U===W?T:U)},[i]);const A=a.useRef(d);A.current=d;const x=()=>{e||(t(A.current),p(""),m.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(T=>s.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg border bg-muted/50 px-2 py-1 text-xs",children:[s.jsx(Be,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:T.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>l(T.id),children:s.jsx(rn,{className:"h-3 w-3"})})]},T.id))}):null,s.jsx(In,{value:d,onChange:p,onSubmit:x,searchRefs:g,handleRef:m,placeholder:u,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:T=>{T.target.files&&o(T.target.files),T.target.value=""}}),s.jsxs(pe,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 rounded-full text-muted-foreground hover:text-foreground",onClick:()=>v.current?.click(),children:[s.jsx(Be,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]}),e?s.jsxs(pe,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(on,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(pe,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:x,children:[s.jsx(sn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function Ao({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Do as A,$o as L,Lo as R,Xn as h,Gn as s};
|
|
6
|
+
//# sourceMappingURL=agent-thread-DQIr20H-.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as n,hf as O,hg as P,cB as D,h as p,hh as R,hi as W,v as N,w as E,o as C,au as L,bd as S,r as _,hj as B,hk as F,c0 as G,hl as U,hm as H,gl as z,L as v,gm as A,O as K,t as M,em as T,ar as q}from"./index-4gCDI7m4.js";import{A as J}from"./agent-editor-form-DfMTSIvj.js";import{P as Q}from"./proposal-review-shell-B4CSiyLB.js";function V({identity:e,sections:s,activeSection:t,activeItem:a,onSectionSelect:l,sectionLabel:c,highlightSection:d=!0,className:u}){const o=a??s.find(i=>i.key===t)??s[0];if(!o)return null;const g=o.icon;return n.jsx("div",{className:p("flex shrink-0 flex-col items-center px-4 lg:px-6",u),children:n.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center justify-center gap-x-3 gap-y-2",children:[e,n.jsxs(O,{children:[n.jsx(P,{asChild:!0,children:n.jsxs("button",{type:"button",className:p("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",d?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-label":c,children:[n.jsx(g,{className:"h-3.5 w-3.5 shrink-0"}),o.label,n.jsx(D,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),n.jsx(R,{align:"center",className:"min-w-[11rem]",children:s.map(({key:i,label:m,icon:x})=>n.jsxs(W,{className:p(i===t&&"bg-accent font-medium"),onSelect:()=>l(i),children:[n.jsx(x,{className:"h-4 w-4"}),n.jsx("span",{children:m})]},i))})]})]})})}const b=[{key:"skills",label:"Skills",icon:B},{key:"guardrails",label:"Guardrails",icon:F},{key:"permissions",label:"Permissions",icon:G,adminOnly:!0},{key:"models",label:"Models",icon:U},{key:"settings",label:"Settings",icon:H}];function X(e){return b.filter(s=>!s.adminOnly||e)}function Y(e,s){if(s===`${e}/conversations`||s.startsWith(`${e}/conversations/`))return null;for(const{key:t}of b)if(s===`${e}/${t}`||s.startsWith(`${e}/${t}/`))return t;return s===`${e}/identity`||s===`${e}/identity/`?"settings":null}function Z(e){return e.trim().charAt(0).toUpperCase()||"?"}function ee({owner:e,agentId:s,agentName:t,activeDest:a}){const l=N(),{orgContext:c}=M(),{isAdmin:d}=T(c.organizationId),u=X(!!d),o=a??"settings",g=b.find(i=>i.key===o);return n.jsx(V,{identity:n.jsxs(v,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:s},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:[n.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:Z(t)}),n.jsx("h1",{className:"min-w-0 truncate text-base font-semibold tracking-tight",children:t})]}),sections:u,activeSection:o,activeItem:g,sectionLabel:"Agent section",highlightSection:a!==null,onSectionSelect:i=>{l({to:`/$owner/agents/$agentId/${i}`,params:{owner:e,agentId:s}})}})}function ae({owner:e,agentId:s}){const t=N(),{pathname:a}=E(),{isAuthenticated:l}=C(),{isMember:c}=L(),d=l&&c,{data:u=[],isLoading:o}=S({enabled:d}),g=u.find(k=>k.agentId===s)??null,i=!g&&!o&&d,m=`/${e}/agents/${s}`,x=`${m}/conversations`,f=a===x||a.startsWith(`${x}/`),r=Y(m,a);_.useEffect(()=>{i&&t({to:"/$owner",params:{owner:e},replace:!0})},[i,t,e]);const j=g?.name??"Agent",$=b.find(k=>k.key===r)?.label??"Conversations",h=a.slice(m.length+1).split("/")[1],y=r==="settings"&&!h,I=y?j:h?h==="create"?r==="skills"?"Add a skill":"New custom guardrail":r==="skills"?"Skill details":r==="guardrails"?"Guardrail details":"Conversation":$;return n.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden py-4 md:py-6",children:[n.jsx("div",{className:"mx-auto w-full max-w-3xl px-4 lg:px-6",children:n.jsx(z,{crumbs:[n.jsx(v,{to:"/$owner/agents",params:{owner:e},className:A,children:"Agents"},"agents"),...y?[]:[n.jsx(v,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:s},search:{run_id:void 0},className:A,children:j},"agent")],...h&&r?[n.jsx(v,{to:`/$owner/agents/$agentId/${r}`,params:{owner:e,agentId:s},className:A,children:$},"section")]:[]],current:I})}),n.jsx(ee,{owner:e,agentId:s,agentName:j,activeDest:r}),n.jsx("div",{className:p("flex min-h-0 min-w-0 flex-1 flex-col px-4 lg:px-6",f?"overflow-hidden":"overflow-y-auto"),children:n.jsx(K,{})})]})}function ne({agent:e,tab:s,runId:t}){return n.jsx("div",{className:"mx-auto w-full max-w-3xl pb-6",children:n.jsx(Q,{resource:{kind:"agent",agentId:e.agentId},runId:t,children:({reviewMode:a,proposal:l,controlsDisabled:c})=>n.jsx(J,{mode:{kind:"edit",agent:e},section:s,reviewMode:a,reviewProposal:l,reviewControlsDisabled:c},e.agentId)})})}function oe({owner:e,agentId:s,tab:t,runId:a}){const{orgContext:l,hasOrgContext:c}=M(),{isLoading:d}=q(`/${e}`,l),{isAuthenticated:u}=C(),{isMember:o,isLoading:g}=L(),i=u&&o,{data:m=[],isLoading:x}=S({enabled:i}),w=i?!c||d||x||g:d||g,f=m.find(r=>r.agentId===s)??null;return w||!f?null:n.jsx(ne,{agent:f,tab:t,runId:a})}export{ae as A,oe as a};
|
|
2
|
+
//# sourceMappingURL=agents-workbench-C8bTa2rv.js.map
|