@dexto/agent-management 1.16.5 → 1.17.0-beta.5

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 (103) hide show
  1. package/dist/auth/dexto-accounts.cjs +277 -0
  2. package/dist/auth/dexto-accounts.d.ts +144 -0
  3. package/dist/auth/dexto-accounts.d.ts.map +1 -0
  4. package/dist/auth/dexto-accounts.js +230 -0
  5. package/dist/auth/dexto-cloud.cjs +51 -0
  6. package/dist/auth/dexto-cloud.d.ts +9 -0
  7. package/dist/auth/dexto-cloud.d.ts.map +1 -0
  8. package/dist/auth/dexto-cloud.js +27 -0
  9. package/dist/auth/dexto-gateway.cjs +162 -0
  10. package/dist/auth/dexto-gateway.d.ts +55 -0
  11. package/dist/auth/dexto-gateway.d.ts.map +1 -0
  12. package/dist/auth/dexto-gateway.js +133 -0
  13. package/dist/auth/dexto-mcp.cjs +77 -0
  14. package/dist/auth/dexto-mcp.d.ts +23 -0
  15. package/dist/auth/dexto-mcp.d.ts.map +1 -0
  16. package/dist/auth/dexto-mcp.js +49 -0
  17. package/dist/auth/dexto-sign-in.cjs +345 -0
  18. package/dist/auth/dexto-sign-in.d.ts +86 -0
  19. package/dist/auth/dexto-sign-in.d.ts.map +1 -0
  20. package/dist/auth/dexto-sign-in.js +314 -0
  21. package/dist/auth/index.cjs +25 -0
  22. package/dist/auth/index.d.ts +6 -0
  23. package/dist/auth/index.d.ts.map +1 -1
  24. package/dist/auth/index.js +10 -0
  25. package/dist/auth/model-auth-handlers.cjs +3 -1
  26. package/dist/auth/model-auth-handlers.d.ts +6 -1
  27. package/dist/auth/model-auth-handlers.d.ts.map +1 -1
  28. package/dist/auth/model-auth-handlers.js +6 -1
  29. package/dist/config/errors.cjs +6 -6
  30. package/dist/config/errors.js +6 -6
  31. package/dist/images/image-store.cjs +2 -4
  32. package/dist/images/image-store.d.ts.map +1 -1
  33. package/dist/images/image-store.js +2 -4
  34. package/dist/index.cjs +40 -29
  35. package/dist/index.d.ts +3 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +9 -6
  38. package/dist/installation.cjs +2 -2
  39. package/dist/installation.js +2 -2
  40. package/dist/plugins/discover-skills.cjs +5 -2
  41. package/dist/plugins/discover-skills.d.ts +6 -2
  42. package/dist/plugins/discover-skills.d.ts.map +1 -1
  43. package/dist/plugins/discover-skills.js +5 -2
  44. package/dist/plugins/errors.cjs +2 -2
  45. package/dist/plugins/errors.js +2 -2
  46. package/dist/plugins/install-plugin.cjs +2 -0
  47. package/dist/plugins/install-plugin.d.ts.map +1 -1
  48. package/dist/plugins/install-plugin.js +2 -0
  49. package/dist/plugins/local-skills.cjs +2 -0
  50. package/dist/plugins/local-skills.d.ts.map +1 -1
  51. package/dist/plugins/local-skills.js +2 -0
  52. package/dist/plugins/marketplace/error-codes.cjs +1 -0
  53. package/dist/plugins/marketplace/error-codes.d.ts +1 -0
  54. package/dist/plugins/marketplace/error-codes.d.ts.map +1 -1
  55. package/dist/plugins/marketplace/error-codes.js +1 -0
  56. package/dist/plugins/marketplace/errors.cjs +14 -4
  57. package/dist/plugins/marketplace/errors.d.ts +3 -0
  58. package/dist/plugins/marketplace/errors.d.ts.map +1 -1
  59. package/dist/plugins/marketplace/errors.js +14 -4
  60. package/dist/plugins/marketplace/install-from-marketplace.cjs +5 -0
  61. package/dist/plugins/marketplace/install-from-marketplace.d.ts.map +1 -1
  62. package/dist/plugins/marketplace/install-from-marketplace.js +7 -1
  63. package/dist/plugins/marketplace/operations.cjs +30 -6
  64. package/dist/plugins/marketplace/operations.d.ts +6 -0
  65. package/dist/plugins/marketplace/operations.d.ts.map +1 -1
  66. package/dist/plugins/marketplace/operations.js +31 -8
  67. package/dist/plugins/marketplace/schemas.cjs +2 -1
  68. package/dist/plugins/marketplace/schemas.d.ts.map +1 -1
  69. package/dist/plugins/marketplace/schemas.js +2 -1
  70. package/dist/plugins/schemas.cjs +9 -3
  71. package/dist/plugins/schemas.d.ts +5 -0
  72. package/dist/plugins/schemas.d.ts.map +1 -1
  73. package/dist/plugins/schemas.js +7 -2
  74. package/dist/preferences/errors.cjs +1 -1
  75. package/dist/preferences/errors.js +1 -1
  76. package/dist/registry/registry.cjs +9 -6
  77. package/dist/registry/registry.d.ts +0 -8
  78. package/dist/registry/registry.d.ts.map +1 -1
  79. package/dist/registry/registry.js +9 -6
  80. package/dist/resolver.cjs +1 -1
  81. package/dist/resolver.js +1 -1
  82. package/dist/tool-factories/agent-spawner/factory.cjs +1 -218
  83. package/dist/tool-factories/agent-spawner/factory.d.ts.map +1 -1
  84. package/dist/tool-factories/agent-spawner/factory.js +1 -228
  85. package/dist/tool-factories/creator-tools/factory.cjs +16 -1
  86. package/dist/tool-factories/creator-tools/factory.d.ts.map +1 -1
  87. package/dist/tool-factories/creator-tools/factory.js +16 -1
  88. package/dist/utils/api-key-store.cjs +3 -2
  89. package/dist/utils/api-key-store.d.ts.map +1 -1
  90. package/dist/utils/api-key-store.js +3 -2
  91. package/dist/utils/dexto-auth.cjs +3 -58
  92. package/dist/utils/dexto-auth.d.ts +4 -18
  93. package/dist/utils/dexto-auth.d.ts.map +1 -1
  94. package/dist/utils/dexto-auth.js +3 -57
  95. package/dist/utils/env-file.cjs +24 -2
  96. package/dist/utils/env-file.d.ts +3 -2
  97. package/dist/utils/env-file.d.ts.map +1 -1
  98. package/dist/utils/env-file.js +24 -2
  99. package/dist/utils/path.cjs +75 -11
  100. package/dist/utils/path.d.ts +14 -1
  101. package/dist/utils/path.d.ts.map +1 -1
  102. package/dist/utils/path.js +73 -10
  103. package/package.json +5 -6
@@ -66,6 +66,16 @@ class MarketplaceError {
66
66
  "Check the URL is correct and you have network access"
67
67
  );
68
68
  }
69
+ static addInvalidName(name) {
70
+ return new import_core.DextoRuntimeError(
71
+ import_error_codes.MarketplaceErrorCode.ADD_INVALID_NAME,
72
+ import_core.ErrorScope.CONFIG,
73
+ import_core.ErrorType.USER,
74
+ `Invalid marketplace name '${name}'`,
75
+ { name },
76
+ 'Use letters, digits, ".", "_", "-" and spaces, starting with a letter or digit; pass --name to choose one'
77
+ );
78
+ }
69
79
  static addInvalidSource(source, reason) {
70
80
  return new import_core.DextoRuntimeError(
71
81
  import_error_codes.MarketplaceErrorCode.ADD_INVALID_SOURCE,
@@ -94,7 +104,7 @@ class MarketplaceError {
94
104
  import_core.ErrorType.USER,
95
105
  `Marketplace '${name}' not found`,
96
106
  { name },
97
- "Use `dexto plugin marketplace list` to see registered marketplaces"
107
+ "Use `/plugin` in the interactive CLI to see registered marketplaces"
98
108
  );
99
109
  }
100
110
  static removeDeleteFailed(name, path, cause) {
@@ -115,7 +125,7 @@ class MarketplaceError {
115
125
  import_core.ErrorType.USER,
116
126
  `Marketplace '${name}' not found`,
117
127
  { name },
118
- "Use `dexto plugin marketplace list` to see registered marketplaces"
128
+ "Use `/plugin` in the interactive CLI to see registered marketplaces"
119
129
  );
120
130
  }
121
131
  static updatePullFailed(name, cause) {
@@ -146,7 +156,7 @@ class MarketplaceError {
146
156
  import_core.ErrorType.USER,
147
157
  `Marketplace '${marketplace}' not found`,
148
158
  { marketplace },
149
- "Use `dexto plugin marketplace list` to see registered marketplaces, or `dexto plugin marketplace add` to register one"
159
+ "Use `/plugin` in the interactive CLI to see registered marketplaces"
150
160
  );
151
161
  }
152
162
  static installPluginNotFound(pluginName, marketplace) {
@@ -157,7 +167,7 @@ class MarketplaceError {
157
167
  import_core.ErrorType.USER,
158
168
  `Plugin '${pluginName}' not found${marketplaceInfo}`,
159
169
  { pluginName, marketplace },
160
- "Use `dexto plugin marketplace` to browse available plugins"
170
+ "Use `/plugin` in the interactive CLI to browse available plugins"
161
171
  );
162
172
  }
163
173
  static installCopyFailed(pluginName, cause) {
@@ -20,6 +20,9 @@ export declare class MarketplaceError {
20
20
  source: string;
21
21
  cause: string;
22
22
  }>;
23
+ static addInvalidName(name: string): DextoRuntimeError<{
24
+ name: string;
25
+ }>;
23
26
  static addInvalidSource(source: string, reason: string): DextoRuntimeError<{
24
27
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AC,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;IAY1D,MAAM,CAAC,UAAU,CAAC,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;CAU3D"}
@@ -43,6 +43,16 @@ class MarketplaceError {
43
43
  "Check the URL is correct and you have network access"
44
44
  );
45
45
  }
46
+ static addInvalidName(name) {
47
+ return new DextoRuntimeError(
48
+ MarketplaceErrorCode.ADD_INVALID_NAME,
49
+ ErrorScope.CONFIG,
50
+ ErrorType.USER,
51
+ `Invalid marketplace name '${name}'`,
52
+ { name },
53
+ 'Use letters, digits, ".", "_", "-" and spaces, starting with a letter or digit; pass --name to choose one'
54
+ );
55
+ }
46
56
  static addInvalidSource(source, reason) {
47
57
  return new DextoRuntimeError(
48
58
  MarketplaceErrorCode.ADD_INVALID_SOURCE,
@@ -71,7 +81,7 @@ class MarketplaceError {
71
81
  ErrorType.USER,
72
82
  `Marketplace '${name}' not found`,
73
83
  { name },
74
- "Use `dexto plugin marketplace list` to see registered marketplaces"
84
+ "Use `/plugin` in the interactive CLI to see registered marketplaces"
75
85
  );
76
86
  }
77
87
  static removeDeleteFailed(name, path, cause) {
@@ -92,7 +102,7 @@ class MarketplaceError {
92
102
  ErrorType.USER,
93
103
  `Marketplace '${name}' not found`,
94
104
  { name },
95
- "Use `dexto plugin marketplace list` to see registered marketplaces"
105
+ "Use `/plugin` in the interactive CLI to see registered marketplaces"
96
106
  );
97
107
  }
98
108
  static updatePullFailed(name, cause) {
@@ -123,7 +133,7 @@ class MarketplaceError {
123
133
  ErrorType.USER,
124
134
  `Marketplace '${marketplace}' not found`,
125
135
  { marketplace },
126
- "Use `dexto plugin marketplace list` to see registered marketplaces, or `dexto plugin marketplace add` to register one"
136
+ "Use `/plugin` in the interactive CLI to see registered marketplaces"
127
137
  );
128
138
  }
129
139
  static installPluginNotFound(pluginName, marketplace) {
@@ -134,7 +144,7 @@ class MarketplaceError {
134
144
  ErrorType.USER,
135
145
  `Plugin '${pluginName}' not found${marketplaceInfo}`,
136
146
  { pluginName, marketplace },
137
- "Use `dexto plugin marketplace` to browse available plugins"
147
+ "Use `/plugin` in the interactive CLI to browse available plugins"
138
148
  );
139
149
  }
140
150
  static installCopyFailed(pluginName, cause) {
@@ -104,7 +104,12 @@ async function installPluginFromMarketplace(pluginSpec, options = {}) {
104
104
  try {
105
105
  (0, import_fs.mkdirSync)(cachePath, { recursive: true });
106
106
  await (0, import_path.copyDirectory)(plugin.sourcePath, cachePath);
107
+ const unchanged = marketplaceEntry !== null && (0, import_operations.realPathInside)(marketplaceEntry.installLocation, plugin.sourcePath) === plugin.sourcePath;
108
+ if (!unchanged) {
109
+ throw new Error("the plugin directory changed while it was being copied");
110
+ }
107
111
  } catch (error) {
112
+ (0, import_fs.rmSync)(cachePath, { recursive: true, force: true });
108
113
  throw import_errors.MarketplaceError.installCopyFailed(
109
114
  pluginName,
110
115
  error instanceof Error ? error.message : String(error)
@@ -1 +1 @@
1
- {"version":3,"file":"install-from-marketplace.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/install-from-marketplace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,KAAK,EACR,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACpB,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAY1F;AA0BD;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAC9C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,yBAA8B,GACxC,OAAO,CAAC,wBAAwB,CAAC,CAgFnC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,MAAM,GACzB,iBAAiB,EAAE,CAqBrB"}
1
+ {"version":3,"file":"install-from-marketplace.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/install-from-marketplace.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH,OAAO,KAAK,EACR,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACpB,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAY1F;AA0BD;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAC9C,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,yBAA8B,GACxC,OAAO,CAAC,wBAAwB,CAAC,CA0FnC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,MAAM,GACzB,iBAAiB,EAAE,CAqBrB"}
@@ -1,10 +1,11 @@
1
1
  import * as path from "path";
2
- import { existsSync, mkdirSync } from "fs";
2
+ import { existsSync, mkdirSync, rmSync } from "fs";
3
3
  import { execSync } from "child_process";
4
4
  import { copyDirectory } from "../../utils/path.js";
5
5
  import { getMarketplaceCacheDir, getMarketplaceEntry } from "./registry.js";
6
6
  import {
7
7
  findPluginInMarketplaces,
8
+ realPathInside,
8
9
  scanMarketplacePlugins,
9
10
  listAllMarketplacePlugins
10
11
  } from "./operations.js";
@@ -73,7 +74,12 @@ async function installPluginFromMarketplace(pluginSpec, options = {}) {
73
74
  try {
74
75
  mkdirSync(cachePath, { recursive: true });
75
76
  await copyDirectory(plugin.sourcePath, cachePath);
77
+ const unchanged = marketplaceEntry !== null && realPathInside(marketplaceEntry.installLocation, plugin.sourcePath) === plugin.sourcePath;
78
+ if (!unchanged) {
79
+ throw new Error("the plugin directory changed while it was being copied");
80
+ }
76
81
  } catch (error) {
82
+ rmSync(cachePath, { recursive: true, force: true });
77
83
  throw MarketplaceError.installCopyFailed(
78
84
  pluginName,
79
85
  error instanceof Error ? error.message : String(error)
@@ -34,6 +34,7 @@ __export(operations_exports, {
34
34
  listAllMarketplacePlugins: () => listAllMarketplacePlugins,
35
35
  listMarketplaces: () => listMarketplaces,
36
36
  parseMarketplaceSource: () => parseMarketplaceSource,
37
+ realPathInside: () => realPathInside,
37
38
  removeMarketplace: () => removeMarketplace,
38
39
  scanMarketplacePlugins: () => scanMarketplacePlugins,
39
40
  updateMarketplace: () => updateMarketplace
@@ -45,6 +46,7 @@ var import_child_process = require("child_process");
45
46
  var import_registry = require("./registry.js");
46
47
  var import_errors = require("./errors.js");
47
48
  var import_schemas = require("./schemas.js");
49
+ var import_schemas2 = require("../schemas.js");
48
50
  var import_validate_plugin = require("../validate-plugin.js");
49
51
  function parseMarketplaceSource(source) {
50
52
  const trimmed = source.trim();
@@ -102,6 +104,9 @@ function getGitSha(dir) {
102
104
  async function addMarketplace(source, options = {}) {
103
105
  const parsedSource = parseMarketplaceSource(source);
104
106
  const name = options.name || deriveMarketplaceName(parsedSource);
107
+ if (!import_schemas2.SafePluginNameSchema.safeParse(name).success) {
108
+ throw import_errors.MarketplaceError.addInvalidName(name);
109
+ }
105
110
  const warnings = [];
106
111
  const existing = (0, import_registry.getMarketplaceEntry)(name);
107
112
  if (existing) {
@@ -119,7 +124,7 @@ async function addMarketplace(source, options = {}) {
119
124
  installLocation = path.join(marketplacesDir, name);
120
125
  const cloneUrl = getCloneUrl(parsedSource);
121
126
  try {
122
- (0, import_child_process.execSync)(`git clone "${cloneUrl}" "${installLocation}"`, {
127
+ (0, import_child_process.execFileSync)("git", ["clone", "--", cloneUrl, installLocation], {
123
128
  encoding: "utf-8",
124
129
  stdio: ["pipe", "pipe", "pipe"]
125
130
  });
@@ -204,7 +209,7 @@ async function updateSingleMarketplace(name) {
204
209
  warnings.push("Marketplace directory not found, re-cloning");
205
210
  const cloneUrl = getCloneUrl(entry.source);
206
211
  try {
207
- (0, import_child_process.execSync)(`git clone "${cloneUrl}" "${entry.installLocation}"`, {
212
+ (0, import_child_process.execFileSync)("git", ["clone", "--", cloneUrl, entry.installLocation], {
208
213
  encoding: "utf-8",
209
214
  stdio: ["pipe", "pipe", "pipe"]
210
215
  });
@@ -254,6 +259,16 @@ async function updateSingleMarketplace(name) {
254
259
  function listMarketplaces() {
255
260
  return (0, import_registry.getAllMarketplaces)();
256
261
  }
262
+ function realPathInside(directory, target) {
263
+ try {
264
+ const realTarget = (0, import_fs.realpathSync)(target);
265
+ const relative = path.relative((0, import_fs.realpathSync)(directory), realTarget);
266
+ const inside = relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
267
+ return inside ? realTarget : void 0;
268
+ } catch {
269
+ return void 0;
270
+ }
271
+ }
257
272
  function scanMarketplacePlugins(marketplacePath, marketplaceName) {
258
273
  const plugins = [];
259
274
  const manifestPath = path.join(marketplacePath, "marketplace.json");
@@ -266,8 +281,11 @@ function scanMarketplacePlugins(marketplacePath, marketplaceName) {
266
281
  const manifest = result.data;
267
282
  if (manifest.plugins && manifest.plugins.length > 0) {
268
283
  for (const plugin of manifest.plugins) {
269
- const pluginPath = path.join(marketplacePath, plugin.source);
270
- if ((0, import_fs.existsSync)(pluginPath)) {
284
+ const pluginPath = realPathInside(
285
+ marketplacePath,
286
+ path.resolve(marketplacePath, plugin.source)
287
+ );
288
+ if (pluginPath !== void 0) {
271
289
  plugins.push({
272
290
  name: plugin.name,
273
291
  ...plugin.description !== void 0 && {
@@ -294,7 +312,8 @@ function scanMarketplacePlugins(marketplacePath, marketplaceName) {
294
312
  const entries = (0, import_fs.readdirSync)(dirPath, { withFileTypes: true });
295
313
  for (const entry of entries) {
296
314
  if (!entry.isDirectory()) continue;
297
- const pluginPath = path.join(dirPath, entry.name);
315
+ const pluginPath = realPathInside(marketplacePath, path.join(dirPath, entry.name));
316
+ if (pluginPath === void 0) continue;
298
317
  const manifest = (0, import_validate_plugin.tryLoadManifest)(pluginPath);
299
318
  if (manifest) {
300
319
  plugins.push({
@@ -317,7 +336,11 @@ function scanMarketplacePlugins(marketplacePath, marketplaceName) {
317
336
  if (!entry.isDirectory()) continue;
318
337
  if (["plugins", "external_plugins", ".git", "node_modules"].includes(entry.name))
319
338
  continue;
320
- const pluginPath = path.join(marketplacePath, entry.name);
339
+ const pluginPath = realPathInside(
340
+ marketplacePath,
341
+ path.join(marketplacePath, entry.name)
342
+ );
343
+ if (pluginPath === void 0) continue;
321
344
  const manifest = (0, import_validate_plugin.tryLoadManifest)(pluginPath);
322
345
  if (manifest) {
323
346
  const existing = plugins.find((p) => p.name === manifest.name);
@@ -368,6 +391,7 @@ function findPluginInMarketplaces(pluginName, marketplaceName) {
368
391
  listAllMarketplacePlugins,
369
392
  listMarketplaces,
370
393
  parseMarketplaceSource,
394
+ realPathInside,
371
395
  removeMarketplace,
372
396
  scanMarketplacePlugins,
373
397
  updateMarketplace
@@ -28,6 +28,12 @@ export declare function updateMarketplace(name?: string): Promise<MarketplaceUpd
28
28
  * List all registered marketplaces
29
29
  */
30
30
  export declare function listMarketplaces(): MarketplaceEntry[];
31
+ /**
32
+ * The real path of `target` when it really lives inside `directory`, after following every
33
+ * symlink on both paths; undefined when it is outside or cannot be resolved (fail closed).
34
+ * Callers use the returned path from then on, so what is copied is what was checked.
35
+ */
36
+ export declare function realPathInside(directory: string, target: string): string | undefined;
31
37
  /**
32
38
  * Scan a marketplace directory for plugins
33
39
  */
@@ -1 +1 @@
1
- {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/operations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,OAAO,KAAK,EACR,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EAE1B,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CA0BxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAqBvE;AAgCD;;GAEG;AACH,wBAAsB,cAAc,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,qBAA0B,GACpC,OAAO,CAAC,oBAAoB,CAAC,CAmE/B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA6BtF;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAiBzF;AAwFD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,EAAE,CAErD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAClC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACxB,iBAAiB,EAAE,CA0GrB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,iBAAiB,EAAE,CAY/D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACzB,iBAAiB,GAAG,IAAI,CAiB1B"}
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/operations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,OAAO,KAAK,EACR,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,EAE1B,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CA0BxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAqBvE;AAgCD;;GAEG;AACH,wBAAsB,cAAc,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,qBAA0B,GACpC,OAAO,CAAC,oBAAoB,CAAC,CAsE/B;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA6BtF;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAiBzF;AAwFD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,EAAE,CAErD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUpF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAClC,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,MAAM,GACxB,iBAAiB,EAAE,CAoHrB;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,iBAAiB,EAAE,CAY/D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,MAAM,EAClB,eAAe,CAAC,EAAE,MAAM,GACzB,iBAAiB,GAAG,IAAI,CAiB1B"}
@@ -1,6 +1,6 @@
1
1
  import * as path from "path";
2
- import { existsSync, readdirSync, readFileSync, rmSync } from "fs";
3
- import { execSync } from "child_process";
2
+ import { existsSync, readdirSync, readFileSync, realpathSync, rmSync } from "fs";
3
+ import { execFileSync, execSync } from "child_process";
4
4
  import {
5
5
  getMarketplacesDir,
6
6
  addMarketplaceEntry,
@@ -11,6 +11,7 @@ import {
11
11
  } from "./registry.js";
12
12
  import { MarketplaceError } from "./errors.js";
13
13
  import { MarketplaceManifestSchema } from "./schemas.js";
14
+ import { SafePluginNameSchema } from "../schemas.js";
14
15
  import { tryLoadManifest } from "../validate-plugin.js";
15
16
  function parseMarketplaceSource(source) {
16
17
  const trimmed = source.trim();
@@ -68,6 +69,9 @@ function getGitSha(dir) {
68
69
  async function addMarketplace(source, options = {}) {
69
70
  const parsedSource = parseMarketplaceSource(source);
70
71
  const name = options.name || deriveMarketplaceName(parsedSource);
72
+ if (!SafePluginNameSchema.safeParse(name).success) {
73
+ throw MarketplaceError.addInvalidName(name);
74
+ }
71
75
  const warnings = [];
72
76
  const existing = getMarketplaceEntry(name);
73
77
  if (existing) {
@@ -85,7 +89,7 @@ async function addMarketplace(source, options = {}) {
85
89
  installLocation = path.join(marketplacesDir, name);
86
90
  const cloneUrl = getCloneUrl(parsedSource);
87
91
  try {
88
- execSync(`git clone "${cloneUrl}" "${installLocation}"`, {
92
+ execFileSync("git", ["clone", "--", cloneUrl, installLocation], {
89
93
  encoding: "utf-8",
90
94
  stdio: ["pipe", "pipe", "pipe"]
91
95
  });
@@ -170,7 +174,7 @@ async function updateSingleMarketplace(name) {
170
174
  warnings.push("Marketplace directory not found, re-cloning");
171
175
  const cloneUrl = getCloneUrl(entry.source);
172
176
  try {
173
- execSync(`git clone "${cloneUrl}" "${entry.installLocation}"`, {
177
+ execFileSync("git", ["clone", "--", cloneUrl, entry.installLocation], {
174
178
  encoding: "utf-8",
175
179
  stdio: ["pipe", "pipe", "pipe"]
176
180
  });
@@ -220,6 +224,16 @@ async function updateSingleMarketplace(name) {
220
224
  function listMarketplaces() {
221
225
  return getAllMarketplaces();
222
226
  }
227
+ function realPathInside(directory, target) {
228
+ try {
229
+ const realTarget = realpathSync(target);
230
+ const relative = path.relative(realpathSync(directory), realTarget);
231
+ const inside = relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
232
+ return inside ? realTarget : void 0;
233
+ } catch {
234
+ return void 0;
235
+ }
236
+ }
223
237
  function scanMarketplacePlugins(marketplacePath, marketplaceName) {
224
238
  const plugins = [];
225
239
  const manifestPath = path.join(marketplacePath, "marketplace.json");
@@ -232,8 +246,11 @@ function scanMarketplacePlugins(marketplacePath, marketplaceName) {
232
246
  const manifest = result.data;
233
247
  if (manifest.plugins && manifest.plugins.length > 0) {
234
248
  for (const plugin of manifest.plugins) {
235
- const pluginPath = path.join(marketplacePath, plugin.source);
236
- if (existsSync(pluginPath)) {
249
+ const pluginPath = realPathInside(
250
+ marketplacePath,
251
+ path.resolve(marketplacePath, plugin.source)
252
+ );
253
+ if (pluginPath !== void 0) {
237
254
  plugins.push({
238
255
  name: plugin.name,
239
256
  ...plugin.description !== void 0 && {
@@ -260,7 +277,8 @@ function scanMarketplacePlugins(marketplacePath, marketplaceName) {
260
277
  const entries = readdirSync(dirPath, { withFileTypes: true });
261
278
  for (const entry of entries) {
262
279
  if (!entry.isDirectory()) continue;
263
- const pluginPath = path.join(dirPath, entry.name);
280
+ const pluginPath = realPathInside(marketplacePath, path.join(dirPath, entry.name));
281
+ if (pluginPath === void 0) continue;
264
282
  const manifest = tryLoadManifest(pluginPath);
265
283
  if (manifest) {
266
284
  plugins.push({
@@ -283,7 +301,11 @@ function scanMarketplacePlugins(marketplacePath, marketplaceName) {
283
301
  if (!entry.isDirectory()) continue;
284
302
  if (["plugins", "external_plugins", ".git", "node_modules"].includes(entry.name))
285
303
  continue;
286
- const pluginPath = path.join(marketplacePath, entry.name);
304
+ const pluginPath = realPathInside(
305
+ marketplacePath,
306
+ path.join(marketplacePath, entry.name)
307
+ );
308
+ if (pluginPath === void 0) continue;
287
309
  const manifest = tryLoadManifest(pluginPath);
288
310
  if (manifest) {
289
311
  const existing = plugins.find((p) => p.name === manifest.name);
@@ -333,6 +355,7 @@ export {
333
355
  listAllMarketplacePlugins,
334
356
  listMarketplaces,
335
357
  parseMarketplaceSource,
358
+ realPathInside,
336
359
  removeMarketplace,
337
360
  scanMarketplacePlugins,
338
361
  updateMarketplace
@@ -28,6 +28,7 @@ __export(schemas_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(schemas_exports);
30
30
  var import_zod = require("zod");
31
+ var import_schemas = require("../schemas.js");
31
32
  const MarketplaceSourceSchema = import_zod.z.object({
32
33
  type: import_zod.z.enum(["github", "git", "local"]).describe("Type of marketplace source"),
33
34
  value: import_zod.z.string().min(1).describe("Source value: owner/repo, git URL, or local path")
@@ -43,7 +44,7 @@ const KnownMarketplacesFileSchema = import_zod.z.object({
43
44
  marketplaces: import_zod.z.record(import_zod.z.string(), MarketplaceEntrySchema).default({}).describe("Registered marketplaces by name")
44
45
  }).strict();
45
46
  const MarketplacePluginEntrySchema = import_zod.z.object({
46
- name: import_zod.z.string().min(1).describe("Plugin name"),
47
+ name: import_schemas.SafePluginNameSchema.describe("Plugin name"),
47
48
  description: import_zod.z.string().optional().describe("Plugin description"),
48
49
  source: import_zod.z.string().describe("Path to plugin within marketplace"),
49
50
  category: import_zod.z.string().optional().describe("Plugin category"),
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/schemas.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;kBAKvB,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;kBAOtB,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;kBAQ3B,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;;iBAQvB,CAAC;AAEnB;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;iBAapB,CAAC;AAEnB;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;kBAQ3B,CAAC;AAEd,eAAO,MAAM,+BAA+B;;;;;;;;kBAM/B,CAAC"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/schemas.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;kBAKvB,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;kBAOtB,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;kBAQ3B,CAAC;AAEd;;GAEG;AACH,eAAO,MAAM,4BAA4B;;;;;;iBAQvB,CAAC;AAEnB;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;iBAapB,CAAC;AAEnB;;GAEG;AACH,eAAO,MAAM,2BAA2B;;;kBAQ3B,CAAC;AAEd,eAAO,MAAM,+BAA+B;;;;;;;;kBAM/B,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { SafePluginNameSchema } from "../schemas.js";
2
3
  const MarketplaceSourceSchema = z.object({
3
4
  type: z.enum(["github", "git", "local"]).describe("Type of marketplace source"),
4
5
  value: z.string().min(1).describe("Source value: owner/repo, git URL, or local path")
@@ -14,7 +15,7 @@ const KnownMarketplacesFileSchema = z.object({
14
15
  marketplaces: z.record(z.string(), MarketplaceEntrySchema).default({}).describe("Registered marketplaces by name")
15
16
  }).strict();
16
17
  const MarketplacePluginEntrySchema = z.object({
17
- name: z.string().min(1).describe("Plugin name"),
18
+ name: SafePluginNameSchema.describe("Plugin name"),
18
19
  description: z.string().optional().describe("Plugin description"),
19
20
  source: z.string().describe("Path to plugin within marketplace"),
20
21
  category: z.string().optional().describe("Plugin category"),
@@ -21,7 +21,8 @@ __export(schemas_exports, {
21
21
  InstalledPluginEntrySchema: () => InstalledPluginEntrySchema,
22
22
  InstalledPluginsFileSchema: () => InstalledPluginsFileSchema,
23
23
  PluginMCPConfigSchema: () => PluginMCPConfigSchema,
24
- PluginManifestSchema: () => PluginManifestSchema
24
+ PluginManifestSchema: () => PluginManifestSchema,
25
+ SafePluginNameSchema: () => SafePluginNameSchema
25
26
  });
26
27
  module.exports = __toCommonJS(schemas_exports);
27
28
  var import_zod = require("zod");
@@ -32,8 +33,12 @@ const AuthorSchema = import_zod.z.union([
32
33
  email: import_zod.z.string().optional()
33
34
  })
34
35
  ]);
36
+ const SafePluginNameSchema = import_zod.z.string().regex(
37
+ /^[A-Za-z0-9][A-Za-z0-9._ -]*$/,
38
+ 'Name may only contain letters, digits, ".", "_", "-" and spaces, and must start with a letter or digit'
39
+ );
35
40
  const PluginManifestSchema = import_zod.z.object({
36
- name: import_zod.z.string().min(1).describe("Unique plugin name (used for namespacing commands)"),
41
+ name: SafePluginNameSchema.describe("Unique plugin name (used for namespacing commands)"),
37
42
  description: import_zod.z.string().optional().describe("Human-readable plugin description"),
38
43
  version: import_zod.z.string().optional().describe("Semantic version (e.g., 1.0.0)"),
39
44
  author: AuthorSchema.optional().describe("Plugin author - string or {name, email} object")
@@ -60,5 +65,6 @@ const InstalledPluginsFileSchema = import_zod.z.object({
60
65
  InstalledPluginEntrySchema,
61
66
  InstalledPluginsFileSchema,
62
67
  PluginMCPConfigSchema,
63
- PluginManifestSchema
68
+ PluginManifestSchema,
69
+ SafePluginNameSchema
64
70
  });
@@ -5,6 +5,11 @@
5
5
  * - .claude-plugin/plugin.json
6
6
  */
7
7
  import { z } from 'zod';
8
+ /**
9
+ * A plugin or marketplace name is used as a directory name, so it must be a single safe path
10
+ * segment: no separators and no leading dot.
11
+ */
12
+ export declare const SafePluginNameSchema: z.ZodString;
8
13
  /**
9
14
  * Schema for Claude Code plugin.json manifest
10
15
  * Uses passthrough to allow unknown fields from Claude Code plugins
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/plugins/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;iBAQ2C,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;iBAQe,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;iBAeG,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;iBAQgB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/plugins/schemas.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,aAK5B,CAAC;AAEN;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;iBAQ2C,CAAC;AAE7E;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;iBAQe,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;iBAeG,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;iBAQgB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAExF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
@@ -6,8 +6,12 @@ const AuthorSchema = z.union([
6
6
  email: z.string().optional()
7
7
  })
8
8
  ]);
9
+ const SafePluginNameSchema = z.string().regex(
10
+ /^[A-Za-z0-9][A-Za-z0-9._ -]*$/,
11
+ 'Name may only contain letters, digits, ".", "_", "-" and spaces, and must start with a letter or digit'
12
+ );
9
13
  const PluginManifestSchema = z.object({
10
- name: z.string().min(1).describe("Unique plugin name (used for namespacing commands)"),
14
+ name: SafePluginNameSchema.describe("Unique plugin name (used for namespacing commands)"),
11
15
  description: z.string().optional().describe("Human-readable plugin description"),
12
16
  version: z.string().optional().describe("Semantic version (e.g., 1.0.0)"),
13
17
  author: AuthorSchema.optional().describe("Plugin author - string or {name, email} object")
@@ -33,5 +37,6 @@ export {
33
37
  InstalledPluginEntrySchema,
34
38
  InstalledPluginsFileSchema,
35
39
  PluginMCPConfigSchema,
36
- PluginManifestSchema
40
+ PluginManifestSchema,
41
+ SafePluginNameSchema
37
42
  };
@@ -33,7 +33,7 @@ class PreferenceError {
33
33
  import_core.ErrorType.USER,
34
34
  `Preferences file not found: ${preferencesPath}`,
35
35
  { preferencesPath },
36
- "Run `dexto setup` to create preferences"
36
+ "Run `dexto login` or set a provider key"
37
37
  );
38
38
  }
39
39
  static fileReadError(preferencesPath, cause) {
@@ -9,7 +9,7 @@ class PreferenceError {
9
9
  ErrorType.USER,
10
10
  `Preferences file not found: ${preferencesPath}`,
11
11
  { preferencesPath },
12
- "Run `dexto setup` to create preferences"
12
+ "Run `dexto login` or set a provider key"
13
13
  );
14
14
  }
15
15
  static fileReadError(preferencesPath, cause) {
@@ -43,6 +43,9 @@ var import_errors = require("./errors.js");
43
43
  var import_user_registry = require("./user-registry.js");
44
44
  var import_loader = require("../preferences/loader.js");
45
45
  let cachedRegistry = null;
46
+ function isOutsideAgentsDir(relativePath) {
47
+ return relativePath === "" || relativePath.startsWith("..") || import_path.default.isAbsolute(relativePath);
48
+ }
46
49
  class LocalAgentRegistry {
47
50
  _registry = null;
48
51
  /**
@@ -176,7 +179,7 @@ class LocalAgentRegistry {
176
179
  * @param agentId ID of the agent to install
177
180
  */
178
181
  async installAgent(agentId) {
179
- import_core.logger.info(`Installing agent: ${agentId}`);
182
+ import_core.logger.debug(`Installing agent: ${agentId}`);
180
183
  const registry = this.getRegistry();
181
184
  const agentData = registry.agents[agentId];
182
185
  if (!agentData) {
@@ -186,7 +189,7 @@ class LocalAgentRegistry {
186
189
  const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
187
190
  const targetDir = import_path.default.resolve(globalAgentsDir, agentId);
188
191
  const relTarget = import_path.default.relative(globalAgentsDir, targetDir);
189
- if (relTarget.startsWith("..") || import_path.default.isAbsolute(relTarget)) {
192
+ if (isOutsideAgentsDir(relTarget)) {
190
193
  throw import_errors.RegistryError.installationFailed(
191
194
  agentId,
192
195
  "invalid agentId: path traversal detected"
@@ -212,7 +215,7 @@ class LocalAgentRegistry {
212
215
  throw import_errors.RegistryError.installationValidationFailed(agentId, mainConfigPath);
213
216
  }
214
217
  await import_fs2.promises.rename(tempDir, targetDir);
215
- import_core.logger.info(`\u2713 Installed agent '${agentId}' to ${targetDir}`);
218
+ import_core.logger.debug(`\u2713 Installed agent '${agentId}' to ${targetDir}`);
216
219
  return this.resolveMainConfig(targetDir, agentId);
217
220
  } catch (error) {
218
221
  try {
@@ -246,7 +249,7 @@ class LocalAgentRegistry {
246
249
  const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
247
250
  const targetDir = import_path.default.resolve(globalAgentsDir, agentId);
248
251
  const relTarget = import_path.default.relative(globalAgentsDir, targetDir);
249
- if (relTarget.startsWith("..") || import_path.default.isAbsolute(relTarget)) {
252
+ if (isOutsideAgentsDir(relTarget)) {
250
253
  throw import_errors.RegistryError.installationFailed(
251
254
  agentId,
252
255
  "invalid agentId: path traversal detected"
@@ -351,7 +354,7 @@ class LocalAgentRegistry {
351
354
  import_core.logger.debug(`Agent '${agentId}' not found in installed path: ${installedPath}`);
352
355
  if (this.hasAgent(agentId)) {
353
356
  if (autoInstall) {
354
- import_core.logger.info(`Installing agent '${agentId}' from registry...`);
357
+ import_core.logger.debug(`Installing agent '${agentId}' from registry...`);
355
358
  return await this.installAgent(agentId);
356
359
  } else {
357
360
  const registry2 = this.getRegistry();
@@ -403,7 +406,7 @@ class LocalAgentRegistry {
403
406
  const globalAgentsDir = (0, import_path2.getDextoGlobalPath)("agents");
404
407
  const agentDir = import_path.default.resolve(globalAgentsDir, agentId);
405
408
  const relAgent = import_path.default.relative(globalAgentsDir, agentDir);
406
- if (relAgent.startsWith("..") || import_path.default.isAbsolute(relAgent)) {
409
+ if (isOutsideAgentsDir(relAgent)) {
407
410
  throw import_errors.RegistryError.uninstallationFailed(
408
411
  agentId,
409
412
  "invalid agentId: path traversal detected"
@@ -1,12 +1,4 @@
1
1
  import { Registry, AgentRegistry, AgentRegistryEntry } from './types.js';
2
- /**
3
- * Local agent registry implementation
4
- * Loads and merges the bundled registry (shipped with the CLI bundle) with the user's custom
5
- * registry under `~/.dexto`.
6
- *
7
- * Hosts (CLI, server, apps) use this to resolve an agent ID to a concrete YAML path, then
8
- * load/validate that YAML and instantiate a `DextoAgent` from the resolved config.
9
- */
10
2
  export declare class LocalAgentRegistry implements AgentRegistry {
11
3
  private _registry;
12
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,QAAQ,EAER,aAAa,EACb,kBAAkB,EAErB,MAAM,YAAY,CAAC;AAapB;;;;;;;GAOG;AACH,qBAAa,kBAAmB,YAAW,aAAa;IACpD,OAAO,CAAC,SAAS,CAAyB;IAE1C;;OAEG;IACH,WAAW,IAAI,QAAQ;IAOvB;;;OAGG;IACH,OAAO,CAAC,YAAY;IAyCpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAKlC;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAKxD;;;OAGG;IACH,OAAO,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