deepline 0.3.49 → 0.3.50
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/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +25 -69
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +0 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +45 -5
- package/dist/bundling-sources/shared_libs/play-runtime/governor/policy.ts +11 -3
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +0 -2
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +11 -0
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +1 -14
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/contract.ts +17 -7
- package/dist/bundling-sources/shared_libs/play-runtime/tool-call/index.ts +0 -1
- package/dist/cli/index.js +730 -433
- package/dist/cli/index.mjs +700 -398
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -164,7 +164,7 @@ configureProxyFromEnv();
|
|
|
164
164
|
|
|
165
165
|
// src/cli/index.ts
|
|
166
166
|
import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile6 } from "fs/promises";
|
|
167
|
-
import { join as
|
|
167
|
+
import { join as join23 } from "path";
|
|
168
168
|
import { tmpdir as tmpdir6 } from "os";
|
|
169
169
|
import { Command as Command4 } from "commander";
|
|
170
170
|
|
|
@@ -1065,7 +1065,7 @@ var SDK_RELEASE = {
|
|
|
1065
1065
|
// available at toolResponse.rawV2 while toolResponse.raw and all declared
|
|
1066
1066
|
// getters keep their established compatibility behavior.
|
|
1067
1067
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
1068
|
-
version: "0.3.
|
|
1068
|
+
version: "0.3.50",
|
|
1069
1069
|
updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
|
|
1070
1070
|
packageCapabilities: {
|
|
1071
1071
|
updatePreferences: 1
|
|
@@ -2202,7 +2202,7 @@ function decodeSseFrame(frame) {
|
|
|
2202
2202
|
return parsed;
|
|
2203
2203
|
}
|
|
2204
2204
|
function sleep(ms) {
|
|
2205
|
-
return new Promise((
|
|
2205
|
+
return new Promise((resolve20) => setTimeout(resolve20, ms));
|
|
2206
2206
|
}
|
|
2207
2207
|
function withCoworkNetworkHint(message) {
|
|
2208
2208
|
if (!isCoworkLikeSandbox2() || message.includes(COWORK_NETWORK_HINT)) {
|
|
@@ -3967,14 +3967,14 @@ async function* observeRunEvents(options) {
|
|
|
3967
3967
|
try {
|
|
3968
3968
|
for (; ; ) {
|
|
3969
3969
|
if (queue.length === 0) {
|
|
3970
|
-
const waitForItem = new Promise((
|
|
3971
|
-
wake =
|
|
3970
|
+
const waitForItem = new Promise((resolve20) => {
|
|
3971
|
+
wake = resolve20;
|
|
3972
3972
|
});
|
|
3973
3973
|
if (!sawFirstSnapshot) {
|
|
3974
3974
|
const timedOut = await Promise.race([
|
|
3975
3975
|
waitForItem.then(() => false),
|
|
3976
3976
|
new Promise(
|
|
3977
|
-
(
|
|
3977
|
+
(resolve20) => setTimeout(() => resolve20(true), OBSERVE_BOOTSTRAP_TIMEOUT_MS)
|
|
3978
3978
|
)
|
|
3979
3979
|
]);
|
|
3980
3980
|
if (timedOut && queue.length === 0) {
|
|
@@ -4333,7 +4333,7 @@ function parseEnvTestPolicyOverrides() {
|
|
|
4333
4333
|
return normalizeTestPolicyOverrides(parsed, "DEEPLINE_TEST_POLICY_OVERRIDES");
|
|
4334
4334
|
}
|
|
4335
4335
|
function sleep2(ms) {
|
|
4336
|
-
return new Promise((
|
|
4336
|
+
return new Promise((resolve20) => setTimeout(resolve20, ms));
|
|
4337
4337
|
}
|
|
4338
4338
|
function isTransientCompileManifestError(error) {
|
|
4339
4339
|
if (error instanceof DeeplineError && typeof error.statusCode === "number") {
|
|
@@ -7752,6 +7752,10 @@ function flattenObjectColumns(row, options = {}) {
|
|
|
7752
7752
|
}
|
|
7753
7753
|
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
7754
7754
|
const record = value;
|
|
7755
|
+
if (options.objectColumns === "json") {
|
|
7756
|
+
flattened[key] = csvSafeJsonString(record);
|
|
7757
|
+
continue;
|
|
7758
|
+
}
|
|
7755
7759
|
const hasMatchedEnvelope = Object.prototype.hasOwnProperty.call(record, "matched_result") || Object.prototype.hasOwnProperty.call(record, "matchedResult");
|
|
7756
7760
|
if (hasMatchedEnvelope) {
|
|
7757
7761
|
flattened[key] = csvSafeJsonString(record);
|
|
@@ -8076,6 +8080,8 @@ async function httpJson(method, url, apiKey, body) {
|
|
|
8076
8080
|
"X-Deepline-API-Contract": SDK_API_CONTRACT
|
|
8077
8081
|
};
|
|
8078
8082
|
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
|
|
8083
|
+
const bypassToken = process.env.VERCEL_PROTECTION_BYPASS_TOKEN?.trim();
|
|
8084
|
+
if (bypassToken) headers["x-vercel-protection-bypass"] = bypassToken;
|
|
8079
8085
|
let response = null;
|
|
8080
8086
|
let lastError = null;
|
|
8081
8087
|
for (const candidateUrl of buildCandidateUrls2(url)) {
|
|
@@ -8142,7 +8148,7 @@ function buildCandidateUrls2(url) {
|
|
|
8142
8148
|
}
|
|
8143
8149
|
}
|
|
8144
8150
|
function sleep4(ms) {
|
|
8145
|
-
return new Promise((
|
|
8151
|
+
return new Promise((resolve20) => setTimeout(resolve20, ms));
|
|
8146
8152
|
}
|
|
8147
8153
|
function printDeeplineLogo() {
|
|
8148
8154
|
if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
|
|
@@ -10113,10 +10119,6 @@ import {
|
|
|
10113
10119
|
import { homedir as homedir5 } from "os";
|
|
10114
10120
|
import { join as join6, resolve as resolve5 } from "path";
|
|
10115
10121
|
|
|
10116
|
-
// src/cli/dataset-stats.ts
|
|
10117
|
-
import { writeFileSync as writeFileSync6 } from "fs";
|
|
10118
|
-
import { resolve as resolve4 } from "path";
|
|
10119
|
-
|
|
10120
10122
|
// ../plays/dataset-summary.ts
|
|
10121
10123
|
function formatDatasetRowCountsLine(counts) {
|
|
10122
10124
|
const { persisted, succeeded, failed } = counts;
|
|
@@ -10170,6 +10172,103 @@ function formatDatasetExecutionStats(raw, _persistedRowTotal) {
|
|
|
10170
10172
|
return stats;
|
|
10171
10173
|
}
|
|
10172
10174
|
|
|
10175
|
+
// src/cli/run-dataset-csv.ts
|
|
10176
|
+
import { writeFileSync as writeFileSync6 } from "fs";
|
|
10177
|
+
import { resolve as resolve4 } from "path";
|
|
10178
|
+
var RunDatasetCsv = class _RunDatasetCsv {
|
|
10179
|
+
#projection;
|
|
10180
|
+
constructor(input2) {
|
|
10181
|
+
const rows = input2.rows.map(projectRunDatasetRow);
|
|
10182
|
+
this.#projection = {
|
|
10183
|
+
rows,
|
|
10184
|
+
columns: runDatasetCsvColumns(rows, input2.columns)
|
|
10185
|
+
};
|
|
10186
|
+
}
|
|
10187
|
+
static from(input2) {
|
|
10188
|
+
return new _RunDatasetCsv(input2);
|
|
10189
|
+
}
|
|
10190
|
+
projection() {
|
|
10191
|
+
return this.#projection;
|
|
10192
|
+
}
|
|
10193
|
+
write(outPath) {
|
|
10194
|
+
const absolutePath = resolve4(outPath);
|
|
10195
|
+
writeFileSync6(
|
|
10196
|
+
absolutePath,
|
|
10197
|
+
csvStringFromRows(this.#projection.rows, this.#projection.columns),
|
|
10198
|
+
"utf-8"
|
|
10199
|
+
);
|
|
10200
|
+
return absolutePath;
|
|
10201
|
+
}
|
|
10202
|
+
};
|
|
10203
|
+
function writeRunDatasetCsv(input2) {
|
|
10204
|
+
return RunDatasetCsv.from(input2).write(input2.outPath);
|
|
10205
|
+
}
|
|
10206
|
+
function projectRunDatasetRow(row) {
|
|
10207
|
+
return Object.fromEntries(
|
|
10208
|
+
Object.entries(row).map(([column, value]) => [
|
|
10209
|
+
column,
|
|
10210
|
+
projectRunDatasetCell(value)
|
|
10211
|
+
])
|
|
10212
|
+
);
|
|
10213
|
+
}
|
|
10214
|
+
function projectRunDatasetCell(value) {
|
|
10215
|
+
const logicalValue = parseSerializedDatasetValue(value);
|
|
10216
|
+
if (logicalValue === null || logicalValue === void 0) return logicalValue;
|
|
10217
|
+
if (typeof logicalValue === "object") {
|
|
10218
|
+
return csvSafeJsonString(canonicalDatasetJson(logicalValue));
|
|
10219
|
+
}
|
|
10220
|
+
return logicalValue;
|
|
10221
|
+
}
|
|
10222
|
+
function canonicalDatasetJson(value) {
|
|
10223
|
+
return canonicalDatasetJsonValue(value, /* @__PURE__ */ new WeakSet());
|
|
10224
|
+
}
|
|
10225
|
+
function canonicalDatasetJsonValue(value, ancestors) {
|
|
10226
|
+
if (Array.isArray(value)) {
|
|
10227
|
+
if (ancestors.has(value)) return value;
|
|
10228
|
+
ancestors.add(value);
|
|
10229
|
+
const normalized2 = value.map(
|
|
10230
|
+
(item) => canonicalDatasetJsonValue(item, ancestors)
|
|
10231
|
+
);
|
|
10232
|
+
ancestors.delete(value);
|
|
10233
|
+
return normalized2;
|
|
10234
|
+
}
|
|
10235
|
+
if (!value || typeof value !== "object" || value instanceof Date) {
|
|
10236
|
+
return value;
|
|
10237
|
+
}
|
|
10238
|
+
if (ancestors.has(value)) return value;
|
|
10239
|
+
ancestors.add(value);
|
|
10240
|
+
const record = value;
|
|
10241
|
+
const normalized = Object.fromEntries(
|
|
10242
|
+
Object.keys(record).sort((left, right) => left.localeCompare(right)).map((key) => [key, canonicalDatasetJsonValue(record[key], ancestors)])
|
|
10243
|
+
);
|
|
10244
|
+
ancestors.delete(value);
|
|
10245
|
+
return normalized;
|
|
10246
|
+
}
|
|
10247
|
+
function parseSerializedDatasetValue(value) {
|
|
10248
|
+
if (typeof value !== "string") return value;
|
|
10249
|
+
const text = value.trim();
|
|
10250
|
+
if (!text || !["{", "["].includes(text[0] ?? "")) return value;
|
|
10251
|
+
try {
|
|
10252
|
+
return JSON.parse(text);
|
|
10253
|
+
} catch {
|
|
10254
|
+
return value;
|
|
10255
|
+
}
|
|
10256
|
+
}
|
|
10257
|
+
function runDatasetCsvColumns(rows, declaredColumns) {
|
|
10258
|
+
const columns = [];
|
|
10259
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10260
|
+
const add = (column) => {
|
|
10261
|
+
if (!column || seen.has(column)) return;
|
|
10262
|
+
seen.add(column);
|
|
10263
|
+
columns.push(column);
|
|
10264
|
+
};
|
|
10265
|
+
for (const column of declaredColumns) add(column);
|
|
10266
|
+
for (const row of rows) {
|
|
10267
|
+
for (const column of Object.keys(row)) add(column);
|
|
10268
|
+
}
|
|
10269
|
+
return columns;
|
|
10270
|
+
}
|
|
10271
|
+
|
|
10173
10272
|
// src/cli/dataset-stats.ts
|
|
10174
10273
|
function mergeCanonicalRowsInfo(left, right) {
|
|
10175
10274
|
const preferred = right.rows.length > left.rows.length || right.complete && !left.complete && right.rows.length === left.rows.length ? right : left;
|
|
@@ -10587,6 +10686,11 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
|
|
|
10587
10686
|
}
|
|
10588
10687
|
return infos;
|
|
10589
10688
|
}
|
|
10689
|
+
var LegacyRunDatasetCatalogAdapter = class {
|
|
10690
|
+
static datasets(statusOrResult) {
|
|
10691
|
+
return collectSerializedDatasetRowsInfos(statusOrResult);
|
|
10692
|
+
}
|
|
10693
|
+
};
|
|
10590
10694
|
function extractCanonicalRowsInfo(statusOrResult) {
|
|
10591
10695
|
return collectCanonicalRowsInfos(statusOrResult)[0] ?? null;
|
|
10592
10696
|
}
|
|
@@ -10756,22 +10860,6 @@ function buildDatasetStats(rows, totalRows = rows.length, columns = inferColumns
|
|
|
10756
10860
|
columnStats
|
|
10757
10861
|
};
|
|
10758
10862
|
}
|
|
10759
|
-
function writeCanonicalRowsCsv(rowsInfo, outPath) {
|
|
10760
|
-
if (!rowsInfo.complete) {
|
|
10761
|
-
throw new Error(
|
|
10762
|
-
`Run output only includes ${rowsInfo.rows.length} preview row(s) of ${rowsInfo.totalRows}; cannot export a complete CSV from this status payload yet.`
|
|
10763
|
-
);
|
|
10764
|
-
}
|
|
10765
|
-
const sanitized = sanitizeCsvProjectionInfo({
|
|
10766
|
-
rows: rowsInfo.rows,
|
|
10767
|
-
columns: rowsInfo.columns
|
|
10768
|
-
});
|
|
10769
|
-
const rows = dataExportRows(sanitized.rows);
|
|
10770
|
-
const columns = dataExportColumns(rows, sanitized.columns);
|
|
10771
|
-
const resolved = resolve4(outPath);
|
|
10772
|
-
writeFileSync6(resolved, csvStringFromRows(rows, columns), "utf-8");
|
|
10773
|
-
return resolved;
|
|
10774
|
-
}
|
|
10775
10863
|
|
|
10776
10864
|
// src/cli/commands/csv.ts
|
|
10777
10865
|
function parseRowRange(raw) {
|
|
@@ -18309,6 +18397,207 @@ var SDK_PACKAGE_JSON = resolve10(SDK_PACKAGE_ROOT, "package.json");
|
|
|
18309
18397
|
var SDK_ENTRY_FILE = resolve10(SDK_SOURCE_ROOT, "index.ts");
|
|
18310
18398
|
var SDK_TYPES_ENTRY_FILE = HAS_SOURCE_BUNDLING_SOURCES ? SDK_ENTRY_FILE : resolve10(SDK_PACKAGE_ROOT, "dist", "index.d.ts");
|
|
18311
18399
|
|
|
18400
|
+
// src/cli/run-dataset-selection.ts
|
|
18401
|
+
var Run = class _Run {
|
|
18402
|
+
#datasets;
|
|
18403
|
+
constructor(input2) {
|
|
18404
|
+
this.#datasets = RunDatasetCatalog.from({
|
|
18405
|
+
runPackage: input2.runPackage,
|
|
18406
|
+
datasets: input2.datasets
|
|
18407
|
+
});
|
|
18408
|
+
}
|
|
18409
|
+
static open(input2) {
|
|
18410
|
+
return new _Run(input2);
|
|
18411
|
+
}
|
|
18412
|
+
datasets() {
|
|
18413
|
+
return this.#datasets;
|
|
18414
|
+
}
|
|
18415
|
+
/** Select the Dataset a caller wants to export; enumerate with datasets(). */
|
|
18416
|
+
dataset(path) {
|
|
18417
|
+
return this.#datasets.choose(path);
|
|
18418
|
+
}
|
|
18419
|
+
};
|
|
18420
|
+
var RunDatasetCatalog = class _RunDatasetCatalog {
|
|
18421
|
+
#available;
|
|
18422
|
+
#returned;
|
|
18423
|
+
#recovered;
|
|
18424
|
+
constructor(input2) {
|
|
18425
|
+
this.#available = input2.available.map((info) => RunDataset.from(info));
|
|
18426
|
+
this.#returned = input2.returned.map((info) => RunDataset.from(info));
|
|
18427
|
+
this.#recovered = input2.available.filter((info) => info.recovered).map((info) => RunDataset.from(info));
|
|
18428
|
+
}
|
|
18429
|
+
static from(input2) {
|
|
18430
|
+
const available = withReturnedDatasetAliases(
|
|
18431
|
+
input2.runPackage,
|
|
18432
|
+
distinctRunDatasets(input2.datasets)
|
|
18433
|
+
);
|
|
18434
|
+
return new _RunDatasetCatalog({
|
|
18435
|
+
available,
|
|
18436
|
+
returned: returnedRunDatasets(input2.runPackage, available)
|
|
18437
|
+
});
|
|
18438
|
+
}
|
|
18439
|
+
available() {
|
|
18440
|
+
return this.#available;
|
|
18441
|
+
}
|
|
18442
|
+
returned() {
|
|
18443
|
+
return this.#returned;
|
|
18444
|
+
}
|
|
18445
|
+
recovered() {
|
|
18446
|
+
return this.#recovered;
|
|
18447
|
+
}
|
|
18448
|
+
/**
|
|
18449
|
+
* Select an exact public Dataset path/id/namespace. With no requested path,
|
|
18450
|
+
* a Run returns its sole returned Dataset, or its sole recovered Dataset.
|
|
18451
|
+
*/
|
|
18452
|
+
choose(path) {
|
|
18453
|
+
const requested = path?.trim();
|
|
18454
|
+
if (requested) {
|
|
18455
|
+
return this.#available.find((dataset) => dataset.matches(requested)) ?? null;
|
|
18456
|
+
}
|
|
18457
|
+
if (this.#returned.length === 1) return this.#returned[0];
|
|
18458
|
+
return this.#returned.length === 0 && this.#recovered.length === 1 ? this.#recovered[0] : null;
|
|
18459
|
+
}
|
|
18460
|
+
};
|
|
18461
|
+
var RunDataset = class _RunDataset {
|
|
18462
|
+
#info;
|
|
18463
|
+
constructor(info) {
|
|
18464
|
+
this.#info = info;
|
|
18465
|
+
}
|
|
18466
|
+
static from(info) {
|
|
18467
|
+
return new _RunDataset(info);
|
|
18468
|
+
}
|
|
18469
|
+
get source() {
|
|
18470
|
+
return this.#info.source;
|
|
18471
|
+
}
|
|
18472
|
+
get datasetId() {
|
|
18473
|
+
return this.#info.datasetId;
|
|
18474
|
+
}
|
|
18475
|
+
get tableNamespace() {
|
|
18476
|
+
return this.#info.tableNamespace;
|
|
18477
|
+
}
|
|
18478
|
+
get rows() {
|
|
18479
|
+
return this.#info.rows;
|
|
18480
|
+
}
|
|
18481
|
+
get totalRows() {
|
|
18482
|
+
return this.#info.totalRows;
|
|
18483
|
+
}
|
|
18484
|
+
get complete() {
|
|
18485
|
+
return this.#info.complete;
|
|
18486
|
+
}
|
|
18487
|
+
get recovered() {
|
|
18488
|
+
return this.#info.recovered;
|
|
18489
|
+
}
|
|
18490
|
+
get exportUnavailableReason() {
|
|
18491
|
+
return this.#info.exportUnavailableReason;
|
|
18492
|
+
}
|
|
18493
|
+
get exportUnavailableMessage() {
|
|
18494
|
+
return this.#info.exportUnavailableMessage;
|
|
18495
|
+
}
|
|
18496
|
+
matches(path) {
|
|
18497
|
+
return this.source === path || this.datasetId === path || this.tableNamespace === path;
|
|
18498
|
+
}
|
|
18499
|
+
/** Return a new Handle when its preview has been replaced by fetched rows. */
|
|
18500
|
+
withRows(info) {
|
|
18501
|
+
return _RunDataset.from(info);
|
|
18502
|
+
}
|
|
18503
|
+
/** Write this Dataset's stable, non-flattening CSV Projection. */
|
|
18504
|
+
exportCsv(outPath) {
|
|
18505
|
+
if (!this.complete) {
|
|
18506
|
+
throw new Error(
|
|
18507
|
+
`Run Dataset '${this.source ?? this.tableNamespace ?? "dataset"}' only includes ${this.rows.length} preview row(s) of ${this.totalRows}; cannot export a complete CSV yet.`
|
|
18508
|
+
);
|
|
18509
|
+
}
|
|
18510
|
+
return writeRunDatasetCsv({
|
|
18511
|
+
rows: this.rows,
|
|
18512
|
+
columns: this.#info.columns,
|
|
18513
|
+
outPath
|
|
18514
|
+
});
|
|
18515
|
+
}
|
|
18516
|
+
/** Compatibility seam for callers which still return CanonicalRowsInfo. */
|
|
18517
|
+
info() {
|
|
18518
|
+
return this.#info;
|
|
18519
|
+
}
|
|
18520
|
+
};
|
|
18521
|
+
function distinctRunDatasets(infos) {
|
|
18522
|
+
const byIdentity = /* @__PURE__ */ new Map();
|
|
18523
|
+
for (const info of infos) {
|
|
18524
|
+
const identity = info.datasetId?.trim() ? `id:${info.datasetId.trim()}` : `path:${info.source ?? info.tableNamespace ?? "dataset"}`;
|
|
18525
|
+
const existing = byIdentity.get(identity);
|
|
18526
|
+
byIdentity.set(
|
|
18527
|
+
identity,
|
|
18528
|
+
existing ? mergeCanonicalRowsInfo(existing, info) : info
|
|
18529
|
+
);
|
|
18530
|
+
}
|
|
18531
|
+
return [...byIdentity.values()];
|
|
18532
|
+
}
|
|
18533
|
+
function packageForDatasetSelection(runPackage) {
|
|
18534
|
+
const root = recordValue(runPackage);
|
|
18535
|
+
const nested = recordValue(root.package);
|
|
18536
|
+
if (nested?.kind === "play_run") return nested;
|
|
18537
|
+
return root.kind === "play_run" ? root : null;
|
|
18538
|
+
}
|
|
18539
|
+
function withReturnedDatasetAliases(runPackage, available) {
|
|
18540
|
+
const outputs = recordValue(packageForDatasetSelection(runPackage)?.outputs);
|
|
18541
|
+
if (Object.keys(outputs).length === 0) return available;
|
|
18542
|
+
const expanded = [...available];
|
|
18543
|
+
for (const outputValue of Object.values(outputs)) {
|
|
18544
|
+
const output2 = recordValue(outputValue);
|
|
18545
|
+
if (output2.kind !== "dataset") continue;
|
|
18546
|
+
const alias = stringValue2(output2.path);
|
|
18547
|
+
if (!alias) continue;
|
|
18548
|
+
const datasetId = stringValue2(output2.datasetId);
|
|
18549
|
+
const canonicalPath2 = stringValue2(output2.dataset);
|
|
18550
|
+
const canonical = available.find(
|
|
18551
|
+
(info) => datasetId && info.datasetId === datasetId || canonicalPath2 && info.source === canonicalPath2
|
|
18552
|
+
);
|
|
18553
|
+
if (!canonical) continue;
|
|
18554
|
+
const aliasIndex = expanded.findIndex((info) => info.source === alias);
|
|
18555
|
+
if (aliasIndex >= 0) {
|
|
18556
|
+
expanded[aliasIndex] = {
|
|
18557
|
+
...mergeCanonicalRowsInfo(expanded[aliasIndex], canonical),
|
|
18558
|
+
source: alias
|
|
18559
|
+
};
|
|
18560
|
+
} else {
|
|
18561
|
+
expanded.push({ ...canonical, source: alias });
|
|
18562
|
+
}
|
|
18563
|
+
}
|
|
18564
|
+
return expanded;
|
|
18565
|
+
}
|
|
18566
|
+
function returnedRunDatasets(runPackage, available) {
|
|
18567
|
+
const outputs = recordValue(packageForDatasetSelection(runPackage)?.outputs);
|
|
18568
|
+
if (Object.keys(outputs).length > 0) {
|
|
18569
|
+
const selected = /* @__PURE__ */ new Map();
|
|
18570
|
+
for (const outputValue of Object.values(outputs)) {
|
|
18571
|
+
const output2 = recordValue(outputValue);
|
|
18572
|
+
if (output2.kind !== "dataset") continue;
|
|
18573
|
+
const datasetId = stringValue2(output2.datasetId);
|
|
18574
|
+
const alias = stringValue2(output2.path);
|
|
18575
|
+
const canonicalPath2 = stringValue2(output2.dataset);
|
|
18576
|
+
const info = (alias ? available.find((candidate) => candidate.source === alias) : null) ?? (datasetId ? available.find((candidate) => candidate.datasetId === datasetId) : null) ?? (canonicalPath2 ? available.find((candidate) => candidate.source === canonicalPath2) : null);
|
|
18577
|
+
if (!info) continue;
|
|
18578
|
+
const identity = datasetId ? `id:${datasetId}` : `path:${canonicalPath2 ?? alias ?? info.source ?? "dataset"}`;
|
|
18579
|
+
const aliased = { ...info, source: alias ?? info.source };
|
|
18580
|
+
const existing = selected.get(identity);
|
|
18581
|
+
selected.set(
|
|
18582
|
+
identity,
|
|
18583
|
+
existing ? mergeCanonicalRowsInfo(existing, aliased) : aliased
|
|
18584
|
+
);
|
|
18585
|
+
}
|
|
18586
|
+
if (selected.size > 0) return [...selected.values()];
|
|
18587
|
+
}
|
|
18588
|
+
return distinctRunDatasets(
|
|
18589
|
+
available.filter(
|
|
18590
|
+
(info) => Boolean(info.source?.startsWith("result.")) && !info.recovered
|
|
18591
|
+
)
|
|
18592
|
+
);
|
|
18593
|
+
}
|
|
18594
|
+
function recordValue(value) {
|
|
18595
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
18596
|
+
}
|
|
18597
|
+
function stringValue2(value) {
|
|
18598
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
18599
|
+
}
|
|
18600
|
+
|
|
18312
18601
|
// src/cli/progress.ts
|
|
18313
18602
|
import { Worker } from "worker_threads";
|
|
18314
18603
|
var CliProgress = class {
|
|
@@ -18578,7 +18867,7 @@ ${hint}`;
|
|
|
18578
18867
|
|
|
18579
18868
|
// ../play-runtime/governor/policy.ts
|
|
18580
18869
|
var DEFAULT_MAX_CONCURRENT_EXTERNAL_CALLS = 64;
|
|
18581
|
-
var MAX_CONFIGURABLE_CONCURRENT_EXTERNAL_CALLS =
|
|
18870
|
+
var MAX_CONFIGURABLE_CONCURRENT_EXTERNAL_CALLS = 1e3;
|
|
18582
18871
|
var MAX_CONFIGURABLE_CONCURRENT_ROWS = 1e3;
|
|
18583
18872
|
function resolveMaxConcurrentExternalCalls(requested) {
|
|
18584
18873
|
if (requested === void 0 || requested === null) {
|
|
@@ -19120,8 +19409,7 @@ var PLAY_RUN_RESERVED_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
|
19120
19409
|
"--force",
|
|
19121
19410
|
"--force-tool-refresh",
|
|
19122
19411
|
"--open",
|
|
19123
|
-
"--debug-map-latency"
|
|
19124
|
-
"--debug-fixture-provider-pacing"
|
|
19412
|
+
"--debug-map-latency"
|
|
19125
19413
|
]);
|
|
19126
19414
|
async function pathExistsIncludingSymlink(path) {
|
|
19127
19415
|
try {
|
|
@@ -19256,7 +19544,7 @@ function traceCliSync(phase, fields, run) {
|
|
|
19256
19544
|
}
|
|
19257
19545
|
}
|
|
19258
19546
|
function sleep5(ms) {
|
|
19259
|
-
return new Promise((
|
|
19547
|
+
return new Promise((resolve20) => setTimeout(resolve20, ms));
|
|
19260
19548
|
}
|
|
19261
19549
|
function parseReferencedPlayTarget2(target) {
|
|
19262
19550
|
const trimmed = target.trim();
|
|
@@ -22569,103 +22857,6 @@ async function fetchBackingDatasetRows(input2) {
|
|
|
22569
22857
|
source: `${input2.rowsInfo.source ?? "result.rows"} -> /api/v2/plays/${playName}/sheet?tableNamespace=${tableNamespace}`
|
|
22570
22858
|
};
|
|
22571
22859
|
}
|
|
22572
|
-
function resolveDatasetByName(available, datasetPath) {
|
|
22573
|
-
const target = datasetPath.trim();
|
|
22574
|
-
const exact = available.find((info) => info.source === target);
|
|
22575
|
-
if (exact) {
|
|
22576
|
-
return exact;
|
|
22577
|
-
}
|
|
22578
|
-
const byDatasetId = available.find((info) => info.datasetId === target);
|
|
22579
|
-
if (byDatasetId) {
|
|
22580
|
-
return byDatasetId;
|
|
22581
|
-
}
|
|
22582
|
-
const byNamespace = available.find(
|
|
22583
|
-
(info) => info.tableNamespace && info.tableNamespace === target
|
|
22584
|
-
);
|
|
22585
|
-
if (byNamespace) {
|
|
22586
|
-
return byNamespace;
|
|
22587
|
-
}
|
|
22588
|
-
return null;
|
|
22589
|
-
}
|
|
22590
|
-
function canonicalRowsIdentity(info) {
|
|
22591
|
-
return info.datasetId?.trim() ? `id:${info.datasetId.trim()}` : `path:${info.source ?? info.tableNamespace ?? "dataset"}`;
|
|
22592
|
-
}
|
|
22593
|
-
function distinctCanonicalRowsInfos(infos) {
|
|
22594
|
-
const byIdentity = /* @__PURE__ */ new Map();
|
|
22595
|
-
for (const info of infos) {
|
|
22596
|
-
const identity = canonicalRowsIdentity(info);
|
|
22597
|
-
const existing = byIdentity.get(identity);
|
|
22598
|
-
byIdentity.set(
|
|
22599
|
-
identity,
|
|
22600
|
-
existing ? mergeCanonicalRowsInfo(existing, info) : info
|
|
22601
|
-
);
|
|
22602
|
-
}
|
|
22603
|
-
return [...byIdentity.values()];
|
|
22604
|
-
}
|
|
22605
|
-
function packageForExportSelection(status) {
|
|
22606
|
-
const root = status;
|
|
22607
|
-
const nested = readRecord(root.package);
|
|
22608
|
-
if (nested?.kind === "play_run") return nested;
|
|
22609
|
-
return root.kind === "play_run" ? root : null;
|
|
22610
|
-
}
|
|
22611
|
-
function withReturnedDatasetAliases(status, available) {
|
|
22612
|
-
const packaged = packageForExportSelection(status);
|
|
22613
|
-
const outputs = readRecord(packaged?.outputs);
|
|
22614
|
-
if (!outputs) return available;
|
|
22615
|
-
const expanded = [...available];
|
|
22616
|
-
for (const outputValue of Object.values(outputs)) {
|
|
22617
|
-
const output2 = readRecord(outputValue);
|
|
22618
|
-
if (output2?.kind !== "dataset") continue;
|
|
22619
|
-
const alias = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
|
|
22620
|
-
if (!alias) continue;
|
|
22621
|
-
const datasetId = typeof output2.datasetId === "string" && output2.datasetId.trim() ? output2.datasetId.trim() : null;
|
|
22622
|
-
const canonicalPath2 = typeof output2.dataset === "string" && output2.dataset.trim() ? output2.dataset.trim() : null;
|
|
22623
|
-
const canonical = available.find(
|
|
22624
|
-
(info) => datasetId && info.datasetId === datasetId || canonicalPath2 && info.source === canonicalPath2
|
|
22625
|
-
);
|
|
22626
|
-
if (canonical) {
|
|
22627
|
-
const aliasIndex = expanded.findIndex((info) => info.source === alias);
|
|
22628
|
-
if (aliasIndex >= 0) {
|
|
22629
|
-
expanded[aliasIndex] = {
|
|
22630
|
-
...mergeCanonicalRowsInfo(expanded[aliasIndex], canonical),
|
|
22631
|
-
source: alias
|
|
22632
|
-
};
|
|
22633
|
-
} else {
|
|
22634
|
-
expanded.push({ ...canonical, source: alias });
|
|
22635
|
-
}
|
|
22636
|
-
}
|
|
22637
|
-
}
|
|
22638
|
-
return expanded;
|
|
22639
|
-
}
|
|
22640
|
-
function returnedRowsInfos(status, available) {
|
|
22641
|
-
const packaged = packageForExportSelection(status);
|
|
22642
|
-
const outputs = readRecord(packaged?.outputs);
|
|
22643
|
-
if (outputs) {
|
|
22644
|
-
const selected = /* @__PURE__ */ new Map();
|
|
22645
|
-
for (const outputValue of Object.values(outputs)) {
|
|
22646
|
-
const output2 = readRecord(outputValue);
|
|
22647
|
-
if (output2?.kind !== "dataset") continue;
|
|
22648
|
-
const datasetId = typeof output2.datasetId === "string" && output2.datasetId.trim() ? output2.datasetId.trim() : null;
|
|
22649
|
-
const alias = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
|
|
22650
|
-
const canonicalPath2 = typeof output2.dataset === "string" && output2.dataset.trim() ? output2.dataset.trim() : null;
|
|
22651
|
-
const info = (alias ? available.find((candidate) => candidate.source === alias) : null) ?? (datasetId ? available.find((candidate) => candidate.datasetId === datasetId) : null) ?? (canonicalPath2 ? available.find((candidate) => candidate.source === canonicalPath2) : null);
|
|
22652
|
-
if (!info) continue;
|
|
22653
|
-
const identity = datasetId ? `id:${datasetId}` : `path:${canonicalPath2 ?? alias ?? info.source ?? "dataset"}`;
|
|
22654
|
-
const aliased = { ...info, source: alias ?? info.source };
|
|
22655
|
-
const existing = selected.get(identity);
|
|
22656
|
-
selected.set(
|
|
22657
|
-
identity,
|
|
22658
|
-
existing ? mergeCanonicalRowsInfo(existing, aliased) : aliased
|
|
22659
|
-
);
|
|
22660
|
-
}
|
|
22661
|
-
if (selected.size > 0) return [...selected.values()];
|
|
22662
|
-
}
|
|
22663
|
-
return distinctCanonicalRowsInfos(
|
|
22664
|
-
available.filter(
|
|
22665
|
-
(info) => Boolean(info.source?.startsWith("result.")) && !info.recovered
|
|
22666
|
-
)
|
|
22667
|
-
);
|
|
22668
|
-
}
|
|
22669
22860
|
function exportDatasetCommand(input2) {
|
|
22670
22861
|
return `deepline runs export ${input2.runId} --dataset ${shellSingleQuote(
|
|
22671
22862
|
input2.datasetPath
|
|
@@ -22724,16 +22915,17 @@ async function exportPlayStatusRows(client2, status, outPath, options = {}) {
|
|
|
22724
22915
|
if (!outPath) {
|
|
22725
22916
|
return null;
|
|
22726
22917
|
}
|
|
22727
|
-
const
|
|
22728
|
-
status,
|
|
22729
|
-
|
|
22730
|
-
);
|
|
22731
|
-
const
|
|
22732
|
-
const
|
|
22733
|
-
|
|
22734
|
-
);
|
|
22735
|
-
const
|
|
22736
|
-
|
|
22918
|
+
const run = Run.open({
|
|
22919
|
+
runPackage: status,
|
|
22920
|
+
datasets: LegacyRunDatasetCatalogAdapter.datasets(status)
|
|
22921
|
+
});
|
|
22922
|
+
const datasets = run.datasets();
|
|
22923
|
+
const availableRows = datasets.available().map((dataset) => dataset.info());
|
|
22924
|
+
const returnedRows = datasets.returned().map((dataset) => dataset.info());
|
|
22925
|
+
const recoveredRows = datasets.recovered().map((dataset) => dataset.info());
|
|
22926
|
+
const selectedDataset = run.dataset(options.datasetPath);
|
|
22927
|
+
const rowsInfo = selectedDataset?.info() ?? null;
|
|
22928
|
+
if (!selectedDataset && options.datasetPath) {
|
|
22737
22929
|
const available = availableRows.map((info) => info.source).filter((source) => typeof source === "string");
|
|
22738
22930
|
const commands = datasetChoiceLines({
|
|
22739
22931
|
runId: status.runId,
|
|
@@ -22824,7 +23016,7 @@ ${commands.join("\n")}`,
|
|
|
22824
23016
|
datasetPath: options.datasetPath
|
|
22825
23017
|
});
|
|
22826
23018
|
return {
|
|
22827
|
-
path:
|
|
23019
|
+
path: RunDataset.from(guarded2).exportCsv(outPath),
|
|
22828
23020
|
rowsInfo: guarded2
|
|
22829
23021
|
};
|
|
22830
23022
|
}
|
|
@@ -22836,7 +23028,7 @@ ${commands.join("\n")}`,
|
|
|
22836
23028
|
datasetPath: options.datasetPath
|
|
22837
23029
|
});
|
|
22838
23030
|
return {
|
|
22839
|
-
path:
|
|
23031
|
+
path: RunDataset.from(guarded2).exportCsv(outPath),
|
|
22840
23032
|
rowsInfo: guarded2
|
|
22841
23033
|
};
|
|
22842
23034
|
}
|
|
@@ -22870,7 +23062,10 @@ ${commands.join("\n")}`,
|
|
|
22870
23062
|
availableRows,
|
|
22871
23063
|
datasetPath: options.datasetPath
|
|
22872
23064
|
});
|
|
22873
|
-
return {
|
|
23065
|
+
return {
|
|
23066
|
+
path: RunDataset.from(guarded).exportCsv(outPath),
|
|
23067
|
+
rowsInfo: guarded
|
|
23068
|
+
};
|
|
22874
23069
|
}
|
|
22875
23070
|
function extractActiveRunsFromError(error) {
|
|
22876
23071
|
if (!(error instanceof DeeplineError)) {
|
|
@@ -23164,9 +23359,6 @@ function parsePlayRunOptions(args) {
|
|
|
23164
23359
|
const forceToolRefresh = args.includes("--force-tool-refresh");
|
|
23165
23360
|
const open2 = args.includes("--open");
|
|
23166
23361
|
const debugMapLatency = args.includes("--debug-map-latency");
|
|
23167
|
-
const debugFixtureProviderPacing = args.includes(
|
|
23168
|
-
"--debug-fixture-provider-pacing"
|
|
23169
|
-
);
|
|
23170
23362
|
const verboseLogs = args.includes("--logs") || debugMapLatency;
|
|
23171
23363
|
let waitTimeoutMs = null;
|
|
23172
23364
|
let maxConcurrentExternalCalls = null;
|
|
@@ -23370,7 +23562,6 @@ function parsePlayRunOptions(args) {
|
|
|
23370
23562
|
open: open2,
|
|
23371
23563
|
profile,
|
|
23372
23564
|
debugMapLatency,
|
|
23373
|
-
debugFixtureProviderPacing,
|
|
23374
23565
|
fixtureBehavior,
|
|
23375
23566
|
runIdFile
|
|
23376
23567
|
};
|
|
@@ -23536,7 +23727,7 @@ function formatPlayRuntimeLimit(runtimeLimit) {
|
|
|
23536
23727
|
function isRecord10(value) {
|
|
23537
23728
|
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
23538
23729
|
}
|
|
23539
|
-
function
|
|
23730
|
+
function stringValue3(value) {
|
|
23540
23731
|
return typeof value === "string" ? value.trim() : "";
|
|
23541
23732
|
}
|
|
23542
23733
|
function asArray(value) {
|
|
@@ -23556,11 +23747,11 @@ function firstRawPath(entry) {
|
|
|
23556
23747
|
...asArray(details.raw_tool_output_paths),
|
|
23557
23748
|
...asArray(details.candidatePaths),
|
|
23558
23749
|
...asArray(details.candidate_paths)
|
|
23559
|
-
].map(
|
|
23750
|
+
].map(stringValue3).filter(Boolean);
|
|
23560
23751
|
return paths[0];
|
|
23561
23752
|
}
|
|
23562
23753
|
function checkHintExpression(value) {
|
|
23563
|
-
return
|
|
23754
|
+
return stringValue3(value).replace(/^toolExecutionResult\./, "result.");
|
|
23564
23755
|
}
|
|
23565
23756
|
function checkHintRawPath(value) {
|
|
23566
23757
|
return value?.replace(/^toolResponse\./, "result.toolResponse.");
|
|
@@ -23575,7 +23766,7 @@ function collectStaticPipelineToolIds(staticPipeline) {
|
|
|
23575
23766
|
]) {
|
|
23576
23767
|
if (!isRecord10(step)) continue;
|
|
23577
23768
|
if (step.type === "tool") {
|
|
23578
|
-
const toolId =
|
|
23769
|
+
const toolId = stringValue3(step.toolId) || stringValue3(step.tool);
|
|
23579
23770
|
if (toolId) seen.add(toolId);
|
|
23580
23771
|
}
|
|
23581
23772
|
if (step.type === "play_call") {
|
|
@@ -23593,14 +23784,14 @@ function toolGetterHintFromMetadata(toolId, tool) {
|
|
|
23593
23784
|
const lists = extractionEntries2(
|
|
23594
23785
|
resultGuidance.extractedLists ?? resultGuidance.extracted_lists
|
|
23595
23786
|
).map((entry) => ({
|
|
23596
|
-
name:
|
|
23787
|
+
name: stringValue3(entry.name),
|
|
23597
23788
|
expression: checkHintExpression(entry.expression),
|
|
23598
23789
|
raw: checkHintRawPath(firstRawPath(entry))
|
|
23599
23790
|
})).filter((entry) => entry.name && entry.expression);
|
|
23600
23791
|
const values = extractionEntries2(
|
|
23601
23792
|
resultGuidance.extractedValues ?? resultGuidance.extracted_values
|
|
23602
23793
|
).map((entry) => ({
|
|
23603
|
-
name:
|
|
23794
|
+
name: stringValue3(entry.name),
|
|
23604
23795
|
expression: checkHintExpression(entry.expression),
|
|
23605
23796
|
raw: checkHintRawPath(firstRawPath(entry))
|
|
23606
23797
|
})).filter((entry) => entry.name && entry.expression);
|
|
@@ -24161,14 +24352,8 @@ async function handleFileBackedRun(options, hooks) {
|
|
|
24161
24352
|
"--fixture-behavior requires DEEPLINE_EVAL_INTEGRATION_MODE=fixture."
|
|
24162
24353
|
);
|
|
24163
24354
|
}
|
|
24164
|
-
if (options.debugFixtureProviderPacing && integrationMode !== "fixture") {
|
|
24165
|
-
throw new Error(
|
|
24166
|
-
"--debug-fixture-provider-pacing requires DEEPLINE_EVAL_INTEGRATION_MODE=fixture."
|
|
24167
|
-
);
|
|
24168
|
-
}
|
|
24169
24355
|
const testPolicyOverrides = {
|
|
24170
|
-
...options.debugMapLatency ? { mapLatencyProfile: true } : {}
|
|
24171
|
-
...options.debugFixtureProviderPacing ? { enforceFixtureProviderPacing: true } : {}
|
|
24356
|
+
...options.debugMapLatency ? { mapLatencyProfile: true } : {}
|
|
24172
24357
|
};
|
|
24173
24358
|
const startRequest = {
|
|
24174
24359
|
name: playName,
|
|
@@ -24350,14 +24535,8 @@ async function handleNamedRun(options, hooks) {
|
|
|
24350
24535
|
"--fixture-behavior requires DEEPLINE_EVAL_INTEGRATION_MODE=fixture."
|
|
24351
24536
|
);
|
|
24352
24537
|
}
|
|
24353
|
-
if (options.debugFixtureProviderPacing && integrationMode !== "fixture") {
|
|
24354
|
-
throw new Error(
|
|
24355
|
-
"--debug-fixture-provider-pacing requires DEEPLINE_EVAL_INTEGRATION_MODE=fixture."
|
|
24356
|
-
);
|
|
24357
|
-
}
|
|
24358
24538
|
const testPolicyOverrides = {
|
|
24359
|
-
...options.debugMapLatency ? { mapLatencyProfile: true } : {}
|
|
24360
|
-
...options.debugFixtureProviderPacing ? { enforceFixtureProviderPacing: true } : {}
|
|
24539
|
+
...options.debugMapLatency ? { mapLatencyProfile: true } : {}
|
|
24361
24540
|
};
|
|
24362
24541
|
const startRequest = {
|
|
24363
24542
|
name: playName,
|
|
@@ -26242,9 +26421,6 @@ Examples:
|
|
|
26242
26421
|
).option("--open", "Open the play page in a browser after the run starts").option(
|
|
26243
26422
|
"--debug-map-latency",
|
|
26244
26423
|
"Internal diagnostics: emit one aggregate latency profile per dataset map"
|
|
26245
|
-
).option(
|
|
26246
|
-
"--debug-fixture-provider-pacing",
|
|
26247
|
-
"Internal diagnostics: retain provider pacing while fixture mode is active"
|
|
26248
26424
|
).option("--json", "Emit JSON output").option("--full", "Debug only: with --json, emit the raw status payload").addHelpText(
|
|
26249
26425
|
"afterAll",
|
|
26250
26426
|
`
|
|
@@ -26291,7 +26467,6 @@ Pass-through input flags:
|
|
|
26291
26467
|
...options.maxConcurrentRows ? ["--max-concurrent-rows", options.maxConcurrentRows] : [],
|
|
26292
26468
|
...options.open ? ["--open"] : [],
|
|
26293
26469
|
...options.debugMapLatency ? ["--debug-map-latency"] : [],
|
|
26294
|
-
...options.debugFixtureProviderPacing ? ["--debug-fixture-provider-pacing"] : [],
|
|
26295
26470
|
...options.json ? ["--json"] : [],
|
|
26296
26471
|
...options.full ? ["--full"] : [],
|
|
26297
26472
|
...passthroughArgs
|
|
@@ -28713,7 +28888,7 @@ function emitEnrichDebug(message) {
|
|
|
28713
28888
|
);
|
|
28714
28889
|
}
|
|
28715
28890
|
function sleep6(ms) {
|
|
28716
|
-
return new Promise((
|
|
28891
|
+
return new Promise((resolve20) => setTimeout(resolve20, ms));
|
|
28717
28892
|
}
|
|
28718
28893
|
function enrichExportBackingRowsWaitMs() {
|
|
28719
28894
|
const raw = process.env.DEEPLINE_ENRICH_EXPORT_BACKING_ROWS_WAIT_MS?.trim();
|
|
@@ -35153,7 +35328,7 @@ async function readHiddenLine(prompt, streams = {}) {
|
|
|
35153
35328
|
}
|
|
35154
35329
|
let value = "";
|
|
35155
35330
|
inputStream.resume();
|
|
35156
|
-
return await new Promise((
|
|
35331
|
+
return await new Promise((resolve20, reject) => {
|
|
35157
35332
|
let settled = false;
|
|
35158
35333
|
const cleanup = () => {
|
|
35159
35334
|
inputStream.off("data", onData);
|
|
@@ -35171,7 +35346,7 @@ async function readHiddenLine(prompt, streams = {}) {
|
|
|
35171
35346
|
settled = true;
|
|
35172
35347
|
outputStream.write("\n");
|
|
35173
35348
|
cleanup();
|
|
35174
|
-
|
|
35349
|
+
resolve20(line);
|
|
35175
35350
|
};
|
|
35176
35351
|
const fail = (error) => {
|
|
35177
35352
|
if (settled) return;
|
|
@@ -35344,22 +35519,149 @@ Examples:
|
|
|
35344
35519
|
// src/cli/commands/setup.ts
|
|
35345
35520
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
35346
35521
|
import {
|
|
35347
|
-
existsSync as
|
|
35348
|
-
lstatSync,
|
|
35522
|
+
existsSync as existsSync14,
|
|
35523
|
+
lstatSync as lstatSync2,
|
|
35349
35524
|
mkdirSync as mkdirSync11,
|
|
35350
|
-
readFileSync as
|
|
35351
|
-
realpathSync as
|
|
35352
|
-
rmSync as rmSync4,
|
|
35525
|
+
readFileSync as readFileSync14,
|
|
35526
|
+
realpathSync as realpathSync4,
|
|
35353
35527
|
writeFileSync as writeFileSync14
|
|
35354
35528
|
} from "fs";
|
|
35355
35529
|
import { homedir as homedir9 } from "os";
|
|
35356
|
-
import {
|
|
35530
|
+
import { dirname as dirname16, join as join16, resolve as resolve15 } from "path";
|
|
35531
|
+
|
|
35532
|
+
// src/cli/installation-lifecycle.ts
|
|
35533
|
+
import {
|
|
35534
|
+
existsSync as existsSync11,
|
|
35535
|
+
lstatSync,
|
|
35536
|
+
readFileSync as readFileSync11,
|
|
35537
|
+
realpathSync as realpathSync3,
|
|
35538
|
+
rmSync as rmSync4
|
|
35539
|
+
} from "fs";
|
|
35540
|
+
import { basename as basename6, dirname as dirname13, join as join13, relative as relative5, resolve as resolve14 } from "path";
|
|
35541
|
+
var nodeFileSystem = {
|
|
35542
|
+
exists: existsSync11,
|
|
35543
|
+
isSymbolicLink(path) {
|
|
35544
|
+
try {
|
|
35545
|
+
return lstatSync(path).isSymbolicLink();
|
|
35546
|
+
} catch {
|
|
35547
|
+
return false;
|
|
35548
|
+
}
|
|
35549
|
+
},
|
|
35550
|
+
read(path) {
|
|
35551
|
+
try {
|
|
35552
|
+
return readFileSync11(path, "utf8");
|
|
35553
|
+
} catch {
|
|
35554
|
+
return "";
|
|
35555
|
+
}
|
|
35556
|
+
},
|
|
35557
|
+
realpath(path) {
|
|
35558
|
+
try {
|
|
35559
|
+
return realpathSync3(path);
|
|
35560
|
+
} catch {
|
|
35561
|
+
return null;
|
|
35562
|
+
}
|
|
35563
|
+
},
|
|
35564
|
+
remove(path) {
|
|
35565
|
+
rmSync4(path, { force: true });
|
|
35566
|
+
}
|
|
35567
|
+
};
|
|
35568
|
+
function inspectLauncher(path, fileSystem = nodeFileSystem) {
|
|
35569
|
+
if (!fileSystem.exists(path)) {
|
|
35570
|
+
return { ownership: "missing", resolvedPath: null };
|
|
35571
|
+
}
|
|
35572
|
+
const resolvedPath = fileSystem.realpath(path);
|
|
35573
|
+
if (CliInstallation.isNpmPackagePath(resolvedPath)) {
|
|
35574
|
+
return { ownership: "npm", resolvedPath };
|
|
35575
|
+
}
|
|
35576
|
+
if (fileSystem.isSymbolicLink(path)) {
|
|
35577
|
+
return { ownership: "symlink", resolvedPath };
|
|
35578
|
+
}
|
|
35579
|
+
const content = fileSystem.read(path);
|
|
35580
|
+
if (content.includes("DEEPLINE_REAL_BINARY") && content.includes("DEEPLINE_ACTIVE_FILE")) {
|
|
35581
|
+
return { ownership: "installer_legacy", resolvedPath };
|
|
35582
|
+
}
|
|
35583
|
+
return { ownership: "user", resolvedPath };
|
|
35584
|
+
}
|
|
35585
|
+
var CliInstallation = class _CliInstallation {
|
|
35586
|
+
constructor(input2) {
|
|
35587
|
+
this.input = input2;
|
|
35588
|
+
}
|
|
35589
|
+
static forUser(input2) {
|
|
35590
|
+
return new _CliInstallation({
|
|
35591
|
+
...input2,
|
|
35592
|
+
fileSystem: input2.fileSystem ?? nodeFileSystem
|
|
35593
|
+
});
|
|
35594
|
+
}
|
|
35595
|
+
static isNpmPackagePath(path) {
|
|
35596
|
+
return path?.includes(`${join13("node_modules", "deepline")}`) ?? false;
|
|
35597
|
+
}
|
|
35598
|
+
launcher(path) {
|
|
35599
|
+
return inspectLauncher(path, this.input.fileSystem);
|
|
35600
|
+
}
|
|
35601
|
+
retiredArtifacts() {
|
|
35602
|
+
const hostDir = join13(
|
|
35603
|
+
this.input.home,
|
|
35604
|
+
".local",
|
|
35605
|
+
"deepline",
|
|
35606
|
+
this.input.baseUrlSlug
|
|
35607
|
+
);
|
|
35608
|
+
const legacyLauncherPath = join13(
|
|
35609
|
+
this.input.home,
|
|
35610
|
+
".local",
|
|
35611
|
+
"bin",
|
|
35612
|
+
"deepline"
|
|
35613
|
+
);
|
|
35614
|
+
const installerCommandPath = this.input.fileSystem.read(join13(hostDir, "sdk", ".command-path")).trim();
|
|
35615
|
+
const ownedInstallerCommand = isOwnedInstallerCommandPath({
|
|
35616
|
+
hostDir,
|
|
35617
|
+
commandPath: installerCommandPath
|
|
35618
|
+
});
|
|
35619
|
+
const legacyLauncher = this.launcher(legacyLauncherPath);
|
|
35620
|
+
const candidates = [
|
|
35621
|
+
...legacyLauncher.ownership === "installer_legacy" ? [legacyLauncherPath] : [],
|
|
35622
|
+
join13(this.input.home, ".local", "bin", "deepline-real"),
|
|
35623
|
+
join13(hostDir, "bin", "deepline"),
|
|
35624
|
+
join13(hostDir, "bin", "deepline-real"),
|
|
35625
|
+
join13(hostDir, "cli", ".install-method"),
|
|
35626
|
+
join13(hostDir, "cli", ".version"),
|
|
35627
|
+
join13(hostDir, "sdk", ".install-method"),
|
|
35628
|
+
join13(hostDir, "sdk", ".command-path"),
|
|
35629
|
+
...ownedInstallerCommand ? [
|
|
35630
|
+
installerCommandPath,
|
|
35631
|
+
join13(dirname13(installerCommandPath), "deepline-sdk")
|
|
35632
|
+
] : []
|
|
35633
|
+
];
|
|
35634
|
+
return {
|
|
35635
|
+
paths: candidates.filter((path) => {
|
|
35636
|
+
if (!this.input.fileSystem.exists(path)) return false;
|
|
35637
|
+
return this.launcher(path).ownership !== "npm";
|
|
35638
|
+
})
|
|
35639
|
+
};
|
|
35640
|
+
}
|
|
35641
|
+
removeRetiredArtifacts() {
|
|
35642
|
+
return removeArtifacts(this.retiredArtifacts(), this.input.fileSystem);
|
|
35643
|
+
}
|
|
35644
|
+
};
|
|
35645
|
+
function removeArtifacts(plan, fileSystem) {
|
|
35646
|
+
for (const path of plan.paths) {
|
|
35647
|
+
fileSystem.remove(path);
|
|
35648
|
+
}
|
|
35649
|
+
return plan.paths;
|
|
35650
|
+
}
|
|
35651
|
+
function isOwnedInstallerCommandPath(input2) {
|
|
35652
|
+
if (!input2.commandPath || basename6(input2.commandPath) !== "deepline") {
|
|
35653
|
+
return false;
|
|
35654
|
+
}
|
|
35655
|
+
const commandPath = resolve14(input2.commandPath);
|
|
35656
|
+
const fromHost = relative5(resolve14(input2.hostDir), commandPath);
|
|
35657
|
+
return fromHost !== "" && fromHost !== ".." && !fromHost.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
|
|
35658
|
+
}
|
|
35357
35659
|
|
|
35358
35660
|
// src/cli/commands/skills.ts
|
|
35359
35661
|
import { spawn as spawn3 } from "child_process";
|
|
35360
|
-
import { existsSync as
|
|
35662
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync10, readFileSync as readFileSync13, writeFileSync as writeFileSync13 } from "fs";
|
|
35361
35663
|
import { homedir as homedir8 } from "os";
|
|
35362
|
-
import { dirname as
|
|
35664
|
+
import { dirname as dirname15, join as join15 } from "path";
|
|
35363
35665
|
|
|
35364
35666
|
// ../../shared_libs/cli/install-commands.json
|
|
35365
35667
|
var install_commands_default = {
|
|
@@ -35464,13 +35766,13 @@ function buildSkillsAddArgs(baseUrl, skillName, options = {}) {
|
|
|
35464
35766
|
// src/cli/skills-sync.ts
|
|
35465
35767
|
import { spawn as spawn2, spawnSync } from "child_process";
|
|
35466
35768
|
import {
|
|
35467
|
-
existsSync as
|
|
35769
|
+
existsSync as existsSync12,
|
|
35468
35770
|
mkdirSync as mkdirSync9,
|
|
35469
|
-
readFileSync as
|
|
35771
|
+
readFileSync as readFileSync12,
|
|
35470
35772
|
unlinkSync,
|
|
35471
35773
|
writeFileSync as writeFileSync12
|
|
35472
35774
|
} from "fs";
|
|
35473
|
-
import { dirname as
|
|
35775
|
+
import { dirname as dirname14, join as join14 } from "path";
|
|
35474
35776
|
|
|
35475
35777
|
// src/cli/windows-arg-escape.ts
|
|
35476
35778
|
var CMD_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
|
|
@@ -35505,10 +35807,10 @@ function shouldSkipSkillsSync() {
|
|
|
35505
35807
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
35506
35808
|
}
|
|
35507
35809
|
function unavailableSkillsNoticePath(baseUrl) {
|
|
35508
|
-
return
|
|
35810
|
+
return join14(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
|
|
35509
35811
|
}
|
|
35510
35812
|
function failedSkillsSyncPath(baseUrl, agents) {
|
|
35511
|
-
return
|
|
35813
|
+
return join14(
|
|
35512
35814
|
sdkCliStateDirPath(baseUrl),
|
|
35513
35815
|
`skills-sync-failed-${agents.join("-")}-version`
|
|
35514
35816
|
);
|
|
@@ -35518,14 +35820,14 @@ function hasMarkedSkillsSyncVersion(path, version) {
|
|
|
35518
35820
|
}
|
|
35519
35821
|
function readMarkedSkillsSyncVersion(path) {
|
|
35520
35822
|
try {
|
|
35521
|
-
return
|
|
35823
|
+
return existsSync12(path) ? readFileSync12(path, "utf-8").trim() : "";
|
|
35522
35824
|
} catch {
|
|
35523
35825
|
return "";
|
|
35524
35826
|
}
|
|
35525
35827
|
}
|
|
35526
35828
|
function writeMarkedSkillsSyncVersion(path, version) {
|
|
35527
35829
|
try {
|
|
35528
|
-
mkdirSync9(
|
|
35830
|
+
mkdirSync9(dirname14(path), { recursive: true });
|
|
35529
35831
|
writeFileSync12(path, `${version}
|
|
35530
35832
|
`, "utf-8");
|
|
35531
35833
|
} catch {
|
|
@@ -35554,7 +35856,7 @@ function hasFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
|
35554
35856
|
);
|
|
35555
35857
|
}
|
|
35556
35858
|
function hasFailedAutomaticSkillsSync(baseUrl, agents) {
|
|
35557
|
-
return
|
|
35859
|
+
return existsSync12(failedSkillsSyncPath(baseUrl, agents));
|
|
35558
35860
|
}
|
|
35559
35861
|
function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
35560
35862
|
writeMarkedSkillsSyncVersion(
|
|
@@ -35679,7 +35981,7 @@ function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NA
|
|
|
35679
35981
|
return commands;
|
|
35680
35982
|
}
|
|
35681
35983
|
function runOneSkillsInstall(install) {
|
|
35682
|
-
return new Promise((
|
|
35984
|
+
return new Promise((resolve20) => {
|
|
35683
35985
|
const plan = resolveSkillsInstallSpawn(install);
|
|
35684
35986
|
const child = spawn2(plan.command, plan.args, {
|
|
35685
35987
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -35691,7 +35993,7 @@ function runOneSkillsInstall(install) {
|
|
|
35691
35993
|
stderr += chunk.toString("utf-8");
|
|
35692
35994
|
});
|
|
35693
35995
|
child.on("error", (error) => {
|
|
35694
|
-
|
|
35996
|
+
resolve20({
|
|
35695
35997
|
ok: false,
|
|
35696
35998
|
detail: `failed to start ${install.command}: ${error.message}`,
|
|
35697
35999
|
manualCommand: install.manualCommand
|
|
@@ -35699,11 +36001,11 @@ function runOneSkillsInstall(install) {
|
|
|
35699
36001
|
});
|
|
35700
36002
|
child.on("close", (code) => {
|
|
35701
36003
|
if (code === 0) {
|
|
35702
|
-
|
|
36004
|
+
resolve20({ ok: true, detail: "", manualCommand: install.manualCommand });
|
|
35703
36005
|
return;
|
|
35704
36006
|
}
|
|
35705
36007
|
const detail = stderr.trim();
|
|
35706
|
-
|
|
36008
|
+
resolve20({
|
|
35707
36009
|
ok: false,
|
|
35708
36010
|
detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
|
|
35709
36011
|
manualCommand: install.manualCommand
|
|
@@ -35905,13 +36207,13 @@ function detectSkillsAgents(input2) {
|
|
|
35905
36207
|
];
|
|
35906
36208
|
const detected = AGENT_MARKERS.filter(
|
|
35907
36209
|
(marker) => roots.some(
|
|
35908
|
-
(root) => marker.paths.some((path) =>
|
|
36210
|
+
(root) => marker.paths.some((path) => existsSync13(join15(root, path)))
|
|
35909
36211
|
)
|
|
35910
36212
|
).map((marker) => marker.agent);
|
|
35911
36213
|
return detected.length > 0 ? detected : ["*"];
|
|
35912
36214
|
}
|
|
35913
36215
|
function skillsStatePathForScope(baseUrl, scope, root) {
|
|
35914
|
-
return scope === "local" && root ?
|
|
36216
|
+
return scope === "local" && root ? join15(root, ".deepline", "setup", "skills.json") : join15(sdkCliStateDirPath(baseUrl), "skills-install.json");
|
|
35915
36217
|
}
|
|
35916
36218
|
function buildSkillsPlan(input2) {
|
|
35917
36219
|
const scopeArgs = input2.scope === "global" ? ["--global"] : [];
|
|
@@ -35978,14 +36280,14 @@ function isSkillsPlanCurrent(plan, state) {
|
|
|
35978
36280
|
}
|
|
35979
36281
|
function readSkillsInstallState(path) {
|
|
35980
36282
|
try {
|
|
35981
|
-
const parsed = JSON.parse(
|
|
36283
|
+
const parsed = JSON.parse(readFileSync13(path, "utf8"));
|
|
35982
36284
|
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
35983
36285
|
} catch {
|
|
35984
36286
|
return null;
|
|
35985
36287
|
}
|
|
35986
36288
|
}
|
|
35987
36289
|
function runProcess(command, args, cwd) {
|
|
35988
|
-
return new Promise((
|
|
36290
|
+
return new Promise((resolve20, reject) => {
|
|
35989
36291
|
const plan = resolveShellSpawn(command, args);
|
|
35990
36292
|
const child = spawn3(plan.command, plan.args, {
|
|
35991
36293
|
cwd,
|
|
@@ -36004,7 +36306,7 @@ function runProcess(command, args, cwd) {
|
|
|
36004
36306
|
process.stderr.write(`${SKILLS_NPX_PACKAGE} exited ${code}.
|
|
36005
36307
|
`);
|
|
36006
36308
|
}
|
|
36007
|
-
|
|
36309
|
+
resolve20(code ?? 1);
|
|
36008
36310
|
});
|
|
36009
36311
|
});
|
|
36010
36312
|
}
|
|
@@ -36122,7 +36424,7 @@ async function runSkillsCommand(options, dependencies = {}) {
|
|
|
36122
36424
|
);
|
|
36123
36425
|
return 5;
|
|
36124
36426
|
}
|
|
36125
|
-
mkdirSync10(
|
|
36427
|
+
mkdirSync10(dirname15(plan.statePath), { recursive: true });
|
|
36126
36428
|
writeFileSync13(
|
|
36127
36429
|
plan.statePath,
|
|
36128
36430
|
`${JSON.stringify(
|
|
@@ -36260,7 +36562,7 @@ function phasesFromLegacyStatus(status) {
|
|
|
36260
36562
|
function readSetupState(input2) {
|
|
36261
36563
|
try {
|
|
36262
36564
|
const parsed = JSON.parse(
|
|
36263
|
-
|
|
36565
|
+
readFileSync14(
|
|
36264
36566
|
setupStatePath(input2.baseUrl, input2.scope, input2.root),
|
|
36265
36567
|
"utf8"
|
|
36266
36568
|
)
|
|
@@ -36336,7 +36638,7 @@ function buildPendingAuthorizationOutput(input2) {
|
|
|
36336
36638
|
};
|
|
36337
36639
|
}
|
|
36338
36640
|
function setupStatePath(baseUrl, scope, root) {
|
|
36339
|
-
return scope === "local" && root ?
|
|
36641
|
+
return scope === "local" && root ? join16(root, ".deepline", "setup", "state.json") : join16(sdkCliStateDirPath(baseUrl), "setup.json");
|
|
36340
36642
|
}
|
|
36341
36643
|
async function captureStdout2(run) {
|
|
36342
36644
|
let stdout = "";
|
|
@@ -36365,57 +36667,16 @@ function asRecord3(value) {
|
|
|
36365
36667
|
}
|
|
36366
36668
|
function safeRead(path) {
|
|
36367
36669
|
try {
|
|
36368
|
-
return
|
|
36670
|
+
return readFileSync14(path, "utf8");
|
|
36369
36671
|
} catch {
|
|
36370
36672
|
return "";
|
|
36371
36673
|
}
|
|
36372
36674
|
}
|
|
36373
|
-
function isNpmManagedDeeplinePath(path) {
|
|
36374
|
-
try {
|
|
36375
|
-
return realpathSync3(path).includes(`${join15("node_modules", "deepline")}`);
|
|
36376
|
-
} catch {
|
|
36377
|
-
return false;
|
|
36378
|
-
}
|
|
36379
|
-
}
|
|
36380
|
-
function isInstallerManagedLegacyLauncher(path) {
|
|
36381
|
-
const content = safeRead(path);
|
|
36382
|
-
return content.includes("DEEPLINE_REAL_BINARY") && content.includes("DEEPLINE_ACTIVE_FILE");
|
|
36383
|
-
}
|
|
36384
36675
|
function removeKnownLegacyPaths(baseUrl) {
|
|
36385
|
-
|
|
36386
|
-
|
|
36387
|
-
|
|
36388
|
-
|
|
36389
|
-
join15(hostDir, "sdk", ".command-path")
|
|
36390
|
-
).trim();
|
|
36391
|
-
const relativeInstallerCommandPath = installerCommandPath ? relative5(resolve14(hostDir), resolve14(installerCommandPath)) : "";
|
|
36392
|
-
const isOwnedInstallerCommand = Boolean(installerCommandPath) && relativeInstallerCommandPath !== "" && !relativeInstallerCommandPath.startsWith(
|
|
36393
|
-
`..${process.platform === "win32" ? "\\" : "/"}`
|
|
36394
|
-
) && relativeInstallerCommandPath !== ".." && basename6(installerCommandPath) === "deepline";
|
|
36395
|
-
const candidates = [
|
|
36396
|
-
...isInstallerManagedLegacyLauncher(legacyLauncherPath) ? [legacyLauncherPath] : [],
|
|
36397
|
-
join15(home, ".local", "bin", "deepline-real"),
|
|
36398
|
-
join15(hostDir, "bin", "deepline"),
|
|
36399
|
-
join15(hostDir, "bin", "deepline-real"),
|
|
36400
|
-
join15(hostDir, "cli", ".install-method"),
|
|
36401
|
-
join15(hostDir, "cli", ".version"),
|
|
36402
|
-
join15(hostDir, "sdk", ".install-method"),
|
|
36403
|
-
join15(hostDir, "sdk", ".command-path"),
|
|
36404
|
-
...isOwnedInstallerCommand ? [
|
|
36405
|
-
installerCommandPath,
|
|
36406
|
-
join15(dirname15(installerCommandPath), "deepline-sdk")
|
|
36407
|
-
] : []
|
|
36408
|
-
];
|
|
36409
|
-
const removed = [];
|
|
36410
|
-
for (const path of candidates) {
|
|
36411
|
-
if (!existsSync13(path)) continue;
|
|
36412
|
-
if (path === installerCommandPath && isNpmManagedDeeplinePath(path)) {
|
|
36413
|
-
continue;
|
|
36414
|
-
}
|
|
36415
|
-
rmSync4(path, { force: true });
|
|
36416
|
-
removed.push(path);
|
|
36417
|
-
}
|
|
36418
|
-
return removed;
|
|
36676
|
+
return CliInstallation.forUser({
|
|
36677
|
+
baseUrlSlug: baseUrlSlug(baseUrl),
|
|
36678
|
+
home: homedir9()
|
|
36679
|
+
}).removeRetiredArtifacts();
|
|
36419
36680
|
}
|
|
36420
36681
|
function resolvePathCommands(command) {
|
|
36421
36682
|
const lookup = spawnSync2(
|
|
@@ -36425,7 +36686,7 @@ function resolvePathCommands(command) {
|
|
|
36425
36686
|
);
|
|
36426
36687
|
return [
|
|
36427
36688
|
...new Set(
|
|
36428
|
-
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) =>
|
|
36689
|
+
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => resolve15(path))
|
|
36429
36690
|
)
|
|
36430
36691
|
];
|
|
36431
36692
|
}
|
|
@@ -36435,7 +36696,7 @@ function resolvePathCommand(command) {
|
|
|
36435
36696
|
function isHomebrewFormulaCommand(path) {
|
|
36436
36697
|
let resolvedPath = path;
|
|
36437
36698
|
try {
|
|
36438
|
-
resolvedPath =
|
|
36699
|
+
resolvedPath = realpathSync4(path);
|
|
36439
36700
|
} catch {
|
|
36440
36701
|
return false;
|
|
36441
36702
|
}
|
|
@@ -36446,7 +36707,7 @@ function isHomebrewFormulaCommand(path) {
|
|
|
36446
36707
|
function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
36447
36708
|
const platform3 = dependencies.platform ?? process.platform;
|
|
36448
36709
|
const run = dependencies.spawn ?? spawnSync2;
|
|
36449
|
-
const pathExists = dependencies.exists ??
|
|
36710
|
+
const pathExists = dependencies.exists ?? existsSync14;
|
|
36450
36711
|
const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
|
|
36451
36712
|
const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
|
|
36452
36713
|
if (homebrewCommand) return homebrewCommand;
|
|
@@ -36458,7 +36719,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
|
36458
36719
|
if (prefix.status !== 0) return null;
|
|
36459
36720
|
const root = String(prefix.stdout ?? "").trim();
|
|
36460
36721
|
if (!root) return null;
|
|
36461
|
-
const candidates = platform3 === "win32" ? [
|
|
36722
|
+
const candidates = platform3 === "win32" ? [join16(root, "deepline.cmd"), join16(root, "deepline")] : [join16(root, "bin", "deepline")];
|
|
36462
36723
|
return candidates.find((candidate) => pathExists(candidate)) ?? null;
|
|
36463
36724
|
}
|
|
36464
36725
|
function inspectGlobalCliAvailability(input2) {
|
|
@@ -36471,20 +36732,20 @@ function inspectGlobalCliAvailability(input2) {
|
|
|
36471
36732
|
}
|
|
36472
36733
|
function pathsResolveToSameFile(left, right) {
|
|
36473
36734
|
try {
|
|
36474
|
-
return
|
|
36735
|
+
return realpathSync4(left) === realpathSync4(right);
|
|
36475
36736
|
} catch {
|
|
36476
|
-
return
|
|
36737
|
+
return resolve15(left) === resolve15(right);
|
|
36477
36738
|
}
|
|
36478
36739
|
}
|
|
36479
36740
|
function isKnownDeeplineCommand(path) {
|
|
36480
|
-
const entrypoint = process.argv[1] ?
|
|
36741
|
+
const entrypoint = process.argv[1] ? resolve15(process.argv[1]) : "";
|
|
36481
36742
|
let resolvedPath = path;
|
|
36482
36743
|
try {
|
|
36483
|
-
resolvedPath =
|
|
36744
|
+
resolvedPath = realpathSync4(path);
|
|
36484
36745
|
} catch {
|
|
36485
36746
|
}
|
|
36486
36747
|
if (entrypoint && resolvedPath === entrypoint) return true;
|
|
36487
|
-
if (resolvedPath.includes(`${
|
|
36748
|
+
if (resolvedPath.includes(`${join16("node_modules", "deepline")}`)) return true;
|
|
36488
36749
|
const content = safeRead(path);
|
|
36489
36750
|
return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
|
|
36490
36751
|
}
|
|
@@ -36492,9 +36753,9 @@ function inspectPathConflict() {
|
|
|
36492
36753
|
const commandPath = resolvePathCommand("deepline");
|
|
36493
36754
|
if (!commandPath || isKnownDeeplineCommand(commandPath)) return null;
|
|
36494
36755
|
try {
|
|
36495
|
-
if (
|
|
36496
|
-
const target =
|
|
36497
|
-
if (target.includes(`${
|
|
36756
|
+
if (lstatSync2(commandPath).isSymbolicLink()) {
|
|
36757
|
+
const target = realpathSync4(commandPath);
|
|
36758
|
+
if (target.includes(`${join16("node_modules", "deepline")}`)) return null;
|
|
36498
36759
|
}
|
|
36499
36760
|
} catch {
|
|
36500
36761
|
}
|
|
@@ -36502,7 +36763,7 @@ function inspectPathConflict() {
|
|
|
36502
36763
|
}
|
|
36503
36764
|
function writeSetupState(input2) {
|
|
36504
36765
|
const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
|
|
36505
|
-
mkdirSync11(
|
|
36766
|
+
mkdirSync11(dirname16(path), { recursive: true });
|
|
36506
36767
|
writeFileSync14(
|
|
36507
36768
|
path,
|
|
36508
36769
|
`${JSON.stringify(
|
|
@@ -36543,7 +36804,7 @@ function failSetupPhase(phases, phase, code) {
|
|
|
36543
36804
|
phases[phase] = { status: "failed", code };
|
|
36544
36805
|
}
|
|
36545
36806
|
function rollbackCommand(scope, root) {
|
|
36546
|
-
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(
|
|
36807
|
+
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(join16(root, ".deepline", "runtime"))}` : "";
|
|
36547
36808
|
return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
|
|
36548
36809
|
}
|
|
36549
36810
|
function setupResumeCommand(baseUrl, scope) {
|
|
@@ -36630,12 +36891,12 @@ function buildDoctorAssessment(input2) {
|
|
|
36630
36891
|
const connected = input2.authStatus.payload?.connected === true;
|
|
36631
36892
|
const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
|
|
36632
36893
|
const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
|
|
36633
|
-
const runningCliPath = process.argv[1] ?
|
|
36894
|
+
const runningCliPath = process.argv[1] ? resolve15(process.argv[1]) : null;
|
|
36634
36895
|
const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
|
|
36635
36896
|
const pathGlobalCli = globalCli?.path ?? null;
|
|
36636
36897
|
const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
|
|
36637
36898
|
const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
|
|
36638
|
-
input2.root && runningCliPath?.includes(
|
|
36899
|
+
input2.root && runningCliPath?.includes(join16(input2.root, ".deepline", "runtime"))
|
|
36639
36900
|
);
|
|
36640
36901
|
const checks = {
|
|
36641
36902
|
cli: {
|
|
@@ -37163,15 +37424,15 @@ Examples:
|
|
|
37163
37424
|
|
|
37164
37425
|
// src/cli/update-preferences.ts
|
|
37165
37426
|
import {
|
|
37166
|
-
existsSync as
|
|
37427
|
+
existsSync as existsSync15,
|
|
37167
37428
|
mkdirSync as mkdirSync12,
|
|
37168
|
-
readFileSync as
|
|
37429
|
+
readFileSync as readFileSync15,
|
|
37169
37430
|
renameSync,
|
|
37170
37431
|
rmSync as rmSync5,
|
|
37171
37432
|
writeFileSync as writeFileSync15
|
|
37172
37433
|
} from "fs";
|
|
37173
37434
|
import { homedir as homedir10 } from "os";
|
|
37174
|
-
import { dirname as
|
|
37435
|
+
import { dirname as dirname17, join as join17 } from "path";
|
|
37175
37436
|
var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
|
|
37176
37437
|
var CLI_UPDATE_MESSAGES = [
|
|
37177
37438
|
{
|
|
@@ -37200,7 +37461,7 @@ function unreadablePreferences(path, error) {
|
|
|
37200
37461
|
};
|
|
37201
37462
|
}
|
|
37202
37463
|
function cliUpdatePreferencesPath(homeDir2 = homedir10()) {
|
|
37203
|
-
return
|
|
37464
|
+
return join17(
|
|
37204
37465
|
homeDir2,
|
|
37205
37466
|
".local",
|
|
37206
37467
|
"deepline",
|
|
@@ -37210,9 +37471,9 @@ function cliUpdatePreferencesPath(homeDir2 = homedir10()) {
|
|
|
37210
37471
|
}
|
|
37211
37472
|
function readCliUpdatePreferences(homeDir2 = homedir10()) {
|
|
37212
37473
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
37213
|
-
if (!
|
|
37474
|
+
if (!existsSync15(path)) return defaultPreferences();
|
|
37214
37475
|
try {
|
|
37215
|
-
const parsed = JSON.parse(
|
|
37476
|
+
const parsed = JSON.parse(readFileSync15(path, "utf8"));
|
|
37216
37477
|
return {
|
|
37217
37478
|
schemaVersion: UPDATE_PREFERENCES_SCHEMA_VERSION,
|
|
37218
37479
|
autoUpdateEnabled: typeof parsed.autoUpdateEnabled === "boolean" ? parsed.autoUpdateEnabled : true,
|
|
@@ -37228,7 +37489,7 @@ function readCliUpdatePreferences(homeDir2 = homedir10()) {
|
|
|
37228
37489
|
function writeCliUpdatePreferences(preferences, homeDir2 = homedir10()) {
|
|
37229
37490
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
37230
37491
|
const tempPath = `${path}.${process.pid}.tmp`;
|
|
37231
|
-
mkdirSync12(
|
|
37492
|
+
mkdirSync12(dirname17(path), { recursive: true });
|
|
37232
37493
|
try {
|
|
37233
37494
|
writeFileSync15(tempPath, `${JSON.stringify(preferences, null, 2)}
|
|
37234
37495
|
`, {
|
|
@@ -37288,10 +37549,10 @@ function consumePendingCliUpdateMessages(homeDir2 = homedir10()) {
|
|
|
37288
37549
|
// src/cli/commands/update.ts
|
|
37289
37550
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "child_process";
|
|
37290
37551
|
import {
|
|
37291
|
-
existsSync as
|
|
37552
|
+
existsSync as existsSync17,
|
|
37292
37553
|
mkdirSync as mkdirSync13,
|
|
37293
|
-
realpathSync as
|
|
37294
|
-
readFileSync as
|
|
37554
|
+
realpathSync as realpathSync5,
|
|
37555
|
+
readFileSync as readFileSync17,
|
|
37295
37556
|
renameSync as renameSync2,
|
|
37296
37557
|
rmSync as rmSync6,
|
|
37297
37558
|
unlinkSync as unlinkSync2,
|
|
@@ -37300,17 +37561,17 @@ import {
|
|
|
37300
37561
|
import { homedir as homedir11 } from "os";
|
|
37301
37562
|
import {
|
|
37302
37563
|
basename as basename7,
|
|
37303
|
-
dirname as
|
|
37564
|
+
dirname as dirname18,
|
|
37304
37565
|
isAbsolute as isAbsolute7,
|
|
37305
|
-
join as
|
|
37566
|
+
join as join19,
|
|
37306
37567
|
relative as relative7,
|
|
37307
|
-
resolve as
|
|
37568
|
+
resolve as resolve17
|
|
37308
37569
|
} from "path";
|
|
37309
37570
|
|
|
37310
37571
|
// src/cli/install-integrity.ts
|
|
37311
37572
|
import { createRequire } from "module";
|
|
37312
|
-
import { existsSync as
|
|
37313
|
-
import { isAbsolute as isAbsolute6, join as
|
|
37573
|
+
import { existsSync as existsSync16, readFileSync as readFileSync16, statSync as statSync5 } from "fs";
|
|
37574
|
+
import { isAbsolute as isAbsolute6, join as join18, relative as relative6, resolve as resolve16 } from "path";
|
|
37314
37575
|
var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
|
|
37315
37576
|
"dist/cli/index.mjs",
|
|
37316
37577
|
"dist/index.mjs",
|
|
@@ -37335,15 +37596,15 @@ function safeRelativePath(value) {
|
|
|
37335
37596
|
}
|
|
37336
37597
|
function resolveContainedPath(root, value) {
|
|
37337
37598
|
if (!safeRelativePath(value)) return null;
|
|
37338
|
-
const target =
|
|
37339
|
-
const relativeTarget = relative6(
|
|
37599
|
+
const target = resolve16(root, value);
|
|
37600
|
+
const relativeTarget = relative6(resolve16(root), target);
|
|
37340
37601
|
if (!relativeTarget || relativeTarget.startsWith("..") || isAbsolute6(relativeTarget)) {
|
|
37341
37602
|
return null;
|
|
37342
37603
|
}
|
|
37343
37604
|
return target;
|
|
37344
37605
|
}
|
|
37345
37606
|
function parseJson(path) {
|
|
37346
|
-
return JSON.parse(
|
|
37607
|
+
return JSON.parse(readFileSync16(path, "utf8"));
|
|
37347
37608
|
}
|
|
37348
37609
|
function isFile(path) {
|
|
37349
37610
|
try {
|
|
@@ -37353,7 +37614,7 @@ function isFile(path) {
|
|
|
37353
37614
|
}
|
|
37354
37615
|
}
|
|
37355
37616
|
function readManifest(packageRoot) {
|
|
37356
|
-
const packageJsonPath =
|
|
37617
|
+
const packageJsonPath = join18(packageRoot, "package.json");
|
|
37357
37618
|
let packageJson;
|
|
37358
37619
|
try {
|
|
37359
37620
|
packageJson = parseJson(packageJsonPath);
|
|
@@ -37361,7 +37622,7 @@ function readManifest(packageRoot) {
|
|
|
37361
37622
|
return {
|
|
37362
37623
|
mode: "manifest",
|
|
37363
37624
|
invalidReason: `invalid Deepline package metadata: ${error.message}`,
|
|
37364
|
-
missing:
|
|
37625
|
+
missing: existsSync16(packageJsonPath) ? [] : ["deepline/package.json"]
|
|
37365
37626
|
};
|
|
37366
37627
|
}
|
|
37367
37628
|
if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
|
|
@@ -37427,8 +37688,8 @@ function readManifest(packageRoot) {
|
|
|
37427
37688
|
return { mode: "manifest", manifest };
|
|
37428
37689
|
}
|
|
37429
37690
|
function inspectSdkSidecarInstall(versionDir) {
|
|
37430
|
-
const nodeModulesRoot =
|
|
37431
|
-
const packageRoot =
|
|
37691
|
+
const nodeModulesRoot = join18(versionDir, "node_modules");
|
|
37692
|
+
const packageRoot = join18(nodeModulesRoot, "deepline");
|
|
37432
37693
|
const manifestResult = readManifest(packageRoot);
|
|
37433
37694
|
if ("invalidReason" in manifestResult) {
|
|
37434
37695
|
return {
|
|
@@ -37439,8 +37700,8 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
37439
37700
|
};
|
|
37440
37701
|
}
|
|
37441
37702
|
const missing = [
|
|
37442
|
-
...manifestResult.manifest.packageFiles.filter((path) => !isFile(
|
|
37443
|
-
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(
|
|
37703
|
+
...manifestResult.manifest.packageFiles.filter((path) => !isFile(join18(packageRoot, path))).map((path) => `deepline/${path}`),
|
|
37704
|
+
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(join18(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
|
|
37444
37705
|
];
|
|
37445
37706
|
return {
|
|
37446
37707
|
ok: missing.length === 0,
|
|
@@ -37451,7 +37712,7 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
37451
37712
|
}
|
|
37452
37713
|
function probeSdkSidecarEsbuild(versionDir) {
|
|
37453
37714
|
try {
|
|
37454
|
-
const requireFromInstall = createRequire(
|
|
37715
|
+
const requireFromInstall = createRequire(join18(versionDir, "package.json"));
|
|
37455
37716
|
const esbuild = requireFromInstall("esbuild");
|
|
37456
37717
|
if (typeof esbuild.transformSync !== "function") {
|
|
37457
37718
|
return "esbuild does not export transformSync";
|
|
@@ -37526,7 +37787,7 @@ function sidecarStateDir(input2) {
|
|
|
37526
37787
|
if (!scope || scope.includes("/") || scope.includes("\\")) {
|
|
37527
37788
|
return null;
|
|
37528
37789
|
}
|
|
37529
|
-
return
|
|
37790
|
+
return join19(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
|
|
37530
37791
|
}
|
|
37531
37792
|
function sidecarRegistryUrl(hostUrl) {
|
|
37532
37793
|
let url;
|
|
@@ -37553,7 +37814,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
|
|
|
37553
37814
|
}
|
|
37554
37815
|
function readOptionalText(path) {
|
|
37555
37816
|
try {
|
|
37556
|
-
return
|
|
37817
|
+
return readFileSync17(path, "utf8").trim();
|
|
37557
37818
|
} catch {
|
|
37558
37819
|
return "";
|
|
37559
37820
|
}
|
|
@@ -37562,18 +37823,18 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37562
37823
|
const stateDir = sidecarStateDir(options);
|
|
37563
37824
|
if (!stateDir) return null;
|
|
37564
37825
|
const relativeEntrypoint = relative7(
|
|
37565
|
-
|
|
37566
|
-
|
|
37826
|
+
resolve17(stateDir),
|
|
37827
|
+
resolve17(options.entrypoint)
|
|
37567
37828
|
);
|
|
37568
37829
|
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute7(relativeEntrypoint)) {
|
|
37569
37830
|
return null;
|
|
37570
37831
|
}
|
|
37571
|
-
const installMethod = readOptionalText(
|
|
37832
|
+
const installMethod = readOptionalText(join19(stateDir, ".install-method"));
|
|
37572
37833
|
if (installMethod !== "python-sidecar") return null;
|
|
37573
37834
|
const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
|
|
37574
37835
|
const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
|
|
37575
|
-
const nodeBin = readOptionalText(
|
|
37576
|
-
const sidecarPath = readOptionalText(
|
|
37836
|
+
const nodeBin = readOptionalText(join19(stateDir, ".node-bin")) || process.execPath;
|
|
37837
|
+
const sidecarPath = readOptionalText(join19(stateDir, ".command-path")) || join19(
|
|
37577
37838
|
stateDir,
|
|
37578
37839
|
"bin",
|
|
37579
37840
|
process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
|
|
@@ -37581,7 +37842,7 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37581
37842
|
const packageSpec = options.packageSpec || "deepline@latest";
|
|
37582
37843
|
const npmCommand = "npm";
|
|
37583
37844
|
const registryUrl = sidecarRegistryUrl(hostUrl);
|
|
37584
|
-
const versionDir =
|
|
37845
|
+
const versionDir = join19(stateDir, "versions", "<version>");
|
|
37585
37846
|
const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
|
|
37586
37847
|
return {
|
|
37587
37848
|
kind: "python-sidecar",
|
|
@@ -37597,16 +37858,16 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37597
37858
|
};
|
|
37598
37859
|
}
|
|
37599
37860
|
function findRepoBackedSdkRoot(startPath) {
|
|
37600
|
-
let current =
|
|
37861
|
+
let current = resolve17(startPath);
|
|
37601
37862
|
while (true) {
|
|
37602
|
-
if (
|
|
37603
|
-
const parent2 =
|
|
37604
|
-
return basename7(parent2) === "packages" && basename7(current) === "sdk" ?
|
|
37863
|
+
if (existsSync17(join19(current, "package.json")) && existsSync17(join19(current, "bin", "deepline-dev.ts"))) {
|
|
37864
|
+
const parent2 = dirname18(current);
|
|
37865
|
+
return basename7(parent2) === "packages" && basename7(current) === "sdk" ? dirname18(parent2) : parent2;
|
|
37605
37866
|
}
|
|
37606
|
-
if (
|
|
37867
|
+
if (existsSync17(join19(current, "sdk", "package.json")) && existsSync17(join19(current, "sdk", "bin", "deepline-dev.ts"))) {
|
|
37607
37868
|
return current;
|
|
37608
37869
|
}
|
|
37609
|
-
const parent =
|
|
37870
|
+
const parent = dirname18(current);
|
|
37610
37871
|
if (parent === current) return null;
|
|
37611
37872
|
current = parent;
|
|
37612
37873
|
}
|
|
@@ -37614,9 +37875,9 @@ function findRepoBackedSdkRoot(startPath) {
|
|
|
37614
37875
|
function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
|
|
37615
37876
|
const normalized = (() => {
|
|
37616
37877
|
try {
|
|
37617
|
-
return
|
|
37878
|
+
return realpathSync5(entrypoint);
|
|
37618
37879
|
} catch {
|
|
37619
|
-
return
|
|
37880
|
+
return resolve17(entrypoint);
|
|
37620
37881
|
}
|
|
37621
37882
|
})();
|
|
37622
37883
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -37631,10 +37892,10 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
|
|
|
37631
37892
|
const directPrefix = prefixParts.join("/").toLowerCase();
|
|
37632
37893
|
const knownWindowsPrefixes = [
|
|
37633
37894
|
env.npm_config_prefix,
|
|
37634
|
-
env.APPDATA ?
|
|
37635
|
-
].filter((value) => Boolean(value)).map((value) =>
|
|
37895
|
+
env.APPDATA ? join19(env.APPDATA, "npm") : void 0
|
|
37896
|
+
].filter((value) => Boolean(value)).map((value) => resolve17(value).replace(/\\/g, "/").toLowerCase());
|
|
37636
37897
|
if (!knownWindowsPrefixes.includes(
|
|
37637
|
-
|
|
37898
|
+
resolve17(directPrefix).replace(/\\/g, "/").toLowerCase()
|
|
37638
37899
|
)) {
|
|
37639
37900
|
return null;
|
|
37640
37901
|
}
|
|
@@ -37647,9 +37908,9 @@ function normalizedNpmPrefix(value) {
|
|
|
37647
37908
|
if (!trimmed) return null;
|
|
37648
37909
|
const normalized = (() => {
|
|
37649
37910
|
try {
|
|
37650
|
-
return
|
|
37911
|
+
return realpathSync5(resolve17(trimmed));
|
|
37651
37912
|
} catch {
|
|
37652
|
-
return
|
|
37913
|
+
return resolve17(trimmed);
|
|
37653
37914
|
}
|
|
37654
37915
|
})().replace(/\\/g, "/");
|
|
37655
37916
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
@@ -37672,9 +37933,9 @@ function resolveNpmGlobalPrefix(env) {
|
|
|
37672
37933
|
function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
37673
37934
|
const normalized = (() => {
|
|
37674
37935
|
try {
|
|
37675
|
-
return
|
|
37936
|
+
return realpathSync5(entrypoint);
|
|
37676
37937
|
} catch {
|
|
37677
|
-
return
|
|
37938
|
+
return resolve17(entrypoint);
|
|
37678
37939
|
}
|
|
37679
37940
|
})();
|
|
37680
37941
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -37684,8 +37945,8 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
|
37684
37945
|
function resolveUpdatePlan(options = {}) {
|
|
37685
37946
|
const env = options.env ?? process.env;
|
|
37686
37947
|
const homeDir2 = options.homeDir ?? homedir11();
|
|
37687
|
-
const entrypoint = options.entrypoint ?? (process.argv[1] ?
|
|
37688
|
-
const sourceRoot = entrypoint ? findRepoBackedSdkRoot(
|
|
37948
|
+
const entrypoint = options.entrypoint ?? (process.argv[1] ? resolve17(process.argv[1]) : "");
|
|
37949
|
+
const sourceRoot = entrypoint ? findRepoBackedSdkRoot(dirname18(entrypoint)) : null;
|
|
37689
37950
|
if (sourceRoot) {
|
|
37690
37951
|
return {
|
|
37691
37952
|
kind: "source",
|
|
@@ -37736,9 +37997,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
|
|
|
37736
37997
|
function autoUpdateFailurePath(plan) {
|
|
37737
37998
|
if (plan.kind === "source" || plan.kind === "homebrew") return null;
|
|
37738
37999
|
if (plan.kind === "python-sidecar") {
|
|
37739
|
-
return
|
|
38000
|
+
return join19(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
|
|
37740
38001
|
}
|
|
37741
|
-
return
|
|
38002
|
+
return join19(
|
|
37742
38003
|
homedir11(),
|
|
37743
38004
|
".local",
|
|
37744
38005
|
"deepline",
|
|
@@ -37756,7 +38017,7 @@ function readAutoUpdateFailure(plan) {
|
|
|
37756
38017
|
if (!path) return null;
|
|
37757
38018
|
try {
|
|
37758
38019
|
const parsed = JSON.parse(
|
|
37759
|
-
|
|
38020
|
+
readFileSync17(path, "utf8")
|
|
37760
38021
|
);
|
|
37761
38022
|
if ((parsed.kind === "npm-global" || parsed.kind === "python-sidecar") && typeof parsed.packageSpec === "string" && typeof parsed.failedAt === "string" && typeof parsed.exitCode === "number" && typeof parsed.manualCommand === "string") {
|
|
37762
38023
|
return parsed;
|
|
@@ -37777,7 +38038,7 @@ function writeAutoUpdateFailure(plan, exitCode) {
|
|
|
37777
38038
|
manualCommand: plan.manualCommand
|
|
37778
38039
|
};
|
|
37779
38040
|
try {
|
|
37780
|
-
mkdirSync13(
|
|
38041
|
+
mkdirSync13(dirname18(path), { recursive: true });
|
|
37781
38042
|
writeFileSync16(path, `${JSON.stringify(marker, null, 2)}
|
|
37782
38043
|
`, "utf8");
|
|
37783
38044
|
} catch {
|
|
@@ -37825,7 +38086,7 @@ function safeVersionSegment(value) {
|
|
|
37825
38086
|
return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
|
|
37826
38087
|
}
|
|
37827
38088
|
function entryPathInVersionDir(versionDir) {
|
|
37828
|
-
return
|
|
38089
|
+
return join19(
|
|
37829
38090
|
versionDir,
|
|
37830
38091
|
"node_modules",
|
|
37831
38092
|
"deepline",
|
|
@@ -37835,14 +38096,14 @@ function entryPathInVersionDir(versionDir) {
|
|
|
37835
38096
|
);
|
|
37836
38097
|
}
|
|
37837
38098
|
function installedPackageVersion(versionDir) {
|
|
37838
|
-
const packageJsonPath =
|
|
38099
|
+
const packageJsonPath = join19(
|
|
37839
38100
|
versionDir,
|
|
37840
38101
|
"node_modules",
|
|
37841
38102
|
"deepline",
|
|
37842
38103
|
"package.json"
|
|
37843
38104
|
);
|
|
37844
38105
|
try {
|
|
37845
|
-
const parsed = JSON.parse(
|
|
38106
|
+
const parsed = JSON.parse(readFileSync17(packageJsonPath, "utf8"));
|
|
37846
38107
|
return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
|
|
37847
38108
|
} catch {
|
|
37848
38109
|
return "";
|
|
@@ -37957,16 +38218,16 @@ async function runNpmInstallWithRegistryFallback(input2) {
|
|
|
37957
38218
|
return first.exitCode;
|
|
37958
38219
|
}
|
|
37959
38220
|
function writeSidecarLauncher(input2) {
|
|
37960
|
-
mkdirSync13(
|
|
37961
|
-
const packageRoot =
|
|
37962
|
-
const versionDir =
|
|
38221
|
+
mkdirSync13(dirname18(input2.path), { recursive: true });
|
|
38222
|
+
const packageRoot = dirname18(dirname18(dirname18(input2.entryPath)));
|
|
38223
|
+
const versionDir = dirname18(dirname18(packageRoot));
|
|
37963
38224
|
const esbuildProbe = "const {createRequire}=require('node:module');const path=require('node:path');const req=createRequire(path.join(process.argv[1],'package.json'));const result=req('esbuild').transformSync('const value: number = 1;',{loader:'ts'});if(!result||typeof result.code!=='string')process.exit(3);";
|
|
37964
38225
|
const criticalPaths = [
|
|
37965
38226
|
...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
|
|
37966
|
-
(path) =>
|
|
38227
|
+
(path) => join19(packageRoot, path)
|
|
37967
38228
|
),
|
|
37968
38229
|
...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
|
|
37969
|
-
(path) =>
|
|
38230
|
+
(path) => join19(versionDir, "node_modules", path)
|
|
37970
38231
|
)
|
|
37971
38232
|
];
|
|
37972
38233
|
if (process.platform === "win32") {
|
|
@@ -38020,17 +38281,17 @@ function writeSidecarLauncher(input2) {
|
|
|
38020
38281
|
);
|
|
38021
38282
|
}
|
|
38022
38283
|
async function runPythonSidecarUpdatePlan(plan) {
|
|
38023
|
-
const versionsDir =
|
|
38024
|
-
const tempDir =
|
|
38284
|
+
const versionsDir = join19(plan.stateDir, "versions");
|
|
38285
|
+
const tempDir = join19(
|
|
38025
38286
|
versionsDir,
|
|
38026
38287
|
`.tmp-sdk-update-${process.pid}-${Date.now()}`
|
|
38027
38288
|
);
|
|
38028
38289
|
rmSync6(tempDir, { recursive: true, force: true });
|
|
38029
38290
|
mkdirSync13(tempDir, { recursive: true });
|
|
38030
|
-
writeFileSync16(
|
|
38291
|
+
writeFileSync16(join19(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
|
|
38031
38292
|
const env = {
|
|
38032
38293
|
...process.env,
|
|
38033
|
-
PATH: `${
|
|
38294
|
+
PATH: `${dirname18(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
|
|
38034
38295
|
};
|
|
38035
38296
|
const installResult = await runCommand(
|
|
38036
38297
|
plan.npmCommand,
|
|
@@ -38067,7 +38328,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38067
38328
|
rmSync6(tempDir, { recursive: true, force: true });
|
|
38068
38329
|
return 1;
|
|
38069
38330
|
}
|
|
38070
|
-
const finalDir =
|
|
38331
|
+
const finalDir = join19(versionsDir, installedVersion);
|
|
38071
38332
|
const finalEntryPath = entryPathInVersionDir(finalDir);
|
|
38072
38333
|
const finalFailure = sidecarInstallFailure(finalDir);
|
|
38073
38334
|
let backupDir = null;
|
|
@@ -38075,8 +38336,8 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38075
38336
|
rmSync6(tempDir, { recursive: true, force: true });
|
|
38076
38337
|
} else {
|
|
38077
38338
|
let shouldPublishTemp = true;
|
|
38078
|
-
if (
|
|
38079
|
-
backupDir =
|
|
38339
|
+
if (existsSync17(finalDir)) {
|
|
38340
|
+
backupDir = join19(
|
|
38080
38341
|
versionsDir,
|
|
38081
38342
|
`.backup-${installedVersion}-${process.pid}-${Date.now()}`
|
|
38082
38343
|
);
|
|
@@ -38109,7 +38370,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38109
38370
|
backupDir = null;
|
|
38110
38371
|
} else {
|
|
38111
38372
|
let restoreFailure = "";
|
|
38112
|
-
if (backupDir &&
|
|
38373
|
+
if (backupDir && existsSync17(backupDir) && !existsSync17(finalDir)) {
|
|
38113
38374
|
try {
|
|
38114
38375
|
renameSync2(backupDir, finalDir);
|
|
38115
38376
|
backupDir = null;
|
|
@@ -38128,7 +38389,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38128
38389
|
}
|
|
38129
38390
|
const publishedFailure = sidecarStructureFailure(finalDir);
|
|
38130
38391
|
if (publishedFailure) {
|
|
38131
|
-
if (backupDir &&
|
|
38392
|
+
if (backupDir && existsSync17(backupDir)) {
|
|
38132
38393
|
rmSync6(finalDir, { recursive: true, force: true });
|
|
38133
38394
|
try {
|
|
38134
38395
|
renameSync2(backupDir, finalDir);
|
|
@@ -38151,27 +38412,27 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38151
38412
|
entryPath: finalEntryPath
|
|
38152
38413
|
});
|
|
38153
38414
|
writeFileSync16(
|
|
38154
|
-
|
|
38415
|
+
join19(plan.stateDir, ".version"),
|
|
38155
38416
|
`${installedVersion}
|
|
38156
38417
|
`,
|
|
38157
38418
|
"utf8"
|
|
38158
38419
|
);
|
|
38159
38420
|
writeFileSync16(
|
|
38160
|
-
|
|
38421
|
+
join19(plan.stateDir, ".install-method"),
|
|
38161
38422
|
"python-sidecar\n",
|
|
38162
38423
|
"utf8"
|
|
38163
38424
|
);
|
|
38164
38425
|
writeFileSync16(
|
|
38165
|
-
|
|
38426
|
+
join19(plan.stateDir, ".command-path"),
|
|
38166
38427
|
`${plan.sidecarPath}
|
|
38167
38428
|
`,
|
|
38168
38429
|
"utf8"
|
|
38169
38430
|
);
|
|
38170
|
-
writeFileSync16(
|
|
38171
|
-
writeFileSync16(
|
|
38431
|
+
writeFileSync16(join19(plan.stateDir, ".runner"), "node\n", "utf8");
|
|
38432
|
+
writeFileSync16(join19(plan.stateDir, ".node-bin"), `${plan.nodeBin}
|
|
38172
38433
|
`, "utf8");
|
|
38173
38434
|
writeFileSync16(
|
|
38174
|
-
|
|
38435
|
+
join19(plan.stateDir, ".entry-path"),
|
|
38175
38436
|
`${finalEntryPath}
|
|
38176
38437
|
`,
|
|
38177
38438
|
"utf8"
|
|
@@ -39100,13 +39361,13 @@ chooses the connected Slack channel or member and the events it receives.
|
|
|
39100
39361
|
import { Option as Option2 } from "commander";
|
|
39101
39362
|
import {
|
|
39102
39363
|
chmodSync,
|
|
39103
|
-
existsSync as
|
|
39364
|
+
existsSync as existsSync18,
|
|
39104
39365
|
mkdtempSync,
|
|
39105
|
-
readFileSync as
|
|
39366
|
+
readFileSync as readFileSync18,
|
|
39106
39367
|
writeFileSync as writeFileSync18
|
|
39107
39368
|
} from "fs";
|
|
39108
39369
|
import { tmpdir as tmpdir5 } from "os";
|
|
39109
|
-
import { join as
|
|
39370
|
+
import { join as join21, resolve as resolve18 } from "path";
|
|
39110
39371
|
|
|
39111
39372
|
// src/tool-output.ts
|
|
39112
39373
|
import {
|
|
@@ -39117,7 +39378,7 @@ import {
|
|
|
39117
39378
|
writeSync
|
|
39118
39379
|
} from "fs";
|
|
39119
39380
|
import { homedir as homedir12 } from "os";
|
|
39120
|
-
import { dirname as
|
|
39381
|
+
import { dirname as dirname19, join as join20 } from "path";
|
|
39121
39382
|
function isPlainObject(value) {
|
|
39122
39383
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
39123
39384
|
}
|
|
@@ -39244,19 +39505,19 @@ function projectRowOutput(conversion) {
|
|
|
39244
39505
|
};
|
|
39245
39506
|
}
|
|
39246
39507
|
function ensureOutputDir() {
|
|
39247
|
-
const outputDir =
|
|
39508
|
+
const outputDir = join20(homedir12(), ".local", "share", "deepline", "data");
|
|
39248
39509
|
mkdirSync14(outputDir, { recursive: true });
|
|
39249
39510
|
return outputDir;
|
|
39250
39511
|
}
|
|
39251
39512
|
function writeJsonOutputFile(payload, stem) {
|
|
39252
39513
|
const outputDir = ensureOutputDir();
|
|
39253
|
-
const outputPath =
|
|
39514
|
+
const outputPath = join20(outputDir, `${stem}_${Date.now()}.json`);
|
|
39254
39515
|
writeFileSync17(outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
39255
39516
|
return outputPath;
|
|
39256
39517
|
}
|
|
39257
39518
|
function writeCsvOutputFile(rows, stem, options) {
|
|
39258
|
-
const outputPath = options?.outPath ? options.outPath :
|
|
39259
|
-
mkdirSync14(
|
|
39519
|
+
const outputPath = options?.outPath ? options.outPath : join20(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
39520
|
+
mkdirSync14(dirname19(outputPath), { recursive: true });
|
|
39260
39521
|
const columns = columnsForRows(rows);
|
|
39261
39522
|
const escapeCell = (value) => {
|
|
39262
39523
|
const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
|
|
@@ -39399,6 +39660,78 @@ function arrayField(value, key) {
|
|
|
39399
39660
|
return Array.isArray(candidate) ? candidate : [];
|
|
39400
39661
|
}
|
|
39401
39662
|
|
|
39663
|
+
// src/cli/tool-description.ts
|
|
39664
|
+
var Capability = class _Capability {
|
|
39665
|
+
#catalogEntry;
|
|
39666
|
+
constructor(catalogEntry) {
|
|
39667
|
+
this.#catalogEntry = catalogEntry;
|
|
39668
|
+
}
|
|
39669
|
+
static fromCatalogEntry(catalogEntry) {
|
|
39670
|
+
return new _Capability(catalogEntry);
|
|
39671
|
+
}
|
|
39672
|
+
describe() {
|
|
39673
|
+
return CapabilityDescription.fromCatalogEntry(this.#catalogEntry);
|
|
39674
|
+
}
|
|
39675
|
+
};
|
|
39676
|
+
var CapabilityDescription = class _CapabilityDescription {
|
|
39677
|
+
#catalogEntry;
|
|
39678
|
+
constructor(catalogEntry) {
|
|
39679
|
+
this.#catalogEntry = catalogEntry;
|
|
39680
|
+
}
|
|
39681
|
+
static fromCatalogEntry(catalogEntry) {
|
|
39682
|
+
return new _CapabilityDescription(catalogEntry);
|
|
39683
|
+
}
|
|
39684
|
+
/**
|
|
39685
|
+
* The customer price already resolved by the catalog. This intentionally
|
|
39686
|
+
* omits provider-price fields, even when a catalog Adapter carried them.
|
|
39687
|
+
*/
|
|
39688
|
+
customerCost() {
|
|
39689
|
+
const legacyCost = recordValue2(this.#catalogEntry.cost);
|
|
39690
|
+
const pricing = recordValue2(this.#catalogEntry.pricing);
|
|
39691
|
+
const unit = stringValue4(pricing.unit);
|
|
39692
|
+
const legacyPricingModel = stringValue4(
|
|
39693
|
+
legacyCost.pricingModel ?? legacyCost.pricing_model
|
|
39694
|
+
);
|
|
39695
|
+
const pricingModel = unit === "call" ? "fixed" : unit === "result" || unit === "page" ? `per_${unit}` : unit === "usage" ? "provider_usage" : legacyPricingModel;
|
|
39696
|
+
const canonicalCredits = numberValue(
|
|
39697
|
+
pricing.creditsPerUnit ?? pricing.credits_per_unit
|
|
39698
|
+
);
|
|
39699
|
+
const canonicalUsd = numberValue(
|
|
39700
|
+
pricing.usdPerUnit ?? pricing.usd_per_unit
|
|
39701
|
+
);
|
|
39702
|
+
return {
|
|
39703
|
+
pricingModel: pricingModel || null,
|
|
39704
|
+
unit: unit || null,
|
|
39705
|
+
displayText: stringValue4(pricing.displayText ?? pricing.display_text),
|
|
39706
|
+
summary: stringValue4(pricing.summary),
|
|
39707
|
+
billingMode: stringValue4(
|
|
39708
|
+
legacyCost.billingMode ?? legacyCost.billing_mode
|
|
39709
|
+
),
|
|
39710
|
+
billingSource: stringValue4(
|
|
39711
|
+
this.#catalogEntry.billingSource ?? this.#catalogEntry.billing_source
|
|
39712
|
+
),
|
|
39713
|
+
billingSourceLabel: stringValue4(
|
|
39714
|
+
this.#catalogEntry.billingSourceLabel ?? this.#catalogEntry.billing_source_label
|
|
39715
|
+
),
|
|
39716
|
+
deeplineCreditsPerPricingUnit: canonicalCredits ?? numberValue(
|
|
39717
|
+
this.#catalogEntry.deeplineCreditsPerPricingUnit ?? this.#catalogEntry.deepline_credits_per_pricing_unit
|
|
39718
|
+
),
|
|
39719
|
+
deeplineUsdPerPricingUnit: canonicalUsd ?? numberValue(
|
|
39720
|
+
this.#catalogEntry.deeplineUsdPerPricingUnit ?? this.#catalogEntry.deepline_usd_per_pricing_unit
|
|
39721
|
+
)
|
|
39722
|
+
};
|
|
39723
|
+
}
|
|
39724
|
+
};
|
|
39725
|
+
function recordValue2(value) {
|
|
39726
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
39727
|
+
}
|
|
39728
|
+
function stringValue4(value) {
|
|
39729
|
+
return typeof value === "string" && value.trim() ? value : null;
|
|
39730
|
+
}
|
|
39731
|
+
function numberValue(value) {
|
|
39732
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
39733
|
+
}
|
|
39734
|
+
|
|
39402
39735
|
// src/cli/commands/tools.ts
|
|
39403
39736
|
var TOOL_COMMAND_TEMPLATES = {
|
|
39404
39737
|
describe: "deepline tools describe <toolId>",
|
|
@@ -40319,7 +40652,7 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
|
|
|
40319
40652
|
const extractedValues = extractionContractEntries(
|
|
40320
40653
|
arrayField2(toolExecutionResult, "extractedValues", "extracted_values")
|
|
40321
40654
|
);
|
|
40322
|
-
const pricing =
|
|
40655
|
+
const pricing = Capability.fromCatalogEntry(tool).describe().customerCost();
|
|
40323
40656
|
const deprecation = recordField2(tool, "deprecation");
|
|
40324
40657
|
const replacementToolId = stringField2(
|
|
40325
40658
|
deprecation,
|
|
@@ -40370,38 +40703,6 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
|
|
|
40370
40703
|
...starterScript ? { starterScript } : {}
|
|
40371
40704
|
};
|
|
40372
40705
|
}
|
|
40373
|
-
function toolPricingContractForDescribe(tool) {
|
|
40374
|
-
const legacyCost = recordField2(tool, "cost");
|
|
40375
|
-
const pricingValue = tool.pricing;
|
|
40376
|
-
const hasCanonicalPricing = isRecord12(pricingValue);
|
|
40377
|
-
const canonicalPricing = hasCanonicalPricing ? pricingValue : {};
|
|
40378
|
-
const unit = stringField2(canonicalPricing, "unit");
|
|
40379
|
-
const legacyPricingModel = stringField2(
|
|
40380
|
-
legacyCost,
|
|
40381
|
-
"pricingModel",
|
|
40382
|
-
"pricing_model"
|
|
40383
|
-
);
|
|
40384
|
-
const pricingModel = unit === "call" ? "fixed" : unit === "result" || unit === "page" ? `per_${unit}` : unit === "usage" ? "provider_usage" : legacyPricingModel;
|
|
40385
|
-
return {
|
|
40386
|
-
pricingModel: pricingModel || null,
|
|
40387
|
-
unit: unit || null,
|
|
40388
|
-
displayText: stringField2(canonicalPricing, "displayText", "display_text") || null,
|
|
40389
|
-
summary: stringField2(canonicalPricing, "summary") || null,
|
|
40390
|
-
billingMode: stringField2(legacyCost, "billingMode", "billing_mode") || null,
|
|
40391
|
-
billingSource: stringField2(tool, "billingSource", "billing_source") || null,
|
|
40392
|
-
billingSourceLabel: stringField2(tool, "billingSourceLabel", "billing_source_label") || null,
|
|
40393
|
-
deeplineCreditsPerPricingUnit: hasCanonicalPricing ? numberField2(canonicalPricing, "creditsPerUnit", "credits_per_unit") : numberField2(
|
|
40394
|
-
tool,
|
|
40395
|
-
"deeplineCreditsPerPricingUnit",
|
|
40396
|
-
"deepline_credits_per_pricing_unit"
|
|
40397
|
-
),
|
|
40398
|
-
deeplineUsdPerPricingUnit: hasCanonicalPricing ? numberField2(canonicalPricing, "usdPerUnit", "usd_per_unit") : numberField2(
|
|
40399
|
-
tool,
|
|
40400
|
-
"deeplineUsdPerPricingUnit",
|
|
40401
|
-
"deepline_usd_per_pricing_unit"
|
|
40402
|
-
)
|
|
40403
|
-
};
|
|
40404
|
-
}
|
|
40405
40706
|
function extractionContractEntries(entries) {
|
|
40406
40707
|
return entries.flatMap((entry) => {
|
|
40407
40708
|
if (!isRecord12(entry)) return [];
|
|
@@ -40854,6 +41155,7 @@ function toolMetadataJsonForDescribe(tool, requestedToolId) {
|
|
|
40854
41155
|
toolId,
|
|
40855
41156
|
provider: tool.provider,
|
|
40856
41157
|
displayName: tool.displayName,
|
|
41158
|
+
cost: Capability.fromCatalogEntry(tool).describe().customerCost(),
|
|
40857
41159
|
usageGuidance,
|
|
40858
41160
|
runtimeOutputHelp: {
|
|
40859
41161
|
contract: "tools describe shows declared schema and Deepline getters; it is not an observed provider response.",
|
|
@@ -41184,11 +41486,11 @@ function normalizeOutputFormat(raw) {
|
|
|
41184
41486
|
}
|
|
41185
41487
|
function resolveAtFilePath(rawPath) {
|
|
41186
41488
|
const trimmed = rawPath.trim();
|
|
41187
|
-
const resolved =
|
|
41188
|
-
if (
|
|
41489
|
+
const resolved = resolve18(trimmed);
|
|
41490
|
+
if (existsSync18(resolved)) return resolved;
|
|
41189
41491
|
if (process.platform !== "win32" && trimmed.includes("\\")) {
|
|
41190
|
-
const normalized =
|
|
41191
|
-
if (
|
|
41492
|
+
const normalized = resolve18(trimmed.replace(/\\/g, "/"));
|
|
41493
|
+
if (existsSync18(normalized)) return normalized;
|
|
41192
41494
|
}
|
|
41193
41495
|
return resolved;
|
|
41194
41496
|
}
|
|
@@ -41199,7 +41501,7 @@ function readJsonArgument(raw, flagName) {
|
|
|
41199
41501
|
throw new Error(`Invalid ${flagName} value: empty @file path.`);
|
|
41200
41502
|
}
|
|
41201
41503
|
try {
|
|
41202
|
-
return
|
|
41504
|
+
return readFileSync18(resolveAtFilePath(filePath), "utf8").replace(
|
|
41203
41505
|
/^\uFEFF/,
|
|
41204
41506
|
""
|
|
41205
41507
|
);
|
|
@@ -41276,7 +41578,7 @@ function parseExecuteOptions(args) {
|
|
|
41276
41578
|
continue;
|
|
41277
41579
|
}
|
|
41278
41580
|
if ((arg === "--out" || arg === "-o") && args[index + 1]) {
|
|
41279
|
-
outPath =
|
|
41581
|
+
outPath = resolve18(args[++index]);
|
|
41280
41582
|
continue;
|
|
41281
41583
|
}
|
|
41282
41584
|
throw new Error(`Unknown option: ${arg}`);
|
|
@@ -41306,9 +41608,9 @@ function starterScriptJson(script) {
|
|
|
41306
41608
|
function seedToolListScript(input2) {
|
|
41307
41609
|
const stem = safeFileStem(input2.toolId);
|
|
41308
41610
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
41309
|
-
const scriptDir = mkdtempSync(
|
|
41611
|
+
const scriptDir = mkdtempSync(join21(tmpdir5(), "deepline-workflow-seed-"));
|
|
41310
41612
|
chmodSync(scriptDir, 448);
|
|
41311
|
-
const scriptPath =
|
|
41613
|
+
const scriptPath = join21(scriptDir, fileName);
|
|
41312
41614
|
const projectDir = `deepline/projects/${stem}-workflow`;
|
|
41313
41615
|
const playName = `${stem}-workflow`;
|
|
41314
41616
|
const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
|
|
@@ -41777,7 +42079,7 @@ Examples:
|
|
|
41777
42079
|
|
|
41778
42080
|
// src/cli/commands/workflow.ts
|
|
41779
42081
|
import { mkdir as mkdir5, readFile as readFile4, writeFile as writeFile5 } from "fs/promises";
|
|
41780
|
-
import { dirname as
|
|
42082
|
+
import { dirname as dirname20, join as join22, resolve as resolve19 } from "path";
|
|
41781
42083
|
|
|
41782
42084
|
// src/cli/workflow-to-play.ts
|
|
41783
42085
|
import { createHash as createHash5 } from "crypto";
|
|
@@ -41994,7 +42296,7 @@ function readStatus(payload) {
|
|
|
41994
42296
|
}
|
|
41995
42297
|
async function readJsonOption(payload, file) {
|
|
41996
42298
|
if (file) {
|
|
41997
|
-
const raw = await readFile4(
|
|
42299
|
+
const raw = await readFile4(resolve19(file), "utf8");
|
|
41998
42300
|
return JSON.parse(raw);
|
|
41999
42301
|
}
|
|
42000
42302
|
if (payload) {
|
|
@@ -42028,8 +42330,8 @@ async function transformOne(api, workflowId, outDir, publish) {
|
|
|
42028
42330
|
revision.config,
|
|
42029
42331
|
{ workflowName: workflow.name, version: revision.version }
|
|
42030
42332
|
);
|
|
42031
|
-
const file =
|
|
42032
|
-
await mkdir5(
|
|
42333
|
+
const file = join22(resolve19(outDir), `${compiled.playName}.play.ts`);
|
|
42334
|
+
await mkdir5(dirname20(file), { recursive: true });
|
|
42033
42335
|
await writeFile5(file, compiled.sourceCode, "utf8");
|
|
42034
42336
|
let published = false;
|
|
42035
42337
|
if (publish) {
|
|
@@ -42404,7 +42706,7 @@ function isDowngradeAutoUpdateResponse(response) {
|
|
|
42404
42706
|
return compareSemver(target, current) < 0;
|
|
42405
42707
|
}
|
|
42406
42708
|
function relaunchCurrentCommand(plan) {
|
|
42407
|
-
return new Promise((
|
|
42709
|
+
return new Promise((resolve20) => {
|
|
42408
42710
|
const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
|
|
42409
42711
|
const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
|
|
42410
42712
|
const child = spawn5(command, args, {
|
|
@@ -42420,9 +42722,9 @@ function relaunchCurrentCommand(plan) {
|
|
|
42420
42722
|
`Deepline SDK/CLI updated, but relaunch failed: ${error.message}
|
|
42421
42723
|
`
|
|
42422
42724
|
);
|
|
42423
|
-
|
|
42725
|
+
resolve20(1);
|
|
42424
42726
|
});
|
|
42425
|
-
child.on("close", (code) =>
|
|
42727
|
+
child.on("close", (code) => resolve20(code ?? 1));
|
|
42426
42728
|
});
|
|
42427
42729
|
}
|
|
42428
42730
|
async function maybeAutoUpdateAndRelaunch(response, baseUrl) {
|
|
@@ -42813,8 +43115,8 @@ function topLevelCommandKnown(program, commandName) {
|
|
|
42813
43115
|
);
|
|
42814
43116
|
}
|
|
42815
43117
|
async function runPlayRunnerHealthCheck() {
|
|
42816
|
-
const dir = await mkdtemp2(
|
|
42817
|
-
const file =
|
|
43118
|
+
const dir = await mkdtemp2(join23(tmpdir6(), "deepline-health-play-"));
|
|
43119
|
+
const file = join23(dir, "health-check.play.ts");
|
|
42818
43120
|
try {
|
|
42819
43121
|
await writeFile6(
|
|
42820
43122
|
file,
|