@robota-sdk/agent-transport 3.0.0-beta.71 → 3.0.0-beta.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/tui/index.cjs +1 -1
- package/dist/node/tui/index.js +1 -1
- package/dist/node/{tui-Bl-bm9iA.js → tui-4hA-SMtS.js} +2 -2
- package/dist/node/{tui-Bl-bm9iA.js.map → tui-4hA-SMtS.js.map} +1 -1
- package/dist/node/{tui-DULGN7sr.cjs → tui-CcLmEJ1r.cjs} +1 -1
- package/package.json +6 -6
- package/src/tui/App.tsx +2 -4
|
@@ -21,4 +21,4 @@ _(interrupted)_`:``)):t})})]})});function Vt({entry:e}){let t=e.data,r=t?.tools,
|
|
|
21
21
|
| |_) | | | | _ \\| | | || | / _ \\
|
|
22
22
|
| _ <| |_| | |_) | |_| || |/ ___ \\
|
|
23
23
|
|_| \\_\\\\___/|____/ \\___/ |_/_/ \\_\\
|
|
24
|
-
`}),(0,o.jsxs)(n.Text,{dimColor:!0,children:[` v`,e.version]})]},`logo`)}),R&&(0,o.jsx)(jn,{message:R}),(0,o.jsxs)(n.Box,{flexDirection:`column`,paddingX:1,flexGrow:1,children:[K&&K.kind!==`main_thread`?(0,o.jsx)(D,{entry:K,page:re,loading:U,error:ae}):(0,o.jsx)(Wt,{history:d}),y&&(0,o.jsx)(n.Box,{marginBottom:1,children:(0,o.jsx)(n.Text,{color:`yellow`,children:`Shutting down...`})}),(_||g.length>0)&&(0,o.jsx)(n.Box,{flexDirection:`column`,marginBottom:1,children:(0,o.jsx)(Dn,{text:h,activeTools:g,isThinking:_})}),(0,o.jsx)(T,{entries:fe})]}),B&&(0,o.jsx)(ee,{snapshot:x,selectedEntryId:S,onSelect:C,onClose:()=>V(!1)}),O&&(0,o.jsx)(Zt,{request:O}),q&&(0,o.jsx)(rt,{prompt:q,onSubmit:ve,onCancel:ye}),J&&(0,o.jsx)(dn,{callbacks:te,onClose:()=>he(!1),addMessage:e=>f((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(e.content)))}),X&&e.transportRegistry&&(0,o.jsx)(An,{registry:e.transportRegistry,onClose:()=>_e(!1)}),Y&&(0,o.jsx)(fn,{sessions:(0,t.listResumableSessionSummaries)(e.sessionStore,e.cwd),onSelect:t=>{ge(!1),e.onSessionSwitch(t)},onCancel:()=>{ge(!1),f((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(`Session resume cancelled.`)))}}),(0,o.jsx)(E,{percentage:k.percentage}),(0,o.jsx)(Cn,{cwd:i,permissionMode:$,modelId:e.modelId,providerType:e.providerType,sessionId:we,isThinking:_,activeToolCount:g.length,activeBackgroundTaskCount:pe,hasPendingPrompt:b!==null,contextState:k,sessionName:P,settings:se,activeAgentLabel:xe,gitRefreshToken:G}),(0,o.jsx)(Ye,{onSubmit:Ce,onCancelQueue:M,isDisabled:!!O||J||X||Y||B||y||q!==null||_&&!!b||!be,isAborting:v,pendingPrompt:b,registry:l,sessionName:P,history:d}),(0,o.jsx)(n.Box,{position:`absolute`,children:(0,o.jsx)(n.Text,{children:` `})})]})}var Pn=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 Fn(e,t,n,r,i,o){let s=In(e.effects,n,r,o);if(r.addEntry((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(e.message))),e.interaction!==void 0&&i.enqueueInteraction(e.interaction),s.length>0&&i.enqueueEffects(s),t.isInitialized){let e=t.getContextState();r.setContextState({percentage:e.usedPercentage,usedTokens:e.usedTokens,maxTokens:e.maxTokens})}}function In(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 Ln(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).replace(/-+/g,`-`).slice(0,60)}async function Rn(e,t){let n=t.slice(0,200),r=await e.chat([(0,a.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,a.createUserMessage)(n)],{maxTokens:20}),i=Ln(typeof r.content==`string`?r.content:``);return!i||i.length<3?Ln(t):i}function zn(e,t){let n=null;return{schedule(){n||=setTimeout(()=>{n=null,e()},t)},flush(){n&&=(clearTimeout(n),null)}}}var Bn=class{history=[];streamingText=``;activeTools=[];isThinking=!1;isAborting=!1;pendingPrompt=null;contextState={percentage:0,usedTokens:0,maxTokens:0};executionWorkspaceSnapshot=null;selectedExecutionEntryId;onChange=null;streamBuf=``;debouncedStreamNotify=zn(()=>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.activeTools=[]),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())}},Vn=class{stateManager;interactiveSession;registry;commandEffectQueue;opts;submitHandler=null;actionQueue=[];processingAction=!1;permissionRequest=null;pendingAction=null;availableCommands=[];isShuttingDown=!1;sessionName;autoNameTriggered=!1;sessionStarted=!1;initCheckInterval=null;permissionQueue=[];processingPermission=!1;onChange=null;constructor(e){this.opts=e,this.sessionName=e.sessionName,this.stateManager=new Bn,this.stateManager.onChange=()=>this.onChange?.(),this.interactiveSession=this.createSession(),this.registry=this.createRegistry(),this.commandEffectQueue=new Pn}createSession(){let e=this.opts;return new t.InteractiveSession({cwd:e.cwd,provider:e.provider,permissionMode:e.permissionMode,maxTurns:e.maxTurns,permissionHandler:(e,t)=>this.handlePermissionRequest(e,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})}createRegistry(){let e=new t.CommandRegistry;for(let t of this.opts.commandModules??[])e.addModule(t);return this.opts.reloadPluginCommandSource?.(e),e}onSubmit(e){this.submitHandler=e}write(e){}async requestAction(e){return new Promise(t=>{this.actionQueue.push({action:e,resolve:t}),this.processNextAction()})}setAvailableCommands(e){this.availableCommands=e,this.onChange?.()}setBusy(e){this.stateManager.onThinking(e)}async start(){this.sessionStarted||(this.sessionStarted=!0,this.wireSessionEvents(),this.syncRestoredHistory(),this.startInitCheck(),this.opts.transportRegistry&&await this.opts.transportRegistry.startAll(this.interactiveSession))}async stop(){this.onChange=null,this.sessionStarted=!1,this.stopInitCheck(),this.opts.transportRegistry&&await this.opts.transportRegistry.stopAll()}getSession(){return this.interactiveSession}getRegistry(){return this.registry}getCommandEffectQueue(){return this.commandEffectQueue}abort(){this.stateManager.setAborting(!0),this.interactiveSession.abort()}cancelQueue(){this.interactiveSession.cancelQueue(),this.stateManager.setPendingPrompt(null)}async shutdown(e){this.isShuttingDown||(this.isShuttingDown=!0,this.stateManager.addEntry((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(`Shutting down...`))),this.onChange?.(),await this.interactiveSession.shutdown({reason:e?.reason??`prompt_input_exit`,message:`CLI shutdown`}))}selectExecutionWorkspaceEntry(e){this.stateManager.selectExecutionWorkspaceEntry(e)}async readExecutionWorkspaceDetail(e){return this.interactiveSession.readExecutionWorkspaceDetail(e)}async sendAgentJob(e,t){await this.interactiveSession.sendAgentJob(e,t)}setSessionName(e){this.sessionName=e,this.interactiveSession.setName(e),this.onChange?.()}resolveAction(e){let t=this.actionQueue[0];t&&(this.actionQueue.shift(),this.processingAction=!1,this.pendingAction=null,this.onChange?.(),t.resolve(e),this.processNextAction())}async handleInput(e){if(!e.startsWith(`/`)){await this.interactiveSession.submit(e),this.stateManager.setPendingPrompt(this.interactiveSession.getPendingPrompt());return}await this.handleSlashCommand(e)}async handleSlashCommand(e){let t=e.slice(1).split(/\s+/),n=t[0]?.toLowerCase()??``,r=t.slice(1).join(` `),i=await this.interactiveSession.executeCommand(n,r);if(i){if(i.effects?.some(e=>e.type===`session-execution-started`)){this.stateManager.setPendingPrompt(this.interactiveSession.getPendingPrompt());return}Fn(i,this.interactiveSession,this.registry,this.stateManager,this.commandEffectQueue,this.opts.reloadPluginCommandSource);return}this.stateManager.addEntry((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(`Unknown command "/${n}". Type /help for help.`)))}processNextAction(){if(this.processingAction)return;let e=this.actionQueue[0];if(!e){this.pendingAction=null,this.onChange?.();return}this.processingAction=!0,this.pendingAction=e.action,this.onChange?.()}handlePermissionRequest(e,t){return new Promise(n=>{this.permissionQueue.push({toolName:e,toolArgs:t,resolve:n}),this.processNextPermission()})}processNextPermission(){if(this.processingPermission)return;let e=this.permissionQueue[0];if(!e){this.permissionRequest=null,this.onChange?.();return}this.processingPermission=!0,this.permissionRequest={toolName:e.toolName,toolArgs:e.toolArgs,resolve:t=>{this.permissionQueue.shift(),this.processingPermission=!1,this.permissionRequest=null,e.resolve(t),setTimeout(()=>this.processNextPermission(),0)}},this.onChange?.()}wireSessionEvents(){let e=this.interactiveSession,t=this.stateManager;e.on(`user_message`,e=>{this.handleAutoNaming(e),t.addEntry((0,a.messageToHistoryEntry)((0,a.createUserMessage)(e)))}),e.on(`text_delta`,t.onTextDelta),e.on(`tool_start`,t.onToolStart),e.on(`tool_end`,t.onToolEnd),e.on(`thinking`,t.onThinking),e.on(`complete`,n=>{t.onComplete(n),t.syncHistory(e.getFullHistory())}),e.on(`interrupted`,t.onInterrupted),e.on(`error`,()=>{t.onError(),t.syncHistory(e.getFullHistory())}),e.on(`context_update`,t.onContextUpdate),e.on(`compact`,()=>{t.syncHistory(e.getFullHistory())}),e.on(`skill_activation`,()=>{t.syncHistory(e.getFullHistory())}),e.on(`execution_workspace_event`,e=>{t.syncExecutionWorkspaceSnapshot(e.snapshot)})}handleAutoNaming(e){this.autoNameTriggered||this.opts.sessionName||this.interactiveSession.getName()||(this.autoNameTriggered=!0,Rn(this.opts.provider,e).then(e=>{this.interactiveSession.setName(e),this.sessionName=e,this.opts.onAutoNamed?.(e),this.onChange?.()}).catch(()=>{this.autoNameTriggered=!1}))}syncRestoredHistory(){if(this.stateManager.history.length===0){let e=this.interactiveSession.getFullHistory();e.length>0&&this.stateManager.syncHistory(e)}}startInitCheck(){this.initCheckInterval=setInterval(()=>{this.runInitCheck()},200)}runInitCheck(){try{let e=this.interactiveSession.getContextState();this.stateManager.setContextState({percentage:e.usedPercentage,usedTokens:e.usedTokens,maxTokens:e.maxTokens});let t=this.interactiveSession.getFullHistory();t.length>0&&this.stateManager.syncHistory(t),this.syncExecutionWorkspace(),this.stopInitCheck()}catch{}}stopInitCheck(){this.initCheckInterval!==null&&(clearInterval(this.initCheckInterval),this.initCheckInterval=null)}syncExecutionWorkspace(){try{this.stateManager.syncExecutionWorkspaceSnapshot(this.interactiveSession.getExecutionWorkspaceSnapshot({selectedEntryId:this.stateManager.selectedExecutionEntryId}))}catch{}}};async function Hn(e){process.on(`unhandledRejection`,e=>{process.stderr.write(`\n[UNHANDLED REJECTION] ${e}\n`),e instanceof Error&&process.stderr.write(`${e.stack}\n`)});let t=t=>new Vn({cwd:e.cwd,provider:e.provider,permissionMode:e.permissionMode,maxTurns:e.maxTurns,sessionStore:e.sessionStore,resumeSessionId:t,forkSession:e.forkSession,sessionName:e.sessionName,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}),r=t(e.resumeSessionId);await(0,n.render)((0,o.jsx)(Mn,{cwd:e.cwd,channel:r,createChannel:t,providerOverride:e.providerOverride,providerType:e.providerType,modelId:e.modelId,permissionMode:e.permissionMode,version:e.version,sessionStore:e.sessionStore,resumeSessionId:e.resumeSessionId,showSessionPickerOnStart:e.showSessionPickerOnStart,startupUpdateNotice:e.startupUpdateNotice,transportRegistry:e.transportRegistry,cliAdapter:e.cliAdapter}),{exitOnCtrlC:!1}).waitUntilExit()}var Un=class{name=`tui`;defaultEnabled=!0;optionsSchema={};options;constructor(e){this.options=e}attach(e){}async start(){await Hn(this.options)}async stop(){}validateOptions(e){return!0}};function Wn({providerDefinitions:e,reloadPluginCommandSource:n}){return{getUserSettingsPath:()=>(0,t.getUserSettingsPath)(),readSettings:e=>(0,t.readSettings)(e),writeSettings:(e,n)=>(0,t.writeSettings)(e,n),deleteSettings:e=>(0,t.deleteSettings)(e),applyStatusLineSettings:(e,n)=>(0,t.applyStatusLineSettings)(e,n),reloadPluginCommandSource:e=>{n(e)},applyActiveModelChange:(e,n,r)=>((0,t.applyActiveModelChange)(e,n,r),{applied:!0}),getGitBranch:e=>(0,t.resolveGitBranch)(e),getProviderDisplayName:t=>(0,a.findProviderDefinition)(e,t)?.displayName??t}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Un}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Wn}});
|
|
24
|
+
`}),(0,o.jsxs)(n.Text,{dimColor:!0,children:[` v`,e.version]})]},`logo`)}),R&&(0,o.jsx)(jn,{message:R}),(0,o.jsxs)(n.Box,{flexDirection:`column`,paddingX:1,flexGrow:1,children:[K&&K.kind!==`main_thread`?(0,o.jsx)(D,{entry:K,page:re,loading:U,error:ae}):(0,o.jsx)(Wt,{history:d}),y&&(0,o.jsx)(n.Box,{marginBottom:1,children:(0,o.jsx)(n.Text,{color:`yellow`,children:`Shutting down...`})}),(_||g.length>0)&&(0,o.jsx)(n.Box,{flexDirection:`column`,marginBottom:1,children:(0,o.jsx)(Dn,{text:h,activeTools:g,isThinking:_})}),(0,o.jsx)(T,{entries:fe})]}),B&&(0,o.jsx)(ee,{snapshot:x,selectedEntryId:S,onSelect:C,onClose:()=>V(!1)}),O&&(0,o.jsx)(Zt,{request:O}),q&&(0,o.jsx)(rt,{prompt:q,onSubmit:ve,onCancel:ye}),J&&(0,o.jsx)(dn,{callbacks:te,onClose:()=>he(!1),addMessage:e=>f((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(e.content)))}),X&&e.transportRegistry&&(0,o.jsx)(An,{registry:e.transportRegistry,onClose:()=>_e(!1)}),Y&&(0,o.jsx)(fn,{sessions:(0,t.listResumableSessionSummaries)(e.sessionStore,e.cwd),onSelect:t=>{ge(!1),e.onSessionSwitch(t)},onCancel:()=>{ge(!1),f((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(`Session resume cancelled.`)))}}),(0,o.jsx)(E,{percentage:k.percentage}),(0,o.jsx)(Cn,{cwd:i,permissionMode:$,modelId:e.modelId,providerType:e.providerType,sessionId:we,isThinking:_,activeToolCount:g.length,activeBackgroundTaskCount:pe,hasPendingPrompt:b!==null,contextState:k,sessionName:P,settings:se,activeAgentLabel:xe,gitRefreshToken:G}),(0,o.jsx)(Ye,{onSubmit:Ce,onCancelQueue:M,isDisabled:!!O||J||X||Y||B||y||q!==null||_&&!!b||!be,isAborting:v,pendingPrompt:b,registry:l,sessionName:P,history:d}),(0,o.jsx)(n.Text,{children:` `})]})}var Pn=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 Fn(e,t,n,r,i,o){let s=In(e.effects,n,r,o);if(r.addEntry((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(e.message))),e.interaction!==void 0&&i.enqueueInteraction(e.interaction),s.length>0&&i.enqueueEffects(s),t.isInitialized){let e=t.getContextState();r.setContextState({percentage:e.usedPercentage,usedTokens:e.usedTokens,maxTokens:e.maxTokens})}}function In(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 Ln(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,``).trim().replace(/\s+/g,`-`).replace(/-+/g,`-`).slice(0,60)}async function Rn(e,t){let n=t.slice(0,200),r=await e.chat([(0,a.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,a.createUserMessage)(n)],{maxTokens:20}),i=Ln(typeof r.content==`string`?r.content:``);return!i||i.length<3?Ln(t):i}function zn(e,t){let n=null;return{schedule(){n||=setTimeout(()=>{n=null,e()},t)},flush(){n&&=(clearTimeout(n),null)}}}var Bn=class{history=[];streamingText=``;activeTools=[];isThinking=!1;isAborting=!1;pendingPrompt=null;contextState={percentage:0,usedTokens:0,maxTokens:0};executionWorkspaceSnapshot=null;selectedExecutionEntryId;onChange=null;streamBuf=``;debouncedStreamNotify=zn(()=>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.activeTools=[]),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())}},Vn=class{stateManager;interactiveSession;registry;commandEffectQueue;opts;submitHandler=null;actionQueue=[];processingAction=!1;permissionRequest=null;pendingAction=null;availableCommands=[];isShuttingDown=!1;sessionName;autoNameTriggered=!1;sessionStarted=!1;initCheckInterval=null;permissionQueue=[];processingPermission=!1;onChange=null;constructor(e){this.opts=e,this.sessionName=e.sessionName,this.stateManager=new Bn,this.stateManager.onChange=()=>this.onChange?.(),this.interactiveSession=this.createSession(),this.registry=this.createRegistry(),this.commandEffectQueue=new Pn}createSession(){let e=this.opts;return new t.InteractiveSession({cwd:e.cwd,provider:e.provider,permissionMode:e.permissionMode,maxTurns:e.maxTurns,permissionHandler:(e,t)=>this.handlePermissionRequest(e,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})}createRegistry(){let e=new t.CommandRegistry;for(let t of this.opts.commandModules??[])e.addModule(t);return this.opts.reloadPluginCommandSource?.(e),e}onSubmit(e){this.submitHandler=e}write(e){}async requestAction(e){return new Promise(t=>{this.actionQueue.push({action:e,resolve:t}),this.processNextAction()})}setAvailableCommands(e){this.availableCommands=e,this.onChange?.()}setBusy(e){this.stateManager.onThinking(e)}async start(){this.sessionStarted||(this.sessionStarted=!0,this.wireSessionEvents(),this.syncRestoredHistory(),this.startInitCheck(),this.opts.transportRegistry&&await this.opts.transportRegistry.startAll(this.interactiveSession))}async stop(){this.onChange=null,this.sessionStarted=!1,this.stopInitCheck(),this.opts.transportRegistry&&await this.opts.transportRegistry.stopAll()}getSession(){return this.interactiveSession}getRegistry(){return this.registry}getCommandEffectQueue(){return this.commandEffectQueue}abort(){this.stateManager.setAborting(!0),this.interactiveSession.abort()}cancelQueue(){this.interactiveSession.cancelQueue(),this.stateManager.setPendingPrompt(null)}async shutdown(e){this.isShuttingDown||(this.isShuttingDown=!0,this.stateManager.addEntry((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(`Shutting down...`))),this.onChange?.(),await this.interactiveSession.shutdown({reason:e?.reason??`prompt_input_exit`,message:`CLI shutdown`}))}selectExecutionWorkspaceEntry(e){this.stateManager.selectExecutionWorkspaceEntry(e)}async readExecutionWorkspaceDetail(e){return this.interactiveSession.readExecutionWorkspaceDetail(e)}async sendAgentJob(e,t){await this.interactiveSession.sendAgentJob(e,t)}setSessionName(e){this.sessionName=e,this.interactiveSession.setName(e),this.onChange?.()}resolveAction(e){let t=this.actionQueue[0];t&&(this.actionQueue.shift(),this.processingAction=!1,this.pendingAction=null,this.onChange?.(),t.resolve(e),this.processNextAction())}async handleInput(e){if(!e.startsWith(`/`)){await this.interactiveSession.submit(e),this.stateManager.setPendingPrompt(this.interactiveSession.getPendingPrompt());return}await this.handleSlashCommand(e)}async handleSlashCommand(e){let t=e.slice(1).split(/\s+/),n=t[0]?.toLowerCase()??``,r=t.slice(1).join(` `),i=await this.interactiveSession.executeCommand(n,r);if(i){if(i.effects?.some(e=>e.type===`session-execution-started`)){this.stateManager.setPendingPrompt(this.interactiveSession.getPendingPrompt());return}Fn(i,this.interactiveSession,this.registry,this.stateManager,this.commandEffectQueue,this.opts.reloadPluginCommandSource);return}this.stateManager.addEntry((0,a.messageToHistoryEntry)((0,a.createSystemMessage)(`Unknown command "/${n}". Type /help for help.`)))}processNextAction(){if(this.processingAction)return;let e=this.actionQueue[0];if(!e){this.pendingAction=null,this.onChange?.();return}this.processingAction=!0,this.pendingAction=e.action,this.onChange?.()}handlePermissionRequest(e,t){return new Promise(n=>{this.permissionQueue.push({toolName:e,toolArgs:t,resolve:n}),this.processNextPermission()})}processNextPermission(){if(this.processingPermission)return;let e=this.permissionQueue[0];if(!e){this.permissionRequest=null,this.onChange?.();return}this.processingPermission=!0,this.permissionRequest={toolName:e.toolName,toolArgs:e.toolArgs,resolve:t=>{this.permissionQueue.shift(),this.processingPermission=!1,this.permissionRequest=null,e.resolve(t),setTimeout(()=>this.processNextPermission(),0)}},this.onChange?.()}wireSessionEvents(){let e=this.interactiveSession,t=this.stateManager;e.on(`user_message`,e=>{this.handleAutoNaming(e),t.addEntry((0,a.messageToHistoryEntry)((0,a.createUserMessage)(e)))}),e.on(`text_delta`,t.onTextDelta),e.on(`tool_start`,t.onToolStart),e.on(`tool_end`,t.onToolEnd),e.on(`thinking`,t.onThinking),e.on(`complete`,n=>{t.onComplete(n),t.syncHistory(e.getFullHistory())}),e.on(`interrupted`,t.onInterrupted),e.on(`error`,()=>{t.onError(),t.syncHistory(e.getFullHistory())}),e.on(`context_update`,t.onContextUpdate),e.on(`compact`,()=>{t.syncHistory(e.getFullHistory())}),e.on(`skill_activation`,()=>{t.syncHistory(e.getFullHistory())}),e.on(`execution_workspace_event`,e=>{t.syncExecutionWorkspaceSnapshot(e.snapshot)})}handleAutoNaming(e){this.autoNameTriggered||this.opts.sessionName||this.interactiveSession.getName()||(this.autoNameTriggered=!0,Rn(this.opts.provider,e).then(e=>{this.interactiveSession.setName(e),this.sessionName=e,this.opts.onAutoNamed?.(e),this.onChange?.()}).catch(()=>{this.autoNameTriggered=!1}))}syncRestoredHistory(){if(this.stateManager.history.length===0){let e=this.interactiveSession.getFullHistory();e.length>0&&this.stateManager.syncHistory(e)}}startInitCheck(){this.initCheckInterval=setInterval(()=>{this.runInitCheck()},200)}runInitCheck(){try{let e=this.interactiveSession.getContextState();this.stateManager.setContextState({percentage:e.usedPercentage,usedTokens:e.usedTokens,maxTokens:e.maxTokens});let t=this.interactiveSession.getFullHistory();t.length>0&&this.stateManager.syncHistory(t),this.syncExecutionWorkspace(),this.stopInitCheck()}catch{}}stopInitCheck(){this.initCheckInterval!==null&&(clearInterval(this.initCheckInterval),this.initCheckInterval=null)}syncExecutionWorkspace(){try{this.stateManager.syncExecutionWorkspaceSnapshot(this.interactiveSession.getExecutionWorkspaceSnapshot({selectedEntryId:this.stateManager.selectedExecutionEntryId}))}catch{}}};async function Hn(e){process.on(`unhandledRejection`,e=>{process.stderr.write(`\n[UNHANDLED REJECTION] ${e}\n`),e instanceof Error&&process.stderr.write(`${e.stack}\n`)});let t=t=>new Vn({cwd:e.cwd,provider:e.provider,permissionMode:e.permissionMode,maxTurns:e.maxTurns,sessionStore:e.sessionStore,resumeSessionId:t,forkSession:e.forkSession,sessionName:e.sessionName,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}),r=t(e.resumeSessionId);await(0,n.render)((0,o.jsx)(Mn,{cwd:e.cwd,channel:r,createChannel:t,providerOverride:e.providerOverride,providerType:e.providerType,modelId:e.modelId,permissionMode:e.permissionMode,version:e.version,sessionStore:e.sessionStore,resumeSessionId:e.resumeSessionId,showSessionPickerOnStart:e.showSessionPickerOnStart,startupUpdateNotice:e.startupUpdateNotice,transportRegistry:e.transportRegistry,cliAdapter:e.cliAdapter}),{exitOnCtrlC:!1}).waitUntilExit()}var Un=class{name=`tui`;defaultEnabled=!0;optionsSchema={};options;constructor(e){this.options=e}attach(e){}async start(){await Hn(this.options)}async stop(){}validateOptions(e){return!0}};function Wn({providerDefinitions:e,reloadPluginCommandSource:n}){return{getUserSettingsPath:()=>(0,t.getUserSettingsPath)(),readSettings:e=>(0,t.readSettings)(e),writeSettings:(e,n)=>(0,t.writeSettings)(e,n),deleteSettings:e=>(0,t.deleteSettings)(e),applyStatusLineSettings:(e,n)=>(0,t.applyStatusLineSettings)(e,n),reloadPluginCommandSource:e=>{n(e)},applyActiveModelChange:(e,n,r)=>((0,t.applyActiveModelChange)(e,n,r),{applied:!0}),getGitBranch:e=>(0,t.resolveGitBranch)(e),getProviderDisplayName:t=>(0,a.findProviderDefinition)(e,t)?.displayName??t}}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Un}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Wn}});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-transport",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.72",
|
|
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",
|
|
@@ -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-
|
|
112
|
-
"@robota-sdk/agent-
|
|
113
|
-
"@robota-sdk/agent-
|
|
114
|
-
"@robota-sdk/agent-
|
|
111
|
+
"@robota-sdk/agent-interface-transport": "3.0.0-beta.72",
|
|
112
|
+
"@robota-sdk/agent-core": "3.0.0-beta.72",
|
|
113
|
+
"@robota-sdk/agent-interface-tui": "3.0.0-beta.72",
|
|
114
|
+
"@robota-sdk/agent-framework": "3.0.0-beta.72"
|
|
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.
|
|
127
|
+
"@robota-sdk/agent-command": "3.0.0-beta.72"
|
|
128
128
|
},
|
|
129
129
|
"license": "MIT",
|
|
130
130
|
"publishConfig": {
|
package/src/tui/App.tsx
CHANGED
|
@@ -472,10 +472,8 @@ function AppInner(
|
|
|
472
472
|
sessionName={sessionName}
|
|
473
473
|
history={history}
|
|
474
474
|
/>
|
|
475
|
-
{/* Blank line for Korean IME —
|
|
476
|
-
<
|
|
477
|
-
<Text> </Text>
|
|
478
|
-
</Box>
|
|
475
|
+
{/* Blank line for Korean IME — normal flow ensures it persists across remounts. */}
|
|
476
|
+
<Text> </Text>
|
|
479
477
|
</Box>
|
|
480
478
|
);
|
|
481
479
|
}
|