@code-yeongyu/senpi 2026.11.6-1 → 2026.11.6-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 (167) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/bundle/chunks/{chunk-5MWHZH2O.js → chunk-2FDW2LQL.js} +1 -1
  3. package/dist/bundle/chunks/{chunk-GG2JO3CL.js → chunk-4E7GDG4H.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-K5JLYACP.js → chunk-4GKU755E.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-437VLZQZ.js → chunk-7III44PV.js} +1 -1
  6. package/dist/bundle/chunks/chunk-7PSBD5KS.js +9 -0
  7. package/dist/bundle/chunks/{chunk-KFWHLVVH.js → chunk-C7OKUC7L.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-CX32K5KD.js → chunk-CF5OGBC4.js} +7 -7
  9. package/dist/bundle/chunks/{chunk-7TGZJH6Z.js → chunk-D5MRJWUK.js} +40 -39
  10. package/dist/bundle/chunks/{chunk-E6L5VZSM.js → chunk-DSWDJ7HT.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-6NMTFURP.js → chunk-ECW7VBMB.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-2CSLJLM6.js → chunk-GKAYPJ4E.js} +2 -2
  13. package/dist/bundle/chunks/{chunk-KCGUUIUS.js → chunk-GNSMNSL7.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-V3JSQ3PG.js → chunk-GSKCWXXG.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-USKWGPA6.js → chunk-GTJJ73DE.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-HHSYTDKO.js → chunk-HLM46XEB.js} +2 -2
  17. package/dist/bundle/chunks/{chunk-A4F4J2KH.js → chunk-I3PHVJAS.js} +2 -2
  18. package/dist/bundle/chunks/{chunk-LAMRXFHZ.js → chunk-LNPAT22L.js} +1 -1
  19. package/dist/bundle/chunks/chunk-NH7SYIGN.js +2 -0
  20. package/dist/bundle/chunks/{chunk-ZIIDIVTG.js → chunk-R2Z7CX77.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-32I42CEY.js → chunk-RQ6CHXQ2.js} +1 -1
  22. package/dist/bundle/chunks/chunk-SJI6UB23.js +2 -0
  23. package/dist/bundle/chunks/{chunk-KUIEHAPR.js → chunk-T2SMQPRE.js} +1 -1
  24. package/dist/bundle/chunks/{chunk-IPG434JT.js → chunk-TIPKAMSS.js} +1 -1
  25. package/dist/bundle/chunks/{chunk-RI5ABX7A.js → chunk-TMXRR3N7.js} +2 -2
  26. package/dist/bundle/chunks/chunk-VD7AKTGP.js +3 -0
  27. package/dist/bundle/chunks/{chunk-22JICYKS.js → chunk-WAOGBBZR.js} +1 -1
  28. package/dist/bundle/chunks/{chunk-6MHCFJDB.js → chunk-WGRKM3N6.js} +2 -2
  29. package/dist/bundle/chunks/{chunk-WF5R2VSP.js → chunk-X5ZVYNOL.js} +1 -1
  30. package/dist/bundle/chunks/{chunk-H2FBGZNP.js → chunk-XCMII2VQ.js} +2 -2
  31. package/dist/bundle/chunks/{chunk-5JUCTKYS.js → chunk-YK3ZZCHI.js} +1 -1
  32. package/dist/bundle/chunks/{cli-main-ZQBSX5H5.js → cli-main-T74YJGIF.js} +1 -1
  33. package/dist/bundle/chunks/{hand-entry-7U7354GG.js → hand-entry-AYRUGE2A.js} +2 -2
  34. package/dist/bundle/chunks/{headless-host-7LKTG76U.js → headless-host-ES74ZB6M.js} +1 -1
  35. package/dist/bundle/chunks/{help-fast-path-NLSWH2CA.js → help-fast-path-TMTGLOBG.js} +1 -1
  36. package/dist/bundle/chunks/{host-command-3YRFN35E.js → host-command-YRXZE4TV.js} +1 -1
  37. package/dist/bundle/chunks/{host-lifecycle-6XLVIECJ.js → host-lifecycle-6VCXMPDW.js} +1 -1
  38. package/dist/bundle/chunks/host-lifecycle.js +1 -1
  39. package/dist/bundle/chunks/{host-session-command-F7USXUZV.js → host-session-command-N7IN7ZDV.js} +1 -1
  40. package/dist/bundle/chunks/{interactive-mode-4RF3PUQ2.js → interactive-mode-B5SQDLH7.js} +1 -1
  41. package/dist/bundle/chunks/{list-tips-H6VGDFTS.js → list-tips-DU57HHKA.js} +1 -1
  42. package/dist/bundle/chunks/{main-G2SRZYQN.js → main-UQFVFCNY.js} +1 -1
  43. package/dist/bundle/chunks/{multi-session-host-RPN54GUC.js → multi-session-host-XSUJDHFZ.js} +5 -5
  44. package/dist/bundle/chunks/{openai-codex-responses-MJZKUS6I.js → openai-codex-responses-7V6LTDRU.js} +2 -2
  45. package/dist/bundle/chunks/{package-manager-cli-D2VFD463.js → package-manager-cli-GLUNPQJU.js} +1 -1
  46. package/dist/bundle/chunks/{role-37WVG42T.js → role-RRFFHZF5.js} +1 -1
  47. package/dist/bundle/chunks/{rotation-stream-QELPMM4N.js → rotation-stream-BN2YK2MC.js} +1 -1
  48. package/dist/bundle/chunks/{rpc-mode-P4D3DVYD.js → rpc-mode-JYN3E7P7.js} +1 -1
  49. package/dist/bundle/chunks/rpc-monitor-source-C6VQ3BC4.js +3 -0
  50. package/dist/bundle/chunks/{run-attached-tui-CGA6O5FR.js → run-attached-tui-W236SEOR.js} +1 -1
  51. package/dist/bundle/chunks/{schedule-command-XWSNOAGG.js → schedule-command-B2EJTBOE.js} +1 -1
  52. package/dist/bundle/chunks/session-control-endpoint-YIMLHGLG.js +3 -0
  53. package/dist/bundle/chunks/{session-picker-OA2AUVZG.js → session-picker-E6ZONUJB.js} +1 -1
  54. package/dist/bundle/chunks/session-worker.js +294 -292
  55. package/dist/bundle/cli.js +2 -2
  56. package/dist/bundle/host-supervisor.js +1 -1
  57. package/dist/bundle/index.js +1 -1
  58. package/dist/bundle/rpc-entry.js +1 -1
  59. package/dist/bundle/runtime-manifest.json +1 -1
  60. package/dist/cli/project-trust-headless.d.ts +13 -0
  61. package/dist/cli/project-trust-headless.js +35 -0
  62. package/dist/cli/project-trust.js +13 -50
  63. package/dist/cli/schedule-delivery.d.ts +4 -0
  64. package/dist/cli/schedule-delivery.js +6 -0
  65. package/dist/cli/schedule-runner.js +8 -0
  66. package/dist/cli/session-opening.d.ts +19 -0
  67. package/dist/cli/session-opening.js +47 -1
  68. package/dist/core/agent-session-runtime.d.ts +12 -0
  69. package/dist/core/agent-session-runtime.js +41 -0
  70. package/dist/core/agent-session.js +13 -22
  71. package/dist/core/egress/api-table.d.ts +121 -0
  72. package/dist/core/egress/api-table.js +41 -0
  73. package/dist/core/egress/classify.d.ts +19 -0
  74. package/dist/core/egress/classify.js +197 -0
  75. package/dist/core/egress/credential-fields.d.ts +18 -0
  76. package/dist/core/egress/credential-fields.js +83 -0
  77. package/dist/core/egress/custody-sidecar.d.ts +44 -0
  78. package/dist/core/egress/custody-sidecar.js +91 -0
  79. package/dist/core/egress/device-custody.d.ts +12 -0
  80. package/dist/core/egress/device-custody.js +82 -0
  81. package/dist/core/egress/endpoint.d.ts +33 -0
  82. package/dist/core/egress/endpoint.js +115 -0
  83. package/dist/core/execute-tool-on-host.d.ts +26 -0
  84. package/dist/core/execute-tool-on-host.js +96 -0
  85. package/dist/core/extensions/builtin/compaction/retained-message-safety.js +15 -0
  86. package/dist/core/extensions/builtin/goal/index.js +15 -3
  87. package/dist/core/extensions/builtin/goal/stop-pause.d.ts +2 -0
  88. package/dist/core/extensions/builtin/goal/stop-pause.js +5 -0
  89. package/dist/core/extensions/builtin/herdr/herdr-state.d.ts +10 -0
  90. package/dist/core/extensions/builtin/herdr/herdr-state.js +34 -6
  91. package/dist/core/extensions/builtin/herdr/index.js +6 -2
  92. package/dist/core/extensions/builtin/mcp/service.d.ts +9 -1
  93. package/dist/core/extensions/builtin/mcp/service.js +32 -1
  94. package/dist/core/extensions/builtin/terminal/rpc-monitor-remote.d.ts +43 -0
  95. package/dist/core/extensions/builtin/terminal/rpc-monitor-remote.js +158 -0
  96. package/dist/core/extensions/builtin/terminal/rpc-monitor-render.d.ts +2 -0
  97. package/dist/core/extensions/builtin/terminal/rpc-monitor-render.js +4 -0
  98. package/dist/core/extensions/builtin/terminal/rpc-monitor-source.d.ts +5 -2
  99. package/dist/core/extensions/builtin/terminal/rpc-monitor-source.js +19 -4
  100. package/dist/core/extensions/builtin/terminal/rpc-monitor-targets.d.ts +4 -0
  101. package/dist/core/extensions/builtin/terminal/rpc-monitor-targets.js +15 -0
  102. package/dist/core/extensions/builtin/terminal/rpc-monitor-watch.d.ts +10 -0
  103. package/dist/core/extensions/builtin/terminal/rpc-monitor-watch.js +28 -2
  104. package/dist/core/extensions/builtin/terminal/rpc-remote-source.d.ts +59 -0
  105. package/dist/core/extensions/builtin/terminal/rpc-remote-source.js +15 -0
  106. package/dist/core/extensions/builtin/terminal/terminal-manifest-model.d.ts +5 -0
  107. package/dist/core/extensions/builtin/terminal/terminal-manifest-parse.js +14 -1
  108. package/dist/core/extensions/builtin/terminal/tools/monitor-rpc.js +8 -1
  109. package/dist/core/extensions/loader.js +8 -0
  110. package/dist/core/extensions/types.d.ts +6 -0
  111. package/dist/core/foreign-session-holders.d.ts +1 -1
  112. package/dist/core/foreign-session-holders.js +3 -3
  113. package/dist/core/session-import/jsonl-import.d.ts +8 -12
  114. package/dist/core/session-import/jsonl-import.js +99 -40
  115. package/dist/core/session-manager.d.ts +2 -0
  116. package/dist/core/session-manager.js +7 -2
  117. package/dist/core/session-store/durable-binding.d.ts +2 -0
  118. package/dist/core/session-store/durable-binding.js +26 -4
  119. package/dist/core/settings-manager.d.ts +20 -0
  120. package/dist/core/settings-manager.js +51 -0
  121. package/dist/core/trust-manager.d.ts +1 -18
  122. package/dist/core/trust-manager.js +3 -124
  123. package/dist/core/trust-requiring-resources.d.ts +21 -0
  124. package/dist/core/trust-requiring-resources.js +189 -0
  125. package/dist/index.d.ts +1 -0
  126. package/dist/index.js +1 -0
  127. package/dist/main.js +42 -12
  128. package/dist/modes/interactive/interactive-mode.js +2 -2
  129. package/dist/modes/interactive/session-control-commands.js +2 -0
  130. package/dist/modes/rpc/connection-handler.js +17 -0
  131. package/dist/modes/rpc/connection-question-bridge.js +7 -4
  132. package/dist/modes/rpc/effect-commands.d.ts +24 -0
  133. package/dist/modes/rpc/host-boot-extensions.d.ts +4 -0
  134. package/dist/modes/rpc/host-boot-extensions.js +17 -0
  135. package/dist/modes/rpc/host-lifecycle-shutdown.js +11 -2
  136. package/dist/modes/rpc/loopless-runtime-settings.js +5 -1
  137. package/dist/modes/rpc/method-classes-schema-session.d.ts +33 -0
  138. package/dist/modes/rpc/method-classes-schema-session.js +4 -0
  139. package/dist/modes/rpc/method-classes-schema.d.ts +33 -0
  140. package/dist/modes/rpc/method-classes.d.ts +4 -0
  141. package/dist/modes/rpc/method-classes.js +7 -0
  142. package/dist/modes/rpc/multi-session-host.d.ts +2 -0
  143. package/dist/modes/rpc/multi-session-host.js +7 -2
  144. package/dist/modes/rpc/project-workspace-commands.d.ts +60 -0
  145. package/dist/modes/rpc/project-workspace-commands.js +145 -0
  146. package/dist/modes/rpc/rpc-error-types.d.ts +11 -1
  147. package/dist/modes/rpc/rpc-error-types.js +10 -0
  148. package/dist/modes/rpc/rpc-input-validation.js +4 -0
  149. package/dist/modes/rpc/rpc-mutation-response-types.d.ts +13 -0
  150. package/dist/modes/rpc/rpc-read-response-types.d.ts +13 -0
  151. package/dist/modes/rpc/rpc-session-command-types.d.ts +15 -0
  152. package/dist/modes/rpc/session-attachment-gate.js +2 -0
  153. package/dist/modes/rpc/session-command-activity.js +2 -0
  154. package/docs/engine-socket/fixtures/admission-routes/h-legacy.json +1 -1
  155. package/docs/engine-socket/fixtures/rpc-inbound-samples.json +41 -2
  156. package/docs/extensions.md +17 -1
  157. package/docs/rpc.md +121 -4
  158. package/docs/terminal-tools.md +8 -0
  159. package/native/socket-secret/prebuilds/win32-arm64/senpi_socket_secret.win32-arm64.node +0 -0
  160. package/native/socket-secret/prebuilds/win32-x64/senpi_socket_secret.win32-x64.node +0 -0
  161. package/package.json +6 -6
  162. package/dist/bundle/chunks/chunk-FUQJK2TU.js +0 -2
  163. package/dist/bundle/chunks/chunk-POZMRM6V.js +0 -2
  164. package/dist/bundle/chunks/chunk-XBG63MJZ.js +0 -8
  165. package/dist/bundle/chunks/chunk-YP47G4YP.js +0 -3
  166. package/dist/bundle/chunks/rpc-monitor-source-KKN2UP4T.js +0 -3
  167. package/dist/bundle/chunks/session-control-endpoint-OST7WAKP.js +0 -3
@@ -0,0 +1,3 @@
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{require_proper_lockfile}from"./chunk-GZVCRV7I.js";import{CONFIG_DIR_NAME,canonicalizePath,canonicalizePathStrict,findNodePackageDir,getDocsPath,getExamplesPath,getExportTemplateDir,getInstallPackageDir,getInteractiveAssetsDir,getPackageDir,getThemesDir,isBunBinary,resolvePath,stripBom}from"./chunk-SODMQEHO.js";import{__toESM}from"./chunk-IKOFCODM.js";import{existsSync as existsSync2,readFileSync}from"node:fs";import{access,readFile}from"node:fs/promises";import{homedir}from"node:os";import{dirname as dirname3,join as join3,sep as sep2}from"node:path";import{existsSync}from"node:fs";import{createRequire}from"node:module";import{dirname as dirname2,join as join2,resolve,sep}from"node:path";import{fileURLToPath as fileURLToPath2}from"node:url";import{dirname,join}from"node:path";import{fileURLToPath}from"node:url";function imagegenSkillPath(baseDir=dirname(fileURLToPath(import.meta.url))){return join(baseDir,"skill","SKILL.md")}var moduleRequire=createRequire(import.meta.url),runningFromSource=fileURLToPath2(import.meta.url).includes(`${sep}src${sep}core${sep}`),bundledBuiltinExtensions=[{id:"codemode",resolvePackage:()=>resolveBundledPackageJson("@code-yeongyu/senpi-codemode/package.json","senpi-codemode/package.json",join2("node_modules","@code-yeongyu","senpi-codemode","package.json"))}];function resolveBundledPackageJson(packageSpecifier,workspaceRelativePath,binaryRelativePath){let packageRoot=getPackageDir(),workspacePath=resolve(packageRoot,"..",workspaceRelativePath);if(runningFromSource&&existsSync(workspacePath))return workspacePath;let binaryPath=resolve(packageRoot,binaryRelativePath);if(isBunBinary&&existsSync(binaryPath))return binaryPath;try{return moduleRequire.resolve(packageSpecifier)}catch(error){if(existsSync(workspacePath))return workspacePath;throw error}}function getBundledResourceRoots(){let roots=[getThemesDir(),getExportTemplateDir(),getInteractiveAssetsDir(),getDocsPath(),getExamplesPath(),dirname2(imagegenSkillPath())];!isBunBinary&&!runningFromSource?roots.push(getPackageDir(),getInstallPackageDir(),findNodePackageDir(dirname2(fileURLToPath2(import.meta.url)))):isBunBinary&&roots.push(dirname2(fileURLToPath2(import.meta.url)));for(let extension of bundledBuiltinExtensions)try{roots.push(dirname2(extension.resolvePackage()))}catch(error){if(!(error instanceof Error&&"code"in error&&error.code==="MODULE_NOT_FOUND"))throw error}return roots}var TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES=["settings.json","mcp.json","extensions","skills","prompts","themes","SYSTEM.md","APPEND_SYSTEM.md"],LEGACY_PROJECT_CONFIG_DIR_NAME=".pi";function*exists(path){return(yield{kind:"exists",path})===!0}function*readText(path){let text=yield{kind:"read",path};return typeof text=="string"?text:void 0}function parseJson(text){try{return{ok:!0,value:JSON.parse(stripBom(text))}}catch{return{ok:!1}}}function valueAtPath(value,path){let current=value;for(let key of path.split(".")){if(typeof current!="object"||current===null)return;current=Reflect.get(current,key)}return current}function*codemodeExecutableSettings(){let codemode=bundledBuiltinExtensions.find(extension=>extension.id==="codemode"),packageJson;try{packageJson=codemode?.resolvePackage()}catch{return}if(packageJson===void 0)return;let text=yield*readText(join3(dirname3(packageJson),"src","config","executable-settings.json")),list=text===void 0?{ok:!1}:parseJson(text);if(!list.ok||typeof list.value!="object"||list.value===null)return;let paths=Reflect.get(list.value,"projectExecutableSettings");return Array.isArray(paths)&&paths.every(entry=>typeof entry=="string")?paths:void 0}function*projectCodemodeNamesExecutable(configDir){let path=join3(configDir,"codemode.json");if(!(yield*exists(path)))return!1;let executableSettings=yield*codemodeExecutableSettings();if(executableSettings===void 0)return!0;let text=yield*readText(path),parsed=text===void 0?{ok:!1}:parseJson(text);return parsed.ok?executableSettings.some(settingPath=>valueAtPath(parsed.value,settingPath)!==void 0):!0}function isHomeOrAboveDir(dir,homeDir){return dir===homeDir||homeDir.startsWith(dir.endsWith(sep2)?dir:`${dir}${sep2}`)}function*findGitRepoRoot(dir){let currentDir=dir;for(;!(yield*exists(join3(currentDir,".git")));){let parentDir=dirname3(currentDir);if(parentDir===currentDir)return;currentDir=parentDir}return currentDir}function homeDirectory(){return canonicalizePath(resolvePath(process.env.HOME||homedir()))}function*agentsSkillDirs(cwd){let homeDir=homeDirectory(),startDir=resolvePath(cwd),gitRepoRoot=yield*findGitRepoRoot(startDir),dirs=[],currentDir=startDir;for(;!isHomeOrAboveDir(canonicalizePath(currentDir),homeDir)&&(dirs.push(join3(currentDir,".agents","skills")),currentDir!==gitRepoRoot);){let parentDir=dirname3(currentDir);if(parentDir===currentDir)break;currentDir=parentDir}return dirs}function*trustRequiringResources(cwd){let homeDir=homeDirectory(),currentDir=canonicalizePath(resolvePath(cwd));if(!isHomeOrAboveDir(currentDir,homeDir)){for(let configDir of[join3(currentDir,CONFIG_DIR_NAME),join3(currentDir,LEGACY_PROJECT_CONFIG_DIR_NAME)])for(let entry of TRUST_REQUIRING_PROJECT_CONFIG_RESOURCES)if(yield*exists(join3(configDir,entry)))return!0;if(yield*projectCodemodeNamesExecutable(join3(currentDir,CONFIG_DIR_NAME)))return!0}for(let dir of yield*agentsSkillDirs(cwd))if(yield*exists(dir))return!0;return!1}function answerSync(probe){if(probe.kind==="exists")return existsSync2(probe.path);try{return readFileSync(probe.path,"utf8")}catch{return}}async function answerAsync(probe){return probe.kind==="exists"?access(probe.path).then(()=>!0,()=>!1):readFile(probe.path,"utf8").catch(()=>{})}function runSync(walk){let step=walk.next();for(;!step.done;)step=walk.next(answerSync(step.value));return step.value}async function runAsync(walk){let step=walk.next();for(;!step.done;)step=walk.next(await answerAsync(step.value));return step.value}function projectAgentsSkillDirs(cwd){return runSync(agentsSkillDirs(cwd))}function hasTrustRequiringProjectResources(cwd){return runSync(trustRequiringResources(cwd))}function hasTrustRequiringProjectResourcesAsync(cwd){return runAsync(trustRequiringResources(cwd))}var import_proper_lockfile=__toESM(require_proper_lockfile(),1);import{existsSync as existsSync3,mkdirSync,readFileSync as readFileSync2,writeFileSync}from"node:fs";import{readFile as readFile2,realpath,stat}from"node:fs/promises";import{basename,dirname as dirname4,join as join4,relative,resolve as resolve2}from"node:path";function normalizeCwd(cwd){let resolved=resolvePath(cwd);try{return canonicalizePathStrict(resolved)}catch{return resolved}}function findNearestTrustEntry(data,cwd){let currentDir=normalizeCwd(cwd);for(;;){let value=data[currentDir];if(value===!0||value===!1)return{path:currentDir,decision:value};let parentDir=dirname4(currentDir);if(parentDir===currentDir)return null;currentDir=parentDir}}function getProjectTrustParentPath(cwd){let trustPath=normalizeCwd(cwd),parentDir=dirname4(trustPath);return parentDir===trustPath?void 0:parentDir}function getProjectTrustOptions(cwd,options){let trustPath=normalizeCwd(cwd),trustOptions=[{label:"Trust",trusted:!0,updates:[{path:trustPath,decision:!0}],savedPath:trustPath}],parentPath=getProjectTrustParentPath(cwd);return parentPath!==void 0&&trustOptions.push({label:`Trust parent folder (${parentPath})`,trusted:!0,updates:[{path:parentPath,decision:!0},{path:trustPath,decision:null}],savedPath:parentPath}),options?.includeSessionOnly&&trustOptions.push({label:"Trust (this session only)",trusted:!0,updates:[]}),trustOptions.push({label:"Do not trust",trusted:!1,updates:[{path:trustPath,decision:!1}],savedPath:trustPath}),options?.includeSessionOnly&&trustOptions.push({label:"Do not trust (this session only)",trusted:!1,updates:[]}),trustOptions}function readTrustFile(path){if(!existsSync3(path))return{};let parsed;try{parsed=JSON.parse(stripBom(readFileSync2(path,"utf-8")))}catch(error){let message=error instanceof Error?error.message:String(error);throw new Error(`Failed to read trust store ${path}: ${message}`)}if(typeof parsed!="object"||parsed===null||Array.isArray(parsed))throw new Error(`Invalid trust store ${path}: expected an object`);let data={};for(let[key,value]of Object.entries(parsed)){if(value!==!0&&value!==!1&&value!==null)throw new Error(`Invalid trust store ${path}: value for ${JSON.stringify(key)} must be true, false, or null`);data[key]=value}return data}function writeTrustFile(path,data){let sorted={};for(let key of Object.keys(data).sort()){let value=data[key];(value===!0||value===!1||value===null)&&(sorted[key]=value)}mkdirSync(dirname4(path),{recursive:!0}),writeFileSync(path,`${JSON.stringify(sorted,null,2)}
3
+ `,"utf-8")}function acquireTrustLockSync(path){let trustDir=dirname4(path);mkdirSync(trustDir,{recursive:!0});let maxAttempts=10,delayMs=20,lastError;for(let attempt=1;attempt<=maxAttempts;attempt++)try{return import_proper_lockfile.default.lockSync(trustDir,{realpath:!1,lockfilePath:`${path}.lock`})}catch(error){if((typeof error=="object"&&error!==null&&"code"in error?String(error.code):void 0)!=="ELOCKED"||attempt===maxAttempts)throw error;lastError=error;let start=Date.now();for(;Date.now()-start<delayMs;);}throw lastError instanceof Error?lastError:new Error("Failed to acquire trust store lock")}function withTrustFileLock(path,fn){let release=acquireTrustLockSync(path);try{return fn()}finally{release()}}var ProjectTrustStore=class{constructor(agentDir){this.trustPath=join4(resolvePath(agentDir),"trust.json")}get(cwd){return this.getEntry(cwd)?.decision??null}getEntry(cwd){return withTrustFileLock(this.trustPath,()=>{let data=readTrustFile(this.trustPath);return findNearestTrustEntry(data,cwd)})}set(cwd,decision){this.setMany([{path:cwd,decision}])}setMany(decisions){withTrustFileLock(this.trustPath,()=>{let data=readTrustFile(this.trustPath);for(let{path,decision}of decisions){let key=normalizeCwd(path);decision===null?delete data[key]:data[key]=decision}writeTrustFile(this.trustPath,data)})}},GITDIR_POINTER=/^gitdir:\s*(.+)$/;async function readFirstLine(path){try{return(await readFile2(path,"utf-8")).split(/\r?\n/,1)[0]?.trim()||void 0}catch{return}}async function realPathOf(path){try{return await realpath(path)}catch{return}}async function entryKind(path){try{let stats=await stat(path);return stats.isDirectory()?"directory":stats.isFile()?"file":void 0}catch{return}}async function linkedWorktreeMainCheckoutDir(cwd){let dir=await realPathOf(resolvePath(cwd))??resolvePath(cwd),checkoutRoot=dir,markerKind=await entryKind(join4(checkoutRoot,".git"));for(;markerKind===void 0;){let parentDir=dirname4(checkoutRoot);if(parentDir===checkoutRoot)return;checkoutRoot=parentDir,markerKind=await entryKind(join4(checkoutRoot,".git"))}if(markerKind!=="file")return;let marker=join4(checkoutRoot,".git"),adminTarget=GITDIR_POINTER.exec(await readFirstLine(marker)??"")?.[1]?.trim();if(!adminTarget)return;let adminDir=await realPathOf(resolve2(checkoutRoot,adminTarget));if(adminDir===void 0)return;let commonDirPointer=await readFirstLine(join4(adminDir,"commondir")),backPointer=await readFirstLine(join4(adminDir,"gitdir"));if(commonDirPointer===void 0||backPointer===void 0)return;let markerRealPath=await realPathOf(marker);if(markerRealPath===void 0||await realPathOf(resolve2(adminDir,backPointer))!==markerRealPath)return;let commonDir=await realPathOf(resolve2(adminDir,commonDirPointer));if(commonDir===void 0||basename(commonDir)!==".git"||dirname4(adminDir)!==join4(commonDir,"worktrees"))return;let mainCheckout=dirname4(commonDir),mainMarker=join4(mainCheckout,".git");if(!(await entryKind(mainMarker)!=="directory"||await realPathOf(mainMarker)!==commonDir))return join4(mainCheckout,relative(checkoutRoot,dir))}async function getSavedProjectTrust(store,cwd){let own=store.get(cwd);if(own!==null)return own;let mainCheckoutDir=await linkedWorktreeMainCheckoutDir(cwd);return mainCheckoutDir===void 0?null:store.get(mainCheckoutDir)}export{imagegenSkillPath,bundledBuiltinExtensions,getBundledResourceRoots,projectAgentsSkillDirs,hasTrustRequiringProjectResources,hasTrustRequiringProjectResourcesAsync,getProjectTrustOptions,ProjectTrustStore,getSavedProjectTrust};
@@ -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{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunk-YP47G4YP.js";import{parseArgs,printHelp}from"./chunk-54YTJCYZ.js";import{CONFIG_DIR_NAME,DISPLAY_VERSION,getAgentDir}from"./chunk-SODMQEHO.js";import{createHash}from"node:crypto";import{existsSync,mkdirSync,readFileSync,renameSync,rmSync,statSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join}from"node:path";var CACHE_FILE_VERSION=1,MAX_CACHED_SCOPES=8;function cachePath(agentDir){return join(agentDir,"cache","help-flags.json")}function scopeKey(scope){let material=[scope.cwd,scope.noExtensions?"no-extensions":"extensions",scope.projectTrusted?"trusted":"untrusted",...scope.cliExtensionPaths].join("\0");return createHash("sha256").update(material).digest("hex").slice(0,32)}function stamp(path){try{let stats=statSync(path);return stats.isDirectory()?`d:${stats.mtimeMs}`:`f:${stats.mtimeMs}:${stats.size}`}catch{return"absent"}}function discoveryInputs(scope,extensionPaths){let paths=new Set([join(scope.agentDir,"settings.json"),join(scope.agentDir,"extensions"),join(scope.agentDir,"trust.json"),join(scope.cwd,CONFIG_DIR_NAME,"settings.json"),join(scope.cwd,CONFIG_DIR_NAME,"extensions")]);for(let path of extensionPaths)isAbsolute(path)&&(paths.add(path),paths.add(dirname(path)));for(let path of scope.cliExtensionPaths)isAbsolute(path)&&paths.add(path);return[...paths].sort()}function readCacheFile(agentDir){try{let parsed=JSON.parse(readFileSync(cachePath(agentDir),"utf8"));return parsed.version!==CACHE_FILE_VERSION||typeof parsed.scopes!="object"||parsed.scopes===null?void 0:parsed}catch{return}}function readHelpFlagsCache(scope){let cached=readCacheFile(scope.agentDir)?.scopes[scopeKey(scope)];if(!(!cached||cached.appVersion!==DISPLAY_VERSION||!Array.isArray(cached.inputs))){for(let input of cached.inputs)if(stamp(input.path)!==input.state)return;return[...cached.flags]}}function writeHelpFlagsCache(options){let{scope,flags,extensionPaths}=options;try{let scopes={...readCacheFile(scope.agentDir)?.scopes??{}};scopes[scopeKey(scope)]={writtenAt:Date.now(),appVersion:DISPLAY_VERSION,inputs:discoveryInputs(scope,extensionPaths).map(path=>({path,state:stamp(path)})),flags:[...flags]};let keptEntries=Object.entries(scopes).sort(([,left],[,right])=>right.writtenAt-left.writtenAt).slice(0,MAX_CACHED_SCOPES),file={version:CACHE_FILE_VERSION,scopes:Object.fromEntries(keptEntries)},target=cachePath(scope.agentDir);mkdirSync(dirname(target),{recursive:!0});let temporary=`${target}.${process.pid}.tmp`;writeFileSync(temporary,JSON.stringify(file),{mode:384});try{renameSync(temporary,target)}catch(error){throw existsSync(temporary)&&rmSync(temporary,{force:!0}),error}}catch{return}}function isPlainHelpRequest(parsed){return parsed.help===!0&&parsed.print!==!0&&parsed.mode===void 0}function resolveHelpProjectTrust(parsed,cwd,agentDir){return parsed.projectTrustOverride!==void 0?parsed.projectTrustOverride:hasTrustRequiringProjectResources(cwd)?new ProjectTrustStore(agentDir).get(cwd)===!0:!0}function helpFlagsScope(parsed,cwd,agentDir,projectTrusted){return{cwd,agentDir,cliExtensionPaths:[...parsed.extensions??[]],noExtensions:parsed.noExtensions===!0,projectTrusted}}function tryPrintHelpWithoutEngine(argv){let parsed;try{parsed=parseArgs([...argv])}catch{return!1}if(!isPlainHelpRequest(parsed)||parsed.diagnostics.length>0)return!1;if(parsed.noExtensions===!0)return printHelp([]),!0;let flags;try{let cwd=process.cwd(),agentDir=getAgentDir();flags=readHelpFlagsCache(helpFlagsScope(parsed,cwd,agentDir,resolveHelpProjectTrust(parsed,cwd,agentDir)))}catch{return!1}return flags?(printHelp(flags),!0):!1}export{writeHelpFlagsCache,isPlainHelpRequest,resolveHelpProjectTrust,helpFlagsScope,tryPrintHelpWithoutEngine};
2
+ import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunk-VD7AKTGP.js";import{parseArgs,printHelp}from"./chunk-54YTJCYZ.js";import{CONFIG_DIR_NAME,DISPLAY_VERSION,getAgentDir}from"./chunk-SODMQEHO.js";import{createHash}from"node:crypto";import{existsSync,mkdirSync,readFileSync,renameSync,rmSync,statSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join}from"node:path";var CACHE_FILE_VERSION=1,MAX_CACHED_SCOPES=8;function cachePath(agentDir){return join(agentDir,"cache","help-flags.json")}function scopeKey(scope){let material=[scope.cwd,scope.noExtensions?"no-extensions":"extensions",scope.projectTrusted?"trusted":"untrusted",...scope.cliExtensionPaths].join("\0");return createHash("sha256").update(material).digest("hex").slice(0,32)}function stamp(path){try{let stats=statSync(path);return stats.isDirectory()?`d:${stats.mtimeMs}`:`f:${stats.mtimeMs}:${stats.size}`}catch{return"absent"}}function discoveryInputs(scope,extensionPaths){let paths=new Set([join(scope.agentDir,"settings.json"),join(scope.agentDir,"extensions"),join(scope.agentDir,"trust.json"),join(scope.cwd,CONFIG_DIR_NAME,"settings.json"),join(scope.cwd,CONFIG_DIR_NAME,"extensions")]);for(let path of extensionPaths)isAbsolute(path)&&(paths.add(path),paths.add(dirname(path)));for(let path of scope.cliExtensionPaths)isAbsolute(path)&&paths.add(path);return[...paths].sort()}function readCacheFile(agentDir){try{let parsed=JSON.parse(readFileSync(cachePath(agentDir),"utf8"));return parsed.version!==CACHE_FILE_VERSION||typeof parsed.scopes!="object"||parsed.scopes===null?void 0:parsed}catch{return}}function readHelpFlagsCache(scope){let cached=readCacheFile(scope.agentDir)?.scopes[scopeKey(scope)];if(!(!cached||cached.appVersion!==DISPLAY_VERSION||!Array.isArray(cached.inputs))){for(let input of cached.inputs)if(stamp(input.path)!==input.state)return;return[...cached.flags]}}function writeHelpFlagsCache(options){let{scope,flags,extensionPaths}=options;try{let scopes={...readCacheFile(scope.agentDir)?.scopes??{}};scopes[scopeKey(scope)]={writtenAt:Date.now(),appVersion:DISPLAY_VERSION,inputs:discoveryInputs(scope,extensionPaths).map(path=>({path,state:stamp(path)})),flags:[...flags]};let keptEntries=Object.entries(scopes).sort(([,left],[,right])=>right.writtenAt-left.writtenAt).slice(0,MAX_CACHED_SCOPES),file={version:CACHE_FILE_VERSION,scopes:Object.fromEntries(keptEntries)},target=cachePath(scope.agentDir);mkdirSync(dirname(target),{recursive:!0});let temporary=`${target}.${process.pid}.tmp`;writeFileSync(temporary,JSON.stringify(file),{mode:384});try{renameSync(temporary,target)}catch(error){throw existsSync(temporary)&&rmSync(temporary,{force:!0}),error}}catch{return}}function isPlainHelpRequest(parsed){return parsed.help===!0&&parsed.print!==!0&&parsed.mode===void 0}function resolveHelpProjectTrust(parsed,cwd,agentDir){return parsed.projectTrustOverride!==void 0?parsed.projectTrustOverride:hasTrustRequiringProjectResources(cwd)?new ProjectTrustStore(agentDir).get(cwd)===!0:!0}function helpFlagsScope(parsed,cwd,agentDir,projectTrusted){return{cwd,agentDir,cliExtensionPaths:[...parsed.extensions??[]],noExtensions:parsed.noExtensions===!0,projectTrusted}}function tryPrintHelpWithoutEngine(argv){let parsed;try{parsed=parseArgs([...argv])}catch{return!1}if(!isPlainHelpRequest(parsed)||parsed.diagnostics.length>0)return!1;if(parsed.noExtensions===!0)return printHelp([]),!0;let flags;try{let cwd=process.cwd(),agentDir=getAgentDir();flags=readHelpFlagsCache(helpFlagsScope(parsed,cwd,agentDir,resolveHelpProjectTrust(parsed,cwd,agentDir)))}catch{return!1}return flags?(printHelp(flags),!0):!1}export{writeHelpFlagsCache,isPlainHelpRequest,resolveHelpProjectTrust,helpFlagsScope,tryPrintHelpWithoutEngine};