@a5c-ai/babysitter-sdk 0.0.149 → 0.0.151

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.
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAo5CA,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBA6CpD,MAAM;EAIvB"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/cli/main.ts"],"names":[],"mappings":";AAu9CA,wBAAgB,mBAAmB;eAEf,MAAM,EAAE,GAA2B,OAAO,CAAC,MAAM,CAAC;kBA6CpD,MAAM;EAIvB"}
package/dist/cli/main.js CHANGED
@@ -37,6 +37,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.createBabysitterCli = createBabysitterCli;
38
38
  const node_fs_1 = require("node:fs");
39
39
  const path = __importStar(require("node:path"));
40
+ const node_url_1 = require("node:url");
40
41
  const crypto = __importStar(require("node:crypto"));
41
42
  const commitEffectResult_1 = require("../runtime/commitEffectResult");
42
43
  const createRun_1 = require("../runtime/createRun");
@@ -421,6 +422,51 @@ function parseEntrypointSpecifier(specifier) {
421
422
  const exportName = specifier.slice(hashIndex + 1) || undefined;
422
423
  return { importPath, exportName };
423
424
  }
425
+ // Use an indirect dynamic import so TypeScript does not downlevel to require() in CommonJS builds.
426
+ // Vitest executes modules inside a VM context that requires direct import() support.
427
+ const dynamicImportModule = (() => {
428
+ if (process.env.VITEST) {
429
+ return (specifier) => Promise.resolve(`${specifier}`).then(s => __importStar(require(s)));
430
+ }
431
+ return new Function("specifier", "return import(specifier);");
432
+ })();
433
+ function listModuleExports(mod) {
434
+ const keys = Object.keys(mod);
435
+ return keys.length > 0 ? keys.join(", ") : "(none)";
436
+ }
437
+ async function validateProcessEntrypoint(importPath, exportName) {
438
+ const resolvedPath = path.isAbsolute(importPath) ? importPath : path.resolve(importPath);
439
+ try {
440
+ await node_fs_1.promises.access(resolvedPath);
441
+ }
442
+ catch (error) {
443
+ throw new Error(`Process entry file not found: ${resolvedPath}. ` +
444
+ `Ensure the path is correct and points to a valid JS/TS module.`);
445
+ }
446
+ const moduleUrl = (0, node_url_1.pathToFileURL)(resolvedPath).href;
447
+ let mod;
448
+ try {
449
+ mod = await dynamicImportModule(moduleUrl);
450
+ }
451
+ catch (error) {
452
+ throw new Error(`Failed to load process module at ${resolvedPath}: ${error instanceof Error ? error.message : String(error)}`);
453
+ }
454
+ const resolvedExportName = exportName ?? "process";
455
+ const candidate = (resolvedExportName && mod[resolvedExportName]) ??
456
+ mod.process ??
457
+ mod.default;
458
+ if (typeof candidate !== "function") {
459
+ const available = listModuleExports(mod);
460
+ if (resolvedExportName && !(resolvedExportName in mod) && mod.default) {
461
+ throw new Error(`Process module ${resolvedPath} does not export '${resolvedExportName}'. ` +
462
+ `Available exports: ${available}. ` +
463
+ `If you intended a default export, pass --entry ${importPath}#default.`);
464
+ }
465
+ throw new Error(`Process module ${resolvedPath} does not export a valid process function. ` +
466
+ `Expected '${resolvedExportName}' (function) or default export. ` +
467
+ `Available exports: ${available}.`);
468
+ }
469
+ }
424
470
  async function readInputsFile(filePath) {
425
471
  const absolute = path.resolve(filePath);
426
472
  let contents;
@@ -512,6 +558,13 @@ async function handleRunCreate(parsed) {
512
558
  }
513
559
  return 0;
514
560
  }
561
+ try {
562
+ await validateProcessEntrypoint(absoluteImportPath, entrypoint.exportName);
563
+ }
564
+ catch (error) {
565
+ console.error(error instanceof Error ? error.message : String(error));
566
+ return 1;
567
+ }
515
568
  const result = await (0, createRun_1.createRun)({
516
569
  runsDir,
517
570
  runId: parsed.runIdOverride,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a5c-ai/babysitter-sdk",
3
- "version": "0.0.149",
3
+ "version": "0.0.151",
4
4
  "description": "Storage and run-registry primitives for event-sourced babysitter workflows.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "commonjs",