@lobu/runtime-server 20.2.0 → 21.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.json +1 -1
- package/dist/connectors/README.md +15 -16
- package/dist/connectors/github.ts +15 -9
- package/dist/connectors/google_calendar.ts +21 -31
- package/dist/connectors/google_drive.ts +106 -131
- package/dist/connectors/google_gmail.ts +53 -30
- package/dist/connectors/hackernews.ts +2 -5
- package/dist/connectors/jira.ts +62 -27
- package/dist/connectors/linear.ts +55 -21
- package/dist/connectors/microsoft_outlook.ts +151 -110
- package/dist/connectors/postgres.ts +19 -11
- package/dist/connectors/producthunt.ts +8 -6
- package/dist/connectors/reddit.ts +2 -2
- package/dist/connectors/rss.ts +2 -2
- package/dist/connectors/whatsapp_web.ts +5 -4
- package/dist/connectors/x.ts +32 -17
- package/dist/connectors/youtube.ts +18 -5
- package/dist/db/migrations/20260917000000_views.sql +271 -0
- package/dist/db/migrations/20260917000001_views_attach_index.sql +14 -0
- package/dist/db/migrations/20260918000000_runs_turn_tool_event_uniq.sql +51 -0
- package/dist/db/migrations/20260923230000_runs_connector_artifact_hash.sql +32 -0
- package/dist/db/migrations/20260924000000_resource_source_files.sql +17 -0
- package/dist/dependencies.bun.lock +109 -98
- package/dist/guest.bundle.js +78 -10
- package/dist/owletto/dist/assets/_-CwFknmeA.js +1 -0
- package/dist/owletto/dist/assets/_-DrcppoWh.js +2 -0
- package/dist/owletto/dist/assets/_agentId-Cr57JKYx.js +1 -0
- package/dist/owletto/dist/assets/_agentId-HNcmgH56.js +1 -0
- package/dist/owletto/dist/assets/_automationId-BCfrLnUS.js +1 -0
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-BAJGfcy7.js → _connectorKey._connectionId-126-iG9w.js} +1 -1
- package/dist/owletto/dist/assets/{_connectorKey.index-BBF8vGJS.js → _connectorKey.index-CywE9A3N.js} +1 -1
- package/dist/owletto/dist/assets/_conversationId-CNETA_rY.js +1 -0
- package/dist/owletto/dist/assets/_deploymentId-CAVpXf8s.js +1 -0
- package/dist/owletto/dist/assets/_name-BP7OlVxL.js +1 -0
- package/dist/owletto/dist/assets/_owner-D2eh4R90.js +1 -0
- package/dist/owletto/dist/assets/_shape-BqV8tSfw.js +1 -0
- package/dist/owletto/dist/assets/_skillKey-2xTjhL_C.js +1 -0
- package/dist/owletto/dist/assets/_slug-DoIaJBbh.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-8ePnWEg-.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-D8rjUFLV.js +1 -0
- package/dist/owletto/dist/assets/_viewKey-DhVOkzYd.js +1 -0
- package/dist/owletto/dist/assets/accept-invitation-BWRiEUsd.js +1 -0
- package/dist/owletto/dist/assets/activity-route-view-rVdTeVXN.js +1 -0
- package/dist/owletto/dist/assets/{agent-card-controls-CZO6GI0s.js → agent-card-controls-JubkhcHt.js} +1 -1
- package/dist/owletto/dist/assets/{agent-client-setup-list-_chLOorY.js → agent-client-setup-list-Btcy4Cu1.js} +1 -1
- package/dist/owletto/dist/assets/{agent-connect-pages-DWBgSIYT.js → agent-connect-pages-Chfqn8iL.js} +1 -1
- package/dist/owletto/dist/assets/{agent-editor-form-BTNlg0kQ.js → agent-editor-form-BrOkwfg8.js} +1 -1
- package/dist/owletto/dist/assets/{agent-guardrails-route-B5uoMC6o.js → agent-guardrails-route-CHM7JbIl.js} +1 -1
- package/dist/owletto/dist/assets/{agent-loading-shells-CLoLeFcB.js → agent-loading-shells-DsiGx1fn.js} +1 -1
- package/dist/owletto/dist/assets/{agent-permissions-matrix-TP00-MYL.js → agent-permissions-matrix-L_gFvSu1.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skill-context-D4a2QCoZ.js → agent-skill-context-D7tOJ8Pb.js} +1 -1
- package/dist/owletto/dist/assets/{agent-skills-route-KVDDTbJB.js → agent-skills-route-AylS-B9v.js} +1 -1
- package/dist/owletto/dist/assets/{agent-subpage-shell-DuVYZvBE.js → agent-subpage-shell-B7tCQ9zd.js} +1 -1
- package/dist/owletto/dist/assets/agent-thread-DOYh7WLW.js +8 -0
- package/dist/owletto/dist/assets/agents-0ncYwbz6.js +1 -0
- package/dist/owletto/dist/assets/agents-workbench-DOwn78eL.js +1 -0
- package/dist/owletto/dist/assets/app-bridge-BH3g2mKG.js +127 -0
- package/dist/owletto/dist/assets/{app._appId-D0_LQTJU.js → app._appId-fJ_RRn1Z.js} +1 -1
- package/dist/owletto/dist/assets/automation-detail-content-CMprQht5.js +1 -0
- package/dist/owletto/dist/assets/automations-0ncYwbz6.js +1 -0
- package/dist/owletto/dist/assets/{calendar-C0XpOHd8.js → calendar-BbD1N97u.js} +1 -1
- package/dist/owletto/dist/assets/{callback-CO_K9eR-.js → callback-PELM84Lh.js} +1 -1
- package/dist/owletto/dist/assets/{card-DeFQuU_J.js → card-DpLjEqIc.js} +1 -1
- package/dist/owletto/dist/assets/{claim-CUpWOSie.js → claim-BLLvLOBM.js} +1 -1
- package/dist/owletto/dist/assets/clients-Bd8WpHSV.js +1 -0
- package/dist/owletto/dist/assets/{code-editor-BqGUZFt6.js → code-editor-DGJQDoHD.js} +1 -1
- package/dist/owletto/dist/assets/connect-Cx49f4J0.js +1 -0
- package/dist/owletto/dist/assets/connect._clientId-BDFBqKSA.js +1 -0
- package/dist/owletto/dist/assets/connected._clientId-BYGmFRCF.js +1 -0
- package/dist/owletto/dist/assets/{connection-BgAlYjeV.js → connection-B0O8OZuK.js} +1 -1
- package/dist/owletto/dist/assets/{connection-feed-detail-B3ePAinf.js → connection-feed-detail-DZjtoEfm.js} +1 -1
- package/dist/owletto/dist/assets/{connector-provenance-DgsDg0Z9.js → connector-provenance-D_g9gGXU.js} +1 -1
- package/dist/owletto/dist/assets/{connectors-CqPQPo9U.js → connectors-BiMMm_QQ.js} +1 -1
- package/dist/owletto/dist/assets/{consent-bswcIzsf.js → consent-CIzW-960.js} +1 -1
- package/dist/owletto/dist/assets/{core.esm-DsLgjoel.js → core.esm-Ds4Nuq9d.js} +1 -1
- package/dist/owletto/dist/assets/create--fsxroj2.js +1 -0
- package/dist/owletto/dist/assets/create-BqL-ahEf.js +1 -0
- package/dist/owletto/dist/assets/{create-Dwo04oWV.js → create-BvCaqhwK.js} +1 -1
- package/dist/owletto/dist/assets/create-automation-form-DN2w080o.js +2 -0
- package/dist/owletto/dist/assets/{create._connectorKey-CCBb2pil.js → create._connectorKey--qDi1h6S.js} +1 -1
- package/dist/owletto/dist/assets/{cronstrue-ChFyC9ps.js → cronstrue-h8_zIyZD.js} +1 -1
- package/dist/owletto/dist/assets/deployments-BROg1Te8.js +1 -0
- package/dist/owletto/dist/assets/deployments-ICDss7yS.js +1 -0
- package/dist/owletto/dist/assets/deployments-body-DulCUAMt.js +1 -0
- package/dist/owletto/dist/assets/device-kTL2l_cz.js +1 -0
- package/dist/owletto/dist/assets/{device-pin-tombstone-1ikyqSdb.js → device-pin-tombstone-BmD4pv_e.js} +1 -1
- package/dist/owletto/dist/assets/device-rows-BqudjhFu.js +1 -0
- package/dist/owletto/dist/assets/{device._deviceId-DTYKGBY8.js → device._deviceId-CsLJJ6jv.js} +1 -1
- package/dist/owletto/dist/assets/entity-options-ErxYvMDH.js +1 -0
- package/dist/owletto/dist/assets/entity-page-CYRAwUGO.js +1 -0
- package/dist/owletto/dist/assets/entity-type-page-BlAizGlz.js +1 -0
- package/dist/owletto/dist/assets/event-page-DTXPxc-E.js +1 -0
- package/dist/owletto/dist/assets/events-feed-L3c-LLiJ.js +1 -0
- package/dist/owletto/dist/assets/{full-page-spinner-BN2G_YiM.js → full-page-spinner-BxcYpJXx.js} +1 -1
- package/dist/owletto/dist/assets/guardrails-Dh4adTXY.js +1 -0
- package/dist/owletto/dist/assets/identity-B8lKn0je.js +1 -0
- package/dist/owletto/dist/assets/{index-C6VAJ8Ku.js → index--lEHrFE4.js} +1 -1
- package/dist/owletto/dist/assets/{index-hSE2E46p.js → index-13rywWam.js} +1 -1
- package/dist/owletto/dist/assets/{index-C-u4yR8Z.js → index-BRvT0VV9.js} +1 -1
- package/dist/owletto/dist/assets/index-BUp24ZJr.js +1 -0
- package/dist/owletto/dist/assets/index-B_-MLsof.js +1 -0
- package/dist/owletto/dist/assets/index-Bq-q4Y7E.js +1 -0
- package/dist/owletto/dist/assets/index-C8CR2-Ck.css +1 -0
- package/dist/owletto/dist/assets/{index-OUb5Mlez.js → index-CDz3-ieP.js} +10 -10
- package/dist/owletto/dist/assets/index-CFkj9iR_.js +1 -0
- package/dist/owletto/dist/assets/index-CgBgOElA.js +1 -0
- package/dist/owletto/dist/assets/{index-C2oCgDX7.js → index-CheCJomo.js} +1 -1
- package/dist/owletto/dist/assets/index-CpiW66xK.js +1 -0
- package/dist/owletto/dist/assets/index-DAv5S2aK.js +1 -0
- package/dist/owletto/dist/assets/index-DBi2Xr3i.js +1 -0
- package/dist/owletto/dist/assets/index-DHOha5OJ.js +1 -0
- package/dist/owletto/dist/assets/index-DdGjY1Hb.js +7898 -0
- package/dist/owletto/dist/assets/index-Dkyl7l6E.js +1 -0
- package/dist/owletto/dist/assets/{index-vdqhlocx.js → index-QcHQZI87.js} +1 -1
- package/dist/owletto/dist/assets/index-kq4537-S.js +1 -0
- package/dist/owletto/dist/assets/{json-diff-DnsW7Pin.js → json-diff-BV2STDGj.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-CHzLN7GK.js → list-skeleton-CT5n4ND_.js} +1 -1
- package/dist/owletto/dist/assets/login-DKsgABYt.js +1 -0
- package/dist/owletto/dist/assets/logout-D_CP-emw.js +1 -0
- package/dist/owletto/dist/assets/member-scope-gate-BTgmlfFJ.js +1 -0
- package/dist/owletto/dist/assets/memory-browse-page-FHaJC3ML.js +101 -0
- package/dist/owletto/dist/assets/missing-view-Bve6pJP-.js +1 -0
- package/dist/owletto/dist/assets/{model-selector-DfbmHjLu.js → model-selector-BLCEahny.js} +1 -1
- package/dist/owletto/dist/assets/models-C4N7LQAW.js +1 -0
- package/dist/owletto/dist/assets/new-BAIGSdfp.js +1 -0
- package/dist/owletto/dist/assets/{new-Df_dY6Z5.js → new-CirOK0Sw.js} +1 -1
- package/dist/owletto/dist/assets/new-DzapH2sV.js +1 -0
- package/dist/owletto/dist/assets/{oauth-workspace-access-D9GmiMfK.js → oauth-workspace-access-BF7jaswv.js} +1 -1
- package/dist/owletto/dist/assets/{organization-uSDYkJpX.js → organization-D9RPsWG-.js} +1 -1
- package/dist/owletto/dist/assets/{permissions-Fe0DP6b8.js → permissions-BlRONw-u.js} +1 -1
- package/dist/owletto/dist/assets/{proposal-review-shell-D9HwnDda.js → proposal-review-shell-uskeFIUr.js} +1 -1
- package/dist/owletto/dist/assets/{recent-C03LhMD7.js → recent-CmJ4Is6V.js} +1 -1
- package/dist/owletto/dist/assets/{renderer-CHNejd95.js → renderer-Dyf4t8kR.js} +2 -2
- package/dist/owletto/dist/assets/{reset-password-CuISnlG_.js → reset-password-BVIeE1Zm.js} +1 -1
- package/dist/owletto/dist/assets/runs-CzBeUzlQ.js +1 -0
- package/dist/owletto/dist/assets/{runs-panel-DsdESupx.js → runs-panel-D7l1uLGm.js} +1 -1
- package/dist/owletto/dist/assets/runs-table-dATyiBg2.js +1 -0
- package/dist/owletto/dist/assets/{schema-value-normalization-B--OWDL8.js → schema-value-normalization-DgMkyVVE.js} +1 -1
- package/dist/owletto/dist/assets/settings-BK1GHmzb.js +1 -0
- package/dist/owletto/dist/assets/{settings-wGNHtsDP.js → settings-Co1wj_m6.js} +1 -1
- package/dist/owletto/dist/assets/skills-DF53JcYt.js +1 -0
- package/dist/owletto/dist/assets/{switch-Dzse_XFM.js → switch-DDkPrV3p.js} +1 -1
- package/dist/owletto/dist/assets/use-applied-views-DELwQQh7.js +1 -0
- package/dist/owletto/dist/assets/{use-mention-search-uyW1Uwf6.js → use-mention-search-CGA3AaKm.js} +1 -1
- package/dist/owletto/dist/assets/view-frame-DDr-Xtet.js +1 -0
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +6703 -3581
- package/npm-shrinkwrap.json +530 -472
- package/package.json +5 -2
- package/vendor/connector-sdk/dist/connector-runtime.d.ts +4 -6
- package/vendor/connector-sdk/dist/connector-runtime.js +3 -5
- package/vendor/connector-sdk/dist/connector-types.d.ts +28 -13
- package/vendor/connector-sdk/dist/define-connector.d.ts +4 -1
- package/vendor/connector-sdk/dist/define-connector.js +4 -1
- package/vendor/connector-sdk/dist/http-client.d.ts +18 -7
- package/vendor/connector-sdk/dist/http-client.js +15 -13
- package/vendor/connector-sdk/dist/index.d.ts +1 -1
- package/vendor/connector-sdk/dist/retry.d.ts +15 -3
- package/vendor/connector-sdk/dist/retry.js +40 -64
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/dist/agent-policy.js +3 -0
- package/vendor/core/dist/connector-query-errors.d.ts +3 -3
- package/vendor/core/dist/connector-query-errors.js +8 -3
- package/vendor/core/dist/contracts/tools/manage-connections.d.ts +24 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +13 -0
- package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +15 -25
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +3 -5
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +11 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +12 -1
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +47 -6
- package/vendor/core/dist/contracts/tools/manage-operations.js +36 -1
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +293 -0
- package/vendor/core/dist/contracts/tools/manage-views.js +203 -0
- package/vendor/core/dist/contracts/tools/source-files-schema.d.ts +7 -0
- package/vendor/core/dist/contracts/tools/source-files-schema.js +19 -0
- package/vendor/core/dist/contracts/tools/source-files.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/source-files.js +55 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +37 -0
- package/vendor/core/dist/contracts/tools/view-content-hash.js +58 -0
- package/vendor/core/dist/contracts/tools/view-path.d.ts +18 -0
- package/vendor/core/dist/contracts/tools/view-path.js +24 -0
- package/vendor/core/dist/contracts/worker/protocol.d.ts +73 -8
- package/vendor/core/dist/contracts/worker/protocol.js +58 -9
- package/vendor/core/dist/reserved.d.ts +3 -3
- package/vendor/core/dist/reserved.js +9 -1
- package/vendor/core/dist/utils/secret-redaction.js +2 -0
- package/vendor/core/package.json +25 -5
- package/vendor/views/dist/api.d.ts +179 -0
- package/vendor/views/dist/api.js +406 -0
- package/vendor/views/dist/bridge.d.ts +141 -0
- package/vendor/views/dist/bridge.js +330 -0
- package/vendor/views/dist/index.d.ts +12 -0
- package/vendor/views/dist/index.js +10 -0
- package/vendor/views/package.json +35 -0
- package/dist/owletto/dist/assets/_-Ds4DyQjj.js +0 -2
- package/dist/owletto/dist/assets/_-VmyR6aN_.js +0 -1
- package/dist/owletto/dist/assets/_agentId-BAVnp0c7.js +0 -1
- package/dist/owletto/dist/assets/_agentId-Df-3rGi5.js +0 -1
- package/dist/owletto/dist/assets/_automationId-D696vOjd.js +0 -1
- package/dist/owletto/dist/assets/_conversationId-Ci4rgrHm.js +0 -1
- package/dist/owletto/dist/assets/_deploymentId-Iy-D5PDq.js +0 -1
- package/dist/owletto/dist/assets/_name-CeGwb0oK.js +0 -1
- package/dist/owletto/dist/assets/_owner-CFR1G8OX.js +0 -1
- package/dist/owletto/dist/assets/_skillKey-DuLcQWBu.js +0 -1
- package/dist/owletto/dist/assets/_slug-CDSO20ac.js +0 -1
- package/dist/owletto/dist/assets/accept-invitation-Db5jklHT.js +0 -1
- package/dist/owletto/dist/assets/activity-route-view-DVW3DoB7.js +0 -1
- package/dist/owletto/dist/assets/agent-thread-CzCJU3-R.js +0 -134
- package/dist/owletto/dist/assets/agents-DFs57C3c.js +0 -1
- package/dist/owletto/dist/assets/agents-workbench-C2bUlJP2.js +0 -1
- package/dist/owletto/dist/assets/automation-detail-content-DWkdhnv2.js +0 -1
- package/dist/owletto/dist/assets/automations-DFs57C3c.js +0 -1
- package/dist/owletto/dist/assets/clients-DhYr4lyL.js +0 -1
- package/dist/owletto/dist/assets/connect-Dtb-E5An.js +0 -1
- package/dist/owletto/dist/assets/connect._clientId-DWtceAAw.js +0 -1
- package/dist/owletto/dist/assets/connected._clientId-CMe-wTuV.js +0 -1
- package/dist/owletto/dist/assets/create-CcXUdke7.js +0 -1
- package/dist/owletto/dist/assets/create-Cp6hMoeU.js +0 -1
- package/dist/owletto/dist/assets/create-automation-form-CJ4meayB.js +0 -1
- package/dist/owletto/dist/assets/deployments-CjfFxyDA.js +0 -1
- package/dist/owletto/dist/assets/deployments-body-Cg0KiWGr.js +0 -1
- package/dist/owletto/dist/assets/device-DpY67Jaj.js +0 -1
- package/dist/owletto/dist/assets/device-rows-Cp3yMcuV.js +0 -1
- package/dist/owletto/dist/assets/entity-options-1EaSGMX4.js +0 -1
- package/dist/owletto/dist/assets/entity-page-DJmM70dv.js +0 -1
- package/dist/owletto/dist/assets/entity-type-page-C3mT7tXn.js +0 -1
- package/dist/owletto/dist/assets/events-feed-iliGfjit.js +0 -1
- package/dist/owletto/dist/assets/guardrails-CLlnRRy9.js +0 -1
- package/dist/owletto/dist/assets/identity-MSLryUi8.js +0 -1
- package/dist/owletto/dist/assets/index-3o4Eepb4.js +0 -1
- package/dist/owletto/dist/assets/index-BUr8321-.js +0 -7898
- package/dist/owletto/dist/assets/index-Bulu5ldM.js +0 -1
- package/dist/owletto/dist/assets/index-BvbfITqH.js +0 -1
- package/dist/owletto/dist/assets/index-ChcQMdod.css +0 -1
- package/dist/owletto/dist/assets/index-Clw9ZBj-.js +0 -1
- package/dist/owletto/dist/assets/index-D2oL4Ydo.js +0 -1
- package/dist/owletto/dist/assets/index-D7wulT4y.js +0 -1
- package/dist/owletto/dist/assets/index-DOLFe19K.js +0 -1
- package/dist/owletto/dist/assets/index-DTSA0Xh1.js +0 -1
- package/dist/owletto/dist/assets/index-DxXXVPU0.js +0 -1
- package/dist/owletto/dist/assets/index-nzvsA3hT.js +0 -1
- package/dist/owletto/dist/assets/login-CCKNM0gV.js +0 -1
- package/dist/owletto/dist/assets/logout-B-N2aodZ.js +0 -1
- package/dist/owletto/dist/assets/member-scope-gate-B560Wg-t.js +0 -1
- package/dist/owletto/dist/assets/memory-browse-page-DMDqKJn7.js +0 -101
- package/dist/owletto/dist/assets/models-M51OGDRE.js +0 -1
- package/dist/owletto/dist/assets/new-BVQS9H-Y.js +0 -1
- package/dist/owletto/dist/assets/new-DxDVE9nL.js +0 -1
- package/dist/owletto/dist/assets/runs-BnYdToDc.js +0 -1
- package/dist/owletto/dist/assets/runs-table-B7jKuILd.js +0 -1
- package/dist/owletto/dist/assets/settings-Bg9yCCoN.js +0 -1
- package/dist/owletto/dist/assets/skills-CN5Ube7A.js +0 -1
- package/vendor/core/dist/contracts/tools/manage-view-templates.d.ts +0 -165
- package/vendor/core/dist/contracts/tools/manage-view-templates.js +0 -130
package/dist/owletto/dist/assets/{agent-skill-context-D4a2QCoZ.js → agent-skill-context-D7tOJ8Pb.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as p,
|
|
1
|
+
import{r as p,aO as B,dQ as ge,dR as pe,gt as be,aG as F,j as ve}from"./index-DdGjY1Hb.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-Ds4Nuq9d.js";import{s as De,b as Ee}from"./skill-editor-D_W3QlRz.js";function G(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 Oe(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=G(n,r,t),o=n[s],a=u[s];return!a||!o?null:{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.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 a=(n=u[t])!=null?n:r;if(!a)return null;if(s===t){const f=u[o];return f?{x:0,y:t<o?f.top+f.height-(a.top+a.height):f.top-a.top,...M}:null}const m=Ne(u,s,t);return s>t&&s<=o?{x:0,y:-a.height-m,...M}:s<t&&s>=o?{x:0,y:a.height+m,...M}:{x:0,y:0,...M}};function Ne(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",Q=B.createContext({activeIndex:-1,containerId:W,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:V,disabled:{draggable:!1,droppable:!1}});function Qe(e){let{children:n,id:t,items:r,strategy:s=V,disabled:u=!1}=e;const{active:o,dragOverlay:a,droppableRects:m,over:f,measureDroppableContainers:i}=Ie(),l=Se(W,t),b=a.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=Oe(u);Y(()=>{I&&k&&i(h)},[I,h,k,i]),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 B.createElement(Q.Provider,{value:g},n)}const Pe=e=>{let{id:n,items:t,activeIndex:r,overIndex:s}=e;return G(t,r,s).indexOf(n)},Me=e=>{let{containerId:n,isSorting:t,wasDragging:r,index:s,items:u,newIndex:o,previousItems:a,previousContainerId:m,transition:f}=e;return!f||!r||a!==u&&s===o?!1:t?!0:o!==s&&n===m},je={duration:200,easing:"ease"},J="transform",$e=H.Transition.toString({property:J,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),a=p.useRef(t);return Y(()=>{if(!n&&t!==a.current&&r.current){const m=s.current;if(m){const f=Ae(r.current,{ignoreTransform:!0}),i={x:m.left-f.left,y:m.top-f.top,scaleX:m.width/f.width,scaleY:m.height/f.height};(i.x||i.y)&&o(i)}}t!==a.current&&(a.current=t)},[n,t,r,s]),p.useEffect(()=>{u&&o(null)},[u]),u}function Je(e){let{animateLayoutChanges:n=Me,attributes:t,disabled:r,data:s,getNewIndex:u=Pe,id:o,strategy:a,resizeObserverConfig:m,transition:f=je}=e;const{items:i,containerId:l,activeIndex:b,disabled:h,disableTransforms:k,sortedRects:w,overIndex:C,useDragOverlay:R,strategy:I}=p.useContext(Q),S=Ge(r,h),c=i.indexOf(o),g=p.useMemo(()=>({sortable:{containerId:l,index:c,items:i},...s}),[l,s,c,i]),d=p.useMemo(()=>i.slice(i.indexOf(o)),[i,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:K,listeners:se,isDragging:$,over:oe,setActivatorNodeRef:ae,transform:ie}=ye({id:o,data:g,attributes:{...ze,...t},disabled:S.draggable}),le=we(L,K),T=!!D,U=T&&!k&&P(b)&&P(C),X=!R&&$,_=X&&U?ie:null,ce=U?_??(a??I)({rects:w,activeNodeRect:ne,activeIndex:b,overIndex:C,index:c}):null,N=P(b)&&P(C)?u({id:o,items:i,activeIndex:b,overIndex:C}):c,O=D?.id,x=p.useRef({activeId:O,items:i,newIndex:N,containerId:l}),ue=i!==x.current.items,q=n({active:D,containerId:l,isDragging:$,isSorting:T,id:o,index:c,items:i,newIndex:x.current.newIndex,previousItems:x.current.items,previousContainerId:x.current.containerId,transition:f,wasDragging:x.current.activeId!=null}),z=Fe({disabled:!q,index:c,node:y,rect:v});return p.useEffect(()=>{T&&x.current.newIndex!==N&&(x.current.newIndex=N),l!==x.current.containerId&&(x.current.containerId=l),i!==x.current.items&&(x.current.items=i)},[T,N,l,i]),p.useEffect(()=>{if(O===x.current.activeId)return;if(O!=null&&x.current.activeId==null){x.current.activeId=O;return}const fe=setTimeout(()=>{x.current.activeId=O},50);return()=>clearTimeout(fe)},[O]),{active:D,activeIndex:b,attributes:re,data:g,rect:v,index:c,newIndex:N,items:i,isOver:A,isSorting:T,isDragging:$,listeners:se,node:y,overIndex:C,over:oe,setNodeRef:le,setActivatorNodeRef:ae,setDroppableNodeRef:L,setDraggableNodeRef:K,transform:z??ce,transition:de()};function de(){if(z||ue&&x.current.newIndex===c)return $e;if(!(X&&!Re(te)||!f)&&(T||q))return H.Transition.toString({...f,property:J})}}function Ge(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 Ke=[E.Down,E.Right,E.Up,E.Left],Ze=(e,n)=>{let{context:{active:t,collisionRect:r,droppableRects:s,droppableContainers:u,over:o,scrollableAncestors:a}}=n;if(Ke.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 i=he(f,"id");if(i===o?.id&&f.length>1&&(i=f[1].id),i!=null){const l=u.get(t.id),b=u.get(i),h=b?s.get(b.id):null,k=b?.node.current;if(k&&h&&l&&b){const C=xe(k).some((d,v)=>a[v]!==d),R=Z(l,b),I=Ue(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 Ue(e,n){return!j(e)||!j(n)||!Z(e,n)?!1:e.data.current.sortable.index<n.data.current.sortable.index}function Xe(e){return{skillsConfig:De(e)}}function _e(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:_e(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 qe(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),a=p.useMemo(()=>t?Ee(t,s?.catalog??[]):[],[t,s]),[m,f]=p.useState(null),i=m??a,l=p.useCallback(async(c,g)=>{if(!t)return F.error("Still loading agent settings — try again in a moment"),!1;try{const d=Xe(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??a;return v.some(y=>y.repo===c)?v:[...v,qe(g)]})},[a,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??a;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},[a]),k=p.useCallback((c,g)=>{f(d=>(d??a).map(v=>v.repo===c?{...v,...g}:v))},[a]),w=p.useCallback((c,g)=>{f(d=>{const v=d??a,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=G(v,y,A);return l(L,"Skill order updated"),L})},[l,a]),C=p.useCallback(async c=>{const g=i.filter(d=>d.repo!==c);return f(g),l(g,"Skill removed")},[l,i]),R=p.useCallback(async(c,g)=>{const d=i.map(v=>v.repo===c?{...v,enabled:g}:v);return f(d),l(d,g?"Skill enabled":"Skill disabled")},[l,i]),I=p.useCallback(async()=>{await l(i,"Skills saved")},[l,i]),S=p.useMemo(()=>({agentId:e,skillRows:i,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,i,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,Qe as S,Ze as a,et as b,Je as c,tt as f,_e as s,rt as u,We as v};
|
package/dist/owletto/dist/assets/{agent-skills-route-KVDDTbJB.js → agent-skills-route-AylS-B9v.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a2 as A,r as u,j as e,P as F,aa as C,ab as K,ea as P,c2 as G,B as N,aj as E,aS as H,eG as z,eH as Q,bm as Y,gi as V,cu as X,hv as q}from"./index-BUr8321-.js";import{a as J,A as U}from"./agent-subpage-shell-DuVYZvBE.js";import{u as $,b as W,f as Z,s as ee,a as se,S as te,v as ae,c as le}from"./agent-skill-context-D4a2QCoZ.js";import{f as ne}from"./agent-loading-shells-CLoLeFcB.js";import{u as ie,a as L,m as oe,P as re,D as ce,n as de,C as me}from"./core.esm-DsLgjoel.js";import{A as ue}from"./agent-card-controls-CZO6GI0s.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 ge({owner:s,agentId:t,onBack:a,backLabel:n="Skills"}){const o=A(),[i,g]=u.useState(""),[k,h]=u.useState(!1),[r,p]=u.useState(""),[m,v]=u.useState(""),{skillRows:c,catalog:x,isLoading:S,addSkillFromCatalog:y,addCustomSkill:b}=$(),l=u.useMemo(()=>new Set(c.map(d=>d.repo)),[c]),f=u.useMemo(()=>W(x?.catalog??[],l),[x?.catalog,l]),j=u.useMemo(()=>Z(f,i),[f,i]),R=d=>{y(d),o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:w(d)}})},O=()=>{const d=b({name:r,instructions:m});d&&o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:w(d)}})},_=a?e.jsx(J,{title:"Add a skill",description:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own.",onBack:a,backLabel:n}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Add a skill"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own."})]});return e.jsxs("div",{className:"space-y-6",children:[_,e.jsx("div",{className:E(H,"w-full"),children:k?e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-name",children:"Name"}),e.jsx(K,{id:"custom-skill-name",value:r,onChange:d=>p(d.target.value),placeholder:"my-skill"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-instructions",children:"Instructions"}),e.jsx(P,{id:"custom-skill-instructions",value:m,onChange:d=>v(d.target.value),placeholder:"Instructions for the agent when this skill is active...",rows:3})]})]}),e.jsx(G,{onCancel:()=>h(!1),children:e.jsx(N,{type:"button",size:"sm",onClick:O,disabled:!r.trim(),children:"Add custom skill"})})]}):e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 p-3 text-left text-muted-foreground transition-colors hover:text-foreground",onClick:()=>h(!0),children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Create custom skill"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define instructions and packages"})]})]})}),S?e.jsx(z,{}):e.jsx(Q,{items:j,searchQuery:i,onSearchChange:g,onSelect:d=>R(d.key),searchPlaceholder:"Search skills...",searchAriaLabel:"Search skills",emptyMessage:i.trim()?`No skills match "${i}"`:f.length===0?"All catalog skills are already configured":"No skills available"})]})}function xe({row:s}){const{isSaving:t,updateSkillRow:a}=$(),n=s.system===!0;return e.jsx("div",{className:"space-y-6",children:n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"System skill metadata is managed by Lobu. You can enable or disable it and change its position in the skill list."}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-name",children:"Name"}),e.jsx(K,{id:"skill-name",value:s.name,onChange:o=>a(s.repo,{name:o.target.value}),disabled:t})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-instructions",children:"Instructions"}),e.jsx(P,{id:"skill-instructions",value:s.instructions??"",onChange:o=>{const i=o.target.value;a(s.repo,{instructions:i,content:i.trim()||s.name})},rows:4,disabled:t})]})]})})}function he({owner:s,agentId:t,skillKey:a}){const n=A(),[o,i]=u.useState(!1),g=B(a),{skillRows:k,catalog:h,isSaving:r,saveSkills:p,removeSkillAndSave:m,addSkillFromCatalog:v}=$(),c=k.find(b=>b.repo===g)??null,x=h?.catalog.find(b=>b.repo===g);u.useEffect(()=>{!c&&x&&v(g)},[v,x,g,c]);const S=async()=>{await m(g)&&(i(!1),n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}}))};if(!c)return x?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skill not found."});const y=!c.system;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{row:c}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-end",children:[y?o?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"button",variant:"destructive",onClick:()=>void S(),disabled:r,children:r?"Removing...":"Remove skill"}),e.jsx(N,{type:"button",variant:"outline",onClick:()=>i(!1),disabled:r,children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>i(!0),disabled:r,children:["Remove ",c.name]}):null,e.jsx(N,{type:"button",onClick:()=>void p(),disabled:r||o,children:r?"Saving...":"Save changes"})]})]})}function fe(s){return s.map(t=>{const a=ee(t).map(String);return{id:t.repo,repo:t.repo,name:t.name,description:t.description,badges:a,enabled:t.enabled}})}const D="Skills bundle instructions, tools, and knowledge an agent can reuse. Add one from the catalog or write your own; drag to set which the agent reaches for first.";function M({owner:s,agentId:t,expandedRepo:a}){const n=A(),{skillRows:o,catalog:i,isLoading:g,isSaving:k,reorderSkills:h,setSkillEnabledAndSave:r,addSkillFromCatalog:p}=$();u.useEffect(()=>{a&&(o.some(l=>l.repo===a)||i?.catalog.some(l=>l.repo===a)&&p(a))},[a,o,i,p]);const m=u.useMemo(()=>fe(o),[o]),v=u.useMemo(()=>m.map(l=>l.repo),[m]),c=ie(L(re,{activationConstraint:{distance:8}}),L(oe,{coordinateGetter:se})),x=()=>{n({to:"/$owner/agents/$agentId/skills/create",params:{owner:s,agentId:t}})},S=e.jsxs(N,{type:"button",onClick:x,children:[e.jsx(F,{className:"mr-1.5 h-4 w-4"}),"Add skill"]}),y=l=>{if(l===a){n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}});return}n({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:w(l)}})},b=l=>{const{active:f,over:j}=l;!j||f.id===j.id||h(String(f.id),String(j.id))};return g?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(ne,{rows:2})]}):m.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(Y,{icon:V,title:"No skills yet",description:"Add a system skill from the catalog or create a custom skill for this agent.",actionLabel:"Add skill",onAction:x})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:D}),S]}),e.jsx(ce,{sensors:c,collisionDetection:de,onDragEnd:b,children:e.jsx(te,{items:v,strategy:ae,children:e.jsx("div",{className:"overflow-hidden rounded-lg border",children:m.map((l,f)=>{const j=l.repo===a;return e.jsx(ke,{card:l,rank:f+1,disabled:k,expanded:j,isLast:f===m.length-1,onToggle:()=>y(l.repo),onToggleEnabled:R=>void r(l.repo,R),toggleDisabled:k,children:j?e.jsx(he,{owner:s,agentId:t,skillKey:w(l.repo)}):null},l.id)})})})})]})}function ke({card:s,rank:t,disabled:a,expanded:n,isLast:o,onToggle:i,onToggleEnabled:g,toggleDisabled:k,children:h}){const r=a||n,{attributes:p,listeners:m,setNodeRef:v,transform:c,transition:x,isDragging:S}=le({id:s.repo,disabled:r}),y={transform:me.Transform.toString(c),transition:x};return e.jsxs("div",{ref:v,style:y,className:E("bg-background",!o||n?"border-b":"",S&&"z-10 bg-card opacity-80 "),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsx("button",{type:"button",className:"flex shrink-0 cursor-grab touch-none items-center px-2 text-muted-foreground hover:text-foreground active:cursor-grabbing disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Reorder ${s.name}`,disabled:r,...p,...m,children:e.jsx(X,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",className:E("flex min-w-0 flex-1 items-center gap-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",!s.enabled&&!n&&"opacity-70"),onClick:i,"aria-expanded":n,children:[e.jsx("span",{className:"w-4 shrink-0 text-center text-xs tabular-nums text-muted-foreground",children:t}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),s.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:s.description}):null,e.jsx(q,{badges:s.badges})]})]}),e.jsx(ue,{enabled:s.enabled,name:s.name,expanded:n,onToggleEnabled:g,toggleDisabled:k,onToggle:i})]}),n&&h?e.jsx("div",{className:"border-t border-border px-4 py-4",children:h}):null]})}function I({owner:s,agentId:t,children:a,showBack:n}){return e.jsx(U,{owner:s,agentId:t,showBack:n,backLabel:"Skills",backTo:"/$owner/agents/$agentId/skills",children:a})}function Ne({owner:s,agentId:t}){return e.jsx(I,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t})})}function Ce({owner:s,agentId:t}){const a=A();return e.jsx(I,{owner:s,agentId:t,children:e.jsx(ge,{owner:s,agentId:t,onBack:()=>{a({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}})}})})}function we({owner:s,agentId:t,skillKey:a}){return e.jsx(I,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t,expandedRepo:B(a)})})}export{Ne as A,Ce as a,we as b};
|
|
1
|
+
import{a4 as w,r as u,j as e,P as F,ac as C,ad as K,dS as P,dT as z,B as N,al as E,aV as G,d$ as H,e0 as Q,bq as V,gA as Y,fL as q,hS as X}from"./index-DdGjY1Hb.js";import{a as J,A as U}from"./agent-subpage-shell-B7tCQ9zd.js";import{u as $,b as W,f as Z,s as ee,a as se,S as te,v as ae,c as le}from"./agent-skill-context-D7tOJ8Pb.js";import{f as ne}from"./agent-loading-shells-DsiGx1fn.js";import{u as ie,a as I,m as oe,P as re,D as ce,n as de,C as me}from"./core.esm-Ds4Nuq9d.js";import{A as ue}from"./agent-card-controls-JubkhcHt.js";const T=":";function A(s){const t=s.indexOf("/");return t<0?s:`${s.slice(0,t)}${T}${s.slice(t+1)}`}function B(s){const t=s.indexOf(T);return t<0?s:`${s.slice(0,t)}/${s.slice(t+1)}`}function ge({owner:s,agentId:t,onBack:a,backLabel:n="Skills"}){const o=w(),[i,g]=u.useState(""),[k,h]=u.useState(!1),[r,p]=u.useState(""),[m,v]=u.useState(""),{skillRows:c,catalog:x,isLoading:S,addSkillFromCatalog:y,addCustomSkill:b}=$(),l=u.useMemo(()=>new Set(c.map(d=>d.repo)),[c]),f=u.useMemo(()=>W(x?.catalog??[],l),[x?.catalog,l]),j=u.useMemo(()=>Z(f,i),[f,i]),R=d=>{y(d),o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},O=()=>{const d=b({name:r,instructions:m});d&&o({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(d)}})},_=a?e.jsx(J,{title:"Add a skill",description:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own.",onBack:a,backLabel:n}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Add a skill"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skills bundle instructions, tools, and knowledge an agent can reuse. Pick one from the catalog or create your own."})]});return e.jsxs("div",{className:"space-y-6",children:[_,e.jsx("div",{className:E(G,"w-full"),children:k?e.jsxs("div",{className:"space-y-3 p-3",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-name",children:"Name"}),e.jsx(K,{id:"custom-skill-name",value:r,onChange:d=>p(d.target.value),placeholder:"my-skill"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"custom-skill-instructions",children:"Instructions"}),e.jsx(P,{id:"custom-skill-instructions",value:m,onChange:d=>v(d.target.value),placeholder:"Instructions for the agent when this skill is active...",rows:3})]})]}),e.jsx(z,{onCancel:()=>h(!1),children:e.jsx(N,{type:"button",size:"sm",onClick:O,disabled:!r.trim(),children:"Add custom skill"})})]}):e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 p-3 text-left text-muted-foreground transition-colors hover:text-foreground",onClick:()=>h(!0),children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted",children:e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Create custom skill"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define instructions and packages"})]})]})}),S?e.jsx(H,{}):e.jsx(Q,{items:j,searchQuery:i,onSearchChange:g,onSelect:d=>R(d.key),searchPlaceholder:"Search skills...",searchAriaLabel:"Search skills",emptyMessage:i.trim()?`No skills match "${i}"`:f.length===0?"All catalog skills are already configured":"No skills available"})]})}function xe({row:s}){const{isSaving:t,updateSkillRow:a}=$(),n=s.system===!0;return e.jsx("div",{className:"space-y-6",children:n?e.jsx("p",{className:"text-sm text-muted-foreground",children:"System skill metadata is managed by Lobu. You can enable or disable it and change its position in the skill list."}):e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-name",children:"Name"}),e.jsx(K,{id:"skill-name",value:s.name,onChange:o=>a(s.repo,{name:o.target.value}),disabled:t})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(C,{htmlFor:"skill-instructions",children:"Instructions"}),e.jsx(P,{id:"skill-instructions",value:s.instructions??"",onChange:o=>{const i=o.target.value;a(s.repo,{instructions:i,content:i.trim()||s.name})},rows:4,disabled:t})]})]})})}function he({owner:s,agentId:t,skillKey:a}){const n=w(),[o,i]=u.useState(!1),g=B(a),{skillRows:k,catalog:h,isSaving:r,saveSkills:p,removeSkillAndSave:m,addSkillFromCatalog:v}=$(),c=k.find(b=>b.repo===g)??null,x=h?.catalog.find(b=>b.repo===g);u.useEffect(()=>{!c&&x&&v(g)},[v,x,g,c]);const S=async()=>{await m(g)&&(i(!1),n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}}))};if(!c)return x?null:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Skill not found."});const y=!c.system;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(xe,{row:c}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-end",children:[y?o?e.jsxs(e.Fragment,{children:[e.jsx(N,{type:"button",variant:"destructive",onClick:()=>void S(),disabled:r,children:r?"Removing...":"Remove skill"}),e.jsx(N,{type:"button",variant:"outline",onClick:()=>i(!1),disabled:r,children:"Cancel"})]}):e.jsxs(N,{type:"button",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>i(!0),disabled:r,children:["Remove ",c.name]}):null,e.jsx(N,{type:"button",onClick:()=>void p(),disabled:r||o,children:r?"Saving...":"Save changes"})]})]})}function fe(s){return s.map(t=>{const a=ee(t).map(String);return{id:t.repo,repo:t.repo,name:t.name,description:t.description,badges:a,enabled:t.enabled}})}const D="Skills bundle instructions, tools, and knowledge an agent can reuse. Add one from the catalog or write your own; drag to set which the agent reaches for first.";function M({owner:s,agentId:t,expandedRepo:a}){const n=w(),{skillRows:o,catalog:i,isLoading:g,isSaving:k,reorderSkills:h,setSkillEnabledAndSave:r,addSkillFromCatalog:p}=$();u.useEffect(()=>{a&&(o.some(l=>l.repo===a)||i?.catalog.some(l=>l.repo===a)&&p(a))},[a,o,i,p]);const m=u.useMemo(()=>fe(o),[o]),v=u.useMemo(()=>m.map(l=>l.repo),[m]),c=ie(I(re,{activationConstraint:{distance:8}}),I(oe,{coordinateGetter:se})),x=()=>{n({to:"/$owner/agents/$agentId/skills/create",params:{owner:s,agentId:t}})},S=e.jsxs(N,{type:"button",onClick:x,children:[e.jsx(F,{className:"mr-1.5 h-4 w-4"}),"Add skill"]}),y=l=>{if(l===a){n({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}});return}n({to:"/$owner/agents/$agentId/skills/$skillKey",params:{owner:s,agentId:t,skillKey:A(l)}})},b=l=>{const{active:f,over:j}=l;!j||f.id===j.id||h(String(f.id),String(j.id))};return g?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(ne,{rows:2})]}):m.length===0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:D}),e.jsx(V,{icon:Y,title:"No skills yet",description:"Add a system skill from the catalog or create a custom skill for this agent.",actionLabel:"Add skill",onAction:x})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("p",{className:"min-w-0 flex-1 text-sm text-muted-foreground",children:D}),S]}),e.jsx(ce,{sensors:c,collisionDetection:de,onDragEnd:b,children:e.jsx(te,{items:v,strategy:ae,children:e.jsx("div",{className:"overflow-hidden rounded-lg border",children:m.map((l,f)=>{const j=l.repo===a;return e.jsx(ke,{card:l,rank:f+1,disabled:k,expanded:j,isLast:f===m.length-1,onToggle:()=>y(l.repo),onToggleEnabled:R=>void r(l.repo,R),toggleDisabled:k,children:j?e.jsx(he,{owner:s,agentId:t,skillKey:A(l.repo)}):null},l.id)})})})})]})}function ke({card:s,rank:t,disabled:a,expanded:n,isLast:o,onToggle:i,onToggleEnabled:g,toggleDisabled:k,children:h}){const r=a||n,{attributes:p,listeners:m,setNodeRef:v,transform:c,transition:x,isDragging:S}=le({id:s.repo,disabled:r}),y={transform:me.Transform.toString(c),transition:x};return e.jsxs("div",{ref:v,style:y,className:E("bg-background",!o||n?"border-b":"",S&&"z-10 bg-card opacity-80 "),children:[e.jsxs("div",{className:"flex items-stretch gap-1 pr-3",children:[e.jsx("button",{type:"button",className:"flex shrink-0 cursor-grab touch-none items-center px-2 text-muted-foreground hover:text-foreground active:cursor-grabbing disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Reorder ${s.name}`,disabled:r,...p,...m,children:e.jsx(q,{className:"h-4 w-4"})}),e.jsxs("button",{type:"button",className:E("flex min-w-0 flex-1 items-center gap-3 py-2.5 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",!s.enabled&&!n&&"opacity-70"),onClick:i,"aria-expanded":n,children:[e.jsx("span",{className:"w-4 shrink-0 text-center text-xs tabular-nums text-muted-foreground",children:t}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:s.name}),s.description?e.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:s.description}):null,e.jsx(X,{badges:s.badges})]})]}),e.jsx(ue,{enabled:s.enabled,name:s.name,expanded:n,onToggleEnabled:g,toggleDisabled:k,onToggle:i})]}),n&&h?e.jsx("div",{className:"border-t border-border px-4 py-4",children:h}):null]})}function L({owner:s,agentId:t,children:a,showBack:n}){return e.jsx(U,{owner:s,agentId:t,showBack:n,backLabel:"Skills",backTo:"/$owner/agents/$agentId/skills",children:a})}function Ne({owner:s,agentId:t}){return e.jsx(L,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t})})}function Ce({owner:s,agentId:t}){const a=w();return e.jsx(L,{owner:s,agentId:t,children:e.jsx(ge,{owner:s,agentId:t,onBack:()=>{a({to:"/$owner/agents/$agentId/skills",params:{owner:s,agentId:t}})}})})}function Ae({owner:s,agentId:t,skillKey:a}){return e.jsx(L,{owner:s,agentId:t,children:e.jsx(M,{owner:s,agentId:t,expandedRepo:B(a)})})}export{Ne as A,Ce as a,Ae as b};
|
package/dist/owletto/dist/assets/{agent-subpage-shell-DuVYZvBE.js → agent-subpage-shell-B7tCQ9zd.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a4 as m,j as e,al as h,B as n,ez as i}from"./index-DdGjY1Hb.js";function p({owner:t,agentId:a,children:s,showBack:r,backLabel:o,backTo:x,title:c,className:u}){const d=m(),l=()=>{d({to:x,params:{owner:t,agentId:a}})};return e.jsx("div",{className:h("mx-auto w-full max-w-3xl pb-8",u),children:c?e.jsxs(e.Fragment,{children:[e.jsx(j,{title:c,onBack:l,backLabel:o}),s]}):r?e.jsx(g,{onBack:l,backLabel:o,children:s}):s})}function g({onBack:t,backLabel:a,children:s}){return e.jsxs("div",{className:"relative",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"absolute right-full top-0 mr-1 size-8 text-muted-foreground hover:text-foreground","aria-label":`Back to ${a}`,onClick:t,children:e.jsx(i,{className:"h-4 w-4"})}),s]})}function j({title:t,onBack:a,backLabel:s,action:r}){return e.jsx("div",{className:"sticky top-0 z-10 mb-2 bg-background py-2",children:e.jsxs("div",{className:"relative flex items-center justify-center gap-1",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${s}`,onClick:a,children:e.jsx(i,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-base font-semibold",children:t}),r?e.jsx("div",{className:"absolute right-0",children:r}):null]})})}function v({title:t,description:a,onBack:s,backLabel:r}){return e.jsxs("div",{className:"mb-2 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(n,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${r}`,onClick:s,children:e.jsx(i,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-xl font-semibold",children:t})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground",children:a})]})}export{p as A,v as a};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{j as s,r as l,el as qt,as as Kt,em as Gt,dQ as Jt,ap as ze,ai as Be,aq as st,cc as Qt,en as lt,eo as Xt,L as xt,al as U,cL as Yt,cU as wt,cW as Zt,ep as en,cm as tn,cX as nn,eq as rn,B as ce,er as on,es as sn,et as We,Z as ln,s as an,cV as cn,aV as Ne,eu as un,cj as dn,ck as pn,ev as fn,cn as mn,bM as hn,ew as gn,ex as vn,e8 as yn,bJ as bn,du as xn,dv as wn}from"./index-DdGjY1Hb.js";import{D as Rn,E as Sn}from"./app-bridge-BH3g2mKG.js";import{A as Tn,a as jn,b as Cn,c as Xe,d as Rt,e as Nn}from"./agent-loading-shells-DsiGx1fn.js";import{t as An}from"./pending-seed-CPbfgnLX.js";import{h as En,t as kn,R as _n,i as In,u as On,b as Pn,f as Ln}from"./use-mention-search-CGA3AaKm.js";const St=l.createContext(null);function Mn({extension:e,children:t}){return s.jsx(St.Provider,{value:e??null,children:t})}function Ye(){return l.useContext(St)}var Ze=(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))(Ze||{});const $n={PROVIDER_QUOTA_EXHAUSTED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_AUTH:{cta:"provider-management",ctaLabel:"Reconnect provider"},PROVIDER_UNKNOWN_MODEL:{cta:"agent-settings",ctaLabel:"Choose model"},PROVIDER_BASE_URL_UNRESOLVED:{cta:"provider-management",ctaLabel:"Manage provider"},PROVIDER_TOOL_CALL_FAILED:{message:"The model provider rejected its own tool call and ended the turn. This is usually temporary — please try again.",cta:"none"},NO_MODEL_CONFIGURED:{message:"No model is configured for this agent. Choose a model in agent settings.",cta:"agent-settings",ctaLabel:"Choose a model"},WORKER_UNRESPONSIVE:{message:"The agent didn't finish responding in time. This is usually temporary — please try again.",cta:"none"},WORKER_DIED:{message:"The agent stopped unexpectedly before it could reply. This is usually temporary — please try again.",cta:"none"},WORKER_STARTUP_FAILED:{message:"The agent couldn't start, so your request wasn't processed. Please try again in a moment.",cta:"none"},SESSION_TIMEOUT:{cta:"none",silent:!0}};function Un(e){if(typeof e=="string")return Object.values(Ze).includes(e)?e:void 0}const Dn=Object.freeze(Object.defineProperty({__proto__:null,AGENT_ERRORS:$n,AgentErrorCode:Ze,toAgentErrorCode:Un},Symbol.toStringTag,{value:"Module"})),{AGENT_ERRORS:Fn,toAgentErrorCode:Vn}=Dn;function it(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 Tt(e,t){const n=Vn(e);if(!n)return null;const r=Fn[n];if(r.cta==="none"||!t.workspaceSlug)return null;const o=encodeURIComponent(t.workspaceSlug);if(r.cta==="provider-connect"||r.cta==="provider-management"){const a=t.provider?`/${o}/connectors/${encodeURIComponent(`${qt}${t.provider}`)}`:`/${o}/connectors`,c=it(a,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 i=it(`/${o}/agents/${encodeURIComponent(t.agentId)}/settings`,t.webOrigin);return i?{label:r.ctaLabel??"Open settings",href:i}:null}function jt(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 at=new Set(["localhost","127.0.0.1","::1","[::1]"]);function Bn(e){return e?.trim().toLowerCase().replace(/^\.+|\.+$/g,"")||null}function ct(e,t){const n=Bn(t);if(!n)return!1;const r=e.toLowerCase().replace(/\.$/,"");return r===n||r.endsWith(`.${n}`)}function ut(e,t,n){try{const r=new URL(t),o=new URL(e,t),i=at.has(o.hostname)&&at.has(r.hostname),a=o.protocol===r.protocol&&(o.protocol==="https:"||o.protocol==="http:")&&ct(o.hostname,n)&&ct(r.hostname,n);return o.origin!==r.origin&&(i||a)&&(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 Hn=/\.(png|jpe?g|gif|webp|avif|bmp|svg)$/i,Ct=new Set(["suggest_actions"]),Me="Thinking…";function zn(e){const{textOut:t,statusLine:n,errorText:r,toolCalls:o}=e,i=[];n===Me&&i.push({type:"reasoning"}),r&&i.push({type:"error",text:r});let a=t;return n&&n!==Me&&(a=t?`${t}
|
|
2
|
+
|
|
3
|
+
${n}`:n),a&&i.push({type:"text",text:a}),i.push(...o),i}const et=l.createContext(null);function Ae(){const e=l.useContext(et);if(!e)throw new Error("useLobuChat must be used within <LobuChatProvider>");return e}function $o({messages:e,children:t}){const n=l.useMemo(()=>({messages:e,running:!1,append:()=>{},cancel:()=>{},pendingAttachments:[],addAttachments:()=>{},removeAttachment:()=>{},agentId:null,conversationId:"",workspaceSlug:null,currentSuggestions:null}),[e]);return s.jsx(et.Provider,{value:n,children:t})}const Nt=/\[([^\]]*)\]\((\S*?\/api\/v1\/files\/[^)\s]+)\)/g;function dt(e){return e.replace(/<lobu_internal_context>[\s\S]*?<\/lobu_internal_context>\n*/g,"").replace(Nt,"").replace(/\n{3,}/g,`
|
|
4
|
+
|
|
5
|
+
`).trim()}function Wn(e){const t=[];for(const n of e.matchAll(Nt)){const r=n[1]?.trim()||"file",o=n[2];o&&t.push({name:r,url:o})}return t}function qn(e,t={}){if(typeof e=="string"){const r=dt(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 i=dt(o.text);i&&n.push({type:"text",text:i})}else t.showToolCalls&&o.type==="toolCall"&&typeof o.name=="string"&&!Ct.has(o.name)&&n.push({type:"tool-call",toolCallId:o.id??`tc-${n.length}`,toolName:o.name,args:o.arguments??{}})}return n}function Kn(e){const t=[],n=r=>{for(const{name:o,url:i}of Wn(r))t.push({id:`file-${t.length}`,name:o,url:i,isImage:Hn.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 i=o.mimeType||"image/png";t.push({id:`img-${t.length}`,name:`image-${t.length+1}`,imageDataUrl:`data:${i};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:qn(e.content,t),attachments:Kn(e.content),createdAt:n&&!Number.isNaN(n)?n:void 0}}const Jn=[],Qn=[];function Xn(e){let t=null;for(const n of e)n.type==="suggestion"&&(t=n.prompts.length>0?n.prompts:null);return t}function Yn(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=Tt(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,requestId:null}})}return n.length===0?null:{id:"history-interactions",role:"assistant",parts:n}}const Zn=3e4,er=3*Zn,tr=15e3;function pt(e){try{return JSON.parse(e.data)}catch{return{content:e.data}}}const me=e=>`${e}-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;function ft(e){const t=[],n=new Set;for(const r of e){if(!r||typeof r!="object")continue;const{title:o,message:i}=r;if(typeof o!="string"||typeof i!="string")continue;const a=o.trim(),c=i.trim();if(a.length===0||c.length===0)continue;const u=`${a}\0${c}`;n.has(u)||(n.add(u),t.push({title:a,message:c}))}return t.length>0?t:null}function Uo({agentId:e,workspaceSlug:t,thread:n="agent-panel",loadHistory:r=!0,ephemeralContext:o,onFirstUserMessage:i,children:a,initialDraft:c}){const u=Kt(),d=l.useRef(null),f=l.useRef(null),y=l.useRef(!1),v=l.useRef(o),m=l.useRef(void 0),[R,O]=l.useState(void 0),x=l.useRef(!1),L=l.useRef(null);v.current=o;const{data:k,isLoading:j}=Gt(e,n,{orgSlug:t,enabled:r&&!!e&&!!n}),A=k?.messages??Jn,K=k?.interactions??Qn,{data:E}=Jt(e,{enabled:!!e}),$=!!(E?.showToolCalls??E?.settings?.showToolCalls),[Z,ne]=l.useState([]),[z,Q]=l.useState(!1),[q,w]=l.useState([]);l.useEffect(()=>{R&&w([])},[R]);const[S,C]=l.useState(null),P=l.useRef(!1);P.current=z;const I=l.useMemo(()=>A.map(N=>Gn(N,{showToolCalls:$})).filter(N=>N!==null),[A,$]),ee=l.useRef(!1);l.useEffect(()=>{if(ee.current||j||P.current)return;ee.current=!0;const N=Yn(K,{workspaceSlug:t,agentId:e,webOrigin:typeof window>"u"?null:window.location.origin});ne(N?[...I,N]:I),C(Xn(K))},[e,j,I,K,t]);const X=l.useCallback(()=>{u.invalidateQueries({queryKey:["agent-thread-messages",t,e,n]}),u.invalidateQueries({queryKey:["agent-threads",t,e]})},[u,t,e,n]),re=l.useCallback(async()=>{if(d.current)return d.current;if(f.current)return f.current;if(!e)throw new Error("No agent selected");const N=(async()=>{const T=await ze(`${Be}/lobu/api/v1/agents`,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-lobu-org":t}:{}},credentials:"include",body:JSON.stringify({agentId:e,thread:n,...m.current?{executionTarget:m.current}:{}}),timeoutMs:2e4});if(!T.ok)throw await st(T);const V=await T.json(),W=Qt(),B={sessionId:V.agentId,sseUrl:ut(V.sseUrl,Be,W),messagesUrl:ut(V.messagesUrl,Be,W),executionTarget:V.executionTarget};return m.current=V.executionTarget,O(V.executionTarget),d.current=B,B})();f.current=N;try{return await N}catch(T){throw d.current=null,T}finally{f.current=null}},[e,t,n]),se=l.useCallback(async(N,T,V)=>{const W=new AbortController;L.current=W;const B=p=>{ne(h=>h.map(b=>b.id===V?{...b,parts:p}:b))};let G;try{G=await re()}catch(p){B([{type:"text",text:`Error: ${p instanceof Error?p.message:"Could not start a session."}`}]);return}let H=await lt(G.sseUrl,{throwOnFailure:!0});const ie=[];let he=null;const Re=()=>{const p=he;he=null,p?.()},ge=p=>{ie.push(p),Re()};let ve=!1,Se=null;const _e=new Promise(p=>{Se=p});let pe=0,ye=Date.now();const fe=p=>{ye=Date.now();const h=Number(p.lastEventId);Number.isFinite(h)&&h>pe&&(pe=h)},Ie=["output","status","complete","closed","agent-error","question","suggestion","link-button","tool-approval","tool_use"],Te=p=>{p.addEventListener("open",()=>{ve=!0,Se?.()}),p.addEventListener("connected",b=>{fe(b),ve||(ve=!0,Se?.())}),p.addEventListener("ping",fe);const h=b=>M=>{fe(M);const te=M;typeof te.data=="string"&&ge({kind:b,payload:pt(te)})};for(const b of Ie)p.addEventListener(b,h(b));p.addEventListener("error",b=>{const M=b;if(typeof M.data=="string"&&M.data){fe(b),ge({kind:"error",payload:pt(M)});return}p.readyState===EventSource.CLOSED&&ge({kind:"error",payload:{error:"Connection closed"}})})};Te(H);const Oe=async()=>{H.close();let p=G.sseUrl;if(pe){const h=new URL(G.sseUrl,window.location.origin);h.searchParams.set("since",String(pe)),p=h.toString()}H=await lt(p,{throwOnFailure:!1}),Te(H),ye=Date.now()};await Promise.race([_e,new Promise(p=>setTimeout(p,1500))]);const Pe=()=>{H.close(),Re()};W.signal.addEventListener("abort",Pe,{once:!0});try{const p=v.current?.trim(),h=!!p&&!x.current;h&&(x.current=!0);let b;if(T.length>0){const g=new FormData;g.set("content",N),h&&p&&g.set("ephemeralContext",p);for(const _ of T)g.append("files",_,_.name);b={method:"POST",credentials:"include",body:g,timeoutMs:12e4}}else{const g={content:N};h&&p&&(g.ephemeralContext=p),b={method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(g),timeoutMs:2e4}}const M=await ze(G.messagesUrl,b);if(!M.ok)throw d.current=null,await st(M);let te="",F=Me,ot=null;const be=[],ae=()=>zn({textOut:te,statusLine:F,errorText:ot,toolCalls:be});for(B(ae());!W.signal.aborted;){if(ie.length===0){let _;const J=await Promise.race([new Promise(Ve=>{he=()=>Ve(!0)}),new Promise(Ve=>{_=setTimeout(()=>Ve(!1),tr)})]);_&&clearTimeout(_),!J&&Date.now()-ye>=er&&(await Oe(),X());continue}const g=ie.shift();if(g){if(g.kind==="output")F=null,te+=String(g.payload.content??"");else if(g.kind==="status")F=Me;else if(g.kind==="complete"){F=null;const _=g.payload.finalText;typeof _=="string"&&_.length>0&&(te=_);const J=g.payload.suggestions;J!==void 0&&C(Array.isArray(J)?ft(J):null),X(),B(ae());return}else if(g.kind==="closed"){d.current=null;const _=g.payload.reason;F=`Session ended${_?`: ${_}`:""}.`,X(),B(ae());return}else if(g.kind==="error"||g.kind==="agent-error"){F=null,ot=typeof g.payload.error=="string"&&g.payload.error?g.payload.error:"Agent reported an error.";const _=g.payload.errorContext&&typeof g.payload.errorContext=="object"?g.payload.errorContext:void 0,J=Tt(g.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});J&&be.push({type:"tool-call",toolCallId:me("l"),toolName:"link-button",args:{label:J.label,url:J.href}}),X(),B(ae());return}else if(g.kind==="question")be.push({type:"tool-call",toolCallId:me("q"),toolName:"question",args:{question:g.payload.question??"",options:g.payload.options??[]}});else if(g.kind==="tool_use"){if(F=null,Ct.has(g.payload.name??"")){B(ae());continue}const _=g.payload.result_summary,J=jt(_);if(!$&&!J){B(ae());continue}be.push({type:"tool-call",toolCallId:g.payload.toolCallId??me("t"),toolName:$?g.payload.name??"tool":"subscription-candidate",args:$?g.payload.input??{}:null,result:_,isError:g.payload.isError})}else if(g.kind==="suggestion"){const _=g.payload.prompts;_!==void 0&&(C(Array.isArray(_)?ft(_):null),B(ae()))}else if(g.kind==="link-button")be.push({type:"tool-call",toolCallId:me("l"),toolName:"link-button",args:{label:g.payload.label??"Open link",url:g.payload.url??""}});else if(g.kind==="tool-approval"){const _=G.messagesUrl.replace(/\/agents\/[^/]+\/messages$/,"/agents/approve"),J=g.payload.runId;be.push({type:"tool-call",toolCallId:g.payload.requestId??(J!=null?`run-${J}`:me("a")),toolName:"tool-approval",args:{requestId:g.payload.requestId??null,tool:g.payload.toolName??"a tool",args:g.payload.args??null,durationOptions:g.payload.durationOptions??["1h","24h","always"],approveUrl:_,orgSlug:t??null,runId:J??null,action:g.payload.action??null,proposal:g.payload.proposal??null,current:g.payload.current??null,fields:g.payload.fields??null,attribution:g.payload.attribution??null,resourceKind:g.payload.resourceKind??null}})}B(ae())}}}catch(p){B([{type:"text",text:`Error: ${p instanceof Error?p.message:"Send failed."}`}])}finally{W.signal.removeEventListener("abort",Pe),H.close()}},[e,re,X,$,t]),ue=l.useCallback(N=>{const T=N.trim(),V=q.map(H=>H.file);if(!T&&V.length===0||P.current||!e)return;y.current||(y.current=!0,i?.(T||V[0]?.name||""));const W={id:me("u"),role:"user",parts:T?[{type:"text",text:T}]:[],attachments:q.map(H=>({id:H.id,name:H.name,isImage:H.isImage,imageDataUrl:H.isImage?URL.createObjectURL(H.file):void 0})),createdAt:Date.now()},B=me("asst"),G={id:B,role:"assistant",parts:[{type:"reasoning"}],createdAt:Date.now()};ne(H=>[...H,W,G]),w([]),Q(!0),P.current=!0,se(T,V,B).finally(()=>{Q(!1),P.current=!1,L.current=null})},[e,i,q,se]),Y=l.useCallback(()=>{L.current?.abort()},[]),le=l.useCallback(N=>{const T=Array.from(N);w(V=>[...V,...T.map(W=>({id:crypto.randomUUID(),name:W.name,file:W,isImage:W.type.startsWith("image/")}))])},[]),D=l.useCallback(N=>{w(T=>T.filter(V=>V.id!==N))},[]),de=l.useRef(!1);l.useEffect(()=>{if(de.current)return;const N=An(n);N&&(de.current=!0,m.current=N.executionTarget,O(N.executionTarget),ue(N.text))},[n,ue]),l.useEffect(()=>{j||I.length===0||re().catch(()=>{})},[re,I.length,j]);const ke=l.useMemo(()=>({messages:Z,running:z,append:ue,cancel:Y,pendingAttachments:q,addAttachments:le,removeAttachment:D,initialDraft:c,agentId:e,conversationId:n,workspaceSlug:t,currentSuggestions:S,executionTarget:R}),[Z,z,ue,Y,q,le,D,c,e,n,t,S,R]);return r&&j?s.jsx(Tn,{}):s.jsx(et.Provider,{value:ke,children:a})}const mt="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 nr({refItem:e}){const t=_n[e.kind]??Xt;return In(e.path)?s.jsxs("span",{className:mt,children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]}):s.jsxs(xt,{to:e.path,className:U(mt,"hover:bg-accent/80"),children:[s.jsx(t,{className:"h-3 w-3 shrink-0 opacity-70"}),e.label]})}const tt=({text:e,renderText:t})=>En(e)?s.jsx(s.Fragment,{children:kn(e).map((n,r)=>n.type==="ref"?s.jsx(nr,{refItem:n.ref},`r${r}`):s.jsx("span",{children:t(n.text)},`t${r}`))}):s.jsx(s.Fragment,{children:t(e)}),rr=({label:e="Thinking"})=>s.jsx("span",{className:"aui-thinking-shimmer inline-block text-sm","aria-live":"polite","aria-busy":"true",children:e}),At=l.createContext(null),Et=()=>{const e=l.useContext(At);if(!e)throw new Error("ChainOfThought components must be used within ChainOfThought");return e},kt=l.memo(({className:e,open:t,defaultOpen:n=!1,onOpenChange:r,children:o,...i})=>{const[a,c]=Yt({prop:t,defaultProp:n,onChange:r}),u=l.useMemo(()=>({isOpen:a,setIsOpen:c}),[a,c]);return s.jsx(At.Provider,{value:u,children:s.jsx("div",{className:U("not-prose max-w-prose space-y-4",e),...i,children:o})})}),_t=l.memo(({className:e,children:t,...n})=>{const{isOpen:r,setIsOpen:o}=Et();return s.jsx(wt,{onOpenChange:o,open:r,children:s.jsxs(Zt,{className:U("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...n,children:[s.jsx(en,{className:"size-4"}),s.jsx("span",{className:"flex-1 text-left",children:t??"Chain of Thought"}),s.jsx(tn,{className:U("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),It=l.memo(({className:e,icon:t=rn,label:n,description:r,status:o="complete",children:i,...a})=>{const c={complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"};return s.jsxs("div",{className:U("flex gap-2 text-sm",c[o],"fade-in-0 slide-in-from-top-2 animate-in",e),...a,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}),i]})]})}),Ot=l.memo(({className:e,children:t,...n})=>{const{isOpen:r}=Et();return s.jsx(wt,{open:r,children:s.jsx(nn,{className:U("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})})});kt.displayName="ChainOfThought";_t.displayName="ChainOfThoughtHeader";It.displayName="ChainOfThoughtStep";Ot.displayName="ChainOfThoughtContent";function or(e){const t=e.current?.loser??{};return{duplicates:Array.isArray(e.current?.duplicates)?e.current.duplicates:[t],winner:e.current?.winner??{}}}function Pt(e,t){if(e.length===0)return"No deterministic identity match details are available for these records.";if(e.length===1&&t===2){const[n]=e;return`Both records have the same ${String(n?.kind??"identity")}: ${String(n?.identifier??"")}.`}return`Recorded match evidence:
|
|
6
|
+
${e.map(n=>`• ${String(n.kind??"Identity")}: ${String(n.identifier??"")}`).join(`
|
|
7
|
+
`)}`}function $e(e,t,n){const r=String(t.id??e.toLowerCase());let o;const i=[],a=new Set;typeof t.href=="string"&&(n.add(t.href),o={id:`entity-${r}`,label:"Open record",variant:"ghost",icon:"external",terminal:!1,tool:"open_review_link",args:{url:t.href}});const c=new Set;for(const u of Array.isArray(t.identities)?t.identities:[]){const d=String(u.connection_name??u.source_connector??"Unknown source");c.add(`${d} · ${String(u.namespace??"identity")}: ${String(u.identifier??"")}`),!(typeof u.connection_href!="string"||a.has(u.connection_href))&&(a.add(u.connection_href),n.add(u.connection_href),i.push({id:`connection-${String(u.id??u.connection_href)}`,label:`Open source: ${d}`,variant:"ghost",icon:"external",terminal:!1,tool:"open_review_link",args:{url:u.connection_href}}))}return{type:"entity",id:r,label:e,name:String(t.name??`Entity ${r}`),details:[...c],recordLink:o,sourceLinks:i}}function nt(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&!Array.isArray(t)):[]}function ht(e){return`${String(e.kind??"Identity")}: ${String(e.identifier??"")}`}function gt(e){if(!Array.isArray(e))return null;const t=nt(e);return t.length===e.length&&t.every(n=>typeof n.kind=="string"&&n.kind.trim().length>0&&typeof n.identifier=="string"&&n.identifier.trim().length>0)?t:null}function sr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e,n=gt(t.dropped),r=gt(t.gained);if(!n||!r)return null;const o=[];for(const i of n)o.push(`− No longer proven — ${ht(i)}`);for(const i of r)o.push(`+ Newly proven — ${ht(i)}`);return{weakened:n.length>0,block:{type:"text",label:n.length>0?"What changed since you reviewed this":r.length>0?"What the re-check newly found":"What changed since you reviewed this",value:o.length>0?o.join(`
|
|
8
|
+
`):"The recorded match evidence did not change."}}}function lr(e){const{duplicates:t,winner:n}=or(e),r=nt(e.proposal?.evidence),o=new Set,i=typeof e.status=="string"?e.status:"pending",a=i==="pending",c=i==="rejected"?"Kept separate":i==="failed"?"Failed":"Approved",u=typeof e.reason=="string"?e.reason:typeof e.proposal?.reason=="string"?e.proposal.reason:null,d=[{type:"text",label:"Why Lobu thinks they match",value:Pt(r,t.length+1)}];u&&d.push({type:"text",label:"Why this needs review",value:u,muted:!0});const f=sr(e.proposal?.evidence_change);f&&d.push(f.block),d.push(...t.map(v=>$e("Duplicate",v,o)),$e("Canonical",n,o),{type:"text",value:a?`If approved, ${t.length===1?"the":"each"} duplicate's relationships and aliases will move to the canonical record.`:typeof e.reviewedByName=="string"?`${c} by ${e.reviewedByName}.`:`${c}.`,muted:!0});const y=a?[{id:"approve",label:f?"Approve again to apply":"Approve merge",variant:"primary",icon:"check",...f?.weakened?{confirm:!0,confirmPrompt:"The evidence for this merge no longer holds. Merge these records anyway?"}:{},tool:"manage_operations",args:{action:"approve"},resolvedLabel:"Merge approved and is being applied."},{id:"reject",label:"Keep separate",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Keep these entities separate?",tool:"manage_operations",args:{action:"reject"},resolvedLabel:"The entities were kept separate."}]:[];return{view:{title:`Merge ${t.length} duplicate ${t.length===1?"record":"records"}${a?"":` · ${c}`}`,icon:"entity",impact:a?{level:"high",reason:"This combines duplicate records into the selected winner."}:{level:"normal"},tone:a||i==="failed"?"warning":"default",blocks:d,actions:y},reviewUrls:o}}function Do(e){const t=e.loser&&typeof e.loser=="object"&&!Array.isArray(e.loser)?{...e.loser}:{},n=e.winner&&typeof e.winner=="object"&&!Array.isArray(e.winner)?{...e.winner}:{};typeof e.loserHref=="string"&&(t.href=e.loserHref),typeof e.winnerHref=="string"&&(n.href=e.winnerHref);const r=nt(e.evidence),o=new Set,i=e.status==="active",c=i&&e.canUndo===!0?[{id:"undo",label:"Undo merge",variant:"outline",icon:"x",confirm:!0,confirmPrompt:"Undo this automatic merge?",tool:"manage_entity",args:{action:"unmerge"},resolvedLabel:"Merge undone."}]:[];return{view:{title:i?"Merged automatically":"Automatic merge undone",icon:"entity",impact:{level:"normal"},tone:i?"default":"warning",blocks:[{type:"text",label:"Why Lobu merged them",value:Pt(r,2)},$e("Duplicate",t,o),$e("Canonical",n,o),{type:"text",value:i?"The entity type's deterministic identity rule applied this merge without human review.":"This automatic merge was undone.",muted:!0}],actions:c},reviewUrls:o}}function ir({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:o}){let i=qe(ar(r,o),t);if(!n)return l.createElement(e,i);if(typeof n=="function")return n(i,r);if(!l.isValidElement(n))return null;let a=n.props,c={...qe(i,a),ref:Ee(i.ref,a.ref)};return l.cloneElement(n,c)}function qe(...e){let t={};for(let n of e){if(!n)continue;let r=n;for(let o of Object.keys(r)){let i=r[o];if(i===void 0)continue;let a=t[o];o==="className"?t[o]=[a,i].filter(Boolean).join(" "):o==="style"?t[o]={...a,...i}:o==="ref"?t[o]=Ee(a,i):ur(o)&&typeof a=="function"&&typeof i=="function"?t[o]=cr(i,a):t[o]=i}}return t}function ar(e,t){let n={};for(let r of Object.keys(e)){let o=e[r],i=t?.[r]?.(o);if(i){Object.assign(n,i);continue}if(r==="slot"){n["data-slot"]=o;continue}let a=`data-${String(r).replace(/[A-Z]/g,c=>`-${c.toLowerCase()}`)}`;typeof o=="boolean"?n[a]=o?"":void 0:o!=null&&(n[a]=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 Ee(...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,pr=64,fr=0,Ue=.5,mr=180,hr=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),Lt={start:!1,end:!1},gr=[],De={currentAnchorId:null,visibleMessageIds:gr};function vr({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return Lt;let o=rt({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:o-r.scrollTop-r.clientHeight>t}}function yr({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:o,visibleMessageIds:i}){if(!e||!o)return De;let a=o.getBoundingClientRect(),c=a.top+t+n,u=typeof IntersectionObserver>"u",d=[],f=null;for(let y of je(e,r)){let v=y.dataset.messageId;if(!v)continue;let m=y.dataset.scrollAnchor==="true",R=m||u?y.getBoundingClientRect():null;(u&&R?R.bottom>c&&R.top<a.bottom:i.has(v))&&d.push(v),m&&R&&R.top<=c+Ue&&(f=v)}return d.length===0&&f===null?De:{currentAnchorId:f,visibleMessageIds:d}}function je(e,t){return Array.from(e.children).filter(n=>n instanceof HTMLElement&&n!==t)}function br(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r?.dataset.scrollAnchor==="true")return r}return null}function xr(e,t){for(let n of e)if(n.dataset.scrollAnchor==="true"&&!t.has(n))return n;return null}function wr(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 Rr(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 i=o.getBoundingClientRect();if(i.bottom>r.top&&i.top<r.bottom)return o}return null}function Tr({align:e,element:t,scrollMargin:n,spacer:r,viewport:o}){let i=Mt(t,o),a=t.getBoundingClientRect().height,c=Nr(r);if(e==="center"){let u=Math.max(0,o.clientHeight-c.start-c.end);return i-c.start-(u-a)/2-n}if(e==="end")return i-o.clientHeight+a+c.end+n;if(e==="nearest"){let u=i+a,d=o.scrollTop+c.start,f=o.scrollTop+o.clientHeight-c.end;return i>=d&&u<=f?o.scrollTop:i<d?i-c.start-n:u-o.clientHeight+c.end+n}return i-c.start-n}function Mt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function Le(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function jr({content:e,scrollTop:t,spacer:n,viewport:r}){let o=rt({content:e,spacer:n,viewport:r});return t+r.clientHeight-o}function rt({content:e,spacer:t,viewport:n}){let r=je(e,t),o=$t(e),i=n.getBoundingClientRect(),a=n.scrollTop,c=o.start+o.end;for(let u of r){let d=u.getBoundingClientRect();c=Math.max(c,d.bottom-i.top+a+o.end)}return c}function Cr(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function $t(e){let t=window.getComputedStyle(e);return{end:Ke(t.paddingBlockEnd||t.paddingBottom),start:Ke(t.paddingBlockStart||t.paddingTop)}}function Nr(e){let t=e?.parentElement;return t?$t(t):{end:0,start:0}}function Ar(e){if(!e)return 0;let t=window.getComputedStyle(e),n=t.rowGap==="normal"?t.gap:t.rowGap;return Ke(n)}function Ke(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function Er({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:o,autoScrollRef:i,autoscrollingRef:a,autoscrollingTimeoutRef:c,contentRef:u,defaultScrollPositionAppliedRef:d,itemCountRef:f,messageElementsRef:y,modeRef:v,pendingScrollToMessageRef:m,prependRestoreRef:R,scrollMarginRef:O,scrollPreviousItemPeekRef:x,spacerGapRef:L,spacerHeightRef:k,spacerRef:j,viewportRef:A}=e,K=l.useCallback(w=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null),a.current!==w&&(a.current=w,t()),w&&(c.current=window.setTimeout(()=>{c.current=null,a.current=!1,t()},mr))},[t]),E=l.useCallback(w=>{let S=j.current;if(!S)return;let C=Math.max(0,Math.ceil(w));k.current!==C&&(k.current=C,S.hidden=C===0,S.style.height=`${C}px`,S.style.marginTop=C>0?`${-L.current}px`:"")},[]),$=l.useCallback((w,{behavior:S="auto",autoscrolling:C=!1}={})=>{let P=A.current;if(!P)return;let I=Math.max(0,w);if(Math.abs(P.scrollTop-I)<=Ue){P.scrollTop=I,t();return}C&&K(!0),P.scrollTo({top:I,behavior:S}),n()},[t,n,K]),Z=l.useCallback(({behavior:w="auto"}={})=>A.current?(E(0),o.current=null,v.current="free-scrolling",$(0,{behavior:w}),r(),!0):!1,[r,$,E]),ne=l.useCallback(({behavior:w="auto"}={})=>{let S=A.current;return S?(E(0),o.current=null,v.current=i.current?"following-bottom":"free-scrolling",$(Cr(S),{autoscrolling:!0,behavior:w}),r(),!0):!1},[r,$,E]),z=l.useCallback((w,{align:S="start",behavior:C="auto",scrollMargin:P=O.current}={},{keepPreviousPeek:I=!1}={})=>{let ee=u.current,X=A.current;if(!ee||!X||!ee.contains(w))return!1;let re=Tr({align:S,element:w,scrollMargin:I?P+x.current:P,spacer:j.current,viewport:X}),se=jr({content:ee,scrollTop:re,spacer:j.current,viewport:X});return E(se),R.current={element:w,viewportTop:Le(w,X)},v.current=I?"anchored-to-message":"settling-jump",o.current=I?w:null,$(re,{behavior:C}),r(),!0},[r,$,E]),Q=l.useCallback(()=>{let w=o.current;return!w||!w.isConnected||v.current!=="anchored-to-message"?!1:z(w,{align:"start"},{keepPreviousPeek:!0})},[z]),q=l.useCallback((w,S)=>{let C=y.current.get(w);return C?(d.current=!0,z(C,S)?(m.current=null,!0):(m.current={messageId:w,options:S},!0)):f.current===0?(m.current={messageId:w,options:S},d.current=!0,!0):!1},[z]);return{flushPendingScrollToMessage:l.useCallback(()=>{let w=m.current;if(!w)return!1;let S=y.current.get(w.messageId);return!S||!z(S,w.options)?!1:(m.current=null,d.current=!0,!0)},[z]),reanchorToAnchoredMessage:Q,scrollToElement:z,scrollToEnd:ne,scrollToMessage:q,scrollToStart:Z}}function Ut(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:o=>{t(n,o)||(n=o,r.forEach(i=>i()))},subscribe:(o,i,a)=>{let c=r.size===0;return r.add(o),c&&i?.(),()=>{r.delete(o),r.size===0&&a?.()}}}}function kr(e,t){return Ut(e,t)}function _r(){return Ut(De,Or)}function Ir(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=l.useRef(e),i=l.useRef(!1),a=l.useRef(null),c=l.useRef(!1),u=l.useRef(t),d=l.useRef(0),f=l.useRef(null),y=l.useRef(0),v=l.useRef(e?"following-bottom":"free-scrolling"),m=l.useRef(new Map),R=l.useRef(null),O=l.useRef(null),x=l.useRef(null),L=l.useRef(r),k=l.useRef(!0),j=l.useRef(null),A=l.useRef(n),K=l.useRef(null),E=l.useRef(0),$=l.useRef(0),Z=l.useRef(null),ne=l.useRef(null),z=l.useRef(null),Q=l.useRef(null),q=l.useRef(null),w=l.useRef(null),S=l.useRef(null),C=l.useRef(null),P=l.useRef(new Set),I=l.useRef(new WeakSet);return z.current===null&&(z.current=kr(Lt,Ir)),C.current===null&&(C.current=_r()),o.current=e,u.current=t,A.current=n,L.current=r,{autoScrollRef:o,autoscrollingRef:i,autoscrollingTimeoutRef:Q,streamingTurnRef:x,contentRef:a,defaultScrollPositionAppliedRef:c,firstItemRef:f,itemCountRef:d,lastScrollTopRef:y,messageElementsRef:m,modeRef:v,pendingScrollFrameRef:K,pendingScrollToMessageRef:R,prependRestoreRef:O,preserveScrollOnPrependRef:k,rootRef:j,scrollEdgeThresholdRef:u,scrollMarginRef:A,scrollPreviousItemPeekRef:L,spacerGapRef:E,spacerHeightRef:$,spacerRef:Z,stateFrameRef:ne,stateStore:z.current,viewportRef:q,visibilityFrameRef:w,visibilityObserverRef:S,visibilityStore:C.current,visibleMessageIdsRef:P,handledScrollAnchorsRef:I}}function vt(e,t){return l.useCallback(n=>{e.current=n,n&&t()},[e,t])}function Lr({autoScroll:e=!1,defaultScrollPosition:t="end",scrollEdgeThreshold:n=dr,scrollPreviousItemPeek:r=pr,scrollMargin:o=fr}){let i=Pr({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:o,scrollPreviousItemPeek:r}),{streamingTurnRef:a,autoScrollRef:c,autoscrollingRef:u,autoscrollingTimeoutRef:d,contentRef:f,defaultScrollPositionAppliedRef:y,firstItemRef:v,itemCountRef:m,lastScrollTopRef:R,messageElementsRef:O,modeRef:x,pendingScrollFrameRef:L,pendingScrollToMessageRef:k,prependRestoreRef:j,preserveScrollOnPrependRef:A,rootRef:K,scrollEdgeThresholdRef:E,scrollMarginRef:$,scrollPreviousItemPeekRef:Z,spacerGapRef:ne,spacerHeightRef:z,spacerRef:Q,stateFrameRef:q,stateStore:w,viewportRef:S,visibilityFrameRef:C,visibilityObserverRef:P,visibilityStore:I,visibleMessageIdsRef:ee,handledScrollAnchorsRef:X}=i,re=l.useRef(t);re.current!==t&&(re.current=t,y.current=!1);let se=l.useCallback(p=>{let h=K.current,b=S.current,M=[p.start&&"start",p.end&&"end"].filter(Boolean).join(" "),te=u.current;for(let F of[h,b])F&&(M?F.setAttribute("data-scrollable",M):F.removeAttribute("data-scrollable"),F.toggleAttribute("data-autoscrolling",te))},[]),ue=l.useCallback(p=>{let h=S.current?.scrollTop??0,b=h<R.current-Ue;R.current=h,c.current&&!p.end&&x.current!=="settling-jump"&&x.current!=="anchored-to-message"?x.current="following-bottom":x.current==="following-bottom"&&p.end&&b&&!u.current&&(x.current="free-scrolling")},[]),Y=l.useCallback(()=>{let p=vr({content:f.current,scrollEdgeThreshold:E.current,spacer:Q.current,viewport:S.current});ue(p);let h=x.current==="following-bottom"?{...p,end:!1}:p;se(h),w.setSnapshot(h)},[ue,w,se]),le=l.useCallback(()=>{q.current===null&&(q.current=window.requestAnimationFrame(()=>{q.current=null,Y()}))},[Y]),D=l.useCallback(()=>{I.hasListeners()&&C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,I.hasListeners()&&I.setSnapshot(yr({content:f.current,scrollMargin:$.current,scrollPreviousItemPeek:Z.current,spacer:Q.current,viewport:S.current,visibleMessageIds:ee.current}))}))},[I]),{flushPendingScrollToMessage:de,reanchorToAnchoredMessage:ke,scrollToElement:N,scrollToEnd:T,scrollToMessage:V,scrollToStart:W}=Er({refs:i,commitScrollState:Y,scheduleStateCommit:le,scheduleVisibilitySync:D}),B=l.useCallback(()=>{let p=j.current,h=S.current;if(!p||!h||!p.element.isConnected)return!1;let b=Le(p.element,h)-p.viewportTop;return Math.abs(b)<=Ue?!1:(h.scrollTop+=b,p.viewportTop=Le(p.element,h),le(),D(),!0)},[le,D]),G=l.useCallback(()=>{let p=f.current,h=S.current;if(!p||!h){j.current=null;return}let b=Sr({content:p,spacer:Q.current,viewport:h});j.current=b?{element:b,viewportTop:Le(b,h)}:null},[]),H=l.useCallback(()=>{L.current===null&&(L.current=window.requestAnimationFrame(()=>{L.current=null,de()&&G()}))},[G,de]),ie=l.useCallback(()=>{if(!t||y.current||m.current===0)return!1;let p=!1;if(t==="last-anchor"){let h=f.current,b=S.current,M=h&&b?Rr(je(h,Q.current)):null;if(!h||!b||!M)p=T({behavior:"auto"});else{let te=Mt(M,b);p=rt({content:h,spacer:Q.current,viewport:b})-te<=b.clientHeight?T({behavior:"auto"}):N(M,{align:"start"},{keepPreviousPeek:!0})}}else p=t==="end"?T({behavior:"auto"}):W({behavior:"auto"});return p?(y.current=!0,!0):!1},[t,N,T,W]),he=l.useCallback(()=>{let p=f.current;if(!p)return;let h=je(p,Q.current),b=m.current,M=v.current;m.current=h.length,v.current=h[0]??null,(()=>{if(de())return;if(b===0){if(ie()||h.length>0&&c.current&&T({behavior:"auto"}))return;Y(),D();return}let te=M?h.indexOf(M):-1;if(A.current&&te>0){B();return}if(h.length>b){let F=br(h,b);if(F){if(c.current&&x.current==="following-bottom"&&wr(h,b)){T({behavior:"auto"});return}N(F,{align:"start"},{keepPreviousPeek:!0}),X.current.add(F);return}}if(h.length===b){let F=xr(h,X.current);if(F){N(F,{align:"start"},{keepPreviousPeek:!0}),X.current.add(F);return}}x.current==="following-bottom"&&c.current?T({behavior:"auto"}):(Y(),D())})(),G()},[ie,G,Y,de,B,D,N,T]),Re=l.useCallback(()=>{if(x.current==="following-bottom"&&c.current){T({behavior:"auto"});return}let p=z.current;if(ke()){c.current&&p>0&&z.current===0&&T({behavior:"auto"});return}le(),D()},[ke,le,D,T]),ge=l.useCallback(()=>{let p=S.current;if(!(!p||!I.hasListeners())){if(typeof IntersectionObserver>"u"){D();return}P.current||(P.current=new IntersectionObserver(h=>{for(let b of h){let M=b.target.dataset.messageId;M&&(b.isIntersecting?ee.current.add(M):ee.current.delete(M))}D()},{root:p,rootMargin:`${-($.current+Z.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),O.current.forEach(h=>{P.current?.observe(h)}),D()}},[D,I]),ve=l.useCallback(()=>{C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),P.current?.disconnect(),P.current=null,ee.current.clear(),I.setSnapshot(De)},[I]),Se=l.useCallback((p,h,b)=>{if(h){O.current.set(p,h),P.current?.observe(h),D(),k.current?.messageId===p&&H();return}b&&O.current.get(p)===b&&(O.current.delete(p),ee.current.delete(p),P.current?.unobserve(b),D())},[H,D]),_e=l.useCallback(()=>{(x.current==="following-bottom"||x.current==="anchored-to-message"||x.current==="settling-jump")&&(a.current=null,x.current="free-scrolling")},[]),pe=l.useCallback(()=>se(w.getSnapshot()),[w,se]),ye=vt(K,pe),fe=vt(S,pe),Ie=l.useCallback(p=>{f.current=p},[]),Te=l.useCallback(p=>{Q.current=p,ne.current=Ar(p?.parentElement??null)},[]),Oe=l.useCallback(()=>{Y(),D(),G()},[G,Y,D]),Pe=l.useMemo(()=>({handleContentChange:he,handleResize:Re,observeVisibility:ge,preserveScrollOnPrependRef:A,scrollToEnd:T,scrollToMessage:V,scrollToStart:W,setContentElement:Ie,setRootElement:ye,setSpacerElement:Te,setViewportElement:fe,stateStore:w,syncAfterScroll:Oe,unobserveVisibility:ve,userScrollIntent:_e,viewportRef:S,visibilityStore:I}),[he,Re,ge,T,V,W,Ie,ye,Te,fe,w,Oe,ve,_e,I]);return l.useLayoutEffect(()=>{ie()},[ie]),l.useEffect(()=>()=>{q.current!==null&&(window.cancelAnimationFrame(q.current),q.current=null),C.current!==null&&(window.cancelAnimationFrame(C.current),C.current=null),d.current!==null&&(window.clearTimeout(d.current),d.current=null),L.current!==null&&(window.cancelAnimationFrame(L.current),L.current=null),P.current?.disconnect(),P.current=null},[]),l.useLayoutEffect(()=>{if(e&&x.current==="following-bottom"&&m.current>0){T({behavior:"auto"});return}Y()},[e,Y,T]),{context:Pe,registerMessage:Se}}function Mr(e){let t=l.useRef(e);return t.current=e,t}var Dt=l.createContext(null),Ft=l.createContext(null);function xe(){let e=l.useContext(Dt);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function $r(){let e=l.useContext(Ft);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Vt(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=xe();return l.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function Bt(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:n}=xe(),r=l.useCallback(o=>n.subscribe(o,e,t),[e,t,n]);return l.useSyncExternalStore(r,n.getSnapshot,n.getSnapshot)}function Ur({autoScroll:e=!1,children:t,defaultScrollPosition:n="end",scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:i}){let{context:a,registerMessage:c}=Lr({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:o,scrollMargin:i});return s.jsx(Dt.Provider,{value:a,children:s.jsx(Ft.Provider,{value:c,children:t})})}function Dr({children:e,...t}){let{setRootElement:n}=xe();return s.jsx("div",{ref:n,...t,children:e})}function Fr({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:o,onWheel:i,preserveScrollOnPrepend:a=!0,ref:c,role:u,tabIndex:d,...f}){let{handleResize:y,preserveScrollOnPrependRef:v,setViewportElement:m,syncAfterScroll:R,userScrollIntent:O,viewportRef:x}=xe();v.current=a;let L=l.useCallback(E=>{m(E),Ee(c)?.(E)},[c,m]);function k(E){R(),r?.(E)}function j(E){O(),i?.(E)}function A(E){O(),o?.(E)}function K(E){hr.has(E.key)&&O(),n?.(E)}return l.useEffect(()=>{let E=x.current;if(!E||typeof ResizeObserver>"u")return;let $=0,Z=new ResizeObserver(()=>{window.cancelAnimationFrame($),$=window.requestAnimationFrame(y)});return Z.observe(E),()=>{window.cancelAnimationFrame($),Z.disconnect()}},[y,x]),s.jsx("div",{ref:L,role:u??"region","aria-label":e??"Messages",tabIndex:d??0,onKeyDown:K,onScroll:k,onTouchMove:A,onWheel:j,...f,children:t})}function Vr({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:o,...i}){let{handleContentChange:a,handleResize:c,setContentElement:u,setSpacerElement:d}=xe(),f=l.useRef(null),y=l.useCallback(v=>{f.current=v,u(v),Ee(n)?.(v)},[n,u]);return l.useLayoutEffect(()=>{let v=f.current;if(!v||(a(),typeof MutationObserver>"u"))return;let m=new MutationObserver(()=>{a()});return m.observe(v,{childList:!0}),()=>m.disconnect()},[a]),l.useEffect(()=>{let v=f.current;if(!v||typeof ResizeObserver>"u")return;let m=0,R=new ResizeObserver(()=>{window.cancelAnimationFrame(m),m=window.requestAnimationFrame(c)});return R.observe(v),()=>{window.cancelAnimationFrame(m),R.disconnect()}},[c]),s.jsxs("div",{ref:y,role:r??"log","aria-relevant":e??"additions",...i,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(),i=l.useRef(null),a=l.useCallback(c=>{let u=i.current;i.current=c,e&&o(e,c,u),Ee(t)?.(c)},[e,t,o]);return s.jsx("div",{ref:a,"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:i,type:a="button",...c}){let{scrollToEnd:u,scrollToStart:d,stateStore:f}=xe(),y=Mr(r),v=l.useCallback(x=>f.subscribe(x),[f]),m=l.useCallback(()=>{let x=f.getSnapshot();return n==="start"?x.start:x.end},[n,f]),R=l.useSyncExternalStore(v,m,m),O=l.useCallback(x=>{R&&(y.current?.(x),x.defaultPrevented||(x.currentTarget.blur(),n==="start"?d({behavior:e}):u({behavior:e})))},[e,n,R,y,u,d]);return ir({defaultTagName:"button",props:qe({type:a,inert:!R,tabIndex:R?i:-1,children:t??s.jsxs("span",{children:["Scroll to ",n]}),onClick:O},c),render:o,state:{active:R,direction:n},stateAttributesMapping:{active:x=>({"data-active":x?"true":"false"})}})}var we={Provider:Ur,Root:Dr,Viewport:Fr,Content:Vr,Item:Br,Button:Hr};const zr=we.Provider;function Wr({className:e,...t}){return s.jsx(we.Root,{className:U("relative flex size-full min-h-0 flex-col overflow-hidden",e),...t})}function qr({className:e,...t}){return s.jsx(we.Viewport,{className:U("size-full min-h-0 overflow-y-auto overscroll-contain [scrollbar-gutter:stable]",e),...t})}function Kr({className:e,...t}){return s.jsx(we.Content,{className:U("flex h-max min-h-full flex-col",e),...t})}function Gr({className:e,...t}){return s.jsx(we.Item,{className:U("min-w-0 shrink-0",e),...t})}function Jr({className:e,...t}){return s.jsx(we.Button,{direction:"end",behavior:"smooth",render:({active:n,...r})=>n?s.jsx(ce,{...r,type:"button",variant:"outline",size:"icon",className:U("absolute right-4 bottom-4 z-20 rounded-full bg-background ",e),"aria-label":"Scroll to latest message",children:s.jsx(on,{})}):null,...t})}function Qr(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 Xr(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 Yr="lobu-spa";function He(e){return typeof e=="string"&&/^https?:\/\//i.test(e.trim())}function Fe(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 Fo=({afterMessagesContent:e,readOnly:t=!1,readerPositionMode:n="messages",interactionExtension:r,onRunSelect:o})=>{const{messages:i,agentId:a,conversationId:c}=Ae(),{data:u=[]}=sn(a,{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:i,trips:u,mode:n,afterMessagesContent:e,onRunSelect:o}),t?null:s.jsx("div",{className:jn,children:s.jsx(ko,{})})]})})},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:i}=Bt(),{scrollToMessage:a}=Vt(),c=l.useRef(null);l.useEffect(()=>{if(e.length===0||typeof window>"u")return;const d=Xr({messageIds:e.map(f=>f.id),scrollTarget:Qr(window.location.search),alreadyScrolledTo:c.current});d.scroll&&(c.current=d.id,a(d.id,{align:"start",behavior:"smooth"}))},[e,a]);const u=d=>n==="runs"?d.id.startsWith("sep:"):d.role==="user";return s.jsxs(Wr,{children:[s.jsx(qr,{"aria-label":n==="runs"?"Automation run history":"Conversation",children:s.jsxs(Kr,{className:U(Xe,Cn),children:[e.map(d=>{const f=n==="runs"&&o?eo(d.id):null;return s.jsx(Gr,{messageId:d.id,scrollAnchor:u(d),"aria-current":d.id===i?"location":void 0,className:U("flex flex-col",n==="runs"&&u(d)&&"border-l-2 border-transparent pl-2 transition-colors",n==="runs"&&d.id===i&&"border-primary"),children:f!=null?s.jsx(go,{message:d,onClick:()=>o?.(f)}):s.jsx(lo,{message:d})},d.id)}),t.map(d=>s.jsx(ro,{trip:d},d.id)),s.jsx(so,{}),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(Jr,{})]})},no=({messages:e,mode:t})=>{const{scrollToMessage:n}=Vt(),{currentAnchorId:r,visibleMessageIds:o}=Bt(),i=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,a=e.flatMap(c=>{if(!(t==="runs"?c.id.startsWith("sep:"):c.role==="user"))return[];const d=c.parts.find(f=>f.type==="text");return[{id:c.id,label:d?.type==="text"?d.text:"Automation run"}]});return a.length===0?null:s.jsxs(dn,{children:[s.jsx(pn,{asChild:!0,children:s.jsxs(ce,{type:"button",variant:"outline",size:"icon",className:U("absolute top-1/2 right-4 z-20 -translate-y-1/2 rounded-full bg-background/95 ",i>0&&"w-auto px-3"),"aria-label":i>0?`Open transcript outline, ${i} ${i===1?"approval":"approvals"} waiting`:"Open transcript outline",children:[s.jsx(fn,{}),i>0?s.jsxs("span",{className:"text-xs tabular-nums",children:[i," waiting"]}):null]})}),s.jsxs(mn,{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:a.map(c=>{const u=c.id===r,d=o.includes(c.id);return s.jsxs(ce,{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:U("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:U(Xe,"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(un,{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=({prompts:e,onPick:t,className:n})=>e.length===0?null:s.jsx("div",{className:U("flex flex-wrap gap-2",n),children:e.map(r=>s.jsx(ce,{type:"button",variant:"outline",size:"sm",className:"h-auto rounded-full whitespace-normal text-left",title:r.message,"aria-label":`${r.title}: ${r.message}`,onClick:()=>t(r.message),children:r.title},`${r.title}\0${r.message}`))}),so=()=>{const{currentSuggestions:e,running:t,append:n}=Ae();return t||!e||e.length===0?null:s.jsx(oo,{prompts:e,className:Xe,onPick:r=>n(r)})},lo=({message:e})=>e.role==="user"?s.jsx(io,{message:e}):e.role==="system"?s.jsx(vo,{message:e}):s.jsx(uo,{message:e}),Ht=({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(We,{className:"h-3 w-3 shrink-0"}),s.jsx("span",{className:"max-w-[14rem] truncate",children:e.name})]});return s.jsx("div",{className:"flex items-center gap-1.5 rounded-md border bg-background px-2 py-1 text-xs",children:e.url?s.jsx("a",{href:e.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-1.5 hover:underline",children:n}):n})},io=({message:e})=>{const t=e.parts.filter(n=>n.type==="bash");return t.length>0?s.jsx("div",{className:Rt,children:s.jsx("div",{className:"space-y-2",children:t.map(n=>s.jsx(ao,{part:n},Fe(e,n)))})}):s.jsx("div",{className:Nn,children:s.jsxs("div",{className:U(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(Ht,{attachment:n},n.id))}):null,e.parts.map(n=>n.type==="text"?s.jsx("div",{className:"whitespace-pre-wrap break-words",children:s.jsx(tt,{text:n.text,renderText:r=>r})},Fe(e,n)):null)]})})},ao=({part:e})=>{const t=e.cancelled||e.exitCode!==void 0&&e.exitCode!==0;return s.jsxs("div",{className:U(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(hn,{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]})},zt=new Set(["question","link-button","tool-approval"]),co="subscription-candidate",uo=({message:e})=>{const t=Ye(),{agentId:n,workspaceSlug:r}=Ae(),o=u=>u.type==="tool-call"&&(zt.has(u.toolName)||t?.toolNames.has(u.toolName)),i=e.parts.filter(u=>u.type==="tool-call"&&!o(u)&&u.toolName!==co),a=e.parts.filter(u=>u.type!=="tool-call"||o(u)),c=e.parts.flatMap(u=>{if(u.type!=="tool-call")return[];const d=jt(u.result);return d?[d]:[]});return s.jsx("div",{className:Rt,children:s.jsxs("div",{className:"space-y-2 text-sm",children:[i.length>0?s.jsx(fo,{tools:i}):null,n&&r?c.map(u=>s.jsx(po,{candidate:u,agentId:n,workspaceSlug:r},`${u.connector_key}:${u.resource_ref}`)):null,a.map(u=>s.jsx(ho,{part:u},Fe(e,u))),e.attachments&&e.attachments.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:e.attachments.map(u=>s.jsx(Ht,{attachment:u},u.id))}):null]})})},po=({candidate:e,agentId:t,workspaceSlug:n})=>s.jsxs("div",{className:U(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(ce,{asChild:!0,size:"sm",variant:"outline",className:"shrink-0",children:s.jsxs(xt,{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(vn,{className:"mr-1.5 h-4 w-4"}),"Add automation"]})})]}),fo=({tools:e})=>s.jsxs(kt,{defaultOpen:!1,children:[s.jsx(_t,{children:e.length===1?e[0].toolName:`${e.length} tool calls`}),s.jsx(Ot,{children:e.map(t=>{const n=t.args!==void 0&&t.args!==null,r=t.result!==void 0&&t.result!==null;return s.jsxs(It,{icon:gn,label:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium",children:t.toolName}),t.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:t.isError?"active":"complete",children:[n?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ce(t.args)}):null,r?s.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-foreground/80 text-xs",children:Ce(t.result)}):null]},t.toolCallId)})})]}),mo=({text:e})=>{let t=e,n=null;const r=e.match(/\{[\s\S]*\}/);if(r)try{const i=JSON.parse(r[0])?.error?.message;typeof i=="string"&&i.trim()&&(t=i,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=Ye();return e.type==="reasoning"?s.jsx(rr,{}):e.type==="error"?s.jsx(mo,{text:e.text}):e.type==="text"?e.text.trim()?s.jsx(tt,{text:e.text,renderText:n=>s.jsx(yn,{text:n})}):null:e.type!=="tool-call"?null:zt.has(e.toolName)||t?.toolNames.has(e.toolName)?s.jsx(Eo,{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:U(Ne,"block w-full cursor-pointer whitespace-pre-wrap break-words px-3 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-muted/50"),children:n?.type==="text"?n.text:"Automation run"})},vo=({message:e})=>s.jsx("div",{className:"self-stretch",children:s.jsx("div",{className:U(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(tt,{text:t.text,renderText:n=>n})},Fe(e,t)):null)})}),yo="/mcp-apps/interaction/index.html";function yt(e){return new Promise(t=>{e({onSettled:(n,r)=>t(!!r)})})}const bo=({src:e,title:t,renderPayload:n,onToolCall:r,onOpenLink:o})=>{const i=l.useRef(null),[a,c]=l.useState(48),u=l.useRef({renderPayload:n,onToolCall:r,onOpenLink:o});return u.current={renderPayload:n,onToolCall:r,onOpenLink:o},l.useEffect(()=>{const d=i.current;if(!d?.contentWindow)return;const f=new Rn(null,{name:"Lobu",version:"1.0.0"},{openLinks:{},serverTools:{}},{hostContext:{theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"}});f.addEventListener("sizechange",({height:m})=>{typeof m=="number"&&c(Math.max(32,Math.ceil(m)))}),f.oncalltool=async({name:m,arguments:R})=>({content:[],isError:await u.current.onToolCall(m,R??{})}),f.onopenlink=async({url:m})=>({isError:await u.current.onOpenLink(m)}),f.addEventListener("initialized",()=>{(async()=>(await f.sendToolInput({arguments:{}}),await f.sendToolResult({content:[],structuredContent:{...u.current.renderPayload,version:1,source:Yr}})))()});const y=new Sn(d.contentWindow,d.contentWindow);f.connect(y).catch(m=>{console.error("[mcp-app-host] failed to initialize",m)});const v=new MutationObserver(()=>{f.setHostContext({theme:document.documentElement.classList.contains("dark")?"dark":"light",displayMode:"inline",platform:"web"})});return v.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{v.disconnect(),y.close()}},[]),s.jsx("iframe",{ref:i,title:t,src:e,sandbox:"allow-scripts",style:{width:"100%",height:a,border:"none",display:"block"}})},xo=new Set(["action"]),wo=["name","description","identity_md"];function oe(e){return e==null||e===""?"":typeof e=="string"?e:Ce(e)}function bt(e){return e===null?"(cleared)":e===void 0?"":typeof e=="string"?e===""?"":e:Ce(e)}function Ge(e){return e.length>0?e[0].toUpperCase()+e.slice(1):e}const Wt=new Set(["delete","disconnect","merge","remove","remove_rule","reset","revoke"]);function Je(e){return e&&Wt.has(e)?"warning":"default"}function Qe(e,t){return e&&Wt.has(e)?{level:"high",reason:t}:{level:"normal"}}function Ro(e,t){const n=e.attribution==="automation"?"An Automation":"An agent",r=Object.keys(t),o=r.map(i=>({label:i,before:oe(e.current?.[i]),after:oe(t[i])}));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??{},i=Object.keys(o).filter(a=>!xo.has(a)&&o[a]!==void 0).map(a=>({label:a,...e.action==="update"&&e.current?.[a]!==void 0?{before:bt(e.current?.[a])}:{},after:bt(o[a])}));return r.push(i.length>0?{type:"diff",fields:i}:{type:"text",value:"No field changes.",muted:!0}),{title:`${Ge(t)} Automation ${n}`,icon:"automation",impact:Qe(e.action,"This archives the Automation and stops future runs."),tone:Je(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){return e.action==="merge"&&(e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.proposal?.winner_entity_id!==void 0||e.current?.winner!==void 0)}function jo(e){if(e.resourceKind==="automation")return So(e);if(e.fields&&Object.keys(e.fields).length>0)return Ro(e,e.fields);if(e.resourceKind==="entity"||e.proposal?.entity_id!==void 0||e.current?.entity_type!==void 0||e.proposal?.entity_type!==void 0){const i=e.proposal?.name??e.current?.name??e.proposal?.entity_id??e.current?.id??"entity",a=e.action??"change",c=[];if(e.action==="delete")c.push({type:"text",value:"This will delete the entity.",muted:!0});else{const u=Object.keys(e.proposal??{}).filter(d=>!["entity_id","id"].includes(d)&&e.proposal?.[d]!==void 0&&oe(e.proposal?.[d])!==oe(e.current?.[d])).map(d=>({label:d,...e.action==="update"?{before:oe(e.current?.[d])}:{},after:oe(e.proposal?.[d])}));c.push(u.length>0?{type:"diff",fields:u}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ge(a)} entity ${i}`,icon:"entity",impact:Qe(e.action,e.action==="merge"?"This combines duplicate records into the selected winner.":"This deletes the entity."),tone:Je(e.action),blocks:c,actions:[{id:"approve",label:"Approve",variant:"primary",icon:"check",tool:"manage_operations",args:{action:"approve"},resolvedLabel:`Approved — ${a} ${i} 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 — ${a} ${i} 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 i=wo.filter(a=>e.proposal?.[a]!==void 0&&oe(e.proposal?.[a])!==oe(e.current?.[a])).map(a=>({label:a,...e.action==="update"?{before:oe(e.current?.[a])}:{},after:oe(e.proposal?.[a])}));o.push(i.length>0?{type:"diff",fields:i}:{type:"text",value:"No field changes.",muted:!0})}return{title:`${Ge(r)} agent ${n}`,icon:"agent",impact:Qe(e.action,"This permanently deletes the agent and its configuration."),tone:Je(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,t){const n=[];e.args!==void 0&&e.args!==null&&n.push({type:"code",value:Ce(e.args)});const r=t.map(o=>({id:o,label:o==="always"?"Always allow":`Approve ${o}`,variant:"outline",tool:"approve_tool_request",args:{decision:o},resolvedLabel:o==="always"?"Approved — always allowed.":`Approved for ${o}.`}));return r.push({id:"deny",label:"Deny",variant:"ghost",tool:"approve_tool_request",args:{decision:"deny"},resolvedLabel:"Denied."}),{title:`Wants to run ${e.tool??"a tool"}`,icon:"tool",impact:{level:"high",reason:"This grants the agent permission to use a tool."},tone:"warning",blocks:n,actions:r}}function No(e){const t=Array.isArray(e.options)?e.options.filter(o=>typeof o=="string"):[],n=[{type:"text",value:e.question||"The agent has a question."}];t.length===0&&n.push({type:"text",value:"Reply below to answer.",muted:!0});const r=t.map(o=>({id:o,label:o,variant:"outline",tool:"answer_question",args:{answer:o},resolvedLabel:`Answered: ${o}`}));return{title:"Input needed",icon:"question",tone:"default",blocks:n,actions:r}}function Ao(e,t){return{tone:"bare",actions:[{id:"open",label:e.label??"Open link",variant:"outline",icon:"external",terminal:!1,href:t}]}}const Eo=({toolName:e,args:t})=>{const n=xn(),r=wn(),{append:o}=Ae(),i=Ye(),a=t??{},c=i?.resolve(e,t)??null;let u=c?.view??null;const d={...c?.handlers??{}},f=new Set;if(!c){if(e==="tool-approval"&&typeof a.runId=="number"){const y=a.runId,v=typeof a.status=="string"?a.status:"pending",m=v==="pending",R=To(a),O=R?lr(a):null,x=O?.view??jo(a),L=v==="rejected"?a.action==="merge"?"Kept separate":"Rejected":v==="failed"?"Failed":"Approved";u=m||R?x:{...x,title:`${x.title??"Approval"} · ${L}`,tone:v==="failed"?"warning":"default",blocks:[...x.blocks??[],{type:"text",value:typeof a.reviewedByName=="string"?`${L} by ${a.reviewedByName}.`:`${L}.`,muted:!0}],actions:(x.actions??[]).filter(j=>j.terminal===!1)},m&&(d.manage_operations=j=>{if(j.action==="approve")return yt(A=>n.mutate({run_id:y},A));if(j.action==="reject"){const A=typeof j.reason=="string"?j.reason:void 0;return yt(K=>r.mutate({run_id:y,...A?{reason:A}:{}},K))}return Promise.resolve(!0)});const k=O?.reviewUrls??new Set;for(const j of k)f.add(j);d.open_review_link=j=>{const A=typeof j.url=="string"?j.url:"";return!k.has(A)||!He(A)?Promise.resolve(!0):(window.open(A,"_blank","noopener,noreferrer"),Promise.resolve(!1))}}else if(e==="tool-approval"){const y=Array.isArray(a.durationOptions)&&a.durationOptions.every(m=>typeof m=="string")&&a.durationOptions.length>0?a.durationOptions:["1h","24h","always"],v=new Set([...y,"deny"]);u=Co(a,y),d.approve_tool_request=async m=>{const R=typeof m.decision=="string"?m.decision:"";if(!a.requestId||!a.approveUrl||!v.has(R))return!0;try{return!(await ze(a.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...a.orgSlug?{"x-lobu-org":a.orgSlug}:{}},credentials:"include",body:JSON.stringify({requestId:a.requestId,decision:R}),timeoutMs:2e4})).ok}catch{return!0}}}else if(e==="question"){const y=Array.isArray(a.options)?a.options.filter(v=>typeof v=="string"):[];u=No(a),d.answer_question=v=>{const m=typeof v.answer=="string"?v.answer:"";return y.includes(m)?(o(m),Promise.resolve(!1)):Promise.resolve(!0)}}else if(e==="link-button"){if(!He(a.url))return null;const y=a.url;f.add(y),u=Ao(a,y)}}return u?s.jsx(bo,{src:yo,title:u.title??"Interaction",renderPayload:u,onToolCall:(y,v)=>d[y]?d[y](v):Promise.resolve(!0),onOpenLink:y=>!f.has(y)||!He(y)?Promise.resolve(!0):(window.open(y,"_blank","noopener,noreferrer"),Promise.resolve(!1))}):null};function Ce(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}const ko=()=>{const{running:e,append:t,cancel:n,pendingAttachments:r,addAttachments:o,removeAttachment:i,initialDraft:a,currentSuggestions:c,executionTarget:u}=Ae(),d=_o({suggestions:e?null:c}),[f,y]=l.useState(a??""),v=l.useRef(null),m=l.useRef(null),R=On(Ln),O=l.useRef(a??"");l.useEffect(()=>{const k=a??"";if(k===O.current)return;const j=O.current;O.current=k,k!==""&&y(A=>A===""||A===j?k:A)},[a]);const x=l.useRef(f);x.current=f;const L=()=>{e||(t(x.current),y(""),m.current?.clear())};return s.jsxs("div",{className:"rounded-2xl border bg-background transition-colors focus-within:ring-1 focus-within:ring-ring",children:[!u&&r.length>0?s.jsx("div",{className:"flex flex-wrap gap-1.5 px-3 pt-3",children:r.map(k=>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(We,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"max-w-[12rem] truncate",children:k.name}),s.jsx("button",{type:"button",className:"text-muted-foreground transition-colors hover:text-foreground","aria-label":"Remove attachment",onClick:()=>i(k.id),children:s.jsx(ln,{className:"h-3 w-3"})})]},k.id))}):null,s.jsx(Pn,{value:f,onChange:y,onSubmit:L,searchRefs:R,handleRef:m,placeholder:d,className:"max-h-48 overflow-y-auto"}),s.jsxs("div",{className:"flex items-center justify-between px-3 pb-2",children:[u?s.jsx("span",{className:"px-2 text-xs text-muted-foreground",children:"Running on your device"}):s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:k=>{k.target.files&&o(k.target.files),k.target.value=""}}),s.jsxs(ce,{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(We,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Attach files"})]})]}),e?s.jsxs(ce,{type:"button",size:"icon",variant:"secondary",className:"h-8 w-8 rounded-full",onClick:n,children:[s.jsx(an,{size:"lg"}),s.jsx("span",{className:"sr-only",children:"Cancel"})]}):s.jsxs(ce,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:L,children:[s.jsx(cn,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send message"})]})]})]})};function _o({suggestions:e}){const t=e?.find(n=>n.message.trim().length>0)?.message;return t?`Recommended: ${t.trim()}`:"Chat… (@ to mention, / for commands)"}export{Fo as A,Uo as L,$o as R,Do as a,lr as b,Yn as h,Gn as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as t,a2 as o}from"./index-DdGjY1Hb.js";const n=()=>t.jsx(o,{});export{n as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s,gw as $,gx as N,cm as L,al as x,gy as M,gz as I,a4 as b,a5 as S,v as j,w,bz as k,r as D,a2 as O,gA as W,gB as P,c7 as E,gC as R,gD as z,a3 as y,g as F,L as G,p as H}from"./index-DdGjY1Hb.js";import{A as U}from"./agent-editor-form-BrOkwfg8.js";import{P as _}from"./proposal-review-shell-uskeFIUr.js";function B({identity:e,sections:n,activeSection:t,activeItem:o,onSectionSelect:r,sectionLabel:c,highlightSection:l=!0,className:g}){const a=o??n.find(i=>i.key===t)??n[0];if(!a)return null;const d=a.icon;return s.jsx("div",{className:x("flex shrink-0 flex-col items-center px-4 lg:px-6",g),children:s.jsxs("div",{className:"flex min-w-0 max-w-full flex-wrap items-center justify-center gap-x-3 gap-y-2",children:[e,s.jsxs($,{children:[s.jsx(N,{asChild:!0,children:s.jsxs("button",{type:"button",className:x("inline-flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1 text-sm transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring",l?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/60 hover:text-foreground"),"aria-label":c,children:[s.jsx(d,{className:"h-3.5 w-3.5 shrink-0"}),a.label,s.jsx(L,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),s.jsx(M,{align:"center",className:"min-w-[11rem]",children:n.map(({key:i,label:u,icon:m})=>s.jsxs(I,{className:x(i===t&&"bg-accent font-medium"),onSelect:()=>r(i),children:[s.jsx(m,{className:"h-4 w-4"}),s.jsx("span",{children:u})]},i))})]})]})})}const p=[{key:"skills",label:"Skills",icon:W},{key:"guardrails",label:"Guardrails",icon:P},{key:"permissions",label:"Permissions",icon:E,adminOnly:!0},{key:"models",label:"Models",icon:R},{key:"settings",label:"Settings",icon:z}];function T(e){return p.filter(n=>!n.adminOnly||e)}function q(e,n){if(n===`${e}/conversations`||n.startsWith(`${e}/conversations/`))return null;for(const{key:t}of p)if(n===`${e}/${t}`||n.startsWith(`${e}/${t}/`))return t;return n===`${e}/identity`||n===`${e}/identity/`?"settings":null}function J(e){return e.trim().charAt(0).toUpperCase()||"?"}function K({owner:e,agentId:n,agentName:t,activeDest:o}){const r=b(),{orgContext:c}=y(),{isAdmin:l}=F(c.organizationId),g=T(!!l),a=o??"settings",d=p.find(i=>i.key===a);return s.jsx(B,{identity:s.jsxs(G,{to:"/$owner/agents/$agentId/settings",params:{owner:e,agentId:n},search:{run_id:void 0},className:"flex min-w-0 items-center gap-2 rounded-md outline-none transition-colors hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring",title:"Agent settings",children:[s.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-semibold text-foreground",children:J(t)}),s.jsx("h1",{className:"min-w-0 truncate text-base font-semibold tracking-tight",children:t})]}),sections:g,activeSection:a,activeItem:d,sectionLabel:"Agent section",highlightSection:o!==null,onSectionSelect:i=>{r({to:`/$owner/agents/$agentId/${i}`,params:{owner:e,agentId:n}})}})}function Z({owner:e,agentId:n}){const t=b(),{pathname:o}=S(),{isAuthenticated:r}=j(),{isMember:c}=w(),l=r&&c,{data:g=[],isLoading:a}=k({enabled:l}),d=g.find(C=>C.agentId===n)??null,i=!d&&!a&&l,u=`/${e}/agents/${n}`,m=`${u}/conversations`,f=o===m||o.startsWith(`${m}/`),h=q(u,o);D.useEffect(()=>{i&&t({to:"/$owner",params:{owner:e},replace:!0})},[i,t,e]);const A=d?.name??"Agent";return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-hidden py-4 md:py-6",children:[s.jsx(K,{owner:e,agentId:n,agentName:A,activeDest:h}),s.jsx("div",{className:x("flex min-h-0 min-w-0 flex-1 flex-col px-4 lg:px-6",f?"overflow-hidden":"overflow-y-auto"),children:s.jsx(O,{})})]})}function Q({agent:e,tab:n,runId:t}){return s.jsx("div",{className:"mx-auto w-full max-w-3xl pb-6",children:s.jsx(_,{resource:{kind:"agent",agentId:e.agentId},runId:t,children:({reviewMode:o,proposal:r,controlsDisabled:c})=>s.jsx(U,{mode:{kind:"edit",agent:e},section:n,reviewMode:o,reviewProposal:r,reviewControlsDisabled:c},e.agentId)})})}function ee({owner:e,agentId:n,tab:t,runId:o}){const{orgContext:r,hasOrgContext:c}=y(),{isLoading:l}=H(`/${e}`,r),{isAuthenticated:g}=j(),{isMember:a,isLoading:d}=w(),i=g&&a,{data:u=[],isLoading:m}=k({enabled:i}),v=i?!c||l||m||d:l||d,f=u.find(h=>h.agentId===n)??null;return v||!f?null:s.jsx(Q,{agent:f,tab:t,runId:o})}export{Z as A,ee as a};
|