@dexto/image-bundler 1.5.0

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.
@@ -0,0 +1,20 @@
1
+
2
+ > @dexto/image-bundler@1.5.0 build /home/runner/work/dexto/dexto/packages/image-bundler
3
+ > tsup
4
+
5
+ CLI Building entry: src/cli.ts, src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.0
8
+ CLI Using tsup config: /home/runner/work/dexto/dexto/packages/image-bundler/tsup.config.ts
9
+ CLI Target: es2022
10
+ CLI Cleaning output folder
11
+ ESM Build start
12
+ ESM dist/cli.js 18.61 KB
13
+ ESM dist/index.js 15.82 KB
14
+ ESM dist/cli.js.map 37.66 KB
15
+ ESM dist/index.js.map 32.16 KB
16
+ ESM ⚡️ Build success in 65ms
17
+ DTS Build start
18
+ DTS ⚡️ Build success in 7928ms
19
+ DTS dist/cli.d.ts 20.00 B
20
+ DTS dist/index.d.ts 965.00 B
package/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # @dexto/image-bundler
2
+
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e7722e5: Minor version bump for new release with bundler, custom tool pkgs, etc.
8
+
9
+ ### Patch Changes
10
+
11
+ - 1e7e974: Added image bundler, @dexto/image-local and moved tool services outside core. Added registry providers to select core services.
12
+ - 5fa79fa: Renamed compression to compaction, added context-awareness to hono, updated cli tool display formatting and added integration test for image-local.
13
+ - ef40e60: Upgrades package versions and related changes to MCP SDK. CLI colors improved and token streaming added to status bar.
14
+
15
+ Security: Resolve all Dependabot security vulnerabilities. Updated @modelcontextprotocol/sdk to 1.25.2, esbuild to 0.25.0, langchain to 0.3.37, and @langchain/core to 0.3.80. Added pnpm overrides for indirect vulnerabilities (preact@10.27.3, qs@6.14.1, jws@3.2.3, mdast-util-to-hast@13.2.1). Fixed type errors from MCP SDK breaking changes.
16
+
17
+ - Updated dependencies [ee12727]
18
+ - Updated dependencies [1e7e974]
19
+ - Updated dependencies [4c05310]
20
+ - Updated dependencies [5fa79fa]
21
+ - Updated dependencies [ef40e60]
22
+ - Updated dependencies [e714418]
23
+ - Updated dependencies [e7722e5]
24
+ - Updated dependencies [7d5ab19]
25
+ - Updated dependencies [436a900]
26
+ - @dexto/core@1.5.0
package/LICENSE ADDED
@@ -0,0 +1,44 @@
1
+ Elastic License 2.0 (ELv2)
2
+
3
+ **Acceptance**
4
+ By using the software, you agree to all of the terms and conditions below.
5
+
6
+ **Copyright License**
7
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
8
+
9
+ **Limitations**
10
+ You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
11
+
12
+ You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
13
+
14
+ You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
15
+
16
+ **Patents**
17
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
18
+
19
+ **Notices**
20
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
21
+
22
+ If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
23
+
24
+ **No Other Rights**
25
+ These terms do not imply any licenses other than those expressly granted in these terms.
26
+
27
+ **Termination**
28
+ If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
29
+
30
+ **No Liability**
31
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
32
+
33
+ **Definitions**
34
+ The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
35
+
36
+ _you_ refers to the individual or entity agreeing to these terms.
37
+
38
+ _your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
39
+
40
+ _your licenses_ are all the licenses granted to you for the software under these terms.
41
+
42
+ _use_ means anything you do with the software requiring one of your licenses.
43
+
44
+ _trademark_ means trademarks, service marks, and similar rights.
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/cli.js ADDED
@@ -0,0 +1,540 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { Command } from "commander";
5
+
6
+ // src/bundler.ts
7
+ import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync, statSync } from "fs";
8
+ import { dirname, join, resolve, extname } from "path";
9
+ import { pathToFileURL } from "url";
10
+ import { validateImageDefinition } from "@dexto/core";
11
+
12
+ // src/generator.ts
13
+ function generateEntryPoint(definition, coreVersion, discoveredProviders) {
14
+ const imports = generateImports(definition, discoveredProviders);
15
+ const registrations = generateProviderRegistrations(definition, discoveredProviders);
16
+ const factory = generateFactory();
17
+ const utilityExports = generateUtilityExports(definition);
18
+ const metadata = generateMetadata(definition, coreVersion);
19
+ const js = `// AUTO-GENERATED by @dexto/bundler
20
+ // Do not edit this file directly. Edit dexto.image.ts instead.
21
+
22
+ ${imports}
23
+
24
+ ${registrations}
25
+
26
+ ${factory}
27
+
28
+ ${utilityExports}
29
+
30
+ ${metadata}
31
+ `;
32
+ const dts = generateTypeDefinitions(definition);
33
+ return { js, dts };
34
+ }
35
+ function generateImports(definition, discoveredProviders) {
36
+ const imports = [];
37
+ if (definition.extends) {
38
+ imports.push(`// Import base image for provider registration (side effect)`);
39
+ imports.push(`import '${definition.extends}';`);
40
+ imports.push(``);
41
+ }
42
+ imports.push(`import { DextoAgent } from '@dexto/core';`);
43
+ imports.push(
44
+ `import { customToolRegistry, pluginRegistry, compactionRegistry, blobStoreRegistry } from '@dexto/core';`
45
+ );
46
+ if (discoveredProviders) {
47
+ const categories = [
48
+ { key: "blobStore", label: "Blob Storage" },
49
+ { key: "customTools", label: "Custom Tools" },
50
+ { key: "compaction", label: "Compaction" },
51
+ { key: "plugins", label: "Plugins" }
52
+ ];
53
+ for (const { key, label } of categories) {
54
+ const providers = discoveredProviders[key];
55
+ if (providers.length > 0) {
56
+ imports.push(``);
57
+ imports.push(`// ${label} providers (auto-discovered)`);
58
+ providers.forEach((path, index) => {
59
+ const varName = `${key}Provider${index}`;
60
+ imports.push(`import * as ${varName} from '${path}';`);
61
+ });
62
+ }
63
+ }
64
+ }
65
+ return imports.join("\n");
66
+ }
67
+ function generateProviderRegistrations(definition, discoveredProviders) {
68
+ const registrations = [];
69
+ if (definition.extends) {
70
+ registrations.push(
71
+ `// Base image providers already registered via import of '${definition.extends}'`
72
+ );
73
+ registrations.push("");
74
+ }
75
+ registrations.push("// SIDE EFFECT: Register providers on import");
76
+ registrations.push("");
77
+ if (discoveredProviders) {
78
+ const categoryMap = [
79
+ { key: "blobStore", registry: "blobStoreRegistry", label: "Blob Storage" },
80
+ { key: "customTools", registry: "customToolRegistry", label: "Custom Tools" },
81
+ { key: "compaction", registry: "compactionRegistry", label: "Compaction" },
82
+ { key: "plugins", registry: "pluginRegistry", label: "Plugins" }
83
+ ];
84
+ for (const { key, registry, label } of categoryMap) {
85
+ const providers = discoveredProviders[key];
86
+ if (providers.length === 0) continue;
87
+ registrations.push(`// Auto-register ${label} providers`);
88
+ providers.forEach((path, index) => {
89
+ const varName = `${key}Provider${index}`;
90
+ registrations.push(`// From ${path}`);
91
+ registrations.push(`for (const exported of Object.values(${varName})) {`);
92
+ registrations.push(
93
+ ` if (exported && typeof exported === 'object' && 'type' in exported && 'create' in exported) {`
94
+ );
95
+ registrations.push(` try {`);
96
+ registrations.push(` ${registry}.register(exported);`);
97
+ registrations.push(
98
+ ` console.log(\`\u2713 Registered ${key}: \${exported.type}\`);`
99
+ );
100
+ registrations.push(` } catch (err) {`);
101
+ registrations.push(` // Ignore duplicate registration errors`);
102
+ registrations.push(
103
+ ` if (!err.message?.includes('already registered')) throw err;`
104
+ );
105
+ registrations.push(` }`);
106
+ registrations.push(` }`);
107
+ registrations.push(`}`);
108
+ });
109
+ registrations.push("");
110
+ }
111
+ }
112
+ for (const [category, config] of Object.entries(definition.providers)) {
113
+ if (!config) continue;
114
+ if (config.register) {
115
+ registrations.push(`// Register ${category} via custom function (from dexto.image.ts)`);
116
+ registrations.push(`await (async () => {`);
117
+ registrations.push(` try {`);
118
+ registrations.push(
119
+ ` ${config.register.toString().replace(/^async\s*\(\)\s*=>\s*{/, "").replace(/}$/, "")}`
120
+ );
121
+ registrations.push(` } catch (err) {`);
122
+ registrations.push(` // Ignore duplicate registration errors`);
123
+ registrations.push(` if (!err.message?.includes('already registered')) {`);
124
+ registrations.push(` throw err;`);
125
+ registrations.push(` }`);
126
+ registrations.push(` }`);
127
+ registrations.push(`})();`);
128
+ registrations.push("");
129
+ }
130
+ }
131
+ return registrations.join("\n");
132
+ }
133
+ function generateFactory() {
134
+ return `/**
135
+ * Create a Dexto agent using this image's registered providers.
136
+ *
137
+ * @param config - Agent configuration
138
+ * @param configPath - Optional path to config file
139
+ * @returns DextoAgent instance with providers already registered
140
+ */
141
+ export function createAgent(config, configPath) {
142
+ return new DextoAgent(config, configPath);
143
+ }
144
+
145
+ /**
146
+ * Re-export registries for runtime customization.
147
+ * This allows apps to add custom providers without depending on @dexto/core directly.
148
+ */
149
+ export {
150
+ customToolRegistry,
151
+ pluginRegistry,
152
+ compactionRegistry,
153
+ blobStoreRegistry,
154
+ } from '@dexto/core';`;
155
+ }
156
+ function generateUtilityExports(definition) {
157
+ const sections = [];
158
+ if (definition.utils && Object.keys(definition.utils).length > 0) {
159
+ sections.push("// Utility exports");
160
+ for (const [name, path] of Object.entries(definition.utils)) {
161
+ sections.push(`export * from '${path}';`);
162
+ }
163
+ }
164
+ if (definition.exports && Object.keys(definition.exports).length > 0) {
165
+ if (sections.length > 0) sections.push("");
166
+ sections.push("// Selective package re-exports");
167
+ for (const [packageName, exports] of Object.entries(definition.exports)) {
168
+ if (exports.length === 1 && exports[0] === "*") {
169
+ sections.push(`export * from '${packageName}';`);
170
+ continue;
171
+ }
172
+ const runtimeExports = exports.filter((exp) => !exp.startsWith("type "));
173
+ if (runtimeExports.length > 0) {
174
+ sections.push(`export {`);
175
+ sections.push(` ${runtimeExports.join(",\n ")}`);
176
+ sections.push(`} from '${packageName}';`);
177
+ }
178
+ }
179
+ }
180
+ if (sections.length === 0) {
181
+ return "// No utilities or exports defined for this image";
182
+ }
183
+ return sections.join("\n");
184
+ }
185
+ function generateMetadata(definition, coreVersion) {
186
+ const metadata = {
187
+ name: definition.name,
188
+ version: definition.version,
189
+ description: definition.description,
190
+ target: definition.target || "custom",
191
+ constraints: definition.constraints || [],
192
+ builtAt: (/* @__PURE__ */ new Date()).toISOString(),
193
+ coreVersion
194
+ };
195
+ if (definition.extends) {
196
+ metadata.extends = definition.extends;
197
+ }
198
+ return `/**
199
+ * Image metadata
200
+ * Generated at build time
201
+ */
202
+ export const imageMetadata = ${JSON.stringify(metadata, null, 4)};`;
203
+ }
204
+ function generateTypeDefinitions(definition) {
205
+ const sections = [];
206
+ if (definition.utils && Object.keys(definition.utils).length > 0) {
207
+ sections.push("// Utility re-exports");
208
+ for (const path of Object.values(definition.utils)) {
209
+ sections.push(`export * from '${path}';`);
210
+ }
211
+ }
212
+ if (definition.exports && Object.keys(definition.exports).length > 0) {
213
+ if (sections.length > 0) sections.push("");
214
+ sections.push("// Selective package re-exports");
215
+ for (const [packageName, exports] of Object.entries(definition.exports)) {
216
+ if (exports.length === 1 && exports[0] === "*") {
217
+ sections.push(`export * from '${packageName}';`);
218
+ continue;
219
+ }
220
+ sections.push(`export {`);
221
+ sections.push(` ${exports.join(",\n ")}`);
222
+ sections.push(`} from '${packageName}';`);
223
+ }
224
+ }
225
+ const utilityExports = sections.length > 0 ? "\n\n" + sections.join("\n") : "";
226
+ return `// AUTO-GENERATED TypeScript definitions
227
+ // Do not edit this file directly
228
+
229
+ import type { DextoAgent, AgentConfig, ImageMetadata } from '@dexto/core';
230
+
231
+ /**
232
+ * Create a Dexto agent using this image's registered providers.
233
+ */
234
+ export declare function createAgent(config: AgentConfig, configPath?: string): DextoAgent;
235
+
236
+ /**
237
+ * Image metadata
238
+ */
239
+ export declare const imageMetadata: ImageMetadata;
240
+
241
+ /**
242
+ * Re-exported registries for runtime customization
243
+ */
244
+ export {
245
+ customToolRegistry,
246
+ pluginRegistry,
247
+ compactionRegistry,
248
+ blobStoreRegistry,
249
+ } from '@dexto/core';${utilityExports}
250
+ `;
251
+ }
252
+
253
+ // src/bundler.ts
254
+ import ts from "typescript";
255
+ async function bundle(options) {
256
+ const warnings = [];
257
+ console.log(`\u{1F4E6} Loading image definition from ${options.imagePath}`);
258
+ const definition = await loadImageDefinition(options.imagePath);
259
+ console.log(`\u2705 Loaded image: ${definition.name} v${definition.version}`);
260
+ console.log(`\u{1F50D} Validating image definition...`);
261
+ try {
262
+ validateImageDefinition(definition);
263
+ console.log(`\u2705 Image definition is valid`);
264
+ } catch (error) {
265
+ throw new Error(`Image validation failed: ${error}`);
266
+ }
267
+ const coreVersion = getCoreVersion();
268
+ console.log(`\u{1F50D} Discovering providers from folders...`);
269
+ const imageDir = dirname(options.imagePath);
270
+ const discoveredProviders = discoverProviders(imageDir);
271
+ console.log(`\u2705 Discovered ${discoveredProviders.totalCount} provider(s)`);
272
+ console.log(`\u{1F528} Generating entry point...`);
273
+ const generated = generateEntryPoint(definition, coreVersion, discoveredProviders);
274
+ const outDir = resolve(options.outDir);
275
+ if (!existsSync(outDir)) {
276
+ mkdirSync(outDir, { recursive: true });
277
+ }
278
+ console.log(`\u{1F528} Compiling provider source files...`);
279
+ const categories = ["blob-store", "tools", "compaction", "plugins"];
280
+ let compiledCount = 0;
281
+ for (const category of categories) {
282
+ const categoryDir = join(imageDir, category);
283
+ if (existsSync(categoryDir)) {
284
+ compileSourceFiles(categoryDir, join(outDir, category));
285
+ compiledCount++;
286
+ }
287
+ }
288
+ if (compiledCount > 0) {
289
+ console.log(
290
+ `\u2705 Compiled ${compiledCount} provider categor${compiledCount === 1 ? "y" : "ies"}`
291
+ );
292
+ }
293
+ const entryFile = join(outDir, "index.js");
294
+ const typesFile = join(outDir, "index.d.ts");
295
+ console.log(`\u{1F4DD} Writing ${entryFile}...`);
296
+ writeFileSync(entryFile, generated.js, "utf-8");
297
+ console.log(`\u{1F4DD} Writing ${typesFile}...`);
298
+ writeFileSync(typesFile, generated.dts, "utf-8");
299
+ updatePackageJson(dirname(options.imagePath), outDir);
300
+ console.log(`\u2728 Build complete!`);
301
+ console.log(` Entry: ${entryFile}`);
302
+ console.log(` Types: ${typesFile}`);
303
+ const metadata = {
304
+ name: definition.name,
305
+ version: definition.version,
306
+ description: definition.description,
307
+ target: definition.target || "custom",
308
+ constraints: definition.constraints || [],
309
+ builtAt: (/* @__PURE__ */ new Date()).toISOString(),
310
+ coreVersion
311
+ };
312
+ return {
313
+ entryFile,
314
+ typesFile,
315
+ metadata,
316
+ warnings
317
+ };
318
+ }
319
+ async function loadImageDefinition(imagePath) {
320
+ const absolutePath = resolve(imagePath);
321
+ if (!existsSync(absolutePath)) {
322
+ throw new Error(`Image file not found: ${absolutePath}`);
323
+ }
324
+ try {
325
+ const fileUrl = pathToFileURL(absolutePath).href;
326
+ const module = await import(fileUrl);
327
+ const definition = module.default;
328
+ if (!definition) {
329
+ throw new Error("Image file must have a default export");
330
+ }
331
+ return definition;
332
+ } catch (error) {
333
+ if (error instanceof Error) {
334
+ throw new Error(`Failed to load image definition: ${error.message}`);
335
+ }
336
+ throw error;
337
+ }
338
+ }
339
+ function getCoreVersion() {
340
+ try {
341
+ const corePackageJson = join(process.cwd(), "node_modules/@dexto/core/package.json");
342
+ if (existsSync(corePackageJson)) {
343
+ const pkg = JSON.parse(readFileSync(corePackageJson, "utf-8"));
344
+ return pkg.version;
345
+ }
346
+ return "1.0.0";
347
+ } catch {
348
+ return "1.0.0";
349
+ }
350
+ }
351
+ function updatePackageJson(imageDir, outDir) {
352
+ const packageJsonPath = join(imageDir, "package.json");
353
+ if (!existsSync(packageJsonPath)) {
354
+ console.log(`\u26A0\uFE0F No package.json found, skipping exports update`);
355
+ return;
356
+ }
357
+ try {
358
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
359
+ pkg.exports = {
360
+ ".": {
361
+ types: "./dist/index.d.ts",
362
+ import: "./dist/index.js"
363
+ }
364
+ };
365
+ pkg.main = "./dist/index.js";
366
+ pkg.types = "./dist/index.d.ts";
367
+ writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2), "utf-8");
368
+ console.log(`\u2705 Updated package.json exports`);
369
+ } catch (error) {
370
+ console.warn(`\u26A0\uFE0F Failed to update package.json: ${error}`);
371
+ }
372
+ }
373
+ function compileSourceFiles(srcDir, outDir) {
374
+ const tsFiles = findTypeScriptFiles(srcDir);
375
+ if (tsFiles.length === 0) {
376
+ console.log(` No TypeScript files found in ${srcDir}`);
377
+ return;
378
+ }
379
+ console.log(` Found ${tsFiles.length} TypeScript file(s) to compile`);
380
+ const compilerOptions = {
381
+ target: ts.ScriptTarget.ES2022,
382
+ module: ts.ModuleKind.ESNext,
383
+ moduleResolution: ts.ModuleResolutionKind.Bundler,
384
+ outDir,
385
+ rootDir: srcDir,
386
+ // Use srcDir as root
387
+ declaration: true,
388
+ esModuleInterop: true,
389
+ skipLibCheck: true,
390
+ strict: true,
391
+ resolveJsonModule: true
392
+ };
393
+ const program2 = ts.createProgram(tsFiles, compilerOptions);
394
+ const emitResult = program2.emit();
395
+ const allDiagnostics = ts.getPreEmitDiagnostics(program2).concat(emitResult.diagnostics);
396
+ if (allDiagnostics.length > 0) {
397
+ allDiagnostics.forEach((diagnostic) => {
398
+ if (diagnostic.file) {
399
+ const { line, character } = ts.getLineAndCharacterOfPosition(
400
+ diagnostic.file,
401
+ diagnostic.start
402
+ );
403
+ const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
404
+ console.error(
405
+ ` ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
406
+ );
407
+ } else {
408
+ console.error(
409
+ ` ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`
410
+ );
411
+ }
412
+ });
413
+ if (emitResult.emitSkipped) {
414
+ throw new Error("TypeScript compilation failed");
415
+ }
416
+ }
417
+ }
418
+ function findTypeScriptFiles(dir) {
419
+ const files = [];
420
+ function walk(currentDir) {
421
+ const entries = readdirSync(currentDir);
422
+ for (const entry of entries) {
423
+ const fullPath = join(currentDir, entry);
424
+ const stat = statSync(fullPath);
425
+ if (stat.isDirectory()) {
426
+ walk(fullPath);
427
+ } else if (stat.isFile() && extname(entry) === ".ts") {
428
+ files.push(fullPath);
429
+ }
430
+ }
431
+ }
432
+ walk(dir);
433
+ return files;
434
+ }
435
+ function discoverProviders(imageDir) {
436
+ const result = {
437
+ blobStore: [],
438
+ customTools: [],
439
+ compaction: [],
440
+ plugins: [],
441
+ totalCount: 0
442
+ };
443
+ const categories = {
444
+ "blob-store": "blobStore",
445
+ tools: "customTools",
446
+ compaction: "compaction",
447
+ plugins: "plugins"
448
+ };
449
+ for (const [folderName, propName] of Object.entries(categories)) {
450
+ const categoryDir = join(imageDir, folderName);
451
+ if (!existsSync(categoryDir)) {
452
+ continue;
453
+ }
454
+ const providerFolders = readdirSync(categoryDir).filter((entry) => {
455
+ const entryPath = join(categoryDir, entry);
456
+ const stat = statSync(entryPath);
457
+ if (!stat.isDirectory()) {
458
+ return false;
459
+ }
460
+ const indexPath = join(entryPath, "index.ts");
461
+ return existsSync(indexPath);
462
+ }).map((folder) => {
463
+ return `./${folderName}/${folder}/index.js`;
464
+ });
465
+ if (providerFolders.length > 0) {
466
+ result[propName].push(
467
+ ...providerFolders
468
+ );
469
+ result.totalCount += providerFolders.length;
470
+ console.log(` Found ${providerFolders.length} provider(s) in ${folderName}/`);
471
+ }
472
+ }
473
+ return result;
474
+ }
475
+
476
+ // src/cli.ts
477
+ import { readFileSync as readFileSync2 } from "fs";
478
+ import { join as join2, dirname as dirname2 } from "path";
479
+ import { fileURLToPath } from "url";
480
+ import pc from "picocolors";
481
+ process.removeAllListeners("warning");
482
+ process.on("warning", (warning) => {
483
+ if (warning.name !== "ExperimentalWarning") {
484
+ console.warn(warning);
485
+ }
486
+ });
487
+ var __filename2 = fileURLToPath(import.meta.url);
488
+ var __dirname2 = dirname2(__filename2);
489
+ var packageJson = JSON.parse(readFileSync2(join2(__dirname2, "../package.json"), "utf-8"));
490
+ var program = new Command();
491
+ program.name("dexto-bundle").description("Bundle Dexto base images").version(packageJson.version);
492
+ program.command("build").description("Build a base image from dexto.image.ts").option("-i, --image <path>", "Path to dexto.image.ts file", "dexto.image.ts").option("-o, --out <dir>", "Output directory", "dist").option("--sourcemap", "Generate source maps", false).option("--minify", "Minify output", false).action(async (options) => {
493
+ try {
494
+ console.log(pc.cyan("\u{1F680} Dexto Image Bundler\n"));
495
+ const result = await bundle({
496
+ imagePath: options.image,
497
+ outDir: options.out,
498
+ sourcemap: options.sourcemap,
499
+ minify: options.minify
500
+ });
501
+ console.log(pc.green("\n\u2728 Build successful!\n"));
502
+ console.log(pc.bold("Image Details:"));
503
+ console.log(` Name: ${result.metadata.name}`);
504
+ console.log(` Version: ${result.metadata.version}`);
505
+ console.log(` Target: ${result.metadata.target}`);
506
+ console.log(` Built at: ${result.metadata.builtAt}`);
507
+ console.log(` Core: v${result.metadata.coreVersion}`);
508
+ if (result.metadata.constraints.length > 0) {
509
+ console.log(` Constraints: ${result.metadata.constraints.join(", ")}`);
510
+ }
511
+ if (result.warnings.length > 0) {
512
+ console.log(pc.yellow("\n\u26A0\uFE0F Warnings:"));
513
+ result.warnings.forEach((w) => console.log(` - ${w}`));
514
+ }
515
+ const packageJsonPath = join2(process.cwd(), "package.json");
516
+ let packageName = result.metadata.name;
517
+ try {
518
+ if (readFileSync2) {
519
+ const pkgJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
520
+ packageName = pkgJson.name || result.metadata.name;
521
+ }
522
+ } catch {
523
+ }
524
+ console.log(pc.green("\n\u2705 Image is ready to use!"));
525
+ console.log(" To use this image in an app:");
526
+ console.log(
527
+ pc.dim(
528
+ ` 1. Install it: pnpm add ${packageName}@file:../${packageName.split("/").pop()}`
529
+ )
530
+ );
531
+ console.log(pc.dim(` 2. Import it: import { createAgent } from '${packageName}';`));
532
+ console.log(pc.dim(`
533
+ Or publish to npm and install normally.`));
534
+ } catch (error) {
535
+ console.error(pc.red("\n\u274C Build failed:"), error);
536
+ process.exit(1);
537
+ }
538
+ });
539
+ program.parse();
540
+ //# sourceMappingURL=cli.js.map