deepline 0.1.3 → 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.3";
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
@@ -1464,6 +1464,27 @@ function buildCandidateUrls2(url) {
1464
1464
  function sleep2(ms) {
1465
1465
  return new Promise((resolve8) => setTimeout(resolve8, ms));
1466
1466
  }
1467
+ function printDeeplineLogo() {
1468
+ if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
1469
+ console.log(" \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557");
1470
+ console.log(" \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D");
1471
+ console.log(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557");
1472
+ console.log(" \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D");
1473
+ console.log(" \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557");
1474
+ console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
1475
+ console.log("");
1476
+ return;
1477
+ }
1478
+ console.log("DEEPLINE");
1479
+ }
1480
+ function printClaimSuccessBanner(statusData) {
1481
+ console.log("");
1482
+ printDeeplineLogo();
1483
+ console.log("\u2713 All set! Your CLI is connected.");
1484
+ if (statusData.org_name) {
1485
+ console.log(` \u2022 Signed in with organization: ${statusData.org_name}`);
1486
+ }
1487
+ }
1467
1488
  async function handleRegister(args) {
1468
1489
  const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
1469
1490
  let orgName = "";
@@ -1539,12 +1560,7 @@ async function handleRegister(args) {
1539
1560
  DEEPLINE_API_KEY: apiKey,
1540
1561
  DEEPLINE_CLAIM_TOKEN: ""
1541
1562
  }, baseUrl);
1542
- console.log("");
1543
- console.log("DEEPLINE");
1544
- console.log("All set! Your CLI is connected.");
1545
- if (statusData.org_name) {
1546
- console.log(` Signed in with organization: ${statusData.org_name}`);
1547
- }
1563
+ printClaimSuccessBanner(statusData);
1548
1564
  return EXIT_OK;
1549
1565
  }
1550
1566
  }
@@ -1605,7 +1621,7 @@ async function handleWait(args) {
1605
1621
  DEEPLINE_API_KEY: apiKey,
1606
1622
  DEEPLINE_CLAIM_TOKEN: ""
1607
1623
  }, baseUrl);
1608
- console.log("All set! Your CLI is connected.");
1624
+ printClaimSuccessBanner(data);
1609
1625
  return EXIT_OK;
1610
1626
  }
1611
1627
  }
@@ -2467,6 +2483,7 @@ function registerOrgCommands(program) {
2467
2483
  import { createHash as createHash3 } from "crypto";
2468
2484
  import {
2469
2485
  existsSync as existsSync4,
2486
+ mkdirSync as mkdirSync3,
2470
2487
  readFileSync as readFileSync3,
2471
2488
  readdirSync,
2472
2489
  realpathSync,
@@ -2577,6 +2594,13 @@ function formatTypeScriptDiagnostic(diagnostic) {
2577
2594
  }
2578
2595
  return `${diagnostic.file.fileName}:${line + 1}:${character + 1} ${message}`;
2579
2596
  }
2597
+ function resolveBundledTypeRoots() {
2598
+ try {
2599
+ return [dirname3(dirname3(playArtifactRequire.resolve("@types/node/package.json")))];
2600
+ } catch {
2601
+ return [];
2602
+ }
2603
+ }
2580
2604
  function typecheckPlaySource(input, adapter) {
2581
2605
  const rootNames = Array.from(
2582
2606
  /* @__PURE__ */ new Set([
@@ -2602,7 +2626,8 @@ function typecheckPlaySource(input, adapter) {
2602
2626
  allowImportingTsExtensions: true,
2603
2627
  allowJs: true,
2604
2628
  resolveJsonModule: true,
2605
- types: ["node"]
2629
+ types: ["node"],
2630
+ typeRoots: resolveBundledTypeRoots()
2606
2631
  });
2607
2632
  return ts.getPreEmitDiagnostics(program).map(formatTypeScriptDiagnostic).filter((message) => Boolean(message));
2608
2633
  }
@@ -3968,6 +3993,67 @@ function defaultMaterializedPlayPath(reference) {
3968
3993
  const safeName = playName.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
3969
3994
  return resolve7(`${safeName || "play"}.play.ts`);
3970
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
+ }
3971
4057
  function materializeRemotePlaySource(input) {
3972
4058
  if (isFileTarget(input.target)) {
3973
4059
  return null;
@@ -5367,6 +5453,22 @@ async function handleNamedRun(options) {
5367
5453
  waitTimeoutMs: options.waitTimeoutMs,
5368
5454
  progress
5369
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
+ }
5370
5472
  const exportedPath = exportPlayStatusRows(finalStatus, options.outPath);
5371
5473
  if (finalStatus.status === "completed") {
5372
5474
  progress.complete();
@@ -6180,7 +6282,7 @@ Examples:
6180
6282
  }
6181
6283
 
6182
6284
  // src/tool-output.ts
6183
- import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync5 } from "fs";
6285
+ import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
6184
6286
  import { homedir as homedir3 } from "os";
6185
6287
  import { join as join7 } from "path";
6186
6288
  function isPlainObject(value) {
@@ -6258,7 +6360,7 @@ function tryConvertToList(payload, options) {
6258
6360
  }
6259
6361
  function ensureOutputDir() {
6260
6362
  const outputDir = join7(homedir3(), ".local", "share", "deepline", "data");
6261
- mkdirSync3(outputDir, { recursive: true });
6363
+ mkdirSync4(outputDir, { recursive: true });
6262
6364
  return outputDir;
6263
6365
  }
6264
6366
  function writeJsonOutputFile(payload, stem) {
@@ -6868,6 +6970,122 @@ async function executeTool(args) {
6868
6970
  return 0;
6869
6971
  }
6870
6972
 
6973
+ // src/cli/skills-sync.ts
6974
+ import { spawn } from "child_process";
6975
+ import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync6 } from "fs";
6976
+ import { homedir as homedir4 } from "os";
6977
+ import { dirname as dirname7, join as join8 } from "path";
6978
+ var CHECK_TIMEOUT_MS2 = 3e3;
6979
+ var SDK_SKILL_NAME = "deepline-sdk";
6980
+ var SKILL_AGENTS = ["codex", "claude-code", "cursor"];
6981
+ var attemptedSync = false;
6982
+ function shouldSkipSkillsSync() {
6983
+ const value = process.env.DEEPLINE_SKIP_SKILLS_SYNC?.trim().toLowerCase();
6984
+ return value === "1" || value === "true" || value === "yes" || value === "on";
6985
+ }
6986
+ function sdkSkillsVersionPath(baseUrl) {
6987
+ const home = process.env.HOME?.trim() || homedir4();
6988
+ return join8(home, ".local", "deepline", baseUrlSlug(baseUrl), "sdk-skills", ".version");
6989
+ }
6990
+ function readLocalSkillsVersion(baseUrl) {
6991
+ const path = sdkSkillsVersionPath(baseUrl);
6992
+ if (!existsSync5(path)) return "";
6993
+ try {
6994
+ return readFileSync4(path, "utf-8").trim();
6995
+ } catch {
6996
+ return "";
6997
+ }
6998
+ }
6999
+ function writeLocalSkillsVersion(baseUrl, version) {
7000
+ const path = sdkSkillsVersionPath(baseUrl);
7001
+ mkdirSync5(dirname7(path), { recursive: true });
7002
+ writeFileSync6(path, `${version}
7003
+ `, "utf-8");
7004
+ }
7005
+ async function fetchSkillsUpdate(baseUrl, localVersion) {
7006
+ const controller = new AbortController();
7007
+ const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS2);
7008
+ try {
7009
+ const response = await fetch(new URL("/api/v2/cli/update-check", baseUrl), {
7010
+ method: "POST",
7011
+ headers: { "Content-Type": "application/json" },
7012
+ body: JSON.stringify({
7013
+ skills: {
7014
+ version: localVersion
7015
+ }
7016
+ }),
7017
+ signal: controller.signal
7018
+ });
7019
+ if (!response.ok) return null;
7020
+ const data = await response.json().catch(() => null);
7021
+ const skills = data?.skills;
7022
+ if (!skills) return null;
7023
+ return {
7024
+ needsUpdate: skills.needs_update === true,
7025
+ remoteVersion: typeof skills.remote?.version === "string" ? skills.remote.version.trim() : ""
7026
+ };
7027
+ } catch {
7028
+ return null;
7029
+ } finally {
7030
+ clearTimeout(timeout);
7031
+ }
7032
+ }
7033
+ function runSkillsInstall(baseUrl) {
7034
+ const packageUrl = new URL("/.well-known/skills/index.json", baseUrl).toString();
7035
+ const args = [
7036
+ "skills",
7037
+ "add",
7038
+ packageUrl,
7039
+ "--agents",
7040
+ ...SKILL_AGENTS,
7041
+ "--global",
7042
+ "--yes",
7043
+ "--skill",
7044
+ SDK_SKILL_NAME,
7045
+ "--full-depth"
7046
+ ];
7047
+ return new Promise((resolve8) => {
7048
+ const child = spawn("npx", args, {
7049
+ stdio: ["ignore", "ignore", "pipe"],
7050
+ env: process.env
7051
+ });
7052
+ let stderr = "";
7053
+ child.stderr.on("data", (chunk) => {
7054
+ stderr += chunk.toString("utf-8");
7055
+ });
7056
+ child.on("error", (error) => {
7057
+ process.stderr.write(`SDK skills sync failed to start: ${error.message}
7058
+ `);
7059
+ resolve8(false);
7060
+ });
7061
+ child.on("close", (code) => {
7062
+ if (code === 0) {
7063
+ resolve8(true);
7064
+ return;
7065
+ }
7066
+ const detail = stderr.trim();
7067
+ process.stderr.write(
7068
+ `SDK skills sync failed${detail ? `: ${detail}` : ""}
7069
+ Run manually: npx ${args.map((arg) => arg.includes(" ") ? JSON.stringify(arg) : arg).join(" ")}
7070
+ `
7071
+ );
7072
+ resolve8(false);
7073
+ });
7074
+ });
7075
+ }
7076
+ async function syncSdkSkillsIfNeeded(baseUrl) {
7077
+ if (attemptedSync || shouldSkipSkillsSync()) return;
7078
+ attemptedSync = true;
7079
+ const localVersion = readLocalSkillsVersion(baseUrl);
7080
+ const update = await fetchSkillsUpdate(baseUrl, localVersion);
7081
+ if (!update?.needsUpdate || !update.remoteVersion) return;
7082
+ process.stderr.write("SDK skills changed; syncing deepline-sdk skill...\n");
7083
+ const installed = await runSkillsInstall(baseUrl);
7084
+ if (!installed) return;
7085
+ writeLocalSkillsVersion(baseUrl, update.remoteVersion);
7086
+ process.stderr.write("SDK skills are up to date.\n");
7087
+ }
7088
+
6871
7089
  // src/cli/index.ts
6872
7090
  function shouldPrintStartupPhase() {
6873
7091
  if (process.argv.includes("--json")) {
@@ -6919,6 +7137,14 @@ Output:
6919
7137
  { baseUrl },
6920
7138
  () => enforceSdkCompatibility(baseUrl)
6921
7139
  );
7140
+ if (printStartupPhase) {
7141
+ progress?.phase("checking sdk skills");
7142
+ }
7143
+ await traceCliSpan(
7144
+ "cli.sdk_skills_sync",
7145
+ { baseUrl },
7146
+ () => syncSdkSkillsIfNeeded(baseUrl)
7147
+ );
6922
7148
  });
6923
7149
  registerAuthCommands(program);
6924
7150
  registerToolsCommands(program);
@@ -6958,6 +7184,7 @@ Output:
6958
7184
  ok: false,
6959
7185
  error: error instanceof Error ? error.message : String(error)
6960
7186
  });
7187
+ progress?.fail();
6961
7188
  if (process.argv.includes("--json")) {
6962
7189
  printJsonError(error);
6963
7190
  } else if (error instanceof Error) {