@burtson-labs/bandit-stealth-cli 1.7.355 → 1.7.357

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 (2) hide show
  1. package/dist/cli.js +2 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -393,7 +393,7 @@ ${Dn}`,O++;return}if(kAt(Ke,ot,St)){$=Ke.slice(Ke.charCodeAt(ot+6)===pJ?ot+7:ot+
393
393
  ${ot}`,O++;break;case"id":E=ot.includes("\0")?void 0:ot;break;case"retry":/^\d+$/.test(ot)?u(parseInt(ot,10)):o(new eae(`Invalid \`retry\` value: "${ot}"`,{type:"invalid-retry",value:ot,line:dt}));break;default:o(new eae(`Unknown field "${Ke.length>20?`${Ke.slice(0,20)}\u2026`:Ke}"`,{type:"unknown-field",field:Ke,value:ot,line:dt}));break}}t(oe,"processField");function me(){O>0&&i({id:E,event:$,data:P}),E=void 0,P="",O=0,$=void 0}t(me,"dispatchEvent");function Re(Ke={}){if(Ke.consume&&m.length>0){let ot=m.join("");ce(ot,0,ot.length)}A=!0,E=void 0,P="",O=0,$=void 0,m.length=0}return t(Re,"reset"),{feed:q,reset:Re}}t(h2n,"createParser");function xAt(r,i,o){return o===100&&r.charCodeAt(i+1)===97&&r.charCodeAt(i+2)===116&&r.charCodeAt(i+3)===97&&r.charCodeAt(i+4)===58}t(xAt,"isDataPrefix");function kAt(r,i,o){return o===101&&r.charCodeAt(i+1)===118&&r.charCodeAt(i+2)===101&&r.charCodeAt(i+3)===110&&r.charCodeAt(i+4)===116&&r.charCodeAt(i+5)===58}t(kAt,"isEventPrefix");Lve.ParseError=eae;Lve.createParser=h2n});var PAt=Lt(jve=>{"use strict";Object.defineProperty(jve,"__esModule",{value:!0});var DAt=IAt(),HFe=class extends TransformStream{static{t(this,"EventSourceParserStream")}constructor({onError:i,onRetry:o,onComment:u}={}){let l;super({start(m){l=DAt.createParser({onEvent:t(A=>{m.enqueue(A)},"onEvent"),onError(A){i==="terminate"?m.error(A):typeof i=="function"&&i(A)},onRetry:o,onComment:u})},transform(m){l.feed(m)}})}};jve.ParseError=DAt.ParseError;jve.EventSourceParserStream=HFe});var OAt=Lt(NZ=>{"use strict";Object.defineProperty(NZ,"__esModule",{value:!0});NZ.StreamableHTTPClientTransport=NZ.StreamableHTTPError=void 0;var NAt=cAt(),PZ=xR(),QP=TAt(),y2n=PAt(),v2n={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},T7=class extends Error{static{t(this,"StreamableHTTPError")}constructor(i,o){super(`Streamable HTTP error: ${o}`),this.code=i}};NZ.StreamableHTTPError=T7;var GFe=class{static{t(this,"StreamableHTTPClientTransport")}constructor(i,o){this._hasCompletedAuthFlow=!1,this._url=i,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=o?.requestInit,this._authProvider=o?.authProvider,this._fetch=o?.fetch,this._fetchWithInit=(0,NAt.createFetchWithInit)(o?.fetch,o?.requestInit),this._sessionId=o?.sessionId,this._reconnectionOptions=o?.reconnectionOptions??v2n}async _authThenStart(){if(!this._authProvider)throw new QP.UnauthorizedError("No auth provider");let i;try{i=await(0,QP.auth)(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(o){throw this.onerror?.(o),o}if(i!=="AUTHORIZED")throw new QP.UnauthorizedError;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let i={};if(this._authProvider){let u=await this._authProvider.tokens();u&&(i.Authorization=`Bearer ${u.access_token}`)}this._sessionId&&(i["mcp-session-id"]=this._sessionId),this._protocolVersion&&(i["mcp-protocol-version"]=this._protocolVersion);let o=(0,NAt.normalizeHeaders)(this._requestInit?.headers);return new Headers({...i,...o})}async _startOrAuthSse(i){let{resumptionToken:o}=i;try{let u=await this._commonHeaders();u.set("Accept","text/event-stream"),o&&u.set("last-event-id",o);let l=await(this._fetch??fetch)(this._url,{method:"GET",headers:u,signal:this._abortController?.signal});if(!l.ok){if(await l.body?.cancel(),l.status===401&&this._authProvider)return await this._authThenStart();if(l.status===405)return;throw new T7(l.status,`Failed to open SSE stream: ${l.statusText}`)}this._handleSseStream(l.body,i,!0)}catch(u){throw this.onerror?.(u),u}}_getNextReconnectionDelay(i){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let o=this._reconnectionOptions.initialReconnectionDelay,u=this._reconnectionOptions.reconnectionDelayGrowFactor,l=this._reconnectionOptions.maxReconnectionDelay;return Math.min(o*Math.pow(u,i),l)}_scheduleReconnection(i,o=0){let u=this._reconnectionOptions.maxRetries;if(o>=u){this.onerror?.(new Error(`Maximum reconnection attempts (${u}) exceeded.`));return}let l=this._getNextReconnectionDelay(o);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(i).catch(m=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${m instanceof Error?m.message:String(m)}`)),this._scheduleReconnection(i,o+1)})},l)}_handleSseStream(i,o,u){if(!i)return;let{onresumptiontoken:l,replayMessageId:m}=o,A,E=!1,P=!1;t(async()=>{try{let $=i.pipeThrough(new TextDecoderStream).pipeThrough(new y2n.EventSourceParserStream({onRetry:t(ce=>{this._serverRetryMs=ce},"onRetry")})).getReader();for(;;){let{value:ce,done:oe}=await $.read();if(oe)break;if(ce.id&&(A=ce.id,E=!0,l?.(ce.id)),!!ce.data&&(!ce.event||ce.event==="message"))try{let me=PZ.JSONRPCMessageSchema.parse(JSON.parse(ce.data));(0,PZ.isJSONRPCResultResponse)(me)&&(P=!0,m!==void 0&&(me.id=m)),this.onmessage?.(me)}catch(me){this.onerror?.(me)}}(u||E)&&!P&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:A,onresumptiontoken:l,replayMessageId:m},0)}catch($){if(this.onerror?.(new Error(`SSE stream disconnected: ${$}`)),(u||E)&&!P&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:A,onresumptiontoken:l,replayMessageId:m},0)}catch(ce){this.onerror?.(new Error(`Failed to reconnect: ${ce instanceof Error?ce.message:String(ce)}`))}}},"processStream")()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(i){if(!this._authProvider)throw new QP.UnauthorizedError("No auth provider");if(await(0,QP.auth)(this._authProvider,{serverUrl:this._url,authorizationCode:i,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new QP.UnauthorizedError("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(i,o){try{let{resumptionToken:u,onresumptiontoken:l}=o||{};if(u){this._startOrAuthSse({resumptionToken:u,replayMessageId:(0,PZ.isJSONRPCRequest)(i)?i.id:void 0}).catch(U=>this.onerror?.(U));return}let m=await this._commonHeaders();m.set("content-type","application/json"),m.set("accept","application/json, text/event-stream");let A={...this._requestInit,method:"POST",headers:m,body:JSON.stringify(i),signal:this._abortController?.signal},E=await(this._fetch??fetch)(this._url,A),P=E.headers.get("mcp-session-id");if(P&&(this._sessionId=P),!E.ok){let U=await E.text().catch(()=>null);if(E.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new T7(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:ce,scope:oe}=(0,QP.extractWWWAuthenticateParams)(E);if(this._resourceMetadataUrl=ce,this._scope=oe,await(0,QP.auth)(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new QP.UnauthorizedError;return this._hasCompletedAuthFlow=!0,this.send(i)}if(E.status===403&&this._authProvider){let{resourceMetadataUrl:ce,scope:oe,error:me}=(0,QP.extractWWWAuthenticateParams)(E);if(me==="insufficient_scope"){let Re=E.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===Re)throw new T7(403,"Server returned 403 after trying upscoping");if(oe&&(this._scope=oe),ce&&(this._resourceMetadataUrl=ce),this._lastUpscopingHeader=Re??void 0,await(0,QP.auth)(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new QP.UnauthorizedError;return this.send(i)}}throw new T7(E.status,`Error POSTing to endpoint: ${U}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,E.status===202){await E.body?.cancel(),(0,PZ.isInitializedNotification)(i)&&this._startOrAuthSse({resumptionToken:void 0}).catch(U=>this.onerror?.(U));return}let $=(Array.isArray(i)?i:[i]).filter(U=>"method"in U&&"id"in U&&U.id!==void 0).length>0,q=E.headers.get("content-type");if($)if(q?.includes("text/event-stream"))this._handleSseStream(E.body,{onresumptiontoken:l},!1);else if(q?.includes("application/json")){let U=await E.json(),ce=Array.isArray(U)?U.map(oe=>PZ.JSONRPCMessageSchema.parse(oe)):[PZ.JSONRPCMessageSchema.parse(U)];for(let oe of ce)this.onmessage?.(oe)}else throw await E.body?.cancel(),new T7(-1,`Unexpected content type: ${q}`);else await E.body?.cancel()}catch(u){throw this.onerror?.(u),u}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let i=await this._commonHeaders(),o={...this._requestInit,method:"DELETE",headers:i,signal:this._abortController?.signal},u=await(this._fetch??fetch)(this._url,o);if(await u.body?.cancel(),!u.ok&&u.status!==405)throw new T7(u.status,`Failed to terminate session: ${u.statusText}`);this._sessionId=void 0}catch(i){throw this.onerror?.(i),i}}setProtocolVersion(i){this._protocolVersion=i}get protocolVersion(){return this._protocolVersion}async resumeStream(i,o){await this._startOrAuthSse({resumptionToken:i,onresumptiontoken:o?.onresumptiontoken})}};NZ.StreamableHTTPClientTransport=GFe});var MAt=Lt(w4=>{"use strict";var A2n=w4&&w4.__createBinding||(Object.create?(function(r,i,o,u){u===void 0&&(u=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:t(function(){return i[o]},"get")}),Object.defineProperty(r,u,l)}):(function(r,i,o,u){u===void 0&&(u=o),r[u]=i[o]})),b2n=w4&&w4.__setModuleDefault||(Object.create?(function(r,i){Object.defineProperty(r,"default",{enumerable:!0,value:i})}):function(r,i){r.default=i}),S2n=w4&&w4.__importStar||(function(){var r=t(function(i){return r=Object.getOwnPropertyNames||function(o){var u=[];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(u[u.length]=l);return u},r(i)},"ownKeys");return function(i){if(i&&i.__esModule)return i;var o={};if(i!=null)for(var u=r(i),l=0;l<u.length;l++)u[l]!=="default"&&A2n(o,i,u[l]);return b2n(o,i),o}})();Object.defineProperty(w4,"__esModule",{value:!0});w4.McpClientPool=void 0;w4.fingerprintServerConfig=tae;var RAt=S2n(ps("crypto"));function tae(r,i){if(i.url){let u={name:r,kind:"url",url:i.url,authKind:BAt(i.auth)};return RAt.createHash("sha256").update(JSON.stringify(u)).digest("hex").slice(0,16)}let o={name:r,kind:"stdio",command:i.command??"",args:i.args??[],envKeys:Object.keys(i.env??{}).sort()};return RAt.createHash("sha256").update(JSON.stringify(o)).digest("hex").slice(0,16)}t(tae,"fingerprintServerConfig");var VFe=null,WFe=null,ZFe=null;function C2n(){return VFe||(VFe=_vt().Client),WFe||(WFe=oAt().StdioClientTransport),ZFe||(ZFe=OAt().StreamableHTTPClientTransport),{Client:VFe,StdioClientTransport:WFe,StreamableHTTPClientTransport:ZFe}}t(C2n,"loadMcpSdk");function BAt(r){return r?r==="bandit"||r.type==="bandit-api-key"?"bandit-api-key":r.type==="bearer"?"bearer":r.type==="header"?`header(${r.name})`:"unknown":"none"}t(BAt,"describeAuth");var KFe=class{static{t(this,"McpClientPool")}constructor(i={}){this.entries=new Map,this.trustedFingerprints=new Set,this.trustGate=i.trustGate,this.onToolsDiscovered=i.onToolsDiscovered,this.resolveAuthToken=i.resolveAuthToken}primeDiscoveryCache(i,o,u){let l=this.entries.get(i);!l||tae(i,l.config)!==o||(l.cachedTools=u)}trustFingerprint(i){this.trustedFingerprints.add(i)}register(i,o){this.entries.get(i)&&this.disposeOne(i);let l=o.disabled?{state:"disabled"}:{state:"idle"};this.entries.set(i,{config:o,status:l})}list(){return[...this.entries.keys()]}hasCachedTools(i){let o=this.entries.get(i);return!!o?.cachedTools&&o.cachedTools.length>0}snapshot(){return[...this.entries.entries()].map(([i,o])=>({name:i,config:o.config,status:o.status}))}async ensureConnected(i){let o=this.entries.get(i);return!o||o.status.state==="disabled"?!1:o.status.state==="connected"?!0:o.pendingConnect?(await o.pendingConnect,o.status.state==="connected"):o.status.state==="error"?!1:(o.status={state:"connecting"},o.pendingConnect=this.spawnAndHandshake(i,o).catch(u=>{let l=u instanceof Error?u.message:String(u);o.status={state:"error",message:l}}).finally(()=>{o.pendingConnect=void 0}),await o.pendingConnect,o.status.state==="connected")}async reconnect(i){let o=this.entries.get(i);return o?(o.status.state==="connected"||o.status.state==="connecting"?(this.disposeOne(i),this.register(i,o.config)):o.status.state==="error"&&(o.status={state:"idle"}),this.ensureConnected(i)):!1}async discoverTools(i){let o=this.entries.get(i);if(!o)return[];if(o.cachedTools)return o.cachedTools;if(!await this.ensureConnected(i))return[];try{let l=await o.client.listTools(),m=Array.isArray(l?.tools)?l.tools:[];if(o.cachedTools=m,o.status={state:"connected",toolCount:m.length},this.onToolsDiscovered)try{this.onToolsDiscovered(i,tae(i,o.config),m)}catch{}return m}catch(l){let m=l instanceof Error?l.message:String(l);return o.status={state:"error",message:m},[]}}async callTool(i,o,u){let l=this.entries.get(i);if(!l)throw new Error(`MCP server "${i}" is not registered.`);if(!await this.ensureConnected(i)){let E=l.status.state==="error"?l.status.message:`state=${l.status.state}`;throw new Error(`MCP server "${i}" is not connected (${E}).`)}return await l.client.callTool({name:o,arguments:u})}async dispose(){for(let i of[...this.entries.keys()])this.disposeOne(i)}disposeOne(i){let o=this.entries.get(i);if(o){try{o.transport?.close?.()}catch{}try{o.client?.close?.()}catch{}this.entries.delete(i)}}async spawnAndHandshake(i,o){let{Client:u,StdioClientTransport:l,StreamableHTTPClientTransport:m}=C2n();if(o.config.url){if(this.trustGate){let q=tae(i,o.config);if(!this.trustedFingerprints.has(q)){if(!await this.trustGate({kind:"url",name:i,url:o.config.url,authKind:BAt(o.config.auth)}))throw new Error(`Trust denied: connecting to remote MCP "${o.config.url}" requires user approval. Approve in the Connections panel (extension) or via /mcp trust ${i} (CLI).`);this.trustedFingerprints.add(q)}}let P=this.buildAuthHeaders(o.config.auth),O=new m(new URL(o.config.url),{requestInit:{headers:P}}),$=new u({name:"bandit",version:"1.0.0"},{capabilities:{}});await $.connect(O),o.client=$,o.transport=O,o.status={state:"connected",toolCount:0};return}if(this.trustGate){let P=tae(i,o.config);if(!this.trustedFingerprints.has(P)){if(!await this.trustGate({kind:"stdio",name:i,command:o.config.command??"",args:o.config.args??[],envKeys:Object.keys(o.config.env??{})}))throw new Error(`Trust denied: spawning "${o.config.command} ${(o.config.args??[]).join(" ")}" requires user approval. Approve in the Connections panel (extension) or via /mcp trust ${i} (CLI).`);this.trustedFingerprints.add(P)}}if(!o.config.command)throw new Error(`MCP server "${i}" config is missing both \`command\` (stdio) and \`url\` (remote) \u2014 one of the two is required.`);let A=new l({command:o.config.command,args:o.config.args??[],env:o.config.env??void 0,stderr:"pipe"}),E=new u({name:"bandit",version:"1.0.0"},{capabilities:{}});await E.connect(A),o.client=E,o.transport=A,o.status={state:"connected",toolCount:0}}buildAuthHeaders(i){if(!i)return{};let o=typeof i=="string"?{type:"bandit-api-key"}:i;if(o.type==="bandit-api-key"){let u=this.resolveAuthToken?.("bandit-api-key");return u?{"X-API-Key":u}:{}}return o.type==="bearer"?{Authorization:`Bearer ${o.token}`}:o.type==="header"?{[o.name]:o.value}:{}}};w4.McpClientPool=KFe});var XFe=Lt(OZ=>{"use strict";Object.defineProperty(OZ,"__esModule",{value:!0});OZ.inferProviderHint=LAt;OZ.effectiveTriggers=YFe;OZ.shouldActivateServer=E2n;OZ.isServerMentioned=w2n;var FAt={slack:["slack","channel","workspace","dm","message"],github:["github","repo","repository","pr","pull request","issue","commit"],gmail:["gmail","email","inbox","mail"],gdrive:["drive","gdrive","docs","spreadsheet","document","folder"],google:["google"],calendar:["calendar","meeting","schedule","event","appointment"],outlook:["outlook","email","inbox","mail"],teams:["teams","channel","meeting"],microsoft:["microsoft","office","sharepoint","onedrive"],filesystem:["file","folder","directory"],postgres:["postgres","sql","database","query"],mongo:["mongo","mongodb","database","query"]};function LAt(r){let i=r.toLowerCase();for(let o of Object.keys(FAt))if(i.includes(o))return o;return null}t(LAt,"inferProviderHint");function YFe(r,i){let o=new Set;o.add(r.toLowerCase());for(let l of i.triggers??[])o.add(l.toLowerCase());let u=LAt(r);if(u)for(let l of FAt[u])o.add(l);return[...o]}t(YFe,"effectiveTriggers");function E2n(r,i,o){if(i.disabled)return!1;if((i.activation??"always")==="always")return!0;if(!o)return!1;let l=o.toLowerCase();return YFe(r,i).some(A=>l.includes(A))}t(E2n,"shouldActivateServer");var T2n=["mcp","model context protocol"];function w2n(r,i,o){if(!o)return!1;let u=o.toLowerCase();return T2n.some(m=>u.includes(m))?!0:YFe(r,i).some(m=>u.includes(m))}t(w2n,"isServerMentioned")});var UAt=Lt($ve=>{"use strict";Object.defineProperty($ve,"__esModule",{value:!0});$ve.mcpToolToAgentTool=$At;$ve.getAllMcpAgentTools=I2n;var jAt=XFe();function e7e(r){if(!r)return;let i=r.type;if(i&&!new Set(["object","array","string","number","integer","boolean","null"]).has(i))return;let u={};if(i&&(u.type=i),r.description&&(u.description=r.description),r.enum&&(u.enum=r.enum),i==="object"&&r.properties){u.properties={};for(let[l,m]of Object.entries(r.properties)){let A=e7e(m);A&&(u.properties[l]=A.description?{...A,description:A.description}:{...A,description:m.description})}r.required&&r.required.length>0&&(u.required=r.required)}else if(i==="array"&&r.items){let l=e7e(r.items);l&&(u.items=l)}return u}t(e7e,"toAgentSchema");function x2n(r){if(!r||r.type!=="object"||!r.properties)return[];let i=new Set(r.required??[]);return Object.entries(r.properties).map(([o,u])=>{let l=e7e(u);return{name:o,description:u?.description??`(${u?.type??"any"})`,required:i.has(o),schema:l}})}t(x2n,"convertInputSchema");function k2n(r){let i=r?.content??[],o=[];for(let l of i)l.type==="text"&&typeof l.text=="string"?o.push(l.text):o.push(`[mcp:${l.type}] (non-text content omitted)`);return{output:o.join(`
394
394
  `).trim()||"(empty MCP response)",isError:!!r?.isError}}t(k2n,"renderMcpResult");function $At(r,i,o){let u=`${r}.${i.name}`,l=i.description?`${i.description} (via MCP server "${r}")`:`MCP tool "${i.name}" exposed by server "${r}".`,m=x2n(i.inputSchema);return{name:u,description:l,parameters:m,async execute(A,E){try{let P={};for(let[$,q]of Object.entries(A)){if(typeof q!="string"){P[$]=q;continue}let U=q.trim();if(U===""){P[$]=q;continue}if(U.startsWith("{")||U.startsWith("[")||/^"[\s\S]*"$/.test(U)||/^(-?\d+(?:\.\d+)?|true|false|null)$/.test(U))try{P[$]=JSON.parse(U)}catch{P[$]=q}else P[$]=q}let O=await o.callTool(r,i.name,P);return k2n(O)}catch(P){let O=P instanceof Error?P.message:String(P);return{output:`Error invoking ${u}: ${O}`,isError:!0}}}}}t($At,"mcpToolToAgentTool");async function I2n(r,i){let o=[];for(let u of r.snapshot()){if(!(0,jAt.shouldActivateServer)(u.name,u.config,i)||!r.hasCachedTools(u.name)&&!(0,jAt.isServerMentioned)(u.name,u.config,i))continue;let m=await r.discoverTools(u.name);for(let A of m)o.push($At(u.name,A,r))}return o}t(I2n,"getAllMcpAgentTools")});var zAt=Lt(Uve=>{"use strict";Object.defineProperty(Uve,"__esModule",{value:!0});Uve.ExperimentalServerTasks=void 0;var QAt=xR(),t7e=class{static{t(this,"ExperimentalServerTasks")}constructor(i){this._server=i}requestStream(i,o,u){return this._server.requestStream(i,o,u)}createMessageStream(i,o){let u=this._server.getClientCapabilities();if((i.tools||i.toolChoice)&&!u?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(i.messages.length>0){let l=i.messages[i.messages.length-1],m=Array.isArray(l.content)?l.content:[l.content],A=m.some($=>$.type==="tool_result"),E=i.messages.length>1?i.messages[i.messages.length-2]:void 0,P=E?Array.isArray(E.content)?E.content:[E.content]:[],O=P.some($=>$.type==="tool_use");if(A){if(m.some($=>$.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!O)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(O){let $=new Set(P.filter(U=>U.type==="tool_use").map(U=>U.id)),q=new Set(m.filter(U=>U.type==="tool_result").map(U=>U.toolUseId));if($.size!==q.size||![...$].every(U=>q.has(U)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:i},QAt.CreateMessageResultSchema,o)}elicitInputStream(i,o){let u=this._server.getClientCapabilities(),l=i.mode??"form";switch(l){case"url":{if(!u?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!u?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let m=l==="form"&&i.mode===void 0?{...i,mode:"form"}:i;return this.requestStream({method:"elicitation/create",params:m},QAt.ElicitResultSchema,o)}async getTask(i,o){return this._server.getTask({taskId:i},o)}async getTaskResult(i,o,u){return this._server.getTaskResult({taskId:i},o,u)}async listTasks(i,o){return this._server.listTasks(i?{cursor:i}:void 0,o)}async cancelTask(i,o){return this._server.cancelTask({taskId:i},o)}};Uve.ExperimentalServerTasks=t7e});var HAt=Lt(Qve=>{"use strict";Object.defineProperty(Qve,"__esModule",{value:!0});Qve.Server=void 0;var JAt=gBe(),Dh=xR(),D2n=fFe(),nae=_ie(),P2n=zAt(),qAt=pFe(),n7e=class extends JAt.Protocol{static{t(this,"Server")}constructor(i,o){super(o),this._serverInfo=i,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Dh.LoggingLevelSchema.options.map((u,l)=>[u,l])),this.isMessageIgnored=(u,l)=>{let m=this._loggingLevels.get(l);return m?this.LOG_LEVEL_SEVERITY.get(u)<this.LOG_LEVEL_SEVERITY.get(m):!1},this._capabilities=o?.capabilities??{},this._instructions=o?.instructions,this._jsonSchemaValidator=o?.jsonSchemaValidator??new D2n.AjvJsonSchemaValidator,this.setRequestHandler(Dh.InitializeRequestSchema,u=>this._oninitialize(u)),this.setNotificationHandler(Dh.InitializedNotificationSchema,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Dh.SetLevelRequestSchema,async(u,l)=>{let m=l.sessionId||l.requestInfo?.headers["mcp-session-id"]||void 0,{level:A}=u.params,E=Dh.LoggingLevelSchema.safeParse(A);return E.success&&this._loggingLevels.set(m,E.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new P2n.ExperimentalServerTasks(this)}),this._experimental}registerCapabilities(i){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=(0,JAt.mergeCapabilities)(this._capabilities,i)}setRequestHandler(i,o){let l=(0,nae.getObjectShape)(i)?.method;if(!l)throw new Error("Schema is missing a method literal");let m;if((0,nae.isZ4Schema)(l)){let E=l;m=E._zod?.def?.value??E.value}else{let E=l;m=E._def?.value??E.value}if(typeof m!="string")throw new Error("Schema method literal must be a string");if(m==="tools/call"){let E=t(async(P,O)=>{let $=(0,nae.safeParse)(Dh.CallToolRequestSchema,P);if(!$.success){let oe=$.error instanceof Error?$.error.message:String($.error);throw new Dh.McpError(Dh.ErrorCode.InvalidParams,`Invalid tools/call request: ${oe}`)}let{params:q}=$.data,U=await Promise.resolve(o(P,O));if(q.task){let oe=(0,nae.safeParse)(Dh.CreateTaskResultSchema,U);if(!oe.success){let me=oe.error instanceof Error?oe.error.message:String(oe.error);throw new Dh.McpError(Dh.ErrorCode.InvalidParams,`Invalid task creation result: ${me}`)}return oe.data}let ce=(0,nae.safeParse)(Dh.CallToolResultSchema,U);if(!ce.success){let oe=ce.error instanceof Error?ce.error.message:String(ce.error);throw new Dh.McpError(Dh.ErrorCode.InvalidParams,`Invalid tools/call result: ${oe}`)}return ce.data},"wrappedHandler");return super.setRequestHandler(i,E)}return super.setRequestHandler(i,o)}assertCapabilityForMethod(i){switch(i){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${i})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${i})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${i})`);break;case"ping":break}}assertNotificationCapability(i){switch(i){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${i})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${i})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${i})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${i})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${i})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(i){if(this._capabilities)switch(i){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${i})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${i})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${i})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${i})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${i})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${i})`);break;case"ping":case"initialize":break}}assertTaskCapability(i){(0,qAt.assertClientRequestTaskCapability)(this._clientCapabilities?.tasks?.requests,i,"Client")}assertTaskHandlerCapability(i){this._capabilities&&(0,qAt.assertToolsCallTaskCapability)(this._capabilities.tasks?.requests,i,"Server")}async _oninitialize(i){let o=i.params.protocolVersion;return this._clientCapabilities=i.params.capabilities,this._clientVersion=i.params.clientInfo,{protocolVersion:Dh.SUPPORTED_PROTOCOL_VERSIONS.includes(o)?o:Dh.LATEST_PROTOCOL_VERSION,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Dh.EmptyResultSchema)}async createMessage(i,o){if((i.tools||i.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(i.messages.length>0){let u=i.messages[i.messages.length-1],l=Array.isArray(u.content)?u.content:[u.content],m=l.some(O=>O.type==="tool_result"),A=i.messages.length>1?i.messages[i.messages.length-2]:void 0,E=A?Array.isArray(A.content)?A.content:[A.content]:[],P=E.some(O=>O.type==="tool_use");if(m){if(l.some(O=>O.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!P)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(P){let O=new Set(E.filter(q=>q.type==="tool_use").map(q=>q.id)),$=new Set(l.filter(q=>q.type==="tool_result").map(q=>q.toolUseId));if(O.size!==$.size||![...O].every(q=>$.has(q)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return i.tools?this.request({method:"sampling/createMessage",params:i},Dh.CreateMessageResultWithToolsSchema,o):this.request({method:"sampling/createMessage",params:i},Dh.CreateMessageResultSchema,o)}async elicitInput(i,o){switch(i.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let l=i;return this.request({method:"elicitation/create",params:l},Dh.ElicitResultSchema,o)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let l=i.mode==="form"?i:{...i,mode:"form"},m=await this.request({method:"elicitation/create",params:l},Dh.ElicitResultSchema,o);if(m.action==="accept"&&m.content&&l.requestedSchema)try{let E=this._jsonSchemaValidator.getValidator(l.requestedSchema)(m.content);if(!E.valid)throw new Dh.McpError(Dh.ErrorCode.InvalidParams,`Elicitation response content does not match requested schema: ${E.errorMessage}`)}catch(A){throw A instanceof Dh.McpError?A:new Dh.McpError(Dh.ErrorCode.InternalError,`Error validating elicitation response: ${A instanceof Error?A.message:String(A)}`)}return m}}}createElicitationCompletionNotifier(i,o){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:i}},o)}async listRoots(i,o){return this.request({method:"roots/list",params:i},Dh.ListRootsResultSchema,o)}async sendLoggingMessage(i,o){if(this._capabilities.logging&&!this.isMessageIgnored(i.level,o))return this.notification({method:"notifications/message",params:i})}async sendResourceUpdated(i){return this.notification({method:"notifications/resources/updated",params:i})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};Qve.Server=n7e});var WAt=Lt(RZ=>{"use strict";var N2n=RZ&&RZ.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(RZ,"__esModule",{value:!0});RZ.StdioServerTransport=void 0;var GAt=N2n(ps("node:process")),VAt=TFe(),r7e=class{static{t(this,"StdioServerTransport")}constructor(i=GAt.default.stdin,o=GAt.default.stdout){this._stdin=i,this._stdout=o,this._readBuffer=new VAt.ReadBuffer,this._started=!1,this._ondata=u=>{this._readBuffer.append(u),this.processReadBuffer()},this._onerror=u=>{this.onerror?.(u)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let i=this._readBuffer.readMessage();if(i===null)break;this.onmessage?.(i)}catch(i){this.onerror?.(i)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(i){return new Promise(o=>{let u=(0,VAt.serializeMessage)(i);this._stdout.write(u)?o():this._stdout.once("drain",o)})}};RZ.StdioServerTransport=r7e});var ZAt=Lt(i7e=>{"use strict";Object.defineProperty(i7e,"__esModule",{value:!0});i7e.serveBanditMcp=B2n;function O2n(r){let i={},o=[];for(let u of r.parameters)i[u.name]={type:"string",description:u.description},u.required&&o.push(u.name);return{type:"object",properties:i,required:o}}t(O2n,"toolInputSchema");function R2n(r){if(!r||typeof r!="object"||Array.isArray(r))return{};let i={};for(let[o,u]of Object.entries(r))if(typeof u=="string")i[o]=u;else{if(u==null)continue;i[o]=JSON.stringify(u)}return i}t(R2n,"coerceArgs");async function B2n(r){let i=HAt(),o=WAt(),u=xR(),{Server:l}=i,{StdioServerTransport:m}=o,{ListToolsRequestSchema:A,CallToolRequestSchema:E}=u,P=r.log??(ce=>process.stderr.write(ce+`
395
395
  `)),O=r.tools,$=new Map;for(let ce of O)$.set(ce.name,ce);let q=new l({name:r.name??"bandit",version:r.version??"1.0.0"},{capabilities:{tools:{}}});q.setRequestHandler(A,async()=>({tools:O.map(ce=>({name:ce.name,description:ce.description,inputSchema:O2n(ce)}))})),q.setRequestHandler(E,async ce=>{let oe=$.get(ce.params.name);if(!oe)return{isError:!0,content:[{type:"text",text:`Unknown tool: ${ce.params.name}`}]};try{let me=R2n(ce.params.arguments),Re=await oe.execute(me,r.toolCtx);return{isError:!!Re.isError,content:[{type:"text",text:Re.output}]}}catch(me){let Re=me instanceof Error?me.message:String(me);return P(`tool call ${ce.params.name} threw: ${Re}`),{isError:!0,content:[{type:"text",text:`Tool error: ${Re}`}]}}}),P(`bandit MCP server: ready on stdio with ${O.length} tool${O.length===1?"":"s"}`);let U=new m;await q.connect(U),await new Promise(ce=>{U.onclose=()=>ce()})}t(B2n,"serveBanditMcp")});var XAt=Lt(ES=>{"use strict";Object.defineProperty(ES,"__esModule",{value:!0});ES.inferProviderHint=ES.effectiveTriggers=ES.shouldActivateServer=ES.serveBanditMcp=ES.getAllMcpAgentTools=ES.mcpToolToAgentTool=ES.fingerprintServerConfig=ES.McpClientPool=void 0;var KAt=MAt();Object.defineProperty(ES,"McpClientPool",{enumerable:!0,get:t(function(){return KAt.McpClientPool},"get")});Object.defineProperty(ES,"fingerprintServerConfig",{enumerable:!0,get:t(function(){return KAt.fingerprintServerConfig},"get")});var YAt=UAt();Object.defineProperty(ES,"mcpToolToAgentTool",{enumerable:!0,get:t(function(){return YAt.mcpToolToAgentTool},"get")});Object.defineProperty(ES,"getAllMcpAgentTools",{enumerable:!0,get:t(function(){return YAt.getAllMcpAgentTools},"get")});var M2n=ZAt();Object.defineProperty(ES,"serveBanditMcp",{enumerable:!0,get:t(function(){return M2n.serveBanditMcp},"get")});var a7e=XFe();Object.defineProperty(ES,"shouldActivateServer",{enumerable:!0,get:t(function(){return a7e.shouldActivateServer},"get")});Object.defineProperty(ES,"effectiveTriggers",{enumerable:!0,get:t(function(){return a7e.effectiveTriggers},"get")});Object.defineProperty(ES,"inferProviderHint",{enumerable:!0,get:t(function(){return a7e.inferProviderHint},"get")})});var BZ=Lt(sy=>{"use strict";var F2n=sy&&sy.__createBinding||(Object.create?(function(r,i,o,u){u===void 0&&(u=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:t(function(){return i[o]},"get")}),Object.defineProperty(r,u,l)}):(function(r,i,o,u){u===void 0&&(u=o),r[u]=i[o]})),zve=sy&&sy.__exportStar||function(r,i){for(var o in r)o!=="default"&&!Object.prototype.hasOwnProperty.call(i,o)&&F2n(i,r,o)};Object.defineProperty(sy,"__esModule",{value:!0});sy.BUILTIN_SECRET_PATTERNS=sy.redactSecretsString=sy.redactSecrets=sy.createAgentRuntime=sy.AgentRuntime=sy.DeterministicProviderClient=sy.collectFromStream=sy.validateAgentPlan=void 0;var L2n=X8e(),j2n=t3e();zve(r3e(),sy);zve(Ift(),sy);var $2n=r3e();Object.defineProperty(sy,"validateAgentPlan",{enumerable:!0,get:t(function(){return $2n.validateAgentPlan},"get")});var U2n=Dft();Object.defineProperty(sy,"collectFromStream",{enumerable:!0,get:t(function(){return U2n.collectFromStream},"get")});var Q2n=t3e();Object.defineProperty(sy,"DeterministicProviderClient",{enumerable:!0,get:t(function(){return Q2n.DeterministicProviderClient},"get")});var z2n=X8e();Object.defineProperty(sy,"AgentRuntime",{enumerable:!0,get:t(function(){return z2n.AgentRuntime},"get")});var J2n=t((r={})=>{let{provider:i,...o}=r,u=i??new j2n.DeterministicProviderClient;return new L2n.AgentRuntime({provider:u,...o})},"createAgentRuntime");sy.createAgentRuntime=J2n;zve(Xdt(),sy);zve(XAt(),sy);var s7e=_3e();Object.defineProperty(sy,"redactSecrets",{enumerable:!0,get:t(function(){return s7e.redactSecrets},"get")});Object.defineProperty(sy,"redactSecretsString",{enumerable:!0,get:t(function(){return s7e.redactSecretsString},"get")});Object.defineProperty(sy,"BUILTIN_SECRET_PATTERNS",{enumerable:!0,get:t(function(){return s7e.BUILTIN_SECRET_PATTERNS},"get")})});var t1t=Lt(e1t=>{"use strict";Object.defineProperty(e1t,"__esModule",{value:!0})});var r1t=Lt(n1t=>{"use strict";Object.defineProperty(n1t,"__esModule",{value:!0})});var o7e=Lt(BE=>{"use strict";Object.defineProperty(BE,"__esModule",{value:!0});BE.STOP_WORDS=BE.FILE_NAME_PATTERN=BE.PATH_PATTERN=void 0;BE.inferGoal=W2n;BE.classifyIntent=s1t;BE.extractExplicitPaths=o1t;BE.extractKeywords=c1t;BE.PATH_PATTERN=/(?:[^\s"'`]+\/)*[A-Za-z0-9_.-]+\.[A-Za-z0-9]{1,6}/g;BE.FILE_NAME_PATTERN=/\b[A-Za-z0-9_.-]+\.[a-z0-9]{1,6}\b/g;var q2n=/\.(tsx|ts|jsx|js|json|md|css|scss|sass|less|html|yml|yaml|vue|svelte|cs|csx|java|kt|kts|sql|go|py|rb|php|c|cc|cpp|h|hpp|rs|swift|sh|bash|ps1|psm1)$/i,H2n=/^\s*(?:[-*•]|\d+[.)])\s+(.*)$/,G2n=/\b(?:then|next|after(?:ward|wards)?|follow(?:ed)? by|plus|as well as|finally)\b/gi;BE.STOP_WORDS=new Set(["the","and","for","with","that","this","there","about","please","could","would","should","bandit","stealth","agent","mode","question","repo","code","file","files","explain","describe","thank","thanks","have","need","maybe","really","just","like","into","from","your","you","what","where","when","why","which","how","does","make","using","are","roughly","currently","actually","around","after","before","goal","task","work","project","component","components","comnponent","comnponents","page","pages","little"]);var V2n={refactor:[/refactor/i,/cleanup/i,/restructure/i,/modular/i,/extract/i,/split/i],fix:[/fix/i,/bug/i,/issue/i,/error/i,/broken/i,/correct/i],feature:[/add/i,/implement/i,/create/i,/support/i,/feature/i,/build/i,/introduce/i],analyze:[/investigate/i,/analy[sz]e/i,/review/i,/audit/i,/inspect/i,/debug/i],doc:[/doc/i,/readme/i,/comment/i,/explain/i,/write documentation/i,/guide/i],style:[/style/i,/css/i,/theme/i,/color/i,/spacing/i,/layout/i,/visual/i]};async function W2n(r){let i=r.prompt?.trim()??"",o=Z2n(i),u=s1t(i),l=K2n(i,r.workspaceIndex??[]),m=_xn(i,r.workspaceIndex??[]),A=fxn([...l,...m]),E=Y2n(u,A),P=txn(i,A,u);return{title:o,intent:u,files:A,rationale:E,tasks:P}}t(W2n,"inferGoal");function Z2n(r){if(!r)return"Bandit agent goal";let i=r.replace(/\s+/g," ").trim();return i.length<=120?rae(i):`${rae(i.slice(0,117).trimEnd())}\u2026`}t(Z2n,"buildTitle");function rae(r){return r&&r.charAt(0).toUpperCase()+r.slice(1)}t(rae,"capitalize");function s1t(r){let i=r.toLowerCase();for(let[o,u]of Object.entries(V2n))if(u.some(l=>l.test(i)))return o;return/bug|error|exception|stack trace/.test(i)?"fix":/doc|readme|documentation|comment/.test(i)?"doc":"feature"}t(s1t,"classifyIntent");function K2n(r,i,o=6){if(!i.length)return[];let u=i.map(P=>P.replace(/\\/g,"/")).filter(P=>q2n.test(P)),l=new Set,m=t(P=>{!P||l.size>=o||l.add(P)},"addMatch");for(let P of o1t(r)){let $=u.find(q=>q.toLowerCase()===P.toLowerCase())??u.find(q=>q.toLowerCase().endsWith(P.toLowerCase()));if($&&m($),l.size>=o)return Array.from(l)}let A=c1t(r);if(!A.length)return Array.from(l);let E=[];for(let P of u){if(l.has(P))continue;let O=P.toLowerCase(),$=0;for(let q of A)O.includes(q)&&($+=q.length,O.endsWith(`/${q}.tsx`)||O.endsWith(`/${q}.ts`)||O.endsWith(`/${q}.jsx`)||O.endsWith(`/${q}.js`)?$+=3:(O.endsWith(`/${q}.md`)||O.endsWith(`/${q}.mdx`))&&($+=2),O.includes(`/${q}/`)&&($+=2));$>0&&E.push({file:P,score:$})}E.sort((P,O)=>O.score-P.score);for(let P of E)if(m(P.file),l.size>=o)break;return Array.from(l)}t(K2n,"selectCandidateFiles");function o1t(r){let i=new Set,o;for(;(o=BE.PATH_PATTERN.exec(r))!==null;){let u=o[0].replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"").trim();u&&i.add(u)}return Array.from(i)}t(o1t,"extractExplicitPaths");function c1t(r){let i=r.toLowerCase().match(/[a-z0-9][a-z0-9_-]{2,}/g);return i?i.filter(o=>!BE.STOP_WORDS.has(o)).slice(0,24):[]}t(c1t,"extractKeywords");function Y2n(r,i){let o=uxn(r);if(!i.length)return`Detected ${o} intent from the prompt.`;let u=i.slice(0,3).join(", ");return`Detected ${o} intent and shortlisted ${u} as likely impacted files.`}t(Y2n,"buildRationale");function X2n(r,i){let o=r.toLowerCase().replace(/\s+/g," ").trim(),u=o.match(/\b(add\s+\w[\w\s]{0,30}?\s+(?:to|for|in))\b/);if(u)return rae(u[1].trim());let l=[[/\b(add\s+comments)\b/i,"Add comments to"],[/\b(add\s+documentation)\b/i,"Add documentation to"],[/\b(add\s+types?\s+annotations?)\b/i,"Add type annotations to"],[/\b(add\s+error\s+handling)\b/i,"Add error handling to"],[/\b(add\s+validation)\b/i,"Add validation to"],[/\b(add\s+logging)\b/i,"Add logging to"],[/\b(add\s+tests?\s+for)\b/i,"Add tests for"],[/\brefactor\b/i,"Refactor"],[/\bfix\b/i,"Fix"],[/\bupdate\b/i,"Update"],[/\bclean\s*up\b/i,"Clean up"],[/\boptimize\b/i,"Optimize"],[/\bdocument\b/i,"Document"]];for(let[m,A]of l)if(m.test(o))return A}t(X2n,"inferActionVerb");function exn(r){switch(r){case"refactor":return"Refactor";case"fix":return"Fix";case"feature":return"Update";case"analyze":return"Analyze";case"doc":return"Document";case"style":return"Style"}}t(exn,"intentVerb");function txn(r,i,o){let u=nxn(r),l=[],m=i.slice(0,6),A=X2n(r,o),E=r.toLowerCase(),P=/\b(all|other|each|every|similar|same)\b/.test(E)&&m.length>1;if(A&&P)m.forEach(q=>{let U=q.split("/").pop()??q;l.push({title:`${A} ${U}`,description:`${A} in ${q}`,files:[q]})});else if(!u.length&&m.length){let q=A??exn(o);m.forEach(U=>{let ce=U.split("/").pop()??U;l.push({title:`${q} ${ce}`,description:`Apply the requested goal to ${U}.`,files:[U]})})}else u.forEach(q=>{let U=cxn(q);if(!U)return;let ce=lxn(q,m);l.push({title:U,description:ce.length?`Likely touched files: ${ce.join(", ")}`:void 0,files:ce.length?ce:void 0})});!l.length&&r.trim()&&l.push({title:rae(r.trim()),description:m.length?`Review ${m.join(", ")}`:void 0,files:m.length?m:void 0}),o!=="analyze"&&l.push({title:"Review and validate changes",description:"Self-review the diff and run any necessary checks.",files:m.slice(0,2)});let O=[],$=new Set;for(let q of l){let U=q.title.toLowerCase();if(!$.has(U)&&($.add(U),O.push(q),O.length>=6))break}return O}t(txn,"buildTaskSuggestions");function nxn(r){let i=ixn(r),o=sxn(i);if(o.length>0)return o.slice(0,8);let u=axn(i);if(!u)return[];let l=u.split(/[.!?]+(?=\s|$)/).map(A=>A.trim()).filter(Boolean);l.length||l.push(u);let m=[];for(let A of l){let E=A.split(G2n).map(P=>P.trim()).filter(Boolean);if(E.length)for(let P of E){let O=l1t(P);if(O&&(m.push(O),m.length>=8))return m}}return m}t(nxn,"extractGoalClauses");function rxn(r){return r?r.split(/\r?\n/).filter(u=>!oxn(u)).join(" "):""}t(rxn,"stripLikelyCodeLines");function ixn(r){if(!r)return"";let i=r.search(/\brelevant files\s*:/i);return i<=0?r:r.slice(0,i)}t(ixn,"stripRelevantFilesSection");function axn(r){return rxn(r).replace(/[\r\n]+/g," ").replace(/\s+/g," ").trim()}t(axn,"normalizePromptForClauseExtraction");function sxn(r){if(!r)return[];let i=r.split(/\r?\n/),o=[];for(let u of i){let l=u.match(H2n);if(!l?.[1])continue;let m=l1t(l[1]);if(m&&(o.push(m),o.length>=8))break}return o}t(sxn,"extractBulletListClauses");function l1t(r){let i=r.replace(/\s+/g," ").trim();return i.length<4?"":i}t(l1t,"normalizeClauseSegment");function oxn(r){let i=r.trim();return!!(!i||i==="{"||i==="}"||/^\s*(public|private|protected|internal)\b/.test(i)||/\bclass\b/.test(i)&&/[{;]$/.test(i)||/\b(get;|set;)\b/.test(i))}t(oxn,"isLikelyCodeLine");function cxn(r){let i=r.trim().replace(/^\b(to|please|kindly)\b/i,"").trim();if(!i)return"";let o=i.replace(/\s+/g," "),u=o.length>120?`${o.slice(0,117).trimEnd()}\u2026`:o;return rae(u)}t(cxn,"formatClauseTitle");function lxn(r,i){if(!i.length)return[];let u=r.toLowerCase().match(/[a-z0-9][a-z0-9_-]{3,}/g);if(!u||!u.length)return[];let l=[];for(let m of i){let A=m.toLowerCase(),E=A.split(/[\\/]/).pop()??A;u.some(P=>A.includes(`/${P}`)||E.includes(P))&&l.push(m)}return l.slice(0,3)}t(lxn,"matchClauseToFiles");function uxn(r){switch(r){case"fix":return"a bug fix";case"refactor":return"a refactor";case"analyze":return"an investigation";case"doc":return"a documentation update";case"style":return"a styling update";default:return"a feature implementation"}}t(uxn,"intentLabel");function fxn(r){let i=new Set,o=[];for(let u of r){if(!u)continue;let l=u.replace(/\\/g,"/");i.has(l)||(i.add(l),o.push(l))}return o}t(fxn,"dedupeFiles");var i1t=/\b(?:create|add|build|use|have|refactor|split|extract|introduce|make)\s+(?:an?\s+|the\s+)?([a-z][a-z0-9\s-]{3,}?)\s+(?:component|components|comnponent|comnponents)\b/gi,a1t=/\b([a-z][a-z0-9\s-]{3,})\s+(?:component|components|comnponent|comnponents)\b/gi,dxn=["src/components/shared","src/components/ui","src/components","components","src"],pxn=new Set(["to","into","with","using","use","and","while","when","that","which","for","of","by","a","an","the"]);function _xn(r,i){let o=mxn(r),u=gxn(r),l=u.size>0?u:o;if(!l.size)return[];let m=yxn(i),A=new Set(i.map(O=>O.replace(/\\/g,"/").toLowerCase())),E=new Set(Array.from(A).map(O=>O.split("/").pop()).filter(O=>!!O)),P=[];for(let O of l){let $=hxn(O);if(!$)continue;let q=vxn($,m,A,E);q&&!A.has(q)&&P.push(q)}return P}t(_xn,"inferSyntheticComponentFiles");function mxn(r){let i=new Set;i1t.lastIndex=0;let o;for(;(o=i1t.exec(r))!==null;)o[1]&&i.add(o[1]);return i}t(mxn,"extractActionDrivenComponentNames");function gxn(r){let i=new Set;a1t.lastIndex=0;let o;for(;(o=a1t.exec(r))!==null;)o[1]&&i.add(o[1]);return i}t(gxn,"extractInlineComponentNames");function hxn(r){if(!r)return;let i=r.replace(/[^a-z0-9\s-]/gi," ").replace(/\s+/g," ").trim().toLowerCase();if(!i)return;let o=i.split(" "),u=0;for(let E=o.length-1;E>=0;E-=1)if(pxn.has(o[E])){u=E+1;break}let l=o.slice(u).filter(E=>E&&!BE.STOP_WORDS.has(E));if(!l.length)return;let A=l.slice(-3).join(" ").trim();return A.length>=3?A:void 0}t(hxn,"refineComponentName");function yxn(r){let i=new Set;for(let o of r){let u=o.replace(/\\/g,"/"),l=u.lastIndexOf("/");if(l===-1)continue;let m=u.slice(0,l);m&&i.add(m)}return Array.from(i).sort((o,u)=>o.length-u.length)}t(yxn,"collectWorkspaceDirectories");function vxn(r,i,o,u){let l=Sxn(r);if(!l||u.has(`${l}.tsx`))return;let m=bxn(r),A=Axn(i,m),E=A?A.replace(/\\/g,"/").replace(/\/+$/,""):"",P=E?`${E}/${l}.tsx`:`${l}.tsx`;if(!o.has(P.toLowerCase()))return P}t(vxn,"buildComponentPathSuggestion");function Axn(r,i){let o=r.find(l=>{let m=l.toLowerCase();return i.some(A=>A&&m.includes(A))});if(o)return o;for(let l of dxn){let m=l.toLowerCase(),A=r.find(E=>{let P=E.toLowerCase();return P===m||P.endsWith(`/${m}`)});if(A)return A}let u=r.find(l=>l.includes("component"));return u||(r.length?r[0]:void 0)}t(Axn,"selectComponentDirectory");function bxn(r){return r.toLowerCase().split(/[\s_-]+/).map(i=>i.trim()).filter(i=>i.length>=3&&!BE.STOP_WORDS.has(i))}t(bxn,"extractNameKeywords");function Sxn(r){let i=r.trim().split(/[\s_-]+/).map(o=>o.toLowerCase().replace(/[^a-z0-9]/g,"")).filter(o=>o.length>0);return i.length?i.join("-"):""}t(Sxn,"toKebabCase")});var u7e=Lt(RR=>{"use strict";var Cxn=RR&&RR.__createBinding||(Object.create?(function(r,i,o,u){u===void 0&&(u=o);var l=Object.getOwnPropertyDescriptor(i,o);(!l||("get"in l?!i.__esModule:l.writable||l.configurable))&&(l={enumerable:!0,get:t(function(){return i[o]},"get")}),Object.defineProperty(r,u,l)}):(function(r,i,o,u){u===void 0&&(u=o),r[u]=i[o]})),Exn=RR&&RR.__setModuleDefault||(Object.create?(function(r,i){Object.defineProperty(r,"default",{enumerable:!0,value:i})}):function(r,i){r.default=i}),u1t=RR&&RR.__importStar||(function(){var r=t(function(i){return r=Object.getOwnPropertyNames||function(o){var u=[];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(u[u.length]=l);return u},r(i)},"ownKeys");return function(i){if(i&&i.__esModule)return i;var o={};if(i!=null)for(var u=r(i),l=0;l<u.length;l++)u[l]!=="default"&&Cxn(o,i,u[l]);return Exn(o,i),o}})();Object.defineProperty(RR,"__esModule",{value:!0});RR.EmbeddingCache=void 0;var FZ=typeof window<"u";async function MZ(){if(FZ)throw new Error("EmbeddingCache is unavailable in browser hosts.");let[r,i]=await Promise.all([Promise.resolve().then(()=>u1t(ps("fs"))),Promise.resolve().then(()=>u1t(ps("path")))]);return{fs:r.promises,path:i}}t(MZ,"getNodeDeps");var f1t=1,c7e=32,Txn=t(r=>{let i=2166136261,o=[];for(let u=0;u<r.length&&o.length<c7e;u+=2){i^=r.charCodeAt(u),i+=(i<<1)+(i<<4)+(i<<7)+(i<<8)+(i<<24);let l=(i>>>0)/4294967295;o.push(l)}for(;o.length<c7e;){i^=2654435769;let u=(i>>>0)/4294967295;o.push(u)}return o.slice(0,c7e)},"hashString"),wxn=t((r,i)=>Txn(`${i}:${r}`),"computeVector"),l7e=class{static{t(this,"EmbeddingCache")}constructor(){this.entries=new Map,this.dirty=!1}async prepare(i,o){if(FZ){this.workspaceRoot=i,this.artifactRoot=o,this.entries.clear(),this.dirty=!1,this.cachePath=void 0;return}let{fs:u,path:l}=await MZ();this.workspaceRoot=i,this.artifactRoot=o,await u.mkdir(o,{recursive:!0}).catch(()=>{}),this.cachePath=l.join(o,"embeddings.json"),this.entries.clear(),this.dirty=!1,await this.load()}async flush(){if(!this.cachePath||!this.dirty)return;if(FZ){this.dirty=!1;return}let{fs:i}=await MZ(),o={version:f1t,entries:Object.fromEntries(this.entries)};await i.writeFile(this.cachePath,JSON.stringify(o,null,2),"utf8"),this.dirty=!1}async indexFiles(i,o){if(FZ)return{reused:0,computed:0};if(!this.cachePath||!this.workspaceRoot||!this.artifactRoot||this.workspaceRoot!==i){let{path:E}=await MZ(),P=this.artifactRoot??E.join(i,".bandit");await this.prepare(i,P)}let{fs:u,path:l}=await MZ(),m={reused:0,computed:0},A=Date.now();for(let E of o)try{let P=l.join(i,E),O=await u.stat(P),$=E,q=this.entries.get($);if(q&&Math.abs(q.mtimeMs-O.mtimeMs)<1&&q.size===O.size){this.entries.set($,{...q,lastUsed:A}),m.reused+=1;continue}let U=await this.readSample(P),ce=wxn(U,E);this.entries.set($,{vector:ce,mtimeMs:O.mtimeMs,size:O.size,lastUsed:A}),this.dirty=!0,m.computed+=1}catch{}return m}getEmbedding(i){let o=this.entries.get(i);return o&&this.entries.set(i,{...o,lastUsed:Date.now()}),o}async load(){if(!this.cachePath||FZ)return;let{fs:i}=await MZ();try{let o=await i.readFile(this.cachePath,"utf8"),u=JSON.parse(o);if(u.version!==f1t||typeof u.entries!="object"||!u.entries)return;for(let[l,m]of Object.entries(u.entries))Array.isArray(m.vector)&&m.vector.length>0&&this.entries.set(l,m)}catch{}}async readSample(i){if(FZ)return"";let{fs:o}=await MZ();try{let u=await o.open(i,"r");try{let l=Buffer.alloc(4096),{bytesRead:m}=await u.read(l,0,l.length,0);return l.toString("utf8",0,m)}finally{await u.close()}}catch{return""}}};RR.EmbeddingCache=l7e});var d7e=Lt(Jve=>{"use strict";Object.defineProperty(Jve,"__esModule",{value:!0});Jve.StealthEmbeddingClient=void 0;var xxn=t(r=>{let i=2166136261;for(let u=0;u<r.length;u+=1)i^=r.charCodeAt(u),i+=(i<<1)+(i<<4)+(i<<7)+(i<<8)+(i<<24);return(i>>>0).toString(16).padStart(16,"0")},"hashString"),kxn="https://api.burtson.ai/api/stealth/embeddings",d1t=8e3,f7e=class r{static{t(this,"StealthEmbeddingClient")}constructor(i){this.baseUrl=r.normalizeBaseUrl(i.baseUrl),this.apiKey=i.apiKey,this.workspaceRoot=i.workspaceRoot}matches(i){return this.baseUrl===r.normalizeBaseUrl(i.baseUrl)&&this.apiKey===i.apiKey&&this.workspaceRoot===i.workspaceRoot}async upsertDocument(i){let o=this.prepareText(i.content);if(!o)return;let u={path:i.path,workspace:this.workspaceRoot,language:i.language,...i.metadata??{}};await this.post("/upsert",{id:this.buildVectorId(i.path),text:o,metadata:u})}async searchDocuments(i,o=6){let u=i.trim();if(!u)return[];let l={query:u,limit:o},m=await this.post("/search",l);return Array.isArray(m)?m.map(A=>this.mapSearchEntry(A)).filter(A=>!!(A&&A.path)):[]}mapSearchEntry(i){if(!i||typeof i!="object")return;let o=i.payload,u=i.id,l=i.score,m=o??{},A=this.extractPathFromMetadata(m);if(A)return{id:u,score:l,path:A,metadata:m}}extractPathFromMetadata(i){let o=[i.path,i.file,i.filePath,i.filepath,i.source];for(let u of o)if(typeof u=="string"&&u.trim().length>0)return u.trim()}async post(i,o){let u=`${this.baseUrl}${i}`,l=await fetch(u,{method:"POST",headers:this.buildHeaders(),body:JSON.stringify(o)});if(!l.ok){let A=await r.safeReadText(l);throw new Error(`Embedding request failed: ${l.status} ${l.statusText}${A?` \u2013 ${A}`:""}`)}let m=await l.text();if(m)try{return JSON.parse(m)}catch(A){console.warn("Failed to parse embedding response JSON",A);return}}buildHeaders(){let i={"Content-Type":"application/json"};return this.apiKey&&(i.Authorization=`Bearer ${this.apiKey}`),i}buildVectorId(i){return xxn(`${this.workspaceRoot}:${i}`)}prepareText(i){if(!i)return"";let o=i.replace(/\r\n/g,`
396
- `).trim();return o.length<=d1t?o:o.slice(0,d1t)}static async safeReadText(i){try{return await i.text()}catch{return""}}static normalizeBaseUrl(i){let o=kxn;if(!i)return o;let u=i.trim();return u?u.replace(/\/$/,""):o}};Jve.StealthEmbeddingClient=f7e});var g7e=Lt(x4=>{"use strict";Object.defineProperty(x4,"__esModule",{value:!0});x4.MODEL_BEHAVIOR_CONFIG_SCHEMA_VERSION=void 0;x4.registerModelBehaviorOverride=_1t;x4.registerModelBehaviorConfig=Ixn;x4.clearModelBehaviorOverrides=Dxn;x4.getBuiltInModelBehaviorProfiles=Pxn;x4.getModelBehaviorProfile=Nxn;x4.parseModelBehaviorConfig=g1t;x4.MODEL_BEHAVIOR_CONFIG_SCHEMA_VERSION=1;var _J=["5xx gateway/model errors","ECONNRESET / ECONNREFUSED / ETIMEDOUT","fetch failed / socket hang up"],qve=[{id:"bandit-logic",match:["bandit-logic"],label:"Bandit Logic / Qwen 3.6 agent profile",protocol:{preferred:"native-tools",fallback:"text-tools",envelope:"ollama-tools",nativeToolFailureFallback:!0},context:{safeInputTokens:64e3,outputBudgetTokens:8192,compaction:"normal"},prompting:{template:"qwen-agent",examples:"minimal",thinking:"on"},reliability:{maxParallelTools:6,retryableErrors:[..._J,"Qwen tool-call parser EOF"],knownFailureModes:["Native tool parser can return upstream 500 on malformed/incomplete tool calls.","Reasoning-only stalls are possible when thinking is disabled."]}},{id:"qwen3.6",match:["qwen3.6"],label:"Qwen 3.6 agent profile",protocol:{preferred:"native-tools",fallback:"text-tools",envelope:"ollama-tools",nativeToolFailureFallback:!0},context:{safeInputTokens:64e3,outputBudgetTokens:8192,compaction:"normal"},prompting:{template:"qwen-agent",examples:"minimal",thinking:"on"},reliability:{maxParallelTools:6,retryableErrors:[..._J,"Qwen tool-call parser EOF"],knownFailureModes:["Can spend a long prefill/thinking phase before first token.","Native tool parsing is valuable but should degrade to text tools on upstream parser failures."]}},{id:"gemma4",match:["gemma4","gemma3","bandit-core:12b","bandit-core:27b","bandit-core:31b"],label:"Gemma-family compact text-tool profile",protocol:{preferred:"text-tools",fallback:void 0,envelope:"xml-json",nativeToolFailureFallback:!1},context:{safeInputTokens:24e3,outputBudgetTokens:2048,compaction:"early"},prompting:{template:"gemma-compact",examples:"strict",thinking:"auto"},reliability:{maxParallelTools:2,retryableErrors:_J,knownFailureModes:["More likely to narrate intent than emit a tool call without compact, explicit examples.","Large multi-edit batches should be serialized."]}},{id:"qwen2.5-coder",match:["qwen2.5-coder"],label:"Qwen 2.5 Coder profile",protocol:{preferred:"native-tools",fallback:"text-tools",envelope:"ollama-tools",nativeToolFailureFallback:!0},context:{safeInputTokens:32e3,outputBudgetTokens:4096,compaction:"normal"},prompting:{template:"qwen-agent",examples:"minimal",thinking:"auto"},reliability:{maxParallelTools:4,retryableErrors:_J,knownFailureModes:["Completion-tuned variants may ask for paths instead of searching unless prompted to inspect first."]}},{id:"llama3",match:["llama3.2","llama3.1","llama3"],label:"Llama lightweight tool profile",protocol:{preferred:"text-tools",fallback:void 0,envelope:"xml-json",nativeToolFailureFallback:!1},context:{safeInputTokens:12e3,outputBudgetTokens:1024,compaction:"aggressive"},prompting:{template:"llama-tool-lite",examples:"strict",thinking:"auto"},reliability:{maxParallelTools:1,retryableErrors:_J,knownFailureModes:["Small variants need narrow context and one tool at a time."]}},{id:"deepseek-r1",match:["deepseek-r1"],label:"DeepSeek R1 reasoning profile",protocol:{preferred:"text-tools",fallback:void 0,envelope:"xml-json",nativeToolFailureFallback:!1},context:{safeInputTokens:24e3,outputBudgetTokens:2048,compaction:"early"},prompting:{template:"default-agent",examples:"strict",thinking:"on"},reliability:{maxParallelTools:1,retryableErrors:_J,knownFailureModes:["Reasoning models can narrate for a long time before acting; keep context narrow and tool calls serialized."]}},{id:"default",match:[""],label:"Default conservative profile",protocol:{preferred:"text-tools",fallback:void 0,envelope:"xml-json",nativeToolFailureFallback:!1},context:{safeInputTokens:8e3,outputBudgetTokens:1024,compaction:"aggressive"},prompting:{template:"default-agent",examples:"strict",thinking:"auto"},reliability:{maxParallelTools:1,retryableErrors:_J,knownFailureModes:["Unknown model: assume limited context, text tool protocol, and serialized tool use."]}}],m7e=new Map;function _1t(r,i){let o=r.trim().toLowerCase();o&&m7e.set(o,i)}t(_1t,"registerModelBehaviorOverride");function Ixn(r){let i=g1t(r);for(let o of i.entries)for(let u of o.match)_1t(u,o.override);return i}t(Ixn,"registerModelBehaviorConfig");function Dxn(){m7e.clear()}t(Dxn,"clearModelBehaviorOverrides");function Pxn(){return qve.map(m1t)}t(Pxn,"getBuiltInModelBehaviorProfiles");function Nxn(r){let i=r.toLowerCase(),o=m1t(Oxn(i)),u=Rxn(i);return u?Bxn(o,u):o}t(Nxn,"getModelBehaviorProfile");function Oxn(r){let i=qve[qve.length-1],o=-1;for(let u of qve)for(let l of u.match){let m=l.toLowerCase();r.startsWith(m)&&m.length>o&&(i=u,o=m.length)}return i}t(Oxn,"findBestProfile");function Rxn(r){let i,o=-1;for(let[u,l]of m7e)r.startsWith(u)&&u.length>o&&(i=l,o=u.length);return i}t(Rxn,"findBestOverride");function m1t(r){return{...r,match:[...r.match],protocol:{...r.protocol},context:{...r.context},prompting:{...r.prompting},reliability:{...r.reliability,retryableErrors:[...r.reliability.retryableErrors],knownFailureModes:[...r.reliability.knownFailureModes]}}}t(m1t,"cloneProfile");function Bxn(r,i){return{...r,...i,match:i.match?[...i.match]:r.match,protocol:{...r.protocol,...i.protocol},context:{...r.context,...i.context},prompting:{...r.prompting,...i.prompting},reliability:{...r.reliability,...i.reliability,retryableErrors:i.reliability?.retryableErrors?[...i.reliability.retryableErrors]:r.reliability.retryableErrors,knownFailureModes:i.reliability?.knownFailureModes?[...i.reliability.knownFailureModes]:r.reliability.knownFailureModes}}}t(Bxn,"mergeProfile");function g1t(r){let i=[],o=[],u=E9(r);if(!u)return{entries:[],errors:["model behavior config must be a JSON object"],warnings:o};let l=u.version??u.schemaVersion;l!==void 0&&l!==x4.MODEL_BEHAVIOR_CONFIG_SCHEMA_VERSION&&o.push(`schema version ${String(l)} is not recognized; parsing compatible fields only`);let m=u.profiles??u.models;if(!m)return{entries:[],errors:["model behavior config must define a profiles object"],warnings:o};let A=[];if(Array.isArray(m))m.forEach((P,O)=>{let $=E9(P),q=typeof $?.id=="string"&&$.id.trim()?$.id.trim():`profiles[${O}]`;A.push({key:q,value:P})});else{let P=E9(m);if(!P)return{entries:[],errors:["profiles must be an object or array"],warnings:o};for(let[O,$]of Object.entries(P))A.push({key:O,value:$})}let E=[];for(let{key:P,value:O}of A){let $=E9(O);if(!$){o.push(`${P}: profile must be an object`);continue}let q=_7e($.match,`${P}.match`,o),ce=(q.length?q:[P]).map(me=>me.trim()).filter(Boolean);if(ce.length===0){o.push(`${P}: profile has no usable match prefixes`);continue}let oe=Mxn(P,$,o);E.push({key:P,match:ce,override:{...oe,match:ce}})}return{entries:E,errors:i,warnings:o}}t(g1t,"parseModelBehaviorConfig");function Mxn(r,i,o){let u={},l=p1t(i.id,`${r}.id`,o),m=p1t(i.label,`${r}.label`,o);l&&(u.id=l),m&&(u.label=m);let A=E9(i.protocol);if(A){let $={},q=mJ(A.preferred,["native-tools","text-tools"],`${r}.protocol.preferred`,o),U=mJ(A.fallback,["native-tools","text-tools"],`${r}.protocol.fallback`,o,!0),ce=mJ(A.envelope,["ollama-tools","xml-json"],`${r}.protocol.envelope`,o),oe=Fxn(A.nativeToolFailureFallback,`${r}.protocol.nativeToolFailureFallback`,o);q&&($.preferred=q),"fallback"in A&&($.fallback=U),ce&&($.envelope=ce),oe!==void 0&&($.nativeToolFailureFallback=oe),u.protocol=$}else i.protocol!==void 0&&o.push(`${r}.protocol must be an object`);let E=E9(i.context);if(E){let $={},q=p7e(E.safeInputTokens,`${r}.context.safeInputTokens`,o),U=p7e(E.outputBudgetTokens,`${r}.context.outputBudgetTokens`,o),ce=mJ(E.compaction,["early","normal","aggressive"],`${r}.context.compaction`,o);q!==void 0&&($.safeInputTokens=q),U!==void 0&&($.outputBudgetTokens=U),ce&&($.compaction=ce),u.context=$}else i.context!==void 0&&o.push(`${r}.context must be an object`);let P=E9(i.prompting);if(P){let $={},q=mJ(P.template,["qwen-agent","gemma-compact","llama-tool-lite","default-agent"],`${r}.prompting.template`,o),U=mJ(P.examples,["none","minimal","strict"],`${r}.prompting.examples`,o),ce=mJ(P.thinking,["on","off","auto"],`${r}.prompting.thinking`,o);q&&($.template=q),U&&($.examples=U),ce&&($.thinking=ce),u.prompting=$}else i.prompting!==void 0&&o.push(`${r}.prompting must be an object`);let O=E9(i.reliability);if(O){let $={},q=p7e(O.maxParallelTools,`${r}.reliability.maxParallelTools`,o),U=_7e(O.retryableErrors,`${r}.reliability.retryableErrors`,o),ce=_7e(O.knownFailureModes,`${r}.reliability.knownFailureModes`,o);q!==void 0&&($.maxParallelTools=q),Array.isArray(O.retryableErrors)&&($.retryableErrors=U),Array.isArray(O.knownFailureModes)&&($.knownFailureModes=ce),u.reliability=$}else i.reliability!==void 0&&o.push(`${r}.reliability must be an object`);return u}t(Mxn,"parseModelBehaviorOverride");function E9(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0}t(E9,"asRecord");function p1t(r,i,o){if(r===void 0)return;if(typeof r!="string"){o.push(`${i} must be a string`);return}let u=r.trim();return u.length?u:void 0}t(p1t,"stringValue");function _7e(r,i,o){if(r===void 0)return[];if(typeof r=="string"){let l=r.trim();return l?[l]:[]}if(!Array.isArray(r))return o.push(`${i} must be a string or string array`),[];let u=[];for(let l of r)typeof l=="string"&&l.trim()?u.push(l.trim()):o.push(`${i} contains a non-string entry`);return u}t(_7e,"stringList");function Fxn(r,i,o){if(r!==void 0){if(typeof r=="boolean")return r;o.push(`${i} must be a boolean`)}}t(Fxn,"booleanValue");function p7e(r,i,o){if(r!==void 0){if(typeof r=="number"&&Number.isInteger(r)&&r>0)return r;o.push(`${i} must be a positive integer`)}}t(p7e,"positiveInteger");function mJ(r,i,o,u,l=!1){if(r!==void 0&&!(r===null&&l)){if(typeof r=="string"&&i.includes(r))return r;u.push(`${o} must be one of: ${i.join(", ")}`)}}t(mJ,"enumValue")});var Hve=Lt(BR=>{"use strict";Object.defineProperty(BR,"__esModule",{value:!0});BR.registerModelCapabilities=$xn;BR.getModelCapabilities=v1t;BR.queryOllamaModelCapabilities=Qxn;BR.checkOllamaLoadedContext=zxn;BR.getContextFileLimit=Jxn;BR.getContextTokenBudget=qxn;BR.getOutputTokenBudget=Hxn;BR.resolveOllamaRuntimeOptions=Gxn;var Lxn=g7e(),jxn=[{prefix:"bandit-core:4b",caps:{contextWindow:8192,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!1,tier:"small",label:"Bandit Core 4B"}},{prefix:"bandit-core:12b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Bandit Core 12B"}},{prefix:"bandit-core:27b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Bandit Core 27B"}},{prefix:"bandit-core:31b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Bandit Core 31B"}},{prefix:"bandit-core-1",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Bandit Core (hosted, 31B)"}},{prefix:"bandit-core-2",caps:{contextWindow:131072,supportsJsonMode:!1,supportsToolCalling:!1,supportsVision:!1,tier:"large",label:"Bandit Core 2 (RunPod 70B)"}},{prefix:"bandit-logic",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Bandit Logic (Qwen 3.6 27B)"}},{prefix:"gemma3:4b",caps:{contextWindow:8192,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"Gemma 3 4B"}},{prefix:"gemma3:12b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Gemma 3 12B"}},{prefix:"gemma3:27b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Gemma 3 27B"}},{prefix:"gemma4:e2b",caps:{contextWindow:16384,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"Gemma 4 e2B"}},{prefix:"gemma4:e4b",caps:{contextWindow:16384,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"Gemma 4 e4B"}},{prefix:"gemma4:31b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"large",label:"Gemma 4 31B"}},{prefix:"gemma4:26b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Gemma 4 26B"}},{prefix:"gemma4",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Gemma 4"}},{prefix:"llama3.2-vision",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Llama 3.2 Vision"}},{prefix:"llama3.1",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Llama 3.1"}},{prefix:"llama3",caps:{contextWindow:8192,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!1,tier:"small",label:"Llama 3"}},{prefix:"qwen3.6:35b",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Qwen 3.6 35B"}},{prefix:"qwen3.6:27b",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Qwen 3.6 27B"}},{prefix:"qwen3.6",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Qwen 3.6"}},{prefix:"qwen2.5-coder:72b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 Coder 72B"}},{prefix:"qwen2.5-coder:32b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 Coder 32B"}},{prefix:"qwen2.5-coder:14b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Qwen 2.5 Coder 14B"}},{prefix:"qwen2.5-coder",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Qwen 2.5 Coder"}},{prefix:"qwen2.5vl",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"medium",label:"Qwen 2.5 VL"}},{prefix:"qwen2-vl",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"medium",label:"Qwen 2 VL"}},{prefix:"qwen2.5:72b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 72B"}},{prefix:"qwen2.5:32b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 32B"}},{prefix:"qwen2.5",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Qwen 2.5"}},{prefix:"llava",caps:{contextWindow:4096,supportsJsonMode:!1,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"LLaVA"}},{prefix:"deepseek-coder:6.7b",caps:{contextWindow:16384,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!1,tier:"small",label:"DeepSeek Coder 6.7B"}}],h1t={contextWindow:8192,supportsJsonMode:!1,supportsToolCalling:!1,supportsVision:!1,tier:"small"},y1t=new Map;function $xn(r,i){r&&y1t.set(r.toLowerCase(),i)}t($xn,"registerModelCapabilities");function v1t(r){if(!r)return h1t;let i=r.toLowerCase();for(let{prefix:u,caps:l}of jxn)if(i.startsWith(u.toLowerCase()))return l;let o=y1t.get(i);return o||h1t}t(v1t,"getModelCapabilities");function Uxn(r){let i=r.match(/(\d+(?:\.\d+)?)\s*[Bb]/);if(!i)return"small";let o=parseFloat(i[1]);return o<=5?"small":o<=35?"medium":"large"}t(Uxn,"deriveTierFromParamSize");async function Qxn(r,i){try{let o=`${i.replace(/\/$/,"")}/api/show`,u=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r}),signal:AbortSignal.timeout(5e3)});if(!u.ok)return null;let l=await u.json(),m=l.details?.parameter_size??"",A=Uxn(m),E=l.model_info?.["llm.context_length"]??(A==="large"?131072:A==="medium"?32768:8192),P=(l.details?.family??"").toLowerCase(),O=new Set((l.capabilities??[]).map(ce=>ce.toLowerCase())),$=!0,q=O.has("tools"),U=O.has("vision")||P.includes("llava")||P.includes("vision")||P.includes("vl");return{tier:A,contextWindow:E,supportsJsonMode:$,supportsToolCalling:q,supportsVision:U,label:r}}catch{return null}}t(Qxn,"queryOllamaModelCapabilities");async function zxn(r,i,o){let u=Math.max(16384,Math.ceil(o*1.1/1024)*1024),l={loadedContext:null,requestedContext:o,underweight:!1,suggestionCommand:`OLLAMA_CONTEXT_LENGTH=${u} ollama serve`};try{let m=`${r.replace(/\/$/,"")}/api/ps`,A=await fetch(m,{signal:AbortSignal.timeout(3e3)});if(!A.ok)return l;let E=await A.json(),P=i.toLowerCase(),O=(E.models??[]).find(U=>(U.model??"").toLowerCase()===P||(U.name??"").toLowerCase()===P);if(!O||typeof O.context_length!="number")return l;let $=O.context_length,q=$<8192&&$<o*.75;return{loadedContext:$,requestedContext:o,underweight:q,suggestionCommand:`OLLAMA_CONTEXT_LENGTH=${u} ollama serve`}}catch{return l}}t(zxn,"checkOllamaLoadedContext");function Jxn(r){switch(r){case"large":return 20;case"medium":return 8;case"small":return 3}}t(Jxn,"getContextFileLimit");function qxn(r){return Math.floor(r.contextWindow*.4)}t(qxn,"getContextTokenBudget");function Hxn(r){switch(r.tier){case"small":return 1024;case"medium":return 2048;case"large":return 8192;default:return 1024}}t(Hxn,"getOutputTokenBudget");function Gxn(r){let i=v1t(r),o;switch(i.tier){case"small":o=12288;break;case"medium":o=24576;break;case"large":o=32768;break;default:o=12288}i.contextWindow>0&&o>i.contextWindow&&(o=i.contextWindow);let u=(0,Lxn.getModelBehaviorProfile)(r),l=u.prompting.thinking==="on"?!0:u.prompting.thinking==="off"?!1:void 0;return{num_ctx:o,keep_alive:-1,...l!==void 0?{think:l}:{}}}t(Gxn,"resolveOllamaRuntimeOptions")});var b7e=Lt(iae=>{"use strict";Object.defineProperty(iae,"__esModule",{value:!0});iae.normalizeOllamaMessages=T1t;iae.createProvider=nkn;iae.serializeBanditPayload=y7e;var b1t=Hve(),Vxn="https://api.burtson.ai/completions",Wxn="http://localhost:11434",Zxn="gemma3:12b",Kxn=[/<\/?end_of_turn>/g,/<\/?start_of_turn>/g,/<\|eot_id\|>/g,/<\|start_header_id\|>/g,/<\|end_header_id\|>/g,/<\|begin_of_text\|>/g,/\[INST\]/g,/\[\/INST\]/g,/<<SYS>>/g,/<\/SYS>>/g];function S1t(r){let i=r;for(let o of Kxn)i=i.replace(o,"");return i=C1t(i),i}t(S1t,"sanitizeOllamaOutput");function C1t(r){let i=/(?:data:[\w/.+-]+;base64,)?[A-Za-z0-9+/]{120,}={0,2}/g;return r.replace(i,o=>`[base64 stripped: ${o.length} chars]`)}t(C1t,"stripBase64BlobsInline");function Yxn(r){let i=t(E=>(typeof E=="string"?E:E.map(O=>O.type==="text"?O.text:"").join(" ")).toLowerCase(),"getLowerText"),o=r.messages.filter(E=>E.role==="system").map(E=>i(E.content)).join(`
396
+ `).trim();return o.length<=d1t?o:o.slice(0,d1t)}static async safeReadText(i){try{return await i.text()}catch{return""}}static normalizeBaseUrl(i){let o=kxn;if(!i)return o;let u=i.trim();return u?u.replace(/\/$/,""):o}};Jve.StealthEmbeddingClient=f7e});var g7e=Lt(x4=>{"use strict";Object.defineProperty(x4,"__esModule",{value:!0});x4.MODEL_BEHAVIOR_CONFIG_SCHEMA_VERSION=void 0;x4.registerModelBehaviorOverride=_1t;x4.registerModelBehaviorConfig=Ixn;x4.clearModelBehaviorOverrides=Dxn;x4.getBuiltInModelBehaviorProfiles=Pxn;x4.getModelBehaviorProfile=Nxn;x4.parseModelBehaviorConfig=g1t;x4.MODEL_BEHAVIOR_CONFIG_SCHEMA_VERSION=1;var _J=["5xx gateway/model errors","ECONNRESET / ECONNREFUSED / ETIMEDOUT","fetch failed / socket hang up"],qve=[{id:"bandit-logic",match:["bandit-logic"],label:"Bandit Logic / Qwen 3.6 agent profile",protocol:{preferred:"native-tools",fallback:"text-tools",envelope:"ollama-tools",nativeToolFailureFallback:!0},context:{safeInputTokens:64e3,outputBudgetTokens:8192,compaction:"normal"},prompting:{template:"qwen-agent",examples:"minimal",thinking:"on"},reliability:{maxParallelTools:6,retryableErrors:[..._J,"Qwen tool-call parser EOF"],knownFailureModes:["Native tool parser can return upstream 500 on malformed/incomplete tool calls.","Reasoning-only stalls are possible when thinking is disabled."]}},{id:"qwen3.6",match:["qwen3.6"],label:"Qwen 3.6 agent profile",protocol:{preferred:"native-tools",fallback:"text-tools",envelope:"ollama-tools",nativeToolFailureFallback:!0},context:{safeInputTokens:64e3,outputBudgetTokens:8192,compaction:"normal"},prompting:{template:"qwen-agent",examples:"minimal",thinking:"on"},reliability:{maxParallelTools:6,retryableErrors:[..._J,"Qwen tool-call parser EOF"],knownFailureModes:["Can spend a long prefill/thinking phase before first token.","Native tool parsing is valuable but should degrade to text tools on upstream parser failures."]}},{id:"gemma4",match:["gemma4","gemma3","bandit-core:12b","bandit-core:27b","bandit-core:31b"],label:"Gemma-family / bandit-core agent profile",protocol:{preferred:"native-tools",fallback:"text-tools",envelope:"ollama-tools",nativeToolFailureFallback:!0},context:{safeInputTokens:24e3,outputBudgetTokens:2048,compaction:"early"},prompting:{template:"gemma-compact",examples:"strict",thinking:"auto"},reliability:{maxParallelTools:2,retryableErrors:_J,knownFailureModes:["More likely to narrate intent than emit a tool call without compact, explicit examples.","Large multi-edit batches should be serialized."]}},{id:"qwen2.5-coder",match:["qwen2.5-coder"],label:"Qwen 2.5 Coder profile",protocol:{preferred:"native-tools",fallback:"text-tools",envelope:"ollama-tools",nativeToolFailureFallback:!0},context:{safeInputTokens:32e3,outputBudgetTokens:4096,compaction:"normal"},prompting:{template:"qwen-agent",examples:"minimal",thinking:"auto"},reliability:{maxParallelTools:4,retryableErrors:_J,knownFailureModes:["Completion-tuned variants may ask for paths instead of searching unless prompted to inspect first."]}},{id:"llama3",match:["llama3.2","llama3.1","llama3"],label:"Llama lightweight tool profile",protocol:{preferred:"text-tools",fallback:void 0,envelope:"xml-json",nativeToolFailureFallback:!1},context:{safeInputTokens:12e3,outputBudgetTokens:1024,compaction:"aggressive"},prompting:{template:"llama-tool-lite",examples:"strict",thinking:"auto"},reliability:{maxParallelTools:1,retryableErrors:_J,knownFailureModes:["Small variants need narrow context and one tool at a time."]}},{id:"deepseek-r1",match:["deepseek-r1"],label:"DeepSeek R1 reasoning profile",protocol:{preferred:"text-tools",fallback:void 0,envelope:"xml-json",nativeToolFailureFallback:!1},context:{safeInputTokens:24e3,outputBudgetTokens:2048,compaction:"early"},prompting:{template:"default-agent",examples:"strict",thinking:"on"},reliability:{maxParallelTools:1,retryableErrors:_J,knownFailureModes:["Reasoning models can narrate for a long time before acting; keep context narrow and tool calls serialized."]}},{id:"default",match:[""],label:"Default conservative profile",protocol:{preferred:"text-tools",fallback:void 0,envelope:"xml-json",nativeToolFailureFallback:!1},context:{safeInputTokens:8e3,outputBudgetTokens:1024,compaction:"aggressive"},prompting:{template:"default-agent",examples:"strict",thinking:"auto"},reliability:{maxParallelTools:1,retryableErrors:_J,knownFailureModes:["Unknown model: assume limited context, text tool protocol, and serialized tool use."]}}],m7e=new Map;function _1t(r,i){let o=r.trim().toLowerCase();o&&m7e.set(o,i)}t(_1t,"registerModelBehaviorOverride");function Ixn(r){let i=g1t(r);for(let o of i.entries)for(let u of o.match)_1t(u,o.override);return i}t(Ixn,"registerModelBehaviorConfig");function Dxn(){m7e.clear()}t(Dxn,"clearModelBehaviorOverrides");function Pxn(){return qve.map(m1t)}t(Pxn,"getBuiltInModelBehaviorProfiles");function Nxn(r){let i=r.toLowerCase(),o=m1t(Oxn(i)),u=Rxn(i);return u?Bxn(o,u):o}t(Nxn,"getModelBehaviorProfile");function Oxn(r){let i=qve[qve.length-1],o=-1;for(let u of qve)for(let l of u.match){let m=l.toLowerCase();r.startsWith(m)&&m.length>o&&(i=u,o=m.length)}return i}t(Oxn,"findBestProfile");function Rxn(r){let i,o=-1;for(let[u,l]of m7e)r.startsWith(u)&&u.length>o&&(i=l,o=u.length);return i}t(Rxn,"findBestOverride");function m1t(r){return{...r,match:[...r.match],protocol:{...r.protocol},context:{...r.context},prompting:{...r.prompting},reliability:{...r.reliability,retryableErrors:[...r.reliability.retryableErrors],knownFailureModes:[...r.reliability.knownFailureModes]}}}t(m1t,"cloneProfile");function Bxn(r,i){return{...r,...i,match:i.match?[...i.match]:r.match,protocol:{...r.protocol,...i.protocol},context:{...r.context,...i.context},prompting:{...r.prompting,...i.prompting},reliability:{...r.reliability,...i.reliability,retryableErrors:i.reliability?.retryableErrors?[...i.reliability.retryableErrors]:r.reliability.retryableErrors,knownFailureModes:i.reliability?.knownFailureModes?[...i.reliability.knownFailureModes]:r.reliability.knownFailureModes}}}t(Bxn,"mergeProfile");function g1t(r){let i=[],o=[],u=E9(r);if(!u)return{entries:[],errors:["model behavior config must be a JSON object"],warnings:o};let l=u.version??u.schemaVersion;l!==void 0&&l!==x4.MODEL_BEHAVIOR_CONFIG_SCHEMA_VERSION&&o.push(`schema version ${String(l)} is not recognized; parsing compatible fields only`);let m=u.profiles??u.models;if(!m)return{entries:[],errors:["model behavior config must define a profiles object"],warnings:o};let A=[];if(Array.isArray(m))m.forEach((P,O)=>{let $=E9(P),q=typeof $?.id=="string"&&$.id.trim()?$.id.trim():`profiles[${O}]`;A.push({key:q,value:P})});else{let P=E9(m);if(!P)return{entries:[],errors:["profiles must be an object or array"],warnings:o};for(let[O,$]of Object.entries(P))A.push({key:O,value:$})}let E=[];for(let{key:P,value:O}of A){let $=E9(O);if(!$){o.push(`${P}: profile must be an object`);continue}let q=_7e($.match,`${P}.match`,o),ce=(q.length?q:[P]).map(me=>me.trim()).filter(Boolean);if(ce.length===0){o.push(`${P}: profile has no usable match prefixes`);continue}let oe=Mxn(P,$,o);E.push({key:P,match:ce,override:{...oe,match:ce}})}return{entries:E,errors:i,warnings:o}}t(g1t,"parseModelBehaviorConfig");function Mxn(r,i,o){let u={},l=p1t(i.id,`${r}.id`,o),m=p1t(i.label,`${r}.label`,o);l&&(u.id=l),m&&(u.label=m);let A=E9(i.protocol);if(A){let $={},q=mJ(A.preferred,["native-tools","text-tools"],`${r}.protocol.preferred`,o),U=mJ(A.fallback,["native-tools","text-tools"],`${r}.protocol.fallback`,o,!0),ce=mJ(A.envelope,["ollama-tools","xml-json"],`${r}.protocol.envelope`,o),oe=Fxn(A.nativeToolFailureFallback,`${r}.protocol.nativeToolFailureFallback`,o);q&&($.preferred=q),"fallback"in A&&($.fallback=U),ce&&($.envelope=ce),oe!==void 0&&($.nativeToolFailureFallback=oe),u.protocol=$}else i.protocol!==void 0&&o.push(`${r}.protocol must be an object`);let E=E9(i.context);if(E){let $={},q=p7e(E.safeInputTokens,`${r}.context.safeInputTokens`,o),U=p7e(E.outputBudgetTokens,`${r}.context.outputBudgetTokens`,o),ce=mJ(E.compaction,["early","normal","aggressive"],`${r}.context.compaction`,o);q!==void 0&&($.safeInputTokens=q),U!==void 0&&($.outputBudgetTokens=U),ce&&($.compaction=ce),u.context=$}else i.context!==void 0&&o.push(`${r}.context must be an object`);let P=E9(i.prompting);if(P){let $={},q=mJ(P.template,["qwen-agent","gemma-compact","llama-tool-lite","default-agent"],`${r}.prompting.template`,o),U=mJ(P.examples,["none","minimal","strict"],`${r}.prompting.examples`,o),ce=mJ(P.thinking,["on","off","auto"],`${r}.prompting.thinking`,o);q&&($.template=q),U&&($.examples=U),ce&&($.thinking=ce),u.prompting=$}else i.prompting!==void 0&&o.push(`${r}.prompting must be an object`);let O=E9(i.reliability);if(O){let $={},q=p7e(O.maxParallelTools,`${r}.reliability.maxParallelTools`,o),U=_7e(O.retryableErrors,`${r}.reliability.retryableErrors`,o),ce=_7e(O.knownFailureModes,`${r}.reliability.knownFailureModes`,o);q!==void 0&&($.maxParallelTools=q),Array.isArray(O.retryableErrors)&&($.retryableErrors=U),Array.isArray(O.knownFailureModes)&&($.knownFailureModes=ce),u.reliability=$}else i.reliability!==void 0&&o.push(`${r}.reliability must be an object`);return u}t(Mxn,"parseModelBehaviorOverride");function E9(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0}t(E9,"asRecord");function p1t(r,i,o){if(r===void 0)return;if(typeof r!="string"){o.push(`${i} must be a string`);return}let u=r.trim();return u.length?u:void 0}t(p1t,"stringValue");function _7e(r,i,o){if(r===void 0)return[];if(typeof r=="string"){let l=r.trim();return l?[l]:[]}if(!Array.isArray(r))return o.push(`${i} must be a string or string array`),[];let u=[];for(let l of r)typeof l=="string"&&l.trim()?u.push(l.trim()):o.push(`${i} contains a non-string entry`);return u}t(_7e,"stringList");function Fxn(r,i,o){if(r!==void 0){if(typeof r=="boolean")return r;o.push(`${i} must be a boolean`)}}t(Fxn,"booleanValue");function p7e(r,i,o){if(r!==void 0){if(typeof r=="number"&&Number.isInteger(r)&&r>0)return r;o.push(`${i} must be a positive integer`)}}t(p7e,"positiveInteger");function mJ(r,i,o,u,l=!1){if(r!==void 0&&!(r===null&&l)){if(typeof r=="string"&&i.includes(r))return r;u.push(`${o} must be one of: ${i.join(", ")}`)}}t(mJ,"enumValue")});var Hve=Lt(BR=>{"use strict";Object.defineProperty(BR,"__esModule",{value:!0});BR.registerModelCapabilities=$xn;BR.getModelCapabilities=v1t;BR.queryOllamaModelCapabilities=Qxn;BR.checkOllamaLoadedContext=zxn;BR.getContextFileLimit=Jxn;BR.getContextTokenBudget=qxn;BR.getOutputTokenBudget=Hxn;BR.resolveOllamaRuntimeOptions=Gxn;var Lxn=g7e(),jxn=[{prefix:"bandit-core:4b",caps:{contextWindow:8192,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!1,tier:"small",label:"Bandit Core 4B"}},{prefix:"bandit-core:12b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Bandit Core 12B"}},{prefix:"bandit-core:27b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Bandit Core 27B"}},{prefix:"bandit-core:31b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Bandit Core 31B"}},{prefix:"bandit-core-1",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Bandit Core (hosted, 31B)"}},{prefix:"bandit-core-2",caps:{contextWindow:131072,supportsJsonMode:!1,supportsToolCalling:!1,supportsVision:!1,tier:"large",label:"Bandit Core 2 (RunPod 70B)"}},{prefix:"bandit-logic",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Bandit Logic (Qwen 3.6 27B)"}},{prefix:"gemma3:4b",caps:{contextWindow:8192,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"Gemma 3 4B"}},{prefix:"gemma3:12b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Gemma 3 12B"}},{prefix:"gemma3:27b",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"medium",label:"Gemma 3 27B"}},{prefix:"gemma4:e2b",caps:{contextWindow:16384,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"Gemma 4 e2B"}},{prefix:"gemma4:e4b",caps:{contextWindow:16384,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"Gemma 4 e4B"}},{prefix:"gemma4:31b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Gemma 4 31B"}},{prefix:"gemma4:26b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"medium",label:"Gemma 4 26B"}},{prefix:"gemma4",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Gemma 4"}},{prefix:"llama3.2-vision",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!0,tier:"medium",label:"Llama 3.2 Vision"}},{prefix:"llama3.1",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Llama 3.1"}},{prefix:"llama3",caps:{contextWindow:8192,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!1,tier:"small",label:"Llama 3"}},{prefix:"qwen3.6:35b",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Qwen 3.6 35B"}},{prefix:"qwen3.6:27b",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Qwen 3.6 27B"}},{prefix:"qwen3.6",caps:{contextWindow:262144,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"large",label:"Qwen 3.6"}},{prefix:"qwen2.5-coder:72b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 Coder 72B"}},{prefix:"qwen2.5-coder:32b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 Coder 32B"}},{prefix:"qwen2.5-coder:14b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Qwen 2.5 Coder 14B"}},{prefix:"qwen2.5-coder",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Qwen 2.5 Coder"}},{prefix:"qwen2.5vl",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"medium",label:"Qwen 2.5 VL"}},{prefix:"qwen2-vl",caps:{contextWindow:32768,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!0,tier:"medium",label:"Qwen 2 VL"}},{prefix:"qwen2.5:72b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 72B"}},{prefix:"qwen2.5:32b",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"large",label:"Qwen 2.5 32B"}},{prefix:"qwen2.5",caps:{contextWindow:131072,supportsJsonMode:!0,supportsToolCalling:!0,supportsVision:!1,tier:"medium",label:"Qwen 2.5"}},{prefix:"llava",caps:{contextWindow:4096,supportsJsonMode:!1,supportsToolCalling:!1,supportsVision:!0,tier:"small",label:"LLaVA"}},{prefix:"deepseek-coder:6.7b",caps:{contextWindow:16384,supportsJsonMode:!0,supportsToolCalling:!1,supportsVision:!1,tier:"small",label:"DeepSeek Coder 6.7B"}}],h1t={contextWindow:8192,supportsJsonMode:!1,supportsToolCalling:!1,supportsVision:!1,tier:"small"},y1t=new Map;function $xn(r,i){r&&y1t.set(r.toLowerCase(),i)}t($xn,"registerModelCapabilities");function v1t(r){if(!r)return h1t;let i=r.toLowerCase();for(let{prefix:u,caps:l}of jxn)if(i.startsWith(u.toLowerCase()))return l;let o=y1t.get(i);return o||h1t}t(v1t,"getModelCapabilities");function Uxn(r){let i=r.match(/(\d+(?:\.\d+)?)\s*[Bb]/);if(!i)return"small";let o=parseFloat(i[1]);return o<=5?"small":o<=35?"medium":"large"}t(Uxn,"deriveTierFromParamSize");async function Qxn(r,i){try{let o=`${i.replace(/\/$/,"")}/api/show`,u=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:r}),signal:AbortSignal.timeout(5e3)});if(!u.ok)return null;let l=await u.json(),m=l.details?.parameter_size??"",A=Uxn(m),E=l.model_info?.["llm.context_length"]??(A==="large"?131072:A==="medium"?32768:8192),P=(l.details?.family??"").toLowerCase(),O=new Set((l.capabilities??[]).map(ce=>ce.toLowerCase())),$=!0,q=O.has("tools"),U=O.has("vision")||P.includes("llava")||P.includes("vision")||P.includes("vl");return{tier:A,contextWindow:E,supportsJsonMode:$,supportsToolCalling:q,supportsVision:U,label:r}}catch{return null}}t(Qxn,"queryOllamaModelCapabilities");async function zxn(r,i,o){let u=Math.max(16384,Math.ceil(o*1.1/1024)*1024),l={loadedContext:null,requestedContext:o,underweight:!1,suggestionCommand:`OLLAMA_CONTEXT_LENGTH=${u} ollama serve`};try{let m=`${r.replace(/\/$/,"")}/api/ps`,A=await fetch(m,{signal:AbortSignal.timeout(3e3)});if(!A.ok)return l;let E=await A.json(),P=i.toLowerCase(),O=(E.models??[]).find(U=>(U.model??"").toLowerCase()===P||(U.name??"").toLowerCase()===P);if(!O||typeof O.context_length!="number")return l;let $=O.context_length,q=$<8192&&$<o*.75;return{loadedContext:$,requestedContext:o,underweight:q,suggestionCommand:`OLLAMA_CONTEXT_LENGTH=${u} ollama serve`}}catch{return l}}t(zxn,"checkOllamaLoadedContext");function Jxn(r){switch(r){case"large":return 20;case"medium":return 8;case"small":return 3}}t(Jxn,"getContextFileLimit");function qxn(r){return Math.floor(r.contextWindow*.4)}t(qxn,"getContextTokenBudget");function Hxn(r){switch(r.tier){case"small":return 1024;case"medium":return 2048;case"large":return 8192;default:return 1024}}t(Hxn,"getOutputTokenBudget");function Gxn(r){let i=v1t(r),o;switch(i.tier){case"small":o=12288;break;case"medium":o=24576;break;case"large":o=32768;break;default:o=12288}i.contextWindow>0&&o>i.contextWindow&&(o=i.contextWindow);let u=(0,Lxn.getModelBehaviorProfile)(r),l=u.prompting.thinking==="on"?!0:u.prompting.thinking==="off"?!1:void 0;return{num_ctx:o,keep_alive:-1,...l!==void 0?{think:l}:{}}}t(Gxn,"resolveOllamaRuntimeOptions")});var b7e=Lt(iae=>{"use strict";Object.defineProperty(iae,"__esModule",{value:!0});iae.normalizeOllamaMessages=T1t;iae.createProvider=nkn;iae.serializeBanditPayload=y7e;var b1t=Hve(),Vxn="https://api.burtson.ai/completions",Wxn="http://localhost:11434",Zxn="gemma3:12b",Kxn=[/<\/?end_of_turn>/g,/<\/?start_of_turn>/g,/<\|eot_id\|>/g,/<\|start_header_id\|>/g,/<\|end_header_id\|>/g,/<\|begin_of_text\|>/g,/\[INST\]/g,/\[\/INST\]/g,/<<SYS>>/g,/<\/SYS>>/g];function S1t(r){let i=r;for(let o of Kxn)i=i.replace(o,"");return i=C1t(i),i}t(S1t,"sanitizeOllamaOutput");function C1t(r){let i=/(?:data:[\w/.+-]+;base64,)?[A-Za-z0-9+/]{120,}={0,2}/g;return r.replace(i,o=>`[base64 stripped: ${o.length} chars]`)}t(C1t,"stripBase64BlobsInline");function Yxn(r){let i=t(E=>(typeof E=="string"?E:E.map(O=>O.type==="text"?O.text:"").join(" ")).toLowerCase(),"getLowerText"),o=r.messages.filter(E=>E.role==="system").map(E=>i(E.content)).join(`
397
397
  `),u=[...r.messages].reverse().find(E=>E.role==="user"),l=`${o}
398
398
  ${u?i(u.content):""}`;return/\b(respond with json(?: only)?|return (?:valid )?json|output (?:valid )?json|json only|format\s*[:=]\s*"?json"?|strictly json)\b/.test(l)?/\b(plan|planning|steps?)\b|execution plan|agent plan|schema|"steps"|"id"|"title"|"description"/.test(l):!1}t(Yxn,"detectJsonRequest");function E1t(r){if(typeof r=="string")return{text:r,imageUrls:[]};if(!Array.isArray(r))return{text:"",imageUrls:[]};let i=[],o=[];for(let u of r)if(u){if(u.type==="text"){let l=typeof u.text=="string"?u.text:u.text!=null?String(u.text):"";l.length>0&&i.push(l);continue}if(u.type==="image_url"){let l=w1t(u);l&&o.push(l)}}return{text:i.join(`
399
399
  `),imageUrls:h7e(o)}}t(E1t,"splitMessageContent");function h7e(r){let i=new Set,o=[];for(let u of r){let l=u.trim();!l||i.has(l)||(i.add(l),o.push(l))}return o}t(h7e,"dedupeStrings");function A1t(r){let i=Gve(r);if(!i||/^https?:/i.test(i))return;if(!/^data:/i.test(i))return i;let o=i.indexOf(",");if(!(o<0||o===i.length-1))return i.slice(o+1).trim()}t(A1t,"normalizeOllamaImage");function T1t(r){let i=r.messages.map(u=>{let{text:l,imageUrls:m}=E1t(u.content),A=m.map(E=>A1t(E)).filter(E=>!!E);return A.length>0?{role:u.role,content:l,images:A}:{role:u.role,content:l}}),o=(Array.isArray(r.images)?r.images:[]).map(u=>A1t(u)).filter(u=>!!u);if(o.length===0)return i;for(let u=i.length-1;u>=0;u-=1){if(i[u]?.role!=="user")continue;let l=i[u].images??[];return i[u].images=h7e([...l,...o]),i}return i.push({role:"user",content:"",images:o}),i}t(T1t,"normalizeOllamaMessages");function Xxn(r){let i=(Array.isArray(r.images)?r.images:[]).map(l=>Gve(l)).filter(l=>!!l),o=[...r.messages].reverse().find(l=>l.role==="user"),u=o?E1t(o.content).imageUrls:[];return h7e([...i,...u])}t(Xxn,"collectBanditPayloadImages");async function*ekn(r){let i=r.body;if(!i)throw new Error("Ollama response has no body.");let o=i.getReader(),u=new TextDecoder,l="";for(;;){let{value:m,done:A}=await o.read();if(A)break;l+=u.decode(m,{stream:!0});let E=l.split(`
@@ -1785,7 +1785,7 @@ ${(()=>{let q=`Bandit insights \u2014 ${new Date(i).toISOString().slice(0,10)}`,
1785
1785
  <h1>You're signed in.</h1>
1786
1786
  <p>Bandit picked up your session. You can close this tab and return to your terminal.</p>
1787
1787
  </div>
1788
- </body></html>`;t(k$n,"startLoopbackListener");t(I$n,"openBrowser");t(D$n,"buildDefaultDeviceLabel");t(P$n,"runOAuthSignIn")});var xbe=Lt((Ffr,N$n)=>{N$n.exports={name:"@burtson-labs/bandit-stealth-cli",version:"1.7.355",description:"Bandit \u2014 a local-first AI coding agent for your terminal. Same runtime as the Bandit Stealth VS Code / Cursor extension.",keywords:["ai","agent","cli","coding-agent","llm","ollama","local-first","bandit","burtson-labs","terminal","repl","developer-tools"],homepage:"https://burtson.ai",bugs:{url:"https://github.com/Burtson-Labs/bandit-agent-framework/issues",email:"team@burtson.ai"},license:"Apache-2.0",author:{name:"Burtson Labs",email:"team@burtson.ai",url:"https://burtson.ai"},repository:{type:"git",url:"git+https://github.com/Burtson-Labs/bandit-agent-framework.git",directory:"apps/bandit-cli"},type:"module",bin:{bandit:"./dist/cli.js"},main:"dist/cli.js",files:["dist/cli.js","README.md","LICENSE"],engines:{node:">=20"},publishConfig:{access:"public"},scripts:{test:"vitest run",typecheck:"tsc -p tsconfig.json --noEmit",build:"node build.mjs","build:publish":"node build.mjs --publish",dev:"node build.mjs --watch",start:"node dist/cli.js",smoke:"node build.mjs && node dist/__smoke__/smoke.js",integration:"node build.mjs && node dist/__integration__/ollama.js",eval:"node build.mjs && node dist/__eval__/eval.js",benchmark:"node build.mjs && node dist/__eval__/benchmark.js","gen-logo":"node scripts/gen-logo.mjs","preview-banner":"node scripts/preview-banner.mjs",clean:"rm -rf dist",prepack:"node scripts/prepack.mjs",postpack:"node scripts/postpack.mjs",prepublishOnly:"pnpm run clean && pnpm run typecheck && pnpm run build:publish"},dependencies:{"pdf-parse":"^2.4.5"},devDependencies:{"@burtson-labs/agent-core":"workspace:*","@burtson-labs/host-kit":"workspace:*","@burtson-labs/stealth-core-runtime":"workspace:*","@types/node":"^20.11.0","@types/pdf-parse":"^1.1.5","@types/pngjs":"^6.0.5","@types/react":"^19.2.2",esbuild:"^0.28.0",ink:"^7.0.4","ink-text-input":"^6.0.0",pngjs:"^7.0.0",react:"^19.2.0",typescript:"^5.4.0",vitest:"^4.0.10"}}});var bUe={};Vre(bUe,{resolveEditor:()=>AUe,spawnEditorOnFile:()=>J$n});import{spawnSync as Q$n,spawn as z$n}from"child_process";import*as Vkt from"path";function AUe(r=process.env){let i=(r.VISUAL??"").trim();if(i.length>0){let{cmd:u,args:l}=Hkt(i);return{label:`$VISUAL (${u})`,cmd:u,args:l}}let o=(r.EDITOR??"").trim();if(o.length>0){let{cmd:u,args:l}=Hkt(o);return{label:`$EDITOR (${u})`,cmd:u,args:l}}return r.TERM_PROGRAM==="vscode"&&Gkt("code",r)?{label:"code --wait (VS Code tab)",cmd:"code",args:["--wait"]}:process.platform==="win32"?{label:"notepad",cmd:"notepad.exe",args:[]}:Gkt("nano",r)?{label:"nano",cmd:"nano",args:[]}:null}async function J$n(r,i){let o=Vkt.resolve(i);return new Promise(u=>{let l=z$n(r.cmd,[...r.args,o],{stdio:"inherit",shell:!1});l.on("exit",(m,A)=>{u({exitCode:typeof m=="number"?m:A?130:1})}),l.on("error",()=>u({exitCode:1}))})}function Hkt(r){let i=r.split(/\s+/).filter(Boolean);return{cmd:i[0]??"",args:i.slice(1)}}function Gkt(r,i){let o=process.platform==="win32"?"where":"which";return Q$n(o,[r],{stdio:"ignore",env:i}).status===0}var Ibe=k3(()=>{"use strict";t(AUe,"resolveEditor");t(J$n,"spawnEditorOnFile");t(Hkt,"splitEditorEnv");t(Gkt,"commandExists")});var Kkt={};Vre(Kkt,{PLAN_FILE:()=>Wkt,STAGING_DIR:()=>RK,loadPlan:()=>Zkt,runWizard:()=>q$n});import*as YJ from"fs";import*as YR from"path";async function Zkt(r){let i=YR.join(r,RK,Wkt),o;try{o=await YJ.promises.readFile(i,"utf-8")}catch{return null}try{let u=JSON.parse(o);return u.version!==1||!Array.isArray(u.entries)||u.entries.length===0?null:u}catch{return null}}async function q$n(r){let i=await Zkt(r.cwd);if(!i)return process.stdout.write(W.red("No migration plan found. ")+W.dim(`Run ${W.cyan("/memory migrate")} first to generate one, then ${W.cyan("/memory migrate apply")} to launch this wizard.
1788
+ </body></html>`;t(k$n,"startLoopbackListener");t(I$n,"openBrowser");t(D$n,"buildDefaultDeviceLabel");t(P$n,"runOAuthSignIn")});var xbe=Lt((Ffr,N$n)=>{N$n.exports={name:"@burtson-labs/bandit-stealth-cli",version:"1.7.357",description:"Bandit \u2014 a local-first AI coding agent for your terminal. Same runtime as the Bandit Stealth VS Code / Cursor extension.",keywords:["ai","agent","cli","coding-agent","llm","ollama","local-first","bandit","burtson-labs","terminal","repl","developer-tools"],homepage:"https://burtson.ai",bugs:{url:"https://github.com/Burtson-Labs/bandit-agent-framework/issues",email:"team@burtson.ai"},license:"Apache-2.0",author:{name:"Burtson Labs",email:"team@burtson.ai",url:"https://burtson.ai"},repository:{type:"git",url:"git+https://github.com/Burtson-Labs/bandit-agent-framework.git",directory:"apps/bandit-cli"},type:"module",bin:{bandit:"./dist/cli.js"},main:"dist/cli.js",files:["dist/cli.js","README.md","LICENSE"],engines:{node:">=20"},publishConfig:{access:"public"},scripts:{test:"vitest run",typecheck:"tsc -p tsconfig.json --noEmit",build:"node build.mjs","build:publish":"node build.mjs --publish",dev:"node build.mjs --watch",start:"node dist/cli.js",smoke:"node build.mjs && node dist/__smoke__/smoke.js",integration:"node build.mjs && node dist/__integration__/ollama.js",eval:"node build.mjs && node dist/__eval__/eval.js",benchmark:"node build.mjs && node dist/__eval__/benchmark.js","gen-logo":"node scripts/gen-logo.mjs","preview-banner":"node scripts/preview-banner.mjs",clean:"rm -rf dist",prepack:"node scripts/prepack.mjs",postpack:"node scripts/postpack.mjs",prepublishOnly:"pnpm run clean && pnpm run typecheck && pnpm run build:publish"},dependencies:{"pdf-parse":"^2.4.5"},devDependencies:{"@burtson-labs/agent-core":"workspace:*","@burtson-labs/host-kit":"workspace:*","@burtson-labs/stealth-core-runtime":"workspace:*","@types/node":"^20.11.0","@types/pdf-parse":"^1.1.5","@types/pngjs":"^6.0.5","@types/react":"^19.2.2",esbuild:"^0.28.0",ink:"^7.0.4","ink-text-input":"^6.0.0",pngjs:"^7.0.0",react:"^19.2.0",typescript:"^5.4.0",vitest:"^4.0.10"}}});var bUe={};Vre(bUe,{resolveEditor:()=>AUe,spawnEditorOnFile:()=>J$n});import{spawnSync as Q$n,spawn as z$n}from"child_process";import*as Vkt from"path";function AUe(r=process.env){let i=(r.VISUAL??"").trim();if(i.length>0){let{cmd:u,args:l}=Hkt(i);return{label:`$VISUAL (${u})`,cmd:u,args:l}}let o=(r.EDITOR??"").trim();if(o.length>0){let{cmd:u,args:l}=Hkt(o);return{label:`$EDITOR (${u})`,cmd:u,args:l}}return r.TERM_PROGRAM==="vscode"&&Gkt("code",r)?{label:"code --wait (VS Code tab)",cmd:"code",args:["--wait"]}:process.platform==="win32"?{label:"notepad",cmd:"notepad.exe",args:[]}:Gkt("nano",r)?{label:"nano",cmd:"nano",args:[]}:null}async function J$n(r,i){let o=Vkt.resolve(i);return new Promise(u=>{let l=z$n(r.cmd,[...r.args,o],{stdio:"inherit",shell:!1});l.on("exit",(m,A)=>{u({exitCode:typeof m=="number"?m:A?130:1})}),l.on("error",()=>u({exitCode:1}))})}function Hkt(r){let i=r.split(/\s+/).filter(Boolean);return{cmd:i[0]??"",args:i.slice(1)}}function Gkt(r,i){let o=process.platform==="win32"?"where":"which";return Q$n(o,[r],{stdio:"ignore",env:i}).status===0}var Ibe=k3(()=>{"use strict";t(AUe,"resolveEditor");t(J$n,"spawnEditorOnFile");t(Hkt,"splitEditorEnv");t(Gkt,"commandExists")});var Kkt={};Vre(Kkt,{PLAN_FILE:()=>Wkt,STAGING_DIR:()=>RK,loadPlan:()=>Zkt,runWizard:()=>q$n});import*as YJ from"fs";import*as YR from"path";async function Zkt(r){let i=YR.join(r,RK,Wkt),o;try{o=await YJ.promises.readFile(i,"utf-8")}catch{return null}try{let u=JSON.parse(o);return u.version!==1||!Array.isArray(u.entries)||u.entries.length===0?null:u}catch{return null}}async function q$n(r){let i=await Zkt(r.cwd);if(!i)return process.stdout.write(W.red("No migration plan found. ")+W.dim(`Run ${W.cyan("/memory migrate")} first to generate one, then ${W.cyan("/memory migrate apply")} to launch this wizard.
1789
1789
  `)),{applied:0,skipped:0,edited:0,quit:!0,originalBackup:""};let o=AUe();if(!o)return process.stdout.write(W.red("No editor available. ")+W.dim("Set $EDITOR (e.g. ")+W.cyan("EDITOR=code")+W.dim(") or ")+W.cyan("EDITOR=nano")+W.dim(" and rerun ")+W.cyan("/memory migrate apply")+W.dim(". ")+W.dim("You can also edit the files under ")+W.cyan(RK)+W.dim(` directly with any editor before running apply \u2014 the wizard reads them as-is.
1790
1790
  `)),{applied:0,skipped:0,edited:0,quit:!0,originalBackup:""};let u="\u2550".repeat(60);process.stdout.write(`
1791
1791
  `+W.accent(u)+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burtson-labs/bandit-stealth-cli",
3
- "version": "1.7.355",
3
+ "version": "1.7.357",
4
4
  "description": "Bandit — a local-first AI coding agent for your terminal. Same runtime as the Bandit Stealth VS Code / Cursor extension.",
5
5
  "keywords": [
6
6
  "ai",