@robota-sdk/agent-transport 3.0.0-beta.67 → 3.0.0-beta.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/node/headless/index.cjs +1 -1
  2. package/dist/node/headless/index.js +1 -1
  3. package/dist/node/{headless-B8yWkXW_.js → headless-C-Ezlo9U.js} +4 -4
  4. package/dist/node/headless-C-Ezlo9U.js.map +1 -0
  5. package/dist/node/{headless-Dp3kQVmo.cjs → headless-Cv-igy49.cjs} +3 -3
  6. package/dist/node/index-CP7kaYMg.d.ts.map +1 -1
  7. package/dist/node/{index-rGmGTQ9o.d.ts → index-D-aT_t_N.d.ts} +16 -8
  8. package/dist/node/index-D-aT_t_N.d.ts.map +1 -0
  9. package/dist/node/index-Gby9H4q2.d.ts.map +1 -1
  10. package/dist/node/{index-CQsMNXAh.d.ts → index-ioN9mYAD.d.ts} +16 -8
  11. package/dist/node/index-ioN9mYAD.d.ts.map +1 -0
  12. package/dist/node/index.cjs +1 -1
  13. package/dist/node/index.d.ts +2 -2
  14. package/dist/node/index.js +1 -1
  15. package/dist/node/tui/index.cjs +1 -1
  16. package/dist/node/tui/index.d.ts +2 -2
  17. package/dist/node/tui/index.js +1 -1
  18. package/dist/node/tui-87G6pg3z.js +25 -0
  19. package/dist/node/tui-87G6pg3z.js.map +1 -0
  20. package/dist/node/tui-BAtwGilM.cjs +24 -0
  21. package/package.json +7 -7
  22. package/src/headless/__tests__/headless-runner.test.ts +2 -0
  23. package/src/headless/headless-runner.ts +24 -3
  24. package/src/headless/headless-stream-json.ts +8 -3
  25. package/src/headless/print-terminal.ts +0 -1
  26. package/src/tui/App.tsx +16 -12
  27. package/src/tui/CjkTextInput.tsx +1 -3
  28. package/src/tui/ContextWarningBanner.tsx +34 -0
  29. package/src/tui/InputArea.tsx +1 -1
  30. package/src/tui/__tests__/command-effect-handler.test.ts +0 -1
  31. package/src/tui/__tests__/confirm-permission-flow.test.ts +40 -1
  32. package/src/tui/__tests__/session-naming.test.ts +64 -0
  33. package/src/tui/create-default-tui-cli-adapter.ts +2 -3
  34. package/src/tui/flows/permission-prompt-flow.ts +13 -4
  35. package/src/tui/hooks/command-effect-handler.ts +0 -5
  36. package/src/tui/hooks/side-effects-types.ts +0 -3
  37. package/src/tui/hooks/use-interactive-session-init.ts +4 -0
  38. package/src/tui/hooks/useInteractiveSession.ts +24 -1
  39. package/src/tui/hooks/useSideEffects.ts +0 -37
  40. package/src/tui/index.ts +1 -1
  41. package/src/tui/render.tsx +24 -8
  42. package/src/tui/session-naming.ts +33 -0
  43. package/src/tui/tui-transport.ts +3 -3
  44. package/src/tui/types.ts +3 -2
  45. package/dist/node/headless-B8yWkXW_.js.map +0 -1
  46. package/dist/node/index-CQsMNXAh.d.ts.map +0 -1
  47. package/dist/node/index-rGmGTQ9o.d.ts.map +0 -1
  48. package/dist/node/tui-B8G3yHrL.cjs +0 -24
  49. package/dist/node/tui-DUIfVw3G.js +0 -25
  50. package/dist/node/tui-DUIfVw3G.js.map +0 -1
  51. package/src/tui/__tests__/model-change-side-effect.test.ts +0 -91
  52. package/src/tui/hooks/model-change-side-effect.ts +0 -63
@@ -0,0 +1,24 @@
1
+ const e=require(`./chunk-Bmb41Sf3.cjs`);let t=require(`ink`),n=require(`react`),r=e.t(n,1);n=e.t(n);let i=require(`@robota-sdk/agent-core`),a=require(`@robota-sdk/agent-framework`),o=require(`react/jsx-runtime`),s=require(`chalk`);s=e.t(s);let c=require(`string-width`);c=e.t(c,1);let l=require(`@robota-sdk/agent-interface-tui`),u=require(`marked`),d=require(`marked-terminal`);d=e.t(d,1);const f=[`active`,`queued`,`running`,`waiting_permission`,`sleeping`],p=/\s+/g;function m(e){return(e?.entries??[]).filter(e=>e.kind===`background_task`&&e.visibility===`default`)}function h(e){return m(e).filter(e=>f.includes(e.status)).length}function g(e,t={}){let n=e.id===t.selectedEntryId,r={id:e.id,radio:n?`●`:`○`,title:v(e),subtitle:y(e),statusLabel:b(e.status),preview:S(e.preview??e.currentAction),color:x(e),isSelected:n};return{...r,accessibleText:C(r)}}function _(e){let t=e.text.trim().replace(p,` `);return t?t.length>160?`${t.slice(0,160)}...`:t:e.kind}function v(e){return e.kind===`main_thread`?e.title:e.kind===`background_group`?`${e.title} group`:e.taskKind===`agent`?`${e.title} agent`:e.taskKind===`process`?e.title||`Process`:e.taskKind===`scheduled`?e.title||`Scheduled`:e.title}function y(e){return e.kind===`main_thread`?e.subtitle:[e.taskKind,e.subtitle,e.attention===`none`?void 0:e.attention].filter(e=>typeof e==`string`&&e.length>0).join(` · `)||void 0}function b(e){return e.replace(/_/g,` `)}function x(e){return e.attention===`failed`||e.status===`failed`?`red`:e.attention===`permission`||e.status===`waiting_permission`?`yellow`:e.status===`completed`?`green`:e.status===`cancelled`?`yellow`:f.includes(e.status)?`cyan`:`white`}function S(e){return e?.trim().replace(p,` `)||void 0}function C(e){return[e.radio,e.title,e.statusLabel,e.subtitle,e.preview].filter(e=>typeof e==`string`&&e.length>0).join(` · `)}function w(e,t={}){let n=g(e),r=T(e)?`□`:`■`,i=[n.statusLabel,n.subtitle].filter(e=>typeof e==`string`&&e.length>0);return{connector:t.isLast===!1?`├`:`└`,marker:r,color:n.color,label:n.title,segments:i,preview:n.preview,accessibleText:[`${t.isLast===!1?`├`:`└`} ${r} ${n.title}`,...i,n.preview].filter(e=>typeof e==`string`&&e.length>0).join(` · `)}}function T(e){return e.status===`active`||e.status===`queued`||e.status===`running`||e.status===`waiting_permission`||e.status===`sleeping`}function E({entries:e}){return e.length===0?null:(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Text,{color:`cyan`,bold:!0,children:`Background work`}),e.map((n,r)=>{let i=w(n,{isLast:r===e.length-1});return(0,o.jsxs)(t.Text,{children:[`${i.connector} `,(0,o.jsx)(t.Text,{color:i.color,children:i.marker}),` ${i.label}`,i.segments.map((e,n)=>(0,o.jsx)(t.Text,{dimColor:!0,children:` · ${e}`},`${e}-${n}`)),i.preview?(0,o.jsx)(t.Text,{dimColor:!0,children:` · ${i.preview}`}):null]},n.id)})]})}function ee({percentage:e}){return e>=90?(0,o.jsx)(t.Box,{borderStyle:`single`,borderColor:`red`,paddingX:1,children:(0,o.jsxs)(t.Text,{color:`red`,bold:!0,children:[`⚠ Context at `,Math.round(e),`% — window nearly full. Run /compact to summarize the conversation.`]})}):e>=70?(0,o.jsx)(t.Box,{paddingX:1,children:(0,o.jsxs)(t.Text,{color:`yellow`,children:[`Context at `,Math.round(e),`% — consider running /compact to free up space.`]})}):null}function D({entry:e,page:n,loading:r,error:i}){let a=g(e,{selectedEntryId:e.id}),s=n?.records.slice(-12)??[];return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Text,{color:`cyan`,bold:!0,children:`Viewing ${a.title}`}),(0,o.jsxs)(t.Text,{dimColor:!0,children:[a.statusLabel,a.subtitle?` · ${a.subtitle}`:``,a.preview?` · ${a.preview}`:``]}),r?(0,o.jsx)(t.Text,{dimColor:!0,children:`Loading workspace detail...`}):null,i?(0,o.jsx)(t.Text,{color:`red`,children:i}):null,!r&&!i&&s.length===0?(0,o.jsx)(t.Text,{dimColor:!0,children:`No detail yet`}):null,!r&&!i&&s.map(e=>(0,o.jsx)(t.Text,{color:O(e.kind),children:_(e)},e.id)),n?.nextCursor?(0,o.jsx)(t.Text,{dimColor:!0,children:`... more detail available`}):null]})}function O(e){if(e===`error`)return`red`;if(e===`result`)return`green`;if(e===`process_output`)return`white`;if(e===`group_summary`)return`cyan`}function k(){return{selectedIndex:0,scrollOffset:0,resolved:!1}}function A(e){if(e.escape===!0)return`cancel`;if(e.upArrow===!0)return`previous`;if(e.downArrow===!0)return`next`;if(e.return===!0)return`select`}function j(e){if(e.escape===!0)return`cancel`;if(e.leftArrow===!0||e.upArrow===!0)return`previous`;if(e.rightArrow===!0||e.downArrow===!0)return`next`;if(e.return===!0)return`select`}function M(e,t,n){if(e.resolved)return{state:e,effect:{type:`none`}};if(t===`cancel`)return{state:{...e,resolved:!0},effect:{type:`cancel`}};if(n.enabled===!1||n.itemCount===0)return{state:e,effect:{type:`none`}};if(t===`select`){let t=F(e.selectedIndex,n.itemCount);return{state:{...e,selectedIndex:t,resolved:!0},effect:{type:`select`,index:t}}}let r=te(e.selectedIndex,t,n),i=P(r,e.scrollOffset,n);return{state:{...e,selectedIndex:r,scrollOffset:i},effect:{type:`none`}}}function N(e,t){if(t.itemCount===0)return{...e,selectedIndex:0,scrollOffset:0};let n=F(e.selectedIndex,t.itemCount),r=P(n,e.scrollOffset,t);return n===e.selectedIndex&&r===e.scrollOffset?e:{...e,selectedIndex:n,scrollOffset:r}}function te(e,t,n){return t===`previous`?n.wrap===!0&&e===0?n.itemCount-1:Math.max(0,e-1):n.wrap===!0&&e===n.itemCount-1?0:Math.min(n.itemCount-1,e+1)}function P(e,t,n){let r=n.maxVisible??n.itemCount;return r<=0?0:e<t?e:e>=t+r?e-r+1:Math.max(0,t)}function F(e,t){return Math.min(Math.max(e,0),t-1)}function I({snapshot:e,selectedEntryId:n,onSelect:r,onClose:i}){let{normalized:a,visibleEntries:s,applyAction:c}=L({entries:[...e?.entries??[]],selectedEntryId:n,onSelect:r,onClose:i});return(0,t.useInput)((e,t)=>{let n=A(t);n!==void 0&&c(n)}),(0,o.jsxs)(t.Box,{flexDirection:`column`,borderStyle:`round`,borderColor:`cyan`,paddingX:1,children:[(0,o.jsx)(t.Text,{color:`cyan`,bold:!0,children:`Execution workspace`}),(0,o.jsx)(t.Box,{flexDirection:`column`,marginTop:1,children:s.length===0?(0,o.jsx)(t.Text,{dimColor:!0,children:`No workspace entries`}):s.map((e,t)=>(0,o.jsx)(B,{entry:e,isFocused:a.scrollOffset+t===a.selectedIndex,selectedEntryId:n},e.id))}),(0,o.jsx)(t.Text,{dimColor:!0,children:`Ctrl+B Close ↑↓ Navigate Enter Switch Esc Close`})]})}function L({entries:e,selectedEntryId:t,onSelect:r,onClose:i}){let[a,o]=(0,n.useState)(()=>k()),s=(0,n.useRef)(a);(0,n.useEffect)(()=>{let n=z({selectedIndex:Math.max(0,e.findIndex(e=>e.id===t)),itemCount:e.length});s.current=n,o(n)},[e.length,t]);let c=z({selectedIndex:a.selectedIndex,scrollOffset:a.scrollOffset,itemCount:e.length});return c!==a&&(s.current=c),{normalized:c,visibleEntries:e.slice(c.scrollOffset,c.scrollOffset+8),applyAction:R({entries:e,stateRef:s,setState:o,onSelect:r,onClose:i})}}function R({entries:e,stateRef:t,setState:n,onSelect:r,onClose:i}){return a=>{let o=M(t.current,a,{itemCount:e.length,maxVisible:8}),s=o.effect.type===`select`||o.effect.type===`cancel`?{...o.state,resolved:!1}:o.state;if(t.current=s,n(s),o.effect.type===`cancel`)i();else if(o.effect.type===`select`){let t=e[o.effect.index];t&&r(t.id)}}}function z(e){return N({selectedIndex:e.selectedIndex,scrollOffset:e.scrollOffset??0,resolved:!1},{itemCount:e.itemCount,maxVisible:8})}function B({entry:e,isFocused:n,selectedEntryId:r}){let i=g(e,{selectedEntryId:r});return(0,o.jsxs)(t.Text,{children:[(0,o.jsx)(t.Text,{color:n?`cyan`:void 0,bold:n,children:n?`> `:` `}),(0,o.jsx)(t.Text,{color:i.color,children:i.radio}),(0,o.jsx)(t.Text,{color:n?`cyan`:void 0,bold:n,children:` ${i.title}`}),(0,o.jsx)(t.Text,{dimColor:!0,children:` · ${i.statusLabel}`}),i.subtitle?(0,o.jsx)(t.Text,{dimColor:!0,children:` · ${i.subtitle}`}):null,i.preview?(0,o.jsx)(t.Text,{dimColor:!0,children:` · ${i.preview}`}):null]})}function V(e,t){let n=null;return{schedule(){n||=setTimeout(()=>{n=null,e()},t)},flush(){n&&=(clearTimeout(n),null)}}}var H=class{history=[];streamingText=``;activeTools=[];isThinking=!1;isAborting=!1;pendingPrompt=null;contextState={percentage:0,usedTokens:0,maxTokens:0};executionWorkspaceSnapshot=null;selectedExecutionEntryId;onChange=null;streamBuf=``;debouncedStreamNotify=V(()=>this.notify(),300);notify(){this.onChange?.()}onTextDelta=e=>{this.streamBuf+=e,this.streamingText=this.streamBuf,this.debouncedStreamNotify.schedule()};onToolStart=e=>{this.activeTools=[...this.activeTools,e],this.notify()};onToolEnd=e=>{let t=this.activeTools.findLastIndex(t=>t.toolName===e.toolName&&t.isRunning);if(t!==-1){let n=[...this.activeTools];n[t]=e,this.activeTools=n}this.notify()};onThinking=e=>{this.isThinking=e,e?(this.debouncedStreamNotify.flush(),this.streamBuf=``,this.streamingText=``,this.activeTools=[]):this.isAborting=!1,this.notify()};onComplete=e=>{this.debouncedStreamNotify.flush(),this.streamBuf=``,this.streamingText=``,this.activeTools=[],this.contextState={percentage:e.contextState.usedPercentage,usedTokens:e.contextState.usedTokens,maxTokens:e.contextState.maxTokens},this.notify()};onInterrupted=()=>{this.debouncedStreamNotify.flush(),this.streamBuf=``,this.streamingText=``,this.activeTools=[],this.notify()};onError=()=>{this.debouncedStreamNotify.flush(),this.streamBuf=``,this.streamingText=``,this.activeTools=[],this.notify()};onContextUpdate=e=>{this.setContextState({percentage:e.usedPercentage,usedTokens:e.usedTokens,maxTokens:e.maxTokens})};syncHistory(e){e.length!==0&&(this.history=e.length>100?e.slice(-100):[...e],this.notify())}addEntry(e){let t=[...this.history,e];this.history=t.length>100?t.slice(-100):t,this.notify()}clearHistory(){this.history=[],this.debouncedStreamNotify.flush(),this.streamBuf=``,this.streamingText=``,this.activeTools=[],this.notify()}setPendingPrompt(e){this.pendingPrompt=e,this.notify()}setAborting(e){this.isAborting=e,this.notify()}setContextState(e){this.contextState=e,this.notify()}syncExecutionWorkspaceSnapshot(e){let t=this.selectedExecutionEntryId,n=t!==void 0&&e.entries.some(e=>e.id===t)?t:e.selectedEntryId??e.entries[0]?.id;this.executionWorkspaceSnapshot={...e,...n?{selectedEntryId:n}:{}},this.selectedExecutionEntryId=n,this.notify()}selectExecutionWorkspaceEntry(e){this.executionWorkspaceSnapshot?.entries.some(t=>t.id===e)&&(this.selectedExecutionEntryId=e,this.executionWorkspaceSnapshot={...this.executionWorkspaceSnapshot,selectedEntryId:e},this.notify())}},ne=class{queue=[];enqueueInteraction(e){this.queue.push({type:`interaction`,interaction:e})}enqueueEffects(e){e.length!==0&&this.queue.push({type:`effects`,effects:[...e]})}drain(){return this.queue.shift()}clear(){this.queue.length=0}};function U(e,t){let n=new a.InteractiveSession({cwd:e.cwd,provider:e.provider,permissionMode:e.permissionMode,maxTurns:e.maxTurns,permissionHandler:t,sessionStore:e.sessionStore,resumeSessionId:e.resumeSessionId,forkSession:e.forkSession,sessionName:e.sessionName,backgroundTaskRunners:e.backgroundTaskRunners,subagentRunnerFactory:e.subagentRunnerFactory,commandModules:e.commandModules,commandHostAdapters:e.commandHostAdapters,shellExec:e.shellExec,language:e.language,agentName:e.agentName,systemPrompt:e.systemPrompt,appendSystemPrompt:e.appendSystemPrompt,allowedTools:e.allowedTools,deniedTools:e.deniedTools}),r=new a.CommandRegistry;for(let t of e.commandModules??[])r.addModule(t);return e.reloadPluginCommandSource?.(r),{interactiveSession:n,registry:r,manager:new H,commandEffectQueue:new ne}}function W(){let[e,t]=(0,r.useState)(null),n=(0,r.useRef)([]),i=(0,r.useRef)(!1),a=(0,r.useCallback)(()=>{if(i.current)return;let e=n.current[0];if(!e){t(null);return}i.current=!0,t({toolName:e.toolName,toolArgs:e.toolArgs,resolve:r=>{n.current.shift(),i.current=!1,t(null),e.resolve(r),setTimeout(()=>a(),0)}})},[]);return{permissionHandler:(0,r.useCallback)((e,t)=>new Promise(r=>{n.current.push({toolName:e,toolArgs:t,resolve:r}),a()}),[a]),permissionRequest:e}}function G(e,t,n,a,o){return(0,r.useCallback)(async r=>{if(!r.startsWith(`/`)){await e.submit(r),n.setPendingPrompt(e.getPendingPrompt());return}let s=r.slice(1).split(/\s+/),c=s[0]?.toLowerCase()??``,l=s.slice(1).join(` `),u=await e.executeCommand(c,l);if(u){if(u.effects?.some(e=>e.type===`session-execution-started`)){n.setPendingPrompt(e.getPendingPrompt());return}re(u,e,t,n,a,o);return}n.addEntry((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Unknown command "/${c}". Type /help for help.`)))},[e,t,n,a,o])}function re(e,t,n,r,a,o){let s=ie(e.effects,n,r,o);if(r.addEntry((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(e.message))),e.interaction!==void 0&&a.enqueueInteraction(e.interaction),s.length>0&&a.enqueueEffects(s),t.isInitialized){let e=t.getContextState();r.setContextState({percentage:e.usedPercentage,usedTokens:e.usedTokens,maxTokens:e.maxTokens})}}function ie(e,t,n,r){if(e===void 0||e.length===0)return[];let i=[];for(let a of e){if(a.type===`conversation-history-cleared`){n.clearHistory();continue}if(a.type===`plugin-registry-reload-requested`){r?.(t);continue}i.push(a)}return i}function ae(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).replace(/-+/g,`-`).slice(0,60)}async function oe(e,t){let n=t.slice(0,200),r=await e.chat([(0,i.createSystemMessage)(`You generate short session titles. Respond with ONLY a 3-5 word lowercase-hyphenated title (e.g. refactor-auth-middleware). No explanation, no punctuation, no quotes.`),(0,i.createUserMessage)(n)],{maxTokens:20}),a=ae(typeof r.content==`string`?r.content:``);return!a||a.length<3?ae(t):a}function se(e,t){t.syncHistory(e.getFullHistory())}function ce(e,t){t.syncHistory(e.getFullHistory())}function K(e,t){try{t.syncExecutionWorkspaceSnapshot(e.getExecutionWorkspaceSnapshot({selectedEntryId:t.selectedExecutionEntryId}))}catch{}}function le(e){let[,t]=(0,r.useState)(0),[n,a]=(0,r.useState)(!1),{permissionHandler:o,permissionRequest:s}=W(),c=(0,r.useRef)(!1),[l]=(0,r.useState)(()=>U(e,o)),{interactiveSession:u,registry:d,manager:f,commandEffectQueue:p}=l;if(f.onChange=()=>t(e=>e+1),f.history.length===0){let e=u.getFullHistory();e.length>0&&f.syncHistory(e)}(0,r.useEffect)(()=>{if(!e.transportRegistry)return;let t=e.transportRegistry;return t.startAll(u).catch(()=>void 0),()=>{t.stopAll().catch(()=>void 0)}},[u,e.transportRegistry]),(0,r.useEffect)(()=>{let t=()=>se(u,f),n=()=>ce(u,f),r=t=>{c.current||e.sessionName||u.getName()||(c.current=!0,oe(e.provider,t).then(t=>{u.setName(t),e.onAutoNamed?.(t)}).catch(()=>{c.current=!1}))},i=e=>f.syncExecutionWorkspaceSnapshot(e.snapshot);u.on(`user_message`,r),u.on(`text_delta`,f.onTextDelta),u.on(`tool_start`,f.onToolStart),u.on(`tool_end`,f.onToolEnd),u.on(`thinking`,f.onThinking),u.on(`complete`,f.onComplete),u.on(`interrupted`,f.onInterrupted),u.on(`error`,f.onError),u.on(`context_update`,f.onContextUpdate),u.on(`compact`,t),u.on(`skill_activation`,n),u.on(`execution_workspace_event`,i);let a=setInterval(()=>{try{let e=u.getContextState();f.setContextState({percentage:e.usedPercentage,usedTokens:e.usedTokens,maxTokens:e.maxTokens});let t=u.getFullHistory();t.length>0&&f.syncHistory(t),K(u,f),clearInterval(a)}catch{}},200);return()=>{clearInterval(a),u.off(`user_message`,r),u.off(`text_delta`,f.onTextDelta),u.off(`tool_start`,f.onToolStart),u.off(`tool_end`,f.onToolEnd),u.off(`thinking`,f.onThinking),u.off(`complete`,f.onComplete),u.off(`interrupted`,f.onInterrupted),u.off(`error`,f.onError),u.off(`context_update`,f.onContextUpdate),u.off(`compact`,t),u.off(`skill_activation`,n),u.off(`execution_workspace_event`,i)}},[u,f]),(0,r.useEffect)(()=>{f.syncHistory(u.getFullHistory()),K(u,f),f.isThinking||f.setPendingPrompt(u.getPendingPrompt())},[f.isThinking,u,f]);let m=G(u,d,f,p,e.reloadPluginCommandSource),h=(0,r.useCallback)(()=>{f.setAborting(!0),u.abort()},[u,f]),g=(0,r.useCallback)(()=>{u.cancelQueue(),f.setPendingPrompt(null)},[u,f]),_=(0,r.useCallback)(async(e=`prompt_input_exit`)=>{n||(a(!0),f.addEntry((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Shutting down...`))),await u.shutdown({reason:e,message:`CLI shutdown`}))},[u,f,n]),v=(0,r.useCallback)(e=>f.selectExecutionWorkspaceEntry(e),[f]),y=(0,r.useCallback)(e=>u.readExecutionWorkspaceDetail(e),[u]);return{interactiveSession:u,registry:d,commandEffectQueue:p,history:f.history,addEntry:e=>f.addEntry(e),streamingText:f.streamingText,activeTools:f.activeTools,isThinking:f.isThinking,isAborting:f.isAborting,isShuttingDown:n,pendingPrompt:f.pendingPrompt,executionWorkspaceSnapshot:f.executionWorkspaceSnapshot,selectedExecutionEntryId:f.selectedExecutionEntryId,permissionRequest:s,contextState:f.contextState,handleSubmit:m,handleAbort:h,handleCancelQueue:g,handleShutdown:_,selectExecutionWorkspaceEntry:v,readExecutionWorkspaceDetail:y}}function ue(){return{listInstalled:async()=>[],listAvailablePlugins:async()=>[],install:async()=>void 0,uninstall:async()=>void 0,enable:async()=>void 0,disable:async()=>void 0,marketplaceAdd:async()=>``,marketplaceRemove:async()=>void 0,marketplaceUpdate:async()=>void 0,marketplaceList:async()=>[],reloadPlugins:async()=>({loadedPluginCount:0})}}function de(e){return(0,r.useMemo)(()=>ue(),[])}function q(e,t){for(let n of e){if(n.type===`language-change-requested`)return J(n.language,t),!0;if(n.type===`settings-reset-requested`)return Y(t),!0;if(n.type===`session-exit-requested`)return t.requestShutdown(n.reason??`prompt_input_exit`,n.message??`User requested exit`),!0;if(n.type===`session-restart-requested`)return t.requestShutdown(n.reason,n.message),!0;if(n.type===`plugin-tui-requested`)return t.openPluginTUI(),!0;if(n.type===`settings-tui-requested`)return t.openTransportTUI(),!0;if(n.type===`agent-switcher-requested`)return t.openAgentSwitcher(),!0;if(n.type===`session-picker-requested`)return t.openSessionPicker(),!0;if(n.type===`session-renamed`)return t.renameSession(n.name),!0;if(n.type===`statusline-settings-patch`&&(0,a.isStatusLineCommandSettingsPatch)(n.patch))return t.applyStatusLinePatch(n.patch)}return!1}function J(e,t){let n=t.cliAdapter.getUserSettingsPath(),r=t.cliAdapter.readSettings(n);r.language=e,t.cliAdapter.writeSettings(n,r),t.addEntry((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Language set to "${e}". Restarting...`))),t.requestShutdown(`other`,`Language change restart`)}function Y(e){let t=e.cliAdapter.getUserSettingsPath();e.cliAdapter.deleteSettings(t)?e.addEntry((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Deleted ${t}. Exiting...`))):e.addEntry((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`No user settings found.`))),e.requestShutdown(`other`,`Reset settings restart`)}const X=(0,n.createContext)(null),fe=X.Provider;function Z(){let e=(0,n.useContext)(X);if(!e)throw Error(`TuiCliAdapterContext not provided`);return e}function pe({cwd:e,providerOverride:n,interactiveSession:a,commandEffectQueue:o,addEntry:s,baseHandleSubmit:c,setSessionName:l,setStatusLineSettings:u,showSessionPickerOnStart:d,openAgentSwitcher:f}){let{exit:p}=(0,t.useApp)(),m=Z(),[h,g]=(0,r.useState)(null),_=(0,r.useRef)(null),[v,y]=(0,r.useState)(!1),[b,x]=(0,r.useState)(d??!1),[S,C]=(0,r.useState)(!1),w=(0,r.useCallback)((e,t)=>{s((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Shutting down...`))),setTimeout(()=>{a.shutdown({reason:e,message:t}).finally(()=>p())},500)},[a,s,p]),T=(0,r.useCallback)(e=>q(e,{addEntry:s,requestShutdown:w,openPluginTUI:()=>y(!0),openSessionPicker:()=>x(!0),openTransportTUI:()=>C(!0),openAgentSwitcher:()=>f?.(),renameSession:e=>{a.setName(e),l(e)},applyStatusLinePatch:e=>(u(m.applyStatusLineSettings(m.getUserSettingsPath(),e)),!0),cliAdapter:m}),[s,m,a,w,l,u]),E=(0,r.useCallback)(e=>{if(e.message.length>0&&s((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(e.message))),e.interaction!==void 0){_.current=e.interaction,g(e.interaction.prompt);return}_.current=null,g(null),e.effects!==void 0&&e.effects.length>0&&T(e.effects)},[s,T]),ee=(0,r.useCallback)(()=>{let e=o.drain();if(e===void 0)return!1;if(e.type===`interaction`){let{interaction:t}=e;return _.current=t,g(t.prompt),!0}return T(e.effects)},[T,o]);return{handleSubmit:(0,r.useCallback)(async e=>{await c(e),ee()},[c,ee]),pendingInteractionPrompt:h,showPluginTUI:v,showSessionPicker:b,showTransportTUI:S,setShowPluginTUI:y,setShowSessionPicker:x,setShowTransportTUI:C,handleInteractionSubmit:(0,r.useCallback)(async e=>{let t=_.current;if(t===null){g(null);return}try{E(await t.submit(e))}catch(e){_.current=null,g(null),s((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Failed: ${e instanceof Error?e.message:String(e)}`)))}},[s,E]),handleInteractionCancel:(0,r.useCallback)(()=>{let e=_.current;if(_.current=null,g(null),e?.cancel===void 0){s((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Command interaction cancelled.`)));return}Promise.resolve(e.cancel()).then(e=>E(e)).catch(e=>{s((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Failed: ${e instanceof Error?e.message:String(e)}`)))})},[s,E])}}function me(e){let t={...a.DEFAULT_STATUS_LINE_COMMAND_SETTINGS},n=e.statusline;return he(n)?{enabled:typeof n.enabled==`boolean`?n.enabled:t.enabled,gitBranch:typeof n.gitBranch==`boolean`?n.gitBranch:t.gitBranch}:t}function he(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function ge(){let e=Z();return(0,r.useState)(()=>me(e.readSettings(e.getUserSettingsPath())))}const _e=`[200~`,Q=`[201~`;function ve(e){return{value:e,cursor:e.length,isPasting:!1,pasteBuffer:``}}function ye(e,t,n){return t===e.value?e:{...e,value:t,cursor:n==null?t.length:Math.min(n,t.length)}}function be(e,t,n,r){let i=Se(e,t,r);if(i!==void 0)return i;let a=Ce(e,t,n,r);if(a!==void 0)return a;let o=we(e,n,r);return o===void 0?Pe(e,t):o}function xe(e,t,n){let r=t.replace(/\r\n?/g,`
2
+ `);return r.length===0?{state:e,effect:{type:`none`}}:r.includes(`
3
+ `)&&n.canPaste?{state:e,effect:{type:`paste`,text:r,cursor:e.cursor}}:Pe(e,r)}function Se(e,t,n){if(t===_e||t.startsWith(_e))return ke(e,t);if(e.isPasting)return Ae(e,t,n)}function Ce(e,t,n,r){if(n.ctrl===!0&&t===`c`||n.tab===!0)return{state:e,effect:{type:`none`}};if(n.return===!0)return{state:e,effect:{type:`submit`,value:e.value}};if(t.length>1&&(t.includes(`
4
+ `)||t.includes(`\r`))&&r.canPaste)return{state:e,effect:{type:`paste`,text:t.replace(/\r\n?/g,`
5
+ `),cursor:e.cursor}}}function we(e,t,n){if(t.upArrow===!0||t.downArrow===!0)return n.enableVerticalNavigation===!1?{state:e,effect:{type:`none`}}:je(e,t.upArrow===!0?`up`:`down`,n.availableWidth);if(t.leftArrow===!0)return Me(e,`left`);if(t.rightArrow===!0)return Me(e,`right`);if(t.backspace===!0||t.delete===!0)return Ne(e)}function Te(e){if(!e||e.length===0)return``;let t=``;for(let n of e){let e=n.charCodeAt(0);e>31&&e!==127&&(t+=n)}return t}function Ee(e,t,n){return{value:e.slice(0,t)+n+e.slice(t),cursor:t+n.length}}function De(e,t,n){let r=0;for(let i=0;i<t&&i<e.length;i++){let t=(0,c.default)(e[i]),a=r%n;a+t>n&&(r+=n-a),r+=t}return r}function Oe(e,t,n){let r=0;for(let i=0;i<e.length;i++){if(r>=t)return i;let a=(0,c.default)(e[i]),o=r%n;o+a>n&&(r+=n-o),r+=a}return e.length}function ke(e,t){return{state:{...e,isPasting:!0,pasteBuffer:t.slice(5)},effect:{type:`none`}}}function Ae(e,t,n){if(t!==Q&&!t.includes(Q))return{state:{...e,pasteBuffer:e.pasteBuffer+t},effect:{type:`none`}};let r=t.split(Q)[0]??``;return xe({...e,isPasting:!1,pasteBuffer:``},e.pasteBuffer+r,n)}function je(e,t,n){if(!n||n<=0)return{state:e,effect:{type:`none`}};let r=[...e.value],i=De(r,e.cursor,n),a=t===`up`?i-n:i+n;if(a<0)return{state:e,effect:{type:`none`}};let o=Oe(r,a,n);return o===e.cursor?{state:e,effect:{type:`none`}}:{state:{...e,cursor:o},effect:{type:`render`}}}function Me(e,t){return t===`left`&&e.cursor>0?{state:{...e,cursor:e.cursor-1},effect:{type:`render`}}:t===`right`&&e.cursor<e.value.length?{state:{...e,cursor:e.cursor+1},effect:{type:`render`}}:{state:e,effect:{type:`none`}}}function Ne(e){if(e.cursor===0)return{state:e,effect:{type:`none`}};let t=e.value.slice(0,e.cursor-1)+e.value.slice(e.cursor);return{state:{...e,value:t,cursor:e.cursor-1},effect:{type:`change`,value:t}}}function Pe(e,t){let n=Te(t);if(n.length===0)return{state:e,effect:{type:`none`}};let r=Ee(e.value,e.cursor,n);return{state:{...e,value:r.value,cursor:r.cursor},effect:{type:`change`,value:r.value}}}function Fe({value:e,onChange:r,onSubmit:i,onPaste:a,placeholder:s=``,focus:c=!0,showCursor:l=!0,availableWidth:u,cursorHint:d=null,enableVerticalNavigation:f=!0}){let p=(0,n.useRef)(ve(e)),[,m]=(0,n.useState)(0);return p.current=ye(p.current,e,d),Ie({stateRef:p,onChange:r,onSubmit:i,onPaste:a,availableWidth:u,focus:c,enableVerticalNavigation:f,forceRender:m}),(0,o.jsx)(t.Text,{children:Be(p.current.value,p.current.cursor,s,l&&c)})}function Ie(e){(0,t.usePaste)(t=>{Re(e,()=>xe(e.stateRef.current,t,Le(e)))},{isActive:e.focus}),(0,t.useInput)((t,n)=>{Re(e,()=>be(e.stateRef.current,t,n,Le(e)))},{isActive:e.focus})}function Le(e){return{availableWidth:e.availableWidth,canPaste:e.onPaste!==void 0,enableVerticalNavigation:e.enableVerticalNavigation}}function Re(e,t){try{let n=t();e.stateRef.current=n.state,ze(n.effect,e.onChange,e.onSubmit,e.onPaste,e.forceRender)}catch{}}function ze(e,t,n,r,i){e.type===`change`?t(e.value):e.type===`submit`?n?.(e.value):e.type===`paste`?r?.(e.text,e.cursor):e.type===`render`&&i(e=>e+1)}function Be(e,t,n,r){if(!r)return e.length>0?e:n?s.default.gray(n):``;if(e.length===0)return n.length>0?s.default.inverse(n[0])+s.default.gray(n.slice(1)):s.default.inverse(` `);let i=[...e],a=``;for(let e=0;e<i.length;e++){let n=i[e]??``;a+=e===t?s.default.inverse(n):n}return t>=i.length&&(a+=s.default.inverse(` `)),a}function Ve(){return[{label:`plan`,value:`plan`,description:`Plan only, no execution`},{label:`default`,value:`default`,description:`Ask before risky actions`},{label:`acceptEdits`,value:`acceptEdits`,description:`Auto-approve file edits`},{label:`bypassPermissions`,value:`bypassPermissions`,description:`Skip all permission checks`}]}function He(){return[{label:`ko Korean`,value:`ko`,description:`한국어`},{label:`en English`,value:`en`,description:`English`},{label:`ja Japanese`,value:`ja`,description:`日本語`},{label:`zh Chinese`,value:`zh`,description:`中文`}]}function Ue(){return[{label:`current`,value:`current`,description:`Show current provider`},{label:`list`,value:`list`,description:`List available providers`},{label:`use`,value:`use`,description:`Switch to a provider`},{label:`add`,value:`add`,description:`Add a new provider`},{label:`test`,value:`test`,description:`Test provider connection`}]}const We={agent:void 0,background:void 0,clear:{onMissingArgs:`confirm`,message:`Clear conversation history?`},compact:void 0,context:void 0,cost:void 0,exit:{onMissingArgs:`confirm`,message:`Exit the session?`},help:void 0,language:{onMissingArgs:`picker`,getItems:He},memory:void 0,mode:{onMissingArgs:`picker`,getItems:Ve},model:void 0,permissions:void 0,plugin:void 0,provider:{onMissingArgs:`picker`,getItems:Ue},rename:void 0,reset:void 0,resume:void 0,rewind:void 0,settings:void 0,skills:void 0,statusline:void 0,"user-local":void 0,"validate-session":void 0};function Ge(e){return We[e]}function Ke(e){if(!e.startsWith(`/`))return{isSlash:!1,parentCommand:``,filter:``};let t=e.slice(1),n=t.indexOf(` `);return n===-1?{isSlash:!0,parentCommand:``,filter:t}:{isSlash:!0,parentCommand:t.slice(0,n),filter:t.slice(n+1)}}function qe(e,t){let[n,i]=(0,r.useState)(0),[a,o]=(0,r.useState)(!1),s=r.default.useRef(e);s.current!==e&&(s.current=e,a&&o(!1));let c=Ke(e),l=c.isSlash&&c.parentCommand.length>0,u=(0,r.useMemo)(()=>{if(!t||!c.isSlash||a)return[];if(l){let e=t.getSubcommands(c.parentCommand);if(e.length===0)return[];if(!c.filter)return e;let n=c.filter.toLowerCase();return e.filter(e=>e.name.toLowerCase().startsWith(n))}return t.getCommands(c.filter)},[t,c.isSlash,c.parentCommand,c.filter,a,l]),d=c.isSlash&&u.length>0&&!a;return n>=u.length&&u.length>0&&i(u.length-1),{showPopup:d,filteredCommands:u,selectedIndex:n,setSelectedIndex:i,isSubcommandMode:l,setShowPopup:e=>{o(typeof e==`function`?t=>!e(!t):!e)}}}function Je(e){if(e.upArrow===!0)return`previous`;if(e.downArrow===!0)return`next`;if(e.escape===!0)return`close`;if(e.tab===!0)return`complete`}function Ye(e){if(e.backspace===!0||e.delete===!0)return`cancelQueue`}function Xe(e){if(e.upArrow===!0)return`previous`;if(e.downArrow===!0)return`next`}function Ze(){return{selectedIndex:null,draft:``}}function Qe(e,t,n,r){if(t.length===0)return{value:e,cursorHint:e.length,state:n};if(r===`previous`){let r=n.selectedIndex===null?t.length-1:Math.max(0,n.selectedIndex-1),i=t[r]??e;return{value:i,cursorHint:i.length,state:{selectedIndex:r,draft:n.selectedIndex===null?e:n.draft}}}if(n.selectedIndex===null)return{value:e,cursorHint:e.length,state:n};if(n.selectedIndex<t.length-1){let r=n.selectedIndex+1,i=t[r]??e;return{value:i,cursorHint:i.length,state:{...n,selectedIndex:r}}}return{value:n.draft,cursorHint:n.draft.length,state:Ze()}}function $e(e,t){let n=t.trim();return n.length===0||e[e.length-1]===n?[...e]:[...e,n]}function et(e){let t=[];for(let n of e){if(n.category!==`chat`||n.type!==`user`)continue;let e=n.data;typeof e?.content==`string`&&(t=$e(t,e.content))}return t}function tt(e,t,n){return t===0?0:n===`previous`?e>0?e-1:t-1:e<t-1?e+1:0}function nt(e,t){let n=Ke(e);return n.parentCommand?{type:`insert`,value:`/${n.parentCommand} ${t.name} `}:t.subcommands&&t.subcommands.length>0?{type:`insert`,value:`/${t.name} `,selectedIndex:0}:{type:`insert`,value:`/${t.name} `}}function rt(e,t,n){let r=Ke(e);return r.parentCommand?{type:`submit`,value:`/${r.parentCommand} ${t.name}`}:n?.onMissingArgs?{type:`open-interaction`,commandName:t.name}:t.subcommands&&t.subcommands.length>0?{type:`insert`,value:`/${t.name} `,selectedIndex:0}:{type:`submit`,value:`/${t.name}`}}function it(e,t,n,r){let i=r.split(`
6
+ `).length,a=`[Pasted text #${n} +${i} lines]`;return{value:e.slice(0,t)+a+e.slice(t),cursorHint:t+a.length,label:a,lineCount:i}}function at(e){return e.trim().length>0}function ot({commandName:e,interaction:n,onConfirm:r,onCancel:i}){return(0,t.useInput)((e,t)=>{t.return||e===`y`||e===`Y`?r():(t.escape||e===`n`||e===`N`)&&i()}),(0,o.jsxs)(t.Box,{paddingX:1,children:[(0,o.jsxs)(t.Text,{bold:!0,color:`yellow`,children:[`/`,e,`:`,` `]}),(0,o.jsxs)(t.Text,{children:[n.message,` `]}),(0,o.jsx)(t.Text,{dimColor:!0,children:`[y/n]`})]})}function st(){let{stdout:e}=(0,t.useStdout)();return Math.max(40,(e.columns??80)-4)}function ct({commandName:e,interaction:r,onSelect:i,onCancel:a}){let s=r.getItems(),[c,l]=(0,n.useState)(0),u=st();(0,t.useInput)((e,t)=>{if(t.upArrow)l(e=>e>0?e-1:s.length-1);else if(t.downArrow)l(e=>e<s.length-1?e+1:0);else if(t.return){let e=s[c];e&&i(e)}else (t.escape||e===`q`)&&a()});let d=s.length<=8||c<8?0:Math.min(c-8+1,s.length-8),f=s.slice(d,d+8);return(0,o.jsxs)(t.Box,{flexDirection:`column`,borderStyle:`round`,borderColor:`cyan`,paddingX:1,children:[(0,o.jsxs)(t.Text,{bold:!0,color:`cyan`,children:[`/`,e]}),f.map((e,n)=>{let r=d+n===c;return(0,o.jsx)(t.Box,{width:u,children:(0,o.jsxs)(t.Text,{color:r?`cyan`:void 0,dimColor:!r,wrap:`truncate-end`,children:[r?`▸ `:` `,e.label,e.description==null?``:` ${e.description}`]})},e.value)}),(0,o.jsx)(t.Text,{dimColor:!0,children:`↑↓ navigate · Enter select · Esc cancel`})]})}function lt(){let{stdout:e}=(0,t.useStdout)(),r=()=>Math.max(40,(e.columns??80)-4),[i,a]=(0,n.useState)(r);return(0,n.useEffect)(()=>{let t=()=>a(r());return e.on(`resize`,t),()=>{e.off(`resize`,t)}},[e]),i}function ut(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e.padEnd(t)}function dt(e){let{cmd:n,isSelected:r,showSlash:i,rowWidth:a,nameColWidth:s}=e,c=r?`▸ `:` `,l=r?`cyan`:void 0,u=!r,d=ut(n.name,s);return(0,o.jsx)(t.Box,{width:a,children:(0,o.jsx)(t.Text,{color:l,dimColor:u,wrap:`truncate-end`,children:i?`${c}/${d} ${n.description??``}`:`${c}${d} ${n.description??``}`})})}function ft({commands:e,selectedIndex:n,visible:r,isSubcommandMode:i}){let a=lt();if(!r||e.length===0)return null;let s=pt(n,e.length),c=e.slice(s,s+8),l=Math.min(20,Math.max(...c.map(e=>e.name.length)));return(0,o.jsx)(t.Box,{flexDirection:`column`,borderStyle:`round`,borderColor:`gray`,paddingX:1,children:c.map((e,t)=>(0,o.jsx)(dt,{cmd:e,isSelected:s+t===n,showSlash:!i,rowWidth:a,nameColWidth:l},e.name))})}function pt(e,t){if(t<=8||e<8)return 0;let n=t-8;return Math.min(e-8+1,n)}const mt=/\[Pasted text #(\d+)(?: \+\d+ lines)?\]/g;function ht(e,t){return e.replace(mt,(e,n)=>t.get(Number(n))??``)}const gt=[`#666666`,`#888888`,`#aaaaaa`,`#888888`];function _t({text:e}){let[r,i]=(0,n.useState)(0);return(0,n.useEffect)(()=>{let e=setInterval(()=>{i(e=>e+1)},400);return()=>clearInterval(e)},[]),(0,o.jsx)(t.Text,{children:[...e].map((e,n)=>(0,o.jsx)(t.Text,{color:gt[(r+Math.floor(n/4))%gt.length],children:e},n))})}function vt({onSubmit:e,onCancelQueue:r,isDisabled:i,isAborting:a,pendingPrompt:s,registry:c,sessionName:u,history:d}){let[f,p]=(0,n.useState)(``),[m,h]=(0,n.useState)(null),[g,_]=(0,n.useState)(null),[v,y]=(0,n.useState)(Ze),[b,x]=(0,n.useState)([]),S=(0,n.useMemo)(()=>et(d??[]),[d]),C=(0,n.useMemo)(()=>b.reduce((e,t)=>$e(e,t),S),[S,b]),w=(0,n.useRef)(new Map),{columns:T}=(0,t.useWindowSize)(),E=T>0?T:80,ee=Math.max(1,E-5),D=(0,n.useRef)(0),{showPopup:O,filteredCommands:k,selectedIndex:A,setSelectedIndex:j,isSubcommandMode:M,setShowPopup:N}=qe(f,c),te=(0,n.useCallback)((e,t)=>{D.current+=1;let n=D.current;w.current.set(n,e),p(r=>{let i=it(r,t,n,e);return h(i.cursorHint),i.value})},[]),P=(0,n.useCallback)(()=>{y(Ze())},[]),F=(0,n.useCallback)(e=>{x(t=>$e(t,e))},[]),I=(0,n.useCallback)(t=>{F(t),P(),e(t)},[e,F,P]),L=(0,n.useCallback)(e=>{let t=nt(f,e);t.type===`insert`&&(p(t.value),t.selectedIndex!==void 0&&j(t.selectedIndex))},[f,j]),R=(0,n.useCallback)(e=>{let t=Ge(e.name),n=rt(f,e,t);if(n.type===`insert`){p(n.value),n.selectedIndex!==void 0&&j(n.selectedIndex);return}if(n.type===`open-interaction`&&t?.onMissingArgs){N(!1),_({commandName:n.commandName,interaction:t});return}n.type===`submit`&&(p(``),I(n.value))},[f,I,j,N]),z=(0,n.useCallback)(e=>{if(!at(e))return;if(O&&k[A]){R(k[A]);return}let t=ht(e.trim(),w.current);p(``),w.current.clear(),D.current=0,I(t)},[O,k,A,R,I]);(0,t.useInput)((e,t)=>{if(!O)return;let n=Je(t);if(n===`previous`||n===`next`)j(e=>tt(e,k.length,n));else if(n===`close`)N(!1);else if(n===`complete`){let e=k[A];e&&L(e)}},{isActive:O&&!i}),(0,t.useInput)((e,t)=>{let n=Xe(t);if(!n)return;let r=Qe(f,C,v,n);p(r.value),h(r.cursorHint),y(r.state)},{isActive:!O&&!i&&!s}),(0,t.useInput)((e,t)=>{Ye(t)===`cancelQueue`&&s&&r?.()},{isActive:!!s});let B=a?`yellow`:s?`cyan`:i?`gray`:`green`,V=Math.max(1,E-2),H=(()=>{if(u){let e=` "${u}" `,t=Math.max(0,V-e.length-2);return{left:`┌`+`─`.repeat(t),label:e,right:`─`.repeat(2)+`┐`}}return{left:`┌`+`─`.repeat(V),label:``,right:`┐`}})(),ne=(0,n.useCallback)(e=>{g&&(_(null),I(`/${g.commandName} ${e.value}`))},[g,I]),U=(0,n.useCallback)(()=>{g&&(_(null),I(`/${g.commandName}`))},[g,I]),W=(0,n.useCallback)(()=>{_(null)},[]);return(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[g&&(0,l.isPickerInteraction)(g.interaction)&&(0,o.jsx)(ct,{commandName:g.commandName,interaction:g.interaction,onSelect:ne,onCancel:W}),g&&(0,l.isConfirmInteraction)(g.interaction)&&(0,o.jsx)(ot,{commandName:g.commandName,interaction:g.interaction,onConfirm:U,onCancel:W}),!g&&O&&(0,o.jsx)(ft,{commands:k,selectedIndex:A,visible:O,isSubcommandMode:M}),(0,o.jsxs)(t.Text,{color:B,children:[H.left,H.label?(0,o.jsx)(t.Text,{backgroundColor:B,color:`black`,bold:!0,children:H.label}):null,H.right]}),(0,o.jsx)(t.Box,{borderStyle:`single`,borderTop:!1,borderColor:B,paddingLeft:1,children:a?(0,o.jsx)(t.Text,{color:`yellow`,children:` Interrupting...`}):s?(0,o.jsxs)(t.Text,{color:`cyan`,children:[` `,`Queued:`,` `,s.length>50?s.slice(0,47)+`...`:s,` `,(0,o.jsx)(t.Text,{dimColor:!0,children:`(Backspace to cancel)`})]}):i?(0,o.jsx)(_t,{text:` Waiting for response... (ESC to interrupt)`}):(0,o.jsxs)(t.Box,{children:[(0,o.jsx)(t.Text,{color:`green`,bold:!0,children:`> `}),(0,o.jsx)(Fe,{value:f,onChange:e=>{p(e),P(),h(null)},onSubmit:z,onPaste:te,placeholder:`Type a message or /help`,availableWidth:ee,cursorHint:m,enableVerticalNavigation:!1})]})})]})}function yt({items:e,renderItem:r,onSelect:i,onCancel:a,maxVisible:s=3}){let[c,l]=(0,n.useState)(()=>k()),u=(0,n.useRef)(c),d=(0,n.useCallback)(t=>{let n=M(u.current,t,{itemCount:e.length,maxVisible:s});if(u.current=n.state,l(n.state),n.effect.type===`cancel`)a();else if(n.effect.type===`select`){let t=e[n.effect.index];t!==void 0&&i(t)}},[e,s,a,i]);if((0,t.useInput)((e,t)=>{let n=A(t);n!==void 0&&d(n)}),e.length===0)return(0,o.jsx)(t.Box,{});let f=N(c,{itemCount:e.length,maxVisible:s});f!==c&&(u.current=f);let{selectedIndex:p,scrollOffset:m}=f,h=e.slice(m,m+s),g=m+s<e.length;return(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[m>0&&(0,o.jsxs)(t.Text,{dimColor:!0,children:[` ↑ `,m,` more above`]}),h.map((e,n)=>(0,o.jsx)(t.Box,{marginBottom:1,children:r(e,m+n===p)},m+n)),g&&(0,o.jsxs)(t.Text,{dimColor:!0,children:[` ↓ `,e.length-m-s,` more below`]})]})}function bt(){return{value:``,resolved:!1}}function xt(e,t){if(t.escape===!0)return{type:`cancel`};if(t.return===!0)return{type:`submit`};if(t.backspace===!0||t.delete===!0)return{type:`delete`};if(e&&t.ctrl!==!0&&t.meta!==!0)return{type:`insert`,value:e}}function St(e,t,n){return e.resolved?{state:e,effect:{type:`none`}}:t.type===`cancel`?{state:{...e,resolved:!0},effect:{type:`cancel`}}:t.type===`delete`?{state:{...e,value:e.value.slice(0,-1),error:void 0},effect:{type:`none`}}:t.type===`insert`?{state:{...e,value:e.value+t.value,error:void 0},effect:{type:`none`}}:Ct(e,n)}function Ct(e,t){let n=e.value.trim();if(!n&&!t.allowEmpty){let r=t.validate?.(n);return{state:r?{...e,error:r}:e,effect:{type:`none`}}}let r=t.validate?.(n);return r===void 0?{state:{...e,resolved:!0},effect:{type:`submit`,value:n}}:{state:{...e,error:r},effect:{type:`none`}}}function wt({title:e,description:r,placeholder:i,onSubmit:a,onCancel:s,validate:c,allowEmpty:l=!1,masked:u=!1}){let[d,f]=(0,n.useState)(()=>bt()),p=(0,n.useRef)(d),m=(0,n.useCallback)(e=>{let t=St(p.current,e,{allowEmpty:l,validate:c});p.current=t.state,f(t.state),t.effect.type===`cancel`?s():t.effect.type===`submit`&&a(t.effect.value)},[l,c,s,a]);return(0,t.useInput)((e,t)=>{let n=xt(e,t);n!==void 0&&m(n)}),(0,o.jsxs)(t.Box,{flexDirection:`column`,borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:[(0,o.jsx)(t.Text,{color:`yellow`,bold:!0,children:e}),(0,o.jsx)(Tt,{description:r}),(0,o.jsxs)(t.Box,{marginTop:1,children:[(0,o.jsx)(t.Text,{color:`cyan`,children:`> `}),d.value?(0,o.jsx)(t.Text,{children:u?`*`.repeat(d.value.length):d.value}):i?(0,o.jsx)(t.Text,{dimColor:!0,children:i}):null,(0,o.jsx)(t.Text,{color:`cyan`,children:`█`})]}),d.error&&(0,o.jsx)(t.Text,{color:`red`,children:d.error}),(0,o.jsx)(t.Text,{dimColor:!0,children:` Enter Submit Esc Cancel`})]})}function Tt({description:e}){return e===void 0||e.length===0?null:(0,o.jsx)(t.Text,{dimColor:!0,children:e})}function Et({prompt:e,onSubmit:n,onCancel:r}){return e.kind===`text`?(0,o.jsx)(wt,{title:e.title,description:e.description,placeholder:e.placeholder,allowEmpty:e.allowEmpty,masked:e.masked,validate:e.validate,onSubmit:n,onCancel:r},`text:${e.title}`):(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[(0,o.jsx)(t.Text,{bold:!0,children:e.title}),e.description!==void 0&&e.description.length>0&&(0,o.jsx)(t.Text,{dimColor:!0,children:e.description}),(0,o.jsx)(yt,{items:[...e.options],maxVisible:e.maxVisible,renderItem:(e,n)=>(0,o.jsxs)(t.Text,{color:n?`cyan`:void 0,children:[n?`> `:` `,e.label]}),onSelect:e=>n(e.value),onCancel:r})]})}const Dt=new Set([`Bash`,`BackgroundProcess`]);function Ot(e){if(!Dt.has(e.toolName)||!e.toolResultData)return;let t=kt(e.toolResultData),n=It(t,`exitCode`),r=Lt(t,`success`),i=Nt(Mt(At(e.toolResultData,t))),a=i.slice(0,4),o=Math.max(0,i.length-a.length),s=e.result===`error`||r===!1||n!==void 0&&n!==0;return{status:s?`error`:`success`,statusLabel:jt(s,n),previewLines:a,omittedLineCount:o,transcriptHint:o>0?`... +${o} lines (full output in session transcript)`:void 0}}function kt(e){try{return JSON.parse(e)}catch{return e}}function At(e,t){if(!$(t))return e;let n=Ft(t,`output`);if(n!==void 0)return n;let r=Ft(t,`stdout`),i=Ft(t,`stderr`),a=Ft(t,`error`),o=[];return r&&o.push(r),i&&o.push(Pt(i,`[stderr] `)),!r&&!i&&a&&o.push(a),o.join(`
7
+ `)}function jt(e,t){return t!==void 0&&t!==0?`exit ${t}`:e?`error`:`ok`}function Mt(e){return e?e.replace(/\r\n/g,`
8
+ `).split(`
9
+ `):[]}function Nt(e){let t=e.length;for(;t>0&&e[t-1].trim().length===0;)--t;return e.slice(0,t)}function Pt(e,t){return Mt(e).map(e=>`${t}${e}`).join(`
10
+ `)}function $(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!(e instanceof Date)}function Ft(e,t){if(!$(e))return;let n=e[t];return typeof n==`string`?n:void 0}function It(e,t){if(!$(e))return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Lt(e,t){if(!$(e))return;let n=e[t];return typeof n==`boolean`?n:void 0}const Rt=`\x1B[0m`,zt=` `,Bt=d.default;function Vt(e){return e===void 0?process.env.NO_COLOR||process.env.FORCE_COLOR===`0`?!1:process.env.FORCE_COLOR?!0:!!process.stdout.isTTY:e}function Ht(e){return e?.trim().toLowerCase()===`diff`}function Ut(e,t,n){let r=`${zt}${e}`.padEnd(t);return n?e.startsWith(`+`)?`${r}${Rt}`:e.startsWith(`-`)?`${r}${Rt}`:r.trimEnd():r.trimEnd()}function Wt(e,t,n){if(e.startsWith(`+`)||e.startsWith(`-`))return Ut(e,n,t);let r=`${zt}${e}`;return t?e.startsWith(`@@`)?`${r}${Rt}`:e.startsWith(`diff `)||e.startsWith(`index `)?`${r}${Rt}`:r:r}function Gt(e,t){let n=e.reduce((e,t)=>Math.max(e,4+t.length),0);return t===void 0?n:Math.max(n,t)}function Kt(e,t,n){let r=e.split(`
11
+ `),i=Gt(r,n);return`${r.map(e=>Wt(e,t,i)).join(`
12
+ `)}\n\n`}function qt(e,t){let n=new Bt(void 0,{ignoreIllegals:!0}),r=n.code.bind(n);return n.code=(n,i,a)=>Ht(i)?Kt(n,e,t):r(n,i,a),n}function Jt(e,t={}){let n=u.marked.parse(e,{renderer:qt(Vt(t.color),t.codeBlockWidth)});return typeof n==`string`?n.trimEnd():e}function Yt({tool:e}){let n=Ot(e);if(!n||n.statusLabel===`ok`&&n.previewLines.length===0&&!n.transcriptHint)return null;let r=n.status===`error`?`red`:`white`;return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginLeft:4,children:[n.statusLabel!==`ok`&&(0,o.jsx)(t.Text,{color:r,dimColor:!0,children:n.statusLabel}),n.previewLines.map((e,n)=>(0,o.jsx)(t.Text,{color:r,dimColor:!0,children:e},`${e}-${n}`)),n.transcriptHint&&(0,o.jsx)(t.Text,{dimColor:!0,children:n.transcriptHint})]})}function Xt(e){let t=e.lines.length>12?Qt(e.lines):e.lines,n=Math.max(...t.map(e=>e.lineNumber),0).toString().length,r=t.map(e=>Zt(e,n)),i=e.lines.length>12;return{file:e.file,markdown:["```diff",...r,"```"].join(`
13
+ `),truncated:i,remainingLineCount:i?e.lines.length-t.length:0}}function Zt(e,t){if(e.type===`hunk`)return e.text;let n=e.lineNumber.toString().padStart(t,` `);return e.type===`remove`?`- ${n} | ${e.text}`:e.type===`add`?`+ ${n} | ${e.text}`:` ${n} | ${e.text}`}function Qt(e){let t=$t(e),n=[];for(let e of t){if(n.length===0&&e.length>10)return e.slice(0,10);if(n.length+e.length>10)break;n.push(...e)}return n.length>0?n:e.slice(0,10)}function $t(e){let t=[],n=[];for(let r of e){if(r.type===`hunk`&&n.length>0){t.push(n),n=[r];continue}n.push(r)}return n.length>0&&t.push(n),t}function en({file:e,lines:n}){let r=Xt({file:e,lines:n});return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginLeft:4,children:[r.file&&(0,o.jsxs)(t.Text,{color:`white`,dimColor:!0,children:[`│ `,r.file]}),(0,o.jsx)(t.Text,{children:Jt(r.markdown)}),r.truncated&&(0,o.jsxs)(t.Text,{color:`white`,dimColor:!0,children:[`│ ... and `,r.remainingLineCount,` more lines`]})]})}function tn({entry:e}){let n=e.data;if(!n)return(0,o.jsx)(o.Fragment,{});let r=n.promptTokens===void 0?`?`:nn(n.promptTokens),a=n.completionTokens===void 0?`?`:nn(n.completionTokens),s=nn(n.totalTokens),c=`${Math.round(n.contextUsedPercentage)}% (${(0,i.formatTokenCount)(n.contextUsedTokens)}/${(0,i.formatTokenCount)(n.contextMaxTokens)})`,l=n.costStatus===`unknown`?`cost unknown`:`cost ${n.costStatus}`;return(0,o.jsx)(t.Box,{flexDirection:`column`,marginBottom:1,children:(0,o.jsxs)(t.Box,{children:[(0,o.jsxs)(t.Text,{color:`white`,bold:!0,children:[`Usage:`,` `]}),(0,o.jsxs)(t.Text,{dimColor:!0,children:[n.kind,` `,s,` tokens (in `,r,` / out `,a,`) · Context `,c,` ·`,` `,l]})]})})}function nn(e){return e<1e3?e.toLocaleString():(0,i.formatTokenCount)(e)}function rn(e){return Ot(e)?.status===`error`?`✗`:e.isRunning?`⟳`:e.result===`error`?`✗`:e.result===`denied`?`⊘`:`✓`}function an(e){return Ot(e)?.status===`error`||e.result===`error`?`red`:e.isRunning||e.result===`denied`?`yellow`:`green`}function on(e){return`${rn(e)} ${e.toolName}${e.firstArg?`(${e.firstArg})`:``}`}function sn({role:e}){switch(e){case`user`:return(0,o.jsxs)(t.Text,{color:`green`,bold:!0,children:[`You:`,` `]});case`assistant`:return(0,o.jsxs)(t.Text,{color:`cyan`,bold:!0,children:[`Robota:`,` `]});case`system`:return(0,o.jsxs)(t.Text,{color:`yellow`,bold:!0,children:[`System:`,` `]});case`tool`:return(0,o.jsxs)(t.Text,{color:`white`,bold:!0,children:[`Tool:`,` `]})}}function cn({message:e}){if(!(0,i.isToolMessage)(e))return(0,o.jsx)(o.Fragment,{});let n=e.name,r=e.content,a=null;try{let e=JSON.parse(r);Array.isArray(e)&&e.length>0&&typeof e[0].line==`string`&&(a=e)}catch{}if(a)return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsxs)(t.Box,{children:[(0,o.jsxs)(t.Text,{color:`white`,bold:!0,children:[`Tool:`,` `]}),n&&(0,o.jsxs)(t.Text,{color:`white`,dimColor:!0,children:[`[`,n,`]`]})]}),(0,o.jsx)(t.Text,{children:` `}),a.map((e,n)=>(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[(0,o.jsxs)(t.Text,{color:`green`,children:[` `,`✓`,` `,e.line]}),e.diffLines&&e.diffLines.length>0&&(0,o.jsx)(en,{file:e.diffFile,lines:e.diffLines})]},n))]});let s=r.split(`
14
+ `).filter(e=>e.trim());return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsxs)(t.Box,{children:[(0,o.jsxs)(t.Text,{color:`white`,bold:!0,children:[`Tool:`,` `]}),n&&(0,o.jsxs)(t.Text,{color:`white`,dimColor:!0,children:[`[`,n,`]`]})]}),(0,o.jsx)(t.Text,{children:` `}),s.map((e,n)=>(0,o.jsxs)(t.Text,{color:`green`,children:[` `,`✓`,` `,e]},n))]})}const ln=n.default.memo(function({message:e}){if((0,i.isToolMessage)(e))return(0,o.jsx)(cn,{message:e});let n=e.content??``,r=e.state===`interrupted`;return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Box,{children:(0,o.jsx)(sn,{role:e.role})}),(0,o.jsx)(t.Text,{children:` `}),(0,o.jsx)(t.Box,{marginLeft:2,children:(0,o.jsx)(t.Text,{wrap:`wrap`,children:(0,i.isAssistantMessage)(e)?Jt(n+(r?`
15
+
16
+ _(interrupted)_`:``)):n})})]})});function un({entry:e}){let n=e.data,r=n?.tools,i=n?.summary?.split(`
17
+ `)??[];return r&&r.length>0?(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Box,{children:(0,o.jsxs)(t.Text,{color:`white`,bold:!0,children:[`Tool:`,` `]})}),(0,o.jsx)(t.Text,{children:` `}),r.map((e,n)=>(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[(0,o.jsxs)(t.Text,{color:an(e),children:[` `,on(e)]}),(0,o.jsx)(Yt,{tool:e}),e.diffLines&&e.diffLines.length>0&&(0,o.jsx)(en,{file:e.diffFile,lines:e.diffLines})]},n))]}):(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Box,{children:(0,o.jsxs)(t.Text,{color:`white`,bold:!0,children:[`Tool:`,` `]})}),(0,o.jsx)(t.Text,{children:` `}),i.map((e,n)=>(0,o.jsxs)(t.Text,{color:`green`,children:[` `,e]},n))]})}function dn({entry:e}){let n=e.data,r=typeof n?.message==`string`?n.message:typeof n?.content==`string`?n.content:e.type;return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Box,{children:(0,o.jsxs)(t.Text,{color:`yellow`,bold:!0,children:[`System:`,` `]})}),(0,o.jsx)(t.Text,{children:` `}),(0,o.jsx)(t.Box,{marginLeft:2,children:(0,o.jsx)(t.Text,{wrap:`wrap`,children:r})})]})}function fn({entry:e}){if(e.category===`chat`){let t=e.data;return(0,o.jsx)(ln,{message:t})}return e.type===`tool-summary`?(0,o.jsx)(un,{entry:e}):e.type===`usage-summary`?(0,o.jsx)(tn,{entry:e}):e.type===`tool-start`||e.type===`tool-end`?(0,o.jsx)(o.Fragment,{}):(0,o.jsx)(dn,{entry:e})}function pn({history:e}){return(0,o.jsx)(t.Box,{flexDirection:`column`,children:e.map(e=>(0,o.jsx)(fn,{entry:e},e.id))})}const mn=[`Allow [y]`,`Allow always (this session) [s]`,`Allow always (this project) [p]`,`Deny [n]`];function hn(e,t){let n=j({...t,escape:!1});if(n!==void 0)return n;if(e===`y`||e===`1`)return{type:`shortcut`,index:0};if(e===`s`||e===`a`||e===`2`)return{type:`shortcut`,index:1};if(e===`p`||e===`3`)return{type:`shortcut`,index:2};if(e===`n`||e===`d`||e===`4`)return{type:`shortcut`,index:3}}function gn(e,t){if(e.resolved)return{state:e,effect:{type:`none`}};if(typeof t!=`string`)return vn(e,t.index);let n=M(e,t,{itemCount:mn.length});return n.effect.type===`select`?{state:n.state,effect:{type:`resolve`,decision:_n(n.effect.index)}}:{state:n.state,effect:{type:`none`}}}function _n(e){return e===0?!0:e===1?`allow-session`:e===2?`allow-project`:!1}function vn(e,t){return{state:{...e,selectedIndex:t,resolved:!0},effect:{type:`resolve`,decision:_n(t)}}}function yn(e){let t=Object.entries(e);return t.length===0?`(no arguments)`:t.map(([e,t])=>`${e}: ${typeof t==`string`?t:JSON.stringify(t)}`).join(`, `)}function bn({request:e}){let[r,i]=n.default.useState(()=>k()),a=n.default.useRef(r),s=n.default.useRef(e);if(s.current!==e){s.current=e;let t=k();a.current=t,i(t)}let c=n.default.useCallback(t=>{let n=gn(a.current,t);a.current=n.state,i(n.state),n.effect.type===`resolve`&&e.resolve(n.effect.decision)},[e]);return(0,t.useInput)((e,t)=>{let n=hn(e,t);n!==void 0&&c(n)}),(0,o.jsxs)(t.Box,{flexDirection:`column`,borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:[(0,o.jsx)(t.Text,{color:`yellow`,bold:!0,children:`[Permission Required]`}),(0,o.jsxs)(t.Text,{children:[`Tool:`,` `,(0,o.jsx)(t.Text,{color:`cyan`,bold:!0,children:e.toolName})]}),(0,o.jsxs)(t.Text,{dimColor:!0,children:[` `,yn(e.toolArgs)]}),(0,o.jsx)(t.Box,{marginTop:1,children:mn.map((e,n)=>(0,o.jsx)(t.Box,{marginRight:2,children:(0,o.jsxs)(t.Text,{color:n===r.selectedIndex?`cyan`:void 0,bold:n===r.selectedIndex,children:[n===r.selectedIndex?`> `:` `,e]})},e))}),(0,o.jsx)(t.Text,{dimColor:!0,children:` left/right to select, Enter to confirm`})]})}function xn(e,t,n){let r=j({...t,escape:!1});if(r!==void 0)return r;if(n===2&&e===`y`)return{type:`shortcut`,index:0};if(n===2&&e===`n`)return{type:`shortcut`,index:1}}function Sn(e,t,n){return e.resolved?{state:e,effect:{type:`none`}}:typeof t==`string`?M(e,t,{itemCount:n}):{state:{...e,selectedIndex:t.index,resolved:!0},effect:{type:`select`,index:t.index}}}function Cn({message:e,options:r=[`Yes`,`No`],onSelect:i}){let[a,s]=(0,n.useState)(()=>k()),c=(0,n.useRef)(a),l=(0,n.useCallback)(e=>{let t=Sn(c.current,e,r.length);c.current=t.state,s(t.state),t.effect.type===`select`&&i(t.effect.index)},[i,r.length]);return(0,t.useInput)((e,t)=>{let n=xn(e,t,r.length);n!==void 0&&l(n)}),(0,o.jsxs)(t.Box,{flexDirection:`column`,borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:[(0,o.jsx)(t.Text,{color:`yellow`,children:e}),(0,o.jsx)(t.Box,{marginTop:1,children:r.map((e,n)=>(0,o.jsx)(t.Box,{marginRight:2,children:(0,o.jsxs)(t.Text,{color:n===a.selectedIndex?`cyan`:void 0,bold:n===a.selectedIndex,children:[n===a.selectedIndex?`> `:` `,e]})},e))}),(0,o.jsx)(t.Text,{dimColor:!0,children:` arrow keys to select, Enter to confirm`})]})}function wn(e,t,n,i,a){let[o,s]=(0,r.useState)([]),[c,l]=(0,r.useState)(!1),[u,d]=(0,r.useState)();return(0,r.useEffect)(()=>{if(s([]),d(void 0),e===`marketplace-list`)l(!0),n.marketplaceList().then(e=>{let t=[{label:`Add Marketplace`,value:`__add__`}],n=e.map(e=>({label:e.name,value:e.name,hint:e.type}));s([...t,...n]),l(!1)}).catch(e=>{d(e instanceof Error?e.message:String(e)),l(!1)});else if(e===`marketplace-browse`){let e=t??``;l(!0),n.listAvailablePlugins(e).then(e=>{s(e.map(e=>({label:e.name,value:e.name,hint:e.installed?`installed`:e.description}))),l(!1)}).catch(e=>{d(e instanceof Error?e.message:String(e)),l(!1)})}else e===`installed-list`&&(l(!0),n.listInstalled().then(e=>{s(e.map(e=>({label:e.name,value:e.name,hint:e.description}))),l(!1)}).catch(e=>{d(e instanceof Error?e.message:String(e)),l(!1)}))},[a,e,t,n,i]),{items:o,loading:c,error:u}}function Tn({title:e,items:r,onSelect:i,onBack:a,loading:s,error:c}){let[l,u]=(0,n.useState)(()=>k()),d=(0,n.useRef)(l),f=!s&&!c,p=(0,n.useCallback)(e=>{let t=M(d.current,e,{itemCount:r.length,enabled:f});if(d.current=t.state,u(t.state),t.effect.type===`cancel`)a();else if(t.effect.type===`select`){let e=r[t.effect.index];e!==void 0&&i(e.value)}},[f,r,a,i]);(0,t.useInput)((e,t)=>{let n=A(t);n!==void 0&&p(n)});let m=N(l,{itemCount:r.length});m!==l&&(d.current=m);let h=m.selectedIndex;return(0,o.jsxs)(t.Box,{flexDirection:`column`,borderStyle:`round`,borderColor:`yellow`,paddingX:1,children:[(0,o.jsx)(t.Text,{color:`yellow`,bold:!0,children:e}),s&&(0,o.jsx)(t.Box,{marginTop:1,children:(0,o.jsx)(t.Text,{dimColor:!0,children:`Loading...`})}),c&&(0,o.jsxs)(t.Box,{marginTop:1,flexDirection:`column`,children:[(0,o.jsx)(t.Text,{color:`red`,children:c}),(0,o.jsx)(t.Text,{dimColor:!0,children:`Press Esc to go back`})]}),!s&&!c&&(0,o.jsx)(t.Box,{flexDirection:`column`,marginTop:1,children:r.map((e,n)=>(0,o.jsxs)(t.Box,{children:[(0,o.jsxs)(t.Text,{color:n===h?`cyan`:void 0,bold:n===h,children:[n===h?`> `:` `,e.label]}),e.hint&&(0,o.jsxs)(t.Text,{dimColor:!0,children:[` `,e.hint]})]},e.value))}),(0,o.jsx)(t.Text,{dimColor:!0,children:s||c?``:` ↑↓ Navigate Enter Select Esc Back`})]})}function En(e,t){e===`marketplace`?t.push({screen:`marketplace-list`}):e===`installed`&&t.push({screen:`installed-list`})}function Dn(e,t){e===`__add__`?t.push({screen:`marketplace-add`}):t.push({screen:`marketplace-action`,context:{marketplace:e}})}function On(e,t,n,r){e===`browse`?r.push({screen:`marketplace-browse`,context:{marketplace:t}}):e===`update`?n.marketplaceUpdate(t).then(()=>{r.notify(`Updated marketplace "${t}".`),r.pop()}).catch(e=>{r.notify(`Error: ${e instanceof Error?e.message:String(e)}`)}):e===`remove`&&r.setConfirm({message:`Remove marketplace "${t}" and all its plugins?`,onConfirm:()=>{r.setConfirm(void 0),n.marketplaceRemove(t).then(()=>{r.notify(`Removed marketplace "${t}".`),r.popN(2)}).catch(e=>{r.notify(`Error: ${e instanceof Error?e.message:String(e)}`)})},onCancel:()=>r.setConfirm(void 0)})}function kn(e,t,n,r){let i=`${e}@${t}`;n.find(t=>t.value===e)?.hint===`installed`?r.push({screen:`installed-action`,context:{pluginId:i}}):r.push({screen:`marketplace-install-scope`,context:{marketplace:t,pluginId:i}})}function An(e,t,n,r){let i=e;n.install(t,i).then(()=>{r.notify(`Installed plugin "${t}" (${i} scope).`),r.popN(2)}).catch(e=>{r.notify(`Error: ${e instanceof Error?e.message:String(e)}`)})}function jn(e,t,n){n.setConfirm({message:`Uninstall plugin "${e}"?`,onConfirm:()=>{n.setConfirm(void 0),t.uninstall(e).then(()=>{n.notify(`Uninstalled plugin "${e}".`),n.refresh()}).catch(e=>{n.notify(`Error: ${e instanceof Error?e.message:String(e)}`)})},onCancel:()=>n.setConfirm(void 0)})}function Mn(e,t,n,r){e===`uninstall`&&r.setConfirm({message:`Uninstall plugin "${t}"?`,onConfirm:()=>{r.setConfirm(void 0),n.uninstall(t).then(()=>{r.notify(`Uninstalled plugin "${t}".`),r.popN(2)}).catch(e=>{r.notify(`Error: ${e instanceof Error?e.message:String(e)}`)})},onCancel:()=>r.setConfirm(void 0)})}function Nn({callbacks:e,onClose:t,addMessage:r}){let[i,a]=(0,n.useState)([{screen:`main`}]),[s,c]=(0,n.useState)(),[l,u]=(0,n.useState)(0),d=i[i.length-1]??{screen:`main`},f=(0,n.useCallback)(e=>{a(t=>[...t,e])},[]),p=(0,n.useCallback)(()=>{a(e=>e.length<=1?(t(),e):e.slice(0,-1))},[t]),m=(0,n.useCallback)(e=>{a(n=>{let r=n.slice(0,Math.max(1,n.length-e));return r.length===0?(t(),n):r})},[t]),h=(0,n.useCallback)(e=>{r?.({role:`system`,content:e})},[r]),g=(0,n.useCallback)(()=>{u(e=>e+1)},[]),_=(0,n.useCallback)(e=>c(e),[c]),v={push:(0,n.useCallback)(e=>f({screen:e.screen,context:e.context}),[f]),pop:p,popN:m,notify:h,setConfirm:_,refresh:g},{items:y,loading:b,error:x}=wn(d.screen,d.context?.marketplace,e,l,i.length),S=(0,n.useCallback)(t=>{let n=d.screen,r=d.context;n===`main`?En(t,v):n===`marketplace-list`?Dn(t,v):n===`marketplace-action`?On(t,r?.marketplace??``,e,v):n===`marketplace-browse`?kn(t,r?.marketplace??``,y,v):n===`marketplace-install-scope`?An(t,r?.pluginId??``,e,v):n===`installed-list`?jn(t,e,v):n===`installed-action`&&Mn(t,r?.pluginId??``,e,v)},[d,y,e,f,p,m,h,c,g]),C=(0,n.useCallback)(t=>{d.screen===`marketplace-add`&&e.marketplaceAdd(t).then(e=>{h(`Added marketplace "${e}" from ${t}.`),p()}).catch(e=>{h(`Error: ${e instanceof Error?e.message:String(e)}`),p()})},[d.screen,e,h,p]);if(s)return(0,o.jsx)(Cn,{message:s.message,onSelect:e=>{e===0?s.onConfirm():s.onCancel()}});let w=d.screen;return w===`marketplace-add`?(0,o.jsx)(wt,{title:`Add Marketplace Source`,placeholder:`owner/repo or git URL`,onSubmit:C,onCancel:p,validate:e=>e.includes(`/`)?void 0:`Must be owner/repo or a git URL`}):w===`marketplace-action`?(0,o.jsx)(Tn,{title:`Marketplace: ${d.context?.marketplace??``}`,items:[{label:`Browse plugins`,value:`browse`},{label:`Update`,value:`update`},{label:`Remove`,value:`remove`}],onSelect:S,onBack:p},i.length):w===`marketplace-install-scope`?(0,o.jsx)(Tn,{title:`Install scope for "${d.context?.pluginId??``}"`,items:[{label:`User scope`,value:`user`},{label:`Project scope`,value:`project`}],onSelect:S,onBack:p},i.length):w===`installed-action`?(0,o.jsx)(Tn,{title:`Plugin: ${d.context?.pluginId??``}`,items:[{label:`Uninstall`,value:`uninstall`}],onSelect:S,onBack:p},i.length):(0,o.jsx)(Tn,{title:{main:`Plugin Management`,"marketplace-list":`Marketplace`,"marketplace-browse":`Browse: ${d.context?.marketplace??``}`,"installed-list":`Installed Plugins`}[w]??`Plugin Management`,items:{main:[{label:`Marketplace`,value:`marketplace`},{label:`Installed Plugins`,value:`installed`}]}[w]??y,onSelect:S,onBack:p,loading:b,error:x},`${w}-${i.length}-${l}`)}function Pn({sessions:e,onSelect:n,onCancel:r}){return(0,o.jsxs)(t.Box,{flexDirection:`column`,paddingX:1,marginBottom:1,children:[(0,o.jsx)(t.Text,{bold:!0,color:`cyan`,children:`Select a session to resume (ESC to cancel):`}),(0,o.jsx)(yt,{items:[...e],renderItem:(e,n)=>{let r=e.preview?e.preview.slice(0,60)+(e.preview.length>60?`...`:``):``;return(0,o.jsxs)(t.Text,{children:[n?`> `:` `,(0,o.jsx)(t.Text,{bold:!0,children:e.name??e.id.slice(0,8)}),` `,(0,o.jsx)(t.Text,{dimColor:!0,children:new Date(e.updatedAt).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}),` `,(0,o.jsxs)(t.Text,{dimColor:!0,children:[`msgs: `,e.messageCount]}),r?(0,o.jsxs)(o.Fragment,{children:[`
18
+ `,(0,o.jsx)(t.Text,{color:`gray`,children:r})]}):null]})},onSelect:e=>n(e.id),onCancel:r})]})}function Fn(e){let t=In(e),n=e.hasPendingPrompt&&t.kind!==`queued`?[`queued`]:[],r=[t.label,...n].join(` · `);return{...t,segments:n,text:r}}function In(e){return e.activeToolCount>0?{kind:`tools`,label:`Tools x${e.activeToolCount}`,color:`cyan`}:e.isThinking?{kind:`thinking`,label:`Thinking`,color:`yellow`}:e.activeBackgroundTaskCount>0?{kind:`background`,label:`Background x${e.activeBackgroundTaskCount}`,color:`cyan`}:e.hasPendingPrompt?{kind:`queued`,label:`Queued`,color:`yellow`}:{kind:`idle`,label:`Idle`,color:`gray`}}function Ln(e){return e>=90?`red`:e>=70?`yellow`:`green`}function Rn({isThinking:e,activeToolCount:n,activeBackgroundTaskCount:r,hasPendingPrompt:i}){let a=Fn({isThinking:e,activeToolCount:n,activeBackgroundTaskCount:r,hasPendingPrompt:i});return(0,o.jsx)(t.Text,{color:a.color,bold:a.kind!==`idle`,children:a.text})}function zn({percentage:e,usedTokens:n,maxTokens:r}){return(0,o.jsxs)(t.Text,{color:Ln(e),children:[`Context: `,Math.round(e),`% (`,(0,i.formatTokenCount)(n),`/`,(0,i.formatTokenCount)(r),`)`]})}function Bn({permissionMode:e}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.Text,{color:`cyan`,bold:!0,children:`Mode:`}),` `,(0,o.jsx)(t.Text,{children:e})]})}function Vn(e){return e!==`default`}function Hn({modelName:e,providerDisplayName:n}){return n===void 0?(0,o.jsx)(t.Text,{dimColor:!0,children:e}):(0,o.jsxs)(t.Text,{dimColor:!0,children:[n,` `,e]})}function Un(e){let n=e.showGitBranch&&e.gitBranch!==void 0&&e.gitBranch.length>0,r=Vn(e.permissionMode);return(0,o.jsxs)(t.Text,{children:[(0,o.jsx)(Rn,{isThinking:e.isThinking,activeToolCount:e.activeToolCount,activeBackgroundTaskCount:e.activeBackgroundTaskCount,hasPendingPrompt:e.hasPendingPrompt}),r&&(0,o.jsxs)(o.Fragment,{children:[` | `,(0,o.jsx)(Bn,{permissionMode:e.permissionMode})]}),e.sessionName&&(0,o.jsxs)(o.Fragment,{children:[` | `,(0,o.jsx)(t.Text,{color:`magenta`,children:e.sessionName})]}),n&&(0,o.jsxs)(o.Fragment,{children:[` | `,(0,o.jsxs)(t.Text,{dimColor:!0,children:[`git: `,e.gitBranch]})]}),` | `,(0,o.jsx)(Hn,{modelName:e.modelName,providerDisplayName:e.providerDisplayName}),` | `,(0,o.jsx)(zn,{percentage:e.contextPercentage,usedTokens:e.contextUsedTokens,maxTokens:e.contextMaxTokens})]})}function Wn({permissionMode:e,modelName:n,providerDisplayName:r,sessionId:i,isThinking:a,activeToolCount:s=0,activeBackgroundTaskCount:c=0,hasPendingPrompt:l=!1,contextPercentage:u,contextUsedTokens:d,contextMaxTokens:f,sessionName:p,gitBranch:m,showGitBranch:h=!0,activeAgentLabel:g}){return(0,o.jsxs)(t.Box,{borderStyle:`single`,borderColor:`gray`,paddingLeft:1,paddingRight:1,justifyContent:`space-between`,children:[(0,o.jsx)(Un,{permissionMode:e,modelName:n,providerDisplayName:r,isThinking:a,activeToolCount:s,activeBackgroundTaskCount:c,hasPendingPrompt:l,contextPercentage:u,contextUsedTokens:d,contextMaxTokens:f,sessionName:p,gitBranch:m,showGitBranch:h}),g!==void 0&&(0,o.jsxs)(t.Text,{color:`yellow`,bold:!0,children:[`[`,g,`]`]})]})}function Gn({cwd:e,permissionMode:t,modelId:r,providerType:i,sessionId:a,isThinking:s,activeToolCount:c,activeBackgroundTaskCount:l,hasPendingPrompt:u,contextState:d,sessionName:f,settings:p,activeAgentLabel:m,gitRefreshToken:h}){let g=Z(),_=(0,n.useMemo)(()=>g.getGitBranch(e),[g,e,h]),v=(0,n.useMemo)(()=>i===void 0?void 0:g.getProviderDisplayName(i),[g,i]);return p.enabled?(0,o.jsx)(Wn,{permissionMode:t,modelName:r??``,providerDisplayName:v,sessionId:a,isThinking:s,activeToolCount:c,activeBackgroundTaskCount:l,hasPendingPrompt:u,contextPercentage:d.percentage,contextUsedTokens:d.usedTokens,contextMaxTokens:d.maxTokens,sessionName:f,gitBranch:_,showGitBranch:p.gitBranch,activeAgentLabel:m}):null}function Kn(e){return e.isRunning?{color:`yellow`,icon:`⟳`,strikethrough:!1}:e.result===`error`?{color:`red`,icon:`✗`,strikethrough:!0}:e.result===`denied`?{color:`yellowBright`,icon:`⊘`,strikethrough:!0}:{color:`green`,icon:`✓`,strikethrough:!1}}function qn(e){return e?(0,o.jsx)(t.Box,{marginBottom:1,children:(0,o.jsx)(t.Text,{color:`yellow`,children:`Thinking...`})}):(0,o.jsx)(o.Fragment,{})}function Jn(e){return(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Text,{color:`white`,bold:!0,children:`Tools:`}),(0,o.jsx)(t.Text,{children:` `}),e.map((e,n)=>{let{color:r,icon:i,strikethrough:a}=Kn(e);return(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[(0,o.jsxs)(t.Text,{color:r,strikethrough:a,children:[` `,i,` `,e.toolName,`(`,e.firstArg,`)`]}),e.diffLines&&e.diffLines.length>0&&(0,o.jsx)(en,{file:e.diffFile,lines:e.diffLines})]},`${e.toolName}-${n}`)})]})}function Yn({text:e,activeTools:n,isThinking:r=!1}){let i=n.length>0,a=e.length>0;return!i&&!a?qn(r):(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[i&&Jn(n),a&&(0,o.jsxs)(t.Box,{flexDirection:`column`,marginBottom:1,children:[(0,o.jsx)(t.Text,{color:`cyan`,bold:!0,children:`Robota:`}),(0,o.jsx)(t.Text,{children:` `}),(0,o.jsx)(t.Box,{marginLeft:2,children:(0,o.jsx)(t.Text,{wrap:`wrap`,children:Jt(e)})})]})]})}function Xn({entry:e,selected:n}){let r=e.config.enabled,i=r?`●`:`○`,a=r?`[enabled] `:`[disabled]`,s=e.config.options?.port,c=typeof s==`number`?`port: ${s}`:``;return(0,o.jsx)(t.Box,{children:(0,o.jsx)(t.Text,{color:n?`cyan`:void 0,bold:n,children:`${i} ${e.transport.name.padEnd(18)} ${a} ${c}`})})}function Zn(e,r,i,a,o,s,c,l){(0,t.useInput)((0,n.useCallback)((t,n)=>{if(!i){if(n.upArrow){o(e=>Math.max(0,e-1));return}if(n.downArrow){o(t=>Math.min(e.length-1,t+1));return}if(n.escape||n.return){c();return}if(t===` `){let t=e[r];if(!t)return;s(!0),a.setEnabled(t.transport.name,!t.config.enabled).then(()=>{l(),s(!1)}).catch(()=>s(!1))}}},[i,e,r,a,c,l,o,s]))}function Qn({registry:e,onClose:r}){let[i,a]=(0,n.useState)(()=>e.getAll()),[s,c]=(0,n.useState)(0),[l,u]=(0,n.useState)(!1);return Zn(i,s,l,e,c,u,r,(0,n.useCallback)(()=>{a(e.getAll())},[e])),(0,o.jsxs)(t.Box,{flexDirection:`column`,paddingX:2,paddingY:1,children:[(0,o.jsx)(t.Text,{bold:!0,children:`Settings › Transports`}),(0,o.jsx)(t.Box,{marginTop:1,flexDirection:`column`,children:i.map((e,t)=>(0,o.jsx)(Xn,{entry:e,selected:t===s},e.transport.name))}),(0,o.jsx)(t.Box,{marginTop:1,children:(0,o.jsx)(t.Text,{dimColor:!0,children:`↑↓ select space toggle enter/esc close`})}),l&&(0,o.jsx)(t.Box,{marginTop:1,children:(0,o.jsx)(t.Text,{color:`yellow`,children:`Saving…`})})]})}function $n({message:e}){return(0,o.jsx)(t.Box,{paddingX:1,marginBottom:1,children:(0,o.jsx)(t.Text,{color:`yellow`,children:e})})}function er(e){let[t,r]=(0,n.useState)(e.resumeSessionId),[i,a]=(0,n.useState)(e.showSessionPickerOnStart??!1);return(0,o.jsx)(fe,{value:e.cliAdapter,children:(0,o.jsx)(tr,{...e,showSessionPickerOnStart:i,resumeSessionId:t,onSessionSwitch:e=>{a(!1),r(e)}},t??`__new__`)})}function tr(e){let r=e.cwd,[s,c]=(0,n.useState)(e.sessionName),{interactiveSession:l,registry:u,commandEffectQueue:d,history:f,addEntry:p,streamingText:g,activeTools:_,isThinking:v,isAborting:y,isShuttingDown:b,pendingPrompt:x,executionWorkspaceSnapshot:S,selectedExecutionEntryId:C,selectExecutionWorkspaceEntry:w,readExecutionWorkspaceDetail:T,permissionRequest:O,contextState:k,handleSubmit:A,handleAbort:j,handleCancelQueue:M,handleShutdown:N}=le({cwd:r,provider:e.provider,permissionMode:e.permissionMode,maxTurns:e.maxTurns,sessionStore:e.sessionStore,resumeSessionId:e.resumeSessionId,forkSession:e.forkSession,sessionName:e.sessionName,onAutoNamed:c,backgroundTaskRunners:e.backgroundTaskRunners,subagentRunnerFactory:e.subagentRunnerFactory,commandModules:e.commandModules,commandHostAdapters:e.commandHostAdapters,shellExec:e.shellExec,transportRegistry:e.transportRegistry,language:e.language,reloadPluginCommandSource:e.reloadPluginCommandSource,agentName:e.agentName,systemPrompt:e.systemPrompt,appendSystemPrompt:e.appendSystemPrompt,allowedTools:e.allowedTools,deniedTools:e.deniedTools}),te=de(r),P=e.commandHostAdapters?.plugin??te,{exit:F}=(0,t.useApp)(),[L,R]=(0,n.useState)(),[z,B]=(0,n.useState)(!1),[V,H]=(0,n.useState)(null),[ne,U]=(0,n.useState)(),[W,G]=(0,n.useState)(!1),[re,ie]=ge(),[ae,oe]=(0,n.useState)(0),se=(0,n.useMemo)(()=>m(S),[S]),ce=h(S),K=(0,n.useMemo)(()=>S?.entries.find(e=>e.id===C),[S,C]),{handleSubmit:ue,pendingInteractionPrompt:q,showPluginTUI:J,showSessionPicker:Y,showTransportTUI:X,setShowPluginTUI:fe,setShowSessionPicker:Z,setShowTransportTUI:me,handleInteractionSubmit:he,handleInteractionCancel:_e}=pe({cwd:r,providerOverride:e.providerOverride,interactiveSession:l,commandEffectQueue:d,addEntry:p,baseHandleSubmit:A,setSessionName:c,setStatusLineSettings:ie,showSessionPickerOnStart:e.showSessionPickerOnStart,openAgentSwitcher:()=>B(!0)}),Q=!K||K.kind===`main_thread`||K.controls.includes(`send`),ve=K&&K.kind!==`main_thread`?K.title:void 0,ye=(0,n.useMemo)(()=>S?.entries.find(e=>e.kind===`main_thread`)?.id,[S]),be=(0,n.useCallback)(async e=>{K&&K.kind!==`main_thread`&&K.controls.includes(`send`)?await l.sendAgentJob(K.sourceId,e):await ue(e)},[K,ue,l]),xe=(0,n.useCallback)(async e=>{oe(e=>e+1),await be(e)},[be]),Se=(0,n.useRef)(!1);(0,n.useEffect)(()=>{Se.current&&!v&&oe(e=>e+1),Se.current=v},[v]),(0,n.useEffect)(()=>{let e=l?.getName?.();e&&!s&&c(e)},[l,s]),(0,n.useEffect)(()=>{let t=!0;return e.startupUpdateNotice?.then(e=>{t&&e!==void 0&&R(e)}).catch(()=>{}),()=>{t=!1}},[e.startupUpdateNotice]),(0,n.useEffect)(()=>{let e=s?`Robota — ${s}`:`Robota`;process.stdout.write(`\x1b]0;${e}\x07`)},[s]),(0,t.useInput)((e,t)=>{!t.escape||!v||O||J||X||Y||z||j()}),(0,t.useInput)((e,t)=>{!t.ctrl||e!==`b`||O||J||Y||b||B(e=>!e)}),(0,t.useInput)((e,t)=>{!t.escape||v||O||J||X||Y||z||K&&K.kind!==`main_thread`&&ye!==void 0&&w(ye)}),(0,t.useInput)((e,t)=>{!t.ctrl||e!==`c`||b||N(`prompt_input_exit`).finally(()=>F())}),(0,n.useEffect)(()=>{let e=()=>{b||N(`other`).finally(()=>F())};return process.once(`SIGINT`,e),process.once(`SIGTERM`,e),()=>{process.off(`SIGINT`,e),process.off(`SIGTERM`,e)}},[N,F,b]),(0,n.useEffect)(()=>{if(!K||K.kind===`main_thread`){H(null),U(void 0),G(!1);return}let e=!0;return G(!0),U(void 0),T(K.id).then(t=>{e&&(H(t),G(!1))}).catch(t=>{e&&(U(t.message),G(!1))}),()=>{e=!1}},[S,T,K]);let Ce=e.permissionMode??`default`,we=``;try{let e=l.getSession();Ce=e.getPermissionMode(),we=e.getSessionId()}catch{}return(0,o.jsxs)(t.Box,{flexDirection:`column`,children:[(0,o.jsxs)(t.Box,{flexDirection:`column`,paddingX:1,marginBottom:1,children:[(0,o.jsx)(t.Text,{color:`cyan`,bold:!0,children:`
19
+ ____ ___ ____ ___ _____ _
20
+ | _ \\ / _ \\| __ ) / _ \\_ _|/ \\
21
+ | |_) | | | | _ \\| | | || | / _ \\
22
+ | _ <| |_| | |_) | |_| || |/ ___ \\
23
+ |_| \\_\\\\___/|____/ \\___/ |_/_/ \\_\\
24
+ `}),(0,o.jsxs)(t.Text,{dimColor:!0,children:[` v`,e.version??`0.0.0`]})]}),L&&(0,o.jsx)($n,{message:L}),(0,o.jsxs)(t.Box,{flexDirection:`column`,paddingX:1,flexGrow:1,children:[K&&K.kind!==`main_thread`?(0,o.jsx)(D,{entry:K,page:V,loading:W,error:ne}):(0,o.jsx)(pn,{history:f}),b&&(0,o.jsx)(t.Box,{marginBottom:1,children:(0,o.jsx)(t.Text,{color:`yellow`,children:`Shutting down...`})}),(v||_.length>0)&&(0,o.jsx)(t.Box,{flexDirection:`column`,marginBottom:1,children:(0,o.jsx)(Yn,{text:g,activeTools:_,isThinking:v})}),(0,o.jsx)(E,{entries:se})]}),z&&(0,o.jsx)(I,{snapshot:S,selectedEntryId:C,onSelect:w,onClose:()=>B(!1)}),O&&(0,o.jsx)(bn,{request:O}),q&&(0,o.jsx)(Et,{prompt:q,onSubmit:he,onCancel:_e}),J&&(0,o.jsx)(Nn,{callbacks:P,onClose:()=>fe(!1),addMessage:e=>p((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(e.content)))}),X&&e.transportRegistry&&(0,o.jsx)(Qn,{registry:e.transportRegistry,onClose:()=>me(!1)}),Y&&(0,o.jsx)(Pn,{sessions:(0,a.listResumableSessionSummaries)(e.sessionStore,e.cwd),onSelect:t=>{Z(!1),e.onSessionSwitch(t)},onCancel:()=>{Z(!1),p((0,i.messageToHistoryEntry)((0,i.createSystemMessage)(`Session resume cancelled.`)))}}),(0,o.jsx)(ee,{percentage:k.percentage}),(0,o.jsx)(Gn,{cwd:r,permissionMode:Ce,modelId:e.modelId,providerType:e.providerType,sessionId:we,isThinking:v,activeToolCount:_.length,activeBackgroundTaskCount:ce,hasPendingPrompt:x!==null,contextState:k,sessionName:s,settings:re,activeAgentLabel:ve,gitRefreshToken:ae}),(0,o.jsx)(vt,{onSubmit:xe,onCancelQueue:M,isDisabled:!!O||J||X||Y||z||b||q!==null||v&&!!x||!Q,isAborting:y,pendingPrompt:x,registry:u,sessionName:s,history:f}),(0,o.jsx)(t.Box,{position:`absolute`,children:(0,o.jsx)(t.Text,{children:` `})})]})}async function nr(e){process.on(`unhandledRejection`,e=>{process.stderr.write(`\n[UNHANDLED REJECTION] ${e}\n`),e instanceof Error&&process.stderr.write(`${e.stack}\n`)}),await(0,t.render)((0,o.jsx)(er,{...e}),{exitOnCtrlC:!1}).waitUntilExit()}var rr=class{name=`tui`;defaultEnabled=!0;optionsSchema={};options;constructor(e){this.options=e}attach(e){}async start(){await nr(this.options)}async stop(){}validateOptions(e){return!0}};function ir({providerDefinitions:e,reloadPluginCommandSource:t}){return{getUserSettingsPath:()=>(0,a.getUserSettingsPath)(),readSettings:e=>(0,a.readSettings)(e),writeSettings:(e,t)=>(0,a.writeSettings)(e,t),deleteSettings:e=>(0,a.deleteSettings)(e),applyStatusLineSettings:(e,t)=>(0,a.applyStatusLineSettings)(e,t),reloadPluginCommandSource:e=>{t(e)},applyActiveModelChange:(e,t,n)=>((0,a.applyActiveModelChange)(e,t,n),{applied:!0}),getGitBranch:e=>(0,a.resolveGitBranch)(e),getProviderDisplayName:t=>(0,i.findProviderDefinition)(e,t)?.displayName??t}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return rr}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return ir}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robota-sdk/agent-transport",
3
- "version": "3.0.0-beta.67",
3
+ "version": "3.0.0-beta.68",
4
4
  "description": "Consolidated transport package for Robota SDK — headless, HTTP, WebSocket, and MCP adapters",
5
5
  "type": "module",
6
6
  "main": "dist/node/index.js",
@@ -98,7 +98,7 @@
98
98
  "@modelcontextprotocol/sdk": "^1.28.0",
99
99
  "chalk": "^5.3.0",
100
100
  "hono": "^4.7.0",
101
- "ink": "^7.0.1",
101
+ "ink": "^7.0.4",
102
102
  "ink-select-input": "^6.2.0",
103
103
  "ink-spinner": "^5.0.0",
104
104
  "ink-text-input": "^6.0.0",
@@ -108,10 +108,10 @@
108
108
  "string-width": "^8.2.0",
109
109
  "ws": "^8.18.3",
110
110
  "zod": "^3.24.4",
111
- "@robota-sdk/agent-core": "3.0.0-beta.67",
112
- "@robota-sdk/agent-framework": "3.0.0-beta.67",
113
- "@robota-sdk/agent-interface-tui": "3.0.0-beta.67",
114
- "@robota-sdk/agent-interface-transport": "3.0.0-beta.67"
111
+ "@robota-sdk/agent-core": "3.0.0-beta.68",
112
+ "@robota-sdk/agent-interface-transport": "3.0.0-beta.68",
113
+ "@robota-sdk/agent-framework": "3.0.0-beta.68",
114
+ "@robota-sdk/agent-interface-tui": "3.0.0-beta.68"
115
115
  },
116
116
  "devDependencies": {
117
117
  "@homebridge/node-pty-prebuilt-multiarch": "^0.13.1",
@@ -124,7 +124,7 @@
124
124
  "tsx": "^4.7.0",
125
125
  "typescript": "^5.3.3",
126
126
  "vitest": "^1.6.1",
127
- "@robota-sdk/agent-command": "3.0.0-beta.67"
127
+ "@robota-sdk/agent-command": "3.0.0-beta.68"
128
128
  },
129
129
  "license": "MIT",
130
130
  "publishConfig": {
@@ -210,6 +210,7 @@ describe('createHeadlessRunner (json format)', () => {
210
210
  result: '',
211
211
  session_id: 'test-session-id',
212
212
  subtype: 'error',
213
+ error_code: 'api_error',
213
214
  });
214
215
  });
215
216
 
@@ -344,6 +345,7 @@ describe('createHeadlessRunner (stream-json format)', () => {
344
345
  result: '',
345
346
  session_id: 'stream-session',
346
347
  subtype: 'error',
348
+ error_code: 'api_error',
347
349
  });
348
350
  });
349
351
 
@@ -22,12 +22,33 @@ export function createHeadlessRunner(options: IHeadlessRunnerOptions): {
22
22
  };
23
23
  }
24
24
 
25
+ export function resolveErrorCode(error: Error): string {
26
+ const msg = error.message.toLowerCase();
27
+ if (msg.includes('api key') || msg.includes('no provider') || msg.includes('provider')) {
28
+ return 'config_error';
29
+ }
30
+ if (msg.includes('tool') || msg.includes('execution')) {
31
+ return 'tool_error';
32
+ }
33
+ return 'api_error';
34
+ }
35
+
25
36
  export function writeJsonResult(
26
37
  sessionId: string,
27
38
  result: string,
28
39
  subtype: 'success' | 'error',
40
+ error?: Error,
29
41
  ): void {
30
- const output = JSON.stringify({ type: 'result', result, session_id: sessionId, subtype });
42
+ const payload: Record<string, unknown> = {
43
+ type: 'result',
44
+ result,
45
+ session_id: sessionId,
46
+ subtype,
47
+ };
48
+ if (subtype === 'error' && error !== undefined) {
49
+ payload['error_code'] = resolveErrorCode(error);
50
+ }
51
+ const output = JSON.stringify(payload);
31
52
  process.stdout.write(output + '\n');
32
53
  }
33
54
 
@@ -95,9 +116,9 @@ function runJsonFormat(session: IInteractiveSession, prompt: string): Promise<nu
95
116
  writeJsonResult(getSessionId(session), result.response, 'success');
96
117
  resolve(0);
97
118
  };
98
- const onError = (_error: Error): void => {
119
+ const onError = (error: Error): void => {
99
120
  cleanup();
100
- writeJsonResult(getSessionId(session), '', 'error');
121
+ writeJsonResult(getSessionId(session), '', 'error', error);
101
122
  resolve(1);
102
123
  };
103
124
 
@@ -82,7 +82,12 @@ export function writeStreamJsonEvent(
82
82
  export function subscribeStreamJsonEvents(
83
83
  session: IInteractiveSession,
84
84
  getSessionId: (s: IInteractiveSession) => string,
85
- writeJsonResult: (sessionId: string, result: string, subtype: 'success' | 'error') => void,
85
+ writeJsonResult: (
86
+ sessionId: string,
87
+ result: string,
88
+ subtype: 'success' | 'error',
89
+ error?: Error,
90
+ ) => void,
86
91
  resolve: (exitCode: number) => void,
87
92
  ): () => void {
88
93
  const emit = (event: TStreamJsonEvent): void =>
@@ -115,9 +120,9 @@ export function subscribeStreamJsonEvents(
115
120
  writeJsonResult(getSessionId(session), result.response, 'success');
116
121
  resolve(0);
117
122
  };
118
- const onError = (_error: Error): void => {
123
+ const onError = (error: Error): void => {
119
124
  cleanup();
120
- writeJsonResult(getSessionId(session), '', 'error');
125
+ writeJsonResult(getSessionId(session), '', 'error', error);
121
126
  resolve(1);
122
127
  };
123
128
 
@@ -7,7 +7,6 @@
7
7
  */
8
8
 
9
9
  import * as readline from 'node:readline';
10
-
11
10
  import type { ITerminalOutput, ISpinner } from '@robota-sdk/agent-core';
12
11
 
13
12
  export class PrintTerminal implements ITerminalOutput {
package/src/tui/App.tsx CHANGED
@@ -5,13 +5,13 @@ import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react'
5
5
 
6
6
  import BackgroundTaskPanel from './BackgroundTaskPanel.js';
7
7
  import ConfirmPrompt from './ConfirmPrompt.js';
8
+ import { ContextWarningBanner } from './ContextWarningBanner.js';
8
9
  import {
9
10
  countActiveBackgroundWorkspaceEntries,
10
11
  getDefaultBackgroundWorkspaceEntries,
11
12
  } from './execution-workspace-view-model.js';
12
13
  import ExecutionWorkspaceDetailPane from './ExecutionWorkspaceDetailPane.js';
13
14
  import ExecutionWorkspaceSwitcher from './ExecutionWorkspaceSwitcher.js';
14
- import { formatModelChangeConfirmationMessage } from './hooks/model-change-side-effect.js';
15
15
  import { useInteractiveSession } from './hooks/useInteractiveSession.js';
16
16
  import { usePluginCallbacks } from './hooks/usePluginCallbacks.js';
17
17
  import { useSideEffects } from './hooks/useSideEffects.js';
@@ -69,6 +69,10 @@ interface IProps {
69
69
  cliAdapter: ITuiCliAdapter;
70
70
  reloadPluginCommandSource?: (registry: CommandRegistry) => void;
71
71
  agentName?: string;
72
+ systemPrompt?: string;
73
+ appendSystemPrompt?: string;
74
+ allowedTools?: string[];
75
+ deniedTools?: string[];
72
76
  }
73
77
 
74
78
  export default function App(props: IProps): React.ReactElement {
@@ -97,6 +101,7 @@ function AppInner(
97
101
  props: IProps & { onSessionSwitch: (sessionId: string) => void },
98
102
  ): React.ReactElement {
99
103
  const cwd = props.cwd;
104
+ const [sessionName, setSessionName] = useState<string | undefined>(props.sessionName);
100
105
 
101
106
  const {
102
107
  interactiveSession,
@@ -129,6 +134,7 @@ function AppInner(
129
134
  resumeSessionId: props.resumeSessionId,
130
135
  forkSession: props.forkSession,
131
136
  sessionName: props.sessionName,
137
+ onAutoNamed: setSessionName,
132
138
  backgroundTaskRunners: props.backgroundTaskRunners,
133
139
  subagentRunnerFactory: props.subagentRunnerFactory,
134
140
  commandModules: props.commandModules,
@@ -138,12 +144,15 @@ function AppInner(
138
144
  language: props.language,
139
145
  reloadPluginCommandSource: props.reloadPluginCommandSource,
140
146
  agentName: props.agentName,
147
+ systemPrompt: props.systemPrompt,
148
+ appendSystemPrompt: props.appendSystemPrompt,
149
+ allowedTools: props.allowedTools,
150
+ deniedTools: props.deniedTools,
141
151
  });
142
152
 
143
153
  const fallbackPluginCallbacks = usePluginCallbacks(cwd);
144
154
  const pluginCallbacks = props.commandHostAdapters?.plugin ?? fallbackPluginCallbacks;
145
155
  const { exit } = useApp();
146
- const [sessionName, setSessionName] = useState<string | undefined>(props.sessionName);
147
156
  const [updateNotice, setUpdateNotice] = useState<string | undefined>();
148
157
  const [showExecutionWorkspaceSwitcher, setShowExecutionWorkspaceSwitcher] = useState(false);
149
158
  const [executionDetailPage, setExecutionDetailPage] = useState<IExecutionDetailPage | null>(null);
@@ -166,7 +175,6 @@ function AppInner(
166
175
 
167
176
  const {
168
177
  handleSubmit,
169
- pendingModelId,
170
178
  pendingInteractionPrompt,
171
179
  showPluginTUI,
172
180
  showSessionPicker,
@@ -174,7 +182,6 @@ function AppInner(
174
182
  setShowPluginTUI,
175
183
  setShowSessionPicker,
176
184
  setShowTransportTUI,
177
- handleModelConfirm,
178
185
  handleInteractionSubmit,
179
186
  handleInteractionCancel,
180
187
  } = useSideEffects({
@@ -417,12 +424,6 @@ function AppInner(
417
424
  />
418
425
  )}
419
426
  {permissionRequest && <PermissionPrompt request={permissionRequest} />}
420
- {pendingModelId && (
421
- <ConfirmPrompt
422
- message={formatModelChangeConfirmationMessage(pendingModelId)}
423
- onSelect={handleModelConfirm}
424
- />
425
- )}
426
427
  {pendingInteractionPrompt && (
427
428
  <InteractivePrompt
428
429
  prompt={pendingInteractionPrompt}
@@ -456,6 +457,7 @@ function AppInner(
456
457
  }}
457
458
  />
458
459
  )}
460
+ <ContextWarningBanner percentage={contextState.percentage} />
459
461
  <SessionStatusBar
460
462
  cwd={cwd}
461
463
  permissionMode={permissionMode}
@@ -492,8 +494,10 @@ function AppInner(
492
494
  sessionName={sessionName}
493
495
  history={history}
494
496
  />
495
- {/* Permanent blank line below inputrequired for Korean IME stability. */}
496
- <Text> </Text>
497
+ {/* Blank line for Korean IME absolute to avoid extending output height. */}
498
+ <Box position="absolute">
499
+ <Text> </Text>
500
+ </Box>
497
501
  </Box>
498
502
  );
499
503
  }
@@ -65,8 +65,6 @@ export default function CjkTextInput({
65
65
  const stateRef = useRef<ICjkTextInputFlowState>(createCjkTextInputFlowState(value));
66
66
  const [, forceRender] = useState(0);
67
67
 
68
- // useCursor removed — see comment below about Terminal.app SIGSEGV
69
-
70
68
  // Sync ref when value changes from parent (e.g., setValue(''), tab completion, paste)
71
69
  stateRef.current = syncCjkTextInputFlowState(stateRef.current, value, cursorHint);
72
70
 
@@ -149,7 +147,7 @@ function applyCjkFlowSafely(
149
147
  options.forceRender,
150
148
  );
151
149
  } catch {
152
- // Korean IME in raw mode can produce unexpected byte sequences.
150
+ // allow-fallback: Korean IME in raw mode can produce unexpected byte sequences
153
151
  }
154
152
  }
155
153
 
@@ -0,0 +1,34 @@
1
+ import { Box, Text } from 'ink';
2
+ import React from 'react';
3
+
4
+ interface IProps {
5
+ percentage: number;
6
+ }
7
+
8
+ const COMPACT_SUGGESTION_THRESHOLD = 70;
9
+ const CRITICAL_THRESHOLD = 90;
10
+
11
+ export function ContextWarningBanner({ percentage }: IProps): React.ReactElement | null {
12
+ if (percentage >= CRITICAL_THRESHOLD) {
13
+ return (
14
+ <Box borderStyle="single" borderColor="red" paddingX={1}>
15
+ <Text color="red" bold>
16
+ ⚠ Context at {Math.round(percentage)}% — window nearly full. Run /compact to summarize
17
+ the conversation.
18
+ </Text>
19
+ </Box>
20
+ );
21
+ }
22
+
23
+ if (percentage >= COMPACT_SUGGESTION_THRESHOLD) {
24
+ return (
25
+ <Box paddingX={1}>
26
+ <Text color="yellow">
27
+ Context at {Math.round(percentage)}% — consider running /compact to free up space.
28
+ </Text>
29
+ </Box>
30
+ );
31
+ }
32
+
33
+ return null;
34
+ }
@@ -1,8 +1,8 @@
1
- import { Box, Text, useInput, useWindowSize } from 'ink';
2
1
  import React, { useState, useCallback, useRef, useMemo } from 'react';
3
2
 
4
3
  const PENDING_PROMPT_DISPLAY_MAX = 50;
5
4
  const PENDING_PROMPT_TAIL_KEEP = 47;
5
+ import { Box, Text, useInput, useWindowSize } from 'ink';
6
6
 
7
7
  import CjkTextInput from './CjkTextInput.js';
8
8
  import { resolveCommandInteraction } from './command-interaction-registry.js';
@@ -55,7 +55,6 @@ function createDeps(settingsPath: string) {
55
55
  return {
56
56
  addEntry: vi.fn(),
57
57
  requestShutdown: vi.fn(),
58
- requestModelChange: vi.fn(),
59
58
  openPluginTUI: vi.fn(),
60
59
  openTransportTUI: vi.fn(),
61
60
  openSessionPicker: vi.fn(),
@@ -6,6 +6,7 @@ import {
6
6
  import {
7
7
  applyPermissionPromptInput,
8
8
  getPermissionPromptInputAction,
9
+ PERMISSION_PROMPT_OPTIONS,
9
10
  } from '../flows/permission-prompt-flow.js';
10
11
  import { createSelectionFlowState } from '../flows/selection-flow.js';
11
12
 
@@ -58,6 +59,21 @@ describe('permission prompt flow', () => {
58
59
  expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
59
60
  });
60
61
 
62
+ it('Given p or 3 shortcut When applied Then allow-project decision is emitted', () => {
63
+ expect(
64
+ applyPermissionPromptInput(
65
+ createSelectionFlowState(),
66
+ getPermissionPromptInputAction('p', {})!,
67
+ ).effect,
68
+ ).toEqual({ type: 'resolve', decision: 'allow-project' });
69
+ expect(
70
+ applyPermissionPromptInput(
71
+ createSelectionFlowState(),
72
+ getPermissionPromptInputAction('3', {})!,
73
+ ).effect,
74
+ ).toEqual({ type: 'resolve', decision: 'allow-project' });
75
+ });
76
+
61
77
  it('Given deny shortcuts When applied Then false decision is emitted', () => {
62
78
  expect(
63
79
  applyPermissionPromptInput(
@@ -68,7 +84,7 @@ describe('permission prompt flow', () => {
68
84
  expect(
69
85
  applyPermissionPromptInput(
70
86
  createSelectionFlowState(),
71
- getPermissionPromptInputAction('3', {})!,
87
+ getPermissionPromptInputAction('4', {})!,
72
88
  ).effect,
73
89
  ).toEqual({ type: 'resolve', decision: false });
74
90
  });
@@ -88,4 +104,27 @@ describe('permission prompt flow', () => {
88
104
 
89
105
  expect(result.effect).toEqual({ type: 'none' });
90
106
  });
107
+
108
+ // CLI-030 TC-03: [s] option is shown
109
+ it('Given PERMISSION_PROMPT_OPTIONS When inspected Then session option contains [s] hint', () => {
110
+ expect(PERMISSION_PROMPT_OPTIONS[1]).toContain('[s]');
111
+ });
112
+
113
+ // CLI-030 TC-03: s key maps to allow-session
114
+ it('Given s shortcut When applied Then allow-session decision is emitted', () => {
115
+ const action = getPermissionPromptInputAction('s', {});
116
+
117
+ const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
118
+
119
+ expect(result.effect).toEqual({ type: 'resolve', decision: 'allow-session' });
120
+ });
121
+
122
+ // CLI-030 TC-04: allow-once (y) does not add to session list
123
+ it('Given y (allow-once) shortcut When applied Then true decision is emitted (not allow-session)', () => {
124
+ const action = getPermissionPromptInputAction('y', {});
125
+
126
+ const result = applyPermissionPromptInput(createSelectionFlowState(), action!);
127
+
128
+ expect(result.effect).toEqual({ type: 'resolve', decision: true });
129
+ });
91
130
  });
@@ -0,0 +1,64 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { generateSessionName } from '../session-naming.js';
3
+ import type { IAIProvider } from '@robota-sdk/agent-core';
4
+
5
+ function makeProvider(responseContent: string): IAIProvider {
6
+ return {
7
+ name: 'mock',
8
+ version: '1.0.0',
9
+ chat: vi.fn().mockResolvedValue({ role: 'assistant', content: responseContent }),
10
+ generateResponse: vi.fn(),
11
+ supportsTools: () => false,
12
+ } as unknown as IAIProvider;
13
+ }
14
+
15
+ describe('generateSessionName', () => {
16
+ it('returns sanitized name from provider response', async () => {
17
+ const provider = makeProvider('refactor-auth-middleware');
18
+ const name = await generateSessionName(provider, 'Refactor the auth middleware');
19
+ expect(name).toBe('refactor-auth-middleware');
20
+ });
21
+
22
+ it('lowercases and strips special characters', async () => {
23
+ const provider = makeProvider('Fix: Database Connection!');
24
+ const name = await generateSessionName(provider, 'Fix database connection');
25
+ expect(name).toBe('fix-database-connection');
26
+ });
27
+
28
+ it('collapses multiple spaces to single hyphen', async () => {
29
+ const provider = makeProvider('write api docs');
30
+ const name = await generateSessionName(provider, 'Write API docs');
31
+ expect(name).toBe('write-api-docs');
32
+ });
33
+
34
+ it('falls back to sanitized first message when response is too short', async () => {
35
+ const provider = makeProvider('ok');
36
+ const name = await generateSessionName(provider, 'Fix login bug');
37
+ expect(name).toBe('fix-login-bug');
38
+ });
39
+
40
+ it('truncates long names to 60 chars', async () => {
41
+ const long = 'a'.repeat(100);
42
+ const provider = makeProvider(long);
43
+ const name = await generateSessionName(provider, 'something');
44
+ expect(name.length).toBeLessThanOrEqual(60);
45
+ });
46
+
47
+ it('passes maxTokens: 20 to provider', async () => {
48
+ const provider = makeProvider('short-name');
49
+ await generateSessionName(provider, 'test');
50
+ expect(provider.chat).toHaveBeenCalledWith(
51
+ expect.any(Array),
52
+ expect.objectContaining({ maxTokens: 20 }),
53
+ );
54
+ });
55
+
56
+ it('truncates first message to 200 chars before sending', async () => {
57
+ const long = 'x'.repeat(500);
58
+ const provider = makeProvider('short-name');
59
+ await generateSessionName(provider, long);
60
+ const messages = (provider.chat as ReturnType<typeof vi.fn>).mock.calls[0][0];
61
+ const userMsg = messages.find((m: { role: string }) => m.role === 'user');
62
+ expect(userMsg.content.length).toBeLessThanOrEqual(200);
63
+ });
64
+ });