@code-yeongyu/senpi 2026.10.1-2 → 2026.10.1
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/CHANGELOG.md +1 -17
- package/dist/bundle/chunks/{app-server-command-P5OFBB4F.js → app-server-command-CZT5WSC4.js} +1 -1
- package/dist/bundle/chunks/chunk-45PHWY2H.js +9 -0
- package/dist/bundle/chunks/{chunk-U67UZN7N.js → chunk-JWHA752H.js} +137 -137
- package/dist/bundle/chunks/{chunk-LFPTNJFL.js → chunk-P4MKROXN.js} +1 -1
- package/dist/bundle/chunks/{chunk-GFJGG447.js → chunk-ZUQ36DFK.js} +1 -1
- package/dist/bundle/chunks/{cli-main-NG6YCUOL.js → cli-main-RCIUWYKL.js} +1 -1
- package/dist/bundle/chunks/{interactive-mode-MPZJRI3K.js → interactive-mode-M64RXEHC.js} +1 -1
- package/dist/bundle/chunks/{multi-session-host-EP53H7TX.js → multi-session-host-BPDPIBNN.js} +1 -1
- package/dist/bundle/chunks/{package-manager-cli-ZEWHBRS5.js → package-manager-cli-Y3GREN75.js} +1 -1
- package/dist/bundle/chunks/{rotation-stream-3JC676HE.js → rotation-stream-PH5JIQBD.js} +1 -1
- package/dist/bundle/chunks/{rpc-mode-EE3ZMJSB.js → rpc-mode-TB4O62O7.js} +1 -1
- package/dist/bundle/chunks/{schedule-command-GSAMNT2Y.js → schedule-command-IN6IJG2Y.js} +1 -1
- package/dist/bundle/chunks/session-worker.js +338 -346
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/bundle/runtime-manifest.json +1 -1
- package/dist/core/extensions/builtin/anthropic-subscription/content-blocks.d.ts +0 -1
- package/dist/core/extensions/builtin/anthropic-subscription/content-blocks.js +0 -3
- package/dist/core/extensions/builtin/anthropic-subscription/prompt-bridge.js +3 -5
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -2
- package/dist/utils/shell.js +2 -3
- package/package.json +6 -6
- package/dist/bundle/chunks/chunk-2SC5XIAI.js +0 -17
- package/dist/core/extensions/builtin/anthropic-subscription/cold-seed-images.d.ts +0 -30
- package/dist/core/extensions/builtin/anthropic-subscription/cold-seed-images.js +0 -133
- package/dist/utils/bundled-bun.d.ts +0 -16
- package/dist/utils/bundled-bun.js +0 -101
package/dist/bundle/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
3
3
|
import{enableStartupCompileCache}from"./chunks/chunk-F73COJ7R.js";import{getLatestPiRelease,hasInheritedInspectorOption,isNewerPackageVersion,processBunRuntimeOptions,releaseInheritedInspectorForChild,resolveBunReexec}from"./chunks/chunk-LX75SBFN.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,DISPLAY_VERSION,PACKAGE_NAME,RUNTIME_SNAPSHOT_MARKER,VERSION,brandProfile,findNodePackageDir,getAgentDir,getInstallPackageDir,getSelfUpdateCommand,getSelfUpdateUnavailableInstruction,isBundledNode,readRuntimeSnapshotMarker}from"./chunks/chunk-JCTWDSQT.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-IKOFCODM.js";import{spawn as spawn2,spawnSync}from"node:child_process";import{existsSync as existsSync2,realpathSync as realpathSync3}from"node:fs";import{dirname as dirname3,join as join5}from"node:path";import{fileURLToPath}from"node:url";import{createHash}from"node:crypto";import{readFileSync as readFileSync3,realpathSync as realpathSync2}from"node:fs";import{basename as basename2,dirname as dirname2,join as join3,relative}from"node:path";import{pathToFileURL}from"node:url";import{existsSync,mkdirSync,readdirSync,readFileSync,realpathSync,renameSync,rmSync,statSync,writeFileSync}from"node:fs";import{basename,dirname,join}from"node:path";import{constants}from"node:fs";import{copyFile,link}from"node:fs/promises";function errorCode(error){return error instanceof Error&&"code"in error?error.code:void 0}var FILE_OPERATIONS={copyFile,link},COPY_CONCURRENCY=8;function nextCopyMode(mode,error,platform){let code=errorCode(error);if(!(code==="ENOENT"||code==="ENOTDIR"||code==="EEXIST"))switch(mode){case"clone":return platform==="darwin"&&code==="ENOSYS"?"clone-or-copy":"link";case"link":return"copy";case"clone-or-copy":case"copy":return}}function createSnapshotFileCopier(platform=process.platform,operations=FILE_OPERATIONS){let mode="clone",attempt=(current,source,target)=>{switch(current){case"clone":return operations.copyFile(source,target,constants.COPYFILE_FICLONE_FORCE);case"clone-or-copy":return operations.copyFile(source,target,constants.COPYFILE_FICLONE);case"link":return operations.link(source,target);case"copy":return operations.copyFile(source,target,0)}};return{get mode(){return mode},async copy(source,target){for(let current=mode;;)try{await attempt(current,source,target);return}catch(error){let next=nextCopyMode(current,error,platform);if(next===void 0)throw error;current=next,mode=next}}}}async function copyFiles(pairs,copier){let next=0,worker=async()=>{for(let index=next++;index<pairs.length;index=next++){let[source,target]=pairs[index]??[];source!==void 0&&target!==void 0&&await copier.copy(source,target)}};await Promise.all(Array.from({length:Math.min(COPY_CONCURRENCY,pairs.length)},worker))}var RuntimeSnapshotLayoutError=class extends Error{constructor(packageName){super(`runtime snapshot resolves ${packageName} differently from the install`),this.packageName=packageName}},STAGING_PREFIX=".tmp-",UNLOADED_FILE=/\.(?:d\.[cm]?ts|map)$/;function isMissing(error){return error instanceof Error&&"code"in error&&(error.code==="ENOENT"||error.code==="ENOTDIR")}function planTree(source,target,files,skipModules,seen=new Set){let real=realpathSync(source);if(!seen.has(real)){seen.add(real),mkdirSync(target,{recursive:!0});for(let entry of readdirSync(real,{withFileTypes:!0})){if(skipModules&&entry.name==="node_modules")continue;let from=join(real,entry.name),to=join(target,entry.name);if(entry.isDirectory())planTree(from,to,files,skipModules,seen);else if(entry.isFile())UNLOADED_FILE.test(entry.name)||files.push([from,to]);else if(entry.isSymbolicLink()){let isDirectory;try{isDirectory=statSync(from).isDirectory()}catch(error){if(isMissing(error))continue;throw error}isDirectory?planTree(from,to,files,skipModules,seen):UNLOADED_FILE.test(entry.name)||files.push([realpathSync(from),to])}}seen.delete(real)}}function moduleDirectoriesFrom(dir){let directories=[];for(let current=dir;;current=dirname(current)){if(basename(current)!=="node_modules"){let candidate=join(current,"node_modules");existsSync(candidate)&&directories.push(candidate)}if(dirname(current)===current)return directories}}function packageRootFrom(dir,packageName){for(let modules of moduleDirectoriesFrom(dir)){let root=join(modules,packageName);if(existsSync(join(root,"package.json")))return realpathSync(root)}}function dependencyNames(packageDir){let manifest=JSON.parse(readFileSync(join(packageDir,"package.json"),"utf8"));if(typeof manifest!="object"||manifest===null)return[];let names=new Set;for(let field of["dependencies","optionalDependencies","peerDependencies"]){let block=manifest[field];if(typeof block=="object"&&block!==null)for(let name of Object.keys(block))names.add(name)}return[...names]}function closureNames(packageDir,extra){let names=new Set(extra),visited=new Set,pending=[realpathSync(packageDir)];for(let dir=pending.pop();dir!==void 0;dir=pending.pop())if(!visited.has(dir)){visited.add(dir);for(let name of dependencyNames(dir)){names.add(name);let root=packageRootFrom(dir,name);root!==void 0&&!visited.has(root)&&pending.push(root)}}return names}function planModules(packageDir,snapshotRoot,externals,files){let self=realpathSync(packageDir),placed=new Map,pending=[],place=(installDir,snapshotDir)=>{planTree(installDir,snapshotDir,files,!0),placed.set(snapshotDir,installDir),pending.push({installDir,snapshotDir})},resolvePlaced=(from,name)=>{for(let dir=from;;dir=dirname(dir)){if(basename(dir)!=="node_modules"){let found=placed.get(join(dir,"node_modules",name));if(found!==void 0)return found}if(dir===snapshotRoot||dirname(dir)===dir)return}};for(let name of closureNames(packageDir,externals)){let source=packageRootFrom(packageDir,name);source!==void 0&&source!==self&&place(source,join(snapshotRoot,"node_modules",name))}for(let next=pending.shift();next!==void 0;next=pending.shift())for(let name of dependencyNames(next.installDir)){let expected=packageRootFrom(next.installDir,name);expected===void 0||expected===self||resolvePlaced(next.snapshotDir,name)!==expected&&place(expected,join(next.snapshotDir,"node_modules",name))}return placed}function verifyExternals(packageDir,snapshotBundleDir,externals,placed){for(let name of externals){let expected=packageRootFrom(packageDir,name);if(expected===void 0)continue;let found=moduleDirectoriesFrom(snapshotBundleDir).map(modules=>join(modules,name)).find(root=>existsSync(join(root,"package.json")));if(found===void 0||placed.get(found)!==expected)throw new RuntimeSnapshotLayoutError(name)}}async function materializeRuntimeSnapshot(packageDir,target,manifest,copier=createSnapshotFileCopier()){let staging=join(dirname(target),`${STAGING_PREFIX}${basename(target)}-${process.pid}`);rmSync(staging,{recursive:!0,force:!0});try{let files=[];planTree(packageDir,staging,files,!0);let placed=planModules(packageDir,staging,manifest.externals,files);await copyFiles(files,copier),verifyExternals(packageDir,join(staging,"dist","bundle","chunks"),manifest.externals,placed);let marker={buildId:manifest.buildId,installPackageDir:realpathSync(packageDir)};writeFileSync(join(staging,RUNTIME_SNAPSHOT_MARKER),`${JSON.stringify(marker)}
|
|
4
|
-
`),rmSync(target,{recursive:!0,force:!0}),renameSync(staging,target)}catch(error){throw rmSync(staging,{recursive:!0,force:!0}),error}}import{mkdirSync as mkdirSync2,readdirSync as readdirSync2,readFileSync as readFileSync2,renameSync as renameSync2,rmSync as rmSync2,statSync as statSync2,unlinkSync,utimesSync,writeFileSync as writeFileSync2}from"node:fs";import{join as join2}from"node:path";var LOCK_NAME=".lock",CLAIMS_DIR="claims",STALE_LOCK_MS=3e4,LOCK_WAIT_MS=5e3,LOCK_RETRY_MS=25,BUILD_LOCK_PREFIX=".build-",BUILD_WAIT_MS=12e4,BUILD_RETRY_MS=50,UNOWNED_BUILD_LOCK_MS=3e4,UNUSED_SNAPSHOT_GRACE_MS=10*6e4,LEFTOVER_MS=60*6e4;function errorCode2(error){return error instanceof Error&&"code"in error?error.code:void 0}function ageMs(path,now){try{return now-statSync2(path).mtimeMs}catch(error){if(errorCode2(error)==="ENOENT")return Number.POSITIVE_INFINITY;throw error}}function sleepSync(ms){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,ms)}function withRuntimeLock(root,task){mkdirSync2(root,{recursive:!0});let lock=join2(root,LOCK_NAME),deadline=Date.now()+LOCK_WAIT_MS;for(;;){try{mkdirSync2(lock);break}catch(error){if(errorCode2(error)!=="EEXIST")throw error}if(ageMs(lock,Date.now())>STALE_LOCK_MS)rmSync2(lock,{recursive:!0,force:!0});else{if(Date.now()>deadline)return;sleepSync(LOCK_RETRY_MS)}}try{return task()}finally{rmSync2(lock,{recursive:!0,force:!0})}}function buildLockHolder(lock){try{let pid=Number(readFileSync2(join2(lock,"pid"),"utf8"));return Number.isSafeInteger(pid)&&pid>0?pid:void 0}catch(error){if(errorCode2(error)==="ENOENT"||errorCode2(error)==="ENOTDIR")return;throw error}}function isAbandonedBuildLock(lock,now,isAlive){let holder=buildLockHolder(lock);return holder===void 0?ageMs(lock,now)>UNOWNED_BUILD_LOCK_MS:!isAlive(holder)}async function withBuildLock(root,id,build,isAlive=isProcessAlive){mkdirSync2(root,{recursive:!0});let lock=join2(root,`${BUILD_LOCK_PREFIX}${id}`),deadline=Date.now()+BUILD_WAIT_MS;for(;;){try{mkdirSync2(lock),writeFileSync2(join2(lock,"pid"),String(process.pid));break}catch(error){if(errorCode2(error)!=="EEXIST")throw error}if(isAbandonedBuildLock(lock,Date.now(),isAlive))rmSync2(lock,{recursive:!0,force:!0});else{if(Date.now()>deadline)return;sleepSync(BUILD_RETRY_MS)}}try{for(let name of readdirSync2(root))name.startsWith(`${STAGING_PREFIX}${id}-`)&&rmSync2(join2(root,name),{recursive:!0,force:!0});return await build()}finally{rmSync2(lock,{recursive:!0,force:!0})}}function isProcessAlive(pid){try{return process.kill(pid,0),!0}catch(error){return errorCode2(error)!=="ESRCH"}}function claimRuntimeSnapshot(snapshotDir,pid){mkdirSync2(join2(snapshotDir,CLAIMS_DIR),{recursive:!0}),writeFileSync2(join2(snapshotDir,CLAIMS_DIR,String(pid)),"");let now=new Date;utimesSync(join2(snapshotDir,RUNTIME_SNAPSHOT_MARKER),now,now)}function reapClaims(snapshotDir,isAlive){let names;try{names=readdirSync2(join2(snapshotDir,CLAIMS_DIR))}catch(error){if(errorCode2(error)==="ENOENT")return 0;throw error}let live=0;for(let name of names){let pid=Number(name);Number.isSafeInteger(pid)&&pid>0&&isAlive(pid)?live+=1:unlinkSync(join2(snapshotDir,CLAIMS_DIR,name))}return live}function pruneRuntimeSnapshots(root,keep,now,isAlive=isProcessAlive){reapClaims(join2(root,keep),isAlive);for(let name of readdirSync2(root)){if(name===LOCK_NAME||name===keep)continue;let path=join2(root,name);if(name.startsWith(".")){ageMs(path,now)>LEFTOVER_MS&&rmSync2(path,{recursive:!0,force:!0});continue}if(reapClaims(path,isAlive)>0||ageMs(join2(path,RUNTIME_SNAPSHOT_MARKER),now)<=UNUSED_SNAPSHOT_GRACE_MS)continue;let trash=join2(root,`.trash-${name}-${process.pid}`);renameSync2(path,trash),rmSync2(trash,{recursive:!0,force:!0})}}var RUNTIME_MANIFEST="runtime-manifest.json";function readRuntimeManifest(bundleDir){let parsed;try{parsed=JSON.parse(readFileSync3(join3(bundleDir,RUNTIME_MANIFEST),"utf8"))}catch(error){if(error instanceof Error&&"code"in error&&error.code==="ENOENT")return;throw error}if(typeof parsed=="object"&&parsed!==null&&"buildId"in parsed&&typeof parsed.buildId=="string"&&/^[A-Za-z0-9._-]+$/.test(parsed.buildId)&&"externals"in parsed&&Array.isArray(parsed.externals)&&parsed.externals.every(name=>typeof name=="string"))return{buildId:parsed.buildId,externals:parsed.externals}}async function prepareRuntimeSnapshot(entryPath,packageDir,agentDir){let bundleDir=dirname2(entryPath),runtimeRoot=join3(agentDir,"runtime");try{if(readRuntimeSnapshotMarker(packageDir))return withRuntimeLock(runtimeRoot,()=>claimRuntimeSnapshot(packageDir,process.pid)),{kind:"run-here"};let manifest=readRuntimeManifest(bundleDir);if(!manifest||relative(packageDir,bundleDir)!==join3("dist","bundle"))return{kind:"run-here"};let installId=createHash("sha256").update(realpathSync2(packageDir)).digest("hex").slice(0,12),snapshotId=`${manifest.buildId}-${installId}`,snapshotDir=join3(runtimeRoot,snapshotId),isBuilt=()=>readRuntimeSnapshotMarker(snapshotDir)?.buildId===manifest.buildId,claim=()=>withRuntimeLock(runtimeRoot,()=>isBuilt()?(claimRuntimeSnapshot(snapshotDir,process.pid),pruneRuntimeSnapshots(runtimeRoot,snapshotId,Date.now()),!0):!1),claimed=claim();return claimed===!1&&await withBuildLock(runtimeRoot,snapshotId,async()=>(isBuilt()||await materializeRuntimeSnapshot(packageDir,snapshotDir,manifest),!0))&&(claimed=claim()),claimed!==!0?{kind:"run-here"}:{kind:"hand-off",entryUrl:pathToFileURL(join3(snapshotDir,"dist","bundle",basename2(entryPath))).href,snapshotDir}}catch{return{kind:"run-here"}}}import{spawn}from"node:child_process";import{readFileSync as readFileSync4}from"node:fs";import{join as join4}from"node:path";function parseBootstrapSelfUpdateArgs(args2){let[command,...rest]=args2;if(command!=="update")return;let force=!1,selfFlag=!1,extensionsFlag=!1,extensionFlag=!1,source;for(let index=0;index<rest.length;index++){let arg=rest[index];if(arg==="-h"||arg==="--help")return;if(arg==="--force"){force=!0;continue}if(arg==="--self"){selfFlag=!0;continue}if(arg==="--extensions"){extensionsFlag=!0;continue}if(arg==="--extension"){extensionFlag=!0,index++;continue}if(arg.startsWith("-")||source)return;source=arg}if(extensionFlag)return;let sourceIsSelf=source==="self"||source==="pi"||source===APP_NAME;if(!(source&&!sourceIsSelf)&&!(!selfFlag&&!sourceIsSelf&&extensionsFlag))return{force}}function getObjectProperty(value,key){if(!(!value||typeof value!="object"))return Object.getOwnPropertyDescriptor(value,key)?.value}function readConfiguredNpmCommand(){try{let parsed=JSON.parse(readFileSync4(join4(getAgentDir(),"settings.json"),"utf-8")),npmCommand=getObjectProperty(parsed,"npmCommand");return!Array.isArray(npmCommand)||npmCommand.some(part=>typeof part!="string")?void 0:npmCommand.length>0?npmCommand:void 0}catch{return}}async function runCommand(step){await new Promise((resolve,reject)=>{let child=spawn(step.command,step.args,{stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{code===0?resolve():reject(signal?new Error(`${step.display} terminated by signal ${signal}`):new Error(`${step.display} exited with code ${code??"unknown"}`))})})}async function handleBootstrapSelfUpdate(args2,dependencies={}){let parsed=parseBootstrapSelfUpdateArgs(args2);if(!parsed)return!1;let writeStdout=dependencies.writeStdout??(line=>console.log(line)),writeStderr=dependencies.writeStderr??(line=>console.error(line)),readNpmCommand=dependencies.readNpmCommand??readConfiguredNpmCommand,resolveSelfUpdateCommand=dependencies.getSelfUpdateCommand??getSelfUpdateCommand,resolveUnavailableInstruction=dependencies.getUnavailableInstruction??getSelfUpdateUnavailableInstruction,executeCommand=dependencies.runCommand??runCommand,brandUpdate=brandProfile()?.update;if(brandUpdate)return writeStdout(`${APP_NAME} ships inside ${brandUpdate.packageName}. Update it with: ${brandUpdate.command}`),!0;let loadLatestRelease=dependencies.getLatestRelease??getLatestPiRelease,latestRelease;if(!parsed.force)try{latestRelease=await loadLatestRelease(VERSION)}catch{latestRelease=void 0}let updatePackageName=latestRelease?.packageName??PACKAGE_NAME;if(!(parsed.force||!latestRelease||updatePackageName!==PACKAGE_NAME||isNewerPackageVersion(latestRelease.version,VERSION)))return writeStdout(`${APP_NAME} is already up to date (v${VERSION})`),!0;let npmCommand=readNpmCommand(),selfUpdateCommand=resolveSelfUpdateCommand(PACKAGE_NAME,npmCommand,updatePackageName);if(!selfUpdateCommand)return writeStderr(`error: ${APP_NAME} cannot self-update this installation.`),writeStderr(resolveUnavailableInstruction(PACKAGE_NAME,npmCommand,updatePackageName)),process.argv[1]&&(writeStderr(""),writeStderr(`Location of ${APP_NAME} executable: ${process.argv[1]}`)),process.exitCode=1,!0;latestRelease?.note?.trim()&&(writeStdout(""),writeStdout("Update note"),writeStdout(latestRelease.note.trim()),writeStdout("")),writeStdout(`Updating ${APP_NAME} with ${selfUpdateCommand.display}...`);for(let step of selfUpdateCommand.steps??[selfUpdateCommand])try{await executeCommand(step)}catch(error){let message=error instanceof Error?error.message:"Unknown package command error";return writeStderr(`Error: ${message}`),writeStderr(`If this keeps failing, run this command yourself: ${selfUpdateCommand.display}`),process.exitCode=1,!0}return writeStdout(`Updated ${APP_NAME}`),!0}var __rewriteRelativeImportExtension=function(path,preserveJsx){return typeof path=="string"&&/^\.\.?\//.test(path)?path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js"}):path};function reexecUnderBunIfNeeded(){let options=processBunRuntimeOptions(existsSync2,realpathSync3),scriptRealPath=process.argv[1]??fileURLToPath(import.meta.url);try{scriptRealPath=realpathSync3(scriptRealPath)}catch{}let decision=resolveBunReexec({scriptRealPath,versions:process.versions,hasInheritedInspectorOption:hasInheritedInspectorOption(),options});if(decision.action==="stay")return!1;let result=spawnSync(decision.bunPath,[scriptRealPath,...process.argv.slice(2)],{stdio:"inherit",windowsHide:!0});return result.signal?(process.kill(process.pid,result.signal),!0):(process.exitCode=result.status??1,!0)}reexecUnderBunIfNeeded()&&process.exit();enableStartupCompileCache();process.title=APP_NAME;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});var args=process.argv.slice(2),PACKAGE_COMMANDS=new Set(["install","remove","uninstall","update","list","config"]);function isRootCommand(args2){let firstArg=args2[0];return firstArg===void 0||!PACKAGE_COMMANDS.has(firstArg)}function isPackageManagerInstall(packageDir){return packageDir.replace(/\\/g,"/").includes("/node_modules/@code-yeongyu/senpi")}function isMissingBundledWorkspaceDependencies(packageDir){return isPackageManagerInstall(packageDir)?["pi-agent-core","pi-ai","pi-tui"].some(name=>!existsSync2(join5(packageDir,"node_modules","@earendil-works",name,"dist","index.js"))):!1}var ISOLATED_CHILD_ENV="SENPI_CLI_ISOLATED_CHILD";function requiresIsolatedProcess(){return process.env[ISOLATED_CHILD_ENV]==="1"?!1:process.execArgv.length>0||hasInheritedInspectorOption()}async function spawnFullCli(){let extension=import.meta.url.endsWith(".ts")?".ts":".js",fullCliPath=isBundledNode?fileURLToPath(import.meta.url):fileURLToPath(new URL(`./cli-main${extension}`,import.meta.url));releaseInheritedInspectorForChild();let childEnvironment=isBundledNode?{...process.env,[ISOLATED_CHILD_ENV]:"1"}:process.env;return await new Promise((resolve,reject)=>{let child=spawn2(process.execPath,[...process.execArgv,fullCliPath,...args],{env:childEnvironment,stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{if(signal){process.kill(process.pid,signal),resolve(1);return}resolve(code??1)})})}isRootCommand(args)&&(args.includes("--version")||args.includes("-v"))&&(console.log(DISPLAY_VERSION),process.exit());if(isRootCommand(args)&&args.some(arg=>arg==="--help"||arg==="-h")){let{tryPrintHelpWithoutEngine}=await import("./chunks/help-fast-path-UYCESCEG.js");tryPrintHelpWithoutEngine(args)&&process.exit()}isMissingBundledWorkspaceDependencies(getInstallPackageDir())&&await handleBootstrapSelfUpdate(args)&&process.exit();if(requiresIsolatedProcess())process.exitCode=await spawnFullCli();else{let entryPath=fileURLToPath(import.meta.url),snapshot=isBundledNode?await prepareRuntimeSnapshot(entryPath,findNodePackageDir(dirname3(entryPath)),getAgentDir()):void 0;snapshot?.kind==="hand-off"?await import(__rewriteRelativeImportExtension(snapshot.entryUrl)):await import("./chunks/cli-main-NG6YCUOL.js")}
|
|
4
|
+
`),rmSync(target,{recursive:!0,force:!0}),renameSync(staging,target)}catch(error){throw rmSync(staging,{recursive:!0,force:!0}),error}}import{mkdirSync as mkdirSync2,readdirSync as readdirSync2,readFileSync as readFileSync2,renameSync as renameSync2,rmSync as rmSync2,statSync as statSync2,unlinkSync,utimesSync,writeFileSync as writeFileSync2}from"node:fs";import{join as join2}from"node:path";var LOCK_NAME=".lock",CLAIMS_DIR="claims",STALE_LOCK_MS=3e4,LOCK_WAIT_MS=5e3,LOCK_RETRY_MS=25,BUILD_LOCK_PREFIX=".build-",BUILD_WAIT_MS=12e4,BUILD_RETRY_MS=50,UNOWNED_BUILD_LOCK_MS=3e4,UNUSED_SNAPSHOT_GRACE_MS=10*6e4,LEFTOVER_MS=60*6e4;function errorCode2(error){return error instanceof Error&&"code"in error?error.code:void 0}function ageMs(path,now){try{return now-statSync2(path).mtimeMs}catch(error){if(errorCode2(error)==="ENOENT")return Number.POSITIVE_INFINITY;throw error}}function sleepSync(ms){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,ms)}function withRuntimeLock(root,task){mkdirSync2(root,{recursive:!0});let lock=join2(root,LOCK_NAME),deadline=Date.now()+LOCK_WAIT_MS;for(;;){try{mkdirSync2(lock);break}catch(error){if(errorCode2(error)!=="EEXIST")throw error}if(ageMs(lock,Date.now())>STALE_LOCK_MS)rmSync2(lock,{recursive:!0,force:!0});else{if(Date.now()>deadline)return;sleepSync(LOCK_RETRY_MS)}}try{return task()}finally{rmSync2(lock,{recursive:!0,force:!0})}}function buildLockHolder(lock){try{let pid=Number(readFileSync2(join2(lock,"pid"),"utf8"));return Number.isSafeInteger(pid)&&pid>0?pid:void 0}catch(error){if(errorCode2(error)==="ENOENT"||errorCode2(error)==="ENOTDIR")return;throw error}}function isAbandonedBuildLock(lock,now,isAlive){let holder=buildLockHolder(lock);return holder===void 0?ageMs(lock,now)>UNOWNED_BUILD_LOCK_MS:!isAlive(holder)}async function withBuildLock(root,id,build,isAlive=isProcessAlive){mkdirSync2(root,{recursive:!0});let lock=join2(root,`${BUILD_LOCK_PREFIX}${id}`),deadline=Date.now()+BUILD_WAIT_MS;for(;;){try{mkdirSync2(lock),writeFileSync2(join2(lock,"pid"),String(process.pid));break}catch(error){if(errorCode2(error)!=="EEXIST")throw error}if(isAbandonedBuildLock(lock,Date.now(),isAlive))rmSync2(lock,{recursive:!0,force:!0});else{if(Date.now()>deadline)return;sleepSync(BUILD_RETRY_MS)}}try{for(let name of readdirSync2(root))name.startsWith(`${STAGING_PREFIX}${id}-`)&&rmSync2(join2(root,name),{recursive:!0,force:!0});return await build()}finally{rmSync2(lock,{recursive:!0,force:!0})}}function isProcessAlive(pid){try{return process.kill(pid,0),!0}catch(error){return errorCode2(error)!=="ESRCH"}}function claimRuntimeSnapshot(snapshotDir,pid){mkdirSync2(join2(snapshotDir,CLAIMS_DIR),{recursive:!0}),writeFileSync2(join2(snapshotDir,CLAIMS_DIR,String(pid)),"");let now=new Date;utimesSync(join2(snapshotDir,RUNTIME_SNAPSHOT_MARKER),now,now)}function reapClaims(snapshotDir,isAlive){let names;try{names=readdirSync2(join2(snapshotDir,CLAIMS_DIR))}catch(error){if(errorCode2(error)==="ENOENT")return 0;throw error}let live=0;for(let name of names){let pid=Number(name);Number.isSafeInteger(pid)&&pid>0&&isAlive(pid)?live+=1:unlinkSync(join2(snapshotDir,CLAIMS_DIR,name))}return live}function pruneRuntimeSnapshots(root,keep,now,isAlive=isProcessAlive){reapClaims(join2(root,keep),isAlive);for(let name of readdirSync2(root)){if(name===LOCK_NAME||name===keep)continue;let path=join2(root,name);if(name.startsWith(".")){ageMs(path,now)>LEFTOVER_MS&&rmSync2(path,{recursive:!0,force:!0});continue}if(reapClaims(path,isAlive)>0||ageMs(join2(path,RUNTIME_SNAPSHOT_MARKER),now)<=UNUSED_SNAPSHOT_GRACE_MS)continue;let trash=join2(root,`.trash-${name}-${process.pid}`);renameSync2(path,trash),rmSync2(trash,{recursive:!0,force:!0})}}var RUNTIME_MANIFEST="runtime-manifest.json";function readRuntimeManifest(bundleDir){let parsed;try{parsed=JSON.parse(readFileSync3(join3(bundleDir,RUNTIME_MANIFEST),"utf8"))}catch(error){if(error instanceof Error&&"code"in error&&error.code==="ENOENT")return;throw error}if(typeof parsed=="object"&&parsed!==null&&"buildId"in parsed&&typeof parsed.buildId=="string"&&/^[A-Za-z0-9._-]+$/.test(parsed.buildId)&&"externals"in parsed&&Array.isArray(parsed.externals)&&parsed.externals.every(name=>typeof name=="string"))return{buildId:parsed.buildId,externals:parsed.externals}}async function prepareRuntimeSnapshot(entryPath,packageDir,agentDir){let bundleDir=dirname2(entryPath),runtimeRoot=join3(agentDir,"runtime");try{if(readRuntimeSnapshotMarker(packageDir))return withRuntimeLock(runtimeRoot,()=>claimRuntimeSnapshot(packageDir,process.pid)),{kind:"run-here"};let manifest=readRuntimeManifest(bundleDir);if(!manifest||relative(packageDir,bundleDir)!==join3("dist","bundle"))return{kind:"run-here"};let installId=createHash("sha256").update(realpathSync2(packageDir)).digest("hex").slice(0,12),snapshotId=`${manifest.buildId}-${installId}`,snapshotDir=join3(runtimeRoot,snapshotId),isBuilt=()=>readRuntimeSnapshotMarker(snapshotDir)?.buildId===manifest.buildId,claim=()=>withRuntimeLock(runtimeRoot,()=>isBuilt()?(claimRuntimeSnapshot(snapshotDir,process.pid),pruneRuntimeSnapshots(runtimeRoot,snapshotId,Date.now()),!0):!1),claimed=claim();return claimed===!1&&await withBuildLock(runtimeRoot,snapshotId,async()=>(isBuilt()||await materializeRuntimeSnapshot(packageDir,snapshotDir,manifest),!0))&&(claimed=claim()),claimed!==!0?{kind:"run-here"}:{kind:"hand-off",entryUrl:pathToFileURL(join3(snapshotDir,"dist","bundle",basename2(entryPath))).href,snapshotDir}}catch{return{kind:"run-here"}}}import{spawn}from"node:child_process";import{readFileSync as readFileSync4}from"node:fs";import{join as join4}from"node:path";function parseBootstrapSelfUpdateArgs(args2){let[command,...rest]=args2;if(command!=="update")return;let force=!1,selfFlag=!1,extensionsFlag=!1,extensionFlag=!1,source;for(let index=0;index<rest.length;index++){let arg=rest[index];if(arg==="-h"||arg==="--help")return;if(arg==="--force"){force=!0;continue}if(arg==="--self"){selfFlag=!0;continue}if(arg==="--extensions"){extensionsFlag=!0;continue}if(arg==="--extension"){extensionFlag=!0,index++;continue}if(arg.startsWith("-")||source)return;source=arg}if(extensionFlag)return;let sourceIsSelf=source==="self"||source==="pi"||source===APP_NAME;if(!(source&&!sourceIsSelf)&&!(!selfFlag&&!sourceIsSelf&&extensionsFlag))return{force}}function getObjectProperty(value,key){if(!(!value||typeof value!="object"))return Object.getOwnPropertyDescriptor(value,key)?.value}function readConfiguredNpmCommand(){try{let parsed=JSON.parse(readFileSync4(join4(getAgentDir(),"settings.json"),"utf-8")),npmCommand=getObjectProperty(parsed,"npmCommand");return!Array.isArray(npmCommand)||npmCommand.some(part=>typeof part!="string")?void 0:npmCommand.length>0?npmCommand:void 0}catch{return}}async function runCommand(step){await new Promise((resolve,reject)=>{let child=spawn(step.command,step.args,{stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{code===0?resolve():reject(signal?new Error(`${step.display} terminated by signal ${signal}`):new Error(`${step.display} exited with code ${code??"unknown"}`))})})}async function handleBootstrapSelfUpdate(args2,dependencies={}){let parsed=parseBootstrapSelfUpdateArgs(args2);if(!parsed)return!1;let writeStdout=dependencies.writeStdout??(line=>console.log(line)),writeStderr=dependencies.writeStderr??(line=>console.error(line)),readNpmCommand=dependencies.readNpmCommand??readConfiguredNpmCommand,resolveSelfUpdateCommand=dependencies.getSelfUpdateCommand??getSelfUpdateCommand,resolveUnavailableInstruction=dependencies.getUnavailableInstruction??getSelfUpdateUnavailableInstruction,executeCommand=dependencies.runCommand??runCommand,brandUpdate=brandProfile()?.update;if(brandUpdate)return writeStdout(`${APP_NAME} ships inside ${brandUpdate.packageName}. Update it with: ${brandUpdate.command}`),!0;let loadLatestRelease=dependencies.getLatestRelease??getLatestPiRelease,latestRelease;if(!parsed.force)try{latestRelease=await loadLatestRelease(VERSION)}catch{latestRelease=void 0}let updatePackageName=latestRelease?.packageName??PACKAGE_NAME;if(!(parsed.force||!latestRelease||updatePackageName!==PACKAGE_NAME||isNewerPackageVersion(latestRelease.version,VERSION)))return writeStdout(`${APP_NAME} is already up to date (v${VERSION})`),!0;let npmCommand=readNpmCommand(),selfUpdateCommand=resolveSelfUpdateCommand(PACKAGE_NAME,npmCommand,updatePackageName);if(!selfUpdateCommand)return writeStderr(`error: ${APP_NAME} cannot self-update this installation.`),writeStderr(resolveUnavailableInstruction(PACKAGE_NAME,npmCommand,updatePackageName)),process.argv[1]&&(writeStderr(""),writeStderr(`Location of ${APP_NAME} executable: ${process.argv[1]}`)),process.exitCode=1,!0;latestRelease?.note?.trim()&&(writeStdout(""),writeStdout("Update note"),writeStdout(latestRelease.note.trim()),writeStdout("")),writeStdout(`Updating ${APP_NAME} with ${selfUpdateCommand.display}...`);for(let step of selfUpdateCommand.steps??[selfUpdateCommand])try{await executeCommand(step)}catch(error){let message=error instanceof Error?error.message:"Unknown package command error";return writeStderr(`Error: ${message}`),writeStderr(`If this keeps failing, run this command yourself: ${selfUpdateCommand.display}`),process.exitCode=1,!0}return writeStdout(`Updated ${APP_NAME}`),!0}var __rewriteRelativeImportExtension=function(path,preserveJsx){return typeof path=="string"&&/^\.\.?\//.test(path)?path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js"}):path};function reexecUnderBunIfNeeded(){let options=processBunRuntimeOptions(existsSync2,realpathSync3),scriptRealPath=process.argv[1]??fileURLToPath(import.meta.url);try{scriptRealPath=realpathSync3(scriptRealPath)}catch{}let decision=resolveBunReexec({scriptRealPath,versions:process.versions,hasInheritedInspectorOption:hasInheritedInspectorOption(),options});if(decision.action==="stay")return!1;let result=spawnSync(decision.bunPath,[scriptRealPath,...process.argv.slice(2)],{stdio:"inherit",windowsHide:!0});return result.signal?(process.kill(process.pid,result.signal),!0):(process.exitCode=result.status??1,!0)}reexecUnderBunIfNeeded()&&process.exit();enableStartupCompileCache();process.title=APP_NAME;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});var args=process.argv.slice(2),PACKAGE_COMMANDS=new Set(["install","remove","uninstall","update","list","config"]);function isRootCommand(args2){let firstArg=args2[0];return firstArg===void 0||!PACKAGE_COMMANDS.has(firstArg)}function isPackageManagerInstall(packageDir){return packageDir.replace(/\\/g,"/").includes("/node_modules/@code-yeongyu/senpi")}function isMissingBundledWorkspaceDependencies(packageDir){return isPackageManagerInstall(packageDir)?["pi-agent-core","pi-ai","pi-tui"].some(name=>!existsSync2(join5(packageDir,"node_modules","@earendil-works",name,"dist","index.js"))):!1}var ISOLATED_CHILD_ENV="SENPI_CLI_ISOLATED_CHILD";function requiresIsolatedProcess(){return process.env[ISOLATED_CHILD_ENV]==="1"?!1:process.execArgv.length>0||hasInheritedInspectorOption()}async function spawnFullCli(){let extension=import.meta.url.endsWith(".ts")?".ts":".js",fullCliPath=isBundledNode?fileURLToPath(import.meta.url):fileURLToPath(new URL(`./cli-main${extension}`,import.meta.url));releaseInheritedInspectorForChild();let childEnvironment=isBundledNode?{...process.env,[ISOLATED_CHILD_ENV]:"1"}:process.env;return await new Promise((resolve,reject)=>{let child=spawn2(process.execPath,[...process.execArgv,fullCliPath,...args],{env:childEnvironment,stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{if(signal){process.kill(process.pid,signal),resolve(1);return}resolve(code??1)})})}isRootCommand(args)&&(args.includes("--version")||args.includes("-v"))&&(console.log(DISPLAY_VERSION),process.exit());if(isRootCommand(args)&&args.some(arg=>arg==="--help"||arg==="-h")){let{tryPrintHelpWithoutEngine}=await import("./chunks/help-fast-path-UYCESCEG.js");tryPrintHelpWithoutEngine(args)&&process.exit()}isMissingBundledWorkspaceDependencies(getInstallPackageDir())&&await handleBootstrapSelfUpdate(args)&&process.exit();if(requiresIsolatedProcess())process.exitCode=await spawnFullCli();else{let entryPath=fileURLToPath(import.meta.url),snapshot=isBundledNode?await prepareRuntimeSnapshot(entryPath,findNodePackageDir(dirname3(entryPath)),getAgentDir()):void 0;snapshot?.kind==="hand-off"?await import(__rewriteRelativeImportExtension(snapshot.entryUrl)):await import("./chunks/cli-main-RCIUWYKL.js")}
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
2
|
-
import{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultResourceLoader,ExtensionEditorComponent,ExtensionRunner,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SESSION_CONTROL_DELIVERY_TYPE,SessionManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildNoticeBox,buildSessionContext,buildSessionProjection,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,connectWebViewService,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isSessionControlDeliveryDetails,isToolCallEventType,isTransportGoneError,isWriteToolResult,kernelToolsStorage,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,readOwnFootprint,readProcessFootprint,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-U67UZN7N.js";import{UnknownCommandError,runRpcMode}from"./chunks/chunk-GFJGG447.js";import"./chunks/chunk-DP63ZKKF.js";import{DefaultPackageManager,DynamicBorder,ExtensionInputComponent,ExtensionSelectorComponent,SessionSelectorComponent,createSyntheticSourceInfo,keyHint,keyText,rawKeyHint}from"./chunks/chunk-FTBU746H.js";import{SettingsManager,Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme}from"./chunks/chunk-KNB5PWS6.js";import"./chunks/chunk-YZJ53A7A.js";import"./chunks/chunk-G6YNJ3G7.js";import{sanitizeTerminalLabel}from"./chunks/chunk-GCEEMWGS.js";import"./chunks/chunk-WIAXG52U.js";import"./chunks/chunk-U5KVIAHJ.js";import"./chunks/chunk-6Q3PLTKP.js";import"./chunks/chunk-JABBHOD5.js";import{DEFAULT_HOST_LAUNCH_SPEC,GENERATION_HANDOFF_CAPABILITY,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,HostLaunchSpecError,PINNED_HOST_CLIENT_CAPABILITIES,REQUIRED_HOST_CAPABILITIES,TUI_PROBE_TIMEOUT_MS,classifyEndpointLiveness,decideHostAction,endpointProbeTimeoutMs,ensureHost,handoffHost,loadHostLaunchSpec,parseHostLaunchSpec,parseHostProtocolInfo,probeHost,readAllHostStatus,readHostStatus,runHostCommand,runHostRequest,stopHost}from"./chunks/chunk-BP7SYEAO.js";import"./chunks/chunk-DN6WCOIS.js";import{gcHostEndpoints,listHostEndpoints}from"./chunks/chunk-5GSU6FQI.js";import"./chunks/chunk-UJQHD3KS.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-LFPTNJFL.js";import"./chunks/chunk-JMS6KHT7.js";import{getPowerShellConfig,getShellConfig,withBundledBunCommands}from"./chunks/chunk-2SC5XIAI.js";import"./chunks/chunk-HP2P2623.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-MHEC3URX.js";import"./chunks/chunk-CIRZTP7W.js";import{ENDPOINT_REGISTRY_VERSION,createHostDaemonPaths,daemonDirectoryName,shardKey,shardSocketPath,shardSocketPathForKey}from"./chunks/chunk-DLCG63OQ.js";import{compareEngineOrdinal,engineBuildIdentity,engineBuildIdentityFrom}from"./chunks/chunk-GXACYECD.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-XOLCOWF6.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-QUHRFKGY.js";import{parseArgs}from"./chunks/chunk-3SROZFB6.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-H6XRTLAJ.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-RUYXD3CX.js";import"./chunks/chunk-LX75SBFN.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-JCTWDSQT.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-JRGNL6WM.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-CWLCGRUS.js";import"./chunks/chunk-6WCOSBI7.js";import"./chunks/chunk-LHYG7TK7.js";import"./chunks/chunk-KRNXUTZJ.js";import"./chunks/chunk-YOPVJDSU.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-HK46JMSC.js";import"./chunks/chunk-4VVYXOOM.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-45SZOLCU.js";import"./chunks/chunk-BBK6SSYT.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-GR32NG6W.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-PJ34QVL5.js";import"./chunks/chunk-IKOFCODM.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_HOST_LAUNCH_SPEC,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ENDPOINT_REGISTRY_VERSION,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,GENERATION_HANDOFF_CAPABILITY,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,HostLaunchSpecError,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,PINNED_HOST_CLIENT_CAPABILITIES,ProjectTrustStore,REQUIRED_HOST_CAPABILITIES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SESSION_CONTROL_DELIVERY_TYPE,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,TUI_PROBE_TIMEOUT_MS,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UnknownCommandError,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildNoticeBox,buildSessionContext,buildSessionProjection,calculateContextTokens,classifyEndpointLiveness,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,compareEngineOrdinal,connectWebViewService,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createHostDaemonPaths,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,daemonDirectoryName,decideHostAction,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,endpointProbeTimeoutMs,engineBuildIdentity,engineBuildIdentityFrom,ensureHost,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,gcHostEndpoints,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getPowerShellConfig,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,handoffHost,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isSessionControlDeliveryDetails,isToolCallEventType,isTransportGoneError,isWriteToolResult,kernelToolsStorage,keyHint,keyText,listHostEndpoints,loadHostLaunchSpec,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseArgs,parseFrontmatter,parseHostLaunchSpec,parseHostProtocolInfo,parseSessionEntries,parseSkillBlock,prepareBranchEntries,probeHost,rawKeyHint,readAllHostStatus,readHostStatus,readOwnFootprint,readProcessFootprint,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runHostCommand,runHostRequest,runPrintMode,runRpcMode,sanitizeTerminalLabel,serializeConversation,sessionEntryToContextMessages,shardKey,shardSocketPath,shardSocketPathForKey,shouldCompact,stopHost,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withBundledBunCommands,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
|
|
2
|
+
import{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultResourceLoader,ExtensionEditorComponent,ExtensionRunner,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SESSION_CONTROL_DELIVERY_TYPE,SessionManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildNoticeBox,buildSessionContext,buildSessionProjection,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,connectWebViewService,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isSessionControlDeliveryDetails,isToolCallEventType,isTransportGoneError,isWriteToolResult,kernelToolsStorage,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,readOwnFootprint,readProcessFootprint,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-JWHA752H.js";import{UnknownCommandError,runRpcMode}from"./chunks/chunk-ZUQ36DFK.js";import"./chunks/chunk-DP63ZKKF.js";import{DefaultPackageManager,DynamicBorder,ExtensionInputComponent,ExtensionSelectorComponent,SessionSelectorComponent,createSyntheticSourceInfo,keyHint,keyText,rawKeyHint}from"./chunks/chunk-FTBU746H.js";import{SettingsManager,Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme}from"./chunks/chunk-KNB5PWS6.js";import"./chunks/chunk-YZJ53A7A.js";import"./chunks/chunk-G6YNJ3G7.js";import{sanitizeTerminalLabel}from"./chunks/chunk-GCEEMWGS.js";import"./chunks/chunk-WIAXG52U.js";import"./chunks/chunk-U5KVIAHJ.js";import"./chunks/chunk-6Q3PLTKP.js";import"./chunks/chunk-JABBHOD5.js";import{DEFAULT_HOST_LAUNCH_SPEC,GENERATION_HANDOFF_CAPABILITY,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,HostLaunchSpecError,PINNED_HOST_CLIENT_CAPABILITIES,REQUIRED_HOST_CAPABILITIES,TUI_PROBE_TIMEOUT_MS,classifyEndpointLiveness,decideHostAction,endpointProbeTimeoutMs,ensureHost,handoffHost,loadHostLaunchSpec,parseHostLaunchSpec,parseHostProtocolInfo,probeHost,readAllHostStatus,readHostStatus,runHostCommand,runHostRequest,stopHost}from"./chunks/chunk-BP7SYEAO.js";import"./chunks/chunk-DN6WCOIS.js";import{gcHostEndpoints,listHostEndpoints}from"./chunks/chunk-5GSU6FQI.js";import"./chunks/chunk-UJQHD3KS.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-P4MKROXN.js";import"./chunks/chunk-JMS6KHT7.js";import{getPowerShellConfig,getShellConfig}from"./chunks/chunk-45PHWY2H.js";import"./chunks/chunk-HP2P2623.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-MHEC3URX.js";import"./chunks/chunk-CIRZTP7W.js";import{ENDPOINT_REGISTRY_VERSION,createHostDaemonPaths,daemonDirectoryName,shardKey,shardSocketPath,shardSocketPathForKey}from"./chunks/chunk-DLCG63OQ.js";import{compareEngineOrdinal,engineBuildIdentity,engineBuildIdentityFrom}from"./chunks/chunk-GXACYECD.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-XOLCOWF6.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-QUHRFKGY.js";import{parseArgs}from"./chunks/chunk-3SROZFB6.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-H6XRTLAJ.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-RUYXD3CX.js";import"./chunks/chunk-LX75SBFN.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-JCTWDSQT.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-JRGNL6WM.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-CWLCGRUS.js";import"./chunks/chunk-6WCOSBI7.js";import"./chunks/chunk-LHYG7TK7.js";import"./chunks/chunk-KRNXUTZJ.js";import"./chunks/chunk-YOPVJDSU.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-HK46JMSC.js";import"./chunks/chunk-4VVYXOOM.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-45SZOLCU.js";import"./chunks/chunk-BBK6SSYT.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-GR32NG6W.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-PJ34QVL5.js";import"./chunks/chunk-IKOFCODM.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_HOST_LAUNCH_SPEC,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ENDPOINT_REGISTRY_VERSION,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,GENERATION_HANDOFF_CAPABILITY,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,HostLaunchSpecError,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,PINNED_HOST_CLIENT_CAPABILITIES,ProjectTrustStore,REQUIRED_HOST_CAPABILITIES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SESSION_CONTROL_DELIVERY_TYPE,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,TUI_PROBE_TIMEOUT_MS,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UnknownCommandError,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildNoticeBox,buildSessionContext,buildSessionProjection,calculateContextTokens,classifyEndpointLiveness,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,compareEngineOrdinal,connectWebViewService,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createHostDaemonPaths,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,daemonDirectoryName,decideHostAction,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,endpointProbeTimeoutMs,engineBuildIdentity,engineBuildIdentityFrom,ensureHost,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,gcHostEndpoints,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getPowerShellConfig,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,handoffHost,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isSessionControlDeliveryDetails,isToolCallEventType,isTransportGoneError,isWriteToolResult,kernelToolsStorage,keyHint,keyText,listHostEndpoints,loadHostLaunchSpec,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseArgs,parseFrontmatter,parseHostLaunchSpec,parseHostProtocolInfo,parseSessionEntries,parseSkillBlock,prepareBranchEntries,probeHost,rawKeyHint,readAllHostStatus,readHostStatus,readOwnFootprint,readProcessFootprint,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runHostCommand,runHostRequest,runPrintMode,runRpcMode,sanitizeTerminalLabel,serializeConversation,sessionEntryToContextMessages,shardKey,shardSocketPath,shardSocketPathForKey,shouldCompact,stopHost,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
|
package/dist/bundle/rpc-entry.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
3
|
-
import{main}from"./chunks/chunk-
|
|
3
|
+
import{main}from"./chunks/chunk-JWHA752H.js";import"./chunks/chunk-ZUQ36DFK.js";import"./chunks/chunk-DP63ZKKF.js";import"./chunks/chunk-FTBU746H.js";import{configureHttpDispatcher}from"./chunks/chunk-KNB5PWS6.js";import"./chunks/chunk-YZJ53A7A.js";import"./chunks/chunk-G6YNJ3G7.js";import"./chunks/chunk-GCEEMWGS.js";import"./chunks/chunk-WIAXG52U.js";import"./chunks/chunk-U5KVIAHJ.js";import"./chunks/chunk-6Q3PLTKP.js";import"./chunks/chunk-JABBHOD5.js";import"./chunks/chunk-BP7SYEAO.js";import"./chunks/chunk-DN6WCOIS.js";import"./chunks/chunk-5GSU6FQI.js";import"./chunks/chunk-UJQHD3KS.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-P4MKROXN.js";import"./chunks/chunk-JMS6KHT7.js";import"./chunks/chunk-45PHWY2H.js";import"./chunks/chunk-HP2P2623.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-MHEC3URX.js";import"./chunks/chunk-CIRZTP7W.js";import"./chunks/chunk-DLCG63OQ.js";import"./chunks/chunk-GXACYECD.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-XOLCOWF6.js";import"./chunks/chunk-QUHRFKGY.js";import"./chunks/chunk-3SROZFB6.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-H6XRTLAJ.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-RUYXD3CX.js";import"./chunks/chunk-LX75SBFN.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,scrubBrandFromEnvironment}from"./chunks/chunk-JCTWDSQT.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-JRGNL6WM.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-CWLCGRUS.js";import"./chunks/chunk-6WCOSBI7.js";import"./chunks/chunk-LHYG7TK7.js";import"./chunks/chunk-KRNXUTZJ.js";import"./chunks/chunk-YOPVJDSU.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-HK46JMSC.js";import"./chunks/chunk-4VVYXOOM.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-45SZOLCU.js";import"./chunks/chunk-BBK6SSYT.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-GR32NG6W.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-PJ34QVL5.js";import"./chunks/chunk-IKOFCODM.js";process.title=`${APP_NAME}-rpc`;scrubBrandFromEnvironment();process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"buildId":"
|
|
1
|
+
{"buildId":"281b0a0a70e21eb7","externals":["@earendil-works/chord","@earendil-works/pi-pty","@silvia-odwyer/photon-node","bufferutil","canvas","kerberos","supports-color","utf-8-validate"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { ContentBlockParam } from "./sdk-boundary.ts";
|
|
2
2
|
export declare function appendSdkContentBlocks(blocks: ContentBlockParam[], content: string | readonly unknown[]): boolean;
|
|
3
|
-
export declare function isSdkImageMediaType(value: string): boolean;
|
|
4
3
|
//# sourceMappingURL=content-blocks.d.ts.map
|
|
@@ -14,9 +14,6 @@ export function appendSdkContentBlocks(blocks, content) {
|
|
|
14
14
|
function isRecord(value) {
|
|
15
15
|
return typeof value === "object" && value !== null;
|
|
16
16
|
}
|
|
17
|
-
export function isSdkImageMediaType(value) {
|
|
18
|
-
return parseImageMediaType(value) !== undefined;
|
|
19
|
-
}
|
|
20
17
|
function parseImageMediaType(value) {
|
|
21
18
|
for (const mediaType of IMAGE_MEDIA_TYPES) {
|
|
22
19
|
if (mediaType === value)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { replayHistoryImages } from "./cold-seed-images.js";
|
|
2
1
|
import { appendSdkContentBlocks } from "./content-blocks.js";
|
|
3
2
|
import { mapPiToolNameToSdk } from "./tools.js";
|
|
4
3
|
export { mapPiToolNameToSdk } from "./tools.js";
|
|
@@ -34,11 +33,10 @@ export function buildPromptBlocks(context, customToolNameToSdk, toolWatchNote) {
|
|
|
34
33
|
pushText(`${hasPreviousTurn ? "\n\n" : ""}${label}\n`);
|
|
35
34
|
hasPreviousTurn = true;
|
|
36
35
|
};
|
|
37
|
-
const
|
|
38
|
-
for (const [index, message] of history.entries()) {
|
|
36
|
+
for (const message of history) {
|
|
39
37
|
if (message.role === "user") {
|
|
40
38
|
pushPrefix("USER:");
|
|
41
|
-
if (!appendContentBlocks(blocks,
|
|
39
|
+
if (!appendContentBlocks(blocks, message.content))
|
|
42
40
|
pushText("(see attached image)");
|
|
43
41
|
continue;
|
|
44
42
|
}
|
|
@@ -52,7 +50,7 @@ export function buildPromptBlocks(context, customToolNameToSdk, toolWatchNote) {
|
|
|
52
50
|
if (message.role === "configurationUpdate" || message.role === "system")
|
|
53
51
|
continue;
|
|
54
52
|
pushPrefix(`TOOL RESULT (historical ${mapPiToolNameToSdk(message.toolName, customToolNameToSdk)}, id=${message.toolCallId}):`);
|
|
55
|
-
if (!appendContentBlocks(blocks,
|
|
53
|
+
if (!appendContentBlocks(blocks, message.content))
|
|
56
54
|
pushText("(see attached image)");
|
|
57
55
|
}
|
|
58
56
|
pushText("\n</conversation_history>");
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,6 @@ export { classifyEndpointLiveness, createHostDaemonPaths, DEFAULT_HOST_LAUNCH_SP
|
|
|
39
39
|
export { ArminComponent, AssistantMessageComponent, BashExecutionComponent, BorderedLoader, BranchSummaryMessageComponent, CompactionSummaryMessageComponent, CustomEditor, type CustomEditorOptions, CustomMessageComponent, DynamicBorder, ExtensionEditorComponent, ExtensionInputComponent, ExtensionSelectorComponent, FooterComponent, keyHint, keyText, LoginDialogComponent, ModelSelectorComponent, OAuthSelectorComponent, type RenderDiffOptions, rawKeyHint, renderDiff, SessionSelectorComponent, type SettingsCallbacks, type SettingsConfig, SettingsSelectorComponent, ShowImagesSelectorComponent, SkillInvocationMessageComponent, ThemeSelectorComponent, ThinkingSelectorComponent, ToolExecutionComponent, type ToolExecutionOptions, TreeSelectorComponent, truncateToVisualLines, UserMessageComponent, UserMessageSelectorComponent, type VisualTruncateResult, } from "./modes/interactive/components/index.ts";
|
|
40
40
|
export { getLanguageFromPath, getMarkdownTheme, getSelectListTheme, getSettingsListTheme, highlightCode, initTheme, Theme, type ThemeAppearance, type ThemeBg, type ThemeColor, type ThemeStyle, type ThemeToken, } from "./modes/interactive/theme/theme.ts";
|
|
41
41
|
export { collectOrphanedChildren } from "./modes/rpc/child-reaper.ts";
|
|
42
|
-
export { withBundledBunCommands } from "./utils/bundled-bun.ts";
|
|
43
42
|
export { copyToClipboard } from "./utils/clipboard.ts";
|
|
44
43
|
export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.ts";
|
|
45
44
|
export { convertToPng } from "./utils/image-convert.ts";
|
package/dist/index.js
CHANGED
|
@@ -55,13 +55,12 @@ export { ArminComponent, AssistantMessageComponent, BashExecutionComponent, Bord
|
|
|
55
55
|
export { getLanguageFromPath, getMarkdownTheme, getSelectListTheme, getSettingsListTheme, highlightCode, initTheme, Theme, } from "./modes/interactive/theme/theme.js";
|
|
56
56
|
// Exact-pid collection of children whose owning thread is gone (#1962)
|
|
57
57
|
export { collectOrphanedChildren } from "./modes/rpc/child-reaper.js";
|
|
58
|
-
// Shell utilities
|
|
59
|
-
export { withBundledBunCommands } from "./utils/bundled-bun.js";
|
|
60
58
|
// Clipboard utilities
|
|
61
59
|
export { copyToClipboard } from "./utils/clipboard.js";
|
|
62
60
|
export { parseFrontmatter, stripFrontmatter } from "./utils/frontmatter.js";
|
|
63
61
|
export { convertToPng } from "./utils/image-convert.js";
|
|
64
62
|
export { formatDimensionNote, resizeImage } from "./utils/image-resize.js";
|
|
65
63
|
export { detectSupportedImageMimeTypeFromFile } from "./utils/mime.js";
|
|
64
|
+
// Shell utilities
|
|
66
65
|
export { getPowerShellConfig, getShellConfig } from "./utils/shell.js";
|
|
67
66
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/shell.js
CHANGED
|
@@ -2,7 +2,6 @@ import { existsSync } from "node:fs";
|
|
|
2
2
|
import { delimiter, join } from "node:path";
|
|
3
3
|
import { spawnSync } from "child_process";
|
|
4
4
|
import { getBinDir } from "../config.js";
|
|
5
|
-
import { withBundledBunCommands } from "./bundled-bun.js";
|
|
6
5
|
/** Environment variable that overrides shell resolution with an explicit bash path (Windows-first). */
|
|
7
6
|
export const GIT_BASH_PATH_ENV = "SENPI_GIT_BASH_PATH";
|
|
8
7
|
/**
|
|
@@ -166,10 +165,10 @@ export function getShellEnv() {
|
|
|
166
165
|
const pathEntries = currentPath.split(delimiter).filter(Boolean);
|
|
167
166
|
const hasBinDir = pathEntries.includes(binDir);
|
|
168
167
|
const updatedPath = hasBinDir ? currentPath : [binDir, currentPath].filter(Boolean).join(delimiter);
|
|
169
|
-
return
|
|
168
|
+
return {
|
|
170
169
|
...process.env,
|
|
171
170
|
[pathKey]: updatedPath,
|
|
172
|
-
}
|
|
171
|
+
};
|
|
173
172
|
}
|
|
174
173
|
/**
|
|
175
174
|
* Sanitize binary output for display/storage.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi",
|
|
3
|
-
"version": "2026.10.1
|
|
3
|
+
"version": "2026.10.1",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@earendil-works/chord": "0.99.1",
|
|
59
|
-
"@earendil-works/pi-agent-core": "npm:@code-yeongyu/senpi-agent-core@2026.10.1
|
|
60
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.10.1
|
|
61
|
-
"@earendil-works/pi-tui": "npm:@code-yeongyu/senpi-tui@2026.10.1
|
|
59
|
+
"@earendil-works/pi-agent-core": "npm:@code-yeongyu/senpi-agent-core@2026.10.1",
|
|
60
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.10.1",
|
|
61
|
+
"@earendil-works/pi-tui": "npm:@code-yeongyu/senpi-tui@2026.10.1",
|
|
62
62
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
63
63
|
"chalk": "6.0.0",
|
|
64
64
|
"cross-spawn": "7.0.6",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"yaml": "2.9.1",
|
|
78
78
|
"@anthropic-ai/claude-agent-sdk": "0.3.285",
|
|
79
79
|
"@anthropic-ai/sdk": "0.127.0",
|
|
80
|
-
"@code-yeongyu/senpi-codemode": "2026.10.1
|
|
81
|
-
"@earendil-works/pi-pty": "npm:@code-yeongyu/senpi-pty@2026.10.1
|
|
80
|
+
"@code-yeongyu/senpi-codemode": "2026.10.1",
|
|
81
|
+
"@earendil-works/pi-pty": "npm:@code-yeongyu/senpi-pty@2026.10.1",
|
|
82
82
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
83
83
|
"@mozilla/readability": "0.6.0",
|
|
84
84
|
"linkedom": "0.18.13",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
2
|
-
import{getAgentDir,getBinDir}from"./chunk-JCTWDSQT.js";import{createHash}from"node:crypto";import{chmodSync,mkdirSync,readFileSync,renameSync,writeFileSync}from"node:fs";import{tmpdir}from"node:os";import{delimiter,join}from"node:path";var EMBEDDED_ENTRY=/^(?:\/\$bunfs\/|[A-Za-z]:[\\/]~BUN[\\/])/;function isCompiledBunExecutable(main){return main!==void 0&&EMBEDDED_ENTRY.test(main)}function currentHost(){return{main:globalThis.Bun?.main,execPath:process.execPath,platform:process.platform,shimRoots:[join(getAgentDir(),"bundled-bun"),join(tmpdir(),"senpi-bundled-bun")]}}function shimFiles(execPath,platform){if(platform==="win32"){let run=extra=>`@echo off\r
|
|
3
|
-
set BUN_BE_BUN=1\r
|
|
4
|
-
"${execPath}" ${extra}%*\r
|
|
5
|
-
exit /b %ERRORLEVEL%\r
|
|
6
|
-
`;return[["bun.cmd",run("")],["bunx.cmd",run("x ")]]}let quoted=`'${execPath.replaceAll("'","'\\''")}'`;return[["bun",`#!/bin/sh
|
|
7
|
-
BUN_BE_BUN=1 exec ${quoted} "$@"
|
|
8
|
-
`],["bunx",`#!/bin/sh
|
|
9
|
-
BUN_BE_BUN=1 exec ${quoted} x "$@"
|
|
10
|
-
`]]}function writeIfChanged(path,content){let current;try{current=readFileSync(path,"utf8")}catch{}if(current!==content){let staged=`${path}.${process.pid}.tmp`;writeFileSync(staged,content,{mode:493}),renameSync(staged,path)}chmodSync(path,493)}function materialize(root,host){let dir=join(root,createHash("sha256").update(host.execPath).digest("hex").slice(0,16));try{mkdirSync(dir,{recursive:!0});for(let[name,content]of shimFiles(host.execPath,host.platform))writeIfChanged(join(dir,name),content);return dir}catch{return}}var resolved=new Map;function bundledBunDir(host=currentHost()){if(!isCompiledBunExecutable(host.main))return;let key=`${host.execPath}\0${host.shimRoots.join("\0")}`;if(!resolved.has(key)){let dir;for(let root of host.shimRoots)if(dir=materialize(root,host),dir!==void 0)break;resolved.set(key,dir)}return resolved.get(key)}function withBundledBunCommands(env,host){let dir=bundledBunDir(host);if(dir===void 0)return env;let pathKey=Object.keys(env).find(key=>key.toLowerCase()==="path")??"PATH",entries=(env[pathKey]??"").split(delimiter).filter(Boolean);return entries.includes(dir)?env:{...env,[pathKey]:[...entries,dir].join(delimiter)}}import{existsSync}from"node:fs";import{delimiter as delimiter2,join as join2}from"node:path";import{spawnSync}from"child_process";var GIT_BASH_PATH_ENV="SENPI_GIT_BASH_PATH";function isLegacyWslBashPath(path){let normalized=path.replace(/\//g,"\\").toLowerCase();return/^[a-z]:\\windows\\(?:system32|sysnative)\\bash\.exe$/.test(normalized)}function resolveShellKind(shellPath){let base=shellPath.replace(/\\/g,"/").split("/").pop()?.toLowerCase().replace(/\.exe$/,"");return base==="cmd"?"cmd":base==="powershell"||base==="pwsh"?"powershell":base==="sh"?"sh":"bash"}function getBashShellConfig(shell){return isLegacyWslBashPath(shell)?{shell,args:["-s"],commandTransport:"stdin",kind:"bash"}:{shell,args:["-c"],kind:"bash"}}function getShellConfigForPath(shellPath){let kind=resolveShellKind(shellPath);switch(kind){case"cmd":return{shell:shellPath,args:["/c"],kind};case"powershell":return{shell:shellPath,args:["-NoProfile","-Command"],kind};case"sh":return{shell:shellPath,args:["-c"],kind};default:return getBashShellConfig(shellPath)}}function findExecutableOnPath(executable){if(process.platform==="win32"){try{let result=spawnSync("where",[executable],{encoding:"utf-8",timeout:5e3,windowsHide:!0});if(result.status===0&&result.stdout){let firstMatch=result.stdout.trim().split(/\r?\n/)[0];if(firstMatch&&existsSync(firstMatch))return firstMatch}}catch{}return null}try{let result=spawnSync("which",[executable],{encoding:"utf-8",timeout:5e3});if(result.status===0&&result.stdout){let firstMatch=result.stdout.trim().split(/\r?\n/)[0];if(firstMatch)return firstMatch}}catch{}return null}function getShellConfig(customShellPath){if(customShellPath){if(existsSync(customShellPath))return getShellConfigForPath(customShellPath);throw new Error(`Custom shell path not found: ${customShellPath}`)}let gitBashOverride=process.env[GIT_BASH_PATH_ENV];if(gitBashOverride){if(existsSync(gitBashOverride))return getShellConfigForPath(gitBashOverride);throw new Error(`${GIT_BASH_PATH_ENV} points to a missing shell: ${gitBashOverride}`)}if(process.platform==="win32"){let paths=[],programFiles=process.env.ProgramFiles;programFiles&&paths.push(`${programFiles}\\Git\\bin\\bash.exe`);let programFilesX86=process.env["ProgramFiles(x86)"];programFilesX86&&paths.push(`${programFilesX86}\\Git\\bin\\bash.exe`);for(let path of paths)if(existsSync(path))return getBashShellConfig(path);let bashOnPath2=findExecutableOnPath("bash.exe");if(bashOnPath2)return getBashShellConfig(bashOnPath2);throw new Error(`No bash shell found. Options:
|
|
11
|
-
1. Install Git for Windows: https://git-scm.com/download/win
|
|
12
|
-
2. Add your bash to PATH (Cygwin, MSYS2, etc.)
|
|
13
|
-
3. Set shellPath in settings.json
|
|
14
|
-
|
|
15
|
-
Searched Git Bash in:
|
|
16
|
-
${paths.map(p=>` ${p}`).join(`
|
|
17
|
-
`)}`)}if(existsSync("/bin/bash"))return getBashShellConfig("/bin/bash");let bashOnPath=findExecutableOnPath("bash");return bashOnPath?getBashShellConfig(bashOnPath):{shell:"sh",args:["-c"]}}var POWERSHELL_ARGS=["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command"];function getPowerShellConfig(){if(process.platform!=="win32")throw new Error("The powershell tool is only available on Windows.");let shell=findExecutableOnPath("pwsh.exe")??findExecutableOnPath("powershell.exe");if(!shell)throw new Error("No PowerShell executable found. Install PowerShell or add powershell.exe/pwsh.exe to PATH.");return{shell,args:[...POWERSHELL_ARGS]}}function getShellEnv(){let binDir=getBinDir(),pathKey=Object.keys(process.env).find(key=>key.toLowerCase()==="path")??"PATH",currentPath=process.env[pathKey]??"",updatedPath=currentPath.split(delimiter2).filter(Boolean).includes(binDir)?currentPath:[binDir,currentPath].filter(Boolean).join(delimiter2);return withBundledBunCommands({...process.env,[pathKey]:updatedPath})}function sanitizeBinaryOutput(str){return hasUnsafeDisplayCharacter(str)?str.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\uFFF9-\uFFFB]/g,""):str}function hasUnsafeDisplayCharacter(str){for(let i=0;i<str.length;i++){let code=str.charCodeAt(i),isAllowedControl=code===9||code===10||code===13;if(code<=31&&!isAllowedControl||code>=65529&&code<=65531)return!0}return!1}var trackedDetachedChildren=new Map;function trackDetachedChildPid(pid){trackedDetachedChildren.set(pid,{pid,pgid:pid,leaderExited:!1})}function untrackDetachedChildPid(pid){trackedDetachedChildren.delete(pid)}function noteDetachedChildExited(pid){let entry=trackedDetachedChildren.get(pid);if(entry!==void 0){if(process.platform==="win32"||!processGroupIsAlive(entry.pgid)){trackedDetachedChildren.delete(pid);return}entry.leaderExited=!0}}function pruneTrackedDetachedChildren(){if(process.platform!=="win32")for(let[pid,entry]of trackedDetachedChildren)trackedDetachedChildIsGone(entry)&&trackedDetachedChildren.delete(pid)}function signalTargetExists(target){try{return process.kill(target,0),!0}catch(error){return error.code!=="ESRCH"}}function processGroupIsAlive(pgid){return signalTargetExists(-pgid)}function trackedDetachedChildIsGone(entry){return processGroupIsAlive(entry.pgid)?!1:entry.leaderExited||!signalTargetExists(entry.pid)}function killTrackedDetachedChildren(){pruneTrackedDetachedChildren();for(let entry of trackedDetachedChildren.values())process.platform==="win32"?killWindowsProcessTree(entry.pid):killTrackedDetachedGroup(entry);trackedDetachedChildren.clear()}function killTrackedDetachedGroup(entry){try{process.kill(-entry.pgid,"SIGKILL");return}catch{}if(!entry.leaderExited)try{process.kill(entry.pid,"SIGKILL")}catch{}}function windowsTaskkillCandidates(env=process.env){let systemDrive=env.SystemDrive?`${env.SystemDrive}\\`:void 0,roots=[env.SystemRoot,env.SYSTEMROOT,env.windir,systemDrive&&join2(systemDrive,"Windows")],candidates=[];for(let root of roots)if(root)for(let systemDir of["System32","Sysnative"]){let absolute=join2(root,systemDir,"taskkill.exe");!candidates.includes(absolute)&&existsSync(absolute)&&candidates.push(absolute)}return candidates.push("taskkill.exe"),candidates}function killProcessDirectly(pid){try{process.kill(pid)}catch{}}var TASKKILL_TIMEOUT_MS=5e3;function taskkillHandledTree(pid,taskkillPath){try{let result=spawnSync(taskkillPath,["/F","/T","/PID",String(pid)],{stdio:"ignore",windowsHide:!0,timeout:TASKKILL_TIMEOUT_MS});return result.error===void 0&&result.status!==null}catch{return!1}}function killWindowsProcessTree(pid,taskkillPaths=windowsTaskkillCandidates()){for(let taskkillPath of taskkillPaths)if(taskkillHandledTree(pid,taskkillPath))return;killProcessDirectly(pid)}function killProcessTree(pid){if(process.platform==="win32")killWindowsProcessTree(pid);else try{process.kill(-pid,"SIGKILL")}catch{try{process.kill(pid,"SIGKILL")}catch{}}}export{withBundledBunCommands,getShellConfig,getPowerShellConfig,getShellEnv,sanitizeBinaryOutput,trackDetachedChildPid,untrackDetachedChildPid,noteDetachedChildExited,pruneTrackedDetachedChildren,killTrackedDetachedChildren,killWindowsProcessTree,killProcessTree};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@earendil-works/pi-ai";
|
|
2
|
-
/**
|
|
3
|
-
* Most distinct historical images one cold-seed / flatten replay re-sends (#2490).
|
|
4
|
-
* The user's own uploads are kept first, then the most recently returned tool
|
|
5
|
-
* images; every other historical image becomes a one-line note. The final user
|
|
6
|
-
* message is not history and always carries its own images.
|
|
7
|
-
*/
|
|
8
|
-
export declare const MAX_REPLAYED_HISTORY_IMAGES = 8;
|
|
9
|
-
export type ReplayedImageOrigin = {
|
|
10
|
-
readonly kind: "user";
|
|
11
|
-
} | {
|
|
12
|
-
readonly kind: "tool";
|
|
13
|
-
readonly toolName: string;
|
|
14
|
-
readonly toolCallId: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const coldSeedImageText: {
|
|
17
|
-
readonly toolOutput: (toolName: string) => string;
|
|
18
|
-
readonly duplicate: (origin: ReplayedImageOrigin, first: ReplayedImageOrigin) => string;
|
|
19
|
-
readonly capped: (origin: ReplayedImageOrigin) => string;
|
|
20
|
-
readonly unreadable: (origin: ReplayedImageOrigin) => string;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Rewrites the image entries of a cold-seed history (#2490): a tool-result image
|
|
24
|
-
* is labeled as tool output, identical bytes are sent once and referenced in text
|
|
25
|
-
* afterwards, the replay is capped, and undecodable image data is dropped with a
|
|
26
|
-
* note. Returns the replacement content for each history index that holds an
|
|
27
|
-
* image; every other message is replayed unchanged.
|
|
28
|
-
*/
|
|
29
|
-
export declare function replayHistoryImages(history: Context["messages"], sdkToolName: (piToolName: string) => string): ReadonlyMap<number, readonly unknown[]>;
|
|
30
|
-
//# sourceMappingURL=cold-seed-images.d.ts.map
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { isSdkImageMediaType } from "./content-blocks.js";
|
|
3
|
-
/**
|
|
4
|
-
* Most distinct historical images one cold-seed / flatten replay re-sends (#2490).
|
|
5
|
-
* The user's own uploads are kept first, then the most recently returned tool
|
|
6
|
-
* images; every other historical image becomes a one-line note. The final user
|
|
7
|
-
* message is not history and always carries its own images.
|
|
8
|
-
*/
|
|
9
|
-
export const MAX_REPLAYED_HISTORY_IMAGES = 8;
|
|
10
|
-
function subject(origin) {
|
|
11
|
-
return origin.kind === "user" ? "[image attached by the user" : `[image returned by the ${origin.toolName} tool`;
|
|
12
|
-
}
|
|
13
|
-
function source(origin) {
|
|
14
|
-
return origin.kind === "user"
|
|
15
|
-
? "attached by the user"
|
|
16
|
-
: `returned by the ${origin.toolName} tool, id=${origin.toolCallId}`;
|
|
17
|
-
}
|
|
18
|
-
export const coldSeedImageText = {
|
|
19
|
-
toolOutput: (toolName) => `[image returned by the ${toolName} tool (tool output, not a user attachment)]`,
|
|
20
|
-
duplicate: (origin, first) => `${subject(origin)}: identical to an image already shown above (${source(first)}); not attached again]`,
|
|
21
|
-
capped: (origin) => `${subject(origin)}: omitted from this replay, which re-sends at most ${MAX_REPLAYED_HISTORY_IMAGES} earlier images; re-read the source if you need it]`,
|
|
22
|
-
unreadable: (origin) => `${subject(origin)}: omitted because its image data is missing or unreadable]`,
|
|
23
|
-
};
|
|
24
|
-
// Standard or URL-safe alphabet, padding optional; line wrapping is stripped first.
|
|
25
|
-
const BASE64 = /^[A-Za-z0-9+/_-]+={0,2}$/;
|
|
26
|
-
function decodeImageData(data) {
|
|
27
|
-
const compact = data.replace(/\s+/g, "");
|
|
28
|
-
if (compact.length === 0 || compact.replace(/=+$/, "").length % 4 === 1 || !BASE64.test(compact))
|
|
29
|
-
return undefined;
|
|
30
|
-
return { sha256: createHash("sha256").update(Buffer.from(compact, "base64")).digest("hex"), compactBase64: compact };
|
|
31
|
-
}
|
|
32
|
-
function isRecord(value) {
|
|
33
|
-
return typeof value === "object" && value !== null;
|
|
34
|
-
}
|
|
35
|
-
function originOf(message, sdkToolName) {
|
|
36
|
-
return message.role === "user"
|
|
37
|
-
? { kind: "user" }
|
|
38
|
-
: { kind: "tool", toolName: sdkToolName(message.toolName), toolCallId: message.toolCallId };
|
|
39
|
-
}
|
|
40
|
-
function imageBearingContent(history, sdkToolName) {
|
|
41
|
-
const contents = new Map();
|
|
42
|
-
history.forEach((message, messageIndex) => {
|
|
43
|
-
if (message.role !== "user" && message.role !== "toolResult")
|
|
44
|
-
return;
|
|
45
|
-
if (typeof message.content === "string")
|
|
46
|
-
return;
|
|
47
|
-
contents.set(messageIndex, { origin: originOf(message, sdkToolName), content: message.content });
|
|
48
|
-
});
|
|
49
|
-
return contents;
|
|
50
|
-
}
|
|
51
|
-
function collectOccurrences(contents) {
|
|
52
|
-
const occurrences = [];
|
|
53
|
-
for (const [messageIndex, { origin, content }] of contents) {
|
|
54
|
-
content.forEach((entry, entryIndex) => {
|
|
55
|
-
// Entries without string data or with an unsupported media type keep the
|
|
56
|
-
// shared mapper's own placeholder (content-blocks.ts), as before.
|
|
57
|
-
if (!isRecord(entry) || entry.type !== "image")
|
|
58
|
-
return;
|
|
59
|
-
if (typeof entry.data !== "string" || typeof entry.mimeType !== "string")
|
|
60
|
-
return;
|
|
61
|
-
if (!isSdkImageMediaType(entry.mimeType))
|
|
62
|
-
return;
|
|
63
|
-
occurrences.push({ messageIndex, entryIndex, origin, entry, decoded: decodeImageData(entry.data) });
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return occurrences;
|
|
67
|
-
}
|
|
68
|
-
function selectUserFirstThenMostRecent(occurrences) {
|
|
69
|
-
const ranked = new Map();
|
|
70
|
-
occurrences.forEach((occurrence, order) => {
|
|
71
|
-
const hash = occurrence.decoded?.sha256;
|
|
72
|
-
if (hash === undefined)
|
|
73
|
-
return;
|
|
74
|
-
const previous = ranked.get(hash);
|
|
75
|
-
ranked.set(hash, {
|
|
76
|
-
fromUser: (previous?.fromUser ?? false) || occurrence.origin.kind === "user",
|
|
77
|
-
lastSeen: order,
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
const ordered = [...ranked.entries()].sort(([, a], [, b]) => Number(b.fromUser) - Number(a.fromUser) || b.lastSeen - a.lastSeen);
|
|
81
|
-
return new Set(ordered.slice(0, MAX_REPLAYED_HISTORY_IMAGES).map(([hash]) => hash));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Rewrites the image entries of a cold-seed history (#2490): a tool-result image
|
|
85
|
-
* is labeled as tool output, identical bytes are sent once and referenced in text
|
|
86
|
-
* afterwards, the replay is capped, and undecodable image data is dropped with a
|
|
87
|
-
* note. Returns the replacement content for each history index that holds an
|
|
88
|
-
* image; every other message is replayed unchanged.
|
|
89
|
-
*/
|
|
90
|
-
export function replayHistoryImages(history, sdkToolName) {
|
|
91
|
-
const contents = imageBearingContent(history, sdkToolName);
|
|
92
|
-
const occurrences = collectOccurrences(contents);
|
|
93
|
-
if (occurrences.length === 0)
|
|
94
|
-
return new Map();
|
|
95
|
-
const replayed = selectUserFirstThenMostRecent(occurrences);
|
|
96
|
-
const firstShown = new Map();
|
|
97
|
-
const replacements = new Map();
|
|
98
|
-
for (const occurrence of occurrences) {
|
|
99
|
-
const { origin, entry, decoded } = occurrence;
|
|
100
|
-
const hash = decoded?.sha256;
|
|
101
|
-
let replacement;
|
|
102
|
-
if (decoded === undefined || hash === undefined) {
|
|
103
|
-
replacement = [{ type: "text", text: coldSeedImageText.unreadable(origin) }];
|
|
104
|
-
}
|
|
105
|
-
else if (!replayed.has(hash)) {
|
|
106
|
-
replacement = [{ type: "text", text: coldSeedImageText.capped(origin) }];
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
const first = firstShown.get(hash);
|
|
110
|
-
if (first) {
|
|
111
|
-
replacement = [{ type: "text", text: coldSeedImageText.duplicate(origin, first) }];
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
firstShown.set(hash, origin);
|
|
115
|
-
const canonical = { ...entry, data: Buffer.from(decoded.compactBase64, "base64").toString("base64") };
|
|
116
|
-
replacement =
|
|
117
|
-
origin.kind === "tool"
|
|
118
|
-
? [{ type: "text", text: coldSeedImageText.toolOutput(origin.toolName) }, canonical]
|
|
119
|
-
: [canonical];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const perMessage = replacements.get(occurrence.messageIndex) ?? new Map();
|
|
123
|
-
perMessage.set(occurrence.entryIndex, replacement);
|
|
124
|
-
replacements.set(occurrence.messageIndex, perMessage);
|
|
125
|
-
}
|
|
126
|
-
const rewritten = new Map();
|
|
127
|
-
for (const [messageIndex, perMessage] of replacements) {
|
|
128
|
-
const content = contents.get(messageIndex)?.content ?? [];
|
|
129
|
-
rewritten.set(messageIndex, content.flatMap((entry, entryIndex) => perMessage.get(entryIndex) ?? [entry]));
|
|
130
|
-
}
|
|
131
|
-
return rewritten;
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=cold-seed-images.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/** Facts about the running process; injectable so the decision is testable on any runtime. */
|
|
2
|
-
export interface BundledBunHost {
|
|
3
|
-
readonly main: string | undefined;
|
|
4
|
-
readonly execPath: string;
|
|
5
|
-
readonly platform: NodeJS.Platform;
|
|
6
|
-
readonly shimRoots: readonly string[];
|
|
7
|
-
}
|
|
8
|
-
export declare function isCompiledBunExecutable(main: string | undefined): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* The directory holding this executable's `bun`/`bunx` commands, created on first use; `undefined`
|
|
11
|
-
* outside a compiled executable, or when no candidate root is writable.
|
|
12
|
-
*/
|
|
13
|
-
export declare function bundledBunDir(host?: BundledBunHost): string | undefined;
|
|
14
|
-
/** `env` with the bundled `bun` directory appended to its PATH when this process is a compiled executable. */
|
|
15
|
-
export declare function withBundledBunCommands(env: NodeJS.ProcessEnv, host?: BundledBunHost): NodeJS.ProcessEnv;
|
|
16
|
-
//# sourceMappingURL=bundled-bun.d.ts.map
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `bun` for agent shells inside a `bun build --compile` executable.
|
|
3
|
-
*
|
|
4
|
-
* Bun Shell resolves a `bun` command to `process.execPath` when no `bun` is on PATH. In a compiled
|
|
5
|
-
* executable that is the app itself, and without `BUN_BE_BUN=1` the app runs its own entrypoint: an
|
|
6
|
-
* agent's `bun test` boots a second agent and its reply comes back as exit-0 output (omo#9362). The
|
|
7
|
-
* child cannot tell it was meant to be Bun (argv and argv0 match a normal launch), so the fix lives
|
|
8
|
-
* on the parent side: agent shells get a directory APPENDED to PATH whose `bun`/`bunx` run this
|
|
9
|
-
* executable with `BUN_BE_BUN=1`. Appending keeps a user's own Bun on PATH in front, and the variable
|
|
10
|
-
* is set only for that one command, so the engine's own self-spawns keep running the engine.
|
|
11
|
-
*/
|
|
12
|
-
import { createHash } from "node:crypto";
|
|
13
|
-
import { chmodSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
14
|
-
import { tmpdir } from "node:os";
|
|
15
|
-
import { delimiter, join } from "node:path";
|
|
16
|
-
import { getAgentDir } from "../config.js";
|
|
17
|
-
/** Bun's embedded filesystem root: `/$bunfs/` on POSIX, `<drive>:\~BUN\` on Windows. */
|
|
18
|
-
const EMBEDDED_ENTRY = /^(?:\/\$bunfs\/|[A-Za-z]:[\\/]~BUN[\\/])/;
|
|
19
|
-
export function isCompiledBunExecutable(main) {
|
|
20
|
-
return main !== undefined && EMBEDDED_ENTRY.test(main);
|
|
21
|
-
}
|
|
22
|
-
function currentHost() {
|
|
23
|
-
const bun = globalThis.Bun;
|
|
24
|
-
return {
|
|
25
|
-
main: bun?.main,
|
|
26
|
-
execPath: process.execPath,
|
|
27
|
-
platform: process.platform,
|
|
28
|
-
shimRoots: [join(getAgentDir(), "bundled-bun"), join(tmpdir(), "senpi-bundled-bun")],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function shimFiles(execPath, platform) {
|
|
32
|
-
if (platform === "win32") {
|
|
33
|
-
const run = (extra) => `@echo off\r\nset BUN_BE_BUN=1\r\n"${execPath}" ${extra}%*\r\nexit /b %ERRORLEVEL%\r\n`;
|
|
34
|
-
return [
|
|
35
|
-
["bun.cmd", run("")],
|
|
36
|
-
["bunx.cmd", run("x ")],
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
const quoted = `'${execPath.replaceAll("'", `'\\''`)}'`;
|
|
40
|
-
return [
|
|
41
|
-
["bun", `#!/bin/sh\nBUN_BE_BUN=1 exec ${quoted} "$@"\n`],
|
|
42
|
-
["bunx", `#!/bin/sh\nBUN_BE_BUN=1 exec ${quoted} x "$@"\n`],
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
function writeIfChanged(path, content) {
|
|
46
|
-
let current;
|
|
47
|
-
try {
|
|
48
|
-
current = readFileSync(path, "utf8");
|
|
49
|
-
}
|
|
50
|
-
catch { }
|
|
51
|
-
if (current !== content) {
|
|
52
|
-
const staged = `${path}.${process.pid}.tmp`;
|
|
53
|
-
writeFileSync(staged, content, { mode: 0o755 });
|
|
54
|
-
renameSync(staged, path);
|
|
55
|
-
}
|
|
56
|
-
chmodSync(path, 0o755);
|
|
57
|
-
}
|
|
58
|
-
function materialize(root, host) {
|
|
59
|
-
const dir = join(root, createHash("sha256").update(host.execPath).digest("hex").slice(0, 16));
|
|
60
|
-
try {
|
|
61
|
-
mkdirSync(dir, { recursive: true });
|
|
62
|
-
for (const [name, content] of shimFiles(host.execPath, host.platform))
|
|
63
|
-
writeIfChanged(join(dir, name), content);
|
|
64
|
-
return dir;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const resolved = new Map();
|
|
71
|
-
/**
|
|
72
|
-
* The directory holding this executable's `bun`/`bunx` commands, created on first use; `undefined`
|
|
73
|
-
* outside a compiled executable, or when no candidate root is writable.
|
|
74
|
-
*/
|
|
75
|
-
export function bundledBunDir(host = currentHost()) {
|
|
76
|
-
if (!isCompiledBunExecutable(host.main))
|
|
77
|
-
return undefined;
|
|
78
|
-
const key = `${host.execPath}\0${host.shimRoots.join("\0")}`;
|
|
79
|
-
if (!resolved.has(key)) {
|
|
80
|
-
let dir;
|
|
81
|
-
for (const root of host.shimRoots) {
|
|
82
|
-
dir = materialize(root, host);
|
|
83
|
-
if (dir !== undefined)
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
resolved.set(key, dir);
|
|
87
|
-
}
|
|
88
|
-
return resolved.get(key);
|
|
89
|
-
}
|
|
90
|
-
/** `env` with the bundled `bun` directory appended to its PATH when this process is a compiled executable. */
|
|
91
|
-
export function withBundledBunCommands(env, host) {
|
|
92
|
-
const dir = bundledBunDir(host);
|
|
93
|
-
if (dir === undefined)
|
|
94
|
-
return env;
|
|
95
|
-
const pathKey = Object.keys(env).find((key) => key.toLowerCase() === "path") ?? "PATH";
|
|
96
|
-
const entries = (env[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
97
|
-
if (entries.includes(dir))
|
|
98
|
-
return env;
|
|
99
|
-
return { ...env, [pathKey]: [...entries, dir].join(delimiter) };
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=bundled-bun.js.map
|