@cuongtran001/kanna 1.83.0 → 1.83.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 (79) hide show
  1. package/dist/client/assets/{BoardsPage-B47z4IUS.js → BoardsPage-mm_dy-6I.js} +1 -1
  2. package/dist/client/assets/{BoardsRoutePage-B9V-5ps8.js → BoardsRoutePage-B7dJA_QL.js} +1 -1
  3. package/dist/client/assets/{ChatPage-DX0B9y32.js → ChatPage-Bw4peAkb.js} +3 -3
  4. package/dist/client/assets/{CronJobRow-Czmwve8c.js → CronJobRow-DKW6LnKe.js} +1 -1
  5. package/dist/client/assets/{CronJobsPage-CwlJzDdC.js → CronJobsPage-CBxttYFH.js} +1 -1
  6. package/dist/client/assets/{CronRunMessage-CWGg7z7P.js → CronRunMessage-B4x7mzzh.js} +1 -1
  7. package/dist/client/assets/{FilePreviewSheet-CSTHZ0r-.js → FilePreviewSheet-iaBNZ_R0.js} +1 -1
  8. package/dist/client/assets/{FlowSurface-BPL2XTsf.js → FlowSurface-B3kKtCHA.js} +1 -1
  9. package/dist/client/assets/{GenUIBlock-BREhbsjV.js → GenUIBlock-CMM23p8L.js} +2 -2
  10. package/dist/client/assets/{InboxPage-Cz9LwqUa.js → InboxPage-C_QKGmlx.js} +1 -1
  11. package/dist/client/assets/{KannaSocketProvider-Qy4JOiDr.js → KannaSocketProvider-Clv949La.js} +1 -1
  12. package/dist/client/assets/{LocalProjectsPage-CnlkL990.js → LocalProjectsPage-BLF1dYUW.js} +1 -1
  13. package/dist/client/assets/{SettingsPage-BF9zHwoY.js → SettingsPage-CITPPDfV.js} +1 -1
  14. package/dist/client/assets/{StackBoardsRoutePage-DQTwVdgd.js → StackBoardsRoutePage-BX-fo655.js} +1 -1
  15. package/dist/client/assets/{ToolCallMessage-BRV-hiN2.js → ToolCallMessage-BbLzqXn7.js} +1 -1
  16. package/dist/client/assets/{VChartSurface-BMzsVUBZ.js → VChartSurface-D9jlaiQA.js} +1 -1
  17. package/dist/client/assets/{WebhooksPage-DqSM0Ldu.js → WebhooksPage-DGi5OTMt.js} +1 -1
  18. package/dist/client/assets/{WorkflowsPage-D0AHM-Wb.js → WorkflowsPage-ndxOqUWo.js} +1 -1
  19. package/dist/client/assets/{WorkflowsSection-CADF_Bzd.js → WorkflowsSection-DgbttKnk.js} +1 -1
  20. package/dist/client/assets/{appSettingsStore-CRg6ywgC.js → appSettingsStore-CDBkjKuH.js} +1 -1
  21. package/dist/client/assets/{arrow-left-B1xpxyAz.js → arrow-left-DOANYNxC.js} +1 -1
  22. package/dist/client/assets/{chart-renderer-rxKOguR8.js → chart-renderer-Cw-dI71U.js} +1 -1
  23. package/dist/client/assets/{chatSounds-B9Ivu374.js → chatSounds-Cjf1Ow1m.js} +1 -1
  24. package/dist/client/assets/chevron-down-Coo9PgPJ.js +1 -0
  25. package/dist/client/assets/chevron-left-n1tLJKrp.js +1 -0
  26. package/dist/client/assets/{clipboard.adapter-B_fp79JP.js → clipboard.adapter-BCxT7Qli.js} +1 -1
  27. package/dist/client/assets/{columnStyle-BIq7Yfnj.js → columnStyle-aXeR3SrA.js} +1 -1
  28. package/dist/client/assets/{contextWindow-Dij7VexD.js → contextWindow-I-trSDu4.js} +1 -1
  29. package/dist/client/assets/{copyFeedbackStore-BVqIZyJA.js → copyFeedbackStore-BW6Vjufv.js} +1 -1
  30. package/dist/client/assets/{createScopedStore-SnvtxVfu.js → createScopedStore-D1trFyJw.js} +1 -1
  31. package/dist/client/assets/{cronJobsStore-abUqA7Tv.js → cronJobsStore-CndqKrjB.js} +1 -1
  32. package/dist/client/assets/{ellipsis-2QrMzUkm.js → ellipsis-CFHwUFtG.js} +1 -1
  33. package/dist/client/assets/{external-link-DOOcesX8.js → external-link-9xEpmM2n.js} +1 -1
  34. package/dist/client/assets/{flow-kinds-DSOaexAL.js → flow-kinds-DnUaQXgl.js} +1 -1
  35. package/dist/client/assets/{folder-Bwd3sLen.js → folder-Bg7BAFNU.js} +1 -1
  36. package/dist/client/assets/{genui-0tseVHei.js → genui-jdDJe0VI.js} +1 -1
  37. package/dist/client/assets/{globe-BzQDkdZX.js → globe-CeniwLw3.js} +1 -1
  38. package/dist/client/assets/{host-C3kMJzEk.js → host-BNDj5_aa.js} +1 -1
  39. package/dist/client/assets/{inbox-OcWbx5dq.js → inbox-C62UubNn.js} +1 -1
  40. package/dist/client/assets/{inboxStore-BZsasEeB.js → inboxStore-Bks9mpiK.js} +1 -1
  41. package/dist/client/assets/{index-CbcQLFbg.js → index-Dp3JEZQ3.js} +3 -3
  42. package/dist/client/assets/{info-BCSQhrG7.js → info-BMdKmB36.js} +1 -1
  43. package/dist/client/assets/{input-ExC-3rHy.js → input-CS1DBeNV.js} +1 -1
  44. package/dist/client/assets/{lexicalToReact-Ce76aPsW.js → lexicalToReact-CkI42EHr.js} +3 -3
  45. package/dist/client/assets/{log-DIu9xkUN.js → log-3sQ-5rrS.js} +1 -1
  46. package/dist/client/assets/{monitor-BP4FTtXg.js → monitor-_V-BjQpD.js} +1 -1
  47. package/dist/client/assets/{pencil-47Ckkow-.js → pencil-BTeN1rO_.js} +1 -1
  48. package/dist/client/assets/{pendingActionsStore-DG0IogaL.js → pendingActionsStore-C9wopHr4.js} +1 -1
  49. package/dist/client/assets/{play-B0G1X5os.js → play-C_g7W9ao.js} +1 -1
  50. package/dist/client/assets/{plus-B-KGULQg.js → plus-D0uUa5kJ.js} +1 -1
  51. package/dist/client/assets/{popover-H1bnfjIL.js → popover-CA332KD1.js} +1 -1
  52. package/dist/client/assets/runDetached-BBRv1zoc.js +1 -0
  53. package/dist/client/assets/{search-D4Ge6Hht.js → search-48C1GM_8.js} +1 -1
  54. package/dist/client/assets/{searchable-select-BE62ykWr.js → searchable-select-C2LG0o1C.js} +1 -1
  55. package/dist/client/assets/{segmented-control-CwOQtips.js → segmented-control-DbmDSdKy.js} +1 -1
  56. package/dist/client/assets/{select-Dee_-sbr.js → select-BKHnGLKS.js} +1 -1
  57. package/dist/client/assets/{settings-header-button-BCTE-ScU.js → settings-header-button-D4w0LZ-R.js} +1 -1
  58. package/dist/client/assets/{sidebarPendingActions-BrcxtPLq.js → sidebarPendingActions-BQ059yIu.js} +1 -1
  59. package/dist/client/assets/{square-pen-DVDO1c01.js → square-pen-C5BA26g7.js} +1 -1
  60. package/dist/client/assets/{state-mark-Cpr4kZpE.js → state-mark-DNAt8L4c.js} +1 -1
  61. package/dist/client/assets/{terminal-CJmWAR__.js → terminal-DDMsYlkg.js} +1 -1
  62. package/dist/client/assets/{timer.adapter-BX7oyt8G.js → timer.adapter-Di4tkt37.js} +1 -1
  63. package/dist/client/assets/{tools-CdXgLXQy.js → tools-CeacgJBu.js} +1 -1
  64. package/dist/client/assets/{triangle-alert-La2uFCiR.js → triangle-alert-B6T8mkaG.js} +1 -1
  65. package/dist/client/assets/{useAppGlobalState-NukFv4HT.js → useAppGlobalState-C6_aikPC.js} +1 -1
  66. package/dist/client/assets/{useKannaState-BUbXZ9PG.js → useKannaState-BESpYf4x.js} +1 -1
  67. package/dist/client/assets/{useTheme-ee-m4Hcs.js → useTheme-V_0ZRiiP.js} +1 -1
  68. package/dist/client/assets/{webhook-CQwbFakw.js → webhook-_4KNokhW.js} +1 -1
  69. package/dist/client/assets/{webhookCommands-BxPTN2Od.js → webhookCommands-ClSc7rRQ.js} +1 -1
  70. package/dist/client/assets/{webhooksStore-26fMZM_X.js → webhooksStore-DmkDHteX.js} +1 -1
  71. package/dist/client/index.html +41 -41
  72. package/package.json +4 -3
  73. package/src/server/event-store-snapshot.test.ts +7 -0
  74. package/src/server/event-store-snapshot.ts +2 -0
  75. package/src/server/event-store.test.ts +37 -0
  76. package/src/server/remote-mcp/remote-mcp-tools.test.ts +8 -5
  77. package/dist/client/assets/chevron-down-Bj1p9afs.js +0 -1
  78. package/dist/client/assets/chevron-left-rwNvioId.js +0 -1
  79. package/dist/client/assets/runDetached-CXTNs9Tz.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{d as r,f as i}from"./log-DIu9xkUN.js";import{a,c as o,n as s,r as c,t as l}from"./pendingActionsStore-DG0IogaL.js";import{n as u,r as d,t as f}from"./clipboard.adapter-B_fp79JP.js";import{t as p}from"./pencil-47Ckkow-.js";import{t as m}from"./plus-B-KGULQg.js";import{n as h}from"./search-D4Ge6Hht.js";import{c as g,d as _,f as v,g as y,h as b,l as x,o as S,p as C,s as w,t as T,u as E}from"./webhooksStore-26fMZM_X.js";import{t as D}from"./webhook-CQwbFakw.js";import{a as O,i as k,n as A,o as j,r as M,u as N}from"./timer.adapter-BX7oyt8G.js";import{t as ee}from"./segmented-control-CwOQtips.js";import{t as P}from"./createScopedStore-SnvtxVfu.js";import{t as F}from"./input-ExC-3rHy.js";import{n as I}from"./shellChrome-bmmKlcOk.js";import{m as L,n as R,p as te,u as z}from"./KannaSocketProvider-Qy4JOiDr.js";import{a as B,i as V,n as H,o as U,r as W,t as G}from"./webhookCommands-BxPTN2Od.js";import{a as K,i as q,n as ne,o as re,r as ie,s as J,t as ae}from"./searchable-select-BE62ykWr.js";var Y=e(t(),1);function oe(e){return U(e)}function se(e){let t=[],n=e.name.trim();n.length===0&&t.push(`Name is required`),n.length>80&&t.push(`Name must be at most 80 characters`),t.push(...oe(e));let r=e.template.trim();return r.length===0&&t.push(`Template is required`),r.length>8e3&&t.push(`Template must be at most ${C} characters`),[e.threadKeyPath,e.senderPath].some(e=>(e?.length??0)>200)&&t.push(`Paths must be at most 200 characters`),(e.replyHint?.length??0)>2e3&&t.push(`Reply hint must be at most ${v} characters`),t}function ce(e,t){let n=e.provider??void 0,r=e.model?.trim()||void 0;if(n===void 0&&r===void 0)return[];if(n===void 0||r===void 0)return[`Provider and model must be set together`];let i=t.find(e=>e.id===n);return i?n===`openrouter`?r.length>200?[`Model must be at most 200 characters`]:[]:i.models.some(e=>e.id===r)?[]:[`Model ${r} is not available for ${n}`]:[`Provider ${n} is not available`]}var X=P(`WebhookCreateDialog`,e=>t=>({name:e?.name??``,mode:e?.mode??`notify`,chatId:e?.chatId??``,projectId:e?.projectId??``,modelValue:e?.provider&&e.model?K(e.provider,e.model):``,template:e?.template??`A webhook was received. Summarize what happened and say whether it needs attention.`,setName:e=>t({name:e}),setMode:e=>t({mode:e}),setChatId:e=>t({chatId:e}),setProjectId:e=>t({projectId:e}),setModelValue:e=>t({modelValue:e}),setTemplate:e=>t({template:e})})),Z=e(n(),1),le=l(`webhooks.create`),ue=[`notify`,`inline`,`spawn`].map(e=>({value:e,label:E(e)}));function de({sidebarData:e,onCreate:t,editing:n}){let r=R(),i=V(),o=n?l(`webhooks.update`,n.id):le,u=c(o),d=T(e=>e.closeEditor),f=X.useScopedStore(e=>e.name),p=X.useScopedStore(e=>e.mode),m=X.useScopedStore(e=>e.chatId),h=X.useScopedStore(e=>e.projectId),g=X.useScopedStore(e=>e.modelValue),_=X.useScopedStore(e=>e.template),v=X.useScopedStore(e=>e.setName),y=X.useScopedStore(e=>e.setMode),b=X.useScopedStore(e=>e.setChatId),S=X.useScopedStore(e=>e.setProjectId),C=X.useScopedStore(e=>e.setModelValue),w=X.useScopedStore(e=>e.setTemplate),E=(0,Y.useMemo)(()=>J(e),[e]),D=(0,Y.useMemo)(()=>re(i),[i]),P=p!==`notify`,I=(0,Y.useMemo)(()=>{let e=P?ne(g):null;return{name:f,mode:p,template:_,...p===`spawn`?{projectId:h}:{chatId:m},...e?{provider:e.provider,model:e.model}:{}}},[m,p,g,f,h,P,_]),L=(0,Y.useMemo)(()=>[...se(I),...ce(I,i)],[i,I]),z=(0,Y.useCallback)(e=>{e||d()},[d]),H=(0,Y.useCallback)(()=>d(),[d]),U=(0,Y.useCallback)(e=>v(e.target.value),[v]),G=(0,Y.useCallback)(e=>w(e.target.value),[w]),K=(0,Y.useCallback)(()=>{L.length>0||s(o,async()=>{if(n){let e={name:I.name,mode:I.mode,template:I.template,chatId:I.chatId??null,projectId:I.projectId??null,provider:I.provider??null,model:I.model??null};await W(r,{type:`webhooks.update`,id:n.id,patch:e})}else await t(I);d()})},[d,n,L.length,I,t,r,o]);return(0,Z.jsx)(A,{open:!0,onOpenChange:z,children:(0,Z.jsxs)(k,{size:`lg`,children:[(0,Z.jsxs)(M,{className:`space-y-4`,children:[(0,Z.jsx)(N,{children:n?`Edit webhook`:`New webhook`}),(0,Z.jsx)(O,{children:`An outside system POSTs to the webhook url and Kanna reacts.`}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-name`,className:`text-sm font-medium text-foreground`,children:`Name`}),(0,Z.jsx)(F,{id:`webhook-name`,value:f,onChange:U,placeholder:`GitHub CI failures`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Action`}),(0,Z.jsx)(ee,{value:p,onValueChange:y,options:ue,size:`sm`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x(p)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-target`,className:`text-sm font-medium text-foreground`,children:p===`spawn`?`Project`:`Chat`}),p===`spawn`?(0,Z.jsx)(B,{id:`webhook-target`,value:h,options:E.projects,placeholder:`Choose a project`,searchPlaceholder:`Search projects...`,onValueChange:S}):(0,Z.jsx)(B,{id:`webhook-target`,value:m,options:E.chats,placeholder:`Choose a chat`,searchPlaceholder:`Search chats...`,onValueChange:b})]}),P?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-model`,className:`text-sm font-medium text-foreground`,children:`Model`}),(0,Z.jsx)(ae,{id:`webhook-model`,value:g,options:D,placeholder:`Choose a model`,searchPlaceholder:`Search models...`,onValueChange:C}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The model the turn started by this webhook runs with.`})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-template`,className:`text-sm font-medium text-foreground`,children:`Instruction template`}),(0,Z.jsx)(te,{id:`webhook-template`,rows:4,value:_,onChange:G}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Insert fields from the JSON body with `,(0,Z.jsx)(`code`,{className:`font-mono`,children:`{{repo.name}}`}),`. The body is appended to the prompt as untrusted data.`]})]}),L.length>0&&f.length>0?(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:L[0]}):null]}),(0,Z.jsxs)(j,{children:[(0,Z.jsx)(a,{variant:`ghost`,size:`sm`,onClick:H,children:`Cancel`}),(0,Z.jsx)(a,{size:`sm`,onClick:K,disabled:L.length>0,pending:u,children:n?`Save`:`Create`})]})]})})}function fe(e){let t=T(e=>e.editor),n=T(e=>e.hooks);if(!t)return null;let r=t.mode===`edit`?n.find(e=>e.id===t.hookId):void 0;return t.mode===`edit`&&!r?null:(0,Z.jsx)(X.Provider,{init:r,children:(0,Z.jsx)(de,{...e,editing:r})})}async function pe(e,t){try{await f.writeText(t),T.getState().markCopied(e)}catch(e){throw z.getState().setCommandError(i(e)),e}}function Q({copyId:e,text:t,label:n}){let r=l(`webhooks.copy`,e),i=c(r),o=T(t=>t.copiedId===e),f=(0,Y.useCallback)(()=>{s(r,()=>pe(e,t))},[e,r,t]);return(0,Z.jsx)(L,{label:n,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":n,pending:i,onClick:f,children:o?(0,Z.jsx)(d,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):(0,Z.jsx)(u,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})})}function me({hook:e,targets:t,catalog:n,origin:r,divider:i}){let u=R(),d=b(),f=_(r,e.id),m=l(`webhooks.update`,e.id),g=l(`webhooks.rotateSecret`,e.id),v=l(`webhooks.delete`,e.id),x=c(m),S=c(g),C=c(v),D=T(e=>e.openEdit),O=(0,Y.useCallback)(()=>D(e.id),[e.id,D]),k=ie(e,n),A=k?`${q(e,t)} · ${k}`:q(e,t),j=(0,Y.useCallback)(()=>{s(m,async()=>{await W(u,{type:`webhooks.update`,id:e.id,patch:{enabled:!e.enabled}})})},[e.enabled,e.id,u,m]),M=(0,Y.useCallback)(()=>{s(g,async()=>{if(!await d.confirm({title:`Rotate the secret for ${e.name}?`,description:`The current secret stops working immediately. Update every system that calls this webhook.`,confirmLabel:`Rotate`}))return;let t=await W(u,{type:`webhooks.rotateSecret`,id:e.id});T.getState().revealSecret(H(t,e.id,e.name))})},[d,e.id,e.name,g,u]),N=(0,Y.useCallback)(()=>{s(v,async()=>{await d.confirm({title:`Delete ${e.name}?`,description:`Callers will receive 404. This cannot be undone.`,confirmLabel:`Delete`,confirmVariant:`destructive`})&&await W(u,{type:`webhooks.delete`,id:e.id})})},[v,d,e.id,e.name,u]);return(0,Z.jsxs)(`div`,{className:o(`flex items-start gap-3 bg-background px-4 py-3`,i&&`border-b border-border`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:E(e.mode)}),e.enabled?null:(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Disabled`})]}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:A}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,children:f}),(0,Z.jsx)(Q,{copyId:e.id,text:f,label:`Copy webhook url`})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`secret ending `,(0,Z.jsx)(`span`,{className:`font-mono`,children:e.secretHint}),` · `,w(e.lastDelivery)]})]}),(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(a,{variant:`secondary`,size:`sm`,pending:x,onClick:j,children:e.enabled?`Disable`:`Enable`}),(0,Z.jsx)(L,{label:`Edit webhook`,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:O,children:(0,Z.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})}),(0,Z.jsx)(L,{label:`Rotate secret`,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Rotate secret for ${e.name}`,pending:S,onClick:M,children:(0,Z.jsx)(h,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})}),(0,Z.jsx)(L,{label:`Delete webhook`,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,pending:C,onClick:N,children:(0,Z.jsx)(y,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})})]})]})}function $({copyId:e,title:t,text:n}){return(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:t}),(0,Z.jsx)(Q,{copyId:e,text:n,label:`Copy ${t} command`})]}),(0,Z.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-border bg-background p-3 font-mono text-xs text-foreground`,children:n})]})}function he({origin:e}){let t=T(e=>e.secretReveal),n=T(e=>e.dismissSecret),r=(0,Y.useCallback)(e=>{e||n()},[n]);if(!t)return null;let i=_(e,t.hookId);return(0,Z.jsx)(A,{open:!0,onOpenChange:r,children:(0,Z.jsxs)(k,{size:`lg`,children:[(0,Z.jsxs)(M,{className:`space-y-4`,children:[(0,Z.jsxs)(N,{children:[`Secret for `,t.hookName]}),(0,Z.jsx)(O,{children:`This is the only time the secret is shown. Copy it now. Rotating it later issues a new one.`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-background p-3`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs text-foreground`,children:t.secret}),(0,Z.jsx)(Q,{copyId:`${t.hookId}-secret`,text:t.secret,label:`Copy secret`})]}),(0,Z.jsx)($,{copyId:`${t.hookId}-bearer`,title:`Bearer token`,text:S(i,t.secret)}),(0,Z.jsx)($,{copyId:`${t.hookId}-hmac`,title:`HMAC signature`,text:g(i,t.secret)})]}),(0,Z.jsx)(j,{children:(0,Z.jsx)(a,{size:`sm`,onClick:n,children:`I have copied it`})})]})})}function ge(){let e=R(),t=T(e=>e.hooks),n=T(e=>e.openCreate),i=z(e=>e.sidebarData),o=(0,Y.useMemo)(()=>J(i),[i]),s=V(),c=r.getOrigin(),l=(0,Y.useCallback)(async t=>{let n=await W(e,{type:`webhooks.create`,input:t});T.getState().revealSecret(G(n))},[e]);return(0,Z.jsxs)(`div`,{className:I,children:[(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[900px] px-4 py-8`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-lg font-semibold text-foreground`,children:[(0,Z.jsx)(D,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),`Webhooks`,(0,Z.jsx)(`span`,{className:`text-sm font-normal text-muted-foreground tabular-nums`,children:t.length})]}),(0,Z.jsxs)(a,{size:`sm`,onClick:n,children:[(0,Z.jsx)(m,{className:`mr-1 h-4 w-4`,"aria-hidden":`true`}),`New webhook`]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`An outside system POSTs to a webhook url with its secret. Kanna leaves a card in a chat, queues a prompt in a chat, or starts a new chat. Webhook urls are reachable wherever Kanna is reachable.`}),t.length===0?(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:`No webhooks yet. Create one to get a url and a secret.`}):(0,Z.jsx)(`div`,{className:`mt-6 overflow-hidden rounded-2xl border border-border`,children:t.map((e,n)=>(0,Z.jsx)(me,{hook:e,targets:o,catalog:s,origin:c,divider:n<t.length-1},e.id))})]}),(0,Z.jsx)(fe,{sidebarData:i,onCreate:l}),(0,Z.jsx)(he,{origin:c})]})}export{ge as WebhooksPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{d as r,f as i}from"./log-3sQ-5rrS.js";import{a,c as o,n as s,r as c,t as l}from"./pendingActionsStore-C9wopHr4.js";import{n as u,r as d,t as f}from"./clipboard.adapter-BCxT7Qli.js";import{t as p}from"./pencil-BTeN1rO_.js";import{t as m}from"./plus-D0uUa5kJ.js";import{n as h}from"./search-48C1GM_8.js";import{c as g,d as _,f as v,g as y,h as b,l as x,o as S,p as C,s as w,t as T,u as E}from"./webhooksStore-DmkDHteX.js";import{t as D}from"./webhook-_4KNokhW.js";import{a as O,i as k,n as A,o as j,r as M,u as N}from"./timer.adapter-Di4tkt37.js";import{t as ee}from"./segmented-control-DbmDSdKy.js";import{t as P}from"./createScopedStore-D1trFyJw.js";import{t as F}from"./input-CS1DBeNV.js";import{n as I}from"./shellChrome-bmmKlcOk.js";import{m as L,n as R,p as te,u as z}from"./KannaSocketProvider-Clv949La.js";import{a as B,i as V,n as H,o as U,r as W,t as G}from"./webhookCommands-ClSc7rRQ.js";import{a as K,i as q,n as ne,o as re,r as ie,s as J,t as ae}from"./searchable-select-C2LG0o1C.js";var Y=e(t(),1);function oe(e){return U(e)}function se(e){let t=[],n=e.name.trim();n.length===0&&t.push(`Name is required`),n.length>80&&t.push(`Name must be at most 80 characters`),t.push(...oe(e));let r=e.template.trim();return r.length===0&&t.push(`Template is required`),r.length>8e3&&t.push(`Template must be at most ${C} characters`),[e.threadKeyPath,e.senderPath].some(e=>(e?.length??0)>200)&&t.push(`Paths must be at most 200 characters`),(e.replyHint?.length??0)>2e3&&t.push(`Reply hint must be at most ${v} characters`),t}function ce(e,t){let n=e.provider??void 0,r=e.model?.trim()||void 0;if(n===void 0&&r===void 0)return[];if(n===void 0||r===void 0)return[`Provider and model must be set together`];let i=t.find(e=>e.id===n);return i?n===`openrouter`?r.length>200?[`Model must be at most 200 characters`]:[]:i.models.some(e=>e.id===r)?[]:[`Model ${r} is not available for ${n}`]:[`Provider ${n} is not available`]}var X=P(`WebhookCreateDialog`,e=>t=>({name:e?.name??``,mode:e?.mode??`notify`,chatId:e?.chatId??``,projectId:e?.projectId??``,modelValue:e?.provider&&e.model?K(e.provider,e.model):``,template:e?.template??`A webhook was received. Summarize what happened and say whether it needs attention.`,setName:e=>t({name:e}),setMode:e=>t({mode:e}),setChatId:e=>t({chatId:e}),setProjectId:e=>t({projectId:e}),setModelValue:e=>t({modelValue:e}),setTemplate:e=>t({template:e})})),Z=e(n(),1),le=l(`webhooks.create`),ue=[`notify`,`inline`,`spawn`].map(e=>({value:e,label:E(e)}));function de({sidebarData:e,onCreate:t,editing:n}){let r=R(),i=V(),o=n?l(`webhooks.update`,n.id):le,u=c(o),d=T(e=>e.closeEditor),f=X.useScopedStore(e=>e.name),p=X.useScopedStore(e=>e.mode),m=X.useScopedStore(e=>e.chatId),h=X.useScopedStore(e=>e.projectId),g=X.useScopedStore(e=>e.modelValue),_=X.useScopedStore(e=>e.template),v=X.useScopedStore(e=>e.setName),y=X.useScopedStore(e=>e.setMode),b=X.useScopedStore(e=>e.setChatId),S=X.useScopedStore(e=>e.setProjectId),C=X.useScopedStore(e=>e.setModelValue),w=X.useScopedStore(e=>e.setTemplate),E=(0,Y.useMemo)(()=>J(e),[e]),D=(0,Y.useMemo)(()=>re(i),[i]),P=p!==`notify`,I=(0,Y.useMemo)(()=>{let e=P?ne(g):null;return{name:f,mode:p,template:_,...p===`spawn`?{projectId:h}:{chatId:m},...e?{provider:e.provider,model:e.model}:{}}},[m,p,g,f,h,P,_]),L=(0,Y.useMemo)(()=>[...se(I),...ce(I,i)],[i,I]),z=(0,Y.useCallback)(e=>{e||d()},[d]),H=(0,Y.useCallback)(()=>d(),[d]),U=(0,Y.useCallback)(e=>v(e.target.value),[v]),G=(0,Y.useCallback)(e=>w(e.target.value),[w]),K=(0,Y.useCallback)(()=>{L.length>0||s(o,async()=>{if(n){let e={name:I.name,mode:I.mode,template:I.template,chatId:I.chatId??null,projectId:I.projectId??null,provider:I.provider??null,model:I.model??null};await W(r,{type:`webhooks.update`,id:n.id,patch:e})}else await t(I);d()})},[d,n,L.length,I,t,r,o]);return(0,Z.jsx)(A,{open:!0,onOpenChange:z,children:(0,Z.jsxs)(k,{size:`lg`,children:[(0,Z.jsxs)(M,{className:`space-y-4`,children:[(0,Z.jsx)(N,{children:n?`Edit webhook`:`New webhook`}),(0,Z.jsx)(O,{children:`An outside system POSTs to the webhook url and Kanna reacts.`}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-name`,className:`text-sm font-medium text-foreground`,children:`Name`}),(0,Z.jsx)(F,{id:`webhook-name`,value:f,onChange:U,placeholder:`GitHub CI failures`})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Action`}),(0,Z.jsx)(ee,{value:p,onValueChange:y,options:ue,size:`sm`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x(p)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-target`,className:`text-sm font-medium text-foreground`,children:p===`spawn`?`Project`:`Chat`}),p===`spawn`?(0,Z.jsx)(B,{id:`webhook-target`,value:h,options:E.projects,placeholder:`Choose a project`,searchPlaceholder:`Search projects...`,onValueChange:S}):(0,Z.jsx)(B,{id:`webhook-target`,value:m,options:E.chats,placeholder:`Choose a chat`,searchPlaceholder:`Search chats...`,onValueChange:b})]}),P?(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-model`,className:`text-sm font-medium text-foreground`,children:`Model`}),(0,Z.jsx)(ae,{id:`webhook-model`,value:g,options:D,placeholder:`Choose a model`,searchPlaceholder:`Search models...`,onValueChange:C}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The model the turn started by this webhook runs with.`})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:`webhook-template`,className:`text-sm font-medium text-foreground`,children:`Instruction template`}),(0,Z.jsx)(te,{id:`webhook-template`,rows:4,value:_,onChange:G}),(0,Z.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Insert fields from the JSON body with `,(0,Z.jsx)(`code`,{className:`font-mono`,children:`{{repo.name}}`}),`. The body is appended to the prompt as untrusted data.`]})]}),L.length>0&&f.length>0?(0,Z.jsx)(`p`,{className:`text-xs text-destructive`,children:L[0]}):null]}),(0,Z.jsxs)(j,{children:[(0,Z.jsx)(a,{variant:`ghost`,size:`sm`,onClick:H,children:`Cancel`}),(0,Z.jsx)(a,{size:`sm`,onClick:K,disabled:L.length>0,pending:u,children:n?`Save`:`Create`})]})]})})}function fe(e){let t=T(e=>e.editor),n=T(e=>e.hooks);if(!t)return null;let r=t.mode===`edit`?n.find(e=>e.id===t.hookId):void 0;return t.mode===`edit`&&!r?null:(0,Z.jsx)(X.Provider,{init:r,children:(0,Z.jsx)(de,{...e,editing:r})})}async function pe(e,t){try{await f.writeText(t),T.getState().markCopied(e)}catch(e){throw z.getState().setCommandError(i(e)),e}}function Q({copyId:e,text:t,label:n}){let r=l(`webhooks.copy`,e),i=c(r),o=T(t=>t.copiedId===e),f=(0,Y.useCallback)(()=>{s(r,()=>pe(e,t))},[e,r,t]);return(0,Z.jsx)(L,{label:n,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":n,pending:i,onClick:f,children:o?(0,Z.jsx)(d,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}):(0,Z.jsx)(u,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})})}function me({hook:e,targets:t,catalog:n,origin:r,divider:i}){let u=R(),d=b(),f=_(r,e.id),m=l(`webhooks.update`,e.id),g=l(`webhooks.rotateSecret`,e.id),v=l(`webhooks.delete`,e.id),x=c(m),S=c(g),C=c(v),D=T(e=>e.openEdit),O=(0,Y.useCallback)(()=>D(e.id),[e.id,D]),k=ie(e,n),A=k?`${q(e,t)} · ${k}`:q(e,t),j=(0,Y.useCallback)(()=>{s(m,async()=>{await W(u,{type:`webhooks.update`,id:e.id,patch:{enabled:!e.enabled}})})},[e.enabled,e.id,u,m]),M=(0,Y.useCallback)(()=>{s(g,async()=>{if(!await d.confirm({title:`Rotate the secret for ${e.name}?`,description:`The current secret stops working immediately. Update every system that calls this webhook.`,confirmLabel:`Rotate`}))return;let t=await W(u,{type:`webhooks.rotateSecret`,id:e.id});T.getState().revealSecret(H(t,e.id,e.name))})},[d,e.id,e.name,g,u]),N=(0,Y.useCallback)(()=>{s(v,async()=>{await d.confirm({title:`Delete ${e.name}?`,description:`Callers will receive 404. This cannot be undone.`,confirmLabel:`Delete`,confirmVariant:`destructive`})&&await W(u,{type:`webhooks.delete`,id:e.id})})},[v,d,e.id,e.name,u]);return(0,Z.jsxs)(`div`,{className:o(`flex items-start gap-3 bg-background px-4 py-3`,i&&`border-b border-border`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:E(e.mode)}),e.enabled?null:(0,Z.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`Disabled`})]}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:A}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 truncate font-mono text-xs text-foreground`,children:f}),(0,Z.jsx)(Q,{copyId:e.id,text:f,label:`Copy webhook url`})]}),(0,Z.jsxs)(`div`,{className:`text-xs text-muted-foreground tabular-nums`,children:[`secret ending `,(0,Z.jsx)(`span`,{className:`font-mono`,children:e.secretHint}),` · `,w(e.lastDelivery)]})]}),(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Z.jsx)(a,{variant:`secondary`,size:`sm`,pending:x,onClick:j,children:e.enabled?`Disable`:`Enable`}),(0,Z.jsx)(L,{label:`Edit webhook`,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.name}`,onClick:O,children:(0,Z.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})}),(0,Z.jsx)(L,{label:`Rotate secret`,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Rotate secret for ${e.name}`,pending:S,onClick:M,children:(0,Z.jsx)(h,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})}),(0,Z.jsx)(L,{label:`Delete webhook`,side:`top`,children:(0,Z.jsx)(a,{variant:`ghost`,size:`icon-sm`,"aria-label":`Delete ${e.name}`,pending:C,onClick:N,children:(0,Z.jsx)(y,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})})]})]})}function $({copyId:e,title:t,text:n}){return(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:t}),(0,Z.jsx)(Q,{copyId:e,text:n,label:`Copy ${t} command`})]}),(0,Z.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-border bg-background p-3 font-mono text-xs text-foreground`,children:n})]})}function he({origin:e}){let t=T(e=>e.secretReveal),n=T(e=>e.dismissSecret),r=(0,Y.useCallback)(e=>{e||n()},[n]);if(!t)return null;let i=_(e,t.hookId);return(0,Z.jsx)(A,{open:!0,onOpenChange:r,children:(0,Z.jsxs)(k,{size:`lg`,children:[(0,Z.jsxs)(M,{className:`space-y-4`,children:[(0,Z.jsxs)(N,{children:[`Secret for `,t.hookName]}),(0,Z.jsx)(O,{children:`This is the only time the secret is shown. Copy it now. Rotating it later issues a new one.`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-background p-3`,children:[(0,Z.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-xs text-foreground`,children:t.secret}),(0,Z.jsx)(Q,{copyId:`${t.hookId}-secret`,text:t.secret,label:`Copy secret`})]}),(0,Z.jsx)($,{copyId:`${t.hookId}-bearer`,title:`Bearer token`,text:S(i,t.secret)}),(0,Z.jsx)($,{copyId:`${t.hookId}-hmac`,title:`HMAC signature`,text:g(i,t.secret)})]}),(0,Z.jsx)(j,{children:(0,Z.jsx)(a,{size:`sm`,onClick:n,children:`I have copied it`})})]})})}function ge(){let e=R(),t=T(e=>e.hooks),n=T(e=>e.openCreate),i=z(e=>e.sidebarData),o=(0,Y.useMemo)(()=>J(i),[i]),s=V(),c=r.getOrigin(),l=(0,Y.useCallback)(async t=>{let n=await W(e,{type:`webhooks.create`,input:t});T.getState().revealSecret(G(n))},[e]);return(0,Z.jsxs)(`div`,{className:I,children:[(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-[900px] px-4 py-8`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-lg font-semibold text-foreground`,children:[(0,Z.jsx)(D,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),`Webhooks`,(0,Z.jsx)(`span`,{className:`text-sm font-normal text-muted-foreground tabular-nums`,children:t.length})]}),(0,Z.jsxs)(a,{size:`sm`,onClick:n,children:[(0,Z.jsx)(m,{className:`mr-1 h-4 w-4`,"aria-hidden":`true`}),`New webhook`]})]}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:`An outside system POSTs to a webhook url with its secret. Kanna leaves a card in a chat, queues a prompt in a chat, or starts a new chat. Webhook urls are reachable wherever Kanna is reachable.`}),t.length===0?(0,Z.jsx)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:`No webhooks yet. Create one to get a url and a secret.`}):(0,Z.jsx)(`div`,{className:`mt-6 overflow-hidden rounded-2xl border border-border`,children:t.map((e,n)=>(0,Z.jsx)(me,{hook:e,targets:o,catalog:s,origin:c,divider:n<t.length-1},e.id))})]}),(0,Z.jsx)(fe,{sidebarData:i,onCreate:l}),(0,Z.jsx)(he,{origin:c})]})}export{ge as WebhooksPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{l as n,u as r}from"./chunk-OB3PAWPO-bMwGZcTr.js";import{t as i}from"./jsx-runtime-BdxMnOeJ.js";import{i as a,m as o,t as s}from"./log-DIu9xkUN.js";import{c,d as l}from"./pendingActionsStore-DG0IogaL.js";import{n as u,t as d}from"./WorkflowsSection-CADF_Bzd.js";import{t as f}from"./arrow-left-B1xpxyAz.js";import{a as p,i as m,m as h,n as g,p as _,r as v}from"./ToolCallMessage-BRV-hiN2.js";import{n as y}from"./search-D4Ge6Hht.js";import{t as b}from"./createScopedStore-SnvtxVfu.js";import{t as x}from"./runDetached-CXTNs9Tz.js";import{c as S}from"./contextWindow-Dij7VexD.js";import{t as C}from"./settings-header-button-BCTE-ScU.js";var w=e(t(),1),T=b(`WorkflowsPageView`,()=>e=>({selectedRunId:null,selectedRun:null,selectedAgentId:null,setSelectedRunId:t=>e({selectedRunId:t}),setSelectedRun:t=>e({selectedRun:t}),setSelectedAgentId:t=>e({selectedAgentId:t}),clearSelection:()=>e({selectedRunId:null,selectedRun:null,selectedAgentId:null})})),E=[],D=b(`WorkflowAgentTranscript`,()=>e=>({loadState:`loading`,messages:E,error:null,reloadNonce:0,setLoaded:t=>e({loadState:`loaded`,messages:t}),setError:t=>e({loadState:`error`,error:t}),refresh:()=>e(e=>({loadState:`loading`,error:null,reloadNonce:e.reloadNonce+1}))})),O=e(i(),1);function k({runId:e,agentId:t,agentLabel:n,promptPreview:r,agentIsRunning:i=!1,onClose:a,getTranscript:s}){let c=D.useScopedStore(e=>e.loadState),u=D.useScopedStore(e=>e.messages),d=D.useScopedStore(e=>e.error),h=D.useScopedStore(e=>e.reloadNonce),g=D.useScopedStore(e=>e.setLoaded),v=D.useScopedStore(e=>e.setError),b=D.useScopedStore(e=>e.refresh);(0,w.useEffect)(()=>{let n=!1;return s(e,t).then(e=>{n||g(_(e))}).catch(o(e=>{n||v(e.message)})),()=>{n=!0}},[e,t,s,h,g,v]);let x=(0,w.useCallback)(()=>{b()},[b]);return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,"data-testid":`workflow-agent-transcript-panel`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border pb-2.5`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Back to run`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,O.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),(0,O.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:n}),(0,O.jsx)(`span`,{className:`shrink-0 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground`,children:`Transcript`}),i?(0,O.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide`,children:[(0,O.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-1.5 animate-pulse rounded-full bg-emerald-500 dark:bg-emerald-400`}),(0,O.jsx)(`span`,{className:`text-emerald-500 dark:text-emerald-400`,children:`Running`})]}):null,(0,O.jsx)(`button`,{type:`button`,onClick:x,"aria-label":`Refresh transcript`,className:`ml-auto inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,O.jsx)(y,{className:c===`loading`?`size-3.5 animate-spin`:`size-3.5`,"aria-hidden":!0})})]}),i?(0,O.jsx)(`p`,{className:`rounded-md border border-amber-500/20 bg-amber-500/5 px-2.5 py-1.5 text-xs text-amber-600 dark:text-amber-400`,children:`This agent is still running — the transcript may be incomplete. Refresh to update.`}):null,r?(0,O.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/40 px-2.5 py-1.5`,children:[(0,O.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Prompt (preview)`}),(0,O.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-muted-foreground/90`,children:r})]}):null,(0,O.jsx)(m,{value:null,children:(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-auto`,children:[c===`loading`?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,O.jsx)(l,{className:`size-3 animate-spin`,"aria-label":`Loading`}),`Loading transcript…`]}):null,c===`error`?(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:d}):null,c===`loaded`&&u.length===0?(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No transcript recorded yet.`}):null,u.map(e=>(0,O.jsx)(p,{message:e,localPath:``},e.id))]})})]})}function A(e){return(0,O.jsx)(D.Provider,{init:void 0,children:(0,O.jsx)(k,{...e})})}function j({runs:e,getRunDetail:t,getAgentTranscript:n,onBackToChat:r}){let i=T.useScopedStore(e=>e.selectedRunId),p=T.useScopedStore(e=>e.selectedRun),m=T.useScopedStore(e=>e.selectedAgentId),g=T.useScopedStore(e=>e.setSelectedRunId),_=T.useScopedStore(e=>e.setSelectedRun),v=T.useScopedStore(e=>e.setSelectedAgentId),y=T.useScopedStore(e=>e.clearSelection),b=(0,w.useRef)(null),S=(0,w.useRef)(0),E=(0,w.useCallback)(n=>{b.current=e,g(n),v(null),_(`loading`);let r=++S.current,i=()=>S.current===r;t(n).then(e=>{i()&&_(e??`not-found`)},o(e=>{s.error(a,`workflows.getRun failed`,e),i()&&_(`failed`)}))},[t,e,g,v,_]),D=(0,w.useCallback)(()=>{y(),b.current=null},[y]);(0,w.useEffect)(()=>{if(i===null||e===b.current)return;let n=e.find(e=>e.runId===i);if(!n||n.status!==`running`)return;let r=!1,a=++S.current;return x(`workflows.getRun refresh`,t(i).then(e=>{r||S.current!==a||e===null||(m===null||e.agents.some(e=>e.agentId===m))&&_(e)})),()=>{r=!0}},[e,i,m,t,_]);let k=p!==`loading`&&p!==`not-found`&&p!==`failed`?p:null,j=m!==null&&k?k.agents.find(e=>e.agentId===m):void 0,M=i!==null,P;return P=p===`loading`?(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(l,{className:`size-4 animate-spin`,"aria-label":`Loading`}),`Loading run…`]}):p===`failed`?(0,O.jsx)(N,{text:`Couldn't load this run. Select it again to retry.`}):p===`not-found`?(0,O.jsx)(N,{text:`Run not found or no longer available.`}):j&&k?(0,O.jsx)(A,{runId:k.runId,agentId:j.agentId,agentLabel:j.label,promptPreview:j.promptPreview,agentIsRunning:j.state===`running`||j.state===`progress`,onClose:()=>v(null),getTranscript:n},m??``):k?(0,O.jsx)(d,{run:k,title:k.workflowName??k.runId,onSelectAgent:e=>v(e)}):(0,O.jsx)(N,{text:`Select a run to view its phases and agents.`}),(0,O.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-4 py-3 md:px-6`,children:[(0,O.jsx)(h,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,O.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Workflows`}),e.length>0?(0,O.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[e.length,` `,e.length===1?`run`:`runs`]}):null,r?(0,O.jsx)(C,{"aria-label":`Back to chat`,className:`ml-auto`,icon:(0,O.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),onClick:r,children:`Back to chat`}):null]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,O.jsx)(`div`,{className:c(`w-full shrink-0 overflow-auto p-3 md:w-80 md:border-r md:border-border`,M&&`hidden md:block`),children:(0,O.jsx)(u,{runs:e,selectedRunId:i,onSelectRun:E})}),(0,O.jsxs)(`div`,{className:c(`min-w-0 flex-1 overflow-auto px-4 py-4 md:px-6`,!M&&`hidden md:block`),children:[M?(0,O.jsxs)(`button`,{type:`button`,onClick:D,"aria-label":`Back to runs`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground md:hidden`,children:[(0,O.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),`All runs`]}):null,P]})]})]})}function M(e){return(0,O.jsx)(T.Provider,{init:void 0,children:(0,O.jsx)(j,{...e})})}function N({text:e}){return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-lg border border-dashed border-border px-8 py-10 text-center`,children:[(0,O.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,O.jsx)(h,{className:`size-5`,"aria-hidden":!0})}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})]})})}function P({chatId:e}){let t=r(),i=n(),a=v(S(g(e??``))),o=(0,w.useCallback)(async n=>e?t.socket.command({type:`workflows.getRun`,chatId:e,runId:n}):null,[e,t.socket]),s=(0,w.useCallback)(async(n,r)=>e?t.socket.command({type:`workflows.getAgentTranscript`,chatId:e,runId:n,agentId:r}):[],[e,t.socket]),c=(0,w.useCallback)(()=>{e&&i(`/chat/${e}`)},[e,i]);return e?(0,O.jsx)(M,{runs:a,getRunDetail:o,getAgentTranscript:s,onBackToChat:c}):(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Open a chat to view its workflows.`})}export{P as WorkflowsPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{l as n,u as r}from"./chunk-OB3PAWPO-bMwGZcTr.js";import{t as i}from"./jsx-runtime-BdxMnOeJ.js";import{i as a,m as o,t as s}from"./log-3sQ-5rrS.js";import{c,d as l}from"./pendingActionsStore-C9wopHr4.js";import{n as u,t as d}from"./WorkflowsSection-DgbttKnk.js";import{t as f}from"./arrow-left-DOANYNxC.js";import{a as p,i as m,m as h,n as g,p as _,r as v}from"./ToolCallMessage-BbLzqXn7.js";import{n as y}from"./search-48C1GM_8.js";import{t as b}from"./createScopedStore-D1trFyJw.js";import{t as x}from"./runDetached-BBRv1zoc.js";import{c as S}from"./contextWindow-I-trSDu4.js";import{t as C}from"./settings-header-button-D4w0LZ-R.js";var w=e(t(),1),T=b(`WorkflowsPageView`,()=>e=>({selectedRunId:null,selectedRun:null,selectedAgentId:null,setSelectedRunId:t=>e({selectedRunId:t}),setSelectedRun:t=>e({selectedRun:t}),setSelectedAgentId:t=>e({selectedAgentId:t}),clearSelection:()=>e({selectedRunId:null,selectedRun:null,selectedAgentId:null})})),E=[],D=b(`WorkflowAgentTranscript`,()=>e=>({loadState:`loading`,messages:E,error:null,reloadNonce:0,setLoaded:t=>e({loadState:`loaded`,messages:t}),setError:t=>e({loadState:`error`,error:t}),refresh:()=>e(e=>({loadState:`loading`,error:null,reloadNonce:e.reloadNonce+1}))})),O=e(i(),1);function k({runId:e,agentId:t,agentLabel:n,promptPreview:r,agentIsRunning:i=!1,onClose:a,getTranscript:s}){let c=D.useScopedStore(e=>e.loadState),u=D.useScopedStore(e=>e.messages),d=D.useScopedStore(e=>e.error),h=D.useScopedStore(e=>e.reloadNonce),g=D.useScopedStore(e=>e.setLoaded),v=D.useScopedStore(e=>e.setError),b=D.useScopedStore(e=>e.refresh);(0,w.useEffect)(()=>{let n=!1;return s(e,t).then(e=>{n||g(_(e))}).catch(o(e=>{n||v(e.message)})),()=>{n=!0}},[e,t,s,h,g,v]);let x=(0,w.useCallback)(()=>{b()},[b]);return(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,"data-testid":`workflow-agent-transcript-panel`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border pb-2.5`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:a,"aria-label":`Back to run`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,O.jsx)(f,{className:`size-4`,"aria-hidden":!0})}),(0,O.jsx)(`span`,{className:`truncate text-sm font-semibold text-foreground`,children:n}),(0,O.jsx)(`span`,{className:`shrink-0 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground`,children:`Transcript`}),i?(0,O.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide`,children:[(0,O.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-1.5 animate-pulse rounded-full bg-emerald-500 dark:bg-emerald-400`}),(0,O.jsx)(`span`,{className:`text-emerald-500 dark:text-emerald-400`,children:`Running`})]}):null,(0,O.jsx)(`button`,{type:`button`,onClick:x,"aria-label":`Refresh transcript`,className:`ml-auto inline-flex size-6 shrink-0 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,O.jsx)(y,{className:c===`loading`?`size-3.5 animate-spin`:`size-3.5`,"aria-hidden":!0})})]}),i?(0,O.jsx)(`p`,{className:`rounded-md border border-amber-500/20 bg-amber-500/5 px-2.5 py-1.5 text-xs text-amber-600 dark:text-amber-400`,children:`This agent is still running — the transcript may be incomplete. Refresh to update.`}):null,r?(0,O.jsxs)(`div`,{className:`rounded-md border border-border/50 bg-muted/40 px-2.5 py-1.5`,children:[(0,O.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Prompt (preview)`}),(0,O.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-muted-foreground/90`,children:r})]}):null,(0,O.jsx)(m,{value:null,children:(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-auto`,children:[c===`loading`?(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,O.jsx)(l,{className:`size-3 animate-spin`,"aria-label":`Loading`}),`Loading transcript…`]}):null,c===`error`?(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:d}):null,c===`loaded`&&u.length===0?(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No transcript recorded yet.`}):null,u.map(e=>(0,O.jsx)(p,{message:e,localPath:``},e.id))]})})]})}function A(e){return(0,O.jsx)(D.Provider,{init:void 0,children:(0,O.jsx)(k,{...e})})}function j({runs:e,getRunDetail:t,getAgentTranscript:n,onBackToChat:r}){let i=T.useScopedStore(e=>e.selectedRunId),p=T.useScopedStore(e=>e.selectedRun),m=T.useScopedStore(e=>e.selectedAgentId),g=T.useScopedStore(e=>e.setSelectedRunId),_=T.useScopedStore(e=>e.setSelectedRun),v=T.useScopedStore(e=>e.setSelectedAgentId),y=T.useScopedStore(e=>e.clearSelection),b=(0,w.useRef)(null),S=(0,w.useRef)(0),E=(0,w.useCallback)(n=>{b.current=e,g(n),v(null),_(`loading`);let r=++S.current,i=()=>S.current===r;t(n).then(e=>{i()&&_(e??`not-found`)},o(e=>{s.error(a,`workflows.getRun failed`,e),i()&&_(`failed`)}))},[t,e,g,v,_]),D=(0,w.useCallback)(()=>{y(),b.current=null},[y]);(0,w.useEffect)(()=>{if(i===null||e===b.current)return;let n=e.find(e=>e.runId===i);if(!n||n.status!==`running`)return;let r=!1,a=++S.current;return x(`workflows.getRun refresh`,t(i).then(e=>{r||S.current!==a||e===null||(m===null||e.agents.some(e=>e.agentId===m))&&_(e)})),()=>{r=!0}},[e,i,m,t,_]);let k=p!==`loading`&&p!==`not-found`&&p!==`failed`?p:null,j=m!==null&&k?k.agents.find(e=>e.agentId===m):void 0,M=i!==null,P;return P=p===`loading`?(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(l,{className:`size-4 animate-spin`,"aria-label":`Loading`}),`Loading run…`]}):p===`failed`?(0,O.jsx)(N,{text:`Couldn't load this run. Select it again to retry.`}):p===`not-found`?(0,O.jsx)(N,{text:`Run not found or no longer available.`}):j&&k?(0,O.jsx)(A,{runId:k.runId,agentId:j.agentId,agentLabel:j.label,promptPreview:j.promptPreview,agentIsRunning:j.state===`running`||j.state===`progress`,onClose:()=>v(null),getTranscript:n},m??``):k?(0,O.jsx)(d,{run:k,title:k.workflowName??k.runId,onSelectAgent:e=>v(e)}):(0,O.jsx)(N,{text:`Select a run to view its phases and agents.`}),(0,O.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-4 py-3 md:px-6`,children:[(0,O.jsx)(h,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,O.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:`Workflows`}),e.length>0?(0,O.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[e.length,` `,e.length===1?`run`:`runs`]}):null,r?(0,O.jsx)(C,{"aria-label":`Back to chat`,className:`ml-auto`,icon:(0,O.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),onClick:r,children:`Back to chat`}):null]}),(0,O.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,O.jsx)(`div`,{className:c(`w-full shrink-0 overflow-auto p-3 md:w-80 md:border-r md:border-border`,M&&`hidden md:block`),children:(0,O.jsx)(u,{runs:e,selectedRunId:i,onSelectRun:E})}),(0,O.jsxs)(`div`,{className:c(`min-w-0 flex-1 overflow-auto px-4 py-4 md:px-6`,!M&&`hidden md:block`),children:[M?(0,O.jsxs)(`button`,{type:`button`,onClick:D,"aria-label":`Back to runs`,className:`mb-3 inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground md:hidden`,children:[(0,O.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),`All runs`]}):null,P]})]})]})}function M(e){return(0,O.jsx)(T.Provider,{init:void 0,children:(0,O.jsx)(j,{...e})})}function N({text:e}){return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-3 rounded-lg border border-dashed border-border px-8 py-10 text-center`,children:[(0,O.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,O.jsx)(h,{className:`size-5`,"aria-hidden":!0})}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})]})})}function P({chatId:e}){let t=r(),i=n(),a=v(S(g(e??``))),o=(0,w.useCallback)(async n=>e?t.socket.command({type:`workflows.getRun`,chatId:e,runId:n}):null,[e,t.socket]),s=(0,w.useCallback)(async(n,r)=>e?t.socket.command({type:`workflows.getAgentTranscript`,chatId:e,runId:n,agentId:r}):[],[e,t.socket]),c=(0,w.useCallback)(()=>{e&&i(`/chat/${e}`)},[e,i]);return e?(0,O.jsx)(M,{runs:a,getRunDetail:o,getAgentTranscript:s,onBackToChat:c}):(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`Open a chat to view its workflows.`})}export{P as WorkflowsPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{i as r,m as i,t as a}from"./log-DIu9xkUN.js";import{c as o,f as s,s as c}from"./pendingActionsStore-DG0IogaL.js";import{W as l}from"./FilePreviewSheet-CSTHZ0r-.js";import{c as u,i as d,n as f,r as p,u as m}from"./timer.adapter-BX7oyt8G.js";import{t as h}from"./createScopedStore-SnvtxVfu.js";import{t as g}from"./runDetached-CXTNs9Tz.js";import{s as _}from"./contextWindow-Dij7VexD.js";import{t as v}from"./formatDuration-BbWTR_M_.js";import{l as y,s as b,t as x}from"./state-mark-Cpr4kZpE.js";var S={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};S.node;var C=s(S),w=e(t(),1),T=h(`WorkflowsSectionDetail`,()=>e=>({selectedRun:null,selectedRunId:null,setSelectedRun:t=>e({selectedRun:t}),setSelectedRunId:t=>e({selectedRunId:t}),clearSelection:()=>e({selectedRun:null,selectedRunId:null})})),E=`Agents`;function D(e){return typeof e.phaseIndex==`number`&&e.phaseIndex>=1}function O(e,t){if(!t.some(D))return t.length===0?[]:[{key:`ungrouped`,phaseIndex:null,title:E,agents:t}];let n=new Map,r=[];for(let e of t)if(D(e)){let t=n.get(e.phaseIndex)??[];t.push(e),n.set(e.phaseIndex,t)}else r.push(e);let i=[];e.forEach((e,t)=>{let r=t+1;i.push({key:`phase-${r}`,phaseIndex:r,title:e.title,detail:e.detail,agents:n.get(r)??[]}),n.delete(r)});for(let e of[...n.keys()].sort((e,t)=>e-t)){let t=n.get(e);i.push({key:`phase-${e}`,phaseIndex:e,title:t[0]?.phaseTitle??`Phase ${e}`,agents:t})}return r.length>0&&i.push({key:`ungrouped`,phaseIndex:null,title:E,agents:r}),i}var k=e(n(),1);function A({runs:e,onSelectRun:t,selectedRunId:n}){return e.length===0?(0,k.jsx)(j,{}):(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,k.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.length,` `,e.length===1?`run`:`runs`]})}),(0,k.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.map(e=>(0,k.jsx)(M,{run:e,selected:e.runId===n,onSelect:t},e.runId))})]})}function j(){return(0,k.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`workflow-empty`,children:[(0,k.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,k.jsx)(C,{className:`size-5`,"aria-hidden":!0})}),(0,k.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No workflow runs`}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Workflow runs will appear here when triggered.`})]})}function M(e){let{run:t,selected:n}=e,r=t.workflowName??t.runId,i=t.status===`running`,a=(0,w.useCallback)(()=>{e.onSelect(t.runId)},[e,t.runId]);return(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,"data-testid":`workflow-row:${t.runId}`,onClick:a,className:o(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,n&&`bg-muted`),children:[(0,k.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:o(`truncate text-sm text-foreground`,(i||n)&&`font-medium`),children:r}),(0,k.jsx)(_,{status:t.status,pulse:!0})]}),(0,k.jsxs)(`span`,{className:`flex w-full items-center gap-3 text-xs text-muted-foreground`,children:[t.agentCount==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[t.agentCount,` `,t.agentCount===1?`agent`:`agents`]}),t.totalTokens==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[t.totalTokens.toLocaleString(),` tokens`]}),t.durationMs==null?null:(0,k.jsx)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:v(t.durationMs)})]})]})})}function N(e){return e===`running`||e===`progress`?`active`:e===`failed`||e===`error`?`destructive`:e===`killed`?`attention`:`muted`}function P(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}function F({run:e,failed:t}){return e?(0,k.jsx)(z,{run:e}):t?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Couldn't load this run. Close and select it again to retry.`}):(0,k.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,k.jsx)(c,{}),`Loading…`]})}function I({run:e,failed:t=!1,open:n,onClose:r}){return(0,k.jsx)(f,{open:n,onOpenChange:e=>{e||r()},children:(0,k.jsxs)(d,{size:`lg`,"aria-describedby":void 0,children:[(0,k.jsx)(u,{children:(0,k.jsx)(m,{children:e?e.workflowName??e.runId:`Workflow run`})}),(0,k.jsx)(p,{children:(0,k.jsx)(F,{run:e,failed:t})})]})})}function L({label:e,text:t}){return(0,k.jsxs)(`div`,{className:`rounded border border-border/50 bg-muted/40 px-2 py-1`,children:[(0,k.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:e}),(0,k.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-muted-foreground/90`,children:t})]})}function R({agent:e,onSelectAgent:t}){let n=N(e.state),r=n===`active`,i=!!(t&&e.agentId);return(0,k.jsxs)(`li`,{"data-testid":`workflow-agent:${e.agentId??e.index}`,className:`group flex items-start gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50`,children:[(0,k.jsx)(x,{tone:n,className:o(`mt-0.5`,b(n))}),(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:o(`truncate text-sm text-foreground`,r&&`font-medium`),children:e.label}),e.model?(0,k.jsx)(`span`,{className:`shrink-0 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.model}):null,i?(0,k.jsxs)(`button`,{type:`button`,"data-testid":`workflow-agent-transcript:${e.agentId}`,onClick:()=>t?.(e.agentId),className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,k.jsx)(l,{className:`size-3`,"aria-hidden":!0}),`Transcript`]}):null]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,k.jsx)(`span`,{className:o(`capitalize`,b(n)),children:e.state}),e.lastToolName?(0,k.jsxs)(`span`,{className:`truncate`,children:[`last: `,e.lastToolName]}):null,e.durationMs==null?null:(0,k.jsx)(`span`,{className:`tabular-nums`,children:v(e.durationMs)}),e.tokens==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,children:[e.tokens.toLocaleString(),` tok`]}),e.toolCalls==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,children:[e.toolCalls,` calls`]})]}),e.lastToolSummary?(0,k.jsx)(`span`,{className:`truncate text-xs text-muted-foreground/80`,children:e.lastToolSummary}):null,e.promptPreview?(0,k.jsx)(L,{label:`Prompt`,text:e.promptPreview}):null,e.resultPreview?(0,k.jsx)(L,{label:`Result`,text:e.resultPreview}):null]})]})}function z({run:e,onSelectAgent:t,title:n}){let r=y(e.status),i=O(e.phases,e.agents);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n?(0,k.jsx)(`h3`,{className:`truncate text-base font-semibold text-foreground`,children:n}):null,(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(_,{status:e.status,pulse:!0}),e.durationMs==null?null:(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:v(e.durationMs)}),e.agentCount==null?null:(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.agentCount,` `,e.agentCount===1?`agent`:`agents`]}),e.totalTokens==null?null:(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.totalTokens.toLocaleString(),` tokens`]}),e.totalToolCalls==null?null:(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.totalToolCalls,` tool calls`]})]})]}),e.summary?(0,k.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`h4`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Summary`}),(0,k.jsx)(`p`,{className:`text-sm text-foreground whitespace-pre-wrap`,children:e.summary})]}):null,i.length>0?(0,k.jsx)(`section`,{className:`flex flex-col gap-4`,"data-testid":`workflow-progress-tree`,children:i.map(e=>(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.phaseIndex==null?null:(0,k.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center rounded bg-muted text-xs font-medium text-muted-foreground tabular-nums`,children:e.phaseIndex}),(0,k.jsx)(`h4`,{className:`text-xs font-semibold tracking-wide text-foreground`,children:e.title}),(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.agents.length,` `,e.agents.length===1?`agent`:`agents`]})]}),e.detail?(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.detail}):null,e.agents.length>0?(0,k.jsx)(`ul`,{className:`ml-1.5 flex flex-col gap-0.5 border-l border-border pl-2.5`,children:e.agents.map(e=>(0,k.jsx)(R,{agent:e,onSelectAgent:t},e.agentId??e.index))}):(0,k.jsx)(`p`,{className:`ml-1.5 border-l border-border pl-2.5 text-xs italic text-muted-foreground/70`,children:`No agents yet`})]},e.key))}):null,e.result?(0,k.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`h4`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Result`}),(0,k.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words`,children:P(e.result)})]}):null,e.script?(0,k.jsxs)(`details`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium tracking-wide text-muted-foreground hover:text-foreground`,children:`Script`}),(0,k.jsx)(`pre`,{className:`mt-1.5 max-h-96 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words`,children:e.script})]}):null,e.error&&e.status!==`completed`?(0,k.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`h4`,{className:o(`text-xs font-medium tracking-wide`,b(r)),children:`Error`}),(0,k.jsx)(`p`,{className:`rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-sm text-destructive whitespace-pre-wrap`,children:e.error})]}):null]})}function B({runs:e,getRunDetail:t}){let n=T.useScopedStore(e=>e.selectedRun),o=T.useScopedStore(e=>e.selectedRunId),s=T.useScopedStore(e=>e.setSelectedRun),c=T.useScopedStore(e=>e.setSelectedRunId),l=T.useScopedStore(e=>e.clearSelection),u=n!==null,d=(0,w.useRef)(null),f=(0,w.useRef)(0),p=(0,w.useCallback)(n=>{d.current=e,c(n),s(`loading`);let o=++f.current,l=()=>f.current===o;t(n).then(e=>{l()&&s(e)},i(e=>{a.error(r,`workflows.getRun failed`,e),l()&&s(`failed`)}))},[t,e,s,c]),m=(0,w.useCallback)(()=>{l(),d.current=null},[l]);return(0,w.useEffect)(()=>{if(o===null||e===d.current)return;let n=e.find(e=>e.runId===o);if(!n||n.status!==`running`)return;let r=!1,i=++f.current;return g(`workflows.getRun refresh`,t(o).then(e=>{r||f.current!==i||e===null||s(e)})),()=>{r=!0}},[e,o,t,s]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(A,{runs:e,onSelectRun:p}),(0,k.jsx)(I,{run:n===`loading`||n===`failed`?null:n,failed:n===`failed`,open:u,onClose:m})]})}function V(e){return(0,k.jsx)(T.Provider,{init:void 0,children:(0,k.jsx)(B,{...e})})}export{C as i,A as n,V as r,z as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{i as r,m as i,t as a}from"./log-3sQ-5rrS.js";import{c as o,f as s,s as c}from"./pendingActionsStore-C9wopHr4.js";import{W as l}from"./FilePreviewSheet-iaBNZ_R0.js";import{c as u,i as d,n as f,r as p,u as m}from"./timer.adapter-Di4tkt37.js";import{t as h}from"./createScopedStore-D1trFyJw.js";import{t as g}from"./runDetached-BBRv1zoc.js";import{s as _}from"./contextWindow-I-trSDu4.js";import{t as v}from"./formatDuration-BbWTR_M_.js";import{l as y,s as b,t as x}from"./state-mark-DNAt8L4c.js";var S={name:`activity`,size:24,node:[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]};S.node;var C=s(S),w=e(t(),1),T=h(`WorkflowsSectionDetail`,()=>e=>({selectedRun:null,selectedRunId:null,setSelectedRun:t=>e({selectedRun:t}),setSelectedRunId:t=>e({selectedRunId:t}),clearSelection:()=>e({selectedRun:null,selectedRunId:null})})),E=`Agents`;function D(e){return typeof e.phaseIndex==`number`&&e.phaseIndex>=1}function O(e,t){if(!t.some(D))return t.length===0?[]:[{key:`ungrouped`,phaseIndex:null,title:E,agents:t}];let n=new Map,r=[];for(let e of t)if(D(e)){let t=n.get(e.phaseIndex)??[];t.push(e),n.set(e.phaseIndex,t)}else r.push(e);let i=[];e.forEach((e,t)=>{let r=t+1;i.push({key:`phase-${r}`,phaseIndex:r,title:e.title,detail:e.detail,agents:n.get(r)??[]}),n.delete(r)});for(let e of[...n.keys()].sort((e,t)=>e-t)){let t=n.get(e);i.push({key:`phase-${e}`,phaseIndex:e,title:t[0]?.phaseTitle??`Phase ${e}`,agents:t})}return r.length>0&&i.push({key:`ungrouped`,phaseIndex:null,title:E,agents:r}),i}var k=e(n(),1);function A({runs:e,onSelectRun:t,selectedRunId:n}){return e.length===0?(0,k.jsx)(j,{}):(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,k.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.length,` `,e.length===1?`run`:`runs`]})}),(0,k.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.map(e=>(0,k.jsx)(M,{run:e,selected:e.runId===n,onSelect:t},e.runId))})]})}function j(){return(0,k.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`workflow-empty`,children:[(0,k.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,k.jsx)(C,{className:`size-5`,"aria-hidden":!0})}),(0,k.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No workflow runs`}),(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Workflow runs will appear here when triggered.`})]})}function M(e){let{run:t,selected:n}=e,r=t.workflowName??t.runId,i=t.status===`running`,a=(0,w.useCallback)(()=>{e.onSelect(t.runId)},[e,t.runId]);return(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,"data-testid":`workflow-row:${t.runId}`,onClick:a,className:o(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,n&&`bg-muted`),children:[(0,k.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,k.jsx)(`span`,{className:o(`truncate text-sm text-foreground`,(i||n)&&`font-medium`),children:r}),(0,k.jsx)(_,{status:t.status,pulse:!0})]}),(0,k.jsxs)(`span`,{className:`flex w-full items-center gap-3 text-xs text-muted-foreground`,children:[t.agentCount==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[t.agentCount,` `,t.agentCount===1?`agent`:`agents`]}),t.totalTokens==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:[t.totalTokens.toLocaleString(),` tokens`]}),t.durationMs==null?null:(0,k.jsx)(`span`,{className:`tabular-nums`,style:{fontVariantNumeric:`tabular-nums`},children:v(t.durationMs)})]})]})})}function N(e){return e===`running`||e===`progress`?`active`:e===`failed`||e===`error`?`destructive`:e===`killed`?`attention`:`muted`}function P(e){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return e;try{return JSON.stringify(JSON.parse(t),null,2)}catch{return e}}function F({run:e,failed:t}){return e?(0,k.jsx)(z,{run:e}):t?(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Couldn't load this run. Close and select it again to retry.`}):(0,k.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,k.jsx)(c,{}),`Loading…`]})}function I({run:e,failed:t=!1,open:n,onClose:r}){return(0,k.jsx)(f,{open:n,onOpenChange:e=>{e||r()},children:(0,k.jsxs)(d,{size:`lg`,"aria-describedby":void 0,children:[(0,k.jsx)(u,{children:(0,k.jsx)(m,{children:e?e.workflowName??e.runId:`Workflow run`})}),(0,k.jsx)(p,{children:(0,k.jsx)(F,{run:e,failed:t})})]})})}function L({label:e,text:t}){return(0,k.jsxs)(`div`,{className:`rounded border border-border/50 bg-muted/40 px-2 py-1`,children:[(0,k.jsx)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:e}),(0,k.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-xs text-muted-foreground/90`,children:t})]})}function R({agent:e,onSelectAgent:t}){let n=N(e.state),r=n===`active`,i=!!(t&&e.agentId);return(0,k.jsxs)(`li`,{"data-testid":`workflow-agent:${e.agentId??e.index}`,className:`group flex items-start gap-2 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50`,children:[(0,k.jsx)(x,{tone:n,className:o(`mt-0.5`,b(n))}),(0,k.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:o(`truncate text-sm text-foreground`,r&&`font-medium`),children:e.label}),e.model?(0,k.jsx)(`span`,{className:`shrink-0 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground`,children:e.model}):null,i?(0,k.jsxs)(`button`,{type:`button`,"data-testid":`workflow-agent-transcript:${e.agentId}`,onClick:()=>t?.(e.agentId),className:`ml-auto inline-flex shrink-0 items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,k.jsx)(l,{className:`size-3`,"aria-hidden":!0}),`Transcript`]}):null]}),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-muted-foreground`,children:[(0,k.jsx)(`span`,{className:o(`capitalize`,b(n)),children:e.state}),e.lastToolName?(0,k.jsxs)(`span`,{className:`truncate`,children:[`last: `,e.lastToolName]}):null,e.durationMs==null?null:(0,k.jsx)(`span`,{className:`tabular-nums`,children:v(e.durationMs)}),e.tokens==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,children:[e.tokens.toLocaleString(),` tok`]}),e.toolCalls==null?null:(0,k.jsxs)(`span`,{className:`tabular-nums`,children:[e.toolCalls,` calls`]})]}),e.lastToolSummary?(0,k.jsx)(`span`,{className:`truncate text-xs text-muted-foreground/80`,children:e.lastToolSummary}):null,e.promptPreview?(0,k.jsx)(L,{label:`Prompt`,text:e.promptPreview}):null,e.resultPreview?(0,k.jsx)(L,{label:`Result`,text:e.resultPreview}):null]})]})}function z({run:e,onSelectAgent:t,title:n}){let r=y(e.status),i=O(e.phases,e.agents);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[n?(0,k.jsx)(`h3`,{className:`truncate text-base font-semibold text-foreground`,children:n}):null,(0,k.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,k.jsx)(_,{status:e.status,pulse:!0}),e.durationMs==null?null:(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:v(e.durationMs)}),e.agentCount==null?null:(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.agentCount,` `,e.agentCount===1?`agent`:`agents`]}),e.totalTokens==null?null:(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.totalTokens.toLocaleString(),` tokens`]}),e.totalToolCalls==null?null:(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.totalToolCalls,` tool calls`]})]})]}),e.summary?(0,k.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`h4`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Summary`}),(0,k.jsx)(`p`,{className:`text-sm text-foreground whitespace-pre-wrap`,children:e.summary})]}):null,i.length>0?(0,k.jsx)(`section`,{className:`flex flex-col gap-4`,"data-testid":`workflow-progress-tree`,children:i.map(e=>(0,k.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.phaseIndex==null?null:(0,k.jsx)(`span`,{"aria-hidden":!0,className:`flex size-4 shrink-0 items-center justify-center rounded bg-muted text-xs font-medium text-muted-foreground tabular-nums`,children:e.phaseIndex}),(0,k.jsx)(`h4`,{className:`text-xs font-semibold tracking-wide text-foreground`,children:e.title}),(0,k.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[e.agents.length,` `,e.agents.length===1?`agent`:`agents`]})]}),e.detail?(0,k.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.detail}):null,e.agents.length>0?(0,k.jsx)(`ul`,{className:`ml-1.5 flex flex-col gap-0.5 border-l border-border pl-2.5`,children:e.agents.map(e=>(0,k.jsx)(R,{agent:e,onSelectAgent:t},e.agentId??e.index))}):(0,k.jsx)(`p`,{className:`ml-1.5 border-l border-border pl-2.5 text-xs italic text-muted-foreground/70`,children:`No agents yet`})]},e.key))}):null,e.result?(0,k.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`h4`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Result`}),(0,k.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words`,children:P(e.result)})]}):null,e.script?(0,k.jsxs)(`details`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium tracking-wide text-muted-foreground hover:text-foreground`,children:`Script`}),(0,k.jsx)(`pre`,{className:`mt-1.5 max-h-96 overflow-auto rounded-md border border-border/60 bg-muted/40 px-3 py-2 text-xs text-foreground whitespace-pre-wrap break-words`,children:e.script})]}):null,e.error&&e.status!==`completed`?(0,k.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,k.jsx)(`h4`,{className:o(`text-xs font-medium tracking-wide`,b(r)),children:`Error`}),(0,k.jsx)(`p`,{className:`rounded-md border border-destructive/20 bg-destructive/5 px-3 py-2 text-sm text-destructive whitespace-pre-wrap`,children:e.error})]}):null]})}function B({runs:e,getRunDetail:t}){let n=T.useScopedStore(e=>e.selectedRun),o=T.useScopedStore(e=>e.selectedRunId),s=T.useScopedStore(e=>e.setSelectedRun),c=T.useScopedStore(e=>e.setSelectedRunId),l=T.useScopedStore(e=>e.clearSelection),u=n!==null,d=(0,w.useRef)(null),f=(0,w.useRef)(0),p=(0,w.useCallback)(n=>{d.current=e,c(n),s(`loading`);let o=++f.current,l=()=>f.current===o;t(n).then(e=>{l()&&s(e)},i(e=>{a.error(r,`workflows.getRun failed`,e),l()&&s(`failed`)}))},[t,e,s,c]),m=(0,w.useCallback)(()=>{l(),d.current=null},[l]);return(0,w.useEffect)(()=>{if(o===null||e===d.current)return;let n=e.find(e=>e.runId===o);if(!n||n.status!==`running`)return;let r=!1,i=++f.current;return g(`workflows.getRun refresh`,t(o).then(e=>{r||f.current!==i||e===null||s(e)})),()=>{r=!0}},[e,o,t,s]),(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(A,{runs:e,onSelectRun:p}),(0,k.jsx)(I,{run:n===`loading`||n===`failed`?null:n,failed:n===`failed`,open:u,onClose:m})]})}function V(e){return(0,k.jsx)(T.Provider,{init:void 0,children:(0,k.jsx)(B,{...e})})}export{C as i,A as n,V as r,z as t};
@@ -1 +1 @@
1
- import{c as e}from"./log-DIu9xkUN.js";var t=1e3,n=5e3;function r(e){return Number.isFinite(e)?Math.min(n,Math.max(500,Math.round(e))):t}var i={enabled:!0,publicUrl:null};function a(e){if(e===`localhost`||e===`[::1]`)return!0;let t=e.split(`.`);return t.length===4&&t[0]===`127`&&t.every(e=>/^\d+$/.test(e)&&Number(e)<=255)}function o(e){if(e===null)return null;let t;try{t=new URL(e.trim())}catch{return null}return t.protocol===`https:`||t.protocol===`http:`&&a(t.hostname)?t.origin:null}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e){return Array.isArray(e)}function l(e){try{return JSON.parse(e)}catch{return null}}var u={enabled:!1,mode:`embedded`,url:`nats://127.0.0.1:4222`,stream:{name:`KANNA`,subjectPrefix:`kanna`,extraSubjects:[],retention:`limits`,storage:`file`,maxAgeDays:30,maxBytesMb:512,maxMsgs:-1,discard:`old`,duplicateWindowSec:120,replicas:1},consumers:[],embedded:{maxMemoryStoreMb:256,maxFileStoreMb:2048,port:`auto`,logLevel:`info`}},d={min:1,max:3650},f={min:1,max:1048576},p={min:0,max:7200},m={min:1,max:5},h={min:1,max:3600},g={min:1,max:1e6},_={min:16,max:1048576},v=/^[A-Za-z0-9_-]{1,64}$/,y=/^[a-z][a-z0-9_-]*$/,b=/^[A-Za-z0-9_-]+$/,x=/^(?:nats|tls|ws|wss):\/\/[^\s/]+$/;function S(e){return e.length<8?null:e.slice(-4)}function C(e){let t=e.split(`.`);return t.every((e,n)=>e===`>`?n===t.length-1:e===`*`||b.test(e))}function w(e,t){return Number.isInteger(e)&&e>=t.min&&e<=t.max}function T(e){let t=[];v.test(e.name)||t.push(`Stream name must be 1–64 letters, digits, - or _`),y.test(e.subjectPrefix)||t.push(`Subject prefix must start with a lowercase letter and use lowercase letters, digits, - or _`);for(let n of e.extraSubjects)C(n)||t.push(`Extra subject "${n}" is not a valid NATS subject`);return w(e.maxAgeDays,d)||t.push(`Max age must be 1–3650 days`),w(e.maxBytesMb,f)||t.push(`Max bytes must be 1–1048576 MB`),(!Number.isInteger(e.maxMsgs)||e.maxMsgs!==-1&&e.maxMsgs<1)&&t.push(`Max messages must be -1 (unlimited) or at least 1`),w(e.duplicateWindowSec,p)||t.push(`Duplicate window must be 0–7200 seconds`),w(e.replicas,m)||t.push(`Replicas must be 1–5`),t}function E(e){let t=[],n=new Set;for(let r of e)v.test(r.durableName)||t.push(`Consumer name "${r.durableName}" must be 1–64 letters, digits, - or _`),n.has(r.durableName)&&t.push(`Consumer name "${r.durableName}" is used twice`),n.add(r.durableName),r.filterSubject.length>0&&!C(r.filterSubject)&&t.push(`Consumer "${r.durableName}" filter is not a valid NATS subject`),w(r.ackWaitSec,h)||t.push(`Consumer "${r.durableName}" ack wait must be 1–3600 seconds`),w(r.maxAckPending,g)||t.push(`Consumer "${r.durableName}" max ack pending must be 1–1000000`);return t}function D(e){let t=[];return w(e.maxMemoryStoreMb,_)||t.push(`Memory store must be 16–1048576 MB`),w(e.maxFileStoreMb,_)||t.push(`File store must be 16–1048576 MB`),e.port!==`auto`&&!w(e.port,{min:1024,max:65535})&&t.push(`Port must be auto or 1024–65535`),t}function O(e){let t=[...T(e.stream),...E(e.consumers),...D(e.embedded)];return e.mode===`external`&&!x.test(e.url)&&t.push(`Server URL must look like nats://host:4222`),t}var k={...u,tokenHint:null};function A(e,t){if(t===void 0)return e;let{token:n,...r}=t,i=n?.trim()??``,a=i.length>0?S(i):e.tokenHint,o=n===null?null:a;return{...e,...r,stream:{...e.stream,...t.stream},consumers:t.consumers??e.consumers,embedded:{...e.embedded,...t.embedded},tokenHint:o}}var j={state:`disabled`,mode:`embedded`,lastError:null,published:0,dropped:0,queued:0,consumers:[],since:0};function M(e,t){return{...e,...t,terminal:{...e.terminal,...t.terminal},panes:{...e.panes,...t.panes},editor:{...e.editor,...t.editor},typography:{...e.typography,...t.typography},providerDefaults:{claude:{...e.providerDefaults.claude,...t.providerDefaults?.claude,modelOptions:{...e.providerDefaults.claude.modelOptions,...t.providerDefaults?.claude?.modelOptions}},codex:{...e.providerDefaults.codex,...t.providerDefaults?.codex,modelOptions:{...e.providerDefaults.codex.modelOptions,...t.providerDefaults?.codex?.modelOptions}},openrouter:{...e.providerDefaults.openrouter,...t.providerDefaults?.openrouter,modelOptions:{}},custom:{...e.providerDefaults.custom,...t.providerDefaults?.custom,modelOptions:{}}},cloudflareTunnel:{...e.cloudflareTunnel,...t.cloudflareTunnel},push:{...e.push,...t.push},telemetry:{...e.telemetry,...t.telemetry},claudeAuth:{tokens:t.claudeAuth?.tokens??e.claudeAuth.tokens,concurrencyDefault:t.claudeAuth?.concurrencyDefault??e.claudeAuth.concurrencyDefault},auth:{...e.auth,...t.auth},uploads:{...e.uploads,...t.uploads},subagents:e.subagents,customMcpServers:e.customMcpServers,customBeacons:e.customBeacons,customModels:e.customModels,mcpSources:e.mcpSources,customProviders:e.customProviders,textSnippets:e.textSnippets,plugins:{...e.plugins,...t.plugins},installedPlugins:e.installedPlugins,remoteMcp:{...e.remoteMcp,...t.remoteMcp},serviceBus:A(e.serviceBus,t.serviceBus),claudeDriver:{lifecycle:{...e.claudeDriver.lifecycle,...t.claudeDriver?.lifecycle}},globalPromptAppend:t.globalPromptAppend??e.globalPromptAppend,subagentRuntime:{runTimeoutMs:t.subagentRuntime?.runTimeoutMs??e.subagentRuntime.runTimeoutMs,defaultLoopSubagentId:t.subagentRuntime?.defaultLoopSubagentId===void 0?e.subagentRuntime.defaultLoopSubagentId:t.subagentRuntime.defaultLoopSubagentId},packageUpdates:{...e.packageUpdates,...t.packageUpdates}}}var ee=e()(e=>({settings:null,hydrationStatus:`idle`,setHydrationStatus:t=>e({hydrationStatus:t}),setFromServer:t=>e({settings:t,hydrationStatus:`ready`}),applyOptimisticPatch:t=>e(e=>({settings:e.settings?M(e.settings,t):e.settings}))})),N=[],P=e=>e.settings?.customMcpServers??N,F=[],I=e=>e.settings?.customBeacons??F,L=[],R=e=>e.settings?.customModels??L,z=[],B=e=>e.settings?.mcpSources??z,V=[],H=e=>e.settings?.customProviders??V,U=[],W=e=>e.settings?.textSnippets??U,G=[],K=e=>e.settings?.plugins.enabled??!1,q=e=>e.settings?.installedPlugins??G,J=e=>e.settings?.remoteMcp??i,Y=e=>e.settings?.serviceBus??k,X=450,Z=`cursor`;function Q(e){return e===`vscode`?`code {path}`:e===`xcode`?`xed {path}`:e===`windsurf`?`windsurf {path}`:`cursor {path}`}var $=e=>e.settings?.terminal.scrollbackLines??1e3,te=e=>e.settings?.terminal.minColumnWidth??X,ne=e=>e.settings?.editor.preset??Z,re=e=>{let t=e.settings?.editor.preset??Z,n=(e.settings?.editor.commandTemplate)?.trim();return n&&n.length>0?n:Q(t)},ie=e=>e.settings?.chatSoundPreference??`always`,ae=e=>e.settings?.chatSoundId??`funk`;export{o as C,r as E,l as S,n as T,ee as _,R as a,c as b,ne as c,te as d,K as f,W as g,Y as h,P as i,q as l,$ as m,ie as n,H as o,J as p,I as r,re as s,ae as t,B as u,j as v,t as w,s as x,O as y};
1
+ import{c as e}from"./log-3sQ-5rrS.js";var t=1e3,n=5e3;function r(e){return Number.isFinite(e)?Math.min(n,Math.max(500,Math.round(e))):t}var i={enabled:!0,publicUrl:null};function a(e){if(e===`localhost`||e===`[::1]`)return!0;let t=e.split(`.`);return t.length===4&&t[0]===`127`&&t.every(e=>/^\d+$/.test(e)&&Number(e)<=255)}function o(e){if(e===null)return null;let t;try{t=new URL(e.trim())}catch{return null}return t.protocol===`https:`||t.protocol===`http:`&&a(t.hostname)?t.origin:null}function s(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function c(e){return Array.isArray(e)}function l(e){try{return JSON.parse(e)}catch{return null}}var u={enabled:!1,mode:`embedded`,url:`nats://127.0.0.1:4222`,stream:{name:`KANNA`,subjectPrefix:`kanna`,extraSubjects:[],retention:`limits`,storage:`file`,maxAgeDays:30,maxBytesMb:512,maxMsgs:-1,discard:`old`,duplicateWindowSec:120,replicas:1},consumers:[],embedded:{maxMemoryStoreMb:256,maxFileStoreMb:2048,port:`auto`,logLevel:`info`}},d={min:1,max:3650},f={min:1,max:1048576},p={min:0,max:7200},m={min:1,max:5},h={min:1,max:3600},g={min:1,max:1e6},_={min:16,max:1048576},v=/^[A-Za-z0-9_-]{1,64}$/,y=/^[a-z][a-z0-9_-]*$/,b=/^[A-Za-z0-9_-]+$/,x=/^(?:nats|tls|ws|wss):\/\/[^\s/]+$/;function S(e){return e.length<8?null:e.slice(-4)}function C(e){let t=e.split(`.`);return t.every((e,n)=>e===`>`?n===t.length-1:e===`*`||b.test(e))}function w(e,t){return Number.isInteger(e)&&e>=t.min&&e<=t.max}function T(e){let t=[];v.test(e.name)||t.push(`Stream name must be 1–64 letters, digits, - or _`),y.test(e.subjectPrefix)||t.push(`Subject prefix must start with a lowercase letter and use lowercase letters, digits, - or _`);for(let n of e.extraSubjects)C(n)||t.push(`Extra subject "${n}" is not a valid NATS subject`);return w(e.maxAgeDays,d)||t.push(`Max age must be 1–3650 days`),w(e.maxBytesMb,f)||t.push(`Max bytes must be 1–1048576 MB`),(!Number.isInteger(e.maxMsgs)||e.maxMsgs!==-1&&e.maxMsgs<1)&&t.push(`Max messages must be -1 (unlimited) or at least 1`),w(e.duplicateWindowSec,p)||t.push(`Duplicate window must be 0–7200 seconds`),w(e.replicas,m)||t.push(`Replicas must be 1–5`),t}function E(e){let t=[],n=new Set;for(let r of e)v.test(r.durableName)||t.push(`Consumer name "${r.durableName}" must be 1–64 letters, digits, - or _`),n.has(r.durableName)&&t.push(`Consumer name "${r.durableName}" is used twice`),n.add(r.durableName),r.filterSubject.length>0&&!C(r.filterSubject)&&t.push(`Consumer "${r.durableName}" filter is not a valid NATS subject`),w(r.ackWaitSec,h)||t.push(`Consumer "${r.durableName}" ack wait must be 1–3600 seconds`),w(r.maxAckPending,g)||t.push(`Consumer "${r.durableName}" max ack pending must be 1–1000000`);return t}function D(e){let t=[];return w(e.maxMemoryStoreMb,_)||t.push(`Memory store must be 16–1048576 MB`),w(e.maxFileStoreMb,_)||t.push(`File store must be 16–1048576 MB`),e.port!==`auto`&&!w(e.port,{min:1024,max:65535})&&t.push(`Port must be auto or 1024–65535`),t}function O(e){let t=[...T(e.stream),...E(e.consumers),...D(e.embedded)];return e.mode===`external`&&!x.test(e.url)&&t.push(`Server URL must look like nats://host:4222`),t}var k={...u,tokenHint:null};function A(e,t){if(t===void 0)return e;let{token:n,...r}=t,i=n?.trim()??``,a=i.length>0?S(i):e.tokenHint,o=n===null?null:a;return{...e,...r,stream:{...e.stream,...t.stream},consumers:t.consumers??e.consumers,embedded:{...e.embedded,...t.embedded},tokenHint:o}}var j={state:`disabled`,mode:`embedded`,lastError:null,published:0,dropped:0,queued:0,consumers:[],since:0};function M(e,t){return{...e,...t,terminal:{...e.terminal,...t.terminal},panes:{...e.panes,...t.panes},editor:{...e.editor,...t.editor},typography:{...e.typography,...t.typography},providerDefaults:{claude:{...e.providerDefaults.claude,...t.providerDefaults?.claude,modelOptions:{...e.providerDefaults.claude.modelOptions,...t.providerDefaults?.claude?.modelOptions}},codex:{...e.providerDefaults.codex,...t.providerDefaults?.codex,modelOptions:{...e.providerDefaults.codex.modelOptions,...t.providerDefaults?.codex?.modelOptions}},openrouter:{...e.providerDefaults.openrouter,...t.providerDefaults?.openrouter,modelOptions:{}},custom:{...e.providerDefaults.custom,...t.providerDefaults?.custom,modelOptions:{}}},cloudflareTunnel:{...e.cloudflareTunnel,...t.cloudflareTunnel},push:{...e.push,...t.push},telemetry:{...e.telemetry,...t.telemetry},claudeAuth:{tokens:t.claudeAuth?.tokens??e.claudeAuth.tokens,concurrencyDefault:t.claudeAuth?.concurrencyDefault??e.claudeAuth.concurrencyDefault},auth:{...e.auth,...t.auth},uploads:{...e.uploads,...t.uploads},subagents:e.subagents,customMcpServers:e.customMcpServers,customBeacons:e.customBeacons,customModels:e.customModels,mcpSources:e.mcpSources,customProviders:e.customProviders,textSnippets:e.textSnippets,plugins:{...e.plugins,...t.plugins},installedPlugins:e.installedPlugins,remoteMcp:{...e.remoteMcp,...t.remoteMcp},serviceBus:A(e.serviceBus,t.serviceBus),claudeDriver:{lifecycle:{...e.claudeDriver.lifecycle,...t.claudeDriver?.lifecycle}},globalPromptAppend:t.globalPromptAppend??e.globalPromptAppend,subagentRuntime:{runTimeoutMs:t.subagentRuntime?.runTimeoutMs??e.subagentRuntime.runTimeoutMs,defaultLoopSubagentId:t.subagentRuntime?.defaultLoopSubagentId===void 0?e.subagentRuntime.defaultLoopSubagentId:t.subagentRuntime.defaultLoopSubagentId},packageUpdates:{...e.packageUpdates,...t.packageUpdates}}}var ee=e()(e=>({settings:null,hydrationStatus:`idle`,setHydrationStatus:t=>e({hydrationStatus:t}),setFromServer:t=>e({settings:t,hydrationStatus:`ready`}),applyOptimisticPatch:t=>e(e=>({settings:e.settings?M(e.settings,t):e.settings}))})),N=[],P=e=>e.settings?.customMcpServers??N,F=[],I=e=>e.settings?.customBeacons??F,L=[],R=e=>e.settings?.customModels??L,z=[],B=e=>e.settings?.mcpSources??z,V=[],H=e=>e.settings?.customProviders??V,U=[],W=e=>e.settings?.textSnippets??U,G=[],K=e=>e.settings?.plugins.enabled??!1,q=e=>e.settings?.installedPlugins??G,J=e=>e.settings?.remoteMcp??i,Y=e=>e.settings?.serviceBus??k,X=450,Z=`cursor`;function Q(e){return e===`vscode`?`code {path}`:e===`xcode`?`xed {path}`:e===`windsurf`?`windsurf {path}`:`cursor {path}`}var $=e=>e.settings?.terminal.scrollbackLines??1e3,te=e=>e.settings?.terminal.minColumnWidth??X,ne=e=>e.settings?.editor.preset??Z,re=e=>{let t=e.settings?.editor.preset??Z,n=(e.settings?.editor.commandTemplate)?.trim();return n&&n.length>0?n:Q(t)},ie=e=>e.settings?.chatSoundPreference??`always`,ae=e=>e.settings?.chatSoundId??`funk`;export{o as C,r as E,l as S,n as T,ee as _,R as a,c as b,ne as c,te as d,K as f,W as g,Y as h,P as i,q as l,$ as m,ie as n,H as o,J as p,I as r,re as s,ae as t,B as u,j as v,t as w,s as x,O as y};
@@ -1 +1 @@
1
- import{f as e}from"./pendingActionsStore-DG0IogaL.js";var t={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};t.node;var n=e(t);export{n as t};
1
+ import{f as e}from"./pendingActionsStore-C9wopHr4.js";var t={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{B as e,H as t,I as n,k as r}from"./genui-0tseVHei.js";var i=`Other`;function a(e,t){let n=t.map(t=>r(e.metrics[t])),[i]=n;return n.every(e=>e.format===i?.format&&e.currency===i?.currency)}function o(e,t,r,i){let a=e.dimensions?.[t];return a?.kind===`time`?n(i,r.grain??a.grain??`month`):i}function s(e,t){let n=[];for(let r of e){let e=r.dimensions[t];e!==void 0&&!n.includes(e)&&n.push(e)}return n}function c(e,t,n){let r=e.dimensions?.[t]?.order;return[...n].sort((e,t)=>{let n=r?r.indexOf(e):-1,i=r?r.indexOf(t):-1;return n===i?e.localeCompare(t,`en`,{numeric:!0}):n===-1?1:i===-1?-1:n-i})}function l(e,t,n,r){let i=new Map;for(let r of e){let e=r.dimensions[t]??``;i.set(e,(i.get(e)??0)+Math.abs(r.values[n]??0))}let a=[...i.entries()].sort((e,t)=>t[1]-e[1]).map(([e])=>e);return new Set(a.length>r+1?a.slice(0,r):a)}function u(n,i,a,c){let l=s(a.rows,n.dimension);return{kind:n.chart,xOrder:l,xLabels:Object.fromEntries(l.map(e=>[e,o(i,n.dimension,a,e)])),format:r(i.metrics[c]),valueLabel:t(c,i.metrics[c]),dimensionLabel:e(n.dimension,i.dimensions?.[n.dimension])}}function d(e,t,n){let[r]=e.metrics;if(!r)return{ok:!1,message:`A chart needs a metric`};if(!a(t,[...e.metrics,...e.secondaryMetric?[e.secondaryMetric]:[]]))return{ok:!1,message:`These metrics use different units, and a chart has one axis. Show them in two charts.`};switch(e.chart){case`waterfall`:return m(e,t,n,r);case`composition`:return h(e,t,n,r);case`combo`:return p(e,t,n,r);default:return f(e,t,n)}}function f(e,n,r){let[a=``]=e.metrics;if(e.chart===`stacked-bar`&&!e.series&&e.metrics.length<2)return{ok:!1,message:`A stacked bar needs a series dimension or at least two metrics to stack`};if(e.series&&e.metrics.length>1)return{ok:!1,message:`Split by a series dimension with one metric, or list several metrics without a series`};let o=u(e,n,r,a),d=[],f=[];if(e.series){let t=e.series,u=l(r.rows,t,a,7),p=c(n,t,[...u]),m=s(r.rows,t).some(e=>!u.has(e));p.forEach((e,t)=>f.push({id:e,label:e,role:`series`,slot:t})),m&&f.push({id:i,label:i,role:`series`,slot:p.length});let h=new Map;for(let n of r.rows){let r=n.dimensions[e.dimension],o=n.dimensions[t]??``,s=n.values[a];if(r===void 0||s==null)continue;let c=`${r}\u0001${u.has(o)?o:i}`;h.set(c,(h.get(c)??0)+s)}for(let[e,t]of h){let[n=``,r=``]=e.split(``);d.push({x:n,xLabel:o.xLabels[n]??n,series:r,value:t})}return{ok:!0,model:{...o,points:d,series:f}}}e.metrics.forEach((e,r)=>{f.push({id:e,label:t(e,n.metrics[e]),role:`series`,slot:r})}),r.comparison&&e.metrics.forEach(e=>{f.push({id:`${e}::compare`,label:`${t(e,n.metrics[e])} (${r.comparison?.label})`,role:`compare`,slot:null})});for(let t of r.rows){let n=t.dimensions[e.dimension];if(n!==void 0)for(let r of e.metrics){let e=t.values[r];e!=null&&d.push({x:n,xLabel:o.xLabels[n]??n,series:r,value:e});let i=t.compare?.[r];i!=null&&d.push({x:n,xLabel:o.xLabels[n]??n,series:`${r}::compare`,value:i})}}return{ok:!0,model:{...o,points:d,series:f}}}function p(e,n,r,i){if(!e.secondaryMetric)return{ok:!1,message:`A combo chart needs a secondaryMetric drawn as a line over the bars`};let a=e.secondaryMetric,o=u(e,n,r,i),s=[];for(let t of r.rows){let n=t.dimensions[e.dimension];if(n===void 0)continue;let r=t.values[i],c=t.values[a];r!=null&&s.push({x:n,xLabel:o.xLabels[n]??n,series:i,value:r}),c!=null&&s.push({x:n,xLabel:o.xLabels[n]??n,series:a,value:c})}return{ok:!0,model:{...o,points:s,series:[{id:i,label:t(i,n.metrics[i]),role:`series`,slot:0},{id:a,label:t(a,n.metrics[a]),role:`secondary`,slot:1}]}}}function m(e,t,n,r){if(e.series)return{ok:!1,message:`A waterfall shows one metric; drop the series dimension`};let i=u(e,t,n,r),a=[],o=0;for(let t of n.rows){let n=t.dimensions[e.dimension],s=t.values[r];if(n===void 0||s==null)continue;let c=o;o+=s,a.push({x:n,xLabel:i.xLabels[n]??n,series:s>=0?`increase`:`decrease`,value:s,start:c,end:o})}let s=e.totalLabel??`Total`;return a.push({x:s,xLabel:s,series:`total`,value:o,start:0,end:o}),{ok:!0,model:{...i,points:a,xOrder:[...a.map(e=>e.x)],xLabels:{...i.xLabels,[s]:s},series:[{id:`increase`,label:`Increase`,role:`increase`,slot:null},{id:`decrease`,label:`Decrease`,role:`decrease`,slot:null},{id:`total`,label:s,role:`total`,slot:null}]}}}function h(e,t,n,r){let a=u(e,t,n,r),o=n.rows.map(t=>({key:t.dimensions[e.dimension]??``,value:t.values[r]??0})).filter(e=>e.value!==0);if(o.some(e=>e.value<0))return{ok:!1,message:`A part-to-whole chart cannot show negative values; use a bar chart`};let s=[...o].sort((e,t)=>t.value-e.value),l=s.length>6?s.slice(0,5):s,d=s.slice(l.length).reduce((e,t)=>e+t.value,0),f=c(t,e.dimension,l.map(e=>e.key)),p=new Map(l.map(e=>[e.key,e.value])),m=f.map((e,t)=>({id:e,label:a.xLabels[e]??e,role:`series`,slot:t})),h=f.map(e=>({x:e,xLabel:a.xLabels[e]??e,series:e,value:p.get(e)??0}));return d>0&&(m.push({id:i,label:i,role:`series`,slot:f.length}),h.push({x:i,xLabel:i,series:i,value:d})),{ok:!0,model:{...a,points:h,series:m,xOrder:h.map(e=>e.x)}}}function g(e,t){if(!t||t.x===void 0)return null;let n=String(t.x);return!e.xOrder.includes(n)||e.kind===`waterfall`&&n===e.xOrder[e.xOrder.length-1]?null:{x:n,series:t.series===void 0?``:String(t.series)}}export{d as n,g as t};
1
+ import{B as e,H as t,I as n,k as r}from"./genui-jdDJe0VI.js";var i=`Other`;function a(e,t){let n=t.map(t=>r(e.metrics[t])),[i]=n;return n.every(e=>e.format===i?.format&&e.currency===i?.currency)}function o(e,t,r,i){let a=e.dimensions?.[t];return a?.kind===`time`?n(i,r.grain??a.grain??`month`):i}function s(e,t){let n=[];for(let r of e){let e=r.dimensions[t];e!==void 0&&!n.includes(e)&&n.push(e)}return n}function c(e,t,n){let r=e.dimensions?.[t]?.order;return[...n].sort((e,t)=>{let n=r?r.indexOf(e):-1,i=r?r.indexOf(t):-1;return n===i?e.localeCompare(t,`en`,{numeric:!0}):n===-1?1:i===-1?-1:n-i})}function l(e,t,n,r){let i=new Map;for(let r of e){let e=r.dimensions[t]??``;i.set(e,(i.get(e)??0)+Math.abs(r.values[n]??0))}let a=[...i.entries()].sort((e,t)=>t[1]-e[1]).map(([e])=>e);return new Set(a.length>r+1?a.slice(0,r):a)}function u(n,i,a,c){let l=s(a.rows,n.dimension);return{kind:n.chart,xOrder:l,xLabels:Object.fromEntries(l.map(e=>[e,o(i,n.dimension,a,e)])),format:r(i.metrics[c]),valueLabel:t(c,i.metrics[c]),dimensionLabel:e(n.dimension,i.dimensions?.[n.dimension])}}function d(e,t,n){let[r]=e.metrics;if(!r)return{ok:!1,message:`A chart needs a metric`};if(!a(t,[...e.metrics,...e.secondaryMetric?[e.secondaryMetric]:[]]))return{ok:!1,message:`These metrics use different units, and a chart has one axis. Show them in two charts.`};switch(e.chart){case`waterfall`:return m(e,t,n,r);case`composition`:return h(e,t,n,r);case`combo`:return p(e,t,n,r);default:return f(e,t,n)}}function f(e,n,r){let[a=``]=e.metrics;if(e.chart===`stacked-bar`&&!e.series&&e.metrics.length<2)return{ok:!1,message:`A stacked bar needs a series dimension or at least two metrics to stack`};if(e.series&&e.metrics.length>1)return{ok:!1,message:`Split by a series dimension with one metric, or list several metrics without a series`};let o=u(e,n,r,a),d=[],f=[];if(e.series){let t=e.series,u=l(r.rows,t,a,7),p=c(n,t,[...u]),m=s(r.rows,t).some(e=>!u.has(e));p.forEach((e,t)=>f.push({id:e,label:e,role:`series`,slot:t})),m&&f.push({id:i,label:i,role:`series`,slot:p.length});let h=new Map;for(let n of r.rows){let r=n.dimensions[e.dimension],o=n.dimensions[t]??``,s=n.values[a];if(r===void 0||s==null)continue;let c=`${r}\u0001${u.has(o)?o:i}`;h.set(c,(h.get(c)??0)+s)}for(let[e,t]of h){let[n=``,r=``]=e.split(``);d.push({x:n,xLabel:o.xLabels[n]??n,series:r,value:t})}return{ok:!0,model:{...o,points:d,series:f}}}e.metrics.forEach((e,r)=>{f.push({id:e,label:t(e,n.metrics[e]),role:`series`,slot:r})}),r.comparison&&e.metrics.forEach(e=>{f.push({id:`${e}::compare`,label:`${t(e,n.metrics[e])} (${r.comparison?.label})`,role:`compare`,slot:null})});for(let t of r.rows){let n=t.dimensions[e.dimension];if(n!==void 0)for(let r of e.metrics){let e=t.values[r];e!=null&&d.push({x:n,xLabel:o.xLabels[n]??n,series:r,value:e});let i=t.compare?.[r];i!=null&&d.push({x:n,xLabel:o.xLabels[n]??n,series:`${r}::compare`,value:i})}}return{ok:!0,model:{...o,points:d,series:f}}}function p(e,n,r,i){if(!e.secondaryMetric)return{ok:!1,message:`A combo chart needs a secondaryMetric drawn as a line over the bars`};let a=e.secondaryMetric,o=u(e,n,r,i),s=[];for(let t of r.rows){let n=t.dimensions[e.dimension];if(n===void 0)continue;let r=t.values[i],c=t.values[a];r!=null&&s.push({x:n,xLabel:o.xLabels[n]??n,series:i,value:r}),c!=null&&s.push({x:n,xLabel:o.xLabels[n]??n,series:a,value:c})}return{ok:!0,model:{...o,points:s,series:[{id:i,label:t(i,n.metrics[i]),role:`series`,slot:0},{id:a,label:t(a,n.metrics[a]),role:`secondary`,slot:1}]}}}function m(e,t,n,r){if(e.series)return{ok:!1,message:`A waterfall shows one metric; drop the series dimension`};let i=u(e,t,n,r),a=[],o=0;for(let t of n.rows){let n=t.dimensions[e.dimension],s=t.values[r];if(n===void 0||s==null)continue;let c=o;o+=s,a.push({x:n,xLabel:i.xLabels[n]??n,series:s>=0?`increase`:`decrease`,value:s,start:c,end:o})}let s=e.totalLabel??`Total`;return a.push({x:s,xLabel:s,series:`total`,value:o,start:0,end:o}),{ok:!0,model:{...i,points:a,xOrder:[...a.map(e=>e.x)],xLabels:{...i.xLabels,[s]:s},series:[{id:`increase`,label:`Increase`,role:`increase`,slot:null},{id:`decrease`,label:`Decrease`,role:`decrease`,slot:null},{id:`total`,label:s,role:`total`,slot:null}]}}}function h(e,t,n,r){let a=u(e,t,n,r),o=n.rows.map(t=>({key:t.dimensions[e.dimension]??``,value:t.values[r]??0})).filter(e=>e.value!==0);if(o.some(e=>e.value<0))return{ok:!1,message:`A part-to-whole chart cannot show negative values; use a bar chart`};let s=[...o].sort((e,t)=>t.value-e.value),l=s.length>6?s.slice(0,5):s,d=s.slice(l.length).reduce((e,t)=>e+t.value,0),f=c(t,e.dimension,l.map(e=>e.key)),p=new Map(l.map(e=>[e.key,e.value])),m=f.map((e,t)=>({id:e,label:a.xLabels[e]??e,role:`series`,slot:t})),h=f.map(e=>({x:e,xLabel:a.xLabels[e]??e,series:e,value:p.get(e)??0}));return d>0&&(m.push({id:i,label:i,role:`series`,slot:f.length}),h.push({x:i,xLabel:i,series:i,value:d})),{ok:!0,model:{...a,points:h,series:m,xOrder:h.map(e=>e.x)}}}function g(e,t){if(!t||t.x===void 0)return null;let n=String(t.x);return!e.xOrder.includes(n)||e.kind===`waterfall`&&n===e.xOrder[e.xOrder.length-1]?null:{x:n,series:t.series===void 0?``:String(t.series)}}export{d as n,g as t};
@@ -1 +1 @@
1
- import{d as e}from"./log-DIu9xkUN.js";import{t}from"./timer.adapter-BX7oyt8G.js";import{t as n}from"./runDetached-CXTNs9Tz.js";var r={blow:`/chat-sounds/Blow.mp3`,bottle:`/chat-sounds/Bottle.mp3`,frog:`/chat-sounds/Frog.mp3`,funk:`/chat-sounds/Funk.mp3`,glass:`/chat-sounds/Glass.mp3`,ping:`/chat-sounds/Ping.mp3`,pop:`/chat-sounds/Pop.mp3`,purr:`/chat-sounds/Purr.mp3`,tink:`/chat-sounds/Tink.mp3`};function i(t=e){return t.getVisibilityState()!==`visible`||!t.hasFocus()}function a(e){let t=new Audio(r[e]);return t.preload=`auto`,t.play()}async function o(e,r,i=t){if(r<=0)return;let o=Array.from({length:r},(t,r)=>new Promise(t=>{i.setTimeout(()=>{n(`chat sound`,a(e).finally(()=>t()))},r*90)}));await Promise.all(o)}function s(t,n=e){return t===`never`?!1:t===`always`||i(n)}export{s as n,o as t};
1
+ import{d as e}from"./log-3sQ-5rrS.js";import{t}from"./timer.adapter-Di4tkt37.js";import{t as n}from"./runDetached-BBRv1zoc.js";var r={blow:`/chat-sounds/Blow.mp3`,bottle:`/chat-sounds/Bottle.mp3`,frog:`/chat-sounds/Frog.mp3`,funk:`/chat-sounds/Funk.mp3`,glass:`/chat-sounds/Glass.mp3`,ping:`/chat-sounds/Ping.mp3`,pop:`/chat-sounds/Pop.mp3`,purr:`/chat-sounds/Purr.mp3`,tink:`/chat-sounds/Tink.mp3`};function i(t=e){return t.getVisibilityState()!==`visible`||!t.hasFocus()}function a(e){let t=new Audio(r[e]);return t.preload=`auto`,t.play()}async function o(e,r,i=t){if(r<=0)return;let o=Array.from({length:r},(t,r)=>new Promise(t=>{i.setTimeout(()=>{n(`chat sound`,a(e).finally(()=>t()))},r*90)}));await Promise.all(o)}function s(t,n=e){return t===`never`?!1:t===`always`||i(n)}export{s as n,o as t};
@@ -0,0 +1 @@
1
+ import{f as e}from"./pendingActionsStore-C9wopHr4.js";var t={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};t.node;var n=e(t);export{n as t};
@@ -0,0 +1 @@
1
+ import{f as e}from"./pendingActionsStore-C9wopHr4.js";var t={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{f as e}from"./pendingActionsStore-DG0IogaL.js";var t={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};t.node;var n=e(t),r={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};r.node;var i=e(r),a={writeText(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API not available`)):navigator.clipboard.writeText(e)},readText(){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API not available`)):navigator.clipboard.readText()}};export{i as n,n as r,a as t};
1
+ import{f as e}from"./pendingActionsStore-C9wopHr4.js";var t={name:`check`,size:24,node:[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]};t.node;var n=e(t),r={name:`copy`,size:24,node:[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]};r.node;var i=e(r),a={writeText(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API not available`)):navigator.clipboard.writeText(e)},readText(){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API not available`)):navigator.clipboard.readText()}};export{i as n,n as r,a as t};
@@ -1 +1 @@
1
- import{c as e}from"./log-DIu9xkUN.js";var t=[];function n(e,t){return`${e}:${t}`}var r=e()(e=>({boardsByOwner:{},viewByBoard:{},pageSizeByBoard:{},setBoards:(t,n)=>e(e=>({boardsByOwner:{...e.boardsByOwner,[t]:n}})),setBoardView:(t,n)=>e(e=>({viewByBoard:{...e.viewByBoard,[t]:n}})),growPage:t=>e(e=>{let n=e.viewByBoard[t];if(n&&!Object.values(n.cursors).some(e=>e!==null))return e;let r=e.pageSizeByBoard[t]??30;return{pageSizeByBoard:{...e.pageSizeByBoard,[t]:r+30}}}),clearBoardView:t=>e(e=>{if(!(t in e.viewByBoard))return e;let n={...e.viewByBoard};delete n[t];let r={...e.pageSizeByBoard};return delete r[t],{viewByBoard:n,pageSizeByBoard:r}})}));function i(e){return n=>n.boardsByOwner[e]??t}function a(e){return t=>t.viewByBoard[e]??null}function o(e){return t=>t.pageSizeByBoard[e]??30}var s={"muted-icon":`bg-muted-icon`,info:`bg-info`,success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`};function c(e,t){return t!==null&&e>t}export{a,o as i,c as n,i as o,n as r,r as s,s as t};
1
+ import{c as e}from"./log-3sQ-5rrS.js";var t=[];function n(e,t){return`${e}:${t}`}var r=e()(e=>({boardsByOwner:{},viewByBoard:{},pageSizeByBoard:{},setBoards:(t,n)=>e(e=>({boardsByOwner:{...e.boardsByOwner,[t]:n}})),setBoardView:(t,n)=>e(e=>({viewByBoard:{...e.viewByBoard,[t]:n}})),growPage:t=>e(e=>{let n=e.viewByBoard[t];if(n&&!Object.values(n.cursors).some(e=>e!==null))return e;let r=e.pageSizeByBoard[t]??30;return{pageSizeByBoard:{...e.pageSizeByBoard,[t]:r+30}}}),clearBoardView:t=>e(e=>{if(!(t in e.viewByBoard))return e;let n={...e.viewByBoard};delete n[t];let r={...e.pageSizeByBoard};return delete r[t],{viewByBoard:n,pageSizeByBoard:r}})}));function i(e){return n=>n.boardsByOwner[e]??t}function a(e){return t=>t.viewByBoard[e]??null}function o(e){return t=>t.pageSizeByBoard[e]??30}var s={"muted-icon":`bg-muted-icon`,info:`bg-info`,success:`bg-success`,warning:`bg-warning`,destructive:`bg-destructive`};function c(e,t){return t!==null&&e>t}export{a,o as i,c as n,i as o,n as r,r as s,s as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{p as r}from"./log-DIu9xkUN.js";import{c as i,l as a,n as o}from"./state-mark-Cpr4kZpE.js";function s(e){if(e==null)return null;switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:null}if(Array.isArray(e))return e.map(e=>s(e));if(r(e)){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=s(r));return t}return null}var c=e(t(),1),l=e=>Symbol.iterator in e,u=e=>`entries`in e,d=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},f=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function p(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:l(e)&&l(t)?u(e)&&u(t)?d(e,t):f(e,t):d({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function m(e){let t=c.useRef(void 0);return n=>{let r=e(n);return p(t.current,r)?t.current:t.current=r}}var h=e(n(),1);function g({tone:e,label:t}){return(0,h.jsx)(o,{tone:e,label:t})}function _({status:e}){return(0,h.jsx)(g,{tone:a(e),label:i(e)})}function v(e,t,n){let r=typeof e.maxTokens==`number`&&Number.isFinite(e.maxTokens)?e.maxTokens:null,i=r&&r>0?Math.min(100,e.usedTokens/r*100):null,a=r===null?null:Math.max(0,Math.round(r-e.usedTokens)),o=i===null?null:Math.max(0,100-i);return{...e,compactsAutomatically:e.compactsAutomatically||n,maxTokens:r??void 0,remainingTokens:a,usedPercentage:i,remainingPercentage:o,updatedAt:t}}function y(e){let t=e.some(e=>e.kind===`compact_boundary`||e.kind===`compact_summary`||e.kind===`context_cleared`);for(let n=e.length-1;n>=0;--n){let r=e[n];if(r&&!(r.kind!==`context_window_updated`||r.usage.usedTokens<=0))return v(r.usage,new Date(r.createdAt).toISOString(),t)}return null}function b(e,t){return!e||t===null||!Number.isFinite(t)||t<=0?e:v({...e,maxTokens:t},e.updatedAt,e.compactsAutomatically)}function x(e){return e===void 0||!Number.isFinite(e)||e<0?0:e}function S(e,t){let n=0,r=0,i=0,a=0;for(let t of e){if(t.kind!==`result`)continue;let e=t.usage;e&&(n+=x(e.inputTokens),r+=x(e.outputTokens),i+=x(e.cachedInputTokens)),a+=x(t.costUsd??e?.costUsd)}for(let e of t){let t=e.usage;t&&(n+=x(t.inputTokens),r+=x(t.outputTokens),i+=x(t.cachedInputTokens),a+=x(t.costUsd))}if(n===0&&r===0&&i===0&&a===0)return null;let o=n>0?i/n*100:null;return{inputTokens:n,outputTokens:r,cachedTokens:i,costUsd:a,cacheHitPercentage:o}}function C(e){return!Number.isFinite(e)||e<=0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function w(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}m`}export{b as a,m as c,C as i,s as l,y as n,g as o,w as r,_ as s,S as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{p as r}from"./log-3sQ-5rrS.js";import{c as i,l as a,n as o}from"./state-mark-DNAt8L4c.js";function s(e){if(e==null)return null;switch(typeof e){case`string`:case`boolean`:return e;case`number`:return Number.isFinite(e)?e:null}if(Array.isArray(e))return e.map(e=>s(e));if(r(e)){let t={};for(let[n,r]of Object.entries(e))r!==void 0&&(t[n]=s(r));return t}return null}var c=e(t(),1),l=e=>Symbol.iterator in e,u=e=>`entries`in e,d=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},f=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function p(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:l(e)&&l(t)?u(e)&&u(t)?d(e,t):f(e,t):d({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function m(e){let t=c.useRef(void 0);return n=>{let r=e(n);return p(t.current,r)?t.current:t.current=r}}var h=e(n(),1);function g({tone:e,label:t}){return(0,h.jsx)(o,{tone:e,label:t})}function _({status:e}){return(0,h.jsx)(g,{tone:a(e),label:i(e)})}function v(e,t,n){let r=typeof e.maxTokens==`number`&&Number.isFinite(e.maxTokens)?e.maxTokens:null,i=r&&r>0?Math.min(100,e.usedTokens/r*100):null,a=r===null?null:Math.max(0,Math.round(r-e.usedTokens)),o=i===null?null:Math.max(0,100-i);return{...e,compactsAutomatically:e.compactsAutomatically||n,maxTokens:r??void 0,remainingTokens:a,usedPercentage:i,remainingPercentage:o,updatedAt:t}}function y(e){let t=e.some(e=>e.kind===`compact_boundary`||e.kind===`compact_summary`||e.kind===`context_cleared`);for(let n=e.length-1;n>=0;--n){let r=e[n];if(r&&!(r.kind!==`context_window_updated`||r.usage.usedTokens<=0))return v(r.usage,new Date(r.createdAt).toISOString(),t)}return null}function b(e,t){return!e||t===null||!Number.isFinite(t)||t<=0?e:v({...e,maxTokens:t},e.updatedAt,e.compactsAutomatically)}function x(e){return e===void 0||!Number.isFinite(e)||e<0?0:e}function S(e,t){let n=0,r=0,i=0,a=0;for(let t of e){if(t.kind!==`result`)continue;let e=t.usage;e&&(n+=x(e.inputTokens),r+=x(e.outputTokens),i+=x(e.cachedInputTokens)),a+=x(t.costUsd??e?.costUsd)}for(let e of t){let t=e.usage;t&&(n+=x(t.inputTokens),r+=x(t.outputTokens),i+=x(t.cachedInputTokens),a+=x(t.costUsd))}if(n===0&&r===0&&i===0&&a===0)return null;let o=n>0?i/n*100:null;return{inputTokens:n,outputTokens:r,cachedTokens:i,costUsd:a,cacheHitPercentage:o}}function C(e){return!Number.isFinite(e)||e<=0?`$0.00`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function w(e){return e==null||!Number.isFinite(e)?`0`:e<1e3?`${Math.round(e)}`:e<1e4?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:e<1e6?`${Math.round(e/1e3)}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,``)}m`}export{b as a,m as c,C as i,s as l,y as n,g as o,w as r,_ as s,S as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{Pt as r}from"./useAppGlobalState-NukFv4HT.js";import{c as i}from"./log-DIu9xkUN.js";import{c as a,f as o}from"./pendingActionsStore-DG0IogaL.js";import{Bt as s,Vt as c}from"./lexicalToReact-Ce76aPsW.js";import{t as l}from"./search-D4Ge6Hht.js";import{t as u}from"./timer.adapter-BX7oyt8G.js";import{t as d}from"./createScopedStore-SnvtxVfu.js";import{_ as f,a as p}from"./appSettingsStore-CRg6ywgC.js";import{D as m,S as h,g,h as ee,m as te}from"./types-C-hQn4rL.js";import{m as ne}from"./KannaSocketProvider-Qy4JOiDr.js";import{n as _,r as v,t as y}from"./popover-H1bnfjIL.js";var b={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};b.node;var x=o(b),S={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};S.node;var C=o(S),w={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};w.node;var T=o(w),E={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};E.node;var D=o(E),O={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};O.node;var k=o(O),A={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};A.node;var j=o(A),M={name:`radio`,size:24,node:[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};M.node;var N=o(M),P={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};P.node;var F=o(P),I={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};I.node;var L=o(I),R={name:`square-menu`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 8h10`,key:`1jw688`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]],aliases:[`menu-square`]};R.node;var z=o(R),B={name:`square-minus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-square`]};B.node;var V=o(B);function re(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(200,Math.max(60,Math.round(t))):60}var H=e(t(),1),U=d(`InputPopover`,()=>e=>({open:!1,setOpen:t=>e({open:t})}));function ie(){return e=>({open:!1,query:``,setQuery:t=>e({query:t}),setPopoverOpen:t=>e(t?{open:!0}:{open:!1,query:``}),closeAndClearQuery:()=>e({open:!1,query:``})})}var W=d(`SearchableModelPopover`,ie),G=e(n(),1),ae=[],oe={openrouter:`Loading models… verify OpenRouter API key in Settings.`,custom:`No models configured. Add an endpoint in Settings → Providers.`};function se({className:e,...t}){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:a(`shrink-0`,e),...t,children:(0,G.jsx)(`path`,{d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`})})}function ce({className:e,...t}){return(0,G.jsx)(`svg`,{viewBox:`0 0 158.7128 157.296`,fill:`currentColor`,"aria-hidden":`true`,className:a(`shrink-0`,e),...t,children:(0,G.jsx)(`path`,{d:`M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z`})})}function le({className:e,...t}){return(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a(`shrink-0`,e),...t,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,G.jsx)(`path`,{d:`M6.3 6.3a8 8 0 1 0 11.4 11.4`}),(0,G.jsx)(`path`,{d:`M17.7 6.3a8 8 0 0 1 0 11.4`}),(0,G.jsx)(`path`,{d:`M2 12h4`}),(0,G.jsx)(`path`,{d:`M18 12h4`})]})}var K={claude:se,codex:ce,openrouter:le,custom:F};function q({onClick:e,selected:t,icon:n,label:r,description:i,disabled:o}){return(0,G.jsxs)(`button`,{onClick:e,disabled:o,className:a(`w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity`,t?`bg-muted border-border`:`hover:opacity-60`,o&&`opacity-40 cursor-not-allowed`),children:[n,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:r}),i?(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i}):null]})]})}function J({trigger:e,triggerClassName:t,disabled:n=!1,children:r}){return n?(0,G.jsx)(`button`,{disabled:!0,className:a(`flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap`,t),children:e}):(0,G.jsx)(U.Provider,{init:void 0,children:(0,G.jsx)(ue,{trigger:e,triggerClassName:t,children:r})})}function ue({trigger:e,triggerClassName:t,children:n}){let r=U.useScopedStore(e=>e.open),i=U.useScopedStore(e=>e.setOpen);return(0,G.jsxs)(y,{open:r,onOpenChange:i,children:[(0,G.jsx)(v,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,className:a(`flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap`,`hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t),children:e})}),(0,G.jsx)(_,{align:`center`,className:`w-64 p-1`,children:(0,G.jsx)(`div`,{className:`space-y-1`,children:typeof n==`function`?n(()=>i(!1)):n})})]})}function de({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){return(0,G.jsx)(W.Provider,{init:void 0,children:(0,G.jsx)(fe,{models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i})})}function fe({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){let o=W.useScopedStore(e=>e.open),s=W.useScopedStore(e=>e.query),c=W.useScopedStore(e=>e.setPopoverOpen),u=W.useScopedStore(e=>e.setQuery),d=W.useScopedStore(e=>e.closeAndClearQuery),f=(0,H.useCallback)(e=>{n(e),d()},[n,d]),p=e.find(e=>e.id===t)?.label??t,m=(0,H.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)):e},[e,s]),h;return h=e.length===0?(0,G.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:i}):m.length===0?(0,G.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:`No matches`}):m.map(e=>(0,G.jsx)(q,{onClick:()=>f(e.id),selected:t===e.id,icon:(0,G.jsx)(C,{className:`h-4 w-4 text-muted-foreground`}),label:e.label,description:e.id},e.id)),(0,G.jsxs)(y,{open:o,onOpenChange:c,children:[(0,G.jsx)(v,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:a(`flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap`,`hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),children:[(0,G.jsx)(r,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{className:`max-w-[200px] truncate`,children:p})]})}),(0,G.jsxs)(_,{align:`center`,className:`w-80 p-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border/50`,children:[(0,G.jsx)(l,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,G.jsx)(`input`,{type:`text`,value:s,onChange:e=>u(e.target.value),placeholder:`Search models...`,autoFocus:!0,className:`flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,G.jsx)(`div`,{className:`max-h-72 overflow-y-auto py-1 space-y-1`,children:h})]})]})}function pe({availableProviders:e,selectedProvider:t,showProviderPicker:n=!0,showCodexCliRequirementHints:r=!1,model:i,modelOptions:o,onProviderChange:l,onModelChange:u,onModelOptionChange:d,planMode:_=!1,onPlanModeChange:v,includePlanMode:y=!0,className:b}){let x=f(p),S=e.find(e=>e.id===t)??e[0],w=S?.id??t,E=K[w],D=C,O=y&&S?.supportsPlanMode&&v,A=w===`claude`&&`contextWindow`in o?o:null,M=w===`codex`&&`fastMode`in o?o:null,N=S?.models??ae,P=N.find(e=>e.id===i)?.contextWindowOptions??[],F=A?.contextWindow??te[0].id,I=F===`1m`?z:V,L=N.find(e=>e.id===i)?.label??i,R=m(w)?(0,G.jsx)(de,{models:N,selectedModel:i,onSelect:e=>u?.(w,e),ModelIcon:D,emptyMessage:oe[w]}):(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:L})]}),children:e=>N.map(t=>{let n=C;return(0,G.jsx)(q,{onClick:()=>{u?.(w,t.id),e()},selected:i===t.id,icon:(0,G.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:r&&w===`codex`&&t.id===`gpt-5.5`?(0,G.jsxs)(G.Fragment,{children:[t.label,` `,(0,G.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`codex-cli >= 0.124`})]}):t.label},t.id)})});return(0,G.jsxs)(`div`,{className:a(`flex md:justify-center items-center gap-0.5`,b),children:[n?(0,G.jsx)(J,{disabled:!l,trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:S?.label??w})]}),children:t=>e.map(e=>{let n=K[e.id];return(0,G.jsx)(q,{onClick:()=>{l?.(e.id),t()},selected:w===e.id,icon:(0,G.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)})}):null,u==null?(0,G.jsx)(ne,{label:`Model is locked while a cron job is running — pause or remove the cron job to change it`,side:`top`,children:(0,G.jsxs)(`span`,{"aria-disabled":`true`,className:`flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap`,children:[(0,G.jsx)(j,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:L})]})}):R,m(w)?null:(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(c,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:w===`claude`?ee.find(e=>e.id===o.reasoningEffort)?.label??o.reasoningEffort:g.find(e=>e.id===o.reasoningEffort)?.label??o.reasoningEffort})]}),children:e=>w===`claude`?h(i,x).map(t=>(0,G.jsx)(q,{onClick:()=>{d({type:`claudeReasoningEffort`,effort:t.id}),e()},selected:o.reasoningEffort===t.id,icon:(0,G.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id)):g.map(t=>(0,G.jsx)(q,{onClick:()=>{d({type:`codexReasoningEffort`,effort:t.id}),e()},selected:o.reasoningEffort===t.id,icon:(0,G.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id))}),w===`claude`&&P.length>1?(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(I,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:P.find(e=>e.id===F)?.label??F})]}),children:e=>P.map(t=>(0,G.jsx)(q,{onClick:()=>{d({type:`contextWindow`,contextWindow:t.id}),e()},selected:F===t.id,icon:t.id===`1m`?(0,G.jsx)(z,{className:`h-4 w-4 text-muted-foreground`}):(0,G.jsx)(V,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.id===`1m`?`Expanded context window`:`Standard context window`},t.id))}):null,w===`codex`?(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[M?.fastMode?(0,G.jsx)(T,{className:`h-3.5 w-3.5`}):(0,G.jsx)(T,{className:`h-3.5 w-3.5 -scale-x-100`}),(0,G.jsx)(`span`,{children:M?.fastMode?`Fast Mode`:`Standard`})]}),triggerClassName:M?.fastMode?`text-success-text`:void 0,children:e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{onClick:()=>{d({type:`fastMode`,fastMode:!1}),e()},selected:!M?.fastMode,icon:(0,G.jsx)(T,{className:`h-4 w-4 text-muted-foreground -scale-x-100`}),label:`Standard`}),(0,G.jsx)(q,{onClick:()=>{d({type:`fastMode`,fastMode:!0}),e()},selected:!!M?.fastMode,icon:(0,G.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),label:`Fast Mode`})]})}):null,O?(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[_?(0,G.jsx)(s,{className:`h-3.5 w-3.5`}):(0,G.jsx)(k,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:_?`Plan Mode`:`Full Access`})]}),triggerClassName:_?`text-info-text`:void 0,children:e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{onClick:()=>{v(!1),e()},selected:!_,icon:(0,G.jsx)(k,{className:`h-4 w-4 text-muted-foreground`}),label:`Full Access`,description:`Execution without approval`}),(0,G.jsx)(q,{onClick:()=>{v(!0),e()},selected:_,icon:(0,G.jsx)(s,{className:`h-4 w-4 text-muted-foreground`}),label:`Plan Mode`,description:`Review a plan before execution`})]})}):null]})}var me=/^[a-z0-9][a-z0-9_-]{0,39}$/,he=`beacon/`,ge=`(^|[\\s\\n\\t])@beacon/([A-Za-z0-9][A-Za-z0-9_-]*)`;function _e(){return new RegExp(ge,`g`)}function ve(e){return e.length===0?`Short name is required`:e.length>40?`Short name must be at most 40 characters`:me.test(e)?null:`Use lowercase letters, digits, - and _, starting with a letter or digit`}function ye(e){return e.alias??e.label}var be=/[^a-z0-9_-]+/g,Y=/^[-_]+|[-_]+$/g;function xe(e){let t=e.toLowerCase().replace(be,`-`).replace(Y,``).slice(0,40).replace(Y,``);return t.length>0?t:`beacon`}function Se(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`}function X(e){let t=[...e].sort((e,t)=>e.id.localeCompare(t.id)),n=new Map,r=new Map;for(let e of t)e.alias!==void 0&&e.alias!==null&&(r.has(e.alias)||(n.set(e.id,e.alias),r.set(e.alias,e.id)));for(let e of t){if(n.has(e.id))continue;let t=Se(xe(e.label),r);n.set(e.id,t),r.set(t,e.id)}return{handleByBeaconId:n,beaconIdByHandle:r}}function Ce(e){let t=[];for(let n of e.matchAll(_e())){let e=n[2];e!==void 0&&t.push(e.toLowerCase())}return t}function we(e,t){let n=Ce(e);if(n.length===0)return{beacons:[],unresolvedHandles:[]};let{beaconIdByHandle:r}=X(t),i=new Map(t.map(e=>[e.id,e])),a=[],o=[],s=new Set;for(let e of n){let t=r.get(e),n=t===void 0?void 0:i.get(t);if(n===void 0){o.includes(e)||o.push(e);continue}s.has(n.id)||(s.add(n.id),a.push(n))}return{beacons:a,unresolvedHandles:o}}var Te=[{value:`cursor`,label:`Cursor`},{value:`xcode`,label:`Xcode`},{value:`windsurf`,label:`Windsurf`},{value:`custom`,label:`Custom`}],Z={cursor:`/editor-icons/cursor.png`,defaultApp:`/editor-icons/default-app.png`,finder:`/editor-icons/finder.png`,preview:`/editor-icons/preview.png`,xcode:`/editor-icons/xcode.png`,terminal:`/editor-icons/terminal.png`,windsurf:`/editor-icons/windsurf.png`,custom:`/editor-icons/custom.png`};function Q({src:e,className:t}){return(0,G.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,draggable:!1,className:t})}function Ee({preset:e,className:t}){switch(e){case`xcode`:return(0,G.jsx)(Q,{src:Z.xcode,className:t});case`windsurf`:return(0,G.jsx)(Q,{src:Z.windsurf,className:t});case`custom`:return(0,G.jsx)(Q,{src:Z.custom,className:t});default:return(0,G.jsx)(Q,{src:Z.cursor,className:t})}}function De({className:e}){return(0,G.jsx)(Q,{src:Z.finder,className:e})}function Oe({className:e}){return(0,G.jsx)(Q,{src:Z.preview,className:e})}function ke({className:e}){return(0,G.jsx)(Q,{src:Z.defaultApp,className:e})}function Ae({className:e}){return(0,G.jsx)(r,{className:e})}function je({className:e}){return(0,G.jsx)(Q,{src:Z.terminal,className:e})}var Me=2e3,Ne={},$=i()((e,t)=>({copiedTokens:Ne,nextToken:1,markCopied:n=>{let r=t().nextToken;return e(e=>({nextToken:r+1,copiedTokens:{...e.copiedTokens,[n]:r}})),r},clearCopied:(n,r)=>{let{copiedTokens:i}=t();if(i[n]!==r)return;let a=Object.fromEntries(Object.entries(i).filter(([e])=>e!==n));e({copiedTokens:Object.keys(a).length>0?a:Ne})}}));async function Pe(e,t,n=u){await t();let r=$.getState().markCopied(e);n.setTimeout(()=>$.getState().clearCopied(e,r),Me)}function Fe(e){return $(t=>t.copiedTokens[e]!==void 0)}export{x as C,D as S,re as _,Ee as a,N as b,Oe as c,ye as d,X as f,q as g,pe as h,Te as i,je as l,ve as m,Fe as n,De as o,we as p,ke as r,Ae as s,Pe as t,he as u,L as v,j as x,F as y};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{Pt as r}from"./useAppGlobalState-C6_aikPC.js";import{c as i}from"./log-3sQ-5rrS.js";import{c as a,f as o}from"./pendingActionsStore-C9wopHr4.js";import{Bt as s,Vt as c}from"./lexicalToReact-CkI42EHr.js";import{t as l}from"./search-48C1GM_8.js";import{t as u}from"./timer.adapter-Di4tkt37.js";import{t as d}from"./createScopedStore-D1trFyJw.js";import{_ as f,a as p}from"./appSettingsStore-CDBkjKuH.js";import{D as m,S as h,g,h as ee,m as te}from"./types-C-hQn4rL.js";import{m as ne}from"./KannaSocketProvider-Clv949La.js";import{n as _,r as v,t as y}from"./popover-CA332KD1.js";var b={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};b.node;var x=o(b),S={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};S.node;var C=o(S),w={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};w.node;var T=o(w),E={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};E.node;var D=o(E),O={name:`lock-open`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 9.9-1`,key:`1mm8w8`}]],aliases:[`unlock`]};O.node;var k=o(O),A={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};A.node;var j=o(A),M={name:`radio`,size:24,node:[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]};M.node;var N=o(M),P={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};P.node;var F=o(P),I={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]};I.node;var L=o(I),R={name:`square-menu`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 8h10`,key:`1jw688`}],[`path`,{d:`M7 12h10`,key:`b7w52i`}],[`path`,{d:`M7 16h10`,key:`wp8him`}]],aliases:[`menu-square`]};R.node;var z=o(R),B={name:`square-minus`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]],aliases:[`minus-square`]};B.node;var V=o(B);function re(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(200,Math.max(60,Math.round(t))):60}var H=e(t(),1),U=d(`InputPopover`,()=>e=>({open:!1,setOpen:t=>e({open:t})}));function ie(){return e=>({open:!1,query:``,setQuery:t=>e({query:t}),setPopoverOpen:t=>e(t?{open:!0}:{open:!1,query:``}),closeAndClearQuery:()=>e({open:!1,query:``})})}var W=d(`SearchableModelPopover`,ie),G=e(n(),1),ae=[],oe={openrouter:`Loading models… verify OpenRouter API key in Settings.`,custom:`No models configured. Add an endpoint in Settings → Providers.`};function se({className:e,...t}){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:a(`shrink-0`,e),...t,children:(0,G.jsx)(`path`,{d:`M17.3041 3.541h-3.6718l6.696 16.918H24Zm-10.6082 0L0 20.459h3.7442l1.3693-3.5527h7.0052l1.3693 3.5528h3.7442L10.5363 3.5409Zm-.3712 10.2232 2.2914-5.9456 2.2914 5.9456Z`})})}function ce({className:e,...t}){return(0,G.jsx)(`svg`,{viewBox:`0 0 158.7128 157.296`,fill:`currentColor`,"aria-hidden":`true`,className:a(`shrink-0`,e),...t,children:(0,G.jsx)(`path`,{d:`M60.8734 57.2556V42.3124c0-1.2586.4722-2.2029 1.5728-2.8314l30.0443-17.3023c4.0899-2.3593 8.9662-3.4599 13.9988-3.4599 18.8759 0 30.8307 14.6289 30.8307 30.2006 0 1.1007 0 2.3593-.158 3.6178l-31.1446-18.2467c-1.8872-1.1006-3.7754-1.1006-5.6629 0L60.8734 57.2556Zm70.1542 58.2005V79.7487c0-2.2028-.9446-3.7756-2.8318-4.8763l-39.481-22.9651 12.8982-7.3934c1.1007-.6285 2.0453-.6285 3.1458 0l30.0441 17.3024c8.6523 5.0341 14.4708 15.7296 14.4708 26.1107 0 11.9539-7.0769 22.965-18.2461 27.527ZM51.593 83.9964l-12.8982-7.5497c-1.1007-.6285-1.5728-1.5728-1.5728-2.8314V39.0105c0-16.8303 12.8982-29.5722 30.3585-29.5722 6.607 0 12.7403 2.2029 17.9324 6.1349l-30.987 17.9324c-1.8871 1.1007-2.8314 2.6735-2.8314 4.8764v45.6159ZM79.3562 100.0403 60.8733 89.6592V67.6383l18.4829-10.3811 18.4812 10.3811v22.0209l-18.4812 10.3811Zm11.8757 47.8188c-6.607 0-12.7403-2.2031-17.9324-6.1344l30.9866-17.9333c1.8872-1.1005 2.8318-2.6728 2.8318-4.8759v-45.616l13.0564 7.5498c1.1005.6285 1.5723 1.5728 1.5723 2.8314v34.6051c0 16.8297-13.0564 29.5723-30.5147 29.5723ZM53.9522 112.7822 23.9079 95.4798c-8.652-5.0343-14.471-15.7296-14.471-26.1107 0-12.1119 7.2356-22.9652 18.403-27.5272v35.8634c0 2.2028.9443 3.7756 2.8314 4.8763l39.3248 22.8068-12.8982 7.3938c-1.1007.6287-2.045.6287-3.1456 0ZM52.2229 138.5791c-17.7745 0-30.8306-13.3713-30.8306-29.8871 0-1.2585.1578-2.5169.3143-3.7754l30.987 17.9323c1.8871 1.1005 3.7757 1.1005 5.6628 0l39.4811-22.807v14.9435c0 1.2585-.4721 2.2021-1.5728 2.8308l-30.0443 17.3025c-4.0898 2.359-8.9662 3.4605-13.9989 3.4605h.0014ZM91.2319 157.296c19.0327 0 34.9188-13.5272 38.5383-31.4594 17.6164-4.562 28.9425-21.0779 28.9425-37.908 0-11.0112-4.719-21.7066-13.2133-29.4143.7867-3.3035 1.2595-6.607 1.2595-9.909 0-22.4929-18.2471-39.3247-39.3251-39.3247-4.2461 0-8.3363.6285-12.4262 2.045-7.0792-6.9213-16.8318-11.3254-27.5271-11.3254-19.0331 0-34.9191 13.5268-38.5384 31.4591C11.3255 36.0212 0 52.5373 0 69.3675c0 11.0112 4.7184 21.7065 13.2125 29.4142-.7865 3.3035-1.2586 6.6067-1.2586 9.9092 0 22.4923 18.2466 39.3241 39.3248 39.3241 4.2462 0 8.3362-.6277 12.426-2.0441 7.0776 6.921 16.8302 11.3251 27.5271 11.3251Z`})})}function le({className:e,...t}){return(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a(`shrink-0`,e),...t,children:[(0,G.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,G.jsx)(`path`,{d:`M6.3 6.3a8 8 0 1 0 11.4 11.4`}),(0,G.jsx)(`path`,{d:`M17.7 6.3a8 8 0 0 1 0 11.4`}),(0,G.jsx)(`path`,{d:`M2 12h4`}),(0,G.jsx)(`path`,{d:`M18 12h4`})]})}var K={claude:se,codex:ce,openrouter:le,custom:F};function q({onClick:e,selected:t,icon:n,label:r,description:i,disabled:o}){return(0,G.jsxs)(`button`,{onClick:e,disabled:o,className:a(`w-full flex items-center gap-2 p-2 border border-border/0 rounded-lg text-left transition-opacity`,t?`bg-muted border-border`:`hover:opacity-60`,o&&`opacity-40 cursor-not-allowed`),children:[n,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:r}),i?(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:i}):null]})]})}function J({trigger:e,triggerClassName:t,disabled:n=!1,children:r}){return n?(0,G.jsx)(`button`,{disabled:!0,className:a(`flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap`,t),children:e}):(0,G.jsx)(U.Provider,{init:void 0,children:(0,G.jsx)(ue,{trigger:e,triggerClassName:t,children:r})})}function ue({trigger:e,triggerClassName:t,children:n}){let r=U.useScopedStore(e=>e.open),i=U.useScopedStore(e=>e.setOpen);return(0,G.jsxs)(y,{open:r,onOpenChange:i,children:[(0,G.jsx)(v,{asChild:!0,children:(0,G.jsx)(`button`,{type:`button`,className:a(`flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap`,`hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t),children:e})}),(0,G.jsx)(_,{align:`center`,className:`w-64 p-1`,children:(0,G.jsx)(`div`,{className:`space-y-1`,children:typeof n==`function`?n(()=>i(!1)):n})})]})}function de({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){return(0,G.jsx)(W.Provider,{init:void 0,children:(0,G.jsx)(fe,{models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i})})}function fe({models:e,selectedModel:t,onSelect:n,ModelIcon:r,emptyMessage:i}){let o=W.useScopedStore(e=>e.open),s=W.useScopedStore(e=>e.query),c=W.useScopedStore(e=>e.setPopoverOpen),u=W.useScopedStore(e=>e.setQuery),d=W.useScopedStore(e=>e.closeAndClearQuery),f=(0,H.useCallback)(e=>{n(e),d()},[n,d]),p=e.find(e=>e.id===t)?.label??t,m=(0,H.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)):e},[e,s]),h;return h=e.length===0?(0,G.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:i}):m.length===0?(0,G.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:`No matches`}):m.map(e=>(0,G.jsx)(q,{onClick:()=>f(e.id),selected:t===e.id,icon:(0,G.jsx)(C,{className:`h-4 w-4 text-muted-foreground`}),label:e.label,description:e.id},e.id)),(0,G.jsxs)(y,{open:o,onOpenChange:c,children:[(0,G.jsx)(v,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:a(`flex min-h-[36px] cursor-pointer touch-manipulation items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-colors text-muted-foreground [&>svg]:shrink-0 [&>span]:whitespace-nowrap`,`hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),children:[(0,G.jsx)(r,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{className:`max-w-[200px] truncate`,children:p})]})}),(0,G.jsxs)(_,{align:`center`,className:`w-80 p-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border/50`,children:[(0,G.jsx)(l,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,G.jsx)(`input`,{type:`text`,value:s,onChange:e=>u(e.target.value),placeholder:`Search models...`,autoFocus:!0,className:`flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}),(0,G.jsx)(`div`,{className:`max-h-72 overflow-y-auto py-1 space-y-1`,children:h})]})]})}function pe({availableProviders:e,selectedProvider:t,showProviderPicker:n=!0,showCodexCliRequirementHints:r=!1,model:i,modelOptions:o,onProviderChange:l,onModelChange:u,onModelOptionChange:d,planMode:_=!1,onPlanModeChange:v,includePlanMode:y=!0,className:b}){let x=f(p),S=e.find(e=>e.id===t)??e[0],w=S?.id??t,E=K[w],D=C,O=y&&S?.supportsPlanMode&&v,A=w===`claude`&&`contextWindow`in o?o:null,M=w===`codex`&&`fastMode`in o?o:null,N=S?.models??ae,P=N.find(e=>e.id===i)?.contextWindowOptions??[],F=A?.contextWindow??te[0].id,I=F===`1m`?z:V,L=N.find(e=>e.id===i)?.label??i,R=m(w)?(0,G.jsx)(de,{models:N,selectedModel:i,onSelect:e=>u?.(w,e),ModelIcon:D,emptyMessage:oe[w]}):(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(D,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:L})]}),children:e=>N.map(t=>{let n=C;return(0,G.jsx)(q,{onClick:()=>{u?.(w,t.id),e()},selected:i===t.id,icon:(0,G.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:r&&w===`codex`&&t.id===`gpt-5.5`?(0,G.jsxs)(G.Fragment,{children:[t.label,` `,(0,G.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:`codex-cli >= 0.124`})]}):t.label},t.id)})});return(0,G.jsxs)(`div`,{className:a(`flex md:justify-center items-center gap-0.5`,b),children:[n?(0,G.jsx)(J,{disabled:!l,trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(E,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:S?.label??w})]}),children:t=>e.map(e=>{let n=K[e.id];return(0,G.jsx)(q,{onClick:()=>{l?.(e.id),t()},selected:w===e.id,icon:(0,G.jsx)(n,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)})}):null,u==null?(0,G.jsx)(ne,{label:`Model is locked while a cron job is running — pause or remove the cron job to change it`,side:`top`,children:(0,G.jsxs)(`span`,{"aria-disabled":`true`,className:`flex min-h-[36px] items-center gap-1.5 px-2 py-1 text-sm rounded-md text-muted-foreground [&>svg]:shrink-0 opacity-70 cursor-default [&>span]:whitespace-nowrap`,children:[(0,G.jsx)(j,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:L})]})}):R,m(w)?null:(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(c,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:w===`claude`?ee.find(e=>e.id===o.reasoningEffort)?.label??o.reasoningEffort:g.find(e=>e.id===o.reasoningEffort)?.label??o.reasoningEffort})]}),children:e=>w===`claude`?h(i,x).map(t=>(0,G.jsx)(q,{onClick:()=>{d({type:`claudeReasoningEffort`,effort:t.id}),e()},selected:o.reasoningEffort===t.id,icon:(0,G.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id)):g.map(t=>(0,G.jsx)(q,{onClick:()=>{d({type:`codexReasoningEffort`,effort:t.id}),e()},selected:o.reasoningEffort===t.id,icon:(0,G.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),label:t.label},t.id))}),w===`claude`&&P.length>1?(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(I,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:P.find(e=>e.id===F)?.label??F})]}),children:e=>P.map(t=>(0,G.jsx)(q,{onClick:()=>{d({type:`contextWindow`,contextWindow:t.id}),e()},selected:F===t.id,icon:t.id===`1m`?(0,G.jsx)(z,{className:`h-4 w-4 text-muted-foreground`}):(0,G.jsx)(V,{className:`h-4 w-4 text-muted-foreground`}),label:t.label,description:t.id===`1m`?`Expanded context window`:`Standard context window`},t.id))}):null,w===`codex`?(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[M?.fastMode?(0,G.jsx)(T,{className:`h-3.5 w-3.5`}):(0,G.jsx)(T,{className:`h-3.5 w-3.5 -scale-x-100`}),(0,G.jsx)(`span`,{children:M?.fastMode?`Fast Mode`:`Standard`})]}),triggerClassName:M?.fastMode?`text-success-text`:void 0,children:e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{onClick:()=>{d({type:`fastMode`,fastMode:!1}),e()},selected:!M?.fastMode,icon:(0,G.jsx)(T,{className:`h-4 w-4 text-muted-foreground -scale-x-100`}),label:`Standard`}),(0,G.jsx)(q,{onClick:()=>{d({type:`fastMode`,fastMode:!0}),e()},selected:!!M?.fastMode,icon:(0,G.jsx)(T,{className:`h-4 w-4 text-muted-foreground`}),label:`Fast Mode`})]})}):null,O?(0,G.jsx)(J,{trigger:(0,G.jsxs)(G.Fragment,{children:[_?(0,G.jsx)(s,{className:`h-3.5 w-3.5`}):(0,G.jsx)(k,{className:`h-3.5 w-3.5`}),(0,G.jsx)(`span`,{children:_?`Plan Mode`:`Full Access`})]}),triggerClassName:_?`text-info-text`:void 0,children:e=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{onClick:()=>{v(!1),e()},selected:!_,icon:(0,G.jsx)(k,{className:`h-4 w-4 text-muted-foreground`}),label:`Full Access`,description:`Execution without approval`}),(0,G.jsx)(q,{onClick:()=>{v(!0),e()},selected:_,icon:(0,G.jsx)(s,{className:`h-4 w-4 text-muted-foreground`}),label:`Plan Mode`,description:`Review a plan before execution`})]})}):null]})}var me=/^[a-z0-9][a-z0-9_-]{0,39}$/,he=`beacon/`,ge=`(^|[\\s\\n\\t])@beacon/([A-Za-z0-9][A-Za-z0-9_-]*)`;function _e(){return new RegExp(ge,`g`)}function ve(e){return e.length===0?`Short name is required`:e.length>40?`Short name must be at most 40 characters`:me.test(e)?null:`Use lowercase letters, digits, - and _, starting with a letter or digit`}function ye(e){return e.alias??e.label}var be=/[^a-z0-9_-]+/g,Y=/^[-_]+|[-_]+$/g;function xe(e){let t=e.toLowerCase().replace(be,`-`).replace(Y,``).slice(0,40).replace(Y,``);return t.length>0?t:`beacon`}function Se(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;return`${e}-${n}`}function X(e){let t=[...e].sort((e,t)=>e.id.localeCompare(t.id)),n=new Map,r=new Map;for(let e of t)e.alias!==void 0&&e.alias!==null&&(r.has(e.alias)||(n.set(e.id,e.alias),r.set(e.alias,e.id)));for(let e of t){if(n.has(e.id))continue;let t=Se(xe(e.label),r);n.set(e.id,t),r.set(t,e.id)}return{handleByBeaconId:n,beaconIdByHandle:r}}function Ce(e){let t=[];for(let n of e.matchAll(_e())){let e=n[2];e!==void 0&&t.push(e.toLowerCase())}return t}function we(e,t){let n=Ce(e);if(n.length===0)return{beacons:[],unresolvedHandles:[]};let{beaconIdByHandle:r}=X(t),i=new Map(t.map(e=>[e.id,e])),a=[],o=[],s=new Set;for(let e of n){let t=r.get(e),n=t===void 0?void 0:i.get(t);if(n===void 0){o.includes(e)||o.push(e);continue}s.has(n.id)||(s.add(n.id),a.push(n))}return{beacons:a,unresolvedHandles:o}}var Te=[{value:`cursor`,label:`Cursor`},{value:`xcode`,label:`Xcode`},{value:`windsurf`,label:`Windsurf`},{value:`custom`,label:`Custom`}],Z={cursor:`/editor-icons/cursor.png`,defaultApp:`/editor-icons/default-app.png`,finder:`/editor-icons/finder.png`,preview:`/editor-icons/preview.png`,xcode:`/editor-icons/xcode.png`,terminal:`/editor-icons/terminal.png`,windsurf:`/editor-icons/windsurf.png`,custom:`/editor-icons/custom.png`};function Q({src:e,className:t}){return(0,G.jsx)(`img`,{src:e,alt:``,"aria-hidden":`true`,draggable:!1,className:t})}function Ee({preset:e,className:t}){switch(e){case`xcode`:return(0,G.jsx)(Q,{src:Z.xcode,className:t});case`windsurf`:return(0,G.jsx)(Q,{src:Z.windsurf,className:t});case`custom`:return(0,G.jsx)(Q,{src:Z.custom,className:t});default:return(0,G.jsx)(Q,{src:Z.cursor,className:t})}}function De({className:e}){return(0,G.jsx)(Q,{src:Z.finder,className:e})}function Oe({className:e}){return(0,G.jsx)(Q,{src:Z.preview,className:e})}function ke({className:e}){return(0,G.jsx)(Q,{src:Z.defaultApp,className:e})}function Ae({className:e}){return(0,G.jsx)(r,{className:e})}function je({className:e}){return(0,G.jsx)(Q,{src:Z.terminal,className:e})}var Me=2e3,Ne={},$=i()((e,t)=>({copiedTokens:Ne,nextToken:1,markCopied:n=>{let r=t().nextToken;return e(e=>({nextToken:r+1,copiedTokens:{...e.copiedTokens,[n]:r}})),r},clearCopied:(n,r)=>{let{copiedTokens:i}=t();if(i[n]!==r)return;let a=Object.fromEntries(Object.entries(i).filter(([e])=>e!==n));e({copiedTokens:Object.keys(a).length>0?a:Ne})}}));async function Pe(e,t,n=u){await t();let r=$.getState().markCopied(e);n.setTimeout(()=>$.getState().clearCopied(e,r),Me)}function Fe(e){return $(t=>t.copiedTokens[e]!==void 0)}export{x as C,D as S,re as _,Ee as a,N as b,Oe as c,ye as d,X as f,q as g,pe as h,Te as i,je as l,ve as m,Fe as n,De as o,we as p,ke as r,Ae as s,Pe as t,he as u,L as v,j as x,F as y};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{l as r,u as i}from"./log-DIu9xkUN.js";var a=e(t(),1),o=e(n(),1);function s(e,t){let n=(0,a.createContext)(null);function s({init:e,children:r}){let s=(0,a.useRef)(null);return s.current===null&&(s.current=i(t(e))),(0,o.jsx)(n.Provider,{value:s.current,children:r})}function c(){let t=(0,a.useContext)(n);if(t===null)throw Error(`${e}: useScopedStore must be used inside its Provider`);return t}function l(e){return r(c(),e)}return{Provider:s,useScopedStore:l,useScopedStoreApi:c}}export{s as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{l as r,u as i}from"./log-3sQ-5rrS.js";var a=e(t(),1),o=e(n(),1);function s(e,t){let n=(0,a.createContext)(null);function s({init:e,children:r}){let s=(0,a.useRef)(null);return s.current===null&&(s.current=i(t(e))),(0,o.jsx)(n.Provider,{value:s.current,children:r})}function c(){let t=(0,a.useContext)(n);if(t===null)throw Error(`${e}: useScopedStore must be used inside its Provider`);return t}function l(e){return r(c(),e)}return{Provider:s,useScopedStore:l,useScopedStoreApi:c}}export{s as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{c as n}from"./log-DIu9xkUN.js";import{t as r}from"./timer.adapter-BX7oyt8G.js";var i=e(t(),1),a={timer:r};function o(e=1e3,t){let{timer:n}=t??a,[r,o]=(0,i.useState)(()=>Date.now()),s=(0,i.useRef)(e);return(0,i.useLayoutEffect)(()=>{s.current=e}),(0,i.useEffect)(()=>{let e=n.setInterval(()=>{o(Date.now())},s.current);return()=>n.clearInterval(e)},[n]),r}var s=[],c=n()(e=>({rows:s,setRows:t=>e({rows:t.length>0?t:s})}));export{o as n,c as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{c as n}from"./log-3sQ-5rrS.js";import{t as r}from"./timer.adapter-Di4tkt37.js";var i=e(t(),1),a={timer:r};function o(e=1e3,t){let{timer:n}=t??a,[r,o]=(0,i.useState)(()=>Date.now()),s=(0,i.useRef)(e);return(0,i.useLayoutEffect)(()=>{s.current=e}),(0,i.useEffect)(()=>{let e=n.setInterval(()=>{o(Date.now())},s.current);return()=>n.clearInterval(e)},[n]),r}var s=[],c=n()(e=>({rows:s,setRows:t=>e({rows:t.length>0?t:s})}));export{o as n,c as t};
@@ -1 +1 @@
1
- import{f as e}from"./pendingActionsStore-DG0IogaL.js";var t={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};t.node;var n=e(t);export{n as t};
1
+ import{f as e}from"./pendingActionsStore-C9wopHr4.js";var t={name:`ellipsis`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]],aliases:[`more-horizontal`]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{f as e}from"./pendingActionsStore-DG0IogaL.js";var t={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};t.node;var n=e(t);export{n as t};
1
+ import{f as e}from"./pendingActionsStore-C9wopHr4.js";var t={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};t.node;var n=e(t);export{n as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{P as r,q as i,t as a}from"./useQuery-DehtkS98.js";import{a as o,c as s,f as c,n as l,r as u,s as d,t as f}from"./pendingActionsStore-DG0IogaL.js";import{i as p,r as m}from"./host-C3kMJzEk.js";import{t as ee}from"./globe-BzQDkdZX.js";import{t as te}from"./info-BCSQhrG7.js";import{n as h,t as g}from"./triangle-alert-La2uFCiR.js";import{t as _}from"./play-B0G1X5os.js";import{t as v}from"./createScopedStore-SnvtxVfu.js";import{F as y,S as b}from"./genui-0tseVHei.js";var x={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};x.node;var S=c(x),C={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};C.node;var w=c(C),T={name:`circle-x`,size:24,node:[[`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`}]],aliases:[`x-circle`]};T.node;var E=c(T),D={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};D.node;var O=c(D),k={name:`diamond`,size:24,node:[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]};k.node;var A=c(k),j={name:`rectangle-horizontal`,size:24,node:[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}]]};j.node;var ne=c(j),M={name:`shield-question-mark`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`shield-question`]};M.node;var re=c(M),N={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};N.node;var P=c(N);function F(e){return e.type??`static`}function I(e){let t=new Map(e.nodes.map(e=>[e.id,0]));for(let n of e.edges)n.from!==n.to&&t.set(n.to,(t.get(n.to)??0)+1);let n=new Set,r=[];for(;r.length<e.nodes.length;){let i=e.nodes.find(e=>!n.has(e.id)&&t.get(e.id)===0)??e.nodes.find(e=>!n.has(e.id));if(!i)break;n.add(i.id),r.push(i);for(let n of e.edges)n.from===i.id&&n.to!==i.id&&t.set(n.to,(t.get(n.to)??0)-1)}return r}function L(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map((e.groups??[]).map(e=>[e.id,e.label])),r=(e,n)=>{let r=t.get(e);return r?[{node:r,edge:n}]:[]};return I(e).map(t=>({node:t,groupLabel:t.group?n.get(t.group)??null:null,incoming:e.edges.filter(e=>e.to===t.id).flatMap(e=>r(e.from,e)),outgoing:e.edges.filter(e=>e.from===t.id).flatMap(e=>r(e.to,e))}))}function R(e){return{step:e.node.label,edge:F(e.edge),...e.edge.label?{label:e.edge.label}:{}}}function z(e,t){let n=L(e).find(e=>e.node.id===t);if(!n)return null;let{node:r}=n;return{...e.title?{diagram:e.title}:{},step:r.label,...r.description?{description:r.description}:{},...r.kind?{kind:r.kind}:{},...r.status?{status:r.status}:{},...n.groupLabel?{group:n.groupLabel}:{},...r.path?{path:r.path}:{},...r.line?{line:r.line}:{},upstream:n.incoming.map(R),downstream:n.outgoing.map(R)}}function B(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`h${(t>>>0).toString(16)}:${e.length}`}var V=e(t(),1),H=e(n(),1),U=(0,V.createContext)(null);function W({value:e,children:t}){return(0,H.jsx)(U.Provider,{value:e,children:t})}function G(){let e=(0,V.useContext)(U);if(!e)throw Error(`GenUI components render only inside a GenUI view`);return e}var K=v(`GenUIView`,()=>e=>({pendingAgentMessage:null,previewPath:null,previewProbe:null,refreshNonce:{},notice:null,proposeAgentMessage:t=>e({pendingAgentMessage:t,notice:null}),cancelAgentMessage:()=>e({pendingAgentMessage:null}),openPreview:t=>e({previewPath:t,previewProbe:null}),closePreview:()=>e({previewPath:null,previewProbe:null}),setPreviewProbe:t=>e({previewProbe:t}),refreshDataset:t=>e(e=>({refreshNonce:{...e.refreshNonce,[t]:(e.refreshNonce[t]??0)+1}})),showNotice:t=>e({notice:t})})),q=10,J=`genui-dataset`;function Y(e){return e.source===`file`?(e.refreshSeconds??q)*1e3:e.source===`mcp`&&e.refreshSeconds?e.refreshSeconds*1e3:!1}function X(e){let{spec:t}=G();return e?t.datasets?.[e]??null:null}function ie(e,t){let n=m(),i=X(e),o=K.useScopedStore(t=>e?t.refreshNonce[e]??0:0),s=i!==null&&i.source!==`inline`&&n.queryDataset!==null&&t!==null,c=(0,V.useMemo)(()=>!i||i.source!==`inline`||!t?null:y(i,i.rows,t),[i,t]),l=n.queryDataset,u=a({queryKey:[J,n.chatId,e,i?B(JSON.stringify(i)):null,t?JSON.stringify(t):null,o],queryFn:async()=>{if(!i||!t||!l)throw Error(`dataset is not queryable`);return await l(i,t,o>0)},enabled:s,placeholderData:r,refetchInterval:i&&s&&!n.readonly?Y(i):!1,retry:!1});if(!i)return{status:`error`,message:`This view refers to a dataset "${e??``}" it does not declare`};if(!t)return{status:`loading`};if(c)return c.ok?{status:`ok`,result:c.result,refreshing:!1}:{status:`error`,message:c.message};if(!n.queryDataset)return{status:`unavailable`,message:`Live data is not included in a shared view`};if(u.error)return{status:`error`,message:b.source_unavailable};let d=u.data;if(!d)return{status:`loading`};switch(d.status){case`ok`:return{status:`ok`,result:d.result,refreshing:u.isPlaceholderData};case`needs_approval`:return d;case`error`:return{status:`error`,message:`${b[d.code]}: ${d.message}`}}}var ae={neutral:`text-muted-foreground`,positive:`text-success-text`,negative:`text-destructive-text`,attention:`text-warning-text`,info:`text-info-text`};function Z(e){return ae[e]}function oe({tone:e,className:t}){let n=s(`h-3.5 w-3.5 shrink-0`,t);switch(e){case`positive`:return(0,H.jsx)(p,{className:n,"aria-hidden":`true`});case`negative`:return(0,H.jsx)(E,{className:n,"aria-hidden":`true`});case`attention`:return(0,H.jsx)(g,{className:n,"aria-hidden":`true`});case`info`:return(0,H.jsx)(te,{className:n,"aria-hidden":`true`});case`neutral`:return(0,H.jsx)(h,{className:n,"aria-hidden":`true`})}}function se(e){return e===`positive`?`positive`:e===`negative`?`negative`:`neutral`}function Q({trend:e,className:t}){let n=s(`h-3.5 w-3.5 shrink-0`,t);return e===`up`?(0,H.jsx)(w,{className:n,"aria-hidden":`true`}):e===`down`?(0,H.jsx)(S,{className:n,"aria-hidden":`true`}):(0,H.jsx)(h,{className:n,"aria-hidden":`true`})}function ce({component:e}){return(0,H.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e,` could not be shown: its settings changed to an unsupported value`]})}function le({server:e,tool:t}){let n=m(),r=i(),a=f(`genui.dataset.approve`,n.chatId??``,e,t),s=u(a),c=n.approveTool;return c?(0,H.jsx)(o,{size:`sm`,variant:`outline`,pending:s,onClick:()=>{l(a,async()=>{await c(e,t),await r.invalidateQueries({queryKey:[J,n.chatId]})})},children:`Allow for this chat`}):null}function ue({state:e,minHeight:t,emptyLabel:n}){return(0,H.jsx)(`div`,{className:`flex items-center justify-center rounded-md border border-dashed border-border px-3 py-4 text-sm`,style:t?{minHeight:t}:void 0,children:(0,H.jsx)(de,{state:e,emptyLabel:n})})}function de({state:e,emptyLabel:t}){switch(e.status){case`loading`:return(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,H.jsx)(d,{}),` Loading data…`]});case`needs_approval`:return(0,H.jsxs)(`span`,{className:`flex flex-col items-center gap-2 text-center text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-foreground`,children:[(0,H.jsx)(re,{className:`h-4 w-4`,"aria-hidden":`true`}),`Action requires approval`]}),(0,H.jsx)(`span`,{className:`max-w-prose text-xs`,children:e.message}),(0,H.jsx)(le,{server:e.server,tool:e.tool})]});case`unavailable`:return(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:t??e.message});case`error`:return(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-destructive-text`,role:`alert`,children:[(0,H.jsx)(g,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),e.message]})}}function fe({label:e,minHeight:t}){return(0,H.jsx)(`div`,{className:`flex items-center justify-center rounded-md border border-dashed border-border px-3 py-4 text-sm text-muted-foreground`,style:t?{minHeight:t}:void 0,children:e})}var $={start:{icon:_,label:`Start`},end:{icon:P,label:`End`},process:{icon:ne,label:`Step`},decision:{icon:A,label:`Decision`},store:{icon:O,label:`Store`},external:{icon:ee,label:`External`}},pe={neutral:`bg-muted-foreground`,positive:`bg-success`,negative:`bg-destructive`,attention:`bg-warning`,info:`bg-info`};function me({node:e,className:t}){let n=$[e.kind??`process`],r=n.icon;return(0,H.jsx)(r,{className:s(`h-3.5 w-3.5 shrink-0 text-muted-foreground`,t),"aria-label":n.label})}function he({node:e}){if(!e.status)return null;let t=e.tone??`neutral`;return(0,H.jsxs)(`span`,{className:s(`flex shrink-0 items-center gap-1 text-xs font-medium whitespace-nowrap tabular-nums`,Z(t)),children:[(0,H.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,pe[t]),"aria-hidden":`true`}),e.status]})}function ge(e){if(!e.path)return null;let t=e.path.split(`/`).pop()??e.path;return e.line?`${t}:${e.line}`:t}export{B as _,ue as a,L as b,oe as c,Z as d,X as f,G as g,W as h,ge as i,Q as l,K as m,me as n,fe as o,ie as p,he as r,ce as s,$ as t,se as u,F as v,z as y};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-eq8zrF0J.js";import{t as n}from"./jsx-runtime-BdxMnOeJ.js";import{P as r,q as i,t as a}from"./useQuery-DehtkS98.js";import{a as o,c as s,f as c,n as l,r as u,s as d,t as f}from"./pendingActionsStore-C9wopHr4.js";import{i as p,r as m}from"./host-BNDj5_aa.js";import{t as ee}from"./globe-CeniwLw3.js";import{t as te}from"./info-BMdKmB36.js";import{n as h,t as g}from"./triangle-alert-B6T8mkaG.js";import{t as _}from"./play-C_g7W9ao.js";import{t as v}from"./createScopedStore-D1trFyJw.js";import{F as y,S as b}from"./genui-jdDJe0VI.js";var x={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};x.node;var S=c(x),C={name:`arrow-up-right`,size:24,node:[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]};C.node;var w=c(C),T={name:`circle-x`,size:24,node:[[`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`}]],aliases:[`x-circle`]};T.node;var E=c(T),D={name:`database`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]};D.node;var O=c(D),k={name:`diamond`,size:24,node:[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]};k.node;var A=c(k),j={name:`rectangle-horizontal`,size:24,node:[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`2`,key:`9lu3g6`}]]};j.node;var ne=c(j),M={name:`shield-question-mark`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`shield-question`]};M.node;var re=c(M),N={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};N.node;var P=c(N);function F(e){return e.type??`static`}function I(e){let t=new Map(e.nodes.map(e=>[e.id,0]));for(let n of e.edges)n.from!==n.to&&t.set(n.to,(t.get(n.to)??0)+1);let n=new Set,r=[];for(;r.length<e.nodes.length;){let i=e.nodes.find(e=>!n.has(e.id)&&t.get(e.id)===0)??e.nodes.find(e=>!n.has(e.id));if(!i)break;n.add(i.id),r.push(i);for(let n of e.edges)n.from===i.id&&n.to!==i.id&&t.set(n.to,(t.get(n.to)??0)-1)}return r}function L(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map((e.groups??[]).map(e=>[e.id,e.label])),r=(e,n)=>{let r=t.get(e);return r?[{node:r,edge:n}]:[]};return I(e).map(t=>({node:t,groupLabel:t.group?n.get(t.group)??null:null,incoming:e.edges.filter(e=>e.to===t.id).flatMap(e=>r(e.from,e)),outgoing:e.edges.filter(e=>e.from===t.id).flatMap(e=>r(e.to,e))}))}function R(e){return{step:e.node.label,edge:F(e.edge),...e.edge.label?{label:e.edge.label}:{}}}function z(e,t){let n=L(e).find(e=>e.node.id===t);if(!n)return null;let{node:r}=n;return{...e.title?{diagram:e.title}:{},step:r.label,...r.description?{description:r.description}:{},...r.kind?{kind:r.kind}:{},...r.status?{status:r.status}:{},...n.groupLabel?{group:n.groupLabel}:{},...r.path?{path:r.path}:{},...r.line?{line:r.line}:{},upstream:n.incoming.map(R),downstream:n.outgoing.map(R)}}function B(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`h${(t>>>0).toString(16)}:${e.length}`}var V=e(t(),1),H=e(n(),1),U=(0,V.createContext)(null);function W({value:e,children:t}){return(0,H.jsx)(U.Provider,{value:e,children:t})}function G(){let e=(0,V.useContext)(U);if(!e)throw Error(`GenUI components render only inside a GenUI view`);return e}var K=v(`GenUIView`,()=>e=>({pendingAgentMessage:null,previewPath:null,previewProbe:null,refreshNonce:{},notice:null,proposeAgentMessage:t=>e({pendingAgentMessage:t,notice:null}),cancelAgentMessage:()=>e({pendingAgentMessage:null}),openPreview:t=>e({previewPath:t,previewProbe:null}),closePreview:()=>e({previewPath:null,previewProbe:null}),setPreviewProbe:t=>e({previewProbe:t}),refreshDataset:t=>e(e=>({refreshNonce:{...e.refreshNonce,[t]:(e.refreshNonce[t]??0)+1}})),showNotice:t=>e({notice:t})})),q=10,J=`genui-dataset`;function Y(e){return e.source===`file`?(e.refreshSeconds??q)*1e3:e.source===`mcp`&&e.refreshSeconds?e.refreshSeconds*1e3:!1}function X(e){let{spec:t}=G();return e?t.datasets?.[e]??null:null}function ie(e,t){let n=m(),i=X(e),o=K.useScopedStore(t=>e?t.refreshNonce[e]??0:0),s=i!==null&&i.source!==`inline`&&n.queryDataset!==null&&t!==null,c=(0,V.useMemo)(()=>!i||i.source!==`inline`||!t?null:y(i,i.rows,t),[i,t]),l=n.queryDataset,u=a({queryKey:[J,n.chatId,e,i?B(JSON.stringify(i)):null,t?JSON.stringify(t):null,o],queryFn:async()=>{if(!i||!t||!l)throw Error(`dataset is not queryable`);return await l(i,t,o>0)},enabled:s,placeholderData:r,refetchInterval:i&&s&&!n.readonly?Y(i):!1,retry:!1});if(!i)return{status:`error`,message:`This view refers to a dataset "${e??``}" it does not declare`};if(!t)return{status:`loading`};if(c)return c.ok?{status:`ok`,result:c.result,refreshing:!1}:{status:`error`,message:c.message};if(!n.queryDataset)return{status:`unavailable`,message:`Live data is not included in a shared view`};if(u.error)return{status:`error`,message:b.source_unavailable};let d=u.data;if(!d)return{status:`loading`};switch(d.status){case`ok`:return{status:`ok`,result:d.result,refreshing:u.isPlaceholderData};case`needs_approval`:return d;case`error`:return{status:`error`,message:`${b[d.code]}: ${d.message}`}}}var ae={neutral:`text-muted-foreground`,positive:`text-success-text`,negative:`text-destructive-text`,attention:`text-warning-text`,info:`text-info-text`};function Z(e){return ae[e]}function oe({tone:e,className:t}){let n=s(`h-3.5 w-3.5 shrink-0`,t);switch(e){case`positive`:return(0,H.jsx)(p,{className:n,"aria-hidden":`true`});case`negative`:return(0,H.jsx)(E,{className:n,"aria-hidden":`true`});case`attention`:return(0,H.jsx)(g,{className:n,"aria-hidden":`true`});case`info`:return(0,H.jsx)(te,{className:n,"aria-hidden":`true`});case`neutral`:return(0,H.jsx)(h,{className:n,"aria-hidden":`true`})}}function se(e){return e===`positive`?`positive`:e===`negative`?`negative`:`neutral`}function Q({trend:e,className:t}){let n=s(`h-3.5 w-3.5 shrink-0`,t);return e===`up`?(0,H.jsx)(w,{className:n,"aria-hidden":`true`}):e===`down`?(0,H.jsx)(S,{className:n,"aria-hidden":`true`}):(0,H.jsx)(h,{className:n,"aria-hidden":`true`})}function ce({component:e}){return(0,H.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(g,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e,` could not be shown: its settings changed to an unsupported value`]})}function le({server:e,tool:t}){let n=m(),r=i(),a=f(`genui.dataset.approve`,n.chatId??``,e,t),s=u(a),c=n.approveTool;return c?(0,H.jsx)(o,{size:`sm`,variant:`outline`,pending:s,onClick:()=>{l(a,async()=>{await c(e,t),await r.invalidateQueries({queryKey:[J,n.chatId]})})},children:`Allow for this chat`}):null}function ue({state:e,minHeight:t,emptyLabel:n}){return(0,H.jsx)(`div`,{className:`flex items-center justify-center rounded-md border border-dashed border-border px-3 py-4 text-sm`,style:t?{minHeight:t}:void 0,children:(0,H.jsx)(de,{state:e,emptyLabel:n})})}function de({state:e,emptyLabel:t}){switch(e.status){case`loading`:return(0,H.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,role:`status`,children:[(0,H.jsx)(d,{}),` Loading data…`]});case`needs_approval`:return(0,H.jsxs)(`span`,{className:`flex flex-col items-center gap-2 text-center text-muted-foreground`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-foreground`,children:[(0,H.jsx)(re,{className:`h-4 w-4`,"aria-hidden":`true`}),`Action requires approval`]}),(0,H.jsx)(`span`,{className:`max-w-prose text-xs`,children:e.message}),(0,H.jsx)(le,{server:e.server,tool:e.tool})]});case`unavailable`:return(0,H.jsx)(`span`,{className:`text-muted-foreground`,children:t??e.message});case`error`:return(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5 text-destructive-text`,role:`alert`,children:[(0,H.jsx)(g,{className:`h-4 w-4 shrink-0`,"aria-hidden":`true`}),e.message]})}}function fe({label:e,minHeight:t}){return(0,H.jsx)(`div`,{className:`flex items-center justify-center rounded-md border border-dashed border-border px-3 py-4 text-sm text-muted-foreground`,style:t?{minHeight:t}:void 0,children:e})}var $={start:{icon:_,label:`Start`},end:{icon:P,label:`End`},process:{icon:ne,label:`Step`},decision:{icon:A,label:`Decision`},store:{icon:O,label:`Store`},external:{icon:ee,label:`External`}},pe={neutral:`bg-muted-foreground`,positive:`bg-success`,negative:`bg-destructive`,attention:`bg-warning`,info:`bg-info`};function me({node:e,className:t}){let n=$[e.kind??`process`],r=n.icon;return(0,H.jsx)(r,{className:s(`h-3.5 w-3.5 shrink-0 text-muted-foreground`,t),"aria-label":n.label})}function he({node:e}){if(!e.status)return null;let t=e.tone??`neutral`;return(0,H.jsxs)(`span`,{className:s(`flex shrink-0 items-center gap-1 text-xs font-medium whitespace-nowrap tabular-nums`,Z(t)),children:[(0,H.jsx)(`span`,{className:s(`h-1.5 w-1.5 rounded-full`,pe[t]),"aria-hidden":`true`}),e.status]})}function ge(e){if(!e.path)return null;let t=e.path.split(`/`).pop()??e.path;return e.line?`${t}:${e.line}`:t}export{B as _,ue as a,L as b,oe as c,Z as d,X as f,G as g,W as h,ge as i,Q as l,K as m,me as n,fe as o,ie as p,he as r,ce as s,$ as t,se as u,F as v,z as y};
@@ -1 +1 @@
1
- import{f as e}from"./pendingActionsStore-DG0IogaL.js";var t={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};t.node;var n=e(t);export{n as t};
1
+ import{f as e}from"./pendingActionsStore-C9wopHr4.js";var t={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};t.node;var n=e(t);export{n as t};