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.
- package/dist/cli/index.js +235 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +238 -11
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/repo/sdk/src/cli/commands/auth.ts +25 -7
- package/dist/repo/sdk/src/cli/commands/play.ts +92 -0
- package/dist/repo/sdk/src/cli/index.ts +10 -0
- package/dist/repo/sdk/src/cli/skills-sync.ts +137 -0
- package/dist/repo/sdk/src/version.ts +1 -1
- package/dist/repo/shared_libs/plays/bundling/index.ts +9 -0
- package/package.json +5 -3
package/dist/cli/index.js
CHANGED
|
@@ -192,7 +192,7 @@ function resolveConfig(options) {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// src/version.ts
|
|
195
|
-
var SDK_VERSION = "0.1.
|
|
195
|
+
var SDK_VERSION = "0.1.7";
|
|
196
196
|
var SDK_API_CONTRACT = "2026-04-plays-v1";
|
|
197
197
|
|
|
198
198
|
// ../shared_libs/play-runtime/coordinator-headers.ts
|
|
@@ -1487,6 +1487,27 @@ function buildCandidateUrls2(url) {
|
|
|
1487
1487
|
function sleep2(ms) {
|
|
1488
1488
|
return new Promise((resolve8) => setTimeout(resolve8, ms));
|
|
1489
1489
|
}
|
|
1490
|
+
function printDeeplineLogo() {
|
|
1491
|
+
if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
|
|
1492
|
+
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");
|
|
1493
|
+
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");
|
|
1494
|
+
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");
|
|
1495
|
+
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");
|
|
1496
|
+
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");
|
|
1497
|
+
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");
|
|
1498
|
+
console.log("");
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
console.log("DEEPLINE");
|
|
1502
|
+
}
|
|
1503
|
+
function printClaimSuccessBanner(statusData) {
|
|
1504
|
+
console.log("");
|
|
1505
|
+
printDeeplineLogo();
|
|
1506
|
+
console.log("\u2713 All set! Your CLI is connected.");
|
|
1507
|
+
if (statusData.org_name) {
|
|
1508
|
+
console.log(` \u2022 Signed in with organization: ${statusData.org_name}`);
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1490
1511
|
async function handleRegister(args) {
|
|
1491
1512
|
const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
|
|
1492
1513
|
let orgName = "";
|
|
@@ -1562,12 +1583,7 @@ async function handleRegister(args) {
|
|
|
1562
1583
|
DEEPLINE_API_KEY: apiKey,
|
|
1563
1584
|
DEEPLINE_CLAIM_TOKEN: ""
|
|
1564
1585
|
}, baseUrl);
|
|
1565
|
-
|
|
1566
|
-
console.log("DEEPLINE");
|
|
1567
|
-
console.log("All set! Your CLI is connected.");
|
|
1568
|
-
if (statusData.org_name) {
|
|
1569
|
-
console.log(` Signed in with organization: ${statusData.org_name}`);
|
|
1570
|
-
}
|
|
1586
|
+
printClaimSuccessBanner(statusData);
|
|
1571
1587
|
return EXIT_OK;
|
|
1572
1588
|
}
|
|
1573
1589
|
}
|
|
@@ -1628,7 +1644,7 @@ async function handleWait(args) {
|
|
|
1628
1644
|
DEEPLINE_API_KEY: apiKey,
|
|
1629
1645
|
DEEPLINE_CLAIM_TOKEN: ""
|
|
1630
1646
|
}, baseUrl);
|
|
1631
|
-
|
|
1647
|
+
printClaimSuccessBanner(data);
|
|
1632
1648
|
return EXIT_OK;
|
|
1633
1649
|
}
|
|
1634
1650
|
}
|
|
@@ -2595,6 +2611,13 @@ function formatTypeScriptDiagnostic(diagnostic) {
|
|
|
2595
2611
|
}
|
|
2596
2612
|
return `${diagnostic.file.fileName}:${line + 1}:${character + 1} ${message}`;
|
|
2597
2613
|
}
|
|
2614
|
+
function resolveBundledTypeRoots() {
|
|
2615
|
+
try {
|
|
2616
|
+
return [(0, import_node_path5.dirname)((0, import_node_path5.dirname)(playArtifactRequire.resolve("@types/node/package.json")))];
|
|
2617
|
+
} catch {
|
|
2618
|
+
return [];
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2598
2621
|
function typecheckPlaySource(input, adapter) {
|
|
2599
2622
|
const rootNames = Array.from(
|
|
2600
2623
|
/* @__PURE__ */ new Set([
|
|
@@ -2620,7 +2643,8 @@ function typecheckPlaySource(input, adapter) {
|
|
|
2620
2643
|
allowImportingTsExtensions: true,
|
|
2621
2644
|
allowJs: true,
|
|
2622
2645
|
resolveJsonModule: true,
|
|
2623
|
-
types: ["node"]
|
|
2646
|
+
types: ["node"],
|
|
2647
|
+
typeRoots: resolveBundledTypeRoots()
|
|
2624
2648
|
});
|
|
2625
2649
|
return import_typescript.default.getPreEmitDiagnostics(program).map(formatTypeScriptDiagnostic).filter((message) => Boolean(message));
|
|
2626
2650
|
}
|
|
@@ -3987,6 +4011,67 @@ function defaultMaterializedPlayPath(reference) {
|
|
|
3987
4011
|
const safeName = playName.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
3988
4012
|
return (0, import_node_path8.resolve)(`${safeName || "play"}.play.ts`);
|
|
3989
4013
|
}
|
|
4014
|
+
function sanitizeGeneratedPlayName(value) {
|
|
4015
|
+
return value.trim().toLowerCase().replace(/^prebuilt\//, "").replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "play";
|
|
4016
|
+
}
|
|
4017
|
+
function buildGeneratedCsvWrapperSource(input) {
|
|
4018
|
+
return `import { definePlay } from 'deepline';
|
|
4019
|
+
|
|
4020
|
+
export default definePlay(
|
|
4021
|
+
${JSON.stringify(input.wrapperName)},
|
|
4022
|
+
async (ctx, input: Record<string, unknown> & { file: string }) => {
|
|
4023
|
+
const rows = await ctx.csv<Record<string, unknown>>(input.file);
|
|
4024
|
+
const constants = Object.fromEntries(
|
|
4025
|
+
Object.entries(input).filter(([key]) => key !== 'file'),
|
|
4026
|
+
);
|
|
4027
|
+
|
|
4028
|
+
const mappedRows = await ctx
|
|
4029
|
+
.map('csv_rows', rows, {
|
|
4030
|
+
key: (row, index) =>
|
|
4031
|
+
String(
|
|
4032
|
+
row.id ??
|
|
4033
|
+
row.lead_id ??
|
|
4034
|
+
row.email ??
|
|
4035
|
+
row.linkedin_url ??
|
|
4036
|
+
row.domain ??
|
|
4037
|
+
index,
|
|
4038
|
+
),
|
|
4039
|
+
})
|
|
4040
|
+
.step('result', (row, rowCtx) =>
|
|
4041
|
+
rowCtx.runPlay(
|
|
4042
|
+
'row_play',
|
|
4043
|
+
${JSON.stringify(input.playRef)},
|
|
4044
|
+
{
|
|
4045
|
+
...constants,
|
|
4046
|
+
...row,
|
|
4047
|
+
},
|
|
4048
|
+
{
|
|
4049
|
+
description: 'Run the source play for this CSV row.',
|
|
4050
|
+
},
|
|
4051
|
+
),
|
|
4052
|
+
)
|
|
4053
|
+
.run({ description: 'Run the source play once per CSV row.' });
|
|
4054
|
+
|
|
4055
|
+
return { rows: mappedRows };
|
|
4056
|
+
},
|
|
4057
|
+
);
|
|
4058
|
+
`;
|
|
4059
|
+
}
|
|
4060
|
+
function writeGeneratedCsvWrapperPlay(playRef) {
|
|
4061
|
+
const baseName = sanitizeGeneratedPlayName(
|
|
4062
|
+
parseReferencedPlayTarget(playRef).unqualifiedPlayName
|
|
4063
|
+
);
|
|
4064
|
+
const wrapperName = `${baseName}-csv`;
|
|
4065
|
+
const outputDir = (0, import_node_path8.resolve)(".deepline", "generated");
|
|
4066
|
+
const outputPath = (0, import_node_path8.join)(outputDir, `${wrapperName}.play.ts`);
|
|
4067
|
+
(0, import_node_fs6.mkdirSync)(outputDir, { recursive: true });
|
|
4068
|
+
(0, import_node_fs6.writeFileSync)(
|
|
4069
|
+
outputPath,
|
|
4070
|
+
buildGeneratedCsvWrapperSource({ wrapperName, playRef }),
|
|
4071
|
+
"utf-8"
|
|
4072
|
+
);
|
|
4073
|
+
return outputPath;
|
|
4074
|
+
}
|
|
3990
4075
|
function materializeRemotePlaySource(input) {
|
|
3991
4076
|
if (isFileTarget(input.target)) {
|
|
3992
4077
|
return null;
|
|
@@ -5386,6 +5471,22 @@ async function handleNamedRun(options) {
|
|
|
5386
5471
|
waitTimeoutMs: options.waitTimeoutMs,
|
|
5387
5472
|
progress
|
|
5388
5473
|
});
|
|
5474
|
+
if (finalStatus.status !== "completed" && options.csvPath) {
|
|
5475
|
+
progress.phase("generating csv wrapper play");
|
|
5476
|
+
const generatedPlayPath = writeGeneratedCsvWrapperPlay(
|
|
5477
|
+
options.target.name
|
|
5478
|
+
);
|
|
5479
|
+
progress.writeLogLine(
|
|
5480
|
+
`Generated CSV wrapper play: ${generatedPlayPath}`
|
|
5481
|
+
);
|
|
5482
|
+
progress.phase("running generated csv wrapper play");
|
|
5483
|
+
return handleFileBackedRun({
|
|
5484
|
+
...options,
|
|
5485
|
+
target: { kind: "file", path: generatedPlayPath },
|
|
5486
|
+
revisionId: null,
|
|
5487
|
+
revisionSelector: null
|
|
5488
|
+
});
|
|
5489
|
+
}
|
|
5389
5490
|
const exportedPath = exportPlayStatusRows(finalStatus, options.outPath);
|
|
5390
5491
|
if (finalStatus.status === "completed") {
|
|
5391
5492
|
progress.complete();
|
|
@@ -6887,6 +6988,122 @@ async function executeTool(args) {
|
|
|
6887
6988
|
return 0;
|
|
6888
6989
|
}
|
|
6889
6990
|
|
|
6991
|
+
// src/cli/skills-sync.ts
|
|
6992
|
+
var import_node_child_process2 = require("child_process");
|
|
6993
|
+
var import_node_fs8 = require("fs");
|
|
6994
|
+
var import_node_os7 = require("os");
|
|
6995
|
+
var import_node_path10 = require("path");
|
|
6996
|
+
var CHECK_TIMEOUT_MS2 = 3e3;
|
|
6997
|
+
var SDK_SKILL_NAME = "deepline-sdk";
|
|
6998
|
+
var SKILL_AGENTS = ["codex", "claude-code", "cursor"];
|
|
6999
|
+
var attemptedSync = false;
|
|
7000
|
+
function shouldSkipSkillsSync() {
|
|
7001
|
+
const value = process.env.DEEPLINE_SKIP_SKILLS_SYNC?.trim().toLowerCase();
|
|
7002
|
+
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
7003
|
+
}
|
|
7004
|
+
function sdkSkillsVersionPath(baseUrl) {
|
|
7005
|
+
const home = process.env.HOME?.trim() || (0, import_node_os7.homedir)();
|
|
7006
|
+
return (0, import_node_path10.join)(home, ".local", "deepline", baseUrlSlug(baseUrl), "sdk-skills", ".version");
|
|
7007
|
+
}
|
|
7008
|
+
function readLocalSkillsVersion(baseUrl) {
|
|
7009
|
+
const path = sdkSkillsVersionPath(baseUrl);
|
|
7010
|
+
if (!(0, import_node_fs8.existsSync)(path)) return "";
|
|
7011
|
+
try {
|
|
7012
|
+
return (0, import_node_fs8.readFileSync)(path, "utf-8").trim();
|
|
7013
|
+
} catch {
|
|
7014
|
+
return "";
|
|
7015
|
+
}
|
|
7016
|
+
}
|
|
7017
|
+
function writeLocalSkillsVersion(baseUrl, version) {
|
|
7018
|
+
const path = sdkSkillsVersionPath(baseUrl);
|
|
7019
|
+
(0, import_node_fs8.mkdirSync)((0, import_node_path10.dirname)(path), { recursive: true });
|
|
7020
|
+
(0, import_node_fs8.writeFileSync)(path, `${version}
|
|
7021
|
+
`, "utf-8");
|
|
7022
|
+
}
|
|
7023
|
+
async function fetchSkillsUpdate(baseUrl, localVersion) {
|
|
7024
|
+
const controller = new AbortController();
|
|
7025
|
+
const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS2);
|
|
7026
|
+
try {
|
|
7027
|
+
const response = await fetch(new URL("/api/v2/cli/update-check", baseUrl), {
|
|
7028
|
+
method: "POST",
|
|
7029
|
+
headers: { "Content-Type": "application/json" },
|
|
7030
|
+
body: JSON.stringify({
|
|
7031
|
+
skills: {
|
|
7032
|
+
version: localVersion
|
|
7033
|
+
}
|
|
7034
|
+
}),
|
|
7035
|
+
signal: controller.signal
|
|
7036
|
+
});
|
|
7037
|
+
if (!response.ok) return null;
|
|
7038
|
+
const data = await response.json().catch(() => null);
|
|
7039
|
+
const skills = data?.skills;
|
|
7040
|
+
if (!skills) return null;
|
|
7041
|
+
return {
|
|
7042
|
+
needsUpdate: skills.needs_update === true,
|
|
7043
|
+
remoteVersion: typeof skills.remote?.version === "string" ? skills.remote.version.trim() : ""
|
|
7044
|
+
};
|
|
7045
|
+
} catch {
|
|
7046
|
+
return null;
|
|
7047
|
+
} finally {
|
|
7048
|
+
clearTimeout(timeout);
|
|
7049
|
+
}
|
|
7050
|
+
}
|
|
7051
|
+
function runSkillsInstall(baseUrl) {
|
|
7052
|
+
const packageUrl = new URL("/.well-known/skills/index.json", baseUrl).toString();
|
|
7053
|
+
const args = [
|
|
7054
|
+
"skills",
|
|
7055
|
+
"add",
|
|
7056
|
+
packageUrl,
|
|
7057
|
+
"--agents",
|
|
7058
|
+
...SKILL_AGENTS,
|
|
7059
|
+
"--global",
|
|
7060
|
+
"--yes",
|
|
7061
|
+
"--skill",
|
|
7062
|
+
SDK_SKILL_NAME,
|
|
7063
|
+
"--full-depth"
|
|
7064
|
+
];
|
|
7065
|
+
return new Promise((resolve8) => {
|
|
7066
|
+
const child = (0, import_node_child_process2.spawn)("npx", args, {
|
|
7067
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
7068
|
+
env: process.env
|
|
7069
|
+
});
|
|
7070
|
+
let stderr = "";
|
|
7071
|
+
child.stderr.on("data", (chunk) => {
|
|
7072
|
+
stderr += chunk.toString("utf-8");
|
|
7073
|
+
});
|
|
7074
|
+
child.on("error", (error) => {
|
|
7075
|
+
process.stderr.write(`SDK skills sync failed to start: ${error.message}
|
|
7076
|
+
`);
|
|
7077
|
+
resolve8(false);
|
|
7078
|
+
});
|
|
7079
|
+
child.on("close", (code) => {
|
|
7080
|
+
if (code === 0) {
|
|
7081
|
+
resolve8(true);
|
|
7082
|
+
return;
|
|
7083
|
+
}
|
|
7084
|
+
const detail = stderr.trim();
|
|
7085
|
+
process.stderr.write(
|
|
7086
|
+
`SDK skills sync failed${detail ? `: ${detail}` : ""}
|
|
7087
|
+
Run manually: npx ${args.map((arg) => arg.includes(" ") ? JSON.stringify(arg) : arg).join(" ")}
|
|
7088
|
+
`
|
|
7089
|
+
);
|
|
7090
|
+
resolve8(false);
|
|
7091
|
+
});
|
|
7092
|
+
});
|
|
7093
|
+
}
|
|
7094
|
+
async function syncSdkSkillsIfNeeded(baseUrl) {
|
|
7095
|
+
if (attemptedSync || shouldSkipSkillsSync()) return;
|
|
7096
|
+
attemptedSync = true;
|
|
7097
|
+
const localVersion = readLocalSkillsVersion(baseUrl);
|
|
7098
|
+
const update = await fetchSkillsUpdate(baseUrl, localVersion);
|
|
7099
|
+
if (!update?.needsUpdate || !update.remoteVersion) return;
|
|
7100
|
+
process.stderr.write("SDK skills changed; syncing deepline-sdk skill...\n");
|
|
7101
|
+
const installed = await runSkillsInstall(baseUrl);
|
|
7102
|
+
if (!installed) return;
|
|
7103
|
+
writeLocalSkillsVersion(baseUrl, update.remoteVersion);
|
|
7104
|
+
process.stderr.write("SDK skills are up to date.\n");
|
|
7105
|
+
}
|
|
7106
|
+
|
|
6890
7107
|
// src/cli/index.ts
|
|
6891
7108
|
function shouldPrintStartupPhase() {
|
|
6892
7109
|
if (process.argv.includes("--json")) {
|
|
@@ -6938,6 +7155,14 @@ Output:
|
|
|
6938
7155
|
{ baseUrl },
|
|
6939
7156
|
() => enforceSdkCompatibility(baseUrl)
|
|
6940
7157
|
);
|
|
7158
|
+
if (printStartupPhase) {
|
|
7159
|
+
progress?.phase("checking sdk skills");
|
|
7160
|
+
}
|
|
7161
|
+
await traceCliSpan(
|
|
7162
|
+
"cli.sdk_skills_sync",
|
|
7163
|
+
{ baseUrl },
|
|
7164
|
+
() => syncSdkSkillsIfNeeded(baseUrl)
|
|
7165
|
+
);
|
|
6941
7166
|
});
|
|
6942
7167
|
registerAuthCommands(program);
|
|
6943
7168
|
registerToolsCommands(program);
|
|
@@ -6977,6 +7202,7 @@ Output:
|
|
|
6977
7202
|
ok: false,
|
|
6978
7203
|
error: error instanceof Error ? error.message : String(error)
|
|
6979
7204
|
});
|
|
7205
|
+
progress?.fail();
|
|
6980
7206
|
if (process.argv.includes("--json")) {
|
|
6981
7207
|
printJsonError(error);
|
|
6982
7208
|
} else if (error instanceof Error) {
|