@bastani/atomic 0.9.28-alpha.2 → 0.9.28-alpha.3

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 (158) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/native-client-licenses/NOTICE +2 -0
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/web-access/package.json +1 -1
  7. package/dist/builtin/workflows/CHANGELOG.md +11 -0
  8. package/dist/builtin/workflows/package.json +1 -1
  9. package/dist/builtin/workflows/src/extension/index.bundle.mjs +14733 -14704
  10. package/dist/cli/args.d.ts.map +1 -1
  11. package/dist/cli/args.js +8 -1
  12. package/dist/cli/args.js.map +1 -1
  13. package/dist/config.d.ts +2 -1
  14. package/dist/config.d.ts.map +1 -1
  15. package/dist/config.js +4 -2
  16. package/dist/config.js.map +1 -1
  17. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  18. package/dist/core/agent-session-extension-bindings.js +3 -2
  19. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  20. package/dist/core/agent-session-methods.d.ts +1 -0
  21. package/dist/core/agent-session-methods.d.ts.map +1 -1
  22. package/dist/core/agent-session-methods.js.map +1 -1
  23. package/dist/core/agent-session-tool-registry.js.map +1 -1
  24. package/dist/core/agent-session-types.d.ts +1 -0
  25. package/dist/core/agent-session-types.d.ts.map +1 -1
  26. package/dist/core/agent-session-types.js.map +1 -1
  27. package/dist/core/agent-session.d.ts +1 -0
  28. package/dist/core/agent-session.d.ts.map +1 -1
  29. package/dist/core/agent-session.js +6 -1
  30. package/dist/core/agent-session.js.map +1 -1
  31. package/dist/core/bash-executor.d.ts.map +1 -1
  32. package/dist/core/bash-executor.js +22 -4
  33. package/dist/core/bash-executor.js.map +1 -1
  34. package/dist/core/child-session-options.d.ts.map +1 -1
  35. package/dist/core/child-session-options.js +17 -2
  36. package/dist/core/child-session-options.js.map +1 -1
  37. package/dist/core/extensions/loader-virtual-modules.d.ts +3 -4
  38. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  39. package/dist/core/extensions/loader-virtual-modules.js +14 -9
  40. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  41. package/dist/core/extensions/tool-events.d.ts +1 -1
  42. package/dist/core/extensions/tool-events.js.map +1 -1
  43. package/dist/core/extensions/ts-source-specifiers.d.ts +18 -0
  44. package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -0
  45. package/dist/core/extensions/ts-source-specifiers.js +142 -0
  46. package/dist/core/extensions/ts-source-specifiers.js.map +1 -0
  47. package/dist/core/sdk-exports.d.ts +2 -2
  48. package/dist/core/sdk-exports.js.map +1 -1
  49. package/dist/core/sdk-types.d.ts +3 -0
  50. package/dist/core/sdk-types.d.ts.map +1 -1
  51. package/dist/core/sdk-types.js.map +1 -1
  52. package/dist/core/sdk.d.ts.map +1 -1
  53. package/dist/core/sdk.js +17 -8
  54. package/dist/core/sdk.js.map +1 -1
  55. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  56. package/dist/core/settings-manager-core.js.map +1 -1
  57. package/dist/core/settings-merge.d.ts +3 -0
  58. package/dist/core/settings-merge.d.ts.map +1 -1
  59. package/dist/core/settings-merge.js +18 -4
  60. package/dist/core/settings-merge.js.map +1 -1
  61. package/dist/core/settings-storage.js.map +1 -1
  62. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  63. package/dist/extensions/codemode/execute.js +14 -1
  64. package/dist/extensions/codemode/execute.js.map +1 -1
  65. package/dist/extensions/codemode/tool.js +2 -2
  66. package/dist/extensions/codemode/tool.js.map +1 -1
  67. package/dist/extensions/llama/provider.d.ts.map +1 -1
  68. package/dist/extensions/llama/provider.js +19 -8
  69. package/dist/extensions/llama/provider.js.map +1 -1
  70. package/dist/extensions/mcp/cli.js +18 -24
  71. package/dist/extensions/mcp/cli.js.map +1 -1
  72. package/dist/extensions/mcp/client/auth-provider.d.ts +4 -0
  73. package/dist/extensions/mcp/client/auth-provider.d.ts.map +1 -1
  74. package/dist/extensions/mcp/client/auth-provider.js.map +1 -1
  75. package/dist/extensions/mcp/client/oauth/discovery.d.ts +3 -0
  76. package/dist/extensions/mcp/client/oauth/discovery.d.ts.map +1 -1
  77. package/dist/extensions/mcp/client/oauth/discovery.js +8 -5
  78. package/dist/extensions/mcp/client/oauth/discovery.js.map +1 -1
  79. package/dist/extensions/mcp/client/oauth/flow.d.ts +4 -0
  80. package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
  81. package/dist/extensions/mcp/client/oauth/flow.js +12 -2
  82. package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
  83. package/dist/extensions/mcp/client/transports/streamable-http.d.ts +3 -0
  84. package/dist/extensions/mcp/client/transports/streamable-http.d.ts.map +1 -1
  85. package/dist/extensions/mcp/client/transports/streamable-http.js +17 -14
  86. package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
  87. package/dist/extensions/mcp/index.d.ts.map +1 -1
  88. package/dist/extensions/mcp/index.js +150 -72
  89. package/dist/extensions/mcp/index.js.map +1 -1
  90. package/dist/extensions/mcp/oauth.d.ts +5 -3
  91. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  92. package/dist/extensions/mcp/oauth.js +36 -10
  93. package/dist/extensions/mcp/oauth.js.map +1 -1
  94. package/dist/extensions/mcp/ui.d.ts +3 -3
  95. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  96. package/dist/extensions/mcp/ui.js +10 -2
  97. package/dist/extensions/mcp/ui.js.map +1 -1
  98. package/dist/index.d.ts +1 -1
  99. package/dist/index.js.map +1 -1
  100. package/dist/main-deferred-startup.d.ts +1 -0
  101. package/dist/main-deferred-startup.d.ts.map +1 -1
  102. package/dist/main-deferred-startup.js +9 -21
  103. package/dist/main-deferred-startup.js.map +1 -1
  104. package/dist/main.d.ts.map +1 -1
  105. package/dist/main.js +8 -6
  106. package/dist/main.js.map +1 -1
  107. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  108. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  109. package/dist/modes/interactive/interactive-input-handling.js +1 -47
  110. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  111. package/dist/modes/interactive/interactive-mode-base.d.ts +0 -1
  112. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  113. package/dist/modes/interactive/interactive-mode-base.js +0 -1
  114. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  115. package/dist/modes/interactive/interactive-mode-surface.d.ts +0 -1
  116. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  117. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  118. package/dist/modes/interactive/interactive-prompt-restore.d.ts.map +1 -1
  119. package/dist/modes/interactive/interactive-prompt-restore.js +0 -5
  120. package/dist/modes/interactive/interactive-prompt-restore.js.map +1 -1
  121. package/dist/modes/interactive/interactive-render-chat.js +0 -5
  122. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  123. package/dist/modes/rpc/rpc-client-process.d.ts +7 -0
  124. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  125. package/dist/modes/rpc/rpc-client-process.js +20 -3
  126. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  127. package/dist/modes/rpc/rpc-command-timeouts.d.ts.map +1 -1
  128. package/dist/modes/rpc/rpc-command-timeouts.js +1 -0
  129. package/dist/modes/rpc/rpc-command-timeouts.js.map +1 -1
  130. package/dist/utils/ansi.d.ts +8 -0
  131. package/dist/utils/ansi.d.ts.map +1 -1
  132. package/dist/utils/ansi.js +29 -10
  133. package/dist/utils/ansi.js.map +1 -1
  134. package/dist/utils/clipboard.d.ts.map +1 -1
  135. package/dist/utils/clipboard.js +13 -3
  136. package/dist/utils/clipboard.js.map +1 -1
  137. package/dist/utils/image-resize-core.d.ts +8 -0
  138. package/dist/utils/image-resize-core.d.ts.map +1 -1
  139. package/dist/utils/image-resize-core.js +1 -0
  140. package/dist/utils/image-resize-core.js.map +1 -1
  141. package/dist/utils/image-resize-worker.js +3 -2
  142. package/dist/utils/image-resize-worker.js.map +1 -1
  143. package/dist/utils/image-resize.d.ts +2 -2
  144. package/dist/utils/image-resize.d.ts.map +1 -1
  145. package/dist/utils/image-resize.js +7 -10
  146. package/dist/utils/image-resize.js.map +1 -1
  147. package/docs/codemode.md +21 -1
  148. package/docs/llama-cpp.md +9 -2
  149. package/docs/mcp-servers.md +3 -3
  150. package/docs/models.md +10 -0
  151. package/docs/providers.md +27 -4
  152. package/docs/reference/cli.md +2 -2
  153. package/docs/sdk/reference.md +3 -3
  154. package/docs/settings.md +2 -2
  155. package/docs/tools.md +1 -1
  156. package/docs/workflows/operations.md +2 -2
  157. package/npm-shrinkwrap.json +32 -32
  158. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"loader-virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/loader-virtual-modules.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,6BAA6B,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACjF,O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AAqB,CAAC,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;AAC/D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,aAAqB,EACrB,UAAgC;IAEhC,MAAM,iBAAiB,GAAG,WAAW,IAAI,cAAc,CAAC;IACxD,IAAI,iBAAiB,IAAI,4BAA4B,CAAC,aAAa,CAAC,EAAE,CAAC;QACtE,OAAO,gCAAgC,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;QACrC,MAAM,aAAa,GAAG,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACxD,IAAI,aAAa;YAAE,OAAO,aAAa,CAAC;IACzC,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;IAC/C,uEAAuE;IACvE,sEAAsE;IACtE,2EAA2E;IAC3E,mDAAmD;IACnD,yEAAyE;IACzE,2EAA2E;IAC3E,4EAA4E;IAC5E,uEAAuE;IACvE,EAAE;IACF,6EAA6E;IAC7E,yEAAyE;IACzE,yEAAyE;IACzE,6EAA6E;IAC7E,wEAAwE;IACxE,0EAA0E;IAC1E,0CAA0C;IAC1C,MAAM,uBAAuB,GAAG,iBAAiB,IAAI,CAAC,SAAS,IAAI,qBAAqB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;IAC7G,IAAI,uBAAuB,EAAE,CAAC;QAC7B,OAAO,8BAA8B,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,qBAAqB,CAAC,aAAa,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { createJiti } from \"jiti\";\nimport { getExtensionTranspileCacheDir, isBunBinary, isBundledBuild } from \"../../config.js\";\nimport { resolutionBaseUrl } from \"../../utils/module-require.ts\";\nimport { resolvePath } from \"../../utils/paths.ts\";\nimport { moduleDirFromMetaUrl } from \"../../utils/split-launcher.ts\";\nimport { installHostModuleBridge } from \"./host-module-bridge.ts\";\nimport { getVirtualModules, loadVirtualModules } from \"./loader-host-modules.js\";\nimport { isNativeBuiltinExtensionPath } from \"./native-builtin-entries.ts\";\nimport type { ExtensionFactory } from \"./types.ts\";\n\nexport { getVirtualModules } from \"./loader-host-modules.js\";\n\nconst require = createRequire(import.meta.url);\nlet _aliases: Record<string, string> | null = null;\nlet _transpileCacheDir: string | null = null;\nlet createJitiPromise: Promise<typeof createJiti> | undefined;\n\nfunction getCreateJiti(): Promise<typeof createJiti> {\n\tcreateJitiPromise ??= (\n\t\tisBunBinary || isBundledBuild ? import(\"./jiti-static-loader.ts\") : import(\"./jiti-loader.ts\")\n\t).then((module) => module.createJiti);\n\treturn createJitiPromise;\n}\n\n/**\n * Persistent on-disk cache for jiti-transpiled extension modules.\n * jiti keys cache entries by source-content hash, so entries self-invalidate\n * when extension sources change; stale sibling version dirs are pruned\n * in the background.\n */\nfunction getTranspileCacheDir(): string {\n\tif (_transpileCacheDir) return _transpileCacheDir;\n\t_transpileCacheDir = getExtensionTranspileCacheDir();\n\tfs.mkdirSync(_transpileCacheDir, { recursive: true });\n\tpruneStaleTranspileCaches(_transpileCacheDir);\n\treturn _transpileCacheDir;\n}\n\nfunction pruneStaleTranspileCaches(currentDir: string): void {\n\tconst parent = path.dirname(currentDir);\n\tconst keep = path.basename(currentDir);\n\tvoid fs.promises\n\t\t.readdir(parent)\n\t\t.then((entries) =>\n\t\t\tPromise.all(\n\t\t\t\tentries\n\t\t\t\t\t.filter((entry) => entry !== keep)\n\t\t\t\t\t.map((entry) => fs.promises.rm(path.join(parent, entry), { recursive: true, force: true })),\n\t\t\t),\n\t\t)\n\t\t.catch(() => {});\n}\n\n/**\n * Per-extension-path record of the complete file graph a transformed (jiti)\n * evaluation read, mapping each absolute file path to the SHA256 hex digest of\n * its content at evaluation time. Persisted under the versioned transpile\n * cache directory so pruneStaleTranspileCaches handles version cleanup.\n */\nexport interface ExtensionGraphManifest {\n\tversion: 1;\n\textensionPath: string;\n\tfiles: Record<string, string>;\n}\n\nconst GRAPH_MANIFEST_VERSION = 1;\nconst GRAPH_MANIFEST_DIR_NAME = \"graph-manifests\";\n\nconst graphManifestFileExtensions = new Set([\".ts\", \".tsx\", \".mts\", \".cts\", \".js\", \".mjs\", \".cjs\", \".jsx\", \".json\"]);\n\nfunction graphManifestDir(): string {\n\treturn path.join(getTranspileCacheDir(), GRAPH_MANIFEST_DIR_NAME);\n}\n\nfunction graphManifestPath(extensionPath: string): string {\n\tconst key = crypto.createHash(\"sha256\").update(extensionPath).digest(\"hex\").slice(0, 32);\n\treturn path.join(graphManifestDir(), `${key}.json`);\n}\n\nfunction sha256Hex(content: string | NodeJS.ArrayBufferView): string {\n\treturn crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n}\n\n// jiti's CJS bundle reads every module source in the require graph through\n// fs.readFileSync (even on fsCache hits, since the cache key is a hash of the\n// source), so observing readFileSync while a transformed import is in flight\n// sees the complete transitive graph. The observer records into every active\n// recorder; unrelated reads that interleave only over-record, which at worst\n// forces a redundant re-evaluation later — never a stale one.\nconst fsExports = require(\"node:fs\") as typeof fs;\nconst activeGraphRecorders = new Set<Map<string, string>>();\nlet observedReadFileSync: typeof fs.readFileSync | null = null;\n\nfunction recordObservedRead(target: Parameters<typeof fs.readFileSync>[0], content: string | Buffer): void {\n\tif (typeof target !== \"string\" || !path.isAbsolute(target)) return;\n\tif (!graphManifestFileExtensions.has(path.extname(target).toLowerCase())) return;\n\tconst normalizedTarget = path.normalize(target);\n\tconst cachePrefix = path.normalize(getTranspileCacheDir()) + path.sep;\n\tif (normalizedTarget.toLowerCase().startsWith(cachePrefix.toLowerCase())) return;\n\tconst hash = sha256Hex(content);\n\tfor (const recorder of activeGraphRecorders) {\n\t\trecorder.set(normalizedTarget, hash);\n\t}\n}\n\nfunction installReadFileSyncObserver(): void {\n\tif (observedReadFileSync) return;\n\tconst original = fsExports.readFileSync;\n\tobservedReadFileSync = original;\n\tconst wrapped = ((...args: Parameters<typeof fs.readFileSync>) => {\n\t\tconst content = original(...args);\n\t\trecordObservedRead(args[0], content);\n\t\treturn content;\n\t}) as typeof fs.readFileSync;\n\tfsExports.readFileSync = wrapped;\n}\n\nfunction uninstallReadFileSyncObserver(): void {\n\tif (!observedReadFileSync || activeGraphRecorders.size > 0) return;\n\tfsExports.readFileSync = observedReadFileSync;\n\tobservedReadFileSync = null;\n}\n\nfunction writeGraphManifest(manifest: ExtensionGraphManifest): void {\n\tconst manifestFile = graphManifestPath(manifest.extensionPath);\n\tlet tempFile: string | undefined;\n\ttry {\n\t\tfs.mkdirSync(path.dirname(manifestFile), { recursive: true });\n\t\ttempFile = `${manifestFile}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;\n\t\tfs.writeFileSync(tempFile, JSON.stringify(manifest));\n\t\tfs.renameSync(tempFile, manifestFile);\n\t} catch {\n\t\t// Manifest persistence is best-effort: a missing manifest only means the\n\t\t// next reload cannot prove the graph unchanged and re-evaluates. A failed\n\t\t// replacement must not leave an older manifest behind describing a graph\n\t\t// that no longer matches this evaluation, so invalidate the destination\n\t\t// first, independently of removing the temporary file.\n\t\ttry {\n\t\t\tfs.rmSync(manifestFile, { force: true });\n\t\t} catch {\n\t\t\t// A leftover stale manifest cannot be reused without also matching\n\t\t\t// the in-memory manifest of the same evaluation, and readers\n\t\t\t// tolerate missing or corrupt files.\n\t\t}\n\t\ttry {\n\t\t\tif (tempFile) fs.rmSync(tempFile, { force: true });\n\t\t} catch {\n\t\t\t// Temporary files carry a unique suffix and are never read back.\n\t\t}\n\t}\n}\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n\treturn Object.values(value).every((entry) => typeof entry === \"string\");\n}\n\nexport function readExtensionGraphManifest(extensionPath: string): ExtensionGraphManifest | undefined {\n\ttry {\n\t\tconst parsed = JSON.parse(\n\t\t\tfs.readFileSync(graphManifestPath(extensionPath), \"utf-8\"),\n\t\t) as Partial<ExtensionGraphManifest>;\n\t\tif (parsed.version !== GRAPH_MANIFEST_VERSION) return undefined;\n\t\tif (parsed.extensionPath !== extensionPath) return undefined;\n\t\tif (!isStringRecord(parsed.files)) return undefined;\n\t\treturn { version: GRAPH_MANIFEST_VERSION, extensionPath, files: parsed.files };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function recordExtensionGraph<T>(\n\textensionPath: string,\n\tload: () => Promise<T>,\n): Promise<{ result: T; manifest: ExtensionGraphManifest }> {\n\tconst files = new Map<string, string>();\n\tactiveGraphRecorders.add(files);\n\tinstallReadFileSyncObserver();\n\tlet result: T;\n\ttry {\n\t\tresult = await load();\n\t} finally {\n\t\tactiveGraphRecorders.delete(files);\n\t\tuninstallReadFileSyncObserver();\n\t}\n\tconst manifest: ExtensionGraphManifest = {\n\t\tversion: GRAPH_MANIFEST_VERSION,\n\t\textensionPath,\n\t\tfiles: Object.fromEntries([...files.entries()].sort(([a], [b]) => a.localeCompare(b))),\n\t};\n\twriteGraphManifest(manifest);\n\treturn { result, manifest };\n}\n\n/**\n * Factories from transformed evaluations, retained across extension cache\n * generation bumps and paired with the graph manifest recorded by the\n * evaluation that produced them. A retained factory is reused on a reload only\n * when the persisted manifest still equals the paired one and every file in it\n * rehashes to its recorded digest; any doubt (missing or corrupt manifest,\n * missing file, hash mismatch, changed graph shape) falls back to a fresh\n * transformed re-evaluation, which re-records the manifest.\n */\nconst retainedTransformedLoads = new Map<string, { factory: ExtensionFactory; manifest: ExtensionGraphManifest }>();\n\nfunction manifestFilesEqual(a: Record<string, string>, b: Record<string, string>): boolean {\n\tconst aEntries = Object.entries(a);\n\tif (aEntries.length !== Object.keys(b).length) return false;\n\treturn aEntries.every(([filePath, hash]) => b[filePath] === hash);\n}\n\nfunction graphUnchangedSince(manifest: ExtensionGraphManifest): boolean {\n\tconst stored = readExtensionGraphManifest(manifest.extensionPath);\n\tif (!stored || !manifestFilesEqual(stored.files, manifest.files)) return false;\n\tconst entries = Object.entries(manifest.files);\n\tif (entries.length === 0) return false;\n\tfor (const [filePath, hash] of entries) {\n\t\ttry {\n\t\t\tif (sha256Hex(fs.readFileSync(filePath)) !== hash) return false;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * A factory can defer loading local code until it is invoked (e.g. a\n * `require()` inside the factory body). Those reads are invisible to the\n * import-time recording, so retained factories are wrapped to record reads\n * that happen while the factory executes and merge them into the retained and\n * persisted manifest — editing a deferred dependency then invalidates reuse\n * like any other graph file.\n */\nfunction withDeferredGraphRecording(extensionPath: string, factory: ExtensionFactory): ExtensionFactory {\n\treturn (pi) => {\n\t\tconst files = new Map<string, string>();\n\t\tactiveGraphRecorders.add(files);\n\t\tinstallReadFileSyncObserver();\n\t\tconst finish = () => {\n\t\t\tactiveGraphRecorders.delete(files);\n\t\t\tuninstallReadFileSyncObserver();\n\t\t\tif (files.size > 0) mergeDeferredGraphReads(extensionPath, files);\n\t\t};\n\t\ttry {\n\t\t\tconst result = factory(pi);\n\t\t\tif (\n\t\t\t\tresult !== null &&\n\t\t\t\t(typeof result === \"object\" || typeof result === \"function\") &&\n\t\t\t\ttypeof (result as PromiseLike<void>).then === \"function\"\n\t\t\t) {\n\t\t\t\treturn Promise.resolve(result).finally(finish);\n\t\t\t}\n\t\t\tfinish();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tfinish();\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\nfunction mergeDeferredGraphReads(extensionPath: string, files: Map<string, string>): void {\n\tconst retained = retainedTransformedLoads.get(extensionPath);\n\tif (!retained) return;\n\tlet changed = false;\n\tfor (const [filePath, hash] of files) {\n\t\tif (retained.manifest.files[filePath] !== hash) {\n\t\t\tretained.manifest.files[filePath] = hash;\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tif (changed) writeGraphManifest(retained.manifest);\n}\n\nlet extensionCacheCwd: string | undefined;\nlet extensionCacheGeneration = 0;\nconst extensionCache = new Map<string, ExtensionFactory>();\n\n// Installed builtin bundles are immutable within a running binary. Keep their\n// evaluated factories outside the generation-scoped editable-extension cache.\nconst nativeBuiltinFactories = new Map<string, ExtensionFactory>();\nconst nativeBuiltinLoads = new Map<string, Promise<ExtensionFactory | undefined>>();\n\nasync function loadNativeBuiltinExtensionModule(\n\textensionPath: string,\n\tcacheToken: ExtensionCacheToken | undefined,\n): Promise<ExtensionFactory | undefined> {\n\tlet factory = nativeBuiltinFactories.get(extensionPath);\n\tif (!factory) {\n\t\tlet pending = nativeBuiltinLoads.get(extensionPath);\n\t\tif (!pending) {\n\t\t\tpending = (async () => {\n\t\t\t\tawait installHostModuleBridge();\n\t\t\t\tconst module = (await import(pathToFileURL(extensionPath).href)) as { default?: unknown };\n\t\t\t\tif (typeof module.default !== \"function\") return undefined;\n\t\t\t\tconst loadedFactory = module.default as ExtensionFactory;\n\t\t\t\tnativeBuiltinFactories.set(extensionPath, loadedFactory);\n\t\t\t\treturn loadedFactory;\n\t\t\t})();\n\t\t\tnativeBuiltinLoads.set(extensionPath, pending);\n\t\t}\n\t\ttry {\n\t\t\tfactory = await pending;\n\t\t} finally {\n\t\t\tnativeBuiltinLoads.delete(extensionPath);\n\t\t}\n\t}\n\tif (factory && isCurrentCacheToken(cacheToken)) {\n\t\textensionCache.set(extensionPath, factory);\n\t}\n\treturn factory;\n}\n\nexport interface ExtensionCacheToken {\n\tcwd: string;\n\tgeneration: number;\n}\n\nexport function clearExtensionCache(): void {\n\textensionCache.clear();\n\textensionCacheCwd = undefined;\n\textensionCacheGeneration++;\n}\n\nexport function useExtensionCacheCwd(cwd: string): ExtensionCacheToken {\n\tconst resolvedCwd = resolvePath(cwd);\n\tif (extensionCacheCwd !== undefined && extensionCacheCwd !== resolvedCwd) {\n\t\tclearExtensionCache();\n\t}\n\textensionCacheCwd = resolvedCwd;\n\treturn { cwd: resolvedCwd, generation: extensionCacheGeneration };\n}\n\nfunction isCurrentCacheToken(cacheToken: ExtensionCacheToken | undefined): cacheToken is ExtensionCacheToken {\n\treturn (\n\t\tcacheToken !== undefined &&\n\t\textensionCacheCwd === cacheToken.cwd &&\n\t\textensionCacheGeneration === cacheToken.generation\n\t);\n}\n\nfunction extensionImportSpecifier(extensionPath: string, cacheToken: ExtensionCacheToken | undefined): string {\n\tconst url = pathToFileURL(extensionPath);\n\tconst cacheKey = cacheToken ? `${cacheToken.generation}:${cacheToken.cwd}` : `${Date.now()}:${Math.random()}`;\n\turl.searchParams.set(\"atomicExtensionCache\", cacheKey);\n\treturn url.href;\n}\n\n/**\n * Locate an installed package's root directory without consulting its\n * \"exports\" map: require.resolve(\"<pkg>/package.json\") throws\n * ERR_PACKAGE_PATH_NOT_EXPORTED under Node for packages that do not export\n * \"./package.json\" (pi-ai does not), and import.meta.resolve() cannot be\n * used because its mere presence silently disables bytecode generation for\n * the compiled binary (CJS bundle). Scanning require.resolve.paths() walks\n * the same node_modules chain Node would, without exports-map encapsulation.\n */\nfunction findPackageRoot(packageName: string, searchPaths?: string[]): string {\n\tfor (const base of searchPaths ?? require.resolve.paths(packageName) ?? []) {\n\t\tconst candidate = path.join(base, packageName);\n\t\tif (fs.existsSync(path.join(candidate, \"package.json\"))) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\tthrow new Error(`Cannot locate package directory for \"${packageName}\"`);\n}\nfunction currentModuleDir(): string {\n\treturn moduleDirFromMetaUrl(import.meta.url, \"dist\", \"core\", \"extensions\");\n}\n\n/**\n * Get aliases for jiti (used in Node.js/development mode).\n * In Bun binary mode, virtualModules is used instead.\n */\nfunction getAliases(): Record<string, string> {\n\tif (_aliases) return _aliases;\n\n\tconst __dirname = currentModuleDir();\n\tconst packageIndex = path.resolve(__dirname, \"../..\", \"index.js\");\n\n\tconst typeboxEntry = require.resolve(\"typebox\");\n\tconst typeboxCompileEntry = require.resolve(\"typebox/compile\");\n\tconst typeboxValueEntry = require.resolve(\"typebox/value\");\n\n\tconst packagesRoot = path.resolve(__dirname, \"../../../../\");\n\tconst resolveWorkspaceOrImport = (workspaceRelativePath: string, packageName: string): string => {\n\t\tconst workspacePath = path.join(packagesRoot, workspaceRelativePath);\n\t\tif (fs.existsSync(workspacePath)) {\n\t\t\treturn workspacePath;\n\t\t}\n\t\tconst packageRoot = findPackageRoot(packageName);\n\t\tconst entryRelativePath = workspaceRelativePath.split(\"/\").slice(1).join(\"/\");\n\t\treturn path.join(packageRoot, entryRelativePath);\n\t};\n\n\tconst piCodingAgentEntry = packageIndex;\n\tconst piAgentCoreEntry = resolveWorkspaceOrImport(\"agent/dist/index.js\", \"@earendil-works/pi-agent-core\");\n\tconst piTuiEntry = resolveWorkspaceOrImport(\"tui/dist/index.js\", \"@earendil-works/pi-tui\");\n\tconst piTuiLayoutEntry = resolveWorkspaceOrImport(\"tui/dist/layout.js\", \"@earendil-works/pi-tui\");\n\tconst piTuiLayoutNodeEntry = resolveWorkspaceOrImport(\"tui/dist/layout-node.js\", \"@earendil-works/pi-tui\");\n\t// The workspace path mirrors pi-ai 0.80.x's built dist layout. If an\n\t// upstream layout change moves these files, this join needs updating to\n\t// match the package's real dist paths.\n\tconst piAiEntry = resolveWorkspaceOrImport(\"ai/dist/compat.js\", \"@bastani/pi-ai\");\n\tconst piAiCodexResponsesEntry = resolveWorkspaceOrImport(\"ai/dist/api/openai-codex-responses.js\", \"@bastani/pi-ai\");\n\tconst piAiLlamaCppClassifyEntry = resolveWorkspaceOrImport(\n\t\t\"ai/dist/api/llama-cpp-classify.lazy.js\",\n\t\t\"@bastani/pi-ai\",\n\t);\n\tconst piAiOauthEntry = resolveWorkspaceOrImport(\"ai/dist/oauth.js\", \"@bastani/pi-ai\");\n\tconst piAiModelsEntry = resolveWorkspaceOrImport(\"ai/dist/models.js\", \"@bastani/pi-ai\");\n\tconst piAiProvidersEntry = resolveWorkspaceOrImport(\"ai/dist/providers/all.js\", \"@bastani/pi-ai\");\n\tconst piAiCopilotEnvEntry = resolveWorkspaceOrImport(\"ai/dist/providers/github-copilot-env.js\", \"@bastani/pi-ai\");\n\tconst piAiProviderEnvEntry = resolveWorkspaceOrImport(\"ai/dist/utils/provider-env.js\", \"@bastani/pi-ai\");\n\tconst piAiOauthPageEntry = resolveWorkspaceOrImport(\"ai/dist/utils/oauth-page.js\", \"@bastani/pi-ai\");\n\tconst piAiGatewayBindingEntry = resolveWorkspaceOrImport(\n\t\t\"ai/dist/api/cloudflare-gateway-binding.js\",\n\t\t\"@bastani/pi-ai\",\n\t);\n\n\t_aliases = {\n\t\t\"@bastani/atomic\": piCodingAgentEntry,\n\t\t\"@earendil-works/pi-coding-agent\": piCodingAgentEntry,\n\t\t\"@earendil-works/pi-agent-core\": piAgentCoreEntry,\n\t\t\"@earendil-works/pi-tui/dist/layout.js\": piTuiLayoutEntry,\n\t\t\"@earendil-works/pi-tui/dist/layout-node.js\": piTuiLayoutNodeEntry,\n\t\t\"@earendil-works/pi-tui\": piTuiEntry,\n\t\t\"@bastani/pi-ai/api/openai-codex-responses\": piAiCodexResponsesEntry,\n\t\t\"@bastani/pi-ai/api/llama-cpp-classify.lazy\": piAiLlamaCppClassifyEntry,\n\t\t\"@bastani/pi-ai/oauth\": piAiOauthEntry,\n\t\t\"@bastani/pi-ai/models\": piAiModelsEntry,\n\t\t\"@bastani/pi-ai/providers/all\": piAiProvidersEntry,\n\t\t\"@bastani/pi-ai/providers/github-copilot-env\": piAiCopilotEnvEntry,\n\t\t\"@bastani/pi-ai/utils/provider-env\": piAiProviderEnvEntry,\n\t\t\"@bastani/pi-ai/utils/oauth-page\": piAiOauthPageEntry,\n\t\t\"@bastani/pi-ai/compat\": piAiEntry,\n\t\t\"@bastani/pi-ai/api/cloudflare-gateway-binding\": piAiGatewayBindingEntry,\n\t\t\"@bastani/pi-ai\": piAiEntry,\n\t\t\"@earendil-works/pi-ai/api/openai-codex-responses\": piAiCodexResponsesEntry,\n\t\t\"@earendil-works/pi-ai/oauth\": piAiOauthEntry,\n\t\t\"@earendil-works/pi-ai/models\": piAiModelsEntry,\n\t\t\"@earendil-works/pi-ai/providers/all\": piAiProvidersEntry,\n\t\t\"@earendil-works/pi-ai/compat\": piAiEntry,\n\t\t\"@earendil-works/pi-ai/api/cloudflare-gateway-binding\": piAiGatewayBindingEntry,\n\t\t\"@earendil-works/pi-ai/utils/oauth-page\": piAiOauthPageEntry,\n\t\t\"@earendil-works/pi-ai\": piAiEntry,\n\t\t\"@mariozechner/pi-agent-core\": piAgentCoreEntry,\n\t\t\"@mariozechner/pi-tui/dist/layout.js\": piTuiLayoutEntry,\n\t\t\"@mariozechner/pi-tui\": piTuiEntry,\n\t\t\"@mariozechner/pi-ai/oauth\": piAiOauthEntry,\n\t\t\"@mariozechner/pi-ai/models\": piAiModelsEntry,\n\t\t\"@mariozechner/pi-ai/providers/all\": piAiProvidersEntry,\n\t\t\"@mariozechner/pi-ai/compat\": piAiEntry,\n\t\t\"@mariozechner/pi-ai/api/cloudflare-gateway-binding\": piAiGatewayBindingEntry,\n\t\t\"@mariozechner/pi-ai\": piAiEntry,\n\t\ttypebox: typeboxEntry,\n\t\t\"typebox/compile\": typeboxCompileEntry,\n\t\t\"typebox/value\": typeboxValueEntry,\n\t\t\"@sinclair/typebox\": typeboxEntry,\n\t\t\"@sinclair/typebox/compile\": typeboxCompileEntry,\n\t\t\"@sinclair/typebox/value\": typeboxValueEntry,\n\t};\n\n\treturn _aliases;\n}\n\nexport const extensionLoaderTestHooks = {\n\tloadVirtualModules,\n\tgetAliases,\n\tfindPackageRoot,\n\tgetTranspileCacheDir,\n\tgraphManifestPath,\n\treadExtensionGraphManifest,\n\tloadExtensionModuleTransformed: (extensionPath: string, cacheToken?: ExtensionCacheToken) =>\n\t\timportExtensionModule(extensionPath, cacheToken, true),\n\tloadTransformedExtensionModule: (extensionPath: string, cacheToken?: ExtensionCacheToken) =>\n\t\tloadTransformedExtensionModule(extensionPath, cacheToken),\n\tloadNativeBuiltinExtensionModule,\n\thasNativeBuiltinFactory: (extensionPath: string): boolean => nativeBuiltinFactories.has(extensionPath),\n};\n\n/**\n * Extension paths already evaluated via native import() in this process. Bun on\n * Windows ignores the cache-busting query on file URLs, so re-loads of these\n * paths (e.g. /reload) must go through jiti's transformed-import path to get a\n * fresh module evaluation.\n */\nconst nativelyImportedPaths = new Set<string>();\n\nasync function importExtensionModule(\n\textensionPath: string,\n\tcacheToken: ExtensionCacheToken | undefined,\n\tforceTransformedImports: boolean,\n): Promise<ExtensionFactory | undefined> {\n\tconst isWindows = process.platform === \"win32\";\n\tconst isSingleFileBuild = isBunBinary || isBundledBuild;\n\tconst createJitiImpl = await getCreateJiti();\n\tconst jiti = createJitiImpl(resolutionBaseUrl(import.meta.url), {\n\t\tmoduleCache: false,\n\t\t...(forceTransformedImports\n\t\t\t? { fsCache: getTranspileCacheDir(), tryNative: false }\n\t\t\t: isWindows\n\t\t\t\t? { fsCache: getTranspileCacheDir() }\n\t\t\t\t: {}),\n\t\t// A first native import can fall back to transformation too. Always share\n\t\t// the live host instead of re-evaluating its graph through source aliases.\n\t\tvirtualModules: await getVirtualModules(),\n\t\t...(!isSingleFileBuild ? { alias: getAliases() } : {}),\n\t});\n\tconst specifier = extensionImportSpecifier(extensionPath, cacheToken);\n\t// Transformed evaluations are the loads whose repeat cost is the Windows\n\t// /reload regression, so they are also the loads whose file graph is\n\t// recorded into a content-hash manifest.\n\tlet module: unknown;\n\tlet recordedManifest: ExtensionGraphManifest | undefined;\n\tif (forceTransformedImports) {\n\t\tconst recorded = await recordExtensionGraph(extensionPath, () => jiti.import(specifier, { default: true }));\n\t\tmodule = recorded.result;\n\t\trecordedManifest = recorded.manifest;\n\t} else {\n\t\tmodule = await jiti.import(specifier, { default: true });\n\t}\n\tif (isWindows && !forceTransformedImports) {\n\t\tnativelyImportedPaths.add(extensionPath);\n\t}\n\tlet factory = module as ExtensionFactory;\n\tif (typeof factory !== \"function\") return undefined;\n\tif (recordedManifest) {\n\t\tfactory = withDeferredGraphRecording(extensionPath, factory);\n\t\tretainedTransformedLoads.set(extensionPath, { factory, manifest: recordedManifest });\n\t}\n\tif (isCurrentCacheToken(cacheToken)) {\n\t\textensionCache.set(extensionPath, factory);\n\t}\n\treturn factory;\n}\n\n/**\n * Load an extension through jiti's transformed-import path, reusing the\n * previously evaluated factory when the recorded graph manifest proves the\n * entire transitive file graph is byte-identical. This lets the\n * unchanged-graph case survive the /reload generation bump instead of\n * re-evaluating hundreds of files; anything else re-evaluates as before.\n *\n * Note: when the graph is byte-identical, the previously evaluated module\n * instance (including any mutable module-scoped state it closed over) is\n * reused. An extension that requires clean module state on every reload must\n * change a file in its graph to force re-evaluation.\n */\nasync function loadTransformedExtensionModule(\n\textensionPath: string,\n\tcacheToken: ExtensionCacheToken | undefined,\n): Promise<ExtensionFactory | undefined> {\n\tconst retained = retainedTransformedLoads.get(extensionPath);\n\tif (retained && graphUnchangedSince(retained.manifest)) {\n\t\tif (isCurrentCacheToken(cacheToken)) {\n\t\t\textensionCache.set(extensionPath, retained.factory);\n\t\t}\n\t\treturn retained.factory;\n\t}\n\treturn importExtensionModule(extensionPath, cacheToken, true);\n}\n\nexport async function loadExtensionModule(\n\textensionPath: string,\n\tcacheToken?: ExtensionCacheToken,\n): Promise<ExtensionFactory | undefined> {\n\tconst isSingleFileBuild = isBunBinary || isBundledBuild;\n\tif (isSingleFileBuild && isNativeBuiltinExtensionPath(extensionPath)) {\n\t\treturn loadNativeBuiltinExtensionModule(extensionPath, cacheToken);\n\t}\n\n\tif (isCurrentCacheToken(cacheToken)) {\n\t\tconst cachedFactory = extensionCache.get(extensionPath);\n\t\tif (cachedFactory) return cachedFactory;\n\t}\n\n\tconst isWindows = process.platform === \"win32\";\n\t// Single-file builds (compiled binary or dev bundle) cannot alias host\n\t// package specifiers to files on disk: extensions must share the live\n\t// module instances baked into the build, so virtualModules is used instead\n\t// (which requires jiti's transformed-import path).\n\t// Every editable path retains the existing jiti/virtualModules behavior.\n\t// Windows first-load fast path: native import() (jiti's default tryNative)\n\t// skips per-launch transpilation of the extension module graph. Re-loads of\n\t// the same path fall back to transformed imports for fresh evaluation.\n\t//\n\t// That fallback is not free. Measured on Windows CI, a transformed re-import\n\t// costs ~15 ms per module file in the extension's transitive graph, so a\n\t// reload of all five builtin packages (621 files) takes ~10.7 s cold and\n\t// ~2.5 s against a warm jiti fsCache, against ~40 ms on Linux and macOS. The\n\t// cost is correctness-driven and is paid interactively on every Windows\n\t// `/reload`; removing it needs a content-hash-keyed evaluation cache or a\n\t// narrower trigger, not a larger timeout.\n\tconst forceTransformedImports = isSingleFileBuild || (isWindows && nativelyImportedPaths.has(extensionPath));\n\tif (forceTransformedImports) {\n\t\treturn loadTransformedExtensionModule(extensionPath, cacheToken);\n\t}\n\treturn importExtensionModule(extensionPath, cacheToken, false);\n}\n"]}
1
+ {"version":3,"file":"loader-virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/loader-virtual-modules.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,6BAA6B,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB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,aAAa,CAAC,CAAC,CAAC;IAC7G,IAAI,uBAAuB,EAAE,CAAC;QAC7B,OAAO,8BAA8B,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,qBAAqB,CAAC,aAAa,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { createJiti } from \"jiti\";\nimport { getExtensionTranspileCacheDir, isBunBinary, isBundledBuild } from \"../../config.js\";\nimport { resolutionBaseUrl } from \"../../utils/module-require.ts\";\nimport { resolvePath } from \"../../utils/paths.ts\";\nimport { moduleDirFromMetaUrl } from \"../../utils/split-launcher.ts\";\nimport { installHostModuleBridge } from \"./host-module-bridge.ts\";\nimport { getVirtualModules, loadVirtualModules } from \"./loader-host-modules.js\";\nimport { isNativeBuiltinExtensionPath } from \"./native-builtin-entries.ts\";\nimport { createTypeScriptSourceSpecifierTransform } from \"./ts-source-specifiers.js\";\nimport type { ExtensionFactory } from \"./types.ts\";\n\nexport { getVirtualModules } from \"./loader-host-modules.js\";\n\nconst require = createRequire(import.meta.url);\nlet _aliases: Record<string, string> | null = null;\nlet _transpileCacheDir: string | null = null;\nlet createJitiPromise: Promise<typeof createJiti> | undefined;\nlet typeScriptSourceSpecifierTransform: ReturnType<typeof createTypeScriptSourceSpecifierTransform> | undefined;\n\nfunction getCreateJiti(): Promise<typeof createJiti> {\n\tcreateJitiPromise ??= (\n\t\tisBunBinary || isBundledBuild ? import(\"./jiti-static-loader.ts\") : import(\"./jiti-loader.ts\")\n\t).then((module) => module.createJiti);\n\treturn createJitiPromise;\n}\n\nfunction getTypeScriptSourceSpecifierTransform(\n\tcreateJitiImpl: typeof createJiti,\n): ReturnType<typeof createTypeScriptSourceSpecifierTransform> {\n\ttypeScriptSourceSpecifierTransform ??= createTypeScriptSourceSpecifierTransform(\n\t\tcreateJitiImpl,\n\t\tresolutionBaseUrl(import.meta.url),\n\t\tgetTranspileCacheDir,\n\t);\n\treturn typeScriptSourceSpecifierTransform;\n}\n\n/**\n * Persistent on-disk cache for transpiled extension modules. Entries are keyed\n * by source content and resolved TypeScript siblings, so they self-invalidate\n * when either changes; stale sibling version dirs are pruned in the background.\n */\nfunction getTranspileCacheDir(): string {\n\tif (_transpileCacheDir) return _transpileCacheDir;\n\t_transpileCacheDir = getExtensionTranspileCacheDir();\n\tfs.mkdirSync(_transpileCacheDir, { recursive: true });\n\tpruneStaleTranspileCaches(_transpileCacheDir);\n\treturn _transpileCacheDir;\n}\n\nfunction pruneStaleTranspileCaches(currentDir: string): void {\n\tconst parent = path.dirname(currentDir);\n\tconst keep = path.basename(currentDir);\n\tvoid fs.promises\n\t\t.readdir(parent)\n\t\t.then((entries) =>\n\t\t\tPromise.all(\n\t\t\t\tentries\n\t\t\t\t\t.filter((entry) => entry !== keep)\n\t\t\t\t\t.map((entry) => fs.promises.rm(path.join(parent, entry), { recursive: true, force: true })),\n\t\t\t),\n\t\t)\n\t\t.catch(() => {});\n}\n\n/**\n * Per-extension-path record of the complete file graph a transformed (jiti)\n * evaluation read, mapping each absolute file path to the SHA256 hex digest of\n * its content at evaluation time. Persisted under the versioned transpile\n * cache directory so pruneStaleTranspileCaches handles version cleanup.\n */\nexport interface ExtensionGraphManifest {\n\tversion: 1;\n\textensionPath: string;\n\tfiles: Record<string, string>;\n}\n\nconst GRAPH_MANIFEST_VERSION = 1;\nconst GRAPH_MANIFEST_DIR_NAME = \"graph-manifests\";\n\nconst graphManifestFileExtensions = new Set([\".ts\", \".tsx\", \".mts\", \".cts\", \".js\", \".mjs\", \".cjs\", \".jsx\", \".json\"]);\n\nfunction graphManifestDir(): string {\n\treturn path.join(getTranspileCacheDir(), GRAPH_MANIFEST_DIR_NAME);\n}\n\nfunction graphManifestPath(extensionPath: string): string {\n\tconst key = crypto.createHash(\"sha256\").update(extensionPath).digest(\"hex\").slice(0, 32);\n\treturn path.join(graphManifestDir(), `${key}.json`);\n}\n\nfunction sha256Hex(content: string | NodeJS.ArrayBufferView): string {\n\treturn crypto.createHash(\"sha256\").update(content).digest(\"hex\");\n}\n\n// jiti's CJS bundle reads every module source in the require graph through\n// fs.readFileSync (even on fsCache hits, since the cache key is a hash of the\n// source), so observing readFileSync while a transformed import is in flight\n// sees the complete transitive graph. The observer records into every active\n// recorder; unrelated reads that interleave only over-record, which at worst\n// forces a redundant re-evaluation later — never a stale one.\nconst fsExports = require(\"node:fs\") as typeof fs;\nconst activeGraphRecorders = new Set<Map<string, string>>();\nlet observedReadFileSync: typeof fs.readFileSync | null = null;\n\nfunction recordObservedRead(target: Parameters<typeof fs.readFileSync>[0], content: string | Buffer): void {\n\tif (typeof target !== \"string\" || !path.isAbsolute(target)) return;\n\tif (!graphManifestFileExtensions.has(path.extname(target).toLowerCase())) return;\n\tconst normalizedTarget = path.normalize(target);\n\tconst cachePrefix = path.normalize(getTranspileCacheDir()) + path.sep;\n\tif (normalizedTarget.toLowerCase().startsWith(cachePrefix.toLowerCase())) return;\n\tconst hash = sha256Hex(content);\n\tfor (const recorder of activeGraphRecorders) {\n\t\trecorder.set(normalizedTarget, hash);\n\t}\n}\n\nfunction installReadFileSyncObserver(): void {\n\tif (observedReadFileSync) return;\n\tconst original = fsExports.readFileSync;\n\tobservedReadFileSync = original;\n\tconst wrapped = ((...args: Parameters<typeof fs.readFileSync>) => {\n\t\tconst content = original(...args);\n\t\trecordObservedRead(args[0], content);\n\t\treturn content;\n\t}) as typeof fs.readFileSync;\n\tfsExports.readFileSync = wrapped;\n}\n\nfunction uninstallReadFileSyncObserver(): void {\n\tif (!observedReadFileSync || activeGraphRecorders.size > 0) return;\n\tfsExports.readFileSync = observedReadFileSync;\n\tobservedReadFileSync = null;\n}\n\nfunction writeGraphManifest(manifest: ExtensionGraphManifest): void {\n\tconst manifestFile = graphManifestPath(manifest.extensionPath);\n\tlet tempFile: string | undefined;\n\ttry {\n\t\tfs.mkdirSync(path.dirname(manifestFile), { recursive: true });\n\t\ttempFile = `${manifestFile}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;\n\t\tfs.writeFileSync(tempFile, JSON.stringify(manifest));\n\t\tfs.renameSync(tempFile, manifestFile);\n\t} catch {\n\t\t// Manifest persistence is best-effort: a missing manifest only means the\n\t\t// next reload cannot prove the graph unchanged and re-evaluates. A failed\n\t\t// replacement must not leave an older manifest behind describing a graph\n\t\t// that no longer matches this evaluation, so invalidate the destination\n\t\t// first, independently of removing the temporary file.\n\t\ttry {\n\t\t\tfs.rmSync(manifestFile, { force: true });\n\t\t} catch {\n\t\t\t// A leftover stale manifest cannot be reused without also matching\n\t\t\t// the in-memory manifest of the same evaluation, and readers\n\t\t\t// tolerate missing or corrupt files.\n\t\t}\n\t\ttry {\n\t\t\tif (tempFile) fs.rmSync(tempFile, { force: true });\n\t\t} catch {\n\t\t\t// Temporary files carry a unique suffix and are never read back.\n\t\t}\n\t}\n}\n\nfunction isStringRecord(value: unknown): value is Record<string, string> {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n\treturn Object.values(value).every((entry) => typeof entry === \"string\");\n}\n\nexport function readExtensionGraphManifest(extensionPath: string): ExtensionGraphManifest | undefined {\n\ttry {\n\t\tconst parsed = JSON.parse(\n\t\t\tfs.readFileSync(graphManifestPath(extensionPath), \"utf-8\"),\n\t\t) as Partial<ExtensionGraphManifest>;\n\t\tif (parsed.version !== GRAPH_MANIFEST_VERSION) return undefined;\n\t\tif (parsed.extensionPath !== extensionPath) return undefined;\n\t\tif (!isStringRecord(parsed.files)) return undefined;\n\t\treturn { version: GRAPH_MANIFEST_VERSION, extensionPath, files: parsed.files };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nasync function recordExtensionGraph<T>(\n\textensionPath: string,\n\tload: () => Promise<T>,\n): Promise<{ result: T; manifest: ExtensionGraphManifest }> {\n\tconst files = new Map<string, string>();\n\tactiveGraphRecorders.add(files);\n\tinstallReadFileSyncObserver();\n\tlet result: T;\n\ttry {\n\t\tresult = await load();\n\t} finally {\n\t\tactiveGraphRecorders.delete(files);\n\t\tuninstallReadFileSyncObserver();\n\t}\n\tconst manifest: ExtensionGraphManifest = {\n\t\tversion: GRAPH_MANIFEST_VERSION,\n\t\textensionPath,\n\t\tfiles: Object.fromEntries([...files.entries()].sort(([a], [b]) => a.localeCompare(b))),\n\t};\n\twriteGraphManifest(manifest);\n\treturn { result, manifest };\n}\n\n/**\n * Factories from transformed evaluations, retained across extension cache\n * generation bumps and paired with the graph manifest recorded by the\n * evaluation that produced them. A retained factory is reused on a reload only\n * when the persisted manifest still equals the paired one and every file in it\n * rehashes to its recorded digest; any doubt (missing or corrupt manifest,\n * missing file, hash mismatch, changed graph shape) falls back to a fresh\n * transformed re-evaluation, which re-records the manifest.\n */\nconst retainedTransformedLoads = new Map<string, { factory: ExtensionFactory; manifest: ExtensionGraphManifest }>();\n\nfunction manifestFilesEqual(a: Record<string, string>, b: Record<string, string>): boolean {\n\tconst aEntries = Object.entries(a);\n\tif (aEntries.length !== Object.keys(b).length) return false;\n\treturn aEntries.every(([filePath, hash]) => b[filePath] === hash);\n}\n\nfunction graphUnchangedSince(manifest: ExtensionGraphManifest): boolean {\n\tconst stored = readExtensionGraphManifest(manifest.extensionPath);\n\tif (!stored || !manifestFilesEqual(stored.files, manifest.files)) return false;\n\tconst entries = Object.entries(manifest.files);\n\tif (entries.length === 0) return false;\n\tfor (const [filePath, hash] of entries) {\n\t\ttry {\n\t\t\tif (sha256Hex(fs.readFileSync(filePath)) !== hash) return false;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * A factory can defer loading local code until it is invoked (e.g. a\n * `require()` inside the factory body). Those reads are invisible to the\n * import-time recording, so retained factories are wrapped to record reads\n * that happen while the factory executes and merge them into the retained and\n * persisted manifest — editing a deferred dependency then invalidates reuse\n * like any other graph file.\n */\nfunction withDeferredGraphRecording(extensionPath: string, factory: ExtensionFactory): ExtensionFactory {\n\treturn (pi) => {\n\t\tconst files = new Map<string, string>();\n\t\tactiveGraphRecorders.add(files);\n\t\tinstallReadFileSyncObserver();\n\t\tconst finish = () => {\n\t\t\tactiveGraphRecorders.delete(files);\n\t\t\tuninstallReadFileSyncObserver();\n\t\t\tif (files.size > 0) mergeDeferredGraphReads(extensionPath, files);\n\t\t};\n\t\ttry {\n\t\t\tconst result = factory(pi);\n\t\t\tif (\n\t\t\t\tresult !== null &&\n\t\t\t\t(typeof result === \"object\" || typeof result === \"function\") &&\n\t\t\t\ttypeof (result as PromiseLike<void>).then === \"function\"\n\t\t\t) {\n\t\t\t\treturn Promise.resolve(result).finally(finish);\n\t\t\t}\n\t\t\tfinish();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tfinish();\n\t\t\tthrow error;\n\t\t}\n\t};\n}\n\nfunction mergeDeferredGraphReads(extensionPath: string, files: Map<string, string>): void {\n\tconst retained = retainedTransformedLoads.get(extensionPath);\n\tif (!retained) return;\n\tlet changed = false;\n\tfor (const [filePath, hash] of files) {\n\t\tif (retained.manifest.files[filePath] !== hash) {\n\t\t\tretained.manifest.files[filePath] = hash;\n\t\t\tchanged = true;\n\t\t}\n\t}\n\tif (changed) writeGraphManifest(retained.manifest);\n}\n\nlet extensionCacheCwd: string | undefined;\nlet extensionCacheGeneration = 0;\nconst extensionCache = new Map<string, ExtensionFactory>();\n\n// Installed builtin bundles are immutable within a running binary. Keep their\n// evaluated factories outside the generation-scoped editable-extension cache.\nconst nativeBuiltinFactories = new Map<string, ExtensionFactory>();\nconst nativeBuiltinLoads = new Map<string, Promise<ExtensionFactory | undefined>>();\n\nasync function loadNativeBuiltinExtensionModule(\n\textensionPath: string,\n\tcacheToken: ExtensionCacheToken | undefined,\n): Promise<ExtensionFactory | undefined> {\n\tlet factory = nativeBuiltinFactories.get(extensionPath);\n\tif (!factory) {\n\t\tlet pending = nativeBuiltinLoads.get(extensionPath);\n\t\tif (!pending) {\n\t\t\tpending = (async () => {\n\t\t\t\tawait installHostModuleBridge();\n\t\t\t\tconst module = (await import(pathToFileURL(extensionPath).href)) as { default?: unknown };\n\t\t\t\tif (typeof module.default !== \"function\") return undefined;\n\t\t\t\tconst loadedFactory = module.default as ExtensionFactory;\n\t\t\t\tnativeBuiltinFactories.set(extensionPath, loadedFactory);\n\t\t\t\treturn loadedFactory;\n\t\t\t})();\n\t\t\tnativeBuiltinLoads.set(extensionPath, pending);\n\t\t}\n\t\ttry {\n\t\t\tfactory = await pending;\n\t\t} finally {\n\t\t\tnativeBuiltinLoads.delete(extensionPath);\n\t\t}\n\t}\n\tif (factory && isCurrentCacheToken(cacheToken)) {\n\t\textensionCache.set(extensionPath, factory);\n\t}\n\treturn factory;\n}\n\nexport interface ExtensionCacheToken {\n\tcwd: string;\n\tgeneration: number;\n}\n\nexport function clearExtensionCache(): void {\n\textensionCache.clear();\n\textensionCacheCwd = undefined;\n\textensionCacheGeneration++;\n}\n\nexport function useExtensionCacheCwd(cwd: string): ExtensionCacheToken {\n\tconst resolvedCwd = resolvePath(cwd);\n\tif (extensionCacheCwd !== undefined && extensionCacheCwd !== resolvedCwd) {\n\t\tclearExtensionCache();\n\t}\n\textensionCacheCwd = resolvedCwd;\n\treturn { cwd: resolvedCwd, generation: extensionCacheGeneration };\n}\n\nfunction isCurrentCacheToken(cacheToken: ExtensionCacheToken | undefined): cacheToken is ExtensionCacheToken {\n\treturn (\n\t\tcacheToken !== undefined &&\n\t\textensionCacheCwd === cacheToken.cwd &&\n\t\textensionCacheGeneration === cacheToken.generation\n\t);\n}\n\nfunction extensionImportSpecifier(extensionPath: string, cacheToken: ExtensionCacheToken | undefined): string {\n\tconst url = pathToFileURL(extensionPath);\n\tconst cacheKey = cacheToken ? `${cacheToken.generation}:${cacheToken.cwd}` : `${Date.now()}:${Math.random()}`;\n\turl.searchParams.set(\"atomicExtensionCache\", cacheKey);\n\treturn url.href;\n}\n\n/**\n * Locate an installed package's root directory without consulting its\n * \"exports\" map: require.resolve(\"<pkg>/package.json\") throws\n * ERR_PACKAGE_PATH_NOT_EXPORTED under Node for packages that do not export\n * \"./package.json\" (pi-ai does not), and import.meta.resolve() cannot be\n * used because its mere presence silently disables bytecode generation for\n * the compiled binary (CJS bundle). Scanning require.resolve.paths() walks\n * the same node_modules chain Node would, without exports-map encapsulation.\n */\nfunction findPackageRoot(packageName: string, searchPaths?: string[]): string {\n\tfor (const base of searchPaths ?? require.resolve.paths(packageName) ?? []) {\n\t\tconst candidate = path.join(base, packageName);\n\t\tif (fs.existsSync(path.join(candidate, \"package.json\"))) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\tthrow new Error(`Cannot locate package directory for \"${packageName}\"`);\n}\nfunction currentModuleDir(): string {\n\treturn moduleDirFromMetaUrl(import.meta.url, \"dist\", \"core\", \"extensions\");\n}\n\n/**\n * Get aliases for jiti (used in Node.js/development mode).\n * In Bun binary mode, virtualModules is used instead.\n */\nfunction getAliases(): Record<string, string> {\n\tif (_aliases) return _aliases;\n\n\tconst __dirname = currentModuleDir();\n\tconst packageIndex = path.resolve(__dirname, \"../..\", \"index.js\");\n\n\tconst typeboxEntry = require.resolve(\"typebox\");\n\tconst typeboxCompileEntry = require.resolve(\"typebox/compile\");\n\tconst typeboxValueEntry = require.resolve(\"typebox/value\");\n\n\tconst packagesRoot = path.resolve(__dirname, \"../../../../\");\n\tconst resolveWorkspaceOrImport = (workspaceRelativePath: string, packageName: string): string => {\n\t\tconst workspacePath = path.join(packagesRoot, workspaceRelativePath);\n\t\tif (fs.existsSync(workspacePath)) {\n\t\t\treturn workspacePath;\n\t\t}\n\t\tconst packageRoot = findPackageRoot(packageName);\n\t\tconst entryRelativePath = workspaceRelativePath.split(\"/\").slice(1).join(\"/\");\n\t\treturn path.join(packageRoot, entryRelativePath);\n\t};\n\n\tconst piCodingAgentEntry = packageIndex;\n\tconst piAgentCoreEntry = resolveWorkspaceOrImport(\"agent/dist/index.js\", \"@earendil-works/pi-agent-core\");\n\tconst piTuiEntry = resolveWorkspaceOrImport(\"tui/dist/index.js\", \"@earendil-works/pi-tui\");\n\tconst piTuiLayoutEntry = resolveWorkspaceOrImport(\"tui/dist/layout.js\", \"@earendil-works/pi-tui\");\n\tconst piTuiLayoutNodeEntry = resolveWorkspaceOrImport(\"tui/dist/layout-node.js\", \"@earendil-works/pi-tui\");\n\t// The workspace path mirrors pi-ai 0.80.x's built dist layout. If an\n\t// upstream layout change moves these files, this join needs updating to\n\t// match the package's real dist paths.\n\tconst piAiEntry = resolveWorkspaceOrImport(\"ai/dist/compat.js\", \"@bastani/pi-ai\");\n\tconst piAiCodexResponsesEntry = resolveWorkspaceOrImport(\"ai/dist/api/openai-codex-responses.js\", \"@bastani/pi-ai\");\n\tconst piAiLlamaCppClassifyEntry = resolveWorkspaceOrImport(\n\t\t\"ai/dist/api/llama-cpp-classify.lazy.js\",\n\t\t\"@bastani/pi-ai\",\n\t);\n\tconst piAiTypesafeSystemOneEntry = resolveWorkspaceOrImport(\n\t\t\"ai/dist/api/typesafe-system-one.lazy.js\",\n\t\t\"@bastani/pi-ai\",\n\t);\n\tconst piAiOauthEntry = resolveWorkspaceOrImport(\"ai/dist/oauth.js\", \"@bastani/pi-ai\");\n\tconst piAiModelsEntry = resolveWorkspaceOrImport(\"ai/dist/models.js\", \"@bastani/pi-ai\");\n\tconst piAiProvidersEntry = resolveWorkspaceOrImport(\"ai/dist/providers/all.js\", \"@bastani/pi-ai\");\n\tconst piAiCopilotEnvEntry = resolveWorkspaceOrImport(\"ai/dist/providers/github-copilot-env.js\", \"@bastani/pi-ai\");\n\tconst piAiProviderEnvEntry = resolveWorkspaceOrImport(\"ai/dist/utils/provider-env.js\", \"@bastani/pi-ai\");\n\tconst piAiOauthPageEntry = resolveWorkspaceOrImport(\"ai/dist/utils/oauth-page.js\", \"@bastani/pi-ai\");\n\tconst piAiGatewayBindingEntry = resolveWorkspaceOrImport(\n\t\t\"ai/dist/api/cloudflare-gateway-binding.js\",\n\t\t\"@bastani/pi-ai\",\n\t);\n\n\t_aliases = {\n\t\t\"@bastani/atomic\": piCodingAgentEntry,\n\t\t\"@earendil-works/pi-coding-agent\": piCodingAgentEntry,\n\t\t\"@earendil-works/pi-agent-core\": piAgentCoreEntry,\n\t\t\"@earendil-works/pi-tui/dist/layout.js\": piTuiLayoutEntry,\n\t\t\"@earendil-works/pi-tui/dist/layout-node.js\": piTuiLayoutNodeEntry,\n\t\t\"@earendil-works/pi-tui\": piTuiEntry,\n\t\t\"@bastani/pi-ai/api/openai-codex-responses\": piAiCodexResponsesEntry,\n\t\t\"@bastani/pi-ai/api/llama-cpp-classify.lazy\": piAiLlamaCppClassifyEntry,\n\t\t\"@bastani/pi-ai/api/typesafe-system-one.lazy\": piAiTypesafeSystemOneEntry,\n\t\t\"@bastani/pi-ai/oauth\": piAiOauthEntry,\n\t\t\"@bastani/pi-ai/models\": piAiModelsEntry,\n\t\t\"@bastani/pi-ai/providers/all\": piAiProvidersEntry,\n\t\t\"@bastani/pi-ai/providers/github-copilot-env\": piAiCopilotEnvEntry,\n\t\t\"@bastani/pi-ai/utils/provider-env\": piAiProviderEnvEntry,\n\t\t\"@bastani/pi-ai/utils/oauth-page\": piAiOauthPageEntry,\n\t\t\"@bastani/pi-ai/compat\": piAiEntry,\n\t\t\"@bastani/pi-ai/api/cloudflare-gateway-binding\": piAiGatewayBindingEntry,\n\t\t\"@bastani/pi-ai\": piAiEntry,\n\t\t\"@earendil-works/pi-ai/api/openai-codex-responses\": piAiCodexResponsesEntry,\n\t\t\"@earendil-works/pi-ai/oauth\": piAiOauthEntry,\n\t\t\"@earendil-works/pi-ai/models\": piAiModelsEntry,\n\t\t\"@earendil-works/pi-ai/providers/all\": piAiProvidersEntry,\n\t\t\"@earendil-works/pi-ai/compat\": piAiEntry,\n\t\t\"@earendil-works/pi-ai/api/cloudflare-gateway-binding\": piAiGatewayBindingEntry,\n\t\t\"@earendil-works/pi-ai/utils/oauth-page\": piAiOauthPageEntry,\n\t\t\"@earendil-works/pi-ai\": piAiEntry,\n\t\t\"@mariozechner/pi-agent-core\": piAgentCoreEntry,\n\t\t\"@mariozechner/pi-tui/dist/layout.js\": piTuiLayoutEntry,\n\t\t\"@mariozechner/pi-tui\": piTuiEntry,\n\t\t\"@mariozechner/pi-ai/oauth\": piAiOauthEntry,\n\t\t\"@mariozechner/pi-ai/models\": piAiModelsEntry,\n\t\t\"@mariozechner/pi-ai/providers/all\": piAiProvidersEntry,\n\t\t\"@mariozechner/pi-ai/compat\": piAiEntry,\n\t\t\"@mariozechner/pi-ai/api/cloudflare-gateway-binding\": piAiGatewayBindingEntry,\n\t\t\"@mariozechner/pi-ai\": piAiEntry,\n\t\ttypebox: typeboxEntry,\n\t\t\"typebox/compile\": typeboxCompileEntry,\n\t\t\"typebox/value\": typeboxValueEntry,\n\t\t\"@sinclair/typebox\": typeboxEntry,\n\t\t\"@sinclair/typebox/compile\": typeboxCompileEntry,\n\t\t\"@sinclair/typebox/value\": typeboxValueEntry,\n\t};\n\n\treturn _aliases;\n}\n\nexport const extensionLoaderTestHooks = {\n\tloadVirtualModules,\n\tgetAliases,\n\tfindPackageRoot,\n\tgetTranspileCacheDir,\n\tgraphManifestPath,\n\treadExtensionGraphManifest,\n\tloadExtensionModuleTransformed: (extensionPath: string, cacheToken?: ExtensionCacheToken) =>\n\t\timportExtensionModule(extensionPath, cacheToken, true),\n\tloadTransformedExtensionModule: (extensionPath: string, cacheToken?: ExtensionCacheToken) =>\n\t\tloadTransformedExtensionModule(extensionPath, cacheToken),\n\tloadNativeBuiltinExtensionModule,\n\thasNativeBuiltinFactory: (extensionPath: string): boolean => nativeBuiltinFactories.has(extensionPath),\n};\n\n/**\n * Extension paths already evaluated via native import() in this process. Bun on\n * Windows ignores the cache-busting query on file URLs, so re-loads of these\n * paths (e.g. /reload) must go through jiti's transformed-import path to get a\n * fresh module evaluation.\n */\nconst nativelyImportedPaths = new Set<string>();\n\nasync function importExtensionModule(\n\textensionPath: string,\n\tcacheToken: ExtensionCacheToken | undefined,\n\tforceTransformedImports: boolean,\n): Promise<ExtensionFactory | undefined> {\n\tconst isWindows = process.platform === \"win32\";\n\tconst isSingleFileBuild = isBunBinary || isBundledBuild;\n\tconst createJitiImpl = await getCreateJiti();\n\tconst jiti = createJitiImpl(resolutionBaseUrl(import.meta.url), {\n\t\tmoduleCache: false,\n\t\tfsCache: false,\n\t\ttransform: getTypeScriptSourceSpecifierTransform(createJitiImpl),\n\t\t...(forceTransformedImports ? { tryNative: false } : {}),\n\t\t// A first native import can fall back to transformation too. Always share\n\t\t// the live host instead of re-evaluating its graph through source aliases.\n\t\tvirtualModules: await getVirtualModules(),\n\t\t...(!isSingleFileBuild ? { alias: getAliases() } : {}),\n\t});\n\tconst specifier = extensionImportSpecifier(extensionPath, cacheToken);\n\t// Transformed evaluations are the loads whose repeat cost is the Windows\n\t// /reload regression, so they are also the loads whose file graph is\n\t// recorded into a content-hash manifest.\n\tlet module: unknown;\n\tlet recordedManifest: ExtensionGraphManifest | undefined;\n\tif (forceTransformedImports) {\n\t\tconst recorded = await recordExtensionGraph(extensionPath, () => jiti.import(specifier, { default: true }));\n\t\tmodule = recorded.result;\n\t\trecordedManifest = recorded.manifest;\n\t} else {\n\t\tmodule = await jiti.import(specifier, { default: true });\n\t}\n\tif (isWindows && !forceTransformedImports) {\n\t\tnativelyImportedPaths.add(extensionPath);\n\t}\n\tlet factory = module as ExtensionFactory;\n\tif (typeof factory !== \"function\") return undefined;\n\tif (recordedManifest) {\n\t\tfactory = withDeferredGraphRecording(extensionPath, factory);\n\t\tretainedTransformedLoads.set(extensionPath, { factory, manifest: recordedManifest });\n\t}\n\tif (isCurrentCacheToken(cacheToken)) {\n\t\textensionCache.set(extensionPath, factory);\n\t}\n\treturn factory;\n}\n\n/**\n * Load an extension through jiti's transformed-import path, reusing the\n * previously evaluated factory when the recorded graph manifest proves the\n * entire transitive file graph is byte-identical. This lets the\n * unchanged-graph case survive the /reload generation bump instead of\n * re-evaluating hundreds of files; anything else re-evaluates as before.\n *\n * Note: when the graph is byte-identical, the previously evaluated module\n * instance (including any mutable module-scoped state it closed over) is\n * reused. An extension that requires clean module state on every reload must\n * change a file in its graph to force re-evaluation.\n */\nasync function loadTransformedExtensionModule(\n\textensionPath: string,\n\tcacheToken: ExtensionCacheToken | undefined,\n): Promise<ExtensionFactory | undefined> {\n\tconst retained = retainedTransformedLoads.get(extensionPath);\n\tif (retained && graphUnchangedSince(retained.manifest)) {\n\t\tif (isCurrentCacheToken(cacheToken)) {\n\t\t\textensionCache.set(extensionPath, retained.factory);\n\t\t}\n\t\treturn retained.factory;\n\t}\n\treturn importExtensionModule(extensionPath, cacheToken, true);\n}\n\nexport async function loadExtensionModule(\n\textensionPath: string,\n\tcacheToken?: ExtensionCacheToken,\n): Promise<ExtensionFactory | undefined> {\n\tconst isSingleFileBuild = isBunBinary || isBundledBuild;\n\tif (isSingleFileBuild && isNativeBuiltinExtensionPath(extensionPath)) {\n\t\treturn loadNativeBuiltinExtensionModule(extensionPath, cacheToken);\n\t}\n\n\tif (isCurrentCacheToken(cacheToken)) {\n\t\tconst cachedFactory = extensionCache.get(extensionPath);\n\t\tif (cachedFactory) return cachedFactory;\n\t}\n\n\tconst isWindows = process.platform === \"win32\";\n\t// Single-file builds (compiled binary or dev bundle) cannot alias host\n\t// package specifiers to files on disk: extensions must share the live\n\t// module instances baked into the build, so virtualModules is used instead\n\t// (which requires jiti's transformed-import path).\n\t// Every editable path retains the existing jiti/virtualModules behavior.\n\t// Windows first-load fast path: native import() (jiti's default tryNative)\n\t// skips per-launch transpilation of the extension module graph. Re-loads of\n\t// the same path fall back to transformed imports for fresh evaluation.\n\t//\n\t// That fallback is not free. Measured on Windows CI, a transformed re-import\n\t// costs ~15 ms per module file in the extension's transitive graph, so a\n\t// reload of all five builtin packages (621 files) takes ~10.7 s cold and\n\t// ~2.5 s against a warm jiti fsCache, against ~40 ms on Linux and macOS. The\n\t// cost is correctness-driven and is paid interactively on every Windows\n\t// `/reload`; removing it needs a content-hash-keyed evaluation cache or a\n\t// narrower trigger, not a larger timeout.\n\tconst forceTransformedImports = isSingleFileBuild || (isWindows && nativelyImportedPaths.has(extensionPath));\n\tif (forceTransformedImports) {\n\t\treturn loadTransformedExtensionModule(extensionPath, cacheToken);\n\t}\n\treturn importExtensionModule(extensionPath, cacheToken, false);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { ImageContent, TextContent } from "@bastani/pi-ai/compat";
2
2
  import type { EditToolDetails } from "../tools/edit.ts";
3
- import type { BashToolDetails, BashToolInput, EditToolInput, FindToolDetails, FindToolInput, LsToolDetails, LsToolInput, PowerShellToolDetails, PowerShellToolInput, ReadToolDetails, ReadToolInput, SearchToolDetails, SearchToolInput, WriteToolInput } from "../tools/index.ts";
3
+ import type { BashToolDetails, BashToolInput, EditToolInput, FindToolDetails, FindToolInput, LsToolDetails, LsToolInput, PowerShellToolDetails, PowerShellToolInput, ReadToolDetails, ReadToolInput, SearchToolDetails, SearchToolInput, WriteToolInput } from "../tools/index.js";
4
4
  interface ToolCallEventBase {
5
5
  type: "tool_call";
6
6
  toolCallId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-events.js","sourceRoot":"","sources":["../../../src/core/extensions/tool-events.ts"],"names":[],"mappings":"AA+JA,kCAAkC;AAClC,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,sBAAsB,CAAC,CAAkB;IACxD,OAAO,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC;AACpC,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,iBAAiB,CAAC,CAAkB;IACnD,OAAO,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC;AAC/B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,CAAkB;IACpD,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAChC,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,CAAkB;IAChD,OAAO,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;AAC5B,CAAC;AAkCD,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,KAAoB;IACzE,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACpC,CAAC","sourcesContent":["import type { ImageContent, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { EditToolDetails } from \"../tools/edit.ts\";\nimport type {\n\tBashToolDetails,\n\tBashToolInput,\n\tEditToolInput,\n\tFindToolDetails,\n\tFindToolInput,\n\tLsToolDetails,\n\tLsToolInput,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tReadToolDetails,\n\tReadToolInput,\n\tSearchToolDetails,\n\tSearchToolInput,\n\tWriteToolInput,\n} from \"../tools/index.ts\";\n\n// ============================================================================\n// Tool Events\n// ============================================================================\n\ninterface ToolCallEventBase {\n\ttype: \"tool_call\";\n\ttoolCallId: string;\n\tparentToolCallId?: string;\n}\n\nexport interface BashToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"bash\";\n\tinput: BashToolInput;\n}\n\nexport interface PowerShellToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"powershell\";\n\tinput: PowerShellToolInput;\n}\n\nexport interface ReadToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"read\";\n\tinput: ReadToolInput;\n}\n\nexport interface EditToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"edit\";\n\tinput: EditToolInput;\n}\n\nexport interface WriteToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"write\";\n\tinput: WriteToolInput;\n}\n\nexport interface FindToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"find\";\n\tinput: FindToolInput;\n}\n\nexport interface SearchToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"search\";\n\tinput: SearchToolInput;\n}\n\nexport interface LsToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"ls\";\n\tinput: LsToolInput;\n}\n\nexport interface CustomToolCallEvent extends ToolCallEventBase {\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n}\n\n/**\n * Fired before a tool executes. Can block.\n *\n * `event.input` is mutable. Mutate it in place to patch tool arguments before execution.\n * Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.\n */\nexport type ToolCallEvent =\n\t| BashToolCallEvent\n\t| PowerShellToolCallEvent\n\t| ReadToolCallEvent\n\t| EditToolCallEvent\n\t| WriteToolCallEvent\n\t| FindToolCallEvent\n\t| SearchToolCallEvent\n\t| LsToolCallEvent\n\t| CustomToolCallEvent;\n\ninterface ToolResultEventBase {\n\ttype: \"tool_result\";\n\ttoolCallId: string;\n\tparentToolCallId?: string;\n\tstructuredContent?: import(\"@bastani/pi-ai\").JsonValue;\n\tusage?: import(\"@bastani/pi-ai\").Usage;\n\tinput: Record<string, unknown>;\n\tcontent: (TextContent | ImageContent)[];\n\tisError: boolean;\n}\n\nexport interface BashToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"bash\";\n\tdetails: BashToolDetails | undefined;\n}\n\nexport interface PowerShellToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"powershell\";\n\tdetails: PowerShellToolDetails | undefined;\n}\n\nexport interface ReadToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"read\";\n\tdetails: ReadToolDetails | undefined;\n}\n\nexport interface EditToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"edit\";\n\tdetails: EditToolDetails | undefined;\n}\n\nexport interface WriteToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"write\";\n\tdetails: undefined;\n}\n\nexport interface FindToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"find\";\n\tdetails: FindToolDetails | undefined;\n}\n\nexport interface SearchToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"search\";\n\tdetails: SearchToolDetails | undefined;\n}\n\nexport interface LsToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"ls\";\n\tdetails: LsToolDetails | undefined;\n}\n\nexport interface CustomToolResultEvent extends ToolResultEventBase {\n\ttoolName: string;\n\tdetails: unknown;\n}\n\n/** Fired after a tool executes. Can modify result. */\nexport type ToolResultEvent =\n\t| BashToolResultEvent\n\t| PowerShellToolResultEvent\n\t| ReadToolResultEvent\n\t| EditToolResultEvent\n\t| WriteToolResultEvent\n\t| FindToolResultEvent\n\t| SearchToolResultEvent\n\t| LsToolResultEvent\n\t| CustomToolResultEvent;\n\n// Type guards for ToolResultEvent\nexport function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent {\n\treturn e.toolName === \"bash\";\n}\nexport function isPowerShellToolResult(e: ToolResultEvent): e is PowerShellToolResultEvent {\n\treturn e.toolName === \"powershell\";\n}\nexport function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent {\n\treturn e.toolName === \"read\";\n}\nexport function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent {\n\treturn e.toolName === \"edit\";\n}\nexport function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent {\n\treturn e.toolName === \"write\";\n}\nexport function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent {\n\treturn e.toolName === \"find\";\n}\nexport function isSearchToolResult(e: ToolResultEvent): e is SearchToolResultEvent {\n\treturn e.toolName === \"search\";\n}\nexport function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent {\n\treturn e.toolName === \"ls\";\n}\n\n/**\n * Type guard for narrowing ToolCallEvent by tool name.\n *\n * Built-in tools narrow automatically (no type params needed):\n * ```ts\n * if (isToolCallEventType(\"bash\", event)) {\n * event.input.command; // string\n * }\n * ```\n *\n * Custom tools require explicit type parameters:\n * ```ts\n * if (isToolCallEventType<\"my_tool\", MyToolInput>(\"my_tool\", event)) {\n * event.input.action; // typed\n * }\n * ```\n *\n * Note: Direct narrowing via `event.toolName === \"bash\"` doesn't work because\n * CustomToolCallEvent.toolName is `string` which overlaps with all literals.\n */\nexport function isToolCallEventType(toolName: \"bash\", event: ToolCallEvent): event is BashToolCallEvent;\nexport function isToolCallEventType(toolName: \"powershell\", event: ToolCallEvent): event is PowerShellToolCallEvent;\nexport function isToolCallEventType(toolName: \"read\", event: ToolCallEvent): event is ReadToolCallEvent;\nexport function isToolCallEventType(toolName: \"edit\", event: ToolCallEvent): event is EditToolCallEvent;\nexport function isToolCallEventType(toolName: \"write\", event: ToolCallEvent): event is WriteToolCallEvent;\nexport function isToolCallEventType(toolName: \"find\", event: ToolCallEvent): event is FindToolCallEvent;\nexport function isToolCallEventType(toolName: \"search\", event: ToolCallEvent): event is SearchToolCallEvent;\nexport function isToolCallEventType(toolName: \"ls\", event: ToolCallEvent): event is LsToolCallEvent;\nexport function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(\n\ttoolName: TName,\n\tevent: ToolCallEvent,\n): event is ToolCallEvent & { toolName: TName; input: TInput };\nexport function isToolCallEventType(toolName: string, event: ToolCallEvent): boolean {\n\treturn event.toolName === toolName;\n}\n"]}
1
+ {"version":3,"file":"tool-events.js","sourceRoot":"","sources":["../../../src/core/extensions/tool-events.ts"],"names":[],"mappings":"AA+JA,kCAAkC;AAClC,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,sBAAsB,CAAC,CAAkB;IACxD,OAAO,CAAC,CAAC,QAAQ,KAAK,YAAY,CAAC;AACpC,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,iBAAiB,CAAC,CAAkB;IACnD,OAAO,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC;AAC/B,CAAC;AACD,MAAM,UAAU,gBAAgB,CAAC,CAAkB;IAClD,OAAO,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;AAC9B,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,CAAkB;IACpD,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC;AAChC,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,CAAkB;IAChD,OAAO,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC;AAC5B,CAAC;AAkCD,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,KAAoB;IACzE,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC;AACpC,CAAC","sourcesContent":["import type { ImageContent, TextContent } from \"@bastani/pi-ai/compat\";\nimport type { EditToolDetails } from \"../tools/edit.ts\";\nimport type {\n\tBashToolDetails,\n\tBashToolInput,\n\tEditToolInput,\n\tFindToolDetails,\n\tFindToolInput,\n\tLsToolDetails,\n\tLsToolInput,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tReadToolDetails,\n\tReadToolInput,\n\tSearchToolDetails,\n\tSearchToolInput,\n\tWriteToolInput,\n} from \"../tools/index.js\";\n\n// ============================================================================\n// Tool Events\n// ============================================================================\n\ninterface ToolCallEventBase {\n\ttype: \"tool_call\";\n\ttoolCallId: string;\n\tparentToolCallId?: string;\n}\n\nexport interface BashToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"bash\";\n\tinput: BashToolInput;\n}\n\nexport interface PowerShellToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"powershell\";\n\tinput: PowerShellToolInput;\n}\n\nexport interface ReadToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"read\";\n\tinput: ReadToolInput;\n}\n\nexport interface EditToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"edit\";\n\tinput: EditToolInput;\n}\n\nexport interface WriteToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"write\";\n\tinput: WriteToolInput;\n}\n\nexport interface FindToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"find\";\n\tinput: FindToolInput;\n}\n\nexport interface SearchToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"search\";\n\tinput: SearchToolInput;\n}\n\nexport interface LsToolCallEvent extends ToolCallEventBase {\n\ttoolName: \"ls\";\n\tinput: LsToolInput;\n}\n\nexport interface CustomToolCallEvent extends ToolCallEventBase {\n\ttoolName: string;\n\tinput: Record<string, unknown>;\n}\n\n/**\n * Fired before a tool executes. Can block.\n *\n * `event.input` is mutable. Mutate it in place to patch tool arguments before execution.\n * Later `tool_call` handlers see earlier mutations. No re-validation is performed after mutation.\n */\nexport type ToolCallEvent =\n\t| BashToolCallEvent\n\t| PowerShellToolCallEvent\n\t| ReadToolCallEvent\n\t| EditToolCallEvent\n\t| WriteToolCallEvent\n\t| FindToolCallEvent\n\t| SearchToolCallEvent\n\t| LsToolCallEvent\n\t| CustomToolCallEvent;\n\ninterface ToolResultEventBase {\n\ttype: \"tool_result\";\n\ttoolCallId: string;\n\tparentToolCallId?: string;\n\tstructuredContent?: import(\"@bastani/pi-ai\").JsonValue;\n\tusage?: import(\"@bastani/pi-ai\").Usage;\n\tinput: Record<string, unknown>;\n\tcontent: (TextContent | ImageContent)[];\n\tisError: boolean;\n}\n\nexport interface BashToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"bash\";\n\tdetails: BashToolDetails | undefined;\n}\n\nexport interface PowerShellToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"powershell\";\n\tdetails: PowerShellToolDetails | undefined;\n}\n\nexport interface ReadToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"read\";\n\tdetails: ReadToolDetails | undefined;\n}\n\nexport interface EditToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"edit\";\n\tdetails: EditToolDetails | undefined;\n}\n\nexport interface WriteToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"write\";\n\tdetails: undefined;\n}\n\nexport interface FindToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"find\";\n\tdetails: FindToolDetails | undefined;\n}\n\nexport interface SearchToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"search\";\n\tdetails: SearchToolDetails | undefined;\n}\n\nexport interface LsToolResultEvent extends ToolResultEventBase {\n\ttoolName: \"ls\";\n\tdetails: LsToolDetails | undefined;\n}\n\nexport interface CustomToolResultEvent extends ToolResultEventBase {\n\ttoolName: string;\n\tdetails: unknown;\n}\n\n/** Fired after a tool executes. Can modify result. */\nexport type ToolResultEvent =\n\t| BashToolResultEvent\n\t| PowerShellToolResultEvent\n\t| ReadToolResultEvent\n\t| EditToolResultEvent\n\t| WriteToolResultEvent\n\t| FindToolResultEvent\n\t| SearchToolResultEvent\n\t| LsToolResultEvent\n\t| CustomToolResultEvent;\n\n// Type guards for ToolResultEvent\nexport function isBashToolResult(e: ToolResultEvent): e is BashToolResultEvent {\n\treturn e.toolName === \"bash\";\n}\nexport function isPowerShellToolResult(e: ToolResultEvent): e is PowerShellToolResultEvent {\n\treturn e.toolName === \"powershell\";\n}\nexport function isReadToolResult(e: ToolResultEvent): e is ReadToolResultEvent {\n\treturn e.toolName === \"read\";\n}\nexport function isEditToolResult(e: ToolResultEvent): e is EditToolResultEvent {\n\treturn e.toolName === \"edit\";\n}\nexport function isWriteToolResult(e: ToolResultEvent): e is WriteToolResultEvent {\n\treturn e.toolName === \"write\";\n}\nexport function isFindToolResult(e: ToolResultEvent): e is FindToolResultEvent {\n\treturn e.toolName === \"find\";\n}\nexport function isSearchToolResult(e: ToolResultEvent): e is SearchToolResultEvent {\n\treturn e.toolName === \"search\";\n}\nexport function isLsToolResult(e: ToolResultEvent): e is LsToolResultEvent {\n\treturn e.toolName === \"ls\";\n}\n\n/**\n * Type guard for narrowing ToolCallEvent by tool name.\n *\n * Built-in tools narrow automatically (no type params needed):\n * ```ts\n * if (isToolCallEventType(\"bash\", event)) {\n * event.input.command; // string\n * }\n * ```\n *\n * Custom tools require explicit type parameters:\n * ```ts\n * if (isToolCallEventType<\"my_tool\", MyToolInput>(\"my_tool\", event)) {\n * event.input.action; // typed\n * }\n * ```\n *\n * Note: Direct narrowing via `event.toolName === \"bash\"` doesn't work because\n * CustomToolCallEvent.toolName is `string` which overlaps with all literals.\n */\nexport function isToolCallEventType(toolName: \"bash\", event: ToolCallEvent): event is BashToolCallEvent;\nexport function isToolCallEventType(toolName: \"powershell\", event: ToolCallEvent): event is PowerShellToolCallEvent;\nexport function isToolCallEventType(toolName: \"read\", event: ToolCallEvent): event is ReadToolCallEvent;\nexport function isToolCallEventType(toolName: \"edit\", event: ToolCallEvent): event is EditToolCallEvent;\nexport function isToolCallEventType(toolName: \"write\", event: ToolCallEvent): event is WriteToolCallEvent;\nexport function isToolCallEventType(toolName: \"find\", event: ToolCallEvent): event is FindToolCallEvent;\nexport function isToolCallEventType(toolName: \"search\", event: ToolCallEvent): event is SearchToolCallEvent;\nexport function isToolCallEventType(toolName: \"ls\", event: ToolCallEvent): event is LsToolCallEvent;\nexport function isToolCallEventType<TName extends string, TInput extends Record<string, unknown>>(\n\ttoolName: TName,\n\tevent: ToolCallEvent,\n): event is ToolCallEvent & { toolName: TName; input: TInput };\nexport function isToolCallEventType(toolName: string, event: ToolCallEvent): boolean {\n\treturn event.toolName === toolName;\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { createJiti } from "jiti";
2
+ type CreateJiti = typeof createJiti;
3
+ type JitiTransform = NonNullable<NonNullable<Parameters<CreateJiti>[1]>["transform"]>;
4
+ /**
5
+ * jiti tries a `./x.js` import of `x.ts` against every resolution condition,
6
+ * base URL, and extension before its `.js` -> `.ts` fallback, and each miss
7
+ * throws. Naming the TypeScript source that fallback would select resolves it
8
+ * on the first probe.
9
+ */
10
+ export declare function typeScriptSourceSpecifier(specifier: string, importer: string): string | undefined;
11
+ /**
12
+ * A jiti `transform` that runs jiti's own Babel transform plus the specifier
13
+ * rewrite. Use it with jiti's `fsCache: false`: jiti keys its cache on the
14
+ * importer source alone, while a rewrite also depends on which siblings exist.
15
+ */
16
+ export declare function createTypeScriptSourceSpecifierTransform(createJitiImpl: CreateJiti, id: string, cacheDir: () => string | undefined): JitiTransform;
17
+ export {};
18
+ //# sourceMappingURL=ts-source-specifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-source-specifiers.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/ts-source-specifiers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,KAAK,UAAU,GAAG,OAAO,UAAU,CAAC;AACpC,KAAK,aAAa,GAAG,WAAW,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AAatF;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQjG;AA0GD;;;;GAIG;AACH,wBAAgB,wCAAwC,CACvD,cAAc,EAAE,UAAU,EAC1B,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,MAAM,GAAG,SAAS,GAChC,aAAa,CAmBf"}
@@ -0,0 +1,142 @@
1
+ import * as crypto from "node:crypto";
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ const TRANSFORM_CACHE_FORMAT = 1;
5
+ const RELATIVE_SCRIPT_SPECIFIER = /["'](\.\.?\/[^"'\r\n]*?\.[cm]?jsx?)["']/g;
6
+ const SCRIPT_EXTENSION = /\.[cm]?jsx?$/;
7
+ const TYPESCRIPT_EXTENSION_FOR = {
8
+ ".js": ".ts",
9
+ ".mjs": ".mts",
10
+ ".cjs": ".cts",
11
+ ".jsx": ".tsx",
12
+ };
13
+ /**
14
+ * jiti tries a `./x.js` import of `x.ts` against every resolution condition,
15
+ * base URL, and extension before its `.js` -> `.ts` fallback, and each miss
16
+ * throws. Naming the TypeScript source that fallback would select resolves it
17
+ * on the first probe.
18
+ */
19
+ export function typeScriptSourceSpecifier(specifier, importer) {
20
+ const scriptExtension = SCRIPT_EXTENSION.exec(specifier)?.[0];
21
+ if (!scriptExtension || !(specifier.startsWith("./") || specifier.startsWith("../")))
22
+ return undefined;
23
+ const typeScriptSpecifier = specifier.slice(0, -scriptExtension.length) + TYPESCRIPT_EXTENSION_FOR[scriptExtension];
24
+ const directory = path.dirname(importer);
25
+ if (fs.existsSync(path.resolve(directory, specifier)))
26
+ return undefined;
27
+ if (!fs.existsSync(path.resolve(directory, typeScriptSpecifier)))
28
+ return undefined;
29
+ return typeScriptSpecifier;
30
+ }
31
+ /** Every rewrite this source can receive; part of the cache key, so a sibling change re-transforms. */
32
+ function planRewrites(source, importer) {
33
+ const rewrites = new Map();
34
+ for (const [, specifier] of source.matchAll(RELATIVE_SCRIPT_SPECIFIER)) {
35
+ if (!specifier || rewrites.has(specifier))
36
+ continue;
37
+ const rewritten = typeScriptSourceSpecifier(specifier, importer);
38
+ if (rewritten !== undefined)
39
+ rewrites.set(specifier, rewritten);
40
+ }
41
+ return rewrites;
42
+ }
43
+ function rewriteSource(literal, rewrites) {
44
+ if (literal?.type !== "StringLiteral" || typeof literal.value !== "string")
45
+ return;
46
+ const rewritten = rewrites.get(literal.value);
47
+ if (rewritten === undefined)
48
+ return;
49
+ literal.value = rewritten;
50
+ literal.extra = undefined;
51
+ }
52
+ function isModuleLoadCall(nodePath) {
53
+ const callee = nodePath.node.callee;
54
+ if (callee?.type === "Import")
55
+ return true;
56
+ return callee?.type === "Identifier" && callee.name === "require" && !nodePath.scope.hasBinding("require");
57
+ }
58
+ function typeScriptSourceSpecifierPlugin(_babel, options) {
59
+ return {
60
+ name: "atomic-typescript-source-specifiers",
61
+ visitor: {
62
+ "ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration"(nodePath) {
63
+ rewriteSource(nodePath.node.source, options.rewrites);
64
+ },
65
+ ImportExpression(nodePath) {
66
+ rewriteSource(nodePath.node.source, options.rewrites);
67
+ },
68
+ CallExpression(nodePath) {
69
+ if (isModuleLoadCall(nodePath))
70
+ rewriteSource(nodePath.node.arguments?.[0], options.rewrites);
71
+ },
72
+ },
73
+ };
74
+ }
75
+ function cacheFile(cacheDir, options, rewrites) {
76
+ const key = crypto
77
+ .createHash("sha256")
78
+ .update(JSON.stringify([
79
+ TRANSFORM_CACHE_FORMAT,
80
+ options.filename,
81
+ options.async,
82
+ options.ts,
83
+ options.jsx,
84
+ options.interopDefault,
85
+ options.retainLines,
86
+ options.babel?.sourceMaps,
87
+ [...rewrites],
88
+ options.source,
89
+ ]))
90
+ .digest("hex")
91
+ .slice(0, 32);
92
+ const name = path.basename(options.filename ?? "module").replace(/[^\w.-]/g, "_");
93
+ return path.join(cacheDir, `${name}.${key}.${options.async ? "mjs" : "cjs"}`);
94
+ }
95
+ function readCached(file) {
96
+ try {
97
+ return fs.readFileSync(file, "utf8");
98
+ }
99
+ catch {
100
+ return undefined;
101
+ }
102
+ }
103
+ function writeCached(file, code) {
104
+ const temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
105
+ try {
106
+ fs.mkdirSync(path.dirname(file), { recursive: true });
107
+ fs.writeFileSync(temporary, code, "utf8");
108
+ fs.renameSync(temporary, file);
109
+ }
110
+ catch {
111
+ fs.rmSync(temporary, { force: true });
112
+ }
113
+ }
114
+ /**
115
+ * A jiti `transform` that runs jiti's own Babel transform plus the specifier
116
+ * rewrite. Use it with jiti's `fsCache: false`: jiti keys its cache on the
117
+ * importer source alone, while a rewrite also depends on which siblings exist.
118
+ */
119
+ export function createTypeScriptSourceSpecifierTransform(createJitiImpl, id, cacheDir) {
120
+ const babelHost = createJitiImpl(id, { fsCache: false, moduleCache: false });
121
+ return (options) => {
122
+ if (!options.filename)
123
+ return { code: babelHost.transform(options) };
124
+ const rewrites = planRewrites(options.source, options.filename);
125
+ const directory = cacheDir();
126
+ const cached = directory ? cacheFile(directory, options, rewrites) : undefined;
127
+ const hit = cached ? readCached(cached) : undefined;
128
+ if (hit !== undefined)
129
+ return { code: hit };
130
+ const plugins = Array.isArray(options.babel?.plugins)
131
+ ? options.babel.plugins
132
+ : [];
133
+ const code = babelHost.transform({
134
+ ...options,
135
+ babel: { ...options.babel, plugins: [...plugins, [typeScriptSourceSpecifierPlugin, { rewrites }]] },
136
+ });
137
+ if (cached && !code.includes("__JITI_ERROR__"))
138
+ writeCached(cached, code);
139
+ return { code };
140
+ };
141
+ }
142
+ //# sourceMappingURL=ts-source-specifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-source-specifiers.js","sourceRoot":"","sources":["../../../src/core/extensions/ts-source-specifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAOlC,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,yBAAyB,GAAG,0CAA0C,CAAC;AAC7E,MAAM,gBAAgB,GAAG,cAAc,CAAC;AACxC,MAAM,wBAAwB,GAAqC;IAClE,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,SAAiB,EAAE,QAAgB;IAC5E,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9D,IAAI,CAAC,eAAe,IAAI,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC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K,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,+BAA+B,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;SACnG,CAAC,CAAC;QACH,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC1E,OAAO,EAAE,IAAI,EAAE,CAAC;IACjB,CAAC,CAAC;AACH,CAAC","sourcesContent":["import * as crypto from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { createJiti } from \"jiti\";\n\ntype CreateJiti = typeof createJiti;\ntype JitiTransform = NonNullable<NonNullable<Parameters<CreateJiti>[1]>[\"transform\"]>;\ntype JitiTransformOptions = Parameters<JitiTransform>[0];\n\nconst TRANSFORM_CACHE_FORMAT = 1;\nconst RELATIVE_SCRIPT_SPECIFIER = /[\"'](\\.\\.?\\/[^\"'\\r\\n]*?\\.[cm]?jsx?)[\"']/g;\nconst SCRIPT_EXTENSION = /\\.[cm]?jsx?$/;\nconst TYPESCRIPT_EXTENSION_FOR: Readonly<Record<string, string>> = {\n\t\".js\": \".ts\",\n\t\".mjs\": \".mts\",\n\t\".cjs\": \".cts\",\n\t\".jsx\": \".tsx\",\n};\n\n/**\n * jiti tries a `./x.js` import of `x.ts` against every resolution condition,\n * base URL, and extension before its `.js` -> `.ts` fallback, and each miss\n * throws. Naming the TypeScript source that fallback would select resolves it\n * on the first probe.\n */\nexport function typeScriptSourceSpecifier(specifier: string, importer: string): string | undefined {\n\tconst scriptExtension = SCRIPT_EXTENSION.exec(specifier)?.[0];\n\tif (!scriptExtension || !(specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))) return undefined;\n\tconst typeScriptSpecifier = specifier.slice(0, -scriptExtension.length) + TYPESCRIPT_EXTENSION_FOR[scriptExtension];\n\tconst directory = path.dirname(importer);\n\tif (fs.existsSync(path.resolve(directory, specifier))) return undefined;\n\tif (!fs.existsSync(path.resolve(directory, typeScriptSpecifier))) return undefined;\n\treturn typeScriptSpecifier;\n}\n\n/** Every rewrite this source can receive; part of the cache key, so a sibling change re-transforms. */\nfunction planRewrites(source: string, importer: string): ReadonlyMap<string, string> {\n\tconst rewrites = new Map<string, string>();\n\tfor (const [, specifier] of source.matchAll(RELATIVE_SCRIPT_SPECIFIER)) {\n\t\tif (!specifier || rewrites.has(specifier)) continue;\n\t\tconst rewritten = typeScriptSourceSpecifier(specifier, importer);\n\t\tif (rewritten !== undefined) rewrites.set(specifier, rewritten);\n\t}\n\treturn rewrites;\n}\n\ninterface StringLiteralNode {\n\ttype: string;\n\tvalue?: string;\n\textra?: object;\n}\n\ninterface ModuleSourceNode {\n\tsource?: StringLiteralNode | null;\n}\n\ninterface CallNode {\n\tcallee?: { type: string; name?: string };\n\targuments?: StringLiteralNode[];\n}\n\ninterface NodePath<Node> {\n\tnode: Node;\n\tscope: { hasBinding(name: string): boolean };\n}\n\nfunction rewriteSource(literal: StringLiteralNode | null | undefined, rewrites: ReadonlyMap<string, string>): void {\n\tif (literal?.type !== \"StringLiteral\" || typeof literal.value !== \"string\") return;\n\tconst rewritten = rewrites.get(literal.value);\n\tif (rewritten === undefined) return;\n\tliteral.value = rewritten;\n\tliteral.extra = undefined;\n}\n\nfunction isModuleLoadCall(nodePath: NodePath<CallNode>): boolean {\n\tconst callee = nodePath.node.callee;\n\tif (callee?.type === \"Import\") return true;\n\treturn callee?.type === \"Identifier\" && callee.name === \"require\" && !nodePath.scope.hasBinding(\"require\");\n}\n\nfunction typeScriptSourceSpecifierPlugin(_babel: object, options: { rewrites: ReadonlyMap<string, string> }) {\n\treturn {\n\t\tname: \"atomic-typescript-source-specifiers\",\n\t\tvisitor: {\n\t\t\t\"ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration\"(nodePath: NodePath<ModuleSourceNode>) {\n\t\t\t\trewriteSource(nodePath.node.source, options.rewrites);\n\t\t\t},\n\t\t\tImportExpression(nodePath: NodePath<ModuleSourceNode>) {\n\t\t\t\trewriteSource(nodePath.node.source, options.rewrites);\n\t\t\t},\n\t\t\tCallExpression(nodePath: NodePath<CallNode>) {\n\t\t\t\tif (isModuleLoadCall(nodePath)) rewriteSource(nodePath.node.arguments?.[0], options.rewrites);\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction cacheFile(cacheDir: string, options: JitiTransformOptions, rewrites: ReadonlyMap<string, string>): string {\n\tconst key = crypto\n\t\t.createHash(\"sha256\")\n\t\t.update(\n\t\t\tJSON.stringify([\n\t\t\t\tTRANSFORM_CACHE_FORMAT,\n\t\t\t\toptions.filename,\n\t\t\t\toptions.async,\n\t\t\t\toptions.ts,\n\t\t\t\toptions.jsx,\n\t\t\t\toptions.interopDefault,\n\t\t\t\toptions.retainLines,\n\t\t\t\toptions.babel?.sourceMaps,\n\t\t\t\t[...rewrites],\n\t\t\t\toptions.source,\n\t\t\t]),\n\t\t)\n\t\t.digest(\"hex\")\n\t\t.slice(0, 32);\n\tconst name = path.basename(options.filename ?? \"module\").replace(/[^\\w.-]/g, \"_\");\n\treturn path.join(cacheDir, `${name}.${key}.${options.async ? \"mjs\" : \"cjs\"}`);\n}\n\nfunction readCached(file: string): string | undefined {\n\ttry {\n\t\treturn fs.readFileSync(file, \"utf8\");\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction writeCached(file: string, code: string): void {\n\tconst temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;\n\ttry {\n\t\tfs.mkdirSync(path.dirname(file), { recursive: true });\n\t\tfs.writeFileSync(temporary, code, \"utf8\");\n\t\tfs.renameSync(temporary, file);\n\t} catch {\n\t\tfs.rmSync(temporary, { force: true });\n\t}\n}\n\n/**\n * A jiti `transform` that runs jiti's own Babel transform plus the specifier\n * rewrite. Use it with jiti's `fsCache: false`: jiti keys its cache on the\n * importer source alone, while a rewrite also depends on which siblings exist.\n */\nexport function createTypeScriptSourceSpecifierTransform(\n\tcreateJitiImpl: CreateJiti,\n\tid: string,\n\tcacheDir: () => string | undefined,\n): JitiTransform {\n\tconst babelHost = createJitiImpl(id, { fsCache: false, moduleCache: false });\n\treturn (options: JitiTransformOptions) => {\n\t\tif (!options.filename) return { code: babelHost.transform(options) };\n\t\tconst rewrites = planRewrites(options.source, options.filename);\n\t\tconst directory = cacheDir();\n\t\tconst cached = directory ? cacheFile(directory, options, rewrites) : undefined;\n\t\tconst hit = cached ? readCached(cached) : undefined;\n\t\tif (hit !== undefined) return { code: hit };\n\t\tconst plugins: ReadonlyArray<string | object> = Array.isArray(options.babel?.plugins)\n\t\t\t? options.babel.plugins\n\t\t\t: [];\n\t\tconst code = babelHost.transform({\n\t\t\t...options,\n\t\t\tbabel: { ...options.babel, plugins: [...plugins, [typeScriptSourceSpecifierPlugin, { rewrites }]] },\n\t\t});\n\t\tif (cached && !code.includes(\"__JITI_ERROR__\")) writeCached(cached, code);\n\t\treturn { code };\n\t};\n}\n"]}
@@ -4,6 +4,6 @@ export type { AgentSettledEvent, BeforeProviderHeadersEvent, EntryRenderer, Entr
4
4
  export { isPowerShellToolResult } from "./extensions/index.js";
5
5
  export type { PromptTemplate } from "./prompt-templates.ts";
6
6
  export type { Skill } from "./skills.ts";
7
- export type { JsonObject, JsonPrimitive, JsonValue, PowerShellOperations, PowerShellSpawnContext, PowerShellSpawnHook, PowerShellToolDetails, PowerShellToolInput, PowerShellToolOptions, ShellToolPresentation, StructuredOutputCapture, StructuredOutputFileCapture, StructuredOutputToolOptions, Tool, } from "./tools/index.ts";
8
- export { BASH_SHELL_PRESENTATION, createBashTool, createCodingTools, createEditTool, createFindTool, createKillTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.ts";
7
+ export type { JsonObject, JsonPrimitive, JsonValue, PowerShellOperations, PowerShellSpawnContext, PowerShellSpawnHook, PowerShellToolDetails, PowerShellToolInput, PowerShellToolOptions, ShellToolPresentation, StructuredOutputCapture, StructuredOutputFileCapture, StructuredOutputToolOptions, Tool, } from "./tools/index.js";
8
+ export { BASH_SHELL_PRESENTATION, createBashTool, createCodingTools, createEditTool, createFindTool, createKillTool, createLocalPowerShellOperations, createLsTool, createPowerShellTool, createPowerShellToolDefinition, createReadOnlyTools, createReadTool, createSearchTool, createStructuredOutputCapture, createStructuredOutputTool, createWriteTool, STRUCTURED_OUTPUT_TOOL_NAME, withFileMutationQueue, } from "./tools/index.js";
9
9
  //# sourceMappingURL=sdk-exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAmB/D,OAAO,EACN,uBAAuB,EACvB,cAAc;AACd,kCAAkC;AAClC,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC","sourcesContent":["export { getPowerShellConfig } from \"../utils/shell.ts\";\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tAgentSettledEvent,\n\tBeforeProviderHeadersEvent,\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tInlineExtension,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tPowerShellToolCallEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n} from \"./extensions/index.js\";\nexport { isPowerShellToolResult } from \"./extensions/index.js\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tPowerShellOperations,\n\tPowerShellSpawnContext,\n\tPowerShellSpawnHook,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tPowerShellToolOptions,\n\tShellToolPresentation,\n\tStructuredOutputCapture,\n\tStructuredOutputFileCapture,\n\tStructuredOutputToolOptions,\n\tTool,\n} from \"./tools/index.ts\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateKillTool,\n\tcreateLocalPowerShellOperations,\n\tcreateLsTool,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateSearchTool,\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\tcreateWriteTool,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\twithFileMutationQueue,\n} from \"./tools/index.ts\";\n"]}
1
+ {"version":3,"file":"sdk-exports.js","sourceRoot":"","sources":["../../src/core/sdk-exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAsB3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAmB/D,OAAO,EACN,uBAAuB,EACvB,cAAc;AACd,kCAAkC;AAClC,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,+BAA+B,EAC/B,YAAY,EACZ,oBAAoB,EACpB,8BAA8B,EAC9B,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,6BAA6B,EAC7B,0BAA0B,EAC1B,eAAe,EACf,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,kBAAkB,CAAC","sourcesContent":["export { getPowerShellConfig } from \"../utils/shell.ts\";\nexport * from \"./agent-session-runtime.ts\";\nexport type {\n\tAgentSettledEvent,\n\tBeforeProviderHeadersEvent,\n\tEntryRenderer,\n\tEntryRenderOptions,\n\tExtensionAPI,\n\tExtensionCommandContext,\n\tExtensionContext,\n\tExtensionFactory,\n\tInlineExtension,\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tPowerShellToolCallEvent,\n\tSlashCommandInfo,\n\tSlashCommandSource,\n\tToolDefinition,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n} from \"./extensions/index.js\";\nexport { isPowerShellToolResult } from \"./extensions/index.js\";\nexport type { PromptTemplate } from \"./prompt-templates.ts\";\nexport type { Skill } from \"./skills.ts\";\nexport type {\n\tJsonObject,\n\tJsonPrimitive,\n\tJsonValue,\n\tPowerShellOperations,\n\tPowerShellSpawnContext,\n\tPowerShellSpawnHook,\n\tPowerShellToolDetails,\n\tPowerShellToolInput,\n\tPowerShellToolOptions,\n\tShellToolPresentation,\n\tStructuredOutputCapture,\n\tStructuredOutputFileCapture,\n\tStructuredOutputToolOptions,\n\tTool,\n} from \"./tools/index.js\";\nexport {\n\tBASH_SHELL_PRESENTATION,\n\tcreateBashTool,\n\t// Tool factories (for custom cwd)\n\tcreateCodingTools,\n\tcreateEditTool,\n\tcreateFindTool,\n\tcreateKillTool,\n\tcreateLocalPowerShellOperations,\n\tcreateLsTool,\n\tcreatePowerShellTool,\n\tcreatePowerShellToolDefinition,\n\tcreateReadOnlyTools,\n\tcreateReadTool,\n\tcreateSearchTool,\n\tcreateStructuredOutputCapture,\n\tcreateStructuredOutputTool,\n\tcreateWriteTool,\n\tSTRUCTURED_OUTPUT_TOOL_NAME,\n\twithFileMutationQueue,\n} from \"./tools/index.js\";\n"]}
@@ -56,6 +56,9 @@ export interface CreateAgentSessionOptions {
56
56
  * an entry starts with `mcp__`; only matching tools are declared directly.
57
57
  * `excludedTools` applies afterwards. `noTools: "all"` overrides this selection.
58
58
  * Intercom follows the same selection and suppression rules as other extension tools.
59
+ * A list of only `+name`/`-name` entries changes the resolved defaults instead
60
+ * of allowlisting tools, and is reapplied on reload. Modifiers take exact names;
61
+ * mixing them with plain names or patterns throws. Total suppression still wins.
59
62
  */
60
63
  tools?: string[];
61
64
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-types.d.ts","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EACX,oBAAoB,EACpB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,KAAK,GAAG,YAAY,GAAG,UAAU,CAAC;AAE1F,MAAM,WAAW,yBAAyB;IACzC,2FAA2F;IAC3F,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cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,2DAA2D;IAC3D,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,uEAAuE;IACvE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,2FAA2F;IAC3F,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,8EAA8E;IAC9E,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAC5C,gEAAgE;IAChE,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,gCAAgC,EAAE,qBAAqB,CAAC;IACxF,kFAAkF;IAClF,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACnD,gFAAgF;IAChF,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,CAAC;CACvE;AAED,qCAAqC;AACrC,MAAM,WAAW,wBAAwB;IACxC,0BAA0B;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,mEAAmE;IACnE,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk-types.js","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSession } from \"./agent-session.js\";\nimport type { ExtensionBindings } from \"./agent-session-types.js\";\nimport type {\n\tLoadExtensionsResult,\n\tOrchestrationContext,\n\tSessionStartEvent,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { ModelFallbackReason } from \"./model-resolver-types.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\n\nexport type AtomicBuiltin = \"workflows\" | \"subagents\" | \"mcp\" | \"web-access\" | \"intercom\";\n\nexport interface CreateAgentSessionOptions {\n\t/** Shipped packages are enabled unless explicitly false. Independent of tool selection. */\n\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>;\n\t/** Working directory for project-local discovery. Default: process.cwd() */\n\tcwd?: string;\n\t/** Global config directory. Default: ~/.atomic/agent */\n\tagentDir?: string;\n\n\t/** Canonical model/auth runtime. Defaults to agentDir/auth.json and models.json. */\n\tmodelRuntime?: ModelRuntime;\n\n\t/** Model to use. Default: from settings, else first available */\n\tmodel?: Model<Api>;\n\t/** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n\tthinkingLevel?: ThinkingLevel;\n\t/**\n\t * Ordered fallback models as provider/model strings with optional :thinkingLevel suffix.\n\t * Used by main-chat turns and borrowed, planner-only, for compaction range planning when\n\t * the current model cannot produce a usable plan — so a configured candidate may receive\n\t * the compaction transcript. Borrowing never changes the session model or thinking level.\n\t * Default: settings.fallbackModels\n\t */\n\tfallbackModels?: string[];\n\t/** Hard eligibility gate applied before fallback inference, including compaction borrowing. */\n\tisFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\t/** Models available for cycling (Ctrl+P in interactive mode) */\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n\t/**\n\t * Tool suppression mode.\n\t *\n\t * - \"all\": no active tools, even with an explicit allowlist\n\t * - \"builtin\": suppress coding-tool defaults only when tools is omitted;\n\t * extension/custom tools remain enabled\n\t */\n\tnoTools?: \"all\" | \"builtin\";\n\t/**\n\t * Optional allowlist of tool names or patterns where `*` matches any characters.\n\t *\n\t * When omitted, Atomic uses the resolved `defaultTools` setting for the initial\n\t * built-in selection when configured. Otherwise it enables the default\n\t * built-in tools (read, bash, edit, write, find, search, ask_user_question,\n\t * todo). Extension/custom tools remain enabled unless `noTools` changes\n\t * that default. MCP tools stay registered for codemode and tool search unless\n\t * an entry starts with `mcp__`; only matching tools are declared directly.\n\t * `excludedTools` applies afterwards. `noTools: \"all\"` overrides this selection.\n\t * Intercom follows the same selection and suppression rules as other extension tools.\n\t */\n\ttools?: string[];\n\t/**\n\t * Optional blocklist of tool names or patterns, including MCP tools.\n\t *\n\t * Matching built-in, extension, and SDK custom tools are omitted from the\n\t * final session tool registry and active tool set. Unknown names are ignored.\n\t */\n\texcludedTools?: string[];\n\t/** Custom tools to register (in addition to built-in tools). */\n\tcustomTools?: ToolDefinition[];\n\n\t/** Resource loader. When omitted, DefaultResourceLoader is used. */\n\tresourceLoader?: ResourceLoader;\n\n\t/** Session manager. Default: SessionManager.create(cwd) */\n\tsessionManager?: SessionManager;\n\n\t/** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n\tsettingsManager?: SettingsManager;\n\t/** Session start event metadata for extension runtime startup. */\n\tsessionStartEvent?: SessionStartEvent;\n\t/** Host bindings installed before extension startup. Rebinding does not replay startup. */\n\textensionBindings?: ExtensionBindings;\n\t/** Session-scoped orchestration policy exposed to extension/tool handlers. */\n\torchestrationContext?: OrchestrationContext;\n\t/** Typed capability policy for an in-process subagent child. */\n\tsubagentPolicy?: SubagentChildPolicy;\n\t/**\n\t * Internal: parent-issued shell task owner for an in-process subagent child. Supplied by the\n\t * parent's child-session options, so child background shells appear in the parent's `/tasks`.\n\t */\n\tparentCommandTaskOwner?: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner;\n\t/** Transform the fully constructed base system prompt at session construction. */\n\tsystemPromptTransform?: (prompt: string) => string;\n\t/** Filter inherited session messages before they enter the new AgentSession. */\n\tinitialContextTransform?: (messages: AgentMessage[]) => AgentMessage[];\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n\t/** The created session */\n\tsession: AgentSession;\n\t/** Extensions result (for UI context setup in interactive mode) */\n\textensionsResult: LoadExtensionsResult;\n\t/** Warning when a restored or configured model cannot be selected. */\n\tmodelFallbackMessage?: string;\n\t/** Semantic reason for modelFallbackMessage; suitable for mode control flow. */\n\tmodelFallbackReason?: ModelFallbackReason;\n}\n"]}
1
+ {"version":3,"file":"sdk-types.js","sourceRoot":"","sources":["../../src/core/sdk-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Api, Model } from \"@bastani/pi-ai/compat\";\nimport type { AgentMessage, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSession } from \"./agent-session.js\";\nimport type { ExtensionBindings } from \"./agent-session-types.js\";\nimport type {\n\tLoadExtensionsResult,\n\tOrchestrationContext,\n\tSessionStartEvent,\n\tSubagentChildPolicy,\n\tToolDefinition,\n} from \"./extensions/index.js\";\nimport type { ModelFallbackReason } from \"./model-resolver-types.ts\";\nimport type { ModelRuntime } from \"./model-runtime.js\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\n\nexport type AtomicBuiltin = \"workflows\" | \"subagents\" | \"mcp\" | \"web-access\" | \"intercom\";\n\nexport interface CreateAgentSessionOptions {\n\t/** Shipped packages are enabled unless explicitly false. Independent of tool selection. */\n\tbuiltins?: Partial<Record<AtomicBuiltin, boolean>>;\n\t/** Working directory for project-local discovery. Default: process.cwd() */\n\tcwd?: string;\n\t/** Global config directory. Default: ~/.atomic/agent */\n\tagentDir?: string;\n\n\t/** Canonical model/auth runtime. Defaults to agentDir/auth.json and models.json. */\n\tmodelRuntime?: ModelRuntime;\n\n\t/** Model to use. Default: from settings, else first available */\n\tmodel?: Model<Api>;\n\t/** Thinking level. Default: from settings, else 'medium' (clamped to model capabilities) */\n\tthinkingLevel?: ThinkingLevel;\n\t/**\n\t * Ordered fallback models as provider/model strings with optional :thinkingLevel suffix.\n\t * Used by main-chat turns and borrowed, planner-only, for compaction range planning when\n\t * the current model cannot produce a usable plan — so a configured candidate may receive\n\t * the compaction transcript. Borrowing never changes the session model or thinking level.\n\t * Default: settings.fallbackModels\n\t */\n\tfallbackModels?: string[];\n\t/** Hard eligibility gate applied before fallback inference, including compaction borrowing. */\n\tisFallbackModelAllowed?: (model: Model<Api>, effort: string | undefined) => boolean;\n\t/** Models available for cycling (Ctrl+P in interactive mode) */\n\tscopedModels?: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\n\t/**\n\t * Tool suppression mode.\n\t *\n\t * - \"all\": no active tools, even with an explicit allowlist\n\t * - \"builtin\": suppress coding-tool defaults only when tools is omitted;\n\t * extension/custom tools remain enabled\n\t */\n\tnoTools?: \"all\" | \"builtin\";\n\t/**\n\t * Optional allowlist of tool names or patterns where `*` matches any characters.\n\t *\n\t * When omitted, Atomic uses the resolved `defaultTools` setting for the initial\n\t * built-in selection when configured. Otherwise it enables the default\n\t * built-in tools (read, bash, edit, write, find, search, ask_user_question,\n\t * todo). Extension/custom tools remain enabled unless `noTools` changes\n\t * that default. MCP tools stay registered for codemode and tool search unless\n\t * an entry starts with `mcp__`; only matching tools are declared directly.\n\t * `excludedTools` applies afterwards. `noTools: \"all\"` overrides this selection.\n\t * Intercom follows the same selection and suppression rules as other extension tools.\n\t * A list of only `+name`/`-name` entries changes the resolved defaults instead\n\t * of allowlisting tools, and is reapplied on reload. Modifiers take exact names;\n\t * mixing them with plain names or patterns throws. Total suppression still wins.\n\t */\n\ttools?: string[];\n\t/**\n\t * Optional blocklist of tool names or patterns, including MCP tools.\n\t *\n\t * Matching built-in, extension, and SDK custom tools are omitted from the\n\t * final session tool registry and active tool set. Unknown names are ignored.\n\t */\n\texcludedTools?: string[];\n\t/** Custom tools to register (in addition to built-in tools). */\n\tcustomTools?: ToolDefinition[];\n\n\t/** Resource loader. When omitted, DefaultResourceLoader is used. */\n\tresourceLoader?: ResourceLoader;\n\n\t/** Session manager. Default: SessionManager.create(cwd) */\n\tsessionManager?: SessionManager;\n\n\t/** Settings manager. Default: SettingsManager.create(cwd, agentDir) */\n\tsettingsManager?: SettingsManager;\n\t/** Session start event metadata for extension runtime startup. */\n\tsessionStartEvent?: SessionStartEvent;\n\t/** Host bindings installed before extension startup. Rebinding does not replay startup. */\n\textensionBindings?: ExtensionBindings;\n\t/** Session-scoped orchestration policy exposed to extension/tool handlers. */\n\torchestrationContext?: OrchestrationContext;\n\t/** Typed capability policy for an in-process subagent child. */\n\tsubagentPolicy?: SubagentChildPolicy;\n\t/**\n\t * Internal: parent-issued shell task owner for an in-process subagent child. Supplied by the\n\t * parent's child-session options, so child background shells appear in the parent's `/tasks`.\n\t */\n\tparentCommandTaskOwner?: import(\"./tasks/child-command-owner.js\").ChildCommandTaskOwner;\n\t/** Transform the fully constructed base system prompt at session construction. */\n\tsystemPromptTransform?: (prompt: string) => string;\n\t/** Filter inherited session messages before they enter the new AgentSession. */\n\tinitialContextTransform?: (messages: AgentMessage[]) => AgentMessage[];\n}\n\n/** Result from createAgentSession */\nexport interface CreateAgentSessionResult {\n\t/** The created session */\n\tsession: AgentSession;\n\t/** Extensions result (for UI context setup in interactive mode) */\n\textensionsResult: LoadExtensionsResult;\n\t/** Warning when a restored or configured model cannot be selected. */\n\tmodelFallbackMessage?: string;\n\t/** Semantic reason for modelFallbackMessage; suitable for mode control flow. */\n\tmodelFallbackReason?: ModelFallbackReason;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAY1F,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,aAAa,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AA+BzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAEnH;AAED,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAEjH"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/core/sdk.ts"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAa1F,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,aAAa,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AA+BzG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAEnH;AAED,4EAA4E;AAC5E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAEjH"}