@hienlh/ppm 0.20.4 → 0.20.5

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 (73) hide show
  1. package/.release-bin/zip +15 -0
  2. package/.release-node-shim.sh +2 -1
  3. package/CHANGELOG.md +5 -0
  4. package/assets/skills/ppm/SKILL.md +1 -1
  5. package/assets/skills/ppm/references/http-api.md +1 -1
  6. package/dist/web/assets/{accounts-settings-section-BcI3ithh.js → accounts-settings-section-Cmmozwer.js} +1 -1
  7. package/dist/web/assets/{ai-resource-editor-C3i7VkUS.js → ai-resource-editor-BlrWV3xU.js} +1 -1
  8. package/dist/web/assets/{ai-settings-section-COdsN_5h.js → ai-settings-section-PaEh_o0w.js} +1 -1
  9. package/dist/web/assets/{ai-settings-section-DIqSLISN.js → ai-settings-section-dDsgddSt.js} +1 -1
  10. package/dist/web/assets/{appearance-settings-section-B9n42QPH.js → appearance-settings-section-DRxziHFt.js} +1 -1
  11. package/dist/web/assets/{chat-tab-D9sk38e8.js → chat-tab-MNuc18Os.js} +4 -4
  12. package/dist/web/assets/{code-editor-iTD62P14.js → code-editor-DYkmDRRF.js} +2 -2
  13. package/dist/web/assets/{conflict-editor-idh_kBSa.js → conflict-editor-D9_sr59D.js} +1 -1
  14. package/dist/web/assets/{csv-preview-B2PR7z0o.js → csv-preview-BMC8jnpF.js} +1 -1
  15. package/dist/web/assets/{database-viewer-DSv_pvEq.js → database-viewer-Box3z5-Q.js} +1 -1
  16. package/dist/web/assets/{diff-viewer-6X5S1lw3.js → diff-viewer-B4PlZ1Dt.js} +1 -1
  17. package/dist/web/assets/{explorer-body-CrtXpmZM.js → explorer-body-SvWDS84f.js} +1 -1
  18. package/dist/web/assets/{explorer-window-content-D11FZUgq.js → explorer-window-content-DBHBTA7B.js} +1 -1
  19. package/dist/web/assets/{extension-manager-section-Cz8fvK1u.js → extension-manager-section-BSt5I_H8.js} +1 -1
  20. package/dist/web/assets/{extension-webview-DzZeXQsO.js → extension-webview-DBGMUU97.js} +1 -1
  21. package/dist/web/assets/{files-settings-section-pc4jOun8.js → files-settings-section-0dwYLZou.js} +1 -1
  22. package/dist/web/assets/{general-settings-section-DIZIA54q.js → general-settings-section-BgLy_6yj.js} +1 -1
  23. package/dist/web/assets/{git-log-panel-BkcIfZIE.js → git-log-panel-BkgmcWk1.js} +1 -1
  24. package/dist/web/assets/{glide-data-grid-nA5LsoJK.js → glide-data-grid-CZVu-zCw.js} +1 -1
  25. package/dist/web/assets/{group-chat-tab-DyzfaPol.js → group-chat-tab-Cy9zIynj.js} +1 -1
  26. package/dist/web/assets/{index-DJM59ogE.js → index-DYGLdCpe.js} +4 -4
  27. package/dist/web/assets/{jira-watcher-section-UEtpcxM9.js → jira-watcher-section-DRQx632s.js} +1 -1
  28. package/dist/web/assets/{keybindings-store-BV0MMt1c.js → keybindings-store-C2HZ1mT4.js} +1 -1
  29. package/dist/web/assets/{keyboard-shortcuts-section-sY56ThaI.js → keyboard-shortcuts-section-WiZSZ-Wr.js} +1 -1
  30. package/dist/web/assets/{markdown-renderer-Bkrk39pO.js → markdown-renderer-BFYBVcZP.js} +1 -1
  31. package/dist/web/assets/{markdown-renderer-Bthd7hxl.js → markdown-renderer-CklcWnd6.js} +1 -1
  32. package/dist/web/assets/{mobile-explorer-sheet--NKsnNJn.js → mobile-explorer-sheet-D1OXw7op.js} +1 -1
  33. package/dist/web/assets/{notification-store-Bv4fnyvR.js → notification-store-DyKshGRs.js} +1 -1
  34. package/dist/web/assets/{notifications-settings-section-BGSLkMuE.js → notifications-settings-section-BEQEjvan.js} +1 -1
  35. package/dist/web/assets/{pdf-preview-DE0wVfyM.js → pdf-preview-DmQazeeV.js} +1 -1
  36. package/dist/web/assets/{postgres-viewer-C0S8dCbA.js → postgres-viewer-Cd_wXjkT.js} +1 -1
  37. package/dist/web/assets/{ppmbot-settings-section-B2AZ8whe.js → ppmbot-settings-section-PzCLPm8a.js} +1 -1
  38. package/dist/web/assets/{process-table-BmT34-_s.js → process-table-C2TdkJck.js} +1 -1
  39. package/dist/web/assets/{proxy-settings-section-BYwWFWvn.js → proxy-settings-section-DsZ6KcHD.js} +1 -1
  40. package/dist/web/assets/{query-audit-section-Dj1-npew.js → query-audit-section-2eX9-6mO.js} +1 -1
  41. package/dist/web/assets/{remote-desktop-mobile-sheet-bFIYIQIj.js → remote-desktop-mobile-sheet-CMXSUcAN.js} +2 -2
  42. package/dist/web/assets/{remote-desktop-mobile-view-BbrHPmPU.js → remote-desktop-mobile-view-Bw6p5ikf.js} +1 -1
  43. package/dist/web/assets/{remote-desktop-readiness-gate-Dme8r7Jp.js → remote-desktop-readiness-gate-W0lAhHq9.js} +1 -1
  44. package/dist/web/assets/{remote-desktop-window-content-BdbszoSx.js → remote-desktop-window-content-P888YEqm.js} +1 -1
  45. package/dist/web/assets/{schedules-settings-section-rczhjkeM.js → schedules-settings-section-C8YDAxlo.js} +1 -1
  46. package/dist/web/assets/{settings-body-CwaQg_uc.js → settings-body-B5v3_Tnb.js} +2 -2
  47. package/dist/web/assets/{settings-tab-C8l9-_9E.js → settings-tab-CauShulf.js} +1 -1
  48. package/dist/web/assets/{settings-window-content-EA1489gi.js → settings-window-content-BIosR7RY.js} +1 -1
  49. package/dist/web/assets/{sql-query-editor-BQsKZVtz.js → sql-query-editor-DMihDPnw.js} +1 -1
  50. package/dist/web/assets/{sqlite-viewer-Di8s3Z1m.js → sqlite-viewer-jCIGt2GP.js} +1 -1
  51. package/dist/web/assets/{system-monitor-body-Dlknm4Uo.js → system-monitor-body-IUamfS5w.js} +2 -2
  52. package/dist/web/assets/{system-monitor-tab-LZRO6_DP.js → system-monitor-tab-DaWeif4k.js} +1 -1
  53. package/dist/web/assets/{system-monitor-window-content-BFDfhqDd.js → system-monitor-window-content-Bq3BS7Mg.js} +1 -1
  54. package/dist/web/assets/{tab-host-window-content-Bh7064Yw.js → tab-host-window-content-vfYLLIKU.js} +1 -1
  55. package/dist/web/assets/{team-member-sheet-CU68IqU0.js → team-member-sheet-Be7OSGMT.js} +2 -2
  56. package/dist/web/assets/{team-member-window-content-BYtro89j.js → team-member-window-content-D5cYZzBq.js} +1 -1
  57. package/dist/web/assets/{terminal-tab-qfSPxRtZ.js → terminal-tab-C89DQllY.js} +1 -1
  58. package/dist/web/assets/tool-cards-CWotDH_2.js +9 -0
  59. package/dist/web/assets/{use-accounts-data-pAQw6nCa.js → use-accounts-data-lmmmG4ep.js} +1 -1
  60. package/dist/web/assets/{use-monaco-theme-DT5Q8kuf.js → use-monaco-theme-0ziS4xlp.js} +1 -1
  61. package/dist/web/assets/{use-remote-desktop-display-choice-CYQsrOMC.js → use-remote-desktop-display-choice-qBZ8ej7J.js} +1 -1
  62. package/dist/web/assets/{use-websocket-mkNA1M8U.js → use-websocket-DAvfbjxh.js} +1 -1
  63. package/dist/web/assets/{video-preview-B2dk48oQ.js → video-preview-B8xALVkh.js} +1 -1
  64. package/dist/web/index.html +1 -1
  65. package/dist/web/sw.js +1 -1
  66. package/package.json +1 -1
  67. package/src/providers/codex-app-server/codex-event-mapper.ts +4 -2
  68. package/src/server/ws/chat.ts +1 -1
  69. package/src/types/api.ts +1 -1
  70. package/src/types/chat.ts +1 -1
  71. package/src/web/components/chat/message-list.tsx +1 -1
  72. package/src/web/components/chat/tool-cards.tsx +10 -0
  73. package/dist/web/assets/tool-cards-CY9J4ux4.js +0 -9
@@ -126,11 +126,13 @@ export function itemToToolResult(item: Item): ChatEvent {
126
126
  const type = item.type;
127
127
  let output = "";
128
128
  let isError = false;
129
+ let exitCode: number | undefined;
129
130
 
130
131
  if (type === "commandExecution") {
131
132
  output = redactTruncate(item.aggregatedOutput ?? "");
132
133
  const exit = item.exitCode;
133
- isError = typeof exit === "number" && exit !== 0;
134
+ exitCode = typeof exit === "number" ? exit : undefined;
135
+ isError = exitCode != null && exitCode !== 0;
134
136
  } else if (type === "mcpToolCall") {
135
137
  output = redactTruncate(item.result ?? item.error ?? "");
136
138
  isError = item.error != null;
@@ -153,7 +155,7 @@ export function itemToToolResult(item: Item): ChatEvent {
153
155
  output = redactTruncate(item);
154
156
  }
155
157
 
156
- return { type: "tool_result", output, isError, toolUseId: item.id };
158
+ return { type: "tool_result", output, isError, ...(exitCode != null ? { exitCode } : {}), toolUseId: item.id };
157
159
  }
158
160
 
159
161
  /**
@@ -333,7 +333,7 @@ function bufferAndBroadcast(sessionId: string, event: unknown): void {
333
333
  for (let i = entry.turnEvents.length - 1; i >= 0; i--) {
334
334
  const buffered = entry.turnEvents[i] as any;
335
335
  if (buffered.type === "tool_use" && buffered.toolUseId === toolUseId) {
336
- buffered.result = { output: (event as any).output, isError: (event as any).isError };
336
+ buffered.result = { output: (event as any).output, isError: (event as any).isError, exitCode: (event as any).exitCode };
337
337
  break;
338
338
  }
339
339
  }
package/src/types/api.ts CHANGED
@@ -62,7 +62,7 @@ export type ChatWsServerMessage =
62
62
  | { type: "text"; content: string; parentToolUseId?: string }
63
63
  | { type: "thinking"; content: string; parentToolUseId?: string }
64
64
  | { type: "tool_use"; tool: string; input: unknown; toolUseId?: string; parentToolUseId?: string }
65
- | { type: "tool_result"; output: string; isError?: boolean; toolUseId?: string; parentToolUseId?: string }
65
+ | { type: "tool_result"; output: string; isError?: boolean; exitCode?: number; toolUseId?: string; parentToolUseId?: string }
66
66
  | { type: "bash_output"; toolUseId: string; content: string; lineCount: number }
67
67
  | { type: "background_registry"; sessionId: string; shells: BackgroundShell[] }
68
68
  | { type: "subagent_status"; toolUseId: string; status: import("../shared/background-agent-status").BackgroundAgentStatus }
package/src/types/chat.ts CHANGED
@@ -180,7 +180,7 @@ export type ChatEvent =
180
180
  * Absent on a launched-but-unfinished agent — the card renders that as still running. */
181
181
  bgStatus?: import("../shared/background-agent-status").BackgroundAgentStatus;
182
182
  }
183
- | { type: "tool_result"; output: string; isError?: boolean; toolUseId?: string; parentToolUseId?: string }
183
+ | { type: "tool_result"; output: string; isError?: boolean; exitCode?: number; toolUseId?: string; parentToolUseId?: string }
184
184
  | { type: "approval_request"; requestId: string; tool: string; input: unknown }
185
185
  | { type: "error"; message: string }
186
186
  | { type: "done"; sessionId: string; resultSubtype?: ResultSubtype; numTurns?: number; contextWindowPct?: number; costUsd?: number; lastMessageUuid?: string; usage?: import("../shared/turn-usage").TurnUsage }
@@ -1180,7 +1180,7 @@ function InterleavedEvents({ events, isStreaming, projectName, bashPartialOutput
1180
1180
  if (g.kind === "tool" && !g.result && g.tool.type === "tool_use") {
1181
1181
  const embedded = (g.tool as any).result;
1182
1182
  if (embedded) {
1183
- g.result = { type: "tool_result", output: embedded.output, isError: embedded.isError } as ChatEvent;
1183
+ g.result = { type: "tool_result", output: embedded.output, isError: embedded.isError, exitCode: embedded.exitCode } as ChatEvent;
1184
1184
  }
1185
1185
  }
1186
1186
  }
@@ -175,6 +175,11 @@ export function ToolCard({
175
175
  const { toolName, input } = extractToolInfo(tool);
176
176
  const hasResult = result?.type === "tool_result";
177
177
  const isError = hasResult && !!(result as any).isError;
178
+ // Codex sends an exit code for shell tools. Keep it visible: output can contain
179
+ // useful rows even when PowerShell recorded a non-terminating error and exited 1.
180
+ const exitCode = hasResult && typeof (result as any).exitCode === "number"
181
+ ? (result as any).exitCode as number
182
+ : undefined;
178
183
  const hasAnswers = toolName === "AskUserQuestion" && !!(input as any)?.answers;
179
184
  const wasApproved = tool.type === "approval_request" && (tool as any).approved != null;
180
185
  const isSubagent = (toolName === "Agent" || toolName === "Task") && tool.type === "tool_use";
@@ -256,6 +261,11 @@ export function ToolCard({
256
261
  {bgRunning && (
257
262
  <span className="text-[10px] text-primary">running…</span>
258
263
  )}
264
+ {exitCode != null && (
265
+ <span className={`text-[10px] font-mono ${exitCode === 0 ? "text-text-3" : "text-error"}`}>
266
+ exit {exitCode}
267
+ </span>
268
+ )}
259
269
  {isError || bgFailed
260
270
  ? <XCircle className="size-3.5 text-error" />
261
271
  : isDone
@@ -1,9 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/markdown-renderer-Bthd7hxl.js","assets/vendor-mermaid-CfY1-PkA.js","assets/rolldown-runtime-FhOqtrmT.js","assets/vendor-ui-CaeeFO0B.js","assets/vendor-markdown-Ls5AcU91.js","assets/markdown-renderer-Bkrk39pO.js","assets/index-DJM59ogE.js","assets/button-DX32ffge.js","assets/utils-IrnQujwR.js","assets/createLucideIcon-D8pyde1A.js","assets/arrow-left-CyFcsyzD.js","assets/bot-D6sx11y0.js","assets/check-DN75Ucvz.js","assets/chevron-down-Dp0rpHb8.js","assets/chevron-right-De-Wz5Lz.js","assets/chevron-up-8PbsNiJp.js","assets/circle-BCy0AUCo.js","assets/clock-C1CQUQPZ.js","assets/sparkles-Dh-_J2Rd.js","assets/copy-BewHj66E.js","assets/database-Y3ESDK4-.js","assets/download-DG3_9xXy.js","assets/use-coarse-long-press-BmI_GVW5.js","assets/eye-off-GjXVuAOn.js","assets/eye-gWwaF4Lg.js","assets/loader-circle-DPMrnLQ2.js","assets/monitor-C835ucWH.js","assets/x-CxoBA0po.js","assets/api-client-CEYCBt_0.js","assets/react-D1Yg256j.js","assets/window-store-D0HbQ1pM.js","assets/window-pip-registry-CrCYYTTf.js","assets/panel-store-BmdcSBNb.js","assets/context-menu-CJL8L98s.js","assets/portal-container-context-DKymYOY-.js","assets/mobile-bottom-sheet-CmySDB6I.js","assets/use-visual-viewport-Bfl3Bxxb.js","assets/use-is-mobile-D1weanbj.js","assets/project-store-wWZ6bjwq.js","assets/ws-auth-D111jj32.js","assets/settings-store-CzLnTR8p.js","assets/streaming-store-9XVmAMfV.js","assets/tab-store-1xYJb0gM.js","assets/apply-theme-BVXAUYoN.js","assets/resolve-theme-CMp5xxCW.js","assets/index-CuYtJ5xF.css","assets/image-gallery-J8h8IY0c.js","assets/run-in-terminal-wHKwAnWP.js","assets/edit-diff-preview-xdDQvPhs.js","assets/libesm-CdttTIAd.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{S as t,x as n}from"./vendor-markdown-Ls5AcU91.js";import{t as r}from"./createLucideIcon-D8pyde1A.js";import{n as i,t as a}from"./circle-question-mark-CzR7YRc-.js";import{t as o}from"./bot-D6sx11y0.js";import{t as s}from"./chevron-down-Dp0rpHb8.js";import{t as c}from"./chevron-right-De-Wz5Lz.js";import{t as l}from"./clock-C1CQUQPZ.js";import{t as u}from"./code-DJgYrFzm.js";import{n as d,t as f}from"./sparkles-Dh-_J2Rd.js";import{t as p}from"./loader-circle-DPMrnLQ2.js";import{t as m}from"./send-Bb0jtcR6.js";import{q as h}from"./vendor-mermaid-CfY1-PkA.js";import{t as g}from"./utils-IrnQujwR.js";import{t as _}from"./tab-store-1xYJb0gM.js";import{Ar as v,Dr as y,It as b,Mr as x,Nn as S,Rn as C,_r as w,nn as T,qn as E,r as D}from"./index-DJM59ogE.js";import{t as O}from"./use-blob-url-CrwoZJUJ.js";import{r as k,t as A}from"./image-gallery-J8h8IY0c.js";var j=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),M=r(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),N=r(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),P=r(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),F=r(`file-search`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]),I=r(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),ee=r(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),L=r(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),R=e(t(),1),z=n(),te=(0,R.lazy)(()=>h(()=>import(`./markdown-renderer-Bthd7hxl.js`).then(e=>({default:e.MarkdownRenderer})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])));function B({content:e,maxHeight:t=`max-h-48`}){return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`animate-pulse h-4 bg-muted rounded`}),children:(0,z.jsx)(te,{content:e,className:`text-text-secondary overflow-auto ${t}`})})}var ne={task_assignment:{label:`task`,className:`bg-primary/20 text-primary`},idle_notification:{label:`idle`,className:`bg-warning/20 text-warning`},completion:{label:`done`,className:`bg-success/20 text-success`},shutdown_request:{label:`shutdown`,className:`bg-error/20 text-error`},shutdown_approved:{label:`shutdown ✓`,className:`bg-text-3/20 text-text-3`},shutdown_response:{label:`shutdown reply`,className:`bg-text-3/20 text-text-3`},plan_approval_request:{label:`plan review`,className:`bg-primary/20 text-primary`},plan_approval_response:{label:`plan reply`,className:`bg-primary/20 text-primary`}},re=new Set([`to`,`message`,`summary`,`notify_when_idle`,`recipient`,`content`,`type`]),V=e=>typeof e==`string`?e:e==null?``:String(e);function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return typeof t.type!=`string`||!t.type?null:{type:t.type,request_id:typeof t.request_id==`string`?t.request_id:void 0,approve:typeof t.approve==`boolean`?t.approve:void 0,reason:typeof t.reason==`string`?t.reason:void 0,feedback:typeof t.feedback==`string`?t.feedback:void 0}}function ie(e){let t=e.trim();if(!t.startsWith(`{`))return null;try{return H(JSON.parse(t))}catch{return null}}function U(e){let t=V(e.to)||V(e.recipient),n=e.message??e.content,r=H(n)??ie(V(n)),i=r?``:V(n),a=V(e.type),o=r?.type||(a&&a!==`message`?a:`message`),s=V(e.summary).trim(),c=Object.entries(e).filter(([e])=>!re.has(e)).map(([e,t])=>({key:e,value:typeof t==`string`?t:JSON.stringify(t)??``}));return{to:t,summary:s||void 0,text:i,firstLine:i.split(`
3
- `).map(e=>e.trim()).find(e=>e.length>0)??``,protocol:r??void 0,kind:o,notifyWhenIdle:e.notify_when_idle===!0,extras:c}}function W(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(Array.isArray(t)){let e=V(t.find(e=>e&&typeof e==`object`&&e.type===`text`)?.text);if(!e)return null;try{t=JSON.parse(e)}catch{return null}}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(typeof n.success!=`boolean`)return null;let r=n.pin&&typeof n.pin==`object`?n.pin:null;return{ok:n.success,detail:V(n.message)||V(n.error)||void 0,peer:r&&V(r.name)||void 0,ref:r&&V(r.ref)||void 0}}function ae({kind:e}){if(e===`message`)return null;let t=ne[e];return(0,z.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] ${t?.className??`bg-panel-2 text-text-3`}`,children:t?.label??e})}function oe({name:e,input:t}){let n=U(t),r=n.summary||n.firstLine||(n.protocol?n.kind:``),a=r.length>72?`${r.slice(0,72)}…`:r;return(0,z.jsxs)(z.Fragment,{children:[e,` `,(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[(0,z.jsx)(i,{className:`size-3 inline`}),` `,n.to||`unknown`,a?` · ${a}`:``]}),n.notifyWhenIdle&&(0,z.jsx)(l,{className:`size-3 inline ml-1 text-text-3`})]})}function se({input:e}){let t=U(e);return(0,z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-text-subtle`,children:`To`}),(0,z.jsx)(`span`,{className:`font-medium text-text-primary`,children:t.to||`unknown`}),(0,z.jsx)(ae,{kind:t.kind}),t.notifyWhenIdle&&(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] bg-panel-2 text-text-3`,children:[(0,z.jsx)(l,{className:`size-3`}),` notify when idle`]})]}),!!t.text&&(0,z.jsx)(B,{content:t.text,maxHeight:`max-h-40`}),t.protocol&&(0,z.jsxs)(`div`,{className:`space-y-0.5 text-text-secondary`,children:[t.protocol.approve!=null&&(0,z.jsxs)(`p`,{children:[t.protocol.approve?`Approved`:`Rejected`,t.protocol.request_id?(0,z.jsxs)(`span`,{className:`text-text-subtle font-mono`,children:[` · `,t.protocol.request_id]}):null]}),!!t.protocol.reason&&(0,z.jsx)(`p`,{className:`text-text-subtle`,children:t.protocol.reason}),!!t.protocol.feedback&&(0,z.jsx)(`p`,{className:`text-text-subtle`,children:t.protocol.feedback})]}),t.extras.length>0&&(0,z.jsx)(`div`,{className:`space-y-0.5`,children:t.extras.map(e=>(0,z.jsxs)(`p`,{className:`text-text-subtle`,children:[(0,z.jsx)(`span`,{className:`font-mono`,children:e.key}),`: `,e.value]},e.key))})]})}function ce({output:e}){let[t,n]=(0,R.useState)(!1),r=W(e);return r?(0,z.jsxs)(`div`,{className:`border-t border-border pt-1.5 space-y-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[r.ok?(0,z.jsx)(v,{className:`size-3 text-success shrink-0`}):(0,z.jsx)(j,{className:`size-3 text-error shrink-0`}),(0,z.jsx)(`span`,{className:r.ok?`text-success`:`text-error`,children:r.ok?`Delivered`:`Not delivered`}),!!r.detail&&(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[`· `,r.detail]}),!!r.ref&&(0,z.jsxs)(`span`,{className:`text-text-3 font-mono text-[10px]`,children:[`[`,r.ref,`]`]})]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors`,children:[(0,z.jsx)(u,{className:`size-3`}),t?`Hide`:`Show`,` raw`]}),t&&(0,z.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono max-h-40 whitespace-pre-wrap break-all text-[10px]`,children:e})]}):null}var le=new Set([`.png`,`.jpg`,`.jpeg`,`.gif`,`.webp`,`.bmp`,`.avif`,`.ico`]);function ue(e){let t=e.lastIndexOf(`.`);return t===-1?!1:le.has(e.slice(t).toLowerCase())}var de=/^\[image(?: · [\d.]+(?:B|KB|MB))?\]$/;function fe(e){if(!e.startsWith(`[`))return!1;let t;try{t=JSON.parse(e)}catch{return!1}return Array.isArray(t)?t.some(e=>{let t=e;return t?.type===`text`&&typeof t.text==`string`&&de.test(t.text)}):!1}var pe=`Async agent launched successfully`;function me(e){return!!e&&e.includes(pe)}var he=`text-[var(--img-meta-label)] @max-[470px]:hidden`,ge=[`60%`,`45%`,`80%`];function _e({aspect:e,actions:t}){return(0,z.jsxs)(`div`,{className:`grid grid-cols-[132px_1fr] items-start gap-[14px] overflow-hidden rounded-lg border border-border bg-panel p-[14px] @max-[470px]:grid-cols-[64px_1fr] @max-[470px]:gap-[11px] @max-[470px]:p-[11px]`,children:[(0,z.jsx)(`div`,{className:`img-skeleton rounded-lg`,style:{aspectRatio:e}}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[9px]`,children:[(0,z.jsx)(`div`,{className:`img-skeleton h-[13px] w-2/5 rounded @max-[470px]:hidden`}),(0,z.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-[14px] gap-y-[4px] font-mono text-[11.5px] @max-[470px]:grid-cols-[1fr]`,children:[`dimensions`,`size`,`path`].map((e,t)=>(0,z.jsxs)(R.Fragment,{children:[(0,z.jsx)(`dt`,{className:he,children:e}),(0,z.jsx)(`dd`,{className:`flex items-center`,children:(0,z.jsx)(`span`,{className:`img-skeleton h-[11px] rounded`,style:{width:ge[t]}})})]},e))}),t]})]})}function ve({code:e,onRetry:t}){return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-panel px-2.5 py-2 font-mono text-[12px] text-text-2`,children:[(0,z.jsx)(x,{className:`size-3 shrink-0`}),(0,z.jsxs)(`span`,{className:`truncate`,children:[`preview unavailable`,e?` · ${e}`:``]}),(0,z.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto shrink-0 text-accent`,children:`retry`})]})}var ye=.62;function be(e,t){let n=e.w/e.h;if(n>2.4)return{variant:`band`,aspect:n,fit:`contain`};let r=Math.max(ye,n),i=t/r;return e.w<t&&e.h<i?{variant:`split`,aspect:r,fit:`native`}:{variant:`split`,aspect:r,fit:n<.62?`contain`:`cover`}}function xe(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function Se(e,t){let n=`${e.w} × ${e.h} px`;return t===`native`?`${n} · shown 1:1`:n}var G=new Map;function Ce(e){return G.get(e)}function we(e,t){G.set(e,t)}var Te=4/5,K=`text-[var(--img-meta-label)] @max-[470px]:hidden`,q=`truncate text-text @max-[470px]:text-text-2`,J=`h-[30px] @max-[470px]:h-[36px] shrink-0 rounded-[7px] px-[9px] font-mono text-[11.5px] text-text-2 bg-[var(--img-ghost)] border border-[var(--img-ghost-border)] backdrop-blur-[6px] transition-colors can-hover:hover:bg-[var(--img-ghost-hover)] can-hover:hover:border-[var(--img-ghost-hover-border)] can-hover:hover:text-text`;function Ee({filePath:e,projectName:t}){let[n,r]=(0,R.useState)(0),{blobUrl:i,blob:a,error:o,errorCode:s}=O(e,t,void 0,n),[c,l]=(0,R.useState)(()=>Ce(e)),[u,d]=(0,R.useState)(!1),[f,p]=(0,R.useState)(!1),m=D(e=>e.open),{openTab:h}=_(b(e=>({openTab:e.openTab}))),v=g(e);(0,R.useEffect)(()=>{if(!f)return;let e=setTimeout(()=>p(!1),1200);return()=>clearTimeout(e)},[f]);let y=t=>{let n={w:t.naturalWidth,h:t.naturalHeight};if(!n.w||!n.h)return d(!0);we(e,n),l(n)},x=()=>{d(!1),r(e=>e+1)};if(o||u)return(0,z.jsx)(`div`,{className:`border-t border-border pt-1.5`,children:(0,z.jsx)(ve,{code:u?void 0:s??void 0,onRetry:x})});let S=c?be(c,132):null,C=S?.aspect??Te,w=(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-[6px]`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:E,className:J,children:[(0,z.jsx)(`span`,{className:`@max-[470px]:hidden`,children:`open in editor`}),(0,z.jsx)(`span`,{className:`hidden @max-[470px]:inline`,children:`open`})]}),(0,z.jsx)(`button`,{type:`button`,onClick:j,className:J,children:f?`copied`:`copy path`}),(0,z.jsx)(`button`,{type:`button`,onClick:M,className:J,children:`full size`})]});function E(){t&&h({type:`editor`,title:v,metadata:{filePath:e,projectName:t},projectId:t,closable:!0})}function j(){T(e).then(()=>p(!0))}function M(e){i&&m(i,v,k(e.currentTarget))}if(!i||!S||!c)return(0,z.jsxs)(`div`,{className:`@container border-t border-border pt-1.5`,children:[i&&(0,z.jsx)(`img`,{src:i,alt:``,className:`hidden`,onLoad:e=>y(e.currentTarget),onError:()=>d(!0)}),(0,z.jsx)(_e,{aspect:C,actions:w})]});let N=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:K,children:`dimensions`}),(0,z.jsx)(`dd`,{className:q,children:Se(c,S.fit)}),a&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`dt`,{className:K,children:`size`}),(0,z.jsxs)(`dd`,{className:q,children:[xe(a.size),a.type?` · ${a.type}`:``]})]}),(0,z.jsx)(`dt`,{className:K,children:`path`}),(0,z.jsx)(`dd`,{dir:`rtl`,className:`${q} text-left`,children:e})]}),P=(0,z.jsx)(`img`,{src:i,alt:v,[A]:``,onLoad:e=>y(e.currentTarget),onError:()=>d(!0),className:S.fit===`cover`?`size-full object-cover`:S.fit===`contain`?`size-full object-contain`:`max-h-full max-w-full`});return(0,z.jsx)(`div`,{className:`@container border-t border-border pt-1.5`,children:(0,z.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-border p-[14px] @max-[470px]:p-[11px]`,children:[(0,z.jsx)(`img`,{"aria-hidden":`true`,alt:``,src:i,className:`absolute inset-0 size-full object-cover`,style:{filter:`var(--img-backdrop)`,transform:`scale(1.3)`}}),(0,z.jsx)(`div`,{className:`absolute inset-0`,style:{background:`var(--img-veil)`}}),S.variant===`band`?(0,z.jsxs)(`div`,{className:`relative grid gap-[11px]`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:M,title:`Open ${v}`,className:`img-checkerboard w-full cursor-zoom-in overflow-hidden rounded-lg border border-[var(--img-plate-border)]`,style:{aspectRatio:S.aspect},children:P}),(0,z.jsx)(`dl`,{className:`grid grid-cols-[auto_auto_1fr] gap-x-[18px] font-mono text-[11.5px] [&_dt]:hidden`,children:N}),w]}):(0,z.jsxs)(`div`,{className:`relative grid grid-cols-[132px_1fr] items-start gap-[14px] @max-[470px]:grid-cols-[64px_1fr] @max-[470px]:gap-[11px]`,children:[(0,z.jsx)(`button`,{type:`button`,onClick:M,title:`Open ${v}`,className:`cursor-zoom-in overflow-hidden rounded-lg border border-[var(--img-plate-border)] bg-[var(--img-plate)] shadow-[var(--img-plate-shadow)] ${S.fit===`cover`?``:`img-checkerboard flex items-center justify-center`}`,style:{aspectRatio:S.aspect},children:P}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-[9px]`,children:[(0,z.jsx)(`p`,{className:`truncate text-[13px] font-semibold text-text @max-[470px]:hidden`,children:v}),(0,z.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-[14px] gap-y-[4px] font-mono text-[11.5px] @max-[470px]:grid-cols-[1fr]`,children:N}),w]})]})]})})}function Y(e,t){if(e!==`Agent`&&e!==`Task`)return null;let n=t.name;return typeof n==`string`&&n.trim()?n.trim():null}function De(e,t,n=!1){if(t&&(e===`Bash`||e===`PowerShell`))return{Icon:C,cls:`bg-error/15 text-error`};if(n)return{Icon:S,cls:`bg-accent-2/15 text-accent-2`};switch(e){case`Read`:case`Glob`:case`LS`:return{Icon:F,cls:`bg-accent-wash text-primary`};case`Grep`:case`Search`:case`WebSearch`:case`ToolSearch`:return{Icon:E,cls:`bg-accent-wash text-primary`};case`WebFetch`:case`Fetch`:return{Icon:w,cls:`bg-info/15 text-info`};case`Edit`:case`MultiEdit`:case`NotebookEdit`:return{Icon:N,cls:`bg-accent-2/15 text-accent-2`};case`Write`:return{Icon:P,cls:`bg-success/15 text-success`};case`Bash`:case`PowerShell`:return{Icon:C,cls:`bg-panel-2 text-text-2`};case`TodoWrite`:return{Icon:ee,cls:`bg-warning/15 text-warning`};case`Task`:case`Agent`:return{Icon:o,cls:`bg-accent-wash text-primary`};case`SendMessage`:return{Icon:m,cls:`bg-info/15 text-info`};case`AskUserQuestion`:return{Icon:a,cls:`bg-accent-wash text-primary`};case`ExitPlanMode`:return{Icon:M,cls:`bg-accent-wash text-primary`};case`Skill`:return{Icon:f,cls:`bg-accent-2/15 text-accent-2`};case`ImageGen`:return{Icon:I,cls:`bg-accent-2/15 text-accent-2`};default:return{Icon:u,cls:`bg-panel-2 text-text-2`}}}function Oe(e){let t=e.type===`approval_request`;return{toolName:e.type===`tool_use`?e.tool:t?e.tool??`Tool`:`Tool`,input:e.type===`tool_use`?e.input:t?e.input??{}:{}}}var ke=new Set([`Read`,`ImageGen`]);function X(e){if(e.type!==`tool_use`||!ke.has(e.tool))return null;let t=e.input?.file_path;return typeof t!=`string`||!/^(\/|[A-Za-z]:[/\\])/.test(t)?null:ue(t)?t:null}function Z({tool:e,result:t,completed:n,projectName:r,bashPartialOutput:i}){let[a,o]=(0,R.useState)(()=>{let n=(e.type,e.tool),r=t?.type===`tool_result`&&!!t.isError;return(n===`Edit`||n===`MultiEdit`)&&!r?!0:!!X(e)});if(e.type===`error`)return(0,z.jsxs)(`div`,{className:`flex items-center gap-2 rounded bg-error/10 border border-error/20 px-2 py-1.5 text-xs text-error`,children:[(0,z.jsx)(x,{className:`size-3`}),(0,z.jsx)(`span`,{children:e.message})]});let{toolName:l,input:u}=Oe(e),d=t?.type===`tool_result`,f=d&&!!t.isError,m=l===`AskUserQuestion`&&!!u?.answers,h=e.type===`approval_request`&&e.approved!=null,g=(l===`Agent`||l===`Task`)&&e.type===`tool_use`,_=g?e.children:void 0,y=_&&_.length>0,b=g&&e.type===`tool_use`?e.bgStatus:void 0,S=g&&(b!=null||d&&!f&&me(String(t.output??``)))&&b==null,C=b===`failed`||b===`stopped`,w=S?!1:d||m||h||n,T=[`Edit`,`MultiEdit`,`Write`,`NotebookEdit`].includes(l),E=X(e),D=d&&fe(String(t.output??``)),O=!!E,k=e.type===`tool_use`?e.toolUseId:void 0,A=(l===`Bash`||l===`PowerShell`)&&!d&&k?i?.current?.get(k):void 0,M=!!A;(0,R.useEffect)(()=>{M&&!a&&o(!0)},[M]);let N=(0,R.useRef)(!1);(0,R.useEffect)(()=>{f&&(l===`Edit`||l===`MultiEdit`)&&!N.current&&(N.current=!0,o(!1))},[f,l]);let{Icon:P,cls:F}=De(l,f,!!Y(l,u)),I=l===`AskUserQuestion`||l===`ExitPlanMode`||g;return(0,z.jsxs)(`div`,{"data-tool-ref":k,className:`rounded-[11px] border overflow-hidden text-xs bg-panel ${I?`border-accent-wash-border`:`border-border`}`,children:[(0,z.jsxs)(`button`,{onClick:()=>o(!a),className:`flex items-center gap-2.5 px-2.5 py-2 w-full text-left hover:bg-panel-2/40 transition-colors min-w-0`,children:[(0,z.jsx)(`span`,{className:`inline-flex items-center justify-center size-6 rounded-[7px] shrink-0 ${F}`,children:(0,z.jsx)(P,{className:`size-3.5`})}),(0,z.jsx)(`span`,{className:`truncate text-text font-medium`,children:(0,z.jsx)(Ae,{name:l,input:u})}),(0,z.jsxs)(`span`,{className:`ml-auto flex items-center gap-2 shrink-0`,children:[M&&(0,z.jsxs)(`span`,{className:`text-[10px] text-warning`,children:[A.lineCount,` line`,A.lineCount===1?``:`s`,` streaming…`]}),y&&!M&&(0,z.jsxs)(`span`,{className:`text-[10px] text-text-3 font-mono`,children:[_.length,` steps`]}),S&&(0,z.jsx)(`span`,{className:`text-[10px] text-primary`,children:`running…`}),f||C?(0,z.jsx)(j,{className:`size-3.5 text-error`}):w?(0,z.jsx)(v,{className:`size-3.5 text-success`}):(0,z.jsx)(p,{className:`size-3.5 text-primary animate-spin`}),a?(0,z.jsx)(s,{className:`size-3 text-text-3`}):(0,z.jsx)(c,{className:`size-3 text-text-3`})]})]}),a&&(0,z.jsxs)(`div`,{className:`px-2 pb-2 space-y-1.5 select-text`,children:[(e.type===`tool_use`||e.type===`approval_request`)&&(0,z.jsx)(je,{name:l,input:u,projectName:r,toolUseId:k}),A&&(0,z.jsx)(Le,{content:A.content,lineCount:A.lineCount}),y&&(0,z.jsx)(Ie,{events:_,projectName:r}),E&&(0,z.jsx)(Ee,{filePath:E,projectName:r??``}),d&&!(T&&!f)&&!(D&&!f)&&!(O&&!f)&&(0,z.jsx)(Pe,{toolName:l,output:t.output})]})]})}function Ae({name:e,input:t}){let n=e=>String(e??``);switch(e){case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:return(0,z.jsxs)(z.Fragment,{children:[e,` `,(0,z.jsx)(`span`,{className:`text-text-subtle`,children:g(n(t.file_path))})]});case`Bash`:case`PowerShell`:{let r=t.description?n(t.description):n(t.command);return(0,z.jsxs)(z.Fragment,{children:[e,` `,(0,z.jsx)(`span`,{className:`text-text-subtle${t.description?``:` font-mono`}`,children:Q(r,60)})]})}case`Glob`:return(0,z.jsxs)(z.Fragment,{children:[e,` `,(0,z.jsx)(`span`,{className:`font-mono text-text-subtle`,children:n(t.pattern)})]});case`Grep`:return(0,z.jsxs)(z.Fragment,{children:[e,` `,(0,z.jsx)(`span`,{className:`font-mono text-text-subtle`,children:Q(n(t.pattern),40)})]});case`WebSearch`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E,{className:`size-3 inline`}),` `,e,` `,(0,z.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.query),50)})]});case`WebFetch`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(w,{className:`size-3 inline`}),` `,e,` `,(0,z.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.url),50)})]});case`ToolSearch`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E,{className:`size-3 inline`}),` `,e,` `,(0,z.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.query),50)})]});case`ImageGen`:{let e=(n(t.prompt).split(`
4
- `).find(e=>e.trim())??``)||g(n(t.file_path));return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(I,{className:`size-3 inline`}),` Image`,(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[` `,Q(e,50)]})]})}case`Agent`:case`Task`:{let r=Y(e,t),i=Q(n(t.description||t.prompt),r?44:60);return(0,z.jsxs)(z.Fragment,{children:[!r&&(0,z.jsx)(o,{className:`size-3 inline`}),` `,e,` `,r&&(0,z.jsx)(`span`,{className:`text-text-primary font-medium`,children:r}),(0,z.jsx)(`span`,{className:`text-text-subtle`,children:r?` · ${i}`:i})]})}case`SendMessage`:return(0,z.jsx)(oe,{name:e,input:t});case`TodoWrite`:{let n=Array.isArray(t.todos)?t.todos:[],r=n.filter(e=>e.status===`completed`).length;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(L,{className:`size-3 inline`}),` `,e,` `,(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[r,`/`,n.length,` done`]})]})}case`AskUserQuestion`:{let n=Array.isArray(t.questions)?t.questions:[],r=!!t.answers;return(0,z.jsxs)(z.Fragment,{children:[e,` `,(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[n.length,` question`,n.length===1?``:`s`,r?` ✓`:``]})]})}case`ScheduleWakeup`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(l,{className:`size-3 inline`}),` `,e,` `,(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[`in `,$(Number(t.delaySeconds)),t.reason?` — ${Q(n(t.reason),50)}`:``]})]});case`TaskCreate`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(L,{className:`size-3 inline`}),` `,e,` `,(0,z.jsx)(`span`,{className:`text-text-subtle`,children:Q(n(t.subject),60)})]});case`TaskUpdate`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(L,{className:`size-3 inline`}),` `,e,` `,(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[`#`,n(t.taskId),` → `,n(t.status)]})]});case`TaskStop`:return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(L,{className:`size-3 inline`}),` `,e,` `,(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[`#`,n(t.taskId),` stopped`]})]});default:return(0,z.jsx)(z.Fragment,{children:e})}}function je({name:e,input:t,projectName:n,toolUseId:r}){let i=e=>String(e??``),{openTab:a}=_(b(e=>({openTab:e.openTab}))),o=e=>{n&&a({type:`editor`,title:g(e),metadata:{filePath:e,projectName:n},projectId:n,closable:!0})},s=(e,t,r)=>{a({type:`git-diff`,title:`Diff ${g(e)}`,metadata:{filePath:e,projectName:n,original:t,modified:r},projectId:n??null,closable:!0})};switch(e){case`Bash`:case`PowerShell`:return(0,z.jsxs)(`div`,{className:`space-y-1`,children:[!!t.description&&(0,z.jsx)(`p`,{className:`text-text-subtle italic`,children:i(t.description)}),(0,z.jsx)(`pre`,{className:`font-mono text-text-secondary overflow-x-auto whitespace-pre-wrap break-all`,children:i(t.command)})]});case`Read`:case`Write`:case`Edit`:case`MultiEdit`:case`NotebookEdit`:{let n=i(t.notebook_path||t.file_path),a=e===`Edit`&&(!!t.old_string||!!t.new_string),c=e=>r?`${r}-${e}`:void 0;return(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`font-mono text-text-secondary break-all hover:text-primary hover:underline text-left flex items-center gap-1 min-w-0`,onClick:()=>o(n),title:`Open file in editor`,children:[(0,z.jsx)(y,{className:`size-3 shrink-0`}),n]}),a&&(0,z.jsxs)(`button`,{type:`button`,className:`text-text-subtle hover:text-primary hover:underline flex items-center gap-1 shrink-0 whitespace-nowrap`,onClick:()=>s(n,i(t.old_string),i(t.new_string)),title:`View diff in new tab`,children:[(0,z.jsx)(d,{className:`size-3 shrink-0`}),`View Diff`]})]}),a&&(0,z.jsx)(`div`,{"data-edit-ref":c(0),children:(0,z.jsx)(Be,{oldStr:i(t.old_string),newStr:i(t.new_string),filePath:n})}),e===`MultiEdit`&&Array.isArray(t.edits)&&(0,z.jsx)(`div`,{className:`space-y-1.5`,children:t.edits.map((e,t)=>(0,z.jsxs)(`div`,{"data-edit-ref":c(t),className:`space-y-0.5`,children:[(0,z.jsxs)(`p`,{className:`text-text-subtle text-[10px]`,children:[`Edit `,t+1]}),(0,z.jsx)(Be,{oldStr:i(e.old_string),newStr:i(e.new_string),filePath:n})]},t))}),e===`Write`&&!!t.content&&(0,z.jsx)(`pre`,{"data-edit-ref":c(0),className:`font-mono text-text-subtle overflow-x-auto max-h-32 whitespace-pre-wrap`,children:Q(i(t.content),300)})]})}case`Glob`:return(0,z.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[i(t.pattern),t.path?` in ${i(t.path)}`:``]});case`Grep`:return(0,z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,z.jsxs)(`p`,{className:`font-mono text-text-secondary`,children:[`/`,i(t.pattern),`/`]}),!!t.path&&(0,z.jsxs)(`p`,{className:`text-text-subtle`,children:[`in `,i(t.path)]})]});case`TodoWrite`:return(0,z.jsx)(Ne,{todos:t.todos??[]});case`Agent`:case`Task`:{let n=Y(e,t);return(0,z.jsxs)(`div`,{className:`space-y-1`,children:[!!n&&(0,z.jsxs)(`p`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-text-subtle`,children:`Name`}),(0,z.jsx)(`span`,{className:`font-medium text-text-primary`,children:n}),(0,z.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] bg-accent-2/15 text-accent-2`,children:`teammate`}),t.isolation===`worktree`&&(0,z.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] bg-panel-2 text-text-3`,children:`worktree`})]}),!!t.description&&(0,z.jsx)(`p`,{className:`text-text-secondary font-medium`,children:i(t.description)}),!!t.subagent_type&&(0,z.jsxs)(`p`,{className:`text-text-subtle`,children:[`Type: `,i(t.subagent_type)]}),!!t.prompt&&(0,z.jsx)(B,{content:i(t.prompt),maxHeight:`max-h-48`})]})}case`SendMessage`:return(0,z.jsx)(se,{input:t});case`ToolSearch`:return(0,z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,z.jsx)(`p`,{className:`font-mono text-text-secondary`,children:i(t.query)}),!!t.max_results&&(0,z.jsxs)(`p`,{className:`text-text-subtle`,children:[`Max results: `,i(t.max_results)]})]});case`WebFetch`:return(0,z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,z.jsxs)(`a`,{href:i(t.url),target:`_blank`,rel:`noopener noreferrer`,className:`font-mono text-primary hover:underline break-all flex items-center gap-1`,children:[(0,z.jsx)(w,{className:`size-3 shrink-0`}),i(t.url)]}),!!t.prompt&&(0,z.jsx)(`p`,{className:`text-text-subtle`,children:Q(i(t.prompt),100)})]});case`AskUserQuestion`:{let e=t.questions??[],n=t.answers??{};return(0,z.jsx)(`div`,{className:`space-y-2`,children:e.map((e,t)=>(0,z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,z.jsxs)(`p`,{className:`text-text-primary font-medium`,children:[e.header?`${e.header}: `:``,e.question]}),(0,z.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map((t,r)=>(0,z.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-xs border ${(n[e.question]??``).split(`, `).includes(t.label)?`border-primary bg-primary/20 text-text-primary`:`border-border text-text-subtle`}`,children:t.label},r))}),n[e.question]&&(0,z.jsxs)(`p`,{className:`text-foreground text-xs`,children:[`Answer: `,n[e.question]]})]},t))})}case`ScheduleWakeup`:{let e=Number(t.delaySeconds)||0;return(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsxs)(`p`,{className:`text-text-secondary`,children:[(0,z.jsx)(l,{className:`size-3 inline mr-1`}),`Wake in `,(0,z.jsx)(`span`,{className:`font-medium text-text-primary`,children:$(e)}),(0,z.jsxs)(`span`,{className:`text-text-subtle`,children:[` (`,e,`s)`]})]}),!!t.reason&&(0,z.jsx)(`p`,{className:`text-text-secondary italic`,children:i(t.reason)}),!!t.prompt&&(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`p`,{className:`text-text-subtle text-[10px] mb-0.5`,children:`Prompt on wake`}),(0,z.jsx)(B,{content:i(t.prompt),maxHeight:`max-h-48`})]})]})}case`TaskCreate`:return(0,z.jsxs)(`div`,{className:`space-y-1`,children:[(0,z.jsx)(`p`,{className:`text-text-primary font-medium`,children:i(t.subject)}),!!t.description&&(0,z.jsx)(`p`,{className:`text-text-subtle`,children:i(t.description)}),!!t.activeForm&&(0,z.jsx)(`p`,{className:`text-text-subtle italic`,children:i(t.activeForm)})]});case`TaskUpdate`:return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`span`,{className:`font-mono text-text-secondary`,children:[`#`,i(t.taskId)]}),(0,z.jsx)(Me,{status:i(t.status)})]});case`TaskStop`:return(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`span`,{className:`font-mono text-text-secondary`,children:[`#`,i(t.taskId)]}),(0,z.jsx)(Me,{status:`stopped`})]});case`ImageGen`:return(0,z.jsxs)(`div`,{className:`space-y-1`,children:[!!t.prompt&&(0,z.jsx)(`p`,{className:`text-text-secondary whitespace-pre-wrap`,children:i(t.prompt)}),t.transparentBackground===!0&&(0,z.jsx)(`p`,{className:`text-text-subtle`,children:`Transparent background`})]});default:return(0,z.jsx)(`pre`,{className:`overflow-x-auto text-text-secondary font-mono whitespace-pre-wrap break-all`,children:JSON.stringify(t,null,2)})}}function Me({status:e}){return(0,z.jsx)(`span`,{className:`inline-block rounded px-1.5 py-0.5 text-[10px] border ${e===`completed`?`text-success border-success/30 bg-success/10`:e===`in_progress`?`text-warning border-warning/30 bg-warning/10`:`text-text-subtle border-border bg-surface`}`,children:e})}function Ne({todos:e}){return(0,z.jsx)(`div`,{className:`space-y-0.5`,children:e.map((e,t)=>(0,z.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,z.jsx)(`span`,{className:`shrink-0 mt-0.5 ${e.status===`completed`?`text-success`:e.status===`in_progress`?`text-warning`:`text-text-subtle`}`,children:e.status===`completed`?`✓`:e.status===`in_progress`?`▶`:`○`}),(0,z.jsx)(`span`,{className:e.status===`completed`?`line-through text-text-subtle`:`text-text-secondary`,children:e.content})]},t))})}function Pe({toolName:e,output:t}){let[n,r]=(0,R.useState)(!1),i=(0,R.useMemo)(()=>{if(e!==`Agent`&&e!==`Task`)return null;try{let e=JSON.parse(t);if(Array.isArray(e)){let t=e.filter(e=>e.type===`text`&&e.text).map(e=>e.text).join(`
5
-
6
- `);if(t)return t}if(typeof e==`string`)return e}catch{if(t&&!t.startsWith(`[{`))return t}return null},[e,t]);return e===`SendMessage`&&W(t)?(0,z.jsx)(ce,{output:t}):i?(0,z.jsxs)(`div`,{className:`border-t border-border pt-1.5 space-y-1`,children:[(0,z.jsx)(B,{content:i,maxHeight:`max-h-60`}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(!n),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors`,children:[(0,z.jsx)(u,{className:`size-3`}),n?`Hide`:`Show`,` raw`]}),n&&(0,z.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono max-h-40 whitespace-pre-wrap break-all text-[10px]`,children:t})]}):(0,z.jsx)(Fe,{output:t})}function Fe({output:e}){let t=e.split(`
7
- `).length,n=t>3||e.length>200,[r,i]=(0,R.useState)(n);return(0,z.jsxs)(`div`,{className:`border-t border-border pt-1.5`,children:[n&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:`flex items-center gap-1 text-[10px] text-text-subtle hover:text-text-secondary transition-colors mb-1`,children:[r?(0,z.jsx)(c,{className:`size-3`}):(0,z.jsx)(s,{className:`size-3`}),`Output (`,t,` lines)`]}),(0,z.jsx)(`pre`,{className:`overflow-x-auto text-text-subtle font-mono whitespace-pre-wrap break-all ${r?`max-h-16 overflow-hidden`:`max-h-60`}`,children:e})]})}function Ie({events:e,projectName:t,className:n}){let r=[],i=``;for(let t of e)if(t.type===`text`)i+=t.content;else if(t.type===`tool_use`)i&&=(r.push({kind:`text`,content:i}),``),r.push({kind:`tool`,tool:t});else if(t.type===`tool_result`){let e=t.toolUseId,n=e?r.find(t=>t.kind===`tool`&&t.tool.type===`tool_use`&&t.tool.toolUseId===e&&!t.result):r.findLast(e=>e.kind===`tool`&&!e.result);n&&(n.result=t)}i&&r.push({kind:`text`,content:i});let a=(0,R.useRef)(null),o=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{a.current&&!o.current&&(a.current.scrollTop=a.current.scrollHeight)},[r.length]),(0,z.jsx)(`div`,{ref:a,onScroll:e=>{let t=e.currentTarget;o.current=t.scrollTop+t.clientHeight<t.scrollHeight-20},className:n??`border-l-2 border-accent/20 pl-2 space-y-1 mt-1 max-h-64 md:max-h-96 overflow-y-auto`,children:r.map((e,n)=>e.kind===`text`?(0,z.jsx)(`div`,{className:`text-text-secondary text-[11px]`,children:(0,z.jsx)(B,{content:e.content,maxHeight:`max-h-24`})},`st-${n}`):(0,z.jsx)(Z,{tool:e.tool,result:e.result,completed:!!e.result,projectName:t},`sc-${n}`))})}function Le({content:e,lineCount:t}){let n=(0,R.useRef)(null),r=(0,R.useRef)(!1);return(0,R.useEffect)(()=>{n.current&&!r.current&&(n.current.scrollTop=n.current.scrollHeight)},[e]),(0,z.jsxs)(`div`,{className:`border-t border-border pt-1.5`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-warning mb-1`,children:[(0,z.jsx)(p,{className:`size-3 animate-spin`}),(0,z.jsxs)(`span`,{children:[`Output (`,t,` line`,t===1?``:`s`,`, streaming...)`]})]}),(0,z.jsx)(`pre`,{ref:n,onScroll:e=>{let t=e.currentTarget;r.current=t.scrollTop+t.clientHeight<t.scrollHeight-20},className:`overflow-x-auto overflow-y-auto max-h-60 text-text-subtle font-mono whitespace-pre-wrap break-all text-[11px]`,children:e.split(`
8
- `).slice(-200).join(`
9
- `)})]})}var Re=h(()=>import(`./edit-diff-preview-xdDQvPhs.js`),__vite__mapDeps([48,2,4,49])),ze=(0,R.lazy)(()=>Re);function Be(e){return(0,z.jsx)(R.Suspense,{fallback:(0,z.jsx)(`div`,{className:`animate-pulse h-8 bg-muted rounded`}),children:(0,z.jsx)(ze,{...e})})}function Q(e,t=50){return e?e.length>t?e.slice(0,t)+`…`:e:``}function $(e){if(!Number.isFinite(e)||e<=0)return`0s`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=Math.round(e%60),i=[];return t&&i.push(`${t}h`),n&&i.push(`${n}m`),(r||i.length===0)&&i.push(`${r}s`),i.join(` `)}export{M as a,L as i,Z as n,j as o,ne as r,Ie as t};