@algochad/archcoder 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +113 -0
  2. package/bin/cli-entry.js +55 -0
  3. package/bin/cli-output.js +145 -0
  4. package/bin/cli.js +5108 -0
  5. package/bin/cli.test.js +56 -0
  6. package/dist/apple-touch-icon-120x120.png +0 -0
  7. package/dist/apple-touch-icon-152x152.png +0 -0
  8. package/dist/apple-touch-icon-167x167.png +0 -0
  9. package/dist/apple-touch-icon-180x180.png +0 -0
  10. package/dist/apple-touch-icon.png +0 -0
  11. package/dist/apple-touch-icon.svg +67 -0
  12. package/dist/assets/MultiRunWindow-BZp3MjJP.js +1 -0
  13. package/dist/assets/SettingsWindow-DoGYXpX7.js +1 -0
  14. package/dist/assets/TerminalView-BN7BR5Ff.js +3 -0
  15. package/dist/assets/TimelineDialog-ZQ33oVQR.js +1 -0
  16. package/dist/assets/ToolOutputDialog-Blv3pnug.js +16 -0
  17. package/dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  18. package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  19. package/dist/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  20. package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  21. package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  22. package/dist/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  23. package/dist/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  24. package/dist/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  25. package/dist/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  26. package/dist/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  27. package/dist/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  28. package/dist/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  29. package/dist/assets/index-CtCEGYrr.css +1 -0
  30. package/dist/assets/index-o_d2wtWC.js +48 -0
  31. package/dist/assets/main-5QGBtzdq.css +1 -0
  32. package/dist/assets/main-B6oiMU86.js +8033 -0
  33. package/dist/assets/vendor--DbVqbJpV.css +1 -0
  34. package/dist/assets/vendor-.bun-HTKwyaEM.js +10086 -0
  35. package/dist/assets/wasm-CG6Dc4jp.js +1 -0
  36. package/dist/assets/worker-bqd4RMrj.js +155 -0
  37. package/dist/favicon-16.png +0 -0
  38. package/dist/favicon-32.png +0 -0
  39. package/dist/favicon.png +0 -0
  40. package/dist/favicon.svg +67 -0
  41. package/dist/index.html +533 -0
  42. package/dist/logo-dark-192x192.png +0 -0
  43. package/dist/logo-dark-512x512.svg +16 -0
  44. package/dist/logo-light-192x192.png +0 -0
  45. package/dist/logo-light-512x512.svg +16 -0
  46. package/dist/pwa-192.png +0 -0
  47. package/dist/pwa-512.png +0 -0
  48. package/dist/pwa-maskable-192.png +0 -0
  49. package/dist/pwa-maskable-512.png +0 -0
  50. package/dist/site.webmanifest +22 -0
  51. package/dist/sw.js +1 -0
  52. package/package.json +107 -0
  53. package/public/apple-touch-icon-120x120.png +0 -0
  54. package/public/apple-touch-icon-152x152.png +0 -0
  55. package/public/apple-touch-icon-167x167.png +0 -0
  56. package/public/apple-touch-icon-180x180.png +0 -0
  57. package/public/apple-touch-icon.png +0 -0
  58. package/public/apple-touch-icon.svg +67 -0
  59. package/public/favicon-16.png +0 -0
  60. package/public/favicon-32.png +0 -0
  61. package/public/favicon.png +0 -0
  62. package/public/favicon.svg +67 -0
  63. package/public/logo-dark-192x192.png +0 -0
  64. package/public/logo-dark-512x512.svg +16 -0
  65. package/public/logo-light-192x192.png +0 -0
  66. package/public/logo-light-512x512.svg +16 -0
  67. package/public/pwa-192.png +0 -0
  68. package/public/pwa-512.png +0 -0
  69. package/public/pwa-maskable-192.png +0 -0
  70. package/public/pwa-maskable-512.png +0 -0
  71. package/public/site.webmanifest +22 -0
  72. package/server/TERMINAL_INPUT_WS_PROTOCOL.md +44 -0
  73. package/server/index.d.ts +37 -0
  74. package/server/index.js +14694 -0
  75. package/server/lib/cloudflare-tunnel.js +650 -0
  76. package/server/lib/git/DOCUMENTATION.md +146 -0
  77. package/server/lib/git/credentials.js +74 -0
  78. package/server/lib/git/identity-storage.js +110 -0
  79. package/server/lib/git/index.js +6 -0
  80. package/server/lib/git/service.js +3117 -0
  81. package/server/lib/github/DOCUMENTATION.md +170 -0
  82. package/server/lib/github/auth.js +307 -0
  83. package/server/lib/github/device-flow.js +50 -0
  84. package/server/lib/github/index.js +24 -0
  85. package/server/lib/github/octokit.js +10 -0
  86. package/server/lib/github/pr-status.js +478 -0
  87. package/server/lib/github/repo/index.js +55 -0
  88. package/server/lib/installer/desktop.js +289 -0
  89. package/server/lib/installer/download.js +208 -0
  90. package/server/lib/installer/index.js +45 -0
  91. package/server/lib/installer/platform.js +100 -0
  92. package/server/lib/notifications/DOCUMENTATION.md +61 -0
  93. package/server/lib/notifications/index.js +1 -0
  94. package/server/lib/notifications/message.js +49 -0
  95. package/server/lib/notifications/message.test.js +59 -0
  96. package/server/lib/opencode/DOCUMENTATION.md +59 -0
  97. package/server/lib/opencode/agents.js +634 -0
  98. package/server/lib/opencode/auth.js +81 -0
  99. package/server/lib/opencode/commands.js +339 -0
  100. package/server/lib/opencode/index.js +66 -0
  101. package/server/lib/opencode/mcp.js +206 -0
  102. package/server/lib/opencode/providers.js +96 -0
  103. package/server/lib/opencode/shared.js +527 -0
  104. package/server/lib/opencode/skills.js +480 -0
  105. package/server/lib/opencode/tunnel-auth.js +591 -0
  106. package/server/lib/opencode/ui-auth.js +510 -0
  107. package/server/lib/package-manager.js +505 -0
  108. package/server/lib/quota/DOCUMENTATION.md +55 -0
  109. package/server/lib/quota/index.js +24 -0
  110. package/server/lib/quota/providers/claude.js +107 -0
  111. package/server/lib/quota/providers/codex.js +113 -0
  112. package/server/lib/quota/providers/copilot.js +165 -0
  113. package/server/lib/quota/providers/google/api.js +92 -0
  114. package/server/lib/quota/providers/google/auth.js +108 -0
  115. package/server/lib/quota/providers/google/index.js +124 -0
  116. package/server/lib/quota/providers/google/transforms.js +109 -0
  117. package/server/lib/quota/providers/index.js +152 -0
  118. package/server/lib/quota/providers/interface.js +55 -0
  119. package/server/lib/quota/providers/kimi.js +108 -0
  120. package/server/lib/quota/providers/minimax-cn-coding-plan.js +15 -0
  121. package/server/lib/quota/providers/minimax-coding-plan.js +15 -0
  122. package/server/lib/quota/providers/minimax-shared.js +136 -0
  123. package/server/lib/quota/providers/nanogpt.js +124 -0
  124. package/server/lib/quota/providers/ollama-cloud.js +112 -0
  125. package/server/lib/quota/providers/openai.js +91 -0
  126. package/server/lib/quota/providers/openrouter.js +92 -0
  127. package/server/lib/quota/providers/zai.js +91 -0
  128. package/server/lib/quota/utils/auth.js +46 -0
  129. package/server/lib/quota/utils/formatters.js +76 -0
  130. package/server/lib/quota/utils/index.js +10 -0
  131. package/server/lib/quota/utils/transformers.js +55 -0
  132. package/server/lib/skills-catalog/DOCUMENTATION.md +178 -0
  133. package/server/lib/skills-catalog/cache.js +32 -0
  134. package/server/lib/skills-catalog/clawdhub/api.js +158 -0
  135. package/server/lib/skills-catalog/clawdhub/index.js +30 -0
  136. package/server/lib/skills-catalog/clawdhub/install.js +238 -0
  137. package/server/lib/skills-catalog/clawdhub/scan.js +113 -0
  138. package/server/lib/skills-catalog/curated-sources.js +21 -0
  139. package/server/lib/skills-catalog/git.js +77 -0
  140. package/server/lib/skills-catalog/index.js +42 -0
  141. package/server/lib/skills-catalog/install.js +294 -0
  142. package/server/lib/skills-catalog/scan.js +221 -0
  143. package/server/lib/skills-catalog/source.js +85 -0
  144. package/server/lib/terminal/DOCUMENTATION.md +114 -0
  145. package/server/lib/terminal/index.js +12 -0
  146. package/server/lib/terminal/input-ws-protocol.js +66 -0
  147. package/server/lib/terminal/input-ws-protocol.test.js +138 -0
  148. package/server/lib/tts/DOCUMENTATION.md +134 -0
  149. package/server/lib/tts/index.js +16 -0
  150. package/server/lib/tts/service.js +162 -0
  151. package/server/lib/tts/summarization.js +171 -0
  152. package/server/lib/tunnels/index.js +166 -0
  153. package/server/lib/tunnels/providers/cloudflare.js +260 -0
  154. package/server/lib/tunnels/registry.js +51 -0
  155. package/server/lib/tunnels/types.js +219 -0
  156. package/server/lib/utils/lru.js +107 -0
  157. package/server/lib/utils/sse.js +121 -0
@@ -0,0 +1,56 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import path from 'path';
3
+ import { pathToFileURL } from 'url';
4
+
5
+ import { isModuleCliExecution, normalizeCliEntryPath } from './cli-entry.js';
6
+
7
+ describe('cli entry detection', () => {
8
+ const modulePath = '/tmp/openchamber/bin/cli.js';
9
+ const moduleUrl = pathToFileURL(modulePath).href;
10
+
11
+ it('resolves symlinked entry paths before comparing', () => {
12
+ const symlinkPath = '/usr/local/bin/openchamber';
13
+ const realpath = (filePath) => {
14
+ if (filePath === path.resolve(symlinkPath)) {
15
+ return modulePath;
16
+ }
17
+ return filePath;
18
+ };
19
+
20
+ expect(isModuleCliExecution(symlinkPath, moduleUrl, realpath)).toBe(true);
21
+ });
22
+
23
+ it('falls back to resolved paths when realpath fails', () => {
24
+ const realpath = () => {
25
+ throw new Error('realpath unavailable');
26
+ };
27
+
28
+ expect(isModuleCliExecution(modulePath, moduleUrl, realpath)).toBe(true);
29
+ });
30
+
31
+ it('returns false for non-matching entry path', () => {
32
+ expect(isModuleCliExecution('/tmp/other-cli.js', moduleUrl)).toBe(false);
33
+ });
34
+
35
+ it('returns false for empty entry path', () => {
36
+ expect(isModuleCliExecution('', moduleUrl)).toBe(false);
37
+ });
38
+
39
+ it('returns false when module url is not provided', () => {
40
+ expect(isModuleCliExecution(modulePath)).toBe(false);
41
+ });
42
+
43
+ it('accepts wrapper binary name fallback when requested', () => {
44
+ const wrapperPath = '/home/user/.local/bin/openchamber';
45
+ expect(isModuleCliExecution(wrapperPath, moduleUrl, undefined, 'openchamber')).toBe(true);
46
+ });
47
+
48
+ it('normalizes direct paths when realpath fails', () => {
49
+ const unresolvedPath = './packages/web/bin/cli.js';
50
+ const realpath = () => {
51
+ throw new Error('no symlink resolution');
52
+ };
53
+
54
+ expect(normalizeCliEntryPath(unresolvedPath, realpath)).toBe(path.resolve(unresolvedPath));
55
+ });
56
+ });
Binary file
@@ -0,0 +1,67 @@
1
+ <svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <defs>
3
+ <linearGradient id="bgGrad" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" stop-color="#1a1a1a"/>
5
+ <stop offset="100%" stop-color="#0d0d0d"/>
6
+ </linearGradient>
7
+ <linearGradient id="orangeGrad" x1="0%" y1="0%" x2="100%" y2="100%">
8
+ <stop offset="0%" stop-color="#ff8533" class="shimmer-stop"/>
9
+ <stop offset="50%" stop-color="#ff6b00" class="shimmer-stop"/>
10
+ <stop offset="100%" stop-color="#cc5500" class="shimmer-stop"/>
11
+ </linearGradient>
12
+ <filter id="glow" x="-30%" y="-30%" width="160%" height="160%">
13
+ <feGaussianBlur stdDeviation="8" result="coloredBlur" class="pulse-blur"/>
14
+ <feMerge>
15
+ <feMergeNode in="coloredBlur"/>
16
+ <feMergeNode in="SourceGraphic"/>
17
+ </feMerge>
18
+ </filter>
19
+ <filter id="innerShadow" x="-20%" y="-20%" width="140%" height="140%">
20
+ <feOffset dx="0" dy="4"/>
21
+ <feGaussianBlur stdDeviation="4" result="offset-blur"/>
22
+ <feComposite operator="out" in="SourceGraphic" in2="offset-blur" result="inverse"/>
23
+ <feFlood flood-color="#ffffff" flood-opacity="0.1" result="color"/>
24
+ <feComposite operator="in" in="color" in2="inverse" result="shadow"/>
25
+ <feComposite operator="over" in="shadow" in2="SourceGraphic"/>
26
+ </filter>
27
+
28
+ <!-- Animation for pulsing glow effect -->
29
+ <style>
30
+ @keyframes pulse {
31
+ 0%, 100% { stdDeviation: 8; }
32
+ 50% { stdDeviation: 12; }
33
+ }
34
+ @keyframes shimmer {
35
+ 0%, 100% { stop-color: #ff8533; }
36
+ 50% { stop-color: #ffaa66; }
37
+ }
38
+ .pulse-blur {
39
+ animation: pulse 2s ease-in-out infinite;
40
+ }
41
+ .shimmer-stop {
42
+ animation: shimmer 3s ease-in-out infinite;
43
+ }
44
+ </style>
45
+ </defs>
46
+
47
+ <rect width="512" height="512" rx="112" fill="url(#bgGrad)"/>
48
+ <rect x="12" y="12" width="488" height="488" rx="100" fill="none" stroke="#2a2a2a" stroke-width="4"/>
49
+
50
+ <g filter="url(#glow)">
51
+ <path d="M256 64L400 400H336L296 304H216L176 400H112L256 64Z" fill="#ffffff" filter="url(#innerShadow)"/>
52
+ </g>
53
+
54
+ <path d="M256 128L288 208H224L256 128Z" fill="url(#orangeGrad)"/>
55
+ <rect x="232" y="248" width="48" height="16" rx="8" fill="url(#orangeGrad)"/>
56
+
57
+ <circle cx="256" cy="64" r="16" fill="url(#orangeGrad)"/>
58
+
59
+ <circle cx="136" cy="432" r="10" fill="#ff6b00"/>
60
+ <circle cx="184" cy="432" r="8" fill="#ffffff" opacity="0.4"/>
61
+ <circle cx="256" cy="432" r="8" fill="#ffffff" opacity="0.6"/>
62
+ <circle cx="328" cy="432" r="8" fill="#ffffff" opacity="0.4"/>
63
+ <circle cx="376" cy="432" r="10" fill="#ff6b00"/>
64
+
65
+ <path d="M120 400L112 400" stroke="#ff6b00" stroke-width="8" stroke-linecap="round"/>
66
+ <path d="M400 400L408 400" stroke="#ff6b00" stroke-width="8" stroke-linecap="round"/>
67
+ </svg>
@@ -0,0 +1 @@
1
+ import{e as y,R as j,u as n,ak as R,a4 as C,ao as _,ap as N,am as k,al as M}from"./vendor-.bun-HTKwyaEM.js";import{c as O}from"./index-o_d2wtWC.js";import{M as S}from"./main-B6oiMU86.js";const E=v=>{const e=y.c(26),{open:h,onOpenChange:t,initialPrompt:b}=v,o=j.useId(),g=z;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx(R,{"data-blur-bg":!0,className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-md"}),e[0]=u):u=e[0];let f,m;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{g()&&w.preventDefault()},m=O("fixed z-50 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]","w-[90vw] max-w-[720px] h-[680px] max-h-[85vh]","flex flex-col rounded-xl border shadow-none overflow-hidden","bg-background"),e[1]=f,e[2]=m):(f=e[1],m=e[2]);let s;e[3]!==t?(s=()=>t(!1),e[3]=t,e[4]=s):s=e[4];let p;e[5]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsx(C,{className:"h-5 w-5"}),e[5]=p):p=e[5];let l;e[6]!==s?(l=n.jsx("div",{className:"absolute right-0.5 top-0.5 z-50",children:n.jsx("button",{type:"button",onClick:s,"aria-label":"Close multi-run",className:"inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:p})}),e[6]=s,e[7]=l):l=e[7];let a;e[8]!==o?(a=n.jsx(_,{id:o,className:"sr-only",children:"ArchCoder Multi-Run window."}),e[8]=o,e[9]=a):a=e[9];let r,i;e[10]!==t?(r=()=>t(!1),i=()=>t(!1),e[10]=t,e[11]=r,e[12]=i):(r=e[11],i=e[12]);let c;e[13]!==b||e[14]!==r||e[15]!==i?(c=n.jsx(S,{initialPrompt:b,onCreated:r,onCancel:i,isWindowed:!0}),e[13]=b,e[14]=r,e[15]=i,e[16]=c):c=e[16];let d;e[17]!==o||e[18]!==c||e[19]!==l||e[20]!==a?(d=n.jsxs(N,{children:[u,n.jsxs(k,{"aria-describedby":o,onInteractOutside:f,className:m,children:[l,a,c]})]}),e[17]=o,e[18]=c,e[19]=l,e[20]=a,e[21]=d):d=e[21];let x;return e[22]!==t||e[23]!==h||e[24]!==d?(x=n.jsx(M,{open:h,onOpenChange:t,children:d}),e[22]=t,e[23]=h,e[24]=d,e[25]=x):x=e[25],x};function z(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-state="open"], [data-slot="select-content"][data-state="open"]')}export{E as MultiRunWindow};
@@ -0,0 +1 @@
1
+ import{e as x,R as h,u as r,ak as b,ao as w,ap as g,am as y,al as j}from"./vendor-.bun-HTKwyaEM.js";import{c as S}from"./index-o_d2wtWC.js";import{S as v}from"./main-B6oiMU86.js";const O=f=>{const e=x.c(15),{open:m,onOpenChange:t}=f,n=h.useId(),p=R;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=r.jsx(b,{"data-blur-bg":!0,className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-md"}),e[0]=l):l=e[0];let i,c;e[1]===Symbol.for("react.memo_cache_sentinel")?(i=u=>{p()&&u.preventDefault()},c=S("fixed z-50 top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%]","w-[90vw] max-w-[960px] h-[85vh] max-h-[900px]","rounded-xl border shadow-none overflow-hidden","bg-background"),e[1]=i,e[2]=c):(i=e[1],c=e[2]);let s;e[3]!==n?(s=r.jsx(w,{id:n,className:"sr-only",children:"ArchCoder settings window."}),e[3]=n,e[4]=s):s=e[4];let o;e[5]!==t?(o=r.jsx(v,{onClose:()=>t(!1),isWindowed:!0}),e[5]=t,e[6]=o):o=e[6];let a;e[7]!==n||e[8]!==s||e[9]!==o?(a=r.jsxs(g,{children:[l,r.jsxs(y,{"aria-describedby":n,onInteractOutside:i,className:c,children:[s,o]})]}),e[7]=n,e[8]=s,e[9]=o,e[10]=a):a=e[10];let d;return e[11]!==t||e[12]!==m||e[13]!==a?(d=r.jsx(j,{open:m,onOpenChange:t,children:a}),e[11]=t,e[12]=m,e[13]=a,e[14]=d):d=e[14],d};function R(){return typeof document>"u"?!1:!!document.querySelector('[data-slot="dropdown-menu-content"][data-state="open"], [data-slot="select-content"][data-state="open"]')}export{O as SettingsWindow};
@@ -0,0 +1,3 @@
1
+ import{R as n,u as s,eU as Ne,aW as Qe,bL as Ze,dn as Xe,bM as Ye,bs as Ge,a4 as Je,aF as et}from"./vendor-.bun-HTKwyaEM.js";import{u as B,v as tt,b4 as nt,c as T}from"./index-o_d2wtWC.js";import{u as rt,a as st,b as ot,c as at,d as $,C as P,D as ce,e as it,B as C,T as ct,f as lt}from"./main-B6oiMU86.js";const ut={esc:"\x1B",tab:" ",enter:"\r","arrow-up":"\x1B[A","arrow-down":"\x1B[B","arrow-left":"\x1B[D","arrow-right":"\x1B[C"},X={ctrl:"5",cmd:"3"},Re={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},dt={retry:{maxRetries:0,initialDelayMs:200,maxDelayMs:500},connectionTimeoutMs:1500},ft=(b,k)=>{if(k)switch(b){case"arrow-up":return`\x1B[1;${X[k]}A`;case"arrow-down":return`\x1B[1;${X[k]}B`;case"arrow-right":return`\x1B[1;${X[k]}C`;case"arrow-left":return`\x1B[1;${X[k]}D`}return ut[b]??null},xt=()=>{const{terminal:b,runtime:k}=rt(),{currentTheme:le}=st(),{monoFont:Y}=lt(),Ie=B(e=>e.terminalFontSize),ue=B(e=>e.bottomTerminalHeight),de=B(e=>e.isBottomTerminalExpanded),{isMobile:l,hasTouchInput:ze}=ot(),A=k.platform!=="vscode",De=B(e=>e.showTerminalQuickKeysOnDesktop),D=l||De,{currentSessionId:Fe,newSessionDraft:Me}=tt(),G=Fe!==null||Me?.open===!0,a=at()??null,S=$(),fe=S.sessions,V=S.hasHydrated,me=S.ensureDirectory,pe=S.createTab,L=S.setActiveTab,U=S.closeTab,O=S.setTabSessionId,N=S.setConnecting,J=S.appendToBuffer,w=n.useMemo(()=>{if(a)return fe.get(a)},[fe,a]),m=n.useMemo(()=>w?A?w.activeTabId??w.tabs[0]?.id??null:w.tabs[0]?.id??null:null,[w,A]),ee=n.useMemo(()=>{if(w)return m?w.tabs.find(e=>e.id===m)??w.tabs[0]:w.tabs[0]},[w,m]),h=ee?.terminalSessionId??null,Be=ee?.bufferChunks??[],Oe=ee?.isConnecting??!1,[he,x]=n.useState(null),[Ke,g]=n.useState(!1),[p,y]=n.useState(null),[H,be]=n.useState(!1),[we,xe]=n.useState(0),ye=n.useId(),te=n.useRef(null),F=n.useRef(null),ge=n.useRef(m),M=n.useRef(h),q=n.useRef(a),R=n.useRef(null),ve=n.useRef(null),Te=n.useRef(!1),ne=n.useRef(null),W=n.useRef(new Set),Ce=n.useRef(!1),I=n.useCallback(()=>{typeof document<"u"&&!document.hasFocus()||R.current?.focus()},[]);n.useEffect(()=>{if(!V||Ce.current)return;Ce.current=!0;const e=new Set;for(const[,r]of $.getState().sessions.entries())for(const t of r.tabs)t.terminalSessionId&&e.add(t.terminalSessionId);W.current=e},[V]);const _e=B(e=>e.activeMainTab),K=B(e=>e.isBottomTerminalOpen),d=_e==="terminal"||K,[re,$e]=n.useState(d);n.useEffect(()=>{!d||k.platform==="vscode"||nt()},[d,k.platform]),n.useEffect(()=>{d&&$e(!0)},[d]),n.useEffect(()=>{Te.current=d},[d]),n.useEffect(()=>{M.current=h},[h]),n.useEffect(()=>{ge.current=m},[m]),n.useEffect(()=>{q.current=a},[a]),n.useEffect(()=>{!D&&p!==null&&y(null)},[D,p,y]),n.useEffect(()=>{!h&&p!==null&&y(null)},[h,p,y]);const f=n.useCallback(()=>{te.current?.(),te.current=null,F.current=null},[]);n.useEffect(()=>()=>{f(),M.current=null},[f]);const ke=n.useCallback((e,r,t,u=Re)=>{if(F.current===t)return;f(),F.current=t;const o=b.connect(t,{onEvent:c=>{if(F.current===t)switch(c.type){case"connected":{N(e,r,!1),x(null),g(!1),I(),ne.current===t&&(ne.current=null,b.sendInput(t,"\r").catch(()=>{}));break}case"reconnecting":{const i=c.attempt??0,v=c.maxAttempts??3;x(`Reconnecting (${i}/${v})...`),g(!1);break}case"data":{c.data&&J(e,r,c.data);break}case"exit":{const i=typeof c.exitCode=="number"?c.exitCode:null,v=typeof c.signal=="number"?c.signal:null,ae=!!$.getState().getDirectoryState(e)?.tabs.find(Z=>Z.id===r)?.label?.startsWith("Action:");J(e,r,`\r
2
+ [Process exited${i!==null?` with code ${i}`:""}${v!==null?` (signal ${v})`:""}]\r
3
+ `),O(e,r,null),N(e,r,!1),x(ae?null:"Terminal session ended"),g(!1),f();break}}},onError:(c,i)=>{if(F.current!==t)return;const v=i?`Connection failed: ${c.message}`:c.message||"Terminal stream connection error";x(v),g(!!i),i&&(N(e,r,!1),O(e,r,null),f())}},u);te.current=()=>{o.close(),F.current=null}},[J,f,I,N,O,b]);n.useEffect(()=>{let e=!1;if(!V||!re)return;if(!a){x(G?"No working directory available for terminal.":"Select a session to open the terminal."),f();return}return(async()=>{const t=a;if(!q.current||q.current!==t)return;me(t);const u=$.getState().getDirectoryState(t);if(!u||u.tabs.length===0)return;const o=A?u.activeTabId??u.tabs[0]?.id??null:u.tabs[0]?.id??null;if(!o)return;const c=u.tabs.find(z=>z.id===o)??u.tabs[0];let i=c?.terminalSessionId??null;const v=!!c?.label?.startsWith("Action:"),Q=(c?.bufferLength??0)>0||(c?.bufferChunks?.length??0)>0,ae=!!i&&W.current.has(i)&&(c?.bufferLength??0)===0&&(c?.bufferChunks?.length??0)===0,Z=!!i&&W.current.has(i);if(!i){if(v&&Q){N(t,o,!1);return}x(null),g(!1),N(t,o,!0);try{const z=ve.current,ie=await b.createSession({cwd:t,cols:z?.cols,rows:z?.rows});if(!(!e&&q.current===t&&ge.current===o)){try{await b.close(ie.sessionId)}catch{}return}O(t,o,ie.sessionId),i=ie.sessionId}catch(z){e||(x(z instanceof Error?z.message:"Failed to start terminal session"),g(!0),N(t,o,!1));return}}!i||e||(M.current=i,Z&&W.current.delete(i),ae&&(ne.current=i),ke(t,o,i,Z?dt:Re))})(),()=>{e=!0,M.current=null,f()}},[G,a,h,m,re,A,V,me,N,O,ke,f,b]),n.useEffect(()=>{if(!d)return;if(typeof window>"u"){I();return}const e=window.requestAnimationFrame(()=>{I()});return()=>{window.cancelAnimationFrame(e)}},[m,I,d]);const se=n.useCallback(async()=>{if(!a||H)return;const e=$.getState().getDirectoryState(a),r=A?m??e?.activeTabId??e?.tabs[0]?.id??null:e?.tabs[0]?.id??null;if(r){be(!0),x(null),g(!1),f();try{await U(a,r)}catch(t){x(t instanceof Error?t.message:"Failed to restart terminal"),g(!0)}finally{be(!1)}}},[m,U,f,a,A,H]),Pe=n.useCallback(async()=>{await se()},[se]),Ve=n.useCallback(()=>{if(!a)return;const e=pe(a);L(a,e),x(null),g(!1),f()},[pe,f,a,L]),Le=n.useCallback(e=>{a&&(L(a,e),x(null),g(!1),f())},[f,a,L]),Ue=n.useCallback(e=>{a&&(e===m&&f(),x(null),g(!1),U(a,e))},[m,U,f,a]),_=n.useCallback(e=>{if(!e)return;let r=e,t=!1;if(p&&e.length>0){const o=e[0];if(o.length===1&&/[a-zA-Z]/.test(o)){const c=o.toUpperCase();(p==="ctrl"||p==="cmd")&&(r=String.fromCharCode(c.charCodeAt(0)&31),t=!0)}t||(t=!0)}const u=M.current;u&&(b.sendInput(u,r).catch(o=>{x(o instanceof Error?o.message:"Failed to send input")}),t&&(y(null),R.current?.focus()))},[p,y,b]),He=n.useCallback((e,r)=>{if(ve.current={cols:e,rows:r},!Te.current)return;const t=M.current;t&&b.resize({sessionId:t,cols:e,rows:r}).catch(()=>{})},[b]),Se=n.useCallback(e=>{y(r=>r===e?null:e),R.current?.focus()},[y]),j=n.useCallback(e=>{const r=ft(e,p);r&&(_(r),y(null),R.current?.focus())},[p,_,y]);n.useEffect(()=>{if(!D||!p||!h)return;const e=r=>{if(r.repeat)return;const t=r.key;if(!t||t==="Control"||t==="Meta"||t==="Alt"||t==="Shift")return;const u=t.length===1?t.toLowerCase():t,o=r.code??"",c=o.startsWith("Key")&&o.length===4?o.slice(3).toUpperCase():null,i=t.length===1&&/[a-zA-Z]/.test(t)?t.toUpperCase():c,v={Tab:"tab",Enter:"enter",ArrowUp:"arrow-up",ArrowDown:"arrow-down",ArrowLeft:"arrow-left",ArrowRight:"arrow-right",Escape:"esc",tab:"tab",enter:"enter",arrowup:"arrow-up",arrowdown:"arrow-down",arrowleft:"arrow-left",arrowright:"arrow-right",escape:"esc"};if(u in v){r.preventDefault(),r.stopPropagation(),j(v[u]);return}if(p==="ctrl"&&i&&i.length===1&&i>="A"&&i<="Z"){const Q=String.fromCharCode(i.charCodeAt(0)&31);r.preventDefault(),r.stopPropagation(),_(Q),y(null),R.current?.focus()}};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[p,j,_,D,y,h]);const qe=n.useMemo(()=>{const e=P[ce].stack;if(typeof window>"u")return(P[Y]??P[ce]).stack;const t=window.getComputedStyle(document.documentElement).getPropertyValue("--font-family-mono");return t&&t.trim().length>0?t.trim():(P[Y]??P[ce]).stack??e},[Y]),je=n.useMemo(()=>it(le),[le]),oe=n.useMemo(()=>{const e=a??"no-dir",r=m??"no-tab",t=h??`pending-${r}`;return`${e}::${r}::${t}`},[a,m,h]),Ee=n.useMemo(()=>`${h??oe}::layout-${we}`,[h,oe,we]);if(n.useEffect(()=>{if(l||!K||!d)return;if(typeof window>"u"){xe(r=>r+1);return}const e=window.setTimeout(()=>{xe(r=>r+1)},140);return()=>{window.clearTimeout(e)}},[ue,de,K,l,d]),n.useEffect(()=>{if(!d)return;const e=R.current;if(!e)return;const r=()=>{e.fit()};if(typeof window<"u"){const t=window.requestAnimationFrame(()=>{r(),I()}),u=[220,400].map(o=>window.setTimeout(r,o));return()=>{window.cancelAnimationFrame(t),u.forEach(o=>window.clearTimeout(o))}}r()},[I,d,oe,h]),n.useEffect(()=>{if(l||!d||!K)return;const e=R.current;if(!e)return;const r=()=>{e.fit()};if(typeof window<"u"){const t=window.requestAnimationFrame(()=>{r()}),u=[0,80,180,320].map(o=>window.setTimeout(r,o));return()=>{window.cancelAnimationFrame(t),u.forEach(o=>window.clearTimeout(o))}}r()},[ue,de,K,l,d]),!G)return s.jsx("div",{className:"flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground",children:"Select a session to open the terminal"});if(!a)return s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground",children:[s.jsx("p",{children:"No working directory available for this session."}),s.jsx("button",{onClick:se,className:"rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:"Retry"})]});const E=!h||Oe||H,We=l?d:re,Ae=s.jsxs(s.Fragment,{children:[s.jsx(C,{type:"button",size:"sm",variant:"outline",className:"h-6 px-2 text-xs",onClick:()=>j("esc"),disabled:E,children:"Esc"}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("tab"),disabled:E,children:[s.jsx(Ne,{size:16}),s.jsx("span",{className:"sr-only",children:"Tab"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:T("h-6 w-9 p-0",p==="ctrl"?"border-[var(--primary-base)] text-[var(--primary-base)] bg-[var(--primary-base)]/10 hover:text-[var(--primary-base)]":void 0),onClick:()=>Se("ctrl"),disabled:E,children:[s.jsx("span",{className:"text-xs font-medium",children:"Ctrl"}),s.jsx("span",{className:"sr-only",children:"Control modifier"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:T("h-6 w-9 p-0",p==="cmd"?"border-[var(--primary-base)] text-[var(--primary-base)] bg-[var(--primary-base)]/10 hover:text-[var(--primary-base)]":void 0),onClick:()=>Se("cmd"),disabled:E,children:[s.jsx(Qe,{size:16}),s.jsx("span",{className:"sr-only",children:"Command modifier"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-up"),disabled:E,children:[s.jsx(Ze,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow up"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-left"),disabled:E,children:[s.jsx(Xe,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow left"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-down"),disabled:E,children:[s.jsx(Ye,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow down"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("arrow-right"),disabled:E,children:[s.jsx(Ne,{size:16}),s.jsx("span",{className:"sr-only",children:"Arrow right"})]}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",className:"h-6 w-9 p-0",onClick:()=>j("enter"),disabled:E,children:[s.jsx(Ge,{size:16}),s.jsx("span",{className:"sr-only",children:"Enter"})]})]});return s.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-[var(--surface-background)]",children:[s.jsxs("div",{className:T("sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs",l?"px-4 py-1.5":"px-5 py-2"),children:[A&&w?s.jsxs("div",{className:T("pl-1 pr-1 flex items-center gap-2",l?"mt-1":"mt-2"),children:[s.jsx("div",{className:T("min-w-0 flex-1 overflow-x-auto",l?"pb-0.5":"pb-1"),children:s.jsxs("div",{className:T("flex w-max items-center pr-1","gap-1"),children:[w.tabs.map(e=>{const r=e.id===m;return s.jsxs("div",{className:T("group flex items-center rounded-md border whitespace-nowrap",l?"h-8 gap-0.5 pl-2 pr-1.5 text-sm leading-none":"gap-1 pl-2 pr-1 py-1 text-xs",r?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx("button",{type:"button",onClick:()=>Le(e.id),className:T("truncate text-left",l?"!min-h-0 !min-w-0 max-w-[9.5rem]":"max-w-[10rem]"),title:e.label,children:e.label}),s.jsx("button",{type:"button",className:T("flex items-center justify-center rounded-sm text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",l?"!min-h-0 !min-w-0 h-3.5 w-3.5 p-0 leading-none":"h-4 w-4 p-0 leading-none",!l&&!r&&"opacity-0 group-hover:opacity-100"),onClick:t=>{t.stopPropagation(),Ue(e.id)},title:"Close tab",children:l?s.jsx("span",{"aria-hidden":!0,children:"×"}):s.jsx(Je,{size:12})})]},e.id)}),s.jsx("button",{type:"button",onClick:Ve,className:T("ml-1 flex items-center justify-center rounded-md border border-[var(--interactive-border)] bg-transparent text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]",l?"!min-h-0 !min-w-0 h-8 w-8":"h-6.5 w-6.5"),title:"New tab",children:s.jsx(et,{size:l?18:16})})]})}),!l&&D?s.jsx("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto pb-1",children:Ae}):null]}):null,D&&(l||!A||!w)?s.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:Ae}):null]}),s.jsxs("div",{className:"relative flex-1 overflow-hidden",style:{backgroundColor:je.background},id:ye,"data-keyboard-avoid":"true",children:[s.jsx("div",{className:"h-full w-full box-border pl-7 pr-5 pt-3 pb-4",children:We?s.jsx(ct,{ref:e=>{R.current=e},sessionKey:Ee,chunks:Be,onInput:_,onResize:He,theme:je,fontFamily:qe,fontSize:Ie,enableTouchScroll:ze,autoFocus:d,keyboardAvoidTargetId:ye},Ee):null}),he&&s.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2",children:[s.jsx("span",{children:he}),Ke&&l&&s.jsx(C,{size:"sm",variant:"secondary",className:"h-6 px-2 py-0 text-xs",onClick:Pe,disabled:H,title:"Force kill and create fresh session",type:"button",children:"Hard Restart"})]})]})]})};export{xt as TerminalView};
@@ -0,0 +1 @@
1
+ import{R as x,u as e,bq as I,aS as P,bs as v,aA as L,aR as N}from"./vendor-.bun-HTKwyaEM.js";import{g as $,h as q,i as A,j as H,k as Q,I as U,l as w,m as y,n as k}from"./main-B6oiMU86.js";import{v as m,$ as B}from"./index-o_d2wtWC.js";function E(a){const n=Date.now()-a,f=Math.floor(n/1e3),i=Math.floor(f/60),r=Math.floor(i/60),l=Math.floor(r/24);return f<60?"just now":i<60?`${i}m ago`:r<24?`${r}h ago`:l<7?`${l}d ago`:new Date(a).toLocaleDateString()}const J=({open:a,onOpenChange:t,onScrollToMessage:n,onScrollByTurnOffset:f,onResumeToLatest:i})=>{const r=m(s=>s.currentSessionId),l=B(s=>r?s.messages.get(r)||[]:[]),M=m(s=>s.revertToMessage),S=m(s=>s.forkFromMessage),D=m(s=>s.loadSessions),[h,p]=x.useState(null),[c,T]=x.useState(""),d=x.useMemo(()=>l.filter(o=>o.info.role==="user").reverse(),[l]),g=x.useMemo(()=>{if(!c.trim())return d;const s=c.toLowerCase();return d.filter(o=>b(o.parts).toLowerCase().includes(s))},[d,c]),C=async s=>{if(r){p(s);try{await S(r,s),await D(),t(!1)}finally{p(null)}}};return r?e.jsx($,{open:a,onOpenChange:t,children:e.jsxs(q,{className:"max-w-2xl max-h-[70vh] flex flex-col",children:[e.jsxs(A,{children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-5 w-5"}),"Conversation Timeline"]}),e.jsx(Q,{children:"Navigate to any point in the conversation or fork a new session"})]}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(P,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:"Search messages...",value:c,onChange:s=>T(s.target.value),className:"pl-9 w-full"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:g.length===0?e.jsx("div",{className:"text-center text-muted-foreground py-8",children:c?"No messages found":"No messages in this session yet"}):g.map(s=>{const o=b(s.parts),j=s.info.time.created,R=E(j),F=d.length-d.indexOf(s);return e.jsxs("div",{className:"group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer",onClick:async()=>{await n?.(s.info.id)!==!1&&t(!1)},children:[e.jsxs("span",{className:"typography-meta text-muted-foreground w-5 text-right flex-shrink-0",children:[F,"."]}),e.jsxs("p",{className:"flex-1 min-w-0 typography-small text-foreground truncate ml-0.5",children:[o||"[No text content]",o&&o.length>=80&&"…"]}),e.jsxs("div",{className:"flex-shrink-0 h-5 flex items-center mr-2",children:[e.jsx("span",{className:"typography-meta text-muted-foreground whitespace-nowrap group-hover:hidden",children:R}),e.jsxs("div",{className:"hidden group-hover:flex gap-1",children:[e.jsxs(w,{delayDuration:1e3,children:[e.jsx(y,{asChild:!0,children:e.jsx("button",{type:"button",className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",onClick:async u=>{u.stopPropagation(),await M(r,s.info.id),t(!1)},children:e.jsx(v,{className:"h-4 w-4"})})}),e.jsx(k,{sideOffset:6,children:"Revert from here"})]}),e.jsxs(w,{delayDuration:1e3,children:[e.jsx(y,{asChild:!0,children:e.jsx("button",{type:"button",className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",onClick:u=>{u.stopPropagation(),C(s.info.id)},disabled:h===s.info.id,children:h===s.info.id?e.jsx(L,{className:"h-4 w-4 animate-spin"}):e.jsx(N,{className:"h-4 w-4"})})}),e.jsx(k,{sideOffset:6,children:"Fork from here"})]})]})]})]},s.info.id)})}),e.jsxs("div",{className:"mt-4 p-3 bg-muted/30 rounded-lg",children:[e.jsx("p",{className:"typography-meta text-muted-foreground font-medium mb-2",children:"Actions"}),e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"text-[11px] uppercase tracking-wide text-muted-foreground/90 hover:text-foreground",onClick:()=>{f?.(-1),t(!1)},children:"Previous turn"}),e.jsx("span",{className:"text-muted-foreground/50",children:"/"}),e.jsx("button",{type:"button",className:"text-[11px] uppercase tracking-wide text-muted-foreground/90 hover:text-foreground",onClick:()=>{i?.(),t(!1)},children:"Latest"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 typography-meta text-muted-foreground",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:"Click on a message to scroll to it in the conversation"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:"Undo to this point (message text will populate input)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{children:"Create a new session starting from here"})]})]})]})]})}):null};function b(a){const t=a.find(n=>n.type==="text");return!t||typeof t.text!="string"?"":t.text.replace(/\n/g," ").slice(0,80)}export{J as TimelineDialog};
@@ -0,0 +1,16 @@
1
+ import{fC as Se,_ as tt,R as T,e as ee,u as s,em as nt,aO as Ve,d6 as Te,d5 as Ue,aT as st,bl as it,d2 as Ce,bv as rt,bj as ze,K as ot,a_ as at,aS as De,cZ as lt,i as ct,c_ as dt,d3 as ut,aR as ft,d4 as mt,aa as We,b3 as pt,Z as ht,a4 as Be,aA as gt}from"./vendor-.bun-HTKwyaEM.js";import{o as xt,p as Ge,q as wt,r as bt,s as yt,t as vt,v as jt,w as qe,x as Nt,y as kt,z as Ae,A as Tt,E as $e,h as St,g as _t}from"./main-B6oiMU86.js";import{c as fe,a5 as ve}from"./index-o_d2wtWC.js";const Lt={text:"plain",plaintext:"plain",shell:"bash",sh:"bash",zsh:"bash",patch:"diff",dockerfile:"docker",js:"javascript",ts:"typescript"},Pe=new Set(["plain"]),Re=new Map,Rt={typescript:["javascript"],tsx:["typescript","jsx","javascript"],jsx:["javascript"],cpp:["c"],csharp:["c"],scss:["css"],kotlin:["java"],toml:[],docker:["bash"]},Ee=n=>{const e=n.toLowerCase();return Lt[e]??e},Ie=n=>Pe.has(n)||!!Se.languages[n],Ke=async n=>{if(Ie(n)){Pe.add(n);return}const e=Re.get(n);if(e)return e;const t=(async()=>{const o=Rt[n]??[];for(const a of o)await Ke(a);try{await tt(()=>import(`prismjs/components/prism-${n}.min.js`),[]),Pe.add(n)}catch{console.warn(`[Prism] Failed to load language: ${n}`)}})();Re.set(n,t),await t,Re.delete(n)},Pt=async n=>{const e=Ee(n);return e==="plain"||e==="text"||Ie(e)?!0:(await Ke(e),Ie(e))},It=80,Mt=20,Et=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Ct=n=>Object.entries(n).filter(([,e])=>e!=null).map(([e,t])=>`${Et(e)}:${String(t)};`).join(""),zt=n=>n.split(",").map(e=>e.trim()).filter(Boolean).flatMap(e=>e.startsWith(".token")?[`.oc-virtualized-prism ${e}`]:e.startsWith("token.")?[`.oc-virtualized-prism .${e}`]:/^[a-z0-9_-]+$/i.test(e)?[`.oc-virtualized-prism .token.${e}`]:e.includes("token")?[`.oc-virtualized-prism ${e}`]:[]),Dt=n=>{const e=[];return Object.entries(n).forEach(([t,o])=>{const a=zt(t);if(a.length===0)return;const l=Ct(o);l&&e.push(`${a.join(",")}{${l}}`)}),e.join(`
2
+ `)},At=5e3,xe=new Map,$t=(n,e)=>{const t=Ee(e),o=`${t}
3
+ ${n}`,a=xe.get(o);if(a!==void 0)return a;const l=Se.languages[t]??Se.languages.text;if(!l){const i=Me(n);return xe.set(o,i),i}try{const i=Se.highlight(n,l,t);if(xe.size>=At){const r=xe.keys().next().value;typeof r=="string"&&xe.delete(r)}return xe.set(o,i),i}catch{const i=Me(n);return xe.set(o,i),i}};function Me(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const Ht=n=>{const e=ee.c(5),[t,o]=T.useState(!1);let a;e[0]!==n?(a=Ee(n),e[0]=n,e[1]=a):a=e[1];const l=a;let i,r;return e[2]!==l?(i=()=>{let c=!1;return o(!1),Pt(l).then(()=>{c||o(!0)}),()=>{c=!0}},r=[l],e[2]=l,e[3]=i,e[4]=r):(i=e[3],r=e[4]),T.useEffect(i,r),t},Ze=T.memo(n=>{const e=ee.c(41),{lines:t,language:o,syntaxTheme:a,maxHeight:l,showLineNumbers:i,lineStyles:r}=n,c=l===void 0?"60vh":l,d=i===void 0?!0:i;let p;e[0]!==a?(p=Dt(a),e[0]=a,e[1]=p):p=e[1];const k=p,L=Ht(o),E=t.length>It;if(!L){let g;e[2]!==c?(g={maxHeight:c,overflow:"auto"},e[2]=c,e[3]=g):g=e[3];let h;e[4]!==k?(h=k?s.jsx("style",{children:k}):null,e[4]=k,e[5]=h):h=e[5];let b;if(e[6]!==r||e[7]!==t||e[8]!==d){let v;e[10]!==r||e[11]!==d?(v=(j,x)=>s.jsx(_e,{line:{...j,text:Me(j.text)},language:"plain",showLineNumbers:d,style:r?.(j)},x),e[10]=r,e[11]=d,e[12]=v):v=e[12],b=t.map(v),e[6]=r,e[7]=t,e[8]=d,e[9]=b}else b=e[9];let m;return e[13]!==g||e[14]!==h||e[15]!==b?(m=s.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism opacity-50",style:g,children:[h,b]}),e[13]=g,e[14]=h,e[15]=b,e[16]=m):m=e[16],m}if(!E){let g;e[17]!==c?(g={maxHeight:c,overflow:"auto"},e[17]=c,e[18]=g):g=e[18];let h;e[19]!==k?(h=k?s.jsx("style",{children:k}):null,e[19]=k,e[20]=h):h=e[20];let b;if(e[21]!==o||e[22]!==r||e[23]!==t||e[24]!==d){let v;e[26]!==o||e[27]!==r||e[28]!==d?(v=(j,x)=>s.jsx(_e,{line:j,language:o,showLineNumbers:d,style:r?.(j)},x),e[26]=o,e[27]=r,e[28]=d,e[29]=v):v=e[29],b=t.map(v),e[21]=o,e[22]=r,e[23]=t,e[24]=d,e[25]=b}else b=e[25];let m;return e[30]!==g||e[31]!==h||e[32]!==b?(m=s.jsxs("div",{className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:g,children:[h,b]}),e[30]=g,e[31]=h,e[32]=b,e[33]=m):m=e[33],m}let N;return e[34]!==o||e[35]!==r||e[36]!==t||e[37]!==c||e[38]!==k||e[39]!==d?(N=s.jsx(Ye,{lines:t,language:o,prismThemeCss:k,maxHeight:c,showLineNumbers:d,lineStyles:r}),e[34]=o,e[35]=r,e[36]=t,e[37]=c,e[38]=k,e[39]=d,e[40]=N):N=e[40],N});Ze.displayName="VirtualizedCodeBlock";const Ye=T.memo(({lines:n,language:e,prismThemeCss:t,maxHeight:o,showLineNumbers:a,lineStyles:l})=>{const i=T.useRef(null),r=nt({count:n.length,getScrollElement:()=>i.current,estimateSize:()=>Mt,overscan:20});return s.jsxs("div",{ref:i,className:"typography-code font-mono w-full min-w-0 oc-virtualized-prism",style:{maxHeight:o,overflow:"auto"},children:[t?s.jsx("style",{children:t}):null,s.jsx("div",{style:{height:`${r.getTotalSize()}px`,width:"100%",position:"relative"},children:r.getVirtualItems().map(c=>{const d=n[c.index];return s.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${c.size}px`,transform:`translateY(${c.start}px)`},children:s.jsx(_e,{line:d,language:e,showLineNumbers:a,style:l?.(d)})},c.index)})})]})});Ye.displayName="VirtualizedRows";const _e=T.memo(n=>{const e=ee.c(15),{line:t,language:o,showLineNumbers:a,style:l}=n;let i;e[0]!==o||e[1]!==t.text?(i=$t(t.text,o),e[0]=o,e[1]=t.text,e[2]=i):i=e[2];const r=i;let c;e[3]!==t.isInfo||e[4]!==t.lineNumber||e[5]!==a?(c=a&&s.jsx("span",{className:"w-10 flex-shrink-0 text-right pr-3 select-none border-r mr-3 -my-0.5 py-0.5",style:{color:"var(--tools-edit-line-number)",borderColor:"var(--tools-border)"},children:!t.isInfo&&t.lineNumber!=null?t.lineNumber:""}),e[3]=t.isInfo,e[4]=t.lineNumber,e[5]=a,e[6]=c):c=e[6];let d;e[7]!==r||e[8]!==t.isInfo||e[9]!==t.text?(d=s.jsx("div",{className:"flex-1 min-w-0",children:t.isInfo?s.jsx("div",{className:"whitespace-pre-wrap break-words text-muted-foreground/70 italic",children:t.text}):s.jsx("div",{className:"whitespace-pre",dangerouslySetInnerHTML:{__html:r}})}),e[7]=r,e[8]=t.isInfo,e[9]=t.text,e[10]=d):d=e[10];let p;return e[11]!==l||e[12]!==c||e[13]!==d?(p=s.jsxs("div",{className:"typography-code font-mono flex w-full min-w-0",style:l,children:[c,d]}),e[11]=l,e[12]=c,e[13]=d,e[14]=p):p=e[14],p});_e.displayName="VirtualizedCodeBlock.Row";const Ot=n=>{const e="h-3.5 w-3.5 flex-shrink-0",t=n.toLowerCase();return t==="reasoning"?s.jsx(st,{className:e}):t==="image-preview"?s.jsx(it,{className:e}):t==="mermaid-preview"?s.jsx(Ce,{className:e}):t==="edit"||t==="multiedit"||t==="apply_patch"||t==="str_replace"||t==="str_replace_based_edit_tool"?s.jsx(rt,{className:e}):t==="write"||t==="create"||t==="file_write"?s.jsx(ze,{className:e}):t==="read"||t==="view"||t==="file_read"||t==="cat"?s.jsx(ze,{className:e}):t==="bash"||t==="shell"||t==="cmd"||t==="terminal"?s.jsx(ot,{className:e}):t==="list"||t==="ls"||t==="dir"||t==="list_files"?s.jsx(at,{className:e}):t==="search"||t==="grep"||t==="find"||t==="ripgrep"?s.jsx(De,{className:e}):t==="glob"?s.jsx(lt,{className:e}):t==="fetch"||t==="curl"||t==="wget"||t==="webfetch"?s.jsx(ct,{className:e}):t==="web-search"||t==="websearch"||t==="search_web"||t==="google"||t==="bing"||t==="duckduckgo"?s.jsx(De,{className:e}):t==="todowrite"||t==="todoread"?s.jsx(dt,{className:e}):t==="plan_enter"?s.jsx(Ce,{className:e}):t==="plan_exit"?s.jsx(ut,{className:e}):t.startsWith("git")?s.jsx(ft,{className:e}):s.jsx(Ve,{className:e})},He=150,Ft=40,Vt=120,Ut=3,Wt=`
4
+ [data-diff-header],
5
+ [data-diff] {
6
+ [data-separator] {
7
+ height: 24px !important;
8
+ }
9
+ }
10
+ `,Bt={hunkLineCount:50,lineHeight:24,diffHeaderHeight:44,hunkSeparatorHeight:24,fileGap:0},Gt=()=>{const n=ee.c(22),e=kt();let t;n[0]===Symbol.for("react.memo_cache_sentinel")?(t=Ae(!1),n[0]=t):t=n[0];const o=t;let a;n[1]===Symbol.for("react.memo_cache_sentinel")?(a=Ae(!0),n[1]=a):a=n[1];const l=a;let i;n[2]!==e?.availableThemes?(i=()=>e?.availableThemes??[o,l],n[2]=e?.availableThemes,n[3]=i):i=n[3],e?.availableThemes;let r;n[4]!==i?(r=i(),n[4]=i,n[5]=r):r=n[5];const c=r,d=e?.lightThemeId??o.metadata.id,p=e?.darkThemeId??l.metadata.id;let k;n[6]!==c||n[7]!==d?(k=c.find(x=>x.metadata.id===d)??o,n[6]=c,n[7]=d,n[8]=k):k=n[8];const L=k;let E;n[9]!==c||n[10]!==p?(E=c.find(x=>x.metadata.id===p)??l,n[9]=c,n[10]=p,n[11]=E):E=n[11];const N=E;let g,h;n[12]!==N||n[13]!==L?(g=()=>{$e(L),$e(N)},h=[N,L],n[12]=N,n[13]=L,n[14]=g,n[15]=h):(g=n[14],h=n[15]),T.useEffect(g,h);const b=e?.currentTheme.metadata.variant??"light";let m;n[16]!==N.metadata.id||n[17]!==L.metadata.id?(m={light:L.metadata.id,dark:N.metadata.id},n[16]=N.metadata.id,n[17]=L.metadata.id,n[18]=m):m=n[18];const v=b==="dark"?"dark":"light";let j;return n[19]!==m||n[20]!==v?(j={theme:m,themeType:v},n[19]=m,n[20]=v,n[21]=j):j=n[21],j},Oe=()=>({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0}),Fe={mobile:{widthRatio:.94,heightRatio:.86,padding:10},desktop:{widthRatio:.8,heightRatio:.8,padding:16}},qt=(n,e)=>{const t=e?Fe.mobile:Fe.desktop,o=Math.max(160,n.width-t.padding*2),a=Math.max(160,n.height-t.padding*2);return{maxWidth:Math.max(160,Math.min(o,n.width*t.widthRatio)),maxHeight:Math.max(160,Math.min(a,n.height*t.heightRatio))}},Kt=n=>{try{const l=Array.from(n.querySelectorAll("g"));let i=0,r=null;for(const c of l){if(!(c instanceof SVGGraphicsElement))continue;const d=c.getBBox();if(!(d.width>0&&d.height>0))continue;const p=d.width*d.height;p>i&&(i=p,r=d.width/d.height)}if(r&&Number.isFinite(r)&&r>0)return r}catch{}const e=n.getAttribute("viewBox");if(e){const l=e.trim().split(/\s+/).map(Number);if(l.length===4){const i=l[2],r=l[3];if(Number.isFinite(i)&&Number.isFinite(r)&&i>0&&r>0)return i/r}}const t=Number(n.getAttribute("width")),o=Number(n.getAttribute("height"));if(Number.isFinite(t)&&Number.isFinite(o)&&t>0&&o>0)return t/o;const a=n.getBoundingClientRect();return a.width>0&&a.height>0?a.width/a.height:null},Xe=n=>{const e=ee.c(7),[t,o]=T.useState(n),[a,l]=T.useState(n),[i,r]=T.useState(!1);let c,d;e[0]!==n?(c=()=>{if(n){if(o(!0),r(!0),typeof window>"u"){l(!0);return}const L=window.requestAnimationFrame(()=>{l(!0)}),E=window.setTimeout(()=>{r(!1)},He);return()=>{window.cancelAnimationFrame(L),window.clearTimeout(E)}}if(l(!1),r(!0),typeof window>"u"){o(!1);return}const k=window.setTimeout(()=>{o(!1),r(!1)},He);return()=>{window.clearTimeout(k)}},d=[n],e[0]=n,e[1]=c,e[2]=d):(c=e[1],d=e[2]),T.useEffect(c,d);let p;return e[3]!==t||e[4]!==i||e[5]!==a?(p={isRendered:t,isVisible:a,isTransitioning:i},e[3]=t,e[4]=i,e[5]=a,e[6]=p):p=e[6],p},Je=n=>{const e=ee.c(3),[t,o]=T.useState(Oe);let a,l;return e[0]!==n?(a=()=>{if(!n||typeof window>"u")return;const i=()=>{o(Oe())};return i(),window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},l=[n],e[0]=n,e[1]=a,e[2]=l):(a=e[1],l=e[2]),T.useEffect(a,l),t},Zt=n=>{const e=ee.c(99),{popup:t,onOpenChange:o,isMobile:a}=n;let l;e:{const u=t.image;if(!u){let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R=[],e[0]=R):R=e[0],l=R;break e}let w;e[1]!==u.gallery?(w=Array.isArray(u.gallery)?u.gallery.filter(Xt):[],e[1]=u.gallery,e[2]=w):w=e[2];const M=w;if(M.length>0){l=M;break e}let C;e[3]!==u.filename||e[4]!==u.mimeType||e[5]!==u.size||e[6]!==u.url?(C=[{url:u.url,mimeType:u.mimeType,filename:u.filename,size:u.size}],e[3]=u.filename,e[4]=u.mimeType,e[5]=u.size,e[6]=u.url,e[7]=C):C=e[7],l=C}const i=l,[r,c]=T.useState(0),[d,p]=T.useState(null),{isRendered:k,isVisible:L,isTransitioning:E}=Xe(t.open),N=Je(t.open);let g;e[8]!==i||e[9]!==t.image||e[10]!==t.open?(g=()=>{if(!t.open||i.length===0)return;const u=typeof t.image?.index=="number"?t.image.index:-1;if(u>=0&&u<i.length){c(u);return}const w=t.image?.url?i.findIndex(M=>M.url===t.image?.url):-1;c(w>=0?w:0)},e[8]=i,e[9]=t.image,e[10]=t.open,e[11]=g):g=e[11];const h=t.image?.index,b=t.image?.url;let m;e[12]!==i||e[13]!==t.open||e[14]!==h||e[15]!==b?(m=[i,h,b,t.open],e[12]=i,e[13]=t.open,e[14]=h,e[15]=b,e[16]=m):m=e[16],T.useEffect(g,m);const v=i[r]??i[0]??t.image,j=v?.filename||t.title||"Image preview",x=i.length>1;let y;e[17]!==i.length?(y=()=>{i.length<=1||c(u=>(u-1+i.length)%i.length)},e[17]=i.length,e[18]=y):y=e[18];const _=y;let I;e[19]!==i.length?(I=()=>{i.length<=1||c(u=>(u+1)%i.length)},e[19]=i.length,e[20]=I):I=e[20];const f=I;let G,P;e[21]!==x||e[22]!==o||e[23]!==t.open||e[24]!==f||e[25]!==_?(G=()=>{if(!t.open)return;const u=w=>{if(w.key==="Escape"){o(!1);return}if(w.key==="ArrowLeft"&&x){w.preventDefault(),_();return}w.key==="ArrowRight"&&x&&(w.preventDefault(),f())};return window.addEventListener("keydown",u),()=>{window.removeEventListener("keydown",u)}},P=[x,o,t.open,f,_],e[21]=x,e[22]=o,e[23]=t.open,e[24]=f,e[25]=_,e[26]=G,e[27]=P):(G=e[26],P=e[27]),T.useEffect(G,P);let Z;e[28]===Symbol.for("react.memo_cache_sentinel")?(Z=()=>{p(null)},e[28]=Z):Z=e[28];const q=v?.url;let te;e[29]!==q?(te=[q],e[29]=q,e[30]=te):te=e[30],T.useEffect(Z,te);let we;e:{const u=Math.max(160,N.width*(a?.86:.75)),w=Math.max(160,N.height*(a?.72:.75));if(!d){let be;e[31]!==u?(be=Math.round(u),e[31]=u,e[32]=be):be=e[32];let ye;e[33]!==w?(ye=Math.round(w),e[33]=w,e[34]=ye):ye=e[34];let ke;e[35]!==be||e[36]!==ye?(ke={width:be,height:ye},e[35]=be,e[36]=ye,e[37]=ke):ke=e[37],we=ke;break e}const M=u/d.width,C=w/d.height,R=Math.min(M,C);let z;e[38]!==d.width||e[39]!==R?(z=Math.round(d.width*R),e[38]=d.width,e[39]=R,e[40]=z):z=e[40];const K=Math.max(1,z);let je;e[41]!==d.height||e[42]!==R?(je=Math.round(d.height*R),e[41]=d.height,e[42]=R,e[43]=je):je=e[43];const Le=Math.max(1,je);let Ne;e[44]!==K||e[45]!==Le?(Ne={width:K,height:Le},e[44]=K,e[45]=Le,e[46]=Ne):Ne=e[46],we=Ne}const me=we;if(!k||!v||typeof document>"u")return null;const ne=t.open?"pointer-events-auto":"pointer-events-none";let se;e[47]!==ne?(se=fe("fixed inset-0 z-50",ne),e[47]=ne,e[48]=se):se=e[48];const pe=E&&"transition-opacity duration-150 ease-out",ie=L?"opacity-100":"opacity-0";let A;e[49]!==pe||e[50]!==ie?(A=fe("absolute inset-0 bg-black/25 backdrop-blur-md",pe,ie),e[49]=pe,e[50]=ie,e[51]=A):A=e[51];let $;e[52]!==o?($=()=>o(!1),e[52]=o,e[53]=$):$=e[53];let re;e[54]!==A||e[55]!==$?(re=s.jsx("div",{"aria-hidden":"true","data-blur-bg":!0,className:A,onMouseDown:$}),e[54]=A,e[55]=$,e[56]=re):re=e[56];let H;e[57]!==x||e[58]!==f||e[59]!==_?(H=x&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onMouseDown:Jt,onClick:_,className:"absolute left-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/25 text-foreground/90 backdrop-blur-sm hover:bg-black/35 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":"Previous image",children:s.jsx(pt,{className:"h-6 w-6"})}),s.jsx("button",{type:"button",onMouseDown:Qt,onClick:f,className:"absolute right-3 top-1/2 -translate-y-1/2 z-10 h-10 w-10 flex items-center justify-center rounded-full bg-black/25 text-foreground/90 backdrop-blur-sm hover:bg-black/35 focus:outline-none focus:ring-2 focus:ring-primary/60","aria-label":"Next image",children:s.jsx(ht,{className:"h-6 w-6"})})]}),e[57]=x,e[58]=f,e[59]=_,e[60]=H):H=e[60];const he=a?"p-2.5":"p-4";let oe;e[61]!==he?(oe=fe("absolute inset-0 flex items-center justify-center pointer-events-none",he),e[61]=he,e[62]=oe):oe=e[62];const ae=E&&"transition-opacity duration-150 ease-out",ge=L?"opacity-100":"opacity-0";let O;e[63]!==ae||e[64]!==ge?(O=fe("pointer-events-auto flex flex-col gap-2",ae,ge),e[63]=ae,e[64]=ge,e[65]=O):O=e[65];const le=`${me.width}px`;let Y;e[66]!==le?(Y={width:le},e[66]=le,e[67]=Y):Y=e[67];let F;e[68]!==j?(F=s.jsx("div",{className:"min-w-0 flex-1 text-foreground typography-ui-header font-semibold truncate",title:j,children:j}),e[68]=j,e[69]=F):F=e[69];let ce;e[70]!==o?(ce=()=>o(!1),e[70]=o,e[71]=ce):ce=e[71];let X;e[72]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx(Be,{className:"h-4 w-4"}),e[72]=X):X=e[72];let V;e[73]!==ce?(V=s.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:ce,"aria-label":"Close image preview",children:X}),e[73]=ce,e[74]=V):V=e[74];let U;e[75]!==F||e[76]!==V?(U=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[F,V]}),e[75]=F,e[76]=V,e[77]=U):U=e[77];const de=`${me.width}px`,ue=`${me.height}px`;let W;e[78]!==de||e[79]!==ue?(W={width:de,height:ue},e[78]=de,e[79]=ue,e[80]=W):W=e[80];let J;e[81]===Symbol.for("react.memo_cache_sentinel")?(J=u=>{const w=u.currentTarget,M=w.naturalWidth,C=w.naturalHeight;M>0&&C>0&&p(R=>R&&R.width===M&&R.height===C?R:{width:M,height:C})},e[81]=J):J=e[81];let B;e[82]!==v.url||e[83]!==j||e[84]!==W?(B=s.jsx("img",{src:v.url,alt:j,className:"block object-contain",style:W,loading:"lazy",onLoad:J}),e[82]=v.url,e[83]=j,e[84]=W,e[85]=B):B=e[85];let Q;e[86]!==O||e[87]!==Y||e[88]!==U||e[89]!==B?(Q=s.jsxs("div",{className:O,style:Y,children:[U,B]}),e[86]=O,e[87]=Y,e[88]=U,e[89]=B,e[90]=Q):Q=e[90];let S;e[91]!==oe||e[92]!==Q?(S=s.jsx("div",{className:oe,children:Q}),e[91]=oe,e[92]=Q,e[93]=S):S=e[93];let D;if(e[94]!==se||e[95]!==re||e[96]!==H||e[97]!==S){const u=s.jsxs("div",{className:se,children:[re,H,S]});D=We.createPortal(u,document.body),e[94]=se,e[95]=re,e[96]=H,e[97]=S,e[98]=D}else D=e[98];return D},Qe=T.memo(n=>{const e=ee.c(7),{popup:t,diffViewMode:o,pierreThemeConfig:a}=n,l=t.content||"",i=o==="unified"?"unified":"split";let r;e[0]!==a.theme||e[1]!==a.themeType||e[2]!==i?(r={diffStyle:i,diffIndicators:"none",hunkSeparators:"line-info-basic",lineDiffType:"none",disableFileHeader:!0,maxLineDiffLength:1e3,expansionLineCount:20,overflow:"wrap",theme:a.theme,themeType:a.themeType,unsafeCSS:Wt},e[0]=a.theme,e[1]=a.themeType,e[2]=i,e[3]=r):r=e[3];let c;return e[4]!==l||e[5]!==r?(c=s.jsx("div",{className:"typography-code",children:s.jsx(mt,{patch:l,metrics:Bt,options:r,className:"block w-full"})}),e[4]=l,e[5]=r,e[6]=c):c=e[6],c});Qe.displayName="DialogUnifiedDiff";const et=T.memo(n=>{const e=ee.c(30),{popup:t,syntaxTheme:o,pierreThemeConfig:a}=n;let l;e[0]!==t.content?(l=Tt(t.content),e[0]=t.content,e[1]=l):l=e[1];const i=l,r=t.metadata?.input;let c;e[2]!==r?(c=typeof r=="object"&&r!==null?r:{},e[2]=r,e[3]=c):c=e[3];const d=c,p=typeof d.offset=="number"?d.offset:0,k=typeof d.file_path=="string"?d.file_path:typeof d.filePath=="string"?d.filePath:typeof d.path=="string"?d.path:"read-output";let L;e[4]!==i.lines?(L=i.lines.map(en).join(`
11
+ `),e[4]=i.lines,e[5]=L):L=e[5];const E=L;let N;e[6]!==k||e[7]!==t.language?(N=t.language||Ge(k)||"text",e[6]=k,e[7]=t.language,e[8]=N):N=e[8];const g=N;let h;e[9]!==i.lines?(h=i.lines.some(tn),e[9]=i.lines,e[10]=h):h=e[10];const b=h;let m;if(e[11]!==b||e[12]!==p||e[13]!==i.lines||e[14]!==i.type){m=[];let x=p;for(const y of i.lines){y.lineNumber!==null&&(x=y.lineNumber);const _=i.type==="file"&&!b&&y.lineNumber===null&&!y.isInfo,I=y.lineNumber??(_?x+1:null);typeof I=="number"&&(x=I),m.push({text:y.text,lineNumber:I,isInfo:y.isInfo})}e[11]=b,e[12]=p,e[13]=i.lines,e[14]=i.type,e[15]=m}else m=e[15];const v=m;if(i.type==="file"){const x=g||void 0;let y;e[16]!==E||e[17]!==k||e[18]!==x?(y={name:k,contents:E,lang:x},e[16]=E,e[17]=k,e[18]=x,e[19]=y):y=e[19];let _;e[20]!==a.theme||e[21]!==a.themeType?(_={disableFileHeader:!0,overflow:"wrap",theme:a.theme,themeType:a.themeType},e[20]=a.theme,e[21]=a.themeType,e[22]=_):_=e[22];let I;return e[23]!==y||e[24]!==_?(I=s.jsx(Ue,{file:y,options:_,className:"block w-full"}),e[23]=y,e[24]=_,e[25]=I):I=e[25],I}let j;return e[26]!==v||e[27]!==g||e[28]!==o?(j=s.jsx(Ze,{lines:v,language:g,syntaxTheme:o,maxHeight:"70vh"}),e[26]=v,e[27]=g,e[28]=o,e[29]=j):j=e[29],j});et.displayName="DialogReadContent";const Yt=n=>{const e=ee.c(83),{popup:t,onOpenChange:o,isMobile:a}=n,[l,i]=T.useState(t.mermaid?.source||""),[r,c]=T.useState(t.mermaid?.source?"ready":"idle"),[d,p]=T.useState(""),{isRendered:k,isVisible:L,isTransitioning:E}=Xe(t.open),[N,g]=T.useState(null),h=Je(t.open),b=T.useRef(0),m=T.useRef(null),v=on,j=an;let x;e[0]!==t.mermaid?(x=async()=>{const S=t.mermaid;if(!S?.url){c("error"),p("Missing Mermaid source URL.");return}if(S.source){i(S.source),c("ready"),p("");return}const D=b.current+1;b.current=D,c("loading"),p("");let u;if(S.url.startsWith("data:"))u=Promise.resolve(j(S.url));else if(S.url.toLowerCase().startsWith("file://")){const w=v(S.url);w?u=fetch(`/api/fs/raw?path=${encodeURIComponent(w)}`).then(ln):u=Promise.reject(new Error("Invalid local file path for Mermaid preview."))}else{const M=(typeof URL.canParse=="function"?URL.canParse(S.url,window.location.origin):!1)?new URL(S.url,window.location.origin):null;!M||M.protocol!=="http:"&&M.protocol!=="https:"?u=Promise.reject(new Error("Unsupported Mermaid URL protocol.")):u=fetch(M.toString()).then(cn)}await u.then(w=>{b.current===D&&(i(w),c("ready"))}).catch(w=>{b.current===D&&(c("error"),p(w instanceof Error?w.message:"Unable to load Mermaid diagram."))})},e[0]=t.mermaid,e[1]=x):x=e[1];const y=x;let _,I;e[2]!==y||e[3]!==t.mermaid||e[4]!==t.open?(_=()=>{!t.open||!t.mermaid||y()},I=[y,t.mermaid,t.open],e[2]=y,e[3]=t.mermaid,e[4]=t.open,e[5]=_,e[6]=I):(_=e[5],I=e[6]),T.useEffect(_,I);let f,G;e[7]!==o||e[8]!==t.open?(f=()=>{if(!t.open)return;const S=D=>{D.key==="Escape"&&o(!1)};return window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}},G=[o,t.open],e[7]=o,e[8]=t.open,e[9]=f,e[10]=G):(f=e[9],G=e[10]),T.useEffect(f,G);let P;e[11]!==t.open||e[12]!==r?(P=()=>{if(!t.open||r!=="ready"){g(null);return}const S=()=>{const R=m.current?.querySelector("svg");if(!R)return!1;const z=Kt(R);return!z||!Number.isFinite(z)||z<=0?!1:(g(K=>K&&Math.abs(K-z)<.001?K:z),!0)};let D=window.requestAnimationFrame(()=>{S()||(D=window.requestAnimationFrame(()=>{S()}))}),u=0,w;const M=()=>{u>=Ut||(w=window.setTimeout(()=>{u=u+1,S()||M()},Vt))};M();const C=new MutationObserver(()=>{S()});return m.current&&C.observe(m.current,{childList:!0,subtree:!0,attributes:!0}),()=>{window.cancelAnimationFrame(D),typeof w=="number"&&window.clearTimeout(w),C.disconnect()}},e[11]=t.open,e[12]=r,e[13]=P):P=e[13];let Z;e[14]!==t.open||e[15]!==l||e[16]!==r?(Z=[t.open,l,r],e[14]=t.open,e[15]=l,e[16]=r,e[17]=Z):Z=e[17],T.useEffect(P,Z);const q=`\`\`\`mermaid
12
+ ${l}
13
+ \`\`\``;let te;if(e[18]!==N||e[19]!==a||e[20]!==h){e:{const{maxWidth:S,maxHeight:D}=qt(h,a),u=Math.max(160,D-Ft);if(N&&N<1){const C=Math.min(S,u);let R;e[22]!==C?(R=Math.round(C),e[22]=C,e[23]=R):R=e[23];let z;e[24]!==C?(z=Math.round(C),e[24]=C,e[25]=z):z=e[25];let K;e[26]!==z||e[27]!==R?(K={width:R,height:z},e[26]=z,e[27]=R,e[28]=K):K=e[28],te=K;break e}const w=Math.round(S);let M;e[29]!==u?(M=Math.round(u),e[29]=u,e[30]=M):M=e[30],te={width:w,height:M}}e[18]=N,e[19]=a,e[20]=h,e[21]=te}else te=e[21];const we=te;if(!k||typeof document>"u")return null;const me=t.open?"pointer-events-auto":"pointer-events-none";let ne;e[31]!==me?(ne=fe("fixed inset-0 z-50",me),e[31]=me,e[32]=ne):ne=e[32];const se=E&&"transition-opacity duration-150 ease-out",pe=L?"opacity-100":"opacity-0";let ie;e[33]!==se||e[34]!==pe?(ie=fe("absolute inset-0 bg-black/25 backdrop-blur-md",se,pe),e[33]=se,e[34]=pe,e[35]=ie):ie=e[35];let A;e[36]!==o?(A=()=>o(!1),e[36]=o,e[37]=A):A=e[37];let $;e[38]!==ie||e[39]!==A?($=s.jsx("div",{"aria-hidden":"true","data-blur-bg":!0,className:ie,onMouseDown:A}),e[38]=ie,e[39]=A,e[40]=$):$=e[40];const re=a?"p-2.5":"p-4";let H;e[41]!==re?(H=fe("absolute inset-0 flex items-center justify-center pointer-events-none",re),e[41]=re,e[42]=H):H=e[42];const he=E&&"transition-opacity duration-150 ease-out",oe=L?"opacity-100":"opacity-0";let ae;e[43]!==he||e[44]!==oe?(ae=fe("pointer-events-auto flex flex-col gap-2",he,oe),e[43]=he,e[44]=oe,e[45]=ae):ae=e[45];const ge=`${we.width}px`;let O;e[46]!==ge?(O={width:ge},e[46]=ge,e[47]=O):O=e[47];let le;e[48]!==o?(le=()=>o(!1),e[48]=o,e[49]=le):le=e[49];let Y;e[50]===Symbol.for("react.memo_cache_sentinel")?(Y=s.jsx(Be,{className:"h-4 w-4"}),e[50]=Y):Y=e[50];let F;e[51]!==le?(F=s.jsx("div",{className:"flex items-center justify-end",children:s.jsx("button",{type:"button",className:"h-8 w-8 flex items-center justify-center rounded-lg text-muted-foreground/80 hover:text-foreground focus:outline-none focus:ring-2 focus:ring-primary/60",onClick:le,"aria-label":"Close diagram preview",children:Y})}),e[51]=le,e[52]=F):F=e[52];const ce=`${we.height}px`;let X;e[53]!==ce?(X={height:ce},e[53]=ce,e[54]=X):X=e[54];let V;e[55]!==r?(V=r==="loading"&&s.jsxs("div",{className:"h-full min-h-28 flex items-center justify-center gap-2 text-muted-foreground typography-meta",children:[s.jsx(gt,{className:"h-4 w-4 animate-spin"}),s.jsx("span",{children:"Loading diagram..."})]}),e[55]=r,e[56]=V):V=e[56];let U;e[57]!==d||e[58]!==y||e[59]!==r?(U=r==="error"&&s.jsxs("div",{className:"rounded-xl border border-border/30 bg-muted/20 p-3 space-y-3",children:[s.jsx("p",{className:"typography-markdown",style:{color:"var(--status-error)"},children:d||"Unable to render Mermaid diagram."}),s.jsx("button",{type:"button",onClick:()=>{y()},className:"px-3 py-1.5 rounded-lg typography-meta border transition-colors hover:bg-[var(--interactive-hover)]",style:{borderColor:"var(--interactive-border)",color:"var(--surface-foreground)"},children:"Retry"})]}),e[57]=d,e[58]=y,e[59]=r,e[60]=U):U=e[60];let de;e[61]!==q||e[62]!==r?(de=r==="ready"&&s.jsx("div",{ref:m,className:"h-full",children:s.jsx(qe,{content:q,variant:"tool",allowMermaidWheelZoom:!0,className:"streamdown-mermaid-fullscreen h-full [&_[data-streamdown='mermaid-block']_button]:hidden",mermaidControls:{download:!1,copy:!1,fullscreen:!1,panZoom:!0}})}),e[61]=q,e[62]=r,e[63]=de):de=e[63];let ue;e[64]!==V||e[65]!==U||e[66]!==de?(ue=s.jsxs("div",{className:"h-full overflow-hidden",children:[V,U,de]}),e[64]=V,e[65]=U,e[66]=de,e[67]=ue):ue=e[67];let W;e[68]!==X||e[69]!==ue?(W=s.jsx("div",{className:"relative overflow-hidden",style:X,children:ue}),e[68]=X,e[69]=ue,e[70]=W):W=e[70];let J;e[71]!==ae||e[72]!==O||e[73]!==F||e[74]!==W?(J=s.jsxs("div",{className:ae,style:O,onMouseDown:dn,children:[F,W]}),e[71]=ae,e[72]=O,e[73]=F,e[74]=W,e[75]=J):J=e[75];let B;e[76]!==H||e[77]!==J?(B=s.jsx("div",{className:H,children:J}),e[76]=H,e[77]=J,e[78]=B):B=e[78];let Q;if(e[79]!==ne||e[80]!==$||e[81]!==B){const S=s.jsxs("div",{className:ne,children:[$,B]});Q=We.createPortal(S,document.body),e[79]=ne,e[80]=$,e[81]=B,e[82]=Q}else Q=e[82];return Q},pn=n=>{const e=ee.c(49),{popup:t,onOpenChange:o,syntaxTheme:a,isMobile:l}=n,[i,r]=T.useState("unified"),c=Gt();let d;e[0]!==t.open?(d=()=>{t.open&&r("unified")},e[0]=t.open,e[1]=d):d=e[1];let p;if(e[2]!==t.open||e[3]!==t.title?(p=[t.open,t.title],e[2]=t.open,e[3]=t.title,e[4]=p):p=e[4],T.useEffect(d,p),t.image){let f;return e[5]!==l||e[6]!==o||e[7]!==t?(f=s.jsx(Zt,{popup:t,onOpenChange:o,isMobile:l}),e[5]=l,e[6]=o,e[7]=t,e[8]=f):f=e[8],f}if(t.mermaid){let f;return e[9]!==l||e[10]!==o||e[11]!==t?(f=s.jsx(Yt,{popup:t,onOpenChange:o,isMobile:l}),e[9]=l,e[10]=o,e[11]=t,e[12]=f):f=e[12],f}const k=t.open,L=l?"w-[95vw] max-w-[95vw]":"max-w-5xl",E=l?"[&>button]:right-1":"[&>button]:top-2.5 [&>button]:right-4";let N;e[13]!==L||e[14]!==E?(N=fe("overflow-hidden flex flex-col min-h-0 pt-3 pb-4 px-4 gap-1","[&>button]:top-1.5",L,E),e[13]=L,e[14]=E,e[15]=N):N=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g={maxHeight:"90vh"},e[16]=g):g=e[16];let h;e[17]!==t.metadata?(h=t.metadata?.tool?Ot(t.metadata.tool):s.jsx(Ve,{className:"h-3.5 w-3.5 text-foreground flex-shrink-0"}),e[17]=t.metadata,e[18]=h):h=e[18];let b;e[19]!==t.title?(b=s.jsx("span",{className:"break-words flex-1 leading-tight",children:t.title}),e[19]=t.title,e[20]=b):b=e[20];let m;e[21]!==i||e[22]!==t.isDiff?(m=t.isDiff&&s.jsx(xt,{mode:i,onModeChange:r,className:"mr-8 flex-shrink-0"}),e[21]=i,e[22]=t.isDiff,e[23]=m):m=e[23];let v;e[24]!==m||e[25]!==h||e[26]!==b?(v=s.jsx("div",{className:"flex-shrink-0 pb-1",children:s.jsxs("div",{className:"flex items-start gap-2 text-foreground typography-ui-header font-semibold",children:[h,b,m]})}),e[24]=m,e[25]=h,e[26]=b,e[27]=v):v=e[27];let j;e[28]!==c||e[29]!==t.metadata||e[30]!==a?(j=t.metadata?.input&&typeof t.metadata.input=="object"&&Object.keys(t.metadata.input).length>0&&t.metadata?.tool!=="todowrite"&&t.metadata?.tool!=="todoread"&&t.metadata?.tool!=="apply_patch"?(()=>{const f=t.metadata,G=f.input,P=Z=>{const q=G[Z];return typeof q=="string"?q:typeof q=="number"?String(q):null};return s.jsxs("div",{className:"border-b border-border/20 p-4 -mx-3",children:[s.jsx("div",{className:"typography-markdown font-medium text-muted-foreground mb-2 px-3",children:f.tool==="bash"?"Command:":f.tool==="task"?"Task Details:":"Input:"}),f.tool==="bash"&&P("command")?s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:s.jsx(Te,{style:a,language:"bash",PreTag:"div",customStyle:ve.getPopupStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},wrapLongLines:!0,children:P("command")})}):f.tool==="task"&&P("prompt")?s.jsxs("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:ve.getPopupStyles(),children:[P("description")?`Task: ${P("description")}
14
+ `:"",P("subagent_type")?`Agent Type: ${P("subagent_type")}
15
+ `:"",`Instructions:
16
+ ${P("prompt")}`]}):f.tool==="write"&&P("content")?s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 mx-3",children:s.jsx(Ue,{file:{name:P("filePath")||P("file_path")||"new-file",contents:P("content"),lang:Ge(P("filePath")||P("file_path")||"")||void 0},options:{disableFileHeader:!0,overflow:"wrap",theme:c.theme,themeType:c.themeType},className:"block w-full"})}):s.jsx("div",{className:"tool-input-surface bg-transparent rounded-xl border border-border/20 font-mono whitespace-pre-wrap text-foreground/90 mx-3",style:ve.getPopupStyles(),children:wt(G,f.tool)})]})})():null,e[28]=c,e[29]=t.metadata,e[30]=a,e[31]=j):j=e[31];let x;e[32]!==i||e[33]!==l||e[34]!==c||e[35]!==t||e[36]!==a?(x=t.isDiff?s.jsx(Qe,{popup:t,diffViewMode:i,pierreThemeConfig:c}):t.content?s.jsx("div",{className:"p-4",children:(()=>{const f=t.metadata?.tool;return f==="todowrite"||f==="todoread"?bt(t.content)||s.jsx(Te,{style:a,language:"json",PreTag:"div",wrapLongLines:!0,customStyle:ve.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content}):f==="list"?yt(t.content)||s.jsx("pre",{className:"typography-markdown bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="grep"?vt(t.content,l)||s.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="glob"?jt(t.content,l)||s.jsx("pre",{className:"typography-code bg-muted/30 p-2 rounded-xl border border-border/20 font-mono whitespace-pre-wrap",children:t.content}):f==="task"||f==="reasoning"?s.jsx("div",{className:f==="reasoning"?"text-muted-foreground/70":"",children:s.jsx(qe,{content:t.content,variant:"tool"})}):f==="web-search"||f==="websearch"||f==="search_web"?Nt(t.content)||s.jsx(Te,{style:a,language:"text",PreTag:"div",wrapLongLines:!0,customStyle:ve.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content}):f==="read"?s.jsx(et,{popup:t,syntaxTheme:a,pierreThemeConfig:c}):s.jsx(Te,{style:a,language:t.language||"text",PreTag:"div",wrapLongLines:!0,customStyle:ve.getPopupContainerStyles(),codeTagProps:{style:{background:"transparent",backgroundColor:"transparent",fontSize:"inherit"}},children:t.content})})()}):s.jsxs("div",{className:"p-8 text-muted-foreground typography-ui-header",children:[s.jsx("div",{className:"mb-2",children:"Command completed successfully"}),s.jsx("div",{className:"typography-meta",children:"No output was produced"})]}),e[32]=i,e[33]=l,e[34]=c,e[35]=t,e[36]=a,e[37]=x):x=e[37];let y;e[38]!==j||e[39]!==x?(y=s.jsx("div",{className:"flex-1 min-h-0 rounded-xl border border-border/30 bg-muted/10 overflow-hidden",children:s.jsxs("div",{className:"tool-output-surface h-full max-h-[75vh] overflow-y-auto px-3 pr-4",children:[j,x]})}),e[38]=j,e[39]=x,e[40]=y):y=e[40];let _;e[41]!==v||e[42]!==y||e[43]!==N?(_=s.jsxs(St,{className:N,style:g,children:[v,y]}),e[41]=v,e[42]=y,e[43]=N,e[44]=_):_=e[44];let I;return e[45]!==o||e[46]!==t.open||e[47]!==_?(I=s.jsx(_t,{open:k,onOpenChange:o,children:_}),e[45]=o,e[46]=t.open,e[47]=_,e[48]=I):I=e[48],I};function Xt(n){return!!n?.url}function Jt(n){return n.stopPropagation()}function Qt(n){return n.stopPropagation()}function en(n){return n.text}function tn(n){return n.lineNumber!==null}function nn(n){if(!n||/[\0\r\n]/.test(n))return!1;const e=n.replace(/\\/g,"/");return e.split("/").filter(Boolean).includes("..")?!1:e.startsWith("/")?!0:/^[A-Za-z]:\//.test(e)}function sn(n,e){const t=Number.parseInt(e,16);return Number.isFinite(t)?String.fromCharCode(t):`%${e}`}function rn(n){return n.replace(/%([0-9A-Fa-f]{2})/g,sn)}function on(n){const e=n.trim();if(!e.toLowerCase().startsWith("file://"))return null;const t=nn,o=rn;if(typeof URL.canParse=="function"?URL.canParse(e):!1){let r=o(new URL(e).pathname||"");return/^\/[A-Za-z]:\//.test(r)&&(r=r.slice(1)),t(r)?r:null}const l=e.replace(/^file:\/\//i,""),i=o(l);return t(i)?i:t(l)?l:null}function an(n){const e=n.indexOf(",");if(e<0)throw new Error("Malformed data URL");const t=n.slice(0,e).toLowerCase(),o=n.slice(e+1);return t.includes(";base64")?atob(o):decodeURIComponent(o)}function ln(n){return n.ok?n.text():Promise.reject(new Error(`Failed to read diagram file (${n.status})`))}function cn(n){return n.ok?n.text():Promise.reject(new Error(`Failed to load diagram (${n.status})`))}function dn(n){return n.stopPropagation()}export{pn as default};