@dexto/agent-management 1.5.6 → 1.5.8

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 (140) hide show
  1. package/dist/config/config-enrichment.cjs +72 -21
  2. package/dist/config/config-enrichment.d.ts +10 -2
  3. package/dist/config/config-enrichment.d.ts.map +1 -1
  4. package/dist/config/config-enrichment.js +76 -21
  5. package/dist/config/discover-prompts.cjs +1 -1
  6. package/dist/config/discover-prompts.d.ts +11 -11
  7. package/dist/config/discover-prompts.d.ts.map +1 -1
  8. package/dist/config/discover-prompts.js +1 -1
  9. package/dist/config/loader.cjs +31 -13
  10. package/dist/config/loader.d.ts.map +1 -1
  11. package/dist/config/loader.js +31 -13
  12. package/dist/index.cjs +76 -0
  13. package/dist/index.d.ts +5 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +78 -0
  16. package/dist/models/custom-models.cjs +2 -1
  17. package/dist/models/custom-models.d.ts +7 -6
  18. package/dist/models/custom-models.d.ts.map +1 -1
  19. package/dist/models/custom-models.js +2 -1
  20. package/dist/plugins/discover-plugins.cjs +176 -0
  21. package/dist/plugins/discover-plugins.d.ts +39 -0
  22. package/dist/plugins/discover-plugins.d.ts.map +1 -0
  23. package/dist/plugins/discover-plugins.js +140 -0
  24. package/dist/plugins/discover-skills.cjs +93 -0
  25. package/dist/plugins/discover-skills.d.ts +49 -0
  26. package/dist/plugins/discover-skills.d.ts.map +1 -0
  27. package/dist/plugins/discover-skills.js +58 -0
  28. package/dist/plugins/error-codes.cjs +47 -0
  29. package/dist/plugins/error-codes.d.ts +24 -0
  30. package/dist/plugins/error-codes.d.ts.map +1 -0
  31. package/dist/plugins/error-codes.js +23 -0
  32. package/dist/plugins/errors.cjs +197 -0
  33. package/dist/plugins/errors.d.ts +68 -0
  34. package/dist/plugins/errors.d.ts.map +1 -0
  35. package/dist/plugins/errors.js +173 -0
  36. package/dist/plugins/index.cjs +144 -0
  37. package/dist/plugins/index.d.ts +23 -0
  38. package/dist/plugins/index.d.ts.map +1 -0
  39. package/dist/plugins/index.js +115 -0
  40. package/dist/plugins/install-plugin.cjs +211 -0
  41. package/dist/plugins/install-plugin.d.ts +47 -0
  42. package/dist/plugins/install-plugin.d.ts.map +1 -0
  43. package/dist/plugins/install-plugin.js +173 -0
  44. package/dist/plugins/list-plugins.cjs +134 -0
  45. package/dist/plugins/list-plugins.d.ts +26 -0
  46. package/dist/plugins/list-plugins.d.ts.map +1 -0
  47. package/dist/plugins/list-plugins.js +99 -0
  48. package/dist/plugins/load-plugin.cjs +197 -0
  49. package/dist/plugins/load-plugin.d.ts +20 -0
  50. package/dist/plugins/load-plugin.d.ts.map +1 -0
  51. package/dist/plugins/load-plugin.js +163 -0
  52. package/dist/plugins/marketplace/error-codes.cjs +45 -0
  53. package/dist/plugins/marketplace/error-codes.d.ts +21 -0
  54. package/dist/plugins/marketplace/error-codes.d.ts.map +1 -0
  55. package/dist/plugins/marketplace/error-codes.js +21 -0
  56. package/dist/plugins/marketplace/errors.cjs +188 -0
  57. package/dist/plugins/marketplace/errors.d.ts +64 -0
  58. package/dist/plugins/marketplace/errors.d.ts.map +1 -0
  59. package/dist/plugins/marketplace/errors.js +164 -0
  60. package/dist/plugins/marketplace/index.cjs +95 -0
  61. package/dist/plugins/marketplace/index.d.ts +14 -0
  62. package/dist/plugins/marketplace/index.d.ts.map +1 -0
  63. package/dist/plugins/marketplace/index.js +74 -0
  64. package/dist/plugins/marketplace/install-from-marketplace.cjs +152 -0
  65. package/dist/plugins/marketplace/install-from-marketplace.d.ts +25 -0
  66. package/dist/plugins/marketplace/install-from-marketplace.d.ts.map +1 -0
  67. package/dist/plugins/marketplace/install-from-marketplace.js +120 -0
  68. package/dist/plugins/marketplace/operations.cjs +374 -0
  69. package/dist/plugins/marketplace/operations.d.ts +43 -0
  70. package/dist/plugins/marketplace/operations.d.ts.map +1 -0
  71. package/dist/plugins/marketplace/operations.js +339 -0
  72. package/dist/plugins/marketplace/registry.cjs +166 -0
  73. package/dist/plugins/marketplace/registry.d.ts +72 -0
  74. package/dist/plugins/marketplace/registry.d.ts.map +1 -0
  75. package/dist/plugins/marketplace/registry.js +119 -0
  76. package/dist/plugins/marketplace/schemas.cjs +79 -0
  77. package/dist/plugins/marketplace/schemas.d.ts +260 -0
  78. package/dist/plugins/marketplace/schemas.d.ts.map +1 -0
  79. package/dist/plugins/marketplace/schemas.js +49 -0
  80. package/dist/plugins/marketplace/types.cjs +16 -0
  81. package/dist/plugins/marketplace/types.d.ts +156 -0
  82. package/dist/plugins/marketplace/types.d.ts.map +1 -0
  83. package/dist/plugins/marketplace/types.js +0 -0
  84. package/dist/plugins/schemas.cjs +74 -0
  85. package/dist/plugins/schemas.d.ts +262 -0
  86. package/dist/plugins/schemas.d.ts.map +1 -0
  87. package/dist/plugins/schemas.js +46 -0
  88. package/dist/plugins/types.cjs +16 -0
  89. package/dist/plugins/types.d.ts +186 -0
  90. package/dist/plugins/types.d.ts.map +1 -0
  91. package/dist/plugins/types.js +0 -0
  92. package/dist/plugins/uninstall-plugin.cjs +133 -0
  93. package/dist/plugins/uninstall-plugin.d.ts +24 -0
  94. package/dist/plugins/uninstall-plugin.d.ts.map +1 -0
  95. package/dist/plugins/uninstall-plugin.js +99 -0
  96. package/dist/plugins/validate-plugin.cjs +180 -0
  97. package/dist/plugins/validate-plugin.d.ts +53 -0
  98. package/dist/plugins/validate-plugin.d.ts.map +1 -0
  99. package/dist/plugins/validate-plugin.js +145 -0
  100. package/dist/preferences/errors.cjs +11 -0
  101. package/dist/preferences/errors.d.ts +1 -0
  102. package/dist/preferences/errors.d.ts.map +1 -1
  103. package/dist/preferences/errors.js +11 -0
  104. package/dist/preferences/loader.cjs +119 -6
  105. package/dist/preferences/loader.d.ts +21 -1
  106. package/dist/preferences/loader.d.ts.map +1 -1
  107. package/dist/preferences/loader.js +102 -1
  108. package/dist/preferences/schemas.cjs +12 -0
  109. package/dist/preferences/schemas.d.ts +38 -12
  110. package/dist/preferences/schemas.d.ts.map +1 -1
  111. package/dist/preferences/schemas.js +10 -0
  112. package/dist/runtime/AgentRuntime.cjs +1 -2
  113. package/dist/runtime/AgentRuntime.d.ts.map +1 -1
  114. package/dist/runtime/AgentRuntime.js +1 -2
  115. package/dist/tool-provider/llm-resolution.cjs +74 -0
  116. package/dist/tool-provider/llm-resolution.d.ts +51 -0
  117. package/dist/tool-provider/llm-resolution.d.ts.map +1 -0
  118. package/dist/tool-provider/llm-resolution.js +50 -0
  119. package/dist/tool-provider/runtime-service.cjs +246 -34
  120. package/dist/tool-provider/runtime-service.d.ts +34 -2
  121. package/dist/tool-provider/runtime-service.d.ts.map +1 -1
  122. package/dist/tool-provider/runtime-service.js +236 -34
  123. package/dist/tool-provider/tool-provider.cjs +154 -1
  124. package/dist/tool-provider/tool-provider.d.ts +7 -1
  125. package/dist/tool-provider/tool-provider.d.ts.map +1 -1
  126. package/dist/tool-provider/tool-provider.js +161 -1
  127. package/dist/tool-provider/types.d.ts +2 -0
  128. package/dist/tool-provider/types.d.ts.map +1 -1
  129. package/dist/utils/api-key-resolver.cjs +5 -2
  130. package/dist/utils/api-key-resolver.d.ts.map +1 -1
  131. package/dist/utils/api-key-resolver.js +5 -2
  132. package/dist/utils/dexto-auth.cjs +83 -0
  133. package/dist/utils/dexto-auth.d.ts +23 -0
  134. package/dist/utils/dexto-auth.d.ts.map +1 -0
  135. package/dist/utils/dexto-auth.js +57 -0
  136. package/dist/utils/feature-flags.cjs +32 -0
  137. package/dist/utils/feature-flags.d.ts +21 -0
  138. package/dist/utils/feature-flags.d.ts.map +1 -0
  139. package/dist/utils/feature-flags.js +8 -0
  140. package/package.json +3 -2
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Plugin Marketplace Operations
3
+ *
4
+ * Handles adding, removing, updating, and listing marketplaces.
5
+ */
6
+ import type { MarketplaceSource, MarketplaceEntry, MarketplacePlugin, MarketplaceAddOptions, MarketplaceAddResult, MarketplaceRemoveResult, MarketplaceUpdateResult } from './types.js';
7
+ /**
8
+ * Parse a source string to determine its type and value
9
+ */
10
+ export declare function parseMarketplaceSource(source: string): MarketplaceSource;
11
+ /**
12
+ * Derive a marketplace name from its source
13
+ */
14
+ export declare function deriveMarketplaceName(source: MarketplaceSource): string;
15
+ /**
16
+ * Add a marketplace
17
+ */
18
+ export declare function addMarketplace(source: string, options?: MarketplaceAddOptions): Promise<MarketplaceAddResult>;
19
+ /**
20
+ * Remove a marketplace
21
+ */
22
+ export declare function removeMarketplace(name: string): Promise<MarketplaceRemoveResult>;
23
+ /**
24
+ * Update a marketplace (git pull)
25
+ */
26
+ export declare function updateMarketplace(name?: string): Promise<MarketplaceUpdateResult[]>;
27
+ /**
28
+ * List all registered marketplaces
29
+ */
30
+ export declare function listMarketplaces(): MarketplaceEntry[];
31
+ /**
32
+ * Scan a marketplace directory for plugins
33
+ */
34
+ export declare function scanMarketplacePlugins(marketplacePath: string, marketplaceName: string): MarketplacePlugin[];
35
+ /**
36
+ * List all plugins across all marketplaces
37
+ */
38
+ export declare function listAllMarketplacePlugins(): MarketplacePlugin[];
39
+ /**
40
+ * Find a plugin by name across all marketplaces
41
+ */
42
+ export declare function findPluginInMarketplaces(pluginName: string, marketplaceName?: string): MarketplacePlugin | null;
43
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,339 @@
1
+ import * as path from "path";
2
+ import { existsSync, readdirSync, readFileSync, rmSync } from "fs";
3
+ import { execSync } from "child_process";
4
+ import {
5
+ getMarketplacesDir,
6
+ addMarketplaceEntry,
7
+ removeMarketplaceEntry,
8
+ getMarketplaceEntry,
9
+ getAllMarketplaces,
10
+ updateMarketplaceTimestamp
11
+ } from "./registry.js";
12
+ import { MarketplaceError } from "./errors.js";
13
+ import { MarketplaceManifestSchema } from "./schemas.js";
14
+ import { tryLoadManifest } from "../validate-plugin.js";
15
+ function parseMarketplaceSource(source) {
16
+ const trimmed = source.trim();
17
+ if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../") || trimmed.startsWith("~/")) {
18
+ return { type: "local", value: trimmed };
19
+ }
20
+ if (trimmed.includes("://") || trimmed.endsWith(".git")) {
21
+ return { type: "git", value: trimmed };
22
+ }
23
+ const githubMatch = /^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)$/.exec(trimmed);
24
+ if (githubMatch) {
25
+ return { type: "github", value: trimmed };
26
+ }
27
+ return { type: "git", value: trimmed };
28
+ }
29
+ function deriveMarketplaceName(source) {
30
+ switch (source.type) {
31
+ case "github": {
32
+ const parts = source.value.split("/");
33
+ return parts[parts.length - 1] ?? source.value;
34
+ }
35
+ case "git": {
36
+ const url = source.value.replace(/\.git$/, "");
37
+ const parts = url.split("/");
38
+ return parts[parts.length - 1] ?? "marketplace";
39
+ }
40
+ case "local": {
41
+ const resolved = source.value.startsWith("~") ? source.value.replace("~", process.env.HOME || "") : path.resolve(source.value);
42
+ return path.basename(resolved);
43
+ }
44
+ }
45
+ }
46
+ function getCloneUrl(source) {
47
+ switch (source.type) {
48
+ case "github":
49
+ return `https://github.com/${source.value}.git`;
50
+ case "git":
51
+ return source.value;
52
+ case "local":
53
+ throw new Error("Cannot clone local source");
54
+ }
55
+ }
56
+ function getGitSha(dir) {
57
+ try {
58
+ const result = execSync("git rev-parse HEAD", {
59
+ cwd: dir,
60
+ encoding: "utf-8",
61
+ stdio: ["pipe", "pipe", "pipe"]
62
+ });
63
+ return result.trim();
64
+ } catch {
65
+ return void 0;
66
+ }
67
+ }
68
+ async function addMarketplace(source, options = {}) {
69
+ const parsedSource = parseMarketplaceSource(source);
70
+ const name = options.name || deriveMarketplaceName(parsedSource);
71
+ const warnings = [];
72
+ const existing = getMarketplaceEntry(name);
73
+ if (existing) {
74
+ throw MarketplaceError.addAlreadyExists(name, existing.installLocation);
75
+ }
76
+ let installLocation;
77
+ if (parsedSource.type === "local") {
78
+ const localPath = parsedSource.value.startsWith("~") ? parsedSource.value.replace("~", process.env.HOME || "") : path.resolve(parsedSource.value);
79
+ if (!existsSync(localPath)) {
80
+ throw MarketplaceError.addLocalNotFound(localPath);
81
+ }
82
+ installLocation = localPath;
83
+ } else {
84
+ const marketplacesDir = getMarketplacesDir();
85
+ installLocation = path.join(marketplacesDir, name);
86
+ const cloneUrl = getCloneUrl(parsedSource);
87
+ try {
88
+ execSync(`git clone "${cloneUrl}" "${installLocation}"`, {
89
+ encoding: "utf-8",
90
+ stdio: ["pipe", "pipe", "pipe"]
91
+ });
92
+ } catch (error) {
93
+ throw MarketplaceError.addCloneFailed(
94
+ source,
95
+ error instanceof Error ? error.message : String(error)
96
+ );
97
+ }
98
+ }
99
+ const plugins = scanMarketplacePlugins(installLocation, name);
100
+ if (plugins.length === 0) {
101
+ warnings.push("No plugins found in marketplace");
102
+ }
103
+ const entry = {
104
+ name,
105
+ source: parsedSource,
106
+ installLocation,
107
+ lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
108
+ };
109
+ addMarketplaceEntry(entry);
110
+ return {
111
+ success: true,
112
+ name,
113
+ pluginCount: plugins.length,
114
+ warnings
115
+ };
116
+ }
117
+ async function removeMarketplace(name) {
118
+ const entry = getMarketplaceEntry(name);
119
+ if (!entry) {
120
+ throw MarketplaceError.removeNotFound(name);
121
+ }
122
+ if (entry.source.type !== "local") {
123
+ try {
124
+ if (existsSync(entry.installLocation)) {
125
+ rmSync(entry.installLocation, { recursive: true, force: true });
126
+ }
127
+ } catch (error) {
128
+ throw MarketplaceError.removeDeleteFailed(
129
+ name,
130
+ entry.installLocation,
131
+ error instanceof Error ? error.message : String(error)
132
+ );
133
+ }
134
+ }
135
+ removeMarketplaceEntry(name);
136
+ return {
137
+ success: true,
138
+ name
139
+ };
140
+ }
141
+ async function updateMarketplace(name) {
142
+ const results = [];
143
+ if (name) {
144
+ const result = await updateSingleMarketplace(name);
145
+ results.push(result);
146
+ } else {
147
+ const marketplaces = getAllMarketplaces();
148
+ for (const marketplace of marketplaces) {
149
+ const result = await updateSingleMarketplace(marketplace.name);
150
+ results.push(result);
151
+ }
152
+ }
153
+ return results;
154
+ }
155
+ async function updateSingleMarketplace(name) {
156
+ const entry = getMarketplaceEntry(name);
157
+ if (!entry) {
158
+ throw MarketplaceError.updateNotFound(name);
159
+ }
160
+ const warnings = [];
161
+ if (entry.source.type === "local") {
162
+ return {
163
+ success: true,
164
+ name,
165
+ hasChanges: false,
166
+ warnings: ["Local marketplaces do not support automatic updates"]
167
+ };
168
+ }
169
+ if (!existsSync(entry.installLocation)) {
170
+ warnings.push("Marketplace directory not found, re-cloning");
171
+ const cloneUrl = getCloneUrl(entry.source);
172
+ try {
173
+ execSync(`git clone "${cloneUrl}" "${entry.installLocation}"`, {
174
+ encoding: "utf-8",
175
+ stdio: ["pipe", "pipe", "pipe"]
176
+ });
177
+ } catch (error) {
178
+ throw MarketplaceError.updatePullFailed(
179
+ name,
180
+ error instanceof Error ? error.message : String(error)
181
+ );
182
+ }
183
+ updateMarketplaceTimestamp(name);
184
+ const newShaValue2 = getGitSha(entry.installLocation);
185
+ return {
186
+ success: true,
187
+ name,
188
+ ...newShaValue2 !== void 0 && { newSha: newShaValue2 },
189
+ hasChanges: true,
190
+ warnings
191
+ };
192
+ }
193
+ const previousShaValue = getGitSha(entry.installLocation);
194
+ try {
195
+ execSync("git pull --ff-only", {
196
+ cwd: entry.installLocation,
197
+ encoding: "utf-8",
198
+ stdio: ["pipe", "pipe", "pipe"]
199
+ });
200
+ } catch (error) {
201
+ throw MarketplaceError.updatePullFailed(
202
+ name,
203
+ error instanceof Error ? error.message : String(error)
204
+ );
205
+ }
206
+ const newShaValue = getGitSha(entry.installLocation);
207
+ const hasChanges = previousShaValue !== newShaValue;
208
+ if (hasChanges) {
209
+ updateMarketplaceTimestamp(name);
210
+ }
211
+ return {
212
+ success: true,
213
+ name,
214
+ ...previousShaValue !== void 0 && { previousSha: previousShaValue },
215
+ ...newShaValue !== void 0 && { newSha: newShaValue },
216
+ hasChanges,
217
+ warnings
218
+ };
219
+ }
220
+ function listMarketplaces() {
221
+ return getAllMarketplaces();
222
+ }
223
+ function scanMarketplacePlugins(marketplacePath, marketplaceName) {
224
+ const plugins = [];
225
+ const manifestPath = path.join(marketplacePath, "marketplace.json");
226
+ if (existsSync(manifestPath)) {
227
+ try {
228
+ const content = readFileSync(manifestPath, "utf-8");
229
+ const parsed = JSON.parse(content);
230
+ const result = MarketplaceManifestSchema.safeParse(parsed);
231
+ if (result.success) {
232
+ const manifest = result.data;
233
+ if (manifest.plugins && manifest.plugins.length > 0) {
234
+ for (const plugin of manifest.plugins) {
235
+ const pluginPath = path.join(marketplacePath, plugin.source);
236
+ if (existsSync(pluginPath)) {
237
+ plugins.push({
238
+ name: plugin.name,
239
+ ...plugin.description !== void 0 && {
240
+ description: plugin.description
241
+ },
242
+ ...plugin.version !== void 0 && { version: plugin.version },
243
+ ...plugin.category !== void 0 && { category: plugin.category },
244
+ sourcePath: pluginPath,
245
+ marketplace: marketplaceName
246
+ });
247
+ }
248
+ }
249
+ return plugins;
250
+ }
251
+ }
252
+ } catch {
253
+ }
254
+ }
255
+ const pluginDirs = ["plugins", "external_plugins"];
256
+ for (const dir of pluginDirs) {
257
+ const dirPath = path.join(marketplacePath, dir);
258
+ if (!existsSync(dirPath)) continue;
259
+ try {
260
+ const entries = readdirSync(dirPath, { withFileTypes: true });
261
+ for (const entry of entries) {
262
+ if (!entry.isDirectory()) continue;
263
+ const pluginPath = path.join(dirPath, entry.name);
264
+ const manifest = tryLoadManifest(pluginPath);
265
+ if (manifest) {
266
+ plugins.push({
267
+ name: manifest.name,
268
+ ...manifest.description !== void 0 && {
269
+ description: manifest.description
270
+ },
271
+ ...manifest.version !== void 0 && { version: manifest.version },
272
+ sourcePath: pluginPath,
273
+ marketplace: marketplaceName
274
+ });
275
+ }
276
+ }
277
+ } catch {
278
+ }
279
+ }
280
+ try {
281
+ const rootEntries = readdirSync(marketplacePath, { withFileTypes: true });
282
+ for (const entry of rootEntries) {
283
+ if (!entry.isDirectory()) continue;
284
+ if (["plugins", "external_plugins", ".git", "node_modules"].includes(entry.name))
285
+ continue;
286
+ const pluginPath = path.join(marketplacePath, entry.name);
287
+ const manifest = tryLoadManifest(pluginPath);
288
+ if (manifest) {
289
+ const existing = plugins.find((p) => p.name === manifest.name);
290
+ if (!existing) {
291
+ plugins.push({
292
+ name: manifest.name,
293
+ ...manifest.description !== void 0 && {
294
+ description: manifest.description
295
+ },
296
+ ...manifest.version !== void 0 && { version: manifest.version },
297
+ sourcePath: pluginPath,
298
+ marketplace: marketplaceName
299
+ });
300
+ }
301
+ }
302
+ }
303
+ } catch {
304
+ }
305
+ return plugins;
306
+ }
307
+ function listAllMarketplacePlugins() {
308
+ const marketplaces = listMarketplaces();
309
+ const allPlugins = [];
310
+ for (const marketplace of marketplaces) {
311
+ if (!existsSync(marketplace.installLocation)) continue;
312
+ const plugins = scanMarketplacePlugins(marketplace.installLocation, marketplace.name);
313
+ allPlugins.push(...plugins);
314
+ }
315
+ return allPlugins;
316
+ }
317
+ function findPluginInMarketplaces(pluginName, marketplaceName) {
318
+ const marketplaces = marketplaceName ? [getMarketplaceEntry(marketplaceName)].filter(Boolean) : listMarketplaces();
319
+ for (const marketplace of marketplaces) {
320
+ if (!existsSync(marketplace.installLocation)) continue;
321
+ const plugins = scanMarketplacePlugins(marketplace.installLocation, marketplace.name);
322
+ const found = plugins.find((p) => p.name.toLowerCase() === pluginName.toLowerCase());
323
+ if (found) {
324
+ return found;
325
+ }
326
+ }
327
+ return null;
328
+ }
329
+ export {
330
+ addMarketplace,
331
+ deriveMarketplaceName,
332
+ findPluginInMarketplaces,
333
+ listAllMarketplacePlugins,
334
+ listMarketplaces,
335
+ parseMarketplaceSource,
336
+ removeMarketplace,
337
+ scanMarketplacePlugins,
338
+ updateMarketplace
339
+ };
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var registry_exports = {};
30
+ __export(registry_exports, {
31
+ DEFAULT_MARKETPLACES: () => DEFAULT_MARKETPLACES,
32
+ addMarketplaceEntry: () => addMarketplaceEntry,
33
+ getAllMarketplaces: () => getAllMarketplaces,
34
+ getMarketplaceCacheDir: () => getMarketplaceCacheDir,
35
+ getMarketplaceEntry: () => getMarketplaceEntry,
36
+ getMarketplacesDir: () => getMarketplacesDir,
37
+ getMarketplacesRegistryPath: () => getMarketplacesRegistryPath,
38
+ getUninstalledDefaults: () => getUninstalledDefaults,
39
+ isDefaultMarketplace: () => isDefaultMarketplace,
40
+ loadKnownMarketplaces: () => loadKnownMarketplaces,
41
+ marketplaceExists: () => marketplaceExists,
42
+ removeMarketplaceEntry: () => removeMarketplaceEntry,
43
+ saveKnownMarketplaces: () => saveKnownMarketplaces,
44
+ updateMarketplaceTimestamp: () => updateMarketplaceTimestamp
45
+ });
46
+ module.exports = __toCommonJS(registry_exports);
47
+ var path = __toESM(require("path"), 1);
48
+ var import_fs = require("fs");
49
+ var import_os = require("os");
50
+ var import_schemas = require("./schemas.js");
51
+ var import_errors = require("./errors.js");
52
+ const DEFAULT_MARKETPLACES = [
53
+ {
54
+ name: "claude-plugins-official",
55
+ source: {
56
+ type: "github",
57
+ value: "anthropics/claude-plugins-official"
58
+ }
59
+ }
60
+ ];
61
+ function getMarketplacesRegistryPath() {
62
+ return path.join((0, import_os.homedir)(), ".dexto", "plugins", "known_marketplaces.json");
63
+ }
64
+ function getMarketplacesDir() {
65
+ return path.join((0, import_os.homedir)(), ".dexto", "plugins", "marketplaces");
66
+ }
67
+ function getMarketplaceCacheDir() {
68
+ return path.join((0, import_os.homedir)(), ".dexto", "plugins", "cache");
69
+ }
70
+ function loadKnownMarketplaces() {
71
+ const filePath = getMarketplacesRegistryPath();
72
+ if (!(0, import_fs.existsSync)(filePath)) {
73
+ return { version: 1, marketplaces: {} };
74
+ }
75
+ try {
76
+ const content = (0, import_fs.readFileSync)(filePath, "utf-8");
77
+ const parsed = JSON.parse(content);
78
+ const result = import_schemas.KnownMarketplacesFileSchema.safeParse(parsed);
79
+ if (!result.success) {
80
+ return { version: 1, marketplaces: {} };
81
+ }
82
+ return result.data;
83
+ } catch {
84
+ return { version: 1, marketplaces: {} };
85
+ }
86
+ }
87
+ function saveKnownMarketplaces(data) {
88
+ const filePath = getMarketplacesRegistryPath();
89
+ const dirPath = path.dirname(filePath);
90
+ if (!(0, import_fs.existsSync)(dirPath)) {
91
+ (0, import_fs.mkdirSync)(dirPath, { recursive: true });
92
+ }
93
+ try {
94
+ (0, import_fs.writeFileSync)(filePath, JSON.stringify(data, null, 2), "utf-8");
95
+ } catch (error) {
96
+ throw import_errors.MarketplaceError.registryWriteFailed(
97
+ filePath,
98
+ error instanceof Error ? error.message : String(error)
99
+ );
100
+ }
101
+ }
102
+ function getMarketplaceEntry(name) {
103
+ const registry = loadKnownMarketplaces();
104
+ return registry.marketplaces[name] || null;
105
+ }
106
+ function marketplaceExists(name) {
107
+ return getMarketplaceEntry(name) !== null;
108
+ }
109
+ function getAllMarketplaces() {
110
+ const registry = loadKnownMarketplaces();
111
+ return Object.values(registry.marketplaces);
112
+ }
113
+ function addMarketplaceEntry(entry) {
114
+ const registry = loadKnownMarketplaces();
115
+ registry.marketplaces[entry.name] = entry;
116
+ saveKnownMarketplaces(registry);
117
+ }
118
+ function removeMarketplaceEntry(name) {
119
+ const registry = loadKnownMarketplaces();
120
+ if (!registry.marketplaces[name]) {
121
+ return false;
122
+ }
123
+ delete registry.marketplaces[name];
124
+ saveKnownMarketplaces(registry);
125
+ return true;
126
+ }
127
+ function updateMarketplaceTimestamp(name) {
128
+ const registry = loadKnownMarketplaces();
129
+ if (registry.marketplaces[name]) {
130
+ registry.marketplaces[name].lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
131
+ saveKnownMarketplaces(registry);
132
+ }
133
+ }
134
+ function getUninstalledDefaults() {
135
+ const registry = loadKnownMarketplaces();
136
+ const uninstalled = [];
137
+ for (const defaultMarket of DEFAULT_MARKETPLACES) {
138
+ if (!registry.marketplaces[defaultMarket.name]) {
139
+ uninstalled.push({
140
+ ...defaultMarket,
141
+ isDefault: true
142
+ });
143
+ }
144
+ }
145
+ return uninstalled;
146
+ }
147
+ function isDefaultMarketplace(name) {
148
+ return DEFAULT_MARKETPLACES.some((m) => m.name === name);
149
+ }
150
+ // Annotate the CommonJS export names for ESM import in node:
151
+ 0 && (module.exports = {
152
+ DEFAULT_MARKETPLACES,
153
+ addMarketplaceEntry,
154
+ getAllMarketplaces,
155
+ getMarketplaceCacheDir,
156
+ getMarketplaceEntry,
157
+ getMarketplacesDir,
158
+ getMarketplacesRegistryPath,
159
+ getUninstalledDefaults,
160
+ isDefaultMarketplace,
161
+ loadKnownMarketplaces,
162
+ marketplaceExists,
163
+ removeMarketplaceEntry,
164
+ saveKnownMarketplaces,
165
+ updateMarketplaceTimestamp
166
+ });
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Plugin Marketplace Registry
3
+ *
4
+ * Manages the known_marketplaces.json file that tracks registered marketplaces.
5
+ */
6
+ import type { KnownMarketplacesFile, MarketplaceEntry, MarketplaceSource } from './types.js';
7
+ /**
8
+ * Default marketplace configuration
9
+ * Claude Code's official plugin marketplace is included by default
10
+ */
11
+ export declare const DEFAULT_MARKETPLACES: Array<{
12
+ name: string;
13
+ source: MarketplaceSource;
14
+ }>;
15
+ /**
16
+ * Get the path to known_marketplaces.json
17
+ */
18
+ export declare function getMarketplacesRegistryPath(): string;
19
+ /**
20
+ * Get the directory where marketplaces are cloned
21
+ */
22
+ export declare function getMarketplacesDir(): string;
23
+ /**
24
+ * Get the marketplace cache directory (for versioned plugin copies)
25
+ */
26
+ export declare function getMarketplaceCacheDir(): string;
27
+ /**
28
+ * Load the known marketplaces registry
29
+ */
30
+ export declare function loadKnownMarketplaces(): KnownMarketplacesFile;
31
+ /**
32
+ * Save the known marketplaces registry
33
+ */
34
+ export declare function saveKnownMarketplaces(data: KnownMarketplacesFile): void;
35
+ /**
36
+ * Get a specific marketplace entry by name
37
+ */
38
+ export declare function getMarketplaceEntry(name: string): MarketplaceEntry | null;
39
+ /**
40
+ * Check if a marketplace exists by name
41
+ */
42
+ export declare function marketplaceExists(name: string): boolean;
43
+ /**
44
+ * Get all registered marketplaces
45
+ */
46
+ export declare function getAllMarketplaces(): MarketplaceEntry[];
47
+ /**
48
+ * Add a marketplace entry to the registry
49
+ */
50
+ export declare function addMarketplaceEntry(entry: MarketplaceEntry): void;
51
+ /**
52
+ * Remove a marketplace entry from the registry
53
+ */
54
+ export declare function removeMarketplaceEntry(name: string): boolean;
55
+ /**
56
+ * Update a marketplace entry's lastUpdated timestamp
57
+ */
58
+ export declare function updateMarketplaceTimestamp(name: string): void;
59
+ /**
60
+ * Get default marketplaces that are not yet installed
61
+ * Returns entries with a special flag indicating they need to be added
62
+ */
63
+ export declare function getUninstalledDefaults(): Array<{
64
+ name: string;
65
+ source: MarketplaceSource;
66
+ isDefault: true;
67
+ }>;
68
+ /**
69
+ * Check if a marketplace is a default marketplace
70
+ */
71
+ export declare function isDefaultMarketplace(name: string): boolean;
72
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/marketplace/registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE7F;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;CAC7B,CAQA,CAAC;AAEF;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,qBAAqB,CAsB7D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAiBvE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAGzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,EAAE,CAGvD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAIjE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAU5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAO7D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,KAAK,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;CACnB,CAAC,CAkBD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D"}