deepline 0.1.4 → 0.1.7

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.
@@ -169,7 +169,7 @@ function resolveConfig(options) {
169
169
  }
170
170
 
171
171
  // src/version.ts
172
- var SDK_VERSION = "0.1.4";
172
+ var SDK_VERSION = "0.1.7";
173
173
  var SDK_API_CONTRACT = "2026-04-plays-v1";
174
174
 
175
175
  // ../shared_libs/play-runtime/coordinator-headers.ts
@@ -2483,6 +2483,7 @@ function registerOrgCommands(program) {
2483
2483
  import { createHash as createHash3 } from "crypto";
2484
2484
  import {
2485
2485
  existsSync as existsSync4,
2486
+ mkdirSync as mkdirSync3,
2486
2487
  readFileSync as readFileSync3,
2487
2488
  readdirSync,
2488
2489
  realpathSync,
@@ -2593,6 +2594,13 @@ function formatTypeScriptDiagnostic(diagnostic) {
2593
2594
  }
2594
2595
  return `${diagnostic.file.fileName}:${line + 1}:${character + 1} ${message}`;
2595
2596
  }
2597
+ function resolveBundledTypeRoots() {
2598
+ try {
2599
+ return [dirname3(dirname3(playArtifactRequire.resolve("@types/node/package.json")))];
2600
+ } catch {
2601
+ return [];
2602
+ }
2603
+ }
2596
2604
  function typecheckPlaySource(input, adapter) {
2597
2605
  const rootNames = Array.from(
2598
2606
  /* @__PURE__ */ new Set([
@@ -2618,7 +2626,8 @@ function typecheckPlaySource(input, adapter) {
2618
2626
  allowImportingTsExtensions: true,
2619
2627
  allowJs: true,
2620
2628
  resolveJsonModule: true,
2621
- types: ["node"]
2629
+ types: ["node"],
2630
+ typeRoots: resolveBundledTypeRoots()
2622
2631
  });
2623
2632
  return ts.getPreEmitDiagnostics(program).map(formatTypeScriptDiagnostic).filter((message) => Boolean(message));
2624
2633
  }
@@ -3984,6 +3993,67 @@ function defaultMaterializedPlayPath(reference) {
3984
3993
  const safeName = playName.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
3985
3994
  return resolve7(`${safeName || "play"}.play.ts`);
3986
3995
  }
3996
+ function sanitizeGeneratedPlayName(value) {
3997
+ return value.trim().toLowerCase().replace(/^prebuilt\//, "").replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "play";
3998
+ }
3999
+ function buildGeneratedCsvWrapperSource(input) {
4000
+ return `import { definePlay } from 'deepline';
4001
+
4002
+ export default definePlay(
4003
+ ${JSON.stringify(input.wrapperName)},
4004
+ async (ctx, input: Record<string, unknown> & { file: string }) => {
4005
+ const rows = await ctx.csv<Record<string, unknown>>(input.file);
4006
+ const constants = Object.fromEntries(
4007
+ Object.entries(input).filter(([key]) => key !== 'file'),
4008
+ );
4009
+
4010
+ const mappedRows = await ctx
4011
+ .map('csv_rows', rows, {
4012
+ key: (row, index) =>
4013
+ String(
4014
+ row.id ??
4015
+ row.lead_id ??
4016
+ row.email ??
4017
+ row.linkedin_url ??
4018
+ row.domain ??
4019
+ index,
4020
+ ),
4021
+ })
4022
+ .step('result', (row, rowCtx) =>
4023
+ rowCtx.runPlay(
4024
+ 'row_play',
4025
+ ${JSON.stringify(input.playRef)},
4026
+ {
4027
+ ...constants,
4028
+ ...row,
4029
+ },
4030
+ {
4031
+ description: 'Run the source play for this CSV row.',
4032
+ },
4033
+ ),
4034
+ )
4035
+ .run({ description: 'Run the source play once per CSV row.' });
4036
+
4037
+ return { rows: mappedRows };
4038
+ },
4039
+ );
4040
+ `;
4041
+ }
4042
+ function writeGeneratedCsvWrapperPlay(playRef) {
4043
+ const baseName = sanitizeGeneratedPlayName(
4044
+ parseReferencedPlayTarget(playRef).unqualifiedPlayName
4045
+ );
4046
+ const wrapperName = `${baseName}-csv`;
4047
+ const outputDir = resolve7(".deepline", "generated");
4048
+ const outputPath = join6(outputDir, `${wrapperName}.play.ts`);
4049
+ mkdirSync3(outputDir, { recursive: true });
4050
+ writeFileSync4(
4051
+ outputPath,
4052
+ buildGeneratedCsvWrapperSource({ wrapperName, playRef }),
4053
+ "utf-8"
4054
+ );
4055
+ return outputPath;
4056
+ }
3987
4057
  function materializeRemotePlaySource(input) {
3988
4058
  if (isFileTarget(input.target)) {
3989
4059
  return null;
@@ -5383,6 +5453,22 @@ async function handleNamedRun(options) {
5383
5453
  waitTimeoutMs: options.waitTimeoutMs,
5384
5454
  progress
5385
5455
  });
5456
+ if (finalStatus.status !== "completed" && options.csvPath) {
5457
+ progress.phase("generating csv wrapper play");
5458
+ const generatedPlayPath = writeGeneratedCsvWrapperPlay(
5459
+ options.target.name
5460
+ );
5461
+ progress.writeLogLine(
5462
+ `Generated CSV wrapper play: ${generatedPlayPath}`
5463
+ );
5464
+ progress.phase("running generated csv wrapper play");
5465
+ return handleFileBackedRun({
5466
+ ...options,
5467
+ target: { kind: "file", path: generatedPlayPath },
5468
+ revisionId: null,
5469
+ revisionSelector: null
5470
+ });
5471
+ }
5386
5472
  const exportedPath = exportPlayStatusRows(finalStatus, options.outPath);
5387
5473
  if (finalStatus.status === "completed") {
5388
5474
  progress.complete();
@@ -6196,7 +6282,7 @@ Examples:
6196
6282
  }
6197
6283
 
6198
6284
  // src/tool-output.ts
6199
- import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync5 } from "fs";
6285
+ import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
6200
6286
  import { homedir as homedir3 } from "os";
6201
6287
  import { join as join7 } from "path";
6202
6288
  function isPlainObject(value) {
@@ -6274,7 +6360,7 @@ function tryConvertToList(payload, options) {
6274
6360
  }
6275
6361
  function ensureOutputDir() {
6276
6362
  const outputDir = join7(homedir3(), ".local", "share", "deepline", "data");
6277
- mkdirSync3(outputDir, { recursive: true });
6363
+ mkdirSync4(outputDir, { recursive: true });
6278
6364
  return outputDir;
6279
6365
  }
6280
6366
  function writeJsonOutputFile(payload, stem) {
@@ -6886,7 +6972,7 @@ async function executeTool(args) {
6886
6972
 
6887
6973
  // src/cli/skills-sync.ts
6888
6974
  import { spawn } from "child_process";
6889
- import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync6 } from "fs";
6975
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync6 } from "fs";
6890
6976
  import { homedir as homedir4 } from "os";
6891
6977
  import { dirname as dirname7, join as join8 } from "path";
6892
6978
  var CHECK_TIMEOUT_MS2 = 3e3;
@@ -6912,7 +6998,7 @@ function readLocalSkillsVersion(baseUrl) {
6912
6998
  }
6913
6999
  function writeLocalSkillsVersion(baseUrl, version) {
6914
7000
  const path = sdkSkillsVersionPath(baseUrl);
6915
- mkdirSync4(dirname7(path), { recursive: true });
7001
+ mkdirSync5(dirname7(path), { recursive: true });
6916
7002
  writeFileSync6(path, `${version}
6917
7003
  `, "utf-8");
6918
7004
  }
@@ -7098,6 +7184,7 @@ Output:
7098
7184
  ok: false,
7099
7185
  error: error instanceof Error ? error.message : String(error)
7100
7186
  });
7187
+ progress?.fail();
7101
7188
  if (process.argv.includes("--json")) {
7102
7189
  printJsonError(error);
7103
7190
  } else if (error instanceof Error) {