@easynet/agent-tool 1.0.18 → 1.0.20

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 (74) hide show
  1. package/dist/api/expose/mcpServer.d.ts.map +1 -1
  2. package/dist/api/expose/openapi.d.ts +2 -2
  3. package/dist/api/expose/openapi.d.ts.map +1 -1
  4. package/dist/api/main.cjs +17 -16
  5. package/dist/api/main.js +6 -5
  6. package/dist/api/runtimeFromConfig.d.ts.map +1 -1
  7. package/dist/canonicalCoreSchemas-JPTOIQKR.js +4 -0
  8. package/dist/{canonicalCoreSchemas-YLHVHYJZ.js.map → canonicalCoreSchemas-JPTOIQKR.js.map} +1 -1
  9. package/dist/canonicalCoreSchemas-K57HKGZJ.cjs +21 -0
  10. package/dist/{canonicalCoreSchemas-CTW6CCFY.cjs.map → canonicalCoreSchemas-K57HKGZJ.cjs.map} +1 -1
  11. package/dist/{chunk-6F5JHLZ7.cjs → chunk-6JWQVVL2.cjs} +24 -20
  12. package/dist/chunk-6JWQVVL2.cjs.map +1 -0
  13. package/dist/{chunk-EMI67SPN.cjs → chunk-6WQYJLVU.cjs} +151 -45
  14. package/dist/chunk-6WQYJLVU.cjs.map +1 -0
  15. package/dist/{chunk-SOFUWEZ6.cjs → chunk-FGGTT32N.cjs} +9 -3
  16. package/dist/chunk-FGGTT32N.cjs.map +1 -0
  17. package/dist/{chunk-5SWSNVMI.js → chunk-GWBJEGS7.js} +9 -4
  18. package/dist/chunk-GWBJEGS7.js.map +1 -0
  19. package/dist/{chunk-RKN4PT7P.js → chunk-IGMDLCV7.js} +138 -33
  20. package/dist/chunk-IGMDLCV7.js.map +1 -0
  21. package/dist/{chunk-OXTQULXH.cjs → chunk-INYWD3OJ.cjs} +14 -13
  22. package/dist/chunk-INYWD3OJ.cjs.map +1 -0
  23. package/dist/{chunk-AE6FSNGY.js → chunk-IU35EFPK.js} +14 -10
  24. package/dist/chunk-IU35EFPK.js.map +1 -0
  25. package/dist/{chunk-7WI5VK5G.js → chunk-NNMMUG2X.js} +3 -3
  26. package/dist/{chunk-7WI5VK5G.js.map → chunk-NNMMUG2X.js.map} +1 -1
  27. package/dist/{chunk-7MRBWT2T.js → chunk-OHDIMQ22.js} +4 -4
  28. package/dist/{chunk-7MRBWT2T.js.map → chunk-OHDIMQ22.js.map} +1 -1
  29. package/dist/{chunk-ZNJBRLKN.cjs → chunk-ONIBCU2Y.cjs} +14 -10
  30. package/dist/chunk-ONIBCU2Y.cjs.map +1 -0
  31. package/dist/{chunk-FR2CXERF.js → chunk-P5UPHQ7N.js} +24 -20
  32. package/dist/chunk-P5UPHQ7N.js.map +1 -0
  33. package/dist/{chunk-YK2MQDNJ.cjs → chunk-QP6JJF76.cjs} +11 -11
  34. package/dist/{chunk-YK2MQDNJ.cjs.map → chunk-QP6JJF76.cjs.map} +1 -1
  35. package/dist/{chunk-ZIFQWIN3.cjs → chunk-TAW4FP3A.cjs} +18 -18
  36. package/dist/{chunk-ZIFQWIN3.cjs.map → chunk-TAW4FP3A.cjs.map} +1 -1
  37. package/dist/{chunk-ETWGKCOP.js → chunk-WKWSXCS4.js} +9 -8
  38. package/dist/chunk-WKWSXCS4.js.map +1 -0
  39. package/dist/core/index.cjs +4 -4
  40. package/dist/core/index.js +1 -1
  41. package/dist/core/registry/ToolRegistry.d.ts +2 -2
  42. package/dist/core/registry/ToolRegistry.d.ts.map +1 -1
  43. package/dist/core/runtime/PTCRuntimePipeline.d.ts +1 -1
  44. package/dist/core/runtime/PTCRuntimePipeline.d.ts.map +1 -1
  45. package/dist/core/runtime.cjs +6 -5
  46. package/dist/core/runtime.js +2 -1
  47. package/dist/core/types/ToolSpec.d.ts +5 -0
  48. package/dist/core/types/ToolSpec.d.ts.map +1 -1
  49. package/dist/index.cjs +81 -73
  50. package/dist/index.d.ts +2 -2
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +10 -10
  53. package/dist/tools/util/canonicalCoreSchemas.d.ts.map +1 -1
  54. package/dist/tools/util/index.d.ts +1 -1
  55. package/dist/tools/util/index.d.ts.map +1 -1
  56. package/dist/tools/util/toolDescriptor.d.ts +11 -13
  57. package/dist/tools/util/toolDescriptor.d.ts.map +1 -1
  58. package/dist/utils/cli/index.cjs +23 -23
  59. package/dist/utils/cli/index.cjs.map +1 -1
  60. package/dist/utils/cli/index.js +8 -8
  61. package/dist/utils/cli/index.js.map +1 -1
  62. package/package.json +1 -1
  63. package/dist/canonicalCoreSchemas-CTW6CCFY.cjs +0 -20
  64. package/dist/canonicalCoreSchemas-YLHVHYJZ.js +0 -3
  65. package/dist/chunk-5SWSNVMI.js.map +0 -1
  66. package/dist/chunk-6F5JHLZ7.cjs.map +0 -1
  67. package/dist/chunk-AE6FSNGY.js.map +0 -1
  68. package/dist/chunk-EMI67SPN.cjs.map +0 -1
  69. package/dist/chunk-ETWGKCOP.js.map +0 -1
  70. package/dist/chunk-FR2CXERF.js.map +0 -1
  71. package/dist/chunk-OXTQULXH.cjs.map +0 -1
  72. package/dist/chunk-RKN4PT7P.js.map +0 -1
  73. package/dist/chunk-SOFUWEZ6.cjs.map +0 -1
  74. package/dist/chunk-ZNJBRLKN.cjs.map +0 -1
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkZNJBRLKN_cjs = require('./chunk-ZNJBRLKN.cjs');
3
+ var chunkONIBCU2Y_cjs = require('./chunk-ONIBCU2Y.cjs');
4
+ var chunkFGGTT32N_cjs = require('./chunk-FGGTT32N.cjs');
4
5
  var Ajv = require('ajv');
5
6
  var addFormats = require('ajv-formats');
6
7
  var cockatiel = require('cockatiel');
@@ -939,9 +940,10 @@ var Tracing = class {
939
940
  }
940
941
  };
941
942
  function resolveTool(toolName, registry) {
942
- const spec = registry.get(toolName);
943
+ const key = chunkFGGTT32N_cjs.normalizeToolName(toolName);
944
+ const spec = registry.get(key);
943
945
  if (!spec) {
944
- throw chunkZNJBRLKN_cjs.createTaggedError(
946
+ throw chunkONIBCU2Y_cjs.createTaggedError(
945
947
  "TOOL_NOT_FOUND",
946
948
  `Tool not found: ${toolName}`,
947
949
  { availableTools: registry.snapshot().slice(0, 20).map((s) => s.name) }
@@ -980,7 +982,7 @@ function validateInput(spec, args, validator) {
980
982
  if (error instanceof SchemaValidationError) {
981
983
  const requiredKeys = getRequiredKeys(spec.inputSchema);
982
984
  const passedKeys = args != null && typeof args === "object" && !Array.isArray(args) ? Object.keys(args) : [];
983
- throw chunkZNJBRLKN_cjs.createTaggedError("INPUT_SCHEMA_INVALID", error.message, {
985
+ throw chunkONIBCU2Y_cjs.createTaggedError("INPUT_SCHEMA_INVALID", error.message, {
984
986
  errors: error.errors,
985
987
  schema: spec.inputSchema,
986
988
  requiredKeys: requiredKeys.length ? requiredKeys : void 0,
@@ -1053,7 +1055,7 @@ async function requireHumanApproval(spec, args, ctx, deps) {
1053
1055
  sideEffect,
1054
1056
  reason: err instanceof Error ? err.message : String(err)
1055
1057
  });
1056
- throw chunkZNJBRLKN_cjs.createTaggedError(
1058
+ throw chunkONIBCU2Y_cjs.createTaggedError(
1057
1059
  "HITL_DENIED",
1058
1060
  `Human denied approval for ${spec.name} (${sideEffect})`,
1059
1061
  { reason: err instanceof Error ? err.message : String(err) }
@@ -1066,7 +1068,7 @@ async function requireHumanApproval(spec, args, ctx, deps) {
1066
1068
  sideEffect,
1067
1069
  reason: "User rejected"
1068
1070
  });
1069
- throw chunkZNJBRLKN_cjs.createTaggedError("HITL_DENIED", `Human denied approval for ${spec.name} (${sideEffect})`);
1071
+ throw chunkONIBCU2Y_cjs.createTaggedError("HITL_DENIED", `Human denied approval for ${spec.name} (${sideEffect})`);
1070
1072
  }
1071
1073
  deps.eventLog.append({
1072
1074
  ...baseEvent,
@@ -1078,7 +1080,7 @@ async function requireHumanApproval(spec, args, ctx, deps) {
1078
1080
  async function executeWithBudget(spec, args, ctx, spanId, deps) {
1079
1081
  const adapter = deps.adapters.get(spec.kind);
1080
1082
  if (!adapter) {
1081
- throw chunkZNJBRLKN_cjs.createTaggedError(
1083
+ throw chunkONIBCU2Y_cjs.createTaggedError(
1082
1084
  "TOOL_NOT_FOUND",
1083
1085
  `No adapter registered for kind: ${spec.kind}`
1084
1086
  );
@@ -1106,7 +1108,7 @@ async function executeWithBudget(spec, args, ctx, spanId, deps) {
1106
1108
  return result;
1107
1109
  });
1108
1110
  };
1109
- const retryFn = () => chunkZNJBRLKN_cjs.withRetry(executeFn, {
1111
+ const retryFn = () => chunkONIBCU2Y_cjs.withRetry(executeFn, {
1110
1112
  maxRetries,
1111
1113
  onRetry: (error, attempt) => {
1112
1114
  deps.metrics.recordRetry(spec.name);
@@ -1133,7 +1135,7 @@ async function executeWithBudget(spec, args, ctx, spanId, deps) {
1133
1135
  });
1134
1136
  } catch (error) {
1135
1137
  if (error instanceof Error && error.message.includes("timed out")) {
1136
- throw chunkZNJBRLKN_cjs.createTaggedError("TIMEOUT", error.message);
1138
+ throw chunkONIBCU2Y_cjs.createTaggedError("TIMEOUT", error.message);
1137
1139
  }
1138
1140
  throw error;
1139
1141
  }
@@ -1147,7 +1149,7 @@ function validateOutput(spec, result, validator) {
1147
1149
  );
1148
1150
  } catch (error) {
1149
1151
  if (error instanceof SchemaValidationError) {
1150
- throw chunkZNJBRLKN_cjs.createTaggedError("OUTPUT_SCHEMA_INVALID", error.message, {
1152
+ throw chunkONIBCU2Y_cjs.createTaggedError("OUTPUT_SCHEMA_INVALID", error.message, {
1151
1153
  errors: error.errors
1152
1154
  });
1153
1155
  }
@@ -1240,7 +1242,7 @@ var PTCRuntime = class {
1240
1242
  logger;
1241
1243
  constructor(options = {}) {
1242
1244
  this.config = options.config ?? {};
1243
- this.registry = options.registry ?? new chunkZNJBRLKN_cjs.ToolRegistry();
1245
+ this.registry = options.registry ?? new chunkONIBCU2Y_cjs.ToolRegistry();
1244
1246
  this.validator = options.validator ?? new SchemaValidator();
1245
1247
  this.policy = options.policy ?? new PolicyEngine(this.config.policy);
1246
1248
  this.budget = options.budget ?? new BudgetManager(this.config.budget);
@@ -1341,7 +1343,7 @@ var PTCRuntime = class {
1341
1343
  tracing: this.tracing
1342
1344
  });
1343
1345
  if (!this.budget.checkRateLimit(spec.name)) {
1344
- throw chunkZNJBRLKN_cjs.createTaggedError(
1346
+ throw chunkONIBCU2Y_cjs.createTaggedError(
1345
1347
  "BUDGET_EXCEEDED",
1346
1348
  `Rate limit exceeded for tool: ${spec.name}`
1347
1349
  );
@@ -1364,7 +1366,7 @@ var PTCRuntime = class {
1364
1366
  const toolError = asToolReturnedError(result);
1365
1367
  if (toolError) {
1366
1368
  const hint = buildInputSchemaHint(spec.inputSchema);
1367
- throw chunkZNJBRLKN_cjs.createTaggedError("UPSTREAM_ERROR", toolError.message, {
1369
+ throw chunkONIBCU2Y_cjs.createTaggedError("UPSTREAM_ERROR", toolError.message, {
1368
1370
  ...toolError.details && typeof toolError.details === "object" && !Array.isArray(toolError.details) ? toolError.details : {},
1369
1371
  hint: hint ?? "Check the tool's input schema for required property names."
1370
1372
  });
@@ -1508,6 +1510,26 @@ function parseToolPath(descriptor) {
1508
1510
  toolName: m[5] ?? ""
1509
1511
  };
1510
1512
  }
1513
+ function npmDescriptorToRegistryPrefix(descriptor, resolvedVersion) {
1514
+ const s = descriptor.trim();
1515
+ if (typeof s !== "string" || !s.startsWith("npm:")) return "";
1516
+ const rest = s.slice(4).trim();
1517
+ const hashIdx = rest.indexOf("#");
1518
+ const beforeHash = hashIdx < 0 ? rest : rest.slice(0, hashIdx);
1519
+ const lastAt = beforeHash.lastIndexOf("@");
1520
+ const scopeAndPackage = lastAt <= 0 ? beforeHash : beforeHash.slice(0, lastAt);
1521
+ let version = lastAt <= 0 ? "latest" : beforeHash.slice(lastAt + 1).trim() || "latest";
1522
+ if ((version === "latest" || !version) && resolvedVersion != null && resolvedVersion !== "") {
1523
+ version = resolvedVersion;
1524
+ }
1525
+ const slashIdx = scopeAndPackage.indexOf("/");
1526
+ const scope = slashIdx < 0 ? scopeAndPackage : scopeAndPackage.slice(0, slashIdx).replace(/^@/, "");
1527
+ const pkg = slashIdx < 0 ? "" : scopeAndPackage.slice(slashIdx + 1);
1528
+ const segment = [scope, pkg, version].filter(Boolean).join(".");
1529
+ const normalized = chunkFGGTT32N_cjs.normalizeToolName(segment);
1530
+ if (!normalized) return "";
1531
+ return "npm." + normalized + ".";
1532
+ }
1511
1533
  function isNpmToolDescriptor(descriptor) {
1512
1534
  return isToolPath(descriptor) && parseToolPath(descriptor)?.protocol === "npm";
1513
1535
  }
@@ -1520,7 +1542,7 @@ function parseNpmToolDescriptor(descriptor) {
1520
1542
  };
1521
1543
  }
1522
1544
  function getDisplayScope(registryName, _kind, _toolVersion) {
1523
- const i = registryName.indexOf("/");
1545
+ const i = registryName.indexOf(".");
1524
1546
  return i < 0 ? registryName : registryName.slice(0, i);
1525
1547
  }
1526
1548
  function resolveNpmToolDescriptor(descriptor) {
@@ -1530,15 +1552,32 @@ function expandToolDescriptorsToRegistryNames(descriptors, registryNames) {
1530
1552
  const out = [];
1531
1553
  const seen = /* @__PURE__ */ new Set();
1532
1554
  function add(name) {
1533
- if (registryNames.includes(name) && !seen.has(name)) {
1534
- seen.add(name);
1535
- out.push(name);
1555
+ const key = chunkFGGTT32N_cjs.normalizeToolName(name);
1556
+ if (registryNames.includes(key) && !seen.has(key)) {
1557
+ seen.add(key);
1558
+ out.push(key);
1559
+ return;
1560
+ }
1561
+ const matched = registryNames.filter((r) => r === key || r.endsWith("." + key));
1562
+ for (const m of matched) {
1563
+ if (!seen.has(m)) {
1564
+ seen.add(m);
1565
+ out.push(m);
1566
+ }
1536
1567
  }
1537
1568
  }
1538
1569
  for (const d of descriptors) {
1539
1570
  const s = d.trim();
1540
1571
  if (!s) continue;
1541
- add(s);
1572
+ if (isToolPath(s)) {
1573
+ if (registryNames.includes(s) && !seen.has(s)) {
1574
+ seen.add(s);
1575
+ out.push(s);
1576
+ }
1577
+ continue;
1578
+ }
1579
+ const name = chunkFGGTT32N_cjs.normalizeToolName(s);
1580
+ add(name);
1542
1581
  }
1543
1582
  return out;
1544
1583
  }
@@ -1692,7 +1731,7 @@ async function importFromCache(packageRoot) {
1692
1731
  fileUrl
1693
1732
  );
1694
1733
  }
1695
- var requireFromPackage = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-EMI67SPN.cjs', document.baseURI).href)));
1734
+ var requireFromPackage = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-6WQYJLVU.cjs', document.baseURI).href)));
1696
1735
  function getProjectRequire() {
1697
1736
  const cwd = process.cwd();
1698
1737
  if (fs.existsSync(path.join(cwd, "package.json"))) return module$1.createRequire(path.join(cwd, "package.json"));
@@ -1704,6 +1743,22 @@ var BUILTIN_PKG_NAMES = [
1704
1743
  "@easynet/agent-tool-builtin",
1705
1744
  "@easynet/agent-tool-buildin"
1706
1745
  ];
1746
+ function getInstalledPackageVersion(packageName) {
1747
+ const projectRequire = getProjectRequire();
1748
+ const requirers = [requireFromPackage];
1749
+ if (projectRequire) requirers.push(projectRequire);
1750
+ for (const req of requirers) {
1751
+ try {
1752
+ const pkgJsonPath = req.resolve(`${packageName}/package.json`);
1753
+ const json = fs.readFileSync(pkgJsonPath, "utf-8");
1754
+ const pkg = JSON.parse(json);
1755
+ return pkg.version ?? null;
1756
+ } catch {
1757
+ continue;
1758
+ }
1759
+ }
1760
+ return null;
1761
+ }
1707
1762
  function loadBuiltinTools() {
1708
1763
  const projectRequire = getProjectRequire();
1709
1764
  const requirers = [requireFromPackage];
@@ -1712,7 +1767,7 @@ function loadBuiltinTools() {
1712
1767
  for (const pkg of BUILTIN_PKG_NAMES) {
1713
1768
  try {
1714
1769
  const mod = req(pkg);
1715
- if (mod && typeof mod.registerCoreTools === "function") return mod;
1770
+ if (mod && typeof mod.registerCoreTools === "function") return { registerCoreTools: mod.registerCoreTools, packageName: pkg };
1716
1771
  } catch {
1717
1772
  continue;
1718
1773
  }
@@ -1720,6 +1775,40 @@ function loadBuiltinTools() {
1720
1775
  }
1721
1776
  return null;
1722
1777
  }
1778
+ function createPrefixingRegistry(registry, prefix) {
1779
+ return {
1780
+ register(spec) {
1781
+ registry.register({ ...spec, name: prefix + chunkFGGTT32N_cjs.normalizeToolName(spec.name) });
1782
+ },
1783
+ bulkRegister(specs) {
1784
+ specs.forEach((s) => this.register(s));
1785
+ },
1786
+ unregister(name) {
1787
+ return registry.unregister(name);
1788
+ },
1789
+ get(name) {
1790
+ return registry.get(name);
1791
+ },
1792
+ has(name) {
1793
+ return registry.has(name);
1794
+ },
1795
+ search(query) {
1796
+ return registry.search(query);
1797
+ },
1798
+ list() {
1799
+ return registry.list();
1800
+ },
1801
+ get size() {
1802
+ return registry.size;
1803
+ },
1804
+ snapshot() {
1805
+ return registry.snapshot();
1806
+ },
1807
+ clear() {
1808
+ return registry.clear();
1809
+ }
1810
+ };
1811
+ }
1723
1812
  function parseNpmDescriptor(entry) {
1724
1813
  if (typeof entry !== "string" || !entry.startsWith("npm:")) return null;
1725
1814
  const rest = entry.slice(4).trim();
@@ -1739,7 +1828,8 @@ function loadBuiltinFromToolYamlCache(configFilePath, stepLog) {
1739
1828
  const cacheOpts = cacheBase ? { cacheBase } : {};
1740
1829
  if (stepLog) stepLog(`Loading builtin from tool.yaml cache (cacheBase: ${cacheBase ?? "~/.agent/cache"})`);
1741
1830
  for (const entry of tools) {
1742
- const parsed = parseNpmDescriptor(String(entry));
1831
+ const entryStr = String(entry).trim();
1832
+ const parsed = parseNpmDescriptor(entryStr);
1743
1833
  if (!parsed || !BUILTIN_PKG_NAMES.includes(parsed.packageName)) continue;
1744
1834
  for (const opts of [cacheOpts, {}]) {
1745
1835
  try {
@@ -1749,7 +1839,10 @@ function loadBuiltinFromToolYamlCache(configFilePath, stepLog) {
1749
1839
  const entryPath = getPackageEntryPath(cacheDir);
1750
1840
  const req = module$1.createRequire(path.join(cacheDir, "package.json"));
1751
1841
  const mod = req(entryPath);
1752
- if (mod && typeof mod.registerCoreTools === "function") return mod;
1842
+ if (mod && typeof mod.registerCoreTools === "function") {
1843
+ const resolvedVersion = path.basename(cacheDir);
1844
+ return { registerCoreTools: mod.registerCoreTools, descriptor: entryStr, resolvedVersion };
1845
+ }
1753
1846
  break;
1754
1847
  } catch {
1755
1848
  if (Object.keys(opts).length > 0) continue;
@@ -1769,7 +1862,8 @@ async function loadBuiltinFromToolYamlCacheAsync(configFilePath, stepLog) {
1769
1862
  const cacheOpts = cacheBase ? { cacheBase } : {};
1770
1863
  if (stepLog) stepLog("Loading builtin from tool.yaml cache (async)");
1771
1864
  for (const entry of tools) {
1772
- const parsed = parseNpmDescriptor(String(entry));
1865
+ const entryStr = String(entry).trim();
1866
+ const parsed = parseNpmDescriptor(entryStr);
1773
1867
  if (!parsed || !BUILTIN_PKG_NAMES.includes(parsed.packageName)) continue;
1774
1868
  for (const opts of [cacheOpts, {}]) {
1775
1869
  try {
@@ -1777,7 +1871,10 @@ async function loadBuiltinFromToolYamlCacheAsync(configFilePath, stepLog) {
1777
1871
  const cacheDir = ensurePackageInCache(parsed.packageName, parsed.version, opts);
1778
1872
  if (stepLog) stepLog(`Using cache: ${cacheDir}`);
1779
1873
  const mod = await importFromCache(cacheDir);
1780
- if (mod && typeof mod.registerCoreTools === "function") return mod;
1874
+ if (mod && typeof mod.registerCoreTools === "function") {
1875
+ const resolvedVersion = path.basename(cacheDir);
1876
+ return { registerCoreTools: mod.registerCoreTools, descriptor: entryStr, resolvedVersion };
1877
+ }
1781
1878
  break;
1782
1879
  } catch {
1783
1880
  if (Object.keys(opts).length > 0) continue;
@@ -1795,14 +1892,18 @@ function loadExampleTools() {
1795
1892
  }
1796
1893
  }
1797
1894
  function createRuntimeFromConfigSync(options = {}) {
1798
- const registry = new chunkZNJBRLKN_cjs.ToolRegistry();
1895
+ const registry = new chunkONIBCU2Y_cjs.ToolRegistry();
1799
1896
  const stepLog = options.stepLog;
1800
1897
  if (options.coreTools !== void 0) {
1801
1898
  if (stepLog) stepLog("Trying builtin from node_modules");
1802
- let builtin = loadBuiltinTools();
1803
- if (builtin) {
1899
+ let builtinNode = loadBuiltinTools();
1900
+ if (builtinNode) {
1804
1901
  if (stepLog) stepLog("Registered builtin from node_modules");
1805
- const coreAdapter = builtin.registerCoreTools(registry, options.coreTools);
1902
+ const descriptor = `npm:${builtinNode.packageName}`;
1903
+ const resolvedVersion = getInstalledPackageVersion(builtinNode.packageName);
1904
+ const prefix = npmDescriptorToRegistryPrefix(descriptor, resolvedVersion ?? void 0);
1905
+ const reg = prefix ? createPrefixingRegistry(registry, prefix) : registry;
1906
+ const coreAdapter = builtinNode.registerCoreTools(reg, options.coreTools);
1806
1907
  const runtime3 = new PTCRuntime({ registry });
1807
1908
  runtime3.registerAdapter(coreAdapter);
1808
1909
  if (options.exampleTools !== void 0) {
@@ -1816,21 +1917,23 @@ function createRuntimeFromConfigSync(options = {}) {
1816
1917
  }
1817
1918
  if (options.configFilePath) {
1818
1919
  if (stepLog) stepLog("No builtin in node_modules, loading from tool.yaml cache");
1819
- builtin = loadBuiltinFromToolYamlCache(options.configFilePath, stepLog);
1820
- }
1821
- if (builtin) {
1822
- if (stepLog) stepLog("Registered builtin from cache");
1823
- const coreAdapter = builtin.registerCoreTools(registry, options.coreTools);
1824
- const runtime3 = new PTCRuntime({ registry });
1825
- runtime3.registerAdapter(coreAdapter);
1826
- if (options.exampleTools !== void 0) {
1827
- const example = loadExampleTools();
1828
- if (example) {
1829
- const exampleAdapter = example.registerExampleTools(registry, options.exampleTools);
1830
- runtime3.registerAdapter(exampleAdapter);
1920
+ const builtinCache = loadBuiltinFromToolYamlCache(options.configFilePath, stepLog);
1921
+ if (builtinCache) {
1922
+ if (stepLog) stepLog("Registered builtin from cache");
1923
+ const prefix = npmDescriptorToRegistryPrefix(builtinCache.descriptor, builtinCache.resolvedVersion);
1924
+ const reg = prefix ? createPrefixingRegistry(registry, prefix) : registry;
1925
+ const coreAdapter = builtinCache.registerCoreTools(reg, options.coreTools);
1926
+ const runtime3 = new PTCRuntime({ registry });
1927
+ runtime3.registerAdapter(coreAdapter);
1928
+ if (options.exampleTools !== void 0) {
1929
+ const example = loadExampleTools();
1930
+ if (example) {
1931
+ const exampleAdapter = example.registerExampleTools(registry, options.exampleTools);
1932
+ runtime3.registerAdapter(exampleAdapter);
1933
+ }
1831
1934
  }
1935
+ return { runtime: runtime3, registry };
1832
1936
  }
1833
- return { runtime: runtime3, registry };
1834
1937
  }
1835
1938
  const runtime2 = new PTCRuntime({ registry });
1836
1939
  return { runtime: runtime2, registry };
@@ -1854,8 +1957,10 @@ async function createRuntimeFromConfig(options = {}) {
1854
1957
  const builtin = await loadBuiltinFromToolYamlCacheAsync(options.configFilePath, options.stepLog);
1855
1958
  if (builtin) {
1856
1959
  if (options.stepLog) options.stepLog("Registered builtin from async cache");
1857
- const registry = new chunkZNJBRLKN_cjs.ToolRegistry();
1858
- const coreAdapter = builtin.registerCoreTools(registry, options.coreTools);
1960
+ const registry = new chunkONIBCU2Y_cjs.ToolRegistry();
1961
+ const prefix = npmDescriptorToRegistryPrefix(builtin.descriptor, builtin.resolvedVersion);
1962
+ const reg = prefix ? createPrefixingRegistry(registry, prefix) : registry;
1963
+ const coreAdapter = builtin.registerCoreTools(reg, options.coreTools);
1859
1964
  const runtime = new PTCRuntime({ registry });
1860
1965
  runtime.registerAdapter(coreAdapter);
1861
1966
  return { runtime, registry };
@@ -1898,6 +2003,7 @@ exports.isBarePackageDescriptor = isBarePackageDescriptor;
1898
2003
  exports.isNpmToolDescriptor = isNpmToolDescriptor;
1899
2004
  exports.loadToolConfig = loadToolConfig;
1900
2005
  exports.normalizeToolList = normalizeToolList;
2006
+ exports.npmDescriptorToRegistryPrefix = npmDescriptorToRegistryPrefix;
1901
2007
  exports.parseNpmDescriptor = parseNpmDescriptor;
1902
2008
  exports.parseNpmToolDescriptor = parseNpmToolDescriptor;
1903
2009
  exports.resolveNpmToolDescriptor = resolveNpmToolDescriptor;
@@ -1905,5 +2011,5 @@ exports.resolveSandboxedPath = resolveSandboxedPath;
1905
2011
  exports.resolveToolDescriptor = resolveToolDescriptor;
1906
2012
  exports.sanitizeForLog = sanitizeForLog;
1907
2013
  exports.summarizeForLog = summarizeForLog;
1908
- //# sourceMappingURL=chunk-EMI67SPN.cjs.map
1909
- //# sourceMappingURL=chunk-EMI67SPN.cjs.map
2014
+ //# sourceMappingURL=chunk-6WQYJLVU.cjs.map
2015
+ //# sourceMappingURL=chunk-6WQYJLVU.cjs.map