@hasna/assistants 1.1.98 → 1.1.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1038,7 +1038,7 @@ Use /help to see available commands.
|
|
|
1038
1038
|
`).map((o)=>`${indent2}${o}`),`${indent2}\`\`\``];processedLines.push(fenced.join(`
|
|
1039
1039
|
`))}else processedLines.push(line)}return processedLines.join(`
|
|
1040
1040
|
`)}async executeShell(command,cwd){let validation=validateBashCommand(command);if(!validation.valid)return getSecurityLogger().log({eventType:"blocked_command",severity:validation.severity||"high",details:{tool:"custom_command",command,reason:validation.reason||"Command blocked by security policy"},sessionId:"custom-command"}),`Error: ${validation.reason||"Command blocked by security policy"}`;try{let runtime=getRuntime(),timeoutMs=5000,isWindows=process.platform==="win32",shellBinary=isWindows?"cmd":runtime.which("bash")||"sh",shellArgs=isWindows?["/c",command]:["-lc",command],proc=runtime.spawn([shellBinary,...shellArgs],{cwd,stdin:"ignore",stdout:"pipe",stderr:"pipe"}),timedOut=!1,timer=setTimeout(()=>{timedOut=!0,proc.kill()},5000),[stdout,stderr]=await Promise.all([proc.stdout?new Response(proc.stdout).text():"",proc.stderr?new Response(proc.stderr).text():""]),exitCode=await proc.exited;if(clearTimeout(timer),timedOut)return`Error: command timed out after ${Math.round(5)}s.`;if(exitCode!==0&&stderr){let truncatedStderr=stderr.length>MAX_SHELL_OUTPUT_LENGTH?`${stderr.slice(0,MAX_SHELL_OUTPUT_LENGTH)}...(truncated)`:stderr;return`Error (exit ${exitCode}):
|
|
1041
|
-
${truncatedStderr}`}let trimmedOutput=stdout.trim();if(trimmedOutput.length>MAX_SHELL_OUTPUT_LENGTH)return`${trimmedOutput.slice(0,MAX_SHELL_OUTPUT_LENGTH)}...(output truncated at ${MAX_SHELL_OUTPUT_LENGTH} bytes)`;return trimmedOutput||"(no output)"}catch(error2){return`Error: ${error2 instanceof Error?error2.message:String(error2)}`}}getSuggestions(partial){if(!partial.startsWith("/"))return[];let name=partial.slice(1).toLowerCase();return this.loader.findMatching(name)}}var MAX_SHELL_OUTPUT_LENGTH=65536;var init_executor4=__esm(async()=>{init_bash_validator();await __promiseAll([init_runtime(),init_logger()])});function resolveAuthTimeout(resolve11){resolve11({exitCode:1,stdout:{toString:()=>"{}"}})}function splitArgs(input){let args=[],current="",quote=null,escaped=!1;for(let i=0;i<input.length;i+=1){let char=input[i];if(quote){if(escaped){current+=char,escaped=!1;continue}if(char==="\\"){escaped=!0;continue}if(char===quote){quote=null;continue}current+=char;continue}if(char==='"'||char==="'"){quote=char;continue}if(char===" "||char==="\t"){if(current)args.push(current),current="";continue}current+=char}if(current)args.push(current);return args}function singleLine2(value2){return value2.replace(/[\r\n]+/g," ").replace(/\s+/g," ").trim()}function formatAge(ms){let seconds=Math.floor(ms/1000);if(seconds<60)return`${seconds}s`;let minutes=Math.floor(seconds/60);if(minutes<60)return`${minutes}m`;let hours=Math.floor(minutes/60);if(hours<24)return`${hours}h`;return`${Math.floor(hours/24)}d`}function createTokenUsage(){return{inputTokens:0,outputTokens:0,totalTokens:0,maxContextTokens:200000}}var VERSION2="1.1.
|
|
1041
|
+
${truncatedStderr}`}let trimmedOutput=stdout.trim();if(trimmedOutput.length>MAX_SHELL_OUTPUT_LENGTH)return`${trimmedOutput.slice(0,MAX_SHELL_OUTPUT_LENGTH)}...(output truncated at ${MAX_SHELL_OUTPUT_LENGTH} bytes)`;return trimmedOutput||"(no output)"}catch(error2){return`Error: ${error2 instanceof Error?error2.message:String(error2)}`}}getSuggestions(partial){if(!partial.startsWith("/"))return[];let name=partial.slice(1).toLowerCase();return this.loader.findMatching(name)}}var MAX_SHELL_OUTPUT_LENGTH=65536;var init_executor4=__esm(async()=>{init_bash_validator();await __promiseAll([init_runtime(),init_logger()])});function resolveAuthTimeout(resolve11){resolve11({exitCode:1,stdout:{toString:()=>"{}"}})}function splitArgs(input){let args=[],current="",quote=null,escaped=!1;for(let i=0;i<input.length;i+=1){let char=input[i];if(quote){if(escaped){current+=char,escaped=!1;continue}if(char==="\\"){escaped=!0;continue}if(char===quote){quote=null;continue}current+=char;continue}if(char==='"'||char==="'"){quote=char;continue}if(char===" "||char==="\t"){if(current)args.push(current),current="";continue}current+=char}if(current)args.push(current);return args}function singleLine2(value2){return value2.replace(/[\r\n]+/g," ").replace(/\s+/g," ").trim()}function formatAge(ms){let seconds=Math.floor(ms/1000);if(seconds<60)return`${seconds}s`;let minutes=Math.floor(seconds/60);if(minutes<60)return`${minutes}m`;let hours=Math.floor(minutes/60);if(hours<24)return`${hours}h`;return`${Math.floor(hours/24)}d`}function createTokenUsage(){return{inputTokens:0,outputTokens:0,totalTokens:0,maxContextTokens:200000}}var VERSION2="1.1.99";function aboutCommand(){return{name:"about",description:"About Hasna and Assistants",builtin:!0,selfHandled:!0,content:"",handler:async(_args,context)=>{let message=`
|
|
1042
1042
|
**About Hasna**
|
|
1043
1043
|
|
|
1044
1044
|
`;return message+=`Hasna is on a mission to make AI more useful to everyone.
|
|
@@ -5945,7 +5945,7 @@ Interactive Mode:
|
|
|
5945
5945
|
- Press Ctrl+C to exit
|
|
5946
5946
|
`),exit3(0);return}if(options2.print!==null){if(!options2.print.trim()){print("Error: Prompt is required with -p/--print flag"),exit3(1);return}if(options2.temperature!==null)process.env.ASSISTANTS_TEMPERATURE=String(options2.temperature);if(options2.noMemory)process.env.ASSISTANTS_NO_MEMORY="1";await runHeadless2({prompt:options2.print,cwd:options2.cwd,outputFormat:options2.outputFormat,allowedTools:options2.allowedTools.length>0?options2.allowedTools:void 0,systemPrompt:options2.systemPrompt||void 0,jsonSchema:options2.jsonSchema||void 0,continue:options2.continue,resume:options2.resume,cwdProvided:options2.cwdProvided,timeoutMs:options2.headlessTimeoutMs,temperature:options2.temperature,costLimit:options2.costLimit,noMemory:options2.noMemory})}}var jsx_dev_runtime53=__toESM(require_react_jsx_dev_runtime_development(),1);setRuntime(bunRuntime);var _worktreeCleanup=null;function cleanup(){if(_worktreeCleanup)_worktreeCleanup();closeDatabase()}process.on("SIGINT",()=>{cleanup(),process.exit(0)});process.on("SIGTERM",()=>{cleanup(),process.exit(0)});process.on("uncaughtException",(error4)=>{process.stderr.write(`Uncaught exception: ${error4}
|
|
5947
5947
|
`),cleanup(),process.exit(1)});process.on("unhandledRejection",(reason)=>{process.stderr.write(`Unhandled rejection: ${reason}
|
|
5948
|
-
`),cleanup(),process.exit(1)});var VERSION4="1.1.
|
|
5948
|
+
`),cleanup(),process.exit(1)});var VERSION4="1.1.99",SYNC_START="\x1B[?2026h",SYNC_END="\x1B[?2026l";function enableSynchronizedOutput(){let originalWrite=process.stdout.write.bind(process.stdout),buffer="",flushScheduled=!1;function flush(){if(flushScheduled=!1,!buffer)return;let output=buffer;buffer="",originalWrite(SYNC_START+output+SYNC_END)}return process.stdout.write=function(chunk,encodingOrCallback,callback){let raw=typeof chunk==="string"?chunk:chunk.toString(),safe=sanitizeTerminalOutput(raw);if(buffer+=safe,!flushScheduled)flushScheduled=!0,queueMicrotask(flush);if(typeof encodingOrCallback==="function")encodingOrCallback();else if(callback)callback();return!0},()=>{flush(),process.stdout.write=originalWrite}}var subcommand=process.argv[2];if(subcommand==="autocomplete"){let shell=(process.argv[3]||"zsh").toLowerCase(),subcommands=["mcp","doctor","serve","report","config","sessions","search","autocomplete"],flags=["--help","-h","--version","-v","--print","-p","--output-format","--allowed-tools","--system-prompt","--json-schema","--headless-timeout-ms","--continue","-c","--resume","-r","--cwd","--worktree","--permission-mode","--temperature","--cost-limit","--no-memory"];if(shell==="zsh")console.log(`# assistants zsh completion
|
|
5949
5949
|
# Add to ~/.zshrc: source <(assistants autocomplete zsh)
|
|
5950
5950
|
|
|
5951
5951
|
_assistants() {
|
|
@@ -6074,4 +6074,4 @@ Interactive Mode:
|
|
|
6074
6074
|
- Press Ctrl+C to exit
|
|
6075
6075
|
`),process.exit(0);var activeWorktree=null;if(options2.worktree!==null)try{let worktreeName=typeof options2.worktree==="string"?options2.worktree:void 0;activeWorktree=createWorktree(options2.cwd,worktreeName),options2.cwd=activeWorktree.path,console.log(`Worktree created: ${activeWorktree.path}`)}catch(error4){console.error(`Error creating worktree: ${error4 instanceof Error?error4.message:error4}`),process.exit(1)}function cleanupWorktree(){if(activeWorktree){if(removeWorktree(activeWorktree.path))console.log(`Worktree cleaned up: ${activeWorktree.path}`);else console.log(`Worktree retained (has changes): ${activeWorktree.path}`);activeWorktree=null}}_worktreeCleanup=cleanupWorktree;if(options2.print!==null){if(!options2.print.trim())console.error("Error: Prompt is required with -p/--print flag"),process.exit(1);runHeadless({prompt:options2.print,cwd:options2.cwd,outputFormat:options2.outputFormat,allowedTools:options2.allowedTools.length>0?options2.allowedTools:void 0,systemPrompt:options2.systemPrompt||void 0,jsonSchema:options2.jsonSchema||void 0,continue:options2.continue,resume:options2.resume,cwdProvided:options2.cwdProvided,timeoutMs:options2.headlessTimeoutMs,permissionMode:options2.permissionMode??void 0}).then((result)=>{cleanup(),process.exit(result.success?0:1)}).catch((error4)=>{cleanup(),console.error("Error:",error4.message),process.exit(1)})}else{let disableSyncOutput=process.env.ASSISTANTS_NO_SYNC!=="1"?enableSynchronizedOutput():()=>{},appElement=jsx_dev_runtime53.jsxDEV(App2,{cwd:options2.cwd,version:VERSION4,permissionMode:options2.permissionMode??void 0},void 0,!1,void 0,this),{waitUntilExit}=render_default(appElement,{patchConsole:!0,exitOnCtrlC:!1});waitUntilExit().then(()=>{disableSyncOutput();let stats=getExitStats();if(stats)printExitSummary(stats);cleanup(),process.exit(0)})}export{parseArgs,main};
|
|
6076
6076
|
|
|
6077
|
-
//# debugId=
|
|
6077
|
+
//# debugId=F06CB6E27E85C42964756E2164756E21
|