@code-yeongyu/senpi 2026.11.13 → 2026.11.15-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/bundle/chunks/{args-H56W53X6.js → args-JWBI5LNO.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-MNN2TINI.js → azure-openai-responses-PEMLRPJ5.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-HZQHA4PA.js → chunk-3RILB2OD.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-BKDXY6EM.js → chunk-5NECOJNK.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-Y4PFEXFN.js → chunk-64FJ4QQJ.js} +1 -1
  7. package/dist/bundle/chunks/chunk-6QQL3SKM.js +2 -0
  8. package/dist/bundle/chunks/{chunk-7T2LAWZ4.js → chunk-73HGQTJN.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-U4FAWC6C.js → chunk-74HCKLRH.js} +1 -1
  10. package/dist/bundle/chunks/chunk-75O3CWR5.js +2 -0
  11. package/dist/bundle/chunks/{chunk-AZ27TE3H.js → chunk-7BX3JQ7F.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-NDI6N4NJ.js → chunk-7CXLNKEH.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-E6ZBTSC6.js → chunk-A3LGSX7Z.js} +1 -1
  14. package/dist/bundle/chunks/chunk-AH2YAO7R.js +2 -0
  15. package/dist/bundle/chunks/{chunk-6FE42M54.js → chunk-BMADOJHZ.js} +2 -2
  16. package/dist/bundle/chunks/{chunk-7GD2EO6T.js → chunk-FYVQEZYN.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-EQT4WNCW.js → chunk-HTWWKJJI.js} +2 -2
  18. package/dist/bundle/chunks/{chunk-SFACYIB6.js → chunk-IK3S2NDB.js} +1 -1
  19. package/dist/bundle/chunks/{chunk-V4VDIV3U.js → chunk-PWA75RQU.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-IREUIMFE.js → chunk-PWTXZXHH.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-KKB3K5CV.js → chunk-Q4RJ4WLE.js} +1 -1
  22. package/dist/bundle/chunks/{chunk-NXGSYUMV.js → chunk-QSU2456D.js} +2 -2
  23. package/dist/bundle/chunks/chunk-QVG5SUSV.js +2 -0
  24. package/dist/bundle/chunks/chunk-RLIY3AUC.js +2 -0
  25. package/dist/bundle/chunks/{chunk-I4N2OIY4.js → chunk-RRFDLGX6.js} +26 -26
  26. package/dist/bundle/chunks/{chunk-JLCZIEBC.js → chunk-THYIV26N.js} +1 -1
  27. package/dist/bundle/chunks/{chunk-NI2AOYP6.js → chunk-TPLEPLEB.js} +3 -2
  28. package/dist/bundle/chunks/{chunk-CU6HUYL7.js → chunk-WAGFTIT4.js} +1 -1
  29. package/dist/bundle/chunks/{chunk-UYPH6RHY.js → chunk-Z4PN2MDA.js} +2 -2
  30. package/dist/bundle/chunks/{chunk-JJYN347Z.js → chunk-ZJUL5ODW.js} +1 -1
  31. package/dist/bundle/chunks/{cli-main-MY53RXU3.js → cli-main-GNQY2LTU.js} +1 -1
  32. package/dist/bundle/chunks/credential-accounts-RXZIUKFM.js +2 -0
  33. package/dist/bundle/chunks/github-copilot.js +1 -1
  34. package/dist/bundle/chunks/{hand-entry-AXTVMVJK.js → hand-entry-D3DNH6XL.js} +1 -1
  35. package/dist/bundle/chunks/{headless-host-SU5O2KZ2.js → headless-host-OEK6W65T.js} +1 -1
  36. package/dist/bundle/chunks/{health-write-TN7EXGLI.js → health-write-44JERGEJ.js} +1 -1
  37. package/dist/bundle/chunks/{help-fast-path-TFQ4HJNO.js → help-fast-path-JWHUCE4E.js} +1 -1
  38. package/dist/bundle/chunks/{host-command-FG56Y53E.js → host-command-O2K2WIPO.js} +1 -1
  39. package/dist/bundle/chunks/{host-session-command-UFEOW7EP.js → host-session-command-K3MR6RJY.js} +1 -1
  40. package/dist/bundle/chunks/interactive-mode-ATBPY4M5.js +2 -0
  41. package/dist/bundle/chunks/{login-health-XBTIORM4.js → login-health-V4B6LSCP.js} +1 -1
  42. package/dist/bundle/chunks/main-OMFVSMUR.js +2 -0
  43. package/dist/bundle/chunks/{multi-session-host-Q6SHI22A.js → multi-session-host-ACQ5N4UB.js} +6 -6
  44. package/dist/bundle/chunks/openai-codex-responses-G7ZXJBU6.js +10 -0
  45. package/dist/bundle/chunks/openai-responses-3TAF7WQF.js +5 -0
  46. package/dist/bundle/chunks/{package-manager-cli-LILAWI3Q.js → package-manager-cli-2VMRV4HL.js} +3 -3
  47. package/dist/bundle/chunks/{role-KODRTWH5.js → role-BTH5PVME.js} +1 -1
  48. package/dist/bundle/chunks/{rotation-stream-2KNROTYB.js → rotation-stream-ZGPXLY62.js} +1 -1
  49. package/dist/bundle/chunks/rpc-mode-XUK5SYKH.js +2 -0
  50. package/dist/bundle/chunks/{run-attached-tui-OEFHV5CZ.js → run-attached-tui-RVVYEINN.js} +1 -1
  51. package/dist/bundle/chunks/{schedule-command-VO4RP2KX.js → schedule-command-6TAAG2KU.js} +1 -1
  52. package/dist/bundle/chunks/{session-control-endpoint-CCVRJHSC.js → session-control-endpoint-Y5EIFFPY.js} +1 -1
  53. package/dist/bundle/chunks/{session-picker-VN5I2ZDI.js → session-picker-PRSZJYY4.js} +1 -1
  54. package/dist/bundle/chunks/session-slot-N4E4OSCX.js +2 -0
  55. package/dist/bundle/chunks/session-worker.js +74 -72
  56. package/dist/bundle/chunks/{state-store-7RVODZJU.js → state-store-I6MUHET3.js} +1 -1
  57. package/dist/bundle/cli.js +2 -2
  58. package/dist/bundle/index.js +1 -1
  59. package/dist/bundle/rpc-entry.js +1 -1
  60. package/dist/bundle/runtime-manifest.json +1 -1
  61. package/dist/core/agent-session-runtime.js +3 -3
  62. package/dist/core/agent-session.d.ts +5 -3
  63. package/dist/core/agent-session.js +20 -8
  64. package/dist/core/credential-accounts.d.ts +5 -3
  65. package/dist/core/credential-accounts.js +8 -6
  66. package/dist/core/credential-pool/classify.js +5 -1
  67. package/dist/core/extensions/builtin/anthropic-subscription/content-blocks.d.ts +6 -0
  68. package/dist/core/extensions/builtin/anthropic-subscription/content-blocks.js +14 -0
  69. package/dist/core/extensions/builtin/anthropic-subscription/prompt-bridge.js +3 -1
  70. package/dist/core/extensions/builtin/anthropic-subscription/session-sync.js +4 -1
  71. package/dist/core/extensions/builtin/permission-system/index.js +6 -1
  72. package/dist/core/extensions/loader.js +17 -1
  73. package/dist/core/extensions/runner.js +16 -2
  74. package/dist/core/extensions/tool-call-signal.d.ts +8 -0
  75. package/dist/core/extensions/tool-call-signal.js +14 -0
  76. package/dist/core/extensions/two-sided-forwarding.d.ts +6 -0
  77. package/dist/core/extensions/types.d.ts +26 -1
  78. package/dist/core/extensions/types.js +10 -0
  79. package/dist/core/reasoning-baseline.d.ts +8 -1
  80. package/dist/core/reasoning-baseline.js +24 -0
  81. package/dist/core/retry-fallback/chains.js +5 -1
  82. package/dist/core/retry-fallback/controller.d.ts +6 -1
  83. package/dist/core/retry-fallback/controller.js +11 -3
  84. package/dist/core/retry-fallback/expansion.js +18 -4
  85. package/dist/core/retry-fallback/settings.d.ts +7 -6
  86. package/dist/core/retry-fallback/settings.js +9 -8
  87. package/dist/core/runtime/bootstrap.d.ts +3 -0
  88. package/dist/core/runtime/bootstrap.js +1 -0
  89. package/dist/core/session-cwd.d.ts +15 -1
  90. package/dist/core/session-cwd.js +22 -1
  91. package/dist/core/tools/bash.d.ts +12 -0
  92. package/dist/core/tools/bash.js +30 -1
  93. package/dist/index.d.ts +4 -0
  94. package/dist/index.js +3 -0
  95. package/dist/modes/rpc/connection-handler.js +4 -0
  96. package/dist/modes/rpc/method-classes-schema-session.d.ts +3 -0
  97. package/dist/modes/rpc/method-classes-schema-session.js +6 -2
  98. package/dist/modes/rpc/method-classes-schema.d.ts +3 -0
  99. package/dist/modes/rpc/project-expected-cwd.d.ts +29 -0
  100. package/dist/modes/rpc/project-expected-cwd.js +45 -0
  101. package/dist/modes/rpc/rpc-error-types.d.ts +7 -1
  102. package/dist/modes/rpc/rpc-error-types.js +6 -0
  103. package/dist/modes/rpc/rpc-session-command-types.d.ts +3 -0
  104. package/dist/modes/rpc/session-router-close.js +6 -1
  105. package/dist/modes/rpc/session-router-open.js +5 -0
  106. package/dist/modes/rpc/session-status.d.ts +1 -1
  107. package/dist/modes/rpc/session-status.js +2 -0
  108. package/dist/package-manager-cli.d.ts +14 -0
  109. package/dist/package-manager-cli.js +20 -4
  110. package/dist/utils/version-check.d.ts +10 -7
  111. package/dist/utils/version-check.js +24 -5
  112. package/docs/extensions.md +12 -0
  113. package/docs/rpc.md +28 -13
  114. package/docs/settings.md +1 -1
  115. package/package.json +7 -7
  116. package/dist/bundle/chunks/chunk-GLTOBXZY.js +0 -2
  117. package/dist/bundle/chunks/chunk-PBUV2Z3R.js +0 -2
  118. package/dist/bundle/chunks/chunk-WRBOKYPS.js +0 -2
  119. package/dist/bundle/chunks/chunk-YT2ZSZOY.js +0 -2
  120. package/dist/bundle/chunks/credential-accounts-ZB5IXHIG.js +0 -2
  121. package/dist/bundle/chunks/interactive-mode-PHES47E3.js +0 -2
  122. package/dist/bundle/chunks/main-PR4FI6HQ.js +0 -2
  123. package/dist/bundle/chunks/openai-codex-responses-VRGOAFEG.js +0 -10
  124. package/dist/bundle/chunks/openai-responses-I7PXRWCM.js +0 -4
  125. package/dist/bundle/chunks/rpc-mode-CGVK4SSA.js +0 -2
  126. package/dist/bundle/chunks/session-slot-GHJVOSG7.js +0 -2
@@ -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{BLOCK_LOG_FILENAME,CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,KNOWN_SLOT_STATE_FIELDS,acquireHalfOpenLease,applicableStoredState,credentialPoolStatePath,slotHealth}from"./chunk-CEFKVI3E.js";import"./chunk-HGCQAMC6.js";import"./chunk-GZVCRV7I.js";import"./chunk-236TAYFX.js";import"./chunk-36BLGKRO.js";import"./chunk-FKX6EWFV.js";import"./chunk-U3VOXCGP.js";import"./chunk-7X72IACK.js";import"./chunk-EUCZC2RF.js";import"./chunk-62OVOJPI.js";import"./chunk-G7U4BOJP.js";import"./chunk-SFACYIB6.js";import"./chunk-XDEZA6U6.js";import"./chunk-COH5F7QV.js";import"./chunk-RFB5CBW7.js";import"./chunk-Y7QPP7BG.js";import"./chunk-IREUIMFE.js";import"./chunk-GVSBCJFI.js";import"./chunk-Z6TEQEZO.js";import"./chunk-ZG3MNTNX.js";import"./chunk-WHPDEDCC.js";import"./chunk-HK46JMSC.js";import"./chunk-5ROMKDLK.js";import"./chunk-3W47LTXQ.js";import"./chunk-UAOOH2V7.js";import"./chunk-WDTJ6JKE.js";import"./chunk-OH5TKHW7.js";import"./chunk-NDNQ23SK.js";import"./chunk-JGKH3D6W.js";import"./chunk-3SASTB6Y.js";import"./chunk-PJ34QVL5.js";import"./chunk-SODMQEHO.js";import"./chunk-ATQFN5HI.js";import"./chunk-MIENF2YK.js";import"./chunk-IKOFCODM.js";export{BLOCK_LOG_FILENAME,CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,KNOWN_SLOT_STATE_FIELDS,acquireHalfOpenLease,applicableStoredState,credentialPoolStatePath,slotHealth};
2
+ import{BLOCK_LOG_FILENAME,CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,KNOWN_SLOT_STATE_FIELDS,acquireHalfOpenLease,applicableStoredState,credentialPoolStatePath,slotHealth}from"./chunk-CEFKVI3E.js";import"./chunk-HGCQAMC6.js";import"./chunk-GZVCRV7I.js";import"./chunk-236TAYFX.js";import"./chunk-36BLGKRO.js";import"./chunk-FKX6EWFV.js";import"./chunk-U3VOXCGP.js";import"./chunk-7X72IACK.js";import"./chunk-EUCZC2RF.js";import"./chunk-62OVOJPI.js";import"./chunk-G7U4BOJP.js";import"./chunk-IK3S2NDB.js";import"./chunk-XDEZA6U6.js";import"./chunk-COH5F7QV.js";import"./chunk-RFB5CBW7.js";import"./chunk-Y7QPP7BG.js";import"./chunk-PWTXZXHH.js";import"./chunk-GVSBCJFI.js";import"./chunk-Z6TEQEZO.js";import"./chunk-ZG3MNTNX.js";import"./chunk-WHPDEDCC.js";import"./chunk-HK46JMSC.js";import"./chunk-5ROMKDLK.js";import"./chunk-3W47LTXQ.js";import"./chunk-UAOOH2V7.js";import"./chunk-WDTJ6JKE.js";import"./chunk-OH5TKHW7.js";import"./chunk-NDNQ23SK.js";import"./chunk-JGKH3D6W.js";import"./chunk-3SASTB6Y.js";import"./chunk-PJ34QVL5.js";import"./chunk-SODMQEHO.js";import"./chunk-ATQFN5HI.js";import"./chunk-MIENF2YK.js";import"./chunk-IKOFCODM.js";export{BLOCK_LOG_FILENAME,CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,KNOWN_SLOT_STATE_FIELDS,acquireHalfOpenLease,applicableStoredState,credentialPoolStatePath,slotHealth};
@@ -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
- import{dispatchAgentDirectoryCommand,enableStartupCompileCache}from"./chunks/chunk-NXGSYUMV.js";import"./chunks/chunk-JLCZIEBC.js";import{getLatestPiRelease,isNewerPackageVersion,processBunRuntimeOptions,resolveBunReexec}from"./chunks/chunk-GLTOBXZY.js";import{captureStdout,exitAfterOutput,hasInheritedInspectorOption,printThenExit,releaseInheritedInspectorForChild}from"./chunks/chunk-U4FAWC6C.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-ZFIC2DZV.js";import"./chunks/chunk-2SOVDETB.js";import{preparePrivateFdSpawn,runtimeExecArgv,spawnWithPrivateFds}from"./chunks/chunk-LJFQYCFH.js";import{releaseInheritedStartupFillers}from"./chunks/chunk-K3GAGIPX.js";import{HOST_STARTUP_EVENTS_ENV}from"./chunks/chunk-RUGTHELO.js";import{isFifoMode}from"./chunks/chunk-42XRJQM6.js";import"./chunks/chunk-IHES3JES.js";import"./chunks/chunk-5XHOHZIR.js";import"./chunks/chunk-HW6AAS3R.js";import{APP_NAME,DISPLAY_VERSION,PACKAGE_NAME,RUNTIME_SNAPSHOT_MARKER,VERSION,brandProfile,findNodePackageDir,getAgentDir,getInstallPackageDir,getSelfUpdateCommand,getSelfUpdateUnavailableInstruction,isBundledNode,readRuntimeSnapshotMarker}from"./chunks/chunk-SODMQEHO.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-FQXWKEVK.js";import"./chunks/chunk-IKOFCODM.js";releaseInheritedStartupFillers(process.env);import{spawn as spawn2,spawnSync}from"node:child_process";import{existsSync as existsSync3,fstatSync,realpathSync as realpathSync5}from"node:fs";import{dirname as dirname4,join as join8}from"node:path";import{fileURLToPath}from"node:url";async function dispatchKillGuardCommand(args2){if(args2[0]!=="__kill-guard")return;let{runKillGuardCheckCommand}=await import("./chunks/check-command-KGFICS6A.js");process.exit(runKillGuardCheckCommand())}import{createHash}from"node:crypto";import{readFileSync as readFileSync5,realpathSync as realpathSync4}from"node:fs";import{basename as basename2,dirname as dirname3,join as join6,relative}from"node:path";import{pathToFileURL}from"node:url";import{existsSync as existsSync2,readFileSync as readFileSync3,realpathSync as realpathSync3,renameSync,rmSync,writeFileSync}from"node:fs";import{basename,dirname as dirname2,join as join4}from"node:path";import{existsSync,readFileSync}from"node:fs";import{join}from"node:path";var INERT_TREE=/^(?:tests?|__tests__|__fixtures__|fixtures|docs?|examples?|bench(?:marks?)?)$/,ROOT_NOTES=/^(?:readme|changelog|history)(?:\.[^/]*)?$/i,ROOT_MARKDOWN=/^[^/]+\.md$/i,LICENSE=/^licen[cs]e(?:\.[^/]*)?$/i;function dependencyFileExclusions(packageDir){let manifest=JSON.parse(readFileSync(join(packageDir,"package.json"),"utf8"));if(typeof manifest!="object"||manifest===null)return()=>!1;let entryRoots=new Set,built=!1,visit=value=>{if(typeof value=="string"){let entry=value.replace(/^\.\//,"");entryRoots.add(entry.split("/")[0]??""),/\.[cm]?js$/.test(entry)&&existsSync(join(packageDir,entry))&&(built=!0)}else if(Array.isArray(value))for(let child of value)visit(child);else if(typeof value=="object"&&value!==null)for(let[condition,child]of Object.entries(value))condition!=="types"&&visit(child)};for(let[key,value]of Object.entries(manifest))["main","module","exports","bin","pi"].includes(key)&&visit(value);return path=>{let root=path.split("/")[0]??"";return entryRoots.has(root)||entryRoots.has("*")||entryRoots.has("**")?!1:INERT_TREE.test(root)||ROOT_NOTES.test(path)||ROOT_MARKDOWN.test(path)&&!LICENSE.test(path)?!0:built&&root==="src"&&/\.[cm]?tsx?$/.test(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))}import{mkdirSync as mkdirSync2,readdirSync as readdirSync2,readFileSync as readFileSync2,realpathSync as realpathSync2,statSync as statSync2}from"node:fs";import{dirname,join as join3}from"node:path";import{mkdirSync,readdirSync,realpathSync,statSync}from"node:fs";import{join as join2}from"node:path";var 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,excluded=()=>!1,relativeDir=""){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 relativePath=relativeDir===""?entry.name:`${relativeDir}/${entry.name}`;if(excluded(relativePath))continue;let from=join2(real,entry.name),to=join2(target,entry.name);if(entry.isDirectory())planTree(from,to,files,skipModules,seen,excluded,relativePath);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,excluded,relativePath):UNLOADED_FILE.test(entry.name)||files.push([realpathSync(from),to])}}seen.delete(real)}}var ALWAYS_SHIPPED=/^(?:package\.json|readme(?:\..*)?|licen[cs]e(?:\..*)?)$/i;function globToRegExp(glob){let source="";for(let index=0;index<glob.length;index++){let char=glob[index];glob.startsWith("**/",index)?(source+="(?:.*/)?",index+=2):glob.startsWith("**",index)?(source+=".*",index+=1):char==="*"?source+="[^/]*":char==="?"?source+="[^/]":source+=char.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${source}(?:/.*)?$`)}function shippedEntries(packageDir){let manifest=JSON.parse(readFileSync2(join3(packageDir,"package.json"),"utf8")),listed=typeof manifest=="object"&&manifest!==null?manifest.files:void 0;if(!Array.isArray(listed)||!listed.every(entry=>typeof entry=="string"))return;let normalize=entry=>entry.replace(/^\.\//,"").replace(/\/+$/,"");return{include:listed.filter(entry=>!entry.startsWith("!")).map(normalize),exclude:listed.filter(entry=>entry.startsWith("!")).map(entry=>globToRegExp(normalize(entry.slice(1))))}}function planPackageRoot(packageDir,target,files){let shipped=shippedEntries(packageDir);if(shipped===void 0){planTree(packageDir,target,files,!0);return}let root=realpathSync2(packageDir),excluded=relativePath=>shipped.exclude.some(pattern=>pattern.test(relativePath)),planned=new Set,plan=relativePath=>{if(planned.has(relativePath)||excluded(relativePath))return;let from=join3(root,relativePath),isDirectory;try{isDirectory=statSync2(from).isDirectory()}catch(error){if(isMissing(error))return;throw error}planned.add(relativePath);let to=join3(target,relativePath);isDirectory?planTree(from,to,files,!0,new Set([root]),excluded,relativePath):UNLOADED_FILE.test(relativePath)||(mkdirSync2(dirname(to),{recursive:!0}),files.push([realpathSync2(from),to]))};mkdirSync2(target,{recursive:!0});let topLevel=readdirSync2(root).filter(name=>name!=="node_modules");for(let name of topLevel)ALWAYS_SHIPPED.test(name)&&plan(name);for(let entry of shipped.include){let segments=entry.split("/"),wildcard=segments.findIndex(segment=>/[*?]/.test(segment));if(wildcard===-1)plan(entry);else if(wildcard>0)plan(segments.slice(0,wildcard).join("/"));else{let pattern=globToRegExp(segments[0]??"");for(let name of topLevel)pattern.test(name)&&plan(name)}}}var RuntimeSnapshotLayoutError=class extends Error{constructor(packageName){super(`runtime snapshot resolves ${packageName} differently from the install`),this.packageName=packageName}},STAGING_PREFIX=".tmp-";function moduleDirectoriesFrom(dir){let directories=[];for(let current=dir;;current=dirname2(current)){if(basename(current)!=="node_modules"){let candidate=join4(current,"node_modules");existsSync2(candidate)&&directories.push(candidate)}if(dirname2(current)===current)return directories}}function packageRootFrom(dir,packageName){for(let modules of moduleDirectoriesFrom(dir)){let root=join4(modules,packageName);if(existsSync2(join4(root,"package.json")))return realpathSync3(root)}}function dependencyNames(packageDir){let manifest=JSON.parse(readFileSync3(join4(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=[realpathSync3(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=realpathSync3(packageDir),placed=new Map,pending=[],place=(installDir,snapshotDir)=>{planTree(installDir,snapshotDir,files,!0,new Set,dependencyFileExclusions(installDir)),placed.set(snapshotDir,installDir),pending.push({installDir,snapshotDir})},resolvePlaced=(from,name)=>{for(let dir=from;;dir=dirname2(dir)){if(basename(dir)!=="node_modules"){let found=placed.get(join4(dir,"node_modules",name));if(found!==void 0)return found}if(dir===snapshotRoot||dirname2(dir)===dir)return}};for(let name of closureNames(packageDir,externals)){let source=packageRootFrom(packageDir,name);source!==void 0&&source!==self&&place(source,join4(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,join4(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=>join4(modules,name)).find(root=>existsSync2(join4(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=join4(dirname2(target),`${STAGING_PREFIX}${basename(target)}-${process.pid}`);rmSync(staging,{recursive:!0,force:!0});try{let files=[];planPackageRoot(packageDir,staging,files);let placed=planModules(packageDir,staging,manifest.externals,files);await copyFiles(files,copier),verifyExternals(packageDir,join4(staging,"dist","bundle","chunks"),manifest.externals,placed);let marker={buildId:manifest.buildId,installPackageDir:realpathSync3(packageDir)};writeFileSync(join4(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 mkdirSync3,readdirSync as readdirSync3,readFileSync as readFileSync4,renameSync as renameSync2,rmSync as rmSync2,statSync as statSync3,unlinkSync,utimesSync,writeFileSync as writeFileSync2}from"node:fs";import{join as join5}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-statSync3(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){mkdirSync3(root,{recursive:!0});let lock=join5(root,LOCK_NAME),deadline=Date.now()+LOCK_WAIT_MS;for(;;){try{mkdirSync3(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(readFileSync4(join5(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){mkdirSync3(root,{recursive:!0});let lock=join5(root,`${BUILD_LOCK_PREFIX}${id}`),deadline=Date.now()+BUILD_WAIT_MS;for(;;){try{mkdirSync3(lock),writeFileSync2(join5(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 readdirSync3(root))name.startsWith(`${STAGING_PREFIX}${id}-`)&&rmSync2(join5(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){mkdirSync3(join5(snapshotDir,CLAIMS_DIR),{recursive:!0}),writeFileSync2(join5(snapshotDir,CLAIMS_DIR,String(pid)),"");let now=new Date;utimesSync(join5(snapshotDir,RUNTIME_SNAPSHOT_MARKER),now,now)}function reapClaims(snapshotDir,isAlive){let names;try{names=readdirSync3(join5(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(join5(snapshotDir,CLAIMS_DIR,name))}return live}function pruneRuntimeSnapshots(root,keep,now,isAlive=isProcessAlive){reapClaims(join5(root,keep),isAlive);for(let name of readdirSync3(root)){if(name===LOCK_NAME||name===keep)continue;let path=join5(root,name);if(name.startsWith(".")){ageMs(path,now)>LEFTOVER_MS&&rmSync2(path,{recursive:!0,force:!0});continue}if(reapClaims(path,isAlive)>0||ageMs(join5(path,RUNTIME_SNAPSHOT_MARKER),now)<=UNUSED_SNAPSHOT_GRACE_MS)continue;let trash=join5(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(readFileSync5(join6(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=dirname3(entryPath),runtimeRoot=join6(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)!==join6("dist","bundle"))return{kind:"run-here"};let installId=createHash("sha256").update(realpathSync4(packageDir)).digest("hex").slice(0,12),snapshotId=`${manifest.buildId}-${installId}`,snapshotDir=join6(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(join6(snapshotDir,"dist","bundle",basename2(entryPath))).href,snapshotDir}}catch{return{kind:"run-here"}}}import{spawn}from"node:child_process";import{readFileSync as readFileSync6}from"node:fs";import{join as join7}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(readFileSync6(join7(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",windowsHide:!0});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 reexecStdio(){let base=channelStdio();if(!process.env[HOST_STARTUP_EVENTS_ENV])return base;try{let stat=fstatSync(16);if(!stat.isSocket()&&!isFifoMode(stat.mode))return base}catch{return base}let slots=typeof base=="string"?[base,base,base]:[...base];for(;slots.length<16;)slots.push("ignore");return slots[16]=16,slots}function channelStdio(){let argv=process.argv.slice(2),presenter=argv.indexOf("--mcp-presenter-fd");if(presenter<0||argv[presenter+1]!=="4")return"inherit";try{let stat=fstatSync(4);if(!stat.isSocket()&&!stat.isFIFO())return"inherit"}catch{return"inherit"}let owner=argv.indexOf("--owner-fd");return["inherit","inherit","inherit",owner>=0&&argv[owner+1]==="3"||process.env.SENPI_RPC_HOST_WATCH_FD==="3"?3:"ignore",4]}function reexecUnderBunIfNeeded(){let options=processBunRuntimeOptions(existsSync3,realpathSync5),scriptRealPath=process.argv[1]??fileURLToPath(import.meta.url);try{scriptRealPath=realpathSync5(scriptRealPath)}catch{}let decision=resolveBunReexec({scriptRealPath,versions:process.versions,hasInheritedInspectorOption:hasInheritedInspectorOption(),options});if(decision.action==="stay")return!1;let transfer=preparePrivateFdSpawn({stdio:reexecStdio(),windowsHide:!0}),result=(()=>{try{return spawnSync(decision.bunPath,[scriptRealPath,...process.argv.slice(2)],transfer.options)}finally{transfer.close()}})();return result.signal?(process.kill(process.pid,result.signal),!0):(process.exitCode=result.status??1,!0)}await dispatchKillGuardCommand(process.argv.slice(2));reexecUnderBunIfNeeded()&&process.exit();var args=process.argv.slice(2);await dispatchAgentDirectoryCommand(args);await enableStartupCompileCache();process.title=APP_NAME;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});var 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=>!existsSync3(join8(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:runtimeExecArgv().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={...process.env,[ISOLATED_CHILD_ENV]:"1"};return await new Promise((resolve,reject)=>{let child=spawnWithPrivateFds(spawn2,process.execPath,[...runtimeExecArgv(),fullCliPath,...args],{env:childEnvironment,stdio:reexecStdio()});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"))&&await printThenExit(()=>console.log(DISPLAY_VERSION));if(isRootCommand(args)&&args.some(arg=>arg==="--help"||arg==="-h")){let{tryPrintHelpWithoutEngine}=await import("./chunks/help-fast-path-TFQ4HJNO.js"),help=await captureStdout(()=>tryPrintHelpWithoutEngine(args));help.result&&await exitAfterOutput(help.output),process.stdout.write(help.output)}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(dirname4(entryPath)),getAgentDir()):void 0;snapshot?.kind==="hand-off"?await import(__rewriteRelativeImportExtension(snapshot.entryUrl)):await import("./chunks/cli-main-MY53RXU3.js")}
3
+ import{dispatchAgentDirectoryCommand,enableStartupCompileCache}from"./chunks/chunk-QSU2456D.js";import"./chunks/chunk-THYIV26N.js";import{getLatestPiRelease,isNewerPackageVersion,processBunRuntimeOptions,resolveBunReexec}from"./chunks/chunk-QVG5SUSV.js";import{captureStdout,exitAfterOutput,hasInheritedInspectorOption,printThenExit,releaseInheritedInspectorForChild}from"./chunks/chunk-74HCKLRH.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-ZFIC2DZV.js";import"./chunks/chunk-2SOVDETB.js";import{preparePrivateFdSpawn,runtimeExecArgv,spawnWithPrivateFds}from"./chunks/chunk-LJFQYCFH.js";import{releaseInheritedStartupFillers}from"./chunks/chunk-K3GAGIPX.js";import{HOST_STARTUP_EVENTS_ENV}from"./chunks/chunk-RUGTHELO.js";import{isFifoMode}from"./chunks/chunk-42XRJQM6.js";import"./chunks/chunk-IHES3JES.js";import"./chunks/chunk-5XHOHZIR.js";import"./chunks/chunk-HW6AAS3R.js";import{APP_NAME,DISPLAY_VERSION,PACKAGE_NAME,RUNTIME_SNAPSHOT_MARKER,VERSION,brandProfile,findNodePackageDir,getAgentDir,getInstallPackageDir,getSelfUpdateCommand,getSelfUpdateUnavailableInstruction,isBundledNode,readRuntimeSnapshotMarker}from"./chunks/chunk-SODMQEHO.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-FQXWKEVK.js";import"./chunks/chunk-IKOFCODM.js";releaseInheritedStartupFillers(process.env);import{spawn as spawn2,spawnSync}from"node:child_process";import{existsSync as existsSync3,fstatSync,realpathSync as realpathSync5}from"node:fs";import{dirname as dirname4,join as join8}from"node:path";import{fileURLToPath}from"node:url";async function dispatchKillGuardCommand(args2){if(args2[0]!=="__kill-guard")return;let{runKillGuardCheckCommand}=await import("./chunks/check-command-KGFICS6A.js");process.exit(runKillGuardCheckCommand())}import{createHash}from"node:crypto";import{readFileSync as readFileSync5,realpathSync as realpathSync4}from"node:fs";import{basename as basename2,dirname as dirname3,join as join6,relative}from"node:path";import{pathToFileURL}from"node:url";import{existsSync as existsSync2,readFileSync as readFileSync3,realpathSync as realpathSync3,renameSync,rmSync,writeFileSync}from"node:fs";import{basename,dirname as dirname2,join as join4}from"node:path";import{existsSync,readFileSync}from"node:fs";import{join}from"node:path";var INERT_TREE=/^(?:tests?|__tests__|__fixtures__|fixtures|docs?|examples?|bench(?:marks?)?)$/,ROOT_NOTES=/^(?:readme|changelog|history)(?:\.[^/]*)?$/i,ROOT_MARKDOWN=/^[^/]+\.md$/i,LICENSE=/^licen[cs]e(?:\.[^/]*)?$/i;function dependencyFileExclusions(packageDir){let manifest=JSON.parse(readFileSync(join(packageDir,"package.json"),"utf8"));if(typeof manifest!="object"||manifest===null)return()=>!1;let entryRoots=new Set,built=!1,visit=value=>{if(typeof value=="string"){let entry=value.replace(/^\.\//,"");entryRoots.add(entry.split("/")[0]??""),/\.[cm]?js$/.test(entry)&&existsSync(join(packageDir,entry))&&(built=!0)}else if(Array.isArray(value))for(let child of value)visit(child);else if(typeof value=="object"&&value!==null)for(let[condition,child]of Object.entries(value))condition!=="types"&&visit(child)};for(let[key,value]of Object.entries(manifest))["main","module","exports","bin","pi"].includes(key)&&visit(value);return path=>{let root=path.split("/")[0]??"";return entryRoots.has(root)||entryRoots.has("*")||entryRoots.has("**")?!1:INERT_TREE.test(root)||ROOT_NOTES.test(path)||ROOT_MARKDOWN.test(path)&&!LICENSE.test(path)?!0:built&&root==="src"&&/\.[cm]?tsx?$/.test(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))}import{mkdirSync as mkdirSync2,readdirSync as readdirSync2,readFileSync as readFileSync2,realpathSync as realpathSync2,statSync as statSync2}from"node:fs";import{dirname,join as join3}from"node:path";import{mkdirSync,readdirSync,realpathSync,statSync}from"node:fs";import{join as join2}from"node:path";var 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,excluded=()=>!1,relativeDir=""){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 relativePath=relativeDir===""?entry.name:`${relativeDir}/${entry.name}`;if(excluded(relativePath))continue;let from=join2(real,entry.name),to=join2(target,entry.name);if(entry.isDirectory())planTree(from,to,files,skipModules,seen,excluded,relativePath);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,excluded,relativePath):UNLOADED_FILE.test(entry.name)||files.push([realpathSync(from),to])}}seen.delete(real)}}var ALWAYS_SHIPPED=/^(?:package\.json|readme(?:\..*)?|licen[cs]e(?:\..*)?)$/i;function globToRegExp(glob){let source="";for(let index=0;index<glob.length;index++){let char=glob[index];glob.startsWith("**/",index)?(source+="(?:.*/)?",index+=2):glob.startsWith("**",index)?(source+=".*",index+=1):char==="*"?source+="[^/]*":char==="?"?source+="[^/]":source+=char.replace(/[.+^${}()|[\]\\]/g,"\\$&")}return new RegExp(`^${source}(?:/.*)?$`)}function shippedEntries(packageDir){let manifest=JSON.parse(readFileSync2(join3(packageDir,"package.json"),"utf8")),listed=typeof manifest=="object"&&manifest!==null?manifest.files:void 0;if(!Array.isArray(listed)||!listed.every(entry=>typeof entry=="string"))return;let normalize=entry=>entry.replace(/^\.\//,"").replace(/\/+$/,"");return{include:listed.filter(entry=>!entry.startsWith("!")).map(normalize),exclude:listed.filter(entry=>entry.startsWith("!")).map(entry=>globToRegExp(normalize(entry.slice(1))))}}function planPackageRoot(packageDir,target,files){let shipped=shippedEntries(packageDir);if(shipped===void 0){planTree(packageDir,target,files,!0);return}let root=realpathSync2(packageDir),excluded=relativePath=>shipped.exclude.some(pattern=>pattern.test(relativePath)),planned=new Set,plan=relativePath=>{if(planned.has(relativePath)||excluded(relativePath))return;let from=join3(root,relativePath),isDirectory;try{isDirectory=statSync2(from).isDirectory()}catch(error){if(isMissing(error))return;throw error}planned.add(relativePath);let to=join3(target,relativePath);isDirectory?planTree(from,to,files,!0,new Set([root]),excluded,relativePath):UNLOADED_FILE.test(relativePath)||(mkdirSync2(dirname(to),{recursive:!0}),files.push([realpathSync2(from),to]))};mkdirSync2(target,{recursive:!0});let topLevel=readdirSync2(root).filter(name=>name!=="node_modules");for(let name of topLevel)ALWAYS_SHIPPED.test(name)&&plan(name);for(let entry of shipped.include){let segments=entry.split("/"),wildcard=segments.findIndex(segment=>/[*?]/.test(segment));if(wildcard===-1)plan(entry);else if(wildcard>0)plan(segments.slice(0,wildcard).join("/"));else{let pattern=globToRegExp(segments[0]??"");for(let name of topLevel)pattern.test(name)&&plan(name)}}}var RuntimeSnapshotLayoutError=class extends Error{constructor(packageName){super(`runtime snapshot resolves ${packageName} differently from the install`),this.packageName=packageName}},STAGING_PREFIX=".tmp-";function moduleDirectoriesFrom(dir){let directories=[];for(let current=dir;;current=dirname2(current)){if(basename(current)!=="node_modules"){let candidate=join4(current,"node_modules");existsSync2(candidate)&&directories.push(candidate)}if(dirname2(current)===current)return directories}}function packageRootFrom(dir,packageName){for(let modules of moduleDirectoriesFrom(dir)){let root=join4(modules,packageName);if(existsSync2(join4(root,"package.json")))return realpathSync3(root)}}function dependencyNames(packageDir){let manifest=JSON.parse(readFileSync3(join4(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=[realpathSync3(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=realpathSync3(packageDir),placed=new Map,pending=[],place=(installDir,snapshotDir)=>{planTree(installDir,snapshotDir,files,!0,new Set,dependencyFileExclusions(installDir)),placed.set(snapshotDir,installDir),pending.push({installDir,snapshotDir})},resolvePlaced=(from,name)=>{for(let dir=from;;dir=dirname2(dir)){if(basename(dir)!=="node_modules"){let found=placed.get(join4(dir,"node_modules",name));if(found!==void 0)return found}if(dir===snapshotRoot||dirname2(dir)===dir)return}};for(let name of closureNames(packageDir,externals)){let source=packageRootFrom(packageDir,name);source!==void 0&&source!==self&&place(source,join4(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,join4(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=>join4(modules,name)).find(root=>existsSync2(join4(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=join4(dirname2(target),`${STAGING_PREFIX}${basename(target)}-${process.pid}`);rmSync(staging,{recursive:!0,force:!0});try{let files=[];planPackageRoot(packageDir,staging,files);let placed=planModules(packageDir,staging,manifest.externals,files);await copyFiles(files,copier),verifyExternals(packageDir,join4(staging,"dist","bundle","chunks"),manifest.externals,placed);let marker={buildId:manifest.buildId,installPackageDir:realpathSync3(packageDir)};writeFileSync(join4(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 mkdirSync3,readdirSync as readdirSync3,readFileSync as readFileSync4,renameSync as renameSync2,rmSync as rmSync2,statSync as statSync3,unlinkSync,utimesSync,writeFileSync as writeFileSync2}from"node:fs";import{join as join5}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-statSync3(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){mkdirSync3(root,{recursive:!0});let lock=join5(root,LOCK_NAME),deadline=Date.now()+LOCK_WAIT_MS;for(;;){try{mkdirSync3(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(readFileSync4(join5(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){mkdirSync3(root,{recursive:!0});let lock=join5(root,`${BUILD_LOCK_PREFIX}${id}`),deadline=Date.now()+BUILD_WAIT_MS;for(;;){try{mkdirSync3(lock),writeFileSync2(join5(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 readdirSync3(root))name.startsWith(`${STAGING_PREFIX}${id}-`)&&rmSync2(join5(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){mkdirSync3(join5(snapshotDir,CLAIMS_DIR),{recursive:!0}),writeFileSync2(join5(snapshotDir,CLAIMS_DIR,String(pid)),"");let now=new Date;utimesSync(join5(snapshotDir,RUNTIME_SNAPSHOT_MARKER),now,now)}function reapClaims(snapshotDir,isAlive){let names;try{names=readdirSync3(join5(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(join5(snapshotDir,CLAIMS_DIR,name))}return live}function pruneRuntimeSnapshots(root,keep,now,isAlive=isProcessAlive){reapClaims(join5(root,keep),isAlive);for(let name of readdirSync3(root)){if(name===LOCK_NAME||name===keep)continue;let path=join5(root,name);if(name.startsWith(".")){ageMs(path,now)>LEFTOVER_MS&&rmSync2(path,{recursive:!0,force:!0});continue}if(reapClaims(path,isAlive)>0||ageMs(join5(path,RUNTIME_SNAPSHOT_MARKER),now)<=UNUSED_SNAPSHOT_GRACE_MS)continue;let trash=join5(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(readFileSync5(join6(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=dirname3(entryPath),runtimeRoot=join6(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)!==join6("dist","bundle"))return{kind:"run-here"};let installId=createHash("sha256").update(realpathSync4(packageDir)).digest("hex").slice(0,12),snapshotId=`${manifest.buildId}-${installId}`,snapshotDir=join6(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(join6(snapshotDir,"dist","bundle",basename2(entryPath))).href,snapshotDir}}catch{return{kind:"run-here"}}}import{spawn}from"node:child_process";import{readFileSync as readFileSync6}from"node:fs";import{join as join7}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(readFileSync6(join7(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",windowsHide:!0});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 reexecStdio(){let base=channelStdio();if(!process.env[HOST_STARTUP_EVENTS_ENV])return base;try{let stat=fstatSync(16);if(!stat.isSocket()&&!isFifoMode(stat.mode))return base}catch{return base}let slots=typeof base=="string"?[base,base,base]:[...base];for(;slots.length<16;)slots.push("ignore");return slots[16]=16,slots}function channelStdio(){let argv=process.argv.slice(2),presenter=argv.indexOf("--mcp-presenter-fd");if(presenter<0||argv[presenter+1]!=="4")return"inherit";try{let stat=fstatSync(4);if(!stat.isSocket()&&!stat.isFIFO())return"inherit"}catch{return"inherit"}let owner=argv.indexOf("--owner-fd");return["inherit","inherit","inherit",owner>=0&&argv[owner+1]==="3"||process.env.SENPI_RPC_HOST_WATCH_FD==="3"?3:"ignore",4]}function reexecUnderBunIfNeeded(){let options=processBunRuntimeOptions(existsSync3,realpathSync5),scriptRealPath=process.argv[1]??fileURLToPath(import.meta.url);try{scriptRealPath=realpathSync5(scriptRealPath)}catch{}let decision=resolveBunReexec({scriptRealPath,versions:process.versions,hasInheritedInspectorOption:hasInheritedInspectorOption(),options});if(decision.action==="stay")return!1;let transfer=preparePrivateFdSpawn({stdio:reexecStdio(),windowsHide:!0}),result=(()=>{try{return spawnSync(decision.bunPath,[scriptRealPath,...process.argv.slice(2)],transfer.options)}finally{transfer.close()}})();return result.signal?(process.kill(process.pid,result.signal),!0):(process.exitCode=result.status??1,!0)}await dispatchKillGuardCommand(process.argv.slice(2));reexecUnderBunIfNeeded()&&process.exit();var args=process.argv.slice(2);await dispatchAgentDirectoryCommand(args);await enableStartupCompileCache();process.title=APP_NAME;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});var 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=>!existsSync3(join8(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:runtimeExecArgv().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={...process.env,[ISOLATED_CHILD_ENV]:"1"};return await new Promise((resolve,reject)=>{let child=spawnWithPrivateFds(spawn2,process.execPath,[...runtimeExecArgv(),fullCliPath,...args],{env:childEnvironment,stdio:reexecStdio()});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"))&&await printThenExit(()=>console.log(DISPLAY_VERSION));if(isRootCommand(args)&&args.some(arg=>arg==="--help"||arg==="-h")){let{tryPrintHelpWithoutEngine}=await import("./chunks/help-fast-path-JWHUCE4E.js"),help=await captureStdout(()=>tryPrintHelpWithoutEngine(args));help.result&&await exitAfterOutput(help.output),process.stdout.write(help.output)}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(dirname4(entryPath)),getAgentDir()):void 0;snapshot?.kind==="hand-off"?await import(__rewriteRelativeImportExtension(snapshot.entryUrl)):await import("./chunks/cli-main-GNQY2LTU.js")}
@@ -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,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultResourceLoader,EVAL_HANDLE_ERROR_CODES,EvalHandleError,ExtensionRunner,FooterComponent,InteractiveMode,JOB_WIDGET_STATE_EVENT,KILL_GUARD_MODULE_URL,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ReservedCustodyKey,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,TextTap,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageSelectorComponent,buildNoticeBox,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,connectWebViewService,convertToPng,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,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,kernelToolsStorage,killGuardProtectedPids,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSkillBlock,prepareBranchEntries,readKillGuardSetting,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-I4N2OIY4.js";import"./chunks/chunk-Y4PFEXFN.js";import{RELOCATION_TOOL_NAMES,SESSION_CONTROL_DELIVERY_TYPE,isSessionControlDeliveryDetails,sessionControlRemoteOriginOf,sessionControlSenderOf}from"./chunks/chunk-KKB3K5CV.js";import{RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,UnknownCommandError,isTransportGoneError}from"./chunks/chunk-NI2AOYP6.js";import"./chunks/chunk-WRBOKYPS.js";import"./chunks/chunk-CU6HUYL7.js";import"./chunks/chunk-NLYT7BND.js";import{DefaultPackageManager,SessionSelectorComponent,SettingsManager}from"./chunks/chunk-EQT4WNCW.js";import"./chunks/chunk-DEUEMEV3.js";import"./chunks/chunk-XI6THO4F.js";import{CURRENT_SESSION_VERSION,SessionManager,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,convertToLlm,getLatestCompactionEntry,migrateSessionEntries,parseSessionEntries,sessionEntryToContextMessages}from"./chunks/chunk-7GD2EO6T.js";import"./chunks/chunk-WMDJMN5W.js";import"./chunks/chunk-GTJJ73DE.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-VD7AKTGP.js";import{AssistantMessageComponent,CustomEditor,ExtensionEditorComponent,REQUIRED_COMPACTION_ERROR_MESSAGE,RequiredCompactionError,UserMessageComponent,copyToClipboard}from"./chunks/chunk-V4VDIV3U.js";import"./chunks/chunk-M2VJVJMK.js";import"./chunks/chunk-TQHNFP77.js";import{DynamicBorder,ExtensionInputComponent,ExtensionSelectorComponent,Theme,findReservedKeywordRuns,findReservedKeywordSpans,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-BKDXY6EM.js";import{SecretInputUnavailableError}from"./chunks/chunk-HKCFMDJN.js";import"./chunks/chunk-E6ZBTSC6.js";import"./chunks/chunk-3QPE75AR.js";import"./chunks/chunk-ULWRGKP2.js";import"./chunks/chunk-4B5JSLLR.js";import"./chunks/chunk-FWIO636S.js";import"./chunks/chunk-MOVB6H22.js";import{registerRpcRemoteSource}from"./chunks/chunk-DLPV4B3R.js";import"./chunks/chunk-VPVD5G32.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-RNLFZ67U.js";import"./chunks/chunk-SOMFLLPD.js";import{readOwnFootprint,readProcessFootprint}from"./chunks/chunk-MTQQ2VQH.js";import{DEFAULT_HOST_LAUNCH_SPEC,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HostLaunchSpecError,PINNED_HOST_CLIENT_CAPABILITIES,TUI_PROBE_TIMEOUT_MS,classifyEndpointLiveness,endpointProbeTimeoutMs,ensureHost,handoffHost,loadHostLaunchSpec,parseHostLaunchSpec,readAllHostStatus,readHostStatus,runHostCommand,runHostRequest}from"./chunks/chunk-WMHESZCU.js";import{GENERATION_HANDOFF_CAPABILITY,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,REQUIRED_HOST_CAPABILITIES,compareEngineOrdinal,decideHostAction,engineBuildIdentity,engineBuildIdentityFrom,gcHostEndpoints,parseHostProtocolInfo,probeHost,stopHost}from"./chunks/chunk-IJXKHJYR.js";import{createSyntheticSourceInfo}from"./chunks/chunk-QMRJYMNH.js";import{listHostEndpoints}from"./chunks/chunk-DZQA5LVN.js";import{parseArgs}from"./chunks/chunk-IEY2SL46.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-4JMGWVRH.js";import"./chunks/chunk-E5O4SP5I.js";import"./chunks/chunk-AT5G5BUI.js";import"./chunks/chunk-7WYJAYHH.js";import"./chunks/chunk-5HMYIYQB.js";import"./chunks/chunk-OSNR3IRD.js";import"./chunks/chunk-UCXBDE6R.js";import{ENDPOINT_REGISTRY_VERSION,createHostDaemonPaths,daemonDirectoryName,shardKey,shardSocketPath,shardSocketPathForKey}from"./chunks/chunk-YI6KRJDC.js";import"./chunks/chunk-VUY4BZDI.js";import"./chunks/chunk-SF4MQDKZ.js";import"./chunks/chunk-UYPH6RHY.js";import"./chunks/chunk-AZ27TE3H.js";import"./chunks/chunk-GILDYS3O.js";import"./chunks/chunk-KLAX467B.js";import"./chunks/chunk-C4AHHZ6P.js";import"./chunks/chunk-CEFKVI3E.js";import"./chunks/chunk-HGCQAMC6.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-236TAYFX.js";import"./chunks/chunk-36BLGKRO.js";import"./chunks/chunk-FKX6EWFV.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-EUCZC2RF.js";import"./chunks/chunk-WHQ2QPP5.js";import"./chunks/chunk-PBUV2Z3R.js";import"./chunks/chunk-WB4BUHOH.js";import"./chunks/chunk-NJ43NBSP.js";import"./chunks/chunk-KDUJCDLM.js";import{decideKillGuardRequest}from"./chunks/chunk-6APXZK7W.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-2IKL4F24.js";import"./chunks/chunk-KJR3XXMI.js";import"./chunks/chunk-IYL5E4QQ.js";import"./chunks/chunk-7THM57HH.js";import"./chunks/chunk-AC72EWI5.js";import"./chunks/chunk-RQFD6LG2.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatSize,getJobWidgetState,registerJobWidgetSource,setJobWidgetAuthorResolver,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-HZQHA4PA.js";import{sanitizeTerminalLabel,visibleWidth}from"./chunks/chunk-4PMRUR4L.js";import"./chunks/chunk-LPYBKMPT.js";import{activateKillGuardRuntime,activeKillGuardEnvironment,getPowerShellConfig,getShellConfig,releaseKillGuardRuntime,withBundledBunCommands}from"./chunks/chunk-JJYN347Z.js";import"./chunks/chunk-NDI6N4NJ.js";import"./chunks/chunk-R7J5TEYK.js";import"./chunks/chunk-62OVOJPI.js";import"./chunks/chunk-G7U4BOJP.js";import"./chunks/chunk-SFACYIB6.js";import"./chunks/chunk-XDEZA6U6.js";import{KILL_GUARD_TAG}from"./chunks/chunk-WOHQJ6JB.js";import"./chunks/chunk-COH5F7QV.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-Y7QPP7BG.js";import"./chunks/chunk-IREUIMFE.js";import"./chunks/chunk-GVSBCJFI.js";import"./chunks/chunk-QTS2XGPQ.js";import"./chunks/chunk-Z6TEQEZO.js";import"./chunks/chunk-ZG3MNTNX.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-HK46JMSC.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-UAOOH2V7.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-OH5TKHW7.js";import"./chunks/chunk-NDNQ23SK.js";import"./chunks/chunk-JGKH3D6W.js";import"./chunks/chunk-3SASTB6Y.js";import"./chunks/chunk-PJ34QVL5.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-GLTOBXZY.js";import"./chunks/chunk-U4FAWC6C.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-ZFIC2DZV.js";import"./chunks/chunk-2SOVDETB.js";import"./chunks/chunk-LJFQYCFH.js";import"./chunks/chunk-K3GAGIPX.js";import"./chunks/chunk-RUGTHELO.js";import"./chunks/chunk-42XRJQM6.js";import"./chunks/chunk-IHES3JES.js";import"./chunks/chunk-5XHOHZIR.js";import"./chunks/chunk-HW6AAS3R.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-SODMQEHO.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-EYSV6A7S.js";import"./chunks/chunk-MIENF2YK.js";import"./chunks/chunk-OXNWERO4.js";import"./chunks/chunk-44BJPS5I.js";import"./chunks/chunk-AOTHPTMU.js";import"./chunks/chunk-O5RYI3IW.js";import"./chunks/chunk-RFFMEA4B.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,EVAL_HANDLE_ERROR_CODES,EvalHandleError,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,JOB_WIDGET_STATE_EVENT,KILL_GUARD_MODULE_URL,KILL_GUARD_TAG,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,PINNED_HOST_CLIENT_CAPABILITIES,ProjectTrustStore,RELOCATION_TOOL_NAMES,REQUIRED_COMPACTION_ERROR_MESSAGE,REQUIRED_HOST_CAPABILITIES,RequiredCompactionError,ReservedCustodyKey,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SESSION_CONTROL_DELIVERY_TYPE,SecretInputUnavailableError,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,TUI_PROBE_TIMEOUT_MS,TextTap,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UnknownCommandError,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,activateKillGuardRuntime,activeKillGuardEnvironment,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,decideKillGuardRequest,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,endpointProbeTimeoutMs,engineBuildIdentity,engineBuildIdentityFrom,ensureHost,estimateTokens,findCutPoint,findReservedKeywordRuns,findReservedKeywordSpans,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,gcHostEndpoints,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getJobWidgetState,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,killGuardProtectedPids,listHostEndpoints,loadHostLaunchSpec,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseArgs,parseFrontmatter,parseHostLaunchSpec,parseHostProtocolInfo,parseSessionEntries,parseSkillBlock,prepareBranchEntries,probeHost,rawKeyHint,readAllHostStatus,readHostStatus,readKillGuardSetting,readOwnFootprint,readProcessFootprint,readStoredCredential,registerJobWidgetSource,registerReadClassifier,registerRpcRemoteSource,releaseKillGuardRuntime,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runHostCommand,runHostRequest,runPrintMode,runRpcMode,sanitizeTerminalLabel,serializeConversation,sessionControlRemoteOriginOf,sessionControlSenderOf,sessionEntryToContextMessages,setJobWidgetAuthorResolver,shardKey,shardSocketPath,shardSocketPathForKey,shouldCompact,stopHost,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,visibleWidth,withBundledBunCommands,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
2
+ import{AgentSession,AgentSessionRuntime,ArminComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultResourceLoader,DeviceMachineConflictError,DeviceUnavailableError,EVAL_HANDLE_ERROR_CODES,EvalHandleError,ExtensionRunner,FooterComponent,InteractiveMode,JOB_WIDGET_STATE_EVENT,KILL_GUARD_MODULE_URL,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ReservedCustodyKey,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,TextTap,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageSelectorComponent,buildNoticeBox,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,connectWebViewService,convertToPng,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createToolMachine,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,kernelToolsStorage,killGuardProtectedPids,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSkillBlock,prepareBranchEntries,readKillGuardSetting,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-RRFDLGX6.js";import"./chunks/chunk-64FJ4QQJ.js";import{RELOCATION_TOOL_NAMES,SESSION_CONTROL_DELIVERY_TYPE,isSessionControlDeliveryDetails,sessionControlRemoteOriginOf,sessionControlSenderOf}from"./chunks/chunk-Q4RJ4WLE.js";import{RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,UnknownCommandError,isTransportGoneError}from"./chunks/chunk-TPLEPLEB.js";import"./chunks/chunk-75O3CWR5.js";import"./chunks/chunk-WAGFTIT4.js";import"./chunks/chunk-NLYT7BND.js";import{DefaultPackageManager,SessionSelectorComponent,SettingsManager}from"./chunks/chunk-HTWWKJJI.js";import"./chunks/chunk-DEUEMEV3.js";import"./chunks/chunk-XI6THO4F.js";import{CURRENT_SESSION_VERSION,SessionManager,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,convertToLlm,getLatestCompactionEntry,migrateSessionEntries,parseSessionEntries,sessionEntryToContextMessages}from"./chunks/chunk-FYVQEZYN.js";import"./chunks/chunk-WMDJMN5W.js";import"./chunks/chunk-GTJJ73DE.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-VD7AKTGP.js";import{AssistantMessageComponent,CustomEditor,ExtensionEditorComponent,REQUIRED_COMPACTION_ERROR_MESSAGE,RequiredCompactionError,UserMessageComponent,copyToClipboard}from"./chunks/chunk-PWA75RQU.js";import"./chunks/chunk-M2VJVJMK.js";import"./chunks/chunk-TQHNFP77.js";import{DynamicBorder,ExtensionInputComponent,ExtensionSelectorComponent,Theme,findReservedKeywordRuns,findReservedKeywordSpans,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-5NECOJNK.js";import{SecretInputUnavailableError}from"./chunks/chunk-HKCFMDJN.js";import"./chunks/chunk-A3LGSX7Z.js";import"./chunks/chunk-3QPE75AR.js";import"./chunks/chunk-ULWRGKP2.js";import"./chunks/chunk-4B5JSLLR.js";import"./chunks/chunk-FWIO636S.js";import"./chunks/chunk-MOVB6H22.js";import{registerRpcRemoteSource}from"./chunks/chunk-DLPV4B3R.js";import"./chunks/chunk-VPVD5G32.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-RNLFZ67U.js";import"./chunks/chunk-SOMFLLPD.js";import{readOwnFootprint,readProcessFootprint}from"./chunks/chunk-MTQQ2VQH.js";import{DEFAULT_HOST_LAUNCH_SPEC,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HostLaunchSpecError,PINNED_HOST_CLIENT_CAPABILITIES,TUI_PROBE_TIMEOUT_MS,classifyEndpointLiveness,endpointProbeTimeoutMs,ensureHost,handoffHost,loadHostLaunchSpec,parseHostLaunchSpec,readAllHostStatus,readHostStatus,runHostCommand,runHostRequest}from"./chunks/chunk-WMHESZCU.js";import{GENERATION_HANDOFF_CAPABILITY,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,REQUIRED_HOST_CAPABILITIES,compareEngineOrdinal,decideHostAction,engineBuildIdentity,engineBuildIdentityFrom,gcHostEndpoints,parseHostProtocolInfo,probeHost,stopHost}from"./chunks/chunk-IJXKHJYR.js";import{createSyntheticSourceInfo}from"./chunks/chunk-QMRJYMNH.js";import{listHostEndpoints}from"./chunks/chunk-DZQA5LVN.js";import{parseArgs}from"./chunks/chunk-IEY2SL46.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-4JMGWVRH.js";import"./chunks/chunk-E5O4SP5I.js";import"./chunks/chunk-AT5G5BUI.js";import"./chunks/chunk-7WYJAYHH.js";import"./chunks/chunk-5HMYIYQB.js";import"./chunks/chunk-OSNR3IRD.js";import"./chunks/chunk-UCXBDE6R.js";import{ENDPOINT_REGISTRY_VERSION,createHostDaemonPaths,daemonDirectoryName,shardKey,shardSocketPath,shardSocketPathForKey}from"./chunks/chunk-YI6KRJDC.js";import"./chunks/chunk-VUY4BZDI.js";import"./chunks/chunk-SF4MQDKZ.js";import"./chunks/chunk-Z4PN2MDA.js";import"./chunks/chunk-7BX3JQ7F.js";import"./chunks/chunk-GILDYS3O.js";import"./chunks/chunk-KLAX467B.js";import"./chunks/chunk-C4AHHZ6P.js";import"./chunks/chunk-CEFKVI3E.js";import"./chunks/chunk-HGCQAMC6.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-236TAYFX.js";import"./chunks/chunk-36BLGKRO.js";import"./chunks/chunk-FKX6EWFV.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-EUCZC2RF.js";import"./chunks/chunk-WHQ2QPP5.js";import"./chunks/chunk-RLIY3AUC.js";import"./chunks/chunk-WB4BUHOH.js";import"./chunks/chunk-NJ43NBSP.js";import"./chunks/chunk-KDUJCDLM.js";import{decideKillGuardRequest}from"./chunks/chunk-6APXZK7W.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-6QQL3SKM.js";import"./chunks/chunk-2IKL4F24.js";import"./chunks/chunk-KJR3XXMI.js";import"./chunks/chunk-IYL5E4QQ.js";import"./chunks/chunk-7THM57HH.js";import"./chunks/chunk-AC72EWI5.js";import"./chunks/chunk-RQFD6LG2.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatSize,getJobWidgetState,registerJobWidgetSource,setJobWidgetAuthorResolver,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-3RILB2OD.js";import{sanitizeTerminalLabel,visibleWidth}from"./chunks/chunk-4PMRUR4L.js";import"./chunks/chunk-LPYBKMPT.js";import{activateKillGuardRuntime,activeKillGuardEnvironment,getPowerShellConfig,getShellConfig,releaseKillGuardRuntime,withBundledBunCommands}from"./chunks/chunk-ZJUL5ODW.js";import"./chunks/chunk-7CXLNKEH.js";import"./chunks/chunk-R7J5TEYK.js";import"./chunks/chunk-62OVOJPI.js";import"./chunks/chunk-G7U4BOJP.js";import"./chunks/chunk-IK3S2NDB.js";import"./chunks/chunk-XDEZA6U6.js";import{KILL_GUARD_TAG}from"./chunks/chunk-WOHQJ6JB.js";import"./chunks/chunk-COH5F7QV.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-Y7QPP7BG.js";import"./chunks/chunk-PWTXZXHH.js";import"./chunks/chunk-GVSBCJFI.js";import"./chunks/chunk-QTS2XGPQ.js";import"./chunks/chunk-Z6TEQEZO.js";import"./chunks/chunk-ZG3MNTNX.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-HK46JMSC.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-UAOOH2V7.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-OH5TKHW7.js";import"./chunks/chunk-NDNQ23SK.js";import"./chunks/chunk-JGKH3D6W.js";import"./chunks/chunk-3SASTB6Y.js";import"./chunks/chunk-PJ34QVL5.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-QVG5SUSV.js";import"./chunks/chunk-74HCKLRH.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-ZFIC2DZV.js";import"./chunks/chunk-2SOVDETB.js";import"./chunks/chunk-LJFQYCFH.js";import"./chunks/chunk-K3GAGIPX.js";import"./chunks/chunk-RUGTHELO.js";import"./chunks/chunk-42XRJQM6.js";import"./chunks/chunk-IHES3JES.js";import"./chunks/chunk-5XHOHZIR.js";import"./chunks/chunk-HW6AAS3R.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-SODMQEHO.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-EYSV6A7S.js";import"./chunks/chunk-MIENF2YK.js";import"./chunks/chunk-OXNWERO4.js";import"./chunks/chunk-44BJPS5I.js";import"./chunks/chunk-AOTHPTMU.js";import"./chunks/chunk-O5RYI3IW.js";import"./chunks/chunk-RFFMEA4B.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,DeviceMachineConflictError,DeviceUnavailableError,DynamicBorder,ENDPOINT_REGISTRY_VERSION,EVAL_HANDLE_ERROR_CODES,EvalHandleError,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,JOB_WIDGET_STATE_EVENT,KILL_GUARD_MODULE_URL,KILL_GUARD_TAG,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,PINNED_HOST_CLIENT_CAPABILITIES,ProjectTrustStore,RELOCATION_TOOL_NAMES,REQUIRED_COMPACTION_ERROR_MESSAGE,REQUIRED_HOST_CAPABILITIES,RequiredCompactionError,ReservedCustodyKey,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SESSION_CONTROL_DELIVERY_TYPE,SecretInputUnavailableError,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,TUI_PROBE_TIMEOUT_MS,TextTap,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UnknownCommandError,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,activateKillGuardRuntime,activeKillGuardEnvironment,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,createToolMachine,createWriteTool,createWriteToolDefinition,daemonDirectoryName,decideHostAction,decideKillGuardRequest,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,endpointProbeTimeoutMs,engineBuildIdentity,engineBuildIdentityFrom,ensureHost,estimateTokens,findCutPoint,findReservedKeywordRuns,findReservedKeywordSpans,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,gcHostEndpoints,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getJobWidgetState,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,killGuardProtectedPids,listHostEndpoints,loadHostLaunchSpec,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseArgs,parseFrontmatter,parseHostLaunchSpec,parseHostProtocolInfo,parseSessionEntries,parseSkillBlock,prepareBranchEntries,probeHost,rawKeyHint,readAllHostStatus,readHostStatus,readKillGuardSetting,readOwnFootprint,readProcessFootprint,readStoredCredential,registerJobWidgetSource,registerReadClassifier,registerRpcRemoteSource,releaseKillGuardRuntime,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runHostCommand,runHostRequest,runPrintMode,runRpcMode,sanitizeTerminalLabel,serializeConversation,sessionControlRemoteOriginOf,sessionControlSenderOf,sessionEntryToContextMessages,setJobWidgetAuthorResolver,shardKey,shardSocketPath,shardSocketPathForKey,shouldCompact,stopHost,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,visibleWidth,withBundledBunCommands,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
@@ -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"./chunks/chunk-JLCZIEBC.js";import{main}from"./chunks/chunk-I4N2OIY4.js";import"./chunks/chunk-Y4PFEXFN.js";import"./chunks/chunk-KKB3K5CV.js";import"./chunks/chunk-NI2AOYP6.js";import"./chunks/chunk-WRBOKYPS.js";import"./chunks/chunk-CU6HUYL7.js";import"./chunks/chunk-NLYT7BND.js";import"./chunks/chunk-EQT4WNCW.js";import{configureHttpDispatcher}from"./chunks/chunk-DEUEMEV3.js";import"./chunks/chunk-XI6THO4F.js";import"./chunks/chunk-7GD2EO6T.js";import"./chunks/chunk-WMDJMN5W.js";import"./chunks/chunk-GTJJ73DE.js";import"./chunks/chunk-VD7AKTGP.js";import"./chunks/chunk-V4VDIV3U.js";import"./chunks/chunk-M2VJVJMK.js";import"./chunks/chunk-TQHNFP77.js";import"./chunks/chunk-BKDXY6EM.js";import"./chunks/chunk-HKCFMDJN.js";import"./chunks/chunk-E6ZBTSC6.js";import"./chunks/chunk-3QPE75AR.js";import"./chunks/chunk-ULWRGKP2.js";import"./chunks/chunk-4B5JSLLR.js";import"./chunks/chunk-FWIO636S.js";import"./chunks/chunk-MOVB6H22.js";import"./chunks/chunk-DLPV4B3R.js";import"./chunks/chunk-VPVD5G32.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-RNLFZ67U.js";import"./chunks/chunk-SOMFLLPD.js";import"./chunks/chunk-MTQQ2VQH.js";import"./chunks/chunk-WMHESZCU.js";import"./chunks/chunk-IJXKHJYR.js";import"./chunks/chunk-QMRJYMNH.js";import"./chunks/chunk-DZQA5LVN.js";import"./chunks/chunk-IEY2SL46.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-4JMGWVRH.js";import"./chunks/chunk-E5O4SP5I.js";import"./chunks/chunk-AT5G5BUI.js";import"./chunks/chunk-7WYJAYHH.js";import"./chunks/chunk-5HMYIYQB.js";import"./chunks/chunk-OSNR3IRD.js";import"./chunks/chunk-UCXBDE6R.js";import"./chunks/chunk-YI6KRJDC.js";import"./chunks/chunk-VUY4BZDI.js";import"./chunks/chunk-SF4MQDKZ.js";import"./chunks/chunk-UYPH6RHY.js";import"./chunks/chunk-AZ27TE3H.js";import"./chunks/chunk-GILDYS3O.js";import"./chunks/chunk-KLAX467B.js";import"./chunks/chunk-C4AHHZ6P.js";import"./chunks/chunk-CEFKVI3E.js";import"./chunks/chunk-HGCQAMC6.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-236TAYFX.js";import"./chunks/chunk-36BLGKRO.js";import"./chunks/chunk-FKX6EWFV.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-EUCZC2RF.js";import"./chunks/chunk-WHQ2QPP5.js";import"./chunks/chunk-PBUV2Z3R.js";import"./chunks/chunk-WB4BUHOH.js";import"./chunks/chunk-NJ43NBSP.js";import"./chunks/chunk-KDUJCDLM.js";import"./chunks/chunk-6APXZK7W.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-2IKL4F24.js";import"./chunks/chunk-KJR3XXMI.js";import"./chunks/chunk-IYL5E4QQ.js";import"./chunks/chunk-7THM57HH.js";import"./chunks/chunk-AC72EWI5.js";import"./chunks/chunk-RQFD6LG2.js";import"./chunks/chunk-HZQHA4PA.js";import"./chunks/chunk-4PMRUR4L.js";import"./chunks/chunk-LPYBKMPT.js";import"./chunks/chunk-JJYN347Z.js";import"./chunks/chunk-NDI6N4NJ.js";import"./chunks/chunk-R7J5TEYK.js";import"./chunks/chunk-62OVOJPI.js";import"./chunks/chunk-G7U4BOJP.js";import"./chunks/chunk-SFACYIB6.js";import"./chunks/chunk-XDEZA6U6.js";import"./chunks/chunk-WOHQJ6JB.js";import"./chunks/chunk-COH5F7QV.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-Y7QPP7BG.js";import"./chunks/chunk-IREUIMFE.js";import"./chunks/chunk-GVSBCJFI.js";import"./chunks/chunk-QTS2XGPQ.js";import"./chunks/chunk-Z6TEQEZO.js";import"./chunks/chunk-ZG3MNTNX.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-HK46JMSC.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-UAOOH2V7.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-OH5TKHW7.js";import"./chunks/chunk-NDNQ23SK.js";import"./chunks/chunk-JGKH3D6W.js";import"./chunks/chunk-3SASTB6Y.js";import"./chunks/chunk-PJ34QVL5.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-GLTOBXZY.js";import"./chunks/chunk-U4FAWC6C.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-ZFIC2DZV.js";import"./chunks/chunk-2SOVDETB.js";import"./chunks/chunk-LJFQYCFH.js";import"./chunks/chunk-K3GAGIPX.js";import"./chunks/chunk-RUGTHELO.js";import"./chunks/chunk-42XRJQM6.js";import"./chunks/chunk-IHES3JES.js";import"./chunks/chunk-5XHOHZIR.js";import"./chunks/chunk-HW6AAS3R.js";import{APP_NAME,scrubBrandFromEnvironment}from"./chunks/chunk-SODMQEHO.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-EYSV6A7S.js";import"./chunks/chunk-MIENF2YK.js";import"./chunks/chunk-FQXWKEVK.js";import"./chunks/chunk-OXNWERO4.js";import"./chunks/chunk-44BJPS5I.js";import"./chunks/chunk-AOTHPTMU.js";import"./chunks/chunk-O5RYI3IW.js";import"./chunks/chunk-RFFMEA4B.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)]);
3
+ import"./chunks/chunk-THYIV26N.js";import{main}from"./chunks/chunk-RRFDLGX6.js";import"./chunks/chunk-64FJ4QQJ.js";import"./chunks/chunk-Q4RJ4WLE.js";import"./chunks/chunk-TPLEPLEB.js";import"./chunks/chunk-75O3CWR5.js";import"./chunks/chunk-WAGFTIT4.js";import"./chunks/chunk-NLYT7BND.js";import"./chunks/chunk-HTWWKJJI.js";import{configureHttpDispatcher}from"./chunks/chunk-DEUEMEV3.js";import"./chunks/chunk-XI6THO4F.js";import"./chunks/chunk-FYVQEZYN.js";import"./chunks/chunk-WMDJMN5W.js";import"./chunks/chunk-GTJJ73DE.js";import"./chunks/chunk-VD7AKTGP.js";import"./chunks/chunk-PWA75RQU.js";import"./chunks/chunk-M2VJVJMK.js";import"./chunks/chunk-TQHNFP77.js";import"./chunks/chunk-5NECOJNK.js";import"./chunks/chunk-HKCFMDJN.js";import"./chunks/chunk-A3LGSX7Z.js";import"./chunks/chunk-3QPE75AR.js";import"./chunks/chunk-ULWRGKP2.js";import"./chunks/chunk-4B5JSLLR.js";import"./chunks/chunk-FWIO636S.js";import"./chunks/chunk-MOVB6H22.js";import"./chunks/chunk-DLPV4B3R.js";import"./chunks/chunk-VPVD5G32.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-RNLFZ67U.js";import"./chunks/chunk-SOMFLLPD.js";import"./chunks/chunk-MTQQ2VQH.js";import"./chunks/chunk-WMHESZCU.js";import"./chunks/chunk-IJXKHJYR.js";import"./chunks/chunk-QMRJYMNH.js";import"./chunks/chunk-DZQA5LVN.js";import"./chunks/chunk-IEY2SL46.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-4JMGWVRH.js";import"./chunks/chunk-E5O4SP5I.js";import"./chunks/chunk-AT5G5BUI.js";import"./chunks/chunk-7WYJAYHH.js";import"./chunks/chunk-5HMYIYQB.js";import"./chunks/chunk-OSNR3IRD.js";import"./chunks/chunk-UCXBDE6R.js";import"./chunks/chunk-YI6KRJDC.js";import"./chunks/chunk-VUY4BZDI.js";import"./chunks/chunk-SF4MQDKZ.js";import"./chunks/chunk-Z4PN2MDA.js";import"./chunks/chunk-7BX3JQ7F.js";import"./chunks/chunk-GILDYS3O.js";import"./chunks/chunk-KLAX467B.js";import"./chunks/chunk-C4AHHZ6P.js";import"./chunks/chunk-CEFKVI3E.js";import"./chunks/chunk-HGCQAMC6.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-236TAYFX.js";import"./chunks/chunk-36BLGKRO.js";import"./chunks/chunk-FKX6EWFV.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-EUCZC2RF.js";import"./chunks/chunk-WHQ2QPP5.js";import"./chunks/chunk-RLIY3AUC.js";import"./chunks/chunk-WB4BUHOH.js";import"./chunks/chunk-NJ43NBSP.js";import"./chunks/chunk-KDUJCDLM.js";import"./chunks/chunk-6APXZK7W.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-6QQL3SKM.js";import"./chunks/chunk-2IKL4F24.js";import"./chunks/chunk-KJR3XXMI.js";import"./chunks/chunk-IYL5E4QQ.js";import"./chunks/chunk-7THM57HH.js";import"./chunks/chunk-AC72EWI5.js";import"./chunks/chunk-RQFD6LG2.js";import"./chunks/chunk-3RILB2OD.js";import"./chunks/chunk-4PMRUR4L.js";import"./chunks/chunk-LPYBKMPT.js";import"./chunks/chunk-ZJUL5ODW.js";import"./chunks/chunk-7CXLNKEH.js";import"./chunks/chunk-R7J5TEYK.js";import"./chunks/chunk-62OVOJPI.js";import"./chunks/chunk-G7U4BOJP.js";import"./chunks/chunk-IK3S2NDB.js";import"./chunks/chunk-XDEZA6U6.js";import"./chunks/chunk-WOHQJ6JB.js";import"./chunks/chunk-COH5F7QV.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-Y7QPP7BG.js";import"./chunks/chunk-PWTXZXHH.js";import"./chunks/chunk-GVSBCJFI.js";import"./chunks/chunk-QTS2XGPQ.js";import"./chunks/chunk-Z6TEQEZO.js";import"./chunks/chunk-ZG3MNTNX.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-HK46JMSC.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-UAOOH2V7.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-OH5TKHW7.js";import"./chunks/chunk-NDNQ23SK.js";import"./chunks/chunk-JGKH3D6W.js";import"./chunks/chunk-3SASTB6Y.js";import"./chunks/chunk-PJ34QVL5.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-QVG5SUSV.js";import"./chunks/chunk-74HCKLRH.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-ZFIC2DZV.js";import"./chunks/chunk-2SOVDETB.js";import"./chunks/chunk-LJFQYCFH.js";import"./chunks/chunk-K3GAGIPX.js";import"./chunks/chunk-RUGTHELO.js";import"./chunks/chunk-42XRJQM6.js";import"./chunks/chunk-IHES3JES.js";import"./chunks/chunk-5XHOHZIR.js";import"./chunks/chunk-HW6AAS3R.js";import{APP_NAME,scrubBrandFromEnvironment}from"./chunks/chunk-SODMQEHO.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-EYSV6A7S.js";import"./chunks/chunk-MIENF2YK.js";import"./chunks/chunk-FQXWKEVK.js";import"./chunks/chunk-OXNWERO4.js";import"./chunks/chunk-44BJPS5I.js";import"./chunks/chunk-AOTHPTMU.js";import"./chunks/chunk-O5RYI3IW.js";import"./chunks/chunk-RFFMEA4B.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":"8ed77a07f2a78b80","externals":["@earendil-works/chord","@earendil-works/pi-pty","@silvia-odwyer/photon-node","bufferutil","canvas","kerberos","supports-color","utf-8-validate"]}
1
+ {"buildId":"f366c384a78b3717","externals":["@earendil-works/chord","@earendil-works/pi-pty","@silvia-odwyer/photon-node","bufferutil","canvas","kerberos","supports-color","utf-8-validate"]}
@@ -355,7 +355,7 @@ export class AgentSessionRuntime {
355
355
  time("beforeSwitch", "switch");
356
356
  const previousSessionFile = this.session.sessionFile;
357
357
  const sessionManager = SessionManager.open(sessionPath, undefined, options?.cwdOverride);
358
- assertSessionCwdExists(sessionManager, this.cwd);
358
+ await assertSessionCwdExists(sessionManager, this.cwd);
359
359
  // Held before the current session is torn down: a session being moved fails the switch here.
360
360
  const hold = holdActiveSession(sessionManager, wasFlushed(sessionManager), this._launchProfile?.holderEndpoint);
361
361
  time("open", "switch");
@@ -525,7 +525,7 @@ export class AgentSessionRuntime {
525
525
  copyFileSync(resolvedPath, destinationPath, constants.COPYFILE_EXCL);
526
526
  }
527
527
  const sessionManager = SessionManager.open(destinationPath, sessionDir, cwdOverride);
528
- assertSessionCwdExists(sessionManager, this.cwd);
528
+ await assertSessionCwdExists(sessionManager, this.cwd);
529
529
  await this.teardownCurrent("resume", sessionManager.getSessionFile(), sessionManager.getSessionId());
530
530
  await this.apply(await this.createRuntime({
531
531
  cwd: sessionManager.getCwd(),
@@ -603,7 +603,7 @@ function holdActiveSession(sessionManager, expectExisting, holderEndpoint) {
603
603
  * later /new, /resume, /fork, and import flows.
604
604
  */
605
605
  export async function createAgentSessionRuntime(createRuntime, options) {
606
- assertSessionCwdExists(options.sessionManager, options.cwd);
606
+ await assertSessionCwdExists(options.sessionManager, options.cwd);
607
607
  const result = await createRuntime(options);
608
608
  return new AgentSessionRuntime(result.session, result.services, createRuntime, result.diagnostics, result.modelFallbackMessage, options.launchProfile);
609
609
  }
@@ -976,6 +976,7 @@ export declare class AgentSession {
976
976
  /** Settles once dispose() has stopped the tool child, swept what it launched, closed its in-process offload jobs, and the fallback log's first-start removal has finished. */
977
977
  private _toolChildClosed;
978
978
  private _fallbackLogSettled;
979
+ private _fallbackLog;
979
980
  private _extensionRunnerRef?;
980
981
  private _initialActiveToolNames?;
981
982
  private _defaultToolNames?;
@@ -1651,9 +1652,10 @@ export declare class AgentSession {
1651
1652
  private _pooledAccountHealth;
1652
1653
  /**
1653
1654
  * The reported usage of this provider's accounts, without the ones only the user can bring back (a re-login, a
1654
- * disabled or signed-out account): the pool skips those whatever their usage reads, so their usage must not
1655
- * release the provider's hold (senpi#6536). Accounts the summary does not name keep their usage, so a provider
1656
- * holding one credential still releases on its own reading.
1655
+ * disabled, signed-out, billing- or organization-blocked account): the pool skips those whatever their usage reads,
1656
+ * so their usage must not release the provider's hold (senpi#6536). An account out only on a usage limit keeps it.
1657
+ * Accounts the summary does not name keep their usage, so a provider holding one credential still releases on its
1658
+ * own reading.
1657
1659
  */
1658
1660
  private _usageOfSelectableAccounts;
1659
1661
  prompt(text: string, options?: PromptOptions): Promise<void>;
@@ -92,6 +92,7 @@ import { deriveExtensionRegistrationId } from "./extensions/builtin/tool-search/
92
92
  import { adoptToolSearchServiceForSession } from "./extensions/builtin/tool-search/service.js";
93
93
  import { ExecuteToolError, } from "./extensions/index.js";
94
94
  import { emitSessionShutdownEvent } from "./extensions/runner.js";
95
+ import { combinedToolCallSignal } from "./extensions/tool-call-signal.js";
95
96
  import { normalizeToolExposure, RUNTIME_EXTENSION_PATH } from "./extensions/types.js";
96
97
  import { createUserActivitySource, emitUserActivity } from "./extensions/user-activity.js";
97
98
  import { deliveryIdOf, ExternalAdmission } from "./external-admission.js";
@@ -120,7 +121,7 @@ import { NestedToolCallRunner } from "./nested-tool-calls.js";
120
121
  import { SessionPendingInputs } from "./pending-input-session.js";
121
122
  import { PROMPT_CACHE_SAFE_WAIT_ENV, resolvePromptCacheSafeWaitSeconds } from "./prompt-cache-budget.js";
122
123
  import { PromptCachePrefixBuilds } from "./prompt-cache-prefix-request.js";
123
- import { requestThinkingLevel } from "./reasoning-baseline.js";
124
+ import { requestThinkingLevel, withLiveConfigurationUpdate } from "./reasoning-baseline.js";
124
125
  import { expandPromptTemplateWithMetadata } from "./prompt-templates.js";
125
126
  import { isRequestLevelRefusal, providerFailureOf, selectedModelOf, } from "./provider-failure.js";
126
127
  import { rejectedImageSources } from "./provider-rejected-images.js";
@@ -849,6 +850,7 @@ export class AgentSession {
849
850
  this._modelRegistry = config.modelRegistry ?? new ModelRegistry(modelRuntime);
850
851
  this._agentDir = config.agentDir ?? getAgentDir();
851
852
  const fallbackLogger = createFallbackLogger(this._agentDir);
853
+ this._fallbackLog = fallbackLogger;
852
854
  this._fallbackLogSettled = fallbackLogger.settled();
853
855
  this._modelConfigErrors = createModelConfigErrorReporter(fallbackLogger, (event) => this._emit(event));
854
856
  this._sessionLogger = createSessionLogger(this._agentDir, {
@@ -1331,7 +1333,7 @@ export class AgentSession {
1331
1333
  }
1332
1334
  const preflightWatch = watchForStall(thresholdMs, (elapsedMs) => warnStalled("tool_call_preflight_stalled", elapsedMs));
1333
1335
  try {
1334
- const signal = options.signal ?? this.agent.signal;
1336
+ const signal = combinedToolCallSignal(options.signal, this.agent.signal);
1335
1337
  // A call released by Stop never runs: block it without asking its hooks (a permission prompt) about it.
1336
1338
  // Callers such as executeTool only honor an explicit block, so returning nothing here would let it run.
1337
1339
  if ((await this._waitForToolBarrier(toolCall, signal)) && signal?.aborted) {
@@ -1348,7 +1350,7 @@ export class AgentSession {
1348
1350
  toolCallId: toolCall.id,
1349
1351
  ...(options.parentToolCallId ? { parentToolCallId: options.parentToolCallId } : {}),
1350
1352
  input: args,
1351
- });
1353
+ }, signal === undefined ? {} : { signal });
1352
1354
  }
1353
1355
  catch (err) {
1354
1356
  if (err instanceof Error) {
@@ -1571,8 +1573,11 @@ export class AgentSession {
1571
1573
  // The idle path tokenizes agent.state.messages in place; every provider
1572
1574
  // request re-hydrates here so tokens can never reach a model.
1573
1575
  this.sessionManager.getResidentStore().materializeInPlace(messages);
1574
- const transformed = this._requestShapeRecovery.apply(previousTransformContext ? await previousTransformContext(messages, signal) : messages);
1575
1576
  const model = this.model;
1577
+ const shaped = this._requestShapeRecovery.apply(previousTransformContext ? await previousTransformContext(messages, signal) : messages);
1578
+ const transformed = model !== undefined && supportsConfigurationUpdate(model)
1579
+ ? withLiveConfigurationUpdate(shaped, this.agent.state.thinkingLevel, Date.now())
1580
+ : shaped;
1576
1581
  if (model?.provider !== "cursor" && model?.provider !== "cursor-cli-oauth")
1577
1582
  return transformed;
1578
1583
  this._applyObservedCursorContextWindow(model);
@@ -3912,6 +3917,7 @@ export class AgentSession {
3912
3917
  }
3913
3918
  const beforeResult = await this.preflightToolCall(prepared.toolCall, prepared.args, {
3914
3919
  waitForEventQueue: this._toolExecutionDepth === 0,
3920
+ ...(options?.signal === undefined ? {} : { signal: options.signal }),
3915
3921
  });
3916
3922
  if (beforeResult?.block) {
3917
3923
  throw new ExecuteToolError("blocked", toolName, beforeResult.reason || "Tool execution was blocked", activeTools);
@@ -4393,9 +4399,10 @@ export class AgentSession {
4393
4399
  }
4394
4400
  /**
4395
4401
  * The reported usage of this provider's accounts, without the ones only the user can bring back (a re-login, a
4396
- * disabled or signed-out account): the pool skips those whatever their usage reads, so their usage must not
4397
- * release the provider's hold (senpi#6536). Accounts the summary does not name keep their usage, so a provider
4398
- * holding one credential still releases on its own reading.
4402
+ * disabled, signed-out, billing- or organization-blocked account): the pool skips those whatever their usage reads,
4403
+ * so their usage must not release the provider's hold (senpi#6536). An account out only on a usage limit keeps it.
4404
+ * Accounts the summary does not name keep their usage, so a provider holding one credential still releases on its
4405
+ * own reading.
4399
4406
  */
4400
4407
  async _usageOfSelectableAccounts(provider) {
4401
4408
  const usage = subscriptionLimits.snapshot();
@@ -4406,7 +4413,12 @@ export class AgentSession {
4406
4413
  const blocked = new Set(accountsNeedingUser(await getCredentialAccounts(storage, provider)));
4407
4414
  return blocked.size === 0 ? usage : usage.filter((limits) => !blocked.has(limits.account));
4408
4415
  }
4409
- catch {
4416
+ catch (error) {
4417
+ // Unfiltered usage only widens what may release the hold; the reason it could not be narrowed is logged.
4418
+ this._fallbackLog?.warn("usage_accounts_unread", {
4419
+ provider,
4420
+ error: error instanceof Error ? error.message : String(error),
4421
+ });
4410
4422
  return usage;
4411
4423
  }
4412
4424
  }
@@ -8,9 +8,11 @@ export type CredentialAccountSource = "login" | "import" | "env";
8
8
  */
9
9
  export type CredentialAccountBlockedReason = "auth_error" | "rate_limit" | "disabled";
10
10
  /**
11
- * The accounts no usage reading can bring back: the user must act (a re-login, a disabled or signed-out account)
12
- * or the pool never selects the slot. A pool skips them whatever their usage reads, so usage they report must not
13
- * release a session's hold on the provider.
11
+ * The accounts no usage reading can bring back, so usage they report must not release a session's hold on the
12
+ * provider (senpi#6536): a slot of the other credential kind (senpi#3486), a signed-out account, and every account
13
+ * blocked for anything but a usage limit. A usage limit is a `rate_limit` block or a `paused` one (a ChatGPT
14
+ * subscription's usage-limit pause, which carries no reason). The Claude lane's billing and organization blocks also
15
+ * reach a summary with no reason but are not paused, so they count as needing the user.
14
16
  */
15
17
  export declare function accountsNeedingUser(summaries: readonly CredentialAccountSummary[]): string[];
16
18
  /**
@@ -14,16 +14,18 @@ import { isForeignAuthBlock, isListedStoredSlot, SENTINEL_OAUTH_FIELDS, } from "
14
14
  import { isAccountBlocked, isLimitLiftedEarly } from "./extensions/builtin/anthropic-subscription/affinity.js";
15
15
  import { accountDirFor, isValidAccountDirId, removeAccountDir, } from "./extensions/builtin/anthropic-subscription/claude-cli-account-dir.js";
16
16
  import { defaultExecutableDeps, resolveClaudeCodeExecutable, } from "./extensions/builtin/anthropic-subscription/executable.js";
17
- /** Blocks only the user can clear: a pool never selects such an account, whatever its usage reads (senpi#6536). */
18
- const NEEDS_USER = new Set(["auth_error", "disabled"]);
19
17
  /**
20
- * The accounts no usage reading can bring back: the user must act (a re-login, a disabled or signed-out account)
21
- * or the pool never selects the slot. A pool skips them whatever their usage reads, so usage they report must not
22
- * release a session's hold on the provider.
18
+ * The accounts no usage reading can bring back, so usage they report must not release a session's hold on the
19
+ * provider (senpi#6536): a slot of the other credential kind (senpi#3486), a signed-out account, and every account
20
+ * blocked for anything but a usage limit. A usage limit is a `rate_limit` block or a `paused` one (a ChatGPT
21
+ * subscription's usage-limit pause, which carries no reason). The Claude lane's billing and organization blocks also
22
+ * reach a summary with no reason but are not paused, so they count as needing the user.
23
23
  */
24
24
  export function accountsNeedingUser(summaries) {
25
25
  return summaries
26
- .filter((account) => account.unused === true || account.signedOut === true || NEEDS_USER.has(account.blockedReason ?? ""))
26
+ .filter((account) => account.unused === true ||
27
+ account.signedOut === true ||
28
+ (account.blocked && account.blockedReason !== "rate_limit" && account.paused !== true))
27
29
  .map((account) => account.name);
28
30
  }
29
31
  /**
@@ -5,7 +5,7 @@ import { ModelsError } from "@earendil-works/pi-ai/utils/models-error";
5
5
  import { isOAuthRefreshUnavailableError, OAuthTokenEndpointError, } from "@earendil-works/pi-ai/utils/oauth-refresh-error";
6
6
  import { getOverflowPatterns } from "@earendil-works/pi-ai/utils/overflow";
7
7
  import { extract429RetryAfterMs, parseRetryAfterMsMarker } from "@earendil-works/pi-ai/utils/retry-hint";
8
- import { siwcRecoveryFromDiagnostic } from "@earendil-works/pi-ai/utils/siwc-errors";
8
+ import { isSiwcMissingResponsesScope, siwcRecoveryFromDiagnostic } from "@earendil-works/pi-ai/utils/siwc-errors";
9
9
  import { rateLimitModelFamily } from "./model-scope.js";
10
10
  import { usageLimitResetMs } from "./reset-time.js";
11
11
  import { isAccountUsageLimitText } from "./usage-limit.js";
@@ -320,6 +320,10 @@ export function classifyCredentialFailure(error, context = {}) {
320
320
  case "account_disabled":
321
321
  return { kind: "failover", block: { reason: "account_disabled" } };
322
322
  case "auth":
323
+ // An account without Responses access is not a rejected sign-in: a re-login cannot clear it, so
324
+ // the turn fails with the provider's message and the slot stays as it was (senpi#6643).
325
+ if (isSiwcMissingResponsesScope(text))
326
+ return { kind: "fail_request" };
323
327
  return { kind: "failover", block: { reason: "auth_error" } };
324
328
  case "request":
325
329
  return { kind: "fail_request" };
@@ -1,4 +1,10 @@
1
1
  import type { ContentBlockParam } from "./sdk-boundary.ts";
2
+ /**
3
+ * Claude Code runs a user text block that starts with `/` as one of its own slash commands. Tool output is
4
+ * untrusted text, so every non-empty text block appended from `from` on gets a marker first, whatever its first
5
+ * character is (invisible characters such as a zero-width space or a BOM included).
6
+ */
7
+ export declare function neutralizeToolResultText(blocks: ContentBlockParam[], from: number): void;
2
8
  export declare function appendSdkContentBlocks(blocks: ContentBlockParam[], content: string | readonly unknown[]): boolean;
3
9
  export declare function isSdkImageMediaType(value: string): boolean;
4
10
  //# sourceMappingURL=content-blocks.d.ts.map
@@ -1,4 +1,18 @@
1
1
  const IMAGE_MEDIA_TYPES = ["image/jpeg", "image/png", "image/gif", "image/webp"];
2
+ const TOOL_OUTPUT_MARKER = "[tool output] ";
3
+ /**
4
+ * Claude Code runs a user text block that starts with `/` as one of its own slash commands. Tool output is
5
+ * untrusted text, so every non-empty text block appended from `from` on gets a marker first, whatever its first
6
+ * character is (invisible characters such as a zero-width space or a BOM included).
7
+ */
8
+ export function neutralizeToolResultText(blocks, from) {
9
+ for (let index = from; index < blocks.length; index++) {
10
+ const block = blocks[index];
11
+ if (block?.type === "text" && block.text.length > 0) {
12
+ blocks[index] = { ...block, text: `${TOOL_OUTPUT_MARKER}${block.text}` };
13
+ }
14
+ }
15
+ }
2
16
  export function appendSdkContentBlocks(blocks, content) {
3
17
  if (typeof content === "string") {
4
18
  if (content.length > 0)
@@ -1,5 +1,5 @@
1
1
  import { replayHistoryImages } from "./cold-seed-images.js";
2
- import { appendSdkContentBlocks } from "./content-blocks.js";
2
+ import { appendSdkContentBlocks, neutralizeToolResultText } from "./content-blocks.js";
3
3
  import { mapPiToolNameToSdk } from "./tools.js";
4
4
  export { mapPiToolNameToSdk } from "./tools.js";
5
5
  export function contentToText(content, customToolNameToSdk) {
@@ -86,8 +86,10 @@ export function buildPromptBlocks(context, customToolNameToSdk, toolWatchNote, o
86
86
  if (message.role === "configurationUpdate" || message.role === "system")
87
87
  continue;
88
88
  pushPrefix(`TOOL RESULT (historical ${mapPiToolNameToSdk(message.toolName, customToolNameToSdk)}, id=${message.toolCallId}):`);
89
+ const toolResultStart = blocks.length;
89
90
  if (!appendContentBlocks(blocks, replayedImages.history.get(index) ?? message.content))
90
91
  pushText("(see attached image)");
92
+ neutralizeToolResultText(blocks, toolResultStart);
91
93
  }
92
94
  if (options.cacheBreakpoint !== undefined)
93
95
  markCacheBreakpoint(blocks, historyStart, options.cacheBreakpoint);
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { appendSdkContentBlocks } from "./content-blocks.js";
2
+ import { appendSdkContentBlocks, neutralizeToolResultText } from "./content-blocks.js";
3
3
  import { longContextAvailable } from "./long-context.js";
4
4
  import { imageNeutralContent } from "./sent-image-slots.js";
5
5
  import { HOST_TOOL_POLICY_FINGERPRINT, mapPiToolNameToSdk } from "./tools.js";
@@ -150,7 +150,10 @@ export function buildDeltaPromptBlocks(messages, customToolNameToSdk) {
150
150
  text: `Tool result (${mapPiToolNameToSdk(message.toolName, customToolNameToSdk)}, id=${message.toolCallId}):\n`,
151
151
  });
152
152
  }
153
+ const contentStart = blocks.length;
153
154
  appendContent(blocks, message.content);
155
+ if (message.role === "toolResult")
156
+ neutralizeToolResultText(blocks, contentStart);
154
157
  }
155
158
  return blocks;
156
159
  }
@@ -1,4 +1,5 @@
1
1
  import { SettingsManager } from "../../../settings-manager.js";
2
+ import { combinedToolCallSignal } from "../../tool-call-signal.js";
2
3
  import { extractPatchedPaths } from "../gpt-apply-patch/index.js";
3
4
  import { decideAuto } from "./auto-policy.js";
4
5
  import { createCellDecision, registerCellAuthorizer, updateCellEnforcement } from "./cell-decision.js";
@@ -243,7 +244,11 @@ export default function permissionSystemExtension(pi) {
243
244
  followPresetFlag(ctx.cwd, ctx.agentDir);
244
245
  return { service, parsers: parserRegistry, preset: activePreset, setupError };
245
246
  }, (event, ctx, signal) => authorizeToolCall(event, ctx, signal));
246
- const authorizeToolCall = async (event, ctx, signal) => {
247
+ const authorizeToolCall = async (event, ctx, dispatchSignal) => {
248
+ // A `tool_call` hook gets no signal argument, so its prompt ends with the turn: an abort releases a prompt
249
+ // nobody answers (a child's dialog forwarded to a host that never shows it), senpi#6670. The dispatch (call)
250
+ // signal does not replace the context's: the prompt runs under their union so a turn abort also ends it (senpi#6679).
251
+ const signal = combinedToolCallSignal(dispatchSignal, ctx.signal);
247
252
  attachWithoutSession(ctx);
248
253
  followPresetFlag(ctx.cwd, ctx.agentDir);
249
254
  if (setupError !== null) {