deepline 0.1.64 → 0.1.66
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 -199
- package/dist/cli/index.mjs +120 -83
- package/dist/index.js +48 -11
- package/dist/index.mjs +44 -7
- package/dist/repo/apps/play-runner-workers/src/coordinator-entry.ts +475 -69
- package/dist/repo/apps/play-runner-workers/src/dedup-do.ts +134 -0
- package/dist/repo/apps/play-runner-workers/src/entry.ts +37 -49
- package/dist/repo/apps/play-runner-workers/src/runtime/harness-receipt-store.ts +13 -0
- package/dist/repo/apps/play-runner-workers/src/runtime/receipts.ts +10 -136
- package/dist/repo/sdk/src/http.ts +44 -0
- package/dist/repo/sdk/src/plays/harness-stub.ts +4 -0
- package/dist/repo/sdk/src/release.ts +2 -2
- package/dist/repo/shared_libs/play-runtime/db-session-crypto.ts +312 -0
- package/dist/repo/shared_libs/play-runtime/db-session-plan.ts +69 -0
- package/dist/repo/shared_libs/play-runtime/db-session.ts +439 -0
- package/dist/repo/shared_libs/play-runtime/work-receipts.ts +92 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -25,8 +25,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
|
|
26
26
|
// src/cli/index.ts
|
|
27
27
|
var import_promises5 = require("fs/promises");
|
|
28
|
-
var
|
|
29
|
-
var
|
|
28
|
+
var import_node_path17 = require("path");
|
|
29
|
+
var import_node_os10 = require("os");
|
|
30
30
|
var import_commander3 = require("commander");
|
|
31
31
|
|
|
32
32
|
// src/config.ts
|
|
@@ -222,12 +222,17 @@ function resolveConfig(options) {
|
|
|
222
222
|
};
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
// src/http.ts
|
|
226
|
+
var import_node_fs2 = require("fs");
|
|
227
|
+
var import_node_os2 = require("os");
|
|
228
|
+
var import_node_path2 = require("path");
|
|
229
|
+
|
|
225
230
|
// src/release.ts
|
|
226
231
|
var SDK_RELEASE = {
|
|
227
|
-
version: "0.1.
|
|
232
|
+
version: "0.1.66",
|
|
228
233
|
apiContract: "2026-05-play-bootstrap-dataset-summary",
|
|
229
234
|
supportPolicy: {
|
|
230
|
-
latest: "0.1.
|
|
235
|
+
latest: "0.1.66",
|
|
231
236
|
minimumSupported: "0.1.53",
|
|
232
237
|
deprecatedBelow: "0.1.53"
|
|
233
238
|
}
|
|
@@ -243,19 +248,51 @@ var COORDINATOR_URL_OVERRIDE_HEADER = "x-deepline-coordinator-url";
|
|
|
243
248
|
var WORKER_CALLBACK_URL_OVERRIDE_HEADER = "x-deepline-worker-callback-url";
|
|
244
249
|
|
|
245
250
|
// src/http.ts
|
|
251
|
+
var MAX_DIAGNOSTIC_HEADER_LENGTH = 120;
|
|
246
252
|
var HttpClient = class {
|
|
247
253
|
constructor(config) {
|
|
248
254
|
this.config = config;
|
|
249
255
|
}
|
|
250
256
|
config;
|
|
257
|
+
cleanDiagnosticHeader(value) {
|
|
258
|
+
const normalized = String(value ?? "").replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, MAX_DIAGNOSTIC_HEADER_LENGTH);
|
|
259
|
+
return normalized || null;
|
|
260
|
+
}
|
|
261
|
+
readSkillsVersionHeader() {
|
|
262
|
+
const explicit = this.cleanDiagnosticHeader(
|
|
263
|
+
process.env.DEEPLINE_SKILLS_VERSION
|
|
264
|
+
);
|
|
265
|
+
if (explicit) return explicit;
|
|
266
|
+
try {
|
|
267
|
+
const versionPath = (0, import_node_path2.join)(
|
|
268
|
+
process.env.HOME?.trim() || (0, import_node_os2.homedir)(),
|
|
269
|
+
".local",
|
|
270
|
+
"deepline",
|
|
271
|
+
baseUrlSlug(this.config.baseUrl),
|
|
272
|
+
"sdk-skills",
|
|
273
|
+
".version"
|
|
274
|
+
);
|
|
275
|
+
if (!(0, import_node_fs2.existsSync)(versionPath)) return null;
|
|
276
|
+
return this.cleanDiagnosticHeader((0, import_node_fs2.readFileSync)(versionPath, "utf-8"));
|
|
277
|
+
} catch {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
251
281
|
authHeaders(extra) {
|
|
252
282
|
const headers = {
|
|
253
283
|
Authorization: `Bearer ${this.config.apiKey}`,
|
|
254
284
|
"User-Agent": `deepline-ts-sdk/${SDK_VERSION}`,
|
|
285
|
+
"X-Deepline-Client-Family": "sdk",
|
|
286
|
+
"X-Deepline-CLI-Family": "sdk",
|
|
287
|
+
"X-Deepline-CLI-Version": SDK_VERSION,
|
|
255
288
|
"X-Deepline-SDK-Version": SDK_VERSION,
|
|
256
289
|
"X-Deepline-API-Contract": SDK_API_CONTRACT,
|
|
257
290
|
...extra
|
|
258
291
|
};
|
|
292
|
+
const skillsVersion = this.readSkillsVersionHeader();
|
|
293
|
+
if (skillsVersion) {
|
|
294
|
+
headers["X-Deepline-Skills-Version"] = skillsVersion;
|
|
295
|
+
}
|
|
259
296
|
const bypassToken = typeof process !== "undefined" ? process.env?.VERCEL_PROTECTION_BYPASS_TOKEN : void 0;
|
|
260
297
|
if (bypassToken) {
|
|
261
298
|
headers["x-vercel-protection-bypass"] = bypassToken;
|
|
@@ -1744,15 +1781,15 @@ async function enforceSdkCompatibility(baseUrl) {
|
|
|
1744
1781
|
}
|
|
1745
1782
|
|
|
1746
1783
|
// src/cli/commands/auth.ts
|
|
1747
|
-
var
|
|
1748
|
-
var
|
|
1749
|
-
var
|
|
1784
|
+
var import_node_fs4 = require("fs");
|
|
1785
|
+
var import_node_os4 = require("os");
|
|
1786
|
+
var import_node_path4 = require("path");
|
|
1750
1787
|
|
|
1751
1788
|
// src/cli/utils.ts
|
|
1752
|
-
var
|
|
1789
|
+
var import_node_fs3 = require("fs");
|
|
1753
1790
|
var import_promises = require("fs/promises");
|
|
1754
|
-
var
|
|
1755
|
-
var
|
|
1791
|
+
var import_node_os3 = require("os");
|
|
1792
|
+
var import_node_path3 = require("path");
|
|
1756
1793
|
var childProcess = __toESM(require("child_process"));
|
|
1757
1794
|
var import_sync = require("csv-parse/sync");
|
|
1758
1795
|
var import_sync2 = require("csv-stringify/sync");
|
|
@@ -1763,15 +1800,15 @@ function getAuthedHttpClient() {
|
|
|
1763
1800
|
return { config, http: new HttpClient(config) };
|
|
1764
1801
|
}
|
|
1765
1802
|
async function writeOutputFile(filename, content) {
|
|
1766
|
-
const outputDir = (0,
|
|
1803
|
+
const outputDir = (0, import_node_path3.resolve)(process.cwd(), "deepline", "data");
|
|
1767
1804
|
await (0, import_promises.mkdir)(outputDir, { recursive: true });
|
|
1768
|
-
const fullPath = (0,
|
|
1805
|
+
const fullPath = (0, import_node_path3.join)(outputDir, filename);
|
|
1769
1806
|
await (0, import_promises.writeFile)(fullPath, content, "utf-8");
|
|
1770
1807
|
return fullPath;
|
|
1771
1808
|
}
|
|
1772
1809
|
function browserFocusStateFile() {
|
|
1773
|
-
const homeDir = process.env.HOME || (0,
|
|
1774
|
-
return (0,
|
|
1810
|
+
const homeDir = process.env.HOME || (0, import_node_os3.homedir)();
|
|
1811
|
+
return (0, import_node_path3.join)(
|
|
1775
1812
|
homeDir,
|
|
1776
1813
|
".local",
|
|
1777
1814
|
"deepline",
|
|
@@ -1783,10 +1820,10 @@ function browserFocusStateFile() {
|
|
|
1783
1820
|
function claimBrowserFocus(now = Date.now()) {
|
|
1784
1821
|
const statePath = browserFocusStateFile();
|
|
1785
1822
|
try {
|
|
1786
|
-
(0,
|
|
1823
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path3.dirname)(statePath), { recursive: true });
|
|
1787
1824
|
let lastFocusedAt = 0;
|
|
1788
|
-
if ((0,
|
|
1789
|
-
const payload = JSON.parse((0,
|
|
1825
|
+
if ((0, import_node_fs3.existsSync)(statePath)) {
|
|
1826
|
+
const payload = JSON.parse((0, import_node_fs3.readFileSync)(statePath, "utf-8"));
|
|
1790
1827
|
const value = payload.lastFocusedAt ?? payload.last_focused_at;
|
|
1791
1828
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
1792
1829
|
lastFocusedAt = value;
|
|
@@ -1798,7 +1835,7 @@ function claimBrowserFocus(now = Date.now()) {
|
|
|
1798
1835
|
if (now - lastFocusedAt < BROWSER_FOCUS_COOLDOWN_MS) {
|
|
1799
1836
|
return false;
|
|
1800
1837
|
}
|
|
1801
|
-
(0,
|
|
1838
|
+
(0, import_node_fs3.writeFileSync)(statePath, JSON.stringify({ lastFocusedAt: now }), "utf-8");
|
|
1802
1839
|
return true;
|
|
1803
1840
|
} catch {
|
|
1804
1841
|
return true;
|
|
@@ -1832,7 +1869,7 @@ function readDefaultMacBrowserBundleId(runner = defaultBrowserCommandRunner) {
|
|
|
1832
1869
|
"/usr/bin/defaults",
|
|
1833
1870
|
[
|
|
1834
1871
|
"read",
|
|
1835
|
-
`${(0,
|
|
1872
|
+
`${(0, import_node_os3.homedir)()}/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist`,
|
|
1836
1873
|
"LSHandlers"
|
|
1837
1874
|
],
|
|
1838
1875
|
{ encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
|
|
@@ -1991,11 +2028,11 @@ function collectLocalEnvInfo() {
|
|
|
1991
2028
|
return {
|
|
1992
2029
|
os: `${process.platform} ${process.arch}`,
|
|
1993
2030
|
node_version: process.version,
|
|
1994
|
-
home_dir: (0,
|
|
2031
|
+
home_dir: (0, import_node_os3.homedir)()
|
|
1995
2032
|
};
|
|
1996
2033
|
}
|
|
1997
2034
|
function readCsvRows(csvPath) {
|
|
1998
|
-
const raw = (0,
|
|
2035
|
+
const raw = (0, import_node_fs3.readFileSync)((0, import_node_path3.resolve)(csvPath), "utf-8");
|
|
1999
2036
|
return (0, import_sync.parse)(raw, {
|
|
2000
2037
|
columns: true,
|
|
2001
2038
|
skip_empty_lines: true
|
|
@@ -2202,25 +2239,25 @@ function pendingClaimTokenPath(baseUrl) {
|
|
|
2202
2239
|
}
|
|
2203
2240
|
function savePendingClaimToken(baseUrl, claimToken) {
|
|
2204
2241
|
const filePath = pendingClaimTokenPath(baseUrl);
|
|
2205
|
-
const dir = (0,
|
|
2206
|
-
if (!(0,
|
|
2207
|
-
(0,
|
|
2242
|
+
const dir = (0, import_node_path4.dirname)(filePath);
|
|
2243
|
+
if (!(0, import_node_fs4.existsSync)(dir)) {
|
|
2244
|
+
(0, import_node_fs4.mkdirSync)(dir, { recursive: true });
|
|
2208
2245
|
}
|
|
2209
|
-
(0,
|
|
2246
|
+
(0, import_node_fs4.writeFileSync)(filePath, `${claimToken}
|
|
2210
2247
|
`, "utf-8");
|
|
2211
2248
|
}
|
|
2212
2249
|
function readPendingClaimToken(baseUrl) {
|
|
2213
2250
|
const filePath = pendingClaimTokenPath(baseUrl);
|
|
2214
|
-
if (!(0,
|
|
2251
|
+
if (!(0, import_node_fs4.existsSync)(filePath)) return "";
|
|
2215
2252
|
try {
|
|
2216
|
-
return (0,
|
|
2253
|
+
return (0, import_node_fs4.readFileSync)(filePath, "utf-8").trim();
|
|
2217
2254
|
} catch {
|
|
2218
2255
|
return "";
|
|
2219
2256
|
}
|
|
2220
2257
|
}
|
|
2221
2258
|
function clearPendingClaimToken(baseUrl) {
|
|
2222
2259
|
try {
|
|
2223
|
-
(0,
|
|
2260
|
+
(0, import_node_fs4.rmSync)(pendingClaimTokenPath(baseUrl), { force: true });
|
|
2224
2261
|
} catch {
|
|
2225
2262
|
}
|
|
2226
2263
|
}
|
|
@@ -2332,7 +2369,7 @@ async function handleRegister(args) {
|
|
|
2332
2369
|
}
|
|
2333
2370
|
if (!agentName) {
|
|
2334
2371
|
try {
|
|
2335
|
-
agentName = (0,
|
|
2372
|
+
agentName = (0, import_node_os4.hostname)() || "Deepline CLI (TS)";
|
|
2336
2373
|
} catch {
|
|
2337
2374
|
agentName = "Deepline CLI (TS)";
|
|
2338
2375
|
}
|
|
@@ -2737,7 +2774,7 @@ Examples:
|
|
|
2737
2774
|
// src/cli/commands/billing.ts
|
|
2738
2775
|
var import_commander = require("commander");
|
|
2739
2776
|
var import_promises2 = require("fs/promises");
|
|
2740
|
-
var
|
|
2777
|
+
var import_node_path5 = require("path");
|
|
2741
2778
|
var import_sync3 = require("csv-stringify/sync");
|
|
2742
2779
|
function humanize(value) {
|
|
2743
2780
|
return String(value || "").split("_").filter(Boolean).map((token) => token[0]?.toUpperCase() + token.slice(1)).join(" ") || "Unknown";
|
|
@@ -2798,7 +2835,7 @@ function ledgerRowsToCsv(rows, header) {
|
|
|
2798
2835
|
});
|
|
2799
2836
|
}
|
|
2800
2837
|
function defaultLedgerExportPath() {
|
|
2801
|
-
return (0,
|
|
2838
|
+
return (0, import_node_path5.resolve)(
|
|
2802
2839
|
process.cwd(),
|
|
2803
2840
|
"deepline",
|
|
2804
2841
|
"data",
|
|
@@ -2960,7 +2997,7 @@ async function handleHistory(options) {
|
|
|
2960
2997
|
}
|
|
2961
2998
|
async function handleLedgerExportAll(options) {
|
|
2962
2999
|
const { http } = getAuthedHttpClient();
|
|
2963
|
-
const outputPath = options.output ? (0,
|
|
3000
|
+
const outputPath = options.output ? (0, import_node_path5.resolve)(String(options.output)) : defaultLedgerExportPath();
|
|
2964
3001
|
let summary = { row_count: 0, net_delta_credits: 0 };
|
|
2965
3002
|
let cursor = null;
|
|
2966
3003
|
let initializedOutput = false;
|
|
@@ -2973,7 +3010,7 @@ async function handleLedgerExportAll(options) {
|
|
|
2973
3010
|
const entries = Array.isArray(payload.entries) ? payload.entries : [];
|
|
2974
3011
|
const rows = entries.map(ledgerApiEntryToRow);
|
|
2975
3012
|
if (!initializedOutput) {
|
|
2976
|
-
await (0, import_promises2.mkdir)((0,
|
|
3013
|
+
await (0, import_promises2.mkdir)((0, import_node_path5.dirname)(outputPath), { recursive: true });
|
|
2977
3014
|
await (0, import_promises2.writeFile)(outputPath, ledgerRowsToCsv([], true), "utf-8");
|
|
2978
3015
|
initializedOutput = true;
|
|
2979
3016
|
}
|
|
@@ -3212,8 +3249,8 @@ Examples:
|
|
|
3212
3249
|
}
|
|
3213
3250
|
|
|
3214
3251
|
// src/cli/dataset-stats.ts
|
|
3215
|
-
var
|
|
3216
|
-
var
|
|
3252
|
+
var import_node_fs5 = require("fs");
|
|
3253
|
+
var import_node_path6 = require("path");
|
|
3217
3254
|
|
|
3218
3255
|
// ../shared_libs/plays/dataset-summary.ts
|
|
3219
3256
|
function datasetSummaryPercentText(numerator, denominator) {
|
|
@@ -3713,8 +3750,8 @@ function writeCanonicalRowsCsv(rowsInfo, outPath) {
|
|
|
3713
3750
|
});
|
|
3714
3751
|
const rows = dataExportRows(sanitized.rows);
|
|
3715
3752
|
const columns = dataExportColumns(rows, sanitized.columns);
|
|
3716
|
-
const resolved = (0,
|
|
3717
|
-
(0,
|
|
3753
|
+
const resolved = (0, import_node_path6.resolve)(outPath);
|
|
3754
|
+
(0, import_node_fs5.writeFileSync)(resolved, csvStringFromRows(rows, columns), "utf-8");
|
|
3718
3755
|
return resolved;
|
|
3719
3756
|
}
|
|
3720
3757
|
|
|
@@ -3850,8 +3887,8 @@ Examples:
|
|
|
3850
3887
|
}
|
|
3851
3888
|
|
|
3852
3889
|
// src/cli/commands/db.ts
|
|
3853
|
-
var
|
|
3854
|
-
var
|
|
3890
|
+
var import_node_fs6 = require("fs");
|
|
3891
|
+
var import_node_path7 = require("path");
|
|
3855
3892
|
var CUSTOMER_DB_QUERY_FORMATS = /* @__PURE__ */ new Set(["table", "json", "csv", "markdown"]);
|
|
3856
3893
|
function parsePositiveInteger(value, flagName) {
|
|
3857
3894
|
const parsed = Number.parseInt(value, 10);
|
|
@@ -3919,8 +3956,8 @@ function customerDbColumnNames(result) {
|
|
|
3919
3956
|
return result.columns.map((column) => column.name).filter(Boolean);
|
|
3920
3957
|
}
|
|
3921
3958
|
function writeCustomerDbCsv(result, outPath) {
|
|
3922
|
-
const resolved = (0,
|
|
3923
|
-
(0,
|
|
3959
|
+
const resolved = (0, import_node_path7.resolve)(outPath);
|
|
3960
|
+
(0, import_node_fs6.writeFileSync)(
|
|
3924
3961
|
resolved,
|
|
3925
3962
|
dataExportCsvString(customerDbRows(result), customerDbColumnNames(result)),
|
|
3926
3963
|
"utf-8"
|
|
@@ -4026,8 +4063,8 @@ async function handleDbQuery(args) {
|
|
|
4026
4063
|
customerDbColumnNames(result)
|
|
4027
4064
|
);
|
|
4028
4065
|
if (outPath) {
|
|
4029
|
-
const exportedPath = (0,
|
|
4030
|
-
(0,
|
|
4066
|
+
const exportedPath = (0, import_node_path7.resolve)(outPath);
|
|
4067
|
+
(0, import_node_fs6.writeFileSync)(exportedPath, content, "utf-8");
|
|
4031
4068
|
printCommandEnvelope(
|
|
4032
4069
|
dbQueryExportEnvelope({
|
|
4033
4070
|
result,
|
|
@@ -4325,21 +4362,21 @@ Examples:
|
|
|
4325
4362
|
|
|
4326
4363
|
// src/cli/commands/play.ts
|
|
4327
4364
|
var import_node_crypto3 = require("crypto");
|
|
4328
|
-
var
|
|
4329
|
-
var
|
|
4365
|
+
var import_node_fs10 = require("fs");
|
|
4366
|
+
var import_node_path12 = require("path");
|
|
4330
4367
|
|
|
4331
4368
|
// src/plays/bundle-play-file.ts
|
|
4332
|
-
var
|
|
4333
|
-
var
|
|
4369
|
+
var import_node_os6 = require("os");
|
|
4370
|
+
var import_node_path10 = require("path");
|
|
4334
4371
|
var import_node_url = require("url");
|
|
4335
|
-
var
|
|
4372
|
+
var import_node_fs8 = require("fs");
|
|
4336
4373
|
|
|
4337
4374
|
// ../shared_libs/plays/bundling/index.ts
|
|
4338
4375
|
var import_node_crypto = require("crypto");
|
|
4339
|
-
var
|
|
4376
|
+
var import_node_fs7 = require("fs");
|
|
4340
4377
|
var import_promises3 = require("fs/promises");
|
|
4341
|
-
var
|
|
4342
|
-
var
|
|
4378
|
+
var import_node_os5 = require("os");
|
|
4379
|
+
var import_node_path8 = require("path");
|
|
4343
4380
|
var import_node_module = require("module");
|
|
4344
4381
|
var import_esbuild = require("esbuild");
|
|
4345
4382
|
|
|
@@ -4398,8 +4435,8 @@ function buildPlayContractCompatibility(input) {
|
|
|
4398
4435
|
var PLAY_BUNDLE_CACHE_VERSION = 24;
|
|
4399
4436
|
var MAX_PLAY_BUNDLE_BYTES = 30 * 1024 * 1024;
|
|
4400
4437
|
var MAX_ESM_WORKERS_BUNDLE_BYTES = 115e4;
|
|
4401
|
-
var PLAY_ARTIFACT_CACHE_DIR = (0,
|
|
4402
|
-
(0,
|
|
4438
|
+
var PLAY_ARTIFACT_CACHE_DIR = (0, import_node_path8.join)(
|
|
4439
|
+
(0, import_node_os5.tmpdir)(),
|
|
4403
4440
|
`deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION}`
|
|
4404
4441
|
);
|
|
4405
4442
|
var PLAY_PROXY_NAMESPACE = "deepline-play-runtime-ref";
|
|
@@ -4443,13 +4480,13 @@ async function normalizeLocalPath(filePath) {
|
|
|
4443
4480
|
try {
|
|
4444
4481
|
return await (0, import_promises3.realpath)(filePath);
|
|
4445
4482
|
} catch {
|
|
4446
|
-
return (0,
|
|
4483
|
+
return (0, import_node_path8.resolve)(filePath);
|
|
4447
4484
|
}
|
|
4448
4485
|
}
|
|
4449
4486
|
function createPlayWorkspace(entryFile) {
|
|
4450
4487
|
return {
|
|
4451
4488
|
entryFile,
|
|
4452
|
-
rootDir: (0,
|
|
4489
|
+
rootDir: (0, import_node_path8.dirname)(entryFile)
|
|
4453
4490
|
};
|
|
4454
4491
|
}
|
|
4455
4492
|
function isPathInsideDirectory(filePath, directory) {
|
|
@@ -4618,7 +4655,7 @@ function extractDefinedPlayName(sourceCode) {
|
|
|
4618
4655
|
}
|
|
4619
4656
|
function readPackageVersionFromPackageJson(packageJsonPath, packageName) {
|
|
4620
4657
|
try {
|
|
4621
|
-
const packageJson = JSON.parse((0,
|
|
4658
|
+
const packageJson = JSON.parse((0, import_node_fs7.readFileSync)(packageJsonPath, "utf-8"));
|
|
4622
4659
|
if (packageJson.name === packageName && typeof packageJson.version === "string") {
|
|
4623
4660
|
return packageJson.version;
|
|
4624
4661
|
}
|
|
@@ -4628,18 +4665,18 @@ function readPackageVersionFromPackageJson(packageJsonPath, packageName) {
|
|
|
4628
4665
|
return null;
|
|
4629
4666
|
}
|
|
4630
4667
|
function findPackageJsonPathFrom(startDir, packageName) {
|
|
4631
|
-
let current = (0,
|
|
4668
|
+
let current = (0, import_node_path8.resolve)(startDir);
|
|
4632
4669
|
while (true) {
|
|
4633
|
-
const packageJsonPath = (0,
|
|
4670
|
+
const packageJsonPath = (0, import_node_path8.join)(
|
|
4634
4671
|
current,
|
|
4635
4672
|
"node_modules",
|
|
4636
4673
|
packageName,
|
|
4637
4674
|
"package.json"
|
|
4638
4675
|
);
|
|
4639
|
-
if ((0,
|
|
4676
|
+
if ((0, import_node_fs7.existsSync)(packageJsonPath)) {
|
|
4640
4677
|
return packageJsonPath;
|
|
4641
4678
|
}
|
|
4642
|
-
const parent = (0,
|
|
4679
|
+
const parent = (0, import_node_path8.dirname)(current);
|
|
4643
4680
|
if (parent === current) {
|
|
4644
4681
|
return null;
|
|
4645
4682
|
}
|
|
@@ -4648,29 +4685,29 @@ function findPackageJsonPathFrom(startDir, packageName) {
|
|
|
4648
4685
|
}
|
|
4649
4686
|
function findPackageJsonPath(packageName, fromFile, adapter) {
|
|
4650
4687
|
const startDirs = [
|
|
4651
|
-
(0,
|
|
4688
|
+
(0, import_node_path8.dirname)(fromFile),
|
|
4652
4689
|
adapter.projectRoot,
|
|
4653
|
-
(0,
|
|
4690
|
+
(0, import_node_path8.dirname)(adapter.sdkPackageJson),
|
|
4654
4691
|
process.cwd()
|
|
4655
4692
|
];
|
|
4656
4693
|
const seen = /* @__PURE__ */ new Set();
|
|
4657
4694
|
for (const startDir of startDirs) {
|
|
4658
|
-
const normalized = (0,
|
|
4695
|
+
const normalized = (0, import_node_path8.resolve)(startDir);
|
|
4659
4696
|
if (seen.has(normalized)) continue;
|
|
4660
4697
|
seen.add(normalized);
|
|
4661
4698
|
const packageJsonPath = findPackageJsonPathFrom(normalized, packageName);
|
|
4662
4699
|
if (packageJsonPath) return packageJsonPath;
|
|
4663
4700
|
}
|
|
4664
|
-
const adapterNodeModulesPackageJson = (0,
|
|
4701
|
+
const adapterNodeModulesPackageJson = (0, import_node_path8.join)(
|
|
4665
4702
|
adapter.nodeModulesDir,
|
|
4666
4703
|
packageName,
|
|
4667
4704
|
"package.json"
|
|
4668
4705
|
);
|
|
4669
|
-
return (0,
|
|
4706
|
+
return (0, import_node_fs7.existsSync)(adapterNodeModulesPackageJson) ? adapterNodeModulesPackageJson : null;
|
|
4670
4707
|
}
|
|
4671
4708
|
function localSdkAliasPlugin(adapter, options) {
|
|
4672
4709
|
const entryFile = options?.workersRuntime ? adapter.sdkWorkersEntryFile : adapter.sdkEntryFile;
|
|
4673
|
-
if (!(0,
|
|
4710
|
+
if (!(0, import_node_fs7.existsSync)(entryFile)) {
|
|
4674
4711
|
return null;
|
|
4675
4712
|
}
|
|
4676
4713
|
return {
|
|
@@ -4680,7 +4717,7 @@ function localSdkAliasPlugin(adapter, options) {
|
|
|
4680
4717
|
path: entryFile
|
|
4681
4718
|
}));
|
|
4682
4719
|
buildContext.onResolve({ filter: /^deepline\/helpers$/ }, () => ({
|
|
4683
|
-
path: (0,
|
|
4720
|
+
path: (0, import_node_path8.join)(adapter.sdkSourceRoot, "helpers.ts")
|
|
4684
4721
|
}));
|
|
4685
4722
|
}
|
|
4686
4723
|
};
|
|
@@ -4713,7 +4750,7 @@ function workersNamedPlayEntryAliasPlugin(playFilePath, exportName) {
|
|
|
4713
4750
|
contents: `export { ${exportName} as default } from ${JSON.stringify(playFilePath)};
|
|
4714
4751
|
`,
|
|
4715
4752
|
loader: "ts",
|
|
4716
|
-
resolveDir: (0,
|
|
4753
|
+
resolveDir: (0, import_node_path8.dirname)(playFilePath)
|
|
4717
4754
|
})
|
|
4718
4755
|
);
|
|
4719
4756
|
}
|
|
@@ -4884,7 +4921,7 @@ function importedPlayProxyPlugin(importedPlayDependencies) {
|
|
|
4884
4921
|
return {
|
|
4885
4922
|
contents: buildImportedPlayProxyModule(dependency.playName),
|
|
4886
4923
|
loader: "ts",
|
|
4887
|
-
resolveDir: (0,
|
|
4924
|
+
resolveDir: (0, import_node_path8.dirname)(args.path)
|
|
4888
4925
|
};
|
|
4889
4926
|
}
|
|
4890
4927
|
);
|
|
@@ -4903,15 +4940,15 @@ async function resolveLocalImport(fromFile, specifier) {
|
|
|
4903
4940
|
if (specifier.startsWith("file:")) {
|
|
4904
4941
|
return normalizeLocalPath(new URL(specifier).pathname);
|
|
4905
4942
|
}
|
|
4906
|
-
const base = (0,
|
|
4943
|
+
const base = (0, import_node_path8.isAbsolute)(specifier) ? (0, import_node_path8.resolve)(specifier) : (0, import_node_path8.resolve)((0, import_node_path8.dirname)(fromFile), specifier);
|
|
4907
4944
|
const candidates = [base];
|
|
4908
|
-
const explicitExtension = (0,
|
|
4945
|
+
const explicitExtension = (0, import_node_path8.extname)(base).toLowerCase();
|
|
4909
4946
|
if (!explicitExtension) {
|
|
4910
4947
|
candidates.push(
|
|
4911
4948
|
...SOURCE_EXTENSIONS.map((extension) => `${base}${extension}`)
|
|
4912
4949
|
);
|
|
4913
4950
|
candidates.push(
|
|
4914
|
-
...SOURCE_EXTENSIONS.map((extension) => (0,
|
|
4951
|
+
...SOURCE_EXTENSIONS.map((extension) => (0, import_node_path8.join)(base, `index${extension}`))
|
|
4915
4952
|
);
|
|
4916
4953
|
} else if ([".js", ".jsx", ".mjs", ".cjs"].includes(explicitExtension)) {
|
|
4917
4954
|
const stem = base.slice(0, -explicitExtension.length);
|
|
@@ -4930,9 +4967,9 @@ async function resolveLocalImport(fromFile, specifier) {
|
|
|
4930
4967
|
}
|
|
4931
4968
|
function resolvePackageImport(specifier, fromFile, adapter) {
|
|
4932
4969
|
const packageName = getPackageName(specifier);
|
|
4933
|
-
if (packageName === "deepline" && (0,
|
|
4970
|
+
if (packageName === "deepline" && (0, import_node_fs7.existsSync)(adapter.sdkPackageJson)) {
|
|
4934
4971
|
const packageJson = JSON.parse(
|
|
4935
|
-
(0,
|
|
4972
|
+
(0, import_node_fs7.readFileSync)(adapter.sdkPackageJson, "utf-8")
|
|
4936
4973
|
);
|
|
4937
4974
|
return {
|
|
4938
4975
|
name: "deepline",
|
|
@@ -4964,7 +5001,7 @@ async function analyzeSourceGraph(entryFile, adapter) {
|
|
|
4964
5001
|
visited.add(absolutePath);
|
|
4965
5002
|
const sourceCode2 = await (0, import_promises3.readFile)(absolutePath, "utf-8");
|
|
4966
5003
|
localFiles.set(absolutePath, sourceCode2);
|
|
4967
|
-
if ((0,
|
|
5004
|
+
if ((0, import_node_path8.extname)(absolutePath).toLowerCase() === ".json") {
|
|
4968
5005
|
return;
|
|
4969
5006
|
}
|
|
4970
5007
|
const handleSpecifier = async (specifier, line, column, kind) => {
|
|
@@ -5079,7 +5116,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
|
|
|
5079
5116
|
const parts = [];
|
|
5080
5117
|
for (const name of tsFiles) {
|
|
5081
5118
|
const contents = await (0, import_promises3.readFile)(
|
|
5082
|
-
(0,
|
|
5119
|
+
(0, import_node_path8.join)(adapter.workersHarnessFilesDir, name),
|
|
5083
5120
|
"utf-8"
|
|
5084
5121
|
);
|
|
5085
5122
|
parts.push({ name, hash: sha256(contents) });
|
|
@@ -5087,7 +5124,7 @@ async function computeWorkersHarnessFingerprintWithAdapter(adapter) {
|
|
|
5087
5124
|
return sha256(JSON.stringify(parts));
|
|
5088
5125
|
}
|
|
5089
5126
|
function artifactCachePath(graphHash, artifactKind, adapter) {
|
|
5090
|
-
return (0,
|
|
5127
|
+
return (0, import_node_path8.join)(
|
|
5091
5128
|
adapter.cacheDir ?? PLAY_ARTIFACT_CACHE_DIR,
|
|
5092
5129
|
`${graphHash}.${artifactKind}.json`
|
|
5093
5130
|
);
|
|
@@ -5122,7 +5159,7 @@ function normalizeSourceMapForRuntime(sourceMapText) {
|
|
|
5122
5159
|
if (sourcePath.startsWith("data:") || sourcePath.startsWith("node:") || sourcePath.startsWith("/") || /^[a-zA-Z]+:\/\//.test(sourcePath)) {
|
|
5123
5160
|
return sourcePath;
|
|
5124
5161
|
}
|
|
5125
|
-
return (0,
|
|
5162
|
+
return (0, import_node_path8.resolve)(process.cwd(), sourcePath);
|
|
5126
5163
|
});
|
|
5127
5164
|
parsed.sourceRoot = void 0;
|
|
5128
5165
|
return JSON.stringify(parsed);
|
|
@@ -5154,8 +5191,8 @@ async function runEsbuildForCjsNode(entryFile, importedPlayDependencies, adapter
|
|
|
5154
5191
|
...namedExportShim ? {
|
|
5155
5192
|
stdin: {
|
|
5156
5193
|
contents: namedExportShim,
|
|
5157
|
-
resolveDir: (0,
|
|
5158
|
-
sourcefile: `${(0,
|
|
5194
|
+
resolveDir: (0, import_node_path8.dirname)(entryFile),
|
|
5195
|
+
sourcefile: `${(0, import_node_path8.basename)(entryFile)}.${exportName}.entry.ts`,
|
|
5159
5196
|
loader: "ts"
|
|
5160
5197
|
}
|
|
5161
5198
|
} : { entryPoints: [entryFile] },
|
|
@@ -5380,10 +5417,10 @@ workers-harness:${harnessFingerprint}`
|
|
|
5380
5417
|
}
|
|
5381
5418
|
const { bundledCode, sourceMapText, outputExtension } = buildOutcome;
|
|
5382
5419
|
const normalizedSourceMap = normalizeSourceMapForRuntime(sourceMapText);
|
|
5383
|
-
const virtualBaseName = exportName === "default" ? (0,
|
|
5420
|
+
const virtualBaseName = exportName === "default" ? (0, import_node_path8.basename)(absolutePath).replace(/\.[^.]+$/, "") : `${(0, import_node_path8.basename)(absolutePath).replace(/\.[^.]+$/, "")}.${exportName}`;
|
|
5384
5421
|
const virtualFilename = `/virtual/deepline-plays/${analysis.graphHash}/${virtualBaseName}.${outputExtension}`;
|
|
5385
5422
|
const executableCode = `${bundledCode}
|
|
5386
|
-
//# sourceMappingURL=${(0,
|
|
5423
|
+
//# sourceMappingURL=${(0, import_node_path8.basename)(virtualFilename)}.map
|
|
5387
5424
|
`;
|
|
5388
5425
|
const bundleSizeError = getBundleSizeError(
|
|
5389
5426
|
absolutePath,
|
|
@@ -5520,7 +5557,7 @@ function resolveExecutionProfile(override) {
|
|
|
5520
5557
|
// src/plays/local-file-discovery.ts
|
|
5521
5558
|
var import_node_crypto2 = require("crypto");
|
|
5522
5559
|
var import_promises4 = require("fs/promises");
|
|
5523
|
-
var
|
|
5560
|
+
var import_node_path9 = require("path");
|
|
5524
5561
|
var SOURCE_EXTENSIONS2 = [
|
|
5525
5562
|
".ts",
|
|
5526
5563
|
".tsx",
|
|
@@ -5536,7 +5573,7 @@ function sha2562(buffer) {
|
|
|
5536
5573
|
return (0, import_node_crypto2.createHash)("sha256").update(buffer).digest("hex");
|
|
5537
5574
|
}
|
|
5538
5575
|
function contentTypeForFile(filePath) {
|
|
5539
|
-
const extension = (0,
|
|
5576
|
+
const extension = (0, import_node_path9.extname)(filePath).toLowerCase();
|
|
5540
5577
|
if (extension === ".csv") return "text/csv";
|
|
5541
5578
|
if (extension === ".json") return "application/json";
|
|
5542
5579
|
if (extension === ".txt") return "text/plain";
|
|
@@ -5735,19 +5772,19 @@ async function fileExists2(filePath) {
|
|
|
5735
5772
|
}
|
|
5736
5773
|
}
|
|
5737
5774
|
function isPathInsideDirectory2(filePath, directory) {
|
|
5738
|
-
const relativePath = (0,
|
|
5739
|
-
return relativePath === "" || !relativePath.startsWith("..") && !(0,
|
|
5775
|
+
const relativePath = (0, import_node_path9.relative)(directory, filePath);
|
|
5776
|
+
return relativePath === "" || !relativePath.startsWith("..") && !(0, import_node_path9.isAbsolute)(relativePath);
|
|
5740
5777
|
}
|
|
5741
5778
|
async function resolveLocalImport2(fromFile, specifier) {
|
|
5742
|
-
const base = (0,
|
|
5779
|
+
const base = (0, import_node_path9.isAbsolute)(specifier) ? (0, import_node_path9.resolve)(specifier) : (0, import_node_path9.resolve)((0, import_node_path9.dirname)(fromFile), specifier);
|
|
5743
5780
|
const candidates = [base];
|
|
5744
|
-
const explicitExtension = (0,
|
|
5781
|
+
const explicitExtension = (0, import_node_path9.extname)(base).toLowerCase();
|
|
5745
5782
|
if (!explicitExtension) {
|
|
5746
5783
|
candidates.push(
|
|
5747
5784
|
...SOURCE_EXTENSIONS2.map((extension) => `${base}${extension}`)
|
|
5748
5785
|
);
|
|
5749
5786
|
candidates.push(
|
|
5750
|
-
...SOURCE_EXTENSIONS2.map((extension) => (0,
|
|
5787
|
+
...SOURCE_EXTENSIONS2.map((extension) => (0, import_node_path9.join)(base, `index${extension}`))
|
|
5751
5788
|
);
|
|
5752
5789
|
} else if ([".js", ".jsx", ".mjs", ".cjs"].includes(explicitExtension)) {
|
|
5753
5790
|
const stem = base.slice(0, -explicitExtension.length);
|
|
@@ -5765,13 +5802,13 @@ async function resolveLocalImport2(fromFile, specifier) {
|
|
|
5765
5802
|
);
|
|
5766
5803
|
}
|
|
5767
5804
|
async function discoverPackagedLocalFiles(entryFile) {
|
|
5768
|
-
const absoluteEntryFile = (0,
|
|
5769
|
-
const packagingRoot = (0,
|
|
5805
|
+
const absoluteEntryFile = (0, import_node_path9.resolve)(entryFile);
|
|
5806
|
+
const packagingRoot = (0, import_node_path9.dirname)(absoluteEntryFile);
|
|
5770
5807
|
const files = /* @__PURE__ */ new Map();
|
|
5771
5808
|
const unresolved = [];
|
|
5772
5809
|
const visitedFiles = /* @__PURE__ */ new Set();
|
|
5773
5810
|
const visitSourceFile = async (filePath) => {
|
|
5774
|
-
const absolutePath = (0,
|
|
5811
|
+
const absolutePath = (0, import_node_path9.resolve)(filePath);
|
|
5775
5812
|
if (visitedFiles.has(absolutePath)) {
|
|
5776
5813
|
return;
|
|
5777
5814
|
}
|
|
@@ -5808,8 +5845,8 @@ async function discoverPackagedLocalFiles(entryFile) {
|
|
|
5808
5845
|
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."
|
|
5809
5846
|
});
|
|
5810
5847
|
} else {
|
|
5811
|
-
const absoluteCsvPath = (0,
|
|
5812
|
-
if ((0,
|
|
5848
|
+
const absoluteCsvPath = (0, import_node_path9.resolve)((0, import_node_path9.dirname)(absolutePath), resolvedPath);
|
|
5849
|
+
if ((0, import_node_path9.isAbsolute)(resolvedPath) || !isPathInsideDirectory2(absoluteCsvPath, packagingRoot)) {
|
|
5813
5850
|
unresolved.push({
|
|
5814
5851
|
sourceFragment: sourceCode.slice(argument.start, argument.end).trim(),
|
|
5815
5852
|
message: "ctx.csv(...) packaged file paths must be relative paths inside the play directory. Pass external files at runtime with input.file instead."
|
|
@@ -5848,30 +5885,30 @@ async function discoverPackagedLocalFiles(entryFile) {
|
|
|
5848
5885
|
// src/plays/bundle-play-file.ts
|
|
5849
5886
|
var import_meta = {};
|
|
5850
5887
|
var PLAY_BUNDLE_CACHE_VERSION2 = 30;
|
|
5851
|
-
var MODULE_DIR = (0,
|
|
5852
|
-
var SDK_PACKAGE_ROOT = (0,
|
|
5853
|
-
var SOURCE_REPO_ROOT = (0,
|
|
5854
|
-
var HAS_SOURCE_BUNDLING_SOURCES = (0,
|
|
5855
|
-
(0,
|
|
5888
|
+
var MODULE_DIR = (0, import_node_path10.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
5889
|
+
var SDK_PACKAGE_ROOT = (0, import_node_path10.resolve)(MODULE_DIR, "..", "..");
|
|
5890
|
+
var SOURCE_REPO_ROOT = (0, import_node_path10.resolve)(SDK_PACKAGE_ROOT, "..");
|
|
5891
|
+
var HAS_SOURCE_BUNDLING_SOURCES = (0, import_node_fs8.existsSync)(
|
|
5892
|
+
(0, import_node_path10.resolve)(SOURCE_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
|
|
5856
5893
|
);
|
|
5857
|
-
var PACKAGED_REPO_ROOT = (0,
|
|
5858
|
-
var HAS_PACKAGED_BUNDLING_SOURCES = (0,
|
|
5859
|
-
(0,
|
|
5894
|
+
var PACKAGED_REPO_ROOT = (0, import_node_path10.resolve)(SDK_PACKAGE_ROOT, "dist", "repo");
|
|
5895
|
+
var HAS_PACKAGED_BUNDLING_SOURCES = (0, import_node_fs8.existsSync)(
|
|
5896
|
+
(0, import_node_path10.resolve)(PACKAGED_REPO_ROOT, "apps", "play-runner-workers", "src", "entry.ts")
|
|
5860
5897
|
);
|
|
5861
|
-
var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_REPO_ROOT : (0,
|
|
5862
|
-
var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? (0,
|
|
5863
|
-
var SDK_PACKAGE_JSON = (0,
|
|
5864
|
-
var SDK_ENTRY_FILE = (0,
|
|
5865
|
-
var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : (0,
|
|
5866
|
-
var SDK_WORKERS_ENTRY_FILE = (0,
|
|
5867
|
-
var WORKERS_HARNESS_ENTRY_FILE = (0,
|
|
5898
|
+
var PROJECT_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? SOURCE_REPO_ROOT : HAS_PACKAGED_BUNDLING_SOURCES ? PACKAGED_REPO_ROOT : (0, import_node_path10.resolve)(SDK_PACKAGE_ROOT, "..");
|
|
5899
|
+
var SDK_SOURCE_ROOT = HAS_SOURCE_BUNDLING_SOURCES ? (0, import_node_path10.resolve)(SOURCE_REPO_ROOT, "sdk", "src") : HAS_PACKAGED_BUNDLING_SOURCES ? (0, import_node_path10.resolve)(PACKAGED_REPO_ROOT, "sdk", "src") : (0, import_node_path10.resolve)(SDK_PACKAGE_ROOT, "src");
|
|
5900
|
+
var SDK_PACKAGE_JSON = (0, import_node_path10.resolve)(SDK_PACKAGE_ROOT, "package.json");
|
|
5901
|
+
var SDK_ENTRY_FILE = (0, import_node_path10.resolve)(SDK_SOURCE_ROOT, "index.ts");
|
|
5902
|
+
var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : (0, import_node_path10.resolve)(SDK_PACKAGE_ROOT, "dist", "index.d.ts");
|
|
5903
|
+
var SDK_WORKERS_ENTRY_FILE = (0, import_node_path10.resolve)(SDK_SOURCE_ROOT, "worker-play-entry.ts");
|
|
5904
|
+
var WORKERS_HARNESS_ENTRY_FILE = (0, import_node_path10.resolve)(
|
|
5868
5905
|
PROJECT_ROOT,
|
|
5869
5906
|
"apps",
|
|
5870
5907
|
"play-runner-workers",
|
|
5871
5908
|
"src",
|
|
5872
5909
|
"entry.ts"
|
|
5873
5910
|
);
|
|
5874
|
-
var WORKERS_HARNESS_FILES_DIR = (0,
|
|
5911
|
+
var WORKERS_HARNESS_FILES_DIR = (0, import_node_path10.resolve)(
|
|
5875
5912
|
PROJECT_ROOT,
|
|
5876
5913
|
"apps",
|
|
5877
5914
|
"play-runner-workers",
|
|
@@ -5900,15 +5937,15 @@ function defaultPlayBundleTarget() {
|
|
|
5900
5937
|
function createSdkPlayBundlingAdapter() {
|
|
5901
5938
|
return {
|
|
5902
5939
|
projectRoot: PROJECT_ROOT,
|
|
5903
|
-
nodeModulesDir: (0,
|
|
5904
|
-
cacheDir: (0,
|
|
5905
|
-
(0,
|
|
5940
|
+
nodeModulesDir: (0, import_node_path10.resolve)(PROJECT_ROOT, "node_modules"),
|
|
5941
|
+
cacheDir: (0, import_node_path10.join)(
|
|
5942
|
+
(0, import_node_os6.tmpdir)(),
|
|
5906
5943
|
`deepline-play-artifacts-v${PLAY_BUNDLE_CACHE_VERSION2}`
|
|
5907
5944
|
),
|
|
5908
5945
|
sdkSourceRoot: SDK_SOURCE_ROOT,
|
|
5909
5946
|
sdkPackageJson: SDK_PACKAGE_JSON,
|
|
5910
5947
|
sdkEntryFile: SDK_ENTRY_FILE,
|
|
5911
|
-
sdkTypesEntryFile: HAS_SOURCE_BUNDLING_SOURCES || !(0,
|
|
5948
|
+
sdkTypesEntryFile: HAS_SOURCE_BUNDLING_SOURCES || !(0, import_node_fs8.existsSync)(SDK_TYPES_ENTRY_FILE) ? SDK_ENTRY_FILE : SDK_TYPES_ENTRY_FILE,
|
|
5912
5949
|
sdkWorkersEntryFile: SDK_WORKERS_ENTRY_FILE,
|
|
5913
5950
|
workersHarnessEntryFile: WORKERS_HARNESS_ENTRY_FILE,
|
|
5914
5951
|
workersHarnessFilesDir: WORKERS_HARNESS_FILES_DIR,
|
|
@@ -5925,8 +5962,8 @@ async function bundlePlayFile2(filePath, options = {}) {
|
|
|
5925
5962
|
}
|
|
5926
5963
|
|
|
5927
5964
|
// src/cli/commands/plays/bootstrap.ts
|
|
5928
|
-
var
|
|
5929
|
-
var
|
|
5965
|
+
var import_node_fs9 = require("fs");
|
|
5966
|
+
var import_node_path11 = require("path");
|
|
5930
5967
|
var import_sync4 = require("csv-parse/sync");
|
|
5931
5968
|
|
|
5932
5969
|
// ../shared_libs/plays/bootstrap-routes.ts
|
|
@@ -6347,13 +6384,13 @@ function inferCsvColumnSpecs(headers, rows) {
|
|
|
6347
6384
|
}));
|
|
6348
6385
|
}
|
|
6349
6386
|
function readCsvSample(csvPath) {
|
|
6350
|
-
const resolvedPath = (0,
|
|
6351
|
-
const size = (0,
|
|
6352
|
-
const fd = (0,
|
|
6387
|
+
const resolvedPath = (0, import_node_path11.resolve)(csvPath);
|
|
6388
|
+
const size = (0, import_node_fs9.statSync)(resolvedPath).size;
|
|
6389
|
+
const fd = (0, import_node_fs9.openSync)(resolvedPath, "r");
|
|
6353
6390
|
const byteLength = Math.min(size, CSV_HEADER_SAMPLE_BYTES);
|
|
6354
6391
|
const buffer = Buffer.alloc(byteLength);
|
|
6355
|
-
const bytesRead = (0,
|
|
6356
|
-
(0,
|
|
6392
|
+
const bytesRead = (0, import_node_fs9.readSync)(fd, buffer, 0, byteLength, 0);
|
|
6393
|
+
(0, import_node_fs9.closeSync)(fd);
|
|
6357
6394
|
if (bytesRead === 0) {
|
|
6358
6395
|
throw new PlayBootstrapUsageError(`--from csv:${csvPath} is empty.`);
|
|
6359
6396
|
}
|
|
@@ -6422,9 +6459,9 @@ ${properties}
|
|
|
6422
6459
|
}
|
|
6423
6460
|
function packagedCsvPathForPlay(csvPath) {
|
|
6424
6461
|
const playDir = process.cwd();
|
|
6425
|
-
const absoluteCsvPath = (0,
|
|
6426
|
-
const relativePath = (0,
|
|
6427
|
-
if (relativePath === "" || relativePath.startsWith("..") || (0,
|
|
6462
|
+
const absoluteCsvPath = (0, import_node_path11.resolve)(csvPath);
|
|
6463
|
+
const relativePath = (0, import_node_path11.relative)(playDir, absoluteCsvPath);
|
|
6464
|
+
if (relativePath === "" || relativePath.startsWith("..") || (0, import_node_path11.isAbsolute)(relativePath)) {
|
|
6428
6465
|
throw new PlayBootstrapUsageError(
|
|
6429
6466
|
`--from csv:${csvPath} must point to a file inside the directory where you run plays bootstrap. Run bootstrap from the intended play directory, then redirect stdout to a .play.ts file there.`
|
|
6430
6467
|
);
|
|
@@ -7856,7 +7893,7 @@ function formatPlayListReference(play) {
|
|
|
7856
7893
|
return play.reference || play.name;
|
|
7857
7894
|
}
|
|
7858
7895
|
function defaultMaterializedPlayPath(reference) {
|
|
7859
|
-
return (0,
|
|
7896
|
+
return (0, import_node_path12.resolve)(defaultStarterPlayPath(reference));
|
|
7860
7897
|
}
|
|
7861
7898
|
function defaultStarterPlayPath(reference) {
|
|
7862
7899
|
const playName = parseReferencedPlayTarget2(reference).unqualifiedPlayName;
|
|
@@ -7882,15 +7919,15 @@ function materializeRemotePlaySource(input) {
|
|
|
7882
7919
|
return null;
|
|
7883
7920
|
}
|
|
7884
7921
|
const outputPath = input.outPath ?? defaultMaterializedPlayPath(input.playName);
|
|
7885
|
-
if ((0,
|
|
7886
|
-
const existingSource = (0,
|
|
7922
|
+
if ((0, import_node_fs10.existsSync)(outputPath)) {
|
|
7923
|
+
const existingSource = (0, import_node_fs10.readFileSync)(outputPath, "utf-8");
|
|
7887
7924
|
if (existingSource === input.sourceCode) {
|
|
7888
7925
|
return { path: outputPath, status: "unchanged", created: false };
|
|
7889
7926
|
}
|
|
7890
|
-
(0,
|
|
7927
|
+
(0, import_node_fs10.writeFileSync)(outputPath, input.sourceCode, "utf-8");
|
|
7891
7928
|
return { path: outputPath, status: "updated", created: false };
|
|
7892
7929
|
}
|
|
7893
|
-
(0,
|
|
7930
|
+
(0, import_node_fs10.writeFileSync)(outputPath, input.sourceCode, "utf-8");
|
|
7894
7931
|
return { path: outputPath, status: "created", created: true };
|
|
7895
7932
|
}
|
|
7896
7933
|
function formatLoadedPlayMessage(materializedFile) {
|
|
@@ -7935,7 +7972,7 @@ function extractPlayName(code, filePath) {
|
|
|
7935
7972
|
throw buildMissingDefinePlayError(filePath);
|
|
7936
7973
|
}
|
|
7937
7974
|
function isFileTarget(target) {
|
|
7938
|
-
return (0,
|
|
7975
|
+
return (0, import_node_fs10.existsSync)((0, import_node_path12.resolve)(target));
|
|
7939
7976
|
}
|
|
7940
7977
|
function looksLikeRunId(target) {
|
|
7941
7978
|
return /^play\/[^/]+\/run\/[^/]+/.test(target.trim());
|
|
@@ -7964,7 +8001,7 @@ function parsePositiveInteger3(value, flagName) {
|
|
|
7964
8001
|
return parsed;
|
|
7965
8002
|
}
|
|
7966
8003
|
function parseJsonInput(raw) {
|
|
7967
|
-
const source = raw.startsWith("@") ? (0,
|
|
8004
|
+
const source = raw.startsWith("@") ? (0, import_node_fs10.readFileSync)((0, import_node_path12.resolve)(raw.slice(1)), "utf-8") : raw;
|
|
7968
8005
|
const parsed = JSON.parse(source);
|
|
7969
8006
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
7970
8007
|
throw new Error("--input must be a JSON object.");
|
|
@@ -8066,7 +8103,7 @@ function fileInputBindingsFromStaticPipeline(staticPipeline) {
|
|
|
8066
8103
|
function isLocalFilePathValue(value) {
|
|
8067
8104
|
if (typeof value !== "string" || !value.trim()) return false;
|
|
8068
8105
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value.trim())) return false;
|
|
8069
|
-
return (0,
|
|
8106
|
+
return (0, import_node_fs10.existsSync)((0, import_node_path12.resolve)(value));
|
|
8070
8107
|
}
|
|
8071
8108
|
function inputContainsLocalFilePath(value) {
|
|
8072
8109
|
if (isLocalFilePathValue(value)) {
|
|
@@ -8094,8 +8131,8 @@ async function stageFileInputArgs(input) {
|
|
|
8094
8131
|
const localFiles = uniqueBindings.flatMap((binding) => {
|
|
8095
8132
|
const value = getDottedInputValue(input.runtimeInput, binding.inputPath);
|
|
8096
8133
|
if (!isLocalFilePathValue(value)) return [];
|
|
8097
|
-
const absolutePath = (0,
|
|
8098
|
-
return [{ binding, absolutePath, logicalPath: (0,
|
|
8134
|
+
const absolutePath = (0, import_node_path12.resolve)(value);
|
|
8135
|
+
return [{ binding, absolutePath, logicalPath: (0, import_node_path12.basename)(absolutePath) }];
|
|
8099
8136
|
});
|
|
8100
8137
|
if (localFiles.length === 0) {
|
|
8101
8138
|
return { inputFile: null, packagedFiles: [] };
|
|
@@ -8127,7 +8164,7 @@ async function stageFileInputArgs(input) {
|
|
|
8127
8164
|
};
|
|
8128
8165
|
}
|
|
8129
8166
|
function stageFile(logicalPath, absolutePath) {
|
|
8130
|
-
const buffer = (0,
|
|
8167
|
+
const buffer = (0, import_node_fs10.readFileSync)(absolutePath);
|
|
8131
8168
|
return {
|
|
8132
8169
|
logicalPath,
|
|
8133
8170
|
contentBase64: buffer.toString("base64"),
|
|
@@ -8138,9 +8175,9 @@ function stageFile(logicalPath, absolutePath) {
|
|
|
8138
8175
|
}
|
|
8139
8176
|
function normalizePlayPath(filePath) {
|
|
8140
8177
|
try {
|
|
8141
|
-
return
|
|
8178
|
+
return import_node_fs10.realpathSync.native((0, import_node_path12.resolve)(filePath));
|
|
8142
8179
|
} catch {
|
|
8143
|
-
return (0,
|
|
8180
|
+
return (0, import_node_path12.resolve)(filePath);
|
|
8144
8181
|
}
|
|
8145
8182
|
}
|
|
8146
8183
|
function formatBundlingErrors(filePath, errors) {
|
|
@@ -9686,7 +9723,7 @@ function sqlStringLiteral(value) {
|
|
|
9686
9723
|
return `'${value.replace(/'/g, "''")}'`;
|
|
9687
9724
|
}
|
|
9688
9725
|
function runExportRetryCommand(runId, outPath, datasetPath) {
|
|
9689
|
-
return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0,
|
|
9726
|
+
return `deepline runs export ${runId}${datasetPath ? ` --dataset ${shellSingleQuote(datasetPath)}` : ""} --out ${shellSingleQuote((0, import_node_path12.resolve)(outPath))}`;
|
|
9690
9727
|
}
|
|
9691
9728
|
function extractRunPlayName(status) {
|
|
9692
9729
|
const run = status.run;
|
|
@@ -9720,7 +9757,7 @@ function buildCustomerDbQueryPlan(input) {
|
|
|
9720
9757
|
return {
|
|
9721
9758
|
sql,
|
|
9722
9759
|
json: `${base} --json`,
|
|
9723
|
-
csv: `${base} --format csv --out ${shellSingleQuote((0,
|
|
9760
|
+
csv: `${base} --format csv --out ${shellSingleQuote((0, import_node_path12.resolve)(input.outPath))}`
|
|
9724
9761
|
};
|
|
9725
9762
|
}
|
|
9726
9763
|
function exportableSheetRow(row) {
|
|
@@ -10358,12 +10395,12 @@ function printToolGetterHints(hints) {
|
|
|
10358
10395
|
async function handlePlayCheck(args) {
|
|
10359
10396
|
const options = parsePlayCheckOptions(args);
|
|
10360
10397
|
if (!isFileTarget(options.target)) {
|
|
10361
|
-
const resolved = (0,
|
|
10398
|
+
const resolved = (0, import_node_path12.resolve)(options.target);
|
|
10362
10399
|
console.error(`File not found: ${resolved}`);
|
|
10363
10400
|
return 1;
|
|
10364
10401
|
}
|
|
10365
|
-
const absolutePlayPath = (0,
|
|
10366
|
-
const sourceCode = (0,
|
|
10402
|
+
const absolutePlayPath = (0, import_node_path12.resolve)(options.target);
|
|
10403
|
+
const sourceCode = (0, import_node_fs10.readFileSync)(absolutePlayPath, "utf-8");
|
|
10367
10404
|
let graph;
|
|
10368
10405
|
try {
|
|
10369
10406
|
graph = await collectBundledPlayGraph(absolutePlayPath);
|
|
@@ -10442,12 +10479,12 @@ async function handleFileBackedRun(options) {
|
|
|
10442
10479
|
}
|
|
10443
10480
|
const client = new DeeplineClient();
|
|
10444
10481
|
const progress = getActiveCliProgress() ?? createCliProgress(!options.jsonOutput);
|
|
10445
|
-
const absolutePlayPath = (0,
|
|
10482
|
+
const absolutePlayPath = (0, import_node_path12.resolve)(options.target.path);
|
|
10446
10483
|
progress.phase("compiling play");
|
|
10447
10484
|
const sourceCode = traceCliSync(
|
|
10448
10485
|
"cli.play_file_read_source",
|
|
10449
10486
|
{ targetKind: "file" },
|
|
10450
|
-
() => (0,
|
|
10487
|
+
() => (0, import_node_fs10.readFileSync)(absolutePlayPath, "utf-8")
|
|
10451
10488
|
);
|
|
10452
10489
|
const runtimeInput = options.input ? { ...options.input } : {};
|
|
10453
10490
|
let graph;
|
|
@@ -10731,19 +10768,19 @@ async function handlePlayRun(args) {
|
|
|
10731
10768
|
if (isFileTarget(options.target.path)) {
|
|
10732
10769
|
return handleFileBackedRun(options);
|
|
10733
10770
|
}
|
|
10734
|
-
const resolved = (0,
|
|
10771
|
+
const resolved = (0, import_node_path12.resolve)(options.target.path);
|
|
10735
10772
|
console.error(`File not found: ${resolved}`);
|
|
10736
|
-
const dir = (0,
|
|
10737
|
-
if ((0,
|
|
10738
|
-
const base = (0,
|
|
10773
|
+
const dir = (0, import_node_path12.dirname)(resolved);
|
|
10774
|
+
if ((0, import_node_fs10.existsSync)(dir)) {
|
|
10775
|
+
const base = (0, import_node_path12.basename)(resolved);
|
|
10739
10776
|
try {
|
|
10740
|
-
const siblings = (0,
|
|
10777
|
+
const siblings = (0, import_node_fs10.readdirSync)(dir).filter(
|
|
10741
10778
|
(f) => f.includes(base.replace(/\.(play\.)?ts$/, "")) || f.endsWith(".play.ts")
|
|
10742
10779
|
);
|
|
10743
10780
|
if (siblings.length > 0) {
|
|
10744
10781
|
console.error(`Did you mean one of these?`);
|
|
10745
10782
|
for (const s of siblings.slice(0, 5)) {
|
|
10746
|
-
console.error(` ${(0,
|
|
10783
|
+
console.error(` ${(0, import_node_path12.join)(dir, s)}`);
|
|
10747
10784
|
}
|
|
10748
10785
|
}
|
|
10749
10786
|
} catch {
|
|
@@ -10887,14 +10924,14 @@ async function handleRunLogs(args) {
|
|
|
10887
10924
|
continue;
|
|
10888
10925
|
}
|
|
10889
10926
|
if (arg === "--out" && args[index + 1]) {
|
|
10890
|
-
outPath = (0,
|
|
10927
|
+
outPath = (0, import_node_path12.resolve)(args[++index]);
|
|
10891
10928
|
}
|
|
10892
10929
|
}
|
|
10893
10930
|
const client = new DeeplineClient();
|
|
10894
10931
|
const status = await client.runs.get(runId);
|
|
10895
10932
|
const logs = status.progress?.logs ?? [];
|
|
10896
10933
|
if (outPath) {
|
|
10897
|
-
(0,
|
|
10934
|
+
(0, import_node_fs10.writeFileSync)(outPath, `${logs.join("\n")}${logs.length > 0 ? "\n" : ""}`);
|
|
10898
10935
|
printCommandEnvelope(
|
|
10899
10936
|
{
|
|
10900
10937
|
runId: status.runId,
|
|
@@ -10983,7 +11020,7 @@ async function handleRunExport(args) {
|
|
|
10983
11020
|
for (let index = 0; index < args.length; index += 1) {
|
|
10984
11021
|
const arg = args[index];
|
|
10985
11022
|
if (arg === "--out" && args[index + 1]) {
|
|
10986
|
-
outPath = (0,
|
|
11023
|
+
outPath = (0, import_node_path12.resolve)(args[++index]);
|
|
10987
11024
|
continue;
|
|
10988
11025
|
}
|
|
10989
11026
|
if (arg === "--dataset" && args[index + 1]) {
|
|
@@ -10991,7 +11028,7 @@ async function handleRunExport(args) {
|
|
|
10991
11028
|
continue;
|
|
10992
11029
|
}
|
|
10993
11030
|
if (arg === "--metadata-out" && args[index + 1]) {
|
|
10994
|
-
metadataOutPath = (0,
|
|
11031
|
+
metadataOutPath = (0, import_node_path12.resolve)(args[++index]);
|
|
10995
11032
|
}
|
|
10996
11033
|
}
|
|
10997
11034
|
if (!outPath) {
|
|
@@ -11048,7 +11085,7 @@ async function handleRunExport(args) {
|
|
|
11048
11085
|
}
|
|
11049
11086
|
};
|
|
11050
11087
|
if (metadataOutPath) {
|
|
11051
|
-
(0,
|
|
11088
|
+
(0, import_node_fs10.writeFileSync)(
|
|
11052
11089
|
metadataOutPath,
|
|
11053
11090
|
`${JSON.stringify(payload, null, 2)}
|
|
11054
11091
|
`,
|
|
@@ -11078,10 +11115,10 @@ async function handlePlayGet(args) {
|
|
|
11078
11115
|
for (let index = 1; index < args.length; index += 1) {
|
|
11079
11116
|
const arg = args[index];
|
|
11080
11117
|
if (arg === "--out" && args[index + 1]) {
|
|
11081
|
-
outPath = (0,
|
|
11118
|
+
outPath = (0, import_node_path12.resolve)(args[++index]);
|
|
11082
11119
|
}
|
|
11083
11120
|
}
|
|
11084
|
-
const playName = isFileTarget(target) ? extractPlayName((0,
|
|
11121
|
+
const playName = isFileTarget(target) ? extractPlayName((0, import_node_fs10.readFileSync)((0, import_node_path12.resolve)(target), "utf-8"), (0, import_node_path12.resolve)(target)) : parseReferencedPlayTarget2(target).playName;
|
|
11085
11122
|
const detail = isFileTarget(target) ? await client.getPlay(playName) : await assertCanonicalNamedPlayReference(client, target);
|
|
11086
11123
|
const resolvedSource = detail.play.workingRevision?.sourceCode ?? detail.play.liveRevision?.sourceCode ?? detail.play.currentRevision?.sourceCode ?? detail.play.sourceCode ?? "";
|
|
11087
11124
|
const materializedFile = outPath ? materializeRemotePlaySource({
|
|
@@ -11507,7 +11544,7 @@ async function handlePlayPublish(args) {
|
|
|
11507
11544
|
}
|
|
11508
11545
|
let graph;
|
|
11509
11546
|
try {
|
|
11510
|
-
graph = await collectBundledPlayGraph((0,
|
|
11547
|
+
graph = await collectBundledPlayGraph((0, import_node_path12.resolve)(playName));
|
|
11511
11548
|
await compileBundledPlayGraphManifests(client, graph);
|
|
11512
11549
|
await publishImportedPlayDependencies(client, graph);
|
|
11513
11550
|
} catch (error) {
|
|
@@ -12063,14 +12100,14 @@ Examples:
|
|
|
12063
12100
|
|
|
12064
12101
|
// src/cli/commands/tools.ts
|
|
12065
12102
|
var import_commander2 = require("commander");
|
|
12103
|
+
var import_node_fs12 = require("fs");
|
|
12104
|
+
var import_node_os8 = require("os");
|
|
12105
|
+
var import_node_path14 = require("path");
|
|
12106
|
+
|
|
12107
|
+
// src/tool-output.ts
|
|
12066
12108
|
var import_node_fs11 = require("fs");
|
|
12067
12109
|
var import_node_os7 = require("os");
|
|
12068
12110
|
var import_node_path13 = require("path");
|
|
12069
|
-
|
|
12070
|
-
// src/tool-output.ts
|
|
12071
|
-
var import_node_fs10 = require("fs");
|
|
12072
|
-
var import_node_os6 = require("os");
|
|
12073
|
-
var import_node_path12 = require("path");
|
|
12074
12111
|
function isPlainObject(value) {
|
|
12075
12112
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
12076
12113
|
}
|
|
@@ -12166,19 +12203,19 @@ function tryConvertToList(payload, options) {
|
|
|
12166
12203
|
return null;
|
|
12167
12204
|
}
|
|
12168
12205
|
function ensureOutputDir() {
|
|
12169
|
-
const outputDir = (0,
|
|
12170
|
-
(0,
|
|
12206
|
+
const outputDir = (0, import_node_path13.join)((0, import_node_os7.homedir)(), ".local", "share", "deepline", "data");
|
|
12207
|
+
(0, import_node_fs11.mkdirSync)(outputDir, { recursive: true });
|
|
12171
12208
|
return outputDir;
|
|
12172
12209
|
}
|
|
12173
12210
|
function writeJsonOutputFile(payload, stem) {
|
|
12174
12211
|
const outputDir = ensureOutputDir();
|
|
12175
|
-
const outputPath = (0,
|
|
12176
|
-
(0,
|
|
12212
|
+
const outputPath = (0, import_node_path13.join)(outputDir, `${stem}_${Date.now()}.json`);
|
|
12213
|
+
(0, import_node_fs11.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
12177
12214
|
return outputPath;
|
|
12178
12215
|
}
|
|
12179
12216
|
function writeCsvOutputFile(rows, stem) {
|
|
12180
12217
|
const outputDir = ensureOutputDir();
|
|
12181
|
-
const outputPath = (0,
|
|
12218
|
+
const outputPath = (0, import_node_path13.join)(outputDir, `${stem}_${Date.now()}.csv`);
|
|
12182
12219
|
const seen = /* @__PURE__ */ new Set();
|
|
12183
12220
|
const columns = [];
|
|
12184
12221
|
for (const row of rows) {
|
|
@@ -12201,7 +12238,7 @@ function writeCsvOutputFile(rows, stem) {
|
|
|
12201
12238
|
for (const row of rows) {
|
|
12202
12239
|
lines.push(columns.map((column) => escapeCell(row[column])).join(","));
|
|
12203
12240
|
}
|
|
12204
|
-
(0,
|
|
12241
|
+
(0, import_node_fs11.writeFileSync)(outputPath, `${lines.join("\n")}
|
|
12205
12242
|
`, "utf-8");
|
|
12206
12243
|
const previewRows = rows.slice(0, 5);
|
|
12207
12244
|
const previewColumns = columns.slice(0, 5);
|
|
@@ -13269,9 +13306,9 @@ function powerShellQuote(value) {
|
|
|
13269
13306
|
function seedToolListScript(input) {
|
|
13270
13307
|
const stem = safeFileStem(input.toolId);
|
|
13271
13308
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
13272
|
-
const scriptDir = (0,
|
|
13273
|
-
(0,
|
|
13274
|
-
const scriptPath = (0,
|
|
13309
|
+
const scriptDir = (0, import_node_fs12.mkdtempSync)((0, import_node_path14.join)((0, import_node_os8.tmpdir)(), "deepline-workflow-seed-"));
|
|
13310
|
+
(0, import_node_fs12.chmodSync)(scriptDir, 448);
|
|
13311
|
+
const scriptPath = (0, import_node_path14.join)(scriptDir, fileName);
|
|
13275
13312
|
const projectDir = `deepline/projects/${stem}-workflow`;
|
|
13276
13313
|
const playName = `${stem}-workflow`;
|
|
13277
13314
|
const sampleRows = input.rows.length > 0 ? `${JSON.stringify(input.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
|
|
@@ -13307,7 +13344,7 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
|
|
|
13307
13344
|
};
|
|
13308
13345
|
});
|
|
13309
13346
|
`;
|
|
13310
|
-
(0,
|
|
13347
|
+
(0, import_node_fs12.writeFileSync)(scriptPath, script, { encoding: "utf-8", mode: 384 });
|
|
13311
13348
|
return {
|
|
13312
13349
|
path: scriptPath,
|
|
13313
13350
|
sourceCode: script,
|
|
@@ -13562,8 +13599,8 @@ async function executeTool(args) {
|
|
|
13562
13599
|
|
|
13563
13600
|
// src/cli/commands/update.ts
|
|
13564
13601
|
var import_node_child_process = require("child_process");
|
|
13565
|
-
var
|
|
13566
|
-
var
|
|
13602
|
+
var import_node_fs13 = require("fs");
|
|
13603
|
+
var import_node_path15 = require("path");
|
|
13567
13604
|
function posixShellQuote(value) {
|
|
13568
13605
|
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
13569
13606
|
}
|
|
@@ -13582,19 +13619,19 @@ function buildSourceUpdateCommand(sourceRoot) {
|
|
|
13582
13619
|
return `${cdCommand} && git fetch origin main --tags && git merge --ff-only origin/main`;
|
|
13583
13620
|
}
|
|
13584
13621
|
function findRepoBackedSdkRoot(startPath) {
|
|
13585
|
-
let current = (0,
|
|
13622
|
+
let current = (0, import_node_path15.resolve)(startPath);
|
|
13586
13623
|
while (true) {
|
|
13587
|
-
if ((0,
|
|
13624
|
+
if ((0, import_node_fs13.existsSync)((0, import_node_path15.join)(current, "sdk", "package.json")) && (0, import_node_fs13.existsSync)((0, import_node_path15.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
|
|
13588
13625
|
return current;
|
|
13589
13626
|
}
|
|
13590
|
-
const parent = (0,
|
|
13627
|
+
const parent = (0, import_node_path15.dirname)(current);
|
|
13591
13628
|
if (parent === current) return null;
|
|
13592
13629
|
current = parent;
|
|
13593
13630
|
}
|
|
13594
13631
|
}
|
|
13595
13632
|
function resolveUpdatePlan() {
|
|
13596
|
-
const entrypoint = process.argv[1] ? (0,
|
|
13597
|
-
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0,
|
|
13633
|
+
const entrypoint = process.argv[1] ? (0, import_node_path15.resolve)(process.argv[1]) : "";
|
|
13634
|
+
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path15.dirname)(entrypoint)) : null;
|
|
13598
13635
|
if (sourceRoot) {
|
|
13599
13636
|
return {
|
|
13600
13637
|
kind: "source",
|
|
@@ -13689,9 +13726,9 @@ Examples:
|
|
|
13689
13726
|
|
|
13690
13727
|
// src/cli/skills-sync.ts
|
|
13691
13728
|
var import_node_child_process2 = require("child_process");
|
|
13692
|
-
var
|
|
13693
|
-
var
|
|
13694
|
-
var
|
|
13729
|
+
var import_node_fs14 = require("fs");
|
|
13730
|
+
var import_node_os9 = require("os");
|
|
13731
|
+
var import_node_path16 = require("path");
|
|
13695
13732
|
var CHECK_TIMEOUT_MS2 = 3e3;
|
|
13696
13733
|
var SDK_SKILL_NAME = "deepline-sdk";
|
|
13697
13734
|
var SKILL_AGENTS = ["codex", "claude-code", "cursor"];
|
|
@@ -13701,8 +13738,8 @@ function shouldSkipSkillsSync() {
|
|
|
13701
13738
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
13702
13739
|
}
|
|
13703
13740
|
function sdkSkillsVersionPath(baseUrl) {
|
|
13704
|
-
const home = process.env.HOME?.trim() || (0,
|
|
13705
|
-
return (0,
|
|
13741
|
+
const home = process.env.HOME?.trim() || (0, import_node_os9.homedir)();
|
|
13742
|
+
return (0, import_node_path16.join)(
|
|
13706
13743
|
home,
|
|
13707
13744
|
".local",
|
|
13708
13745
|
"deepline",
|
|
@@ -13713,24 +13750,24 @@ function sdkSkillsVersionPath(baseUrl) {
|
|
|
13713
13750
|
}
|
|
13714
13751
|
function readLocalSkillsVersion(baseUrl) {
|
|
13715
13752
|
const path = sdkSkillsVersionPath(baseUrl);
|
|
13716
|
-
if (!(0,
|
|
13753
|
+
if (!(0, import_node_fs14.existsSync)(path)) return "";
|
|
13717
13754
|
try {
|
|
13718
|
-
return (0,
|
|
13755
|
+
return (0, import_node_fs14.readFileSync)(path, "utf-8").trim();
|
|
13719
13756
|
} catch {
|
|
13720
13757
|
return "";
|
|
13721
13758
|
}
|
|
13722
13759
|
}
|
|
13723
13760
|
function writeLocalSkillsVersion(baseUrl, version) {
|
|
13724
13761
|
const path = sdkSkillsVersionPath(baseUrl);
|
|
13725
|
-
(0,
|
|
13726
|
-
(0,
|
|
13762
|
+
(0, import_node_fs14.mkdirSync)((0, import_node_path16.dirname)(path), { recursive: true });
|
|
13763
|
+
(0, import_node_fs14.writeFileSync)(path, `${version}
|
|
13727
13764
|
`, "utf-8");
|
|
13728
13765
|
}
|
|
13729
13766
|
function installedSdkSkillHasStalePositionalExecuteExamples() {
|
|
13730
|
-
const home = process.env.HOME?.trim() || (0,
|
|
13767
|
+
const home = process.env.HOME?.trim() || (0, import_node_os9.homedir)();
|
|
13731
13768
|
const roots = [
|
|
13732
|
-
(0,
|
|
13733
|
-
(0,
|
|
13769
|
+
(0, import_node_path16.join)(home, ".claude", "skills", SDK_SKILL_NAME),
|
|
13770
|
+
(0, import_node_path16.join)(home, ".agents", "skills", SDK_SKILL_NAME)
|
|
13734
13771
|
];
|
|
13735
13772
|
const staleMarkers = [
|
|
13736
13773
|
"ctx.tools.execute(key",
|
|
@@ -13740,22 +13777,22 @@ function installedSdkSkillHasStalePositionalExecuteExamples() {
|
|
|
13740
13777
|
'rowCtx.tools.execute("'
|
|
13741
13778
|
];
|
|
13742
13779
|
const scan = (dir) => {
|
|
13743
|
-
for (const entry of (0,
|
|
13744
|
-
const path = (0,
|
|
13745
|
-
const stat3 = (0,
|
|
13780
|
+
for (const entry of (0, import_node_fs14.readdirSync)(dir)) {
|
|
13781
|
+
const path = (0, import_node_path16.join)(dir, entry);
|
|
13782
|
+
const stat3 = (0, import_node_fs14.statSync)(path);
|
|
13746
13783
|
if (stat3.isDirectory()) {
|
|
13747
13784
|
if (scan(path)) return true;
|
|
13748
13785
|
continue;
|
|
13749
13786
|
}
|
|
13750
13787
|
if (!entry.endsWith(".md")) continue;
|
|
13751
|
-
const text = (0,
|
|
13788
|
+
const text = (0, import_node_fs14.readFileSync)(path, "utf-8");
|
|
13752
13789
|
if (staleMarkers.some((marker) => text.includes(marker))) return true;
|
|
13753
13790
|
}
|
|
13754
13791
|
return false;
|
|
13755
13792
|
};
|
|
13756
13793
|
for (const root of roots) {
|
|
13757
13794
|
try {
|
|
13758
|
-
if ((0,
|
|
13795
|
+
if ((0, import_node_fs14.existsSync)(root) && scan(root)) return true;
|
|
13759
13796
|
} catch {
|
|
13760
13797
|
continue;
|
|
13761
13798
|
}
|
|
@@ -13957,8 +13994,8 @@ function shouldDeferSkillsSyncForCommand() {
|
|
|
13957
13994
|
return (command === "play" || command === "plays") && subcommand === "run" && args.includes("--json");
|
|
13958
13995
|
}
|
|
13959
13996
|
async function runPlayRunnerHealthCheck() {
|
|
13960
|
-
const dir = await (0, import_promises5.mkdtemp)((0,
|
|
13961
|
-
const file = (0,
|
|
13997
|
+
const dir = await (0, import_promises5.mkdtemp)((0, import_node_path17.join)((0, import_node_os10.tmpdir)(), "deepline-health-play-"));
|
|
13998
|
+
const file = (0, import_node_path17.join)(dir, "health-check.play.ts");
|
|
13962
13999
|
try {
|
|
13963
14000
|
await (0, import_promises5.writeFile)(
|
|
13964
14001
|
file,
|