@x-otto/tui 0.1.0-alpha.38 → 0.1.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Tabable-BRz398OB.d.ts +1 -2
- package/dist/WizardDialog-BWGcsBR1.js +1 -2
- package/dist/compat.d.ts +1 -2
- package/dist/compat.js +1 -2
- package/dist/i18n-sGAClHYZ.js +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/standalone.d.ts +1 -2
- package/dist/standalone.js +1 -2
- package/package.json +6 -6
- package/dist/Tabable-BRz398OB.d.ts.map +0 -1
- package/dist/WizardDialog-BWGcsBR1.js.map +0 -1
- package/dist/compat.d.ts.map +0 -1
- package/dist/compat.js.map +0 -1
- package/dist/i18n-sGAClHYZ.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/standalone.d.ts.map +0 -1
- package/dist/standalone.js.map +0 -1
|
@@ -4125,5 +4125,4 @@ declare function Tabable({
|
|
|
4125
4125
|
children
|
|
4126
4126
|
}: TabableProps): React.ReactElement;
|
|
4127
4127
|
//#endregion
|
|
4128
|
-
export { ExtensionMenuContribution as $, ToolCompletionMessage as $n, subagentEntryStatus as $t, RemoteSessionSnapshot as A, ThemeRegistry as An, SigilPrefix as At, createSelectState as B, THEME as Bn, navigateSuggestions as Bt, TuiHandle as C, Risk as Cn, formatProviderUsageLimitTypeFull as Ct, WizardRequest as D, ThemePresetInput as Dn, SubmitMode as Dt, TuiStreamEvent as E, ThemePreset as En, PromptInput as Et, MessageStore as F, PANEL_BORDER as Fn, TypeaheadState as Ft, MemoryDialog as G, MessageContent as Gn, PasteStoreResidencySource as Gt, NotifyScheduler as H, A2uiContent as Hn, PasteSnapshot as Ht, Question as I, FIGURES as In, applySlashCompletion as It, MemoryEntrySource as J, StopReason as Jn, ObservationLike as Jt, MemoryDialogProps as K, PendingPermission as Kn, createPasteStore as Kt, SelectOption as L, FiguresMap as Ln, createCommandRegistry as Lt, SessionDataTarget as M, LAYOUT as Mn, CommandEntry as Mt, SessionTransport as N, SPACING as Nn, CommandRegistry as Nt, AttachDataSourceDeps as O, ThemePresetSelection as On, SigilEntry as Ot, createAttachSessionDataSource as P, DIALOG_BORDER as Pn, SlashNavigateAction as Pt, ExtensionListEntry as Q, ToolCall as Qn, observationRow as Qt, SelectOptions as R, PALETTE as Rn, extractSlashPrefix as Rt, SubagentContext as S, LangMode as Sn, ProviderUsageBadgeItem as St, TuiPanelRegistration as T, ThemeAppearance as Tn, QueuedCommands as Tt, NotifyStats as U, AssistantMessage as Un, PasteSnapshotEntry as Ut, A2uiButtonInfo as V, ThemeColors as Vn, CreatePasteStoreOptions as Vt, makeNotifyScheduler as W, ChatMessage as Wn, PasteStore as Wt, InfoDialogAction as X, TextContent as Xn, formatTurnTimeline as Xt, InfoDialog as Y, StreamEvent as Yn, formatAgentDiagnosticsText as Yt, InfoDialogProps as Z, ThinkingContent as Zn, observationLiveFields as Zt, ModalRequestInput as _, detectLanguage as _n, createBudgetStore as _t, TabableContextValue as a, RateLimitType as an, ButtonProps as at, PluginRegistration as b, t as bn, HomeProps as bt, TabableRegistry as c, KeyBindingPredicate as cn, RegisteredRenderer as ct, useTabableContext as d, DataListProps as dn, NotificationStore as dt, subagentRestoreFields as en, ToolMessage as er, ExtensionsListRequest as et, ConfirmDialog as f, DataListRow as fn, ProxyStore as ft, DraftItemView as g, useAppState as gn, BudgetView as gt, ConfirmRequest as h, Store as hn, BudgetStore as ht, Tabable as i, ErrorRetryItem as in, ButtonColor as it, SessionDataSource as j, createBuiltinThemeRegistry as jn, SigilSearchRegistry as jt, RemoteSessionEvent as k, ThemePresetSource as kn, SigilKind as kt, UseTabableOptions as l, DataList as ln, clearPluginRenderers as lt, AlertRequest as m, StatusStore as mn, BudgetState as mt, RouteContext as n, ErrorRetryAction as nn, ExtensionDetailRequest as nt, TabableEntry as o, ContextStore as on, ButtonVariant as ot, ConfirmDialogProps as p, DataListTone as pn, CacheStore as pt, MemoryEntry as q, PulseSurveyItem as qn, Completer as qt, RouteContextValue as r, ErrorRetryActionKind as rn, Button as rt, TabableProps as s, OnboardingResult as sn, PluginMessageRenderer as st, FocusStyle as t, EditedFileEntry as tn, UserMessage as tr, ExtensionDetailAction as tt, useTabable as u, DataListEntry as un, registerPluginRenderers as ut, ModalRequestVoid as v, i18next as vn, TaskStore as vt, TuiOptions as w, MarkdownThemeOverrides as wn, isUsingOverage as wt, PromptRequest as x, Lang as xn, SessionListItem as xt, PermissionDecision as y, initI18n as yn, Home as yt, SelectState as z, STATUS as zn, getCommandSuggestions as zt };
|
|
4129
|
-
//# sourceMappingURL=Tabable-BRz398OB.d.ts.map
|
|
4128
|
+
export { ExtensionMenuContribution as $, ToolCompletionMessage as $n, subagentEntryStatus as $t, RemoteSessionSnapshot as A, ThemeRegistry as An, SigilPrefix as At, createSelectState as B, THEME as Bn, navigateSuggestions as Bt, TuiHandle as C, Risk as Cn, formatProviderUsageLimitTypeFull as Ct, WizardRequest as D, ThemePresetInput as Dn, SubmitMode as Dt, TuiStreamEvent as E, ThemePreset as En, PromptInput as Et, MessageStore as F, PANEL_BORDER as Fn, TypeaheadState as Ft, MemoryDialog as G, MessageContent as Gn, PasteStoreResidencySource as Gt, NotifyScheduler as H, A2uiContent as Hn, PasteSnapshot as Ht, Question as I, FIGURES as In, applySlashCompletion as It, MemoryEntrySource as J, StopReason as Jn, ObservationLike as Jt, MemoryDialogProps as K, PendingPermission as Kn, createPasteStore as Kt, SelectOption as L, FiguresMap as Ln, createCommandRegistry as Lt, SessionDataTarget as M, LAYOUT as Mn, CommandEntry as Mt, SessionTransport as N, SPACING as Nn, CommandRegistry as Nt, AttachDataSourceDeps as O, ThemePresetSelection as On, SigilEntry as Ot, createAttachSessionDataSource as P, DIALOG_BORDER as Pn, SlashNavigateAction as Pt, ExtensionListEntry as Q, ToolCall as Qn, observationRow as Qt, SelectOptions as R, PALETTE as Rn, extractSlashPrefix as Rt, SubagentContext as S, LangMode as Sn, ProviderUsageBadgeItem as St, TuiPanelRegistration as T, ThemeAppearance as Tn, QueuedCommands as Tt, NotifyStats as U, AssistantMessage as Un, PasteSnapshotEntry as Ut, A2uiButtonInfo as V, ThemeColors as Vn, CreatePasteStoreOptions as Vt, makeNotifyScheduler as W, ChatMessage as Wn, PasteStore as Wt, InfoDialogAction as X, TextContent as Xn, formatTurnTimeline as Xt, InfoDialog as Y, StreamEvent as Yn, formatAgentDiagnosticsText as Yt, InfoDialogProps as Z, ThinkingContent as Zn, observationLiveFields as Zt, ModalRequestInput as _, detectLanguage as _n, createBudgetStore as _t, TabableContextValue as a, RateLimitType as an, ButtonProps as at, PluginRegistration as b, t as bn, HomeProps as bt, TabableRegistry as c, KeyBindingPredicate as cn, RegisteredRenderer as ct, useTabableContext as d, DataListProps as dn, NotificationStore as dt, subagentRestoreFields as en, ToolMessage as er, ExtensionsListRequest as et, ConfirmDialog as f, DataListRow as fn, ProxyStore as ft, DraftItemView as g, useAppState as gn, BudgetView as gt, ConfirmRequest as h, Store as hn, BudgetStore as ht, Tabable as i, ErrorRetryItem as in, ButtonColor as it, SessionDataSource as j, createBuiltinThemeRegistry as jn, SigilSearchRegistry as jt, RemoteSessionEvent as k, ThemePresetSource as kn, SigilKind as kt, UseTabableOptions as l, DataList as ln, clearPluginRenderers as lt, AlertRequest as m, StatusStore as mn, BudgetState as mt, RouteContext as n, ErrorRetryAction as nn, ExtensionDetailRequest as nt, TabableEntry as o, ContextStore as on, ButtonVariant as ot, ConfirmDialogProps as p, DataListTone as pn, CacheStore as pt, MemoryEntry as q, PulseSurveyItem as qn, Completer as qt, RouteContextValue as r, ErrorRetryActionKind as rn, Button as rt, TabableProps as s, OnboardingResult as sn, PluginMessageRenderer as st, FocusStyle as t, EditedFileEntry as tn, UserMessage as tr, ExtensionDetailAction as tt, useTabable as u, DataListEntry as un, registerPluginRenderers as ut, ModalRequestVoid as v, i18next as vn, TaskStore as vt, TuiOptions as w, MarkdownThemeOverrides as wn, isUsingOverage as wt, PromptRequest as x, Lang as xn, SessionListItem as xt, PermissionDecision as y, initI18n as yn, Home as yt, SelectState as z, STATUS as zn, getCommandSuggestions as zt };
|
|
@@ -11,5 +11,4 @@ import{n as e}from"./i18n-sGAClHYZ.js";import{createRequire as t}from"node:modul
|
|
|
11
11
|
`),action:`insert`};if(e.offset>0&&e.text[e.offset-1]===`\\`&&!o){let t=e.backspace();return It(),{cursor:t.insert(`
|
|
12
12
|
`),action:`insert`}}return It(),{cursor:e,action:i||a||r?`submit_force`:`submit`}}let s=Mt(e,t);return s?(s.action===`kill_to_end`&&s.killed?Ft(s.killed,!1):s.action===`kill_to_start`&&s.killed||s.action===`kill_word_before`&&s.killed?Ft(s.killed,!0):s.action===`kill_word_after`&&s.killed||s.action===`kill_selection`&&s.killed?Ft(s.killed,!1):(s.action===`delete_backward`||s.action===`delete_selection`||s.action===`clear_selection`||s.action===`insert`)&&It(),s):null}function Rt(e){return e.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,``).replace(/\x1b\][^\x1b]*$/g,``).replace(/\x1b\[[0-9;]*[~a-zA-Z]/g,``).replace(/\r\n?/g,`
|
|
13
13
|
`).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function zt(e){return e.measuredText.lineCount>10}function Bt(e,t){let n=e.measuredText.lineCount;if(n<=t)return null;let r=e.position,i=e.getViewportStartLine(t),a=Math.min(i+t,n);return{startLine:i,endLine:a,visibleLines:e.measuredText.lines.slice(i,a),cursorLine:r.line-i}}const Vt={file:{colorToken:`suggestion`,categoryLabelKey:`sigil.catFile`},agent:{colorToken:`accent`,categoryLabelKey:`sigil.catAgent`},skill:{colorToken:`special`,categoryLabelKey:`sigil.catSkill`},mcp:{colorToken:`special`,categoryLabelKey:null,categoryLabelLiteral:`MCP`},plugin:{colorToken:`special`,categoryLabelKey:`sigil.catPlugin`},person:{colorToken:`success`,categoryLabelKey:`sigil.catPerson`},model:{colorToken:void 0,categoryLabelKey:`sigil.catModel`},effort:{colorToken:void 0,categoryLabelKey:`sigil.catEffort`},shortcut:{colorToken:void 0,categoryLabelKey:`sigil.catShortcut`},resource:{colorToken:void 0,categoryLabelKey:`sigil.catResource`},hashtag:{colorToken:void 0,categoryLabelKey:`sigil.catHashtag`},paste:{colorToken:`inactive`,categoryLabelKey:null}};function Ht(e){return Vt[e]}function Ut(e,t){let n=L(U.ellipsis);if(t<=1)return U.ellipsis;if(L(e)<=t)return e;let r=t-n,i=``;for(let t of e){let e=L(t);if(e>r)break;i+=t,r-=e}return`${i}${U.ellipsis}`}function Wt(e,t){let n=L(e);return n<=0||t<=0?``:e.repeat(Math.max(0,Math.floor(t/n)))}function Gt(e,t){let n=L(e);return n>=t?e:e+` `.repeat(t-n)}function Kt(e,t,n){return{x:e,y:t,lastChangeAt:n,targetX:e,targetY:t}}function qt(e,t,n,r,i){let a=t!==e.targetX||n!==e.targetY;return i?a?r-e.lastChangeAt<150?{...e,targetX:t,targetY:n,lastChangeAt:r}:{x:t,y:n,targetX:t,targetY:n,lastChangeAt:r}:(e.x!==t||e.y!==n)&&r-e.lastChangeAt>=150?{...e,x:t,y:n}:e:!a&&e.x===t&&e.y===n?e:{x:t,y:n,targetX:t,targetY:n,lastChangeAt:r}}function Jt(e){if(!e?.yogaNode)return null;let t=0,n=0,r=e;for(;r?.yogaNode;)t+=r.yogaNode.getComputedLeft(),n+=r.yogaNode.getComputedTop(),r=r.parentNode;return{x:Math.round(t),y:Math.round(n)}}function Yt(e){let t=e??void 0;for(;t;){if(!t.parentNode)return t.nodeName===`ink-root`?t:void 0;t=t.parentNode}}let Xt=0;function Zt(e){if(!e)return`NULL`;let t=[],n=e;for(let e=0;e<4&&n;e++)t.push(n.nodeName??`?`),n=n.parentNode;let r=e.childNodes?.[0]?.nodeValue;return`${t.join(`<`)}${r?`:${JSON.stringify(r.slice(0,12))}`:``}`}function Qt(e){let[t,n]=f(null),r=i.useRef(0);r.current===0&&(r.current=++Xt);let a=s(()=>{if(!e.current)return;let t=Jt(e.current);n(n=>{let i=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(i)try{x(`node:fs`).appendFileSync(i,`[ORG#${r.current}] t=${Date.now()%1e5} next=${t?`${t.x},${t.y}`:`NULL`} prev=${n?`${n.x},${n.y}`:`NULL`} node=${Zt(e.current)}\n`)}catch{}return t===null||n!==null&&n.x===t.x&&n.y===t.y?n:t})},[e]);return l(a),l(()=>{let t=Yt(e.current);if(t)return t.internal_layoutListeners??=new Set,t.internal_layoutListeners.add(a),()=>{t.internal_layoutListeners?.delete(a)}}),t}let $t=0;function en({active:e,containerRef:t,text:n,inline:r,deleteKeyAt:i}){let{setCursorPosition:a}=v(),o=Qt(t),s=d(0);s.current===0&&(s.current=++$t);let c=d(null),u=d(null),p=d(n.length),m=d(0);n.length<p.current&&(m.current=Date.now()),p.current=n.length;let[,h]=f(0);if(e&&o){let e=Date.now(),t=e-i<300,l=n.length===0,d=!t&&!l&&e-m.current<300,f=qt(c.current??Kt(r.column,r.lineOffset,e),r.column,r.lineOffset,e,d);c.current=f;let p=o.x+f.x,h=o.y+f.y,g=u.current;g!==null&&f.y>g.inlineOffset&&o.y===g.originY&&(h=g.y),u.current={y:h,originY:o.y,inlineOffset:f.y},a({x:p,y:h});let _=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(_)try{x(`node:fs`).appendFileSync(_,`[ON #${s.current}] t=${e%1e5} out=${p},${h} target=${o.x+r.column},${o.y+r.lineOffset} origin=${o.x},${o.y} inline=${r.column},${r.lineOffset} frozenInline=${f.x},${f.y} armed=${d?1:0} byDel=${t?1:0} byClr=${l?1:0} len=${n.length}\n`)}catch{}}else{c.current=null,u.current=null,a(void 0);let t=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(t)try{x(`node:fs`).appendFileSync(t,`[OFF#${s.current}] t=${Date.now()%1e5} active=${e?1:0} origin=${o?`${o.x},${o.y}`:`NULL`} len=${n.length}\n`)}catch{}}l(()=>{let e=c.current;if(!e||e.x===e.targetX&&e.y===e.targetY)return;let t=setTimeout(()=>h(e=>e+1),160);return()=>clearTimeout(t)})}const tn=new Intl.Segmenter(`en`,{granularity:`grapheme`});function nn(e,t,n){let r=0,i=e,a=t;if(e>n){let o=Math.floor(n/2);r=Math.max(0,t-o),Math.min(e,r+n)-r<n&&(r=Math.max(0,e-n)),i=n,a=t-r}return{startLine:r,visibleRows:i,cursorLineInWindow:a}}const rn={send:`> `,bash:`! `,bash_async:`!! `,memory:`# `,steer:`» `,dialog:``};function an(e,t){return e===`bash`||e===`bash_async`?t.warning:e===`memory`?t.special:e===`steer`?t.success:t.suggestion}function on(e,t,n){if(!e)return{lines:[``],cursorLine:0,cursorCharInLine:0,lineStarts:[0]};let r=[...tn.segment(e)],i=[],a=[0],o=``,s=0,c=0,l=0,u=0;for(let e=0;e<r.length;e++){let d=r[e],f=yt(d.segment);if(u===n&&(c=i.length,l=o.length),d.segment===`
|
|
14
|
-
`){i.push(o),o=``,s=0,u+=d.segment.length,a.push(u);continue}s+f>t&&o.length>0&&(i.push(o),o=``,s=0,a.push(u)),o+=d.segment,s+=f,u+=d.segment.length}return n>=u&&(c=i.length,l=o.length),i.push(o),{lines:i,cursorLine:c,cursorCharInLine:l,lineStarts:a}}function sn(e,t,n){if(!n)return{pre:e,sel:``,post:``};let r=Math.max(0,n.start-t),i=Math.min(e.length,n.end-t);return r>=i?{pre:e,sel:``,post:``}:{pre:e.slice(0,r),sel:e.slice(r,i),post:e.slice(i)}}function cn(e,t,n,r,i,a,o){let s=t?[{chunk:e,isChip:!1}]:ln(e);return s.length===0?[]:s.map((e,t)=>{let s=e.isChip&&dn(e,n);return m(_,{inverse:i,color:i?void 0:s?r.error:e.isChip?un(e.kind,r):void 0,strikethrough:s,children:e.chunk},`${a}${o+t}`)})}function ln(e){X.lastIndex=0;let t=[],n=0,r;for(;(r=X.exec(e))!==null;){r.index>n&&t.push({chunk:e.slice(n,r.index),isChip:!1});let i=r[0],a=Ct(i);t.push({chunk:i,isChip:!0,kind:a,pasteId:a===`paste`?wt(i):void 0}),n=r.index+i.length}return n<e.length&&t.push({chunk:e.slice(n),isChip:!1}),t}function un(e,t){if(e===void 0)return;let n=Ht(e)?.colorToken;return n?t[n]:void 0}function dn(e,t){return e.kind===`paste`&&e.pasteId!==void 0&&(t?.has(e.pasteId)??!1)}function fn(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(t>n.index&&t<n.index+n[0].length){let e=Ct(n[0]);return{kind:e,pasteId:e===`paste`?wt(n[0]):void 0}}}function pn(e,t){let n=Dt(e,t);if(!n)return;let r=Ct(n.text);return{text:n.text,kind:r,pasteId:r===`paste`?wt(n.text):void 0}}function mn(e){return Wt(`•`,L(e))}const hn=i.memo(function({value:t,offset:n,columns:r,mode:a=`send`,placeholder:o=``,maxVisibleLines:s=10,focused:c,tabIndex:l=-1,mask:u=!1,noPrefix:d=!1,ghostSuffix:f,invalidPasteIds:v,containerRef:y,physicalCursor:b=!1,deleteKeyAt:x=0,selection:S=null}){let C=K(),{focused:w}=Je({tabIndex:l,disabled:l<0}),T=c??w,E=d?``:a===`dialog`&&!u?`> `:rn[a],D=yt(E),O=E,k=Math.max(20,r-D),A=T,{lines:j,cursorLine:M,cursorCharInLine:ee,lineStarts:te}=i.useMemo(()=>on(t,k,n),[t,k,n]),N=S!==null&&S!==n?{start:Math.min(S,n),end:Math.max(S,n)}:null,P=i.useRef(null),F=i.useCallback(e=>{P.current=e,typeof y==`function`?y(e):y&&(y.current=e)},[y]),ne=nn(j.length,M,s),I=ne.startLine>0?1:0,L={column:D+yt((j[M]??``).slice(0,ee)),lineOffset:I+ne.cursorLineInWindow};if(en({active:b&&T,containerRef:P,text:t,inline:L,deleteKeyAt:x}),t.length===0&&o)return h(g,{ref:F,flexDirection:`row`,children:[m(_,{color:T?an(a,C):C.inactive,children:O}),T&&m(_,{inverse:A,children:` `}),m(_,{dimColor:!0,children:o})]});let R=j.length,{startLine:z,visibleRows:B}=nn(R,M,s),re=z+B,ie=j.slice(z,re);return h(g,{ref:F,flexDirection:`column`,children:[z>0&&m(_,{dimColor:!0,children:` … ${z} ${e.t(`scroll.viewportLinesAbove`)}`}),ie.map((e,t)=>{let n=z+t,r=n===M,i=u?mn(e):e;if(!r||!T){let{pre:r,sel:o,post:s}=sn(i,te[n]??0,N);return h(g,{flexDirection:`row`,children:[n===0&&O?m(_,{color:T?an(a,C):C.inactive,children:O}):D>0&&m(_,{dimColor:!0,children:` `.repeat(D)}),i.length===0?m(_,{children:` `}):h(p,{children:[cn(r,u,v,C,!1,`p`,0),cn(o,u,v,C,!0,`s`,1e3),cn(s,u,v,C,!1,`q`,2e3)]})]},`${t}-${e.slice(0,10)}`)}let o=Math.max(0,Math.min(ee,i.length)),s=!u&&o<i.length?pn(i,o):void 0;if(s){let r=i.slice(0,o),c=i.slice(o+s.text.length),l=s.kind===`paste`&&s.pasteId!==void 0&&(v?.has(s.pasteId)??!1);return h(g,{flexDirection:`row`,children:[n===0&&O?m(_,{color:T?an(a,C):C.inactive,children:O}):D>0&&m(_,{dimColor:!0,children:` `.repeat(D)}),ln(r).map((e,t)=>{let n=e.isChip&&dn(e,v);return m(_,{color:n?C.error:e.isChip?un(e.kind,C):void 0,strikethrough:n,children:e.chunk},`b-${t}`)}),m(_,{inverse:!0,color:l?C.error:void 0,strikethrough:l,children:s.text}),ln(c).map((e,t)=>{let n=e.isChip&&dn(e,v);return m(_,{color:n?C.error:e.isChip?un(e.kind,C):void 0,strikethrough:n,children:e.chunk},`a-${t}`)}),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}let c=i.slice(0,o),l=i.slice(o),d=l.length>0?[...l][0]??` `:` `,y=l.length>0?l.slice(d.length):``,b=!u&&l.length>0?fn(i,o):void 0,x=b?.kind===`paste`&&b.pasteId!==void 0&&(v?.has(b.pasteId)??!1),S=te[n]??0,w=N?{start:N.start,end:Math.min(N.end,S+o)}:null,E=N?{start:Math.max(N.start,S+o+1),end:N.end}:null,k=sn(c,S,w),j=sn(y,S,E),P=N!==null&&N.start<=S+o&&S+o<N.end;return h(g,{flexDirection:`row`,children:[n===0&&O?m(_,{color:T?an(a,C):C.inactive,children:O}):D>0&&m(_,{dimColor:!0,children:` `.repeat(D)}),cn(k.pre,u,v,C,!1,`b`,0),cn(k.sel,u,v,C,!0,`bs`,1e3),cn(k.post,u,v,C,!1,`bp`,2e3),m(_,{inverse:A||P,color:x?C.error:b==null?void 0:un(b.kind,C),strikethrough:x,children:d}),cn(j.pre,u,v,C,!1,`a`,0),cn(j.sel,u,v,C,!0,`as`,1e3),cn(j.post,u,v,C,!1,`ap`,2e3),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}),re<R&&m(_,{dimColor:!0,children:` … ${R-re} ${e.t(`scroll.viewportLinesBelow`)}`})]})}),gn=[{commandId:`cycle-permission-mode`,description:`循环切换权限模式`,predicate:{shift:!0,key:`tab`},scopes:`*`},{commandId:`toggle-notifications`,description:`打开/关闭通知中心`,predicate:{ctrl:!0,input:`n`},scopes:`*`},{commandId:`toggle-edited-files`,description:`打开/关闭编辑文件面板`,predicate:{ctrl:!0,input:`v`},scopes:`*`},{commandId:`toggle-subagents`,description:`打开/关闭子代理面板`,predicate:{ctrl:!0,input:`t`},scopes:`*`},{commandId:`toggle-delegates`,description:`打开/关闭委派面板`,predicate:{ctrl:!0,input:`p`},scopes:`*`},{commandId:`toggle-clipboard`,description:`打开/关闭剪贴板面板`,predicate:{ctrl:!0,input:`g`},scopes:`*`},{commandId:`toggle-draft-pane`,description:`打开/关闭草稿面板`,predicate:{ctrl:!0,input:`o`},scopes:`*`},{commandId:`toggle-queue-pane`,description:`打开/关闭队列面板`,predicate:{ctrl:!0,input:`q`},scopes:`*`},{commandId:`smart-close`,description:`智能关闭当前最上层面板`,predicate:{ctrl:!0,input:`k`},scopes:`*`},{commandId:`save-draft`,description:`保存当前输入为草稿`,predicate:{ctrl:!0,input:`s`},scopes:[`prompt`]},{commandId:`open-keybinding-panel`,description:`打开快捷键面板:浏览、搜索、重映射、重置快捷键`,predicate:{ctrl:!0,input:`/`},scopes:`*`}];function _n(e){return e.ctrl===void 0&&e.shift===void 0&&e.meta===void 0&&e.input===void 0&&e.key===void 0&&e.upArrow===void 0&&e.downArrow===void 0}function vn(e,t,n){let r=n?.[e];return r===void 0?t:r}function yn(e,t,n){if(e.ctrl!==void 0&&!!n.ctrl!==e.ctrl||e.shift!==void 0&&!!n.shift!==e.shift||e.meta!==void 0&&!!n.meta!==e.meta||e.input!==void 0&&t!==e.input)return!1;if(e.key!==void 0)switch(e.key){case`tab`:if(!n.tab)return!1;break;case`escape`:if(!n.escape)return!1;break;case`return`:if(!n.return)return!1;break}return!(e.upArrow!==void 0&&n.upArrow!==e.upArrow||e.downArrow!==void 0&&n.downArrow!==e.downArrow)}function bn(e,t){return e===`*`?!0:e.includes(t)}function xn(e,t,n,r,i){for(let a of e){if(!bn(a.scopes,t))continue;let e=vn(a.commandId,a.predicate,i);if(!_n(e)&&yn(e,n,r))return a.commandId}}const Sn=[{commandId:`list-nav-up`,description:`列表选中项上移`,predicate:{upArrow:!0},scopes:`*`},{commandId:`list-nav-up`,description:`列表选中项上移(vim k)`,predicate:{input:`k`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]},{commandId:`list-nav-down`,description:`列表选中项下移`,predicate:{downArrow:!0},scopes:`*`},{commandId:`list-nav-down`,description:`列表选中项下移(vim j)`,predicate:{input:`j`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]}];function Cn(e,t,n,r,i){for(let a of Sn){if(r!==void 0&&!wn(a.scopes,r))continue;let o=vn(a.commandId,a.predicate,i);if(!_n(o)&&yn(o,t,n))return a.commandId===e}return!1}function wn(e,t){return e===`*`?!0:e.includes(t)}function Tn(e,t,n,r){let i=[...gn,...Sn];for(let a of i){if(a.commandId===e)continue;let i=vn(a.commandId,a.predicate,r);if(!_n(i)&&bn(a.scopes,n)&&En(i,t))return{conflictsWith:a.commandId}}return null}function En(e,t){return e.ctrl===t.ctrl&&e.shift===t.shift&&e.meta===t.meta&&e.input===t.input&&e.key===t.key&&e.upArrow===t.upArrow&&e.downArrow===t.downArrow}function Dn(){let e=new Set(gn.map(e=>e.commandId)),t=new Set(Sn.map(e=>e.commandId));for(let n of e)if(t.has(n))throw Error(`[keybindings] duplicate commandId '${n}' found across KEY_BINDINGS and CONTROL_BINDINGS`)}Dn();function On(e,t,n){if(!t)return!1;let r=e.get(t);return r?n.tab?!!(r.onTab&&r.onTab(n.shift??!1)):n.escape?!!(r.onEscape&&r.onEscape()):n.return?!!(r.onAction&&r.onAction()):!1:!1}function kn(e,t,n,r,i){if(i.tab){let a=t;if(e.getTabable(n).length===0)return!1;if(a){let t=i.shift?e.prev(a,n):e.next(a,n);t&&r(t)}else if(!i.shift){let t=e.getInitialFocus(n);t&&r(t)}return!0}return!1}let An=null;function jn(e){An=e}function Mn(){return An}const Nn=`/overlay/toast`,Pn=`/overlay/pause`,Fn=`/overlay/retry`,In=`/overlay/error-retry`,Ln=`/overlay/pulse-survey`,Rn=`/overlay/forced-upgrade`,zn=`/overlay/paste-confirm`,Bn=`/overlay/services`,Vn=`/overlay/chip-viewer`,Hn=[Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn];function Un(e){return e.startsWith(`/overlay/`)}function Wn(e){return e.startsWith(`/dialog/`)}function Gn(e,t,n){e&&(n?e.ensure(t):e.dismiss(t))}const Kn=a(null);function qn(){let e=c(Kn);if(!e)throw Error(`useRouter() must be used inside <Router>`);return e}function Jn(){return c(Kn)}function Yn(){let{stack:e}=qn(),t=e[e.length-1];return t?{path:t.path,params:t.params,state:t.state}:{path:`/`,params:{},state:void 0}}function Xn(e){let{stack:t}=qn();for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.path===e&&r.state!==void 0)return r.state}}function Zn(){let{stack:e}=qn(),t=c(Ke).routePath;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.path===t)return r.state}}function Qn(e,t){let n=e.split(`/`),r=t.split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;e<n.length;e++){let t=n[e],a=r[e];if(t.startsWith(`:`))i[t.slice(1)]=a;else if(t!==a)return null}return i}function $n({children:e,initialPath:t=`/`}){let n=u(()=>new Ge,[]),[r,i]=f(()=>({entries:[{path:t,params:{}}],index:0})),[a,o]=f(null),c=d(null);c.current=a;let p=r.entries[r.index]?.path??t,h=r.entries.slice(0,r.index+1),g=d(h);g.current=h;let _=s(e=>{o(e)},[]),v=s(e=>{setTimeout(()=>{e?.lastFocusId?o(e.lastFocusId):o(n.getInitialFocus(e?.path??`/`))},0)},[n]),y=s(e=>{setTimeout(()=>{o(n.getInitialFocus(e))},0)},[n]),b=s((e,t)=>{if(typeof e==`number`){i(t=>{if(e===0||t.entries.length===0)return t;let n=t.index+e;return n<0||n>=t.entries.length?t:(v(t.entries[n]),{...t,index:n})});return}let r={path:e,params:{},state:t?.state};i(i=>{if(t?.reset){if(Wn(e))return{entries:[r],index:0};let t=i.entries.slice(0,i.index+1).filter(e=>Wn(e.path));if(t.length===0)return{entries:[r],index:0};let n=[r,...t];return{entries:n,index:n.length-1}}let a=c.current,o=[...i.entries];if(o.length>0&&a){let e=o[i.index];e&&(n.rememberFocus(e.path,a),o[i.index]={...e,lastFocusId:a})}if(t?.replace&&o.length>0)return o[i.index]=r,{entries:o,index:i.index};let s=[...o.slice(0,i.index+1),r];return{entries:s,index:s.length-1}}),y(e)},[y,n,v]),x=s(()=>{b(-1)},[b]),S=s(e=>{i(t=>{if(t.entries.slice(0,t.index+1).some(t=>t.path===e))return t;let r=c.current,i=[...t.entries],a=i[t.index];a&&r&&(n.rememberFocus(a.path,r),i[t.index]={...a,lastFocusId:r});let o=[...i.slice(0,t.index+1),{path:e,params:{}}];return y(e),{entries:o,index:o.length-1}})},[y,n]),C=s(e=>{i(t=>{if(t.entries.length<=1)return t;let n=-1;for(let r=t.index;r>=0;r--)if(t.entries[r].path===e){n=r;break}if(n<=0)return t;let r=[...t.entries.slice(0,n),...t.entries.slice(n+1)],i=n<=t.index?Math.max(0,t.index-1):t.index;return n===t.index&&v(r[i]),{entries:r,index:Math.min(i,r.length-1)}})},[v]),w=s(e=>{o(e)},[]),T=s((e,t)=>On(n,c.current,t),[n]),E=s((e,t)=>kn(n,c.current,p,o,t)?!0:t.escape&&h.length>1?(x(),!0):!1,[n,p,h.length,x]),D=s((e,t)=>T(e,t)||E(e,t),[T,E]);l(()=>(jn({navigate:b,goBack:x,ensure:S,dismiss:C,get stack(){return g.current},get currentPath(){return g.current[g.current.length-1]?.path??`/`}}),()=>jn(null)),[b,x,S,C]);let O=rt(),k=d(T);k.current=T;let A=d(E);A.current=E,l(()=>{let e=O.register(`router-intercept`,(e,t)=>k.current(e,t),50),t=O.register(`router-default`,(e,t)=>A.current(e,t),5);return()=>{e(),t()}},[O]),l(()=>{let e=n.getInitialFocus(p);e&&!c.current&&o(e)},[p]);let j=u(()=>({routePath:p,currentPath:p,activeId:a,registry:n,onFocusFallback:_,hasRouter:!0}),[p,a,n,_]),M=u(()=>({stack:h,currentPath:p,activeId:a,navigate:b,goBack:x,ensure:S,dismiss:C,focus:w,handleKey:D}),[h,p,a,b,x,S,C,w,D]);return m(Kn.Provider,{value:M,children:m(Ke.Provider,{value:j,children:e})})}function er(e,t){return t===e||t.startsWith(e+`/`)}function tr(e){for(let t=e.length-1;t>=0;t--){let n=e[t].path;if(!n.startsWith(`/overlay/`))return n}}function nr({path:e,prefix:t,inStack:n,dismissibleByOverlay:r,element:i,children:a}){let{currentPath:o,stack:s,activeId:l}=qn(),u=c(Ke),d=e=>u?h(Ke.Provider,{value:{...u,routePath:e,activeId:l},children:[i,a]}):h(p,{children:[i,a]});if(e===`*`)return d(o);if(n)return s.some(t=>t.path===e)?d(e):null;if(r){let n=tr(s);return n===void 0||(t?!er(e,n):n!==e)?null:d(e)}return t?er(e,o)?d(e):null:Qn(e,o)?d(e):null}function rr({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▲ ${e.t(`common.more`)}`:e.t(`scroll.above`,{n})]}):null}function ir({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▼ ${e.t(`common.more`)}`:e.t(`scroll.below`,{n})]}):null}function ar(e,t){switch(e){case`primary`:return t.text;case`secondary`:return t.inactive;case`danger`:return t.error;case`success`:return t.success;case`warning`:return t.warning;case`accent`:return t.accent}}function $({children:e,type:t=`primary`,bold:n,italic:r,dim:i,wrap:a}){return m(_,{color:ar(t,K()),bold:n,italic:r,dimColor:i,wrap:a,children:e})}function or(e){return e.leftArrow?-1:e.rightArrow?1:e.tab?e.shift?-1:1:0}function sr(e,t,n){return n<=0?0:(e+t+n)%n}function cr({children:e,type:t=`secondary`,leadingSpace:n=!1}){let r=K();return h(_,{children:[n?` `:``,h(_,{color:ar(t,r),backgroundColor:r.tagBg,children:[` `,`[`,e,`]`,` `]})]})}function lr(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)*.6666666666666666))}function ur(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)*.3333333333333333))}function dr(e,t,n){let r=Number.isFinite(e)&&e>0?e:0,i=n??ur(t);return Math.min(i,Math.max(15,r))}function fr(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)/3))}function pr(e,t,n=0,r=5){let i=Math.min(Number.isFinite(e)&&e>0?Math.floor(e):0,r),a=Math.max(1,ur(t)-n);return Math.min(i,a)}function mr(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function hr(e){let t=Math.round(mr(e.percent)),n=Math.max(0,Math.floor(e.width));if(n===0)return{pct:t,filledCount:0,cells:[]};let r=e.segments?.filter(e=>e.width>0)??[],i=r.length>0,a,o;if(i){a=[];for(let e of r)for(let t=0;t<e.width;t++)a.push({filled:!0,segmentKey:e.key});for(o=a.length;a.length<n;)a.push({filled:!1})}else o=Math.max(0,Math.min(n,Math.round(t/100*n))),a=Array.from({length:n},(e,t)=>({filled:t<o}));if(e.markers)for(let[t,r]of Object.entries(e.markers)){if(!Number.isFinite(r))continue;let e=Math.max(0,Math.min(n-1,Math.round(r/100*n))),i=a[e];i&&(i.markerKey=t)}return{pct:t,filledCount:o,cells:a}}const gr={ascii:{filled:`=`,empty:`.`},block:{filled:`█`,empty:`░`},dot:{filled:`▰`,empty:`▱`}};function _r(e){return e?typeof e==`string`?gr[e]:e:gr.block}function vr({label:e,indent:t=` `}){let n=K(),r=typeof e==`string`?e:String(e??``);return h(_,{color:n.inactive,bold:!0,children:[t,r.toUpperCase()]})}function yr(e,t,n,r,i){let a=e.length;if(!Number.isFinite(n))return{rows:[...e],fillerCount:0,hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};if(n<=0||a===0)return{rows:[],fillerCount:Math.max(0,n),hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};let o=t>=0?t:0,s=r;o<s?s=i?Math.min(o,Math.max(0,i(o))):o:o>=s+n&&(s=o-n+1);let c=Math.max(0,a-n);s=Math.min(Math.max(0,s),c);let l=Math.min(a,s+n),u=e.slice(s,l);return{rows:u,fillerCount:Math.max(0,n-u.length),hasMoreAbove:s>0,hasMoreBelow:l<a,scrollTop:s}}function br(e,t=`below`){let n=[],r,i=0;return e.forEach((e,a)=>{e.group&&e.group!==r&&(i>0&&n.push({kind:`spacer`}),n.push({kind:`divider`,label:e.group}),i++),r=e.group,n.push({kind:`item`,option:e,optionIndex:a}),e.detail&&t===`below`&&n.push({kind:`detail`,option:e,optionIndex:a})}),n}function xr(e,t,n,r){return yr(e,e.findIndex(e=>e.kind===`item`&&e.optionIndex===t),n,r,t=>{let n=t;for(;n>0&&e[n-1]?.kind===`divider`;)n--;for(;n>0&&e[n-1]?.kind===`spacer`;)n--;return n})}function Sr(){let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}function Cr(e){return Math.max(1,Math.round(e/80))*80}const wr={now:()=>Date.now(),setTimer:(e,t)=>{let n=setTimeout(e,t);return n.unref?.(),n},clearTimer:e=>clearTimeout(e)};function Tr(e={}){let t=e.clock??wr,n=e.reducedMotion??(()=>{let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}),r=new Set,i=null,a=t.now(),o=e=>e.startedAtElapsed+(e.lastFrame+1)*e.periodMs,s=()=>{if(i!==null&&(t.clearTimer(i),i=null),r.size===0)return;let e=t.now()-a,n=1/0;for(let e of r){let t=o(e);t<n&&(n=t)}let s=Math.max(0,n-e);i=t.setTimer(c,s)},c=()=>{i=null;let e=t.now()-a;for(let t of r){let n=Math.floor((e-t.startedAtElapsed)/t.periodMs);if(n!==t.lastFrame){t.lastFrame=n;try{t.onFrame(n)}catch{}}}s()};return{subscribe(e,i){if(!Number.isFinite(e)||e<=0||n())return()=>{};let o=Cr(e),c=t.now()-a,l={periodMs:o,onFrame:i,lastFrame:0,startedAtElapsed:Math.floor(c/80)*80};return r.add(l),s(),()=>{r.delete(l),s()}},minPeriodMs(){let e;for(let t of r)e=e===void 0?t.periodMs:Math.min(e,t.periodMs);return e},size:()=>r.size,dispose(){r.clear(),i!==null&&(t.clearTimer(i),i=null)}}}const Er=Tr();function Dr(e,t){let n=d(t);n.current=t,l(()=>{if(e!=null)return Er.subscribe(e,e=>n.current(e))},[e])}function Or(e,t={}){let n=t.maxVisible??10,r=e.findIndex(e=>!e.disabled);r<0&&(r=0);let i=0;function a(){r<i?i=r:r>=i+n&&(i=r-n+1);let t=Math.max(0,e.length-n);i<0&&(i=0),i>t&&(i=t)}function o(n){if(n<0){t.onBoundary?.(`top`);return}if(n>=e.length){t.onBoundary?.(`bottom`);return}let i=n>r?1:-1,o=n;for(;o>=0&&o<e.length&&e[o]?.disabled;)o+=i;if(o<0){t.onBoundary?.(`top`);return}if(o>=e.length){t.onBoundary?.(`bottom`);return}r=o,a(),o===0&&t.onBoundary?.(`top`),o===e.length-1&&t.onBoundary?.(`bottom`)}return a(),{get selectedIndex(){return r},get scrollOffset(){return i},getVisibleOptions(){return e.slice(i,i+n)},getOptionAt(t){return e[t]},hasMoreAbove(){return i>0},hasMoreBelow(){return i+n<e.length},getSelected(){return e[r]??null},moveUp(){o(r-1)},moveDown(){o(r+1)},accept(){return e[r]??null},selectByHotkey(t){let n=e.findIndex(e=>e.hotkey===t);return n>=0&&!e[n]?.disabled?(r=n,a(),e[n]):null},selectByIndex(t){t>=0&&t<e.length&&!e[t]?.disabled&&(r=t,a())}}}function kr(e,t){return t.escape?{type:`cancel`}:t.return?{type:`accept`}:Cn(`list-nav-up`,e,t)?{type:`up`}:Cn(`list-nav-down`,e,t)?{type:`down`}:/^[1-9]$/.test(e)?{type:`index`,index:Number(e)-1}:null}const Ar={black:0,red:.3,green:.55,yellow:.93,blue:.2,magenta:.4,cyan:.7,white:1,gray:.5,grey:.5};function jr(e){if(e.startsWith(`#`)){let t=e.slice(1),[n,r,i]=(t.length===3?[t[0]+t[0],t[1]+t[1],t[2]+t[2]]:[t.slice(0,2),t.slice(2,4),t.slice(4,6)]).map(e=>parseInt(e,16)/255);return .299*n+.587*r+.114*i}return Ar[e.toLowerCase()]??.5}function Mr(e){return e&&jr(e)>.55?`black`:`white`}function Nr(e,t){switch(e){case`accent`:return t.selection;case`amber`:return t.warning;case`red`:return t.error;case`green`:return t.success;case`gray`:return t.panelBorder}}function Pr(e,t){return Nr(e,t)}function Fr(e,t=w){let{label:n,variant:r=`ghost`,color:i=`accent`,focused:a=!1,disabled:o=!1}=e,s=e.brackets??r===`outline`,c=`[ ${n} ]`;if(o)return{label:c,color:t.inactive,bold:!1,dim:!0};if(r===`ghost`){let e=` ${n} `;if(a){let n=Nr(i,t);return{label:s?c:e,color:Mr(n),backgroundColor:n,bold:!0,dim:!1}}return{label:s?c:e,color:t.inactive,bold:!1,dim:!1}}let l=Nr(i,t),u=Pr(i,t);if(r===`solid`){let e=` ${n} `;return a?{label:s?c:e,color:Mr(l),backgroundColor:l,bold:!0,dim:!1}:{label:s?c:e,color:s?t.inactive:u,bold:!1,dim:!1}}return a?{label:s?c:` ${n} `,color:u,bold:!0,dim:!1}:{label:s?c:` ${n} `,color:t.inactive,bold:!1,dim:!1}}function Ir({label:e,variant:t=`ghost`,color:n=`accent`,focused:r,disabled:i=!1,brackets:a,tabIndex:o=-1,onAction:s}){let c=K(),{focused:l}=Je({tabIndex:o,disabled:i||o<0,onAction:s}),u=Fr({label:e,variant:t,color:n,focused:r??l,disabled:i,brackets:a},c);return m(_,{color:u.color,backgroundColor:u.backgroundColor,bold:u.bold,dimColor:u.dim||void 0,children:u.label})}function Lr(e){return null}Lr.displayName=`Select.Item`;function Rr(e){return null}Rr.displayName=`Select.Label`;function zr(e){return null}zr.displayName=`Select.Group`;function Br(){return null}Br.displayName=`Select.Separator`;function Vr({children:e}){return m(p,{children:e})}Vr.displayName=`Select.Content`;function Hr(e){return null}Hr.displayName=`Select.Trigger`;function Ur(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(Array.isArray(e))return e.map(Ur).join(``);if(i.isValidElement(e)){let t=e.props;return Ur(t.children)}return``}function Wr(e){let t=[],n=0;function r(e,a){i.Children.forEach(e,e=>{if(!i.isValidElement(e))return;let o=e.type;if(o.displayName===`Select.Item`){let r=e.props;n+=1,t.push({value:r.value,label:Ur(r.children),disabled:r.disabled,detail:r.detail,indent:r.indent,marker:r.marker,ordinal:n,trailingLabel:r.trailingLabel,trailingColor:r.trailingColor,labelColor:r.labelColor,group:a});return}if(o.displayName===`Select.Group`){let t=e.props,n;i.Children.forEach(t.children,e=>{i.isValidElement(e)&&e.type.displayName===`Select.Label`&&(n=Ur(e.props.children))}),r(t.children,n);return}if(o.displayName===`Select.Label`||o.displayName===`Select.Separator`||o.displayName===`Select.Trigger`)return;let s=e.props;s.children!==void 0&&r(s.children,a)})}return r(e,void 0),t}function Gr({title:t,subtitle:n,headerAction:r,defaultValue:i,onValueChange:a,onCancel:o,maxVisible:s=10,footer:c,active:l=!0,onKey:v,frame:y=!0,highlightSelection:b=!0,rows:x=24,extensionHeightBudget:S=!1,detailPlacement:C=`below`,children:w}){let T=K(),E=u(()=>Wr(w),[w]),D=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.label))):0,[C,E]),O=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.trailingLabel??``))):0,[C,E]),k=d(null);if(!k.current){let e=i?E.findIndex(e=>e.value===i):-1;k.current=Or(E,{maxVisible:s}),e>=0&&k.current.selectByIndex(e)}let A=k.current,[j,M]=f(!1);Dr(2e3,e=>M(e%2==1));let[,ee]=f(0),te=()=>ee(e=>e+1),[N,P]=f(()=>!!r&&!E.some(e=>!e.disabled));J(`select-primitive`,(e,t)=>{if(v?.(e,t,A.getSelected())){te();return}if(r&&N){if(t.return){r.onPress();return}if(t.downArrow){P(!1),te();return}if(t.escape){o?.();return}return}let n=kr(e,t);if(n)switch(n.type){case`cancel`:o?.();return;case`up`:{let e=A.selectedIndex;A.moveUp(),r&&A.selectedIndex===e&&P(!0),te();return}case`down`:A.moveDown(),te();return;case`index`:{A.selectByIndex(n.index);let e=A.getSelected();e&&!e.disabled&&a?.(e.value);return}case`accept`:{let e=A.accept();e&&!e.disabled&&a?.(e.value);return}}},{isActive:l});let F=u(()=>br(E,C),[E,C]),ne=d(0),I=3+(t?2:0)+(n?1:0)+(r?1+(n?1:0):0)+2+2,R=fr(x),z=y?S?Math.max(1,Math.min(F.length,R-I)):dr(F.length+I,x)-I:1/0,B=xr(F,A.selectedIndex,z,ne.current);ne.current=B.scrollTop;let re=E[A.selectedIndex]??null,ie=h(p,{children:[t&&m(Re,{children:t}),t&&m(g,{marginTop:G.tight}),n&&m($,{type:`secondary`,children:n}),r&&h(g,{flexDirection:`row`,alignSelf:`flex-start`,marginTop:n?G.tight:G.none,children:[h(_,{color:T.accent,children:[r.hint,` `]}),m(Ir,{variant:`ghost`,brackets:!0,color:`accent`,label:r.label,focused:N,tabIndex:-1})]})]}),V=h(p,{children:[m(g,{height:1,children:m(rr,{hasMore:B.hasMoreAbove})}),B.rows.map((t,n)=>{if(t.kind===`spacer`)return m(_,{children:` `},`spacer-${n}`);if(t.kind===`divider`)return m(g,{flexDirection:`column`,children:m(vr,{label:t.label,indent:``})},`div-${n}`);let r=t.option;if(t.kind===`detail`){let e=r.indent??` `,n=r.detail??``,i=r.marker===`number`?` `.repeat(`${r.ordinal}. `.length):r.marker?` `.repeat(`${r.marker} `.length):``,a=/^● (.+?) · /u.exec(n),o=a?.[1],s=a?n.slice(a[0].length):n;return h(g,{flexDirection:`row`,children:[m(g,{flexShrink:0,children:h($,{type:`secondary`,dim:!0,children:[` `,e,i]})}),o?m(g,{flexShrink:0,children:h(_,{color:T.accent,children:[j?U.breatheBright:U.breatheDim,` `,o]})}):null,m(g,{flexGrow:1,flexShrink:1,minWidth:0,children:m($,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:o?` · ${s}`:s})})]},`detail-${t.optionIndex}`)}let i=r.indent??` `,a=r.marker===`number`?`${r.ordinal}. `:r.marker?`${r.marker} `:``,o=b&&r===re&&!N,s=C===`inline`&&r.detail;return h(g,{flexDirection:`row`,children:[m(g,{flexShrink:0,children:h(_,{color:r.disabled?T.inactive:o?T.selection:r.labelColor??T.inactive,dimColor:r.disabled,bold:o&&!r.disabled,wrap:`truncate-end`,children:[o&&!r.disabled?ce():le(),i,a,s?`${Gt(r.label,D)} ${Gt(r.trailingLabel??``,O)} `:r.label,r.disabled?` (${e.t(`common.disabled`)})`:``]})}),s&&m(g,{flexGrow:1,flexShrink:1,minWidth:0,children:m($,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:r.detail})}),r.trailingLabel&&!s&&h(p,{children:[m($,{type:`secondary`,children:` `}),m(_,{color:r.trailingColor??T.inactive,dimColor:!r.trailingColor,children:r.trailingLabel})]})]},`item-${t.optionIndex}`)}),Array.from({length:B.fillerCount},(e,t)=>m(_,{children:` `},`filler-${t}`)),m(g,{height:1,children:m(ir,{hasMore:B.hasMoreBelow})})]});return y?m(Le,{header:ie,footer:c??m(Be,{items:[[`${q.up}${q.down}`,e.t(`hint.select`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),maxHeight:S&&y?R:void 0,children:V}):h(g,{flexDirection:`column`,children:[ie,V]})}const Kr={Root:Gr,Trigger:Hr,Content:Vr,Group:zr,Label:Rr,Item:Lr,Separator:Br};function qr({title:t,message:n,confirmLabel:r,cancelLabel:i,confirmColor:a=`accent`,dangerous:o=!1,extraLabel:c,extraColor:l=`amber`,checkLabel:u,checked:d=!1,onConfirm:p,onCancel:v,onExtra:y,onCheckChange:b}){let x=!!c,S=x?2:1,[C,w]=f(o?S:0),[T,E]=f(d),D=Array.isArray(n)?n:[n],O=s(()=>{let e=!T;E(e),b?.(e)},[T,b]);Je({onEscape:()=>(v(),!0)}),J(`confirm-dialog-buttons`,(e,t)=>{if(t.escape)return v(),!0;let n=or(t);return n===0?t.return?(w(e=>(e===0?p():x&&e===1?y?.():v(),e)),!0):u&&e===` `&&!t.ctrl&&!t.meta?(O(),!0):!1:(w(e=>sr(e,n,S+1)),!0)});let k=r??e.t(`common.confirmButton`),A=i??e.t(`common.genericCancelButton`);return h(Le,{header:m(Re,{children:t}),footer:m(Be,{items:[[`${q.left}${q.right}`,e.t(`hint.switch`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:D.map((e,t)=>m(_,{wrap:`truncate-end`,children:e===``?` `:e},t))}),u&&h(g,{marginTop:G.tight,children:[h($,{type:`secondary`,children:[T?U.bullet:U.todoPending,` `]}),m($,{type:`secondary`,children:u})]}),h(g,{marginTop:G.tight,flexDirection:`row`,gap:G.section,children:[m(Ir,{variant:`solid`,brackets:!0,color:a,label:k,focused:C===0}),x&&m(Ir,{variant:`solid`,brackets:!0,color:l,label:c,focused:C===1}),m(Ir,{variant:`solid`,brackets:!0,color:`gray`,label:A,focused:C===S})]})]})}function Jr({tabIndex:e=0,autoFocus:t=!1,options:n,onSelect:r,initialIndex:i=0,maxVisible:a=8,id:o,compact:s=!1}){let c=K(),{focused:l}=Je({tabIndex:e,autoFocus:t,id:o}),[u,d]=f(Math.min(i,n.length-1));at(l,(e,t)=>{if(t.upArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e-r+n.length)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.downArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e+r)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.return){let e=n[u];return e&&!e.disabled&&r(e.value),!0}for(let t=0;t<Math.min(n.length,9);t++)if(e===String(t+1)&&n[t]&&!n[t].disabled)return r(n[t].value),!0;return!1});let p=n.length,v=p<=a?0:Math.min(Math.max(0,u-Math.floor(a/2)),p-a),y=n.slice(v,v+a);return h(g,{flexDirection:`column`,children:[v>0&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▲ `,v]})}),y.map((e,t)=>{let n=v+t===u,r=n&&l,i=e.disabled?c.inactive:r||n?c.selection:c.inactive,a=n&&!e.disabled;return h(g,{marginBottom:s?G.none:G.tight,flexDirection:`column`,children:[h(_,{color:i,bold:a,children:[r?ce():le(),e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m(_,{color:c.inactive,children:e.detail})})]},e.value)}),v+a<p&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▼ `,p-v-a]})})]})}function Yr({label:e,detail:t,disabled:n,children:r}){let i=K();return h(g,{flexDirection:`column`,children:[m(_,{color:n?i.inactive:void 0,children:e}),t&&m(_,{color:i.inactive,dimColor:!0,children:t}),r]})}function Xr(e,t){switch(e){case`success`:return t.success;case`warning`:return t.warning;case`error`:return t.error;case`muted`:return t.inactive;case`secondary`:return t.secondary}}function Zr(e){let t=[],n=[];for(let r of e)r.kind===`group`?(n.length>0&&t.push(n),n=[r]):n.push(r);return n.length>0&&t.push(n),t}function Qr({entries:e}){let t=K();return m(g,{flexDirection:`column`,children:Zr(e).map((e,n)=>{let r=e.filter(e=>e.kind===`row`),i=Math.max(0,...r.map(e=>L(e.label)));return m(g,{flexDirection:`column`,marginTop:n>0?G.tight:G.none,children:e.map((e,n)=>{if(e.kind===`group`)return m(vr,{label:e.title},n);if(e.kind===`blank`)return m(_,{children:` `},n);if(e.kind===`text`)return m(_,{color:e.tone?Xr(e.tone,t):void 0,dimColor:e.tone===`muted`,children:e.value},n);let r=` `.repeat(Math.max(0,i-L(e.label)));return h(_,{children:[` `,m(_,{color:t.inactive,children:e.label}),r,` `,m(_,{color:e.tone?Xr(e.tone,t):void 0,children:e.value})]},n)})},n)})})}function $r(t){switch(t){case`retry`:return e.t(`retry.nowButton`);case`login`:return e.t(`model.goToLoginButton`);case`extension`:return e.t(`model.goToExtensionButton`)}}function ei(e,t){switch(e){case`success`:return t.success;case`muted`:return t.inactive;case`warning`:return t.warning}}function ti({title:t,lines:n,lineTones:r,onDismiss:i,action:a,dataListEntries:o}){let s=K();J(`info-dialog`,(e,t)=>t.escape?(i(),!0):t.return&&a?(i(),queueMicrotask(()=>a.run()),!0):!1);let c=a?$r(a.kind):void 0;return h(Le,{header:m(Re,{children:t}),footer:m(Be,{items:a?[[q.enter,c],[q.esc,e.t(`hint.close`)]]:[[q.esc,e.t(`hint.close`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:o?m(Qr,{entries:o}):n.map((e,t)=>{let n=r?.[t];return m(_,{color:n?ei(n,s):void 0,dimColor:n===`muted`,wrap:`truncate-end`,children:e===``?` `:e},t)})}),a&&m(g,{marginTop:G.tight,children:m(Ir,{variant:`solid`,brackets:!0,color:`accent`,label:c,focused:!0})})]})}function ni({percent:e,width:t,chars:n,color:r,segments:i,markers:a,labelPosition:o=`suffix`,labelPrefix:s=``}){let c=K(),{filled:l,empty:u}=_r(n),d=hr({percent:e,width:t,segments:i?.map(e=>({key:e.key,width:e.width}))}),f=new Map((i??[]).map(e=>[e.key,e.color])),p=new Map((i??[]).map(e=>[e.key,e.dimColor??!1])),g=new Map(Object.entries(a??{}).map(([e,t])=>[t.pos,{name:e,color:t.color}])),v=(e=>typeof r==`function`?r(e):typeof r==`string`?r:c.inactive)(d.pct),y=`${s}${d.pct}%`;return h(_,{children:[o===`prefix`?h(_,{color:v,bold:!0,children:[y,` `]}):null,d.cells.map((e,t)=>{let n=g.get(t),r=c.inactive;e.filled&&(r=e.segmentKey?f.get(e.segmentKey)??v:v),n&&e.filled&&(r=n.color);let i=e.filled&&e.segmentKey?p.get(e.segmentKey)??!1:!1;return m(_,{color:r,dimColor:i,children:e.filled?l:u},t)}),o===`suffix`?h(_,{children:[` `,y]}):null]})}const ri={pending:U.todoPending,active:U.todoActive,done:U.check,error:U.cross};function ii(e,t){let n=[];return e.forEach((e,r)=>{let i=t[r]??`pending`;i!==`pending`&&n.push({label:e,status:i})}),n}function ai({title:t,phases:n,phaseStatuses:r,percent:a,detail:o,subProgress:s,status:c,errorMessage:u,nextStep:v,onDismiss:y}){let b=K(),x=c===`running`,S=d(null);l(()=>{if(c===`success`)return S.current=setTimeout(y,2e3),()=>{S.current&&clearTimeout(S.current)}},[c,y]);let[C,w]=f(0);return Dr(c===`running`?160:null,e=>{w(e%ue.length)}),J(`progress-dialog`,(e,t)=>(t.return||t.escape)&&c!==`running`?(y(),!0):!1),m(Le,{header:m(Re,{children:t}),footer:c===`partial`||c===`error`?m(Be,{items:[[`${q.enter}/${q.esc}`,e.t(`hint.close`)]]}):void 0,children:h(g,{flexDirection:`column`,paddingX:G.tight,children:[m(g,{height:1}),x?n.map((e,t)=>{let n=r[t]??`pending`,i=n===`active`,a=n===`error`,s=n===`done`,c=b.inactive;return i?c=b.accent:a?c=b.error:s&&(c=b.success),h(g,{children:[h(_,{color:c,children:[ri[n]??` `,` `]}),m(_,{color:i?b.accent:a?b.error:s?b.success:b.inactive,children:e}),i?h(p,{children:[h(_,{color:b.accent,children:[` `,ue[C],` `]}),m($,{type:`secondary`,children:o})]}):null]},t)}):null,!x&&c!==`success`?m(g,{children:ii(n,r).map((e,t)=>h(i.Fragment,{children:[t>0?m($,{type:`secondary`,children:` · `}):null,h(_,{color:e.status===`error`?b.error:e.status===`done`?b.success:b.accent,children:[ri[e.status],` `]}),m($,{type:`secondary`,children:e.label})]},t))}):null,s&&c===`running`?m(g,{marginTop:G.tight,children:h(cr,{children:[s.current,`/`,s.total]})}):null,x?m(g,{marginTop:G.tight,marginBottom:G.tight,children:m(ni,{percent:a,width:40,chars:`ascii`,color:b.accent})}):null,x?null:h(g,{marginTop:c===`success`?G.none:G.tight,flexDirection:`column`,children:[m(g,{children:h(_,{bold:!0,color:c===`success`?b.success:c===`partial`?b.warning:b.error,children:[c===`success`?U.check:c===`partial`?U.warn:U.cross,` `,c===`success`?e.t(`install.done`):c===`partial`?e.t(`install.summaryPartial`):e.t(`install.summaryFailed`)]})}),c!==`success`&&u?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,wrap:`wrap`,children:u})}):null,v?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,children:v.label})}):null]})]})})}function oi(e){return e.some(e=>e.freeformInput===!0)}function si(e){return{tab:0,cursor:0,selected:e.map(()=>[]),freeformText:``,freeformOffset:0}}function ci(e,t,n=!1){return t.escape?{type:`cancel`}:t.tab?{type:t.shift?`tabPrev`:`tabNext`}:Cn(`list-nav-up`,e,t)?{type:`cursorPrev`}:Cn(`list-nav-down`,e,t)?{type:`cursorNext`}:!n&&(e===` `||t.return)?{type:`choose`}:null}function li(e,t,n){let r=oi(n),i=n.length+(r?1:0),a=r?n.length:-1;switch(t?.type){case`cancel`:return{state:e,done:`cancel`};case`tabPrev`:return{state:{...e,tab:(e.tab-1+i+1)%(i+1),cursor:0}};case`tabNext`:return{state:{...e,tab:(e.tab+1)%(i+1),cursor:0}};case`cursorPrev`:return e.tab===i||e.tab===a?{state:e}:{state:{...e,cursor:Math.max(0,e.cursor-1)}};case`cursorNext`:{if(e.tab===i||e.tab===a)return{state:e};let t=n[e.tab].options.length;return{state:{...e,cursor:Math.min(t-1,e.cursor+1)}}}case`choose`:{if(e.tab===i)return{state:e,done:`submit`};if(e.tab===a)return{state:{...e,tab:i}};let t=n[e.tab],r=e.selected[e.tab]??[],o=t.multiSelect?r.includes(e.cursor)?r.filter(t=>t!==e.cursor):[...r,e.cursor]:[e.cursor],s=e.selected.map((t,n)=>n===e.tab?o:t),c=t.multiSelect?e.tab:Math.min(i,e.tab+1);return{state:{...e,selected:s,tab:c,cursor:0}}}default:return{state:e}}}function ui(e,t){let n={};return t.forEach((t,r)=>{n[t.header]=(e.selected[r]??[]).map(e=>t.options[e]?.label).filter(e=>typeof e==`string`)}),n}function di(e,t){return t.every((t,n)=>(e.selected[n]?.length??0)>0)}function fi(e){return Ut(e,23)}function pi({title:t,questions:n,onSubmit:r,onCancel:a,columns:o=60}){let s=K(),c=oi(n),l=d(null);l.current??=si(n);let[,u]=f(0),v=c?n.length:-1,y=n.length+(c?1:0),b=e=>{let t=l.current,i=ci(``,{tab:!0,shift:e},t.tab===v);if(!i)return!1;let{state:o,done:s}=li(t,i,n);return l.current=o,s===`cancel`?(a?.(),!0):s===`submit`?(r(ui(o,n),o.freeformText||void 0),!0):(u(e=>e+1),!0)};Je({onEscape:()=>(a?.(),!0),onTab:e=>b(e)}),J(`questions-dialog`,(e,t)=>{let i=l.current;if(i.tab===v){if(t.escape&&i.freeformText.length===0){a?.();return}if(t.tab){b(t.shift??!1);return}if((t.ctrl||t.meta)&&(t.leftArrow||t.rightArrow||t.home||t.end)){let e={name:t.home?`home`:t.end?`end`:t.leftArrow?`left`:`right`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},n=Lt(At.fromText(i.freeformText,o,i.freeformOffset),e);n&&(l.current={...i,freeformText:n.cursor.text,freeformOffset:n.cursor.offset},u(e=>e+1));return}if(t.home||t.end){let e={name:t.home?`home`:`end`,ctrl:!1,shift:!1,alt:!1,meta:!1},n=Lt(At.fromText(i.freeformText,o,i.freeformOffset),e);n&&(l.current={...i,freeformText:n.cursor.text,freeformOffset:n.cursor.offset},u(e=>e+1));return}if(t.leftArrow){let e=At.fromText(i.freeformText,o,i.freeformOffset).left();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(t.rightArrow){let e=At.fromText(i.freeformText,o,i.freeformOffset).right();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(e.length>1&&!t.ctrl&&!t.meta&&!t.return&&!t.escape&&!t.backspace&&!t.delete&&!t.leftArrow&&!t.rightArrow){let t=Rt(e);if(t){let e=i.freeformText,n=i.freeformOffset;l.current={...i,freeformText:e.slice(0,n)+t+e.slice(n),freeformOffset:n+t.length},u(e=>e+1)}return}if(t.return){let{state:e,done:t}=li(i,ci(``,{tab:!0},!0),n);if(l.current=e,t===`submit`){r(ui(e,n),e.freeformText||void 0);return}u(e=>e+1);return}let s={name:t.escape?`escape`:t.backspace?`backspace`:t.delete?`delete`:e||`unknown`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},c=Lt(At.fromText(i.freeformText,o,i.freeformOffset),s);if(!c)return;l.current={...i,freeformText:c.cursor.text,freeformOffset:c.cursor.offset},u(e=>e+1);return}let s=ci(e,t);if(!s)return;let{state:c,done:d}=li(i,s,n);if(l.current=c,d===`cancel`){a?.();return}if(d===`submit`){r(ui(c,n),c.freeformText||void 0);return}u(e=>e+1)});let x=l.current,S=x.tab===y,C=x.tab===v?m(Be,{items:[[q.enter,e.t(`freeform.advance`)],[q.esc,e.t(`hint.cancel`)]]}):m(Be,{items:[[`${q.up}${q.down}`,e.t(`hint.option`)],[q.tab,e.t(`hint.question`)],S?[q.enter,e.t(`hint.submit`)]:[`space/${q.enter}`,e.t(`hint.choose`)],[q.esc,e.t(`hint.cancel`)]]});return h(Le,{header:t?m(Re,{children:t}):void 0,footer:C,children:[h(g,{flexDirection:`row`,marginTop:G.tight,children:[n.map((e,t)=>{let n=(x.selected[t]?.length??0)>0,r=x.tab===t,a=r?s.selection:n?s.success:s.inactive;return h(i.Fragment,{children:[t>0&&m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:a,bold:r,children:fi(e.header)})]},t)}),c&&h(p,{children:[m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:x.tab===v?s.selection:x.freeformText?s.success:s.inactive,bold:x.tab===v,children:e.t(`freeform.tab`)})]}),m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:S?s.selection:s.inactive,bold:S,children:e.t(`prompt.submit`)})]}),S?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:di(x,n)?s.success:s.warning,children:di(x,n)?e.t(`questions.readyToSubmit`):e.t(`questions.someUnanswered`)}),m(g,{marginTop:G.tight,children:m(Ir,{variant:`solid`,brackets:!0,color:`accent`,label:e.t(`prompt.submit`),focused:!0})})]}):x.tab===v?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:s.secondary,children:e.t(`freeform.label`)}),m(g,{marginTop:G.tight,children:m(hn,{value:x.freeformText,offset:x.freeformOffset,columns:o,mode:`dialog`,placeholder:e.t(`freeform.placeholder`),focused:!0,physicalCursor:!0})})]}):h(g,{flexDirection:`column`,marginTop:G.tight,children:[n[x.tab].question!==t&&m(_,{color:s.text,children:n[x.tab].question}),m(g,{flexDirection:`column`,marginTop:G.tight,children:n[x.tab].options.map((e,t)=>{let n=t===x.cursor,r=(x.selected[x.tab]??[]).includes(t),i=r?U.bullet:U.todoPending;return h(g,{flexDirection:`column`,children:[h(g,{flexDirection:`row`,children:[m(_,{color:n?s.selection:s.inactive,bold:n,children:n?ce():le()}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:i}),m(_,{children:` `}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:e.label})]}),e.description&&m(g,{marginLeft:G.loose,children:m($,{type:`secondary`,dim:!0,children:e.description})})]},t)})})]})]})}function mi(e,t,n,r){return h(g,{flexDirection:`row`,marginBottom:G.tight,children:[n.map((n,a)=>{let o=t.has(a),s=a===e,c=o?U.check:s?U.todoDone:U.todoPending,l=o?r.inactive:s?r.text:r.inactive;return h(i.Fragment,{children:[a>0&&m($,{type:`secondary`,children:` · `}),h(_,{color:l,bold:s,children:[c,` `,n]})]},a)}),h(g,{marginLeft:G.section,children:[m($,{type:`secondary`,children:`Step `}),m(_,{color:r.text,bold:!0,children:e+1}),h($,{type:`secondary`,children:[`/`,4]})]})]})}function hi(){return m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,dim:!0,children:Wt(U.hr,60)})})}function gi({request:t}){let n=K(),[r,i]=f(!1),[a,o]=f(!1),[c,u]=f(()=>Math.min(t.initialCurrent,3)),[p,v]=f(()=>new Set(t.initialCompleted)),[y,b]=f(null),[x,S]=f(null),[C,w]=f(null),[T,E]=f(null),[D,O]=f(null),[k,A]=f([]),[j,M]=f(!1),[ee,te]=f(null),N=d(null),[P,F]=f(`select`),[ne,I]=f(null),[L,R]=f(null),[z,B]=f(null),[re,ie]=f(``),V=d(``),[ae,oe]=f(t.authProviderName??``),se=s(e=>{V.current=e,ie(e)},[]),H=d(null),ce=d(!1),le=s(()=>{ce.current=!0,H.current?.cancel(),N.current&&=(clearTimeout(N.current),null),t.onDismiss()},[t]),ue=s(()=>{if(P!==`select`&&c===1){H.current?.cancel(),F(`select`),I(null),R(null),B(null),se(``),V.current=``,b(null);return}if(T){E(null),b(null);return}c===0?le():(v(e=>{let t=new Set(e);return t.delete(c-1),t}),u(e=>e-1),b(null),F(`select`),I(null),R(null),B(null),se(``),w(null),A([]),M(!1),E(null),N.current&&=(clearTimeout(N.current),null))},[c,le,P,T]);l(()=>()=>{H.current?.cancel(),N.current&&clearTimeout(N.current)},[]);let W=s(()=>{v(e=>new Set([...e,c])),b(null),S(null),w(null),A([]),M(!1),E(null),F(`select`),O(null),I(null),R(null),B(null),se(``),V.current=``,H.current=null,c>=3?(le(),t.onComplete()):u(e=>e+1)},[c,le,t]),de=d(null),fe=s(async e=>{S(e),b(null);let n=await t.onInstallProvider(e,()=>{});ce.current||(S(null),n.ok?(oe(n.providerId??e),A(n.capabilities??[]),M(n.pendingCapabilities===!0),w(e),N.current=setTimeout(()=>{N.current=null,W()},900)):(E(e),b(n.error)))},[t,W]);de.current=fe;let pe=s(()=>{let e=T;e&&(E(null),b(null),de.current?.(e))},[T]),me=s(()=>{E(null),b(null)},[]),he=d(null),ge=s(async()=>{if(t.onRefreshModelOptions)try{te(await t.onRefreshModelOptions())}catch{}},[t]),_e=s(async()=>{if(!t.onProviderOAuthStart)return;b(null),F(`oauth-wait`);let e=await t.onProviderOAuthStart(ae);if(!e){F(`select`),b(`OAuth flow not available for this provider.`);return}H.current=e,I(e.authorizationUrl),R(e.code??null),B(e.instructions??null);let n=async()=>{if(ce.current)return;let t=await e.poll();if(ce.current)return;let r=typeof t==`string`?t:t.status,i=typeof t==`string`?void 0:t.reason;r===`pending`?setTimeout(()=>{n().catch(()=>{})},1500):r===`done`?(await ge(),W()):i===`cancelled`?F(`select`):O(i===`network`?`network`:`rejected`)};n().catch(()=>{})},[t,W,ae,ge]),ve=s(()=>{O(null),b(null),he.current?.()},[]),ye=s(()=>{O(null),t.onOpenProxySettings?.()},[t]);he.current=_e;let be=s(()=>{H.current?.openAgain?.()},[]),xe=s(()=>{H.current?.cancel(),H.current=null,I(null),R(null),B(null),b(null),se(``),F(`key-input`)},[se]),Se=s(async()=>{if(!t.onSubmitProviderApiKey||!V.current.trim())return;b(null),F(`logging-in`);let e=await t.onSubmitProviderApiKey(ae,V.current.trim());e.ok?(await ge(),W()):(F(`key-input`),b(e.error))},[t,W,re,ae,ge]),Ce=s(async e=>{b(null);try{await t.onSelectModel(e),W()}catch(e){b(e instanceof Error?e.message:String(e))}},[t,W]),we=s(()=>W(),[W]);J(`wizard-dialog`,(e,n)=>r?n.escape?(ue(),!0):!1:n.return?(t.onDontShowAgain(a),i(!0),!0):n.escape?(le(),!0):e===` `?(o(e=>!e),!0):!1);let Te=(()=>{if(!r)return[[q.enter,t.welcomeStartLabel],[q.esc,t.welcomeCancelLabel],[`Space`,t.welcomeDontShowAgainLabel]];let n=c===0&&!T?`exit`:`back`;switch(c){case 0:{let r=Math.min(t.providerOptions.length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionInstall`)],[q.esc,n]]}case 1:return P===`key-input`?[[q.enter,`submit`],[q.esc,n]]:P===`oauth-wait`?[[q.esc,`cancel`]]:[[`1-${Math.min(t.providerAuthOptions(ae).length,9)}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionLogin`)],[q.esc,n]];case 2:{let r=Math.min((ee??t.modelOptions).length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`hint.confirm`)],[q.esc,n]]}case 3:return[[q.enter,e.t(`hint.confirm`)]];default:return[[q.esc,n]]}})();return m(Le,{header:m(Re,{children:t.title}),footer:m(Be,{items:Te}),children:r?h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[mi(c,p,t.stepNames,n),m(g,{marginBottom:G.tight,flexDirection:`column`,children:m(_,{bold:!0,children:t.stepSubtitles[c]})}),m(hi,{}),y&&h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:n.error,children:[e.t(`setup.errorTitle`),`:`]}),m(_,{color:n.error,children:y})]}),m(_i,{step:c,request:t,installing:x,installSucceeded:C,installedCapabilities:k,installPendingCaps:j,installFailed:T,onRetryInstall:pe,onChooseAnother:me,authMode:P,setAuthMode:F,oauthUrl:ne,oauthCode:L,oauthInstructions:z,apiKey:re,apiKeyRef:V,setApiKey:se,onInstall:fe,onOAuthStart:_e,onApiKeySubmit:Se,onOpenAgain:be,onSwitchToApiKey:xe,onRetryAuth:ve,onOpenProxySettings:ye,authFailure:D,onModel:Ce,onComplete:we,selectedProvider:ae,modelOptionsOverride:ee})]}):h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[m(g,{marginBottom:G.tight,children:m(_,{bold:!0,children:t.welcomeTitle})}),t.welcomeGreeting&&m(g,{marginBottom:G.tight,children:m(_,{children:t.welcomeGreeting})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:t.welcomeDescription})}),m(hi,{}),m(g,{marginBottom:G.tight,children:h(_,{color:a?n.text:n.inactive,children:[a?U.bullet:U.todoPending,` `,t.welcomeDontShowAgainLabel]})})]})})}function _i(e){switch(e.step){case 0:return m(yi,{request:e.request,installing:e.installing,installSucceeded:e.installSucceeded,installedCapabilities:e.installedCapabilities,installPendingCaps:e.installPendingCaps,installFailed:e.installFailed,onRetryInstall:e.onRetryInstall,onChooseAnother:e.onChooseAnother,onInstall:e.onInstall});case 1:return m(bi,{request:e.request,authMode:e.authMode,setAuthMode:e.setAuthMode,oauthUrl:e.oauthUrl,oauthCode:e.oauthCode,oauthInstructions:e.oauthInstructions,apiKey:e.apiKey,apiKeyRef:e.apiKeyRef,setApiKey:e.setApiKey,onOAuthStart:e.onOAuthStart,onApiKeySubmit:e.onApiKeySubmit,onOpenAgain:e.onOpenAgain,onSwitchToApiKey:e.onSwitchToApiKey,onRetryAuth:e.onRetryAuth,onOpenProxySettings:e.onOpenProxySettings,authFailure:e.authFailure,selectedProvider:e.selectedProvider});case 2:return m(xi,{request:e.request,onModel:e.onModel,modelOptionsOverride:e.modelOptionsOverride});case 3:return m(Si,{request:e.request,onComplete:e.onComplete});default:return m(_,{children:`Unknown step`})}}function vi(){let e=K(),t=Sr(),[n,r]=f(0);return Dr(160,e=>r(e%ue.length)),t?null:h(_,{color:e.accent,children:[` `,ue[n]]})}function yi({request:t,installing:n,installSucceeded:r,installedCapabilities:i,installPendingCaps:a,installFailed:o,onRetryInstall:s,onChooseAnother:c,onInstall:l}){let u=K(),[d,p]=f(0),v=t.providerOptions,y=n!==null;if(r){let t=v.find(e=>e.value===r)?.label??r;return h(g,{flexDirection:`column`,children:[m(g,{children:h(_,{color:u.success,bold:!0,children:[U.check,` `,e.t(`setup.installedProvider`,{provider:t})]})}),a&&m(g,{marginTop:G.tight,children:m(_,{color:u.warning,children:e.t(`setup.installPendingCapabilities`)})}),i.length>0&&h(g,{marginTop:G.tight,flexDirection:`column`,children:[m($,{type:`secondary`,children:e.t(`setup.capabilityGranted`,{caps:i.join(`, `)})}),m($,{type:`secondary`,children:e.t(`setup.capabilityRevokeHint`)})]})]})}if(o)return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.installFailedRecovery`,{provider:o})})}),h(Y.Root,{id:`wizard-install-failed`,onPick:e=>{e===0?s():c()},children:[m(Y.Item,{label:e.t(`setup.actionRetryInstall`)}),m(Y.Item,{label:e.t(`setup.actionChooseAnotherProvider`)})]})]});if(y){let t=v.find(e=>e.value===n)?.label??n;return h(g,{children:[m(_,{color:u.text,children:e.t(`setup.installingProvider`,{provider:t})}),m(vi,{})]})}return m(Y.Root,{id:`wizard-dialog-2`,onPick:e=>{!y&&v[e]&&l(v[e].value)},activeIndex:d,onActiveChange:p,children:v.map(e=>m(Y.Item,{label:e.label,detail:e.detail,color:u.selection},e.value))})}function bi({request:t,authMode:n,setAuthMode:r,oauthUrl:i,oauthCode:a,oauthInstructions:o,apiKey:s,apiKeyRef:c,setApiKey:l,onOAuthStart:u,onApiKeySubmit:d,onOpenAgain:v,onSwitchToApiKey:y,onRetryAuth:b,onOpenProxySettings:x,authFailure:S,selectedProvider:C}){let w=K(),[T,E]=f(0),D=n,O=t.providerAuthOptions(C);if(J(`wizard-dialog-3`,(e,n)=>{if(D===`key-input`)return n.return&&c.current.trim()?(d(),!0):n.escape?(r(`select`),!0):e&&e.length>0?(l(c.current+e),!0):((n.backspace||n.delete)&&l(c.current.slice(0,-1)),!0);if(D!==`select`)return!1;if(n.upArrow||n.downArrow)return E(e=>(e+1)%Math.max(O.length,1)),!0;if(n.return&&O[T]){let e=O[T];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}let i=e?Number(e):NaN;if(Number.isInteger(i)&&i>=1&&i<=O.length){let e=O[i-1];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}return!1}),S){let t=S===`network`;return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{color:w.error,children:e.t(t?`setup.authFailedNetwork`:`setup.authFailedRejected`)})}),h(Y.Root,{id:`wizard-auth-failed`,onPick:e=>{if(t&&e===0){x();return}(t?e-1:e)===0?b():y()},children:[t?m(Y.Item,{label:e.t(`setup.actionOpenProxySettings`)}):null,m(Y.Item,{label:e.t(`setup.actionRetryAuth`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]})}return t.onProviderOAuthStart&&n===`oauth-wait`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:a?`Complete device authorization`:`Sign in via OAuth`})}),a?h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`1. Open this page:`})}),i&&m(g,{marginBottom:G.tight,children:h($,{type:`secondary`,children:[` `,i]})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`2. Enter this code:`})}),m(g,{marginBottom:G.tight,children:h(_,{bold:!0,color:w.text,children:[` `,a]})}),o&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:o})})]}):h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Open this URL in your browser to authorize:`})}),i&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:i})})]}),m(g,{marginBottom:G.tight,children:m(_,{color:w.text,children:e.t(`setup.oauthWaiting`)})}),h(Y.Root,{id:`wizard-oauth-wait`,onPick:e=>{e===0?v():y()},children:[m(Y.Item,{label:e.t(`setup.actionOpenAgain`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]}):n===`key-input`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:`Paste your API key`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Generate a key on your provider dashboard and paste it below.`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.apiKeyStorageNote`)})}),m(g,{marginBottom:G.tight,children:m(hn,{value:s,offset:0,columns:60,mode:`dialog`,mask:!0,placeholder:e.t(`setup.wizardApiKeyPlaceholder`),focused:!0})})]}):n===`logging-in`?m(g,{flexDirection:`column`,children:m(_,{color:w.text,children:e.t(`setup.loggingIn`)})}):h(g,{flexDirection:`column`,children:[C&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:C})}),m(g,{flexDirection:`column`,children:O.map((e,t)=>h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:t===T?w.selection:w.inactive,bold:t===T,children:[t===T?U.pointer:` `,` `,e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m($,{type:`secondary`,children:e.detail})})]},e.value))})]})}function xi({request:t,onModel:n,modelOptionsOverride:r}){let i=r??t.modelOptions,a=t=>t===`unauthenticated`?e.t(`setup.modelUnusableUnauthenticated`):t===`oauth-429-risk`?e.t(`setup.modelUnusableOauthRisk`):t===`intranet-unreachable`?e.t(`setup.modelUnusableIntranet`):``;return h(g,{flexDirection:`column`,children:[i.some(e=>e.recommended)&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.modelRecommendedHint`)})}),m(Kr.Root,{maxVisible:8,frame:!1,onValueChange:e=>{n(e)},children:i.map(t=>{let n=a(t.unusableReason),r=[t.recommended?e.t(`setup.modelRecommendedTag`):``,n,t.detail??``].filter(Boolean).join(` · `);return m(Kr.Item,{value:t.value,detail:r||void 0,children:t.label},t.value)})})]})}function Si({request:t,onComplete:n}){let r=K();return J(`wizard-dialog-4`,(e,t)=>t.return?(n(),!0):!1),h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.tryAsking`)})}),m(g,{flexDirection:`column`,marginBottom:G.tight,children:t.examplePrompts.map((e,t)=>h($,{type:`secondary`,children:[` "`,e,`"`]},t))}),m(_,{color:r.text,children:e.t(`setup.pressEnterToStart`)})]})}export{Gn as $,q as $t,or as A,C as An,bt as At,Zn as B,ot as Bt,lr as C,se as Cn,X as Ct,pr as D,re as Dn,Ct as Dt,dr as E,z as En,Dt as Et,$n as F,Qe as Ft,zn as G,Ye as Gt,Vn as H,lt as Ht,Qn as I,$e as It,Ln as J,He as Jt,Hn as K,Ge as Kt,Jn as L,dt as Lt,rr as M,T as Mn,Ze as Mt,ir as N,x as Nn,nt as Nt,cr as O,ie as On,wt as Ot,nr as P,et as Pt,Un as Q,Le as Qt,Xn as R,J as Rt,hr as S,L as Sn,zt as St,ur as T,H as Tn,Z as Tt,In as U,at as Ut,qn as V,ut as Vt,Rn as W,Ke as Wt,Bn as X,ze as Xt,Fn as Y,Be as Yt,Nn as Z,Re as Zt,br as _,fe as _n,Nt as _t,ti as a,ke as an,Cn as at,vr as b,le as bn,Pt as bt,Yr as c,K as cn,vn as ct,Ir as d,be as dn,en as dt,Ne as en,Mn as et,kr as f,xe as fn,Gt as ft,Sr as g,de as gn,Bt as gt,Dr as h,pe as hn,Ht as ht,ni as i,je as in,Sn as it,$ as j,w as jn,Y as jt,sr as k,S as kn,yt as kt,qr as l,De as ln,gn as lt,Er as m,G as mn,Ut as mt,pi as n,Fe as nn,kn as nt,Qr as o,Oe as on,xn as ot,Or as p,me as pn,Wt as pt,Pn as q,Je as qt,ai as r,Pe as rn,Tn as rt,Jr as s,Ee as sn,_n as st,gi as t,Ie as tn,On as tt,Kr as u,we as un,hn as ut,yr as v,U as vn,Mt as vt,fr as w,oe as wn,At as wt,_r as x,ce as xn,Rt as xt,xr as y,ue as yn,Lt as yt,Yn as z,rt as zt};
|
|
15
|
-
//# sourceMappingURL=WizardDialog-BWGcsBR1.js.map
|
|
14
|
+
`){i.push(o),o=``,s=0,u+=d.segment.length,a.push(u);continue}s+f>t&&o.length>0&&(i.push(o),o=``,s=0,a.push(u)),o+=d.segment,s+=f,u+=d.segment.length}return n>=u&&(c=i.length,l=o.length),i.push(o),{lines:i,cursorLine:c,cursorCharInLine:l,lineStarts:a}}function sn(e,t,n){if(!n)return{pre:e,sel:``,post:``};let r=Math.max(0,n.start-t),i=Math.min(e.length,n.end-t);return r>=i?{pre:e,sel:``,post:``}:{pre:e.slice(0,r),sel:e.slice(r,i),post:e.slice(i)}}function cn(e,t,n,r,i,a,o){let s=t?[{chunk:e,isChip:!1}]:ln(e);return s.length===0?[]:s.map((e,t)=>{let s=e.isChip&&dn(e,n);return m(_,{inverse:i,color:i?void 0:s?r.error:e.isChip?un(e.kind,r):void 0,strikethrough:s,children:e.chunk},`${a}${o+t}`)})}function ln(e){X.lastIndex=0;let t=[],n=0,r;for(;(r=X.exec(e))!==null;){r.index>n&&t.push({chunk:e.slice(n,r.index),isChip:!1});let i=r[0],a=Ct(i);t.push({chunk:i,isChip:!0,kind:a,pasteId:a===`paste`?wt(i):void 0}),n=r.index+i.length}return n<e.length&&t.push({chunk:e.slice(n),isChip:!1}),t}function un(e,t){if(e===void 0)return;let n=Ht(e)?.colorToken;return n?t[n]:void 0}function dn(e,t){return e.kind===`paste`&&e.pasteId!==void 0&&(t?.has(e.pasteId)??!1)}function fn(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(t>n.index&&t<n.index+n[0].length){let e=Ct(n[0]);return{kind:e,pasteId:e===`paste`?wt(n[0]):void 0}}}function pn(e,t){let n=Dt(e,t);if(!n)return;let r=Ct(n.text);return{text:n.text,kind:r,pasteId:r===`paste`?wt(n.text):void 0}}function mn(e){return Wt(`•`,L(e))}const hn=i.memo(function({value:t,offset:n,columns:r,mode:a=`send`,placeholder:o=``,maxVisibleLines:s=10,focused:c,tabIndex:l=-1,mask:u=!1,noPrefix:d=!1,ghostSuffix:f,invalidPasteIds:v,containerRef:y,physicalCursor:b=!1,deleteKeyAt:x=0,selection:S=null}){let C=K(),{focused:w}=Je({tabIndex:l,disabled:l<0}),T=c??w,E=d?``:a===`dialog`&&!u?`> `:rn[a],D=yt(E),O=E,k=Math.max(20,r-D),A=T,{lines:j,cursorLine:M,cursorCharInLine:ee,lineStarts:te}=i.useMemo(()=>on(t,k,n),[t,k,n]),N=S!==null&&S!==n?{start:Math.min(S,n),end:Math.max(S,n)}:null,P=i.useRef(null),F=i.useCallback(e=>{P.current=e,typeof y==`function`?y(e):y&&(y.current=e)},[y]),ne=nn(j.length,M,s),I=ne.startLine>0?1:0,L={column:D+yt((j[M]??``).slice(0,ee)),lineOffset:I+ne.cursorLineInWindow};if(en({active:b&&T,containerRef:P,text:t,inline:L,deleteKeyAt:x}),t.length===0&&o)return h(g,{ref:F,flexDirection:`row`,children:[m(_,{color:T?an(a,C):C.inactive,children:O}),T&&m(_,{inverse:A,children:` `}),m(_,{dimColor:!0,children:o})]});let R=j.length,{startLine:z,visibleRows:B}=nn(R,M,s),re=z+B,ie=j.slice(z,re);return h(g,{ref:F,flexDirection:`column`,children:[z>0&&m(_,{dimColor:!0,children:` … ${z} ${e.t(`scroll.viewportLinesAbove`)}`}),ie.map((e,t)=>{let n=z+t,r=n===M,i=u?mn(e):e;if(!r||!T){let{pre:r,sel:o,post:s}=sn(i,te[n]??0,N);return h(g,{flexDirection:`row`,children:[n===0&&O?m(_,{color:T?an(a,C):C.inactive,children:O}):D>0&&m(_,{dimColor:!0,children:` `.repeat(D)}),i.length===0?m(_,{children:` `}):h(p,{children:[cn(r,u,v,C,!1,`p`,0),cn(o,u,v,C,!0,`s`,1e3),cn(s,u,v,C,!1,`q`,2e3)]})]},`${t}-${e.slice(0,10)}`)}let o=Math.max(0,Math.min(ee,i.length)),s=!u&&o<i.length?pn(i,o):void 0;if(s){let r=i.slice(0,o),c=i.slice(o+s.text.length),l=s.kind===`paste`&&s.pasteId!==void 0&&(v?.has(s.pasteId)??!1);return h(g,{flexDirection:`row`,children:[n===0&&O?m(_,{color:T?an(a,C):C.inactive,children:O}):D>0&&m(_,{dimColor:!0,children:` `.repeat(D)}),ln(r).map((e,t)=>{let n=e.isChip&&dn(e,v);return m(_,{color:n?C.error:e.isChip?un(e.kind,C):void 0,strikethrough:n,children:e.chunk},`b-${t}`)}),m(_,{inverse:!0,color:l?C.error:void 0,strikethrough:l,children:s.text}),ln(c).map((e,t)=>{let n=e.isChip&&dn(e,v);return m(_,{color:n?C.error:e.isChip?un(e.kind,C):void 0,strikethrough:n,children:e.chunk},`a-${t}`)}),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}let c=i.slice(0,o),l=i.slice(o),d=l.length>0?[...l][0]??` `:` `,y=l.length>0?l.slice(d.length):``,b=!u&&l.length>0?fn(i,o):void 0,x=b?.kind===`paste`&&b.pasteId!==void 0&&(v?.has(b.pasteId)??!1),S=te[n]??0,w=N?{start:N.start,end:Math.min(N.end,S+o)}:null,E=N?{start:Math.max(N.start,S+o+1),end:N.end}:null,k=sn(c,S,w),j=sn(y,S,E),P=N!==null&&N.start<=S+o&&S+o<N.end;return h(g,{flexDirection:`row`,children:[n===0&&O?m(_,{color:T?an(a,C):C.inactive,children:O}):D>0&&m(_,{dimColor:!0,children:` `.repeat(D)}),cn(k.pre,u,v,C,!1,`b`,0),cn(k.sel,u,v,C,!0,`bs`,1e3),cn(k.post,u,v,C,!1,`bp`,2e3),m(_,{inverse:A||P,color:x?C.error:b==null?void 0:un(b.kind,C),strikethrough:x,children:d}),cn(j.pre,u,v,C,!1,`a`,0),cn(j.sel,u,v,C,!0,`as`,1e3),cn(j.post,u,v,C,!1,`ap`,2e3),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}),re<R&&m(_,{dimColor:!0,children:` … ${R-re} ${e.t(`scroll.viewportLinesBelow`)}`})]})}),gn=[{commandId:`cycle-permission-mode`,description:`循环切换权限模式`,predicate:{shift:!0,key:`tab`},scopes:`*`},{commandId:`toggle-notifications`,description:`打开/关闭通知中心`,predicate:{ctrl:!0,input:`n`},scopes:`*`},{commandId:`toggle-edited-files`,description:`打开/关闭编辑文件面板`,predicate:{ctrl:!0,input:`v`},scopes:`*`},{commandId:`toggle-subagents`,description:`打开/关闭子代理面板`,predicate:{ctrl:!0,input:`t`},scopes:`*`},{commandId:`toggle-delegates`,description:`打开/关闭委派面板`,predicate:{ctrl:!0,input:`p`},scopes:`*`},{commandId:`toggle-clipboard`,description:`打开/关闭剪贴板面板`,predicate:{ctrl:!0,input:`g`},scopes:`*`},{commandId:`toggle-draft-pane`,description:`打开/关闭草稿面板`,predicate:{ctrl:!0,input:`o`},scopes:`*`},{commandId:`toggle-queue-pane`,description:`打开/关闭队列面板`,predicate:{ctrl:!0,input:`q`},scopes:`*`},{commandId:`smart-close`,description:`智能关闭当前最上层面板`,predicate:{ctrl:!0,input:`k`},scopes:`*`},{commandId:`save-draft`,description:`保存当前输入为草稿`,predicate:{ctrl:!0,input:`s`},scopes:[`prompt`]},{commandId:`open-keybinding-panel`,description:`打开快捷键面板:浏览、搜索、重映射、重置快捷键`,predicate:{ctrl:!0,input:`/`},scopes:`*`}];function _n(e){return e.ctrl===void 0&&e.shift===void 0&&e.meta===void 0&&e.input===void 0&&e.key===void 0&&e.upArrow===void 0&&e.downArrow===void 0}function vn(e,t,n){let r=n?.[e];return r===void 0?t:r}function yn(e,t,n){if(e.ctrl!==void 0&&!!n.ctrl!==e.ctrl||e.shift!==void 0&&!!n.shift!==e.shift||e.meta!==void 0&&!!n.meta!==e.meta||e.input!==void 0&&t!==e.input)return!1;if(e.key!==void 0)switch(e.key){case`tab`:if(!n.tab)return!1;break;case`escape`:if(!n.escape)return!1;break;case`return`:if(!n.return)return!1;break}return!(e.upArrow!==void 0&&n.upArrow!==e.upArrow||e.downArrow!==void 0&&n.downArrow!==e.downArrow)}function bn(e,t){return e===`*`?!0:e.includes(t)}function xn(e,t,n,r,i){for(let a of e){if(!bn(a.scopes,t))continue;let e=vn(a.commandId,a.predicate,i);if(!_n(e)&&yn(e,n,r))return a.commandId}}const Sn=[{commandId:`list-nav-up`,description:`列表选中项上移`,predicate:{upArrow:!0},scopes:`*`},{commandId:`list-nav-up`,description:`列表选中项上移(vim k)`,predicate:{input:`k`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]},{commandId:`list-nav-down`,description:`列表选中项下移`,predicate:{downArrow:!0},scopes:`*`},{commandId:`list-nav-down`,description:`列表选中项下移(vim j)`,predicate:{input:`j`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]}];function Cn(e,t,n,r,i){for(let a of Sn){if(r!==void 0&&!wn(a.scopes,r))continue;let o=vn(a.commandId,a.predicate,i);if(!_n(o)&&yn(o,t,n))return a.commandId===e}return!1}function wn(e,t){return e===`*`?!0:e.includes(t)}function Tn(e,t,n,r){let i=[...gn,...Sn];for(let a of i){if(a.commandId===e)continue;let i=vn(a.commandId,a.predicate,r);if(!_n(i)&&bn(a.scopes,n)&&En(i,t))return{conflictsWith:a.commandId}}return null}function En(e,t){return e.ctrl===t.ctrl&&e.shift===t.shift&&e.meta===t.meta&&e.input===t.input&&e.key===t.key&&e.upArrow===t.upArrow&&e.downArrow===t.downArrow}function Dn(){let e=new Set(gn.map(e=>e.commandId)),t=new Set(Sn.map(e=>e.commandId));for(let n of e)if(t.has(n))throw Error(`[keybindings] duplicate commandId '${n}' found across KEY_BINDINGS and CONTROL_BINDINGS`)}Dn();function On(e,t,n){if(!t)return!1;let r=e.get(t);return r?n.tab?!!(r.onTab&&r.onTab(n.shift??!1)):n.escape?!!(r.onEscape&&r.onEscape()):n.return?!!(r.onAction&&r.onAction()):!1:!1}function kn(e,t,n,r,i){if(i.tab){let a=t;if(e.getTabable(n).length===0)return!1;if(a){let t=i.shift?e.prev(a,n):e.next(a,n);t&&r(t)}else if(!i.shift){let t=e.getInitialFocus(n);t&&r(t)}return!0}return!1}let An=null;function jn(e){An=e}function Mn(){return An}const Nn=`/overlay/toast`,Pn=`/overlay/pause`,Fn=`/overlay/retry`,In=`/overlay/error-retry`,Ln=`/overlay/pulse-survey`,Rn=`/overlay/forced-upgrade`,zn=`/overlay/paste-confirm`,Bn=`/overlay/services`,Vn=`/overlay/chip-viewer`,Hn=[Nn,Pn,Fn,In,Ln,Rn,zn,Bn,Vn];function Un(e){return e.startsWith(`/overlay/`)}function Wn(e){return e.startsWith(`/dialog/`)}function Gn(e,t,n){e&&(n?e.ensure(t):e.dismiss(t))}const Kn=a(null);function qn(){let e=c(Kn);if(!e)throw Error(`useRouter() must be used inside <Router>`);return e}function Jn(){return c(Kn)}function Yn(){let{stack:e}=qn(),t=e[e.length-1];return t?{path:t.path,params:t.params,state:t.state}:{path:`/`,params:{},state:void 0}}function Xn(e){let{stack:t}=qn();for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.path===e&&r.state!==void 0)return r.state}}function Zn(){let{stack:e}=qn(),t=c(Ke).routePath;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.path===t)return r.state}}function Qn(e,t){let n=e.split(`/`),r=t.split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;e<n.length;e++){let t=n[e],a=r[e];if(t.startsWith(`:`))i[t.slice(1)]=a;else if(t!==a)return null}return i}function $n({children:e,initialPath:t=`/`}){let n=u(()=>new Ge,[]),[r,i]=f(()=>({entries:[{path:t,params:{}}],index:0})),[a,o]=f(null),c=d(null);c.current=a;let p=r.entries[r.index]?.path??t,h=r.entries.slice(0,r.index+1),g=d(h);g.current=h;let _=s(e=>{o(e)},[]),v=s(e=>{setTimeout(()=>{e?.lastFocusId?o(e.lastFocusId):o(n.getInitialFocus(e?.path??`/`))},0)},[n]),y=s(e=>{setTimeout(()=>{o(n.getInitialFocus(e))},0)},[n]),b=s((e,t)=>{if(typeof e==`number`){i(t=>{if(e===0||t.entries.length===0)return t;let n=t.index+e;return n<0||n>=t.entries.length?t:(v(t.entries[n]),{...t,index:n})});return}let r={path:e,params:{},state:t?.state};i(i=>{if(t?.reset){if(Wn(e))return{entries:[r],index:0};let t=i.entries.slice(0,i.index+1).filter(e=>Wn(e.path));if(t.length===0)return{entries:[r],index:0};let n=[r,...t];return{entries:n,index:n.length-1}}let a=c.current,o=[...i.entries];if(o.length>0&&a){let e=o[i.index];e&&(n.rememberFocus(e.path,a),o[i.index]={...e,lastFocusId:a})}if(t?.replace&&o.length>0)return o[i.index]=r,{entries:o,index:i.index};let s=[...o.slice(0,i.index+1),r];return{entries:s,index:s.length-1}}),y(e)},[y,n,v]),x=s(()=>{b(-1)},[b]),S=s(e=>{i(t=>{if(t.entries.slice(0,t.index+1).some(t=>t.path===e))return t;let r=c.current,i=[...t.entries],a=i[t.index];a&&r&&(n.rememberFocus(a.path,r),i[t.index]={...a,lastFocusId:r});let o=[...i.slice(0,t.index+1),{path:e,params:{}}];return y(e),{entries:o,index:o.length-1}})},[y,n]),C=s(e=>{i(t=>{if(t.entries.length<=1)return t;let n=-1;for(let r=t.index;r>=0;r--)if(t.entries[r].path===e){n=r;break}if(n<=0)return t;let r=[...t.entries.slice(0,n),...t.entries.slice(n+1)],i=n<=t.index?Math.max(0,t.index-1):t.index;return n===t.index&&v(r[i]),{entries:r,index:Math.min(i,r.length-1)}})},[v]),w=s(e=>{o(e)},[]),T=s((e,t)=>On(n,c.current,t),[n]),E=s((e,t)=>kn(n,c.current,p,o,t)?!0:t.escape&&h.length>1?(x(),!0):!1,[n,p,h.length,x]),D=s((e,t)=>T(e,t)||E(e,t),[T,E]);l(()=>(jn({navigate:b,goBack:x,ensure:S,dismiss:C,get stack(){return g.current},get currentPath(){return g.current[g.current.length-1]?.path??`/`}}),()=>jn(null)),[b,x,S,C]);let O=rt(),k=d(T);k.current=T;let A=d(E);A.current=E,l(()=>{let e=O.register(`router-intercept`,(e,t)=>k.current(e,t),50),t=O.register(`router-default`,(e,t)=>A.current(e,t),5);return()=>{e(),t()}},[O]),l(()=>{let e=n.getInitialFocus(p);e&&!c.current&&o(e)},[p]);let j=u(()=>({routePath:p,currentPath:p,activeId:a,registry:n,onFocusFallback:_,hasRouter:!0}),[p,a,n,_]),M=u(()=>({stack:h,currentPath:p,activeId:a,navigate:b,goBack:x,ensure:S,dismiss:C,focus:w,handleKey:D}),[h,p,a,b,x,S,C,w,D]);return m(Kn.Provider,{value:M,children:m(Ke.Provider,{value:j,children:e})})}function er(e,t){return t===e||t.startsWith(e+`/`)}function tr(e){for(let t=e.length-1;t>=0;t--){let n=e[t].path;if(!n.startsWith(`/overlay/`))return n}}function nr({path:e,prefix:t,inStack:n,dismissibleByOverlay:r,element:i,children:a}){let{currentPath:o,stack:s,activeId:l}=qn(),u=c(Ke),d=e=>u?h(Ke.Provider,{value:{...u,routePath:e,activeId:l},children:[i,a]}):h(p,{children:[i,a]});if(e===`*`)return d(o);if(n)return s.some(t=>t.path===e)?d(e):null;if(r){let n=tr(s);return n===void 0||(t?!er(e,n):n!==e)?null:d(e)}return t?er(e,o)?d(e):null:Qn(e,o)?d(e):null}function rr({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▲ ${e.t(`common.more`)}`:e.t(`scroll.above`,{n})]}):null}function ir({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▼ ${e.t(`common.more`)}`:e.t(`scroll.below`,{n})]}):null}function ar(e,t){switch(e){case`primary`:return t.text;case`secondary`:return t.inactive;case`danger`:return t.error;case`success`:return t.success;case`warning`:return t.warning;case`accent`:return t.accent}}function $({children:e,type:t=`primary`,bold:n,italic:r,dim:i,wrap:a}){return m(_,{color:ar(t,K()),bold:n,italic:r,dimColor:i,wrap:a,children:e})}function or(e){return e.leftArrow?-1:e.rightArrow?1:e.tab?e.shift?-1:1:0}function sr(e,t,n){return n<=0?0:(e+t+n)%n}function cr({children:e,type:t=`secondary`,leadingSpace:n=!1}){let r=K();return h(_,{children:[n?` `:``,h(_,{color:ar(t,r),backgroundColor:r.tagBg,children:[` `,`[`,e,`]`,` `]})]})}function lr(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)*.6666666666666666))}function ur(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)*.3333333333333333))}function dr(e,t,n){let r=Number.isFinite(e)&&e>0?e:0,i=n??ur(t);return Math.min(i,Math.max(15,r))}function fr(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)/3))}function pr(e,t,n=0,r=5){let i=Math.min(Number.isFinite(e)&&e>0?Math.floor(e):0,r),a=Math.max(1,ur(t)-n);return Math.min(i,a)}function mr(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function hr(e){let t=Math.round(mr(e.percent)),n=Math.max(0,Math.floor(e.width));if(n===0)return{pct:t,filledCount:0,cells:[]};let r=e.segments?.filter(e=>e.width>0)??[],i=r.length>0,a,o;if(i){a=[];for(let e of r)for(let t=0;t<e.width;t++)a.push({filled:!0,segmentKey:e.key});for(o=a.length;a.length<n;)a.push({filled:!1})}else o=Math.max(0,Math.min(n,Math.round(t/100*n))),a=Array.from({length:n},(e,t)=>({filled:t<o}));if(e.markers)for(let[t,r]of Object.entries(e.markers)){if(!Number.isFinite(r))continue;let e=Math.max(0,Math.min(n-1,Math.round(r/100*n))),i=a[e];i&&(i.markerKey=t)}return{pct:t,filledCount:o,cells:a}}const gr={ascii:{filled:`=`,empty:`.`},block:{filled:`█`,empty:`░`},dot:{filled:`▰`,empty:`▱`}};function _r(e){return e?typeof e==`string`?gr[e]:e:gr.block}function vr({label:e,indent:t=` `}){let n=K(),r=typeof e==`string`?e:String(e??``);return h(_,{color:n.inactive,bold:!0,children:[t,r.toUpperCase()]})}function yr(e,t,n,r,i){let a=e.length;if(!Number.isFinite(n))return{rows:[...e],fillerCount:0,hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};if(n<=0||a===0)return{rows:[],fillerCount:Math.max(0,n),hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};let o=t>=0?t:0,s=r;o<s?s=i?Math.min(o,Math.max(0,i(o))):o:o>=s+n&&(s=o-n+1);let c=Math.max(0,a-n);s=Math.min(Math.max(0,s),c);let l=Math.min(a,s+n),u=e.slice(s,l);return{rows:u,fillerCount:Math.max(0,n-u.length),hasMoreAbove:s>0,hasMoreBelow:l<a,scrollTop:s}}function br(e,t=`below`){let n=[],r,i=0;return e.forEach((e,a)=>{e.group&&e.group!==r&&(i>0&&n.push({kind:`spacer`}),n.push({kind:`divider`,label:e.group}),i++),r=e.group,n.push({kind:`item`,option:e,optionIndex:a}),e.detail&&t===`below`&&n.push({kind:`detail`,option:e,optionIndex:a})}),n}function xr(e,t,n,r){return yr(e,e.findIndex(e=>e.kind===`item`&&e.optionIndex===t),n,r,t=>{let n=t;for(;n>0&&e[n-1]?.kind===`divider`;)n--;for(;n>0&&e[n-1]?.kind===`spacer`;)n--;return n})}function Sr(){let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}function Cr(e){return Math.max(1,Math.round(e/80))*80}const wr={now:()=>Date.now(),setTimer:(e,t)=>{let n=setTimeout(e,t);return n.unref?.(),n},clearTimer:e=>clearTimeout(e)};function Tr(e={}){let t=e.clock??wr,n=e.reducedMotion??(()=>{let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}),r=new Set,i=null,a=t.now(),o=e=>e.startedAtElapsed+(e.lastFrame+1)*e.periodMs,s=()=>{if(i!==null&&(t.clearTimer(i),i=null),r.size===0)return;let e=t.now()-a,n=1/0;for(let e of r){let t=o(e);t<n&&(n=t)}let s=Math.max(0,n-e);i=t.setTimer(c,s)},c=()=>{i=null;let e=t.now()-a;for(let t of r){let n=Math.floor((e-t.startedAtElapsed)/t.periodMs);if(n!==t.lastFrame){t.lastFrame=n;try{t.onFrame(n)}catch{}}}s()};return{subscribe(e,i){if(!Number.isFinite(e)||e<=0||n())return()=>{};let o=Cr(e),c=t.now()-a,l={periodMs:o,onFrame:i,lastFrame:0,startedAtElapsed:Math.floor(c/80)*80};return r.add(l),s(),()=>{r.delete(l),s()}},minPeriodMs(){let e;for(let t of r)e=e===void 0?t.periodMs:Math.min(e,t.periodMs);return e},size:()=>r.size,dispose(){r.clear(),i!==null&&(t.clearTimer(i),i=null)}}}const Er=Tr();function Dr(e,t){let n=d(t);n.current=t,l(()=>{if(e!=null)return Er.subscribe(e,e=>n.current(e))},[e])}function Or(e,t={}){let n=t.maxVisible??10,r=e.findIndex(e=>!e.disabled);r<0&&(r=0);let i=0;function a(){r<i?i=r:r>=i+n&&(i=r-n+1);let t=Math.max(0,e.length-n);i<0&&(i=0),i>t&&(i=t)}function o(n){if(n<0){t.onBoundary?.(`top`);return}if(n>=e.length){t.onBoundary?.(`bottom`);return}let i=n>r?1:-1,o=n;for(;o>=0&&o<e.length&&e[o]?.disabled;)o+=i;if(o<0){t.onBoundary?.(`top`);return}if(o>=e.length){t.onBoundary?.(`bottom`);return}r=o,a(),o===0&&t.onBoundary?.(`top`),o===e.length-1&&t.onBoundary?.(`bottom`)}return a(),{get selectedIndex(){return r},get scrollOffset(){return i},getVisibleOptions(){return e.slice(i,i+n)},getOptionAt(t){return e[t]},hasMoreAbove(){return i>0},hasMoreBelow(){return i+n<e.length},getSelected(){return e[r]??null},moveUp(){o(r-1)},moveDown(){o(r+1)},accept(){return e[r]??null},selectByHotkey(t){let n=e.findIndex(e=>e.hotkey===t);return n>=0&&!e[n]?.disabled?(r=n,a(),e[n]):null},selectByIndex(t){t>=0&&t<e.length&&!e[t]?.disabled&&(r=t,a())}}}function kr(e,t){return t.escape?{type:`cancel`}:t.return?{type:`accept`}:Cn(`list-nav-up`,e,t)?{type:`up`}:Cn(`list-nav-down`,e,t)?{type:`down`}:/^[1-9]$/.test(e)?{type:`index`,index:Number(e)-1}:null}const Ar={black:0,red:.3,green:.55,yellow:.93,blue:.2,magenta:.4,cyan:.7,white:1,gray:.5,grey:.5};function jr(e){if(e.startsWith(`#`)){let t=e.slice(1),[n,r,i]=(t.length===3?[t[0]+t[0],t[1]+t[1],t[2]+t[2]]:[t.slice(0,2),t.slice(2,4),t.slice(4,6)]).map(e=>parseInt(e,16)/255);return .299*n+.587*r+.114*i}return Ar[e.toLowerCase()]??.5}function Mr(e){return e&&jr(e)>.55?`black`:`white`}function Nr(e,t){switch(e){case`accent`:return t.selection;case`amber`:return t.warning;case`red`:return t.error;case`green`:return t.success;case`gray`:return t.panelBorder}}function Pr(e,t){return Nr(e,t)}function Fr(e,t=w){let{label:n,variant:r=`ghost`,color:i=`accent`,focused:a=!1,disabled:o=!1}=e,s=e.brackets??r===`outline`,c=`[ ${n} ]`;if(o)return{label:c,color:t.inactive,bold:!1,dim:!0};if(r===`ghost`){let e=` ${n} `;if(a){let n=Nr(i,t);return{label:s?c:e,color:Mr(n),backgroundColor:n,bold:!0,dim:!1}}return{label:s?c:e,color:t.inactive,bold:!1,dim:!1}}let l=Nr(i,t),u=Pr(i,t);if(r===`solid`){let e=` ${n} `;return a?{label:s?c:e,color:Mr(l),backgroundColor:l,bold:!0,dim:!1}:{label:s?c:e,color:s?t.inactive:u,bold:!1,dim:!1}}return a?{label:s?c:` ${n} `,color:u,bold:!0,dim:!1}:{label:s?c:` ${n} `,color:t.inactive,bold:!1,dim:!1}}function Ir({label:e,variant:t=`ghost`,color:n=`accent`,focused:r,disabled:i=!1,brackets:a,tabIndex:o=-1,onAction:s}){let c=K(),{focused:l}=Je({tabIndex:o,disabled:i||o<0,onAction:s}),u=Fr({label:e,variant:t,color:n,focused:r??l,disabled:i,brackets:a},c);return m(_,{color:u.color,backgroundColor:u.backgroundColor,bold:u.bold,dimColor:u.dim||void 0,children:u.label})}function Lr(e){return null}Lr.displayName=`Select.Item`;function Rr(e){return null}Rr.displayName=`Select.Label`;function zr(e){return null}zr.displayName=`Select.Group`;function Br(){return null}Br.displayName=`Select.Separator`;function Vr({children:e}){return m(p,{children:e})}Vr.displayName=`Select.Content`;function Hr(e){return null}Hr.displayName=`Select.Trigger`;function Ur(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(Array.isArray(e))return e.map(Ur).join(``);if(i.isValidElement(e)){let t=e.props;return Ur(t.children)}return``}function Wr(e){let t=[],n=0;function r(e,a){i.Children.forEach(e,e=>{if(!i.isValidElement(e))return;let o=e.type;if(o.displayName===`Select.Item`){let r=e.props;n+=1,t.push({value:r.value,label:Ur(r.children),disabled:r.disabled,detail:r.detail,indent:r.indent,marker:r.marker,ordinal:n,trailingLabel:r.trailingLabel,trailingColor:r.trailingColor,labelColor:r.labelColor,group:a});return}if(o.displayName===`Select.Group`){let t=e.props,n;i.Children.forEach(t.children,e=>{i.isValidElement(e)&&e.type.displayName===`Select.Label`&&(n=Ur(e.props.children))}),r(t.children,n);return}if(o.displayName===`Select.Label`||o.displayName===`Select.Separator`||o.displayName===`Select.Trigger`)return;let s=e.props;s.children!==void 0&&r(s.children,a)})}return r(e,void 0),t}function Gr({title:t,subtitle:n,headerAction:r,defaultValue:i,onValueChange:a,onCancel:o,maxVisible:s=10,footer:c,active:l=!0,onKey:v,frame:y=!0,highlightSelection:b=!0,rows:x=24,extensionHeightBudget:S=!1,detailPlacement:C=`below`,children:w}){let T=K(),E=u(()=>Wr(w),[w]),D=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.label))):0,[C,E]),O=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.trailingLabel??``))):0,[C,E]),k=d(null);if(!k.current){let e=i?E.findIndex(e=>e.value===i):-1;k.current=Or(E,{maxVisible:s}),e>=0&&k.current.selectByIndex(e)}let A=k.current,[j,M]=f(!1);Dr(2e3,e=>M(e%2==1));let[,ee]=f(0),te=()=>ee(e=>e+1),[N,P]=f(()=>!!r&&!E.some(e=>!e.disabled));J(`select-primitive`,(e,t)=>{if(v?.(e,t,A.getSelected())){te();return}if(r&&N){if(t.return){r.onPress();return}if(t.downArrow){P(!1),te();return}if(t.escape){o?.();return}return}let n=kr(e,t);if(n)switch(n.type){case`cancel`:o?.();return;case`up`:{let e=A.selectedIndex;A.moveUp(),r&&A.selectedIndex===e&&P(!0),te();return}case`down`:A.moveDown(),te();return;case`index`:{A.selectByIndex(n.index);let e=A.getSelected();e&&!e.disabled&&a?.(e.value);return}case`accept`:{let e=A.accept();e&&!e.disabled&&a?.(e.value);return}}},{isActive:l});let F=u(()=>br(E,C),[E,C]),ne=d(0),I=3+(t?2:0)+(n?1:0)+(r?1+(n?1:0):0)+2+2,R=fr(x),z=y?S?Math.max(1,Math.min(F.length,R-I)):dr(F.length+I,x)-I:1/0,B=xr(F,A.selectedIndex,z,ne.current);ne.current=B.scrollTop;let re=E[A.selectedIndex]??null,ie=h(p,{children:[t&&m(Re,{children:t}),t&&m(g,{marginTop:G.tight}),n&&m($,{type:`secondary`,children:n}),r&&h(g,{flexDirection:`row`,alignSelf:`flex-start`,marginTop:n?G.tight:G.none,children:[h(_,{color:T.accent,children:[r.hint,` `]}),m(Ir,{variant:`ghost`,brackets:!0,color:`accent`,label:r.label,focused:N,tabIndex:-1})]})]}),V=h(p,{children:[m(g,{height:1,children:m(rr,{hasMore:B.hasMoreAbove})}),B.rows.map((t,n)=>{if(t.kind===`spacer`)return m(_,{children:` `},`spacer-${n}`);if(t.kind===`divider`)return m(g,{flexDirection:`column`,children:m(vr,{label:t.label,indent:``})},`div-${n}`);let r=t.option;if(t.kind===`detail`){let e=r.indent??` `,n=r.detail??``,i=r.marker===`number`?` `.repeat(`${r.ordinal}. `.length):r.marker?` `.repeat(`${r.marker} `.length):``,a=/^● (.+?) · /u.exec(n),o=a?.[1],s=a?n.slice(a[0].length):n;return h(g,{flexDirection:`row`,children:[m(g,{flexShrink:0,children:h($,{type:`secondary`,dim:!0,children:[` `,e,i]})}),o?m(g,{flexShrink:0,children:h(_,{color:T.accent,children:[j?U.breatheBright:U.breatheDim,` `,o]})}):null,m(g,{flexGrow:1,flexShrink:1,minWidth:0,children:m($,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:o?` · ${s}`:s})})]},`detail-${t.optionIndex}`)}let i=r.indent??` `,a=r.marker===`number`?`${r.ordinal}. `:r.marker?`${r.marker} `:``,o=b&&r===re&&!N,s=C===`inline`&&r.detail;return h(g,{flexDirection:`row`,children:[m(g,{flexShrink:0,children:h(_,{color:r.disabled?T.inactive:o?T.selection:r.labelColor??T.inactive,dimColor:r.disabled,bold:o&&!r.disabled,wrap:`truncate-end`,children:[o&&!r.disabled?ce():le(),i,a,s?`${Gt(r.label,D)} ${Gt(r.trailingLabel??``,O)} `:r.label,r.disabled?` (${e.t(`common.disabled`)})`:``]})}),s&&m(g,{flexGrow:1,flexShrink:1,minWidth:0,children:m($,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:r.detail})}),r.trailingLabel&&!s&&h(p,{children:[m($,{type:`secondary`,children:` `}),m(_,{color:r.trailingColor??T.inactive,dimColor:!r.trailingColor,children:r.trailingLabel})]})]},`item-${t.optionIndex}`)}),Array.from({length:B.fillerCount},(e,t)=>m(_,{children:` `},`filler-${t}`)),m(g,{height:1,children:m(ir,{hasMore:B.hasMoreBelow})})]});return y?m(Le,{header:ie,footer:c??m(Be,{items:[[`${q.up}${q.down}`,e.t(`hint.select`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),maxHeight:S&&y?R:void 0,children:V}):h(g,{flexDirection:`column`,children:[ie,V]})}const Kr={Root:Gr,Trigger:Hr,Content:Vr,Group:zr,Label:Rr,Item:Lr,Separator:Br};function qr({title:t,message:n,confirmLabel:r,cancelLabel:i,confirmColor:a=`accent`,dangerous:o=!1,extraLabel:c,extraColor:l=`amber`,checkLabel:u,checked:d=!1,onConfirm:p,onCancel:v,onExtra:y,onCheckChange:b}){let x=!!c,S=x?2:1,[C,w]=f(o?S:0),[T,E]=f(d),D=Array.isArray(n)?n:[n],O=s(()=>{let e=!T;E(e),b?.(e)},[T,b]);Je({onEscape:()=>(v(),!0)}),J(`confirm-dialog-buttons`,(e,t)=>{if(t.escape)return v(),!0;let n=or(t);return n===0?t.return?(w(e=>(e===0?p():x&&e===1?y?.():v(),e)),!0):u&&e===` `&&!t.ctrl&&!t.meta?(O(),!0):!1:(w(e=>sr(e,n,S+1)),!0)});let k=r??e.t(`common.confirmButton`),A=i??e.t(`common.genericCancelButton`);return h(Le,{header:m(Re,{children:t}),footer:m(Be,{items:[[`${q.left}${q.right}`,e.t(`hint.switch`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:D.map((e,t)=>m(_,{wrap:`truncate-end`,children:e===``?` `:e},t))}),u&&h(g,{marginTop:G.tight,children:[h($,{type:`secondary`,children:[T?U.bullet:U.todoPending,` `]}),m($,{type:`secondary`,children:u})]}),h(g,{marginTop:G.tight,flexDirection:`row`,gap:G.section,children:[m(Ir,{variant:`solid`,brackets:!0,color:a,label:k,focused:C===0}),x&&m(Ir,{variant:`solid`,brackets:!0,color:l,label:c,focused:C===1}),m(Ir,{variant:`solid`,brackets:!0,color:`gray`,label:A,focused:C===S})]})]})}function Jr({tabIndex:e=0,autoFocus:t=!1,options:n,onSelect:r,initialIndex:i=0,maxVisible:a=8,id:o,compact:s=!1}){let c=K(),{focused:l}=Je({tabIndex:e,autoFocus:t,id:o}),[u,d]=f(Math.min(i,n.length-1));at(l,(e,t)=>{if(t.upArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e-r+n.length)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.downArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e+r)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.return){let e=n[u];return e&&!e.disabled&&r(e.value),!0}for(let t=0;t<Math.min(n.length,9);t++)if(e===String(t+1)&&n[t]&&!n[t].disabled)return r(n[t].value),!0;return!1});let p=n.length,v=p<=a?0:Math.min(Math.max(0,u-Math.floor(a/2)),p-a),y=n.slice(v,v+a);return h(g,{flexDirection:`column`,children:[v>0&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▲ `,v]})}),y.map((e,t)=>{let n=v+t===u,r=n&&l,i=e.disabled?c.inactive:r||n?c.selection:c.inactive,a=n&&!e.disabled;return h(g,{marginBottom:s?G.none:G.tight,flexDirection:`column`,children:[h(_,{color:i,bold:a,children:[r?ce():le(),e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m(_,{color:c.inactive,children:e.detail})})]},e.value)}),v+a<p&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▼ `,p-v-a]})})]})}function Yr({label:e,detail:t,disabled:n,children:r}){let i=K();return h(g,{flexDirection:`column`,children:[m(_,{color:n?i.inactive:void 0,children:e}),t&&m(_,{color:i.inactive,dimColor:!0,children:t}),r]})}function Xr(e,t){switch(e){case`success`:return t.success;case`warning`:return t.warning;case`error`:return t.error;case`muted`:return t.inactive;case`secondary`:return t.secondary}}function Zr(e){let t=[],n=[];for(let r of e)r.kind===`group`?(n.length>0&&t.push(n),n=[r]):n.push(r);return n.length>0&&t.push(n),t}function Qr({entries:e}){let t=K();return m(g,{flexDirection:`column`,children:Zr(e).map((e,n)=>{let r=e.filter(e=>e.kind===`row`),i=Math.max(0,...r.map(e=>L(e.label)));return m(g,{flexDirection:`column`,marginTop:n>0?G.tight:G.none,children:e.map((e,n)=>{if(e.kind===`group`)return m(vr,{label:e.title},n);if(e.kind===`blank`)return m(_,{children:` `},n);if(e.kind===`text`)return m(_,{color:e.tone?Xr(e.tone,t):void 0,dimColor:e.tone===`muted`,children:e.value},n);let r=` `.repeat(Math.max(0,i-L(e.label)));return h(_,{children:[` `,m(_,{color:t.inactive,children:e.label}),r,` `,m(_,{color:e.tone?Xr(e.tone,t):void 0,children:e.value})]},n)})},n)})})}function $r(t){switch(t){case`retry`:return e.t(`retry.nowButton`);case`login`:return e.t(`model.goToLoginButton`);case`extension`:return e.t(`model.goToExtensionButton`)}}function ei(e,t){switch(e){case`success`:return t.success;case`muted`:return t.inactive;case`warning`:return t.warning}}function ti({title:t,lines:n,lineTones:r,onDismiss:i,action:a,dataListEntries:o}){let s=K();J(`info-dialog`,(e,t)=>t.escape?(i(),!0):t.return&&a?(i(),queueMicrotask(()=>a.run()),!0):!1);let c=a?$r(a.kind):void 0;return h(Le,{header:m(Re,{children:t}),footer:m(Be,{items:a?[[q.enter,c],[q.esc,e.t(`hint.close`)]]:[[q.esc,e.t(`hint.close`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:o?m(Qr,{entries:o}):n.map((e,t)=>{let n=r?.[t];return m(_,{color:n?ei(n,s):void 0,dimColor:n===`muted`,wrap:`truncate-end`,children:e===``?` `:e},t)})}),a&&m(g,{marginTop:G.tight,children:m(Ir,{variant:`solid`,brackets:!0,color:`accent`,label:c,focused:!0})})]})}function ni({percent:e,width:t,chars:n,color:r,segments:i,markers:a,labelPosition:o=`suffix`,labelPrefix:s=``}){let c=K(),{filled:l,empty:u}=_r(n),d=hr({percent:e,width:t,segments:i?.map(e=>({key:e.key,width:e.width}))}),f=new Map((i??[]).map(e=>[e.key,e.color])),p=new Map((i??[]).map(e=>[e.key,e.dimColor??!1])),g=new Map(Object.entries(a??{}).map(([e,t])=>[t.pos,{name:e,color:t.color}])),v=(e=>typeof r==`function`?r(e):typeof r==`string`?r:c.inactive)(d.pct),y=`${s}${d.pct}%`;return h(_,{children:[o===`prefix`?h(_,{color:v,bold:!0,children:[y,` `]}):null,d.cells.map((e,t)=>{let n=g.get(t),r=c.inactive;e.filled&&(r=e.segmentKey?f.get(e.segmentKey)??v:v),n&&e.filled&&(r=n.color);let i=e.filled&&e.segmentKey?p.get(e.segmentKey)??!1:!1;return m(_,{color:r,dimColor:i,children:e.filled?l:u},t)}),o===`suffix`?h(_,{children:[` `,y]}):null]})}const ri={pending:U.todoPending,active:U.todoActive,done:U.check,error:U.cross};function ii(e,t){let n=[];return e.forEach((e,r)=>{let i=t[r]??`pending`;i!==`pending`&&n.push({label:e,status:i})}),n}function ai({title:t,phases:n,phaseStatuses:r,percent:a,detail:o,subProgress:s,status:c,errorMessage:u,nextStep:v,onDismiss:y}){let b=K(),x=c===`running`,S=d(null);l(()=>{if(c===`success`)return S.current=setTimeout(y,2e3),()=>{S.current&&clearTimeout(S.current)}},[c,y]);let[C,w]=f(0);return Dr(c===`running`?160:null,e=>{w(e%ue.length)}),J(`progress-dialog`,(e,t)=>(t.return||t.escape)&&c!==`running`?(y(),!0):!1),m(Le,{header:m(Re,{children:t}),footer:c===`partial`||c===`error`?m(Be,{items:[[`${q.enter}/${q.esc}`,e.t(`hint.close`)]]}):void 0,children:h(g,{flexDirection:`column`,paddingX:G.tight,children:[m(g,{height:1}),x?n.map((e,t)=>{let n=r[t]??`pending`,i=n===`active`,a=n===`error`,s=n===`done`,c=b.inactive;return i?c=b.accent:a?c=b.error:s&&(c=b.success),h(g,{children:[h(_,{color:c,children:[ri[n]??` `,` `]}),m(_,{color:i?b.accent:a?b.error:s?b.success:b.inactive,children:e}),i?h(p,{children:[h(_,{color:b.accent,children:[` `,ue[C],` `]}),m($,{type:`secondary`,children:o})]}):null]},t)}):null,!x&&c!==`success`?m(g,{children:ii(n,r).map((e,t)=>h(i.Fragment,{children:[t>0?m($,{type:`secondary`,children:` · `}):null,h(_,{color:e.status===`error`?b.error:e.status===`done`?b.success:b.accent,children:[ri[e.status],` `]}),m($,{type:`secondary`,children:e.label})]},t))}):null,s&&c===`running`?m(g,{marginTop:G.tight,children:h(cr,{children:[s.current,`/`,s.total]})}):null,x?m(g,{marginTop:G.tight,marginBottom:G.tight,children:m(ni,{percent:a,width:40,chars:`ascii`,color:b.accent})}):null,x?null:h(g,{marginTop:c===`success`?G.none:G.tight,flexDirection:`column`,children:[m(g,{children:h(_,{bold:!0,color:c===`success`?b.success:c===`partial`?b.warning:b.error,children:[c===`success`?U.check:c===`partial`?U.warn:U.cross,` `,c===`success`?e.t(`install.done`):c===`partial`?e.t(`install.summaryPartial`):e.t(`install.summaryFailed`)]})}),c!==`success`&&u?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,wrap:`wrap`,children:u})}):null,v?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,children:v.label})}):null]})]})})}function oi(e){return e.some(e=>e.freeformInput===!0)}function si(e){return{tab:0,cursor:0,selected:e.map(()=>[]),freeformText:``,freeformOffset:0}}function ci(e,t,n=!1){return t.escape?{type:`cancel`}:t.tab?{type:t.shift?`tabPrev`:`tabNext`}:Cn(`list-nav-up`,e,t)?{type:`cursorPrev`}:Cn(`list-nav-down`,e,t)?{type:`cursorNext`}:!n&&(e===` `||t.return)?{type:`choose`}:null}function li(e,t,n){let r=oi(n),i=n.length+(r?1:0),a=r?n.length:-1;switch(t?.type){case`cancel`:return{state:e,done:`cancel`};case`tabPrev`:return{state:{...e,tab:(e.tab-1+i+1)%(i+1),cursor:0}};case`tabNext`:return{state:{...e,tab:(e.tab+1)%(i+1),cursor:0}};case`cursorPrev`:return e.tab===i||e.tab===a?{state:e}:{state:{...e,cursor:Math.max(0,e.cursor-1)}};case`cursorNext`:{if(e.tab===i||e.tab===a)return{state:e};let t=n[e.tab].options.length;return{state:{...e,cursor:Math.min(t-1,e.cursor+1)}}}case`choose`:{if(e.tab===i)return{state:e,done:`submit`};if(e.tab===a)return{state:{...e,tab:i}};let t=n[e.tab],r=e.selected[e.tab]??[],o=t.multiSelect?r.includes(e.cursor)?r.filter(t=>t!==e.cursor):[...r,e.cursor]:[e.cursor],s=e.selected.map((t,n)=>n===e.tab?o:t),c=t.multiSelect?e.tab:Math.min(i,e.tab+1);return{state:{...e,selected:s,tab:c,cursor:0}}}default:return{state:e}}}function ui(e,t){let n={};return t.forEach((t,r)=>{n[t.header]=(e.selected[r]??[]).map(e=>t.options[e]?.label).filter(e=>typeof e==`string`)}),n}function di(e,t){return t.every((t,n)=>(e.selected[n]?.length??0)>0)}function fi(e){return Ut(e,23)}function pi({title:t,questions:n,onSubmit:r,onCancel:a,columns:o=60}){let s=K(),c=oi(n),l=d(null);l.current??=si(n);let[,u]=f(0),v=c?n.length:-1,y=n.length+(c?1:0),b=e=>{let t=l.current,i=ci(``,{tab:!0,shift:e},t.tab===v);if(!i)return!1;let{state:o,done:s}=li(t,i,n);return l.current=o,s===`cancel`?(a?.(),!0):s===`submit`?(r(ui(o,n),o.freeformText||void 0),!0):(u(e=>e+1),!0)};Je({onEscape:()=>(a?.(),!0),onTab:e=>b(e)}),J(`questions-dialog`,(e,t)=>{let i=l.current;if(i.tab===v){if(t.escape&&i.freeformText.length===0){a?.();return}if(t.tab){b(t.shift??!1);return}if((t.ctrl||t.meta)&&(t.leftArrow||t.rightArrow||t.home||t.end)){let e={name:t.home?`home`:t.end?`end`:t.leftArrow?`left`:`right`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},n=Lt(At.fromText(i.freeformText,o,i.freeformOffset),e);n&&(l.current={...i,freeformText:n.cursor.text,freeformOffset:n.cursor.offset},u(e=>e+1));return}if(t.home||t.end){let e={name:t.home?`home`:`end`,ctrl:!1,shift:!1,alt:!1,meta:!1},n=Lt(At.fromText(i.freeformText,o,i.freeformOffset),e);n&&(l.current={...i,freeformText:n.cursor.text,freeformOffset:n.cursor.offset},u(e=>e+1));return}if(t.leftArrow){let e=At.fromText(i.freeformText,o,i.freeformOffset).left();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(t.rightArrow){let e=At.fromText(i.freeformText,o,i.freeformOffset).right();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(e.length>1&&!t.ctrl&&!t.meta&&!t.return&&!t.escape&&!t.backspace&&!t.delete&&!t.leftArrow&&!t.rightArrow){let t=Rt(e);if(t){let e=i.freeformText,n=i.freeformOffset;l.current={...i,freeformText:e.slice(0,n)+t+e.slice(n),freeformOffset:n+t.length},u(e=>e+1)}return}if(t.return){let{state:e,done:t}=li(i,ci(``,{tab:!0},!0),n);if(l.current=e,t===`submit`){r(ui(e,n),e.freeformText||void 0);return}u(e=>e+1);return}let s={name:t.escape?`escape`:t.backspace?`backspace`:t.delete?`delete`:e||`unknown`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},c=Lt(At.fromText(i.freeformText,o,i.freeformOffset),s);if(!c)return;l.current={...i,freeformText:c.cursor.text,freeformOffset:c.cursor.offset},u(e=>e+1);return}let s=ci(e,t);if(!s)return;let{state:c,done:d}=li(i,s,n);if(l.current=c,d===`cancel`){a?.();return}if(d===`submit`){r(ui(c,n),c.freeformText||void 0);return}u(e=>e+1)});let x=l.current,S=x.tab===y,C=x.tab===v?m(Be,{items:[[q.enter,e.t(`freeform.advance`)],[q.esc,e.t(`hint.cancel`)]]}):m(Be,{items:[[`${q.up}${q.down}`,e.t(`hint.option`)],[q.tab,e.t(`hint.question`)],S?[q.enter,e.t(`hint.submit`)]:[`space/${q.enter}`,e.t(`hint.choose`)],[q.esc,e.t(`hint.cancel`)]]});return h(Le,{header:t?m(Re,{children:t}):void 0,footer:C,children:[h(g,{flexDirection:`row`,marginTop:G.tight,children:[n.map((e,t)=>{let n=(x.selected[t]?.length??0)>0,r=x.tab===t,a=r?s.selection:n?s.success:s.inactive;return h(i.Fragment,{children:[t>0&&m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:a,bold:r,children:fi(e.header)})]},t)}),c&&h(p,{children:[m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:x.tab===v?s.selection:x.freeformText?s.success:s.inactive,bold:x.tab===v,children:e.t(`freeform.tab`)})]}),m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:S?s.selection:s.inactive,bold:S,children:e.t(`prompt.submit`)})]}),S?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:di(x,n)?s.success:s.warning,children:di(x,n)?e.t(`questions.readyToSubmit`):e.t(`questions.someUnanswered`)}),m(g,{marginTop:G.tight,children:m(Ir,{variant:`solid`,brackets:!0,color:`accent`,label:e.t(`prompt.submit`),focused:!0})})]}):x.tab===v?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:s.secondary,children:e.t(`freeform.label`)}),m(g,{marginTop:G.tight,children:m(hn,{value:x.freeformText,offset:x.freeformOffset,columns:o,mode:`dialog`,placeholder:e.t(`freeform.placeholder`),focused:!0,physicalCursor:!0})})]}):h(g,{flexDirection:`column`,marginTop:G.tight,children:[n[x.tab].question!==t&&m(_,{color:s.text,children:n[x.tab].question}),m(g,{flexDirection:`column`,marginTop:G.tight,children:n[x.tab].options.map((e,t)=>{let n=t===x.cursor,r=(x.selected[x.tab]??[]).includes(t),i=r?U.bullet:U.todoPending;return h(g,{flexDirection:`column`,children:[h(g,{flexDirection:`row`,children:[m(_,{color:n?s.selection:s.inactive,bold:n,children:n?ce():le()}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:i}),m(_,{children:` `}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:e.label})]}),e.description&&m(g,{marginLeft:G.loose,children:m($,{type:`secondary`,dim:!0,children:e.description})})]},t)})})]})]})}function mi(e,t,n,r){return h(g,{flexDirection:`row`,marginBottom:G.tight,children:[n.map((n,a)=>{let o=t.has(a),s=a===e,c=o?U.check:s?U.todoDone:U.todoPending,l=o?r.inactive:s?r.text:r.inactive;return h(i.Fragment,{children:[a>0&&m($,{type:`secondary`,children:` · `}),h(_,{color:l,bold:s,children:[c,` `,n]})]},a)}),h(g,{marginLeft:G.section,children:[m($,{type:`secondary`,children:`Step `}),m(_,{color:r.text,bold:!0,children:e+1}),h($,{type:`secondary`,children:[`/`,4]})]})]})}function hi(){return m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,dim:!0,children:Wt(U.hr,60)})})}function gi({request:t}){let n=K(),[r,i]=f(!1),[a,o]=f(!1),[c,u]=f(()=>Math.min(t.initialCurrent,3)),[p,v]=f(()=>new Set(t.initialCompleted)),[y,b]=f(null),[x,S]=f(null),[C,w]=f(null),[T,E]=f(null),[D,O]=f(null),[k,A]=f([]),[j,M]=f(!1),[ee,te]=f(null),N=d(null),[P,F]=f(`select`),[ne,I]=f(null),[L,R]=f(null),[z,B]=f(null),[re,ie]=f(``),V=d(``),[ae,oe]=f(t.authProviderName??``),se=s(e=>{V.current=e,ie(e)},[]),H=d(null),ce=d(!1),le=s(()=>{ce.current=!0,H.current?.cancel(),N.current&&=(clearTimeout(N.current),null),t.onDismiss()},[t]),ue=s(()=>{if(P!==`select`&&c===1){H.current?.cancel(),F(`select`),I(null),R(null),B(null),se(``),V.current=``,b(null);return}if(T){E(null),b(null);return}c===0?le():(v(e=>{let t=new Set(e);return t.delete(c-1),t}),u(e=>e-1),b(null),F(`select`),I(null),R(null),B(null),se(``),w(null),A([]),M(!1),E(null),N.current&&=(clearTimeout(N.current),null))},[c,le,P,T]);l(()=>()=>{H.current?.cancel(),N.current&&clearTimeout(N.current)},[]);let W=s(()=>{v(e=>new Set([...e,c])),b(null),S(null),w(null),A([]),M(!1),E(null),F(`select`),O(null),I(null),R(null),B(null),se(``),V.current=``,H.current=null,c>=3?(le(),t.onComplete()):u(e=>e+1)},[c,le,t]),de=d(null),fe=s(async e=>{S(e),b(null);let n=await t.onInstallProvider(e,()=>{});ce.current||(S(null),n.ok?(oe(n.providerId??e),A(n.capabilities??[]),M(n.pendingCapabilities===!0),w(e),N.current=setTimeout(()=>{N.current=null,W()},900)):(E(e),b(n.error)))},[t,W]);de.current=fe;let pe=s(()=>{let e=T;e&&(E(null),b(null),de.current?.(e))},[T]),me=s(()=>{E(null),b(null)},[]),he=d(null),ge=s(async()=>{if(t.onRefreshModelOptions)try{te(await t.onRefreshModelOptions())}catch{}},[t]),_e=s(async()=>{if(!t.onProviderOAuthStart)return;b(null),F(`oauth-wait`);let e=await t.onProviderOAuthStart(ae);if(!e){F(`select`),b(`OAuth flow not available for this provider.`);return}H.current=e,I(e.authorizationUrl),R(e.code??null),B(e.instructions??null);let n=async()=>{if(ce.current)return;let t=await e.poll();if(ce.current)return;let r=typeof t==`string`?t:t.status,i=typeof t==`string`?void 0:t.reason;r===`pending`?setTimeout(()=>{n().catch(()=>{})},1500):r===`done`?(await ge(),W()):i===`cancelled`?F(`select`):O(i===`network`?`network`:`rejected`)};n().catch(()=>{})},[t,W,ae,ge]),ve=s(()=>{O(null),b(null),he.current?.()},[]),ye=s(()=>{O(null),t.onOpenProxySettings?.()},[t]);he.current=_e;let be=s(()=>{H.current?.openAgain?.()},[]),xe=s(()=>{H.current?.cancel(),H.current=null,I(null),R(null),B(null),b(null),se(``),F(`key-input`)},[se]),Se=s(async()=>{if(!t.onSubmitProviderApiKey||!V.current.trim())return;b(null),F(`logging-in`);let e=await t.onSubmitProviderApiKey(ae,V.current.trim());e.ok?(await ge(),W()):(F(`key-input`),b(e.error))},[t,W,re,ae,ge]),Ce=s(async e=>{b(null);try{await t.onSelectModel(e),W()}catch(e){b(e instanceof Error?e.message:String(e))}},[t,W]),we=s(()=>W(),[W]);J(`wizard-dialog`,(e,n)=>r?n.escape?(ue(),!0):!1:n.return?(t.onDontShowAgain(a),i(!0),!0):n.escape?(le(),!0):e===` `?(o(e=>!e),!0):!1);let Te=(()=>{if(!r)return[[q.enter,t.welcomeStartLabel],[q.esc,t.welcomeCancelLabel],[`Space`,t.welcomeDontShowAgainLabel]];let n=c===0&&!T?`exit`:`back`;switch(c){case 0:{let r=Math.min(t.providerOptions.length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionInstall`)],[q.esc,n]]}case 1:return P===`key-input`?[[q.enter,`submit`],[q.esc,n]]:P===`oauth-wait`?[[q.esc,`cancel`]]:[[`1-${Math.min(t.providerAuthOptions(ae).length,9)}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionLogin`)],[q.esc,n]];case 2:{let r=Math.min((ee??t.modelOptions).length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`hint.confirm`)],[q.esc,n]]}case 3:return[[q.enter,e.t(`hint.confirm`)]];default:return[[q.esc,n]]}})();return m(Le,{header:m(Re,{children:t.title}),footer:m(Be,{items:Te}),children:r?h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[mi(c,p,t.stepNames,n),m(g,{marginBottom:G.tight,flexDirection:`column`,children:m(_,{bold:!0,children:t.stepSubtitles[c]})}),m(hi,{}),y&&h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:n.error,children:[e.t(`setup.errorTitle`),`:`]}),m(_,{color:n.error,children:y})]}),m(_i,{step:c,request:t,installing:x,installSucceeded:C,installedCapabilities:k,installPendingCaps:j,installFailed:T,onRetryInstall:pe,onChooseAnother:me,authMode:P,setAuthMode:F,oauthUrl:ne,oauthCode:L,oauthInstructions:z,apiKey:re,apiKeyRef:V,setApiKey:se,onInstall:fe,onOAuthStart:_e,onApiKeySubmit:Se,onOpenAgain:be,onSwitchToApiKey:xe,onRetryAuth:ve,onOpenProxySettings:ye,authFailure:D,onModel:Ce,onComplete:we,selectedProvider:ae,modelOptionsOverride:ee})]}):h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[m(g,{marginBottom:G.tight,children:m(_,{bold:!0,children:t.welcomeTitle})}),t.welcomeGreeting&&m(g,{marginBottom:G.tight,children:m(_,{children:t.welcomeGreeting})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:t.welcomeDescription})}),m(hi,{}),m(g,{marginBottom:G.tight,children:h(_,{color:a?n.text:n.inactive,children:[a?U.bullet:U.todoPending,` `,t.welcomeDontShowAgainLabel]})})]})})}function _i(e){switch(e.step){case 0:return m(yi,{request:e.request,installing:e.installing,installSucceeded:e.installSucceeded,installedCapabilities:e.installedCapabilities,installPendingCaps:e.installPendingCaps,installFailed:e.installFailed,onRetryInstall:e.onRetryInstall,onChooseAnother:e.onChooseAnother,onInstall:e.onInstall});case 1:return m(bi,{request:e.request,authMode:e.authMode,setAuthMode:e.setAuthMode,oauthUrl:e.oauthUrl,oauthCode:e.oauthCode,oauthInstructions:e.oauthInstructions,apiKey:e.apiKey,apiKeyRef:e.apiKeyRef,setApiKey:e.setApiKey,onOAuthStart:e.onOAuthStart,onApiKeySubmit:e.onApiKeySubmit,onOpenAgain:e.onOpenAgain,onSwitchToApiKey:e.onSwitchToApiKey,onRetryAuth:e.onRetryAuth,onOpenProxySettings:e.onOpenProxySettings,authFailure:e.authFailure,selectedProvider:e.selectedProvider});case 2:return m(xi,{request:e.request,onModel:e.onModel,modelOptionsOverride:e.modelOptionsOverride});case 3:return m(Si,{request:e.request,onComplete:e.onComplete});default:return m(_,{children:`Unknown step`})}}function vi(){let e=K(),t=Sr(),[n,r]=f(0);return Dr(160,e=>r(e%ue.length)),t?null:h(_,{color:e.accent,children:[` `,ue[n]]})}function yi({request:t,installing:n,installSucceeded:r,installedCapabilities:i,installPendingCaps:a,installFailed:o,onRetryInstall:s,onChooseAnother:c,onInstall:l}){let u=K(),[d,p]=f(0),v=t.providerOptions,y=n!==null;if(r){let t=v.find(e=>e.value===r)?.label??r;return h(g,{flexDirection:`column`,children:[m(g,{children:h(_,{color:u.success,bold:!0,children:[U.check,` `,e.t(`setup.installedProvider`,{provider:t})]})}),a&&m(g,{marginTop:G.tight,children:m(_,{color:u.warning,children:e.t(`setup.installPendingCapabilities`)})}),i.length>0&&h(g,{marginTop:G.tight,flexDirection:`column`,children:[m($,{type:`secondary`,children:e.t(`setup.capabilityGranted`,{caps:i.join(`, `)})}),m($,{type:`secondary`,children:e.t(`setup.capabilityRevokeHint`)})]})]})}if(o)return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.installFailedRecovery`,{provider:o})})}),h(Y.Root,{id:`wizard-install-failed`,onPick:e=>{e===0?s():c()},children:[m(Y.Item,{label:e.t(`setup.actionRetryInstall`)}),m(Y.Item,{label:e.t(`setup.actionChooseAnotherProvider`)})]})]});if(y){let t=v.find(e=>e.value===n)?.label??n;return h(g,{children:[m(_,{color:u.text,children:e.t(`setup.installingProvider`,{provider:t})}),m(vi,{})]})}return m(Y.Root,{id:`wizard-dialog-2`,onPick:e=>{!y&&v[e]&&l(v[e].value)},activeIndex:d,onActiveChange:p,children:v.map(e=>m(Y.Item,{label:e.label,detail:e.detail,color:u.selection},e.value))})}function bi({request:t,authMode:n,setAuthMode:r,oauthUrl:i,oauthCode:a,oauthInstructions:o,apiKey:s,apiKeyRef:c,setApiKey:l,onOAuthStart:u,onApiKeySubmit:d,onOpenAgain:v,onSwitchToApiKey:y,onRetryAuth:b,onOpenProxySettings:x,authFailure:S,selectedProvider:C}){let w=K(),[T,E]=f(0),D=n,O=t.providerAuthOptions(C);if(J(`wizard-dialog-3`,(e,n)=>{if(D===`key-input`)return n.return&&c.current.trim()?(d(),!0):n.escape?(r(`select`),!0):e&&e.length>0?(l(c.current+e),!0):((n.backspace||n.delete)&&l(c.current.slice(0,-1)),!0);if(D!==`select`)return!1;if(n.upArrow||n.downArrow)return E(e=>(e+1)%Math.max(O.length,1)),!0;if(n.return&&O[T]){let e=O[T];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}let i=e?Number(e):NaN;if(Number.isInteger(i)&&i>=1&&i<=O.length){let e=O[i-1];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}return!1}),S){let t=S===`network`;return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{color:w.error,children:e.t(t?`setup.authFailedNetwork`:`setup.authFailedRejected`)})}),h(Y.Root,{id:`wizard-auth-failed`,onPick:e=>{if(t&&e===0){x();return}(t?e-1:e)===0?b():y()},children:[t?m(Y.Item,{label:e.t(`setup.actionOpenProxySettings`)}):null,m(Y.Item,{label:e.t(`setup.actionRetryAuth`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]})}return t.onProviderOAuthStart&&n===`oauth-wait`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:a?`Complete device authorization`:`Sign in via OAuth`})}),a?h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`1. Open this page:`})}),i&&m(g,{marginBottom:G.tight,children:h($,{type:`secondary`,children:[` `,i]})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`2. Enter this code:`})}),m(g,{marginBottom:G.tight,children:h(_,{bold:!0,color:w.text,children:[` `,a]})}),o&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:o})})]}):h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Open this URL in your browser to authorize:`})}),i&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:i})})]}),m(g,{marginBottom:G.tight,children:m(_,{color:w.text,children:e.t(`setup.oauthWaiting`)})}),h(Y.Root,{id:`wizard-oauth-wait`,onPick:e=>{e===0?v():y()},children:[m(Y.Item,{label:e.t(`setup.actionOpenAgain`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]}):n===`key-input`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:`Paste your API key`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Generate a key on your provider dashboard and paste it below.`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.apiKeyStorageNote`)})}),m(g,{marginBottom:G.tight,children:m(hn,{value:s,offset:0,columns:60,mode:`dialog`,mask:!0,placeholder:e.t(`setup.wizardApiKeyPlaceholder`),focused:!0})})]}):n===`logging-in`?m(g,{flexDirection:`column`,children:m(_,{color:w.text,children:e.t(`setup.loggingIn`)})}):h(g,{flexDirection:`column`,children:[C&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:C})}),m(g,{flexDirection:`column`,children:O.map((e,t)=>h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:t===T?w.selection:w.inactive,bold:t===T,children:[t===T?U.pointer:` `,` `,e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m($,{type:`secondary`,children:e.detail})})]},e.value))})]})}function xi({request:t,onModel:n,modelOptionsOverride:r}){let i=r??t.modelOptions,a=t=>t===`unauthenticated`?e.t(`setup.modelUnusableUnauthenticated`):t===`oauth-429-risk`?e.t(`setup.modelUnusableOauthRisk`):t===`intranet-unreachable`?e.t(`setup.modelUnusableIntranet`):``;return h(g,{flexDirection:`column`,children:[i.some(e=>e.recommended)&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.modelRecommendedHint`)})}),m(Kr.Root,{maxVisible:8,frame:!1,onValueChange:e=>{n(e)},children:i.map(t=>{let n=a(t.unusableReason),r=[t.recommended?e.t(`setup.modelRecommendedTag`):``,n,t.detail??``].filter(Boolean).join(` · `);return m(Kr.Item,{value:t.value,detail:r||void 0,children:t.label},t.value)})})]})}function Si({request:t,onComplete:n}){let r=K();return J(`wizard-dialog-4`,(e,t)=>t.return?(n(),!0):!1),h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.tryAsking`)})}),m(g,{flexDirection:`column`,marginBottom:G.tight,children:t.examplePrompts.map((e,t)=>h($,{type:`secondary`,children:[` "`,e,`"`]},t))}),m(_,{color:r.text,children:e.t(`setup.pressEnterToStart`)})]})}export{Gn as $,q as $t,or as A,C as An,bt as At,Zn as B,ot as Bt,lr as C,se as Cn,X as Ct,pr as D,re as Dn,Ct as Dt,dr as E,z as En,Dt as Et,$n as F,Qe as Ft,zn as G,Ye as Gt,Vn as H,lt as Ht,Qn as I,$e as It,Ln as J,He as Jt,Hn as K,Ge as Kt,Jn as L,dt as Lt,rr as M,T as Mn,Ze as Mt,ir as N,x as Nn,nt as Nt,cr as O,ie as On,wt as Ot,nr as P,et as Pt,Un as Q,Le as Qt,Xn as R,J as Rt,hr as S,L as Sn,zt as St,ur as T,H as Tn,Z as Tt,In as U,at as Ut,qn as V,ut as Vt,Rn as W,Ke as Wt,Bn as X,ze as Xt,Fn as Y,Be as Yt,Nn as Z,Re as Zt,br as _,fe as _n,Nt as _t,ti as a,ke as an,Cn as at,vr as b,le as bn,Pt as bt,Yr as c,K as cn,vn as ct,Ir as d,be as dn,en as dt,Ne as en,Mn as et,kr as f,xe as fn,Gt as ft,Sr as g,de as gn,Bt as gt,Dr as h,pe as hn,Ht as ht,ni as i,je as in,Sn as it,$ as j,w as jn,Y as jt,sr as k,S as kn,yt as kt,qr as l,De as ln,gn as lt,Er as m,G as mn,Ut as mt,pi as n,Fe as nn,kn as nt,Qr as o,Oe as on,xn as ot,Or as p,me as pn,Wt as pt,Pn as q,Je as qt,ai as r,Pe as rn,Tn as rt,Jr as s,Ee as sn,_n as st,gi as t,Ie as tn,On as tt,Kr as u,we as un,hn as ut,yr as v,U as vn,Mt as vt,fr as w,oe as wn,At as wt,_r as x,ce as xn,Rt as xt,xr as y,ue as yn,Lt as yt,Yn as z,rt as zt};
|
package/dist/compat.d.ts
CHANGED
|
@@ -124,5 +124,4 @@ interface PaletteResult {
|
|
|
124
124
|
*/
|
|
125
125
|
declare function showCommandPalette(_commands: Command[], _stdin?: NodeJS.ReadStream, _stdout?: NodeJS.WriteStream): Promise<PaletteResult>;
|
|
126
126
|
//#endregion
|
|
127
|
-
export { Command, CommandAction, CommandContext, CommandRegistry, CommandResult, CommandType, PaletteResult, RenderOptions, createBuiltinCommands, showCommandPalette };
|
|
128
|
-
//# sourceMappingURL=compat.d.ts.map
|
|
127
|
+
export { Command, CommandAction, CommandContext, CommandRegistry, CommandResult, CommandType, PaletteResult, RenderOptions, createBuiltinCommands, showCommandPalette };
|
package/dist/compat.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import{n as e}from"./i18n-sGAClHYZ.js";var t=class{commands=new Map;register(e){if(this.commands.has(e.name))throw Error(`Command "/${e.name}" is already registered`);this.commands.set(e.name,e)}get(e){return this.commands.get(e)}find(e){let t=this.commands.get(e);if(t)return t;for(let t of this.commands.values())if(t.aliases?.includes(e))return t}list(){return[...this.commands.values()]}names(){return[...this.commands.keys()]}has(e){return this.commands.has(e)}unregister(e){return this.commands.delete(e)}};function n(){let n=new t;return n.register({name:`help`,description:e.t(`cmdDesc.help`),aliases:[`h`,`?`],type:`action`,source:`builtin`,execute:()=>({kind:`help`})}),n.register({name:`exit`,description:e.t(`cmdDesc.exit`),aliases:[`quit`,`q`],type:`action`,source:`builtin`,execute:e=>{let t=e?.trim()??``;return t===`--restart`||t===`-r`?{kind:`exit`,restart:!0}:{kind:`exit`}}}),n.register({name:`clear`,description:e.t(`cmdDesc.clear`),type:`action`,source:`builtin`,execute:()=>({kind:`clear`})}),n.register({name:`abort`,description:e.t(`cmdDesc.abort`),type:`action`,source:`builtin`,execute:()=>({kind:`abort`})}),n.register({name:`copy`,description:e.t(`cmdDesc.copy`),type:`action`,source:`builtin`,execute:()=>({kind:`copy`})}),n.register({name:`model`,description:e.t(`cmdDesc.model`),aliases:[`m`],type:`action`,source:`builtin`,execute:(t,n)=>{if(!n.models||n.models.length===0)return e.t(`model.noRegistry`);if(t&&n.onModelChange){let r=n.models.find(e=>e.id===t||e.name===t);return r?{kind:`model`,modelId:r.id}:e.t(`model.notFound`,{name:t})}let r=new Map;for(let e of n.models){let t=r.get(e.provider)??[];t.push(e),r.set(e.provider,t)}let i=[``];for(let[e,t]of r){i.push(` ${e}:`);for(let e of t){let t=e.id===n.currentModel?` *`:` `;i.push(` ${t} ${e.id} — ${e.name}`)}}return i.push(``,e.t(`model.listFooter`)),i.join(`
|
|
2
|
-
`)}}),n.register({name:`status`,description:e.t(`cmdDesc.status`),type:`action`,source:`builtin`,execute:()=>({kind:`status`})}),n}function r(e,t,n){return Promise.resolve({command:`help`,args:``})}export{t as CommandRegistry,n as createBuiltinCommands,r as showCommandPalette};
|
|
3
|
-
//# sourceMappingURL=compat.js.map
|
|
2
|
+
`)}}),n.register({name:`status`,description:e.t(`cmdDesc.status`),type:`action`,source:`builtin`,execute:()=>({kind:`status`})}),n}function r(e,t,n){return Promise.resolve({command:`help`,args:``})}export{t as CommandRegistry,n as createBuiltinCommands,r as showCommandPalette};
|
package/dist/i18n-sGAClHYZ.js
CHANGED
|
@@ -72,5 +72,4 @@ A crash report has been recorded.`,stepNameProvider:`Provider`,stepNameLogin:`Lo
|
|
|
72
72
|
这是你创建或信任的项目吗(你自己的代码、知名开源项目、或团队的工作)?
|
|
73
73
|
otto 将在此读取、编辑、执行文件。不确定就先查看此目录,或以只读方式打开。`,optTrust:`信任 — 完整访问(读 / 改 / 执行 + 应用其配置)`,optReadonly:`只读这一会话 — 安全查看,禁写 / 执行 / 联网`,optExit:`否,退出`},parent:{title:`检测到父级 workspace`,body:`当前目录 {{currentRoot}} 没有 workspace 身份,
|
|
74
74
|
但上级目录 {{parentRoot}} 已有 workspace。`,optUseParent:`使用上级 workspace — 共享会话与记忆`,optCreateNew:`在当前目录创建新 workspace — 独立身份`,optExit:`退出`},notif:{title:`通知`,readDivider:`──── 已读 ────`},confirm:{reset:`确认重置`,replace:`确认替换`,abortConfirmTitle:`中止 Agent?`,abortConfirmMessage:`Agent 正在运行中。中止后当前回合将丢失,未完成的写入操作可能不完整。`,exitConfirmTitle:`终止并退出 otto?`,exitConfirmMessage:`Agent 正在运行中。退出将中止当前回合,未完成的写入操作可能不完整。`,exitRestartConfirmTitle:`终止并重启 otto?`},cache:{sessionLabel:`会话`,lastTurnLabel:`最近一轮`},capability:{sectionTitle:`可选项目能力`,reasonWebApp:`检测到 Web 应用`,reasonMobile:`检测到 Android/iOS 相关文件`,reasonSchedule:`运行定时任务`,actionInstall:`安装`,actionLearnMore:`了解更多`,actionNotNow:`暂不需要`},recovery:{titleProvider:`尚未安装 AI provider`,hintProvider:`otto 需要一个 provider 才能连接模型。`,ctaProvider:`运行 /setup 安装`,titleAuth:`已安装 provider,尚未连接`,hintAuth:`登录或粘贴 API key 即可继续。`,ctaAuth:`运行 /setup 连接`,titleModel:`尚无可用模型`,hintModel:`凭据可能缺失或已过期。`,ctaModel:`运行 /setup 选择模型`},suggestion:{hasReadme:`总结这个项目,并建议一个安全的第一步任务。`,hasPackageManifest:`解释一下有哪些可用脚本,以及如何运行这个项目。`,hasTestConfig:`运行现有测试,解释任何失败的原因。`,emptyProject:`帮我搭建一个新项目的脚手架,先问我一个问题。`,unrecognized:`解释一下这个项目里有什么。`},setup:{wizardApiKeyPlaceholder:`输入或粘贴密钥,按 Enter 确认`,title:`设置向导`,welcomeTitle:`欢迎使用 otto,你的 AI 伙伴`,welcomeGreeting:``,welcomeDescription:`本向导将通过 4 个步骤帮你完成初始设置:选择 AI 服务商、登录、选择模型,然后开始对话。`,welcomeDontShowAgain:`不再显示此向导`,welcomeStart:`开始`,welcomeCancel:`取消`,step1Subtitle:`otto 需要至少一个 AI provider 才能工作。选择一个安装——稍后可以通过 /extension 添加更多。`,step3Subtitle:`选择 provider 的认证方式。`,step4Subtitle:`选择一个模型开始对话。`,step5Done:`一切就绪!输入消息即可开始。`,tryAsking:`可以试着问我:`,pressEnterToStart:`按 Enter 开始对话`,installing:`安装中…`,installed:`已安装!`,installFailed:`安装失败:{{reason}}`,loginOAuth:`通过 OAuth 登录(推荐)`,loginApiKey:`粘贴 API key`,loggingIn:`登录中…`,loginFailed:`登录失败:{{reason}}`,exitTitle:`退出向导`,exitConfirm:`退出设置向导?进度将被保存 — 稍后可用 /setup 继续。`,errorTitle:`设置出错`,errorMessage:`设置步骤 {{step}} 失败:{{msg}}
|
|
75
|
-
已记录崩溃报告。`,stepNameProvider:`LLM 服务商`,stepNameLogin:`登录`,stepNameModel:`模型`,stepNameStart:`开始`,actionInstall:`安装`,actionLogin:`登录`,installingProvider:`正在安装 {{provider}}…`,installedProvider:`已安装 {{provider}}`,installPendingCapabilities:`已安装,但部分能力尚未授权——请运行 /extension 授予,否则该 provider 不会提供任何模型。`,modelRecommendedTag:`推荐`,modelRecommendedHint:`已把推荐项排在最前——随时可用 /model 更换。`,modelUnusableUnauthenticated:`需要先登录`,modelUnusableOauthRisk:`订阅方案可能被限流`,modelUnusableIntranet:`内网网关不可达`,authFailedNetwork:`无法连接授权服务,可能是网络或代理问题。`,authFailedRejected:`授权未完成。`,actionOpenProxySettings:`打开代理设置`,actionRetryAuth:`重新登录`,oauthWaiting:`等待浏览器中完成授权…`,actionOpenAgain:`重新打开授权页`,actionUseApiKeyInstead:`改用 API key`,apiKeyStorageNote:`保存在本机凭据文件中——不会写入当前项目,也不会进入聊天记录。`,installFailedRecovery:`{{provider}} 安装失败。选择下一步:`,actionRetryInstall:`重试安装`,actionChooseAnotherProvider:`换一个 provider`,capabilityGranted:`已授予能力:{{caps}}`,capabilityRevokeHint:`可随时在 /extension 中撤销。`},install:{title:`正在安装 {{source}}`,phaseResolving:`解析来源…`,phaseDetecting:`检测内容…`,phaseInstalling:`安装中…`,phaseRefreshing:`刷新能力…`,reloadingDetail:`正在刷新能力…`,done:`已安装`,summaryFailed:`安装失败`,summaryPartial:`部分安装成功`,nextStepForce:`提示:加 --force 可覆盖已存在的内容`,nextStepReload:`提示:执行 /extension reload 手动刷新能力`,failureOverflow:`(完整列表见下方消息)`,partialCounts:`{{ok}} 个成功,{{fail}} 个失败:`},proxy:{title:`Proxy`,groupConfig:`配置`,groupAbout:`说明`,fieldUrl:`代理地址`,fieldEnabled:`启用状态`,dialogSetUrl:`设置代理地址`,dialogEditUrl:`编辑代理地址`,urlPlaceholder:`http://127.0.0.1:7890`,urlEmpty:`尚未设置 — 例如 http://127.0.0.1:7890`,stateEnabled:`已启用`,stateDisabled:`已停用`,actionClear:`清除配置`,clearTitle:`清除代理配置`,clearMessage:`确认清除代理配置?({{url}})`,clearConfirm:`清除`,aboutScope:`作用于所有出站 HTTP:模型 API、登录、网页抓取、版本检查。`,aboutLoopback:`本机地址(localhost / 127.0.0.1)始终直连。`,aboutStorage:`配置存储在 {{path}}`,aboutCommand:`命令行等效:/proxy [<url>|on|off|status|clear]`,actionTest:`测试连接`,actionAdoptEnv:`采用系统代理 {{value}}(来自 {{source}})`,probeProbing:`测试中…`,probeOk:`代理可达 — {{latency}}ms({{target}})`,probeFailedProxy:`代理不可达 — {{reason}}`,probeFailedTarget:`代理正常,但目标不可达 — {{reason}}`,probeNoModel:`请先配置模型,再测试连接`,effectiveMismatch:`当前生效:{{effective}} — 需重启会话使变更生效`,effectiveNotApplied:`尚未生效 — 需重启会话使变更生效`,envDetectedToast:`检测到 {{source}}={{value}} — 运行 /proxy 可一键采用`},crashGap:{toastTitle:`检测到上次异常退出丢失了部分对话`,toastBody:`上次进程异常终止(如内存耗尽或被强制结束)时,约 {{lostTurns}} 个回合的消息未能保存,已无法恢复。较早的对话已完整保留。`},signalBar:{tabHint:`Tab 切换`,clipboard:`剪贴板`,services:`服务`,clipboardFailed:`复制受限 — 按住 {{modifier}} 拖拽用终端原生复制`,clipboardToolMissing:`复制受限 — 缺剪贴板工具,安装其一:sudo apt install wl-clipboard 或 xclip`},clipboard:{paneTitle:`剪贴板`,viewerTitle:`剪贴板内容`,charsLabel:`{{count}} 个字符`,empty:`暂无复制内容`,openHint:`查看`},mouse:{toggleTitle:`鼠标`,enabledBody:`已开启 — 拖拽即选择并复制;按住 {{modifier}} 可用终端原生选择;滚轮可滚动`,disabledBody:`已关闭 — 恢复终端原生选择,滚轮失效(可用 Alt+↑/↓ 回看)`}}}};function r(r){return e.isInitialized?e.changeLanguage(r):e.use(t).init({lng:r,fallbackLng:`en`,resources:n,defaultNS:`translation`,interpolation:{escapeValue:!1},returnNull:!1,returnEmptyString:!1}),e}r(`en`);const i=e.t.bind(e);function a(){let e=process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||``;return/zh/i.test(e)?`zh`:`en`}export{i,e as n,r,a as t};
|
|
76
|
-
//# sourceMappingURL=i18n-sGAClHYZ.js.map
|
|
75
|
+
已记录崩溃报告。`,stepNameProvider:`LLM 服务商`,stepNameLogin:`登录`,stepNameModel:`模型`,stepNameStart:`开始`,actionInstall:`安装`,actionLogin:`登录`,installingProvider:`正在安装 {{provider}}…`,installedProvider:`已安装 {{provider}}`,installPendingCapabilities:`已安装,但部分能力尚未授权——请运行 /extension 授予,否则该 provider 不会提供任何模型。`,modelRecommendedTag:`推荐`,modelRecommendedHint:`已把推荐项排在最前——随时可用 /model 更换。`,modelUnusableUnauthenticated:`需要先登录`,modelUnusableOauthRisk:`订阅方案可能被限流`,modelUnusableIntranet:`内网网关不可达`,authFailedNetwork:`无法连接授权服务,可能是网络或代理问题。`,authFailedRejected:`授权未完成。`,actionOpenProxySettings:`打开代理设置`,actionRetryAuth:`重新登录`,oauthWaiting:`等待浏览器中完成授权…`,actionOpenAgain:`重新打开授权页`,actionUseApiKeyInstead:`改用 API key`,apiKeyStorageNote:`保存在本机凭据文件中——不会写入当前项目,也不会进入聊天记录。`,installFailedRecovery:`{{provider}} 安装失败。选择下一步:`,actionRetryInstall:`重试安装`,actionChooseAnotherProvider:`换一个 provider`,capabilityGranted:`已授予能力:{{caps}}`,capabilityRevokeHint:`可随时在 /extension 中撤销。`},install:{title:`正在安装 {{source}}`,phaseResolving:`解析来源…`,phaseDetecting:`检测内容…`,phaseInstalling:`安装中…`,phaseRefreshing:`刷新能力…`,reloadingDetail:`正在刷新能力…`,done:`已安装`,summaryFailed:`安装失败`,summaryPartial:`部分安装成功`,nextStepForce:`提示:加 --force 可覆盖已存在的内容`,nextStepReload:`提示:执行 /extension reload 手动刷新能力`,failureOverflow:`(完整列表见下方消息)`,partialCounts:`{{ok}} 个成功,{{fail}} 个失败:`},proxy:{title:`Proxy`,groupConfig:`配置`,groupAbout:`说明`,fieldUrl:`代理地址`,fieldEnabled:`启用状态`,dialogSetUrl:`设置代理地址`,dialogEditUrl:`编辑代理地址`,urlPlaceholder:`http://127.0.0.1:7890`,urlEmpty:`尚未设置 — 例如 http://127.0.0.1:7890`,stateEnabled:`已启用`,stateDisabled:`已停用`,actionClear:`清除配置`,clearTitle:`清除代理配置`,clearMessage:`确认清除代理配置?({{url}})`,clearConfirm:`清除`,aboutScope:`作用于所有出站 HTTP:模型 API、登录、网页抓取、版本检查。`,aboutLoopback:`本机地址(localhost / 127.0.0.1)始终直连。`,aboutStorage:`配置存储在 {{path}}`,aboutCommand:`命令行等效:/proxy [<url>|on|off|status|clear]`,actionTest:`测试连接`,actionAdoptEnv:`采用系统代理 {{value}}(来自 {{source}})`,probeProbing:`测试中…`,probeOk:`代理可达 — {{latency}}ms({{target}})`,probeFailedProxy:`代理不可达 — {{reason}}`,probeFailedTarget:`代理正常,但目标不可达 — {{reason}}`,probeNoModel:`请先配置模型,再测试连接`,effectiveMismatch:`当前生效:{{effective}} — 需重启会话使变更生效`,effectiveNotApplied:`尚未生效 — 需重启会话使变更生效`,envDetectedToast:`检测到 {{source}}={{value}} — 运行 /proxy 可一键采用`},crashGap:{toastTitle:`检测到上次异常退出丢失了部分对话`,toastBody:`上次进程异常终止(如内存耗尽或被强制结束)时,约 {{lostTurns}} 个回合的消息未能保存,已无法恢复。较早的对话已完整保留。`},signalBar:{tabHint:`Tab 切换`,clipboard:`剪贴板`,services:`服务`,clipboardFailed:`复制受限 — 按住 {{modifier}} 拖拽用终端原生复制`,clipboardToolMissing:`复制受限 — 缺剪贴板工具,安装其一:sudo apt install wl-clipboard 或 xclip`},clipboard:{paneTitle:`剪贴板`,viewerTitle:`剪贴板内容`,charsLabel:`{{count}} 个字符`,empty:`暂无复制内容`,openHint:`查看`},mouse:{toggleTitle:`鼠标`,enabledBody:`已开启 — 拖拽即选择并复制;按住 {{modifier}} 可用终端原生选择;滚轮可滚动`,disabledBody:`已关闭 — 恢复终端原生选择,滚轮失效(可用 Alt+↑/↓ 回看)`}}}};function r(r){return e.isInitialized?e.changeLanguage(r):e.use(t).init({lng:r,fallbackLng:`en`,resources:n,defaultNS:`translation`,interpolation:{escapeValue:!1},returnNull:!1,returnEmptyString:!1}),e}r(`en`);const i=e.t.bind(e);function a(){let e=process.env.LC_ALL||process.env.LC_MESSAGES||process.env.LANG||``;return/zh/i.test(e)?`zh`:`en`}export{i,e as n,r,a as t};
|
package/dist/index.d.ts
CHANGED
|
@@ -2137,5 +2137,4 @@ interface AttachEventBridge {
|
|
|
2137
2137
|
}
|
|
2138
2138
|
declare function createSessionEventReduceBridge(sink: StoreTuiSink): AttachEventBridge;
|
|
2139
2139
|
//#endregion
|
|
2140
|
-
export { type A2uiContent, ACTION_CHIP_PATTERN, ACTION_CHIP_VALUE_SEGMENT, AlertDialog, type AlertDialogProps, type AlertRequest, App, type AppProps, type AssistantMessage, type AttachDataSourceDeps, BASH_HISTFILE_SOURCE, BashPermissionDialog, BracketedPasteHandler, type BracketedPasteOptions, type BudgetState, type BudgetStore, type BudgetView, type BufferEntry, Button, type ButtonColor, type ButtonProps, type ButtonVariant, COMPACTING_SENTINEL, type ChatMessage, type Coalescer, type CollapsedBlock, type CollapsibleMessage, type Command, type CommandContext, type CommandEntry, type CommandRegistry, type CommandResult, ConfirmDialog, type ConfirmDialogProps, type ConfirmRequest, type CreatePasteStoreOptions, Cursor, DEFAULT_SENSITIVE_PATTERNS, DIALOG_BORDER, DataList, type DataListEntry, type DataListProps, type DataListRow, type DataListTone, type DiffHunk, type DiffHunkLine, type DraftItemView, type EditAction, type EditKeyEvent, type EditResult, type ErrorRetryAction, type ErrorRetryActionKind, type ErrorRetryItem, type ExtensionDetailAction, type ExtensionDetailRequest, type ExtensionListEntry, type ExtensionMenuContribution, type ExtensionsListRequest, FIGURES, FISH_HISTFILE_SOURCE, type FiguresMap, type FocusOwner, type FocusStyle, type FuzzySearchOptions, GroupDivider, type GroupDividerProps, type GuardState, type HighlightRange, type HistoryEntry, type HistorySource, Home, type HomeProps, type IncrementalSearcher, type InputBuffer, type InputHistory, type InputMode, type InsertHistoryMode, type InsertHistoryOptions, type KeyBindingPredicate, type KeyValueEntry, type KeyValueRow, LAYOUT, type Lang, type LangMode, type MarkdownThemeOverrides, MeasuredText, MemoryDialog, type MemoryDialogProps, type MemoryEntry, type MemoryEntrySource, type MergeHistoryOptions, type MergedHistoryProvider, Message, type MessageContent, type MessageProps, type NotifyScheduler, type NotifyStats, OTTO_SESSION_SOURCE, type ObservationLike, PALETTE, PANEL_BORDER, type ParentWorkspaceChoice, type ParentWorkspacePromptOptions, type ParseBashHistoryOptions, type ParseFishHistoryOptions, type ParseZshHistoryOptions, type ParsedExtendedKey, type PasteEvent, type PasteSnapshot, type PasteSnapshotEntry, type PasteStore, type PasteStoreResidencySource, type PermissionDecision, PermissionDialog as PermissionDialogDialog, type PersistedTurnSummary, type PluginMessageRenderer, type PluginRegistration, type PrintOptions, type PrintableMessage, PromptDialog, type PromptDialogProps, type PromptEndFields, PromptInput, type PromptRequest, type ProviderUsageBadgeItem, type QueryGuard, QueuedCommands, REPLRegion, type REPLRegionProps, type RankedMatch, type RateLimitType, type ReducerState, type RegisteredRenderer, type RemoteSessionEvent, type RemoteSessionSnapshot, type RenderOptions, type Risk, SPACING, STATUS, STREAM_COALESCE_MS, ScrollIndicatorAbove, ScrollIndicatorBelow, type SearchMatch, type SearchableItem, Segmented, Segmented as Tabs, type SegmentedProps, Select, type SelectGroupProps, type SelectItemProps, type SelectLabelProps, type SelectOption, type SelectOptions, type SelectRootProps, type SelectState, type SessionDataSource, type SessionDataTarget, type SessionListItem, type SessionTransport, type SigilEntry, type SigilKind, SigilPane, type SigilPaneProps, type SigilPrefix, type SigilSearchRegistry, type SigilTrigger, type SlashNavigateAction, Spinner, type SpinnerProps, type StopReason, type Store, type StreamChunk, type StreamCommitResult, type StreamCommitState, type StreamEvent, type SubagentContext, type SubmitMode, type SubmitRoute, type SubmitRouteCtx, type SubsequenceResult, THEME, TabScope, type TabScopeProps, Tabable, type TabableProps, type TextContent, TextInput, type TextInputProps, type ThemeAppearance, type ThemeColors, type ThemePreset, type ThemePresetInput, type ThemePresetSelection, type ThemePresetSource, ThemeRegistry, type ThinkingContent, type ToolCall, type ToolCompletionMessage, type ToolMessage, type TrustPromptChoice, type TuiHandle, type TuiPanelRegistration, type TuiSink, type TuiStreamEvent, type TypeaheadState, type UseTabableOptions, type UserMessage, type WorkspaceTrustPromptOptions, type WrapPolicy, ZSH_HISTFILE_SOURCE, applySigilCompletion, applySlashCompletion, beginSyncFrame, buildTurnSummary, clearPluginRenderers, collapseMessages, createAttachSessionDataSource, createBudgetStore, createBuiltinCommands, createBuiltinThemeRegistry, createCommandRegistry, createIncrementalSearcher, createInputBuffer, createInputHistory, createMergedHistoryProvider, createPasteStore, createQueryGuard, createReducerState, createSelectState, createSessionEventReduceBridge, createStoreTuiSink, cycleIndex, deriveTurnBoundaries, detectLanguage, displayWidth, effectiveBusy, endSyncFrame, entriesToCommands, expandCollapsed, extractSigilPrefix, extractSlashPrefix, formatAgentDiagnosticsText, formatKeyValueLines, formatProviderUsageLimitTypeFull, formatTranscriptText, formatTurnTimeline, getCommandSuggestions, getInputViewport, getKillRingEntries, getMarkdownThemeUserOverrides, guardScrollbackStdout, handleEditingKey, handleEditingKeyExtended, i18next, initI18n, initStreamCommit, insertHistory, insertHistorySequence, insertTurnSummaries, isPureActionChip, isSensitiveCommand, isUsingOverage, makeCoalescer, makeNotifyScheduler, matchSubsequence, mergeHistoryEntries, navigateSuggestions, normalizeCommand, observationLiveFields, observationRow, osc52QuerySequence, osc52Write, osc8FilePath, osc8Hyperlink, parseBashHistory, parseExtendedKey, parseFishHistory, parseZshHistory, pickInsertMode, positionsToHighlightRanges, preWrapLine, preWrapLineHanging, preWrapLines, printMessages, promptParentWorkspaceChoice, promptWorkspaceTrust, rankCandidates, rankLabeledItems, rankNamedItems, reduceToTui, registerPluginRenderers, renderInline, renderMarkdownToLines, renderMessageLines, resetKillRing, resolveHorizontalStep, routeSubmit, safeCommitBoundary, scoreSubsequence, setMarkdownThemeUserOverrides, shouldPreserveDraft, shouldStripSyncOutput, shouldUseViewport, showCommandPalette, slashCommandName, startTui, streamCommitStep, stringWidth, stripScrollbackClear, stripSyncSequences, stripSyncStdout, subagentEntryStatus, subagentRestoreFields, t, toggleCollapse, useAppState, useTabScope, useTabable, withSyncFrame };
|
|
2141
|
-
//# sourceMappingURL=index.d.ts.map
|
|
2140
|
+
export { type A2uiContent, ACTION_CHIP_PATTERN, ACTION_CHIP_VALUE_SEGMENT, AlertDialog, type AlertDialogProps, type AlertRequest, App, type AppProps, type AssistantMessage, type AttachDataSourceDeps, BASH_HISTFILE_SOURCE, BashPermissionDialog, BracketedPasteHandler, type BracketedPasteOptions, type BudgetState, type BudgetStore, type BudgetView, type BufferEntry, Button, type ButtonColor, type ButtonProps, type ButtonVariant, COMPACTING_SENTINEL, type ChatMessage, type Coalescer, type CollapsedBlock, type CollapsibleMessage, type Command, type CommandContext, type CommandEntry, type CommandRegistry, type CommandResult, ConfirmDialog, type ConfirmDialogProps, type ConfirmRequest, type CreatePasteStoreOptions, Cursor, DEFAULT_SENSITIVE_PATTERNS, DIALOG_BORDER, DataList, type DataListEntry, type DataListProps, type DataListRow, type DataListTone, type DiffHunk, type DiffHunkLine, type DraftItemView, type EditAction, type EditKeyEvent, type EditResult, type ErrorRetryAction, type ErrorRetryActionKind, type ErrorRetryItem, type ExtensionDetailAction, type ExtensionDetailRequest, type ExtensionListEntry, type ExtensionMenuContribution, type ExtensionsListRequest, FIGURES, FISH_HISTFILE_SOURCE, type FiguresMap, type FocusOwner, type FocusStyle, type FuzzySearchOptions, GroupDivider, type GroupDividerProps, type GuardState, type HighlightRange, type HistoryEntry, type HistorySource, Home, type HomeProps, type IncrementalSearcher, type InputBuffer, type InputHistory, type InputMode, type InsertHistoryMode, type InsertHistoryOptions, type KeyBindingPredicate, type KeyValueEntry, type KeyValueRow, LAYOUT, type Lang, type LangMode, type MarkdownThemeOverrides, MeasuredText, MemoryDialog, type MemoryDialogProps, type MemoryEntry, type MemoryEntrySource, type MergeHistoryOptions, type MergedHistoryProvider, Message, type MessageContent, type MessageProps, type NotifyScheduler, type NotifyStats, OTTO_SESSION_SOURCE, type ObservationLike, PALETTE, PANEL_BORDER, type ParentWorkspaceChoice, type ParentWorkspacePromptOptions, type ParseBashHistoryOptions, type ParseFishHistoryOptions, type ParseZshHistoryOptions, type ParsedExtendedKey, type PasteEvent, type PasteSnapshot, type PasteSnapshotEntry, type PasteStore, type PasteStoreResidencySource, type PermissionDecision, PermissionDialog as PermissionDialogDialog, type PersistedTurnSummary, type PluginMessageRenderer, type PluginRegistration, type PrintOptions, type PrintableMessage, PromptDialog, type PromptDialogProps, type PromptEndFields, PromptInput, type PromptRequest, type ProviderUsageBadgeItem, type QueryGuard, QueuedCommands, REPLRegion, type REPLRegionProps, type RankedMatch, type RateLimitType, type ReducerState, type RegisteredRenderer, type RemoteSessionEvent, type RemoteSessionSnapshot, type RenderOptions, type Risk, SPACING, STATUS, STREAM_COALESCE_MS, ScrollIndicatorAbove, ScrollIndicatorBelow, type SearchMatch, type SearchableItem, Segmented, Segmented as Tabs, type SegmentedProps, Select, type SelectGroupProps, type SelectItemProps, type SelectLabelProps, type SelectOption, type SelectOptions, type SelectRootProps, type SelectState, type SessionDataSource, type SessionDataTarget, type SessionListItem, type SessionTransport, type SigilEntry, type SigilKind, SigilPane, type SigilPaneProps, type SigilPrefix, type SigilSearchRegistry, type SigilTrigger, type SlashNavigateAction, Spinner, type SpinnerProps, type StopReason, type Store, type StreamChunk, type StreamCommitResult, type StreamCommitState, type StreamEvent, type SubagentContext, type SubmitMode, type SubmitRoute, type SubmitRouteCtx, type SubsequenceResult, THEME, TabScope, type TabScopeProps, Tabable, type TabableProps, type TextContent, TextInput, type TextInputProps, type ThemeAppearance, type ThemeColors, type ThemePreset, type ThemePresetInput, type ThemePresetSelection, type ThemePresetSource, ThemeRegistry, type ThinkingContent, type ToolCall, type ToolCompletionMessage, type ToolMessage, type TrustPromptChoice, type TuiHandle, type TuiPanelRegistration, type TuiSink, type TuiStreamEvent, type TypeaheadState, type UseTabableOptions, type UserMessage, type WorkspaceTrustPromptOptions, type WrapPolicy, ZSH_HISTFILE_SOURCE, applySigilCompletion, applySlashCompletion, beginSyncFrame, buildTurnSummary, clearPluginRenderers, collapseMessages, createAttachSessionDataSource, createBudgetStore, createBuiltinCommands, createBuiltinThemeRegistry, createCommandRegistry, createIncrementalSearcher, createInputBuffer, createInputHistory, createMergedHistoryProvider, createPasteStore, createQueryGuard, createReducerState, createSelectState, createSessionEventReduceBridge, createStoreTuiSink, cycleIndex, deriveTurnBoundaries, detectLanguage, displayWidth, effectiveBusy, endSyncFrame, entriesToCommands, expandCollapsed, extractSigilPrefix, extractSlashPrefix, formatAgentDiagnosticsText, formatKeyValueLines, formatProviderUsageLimitTypeFull, formatTranscriptText, formatTurnTimeline, getCommandSuggestions, getInputViewport, getKillRingEntries, getMarkdownThemeUserOverrides, guardScrollbackStdout, handleEditingKey, handleEditingKeyExtended, i18next, initI18n, initStreamCommit, insertHistory, insertHistorySequence, insertTurnSummaries, isPureActionChip, isSensitiveCommand, isUsingOverage, makeCoalescer, makeNotifyScheduler, matchSubsequence, mergeHistoryEntries, navigateSuggestions, normalizeCommand, observationLiveFields, observationRow, osc52QuerySequence, osc52Write, osc8FilePath, osc8Hyperlink, parseBashHistory, parseExtendedKey, parseFishHistory, parseZshHistory, pickInsertMode, positionsToHighlightRanges, preWrapLine, preWrapLineHanging, preWrapLines, printMessages, promptParentWorkspaceChoice, promptWorkspaceTrust, rankCandidates, rankLabeledItems, rankNamedItems, reduceToTui, registerPluginRenderers, renderInline, renderMarkdownToLines, renderMessageLines, resetKillRing, resolveHorizontalStep, routeSubmit, safeCommitBoundary, scoreSubsequence, setMarkdownThemeUserOverrides, shouldPreserveDraft, shouldStripSyncOutput, shouldUseViewport, showCommandPalette, slashCommandName, startTui, streamCommitStep, stringWidth, stripScrollbackClear, stripSyncSequences, stripSyncStdout, subagentEntryStatus, subagentRestoreFields, t, toggleCollapse, useAppState, useTabScope, useTabable, withSyncFrame };
|
package/dist/index.js
CHANGED
|
@@ -110,5 +110,4 @@ line three`,onDismiss:$},rows:24,columns:80})}]},{id:`A2uiFormDialog`,category:`
|
|
|
110
110
|
`)),s+=60,e.notify(),setImmediate(l)};setImmediate(l)},d=r=>{if(r===``){u(n,t.length,()=>{s(),e.streamStore.setState({streamingText:``})});return}t=r;let i=Uc(r);i>n&&(l(n,i),n=i);let o=r.slice(n);o!==e.streamStore.getState().lastTail&&e.streamStore.setState({streamingText:o.trim()?vo(Ws(ml(o)),a()).join(`
|
|
111
111
|
`):``,lastTail:o})},f=t=>{if(e.scrollbackMode){d(t);return}let{chunks:n,tail:r,state:i}=Gc(e.streamStore.getState().streamCommit,t);if(n.length>0){let t=n.map(t=>{let n=e.incMsgCounter();return{role:`assistant_stream`,text:t.text,lead:t.lead,id:`s-${n}`}});e.messageStoreHandle.appendMany(t,()=>`s-${e.incMsgCounter()}`)}e.streamStore.setState({streamCommit:i,streamingText:r}),(t===``||n.length>0)&&e.notify()},p=t=>{e.streamStore.setState({streamingThinking:t})};return{applyStreamText:f,applyStreamThinking:p,streamTextCoalescer:Jc(f,e.coalesceMs),streamThinkingCoalescer:Jc(p,e.coalesceMs),outputTokensThrottle:jl(e.streamStore,e.coalesceMs),resetController:()=>{t=``,n=0,r=0,i=!1}}}function tv(e,t){if(e.length===0)return[];let n=Math.max(1,t);return e.map(e=>yc(e,n))}function nv(e){let t=t=>{let n=tv(t,e.getColumns()),{text:r,hasHistory:i}=al(t.map((e,t)=>({role:e.role??``,lines:n[t]??[]})),e.getHasHistory());return e.setHasHistory(i),r},n=null,r=r=>{let i=t(r);if(i){if(n){n.push(i);return}e.scrollbackBuffer.write(i)}},i=i=>{if(i.length<=60&&!n){r(i);return}if(n){let e=t(i);e&&n.push(e);return}n=[t(i.slice(0,60))];let a=60,o=()=>{if(a>=i.length){let t=(n??[]).join(``);n=null,t&&e.scrollbackBuffer.write(t),e.notify();return}let r=i.slice(a,a+60);a+=60,n?.push(t(r)),setImmediate(o)};setImmediate(o)};return{commitToHistory:e=>i([e]),commitManyToHistory:i}}function rv(e){let{taskStore:t,notificationStore:n,resolvers:r,flushScrollbackIfIdle:i,paneOwnsViewport:a,setPaneOwnsViewport:o,getRouter:s=F}=e,c=null,l={},u=(e,t)=>{let n=s();n.navigate(`/dialog/plugin-panel`,{state:{panelInfo:e,onClose:()=>{n.goBack(),t?.()}}})};return{openModal:(e=>{switch(e.kind){case`select`:{let t=s();if(e.async){let n=!1;t.navigate(`/dialog/select`,{state:{title:e.title,subtitle:`Probing, please wait…`,options:[],layout:e.layout??`buttons`}}),r.select=e=>{if(e==null){n=!0;return}},(async()=>{try{let i=await e.async;if(n)return;r.select=t=>{t==null?e.onCancel?.():e.onSelect(t)},t.navigate(`/dialog/select`,{replace:!0,state:{title:i.title??e.title,subtitle:i.subtitle??e.subtitle,subtitleTone:e.subtitleTone,options:i.options,maxVisible:e.maxVisible,layout:e.layout,searchable:e.searchable,subtitleActions:e.subtitleActions,detailPlacement:e.detailPlacement,onHighlight:e.onHighlight}})}catch(i){if(n)return;r.select=()=>{},t.navigate(`/dialog/select`,{replace:!0,state:{title:e.title,subtitle:`Error: ${i instanceof Error?i.message:String(i)}`,options:[{label:`Close`,value:`close`,color:`gray`}],layout:`buttons`}})}})();return}process.env.NODE_ENV!==`production`&&t.currentPath===`/dialog/select`&&e.replace!==!0&&console.warn('[openModal] Detected re-entrant openModal({ kind: "select" }) — this pushes a new dialog stack entry instead of replacing the current one. Use the `async` field for loading→content transitions, or close the current dialog before opening a new one. See RFC-285 D2.');let n=e.replace===!0&&t.currentPath===`/dialog/select`;t.navigate(`/dialog/select`,{replace:n,state:{title:e.title,subtitle:e.subtitle,subtitleTone:e.subtitleTone,options:e.options,maxVisible:e.maxVisible,searchable:e.searchable,layout:e.layout,subtitleActions:e.subtitleActions,detailPlacement:e.detailPlacement,initialFilter:e.initialFilter,onFilterChange:e.onFilterChange,onHighlight:e.onHighlight,defaultSelectedValue:e.defaultSelectedValue}}),r.select=t=>{t==null?e.onCancel?.():e.onSelect(t)};return}case`extensionDetail`:{let t=s(),n=()=>{t.goBack()};t.navigate(`/dialog/extension`,{state:{title:e.title,meta:e.meta,metaStatus:e.metaStatus,metaSuffix:e.metaSuffix,actions:e.actions,panelInfo:e.panelInfo,info:e.info,healthStats:e.healthStats,logEntries:e.logEntries,onRefresh:e.onRefresh,dataListEntries:e.dataListEntries,fullText:e.fullText,onOpenPanel:e.panelInfo?()=>u(e.panelInfo):void 0,onAction:t=>{n(),e.onAction(t)},onClose:()=>{let r=t.stack,i=r.length>=2?r[r.length-2]?.path:void 0;n(),i!==`/dialog/extensions`&&e.onClose?.()}}});return}case`pluginPanel`:u(e.panelInfo,e.onClose);return;case`extensionsList`:{let t=s();t.navigate(`/dialog/extensions`,{state:{entries:e.entries,menuContributions:e.menuContributions,lastSelectedValue:l.value,onSelect:n=>{l.value=n,n.startsWith(`contrib:`)&&t.goBack(),e.onSelect(n)},onCancel:()=>{t.goBack(),e.onCancel?.()}}});return}case`input`:return new Promise(t=>{if(e.signal?.aborted){t(null);return}let n=!1,i=e=>{n||(n=!0,r.input===i&&(s()?.goBack(),r.input=null,r.inputAction=null),t(e))};r.input=i,e.actionButton?.onPress&&(r.inputAction=e.actionButton.onPress),e.signal?.addEventListener(`abort`,()=>i(null),{once:!0}),s().navigate(`/dialog/input`,{state:{title:e.title,description:e.description,placeholder:e.placeholder,defaultValue:e.defaultValue,mask:e.mask,actionButton:e.actionButton?{label:e.actionButton.label}:void 0}})});case`onboarding`:return new Promise(t=>{let n=!1,i=e=>{n||(n=!0,r.onboarding===i&&(s()?.dismiss(`/dialog/onboarding`),r.onboarding=null),t(e))};r.onboarding=i,s().navigate(`/dialog/onboarding`,{state:{onLanguagePreview:e.onLanguagePreview}})});case`questions`:return new Promise(t=>{o(!0),r.questions=(e,n)=>{t(e?{answers:e,freeformText:n}:null)},s().navigate(`/dialog/questions`,{state:{title:e.title,questions:e.questions}})});case`confirm`:{let t=s();r.confirm=()=>e.onConfirm(),r.cancel=()=>e.onCancel?.(),r.extra=e.onExtra??null;let n=t.currentPath===`/dialog/confirm`;t.navigate(`/dialog/confirm`,{replace:n,state:{title:e.title,message:e.message,confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,confirmColor:e.confirmColor,dangerous:e.dangerous,extraLabel:e.extraLabel,extraColor:e.extraColor}});return}case`permissions`:s().navigate(`/dialog/info`,{state:{title:`Permissions`,lines:e.lines}});return;case`info`:s().navigate(`/dialog/info`,{state:{title:e.title,lines:e.lines,action:e.action,lineTones:e.lineTones,dataListEntries:e.dataListEntries}});return;case`context`:s().navigate(`/pane/context`);return;case`memory`:s().navigate(`/dialog/memory`,{state:{projectIndex:e.projectIndex,userIndex:e.userIndex,onViewEntry:e.onViewEntry,onForget:e.onForget}});return;case`keybindingPanel`:s().navigate(`/dialog/keybindings`,{state:{overrides:e.overrides,onSave:e.onSave,onSaveReplace:e.onSaveReplace,onReset:e.onReset,onResetAll:e.onResetAll}});return;case`shortcutsPanel`:s().navigate(`/dialog/shortcuts`,{state:{bindings:e.shortcuts,onSave:e.onSave,onDelete:e.onDelete}});return;case`fileViewer`:s().navigate(`/viewer/file`,{state:{path:e.path,content:e.content,preTruncated:e.preTruncated,onDismiss:e.onDismiss}});return;case`helpViewer`:s().navigate(`/viewer/help`,{state:{title:e.title,lines:e.lines,onDismiss:e.onDismiss}});return;case`progress`:{let t=s();c={title:e.title,phases:e.phases,phaseIndex:0,phaseStatuses:[`active`,`pending`,`pending`,`pending`],percent:0,detail:e.phases[0]??``,status:`running`,onDismiss:()=>{c=null}},t.navigate(`/dialog/progress`,{state:c});return}case`wizard`:{let t=s();if(t?.currentPath===`/dialog/wizard`)return;t?.navigate(`/dialog/wizard`,{state:{...e,onDismiss:()=>{t.dismiss(`/dialog/wizard`),e.onDismiss?.()},onComplete:()=>{t.dismiss(`/dialog/wizard`),e.onComplete?.()}}});return}case`a2uiForm`:{let t=s();t.navigate(`/dialog/a2ui-form`,{state:{component:e.component,onAction:(n,r,i)=>{t.goBack(),e.onAction(n,r,i)},onDismiss:()=>{t.goBack()}}});return}default:return e}}),togglePane:(e,r)=>{let a=s();if(!a)return;let o=e=>a.currentPath===e||a.currentPath.startsWith(e+`/`),c=e=>{a.currentPath===e?a.goBack():a.navigate(`/`,{reset:!0})};switch(e){case`history`:Zu()?.();return;case`backgroundTasks`:{let e=`/pane/delegates`;r??!o(e)?a.navigate(e):(c(e),t.setState({backgroundOutput:null}),i());return}case`draftPane`:{let e=`/pane/draft`;r??!o(e)?a.navigate(e):c(e);return}case`queuePane`:{let e=`/pane/queue`;r??!o(e)?a.navigate(e):c(e);return}case`notifications`:r??a.currentPath!==`/pane/notifications`?a.navigate(`/pane/notifications`):(a.goBack(),n.setState({notifications:n.getState().notifications.map(e=>({...e,read:!0}))}));return;case`schedulePane`:r??a.currentPath!==`/pane/schedule`?a.navigate(`/pane/schedule`):a.goBack();return;case`status`:r??a.currentPath!==`/pane/status`?a.navigate(`/pane/status`):a.goBack();return;case`cacheStats`:r??a.currentPath!==`/pane/cache`?a.navigate(`/pane/cache`):a.goBack();return;case`compactionLog`:{let e=`/pane/compaction-log`;r??!o(e)?a.navigate(e):c(e);return}case`gallery`:r??a.currentPath!==`/pane/gallery`?a.navigate(`/pane/gallery`):a.goBack();return;case`proxy`:r??a.currentPath!==`/pane/proxy`?a.navigate(`/pane/proxy`):a.goBack();return;case`prompts`:{let e=`/pane/prompts`;r??!o(e)?a.navigate(e):c(e);return}default:return e}},getNotifyStats:e.getNotifyStats,isFullScreenPaneActive:()=>a(),getCurrentPath:()=>s()?.currentPath??`/`,isForcedUpgradeActive:()=>e.taskStore.getState().forcedUpgrade!==null,openAlert:e=>{r.alert=()=>e.onOk?.(),s().navigate(`/dialog/alert`,{state:{title:e.title,message:e.message,okLabel:e.okLabel}})},openPrompt:e=>new Promise(t=>{r.prompt=t,s().navigate(`/dialog/prompt`,{state:{title:e.title,message:e.message,placeholder:e.placeholder,initialValue:e.initialValue,submitLabel:e.submitLabel,cancelLabel:e.cancelLabel}})}),updateProgress(e){if(!c)return;let t=s();if(!t){c=null;return}c={...c,...e},t.navigate(`/dialog/progress`,{replace:!0,state:c})}}}function iv(e){let{taskStore:t,state:n,notify:r,showToast:i,getRouter:a=F}=e;return{startShellExecution:e=>{n.shellTimer&&clearTimeout(n.shellTimer),t.setState({shellExecution:{command:e,output:``,status:`running`,exitCode:null}}),a()?.navigate(`/pane/shell`),r()},appendShellOutput:e=>{t.getState().shellExecution&&(t.setState({shellExecution:{...t.getState().shellExecution,output:t.getState().shellExecution.output+e}}),r())},finishShellExecution:(e,n,i)=>{t.getState().shellExecution&&(t.setState({shellExecution:{...t.getState().shellExecution,status:e===null?`error`:`done`,exitCode:e,terminated:i,output:n?t.getState().shellExecution.output+n:t.getState().shellExecution.output}}),r())},dismissShellExecution:()=>{n.shellTimer&&clearTimeout(n.shellTimer),t.setState({shellExecution:null}),a()?.currentPath===`/pane/shell`&&a()?.goBack(),n.shellTimer=null,r()},copyShellOutput:()=>{let e=t.getState().shellExecution;e&&(pr(e.output),i(V.t(`shell.copiedTitle`),V.t(`shell.copiedBody`)))},getShellExecutionSnapshot:()=>{let e=t.getState().shellExecution;return e?{command:e.command,output:e.output,exitCode:e.exitCode,terminated:e.terminated}:null}}}function av(t){let{notificationStore:n,state:r,counters:i,notify:a,getRouter:o=F}=t;return{showToast:(t,s)=>{r.toastTimer&&clearTimeout(r.toastTimer);let c={id:++i.toast,title:t,content:s};n.setState({toast:c}),e(o(),Se,!0),r.toastTimer=setTimeout(()=>{n.setState({toast:null}),r.toastTimer=null,e(o(),Se,!1),a()},mh),a()},showRetryDialog:(t,r,i,s,c,l,u)=>{n.setState({retryCountdown:{attempt:t,max:r,delayMs:i,accelerate:s,reason:l,onExpired:()=>{n.setState({retryCountdown:null}),e(o(),xe,!1),a(),c()},onStop:u?()=>{n.setState({retryCountdown:null}),e(o(),xe,!1),a(),u()}:void 0}}),e(o(),xe,!0),a()},clearRetryDialog:()=>{n.setState({retryCountdown:null}),e(o(),xe,!1),a()},showErrorRetry:t=>{let r=t=>()=>{n.setState({errorRetry:null}),e(o(),pe,!1),a(),t()};n.setState({errorRetry:{...t,actions:t.actions.map(e=>({...e,run:r(e.run)})),focusIndex:0,exhausted:t.exhausted??!1,onExpired:r(t.onExpired),onCancel:r(t.onCancel)}}),e(o(),pe,!0),a()},clearErrorRetry:()=>{n.setState({errorRetry:null}),e(o(),pe,!1),a()},pushNotification:(e,t,r=`system`,o=`info`)=>{n.setState({notifications:[{id:++i.notify,source:r,level:o,title:e,message:t,timestamp:Date.now(),read:!1},...n.getState().notifications.slice(0,49)]}),a()},dismissNotification:e=>{n.setState({notifications:n.getState().notifications.filter(t=>t.id!==e)}),n.getState().notifications.length===0&&o()?.goBack(),a()},markAllNotificationsRead:()=>{n.setState({notifications:n.getState().notifications.map(e=>({...e,read:!0}))}),a()}}}function ov(e){let{taskStore:t,messageStoreHandle:n,counters:r,pendingSteerMsgIds:i,scrollbackMode:a,commitToHistory:o,scanA2uiButtons:s,notify:c}=e;return{setPendingEcho:(e,r)=>{if(t.setState({pendingEcho:{text:e,mode:r}}),!a){let e=n.store.getState().messages.at(-1);e?.id?n.patchById(e.id,{streaming:!0}):n.patchLast({streaming:!0})}c()},clearPendingEcho:()=>{let e=t.getState().pendingEcho;if(e){if(a&&(o({role:`user`,content:e.text}),s()),t.setState({pendingEcho:null}),!a){let e=n.store.getState().messages.at(-1);e?.id?n.patchById(e.id,{streaming:!1}):n.patchLast({streaming:!1})}c()}},withdrawPendingEcho:()=>{if(!t.getState().pendingEcho)return!1;if(t.setState({pendingEcho:null}),!a){let e=`u-${r.msg}`,t=n.store.getState().messages.findLastIndex(t=>t.id===e);if(t!==-1){let e=[...n.store.getState().messages];e.splice(t,1),n.store.setState({messages:e})}else n.removeLast()}return c(),!0},setPendingSteer:(e,o)=>{if(t.setState({pendingSteers:[...t.getState().pendingSteers,{text:e,id:o}]}),!a){r.msg++;let t=`u-${r.msg}`;i.set(o,t),n.append({role:`user`,content:e,streaming:!0,id:t},t)}c()},commitPendingSteer:e=>{let r=t.getState().pendingSteers,l=r.find(t=>t.id===e);if(l){if(a)o({role:`user`,content:l.text}),s();else{let t=i.get(e);t&&(n.patchById(t,{streaming:!1}),i.delete(e))}t.setState({pendingSteers:r.filter(t=>t.id!==e)}),c()}},withdrawPendingSteer:e=>{let r=t.getState().pendingSteers;if(r.some(t=>t.id===e)){if(t.setState({pendingSteers:r.filter(t=>t.id!==e)}),!a){let t=i.get(e);if(t){let r=n.store.getState().messages.filter(e=>e.id!==t);n.store.setState({messages:r}),i.delete(e)}}c()}},clearPendingSteers:()=>{let e=t.getState().pendingSteers;if(e.length!==0){if(a){for(let t of e)o({role:`user`,content:t.text});s()}else for(let t of e){let e=i.get(t.id);e&&(n.patchById(e,{streaming:!1}),i.delete(t.id))}t.setState({pendingSteers:[]}),c()}}}}function sv(e){let{streamStore:t,streamTextCoalescer:n,streamThinkingCoalescer:r,outputTokensThrottle:i,perfStore:a,statusStore:o,compactionLogStore:s,drainQueue:c,getRouterRef:l,notify:u}=e;return{pushEngineEvent:e=>{switch(e.kind){case`agentProcessing`:t.setState({processing:e.value}),e.value||c();break;case`streamingText`:n.push(e.text,e.text===``);break;case`streamingThinking`:r.push(e.text,e.text===``);break;case`activeTool`:t.setState({activeTool:e.name});break;case`spinnerMode`:t.setState(e.mode===`requesting`?{spinnerMode:e.mode,outputTokensThisTurn:0}:{spinnerMode:e.mode});break;case`outputTokensThisTurn`:i.push(e.n);break;case`maxOutputTokens`:t.setState({maxOutputTokens:e.n});break;case`toolBudget`:t.setState({toolTurnCount:e.toolTurnCount,maxToolTurns:e.maxToolTurns,promptOutputTokens:e.outputTokens??0,promptOutputTokenBudget:e.outputTokenBudget??0});break;case`perf`:e.indicatorLevel&&a.setIndicatorLevel(e.indicatorLevel);break;case`status`:{let t=!1;e.session&&(o.setSession(e.session),t=!0),e.memory&&(o.setMemory(e.memory),t=!0),e.notify&&(o.setNotify(e.notify),t=!0),e.pluginMetrics&&(o.setPluginMetrics(e.pluginMetrics),t=!0),t&&u();break}case`compactionLog`:switch(e.entryKind){case`compact`:s.recordCompaction(e.before,e.after,e.summary);break;case`prune`:s.recordPrune(e.tokensSaved,e.prunedCount??0);break;case`history_capped`:s.recordHistoryCapped(e.removedCount);break}l()?.currentPath.startsWith(`/pane/compaction-log`)&&u();break}}}}function cv(e){let{modalHandleMethods:t,permResolvers:n,counters:r,taskStore:i,getRouterRef:a,notify:o,onConfirmResolve:s}=e;return{...t,resolveConfirm:e=>{s(e)},requestPermission:e=>{let t=`perm-${++r.perm}`;return new Promise(r=>{n.set(t,r);let s={id:t,tool:e.tool,input:e.input,risk:e.risk,description:e.description,alwaysAllowLabel:e.alwaysAllowLabel};i.setState({pendingPermission:s}),o(),a()?.navigate(`/dialog/permission`,{state:s})})}}}function lv(e){let{pendingMethods:t,restoreInputRef:n,pasteBridgeRef:r}=e;return{...t,restoreInputText:e=>{n.current?.fill(e)},hydratePaste:e=>{r.current?.hydrate(e)},exportPaste:()=>r.current?.export()??null}}function uv(e){let{lifecycleFlags:t,scrollbackBuffer:n,streamTextCoalescer:r,streamThinkingCoalescer:i,notifyScheduler:a,state:o,registryUnregisterAll:s,unmount:c,windowMode:l,scopedViewport:u,hasHistoryRef:d,resetStreamController:f,messageStoreHandle:p,scrollStoreHandle:m,streamStoreHandle:h,taskStoreHandle:g,notificationStoreHandle:_,perfStore:v,statusStore:y,contextStore:b,budgetStore:x,taskStore:S,notificationStore:C,a2uiButtonsRef:w,resetStatusWidgetBreakers:ee,getRouterRef:T,overlayPaths:te,syncOverlayRoute:ne,notify:re,i18next:ie,detectLanguage:E,setLanguage:ae,getThemeRef:oe,setTerminalTitle:D}=e;return{stop:async()=>{if(!t.stopped){t.stopped=!0,t.unmounted=!0;try{e.detachSessionSource?.(),s();try{n.flush()}catch{}r.cancel(),i.cancel(),a.cancel(),o.toastTimer&&=(clearTimeout(o.toastTimer),null)}catch{}finally{try{c()}catch{}try{await e.teardownTerminal?.()}catch{}try{e.onStop?.()}catch{}}}},clearSession:()=>{l||n.write(u?`\x1B[2J\x1B[H`:`\x1B[2J\x1B[3J\x1B[H`),d.set(!1),f(),p.reset(),m.toBottom(),h.reset(),g.reset(),_.reset(),v.reset(),y.reset(),b.reset(),x.reset(),S.setState({tasks:[]}),S.setState({tasksTitle:void 0}),S.setState({turnBoundaries:[]}),S.setState({editedFiles:[]}),S.setState({subagentsAccum:new Map}),C.setState({toast:null}),C.setState({retryCountdown:null}),C.setState({errorRetry:null});let e=T();if(e)for(let t of te)ne(e,t,!1);C.setState({providerUsage:null}),o.toastTimer&&=(clearTimeout(o.toastTimer),null),w.current=[],s(),ee(),e?.currentPath!==`/home`&&e?.navigate(`/home`,{reset:!0}),re()},setLanguage:e=>{let t=e===`auto`?E():e;return ie.changeLanguage(t),ae(t),re(),t},setPresetSelection:e=>{oe()?.setPresetSelection(e)},setTerminalTitle:e=>D(e)}}function dv(e){let{messageStoreHandle:t,notify:n}=e,r=null,i=()=>{let e=r;e&&(r=null,e.stop())};return{attachSessionSource:async e=>{if(r)throw Error(`attachSessionSource: a session data source is already attached`);return r={stop:await e.start({messageStore:{setState:e=>t.store.setState(e)}})},n(),i},detachSessionSource:i}}function fv(e){let{scrollbackMode:t,commitToHistory:n,commitManyToHistory:r,messageStoreHandle:i,counters:a,getTurnMessagesFor:o,taskStore:s,notify:c,scanA2uiButtons:l}=e;return{pushMessage:e=>{if(t){n(e),c(),l();return}a.msg++,i.append(e,`m-${a.msg}`),c(),l()},pushMessages:e=>{if(e.length!==0){if(t){r(e),c(),l();return}i.appendMany(e,()=>(a.msg++,`m-${a.msg}`)),c(),l()}},echoUserInput:(e,r)=>{let o=r?.pending===!0;if(t){if(o)return;n({role:`user`,content:e}),l();return}a.msg++;let s=`u-${a.msg}`;i.append({role:`user`,content:e,streaming:o,id:s},s),c(),l()},getTurnMessages:o,getTurnBoundaries:()=>s.getState().turnBoundaries,getEditedFiles:()=>s.getState().editedFiles}}function pv(e){let{streamMethods:t,taskStore:n,notificationStore:r,notificationMethods:i,getRouterRef:a,syncOverlayRoute:o,overlayPause:s,drainQueue:c,notify:l}=e;return{pushEngineEvent:t.pushEngineEvent,hasQueuedFollowUp:()=>n.getState().queued.length>0,takeLastQueuedFollowUp:()=>{let e=n.getState().queued,t=e.at(-1);if(t)return n.setState({queued:e.slice(0,-1)}),l(),t},enqueueFollowUp:(e,t=`send`)=>{n.setState({queued:[...n.getState().queued,{text:e,mode:t}]}),l(),c()},setPauseDialog:e=>{r.setState({pauseDialog:e}),o(a(),s,!!e),l()},showRetryDialog:i.showRetryDialog,clearRetryDialog:i.clearRetryDialog,showErrorRetry:i.showErrorRetry,clearErrorRetry:i.clearErrorRetry}}function mv(e){let{modalHandleMethods:t,taskStore:n,getRouterRef:r,syncOverlayRoute:i,overlayServices:a,flushScrollbackIfIdle:o,notify:s}=e;return{togglePane:t.togglePane,setServices:e=>{i(r(),a,e),s()},switchToSubagentContext:e=>{n.setState({subagentContext:e});let t=r();e&&t?.currentPath!==`/subagent`&&t?.navigate(`/subagent`),o(),s()},toggleEditedFiles:e=>{if(n.getState().editedFiles.length===0)return;let t=r();if(!t)return;let i=`/pane/edited-files`,a=t.currentPath===i||t.currentPath.startsWith(i+`/`),o=e??!a;o&&!a?t.navigate(i):!o&&a&&t.currentPath===i&&t.goBack()},clearEditedFiles:()=>{n.setState({editedFiles:[]}),s()},removeQueuedAt:e=>{n.setState({queued:n.getState().queued.filter((t,n)=>n!==e)}),s()},clearQueue:()=>{n.setState({queued:[]}),s()},moveQueuedItem:(e,t)=>{let r=e,i=e+t;if(i<0||i>=n.getState().queued.length||r<0||r>=n.getState().queued.length)return;let a=[...n.getState().queued],[o]=a.splice(r,1);o&&a.splice(i,0,o),n.setState({queued:a}),s()}}}function hv(e){let{taskStore:t,taskStoreHandle:n,registerPlugin:r,registryUnregister:i,computeStalePluginIds:a,getRegistrySnapshot:o,getStatusItems:s,getStatusWidgets:c,resetStatusWidgetBreakers:l,registryRef:u,a2uiButtonsRef:d,subagentRestoreFields:f,notify:p}=e;return{setPluginRegistrations:e=>{let n=new Set;for(let t of e)n.add(t.pluginId),r(t.pluginId,t);for(let e of a(n,o()))i(e);l(),t.setState({pluginStatusItems:s(),statusWidgets:c()}),p()},unregisterPluginSource:e=>{i(e),l(),t.setState({pluginStatusItems:s(),statusWidgets:c()}),p()},setPluginStatusItems:e=>{n.actions.setPluginStatusItems(e.map(e=>({id:e.icon,text:e.text})))},setCommands:e=>{t.setState({commands:e}),r(`cli-commands`,{pluginId:`cli-commands`,commands:[...e]})},registerArgumentSuggester:(e,t)=>{u?.current&&u.current.registerArgumentSuggester(e,t)},setA2uiButtons:e=>{d.current=e},addSubagent:e=>{let n=new Map(t.getState().subagentsAccum);n.set(e.id,{id:e.id,command:e.name,type:`agent-session`,startedAt:e.startedAt??Date.now(),...f(e.status)}),t.setState({subagentsAccum:n}),p()},getSubagents:()=>t.getState().subagentsAccum,clearSubagents:()=>{t.setState({subagentsAccum:new Map}),p()}}}function gv(e){let{notificationMethods:t,notifyScheduler:n,taskStore:r,modalHandleMethods:i,shellMethods:a,contextStore:o,getRouterRef:s,scrollStoreHandle:c}=e;return{pushNotification:t.pushNotification,dismissNotification:t.dismissNotification,markAllNotificationsRead:t.markAllNotificationsRead,getNotifyStats:()=>n.getStats(),getCurrentPath:()=>s()?.currentPath??`/`,isForcedUpgradeActive:()=>r.getState().forcedUpgrade!==null,isFullScreenPaneActive:()=>i.isFullScreenPaneActive(),getShellExecutionSnapshot:a.getShellExecutionSnapshot,addContextTurn:e=>o.addTurn(e),markContextTurns:e=>o.markTurns(e),showToast:t.showToast,setTopView:e=>{s()?.navigate(`/`,{reset:!0}),c.toBottom(),c.setTotalLines(0)}}}function _v(e){let t=e.intervalMs??5e3,n=e.minIntervalMs??2e3,{stdout:r,enabled:i}=e,a=null,o=0,s=()=>{try{r.write(`\x1B]11;?\x07`),o=Date.now()}catch{}};return{start:()=>{i&&r.isTTY&&(a||(s(),a=setInterval(s,t),a.unref?.()))},stop:()=>{a&&=(clearInterval(a),null)},pollNow:()=>{i&&r.isTTY&&(Date.now()-o<n||s())}}}function vv(e,t,n,r,i){return{onPermissionDecision:(e,n,i)=>{let a=t.get(e);t.delete(e),r.setState({pendingPermission:null}),F()?.goBack(),a?.({approved:n,mode:i})},onSelectResolve:e=>{let t=n.select;n.select=null,F()?.goBack(),t?.(e)},onInputResolve:e=>{let t=n.input;t&&(n.input=null,F()?.currentPath===`/dialog/input`&&F()?.goBack(),t(e))},onOnboardingResolve:e=>{n.onboarding?.(e)},onInputAction:()=>{let e=n.inputAction;e?.()},onQuestionsResolve:(e,t)=>{let r=n.questions;r&&(i?.(!1),n.questions=null,F()?.currentPath===`/dialog/questions`&&F()?.goBack(),r(e,t))},onConfirmResolve:(e,t)=>{let r=n.confirm,i=n.cancel,a=n.extra;n.confirm=null,n.cancel=null,n.extra=null,F()?.currentPath===`/dialog/confirm`&&F()?.goBack(),!(!r&&!i&&!a)&&(t?a?.():e?r?.():i?.())},onAlertResolve:()=>{let e=n.alert;n.alert=null,F()?.goBack(),e?.()},onPromptResolve:e=>{let t=n.prompt;n.prompt=null,F()?.goBack(),t?.(e)},getTurnMessagesFor:t=>{let n=r.getState().turnBoundaries,i=e.getMessages(),a=t>1?n[t-2]??0:0,o=n[t-1]??i.length;return i.slice(a,o)}}}function yv(e,t,n,r,i){return()=>{if(t()||i.getState().queued.length===0)return;let[e,...a]=i.getState().queued;i.setState({queued:a}),n(),queueMicrotask(()=>{try{let t=r?.(e.text,e.mode);t&&typeof t.catch==`function`&&t.catch(()=>{})}catch{}})}}function bv(t){let[,n]=K(0);H.useEffect(()=>{let e=()=>n(e=>e+1);return t.state.listener=e,()=>{t.state.listener===e&&(t.state.listener=null)}},[]);let r=H.useCallback(()=>{Tu(),t.taskStore.setState({backgroundOutput:null}),t.opts.onBackgroundOutputClose?.(),t.flushScrollbackIfIdle(),t.notify()},[]),i=H.useCallback(()=>{F()?.goBack(),t.taskStore.setState({backgroundOutput:null}),t.opts.onBackgroundOutputClose?.(),t.flushScrollbackIfIdle(),t.notify()},[]),a=H.useCallback(()=>{F()?.currentPath===`/subagent`&&F()?.goBack(),t.opts.onSubagentExit?.(),t.taskStore.setState({subagentContext:null}),t.flushScrollbackIfIdle(),t.notify()},[]),o=H.useCallback(()=>{t.taskStore.getState().queued.length!==0&&(t.taskStore.setState({queued:t.taskStore.getState().queued.slice(0,-1)}),t.notify())},[]),s=H.useCallback(()=>{F()?.currentPath===`/dialog/info`&&F()?.goBack(),t.notify()},[]),c=H.useCallback(()=>{F()?.currentPath===`/dialog/memory`&&F()?.goBack(),t.notify()},[]),l=H.useCallback(()=>{F()?.currentPath===`/dialog/keybindings`&&F()?.goBack(),t.notify()},[]),u=H.useCallback(()=>{F()?.currentPath===`/dialog/shortcuts`&&F()?.goBack(),t.notify()},[]),d=H.useCallback(()=>{F()?.navigate(`/pane/context/detail`)},[]),f=H.useCallback(()=>{F()?.currentPath===`/pane/context/detail`&&F()?.goBack()},[]),p=H.useCallback(()=>{let e=F();e?.currentPath.startsWith(`/pane/context`)&&e.navigate(`/`,{reset:!0})},[]),m=H.useCallback(()=>{let e=F();e&&(e.currentPath===`/pane/notifications`?e.goBack():e.navigate(`/pane/notifications`))},[]),h=H.useCallback(e=>{t.notificationStore.setState({notifications:t.notificationStore.getState().notifications.filter(t=>t.id!==e)}),t.notificationStore.getState().notifications.length===0&&F()?.goBack()},[]),g=H.useCallback(()=>{t.notificationStore.setState({notifications:t.notificationStore.getState().notifications.map(e=>({...e,read:!0}))}),F()?.goBack()},[]),_=H.useCallback(()=>{t.opts.onSubmit?.(`/upgrade --force`,`send`)},[]),v=H.useCallback(()=>{t.stopRef.current?.()},[]),y=H.useCallback((n,r)=>{t.state.toastTimer&&clearTimeout(t.state.toastTimer);let i={id:++t.toastCounterRef.current,title:n,content:r};t.notificationStore.setState({toast:i}),e(F(),Se,!0),t.state.toastTimer=setTimeout(()=>{t.notificationStore.setState({toast:null}),t.state.toastTimer=null,e(F(),Se,!1),t.notify()},mh),t.notify()},[]),b=H.useCallback(()=>{t.state.toastTimer&&(clearTimeout(t.state.toastTimer),t.state.toastTimer=null),t.notificationStore.getState().toast&&(t.notificationStore.setState({toast:null}),e(F(),Se,!1),t.notify())},[]),x=t.scrollbackMode?H.useCallback(e=>{t.inkWriteRef.current=e},[]):void 0,S=t.opts.welcome?.cwd?H.useCallback(async e=>{let{content:n,truncated:r}=await vn(An(t.opts.welcome.cwd,e));return{content:n,truncated:r}},[]):void 0,C=H.useCallback(()=>{if(t.taskStore.getState().editedFiles.length===0)return;let e=F();if(!e)return;let n=`/pane/edited-files`;e.currentPath===n||e.currentPath.startsWith(n+`/`)?e.navigate(`/`,{reset:!0}):e.navigate(n,{replace:!0})},[]),w=H.useCallback(()=>{if(t.taskStore.getState().subagentsAccum.size===0)return;let e=F();e&&(e.currentPath===`/pane/subagents`?e.navigate(`/`,{reset:!0}):e.navigate(`/pane/subagents`,{replace:!0}))},[]),ee=H.useCallback(()=>{if(t.taskStore.getState().scheduleTasks.length===0)return;let e=F();e&&(e.currentPath===`/pane/schedule`?e.navigate(`/`,{reset:!0}):e.navigate(`/pane/schedule`,{replace:!0}))},[]),T=H.useCallback(e=>{let t=F();if(!t)return;let n=`/pane/draft`,r=t.currentPath===n||t.currentPath.startsWith(n+`/`),i=e??!r;i&&!r?t.navigate(n,{replace:!0}):!i&&r&&t.navigate(`/`,{reset:!0})},[]),te=H.useCallback(e=>{let t=F();if(!t)return;let n=`/pane/queue`,r=t.currentPath===n||t.currentPath.startsWith(n+`/`),i=e??!r;i&&!r?t.navigate(n,{replace:!0}):!i&&r&&t.navigate(`/`,{reset:!0})},[]),ne=H.useCallback(()=>{let e=F();if(!e)return;let t=`/pane/prompts`;e.currentPath===t||e.currentPath.startsWith(t+`/`)?Tu():e.navigate(t,{replace:!0})},[]),re=H.useCallback(e=>{t.opts.onDraftSave?.(e)},[]),ie=H.useCallback(e=>{let n=t.taskStore.getState().drafts[e];n&&t.opts.onDraftDelete?.(n.id)},[]),E=H.useCallback(e=>{t.opts.onDraftDeleteMany?.(e)},[]),ae=H.useCallback(e=>{t.taskStore.setState({queued:t.taskStore.getState().queued.filter((t,n)=>n!==e)}),t.notify()},[]),oe=H.useCallback((e,n)=>{let r=e,i=e+n;if(i<0||i>=t.taskStore.getState().queued.length||r<0||r>=t.taskStore.getState().queued.length)return;let a=[...t.taskStore.getState().queued],[o]=a.splice(r,1);o&&a.splice(i,0,o),t.taskStore.setState({queued:a}),t.notify()},[]),D=H.useCallback((e,n)=>{let r=t.taskStore.getState().queued;if(e<0||e>=r.length)return;let i=[...r],a=i[e];a&&(i[e]={...a,text:n}),t.taskStore.setState({queued:i}),t.notify()},[]),se=H.useCallback((e,n)=>{let r=t.taskStore.getState().queued;if(e<0||e>=r.length)return;let i=r[e].mode;t.taskStore.setState({queued:r.filter((t,n)=>n!==e)}),t.notify(),t.opts.onQueueSendNow?.(n,i)},[]),O=H.useCallback(e=>{let n=t.notificationStore.getState().errorRetry;n&&(t.notificationStore.setState({errorRetry:{...n,focusIndex:e}}),t.notify())},[]),k=H.useCallback(e=>{let n=t.notificationStore.getState().pulseSurvey;n&&(t.notificationStore.setState({pulseSurvey:{...n,...e}}),t.notify())},[]),A=H.useCallback(()=>{if(t.taskStore.getState().backgroundTasks.length===0)return;let e=F();if(!e)return;let n=`/pane/delegates`;e.currentPath===n||e.currentPath.startsWith(n+`/`)?(e.navigate(`/`,{reset:!0}),t.taskStore.setState({backgroundOutput:null}),t.flushScrollbackIfIdle()):e.navigate(n,{replace:!0})},[]),ce=H.useCallback(()=>{t.state.shellTimer&&clearTimeout(t.state.shellTimer),t.taskStore.setState({shellExecution:null}),t.state.shellTimer=null,F()?.currentPath===`/pane/shell`&&F()?.goBack(),t.notify()},[]),j=H.useCallback(()=>{let e=t.taskStore.getState().shellExecution;e&&(pr(e.output),y(V.t(`shell.copiedTitle`),V.t(`shell.copiedBody`)))},[]);return H.useEffect(()=>{let e=null,n=()=>{e&&clearTimeout(e),e=setTimeout(()=>{let e=t.opts.columns||(t.stdout.columns>0?t.stdout.columns:process.stdout.columns>0?process.stdout.columns:80),n=t.opts.rows||(t.stdout.rows>0?t.stdout.rows:process.stdout.rows>0?process.stdout.rows:24);(e!==t.columnsRef.current||n!==t.rowsRef.current)&&(t.columnsRef.current=e,t.rowsRef.current=n,t.notify())},100)};return t.stdout.on(`resize`,n),()=>{e&&clearTimeout(e),t.stdout.off(`resize`,n)}},[]),H.createElement(Jg,{columns:t.columnsRef.current,rows:t.rowsRef.current,registerWrite:t.scrollbackMode?x:void 0,maxPreviewRows:t.scrollbackMode?1:void 0,hasHistory:t.hasHistoryRef.current,messages:t.messageStore.getState().messages,scrollStore:t.scrollStore,loadHistory:t.opts.loadHistory,messageStore:t.messageStoreHandle,windowMode:t.windowMode,scrollbackMode:t.scrollbackMode,shadow:t.opts.shadow??!1,language:t.languageRef.current,systemTheme:t.systemTheme,themeRegistry:t.themeRegistry,presetSelection:t.presetSelection,keybindingOverrides:t.opts.keybindingOverrides,onCyclePermissionMode:t.opts.onCyclePermissionMode,pluginInput:t.opts.pluginInput,readFileContent:S,getTurnMessages:t.getTurnMessagesFor,editedFilesOpen:!1,onToggleEditedFiles:C,subagentsOpen:!1,onToggleSubagents:w,onToggleSchedule:ee,initialHistory:t.opts.initialHistory,externalHistoryCommands:t.opts.externalHistoryCommands,onHistoryPush:t.opts.onHistoryPush,residencyGovernor:t.opts.residencyGovernor,resolveWholeFileDiff:t.opts.resolveWholeFileDiff,restoreInputRef:t.restoreInputRef,pasteBridgeRef:t.pasteBridgeRef,shiftEnterRef:t.shiftEnterRef,scheduleOpen:!1,draftOpen:!1,onToggleDraftPane:T,onDraftSave:re,onDraftDelete:ie,onDraftDeleteMany:E,onSigilSelect:t.opts.onSigilSelect,queueOpen:!1,onToggleQueuePane:te,onTogglePrompts:ne,onQueueDelete:ae,onQueueMove:oe,onQueueEditText:D,onQueueSendNow:se,pendingEcho:t.taskStore.getState().pendingEcho,onErrorRetryFocusChange:O,onPulseSurveyChange:k,backgroundTasksOpen:!1,onToggleDelegates:A,onBackgroundClose:r,onBackgroundKill:t.opts.onBackgroundKill,onBackgroundViewOutput:t.opts.onBackgroundViewOutput,onBackgroundOutputClose:i,onBackgroundApply:t.opts.onBackgroundApply,onBackgroundSwitch:t.opts.onBackgroundSwitch,onBackgroundDelete:t.opts.onBackgroundDelete,onExitSubagentContext:a,onPaneOwnsViewportChange:t.scrollbackMode?t.setPaneOwnsViewport:void 0,onFocusOwnerChange:t.scrollbackMode?t.setFocusOwnerForBuffer:void 0,onScrollActiveChange:t.setScrollActive,onDelegateSupply:t.opts.onDelegateSupply,welcome:t.opts.welcome,promptSuggestions:t.opts.promptSuggestions,onSessionSelect:t.opts.onSessionSelect,onInstallCapability:t.opts.onInstallCapability,onDismissCapabilityRecommendations:t.opts.onDismissCapabilityRecommendations,budgetStore:t.budgetStore,contextStore:t.contextStore,notificationStore:t.notificationStoreHandle,perfStore:t.perfStore,statusStore:t.statusStore,onStatusDismiss:()=>{F()?.currentPath===`/pane/status`&&F()?.goBack()},cacheStore:t.cacheStore,onCacheDismiss:()=>{F()?.currentPath===`/pane/cache`&&F()?.goBack()},proxyStore:t.proxyStore,proxyOpen:!1,onProxyDismiss:()=>{F()?.goBack()},onProxyOpenModal:t.proxyOpenModal,onProxySubmitUrl:t.opts.onProxySubmitUrl,onProxyToggleEnabled:t.opts.onProxyToggleEnabled,onProxyClear:t.opts.onProxyClear,compactionLogStore:t.compactionLogStore,onCompactionLogDismiss:()=>{let e=F();e?.currentPath.startsWith(`/pane/compaction-log`)&&e.navigate(`/`,{reset:!0})},galleryStore:t.galleryStore,onGalleryDismiss:()=>{F()?.currentPath===`/pane/gallery`&&F()?.goBack()},streamStore:t.streamStoreHandle,taskStore:t.taskStoreHandle,initialPath:t.opts.initialPath,onStatusRefresh:t.opts.onStatusRefresh,onSubmit:t.submitOrQueue,onInterrupt:t.opts.onInterrupt,onWithdrawPending:t.opts.onWithdrawPending,onWithdrawSteer:t.opts.onWithdrawSteer,onPopQueued:o,onPermissionDecision:t.onPermissionDecision,onSelectResolve:t.onSelectResolve,onInputResolve:t.onInputResolve,onOnboardingResolve:t.onOnboardingResolve,onInputAction:t.onInputAction,onQuestionsResolve:t.onQuestionsResolve,onConfirmResolve:t.onConfirmResolve,onAlertResolve:t.onAlertResolve,onPromptResolve:t.onPromptResolve,onInfoDismiss:s,onMemoryDismiss:c,onKeybindingPanelDismiss:l,onShortcutsDialogDismiss:u,onViewDetails:d,onBackToContextPane:f,onContextDismiss:p,notificationsOpen:!1,onToggleNotifications:m,onDismissNotification:h,onCloseNotifications:g,onUpgrade:_,onCancelUpgrade:v,onToast:y,onDismissToast:b,registryRef:t.registryRef,shellBackendRef:t.shellBackendRef,shellExecution:t.taskStore.getState().shellExecution,onShellAbort:t.opts.onInterrupt,onShellDismiss:ce,onShellCopyOutput:j,onShellAskAi:t.opts.onShellAskAi,a2uiButtons:t.a2uiButtonsRef.current,onA2uiAction:t.a2uiActionRef.current})}function xv(){let e=Buffer.alloc(0);return t=>{let n=lt(t),r=e.length?Buffer.concat([e,n]):n;e=Buffer.alloc(0);let i=r.length;i>=2&&r[i-2]===27&&r[i-1]===91&&(e=Buffer.from(r.subarray(i-2)),i-=2);let a,o=[],s=0;for(;s<i;){if(r[s]===27&&r[s+1]===91&&(r[s+2]===73||r[s+2]===79)){a=r[s+2]===73,s+=3;continue}o.push(r[s]),s++}return{focused:a,rest:Buffer.from(o)}}}var Sv=class{pending=null;feed(e){let t=lt(e),n=this.pending?Buffer.concat([this.pending,t]):t;this.pending=null;let r=[],i=null,a=0;for(;a<n.length;){let e=n.indexOf(`\x1B]`,a,`latin1`);if(e<0){a<n.length&&r.push(n.slice(a));break}e>a&&r.push(n.slice(a,e));let t=n.indexOf(7,e),o=n.indexOf(`\x1B\\`,e,`latin1`),s=-1,c=0;if(t>=0&&(o<0||t<o)?(s=t,c=1):o>=0&&(s=o,c=2),s<0){let t=n.slice(e);t.length>64?r.push(t):this.pending=t;break}let l=Cv(n.slice(e,s).toString(`latin1`));l&&(i=l),a=s+c}return{keys:r.length>0?Buffer.concat(r):Buffer.alloc(0),osc11:i}}};function Cv(e){let t=e.match(/\]11;rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(!t)return null;let n=parseInt(t[1].slice(0,2),16),r=parseInt(t[2].slice(0,2),16),i=parseInt(t[3].slice(0,2),16);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(i)?null:{r:n,g:r,b:i}}function wv(e,t,n){return .2126*e+.7152*t+.0722*n<128?`dark`:`light`}function Tv(e){let t=!1;return n=>{let r=typeof n==`string`?n:n.toString(`latin1`),i=[],a=0;for(;a<r.length;){if(t){let e=r.indexOf(`\x1B[201~`,a);if(e>=0)i.push(r.slice(a,e+6)),t=!1,a=e+6;else{i.push(r.slice(a));break}continue}let n=r.indexOf(`\x1B[200~`,a);if(n>=0){i.push(r.slice(a,n+6)),t=!0,a=n+6;continue}let o=a;for(;o<r.length;){let t=r[o];if(t===`
|
|
112
112
|
`){o>a&&i.push(r.slice(a,o)),e.onShiftEnter(),o++,a=o;continue}if(t===`\x1B`){i.push(r.slice(a)),a=r.length;break}o++}o>=r.length&&a<r.length&&(i.push(r.slice(a)),a=r.length)}return Buffer.from(i.join(``),`latin1`)}}function Ev(e){let{stdin:t,renderStdout:n,onInterrupt:r,onFocusChange:i,onTerminalBgDetected:a,onMouseWheel:o,onMouseDrag:s,onShiftEnter:c}=e,l=[],u=process.env.OTTO_TUI_MOUSE===`0`,d=(typeof o==`function`||typeof s==`function`)&&!!t.isTTY,f=d&&!u,p=d?L_():null,m=f,h;if(f)try{n.write(j_)}catch{}d&&(h=()=>{try{n.write(M_)}catch{}},process.once(`exit`,h));let g=e=>{if(!d)return!1;if(e===m)return m;m=e;try{n.write(e?j_:M_)}catch{}return m},_=new Sv,v=e=>{if(!a)return lt(e);let{keys:t,osc11:n}=_.feed(e);return n&&a(wv(n.r,n.g,n.b)),t},y=e=>{if(!p)return v(e);let{wheels:t,drags:n,rest:r}=p(e);if(m){for(let e of t)o?.(e.delta);for(let e of n)s?.(e)}return v(r)},b=c?Tv({onShiftEnter:c}):null,x=e=>b?b(e):e,S=process.env.OTTO_TUI_KITTY===`1`&&!!t.isTTY,C,w=t;if(S){try{n.write(`\x1B[>1u`)}catch{}C=()=>{try{n.write(q_)}catch{}},process.once(`exit`,C);let e=Z_(),i=new zn;Object.assign(i,{isTTY:!0,setRawMode:e=>{try{t.setRawMode?.(e)}catch{}return i},ref:()=>{try{t.ref?.()}catch{}return i},unref:()=>{try{t.unref?.()}catch{}return i}});let a=t=>{let n=y(t);if(n.length===0)return;let a=x(e(n));a.includes(3)&&r?.(),i.write(a)};t.on(`data`,a),l.push({stream:t,fn:a});try{t.isTTY&&t.setRawMode(!0)}catch{}try{t.resume()}catch{}w=i}let ee=process.env.OTTO_TUI_FOCUS===`1`&&!!t.isTTY&&typeof i==`function`,T;if(ee){try{n.write(`\x1B[?1004h`)}catch{}T=()=>{try{n.write(`\x1B[?1004l`)}catch{}},process.once(`exit`,T);let e=w,t=xv(),r=new zn;Object.assign(r,{isTTY:!0,setRawMode:t=>{try{e.setRawMode?.(t)}catch{}return r},ref:()=>{try{e.ref?.()}catch{}return r},unref:()=>{try{e.unref?.()}catch{}return r}});let a=e=>{let n=y(e);if(n.length===0)return;let{focused:a,rest:o}=t(n);a!==void 0&&i?.(a),o.length&&r.write(x(o))};e.on(`data`,a),l.push({stream:e,fn:a});try{e.isTTY&&e.setRawMode(!0)}catch{}try{e.resume()}catch{}w=r}if(!S&&!ee&&(a||f||b)){let e=w,t=new zn;Object.assign(t,{isTTY:!0,setRawMode:n=>(e.setRawMode?.(n),t),ref:()=>(e.ref?.(),t),unref:()=>(e.unref?.(),t)});let n=e=>{let n=y(e);n.length>0&&t.write(x(n))};e.on(`data`,n),l.push({stream:e,fn:n});try{e.isTTY&&e.setRawMode(!0)}catch{}e.resume(),w=t}return{renderStdin:w,kittyOn:S,focusOn:ee,mouseOn:f,kittyExitHandler:C,focusExitHandler:T,mouseExitHandler:h,setMouseEnabled:g,isMouseEnabled:()=>m,cleanup:()=>{for(let{stream:e,fn:t}of l)e.removeListener(`data`,t);l.length=0}}}const Dv=12e3,Ov=hr();async function kv(t){let{stdin:n,stdout:r,onStop:i}=t,a=Kc(t.maxFps??30),o=t.renderMaxFps??90;Ua();let s=t.columns||(r.columns>0?r.columns:process.stdout.columns>0?process.stdout.columns:80),c=t.rows||(r.rows>0?r.rows:process.stdout.rows>0?process.stdout.rows:24),l=t.language&&t.language!==`auto`?t.language:Vt();Bt(l);let u=await Je(),d=t.themeRegistry,f=t.presetSelection,p=process.env.OTTO_TUI_SCOPED_VIEWPORT!==`0`,m=r_(r),h=()=>_t?.buffer.height||Math.max(1,c-1);process.once(`exit`,()=>m.exit());let g=t.scrollback===!0||process.env.OTTO_TUI_SCROLLBACK===`1`,_=t.scrollback===!1||process.env.OTTO_TUI_SCROLLBACK===`0`,v=!g&&!_,y=Sr()?xr(r):r;g&&!p&&(y=Tr(y));let b=e=>{y.write(e)},C=!1,w={current:null};y=new Proxy(y,{get(e,t,n){if(t===`write`)return(t,...n)=>(typeof t==`string`&&(t.includes(`\x1B[2J`)||t.includes(`\x1B[3J`))&&w.current?.(),e.write(t,...n));let r=Reflect.get(e,t,n);return typeof r==`function`?r.bind(e):r}});let{streamStoreHandle:ee,streamStore:T,notificationStoreHandle:te,notificationStore:ne,taskStoreHandle:re,taskStore:ie,messageStoreHandle:E,messageStore:ae,scrollStoreHandle:oe,budgetStore:D,contextStore:se,perfStore:O,statusStore:k,cacheStore:A,proxyStore:ce,compactionLogStore:j,galleryStore:le,completer:ue,shellBackendRef:de,a2uiButtonsRef:fe,a2uiActionRef:pe,scanA2uiButtons:me}=e_(t),he={toastTimer:null,listener:null,shellTimer:null},ge={current:null},ve={current:null},be={current:null},xe=process.env.OTTO_TUI_PANE_BUFFER!==`0`,M=`prompt`,Se=()=>xe&&(ie.getState().subagentContext!=null||ie.getState().backgroundOutput!=null||ie.getState().paneOwnsViewportFlag||M!==`prompt`),Ce=t_({paneOwnsViewport:Se,realWrite:e=>b(e)}),we=()=>{Se()||Ce.flush()},Te=e=>{let t=M===`prompt`;M=e,e===`prompt`&&!t&&we()},Ee=!0,De=e=>{Ee=e},Oe=e=>{ie.setState({paneOwnsViewportFlag:e}),e||we()},ke={msg:0,perm:0,toast:0,notify:0},Ae=new Map,je=new Map,Me={select:null,input:null,inputAction:null,questions:null,confirm:null,cancel:null,extra:null,alert:null,prompt:null,onboarding:null},Ne={current:null},N={current:null},Pe=(e=>N.current?N.current.openModal(e):e.kind===`input`?Promise.resolve(null):void 0),P=Yc({listener:()=>he.listener?.(),intervalMs:a}),Fe=()=>P.immediate();re.setNotify(Fe),te.setNotify(Fe);let{commitToHistory:Ie,commitManyToHistory:Le}=nv({scrollbackBuffer:Ce,getColumns:()=>s,getHasHistory:()=>C,setHasHistory:e=>{C=e},notify:Fe}),{streamTextCoalescer:Re,streamThinkingCoalescer:ze,outputTokensThrottle:Be,resetController:Ve}=ev({streamStore:T,messageStore:ae,messageStoreHandle:E,scrollbackBuffer:Ce,scrollbackMode:g,coalesceMs:a,getColumns:()=>s,getHasHistory:()=>C,setHasHistory:e=>{C=e},getMsgCounter:()=>ke.msg,incMsgCounter:()=>++ke.msg,notify:Fe}),He=()=>ha(ma(fa(t.isAgentBusy,T.getState().processing),!!ne.getState().errorRetry),!!t.isPaused?.()),Ue=(e,n,r)=>{let i=ga(e,n,r??!1,{processing:He(),isImmediateCommand:e=>t.isImmediateCommand?.(e)??!1,isInterruptCommand:e=>t.isInterruptCommand?.(e)??!1});if(i===`queue`){ie.setState({queued:[...ie.getState().queued,{text:e,mode:n}]}),Fe();return}if(i===`action`){t.onSubmit?.(e,n,`action`);return}t.onSubmit?.(e,n,i===`steer`?`steer`:`send`)},We=yv(he,He,Fe,t.onSubmit,ie);re.setEffects({syncForcedUpgradeRoute:t=>e(F(),_e,t),backgroundOutputRoute:e=>{e?F()?.ensure(`/pane/delegates/output`):F()?.currentPath===`/pane/delegates/output`&&F()?.goBack()},flushScrollbackIfIdle:we,registerStatusItems:e=>os(`cli-status`,{pluginId:`cli-status`,statusItems:[...e]})}),te.setEffects({drainQueueOnResume:()=>We(),syncPulseSurveyRoute:t=>e(F(),x,t)});let{onPermissionDecision:Ge,onSelectResolve:Ke,onInputResolve:qe,onOnboardingResolve:Ye,onInputAction:I,onQuestionsResolve:L,onConfirmResolve:Xe,onAlertResolve:Ze,onPromptResolve:Qe,getTurnMessagesFor:$e}=vv({getMessages:()=>ae.getState().messages},je,Me,ie,Oe),et={shiftEnterRef:ve,state:he,columnsRef:{get current(){return s},set current(e){s=e}},rowsRef:{get current(){return c},set current(e){c=e}},hasHistoryRef:{get current(){return C},set current(e){C=e}},inkWriteRef:{get current(){return b},set current(e){b=e}},toastCounterRef:{get current(){return ke.toast},set current(e){ke.toast=e}},languageRef:{get current(){return l},set current(e){l=e}},systemTheme:u,themeRegistry:d,presetSelection:f,stopRef:{},taskStore:ie,notificationStore:ne,messageStore:ae,streamStoreHandle:ee,taskStoreHandle:re,notificationStoreHandle:te,messageStoreHandle:E,budgetStore:D,contextStore:se,perfStore:O,statusStore:k,cacheStore:A,proxyStore:ce,compactionLogStore:j,galleryStore:le,opts:t,notify:Fe,flushScrollbackIfIdle:we,setPaneOwnsViewport:Oe,setFocusOwnerForBuffer:Te,setScrollActive:De,getTurnMessagesFor:$e,submitOrQueue:Ue,onPermissionDecision:Ge,onSelectResolve:Ke,onInputResolve:qe,onOnboardingResolve:Ye,onInputAction:I,onQuestionsResolve:L,onConfirmResolve:Xe,onAlertResolve:Ze,onPromptResolve:Qe,proxyOpenModal:Pe,restoreInputRef:ge,pasteBridgeRef:be,registryRef:Ne,shellBackendRef:de,a2uiButtonsRef:fe,a2uiActionRef:pe,scrollbackMode:g,windowMode:v,scrollStore:oe,stdout:r},tt=()=>bv(et),nt=_v({stdout:y,enabled:!0}),rt=R_(e=>{oe.dispatchWheel(e)||wu(M)&&Ee&&oe.scrollBy(e*3)}),R={current:null},it=0;Lu(oe.store,()=>R.current?.clear());let{renderStdin:at,kittyOn:ot,focusOn:st,mouseOn:ct,kittyExitHandler:lt,focusExitHandler:ut,mouseExitHandler:dt,setMouseEnabled:ft,isMouseEnabled:pt,cleanup:ht}=Ev({stdin:n,renderStdout:y,onInterrupt:t.onInterrupt,onFocusChange:t.onFocusChange,onMouseWheel:e=>rt.push(e),onShiftEnter:()=>ve.current?.(),onMouseDrag:e=>{R.current?.handleDrag(e)},onTerminalBgDetected:e=>{process.env.OTTO_DEBUG_THEME&&process.stderr.write(`[RFC-282] OSC detected: ${e} themeRef=${!!Tt()}\n`),Tt()?.setSystemTheme(e)}}),gt=t.concurrent??process.env.OTTO_TUI_CONCURRENT===`1`;p&&m.enter();let _t=await v_(y,process.env,{anchorMode:p?`anchored`:`flowing`});_t?.buffer.setMaxLineWidth(s),w.current=_t?()=>_t.buffer.resync():null,_t&&(R.current=k_({buffer:_t.buffer,terminalRows:()=>h(),writeSelectionRepaint:e=>{if(e)try{y.write(e)}catch{}},writeClipboard:e=>{let t=K_(e),n=!1;try{pr(e),n=!0}catch{n=!1}return t||n&&!Ov},onCopied:(e,t)=>{let n=A_(e);if(t){it+=1;let t=it;ie.setState({clipboardChars:n,clipboardText:e,clipboardFailed:!1,clipboardJustCopied:!0}),setTimeout(()=>{ie.getState().clipboardChars===n&&ie.setState({clipboardChars:0})},Dv),setTimeout(()=>{it===t&&ie.setState({clipboardJustCopied:!1})},1500)}else{let e=process.platform===`linux`&&G_()?.outcome===`missing`&&Ov;ie.setState({clipboardFailed:!0,clipboardChars:0,clipboardFailedReason:e?`tool-missing`:`native-hint`}),setTimeout(()=>{ie.getState().clipboardFailed&&ie.setState({clipboardFailed:!1,clipboardFailedReason:void 0})},Dv)}}}),Pu(R.current),_t.onDamage(e=>{R.current?.onFrameDamage(e)}));let{waitUntilExit:vt,unmount:yt}=en(H.createElement(tt),{stdout:y,stdin:at,exitOnCtrlC:!1,maxFps:o,concurrent:gt,patchConsole:!1});gt&&await new Promise(e=>{let t=Date.now()+1e3,n=()=>{he.listener||Date.now()>t?e():setImmediate(n)};n()});let bt=Q_({stdin:n,stdout:r,renderStdout:y,kittyOn:ot,kittyExitHandler:lt,focusOn:st,focusExitHandler:ut,mouseOn:ct,mouseExitHandler:dt,onInterrupt:t.onInterrupt,unmount:()=>yt(),terminalInputCleanup:ht});bt.setupRawInput(),nt.start();let xt=()=>{nt.pollNow();let e=r.columns>0?r.columns:s;_t?.buffer.setMaxLineWidth(e),_t?.buffer.resync()};r.on(`resize`,xt),process.once(`exit`,()=>{r.removeListener(`resize`,xt),nt.stop();try{n.pause?.()}catch{}try{n.setRawMode?.(!1)}catch{}});let St={stopped:!1,unmounted:!1},Ct=!1,wt=async()=>{if(Ct)return;Ct=!0;let e=e=>{try{e()}catch{}};e(()=>nt.stop()),e(()=>r.removeListener(`resize`,xt)),e(()=>bt.cleanup()),e(()=>{try{n.isTTY&&n.setRawMode(!0)}catch{}}),e(()=>_t?.dispose()),e(()=>{m.active()||r.write(n_(h()))}),e(()=>{r.write(`\x1B[?25h`)}),e(()=>m.exit()),await new Promise(e=>setTimeout(e,200));try{bt.releaseStdin()}catch{}},z=rv({taskStore:ie,notificationStore:ne,cacheStore:A,proxyStore:ce,resolvers:Me,getNotifyStats:()=>P.getStats(),flushScrollbackIfIdle:we,paneOwnsViewport:Se,setPaneOwnsViewport:Oe});N.current=z;let Et=iv({taskStore:ie,state:he,notify:Fe,showToast:(...e)=>Ft.info.showToast(...e)}),Dt=av({notificationStore:ne,state:he,counters:ke,notify:Fe}),B=lv({pendingMethods:ov({taskStore:ie,messageStoreHandle:E,counters:ke,pendingSteerMsgIds:Ae,scrollbackMode:g,commitToHistory:Ie,scanA2uiButtons:me,notify:Fe}),restoreInputRef:ge,pasteBridgeRef:be}),Ot=dv({messageStoreHandle:E,notify:Fe}),kt=uv({lifecycleFlags:St,scrollbackBuffer:Ce,streamTextCoalescer:Re,streamThinkingCoalescer:ze,notifyScheduler:P,state:he,registryUnregisterAll:cs,unmount:yt,windowMode:v,scopedViewport:p,hasHistoryRef:{set:e=>{C=e}},resetStreamController:Ve,messageStoreHandle:E,scrollStoreHandle:oe,streamStoreHandle:ee,taskStoreHandle:re,notificationStoreHandle:te,perfStore:O,statusStore:k,contextStore:se,budgetStore:D,taskStore:ie,notificationStore:ne,a2uiButtonsRef:fe,resetStatusWidgetBreakers:Wu,getRouterRef:F,overlayPaths:S,syncOverlayRoute:e,notify:Fe,i18next:V,detectLanguage:Vt,setLanguage:e=>{l=e},getThemeRef:Tt,setTerminalTitle:lr,onStop:i,detachSessionSource:Ot.detachSessionSource,teardownTerminal:wt}),At=mv({modalHandleMethods:z,taskStore:ie,getRouterRef:F,syncOverlayRoute:e,overlayServices:ye,flushScrollbackIfIdle:we,notify:Fe}),jt=hv({taskStore:ie,taskStoreHandle:re,registerPlugin:os,registryUnregister:ss,computeStalePluginIds:ds,getRegistrySnapshot:ls,getStatusItems:ps,getStatusWidgets:hs,resetStatusWidgetBreakers:Wu,registryRef:Ne,a2uiButtonsRef:fe,subagentRestoreFields:Ho,notify:Fe}),Mt=gv({notificationMethods:Dt,notifyScheduler:P,taskStore:ie,modalHandleMethods:z,shellMethods:Et,contextStore:se,getRouterRef:F,scrollStoreHandle:oe}),Nt=pv({streamMethods:sv({streamStore:T,streamTextCoalescer:Re,streamThinkingCoalescer:ze,outputTokensThrottle:Be,perfStore:O,statusStore:k,compactionLogStore:j,drainQueue:We,getRouterRef:F,notify:Fe}),taskStore:ie,notificationStore:ne,notificationMethods:Dt,getRouterRef:F,syncOverlayRoute:e,overlayPause:mt,drainQueue:We,notify:Fe}),Pt=fv({scrollbackMode:g,commitToHistory:Ie,commitManyToHistory:Le,messageStoreHandle:E,counters:ke,getTurnMessagesFor:$e,taskStore:ie,notify:Fe,scanA2uiButtons:me}),Ft={modal:cv({modalHandleMethods:z,permResolvers:je,counters:ke,taskStore:ie,getRouterRef:F,notify:Fe,onConfirmResolve:Xe}),pending:B,lifecycle:{...kt,...Ot,toggleMouse:()=>{let e=ft(!pt());return Ft.info.showToast(V.t(`mouse.toggleTitle`),e?V.t(`mouse.enabledBody`,{modifier:If()}):V.t(`mouse.disabledBody`)),e}},messages:Pt,engine:Nt,panes:At,plugins:jt,info:Mt,shell:Et,stores:{tasks:re.actions,budget:{setBudget:D.setBudget},context:{setBudget:se.setBudget,addTurn:se.addTurn,markTurns:se.markTurns},cache:{setView:A.setView},proxy:{setView:ce.setView},notification:{setProviderUsage:te.setProviderUsage,setPausePending:te.setPausePending,setPaused:te.setPaused,setPulseSurvey:te.setPulseSurvey}}};return et.stopRef.current=()=>Ft.lifecycle.stop(),vt().then(()=>{St.unmounted||(St.unmounted=!0,yt()),wt()}),Ft}function Av(){return{streamBuf:``,thinkBuf:``,turnStart:0,turnToolCount:0,lastTasks:[],messageIndex:0}}function jv(e,t){let n=[];e.forEach((e,t)=>{e?.role===`user`&&n.push(t)});let r=n.length,i=Math.max(t,r);if(r===0||i<=1)return[];let a=n[0],o=Array(i-1).fill(a);for(let e=0;e<r;e++){let t=i-r-1+e;t>=0&&t<o.length&&(o[t]=n[e])}return o}function Mv(e){return e.filter(e=>e.status!==`done`&&e.status!==`skipped`&&e.status!==`failed`).length}function Nv(e,t,n){if(t.length===0)return[...e];let r=[];e.forEach((e,t)=>{e?.role===`user`&&r.push(t)});let i=r.length,a=Math.max(n,i);if(i===0||a<=0)return[...e];let o=a-i+1,s=new Map;for(let e of t)s.set(e.turn,e);let c=new Map;for(let t of s.values()){if(t.turn<o||t.turn>a)continue;let n=t.turn-o,s=n+1<i?r[n+1]:e.length,{turn:l,...u}=t,d={role:`summary`,...u},f=c.get(s);f?f.push(d):c.set(s,[d])}if(c.size===0)return[...e];let l=[];for(let t=0;t<e.length;t++){l.push(e[t]);let n=c.get(t+1);n&&l.push(...n)}return l}function Pv(e,t){let n=Mv(t.lastTasks),r=e.stopReason??`completed`,i=r===`error`?`error`:r===`interrupted`?`interrupted`:n>0?`incomplete`:`done`,a={toolCount:t.turnToolCount,elapsedMs:t.turnStart>0?performance.now()-t.turnStart:0,tokensUsed:e.tokens??void 0,model:e.model||void 0,effort:e.effort||void 0,cacheHitRatio:e.cacheHitRatio??void 0,errorMessage:e.errorMessage};return i===`incomplete`?{...a,status:i,tasksDone:t.lastTasks.length-n,tasksTotal:t.lastTasks.length}:{...a,status:i}}function Fv(e,t,n){let r=()=>{n.thinkBuf.trim()&&(t.pushMessage({role:`assistant`,content:[{type:`thinking`,thinking:n.thinkBuf}]}),n.messageIndex++),n.thinkBuf=``,t.pushEngineEvent({kind:`streamingThinking`,text:``})};switch(e.kind){case`prompt.start`:n.turnStart=performance.now(),n.turnToolCount=0,t.addTurnBoundary?.(n.messageIndex);return;case`prompt.end`:{n.thinkBuf.trim()&&(t.pushMessage({role:`assistant`,content:[{type:`thinking`,thinking:n.thinkBuf}]}),n.messageIndex++),n.streamBuf=``,n.thinkBuf=``,t.pushEngineEvent({kind:`streamingText`,text:``}),t.pushEngineEvent({kind:`streamingThinking`,text:``});let r={role:`summary`,...Pv(e,n)};t.pushMessage(r),n.messageIndex++;return}case`stream.text.delta`:n.streamBuf+=e.delta,t.pushEngineEvent({kind:`streamingText`,text:n.streamBuf});return;case`stream.thinking.delta`:n.thinkBuf+=e.delta,t.pushEngineEvent({kind:`streamingThinking`,text:n.thinkBuf});return;case`stream.text.start`:r(),n.streamBuf=``;return;case`stream.text.end`:t.pushEngineEvent({kind:`streamingText`,text:``}),n.streamBuf=``;return;case`stream.thinking.start`:n.thinkBuf=``;return;case`stream.thinking.end`:r();return;case`tool.start`:t.pushEngineEvent({kind:`activeTool`,name:e.call.name});return;case`tool.end`:{if(t.pushEngineEvent({kind:`activeTool`,name:null}),n.turnToolCount++,e.suppressMessage)return;let r=e.call.arguments??{},i=r,a=i.command??i.path??i.file_path??i.pattern??i.query??JSON.stringify(r);t.pushMessage({role:`tool`,name:e.call.name,args:typeof a==`string`?a:JSON.stringify(a),argsObj:r,result:e.resultText,isError:e.isError}),n.messageIndex++;return}case`tasks.update`:n.lastTasks=e.tasks,t.setTasks(e.tasks,e.title);return;case`turn.budget`:t.pushEngineEvent({kind:`toolBudget`,toolTurnCount:e.toolTurnCount,maxToolTurns:e.maxToolTurns,outputTokens:e.outputTokens,outputTokenBudget:e.outputTokenBudget});return;case`delegate.update`:return}}function Iv(e,t={}){for(let t of e){let e=t.role??`unknown`,n=t.content??[],r=Array.isArray(n)?n.filter(e=>e.type===`text`).map(e=>String(e.text??``)).join(`
|
|
113
|
-
`):String(n);if(e===`user`)process.stdout.write(`\x1b[34m▸ ${r}\x1b[0m\n`);else if(e===`assistant`){process.stdout.write(`${r}\n`);let e=t.tool_calls??[];for(let t of e){let e=t.function;process.stdout.write(`\x1b[33m ⚙ ${e?.name??`unknown`}\x1b[0m\n`)}}else e===`system`?process.stdout.write(`\x1b[2m${r}\x1b[0m\n`):process.stdout.write(`${r}\n`)}}function Lv(e,t){return{search:n=>hn(e,n,t)}}function Rv(e){let{transport:t,sessionId:n,onSessionEvent:r,hydrateMessages:i,onGap:a}=e;return{async start(e){let o=null,s=!1,c=!1,l=0,u=1,d=new Map,f=e=>{s||(o?.(),l=e,u=e+1,d.clear(),o=t.subscribe(n,e,e=>{if(!(s||e.seq<u||d.has(e.seq)))for(d.set(e.seq,e);d.has(u);){let e=d.get(u);d.delete(u),r(e),l=u,u+=1}},e=>{s||c||(a(e),p())}))},p=async()=>{if(!c){c=!0;try{let r=await t.fetchSnapshot(n);if(s)return;i(e,r.session.messages),f(r.cursor)}catch{a({reason:`gap`,oldestAvailable:l})}finally{c=!1}}};try{let r=await t.fetchSnapshot(n);if(s)return()=>{};i(e,r.session.messages),f(r.cursor)}catch(e){throw s=!0,e}return()=>{s=!0,o?.(),o=null}}}}function zv(e){let t=Av();return{handle(n){Fv(n.payload,e,t)},reset(e=0){t={...Av(),messageIndex:e}}}}function Bv(e){return{pushMessage:e.pushMessage,echoUserInput:e.echoUserInput,pushEngineEvent:e.pushEngineEvent,getNotifyStats:e.getNotifyStats,setTasks:e.setTasks,addTurnBoundary:e.addTurnBoundary}}export{ca as ACTION_CHIP_PATTERN,la as ACTION_CHIP_VALUE_SEGMENT,iu as AlertDialog,Jg as App,_i as BASH_HISTFILE_SOURCE,ru as BashPermissionDialog,nr as BracketedPasteHandler,P as Button,jo as COMPACTING_SENTINEL,Ht as CommandRegistry,et as ConfirmDialog,jt as Cursor,si as DEFAULT_SENSITIVE_PATTERNS,Ge as DIALOG_BORDER,ct as DataList,B as FIGURES,xi as FISH_HISTFILE_SOURCE,Ae as GroupDivider,of as Home,ft as LAYOUT,fe as MeasuredText,Gl as MemoryDialog,nl as Message,Ei as OTTO_SESSION_SOURCE,Qe as PALETTE,He as PANEL_BORDER,$l as PermissionDialogDialog,au as PromptDialog,Ki as PromptInput,qi as QueuedCommands,Ll as REPLRegion,R as SPACING,r as STATUS,qc as STREAM_COALESCE_MS,T as ScrollIndicatorAbove,ne as ScrollIndicatorBelow,$p as Segmented,$p as Tabs,z as Select,Hc as SigilPane,Ol as Spinner,L as THEME,Zg as TabScope,v as Tabable,Et as TextInput,Fe as ThemeRegistry,li as ZSH_HISTFILE_SOURCE,wn as applySigilCompletion,Ur as applySlashCompletion,gr as beginSyncFrame,Pv as buildTurnSummary,vs as clearPluginRenderers,Qc as collapseMessages,Rv as createAttachSessionDataSource,ed as createBudgetStore,Ut as createBuiltinCommands,ze as createBuiltinThemeRegistry,zr as createCommandRegistry,Lv as createIncrementalSearcher,Er as createInputBuffer,Or as createInputHistory,Ni as createMergedHistoryProvider,Rr as createPasteStore,Xc as createQueryGuard,Av as createReducerState,dt as createSelectState,zv as createSessionEventReduceBridge,Bv as createStoreTuiSink,Ze as cycleIndex,jv as deriveTurnBoundaries,Vt as detectLanguage,j as displayWidth,pa as effectiveBusy,_r as endSyncFrame,Mi as entriesToCommands,el as expandCollapsed,Dn as extractSigilPrefix,Br as extractSlashPrefix,Yo as formatAgentDiagnosticsText,Ul as formatKeyValueLines,Jn as formatProviderUsageLimitTypeFull,Hl as formatTranscriptText,qo as formatTurnTimeline,Vr as getCommandSuggestions,Ue as getInputViewport,Ee as getKillRingEntries,Qa as getMarkdownThemeUserOverrides,Tr as guardScrollbackStdout,Ot as handleEditingKey,Lt as handleEditingKeyExtended,V as i18next,Bt as initI18n,Wc as initStreamCommit,c as insertHistory,At as insertHistorySequence,Nv as insertTurnSummaries,ua as isPureActionChip,ci as isSensitiveCommand,Xn as isUsingOverage,Jc as makeCoalescer,Yc as makeNotifyScheduler,fn as matchSubsequence,Oi as mergeHistoryEntries,Hr as navigateSuggestions,gi as normalizeCommand,Uo as observationLiveFields,Go as observationRow,mr as osc52QuerySequence,pr as osc52Write,fr as osc8FilePath,dr as osc8Hyperlink,vi as parseBashHistory,or as parseExtendedKey,Si as parseFishHistory,pi as parseZshHistory,de as pickInsertMode,mn as positionsToHighlightRanges,m as preWrapLine,d as preWrapLineHanging,ae as preWrapLines,Iv as printMessages,Gn as promptParentWorkspaceChoice,Hn as promptWorkspaceTrust,hn as rankCandidates,gn as rankLabeledItems,_n as rankNamedItems,Fv as reduceToTui,_s as registerPluginRenderers,ro as renderInline,vo as renderMarkdownToLines,yc as renderMessageLines,Me as resetKillRing,n as resolveHorizontalStep,ga as routeSubmit,Uc as safeCommitBoundary,yn as scoreSubsequence,Za as setMarkdownThemeUserOverrides,da as shouldPreserveDraft,Sr as shouldStripSyncOutput,le as shouldUseViewport,Wt as showCommandPalette,sa as slashCommandName,kv as startTui,Gc as streamCommitStep,$e as stringWidth,wr as stripScrollbackClear,br as stripSyncSequences,xr as stripSyncStdout,Vo as subagentEntryStatus,Ho as subagentRestoreFields,zt as t,$c as toggleCollapse,Z as useAppState,Xg as useTabScope,ht as useTabable,vr as withSyncFrame};
|
|
114
|
-
//# sourceMappingURL=index.js.map
|
|
113
|
+
`):String(n);if(e===`user`)process.stdout.write(`\x1b[34m▸ ${r}\x1b[0m\n`);else if(e===`assistant`){process.stdout.write(`${r}\n`);let e=t.tool_calls??[];for(let t of e){let e=t.function;process.stdout.write(`\x1b[33m ⚙ ${e?.name??`unknown`}\x1b[0m\n`)}}else e===`system`?process.stdout.write(`\x1b[2m${r}\x1b[0m\n`):process.stdout.write(`${r}\n`)}}function Lv(e,t){return{search:n=>hn(e,n,t)}}function Rv(e){let{transport:t,sessionId:n,onSessionEvent:r,hydrateMessages:i,onGap:a}=e;return{async start(e){let o=null,s=!1,c=!1,l=0,u=1,d=new Map,f=e=>{s||(o?.(),l=e,u=e+1,d.clear(),o=t.subscribe(n,e,e=>{if(!(s||e.seq<u||d.has(e.seq)))for(d.set(e.seq,e);d.has(u);){let e=d.get(u);d.delete(u),r(e),l=u,u+=1}},e=>{s||c||(a(e),p())}))},p=async()=>{if(!c){c=!0;try{let r=await t.fetchSnapshot(n);if(s)return;i(e,r.session.messages),f(r.cursor)}catch{a({reason:`gap`,oldestAvailable:l})}finally{c=!1}}};try{let r=await t.fetchSnapshot(n);if(s)return()=>{};i(e,r.session.messages),f(r.cursor)}catch(e){throw s=!0,e}return()=>{s=!0,o?.(),o=null}}}}function zv(e){let t=Av();return{handle(n){Fv(n.payload,e,t)},reset(e=0){t={...Av(),messageIndex:e}}}}function Bv(e){return{pushMessage:e.pushMessage,echoUserInput:e.echoUserInput,pushEngineEvent:e.pushEngineEvent,getNotifyStats:e.getNotifyStats,setTasks:e.setTasks,addTurnBoundary:e.addTurnBoundary}}export{ca as ACTION_CHIP_PATTERN,la as ACTION_CHIP_VALUE_SEGMENT,iu as AlertDialog,Jg as App,_i as BASH_HISTFILE_SOURCE,ru as BashPermissionDialog,nr as BracketedPasteHandler,P as Button,jo as COMPACTING_SENTINEL,Ht as CommandRegistry,et as ConfirmDialog,jt as Cursor,si as DEFAULT_SENSITIVE_PATTERNS,Ge as DIALOG_BORDER,ct as DataList,B as FIGURES,xi as FISH_HISTFILE_SOURCE,Ae as GroupDivider,of as Home,ft as LAYOUT,fe as MeasuredText,Gl as MemoryDialog,nl as Message,Ei as OTTO_SESSION_SOURCE,Qe as PALETTE,He as PANEL_BORDER,$l as PermissionDialogDialog,au as PromptDialog,Ki as PromptInput,qi as QueuedCommands,Ll as REPLRegion,R as SPACING,r as STATUS,qc as STREAM_COALESCE_MS,T as ScrollIndicatorAbove,ne as ScrollIndicatorBelow,$p as Segmented,$p as Tabs,z as Select,Hc as SigilPane,Ol as Spinner,L as THEME,Zg as TabScope,v as Tabable,Et as TextInput,Fe as ThemeRegistry,li as ZSH_HISTFILE_SOURCE,wn as applySigilCompletion,Ur as applySlashCompletion,gr as beginSyncFrame,Pv as buildTurnSummary,vs as clearPluginRenderers,Qc as collapseMessages,Rv as createAttachSessionDataSource,ed as createBudgetStore,Ut as createBuiltinCommands,ze as createBuiltinThemeRegistry,zr as createCommandRegistry,Lv as createIncrementalSearcher,Er as createInputBuffer,Or as createInputHistory,Ni as createMergedHistoryProvider,Rr as createPasteStore,Xc as createQueryGuard,Av as createReducerState,dt as createSelectState,zv as createSessionEventReduceBridge,Bv as createStoreTuiSink,Ze as cycleIndex,jv as deriveTurnBoundaries,Vt as detectLanguage,j as displayWidth,pa as effectiveBusy,_r as endSyncFrame,Mi as entriesToCommands,el as expandCollapsed,Dn as extractSigilPrefix,Br as extractSlashPrefix,Yo as formatAgentDiagnosticsText,Ul as formatKeyValueLines,Jn as formatProviderUsageLimitTypeFull,Hl as formatTranscriptText,qo as formatTurnTimeline,Vr as getCommandSuggestions,Ue as getInputViewport,Ee as getKillRingEntries,Qa as getMarkdownThemeUserOverrides,Tr as guardScrollbackStdout,Ot as handleEditingKey,Lt as handleEditingKeyExtended,V as i18next,Bt as initI18n,Wc as initStreamCommit,c as insertHistory,At as insertHistorySequence,Nv as insertTurnSummaries,ua as isPureActionChip,ci as isSensitiveCommand,Xn as isUsingOverage,Jc as makeCoalescer,Yc as makeNotifyScheduler,fn as matchSubsequence,Oi as mergeHistoryEntries,Hr as navigateSuggestions,gi as normalizeCommand,Uo as observationLiveFields,Go as observationRow,mr as osc52QuerySequence,pr as osc52Write,fr as osc8FilePath,dr as osc8Hyperlink,vi as parseBashHistory,or as parseExtendedKey,Si as parseFishHistory,pi as parseZshHistory,de as pickInsertMode,mn as positionsToHighlightRanges,m as preWrapLine,d as preWrapLineHanging,ae as preWrapLines,Iv as printMessages,Gn as promptParentWorkspaceChoice,Hn as promptWorkspaceTrust,hn as rankCandidates,gn as rankLabeledItems,_n as rankNamedItems,Fv as reduceToTui,_s as registerPluginRenderers,ro as renderInline,vo as renderMarkdownToLines,yc as renderMessageLines,Me as resetKillRing,n as resolveHorizontalStep,ga as routeSubmit,Uc as safeCommitBoundary,yn as scoreSubsequence,Za as setMarkdownThemeUserOverrides,da as shouldPreserveDraft,Sr as shouldStripSyncOutput,le as shouldUseViewport,Wt as showCommandPalette,sa as slashCommandName,kv as startTui,Gc as streamCommitStep,$e as stringWidth,wr as stripScrollbackClear,br as stripSyncSequences,xr as stripSyncStdout,Vo as subagentEntryStatus,Ho as subagentRestoreFields,zt as t,$c as toggleCollapse,Z as useAppState,Xg as useTabScope,ht as useTabable,vr as withSyncFrame};
|
package/dist/standalone.d.ts
CHANGED
|
@@ -320,5 +320,4 @@ interface StandaloneTuiContext<R> {
|
|
|
320
320
|
*/
|
|
321
321
|
declare function runStandaloneTui<R>(options: StandaloneTuiOptions, run: (ctx: StandaloneTuiContext<R>) => void): Promise<R>;
|
|
322
322
|
//#endregion
|
|
323
|
-
export { ConfirmDialog, type ConfirmDialogProps, FocusBus, type FocusBusContextValue, FocusBusProvider, type FocusStyle, InfoDialog, type InfoDialogAction, type InfoDialogProps, type KeyHandler, List, ListItem, type ListItemProps, type ListOption, type ListProps, PRIORITY_FALLBACK, PRIORITY_FOCUSED, PRIORITY_ROUTER, ProgressDialog, type ProgressDialogProps, type Question, QuestionsDialog, type QuestionsDialogProps, Route, RouteContext, type RouteContextValue, type RouteProps, Router, type RouterContextValue, StandaloneTuiContext, StandaloneTuiOptions, Tabable, type TabableContextValue, type TabableEntry, type TabableProps, TabableRegistry, type UseTabableOptions, WizardDialog, type WizardRequest, matchPath, runStandaloneTui, useFallbackInput, useFocusBus, useRoute, useRouter, useTabable, useTabableContext, useTabableInput };
|
|
324
|
-
//# sourceMappingURL=standalone.d.ts.map
|
|
323
|
+
export { ConfirmDialog, type ConfirmDialogProps, FocusBus, type FocusBusContextValue, FocusBusProvider, type FocusStyle, InfoDialog, type InfoDialogAction, type InfoDialogProps, type KeyHandler, List, ListItem, type ListItemProps, type ListOption, type ListProps, PRIORITY_FALLBACK, PRIORITY_FOCUSED, PRIORITY_ROUTER, ProgressDialog, type ProgressDialogProps, type Question, QuestionsDialog, type QuestionsDialogProps, Route, RouteContext, type RouteContextValue, type RouteProps, Router, type RouterContextValue, StandaloneTuiContext, StandaloneTuiOptions, Tabable, type TabableContextValue, type TabableEntry, type TabableProps, TabableRegistry, type UseTabableOptions, WizardDialog, type WizardRequest, matchPath, runStandaloneTui, useFallbackInput, useFocusBus, useRoute, useRouter, useTabable, useTabableContext, useTabableInput };
|
package/dist/standalone.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import{F as e,Ft as t,Gt as n,I as r,It as i,Jt as a,Kt as o,Mt as s,Nt as c,P as l,Pt as u,Rt as d,Ut as f,V as p,Wt as m,a as h,an as g,c as _,et as v,l as y,n as b,qt as x,r as S,s as C,t as w,z as T,zt as E}from"./WizardDialog-BWGcsBR1.js";import{r as D,t as O}from"./i18n-sGAClHYZ.js";import k,{useEffect as A}from"react";import{render as j,useInput as M}from"ink";const N=(()=>{}),P=()=>{};function F(e){return{get navigate(){return v()?.navigate??N},get goBack(){return v()?.goBack??P},resolve:e}}function I(e){return e===`zh`||e===`en`?e:O()}function L(t,n){return D(I(t.language)),new Promise(r=>{let i=!1,a=null,o=F(e=>{i||(i=!0,a?.clear(),a?.unmount(),g(),r(e))}),s={current:n};function l(){let e=E();return M((t,n)=>{e.dispatch(t,n)},{isActive:process.stdin.isTTY===!0}),A(()=>{let e=setTimeout(()=>s.current(o),0);return()=>clearTimeout(e)},[]),null}a=j(k.createElement(c,null,k.createElement(e,{initialPath:t.initialPath??`/`,children:k.createElement(k.Fragment,null,k.createElement(l,null),t.routes)})),{exitOnCtrlC:!1})})}export{y as ConfirmDialog,s as FocusBus,c as FocusBusProvider,h as InfoDialog,C as List,_ as ListItem,u as PRIORITY_FALLBACK,t as PRIORITY_FOCUSED,i as PRIORITY_ROUTER,S as ProgressDialog,b as QuestionsDialog,l as Route,m as RouteContext,e as Router,n as Tabable,o as TabableRegistry,w as WizardDialog,r as matchPath,L as runStandaloneTui,d as useFallbackInput,E as useFocusBus,T as useRoute,p as useRouter,x as useTabable,a as useTabableContext,f as useTabableInput};
|
|
2
|
-
//# sourceMappingURL=standalone.js.map
|
|
1
|
+
import{F as e,Ft as t,Gt as n,I as r,It as i,Jt as a,Kt as o,Mt as s,Nt as c,P as l,Pt as u,Rt as d,Ut as f,V as p,Wt as m,a as h,an as g,c as _,et as v,l as y,n as b,qt as x,r as S,s as C,t as w,z as T,zt as E}from"./WizardDialog-BWGcsBR1.js";import{r as D,t as O}from"./i18n-sGAClHYZ.js";import k,{useEffect as A}from"react";import{render as j,useInput as M}from"ink";const N=(()=>{}),P=()=>{};function F(e){return{get navigate(){return v()?.navigate??N},get goBack(){return v()?.goBack??P},resolve:e}}function I(e){return e===`zh`||e===`en`?e:O()}function L(t,n){return D(I(t.language)),new Promise(r=>{let i=!1,a=null,o=F(e=>{i||(i=!0,a?.clear(),a?.unmount(),g(),r(e))}),s={current:n};function l(){let e=E();return M((t,n)=>{e.dispatch(t,n)},{isActive:process.stdin.isTTY===!0}),A(()=>{let e=setTimeout(()=>s.current(o),0);return()=>clearTimeout(e)},[]),null}a=j(k.createElement(c,null,k.createElement(e,{initialPath:t.initialPath??`/`,children:k.createElement(k.Fragment,null,k.createElement(l,null),t.routes)})),{exitOnCtrlC:!1})})}export{y as ConfirmDialog,s as FocusBus,c as FocusBusProvider,h as InfoDialog,C as List,_ as ListItem,u as PRIORITY_FALLBACK,t as PRIORITY_FOCUSED,i as PRIORITY_ROUTER,S as ProgressDialog,b as QuestionsDialog,l as Route,m as RouteContext,e as Router,n as Tabable,o as TabableRegistry,w as WizardDialog,r as matchPath,L as runStandaloneTui,d as useFallbackInput,E as useFocusBus,T as useRoute,p as useRouter,x as useTabable,a as useTabableContext,f as useTabableInput};
|