yepanywhere 0.9.1 → 0.9.2
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/bundled/@yep-anywhere/shared/dist/__tests__/model-prices.test.js +12 -0
- package/bundled/@yep-anywhere/shared/dist/__tests__/model-prices.test.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts +2 -2
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/app-types.js +5 -5
- package/bundled/@yep-anywhere/shared/dist/app-types.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.d.ts +21 -0
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.js +22 -1
- package/bundled/@yep-anywhere/shared/dist/artifact-viewer.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/tool/ToolResultSchemas.d.ts +2 -2
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.d.ts +41 -0
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.js +280 -0
- package/bundled/@yep-anywhere/shared/dist/find/documentFind.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.d.ts +2 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.d.ts +2 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.js +5 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.generated.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.js +59 -0
- package/bundled/@yep-anywhere/shared/dist/find/frameFindAgent.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.d.ts +46 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.js +45 -0
- package/bundled/@yep-anywhere/shared/dist/find/protocol.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/index.d.ts +4 -2
- package/bundled/@yep-anywhere/shared/dist/index.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/index.js +3 -1
- package/bundled/@yep-anywhere/shared/dist/index.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/model-prices.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/model-prices.js +9 -2
- package/bundled/@yep-anywhere/shared/dist/model-prices.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/pdfjs.d.ts +7 -0
- package/bundled/@yep-anywhere/shared/dist/pdfjs.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/pdfjs.js +7 -0
- package/bundled/@yep-anywhere/shared/dist/pdfjs.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/skill-invocations.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/skill-invocations.js +7 -10
- package/bundled/@yep-anywhere/shared/dist/skill-invocations.js.map +1 -1
- package/bundled/@yep-anywhere/shared/package.json +1 -1
- package/client-dist/assets/{AboutSettings-CHsaLshd.js → AboutSettings-CCzudbSj.js} +1 -1
- package/client-dist/assets/{ActivityPage-CBVcBckm.js → ActivityPage-Bn0LbMgE.js} +1 -1
- package/client-dist/assets/{AgentContextSettings-DLLaiwUX.js → AgentContextSettings-DI8jQVIx.js} +1 -1
- package/client-dist/assets/{AgentsPage-C3_U9MGs.js → AgentsPage-Ci_iJt8T.js} +1 -1
- package/client-dist/assets/App-rFnK5pnF.js +2 -0
- package/client-dist/assets/AppearanceSettings-DTYVt0W5.js +2 -0
- package/client-dist/assets/{AppsSettings-B1BIWKaz.js → AppsSettings-hbh_sguk.js} +1 -1
- package/client-dist/assets/{AttachmentChip-CQTl9l1O.js → AttachmentChip-BFve3lTD.js} +1 -1
- package/client-dist/assets/{AuthContext-BQK10GgC.js → AuthContext-DmXjW0be.js} +1 -1
- package/client-dist/assets/{BangCommandDisplayObject-BDGW0BZN.js → BangCommandDisplayObject-BH2KRGnc.js} +1 -1
- package/client-dist/assets/{BangCommandsPage-C1-n2iHi.js → BangCommandsPage-MfkuL8yS.js} +1 -1
- package/client-dist/assets/{BrowserDebugToolbarButton-CRE47FFy.js → BrowserDebugToolbarButton-BPghQu17.js} +1 -1
- package/client-dist/assets/{CacheMissBillingSettings-BspB12sl.js → CacheMissBillingSettings-rUgC-_DD.js} +1 -1
- package/client-dist/assets/{CodexUpdatePrompt-BXTqvclk.js → CodexUpdatePrompt-mT9K-f1e.js} +1 -1
- package/client-dist/assets/{CommittedRangeInput-bK7EXtAc.js → CommittedRangeInput-BwuV6Q6c.js} +1 -1
- package/client-dist/assets/{CommittedRangeNumberInput-bGOjN2Xv.js → CommittedRangeNumberInput-C5YSVltB.js} +1 -1
- package/client-dist/assets/{ComputerControlSettings-BLA4wsEA.js → ComputerControlSettings-MWIdP7SS.js} +1 -1
- package/client-dist/assets/{ConversationPreviewPage-rxHQQOck.js → ConversationPreviewPage-B47r7mUF.js} +2 -2
- package/client-dist/assets/{DevelopmentSettings-CFo3ctnP.js → DevelopmentSettings-BEAy_xq-.js} +1 -1
- package/client-dist/assets/{DevicesSettings-DPdJOmEQ.js → DevicesSettings-DKQOZkRN.js} +1 -1
- package/client-dist/assets/{EmulatorPage-RPHDvihL.js → EmulatorPage-DlsPq3nR.js} +1 -1
- package/client-dist/assets/{EmulatorSettings-8dHy0xqk.js → EmulatorSettings-C6Ye1k_Y.js} +1 -1
- package/client-dist/assets/{EnvironmentSettings-DaFyodJV.js → EnvironmentSettings-ou8UNqTa.js} +1 -1
- package/client-dist/assets/{FilePage-BwbKyIGF.js → FilePage-Cw2PaO5H.js} +1 -1
- package/client-dist/assets/{FilterDropdown-BiB5gAUh.js → FilterDropdown-CACc6ysA.js} +1 -1
- package/client-dist/assets/{FloatingActionButton-DEiaqWhv.js → FloatingActionButton-Bl1Eumxh.js} +1 -1
- package/client-dist/assets/{GitStatusPage-CSXr__tv.js → GitStatusPage-CLTkgnDI.js} +1 -1
- package/client-dist/assets/{GlobalSessionsPage-C-CbcZjC.js → GlobalSessionsPage-Bvzs4zmW.js} +1 -1
- package/client-dist/assets/{HeartbeatTextArea-DWZZh0eE.js → HeartbeatTextArea-CtP5kx9R.js} +1 -1
- package/client-dist/assets/{HostIdentityContext-DbEx7dor.js → HostIdentityContext-DA7dMF-y.js} +1 -1
- package/client-dist/assets/{HostsPage-BRlkrB-8.js → HostsPage-CBOYGC2-.js} +1 -1
- package/client-dist/assets/{InboxContext-DtjKccKZ.js → InboxContext-8PXoTbK1.js} +1 -1
- package/client-dist/assets/{InboxPage-DFaLlFm5.js → InboxPage-DWl7uzdw.js} +1 -1
- package/client-dist/assets/{IssueSettings-CHjLBTZK.js → IssueSettings-BVljRpuD.js} +1 -1
- package/client-dist/assets/{IssuesPage-CfYD-jwK.js → IssuesPage-BFxgsMkf.js} +1 -1
- package/client-dist/assets/{LifecycleWebhooksSettings-Ir3_1MvY.js → LifecycleWebhooksSettings-Qw_dN3F3.js} +1 -1
- package/client-dist/assets/{LocalAccessSettings-BVh3wBDY.js → LocalAccessSettings-SWirs75o.js} +1 -1
- package/client-dist/assets/LocalMediaModal-B3KXtyEB.css +1 -0
- package/client-dist/assets/LocalMediaModal-B9eHVx6y.js +14 -0
- package/client-dist/assets/{LoginPage-irZxKYu1.js → LoginPage-CYWqVJ95.js} +1 -1
- package/client-dist/assets/{MessageAge-CKdiBg7K.js → MessageAge-CaPpa1nH.js} +1 -1
- package/client-dist/assets/{MessageDeliverySettings-BJ6Hgu1F.js → MessageDeliverySettings-BUSuGKlc.js} +1 -1
- package/client-dist/assets/MessageInput-a13ZPAHv.js +3 -0
- package/client-dist/assets/{MessageInputToolbar-CvUMMGJv.js → MessageInputToolbar-CQGTnVea.js} +3 -3
- package/client-dist/assets/MessageList-C7kAuWKg.js +4 -0
- package/client-dist/assets/{Modal-DOzUIhWU.js → Modal-ClSjJagX.js} +2 -2
- package/client-dist/assets/{ModelSettings-SWaaTKgm.js → ModelSettings-Dnd4yzmI.js} +1 -1
- package/client-dist/assets/{NavigationLayout-D8BMwd7T.js → NavigationLayout-BTFsWVtE.js} +2 -2
- package/client-dist/assets/{NewSessionPage-BBFzYBNs.js → NewSessionPage-BfiAS-Mo.js} +1 -1
- package/client-dist/assets/{NotificationsSettings-0iotA0wy.js → NotificationsSettings-B1ugQIp-.js} +1 -1
- package/client-dist/assets/{PageHeader-Ca3PbaMb.js → PageHeader-BjwH2pWD.js} +1 -1
- package/client-dist/assets/{PerformanceSettings-BgDJMjlN.js → PerformanceSettings-jJYF9SPY.js} +1 -1
- package/client-dist/assets/{ProjectSessionDefaultsModal-LEaPwpSM.js → ProjectSessionDefaultsModal-G_0uxJEv.js} +1 -1
- package/client-dist/assets/{ProjectTemplatesSettings-fPlh8ZpJ.js → ProjectTemplatesSettings-BQTCV3-3.js} +1 -1
- package/client-dist/assets/{ProjectsPage-CiQ3rBB_.js → ProjectsPage-suTd8s9l.js} +1 -1
- package/client-dist/assets/ProviderBadge-P0VTI71n.js +1 -0
- package/client-dist/assets/{ProviderChildSessionDetail-CSAbaZtr.js → ProviderChildSessionDetail-D0472EW8.js} +13 -13
- package/client-dist/assets/ProviderChildSessionPage-9__sgY14.js +1 -0
- package/client-dist/assets/{ProvidersSettings-B327MdUT.js → ProvidersSettings-Bwzy73Rk.js} +1 -1
- package/client-dist/assets/{RecapAfterSecondsControl-DWG9fB4u.js → RecapAfterSecondsControl-CxuXyFSr.js} +1 -1
- package/client-dist/assets/{RelayProtocol-DOWXVB0k.js → RelayProtocol-BpdH0COG.js} +1 -1
- package/client-dist/assets/{RemoteAccessSettings-CBSIP-qP.js → RemoteAccessSettings-Dn7KB5nK.js} +1 -1
- package/client-dist/assets/{RemoteExecutorsSettings-DDAqEB42.js → RemoteExecutorsSettings-Cjl4Y2rB.js} +1 -1
- package/client-dist/assets/{SchemaValidationContext-DLNGXai_.js → SchemaValidationContext-57RCj4c4.js} +1 -1
- package/client-dist/assets/{SearchPreview-BCP67hKg.js → SearchPreview-OzVFWPJZ.js} +1 -1
- package/client-dist/assets/{SessionHeader.module-CHO2T3eQ.js → SessionHeader.module-BpaFAQ-S.js} +1 -1
- package/client-dist/assets/SessionPage-BYthaEfZ.js +50 -0
- package/client-dist/assets/SessionPage-CXXEAwu2.css +1 -0
- package/client-dist/assets/{SettingsItem-BWF_CyTI.js → SettingsItem-C9Vh5p7F.js} +1 -1
- package/client-dist/assets/{SettingsSection-DbOwfvBD.js → SettingsSection-BaPzETK6.js} +1 -1
- package/client-dist/assets/{SourceControlSettings-BopLkzc6.js → SourceControlSettings-DnqLg0db.js} +1 -1
- package/client-dist/assets/{SourceFileHeaderActions-HoUciheJ.js → SourceFileHeaderActions-PjhUGnn6.js} +1 -1
- package/client-dist/assets/SpeechControlMenu-BYVdEa3C.js +2 -0
- package/client-dist/assets/{SpeechSettings-B4mB2LIj.js → SpeechSettings-B6LkqfSK.js} +1 -1
- package/client-dist/assets/{SpeechSmartTurnControls-tb5zP_85.js → SpeechSmartTurnControls-LPq9wBaM.js} +1 -1
- package/client-dist/assets/{StorageSettings-B5A0CtTo.js → StorageSettings-DtsJnYaz.js} +1 -1
- package/client-dist/assets/{ThinkingControls-BEweLRqu.js → ThinkingControls-DXbxdJRi.js} +1 -1
- package/client-dist/assets/{ToolbarSettings-CJbxOope.js → ToolbarSettings-Nb2BKpnk.js} +1 -1
- package/client-dist/assets/{UsersSettings-NWqRSGov.js → UsersSettings-BdvqmyqK.js} +1 -1
- package/client-dist/assets/ViewerModePage-DzRIpuYF.js +1 -0
- package/client-dist/assets/{VoiceInputButton-0BzvkjjK.js → VoiceInputButton-CCgovfyf.js} +1 -1
- package/client-dist/assets/{WorkstreamsPage-oM6jTLsK.js → WorkstreamsPage-dlEUllSL.js} +1 -1
- package/client-dist/assets/{YaServerProvider-BNTM9_P9.js → YaServerProvider-CN3tC5UL.js} +1 -1
- package/client-dist/assets/{YepAnywhereLogo-C4H1sg3q.js → YepAnywhereLogo-5zFKWjQq.js} +1 -1
- package/client-dist/assets/{abnfDiagram-VCTEODGH-DIBSwOuB.js → abnfDiagram-VCTEODGH-BWHUBcV3.js} +1 -1
- package/client-dist/assets/{arc-Blz12Cef.js → arc-DKsIJWGD.js} +1 -1
- package/client-dist/assets/{architectureDiagram-5GKGNRK7-CtTnQhBI.js → architectureDiagram-5GKGNRK7-BuLImqW3.js} +1 -1
- package/client-dist/assets/{attachmentFileNames-DwaA5IPB.js → attachmentFileNames-CBV_5g65.js} +1 -1
- package/client-dist/assets/{blockDiagram-I7D4REHJ-BanTkGM6.js → blockDiagram-I7D4REHJ-CJ4Gh6sL.js} +1 -1
- package/client-dist/assets/{c4Diagram-7LVT6UL2-C4p1KgTp.js → c4Diagram-7LVT6UL2-WR43XvCI.js} +1 -1
- package/client-dist/assets/channel-PV8AAsuo.js +1 -0
- package/client-dist/assets/{chunk-2Q5K7J3B-CJSvy8go.js → chunk-2Q5K7J3B-CiP4m_EA.js} +1 -1
- package/client-dist/assets/{chunk-5VM5RSS4-BVg02Giz.js → chunk-5VM5RSS4-BUAhj1h9.js} +1 -1
- package/client-dist/assets/{chunk-F27PBJKO-f_VOUJ8l.js → chunk-F27PBJKO-BUZNwiGx.js} +1 -1
- package/client-dist/assets/{chunk-IMKFNOWR-P5H0uE4d.js → chunk-IMKFNOWR-CX1a0BCE.js} +1 -1
- package/client-dist/assets/{chunk-JWPE2WC7-BpEGNu2X.js → chunk-JWPE2WC7-C6tL-mLF.js} +1 -1
- package/client-dist/assets/{chunk-POPQ4Y6H-oZudgMt7.js → chunk-POPQ4Y6H-BzijGGWv.js} +1 -1
- package/client-dist/assets/{chunk-SVP7TREG-dMWNgoWs.js → chunk-SVP7TREG-CsZImJKI.js} +1 -1
- package/client-dist/assets/{chunk-TICWLB2K-D8VqJUFw.js → chunk-TICWLB2K-TwCtuDc1.js} +1 -1
- package/client-dist/assets/{chunk-XXDRQBXY-ZwkKkcDz.js → chunk-XXDRQBXY-C-2EoNns.js} +1 -1
- package/client-dist/assets/classDiagram-ZZMXUADV-DvtSxfma.js +1 -0
- package/client-dist/assets/classDiagram-v2-VYDZK3BY-DvtSxfma.js +1 -0
- package/client-dist/assets/{client-D_ikArFV.js → client-Ci_HPGfl.js} +1 -1
- package/client-dist/assets/{compactSettingsControls-CzgNQCH3.js → compactSettingsControls-C9mLZh5H.js} +1 -1
- package/client-dist/assets/{cose-bilkent-JH36ORCC-DrtmDj3A.js → cose-bilkent-JH36ORCC-CmbEx2jT.js} +1 -1
- package/client-dist/assets/{cynefin-OW5HDTMX-CYhxgFq5.js → cynefin-OW5HDTMX-BSQHHXFU.js} +1 -1
- package/client-dist/assets/{cynefinDiagram-5FMLGOSQ-BXvBp5eq.js → cynefinDiagram-5FMLGOSQ-C-62JZJD.js} +1 -1
- package/client-dist/assets/{dagre-GXQ25YYZ-CdvzhCPS.js → dagre-GXQ25YYZ-BBERQe_A.js} +1 -1
- package/client-dist/assets/{diagram-S7CK7UJ4-DSGzzHN1.js → diagram-S7CK7UJ4-muw11lmG.js} +1 -1
- package/client-dist/assets/{diagram-UQ7AKVKN-Bk4fbl1S.js → diagram-UQ7AKVKN-DpePWzAe.js} +1 -1
- package/client-dist/assets/{diagram-VSXAHHWV-BAOCj4oX.js → diagram-VSXAHHWV-DHX6AHUY.js} +1 -1
- package/client-dist/assets/{diagram-VX7I27RA-KHmeuEjq.js → diagram-VX7I27RA-DYmR6NH_.js} +1 -1
- package/client-dist/assets/{diagram-Z3DM3KII-D6GpIAdx.js → diagram-Z3DM3KII-BC1SenHB.js} +1 -1
- package/client-dist/assets/{ebnfDiagram-PWID7BFC-Bm_JuhNL.js → ebnfDiagram-PWID7BFC-EVpri6Ma.js} +1 -1
- package/client-dist/assets/{erDiagram-RLTQ6QDP-u5Ryj9Z_.js → erDiagram-RLTQ6QDP-DthztUaa.js} +1 -1
- package/client-dist/assets/{flowDiagram-HODETNUW-C9A7e1yC.js → flowDiagram-HODETNUW-DEpC5nMx.js} +1 -1
- package/client-dist/assets/{frontendReload-DN8qVYjF.js → frontendReload-CBdyvvdy.js} +1 -1
- package/client-dist/assets/{ganttDiagram-EL5Y4UJY-BEIN_FhZ.js → ganttDiagram-EL5Y4UJY-Csqji8t1.js} +1 -1
- package/client-dist/assets/{gitGraphDiagram-WWUBYQGX-Cu5ow6Ls.js → gitGraphDiagram-WWUBYQGX-DVX1SDIE.js} +1 -1
- package/client-dist/assets/{hostStorage-C37tOOJa.js → hostStorage-D1KAm3U1.js} +1 -1
- package/client-dist/assets/{index-_2WVhpKj.js → index-BESqiBDI.js} +1 -1
- package/client-dist/assets/index-BkOdUxq4.js +2 -0
- package/client-dist/assets/index-CPb-36gi.css +1 -0
- package/client-dist/assets/{index-YAR5D3xY.js → index-CoR-vzsb.js} +1 -1
- package/client-dist/assets/index-Cv3tQXyE.js +1 -0
- package/client-dist/assets/{index-LT-lzpNS.js → index-DSFMItgO.js} +1 -1
- package/client-dist/assets/index-umZg0LZ6.js +81 -0
- package/client-dist/assets/{infoDiagram-27XIBGKW-ILfv0Qu_.js → infoDiagram-27XIBGKW-CHm3qsd2.js} +1 -1
- package/client-dist/assets/{ishikawaDiagram-5VMMS53U-D1P8nenz.js → ishikawaDiagram-5VMMS53U-tBRZwz-_.js} +1 -1
- package/client-dist/assets/{journeyDiagram-3NMN7TZE-CXP61NqX.js → journeyDiagram-3NMN7TZE-EJic7nqD.js} +1 -1
- package/client-dist/assets/{kanban-definition-UXKFOSKX-2x79Nimu.js → kanban-definition-UXKFOSKX-DtzL6eeO.js} +1 -1
- package/client-dist/assets/{layout-D7AfOq-G.js → layout-gb-Axsoq.js} +1 -1
- package/client-dist/assets/{linear-B_4Bripc.js → linear-CAe4xGbR.js} +1 -1
- package/client-dist/assets/{mermaid.core-y_avJe8E.js → mermaid.core-BCu1nv8H.js} +5 -5
- package/client-dist/assets/{mindmap-definition-YA3MSWOX-DwMJuV6d.js → mindmap-definition-YA3MSWOX-C7-KSPtJ.js} +1 -1
- package/client-dist/assets/{pegDiagram-XKGWAZYB-43LaxzRF.js → pegDiagram-XKGWAZYB-iWVH9rbY.js} +1 -1
- package/client-dist/assets/{pieDiagram-E7YTZNPT-DAOi_afd.js → pieDiagram-E7YTZNPT-VKD6PLHa.js} +1 -1
- package/client-dist/assets/{providerChildSessions-BpJF5D9s.css → providerChildSessions-Cd7oK6KQ.css} +1 -1
- package/client-dist/assets/providerChildSessions-DbLFSybt.js +77 -0
- package/client-dist/assets/{quadrantDiagram-AXDQQJYC-BRPBWWpv.js → quadrantDiagram-AXDQQJYC-AXFugcFl.js} +1 -1
- package/client-dist/assets/{railroadDiagram-O6MQD6OU-xAuDG62P.js → railroadDiagram-O6MQD6OU-D6oZy6Al.js} +1 -1
- package/client-dist/assets/{recentProjectPathLinks-B6pQxzWg.js → recentProjectPathLinks-D0Dx6YXT.js} +1 -1
- package/client-dist/assets/{registerServiceWorker-fKJh5dWO.js → registerServiceWorker-B8K2KVOY.js} +1 -1
- package/client-dist/assets/{relayEndpoints-DRyKx83V.js → relayEndpoints-BTq9xppf.js} +1 -1
- package/client-dist/assets/{remoteRoutePaths-BxKY1U2z.js → remoteRoutePaths-D8htA0xa.js} +1 -1
- package/client-dist/assets/{requirementDiagram-BXWQKSXE-BJvybhuU.js → requirementDiagram-BXWQKSXE-Eqtb74It.js} +1 -1
- package/client-dist/assets/{sankeyDiagram-P5KCCOFB-aAAflmwo.js → sankeyDiagram-P5KCCOFB-CxvDiZ1R.js} +1 -1
- package/client-dist/assets/{sequenceDiagram-WJ2MYXX4-CP3BPtU-.js → sequenceDiagram-WJ2MYXX4-BbpkgW2L.js} +1 -1
- package/client-dist/assets/{sessionNavigationState-MSOOrZi4.js → sessionNavigationState-BXejf2ZW.js} +1 -1
- package/client-dist/assets/sessionRouteLayer-D9T2QT8G.js +1 -0
- package/client-dist/assets/{sizeCapture-INFHLROL-BwAQ5zb3.js → sizeCapture-INFHLROL-DcuwWD5r.js} +1 -1
- package/client-dist/assets/{sourceControlNavigationState-t_nQLZvO.js → sourceControlNavigationState-BJbTzWTE.js} +1 -1
- package/client-dist/assets/{speechDraftTransaction-8sgF4uer.js → speechDraftTransaction-WhqFE1h9.js} +1 -1
- package/client-dist/assets/{stateDiagram-D77RDMKH-B8llvNN3.js → stateDiagram-D77RDMKH-Cidpq73w.js} +1 -1
- package/client-dist/assets/stateDiagram-v2-MP3YSRHH-DFqKXxjz.js +1 -0
- package/client-dist/assets/{swimlanes-42K2YHIH-qqdgDD32.js → swimlanes-42K2YHIH-Ba8C7MwG.js} +1 -1
- package/client-dist/assets/swimlanesDiagram-VR7AAH4N-3pW2TcAt.js +8 -0
- package/client-dist/assets/{timeline-definition-24CTP7MA-EBxDGVBl.js → timeline-definition-24CTP7MA-CKefGvUK.js} +1 -1
- package/client-dist/assets/{useAcliCommentarySetting-JMx-BSAu.js → useAcliCommentarySetting-CBKAl7qr.js} +2 -2
- package/client-dist/assets/{useActivityBusState-CnG-LXsr.js → useActivityBusState-C0dor9p7.js} +1 -1
- package/client-dist/assets/{useBackgroundRevalidation-7vLWDD_M.js → useBackgroundRevalidation-C79HAUP3.js} +1 -1
- package/client-dist/assets/{useCodexUpdateStatus-CAR1HkyO.js → useCodexUpdateStatus-CEZO_f2Y.js} +1 -1
- package/client-dist/assets/{useConnectedDevices-DxgKt21O.js → useConnectedDevices-Ds-DuUDc.js} +1 -1
- package/client-dist/assets/{useDocumentTitle-bldu9XOq.js → useDocumentTitle-Xz5t-nlB.js} +1 -1
- package/client-dist/assets/{useEmulators-BPiSdRjQ.js → useEmulators-qS_cCZ3I.js} +1 -1
- package/client-dist/assets/{useFileActivity-D0JXhEz7.js → useFileActivity-BoW4X3DY.js} +1 -1
- package/client-dist/assets/{useFloatingActionButtonEnabled-Dp_hZuYb.js → useFloatingActionButtonEnabled-2_hw7nSa.js} +1 -1
- package/client-dist/assets/{useForkSummaryAutoOpen-Cty_gTm1.js → useForkSummaryAutoOpen-CS33Irpf.js} +1 -1
- package/client-dist/assets/{useGeneratedTitleLength-BpbPYGRf.js → useGeneratedTitleLength-D856ktVg.js} +1 -1
- package/client-dist/assets/{useKeepMobileKeyboardOpenAfterDelivery-BWCiVVkU.js → useKeepMobileKeyboardOpenAfterDelivery-Ba77SbWF.js} +1 -1
- package/client-dist/assets/{useModelSettings-CeABGid0.js → useModelSettings-BdlYk1DT.js} +1 -1
- package/client-dist/assets/{useNotifyInApp-CuUBcZeR.js → useNotifyInApp-DcWe3dh4.js} +1 -1
- package/client-dist/assets/{useOnboarding-BDCBf2Fp.js → useOnboarding-CoE3WF8a.js} +1 -1
- package/client-dist/assets/{useProviders-45TZLkhy.js → useProviders-CeN1PclA.js} +1 -1
- package/client-dist/assets/{useQuestionAsideSetting-B0bjoe-z.js → useQuestionAsideSetting-CPFw1u0y.js} +1 -1
- package/client-dist/assets/{useRecentSessions-COrEGQJH.js → useRecentSessions-ieTzzJu4.js} +1 -1
- package/client-dist/assets/{useRelativeNow-XM1dKxcx.js → useRelativeNow-Ca6QGcPa.js} +1 -1
- package/client-dist/assets/{useReloadNotifications-JBj22syT.js → useReloadNotifications-Dm1jmdIb.js} +1 -1
- package/client-dist/assets/{useRemoteExecutors-Bzvi8gRe.js → useRemoteExecutors-zBAQnQXH.js} +1 -1
- package/client-dist/assets/{useSidebarWidth-CITe0sSV.js → useSidebarWidth-CBCcbSLg.js} +1 -1
- package/client-dist/assets/{useSourceControlCleanLanding-B-8NTKPa.js → useSourceControlCleanLanding-VDlft5tr.js} +1 -1
- package/client-dist/assets/{useStableToolPreviewRendering-CeH1PY9S.js → useStableToolPreviewRendering-hbVp38Jd.js} +1 -1
- package/client-dist/assets/{useStreamingEnabled-C535nHwb.js → useStreamingEnabled-hU1g8i7_.js} +1 -1
- package/client-dist/assets/{useTabTitleActivityPreference-NekVdSEZ.js → useTabTitleActivityPreference-DhREY7m2.js} +1 -1
- package/client-dist/assets/{useVhostAccess-CHT40zJ3.js → useVhostAccess-DUtn_sH1.js} +1 -1
- package/client-dist/assets/{useWorkflowTags-Bl7Czynw.js → useWorkflowTags-DxbEBqtf.js} +1 -1
- package/client-dist/assets/{vennDiagram-4TSXK5OY-BRLuM0pk.js → vennDiagram-4TSXK5OY-CSGBq-Ur.js} +1 -1
- package/client-dist/assets/{wardleyDiagram-VM6X3IG4-D5cPV-h-.js → wardleyDiagram-VM6X3IG4-DIMvcaMb.js} +1 -1
- package/client-dist/assets/{xychartDiagram-S5SC5T6Z-M2QslymW.js → xychartDiagram-S5SC5T6Z-TYXSqT3w.js} +1 -1
- package/client-dist/index.html +3 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +19 -10
- package/dist/app.js.map +1 -1
- package/dist/artifacts/ArtifactServer.d.ts +0 -1
- package/dist/artifacts/ArtifactServer.d.ts.map +1 -1
- package/dist/artifacts/ArtifactServer.js +41 -9
- package/dist/artifacts/ArtifactServer.js.map +1 -1
- package/dist/auth/limitedUserPolicy.d.ts +9 -5
- package/dist/auth/limitedUserPolicy.d.ts.map +1 -1
- package/dist/auth/limitedUserPolicy.js +64 -35
- package/dist/auth/limitedUserPolicy.js.map +1 -1
- package/dist/auth/principal.d.ts +6 -0
- package/dist/auth/principal.d.ts.map +1 -1
- package/dist/auth/principal.js +6 -0
- package/dist/auth/principal.js.map +1 -1
- package/dist/frontend/static.d.ts.map +1 -1
- package/dist/frontend/static.js +2 -1
- package/dist/frontend/static.js.map +1 -1
- package/dist/middleware/authenticated-transport.d.ts +13 -0
- package/dist/middleware/authenticated-transport.d.ts.map +1 -1
- package/dist/middleware/authenticated-transport.js +12 -0
- package/dist/middleware/authenticated-transport.js.map +1 -1
- package/dist/middleware/limited-users.d.ts +9 -5
- package/dist/middleware/limited-users.d.ts.map +1 -1
- package/dist/middleware/limited-users.js +37 -23
- package/dist/middleware/limited-users.js.map +1 -1
- package/dist/routes/file-edit.d.ts +4 -1
- package/dist/routes/file-edit.d.ts.map +1 -1
- package/dist/routes/file-edit.js +22 -6
- package/dist/routes/file-edit.js.map +1 -1
- package/dist/routes/files.d.ts.map +1 -1
- package/dist/routes/files.js +19 -5
- package/dist/routes/files.js.map +1 -1
- package/dist/routes/pdfjs.d.ts +9 -0
- package/dist/routes/pdfjs.d.ts.map +1 -0
- package/dist/routes/pdfjs.js +34 -0
- package/dist/routes/pdfjs.js.map +1 -0
- package/dist/routes/recents.d.ts +4 -1
- package/dist/routes/recents.d.ts.map +1 -1
- package/dist/routes/recents.js +7 -0
- package/dist/routes/recents.js.map +1 -1
- package/dist/routes/settings.d.ts +7 -2
- package/dist/routes/settings.d.ts.map +1 -1
- package/dist/routes/settings.js +43 -1
- package/dist/routes/settings.js.map +1 -1
- package/dist/routes/ws-relay-handlers.d.ts +12 -0
- package/dist/routes/ws-relay-handlers.d.ts.map +1 -1
- package/dist/routes/ws-relay-handlers.js +25 -4
- package/dist/routes/ws-relay-handlers.js.map +1 -1
- package/dist/routes/ws-relay.d.ts.map +1 -1
- package/dist/routes/ws-relay.js +8 -0
- package/dist/routes/ws-relay.js.map +1 -1
- package/dist/sdk/providers/codex-model-catalog.d.ts.map +1 -1
- package/dist/sdk/providers/codex-model-catalog.js +5 -3
- package/dist/sdk/providers/codex-model-catalog.js.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts +4 -1
- package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts +4 -1
- package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/Personality.d.ts +3 -0
- package/dist/sdk/providers/codex-protocol/generated/Personality.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.d.ts +2 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.d.ts.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/{ThreadRollbackParams.js → McpAppDisplayMode.js} +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppDisplayMode.js.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.d.ts +9 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.d.ts.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/{ThreadRollbackResponse.js → McpAppUi.js} +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpAppUi.js.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/Thread.d.ts +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkResponse.d.ts +4 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkResponse.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts +6 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeParams.d.ts +4 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts +9 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts +9 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartResponse.d.ts +4 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadStartResponse.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/TurnStartParams.d.ts +7 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/TurnStartParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts +3 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/index.d.ts +0 -2
- package/dist/sdk/providers/codex-protocol/index.d.ts.map +1 -1
- package/dist/sdk/providers/codex.d.ts +7 -2
- package/dist/sdk/providers/codex.d.ts.map +1 -1
- package/dist/sdk/providers/codex.js +21 -20
- package/dist/sdk/providers/codex.js.map +1 -1
- package/dist/services/ArtifactRebuildService.d.ts +11 -14
- package/dist/services/ArtifactRebuildService.d.ts.map +1 -1
- package/dist/services/ArtifactRebuildService.js +15 -7
- package/dist/services/ArtifactRebuildService.js.map +1 -1
- package/dist/services/PdfjsAssetCache.d.ts +20 -0
- package/dist/services/PdfjsAssetCache.d.ts.map +1 -0
- package/dist/services/PdfjsAssetCache.js +131 -0
- package/dist/services/PdfjsAssetCache.js.map +1 -0
- package/package.json +3 -3
- package/client-dist/assets/App-DYWU2-wq.js +0 -2
- package/client-dist/assets/AppearanceSettings-Ci0wlAx3.js +0 -2
- package/client-dist/assets/LocalMediaModal-DOcizK52.css +0 -1
- package/client-dist/assets/LocalMediaModal-DyDpC0dk.js +0 -12
- package/client-dist/assets/MessageInput-leX__dbU.js +0 -3
- package/client-dist/assets/MessageList-DDA4Q_Gj.js +0 -4
- package/client-dist/assets/ProviderBadge-BKZVllDn.js +0 -1
- package/client-dist/assets/ProviderChildSessionPage-vpu5u3YA.js +0 -1
- package/client-dist/assets/SessionPage-BJ5qaa-G.js +0 -50
- package/client-dist/assets/SessionPage-BiV0X3n1.css +0 -1
- package/client-dist/assets/SpeechControlMenu-DEDIWl9h.js +0 -2
- package/client-dist/assets/ViewerModePage-Dyq_I7ws.js +0 -1
- package/client-dist/assets/channel-DwT-nHaK.js +0 -1
- package/client-dist/assets/classDiagram-ZZMXUADV-DdlhZ-2W.js +0 -1
- package/client-dist/assets/classDiagram-v2-VYDZK3BY-DdlhZ-2W.js +0 -1
- package/client-dist/assets/index-BY-TgOY-.js +0 -81
- package/client-dist/assets/index-BgkZrNQv.js +0 -1
- package/client-dist/assets/index-BrCZcBcO.js +0 -2
- package/client-dist/assets/index-wA2zlxt-.css +0 -1
- package/client-dist/assets/providerChildSessions-DVWCZpC4.js +0 -78
- package/client-dist/assets/stateDiagram-v2-MP3YSRHH-CD7vRqY6.js +0 -1
- package/client-dist/assets/swimlanesDiagram-VR7AAH4N-NBdWyLIY.js +0 -8
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts +0 -14
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.d.ts.map +0 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackParams.js.map +0 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.d.ts +0 -12
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.d.ts.map +0 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadRollbackResponse.js.map +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var Pc=Object.defineProperty;var Ec=(e,t,n)=>t in e?Pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var be=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);import{u as Z,r as m,bp as yn,j as s,ax as br,bt as pa,cv as Ic,cw as Mc,cx as vo,cB as $c,cC as Lc,cE as Ac,cz as wo,cF as Fc,cG as Bc,cH as _o,cA as Dc,cm as I,cn as Ke,cp as ce,co as ke,cI as te,cJ as Xe,cK as J,cL as Oc,cM as qn,cN as Uc,cO as Hc,cP as Wc,cQ as Js,cR as Vc,cS as Gc,cT as zc,cU as qc,cV as Kc,cW as Xc,cX as Yc,cY as Jc,cZ as Qc,c_ as Zc,c$ as ed,d0 as td,d1 as nd,d2 as sd,d3 as rd,L as vr,d4 as us,
|
|
1
|
+
var Pc=Object.defineProperty;var Ec=(e,t,n)=>t in e?Pc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var be=(e,t,n)=>Ec(e,typeof t!="symbol"?t+"":t,n);import{u as Z,r as m,bp as yn,j as s,ax as br,bt as pa,cv as Ic,cw as Mc,cx as vo,cB as $c,cC as Lc,cE as Ac,cz as wo,cF as Fc,cG as Bc,cH as _o,cA as Dc,cm as I,cn as Ke,cp as ce,co as ke,cI as te,cJ as Xe,cK as J,cL as Oc,cM as qn,cN as Uc,cO as Hc,cP as Wc,cQ as Js,cR as Vc,cS as Gc,cT as zc,cU as qc,cV as Kc,cW as Xc,cX as Yc,cY as Jc,cZ as Qc,c_ as Zc,c$ as ed,d0 as td,d1 as nd,d2 as sd,d3 as rd,L as vr,d4 as us,bV as ms,s as ga,d5 as xa,cc as Lt,d6 as od,d7 as id,bu as Ss,d8 as No,d9 as ko}from"./index-umZg0LZ6.js";import{H as Kn,V as nn,Z as ya,a as on,X as fs,aA as ad,aB as ld,Y as cd}from"./client-Ci_HPGfl.js";import{ao as at,a4 as dd,g as tt,a7 as hs,b as wr,p as qt,f as ps,h as ud,q as _r,k as Nr,e as ge,ap as kr,a0 as ja,a2 as md,L as ba,aq as fd,r as oe,$ as hd,v as pd,S as gd,ar as gs,X as Sr,as as va,d as xd,at as Ut,au as yd,O as jd}from"./LocalMediaModal-B9eHVx6y.js";import{l as bd,L as St,T as Cr,u as vd,a as wd}from"./useAcliCommentarySetting-CBKAl7qr.js";import{i as _d}from"./postCompactReplay-D6HuoQK2.js";import{aA as Nd,aB as kd,aC as Sd,aD as Cd,aE as Tr,aF as Rr,aG as wa,aH as Pr,ax as _a,i as Na,o as Td,r as ka,aI as Sa,aJ as Er,aK as Rd,aL as Pd,aM as Ed,R as Ca,aN as Id,aO as Ta,aP as Ir,aQ as Md,q as st,aR as $d,aS as Ld,aT as Ye,aU as Ad,aV as mn,aW as Fd,aX as Ra,aY as Bd,O as Dd,aZ as Od,a_ as So,a$ as Ud,b0 as Hd,b1 as Wd,b2 as Vd,M as Pa,b3 as Ea,b4 as Gd,b5 as zd,b6 as Co,w as qd,b7 as Kd,b8 as Xd,j as Ia}from"./providerChildSessions-DbLFSybt.js";import{a as xs,b as Yd}from"./recentProjectPathLinks-D0Dx6YXT.js";import{C as Ma}from"./index-CoR-vzsb.js";import{M as Jd}from"./MessageAge-CaPpa1nH.js";import{B as Qd}from"./BangCommandDisplayObject-BH2KRGnc.js";import{u as $a,A as Zd}from"./AttachmentChip-BFve3lTD.js";import{a as Cs,r as Cn}from"./browserDebugPerformance-ZT9tAT-A.js";import{b as Kt,x as eu,M as La,u as Mr,g as Aa}from"./Modal-ClSjJagX.js";import{u as tu}from"./useStableToolPreviewRendering-hbVp38Jd.js";import{a as ve}from"./SchemaValidationContext-57RCj4c4.js";import{S as nu}from"./SourceFileHeaderActions-PjhUGnn6.js";function mt(e,t){const n=e.slice(0,4097),r=n.indexOf(`
|
|
2
2
|
`),o=r<0?n:n.slice(0,r);return(r>=0||t)&&o.length<=4096?Nd(o):null}class Fa{constructor(t="stdout"){be(this,"source","");be(this,"framer",null);be(this,"format","raw");be(this,"previous",null);be(this,"textBlock",[]);be(this,"afterCommentary",!1);be(this,"nextId",0);this.channel=t}appendSnapshot(t,n,r){let o=this.source.length;if(!this.framer){const a=t.indexOf(`
|
|
3
|
-
`);if(a<0&&!n)return[];const l=mt(t,n);this.format=l==="lines"?"lines":r?"json":"raw",this.framer=new kd(this.format==="json"?"json":"lines"),l&&(o=a<0?t.length:a+1)}const i=this.framer.append(t.slice(o));return this.source=t,n&&i.push(...this.framer.finish()),i.map(a=>{const l=this.format==="json"?Sd(a):this.format==="lines"?Cd(a):{source:a,data:a,commentary:[],removed:[],metadataOnly:!1};let c=null;if(this.channel==="stdout"||this.channel==="unknown"&&this.format==="json"){const d=this.previous,u=this.textBlock;this.format==="lines"&&u.length?c=()=>u.join(""):d&&(c=()=>d.data)}return l.metadataOnly?this.afterCommentary=!0:(this.format==="lines"&&(this.afterCommentary&&(this.textBlock=[]),this.textBlock.push(l.data)),this.afterCommentary=!1,a.trim()&&(this.previous=l)),{id:this.nextId++,record:l,getPreviousContext:c}})}}function Qs(e,t){return[...t.metadataOnly?[]:[{id:e,text:t.data,kind:"data",opaque:t.json}],...t.commentary.map(n=>({id:`${e}:${n.id}`,text:n.text,kind:"commentary"}))]}const su=/<ide_(opened_file|selection)>[\s\S]*?<\/ide_\1>/g,ru=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g;function ou(e){return e.replace(su,"").trim()}function iu(e){const t=e.match(/(?:user opened the file|opened the file)\s+(.+?)\s+in the IDE/i);return(t==null?void 0:t[1])??null}function au(e){const t=[];for(const n of e.matchAll(ru)){const r=n[1];if(r){const o=iu(r);o&&t.push(o)}}return t}function lu(e){const t=e.split(/[\\/]/);return t[t.length-1]||e}function Zs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ba(e){try{return JSON.parse(e)}catch{return}}const cu=new Set(["chunk_id","wall_time_seconds","exit_code","output","session_id","original_token_count"]),du=new Set(["i","status","value"]);function uu(e){let t=Ba(e);if(Zs(t)){if(t.status==="fulfilled"){if(!Object.keys(t).every(n=>du.has(n))||t.i!==void 0&&(!Number.isInteger(t.i)||Number(t.i)<0))return;t=t.value}if(!(!Zs(t)||!Object.keys(t).every(n=>cu.has(n))||typeof t.chunk_id!="string"||!t.chunk_id||typeof t.output!="string"||typeof t.wall_time_seconds!="number"||!Number.isFinite(t.wall_time_seconds)||t.wall_time_seconds<0)&&!(t.exit_code!==void 0&&(typeof t.exit_code!="number"||!Number.isInteger(t.exit_code)))&&!(t.session_id!==void 0&&!(typeof t.session_id=="string"&&t.session_id.length>0)&&!(typeof t.session_id=="number"&&Number.isInteger(t.session_id)&&t.session_id>=0))&&!(t.exit_code===void 0&&t.session_id===void 0)&&!(t.original_token_count!==void 0&&!(typeof t.original_token_count=="number"&&Number.isInteger(t.original_token_count)&&t.original_token_count>=0)))return{kind:"command-output",text:t.output,durationSeconds:t.wall_time_seconds,...typeof t.exit_code=="number"?{exitCode:t.exit_code}:{},...typeof t.session_id=="string"||typeof t.session_id=="number"?{sessionId:t.session_id}:{}}}}function ht(e,t={}){const n=typeof e=="string"?Ba(e):e;if(!Array.isArray(n)||n.length===0)return;const r=[];for(const o of n){if(!Zs(o)||typeof o.type!="string"||!["input_text","output_text","text"].includes(o.type)||typeof o.text!="string")return;const i=o.text;r.length===0&&/^Script (?:completed|running with cell ID \w+)\r?\nWall time[^\n]*\r?\nOutput:\r?\n$/.test(i)?r.push({kind:"script-status",text:i.replace(/\r?\nOutput:\r?\n$/,"")}):r.push((t.commandResults!=="preserve"?uu(i):void 0)??{kind:"text",text:i})}return{parts:r}}const Tn=["black","red","green","yellow","blue","magenta","cyan","white"];function Da(){return{fg:null,bg:null,bold:!1,italic:!1,underline:!1,inverse:!1,strikethrough:!1}}function mu(e){const t=[],n=e.inverse?e.bg:e.fg,r=e.inverse?e.fg:e.bg;return n&&t.push(`ansi-fg-${n}`),r&&t.push(`ansi-bg-${r}`),e.inverse&&!n&&!r&&t.push("ansi-inverse"),e.bold&&t.push("ansi-bold"),e.italic&&t.push("ansi-italic"),e.underline&&t.push("ansi-underline"),e.strikethrough&&t.push("ansi-strikethrough"),t}function fu(e,t){let n=0;for(;n<t.length;){const r=t[n]??0;if(r===0)Object.assign(e,Da());else if(r===1)e.bold=!0;else if(r===3)e.italic=!0;else if(r===4)e.underline=!0;else if(r===7)e.inverse=!0;else if(r===9)e.strikethrough=!0;else if(r===22)e.bold=!1;else if(r===23)e.italic=!1;else if(r===24)e.underline=!1;else if(r===27)e.inverse=!1;else if(r===29)e.strikethrough=!1;else if(r>=30&&r<=37)e.fg=Tn[r-30]??null;else if(r===38){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.fg=null}else if(r===39)e.fg=null;else if(r>=40&&r<=47)e.bg=Tn[r-40]??null;else if(r===48){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.bg=null}else r===49?e.bg=null:r>=90&&r<=97?e.fg=`bright-${Tn[r-90]}`:r>=100&&r<=107&&(e.bg=`bright-${Tn[r-100]}`);n++}}function To(e){return bd(e,{external:!0},hu)}function hu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const pu=/[\d;:?\s]/;function gu(e){return e.indexOf("\x1B[")!==-1}function xu(e){const t=Da();let n="",r="",o=0;const i=()=>{if(r.length===0)return;const a=mu(t);a.length>0?n+=`<span class="${a.join(" ")}">${To(r)}</span>`:n+=To(r),r=""};for(;o<e.length;){const a=e[o];if(a==="\x1B"&&e[o+1]==="["){i();let l=o+2,c="";for(;l<e.length&&pu.test(e[l]??"");)c+=e[l],l++;const d=e[l]??"";if(d==="m"){const u=c.length>0?c.split(";").map(f=>parseInt(f,10)||0):[0];fu(t,u)}o=l+(d?1:0)}else if(a==="\x1B"&&e[o+1]==="]"){i();let l=o+2;for(;l<e.length;){const c=e[l];if(c==="\x07"){l++;break}if(c==="\x1B"&&e[l+1]==="\\"){l+=2;break}l++}o=l}else a==="\x1B"?(i(),o+=e[o+1]!==void 0?2:1):(r+=a,o++)}return i(),n}const yu="<synthetic>",ju="Continue from where you left off.",bu="No response requested.";function Oa(e){const t=e.message&&typeof e.message=="object"?e.message:void 0,n=(t==null?void 0:t.content)??e.content;return typeof n=="string"?n.trim():Array.isArray(n)&&n.filter(o=>!!o&&typeof o=="object"&&o.type==="text"&&typeof o.text=="string").map(o=>o.text).join("").trim()||void 0}function vu(e){var n;if(!e||typeof e!="object")return!1;const t=(n=e.message)==null?void 0:n.role;return e.type!=="user"&&t!=="user"||e.isMeta!==!0?!1:Oa(e)===ju}function wu(e){if(!e||typeof e!="object")return!1;const t=e.message&&typeof e.message=="object"?e.message:void 0;return e.type!=="assistant"&&(t==null?void 0:t.role)!=="assistant"||(t==null?void 0:t.model)!==yu?!1:Oa(e)===bu}
|
|
3
|
+
`);if(a<0&&!n)return[];const l=mt(t,n);this.format=l==="lines"?"lines":r?"json":"raw",this.framer=new kd(this.format==="json"?"json":"lines"),l&&(o=a<0?t.length:a+1)}const i=this.framer.append(t.slice(o));return this.source=t,n&&i.push(...this.framer.finish()),i.map(a=>{const l=this.format==="json"?Sd(a):this.format==="lines"?Cd(a):{source:a,data:a,commentary:[],removed:[],metadataOnly:!1};let c=null;if(this.channel==="stdout"||this.channel==="unknown"&&this.format==="json"){const d=this.previous,u=this.textBlock;this.format==="lines"&&u.length?c=()=>u.join(""):d&&(c=()=>d.data)}return l.metadataOnly?this.afterCommentary=!0:(this.format==="lines"&&(this.afterCommentary&&(this.textBlock=[]),this.textBlock.push(l.data)),this.afterCommentary=!1,a.trim()&&(this.previous=l)),{id:this.nextId++,record:l,getPreviousContext:c}})}}function Qs(e,t){return[...t.metadataOnly?[]:[{id:e,text:t.data,kind:"data",opaque:t.json}],...t.commentary.map(n=>({id:`${e}:${n.id}`,text:n.text,kind:"commentary"}))]}const su=/<ide_(opened_file|selection)>[\s\S]*?<\/ide_\1>/g,ru=/<ide_opened_file>([\s\S]*?)<\/ide_opened_file>/g;function ou(e){return e.replace(su,"").trim()}function iu(e){const t=e.match(/(?:user opened the file|opened the file)\s+(.+?)\s+in the IDE/i);return(t==null?void 0:t[1])??null}function au(e){const t=[];for(const n of e.matchAll(ru)){const r=n[1];if(r){const o=iu(r);o&&t.push(o)}}return t}function lu(e){const t=e.split(/[\\/]/);return t[t.length-1]||e}function Zs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ba(e){try{return JSON.parse(e)}catch{return}}const cu=new Set(["chunk_id","wall_time_seconds","exit_code","output","session_id","original_token_count"]),du=new Set(["i","status","value"]);function uu(e){let t=Ba(e);if(Zs(t)){if(t.status==="fulfilled"){if(!Object.keys(t).every(n=>du.has(n))||t.i!==void 0&&(!Number.isInteger(t.i)||Number(t.i)<0))return;t=t.value}if(!(!Zs(t)||!Object.keys(t).every(n=>cu.has(n))||typeof t.chunk_id!="string"||!t.chunk_id||typeof t.output!="string"||typeof t.wall_time_seconds!="number"||!Number.isFinite(t.wall_time_seconds)||t.wall_time_seconds<0)&&!(t.exit_code!==void 0&&(typeof t.exit_code!="number"||!Number.isInteger(t.exit_code)))&&!(t.session_id!==void 0&&!(typeof t.session_id=="string"&&t.session_id.length>0)&&!(typeof t.session_id=="number"&&Number.isInteger(t.session_id)&&t.session_id>=0))&&!(t.exit_code===void 0&&t.session_id===void 0)&&!(t.original_token_count!==void 0&&!(typeof t.original_token_count=="number"&&Number.isInteger(t.original_token_count)&&t.original_token_count>=0)))return{kind:"command-output",text:t.output,durationSeconds:t.wall_time_seconds,...typeof t.exit_code=="number"?{exitCode:t.exit_code}:{},...typeof t.session_id=="string"||typeof t.session_id=="number"?{sessionId:t.session_id}:{}}}}function ht(e,t={}){const n=typeof e=="string"?Ba(e):e;if(!Array.isArray(n)||n.length===0)return;const r=[];for(const o of n){if(!Zs(o)||typeof o.type!="string"||!["input_text","output_text","text"].includes(o.type)||typeof o.text!="string")return;const i=o.text;r.length===0&&/^Script (?:completed|running with cell ID \w+)\r?\nWall time[^\n]*\r?\nOutput:\r?\n$/.test(i)?r.push({kind:"script-status",text:i.replace(/\r?\nOutput:\r?\n$/,"")}):r.push((t.commandResults!=="preserve"?uu(i):void 0)??{kind:"text",text:i})}return{parts:r}}const Tn=["black","red","green","yellow","blue","magenta","cyan","white"];function Da(){return{fg:null,bg:null,bold:!1,italic:!1,underline:!1,inverse:!1,strikethrough:!1}}function mu(e){const t=[],n=e.inverse?e.bg:e.fg,r=e.inverse?e.fg:e.bg;return n&&t.push(`ansi-fg-${n}`),r&&t.push(`ansi-bg-${r}`),e.inverse&&!n&&!r&&t.push("ansi-inverse"),e.bold&&t.push("ansi-bold"),e.italic&&t.push("ansi-italic"),e.underline&&t.push("ansi-underline"),e.strikethrough&&t.push("ansi-strikethrough"),t}function fu(e,t){let n=0;for(;n<t.length;){const r=t[n]??0;if(r===0)Object.assign(e,Da());else if(r===1)e.bold=!0;else if(r===3)e.italic=!0;else if(r===4)e.underline=!0;else if(r===7)e.inverse=!0;else if(r===9)e.strikethrough=!0;else if(r===22)e.bold=!1;else if(r===23)e.italic=!1;else if(r===24)e.underline=!1;else if(r===27)e.inverse=!1;else if(r===29)e.strikethrough=!1;else if(r>=30&&r<=37)e.fg=Tn[r-30]??null;else if(r===38){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.fg=null}else if(r===39)e.fg=null;else if(r>=40&&r<=47)e.bg=Tn[r-40]??null;else if(r===48){const o=t[n+1];o===5?n+=2:o===2&&(n+=4),e.bg=null}else r===49?e.bg=null:r>=90&&r<=97?e.fg=`bright-${Tn[r-90]}`:r>=100&&r<=107&&(e.bg=`bright-${Tn[r-100]}`);n++}}function To(e){return bd(e,{external:!0},hu)}function hu(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}const pu=/[\d;:?\s]/;function gu(e){return e.indexOf("\x1B[")!==-1}function xu(e){const t=Da();let n="",r="",o=0;const i=()=>{if(r.length===0)return;const a=mu(t);a.length>0?n+=`<span class="${a.join(" ")}">${To(r)}</span>`:n+=To(r),r=""};for(;o<e.length;){const a=e[o];if(a==="\x1B"&&e[o+1]==="["){i();let l=o+2,c="";for(;l<e.length&&pu.test(e[l]??"");)c+=e[l],l++;const d=e[l]??"";if(d==="m"){const u=c.length>0?c.split(";").map(f=>parseInt(f,10)||0):[0];fu(t,u)}o=l+(d?1:0)}else if(a==="\x1B"&&e[o+1]==="]"){i();let l=o+2;for(;l<e.length;){const c=e[l];if(c==="\x07"){l++;break}if(c==="\x1B"&&e[l+1]==="\\"){l+=2;break}l++}o=l}else a==="\x1B"?(i(),o+=e[o+1]!==void 0?2:1):(r+=a,o++)}return i(),n}const yu="<synthetic>",ju="Continue from where you left off.",bu="No response requested.";function Oa(e){const t=e.message&&typeof e.message=="object"?e.message:void 0,n=(t==null?void 0:t.content)??e.content;return typeof n=="string"?n.trim():Array.isArray(n)&&n.filter(o=>!!o&&typeof o=="object"&&o.type==="text"&&typeof o.text=="string").map(o=>o.text).join("").trim()||void 0}function vu(e){var n;if(!e||typeof e!="object")return!1;const t=(n=e.message)==null?void 0:n.role;return e.type!=="user"&&t!=="user"||e.isMeta!==!0?!1:Oa(e)===ju}function wu(e){if(!e||typeof e!="object")return!1;const t=e.message&&typeof e.message=="object"?e.message:void 0;return e.type!=="assistant"&&(t==null?void 0:t.role)!=="assistant"||(t==null?void 0:t.model)!==yu?!1:Oa(e)===bu}const _u="_notice_ztq97_1",Nu="_label_ztq97_16",ku="_objective_ztq97_21",Su="_flag_ztq97_27",Dn={notice:_u,label:Nu,objective:ku,flag:Su};function Cu({objective:e,status:t}){const{t:n}=Z();return s.jsxs("div",{className:Dn.notice,title:t,children:[s.jsx("strong",{className:Dn.label,children:n("goalNoticeLabel")}),s.jsx("span",{className:Dn.objective,children:s.jsx(St,{text:e})})]})}function G_({objective:e,status:t,onToggle:n,onEdit:r}){const{t:o}=Z(),[i,a]=m.useState(!1),l=t==="active"?"pause":t==="paused"||t==="blocked"||t==="usageLimited"?"resume":void 0,c={active:o("goalStatusActive"),paused:o("goalStatusPaused"),blocked:o("goalStatusBlocked"),usageLimited:o("goalStatusUsageLimited"),budgetLimited:o("goalStatusBudgetLimited"),complete:o("goalStatusComplete")},d=t?c[t]??t:void 0,u=yn([d&&o("goalFlagStatus",{status:d}),e,i?o("goalFlagUpdating"):n&&l?o(l==="pause"?"goalFlagPauseHint":"goalFlagResumeHint"):void 0].filter(Boolean).join(`
|
|
4
4
|
|
|
5
5
|
`));return s.jsx("button",{type:"button",className:Dn.flag,...u,"aria-label":o("goalFlagLabel",{objective:e}),"data-goal-status":t??void 0,"aria-busy":i,"aria-disabled":i,onClick:async()=>{if(!(i||!l||!n)){a(!0);try{await n(l)}finally{a(!1)}}},onMouseDown:f=>{f.button===2&&f.preventDefault()},onContextMenu:r,children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75","aria-hidden":"true",children:s.jsx("path",{d:"M5 21V4m0 0c5-5 9 5 14 0v10c-5 5-9-5-14 0"})})})}const Tu={activeToolApproval:!0,markdown:!0,workflowTags:!0,workflowSchemaFiles:!0},Ru=Object.keys(Tu),Ro=new WeakMap,Pu=3;function Eu(e,t,n){const r=t==null?void 0:t.markdown,o=t==null?void 0:t.activeToolApproval,i=Ro.get(e),a=i==null?void 0:i.find(d=>d.compiler===n&&Ru.every(u=>d[u]===(t==null?void 0:t[u])));if(a)return a.items;const l=n(e,t),c=i??[];return c.push({workflowSchemaFiles:t==null?void 0:t.workflowSchemaFiles,workflowTags:t==null?void 0:t.workflowTags,activeToolApproval:o,compiler:n,items:l,markdown:r}),c.length>Pu&&c.shift(),Ro.set(e,c),l}function Po(e){return e.type==="system"&&e.subtype==="compact_boundary"}function Iu(e){return e.sourceMessages.some(t=>t.type==="system"&&t.subtype==="compact_boundary")}function Mu(e){const t=[],n=[];for(const r of e)typeof r=="string"&&r.startsWith("compactMetadata:")?t.push(r):n.push(r);return[...n,...t]}function $u(e){const t=e[0];if(!t)throw new Error("Cannot merge an empty compact boundary run");const n=e.find(Iu)??t,r=e.flatMap(i=>i.sourceMessages),o=Mu(e.flatMap(i=>i.details??[]));return{type:"system",id:n.id,subtype:"compact_boundary",content:n.content,status:n.status,configChanged:n.configChanged,isSubagent:n.isSubagent,sourceMessages:r,details:o.length>0?o:void 0}}function Lu(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!r||!Po(r)){r&&t.push(r),n+=1;continue}const o=[r];let i=n+1;for(;i<e.length;){const a=e[i];if(!a||!Po(a))break;o.push(a),i+=1}t.push($u(o)),n=i}return t}const Au="<task-notification>",Fu="</task-notification>";function Bu(e){var n;const t=((n=e.message)==null?void 0:n.content)??e.content;return typeof t=="string"?t:void 0}function Du(e){const t=e.trim();return t.startsWith(Au)&&t.endsWith(Fu)}function Ua(e){const t=e.origin;if((t==null?void 0:t.kind)==="task-notification")return!0;const n=Bu(e);return n!==void 0&&Du(n)}function At(e,t){var o;const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e),r=(o=n==null?void 0:n[1])==null?void 0:o.trim();return r||void 0}function Ou(e){return{taskId:At(e,"task-id"),toolUseId:At(e,"tool-use-id"),outputFile:At(e,"output-file"),status:At(e,"status"),summary:At(e,"summary"),event:At(e,"event")}}function Uu(e){const t=e.match(/(?:^|\n)\s*(?:Error:\s*)?(?:Process exited with code|Exit code:?)\s*(-?\d+)\b/i);if(t!=null&&t[1])return Number.parseInt(t[1],10)}function Hu(e){const t=e.match(/(?:^|\n)\s*Wall time:?\s+([^\n]+)\s*(?:\n|$)/i);if(t!=null&&t[1])return t[1].trim()}const Wu=/(?:^|\n)\s*Script\s+running\s+with\s+cell\s+ID\s+(\w+)\b/i;function Xn(e){var t;return(t=Wu.exec(e))==null?void 0:t[1]}function Me(e,t={}){const n=e.match(/(?:^|\n)\s*Output:\s*\n([\s\S]*)$/i),r=t.bareExitCodeIsEnvelope?e.match(/^\s*(?:Error:\s*)?(?:Process exited with code|Exit code:?)\s*(-?\d+)\b[^\n]*(?:\n|$)/i):null,o=!!n||!!r,i=((n==null?void 0:n[1])??(r?e.slice(r[0].length):e)).trimEnd(),a=n?Uu(e):r!=null&&r[1]?Number.parseInt(r[1],10):void 0;return{output:i,exitCode:a,wallTime:Hu(e),hasEnvelope:o}}function Eo(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function Ct(e){if(!e||typeof e!="object")return{};const t=e,n=Eo(t.exitCode??t.exit_code),r=Eo(t.durationSeconds??t.wall_time_seconds);return{...n!==void 0?{exitCode:n}:{},...r!==void 0?{durationSeconds:r}:{}}}function et(e){if(!Number.isFinite(e)||e<0)return"";if(e<60)return`${Math.round(e*10)/10}s`;if(e<3600){const r=Math.floor(e/60),o=Math.round(e-r*60);return o>=60?`${r+1}m`:o>0?`${r}m${o}s`:`${r}m`}const t=Math.floor(e/3600),n=Math.round((e-t*60*60)/60);return n>=60?`${t+1}h`:n>0?`${t}h${n}m`:`${t}h`}function Vu(e){const t=[];if(typeof e.content=="string")t.push(e.content);else if(Array.isArray(e.content))for(const l of e.content)l.type==="text"&&l.text&&t.push(l.text);const n=t.join(`
|
|
6
6
|
`);if(!n)return;const r=Gu(e),o=n.match(/^agentId:\s*(\S+)/m);if(!o)return;const i={agentId:o[1],status:"completed"};r&&r.length>0&&(i.content=r);const a=n.match(/<usage>([\s\S]*?)<\/usage>/);if(a!=null&&a[1]){const l=a[1],c=l.match(/total_tokens:\s*(\d+)/),d=l.match(/tool_uses:\s*(\d+)/),u=l.match(/duration_ms:\s*(\d+)/);c!=null&&c[1]&&(i.totalTokens=Number(c[1])),d!=null&&d[1]&&(i.totalToolUseCount=Number(d[1])),u!=null&&u[1]&&(i.totalDurationMs=Number(u[1]))}return i}function Io(e){return e.replace(/^agentId:\s*\S+.*$/gm,"").replace(/<usage>[\s\S]*?<\/usage>/g,"").trim()}function Gu(e){if(typeof e.content=="string"){const n=Io(e.content);return n?[{type:"text",text:n}]:void 0}if(!Array.isArray(e.content))return;const t=[];for(const n of e.content)if(!(!n||typeof n!="object")){if(n.type==="text"&&typeof n.text=="string"){const r=Io(n.text);if(!r)continue;t.push({...n,text:r});continue}t.push(n)}return t.length>0?t:void 0}function ys(e){return typeof e=="string"?e:e.map(t=>t.type==="text"&&typeof t.text=="string"?t.text:"").filter(Boolean).join(`
|
|
7
7
|
`)}function zu(e){return e.type==="system"&&e.subtype==="local_command"}function qu(e){return e.type!=="user_prompt"||!e.sourceMessages.some(t=>t.isMeta===!0)?!1:ys(e.content).trimStart().startsWith("Base directory for this skill:")}function Mo(e){const t=e.promptId;return typeof t=="string"&&t?t:null}function Ku(e,t){const n=new Set(e.sourceMessages.map(Kn).filter(Boolean)),r=t.sourceMessages.map(a=>typeof a.parentUuid=="string"?a.parentUuid:null).filter(a=>a!==null);if(r.length>0&&n.size>0)return r.some(a=>n.has(a));const o=new Set(e.sourceMessages.map(Mo).filter(a=>a!==null)),i=t.sourceMessages.map(Mo).filter(a=>a!==null);return i.length>0&&o.size>0?i.some(a=>o.has(a)):!0}function Xu(e,t){return{...e,sourceMessages:[...e.sourceMessages,...t.sourceMessages],details:[...e.details??[],t.content]}}function Yu(e){const t=[];let n=0;for(;n<e.length;){const r=e[n],o=e[n+1];if(r&&o&&zu(r)&&qu(o)&&Ku(r,o)){t.push(Xu(r,o)),n+=2;continue}r&&t.push(r),n+=1}return t}const Ju=/\s*\(disable recaps in \/config\)\s*$/u;function Qu(e){return e.replace(Ju,"")}function Zu(e,t,n){const r=[],o=new Map,i=new Map,a={lastSignature:null},l=em(e,(t==null?void 0:t.activeToolApproval)===!0);for(const c of e)um(c,r,o,i,l,a,t,n);return r}function em(e,t){const n=new Set,r=t?tm(e):e.length;for(let o=0;o<e.length;o++){const i=e[o];if(i!=null&&i.orphanedToolUseIds&&!(t&&o>=r))for(const a of i.orphanedToolUseIds)n.add(a)}return n}function tm(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n&&cm(n))return t}return 0}const nm="Reasoning [internal]";function js(e){var t;return((t=e.message)==null?void 0:t.content)??e.content}const sm="This session is being continued from a previous conversation that ran out of context";function Ha(e){var o;const t=js(e);if(t===void 0)return!1;const n=typeof t=="string"?t:ys(t);if(!_d(n))return!1;const r=((o=e.message)==null?void 0:o.role)??e.role;return e.type==="user"||r==="user"}function er(e){var i;if(e.isCompactSummary===!0)return!0;const t=js(e);if(t===void 0||!(typeof t=="string"?t:ys(t)).trimStart().startsWith(sm))return!1;const o=((i=e.message)==null?void 0:i.role)??e.role;return e.type==="user"||o==="user"}function Wa(e){const t=e.trim().replace(/^\/+/,"").toLowerCase();return t==="compact"||t==="compress"}function rm(e){if(typeof e!="string"||Tr(e))return null;const t=Rr(e);if(t)return Wa(t.command)?null:wa(t);const n=Pr(e);if(n!==null)return n?_a(n)?null:n:null;const r=e.trim();return r||null}function om(e){const t=e.details;if(!Array.isArray(t))return;const n=t.filter(r=>typeof r=="string"&&!!r.trim());return n.length>0?n:void 0}function im(e){const t=e.compactMetadata;return ym(t)?`compactMetadata:
|
|
8
8
|
${JSON.stringify(t,null,2)}`:null}function am(e){const t=[],n=e.compactSummaryText;typeof n=="string"&&n.trim()&&t.push(n.trim());const r=im(e);return r&&t.push(r),t}function $o(e){return e===void 0?[]:[e]}function lm(e){const t=js(e);return e.isMeta===!0&&t!==void 0&&ys(t).trimStart().startsWith("Base directory for this skill:")}function cm(e){var o;const t=js(e),n=((o=e.message)==null?void 0:o.role)??e.role;return!(e.type==="user"||n==="user")||Ua(e)||er(e)||Ha(e)||lm(e)?!1:Array.isArray(t)?!t.every(i=>i.type==="tool_result"):typeof t!="string"||e.isMeta===!0&&Tr(t)||Pr(t)!==null?!1:!Rr(t)}function dm(e){const t=e==null?void 0:e.trim();return!!t&&t!==nm}function Lo(e){var t;for(let n=e.length-1;n>=0;n--){const r=e[n];if((r==null?void 0:r.type)==="text"&&((t=r.text)!=null&&t.trim()))return n}return-1}function um(e,t,n,r,o,i,a,l){var y,x,b,_,N,v,j,C;const c=Kn(e);if(vu(e)||Ha(e))return;if(wu(e)){t.push({type:"system",id:c,subtype:"no_model_turn",content:"Session continued without running a turn",sourceMessages:[e],isSubagent:e.isSubagent});return}if(e.type==="error"){const w=typeof e.error=="string"&&e.error||typeof e.content=="string"&&e.content||"Agent error",k={type:"system",id:c||`error-${e.timestamp??Date.now()}`,subtype:e.codexWillRetry===!0?"warning":"error",content:w,sourceMessages:[e]};t.push(k);return}if(e.type==="system"){const w=e.subtype??"unknown";if(w==="informational"){typeof e.content=="string"&&e.content.trim()&&t.push({type:"system",id:c,subtype:e.level==="warning"?"warning":"informational",content:e.content,sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="local_command"){const k=rm(e.content);k!==null&&t.push({type:"system",id:c,subtype:w,content:k,details:om(e),sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="rewound_group"){t.push({type:"system",id:c,subtype:w,content:typeof e.content=="string"?e.content:"",sourceMessages:[e]});return}if(w==="tool_output"){const k=typeof e.codexToolName=="string"?e.codexToolName:"",$=[typeof e.codexToolNamespace=="string"?e.codexToolNamespace:"",k].filter(Boolean).join("."),T=typeof e.content=="string"?e.content:"";t.push({type:"system",id:c,subtype:w,content:$,details:T?[T]:[],sourceMessages:[e],isSubagent:e.isSubagent});return}if(w==="compact_boundary"||w==="turn_aborted"||w==="config_ack"||w==="away_summary"||w==="subagent_activity"){const k=w==="config_ack"?mm(e):null,S=typeof e.content=="string"?e.content:w==="turn_aborted"?"Turn aborted":w==="config_ack"?"Configuration updated":w==="away_summary"?"Recap unavailable":w==="subagent_activity"?"Subagent updated":"Context compacted",$={type:"system",id:c,subtype:w,content:w==="away_summary"?Qu(S):S,sourceMessages:[e],...w==="compact_boundary"?{details:am(e)}:{},...w==="config_ack"?{configChanged:e.configMismatch===!0&&k!==null&&k!==i.lastSignature}:{}};t.push($),w==="config_ack"&&k!==null&&(i.lastSignature=k)}return}e.type==="assistant"&&((y=l==null?void 0:l.onAssistantMessage)==null||y.call(l,{msgId:c,uuid:e.uuid,id:e.id,_isStreaming:e._isStreaming}));const d=((x=e.message)==null?void 0:x.content)??e.content,u=((b=e.message)==null?void 0:b.role)??e.role,f=e.type==="user"||u==="user";if(typeof d=="string"){if(f){if(er(e)){t.push({type:"system",id:c,subtype:"compact_boundary",content:"Context compacted",details:$o(d),sourceMessages:[e],isSubagent:e.isSubagent});return}if(e.isMeta===!0&&Tr(d))return;const w=Rr(d);if(w){if(Wa(w.command))return;t.push({type:"system",id:c,subtype:"local_command",content:wa(w),sourceMessages:[e],isSubagent:e.isSubagent});return}const k=Pr(d);if(k!==null){if(!k||_a(k))return;t.push({type:"system",id:c,subtype:"local_command",content:k,sourceMessages:[e],isSubagent:e.isSubagent});return}if(Ua(e)){const S=Ou(d);t.push({type:"task_notification",id:c,raw:d,sourceMessages:[e],isSubagent:e.isSubagent,...S});return}t.push({type:"user_prompt",id:c,content:d,projectPathLinks:xs(e._projectPathLinks),sourceMessages:[e],isSubagent:e.isSubagent});return}if(d.trim()){const w=e._html;t.push({type:"text",id:c,text:d,sourceBlockIndex:0,sourceMessages:[e],isSubagent:e.isSubagent,augmentHtml:w??((N=(_=a==null?void 0:a.markdown)==null?void 0:_[c])==null?void 0:N.html)})}return}if(!Array.isArray(d))return;if(f&&d.every(w=>w.type==="tool_result")){for(const w of d)w.type==="tool_result"&&w.tool_use_id&&hm(w,e,t,r,l);return}if(f){if(er(e)){t.push({type:"system",id:c,subtype:"compact_boundary",content:"Context compacted",details:$o(d),sourceMessages:[e],isSubagent:e.isSubagent});return}t.push({type:"user_prompt",id:c,content:d,sourceMessages:[e],isSubagent:e.isSubagent});return}const g=e._isStreaming?Lo(d):-1,p=e.isAbortedMidStream===!0&&!e._isStreaming?Lo(d):-1;for(let w=0;w<d.length;w++){const k=d[w];if(!k)continue;const S=`${c}-${w}`;if(k.type==="text"){if((v=k.text)!=null&&v.trim()){const $=k._html;t.push({type:"text",id:S,text:k.text,sourceBlockIndex:w,sourceMessages:[e],isSubagent:e.isSubagent,isStreaming:e._isStreaming&&w===g,augmentHtml:$??((C=(j=a==null?void 0:a.markdown)==null?void 0:j[c])==null?void 0:C.html),...w===p?{abortedMidStream:!0}:{}})}}else if(k.type==="thinking"){const $=k.thinking;dm($)&&t.push({type:"thinking",id:S,thinking:$,sourceBlockIndex:w,signature:void 0,status:e._isStreaming?"streaming":"complete",sourceMessages:[e],isSubagent:e.isSubagent})}else if(k.type==="tool_use"&&k.id&&k.name){const $=n.get(k.id);if($!==void 0){const D=t[$];(D==null?void 0:D.type)==="tool_call"&&(t[$]=fm(D,e,k.input,k._displayActions),D.status==="pending"&&r.set(k.id,$));continue}const T=o.has(k.id),E={type:"tool_call",id:k.id,toolName:k.name,toolInput:k.input,...k._displayActions?{displayActions:k._displayActions}:{},toolResult:void 0,status:T?"incomplete":"pending",sourceMessages:[e],isSubagent:e.isSubagent},R=t.length;n.set(k.id,R),r.set(k.id,R),t.push(E)}}}function mm(e){const t=typeof e.configModel=="string"?e.configModel.trim():"",n=typeof e.configThinking=="string"?e.configThinking.trim():"";return t||n?`${t}::${n}`:typeof e.content=="string"?e.content.trim():null}function Va(e,t){const n=Kn(t);return e.sourceMessages.some(r=>Kn(r)===n)?e:{...e,sourceMessages:[...e.sourceMessages,t]}}function fm(e,t,n,r){return{...Va(e,t),toolInput:n,displayActions:r}}function hm(e,t,n,r,o){var y;const i=e.tool_use_id;if(!i)return;const a=r.get(i);if(a===void 0){o!=null&&o.onUnmatchedToolResult?o.onUnmatchedToolResult({toolUseId:i,message:t}):console.warn(`Tool result for unknown tool_use: ${i}`);return}const l=n[a];if((l==null?void 0:l.type)!=="tool_call")return;let c=t.toolUseResult??t.tool_use_result;!c&&(l.toolName==="Agent"||l.toolName==="Task")&&(c=Vu(e)),c=pm(l,e,c);const d=xs(e._projectPathLinks),u={content:typeof e.content=="string"?e.content:"",isError:e.is_error||!1,structured:c,...d?{projectPathLinks:d}:{},...(y=t.toolResultMedia)!=null&&y.some(x=>x.toolCallId===e.tool_use_id)?{media:t.toolResultMedia.filter(x=>x.toolCallId===e.tool_use_id)}:{}},f=gm(e,l.toolName),h=xm(e,u,l.toolName);let g="complete";h||l.status==="aborted"?g="aborted":f?g=l.status==="incomplete"?"incomplete":"pending":e.is_error&&(g="error");const p={type:"tool_call",id:l.id,toolName:l.toolName,toolInput:l.toolInput,...l.displayActions?{displayActions:l.displayActions}:{},toolResult:u,status:g,sourceMessages:Va(l,t).sourceMessages,isSubagent:l.isSubagent};n[a]=p,!f&&!h&&r.delete(i)}function pm(e,t,n){if(e.toolName!=="Bash"||t.is_error!==!0)return n;const r=typeof n=="string"?n:typeof t.content=="string"?t.content:"",o=Me(r,{bareExitCodeIsEnvelope:!0});return!o.hasEnvelope||o.exitCode===void 0?n:{stdout:o.output,stderr:"",interrupted:!1,isImage:!1,exitCode:o.exitCode}}function gm(e,t){if(t!=="Bash")return!1;const n=typeof e.content=="string"?e.content:"";return n?/(?:^|\n)\s*(?:Process\s+running\s+with\s+session\s+ID|session(?:\s+id)?)\s*:?\s*\d+\b/i.test(n)&&!/(?:^|\n)\s*(?:Exit code:|Process exited with code)\s*-?\d+\b/i.test(n):!1}function xm(e,t,n){if(n!=="Bash")return!1;if(t.structured&&typeof t.structured=="object"&&t.structured.interrupted===!0)return!0;const r=typeof e.content=="string"?e.content:"";return/(?:^|\n)\s*(?:aborted by user|interrupted by user)(?:\s|$)/i.test(r)}function ym(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const jm=[/^<recommended_plugins>[\s\S]*?<\/recommended_plugins>/iu,/^# AGENTS\.md instructions[^\r\n]*(?:\r?\n)+\s*<INSTRUCTIONS>[\s\S]*?<\/INSTRUCTIONS>/iu,/^<environment_context>[\s\S]*?<\/environment_context>/iu];function bm(e){return e.some(t=>typeof t.codexUserTurnProvenance=="string")}function vm(e){return e.some(t=>t._source==="sdk")}function wm(e){let t=e.trim(),n=!1;for(;t;){const r=jm.map(o=>o.exec(t)).find(o=>(o==null?void 0:o.index)===0);if(!(r!=null&&r[0]))return!1;n=!0,t=t.slice(r[0].length).trimStart()}return n}function Ga(e,t=[]){return bm(t)||vm(t)?!1:wm(e)}function _m(e,t=[]){return Ga(e,t)?e.trimStart().startsWith("<environment_context>"):!1}const Nm=5e3;function za(e){return typeof e=="string"?e:e.filter(t=>t.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
9
|
-
`)}function tr(e){const t=za(e.content).trimStart();return Ga(t,e.sourceMessages)}function km(e){return _m(za(e.content),e.sourceMessages)}function Ao(e){const t=e.sourceMessages.map(n=>typeof n.timestamp=="string"?Date.parse(n.timestamp):NaN).find(Number.isFinite);return t===void 0?null:t}function Sm(e,t){if(!km(e)||(t==null?void 0:t.type)!=="user_prompt"||tr(t))return!1;const n=Ao(e),r=Ao(t);if(n===null||r===null)return!1;const o=r-n;return o>=0&&o<=Nm}function Cm(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if((r==null?void 0:r.type)!=="user_prompt"||!tr(r)){t.push(r),n+=1;continue}const o=[];let i=n;for(;i<e.length;){const c=e[i];if((c==null?void 0:c.type)!=="user_prompt"||!tr(c))break;o.push(c),i+=1}const a=o.length===1?o[0]:void 0;if(a!==void 0&&Sm(a,e[i])){n=i;continue}if(o.length>1||n===0){const c=o[0];if(!c){n=i;continue}const d={type:"session_setup",id:`session-setup-${c.id}`,title:"Session setup",prompts:o.map(u=>u.content),sourceMessages:o.flatMap(u=>u.sourceMessages)};t.push(d)}else{const c=o[0];c&&t.push(c)}n=i}return t}function nt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Tm(e){if(nt(e)){if(typeof e.command=="string"&&e.command.trim().length>0)return e.command;if(typeof e.cmd=="string"&&e.cmd.trim().length>0)return e.cmd}}function wt(e){if(typeof e=="number"&&Number.isFinite(e))return String(Math.trunc(e));if(typeof e=="string"&&e.trim().length>0)return e.trim()}function qa(e){if(nt(e))return wt(e.session_id??e.sessionId)}function Fo(e){var i,a;const t=(i=e.toolResult)==null?void 0:i.structured;if(nt(t)){const l=wt(t.session_id??t.sessionId);if(l)return l}const n=((a=e.toolResult)==null?void 0:a.content)??"",o=(typeof n=="string"?n:"").match(/(?:^|\n)\s*(?:Process\s+running\s+with\s+session\s+ID|session[_\s]?id|session)\s*[:=]?\s*(\d+)\b/i);if(o!=null&&o[1])return o[1]}function $r(e){if(nt(e))return wt(e.cell_id??e.cellId)}function Yn(e){var n;const t=((n=e.toolResult)==null?void 0:n.content)??"";return Xn(typeof t=="string"?t:"")}function Rm(e,t){return!nt(e)||typeof e.linked_command=="string"&&e.linked_command.trim()?e:{...e,linked_command:t}}function Pm(e,t){return!nt(e)||typeof e.linked_file_path=="string"&&e.linked_file_path.trim()?e:{...e,linked_file_path:t}}function Em(e,t){return!nt(e)||typeof e.linked_tool_name=="string"&&e.linked_tool_name.trim()?e:{...e,linked_tool_name:t}}function nr(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function Bo(e){const t=e.toLowerCase();return t==="read"||t==="write"||t==="edit"}function Im(e){if(!nt(e)||typeof e.file_path!="string")return;const t=e.file_path.trim();return t.length>0?t:void 0}const Mm=/(?:Command|Process)\s+running\s+(?:in\s+background\s+with\s+ID|with\s+session\s+ID)\s*:?\s*([\w-]+)/i,$m=/(?:^|\n)\s*Process exited with code \d+/i,Lm=/^(completed|failed|killed|stopped|success|error|done)/i;function $e(e,t){return nt(e)?e[t]:void 0}function Am(e){return e==="taskoutput"||e==="task_output"||e==="get_command_or_subagent_output"}function Fm(e){return e==="killshell"||e==="kill_shell"||e==="kill_command_or_subagent"}function Bm(e){return e==="completed"||e==="failed"||e==="cancelled"}function Do(e){var n;const t=(n=e.toolResult)==null?void 0:n.content;return typeof t=="string"?t:""}function Dm(e){var r;const t=new Set,n=(...o)=>{for(const i of o)i&&t.add(i)};for(const o of e){if(o.type==="task_notification"){o.status&&Lm.test(o.status)&&n(o.taskId,o.toolUseId&&`tool:${o.toolUseId}`);continue}if(o.type!=="tool_call")continue;const i=o.toolName.toLowerCase(),a=o.toolInput,l=(r=o.toolResult)==null?void 0:r.structured;if(i==="bashoutput"||i==="bash_output"){const c=wt($e(l,"shellId")??$e(a,"bash_id")),d=$e(l,"status"),u=typeof $e(l,"exitCode")=="number";c&&(u||d==="completed"||d==="failed")&&n(c)}else if(Am(i)){const c=$e(l,"tasks"),d=Array.isArray(c)?c:[$e(l,"task")];for(const u of d)Bm($e(u,"status"))&&n(wt($e(u,"task_id")??$e(a,"task_id")))}else if(Fm(i))n(wt($e(l,"shell_id")??$e(l,"task_id")??$e(a,"shell_id")??$e(a,"task_id")));else if((i==="writestdin"||i==="write_stdin"||i==="wait")&&(typeof $e(l,"exit_code")=="number"||$m.test(Do(o)))){const d=qa(a),u=$r(a);n(d&&`session:${d}`,u&&`cell:${u}`)}}return e.map(o=>{var g;if(o.type!=="tool_call"||o.status!=="complete"||!nr(o.toolName))return o;const i=Do(o),a=[`tool:${o.id}`];let l=$e(o.toolInput,"run_in_background")===!0;const c=wt($e((g=o.toolResult)==null?void 0:g.structured,"backgroundTaskId"));c&&(l=!0,a.push(c,`session:${c}`));const d=i.match(Mm);d!=null&&d[1]&&(l=!0,a.push(d[1]),/session\s+ID/i.test(d[0])&&a.push(`session:${d[1]}`));const u=Xn(i);if(u&&(l=!0,a.push(`cell:${u}`)),!l)return o;const f=a.some(p=>t.has(p)),h=nt(o.toolInput)?o.toolInput:{};return{...o,toolInput:{...h,_backgroundTaskStatus:f?"completed":"running"}}})}function Om(e){const t=new Map,n=new Map;return e.map(r=>{if(r.type!=="tool_call")return r;if(nr(r.toolName)||Bo(r.toolName)){const f=Fo(r),h=Yn(r);if(!f&&!h)return r;const g=nr(r.toolName)?Tm(r.toolInput):void 0,p=Bo(r.toolName)?Im(r.toolInput):void 0;for(const[y,x]of[[f,t],[h,n]]){if(!y)continue;const b=x.get(y)??{};x.set(y,{command:g??b.command,filePath:p??b.filePath,toolName:r.toolName??b.toolName})}return r}const o=r.toolName.toLowerCase();if(o!=="writestdin"&&o!=="write_stdin"&&o!=="wait")return r;const i=qa(r.toolInput),a=$r(r.toolInput),l=(i?t.get(i):void 0)??(a?n.get(a):void 0),c=Yn(r);if(c&&l){const f=n.get(c)??{};n.set(c,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}const d=Fo(r);if(d&&l){const f=t.get(d)??{};t.set(d,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}if(!l)return r;let u=r.toolInput;return l.command&&(u=Rm(u,l.command)),l.filePath&&(u=Pm(u,l.filePath)),l.toolName&&(u=Em(u,l.toolName)),u===r.toolInput?r:{...r,toolInput:u}})}function Oo(e){const t=e.toLowerCase();return t==="writestdin"||t==="write_stdin"||t==="wait"}function Um(e){const t=new Map;for(let i=0;i<e.length;i++){const a=e[i];if((a==null?void 0:a.type)!=="tool_call"||!Oo(a.toolName))continue;const l=$r(a.toolInput);if(!l)continue;const c=t.get(l);c?c.push(i):t.set(l,[i])}if(t.size===0)return e;const n=new Set,r=(i,a)=>{const l=t.get(i);if(!l)return-1;for(const c of l)if(c>a&&!n.has(c))return c;return-1},o=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let a=e[i];if(a!==void 0){if(a.type==="tool_call"&&Oo(a.toolName)){let l=Yn(a),c=i;for(;l;){const d=r(l,c);if(d<0)break;const u=e[d];if((u==null?void 0:u.type)!=="tool_call")break;n.add(d),c=d,a={...a,status:u.status,toolResult:u.toolResult},l=u.toolResult!==void 0?Yn(u):void 0}}o.push(a)}}return o}function Hm(e){return e.filter(t=>{var d,u,f;if(t.type!=="tool_call"||t.status!=="complete")return!0;const n=t.toolName.toLowerCase();if(n!=="writestdin"&&n!=="write_stdin"&&n!=="wait"||(d=t.toolResult)!=null&&d.isError)return!0;const r=nt(t.toolInput)?t.toolInput:{};if((typeof r.chars=="string"?r.chars:"").length>0||[r.linked_command,r.linked_file_path,r.linked_tool_name].some(h=>typeof h=="string"&&h.trim().length>0))return!0;const a=((u=t.toolResult)==null?void 0:u.content)??"",l=Me(a),c=Ct((f=t.toolResult)==null?void 0:f.structured).exitCode??l.exitCode;return l.output.trim().length>0||c!==void 0})}const Uo="@@visualization-schema/1 ",Ka={containsTags:!1,closed:!1},Wm={containsTags:!0,view:"spans"},Xa={collect:!1,order:0};function sr(e){return typeof e=="string"&&e.length>0&&!/[[\]\r\n]/.test(e)}function Ya(e){var t;return(t=/^(?:\[[^[\]\r\n]+\])+/.exec(e))==null?void 0:t[0]}function rr(e){try{return JSON.parse(e)}catch{return}}function Ho(e,t){if(e===void 0)return t;if(!(!st(e)||e.containsTags!==void 0&&typeof e.containsTags!="boolean"||e.closed!==void 0&&typeof e.closed!="boolean")&&!(e.view!==void 0&&e.view!=="spans"&&e.view!=="matching-lines")&&!(e.whitelist!==void 0&&(!Array.isArray(e.whitelist)||!e.whitelist.every(n=>typeof n=="string"&&Ya(n)===n))))return{containsTags:e.containsTags??!1,closed:e.closed??!1,view:e.view,whitelist:e.whitelist}}function Wo(e){if(e===void 0)return Xa;if(!(!st(e)||e.collect!==void 0&&typeof e.collect!="boolean"||e.order!==void 0&&(typeof e.order!="number"||!Number.isFinite(e.order))))return{collect:e.collect??!1,order:e.order??0}}function Vo(e){if(!st(e)||e.type!=="tagged-stages/1"||typeof e.id!="string"||!e.id||/\s/.test(e.id)||!sr(e.key)||e.key==="workflow"||typeof e.title!="string"||!Array.isArray(e.stages))return;const t=Ho(e.toolOutput,Ka),n=Wo(e.presentation);if(!t||!n)return;const r=new Map,o=`[${e.key}]`;r.set(o,{title:e.title,policy:t,presentation:n});function i(a,l,c,d){if(d>32||r.size+a.length>512)return!1;for(const u of a){if(!st(u)||!sr(u.key)||u.title!==void 0&&typeof u.title!="string"||u.children!==void 0&&!Array.isArray(u.children))return!1;const f=`${l}[${u.key}]`,h=Ho(u.toolOutput,c.policy),g=Wo(u.presentation);if(r.has(f)||r.size>=512||!h||!g)return!1;const p={title:`${c.title} › ${u.title??u.key}`,policy:h,presentation:g};if(r.set(f,p),Array.isArray(u.children)&&!i(u.children,f,p,d+1))return!1}return!0}if(i(e.stages,o,r.get(o),1))return{id:e.id,title:e.title,root:o,stages:r}}function Vm(e){const t=rr(e);if(!Array.isArray(t))return;const n=[];for(const r of t){const o=typeof r=="string"?[r]:r;if(!Array.isArray(o)||!o.length||!o.every(sr))return;n.push(o.map(i=>`[${i}]`).join(""))}return{id:"",title:"",root:"",stages:new Map,inline:new Set(n)}}function Lr(e){if(!/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/.test(e))return;const t=e.indexOf("#");return{path:t<0?e:e.slice(0,t),id:t<0?void 0:e.slice(t+1)}}function Go(e,t){const n=Lr(t);if(!n)return;const{id:r}=n,o=rr(e);if(st(o)){const a=Vo(o);return a&&(r===void 0||a.id===r)?a:void 0}const i=[];for(const a of e.matchAll(/^```json\s*\r?\n([\s\S]*?)^```\s*$/gm)){const l=rr(a[1]??"");if(!st(l)||(r===void 0?!l.type:l.id!==r))continue;const c=Vo(l);if(!c)return;i.push(c)}return i.length===1?i[0]:void 0}function Ot(e){return e.schema.stages.get(e.path)??{title:e.path.replace(/\]\[/g," › ").replace(/^\[|\]$/g,""),policy:e.schema.inline?Wm:Ka,presentation:Xa}}function zo(e,t){var o;let n="",r="";for(const i of t.slice(1,-1).split("]["))n+=`[${i}]`,r=((o=e.stages.get(n))==null?void 0:o.title)??`${r?`${r} › `:""}${i}`;return r}function Gm(e,t){var r;if(t.schema.inline)return t.schema.inline.has(e);const n=Ot(t).policy;return n.containsTags&&(!n.closed||t.schema.stages.has(`${t.path}${e}`)||((r=n.whitelist)==null?void 0:r.includes(e))===!0)}function zm(e){var r,o,i,a,l,c;const t=(r=e.toolResult)==null?void 0:r.structured;if(e.toolName==="Exec"){const d=ht(t??((o=e.toolResult)==null?void 0:o.content));if(d){const u=d.parts.filter(f=>f.kind!=="script-status").map(f=>f.text);return u.length?u:[""]}}if(e.toolName==="Read"&&st(t)&&t.type==="text"&&st(t.file)&&typeof t.file.content=="string")return[t.file.content];const n=["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase());if(st(t)&&(typeof t.stdout=="string"||typeof t.stderr=="string"))return[typeof t.stdout=="string"?t.stdout:n?"":((i=e.toolResult)==null?void 0:i.content)??"",typeof t.stderr=="string"?t.stderr:""];if(n){const d=((a=e.toolResult)==null?void 0:a.content)??"",u=Me(d,{bareExitCodeIsEnvelope:(l=e.toolResult)==null?void 0:l.isError});return[u.hasEnvelope?u.output:d]}return[((c=e.toolResult)==null?void 0:c.content)??""]}function or(e,t,n,r,o,i,a,l){var _,N;const c={markers:[]};let d=t;const u=t==null?void 0:t.path;t&&u&&(c.parent={path:u,title:Ot(t).title}),n&&t&&Ot(t).policy.containsTags&&(c.view=Ot(t).policy.view??"spans");const f=[];function h(v,j){const C=f.at(-1);C&&C.end>=v?C.end=j:f.push({start:v,end:j})}let g,p="data";const y=new Map;let x=0,b=0;for(const v of e.split(`
|
|
9
|
+
`)}function tr(e){const t=za(e.content).trimStart();return Ga(t,e.sourceMessages)}function km(e){return _m(za(e.content),e.sourceMessages)}function Ao(e){const t=e.sourceMessages.map(n=>typeof n.timestamp=="string"?Date.parse(n.timestamp):NaN).find(Number.isFinite);return t===void 0?null:t}function Sm(e,t){if(!km(e)||(t==null?void 0:t.type)!=="user_prompt"||tr(t))return!1;const n=Ao(e),r=Ao(t);if(n===null||r===null)return!1;const o=r-n;return o>=0&&o<=Nm}function Cm(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if((r==null?void 0:r.type)!=="user_prompt"||!tr(r)){t.push(r),n+=1;continue}const o=[];let i=n;for(;i<e.length;){const c=e[i];if((c==null?void 0:c.type)!=="user_prompt"||!tr(c))break;o.push(c),i+=1}const a=o.length===1?o[0]:void 0;if(a!==void 0&&Sm(a,e[i])){n=i;continue}if(o.length>1||n===0){const c=o[0];if(!c){n=i;continue}const d={type:"session_setup",id:`session-setup-${c.id}`,title:"Session setup",prompts:o.map(u=>u.content),sourceMessages:o.flatMap(u=>u.sourceMessages)};t.push(d)}else{const c=o[0];c&&t.push(c)}n=i}return t}function nt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Tm(e){if(nt(e)){if(typeof e.command=="string"&&e.command.trim().length>0)return e.command;if(typeof e.cmd=="string"&&e.cmd.trim().length>0)return e.cmd}}function wt(e){if(typeof e=="number"&&Number.isFinite(e))return String(Math.trunc(e));if(typeof e=="string"&&e.trim().length>0)return e.trim()}function qa(e){if(nt(e))return wt(e.session_id??e.sessionId)}function Fo(e){var i,a;const t=(i=e.toolResult)==null?void 0:i.structured;if(nt(t)){const l=wt(t.session_id??t.sessionId);if(l)return l}const n=((a=e.toolResult)==null?void 0:a.content)??"",o=(typeof n=="string"?n:"").match(/(?:^|\n)\s*(?:Process\s+running\s+with\s+session\s+ID|session[_\s]?id|session)\s*[:=]?\s*(\d+)\b/i);if(o!=null&&o[1])return o[1]}function $r(e){if(nt(e))return wt(e.cell_id??e.cellId)}function Yn(e){var n;const t=((n=e.toolResult)==null?void 0:n.content)??"";return Xn(typeof t=="string"?t:"")}function Rm(e,t){return!nt(e)||typeof e.linked_command=="string"&&e.linked_command.trim()?e:{...e,linked_command:t}}function Pm(e,t){return!nt(e)||typeof e.linked_file_path=="string"&&e.linked_file_path.trim()?e:{...e,linked_file_path:t}}function Em(e,t){return!nt(e)||typeof e.linked_tool_name=="string"&&e.linked_tool_name.trim()?e:{...e,linked_tool_name:t}}function nr(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function Bo(e){const t=e.toLowerCase();return t==="read"||t==="write"||t==="edit"}function Im(e){if(!nt(e)||typeof e.file_path!="string")return;const t=e.file_path.trim();return t.length>0?t:void 0}const Mm=/(?:Command|Process)\s+running\s+(?:in\s+background\s+with\s+ID|with\s+session\s+ID)\s*:?\s*([\w-]+)/i,$m=/(?:^|\n)\s*Process exited with code \d+/i,Lm=/^(completed|failed|killed|stopped|success|error|done)/i;function $e(e,t){return nt(e)?e[t]:void 0}function Am(e){return e==="taskoutput"||e==="task_output"||e==="get_command_or_subagent_output"}function Fm(e){return e==="killshell"||e==="kill_shell"||e==="kill_command_or_subagent"}function Bm(e){return e==="completed"||e==="failed"||e==="cancelled"}function Do(e){var n;const t=(n=e.toolResult)==null?void 0:n.content;return typeof t=="string"?t:""}function Dm(e){var r;const t=new Set,n=(...o)=>{for(const i of o)i&&t.add(i)};for(const o of e){if(o.type==="task_notification"){o.status&&Lm.test(o.status)&&n(o.taskId,o.toolUseId&&`tool:${o.toolUseId}`);continue}if(o.type!=="tool_call")continue;const i=o.toolName.toLowerCase(),a=o.toolInput,l=(r=o.toolResult)==null?void 0:r.structured;if(i==="bashoutput"||i==="bash_output"){const c=wt($e(l,"shellId")??$e(a,"bash_id")),d=$e(l,"status"),u=typeof $e(l,"exitCode")=="number";c&&(u||d==="completed"||d==="failed")&&n(c)}else if(Am(i)){const c=$e(l,"tasks"),d=Array.isArray(c)?c:[$e(l,"task")];for(const u of d)Bm($e(u,"status"))&&n(wt($e(u,"task_id")??$e(a,"task_id")))}else if(Fm(i))n(wt($e(l,"shell_id")??$e(l,"task_id")??$e(a,"shell_id")??$e(a,"task_id")));else if((i==="writestdin"||i==="write_stdin"||i==="wait")&&(typeof $e(l,"exit_code")=="number"||$m.test(Do(o)))){const d=qa(a),u=$r(a);n(d&&`session:${d}`,u&&`cell:${u}`)}}return e.map(o=>{var g;if(o.type!=="tool_call"||o.status!=="complete"||!nr(o.toolName))return o;const i=Do(o),a=[`tool:${o.id}`];let l=$e(o.toolInput,"run_in_background")===!0;const c=wt($e((g=o.toolResult)==null?void 0:g.structured,"backgroundTaskId"));c&&(l=!0,a.push(c,`session:${c}`));const d=i.match(Mm);d!=null&&d[1]&&(l=!0,a.push(d[1]),/session\s+ID/i.test(d[0])&&a.push(`session:${d[1]}`));const u=Xn(i);if(u&&(l=!0,a.push(`cell:${u}`)),!l)return o;const f=a.some(p=>t.has(p)),h=nt(o.toolInput)?o.toolInput:{};return{...o,toolInput:{...h,_backgroundTaskStatus:f?"completed":"running"}}})}function Om(e){const t=new Map,n=new Map;return e.map(r=>{if(r.type!=="tool_call")return r;if(nr(r.toolName)||Bo(r.toolName)){const f=Fo(r),h=Yn(r);if(!f&&!h)return r;const g=nr(r.toolName)?Tm(r.toolInput):void 0,p=Bo(r.toolName)?Im(r.toolInput):void 0;for(const[y,x]of[[f,t],[h,n]]){if(!y)continue;const b=x.get(y)??{};x.set(y,{command:g??b.command,filePath:p??b.filePath,toolName:r.toolName??b.toolName})}return r}const o=r.toolName.toLowerCase();if(o!=="writestdin"&&o!=="write_stdin"&&o!=="wait")return r;const i=qa(r.toolInput),a=$r(r.toolInput),l=(i?t.get(i):void 0)??(a?n.get(a):void 0),c=Yn(r);if(c&&l){const f=n.get(c)??{};n.set(c,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}const d=Fo(r);if(d&&l){const f=t.get(d)??{};t.set(d,{command:l.command??f.command,filePath:l.filePath??f.filePath,toolName:l.toolName??f.toolName})}if(!l)return r;let u=r.toolInput;return l.command&&(u=Rm(u,l.command)),l.filePath&&(u=Pm(u,l.filePath)),l.toolName&&(u=Em(u,l.toolName)),u===r.toolInput?r:{...r,toolInput:u}})}function Oo(e){const t=e.toLowerCase();return t==="writestdin"||t==="write_stdin"||t==="wait"}function Um(e){const t=new Map;for(let i=0;i<e.length;i++){const a=e[i];if((a==null?void 0:a.type)!=="tool_call"||!Oo(a.toolName))continue;const l=$r(a.toolInput);if(!l)continue;const c=t.get(l);c?c.push(i):t.set(l,[i])}if(t.size===0)return e;const n=new Set,r=(i,a)=>{const l=t.get(i);if(!l)return-1;for(const c of l)if(c>a&&!n.has(c))return c;return-1},o=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let a=e[i];if(a!==void 0){if(a.type==="tool_call"&&Oo(a.toolName)){let l=Yn(a),c=i;for(;l;){const d=r(l,c);if(d<0)break;const u=e[d];if((u==null?void 0:u.type)!=="tool_call")break;n.add(d),c=d,a={...a,status:u.status,toolResult:u.toolResult},l=u.toolResult!==void 0?Yn(u):void 0}}o.push(a)}}return o}function Hm(e){return e.filter(t=>{var d,u,f;if(t.type!=="tool_call"||t.status!=="complete")return!0;const n=t.toolName.toLowerCase();if(n!=="writestdin"&&n!=="write_stdin"&&n!=="wait"||(d=t.toolResult)!=null&&d.isError)return!0;const r=nt(t.toolInput)?t.toolInput:{};if((typeof r.chars=="string"?r.chars:"").length>0||[r.linked_command,r.linked_file_path,r.linked_tool_name].some(h=>typeof h=="string"&&h.trim().length>0))return!0;const a=((u=t.toolResult)==null?void 0:u.content)??"",l=Me(a),c=Ct((f=t.toolResult)==null?void 0:f.structured).exitCode??l.exitCode;return l.output.trim().length>0||c!==void 0})}const Uo="@@visualization-schema/1 ",Ka={containsTags:!1,closed:!1},Wm={containsTags:!0,view:"spans"},Xa={collect:!1,order:0};function sr(e){return typeof e=="string"&&e.length>0&&!/[[\]\r\n]/.test(e)}function Ya(e){var t;return(t=/^(?:\[[^[\]\r\n]+\])+/.exec(e))==null?void 0:t[0]}function rr(e){try{return JSON.parse(e)}catch{return}}function Ho(e,t){if(e===void 0)return t;if(!(!at(e)||e.containsTags!==void 0&&typeof e.containsTags!="boolean"||e.closed!==void 0&&typeof e.closed!="boolean")&&!(e.view!==void 0&&e.view!=="spans"&&e.view!=="matching-lines")&&!(e.whitelist!==void 0&&(!Array.isArray(e.whitelist)||!e.whitelist.every(n=>typeof n=="string"&&Ya(n)===n))))return{containsTags:e.containsTags??!1,closed:e.closed??!1,view:e.view,whitelist:e.whitelist}}function Wo(e){if(e===void 0)return Xa;if(!(!at(e)||e.collect!==void 0&&typeof e.collect!="boolean"||e.order!==void 0&&(typeof e.order!="number"||!Number.isFinite(e.order))))return{collect:e.collect??!1,order:e.order??0}}function Vo(e){if(!at(e)||e.type!=="tagged-stages/1"||typeof e.id!="string"||!e.id||/\s/.test(e.id)||!sr(e.key)||e.key==="workflow"||typeof e.title!="string"||!Array.isArray(e.stages))return;const t=Ho(e.toolOutput,Ka),n=Wo(e.presentation);if(!t||!n)return;const r=new Map,o=`[${e.key}]`;r.set(o,{title:e.title,policy:t,presentation:n});function i(a,l,c,d){if(d>32||r.size+a.length>512)return!1;for(const u of a){if(!at(u)||!sr(u.key)||u.title!==void 0&&typeof u.title!="string"||u.children!==void 0&&!Array.isArray(u.children))return!1;const f=`${l}[${u.key}]`,h=Ho(u.toolOutput,c.policy),g=Wo(u.presentation);if(r.has(f)||r.size>=512||!h||!g)return!1;const p={title:`${c.title} › ${u.title??u.key}`,policy:h,presentation:g};if(r.set(f,p),Array.isArray(u.children)&&!i(u.children,f,p,d+1))return!1}return!0}if(i(e.stages,o,r.get(o),1))return{id:e.id,title:e.title,root:o,stages:r}}function Vm(e){const t=rr(e);if(!Array.isArray(t))return;const n=[];for(const r of t){const o=typeof r=="string"?[r]:r;if(!Array.isArray(o)||!o.length||!o.every(sr))return;n.push(o.map(i=>`[${i}]`).join(""))}return{id:"",title:"",root:"",stages:new Map,inline:new Set(n)}}function Lr(e){if(!/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/.test(e))return;const t=e.indexOf("#");return{path:t<0?e:e.slice(0,t),id:t<0?void 0:e.slice(t+1)}}function Go(e,t){const n=Lr(t);if(!n)return;const{id:r}=n,o=rr(e);if(at(o)){const a=Vo(o);return a&&(r===void 0||a.id===r)?a:void 0}const i=[];for(const a of e.matchAll(/^```json\s*\r?\n([\s\S]*?)^```\s*$/gm)){const l=rr(a[1]??"");if(!at(l)||(r===void 0?!l.type:l.id!==r))continue;const c=Vo(l);if(!c)return;i.push(c)}return i.length===1?i[0]:void 0}function Ot(e){return e.schema.stages.get(e.path)??{title:e.path.replace(/\]\[/g," › ").replace(/^\[|\]$/g,""),policy:e.schema.inline?Wm:Ka,presentation:Xa}}function zo(e,t){var o;let n="",r="";for(const i of t.slice(1,-1).split("]["))n+=`[${i}]`,r=((o=e.stages.get(n))==null?void 0:o.title)??`${r?`${r} › `:""}${i}`;return r}function Gm(e,t){var r;if(t.schema.inline)return t.schema.inline.has(e);const n=Ot(t).policy;return n.containsTags&&(!n.closed||t.schema.stages.has(`${t.path}${e}`)||((r=n.whitelist)==null?void 0:r.includes(e))===!0)}function zm(e){var r,o,i,a,l,c;const t=(r=e.toolResult)==null?void 0:r.structured;if(e.toolName==="Exec"){const d=ht(t??((o=e.toolResult)==null?void 0:o.content));if(d){const u=d.parts.filter(f=>f.kind!=="script-status").map(f=>f.text);return u.length?u:[""]}}if(e.toolName==="Read"&&at(t)&&t.type==="text"&&at(t.file)&&typeof t.file.content=="string")return[t.file.content];const n=["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase());if(at(t)&&(typeof t.stdout=="string"||typeof t.stderr=="string"))return[typeof t.stdout=="string"?t.stdout:n?"":((i=e.toolResult)==null?void 0:i.content)??"",typeof t.stderr=="string"?t.stderr:""];if(n){const d=((a=e.toolResult)==null?void 0:a.content)??"",u=Me(d,{bareExitCodeIsEnvelope:(l=e.toolResult)==null?void 0:l.isError});return[u.hasEnvelope?u.output:d]}return[((c=e.toolResult)==null?void 0:c.content)??""]}function or(e,t,n,r,o,i,a,l){var _,N;const c={markers:[]};let d=t;const u=t==null?void 0:t.path;t&&u&&(c.parent={path:u,title:Ot(t).title}),n&&t&&Ot(t).policy.containsTags&&(c.view=Ot(t).policy.view??"spans");const f=[];function h(v,j){const C=f.at(-1);C&&C.end>=v?C.end=j:f.push({start:v,end:j})}let g,p="data";const y=new Map;let x=0,b=0;for(const v of e.split(`
|
|
10
10
|
`)){const j=v.replace(/\r$/,""),C=x,w=a==null?void 0:a.get(C);w!==void 0&&w!==p&&(y.set(p,g),p=w,g=y.get(p)),x+=v.length+1;const k=Math.min(x,e.length);if(n&&c.view!=="matching-lines"&&h(C,k),r&&x>e.length)break;for(;l!=null&&l[b]&&l[b].end<=C;)b++;if(l!=null&&l[b]&&l[b].start<=C)continue;const S=(_=/^ {0,3}(`{3,}|~{3,})/.exec(j))==null?void 0:_[1],$=g!==void 0;S&&(g?S[0]===g[0]&&S.length>=g.length&&/^ {0,3}(?:`+|~+)\s*$/.test(j)&&(g=void 0):g=S);const T=(R,D,K,V)=>{n&&h(C,k),c.markers.push({start:C,end:C+D.length,prefix:D,title:K,kind:R,...V?{path:V}:{}})};if(!$&&!S&&j.startsWith(Uo)){const R=j.slice(Uo.length).trim(),D=Lr(R),K=i==null?void 0:i[R],V=D&&n?Go(e,R):void 0,G=R.startsWith("[")?Vm(R):D?V??Go(K??"",R):void 0,W=G&&!G.inline?JSON.stringify([...G.stages]):void 0,ie=G&&o.declarations.get(G.id);if(!G||ie!==void 0&&ie!==W){T("unresolved",j,R),D&&(c.markers.at(-1).schemaRef=R);continue}W&&o.declarations.set(G.id,W),d=G.inline?{schema:G,path:""}:void 0,(!n||!t)&&(o.activated=G,o.cursor=d),n&&G.inline&&(c.view="spans"),T("activation",j,G.title),D&&!V&&(c.markers.at(-1).schemaRef=R);continue}if(!n&&($||S))continue;const E=Ya(j);if(E){if(!n&&!(d!=null&&d.schema.inline)&&E==="[workflow][start]"){const R=/^\[workflow\]\[start\] id=(\S+) schema=(\S+)\s*$/.exec(j);R&&o.activated&&!o.activated.inline&&o.activated.id===R[2]&&!o.cursor&&(o.cursor={schema:o.activated,path:o.activated.root,instance:R[1]},d=o.cursor,T("start",E,o.activated.title))}else if(!n&&!(d!=null&&d.schema.inline)&&E==="[workflow][end]"){const R=/^\[workflow\]\[end\] id=(\S+) status=(completed|blocked|failed)(?:\s|$)/.exec(j);R&&o.cursor&&o.cursor.instance===R[1]&&(T("end",E,`${o.cursor.schema.title} · ${R[2]}`),o.cursor=void 0,d=void 0)}else if(d){if(!(n?Gm(E,d):((N=d.schema.inline)==null?void 0:N.has(E))??d.schema.stages.has(E)))continue;const D=n?`${u??""}${E}`:E,K=n&&t&&t.schema!==d.schema&&u?`${Ot(t).title} › ${zo(d.schema,E)}`:zo(d.schema,D);T("stage",E,K,D),n||(o.cursor={...d,path:E},d=o.cursor)}}}return n&&c.view&&(c.visibleRanges=f),c}function qm(e,t,n){return{initial:e?{...e,schema:{...e.schema,stages:[...e.schema.stages],inline:e.schema.inline?[...e.schema.inline]:void 0}}:void 0,schemaFiles:n,declarations:[...t.declarations]}}function ir(e,t,n){const r=e.outputText??"",o=r&&n?`
|
|
11
11
|
`:"",i=r.length+o.length;e.outputText=r+o+n,e.outputBoundaries??(e.outputBoundaries=[]),e.outputBoundaries.push(...(t.outputBoundaries??[0]).map(a=>a+i)),e.parent??(e.parent=t.parent),e.view??(e.view=t.view),e.markers.push(...t.markers.map(a=>({...a,start:a.start+i,end:a.end+i}))),e.visibleRanges??(e.visibleRanges=[]),e.visibleRanges.push(...(t.visibleRanges??[{start:0,end:n.length}]).map(a=>({start:a.start+i,end:a.end+i})))}function Km(e){const t={markers:[],outputText:""};for(const n of e)ir(t,n,n.outputText??"");return t}function Jn(e,t,n={declarations:new Map(t.declarations)}){const r=t.initial?{...t.initial,schema:{...t.initial.schema,stages:new Map(t.initial.schema.stages),inline:t.initial.schema.inline?new Set(t.initial.schema.inline):void 0}}:void 0,o={markers:[],outputText:""},i={markers:[],outputText:""},a={};for(const l of e){let c="",d;const u=new Map,f=l.map(N=>{c&&!c.endsWith(`
|
|
12
12
|
`)&&(N.kind==="commentary"||d==="commentary")&&(c+=`
|
|
13
13
|
`);const v=c.length;return u.set(v,N.kind==="data"?"data":N.id),c+=N.text,d=N.kind,{fragment:N,start:v,end:c.length}}),h=or(c,r,!0,!1,n,t.schemaFiles,u,f.filter(N=>N.fragment.opaque));ir(i,h,c);const g={markers:[],outputText:"",parent:h.parent,view:h.view,visibleRanges:[]};let p,y,x=0,b=0;const _=h.visibleRanges??[{start:0,end:c.length}];for(const{fragment:N,start:v,end:j}of f){const C=[];for(;h.markers[x]&&h.markers[x].start<j;){const S=h.markers[x++];S.start>=v&&C.push(S)}const w=[];for(;_[b]&&_[b].end<=v;)b++;for(let S=b;_[S]&&_[S].start<j;S++){const $=_[S],T=Math.max(v,$.start),E=Math.min(j,$.end);T<E&&w.push({start:T-v,end:E-v})}const k={markers:C.map(S=>({...S,start:S.start-v,end:S.end-v})),parent:p!=null&&p.path?{path:p.path,title:p.title}:h.parent,view:h.view,visibleRanges:w};if(N.kind==="commentary")a[N.id]=k;else{const S=g.outputText.length;h.view==="spans"&&p&&p!==y&&!C.some($=>$.start===v)&&g.markers.push({...p,prefix:"",start:S,end:S}),g.markers.push(...k.markers.map($=>({...$,start:$.start+S,end:$.end+S}))),g.visibleRanges.push(...k.visibleRanges.map($=>({start:$.start+S,end:$.end+S}))),g.outputText+=N.text}for(const S of C)S.kind==="stage"?p=S:S.kind==="activation"&&(p=void 0);N.kind==="data"&&(y=p)}ir(o,g,g.outputText)}return{data:o,combined:i,commentary:a}}function Ja(e,t){const n=[];for(const r of t.visibleRanges??[{start:0,end:e.length}]){let o=r.start,i;for(const a of t.markers)a.start<r.start||a.start>=r.end||((o<a.start||i)&&n.push({text:e.slice(o,a.start),marker:i}),i=a,o=a.end);(o<r.end||i)&&n.push({text:e.slice(o,r.end),marker:i})}return n}function Xm(e,t,n){const r=new Map,o=new Map,i=new Map;let a=0;const l={declarations:new Map};for(const c of t){if(c.isSubagent)continue;const d=c.sourceMessages[0];if(d){const u=r.get(d)??[];u.push({item:c,result:!1}),r.set(d,u)}if(c.type==="tool_call"&&c.toolResult){const u=[...c.sourceMessages].reverse().find(f=>{var g;const h=((g=f.message)==null?void 0:g.content)??f.content;return Array.isArray(h)&&h.some(p=>p.type==="tool_result"&&p.tool_use_id===c.id)});if(u){const f=r.get(u)??[];f.push({item:c,result:!0}),r.set(u,f)}}}for(const c of e)for(const d of r.get(c)??[]){const{item:u,result:f}=d;if(u.type==="user_prompt"||u.type==="system"&&u.subtype==="compact_boundary")a++,l.cursor=void 0,l.activated=void 0,l.declarations=new Map;else if(u.type==="text")o.set(u,or(u.text,l.cursor,!1,u.isStreaming===!0,l,n));else if(u.type==="tool_call")if(f){const h=i.get(u);if((h==null?void 0:h.turn)===a&&u.toolResult){const g=zm(u),p=u.status!=="pending";if(g.some(N=>mt(N,p))){const N=qm(h.cursor,l,n),v=u.toolName!=="Exec"&&g.some(w=>mt(w,p)==="json"),j=g.map((w,k)=>new Fa("unknown").appendSnapshot(w,p,u.toolName==="Exec"?mt(w,p)==="json":k===0&&v).flatMap(({id:S,record:$})=>Qs(`${k}:${S}`,$))),C=Jn(j,N,l);o.set(u,{...C.combined,toolContext:N});continue}const y=g.join(`
|
|
14
14
|
`),x={markers:[],outputBoundaries:[]},b=[];let _=0;for(const N of g){x.outputBoundaries.push(_);const v=or(N,h.cursor,!0,u.status==="pending",l,n);x.parent=v.parent,v.view&&(x.view=v.view),x.markers.push(...v.markers.map(j=>({...j,start:j.start+_,end:j.end+_})));for(const j of v.visibleRanges??[{start:0,end:N.length}])b.push({start:j.start+_,end:j.end+_});_+N.length<y.length&&b.push({start:_+N.length,end:_+N.length+1}),_+=N.length+1}x.view&&(x.visibleRanges=b),x.view&&y!==u.toolResult.content&&(x.outputText=y),o.set(u,x)}}else{const h=l.cursor;i.set(u,{cursor:h,turn:a}),h!=null&&h.path&&o.set(u,{markers:[],parent:{path:h.path,title:Ot(h).title}})}}return t.map(c=>{const d=o.get(c);return d&&(d.markers.length||d.parent||d.view||d.toolContext)?{...c,workflow:d}:c})}function Ym(e,t,n){const r=Zu(e,t,n),o=t!=null&&t.workflowTags?Xm(e,r,t.workflowSchemaFiles):r,i=Lu(o),a=Yu(i),l=Om(a),c=Um(l),d=Dm(c),u=Hm(d);return Cm(u)}const Jm={onAssistantMessage(e){console.log("[preprocessMessages] Processing assistant message:",e)}};function Ar(e,t){const n=typeof window<"u"&&window.__STREAMING_DEBUG__?Jm:void 0;return Ym(e,t,n)}function Qa(e,t){return Yd(Ar(e,t))}function z_(e,t,n=!1){return n?Qa(e,t):Ar(e,t)}function Fr(e,t,n=!1){return Eu(e,t,n?Qa:Ar)}function q_(e){var n;const t=Fr(e);for(let r=t.length-1;r>=0;r-=1){const o=((n=t[r])==null?void 0:n.sourceMessages)??[];for(let i=o.length-1;i>=0;i-=1){const a=o[i],l=(a==null?void 0:a.uuid)??(a==null?void 0:a.id);if(l)return l}}return""}function Qm(e,t,n=!1){if(t.length===0)return e;const r=t.flatMap((i,a)=>{var c;if(i.placementAfterMessageId==="")return[{itemIndex:-1,object:i,order:a}];let l=Number.NEGATIVE_INFINITY;for(let d=0;d<e.length;d+=1){const u=e[d];u!=null&&u.sourceMessages.some(f=>(f.uuid??f.id)===i.placementAfterMessageId)&&(l=d)}if(l===Number.NEGATIVE_INFINITY&&n&&i.kind==="bang-command"){const d=nn(i.createdAt);if(d!==null)for(let u=0;u<e.length;u+=1){const f=ya(((c=e[u])==null?void 0:c.sourceMessages)??[]);f!==null&&f<=d&&(l=u)}}return l===Number.NEGATIVE_INFINITY?[]:[{itemIndex:l,object:i,order:a}]});if(r.sort((i,a)=>a.itemIndex-i.itemIndex||a.order-i.order),r.length===0)return e;const o=[...e];for(const i of r)o.splice(i.itemIndex+1,0,{type:"transcript_display_object",id:i.object.id,object:i.object,sourceMessages:[]});return o}const Za=m.createContext(null);function K_({children:e}){const t=m.useRef(null),n=m.useRef(null),r=m.useCallback(u=>(typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] Handler registered","color: #2196F3",{hadPreviousHandler:!!t.current}),t.current=u,()=>{t.current===u&&(typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] Handler unregistered","color: #FF5722"),t.current=null)}),[]),o=m.useCallback(u=>{n.current=u},[]),i=m.useCallback(u=>{var f;typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] dispatchAugment called","color: #4CAF50",{hasHandler:!!t.current,augment:{blockIndex:u.blockIndex,type:u.type}}),(f=t.current)==null||f.onAugment(u)},[]),a=m.useCallback(u=>{var f;typeof window<"u"&&window.__STREAMING_DEBUG__&&console.log("%c[CONTEXT] dispatchPending called","color: #FF9800",{hasHandler:!!t.current,htmlLength:u.html.length}),(f=t.current)==null||f.onPending(u)},[]),l=m.useCallback(()=>{var u;(u=t.current)==null||u.onStreamEnd(),n.current=null},[]),c=m.useCallback(()=>{var u,f;return((f=(u=t.current)==null?void 0:u.captureHtml)==null?void 0:f.call(u))??null},[]),d=m.useMemo(()=>({registerStreamingHandler:r,setCurrentMessageId:o,dispatchAugment:i,dispatchPending:a,dispatchStreamEnd:l,captureStreamingHtml:c}),[r,o,i,a,l,c]);return s.jsx(Za.Provider,{value:d,children:e})}function Zm(){return m.useContext(Za)}const Ts=100,ef=750,qo=16,tf=20;function Rn(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Re(e,t,n){if(typeof window<"u"&&window.__STREAMING_DEBUG__){const r={augment:"[AUGMENT]",pending:"[PENDING]",event:"[EVENT]",dom:"[DOM]"}[e],o=n?` ${JSON.stringify(n)}`:"";console.log(`%c${r} ${t}${o}`,nf(e))}}function nf(e){return{augment:"color: #4caf50; font-weight: bold",pending:"color: #ff9800; font-weight: bold",event:"color: #2196f3; font-weight: bold",dom:"color: #9c27b0; font-weight: bold"}[e]||""}function sf(e={}){const t=m.useRef(null),n=m.useRef(null),[r,o]=m.useState(!1),i=m.useRef(e.transformHtml);i.current=e.transformHtml;const a=m.useRef(new Map),l=m.useRef(new Map),c=m.useRef(""),d=m.useRef(-1),u=m.useRef(new Map),f=m.useRef(null),h=m.useRef(null),g=m.useRef(Number.NEGATIVE_INFINITY),p=m.useRef(Ts),y=m.useRef(0),x=m.useCallback(()=>{o(T=>T||!0)},[]),b=m.useCallback(T=>{var G;const E=t.current;if(Re("augment","Received augment",{blockIndex:T.blockIndex,type:T.type,htmlLength:T.html.length,htmlPreview:T.html.substring(0,100)}),!E){Re("augment","ERROR: containerRef.current is null - refs not attached!");return}x();const{blockIndex:R,html:D}=T;l.current.set(R,T);const K=((G=i.current)==null?void 0:G.call(i,D))??D;if(a.current.has(R)){const W=a.current.get(R);W&&(Re("dom","Updating existing block",{blockIndex:R}),W.innerHTML=K);return}const V=document.createElement("div");if(V.className="streaming-block",V.dataset.blockIndex=String(R),V.innerHTML=K,Re("dom","Created new block element",{blockIndex:R,className:V.className}),R>d.current)E.appendChild(V),d.current=R,Re("dom","Appended block to end",{blockIndex:R,maxBlockIndex:d.current});else{let W=!1;const ie=E.children;for(let ae=0;ae<ie.length;ae++){const Pe=ie[ae],se=Number.parseInt(Pe.dataset.blockIndex??"-1",10);if(se>R){E.insertBefore(V,Pe),W=!0,Re("dom","Inserted block before",{blockIndex:R,beforeIndex:se});break}}W||(E.appendChild(V),Re("dom","Appended out-of-order block to end",{blockIndex:R}))}a.current.set(R,V),Re("dom","Block tracking updated",{totalBlocks:a.current.size})},[x]),_=m.useCallback(T=>{var R;const E=n.current;if(Re("pending","Received pending update",{htmlLength:T.html.length,htmlPreview:T.html.substring(0,80)}),!E){Re("pending","ERROR: pendingRef.current is null - refs not attached!");return}x(),c.current=T.html,E.innerHTML=((R=i.current)==null?void 0:R.call(i,T.html))??T.html,Re("pending","Updated pending element innerHTML")},[x]),N=m.useCallback(()=>{h.current!==null&&(clearTimeout(h.current),h.current=null)},[]),v=m.useCallback(()=>{N();const T=u.current,E=f.current;if(T.size===0&&E===null){y.current=0;return}const R=[...T.values()].sort((G,W)=>G.blockIndex-W.blockIndex),D=y.current;T.clear(),f.current=null,y.current=0;const K=Rn();for(const G of R)b(G);E!==null&&_({html:E});const V=Rn()-K;Cs()&&(Cn("streaming-markdown.flush",{durationMs:V}),Cn("streaming-markdown.flushed-event",{count:D,category:R.length>0&&E!==null?"augment-and-pending":R.length>0?"augment":"pending"})),V>qo||D>tf?p.current=Math.min(ef,Math.max(200,Math.ceil(p.current*1.5))):V<qo/2&&D<=6&&(p.current=Math.max(Ts,Math.floor(p.current*.8))),g.current=Rn()},[b,_,N]),j=m.useCallback(()=>{if(h.current!==null)return;const E=Rn()-g.current,R=p.current;if(E>=R){v();return}h.current=setTimeout(v,R-E)},[v]),C=m.useCallback(T=>{Cs()&&Cn("streaming-markdown.event",{category:"augment",chars:T.html.length}),u.current.set(T.blockIndex,T),y.current+=1,j()},[j]),w=m.useCallback(T=>{Cs()&&Cn("streaming-markdown.event",{category:"pending",chars:T.html.length}),f.current=T.html,y.current+=1,j()},[j]),k=m.useCallback(()=>{Re("event","Stream ended"),v();const T=n.current;c.current="",T&&(T.innerHTML="",Re("event","Cleared pending element")),o(!1),Re("event","Set isStreaming to false")},[v]),S=m.useCallback(()=>{Re("event","Reset called"),N(),u.current.clear(),f.current=null,l.current.clear(),c.current="",y.current=0,p.current=Ts;const T=t.current,E=n.current;T&&(T.innerHTML="",Re("event","Cleared container")),E&&(E.innerHTML="",Re("event","Cleared pending element"));const R=a.current.size;a.current.clear(),d.current=-1,o(!1),Re("event","Reset complete",{previousBlockCount:R,maxBlockIndexReset:!0})},[N]),$=m.useCallback(()=>{if(v(),!t.current)return null;const T=document.createElement("div");for(const R of[...l.current.values()].sort((D,K)=>D.blockIndex-K.blockIndex)){const D=document.createElement("div");D.className="streaming-block",D.dataset.blockIndex=String(R.blockIndex),D.innerHTML=R.html,T.append(D)}const E=T.innerHTML;return Re("event","Captured HTML",{length:E.length}),E||null},[v]);return m.useEffect(()=>{var E,R;for(const[D,K]of a.current){const V=l.current.get(D);V&&(K.innerHTML=((E=e.transformHtml)==null?void 0:E.call(e,V.html))??V.html)}const T=n.current;T&&c.current&&(T.innerHTML=((R=e.transformHtml)==null?void 0:R.call(e,c.current))??c.current)},[e.transformHtml]),m.useEffect(()=>()=>{N()},[N]),{containerRef:t,pendingRef:n,isStreaming:r,onAugment:C,onPending:w,onStreamEnd:k,reset:S,captureHtml:$}}function Ko(e,t,n,r){if(r){const o=dd(r,{filePath:n});if(!o)return!1;e.setAttribute("href",o),e.dataset.publicShareFileLink="true"}else{const o=new URLSearchParams({path:n});e.setAttribute("href",`/projects/${encodeURIComponent(t)}/file?${o}`),e.dataset.yaPrivateProjectFileLink="true"}return e.dataset.yaResource="project-file",e.dataset.yaProjectId=t,e.dataset.yaPath=n,e.title=`${n}
|
|
15
|
-
Click to view, or use a browser link gesture to open this file`,!0}function el(e,t,n,r){var u,f;if(!e||!(t!=null&&t.length)||!n||typeof document>"u")return{changed:!1,html:e};const o=new Map(t.map(h=>[h.text,h.filePath])),i=document.createElement("template");i.innerHTML=e;let a=!1;for(const h of i.content.querySelectorAll('a[data-ya-resource="project-file"]')){const g=o.get(((u=h.textContent)==null?void 0:u.trim())??"");g&&Ko(h,n,g,r)&&(a=!0)}const l=document.createTreeWalker(i.content,NodeFilter.SHOW_TEXT),c=[];let d=l.nextNode();for(;d;)d instanceof Text&&!((f=d.parentElement)!=null&&f.closest("a,button,script,style,textarea"))&&c.push(d),d=l.nextNode();for(const h of c){const g=Na(h.data).filter(p=>o.has(p.text));for(let p=g.length-1;p>=0;p-=1){const y=g[p];if(!y)continue;const x=document.createElement("a");if(!Ko(x,n,o.get(y.text),r))continue;h.splitText(y.end);const b=h.splitText(y.start);b.replaceWith(x),x.append(b),a=!0}}return{changed:a,html:a?i.innerHTML:e}}const ar='a.local-media-link[data-media-type="image"], a.local-media-link[data-ya-media-type="image"]';function tl(e,t){return`${e}:inline-image:${t}`}function Br(e){return Array.from(e.querySelectorAll(ar))}function rf(e){var n,r;const t=e.getAttribute("data-ya-path")??((r=(n=e.closest(".local-media-link-group"))==null?void 0:n.querySelector("[data-media-path]"))==null?void 0:r.getAttribute("data-media-path"));if(t)return t;try{return new URL(e.href,window.location.href).searchParams.get("path")}catch{return null}}function of(e,t){var r,o;const n=e.cloneNode(!0);return(r=n.querySelector(".local-media-type"))==null||r.remove(),((o=n.textContent)==null?void 0:o.trim())||tt(t)}function af(e,t){if(!e.augmentHtml||typeof document>"u")return[];const n=document.createElement("template");n.innerHTML=e.augmentHtml;const r=[];for(const[o,i]of Br(n.content).entries()){const a=rf(i);a&&r.push({basename:tt(a),id:tl(e.id,o),label:of(i,a),originalIndex:t+r.length,path:a,sourceIndex:o,sourceItemId:e.id})}return r}function lf(e){const t=[];for(const n of e)n.type==="text"&&t.push(...af(n,t.length));return t}function Xo(e,t,n){var a;if(!(n instanceof Element))return null;const r=n.closest(`${ar}, button.local-media-inline-toggle[data-media-type="image"]`);if(!r||!e.contains(r))return null;const o=r instanceof HTMLAnchorElement?r:(a=r.closest(".local-media-link-group"))==null?void 0:a.querySelector(ar);if(!o)return null;const i=Br(e).indexOf(o);return i>=0?{id:tl(t,i),kind:r instanceof HTMLAnchorElement?"link":"toggle"}:null}function nl(e,t){return Br(e)[t]??null}function cf(e){return!e||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0?null:e}function df(e){return e?Math.max(.2,Math.min(5,e.width/e.height)):4/3}function uf(e,t,n,r,o){const i=Array.from({length:t},()=>({aspectSum:0,images:[]}));for(const c of e){let d=i[0];if(d){for(const u of i.slice(1))u.aspectSum<d.aspectSum&&(d=u);d.images.push(c),d.aspectSum+=c.aspect}}const l=Math.max(1,r-o*(t-1))/t;return i.filter(c=>c.images.length>0).map(c=>{const d=Math.max(1,n-o*(c.images.length-1)),u=Math.max(1,Math.min(l,d/c.aspectSum)),f=c.images.map(h=>{const g=h.naturalHeight===null?u:Math.min(u,h.naturalHeight);return{height:g,id:h.id,naturalHeight:h.naturalHeight,naturalWidth:h.naturalWidth,width:h.aspect*g}});return{height:Math.max(...f.map(h=>h.height)),items:f}})}function mf(e,t,n,r,o=8){if(e.length===0||n<=0||r<=0)return[];const i=e.map(d=>{const u=cf(t.get(d.id));return{...d,aspect:df(u),naturalHeight:(u==null?void 0:u.height)??null,naturalWidth:(u==null?void 0:u.width)??null}}).sort((d,u)=>u.aspect-d.aspect||d.originalIndex-u.originalIndex);let a=[],l=0;const c=Math.min(3,e.length);for(let d=1;d<=c;d+=1){const u=uf(i,d,n,r,o),f=Math.min(...u.flatMap(h=>h.items.map(g=>g.height)));f>l&&(a=u,l=f)}return a}function ff({alt:e,ariaLabel:t,buttonClassName:n,fileName:r,filePath:o,loadBlob:i,onImageLoad:a,onOpen:l,placeholderClassName:c,title:d}){const{t:u}=Z(),{url:f,error:h}=$a(o,!0,i),g=hs({fileName:r,filePath:o,loadBlob:i,onOpen:l});return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:n,"aria-label":t,title:d,onClick:l,onContextMenu:g.handleContextMenu,children:f?s.jsx("img",{src:f,alt:e,draggable:!1,onLoad:a}):s.jsx("span",{className:c,children:u(h?"inlineImageUnavailable":"inlineImageLoading")})}),g.contextMenuElement]})}const hf="_gallery_1ydih_1",pf="_rows_1ydih_9",gf="_row_1ydih_9",xf="_item_1ydih_24",yf="_featured_1ydih_38",jf="_thumbnail_1ydih_43",bf="_placeholder_1ydih_63",vf="_footer_1ydih_74",wf="_caption_1ydih_82",_f="_count_1ydih_112",Nf="_dismiss_1ydih_118",Ze={gallery:hf,rows:pf,row:gf,item:xf,featured:yf,thumbnail:jf,placeholder:bf,footer:vf,caption:wf,count:_f,dismiss:Nf},sl=m.createContext(null);function kf(){return m.useContext(sl)}function Sf(){const e=ps();return m.useMemo(()=>{if(e)return{buildApiPath:t=>ud(e,t),fetchBlob:async(t,n)=>await Td({path:n,relayUrl:e.relayUrl,relayUsername:e.relayUsername})}},[e])}function Cf({candidate:e,featured:t,mediaSource:n,onDimensions:r,onFeature:o,onOpen:i,registerElement:a,style:l}){const{t:c}=Z(),d=Kt().transport,u=m.useCallback(()=>_r(e.path,n,"inline",d),[e.path,n,d]);return s.jsx("div",{ref:f=>a(e.id,f),className:`${Ze.item}${t?` ${Ze.featured}`:""}`,"data-gallery-image-id":e.id,role:"group","aria-label":e.label,style:l,tabIndex:-1,onFocus:()=>o(e.id),onPointerEnter:()=>o(e.id),children:s.jsx(ff,{alt:e.label,ariaLabel:c("turnImageGalleryOpen",{label:e.label}),buttonClassName:Ze.thumbnail,fileName:e.basename,filePath:e.path,loadBlob:u,onImageLoad:f=>{const{naturalHeight:h,naturalWidth:g}=f.currentTarget;r(e.id,{height:h,width:g})},onOpen:()=>i(e),placeholderClassName:Ze.placeholder})})}function X_({children:e,items:t}){var xe;const{t:n}=Z(),{compactMultiImageGalleries:r,inlineMediaExpandedByDefault:o}=wr(),i=m.useMemo(()=>lf(t),[t]),a=i.map(L=>L.id).join("\0"),l=m.useMemo(()=>new Set(i.map(L=>L.id)),[i]),c=m.useMemo(()=>new Map(i.map(L=>[L.id,L])),[i]),d=m.useMemo(()=>new Map(i.map(L=>[L.id,L.label])),[i]),u=r&&i.length>=2,[f,h]=m.useState(!1),[g,p]=m.useState(!1),[y,x]=m.useState(((xe=i[0])==null?void 0:xe.id)??""),[b,_]=m.useState(null),[N,v]=m.useState(()=>new Map),[j,C]=m.useState({height:240,width:720}),w=m.useRef(null),k=m.useRef(null),S=m.useRef(new Map),$=m.useRef(null),T=m.useRef(null),E=m.useRef(null),R=m.useRef(null),D=m.useRef(null),K=m.useRef(null),V=m.useRef(y);V.current=y;const G=Sf(),W=u&&!f&&(o||g);m.useEffect(()=>{var L;l.has(y)||x(((L=i[0])==null?void 0:L.id)??"")},[l,i,y]),m.useLayoutEffect(()=>{const L=k.current;if(!L||!W)return;const B=()=>{const pe=window.innerHeight;C({height:Math.max(120,Math.min(320,pe/3-48)),width:Math.max(1,L.clientWidth)})};B();const Q=new ResizeObserver(B);return Q.observe(L),window.addEventListener("resize",B),()=>{Q.disconnect(),window.removeEventListener("resize",B)}},[W]);const ie=m.useCallback(L=>{x(L);const B=S.current.get(L);if(!B){$.current=L;return}B.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),B.focus({preventScroll:!0}),$.current=null},[]),ae=m.useCallback(L=>{l.has(L)&&($.current=L,x(L),p(!0),h(!1),W&&ie(L))},[l,ie,W]),Pe=m.useCallback(()=>{h(!0),p(!1)},[]),se=m.useCallback(()=>{var B;if(!u)return;const L=l.has(V.current)?V.current:(B=i[0])==null?void 0:B.id;L&&($.current=L,x(L)),p(!0),h(!1)},[l,i,u]);m.useLayoutEffect(()=>{W&&$.current&&ie($.current)},[ie,W]);const Se=m.useCallback(L=>{const B=w.current;if(!B)return null;const Q=Array.from(B.querySelectorAll("[data-turn-image-source-id]")).find(ye=>ye.dataset.turnImageSourceId===L.sourceItemId);return Q?nl(Q,L.sourceIndex):null},[]),F=m.useCallback(L=>{const B=Se(L);B&&(B.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),B.focus({preventScroll:!0}))},[Se]),O=m.useCallback((L,B)=>{D.current=B,K.current=B==="source"?L.id:null,x(L.id),_(L)},[]),Ce=m.useCallback(L=>{const B=c.get(L);B&&O(B,"source")},[c,O]),je=m.useCallback(L=>{if(!b||i.length<2)return;const B=i.findIndex(ye=>ye.id===b.id);if(B<0)return;const Q=(B+L+i.length)%i.length,pe=i[Q];pe&&(x(pe.id),_(pe))},[i,b]),He=m.useCallback(()=>{const L=(b==null?void 0:b.id)??null,B=D.current,Q=K.current;D.current=null,K.current=null,_(null),requestAnimationFrame(()=>{var pe;if(B==="gallery"&&L&&W){ie(L);return}if(Q){const ye=c.get(Q);ye&&((pe=Se(ye))==null||pe.focus({preventScroll:!0}))}})},[c,ie,Se,W,b]),ue=b?i.findIndex(L=>L.id===b.id):-1,Fe=ue>=0&&i.length>1?{count:i.length,current:ue+1,onNext:()=>je(1),onPrevious:()=>je(-1)}:void 0,Oe=m.useMemo(()=>mf(i,N,j.width,j.height),[i,N,j]),We=m.useMemo(()=>new Map(Oe.flatMap(L=>L.items.map(B=>[B.id,{"--turn-gallery-item-height":`${B.height}px`,"--turn-gallery-item-width":`${B.width}px`,...B.naturalHeight===null?{}:{"--turn-gallery-natural-height":`${B.naturalHeight}px`},...B.naturalWidth===null?{}:{"--turn-gallery-natural-width":`${B.naturalWidth}px`}}]))),[Oe]),re=i.find(L=>L.id===y)??i[0],Te=u?i[i.length-1]??null:null,A=m.useMemo(()=>({actionTarget:Te,active:W,activate:ae,available:u,candidateLabels:d,candidateIds:l,collapse:Pe,openImage:Ce,show:se}),[Te,ae,d,l,Pe,u,W,Ce,se]),U=m.useCallback(()=>{T.current=null;const L=k.current;if(!L)return;const B=L.getBoundingClientRect().left+L.clientWidth/2;let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.abs(me.left+me.width/2-B);(!Q||Be<Q.distance)&&(Q={distance:Be,id:pe})}Q&&x(Q.id)},[]),z=m.useCallback((L,B)=>{let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.max(me.left-L,0,L-me.right),ot=Math.max(me.top-B,0,B-me.bottom),Je=Be*Be+ot*ot,gt=me.left+me.width/2,$t=me.top+me.height/2,qe=(gt-L)**2+($t-B)**2;(!Q||Je<Q.edgeDistance||Je===Q.edgeDistance&&qe<Q.centerDistance)&&(Q={centerDistance:qe,edgeDistance:Je,id:pe})}Q&&x(Q.id)},[]),X=m.useCallback((L,B)=>{R.current={clientX:L,clientY:B},E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null;const Q=R.current;Q&&z(Q.clientX,Q.clientY)}))},[z]);return m.useEffect(()=>{if(!W||b)return;const L=B=>{B.pointerType!=="touch"&&X(B.clientX,B.clientY)};return window.addEventListener("pointermove",L,{passive:!0}),()=>window.removeEventListener("pointermove",L)},[W,X,b]),m.useEffect(()=>()=>{T.current!==null&&cancelAnimationFrame(T.current),E.current!==null&&cancelAnimationFrame(E.current)},[]),s.jsx(sl.Provider,{value:A,children:s.jsxs("div",{ref:w,className:`assistant-turn${W?" has-turn-image-gallery":""}`,children:[e,W?s.jsxs("section",{className:Ze.gallery,"aria-label":n("turnImageGalleryLabel"),onKeyDown:L=>{L.key==="Escape"&&(L.preventDefault(),Pe())},children:[s.jsx("div",{ref:k,className:Ze.rows,style:{"--turn-gallery-max-height":`${j.height}px`},onScroll:()=>{T.current===null&&(T.current=requestAnimationFrame(U))},children:Oe.map((L,B)=>s.jsx("div",{className:Ze.row,style:{height:L.height},children:L.items.map(Q=>{const pe=i.find(ye=>ye.id===Q.id);return pe?s.jsx(Cf,{candidate:pe,featured:pe.id===(re==null?void 0:re.id),mediaSource:G,onDimensions:(ye,me)=>{v(Be=>{const ot=Be.get(ye);if((ot==null?void 0:ot.width)===me.width&&ot.height===me.height)return Be;const Je=new Map(Be);return Je.set(ye,me),Je})},onFeature:x,onOpen:ye=>O(ye,"gallery"),registerElement:(ye,me)=>{me?S.current.set(ye,me):S.current.delete(ye)},style:We.get(pe.id)??{}},pe.id):null})},`${a}:row:${B}`))}),s.jsxs("div",{className:Ze.footer,children:[re?s.jsxs("button",{type:"button",className:Ze.caption,onClick:()=>F(re),children:[s.jsx("span",{children:re.label}),re.basename!==re.label?s.jsx("small",{children:re.basename}):null]}):null,s.jsx("span",{className:Ze.count,children:n("turnImageGalleryCount",{count:i.length,current:Math.max(1,i.findIndex(L=>L.id===(re==null?void 0:re.id))+1)})}),s.jsx("button",{type:"button",className:Ze.dismiss,"aria-keyshortcuts":"Escape",onClick:Pe,children:n("turnImageGalleryCollapse")})]})]}):null,b?s.jsx(qt,{path:b.path,mediaType:"image",mediaSource:G,imageNavigation:Fe,onClose:He}):null]})})}const Tf="_root_13m0q_1",Rf="_source_13m0q_11",Pf="_timelineAction_13m0q_46",Ef="_abortedMidStream_13m0q_57",Pn={root:Tf,source:Rf,timelineAction:Pf,abortedMidStream:Ef},If={html:"",changed:!1};function Mf(e){if(typeof document>"u")return e;const t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}const Yo=m.memo(function({artifact:t,className:n,html:r,projectId:o,projectPathLinks:i,publicShare:a}){const l=Nr(),c=m.useMemo(()=>{const d=el(r,i,o,a).html,u=Er(d,t).html;return kr(u,l)},[t,r,o,i,a,l]);return s.jsx("div",{className:n,dangerouslySetInnerHTML:{__html:c}})}),Qn=m.memo(function({text:t,isStreaming:n=!1,abortedMidStream:r=!1,augmentHtml:o,projectPathLinks:i,onQuoteBlock:a,alwaysShowQuoteCircle:l=!1,paragraphQuoteCirclesEnabled:c=!0,renderItemId:d,timelineAction:u}){var A;const{t:f}=Z(),[h,g]=m.useState(!1),[p,y]=m.useState(null),x=m.useRef(null),b=m.useRef(null),_=m.useMemo(()=>n?If:ka(t),[n,t]),N=Sa(),v=N.state==="ready"&&((A=N.result)==null?void 0:A.status)==="ready"?N.result.artifact:void 0,j=ps(),C=Nr(),w=ge(),k=(w==null?void 0:w.projectId)??(j==null?void 0:j.projectId)??void 0,S=m.useCallback(U=>{const z=el(U,i,k,j).html,X=Er(z,v).html;return kr(X,C)},[v,k,i,j,C]),$=m.useMemo(()=>o?Mf(o).trim()!==t.trim():!1,[o,t]),T=sf({transformHtml:S}),E=Zm(),[R,D]=m.useState(!1);m.useEffect(()=>{if(!n||!E){n||(D(!1),T.reset());return}return E.registerStreamingHandler({onAugment:z=>{D(X=>X||!0),T.onAugment(z)},onPending:T.onPending,onStreamEnd:T.onStreamEnd,captureHtml:T.captureHtml})},[n,E,T.captureHtml,T.onAugment,T.onPending,T.onStreamEnd,T.reset]);const K=m.useCallback(async()=>{try{await navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),3e3)}catch(U){console.error("Failed to copy text:",U)}},[t]);m.useEffect(()=>{const U=x.current;if(U)return eu(U,t)},[t]);const{modal:V,localFileModal:G,projectFileModal:W,handleClick:ie,handleContextMenu:ae,closeModal:Pe,closeLocalFileModal:se,closeProjectFileModal:Se,contextMenuElement:F}=ja(),O=kf();md(x,void 0,void 0,{suppressAutomaticImages:(O==null?void 0:O.available)===!0}),Rd(x);const Ce=m.useCallback(U=>{const z=x.current,X=z&&d&&(O!=null&&O.available)?Xo(z,d,U.target):null;if(X&&(O!=null&&O.candidateIds.has(X.id))){U.preventDefault(),U.stopPropagation(),X.kind==="link"?O.openImage(X.id):O.active?O.collapse():O.activate(X.id);return}ie(U)},[ie,d,O]),je=n&&R,He=$||_.changed,{showRendered:ue,toggleLocalMode:Fe}=Pd(He,{participateInGlobalMode:!1,resetDependencies:[n,n?"":t,o??""]}),Oe=n,We=[ue,t,o??""].join("\0"),re=(O==null?void 0:O.actionTarget)??null,Te=(O==null?void 0:O.active)===!0;return m.useEffect(()=>{const U=x.current;if(!U||!ue||je||!d||!(O!=null&&O.available))return;const z=U.querySelectorAll("button.local-media-inline-toggle[data-media-type='image']");for(const X of z){const xe=Xo(U,d,X);if(!xe||!O.candidateIds.has(xe.id))continue;const L=O.candidateLabels.get(xe.id)??"",B=Te?f("turnImageGalleryCollapse"):f("turnImageGalleryExpandAt",{label:L});X.dataset.expanded=String(Te),X.setAttribute("aria-expanded",String(Te)),X.setAttribute("aria-label",B),X.title=B,X.textContent=Te?"−":"+"}},[Te,d,ue,je,f,O]),m.useLayoutEffect(()=>{const U=x.current;let z=null;if(U&&ue&&!je&&d&&(re==null?void 0:re.sourceItemId)===d){const X=nl(U,re.sourceIndex),xe=X==null?void 0:X.closest(".local-media-link-group");xe&&(z=document.createElement("span"),z.className="turn-image-gallery-inline-action-host",xe.append(z))}return y(z),()=>z==null?void 0:z.remove()},[re,d,ue,je]),s.jsxs("div",{ref:b,className:`${Pn.root} text-block text-block-assistant timeline-item${n?" streaming":""}`,"data-turn-image-source-id":d,children:[u?s.jsx("span",{className:Pn.timelineAction,children:u}):null,a?s.jsx(Ed,{alwaysShowQuoteCircle:l,contentRef:x,layoutKey:We,onQuoteBlock:a,paragraphQuoteCirclesEnabled:c&&!je,sourceRef:x,surfaceRef:b}):null,s.jsxs("div",{className:"text-block-actions",children:[He&&s.jsx("button",{type:"button",className:`text-block-toggle ${ue?"is-rendered":""}`,onClick:Fe,title:ue?"Show source":"Show rendered","aria-label":ue?"Show source":"Show rendered","aria-pressed":ue,children:s.jsx(Ca,{})}),s.jsx("button",{type:"button",className:`text-block-copy ${h?"copied":""}`,onClick:K,title:h?"Copied!":"Copy markdown","aria-label":h?"Copied!":"Copy markdown",children:h?s.jsx(Lf,{}):s.jsx($f,{})})]}),s.jsxs("div",{ref:x,className:`text-block-content ${Id}`,onClick:Ce,onContextMenu:ae,children:[Oe&&s.jsxs("div",{style:je&&ue?void 0:{display:"none"},children:[s.jsx("div",{ref:T.containerRef,className:"streaming-blocks"}),s.jsx("span",{ref:T.pendingRef,className:"streaming-pending"})]}),!je&&(ue&&o?s.jsx(Yo,{artifact:v,html:o,projectId:k,projectPathLinks:i,publicShare:j}):ue&&_.changed?s.jsx(Yo,{artifact:v,className:"text-block-local-rendered",html:_.html,projectId:k,projectPathLinks:i,publicShare:j}):s.jsx("pre",{className:`${Pn.source} text-block-source`,children:s.jsx("code",{children:t})})),r&&s.jsxs("span",{className:`${Pn.abortedMidStream} text-block-aborted-mid-stream`,title:f("textBlockAbortedMidStreamTitle"),children:[s.jsx("span",{"aria-hidden":"true",children:"⨯"}),f("textBlockAbortedMidStream")]})]}),p?br.createPortal(s.jsxs("button",{type:"button",className:"turn-image-gallery-inline-action","aria-expanded":Te,"aria-label":f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),title:f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),onClick:U=>{U.preventDefault(),U.stopPropagation(),Te?O==null||O.collapse():O==null||O.show()},children:[s.jsx("span",{"aria-hidden":"true",children:Te?"−":"+"}),f("turnImageGalleryShow")]}),p):null,V&&s.jsx(qt,{path:V.path,mediaType:V.mediaType,onClose:Pe}),G&&s.jsx(ba,{resource:G.resource,initialPresentation:G.initialPresentation,onClose:se}),W&&s.jsx(Ta,{projectId:W.projectId,filePath:W.filePath,lineNumber:W.lineNumber,lineEnd:W.lineEnd,initialPresentation:W.initialPresentation,onClose:Se}),F]})});function $f(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"9",height:"9",rx:"1.5"}),s.jsx("path",{d:"M11 5V3.5A1.5 1.5 0 0 0 9.5 2H3.5A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5"})]})}function Lf(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5L6.5 12L13 4"})})}const Af=/^(?:-{2,}\s*)?\((?:\d+\w* (?:ago|later)(?:, had seen: "[^"\n]*")?|had seen: "[^"\n]*")\)\s*/,Ff=/^\[sent [^\]\n]+\]\s*/,Bf=/\s*\[sent [^\]\n]+\]\s*$/;function Df(e){return e.replace(Af,"").replace(Ff,"").replace(Bf,"")}function Jo(e){var i;const t=e.trim(),n=t.match(/^(\d+(?:\.\d+)?)\s*([KMGT]?B)$/i);if(!n)return t;const r=Number(n[1]);if(!Number.isFinite(r))return t;const o=(n[2]??"").toUpperCase();return o==="B"?`${Math.round(r)} b`:o==="KB"?`${Math.round(r)} kb`:`${Math.round(r*10)/10} ${((i=o[0])==null?void 0:i.toLowerCase())??""}b`}const Dr=lu;function Of(e){const t=[],n=[`
|
|
15
|
+
Click to view, or use a browser link gesture to open this file`,!0}function el(e,t,n,r){var u,f;if(!e||!(t!=null&&t.length)||!n||typeof document>"u")return{changed:!1,html:e};const o=new Map(t.map(h=>[h.text,h.filePath])),i=document.createElement("template");i.innerHTML=e;let a=!1;for(const h of i.content.querySelectorAll('a[data-ya-resource="project-file"]')){const g=o.get(((u=h.textContent)==null?void 0:u.trim())??"");g&&Ko(h,n,g,r)&&(a=!0)}const l=document.createTreeWalker(i.content,NodeFilter.SHOW_TEXT),c=[];let d=l.nextNode();for(;d;)d instanceof Text&&!((f=d.parentElement)!=null&&f.closest("a,button,script,style,textarea"))&&c.push(d),d=l.nextNode();for(const h of c){const g=Na(h.data).filter(p=>o.has(p.text));for(let p=g.length-1;p>=0;p-=1){const y=g[p];if(!y)continue;const x=document.createElement("a");if(!Ko(x,n,o.get(y.text),r))continue;h.splitText(y.end);const b=h.splitText(y.start);b.replaceWith(x),x.append(b),a=!0}}return{changed:a,html:a?i.innerHTML:e}}const ar='a.local-media-link[data-media-type="image"], a.local-media-link[data-ya-media-type="image"]';function tl(e,t){return`${e}:inline-image:${t}`}function Br(e){return Array.from(e.querySelectorAll(ar))}function rf(e){var n,r;const t=e.getAttribute("data-ya-path")??((r=(n=e.closest(".local-media-link-group"))==null?void 0:n.querySelector("[data-media-path]"))==null?void 0:r.getAttribute("data-media-path"));if(t)return t;try{return new URL(e.href,window.location.href).searchParams.get("path")}catch{return null}}function of(e,t){var r,o;const n=e.cloneNode(!0);return(r=n.querySelector(".local-media-type"))==null||r.remove(),((o=n.textContent)==null?void 0:o.trim())||tt(t)}function af(e,t){if(!e.augmentHtml||typeof document>"u")return[];const n=document.createElement("template");n.innerHTML=e.augmentHtml;const r=[];for(const[o,i]of Br(n.content).entries()){const a=rf(i);a&&r.push({basename:tt(a),id:tl(e.id,o),label:of(i,a),originalIndex:t+r.length,path:a,sourceIndex:o,sourceItemId:e.id})}return r}function lf(e){const t=[];for(const n of e)n.type==="text"&&t.push(...af(n,t.length));return t}function Xo(e,t,n){var a;if(!(n instanceof Element))return null;const r=n.closest(`${ar}, button.local-media-inline-toggle[data-media-type="image"]`);if(!r||!e.contains(r))return null;const o=r instanceof HTMLAnchorElement?r:(a=r.closest(".local-media-link-group"))==null?void 0:a.querySelector(ar);if(!o)return null;const i=Br(e).indexOf(o);return i>=0?{id:tl(t,i),kind:r instanceof HTMLAnchorElement?"link":"toggle"}:null}function nl(e,t){return Br(e)[t]??null}function cf(e){return!e||!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0?null:e}function df(e){return e?Math.max(.2,Math.min(5,e.width/e.height)):4/3}function uf(e,t,n,r,o){const i=Array.from({length:t},()=>({aspectSum:0,images:[]}));for(const c of e){let d=i[0];if(d){for(const u of i.slice(1))u.aspectSum<d.aspectSum&&(d=u);d.images.push(c),d.aspectSum+=c.aspect}}const l=Math.max(1,r-o*(t-1))/t;return i.filter(c=>c.images.length>0).map(c=>{const d=Math.max(1,n-o*(c.images.length-1)),u=Math.max(1,Math.min(l,d/c.aspectSum)),f=c.images.map(h=>{const g=h.naturalHeight===null?u:Math.min(u,h.naturalHeight);return{height:g,id:h.id,naturalHeight:h.naturalHeight,naturalWidth:h.naturalWidth,width:h.aspect*g}});return{height:Math.max(...f.map(h=>h.height)),items:f}})}function mf(e,t,n,r,o=8){if(e.length===0||n<=0||r<=0)return[];const i=e.map(d=>{const u=cf(t.get(d.id));return{...d,aspect:df(u),naturalHeight:(u==null?void 0:u.height)??null,naturalWidth:(u==null?void 0:u.width)??null}}).sort((d,u)=>u.aspect-d.aspect||d.originalIndex-u.originalIndex);let a=[],l=0;const c=Math.min(3,e.length);for(let d=1;d<=c;d+=1){const u=uf(i,d,n,r,o),f=Math.min(...u.flatMap(h=>h.items.map(g=>g.height)));f>l&&(a=u,l=f)}return a}function ff({alt:e,ariaLabel:t,buttonClassName:n,fileName:r,filePath:o,loadBlob:i,onImageLoad:a,onOpen:l,placeholderClassName:c,title:d}){const{t:u}=Z(),{url:f,error:h}=$a(o,!0,i),g=hs({fileName:r,filePath:o,loadBlob:i,onOpen:l});return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:n,"aria-label":t,title:d,onClick:l,onContextMenu:g.handleContextMenu,children:f?s.jsx("img",{src:f,alt:e,draggable:!1,onLoad:a}):s.jsx("span",{className:c,children:u(h?"inlineImageUnavailable":"inlineImageLoading")})}),g.contextMenuElement]})}const hf="_gallery_1ydih_1",pf="_rows_1ydih_9",gf="_row_1ydih_9",xf="_item_1ydih_24",yf="_featured_1ydih_38",jf="_thumbnail_1ydih_43",bf="_placeholder_1ydih_63",vf="_footer_1ydih_74",wf="_caption_1ydih_82",_f="_count_1ydih_112",Nf="_dismiss_1ydih_118",Ze={gallery:hf,rows:pf,row:gf,item:xf,featured:yf,thumbnail:jf,placeholder:bf,footer:vf,caption:wf,count:_f,dismiss:Nf},sl=m.createContext(null);function kf(){return m.useContext(sl)}function Sf(){const e=ps();return m.useMemo(()=>{if(e)return{buildApiPath:t=>ud(e,t),fetchBlob:async(t,n)=>await Td({path:n,relayUrl:e.relayUrl,relayUsername:e.relayUsername})}},[e])}function Cf({candidate:e,featured:t,mediaSource:n,onDimensions:r,onFeature:o,onOpen:i,registerElement:a,style:l}){const{t:c}=Z(),d=Kt().transport,u=m.useCallback(()=>_r(e.path,n,"inline",d),[e.path,n,d]);return s.jsx("div",{ref:f=>a(e.id,f),className:`${Ze.item}${t?` ${Ze.featured}`:""}`,"data-gallery-image-id":e.id,role:"group","aria-label":e.label,style:l,tabIndex:-1,onFocus:()=>o(e.id),onPointerEnter:()=>o(e.id),children:s.jsx(ff,{alt:e.label,ariaLabel:c("turnImageGalleryOpen",{label:e.label}),buttonClassName:Ze.thumbnail,fileName:e.basename,filePath:e.path,loadBlob:u,onImageLoad:f=>{const{naturalHeight:h,naturalWidth:g}=f.currentTarget;r(e.id,{height:h,width:g})},onOpen:()=>i(e),placeholderClassName:Ze.placeholder})})}function X_({children:e,items:t}){var xe;const{t:n}=Z(),{compactMultiImageGalleries:r,inlineMediaExpandedByDefault:o}=wr(),i=m.useMemo(()=>lf(t),[t]),a=i.map(L=>L.id).join("\0"),l=m.useMemo(()=>new Set(i.map(L=>L.id)),[i]),c=m.useMemo(()=>new Map(i.map(L=>[L.id,L])),[i]),d=m.useMemo(()=>new Map(i.map(L=>[L.id,L.label])),[i]),u=r&&i.length>=2,[f,h]=m.useState(!1),[g,p]=m.useState(!1),[y,x]=m.useState(((xe=i[0])==null?void 0:xe.id)??""),[b,_]=m.useState(null),[N,v]=m.useState(()=>new Map),[j,C]=m.useState({height:240,width:720}),w=m.useRef(null),k=m.useRef(null),S=m.useRef(new Map),$=m.useRef(null),T=m.useRef(null),E=m.useRef(null),R=m.useRef(null),D=m.useRef(null),K=m.useRef(null),V=m.useRef(y);V.current=y;const G=Sf(),W=u&&!f&&(o||g);m.useEffect(()=>{var L;l.has(y)||x(((L=i[0])==null?void 0:L.id)??"")},[l,i,y]),m.useLayoutEffect(()=>{const L=k.current;if(!L||!W)return;const B=()=>{const pe=window.innerHeight;C({height:Math.max(120,Math.min(320,pe/3-48)),width:Math.max(1,L.clientWidth)})};B();const Q=new ResizeObserver(B);return Q.observe(L),window.addEventListener("resize",B),()=>{Q.disconnect(),window.removeEventListener("resize",B)}},[W]);const ie=m.useCallback(L=>{x(L);const B=S.current.get(L);if(!B){$.current=L;return}B.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}),B.focus({preventScroll:!0}),$.current=null},[]),ae=m.useCallback(L=>{l.has(L)&&($.current=L,x(L),p(!0),h(!1),W&&ie(L))},[l,ie,W]),Pe=m.useCallback(()=>{h(!0),p(!1)},[]),se=m.useCallback(()=>{var B;if(!u)return;const L=l.has(V.current)?V.current:(B=i[0])==null?void 0:B.id;L&&($.current=L,x(L)),p(!0),h(!1)},[l,i,u]);m.useLayoutEffect(()=>{W&&$.current&&ie($.current)},[ie,W]);const Se=m.useCallback(L=>{const B=w.current;if(!B)return null;const Q=Array.from(B.querySelectorAll("[data-turn-image-source-id]")).find(ye=>ye.dataset.turnImageSourceId===L.sourceItemId);return Q?nl(Q,L.sourceIndex):null},[]),F=m.useCallback(L=>{const B=Se(L);B&&(B.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),B.focus({preventScroll:!0}))},[Se]),O=m.useCallback((L,B)=>{D.current=B,K.current=B==="source"?L.id:null,x(L.id),_(L)},[]),Ce=m.useCallback(L=>{const B=c.get(L);B&&O(B,"source")},[c,O]),je=m.useCallback(L=>{if(!b||i.length<2)return;const B=i.findIndex(ye=>ye.id===b.id);if(B<0)return;const Q=(B+L+i.length)%i.length,pe=i[Q];pe&&(x(pe.id),_(pe))},[i,b]),He=m.useCallback(()=>{const L=(b==null?void 0:b.id)??null,B=D.current,Q=K.current;D.current=null,K.current=null,_(null),requestAnimationFrame(()=>{var pe;if(B==="gallery"&&L&&W){ie(L);return}if(Q){const ye=c.get(Q);ye&&((pe=Se(ye))==null||pe.focus({preventScroll:!0}))}})},[c,ie,Se,W,b]),ue=b?i.findIndex(L=>L.id===b.id):-1,Fe=ue>=0&&i.length>1?{count:i.length,current:ue+1,onNext:()=>je(1),onPrevious:()=>je(-1)}:void 0,Oe=m.useMemo(()=>mf(i,N,j.width,j.height),[i,N,j]),We=m.useMemo(()=>new Map(Oe.flatMap(L=>L.items.map(B=>[B.id,{"--turn-gallery-item-height":`${B.height}px`,"--turn-gallery-item-width":`${B.width}px`,...B.naturalHeight===null?{}:{"--turn-gallery-natural-height":`${B.naturalHeight}px`},...B.naturalWidth===null?{}:{"--turn-gallery-natural-width":`${B.naturalWidth}px`}}]))),[Oe]),re=i.find(L=>L.id===y)??i[0],Te=u?i[i.length-1]??null:null,A=m.useMemo(()=>({actionTarget:Te,active:W,activate:ae,available:u,candidateLabels:d,candidateIds:l,collapse:Pe,openImage:Ce,show:se}),[Te,ae,d,l,Pe,u,W,Ce,se]),U=m.useCallback(()=>{T.current=null;const L=k.current;if(!L)return;const B=L.getBoundingClientRect().left+L.clientWidth/2;let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.abs(me.left+me.width/2-B);(!Q||Be<Q.distance)&&(Q={distance:Be,id:pe})}Q&&x(Q.id)},[]),z=m.useCallback((L,B)=>{let Q=null;for(const[pe,ye]of S.current){const me=ye.getBoundingClientRect(),Be=Math.max(me.left-L,0,L-me.right),rt=Math.max(me.top-B,0,B-me.bottom),Je=Be*Be+rt*rt,gt=me.left+me.width/2,$t=me.top+me.height/2,qe=(gt-L)**2+($t-B)**2;(!Q||Je<Q.edgeDistance||Je===Q.edgeDistance&&qe<Q.centerDistance)&&(Q={centerDistance:qe,edgeDistance:Je,id:pe})}Q&&x(Q.id)},[]),X=m.useCallback((L,B)=>{R.current={clientX:L,clientY:B},E.current===null&&(E.current=requestAnimationFrame(()=>{E.current=null;const Q=R.current;Q&&z(Q.clientX,Q.clientY)}))},[z]);return m.useEffect(()=>{if(!W||b)return;const L=B=>{B.pointerType!=="touch"&&X(B.clientX,B.clientY)};return window.addEventListener("pointermove",L,{passive:!0}),()=>window.removeEventListener("pointermove",L)},[W,X,b]),m.useEffect(()=>()=>{T.current!==null&&cancelAnimationFrame(T.current),E.current!==null&&cancelAnimationFrame(E.current)},[]),s.jsx(sl.Provider,{value:A,children:s.jsxs("div",{ref:w,className:`assistant-turn${W?" has-turn-image-gallery":""}`,children:[e,W?s.jsxs("section",{className:Ze.gallery,"aria-label":n("turnImageGalleryLabel"),onKeyDown:L=>{L.key==="Escape"&&(L.preventDefault(),Pe())},children:[s.jsx("div",{ref:k,className:Ze.rows,style:{"--turn-gallery-max-height":`${j.height}px`},onScroll:()=>{T.current===null&&(T.current=requestAnimationFrame(U))},children:Oe.map((L,B)=>s.jsx("div",{className:Ze.row,style:{height:L.height},children:L.items.map(Q=>{const pe=i.find(ye=>ye.id===Q.id);return pe?s.jsx(Cf,{candidate:pe,featured:pe.id===(re==null?void 0:re.id),mediaSource:G,onDimensions:(ye,me)=>{v(Be=>{const rt=Be.get(ye);if((rt==null?void 0:rt.width)===me.width&&rt.height===me.height)return Be;const Je=new Map(Be);return Je.set(ye,me),Je})},onFeature:x,onOpen:ye=>O(ye,"gallery"),registerElement:(ye,me)=>{me?S.current.set(ye,me):S.current.delete(ye)},style:We.get(pe.id)??{}},pe.id):null})},`${a}:row:${B}`))}),s.jsxs("div",{className:Ze.footer,children:[re?s.jsxs("button",{type:"button",className:Ze.caption,onClick:()=>F(re),children:[s.jsx("span",{children:re.label}),re.basename!==re.label?s.jsx("small",{children:re.basename}):null]}):null,s.jsx("span",{className:Ze.count,children:n("turnImageGalleryCount",{count:i.length,current:Math.max(1,i.findIndex(L=>L.id===(re==null?void 0:re.id))+1)})}),s.jsx("button",{type:"button",className:Ze.dismiss,"aria-keyshortcuts":"Escape",onClick:Pe,children:n("turnImageGalleryCollapse")})]})]}):null,b?s.jsx(qt,{path:b.path,mediaType:"image",mediaSource:G,imageNavigation:Fe,onClose:He}):null]})})}const Tf="_root_13m0q_1",Rf="_source_13m0q_11",Pf="_timelineAction_13m0q_46",Ef="_abortedMidStream_13m0q_57",Pn={root:Tf,source:Rf,timelineAction:Pf,abortedMidStream:Ef},If={html:"",changed:!1};function Mf(e){if(typeof document>"u")return e;const t=document.createElement("template");return t.innerHTML=e,t.content.textContent??""}const Yo=m.memo(function({artifact:t,className:n,html:r,projectId:o,projectPathLinks:i,publicShare:a}){const l=Nr(),c=m.useMemo(()=>{const d=el(r,i,o,a).html,u=Er(d,t).html;return kr(u,l)},[t,r,o,i,a,l]);return s.jsx("div",{className:n,dangerouslySetInnerHTML:{__html:c}})}),Qn=m.memo(function({text:t,isStreaming:n=!1,abortedMidStream:r=!1,augmentHtml:o,projectPathLinks:i,onQuoteBlock:a,alwaysShowQuoteCircle:l=!1,paragraphQuoteCirclesEnabled:c=!0,renderItemId:d,timelineAction:u}){var A;const{t:f}=Z(),[h,g]=m.useState(!1),[p,y]=m.useState(null),x=m.useRef(null),b=m.useRef(null),_=m.useMemo(()=>n?If:ka(t),[n,t]),N=Sa(),v=N.state==="ready"&&((A=N.result)==null?void 0:A.status)==="ready"?N.result.artifact:void 0,j=ps(),C=Nr(),w=ge(),k=(w==null?void 0:w.projectId)??(j==null?void 0:j.projectId)??void 0,S=m.useCallback(U=>{const z=el(U,i,k,j).html,X=Er(z,v).html;return kr(X,C)},[v,k,i,j,C]),$=m.useMemo(()=>o?Mf(o).trim()!==t.trim():!1,[o,t]),T=sf({transformHtml:S}),E=Zm(),[R,D]=m.useState(!1);m.useEffect(()=>{if(!n||!E){n||(D(!1),T.reset());return}return E.registerStreamingHandler({onAugment:z=>{D(X=>X||!0),T.onAugment(z)},onPending:T.onPending,onStreamEnd:T.onStreamEnd,captureHtml:T.captureHtml})},[n,E,T.captureHtml,T.onAugment,T.onPending,T.onStreamEnd,T.reset]);const K=m.useCallback(async()=>{try{await navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),3e3)}catch(U){console.error("Failed to copy text:",U)}},[t]);m.useEffect(()=>{const U=x.current;if(U)return eu(U,t)},[t]);const{modal:V,localFileModal:G,projectFileModal:W,handleClick:ie,handleContextMenu:ae,closeModal:Pe,closeLocalFileModal:se,closeProjectFileModal:Se,contextMenuElement:F}=ja(),O=kf();md(x,void 0,void 0,{suppressAutomaticImages:(O==null?void 0:O.available)===!0}),Rd(x);const Ce=m.useCallback(U=>{const z=x.current,X=z&&d&&(O!=null&&O.available)?Xo(z,d,U.target):null;if(X&&(O!=null&&O.candidateIds.has(X.id))){U.preventDefault(),U.stopPropagation(),X.kind==="link"?O.openImage(X.id):O.active?O.collapse():O.activate(X.id);return}ie(U)},[ie,d,O]),je=n&&R,He=$||_.changed,{showRendered:ue,toggleLocalMode:Fe}=Pd(He,{participateInGlobalMode:!1,resetDependencies:[n,n?"":t,o??""]}),Oe=n,We=[ue,t,o??""].join("\0"),re=(O==null?void 0:O.actionTarget)??null,Te=(O==null?void 0:O.active)===!0;return m.useEffect(()=>{const U=x.current;if(!U||!ue||je||!d||!(O!=null&&O.available))return;const z=U.querySelectorAll("button.local-media-inline-toggle[data-media-type='image']");for(const X of z){const xe=Xo(U,d,X);if(!xe||!O.candidateIds.has(xe.id))continue;const L=O.candidateLabels.get(xe.id)??"",B=Te?f("turnImageGalleryCollapse"):f("turnImageGalleryExpandAt",{label:L});X.dataset.expanded=String(Te),X.setAttribute("aria-expanded",String(Te)),X.setAttribute("aria-label",B),X.title=B,X.textContent=Te?"−":"+"}},[Te,d,ue,je,f,O]),m.useLayoutEffect(()=>{const U=x.current;let z=null;if(U&&ue&&!je&&d&&(re==null?void 0:re.sourceItemId)===d){const X=nl(U,re.sourceIndex),xe=X==null?void 0:X.closest(".local-media-link-group");xe&&(z=document.createElement("span"),z.className="turn-image-gallery-inline-action-host",xe.append(z))}return y(z),()=>z==null?void 0:z.remove()},[re,d,ue,je]),s.jsxs("div",{ref:b,className:`${Pn.root} text-block text-block-assistant timeline-item${n?" streaming":""}`,"data-turn-image-source-id":d,children:[u?s.jsx("span",{className:Pn.timelineAction,children:u}):null,a?s.jsx(Ed,{alwaysShowQuoteCircle:l,contentRef:x,layoutKey:We,onQuoteBlock:a,paragraphQuoteCirclesEnabled:c&&!je,sourceRef:x,surfaceRef:b}):null,s.jsxs("div",{className:"text-block-actions",children:[He&&s.jsx("button",{type:"button",className:`text-block-toggle ${ue?"is-rendered":""}`,onClick:Fe,title:ue?"Show source":"Show rendered","aria-label":ue?"Show source":"Show rendered","aria-pressed":ue,children:s.jsx(Ca,{})}),s.jsx("button",{type:"button",className:`text-block-copy ${h?"copied":""}`,onClick:K,title:h?"Copied!":"Copy markdown","aria-label":h?"Copied!":"Copy markdown",children:h?s.jsx(Lf,{}):s.jsx($f,{})})]}),s.jsxs("div",{ref:x,className:`text-block-content ${Id}`,onClick:Ce,onContextMenu:ae,children:[Oe&&s.jsxs("div",{style:je&&ue?void 0:{display:"none"},children:[s.jsx("div",{ref:T.containerRef,className:"streaming-blocks"}),s.jsx("span",{ref:T.pendingRef,className:"streaming-pending"})]}),!je&&(ue&&o?s.jsx(Yo,{artifact:v,html:o,projectId:k,projectPathLinks:i,publicShare:j}):ue&&_.changed?s.jsx(Yo,{artifact:v,className:"text-block-local-rendered",html:_.html,projectId:k,projectPathLinks:i,publicShare:j}):s.jsx("pre",{className:`${Pn.source} text-block-source`,children:s.jsx("code",{children:t})})),r&&s.jsxs("span",{className:`${Pn.abortedMidStream} text-block-aborted-mid-stream`,title:f("textBlockAbortedMidStreamTitle"),children:[s.jsx("span",{"aria-hidden":"true",children:"⨯"}),f("textBlockAbortedMidStream")]})]}),p?br.createPortal(s.jsxs("button",{type:"button",className:"turn-image-gallery-inline-action","aria-expanded":Te,"aria-label":f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),title:f(Te?"turnImageGalleryCollapse":"turnImageGalleryExpand"),onClick:U=>{U.preventDefault(),U.stopPropagation(),Te?O==null||O.collapse():O==null||O.show()},children:[s.jsx("span",{"aria-hidden":"true",children:Te?"−":"+"}),f("turnImageGalleryShow")]}),p):null,V&&s.jsx(qt,{path:V.path,mediaType:V.mediaType,onClose:Pe}),G&&s.jsx(ba,{resource:G.resource,initialPresentation:G.initialPresentation,onClose:se}),W&&s.jsx(Ta,{projectId:W.projectId,filePath:W.filePath,lineNumber:W.lineNumber,lineEnd:W.lineEnd,initialPresentation:W.initialPresentation,onClose:Se}),F]})});function $f(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"9",height:"9",rx:"1.5"}),s.jsx("path",{d:"M11 5V3.5A1.5 1.5 0 0 0 9.5 2H3.5A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5"})]})}function Lf(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5L6.5 12L13 4"})})}const Af=/^(?:-{2,}\s*)?\((?:\d+\w* (?:ago|later)(?:, had seen: "[^"\n]*")?|had seen: "[^"\n]*")\)\s*/,Ff=/^\[sent [^\]\n]+\]\s*/,Bf=/\s*\[sent [^\]\n]+\]\s*$/;function Df(e){return e.replace(Af,"").replace(Ff,"").replace(Bf,"")}function Jo(e){var i;const t=e.trim(),n=t.match(/^(\d+(?:\.\d+)?)\s*([KMGT]?B)$/i);if(!n)return t;const r=Number(n[1]);if(!Number.isFinite(r))return t;const o=(n[2]??"").toUpperCase();return o==="B"?`${Math.round(r)} b`:o==="KB"?`${Math.round(r)} kb`:`${Math.round(r*10)/10} ${((i=o[0])==null?void 0:i.toLowerCase())??""}b`}const Dr=lu;function Of(e){const t=[],n=[`
|
|
16
16
|
|
|
17
17
|
User uploaded files in .attachments:
|
|
18
18
|
`,`
|
|
@@ -29,8 +29,8 @@ Change: ${t.change}`:t.correctedText:e}function En({files:e}){return e.length===
|
|
|
29
29
|
`).replace(/\n{3,}/g,`
|
|
30
30
|
|
|
31
31
|
`).trim()}function sh(e){var d;const t=/^data:([^;,]+)?(;base64)?,(.*)$/i.exec(e);if(!t)return{};const r=((d=t[1])==null?void 0:d.trim())||void 0,o=!!t[2],i=(t[3]??"").trim();if(!i)return{mimeType:r};if(!o){const u=decodeURIComponent(i);return{mimeType:r,bytes:u.length}}const a=i.replace(/\s+/g,""),l=a.endsWith("==")?2:a.endsWith("=")?1:0,c=Math.max(0,Math.floor(a.length*3/4)-l);return{mimeType:r,bytes:c}}function rh(e){return!e||e<0?"unknown size":e<1024?`${e} b`:e<1024*1024?`${Math.round(e/1024)} kb`:`${Math.round(e/(1024*1024)*10)/10} mb`}function ri(e){const t=e.toLowerCase();if(t.endsWith(".png"))return"image/png";if(t.endsWith(".jpg")||t.endsWith(".jpeg"))return"image/jpeg";if(t.endsWith(".gif"))return"image/gif";if(t.endsWith(".webp"))return"image/webp";if(t.endsWith(".bmp"))return"image/bmp";if(t.endsWith(".svg"))return"image/svg+xml"}function oh(e){const t=e.toLowerCase();if(t==="image/jpeg")return"jpg";if(t==="image/svg+xml")return"svg";const n=t.indexOf("/");return n===-1?"png":t.slice(n+1)||"png"}function ih(e){if(e.startsWith("data:"))return null;try{const r=(new URL(e,"https://codex.local").pathname||"").split("/").filter(Boolean).pop();return r?decodeURIComponent(r):null}catch{return null}}function ah(e){const t=[];let n=0;for(const r of e){if(!th(r))continue;n+=1;const o=typeof r.file_path=="string"?r.file_path.trim():"",i=typeof r.image_url=="string"?r.image_url.trim():"",a=i?sh(i):{},l=typeof r.mime_type=="string"&&r.mime_type.trim()||a.mimeType||(o?ri(o):void 0)||(i?ri(i):void 0)||"image/*",c=o&&Dr(o)||i&&ih(i)||`pasted-image-${n}.${oh(l)}`,d=o||(i&&!i.startsWith("data:")?i:"")||`codex-inline://image/${n}`;t.push({originalName:c,size:rh(a.bytes),mimeType:l,path:d,previewUrl:i||void 0})}return t}function lh(e,t){const n=new Set,r=[];for(const o of[...e,...t])n.has(o.path)||(n.add(o.path),r.push(o));return r}function In({files:e}){return e.length===0?null:s.jsx("div",{className:"user-prompt-metadata",children:e.map(t=>s.jsx(Zd,{originalName:t.originalName,path:t.path,mimeType:t.mimeType,sizeLabel:t.size,imageWidth:t.width,imageHeight:t.height,previewUrl:t.previewUrl},t.path))})}function oi({projectPathLinks:e,text:t}){const[n,r]=m.useState(!1),o=t.split(`
|
|
32
|
-
`),i=o.length>cr,a=t.length>Rs,l=i||a,c=
|
|
33
|
-
`):t;d.length>Rs&&(d=d.slice(0,Rs));const u=
|
|
32
|
+
`),i=o.length>cr,a=t.length>Rs,l=i||a,c=st(t);let d=i?o.slice(0,cr).join(`
|
|
33
|
+
`):t;d.length>Rs&&(d=d.slice(0,Rs));const u=st(d);return!l||n?s.jsxs("div",{className:"text-block",children:[s.jsx("div",{ref:c,children:s.jsx(lr,{text:t,projectPathLinks:e})}),n&&l&&s.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!1),children:"Show less"})]}):s.jsxs("div",{className:"text-block collapsible-text",children:[s.jsxs("div",{ref:u,className:"truncated-content",children:[s.jsx(lr,{text:d,projectPathLinks:e,suppressTrailingUrl:!0}),s.jsx("div",{className:"fade-overlay"})]}),s.jsx("button",{type:"button",className:"show-more-btn",onClick:()=>r(!0),children:"Show more"})]})}function ii({actionsRef:e,messageId:t,onCorrect:n,onCancelUnconfirmed:r,onTrimBefore:o,onForkBefore:i,onForkAfter:a,onForkAfterSummary:l,forkAfterDisabled:c,forkUnavailableMessage:d,copyText:u,extraActions:f}){const{t:h}=Z();return!n&&!r&&!o&&!a&&!d&&!u&&!f?null:s.jsxs("div",{ref:e,className:"user-prompt-actions",children:[u&&s.jsx(Ma,{text:u,label:h("userPromptCopyAction"),className:"user-prompt-action user-prompt-action-copy"}),n&&s.jsxs("button",{type:"button",className:"user-prompt-action user-prompt-action-edit",onClick:n,"aria-label":h("userPromptEditAction"),title:h("userPromptEditAction"),children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),s.jsx("span",{className:"user-prompt-correct-label",children:"Edit"})]}),r&&s.jsx("button",{type:"button",className:"user-prompt-action user-prompt-action-cancel-sent",onClick:r,"aria-label":h("userPromptCancelUnconfirmedAction"),title:h("userPromptCancelUnconfirmedAction"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M18 6 6 18"}),s.jsx("path",{d:"m6 6 12 12"})]})}),(a&&l||d)&&s.jsx(Kf,{messageId:t,onForkBefore:i,onForkAfter:a,onForkAfterSummary:l,afterDisabled:c,unavailableMessage:d}),o&&s.jsx("button",{type:"button",className:"user-prompt-action user-prompt-action-show-starting",onClick:o,"aria-label":h("userPromptShowStartingHere"),title:h("userPromptShowStartingHere"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("path",{d:"M4 7h16"}),s.jsx("path",{d:"M4 12h10"}),s.jsx("path",{d:"M4 17h6"}),s.jsx("path",{d:"m15 16 3 3 3-3"}),s.jsx("path",{d:"M18 5v14"})]})}),f]})}function ai({deliveryState:e}){const{t}=Z(),[n,r]=m.useState(!1);return e!=="sent"?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"user-prompt-delivery-marker",title:t("userPromptDeliverySent"),"aria-label":t("userPromptDeliverySent"),"aria-expanded":n,onClick:()=>r(o=>!o),onBlur:()=>r(!1),onKeyDown:o=>{o.key==="Escape"&&r(!1)},children:t("userPromptDeliverySentLabel")}),n&&s.jsx("span",{className:"user-prompt-delivery-popover",role:"status",children:t("userPromptDeliverySentDetail")})]})}function li({projectPathLinks:e,text:t}){const n=il(t);return n?s.jsxs("div",{className:"user-prompt-correction",children:[s.jsx("div",{className:"user-prompt-correction-label",children:"Correction"}),s.jsx(oi,{text:n.correctedText,projectPathLinks:e}),n.change&&s.jsxs("div",{className:"user-prompt-correction-change",children:["Change:"," ",s.jsx(lr,{text:n.change,projectPathLinks:e})]})]}):s.jsx(oi,{text:t,projectPathLinks:e})}const al=m.memo(function({content:t,messageId:n,projectPathLinks:r,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,extraActions:h,deliveryState:g}){const p=g==="sent"?" user-prompt-unconfirmed":"",y=+!!t+ +!!o+ +!!i+ +!!(c&&d||f)+ +!!a+m.Children.count(h),x=typeof t=="string"?t:t.map(S=>S.type==="text"&&typeof S.text=="string"?S.text:S.type).join("\0"),b=Jf(y,x);if(typeof t=="string"){const{text:S,openedFiles:$,uploadedFiles:T}=Qo(t);return S?s.jsxs("div",{ref:b.containerRef,className:"user-prompt-container",style:b.style,children:[s.jsx("div",{ref:b.bubbleRef,className:`message message-user-prompt ${o?"user-prompt-correctable":""}${p}`,children:s.jsxs("div",{className:"message-content",children:[s.jsx(li,{text:S,projectPathLinks:r}),s.jsx(ai,{deliveryState:g}),s.jsx(In,{files:T})]})}),s.jsx(ii,{actionsRef:b.actionsRef,messageId:n,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,copyText:si(S),extraActions:h}),s.jsx(En,{files:$})]}):$.length>0||T.length>0?s.jsxs(s.Fragment,{children:[s.jsx(In,{files:T}),s.jsx(En,{files:$})]}):null}const _=t.filter(S=>S.type==="text"&&S.text).map(S=>S.text).join(`
|
|
34
34
|
`),N=ah(t),v=N.length>0?nh(_):_,{text:j,openedFiles:C,uploadedFiles:w}=Qo(v),k=lh(w,N);return j?s.jsxs("div",{ref:b.containerRef,className:"user-prompt-container",style:b.style,children:[s.jsx("div",{ref:b.bubbleRef,className:`message message-user-prompt ${o?"user-prompt-correctable":""}${p}`,children:s.jsxs("div",{className:"message-content",children:[s.jsx(li,{text:j,projectPathLinks:r}),s.jsx(ai,{deliveryState:g}),s.jsx(In,{files:k})]})}),s.jsx(ii,{actionsRef:b.actionsRef,messageId:n,onCorrect:o,onCancelUnconfirmed:i,onTrimBefore:a,onForkBefore:l,onForkAfter:c,onForkAfterSummary:d,forkAfterDisabled:u,forkUnavailableMessage:f,copyText:si(j),extraActions:h}),s.jsx(En,{files:C})]}):C.length>0||k.length>0?s.jsxs(s.Fragment,{children:[s.jsx(In,{files:k}),s.jsx(En,{files:C})]}):s.jsx("div",{className:"message message-user-prompt",children:s.jsx("div",{className:"message-content",children:s.jsx("div",{className:"text-block",children:"[Complex content]"})})})});function ch({open:e,onOpenChange:t,delayMultiplier:n=1}){const r=pa(),o=m.useRef(Symbol("rich-tooltip-intent")),i=m.useRef(null),a=m.useRef(null),l=m.useRef(null),c=m.useRef(null),d=m.useRef(!1),u=m.useRef(e);u.current=e;const f=m.useCallback(()=>{Ic(o.current)},[]),h=m.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),g=m.useCallback(()=>{const w=a.current;w&&(a.current=null,Mc(w))},[]),p=m.useCallback(()=>{f(),h(),g(),t(!1)},[h,f,t,g]),y=m.useCallback(()=>{if(vo()){p();return}const w=l.current;!d.current&&(!w||!$c(w))||(!a.current&&r==="themed"&&(a.current=Lc(p)),t(!0))},[p,t,r]),x=m.useCallback(()=>{if(f(),vo()||u.current)return;const w=r==="native"?0:Ac(n);w===0?wo(o.current,0,y):wo(o.current,w,y)},[f,n,y,r]),b=m.useCallback(()=>{if(i.current)return;const w=r==="native"?0:Fc()*Bc;if(w===0){p();return}i.current=setTimeout(()=>{i.current=null,p()},w)},[p,r]),_=m.useCallback(w=>{w.pointerType!=="touch"&&(l.current=w.currentTarget,c.current={x:w.clientX,y:w.clientY},h(),x())},[h,x]),N=m.useCallback(w=>{w.pointerType!=="touch"&&(l.current=w.currentTarget,c.current={x:w.clientX,y:w.clientY},h(),u.current||x())},[h,x]),v=m.useCallback(w=>{if(w.relatedTarget instanceof Node&&w.currentTarget.contains(w.relatedTarget))return;const k=c.current;u.current&&!_o(k,w.clientX,w.clientY)||(u.current?b():p())},[p,b]),j=m.useCallback(w=>{w.currentTarget.matches(":focus-visible")&&(d.current=!0,h(),x())},[h,x]),C=m.useCallback(w=>{w.relatedTarget instanceof Node&&w.currentTarget.contains(w.relatedTarget)||(d.current=!1,p())},[p]);return m.useEffect(()=>{e||g()},[e,g]),m.useEffect(()=>Dc(p),[p]),m.useEffect(()=>{if(!e||r!=="themed")return;const w=k=>{if(d.current)return;const S=l.current;S&&k.target instanceof Node&&S.contains(k.target)||_o(c.current,k.clientX,k.clientY)&&b()};return document.addEventListener("pointermove",w),()=>document.removeEventListener("pointermove",w)},[e,b,r]),m.useEffect(()=>()=>{f(),h(),g()},[h,f,g]),{onPointerEnter:_,onPointerMove:N,onPointerLeave:v,onFocus:j,onBlur:C,cancelPending:f,close:p}}const ci={shell_command:"Bash",exec_command:"Bash",write_stdin:"WriteStdin",wait:"WriteStdin",update_plan:"UpdatePlan",apply_patch:"Edit",web_search_call:"WebSearch",search_query:"WebSearch",Agent:"Task",view_image:"ViewImage",imageView:"ViewImage"};function ll(e){return ci[e]??ci[e.toLowerCase()]??e}const dh={read:"read",grep:"search",search:"search",grepsearch:"search",grep_search:"search",glob:"list",ls:"list",list:"list",listdir:"list",list_dir:"list","list-dir":"list"};function J_(e){return dh[ll(e).toLowerCase()]??null}const uh="_partial_1py7t_1",mh={partial:uh},fn=m.memo(function({text:t,className:n,as:r="code"}){const o=Nr();if(!gu(t)){const a=s.jsx(St,{text:t});return r==="span"?s.jsx("span",{className:n,children:a}):s.jsx("code",{className:n,children:a})}const i=kr($d("ansi-render",()=>({chars:t.length,lines:t.length===0?0:t.split(`
|
|
35
35
|
`).length}),()=>xu(t)),o);return r==="span"?s.jsx("span",{className:n,dangerouslySetInnerHTML:{__html:i}}):s.jsx("code",{className:n,dangerouslySetInnerHTML:{__html:i}})}),fh="_json_14506_1",hh="_metadata_14506_6",di={json:fh,metadata:hh};function pt({text:e,compact:t=!1}){return m.useMemo(()=>Ld(e),[e]).map((r,o)=>s.jsx("span",{"data-tool-output-kind":r.kind,className:r.kind==="metadata"?di.metadata:r.kind==="json"?di.json:void 0,children:s.jsx(fn,{as:"span",text:t?r.source:r.text})},o))}const ph="_row_1bm9g_1",gh="_header_1bm9g_11",xh="_details_1bm9g_17",yh="_output_1bm9g_22",jh="_status_1bm9g_30",bt={row:ph,header:gh,details:xh,output:yh,status:jh};function ui(e){return typeof e=="string"?e:JSON.stringify(e,null,2)??""}function Ur({toolName:e,toolInput:t,toolResult:n,status:r,error:o}){const{t:i}=Z();return s.jsxs("div",{className:bt.row,"data-tool-display":"raw",children:[s.jsxs("div",{className:bt.header,children:[s.jsx("strong",{children:e}),s.jsx("span",{className:bt.status,"data-status":r,children:i(`toolDisplay.status.${r}`)})]}),o&&s.jsx("pre",{className:bt.output,children:o.message}),s.jsxs("details",{className:bt.details,children:[s.jsx("summary",{children:i("toolDisplay.rawNotice")}),n!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:i("toolDisplay.output")}),s.jsx("pre",{className:bt.output,children:ui(n)})]}),s.jsx("strong",{children:i("toolDisplay.input")}),s.jsx("pre",{className:bt.output,children:ui(t)})]})]})}class cl extends m.Component{constructor(){super(...arguments);be(this,"state",{error:null,record:this.props})}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,r){const o=r.record;return o.id!==n.id||o.toolName!==n.toolName||o.toolInput!==n.toolInput||o.toolResult!==n.toolResult||o.status!==n.status?{error:null,record:n}:null}componentDidCatch(){}render(){return this.state.error?s.jsx(Ur,{...this.props,error:this.state.error}):this.props.children}}function Mn(e,t,n,r=n?"error":t===void 0?"pending":"complete"){return{input:e,result:t,isError:n,status:r}}function dl(e){return e.isError??e.status==="error"}function Hr(e){var t;return dl({status:e.status,isError:(t=e.toolResult)==null?void 0:t.isError})}function bh(e,t){var d;const n=dl(t),r=e.input.safeParse(t.input),o=n?e.failure:t.input===void 0?e.standaloneResultSchema??e.result:e.result,i=t.result===void 0||o==null?void 0:o.safeParse(t.result),a=!n&&i&&!i.success?(d=e.partialResult)==null?void 0:d.safeParse(t.result):void 0,l=r.success||t.input===void 0&&e.standaloneResult&&((i==null?void 0:i.success)||(a==null?void 0:a.success)),c=l?n&&!e.failure||i&&!i.success&&!(a!=null&&a.success)?"result":void 0:"input";return{kind:c?"raw":a!=null&&a.success?"partial":"rich",reason:c,status:t.status,isError:n,input:r,result:i,partialResult:a,inputEligible:l}}const vh=Symbol("checked tool definition");function de(e,t){const{renderFailure:n,getFailureSummary:r}=t,o=["renderToolUse","renderToolResult","getUseSummary","getResultSummary","renderCollapsedPreview","renderInteractiveSummary","renderInline","displayNameForCall"].filter(i=>typeof Reflect.get(t,i)=="function");return Object.freeze({[vh]:!0,tool:t.tool,displayName:t.displayName,pendingDisplayName:t.pendingDisplayName,variants:e.variants,standaloneResult:e.standaloneResult,operations:o,prepare(i){const{isError:a,input:l,result:c,partialResult:d,inputEligible:u,reason:f,kind:h}=bh(e,i),g=n&&a&&e.failure&&(c!=null&&c.success)?{data:c.data,render:n}:void 0,p=g||!(c!=null&&c.success)?void 0:{data:c.data},y=(v=i.status)=>(v==="pending"?t.pendingDisplayName:void 0)??t.displayName??t.tool,x=v=>s.jsx(Ur,{id:v.toolUseId??t.tool,toolName:i.toolName??t.tool,toolInput:i.input,toolResult:i.result,status:i.status}),b=()=>d!=null&&d.success?s.jsx("pre",{className:mh.partial,"data-tool-display":"partial",children:s.jsx(pt,{text:d.data})}):null,_=v=>{try{return v()}catch{return}},N=(v,j)=>{if(h==="raw")return x(v);try{const{toolUseResult:C,getToolUse:w,...k}=v,S=j(k);return S==null||S===!1?S:s.jsx(cl,{id:v.toolUseId??t.tool,toolName:i.toolName??t.tool,toolInput:i.input,toolResult:i.result,status:i.status,children:S})}catch{return x(v)}};return{kind:h,reason:f,status:i.status,isError:a,getDisplayName:(v=i.status)=>(l.success?_(()=>{var j;return(j=t.displayNameForCall)==null?void 0:j.call(t,l.data,v)}):void 0)??y(v),getUseSummary:v=>l.success?_(()=>{var j;return(j=t.getUseSummary)==null?void 0:j.call(t,l.data,v)}):void 0,getResultSummary:v=>u?g?_(()=>r==null?void 0:r(g.data,l.success?l.data:void 0)):p?_(()=>{var j;return(j=t.getResultSummary)==null?void 0:j.call(t,p.data,a,l.success?l.data:void 0,v)}):void 0:void 0,renderToolUse:v=>N(v,j=>l.success?t.renderToolUse(l.data,j):x(j)),renderToolResult:v=>N(v,j=>d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?t.renderToolUse(l.data,j):null,b()]}):g?g.render(g.data,j,l.success?l.data:void 0):p?t.renderToolResult(p.data,a,j,l.success?l.data:void 0):x(j)),renderCollapsedPreview:v=>N(v,j=>{var C,w;return d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?(C=t.renderCollapsedPreview)==null?void 0:C.call(t,l.data,void 0,a,j):null,b()]}):l.success?((w=t.renderCollapsedPreview)==null?void 0:w.call(t,l.data,p==null?void 0:p.data,a,j))??null:x(j)}),renderInteractiveSummary:v=>N(v,j=>{var C;return l.success?((C=t.renderInteractiveSummary)==null?void 0:C.call(t,l.data,p==null?void 0:p.data,a,j))??null:x(j)}),renderInline:v=>N(v,j=>{var C,w;return d!=null&&d.success?s.jsxs(s.Fragment,{children:[l.success?(C=t.renderInline)==null?void 0:C.call(t,l.data,void 0,a,i.status,j):null,b()]}):l.success?((w=t.renderInline)==null?void 0:w.call(t,l.data,p==null?void 0:p.data,a,i.status,j))??null:x(j)})}}})}const bs=I({stdout:ce().optional(),stderr:ce().optional(),interrupted:ke().default(!1),isImage:ke().default(!1),backgroundTaskId:ce().optional(),exitCode:Ke().optional(),durationSeconds:Ke().optional()}).refine(e=>e.stdout!==void 0||e.stderr!==void 0||e.backgroundTaskId!==void 0).transform(e=>({...e,stdout:e.stdout??"",stderr:e.stderr??""}));function Xt(e,t){if(!e)return{stdout:"",stderr:"",interrupted:!1,isImage:!1};if(typeof e=="string"){const r=Me(e,{bareExitCodeIsEnvelope:t}),o=r.hasEnvelope?r.output:e;return{stdout:!t||r.hasEnvelope?o:"",stderr:t&&!r.hasEnvelope?o:"",interrupted:!1,isImage:!1,...r.exitCode!==void 0?{exitCode:r.exitCode}:{}}}const n=bs.safeParse(e);return n.success?n.data:{stdout:"",stderr:"",interrupted:!1,isImage:!1}}const wh=I({file_path:ce(),offset:Ke().optional(),limit:Ke().optional()}),_h=I({file_path:ce(),content:ce(),_highlightedContentHtml:ce().optional(),_highlightedLanguage:ce().optional(),_highlightedTruncated:ke().optional(),_renderedMarkdownHtml:ce().optional()}),ul=I({filePath:ce(),content:ce(),numLines:Ke(),startLine:Ke(),totalLines:Ke()}),Wr=I({oldStart:Ke(),oldLines:Ke(),newStart:Ke(),newLines:Ke(),lines:J(ce())}),ml=I({id:ce().optional(),question:ce(),header:ce(),options:J(I({label:ce(),description:ce(),preview:ce().optional()})),multiSelect:ke(),isOther:ke().optional(),isSecret:ke().optional()}),Nh=I({questions:J(ml)}),kh=te([I({file:ul,content:ce().optional()}),ce().transform(e=>({content:e,file:void 0})),I({content:ce(),file:Js()})]),De=te([ce(),I({tool_use_id:ce(),content:ce()}).transform(e=>e.content)]),M=ce(),he=Ke(),P=M.optional(),ne=he.optional(),Vr=J(I({type:Xe(["input_text","output_text","text"]),text:M})).min(1),Sh=Vr.transform(e=>e.map(t=>t.text).join(`
|
|
36
36
|
`)),Ve=te([M.transform(e=>({content:e})),I({content:M})]),Ps={_highlightedContentHtml:P,_highlightedLanguage:P,_highlightedTruncated:ke().optional(),_renderedMarkdownHtml:P},fl=I({base64:P,filePath:P,type:M,originalSize:ne,dimensions:I({originalWidth:ne,originalHeight:ne,displayWidth:ne,displayHeight:ne}).optional()}),Ch=fl.extend({type:M.default("application/pdf")}),Th=te([I({type:Xe(["text","file_unchanged"]).optional(),file:te([ul,I({filePath:M,content:Js().optional(),numLines:Js().optional()})]),...Ps}),I({type:qn("image"),file:fl,...Ps}),I({type:qn("pdf"),file:Ch,...Ps})]),lt={file_path:P,old_string:P,new_string:P,replace_all:ke().optional(),_structuredPatch:J(Wr).optional(),_diffHtml:P,_rawPatch:P,changes:J(I({path:M})).optional()},Rh=te([I({...lt,changes:J(I({path:M})).min(1)}).transform(e=>({...e,displayVariant:"changes"})),I({...lt,file_path:M,old_string:M,new_string:M}).transform(e=>({...e,displayVariant:"replacement"})),I({...lt,_rawPatch:M}).transform(e=>({...e,displayVariant:"patch"})),I({...lt,rawPatch:M}).transform(({rawPatch:e,...t})=>({...t,_rawPatch:e,displayVariant:"patch"})),I({...lt,patch:M}).transform(({patch:e,...t})=>({...t,_rawPatch:e,displayVariant:"patch"})),M.transform(e=>({...I(lt).parse({}),_rawPatch:e,displayVariant:"patch"})),I({...lt,_structuredPatch:J(Wr)}).transform(e=>({...e,displayVariant:"augmented"})),I({...lt,file_path:M}).transform(e=>({...e,displayVariant:"target"}))]),mi=I({filePath:P,oldString:P,newString:P,originalFile:M.nullable().optional(),replaceAll:ke().optional(),userModified:ke().optional(),structuredPatch:J(Wr).optional(),content:P}),fi=te([mi,Sh.transform(e=>mi.parse({content:e}))]),Ph=I({command:P,cmd:te([M,J(M)]).optional(),description:P,timeout:ne,run_in_background:ke().optional(),_backgroundTaskStatus:P,_projectPathLinks:J(I({text:M,filePath:M})).optional(),_previewResult:te([M,bs]).optional()}).refine(e=>e.command!==void 0||e.cmd!==void 0),Eh=te([bs,De.transform(e=>Xt(e,!1))]),Ih=te([bs,ce().transform(e=>Xt(e,!0))]),Mh=I({pattern:M,path:P}),$h=I({filenames:J(M),durationMs:he,numFiles:he,truncated:ke()}),Lh=I({pattern:M,path:P,glob:P,output_mode:Xe(["files_with_matches","content","count"]).optional()}),Ah=I({mode:Xe(["files_with_matches","content","count"]),filenames:J(M),numFiles:he,content:P,numLines:ne,appliedLimit:ne,matches:J(I({filePath:M,lineNumber:he,text:M,columnNumber:ne,ranges:J(I({start:he,end:he})).optional()})).optional()}),dr=I({content:M,status:Xe(["pending","in_progress","completed"]),activeForm:M}),Fh=I({todos:J(dr)}),Bh=I({oldTodos:J(dr),newTodos:J(dr)}),Dh=I({prompt:M,description:P,subagent_type:P,model:P}),hl=I({status:Xe(["completed","failed","timeout","async_launched"]),prompt:P,agentId:P,content:J(I({type:M,id:P,text:P,_renderedHtml:P,summary:J(te([M,I({type:P,text:P})])).optional(),thinking:P,signature:P,name:P,input:Wc().optional(),tool_use_id:P,content:P,is_error:ke().optional()}).superRefine((e,t)=>{const n=e.type==="tool_use"?["name","id"]:e.type==="text"?["text"]:e.type==="tool_result"?["tool_use_id"]:[];for(const r of n)typeof Reflect.get(e,r)!="string"&&t.addIssue({code:"custom",path:[r],message:`Missing ${e.type} ${r}`})})).default([]),totalDurationMs:he.default(0),totalTokens:he.default(0),totalToolUseCount:he.default(0),isAsync:ke().optional(),outputFile:P}),Oh=te([hl,te([M,I({content:M})]).transform(e=>({status:"failed",content:[{type:"text",text:typeof e=="string"?e:e.content}],totalDurationMs:0,totalTokens:0,totalToolUseCount:0}))]),Uh=I({query:M}),Hh=I({query:M,results:J(te([M,I({content:J(I({title:M,url:M}))})])),durationSeconds:ne}),Wh=I({url:M,prompt:M}),Vh=I({bytes:he,code:he,codeText:M,result:M,durationMs:he,url:M}),Gh=I({questions:J(ml.extend({multiSelect:ke().optional()})).optional(),answers:Hc(M,te([M,J(M)])).optional()}),zh=I({plan:P,_renderedHtml:P}),hi=I({message:P,plan:P,isAgent:ke().optional(),filePath:P,_renderedHtml:P}),qh=te([M.transform(e=>({message:e})),I({message:M})]),Kh=I({explanation:P,plan:J(I({step:M,status:M})).optional()}),Es=te([M,Vr,I({message:P})]),Xh=I({session_id:te([M,he]).optional(),cell_id:te([M,he]).optional(),cellId:te([M,he]).optional(),command:P,cmd:P,chars:P,linked_command:P,linked_file_path:P,linked_tool_name:P}),pi=te([M,Vr,I({content:P,stdout:P,output:P,exitCode:ne,exit_code:ne,durationSeconds:ne,wall_time_seconds:ne})]),Yh=I({bash_id:M,block:ke().optional(),wait_up_to:ne}),Jh=I({shellId:M,command:M,status:Xe(["running","completed","failed"]),exitCode:he.nullable(),stdout:M,stderr:M,stdoutLines:he,stderrLines:he,timestamp:M}),Qh=I({task_id:M,block:ke().optional(),timeout:ne}),Zh=I({retrieval_status:Xe(["completed","timeout","running","success","not_ready"]),task:I({task_id:P,task_type:Xe(["local_bash","local_agent","agent"]).optional(),status:Xe(["running","completed","failed"]).optional(),description:P,output:P,exitCode:he.nullable().optional()}).optional()}),ep=I({shell_id:M}),tp=I({message:M,shell_id:M}),np=I({skill:M,args:P}),sp=I({success:ke(),commandName:P}),rp=I({path:M}),op=te([M,J(te([I({type:Xe(["input_text","output_text","text"]),text:M}),I({type:qn("input_image"),image_url:M,detail:P})])).min(1),I({}),Uc()]),ip=I({description:P,prompt:P,message:P,task:P,objective:P,role:P,agent_role:P,agent_type:P,subagent_type:P,model:P}),gi=I({agent_id:P,agentId:P,nickname:P}).transform(e=>({...e,agentId:e.agent_id??e.agentId})),xi=te([gi,M.transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:"custom",message:"Invalid agent result JSON"}),Oc}}).pipe(gi),M]),pl=I({version:qn(1),tasks:J(I({id:M,subject:M,status:M,description:P,activeForm:P,missingCreate:ke().optional()})),currentTaskId:P,sourceToolUseId:P,unresolvedTaskIds:J(M).optional()}),yi=I({subject:P,taskId:P,task_id:P,id:P,status:P,_taskSnapshot:pl.optional()}),ji=te([M,I({content:P,_taskSnapshot:pl.optional()})]),Is=I({objective:P,token_budget:ne,tokenBudget:ne,status:P}),bi=I({objective:P,status:P,token_budget:ne,tokenBudget:ne,tokens_used:ne,tokensUsed:ne,time_used_seconds:ne,timeUsedSeconds:ne}),Ft=te([M,bi.extend({goal:bi.nullable().optional(),message:P,content:P,error:te([M,I({message:P,detail:P})]).optional(),remainingTokens:he.nullable().optional(),remaining_tokens:he.nullable().optional()})]),vi=I({q:P,recency:ne,domains:J(M).optional()}),Ms=I({ref_id:P,lineno:he.nullable().optional(),pattern:P,id:ne}),ap=I({search_query:J(vi).optional(),image_query:J(vi).optional(),open:J(Ms).optional(),click:J(Ms).optional(),find:J(Ms).optional(),response_length:P}),lp=te([M,I({pages:J(I({ref:P,title:M,url:P,wordLimit:ne,totalLines:ne,contentType:P,published:P,redirectedUrl:P,crawled:P,source:P,text:P,lines:J(I({n:he,text:M})).optional()})),durationSeconds:ne,text:P})]),cp=I({calls:J(I({toolName:M,input:I({cmd:P}).optional()})),source:M}),dp=te([M,J(I({type:Xe(["input_text","text"]),text:M}))]),fe={TodoWrite:{partialResult:De,input:Fh,result:Bh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},TaskOutput:{partialResult:De,input:Qh,result:Zh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},AskUserQuestion:{partialResult:De,input:Nh,result:Gh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},Glob:{partialResult:De,input:Mh,result:$h,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},WebFetch:{partialResult:De,input:Wh,result:Vh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},ExitPlanMode:{partialResult:De,input:zh,result:hi,failure:qh,standaloneResultSchema:hi.refine(e=>!!(e.plan||e._renderedHtml||e.message)),variants:["standard","plain-text"],standaloneResult:!0},Exec:{input:cp,result:dp,variants:["standard"],standaloneResult:!0},Web:{input:ap,result:lp,variants:["standard"],standaloneResult:!0},UpdatePlan:{input:Kh,result:Es,failure:Es,standaloneResultSchema:Es.refine(e=>{var t;return typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.some(n=>n.text.trim().length>0):!!((t=e.message)!=null&&t.trim())}),variants:["standard"],standaloneResult:!0},Read:{partialResult:De,input:wh,result:Th,failure:Ve,variants:["text","dedup","image","pdf","plain-text"],standaloneResult:!0},ViewImage:{input:rp,result:op,variants:["standard"],standaloneResult:!1},Task:{partialResult:De,input:Dh,result:hl,failure:Oh,variants:["standard","asynchronous","plain-text"],standaloneResult:!1},Grep:{partialResult:De,input:Lh,result:Ah,failure:Ve,variants:["files","content","count","plain-text"],standaloneResult:!0},Bash:{input:Ph,result:Eh,failure:Ih,variants:["standard"],standaloneResult:!0},WebSearch:{partialResult:De,input:Uh,result:Hh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},spawn_agent:{input:ip,result:xi,failure:xi,variants:["standard"],standaloneResult:!1},Write:{input:_h,result:kh,failure:Ve,variants:["file","acknowledgement"],standaloneResult:!0},TaskCreate:{input:yi,result:ji,variants:["event","snapshot"],standaloneResult:!0},TaskUpdate:{input:yi,result:ji,variants:["event","snapshot"],standaloneResult:!0},WriteStdin:{input:Xh,result:pi,failure:pi,variants:["standard"],standaloneResult:!0},BashOutput:{partialResult:De,input:Yh,result:Jh,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},KillShell:{partialResult:De,input:ep,result:tp,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},Skill:{partialResult:De,input:np,result:sp,failure:Ve,variants:["standard","plain-text"],standaloneResult:!0},Edit:{partialResult:De,input:Rh,result:fi,failure:Ve,standaloneResultSchema:fi.refine(e=>e.filePath!==void 0||e.structuredPatch!==void 0||e.content!==void 0),variants:["replacement","patch","augmented","changes","target","plain-text"],standaloneResult:!0},create_goal:{input:Is,result:Ft,failure:Ft,variants:["standard"],standaloneResult:!0},get_goal:{input:Is,result:Ft,failure:Ft,variants:["standard"],standaloneResult:!0},update_goal:{input:Is,result:Ft,failure:Ft,variants:["standard"],standaloneResult:!0}},gl={Task:sd,Bash:nd,Read:td,Edit:ed,Write:Zc,Glob:Qc,Grep:Jc,TodoWrite:Yc,WebSearch:Xc,WebFetch:Kc,AskUserQuestion:qc,BashOutput:zc,TaskOutput:Gc,KillShell:Vc};Object.freeze(Object.keys(gl));function we(e,t){const n=gl[e];if(!n)return{valid:!0,toolName:e};const r=n.safeParse(t);return r.success?{valid:!0,toolName:e}:{valid:!1,errors:r.error,toolName:e}}function up(e){const t=e.issues,n=[],r=[];for(const o of t){const i=o.path.join(".")||"(root)";o.code==="invalid_type"&&o.message.toLowerCase().includes("required")?n.push(i):r.push({path:i,message:o.message})}return{missing:n,invalid:r}}const mp="https://github.com/kzahel/yepanywhere/issues/new";function fp(e,t,n){const r=`Schema validation error: ${e}`,o=[`## Tool
|
|
@@ -61,7 +61,7 @@ ${o.slice(-i).join(`
|
|
|
61
61
|
`)}function ng({input:e}){const t=qr(e),[n,r]=m.useState(!1),o=t.split(`
|
|
62
62
|
`),i=o.length>Ti,a=i&&!n?`${o.slice(0,Ti).join(`
|
|
63
63
|
`)}
|
|
64
|
-
...`:t,l=
|
|
64
|
+
...`:t,l=st(a);return s.jsxs("div",{className:"bash-tool-use",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:"Command"}),s.jsx(ft,{text:t,label:"Copy command"})]}),s.jsx("pre",{ref:l,className:"code-block",children:s.jsx("code",{children:s.jsx(Wt,{text:a,links:e._projectPathLinks})})}),s.jsx(zr,{command:t}),i&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!n),children:n?"Show less":`Show all ${o.length} lines`})]})}function sg({result:e,isError:t,input:n,projectPathLinks:r}){const[o,i]=m.useState(!1),{enabled:a,reportValidationError:l,isToolIgnored:c}=ve(),[d,u]=m.useState(null),f=typeof e=="string"?Xt(e,t):e;m.useEffect(()=>{if(a&&e&&typeof e=="object"){const k=we("Bash",e);!k.valid&&k.errors?(u(k.errors),l("Bash",k.errors)):u(null)}},[a,e,l]);const h=a&&d&&!c("Bash"),g=f.stdout||"",p=f.stderr||"",y=n?qr(n):"",x=st(y),b=ge(),_=g.split(`
|
|
65
65
|
`),N=m.useMemo(()=>mn(g,{projectId:b==null?void 0:b.projectId,projectPath:(b==null?void 0:b.projectPath)??void 0,projectPathLinks:r}),[g,b==null?void 0:b.projectId,b==null?void 0:b.projectPath,r]),v=m.useMemo(()=>mn(p,{projectId:b==null?void 0:b.projectId,projectPath:(b==null?void 0:b.projectPath)??void 0,projectPathLinks:r}),[p,b==null?void 0:b.projectId,b==null?void 0:b.projectPath,r]),j=_.length>Ci,C=j&&!o?`${_.slice(0,Ci).join(`
|
|
66
66
|
`)}
|
|
67
67
|
...`:g,w=N.changed?g:C;return s.jsxs("div",{className:`bash-result ${t?"bash-result-error":""}`,children:[h&&d&&s.jsx(q,{toolName:"Bash",errors:d}),y&&s.jsxs("div",{className:"bash-expanded-section bash-expanded-command-section",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:"Command"}),s.jsx(ft,{text:y,label:"Copy command"})]}),s.jsx("pre",{ref:x,className:"code-block",children:s.jsx("code",{children:s.jsx(Wt,{text:y,links:n==null?void 0:n._projectPathLinks})})}),s.jsx(zr,{command:y})]}),(f==null?void 0:f.interrupted)&&s.jsx("span",{className:"badge badge-warning",children:"Interrupted"}),(f==null?void 0:f.backgroundTaskId)&&s.jsxs("span",{className:"badge badge-info",children:["Background: ",f.backgroundTaskId]}),s.jsx(_l,{result:f}),g&&s.jsxs("div",{className:"bash-stdout bash-expanded-section",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:"Output"}),s.jsx(ft,{text:g,label:"Copy output"})]}),s.jsx(Ye,{sourceText:w,projectPathLinks:r,precomputedRendered:w===g?N:kl,sourceView:s.jsx("pre",{className:"code-block",children:s.jsx(pt,{text:C})}),renderRenderedView:k=>Zn(k)}),j&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>i(!o),children:o?"Show less":`Show all ${_.length} lines`})]}),p&&s.jsxs("div",{className:"bash-stderr bash-expanded-section",children:[s.jsxs("div",{className:"bash-inline-section-header",children:[s.jsx("span",{className:"bash-inline-section-label",children:t?"Error":"Stderr"}),s.jsx(ft,{text:p,label:t?"Copy error output":"Copy stderr"})]}),s.jsx(Ye,{sourceText:p,projectPathLinks:r,precomputedRendered:v,sourceView:s.jsx("pre",{className:"code-block code-block-error",children:s.jsx(pt,{text:p})}),renderRenderedView:k=>Zn(k,"code-block code-block-error")})]}),!g&&!p&&!(f!=null&&f.interrupted)&&s.jsx("div",{className:"bash-empty",children:"No output"})]})}function rg(e){return e._previewResult}function og({input:e,result:t,isError:n,provider:r,projectPathLinks:o}){const[i,a]=m.useState(!1),l=us(),{enabled:c,reportValidationError:d,isToolIgnored:u}=ve(),[f,h]=m.useState(null),g=t??rg(e),p=typeof g=="string"?Xt(g,n):g;m.useEffect(()=>{if(c&&t&&typeof t=="object"){const R=we("Bash",t);!R.valid&&R.errors?(h(R.errors),d("Bash",R.errors)):h(null)}},[c,t,d]);const y=c&&f&&!u("Bash"),x=ge(),b=!!(p!=null&&p.stderr),_=tg((b?p==null?void 0:p.stderr:p==null?void 0:p.stdout)||"",r),N=m.useMemo(()=>mn(_,{projectId:x==null?void 0:x.projectId,projectPath:(x==null?void 0:x.projectPath)??void 0,projectPathLinks:o}),[_,x==null?void 0:x.projectId,x==null?void 0:x.projectPath,o]),{text:v,truncated:j}=bl(_,N.changed?{maxLines:Qp,maxChars:Zp}:yl(l)),C=jl(_,l),w=Yt(_,l),k=m.useMemo(()=>v===_?N:N.changed?mn(v,{projectId:x==null?void 0:x.projectId,projectPath:(x==null?void 0:x.projectPath)??void 0,projectPathLinks:o}):kl,[v,_,N,x==null?void 0:x.projectId,x==null?void 0:x.projectPath,o]),S=v.length>0,$=m.useCallback(R=>{var K;const D=R.target;(K=D==null?void 0:D.closest)!=null&&K.call(D,"button,a")||Nl(R.currentTarget)||a(!0)},[]),T=m.useCallback(R=>{R.target===R.currentTarget&&(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),a(!0))},[]),E=m.useCallback(()=>{a(!1)},[]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{role:"button",tabIndex:0,"aria-label":"View bash command output",className:"bash-collapsed-preview",onClick:$,onKeyDown:T,children:[y&&f&&s.jsx("div",{className:"bash-preview-row bash-preview-warning-row",children:s.jsx(q,{toolName:"Bash",errors:f})}),S&&s.jsxs("div",{className:"bash-preview-row bash-preview-output-row",children:[s.jsxs("div",{className:`bash-preview-output ${j?"bash-preview-truncated":""} ${b?"bash-preview-error":""}`,style:{"--bash-preview-line-count":String(l)},children:[s.jsx(Ye,{sourceText:v,projectPathLinks:o,precomputedRendered:k,sourceView:s.jsx("pre",{children:s.jsx(pt,{text:v,compact:!0})}),renderRenderedView:R=>s.jsx("pre",{children:s.jsx("div",{className:`fixed-font-rendered__content ${vl.fixedWidthOutput}`,dangerouslySetInnerHTML:{__html:R}})})}),j&&s.jsx("div",{className:"bash-preview-fade"})]}),s.jsx(ft,{text:_,label:b?"Copy stderr":"Copy output"}),C>0&&s.jsx(Tt,{className:"bash-preview-more",count:C,tooltip:w??_})]}),!S&&p&&!p.interrupted&&s.jsx("div",{className:"bash-preview-row",children:s.jsx("span",{className:"bash-preview-empty",children:"No output"})}),(p==null?void 0:p.interrupted)&&s.jsx("div",{className:"bash-preview-row",children:s.jsx("span",{className:"bash-preview-interrupted",children:"Interrupted"})})]}),i&&s.jsx(Mt,{title:e.description||"Bash Command",label:e.description||"Bash Command",onClose:E,children:s.jsx(wl,{input:e,result:p,isError:n,projectPathLinks:o})})]})}const ig=de(fe.Bash,{tool:"Bash",displayName:"Ran",pendingDisplayName:"Run",displayNameForCall(e,t){return t!=="complete"?void 0:e._backgroundTaskStatus==="running"?"Running":void 0},renderToolUse(e,t){return s.jsx(ng,{input:e})},renderToolResult(e,t,n,r){return s.jsx(sg,{result:e,isError:t,input:r,projectPathLinks:n.projectPathLinks})},getUseSummary(e){const t=e,n=qr(t);if(t.description)return t.description;if(!n)return"Bash command";const r=n.split(`
|
|
@@ -91,25 +91,25 @@ ${o.slice(-i).join(`
|
|
|
91
91
|
`),baseFilePath:e.filePath,renderMode:Pt(Rt(t,e)),truncated:x,hiddenLineCount:Math.max(0,y-Ae),sourceView:e.structuredPatch.map((v,j)=>s.jsx(Dg,{hunk:v},`hunk-${v.oldStart}-${j}`))})})]}),r&&s.jsx(Nt,{filePath:e.filePath??"",displayText:_t(e.filePath),lineRange:pn(e.structuredPatch),label:_t(e.filePath),onClose:g,children:s.jsx(gn,{structuredPatch:e.structuredPatch,filePath:e.filePath??"",oldString:e.oldString??(t==null?void 0:t.old_string)??"",newString:e.newString??(t==null?void 0:t.new_string)??"",originalFile:e.originalFile,selection:i})})]})}const zg=de(fe.Edit,{tool:"Edit",displayName:"Edit",renderToolUse(e){return s.jsx(Ug,{input:e})},renderToolResult(e,t,n,r){return s.jsx(Gg,{result:e,input:r,isError:t})},getUseSummary(e){return ur(e)},getResultSummary(e,t,n){if(t){const o=e==null?void 0:e.content;return o?vs(o).label:"Error"}return ur(n,e)},renderCollapsedPreview(e,t,n){return s.jsx(Wg,{input:e,result:t,isError:n})},renderInteractiveSummary(e,t,n,r){return s.jsx(Vg,{input:e,result:t,isError:n})}}),qg="_pending_1d2ql_1",Kg="_root_1d2ql_8",Xg="_inline_1d2ql_17",Yg="_error_1d2ql_102",tn={pending:qg,root:Kg,inline:Xg,error:Yg};function $i({plan:e,renderedHtml:t}){const n=va(t??"");return t?s.jsx("div",{dangerouslySetInnerHTML:{__html:n}}):s.jsx("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"inherit"},children:e})}const Jg=de(fe.ExitPlanMode,{tool:"ExitPlanMode",renderToolUse(){return null},renderToolResult(e,t){return t?s.jsx("div",{className:tn.error,children:e.message}):s.jsx($i,{plan:e.plan??e.message,renderedHtml:e._renderedHtml})},renderInline(e,t,n,r){const o=e,i=t,a=(o==null?void 0:o.plan)||(i==null?void 0:i.plan),l=(o==null?void 0:o._renderedHtml)||(i==null?void 0:i._renderedHtml);if(n){let c="Exit plan mode failed";if(typeof t=="string")c=t;else if(typeof t=="object"&&t!==null){const d="message"in t?t:void 0;d!=null&&d.message&&(c=String(d.message))}return s.jsx("div",{className:tn.error,children:c})}return!a&&!l?r==="pending"?s.jsx("div",{className:tn.pending,children:"Planning..."}):null:s.jsxs("details",{className:`${tn.root} collapsible`,open:!0,children:[s.jsxs("summary",{className:"collapsible__summary",children:[s.jsx("span",{children:r==="pending"?"Planning...":"Plan"}),s.jsx("span",{className:"collapsible__icon",children:"▸"})]}),s.jsx("div",{className:"collapsible__content",children:s.jsx("div",{className:`${tn.inline} ${r==="pending"?"pending":""}`,children:s.jsx($i,{plan:a,renderedHtml:l})})})]})},getUseSummary(e){return"Exit plan mode"},getResultSummary(e,t){return t?"Error":"Plan"}}),Qg="_toolUse_w9zbq_1",Zg="_pattern_w9zbq_8",ex="_path_w9zbq_14",tx="_result_w9zbq_19",nx="_header_w9zbq_25",sx="_count_w9zbq_31",rx="_error_w9zbq_36",ox="_empty_w9zbq_43",dt={toolUse:Qg,pattern:Zg,path:ex,result:tx,header:nx,count:sx,error:rx,empty:ox},Fs=20;function ix(e){return tt(e)}function ax({input:e,projectPath:t}){return s.jsxs("div",{className:dt.toolUse,children:[s.jsx("span",{className:dt.pattern,children:e.pattern}),e.path&&s.jsxs("span",{className:dt.path,children:["in ",oe(e.path,t)]})]})}function lx({result:e,projectPath:t}){const[n,r]=m.useState(!1),{enabled:o,reportValidationError:i,isToolIgnored:a}=ve(),[l,c]=m.useState(null);m.useEffect(()=>{if(o&&e){const y=we("Glob",e);!y.valid&&y.errors?(c(y.errors),i("Glob",y.errors)):c(null)}},[o,e,i]);const d=o&&l&&!a("Glob");if(!(e!=null&&e.filenames)||e.filenames.length===0)return s.jsxs("div",{className:dt.empty,children:[d&&l&&s.jsx(q,{toolName:"Glob",errors:l}),"No files found"]});const{filenames:u,numFiles:f,truncated:h}=e,g=u.length>Fs,p=g&&!n?u.slice(0,Fs):u;return s.jsxs("div",{className:dt.result,children:[s.jsxs("div",{className:dt.header,children:[s.jsxs("span",{className:dt.count,children:[f," files"]}),h&&s.jsx("span",{className:"badge badge-warning",children:"truncated"}),d&&l&&s.jsx(q,{toolName:"Glob",errors:l})]}),s.jsxs("div",{className:"file-list",children:[p.map(y=>s.jsxs("div",{className:"file-list-item",children:[s.jsx("span",{className:"file-path",children:ix(oe(y,t))}),s.jsx("span",{className:"file-dir",children:oe(y,t)})]},y)),g&&!n&&s.jsxs("div",{className:"file-list-more",children:["... and ",u.length-Fs," more"]})]}),g&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!n),children:n?"Show less":`Show all ${u.length} files`})]})}const cx=de(fe.Glob,{tool:"Glob",displayName:"List",renderToolUse(e,t){return s.jsx(ax,{input:e,projectPath:t.projectPath})},renderToolResult(e,t,n){return s.jsx(lx,{result:e,projectPath:n.projectPath})},renderFailure(e){return s.jsx("div",{className:dt.error,children:e.content||"Glob search failed"})},getFailureSummary(){return"Error"},getUseSummary(e,t){const n=e,r=`pattern: "${n.pattern}"`;return n.path?`${r} in ${oe(n.path,t==null?void 0:t.projectPath)}`:r},getResultSummary(e){const t=e;return(t==null?void 0:t.numFiles)===void 0?"Searching...":t.numFiles===0?"No files found":`Found ${t.numFiles} files`}}),dx="_card_e2590_1",ux="_empty_e2590_2",mx="_statusActive_e2590_25",fx="_statusPaused_e2590_29",hx="_statusLimited_e2590_30",px="_statusBlocked_e2590_34",gx="_error_e2590_35",xx="_statusComplete_e2590_39",yx="_statusUnknown_e2590_43",jx="_topline_e2590_47",bx="_objectiveLabel_e2590_55",vx="_statusBadge_e2590_65",wx="_objective_e2590_55",_x="_metrics_e2590_111",Nx="_metric_e2590_111",kx="_metricSecondary_e2590_129",Sx="_progress_e2590_133",Cx="_errorMessage_e2590_166",Ne={card:dx,empty:ux,statusActive:mx,statusPaused:fx,statusLimited:hx,statusBlocked:px,error:gx,statusComplete:xx,statusUnknown:yx,topline:jx,objectiveLabel:bx,statusBadge:vx,objective:wx,metrics:_x,metric:Nx,metricSecondary:kx,progress:Sx,errorMessage:Cx};function Gt(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function bn(e){if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}}function zt(e,...t){for(const n of t){const r=e[n];if(typeof r=="string"&&r.trim())return r.trim()}}function ln(e,...t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r}}function $l(e){if(!e)return"active";switch(e.trim().toLowerCase().replace(/[\s_-]+/g,"")){case"active":return"active";case"paused":return"paused";case"blocked":return"blocked";case"usagelimited":return"usageLimited";case"budgetlimited":return"budgetLimited";case"complete":case"completed":return"complete";default:return e}}function Tx(e){const t=bn(e);if(!Gt(t))return;const n=zt(t,"objective");if(n)return{objective:n,status:$l(zt(t,"status")),tokenBudget:ln(t,"tokenBudget","token_budget"),tokensUsed:ln(t,"tokensUsed","tokens_used"),timeUsedSeconds:ln(t,"timeUsedSeconds","time_used_seconds")}}function Ll(e){const t=bn(e);if(!Gt(t))return{};const r=Object.hasOwn(t,"goal")?t.goal:t;return{goal:r===null?null:Tx(r),remainingTokens:ln(t,"remainingTokens","remaining_tokens")}}function Al(e){const t=bn(e);if(!Gt(t))return;const n=zt(t,"objective");if(n)return{objective:n,status:"active",tokenBudget:ln(t,"tokenBudget","token_budget"),tokensUsed:0,timeUsedSeconds:0}}function Qr(e){const t=bn(e);if(!Gt(t))return;const n=$l(zt(t,"status"));return n==="complete"||n==="blocked"?n:void 0}function Li(e){return e.replace(/\s+/g," ").trim()}function Ai(e,t,n){var o;const r=Ll(n);if((o=r.goal)!=null&&o.objective)return Li(r.goal.objective);if(r.goal===null)return"No goal set";if(e==="create"){const i=Al(t);if(i)return Li(i.objective)}return e==="update"?Qr(t)??"current goal":"current goal"}function Rx(e,t,n){if(e==="create")return n==="pending"?"Creating goal":n==="complete"?"Created goal":"Create goal";if(e==="get")return n==="pending"?"Checking goal":n==="complete"?"Checked goal":"Check goal";const r=Qr(t);if(n!=="pending"&&n!=="complete")return r==="complete"?"Complete goal":r==="blocked"?"Block goal":"Update goal";if(r==="complete"){if(n==="pending")return"Completing goal";if(n==="complete")return"Goal complete"}if(r==="blocked"){if(n==="pending")return"Blocking goal";if(n==="complete")return"Goal blocked"}return n==="pending"?"Updating goal":"Updated goal"}function Px(e){const t=bn(e);if(typeof t=="string")return t.trim()||void 0;if(!Gt(t))return;const n=zt(t,"message","error","content");return n||(Gt(t.error)?zt(t.error,"message","detail"):void 0)}function Ex(e){const t=Math.max(0,Math.round(e));if(t<60)return`${t}s`;const n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;const r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function Ix(e){switch(e){case"active":return Ne.statusActive;case"paused":return Ne.statusPaused;case"blocked":return Ne.statusBlocked;case"usageLimited":case"budgetLimited":return Ne.statusLimited;case"complete":return Ne.statusComplete;default:return Ne.statusUnknown}}function Bs({operation:e,input:t,result:n,isError:r,context:o}){const{locale:i,t:a}=Z(),l=Ll(n),c=l.goal??(e==="create"?Al(t):void 0),d=new Intl.NumberFormat(i),u=x=>{switch(x){case"active":return a("goalRendererStatusActive");case"paused":return a("goalRendererStatusPaused");case"blocked":return a("goalRendererStatusBlocked");case"usageLimited":return a("goalRendererStatusUsageLimited");case"budgetLimited":return a("goalRendererStatusBudgetLimited");case"complete":return a("goalRendererStatusComplete");default:return x.replace(/([a-z])([A-Z])/g,"$1 $2")}};if(r)return s.jsxs("div",{className:`${Ne.card} ${Ne.error}`,"data-goal-card":"error",children:[s.jsx("strong",{children:a("goalRendererFailed")}),s.jsx("span",{className:Ne.errorMessage,children:Px(n)??a("goalRendererFailedFallback")})]});if(!c){const x=Qr(t),b=o.isStreaming?a(e==="get"?"goalRendererChecking":x==="complete"?"goalRendererCompleting":x==="blocked"?"goalRendererBlocking":"goalRendererUpdating"):l.goal===null?a("goalRendererNone"):a("goalRendererDetailsUnavailable");return s.jsx("div",{className:Ne.empty,"data-goal-card":"empty",children:b})}const f=c.tokensUsed,h=c.tokenBudget,g=l.remainingTokens??(h!==void 0&&f!==void 0?Math.max(0,h-f):void 0),p=h!==void 0&&h>0,y=p?Math.min(h,Math.max(0,f??0)):void 0;return s.jsxs("section",{className:`${Ne.card} ${Ix(c.status)}`,"aria-label":a("goalRendererCardLabel"),"data-goal-card":"goal","data-goal-status":c.status,children:[s.jsxs("div",{className:Ne.topline,children:[s.jsx("span",{className:Ne.objectiveLabel,children:a("goalRendererObjectiveLabel")}),s.jsx("span",{className:Ne.statusBadge,children:u(c.status)})]}),s.jsx("p",{className:Ne.objective,children:c.objective}),(f!==void 0||(c.timeUsedSeconds??0)>0)&&s.jsxs("div",{className:Ne.metrics,children:[f!==void 0&&s.jsx("span",{className:Ne.metric,children:p?a("goalRendererTokenBudget",{used:d.format(f),budget:d.format(h)}):a("goalRendererTokensUsed",{count:d.format(f)})}),g!==void 0&&s.jsx("span",{className:Ne.metricSecondary,children:a("goalRendererTokensRemaining",{count:d.format(g)})}),(c.timeUsedSeconds??0)>0&&s.jsx("span",{className:Ne.metricSecondary,children:a("goalRendererElapsed",{duration:Ex(c.timeUsedSeconds??0)})})]}),p&&y!==void 0&&s.jsx("progress",{className:Ne.progress,value:y,max:h,"aria-label":a("goalRendererTokenProgressLabel",{used:d.format(f??0),budget:d.format(h)})})]})}function Zr(e,t){return de(fe[e],{tool:e,displayName:"Goal",displayNameForCall(n,r){return Rx(t,n,r)},renderToolUse(n,r){return s.jsx(Bs,{operation:t,input:n,isError:!1,context:r})},renderToolResult(n,r,o,i){return s.jsx(Bs,{operation:t,input:i,result:n,isError:r,context:o})},renderCollapsedPreview(n,r,o,i){return s.jsx(Bs,{operation:t,input:n,result:r,isError:o,context:i})},getUseSummary(n){return Ai(t,n)},getResultSummary(n,r,o){return r?"failed":Ai(t,o,n)}})}const Mx=Zr("create_goal","create"),$x=Zr("get_goal","get"),Lx=Zr("update_goal","update"),Ax="_toolUse_142hc_1",Fx="_pattern_142hc_8",Bx="_glob_142hc_14",Dx="_path_142hc_19",Ox="_result_142hc_24",Ux="_header_142hc_30",Hx="_count_142hc_36",Wx="_inlineSummary_142hc_41",Vx="_summaryPattern_142hc_54",Gx="_summaryPatternRow_142hc_62",zx="_summaryPatternClip_142hc_70",qx="_summaryPatternAction_142hc_79",Kx="_summaryPatternFull_142hc_99",Xx="_summaryPatternMeasure_142hc_106",Yx="_summaryScope_142hc_115",Jx="_summaryScopePrefix_142hc_132",Qx="_summaryScopeText_142hc_136",Zx="_summaryArrow_142hc_140",ey="_matchCountButton_142hc_144",ty="_matchModal_142hc_160",ny="_matchTable_142hc_165",sy="_matchFile_142hc_179",ry="_matchLine_142hc_185",oy="_matchText_142hc_192",iy="_matchHighlight_142hc_198",ay="_collapsedPreview_142hc_208",ly="_previewMatch_142hc_221",cy="_previewFile_142hc_229",dy="_previewLine_142hc_241",uy="_previewText_142hc_246",my="_previewMore_142hc_253",fy="_countSummary_142hc_260",hy="_content_142hc_269",py="_error_142hc_273",gy="_empty_142hc_280",Y={toolUse:Ax,pattern:Fx,glob:Bx,path:Dx,result:Ox,header:Ux,count:Hx,inlineSummary:Wx,summaryPattern:Vx,summaryPatternRow:Gx,summaryPatternClip:zx,summaryPatternAction:qx,summaryPatternFull:Kx,summaryPatternMeasure:Xx,summaryScope:Yx,summaryScopePrefix:Jx,summaryScopeText:Qx,summaryArrow:Zx,matchCountButton:ey,matchModal:ty,matchTable:ny,matchFile:sy,matchLine:ry,matchText:oy,matchHighlight:iy,collapsedPreview:ay,previewMatch:ly,previewFile:cy,previewLine:dy,previewText:uy,previewMore:my,countSummary:fy,content:hy,error:py,empty:gy},Ds=20,Fi=30,Os="...",xy=12;function Fl(e){return e?e.split(`
|
|
92
92
|
`).filter(t=>/(^|:)\d+:/.test(t)).length:0}function yy(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jy(e){if(!e)return null;try{const t=new RegExp(e,"g");return t.source==="(?:)"?null:t}catch{const t=yy(e);return t?new RegExp(t,"gi"):null}}function by(e,t){if(!t||t.length===0)return null;const n=[];let r=0;for(const[o,i]of t.entries()){const a=Math.max(0,Math.min(e.length,i.start)),l=Math.max(a,Math.min(e.length,i.end));if(a>r&&n.push(e.slice(r,a)),l>a&&n.push(s.jsx("mark",{className:Y.matchHighlight,children:e.slice(a,l)},`match-${o}`)),r=l,o>=50)break}return r<e.length&&n.push(e.slice(r)),n.length>0?n:null}function Bl(e,t,n){const r=by(e,t);if(r)return r;const o=jy(n);if(!o)return e;const i=[];let a=0,l=0;for(const c of e.matchAll(o)){const d=c[0],u=c.index??0;if(!d||(u>a&&i.push(e.slice(a,u)),i.push(s.jsx("mark",{className:Y.matchHighlight,children:d},`match-${l}`)),l+=1,a=u+d.length,l>=50))break}return i.length===0?e:(a<e.length&&i.push(e.slice(a)),i)}function Dl({label:e,matches:t,pattern:n,projectPath:r}){const[o,i]=m.useState(!1),a=Ol(t);return t.length===0?s.jsx("span",{className:Y.count,children:e}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:Y.matchCountButton,onClick:l=>{l.preventDefault(),l.stopPropagation(),i(!0)},children:e}),o&&s.jsx(Mt,{title:e,label:e,onClose:()=>i(!1),children:s.jsx("div",{className:Y.matchModal,children:s.jsxs("table",{className:Y.matchTable,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[a&&s.jsx("th",{children:"File"}),s.jsx("th",{children:"Line"}),s.jsx("th",{children:"Text"})]})}),s.jsx("tbody",{children:t.map((l,c)=>s.jsxs("tr",{children:[a&&s.jsx("td",{className:Y.matchFile,children:oe(l.filePath,r)}),s.jsx("td",{className:Y.matchLine,children:l.columnNumber?`${l.lineNumber}:${l.columnNumber}`:l.lineNumber}),s.jsx("td",{className:Y.matchText,children:Bl(l.text,l.ranges,n)})]},`${l.filePath}:${l.lineNumber}:${l.columnNumber??""}:${c}`))})]})})})]})}function eo(e){return tt(e)}function Ol(e){return new Set(e.map(n=>n.filePath)).size>1}function vy({input:e,projectPath:t}){return s.jsxs("div",{className:Y.toolUse,children:[s.jsx("span",{className:Y.pattern,children:e.pattern}),e.glob&&s.jsxs("span",{className:Y.glob,children:["(",e.glob,")"]}),e.path&&s.jsxs("span",{className:Y.path,children:["in ",oe(e.path,t)]})]})}function wy({filenames:e,isExpanded:t,projectPath:n,setIsExpanded:r}){const o=e.length>Ds,i=o&&!t?e.slice(0,Ds):e;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"file-list",children:[i.map(a=>s.jsxs("div",{className:"file-list-item",children:[s.jsx("span",{className:"file-path",children:eo(oe(a,n))}),s.jsx("span",{className:"file-dir",children:oe(a,n)})]},a)),o&&!t&&s.jsxs("div",{className:"file-list-more",children:["... and ",e.length-Ds," more"]})]}),o&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>r(!t),children:t?"Show less":`Show all ${e.length} files`})]})}function _y({content:e,isExpanded:t,setIsExpanded:n}){const r=e.split(`
|
|
93
93
|
`),o=r.length>Fi,a=(o&&!t?r.slice(0,Fi):r).join(`
|
|
94
|
-
`),l=rt(a);return s.jsxs(s.Fragment,{children:[s.jsx("pre",{ref:l,className:`${Y.content} code-block`,children:s.jsx("code",{children:a})}),o&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${r.length} lines`})]})}function Ny({input:e,result:t,isError:n,projectPath:r}){const o=us(),i=m.useMemo(()=>n||(t==null?void 0:t.mode)!=="content"?[]:t.matches??[],[n,t]),a=Math.max(0,o-1),l=i.slice(0,a);if(l.length===0)return null;const c=Ol(i),d=Math.max(0,i.length-l.length);return s.jsxs("div",{className:Y.collapsedPreview,children:[l.map((u,f)=>s.jsxs("div",{className:Y.previewMatch,children:[c&&s.jsx("span",{className:Y.previewFile,title:oe(u.filePath,r),children:eo(oe(u.filePath,r))}),s.jsx("span",{className:Y.previewLine,children:u.columnNumber?`${u.lineNumber}:${u.columnNumber}`:u.lineNumber}),s.jsx(ky,{match:u,pattern:e==null?void 0:e.pattern})]},`${u.filePath}:${u.lineNumber}:${u.columnNumber??""}:${f}`)),d>0&&s.jsxs("div",{className:Y.previewMore,children:["+",d," ",d===1?"match":"matches"]})]})}function ky({match:e,pattern:t}){const n=rt(e.text);return s.jsx("span",{ref:n,className:Y.previewText,children:Bl(e.text,e.ranges,t)})}function Sy({input:e,result:t,projectPath:n}){const[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&t){const x=we("Grep",t);!x.valid&&x.errors?(d(x.errors),a("Grep",x.errors)):d(null)}},[i,t,a]);const u=i&&c&&!l("Grep");if(!t)return s.jsx("div",{className:Y.empty,children:"No results"});const{mode:f,filenames:h,numFiles:g,content:p,appliedLimit:y}=t;if(f==="count")return s.jsxs("div",{className:Y.result,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),s.jsxs("div",{className:Y.countSummary,children:[g," ",g===1?"file":"files"," matched"]})]});if(f==="content"&&p){const x=t.matches??[],b=x.length||Fl(p),_=`${b} ${b===1?"match":"matches"}`;return s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsx(Dl,{label:_,matches:x,pattern:e==null?void 0:e.pattern,projectPath:n}),y&&s.jsxs("span",{className:"badge badge-info",children:["limit: ",y]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(_y,{content:p,isExpanded:r,setIsExpanded:o})]})}return!h||h.length===0?s.jsxs("div",{className:Y.empty,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),"No matches found"]}):s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsxs("span",{className:Y.count,children:[g," files"]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(wy,{filenames:h,isExpanded:r,projectPath:n,setIsExpanded:o})]})}function Ul(e,t){if(e.path){const n=oe(e.path,t);return{kind:"path",value:e.path,label:eo(n)}}return e.glob?{kind:"glob",value:e.glob,label:e.glob}:null}function Hl(e,t){const n=Ul(e,t);if(!n)return e.pattern;const r=n.kind==="path"?oe(n.value,t):n.value;return`${e.pattern} in ${r}`}function Cy(e,t,n){if(t<=0)return"";if(n(e)<=t)return e;if(n(Os)>t)return"";let r=0,o=e.length;for(;r<o;){const i=Math.ceil((r+o)/2),a=`${e.slice(0,i)}${Os}`;n(a)<=t?r=i:o=i-1}return`${e.slice(0,r)}${Os}`}function Ty({expanded:e,input:t,onToggle:n,projectPath:r}){const o=Hl(t,r),i=Ul(t,r),a=(i==null?void 0:i.value)??"",l=m.useRef(null),c=m.useRef(null),d=m.useRef(null),[u,f]=m.useState(t.pattern);m.useLayoutEffect(()=>{const p=()=>{var C;if(e){f(t.pattern);return}const x=l.current,b=d.current;if(!x||!b){f(t.pattern);return}const _=x.getBoundingClientRect().width;if(_<=0){f(t.pattern);return}const N=((C=c.current)==null?void 0:C.getBoundingClientRect().width)??0,v=Math.max(0,_-N-(N>0?xy:0)),j=w=>(b.textContent=w,b.getBoundingClientRect().width);f(Cy(t.pattern,v,j))};if(p(),typeof ResizeObserver>"u")return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const y=new ResizeObserver(p);return l.current&&y.observe(l.current),c.current&&y.observe(c.current),()=>y.disconnect()},[e,t.pattern,a]);const h=`${Y.summaryPatternClip}${n?` ${Y.summaryPatternAction}`:""}`,g=n?s.jsx("button",{type:"button",className:h,title:o,"aria-label":e?"Collapse grep pattern":"Show full grep pattern","aria-expanded":e,onClick:p=>{p.preventDefault(),p.stopPropagation(),n()},children:u}):s.jsx("span",{className:h,title:o,children:u});return s.jsxs("span",{className:`${Y.summaryPattern}${e?" is-expanded":""}`,children:[s.jsxs("span",{className:Y.summaryPatternRow,ref:l,children:[g,i&&s.jsxs("span",{className:Y.summaryScope,ref:c,children:[s.jsx("span",{className:Y.summaryScopePrefix,children:"in"}),i.kind==="path"?s.jsx(Ue,{displayPath:i.label,filePath:i.value,showLineSuffix:!1}):s.jsx("span",{className:Y.summaryScopeText,title:i.value,children:i.label})]})]}),s.jsx("span",{className:Y.summaryPatternMeasure,ref:d}),e&&s.jsx("span",{className:Y.summaryPatternFull,children:o})]})}function Wl(e){if(e.mode==="content"){const t=e.matches??[],n=t.length||Fl(e.content);return{matches:t,text:`${n} ${n===1?"match":"matches"}`}}return e.numFiles===0?{matches:[],text:"0 matches"}:{matches:[],text:e.numFiles!==void 0?`${e.numFiles} ${e.numFiles===1?"file":"files"}`:"Results"}}function Ry({input:e,result:t,isError:n,projectPath:r,summaryExpanded:o,toggleSummaryExpanded:i}){if(n||!t)return null;const a=Wl(t);return s.jsxs("span",{className:Y.inlineSummary,children:[s.jsx(Ty,{expanded:o??!1,input:e,onToggle:i,projectPath:r}),s.jsx("span",{className:Y.summaryArrow,"aria-hidden":"true",children:"→"}),s.jsx(Dl,{label:a.text,matches:a.matches,pattern:e.pattern,projectPath:r})]})}const Py=de(fe.Grep,{tool:"Grep",displayName:"Grep",renderToolUse(e,t){return s.jsx(vy,{input:e,projectPath:t.projectPath})},renderToolResult(e,t,n,r){return s.jsx(Sy,{input:r,result:e,projectPath:n.projectPath})},renderFailure(e){return s.jsx("div",{className:Y.error,children:e.content||"Search failed"})},getFailureSummary(){return"Error"},getUseSummary(e,t){return Hl(e,t==null?void 0:t.projectPath)},getResultSummary(e){const t=e;return t?Wl(t).text:"Results"},renderInteractiveSummary(e,t,n,r){return s.jsx(Ry,{input:e,result:t,isError:n,projectPath:r.projectPath,summaryExpanded:r.summaryExpanded,toggleSummaryExpanded:r.toggleSummaryExpanded})},renderCollapsedPreview(e,t,n,r){return s.jsx(Ny,{input:e,result:t,isError:n,projectPath:r.projectPath})}}),Ey="_toolUse_1vtak_1",Iy="_label_1vtak_7",My="_shellId_1vtak_11",$y="_result_1vtak_20",Ly="_message_1vtak_26",Ay="_error_1vtak_30",Fy="_empty_1vtak_37",ut={toolUse:Ey,label:Iy,shellId:My,result:$y,message:Ly,error:Ay,empty:Fy};function By({input:e}){return s.jsxs("div",{className:ut.toolUse,children:[s.jsx("span",{className:ut.label,children:"Killing shell"}),s.jsx("code",{className:ut.shellId,children:e.shell_id})]})}function Dy({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("KillShell",e);!l.valid&&l.errors?(i(l.errors),n("KillShell",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("KillShell");return e?s.jsxs("div",{className:ut.result,children:[a&&o&&s.jsx(q,{toolName:"KillShell",errors:o}),s.jsx("span",{className:ut.message,children:e.message}),e.shell_id&&s.jsx("code",{className:ut.shellId,children:e.shell_id})]}):s.jsx("div",{className:ut.empty,children:"No result"})}const Oy=de(fe.KillShell,{tool:"KillShell",renderToolUse(e,t){return s.jsx(By,{input:e})},renderToolResult(e,t,n){return s.jsx(Dy,{result:e})},renderFailure(e){return s.jsx("div",{className:ut.error,children:e.content||"Failed to kill shell"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.shell_id},getResultSummary(e){const t=e;return(t==null?void 0:t.message)||"Killed"}}),Uy="_container_blm34_7",Hy={container:Uy};function ws({html:e,className:t}){return s.jsx("div",{className:`shiki-container ${Hy.container}${t?` ${t}`:""}`,dangerouslySetInnerHTML:{__html:Wd(e)??""}})}const Wy="_imagePreviewButton_1dcmz_1",Vy={imagePreviewButton:Wy};function cn(e){return tt(e)}function to(e){return"content"in e&&typeof e.content=="string"}function Gy(e){return"filePath"in e?e.filePath??"":""}function zy({filePath:e}){const t=ge(),n=oe(e,t==null?void 0:t.projectPath);return s.jsx("div",{className:"read-text-result read-text-inline",children:s.jsx(vt,{displayPath:n,filePath:e,children:s.jsx("span",{className:"file-line-count-inline",children:"unchanged"})})})}function mr(e){if(e.numLines<=0)return{};if(!(e.startLine>1||e.numLines<e.totalLines))return{};const n=e.startLine+Math.max(1,e.numLines)-1;return{lineEnd:n>e.startLine?n:void 0,lineNumber:e.startLine}}function qy(e){if(e.offset===void 0)return{};const t=e.limit!==void 0?e.offset+Math.max(1,e.limit)-1:void 0;return{lineEnd:t!==void 0&&t>e.offset?t:void 0,lineNumber:e.offset}}function Bi(e){return s.jsx("div",{className:"file-viewer-code fixed-font-rendered-panel",children:s.jsx("div",{className:"fixed-font-rendered__content",dangerouslySetInnerHTML:{__html:e}})})}function vt({children:e,displayPath:t,filePath:n,lineEnd:r,lineNumber:o}){return s.jsxs("span",{className:"file-link-inline",children:[s.jsx(Ue,{displayPath:t,filePath:n,lineEnd:r,lineNumber:o}),e&&s.jsxs(s.Fragment,{children:[" ",e]})]})}function Vl({filePath:e,lineEnd:t,lineNumber:n,text:r}){return s.jsx(Ue,{displayPath:r,filePath:e,lineEnd:t,lineNumber:n,showLineSuffix:!1,viewMode:"range",showCopyButton:!1})}function Ky({input:e}){const t=ge(),n=oe(e.file_path,t==null?void 0:t.projectPath),r=qy(e);return s.jsxs("div",{className:"read-tool-use",children:[s.jsx("span",{className:"file-path",children:s.jsx(Ue,{displayPath:n,filePath:e.file_path,lineEnd:r.lineEnd,lineNumber:r.lineNumber})}),(e.offset!==void 0||e.limit!==void 0)&&s.jsxs("span",{className:"read-range",title:`offset ${e.offset??0}, limit ${e.limit??"∞"}`,children:[e.offset!==void 0&&` from line ${e.offset}`,e.limit!==void 0&&` (${e.limit} lines)`]})]})}function Xy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=Sr(e.filePath),i=m.useMemo(()=>{if(!o||r)return null;const C=mn(e.content,{baseFilePath:e.filePath});return C.changed?C.html:null},[e.content,e.filePath,o,r]),a=o?r??i:null,l=!!a,[c,d]=m.useState(!1),u=rt(t||c&&a?e.content:null),f=m.useMemo(()=>t?ka(e.content):null,[t,e.content]),h=!!(f!=null&&f.changed),[g,p]=m.useState(!1),{btnRef:y,handleClick:x}=Vd(g,()=>p(C=>!C)),b=e.content.length>0?e.content.split(`
|
|
95
|
-
`):[],_=e.content.length===0?s.jsx("div",{className:"file-viewer-empty-content",children:"No content read"}):t?s.jsxs("div",{className:"file-viewer-code file-viewer-code-highlighted",children:[s.jsx(ws,{html:t}),n&&s.jsx("div",{className:"file-viewer-truncated",children:"Content truncated for highlighting (showing first 2000 lines)"})]}):s.jsxs("div",{className:"file-content-with-lines",children:[s.jsx("div",{className:"line-numbers",children:b.map((C,w)=>s.jsx("div",{children:e.startLine+w},`ln-${w+1}`))}),s.jsx("pre",{className:"line-content",children:s.jsx("code",{children:e.content})})]}),N=c&&a?s.jsx(Pa,{html:a,sourcePath:e.filePath,density:Ea}):t?g&&f?Bi(f.html):_:s.jsx(Ye,{sourceText:e.content,renderMode:o?"rich":"math",sourceView:_,renderRenderedView:C=>Bi(C)}),v=l&&s.jsxs("div",{className:"markdown-view-toggle",children:[s.jsx("button",{type:"button",className:`toggle-btn ${c?"":"active"}`,onClick:()=>d(!1),children:"Source"}),s.jsx("button",{type:"button",className:`toggle-btn ${c?"active":""}`,onClick:()=>d(!0),children:"Preview"})]}),j=!l&&h;return s.jsxs("div",{className:"file-content-modal",ref:u,children:[v,j?s.jsxs("div",{className:"fixed-font-render-toggle",children:[N,s.jsx("button",{ref:y,type:"button",className:`fixed-font-render-toggle__button ${g?"is-rendered":""}`,onClick:x,"aria-label":g?"Show source":"Render math (LaTeX)",title:g?"Show source":"Render math (LaTeX)","aria-pressed":g,children:s.jsx(Ca,{})})]}):N]})}function Yy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=ge(),i=oe(e.filePath,o==null?void 0:o.projectPath),a=e.numLines>0,l=a&&(e.startLine>1||e.numLines<e.totalLines),c=mr(e);return s.jsxs("div",{className:"read-text-result read-text-inline",children:[s.jsx("div",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:i,filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber})}),l&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx(Vl,{filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber,text:`lines ${e.startLine}–${e.startLine+e.numLines-1}`})," ","of ",e.totalLines]}),!a&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),e.totalLines>0&&s.jsxs(s.Fragment,{children:[" of ",e.totalLines]})]}),s.jsx(Xy,{file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r})]})}function Jy(e,t){const n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)r[o]=n.charCodeAt(o);return new Blob([r],{type:t})}function Qy({file:e,filePath:t}){const{t:n}=Z(),r=e.originalSize?Math.round(e.originalSize/1024):0,{dimensions:o}=e,i=ge(),a=t?oe(t,i==null?void 0:i.projectPath):null,l=(o==null?void 0:o.originalWidth)!=null&&(o==null?void 0:o.originalHeight)!=null,{inlineMediaExpandedByDefault:c}=wr(),[d,u]=m.useState(null),f=d??c,[h,g]=m.useState(!1),p=Kt().transport,y=e.base64,x=m.useCallback(async()=>{if(y)return Jy(y,e.type);if(t)return _r(t,void 0,"inline",p);throw new Error("Read image result carries neither bytes nor a file path")},[e.type,t,y,p]),b=m.useMemo(()=>y?{buildApiPath:()=>"inline-read-image",fetchBlob:x}:void 0,[y,x]),_=y?`data:${e.type};base64,${y}`:null,{url:N,error:v}=$a(t??null,f&&!y,x),j=_??N,C=m.useCallback(()=>g(!0),[]),w=t?cn(t):"image",k=hs({fileName:w,filePath:t,loadBlob:x,onOpen:C});return s.jsxs("div",{className:"read-image-result",children:[s.jsxs("div",{className:"local-media-link-group",children:[s.jsx("button",{type:"button",className:"local-media-inline-toggle","aria-expanded":f,"aria-label":f?"Collapse image":"Expand image",title:f?"Collapse inline preview":"Expand inline preview",onClick:()=>u(!f),children:f?"-":"+"}),t&&a?s.jsx("span",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:a,filePath:t})}):s.jsx("span",{className:"local-media-type",children:"image"})]}),(l||r>0)&&s.jsxs("div",{className:"image-info",children:[l&&s.jsxs(s.Fragment,{children:[o.originalWidth,"x",o.originalHeight]}),l&&r>0&&" ",r>0&&s.jsxs(s.Fragment,{children:["(",r," ","kb)"]})]}),f&&(j?s.jsx("button",{type:"button",className:Vy.imagePreviewButton,"aria-label":`Open ${w}`,onClick:C,onContextMenu:k.handleContextMenu,children:s.jsx("img",{className:"read-image",src:j,alt:"File content",width:o==null?void 0:o.displayWidth,height:o==null?void 0:o.displayHeight})}):s.jsx("span",{className:"file-line-count-inline",children:n(v?"inlineImageUnavailable":"inlineImageLoading")})),h?s.jsx(qt,{path:y?w:t??w,filePath:t??null,mediaType:"image",mediaSource:b,onClose:()=>g(!1)}):null,k.contextMenuElement]})}function Zy(e){const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);const r=new Blob([n],{type:"application/pdf"}),o=URL.createObjectURL(r);window.open(o,"_blank")}function ej({file:e,filePath:t}){const n=e.originalSize?Math.round(e.originalSize/1024):0,r=t?cn(t):"document.pdf",o=ge(),i=t?oe(t,o==null?void 0:o.projectPath):null;if(t&&i)return s.jsx("div",{className:"read-pdf-result",children:s.jsxs(vt,{displayPath:i,filePath:t,children:[n>0&&s.jsxs("span",{className:"file-line-count-inline",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count-inline",children:"PDF"})]})});const a=e.base64;return a?s.jsx("div",{className:"read-pdf-result",children:s.jsxs("button",{type:"button",className:"file-link-button",onClick:()=>Zy(a),children:[r,n>0&&s.jsxs("span",{className:"file-line-count",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count",children:"Open PDF"})]})}):s.jsx("div",{className:"read-pdf-result",children:s.jsx("span",{className:"file-line-count-inline",children:"PDF"})})}function tj({input:e,result:t}){const{enabled:n,reportValidationError:r,isToolIgnored:o}=ve(),[i,a]=m.useState(null);m.useEffect(()=>{if(n&&t){const c=we("Read",t);!c.valid&&c.errors?(a(c.errors),r("Read",c.errors)):a(null)}},[n,t,r]);const l=n&&i&&!o("Read");return t!=null&&t.file?t.type==="pdf"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(ej,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):t.type==="image"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Qy,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):to(t.file)?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Yy,{file:t.file,highlightedHtml:t._highlightedContentHtml,highlightedTruncated:t._highlightedTruncated,renderedMarkdownHtml:t._renderedMarkdownHtml})]}):s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(zy,{filePath:Gy(t.file)||((e==null?void 0:e.file_path)??"")})]}):s.jsxs("div",{className:"read-error",children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),"Failed to read file"]})}function nj({input:e,result:t,isError:n}){const{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&t){const h=we("Read",t);!h.valid&&h.errors?(l(h.errors),o("Read",h.errors)):l(null)}},[r,t,o]);const c=r&&a&&!i("Read"),d=ge(),u=oe(e.file_path,d==null?void 0:d.projectPath);if(n)return s.jsxs("span",{children:[s.jsx(Ue,{displayPath:u,filePath:e.file_path}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!(t!=null&&t.file))return s.jsx("span",{children:s.jsx(Ue,{displayPath:u,filePath:e.file_path})});if(t.type==="pdf")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(PDF)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(t.type==="image")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(image)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!to(t.file))return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"unchanged"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});const f=t.file;return f.numLines<=0?s.jsxs(vt,{displayPath:u,filePath:f.filePath,children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]}):s.jsxs(vt,{displayPath:u,filePath:f.filePath,...mr(f),children:[s.jsx("span",{className:"file-line-count-inline",children:s.jsx(Vl,{filePath:f.filePath,text:`${f.numLines} lines`,...mr(f)})}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]})}const sj=de(fe.Read,{tool:"Read",renderToolUse(e,t){return s.jsx(Ky,{input:e})},renderToolResult(e,t,n,r){return s.jsx(tj,{input:r,result:e})},renderFailure(e){return s.jsx("div",{className:"read-error",children:e.content||"Failed to read file"})},getFailureSummary(e,t){return t?cn(t.file_path):"Error"},getUseSummary(e){return cn(e.file_path)},getResultSummary(e){const t=e;return t!=null&&t.file?t.type==="pdf"?"PDF":t.type==="image"?"Image":to(t.file)?t.file.numLines<=0?"0 lines":cn(t.file.filePath):"unchanged":"Reading..."},renderInteractiveSummary(e,t,n,r){return s.jsx(nj,{input:e,result:t,isError:n})}}),rj="_toolUse_yz7zv_1",oj="_name_yz7zv_8",ij="_args_yz7zv_17",aj="_result_yz7zv_22",lj="_label_yz7zv_29",cj="_error_yz7zv_33",it={toolUse:rj,name:oj,args:ij,result:aj,label:lj,error:cj};function no(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim();if(t)return t.length>120?`${t.slice(0,117)}...`:t}function Gl(e,t){return(e==null?void 0:e.commandName)??(t==null?void 0:t.skill)??"skill"}function dj({input:e}){const t=no(e.args);return s.jsxs("div",{className:it.toolUse,children:[s.jsx("code",{className:it.name,children:e.skill}),t?s.jsx("span",{className:it.args,children:t}):null]})}function uj({result:e,input:t}){const n=Gl(e,t);if(!e.success)return s.jsxs("div",{className:it.error,children:[n," did not load"]});const r=no(t==null?void 0:t.args);return s.jsxs("div",{className:it.result,children:[s.jsx("span",{className:it.label,children:"Loaded"}),s.jsx("code",{className:it.name,children:n}),r?s.jsx("span",{className:it.args,children:r}):null]})}const mj=de(fe.Skill,{tool:"Skill",displayName:"Skill",pendingDisplayName:"Loading skill",renderToolUse(e,t){return s.jsx(dj,{input:e})},renderToolResult(e,t,n,r){return s.jsx(uj,{result:e,input:r})},renderFailure(e){return s.jsx("div",{className:it.error,children:e.content||"Skill failed"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=no(e.args);return t?`${e.skill} ${t}`:e.skill},getResultSummary(e,t,n){return t?"Error":e.success?Gl(e,n):"Not loaded"}}),so=m.createContext(null);function Q_({children:e,agentContent:t,mergeLoadedAgentContent:n,toolUseToAgent:r,projectId:o}){const[i,a]=m.useState(new Set),l=m.useRef(new Set),c=m.useCallback(async(f,h,g)=>{if(l.current.has(g))return t[g]??{messages:[],status:"pending"};if(i.has(g))return new Promise(p=>{const y=setInterval(()=>{l.current.has(g)&&(clearInterval(y),p(t[g]??{messages:[],status:"pending"}))},100);setTimeout(()=>{clearInterval(y),p({messages:[],status:"pending"})},3e4)});a(p=>new Set(p).add(g));try{const p=await on.getAgentSession(f,h,g);return l.current.add(g),n(g,p),{messages:p.messages,status:p.status}}catch(p){return console.error(`Failed to load agent content for ${g}:`,p),{messages:[],status:"failed"}}finally{a(p=>{const y=new Set(p);return y.delete(g),y})}},[t,i,n]),d=m.useCallback(f=>i.has(f),[i]),u=m.useMemo(()=>({agentContent:t,toolUseToAgent:r,loadAgentContent:c,isLoading:d,projectId:o}),[t,r,c,d,o]);return s.jsx(so.Provider,{value:u,children:e})}function Di(e){return`${e.type}:${e.id}`}function zl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function fj(e,t){return zl(e.sourceMessages,t.sourceMessages)}function Un(e,t,n){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((r,o)=>{const i=t[o];return i!==void 0&&n(r,i)})}function hj(e,t){return e.id===t.id&&e.kind===t.kind&&e.slot===t.slot&&e.thinking===t.thinking&&e.status===t.status&&e.endedAtMs===t.endedAtMs}function Oi(e,t){return e.label===t.label&&e.detail===t.detail&&e.preview===t.preview}function $n(e,t){return Un(e,t,(n,r)=>n.text===r.text&&n.filePath===r.filePath)}function Ui(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return xs(e._projectPathLinks)}function pj(e,t){var n,r;if(e.type!==t.type||e.id!==t.id||e.isSubagent!==t.isSubagent||JSON.stringify(e.workflow)!==JSON.stringify(t.workflow)||!fj(e,t))return!1;switch(e.type){case"text":return t.type==="text"&&e.text===t.text&&e.isStreaming===t.isStreaming&&e.augmentHtml===t.augmentHtml&&$n(e.projectPathLinks,t.projectPathLinks);case"thinking":return t.type==="thinking"&&e.thinking===t.thinking&&e.signature===t.signature&&e.status===t.status;case"tool_call":return t.type==="tool_call"&&e.toolName===t.toolName&&e.status===t.status&&$n(Ui(e.toolInput),Ui(t.toolInput))&&$n((n=e.toolResult)==null?void 0:n.projectPathLinks,(r=t.toolResult)==null?void 0:r.projectPathLinks);case"user_prompt":return t.type==="user_prompt"&&e.content===t.content&&$n(e.projectPathLinks,t.projectPathLinks);case"session_setup":return t.type==="session_setup"&&e.title===t.title&&zl(e.prompts,t.prompts);case"transcript_display_object":return t.type==="transcript_display_object"&&e.object===t.object;case"system":return t.type==="system"&&e.subtype===t.subtype&&e.content===t.content&&e.status===t.status&&e.configChanged===t.configChanged;case"task_notification":return t.type==="task_notification"&&e.raw===t.raw;case"conversation_activity":return t.type==="conversation_activity"&&e.activityCount===t.activityCount&&e.active===t.active&&e.expanded===t.expanded&&e.hasFollowingConversationText===t.hasFollowingConversationText&&Un(e.thinkingPreviews,t.thinkingPreviews,hj)&&Un(e.recentActivities,t.recentActivities,Oi)&&Un(e.tooltipActivities,t.tooltipActivities,Oi)&&e.startedAtMs===t.startedAtMs&&e.endedAtMs===t.endedAtMs}}function gj(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;for(const r of e){const o=Di(r),i=n.get(o);i?i.push(r):n.set(o,[r])}return t.map(r=>{const o=n.get(Di(r));if(!o)return r;const i=o.findIndex(l=>pj(l,r));if(i===-1)return r;const[a]=o.splice(i,1);return a??r})}function Z_({messages:e,provider:t,markdownAugments:n,activeToolApproval:r,transcriptDisplayObjects:o=[],recoverUnanchoredBangCommands:i=!1,previousRenderItems:a=[],recentProjectPathLinksEnabled:l=!1,workflowTagsEnabled:c=!1,workflowSchemaFiles:d}){const u=Fr(e,{markdown:n,activeToolApproval:r,workflowTags:c,workflowSchemaFiles:d},l),f=t==="claude-gateway"?u.filter(g=>g.type!=="thinking"||g.thinking!=="Thinking..."):u,h=Qm(f,o,i);return gj(a,h)}function eN(e){const t=[];let n=[];for(const r of e)r.type==="transcript_display_object"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!1,isStandalone:!0,items:[r]})):r.type==="user_prompt"||r.type==="session_setup"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!0,items:[r]})):n.push(r);return n.length>0&&t.push({isUserPrompt:!1,items:n}),t}function xj(e,t){return e.isUserPrompt!==t.isUserPrompt||e.isStandalone!==t.isStandalone||e.items.length!==t.items.length?!1:e.items.every((n,r)=>n===t.items[r])}function Hi(e,t){const n=e.items[0];return n?`${e.isUserPrompt?"user":"assistant"}:${n.type}:${n.id}`:`empty:${t}`}function tN(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;return e.forEach((r,o)=>{const i=Hi(r,o),a=n.get(i);a?a.push(r):n.set(i,[r])}),t.map((r,o)=>{const i=n.get(Hi(r,o));if(!i)return r;const a=i.findIndex(c=>xj(c,r));if(a===-1)return r;const[l]=i.splice(a,1);return l??r})}function nN(e){let t=null;for(const n of e){const r=fs(n.sourceMessages);r!==null&&(t=t===null?r:Math.max(t,r))}return t}function sN(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&fs(n.sourceMessages)!==null)return n}return null}function rN(e,t){return e.isStandalone||!e.isUserPrompt?!0:!t||t.isUserPrompt||t.isStandalone===!0}function oN({asides:e=[],deferredMessages:t=[],displayRenderItems:n,pendingMessages:r=[],projectQueueMessages:o=[]}){let i=null;const a=l=>{l!==null&&(i=i===null?l:Math.max(i,l))};for(const l of n)a(fs(l.sourceMessages));for(const l of r)a(nn(l.timestamp));for(const l of t)a(nn(l.timestamp));for(const l of o)a(nn(l.timestamp));for(const l of e)a(nn(l.historyAt??l.updatedAt));return i}function xn(e){for(const t of e.sourceMessages){const n=t.rewoundGroupId;if(typeof n=="string"&&n)return n}}function iN(e,t){const n=t.expandedRewoundGroups,r=new Map;for(const a of e){const l=xn(a);if(!(!l||r.has(l)))for(const c of a.sourceMessages){const d=c.rewoundParentGroupId;if(typeof d=="string"&&d){r.set(l,d);break}}}const o=a=>{const l=new Set;let c=a;for(;c&&!l.has(c);){if(!(n!=null&&n.has(c)))return!1;l.add(c),c=r.get(c)}return!0},i=a=>{if(!t.thinkingItemsVisible&&a.type==="thinking")return!1;const l=xn(a);return l?a.type==="system"&&a.subtype==="rewound_group"?o(r.get(l)):o(l):!0};return e.every(i)?e:e.filter(i)}const yj=32;function jj(e,t=yj){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function bj(e,t,n={}){const{enabled:r=!0,identity:o}=n,i=m.useRef(!0),a=m.useRef(o),l=m.useCallback(()=>{const c=e.current;c&&(i.current=jj(c))},[e]);return m.useLayoutEffect(()=>{if(Object.is(a.current,o)||(a.current=o,i.current=!0),!r)return;const c=e.current;!c||!i.current||(c.scrollTop=c.scrollHeight)},[e,t,r,o]),{onScroll:l}}const ql=3e4;function vj(e,t,n,r=ql){return!e||t>=e.heightPx?{heightPx:t,shrankAtMs:null}:e.shrankAtMs===null?{heightPx:e.heightPx,shrankAtMs:n}:n-e.shrankAtMs>=r?{heightPx:t,shrankAtMs:null}:e}function wj(e,t,n=ql){return e.shrankAtMs===null?null:Math.max(0,e.shrankAtMs+n-t)}const _j=48,Nj=256,kj=544,Sj=288;function Wi(e,t,n){const r=Math.max(Nj,Math.min(kj,Math.ceil(n)+_j));return(e==null?void 0:e.id)===t&&e.targetWidthPx>=r?e:{id:t,targetWidthPx:r}}const Cj=5e3,Vi=1500;function Gi({active:e,hasFollowingConversationText:t,endedAtMs:n,shownSinceMs:r=null,nowMs:o,hideAfterMs:i=Cj}){if(e||!t)return null;const a=n===null?r:r===null?n:Math.max(n,r);if(a===null)return 0;const l=i-(o-a);return l>0?l:0}const Tj=2,Rj=1.5;function Pj({viewportHeightPx:e,trailingContentPx:t,contextReservePx:n,previousTopPx:r,previousChromePx:o,minContentHeightPx:i}){const a=Kl(e,t+n)-r-o;return a>=(i??n)?a:null}function Kl(e,t){return Math.max(0,e-t)}const Ej=2,Ij=1,Mj=4;function $j(e,t,n=Ej){return e===null||t>e?t:e-t<=n?e:t}function Lj(e,t,n=Ij,r=Mj){return e<=n?!0:e>r?!1:t}function Aj(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}`:`${r}s`}function Fj({object:e,targetHref:t,onCancel:n,onToggleAutoOpen:r,onFollow:o}){const{t:i}=Z(),[a,l]=m.useState(()=>Date.now());if(m.useEffect(()=>{if(e.status!=="generating")return;const u=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(u)},[e.status]),e.status==="generating")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-generating",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-spinner","aria-hidden":"true"}),s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryProgress")}),s.jsx("span",{className:"fork-summary-display-object-elapsed",children:Aj(a-Date.parse(e.createdAt))}),s.jsxs("label",{className:"fork-summary-display-object-autoopen",children:[s.jsx("input",{type:"checkbox",checked:e.autoOpenWhenReady??!1,onChange:u=>r(u.target.checked)}),i("forkSummaryAutoOpenToggle")]}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryCancelInFlight")})]});if(e.status==="error")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-error",role:"alert",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:e.error?`${i("forkSummaryFailed")}: ${e.error}`:i("forkSummaryFailed")}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryDismiss")})]});const c=e.title??i("forkSummaryReadyFallbackTitle"),d=e.clickedAt?i("forkSummaryClicked"):e.openedAt?i("forkSummaryOpenedMarker"):void 0;return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-ready",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryReadyPrefix")}),s.jsxs("a",{className:"fork-summary-display-object-link",href:t??"#",target:"_blank",rel:"noopener noreferrer",onClick:o,title:c,children:[c," ↗"]}),d&&s.jsx("span",{className:"fork-summary-display-object-state",children:d})]})}function Bj(e){if(typeof e=="string")return`s:${e.length}:${e.slice(0,80)}`;const t=e.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
94
|
+
`),l=st(a);return s.jsxs(s.Fragment,{children:[s.jsx("pre",{ref:l,className:`${Y.content} code-block`,children:s.jsx("code",{children:a})}),o&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${r.length} lines`})]})}function Ny({input:e,result:t,isError:n,projectPath:r}){const o=us(),i=m.useMemo(()=>n||(t==null?void 0:t.mode)!=="content"?[]:t.matches??[],[n,t]),a=Math.max(0,o-1),l=i.slice(0,a);if(l.length===0)return null;const c=Ol(i),d=Math.max(0,i.length-l.length);return s.jsxs("div",{className:Y.collapsedPreview,children:[l.map((u,f)=>s.jsxs("div",{className:Y.previewMatch,children:[c&&s.jsx("span",{className:Y.previewFile,title:oe(u.filePath,r),children:eo(oe(u.filePath,r))}),s.jsx("span",{className:Y.previewLine,children:u.columnNumber?`${u.lineNumber}:${u.columnNumber}`:u.lineNumber}),s.jsx(ky,{match:u,pattern:e==null?void 0:e.pattern})]},`${u.filePath}:${u.lineNumber}:${u.columnNumber??""}:${f}`)),d>0&&s.jsxs("div",{className:Y.previewMore,children:["+",d," ",d===1?"match":"matches"]})]})}function ky({match:e,pattern:t}){const n=st(e.text);return s.jsx("span",{ref:n,className:Y.previewText,children:Bl(e.text,e.ranges,t)})}function Sy({input:e,result:t,projectPath:n}){const[r,o]=m.useState(!1),{enabled:i,reportValidationError:a,isToolIgnored:l}=ve(),[c,d]=m.useState(null);m.useEffect(()=>{if(i&&t){const x=we("Grep",t);!x.valid&&x.errors?(d(x.errors),a("Grep",x.errors)):d(null)}},[i,t,a]);const u=i&&c&&!l("Grep");if(!t)return s.jsx("div",{className:Y.empty,children:"No results"});const{mode:f,filenames:h,numFiles:g,content:p,appliedLimit:y}=t;if(f==="count")return s.jsxs("div",{className:Y.result,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),s.jsxs("div",{className:Y.countSummary,children:[g," ",g===1?"file":"files"," matched"]})]});if(f==="content"&&p){const x=t.matches??[],b=x.length||Fl(p),_=`${b} ${b===1?"match":"matches"}`;return s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsx(Dl,{label:_,matches:x,pattern:e==null?void 0:e.pattern,projectPath:n}),y&&s.jsxs("span",{className:"badge badge-info",children:["limit: ",y]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(_y,{content:p,isExpanded:r,setIsExpanded:o})]})}return!h||h.length===0?s.jsxs("div",{className:Y.empty,children:[u&&c&&s.jsx(q,{toolName:"Grep",errors:c}),"No matches found"]}):s.jsxs("div",{className:Y.result,children:[s.jsxs("div",{className:Y.header,children:[s.jsxs("span",{className:Y.count,children:[g," files"]}),u&&c&&s.jsx(q,{toolName:"Grep",errors:c})]}),s.jsx(wy,{filenames:h,isExpanded:r,projectPath:n,setIsExpanded:o})]})}function Ul(e,t){if(e.path){const n=oe(e.path,t);return{kind:"path",value:e.path,label:eo(n)}}return e.glob?{kind:"glob",value:e.glob,label:e.glob}:null}function Hl(e,t){const n=Ul(e,t);if(!n)return e.pattern;const r=n.kind==="path"?oe(n.value,t):n.value;return`${e.pattern} in ${r}`}function Cy(e,t,n){if(t<=0)return"";if(n(e)<=t)return e;if(n(Os)>t)return"";let r=0,o=e.length;for(;r<o;){const i=Math.ceil((r+o)/2),a=`${e.slice(0,i)}${Os}`;n(a)<=t?r=i:o=i-1}return`${e.slice(0,r)}${Os}`}function Ty({expanded:e,input:t,onToggle:n,projectPath:r}){const o=Hl(t,r),i=Ul(t,r),a=(i==null?void 0:i.value)??"",l=m.useRef(null),c=m.useRef(null),d=m.useRef(null),[u,f]=m.useState(t.pattern);m.useLayoutEffect(()=>{const p=()=>{var C;if(e){f(t.pattern);return}const x=l.current,b=d.current;if(!x||!b){f(t.pattern);return}const _=x.getBoundingClientRect().width;if(_<=0){f(t.pattern);return}const N=((C=c.current)==null?void 0:C.getBoundingClientRect().width)??0,v=Math.max(0,_-N-(N>0?xy:0)),j=w=>(b.textContent=w,b.getBoundingClientRect().width);f(Cy(t.pattern,v,j))};if(p(),typeof ResizeObserver>"u")return window.addEventListener("resize",p),()=>window.removeEventListener("resize",p);const y=new ResizeObserver(p);return l.current&&y.observe(l.current),c.current&&y.observe(c.current),()=>y.disconnect()},[e,t.pattern,a]);const h=`${Y.summaryPatternClip}${n?` ${Y.summaryPatternAction}`:""}`,g=n?s.jsx("button",{type:"button",className:h,title:o,"aria-label":e?"Collapse grep pattern":"Show full grep pattern","aria-expanded":e,onClick:p=>{p.preventDefault(),p.stopPropagation(),n()},children:u}):s.jsx("span",{className:h,title:o,children:u});return s.jsxs("span",{className:`${Y.summaryPattern}${e?" is-expanded":""}`,children:[s.jsxs("span",{className:Y.summaryPatternRow,ref:l,children:[g,i&&s.jsxs("span",{className:Y.summaryScope,ref:c,children:[s.jsx("span",{className:Y.summaryScopePrefix,children:"in"}),i.kind==="path"?s.jsx(Ue,{displayPath:i.label,filePath:i.value,showLineSuffix:!1}):s.jsx("span",{className:Y.summaryScopeText,title:i.value,children:i.label})]})]}),s.jsx("span",{className:Y.summaryPatternMeasure,ref:d}),e&&s.jsx("span",{className:Y.summaryPatternFull,children:o})]})}function Wl(e){if(e.mode==="content"){const t=e.matches??[],n=t.length||Fl(e.content);return{matches:t,text:`${n} ${n===1?"match":"matches"}`}}return e.numFiles===0?{matches:[],text:"0 matches"}:{matches:[],text:e.numFiles!==void 0?`${e.numFiles} ${e.numFiles===1?"file":"files"}`:"Results"}}function Ry({input:e,result:t,isError:n,projectPath:r,summaryExpanded:o,toggleSummaryExpanded:i}){if(n||!t)return null;const a=Wl(t);return s.jsxs("span",{className:Y.inlineSummary,children:[s.jsx(Ty,{expanded:o??!1,input:e,onToggle:i,projectPath:r}),s.jsx("span",{className:Y.summaryArrow,"aria-hidden":"true",children:"→"}),s.jsx(Dl,{label:a.text,matches:a.matches,pattern:e.pattern,projectPath:r})]})}const Py=de(fe.Grep,{tool:"Grep",displayName:"Grep",renderToolUse(e,t){return s.jsx(vy,{input:e,projectPath:t.projectPath})},renderToolResult(e,t,n,r){return s.jsx(Sy,{input:r,result:e,projectPath:n.projectPath})},renderFailure(e){return s.jsx("div",{className:Y.error,children:e.content||"Search failed"})},getFailureSummary(){return"Error"},getUseSummary(e,t){return Hl(e,t==null?void 0:t.projectPath)},getResultSummary(e){const t=e;return t?Wl(t).text:"Results"},renderInteractiveSummary(e,t,n,r){return s.jsx(Ry,{input:e,result:t,isError:n,projectPath:r.projectPath,summaryExpanded:r.summaryExpanded,toggleSummaryExpanded:r.toggleSummaryExpanded})},renderCollapsedPreview(e,t,n,r){return s.jsx(Ny,{input:e,result:t,isError:n,projectPath:r.projectPath})}}),Ey="_toolUse_1vtak_1",Iy="_label_1vtak_7",My="_shellId_1vtak_11",$y="_result_1vtak_20",Ly="_message_1vtak_26",Ay="_error_1vtak_30",Fy="_empty_1vtak_37",ut={toolUse:Ey,label:Iy,shellId:My,result:$y,message:Ly,error:Ay,empty:Fy};function By({input:e}){return s.jsxs("div",{className:ut.toolUse,children:[s.jsx("span",{className:ut.label,children:"Killing shell"}),s.jsx("code",{className:ut.shellId,children:e.shell_id})]})}function Dy({result:e}){const{enabled:t,reportValidationError:n,isToolIgnored:r}=ve(),[o,i]=m.useState(null);m.useEffect(()=>{if(t&&e){const l=we("KillShell",e);!l.valid&&l.errors?(i(l.errors),n("KillShell",l.errors)):i(null)}},[t,e,n]);const a=t&&o&&!r("KillShell");return e?s.jsxs("div",{className:ut.result,children:[a&&o&&s.jsx(q,{toolName:"KillShell",errors:o}),s.jsx("span",{className:ut.message,children:e.message}),e.shell_id&&s.jsx("code",{className:ut.shellId,children:e.shell_id})]}):s.jsx("div",{className:ut.empty,children:"No result"})}const Oy=de(fe.KillShell,{tool:"KillShell",renderToolUse(e,t){return s.jsx(By,{input:e})},renderToolResult(e,t,n){return s.jsx(Dy,{result:e})},renderFailure(e){return s.jsx("div",{className:ut.error,children:e.content||"Failed to kill shell"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.shell_id},getResultSummary(e){const t=e;return(t==null?void 0:t.message)||"Killed"}}),Uy="_container_blm34_7",Hy={container:Uy};function ws({html:e,className:t}){return s.jsx("div",{className:`shiki-container ${Hy.container}${t?` ${t}`:""}`,dangerouslySetInnerHTML:{__html:Wd(e)??""}})}const Wy="_imagePreviewButton_1dcmz_1",Vy={imagePreviewButton:Wy};function cn(e){return tt(e)}function to(e){return"content"in e&&typeof e.content=="string"}function Gy(e){return"filePath"in e?e.filePath??"":""}function zy({filePath:e}){const t=ge(),n=oe(e,t==null?void 0:t.projectPath);return s.jsx("div",{className:"read-text-result read-text-inline",children:s.jsx(vt,{displayPath:n,filePath:e,children:s.jsx("span",{className:"file-line-count-inline",children:"unchanged"})})})}function mr(e){if(e.numLines<=0)return{};if(!(e.startLine>1||e.numLines<e.totalLines))return{};const n=e.startLine+Math.max(1,e.numLines)-1;return{lineEnd:n>e.startLine?n:void 0,lineNumber:e.startLine}}function qy(e){if(e.offset===void 0)return{};const t=e.limit!==void 0?e.offset+Math.max(1,e.limit)-1:void 0;return{lineEnd:t!==void 0&&t>e.offset?t:void 0,lineNumber:e.offset}}function Bi(e){return s.jsx("div",{className:"file-viewer-code fixed-font-rendered-panel",children:s.jsx("div",{className:"fixed-font-rendered__content",dangerouslySetInnerHTML:{__html:e}})})}function vt({children:e,displayPath:t,filePath:n,lineEnd:r,lineNumber:o}){return s.jsxs("span",{className:"file-link-inline",children:[s.jsx(Ue,{displayPath:t,filePath:n,lineEnd:r,lineNumber:o}),e&&s.jsxs(s.Fragment,{children:[" ",e]})]})}function Vl({filePath:e,lineEnd:t,lineNumber:n,text:r}){return s.jsx(Ue,{displayPath:r,filePath:e,lineEnd:t,lineNumber:n,showLineSuffix:!1,viewMode:"range",showCopyButton:!1})}function Ky({input:e}){const t=ge(),n=oe(e.file_path,t==null?void 0:t.projectPath),r=qy(e);return s.jsxs("div",{className:"read-tool-use",children:[s.jsx("span",{className:"file-path",children:s.jsx(Ue,{displayPath:n,filePath:e.file_path,lineEnd:r.lineEnd,lineNumber:r.lineNumber})}),(e.offset!==void 0||e.limit!==void 0)&&s.jsxs("span",{className:"read-range",title:`offset ${e.offset??0}, limit ${e.limit??"∞"}`,children:[e.offset!==void 0&&` from line ${e.offset}`,e.limit!==void 0&&` (${e.limit} lines)`]})]})}function Xy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=Sr(e.filePath),i=m.useMemo(()=>{if(!o||r)return null;const C=mn(e.content,{baseFilePath:e.filePath});return C.changed?C.html:null},[e.content,e.filePath,o,r]),a=o?r??i:null,l=!!a,[c,d]=m.useState(!1),u=st(t||c&&a?e.content:null),f=m.useMemo(()=>t?ka(e.content):null,[t,e.content]),h=!!(f!=null&&f.changed),[g,p]=m.useState(!1),{btnRef:y,handleClick:x}=Vd(g,()=>p(C=>!C)),b=e.content.length>0?e.content.split(`
|
|
95
|
+
`):[],_=e.content.length===0?s.jsx("div",{className:"file-viewer-empty-content",children:"No content read"}):t?s.jsxs("div",{className:"file-viewer-code file-viewer-code-highlighted",children:[s.jsx(ws,{html:t}),n&&s.jsx("div",{className:"file-viewer-truncated",children:"Content truncated for highlighting (showing first 2000 lines)"})]}):s.jsxs("div",{className:"file-content-with-lines",children:[s.jsx("div",{className:"line-numbers",children:b.map((C,w)=>s.jsx("div",{children:e.startLine+w},`ln-${w+1}`))}),s.jsx("pre",{className:"line-content",children:s.jsx("code",{children:e.content})})]}),N=c&&a?s.jsx(Pa,{html:a,sourcePath:e.filePath,density:Ea}):t?g&&f?Bi(f.html):_:s.jsx(Ye,{sourceText:e.content,renderMode:o?"rich":"math",sourceView:_,renderRenderedView:C=>Bi(C)}),v=l&&s.jsxs("div",{className:"markdown-view-toggle",children:[s.jsx("button",{type:"button",className:`toggle-btn ${c?"":"active"}`,onClick:()=>d(!1),children:"Source"}),s.jsx("button",{type:"button",className:`toggle-btn ${c?"active":""}`,onClick:()=>d(!0),children:"Preview"})]}),j=!l&&h;return s.jsxs("div",{className:"file-content-modal",ref:u,children:[v,j?s.jsxs("div",{className:"fixed-font-render-toggle",children:[N,s.jsx("button",{ref:y,type:"button",className:`fixed-font-render-toggle__button ${g?"is-rendered":""}`,onClick:x,"aria-label":g?"Show source":"Render math (LaTeX)",title:g?"Show source":"Render math (LaTeX)","aria-pressed":g,children:s.jsx(Ca,{})})]}):N]})}function Yy({file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r}){const o=ge(),i=oe(e.filePath,o==null?void 0:o.projectPath),a=e.numLines>0,l=a&&(e.startLine>1||e.numLines<e.totalLines),c=mr(e);return s.jsxs("div",{className:"read-text-result read-text-inline",children:[s.jsx("div",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:i,filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber})}),l&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx(Vl,{filePath:e.filePath,lineEnd:c.lineEnd,lineNumber:c.lineNumber,text:`lines ${e.startLine}–${e.startLine+e.numLines-1}`})," ","of ",e.totalLines]}),!a&&s.jsxs("div",{className:"file-range-inline",children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),e.totalLines>0&&s.jsxs(s.Fragment,{children:[" of ",e.totalLines]})]}),s.jsx(Xy,{file:e,highlightedHtml:t,highlightedTruncated:n,renderedMarkdownHtml:r})]})}function Jy(e,t){const n=atob(e),r=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)r[o]=n.charCodeAt(o);return new Blob([r],{type:t})}function Qy({file:e,filePath:t}){const{t:n}=Z(),r=e.originalSize?Math.round(e.originalSize/1024):0,{dimensions:o}=e,i=ge(),a=t?oe(t,i==null?void 0:i.projectPath):null,l=(o==null?void 0:o.originalWidth)!=null&&(o==null?void 0:o.originalHeight)!=null,{inlineMediaExpandedByDefault:c}=wr(),[d,u]=m.useState(null),f=d??c,[h,g]=m.useState(!1),p=Kt().transport,y=e.base64,x=m.useCallback(async()=>{if(y)return Jy(y,e.type);if(t)return _r(t,void 0,"inline",p);throw new Error("Read image result carries neither bytes nor a file path")},[e.type,t,y,p]),b=m.useMemo(()=>y?{buildApiPath:()=>"inline-read-image",fetchBlob:x}:void 0,[y,x]),_=y?`data:${e.type};base64,${y}`:null,{url:N,error:v}=$a(t??null,f&&!y,x),j=_??N,C=m.useCallback(()=>g(!0),[]),w=t?cn(t):"image",k=hs({fileName:w,filePath:t,loadBlob:x,onOpen:C});return s.jsxs("div",{className:"read-image-result",children:[s.jsxs("div",{className:"local-media-link-group",children:[s.jsx("button",{type:"button",className:"local-media-inline-toggle","aria-expanded":f,"aria-label":f?"Collapse image":"Expand image",title:f?"Collapse inline preview":"Expand inline preview",onClick:()=>u(!f),children:f?"-":"+"}),t&&a?s.jsx("span",{className:"file-range-inline",children:s.jsx(Ue,{displayPath:a,filePath:t})}):s.jsx("span",{className:"local-media-type",children:"image"})]}),(l||r>0)&&s.jsxs("div",{className:"image-info",children:[l&&s.jsxs(s.Fragment,{children:[o.originalWidth,"x",o.originalHeight]}),l&&r>0&&" ",r>0&&s.jsxs(s.Fragment,{children:["(",r," ","kb)"]})]}),f&&(j?s.jsx("button",{type:"button",className:Vy.imagePreviewButton,"aria-label":`Open ${w}`,onClick:C,onContextMenu:k.handleContextMenu,children:s.jsx("img",{className:"read-image",src:j,alt:"File content",width:o==null?void 0:o.displayWidth,height:o==null?void 0:o.displayHeight})}):s.jsx("span",{className:"file-line-count-inline",children:n(v?"inlineImageUnavailable":"inlineImageLoading")})),h?s.jsx(qt,{path:y?w:t??w,filePath:t??null,mediaType:"image",mediaSource:b,onClose:()=>g(!1)}):null,k.contextMenuElement]})}function Zy(e){const t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);const r=new Blob([n],{type:"application/pdf"}),o=URL.createObjectURL(r);window.open(o,"_blank")}function ej({file:e,filePath:t}){const n=e.originalSize?Math.round(e.originalSize/1024):0,r=t?cn(t):"document.pdf",o=ge(),i=t?oe(t,o==null?void 0:o.projectPath):null;if(t&&i)return s.jsx("div",{className:"read-pdf-result",children:s.jsxs(vt,{displayPath:i,filePath:t,children:[n>0&&s.jsxs("span",{className:"file-line-count-inline",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count-inline",children:"PDF"})]})});const a=e.base64;return a?s.jsx("div",{className:"read-pdf-result",children:s.jsxs("button",{type:"button",className:"file-link-button",onClick:()=>Zy(a),children:[r,n>0&&s.jsxs("span",{className:"file-line-count",children:["(",n," ","kb)"]}),s.jsx("span",{className:"file-line-count",children:"Open PDF"})]})}):s.jsx("div",{className:"read-pdf-result",children:s.jsx("span",{className:"file-line-count-inline",children:"PDF"})})}function tj({input:e,result:t}){const{enabled:n,reportValidationError:r,isToolIgnored:o}=ve(),[i,a]=m.useState(null);m.useEffect(()=>{if(n&&t){const c=we("Read",t);!c.valid&&c.errors?(a(c.errors),r("Read",c.errors)):a(null)}},[n,t,r]);const l=n&&i&&!o("Read");return t!=null&&t.file?t.type==="pdf"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(ej,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):t.type==="image"?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Qy,{file:t.file,filePath:(e==null?void 0:e.file_path)??t.file.filePath})]}):to(t.file)?s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(Yy,{file:t.file,highlightedHtml:t._highlightedContentHtml,highlightedTruncated:t._highlightedTruncated,renderedMarkdownHtml:t._renderedMarkdownHtml})]}):s.jsxs(s.Fragment,{children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),s.jsx(zy,{filePath:Gy(t.file)||((e==null?void 0:e.file_path)??"")})]}):s.jsxs("div",{className:"read-error",children:[l&&i&&s.jsx(q,{toolName:"Read",errors:i}),"Failed to read file"]})}function nj({input:e,result:t,isError:n}){const{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&t){const h=we("Read",t);!h.valid&&h.errors?(l(h.errors),o("Read",h.errors)):l(null)}},[r,t,o]);const c=r&&a&&!i("Read"),d=ge(),u=oe(e.file_path,d==null?void 0:d.projectPath);if(n)return s.jsxs("span",{children:[s.jsx(Ue,{displayPath:u,filePath:e.file_path}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!(t!=null&&t.file))return s.jsx("span",{children:s.jsx(Ue,{displayPath:u,filePath:e.file_path})});if(t.type==="pdf")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(PDF)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(t.type==="image")return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"(image)"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});if(!to(t.file))return s.jsxs(vt,{displayPath:u,filePath:e.file_path,children:[s.jsx("span",{className:"file-line-count-inline",children:"unchanged"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]});const f=t.file;return f.numLines<=0?s.jsxs(vt,{displayPath:u,filePath:f.filePath,children:[s.jsx("span",{className:"file-line-count-inline",children:"0 lines"}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]}):s.jsxs(vt,{displayPath:u,filePath:f.filePath,...mr(f),children:[s.jsx("span",{className:"file-line-count-inline",children:s.jsx(Vl,{filePath:f.filePath,text:`${f.numLines} lines`,...mr(f)})}),c&&a&&s.jsx(q,{toolName:"Read",errors:a})]})}const sj=de(fe.Read,{tool:"Read",renderToolUse(e,t){return s.jsx(Ky,{input:e})},renderToolResult(e,t,n,r){return s.jsx(tj,{input:r,result:e})},renderFailure(e){return s.jsx("div",{className:"read-error",children:e.content||"Failed to read file"})},getFailureSummary(e,t){return t?cn(t.file_path):"Error"},getUseSummary(e){return cn(e.file_path)},getResultSummary(e){const t=e;return t!=null&&t.file?t.type==="pdf"?"PDF":t.type==="image"?"Image":to(t.file)?t.file.numLines<=0?"0 lines":cn(t.file.filePath):"unchanged":"Reading..."},renderInteractiveSummary(e,t,n,r){return s.jsx(nj,{input:e,result:t,isError:n})}}),rj="_toolUse_yz7zv_1",oj="_name_yz7zv_8",ij="_args_yz7zv_17",aj="_result_yz7zv_22",lj="_label_yz7zv_29",cj="_error_yz7zv_33",ot={toolUse:rj,name:oj,args:ij,result:aj,label:lj,error:cj};function no(e){const t=e==null?void 0:e.replace(/\s+/g," ").trim();if(t)return t.length>120?`${t.slice(0,117)}...`:t}function Gl(e,t){return(e==null?void 0:e.commandName)??(t==null?void 0:t.skill)??"skill"}function dj({input:e}){const t=no(e.args);return s.jsxs("div",{className:ot.toolUse,children:[s.jsx("code",{className:ot.name,children:e.skill}),t?s.jsx("span",{className:ot.args,children:t}):null]})}function uj({result:e,input:t}){const n=Gl(e,t);if(!e.success)return s.jsxs("div",{className:ot.error,children:[n," did not load"]});const r=no(t==null?void 0:t.args);return s.jsxs("div",{className:ot.result,children:[s.jsx("span",{className:ot.label,children:"Loaded"}),s.jsx("code",{className:ot.name,children:n}),r?s.jsx("span",{className:ot.args,children:r}):null]})}const mj=de(fe.Skill,{tool:"Skill",displayName:"Skill",pendingDisplayName:"Loading skill",renderToolUse(e,t){return s.jsx(dj,{input:e})},renderToolResult(e,t,n,r){return s.jsx(uj,{result:e,input:r})},renderFailure(e){return s.jsx("div",{className:ot.error,children:e.content||"Skill failed"})},getFailureSummary(){return"Error"},getUseSummary(e){const t=no(e.args);return t?`${e.skill} ${t}`:e.skill},getResultSummary(e,t,n){return t?"Error":e.success?Gl(e,n):"Not loaded"}}),so=m.createContext(null);function Q_({children:e,agentContent:t,mergeLoadedAgentContent:n,toolUseToAgent:r,projectId:o}){const[i,a]=m.useState(new Set),l=m.useRef(new Set),c=m.useCallback(async(f,h,g)=>{if(l.current.has(g))return t[g]??{messages:[],status:"pending"};if(i.has(g))return new Promise(p=>{const y=setInterval(()=>{l.current.has(g)&&(clearInterval(y),p(t[g]??{messages:[],status:"pending"}))},100);setTimeout(()=>{clearInterval(y),p({messages:[],status:"pending"})},3e4)});a(p=>new Set(p).add(g));try{const p=await on.getAgentSession(f,h,g);return l.current.add(g),n(g,p),{messages:p.messages,status:p.status}}catch(p){return console.error(`Failed to load agent content for ${g}:`,p),{messages:[],status:"failed"}}finally{a(p=>{const y=new Set(p);return y.delete(g),y})}},[t,i,n]),d=m.useCallback(f=>i.has(f),[i]),u=m.useMemo(()=>({agentContent:t,toolUseToAgent:r,loadAgentContent:c,isLoading:d,projectId:o}),[t,r,c,d,o]);return s.jsx(so.Provider,{value:u,children:e})}function Di(e){return`${e.type}:${e.id}`}function zl(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function fj(e,t){return zl(e.sourceMessages,t.sourceMessages)}function Un(e,t,n){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((r,o)=>{const i=t[o];return i!==void 0&&n(r,i)})}function hj(e,t){return e.id===t.id&&e.kind===t.kind&&e.slot===t.slot&&e.thinking===t.thinking&&e.status===t.status&&e.endedAtMs===t.endedAtMs}function Oi(e,t){return e.label===t.label&&e.detail===t.detail&&e.preview===t.preview}function $n(e,t){return Un(e,t,(n,r)=>n.text===r.text&&n.filePath===r.filePath)}function Ui(e){if(!(!e||typeof e!="object"||Array.isArray(e)))return xs(e._projectPathLinks)}function pj(e,t){var n,r;if(e.type!==t.type||e.id!==t.id||e.isSubagent!==t.isSubagent||JSON.stringify(e.workflow)!==JSON.stringify(t.workflow)||!fj(e,t))return!1;switch(e.type){case"text":return t.type==="text"&&e.text===t.text&&e.isStreaming===t.isStreaming&&e.augmentHtml===t.augmentHtml&&$n(e.projectPathLinks,t.projectPathLinks);case"thinking":return t.type==="thinking"&&e.thinking===t.thinking&&e.signature===t.signature&&e.status===t.status;case"tool_call":return t.type==="tool_call"&&e.toolName===t.toolName&&e.status===t.status&&$n(Ui(e.toolInput),Ui(t.toolInput))&&$n((n=e.toolResult)==null?void 0:n.projectPathLinks,(r=t.toolResult)==null?void 0:r.projectPathLinks);case"user_prompt":return t.type==="user_prompt"&&e.content===t.content&&$n(e.projectPathLinks,t.projectPathLinks);case"session_setup":return t.type==="session_setup"&&e.title===t.title&&zl(e.prompts,t.prompts);case"transcript_display_object":return t.type==="transcript_display_object"&&e.object===t.object;case"system":return t.type==="system"&&e.subtype===t.subtype&&e.content===t.content&&e.status===t.status&&e.configChanged===t.configChanged;case"task_notification":return t.type==="task_notification"&&e.raw===t.raw;case"conversation_activity":return t.type==="conversation_activity"&&e.activityCount===t.activityCount&&e.active===t.active&&e.expanded===t.expanded&&e.hasFollowingConversationText===t.hasFollowingConversationText&&Un(e.thinkingPreviews,t.thinkingPreviews,hj)&&Un(e.recentActivities,t.recentActivities,Oi)&&Un(e.tooltipActivities,t.tooltipActivities,Oi)&&e.startedAtMs===t.startedAtMs&&e.endedAtMs===t.endedAtMs}}function gj(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;for(const r of e){const o=Di(r),i=n.get(o);i?i.push(r):n.set(o,[r])}return t.map(r=>{const o=n.get(Di(r));if(!o)return r;const i=o.findIndex(l=>pj(l,r));if(i===-1)return r;const[a]=o.splice(i,1);return a??r})}function Z_({messages:e,provider:t,markdownAugments:n,activeToolApproval:r,transcriptDisplayObjects:o=[],recoverUnanchoredBangCommands:i=!1,previousRenderItems:a=[],recentProjectPathLinksEnabled:l=!1,workflowTagsEnabled:c=!1,workflowSchemaFiles:d}){const u=Fr(e,{markdown:n,activeToolApproval:r,workflowTags:c,workflowSchemaFiles:d},l),f=t==="claude-gateway"?u.filter(g=>g.type!=="thinking"||g.thinking!=="Thinking..."):u,h=Qm(f,o,i);return gj(a,h)}function eN(e){const t=[];let n=[];for(const r of e)r.type==="transcript_display_object"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!1,isStandalone:!0,items:[r]})):r.type==="user_prompt"||r.type==="session_setup"?(n.length>0&&(t.push({isUserPrompt:!1,items:n}),n=[]),t.push({isUserPrompt:!0,items:[r]})):n.push(r);return n.length>0&&t.push({isUserPrompt:!1,items:n}),t}function xj(e,t){return e.isUserPrompt!==t.isUserPrompt||e.isStandalone!==t.isStandalone||e.items.length!==t.items.length?!1:e.items.every((n,r)=>n===t.items[r])}function Hi(e,t){const n=e.items[0];return n?`${e.isUserPrompt?"user":"assistant"}:${n.type}:${n.id}`:`empty:${t}`}function tN(e,t){if(e.length===0||t.length===0)return[...t];const n=new Map;return e.forEach((r,o)=>{const i=Hi(r,o),a=n.get(i);a?a.push(r):n.set(i,[r])}),t.map((r,o)=>{const i=n.get(Hi(r,o));if(!i)return r;const a=i.findIndex(c=>xj(c,r));if(a===-1)return r;const[l]=i.splice(a,1);return l??r})}function nN(e){let t=null;for(const n of e){const r=fs(n.sourceMessages);r!==null&&(t=t===null?r:Math.max(t,r))}return t}function sN(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n&&fs(n.sourceMessages)!==null)return n}return null}function rN(e,t){return e.isStandalone||!e.isUserPrompt?!0:!t||t.isUserPrompt||t.isStandalone===!0}function oN({asides:e=[],deferredMessages:t=[],displayRenderItems:n,pendingMessages:r=[],projectQueueMessages:o=[]}){let i=null;const a=l=>{l!==null&&(i=i===null?l:Math.max(i,l))};for(const l of n)a(fs(l.sourceMessages));for(const l of r)a(nn(l.timestamp));for(const l of t)a(nn(l.timestamp));for(const l of o)a(nn(l.timestamp));for(const l of e)a(nn(l.historyAt??l.updatedAt));return i}function xn(e){for(const t of e.sourceMessages){const n=t.rewoundGroupId;if(typeof n=="string"&&n)return n}}function iN(e,t){const n=t.expandedRewoundGroups,r=new Map;for(const a of e){const l=xn(a);if(!(!l||r.has(l)))for(const c of a.sourceMessages){const d=c.rewoundParentGroupId;if(typeof d=="string"&&d){r.set(l,d);break}}}const o=a=>{const l=new Set;let c=a;for(;c&&!l.has(c);){if(!(n!=null&&n.has(c)))return!1;l.add(c),c=r.get(c)}return!0},i=a=>{if(!t.thinkingItemsVisible&&a.type==="thinking")return!1;const l=xn(a);return l?a.type==="system"&&a.subtype==="rewound_group"?o(r.get(l)):o(l):!0};return e.every(i)?e:e.filter(i)}const yj=32;function jj(e,t=yj){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}function bj(e,t,n={}){const{enabled:r=!0,identity:o}=n,i=m.useRef(!0),a=m.useRef(o),l=m.useCallback(()=>{const c=e.current;c&&(i.current=jj(c))},[e]);return m.useLayoutEffect(()=>{if(Object.is(a.current,o)||(a.current=o,i.current=!0),!r)return;const c=e.current;!c||!i.current||(c.scrollTop=c.scrollHeight)},[e,t,r,o]),{onScroll:l}}const ql=3e4;function vj(e,t,n,r=ql){return!e||t>=e.heightPx?{heightPx:t,shrankAtMs:null}:e.shrankAtMs===null?{heightPx:e.heightPx,shrankAtMs:n}:n-e.shrankAtMs>=r?{heightPx:t,shrankAtMs:null}:e}function wj(e,t,n=ql){return e.shrankAtMs===null?null:Math.max(0,e.shrankAtMs+n-t)}const _j=48,Nj=256,kj=544,Sj=288;function Wi(e,t,n){const r=Math.max(Nj,Math.min(kj,Math.ceil(n)+_j));return(e==null?void 0:e.id)===t&&e.targetWidthPx>=r?e:{id:t,targetWidthPx:r}}const Cj=5e3,Vi=1500;function Gi({active:e,hasFollowingConversationText:t,endedAtMs:n,shownSinceMs:r=null,nowMs:o,hideAfterMs:i=Cj}){if(e||!t)return null;const a=n===null?r:r===null?n:Math.max(n,r);if(a===null)return 0;const l=i-(o-a);return l>0?l:0}const Tj=2,Rj=1.5;function Pj({viewportHeightPx:e,trailingContentPx:t,contextReservePx:n,previousTopPx:r,previousChromePx:o,minContentHeightPx:i}){const a=Kl(e,t+n)-r-o;return a>=(i??n)?a:null}function Kl(e,t){return Math.max(0,e-t)}const Ej=2,Ij=1,Mj=4;function $j(e,t,n=Ej){return e===null||t>e?t:e-t<=n?e:t}function Lj(e,t,n=Ij,r=Mj){return e<=n?!0:e>r?!1:t}function Aj(e){const t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return n>0?`${n}:${String(r).padStart(2,"0")}`:`${r}s`}function Fj({object:e,targetHref:t,onCancel:n,onToggleAutoOpen:r,onFollow:o}){const{t:i}=Z(),[a,l]=m.useState(()=>Date.now());if(m.useEffect(()=>{if(e.status!=="generating")return;const u=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(u)},[e.status]),e.status==="generating")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-generating",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-spinner","aria-hidden":"true"}),s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryProgress")}),s.jsx("span",{className:"fork-summary-display-object-elapsed",children:Aj(a-Date.parse(e.createdAt))}),s.jsxs("label",{className:"fork-summary-display-object-autoopen",children:[s.jsx("input",{type:"checkbox",checked:e.autoOpenWhenReady??!1,onChange:u=>r(u.target.checked)}),i("forkSummaryAutoOpenToggle")]}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryCancelInFlight")})]});if(e.status==="error")return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-error",role:"alert",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:e.error?`${i("forkSummaryFailed")}: ${e.error}`:i("forkSummaryFailed")}),s.jsx("button",{type:"button",className:"fork-summary-display-object-cancel",onClick:n,children:i("forkSummaryDismiss")})]});const c=e.title??i("forkSummaryReadyFallbackTitle"),d=e.clickedAt?i("forkSummaryClicked"):e.openedAt?i("forkSummaryOpenedMarker"):void 0;return s.jsxs("div",{className:"fork-summary-display-object fork-summary-display-object-ready",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"fork-summary-display-object-label",children:i("forkSummaryReadyPrefix")}),s.jsxs("a",{className:"fork-summary-display-object-link",href:t??"#",target:"_blank",rel:"noopener noreferrer",onClick:o,title:c,children:[c," ↗"]}),d&&s.jsx("span",{className:"fork-summary-display-object-state",children:d})]})}function Bj(e){if(typeof e=="string")return`s:${e.length}:${e.slice(0,80)}`;const t=e.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join(`
|
|
96
96
|
`);return`a:${e.length}:${t.length}:${t.slice(0,80)}`}const Dj=m.memo(function({title:t,prompts:n}){const r=new Map;return s.jsxs("details",{className:"session-setup-block collapsible",children:[s.jsxs("summary",{className:"collapsible__summary",children:[s.jsx("span",{className:"collapsible__icon",children:"▸"}),s.jsx("span",{children:t})]}),s.jsx("div",{className:"collapsible__content",children:n.map(o=>{const i=Bj(o),a=(r.get(i)??0)+1;return r.set(i,a),s.jsx("div",{className:"session-setup-entry",children:s.jsx(al,{content:o})},`${i}:${a}`)})})]})});function Oj(e){switch(e){case"completed":return{variant:"task-notification-completed",icon:"✓"};case"failed":case"error":return{variant:"task-notification-failed",icon:"!"};case"cancelled":case"canceled":return{variant:"task-notification-cancelled",icon:"⊘"};default:return{variant:"task-notification-progress",icon:"⟳"}}}const Uj=m.memo(function({item:t}){const{variant:n,icon:r}=Oj(t.status),o=t.summary??t.raw.trim();return s.jsxs("div",{className:`task-notification ${n}`.trim(),children:[s.jsxs("div",{className:"task-notification-head",children:[s.jsx("span",{className:"task-notification-icon","aria-hidden":"true",children:r}),s.jsx("span",{className:"task-notification-summary",children:o}),t.outputFile&&s.jsx("span",{className:"task-notification-output",title:t.outputFile,children:Dr(t.outputFile)})]}),t.event&&s.jsx("pre",{className:"task-notification-event",children:t.event.trim()})]})});function Hj(e){const t=Math.max(0,e)/1e3;if(t<10)return`${t.toFixed(1)} sec`;if(t<60)return`${Math.round(t)} sec`;const n=t/60;return n<10?`${n.toFixed(1)} min`:`${Math.round(n)} min`}const Wj=m.memo(function({thinking:t,status:n,isExpanded:r,onToggle:o,durationMs:i}){const a=n==="streaming",l=i!==void 0&&i>=100?Hj(i):null,c=["thinking-block","collapsible","timeline-item",a&&!r?"thinking-streaming-collapsed":""].filter(Boolean).join(" ");return s.jsxs("details",{className:c,open:r,onToggle:d=>{d.currentTarget.open!==r&&o()},children:[s.jsxs("summary",{className:"collapsible__summary","aria-label":r?"Collapse thinking":"Expand thinking",title:r?"Collapse thinking":"Expand thinking",children:[s.jsx("span",{className:"timeline-dot-btn","aria-hidden":!0}),s.jsxs("span",{children:[a?"Thinking...":"Thinking",l&&s.jsxs("span",{className:"thinking-duration",children:["for ",l]})]}),s.jsx("span",{className:"collapsible__icon",children:"▸"})]}),s.jsx("div",{className:"collapsible__content",children:s.jsx(Cr,{text:t,isStreaming:a})})]})}),Xl="\0";function zi(e,t){return[e,t].join(Xl)}function Vj(e){const t=e.indexOf(Xl);return t===-1?e:e.slice(0,t)}function aN(){const e=new Map;return{get size(){return e.size},read(t,n,r){const o=e.get(zi(t,n));return o===void 0?{expanded:r,overridden:!1}:{expanded:o,overridden:!0}},write(t,n,r,o){const i=zi(t,n);o===r?e.delete(i):e.set(i,o)},pruneOwners(t){for(const n of e.keys())t.has(Vj(n))||e.delete(n)}}}const Yl=m.createContext(null);function lN({children:e,registry:t}){return s.jsx(Yl.Provider,{value:t,children:e})}function Dt(e,t,n){const r=m.useContext(Yl),[o]=m.useState(()=>(r==null?void 0:r.read(e,t,n))??{expanded:n,overridden:!1}),[i,a]=m.useState(o.expanded),l=m.useCallback(c=>{a(d=>{const u=typeof c=="function"?c(d):c;return r==null||r.write(e,t,n,u),u})},[t,n,e,r]);return[i,l,o.overridden]}const Gj="_toggle_ipqut_1",zj="_inline_ipqut_23",qi={toggle:Gj,inline:zj};function ro({expanded:e,label:t,onClick:n,controls:r,status:o,inline:i=!1}){return s.jsx("button",{type:"button",className:`${qi.toggle} ${i?qi.inline:""}`,onClick:n,"aria-label":t,"aria-expanded":e,"aria-controls":r,title:t,"data-status":o,children:s.jsx("span",{"aria-hidden":"true",children:e?"−":"+"})})}const qj="_root_7iwcz_3",Kj="_rowHeader_7iwcz_8",Xj="_filename_7iwcz_17",Yj="_suffix_7iwcz_39",Jj="_dimensions_7iwcz_40",Qj="_row_7iwcz_8",Zj="_rejected_7iwcz_49",eb="_preview_7iwcz_53",tb="_loading_7iwcz_67",nb="_error_7iwcz_68",sb="_imageButton_7iwcz_76",Le={root:qj,rowHeader:Kj,filename:Xj,suffix:Yj,dimensions:Jj,row:Qj,rejected:Zj,preview:eb,loading:tb,error:nb,imageButton:sb},rb={"invalid-image-data":"toolResultMediaInvalidImageData","source-unavailable":"toolResultMediaSourceUnavailable","storage-unavailable":"toolResultMediaStorageUnavailable","too-large":"toolResultMediaTooLarge","unsupported-media":"toolResultMediaUnsupportedMedia"};function ob({displayName:e,media:t,sourcePath:n,status:r}){return s.jsx("div",{className:Le.root,children:t.map((o,i)=>s.jsx(ib,{displayName:e,index:i,media:o,sourcePath:n,status:r},o.state==="stored"?o.id:`${o.reason}-${i}`))})}function ib({displayName:e,index:t,media:n,sourcePath:r,status:o}){const{inlineMediaExpandedByDefault:i}=wr(),{t:a}=Z(),l=n.filename||a("toolResultMediaUnnamed",{number:t+1});return n.state==="rejected"?s.jsx("div",{className:`tool-row timeline-item status-${o} ${Le.row} ${Le.rejected}`,children:s.jsxs("div",{className:Le.rowHeader,title:a(rb[n.reason]),children:[s.jsx("span",{className:"tool-name",children:e}),s.jsx("span",{className:Le.filename,children:l}),s.jsxs("span",{className:Le.suffix,children:["(",a("toolResultMediaUnavailable"),")"]})]})}):s.jsx(ab,{displayName:e,filename:l,initialExpanded:i,media:n,sourcePath:r,status:o})}function ab({displayName:e,filename:t,initialExpanded:n,media:r,sourcePath:o,status:i}){const{projectId:a,sessionId:l}=gs(),c=Kt().transport,{t:d}=Z(),[u,f]=Dt(r.toolCallId,`media-preview:${r.id}`,n),[h,g]=m.useState({state:"idle"}),[p,y]=m.useState(!1),x=`/api/projects/${encodeURIComponent(a)}/sessions/${encodeURIComponent(l)}/media/${encodeURIComponent(r.id)}`,b=m.useMemo(()=>({buildApiPath:()=>x}),[x]),_=m.useCallback(()=>c.fetchBlob(xd(x)),[x,c]),N=m.useCallback(()=>y(!0),[]),v=hs({fileName:t,filePath:o,loadBlob:_,onOpen:N});m.useEffect(()=>{if(!u){g({state:"idle"});return}let S=!1,$=null;return g({state:"loading"}),_().then(T=>{if($=URL.createObjectURL(T),S){URL.revokeObjectURL($);return}g({state:"loaded",objectUrl:$})}).catch(()=>{S||g({state:"error"})}),()=>{S=!0,$&&URL.revokeObjectURL($)}},[u,_]);const j=r.mimeType.startsWith("video/"),C=r.width&&r.height?`${r.width}×${r.height}`:null,w={"--tool-result-media-aspect-ratio":r.width&&r.height?`${r.width} / ${r.height}`:"16 / 9","--tool-result-media-max-width":r.width?`${Math.min(r.width,720)}px`:"720px"},k=d(u?"toolResultMediaCollapse":"toolResultMediaExpand");return s.jsxs("div",{className:`tool-row timeline-item status-${i} ${Le.row}`,children:[s.jsx(ro,{expanded:u,label:k,status:i,onClick:()=>f(S=>!S)}),s.jsxs("div",{className:Le.rowHeader,children:[s.jsx("span",{className:"tool-name",children:e}),s.jsx("button",{type:"button",className:Le.filename,onClick:N,onContextMenu:v.handleContextMenu,children:t}),s.jsxs("span",{className:Le.suffix,children:["(",d(j?"toolResultMediaVideo":"toolResultMediaImage"),")"]}),C&&s.jsx("span",{className:Le.dimensions,children:C})]}),u&&s.jsxs("div",{className:Le.preview,style:w,children:[h.state==="loading"&&s.jsx("span",{className:Le.loading,children:d("toolResultMediaLoading")}),h.state==="error"&&s.jsx("span",{className:Le.error,children:d("toolResultMediaLoadFailed")}),h.state==="loaded"&&(j?s.jsx("video",{className:Le.imageButton,src:h.objectUrl,controls:!0,playsInline:!0,preload:"metadata","aria-label":d("toolResultMediaAlt",{filename:t})}):s.jsx("button",{type:"button",className:Le.imageButton,onClick:N,onContextMenu:v.handleContextMenu,"aria-label":d("toolResultMediaOpen",{filename:t}),children:s.jsx("img",{src:h.objectUrl,alt:d("toolResultMediaAlt",{filename:t}),width:r.width,height:r.height})}))]}),p&&s.jsx(qt,{path:t,filePath:o??null,mediaType:j?"video":"image",mediaSource:b,onClose:()=>y(!1)}),v.contextMenuElement]})}function lb(e,t,n){if(n!==1||!t||typeof t!="object")return;const r=e.toLowerCase().replaceAll("_","");if(r!=="viewimage"&&r!=="imageview"&&r!=="read")return;const o=t,i=[o.path,o.file_path,o.filePath].filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean);return new Set(i).size===1?i[0]:void 0}const cb=500,db=/^timeout waiting for ([^\r\n]+) to reach not-running; current status=running$/;function ub(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Hn(e){const t=ht(e);if(t)return t.parts.filter(n=>n.kind!=="script-status").map(n=>n.text).join(`
|
|
97
97
|
`);if(typeof e=="string")return e;if(ub(e)){if(typeof e.content=="string")return e.content;const n=typeof e.stdout=="string"?e.stdout:"",r=typeof e.stderr=="string"?e.stderr:"";if(n||r)return[n,r].filter(Boolean).join(`
|
|
98
98
|
`);if(typeof e.output=="string")return e.output}return e==null?"":typeof e=="number"||typeof e=="boolean"?String(e):JSON.stringify(e,null,2)}function Jl(e,t,n){var u;const r=ht(e),o=r==null?void 0:r.parts.filter(f=>f.kind!=="script-status");if(o&&o.length!==1)return null;const i=o==null?void 0:o[0],a=Me((i==null?void 0:i.text)??Hn(e),{bareExitCodeIsEnvelope:t}),l=a.output.trim();if(l.length===0||l.length>cb||/[\r\n]/.test(l))return null;const c=Ct(e).exitCode??((i==null?void 0:i.kind)==="command-output"?i.exitCode:void 0)??a.exitCode??(n?Me(n,{bareExitCodeIsEnvelope:t}).exitCode:void 0),d=c===1?(u=db.exec(l))==null?void 0:u[1]:void 0;return d?{kind:"waiting",target:d,output:l,exitCode:c}:{kind:"compact",output:l,exitCode:c}}function mb(e,t,n,r,o,i){const a=i??ze.prepare(e,{input:t,result:(n==null?void 0:n.structured)??(n==null?void 0:n.content),isError:n==null?void 0:n.isError,status:r}),l=ze.metadata(e).tool;if(r==="pending"||r==="aborted"||r==="incomplete"){if(a.getUseSummary){const u=a.getUseSummary(o);if(u!==void 0)return u}return Us(l,t)}let c;a.getUseSummary?c=a.getUseSummary(o)??Us(l,t):c=Us(l,t);let d;return a.getResultSummary?d=a.getResultSummary(o)??Ki(l,n,r):d=Ki(l,n,r),n?l==="Glob"||l==="Grep"?`${c} → ${d}`:l==="Bash"?c:l==="WriteStdin"&&c&&c!=="waiting for output"?`${c} → ${d}`:d:c}function Us(e,t){if(!t||typeof t!="object")return"...";const n=t;switch(e){case"Read":case"Write":case"Edit":if(typeof n.file_path=="string")return hb(n.file_path);break;case"Bash":{const r=jn(n);if(r)return r}break;case"Glob":if(typeof n.pattern=="string")return n.pattern;break;case"Grep":if(typeof n.pattern=="string")return`"${n.pattern}"`;break;case"Task":case"Agent":if(typeof n.description=="string")return Wn(n.description,30);break;case"WebSearch":if(typeof n.query=="string")return Wn(n.query,30);break;case"WebFetch":if(typeof n.url=="string")return Wn(n.url,40);break}return fb(n)}function fb(e){for(const t of Object.values(e))if(typeof t=="string"&&t.length>0&&t.length<100)return Wn(t,40);return"..."}function Ki(e,t,n){if(n==="error")return"failed";if(!t)return"done";const o=(typeof t.content=="string"?t.content:"").split(`
|
|
99
|
-
`).filter(Boolean).length;switch(e){case"Read":return`${o} lines`;case"Bash":return`${o} lines`;case"Glob":return`${o} files`;case"Grep":return`${o} matches`;default:return"done"}}function Wn(e,t){return e.length<=t?e:`${e.slice(0,t-3)}...`}function hb(e){return tt(e)}const pb="_root_1ht2d_1",gb="_content_1ht2d_6",xb="_boundary_1ht2d_14",yb="_tag_1ht2d_31",jb="_title_1ht2d_42",bb="_context_1ht2d_47",vb="_original_1ht2d_54",at={root:pb,content:gb,boundary:xb,tag:yb,title:jb,context:bb,original:vb};function Ql({marker:e}){const{t}=Z(),n=e.kind==="unresolved"?t("workflowSchemaUnresolved"):t("workflowSchemaActivated",{title:e.title}),r=e.schemaRef?Lr(e.schemaRef):void 0;return r?s.jsx(Ue,{displayPath:n,filePath:r.path,showCopyButton:!1,showVersionControlLinks:!1}):n}function oo({marker:e}){return s.jsxs("span",{className:at.boundary,"data-workflow-boundary":e.kind,"data-workflow-path":e.path,children:[e.kind!=="activation"&&e.kind!=="unresolved"&&s.jsx("mark",{className:at.tag,children:e.prefix}),e.kind!=="activation"||e.title?s.jsx("span",{className:at.title,children:e.kind==="unresolved"||e.kind==="activation"?s.jsx(Ql,{marker:e}):e.title}):null]})}function Zl({workflow:e}){return s.jsxs(s.Fragment,{children:[e.parent?s.jsx("div",{className:at.context,"data-workflow-parent":e.parent.path,children:e.parent.title}):null,e.markers.filter(t=>!e.view&&(t.kind==="activation"||t.kind==="unresolved")).map(t=>s.jsx("div",{className:at.context,title:t.prefix,"data-workflow-schema":t.kind,children:s.jsx(Ql,{marker:t})},t.start))]})}function ec({text:e,workflow:t,original:n,preview:r}){const{t:o}=Z(),[i,a]=m.useState(!1),l=m.useId(),c=[],d=(f,h)=>{const g=[f,...(t.outputBoundaries??[]).filter(p=>p>f&&p<h),h];return g.slice(0,-1).map((p,y)=>s.jsx(pt,{text:e.slice(p,g[y+1])},p))};let u=0;for(const f of t.visibleRanges??[{start:0,end:e.length}]){let h=f.start;for(;u<t.markers.length;){const g=t.markers[u];if(g.start>=f.end)break;u++,!(g.start<f.start)&&(c.push(s.jsxs(m.Fragment,{children:[d(h,g.start),s.jsx(oo,{marker:g})]},g.start)),h=g.end)}c.push(s.jsx(m.Fragment,{children:d(h,f.end)},`tail-${f.start}`))}return s.jsxs("div",{className:`${at.root} timeline-item`,"data-workflow-output":"true",children:[s.jsx(ro,{expanded:i,label:o(i?"workflowHideOriginal":"workflowShowOriginal"),controls:l,onClick:()=>a(f=>!f)}),r??s.jsx("pre",{className:at.content,children:c}),i&&s.jsx("div",{className:at.original,id:l,"data-workflow-original":"true",children:n??s.jsx("pre",{className:at.content,children:e})})]})}class Xi{constructor(t,n=!0){be(this,"decoder");be(this,"data",[]);be(this,"fragments",[]);this.channel=t,this.decoder=new Fa(n?t:"unknown")}}class wb{constructor(t,n,r,o=!0,i){be(this,"stdout");be(this,"stderr",new Xi("stderr"));be(this,"finished",!1);be(this,"records",[]);be(this,"active",!1);be(this,"stopped",!1);be(this,"projection",{stdout:"",stderr:"",commentary:[],failed:!1,complete:!1,fragments:{stdout:[],stderr:[]}});this.render=t,this.publish=n,this.workflowContext=i,this.stdout=new Xi("stdout",o),r&&(this.stdout.decoder.source=r.source,this.stderr.decoder.source=r.stderr,this.finished=!0,this.projection=r.projection)}appendSnapshot(t,n,r=""){if(this.stopped)return!1;for(const[i,a]of[[this.stdout,t],[this.stderr,r]])if(!a.startsWith(i.decoder.source)||this.finished&&a!==i.decoder.source)return!1;if(this.finished)return!0;const o=[t,r].some(i=>mt(i,n)==="json");return this.appendStream(this.stdout,t,n,o),this.appendStream(this.stderr,r,n,!1),this.finished=n,this.finished&&!this.active&&this.records.length===0&&!this.projection.complete&&(this.projection={...this.projection,complete:!0},this.publish(this.projection)),this.drain(),!0}appendStream(t,n,r,o){for(const i of t.decoder.appendSnapshot(n,r,o))this.records.push({...i,id:`${t.channel}:${i.id}`,stream:t})}stop(){this.stopped=!0,this.records=[]}async drain(){if(!(this.active||this.stopped||this.records.length===0)){this.active=!0;try{for(;!this.stopped&&this.records.length>0;){const t=this.records.splice(0),n=this.workflowContext?Jn([this.stdout,this.stderr].map(c=>[...c.fragments,...t.filter(d=>d.stream===c).flatMap(({id:d,record:u})=>Qs(d,u))]),this.workflowContext):void 0,r=new Map(t.flatMap(({id:c,record:d})=>d.commentary.map(u=>{const f=`${c}:${u.id}`,h=n==null?void 0:n.commentary[f];return[f,h?Ja(u.text,h):[{text:u.text}]]}))),o=[...r.values()].flatMap(c=>c.filter(d=>d.text.trim()).map(d=>d.text));let i;try{if(i=o.length?await this.render(o):[],i.length!==o.length)throw new Error("Incomplete commentary rendering")}catch{i=null}if(this.stopped)return;let a=0;const l=[...this.projection.commentary];for(const{id:c,record:d,stream:u,getPreviousContext:f}of t){if(!i){u.data.push(d.source),u.fragments.push({id:c,text:d.source,kind:"data",opaque:d.json});continue}u.fragments.push(...Qs(c,d)),d.metadataOnly||u.data.push(d.data);for(const h of d.commentary){const g=`${c}:${h.id}`,p=r.get(g).map(y=>({...y,html:y.text.trim()?i[a++]:""}));l.push({id:g,text:h.text,html:p.map(y=>y.html).join(""),...n?{workflow:n.commentary[g],segments:p}:{},getContext:h.context?()=>Gd(d,h):d.metadataOnly?f:null})}}this.projection={stdout:this.stdout.data.join(""),stderr:this.stderr.data.join(""),commentary:l,failed:this.projection.failed||i===null,complete:this.finished&&this.records.length===0,fragments:{stdout:[...this.stdout.fragments],stderr:[...this.stderr.fragments]},workflow:i?n==null?void 0:n.data:this.workflowContext?Jn([this.stdout.fragments,this.stderr.fragments],this.workflowContext).data:void 0},this.publish(this.projection)}}finally{this.active=!1}}}}async function tc(e,t,n,r){const o=[];for(let i=0;i<n.length;){let a=Math.min(zd,n.length-i),l=JSON.stringify({texts:n.slice(i,i+a)});for(;new TextEncoder().encode(l).length>Co&&a>1;)a=Math.floor(a/2),l=JSON.stringify({texts:n.slice(i,i+a)});if(new TextEncoder().encode(l).length>Co)throw new Error("Commentary exceeds rendering limit");const c=await e.transport.fetch(`/projects/${t}/tool-commentary/render`,{method:"POST",body:l,signal:r});if(!Array.isArray(c.html)||c.html.length!==a||c.html.some(d=>typeof d!="string"))throw new Error("Invalid commentary response");o.push(...c.html),i+=a}return o}function nc(e){var r,o,i,a,l;const t=((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content)??((i=Ut(e.toolInput))==null?void 0:i._previewResult);if(["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase())){const c=Xt(t,Hr(e));return{stdout:c.stdout??"",stderr:c.stderr??"",shell:c,stdoutSequenced:typeof((a=Ut(t))==null?void 0:a.stdout)=="string"}}const n=Ut(t);return{stdout:typeof(n==null?void 0:n.stdout)=="string"?n.stdout:((l=e.toolResult)==null?void 0:l.content)??"",stderr:typeof(n==null?void 0:n.stderr)=="string"?n.stderr:"",stdoutSequenced:typeof(n==null?void 0:n.stdout)=="string",shell:null}}const Yi=new WeakMap;function cN(e){const t=Yi.get(e);if(t!==void 0)return t;const n=_b(e);return e.status!=="pending"&&Yi.set(e,n),n}function _b(e){var r,o;const t=e.status!=="pending";if(e.toolName==="Exec"){const i=ht(((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content));return(i==null?void 0:i.parts.some(a=>mt(a.text,t)!==null))??!1}const n=nc(e);return[n.stdout,n.stderr].some(i=>mt(i,t)!==null)}const Nb="_bullet_15up9_1",kb="_context_15up9_32",Sb="_close_15up9_55",Hs={bullet:Nb,context:kb,close:Sb},Cb=m.memo(function({items:t,command:n,onOpenOutput:r}){return t.map(o=>{var i,a;return o.segments?s.jsxs(m.Fragment,{children:[o.segments.length&&!((i=o.segments[0])!=null&&i.marker)?s.jsx(Zl,{workflow:{markers:[],parent:(a=o.workflow)==null?void 0:a.parent}}):null,o.segments.map((l,c)=>s.jsxs(m.Fragment,{children:[l.marker?s.jsx(oo,{marker:l.marker}):null,l.text.trim()||l.marker?s.jsx(Qn,{text:l.text,augmentHtml:l.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})}):null]},c))]},o.id):s.jsx(Qn,{text:o.text,augmentHtml:o.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})},o.id)})});function Ji({item:e,command:t,onOpenOutput:n}){const{t:r}=Z(),o=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[d,u]=m.useState(!1),[f,h]=m.useState(""),[g,p]=m.useState({left:8,top:8,maxHeight:320}),y=m.useCallback(_=>{var N;if(!(!e.getContext||d&&!_)){if(_){h(e.getContext());const v=(N=i.current)==null?void 0:N.getBoundingClientRect();if(v){const j=Math.min(480,window.innerWidth-16),C=Math.max(8,Math.min(v.bottom+6,window.innerHeight*.55));p({left:Math.max(8,Math.min(v.left,window.innerWidth-j-8)),top:C,maxHeight:window.innerHeight-C-8})}}c(_)}},[e,d]),x=ch({open:l,onOpenChange:y}),b=m.useCallback(()=>{u(!1),c(!1)},[]);return m.useEffect(()=>{if(!l)return;const _=v=>{var j,C;v.target instanceof Node&&((j=a.current)!=null&&j.contains(v.target)||(C=i.current)!=null&&C.contains(v.target))||b()},N=v=>{var j;v.key==="Escape"&&(v.stopPropagation(),b(),(j=i.current)==null||j.focus())};return document.addEventListener("pointerdown",_),document.addEventListener("scroll",_,!0),document.addEventListener("keydown",N),window.addEventListener("resize",b),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("scroll",_,!0),document.removeEventListener("keydown",N),window.removeEventListener("resize",b)}},[l,b]),s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:i,type:"button",className:Hs.bullet,"aria-label":r(e.getContext?"acliCommentaryContext":"acliCommentaryOutput"),"aria-expanded":e.getContext?l:void 0,"aria-controls":l?o:void 0,title:e.getContext?void 0:t,onPointerEnter:x.onPointerEnter,onPointerMove:x.onPointerMove,onPointerLeave:x.onPointerLeave,onFocus:x.onFocus,onBlur:x.onBlur,onClick:()=>{if(!e.getContext){n();return}d?b():(y(!0),u(!0))}}),l?br.createPortal(s.jsxs("div",{ref:a,id:o,className:Hs.context,style:g,role:"dialog","aria-label":r("acliCommentaryContext"),children:[s.jsx("button",{type:"button",className:Hs.close,onClick:b,"aria-label":r("acliCommentaryCloseContext"),children:"×"}),s.jsx("pre",{children:f})]}),document.body):null]})}const Qi=new WeakMap;function sc(e,t){return mt(e,!t)!==null}function Tb(e){var h,g,p,y,x;const t=((h=e.toolResult)==null?void 0:h.structured)??((g=e.toolResult)==null?void 0:g.content),n=Hr(e),r=m.useMemo(()=>{const b=e.toolResult?Qi.get(e.toolResult):void 0;if((b==null?void 0:b.source)===t&&e.status!=="pending")return b;const _=ht(t);if(!_)return null;const N=_.parts.flatMap((k,S)=>sc(k.text,e.status==="pending")?[{part:k,index:S}]:[]);if(!N.length)return null;const v=typeof t=="string"?JSON.parse(t):t,j=N.map(({part:k,index:S})=>{const $=v[S],T=k.kind==="command-output"?JSON.parse($.text):null;return{index:S,result:{...e.toolResult,content:k.text,structured:void 0,isError:n},replaceText:E=>({...$,text:T?JSON.stringify(T.status==="fulfilled"?{...T,value:{...T.value,output:E}}:{...T,output:E}):k.kind==="script-status"?$.text:E})}}),C=_.parts.flatMap((k,S)=>k.kind==="script-status"?[]:[{index:S,text:k.text}]),w={source:t,blocks:v,parts:j,textParts:C};return e.toolResult&&e.status!=="pending"&&Qi.set(e.toolResult,w),w},[t,e.toolResult,e.status,n]),[o,i]=m.useState(()=>new Map),a=m.useCallback((b,_,N)=>{i(v=>{var j,C;return v.has(b)&&((j=v.get(b))==null?void 0:j.result)===_&&((C=v.get(b))==null?void 0:C.workflow)===N?v:new Map(v).set(b,{result:_,workflow:N})})},[]),l=Ut(e.toolInput),c=m.useMemo(()=>({cmd:l==null?void 0:l.source}),[l==null?void 0:l.source]);if(!r||e.supported===!1)return e.children(e.toolInput,e.toolResult,e.workflow);const d=[...r.blocks];for(const b of r.parts)d[b.index]=b.replaceText(((y=(p=o.get(b.index))==null?void 0:p.result)==null?void 0:y.content)??"");const u=(x=e.workflow)==null?void 0:x.toolContext,f=u?Km(r.textParts.map(b=>{var _;return r.parts.some(N=>N.index===b.index)?((_=o.get(b.index))==null?void 0:_.workflow)??{markers:[],outputText:""}:Jn([[{id:String(b.index),kind:"data",text:b.text}]],u).data})):e.workflow;return s.jsxs(s.Fragment,{children:[e.children(e.toolInput,{...e.toolResult,content:JSON.stringify(d),structured:d,isError:n},f),r.parts.map(b=>m.createElement(rc,{...e,key:b.index,id:`${e.id}:${b.index}`,toolName:"Exec output",toolInput:c,toolResult:b.result},(_,N,v)=>s.jsx(Rb,{index:b.index,result:N,workflow:v,project:a})))]})}function Rb({index:e,result:t,workflow:n,project:r}){return m.useLayoutEffect(()=>r(e,t,n),[e,t,n,r]),null}function Pb(e){var l;const{acliCommentaryEnabled:t}=vd(),n=ge(),r=ps(),o=Kt(),i=Aa(o.sourceKey);if(!t||!n||r)return e.children(e.toolInput,e.toolResult,e.workflow);const a=e.toolName==="Exec"?Tb:rc;return s.jsx(a,{...e,projectId:n.projectId,runtime:o,supported:i?ga(i,xa):null},`${o.sourceKey}:${n.projectId}:${n.sessionId}:${e.id}:${JSON.stringify((l=e.workflow)==null?void 0:l.toolContext)}`)}function rc(e){const t=m.useMemo(()=>nc({toolName:e.toolName,toolInput:e.toolInput,toolResult:e.toolResult,status:e.status}),[e.toolResult,e.toolInput,e.toolName,e.status]),[n,r]=m.useState(null),o=[t.stdout,t.stderr].some(a=>sc(a,e.status==="pending"));if(n===null&&(e.supported===!1?r("raw"):o&&e.supported?r("commentary"):!o&&(e.status!=="pending"||t.stdout.includes(`
|
|
99
|
+
`).filter(Boolean).length;switch(e){case"Read":return`${o} lines`;case"Bash":return`${o} lines`;case"Glob":return`${o} files`;case"Grep":return`${o} matches`;default:return"done"}}function Wn(e,t){return e.length<=t?e:`${e.slice(0,t-3)}...`}function hb(e){return tt(e)}const pb="_root_1ht2d_1",gb="_content_1ht2d_6",xb="_boundary_1ht2d_14",yb="_tag_1ht2d_31",jb="_title_1ht2d_42",bb="_context_1ht2d_47",vb="_original_1ht2d_54",it={root:pb,content:gb,boundary:xb,tag:yb,title:jb,context:bb,original:vb};function Ql({marker:e}){const{t}=Z(),n=e.kind==="unresolved"?t("workflowSchemaUnresolved"):t("workflowSchemaActivated",{title:e.title}),r=e.schemaRef?Lr(e.schemaRef):void 0;return r?s.jsx(Ue,{displayPath:n,filePath:r.path,showCopyButton:!1,showVersionControlLinks:!1}):n}function oo({marker:e}){return s.jsxs("span",{className:it.boundary,"data-workflow-boundary":e.kind,"data-workflow-path":e.path,children:[e.kind!=="activation"&&e.kind!=="unresolved"&&s.jsx("mark",{className:it.tag,children:e.prefix}),e.kind!=="activation"||e.title?s.jsx("span",{className:it.title,children:e.kind==="unresolved"||e.kind==="activation"?s.jsx(Ql,{marker:e}):e.title}):null]})}function Zl({workflow:e}){return s.jsxs(s.Fragment,{children:[e.parent?s.jsx("div",{className:it.context,"data-workflow-parent":e.parent.path,children:e.parent.title}):null,e.markers.filter(t=>!e.view&&(t.kind==="activation"||t.kind==="unresolved")).map(t=>s.jsx("div",{className:it.context,title:t.prefix,"data-workflow-schema":t.kind,children:s.jsx(Ql,{marker:t})},t.start))]})}function ec({text:e,workflow:t,original:n,preview:r}){const{t:o}=Z(),[i,a]=m.useState(!1),l=m.useId(),c=[],d=(f,h)=>{const g=[f,...(t.outputBoundaries??[]).filter(p=>p>f&&p<h),h];return g.slice(0,-1).map((p,y)=>s.jsx(pt,{text:e.slice(p,g[y+1])},p))};let u=0;for(const f of t.visibleRanges??[{start:0,end:e.length}]){let h=f.start;for(;u<t.markers.length;){const g=t.markers[u];if(g.start>=f.end)break;u++,!(g.start<f.start)&&(c.push(s.jsxs(m.Fragment,{children:[d(h,g.start),s.jsx(oo,{marker:g})]},g.start)),h=g.end)}c.push(s.jsx(m.Fragment,{children:d(h,f.end)},`tail-${f.start}`))}return s.jsxs("div",{className:`${it.root} timeline-item`,"data-workflow-output":"true",children:[s.jsx(ro,{expanded:i,label:o(i?"workflowHideOriginal":"workflowShowOriginal"),controls:l,onClick:()=>a(f=>!f)}),r??s.jsx("pre",{className:it.content,children:c}),i&&s.jsx("div",{className:it.original,id:l,"data-workflow-original":"true",children:n??s.jsx("pre",{className:it.content,children:e})})]})}class Xi{constructor(t,n=!0){be(this,"decoder");be(this,"data",[]);be(this,"fragments",[]);this.channel=t,this.decoder=new Fa(n?t:"unknown")}}class wb{constructor(t,n,r,o=!0,i){be(this,"stdout");be(this,"stderr",new Xi("stderr"));be(this,"finished",!1);be(this,"records",[]);be(this,"active",!1);be(this,"stopped",!1);be(this,"projection",{stdout:"",stderr:"",commentary:[],failed:!1,complete:!1,fragments:{stdout:[],stderr:[]}});this.render=t,this.publish=n,this.workflowContext=i,this.stdout=new Xi("stdout",o),r&&(this.stdout.decoder.source=r.source,this.stderr.decoder.source=r.stderr,this.finished=!0,this.projection=r.projection)}appendSnapshot(t,n,r=""){if(this.stopped)return!1;for(const[i,a]of[[this.stdout,t],[this.stderr,r]])if(!a.startsWith(i.decoder.source)||this.finished&&a!==i.decoder.source)return!1;if(this.finished)return!0;const o=[t,r].some(i=>mt(i,n)==="json");return this.appendStream(this.stdout,t,n,o),this.appendStream(this.stderr,r,n,!1),this.finished=n,this.finished&&!this.active&&this.records.length===0&&!this.projection.complete&&(this.projection={...this.projection,complete:!0},this.publish(this.projection)),this.drain(),!0}appendStream(t,n,r,o){for(const i of t.decoder.appendSnapshot(n,r,o))this.records.push({...i,id:`${t.channel}:${i.id}`,stream:t})}stop(){this.stopped=!0,this.records=[]}async drain(){if(!(this.active||this.stopped||this.records.length===0)){this.active=!0;try{for(;!this.stopped&&this.records.length>0;){const t=this.records.splice(0),n=this.workflowContext?Jn([this.stdout,this.stderr].map(c=>[...c.fragments,...t.filter(d=>d.stream===c).flatMap(({id:d,record:u})=>Qs(d,u))]),this.workflowContext):void 0,r=new Map(t.flatMap(({id:c,record:d})=>d.commentary.map(u=>{const f=`${c}:${u.id}`,h=n==null?void 0:n.commentary[f];return[f,h?Ja(u.text,h):[{text:u.text}]]}))),o=[...r.values()].flatMap(c=>c.filter(d=>d.text.trim()).map(d=>d.text));let i;try{if(i=o.length?await this.render(o):[],i.length!==o.length)throw new Error("Incomplete commentary rendering")}catch{i=null}if(this.stopped)return;let a=0;const l=[...this.projection.commentary];for(const{id:c,record:d,stream:u,getPreviousContext:f}of t){if(!i){u.data.push(d.source),u.fragments.push({id:c,text:d.source,kind:"data",opaque:d.json});continue}u.fragments.push(...Qs(c,d)),d.metadataOnly||u.data.push(d.data);for(const h of d.commentary){const g=`${c}:${h.id}`,p=r.get(g).map(y=>({...y,html:y.text.trim()?i[a++]:""}));l.push({id:g,text:h.text,html:p.map(y=>y.html).join(""),...n?{workflow:n.commentary[g],segments:p}:{},getContext:h.context?()=>Gd(d,h):d.metadataOnly?f:null})}}this.projection={stdout:this.stdout.data.join(""),stderr:this.stderr.data.join(""),commentary:l,failed:this.projection.failed||i===null,complete:this.finished&&this.records.length===0,fragments:{stdout:[...this.stdout.fragments],stderr:[...this.stderr.fragments]},workflow:i?n==null?void 0:n.data:this.workflowContext?Jn([this.stdout.fragments,this.stderr.fragments],this.workflowContext).data:void 0},this.publish(this.projection)}}finally{this.active=!1}}}}async function tc(e,t,n,r){const o=[];for(let i=0;i<n.length;){let a=Math.min(zd,n.length-i),l=JSON.stringify({texts:n.slice(i,i+a)});for(;new TextEncoder().encode(l).length>Co&&a>1;)a=Math.floor(a/2),l=JSON.stringify({texts:n.slice(i,i+a)});if(new TextEncoder().encode(l).length>Co)throw new Error("Commentary exceeds rendering limit");const c=await e.transport.fetch(`/projects/${t}/tool-commentary/render`,{method:"POST",body:l,signal:r});if(!Array.isArray(c.html)||c.html.length!==a||c.html.some(d=>typeof d!="string"))throw new Error("Invalid commentary response");o.push(...c.html),i+=a}return o}function nc(e){var r,o,i,a,l;const t=((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content)??((i=Ut(e.toolInput))==null?void 0:i._previewResult);if(["bash","exec_command","shell_command"].includes(e.toolName.toLowerCase())){const c=Xt(t,Hr(e));return{stdout:c.stdout??"",stderr:c.stderr??"",shell:c,stdoutSequenced:typeof((a=Ut(t))==null?void 0:a.stdout)=="string"}}const n=Ut(t);return{stdout:typeof(n==null?void 0:n.stdout)=="string"?n.stdout:((l=e.toolResult)==null?void 0:l.content)??"",stderr:typeof(n==null?void 0:n.stderr)=="string"?n.stderr:"",stdoutSequenced:typeof(n==null?void 0:n.stdout)=="string",shell:null}}const Yi=new WeakMap;function cN(e){const t=Yi.get(e);if(t!==void 0)return t;const n=_b(e);return e.status!=="pending"&&Yi.set(e,n),n}function _b(e){var r,o;const t=e.status!=="pending";if(e.toolName==="Exec"){const i=ht(((r=e.toolResult)==null?void 0:r.structured)??((o=e.toolResult)==null?void 0:o.content));return(i==null?void 0:i.parts.some(a=>mt(a.text,t)!==null))??!1}const n=nc(e);return[n.stdout,n.stderr].some(i=>mt(i,t)!==null)}const Nb="_bullet_15up9_1",kb="_context_15up9_32",Sb="_close_15up9_55",Hs={bullet:Nb,context:kb,close:Sb},Cb=m.memo(function({items:t,command:n,onOpenOutput:r}){return t.map(o=>{var i,a;return o.segments?s.jsxs(m.Fragment,{children:[o.segments.length&&!((i=o.segments[0])!=null&&i.marker)?s.jsx(Zl,{workflow:{markers:[],parent:(a=o.workflow)==null?void 0:a.parent}}):null,o.segments.map((l,c)=>s.jsxs(m.Fragment,{children:[l.marker?s.jsx(oo,{marker:l.marker}):null,l.text.trim()||l.marker?s.jsx(Qn,{text:l.text,augmentHtml:l.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})}):null]},c))]},o.id):s.jsx(Qn,{text:o.text,augmentHtml:o.html,timelineAction:s.jsx(Ji,{item:o,command:n,onOpenOutput:r})},o.id)})});function Ji({item:e,command:t,onOpenOutput:n}){const{t:r}=Z(),o=m.useId(),i=m.useRef(null),a=m.useRef(null),[l,c]=m.useState(!1),[d,u]=m.useState(!1),[f,h]=m.useState(""),[g,p]=m.useState({left:8,top:8,maxHeight:320}),y=m.useCallback(_=>{var N;if(!(!e.getContext||d&&!_)){if(_){h(e.getContext());const v=(N=i.current)==null?void 0:N.getBoundingClientRect();if(v){const j=Math.min(480,window.innerWidth-16),C=Math.max(8,Math.min(v.bottom+6,window.innerHeight*.55));p({left:Math.max(8,Math.min(v.left,window.innerWidth-j-8)),top:C,maxHeight:window.innerHeight-C-8})}}c(_)}},[e,d]),x=ch({open:l,onOpenChange:y}),b=m.useCallback(()=>{u(!1),c(!1)},[]);return m.useEffect(()=>{if(!l)return;const _=v=>{var j,C;v.target instanceof Node&&((j=a.current)!=null&&j.contains(v.target)||(C=i.current)!=null&&C.contains(v.target))||b()},N=v=>{var j;v.key==="Escape"&&(v.stopPropagation(),b(),(j=i.current)==null||j.focus())};return document.addEventListener("pointerdown",_),document.addEventListener("scroll",_,!0),document.addEventListener("keydown",N),window.addEventListener("resize",b),()=>{document.removeEventListener("pointerdown",_),document.removeEventListener("scroll",_,!0),document.removeEventListener("keydown",N),window.removeEventListener("resize",b)}},[l,b]),s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:i,type:"button",className:Hs.bullet,"aria-label":r(e.getContext?"acliCommentaryContext":"acliCommentaryOutput"),"aria-expanded":e.getContext?l:void 0,"aria-controls":l?o:void 0,title:e.getContext?void 0:t,onPointerEnter:x.onPointerEnter,onPointerMove:x.onPointerMove,onPointerLeave:x.onPointerLeave,onFocus:x.onFocus,onBlur:x.onBlur,onClick:()=>{if(!e.getContext){n();return}d?b():(y(!0),u(!0))}}),l?br.createPortal(s.jsxs("div",{ref:a,id:o,className:Hs.context,style:g,role:"dialog","aria-label":r("acliCommentaryContext"),children:[s.jsx("button",{type:"button",className:Hs.close,onClick:b,"aria-label":r("acliCommentaryCloseContext"),children:"×"}),s.jsx("pre",{children:f})]}),document.body):null]})}const Qi=new WeakMap;function sc(e,t){return mt(e,!t)!==null}function Tb(e){var h,g,p,y,x;const t=((h=e.toolResult)==null?void 0:h.structured)??((g=e.toolResult)==null?void 0:g.content),n=Hr(e),r=m.useMemo(()=>{const b=e.toolResult?Qi.get(e.toolResult):void 0;if((b==null?void 0:b.source)===t&&e.status!=="pending")return b;const _=ht(t);if(!_)return null;const N=_.parts.flatMap((k,S)=>sc(k.text,e.status==="pending")?[{part:k,index:S}]:[]);if(!N.length)return null;const v=typeof t=="string"?JSON.parse(t):t,j=N.map(({part:k,index:S})=>{const $=v[S],T=k.kind==="command-output"?JSON.parse($.text):null;return{index:S,result:{...e.toolResult,content:k.text,structured:void 0,isError:n},replaceText:E=>({...$,text:T?JSON.stringify(T.status==="fulfilled"?{...T,value:{...T.value,output:E}}:{...T,output:E}):k.kind==="script-status"?$.text:E})}}),C=_.parts.flatMap((k,S)=>k.kind==="script-status"?[]:[{index:S,text:k.text}]),w={source:t,blocks:v,parts:j,textParts:C};return e.toolResult&&e.status!=="pending"&&Qi.set(e.toolResult,w),w},[t,e.toolResult,e.status,n]),[o,i]=m.useState(()=>new Map),a=m.useCallback((b,_,N)=>{i(v=>{var j,C;return v.has(b)&&((j=v.get(b))==null?void 0:j.result)===_&&((C=v.get(b))==null?void 0:C.workflow)===N?v:new Map(v).set(b,{result:_,workflow:N})})},[]),l=Ut(e.toolInput),c=m.useMemo(()=>({cmd:l==null?void 0:l.source}),[l==null?void 0:l.source]);if(!r||e.supported===!1)return e.children(e.toolInput,e.toolResult,e.workflow);const d=[...r.blocks];for(const b of r.parts)d[b.index]=b.replaceText(((y=(p=o.get(b.index))==null?void 0:p.result)==null?void 0:y.content)??"");const u=(x=e.workflow)==null?void 0:x.toolContext,f=u?Km(r.textParts.map(b=>{var _;return r.parts.some(N=>N.index===b.index)?((_=o.get(b.index))==null?void 0:_.workflow)??{markers:[],outputText:""}:Jn([[{id:String(b.index),kind:"data",text:b.text}]],u).data})):e.workflow;return s.jsxs(s.Fragment,{children:[e.children(e.toolInput,{...e.toolResult,content:JSON.stringify(d),structured:d,isError:n},f),r.parts.map(b=>m.createElement(rc,{...e,key:b.index,id:`${e.id}:${b.index}`,toolName:"Exec output",toolInput:c,toolResult:b.result},(_,N,v)=>s.jsx(Rb,{index:b.index,result:N,workflow:v,project:a})))]})}function Rb({index:e,result:t,workflow:n,project:r}){return m.useLayoutEffect(()=>r(e,t,n),[e,t,n,r]),null}function Pb(e){var l;const{acliCommentaryEnabled:t}=vd(),n=ge(),r=ps(),o=Kt(),i=Aa(o.sourceKey);if(!t||!n||r)return e.children(e.toolInput,e.toolResult,e.workflow);const a=e.toolName==="Exec"?Tb:rc;return s.jsx(a,{...e,projectId:n.projectId,runtime:o,supported:i?ga(i,xa):null},`${o.sourceKey}:${n.projectId}:${n.sessionId}:${e.id}:${JSON.stringify((l=e.workflow)==null?void 0:l.toolContext)}`)}function rc(e){const t=m.useMemo(()=>nc({toolName:e.toolName,toolInput:e.toolInput,toolResult:e.toolResult,status:e.status}),[e.toolResult,e.toolInput,e.toolName,e.status]),[n,r]=m.useState(null),o=[t.stdout,t.stderr].some(a=>sc(a,e.status==="pending"));if(n===null&&(e.supported===!1?r("raw"):o&&e.supported?r("commentary"):!o&&(e.status!=="pending"||t.stdout.includes(`
|
|
100
100
|
`))&&r("raw")),n==="commentary")return s.jsx(Eb,{...e,output:t});if(n==="raw")return e.children(e.toolInput,e.toolResult,e.workflow);const i=Ut(e.toolInput);return e.children(i?{...i,_previewResult:void 0}:e.toolInput,void 0,void 0)}const Zi=new WeakMap;function Eb(e){var b,_;const{t}=Z(),n=Hr(e),[r]=m.useState((b=e.workflow)==null?void 0:b.toolContext),[o]=m.useState(()=>{var v;const N=e.toolResult?Zi.get(e.toolResult):void 0;return(N==null?void 0:N.sourceKey)===e.runtime.sourceKey&&N.workflowKey===JSON.stringify((v=e.workflow)==null?void 0:v.toolContext)&&N.source===e.output.stdout&&N.stderr===e.output.stderr&&e.status!=="pending"?N:null}),[i,a]=m.useState((o==null?void 0:o.projection)??null),[l,c]=m.useState(!1),d=m.useRef(null),u=m.useRef(null),f=m.useRef(e);f.current=e;const h=jn(e.toolInput)||e.toolName;m.useEffect(()=>{let N=new AbortController;const v=C=>new wb(w=>tc(e.runtime,e.projectId,w,N.signal),w=>{var S;a(w);const k=f.current;w.complete&&k.toolResult&&k.status!=="pending"&&Zi.set(k.toolResult,{sourceKey:k.runtime.sourceKey,source:k.output.stdout,stderr:k.output.stderr,projection:w,workflowKey:JSON.stringify((S=k.workflow)==null?void 0:S.toolContext)})},C,e.output.stdoutSequenced,r);u.current=()=>{var w;N.abort(),(w=d.current)==null||w.stop(),N=new AbortController,d.current=v();const C=f.current;d.current.appendSnapshot(C.output.stdout,C.status!=="pending",C.output.stderr)},d.current=v(o??void 0);const j=f.current;return d.current.appendSnapshot(j.output.stdout,j.status!=="pending",j.output.stderr),()=>{var C;N.abort(),(C=d.current)==null||C.stop(),d.current=null,u.current=null}},[e.projectId,e.runtime,e.output.stdoutSequenced,o,r]),m.useEffect(()=>{var N;d.current&&(d.current.appendSnapshot(e.output.stdout,e.status!=="pending",e.output.stderr)||(N=u.current)==null||N.call(u))},[e.output.stdout,e.output.stderr,e.status]);const g=m.useCallback(()=>c(!1),[]),p=m.useCallback(()=>c(!0),[]),y=m.useMemo(()=>{if(!i)return;const N=i.stderr;return{...e.toolResult,content:i.stdout,isError:n,structured:e.output.shell?{...e.output.shell,stdout:i.stdout,stderr:N}:e.output.stderr?{stdout:i.stdout,stderr:N}:void 0}},[e.toolResult,e.output,i,n]),x=m.useMemo(()=>{const N=Ut(e.toolInput);return N?{...N,_previewResult:y==null?void 0:y.structured}:e.toolInput},[e.toolInput,y]);return s.jsxs(s.Fragment,{children:[e.children(x,y,i==null?void 0:i.workflow),i?s.jsx(Cb,{items:i.commentary,command:h,onOpenOutput:p}):null,i!=null&&i.failed?s.jsx("span",{role:"status",children:t("acliCommentaryUnavailable")}):null,l?s.jsxs(Mt,{title:h,label:h,onClose:g,children:[e.output.shell?s.jsx(wl,{input:e.toolInput,result:y==null?void 0:y.structured,isError:n,projectPathLinks:(_=e.toolResult)==null?void 0:_.projectPathLinks}):s.jsx("pre",{children:i==null?void 0:i.stdout}),s.jsxs("details",{children:[s.jsx("summary",{children:t("workflowOriginalOutput")}),s.jsxs("pre",{children:[e.output.stdout,e.output.stderr?`
|
|
101
101
|
${e.output.stderr}`:""]})]})]}):null]})}const Ib="_expandedCommand_1gp9x_1",Mb="_disclosureAnchor_1gp9x_8",$b="_waitingRow_1gp9x_16",Lb="_waitingSummary_1gp9x_20",Ab="_waitingHeader_1gp9x_28",dn={expandedCommand:Ib,disclosureAnchor:Mb,waitingRow:$b,waitingSummary:Lb,waitingHeader:Ab},Ge={outputRowChromePx:12,previewBorderPx:2,emptyOutputRowPx:28,minOutputRowPx:35,outputLineHeightPx:18,minPx:28,maxPx:94,defaultContentWidthPx:720,minCharsPerLine:24,maxCharsPerLine:160,averageCharWidthPx:7.5},Ht={averageCharWidthPx:Ge.averageCharWidthPx,outputLineHeightPx:Ge.outputLineHeightPx,outputRowChromePx:Ge.outputRowChromePx},Ws=220;function kt(e,t,n){return Math.min(n,Math.max(t,e))}function Vn(e){const{toolInput:t,structuredResult:n,status:r,startTimestampMs:o,resultTimestampMs:i,nowMs:a}=e,l=t&&typeof t=="object"?t._backgroundTaskStatus:void 0;if(r==="pending"||l==="running")return typeof o=="number"?{seconds:(a-o)/1e3,kind:"running"}:null;const c=Ct(n);return c.durationSeconds!==void 0?{seconds:c.durationSeconds,kind:"reported"}:l!==void 0?null:typeof o=="number"&&typeof i=="number"&&i>=o?{seconds:(i-o)/1e3,kind:"approximate"}:null}function Fb(e){const t=Vn(e);if(!t)return null;const n=et(t.seconds);switch(t.kind){case"running":return`running for ${n}`;case"reported":return`took ${n}`;case"approximate":return`took ~${n}`}}function io(e){return{averageCharWidthPx:kt((e==null?void 0:e.averageCharWidthPx)??Ht.averageCharWidthPx,4,18),outputLineHeightPx:kt((e==null?void 0:e.outputLineHeightPx)??Ht.outputLineHeightPx,12,42),outputRowChromePx:kt((e==null?void 0:e.outputRowChromePx)??Ht.outputRowChromePx,4,32)}}function oc(e,t){const n=typeof e=="number"&&e>0?Math.max(120,e-112):Ge.defaultContentWidthPx,r=io(t);return kt(Math.floor(n/r.averageCharWidthPx),Ge.minCharsPerLine,Ge.maxCharsPerLine)}function ic(e,t){const n=e.replace(/\r\n/g,`
|
|
102
102
|
`).split(`
|
|
103
103
|
`);let r=0;for(const o of n)r+=Math.max(1,Math.ceil(o.length/t));return r}function Bb({hiddenChars:e,hiddenLines:t}){return t||e||null}function Db(e,t){const n=kt(Math.round(t),1,8),r=e.replace(/\r\n/g,`
|
|
104
104
|
`).split(`
|
|
105
105
|
`),o=r.slice(0,n);let i=0;const a=o.map(c=>c.length<=Ws?c:(i+=c.length-Ws,`${c.slice(0,Ws)}...`)).join(`
|
|
106
|
-
`),l=Math.max(0,r.length-o.length);return{text:a,hiddenCount:Bb({hiddenChars:i,hiddenLines:l})}}function Ob(e){if(!sn(e.status)||!ao(e.toolName))return null;const t=lo(e.result,e.status==="error").trimEnd();if(e.result===void 0&&!t)return null;const n=io(e.typography),r=oc(e.rowWidthPx,n),i=kt(Math.round(e.previewLineCount??4),1,8)*n.outputLineHeightPx,a=t?Math.max(Ge.minOutputRowPx,Math.min(i,ic(t,r)*n.outputLineHeightPx)+n.outputRowChromePx):e.result?Ge.emptyOutputRowPx:0;return kt(a+Ge.previewBorderPx,Ge.minPx,Math.max(Ge.maxPx,i+n.outputRowChromePx+Ge.previewBorderPx))}function ea(){if(typeof document>"u")return Ht;const e=document.createElement("span");e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.fontFamily="var(--output-prose-font-family)",e.style.fontSize="var(--output-prose-font-size)",e.style.lineHeight="var(--output-prose-line-height)",e.textContent="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",document.body.appendChild(e);const t=window.getComputedStyle(e),n=e.getBoundingClientRect(),r=Number.parseFloat(t.fontSize),o=Number.parseFloat(t.lineHeight);e.remove();const i=Number.isFinite(r)?r:Ht.outputLineHeightPx/1.5,a=n.width>0&&e.textContent?n.width/e.textContent.length:i*.5,l=Number.isFinite(o)?o:i*1.5,c=Ge.outputRowChromePx+(l-Ht.outputLineHeightPx)*.5;return io({averageCharWidthPx:a,outputLineHeightPx:l,outputRowChromePx:c})}function Ub(){const[e,t]=m.useState(ea);return m.useEffect(()=>{const n=()=>t(ea());return n(),window.addEventListener(No,n),()=>window.removeEventListener(No,n)},[]),e}function ao(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function sn(e,t=!0){return t&&(e==="complete"||e==="error")}function Hb(e){let t=e.parentElement;for(;t;){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t;t=t.parentElement}return null}function Wb(e){if(!e)return;const t=Hb(e);if(!t)return;const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(0,t.scrollTop+r.top-n.top-12);t.scrollTop=o,t.dispatchEvent(new Event("scroll"))}function Vb(e){const t=()=>Wb(e.current);t(),typeof window.requestAnimationFrame=="function"&&window.requestAnimationFrame(t),window.setTimeout(t,80)}function Gb(e,t){const n=m.useRef(null),[r,o]=m.useState(null),[i,a]=m.useState(()=>!sn(e,t)||typeof window>"u"||typeof IntersectionObserver>"u");return m.useEffect(()=>{if(!sn(e,t)){a(!0);return}if(typeof IntersectionObserver>"u"){a(!0);return}a(!1)},[e,t]),m.useLayoutEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l)return;const c=Math.round(l.getBoundingClientRect().width);c>0&&o(d=>d===c?d:c)},[i,e,t]),m.useEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l){a(!0);return}const c=new IntersectionObserver(d=>{d.some(u=>u.isIntersecting)&&(a(!0),c.disconnect())},{root:null,rootMargin:Kd});return c.observe(l),()=>c.disconnect()},[i,e,t]),{rowRef:n,shouldHydrate:i,hydrateNow:()=>a(!0),rowWidthPx:r}}const zb=m.memo(function(t){var r,o;const n=((r=t.toolResult)==null?void 0:r.structured)??((o=t.toolResult)==null?void 0:o.content);return s.jsx(cl,{...t,toolResult:n,children:s.jsx(Pb,{...t,children:(i,a,l)=>s.jsx(qb,{...t,toolInput:i,toolResult:a,workflow:l,originalOutput:n})})})});function qb(e){var c,d,u,f,h,g;const{t}=Z(),n=((c=e.toolResult)==null?void 0:c.structured)??((d=e.toolResult)==null?void 0:d.content),r=m.useMemo(()=>{var p;return ze.prepare(e.toolName,{input:e.toolInput,result:n,status:e.status,isError:(p=e.toolResult)==null?void 0:p.isError})},[e.toolName,e.toolInput,n,e.status,(u=e.toolResult)==null?void 0:u.isError]),o=ze.metadata(e.toolName),{enabled:i,reportValidationError:a}=ve();if(m.useEffect(()=>{var y;if(r.kind!=="raw"||!i||!((y=e.toolResult)!=null&&y.structured))return;const p=we(o.tool,e.toolResult.structured);!p.valid&&p.errors&&a(o.tool,p.errors)},[r.kind,i,(f=e.toolResult)==null?void 0:f.structured,o.tool,a]),(g=(h=e.toolResult)==null?void 0:h.media)!=null&&g.length)return s.jsx(ob,{displayName:r.getDisplayName(),media:e.toolResult.media,sourcePath:lb(e.toolName,e.toolInput,e.toolResult.media.length),status:e.status});if(r.kind==="raw"&&o.registered)return s.jsx(Ur,{...e,toolResult:n});const l=Kb(o.tool,e,n);return l?s.jsx("div",{className:`tool-row timeline-item ${dn.waitingRow}`,children:s.jsxs("div",{className:`tool-row-header ${dn.waitingHeader}`,children:[s.jsx("span",{className:"tool-name",children:t("toolShellPollWaitingLabel")}),s.jsx("span",{className:dn.waitingSummary,children:t("toolShellPollWaitingSummary",{target:l})})]})}):s.jsx(Xb,{...e,prepared:r})}function Kb(e,t,n){var o;if(e!=="Bash"&&e!=="WriteStdin"||t.status!=="complete"&&t.status!=="error"||t.workflow||It(t.toolInput)&&(t.toolInput.chars||t.toolInput.linked_file_path))return;const r=Jl(n,t.status==="error",(o=t.toolResult)==null?void 0:o.content);return(r==null?void 0:r.kind)==="waiting"?r.target:void 0}const Xb=m.memo(function({id:t,toolName:n,toolInput:r,toolResult:o,workflow:i,status:a,sessionProvider:l,startTimestampMs:c,resultTimestampMs:d,originalOutput:u,prepared:f}){const[h,g]=Dt(t,"interactive-summary",!1),[p,y]=Dt(t,"bash-command",!1),{enabled:x,reportValidationError:b}=ve(),_=ge(),N=us(),v=Ub(),j=pa(),C=m.useCallback(()=>{g(H=>!H)},[g]),w=m.useMemo(()=>({isStreaming:a==="pending",theme:"dark",toolUseId:t,provider:l,projectPath:(_==null?void 0:_.projectPath)??null,projectPathLinks:o==null?void 0:o.projectPathLinks}),[a,t,l,_==null?void 0:_.projectPath,o==null?void 0:o.projectPathLinks]),k=m.useMemo(()=>({...w,summaryExpanded:h,toggleSummaryExpanded:C}),[w,h,C]),S=(o==null?void 0:o.structured)??(o==null?void 0:o.content),{stableToolPreviewRendering:$}=tu(),{rowRef:T,shouldHydrate:E,hydrateNow:R,rowWidthPx:D}=Gb(a,!$);m.useEffect(()=>{if(!(a!=="pending"||!T.current))return qd(T.current)},[T,a]);const K=ze.hasInlineRenderer(n),V=Jb(n,S,o==null?void 0:o.content,a),G=Yb(n,r,S,a,V!==null),W=ze.metadata(n).tool;m.useEffect(()=>{if(!x||E||!S||W==="Bash"&&typeof S!="object")return;const H=we(W,S);!H.valid&&H.errors&&b(W,H.errors)},[W,b,x,E,S]);const ie=(f.kind==="partial"||ze.hasCollapsedPreview(n))&&!G,ae=W==="Edit",Pe=W==="Read",se=W==="Bash",Se=se?fr(S,o==null?void 0:o.content,a==="error"):void 0,F=Se!==void 0&&Se!==0,O=W==="Grep",Ce=m.useCallback(H=>{se&&Lt(H.currentTarget,Fb({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),j)},[se,r,S,a,c,d,j]),je=a==="complete"||a==="error"&&W==="WriteStdin"||a==="pending"&&ae,He=je&&ze.hasInteractiveSummary(n),ue=m.useMemo(()=>Ob({toolName:n,result:S,status:a,rowWidthPx:D,typography:v,previewLineCount:N}),[n,r,S,a,D,v,N]),Fe=m.useMemo(()=>!je||!ze.hasInteractiveSummary(n)||!E?null:f.renderInteractiveSummary(k),[n,k,f,E,je]),Oe=Fe!=null&&Fe!==!1,We=m.useMemo(()=>G||f.kind!=="partial"&&!ze.hasCollapsedPreview(n)&&!(i!=null&&i.view)||!E?null:i!=null&&i.view&&o&&(i.markers.length>0||i.view==="matching-lines")?s.jsx(ec,{text:i.outputText??o.content,workflow:i,original:s.jsx("pre",{children:typeof u=="string"?u:JSON.stringify(u,null,2)})}):f.renderCollapsedPreview(w),[n,G,i,u,o,w,f,E]),re=We!=null&&We!==!1,U=se&&re||ae&&re&&o!==void 0,z=!E&&ie&&ue!==null,X=!E&&(ie||He),[xe,L]=Dt(t,"rich-preview",!0),B=Oe||re||X,Q=W==="WriteStdin",pe=m.useMemo(()=>{if(!Q||a!=="complete"||o!=null&&o.isError)return!1;const H=Me(typeof(o==null?void 0:o.content)=="string"?o.content:"").output.trim();if(H.length===0)return!1;const ee=oc(D,v);return ic(H,ee)<=N},[Q,a,o,N,D,v]),ye=!B&&(n==="Edit"||n==="TodoWrite"||pe),[me,Be,ot]=Dt(t,"tool-result",ye),Je=m.useRef(ot);m.useEffect(()=>{pe&&!Je.current&&Be(!0)},[Be,pe]);const[gt,$t]=Dt(t,"inline-tool-result",!1),qe=m.useRef(!1),wn=B&&Oe&&E&&Pe,Qt=O&&He,vc=!B||wn||U||Qt,_n=wn,Nn=U&&E,wc=H=>{H.stopPropagation(),R(),U?L(ee=>(ee||(qe.current=!0),!ee)):Qt?g(ee=>!ee):B?wn&&$t(ee=>(ee||(qe.current=!0),!ee)):(Je.current=!0,Be(ee=>(ee||(qe.current=!0),!ee)))},_c=m.useMemo(()=>mb(n,r,o,a,{projectPath:(_==null?void 0:_.projectPath)??null},f),[n,r,o,a,_==null?void 0:_.projectPath,f]),le=se?jn(r):"",po=xs(It(r)?r._projectPathLinks:void 0),ks=se&&It(r)&&typeof r.description=="string"&&r.description.trim().length>0,Zt=se&&!ks&&le.length>0,xt=m.useMemo(()=>Db(le,N),[le,N]),kn=!p&&xt.hiddenCount!==null&&xt.hiddenCount>0,go=rt(Zt?!V&&p?le:xt.text:""),xo=m.useRef(le);m.useEffect(()=>{xo.current!==le&&(xo.current=le,y(!1))},[le,y]);const yo=m.useCallback(H=>{const ee=H.currentTarget.querySelector(".tool-summary-command-text")??H.currentTarget,yt=kn||!od(ee);if(!le||!yt){Lt(H.currentTarget,null,j);return}const jt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,jt?`[${et(jt.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,kn,j]),Nc=m.useCallback(H=>{if(!le){Lt(H.currentTarget,null,j);return}const ee=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,ee?`[${et(ee.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,j]),kc=m.useCallback(H=>{if(!se)return;const ee=lo(S,a==="error").trimEnd(),yt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),jt=yt?`[${et(yt.seconds)}] `:"",Tc=Yt(ee,N,jt),Sn=H.currentTarget.querySelector(".bash-preview-output"),Rc=(Sn==null?void 0:Sn.querySelector("pre, .fixed-font-rendered__content"))??Sn??H.currentTarget;Lt(H.currentTarget,id(Rc,`${jt}${ee}`,Tc),j)},[se,S,N,r,a,c,d,j]),jo=()=>{R(),B||(Je.current=!0,Be(H=>(H||(qe.current=!0),!H)))},bo=()=>{L(H=>(H||(qe.current=!0),!H))},Sc=B?U?xe?"Collapse preview":"Expand preview":Qt?h?"Collapse summary":"Expand summary":gt?"Collapse inline view":"Expand inline view":me?"Collapse":"Expand",Cc=B?U?xe:Qt?h:gt:me;return m.useLayoutEffect(()=>{!qe.current||!me&&!gt&&!xe||(qe.current=!1,Vb(T))},[xe,me,gt,T]),K?s.jsx("div",{className:"tool-inline timeline-item",children:f.renderInline(w)}):s.jsxs("div",{ref:T,onPointerEnter:R,onFocus:R,className:`tool-row timeline-item ${me?"expanded":"collapsed"} status-${a} ${B?"interactive":""} ${E?"":"rich-deferred"} ${se?"ran-tool-row":""}`,children:[s.jsxs("div",{className:["tool-row-header",B?"non-expandable":"",Zt?"has-command-preview":"",V||F?"has-result-suffix":""].filter(Boolean).join(" "),onClick:X?R:Nn?bo:_n?()=>$t(H=>(H||(qe.current=!0),!H)):B?void 0:jo,onKeyDown:X?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),R())}:Nn?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),bo())}:_n?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),$t(ee=>(ee||(qe.current=!0),!ee)))}:B?void 0:H=>H.key==="Enter"&&jo(),role:X||Nn||_n||!B?"button":"presentation",tabIndex:X||Nn||_n||!B?0:void 0,children:[a==="pending"&&s.jsx("span",{className:"tool-spinner",role:"status","aria-label":"Running",children:s.jsx(nv,{})}),a==="aborted"&&s.jsx("span",{className:"tool-aborted-icon",role:"img","aria-label":"Interrupted",children:"⨯"}),a==="incomplete"&&s.jsx("span",{className:"tool-incomplete-icon",role:"img","aria-label":"Result unavailable",children:"?"}),s.jsxs("span",{className:"tool-name",onPointerEnter:Ce,children:[s.jsx("span",{className:dn.disclosureAnchor,children:vc&&s.jsx(ro,{inline:!0,onClick:wc,label:Sc,expanded:Cc,status:a})}),f.getDisplayName()]}),Oe&&je?s.jsx("span",{className:`tool-summary interactive-summary${Qt?" outline-summary":""}`,children:Fe}):Zt&&V?s.jsx("span",{className:"tool-summary tool-summary-command",...Ss(kn?le:null,j),onPointerEnter:yo,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:xt.text,links:po})})}):Zt?s.jsx("span",{className:["tool-summary","tool-summary-command",p?dn.expandedCommand:""].filter(Boolean).join(" "),...Ss(kn?le:null,j),onPointerEnter:yo,"aria-label":p?"Collapse command":"Show full command","aria-expanded":p,onClick:H=>{var ee,yt;(yt=(ee=H.target)==null?void 0:ee.closest)!=null&&yt.call(ee,"a,button")||(H.preventDefault(),H.stopPropagation(),y(jt=>!jt))},onKeyDown:H=>{H.target===H.currentTarget&&(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),H.stopPropagation(),y(ee=>!ee))},role:"button",tabIndex:0,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:p?le:xt.text,links:po})})}):s.jsxs("span",{className:"tool-summary",...ks&&le?Ss(le,j):{},onPointerEnter:ks&&le?Nc:void 0,children:[_c,a==="aborted"&&s.jsx("span",{className:"tool-aborted-label",children:" (interrupted)"}),a==="incomplete"&&s.jsxs("span",{className:"tool-incomplete-label",children:[" ","(result unavailable)"]})]}),V&&s.jsx("span",{className:"tool-result-suffix",children:"(no output)"}),F&&s.jsxs("span",{className:"tool-result-suffix tool-result-suffix-rc",children:["rc=",Se]}),le&&s.jsx(ov,{text:le,label:"Copy command"}),Zt&&!p&&xt.hiddenCount&&s.jsx(Tt,{className:"tool-summary-command-more",count:xt.hiddenCount,tooltip:le})]}),re&&xe&&s.jsxs("div",{className:"tool-row-collapsed-preview",onPointerEnter:kc,children:[U&&s.jsx(Vs,{onCollapse:()=>L(!1),ariaLabel:"Collapse preview from left gutter"}),We]}),z&&s.jsx("div",{className:"tool-row-collapsed-preview tool-row-deferred-preview",style:{"--tool-row-deferred-preview-height":`${ue}px`},"aria-hidden":"true",children:s.jsx("div",{className:"tool-row-deferred-preview-box"})}),gt&&wn&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>$t(!1)}),s.jsx(ta,{prepared:f,toolResult:o,context:w})]}),me&&!B&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>{Je.current=!0,Be(!1)}}),V&&se?s.jsx(ev,{command:le}):a==="pending"||a==="aborted"||a==="incomplete"?s.jsx(tv,{prepared:f,context:w}):s.jsx(ta,{prepared:f,toolResult:o,context:w})]})]})});function Vs({onCollapse:e,ariaLabel:t="Collapse expanded tool row"}){return s.jsx("button",{type:"button",className:"tool-row-collapse-strip",onClick:n=>{n.stopPropagation(),e()},"aria-label":t,title:t})}function Yb(e,t,n,r,o=!1){return ao(e)?r==="pending"?!Zb(t):n===void 0||o:!1}function Jb(e,t,n,r){if(!ao(e)||r!=="complete"&&r!=="error"||t===void 0)return null;const o=r==="error";return lo(t,o).trim().length>0?null:It(t)?t.interrupted===!0||t.backgroundTaskId!==void 0?null:{exitCode:fr(t,n,o)}:{exitCode:fr(t,n,o)}}function fr(e,t,n=!1){if(typeof e=="string")return Me(e,{bareExitCodeIsEnvelope:n}).exitCode;if(It(e)){const r=Qb(e,["exitCode","exit_code","returnCode","return_code","rc"]);if(r!==void 0)return r;if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:n}).exitCode;if(o!==void 0)return o}}return t?Me(t,{bareExitCodeIsEnvelope:n}).exitCode:void 0}function Qb(e,t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"&&/^-?\d+$/.test(r.trim()))return Number.parseInt(r,10)}}function It(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Zb(e){return It(e)&&e._previewResult!==void 0}function lo(e,t=!1){if(typeof e=="string"){const o=Me(e,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e}if(!It(e))return"";const n=typeof e.stdout=="string"?e.stdout:"",r=typeof e.stderr=="string"?e.stderr:"";if(n||r)return[n,r].filter(Boolean).join(`
|
|
107
|
-
`);if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e.content}return""}function ev({command:e}){const t=
|
|
106
|
+
`),l=Math.max(0,r.length-o.length);return{text:a,hiddenCount:Bb({hiddenChars:i,hiddenLines:l})}}function Ob(e){if(!sn(e.status)||!ao(e.toolName))return null;const t=lo(e.result,e.status==="error").trimEnd();if(e.result===void 0&&!t)return null;const n=io(e.typography),r=oc(e.rowWidthPx,n),i=kt(Math.round(e.previewLineCount??4),1,8)*n.outputLineHeightPx,a=t?Math.max(Ge.minOutputRowPx,Math.min(i,ic(t,r)*n.outputLineHeightPx)+n.outputRowChromePx):e.result?Ge.emptyOutputRowPx:0;return kt(a+Ge.previewBorderPx,Ge.minPx,Math.max(Ge.maxPx,i+n.outputRowChromePx+Ge.previewBorderPx))}function ea(){if(typeof document>"u")return Ht;const e=document.createElement("span");e.style.position="absolute",e.style.left="-9999px",e.style.top="-9999px",e.style.visibility="hidden",e.style.whiteSpace="pre",e.style.fontFamily="var(--output-prose-font-family)",e.style.fontSize="var(--output-prose-font-size)",e.style.lineHeight="var(--output-prose-line-height)",e.textContent="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",document.body.appendChild(e);const t=window.getComputedStyle(e),n=e.getBoundingClientRect(),r=Number.parseFloat(t.fontSize),o=Number.parseFloat(t.lineHeight);e.remove();const i=Number.isFinite(r)?r:Ht.outputLineHeightPx/1.5,a=n.width>0&&e.textContent?n.width/e.textContent.length:i*.5,l=Number.isFinite(o)?o:i*1.5,c=Ge.outputRowChromePx+(l-Ht.outputLineHeightPx)*.5;return io({averageCharWidthPx:a,outputLineHeightPx:l,outputRowChromePx:c})}function Ub(){const[e,t]=m.useState(ea);return m.useEffect(()=>{const n=()=>t(ea());return n(),window.addEventListener(No,n),()=>window.removeEventListener(No,n)},[]),e}function ao(e){const t=e.toLowerCase();return t==="bash"||t==="exec_command"||t==="shell_command"}function sn(e,t=!0){return t&&(e==="complete"||e==="error")}function Hb(e){let t=e.parentElement;for(;t;){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t;t=t.parentElement}return null}function Wb(e){if(!e)return;const t=Hb(e);if(!t)return;const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),o=Math.max(0,t.scrollTop+r.top-n.top-12);t.scrollTop=o,t.dispatchEvent(new Event("scroll"))}function Vb(e){const t=()=>Wb(e.current);t(),typeof window.requestAnimationFrame=="function"&&window.requestAnimationFrame(t),window.setTimeout(t,80)}function Gb(e,t){const n=m.useRef(null),[r,o]=m.useState(null),[i,a]=m.useState(()=>!sn(e,t)||typeof window>"u"||typeof IntersectionObserver>"u");return m.useEffect(()=>{if(!sn(e,t)){a(!0);return}if(typeof IntersectionObserver>"u"){a(!0);return}a(!1)},[e,t]),m.useLayoutEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l)return;const c=Math.round(l.getBoundingClientRect().width);c>0&&o(d=>d===c?d:c)},[i,e,t]),m.useEffect(()=>{if(i||!sn(e,t))return;const l=n.current;if(!l){a(!0);return}const c=new IntersectionObserver(d=>{d.some(u=>u.isIntersecting)&&(a(!0),c.disconnect())},{root:null,rootMargin:Kd});return c.observe(l),()=>c.disconnect()},[i,e,t]),{rowRef:n,shouldHydrate:i,hydrateNow:()=>a(!0),rowWidthPx:r}}const zb=m.memo(function(t){var r,o;const n=((r=t.toolResult)==null?void 0:r.structured)??((o=t.toolResult)==null?void 0:o.content);return s.jsx(cl,{...t,toolResult:n,children:s.jsx(Pb,{...t,children:(i,a,l)=>s.jsx(qb,{...t,toolInput:i,toolResult:a,workflow:l,originalOutput:n})})})});function qb(e){var c,d,u,f,h,g;const{t}=Z(),n=((c=e.toolResult)==null?void 0:c.structured)??((d=e.toolResult)==null?void 0:d.content),r=m.useMemo(()=>{var p;return ze.prepare(e.toolName,{input:e.toolInput,result:n,status:e.status,isError:(p=e.toolResult)==null?void 0:p.isError})},[e.toolName,e.toolInput,n,e.status,(u=e.toolResult)==null?void 0:u.isError]),o=ze.metadata(e.toolName),{enabled:i,reportValidationError:a}=ve();if(m.useEffect(()=>{var y;if(r.kind!=="raw"||!i||!((y=e.toolResult)!=null&&y.structured))return;const p=we(o.tool,e.toolResult.structured);!p.valid&&p.errors&&a(o.tool,p.errors)},[r.kind,i,(f=e.toolResult)==null?void 0:f.structured,o.tool,a]),(g=(h=e.toolResult)==null?void 0:h.media)!=null&&g.length)return s.jsx(ob,{displayName:r.getDisplayName(),media:e.toolResult.media,sourcePath:lb(e.toolName,e.toolInput,e.toolResult.media.length),status:e.status});if(r.kind==="raw"&&o.registered)return s.jsx(Ur,{...e,toolResult:n});const l=Kb(o.tool,e,n);return l?s.jsx("div",{className:`tool-row timeline-item ${dn.waitingRow}`,children:s.jsxs("div",{className:`tool-row-header ${dn.waitingHeader}`,children:[s.jsx("span",{className:"tool-name",children:t("toolShellPollWaitingLabel")}),s.jsx("span",{className:dn.waitingSummary,children:t("toolShellPollWaitingSummary",{target:l})})]})}):s.jsx(Xb,{...e,prepared:r})}function Kb(e,t,n){var o;if(e!=="Bash"&&e!=="WriteStdin"||t.status!=="complete"&&t.status!=="error"||t.workflow||It(t.toolInput)&&(t.toolInput.chars||t.toolInput.linked_file_path))return;const r=Jl(n,t.status==="error",(o=t.toolResult)==null?void 0:o.content);return(r==null?void 0:r.kind)==="waiting"?r.target:void 0}const Xb=m.memo(function({id:t,toolName:n,toolInput:r,toolResult:o,workflow:i,status:a,sessionProvider:l,startTimestampMs:c,resultTimestampMs:d,originalOutput:u,prepared:f}){const[h,g]=Dt(t,"interactive-summary",!1),[p,y]=Dt(t,"bash-command",!1),{enabled:x,reportValidationError:b}=ve(),_=ge(),N=us(),v=Ub(),j=pa(),C=m.useCallback(()=>{g(H=>!H)},[g]),w=m.useMemo(()=>({isStreaming:a==="pending",theme:"dark",toolUseId:t,provider:l,projectPath:(_==null?void 0:_.projectPath)??null,projectPathLinks:o==null?void 0:o.projectPathLinks}),[a,t,l,_==null?void 0:_.projectPath,o==null?void 0:o.projectPathLinks]),k=m.useMemo(()=>({...w,summaryExpanded:h,toggleSummaryExpanded:C}),[w,h,C]),S=(o==null?void 0:o.structured)??(o==null?void 0:o.content),{stableToolPreviewRendering:$}=tu(),{rowRef:T,shouldHydrate:E,hydrateNow:R,rowWidthPx:D}=Gb(a,!$);m.useEffect(()=>{if(!(a!=="pending"||!T.current))return qd(T.current)},[T,a]);const K=ze.hasInlineRenderer(n),V=Jb(n,S,o==null?void 0:o.content,a),G=Yb(n,r,S,a,V!==null),W=ze.metadata(n).tool;m.useEffect(()=>{if(!x||E||!S||W==="Bash"&&typeof S!="object")return;const H=we(W,S);!H.valid&&H.errors&&b(W,H.errors)},[W,b,x,E,S]);const ie=(f.kind==="partial"||ze.hasCollapsedPreview(n))&&!G,ae=W==="Edit",Pe=W==="Read",se=W==="Bash",Se=se?fr(S,o==null?void 0:o.content,a==="error"):void 0,F=Se!==void 0&&Se!==0,O=W==="Grep",Ce=m.useCallback(H=>{se&&Lt(H.currentTarget,Fb({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),j)},[se,r,S,a,c,d,j]),je=a==="complete"||a==="error"&&W==="WriteStdin"||a==="pending"&&ae,He=je&&ze.hasInteractiveSummary(n),ue=m.useMemo(()=>Ob({toolName:n,result:S,status:a,rowWidthPx:D,typography:v,previewLineCount:N}),[n,r,S,a,D,v,N]),Fe=m.useMemo(()=>!je||!ze.hasInteractiveSummary(n)||!E?null:f.renderInteractiveSummary(k),[n,k,f,E,je]),Oe=Fe!=null&&Fe!==!1,We=m.useMemo(()=>G||f.kind!=="partial"&&!ze.hasCollapsedPreview(n)&&!(i!=null&&i.view)||!E?null:i!=null&&i.view&&o&&(i.markers.length>0||i.view==="matching-lines")?s.jsx(ec,{text:i.outputText??o.content,workflow:i,original:s.jsx("pre",{children:typeof u=="string"?u:JSON.stringify(u,null,2)})}):f.renderCollapsedPreview(w),[n,G,i,u,o,w,f,E]),re=We!=null&&We!==!1,U=se&&re||ae&&re&&o!==void 0,z=!E&&ie&&ue!==null,X=!E&&(ie||He),[xe,L]=Dt(t,"rich-preview",!0),B=Oe||re||X,Q=W==="WriteStdin",pe=m.useMemo(()=>{if(!Q||a!=="complete"||o!=null&&o.isError)return!1;const H=Me(typeof(o==null?void 0:o.content)=="string"?o.content:"").output.trim();if(H.length===0)return!1;const ee=oc(D,v);return ic(H,ee)<=N},[Q,a,o,N,D,v]),ye=!B&&(n==="Edit"||n==="TodoWrite"||pe),[me,Be,rt]=Dt(t,"tool-result",ye),Je=m.useRef(rt);m.useEffect(()=>{pe&&!Je.current&&Be(!0)},[Be,pe]);const[gt,$t]=Dt(t,"inline-tool-result",!1),qe=m.useRef(!1),wn=B&&Oe&&E&&Pe,Qt=O&&He,vc=!B||wn||U||Qt,_n=wn,Nn=U&&E,wc=H=>{H.stopPropagation(),R(),U?L(ee=>(ee||(qe.current=!0),!ee)):Qt?g(ee=>!ee):B?wn&&$t(ee=>(ee||(qe.current=!0),!ee)):(Je.current=!0,Be(ee=>(ee||(qe.current=!0),!ee)))},_c=m.useMemo(()=>mb(n,r,o,a,{projectPath:(_==null?void 0:_.projectPath)??null},f),[n,r,o,a,_==null?void 0:_.projectPath,f]),le=se?jn(r):"",po=xs(It(r)?r._projectPathLinks:void 0),ks=se&&It(r)&&typeof r.description=="string"&&r.description.trim().length>0,Zt=se&&!ks&&le.length>0,xt=m.useMemo(()=>Db(le,N),[le,N]),kn=!p&&xt.hiddenCount!==null&&xt.hiddenCount>0,go=st(Zt?!V&&p?le:xt.text:""),xo=m.useRef(le);m.useEffect(()=>{xo.current!==le&&(xo.current=le,y(!1))},[le,y]);const yo=m.useCallback(H=>{const ee=H.currentTarget.querySelector(".tool-summary-command-text")??H.currentTarget,yt=kn||!od(ee);if(!le||!yt){Lt(H.currentTarget,null,j);return}const jt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,jt?`[${et(jt.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,kn,j]),Nc=m.useCallback(H=>{if(!le){Lt(H.currentTarget,null,j);return}const ee=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()});Lt(H.currentTarget,ee?`[${et(ee.seconds)}] ${le}`:le,j)},[le,r,S,a,c,d,j]),kc=m.useCallback(H=>{if(!se)return;const ee=lo(S,a==="error").trimEnd(),yt=Vn({toolInput:r,structuredResult:S,status:a,startTimestampMs:c,resultTimestampMs:d,nowMs:Date.now()}),jt=yt?`[${et(yt.seconds)}] `:"",Tc=Yt(ee,N,jt),Sn=H.currentTarget.querySelector(".bash-preview-output"),Rc=(Sn==null?void 0:Sn.querySelector("pre, .fixed-font-rendered__content"))??Sn??H.currentTarget;Lt(H.currentTarget,id(Rc,`${jt}${ee}`,Tc),j)},[se,S,N,r,a,c,d,j]),jo=()=>{R(),B||(Je.current=!0,Be(H=>(H||(qe.current=!0),!H)))},bo=()=>{L(H=>(H||(qe.current=!0),!H))},Sc=B?U?xe?"Collapse preview":"Expand preview":Qt?h?"Collapse summary":"Expand summary":gt?"Collapse inline view":"Expand inline view":me?"Collapse":"Expand",Cc=B?U?xe:Qt?h:gt:me;return m.useLayoutEffect(()=>{!qe.current||!me&&!gt&&!xe||(qe.current=!1,Vb(T))},[xe,me,gt,T]),K?s.jsx("div",{className:"tool-inline timeline-item",children:f.renderInline(w)}):s.jsxs("div",{ref:T,onPointerEnter:R,onFocus:R,className:`tool-row timeline-item ${me?"expanded":"collapsed"} status-${a} ${B?"interactive":""} ${E?"":"rich-deferred"} ${se?"ran-tool-row":""}`,children:[s.jsxs("div",{className:["tool-row-header",B?"non-expandable":"",Zt?"has-command-preview":"",V||F?"has-result-suffix":""].filter(Boolean).join(" "),onClick:X?R:Nn?bo:_n?()=>$t(H=>(H||(qe.current=!0),!H)):B?void 0:jo,onKeyDown:X?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),R())}:Nn?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),bo())}:_n?H=>{(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),$t(ee=>(ee||(qe.current=!0),!ee)))}:B?void 0:H=>H.key==="Enter"&&jo(),role:X||Nn||_n||!B?"button":"presentation",tabIndex:X||Nn||_n||!B?0:void 0,children:[a==="pending"&&s.jsx("span",{className:"tool-spinner",role:"status","aria-label":"Running",children:s.jsx(nv,{})}),a==="aborted"&&s.jsx("span",{className:"tool-aborted-icon",role:"img","aria-label":"Interrupted",children:"⨯"}),a==="incomplete"&&s.jsx("span",{className:"tool-incomplete-icon",role:"img","aria-label":"Result unavailable",children:"?"}),s.jsxs("span",{className:"tool-name",onPointerEnter:Ce,children:[s.jsx("span",{className:dn.disclosureAnchor,children:vc&&s.jsx(ro,{inline:!0,onClick:wc,label:Sc,expanded:Cc,status:a})}),f.getDisplayName()]}),Oe&&je?s.jsx("span",{className:`tool-summary interactive-summary${Qt?" outline-summary":""}`,children:Fe}):Zt&&V?s.jsx("span",{className:"tool-summary tool-summary-command",...Ss(kn?le:null,j),onPointerEnter:yo,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:xt.text,links:po})})}):Zt?s.jsx("span",{className:["tool-summary","tool-summary-command",p?dn.expandedCommand:""].filter(Boolean).join(" "),...Ss(kn?le:null,j),onPointerEnter:yo,"aria-label":p?"Collapse command":"Show full command","aria-expanded":p,onClick:H=>{var ee,yt;(yt=(ee=H.target)==null?void 0:ee.closest)!=null&&yt.call(ee,"a,button")||(H.preventDefault(),H.stopPropagation(),y(jt=>!jt))},onKeyDown:H=>{H.target===H.currentTarget&&(H.key==="Enter"||H.key===" ")&&(H.preventDefault(),H.stopPropagation(),y(ee=>!ee))},role:"button",tabIndex:0,children:s.jsx("span",{ref:go,className:"tool-summary-command-text",children:s.jsx(Wt,{text:p?le:xt.text,links:po})})}):s.jsxs("span",{className:"tool-summary",...ks&&le?Ss(le,j):{},onPointerEnter:ks&&le?Nc:void 0,children:[_c,a==="aborted"&&s.jsx("span",{className:"tool-aborted-label",children:" (interrupted)"}),a==="incomplete"&&s.jsxs("span",{className:"tool-incomplete-label",children:[" ","(result unavailable)"]})]}),V&&s.jsx("span",{className:"tool-result-suffix",children:"(no output)"}),F&&s.jsxs("span",{className:"tool-result-suffix tool-result-suffix-rc",children:["rc=",Se]}),le&&s.jsx(ov,{text:le,label:"Copy command"}),Zt&&!p&&xt.hiddenCount&&s.jsx(Tt,{className:"tool-summary-command-more",count:xt.hiddenCount,tooltip:le})]}),re&&xe&&s.jsxs("div",{className:"tool-row-collapsed-preview",onPointerEnter:kc,children:[U&&s.jsx(Vs,{onCollapse:()=>L(!1),ariaLabel:"Collapse preview from left gutter"}),We]}),z&&s.jsx("div",{className:"tool-row-collapsed-preview tool-row-deferred-preview",style:{"--tool-row-deferred-preview-height":`${ue}px`},"aria-hidden":"true",children:s.jsx("div",{className:"tool-row-deferred-preview-box"})}),gt&&wn&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>$t(!1)}),s.jsx(ta,{prepared:f,toolResult:o,context:w})]}),me&&!B&&s.jsxs("div",{className:"tool-row-content",children:[s.jsx(Vs,{onCollapse:()=>{Je.current=!0,Be(!1)}}),V&&se?s.jsx(ev,{command:le}):a==="pending"||a==="aborted"||a==="incomplete"?s.jsx(tv,{prepared:f,context:w}):s.jsx(ta,{prepared:f,toolResult:o,context:w})]})]})});function Vs({onCollapse:e,ariaLabel:t="Collapse expanded tool row"}){return s.jsx("button",{type:"button",className:"tool-row-collapse-strip",onClick:n=>{n.stopPropagation(),e()},"aria-label":t,title:t})}function Yb(e,t,n,r,o=!1){return ao(e)?r==="pending"?!Zb(t):n===void 0||o:!1}function Jb(e,t,n,r){if(!ao(e)||r!=="complete"&&r!=="error"||t===void 0)return null;const o=r==="error";return lo(t,o).trim().length>0?null:It(t)?t.interrupted===!0||t.backgroundTaskId!==void 0?null:{exitCode:fr(t,n,o)}:{exitCode:fr(t,n,o)}}function fr(e,t,n=!1){if(typeof e=="string")return Me(e,{bareExitCodeIsEnvelope:n}).exitCode;if(It(e)){const r=Qb(e,["exitCode","exit_code","returnCode","return_code","rc"]);if(r!==void 0)return r;if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:n}).exitCode;if(o!==void 0)return o}}return t?Me(t,{bareExitCodeIsEnvelope:n}).exitCode:void 0}function Qb(e,t){for(const n of t){const r=e[n];if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"&&/^-?\d+$/.test(r.trim()))return Number.parseInt(r,10)}}function It(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Zb(e){return It(e)&&e._previewResult!==void 0}function lo(e,t=!1){if(typeof e=="string"){const o=Me(e,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e}if(!It(e))return"";const n=typeof e.stdout=="string"?e.stdout:"",r=typeof e.stderr=="string"?e.stderr:"";if(n||r)return[n,r].filter(Boolean).join(`
|
|
107
|
+
`);if(typeof e.content=="string"){const o=Me(e.content,{bareExitCodeIsEnvelope:t});return o.hasEnvelope?o.output:e.content}return""}function ev({command:e}){const t=st(e);return e.trim()?s.jsx("pre",{ref:t,className:"code-block bash-no-output-command",children:s.jsx("code",{children:e})}):null}function tv({prepared:e,context:t}){return s.jsx("div",{className:"tool-use-expanded",children:e.renderToolUse(t)})}function ta({prepared:e,toolResult:t,context:n}){return t?s.jsx("div",{className:"tool-result-expanded",children:e.renderToolResult(n)}):s.jsx("div",{className:"tool-no-result",children:"No result data"})}function nv(){return s.jsx("svg",{className:"spinner",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:s.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"24",strokeDashoffset:"8"})})}function sv(){return s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.7","aria-hidden":"true",children:[s.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1.5"}),s.jsx("path",{d:"M3 10.5H2.5A1.5 1.5 0 0 1 1 9V2.5A1.5 1.5 0 0 1 2.5 1H9a1.5 1.5 0 0 1 1.5 1.5V3"})]})}function rv(){return s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:"M3 8.5 6.5 12 13 4"})})}function ov({text:e,label:t}){const[n,r]=m.useState(!1);return s.jsx("button",{type:"button",className:`tool-header-copy ${n?"copied":""}`,onClick:o=>{o.preventDefault(),o.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{r(!0),window.setTimeout(()=>r(!1),3e3)}).catch(i=>{console.error("Failed to copy tool header text:",i)})},"aria-label":n?"Copied":t,title:n?"Copied":t,children:n?s.jsx(rv,{}):s.jsx(sv,{})})}const iv="_thinkingPreviewLabel_yqj8y_20",av="_thinkingPreviewAge_yqj8y_33",lv="_activityChevron_yqj8y_40",cv="_activityChevronExpanded_yqj8y_51",dv="_activityPulse_yqj8y_55",uv="_activityLabel_yqj8y_66",mv="_activityHeightReserve_yqj8y_83",fv="_thinkingRollingUp_yqj8y_94",hv="_thinkingAutoHiding_yqj8y_114",pv="_compactBoundaryOutline_yqj8y_163",gv="_toolOutputDetails_yqj8y_173",xv="_rewoundGroupHeader_yqj8y_182",yv="_rewoundGroupToggleButton_yqj8y_189",jv="_rewoundItem_yqj8y_209",bv="_rewoundGroupToggle_yqj8y_189",vv="_rewoundGroupCopy_yqj8y_231",Ie={thinkingPreviewLabel:iv,thinkingPreviewAge:av,activityChevron:lv,activityChevronExpanded:cv,activityPulse:dv,activityLabel:uv,activityHeightReserve:mv,thinkingRollingUp:fv,thinkingAutoHiding:hv,compactBoundaryOutline:pv,toolOutputDetails:gv,rewoundGroupHeader:xv,rewoundGroupToggleButton:yv,rewoundItem:jv,rewoundGroupToggle:bv,rewoundGroupCopy:vv};function wv({text:e,workflow:t,isStreaming:n,original:r,renderText:o}){const i=Kt(),a=ge(),l=ps(),c=Aa(i.sourceKey),d=a==null?void 0:a.projectId,u=!l&&!!d&&!!c&&ga(c,xa),f=Ja(e,t),h=JSON.stringify(f.map(_=>_.text).filter(_=>_.trim())),g=m.useMemo(()=>JSON.parse(h),[h]),p=JSON.stringify([i.sourceKey,d,a==null?void 0:a.sessionId,h]),[y,x]=m.useState(null);if(m.useEffect(()=>{if(!u||!d||n)return;const _=new AbortController;return tc(i,d,g,_.signal).then(N=>{_.signal.aborted||x({key:p,html:N})},()=>{_.signal.aborted||x(null)}),()=>_.abort()},[i,d,u,n,g,p]),!u||n||(y==null?void 0:y.key)!==p)return r;let b=0;return s.jsx(ec,{text:e,workflow:t,original:r,preview:f.map((_,N)=>s.jsxs(m.Fragment,{children:[_.marker?s.jsx(oo,{marker:_.marker}):null,_.text.trim()?o(_.text,y.html[b++]):null]},N))})}function _v(e){return typeof e.uuid=="string"&&e.uuid.length>0?e.uuid:typeof e.id=="string"&&e.id.length>0?e.id:"<missing>"}function Nv(e){const t={sdk:0,jsonl:0,unknown:0},n={},r=[];let o=0,i=0;for(const a of e){const l=a._source==="sdk"||a._source==="jsonl"?a._source:"unknown";t[l]=(t[l]??0)+1;const c=typeof a.type=="string"?a.type:"unknown";n[c]=(n[c]??0)+1,c==="stream_event"&&o++,a._isStreaming&&i++,r.push(_v(a))}return{total:e.length,bySource:t,byType:n,streamEventCount:o,streamingPlaceholderCount:i,ids:r}}function kv(e,t){var r;const n=Nv(e.sourceMessages);return{render:{id:e.id,type:e.type,isSubagent:e.isSubagent??!1},uiContext:{sessionProvider:t.sessionProvider??"unknown",sessionIsStreaming:t.isStreaming,thinkingExpanded:t.thinkingExpanded},itemContext:e.type==="tool_call"?{toolName:e.toolName,status:e.status,hasToolResult:!!e.toolResult,hasStructuredResult:((r=e.toolResult)==null?void 0:r.structured)!==void 0,toolUseId:e.id}:e.type==="text"?{isStreamingTextBlock:e.isStreaming??!1,hasAugmentHtml:!!e.augmentHtml}:e.type==="thinking"?{status:e.status,thinkingLength:e.thinking.length}:e.type==="system"?{subtype:e.subtype,status:e.status??null}:e.type==="session_setup"?{promptCount:e.prompts.length}:null,sourceSummary:n,sourceMessages:e.sourceMessages,renderItem:e}}function ac(e){return typeof e=="string"?e:e.map(t=>t.type==="text"&&typeof t.text=="string"?t.text:t.type==="tool_result"&&typeof t.content=="string"?t.content:"").filter(Boolean).join(`
|
|
108
108
|
`)}const Sv="No provider summary was retained for this compaction.";function hr(e,t){return e==="/"&&t.trimStart().startsWith("/")?"":e}function Cv({item:e}){const{t}=Z(),n=ol(),r=xn(e),o=e.sourceMessages[0],i=(o==null?void 0:o.rewoundGroup)??{},a=r?n.expandedRewoundGroups.has(r):!1,l=String(i.droppedTurnCount??i.rowCount??0),c=String(i.cutTurnIndex??0),d=i.clearloopIteration!==void 0?t("rewoundGroupClearloopLabel",{iteration:String(i.clearloopIteration),total:String(i.clearloopTotal??"?"),prompt:i.clearloopPrompt??"",index:c}):t("rewoundGroupLabel",{index:c}),u=t("rewoundGroupTooltip",{count:l}),f=i.clearloopIteration!==void 0&&i.clearloopTotal!==void 0&&i.clearloopPrompt?`/clearloop ${c} ${Math.max(0,i.clearloopTotal-i.clearloopIteration)}: ${i.clearloopPrompt}`:null;return s.jsxs("div",{className:`system-message system-message-local-command ${Ie.rewoundGroupHeader}`,children:[s.jsxs("button",{type:"button",className:Ie.rewoundGroupToggleButton,"aria-expanded":a,title:`${u} — ${t(a?"rewoundGroupCollapse":"rewoundGroupExpand")}`,onClick:()=>r&&n.toggleRewoundGroup(r),children:[s.jsx("span",{className:Ie.rewoundGroupToggle,"aria-hidden":"true",children:a?"−":"+"}),s.jsx("span",{className:"system-message-icon",children:"↶"}),s.jsx("span",{className:"system-message-text",children:d})]}),f&&s.jsx(Ma,{text:f,label:t("rewoundGroupCopyRelaunch"),className:`user-prompt-action user-prompt-action-copy ${Ie.rewoundGroupCopy}`})]})}function Tv({item:e,icon:t,label:n}){const r=(e.details??[]).map(ac).map(f=>f.trim()).filter(Boolean),o=e.subtype==="compact_boundary",i=e.subtype==="tool_output",a=o?"system-message-compact-boundary":"system-message-local-command",l=o?"system-message-summary system-message-compact-summary":"system-message-summary system-message-local-command-summary",c=n??e.content,d=hr(t,c);if(!o&&r.length===0)return s.jsxs("div",{className:`system-message ${a}`,children:[d&&s.jsx("span",{className:"system-message-icon",children:d}),s.jsx("span",{className:"system-message-text",children:s.jsx(St,{text:c})})]});const u=r.length>0?r:[Sv];return s.jsxs("details",{className:`system-message ${a} ${a}--details system-message--details${o?` ${Ie.compactBoundaryOutline}`:""}`,children:[s.jsxs("summary",{className:l,children:[s.jsx("span",{className:"collapsible__icon","aria-hidden":"true",children:"▸"}),d&&s.jsx("span",{className:"system-message-icon",children:d}),s.jsx("span",{className:"system-message-text",children:s.jsx(St,{text:c})})]}),s.jsx("div",{className:`system-message-details${i?` ${Ie.toolOutputDetails}`:""}`,children:u.map((f,h)=>s.jsx("pre",{className:"system-message-detail",children:f},`${e.id}-system-detail-${h}`))})]})}const lc='.conversation-thinking-preview[data-preview-slot="latest"]',Rv='.conversation-thinking-preview[data-preview-slot="previous"]',co=".conversation-thinking-preview-content",pr="--conversation-previous-thinking-budget",Gn="previousThinking",Ln="--conversation-thinking-height";function Pv(e){for(let t=e.parentElement;t;t=t.parentElement){const{overflowY:n}=window.getComputedStyle(t);if(n==="auto"||n==="scroll")return t}return null}function Ev(e,t){var l;const n=e.querySelector(`${co} .thinking-text`),r=n?Number.parseFloat(window.getComputedStyle(n).lineHeight):Number.NaN,o=Number.isFinite(r)&&r>0?r:Rj*(Number.parseFloat(window.getComputedStyle(e).fontSize)||0),i=(l=e.previousElementSibling)==null?void 0:l.getBoundingClientRect().bottom,a=i===void 0?0:Math.max(0,t.top-i);return Tj*o+a}function Iv(e,t){if(!t)return 0;const n=t.scrollTop+e.bottom-t.getBoundingClientRect().top;return Math.max(0,t.scrollHeight-n)}function Gs(e){delete e.dataset[Gn],e.style.removeProperty(pr)}function Mv(e,t){const n=(t==null?void 0:t.clientHeight)||window.innerHeight;if(!(n>0))return Gs(e),null;const r=e.getBoundingClientRect(),o=Ev(e,r),i=Iv(r,t),a=Kl(n,i+o),l=e.querySelector(lc),c=e.querySelector(Rv);if(!l||!c)return Gs(e),a;const d=l.getBoundingClientRect(),u=c.getBoundingClientRect();if(Lj(u.top-d.top,e.dataset[Gn]===void 0))return Gs(e),a;const f=l.querySelector(co),h=Pj({viewportHeightPx:n,trailingContentPx:i,contextReservePx:o,previousTopPx:u.top-r.top,previousChromePx:d.height-((f==null?void 0:f.getBoundingClientRect().height)??0)+(Number.parseFloat(window.getComputedStyle(l).marginBottom)||0)});return h===null?(e.dataset[Gn]="dropped",e.style.removeProperty(pr)):(e.dataset[Gn]="stacked",e.style.setProperty(pr,`${Math.round(h)}px`)),a}function cc(e,t,n=null){const r=e.getBoundingClientRect().top;let o=0;for(const c of Array.from(e.children))o=Math.max(o,c.getBoundingClientRect().bottom-r);const i=Date.now(),a=vj(t.reserve,o,i);t.reserve=a,e.style.setProperty("--conversation-activity-reserved-height",`${n===null?a.heightPx:Math.min(a.heightPx,n)}px`),t.timer!==null&&(window.clearTimeout(t.timer),t.timer=null);const l=wj(a,i);l!==null&&(t.timer=window.setTimeout(()=>{t.timer=null,cc(e,t)},l))}function dc(e){return e>=10&&e<60?`${Math.round(e)}s`:et(e)}function $v({item:e,onToggle:t,collapsedThinkingPreviewSlots:n,onToggleThinkingPreview:r,onDismissThinkingPreview:o,widerActivityPreviews:i}){var Ce,je,He,ue,Fe,Oe,We,re,Te;const{t:a}=Z(),l=m.useRef(null),c=m.useRef(null),d=m.useRef(!1),u=m.useRef(null),[f,h]=m.useState(()=>Gi({active:e.active,hasFollowingConversationText:!!e.hasFollowingConversationText,endedAtMs:e.endedAtMs,nowMs:Date.now()})===0?"hidden":"visible"),g=m.useRef(((Ce=e.thinkingPreviews)==null?void 0:Ce.length)??0),[p,y]=m.useState(null),x=m.useCallback(()=>{d.current=!1,u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]);m.useEffect(()=>x,[x]);const b=A=>{if(x(),A.pointerType!=="touch")return;const U=A.currentTarget.getBoundingClientRect();d.current=A.clientX<U.left||A.clientX>=U.right||A.clientY<U.top||A.clientY>=U.bottom},_=()=>{d.current&&(u.current=window.setTimeout(x,0))},N=()=>{if(d.current){x();return}t==null||t(e.id)},v=m.useCallback(()=>{const A=c.current;A&&A.classList.toggle("is-clipped",A.scrollHeight-A.clientHeight>1)},[]),j=(je=e.thinkingPreviews)==null?void 0:je.map(A=>`${A.slot}:${n.has(A.slot)?"c":"o"}`).join("|");m.useLayoutEffect(()=>{const A=l.current;if(!A)return;const U=A.querySelector(lc);if(!U){A.style.removeProperty(Ln);return}const z=U.querySelector(co);if(!z){A.style.setProperty(Ln,"0px");return}let X=null;const xe=()=>{const B=$j(X,z.offsetHeight);X=B;const Q=`${B}px`;A.style.getPropertyValue(Ln)!==Q&&A.style.setProperty(Ln,Q),v()};xe();const L=new ResizeObserver(xe);return L.observe(z),()=>L.disconnect()},[j,v]);const C=m.useRef({reserve:null,timer:null}),w=m.useRef(null),k=m.useCallback(()=>{const A=l.current;if(!A)return;const U=Mv(A,w.current);cc(A,C.current,U)},[]),S=(((He=e.thinkingPreviews)==null?void 0:He.length)??0)>0;m.useLayoutEffect(()=>{const A=l.current;if(!A)return;const U=S?Pv(A):null;w.current=U,k();const z=new ResizeObserver(k);z.observe(A);for(const xe of Array.from(A.children))z.observe(xe);U&&z.observe(U);const X=C.current;return()=>{z.disconnect(),w.current=null,X.timer!==null&&(window.clearTimeout(X.timer),X.timer=null)}},[S,j,k]);const $=((ue=e.thinkingPreviews)==null?void 0:ue.length)??0,T=(e.thinkingPreviews??[]).filter(A=>n.has(A.slot)).map(A=>A.slot).join("|"),E=m.useRef(T),R=m.useRef($);m.useLayoutEffect(()=>{const A=new Set(E.current.split("|").filter(Boolean)),U=T.split("|").filter(Boolean).some(X=>!A.has(X)),z=$===0&&R.current>0;E.current=T,R.current=$,(U||z)&&(C.current.reserve=null,k())},[T,$,k]),m.useLayoutEffect(()=>{v()},[v,e.recentActivities]),m.useEffect(()=>{var z;const A=((z=e.thinkingPreviews)==null?void 0:z.length)??0,U=g.current;if(g.current=A,A===0){y(null);return}U===0&&(y(Date.now()),h("visible"))},[(Fe=e.thinkingPreviews)==null?void 0:Fe.length]),m.useEffect(()=>{const A=Gi({active:e.active,hasFollowingConversationText:!!e.hasFollowingConversationText,endedAtMs:e.endedAtMs,shownSinceMs:p,nowMs:Date.now()});if(A===null){h("visible");return}if(A===0){h(z=>z==="visible"?"hidden":z);return}h("visible");const U=window.setTimeout(()=>{h("fading")},A);return()=>window.clearTimeout(U)},[e.active,e.endedAtMs,e.hasFollowingConversationText,p]),m.useEffect(()=>{if(f!=="fading")return;const A=window.setTimeout(()=>{h("hidden")},Vi);return()=>window.clearTimeout(A)},[f]),m.useLayoutEffect(()=>{const A=l.current;if(f==="fading"&&A){const U=A.querySelector(".conversation-activity-summary"),z=A.offsetHeight;let X=z;if(U){const L=window.getComputedStyle(U);X=Math.ceil((Number.parseFloat(L.marginTop)||0)+U.offsetHeight+(Number.parseFloat(L.marginBottom)||0))}A.style.height=`${z}px`,C.current.reserve=null,A.style.removeProperty("--conversation-activity-reserved-height");const xe=window.requestAnimationFrame(()=>{A.style.height=`${Math.min(z,X)}px`});return()=>window.cancelAnimationFrame(xe)}A&&A.style.removeProperty("height"),f!=="visible"&&(C.current.reserve=null,k())},[f,k]);const D=e.startedAtMs!==null&&e.endedAtMs!==null&&e.endedAtMs>=e.startedAtMs?(e.endedAtMs-e.startedAtMs)/1e3:null,K=D===null?"":dc(D),V=a(e.activityCount===1?"conversationActivitySingular":"conversationActivityPlural"),G=e.expanded?"conversationActivityExpanded":"conversationActivityComplete",W=e.expanded?"conversationActivityExpandedWithoutTime":"conversationActivityCompleteWithoutTime",ie=K?a(e.active?"conversationActivityActive":G,{duration:K,count:e.activityCount,activity:V}):a(e.active?"conversationActivityActiveWithoutTime":W,{count:e.activityCount,activity:V}),ae=a(e.expanded?"conversationActivityCollapseTitle":"conversationActivityExpandTitle"),Pe=(Oe=e.tooltipActivities)==null?void 0:Oe.map(A=>A.detail).join(`
|
|
109
109
|
`),se=yn(ae,Pe?{headline:ie,detail:`${Pe}${e.activityCount>(((We=e.tooltipActivities)==null?void 0:We.length)??0)?`
|
|
110
110
|
…`:""}`}:void 0),Se=f!=="hidden",F=f==="fading",O=Se&&((re=e.thinkingPreviews)==null?void 0:re.some(A=>!n.has(A.slot)));return s.jsxs("div",{className:`conversation-activity-row ${Ie.activityHeightReserve}${i?" is-wide-activity-previews":""}${F?` ${Ie.thinkingRollingUp}`:""}`,ref:l,style:F?{"--conversation-thinking-rollup-ms":`${Vi}ms`}:void 0,children:[s.jsxs("div",{className:"conversation-activity-column",children:[s.jsxs("button",{type:"button",className:`conversation-activity-summary${e.active?" is-active":""}${e.expanded?" is-expanded":""}`,onClick:N,onPointerCancel:x,onPointerDown:b,onPointerUp:_,"aria-expanded":e.expanded,...se,children:[s.jsx("span",{className:`${Ie.activityChevron}${e.expanded?` ${Ie.activityChevronExpanded}`:""}`,"aria-hidden":"true",children:e.expanded?"▾":"▸"}),e.active?s.jsx("span",{className:Ie.activityPulse,"aria-hidden":"true"}):null,s.jsx("span",{className:Ie.activityLabel,children:ie})]}),O&&e.recentActivities?s.jsx("ul",{ref:c,className:`conversation-recent-activities${F?` ${Ie.thinkingAutoHiding}`:""}`,"aria-label":a("conversationRecentActivities"),children:e.recentActivities.map((A,U)=>s.jsx(Lv,{activity:A},`${A.label}-${U}`))}):null]}),Se?(Te=e.thinkingPreviews)==null?void 0:Te.map(A=>s.jsx(Fv,{autoHiding:F,collapsed:n.has(A.slot),turnEndedAtMs:e.endedAtMs,onDismiss:o,onToggle:r,preview:A},A.slot)):null]})}function Lv({activity:e}){const t=yn(e.detail);return s.jsxs("li",{...t,children:[s.jsx("span",{className:"conversation-recent-activity-name",children:e.label}),e.preview?s.jsx("span",{className:"conversation-recent-activity-preview",children:e.preview}):null]})}function na(e){let t=0;for(const n of e.replace(/\r\n?/g,`
|
|
111
111
|
`).split(`
|
|
112
|
-
`))t=Math.max(t,n.length);return t*8}function Av(e,t){if(e.status==="streaming"||e.endedAtMs===null||t===null)return"";const n=(t-e.endedAtMs)/1e3;return!Number.isFinite(n)||n<1?"":dc(n)}function Fv({preview:e,collapsed:t,autoHiding:n,onToggle:r,onDismiss:o,turnEndedAtMs:i}){const{t:a}=Z(),l=m.useRef(null),[c,d]=m.useState(null),u=a(e.kind==="current"?"conversationThinkingPreviewCurrent":e.kind==="latest"?"conversationThinkingPreviewLatest":"conversationThinkingPreviewPrevious"),f=a(t?"conversationThinkingPreviewExpand":"conversationThinkingPreviewCollapse"),h=a("conversationThinkingPreviewDismiss",{label:u}),g=Av(e,i),p=(c==null?void 0:c.id)===e.id?c.targetWidthPx:Sj;m.useLayoutEffect(()=>{var C;if(t)return;const x=(C=l.current)==null?void 0:C.querySelector(".thinking-text");if(!x)return;const b=x.style.display,_=x.style.width,N=x.style.maxWidth;x.style.display=x.classList.contains("thinking-outline")?"inline-grid":"inline-block",x.style.width="max-content",x.style.maxWidth="none";const v=x.getBoundingClientRect().width;x.style.display=b,x.style.width=_,x.style.maxWidth=N;const j=v>0?v:na(e.thinking);d(w=>Wi(w,e.id,j))},[t,e.id]),m.useLayoutEffect(()=>{t||d(x=>Wi(x,e.id,na(e.thinking)))},[t,e.id,e.thinking]);const{onScroll:y}=bj(l,e.thinking,{enabled:e.status==="streaming",identity:e.id});return s.jsxs("div",{className:`conversation-thinking-preview${e.status==="streaming"?" is-streaming":""}${t?" is-collapsed":""}${n?` ${Ie.thinkingAutoHiding}`:""}`,"data-preview-slot":e.slot,style:{"--conversation-thinking-preview-target-width":`${p}px`},children:[s.jsxs("div",{className:"conversation-thinking-preview-header",children:[s.jsxs("button",{type:"button",className:"conversation-thinking-preview-toggle","aria-expanded":!t,"aria-label":f,title:f,onClick:()=>r==null?void 0:r(e.slot),children:[s.jsx("span",{className:"conversation-thinking-preview-dot","aria-hidden":!0}),s.jsx("span",{className:Ie.thinkingPreviewLabel,children:u}),g?s.jsx("span",{className:Ie.thinkingPreviewAge,title:a("conversationThinkingPreviewAgeTitle",{duration:g}),children:a("conversationThinkingPreviewAge",{duration:g})}):null,s.jsx("span",{className:"conversation-thinking-preview-chevron","aria-hidden":!0,children:t?"▸":"▾"})]}),s.jsx("button",{type:"button",className:"conversation-thinking-preview-dismiss","aria-label":h,title:h,onClick:()=>o==null?void 0:o(e.slot),children:"×"})]}),t?null:s.jsx("div",{ref:l,className:"conversation-thinking-preview-content",onScroll:y,children:s.jsx(Cr,{text:e.thinking,isStreaming:e.status==="streaming"})})]})}const Bv=m.memo(function({item:t,isStreaming:n,thinkingExpanded:r,toggleThinkingExpanded:o,sessionProvider:i,onCorrectUserPrompt:a,onCancelUnconfirmedUserPrompt:l,onTrimBeforeUserPrompt:c,onForkBeforeUserPrompt:d,onForkAfterUserPrompt:u,onForkAfterSummaryUserPrompt:f,forkAfterUserPromptDisabled:h,forkUnavailableMessage:g,onQuoteTextBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x,staleNowMs:b,thinkingDurationMs:_,getForkSummaryTargetHref:N,onCancelForkSummary:v,onToggleForkSummaryAutoOpen:j,onFollowForkSummary:C,bangCommandHandlers:w,onToggleConversationActivity:k,widerConversationActivityPreviews:S=!1,collapsedConversationThinkingPreviewSlots:$=new Set,onToggleConversationThinkingPreview:T,onDismissConversationThinkingPreview:E}){var Se;const{t:R}=Z(),D=m.useRef(Date.now()),K=fs(t.sourceMessages),V=t.type!=="conversation_activity"&&K!==null,G=V&&b!==void 0,W=G?b??Date.now():D.current,ie=G&&W!==null&&W-K>=cd,ae=
|
|
112
|
+
`))t=Math.max(t,n.length);return t*8}function Av(e,t){if(e.status==="streaming"||e.endedAtMs===null||t===null)return"";const n=(t-e.endedAtMs)/1e3;return!Number.isFinite(n)||n<1?"":dc(n)}function Fv({preview:e,collapsed:t,autoHiding:n,onToggle:r,onDismiss:o,turnEndedAtMs:i}){const{t:a}=Z(),l=m.useRef(null),[c,d]=m.useState(null),u=a(e.kind==="current"?"conversationThinkingPreviewCurrent":e.kind==="latest"?"conversationThinkingPreviewLatest":"conversationThinkingPreviewPrevious"),f=a(t?"conversationThinkingPreviewExpand":"conversationThinkingPreviewCollapse"),h=a("conversationThinkingPreviewDismiss",{label:u}),g=Av(e,i),p=(c==null?void 0:c.id)===e.id?c.targetWidthPx:Sj;m.useLayoutEffect(()=>{var C;if(t)return;const x=(C=l.current)==null?void 0:C.querySelector(".thinking-text");if(!x)return;const b=x.style.display,_=x.style.width,N=x.style.maxWidth;x.style.display=x.classList.contains("thinking-outline")?"inline-grid":"inline-block",x.style.width="max-content",x.style.maxWidth="none";const v=x.getBoundingClientRect().width;x.style.display=b,x.style.width=_,x.style.maxWidth=N;const j=v>0?v:na(e.thinking);d(w=>Wi(w,e.id,j))},[t,e.id]),m.useLayoutEffect(()=>{t||d(x=>Wi(x,e.id,na(e.thinking)))},[t,e.id,e.thinking]);const{onScroll:y}=bj(l,e.thinking,{enabled:e.status==="streaming",identity:e.id});return s.jsxs("div",{className:`conversation-thinking-preview${e.status==="streaming"?" is-streaming":""}${t?" is-collapsed":""}${n?` ${Ie.thinkingAutoHiding}`:""}`,"data-preview-slot":e.slot,style:{"--conversation-thinking-preview-target-width":`${p}px`},children:[s.jsxs("div",{className:"conversation-thinking-preview-header",children:[s.jsxs("button",{type:"button",className:"conversation-thinking-preview-toggle","aria-expanded":!t,"aria-label":f,title:f,onClick:()=>r==null?void 0:r(e.slot),children:[s.jsx("span",{className:"conversation-thinking-preview-dot","aria-hidden":!0}),s.jsx("span",{className:Ie.thinkingPreviewLabel,children:u}),g?s.jsx("span",{className:Ie.thinkingPreviewAge,title:a("conversationThinkingPreviewAgeTitle",{duration:g}),children:a("conversationThinkingPreviewAge",{duration:g})}):null,s.jsx("span",{className:"conversation-thinking-preview-chevron","aria-hidden":!0,children:t?"▸":"▾"})]}),s.jsx("button",{type:"button",className:"conversation-thinking-preview-dismiss","aria-label":h,title:h,onClick:()=>o==null?void 0:o(e.slot),children:"×"})]}),t?null:s.jsx("div",{ref:l,className:"conversation-thinking-preview-content",onScroll:y,children:s.jsx(Cr,{text:e.thinking,isStreaming:e.status==="streaming"})})]})}const Bv=m.memo(function({item:t,isStreaming:n,thinkingExpanded:r,toggleThinkingExpanded:o,sessionProvider:i,onCorrectUserPrompt:a,onCancelUnconfirmedUserPrompt:l,onTrimBeforeUserPrompt:c,onForkBeforeUserPrompt:d,onForkAfterUserPrompt:u,onForkAfterSummaryUserPrompt:f,forkAfterUserPromptDisabled:h,forkUnavailableMessage:g,onQuoteTextBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x,staleNowMs:b,thinkingDurationMs:_,getForkSummaryTargetHref:N,onCancelForkSummary:v,onToggleForkSummaryAutoOpen:j,onFollowForkSummary:C,bangCommandHandlers:w,onToggleConversationActivity:k,widerConversationActivityPreviews:S=!1,collapsedConversationThinkingPreviewSlots:$=new Set,onToggleConversationThinkingPreview:T,onDismissConversationThinkingPreview:E}){var Se;const{t:R}=Z(),D=m.useRef(Date.now()),K=fs(t.sourceMessages),V=t.type!=="conversation_activity"&&K!==null,G=V&&b!==void 0,W=G?b??Date.now():D.current,ie=G&&W!==null&&W-K>=cd,ae=st(t.type==="system"&&t.subtype==="away_summary"?t.content:""),Pe=m.useCallback(F=>{const O=window.getSelection();O&&O.toString().length>0||F.shiftKey&&!F.ctrlKey&&!F.metaKey&&(F.preventDefault(),F.stopPropagation(),console.log("[DEBUG] Render snapshot",kv(t,{isStreaming:n,thinkingExpanded:r,sessionProvider:i})))},[t,n,r,i]),se=()=>{switch(t.type){case"text":return s.jsx(Xd,{renderId:t.id,fallback:s.jsx(Qn,{text:t.text,isStreaming:t.isStreaming,abortedMidStream:t.abortedMidStream,augmentHtml:t.augmentHtml,projectPathLinks:t.projectPathLinks,renderItemId:t.id,onQuoteBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x})});case"thinking":return s.jsx(Wj,{thinking:t.thinking,status:t.status,isExpanded:r,onToggle:o,durationMs:_});case"tool_call":return s.jsx(zb,{id:t.id,toolName:t.toolName,toolInput:t.toolInput,toolResult:t.toolResult,workflow:t.workflow,status:t.status,sessionProvider:i,startTimestampMs:ya(t.sourceMessages),resultTimestampMs:t.sourceMessages.length>1?K:null});case"user_prompt":{const F=ad(t.sourceMessages),O=ld(t.sourceMessages);return s.jsx(al,{content:t.content,messageId:t.id,projectPathLinks:t.projectPathLinks,onCorrect:a,onCancelUnconfirmed:O&&l?()=>l(O):void 0,onTrimBefore:c,onForkBefore:d,onForkAfter:u,onForkAfterSummary:f,forkAfterDisabled:h,forkUnavailableMessage:g,deliveryState:F})}case"session_setup":return s.jsx(Dj,{title:t.title,prompts:t.prompts});case"transcript_display_object":{const F=t.object;return F.kind==="bang-command"?s.jsx(Qd,{object:F,handlers:w}):s.jsx(Fj,{object:F,targetHref:F.targetSessionId?N==null?void 0:N(F.targetSessionId):void 0,onCancel:()=>v==null?void 0:v(F.id),onToggleAutoOpen:O=>j==null?void 0:j(F.id,O),onFollow:()=>C==null?void 0:C(F.id)})}case"task_notification":return s.jsx(Uj,{item:t});case"conversation_activity":return s.jsx($v,{item:t,onToggle:k,collapsedThinkingPreviewSlots:$,onToggleThinkingPreview:T,onDismissThinkingPreview:E,widerActivityPreviews:S});case"system":{if(t.subtype==="rewound_group")return s.jsx(Cv,{item:t});if(t.subtype==="local_command"&&t.content==="/goal"){const[U="",...z]=(t.details??[]).map(ac);return s.jsx(Cu,{objective:U,status:z.join(`
|
|
113
113
|
`)})}if(t.subtype==="away_summary")return s.jsxs("div",{className:"system-message-recap",children:[s.jsx("span",{className:"system-message-recap-mark",children:"※"}),s.jsx("span",{ref:ae,className:"system-message-recap-body",children:s.jsx(St,{text:t.content})})]});const F=t.subtype==="status"&&t.status==="compacting",O=t.subtype==="error",Ce=t.subtype==="warning",je=t.subtype==="informational",He=t.subtype==="config_ack",ue=t.subtype==="local_command",Fe=t.subtype==="tool_output",Oe=t.subtype==="subagent_activity",We=t.subtype==="no_model_turn",re=t.subtype==="history_search_gap",Te=He&&t.configChanged!==!1,A=O||Ce?"!":je?"i":He?"✓":ue?"/":Fe?"<":Oe?"↳":We?"∅":re?"⋯":"⟳";return t.subtype==="compact_boundary"||ue||Fe?s.jsx(Tv,{item:t,icon:A,label:Fe?t.content?R("toolOutputFrom",{tool:t.content}):R("toolOutput"):void 0}):s.jsxs("div",{className:`system-message ${F?"system-message-compacting":""} ${O?"system-message-error":""} ${Ce?"system-message-warning":""} ${Te?"system-message-config-ack":""} ${ue?"system-message-local-command":""}`,children:[hr(A,t.content)&&s.jsx("span",{className:`system-message-icon ${F?"spinning":""}`,children:hr(A,t.content)}),s.jsx("span",{className:"system-message-text",children:s.jsx(St,{text:t.content})})]})}default:return null}};return s.jsxs("div",{className:["message-render-row",V?"has-message-age":"",ie?"is-message-age-visible":"",t.isSubagent?"subagent-item":"",xn(t)&&!(t.type==="system"&&t.subtype==="rewound_group")?`subagent-item ${Ie.rewoundItem}`:""].filter(Boolean).join(" "),"data-render-type":t.type,"data-render-id":t.id,"data-rewound-group":t.type==="system"&&t.subtype==="rewound_group"?void 0:xn(t),onClick:Pe,children:[s.jsxs("div",{className:"message-render-content",children:[t.type==="tool_call"&&t.workflow?s.jsx(Zl,{workflow:t.workflow}):null,t.type==="text"&&((Se=t.workflow)!=null&&Se.markers.length)?s.jsx(wv,{text:t.text,workflow:t.workflow,isStreaming:t.isStreaming,original:se(),renderText:(F,O)=>s.jsx(Qn,{text:F,augmentHtml:O,projectPathLinks:t.projectPathLinks,renderItemId:t.id,onQuoteBlock:p,alwaysShowQuoteCircle:y,paragraphQuoteCirclesEnabled:x})}):se(),(t.type==="tool_call"||t.type==="conversation_activity")&&s.jsx(yd,{messages:t.sourceMessages})]}),s.jsx(Jd,{timestampMs:K,nowMs:W??Date.now()})]})});function uo({messages:e,isStreaming:t}){const{recentProjectPathLinksEnabled:n}=wd(),[r,o]=m.useState(!1),i=m.useCallback(()=>{o(l=>!l)},[]),a=m.useMemo(()=>Fr(e,void 0,n),[e,n]);return s.jsx("div",{className:"task-nested-content",children:a.map(l=>s.jsx(Bv,{item:l,isStreaming:t,thinkingExpanded:r,toggleThinkingExpanded:i},l.id))})}function rs(){return s.jsx("svg",{className:"spinner",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:s.jsx("circle",{cx:"8",cy:"8",r:"6",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeDasharray:"24",strokeDashoffset:"8"})})}const Dv="_headerRow_3ven4_1",Ov="_expandButton_3ven4_7",Uv="_openPage_3ven4_12",Hv="_rejection_3ven4_29",ct={headerRow:Dv,expandButton:Ov,openPage:Uv,rejection:Hv};function gr(e){return typeof e=="object"?e:null}function Wv(e,t){const n=e==null?void 0:e.replace(/\s+/g," ").trim();return n?n.length>140?`${n.slice(0,137)}...`:n:t}function xr(e,t){return Wv((t==null?void 0:t.nickname)??e.description??e.task??e.objective??e.message??e.prompt,"Codex subagent")}function sa(e){return e.agent_type??e.subagent_type??e.agent_role??e.role??"agent"}function Vv({isError:e,status:t,childStatus:n,hasAgentId:r}){return e||t!=="pending"&&!r?{className:"badge-error",text:"failed",isRunning:!1}:t==="aborted"?{className:"badge-warning",text:"interrupted",isRunning:!1}:t==="incomplete"?{className:"badge-warning",text:"result unavailable",isRunning:!1}:n==="failed"?{className:"badge-error",text:"failed",isRunning:!1}:n==="running"||!r&&t==="pending"?{className:"badge-running",text:"running",isRunning:!0}:n==="completed"?{className:"badge-success",text:"completed",isRunning:!1}:r?{className:"badge-success",text:"spawned",isRunning:!1}:{className:"badge-pending",text:"pending",isRunning:!1}}function yr(e){if(typeof e=="string")return e;if(e===void 0)return"";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Gv({input:e,result:t,isError:n,status:r,toolUseId:o}){const{t:i}=Z(),a=Mr(),{projectId:l,sessionId:c}=gs(),d=m.useContext(so),u=gr(t),f=(u==null?void 0:u.agentId)??(o?d==null?void 0:d.toolUseToAgent.get(o):void 0),h=f?d==null?void 0:d.agentContent[f]:void 0,[g,p]=m.useState(!1),[y,x]=m.useState(!1),b=Vv({isError:n,status:r,childStatus:h==null?void 0:h.status,hasAgentId:!!f}),_=async()=>{const j=(h==null?void 0:h.messages)&&h.messages.length>0;if(!g&&f&&d&&!j){p(!0),x(!0);try{await d.loadAgentContent(l,c,f)}finally{x(!1)}return}p(C=>!C)},N=xr(e,u),v=r!=="pending"&&!f;return s.jsxs("div",{className:`task-inline ${g?"expanded":"collapsed"} status-${b.text}`,children:[s.jsxs("div",{className:ct.headerRow,children:[v?s.jsxs("div",{className:`task-inline-header noninteractive ${ct.expandButton}`,children:[s.jsx("span",{className:"task-expand-icon"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:sa(e)}),s.jsx("span",{className:"task-inline-title",children:N}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),s.jsx("span",{className:`badge ${b.className}`,children:b.text})]}):s.jsxs("button",{type:"button",className:`task-inline-header ${ct.expandButton}`,onClick:_,children:[s.jsx("span",{className:"task-expand-icon",children:g?"▼":"▶"}),s.jsx("span",{className:"badge badge-info task-agent-type",children:sa(e)}),s.jsx("span",{className:"task-inline-title",children:N}),e.model&&s.jsx("span",{className:"badge task-model",children:e.model}),b.isRunning?s.jsx("span",{className:"task-spinner",role:"status","aria-label":"Running",children:s.jsx(rs,{})}):s.jsx("span",{className:`badge ${b.className}`,children:b.text})]}),f&&s.jsx(vr,{className:ct.openPage,to:Ia(a,l,c,f),children:i("providerChildOpen")})]}),v&&yr(t)&&s.jsx("pre",{className:`tool-fallback tool-fallback-error ${ct.rejection}`,children:s.jsx("code",{children:yr(t)})}),y&&s.jsxs("div",{className:"task-loading",children:[s.jsx(rs,{})," Loading agent content..."]}),g&&s.jsx("div",{className:"task-inline-content",children:h!=null&&h.messages.length?s.jsx(uo,{messages:h.messages,isStreaming:h.status==="running"}):f?s.jsx("div",{className:"task-empty",children:"No content"}):s.jsx("div",{className:"task-empty",children:"No agent session found"})})]})}const zv=de(fe.spawn_agent,{tool:"spawn_agent",displayName:"Spawn agent",pendingDisplayName:"Spawning agent",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:xr(e,null)})},renderToolResult(e,t){const n=gr(e);return s.jsx("div",{className:t||!(n!=null&&n.agentId)?"todo-error":"todo-summary",children:n!=null&&n.agentId?`Agent ${n.agentId}`:yr(e)||"Failed to spawn agent"})},getUseSummary(e){return xr(e,null)},getResultSummary(e,t){if(t)return"Error";const n=gr(e);return n!=null&&n.agentId?`Agent ${n.agentId}`:"Failed"},renderInline(e,t,n,r,o){return s.jsx(Gv,{input:e,result:t,isError:n,status:r,toolUseId:o.toolUseId})}}),ra=20;function oa({status:e}){const n={running:{icon:"⟳",className:"status-running"},completed:{icon:"✓",className:"status-completed"},failed:{icon:"✗",className:"status-failed"},timeout:{icon:"⏱",className:"status-timeout"}}[e]||{icon:"?",className:""};return s.jsxs("span",{className:`taskoutput-status ${n.className}`,children:[n.icon," ",e]})}function qv({input:e}){return s.jsxs("div",{className:"taskoutput-tool-use",children:[s.jsx("span",{className:"taskoutput-label",children:"Polling task"}),s.jsx("code",{className:"taskoutput-id",children:e.task_id}),e.block!==void 0&&s.jsx("span",{className:"badge",children:e.block?"blocking":"non-blocking"}),e.timeout!==void 0&&s.jsxs("span",{className:"badge",children:["timeout: ",e.timeout,"ms"]})]})}function Kv({result:e}){var g;const[t,n]=m.useState(!1),{enabled:r,reportValidationError:o,isToolIgnored:i}=ve(),[a,l]=m.useState(null);m.useEffect(()=>{if(r&&e){const p=we("TaskOutput",e);!p.valid&&p.errors?(l(p.errors),o("TaskOutput",p.errors)):l(null)}},[r,e,o]);const c=r&&a&&!i("TaskOutput");if(!e)return s.jsx("div",{className:"taskoutput-empty",children:"No output"});const d=e.task,u=((g=d==null?void 0:d.output)==null?void 0:g.split(`
|
|
114
114
|
`))||[],f=u.length>ra,h=f&&!t?u.slice(0,ra):u;return s.jsxs("div",{className:"taskoutput-result",children:[s.jsxs("div",{className:"taskoutput-header",children:[s.jsx(oa,{status:e.retrieval_status}),(d==null?void 0:d.task_type)&&s.jsx("span",{className:"badge badge-info",children:d.task_type}),(d==null?void 0:d.description)&&s.jsx("span",{className:"taskoutput-desc",children:d.description}),c&&a&&s.jsx(q,{toolName:"TaskOutput",errors:a})]}),d&&s.jsxs("div",{className:"taskoutput-task",children:[s.jsxs("div",{className:"taskoutput-task-status",children:[d.status&&s.jsx(oa,{status:d.status}),d.exitCode!=null&&s.jsxs("span",{className:`badge ${d.exitCode===0?"badge-success":"badge-error"}`,children:["exit ",d.exitCode]})]}),d.output&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"taskoutput-content code-block",children:s.jsx("code",{children:h.join(`
|
|
115
115
|
`)})}),f&&s.jsx("button",{type:"button",className:"expand-button",onClick:()=>n(!t),children:t?"Show less":`Show all ${u.length} lines`})]})]})]})}const Xv=de(fe.TaskOutput,{tool:"TaskOutput",renderToolUse(e,t){return s.jsx(qv,{input:e})},renderToolResult(e,t,n){return s.jsx(Kv,{result:e})},renderFailure(e){return s.jsx("div",{className:"taskoutput-error",children:e.content||"Failed to get task output"})},getFailureSummary(){return"Error"},getUseSummary(e){return e.task_id},getResultSummary(e){const t=e;return t?t.retrieval_status:"Pending"}});function uc(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function un(e,t){if(!uc(e))return;const n=e[t];return typeof n=="string"&&n.trim()?n.trim():void 0}function os(e){return typeof e=="object"&&e!==null?e._taskSnapshot:void 0}function Yv(e){return un(e,"taskId")??un(e,"task_id")??un(e,"id")}function mo(e){if(typeof e!="string")return"unknown";const t=e.trim().toLowerCase().replace(/[\s-]+/g,"_");return t==="completed"||t==="complete"?"completed":t==="in_progress"||t==="running"?"in_progress":t==="pending"||t==="todo"?"pending":t==="failed"||t==="error"?"failed":t==="cancelled"||t==="canceled"?"cancelled":"unknown"}function Jv(e){switch(e){case"completed":return"✓";case"in_progress":return"◐";case"failed":return"!";case"cancelled":return"×";default:return"○"}}function Qv(e){return e==="in_progress"?"todo-status-in-progress":`todo-status-${e}`}function Zv(e){var t;return(t=e.subject)!=null&&t.trim()?e.subject.trim():e.id?`Task #${e.id}`:"Task"}function mc(e){return e.filter(t=>mo(t.status)==="completed").length}function ew({snapshot:e}){const t=e.tasks,n=mc(t);return s.jsxs("div",{className:"todo-result",children:[s.jsxs("div",{className:"todo-summary",children:[n," out of ",t.length," tasks completed"]}),s.jsx("div",{className:"todo-list",children:t.map(r=>{const o=mo(r.status),i=o==="completed",a=Zv(r);return s.jsxs("div",{className:`todo-item ${Qv(o)}`,children:[s.jsx("span",{className:"todo-checkbox",children:Jv(o)}),s.jsx("span",{className:`todo-content ${i?"todo-completed":""}`,children:a})]},r.id||a)})})]})}function _s(e,t){if(e==="TaskCreate")return un(t,"subject")??"Task created";const n=Yv(t),r=mo(un(t,"status")),o=r==="unknown"?"updated":r.replace("_"," ");return n?`Task #${n} ${o}`:`Task ${o}`}function tw(e){if(typeof e=="string")return e.trim()||void 0;if(!uc(e))return;const t=e.content;return typeof t=="string"&&t.trim()?t.trim():void 0}function is(e,t,n,r){const o=os(n)??os(t);return!r&&o&&o.tasks.length>0?s.jsx(ew,{snapshot:o}):r?s.jsx("div",{className:"todo-error",children:tw(n)??"Task update failed"}):s.jsx("div",{className:"todo-summary",children:_s(e,t)})}function as(e,t,n){const r=os(n)??os(t);return r!=null&&r.tasks.length?`${mc(r.tasks)}/${r.tasks.length} complete`:_s(e,t)}const nw=de(fe.TaskCreate,{tool:"TaskCreate",displayName:"Create task",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:_s("TaskCreate",e)})},renderToolResult(e,t,n,r){return is("TaskCreate",r,e,t)},renderInline(e,t,n){return is("TaskCreate",e,t,n)},getUseSummary(e){return as("TaskCreate",e)},getResultSummary(e,t,n){return t?"Error":as("TaskCreate",n,e)}}),sw=de(fe.TaskUpdate,{tool:"TaskUpdate",displayName:"Update task",renderToolUse(e){return s.jsx("div",{className:"todo-summary",children:_s("TaskUpdate",e)})},renderToolResult(e,t,n,r){return is("TaskUpdate",r,e,t)},renderInline(e,t,n){return is("TaskUpdate",e,t,n)},getUseSummary(e){return as("TaskUpdate",e)},getResultSummary(e,t,n){return t?"Error":as("TaskUpdate",n,e)}});function rw({block:e}){return s.jsxs("div",{className:"fallback-block",children:[s.jsx("div",{className:"fallback-type",children:e.type}),s.jsx("pre",{className:"fallback-content",children:s.jsx("code",{children:JSON.stringify(e,null,2)})})]})}const ow={type:[],render(e,t){return s.jsx(rw,{block:e,context:t})}};function iw({block:e}){const t=va(e._renderedHtml??""),{modal:n,localFileModal:r,projectFileModal:o,handleClick:i,handleContextMenu:a,closeModal:l,closeLocalFileModal:c,closeProjectFileModal:d,contextMenuElement:u}=ja();return e._renderedHtml?s.jsxs("div",{className:"text-block",onClick:i,onContextMenu:a,children:[s.jsx("div",{dangerouslySetInnerHTML:{__html:t}}),n&&s.jsx(qt,{path:n.path,mediaType:n.mediaType,onClose:l}),r&&s.jsx(ba,{resource:r.resource,initialPresentation:r.initialPresentation,onClose:c}),o&&s.jsx(Ta,{projectId:o.projectId,filePath:o.filePath,lineNumber:o.lineNumber,lineEnd:o.lineEnd,initialPresentation:o.initialPresentation,onClose:d}),u]}):s.jsx("div",{className:"text-block",children:s.jsx("pre",{style:{whiteSpace:"pre-wrap",fontFamily:"inherit"},children:e.text})})}const aw={type:"text",render(e,t){return s.jsx(iw,{block:e})},getSummary(e){const t=e.text;return t.length>100?`${t.slice(0,97)}...`:t}};function fc(e){var n;if(typeof e.thinking=="string")return e.thinking;const t=(n=e.summary)==null?void 0:n.map(r=>typeof r=="string"?r:r.text).filter(r=>typeof r=="string").join(`
|