@av-pi-studio/web-client 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/web/assets/{BinaryFallbackViewer-Cpu5Tg1C.js → BinaryFallbackViewer-Cb-P_8V-.js} +2 -2
- package/dist/web/assets/{BinaryFallbackViewer-Cpu5Tg1C.js.map → BinaryFallbackViewer-Cb-P_8V-.js.map} +1 -1
- package/dist/web/assets/{ChatPanel-BqI2xnxv.js → ChatPanel-D_3cLBoK.js} +2 -2
- package/dist/web/assets/ChatPanel-D_3cLBoK.js.map +1 -0
- package/dist/web/assets/{CodeView-B18owi8N.js → CodeView-B1cJEve4.js} +2 -2
- package/dist/web/assets/{CodeView-B18owi8N.js.map → CodeView-B1cJEve4.js.map} +1 -1
- package/dist/web/assets/{FilePanel-BBfL4iba.js → FilePanel-YoyZJ2v2.js} +3 -3
- package/dist/web/assets/{FilePanel-BBfL4iba.js.map → FilePanel-YoyZJ2v2.js.map} +1 -1
- package/dist/web/assets/{ImageViewer-KAEt1ZI8.js → ImageViewer-BvKE7WrT.js} +2 -2
- package/dist/web/assets/{ImageViewer-KAEt1ZI8.js.map → ImageViewer-BvKE7WrT.js.map} +1 -1
- package/dist/web/assets/{MarkdownFileViewer-Cb8Cm1VS.js → MarkdownFileViewer-Ct7fWGmR.js} +2 -2
- package/dist/web/assets/{MarkdownFileViewer-Cb8Cm1VS.js.map → MarkdownFileViewer-Ct7fWGmR.js.map} +1 -1
- package/dist/web/assets/{TerminalPanel-DyLLAPYP.js → TerminalPanel-rKZq5rWo.js} +2 -2
- package/dist/web/assets/{TerminalPanel-DyLLAPYP.js.map → TerminalPanel-rKZq5rWo.js.map} +1 -1
- package/dist/web/assets/{TextViewer-C4U4WLH6.js → TextViewer-BsdUzTN-.js} +2 -2
- package/dist/web/assets/{TextViewer-C4U4WLH6.js.map → TextViewer-BsdUzTN-.js.map} +1 -1
- package/dist/web/assets/{VideoViewer-tThxC8b-.js → VideoViewer-BoA5BwxX.js} +2 -2
- package/dist/web/assets/{VideoViewer-tThxC8b-.js.map → VideoViewer-BoA5BwxX.js.map} +1 -1
- package/dist/web/assets/index-BTP_UxAo.js +3 -0
- package/dist/web/assets/index-BTP_UxAo.js.map +1 -0
- package/dist/web/assets/index-EefWgf31.css +1 -0
- package/dist/web/assets/{use-file-download-BPiZ1x6n.js → use-file-download-CwyNTuhL.js} +2 -2
- package/dist/web/assets/{use-file-download-BPiZ1x6n.js.map → use-file-download-CwyNTuhL.js.map} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +3 -3
- package/dist/web/assets/ChatPanel-BqI2xnxv.js.map +0 -1
- package/dist/web/assets/index-BFWpAuBZ.js +0 -3
- package/dist/web/assets/index-BFWpAuBZ.js.map +0 -1
- package/dist/web/assets/index-BMbFIm_9.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
html,body{margin:0;padding:0}body{min-height:100vh;overflow:hidden;background:var(--pi-color-background, #0a0a0a);color:var(--pi-color-foreground, #fafafa);font-family:var(--pi-font-ui, system-ui, sans-serif)}#root{display:flex;flex-direction:column;min-height:100vh}*,*:before,*:after{box-sizing:border-box}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--pi-color-border, #353b46);border-radius:3px}._btn_1chbg_4{display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:var(--pi-radius-lg, 8px);border:1px solid transparent;font-family:var(--pi-font-ui, system-ui, sans-serif);font-weight:500;cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;text-decoration:none;outline:none;transition:opacity .12s ease,background-color .12s ease,border-color .12s ease;box-sizing:border-box}._btn_1chbg_4:focus-visible{outline:2px solid var(--pi-color-accent, #2e5cb8);outline-offset:2px}._btn_1chbg_4:disabled,._btn_1chbg_4[aria-disabled=true]{cursor:not-allowed;pointer-events:none}._default_1chbg_35{background-color:var(--pi-color-accent, #2e5cb8);color:var(--pi-color-accentForeground, #ffffff);border-color:var(--pi-color-accent, #2e5cb8)}._default_1chbg_35:hover:not(:disabled){filter:brightness(1.08)}._secondary_1chbg_44{background-color:var(--pi-color-surface3, #3f3f46);color:var(--pi-color-foreground, #fafafa);border-color:var(--pi-color-border, #3f3f46)}._secondary_1chbg_44:hover:not(:disabled){background-color:var(--pi-color-surface2, #27272a)}._outline_1chbg_53{background-color:transparent;color:var(--pi-color-accentBright, #a2b4d7);border-color:var(--pi-color-accent, #2e5cb8)}._outline_1chbg_53:hover:not(:disabled){background-color:var(--pi-color-surface1, #18181b)}._ghost_1chbg_62{background-color:transparent;color:var(--pi-color-foregroundMuted, #a1a1aa);border-color:transparent}._ghost_1chbg_62:hover:not(:disabled){color:var(--pi-color-foreground, #fafafa);background-color:var(--pi-color-surface1, #18181b)}._destructive_1chbg_72{background-color:var(--pi-color-destructive, #991b1b);color:var(--pi-color-destructiveForeground, #fef2f2);border-color:var(--pi-color-destructive, #991b1b)}._destructive_1chbg_72:hover:not(:disabled){filter:brightness(1.1)}._iconOnly_1chbg_82{padding-left:0!important;padding-right:0!important;aspect-ratio:1}._loadingSpinner_1chbg_89{animation:_piSpin_1chbg_1 .75s linear infinite;flex-shrink:0}@keyframes _piSpin_1chbg_1{0%{transform:rotate(0)}to{transform:rotate(360deg)}}._input_a7qyq_3{width:100%;padding:8px 12px;border-radius:var(--pi-radius-md, 6px);border:1px solid var(--pi-color-border, #3f3f46);background-color:var(--pi-color-surface2, #27272a);color:var(--pi-color-foreground, #fafafa);font-size:var(--pi-font-size-base, 16px);font-family:var(--pi-font-ui, system-ui, sans-serif);outline:none;transition:border-color .12s ease;box-sizing:border-box}._input_a7qyq_3::placeholder{color:var(--pi-color-foregroundMuted, #a1a1aa)}._input_a7qyq_3:focus{border-color:var(--pi-color-accent, #2e5cb8);outline:2px solid var(--pi-color-accent, #2e5cb8);outline-offset:-1px}._input_a7qyq_3:disabled{opacity:.5;cursor:not-allowed}._textarea_a7qyq_32{resize:vertical;min-height:80px}._wrap_emmus_1{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--pi-color-foregroundMuted, #9aa0a6)}._dot_emmus_8{width:8px;height:8px;border-radius:50%;background:var(--pi-color-foregroundMuted, #9aa0a6);flex-shrink:0}._dot_emmus_8._open_emmus_15{background:var(--pi-color-statusSuccess, #3ecf8e)}._dot_emmus_8._connecting_emmus_18{background:var(--pi-color-statusWarning, #e0a030)}._dot_emmus_8._closed_emmus_21,._dot_emmus_8._idle_emmus_22,._dot_emmus_8._closing_emmus_23{background:var(--pi-color-statusDanger, #e5484d)}._toolbar_i9hmh_1{display:flex;align-items:center;gap:10px;padding:6px 10px;border-bottom:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surface, #16181a);flex-shrink:0}._brand_i9hmh_10{font-weight:600;font-size:13px;letter-spacing:.02em;white-space:nowrap}._version_i9hmh_16{font-size:11px;color:var(--pi-color-foregroundMuted, #7a8394);white-space:nowrap;margin-left:-4px}._sep_i9hmh_22{width:1px;height:18px;background:var(--pi-color-border, #353b46);flex-shrink:0}._host_i9hmh_28{width:190px}._password_i9hmh_31{width:100px}._sidebarToggles_i9hmh_34{display:flex;align-items:center;gap:4px;margin-left:auto}._dot_gfh8u_3{display:inline-block;width:8px;height:8px;border-radius:9999px;flex-shrink:0}._spinner_gfh8u_16{display:inline-block;width:12px;height:12px;border-radius:9999px;border:2px solid var(--pi-color-border, #353b46);flex-shrink:0;animation:_statusSpin_gfh8u_1 .7s linear infinite}@keyframes _statusSpin_gfh8u_1{to{transform:rotate(360deg)}}._wrap_14der_1{display:flex;flex-direction:column;min-height:0;height:100%}._header_14der_7{display:flex;align-items:center;justify-content:space-between;padding:8px 10px;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._header_14der_7 h3{margin:0;font-size:12px;font-weight:600;color:var(--pi-color-foregroundMuted, #9aa0a6);text-transform:uppercase;letter-spacing:.04em}._list_14der_23{flex:1 1 auto;overflow-y:auto;min-height:0}._item_14der_28{position:relative;padding:8px 10px;cursor:pointer;border-bottom:1px solid transparent}._item_14der_28:hover{background:var(--pi-color-surfaceHover, #1e2124)}._item_14der_28._active_14der_37{background:var(--pi-color-surfaceSunken, #111);box-shadow:inset 2px 0 0 var(--pi-color-accent, #2e5cb8)}._title_14der_41{display:flex;align-items:center;gap:6px;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._meta_14der_50{margin-top:2px;font-size:11px;color:var(--pi-color-foregroundMuted, #9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._menuBtn_14der_58{position:absolute;top:6px;right:6px;opacity:0;padding:2px 4px;background:none;border:none;border-radius:4px;cursor:pointer;color:var(--pi-color-foregroundMuted, #9aa0a6)}._item_14der_28:hover ._menuBtn_14der_58{opacity:1}._menuBtn_14der_58:hover{background:var(--pi-color-surfaceHover, #1e2124)}._workspaceGroup_14der_76{border-bottom:1px solid var(--pi-color-border, #353b46)}._workspaceHeader_14der_79{display:flex;align-items:center;gap:6px;padding:7px 10px;cursor:pointer;font-size:12px;font-weight:600;color:var(--pi-color-foreground, #e6e6e6)}._workspaceHeader_14der_79:hover{background:var(--pi-color-surfaceHover, #1e2124)}._workspaceChevron_14der_92{display:flex;align-items:center;justify-content:center;padding:0;background:none;border:none;cursor:pointer;color:var(--pi-color-foregroundMuted, #9aa0a6);flex-shrink:0}._workspaceIcon_14der_103{color:var(--pi-color-foregroundMuted, #9aa0a6);flex-shrink:0}._workspaceLabel_14der_107{flex:1 1 auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._workspaceCount_14der_113{font-size:11px;font-weight:400;color:var(--pi-color-foregroundMuted, #9aa0a6)}._newSessionBtn_14der_118{flex-shrink:0;opacity:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._workspaceHeader_14der_79:hover ._newSessionBtn_14der_118{opacity:1}._newSessionBtn_14der_118:hover{background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #e6e6e6)}._workspaceSessions_14der_130{padding-left:12px}._emptyState_14der_133{padding:12px 10px;font-size:12px;color:var(--pi-color-foregroundMuted, #9aa0a6)}._trigger_42hju_1{position:fixed;width:1px;height:1px;padding:0;border:0;background:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;opacity:0;pointer-events:none}._content_42hju_12{min-width:160px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000}._item_42hju_21{display:flex;align-items:center;padding:6px 10px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_42hju_21:hover,._item_42hju_21[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._item_42hju_21[data-disabled]{opacity:.4;cursor:default}._danger_42hju_38{color:var(--pi-color-statusDanger, #e5484d)}._sep_42hju_41{height:1px;margin:4px 0;background:var(--pi-color-border, #353b46)}._strip_8jveh_1{display:flex;align-items:center;gap:2px;padding:4px 6px 0;overflow-x:auto;flex-shrink:0;border-bottom:1px solid var(--pi-color-border, #353b46)}._tab_8jveh_10{display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:var(--pi-borderRadius-md, 6px) var(--pi-borderRadius-md, 6px) 0 0;font-size:12px;cursor:pointer;color:var(--pi-color-foregroundMuted, #9aa0a6);white-space:nowrap;flex-shrink:0;-webkit-user-select:none;user-select:none}._tab_8jveh_10:hover{background:var(--pi-color-surfaceHover, #1e2124)}._active_8jveh_26{background:var(--pi-color-surfaceSunken, #111);color:var(--pi-color-foreground, #fafafa)}._icon_8jveh_30{display:flex;align-items:center;flex-shrink:0}._label_8jveh_35{max-width:160px;overflow:hidden;text-overflow:ellipsis}._close_8jveh_40{display:flex;align-items:center;border-radius:3px;padding:1px;flex-shrink:0}._close_8jveh_40:hover{background:var(--pi-color-surfaceHover, #1e2124)}._newTab_8jveh_50{position:relative;display:flex;align-items:center;justify-content:center;flex-shrink:0;margin:0 4px;width:20px;height:20px;border-radius:var(--pi-borderRadius-sm, 4px);color:var(--pi-color-foregroundMuted, #9aa0a6);background:transparent;border:none;cursor:pointer}._newTab_8jveh_50:hover:not(:disabled){background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #fafafa)}._newTab_8jveh_50:disabled{opacity:.4;cursor:default}._content_8jveh_73{min-width:160px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000}._item_8jveh_82{display:flex;align-items:center;gap:8px;padding:6px 10px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_8jveh_82:hover,._item_8jveh_82[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._itemIcon_8jveh_96{flex-shrink:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._spinner_1tgzp_3{display:inline-block;border-radius:9999px;border-style:solid;border-color:currentColor transparent transparent transparent;animation:_piSpinnerRotate_1tgzp_1 .7s linear infinite;flex-shrink:0}@keyframes _piSpinnerRotate_1tgzp_1{0%{transform:rotate(0)}to{transform:rotate(360deg)}}._area_z7u01_1{position:relative;flex:1 1 auto;min-height:0;overflow:hidden}._panel_z7u01_7{position:absolute;top:0;right:0;bottom:0;left:0;display:none;flex-direction:column;min-height:0}._active_z7u01_14{display:flex}._empty_z7u01_17{display:flex;align-items:center;justify-content:center;height:100%;color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:13px}._emptyStack_z7u01_25{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;height:100%;padding:0 16px;text-align:center}._emptyTitle_z7u01_35{font-size:13px;color:var(--pi-color-foreground, #e6e6e6)}._emptyHint_z7u01_39{font-size:12px;color:var(--pi-color-foregroundMuted, #9aa0a6)}._container_1098n_1{position:relative;height:100%;display:flex;flex-direction:column}._header_1098n_7{display:flex;align-items:center;gap:6px;padding:6px 8px;border-bottom:1px solid var(--pi-color-border, #353b46)}._uploadButton_1098n_14{display:inline-flex;align-items:center;gap:5px;font-size:11px;padding:3px 8px;border-radius:4px;border:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surface, #1e2124);color:var(--pi-color-foreground, #e4e6eb);cursor:pointer}._uploadButton_1098n_14:hover:not(:disabled){background:var(--pi-color-surfaceHover, #2a2e33)}._uploadButton_1098n_14:disabled{opacity:.5;cursor:default}._hiddenInput_1098n_33{display:none}._status_1098n_36,._statusError_1098n_37{font-size:11px;padding:4px 8px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._status_1098n_36{color:var(--pi-color-foregroundMuted, #9aa0a6)}._statusError_1098n_37{color:var(--pi-color-danger, #e5534b)}._rowAction_1098n_50{margin-left:auto;display:none;align-items:center;padding:2px;border:none;background:transparent;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer;border-radius:3px}._rowAction_1098n_50:hover{color:var(--pi-color-foreground, #e4e6eb);background:var(--pi-color-surface, #1e2124)}._item_1098n_65:hover ._rowAction_1098n_50{display:inline-flex}._dropOverlay_1098n_68{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;font-size:13px;color:var(--pi-color-accentBright, #a2b4d7);background:color-mix(in srgb,var(--pi-color-surface, #1e2124) 80%,transparent);border:2px dashed var(--pi-color-accentBright, #a2b4d7);border-radius:6px;pointer-events:none;z-index:2}._list_1098n_83{padding:4px 0;flex:1;overflow-y:auto;position:relative}._item_1098n_65{height:24px;padding-right:8px;font-size:12px;border-radius:3px;cursor:pointer;display:flex;align-items:center;gap:6px}._item_1098n_65:hover{background:var(--pi-color-surfaceHover, #1e2124)}._chevronSlot_1098n_102{display:flex;align-items:center;justify-content:center;width:12px;flex-shrink:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._chevron_1098n_102{transition:transform .1s ease}._chevronOpen_1098n_113{transform:rotate(90deg)}._icon_1098n_116{display:flex;align-items:center;width:16px;flex-shrink:0;color:var(--pi-color-foregroundMuted, #9aa0a6)}._name_1098n_123{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._dirName_1098n_128{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--pi-color-accentBright, #a2b4d7)}._statusRow_1098n_134{height:24px;display:flex;align-items:center;padding-right:8px;font-size:11px;color:var(--pi-color-foregroundMuted, #9aa0a6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._statusRowError_1098n_145{color:var(--pi-color-danger, #e5534b)}._emptyState_1098n_148{color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px;text-align:center;padding:20px}._draftInput_1098n_154{flex:1;min-width:0;height:18px;font:inherit;font-size:12px;padding:0 4px;color:var(--pi-color-foreground, #e4e6eb);background:var(--pi-color-surfaceSunken, #111);border:1px solid var(--pi-color-accent, #2e5cb8);border-radius:3px;outline:none}._trigger_ngv1a_1{position:fixed;width:1px;height:1px;padding:0;border:0;background:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;opacity:0;pointer-events:none}._content_ngv1a_12{min-width:140px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000}._item_ngv1a_21{display:flex;align-items:center;padding:6px 10px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_ngv1a_21:hover,._item_ngv1a_21[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._danger_ngv1a_34{color:var(--pi-color-statusDanger, #e5484d)}._sep_ngv1a_37{height:1px;margin:4px 0;background:var(--pi-color-border, #353b46)}._list_1pgby_1{padding:4px 0}._summary_1pgby_4{padding:4px 8px;font-size:11px;color:var(--pi-color-foregroundMuted, #9aa0a6);border-bottom:1px solid var(--pi-color-border, #353b46);margin-bottom:4px}._item_1pgby_11{padding:4px 8px;font-size:12px;border-radius:3px;cursor:pointer;display:flex;align-items:center;gap:6px}._item_1pgby_11:hover{background:var(--pi-color-surfaceHover, #1e2124)}._badge_1pgby_23{font-size:10px;padding:0 4px;border-radius:3px;font-weight:600;flex-shrink:0}._added_1pgby_30{background:color-mix(in srgb,var(--pi-color-statusSuccess, #4ade80) 20%,transparent);color:var(--pi-color-statusSuccess, #4ade80)}._modified_1pgby_34{background:color-mix(in srgb,var(--pi-color-statusWarning, #facc15) 20%,transparent);color:var(--pi-color-statusWarning, #facc15)}._deleted_1pgby_38{background:color-mix(in srgb,var(--pi-color-statusDanger, #ff8a80) 20%,transparent);color:var(--pi-color-statusDanger, #ff8a80)}._name_1pgby_42{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._emptyState_1pgby_47{color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px;text-align:center;padding:20px}._wrap_r37ok_1{display:flex;flex-direction:column;height:100%;min-height:0}._tabBar_r37ok_7{display:flex;align-items:center;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._tabBtn_r37ok_13{font:inherit;font-size:12px;padding:8px 12px;background:none;border:none;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer;border-bottom:2px solid transparent}._tabBtn_r37ok_13:hover{color:var(--pi-color-foreground, #fafafa)}._active_r37ok_26{color:var(--pi-color-foreground, #fafafa);border-bottom-color:var(--pi-color-accent, #2e5cb8)}._refreshBtn_r37ok_30{margin-left:auto;margin-right:6px}._content_r37ok_34{flex:1;overflow-y:auto;padding:8px;min-height:0}._content_17y31_4{min-width:240px;padding:4px;border-radius:var(--pi-borderRadius-md, 6px);background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);box-shadow:0 8px 24px #0006;z-index:1000;display:flex;flex-direction:column;gap:4px}._search_17y31_17{width:100%;box-sizing:border-box;padding:6px 8px;border-radius:var(--pi-radius-md, 6px);border:1px solid var(--pi-color-border, #3f3f46);background:var(--pi-color-surface2, #27272a);color:var(--pi-color-foreground, #fafafa);font-size:12px;outline:none}._search_17y31_17::placeholder{color:var(--pi-color-foregroundMuted, #9aa0a6)}._search_17y31_17:focus{border-color:var(--pi-color-accent, #2e5cb8)}._list_17y31_35{max-height:320px;overflow-y:auto}._item_17y31_40{display:flex;align-items:center;gap:6px;padding:6px 8px;border-radius:4px;font-size:13px;cursor:pointer;outline:none}._item_17y31_40:hover,._item_17y31_40[data-highlighted]{background:var(--pi-color-surfaceHover, #1e2124)}._checkSlot_17y31_55{width:16px;flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;color:var(--pi-color-foreground, #fafafa)}._label_17y31_64{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._modelId_17y31_70{color:var(--pi-color-foregroundMuted, #9aa0a6);margin-left:4px;font-size:12px;white-space:nowrap}._state_17y31_77{display:flex;align-items:center;justify-content:center;padding:12px;color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px}._stateError_17y31_86{padding:8px;color:var(--pi-color-danger, #e5534b);font-size:12px}._statusBar_tm1j6_1{height:35px;width:100%;flex-shrink:0;display:flex;align-items:center;gap:2px;padding:0 12px;overflow-x:auto;border-top:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surface, #16181a);font-size:12px;color:var(--pi-color-foreground, #e4e6eb);white-space:nowrap}._segmentGroup_tm1j6_16{display:flex;align-items:center}._chevron_tm1j6_20{color:var(--pi-color-border, #353b46);margin:0 4px;flex-shrink:0}._segment_tm1j6_16{display:flex;align-items:center;gap:6px;padding:2px 8px;border-radius:4px;background:var(--pi-color-surfaceRaised, #1c1f22)}._icon_tm1j6_33{display:flex;align-items:center;color:var(--pi-color-foregroundMuted, #7a8394);flex-shrink:0}._modelSegment_tm1j6_39{display:flex;align-items:center;gap:5px;padding:2px 6px 2px 8px;border-radius:4px;border:1px solid var(--pi-color-border, #353b46);background:var(--pi-color-surfaceRaised, #1c1f22);color:inherit;font:inherit;cursor:pointer}._modelSegment_tm1j6_39:hover:not(:disabled){background:var(--pi-color-surfaceHover, #23262b);border-color:var(--pi-color-foregroundMuted, #7a8394)}._modelSegment_tm1j6_39[data-state=open]{background:var(--pi-color-surfaceHover, #23262b);border-color:var(--pi-color-accent, #2e5cb8)}._modelSegment_tm1j6_39:disabled{cursor:default;opacity:.6}._modelChevron_tm1j6_63{color:var(--pi-color-foregroundMuted, #7a8394);flex-shrink:0;transition:transform .15s ease;transform:rotate(180deg)}._modelSegment_tm1j6_39[data-state=open] ._modelChevron_tm1j6_63{transform:rotate(0)}._text_tm1j6_74{overflow:hidden;text-overflow:ellipsis;max-width:320px}._wrapper_131x2_3{display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-family:var(--pi-font-ui, system-ui);font-size:var(--pi-font-size-sm, 14px);color:var(--pi-color-foreground, #fafafa)}._wrapper_131x2_3[data-disabled=true]{opacity:.5;pointer-events:none}._box_131x2_18{width:16px;height:16px;border-radius:var(--pi-radius-sm, 3px);border:1.5px solid var(--pi-color-border, #3f3f46);background-color:transparent;display:flex;align-items:center;justify-content:center;transition:background-color .1s,border-color .1s;flex-shrink:0}._box_131x2_18[data-checked=true]{background-color:var(--pi-color-accent, #2e5cb8);border-color:var(--pi-color-accent, #2e5cb8)}._checkmark_131x2_36{color:var(--pi-color-accentForeground, #ffffff)}._nativeInput_131x2_41{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}._select_vj45v_3{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--pi-color-surface1, #18181b);border:1px solid var(--pi-color-border, #3f3f46);border-radius:var(--pi-radius-base, 4px);padding:8px 32px 8px 10px;font-family:var(--pi-font-ui, system-ui);font-size:var(--pi-font-size-sm, 14px);color:var(--pi-color-foreground, #fafafa);width:100%;outline:none;transition:border-color .1s;cursor:pointer;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a1a1aa' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center}._select_vj45v_3:focus{border-color:var(--pi-color-accent, #2e5cb8)}._select_vj45v_3:disabled{opacity:.5;cursor:not-allowed}._comboboxWrapper_vj45v_31{position:relative;width:100%}._comboboxInput_vj45v_36{width:100%;background-color:var(--pi-color-surface1, #18181b);border:1px solid var(--pi-color-border, #3f3f46);border-radius:var(--pi-radius-base, 4px);padding:8px 10px;font-family:var(--pi-font-ui, system-ui);font-size:var(--pi-font-size-sm, 14px);color:var(--pi-color-foreground, #fafafa);outline:none;box-sizing:border-box}._comboboxInput_vj45v_36:focus{border-color:var(--pi-color-accent, #2e5cb8)}._comboboxList_vj45v_53{position:absolute;top:100%;left:0;right:0;z-index:80;max-height:200px;overflow-y:auto;background-color:var(--pi-color-surface1, #18181b);border:1px solid var(--pi-color-border, #3f3f46);border-radius:var(--pi-radius-base, 4px);margin-top:4px;padding:4px;box-shadow:var(--pi-shadow-md, 0 4px 12px rgba(0,0,0,.4))}._comboboxOption_vj45v_69{padding:6px 8px;border-radius:var(--pi-radius-sm, 3px);font-size:var(--pi-font-size-sm, 14px);font-family:var(--pi-font-ui, system-ui);color:var(--pi-color-foreground, #fafafa);cursor:pointer;background:none;border:none;width:100%;text-align:left}._comboboxOption_vj45v_69:hover,._comboboxOptionHighlighted_vj45v_82{background-color:var(--pi-color-surface2, #27272a)}._overlay_1yaef_1{position:fixed;top:0;right:0;bottom:0;left:0;background:#0009;z-index:100}._contentWrapper_1yaef_7{position:fixed;top:0;right:0;bottom:0;left:0;z-index:101;display:flex;align-items:center;justify-content:center;pointer-events:none}._dialog_1yaef_16{pointer-events:auto;width:500px;max-width:90vw;max-height:70vh;background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);border-radius:var(--pi-radius-lg, 8px);display:flex;flex-direction:column;box-shadow:0 8px 32px #00000080}._header_1yaef_28{padding:12px 14px;border-bottom:1px solid var(--pi-color-border, #353b46);display:flex;align-items:center;gap:8px;flex-shrink:0}._title_1yaef_36{font-size:13px;margin:0;flex:1;color:var(--pi-color-foreground, #fafafa);font-weight:600}._closeBtn_1yaef_43{display:flex;align-items:center;background:none;border:none;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer;padding:4px;border-radius:4px}._closeBtn_1yaef_43:hover{background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #fafafa)}._body_1yaef_57{flex:1;display:flex;flex-direction:column;min-height:0}._footer_1yaef_63{padding:10px 14px;border-top:1px solid var(--pi-color-border, #353b46);display:flex;align-items:center;gap:8px;justify-content:flex-end;flex-shrink:0}._bare_1yaef_72{border:none;background:transparent;box-shadow:none;position:relative}._bareBody_1yaef_78{border-radius:var(--pi-radius-lg, 8px);overflow:hidden}._bareCloseBtn_1yaef_82{position:absolute;top:-12px;right:-12px;display:flex;align-items:center;justify-content:center;width:28px;height:28px;background:var(--pi-color-surface, #16181a);border:1px solid var(--pi-color-border, #353b46);border-radius:50%;color:var(--pi-color-foregroundMuted, #9aa0a6);cursor:pointer}._bareCloseBtn_1yaef_82:hover{background:var(--pi-color-surfaceHover, #1e2124);color:var(--pi-color-foreground, #fafafa)}._visuallyHidden_1yaef_101{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}._handle_1ocv1_1{position:absolute;top:0;bottom:0;width:5px;cursor:col-resize;z-index:5;background:transparent;transition:background .12s ease}._handle_1ocv1_1:hover,._handle_1ocv1_1:active{background:var(--pi-color-accent, #2e5cb8)}._pathRow_trimn_1{padding:8px 14px;display:flex;align-items:center;gap:6px;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._pathInput_trimn_9{flex:1;font-size:12px}._createRow_trimn_13{padding:6px 14px;display:flex;align-items:center;gap:6px;border-bottom:1px solid var(--pi-color-border, #353b46);flex-shrink:0}._createInput_trimn_21{flex:1;font-size:12px}._createError_trimn_25{padding:4px 14px 6px;font-size:11px;color:var(--pi-color-danger, #e5534b)}._list_trimn_30{flex:1;overflow-y:auto;padding:4px 0;min-height:200px;max-height:400px}._item_trimn_37{padding:6px 14px;cursor:pointer;display:flex;align-items:center;gap:8px;font-size:12px;color:var(--pi-color-foreground, #fafafa)}._item_trimn_37:hover{background:var(--pi-color-surfaceHover, #1e2124)}._name_trimn_49{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._emptyState_trimn_54{color:var(--pi-color-foregroundMuted, #9aa0a6);font-size:12px;text-align:center;padding:20px}._shell_1m1nv_1{display:flex;flex-direction:column;height:100vh;min-height:0}._main_1m1nv_7{display:flex;flex:1 1 auto;min-height:0;overflow:hidden}._sidebarLeft_1m1nv_13{position:relative;flex-shrink:0;border-right:1px solid var(--pi-color-border, #353b46);display:flex;flex-direction:column;min-width:0}._leftHandle_1m1nv_21{right:-3px}._center_1m1nv_24{flex:1 1 auto;display:flex;flex-direction:column;min-width:0;min-height:0}._sidebarRight_1m1nv_31{position:relative;flex-shrink:0;border-left:1px solid var(--pi-color-border, #353b46);display:flex;flex-direction:column;min-width:0}._rightHandle_1m1nv_39{left:-3px}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as a}from"./vendor-react-BoIQBqDW.js";import{u as f}from"./vendor-query-AtKBh_Yt.js";import{a as s,d as m,r as y}from"./index-
|
|
2
|
-
//# sourceMappingURL=use-file-download-
|
|
1
|
+
import{r as a}from"./vendor-react-BoIQBqDW.js";import{u as f}from"./vendor-query-AtKBh_Yt.js";import{a as s,d as m,r as y}from"./index-BTP_UxAo.js";function p(o,u=!0){var i;const l=s(e=>e.client),n=s(e=>e.daemon),c=f({queryKey:y.fileDownload(o),queryFn:async()=>{if(!l||!n)throw new Error("not connected");const e=await m(n).download(o),t=new Blob([Uint8Array.from(e.bytes)],{type:e.mimeType||"application/octet-stream"});return{objectUrl:URL.createObjectURL(t),mimeType:e.mimeType,fileName:e.fileName}},enabled:!!l&&!!n&&!!o&&u,staleTime:1/0,gcTime:0}),r=a.useRef(null);return a.useEffect(()=>{var t;const e=((t=c.data)==null?void 0:t.objectUrl)??null;e&&r.current&&r.current!==e&&URL.revokeObjectURL(r.current),r.current=e},[(i=c.data)==null?void 0:i.objectUrl]),a.useEffect(()=>()=>{r.current&&URL.revokeObjectURL(r.current)},[]),c}export{p as u};
|
|
2
|
+
//# sourceMappingURL=use-file-download-CwyNTuhL.js.map
|
package/dist/web/assets/{use-file-download-BPiZ1x6n.js.map → use-file-download-CwyNTuhL.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-file-download-
|
|
1
|
+
{"version":3,"file":"use-file-download-CwyNTuhL.js","sources":["../../../src/hooks/use-file-download.ts"],"sourcesContent":["/**\n * `use-file-download` — TanStack Query wrapper over the binary file-transfer download path\n * (`file_download_token_request` → `file_download_request` → chunked `Begin`/`Chunk`/`End`\n * binary frames), for viewers that need raw bytes rather than the UTF-8 preview\n * `file_read_request` returns (images, video — POC_TO_APP_PLAN_UI.md §4.5 follow-up: modular\n * file preview). Resolves to an object URL, revoked once superseded by a new one or once this\n * consumer unmounts.\n */\n\nimport { useEffect, useRef } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { rpcKeys } from \"@pi-studio-ui/lib/connection/rpc-keys.js\";\nimport { transferFor } from \"./file-transfer-instance.js\";\n\nexport interface FileDownload {\n objectUrl: string;\n mimeType?: string;\n fileName?: string;\n}\n\nexport function useFileDownload(path: string, enabled = true) {\n const client = useConnectionStore((s) => s.client);\n const daemon = useConnectionStore((s) => s.daemon);\n\n const query = useQuery({\n queryKey: rpcKeys.fileDownload(path),\n queryFn: async (): Promise<FileDownload> => {\n if (!client || !daemon) throw new Error(\"not connected\");\n const file = await transferFor(daemon).download(path);\n // `Blob`'s DOM typings require an `ArrayBuffer`-backed view; the assembled `Uint8Array`'s\n // `ArrayBufferLike` backing (a decode-time implementation detail) doesn't satisfy that on\n // its own, so copy into a plain `ArrayBuffer`-backed `Uint8Array` first.\n const blob = new Blob([Uint8Array.from(file.bytes)], {\n type: file.mimeType || \"application/octet-stream\",\n });\n return { objectUrl: URL.createObjectURL(blob), mimeType: file.mimeType, fileName: file.fileName };\n },\n enabled: Boolean(client) && Boolean(daemon) && Boolean(path) && enabled,\n // Object URLs are process-local, non-serializable browser resources — never persist them or\n // silently refetch behind this hook's back (that would leak the previous blob's URL).\n staleTime: Infinity,\n gcTime: 0,\n });\n\n // Revoke the previous object URL once a new one supersedes it, and the current one on unmount\n // — TanStack Query's cache has no notion that this value owns a browser resource to release.\n const urlRef = useRef<string | null>(null);\n useEffect(() => {\n const nextUrl = query.data?.objectUrl ?? null;\n if (nextUrl && urlRef.current && urlRef.current !== nextUrl) {\n URL.revokeObjectURL(urlRef.current);\n }\n urlRef.current = nextUrl;\n }, [query.data?.objectUrl]);\n\n useEffect(() => {\n return () => {\n if (urlRef.current) URL.revokeObjectURL(urlRef.current);\n };\n }, []);\n\n return query;\n}\n"],"names":["useFileDownload","path","enabled","client","useConnectionStore","s","daemon","query","useQuery","rpcKeys","file","transferFor","blob","urlRef","useRef","useEffect","nextUrl","_a"],"mappings":"oJAqBO,SAASA,EAAgBC,EAAcC,EAAU,GAAM,OAC5D,MAAMC,EAASC,EAAoBC,GAAMA,EAAE,MAAM,EAC3CC,EAASF,EAAoBC,GAAMA,EAAE,MAAM,EAE3CE,EAAQC,EAAS,CACrB,SAAUC,EAAQ,aAAaR,CAAI,EACnC,QAAS,SAAmC,CAC1C,GAAI,CAACE,GAAU,CAACG,EAAQ,MAAM,IAAI,MAAM,eAAe,EACvD,MAAMI,EAAO,MAAMC,EAAYL,CAAM,EAAE,SAASL,CAAI,EAI9CW,EAAO,IAAI,KAAK,CAAC,WAAW,KAAKF,EAAK,KAAK,CAAC,EAAG,CACnD,KAAMA,EAAK,UAAY,0BAAA,CACxB,EACD,MAAO,CAAE,UAAW,IAAI,gBAAgBE,CAAI,EAAG,SAAUF,EAAK,SAAU,SAAUA,EAAK,QAAA,CACzF,EACA,QAAS,EAAQP,GAAW,EAAQG,GAAW,EAAQL,GAASC,EAGhE,UAAW,IACX,OAAQ,CAAA,CACT,EAIKW,EAASC,EAAAA,OAAsB,IAAI,EACzCC,OAAAA,EAAAA,UAAU,IAAM,OACd,MAAMC,IAAUC,EAAAV,EAAM,OAAN,YAAAU,EAAY,YAAa,KACrCD,GAAWH,EAAO,SAAWA,EAAO,UAAYG,GAClD,IAAI,gBAAgBH,EAAO,OAAO,EAEpCA,EAAO,QAAUG,CACnB,EAAG,EAACC,EAAAV,EAAM,OAAN,YAAAU,EAAY,SAAS,CAAC,EAE1BF,EAAAA,UAAU,IACD,IAAM,CACPF,EAAO,SAAS,IAAI,gBAAgBA,EAAO,OAAO,CACxD,EACC,CAAA,CAAE,EAEEN,CACT"}
|
package/dist/web/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>Pi-Studio</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BTP_UxAo.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BoIQBqDW.js">
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-query-AtKBh_Yt.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/vendor-markdown-B8HSIhaA.js">
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/vendor-icons-CX25WOn8.js">
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/vendor-overlays-UwLNGk04.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/vendor-dnd-D9kA7FgH.js">
|
|
16
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
16
|
+
<link rel="stylesheet" crossorigin href="/assets/index-EefWgf31.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body>
|
|
19
19
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@av-pi-studio/web-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@av-pi-studio/client": "^0.0.
|
|
18
|
-
"@av-pi-studio/protocol": "^0.0.
|
|
17
|
+
"@av-pi-studio/client": "^0.0.41",
|
|
18
|
+
"@av-pi-studio/protocol": "^0.0.41",
|
|
19
19
|
"@codemirror/language": "^6.12.4",
|
|
20
20
|
"@codemirror/language-data": "^6.5.2",
|
|
21
21
|
"@codemirror/state": "^6.7.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ChatPanel-BqI2xnxv.js","sources":["../../../src/ui/status-badge.ts","../../../src/components/primitives/StatusBadge.tsx","../../../src/timeline/tool-mapping.ts","../../../src/lib/connection/files-changed.ts","../../../src/hooks/agent-stream-events.ts","../../../src/hooks/use-agent-stream.ts","../../../src/features/chat/rows/AssistantRow.tsx","../../../src/features/chat/rows/ReasoningRow.tsx","../../../src/features/chat/rows/ToolCard.tsx","../../../src/features/chat/rows/UserRow.tsx","../../../src/features/chat/rows/ErrorRow.tsx","../../../src/features/chat/rows/SystemRow.tsx","../../../src/features/chat/Timeline.tsx","../../../src/features/chat/Attachments.tsx","../../../src/features/chat/Composer.tsx","../../../src/features/chat/ChatPanel.tsx"],"sourcesContent":["// StatusBadge + Alert variant contracts.\n// ui-components.md § Surfaces / badges / chips / avatars\n\nexport type StatusBadgeVariant = \"success\" | \"error\" | \"muted\";\n\n// Single semantic token per variant — text color AND a translucent tint of the SAME token as\n// background (matches `ChangesPanel.module.css`'s `.added`/`.modified`/`.deleted` convention).\n// Never split bg/border/text across different token families (e.g. `success` vs `statusSuccess`)\n// — they can diverge in the theme (dark mode's `success` aliases the blue accent, not green),\n// producing a badge with mismatched border/background colors.\nexport type BadgeTokens = {\n token: string;\n};\n\nexport function statusBadgeTokens(variant: StatusBadgeVariant): BadgeTokens {\n switch (variant) {\n case \"success\":\n return { token: \"statusSuccess\" };\n case \"error\":\n return { token: \"statusDanger\" };\n case \"muted\":\n return { token: \"foregroundMuted\" };\n }\n}\n\nexport type AlertVariant = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport type AlertIconInfo = {\n /** Lucide icon name string for the alert variant. */\n icon: string;\n /** Theme token key for the icon/border/title accent color. */\n accentToken: string;\n};\n\nexport function alertIconInfo(variant: AlertVariant): AlertIconInfo {\n switch (variant) {\n case \"default\":\n return { icon: \"info\", accentToken: \"foregroundMuted\" };\n case \"info\":\n return { icon: \"info\", accentToken: \"accent\" };\n case \"success\":\n return { icon: \"check-circle\", accentToken: \"success\" };\n case \"warning\":\n return { icon: \"triangle-alert\", accentToken: \"statusWarning\" };\n case \"error\":\n return { icon: \"circle-x\", accentToken: \"destructive\" };\n }\n}\n\n// AttachmentPill remove-button visibility — mirrors hover-to-show pattern.\nexport function attachmentPillRemoveVisible(\n isNativeCtx: boolean,\n isCompact: boolean,\n hovered: boolean,\n): boolean {\n return isNativeCtx || isCompact || hovered;\n}\n","/**\n * StatusBadge — small rounded pill with variant coloring.\n * ui-components.md § Surfaces / badges / chips / avatars\n */\n\nimport { type ReactNode } from \"react\";\nimport styles from \"./StatusBadge.module.css\";\nimport { statusBadgeTokens, type StatusBadgeVariant } from \"@pi-studio-ui/ui/status-badge.js\";\n\nexport interface StatusBadgeProps {\n label: ReactNode;\n variant: StatusBadgeVariant;\n className?: string;\n}\n\nexport function StatusBadge({ label, variant, className }: StatusBadgeProps) {\n const { token } = statusBadgeTokens(variant);\n const color = `var(--pi-color-${token})`;\n return (\n <span\n className={`${styles.badge}${className ? ` ${className}` : \"\"}`}\n style={{\n backgroundColor: `color-mix(in srgb, ${color} 18%, transparent)`,\n borderColor: `color-mix(in srgb, ${color} 45%, transparent)`,\n color,\n }}\n >\n {label}\n </span>\n );\n}\n","/**\n * tool.kind → display label + icon. Scoped to the protocol's `ToolCallDetail` union\n * (shell/read/edit/write/search/fetch/task) — POC_TO_APP_PLAN_UI.md §3 `timeline/tool-mapping.ts`.\n */\n\nimport type { ToolCallDetail } from \"@av-pi-studio/protocol\";\nimport {\n Terminal,\n Eye,\n Pencil,\n FilePlus,\n Search,\n Globe,\n ListTree,\n type LucideIcon,\n} from \"lucide-react\";\nimport { toolDetailText } from \"./row-model.js\";\n\nconst ICON_BY_KIND: Record<ToolCallDetail[\"kind\"], LucideIcon> = {\n shell: Terminal,\n read: Eye,\n edit: Pencil,\n write: FilePlus,\n search: Search,\n fetch: Globe,\n task: ListTree,\n};\n\nexport function toolIcon(tool: ToolCallDetail): LucideIcon {\n return ICON_BY_KIND[tool.kind] ?? Terminal;\n}\n\n/** Human label for a tool card header, e.g. \"shell\", \"edit\". */\nexport function toolLabel(tool: ToolCallDetail): string {\n return tool.kind;\n}\n\n/** One-line detail summary for a tool card (POC: `t.command || t.path || t.query || …`). */\nexport function toolSummary(tool: ToolCallDetail): string {\n return toolDetailText(tool);\n}\n\n/** File path a tool touched, if any — used to target `filesChanged` invalidation (§4.5). */\nexport function toolFilePath(tool: ToolCallDetail): string | null {\n switch (tool.kind) {\n case \"read\":\n case \"write\":\n case \"edit\":\n return tool.path ?? null;\n default:\n return null;\n }\n}\n\n/** True for tool kinds whose completion should invalidate open file/diff/explorer/git queries. */\nexport function toolMutatesFiles(tool: ToolCallDetail): boolean {\n return tool.kind === \"write\" || tool.kind === \"edit\" || tool.kind === \"shell\";\n}\n\n/**\n * Expandable detail body for a tool card, as an ordered list of sections. `diff` renders as a\n * `<DiffView>`; `code` renders in a monospace block. Order: input detail (command/path/query/…)\n * first, then tool output (stdout, file content, etc.) if present. Empty array = header-only card\n * with nothing worth expanding.\n */\nexport type ToolBodySection = { kind: \"diff\"; patch: string } | { kind: \"code\"; text: string };\n\nexport function toolBody(tool: ToolCallDetail): ToolBodySection[] {\n const sections: ToolBodySection[] = [];\n if (tool.kind === \"edit\" && tool.diff) sections.push({ kind: \"diff\", patch: tool.diff });\n else {\n const text = toolDetailText(tool);\n if (text) sections.push({ kind: \"code\", text });\n }\n if (tool.output) sections.push({ kind: \"code\", text: tool.output });\n return sections;\n}\n\n/** Concise inline label shown in the collapsed header (basename for paths, first line for commands). */\nexport function toolInlineDetail(tool: ToolCallDetail): string {\n const text = toolDetailText(tool);\n if (!text) return \"\";\n switch (tool.kind) {\n case \"read\":\n case \"write\":\n case \"edit\": {\n const parts = text.split(\"/\");\n return parts[parts.length - 1] || text;\n }\n case \"shell\": {\n const firstLine = text.split(\"\\n\", 1)[0] ?? text;\n return firstLine;\n }\n default:\n return text;\n }\n}\n","/**\n * `filesChanged` signal — invalidates the file/diff/explorer query caches after a completed\n * write/edit/shell tool call (POC `scheduleFileRefresh`/`reloadOpenFileTabs`, chat.html\n * ~line 1070-1092, POC_TO_APP_PLAN_UI.md §4.3/§4.5/§5). Debounced ~500ms to coalesce a burst of\n * tool completions (POC used `setTimeout(...,600)`/`400`).\n *\n * The daemon does NOT push a `checkout_status_update` automatically after a git-affecting tool\n * completion, so this module also fires an explicit `checkout_refresh_request` for the active\n * cwd — `ChangesPanel`/`FileExplorer` then pick up the resulting push/refetch reactively, since\n * they're already subscribed (`use-checkout-status.ts`) or query-cache-driven (`use-explorer.ts`).\n *\n * NOTE (follow-up, cross-slice): this module only *exports* the invalidation function. The actual\n * call site — wiring this into the timeline reducer's `tool_call` handling on `status:\"completed\"`\n * for `toolMutatesFiles(tool) === true` — belongs to the chat/session-store slice (built in\n * parallel) or the top-level app wiring; do not import/call it from `timeline/reducer.ts` here,\n * that file is a shared contract file owned across slices.\n */\n\nimport type { QueryClient } from \"@tanstack/react-query\";\nimport type { PiStudioClient } from \"@av-pi-studio/client\";\n\nconst DEBOUNCE_MS = 500;\nlet pendingTimer: ReturnType<typeof setTimeout> | undefined;\n\n/**\n * Invalidate file/diff/explorer TanStack Query caches and refresh git status for `cwd`.\n * Debounced: repeated calls within `DEBOUNCE_MS` coalesce into a single invalidation pass.\n *\n * `toolFilePath` is accepted for future path-scoped invalidation (POC `reloadOpenFileTabs`\n * matched by path suffix) but the current pass invalidates the whole `file`/`explorer` query\n * families — TanStack Query dedupes refetches for inactive queries, so this is cheap and correct\n * even when the path is unknown.\n */\nexport function invalidateAfterToolCompletion(\n queryClient: QueryClient,\n client: PiStudioClient | null,\n cwd: string | null,\n _toolFilePath: string | null,\n): void {\n clearTimeout(pendingTimer);\n pendingTimer = setTimeout(() => {\n pendingTimer = undefined;\n void queryClient.invalidateQueries({ queryKey: [\"file\"] });\n void queryClient.invalidateQueries({ queryKey: [\"explorer\"] });\n if (client && cwd) {\n void client.connection.request(\"checkout_refresh_request\", { cwd }).catch(() => {});\n }\n }, DEBOUNCE_MS);\n}\n","/**\n * Shared `AgentStreamEvent` → store-update logic, consumed by the live subscription\n * (`use-agent-stream.ts`), which attaches the instant a session's `agentId` is bound —\n * including a freshly materialized draft, before its first turn can possibly start streaming\n * (`Composer.tsx`'s file header) — so there is no separate raw-broadcast/first-turn-gate path\n * here anymore.\n */\n\nimport type { PiStudioClient } from \"@av-pi-studio/client\";\nimport type { AgentStreamEvent } from \"@av-pi-studio/protocol\";\nimport type { QueryClient } from \"@tanstack/react-query\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport { toolMutatesFiles, toolFilePath } from \"@pi-studio-ui/timeline/tool-mapping.js\";\nimport { invalidateAfterToolCompletion } from \"@pi-studio-ui/lib/connection/files-changed.js\";\n\nexport interface ApplyAgentStreamEventArgs {\n sessionId: string;\n event: AgentStreamEvent;\n client: PiStudioClient;\n queryClient: QueryClient;\n}\n\nexport function applyAgentStreamEvent({\n sessionId,\n event,\n client,\n queryClient,\n}: ApplyAgentStreamEventArgs): void {\n const sessionStore = useSessionStore.getState();\n sessionStore.applyStreamEvent(sessionId, event);\n switch (event.kind) {\n case \"turn_started\":\n sessionStore.setStatus(sessionId, \"running\");\n break;\n case \"turn_completed\":\n sessionStore.setStatus(sessionId, \"idle\");\n break;\n case \"turn_failed\":\n sessionStore.setStatus(sessionId, \"error\");\n break;\n case \"turn_canceled\":\n sessionStore.setStatus(sessionId, \"idle\");\n break;\n case \"tool_call\": {\n if (event.status === \"completed\" && toolMutatesFiles(event.tool)) {\n const session = sessionStore.sessions[sessionId];\n const cwd = session?.cwd || null;\n invalidateAfterToolCompletion(queryClient, client, cwd, toolFilePath(event.tool));\n }\n break;\n }\n default:\n break;\n }\n}\n","/**\n * Live timeline subscription for a chat session. Subscribes to\n * `client.agent(agentId).timeline.subscribe` whenever both the connection's `client` and the\n * session's `agentId` are available, routing every event through `applyAgentStreamEvent`\n * (POC_TO_APP_PLAN_UI.md §4.3). Also mirrors the POC's `handleAgentStream` turn-lifecycle →\n * `session.status` transitions so the Composer's Stop button and the session-list status dot\n * stay live.\n *\n * NOTE: this only covers events that arrive *after* the subscription attaches, which requires a\n * bound `agentId`. The daemon runs the whole first turn of a brand-new agent *before*\n * `create_agent_request` resolves, so `Composer.handleSend` applies that first turn live from the\n * raw broadcast (latching the agent id from the first `agent_stream` frame it sees) and only\n * calls `bindAgent` once the RPC resolves — after the turn is already applied. This hook therefore\n * attaches only in time for *follow-up* turns, which is exactly what avoids double-applying the\n * first turn (the reducer is not event-id-idempotent).\n */\n\nimport { useEffect } from \"react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport { applyAgentStreamEvent } from \"./agent-stream-events.js\";\n\nexport function useAgentStream(sessionId: string): void {\n const client = useConnectionStore((s) => s.client);\n const agentId = useSessionStore((s) => s.sessions[sessionId]?.agentId ?? null);\n const queryClient = useQueryClient();\n\n useEffect(() => {\n if (!client || !agentId) return;\n\n const unsubscribe = client.agent(agentId).timeline.subscribe((event) => {\n applyAgentStreamEvent({ sessionId, event, client, queryClient });\n });\n\n return unsubscribe;\n }, [client, agentId, sessionId, queryClient]);\n}\n","/**\n * Assistant message row (POC `.msg.assistant`, POC_TO_APP_PLAN_UI.md §4.3). While streaming,\n * renders plain text with a blinking cursor — re-parsing markdown on every token would be\n * wasteful (§6 Performance strategy). Once `turn_completed` finalizes the row (`streaming:\n * false`), it renders through `<Markdown>`.\n */\n\nimport type { AssistantRow as AssistantRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport { Markdown } from \"@pi-studio-ui/timeline/markdown.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface AssistantRowProps {\n row: AssistantRowModel;\n}\n\nexport function AssistantRow({ row }: AssistantRowProps) {\n return (\n <div className={`${styles.row} ${styles.assistant}${row.streaming ? ` ${styles.streaming}` : \"\"}`}>\n <span className={styles.who}>assistant</span>\n {row.streaming ? (\n <span className={styles.streamingText}>\n {row.text}\n <span className={styles.cursor}>▍</span>\n </span>\n ) : (\n <Markdown text={row.text} />\n )}\n </div>\n );\n}\n","/**\n * Reasoning row — dimmer/italic styling, visually distinct from assistant replies (POC\n * `.msg.reasoning`, POC_TO_APP_PLAN_UI.md §4.3). Streams as plain text with a cursor, same\n * rationale as `AssistantRow`.\n */\n\nimport type { ReasoningRow as ReasoningRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport { Markdown } from \"@pi-studio-ui/timeline/markdown.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface ReasoningRowProps {\n row: ReasoningRowModel;\n}\n\nexport function ReasoningRow({ row }: ReasoningRowProps) {\n return (\n <div className={`${styles.row} ${styles.reasoning}`}>\n <span className={styles.who}>thinking</span>\n {row.streaming ? (\n <span className={styles.streamingText}>\n {row.text}\n <span className={styles.cursor}>▍</span>\n </span>\n ) : (\n <Markdown text={row.text} />\n )}\n </div>\n );\n}\n","/**\n * Tool call card — icon + label + inline detail + status badge header, with an expandable body\n * (POC `.msg.tool`, POC_TO_APP_PLAN_UI.md §4.3). Collapsed by default; clicking the header reveals\n * the full detail as an ordered list of sections: input detail (`edit` diffs render through the\n * shared `<DiffView>`; shell command/path/query/url/task description render in a monospace block)\n * followed by tool output (stdout, file content, etc.), when present. Cards with no expandable\n * sections (`toolBody` → `[]`) show only the header. The virtualized timeline re-measures on\n * expand via `measureElement`, so height changes need no special handling here.\n */\n\nimport { useState } from \"react\";\nimport { ChevronRight } from \"lucide-react\";\nimport { clsx } from \"clsx\";\nimport { StatusBadge } from \"@pi-studio-ui/components/primitives/StatusBadge.js\";\nimport { DiffView } from \"@pi-studio-ui/features/files/DiffView.js\";\nimport { toolIcon, toolLabel, toolInlineDetail, toolBody } from \"@pi-studio-ui/timeline/tool-mapping.js\";\nimport type { ToolRow } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface ToolCardProps {\n row: ToolRow;\n}\n\nconst BADGE_VARIANT = {\n running: \"muted\",\n completed: \"success\",\n error: \"error\",\n} as const;\n\nexport function ToolCard({ row }: ToolCardProps) {\n const [expanded, setExpanded] = useState(false);\n const Icon = toolIcon(row.tool);\n const inlineDetail = toolInlineDetail(row.tool);\n const body = toolBody(row.tool);\n const hasBody = body.length > 0;\n\n return (\n <div className={clsx(styles.row, styles.tool)}>\n <button\n type=\"button\"\n className={styles.toolHeader}\n onClick={() => hasBody && setExpanded((v) => !v)}\n aria-expanded={hasBody ? expanded : undefined}\n disabled={!hasBody}\n >\n {hasBody && (\n <ChevronRight\n size={12}\n className={clsx(styles.toolChevron, expanded && styles.toolChevronOpen)}\n />\n )}\n <span className={clsx(styles.toolIcon, styles[row.status])}>\n <Icon size={14} />\n </span>\n <span className={styles.toolLabel}>{toolLabel(row.tool)}</span>\n {inlineDetail && (\n <span className={styles.toolInlineDetail} title={inlineDetail}>\n {inlineDetail}\n </span>\n )}\n <StatusBadge className={styles.toolBadge} label={row.status} variant={BADGE_VARIANT[row.status]} />\n </button>\n {expanded && hasBody && (\n <div className={styles.toolBody}>\n {body.map((section, i) =>\n section.kind === \"diff\" ? (\n <DiffView key={i} patch={section.patch} />\n ) : (\n <pre key={i} className={styles.toolCode}>\n {section.text}\n </pre>\n ),\n )}\n </div>\n )}\n </div>\n );\n}\n","/**\n * User message row — plain text + optional image thumbnails (POC `.msg.user`,\n * POC_TO_APP_PLAN_UI.md §4.3/§4.4). Images render at up to 200×150, matching the POC's inline\n * `userBubble.appendChild(img)` styling. Clicking a thumbnail opens it full-size in a `Dialog`.\n *\n * `row.pending` (optimistic echo not yet confirmed by the server's `user_message` broadcast —\n * see Composer.tsx) dims the row via CSS; `row.failed` (the RPC rejected before confirmation\n * ever arrived) tints it toward the error color and appends a \"failed to send\" label instead.\n * `row.queued` (steered mid-turn, not yet handed to the LLM — cleared by a `queue_update` stream\n * event, see `timeline/reducer.ts`'s `onQueueUpdate`) shows a small \"queued\" pill next to the\n * sender label. All three are terminal/transient states set by the reducer — this component only\n * reflects them.\n */\n\nimport { useState } from \"react\";\nimport { Clock } from \"lucide-react\";\nimport { Dialog } from \"@pi-studio-ui/components/primitives/Dialog.js\";\nimport type { UserRow as UserRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface UserRowProps {\n row: UserRowModel;\n}\n\nexport function UserRow({ row }: UserRowProps) {\n const [openedSrc, setOpenedSrc] = useState<string | null>(null);\n\n const stateClass = row.failed\n ? styles.userFailed\n : row.pending\n ? styles.userPending\n : row.queued\n ? styles.userQueued\n : \"\";\n\n return (\n <div className={`${styles.row} ${styles.user}${stateClass ? ` ${stateClass}` : \"\"}`}>\n <span className={styles.who}>\n you{row.failed ? \" · failed to send\" : \"\"}\n {row.queued && !row.failed && (\n <span className={styles.queuedBadge}>\n <Clock size={9} />\n queued\n </span>\n )}\n </span>\n {row.text}\n {row.images && row.images.length > 0 && (\n <div className={styles.userImages}>\n {row.images.map((img, i) => {\n const src = `data:${img.mimeType ?? \"image/png\"};base64,${img.data ?? \"\"}`;\n return (\n <img\n key={i}\n className={styles.userImage}\n src={src}\n alt=\"\"\n role=\"button\"\n tabIndex={0}\n onClick={() => setOpenedSrc(src)}\n onKeyDown={(ev) => {\n if (ev.key === \"Enter\" || ev.key === \" \") setOpenedSrc(src);\n }}\n />\n );\n })}\n </div>\n )}\n <Dialog\n open={openedSrc !== null}\n onOpenChange={(open) => {\n if (!open) setOpenedSrc(null);\n }}\n title=\"Image\"\n width=\"auto\"\n bare\n className={styles.imageDialog}\n >\n {openedSrc && <img className={styles.imageDialogPreview} src={openedSrc} alt=\"\" />}\n </Dialog>\n </div>\n );\n}\n","/**\n * Error row — red-tinted block (POC `.msg.err`, POC_TO_APP_PLAN_UI.md §4.3), used for\n * `turn_failed`/`error` stream events.\n */\n\nimport type { ErrorRow as ErrorRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface ErrorRowProps {\n row: ErrorRowModel;\n}\n\nexport function ErrorRow({ row }: ErrorRowProps) {\n return (\n <div className={`${styles.row} ${styles.error}`}>\n <span className={styles.who}>error</span>\n {row.text}\n </div>\n );\n}\n","/**\n * System row — muted/italic styling (POC's `turn_canceled` \"(canceled)\" reasoning-styled bubble,\n * POC_TO_APP_PLAN_UI.md §4.3), used for canceled-turn markers and other system notices.\n */\n\nimport type { SystemRow as SystemRowModel } from \"@pi-studio-ui/timeline/row-model.js\";\nimport styles from \"./rows.module.css\";\n\nexport interface SystemRowProps {\n row: SystemRowModel;\n}\n\nexport function SystemRow({ row }: SystemRowProps) {\n return <div className={`${styles.row} ${styles.system}`}>{row.text}</div>;\n}\n","/**\n * Virtualized timeline viewport — TanStack Virtual over `session.timeline.rows` with\n * variable-size rows (POC `.chat-area`, POC_TO_APP_PLAN_UI.md §4.3/§6). Auto-scrolls to the\n * bottom on new rows unless the user has scrolled up more than 40px from the bottom; re-sticks\n * whenever the row count grows from a user's own send (POC's forced `scrollTop = scrollHeight`,\n * fixed to respect manual scroll-up). The mount-time \"grew\" tracking ref reverts itself on\n * cleanup — required for correctness under React StrictMode's dev-only double-invoke, which\n * otherwise swallows the necessary scroll-to-bottom on a freshly restored/opened session (see\n * the effect's own comment).\n */\n\nimport { useEffect, useRef } from \"react\";\nimport { measureElement as measureElementDefault, useVirtualizer } from \"@tanstack/react-virtual\";\nimport type { SessionEntry } from \"@pi-studio-ui/stores/session-store.js\";\nimport type { TimelineRow } from \"@pi-studio-ui/timeline/row-model.js\";\nimport { AssistantRow } from \"./rows/AssistantRow.js\";\nimport { ReasoningRow } from \"./rows/ReasoningRow.js\";\nimport { ToolCard } from \"./rows/ToolCard.js\";\nimport { UserRow } from \"./rows/UserRow.js\";\nimport { ErrorRow } from \"./rows/ErrorRow.js\";\nimport { SystemRow } from \"./rows/SystemRow.js\";\nimport styles from \"./Timeline.module.css\";\n\nexport interface TimelineProps {\n session: SessionEntry;\n}\n\nconst STICK_THRESHOLD_PX = 40;\n\nfunction renderRow(row: TimelineRow) {\n switch (row.kind) {\n case \"user\":\n return <UserRow row={row} />;\n case \"assistant\":\n return <AssistantRow row={row} />;\n case \"reasoning\":\n return <ReasoningRow row={row} />;\n case \"tool\":\n return <ToolCard row={row} />;\n case \"error\":\n return <ErrorRow row={row} />;\n case \"system\":\n return <SystemRow row={row} />;\n }\n}\n\nexport function Timeline({ session }: TimelineProps) {\n const rows = session.timeline.rows;\n const running = session.status === \"running\";\n const scrollRef = useRef<HTMLDivElement>(null);\n const stickToBottomRef = useRef(true);\n // Init to 0 (not `rows.length`) so a freshly-mounted tab with existing history — a brand-new\n // chat tab switch or a session restored from disk — still counts as \"grew\" on its first effect\n // run and scrolls to the last message, instead of opening at the top.\n const prevRowCountRef = useRef(0);\n\n const virtualizer = useVirtualizer({\n count: rows.length,\n getScrollElement: () => scrollRef.current,\n estimateSize: () => 48,\n overscan: 8,\n getItemKey: (index) => rows[index]?.id ?? index,\n // `TabPanelHost` keeps inactive chat tabs mounted under `display:none` rather than\n // unmounting them (so switching tabs preserves scroll position — see its own doc comment).\n // But a `display:none` ancestor collapses every row to a 0×0 border box, and the default\n // `measureElement` would cache that bogus 0 height — shrinking `.inner`'s total height to\n // ~0 and permanently clamping the scroll container's `scrollTop` to 0 in the process, which\n // survives the tab becoming visible again (the browser never un-clamps a scroll offset just\n // because content grows back). Skip the measurement while hidden and keep whatever size is\n // already cached (or the `estimateSize` default on first mount) instead.\n measureElement: (element, entry, instance) => {\n if ((element as HTMLElement).offsetParent !== null) return measureElementDefault(element, entry, instance);\n const index = instance.indexFromElement(element);\n const key = instance.options.getItemKey(index);\n return instance.itemSizeCache.get(key) ?? instance.options.estimateSize(index);\n },\n });\n\n function handleScroll(): void {\n const el = scrollRef.current;\n if (!el) return;\n const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;\n stickToBottomRef.current = distanceFromBottom < STICK_THRESHOLD_PX;\n }\n\n useEffect(() => {\n const prevCount = prevRowCountRef.current;\n const grew = rows.length > prevCount;\n prevRowCountRef.current = rows.length;\n if (grew && stickToBottomRef.current) {\n virtualizer.scrollToIndex(rows.length - 1, { align: \"end\" });\n }\n // React StrictMode double-invokes this effect on mount (mount -> phantom cleanup -> mount,\n // same instance — see TerminalPanel.tsx's own StrictMode doc comment for the established\n // pattern here). `@tanstack/react-virtual`'s own scroll-element attachment effect DOES\n // correctly redo its setup across that phantom cycle and, in doing so, resets the DOM\n // `scrollTop` back to 0 on the second (real) attach — but without this cleanup, this ref's\n // `grew` flip from the first (phantom) invocation would make the second invocation a false\n // \"unchanged\" no-op, permanently losing the scroll-to-bottom to the library's reset and\n // leaving a freshly restored/opened session's timeline stuck at the top. Reverting the ref\n // on cleanup makes each real invocation see the true count it started from.\n return () => {\n prevRowCountRef.current = prevCount;\n };\n }, [rows.length, virtualizer]);\n\n if (rows.length === 0) {\n return (\n <div className={styles.viewport} ref={scrollRef}>\n {running ? (\n <div className={styles.working} role=\"status\" aria-live=\"polite\">\n <span className={styles.workingDots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n Agent is working…\n </div>\n ) : (\n <div className={styles.empty}>No messages yet — say something to start.</div>\n )}\n </div>\n );\n }\n\n return (\n <div className={styles.viewport} ref={scrollRef} onScroll={handleScroll}>\n <div className={styles.inner} style={{ height: virtualizer.getTotalSize() }}>\n {virtualizer.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index];\n if (!row) return null;\n return (\n <div\n key={virtualRow.key}\n ref={virtualizer.measureElement}\n data-index={virtualRow.index}\n className={styles.rowWrap}\n style={{ transform: `translateY(${virtualRow.start}px)` }}\n >\n {renderRow(row)}\n </div>\n );\n })}\n </div>\n {running && (\n <div className={styles.working} role=\"status\" aria-live=\"polite\">\n <span className={styles.workingDots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n Agent is working…\n </div>\n )}\n </div>\n );\n}\n","/**\n * Attachment preview strip — presentational thumbnail row with remove buttons (POC\n * `renderAttachments`, POC_TO_APP_PLAN_UI.md §4.4). Pending-image state lives in `Composer`;\n * this component only renders `images` and forwards `onRemove(index)`.\n */\n\nimport styles from \"./Attachments.module.css\";\n\nexport interface PendingImage {\n mimeType: string;\n /** Base64 payload, no `data:...;base64,` prefix — sent to the daemon as-is. */\n data: string;\n /** Full data URL, for the thumbnail `<img src>`. */\n thumbUrl: string;\n}\n\nexport interface AttachmentsProps {\n images: PendingImage[];\n onRemove: (index: number) => void;\n}\n\nexport function Attachments({ images, onRemove }: AttachmentsProps) {\n if (images.length === 0) return null;\n\n return (\n <div className={styles.strip}>\n {images.map((img, i) => (\n <div key={i} className={styles.thumb}>\n <img src={img.thumbUrl} alt=\"\" />\n <button\n type=\"button\"\n className={styles.remove}\n title=\"Remove\"\n onClick={() => onRemove(i)}\n >\n ×\n </button>\n </div>\n ))}\n </div>\n );\n}\n\n/** `FileReader.readAsDataURL` wrapped as a promise (POC `addImageFile`). */\nexport function readImageFile(file: File): Promise<PendingImage> {\n const { promise, resolve, reject } = Promise.withResolvers<PendingImage>();\n const reader = new FileReader();\n reader.onload = () => {\n const result = reader.result;\n if (typeof result !== \"string\") {\n reject(new Error(\"Unexpected FileReader result\"));\n return;\n }\n const commaIndex = result.indexOf(\",\");\n const data = commaIndex >= 0 ? result.slice(commaIndex + 1) : result;\n resolve({ mimeType: file.type, data, thumbUrl: result });\n };\n reader.onerror = () => reject(reader.error ?? new Error(\"Failed to read file\"));\n reader.readAsDataURL(file);\n return promise;\n}\n","/**\n * Composer — autosizing textarea + attach/send/stop (POC `initChatPanel`/`send()`,\n * POC_TO_APP_PLAN_UI.md §4.4). Every send goes through `ensureMaterialized` (`stores/\n * materialize.ts`) first: a brand-new session (`agentId: null`) becomes a real, persisted draft\n * via a no-`initialPrompt` `createAgent` call — the daemon persists the record but does NOT spawn\n * a provider process yet (`agent-service.ts` `handleCreate`'s deferred-draft branch); the process\n * spawns lazily on this very send (`spawnOrResumeSession`). `ensureMaterialized` is a no-op once\n * already bound, so this is the single path for both \"first message ever\" and every follow-up:\n * `client.agent(agentId).send(...)`. Stop → `client.agent(agentId).interrupt()`.\n *\n * Because the agent is bound (materialized) *before* this call, `useAgentStream` (attaches once\n * `agentId` is set) is already subscribed by the time `send`'s turn starts streaming — unlike the\n * old \"one RPC does create-agent-and-run-the-first-turn\" path, there is no window where the first\n * turn's events arrive on a raw broadcast nobody is listening to, so this file no longer needs a\n * first-turn gate/latch dance for a still-unbound session.\n *\n * OPTIMISTIC ECHO: `send_agent_prompt` blocks server-side until the whole turn finishes, and even\n * the *first* broadcast event only fires once the agent process is booted/warm — for a session\n * materializing on this very send, that means a real process-spawn+handshake before anything\n * appears (see AGENTS.md \"First-message latency\"). To hide that, `submit` mints a\n * `clientMessageId` and inserts the user's row into the timeline *synchronously*, before the RPC\n * is even issued. The daemon echoes the same id back verbatim as the `user_message` event's\n * `messageId` (`packages/server/src/agent/agent-service.ts` `runTurn`); the reducer\n * (`timeline/reducer.ts` `onUserMessage`) matches it against the pending row and confirms it in\n * place instead of appending a duplicate.\n *\n * MODEL & MATERIALIZATION: a chat materializes the instant its tab is created\n * (`tab-store.ts` `openNewChat` calls `ensureMaterialized`, which also resolves and pins the\n * default model into the record if none was set yet) — long before this composer even mounts, in\n * the common case. `submit`'s own `ensureMaterialized` call below is the retry path: it only does\n * real work when the eager materialize failed or never ran (opened while disconnected). Picking a\n * different model (`StatusBar.tsx`'s `handleSelectModel`) updates the already-materialized\n * record's `config.model`/`config.modelProvider` directly — replayed by the server on first spawn\n * regardless of whether it's the resolved default or an explicit pick (`spawnOrResumeSession`).\n *\n * STEERING: while the agent is running, the primary action becomes **Steer** instead of Send\n * (`send_agent_prompt` is only legal when idle — see AGENTS.md \"Steering\"). Steer reuses the exact\n * optimistic-echo + reconciliation path above (`clientMessageId` in, same `user_message` echo\n * back), just against `client.agent(id).steer(...)` instead of `.send(...)`, and marks the\n * optimistic row `queued: true` so `UserRow` can show a \"queued\" badge until a `queue_update`\n * stream event drops the text from its `steering[]` list (`timeline/reducer.ts`'s\n * `onQueueUpdate`). Follow-up (`.followUp(...)`, delivered only after the turn fully stops) is\n * intentionally not surfaced here — SDK/CLI only for now. Steering only makes sense against a\n * live agent — never triggers materialization itself.\n */\n\nimport { useRef, useState, type ChangeEvent, type ClipboardEvent, type KeyboardEvent } from \"react\";\nimport { Navigation, Paperclip, Send, Square } from \"lucide-react\";\nimport { Button } from \"@pi-studio-ui/components/primitives/Button.js\";\nimport { TextArea } from \"@pi-studio-ui/components/primitives/TextInput.js\";\nimport { useConnectionStore } from \"@pi-studio-ui/lib/connection/connection-store.js\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport { ensureMaterialized } from \"@pi-studio-ui/stores/materialize.js\";\nimport { Attachments, readImageFile, type PendingImage } from \"./Attachments.js\";\nimport styles from \"./Composer.module.css\";\n\nconst MAX_TEXTAREA_HEIGHT = 160;\n\nexport interface ComposerProps {\n sessionId: string;\n}\n\nfunction autoResize(el: HTMLTextAreaElement): void {\n el.style.height = \"auto\";\n el.style.height = `${Math.min(el.scrollHeight, MAX_TEXTAREA_HEIGHT)}px`;\n}\n\n/** `steer_agent_response`'s `{ ok: false }` — no live turn, or the provider lacks steering. */\nfunction isOkFalse(value: unknown): boolean {\n return typeof value === \"object\" && value !== null && \"ok\" in value && value.ok === false;\n}\n\nexport function Composer({ sessionId }: ComposerProps) {\n const client = useConnectionStore((s) => s.client);\n const session = useSessionStore((s) => s.sessions[sessionId]);\n const addOptimisticUserMessage = useSessionStore((s) => s.addOptimisticUserMessage);\n const markUserMessageFailed = useSessionStore((s) => s.markUserMessageFailed);\n const setCwd = useSessionStore((s) => s.setCwd);\n\n const [text, setText] = useState(\"\");\n const [images, setImages] = useState<PendingImage[]>([]);\n // Two independent busy flags: `sending` guards Send/create-agent, whose RPC blocks\n // server-side for the *entire* turn (`runTurn` doesn't resolve until the turn ends — see\n // AGENTS.md \"Steering\"); `steering` guards the separate, fire-and-forget steer RPC. Sharing\n // one flag would leave the Steer button disabled for the whole turn, since the original\n // send's promise stays pending throughout it.\n const [sending, setSending] = useState(false);\n const [steering, setSteering] = useState(false);\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const fileInputRef = useRef<HTMLInputElement>(null);\n\n const running = session?.status === \"running\";\n const busy = running ? steering : sending;\n const canSubmit = Boolean(client) && !busy && (text.trim().length > 0 || images.length > 0);\n\n async function addImageFile(file: File): Promise<void> {\n if (!file.type.startsWith(\"image/\")) return;\n try {\n const image = await readImageFile(file);\n setImages((prev) => [...prev, image]);\n } catch {\n // Best-effort attachment read — ignore unreadable files (POC has no error UI here either).\n }\n }\n\n function handleFileInputChange(ev: ChangeEvent<HTMLInputElement>): void {\n for (const file of ev.target.files ?? []) void addImageFile(file);\n ev.target.value = \"\";\n }\n\n function handlePaste(ev: ClipboardEvent<HTMLTextAreaElement>): void {\n for (const item of ev.clipboardData.items) {\n if (item.type.startsWith(\"image/\")) {\n ev.preventDefault();\n const file = item.getAsFile();\n if (file) void addImageFile(file);\n }\n }\n }\n\n function handleRemoveImage(index: number): void {\n setImages((prev) => prev.filter((_, i) => i !== index));\n }\n\n function handleTextareaChange(ev: ChangeEvent<HTMLTextAreaElement>): void {\n setText(ev.target.value);\n autoResize(ev.target);\n }\n\n function handleKeyDown(ev: KeyboardEvent<HTMLTextAreaElement>): void {\n if (ev.key === \"Enter\" && !ev.shiftKey) {\n ev.preventDefault();\n void submit(running ? \"steer\" : \"send\");\n }\n }\n\n async function submit(mode: \"send\" | \"steer\"): Promise<void> {\n if (!client || !session) return;\n if (mode === \"steer\" ? steering : sending) return;\n // Steering only makes sense against a live agent — a running session always has one.\n if (mode === \"steer\" && !session.agentId) return;\n const trimmed = text.trim();\n if (!trimmed && images.length === 0) return;\n\n setText(\"\");\n if (textareaRef.current) autoResize(textareaRef.current);\n const sentImages = images;\n setImages([]);\n\n const prompt = trimmed || \"Describe this image\";\n const rpcImages =\n sentImages.length > 0\n ? sentImages.map((img) => ({ mimeType: img.mimeType, data: img.data }))\n : undefined;\n\n // Optimistic echo: render the user's row synchronously instead of waiting for the daemon's\n // `user_message` broadcast (see file header). `clientMessageId` is round-tripped through the\n // RPC below and echoed back verbatim as the broadcast event's `messageId`, which is how the\n // reducer reconciles this row instead of appending a duplicate once the server confirms it.\n // Steered rows are additionally marked `queued: true` (cleared by a later `queue_update`).\n const clientMessageId = crypto.randomUUID();\n addOptimisticUserMessage(sessionId, clientMessageId, prompt, rpcImages, mode === \"steer\");\n\n const setBusy = mode === \"steer\" ? setSteering : setSending;\n setBusy(true);\n try {\n if (mode === \"steer\") {\n // Fire-and-forget injection into the live turn — never touches materialization, which\n // only applies to the send-only, no-agent-yet path below.\n const result = await client\n .agent(session.agentId!)\n .steer(prompt, { clientMessageId, images: rpcImages });\n if (isOkFalse(result)) markUserMessageFailed(sessionId, clientMessageId);\n } else {\n if (!session.agentId) setCwd(sessionId, session.cwd || \"~\");\n // Retry path (see file header \"MODEL & MATERIALIZATION\") for a session whose eager\n // materialize (`tab-store.ts` `openNewChat`) never ran or failed — a no-op once already\n // bound. `useAgentStream` attaches the instant `agentId` is bound, before this turn's\n // first event can possibly arrive (see file header), so `send` needs no separate\n // first-turn broadcast path the way a combined create-and-run RPC used to.\n const agentId = await ensureMaterialized(client, sessionId);\n await client.agent(agentId).send(prompt, { clientMessageId, images: rpcImages });\n }\n } catch {\n // RPC rejection before any `user_message` broadcast arrived (e.g. dropped connection) —\n // the optimistic row would otherwise stay pending forever with no feedback. If the server\n // *did* manage to broadcast `user_message` first (the row is already reconciled), this is\n // a no-op — `markUserMessageFailed` only touches a still-pending row. Turn-level failures\n // that occur after that point still surface via `agent_stream` `error`/`turn_failed`\n // events (POC swallows the RPC rejection the same way; the stream is the source of truth\n // for those).\n markUserMessageFailed(sessionId, clientMessageId);\n } finally {\n setBusy(false);\n }\n }\n\n function handleStop(): void {\n if (!session?.agentId) return;\n void client?.agent(session.agentId).interrupt();\n }\n\n return (\n <div className={styles.composer}>\n <div className={styles.inputArea}>\n <TextArea\n ref={textareaRef}\n className={styles.textarea}\n rows={1}\n value={text}\n placeholder={\n running\n ? \"Steer the running turn… (Enter to steer, Shift+Enter for newline)\"\n : \"Ask anything… (Enter to send, Shift+Enter for newline)\"\n }\n onChange={handleTextareaChange}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n />\n <Attachments images={images} onRemove={handleRemoveImage} />\n </div>\n <Button\n className={styles.attachBtn}\n variant=\"ghost\"\n size=\"md\"\n iconOnly\n title=\"Attach image\"\n onClick={() => fileInputRef.current?.click()}\n >\n <Paperclip size={16} />\n </Button>\n <input\n ref={fileInputRef}\n className={styles.hiddenFileInput}\n type=\"file\"\n accept=\"image/*\"\n multiple\n onChange={handleFileInputChange}\n />\n <div className={styles.actions}>\n {running ? (\n <Button\n size=\"sm\"\n disabled={!canSubmit}\n onClick={() => void submit(\"steer\")}\n leftIcon={<Navigation size={14} />}\n >\n Steer\n </Button>\n ) : (\n <Button\n size=\"sm\"\n disabled={!canSubmit}\n onClick={() => void submit(\"send\")}\n leftIcon={<Send size={14} />}\n >\n Send\n </Button>\n )}\n {running && (\n <Button\n size=\"sm\"\n variant=\"destructive\"\n onClick={handleStop}\n leftIcon={<Square size={14} />}\n >\n Stop\n </Button>\n )}\n </div>\n </div>\n );\n}\n","/**\n * ChatPanel — the tab content mounted by `panel-registry.ts` for `kind: \"chat\"` tabs. Looks up\n * the session by `tab.data.sessionId`, keeps its timeline live via `useAgentStream`, and renders\n * the virtualized `Timeline` + `Composer` (POC_TO_APP_PLAN_UI.md §4.3/§4.4).\n */\n\nimport { useAgentStream } from \"@pi-studio-ui/hooks/use-agent-stream.js\";\nimport { useSessionStore } from \"@pi-studio-ui/stores/session-store.js\";\nimport type { Tab, ChatTabData } from \"@pi-studio-ui/stores/tab-store.js\";\nimport { Timeline } from \"./Timeline.js\";\nimport { Composer } from \"./Composer.js\";\nimport styles from \"./ChatPanel.module.css\";\n\nexport interface ChatPanelProps {\n tab: Tab;\n}\n\nexport function ChatPanel({ tab }: ChatPanelProps) {\n // `panel-registry.ts` only ever mounts this component for `tab.kind === \"chat\"`, whose `data`\n // is always `ChatTabData` — narrowed here since `Tab[\"data\"]` is a union at the type level.\n const { sessionId } = tab.data as ChatTabData;\n const session = useSessionStore((s) => s.sessions[sessionId]);\n\n useAgentStream(sessionId);\n\n if (!session) {\n return (\n <div className={styles.panel}>\n <div className={styles.empty}>Session not found.</div>\n </div>\n );\n }\n\n return (\n <div className={styles.panel}>\n <Timeline session={session} />\n <Composer sessionId={session.id} />\n </div>\n );\n}\n"],"names":["statusBadgeTokens","variant","StatusBadge","label","className","token","color","jsx","styles","ICON_BY_KIND","Terminal","Eye","Pencil","FilePlus","Search","Globe","ListTree","toolIcon","tool","toolLabel","toolFilePath","toolMutatesFiles","toolBody","sections","text","toolDetailText","toolInlineDetail","parts","DEBOUNCE_MS","pendingTimer","invalidateAfterToolCompletion","queryClient","client","cwd","_toolFilePath","applyAgentStreamEvent","sessionId","event","sessionStore","useSessionStore","session","useAgentStream","useConnectionStore","s","agentId","_a","useQueryClient","useEffect","AssistantRow","row","jsxs","Markdown","ReasoningRow","BADGE_VARIANT","ToolCard","expanded","setExpanded","useState","Icon","inlineDetail","body","hasBody","clsx","v","ChevronRight","section","i","DiffView","UserRow","openedSrc","setOpenedSrc","stateClass","Clock","img","src","ev","Dialog","open","ErrorRow","SystemRow","STICK_THRESHOLD_PX","renderRow","Timeline","rows","running","scrollRef","useRef","stickToBottomRef","prevRowCountRef","virtualizer","useVirtualizer","index","element","entry","instance","measureElementDefault","key","handleScroll","el","distanceFromBottom","prevCount","grew","virtualRow","Attachments","images","onRemove","readImageFile","file","promise","resolve","reject","reader","result","commaIndex","data","MAX_TEXTAREA_HEIGHT","autoResize","isOkFalse","value","Composer","addOptimisticUserMessage","markUserMessageFailed","setCwd","setText","setImages","sending","setSending","steering","setSteering","textareaRef","fileInputRef","canSubmit","addImageFile","image","prev","handleFileInputChange","handlePaste","item","handleRemoveImage","_","handleTextareaChange","handleKeyDown","submit","mode","trimmed","sentImages","prompt","rpcImages","clientMessageId","setBusy","ensureMaterialized","handleStop","TextArea","Button","Paperclip","Navigation","Send","Square","ChatPanel","tab"],"mappings":"kpBAcO,SAASA,GAAkBC,EAA0C,CAC1E,OAAQA,EAAA,CACN,IAAK,UACH,MAAO,CAAE,MAAO,eAAA,EAClB,IAAK,QACH,MAAO,CAAE,MAAO,cAAA,EAClB,IAAK,QACH,MAAO,CAAE,MAAO,iBAAA,CAAkB,CAExC,CCRO,SAASC,GAAY,CAAE,MAAAC,EAAO,QAAAF,EAAS,UAAAG,GAA+B,CAC3E,KAAM,CAAE,MAAAC,CAAA,EAAUL,GAAkBC,CAAO,EACrCK,EAAQ,kBAAkBD,CAAK,IACrC,OACEE,EAAAA,IAAC,OAAA,CACC,UAAW,GAAGC,GAAO,KAAK,GAAGJ,EAAY,IAAIA,CAAS,GAAK,EAAE,GAC7D,MAAO,CACL,gBAAiB,sBAAsBE,CAAK,qBAC5C,YAAa,sBAAsBA,CAAK,qBACxC,MAAAA,CAAA,EAGD,SAAAH,CAAA,CAAA,CAGP,CCZA,MAAMM,GAA2D,CAC/D,MAAOC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AA3H,GAAc2H,EAAI,KACpBvH,EAAUD,EAAiBI,GAAMA,EAAE,SAASP,CAAS,CAAC,EAI5D,OAFAK,GAAeL,CAAS,EAEnBI,EASHU,EAAAA,KAAC,MAAA,CAAI,UAAW1C,EAAO,MACrB,SAAA,CAAAD,MAAC2E,IAAS,QAAA1C,EAAkB,EAC5BjC,EAAAA,IAACgH,GAAA,CAAS,UAAW/E,EAAQ,EAAA,CAAI,CAAA,EACnC,EAVEjC,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAO,MACrB,SAAAD,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAO,MAAO,SAAA,oBAAA,CAAkB,EAClD,CAUN"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChatPanel-BqI2xnxv.js","assets/vendor-react-BoIQBqDW.js","assets/vendor-query-AtKBh_Yt.js","assets/vendor-icons-CX25WOn8.js","assets/markdown-D9FuaV1m.js","assets/vendor-highlight-DCzuSv8g.js","assets/vendor-markdown-B8HSIhaA.js","assets/vendor--os7hw7d.js","assets/markdown-BQwXm0MF.css","assets/DiffView-DlVCPvLc.js","assets/DiffView-CRbeRztO.css","assets/vendor-overlays-UwLNGk04.js","assets/vendor-dnd-D9kA7FgH.js","assets/ChatPanel-CTnpkb2U.css","assets/FilePanel-BBfL4iba.js","assets/FilePanel-DIInFr3h.css","assets/TerminalPanel-DyLLAPYP.js","assets/vendor-terminal-BhzX2_ts.js","assets/vendor-terminal-DYP7pi_n.css","assets/TerminalPanel-BQj62G6N.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Tn=Object.defineProperty;var Nn=(t,e,n)=>e in t?Tn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var I=(t,e,n)=>Nn(t,typeof e!="symbol"?e+"":e,n);import{r as v,j as i,d as En}from"./vendor-react-BoIQBqDW.js";import{Q as Rn,a as qn,u as Ot,b as Mn,c as Re,d as Bn}from"./vendor-query-AtKBh_Yt.js";import{A as l,B as u,C as A,D as Pt,E as q,F as qe,G as ne,H as B,I as w,J as D,K as O,L as Ue,M as _e,N as pe}from"./vendor--os7hw7d.js";import{L as $n,P as An,a as Dn,b as Fn,c as On,E as zt,C as ft,d as Ht,F as Pn,e as Wt,f as Lt,S as Ut,G as zn,g as Hn,M as Kt,X as ot,h as Ee,i as Gt,j as Wn,k as Vt,U as Ln,R as Un,l as Jt,m as Kn,n as Gn,o as Vn,D as Jn,p as Yn,A as Xn}from"./vendor-icons-CX25WOn8.js";import{R as Ke,T as Ge,P as Ve,C as Je,I as G,S as rt,D as Qn,a as Zn,b as es,c as ts,d as wt,e as at}from"./vendor-overlays-UwLNGk04.js";import{u as ns,a as ss,D as os,c as rs,S as as,h as is,P as cs,b as ls,C as ds}from"./vendor-dnd-D9kA7FgH.js";import{_ as ht}from"./vendor-highlight-DCzuSv8g.js";import"./vendor-markdown-B8HSIhaA.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const r of o)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&s(a)}).observe(document,{childList:!0,subtree:!0});function n(o){const r={};return o.integrity&&(r.integrity=o.integrity),o.referrerPolicy&&(r.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?r.credentials="include":o.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(o){if(o.ep)return;o.ep=!0;const r=n(o);fetch(o.href,r)}})();const us=new Rn;function Yt(t){const e=t.trim().replace(/^#/,""),n=e.length===3?e.split("").map(s=>s+s).join(""):e;if(n.length!==6||/[^0-9a-fA-F]/.test(n))throw new Error(`Invalid hex color: ${t}`);return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16)}}function ps(t){return Math.max(0,Math.min(255,Math.round(t)))}function fs({r:t,g:e,b:n}){const s=o=>ps(o).toString(16).padStart(2,"0");return`#${s(t)}${s(e)}${s(n)}`}function hs(t){const{r:e,g:n,b:s}=Yt(t),o=r=>{const a=r/255;return a<=.03928?a/12.92:((a+.055)/1.055)**2.4};return .2126*o(e)+.7152*o(n)+.0722*o(s)}function mt(t,e="#18181b",n="#ffffff"){return hs(t)>.45?e:n}function ms(t,e){const{r:n,g:s,b:o}=Yt(t),r=Math.max(0,Math.min(1,e));return fs({r:n+(255-n)*r,g:s+(255-s)*r,b:o+(255-o)*r})}function De(t){const e=t.trim().replace(/^#/,"");return(e.length===3||e.length===6)&&!/[^0-9a-fA-F]/.test(e)}const L=(t,e,n,s,o,r,a,c,d,f,g)=>({50:t,100:e,200:n,300:s,400:o,500:r,600:a,700:c,800:d,900:f,950:g}),x={zinc:L("#fafafa","#f4f4f5","#e4e4e7","#d4d4d8","#a1a1aa","#71717a","#52525b","#3f3f46","#27272a","#18181b","#09090b"),gray:L("#f9fafb","#f3f4f6","#e5e7eb","#d1d5db","#9ca3af","#6b7280","#4b5563","#374151","#1f2937","#111827","#030712"),slate:L("#f8fafc","#f1f5f9","#e2e8f0","#cbd5e1","#94a3b8","#64748b","#475569","#334155","#1e293b","#0f172a","#020617"),blue:L("#eff6ff","#dbeafe","#bfdbfe","#93c5fd","#60a5fa","#3b82f6","#2563eb","#1d4ed8","#1e40af","#1e3a8a","#172554"),green:L("#f0fdf4","#dcfce7","#bbf7d0","#86efac","#4ade80","#22c55e","#16a34a","#15803d","#166534","#14532d","#052e16"),red:L("#fef2f2","#fee2e2","#fecaca","#fca5a5","#f87171","#ef4444","#dc2626","#b91c1c","#991b1b","#7f1d1d","#450a0a"),teal:L("#f0fdfa","#ccfbf1","#99f6e4","#5eead4","#2dd4bf","#14b8a6","#0d9488","#0f766e","#115e59","#134e4a","#042f2e"),amber:L("#fffbeb","#fef3c7","#fde68a","#fcd34d","#fbbf24","#f59e0b","#d97706","#b45309","#92400e","#78350f","#451a03"),yellow:L("#fefce8","#fef9c3","#fef08a","#fde047","#facc15","#eab308","#ca8a04","#a16207","#854d0e","#713f12","#422006"),purple:L("#faf5ff","#f3e8ff","#e9d5ff","#d8b4fe","#c084fc","#a855f7","#9333ea","#7e22ce","#6b21a8","#581c87","#3b0764"),orange:L("#fff7ed","#ffedd5","#fed7aa","#fdba74","#fb923c","#f97316","#ea580c","#c2410c","#9a3412","#7c2d12","#431407"),white:"#ffffff",black:"#000000"},gs={statusSuccess:"#16a34a",statusDanger:"#dc2626",statusWarning:"#f59e0b",statusMerged:"#9333ea"},_s={statusSuccess:"#15803d",statusDanger:"#b91c1c",statusWarning:"#d97706",statusMerged:"#7c3aed"};function ys(){return{keyword:x.purple[300],string:x.green[300],number:x.orange[300],boolean:x.orange[300],comment:x.zinc[500],function:x.blue[300],variable:x.zinc[200],type:x.teal[300],class:x.amber[300],constant:x.orange[300],operator:x.zinc[400],punctuation:x.zinc[400],tag:x.red[300],attribute:x.amber[300],property:x.blue[200],regexp:x.teal[300],escape:x.orange[200],heading:x.blue[300],link:x.blue[400],deleted:x.red[400],inserted:x.green[400]}}function bs(){return{keyword:x.purple[700],string:x.green[700],number:x.orange[700],boolean:x.orange[700],comment:x.zinc[500],function:x.blue[700],variable:x.zinc[800],type:x.teal[700],class:x.amber[700],constant:x.orange[700],operator:x.zinc[600],punctuation:x.zinc[600],tag:x.red[700],attribute:x.amber[700],property:x.blue[700],regexp:x.teal[700],escape:x.orange[700],heading:x.blue[700],link:x.blue[600],deleted:x.red[700],inserted:x.green[700]}}function Xt(t,e,n){return{background:t,foreground:e,cursor:n,cursorAccent:t,selectionBackground:"rgba(255,255,255,0.18)",black:x.zinc[900],red:x.red[500],green:x.green[500],yellow:x.amber[500],blue:x.blue[500],magenta:x.purple[500],cyan:x.teal[500],white:x.zinc[300],brightBlack:x.zinc[600],brightRed:x.red[400],brightGreen:x.green[400],brightYellow:x.amber[400],brightBlue:x.blue[400],brightMagenta:x.purple[400],brightCyan:x.teal[400],brightWhite:x.zinc[50]}}function xe(t){const e=x.zinc[50],n=mt(t.accent);return{surface0:t.surface0,surface1:t.surface1,surface2:t.surface2,surface3:t.surface3,surface4:t.surface4,surfaceDiffEmpty:t.surfaceDiffEmpty,surfaceSidebar:t.surfaceSidebar,surfaceSidebarHover:t.surfaceSidebarHover,surfaceWorkspace:t.surface1,foreground:e,foregroundMuted:t.mutedForeground,accent:t.accent,accentBright:t.accentBright,accentForeground:n,destructive:t.destructive,destructiveForeground:x.white,success:t.accent,successForeground:x.white,border:t.border,borderAccent:t.borderAccent,...gs,diffAddition:x.green[400],diffDeletion:x.red[500],scrollbarHandle:t.scrollbarHandle,background:t.surface0,popover:t.surface2,popoverForeground:e,primary:t.accent,secondary:t.surface2,muted:t.surface2,mutedForeground:t.mutedForeground,input:t.surface2,ring:t.accent,palette:x,syntax:ys(),terminal:Xt(t.surface0,e,t.accent)}}function ws(){const t="#1a1a1e",e="#253e6f";return{surface0:"#ffffff",surface1:"#fafafa",surface2:"#f4f4f5",surface3:"#e4e4e7",surface4:"#d4d4d8",surfaceDiffEmpty:"#f6f6f6",surfaceSidebar:"#f4f4f5",surfaceSidebarHover:"#e9e9ec",surfaceWorkspace:"#ffffff",foreground:t,foregroundMuted:"#71717a",accent:e,accentBright:"#2f4f8e",accentForeground:mt(e),destructive:"#b04138",destructiveForeground:"#ffffff",success:e,successForeground:"#ffffff",border:"#e4e4e7",borderAccent:"#ececf1",..._s,diffAddition:"#15803d",diffDeletion:"#b91c1c",scrollbarHandle:"#3f3f46",background:"#ffffff",popover:"#ffffff",popoverForeground:t,primary:e,secondary:"#f4f4f5",muted:"#f4f4f5",mutedForeground:"#71717a",input:"#f4f4f5",ring:e,palette:x,syntax:bs(),terminal:{...Xt("#ffffff",t,e),selectionBackground:"rgba(0,0,0,0.15)",white:"#ffffff",brightWhite:"#fafafa"}}}const Ss={light:"#ffffff",dark:"#3b62b0",zinc:"#808080",midnight:"#4A6BA8",claude:"#D97757",ghostty:"#8caaee"},Qt=["light","dark","zinc","midnight","claude","ghostty"];function xs(t){if(t==="light")return ws();switch(t){case"dark":return xe({surface0:"#181B1A",surface1:"#1E2120",surface2:"#272A29",surface3:"#434645",surface4:"#595B5B",surfaceDiffEmpty:"#252827",surfaceSidebar:"#141716",surfaceSidebarHover:"#1c1f1e",mutedForeground:"#A1A5A4",scrollbarHandle:"#717574",border:"#252B2A",borderAccent:"#2f3135",accent:"#2e5cb8",accentBright:"#a2b4d7",destructive:"#c64f43"});case"zinc":return xe({surface0:"#18181b",surface1:"#1f1f22",surface2:"#27272a",surface3:"#3f3f46",surface4:"#52525b",surfaceDiffEmpty:"#242427",surfaceSidebar:"#131316",surfaceSidebarHover:"#1b1b1e",mutedForeground:"#a1a1aa",scrollbarHandle:"#71717a",border:"#27272a",borderAccent:"#303036",accent:"#e4e4e7",accentBright:"#fafafa",destructive:"#c44a4a"});case"midnight":return xe({surface0:"#161820",surface1:"#1c1e27",surface2:"#252731",surface3:"#3c3e4c",surface4:"#535564",surfaceDiffEmpty:"#222430",surfaceSidebar:"#121420",surfaceSidebarHover:"#1a1c28",mutedForeground:"#9a9db0",scrollbarHandle:"#6b6e82",border:"#242636",borderAccent:"#2e3040",accent:"#3b6fcf",accentBright:"#7eaaeb",destructive:"#c44a52"});case"claude":return xe({surface0:"#1f1f1e",surface1:"#262523",surface2:"#2f2d2b",surface3:"#4a4745",surface4:"#605d5b",surfaceDiffEmpty:"#2a2826",surfaceSidebar:"#1a1918",surfaceSidebarHover:"#222120",mutedForeground:"#ada9a5",scrollbarHandle:"#78746f",border:"#2c2a27",borderAccent:"#36332f",accent:"#d97757",accentBright:"#e89a7f",destructive:"#cf513e"});case"ghostty":return xe({surface0:"#282c34",surface1:"#2f333d",surface2:"#383c48",surface3:"#4a4f5e",surface4:"#5b6175",surfaceDiffEmpty:"#323643",surfaceSidebar:"#21252d",surfaceSidebarHover:"#292d36",mutedForeground:"#c8ccd8",scrollbarHandle:"#a0a4b2",border:"#353a47",borderAccent:"#3f4454",accent:"#89b4fa",accentBright:"#b4d0fc",destructive:"#c44a55"})}}const Zt={};for(const t of Qt){const e=t==="light"?"light":"dark";Zt[t]={name:t,colorScheme:e,colors:xs(t),swatch:Ss[t]}}const vs=Zt,ks={0:0,1:4,"1.5":6,2:8,3:12,4:16,6:24,8:32,12:48,16:64,20:80,24:96,32:128},en={xs:12,code:12,sm:14,base:16,lg:18,xl:20,"2xl":22,"3xl":26,"4xl":34},Is={normal:"400",medium:"500",semibold:"600",bold:"700"},js={none:0,sm:2,base:4,md:6,lg:8,xl:12,"2xl":16,full:9999},Cs={0:0,1:1,2:2},Ts={0:0,50:.5,100:1},Ns={xs:12,sm:14,md:16,lg:20},Es={diff:22},tn='system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',nn='ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace';function Rs(t){const e=t==="dark"?"rgba(0,0,0,0.55)":"rgba(24,24,27,0.12)";return{sm:{color:e,offsetX:0,offsetY:1,radius:2,elevation:1},md:{color:e,offsetX:0,offsetY:3,radius:8,elevation:4},lg:{color:e,offsetX:0,offsetY:10,radius:24,elevation:12}}}function sn(t){const e=vs[t];return{name:t,colorScheme:e.colorScheme,colors:e.colors,spacing:ks,fontSize:{...en},fontFamily:{ui:tn,mono:nn},lineHeight:{...Es},iconSize:Ns,fontWeight:Is,borderRadius:js,borderWidth:Cs,opacity:Ts,shadow:Rs(e.colorScheme),swatch:e.swatch}}const qs=16,Ms=10,Bs=24;function $s(t,e){const n=e.themeName??t.name,s=sn(n),o=e.uiFont&&e.uiFont.trim()!==""?e.uiFont:tn,r=e.monoFont&&e.monoFont.trim()!==""?e.monoFont:nn;let a={...s.fontSize};if(e.fontSize!=null){const d=Math.max(Ms,Math.min(Bs,e.fontSize))/qs,f=["xs","code","sm","base","lg","xl","2xl","3xl","4xl"];for(const g of f){const b=en[g];a[g]=Math.round(b*d)}}return{...s,fontSize:a,fontFamily:{ui:o,mono:r}}}function As(t){return sn(t)}const Ds="dark";function Fs(t){const e={};Os(t.colors,e);for(const[n,s]of Object.entries(t.spacing))e[`--pi-spacing-${n}`]=`${s}px`;for(const[n,s]of Object.entries(t.fontSize))e[`--pi-font-size-${n}`]=`${s}px`;e["--pi-font-ui"]=t.fontFamily.ui,e["--pi-font-mono"]=t.fontFamily.mono,e["--pi-line-height-diff"]=`${t.lineHeight.diff}px`;for(const[n,s]of Object.entries(t.iconSize))e[`--pi-icon-size-${n}`]=`${s}px`;for(const[n,s]of Object.entries(t.fontWeight))e[`--pi-font-weight-${n}`]=String(s);for(const[n,s]of Object.entries(t.borderRadius))e[`--pi-radius-${n}`]=s===9999?"9999px":`${s}px`;for(const[n,s]of Object.entries(t.borderWidth))e[`--pi-border-width-${n}`]=`${s}px`;for(const[n,s]of Object.entries(t.opacity))e[`--pi-opacity-${n}`]=String(s);for(const[n,s]of Object.entries(t.shadow))if(typeof s=="string")e[`--pi-shadow-${n}`]=s;else if(s&&typeof s=="object"){const o=s;e[`--pi-shadow-${n}`]=`${o.offsetX}px ${o.offsetY}px ${o.radius}px ${o.color}`}return e["--pi-color-scheme"]=t.colorScheme,e}function Os(t,e){const{palette:n,syntax:s,terminal:o,...r}=t;for(const[a,c]of Object.entries(r))typeof c=="string"&&(e[`--pi-color-${a}`]=c);s&&Ps(s,e),o&&(e["--pi-terminal-bg"]=o.background,e["--pi-terminal-fg"]=o.foreground)}function Ps(t,e){for(const[n,s]of Object.entries(t))typeof s=="string"&&(e[`--syntax-${zs(n)}`]=s)}function zs(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Hs(t){if(typeof document>"u")return;const e=document.documentElement.style;for(const[s,o]of Object.entries(t))e.setProperty(s,o);const n=t["--pi-color-scheme"];n&&document.documentElement.style.setProperty("color-scheme",n)}function Ws(t){const e=Fs(t);Hs(e)}const ve=l().min(1,"Asset path must not be empty"),Ls=u({accent:l().refine(De,{message:"accent must be a valid #rrggbb hex color"}),accentBright:l().refine(De,{message:"accentBright must be a valid #rrggbb hex color"}).optional(),accentForeground:l().refine(De,{message:"accentForeground must be a valid #rrggbb hex color"}).optional(),swatch:l().refine(De,{message:"swatch must be a valid #rrggbb hex color"}).optional()}),Us=u({logoLight:ve,logoDark:ve,logoMark:ve.optional(),icon:ve,splash:ve.optional()}),Ks=u({docs:l().url().optional(),support:l().url().optional(),issues:l().url().optional(),website:l().url().optional()}).optional(),Gs=u({copyright:l().optional(),companyName:l().optional()}).optional();u({productName:l().min(1,"productName is required"),shortName:l().optional(),tagline:l().optional(),colors:Ls,assets:Us,links:Ks,legal:Gs});function Vs(t){const e=t.accent,n=t.accentBright??ms(e,.35),s=t.accentForeground??mt(e),o=t.swatch??e;return{accent:e,accentBright:n,accentForeground:s,swatch:o}}function Js(t,e){return{...t,colors:{...t.colors,accent:e.accent,accentBright:e.accentBright,accentForeground:e.accentForeground,primary:e.accent,ring:e.accent},swatch:e.swatch}}const St="pi-studio-appearance";function Ys(t,e){let n=c(t),s=null;function o(g){return g==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":g}function r(g,b){const h=o(g),S=As(h);let m=$s(S,{...b,themeName:h});if(e!=null&&e.colors){const _=Vs(e.colors);m=Js(m,_)}return m}function a(){const g=JSON.stringify({mode:n.mode,settings:n.settings});t.set(St,g)}function c(g){const b=g.get(St);let h=Ds,S={};if(b)try{const _=JSON.parse(b);_.mode&&(Qt.includes(_.mode)||_.mode==="system")&&(h=_.mode),_.settings&&typeof _.settings=="object"&&(S=_.settings)}catch{}const m=r(h,S);return{mode:h,settings:S,resolvedTheme:m}}function d(){n={...n,resolvedTheme:r(n.mode,n.settings)},a()}const f={getState(){return n},setMode(g){n={...n,mode:g},d(),f.apply()},updateSettings(g){n={...n,settings:{...n.settings,...g}},d(),f.apply()},apply(){Ws(n.resolvedTheme)},listen(){if(typeof window>"u")return()=>{};const g=window.matchMedia("(prefers-color-scheme: dark)"),b=()=>{n.mode==="system"&&(d(),f.apply())};return g.addEventListener("change",b),s=()=>g.removeEventListener("change",b),s}};return f}function Xs({store:t,brandConfig:e,children:n}){const s=v.useRef(null);return s.current||(s.current=Ys(t,e),s.current.apply()),v.useEffect(()=>s.current.listen(),[]),i.jsx(i.Fragment,{children:n})}const Qs={get(t){var e;try{return((e=globalThis.localStorage)==null?void 0:e.getItem(t))??null}catch{return null}},set(t,e){var n;try{(n=globalThis.localStorage)==null||n.setItem(t,e)}catch{}}};function Zs({children:t}){return i.jsx(Xs,{store:Qs,children:i.jsx(qn,{client:us,children:t})})}const eo="_btn_1chbg_4",to="_secondary_1chbg_44",no="_outline_1chbg_53",so="_ghost_1chbg_62",oo="_destructive_1chbg_72",ro="_iconOnly_1chbg_82",ao="_loadingSpinner_1chbg_89",io="_piSpin_1chbg_1",Fe={btn:eo,default:"_default_1chbg_35",secondary:to,outline:no,ghost:so,destructive:oo,iconOnly:ro,loadingSpinner:ao,piSpin:io},xt={xs:28,sm:32,md:36,lg:40},co={xs:12,sm:14,md:16,lg:20},vt={xs:8,sm:10,md:12,lg:16},lo={xs:12,sm:13,md:14,lg:15};function uo(t){const{disabled:e,loading:n}=t;return e||n?{opacity:.5,isGhostHover:!1}:{opacity:1,isGhostHover:!1}}function F({variant:t="default",size:e="md",loading:n=!1,disabled:s=!1,leftIcon:o,trailing:r,iconOnly:a=!1,children:c,style:d,className:f,...g}){const{opacity:b}=uo({disabled:s??!1,loading:n}),h=s||n,S=co[e];return i.jsxs("button",{className:A(Fe.btn,Fe[t],a&&Fe.iconOnly,f),disabled:h,"aria-busy":n||void 0,style:{minHeight:xt[e],paddingLeft:a?void 0:vt[e],paddingRight:a?void 0:vt[e],fontSize:lo[e],opacity:b,...a?{width:xt[e]}:{},...d},...g,children:[n?i.jsx($n,{className:Fe.loadingSpinner,size:S,"aria-hidden":!0}):o?i.jsx("span",{"aria-hidden":!0,style:{display:"flex",alignItems:"center",flexShrink:0},children:o}):null,c,r&&!n&&i.jsx("span",{"aria-hidden":!0,style:{display:"flex",alignItems:"center",flexShrink:0},children:r})]})}const po="_input_a7qyq_3",fo="_textarea_a7qyq_32",it={input:po,textarea:fo},Le=v.forwardRef(function({className:e,...n},s){return i.jsx("input",{ref:s,className:A(it.input,e),...n})}),zd=v.forwardRef(function({className:e,...n},s){return i.jsx("textarea",{ref:s,className:A(it.input,it.textarea,e),...n})}),on=l().datetime({offset:!0});l().uuid();l().regex(/^[A-Za-z0-9_-]+$/,"expected base64url");const Ne=Pt([q(),on]),ho=qe(["mobile","browser","cli","mcp"]),mo=u({type:w("hello"),clientId:l(),clientType:ho,protocolVersion:q(),appVersion:l().optional(),capabilities:ne(l(),B()).optional()}),go=u({status:w("server_info"),serverId:l(),hostname:l().optional(),version:l().optional(),capabilities:ne(l(),D()),features:ne(l(),D())}),_o=u({type:w("status"),payload:go}),yo=u({type:w("ping"),requestId:l(),clientSentAt:Ne.optional()}),bo=u({type:w("pong"),requestId:l(),clientSentAt:Ne.optional(),serverReceivedAt:Ne,serverSentAt:Ne}),rn=qe(["initializing","idle","running","error","closed"]),Ye=u({mimeType:l().optional(),data:l().optional()}).passthrough(),wo=u({prs:O(D()).optional(),issues:O(D()).optional()}).passthrough(),So=u({provider:l(),cwd:l(),modeId:l().optional(),model:l().optional(),modelProvider:l().optional(),thinkingOptionId:l().optional(),featureValues:ne(l(),D()).optional(),title:l().nullable().optional(),approvalPolicy:l().optional(),sandboxMode:l().optional(),networkAccess:B().optional(),webSearch:B().optional(),extra:u({pi:D().optional()}).passthrough().optional(),systemPrompt:l().optional(),mcpServers:ne(l(),D()).optional()}),xo=u({type:w("create_agent_request"),requestId:l(),config:So,env:ne(l(),l()).optional(),workspaceId:l().optional(),worktreeName:l().optional(),initialPrompt:l().optional(),clientMessageId:l().optional(),outputSchema:ne(l(),D()).optional(),images:O(Ye).optional(),attachments:wo.optional(),git:D().optional(),worktree:D().optional(),autoArchive:B().optional(),labels:ne(l(),l()).default({})}),vo=u({type:w("create_agent_response"),requestId:l(),payload:u({agentId:l()}).passthrough()}),ko=u({type:w("agent_update"),agentId:l(),status:rn.optional(),title:l().nullable().optional(),labels:ne(l(),l()).optional()}),Io=u({type:w("agent_status"),agentId:l(),status:rn}),jo=u({type:w("agent_list"),agents:O(u({id:l()}).passthrough())}),Co=u({type:w("agent_deleted"),agentId:l()}),To=u({type:w("agent_archived"),agentId:l(),archivedAt:on.optional()}),an=Ue("kind",[u({kind:w("shell"),command:l().optional(),output:l().optional()}),u({kind:w("read"),path:l().optional(),output:l().optional()}),u({kind:w("edit"),path:l().optional(),diff:l().optional(),output:l().optional()}),u({kind:w("write"),path:l().optional(),output:l().optional()}),u({kind:w("search"),query:l().optional(),output:l().optional()}),u({kind:w("fetch"),url:l().optional(),output:l().optional()}),u({kind:w("task"),description:l().optional(),output:l().optional()})]),No=Ue("kind",[u({kind:w("user_message"),messageId:l().optional(),text:l().optional(),images:O(Ye).optional()}),u({kind:w("assistant_message"),messageId:l().optional(),text:l().optional()}),u({kind:w("reasoning"),text:l().optional()}),u({kind:w("tool_call"),callId:l().optional(),tool:an,status:l().optional()}),u({kind:w("turn_started"),turnId:l().optional()}),u({kind:w("turn_completed"),turnId:l().optional()}),u({kind:w("turn_failed"),turnId:l().optional(),error:l().optional()}),u({kind:w("turn_canceled"),turnId:l().optional()}),u({kind:w("error"),message:l().optional()}),u({kind:w("queue_update"),steering:O(l()).optional(),followUp:O(l()).optional()})]),Eo=u({type:w("agent_stream"),agentId:l(),seq:q().optional(),timestamp:Ne.optional(),event:No}),Ro=qe(["before","after"]),qo=u({start:q(),end:q()}),Mo=u({type:w("fetch_agent_timeline_request"),requestId:l(),agentId:l(),cursor:l().nullable().optional(),direction:Ro,limit:q().optional()}),Bo=u({type:w("fetch_agent_timeline_response"),requestId:l(),agentId:l().optional(),items:O(D()),seqStart:q(),seqEnd:q(),sourceSeqRanges:O(qo),collapsed:B(),hasNewer:B(),startCursor:l().nullable().optional(),endCursor:l().nullable().optional()}),$o=u({type:w("agent_permission_request"),requestId:l(),agentId:l(),toolName:l().optional(),tool:an.optional(),action:D().optional(),responses:O(l()).optional()}),Ao=u({type:w("agent_permission_resolved"),requestId:l(),agentId:l(),decision:l().optional()}),Do=u({type:w("agent.permission.respond.request"),requestId:l(),permissionRequestId:l(),response:D()}),Fo=u({type:w("agent.permission.respond.response"),requestId:l(),payload:u({resolved:B()}).passthrough()}),Oo=u({type:w("respond_to_permission"),requestId:l(),permissionRequestId:l(),response:D()}),cn=qe(["conversation","files","both"]),Po=u({type:w("agent.rewind.request"),requestId:l(),agentId:l(),messageId:l(),mode:cn}).passthrough(),zo=u({type:w("agent.rewind.response"),requestId:l(),payload:u({agentId:l(),messageId:l(),mode:cn,truncatedAt:l().optional()}).passthrough()}).passthrough(),Ho=u({input:q().optional(),output:q().optional(),cacheRead:q().optional(),cacheWrite:q().optional(),total:q().optional()}).passthrough(),Wo=u({tokens:q().nullable().optional(),contextWindow:q().optional(),percent:q().nullable().optional()}).passthrough(),Lo=u({type:w("agent_session_stats_request"),requestId:l(),agentId:l()}).passthrough(),Uo=u({type:w("agent_session_stats_response"),requestId:l(),payload:u({sessionId:l().optional(),sessionFile:l().optional(),userMessages:q().optional(),assistantMessages:q().optional(),toolCalls:q().optional(),toolResults:q().optional(),totalMessages:q().optional(),tokens:Ho.optional(),cost:q().optional(),contextUsage:Wo.optional(),model:l().optional()}).passthrough()}).passthrough(),Ko=u({type:w("agent_compact_request"),requestId:l(),agentId:l(),customInstructions:l().optional()}).passthrough(),Go=u({type:w("agent_compact_response"),requestId:l(),payload:u({summary:l().optional(),firstKeptEntryId:l().optional(),tokensBefore:q().optional(),details:D().optional()}).passthrough()}).passthrough(),Vo=u({type:w("agent_new_session_request"),requestId:l(),agentId:l()}).passthrough(),Jo=u({type:w("agent_new_session_response"),requestId:l(),payload:u({cancelled:B()}).passthrough()}).passthrough(),Yo=u({type:w("agent_switch_session_request"),requestId:l(),agentId:l(),sessionPath:l()}).passthrough(),Xo=u({type:w("agent_switch_session_response"),requestId:l(),payload:u({cancelled:B()}).passthrough()}).passthrough(),Qo=u({type:w("agent_fork_request"),requestId:l(),agentId:l(),entryId:l()}).passthrough(),Zo=u({type:w("agent_fork_response"),requestId:l(),payload:u({text:l(),cancelled:B()}).passthrough()}).passthrough(),er=u({type:w("agent_fork_messages_request"),requestId:l(),agentId:l()}).passthrough(),tr=u({type:w("agent_fork_messages_response"),requestId:l(),payload:u({messages:O(u({entryId:l(),text:l()}).passthrough())}).passthrough()}).passthrough(),nr=u({type:w("agent_clone_request"),requestId:l(),agentId:l()}).passthrough(),sr=u({type:w("agent_clone_response"),requestId:l(),payload:u({cancelled:B()}).passthrough()}).passthrough(),or=u({type:w("agent_set_session_name_request"),requestId:l(),agentId:l(),name:l()}).passthrough(),rr=u({type:w("agent_set_session_name_response"),requestId:l(),payload:u({}).passthrough().optional()}).passthrough(),ar=u({type:w("agent_export_html_request"),requestId:l(),agentId:l(),outputPath:l().optional()}).passthrough(),ir=u({type:w("agent_export_html_response"),requestId:l(),payload:u({path:l()}).passthrough()}).passthrough(),cr=u({type:w("agent_set_model_request"),requestId:l(),agentId:l(),provider:l(),modelId:l()}).passthrough(),lr=u({type:w("agent_set_model_response"),requestId:l(),payload:u({}).passthrough()}).passthrough(),dr=u({type:w("agent_cycle_model_request"),requestId:l(),agentId:l()}).passthrough(),ur=u({type:w("agent_cycle_model_response"),requestId:l(),payload:u({model:D().nullable().optional(),thinkingLevel:l().optional(),isScoped:B().optional()}).passthrough()}).passthrough(),pr=u({type:w("agent_last_assistant_text_request"),requestId:l(),agentId:l()}).passthrough(),fr=u({type:w("agent_last_assistant_text_response"),requestId:l(),payload:u({text:l().nullable()}).passthrough()}).passthrough(),hr=u({type:w("steer_agent_request"),requestId:l(),agentId:l(),message:l(),images:O(Ye).optional(),clientMessageId:l().optional()}).passthrough(),mr=u({type:w("steer_agent_response"),requestId:l(),agentId:l(),ok:B()}).passthrough(),gr=u({type:w("follow_up_agent_request"),requestId:l(),agentId:l(),message:l(),images:O(Ye).optional(),clientMessageId:l().optional()}).passthrough(),_r=u({type:w("follow_up_agent_response"),requestId:l(),agentId:l(),ok:B()}).passthrough(),yr=u({type:w("rpc_error"),requestId:l(),code:l().optional(),message:l().optional(),error:l().optional()}),br=Ue("type",[xo,vo,ko,Io,jo,Co,To,Eo,Mo,Bo,$o,Ao,Do,Fo,Oo,Po,zo,Lo,Uo,Ko,Go,Vo,Jo,Yo,Xo,Qo,Zo,er,tr,nr,sr,or,rr,ar,ir,cr,lr,dr,ur,pr,fr,hr,mr,gr,_r,yr]),wr=u({type:l()}).passthrough(),Sr=u({type:w("session"),message:Pt([br,wr])});Ue("type",[mo,_o,yo,bo,Sr]);const he={Output:1,Input:2,Resize:3,Snapshot:4,Restore:5},xr=Object.fromEntries(Object.entries(he).map(([t,e])=>[e,t])),ln=u({rows:q().int().nonnegative(),cols:q().int().nonnegative()});class je extends Error{constructor(e){super(e),this.name="TerminalFrameError"}}const vr=new TextEncoder,kr=new TextDecoder;function Ir(t){if(!Number.isInteger(t)||t<0||t>255)throw new je(`slot must be an integer 0–255, got ${t}`)}function ke(t,e,n){const s=new Uint8Array(2+n.length);return s[0]=t,s[1]=e,s.set(n,2),s}function Hd(t){switch(Ir(t.slot),t.opcode){case"Output":return ke(he.Output,t.slot,t.data);case"Input":return ke(he.Input,t.slot,t.data);case"Snapshot":return ke(he.Snapshot,t.slot,t.data);case"Restore":return ke(he.Restore,t.slot,t.data);case"Resize":{const e=JSON.stringify(ln.parse({rows:t.rows,cols:t.cols}));return ke(he.Resize,t.slot,vr.encode(e))}}}function jr(t){if(t.length<2)throw new je(`frame too short: ${t.length} bytes (need ≥ 2)`);const e=t[0],n=t[1],s=xr[e];if(!s)throw new je(`unknown terminal opcode 0x${e.toString(16)}`);const o=t.subarray(2);if(s==="Resize"){let r;try{r=JSON.parse(kr.decode(o))}catch{throw new je("resize payload is not valid JSON")}const a=ln.safeParse(r);if(!a.success)throw new je("resize payload is not { rows, cols }");return{opcode:"Resize",slot:n,rows:a.data.rows,cols:a.data.cols}}return{opcode:s,slot:n,data:o.slice()}}const ge={Begin:16,Chunk:17,End:18,Error:19},Cr=Object.fromEntries(Object.entries(ge).map(([t,e])=>[e,t])),dn=u({transferId:l(),fileName:l().optional(),mimeType:l().optional(),totalBytes:q().int().nonnegative().optional()});class Ce extends Error{constructor(e){super(e),this.name="FileTransferFrameError"}}const kt=new TextEncoder,It=new TextDecoder;function Tr(t){if(!Number.isInteger(t)||t<0||t>255)throw new Ce(`stream must be an integer 0–255, got ${t}`)}function Oe(t,e,n){const s=new Uint8Array(2+n.length);return s[0]=t,s[1]=e,s.set(n,2),s}function et(t){switch(Tr(t.stream),t.opcode){case"Begin":return Oe(ge.Begin,t.stream,kt.encode(JSON.stringify(dn.parse(t.meta))));case"Chunk":return Oe(ge.Chunk,t.stream,t.data);case"End":return Oe(ge.End,t.stream,new Uint8Array([t.ok?1:0]));case"Error":return Oe(ge.Error,t.stream,kt.encode(t.message))}}function Nr(t){if(t.length<2)throw new Ce(`frame too short: ${t.length} bytes (need ≥ 2)`);const e=t[0],n=t[1],s=Cr[e];if(!s)throw new Ce(`unknown file-transfer opcode 0x${e.toString(16)}`);const o=t.subarray(2);switch(s){case"Begin":{let r;try{r=JSON.parse(It.decode(o))}catch{throw new Ce("begin payload is not valid JSON")}const a=dn.safeParse(r);if(!a.success)throw new Ce("begin payload is not a valid transfer header");return{opcode:"Begin",stream:n,meta:a.data}}case"Chunk":return{opcode:"Chunk",stream:n,data:o.slice()};case"End":return{opcode:"End",stream:n,ok:(o[0]??1)!==0};case"Error":return{opcode:"Error",stream:n,message:It.decode(o)}}}function Er(t){try{return Nr(t)}catch{return null}}const Rr=l().regex(/^[a-z][a-z0-9-]*$/,"invalid provider id"),qr=qe(["safe","moderate","dangerous","planning"]),Mr=u({supportsStreaming:B(),supportsSessionPersistence:B(),supportsDynamicModes:B(),supportsMcpServers:B(),supportsReasoningStream:B(),supportsToolInvocations:B(),supportsRewindConversation:B().optional(),supportsRewindFiles:B().optional(),supportsRewindBoth:B().optional(),supportsSteering:B().optional()}).passthrough(),Br=u({id:l(),label:l().optional(),description:l().optional(),icon:l().optional(),colorTier:qr});u({id:Rr,label:l(),description:l().optional(),extends:l().optional(),modes:O(Br),capabilities:Mr});function ct(t){return typeof t=="string"?t:t instanceof Uint8Array||Buffer.isBuffer(t)?t.toString("utf8"):String(t??"")}function un(t){let e=null;const n={onMessage:null,onClose:null,onError:null,get isOpen(){return e!==null&&e.readyState===1},connect(s){return new Promise((o,r)=>{const a=t??(()=>new WebSocket(s));try{e=t?a(s):new WebSocket(s)}catch(c){r(c);return}e.onopen=()=>o(),e.onerror=c=>{var d;(e==null?void 0:e.readyState)!==1&&r(c),(d=n.onError)==null||d.call(n,c)},e.onclose=c=>{var d;(d=n.onClose)==null||d.call(n,c.code,ct(c.reason))},e.onmessage=c=>{var f,g,b,h;const{data:d}=c;d instanceof ArrayBuffer||d instanceof Uint8Array?(f=n.onMessage)==null||f.call(n,d):typeof d=="string"?(g=n.onMessage)==null||g.call(n,d):typeof Blob<"u"&&d instanceof Blob?(b=n.onMessage)==null||b.call(n,d):Buffer.isBuffer(d)&&((h=n.onMessage)==null||h.call(n,d.buffer.slice(d.byteOffset,d.byteOffset+d.byteLength)))}})},sendText(s){e==null||e.send(s)},sendBinary(s){e==null||e.send(s)},close(s=1e3,o=""){e==null||e.close(s,o),e=null}};return n}const Te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function pn(t){let e="";for(let n=0;n<t.length;n+=3){const s=t[n],o=n+1<t.length,r=n+2<t.length,a=o?t[n+1]:0,c=r?t[n+2]:0;e+=Te[s>>2],e+=Te[(s&3)<<4|a>>4],e+=o?Te[(a&15)<<2|c>>6]:"=",e+=r?Te[c&63]:"="}return e}function fn(t){const e=t.replace(/=+$/,""),n=[];let s=0,o=0;for(const r of e){const a=Te.indexOf(r);if(a===-1)throw new Error(`invalid base64 character: ${JSON.stringify(r)}`);s=s<<6|a,o+=6,o>=8&&(o-=8,n.push(s>>o&255))}return new Uint8Array(n)}function $r(t){try{const e=JSON.parse(t);return!e||typeof e.type!="string"?null:e}catch{return null}}const He=24;function hn(t,e){const n=_e.randomBytes(He),s=_e.box.after(t,n,e),o=new Uint8Array(n.length+s.length);return o.set(n,0),o.set(s,n.length),pn(o)}function mn(t,e){let n;try{n=fn(t)}catch{return null}if(n.length<He)return null;const s=n.slice(0,He),o=n.slice(He);return _e.box.open.after(o,s,e)}function Ar(t,e){return hn(new TextEncoder().encode(t),e)}function Dr(t,e){const n=mn(t,e);return n?new TextDecoder().decode(n):null}function Fr(t,e,n,s,o,r){let a=!1;return n.onClose(c=>{var d;a=!0,(d=s.onClose)==null||d.call(s,c)}),{handleAppFrame(c){var g,b;if(a)return;const d=o();if(!r()||!d)return;const f=Dr(c.frame,d);if(f===null){(g=s.onAuthError)==null||g.call(s,new Error(`relay ${t} channel: message failed authentication`));return}(b=s.onMessage)==null||b.call(s,f)},handleBinaryFrame(c){var g,b;if(a)return;const d=o();if(!r()||!d)return;const f=mn(c.frame,d);if(f===null){(g=s.onAuthError)==null||g.call(s,new Error(`relay ${t} channel: binary message failed authentication`));return}(b=s.onBinaryMessage)==null||b.call(s,f)},send(c){if(a)throw new Error(`relay ${t} channel: cannot send after close()`);const d=o();if(!r()||!d)throw new Error(`relay ${t} channel: cannot send before the E2EE handshake completes`);n.send(JSON.stringify({type:"e2ee_app",frame:Ar(c,d)}))},sendBinary(c){if(a)throw new Error(`relay ${t} channel: cannot send after close()`);const d=o();if(!r()||!d)throw new Error(`relay ${t} channel: cannot send before the E2EE handshake completes`);n.send(JSON.stringify({type:"e2ee_bin",frame:hn(c,d)}))},close(){a||(a=!0,n.close())}}}function Or(t){const{transport:e,attachment:n,daemonPublicKey:s}=t,o=t.events??{},r=_e.box.keyPair(),a=_e.box.before(s,r.secretKey);let c=!1;const d=Fr("client",n,e,o,()=>a,()=>c);return e.onMessage(f=>{var b;const g=$r(f);if(g){if(g.type==="e2ee_ready"){if(c)return;c=!0,(b=o.onReady)==null||b.call(o);return}if(g.type==="e2ee_app"){d.handleAppFrame(g);return}g.type==="e2ee_bin"&&d.handleBinaryFrame(g)}}),e.send(JSON.stringify({type:"e2ee_hello",ephemeralPublicKey:pn(r.publicKey)})),{role:"client",attachment:n,get ready(){return c},send:d.send,sendBinary:d.sendBinary,close:d.close}}const Pr=16;function zr(t){const e=_e.hash(t);let n="";for(let s=0;s<Pr;s++)n+=e[s].toString(16).padStart(2,"0");return n}function Hr(t){const e=t.useTls?"wss":"ws",n=t.endpoint.replace(/^(?:https?|wss?):\/\//,"").replace(/\/+$/,"");return`${e}://${n}`}function Wr(t){let e=null,n=null;const s=t.sessionId??zr(t.daemonPublicKey),o={onMessage:null,onClose:null,onError:null,get isOpen(){return e!==null&&e.readyState===1&&n!==null&&n.ready},connect(r){return new Promise((a,c)=>{const d=t.factory??(()=>new WebSocket(r));try{e=t.factory?d(r):new WebSocket(r)}catch(h){c(h);return}const f=e,g=[],b=[];f.onopen=()=>{f.send(JSON.stringify({type:"relay_register",sessionId:s})),n=Or({transport:{send:h=>f.send(h),onMessage:h=>g.push(h),onClose:h=>b.push(h),close:()=>f.close()},attachment:{sessionId:s},daemonPublicKey:t.daemonPublicKey,events:{onReady:()=>a(),onMessage:h=>{var S;return(S=o.onMessage)==null?void 0:S.call(o,h)},onBinaryMessage:h=>{var S;return(S=o.onMessage)==null?void 0:S.call(o,h.slice().buffer)},onAuthError:h=>{var S;return(S=o.onError)==null?void 0:S.call(o,h)}}})},f.onerror=h=>{var S;f.readyState!==1&&c(h),(S=o.onError)==null||S.call(o,h)},f.onclose=h=>{var S;for(const m of b)m(ct(h.reason));(S=o.onClose)==null||S.call(o,h.code,ct(h.reason))},f.onmessage=h=>{const{data:S}=h;if(typeof S=="string")for(const m of g)m(S)}})},sendText(r){if(!n||!n.ready)throw new Error("relay transport: cannot send before the E2EE handshake completes");n.send(r)},sendBinary(r){if(!n||!n.ready)throw new Error("relay transport: cannot send before the E2EE handshake completes");n.sendBinary(r)},close(r=1e3,a=""){n==null||n.close(),n=null,e==null||e.close(r,a),e=null}};return o}function Lr(t){const e=t.indexOf("#"),n=e===-1?t:t.slice(e+1),s=new URLSearchParams(n),o=s.get("offer");if(!o)return null;let r;try{r=fn(o)}catch{return null}const a=s.get("relay");if(a){const d={endpoint:a,useTls:s.get("relayTls")==="1"};return{publicKeyB64:o,publicKey:r,relay:d}}const c=s.get("host")??void 0;return{publicKeyB64:o,publicKey:r,...c?{host:c}:{}}}const Ur=1;function lt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}class Kr extends Error{constructor(e,n,s){super(e),this.requestId=n,this.code=s,this.name="RpcError"}}class jt extends Error{constructor(e){super(`RPC ${e} timed out`),this.requestId=e,this.name="RpcTimeoutError"}}class Gr{constructor(e){I(this,"transport");I(this,"rpcTimeoutMs");I(this,"now");I(this,"_state","idle");I(this,"_serverId",null);I(this,"_features",{});I(this,"_serverCapabilities",{});I(this,"pending",new Map);I(this,"sessionHandlers",new Set);I(this,"terminalHandlers",new Set);I(this,"fileTransferHandlers",new Set);I(this,"stateHandlers",new Set);I(this,"helloResolve",null);I(this,"helloReject",null);this.options=e,this.transport=e.transport??un(),this.rpcTimeoutMs=e.rpcTimeoutMs??3e4,this.now=e.now??(()=>Date.now()),this.transport.onMessage=n=>this.handleIncoming(n),this.transport.onClose=(n,s)=>this.handleClose(n,s),this.transport.onError=()=>{}}get state(){return this._state}get serverId(){return this._serverId}get features(){return this._features}get serverCapabilities(){return this._serverCapabilities}hasFeature(e){return!!this._features[e]}async connect(){this.setState("connecting"),await this.transport.connect(this.options.url);const e=new Promise((s,o)=>{this.helloResolve=s,this.helloReject=o});this.transport.sendText(JSON.stringify({type:"hello",clientId:this.options.clientId,clientType:this.options.clientType,protocolVersion:this.options.protocolVersion??Ur,appVersion:this.options.appVersion,capabilities:this.options.capabilities}));const n=await e;return this._serverId=n.serverId,this._features=n.features,this._serverCapabilities=n.capabilities,this.setState("open"),n}close(e=1e3,n=""){this.setState("closing"),this.transport.close(e,n)}request(e,n={},s){const o=n.requestId??lt();return new Promise((r,a)=>{const c=s??this.rpcTimeoutMs,d=c>0?setTimeout(()=>{this.pending.delete(o),a(new jt(o))},c):null;this.pending.set(o,{resolve:f=>r(f),reject:a,timer:d}),this.sendSession({type:e,...n,requestId:o})})}sendSession(e){this.transport.sendText(JSON.stringify({type:"session",message:e}))}sendBinary(e){this.transport.sendBinary(e)}ping(e=1e4){const n=lt();return new Promise((s,o)=>{const r=e>0?setTimeout(()=>{this.pending.delete(n),o(new jt(n))},e):null;this.pending.set(n,{resolve:()=>s(),reject:o,timer:r}),this.transport.sendText(JSON.stringify({type:"ping",requestId:n,clientSentAt:this.now()}))})}onSessionMessage(e){return this.sessionHandlers.add(e),()=>this.sessionHandlers.delete(e)}onTerminalFrame(e){return this.terminalHandlers.add(e),()=>this.terminalHandlers.delete(e)}onFileTransferFrame(e){return this.fileTransferHandlers.add(e),()=>this.fileTransferHandlers.delete(e)}onStateChange(e){return this.stateHandlers.add(e),()=>this.stateHandlers.delete(e)}setState(e){if(this._state!==e){this._state=e;for(const n of this.stateHandlers)n(e)}}handleClose(e,n){this.helloReject&&(this.helloReject(new Error(`socket closed during handshake: ${n}`)),this.helloResolve=null,this.helloReject=null);for(const[,s]of this.pending)s.timer&&clearTimeout(s.timer),s.reject(new Error(`socket closed: ${n}`));this.pending.clear(),this.setState("closed")}handleIncoming(e){if(typeof e=="string"){this.handleTextFrame(e);return}if(e instanceof ArrayBuffer){this.handleBinaryFrame(new Uint8Array(e));return}typeof e.arrayBuffer=="function"&&e.arrayBuffer().then(n=>this.handleBinaryFrame(new Uint8Array(n)))}handleBinaryFrame(e){const n=e[0];if(n!==void 0&&Object.values(ge).includes(n)){const r=Er(e);if(!r)return;for(const a of this.fileTransferHandlers)a(r);return}const o=jr(e);for(const r of this.terminalHandlers)r(o)}handleTextFrame(e){let n;try{n=JSON.parse(e)}catch{return}const s=n;switch(s.type){case"status":this.handleStatus(s);return;case"pong":this.resolvePending(s.requestId,void 0);return;case"ping":this.transport.sendText(JSON.stringify({type:"pong",requestId:s.requestId,serverReceivedAt:this.now(),serverSentAt:this.now()}));return;case"session":this.handleSession(s.message);return;default:return}}handleStatus(e){const n=e.payload;(n==null?void 0:n.status)==="server_info"&&this.helloResolve&&(this.helloResolve(n),this.helloResolve=null,this.helloReject=null)}handleSession(e){if(!e||typeof e!="object")return;const n=e;if(n.type==="rpc_error"&&typeof n.requestId=="string"){const s=this.pending.get(n.requestId);s&&(s.timer&&clearTimeout(s.timer),this.pending.delete(n.requestId),s.reject(new Kr(n.message??n.error??"RPC failed",n.requestId,n.code)));return}if(typeof n.requestId=="string"&&this.pending.has(n.requestId)){const s="payload"in n?n.payload:n;this.resolvePending(n.requestId,s)}for(const s of this.sessionHandlers)s(e)}resolvePending(e,n){const s=this.pending.get(e);s&&(s.timer&&clearTimeout(s.timer),this.pending.delete(e),s.resolve(n))}}class Vr{constructor(e){this.daemon=e}get connection(){return this.daemon}async createAgent(e){return await this.daemon.request("create_agent_request",{...e})}agent(e){return new Yr(this.daemon,e)}workspace(e){return new Xr(this.daemon,e)}get providers(){return new Qr(this.daemon)}onAgentUpdate(e){return this.daemon.onSessionMessage(n=>{n.type==="agent_update"&&e(n)})}onWorkspaceUpdate(e){return this.daemon.onSessionMessage(n=>{n.type==="workspace_update"&&e(n)})}}class Jr{constructor(e,n){this.daemon=e,this.agentId=n}fetch(e={}){return this.daemon.request("fetch_agent_timeline_request",{agentId:this.agentId,cursor:e.cursor,direction:e.direction,limit:e.limit})}subscribe(e){return this.daemon.onSessionMessage(n=>{const s=n;s.type==="agent_stream"&&s.agentId===this.agentId&&s.event&&e(s.event)})}}class Yr{constructor(e,n){I(this,"timeline");this.daemon=e,this.agentId=n,this.timeline=new Jr(e,n)}send(e,n={}){return this.daemon.request("send_agent_prompt",{agentId:this.agentId,prompt:e,clientMessageId:n.clientMessageId,images:n.images})}run(e,n){return this.send(e,n)}interrupt(){return this.daemon.request("interrupt_agent",{agentId:this.agentId})}steer(e,n={}){return this.daemon.request("steer_agent_request",{agentId:this.agentId,message:e,clientMessageId:n.clientMessageId,images:n.images})}followUp(e,n={}){return this.daemon.request("follow_up_agent_request",{agentId:this.agentId,message:e,clientMessageId:n.clientMessageId,images:n.images})}update(e){return this.daemon.request("update_agent",{agentId:this.agentId,...e})}resume(){return this.daemon.request("resume_agent",{agentId:this.agentId})}archive(){return this.daemon.request("archive_agent",{agentId:this.agentId})}delete(){return this.daemon.request("delete_agent",{agentId:this.agentId})}onUpdate(e){return this.daemon.onSessionMessage(n=>{const s=n;s.type==="agent_update"&&s.agentId===this.agentId&&e(s)})}sessionStats(){return this.daemon.request("agent_session_stats_request",{agentId:this.agentId})}compact(e){return this.daemon.request("agent_compact_request",{agentId:this.agentId,customInstructions:e})}newSession(){return this.daemon.request("agent_new_session_request",{agentId:this.agentId})}switchSession(e){return this.daemon.request("agent_switch_session_request",{agentId:this.agentId,sessionPath:e})}fork(e){return this.daemon.request("agent_fork_request",{agentId:this.agentId,entryId:e})}forkMessages(){return this.daemon.request("agent_fork_messages_request",{agentId:this.agentId})}clone(){return this.daemon.request("agent_clone_request",{agentId:this.agentId})}setSessionName(e){return this.daemon.request("agent_set_session_name_request",{agentId:this.agentId,name:e})}exportHtml(e){return this.daemon.request("agent_export_html_request",{agentId:this.agentId,outputPath:e})}setModel(e,n){return this.daemon.request("agent_set_model_request",{agentId:this.agentId,provider:e,modelId:n})}cycleModel(){return this.daemon.request("agent_cycle_model_request",{agentId:this.agentId})}lastAssistantText(){return this.daemon.request("agent_last_assistant_text_request",{agentId:this.agentId})}}class Xr{constructor(e,n){this.daemon=e,this.workspaceId=n}onUpdate(e){return this.daemon.onSessionMessage(n=>{const s=n;s.type==="workspace_update"&&s.workspaceId===this.workspaceId&&e(s)})}}class Qr{constructor(e){this.daemon=e}listProviders(){return this.daemon.request("list_providers",{})}listModels(e){return this.daemon.request("list_provider_models",{provider:e})}listModes(e){return this.daemon.request("list_provider_modes",{provider:e})}resolveDefaultModel(e,n){return this.daemon.request("resolve_default_model",{provider:e,...n?{cwd:n}:{}})}refreshSnapshot(){return this.daemon.request("providers.snapshot.refresh.request",{})}}const Ct=32*1024;function Zr(t){const e=t.reduce((o,r)=>o+r.length,0),n=new Uint8Array(e);let s=0;for(const o of t)n.set(o,s),s+=o.length;return n}class ea{constructor(e){I(this,"pending",new Map);I(this,"nextStream",1);I(this,"detach",null);this.daemon=e}start(){this.detach||(this.detach=this.daemon.onFileTransferFrame(e=>this.dispatch(e)))}stop(){var e;(e=this.detach)==null||e.call(this),this.detach=null;for(const[n,s]of this.pending)s.reject(new Error("file transfer router stopped")),this.pending.delete(n)}async download(e){const n=await this.daemon.request("file_download_token_request",{path:e});if(!n.ok||!n.token)throw new Error(n.error??"failed to issue download token");const s=this.nextStream++,o=new Promise((a,c)=>{this.pending.set(s,{chunks:[],meta:{},resolve:a,reject:c})}),r=await this.daemon.request("file_download_request",{token:n.token,stream:s});if(!r.ok)throw this.pending.delete(s),new Error(r.error??"download request failed");return o}async upload(e,n){const s=lt(),o=await this.daemon.request("file_upload_request",{path:e,transferId:s});if(!o.ok||o.stream===void 0)throw new Error(o.error??"upload request failed");const r=o.stream;this.daemon.sendBinary(et({opcode:"Begin",stream:r,meta:{transferId:s}}));for(let a=0;a<n.length;a+=Ct){const c=n.subarray(a,a+Ct);this.daemon.sendBinary(et({opcode:"Chunk",stream:r,data:c}))}this.daemon.sendBinary(et({opcode:"End",stream:r,ok:!0}))}dispatch(e){const n=this.pending.get(e.stream);if(n)switch(e.opcode){case"Begin":n.meta.fileName=e.meta.fileName,n.meta.mimeType=e.meta.mimeType;return;case"Chunk":n.chunks.push(e.data);return;case"End":this.pending.delete(e.stream),e.ok?n.resolve({bytes:Zr(n.chunks),...n.meta}):n.reject(new Error("download failed"));return;case"Error":this.pending.delete(e.stream),n.reject(new Error(e.message));return}}}class ta{constructor(e,n={}){I(this,"initialDelayMs");I(this,"maxDelayMs");I(this,"factor");I(this,"jitter");I(this,"maxAttempts");I(this,"setTimer");I(this,"clearTimer");I(this,"random");I(this,"attempt",0);I(this,"timer",null);I(this,"active",!1);I(this,"detachState",null);I(this,"reconnectedHandlers",new Set);I(this,"failedHandlers",new Set);this.daemon=e,this.initialDelayMs=n.initialDelayMs??500,this.maxDelayMs=n.maxDelayMs??3e4,this.factor=n.factor??2,this.jitter=n.jitter??.2,this.maxAttempts=n.maxAttempts??Number.POSITIVE_INFINITY,this.setTimer=n.setTimer??((s,o)=>setTimeout(s,o)),this.clearTimer=n.clearTimer??(s=>clearTimeout(s)),this.random=n.random??Math.random}delayForAttempt(e){const n=Math.min(this.maxDelayMs,this.initialDelayMs*this.factor**(e-1)),s=n*this.jitter*(this.random()*2-1);return Math.max(0,Math.round(n+s))}onReconnected(e){return this.reconnectedHandlers.add(e),()=>this.reconnectedHandlers.delete(e)}onReconnectFailed(e){return this.failedHandlers.add(e),()=>this.failedHandlers.delete(e)}start(){this.active||(this.active=!0,this.detachState=this.daemon.onStateChange(e=>{e==="closed"&&this.active&&this.scheduleReconnect(),e==="open"&&(this.attempt=0)}))}stop(){var e;this.active=!1,this.timer&&this.clearTimer(this.timer),this.timer=null,(e=this.detachState)==null||e.call(this),this.detachState=null}get attemptCount(){return this.attempt}scheduleReconnect(){if(!this.active||this.attempt>=this.maxAttempts)return;this.attempt+=1;const e=this.delayForAttempt(this.attempt);this.timer=this.setTimer(()=>{this.timer=null,this.tryReconnect()},e)}async tryReconnect(){if(!this.active)return;const e=this.attempt;try{await this.daemon.connect();for(const n of this.reconnectedHandlers)n({attempt:e,serverId:this.daemon.serverId})}catch(n){for(const s of this.failedHandlers)s(n,e);this.scheduleReconnect()}}}function Tt(t){const e=t.trim();if(e==="")return e;const n=e.match(/^([a-z][a-z0-9+.-]*):\/\//i);if(!n)return`ws://${e.replace(/\/+$/,"")}`;const s=n[1].toLowerCase(),o=e.slice(n[0].length).replace(/\/+$/,"");switch(s){case"http":return`ws://${o}`;case"https":return`wss://${o}`;case"ws":case"wss":return`${s}://${o}`;default:return e}}function na(t){const e=Lr(t);return e!=null&&e.relay?{mode:"relay",url:Hr(e.relay),daemonPublicKey:e.publicKey}:e!=null&&e.host?{mode:"direct",url:Tt(e.host)}:{mode:"direct",url:Tt(t)}}function sa(){return"web-"+Math.random().toString(36).slice(2,10)}const C=pe()((t,e)=>({status:"idle",serverInfo:null,error:null,daemon:null,client:null,reconnection:null,async connect(n){e().disconnect();const s=na(n.url);let o;s.mode==="relay"?o=Wr({daemonPublicKey:s.daemonPublicKey}):n.password&&(o=un(d=>new WebSocket(d,[`pi-studio.bearer.${n.password}`])));const r=new Gr({url:s.url,clientId:n.clientId??sa(),clientType:"browser",capabilities:{},transport:o,rpcTimeoutMs:1800*1e3}),a=new Vr(r),c=new ta(r);r.onStateChange(d=>t({status:d})),c.onReconnected(()=>t({error:null})),c.onReconnectFailed(d=>{t({error:d instanceof Error?d.message:String(d)})}),t({daemon:r,client:a,reconnection:c,error:null,status:"connecting"});try{const d=await r.connect();t({serverInfo:d}),c.start()}catch(d){throw t({error:d instanceof Error?d.message:String(d)}),d}},disconnect(){const{daemon:n,reconnection:s}=e();s==null||s.stop(),n==null||n.close(),t({status:"idle",serverInfo:null,daemon:null,client:null,reconnection:null})}})),oa=100,ra=480,aa=220,ia=280;function Pe(t){return Math.min(ra,Math.max(oa,t))}const k=pe()(t=>({host:"ws://127.0.0.1:6767",password:"",cwd:"~",cwdPickerOpen:!1,sessionMenu:null,fileMenu:null,rightSidebarTab:"files",collapsedWorkspaces:new Set,leftSidebarCollapsed:!1,rightSidebarCollapsed:!1,leftSidebarWidth:aa,rightSidebarWidth:ia,setHost:e=>t({host:e}),setPassword:e=>t({password:e}),setCwd:e=>t({cwd:e}),openCwdPicker:()=>t({cwdPickerOpen:!0}),closeCwdPicker:()=>t({cwdPickerOpen:!1}),openSessionMenu:(e,n,s)=>t({sessionMenu:{sessionId:e,x:n,y:s}}),closeSessionMenu:()=>t({sessionMenu:null}),openFileMenu:(e,n,s,o)=>t({fileMenu:{path:e,isDirectory:n,x:s,y:o}}),closeFileMenu:()=>t({fileMenu:null}),setRightSidebarTab:e=>t({rightSidebarTab:e}),toggleWorkspaceCollapsed:e=>t(n=>{const s=new Set(n.collapsedWorkspaces);return s.has(e)?s.delete(e):s.add(e),{collapsedWorkspaces:s}}),toggleLeftSidebar:()=>t(e=>({leftSidebarCollapsed:!e.leftSidebarCollapsed})),toggleRightSidebar:()=>t(e=>({rightSidebarCollapsed:!e.rightSidebarCollapsed})),setLeftSidebarWidth:e=>t({leftSidebarWidth:Pe(e)}),setRightSidebarWidth:e=>t({rightSidebarWidth:Pe(e)}),resizeLeftSidebar:e=>t(n=>({leftSidebarWidth:Pe(n.leftSidebarWidth+e)})),resizeRightSidebar:e=>t(n=>({rightSidebarWidth:Pe(n.rightSidebarWidth+e)}))})),ca="_wrap_emmus_1",la="_dot_emmus_8",da="_open_emmus_15",ua="_connecting_emmus_18",pa="_closed_emmus_21",fa="_idle_emmus_22",ha="_closing_emmus_23",tt={wrap:ca,dot:la,open:da,connecting:ua,closed:pa,idle:fa,closing:ha},ma={idle:"disconnected",connecting:"connecting…",open:"connected",closing:"disconnecting…",closed:"disconnected"};function ga(){const t=C(n=>n.status),e=C(n=>n.error);return i.jsxs("span",{className:tt.wrap,title:e??void 0,children:[i.jsx("span",{className:A(tt.dot,tt[t])}),ma[t]??t]})}const _a="_toolbar_i9hmh_1",ya="_brand_i9hmh_10",ba="_version_i9hmh_16",wa="_sep_i9hmh_22",Sa="_host_i9hmh_28",xa="_password_i9hmh_31",va="_sidebarToggles_i9hmh_34",le={toolbar:_a,brand:ya,version:ba,sep:wa,host:Sa,password:xa,sidebarToggles:va};function ka(){const t=C(h=>h.status),e=C(h=>h.connect),n=C(h=>h.disconnect),s=k(h=>h.host),o=k(h=>h.setHost),r=k(h=>h.password),a=k(h=>h.setPassword),c=k(h=>h.leftSidebarCollapsed),d=k(h=>h.toggleLeftSidebar),f=k(h=>h.rightSidebarCollapsed),g=k(h=>h.toggleRightSidebar),b=t==="open"||t==="connecting";return i.jsxs("div",{className:le.toolbar,children:[i.jsx("span",{className:le.brand,children:"Pi-Studio"}),i.jsxs("span",{className:le.version,children:["v","0.0.39"]}),i.jsx(ga,{}),i.jsx("div",{className:le.sep}),i.jsx(Le,{className:le.host,value:s,onChange:h=>o(h.target.value),placeholder:"host:port, ws://…/http://…, or a pasted pairing link",disabled:b}),i.jsx(Le,{className:le.password,type:"password",value:r,onChange:h=>a(h.target.value),placeholder:"password",disabled:b}),t==="open"||t==="connecting"||t==="closing"?i.jsx(F,{size:"sm",onClick:()=>n(),children:"Disconnect"}):i.jsx(F,{size:"sm",variant:"default",onClick:()=>void e({url:s,password:r||void 0}),children:"Connect"}),i.jsxs("div",{className:le.sidebarToggles,children:[i.jsx(F,{size:"sm",variant:"ghost",iconOnly:!0,title:c?"Show sessions sidebar":"Hide sessions sidebar",onClick:()=>d(),children:c?i.jsx(An,{size:16}):i.jsx(Dn,{size:16})}),i.jsx(F,{size:"sm",variant:"ghost",iconOnly:!0,title:f?"Show files/changes sidebar":"Hide files/changes sidebar",onClick:()=>g(),children:f?i.jsx(Fn,{size:16}):i.jsx(On,{size:16})})]})]})}const dt={rows:[],streamingAssistantIndex:null,streamingReasoningIndex:null,toolIndexByCallId:{}};let Nt=0;function re(){return Nt+=1,`row-${Nt}`}function Ia(t){switch(t.kind){case"shell":return t.command??"";case"read":case"write":return t.path??"";case"edit":return t.path??"";case"search":return t.query??"";case"fetch":return t.url??"";case"task":return t.description??"";default:return""}}function ja(t,e){return t??`${e.kind}:${Ia(e)}`}function Ca(t){return{...t,streamingAssistantIndex:null,streamingReasoningIndex:null}}function Ta(t,e){var r;const n=t.rows.slice();let s=t.streamingAssistantIndex;if(s===null||((r=n[s])==null?void 0:r.kind)!=="assistant"){const a={kind:"assistant",id:re(),text:"",streaming:!0};n.push(a),s=n.length-1}const o=n[s];return!o||o.kind!=="assistant"?t:(n[s]={...o,text:o.text+e},{...t,rows:n,streamingAssistantIndex:s,streamingReasoningIndex:null})}function Na(t,e){var r;const n=t.rows.slice();let s=t.streamingReasoningIndex;if(s===null||((r=n[s])==null?void 0:r.kind)!=="reasoning"){const a={kind:"reasoning",id:re(),text:"",streaming:!0};n.push(a),s=n.length-1}const o=n[s];return!o||o.kind!=="reasoning"?t:(n[s]={...o,text:o.text+e},{...t,rows:n,streamingReasoningIndex:s,streamingAssistantIndex:null})}function Ea(t,e){if(t.kind!==e.kind)return e;const n={...t};for(const[s,o]of Object.entries(e))o!==void 0&&o!==""&&(n[s]=o);return n}function Ra(t,e){var c;const n=ja(e.callId,e.tool),s=e.status==="completed"||e.status==="error"?e.status:"running",o=t.toolIndexByCallId[n],r=t.rows.slice();if(o!==void 0&&((c=r[o])==null?void 0:c.kind)==="tool"){const d=r[o];return d.kind!=="tool"?t:(r[o]={...d,tool:Ea(d.tool,e.tool),status:s},{...t,rows:r,streamingAssistantIndex:null,streamingReasoningIndex:null})}const a={kind:"tool",id:re(),callId:n,tool:e.tool,status:s};return r.push(a),{...t,rows:r,toolIndexByCallId:{...t.toolIndexByCallId,[n]:r.length-1},streamingAssistantIndex:null,streamingReasoningIndex:null}}function gt(t){const e=t.rows.slice();if(t.streamingAssistantIndex!==null){const n=e[t.streamingAssistantIndex];(n==null?void 0:n.kind)==="assistant"&&(e[t.streamingAssistantIndex]={...n,streaming:!1})}if(t.streamingReasoningIndex!==null){const n=e[t.streamingReasoningIndex];(n==null?void 0:n.kind)==="reasoning"&&(e[t.streamingReasoningIndex]={...n,streaming:!1})}return{...t,rows:e,streamingAssistantIndex:null,streamingReasoningIndex:null}}function qa(t,e){const n=gt(t),s={kind:"error",id:re(),text:e||"turn failed"};return{...n,rows:[...n.rows,s]}}function Ma(t){const e=gt(t),n={kind:"system",id:re(),text:"(canceled)"};return{...e,rows:[...e.rows,n]}}function Ba(t,e){const n={kind:"error",id:re(),text:e||"error"};return{...t,rows:[...t.rows,n]}}function $a(t,e,n,s){if(s!==void 0){const r=t.rows.findIndex(a=>a.kind==="user"&&a.pending&&a.clientMessageId===s);if(r!==-1){const a=t.rows.slice(),c=a[r];if((c==null?void 0:c.kind)==="user")return a[r]={...c,text:e,images:n,pending:!1},{...t,rows:a}}}const o={kind:"user",id:re(),text:e,images:n,clientMessageId:s};return{...t,rows:[...t.rows,o]}}function Aa(t,e){let n=!1;const s=t.rows.map(o=>o.kind!=="user"||!o.queued||e.includes(o.text)?o:(n=!0,{...o,queued:!1}));return n?{...t,rows:s}:t}function gn(t,e){switch(e.kind){case"turn_started":return Ca(t);case"user_message":return $a(t,e.text??"",e.images,e.messageId);case"assistant_message":return Ta(t,e.text??"");case"reasoning":return Na(t,e.text??"");case"tool_call":return Ra(t,e);case"turn_completed":return gt(t);case"turn_failed":return qa(t,e.error);case"turn_canceled":return Ma(t);case"error":return Ba(t,e.message);case"queue_update":return Aa(t,e.steering??[]);default:return t}}function Da(t,e,n,s,o){const r={kind:"user",id:re(),text:n,images:s,clientMessageId:e,pending:!0,queued:o};return{...t,rows:[...t.rows,r]}}function Fa(t,e){const n=t.rows.findIndex(r=>r.kind==="user"&&r.pending&&r.clientMessageId===e);if(n===-1)return t;const s=t.rows.slice(),o=s[n];return(o==null?void 0:o.kind)!=="user"?t:(s[n]={...o,pending:!1,failed:!0},{...t,rows:s})}let Et=0;function Oa(){return Et+=1,`s-${Date.now().toString(36)}-${Et}`}const T=pe()((t,e)=>({sessions:{},order:[],activeSessionId:null,createSession(n){const s=Oa(),o={id:s,agentId:null,title:"New chat",status:"idle",cwd:n,timeline:dt,userMessageCount:0};return t(r=>({sessions:{...r.sessions,[s]:o},order:[s,...r.order],activeSessionId:s})),s},hydrate(n){t(s=>s.sessions[n.id]?s:{sessions:{...s.sessions,[n.id]:n},order:[...s.order,n.id]})},bindAgent(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,agentId:s}}}:o})},setStatus(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,status:s}}}:o})},setStatusByAgentId(n,s){const o=e().findByAgentId(n);o&&e().setStatus(o.id,s)},setModel(n,s,o){t(r=>{const a=r.sessions[n];return a?{sessions:{...r.sessions,[n]:{...a,model:s,modelProvider:o}}}:r})},setModelByAgentId(n,s,o){const r=e().findByAgentId(n);r&&e().setModel(r.id,s,o)},setTitle(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,title:s}}}:o})},setCwd(n,s){t(o=>{const r=o.sessions[n];return r?{sessions:{...o.sessions,[n]:{...r,cwd:s}}}:o})},applyStreamEvent(n,s){t(o=>{const r=o.sessions[n];if(!r)return o;const a=gn(r.timeline,s);let c=r.title;if(s.kind==="turn_completed"&&c==="New chat"){const d=a.rows.slice().reverse().find(f=>f.kind==="assistant");d&&d.kind==="assistant"&&d.text&&(c=d.text.slice(0,40)+(d.text.length>40?"…":""))}return{sessions:{...o.sessions,[n]:{...r,timeline:a,title:c}}}})},addOptimisticUserMessage(n,s,o,r,a){t(c=>{const d=c.sessions[n];if(!d)return c;const f=Da(d.timeline,s,o,r,a);return{sessions:{...c.sessions,[n]:{...d,timeline:f,userMessageCount:d.userMessageCount+1}}}})},markUserMessageFailed(n,s){t(o=>{const r=o.sessions[n];if(!r)return o;const a=Fa(r.timeline,s);return{sessions:{...o.sessions,[n]:{...r,timeline:a}}}})},activate(n){t({activeSessionId:n})},remove(n){t(s=>{const{[n]:o,...r}=s.sessions,a=s.order.filter(d=>d!==n),c=s.activeSessionId===n?a[0]??null:s.activeSessionId;return{sessions:r,order:a,activeSessionId:c}})},findByAgentId(n){return Object.values(e().sessions).find(s=>s.agentId===n)}})),Rt=new WeakMap;function Pa(t,e="pi"){const n=Rt.get(t);if(n)return n;const s=t.providers.resolveDefaultModel(e).then(o=>({model:o.model,modelProvider:o.modelProvider})).catch(()=>({}));return Rt.set(t,s),s}const We=new Map;function _n(t,e){const n=T.getState().sessions[e];if(!n)return Promise.reject(new Error(`unknown session: ${e}`));if(n.agentId)return Promise.resolve(n.agentId);const s=We.get(e);if(s)return s;const o=(async()=>{if(!n.model){const d=await Pa(t),f=T.getState().sessions[e];d.model&&f&&!f.model&&T.getState().setModel(e,d.model,d.modelProvider)}const r=T.getState().sessions[e];if(!r)throw new Error(`unknown session: ${e}`);const a={provider:"pi",cwd:r.cwd||"~"};r.model&&(a.model=r.model),r.modelProvider&&(a.modelProvider=r.modelProvider);const c=await t.createAgent({config:a,labels:{}});return T.getState().bindAgent(e,c.agentId),c.agentId})();return We.set(e,o),o.finally(()=>We.delete(e)),o}async function za(t,e){var o;const n=T.getState().sessions[e];if(!n||n.userMessageCount>0||n.timeline.rows.length>0)return!1;await((o=We.get(e))==null?void 0:o.catch(()=>{}));const s=T.getState().sessions[e];return s?(s.agentId&&t&&await t.agent(s.agentId).delete().catch(()=>{}),T.getState().remove(e),!0):!1}function nt(t,e){return t.filter(n=>n.workspaceCwd===e)}const E=pe()((t,e)=>({tabs:[],activeTabId:null,activeWorkspaceCwd:null,lastActiveTabByWorkspace:{},open(n){const s=e().tabs.find(o=>o.id===n.id);if(s){e().activate(s.id);return}t(o=>({tabs:[...o.tabs,n],activeTabId:n.id,activeWorkspaceCwd:n.workspaceCwd,lastActiveTabByWorkspace:{...o.lastActiveTabByWorkspace,[n.workspaceCwd]:n.id}}))},close(n){t(s=>{const o=s.tabs.find(f=>f.id===n);if(!o)return s;const r=s.tabs.findIndex(f=>f.id===n),a=s.tabs.filter(f=>f.id!==n);let c=s.activeTabId;const d={...s.lastActiveTabByWorkspace};if(c===n){const f=nt(a,o.workspaceCwd),g=Math.min(r,f.length-1),b=f[g];c=(b==null?void 0:b.id)??null}if(d[o.workspaceCwd]===n){const f=nt(a,o.workspaceCwd)[0];f?d[o.workspaceCwd]=f.id:delete d[o.workspaceCwd]}return{tabs:a,activeTabId:c,lastActiveTabByWorkspace:d}})},activate(n){t(s=>{const o=s.tabs.find(r=>r.id===n);return o?{activeTabId:n,activeWorkspaceCwd:o.workspaceCwd,lastActiveTabByWorkspace:{...s.lastActiveTabByWorkspace,[o.workspaceCwd]:n}}:s})},switchWorkspace(n){t(s=>{var d;const o=nt(s.tabs,n),r=s.lastActiveTabByWorkspace[n],c=r&&o.some(f=>f.id===r)?r:((d=o[0])==null?void 0:d.id)??null;return{activeWorkspaceCwd:n,activeTabId:c,lastActiveTabByWorkspace:c?{...s.lastActiveTabByWorkspace,[n]:c}:s.lastActiveTabByWorkspace}})},reorder(n,s){t(o=>{const r=o.tabs.findIndex(f=>f.id===n),a=o.tabs.findIndex(f=>f.id===s);if(r===-1||a===-1||r===a)return o;const c=o.tabs.slice(),[d]=c.splice(r,1);return d?(c.splice(a,0,d),{tabs:c}):o})},updateLabel(n,s){t(o=>({tabs:o.tabs.map(r=>r.id===n?{...r,label:s}:r)}))},updateData(n,s){t(o=>({tabs:o.tabs.map(r=>r.id===n?{...r,data:{...r.data,...s}}:r)}))}})),Q={chat:t=>`chat-${t}`,file:t=>`file-${t}`,diff:(t,e)=>`diff-${t}${e?"-staged":""}`,terminal:t=>`term-${t}`};let st=0;function yn(t){st+=1,E.getState().open({id:Q.terminal(`new-${st}`),kind:"terminal",label:`Terminal ${st}`,closable:!0,data:{slot:null,cwd:t},workspaceCwd:t})}function _t(t){const e=T.getState().createSession(t);E.getState().open({id:Q.chat(e),kind:"chat",label:"New chat",closable:!0,data:{sessionId:e},workspaceCwd:t});const n=C.getState().client;n&&_n(n,e).catch(()=>{})}function ut(t){const e=E.getState().tabs.find(s=>s.id===t);if(E.getState().close(t),(e==null?void 0:e.kind)!=="chat")return;const{sessionId:n}=e.data;za(C.getState().client,n)}const oe=pe()(t=>({rootPath:"",expanded:new Set,expandedByRoot:new Map,draft:null,setRoot:e=>t(n=>{const s=new Map(n.expandedByRoot);n.rootPath&&s.set(n.rootPath,n.expanded);const o=s.get(e),r=new Set(o);return r.add(e),{rootPath:e,expanded:r,expandedByRoot:s,draft:null}}),toggle:e=>t(n=>{if(e===n.rootPath)return n;const s=new Set(n.expanded);s.has(e)?s.delete(e):s.add(e);const o=new Map(n.expandedByRoot);return o.set(n.rootPath,s),{expanded:s,expandedByRoot:o}}),startDraft:(e,n)=>t(s=>{const o=new Set(s.expanded);o.add(e);const r=new Map(s.expandedByRoot);return s.rootPath&&r.set(s.rootPath,o),{draft:{parentPath:e,kind:n},expanded:o,expandedByRoot:r}}),cancelDraft:()=>t({draft:null})}));let me=null;const pt=new Set;function Ha(t){return pt.add(t),()=>pt.delete(t)}async function Xe(t){var e;if(me)return me;try{const n=await t.connection.request("file_explorer_request",{path:"/home"}),o=(((e=n.result)==null?void 0:e.entries)??n.entries??[]).find(r=>r.kind==="directory"||r.type==="directory");me="/home/"+((o==null?void 0:o.name)||"user")}catch{return"/tmp"}for(const n of pt)n(me);return me}function Wa(){return me}async function La(t,e){return e==="~"||e.startsWith("~/")?await Xe(t)+e.slice(1):e}function yt(){const t=C(o=>o.client),e=C(o=>o.status),[n,s]=v.useState(Wa());return v.useEffect(()=>Ha(s),[]),v.useEffect(()=>{!t||e!=="open"||n||Xe(t)},[t,e,n]),n}const Ua="_dot_202py_3",Ka={dot:Ua};function Ga(t){const{status:e,requiresAttention:n,attentionReason:s,showInactive:o}=t;if(!e)return null;if(n)switch(s){case"permission":return"statusWarning";case"error":return"statusDanger";case"finished":default:return"statusSuccess"}switch(e){case"running":case"queued":return"accent";case"waiting":return"statusWarning";case"finished":return"statusSuccess";case"error":return"statusDanger";case"idle":case"archived":return o?"foregroundMuted":null}}const qt=8,Va={accent:"var(--pi-color-accent)",statusSuccess:"var(--pi-color-statusSuccess)",statusDanger:"var(--pi-color-statusDanger)",statusWarning:"var(--pi-color-statusWarning)",foregroundMuted:"var(--pi-color-foregroundMuted)"};function Ja({className:t,...e}){const n=Ga(e);return n?i.jsx("span",{className:`${Ka.dot}${t?` ${t}`:""}`,style:{width:qt,height:qt,backgroundColor:Va[n]??"currentColor"},role:"presentation"}):null}const Ya={initializing:"queued",idle:"idle",running:"running",error:"error",closed:"finished"};function Xa(t){return Ya[t]??"idle"}const Qa="_wrap_1pbba_1",Za="_header_1pbba_7",ei="_list_1pbba_23",ti="_item_1pbba_28",ni="_active_1pbba_37",si="_title_1pbba_40",oi="_meta_1pbba_49",ri="_menuBtn_1pbba_57",ai="_workspaceGroup_1pbba_75",ii="_workspaceHeader_1pbba_78",ci="_workspaceChevron_1pbba_91",li="_workspaceIcon_1pbba_102",di="_workspaceLabel_1pbba_106",ui="_workspaceCount_1pbba_112",pi="_newSessionBtn_1pbba_117",fi="_workspaceSessions_1pbba_129",hi="_emptyState_1pbba_132",$={wrap:Qa,header:Za,list:ei,item:ti,active:ni,title:si,meta:oi,menuBtn:ri,workspaceGroup:ai,workspaceHeader:ii,workspaceChevron:ci,workspaceIcon:li,workspaceLabel:di,workspaceCount:ui,newSessionBtn:pi,workspaceSessions:fi,emptyState:hi};function mi({session:t,active:e,onSelect:n,onOpenMenu:s}){return i.jsxs("div",{className:A($.item,e&&$.active),onClick:n,onContextMenu:o=>{o.preventDefault(),s(o.clientX,o.clientY)},children:[i.jsxs("div",{className:$.title,children:[i.jsx(Ja,{status:Xa(t.status),showInactive:!0}),i.jsx("span",{children:t.title})]}),i.jsxs("div",{className:$.meta,children:[t.cwd||"~"," · ",t.agentId?t.agentId.slice(0,8):"new"," ·"," ",t.userMessageCount," msgs"]}),i.jsx("button",{type:"button",className:$.menuBtn,title:"Actions",onClick:o=>{o.stopPropagation();const r=o.currentTarget.getBoundingClientRect();s(r.left,r.bottom)},children:i.jsx(zt,{size:14})})]})}const gi="_trigger_16o4s_1",_i="_content_16o4s_7",yi="_item_16o4s_16",bi="_danger_16o4s_33",wi="_sep_16o4s_36",Z={trigger:gi,content:_i,item:yi,danger:bi,sep:wi};function Si(){const t=k(m=>m.sessionMenu),e=k(m=>m.closeSessionMenu),n=C(m=>m.client),s=v.useRef(null),[o,r]=v.useState(!1);v.useEffect(()=>{r(t!==null)},[t]);const a=T(m=>t?m.sessions[t.sessionId]:void 0);if(!t)return null;const c=!!(a!=null&&a.agentId)&&(a==null?void 0:a.status)==="running";function d(m){r(m),m||e()}function f(){if(!a)return;const m=window.prompt("Rename:",a.title);if(m!=null&&m.trim()){const _=m.trim();T.getState().setTitle(a.id,_),E.getState().updateLabel(Q.chat(a.id),_),a.agentId&&(n==null||n.agent(a.agentId).update({title:_}).catch(()=>{}))}e()}function g(){a!=null&&a.agentId&&(n==null||n.agent(a.agentId).interrupt().catch(()=>{})),e()}function b(m){T.getState().remove(m),E.getState().close(Q.chat(m))}async function h(){if(a){if(!window.confirm("Archive this agent? It can be resumed later."))return e();if(e(),!a.agentId){b(a.id);return}if(!n){window.alert("Not connected — cannot archive remotely.");return}try{await n.agent(a.agentId).archive(),b(a.id)}catch(m){window.alert(`Failed to archive: ${m instanceof Error?m.message:String(m)}`)}}}async function S(){if(a){if(!window.confirm("Permanently delete this agent? This cannot be undone."))return e();if(e(),!a.agentId){b(a.id);return}if(!n){window.alert("Not connected — cannot delete remotely.");return}try{await n.agent(a.agentId).delete(),b(a.id)}catch(m){window.alert(`Failed to delete: ${m instanceof Error?m.message:String(m)}`)}}}return i.jsxs(Ke,{open:o,onOpenChange:d,modal:!1,children:[i.jsx(Ge,{asChild:!0,children:i.jsx("button",{ref:s,type:"button",className:Z.trigger,style:{left:t.x,top:t.y},"aria-hidden":!0,tabIndex:-1})}),i.jsx(Ve,{children:i.jsxs(Je,{className:Z.content,align:"start",sideOffset:2,children:[i.jsx(G,{className:Z.item,onSelect:f,children:"Rename"}),i.jsx(G,{className:Z.item,disabled:!c,onSelect:g,children:"Stop agent"}),i.jsx(rt,{className:Z.sep}),i.jsx(G,{className:`${Z.item} ${Z.danger}`,onSelect:h,children:"Archive"}),i.jsx(G,{className:`${Z.item} ${Z.danger}`,onSelect:S,children:"Delete permanently"})]})})]})}function xi({label:t,cwd:e,sessionCount:n,collapsed:s,onToggleCollapsed:o,onNewSession:r}){return i.jsxs("div",{className:$.workspaceHeader,onClick:o,title:e,children:[i.jsx("button",{type:"button",className:$.workspaceChevron,"aria-label":s?"Expand workspace":"Collapse workspace",onClick:a=>{a.stopPropagation(),o()},children:s?i.jsx(ft,{size:13}):i.jsx(Ht,{size:13})}),i.jsx(Pn,{size:13,className:A($.workspaceIcon)}),i.jsx("span",{className:$.workspaceLabel,children:t}),i.jsx("span",{className:$.workspaceCount,children:n}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"New conversation",className:$.newSessionBtn,onClick:a=>{a.stopPropagation(),r()},children:i.jsx(Wt,{size:13})})]})}function ye(t,e){return e&&(t==="~"||t.startsWith("~/"))?e+t.slice(1):t}function bn(t,e,n){const s=new Map;for(const o of t){const r=e[o];if(!r)continue;const a=ye(r.cwd||"~",n),c=s.get(a);c?c.push(r):s.set(a,[r])}return Array.from(s,([o,r])=>({cwd:o,sessions:r}))}function vi(t){return!t||t==="~"?"~":t.split("/").filter(Boolean).pop()||t}function ki(){const t=T(_=>_.order),e=T(_=>_.sessions),n=T(_=>_.activeSessionId),s=T(_=>_.activate),o=E(_=>_.open),r=C(_=>_.status),a=k(_=>_.openSessionMenu),c=k(_=>_.setCwd),d=k(_=>_.openCwdPicker),f=k(_=>_.collapsedWorkspaces),g=k(_=>_.toggleWorkspaceCollapsed),b=yt();function h(_){const y=ye(_||"~",b);_t(y)}function S(_){s(_);const y=e[_],M=ye((y==null?void 0:y.cwd)||"~",b);y!=null&&y.cwd&&c(y.cwd),o({id:Q.chat(_),kind:"chat",label:(y==null?void 0:y.title)??"Chat",closable:!0,data:{sessionId:_},workspaceCwd:M})}const m=bn(t,e,b);return i.jsxs("div",{className:$.wrap,children:[i.jsxs("div",{className:$.header,children:[i.jsx("h3",{children:"Workspaces"}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:r!=="open"?"Connect to open a workspace":"Open a workspace folder",disabled:r!=="open",onClick:()=>d(),children:i.jsx(Lt,{size:14})})]}),i.jsxs("div",{className:$.list,children:[m.length===0&&i.jsx("div",{className:$.emptyState,children:r!=="open"?"Not connected":"No workspaces — open a folder to start"}),m.map(_=>{const y=f.has(_.cwd);return i.jsxs("div",{className:$.workspaceGroup,children:[i.jsx(xi,{label:vi(_.cwd),cwd:_.cwd,sessionCount:_.sessions.length,collapsed:y,onToggleCollapsed:()=>g(_.cwd),onNewSession:()=>h(_.cwd)}),!y&&i.jsx("div",{className:$.workspaceSessions,children:_.sessions.map(M=>i.jsx(mi,{session:M,active:M.id===n,onSelect:()=>S(M.id),onOpenMenu:(V,j)=>a(M.id,V,j)},M.id))})]},_.cwd)})]}),i.jsx(Si,{})]})}const Ii="_strip_8jveh_1",ji="_tab_8jveh_10",Ci="_active_8jveh_26",Ti="_icon_8jveh_30",Ni="_label_8jveh_35",Ei="_close_8jveh_40",Ri="_newTab_8jveh_50",qi="_content_8jveh_73",Mi="_item_8jveh_82",Bi="_itemIcon_8jveh_96",H={strip:Ii,tab:ji,active:Ci,icon:Ti,label:Ni,close:Ei,newTab:Ri,content:qi,item:Mi,itemIcon:Bi},$i={chat:Kt,file:Hn,diff:zn,terminal:Ut};function Ai({tab:t}){const e=E(g=>g.activeTabId),n=E(g=>g.activate),s=$i[t.kind],{attributes:o,listeners:r,setNodeRef:a,transform:c,transition:d,isDragging:f}=ls({id:t.id});return i.jsxs("div",{ref:a,className:A(H.tab,t.id===e&&H.active),style:{transform:ds.Transform.toString(c),transition:d,opacity:f?.5:1},onClick:()=>n(t.id),onAuxClick:g=>{g.button===1&&t.closable&&ut(t.id)},title:t.label,...o,...r,children:[i.jsx("span",{className:H.icon,children:i.jsx(s,{size:13})}),i.jsx("span",{className:H.label,children:t.label}),t.closable&&i.jsx("span",{className:H.close,onClick:g=>{g.stopPropagation(),ut(t.id)},children:i.jsx(ot,{size:12})})]})}function Di({workspaceCwd:t}){const e=t??"~";return i.jsxs(Ke,{children:[i.jsx(Ge,{asChild:!0,children:i.jsx("button",{type:"button",className:H.newTab,title:"New tab",disabled:!t,children:i.jsx(Wt,{size:14})})}),i.jsx(Ve,{children:i.jsxs(Je,{className:H.content,align:"start",sideOffset:4,children:[i.jsxs(G,{className:H.item,onSelect:()=>_t(e),children:[i.jsx(Kt,{size:13,className:H.itemIcon}),"New chat"]}),i.jsxs(G,{className:H.item,onSelect:()=>yn(e),children:[i.jsx(Ut,{size:13,className:H.itemIcon}),"New terminal"]})]})})]})}function Fi(){const t=E(a=>a.tabs),e=E(a=>a.activeWorkspaceCwd),n=E(a=>a.reorder),s=t.filter(a=>a.workspaceCwd===e),o=ns(ss(cs,{activationConstraint:{distance:4}}));function r(a){const{active:c,over:d}=a;!d||c.id===d.id||n(String(c.id),String(d.id))}return i.jsxs("div",{className:H.strip,children:[i.jsx(os,{sensors:o,collisionDetection:rs,onDragEnd:r,children:i.jsx(as,{items:s.map(a=>a.id),strategy:is,children:s.map(a=>i.jsx(Ai,{tab:a},a.id))})}),i.jsx(Di,{workspaceCwd:e})]})}const Oi="_spinner_1tgzp_3",Pi={spinner:Oi},zi={xs:12,sm:16,md:20,lg:24},Hi={xs:1,sm:2,md:2,lg:3};function wn({size:t="md",color:e="currentColor",className:n,"aria-label":s="Loading"}){const o=typeof t=="number"?t:zi[t],r=typeof t=="number"?2:Hi[t];return i.jsx("span",{className:`${Pi.spinner}${n?` ${n}`:""}`,role:"status","aria-label":s,style:{width:o,height:o,borderWidth:r,color:e}})}const Wi=v.lazy(()=>ht(()=>import("./ChatPanel-BqI2xnxv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.ChatPanel}))),Mt=v.lazy(()=>ht(()=>import("./FilePanel-BBfL4iba.js").then(t=>t.F),__vite__mapDeps([14,1,7,6,5,2,9,10,15])).then(t=>({default:t.FilePanel}))),Li=v.lazy(()=>ht(()=>import("./TerminalPanel-DyLLAPYP.js"),__vite__mapDeps([16,1,17,18,7,6,5,2,3,11,12,19])).then(t=>({default:t.TerminalPanel}))),Ui={chat:Wi,file:Mt,diff:Mt,terminal:Li},Ki="_area_z7u01_1",Gi="_panel_z7u01_7",Vi="_active_z7u01_14",Ji="_empty_z7u01_17",Yi="_emptyStack_z7u01_25",Xi="_emptyTitle_z7u01_35",Qi="_emptyHint_z7u01_39",ee={area:Ki,panel:Gi,active:Vi,empty:Ji,emptyStack:Yi,emptyTitle:Xi,emptyHint:Qi};function Zi(){const t=E(a=>a.tabs),e=E(a=>a.activeTabId),n=E(a=>a.activeWorkspaceCwd),s=C(a=>a.status),o=k(a=>a.openCwdPicker),r=t.some(a=>a.workspaceCwd===n);return n===null?i.jsx("div",{className:ee.area,children:i.jsxs("div",{className:ee.emptyStack,children:[i.jsx("div",{className:ee.emptyTitle,children:"No workspace open"}),i.jsx("div",{className:ee.emptyHint,children:"Open a project folder to start a chat."}),i.jsx(F,{size:"sm",variant:"secondary",leftIcon:i.jsx(Lt,{size:14}),disabled:s!=="open",title:s!=="open"?"Connect to open a workspace":"Open a workspace folder",onClick:()=>o(),children:"Open Workspace"})]})}):r?i.jsx("div",{className:ee.area,children:t.map(a=>{const c=Ui[a.kind];return i.jsx("div",{className:A(ee.panel,a.id===e&&ee.active),children:i.jsx(v.Suspense,{fallback:i.jsx(wn,{size:"md"}),children:i.jsx(c,{tab:a})})},a.id)})}):i.jsx("div",{className:ee.area,children:i.jsx("div",{className:ee.empty,children:"No open tabs in this workspace"})})}const Me={fileRead:t=>["file","read",t],fileDownload:t=>["file","download",t],fileDiff:(t,e,n)=>["file","diff",t,e,n],explorer:t=>["explorer",t],agentList:()=>["agents","list"],providerModels:t=>["providers","models",t],agentTimeline:t=>["agents","timeline",t]};function ec(t){const e=t.kind==="directory"||t.type==="directory"?"directory":"file";return{name:t.name??"",kind:e,size:t.size,mtimeMs:t.mtimeMs}}function tc(t){return t.slice().sort((e,n)=>e.kind!==n.kind?e.kind==="directory"?-1:1:e.name.localeCompare(n.name))}async function Sn(t,e){const s=(await t.connection.request("file_explorer_request",{path:e})).result;if(!s||s.ok===!1)throw new Error(s&&"error"in s?s.error:"explorer request failed");const o="entries"in s?s.entries??[]:[];return{path:s.resolvedPath??e,entries:tc(o.map(ec))}}function nc(t,e=!0){const n=C(s=>s.client);return Ot({queryKey:Me.explorer(t),queryFn:()=>{if(!n)throw new Error("not connected");return Sn(n,t)},enabled:!!n&&!!t&&e})}function sc(t){const e=C(o=>o.client),n=v.useMemo(()=>Array.from(t),[t]),s=Mn({queries:n.map(o=>({queryKey:Me.explorer(o),queryFn:()=>{if(!e)throw new Error("not connected");return Sn(e,o)},enabled:!!e&&!!o}))});return v.useMemo(()=>{const o=new Map;return n.forEach((r,a)=>{const c=s[a];o.set(r,{listing:c==null?void 0:c.data,isLoading:!!(c!=null&&c.isLoading),isError:!!(c!=null&&c.isError),error:c==null?void 0:c.error})}),o},[n,s])}const Bt=new WeakMap;function $t(t){let e=Bt.get(t);return e||(e=new ea(t),e.start(),Bt.set(t,e)),e}function oc(t,e,n){const s=new Blob([Uint8Array.from(t)],{type:n||"application/octet-stream"}),o=URL.createObjectURL(s),r=document.createElement("a");r.href=o,r.download=e,r.rel="noopener",document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(o),0)}function xn(){const t=C(o=>o.daemon),e=Re(),n=v.useCallback(async(o,r)=>{if(!t)throw new Error("not connected");const a=o?`${o}/${r.name}`:r.name,c=new Uint8Array(await r.arrayBuffer());await $t(t).upload(a,c),await e.invalidateQueries({queryKey:["explorer"]})},[t,e]),s=v.useCallback(async o=>{if(!t)throw new Error("not connected");const r=await $t(t).download(o);oc(r.bytes,r.fileName||o.split("/").pop()||"download",r.mimeType)},[t]);return{upload:n,saveToDisk:s}}function rc(t,e){return t.endsWith("/")?`${t}${e}`:`${t}/${e}`}function vn(t,e,n,s,o,r){var c;(r==null?void 0:r.parentPath)===e&&t.push({kind:"draft",path:`${e}::draft`,depth:n,draftKind:r.kind,parentPath:e});const a=o.get(e);if(!a||a.isLoading){t.push({kind:"loading",path:e,depth:n});return}if(a.isError){const d=a.error instanceof Error?a.error.message:"failed to load";t.push({kind:"error",path:e,depth:n,message:d});return}for(const d of((c=a.listing)==null?void 0:c.entries)??[])ac(t,e,d,n,s,o,r)}function ac(t,e,n,s,o,r,a){const c=rc(e,n.name);if(n.kind!=="directory"){t.push({kind:"file",path:c,name:n.name,depth:s});return}const d=o.has(c);t.push({kind:"directory",path:c,name:n.name,depth:s,expanded:d}),d&&vn(t,c,s+1,o,r,a)}function ic(t,e,n,s){if(!t)return[];const o=[];return vn(o,t,0,e,n,s),o}const cc="_container_1098n_1",lc="_header_1098n_7",dc="_uploadButton_1098n_14",uc="_hiddenInput_1098n_33",pc="_status_1098n_36",fc="_statusError_1098n_37",hc="_rowAction_1098n_50",mc="_item_1098n_65",gc="_dropOverlay_1098n_68",_c="_list_1098n_83",yc="_chevronSlot_1098n_102",bc="_chevron_1098n_102",wc="_chevronOpen_1098n_113",Sc="_icon_1098n_116",xc="_name_1098n_123",vc="_dirName_1098n_128",kc="_statusRow_1098n_134",Ic="_statusRowError_1098n_145",jc="_emptyState_1098n_148",Cc="_draftInput_1098n_154",N={container:cc,header:lc,uploadButton:dc,hiddenInput:uc,status:pc,statusError:fc,rowAction:hc,item:mc,dropOverlay:gc,list:_c,chevronSlot:yc,chevron:bc,chevronOpen:wc,icon:Sc,name:xc,dirName:vc,statusRow:kc,statusRowError:Ic,emptyState:jc,draftInput:Cc};function Tc({draftKind:t,indentStyle:e,onSubmit:n,onCancel:s}){const[o,r]=v.useState("");return i.jsxs("div",{className:N.item,style:e,onClick:a=>a.stopPropagation(),children:[i.jsx("span",{className:N.chevronSlot}),i.jsx("span",{className:N.icon,children:t==="directory"?i.jsx(Ee,{size:14}):i.jsx(Gt,{size:14})}),i.jsx("input",{className:N.draftInput,autoFocus:!0,spellCheck:!1,placeholder:t==="directory"?"New folder":"New file",value:o,onChange:a=>r(a.target.value),onKeyDown:a=>{if(a.key==="Enter"){a.preventDefault();const c=o.trim();c?n(c):s()}else a.key==="Escape"&&(a.preventDefault(),s())},onBlur:s})]})}const Nc=14;function Ec({row:t,onToggle:e,onOpenFile:n,onContextMenu:s,onSubmitDraft:o,onCancelDraft:r}){const a={paddingLeft:8+t.depth*Nc};if(t.kind==="loading")return i.jsx("div",{className:N.statusRow,style:a,children:"Loading…"});if(t.kind==="error")return i.jsx("div",{className:A(N.statusRow,N.statusRowError),style:a,children:t.message??"failed to load"});if(t.kind==="draft")return i.jsx(Tc,{draftKind:t.draftKind,indentStyle:a,onSubmit:d=>o(t.parentPath,d),onCancel:r});const c=t.kind==="directory";return i.jsxs("div",{className:N.item,style:a,onClick:()=>c?e(t.path):n(t.path),onContextMenu:d=>{d.preventDefault(),s(t.path,c,d.clientX,d.clientY)},children:[i.jsx("span",{className:N.chevronSlot,children:c&&i.jsx(ft,{size:12,className:A(N.chevron,t.expanded&&N.chevronOpen)})}),i.jsx("span",{className:N.icon,children:c?i.jsx(Ee,{size:14}):i.jsx(Gt,{size:14})}),i.jsx("span",{className:c?N.dirName:N.name,children:t.name}),i.jsx("button",{type:"button",className:N.rowAction,title:"Actions",onClick:d=>{d.stopPropagation();const f=d.currentTarget.getBoundingClientRect();s(t.path,c,f.left,f.bottom)},children:i.jsx(zt,{size:12})})]})}const Rc="_trigger_g81d7_1",qc="_content_g81d7_7",Mc="_item_g81d7_16",Bc="_danger_g81d7_29",$c="_sep_g81d7_32",te={trigger:Rc,content:qc,item:Mc,danger:Bc,sep:$c};function Ac(){const t=k(m=>m.fileMenu),e=k(m=>m.closeFileMenu),n=C(m=>m.client),s=oe(m=>m.startDraft),{saveToDisk:o}=xn(),r=Re(),a=v.useRef(null),[c,d]=v.useState(!1);if(v.useEffect(()=>{d(t!==null)},[t]),!t)return null;const f=t.path.split("/").pop()||t.path;function g(m){d(m),m||e()}async function b(){if(t){e();try{await o(t.path)}catch(m){window.alert(`Failed to download: ${m instanceof Error?m.message:String(m)}`)}}}async function h(){if(!t)return;const m=t.isDirectory?"folder (and everything inside it)":"file";if(!window.confirm(`Permanently delete this ${m}? "${f}" — this cannot be undone.`))return e();if(e(),!n){window.alert("Not connected — cannot delete remotely.");return}try{const _=await n.connection.request("file_delete_request",{path:t.path});if(!_.ok)throw new Error(_.error??"delete failed");await r.invalidateQueries({queryKey:["explorer"]})}catch(_){window.alert(`Failed to delete: ${_ instanceof Error?_.message:String(_)}`)}}function S(m){if(!t)return;const _=t.isDirectory?t.path:t.path.split("/").slice(0,-1).join("/")||"/";e(),s(_,m)}return i.jsxs(Ke,{open:c,onOpenChange:g,modal:!1,children:[i.jsx(Ge,{asChild:!0,children:i.jsx("button",{ref:a,type:"button",className:te.trigger,style:{left:t.x,top:t.y},"aria-hidden":!0,tabIndex:-1})}),i.jsx(Ve,{children:i.jsxs(Je,{className:te.content,align:"start",sideOffset:2,children:[i.jsx(G,{className:te.item,onSelect:()=>S("file"),children:"New File"}),i.jsx(G,{className:te.item,onSelect:()=>S("directory"),children:"New Folder"}),i.jsx(rt,{className:te.sep}),!t.isDirectory&&i.jsx(G,{className:te.item,onSelect:b,children:"Download"}),i.jsx(rt,{className:te.sep}),i.jsx(G,{className:`${te.item} ${te.danger}`,onSelect:h,children:"Delete"})]})})]})}const Dc={empty_path:"Choose a folder first.",invalid_name:'Invalid name — cannot be empty or contain "/".',exists:"An item with that name already exists here.",not_found:"That folder no longer exists.",not_a_directory:"That path is not a folder.",unreadable:"That folder is not readable."};async function kn(t,e,n,s){const o=await t.connection.request("file_create_request",{path:e,name:n,kind:s});if(!o.ok){const r=o.error??"";throw new Error(Dc[r]??r??"Failed to create")}return o.path??(e.endsWith("/")?`${e}${n}`:`${e}/${n}`)}const Fc=24;function Oc(){const t=C(p=>p.client),e=oe(p=>p.rootPath),n=oe(p=>p.expanded),s=oe(p=>p.setRoot),o=oe(p=>p.toggle),r=oe(p=>p.draft),a=oe(p=>p.startDraft),c=oe(p=>p.cancelDraft),d=E(p=>p.activeWorkspaceCwd),f=E(p=>p.open),{upload:g}=xn(),b=k(p=>p.openFileMenu),h=Re(),[S,m]=v.useState(null),[_,y]=v.useState(!1),[M,V]=v.useState(null),j=v.useRef(null),Be=v.useRef(null),be=v.useRef(null);v.useEffect(()=>{if(!t)return;const p=d||"~";be.current!==p&&(be.current=p,La(t,p).then(R=>s(R)))},[t,d,s]);const fe=sc(n),ae=v.useMemo(()=>ic(e,n,fe,r),[e,n,fe,r]),ie=Bn({count:ae.length,getScrollElement:()=>Be.current,estimateSize:()=>Fc,overscan:12,getItemKey:p=>{var R;return((R=ae[p])==null?void 0:R.path)??p}});function ce(p){f({id:Q.file(p),kind:"file",label:p.split("/").pop()||p,closable:!0,data:{path:p},workspaceCwd:d||"~"})}async function Qe(p,R){const P=(r==null?void 0:r.kind)??"file";if(c(),!!t)try{const W=await kn(t,p,R,P);await h.invalidateQueries({queryKey:Me.explorer(p)}),m({text:`Created ${W}`,error:!1}),P==="file"&&ce(W)}catch(W){m({text:W instanceof Error?W.message:"Failed to create",error:!0})}}async function we(p,R){var Ae;if(!R.length||!p)return;const P=(Ae=fe.get(p))==null?void 0:Ae.listing,W=new Set((P==null?void 0:P.entries.map(J=>J.name))??[]),Se=R.filter(J=>W.has(J.name));if(Se.length>0){const J=Se.map(Cn=>Cn.name).join(", ");if(!window.confirm(`Overwrite ${Se.length>1?"these files":"this file"}? ${J}`))return}m({text:`Uploading ${R.length} file${R.length>1?"s":""}…`,error:!1});try{for(const J of R)await g(p,J);m({text:`Uploaded ${R.length} file${R.length>1?"s":""}`,error:!1})}catch(J){m({text:`Upload failed: ${J instanceof Error?J.message:"unknown"}`,error:!0})}}function $e(p){p.preventDefault(),y(!1);const R=M??e;V(null);const P=Array.from(p.dataTransfer.files);we(R,P)}function Ze(p){p.dataTransfer.types.includes("Files")&&(p.preventDefault(),y(!0))}return t?i.jsxs("div",{className:N.container,onDragOver:Ze,onDragLeave:()=>y(!1),onDrop:$e,children:[i.jsxs("div",{className:N.header,children:[i.jsx("button",{type:"button",className:N.uploadButton,onClick:()=>a(e,"file"),disabled:!e,title:"New file in workspace root",children:i.jsx(Wn,{size:12})}),i.jsx("button",{type:"button",className:N.uploadButton,onClick:()=>a(e,"directory"),disabled:!e,title:"New folder in workspace root",children:i.jsx(Vt,{size:12})}),i.jsxs("button",{type:"button",className:N.uploadButton,onClick:()=>{var p;return(p=j.current)==null?void 0:p.click()},disabled:!e,title:"Upload files to the workspace root",children:[i.jsx(Ln,{size:12}),i.jsx("span",{children:"Upload"})]}),i.jsx("input",{ref:j,type:"file",multiple:!0,className:N.hiddenInput,onChange:p=>{we(e,Array.from(p.target.files??[])),p.target.value=""}})]}),S&&i.jsx("div",{className:S.error?N.statusError:N.status,children:S.text}),i.jsxs("div",{className:N.list,ref:Be,children:[ae.length===0&&i.jsx("div",{className:N.emptyState,children:"No files loaded"}),i.jsx("div",{style:{position:"relative",height:ie.getTotalSize()},children:ie.getVirtualItems().map(p=>{const R=ae[p.index];return R?i.jsx("div",{"data-index":p.index,style:{position:"absolute",top:0,left:0,width:"100%",height:p.size,transform:`translateY(${p.start}px)`},onDragEnter:()=>{R.kind==="directory"&&V(R.path)},children:i.jsx(Ec,{row:R,onToggle:o,onOpenFile:ce,onContextMenu:(P,W,Se,Ae)=>b(P,W,Se,Ae),onSubmitDraft:(P,W)=>void Qe(P,W),onCancelDraft:c})},p.key):null})})]}),_&&i.jsx("div",{className:N.dropOverlay,children:"Drop to upload"}),i.jsx(Ac,{})]}):i.jsx("div",{className:N.emptyState,children:"Connect to browse files"})}const At={available:!1,branch:null,upstream:null,ahead:0,behind:0,detached:!1,conflictCount:0},X=pe()(t=>({subscribedCwd:null,changes:[],...At,setSubscribedCwd:e=>t({subscribedCwd:e}),applyProjection:e=>{if(!e||!e.available){t({changes:[],...At});return}const n=[];for(const s of e.staged)n.push({path:s.path,status:s.indexStatus==="A"?"added":s.indexStatus==="D"?"deleted":"modified",staged:!0});for(const s of e.unstaged)n.push({path:s.path,status:s.worktreeStatus==="D"?"deleted":"modified",staged:!1});for(const s of e.untracked)n.push({path:s,status:"added",staged:!1});t({changes:n,available:!0,branch:e.branch,upstream:e.upstream,ahead:e.ahead,behind:e.behind,detached:e.detached,conflictCount:e.conflicted.length})}})),Pc="_list_1pgby_1",zc="_summary_1pgby_4",Hc="_item_1pgby_11",Wc="_badge_1pgby_23",Lc="_added_1pgby_30",Uc="_modified_1pgby_34",Kc="_deleted_1pgby_38",Gc="_name_1pgby_42",Vc="_emptyState_1pgby_47",de={list:Pc,summary:zc,item:Hc,badge:Wc,added:Lc,modified:Uc,deleted:Kc,name:Gc,emptyState:Vc},Jc={added:"A",modified:"M",deleted:"D"};function Yc(){const e=E(r=>r.activeWorkspaceCwd)||"~",n=X(r=>r.changes),s=E(r=>r.open);function o(r,a){s({id:Q.diff(r,a),kind:"diff",label:r.split("/").pop()||r,closable:!0,data:{path:r,staged:a},workspaceCwd:e})}return n.length===0?i.jsx("div",{className:de.emptyState,children:"No changes detected"}):i.jsxs("div",{className:de.list,children:[i.jsxs("div",{className:de.summary,children:[n.length," changed file",n.length===1?"":"s"]}),n.map((r,a)=>i.jsxs("div",{className:de.item,onClick:()=>o(r.path,r.staged),children:[i.jsx("span",{className:A(de.badge,de[r.status]),children:Jc[r.status]}),i.jsx("span",{className:de.name,children:r.path})]},`${r.path}-${r.staged}-${a}`))]})}const Xc="_wrap_r37ok_1",Qc="_tabBar_r37ok_7",Zc="_tabBtn_r37ok_13",el="_active_r37ok_26",tl="_refreshBtn_r37ok_30",nl="_content_r37ok_34",se={wrap:Xc,tabBar:Qc,tabBtn:Zc,active:el,refreshBtn:tl,content:nl};function sl(){const t=k(c=>c.rightSidebarTab),e=k(c=>c.setRightSidebarTab),s=E(c=>c.activeWorkspaceCwd)||"~",o=C(c=>c.client),r=Re();function a(){r.invalidateQueries({queryKey:["explorer"]}),o&&s&&o.connection.request("checkout_refresh_request",{cwd:s}).catch(()=>{})}return i.jsxs("div",{className:se.wrap,children:[i.jsxs("div",{className:se.tabBar,children:[i.jsx("button",{type:"button",className:A(se.tabBtn,t==="files"&&se.active),onClick:()=>e("files"),children:"Files"}),i.jsx("button",{type:"button",className:A(se.tabBtn,t==="changes"&&se.active),onClick:()=>e("changes"),children:"Changes"}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"Refresh",className:se.refreshBtn,onClick:a,children:i.jsx(Un,{size:13})})]}),i.jsx("div",{className:se.content,children:t==="files"?i.jsx(Oc,{}):i.jsx(Yc,{})})]})}const In=pe()(t=>({bySession:{},setStats(e,n){t(s=>({bySession:{...s.bySession,[e]:{...s.bySession[e],...n}}}))},clear(e){t(n=>{const{[e]:s,...o}=n.bySession;return{bySession:o}})}})),ol=12e3;function rl(t,e){return t==="running"&&e!=="running"}function Dt(t,e){var s,o,r,a,c,d;const n={};((s=e.contextUsage)==null?void 0:s.tokens)!=null&&(n.contextTokens=e.contextUsage.tokens),((o=e.contextUsage)==null?void 0:o.contextWindow)!==void 0&&(n.contextWindow=e.contextUsage.contextWindow),((r=e.contextUsage)==null?void 0:r.percent)!=null&&(n.contextPercent=e.contextUsage.percent),((a=e.tokens)==null?void 0:a.total)!==void 0&&(n.totalTokens=e.tokens.total),((c=e.tokens)==null?void 0:c.input)!==void 0&&(n.inputTokens=e.tokens.input),((d=e.tokens)==null?void 0:d.output)!==void 0&&(n.outputTokens=e.tokens.output),e.cost!==void 0&&(n.cost=e.cost),e.model!==void 0&&(n.model=e.model,T.getState().setModel(t,e.model)),In.getState().setStats(t,n)}function al(t){const e=C(c=>c.client),n=C(c=>c.status),s=T(c=>{var d;return t?((d=c.sessions[t])==null?void 0:d.agentId)??null:null}),o=T(c=>{var d;return t?(d=c.sessions[t])==null?void 0:d.status:void 0}),r=v.useRef(!1),a=v.useRef(void 0);v.useEffect(()=>{if(n!=="open"||!e||!t||!s)return;let c=!1;const d=async()=>{if(!r.current){r.current=!0;try{const g=await e.agent(s).sessionStats();c||Dt(t,g)}catch{}finally{r.current=!1}}};d();const f=setInterval(()=>void d(),ol);return()=>{c=!0,clearInterval(f)}},[n,e,t,s]),v.useEffect(()=>{const c=a.current;a.current=o,rl(c,o)&&(n!=="open"||!e||!t||!s||(r.current=!1,e.agent(s).sessionStats().then(d=>Dt(t,d)).catch(()=>{})))},[o,n,e,t,s])}function il(t){return typeof t=="object"&&t!==null&&"type"in t&&t.type==="checkout_status_update"&&"cwd"in t&&typeof t.cwd=="string"&&"projection"in t&&typeof t.projection=="object"&&t.projection!==null}function cl(t){const e=C(r=>r.client),n=X(r=>r.applyProjection),s=X(r=>r.setSubscribedCwd),o=v.useRef(e);return o.current=e,v.useEffect(()=>{if(!e||!t)return;let r=!1;e.connection.request("checkout_status_subscribe",{cwd:t}).catch(()=>{}),s(t);const a=e.connection.onSessionMessage(c=>{if(r)return;const d=c;il(d)&&d.cwd===t&&n(d.projection)});return e.connection.request("checkout_refresh_request",{cwd:t}).catch(()=>{}),()=>{r=!0,a(),e.connection.request("checkout_status_unsubscribe",{cwd:t}).catch(()=>{}),s(null)}},[e,t,n,s]),{refresh(){const r=o.current;!r||!t||r.connection.request("checkout_refresh_request",{cwd:t}).catch(()=>{})}}}const bt="--";function Ie(t){return t===void 0?bt:t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(1)}M`}function ll(t){if(t==null)return bt;const e=t<=1?t*100:t;return`${Math.round(e)}%`}function dl(t){if(t===void 0)return bt;const e=t<1?4:2;return`$${t.toFixed(e)}`}function ul(t,e){return e?t===e?"~":t.startsWith(`${e}/`)?`~${t.slice(e.length)}`:t:t}function pl(t,e){const n=[];return t>0&&n.push(`↑${t}`),e>0&&n.push(`↓${e}`),n.join(" ")}function fl(t,e=!0){const n=C(s=>s.client);return Ot({queryKey:Me.providerModels(t),queryFn:async()=>{if(!n)throw new Error("not connected");return(await n.providers.listModels(t)).models},enabled:!!n&&!!t&&e})}function hl(t,e){if(e.trim()==="")return t;const n=e.toLowerCase();return t.filter(s=>s.label.toLowerCase().includes(n)||s.description!==void 0&&s.description.toLowerCase().includes(n))}function ml(t,e){if(!e)return t;const n=t.find(s=>s.id===e);return n?[n,...t.filter(s=>s.id!==e)]:t}function gl(t){const e=new Set;return t.filter(n=>e.has(n.id)?!1:(e.add(n.id),!0))}const _l="_content_17y31_4",yl="_search_17y31_17",bl="_list_17y31_35",wl="_item_17y31_40",Sl="_checkSlot_17y31_55",xl="_label_17y31_64",vl="_modelId_17y31_70",kl="_state_17y31_77",Il="_stateError_17y31_86",Y={content:_l,search:yl,list:bl,item:wl,checkSlot:Sl,label:xl,modelId:vl,state:kl,stateError:Il};function jl({currentModel:t,provider:e,onSelect:n,renderTrigger:s}){const[o,r]=v.useState(!1),[a,c]=v.useState(""),d=v.useRef(null),{data:f=[],isLoading:g,isError:b,error:h}=fl(e,o),S=gl(ml(f,t));v.useEffect(()=>{var j;o&&(c(""),(j=d.current)==null||j.focus())},[o]);const m=new Map(S.map(j=>[j.id,j.provider])),_=S.map(j=>({value:j.id,label:j.label??j.id,description:j.id})),y=hl(_,a),M=h instanceof Error?h.message:"Failed to load models";function V(j){j.stopPropagation(),j.key==="Escape"&&r(!1)}return i.jsxs(Ke,{open:o,onOpenChange:r,modal:!1,children:[i.jsx(Ge,{asChild:!0,children:s(t)}),i.jsx(Ve,{children:i.jsxs(Je,{className:Y.content,align:"start",sideOffset:4,children:[i.jsx("input",{ref:d,className:Y.search,placeholder:"Search models…",value:a,onChange:j=>c(j.target.value),onKeyDown:V}),g&&i.jsx("div",{className:Y.state,children:i.jsx(wn,{size:"sm"})}),!g&&b&&i.jsx("div",{className:Y.stateError,children:M}),!g&&!b&&y.length===0&&i.jsx("div",{className:Y.state,children:"No models found"}),!g&&!b&&y.length>0&&i.jsx("div",{className:Y.list,children:y.map(j=>i.jsxs(G,{className:Y.item,onSelect:()=>n(j.value,m.get(j.value)),children:[i.jsx("span",{className:Y.checkSlot,"aria-hidden":!0,children:j.value===t&&i.jsx(Jt,{size:14})}),i.jsx("span",{className:Y.label,children:j.label}),i.jsxs("span",{className:Y.modelId,children:["(",j.value,")"]})]},j.value))})]})})]})}const Cl="_statusBar_tm1j6_1",Tl="_segmentGroup_tm1j6_16",Nl="_chevron_tm1j6_20",El="_segment_tm1j6_16",Rl="_icon_tm1j6_33",ql="_modelSegment_tm1j6_39",Ml="_modelChevron_tm1j6_63",Bl="_text_tm1j6_74",U={statusBar:Cl,segmentGroup:Tl,chevron:Nl,segment:El,icon:Rl,modelSegment:ql,modelChevron:Ml,text:Bl};function $l(){const t=T(y=>y.activeSessionId),e=T(y=>t?y.sessions[t]:void 0),n=C(y=>y.client),s=T(y=>y.setModel),o=yt(),r=E(y=>y.activeWorkspaceCwd);cl(r||"");const a=X(y=>y.available),c=X(y=>y.branch),d=X(y=>y.ahead),f=X(y=>y.behind),g=X(y=>y.detached),b=X(y=>y.conflictCount),h=X(y=>y.changes.length),S=In(y=>t?y.bySession[t]:void 0);al(t);const m=[];if(e){const y=ul(e.cwd,o);m.push({key:"cwd",icon:i.jsx(Ee,{size:13}),text:y,title:e.cwd})}if(a){const y=pl(d,f),M=[g?"(detached)":c??"?"];y&&M.push(y),h>0&&M.push(`●${h}`),b>0&&M.push(`⚠${b}`),m.push({key:"branch",icon:i.jsx(Kn,{size:13}),text:M.join(" ")})}if(e){const y=`${ll(S==null?void 0:S.contextPercent)} (${Ie(S==null?void 0:S.contextTokens)}/${Ie(S==null?void 0:S.contextWindow)})`;m.push({key:"context",icon:i.jsx(Gn,{size:13}),text:y}),m.push({key:"tokens",icon:i.jsx(Vn,{size:13}),text:Ie(S==null?void 0:S.totalTokens),title:`in ${Ie(S==null?void 0:S.inputTokens)} / out ${Ie(S==null?void 0:S.outputTokens)}`}),m.push({key:"cost",icon:i.jsx(Jn,{size:13}),text:dl(S==null?void 0:S.cost)})}function _(y,M){t&&(s(t,y,M),!(!n||!M)&&(async()=>{const V=await _n(n,t);await n.agent(V).setModel(M,y)})().catch(()=>{}))}return i.jsxs("div",{className:U.statusBar,children:[e&&i.jsx("span",{className:U.segmentGroup,children:i.jsx(jl,{currentModel:e.model,provider:"pi",onSelect:_,renderTrigger:y=>i.jsxs("button",{type:"button",className:U.modelSegment,disabled:!n,title:y?`Model: ${y}`:"Select model",children:[i.jsx("span",{className:U.icon,children:i.jsx(Yn,{size:13})}),i.jsx("span",{className:U.text,children:y??"Model"}),i.jsx(Ht,{size:12,className:U.modelChevron,"aria-hidden":"true"})]})})}),m.map((y,M)=>i.jsxs("span",{className:U.segmentGroup,children:[(!!e||M>0)&&i.jsx(ft,{size:12,className:U.chevron,"aria-hidden":"true"}),i.jsxs("span",{className:U.segment,title:y.title,children:[i.jsx("span",{className:U.icon,children:y.icon}),i.jsx("span",{className:U.text,children:y.text})]})]},y.key))]})}const Al="_wrapper_131x2_3",Dl="_box_131x2_18",Fl="_checkmark_131x2_36",Ol="_nativeInput_131x2_41",ze={wrapper:Al,box:Dl,checkmark:Fl,nativeInput:Ol};v.forwardRef(function({label:e,checked:n=!1,disabled:s,className:o,onChange:r,...a},c){return i.jsxs("label",{className:ze.wrapper,"data-disabled":s||void 0,children:[i.jsx("input",{ref:c,type:"checkbox",className:ze.nativeInput,checked:n,disabled:s,onChange:r,...a}),i.jsx("span",{className:ze.box,"data-checked":n,"aria-hidden":!0,children:n&&i.jsx(Jt,{size:12,className:ze.checkmark})}),e&&i.jsx("span",{children:e})]})});const Pl="_select_vj45v_3",zl={select:Pl};v.forwardRef(function({options:e,placeholder:n,className:s,...o},r){return i.jsxs("select",{ref:r,className:A(zl.select,s),...o,children:[n&&i.jsx("option",{value:"",disabled:!0,children:n}),e.map(a=>i.jsx("option",{value:a.value,children:a.label},a.value))]})});const Hl="_overlay_1yaef_1",Wl="_contentWrapper_1yaef_7",Ll="_dialog_1yaef_16",Ul="_header_1yaef_28",Kl="_title_1yaef_36",Gl="_closeBtn_1yaef_43",Vl="_body_1yaef_57",Jl="_footer_1yaef_63",Yl="_bare_1yaef_72",Xl="_bareBody_1yaef_78",Ql="_bareCloseBtn_1yaef_82",Zl="_visuallyHidden_1yaef_101",z={overlay:Hl,contentWrapper:Wl,dialog:Ll,header:Ul,title:Kl,closeBtn:Gl,body:Vl,footer:Jl,bare:Yl,bareBody:Xl,bareCloseBtn:Ql,visuallyHidden:Zl},ed=at;function td({open:t,onOpenChange:e,title:n,children:s,footer:o,width:r,className:a,bare:c=!1}){return i.jsx(Qn,{open:t,onOpenChange:e,children:i.jsxs(Zn,{children:[i.jsx(es,{className:z.overlay}),i.jsx("div",{className:z.contentWrapper,children:i.jsxs(ts,{className:A(z.dialog,c&&z.bare,a),style:r!==void 0?{width:r}:void 0,children:[c?i.jsx(wt,{className:z.visuallyHidden,children:n}):i.jsxs("div",{className:z.header,children:[i.jsx(wt,{className:z.title,children:n}),i.jsx(at,{asChild:!0,children:i.jsx("button",{type:"button",className:z.closeBtn,"aria-label":"Close",children:i.jsx(ot,{size:16})})})]}),i.jsx("div",{className:A(z.body,c&&z.bareBody),children:s}),c&&i.jsx(at,{asChild:!0,children:i.jsx("button",{type:"button",className:z.bareCloseBtn,"aria-label":"Close",children:i.jsx(ot,{size:16})})}),o&&i.jsx("div",{className:z.footer,children:o})]})})]})})}const nd="_handle_1ocv1_1",sd={handle:nd};function Ft({side:t,onResize:e,className:n}){const s=v.useRef(0),o=v.useCallback(c=>{const d=c.clientX-s.current;s.current=c.clientX,e(t==="left"?d:-d)},[e,t]),r=v.useCallback(c=>{var d,f;window.removeEventListener("pointermove",o),window.removeEventListener("pointerup",r),document.body.style.cursor="",document.body.style.userSelect="",(f=(d=c.target)==null?void 0:d.releasePointerCapture)==null||f.call(d,c.pointerId)},[o]);function a(c){c.preventDefault(),s.current=c.clientX,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("pointermove",o),window.addEventListener("pointerup",r)}return i.jsx("div",{className:A(sd.handle,n),onPointerDown:a,role:"separator","aria-orientation":"vertical"})}function od(t,e){const{order:n,sessions:s}=T.getState(),r=bn(n,s,e).find(a=>a.cwd===t);if(r!=null&&r.sessions[0]){const a=r.sessions[0].id;T.getState().activate(a);const c=T.getState().sessions[a];E.getState().open({id:Q.chat(a),kind:"chat",label:(c==null?void 0:c.title)??"New chat",closable:!0,data:{sessionId:a},workspaceCwd:t})}else _t(t);k.getState().setCwd(t)}const rd="_pathRow_trimn_1",ad="_pathInput_trimn_9",id="_createRow_trimn_13",cd="_createInput_trimn_21",ld="_createError_trimn_25",dd="_list_trimn_30",ud="_item_trimn_37",pd="_name_trimn_49",fd="_emptyState_trimn_54",K={pathRow:rd,pathInput:ad,createRow:id,createInput:cd,createError:ld,list:dd,item:ud,name:pd,emptyState:fd};function hd(){const t=k(p=>p.cwdPickerOpen),e=k(p=>p.closeCwdPicker),n=E(p=>p.activeWorkspaceCwd),s=k(p=>p.cwd),o=C(p=>p.client),r=yt(),[a,c]=v.useState("/"),[d,f]=v.useState("/"),[g,b]=v.useState(!1),[h,S]=v.useState(""),[m,_]=v.useState(null),[y,M]=v.useState(!1),V=Re();v.useEffect(()=>{if(!t)return;const p=ye(n||s||"~",r);c(p),f(p),ie()},[t,o,n,s]);const{data:j,isLoading:Be,isError:be,error:fe}=nc(a,t&&!!o),ae=((j==null?void 0:j.entries)??[]).filter(p=>p.kind==="directory");function ie(){b(!1),S(""),_(null)}function ce(p){c(p),f(p),ie()}function Qe(){ce(a.split("/").slice(0,-1).join("/")||"/")}function we(){ce(d.trim())}async function $e(){const p=h.trim();if(!(!p||!o||y)){M(!0),_(null);try{const R=await kn(o,a,p,"directory");await V.invalidateQueries({queryKey:Me.explorer(a)}),ce(R)}catch(R){_(R instanceof Error?R.message:"Failed to create folder")}finally{M(!1)}}}function Ze(){od(a,r),e()}return i.jsxs(td,{open:t,onOpenChange:p=>!p&&e(),title:"Open Workspace",footer:i.jsxs(i.Fragment,{children:[i.jsx(ed,{asChild:!0,children:i.jsx(F,{size:"sm",variant:"secondary",children:"Cancel"})}),i.jsx(F,{size:"sm",onClick:Ze,children:"Open this folder"})]}),children:[i.jsxs("div",{className:K.pathRow,children:[i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"Up",onClick:Qe,children:i.jsx(Xn,{size:13})}),i.jsx(Le,{className:K.pathInput,value:d,onChange:p=>f(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),we())}}),i.jsx(F,{size:"xs",onClick:we,children:"Go"}),i.jsx(F,{size:"xs",variant:"ghost",iconOnly:!0,title:"New folder",disabled:!o||be||g,onClick:()=>{b(!0),S(""),_(null)},children:i.jsx(Vt,{size:13})})]}),g&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:K.createRow,children:[i.jsx(Ee,{size:14}),i.jsx(Le,{className:K.createInput,autoFocus:!0,placeholder:"New folder name",value:h,onChange:p=>S(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),$e()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),ie())}}),i.jsx(F,{size:"xs",loading:y,disabled:!h.trim()||y,onClick:()=>void $e(),children:"Create"}),i.jsx(F,{size:"xs",variant:"secondary",onClick:ie,children:"Cancel"})]}),m&&i.jsx("div",{className:K.createError,children:m})]}),i.jsx("div",{className:K.list,children:Be?i.jsx("div",{className:K.emptyState,children:"Loading..."}):be?i.jsxs("div",{className:K.emptyState,children:["Error: ",fe instanceof Error?fe.message:"unknown error"]}):ae.length===0?i.jsx("div",{className:K.emptyState,children:"No subdirectories"}):ae.map(p=>i.jsxs("div",{className:K.item,onClick:()=>ce(a==="/"?`/${p.name}`:`${a}/${p.name}`),children:[i.jsx(Ee,{size:14}),i.jsx("span",{className:K.name,children:p.name})]},p.name))})]})}const md="_shell_1m1nv_1",gd="_main_1m1nv_7",_d="_sidebarLeft_1m1nv_13",yd="_leftHandle_1m1nv_21",bd="_center_1m1nv_24",wd="_sidebarRight_1m1nv_31",Sd="_rightHandle_1m1nv_39",ue={shell:md,main:gd,sidebarLeft:_d,leftHandle:yd,center:bd,sidebarRight:wd,rightHandle:Sd};function xd(){const t=k(a=>a.leftSidebarCollapsed),e=k(a=>a.rightSidebarCollapsed),n=k(a=>a.leftSidebarWidth),s=k(a=>a.rightSidebarWidth),o=k(a=>a.resizeLeftSidebar),r=k(a=>a.resizeRightSidebar);return i.jsxs("div",{className:ue.shell,children:[i.jsx(ka,{}),i.jsxs("div",{className:ue.main,children:[!t&&i.jsxs("aside",{className:ue.sidebarLeft,style:{width:n},children:[i.jsx(ki,{}),i.jsx(Ft,{side:"left",className:ue.leftHandle,onResize:o})]}),i.jsxs("div",{className:ue.center,children:[i.jsx(Fi,{}),i.jsx(Zi,{})]}),!e&&i.jsxs("aside",{className:ue.sidebarRight,style:{width:s},children:[i.jsx(Ft,{side:"right",className:ue.rightHandle,onResize:r}),i.jsx(sl,{})]})]}),i.jsx($l,{}),i.jsx(hd,{})]})}function vd(){const t=v.useRef(!1);v.useEffect(()=>{if(t.current)return;if(t.current=!0,window.location.hash.includes("offer=")){const d=window.location.href;k.getState().setHost(d),C.getState().connect({url:d});return}const e=new URLSearchParams(window.location.search),n=e.get("host"),s=e.get("pair"),o=e.get("password"),r=e.get("cwd"),a=e.get("connect")==="1",c=k.getState();if(s?c.setHost(s):n&&c.setHost(n),o&&c.setPassword(o),r&&c.setCwd(r),s)C.getState().connect({url:s});else if(a){const{host:d,password:f}=k.getState();C.getState().connect({url:d,password:f||void 0})}},[])}function kd(t){return typeof t=="object"&&t!==null&&"kind"in t}function Id(t){const e=[];for(const n of t)if(kd(n))if(n.kind==="other")n.event&&e.push(n.event);else for(const s of n.events??[])e.push(s);return e}function jd(t){return typeof t.model=="string"}function Cd(){const t=C(s=>s.client),e=C(s=>s.status),n=v.useRef(!1);v.useEffect(()=>{e!=="open"||!t||n.current||(n.current=!0,(async()=>{var g;let s=[];try{s=(await t.connection.request("list_agents_request",{all:!1})).agents??[]}catch{s=[]}s.sort((b,h)=>(h.lastActivity??0)-(b.lastActivity??0));const o=T.getState();for(const b of s){if(o.findByAgentId(b.agentId))continue;let h=dt;try{const m=await t.agent(b.agentId).timeline.fetch({direction:"after",limit:200});h=Id(m.items).reduce(gn,dt)}catch{}const S=h.rows.length===0;o.hydrate({id:`s-${b.agentId.slice(0,12)}`,agentId:b.agentId,title:b.title||(S?"New chat":(g=b.cwd)==null?void 0:g.split("/").pop())||"Restored",status:b.status??"idle",cwd:b.cwd||"~",timeline:h,userMessageCount:h.rows.filter(m=>m.kind==="user").length,model:b.model,modelProvider:b.modelProvider})}const{order:r,sessions:a}=T.getState(),c=r.length>0?a[r[0]??""]:void 0;if(!c)return;const d=await Xe(t).catch(()=>null),f=ye(c.cwd||"~",d);T.getState().activate(c.id),k.getState().setCwd(c.cwd),E.getState().open({id:Q.chat(c.id),kind:"chat",label:c.title,closable:!0,data:{sessionId:c.id},workspaceCwd:f})})())},[e,t]),v.useEffect(()=>{if(!(e!=="open"||!t))return t.onAgentUpdate(s=>{if(jd(s)){const o=typeof s.modelProvider=="string"?s.modelProvider:void 0;T.getState().setModelByAgentId(s.agentId,s.model,o)}})},[e,t])}function Td(){const t=C(s=>s.client),e=C(s=>s.status),n=v.useRef(!1);v.useEffect(()=>{e!=="open"||!t||n.current||(n.current=!0,(async()=>{let s=[];try{s=(await t.connection.request("list_terminals_request",{})).terminals??[]}catch{s=[]}if(s.length===0)return;const o=await Xe(t).catch(()=>null),r=E.getState().open;for(const a of s){if(a.closed)continue;const c=ye(a.cwd||"~",o);r({id:Q.terminal(a.slot),kind:"terminal",label:a.name,closable:!0,data:{slot:a.slot,cwd:c},workspaceCwd:c})}})())},[e,t])}function Nd(){v.useEffect(()=>{function t(e){const n=k.getState();if(e.key==="Escape"){n.closeCwdPicker(),n.closeSessionMenu();return}const s=e.ctrlKey||e.metaKey;if(s&&e.key.toLowerCase()==="t"){e.preventDefault(),yn(E.getState().activeWorkspaceCwd||"~");return}if(s&&e.key.toLowerCase()==="w"){const{activeTabId:o,tabs:r}=E.getState();if(!o)return;const a=r.find(c=>c.id===o);(a==null?void 0:a.closable)!==!1&&(e.preventDefault(),ut(o))}}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[])}function Ed(){return vd(),Cd(),Td(),Nd(),null}function Rd(){return i.jsxs(Zs,{children:[i.jsx(Ed,{}),i.jsx(xd,{})]})}const jn=document.getElementById("root");if(!jn)throw new Error("Missing #root element");En.createRoot(jn).render(i.jsx(v.StrictMode,{children:i.jsx(Rd,{})}));export{F as B,td as D,wn as S,zd as T,C as a,Hd as b,E as c,$t as d,_n as e,Me as r,Ia as t,T as u};
|
|
3
|
-
//# sourceMappingURL=index-BFWpAuBZ.js.map
|