deepline 0.1.24 → 0.1.25
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 +236 -104
- package/dist/cli/index.mjs +198 -66
- 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/version.ts +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli/index.ts
|
|
4
|
-
import { Command } from "commander";
|
|
4
|
+
import { Command as Command2 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/config.ts
|
|
7
7
|
import { readFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
|
|
@@ -243,7 +243,7 @@ function saveProjectDeeplineEnvValues(baseUrl, values, startDir = projectEnvStar
|
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
// src/version.ts
|
|
246
|
-
var SDK_VERSION = "0.1.
|
|
246
|
+
var SDK_VERSION = "0.1.25";
|
|
247
247
|
var SDK_API_CONTRACT = "2026-05-runs-v2";
|
|
248
248
|
|
|
249
249
|
// ../shared_libs/play-runtime/coordinator-headers.ts
|
|
@@ -525,7 +525,7 @@ function decodeSseFrame(frame) {
|
|
|
525
525
|
return parsed;
|
|
526
526
|
}
|
|
527
527
|
function sleep(ms) {
|
|
528
|
-
return new Promise((
|
|
528
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
// src/client.ts
|
|
@@ -533,7 +533,7 @@ var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "ca
|
|
|
533
533
|
var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
|
|
534
534
|
var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
|
|
535
535
|
function sleep2(ms) {
|
|
536
|
-
return new Promise((
|
|
536
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
537
537
|
}
|
|
538
538
|
function isTransientCompileManifestError(error) {
|
|
539
539
|
if (error instanceof DeeplineError && typeof error.statusCode === "number") {
|
|
@@ -2023,7 +2023,7 @@ function buildCandidateUrls2(url) {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
}
|
|
2025
2025
|
function sleep3(ms) {
|
|
2026
|
-
return new Promise((
|
|
2026
|
+
return new Promise((resolve9) => setTimeout(resolve9, ms));
|
|
2027
2027
|
}
|
|
2028
2028
|
function printDeeplineLogo() {
|
|
2029
2029
|
if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
|
|
@@ -2397,6 +2397,10 @@ Examples:
|
|
|
2397
2397
|
}
|
|
2398
2398
|
|
|
2399
2399
|
// src/cli/commands/billing.ts
|
|
2400
|
+
import { Command } from "commander";
|
|
2401
|
+
import { appendFile, mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
2402
|
+
import { dirname as dirname4, resolve as resolve3 } from "path";
|
|
2403
|
+
import { stringify as stringify2 } from "csv-stringify/sync";
|
|
2400
2404
|
function humanize(value) {
|
|
2401
2405
|
return String(value || "").split("_").filter(Boolean).map((token) => token[0]?.toUpperCase() + token.slice(1)).join(" ") || "Unknown";
|
|
2402
2406
|
}
|
|
@@ -2414,6 +2418,54 @@ function printRecentUsage(entries) {
|
|
|
2414
2418
|
`);
|
|
2415
2419
|
}
|
|
2416
2420
|
}
|
|
2421
|
+
function summarizeLedgerRows(summary, rows) {
|
|
2422
|
+
const netDelta = rows.reduce((sum, row) => {
|
|
2423
|
+
const value = Number.parseFloat(String(row.delta_credits ?? "").trim());
|
|
2424
|
+
return Number.isFinite(value) ? sum + value : sum;
|
|
2425
|
+
}, summary.net_delta_credits);
|
|
2426
|
+
return {
|
|
2427
|
+
row_count: summary.row_count + rows.length,
|
|
2428
|
+
net_delta_credits: Math.round((netDelta + Number.EPSILON) * 100) / 100
|
|
2429
|
+
};
|
|
2430
|
+
}
|
|
2431
|
+
function ledgerApiEntryToRow(entry) {
|
|
2432
|
+
const metadata = typeof entry.metadata === "object" && entry.metadata !== null ? entry.metadata : {};
|
|
2433
|
+
return {
|
|
2434
|
+
created_at: entry.created_at ?? "",
|
|
2435
|
+
delta_credits: entry.delta ?? "",
|
|
2436
|
+
reason: entry.reason ?? "",
|
|
2437
|
+
provider: metadata.provider ?? "",
|
|
2438
|
+
operation: metadata.operation ?? "",
|
|
2439
|
+
request_id: metadata.requestId ?? metadata.request_id ?? "",
|
|
2440
|
+
run_id: metadata.runId ?? metadata.run_id ?? "",
|
|
2441
|
+
api_key_id: entry.api_key_id ?? "",
|
|
2442
|
+
stripe_session_id: entry.stripe_session_id ?? ""
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2445
|
+
function ledgerRowsToCsv(rows, header) {
|
|
2446
|
+
return stringify2(rows, {
|
|
2447
|
+
header,
|
|
2448
|
+
columns: [
|
|
2449
|
+
"created_at",
|
|
2450
|
+
"delta_credits",
|
|
2451
|
+
"reason",
|
|
2452
|
+
"provider",
|
|
2453
|
+
"operation",
|
|
2454
|
+
"request_id",
|
|
2455
|
+
"run_id",
|
|
2456
|
+
"api_key_id",
|
|
2457
|
+
"stripe_session_id"
|
|
2458
|
+
]
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2461
|
+
function defaultLedgerExportPath() {
|
|
2462
|
+
return resolve3(
|
|
2463
|
+
process.cwd(),
|
|
2464
|
+
"deepline",
|
|
2465
|
+
"data",
|
|
2466
|
+
`billing-ledger-all-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.csv`
|
|
2467
|
+
);
|
|
2468
|
+
}
|
|
2417
2469
|
async function handleBalance(options) {
|
|
2418
2470
|
const { http } = getAuthedHttpClient();
|
|
2419
2471
|
const payload = await http.get("/api/v2/billing/balance");
|
|
@@ -2502,6 +2554,51 @@ async function handleHistory(options) {
|
|
|
2502
2554
|
process.stdout.write(`${rows.length} row(s) exported.
|
|
2503
2555
|
`);
|
|
2504
2556
|
}
|
|
2557
|
+
async function handleLedgerExportAll(options) {
|
|
2558
|
+
const { http } = getAuthedHttpClient();
|
|
2559
|
+
const outputPath = options.output ? resolve3(String(options.output)) : defaultLedgerExportPath();
|
|
2560
|
+
let summary = { row_count: 0, net_delta_credits: 0 };
|
|
2561
|
+
let cursor = null;
|
|
2562
|
+
let initializedOutput = false;
|
|
2563
|
+
for (; ; ) {
|
|
2564
|
+
const params = new URLSearchParams({ limit: "5000" });
|
|
2565
|
+
if (cursor !== null) params.set("cursor", cursor);
|
|
2566
|
+
const payload = await http.get(
|
|
2567
|
+
`/api/v2/billing/ledger?${params.toString()}`
|
|
2568
|
+
);
|
|
2569
|
+
const entries = Array.isArray(payload.entries) ? payload.entries : [];
|
|
2570
|
+
const rows = entries.map(ledgerApiEntryToRow);
|
|
2571
|
+
if (!initializedOutput) {
|
|
2572
|
+
await mkdir2(dirname4(outputPath), { recursive: true });
|
|
2573
|
+
await writeFile2(outputPath, ledgerRowsToCsv([], true), "utf-8");
|
|
2574
|
+
initializedOutput = true;
|
|
2575
|
+
}
|
|
2576
|
+
if (rows.length > 0) {
|
|
2577
|
+
await appendFile(outputPath, ledgerRowsToCsv(rows, false), "utf-8");
|
|
2578
|
+
summary = summarizeLedgerRows(summary, rows);
|
|
2579
|
+
}
|
|
2580
|
+
const nextCursor = typeof payload.next_cursor === "string" && payload.next_cursor.length > 0 ? payload.next_cursor : null;
|
|
2581
|
+
if (rows.length === 0 || payload.has_more !== true || nextCursor === null) {
|
|
2582
|
+
break;
|
|
2583
|
+
}
|
|
2584
|
+
if (nextCursor === cursor) break;
|
|
2585
|
+
cursor = nextCursor;
|
|
2586
|
+
}
|
|
2587
|
+
if (shouldEmitJson(options.json)) {
|
|
2588
|
+
return printJson({
|
|
2589
|
+
output_path: outputPath,
|
|
2590
|
+
row_count: summary.row_count,
|
|
2591
|
+
net_delta_credits: summary.net_delta_credits,
|
|
2592
|
+
scope: "current_auth_context"
|
|
2593
|
+
});
|
|
2594
|
+
}
|
|
2595
|
+
process.stdout.write(`Billing ledger written to ${outputPath}
|
|
2596
|
+
`);
|
|
2597
|
+
process.stdout.write(`${summary.row_count} row(s) exported for the current auth context.
|
|
2598
|
+
`);
|
|
2599
|
+
process.stdout.write(`Net ledger delta: ${summary.net_delta_credits} Deepline Credits
|
|
2600
|
+
`);
|
|
2601
|
+
}
|
|
2505
2602
|
async function handleCheckout(options) {
|
|
2506
2603
|
const { http } = getAuthedHttpClient();
|
|
2507
2604
|
const payload = await http.post("/api/v2/billing/checkout", {
|
|
@@ -2598,6 +2695,41 @@ Examples:
|
|
|
2598
2695
|
deepline billing off --json
|
|
2599
2696
|
`
|
|
2600
2697
|
).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleLimitOff);
|
|
2698
|
+
billing.command("ledger").description("Inspect and export billing ledger rows.").addHelpText(
|
|
2699
|
+
"after",
|
|
2700
|
+
`
|
|
2701
|
+
Notes:
|
|
2702
|
+
Read-only. Exports ledger rows for the current auth context. API-key auth is
|
|
2703
|
+
scoped by the server to that API key; session auth is scoped to the active
|
|
2704
|
+
workspace.
|
|
2705
|
+
|
|
2706
|
+
Examples:
|
|
2707
|
+
deepline billing ledger export all
|
|
2708
|
+
deepline billing ledger export all --output ./ledger.csv
|
|
2709
|
+
deepline billing ledger export all --json
|
|
2710
|
+
`
|
|
2711
|
+
).addCommand(
|
|
2712
|
+
new Command("export").description("Export billing ledger rows.").addHelpText(
|
|
2713
|
+
"after",
|
|
2714
|
+
`
|
|
2715
|
+
Examples:
|
|
2716
|
+
deepline billing ledger export all
|
|
2717
|
+
`
|
|
2718
|
+
).addCommand(
|
|
2719
|
+
new Command("all").description("Export all available billing ledger rows to CSV.").addHelpText(
|
|
2720
|
+
"after",
|
|
2721
|
+
`
|
|
2722
|
+
Notes:
|
|
2723
|
+
Pages through the ledger for the current auth context, writes CSV locally,
|
|
2724
|
+
then reports the row count and the net delta computed from delta_credits.
|
|
2725
|
+
|
|
2726
|
+
Examples:
|
|
2727
|
+
deepline billing ledger export all
|
|
2728
|
+
deepline billing ledger export all --json
|
|
2729
|
+
`
|
|
2730
|
+
).option("--output <path>", "Write CSV to an explicit path").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleLedgerExportAll)
|
|
2731
|
+
)
|
|
2732
|
+
);
|
|
2601
2733
|
billing.command("history").description("Export billing ledger history to CSV.").addHelpText(
|
|
2602
2734
|
"after",
|
|
2603
2735
|
`
|
|
@@ -2639,7 +2771,7 @@ Examples:
|
|
|
2639
2771
|
|
|
2640
2772
|
// src/cli/dataset-stats.ts
|
|
2641
2773
|
import { writeFileSync as writeFileSync4 } from "fs";
|
|
2642
|
-
import { resolve as
|
|
2774
|
+
import { resolve as resolve4 } from "path";
|
|
2643
2775
|
var CSV_PROJECTED_FIELDS_KEY = "__deeplineCsvProjectedFields";
|
|
2644
2776
|
function csvProjectedFields(row) {
|
|
2645
2777
|
const serialized = row[CSV_PROJECTED_FIELDS_KEY];
|
|
@@ -2969,7 +3101,7 @@ function writeCanonicalRowsCsv(rowsInfo, outPath) {
|
|
|
2969
3101
|
rows: rowsInfo.rows,
|
|
2970
3102
|
columns: rowsInfo.columns
|
|
2971
3103
|
});
|
|
2972
|
-
const resolved =
|
|
3104
|
+
const resolved = resolve4(outPath);
|
|
2973
3105
|
writeFileSync4(
|
|
2974
3106
|
resolved,
|
|
2975
3107
|
csvStringFromRows(sanitized.rows, sanitized.columns),
|
|
@@ -3370,19 +3502,19 @@ import {
|
|
|
3370
3502
|
realpathSync,
|
|
3371
3503
|
writeFileSync as writeFileSync5
|
|
3372
3504
|
} from "fs";
|
|
3373
|
-
import { basename as basename3, dirname as
|
|
3505
|
+
import { basename as basename3, dirname as dirname8, join as join6, resolve as resolve8 } from "path";
|
|
3374
3506
|
|
|
3375
3507
|
// src/plays/bundle-play-file.ts
|
|
3376
3508
|
import { tmpdir as tmpdir2 } from "os";
|
|
3377
|
-
import { dirname as
|
|
3509
|
+
import { dirname as dirname7, join as join5, resolve as resolve7 } from "path";
|
|
3378
3510
|
import { fileURLToPath } from "url";
|
|
3379
3511
|
import { existsSync as existsSync4 } from "fs";
|
|
3380
3512
|
|
|
3381
3513
|
// ../shared_libs/plays/bundling/index.ts
|
|
3382
3514
|
import { createHash } from "crypto";
|
|
3383
|
-
import { mkdir as
|
|
3515
|
+
import { mkdir as mkdir3, readFile, realpath, stat, writeFile as writeFile3 } from "fs/promises";
|
|
3384
3516
|
import { tmpdir } from "os";
|
|
3385
|
-
import { basename, dirname as
|
|
3517
|
+
import { basename, dirname as dirname5, extname, isAbsolute, join as join3, resolve as resolve5 } from "path";
|
|
3386
3518
|
import { builtinModules, createRequire } from "module";
|
|
3387
3519
|
import { build } from "esbuild";
|
|
3388
3520
|
|
|
@@ -3475,13 +3607,13 @@ async function normalizeLocalPath(filePath) {
|
|
|
3475
3607
|
try {
|
|
3476
3608
|
return await realpath(filePath);
|
|
3477
3609
|
} catch {
|
|
3478
|
-
return
|
|
3610
|
+
return resolve5(filePath);
|
|
3479
3611
|
}
|
|
3480
3612
|
}
|
|
3481
3613
|
function createPlayWorkspace(entryFile) {
|
|
3482
3614
|
return {
|
|
3483
3615
|
entryFile,
|
|
3484
|
-
rootDir:
|
|
3616
|
+
rootDir: dirname5(entryFile)
|
|
3485
3617
|
};
|
|
3486
3618
|
}
|
|
3487
3619
|
function isPathInsideDirectory(filePath, directory) {
|
|
@@ -3682,7 +3814,7 @@ function workersNamedPlayEntryAliasPlugin(playFilePath, exportName) {
|
|
|
3682
3814
|
contents: `export { ${exportName} as default } from ${JSON.stringify(playFilePath)};
|
|
3683
3815
|
`,
|
|
3684
3816
|
loader: "ts",
|
|
3685
|
-
resolveDir:
|
|
3817
|
+
resolveDir: dirname5(playFilePath)
|
|
3686
3818
|
})
|
|
3687
3819
|
);
|
|
3688
3820
|
}
|
|
@@ -3846,7 +3978,7 @@ function importedPlayProxyPlugin(importedPlayDependencies) {
|
|
|
3846
3978
|
return {
|
|
3847
3979
|
contents: buildImportedPlayProxyModule(dependency.playName),
|
|
3848
3980
|
loader: "ts",
|
|
3849
|
-
resolveDir:
|
|
3981
|
+
resolveDir: dirname5(args.path)
|
|
3850
3982
|
};
|
|
3851
3983
|
});
|
|
3852
3984
|
}
|
|
@@ -3864,7 +3996,7 @@ async function resolveLocalImport(fromFile, specifier) {
|
|
|
3864
3996
|
if (specifier.startsWith("file:")) {
|
|
3865
3997
|
return normalizeLocalPath(new URL(specifier).pathname);
|
|
3866
3998
|
}
|
|
3867
|
-
const base = isAbsolute(specifier) ?
|
|
3999
|
+
const base = isAbsolute(specifier) ? resolve5(specifier) : resolve5(dirname5(fromFile), specifier);
|
|
3868
4000
|
const candidates = [base];
|
|
3869
4001
|
const explicitExtension = extname(base).toLowerCase();
|
|
3870
4002
|
if (!explicitExtension) {
|
|
@@ -4065,8 +4197,8 @@ async function readArtifactCache(graphHash, artifactKind, adapter) {
|
|
|
4065
4197
|
}
|
|
4066
4198
|
async function writeArtifactCache(artifact, adapter) {
|
|
4067
4199
|
const cacheDir = adapter.cacheDir ?? PLAY_ARTIFACT_CACHE_DIR;
|
|
4068
|
-
await
|
|
4069
|
-
await
|
|
4200
|
+
await mkdir3(cacheDir, { recursive: true });
|
|
4201
|
+
await writeFile3(
|
|
4070
4202
|
artifactCachePath(
|
|
4071
4203
|
artifact.graphHash,
|
|
4072
4204
|
artifact.artifactKind ?? PLAY_ARTIFACT_KINDS.cjsNode20,
|
|
@@ -4082,7 +4214,7 @@ function normalizeSourceMapForRuntime(sourceMapText) {
|
|
|
4082
4214
|
if (sourcePath.startsWith("data:") || sourcePath.startsWith("node:") || sourcePath.startsWith("/") || /^[a-zA-Z]+:\/\//.test(sourcePath)) {
|
|
4083
4215
|
return sourcePath;
|
|
4084
4216
|
}
|
|
4085
|
-
return
|
|
4217
|
+
return resolve5(process.cwd(), sourcePath);
|
|
4086
4218
|
});
|
|
4087
4219
|
parsed.sourceRoot = void 0;
|
|
4088
4220
|
return JSON.stringify(parsed);
|
|
@@ -4114,7 +4246,7 @@ async function runEsbuildForCjsNode(entryFile, importedPlayDependencies, adapter
|
|
|
4114
4246
|
...namedExportShim ? {
|
|
4115
4247
|
stdin: {
|
|
4116
4248
|
contents: namedExportShim,
|
|
4117
|
-
resolveDir:
|
|
4249
|
+
resolveDir: dirname5(entryFile),
|
|
4118
4250
|
sourcefile: `${basename(entryFile)}.${exportName}.entry.ts`,
|
|
4119
4251
|
loader: "ts"
|
|
4120
4252
|
}
|
|
@@ -4404,7 +4536,7 @@ function resolveExecutionProfile(override) {
|
|
|
4404
4536
|
// src/plays/local-file-discovery.ts
|
|
4405
4537
|
import { createHash as createHash2 } from "crypto";
|
|
4406
4538
|
import { readFile as readFile2, stat as stat2 } from "fs/promises";
|
|
4407
|
-
import { basename as basename2, dirname as
|
|
4539
|
+
import { basename as basename2, dirname as dirname6, extname as extname2, isAbsolute as isAbsolute2, join as join4, relative, resolve as resolve6 } from "path";
|
|
4408
4540
|
var SOURCE_EXTENSIONS2 = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".json"];
|
|
4409
4541
|
function sha2562(buffer) {
|
|
4410
4542
|
return createHash2("sha256").update(buffer).digest("hex");
|
|
@@ -4605,7 +4737,7 @@ function isPathInsideDirectory2(filePath, directory) {
|
|
|
4605
4737
|
return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute2(relativePath);
|
|
4606
4738
|
}
|
|
4607
4739
|
async function resolveLocalImport2(fromFile, specifier) {
|
|
4608
|
-
const base = isAbsolute2(specifier) ?
|
|
4740
|
+
const base = isAbsolute2(specifier) ? resolve6(specifier) : resolve6(dirname6(fromFile), specifier);
|
|
4609
4741
|
const candidates = [base];
|
|
4610
4742
|
const explicitExtension = extname2(base).toLowerCase();
|
|
4611
4743
|
if (!explicitExtension) {
|
|
@@ -4623,13 +4755,13 @@ async function resolveLocalImport2(fromFile, specifier) {
|
|
|
4623
4755
|
throw new Error(`Could not resolve local import "${specifier}" from ${fromFile}`);
|
|
4624
4756
|
}
|
|
4625
4757
|
async function discoverPackagedLocalFiles(entryFile) {
|
|
4626
|
-
const absoluteEntryFile =
|
|
4627
|
-
const packagingRoot =
|
|
4758
|
+
const absoluteEntryFile = resolve6(entryFile);
|
|
4759
|
+
const packagingRoot = dirname6(absoluteEntryFile);
|
|
4628
4760
|
const files = /* @__PURE__ */ new Map();
|
|
4629
4761
|
const unresolved = [];
|
|
4630
4762
|
const visitedFiles = /* @__PURE__ */ new Set();
|
|
4631
4763
|
const visitSourceFile = async (filePath) => {
|
|
4632
|
-
const absolutePath =
|
|
4764
|
+
const absolutePath = resolve6(filePath);
|
|
4633
4765
|
if (visitedFiles.has(absolutePath)) {
|
|
4634
4766
|
return;
|
|
4635
4767
|
}
|
|
@@ -4661,7 +4793,7 @@ async function discoverPackagedLocalFiles(entryFile) {
|
|
|
4661
4793
|
message: "Could not resolve this ctx.csv(...) path at submit time. Use a string literal, a top-level const string, or pass a runtime input like input.file."
|
|
4662
4794
|
});
|
|
4663
4795
|
} else {
|
|
4664
|
-
const absoluteCsvPath =
|
|
4796
|
+
const absoluteCsvPath = resolve6(dirname6(absolutePath), resolvedPath);
|
|
4665
4797
|
if (isAbsolute2(resolvedPath) || !isPathInsideDirectory2(absoluteCsvPath, packagingRoot)) {
|
|
4666
4798
|
unresolved.push({
|
|
4667
4799
|
sourceFragment: sourceCode.slice(argument.start, argument.end).trim(),
|
|
@@ -4700,24 +4832,24 @@ async function discoverPackagedLocalFiles(entryFile) {
|
|
|
4700
4832
|
|
|
4701
4833
|
// src/plays/bundle-play-file.ts
|
|
4702
4834
|
var PLAY_BUNDLE_CACHE_VERSION2 = 26;
|
|
4703
|
-
var MODULE_DIR =
|
|
4704
|
-
var SDK_PACKAGE_ROOT =
|
|
4705
|
-
var SOURCE_REPO_ROOT =
|
|
4835
|
+
var MODULE_DIR = dirname7(fileURLToPath(import.meta.url));
|
|
4836
|
+
var SDK_PACKAGE_ROOT = resolve7(MODULE_DIR, "..", "..");
|
|
4837
|
+
var SOURCE_REPO_ROOT = resolve7(SDK_PACKAGE_ROOT, "..");
|
|
4706
4838
|
var HAS_SOURCE_BUNDLING_SOURCES = existsSync4(
|
|
4707
|
-
|
|
4839
|
+
resolve7(SOURCE_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
|
|
4708
4840
|
);
|
|
4709
|
-
var PACKAGED_REPO_ROOT =
|
|
4841
|
+
var PACKAGED_REPO_ROOT = resolve7(SDK_PACKAGE_ROOT, "dist", "repo");
|
|
4710
4842
|
var HAS_PACKAGED_BUNDLING_SOURCES = existsSync4(
|
|
4711
|
-
|
|
4843
|
+
resolve7(PACKAGED_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
|
|
4712
4844
|
);
|
|
4713
|
-
var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_REPO_ROOT :
|
|
4714
|
-
var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ?
|
|
4715
|
-
var SDK_PACKAGE_JSON =
|
|
4716
|
-
var SDK_ENTRY_FILE =
|
|
4717
|
-
var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE :
|
|
4718
|
-
var SDK_WORKERS_ENTRY_FILE =
|
|
4719
|
-
var WORKERS_HARNESS_ENTRY_FILE =
|
|
4720
|
-
var WORKERS_HARNESS_FILES_DIR =
|
|
4845
|
+
var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_REPO_ROOT : resolve7(SDK_PACKAGE_ROOT, "..");
|
|
4846
|
+
var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? resolve7(SOURCE_REPO_ROOT, "sdk", "src") : HAS_PACKAGED_BUNDLING_SOURCES ? resolve7(PACKAGED_REPO_ROOT, "sdk", "src") : resolve7(SDK_PACKAGE_ROOT, "src");
|
|
4847
|
+
var SDK_PACKAGE_JSON = resolve7(SDK_PACKAGE_ROOT, "package.json");
|
|
4848
|
+
var SDK_ENTRY_FILE = resolve7(SDK_SOURCE_ROOT, "index.ts");
|
|
4849
|
+
var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : resolve7(SDK_PACKAGE_ROOT, "dist", "index.d.ts");
|
|
4850
|
+
var SDK_WORKERS_ENTRY_FILE = resolve7(SDK_SOURCE_ROOT, "worker-play-entry.ts");
|
|
4851
|
+
var WORKERS_HARNESS_ENTRY_FILE = resolve7(PROJECT_ROOT, "apps", "play-runner-workers", "src", "entry.ts");
|
|
4852
|
+
var WORKERS_HARNESS_FILES_DIR = resolve7(PROJECT_ROOT, "apps", "play-runner-workers", "src");
|
|
4721
4853
|
var hasWarnedAboutNonDevelopmentBundling = false;
|
|
4722
4854
|
function warnAboutNonDevelopmentBundling(filePath) {
|
|
4723
4855
|
if (hasWarnedAboutNonDevelopmentBundling) {
|
|
@@ -4741,7 +4873,7 @@ function defaultPlayBundleTarget() {
|
|
|
4741
4873
|
function createSdkPlayBundlingAdapter() {
|
|
4742
4874
|
return {
|
|
4743
4875
|
projectRoot: PROJECT_ROOT,
|
|
4744
|
-
nodeModulesDir:
|
|
4876
|
+
nodeModulesDir: resolve7(PROJECT_ROOT, "node_modules"),
|
|
4745
4877
|
cacheDir: join5(tmpdir2(), `deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION2}`),
|
|
4746
4878
|
sdkSourceRoot: SDK_SOURCE_ROOT,
|
|
4747
4879
|
sdkPackageJson: SDK_PACKAGE_JSON,
|
|
@@ -5022,7 +5154,7 @@ function formatPlayListReference(play) {
|
|
|
5022
5154
|
function defaultMaterializedPlayPath(reference) {
|
|
5023
5155
|
const playName = parseReferencedPlayTarget(reference).unqualifiedPlayName;
|
|
5024
5156
|
const safeName = playName.trim().toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
5025
|
-
return
|
|
5157
|
+
return resolve8(`${safeName || "play"}.play.ts`);
|
|
5026
5158
|
}
|
|
5027
5159
|
function materializeRemotePlaySource(input) {
|
|
5028
5160
|
if (isFileTarget(input.target)) {
|
|
@@ -5085,7 +5217,7 @@ function extractPlayName(code, filePath) {
|
|
|
5085
5217
|
throw buildMissingDefinePlayError(filePath);
|
|
5086
5218
|
}
|
|
5087
5219
|
function isFileTarget(target) {
|
|
5088
|
-
return existsSync5(
|
|
5220
|
+
return existsSync5(resolve8(target));
|
|
5089
5221
|
}
|
|
5090
5222
|
function looksLikeFilePath(target) {
|
|
5091
5223
|
if (target.trim().toLowerCase().startsWith("prebuilt/")) {
|
|
@@ -5104,7 +5236,7 @@ function parsePositiveInteger2(value, flagName) {
|
|
|
5104
5236
|
return parsed;
|
|
5105
5237
|
}
|
|
5106
5238
|
function parseJsonInput(raw) {
|
|
5107
|
-
const source = raw.startsWith("@") ? readFileSync3(
|
|
5239
|
+
const source = raw.startsWith("@") ? readFileSync3(resolve8(raw.slice(1)), "utf-8") : raw;
|
|
5108
5240
|
const parsed = JSON.parse(source);
|
|
5109
5241
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
5110
5242
|
throw new Error("--input must be a JSON object.");
|
|
@@ -5214,7 +5346,7 @@ function applyCsvShortcutInput(input) {
|
|
|
5214
5346
|
function isLocalFilePathValue(value) {
|
|
5215
5347
|
if (typeof value !== "string" || !value.trim()) return false;
|
|
5216
5348
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim())) return false;
|
|
5217
|
-
return existsSync5(
|
|
5349
|
+
return existsSync5(resolve8(value));
|
|
5218
5350
|
}
|
|
5219
5351
|
function inputContainsLocalFilePath(value) {
|
|
5220
5352
|
if (isLocalFilePathValue(value)) {
|
|
@@ -5240,7 +5372,7 @@ async function stageFileInputArgs(input) {
|
|
|
5240
5372
|
const localFiles = uniqueBindings.flatMap((binding) => {
|
|
5241
5373
|
const value = getDottedInputValue(input.runtimeInput, binding.inputPath);
|
|
5242
5374
|
if (!isLocalFilePathValue(value)) return [];
|
|
5243
|
-
const absolutePath =
|
|
5375
|
+
const absolutePath = resolve8(value);
|
|
5244
5376
|
return [{ binding, absolutePath, logicalPath: basename3(absolutePath) }];
|
|
5245
5377
|
});
|
|
5246
5378
|
if (localFiles.length === 0) {
|
|
@@ -5276,9 +5408,9 @@ function stageFile(logicalPath, absolutePath) {
|
|
|
5276
5408
|
}
|
|
5277
5409
|
function normalizePlayPath(filePath) {
|
|
5278
5410
|
try {
|
|
5279
|
-
return realpathSync.native(
|
|
5411
|
+
return realpathSync.native(resolve8(filePath));
|
|
5280
5412
|
} catch {
|
|
5281
|
-
return
|
|
5413
|
+
return resolve8(filePath);
|
|
5282
5414
|
}
|
|
5283
5415
|
}
|
|
5284
5416
|
function formatBundlingErrors(filePath, errors) {
|
|
@@ -6338,7 +6470,7 @@ function parsePlayRunOptions(args) {
|
|
|
6338
6470
|
continue;
|
|
6339
6471
|
}
|
|
6340
6472
|
if (arg === "--out" && args[index + 1]) {
|
|
6341
|
-
outPath =
|
|
6473
|
+
outPath = resolve8(args[++index]);
|
|
6342
6474
|
continue;
|
|
6343
6475
|
}
|
|
6344
6476
|
if (arg === "--poll-interval-ms" || arg === "--interval-ms") {
|
|
@@ -6438,11 +6570,11 @@ function shouldUseLocalOnlyPlayCheck() {
|
|
|
6438
6570
|
async function handlePlayCheck(args) {
|
|
6439
6571
|
const options = parsePlayCheckOptions(args);
|
|
6440
6572
|
if (!isFileTarget(options.target)) {
|
|
6441
|
-
const resolved =
|
|
6573
|
+
const resolved = resolve8(options.target);
|
|
6442
6574
|
console.error(`File not found: ${resolved}`);
|
|
6443
6575
|
return 1;
|
|
6444
6576
|
}
|
|
6445
|
-
const absolutePlayPath =
|
|
6577
|
+
const absolutePlayPath = resolve8(options.target);
|
|
6446
6578
|
const sourceCode = readFileSync3(absolutePlayPath, "utf-8");
|
|
6447
6579
|
let graph;
|
|
6448
6580
|
try {
|
|
@@ -6506,7 +6638,7 @@ async function handleFileBackedRun(options) {
|
|
|
6506
6638
|
}
|
|
6507
6639
|
const client = new DeeplineClient();
|
|
6508
6640
|
const progress = getActiveCliProgress() ?? createCliProgress(!options.jsonOutput);
|
|
6509
|
-
const absolutePlayPath =
|
|
6641
|
+
const absolutePlayPath = resolve8(options.target.path);
|
|
6510
6642
|
progress.phase("compiling play");
|
|
6511
6643
|
const sourceCode = traceCliSync(
|
|
6512
6644
|
"cli.play_file_read_source",
|
|
@@ -6795,9 +6927,9 @@ async function handlePlayRun(args) {
|
|
|
6795
6927
|
if (isFileTarget(options.target.path)) {
|
|
6796
6928
|
return handleFileBackedRun(options);
|
|
6797
6929
|
}
|
|
6798
|
-
const resolved =
|
|
6930
|
+
const resolved = resolve8(options.target.path);
|
|
6799
6931
|
console.error(`File not found: ${resolved}`);
|
|
6800
|
-
const dir =
|
|
6932
|
+
const dir = dirname8(resolved);
|
|
6801
6933
|
if (existsSync5(dir)) {
|
|
6802
6934
|
const base = basename3(resolved);
|
|
6803
6935
|
try {
|
|
@@ -6953,7 +7085,7 @@ async function handleRunLogs(args) {
|
|
|
6953
7085
|
continue;
|
|
6954
7086
|
}
|
|
6955
7087
|
if (arg === "--out" && args[index + 1]) {
|
|
6956
|
-
outPath =
|
|
7088
|
+
outPath = resolve8(args[++index]);
|
|
6957
7089
|
}
|
|
6958
7090
|
}
|
|
6959
7091
|
const client = new DeeplineClient();
|
|
@@ -7040,7 +7172,7 @@ async function handleRunExport(args) {
|
|
|
7040
7172
|
for (let index = 0; index < args.length; index += 1) {
|
|
7041
7173
|
const arg = args[index];
|
|
7042
7174
|
if (arg === "--out" && args[index + 1]) {
|
|
7043
|
-
outPath =
|
|
7175
|
+
outPath = resolve8(args[++index]);
|
|
7044
7176
|
}
|
|
7045
7177
|
}
|
|
7046
7178
|
if (!outPath) {
|
|
@@ -7080,10 +7212,10 @@ async function handlePlayGet(args) {
|
|
|
7080
7212
|
for (let index = 1; index < args.length; index += 1) {
|
|
7081
7213
|
const arg = args[index];
|
|
7082
7214
|
if (arg === "--out" && args[index + 1]) {
|
|
7083
|
-
outPath =
|
|
7215
|
+
outPath = resolve8(args[++index]);
|
|
7084
7216
|
}
|
|
7085
7217
|
}
|
|
7086
|
-
const playName = isFileTarget(target) ? extractPlayName(readFileSync3(
|
|
7218
|
+
const playName = isFileTarget(target) ? extractPlayName(readFileSync3(resolve8(target), "utf-8"), resolve8(target)) : parseReferencedPlayTarget(target).playName;
|
|
7087
7219
|
const detail = isFileTarget(target) ? await client.getPlay(playName) : await assertCanonicalNamedPlayReference(client, target);
|
|
7088
7220
|
const resolvedSource = detail.play.workingRevision?.sourceCode ?? detail.play.liveRevision?.sourceCode ?? detail.play.currentRevision?.sourceCode ?? detail.play.sourceCode ?? "";
|
|
7089
7221
|
const materializedFile = outPath ? materializeRemotePlaySource({
|
|
@@ -7375,7 +7507,7 @@ async function handlePlayPublish(args) {
|
|
|
7375
7507
|
}
|
|
7376
7508
|
let graph;
|
|
7377
7509
|
try {
|
|
7378
|
-
graph = await collectBundledPlayGraph(
|
|
7510
|
+
graph = await collectBundledPlayGraph(resolve8(playName));
|
|
7379
7511
|
await compileBundledPlayGraphManifests(client, graph);
|
|
7380
7512
|
await publishImportedPlayDependencies(client, graph);
|
|
7381
7513
|
} catch (error) {
|
|
@@ -8668,7 +8800,7 @@ async function executeTool(args) {
|
|
|
8668
8800
|
import { spawn, spawnSync as spawnSync2 } from "child_process";
|
|
8669
8801
|
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readFileSync as readFileSync4, writeFileSync as writeFileSync8 } from "fs";
|
|
8670
8802
|
import { homedir as homedir4 } from "os";
|
|
8671
|
-
import { dirname as
|
|
8803
|
+
import { dirname as dirname9, join as join9 } from "path";
|
|
8672
8804
|
var CHECK_TIMEOUT_MS2 = 3e3;
|
|
8673
8805
|
var SDK_SKILL_NAME = "deepline-sdk";
|
|
8674
8806
|
var SKILL_AGENTS = ["codex", "claude-code", "cursor"];
|
|
@@ -8692,7 +8824,7 @@ function readLocalSkillsVersion(baseUrl) {
|
|
|
8692
8824
|
}
|
|
8693
8825
|
function writeLocalSkillsVersion(baseUrl, version) {
|
|
8694
8826
|
const path = sdkSkillsVersionPath(baseUrl);
|
|
8695
|
-
mkdirSync5(
|
|
8827
|
+
mkdirSync5(dirname9(path), { recursive: true });
|
|
8696
8828
|
writeFileSync8(path, `${version}
|
|
8697
8829
|
`, "utf-8");
|
|
8698
8830
|
}
|
|
@@ -8787,7 +8919,7 @@ function resolveSkillsInstallCommands(baseUrl) {
|
|
|
8787
8919
|
return [npxInstall];
|
|
8788
8920
|
}
|
|
8789
8921
|
function runOneSkillsInstall(install) {
|
|
8790
|
-
return new Promise((
|
|
8922
|
+
return new Promise((resolve9) => {
|
|
8791
8923
|
const child = spawn(install.command, install.args, {
|
|
8792
8924
|
stdio: ["ignore", "ignore", "pipe"],
|
|
8793
8925
|
env: process.env
|
|
@@ -8797,7 +8929,7 @@ function runOneSkillsInstall(install) {
|
|
|
8797
8929
|
stderr += chunk.toString("utf-8");
|
|
8798
8930
|
});
|
|
8799
8931
|
child.on("error", (error) => {
|
|
8800
|
-
|
|
8932
|
+
resolve9({
|
|
8801
8933
|
ok: false,
|
|
8802
8934
|
detail: `failed to start ${install.command}: ${error.message}`,
|
|
8803
8935
|
manualCommand: install.manualCommand
|
|
@@ -8805,11 +8937,11 @@ function runOneSkillsInstall(install) {
|
|
|
8805
8937
|
});
|
|
8806
8938
|
child.on("close", (code) => {
|
|
8807
8939
|
if (code === 0) {
|
|
8808
|
-
|
|
8940
|
+
resolve9({ ok: true, detail: "", manualCommand: install.manualCommand });
|
|
8809
8941
|
return;
|
|
8810
8942
|
}
|
|
8811
8943
|
const detail = stderr.trim();
|
|
8812
|
-
|
|
8944
|
+
resolve9({
|
|
8813
8945
|
ok: false,
|
|
8814
8946
|
detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
|
|
8815
8947
|
manualCommand: install.manualCommand
|
|
@@ -8886,7 +9018,7 @@ async function main() {
|
|
|
8886
9018
|
if (printStartupPhase) {
|
|
8887
9019
|
progress?.phase("loading deepline cli");
|
|
8888
9020
|
}
|
|
8889
|
-
const program = new
|
|
9021
|
+
const program = new Command2();
|
|
8890
9022
|
program.name("deepline").description("Deepline CLI (TypeScript SDK)").version(SDK_VERSION, "-v, --version", "Show version").showHelpAfterError().showSuggestionAfterError(true).addHelpText(
|
|
8891
9023
|
"after",
|
|
8892
9024
|
`
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.1.
|
|
1
|
+
export const SDK_VERSION = "0.1.25";
|
|
2
2
|
export const SDK_API_CONTRACT = "2026-05-runs-v2";
|