deepline 0.2.20 → 0.2.21
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/cli/index.js +414 -140
- package/dist/cli/index.mjs +384 -110
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/install-integrity.json +234 -0
- package/package.json +9 -5
package/dist/cli/index.js
CHANGED
|
@@ -186,7 +186,7 @@ configureProxyFromEnv();
|
|
|
186
186
|
|
|
187
187
|
// src/cli/index.ts
|
|
188
188
|
var import_promises8 = require("fs/promises");
|
|
189
|
-
var
|
|
189
|
+
var import_node_path26 = require("path");
|
|
190
190
|
var import_node_os19 = require("os");
|
|
191
191
|
var import_commander4 = require("commander");
|
|
192
192
|
|
|
@@ -1044,7 +1044,7 @@ var SDK_RELEASE = {
|
|
|
1044
1044
|
// 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
|
|
1045
1045
|
// exposed storage-dependent synchronous access. This deliberate minor
|
|
1046
1046
|
// release keeps lazy paging semantics independent of row residency.
|
|
1047
|
-
version: "0.2.
|
|
1047
|
+
version: "0.2.21",
|
|
1048
1048
|
contracts: {
|
|
1049
1049
|
api: {
|
|
1050
1050
|
name: "sdk-http-api",
|
|
@@ -1812,7 +1812,7 @@ function decodeSseFrame(frame) {
|
|
|
1812
1812
|
return parsed;
|
|
1813
1813
|
}
|
|
1814
1814
|
function sleep(ms) {
|
|
1815
|
-
return new Promise((
|
|
1815
|
+
return new Promise((resolve19) => setTimeout(resolve19, ms));
|
|
1816
1816
|
}
|
|
1817
1817
|
function withCoworkNetworkHint(message) {
|
|
1818
1818
|
if (!isCoworkLikeSandbox2() || message.includes(COWORK_NETWORK_HINT)) {
|
|
@@ -3114,14 +3114,14 @@ async function* observeRunEvents(options) {
|
|
|
3114
3114
|
try {
|
|
3115
3115
|
for (; ; ) {
|
|
3116
3116
|
if (queue.length === 0) {
|
|
3117
|
-
const waitForItem = new Promise((
|
|
3118
|
-
wake =
|
|
3117
|
+
const waitForItem = new Promise((resolve19) => {
|
|
3118
|
+
wake = resolve19;
|
|
3119
3119
|
});
|
|
3120
3120
|
if (!sawFirstSnapshot) {
|
|
3121
3121
|
const timedOut = await Promise.race([
|
|
3122
3122
|
waitForItem.then(() => false),
|
|
3123
3123
|
new Promise(
|
|
3124
|
-
(
|
|
3124
|
+
(resolve19) => setTimeout(() => resolve19(true), OBSERVE_BOOTSTRAP_TIMEOUT_MS)
|
|
3125
3125
|
)
|
|
3126
3126
|
]);
|
|
3127
3127
|
if (timedOut && queue.length === 0) {
|
|
@@ -3431,7 +3431,7 @@ function parseEnvTestPolicyOverrides() {
|
|
|
3431
3431
|
return normalizeTestPolicyOverrides(parsed, "DEEPLINE_TEST_POLICY_OVERRIDES");
|
|
3432
3432
|
}
|
|
3433
3433
|
function sleep2(ms) {
|
|
3434
|
-
return new Promise((
|
|
3434
|
+
return new Promise((resolve19) => setTimeout(resolve19, ms));
|
|
3435
3435
|
}
|
|
3436
3436
|
function isTransientCompileManifestError(error) {
|
|
3437
3437
|
if (error instanceof DeeplineError && typeof error.statusCode === "number") {
|
|
@@ -6965,7 +6965,7 @@ function buildCandidateUrls2(url) {
|
|
|
6965
6965
|
}
|
|
6966
6966
|
}
|
|
6967
6967
|
function sleep4(ms) {
|
|
6968
|
-
return new Promise((
|
|
6968
|
+
return new Promise((resolve19) => setTimeout(resolve19, ms));
|
|
6969
6969
|
}
|
|
6970
6970
|
function printDeeplineLogo() {
|
|
6971
6971
|
if (process.stdout.isTTY && (process.stdout.columns ?? 80) >= 70) {
|
|
@@ -17058,7 +17058,7 @@ function traceCliSync(phase, fields, run) {
|
|
|
17058
17058
|
}
|
|
17059
17059
|
}
|
|
17060
17060
|
function sleep5(ms) {
|
|
17061
|
-
return new Promise((
|
|
17061
|
+
return new Promise((resolve19) => setTimeout(resolve19, ms));
|
|
17062
17062
|
}
|
|
17063
17063
|
function parseReferencedPlayTarget2(target) {
|
|
17064
17064
|
const trimmed = target.trim();
|
|
@@ -25521,7 +25521,7 @@ function emitEnrichDebug(message) {
|
|
|
25521
25521
|
);
|
|
25522
25522
|
}
|
|
25523
25523
|
function sleep6(ms) {
|
|
25524
|
-
return new Promise((
|
|
25524
|
+
return new Promise((resolve19) => setTimeout(resolve19, ms));
|
|
25525
25525
|
}
|
|
25526
25526
|
function enrichExportBackingRowsWaitMs() {
|
|
25527
25527
|
const raw = process.env.DEEPLINE_ENRICH_EXPORT_BACKING_ROWS_WAIT_MS?.trim();
|
|
@@ -31686,7 +31686,7 @@ async function readHiddenLine(prompt, streams = {}) {
|
|
|
31686
31686
|
}
|
|
31687
31687
|
let value = "";
|
|
31688
31688
|
inputStream.resume();
|
|
31689
|
-
return await new Promise((
|
|
31689
|
+
return await new Promise((resolve19, reject) => {
|
|
31690
31690
|
let settled = false;
|
|
31691
31691
|
const cleanup = () => {
|
|
31692
31692
|
inputStream.off("data", onData);
|
|
@@ -31704,7 +31704,7 @@ async function readHiddenLine(prompt, streams = {}) {
|
|
|
31704
31704
|
settled = true;
|
|
31705
31705
|
outputStream.write("\n");
|
|
31706
31706
|
cleanup();
|
|
31707
|
-
|
|
31707
|
+
resolve19(line);
|
|
31708
31708
|
};
|
|
31709
31709
|
const fail = (error) => {
|
|
31710
31710
|
if (settled) return;
|
|
@@ -35152,9 +35152,9 @@ Notes:
|
|
|
35152
35152
|
|
|
35153
35153
|
// src/cli/commands/update.ts
|
|
35154
35154
|
var import_node_child_process3 = require("child_process");
|
|
35155
|
-
var
|
|
35155
|
+
var import_node_fs20 = require("fs");
|
|
35156
35156
|
var import_node_os16 = require("os");
|
|
35157
|
-
var
|
|
35157
|
+
var import_node_path23 = require("path");
|
|
35158
35158
|
|
|
35159
35159
|
// src/cli/commands/skills.ts
|
|
35160
35160
|
var import_node_child_process2 = require("child_process");
|
|
@@ -35458,7 +35458,7 @@ function readSkillsInstallState(path) {
|
|
|
35458
35458
|
}
|
|
35459
35459
|
}
|
|
35460
35460
|
function runProcess(command, args, cwd) {
|
|
35461
|
-
return new Promise((
|
|
35461
|
+
return new Promise((resolve19, reject) => {
|
|
35462
35462
|
const plan = resolveShellSpawn(command, args);
|
|
35463
35463
|
const child = (0, import_node_child_process2.spawn)(plan.command, plan.args, {
|
|
35464
35464
|
cwd,
|
|
@@ -35477,7 +35477,7 @@ function runProcess(command, args, cwd) {
|
|
|
35477
35477
|
process.stderr.write(`skills@latest exited ${code}.
|
|
35478
35478
|
`);
|
|
35479
35479
|
}
|
|
35480
|
-
|
|
35480
|
+
resolve19(code ?? 1);
|
|
35481
35481
|
});
|
|
35482
35482
|
});
|
|
35483
35483
|
}
|
|
@@ -35671,6 +35671,166 @@ Examples:
|
|
|
35671
35671
|
});
|
|
35672
35672
|
}
|
|
35673
35673
|
|
|
35674
|
+
// src/cli/install-integrity.ts
|
|
35675
|
+
var import_node_module2 = require("module");
|
|
35676
|
+
var import_node_fs19 = require("fs");
|
|
35677
|
+
var import_node_path22 = require("path");
|
|
35678
|
+
var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
|
|
35679
|
+
"dist/cli/index.mjs",
|
|
35680
|
+
"dist/index.mjs",
|
|
35681
|
+
"dist/index.d.ts",
|
|
35682
|
+
"dist/plays/bundle-play-file.mjs",
|
|
35683
|
+
"dist/bundling-sources/shared_libs/observability/telemetry.ts",
|
|
35684
|
+
"dist/bundling-sources/shared_libs/play-runtime/backend.ts",
|
|
35685
|
+
"dist/bundling-sources/shared_libs/plays/bundling/index.ts",
|
|
35686
|
+
"dist/bundling-sources/shared_libs/tool-execution-error.ts"
|
|
35687
|
+
];
|
|
35688
|
+
var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
|
|
35689
|
+
"esbuild/package.json",
|
|
35690
|
+
"esbuild/lib/main.js"
|
|
35691
|
+
];
|
|
35692
|
+
function safeRelativePath(value) {
|
|
35693
|
+
if (typeof value !== "string" || !value || (0, import_node_path22.isAbsolute)(value)) return false;
|
|
35694
|
+
const segments = value.split(/[\\/]+/);
|
|
35695
|
+
return segments.every(
|
|
35696
|
+
(segment) => Boolean(segment) && segment !== "." && segment !== ".."
|
|
35697
|
+
);
|
|
35698
|
+
}
|
|
35699
|
+
function resolveContainedPath(root, value) {
|
|
35700
|
+
if (!safeRelativePath(value)) return null;
|
|
35701
|
+
const target = (0, import_node_path22.resolve)(root, value);
|
|
35702
|
+
const relativeTarget = (0, import_node_path22.relative)((0, import_node_path22.resolve)(root), target);
|
|
35703
|
+
if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path22.isAbsolute)(relativeTarget)) {
|
|
35704
|
+
return null;
|
|
35705
|
+
}
|
|
35706
|
+
return target;
|
|
35707
|
+
}
|
|
35708
|
+
function parseJson(path) {
|
|
35709
|
+
return JSON.parse((0, import_node_fs19.readFileSync)(path, "utf8"));
|
|
35710
|
+
}
|
|
35711
|
+
function isFile(path) {
|
|
35712
|
+
try {
|
|
35713
|
+
return (0, import_node_fs19.statSync)(path).isFile();
|
|
35714
|
+
} catch {
|
|
35715
|
+
return false;
|
|
35716
|
+
}
|
|
35717
|
+
}
|
|
35718
|
+
function readManifest(packageRoot) {
|
|
35719
|
+
const packageJsonPath = (0, import_node_path22.join)(packageRoot, "package.json");
|
|
35720
|
+
let packageJson;
|
|
35721
|
+
try {
|
|
35722
|
+
packageJson = parseJson(packageJsonPath);
|
|
35723
|
+
} catch (error) {
|
|
35724
|
+
return {
|
|
35725
|
+
mode: "manifest",
|
|
35726
|
+
invalidReason: `invalid Deepline package metadata: ${error.message}`,
|
|
35727
|
+
missing: (0, import_node_fs19.existsSync)(packageJsonPath) ? [] : ["deepline/package.json"]
|
|
35728
|
+
};
|
|
35729
|
+
}
|
|
35730
|
+
if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
|
|
35731
|
+
return {
|
|
35732
|
+
mode: "manifest",
|
|
35733
|
+
invalidReason: "invalid Deepline package metadata: expected an object"
|
|
35734
|
+
};
|
|
35735
|
+
}
|
|
35736
|
+
const metadata = packageJson;
|
|
35737
|
+
if (metadata.deepline !== void 0 && (!metadata.deepline || typeof metadata.deepline !== "object" || Array.isArray(metadata.deepline))) {
|
|
35738
|
+
return {
|
|
35739
|
+
mode: "manifest",
|
|
35740
|
+
invalidReason: "invalid Deepline package metadata: deepline must be an object"
|
|
35741
|
+
};
|
|
35742
|
+
}
|
|
35743
|
+
const declaration = metadata.deepline?.installIntegrity;
|
|
35744
|
+
if (!declaration) {
|
|
35745
|
+
return {
|
|
35746
|
+
mode: "legacy",
|
|
35747
|
+
manifest: {
|
|
35748
|
+
schemaVersion: 1,
|
|
35749
|
+
packageFiles: [...SDK_SIDECAR_CRITICAL_PACKAGE_FILES],
|
|
35750
|
+
dependencyFiles: [...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES]
|
|
35751
|
+
}
|
|
35752
|
+
};
|
|
35753
|
+
}
|
|
35754
|
+
if (declaration.schemaVersion !== 1 || !safeRelativePath(declaration.manifest)) {
|
|
35755
|
+
return {
|
|
35756
|
+
mode: "manifest",
|
|
35757
|
+
invalidReason: "invalid Deepline install-integrity declaration"
|
|
35758
|
+
};
|
|
35759
|
+
}
|
|
35760
|
+
const manifestPath = resolveContainedPath(packageRoot, declaration.manifest);
|
|
35761
|
+
if (!manifestPath || !isFile(manifestPath)) {
|
|
35762
|
+
return {
|
|
35763
|
+
mode: "manifest",
|
|
35764
|
+
invalidReason: "declared Deepline install-integrity manifest is missing",
|
|
35765
|
+
missing: [String(declaration.manifest)]
|
|
35766
|
+
};
|
|
35767
|
+
}
|
|
35768
|
+
let raw;
|
|
35769
|
+
try {
|
|
35770
|
+
raw = parseJson(manifestPath);
|
|
35771
|
+
} catch (error) {
|
|
35772
|
+
return {
|
|
35773
|
+
mode: "manifest",
|
|
35774
|
+
invalidReason: `invalid Deepline install-integrity manifest: ${error.message}`
|
|
35775
|
+
};
|
|
35776
|
+
}
|
|
35777
|
+
if (!raw || typeof raw !== "object" || raw.schemaVersion !== 1 || !Array.isArray(raw.packageFiles) || !Array.isArray(raw.dependencyFiles)) {
|
|
35778
|
+
return {
|
|
35779
|
+
mode: "manifest",
|
|
35780
|
+
invalidReason: "invalid Deepline install-integrity manifest schema"
|
|
35781
|
+
};
|
|
35782
|
+
}
|
|
35783
|
+
const manifest = raw;
|
|
35784
|
+
if (manifest.packageFiles.length === 0 || manifest.dependencyFiles.length === 0 || !manifest.packageFiles.every(safeRelativePath) || !manifest.dependencyFiles.every(safeRelativePath)) {
|
|
35785
|
+
return {
|
|
35786
|
+
mode: "manifest",
|
|
35787
|
+
invalidReason: "unsafe path in Deepline install-integrity manifest"
|
|
35788
|
+
};
|
|
35789
|
+
}
|
|
35790
|
+
return { mode: "manifest", manifest };
|
|
35791
|
+
}
|
|
35792
|
+
function inspectSdkSidecarInstall(versionDir) {
|
|
35793
|
+
const nodeModulesRoot = (0, import_node_path22.join)(versionDir, "node_modules");
|
|
35794
|
+
const packageRoot = (0, import_node_path22.join)(nodeModulesRoot, "deepline");
|
|
35795
|
+
const manifestResult = readManifest(packageRoot);
|
|
35796
|
+
if ("invalidReason" in manifestResult) {
|
|
35797
|
+
return {
|
|
35798
|
+
ok: false,
|
|
35799
|
+
missing: manifestResult.missing ?? [],
|
|
35800
|
+
invalidReason: manifestResult.invalidReason,
|
|
35801
|
+
mode: manifestResult.mode
|
|
35802
|
+
};
|
|
35803
|
+
}
|
|
35804
|
+
const missing = [
|
|
35805
|
+
...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path22.join)(packageRoot, path))).map((path) => `deepline/${path}`),
|
|
35806
|
+
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path22.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
|
|
35807
|
+
];
|
|
35808
|
+
return {
|
|
35809
|
+
ok: missing.length === 0,
|
|
35810
|
+
missing,
|
|
35811
|
+
invalidReason: null,
|
|
35812
|
+
mode: manifestResult.mode
|
|
35813
|
+
};
|
|
35814
|
+
}
|
|
35815
|
+
function probeSdkSidecarEsbuild(versionDir) {
|
|
35816
|
+
try {
|
|
35817
|
+
const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path22.join)(versionDir, "package.json"));
|
|
35818
|
+
const esbuild = requireFromInstall("esbuild");
|
|
35819
|
+
if (typeof esbuild.transformSync !== "function") {
|
|
35820
|
+
return "esbuild does not export transformSync";
|
|
35821
|
+
}
|
|
35822
|
+
const result = esbuild.transformSync("const value: number = 1;", {
|
|
35823
|
+
loader: "ts"
|
|
35824
|
+
});
|
|
35825
|
+
if (typeof result?.code !== "string") {
|
|
35826
|
+
return "esbuild transform probe returned no code";
|
|
35827
|
+
}
|
|
35828
|
+
return null;
|
|
35829
|
+
} catch (error) {
|
|
35830
|
+
return error instanceof Error ? error.message : String(error);
|
|
35831
|
+
}
|
|
35832
|
+
}
|
|
35833
|
+
|
|
35674
35834
|
// src/cli/commands/update.ts
|
|
35675
35835
|
var NPM_SDK_INSTALL_COMMON_FLAGS = [
|
|
35676
35836
|
"--no-audit",
|
|
@@ -35726,7 +35886,7 @@ function sidecarStateDir(input2) {
|
|
|
35726
35886
|
if (!scope || scope.includes("/") || scope.includes("\\")) {
|
|
35727
35887
|
return null;
|
|
35728
35888
|
}
|
|
35729
|
-
return (0,
|
|
35889
|
+
return (0, import_node_path23.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
|
|
35730
35890
|
}
|
|
35731
35891
|
function sidecarRegistryUrl(hostUrl) {
|
|
35732
35892
|
let url;
|
|
@@ -35753,7 +35913,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
|
|
|
35753
35913
|
}
|
|
35754
35914
|
function readOptionalText(path) {
|
|
35755
35915
|
try {
|
|
35756
|
-
return (0,
|
|
35916
|
+
return (0, import_node_fs20.readFileSync)(path, "utf8").trim();
|
|
35757
35917
|
} catch {
|
|
35758
35918
|
return "";
|
|
35759
35919
|
}
|
|
@@ -35761,19 +35921,19 @@ function readOptionalText(path) {
|
|
|
35761
35921
|
function resolvePythonSidecarUpdatePlan(options) {
|
|
35762
35922
|
const stateDir = sidecarStateDir(options);
|
|
35763
35923
|
if (!stateDir) return null;
|
|
35764
|
-
const relativeEntrypoint = (0,
|
|
35765
|
-
(0,
|
|
35766
|
-
(0,
|
|
35924
|
+
const relativeEntrypoint = (0, import_node_path23.relative)(
|
|
35925
|
+
(0, import_node_path23.resolve)(stateDir),
|
|
35926
|
+
(0, import_node_path23.resolve)(options.entrypoint)
|
|
35767
35927
|
);
|
|
35768
|
-
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0,
|
|
35928
|
+
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path23.isAbsolute)(relativeEntrypoint)) {
|
|
35769
35929
|
return null;
|
|
35770
35930
|
}
|
|
35771
|
-
const installMethod = readOptionalText((0,
|
|
35931
|
+
const installMethod = readOptionalText((0, import_node_path23.join)(stateDir, ".install-method"));
|
|
35772
35932
|
if (installMethod !== "python-sidecar") return null;
|
|
35773
35933
|
const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
|
|
35774
35934
|
const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
|
|
35775
|
-
const nodeBin = readOptionalText((0,
|
|
35776
|
-
const sidecarPath = readOptionalText((0,
|
|
35935
|
+
const nodeBin = readOptionalText((0, import_node_path23.join)(stateDir, ".node-bin")) || process.execPath;
|
|
35936
|
+
const sidecarPath = readOptionalText((0, import_node_path23.join)(stateDir, ".command-path")) || (0, import_node_path23.join)(
|
|
35777
35937
|
stateDir,
|
|
35778
35938
|
"bin",
|
|
35779
35939
|
process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
|
|
@@ -35781,7 +35941,7 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
35781
35941
|
const packageSpec = options.packageSpec || "deepline@latest";
|
|
35782
35942
|
const npmCommand = "npm";
|
|
35783
35943
|
const registryUrl = sidecarRegistryUrl(hostUrl);
|
|
35784
|
-
const versionDir = (0,
|
|
35944
|
+
const versionDir = (0, import_node_path23.join)(stateDir, "versions", "<version>");
|
|
35785
35945
|
const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
|
|
35786
35946
|
return {
|
|
35787
35947
|
kind: "python-sidecar",
|
|
@@ -35797,12 +35957,12 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
35797
35957
|
};
|
|
35798
35958
|
}
|
|
35799
35959
|
function findRepoBackedSdkRoot(startPath) {
|
|
35800
|
-
let current = (0,
|
|
35960
|
+
let current = (0, import_node_path23.resolve)(startPath);
|
|
35801
35961
|
while (true) {
|
|
35802
|
-
if ((0,
|
|
35962
|
+
if ((0, import_node_fs20.existsSync)((0, import_node_path23.join)(current, "sdk", "package.json")) && (0, import_node_fs20.existsSync)((0, import_node_path23.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
|
|
35803
35963
|
return current;
|
|
35804
35964
|
}
|
|
35805
|
-
const parent = (0,
|
|
35965
|
+
const parent = (0, import_node_path23.dirname)(current);
|
|
35806
35966
|
if (parent === current) return null;
|
|
35807
35967
|
current = parent;
|
|
35808
35968
|
}
|
|
@@ -35810,9 +35970,9 @@ function findRepoBackedSdkRoot(startPath) {
|
|
|
35810
35970
|
function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
|
|
35811
35971
|
const normalized = (() => {
|
|
35812
35972
|
try {
|
|
35813
|
-
return (0,
|
|
35973
|
+
return (0, import_node_fs20.realpathSync)(entrypoint);
|
|
35814
35974
|
} catch {
|
|
35815
|
-
return (0,
|
|
35975
|
+
return (0, import_node_path23.resolve)(entrypoint);
|
|
35816
35976
|
}
|
|
35817
35977
|
})();
|
|
35818
35978
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -35831,9 +35991,9 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
|
|
|
35831
35991
|
function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
35832
35992
|
const normalized = (() => {
|
|
35833
35993
|
try {
|
|
35834
|
-
return (0,
|
|
35994
|
+
return (0, import_node_fs20.realpathSync)(entrypoint);
|
|
35835
35995
|
} catch {
|
|
35836
|
-
return (0,
|
|
35996
|
+
return (0, import_node_path23.resolve)(entrypoint);
|
|
35837
35997
|
}
|
|
35838
35998
|
})();
|
|
35839
35999
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -35843,8 +36003,8 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
|
35843
36003
|
function resolveUpdatePlan(options = {}) {
|
|
35844
36004
|
const env = options.env ?? process.env;
|
|
35845
36005
|
const homeDir2 = options.homeDir ?? (0, import_node_os16.homedir)();
|
|
35846
|
-
const entrypoint = options.entrypoint ?? (process.argv[1] ? (0,
|
|
35847
|
-
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0,
|
|
36006
|
+
const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path23.resolve)(process.argv[1]) : "");
|
|
36007
|
+
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path23.dirname)(entrypoint)) : null;
|
|
35848
36008
|
if (sourceRoot) {
|
|
35849
36009
|
return {
|
|
35850
36010
|
kind: "source",
|
|
@@ -35891,9 +36051,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
|
|
|
35891
36051
|
function autoUpdateFailurePath(plan) {
|
|
35892
36052
|
if (plan.kind === "source" || plan.kind === "homebrew") return null;
|
|
35893
36053
|
if (plan.kind === "python-sidecar") {
|
|
35894
|
-
return (0,
|
|
36054
|
+
return (0, import_node_path23.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
|
|
35895
36055
|
}
|
|
35896
|
-
return (0,
|
|
36056
|
+
return (0, import_node_path23.join)(
|
|
35897
36057
|
(0, import_node_os16.homedir)(),
|
|
35898
36058
|
".local",
|
|
35899
36059
|
"deepline",
|
|
@@ -35911,7 +36071,7 @@ function readAutoUpdateFailure(plan) {
|
|
|
35911
36071
|
if (!path) return null;
|
|
35912
36072
|
try {
|
|
35913
36073
|
const parsed = JSON.parse(
|
|
35914
|
-
(0,
|
|
36074
|
+
(0, import_node_fs20.readFileSync)(path, "utf8")
|
|
35915
36075
|
);
|
|
35916
36076
|
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") {
|
|
35917
36077
|
return parsed;
|
|
@@ -35932,8 +36092,8 @@ function writeAutoUpdateFailure(plan, exitCode) {
|
|
|
35932
36092
|
manualCommand: plan.manualCommand
|
|
35933
36093
|
};
|
|
35934
36094
|
try {
|
|
35935
|
-
(0,
|
|
35936
|
-
(0,
|
|
36095
|
+
(0, import_node_fs20.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
|
|
36096
|
+
(0, import_node_fs20.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
|
|
35937
36097
|
`, "utf8");
|
|
35938
36098
|
} catch {
|
|
35939
36099
|
}
|
|
@@ -35942,7 +36102,7 @@ function clearAutoUpdateFailure(plan) {
|
|
|
35942
36102
|
const path = autoUpdateFailurePath(plan);
|
|
35943
36103
|
if (!path) return;
|
|
35944
36104
|
try {
|
|
35945
|
-
(0,
|
|
36105
|
+
(0, import_node_fs20.unlinkSync)(path);
|
|
35946
36106
|
} catch {
|
|
35947
36107
|
}
|
|
35948
36108
|
}
|
|
@@ -35980,7 +36140,7 @@ function safeVersionSegment(value) {
|
|
|
35980
36140
|
return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
|
|
35981
36141
|
}
|
|
35982
36142
|
function entryPathInVersionDir(versionDir) {
|
|
35983
|
-
return (0,
|
|
36143
|
+
return (0, import_node_path23.join)(
|
|
35984
36144
|
versionDir,
|
|
35985
36145
|
"node_modules",
|
|
35986
36146
|
"deepline",
|
|
@@ -35990,19 +36150,36 @@ function entryPathInVersionDir(versionDir) {
|
|
|
35990
36150
|
);
|
|
35991
36151
|
}
|
|
35992
36152
|
function installedPackageVersion(versionDir) {
|
|
35993
|
-
const packageJsonPath = (0,
|
|
36153
|
+
const packageJsonPath = (0, import_node_path23.join)(
|
|
35994
36154
|
versionDir,
|
|
35995
36155
|
"node_modules",
|
|
35996
36156
|
"deepline",
|
|
35997
36157
|
"package.json"
|
|
35998
36158
|
);
|
|
35999
36159
|
try {
|
|
36000
|
-
const parsed = JSON.parse((0,
|
|
36160
|
+
const parsed = JSON.parse((0, import_node_fs20.readFileSync)(packageJsonPath, "utf8"));
|
|
36001
36161
|
return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
|
|
36002
36162
|
} catch {
|
|
36003
36163
|
return "";
|
|
36004
36164
|
}
|
|
36005
36165
|
}
|
|
36166
|
+
function sidecarStructureFailure(versionDir) {
|
|
36167
|
+
const health = inspectSdkSidecarInstall(versionDir);
|
|
36168
|
+
if (!health.ok) {
|
|
36169
|
+
const details = [
|
|
36170
|
+
...health.invalidReason ? [health.invalidReason] : [],
|
|
36171
|
+
...health.missing.length > 0 ? [`missing ${health.missing.join(", ")}`] : []
|
|
36172
|
+
].join("; ");
|
|
36173
|
+
return details || "required SDK CLI files are missing";
|
|
36174
|
+
}
|
|
36175
|
+
return null;
|
|
36176
|
+
}
|
|
36177
|
+
function sidecarInstallFailure(versionDir) {
|
|
36178
|
+
const structureFailure = sidecarStructureFailure(versionDir);
|
|
36179
|
+
if (structureFailure) return structureFailure;
|
|
36180
|
+
const esbuildFailure = probeSdkSidecarEsbuild(versionDir);
|
|
36181
|
+
return esbuildFailure ? `esbuild probe failed: ${esbuildFailure}` : null;
|
|
36182
|
+
}
|
|
36006
36183
|
function runCommand(command, args, env = process.env) {
|
|
36007
36184
|
return new Promise((resolveResult) => {
|
|
36008
36185
|
let output2 = "";
|
|
@@ -36074,26 +36251,62 @@ async function runNpmInstallWithRegistryFallback(input2) {
|
|
|
36074
36251
|
return fallback.exitCode;
|
|
36075
36252
|
}
|
|
36076
36253
|
function writeSidecarLauncher(input2) {
|
|
36077
|
-
(0,
|
|
36254
|
+
(0, import_node_fs20.mkdirSync)((0, import_node_path23.dirname)(input2.path), { recursive: true });
|
|
36255
|
+
const packageRoot = (0, import_node_path23.dirname)((0, import_node_path23.dirname)((0, import_node_path23.dirname)(input2.entryPath)));
|
|
36256
|
+
const versionDir = (0, import_node_path23.dirname)((0, import_node_path23.dirname)(packageRoot));
|
|
36257
|
+
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);";
|
|
36258
|
+
const criticalPaths = [
|
|
36259
|
+
...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
|
|
36260
|
+
(path) => (0, import_node_path23.join)(packageRoot, path)
|
|
36261
|
+
),
|
|
36262
|
+
...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
|
|
36263
|
+
(path) => (0, import_node_path23.join)(versionDir, "node_modules", path)
|
|
36264
|
+
)
|
|
36265
|
+
];
|
|
36078
36266
|
if (process.platform === "win32") {
|
|
36079
|
-
(0,
|
|
36267
|
+
(0, import_node_fs20.writeFileSync)(
|
|
36080
36268
|
input2.path,
|
|
36081
36269
|
[
|
|
36082
36270
|
`@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
|
|
36083
36271
|
`@set DEEPLINE_CONFIG_SCOPE=${input2.scope.replace(/\r?\n/g, "")}`,
|
|
36272
|
+
...criticalPaths.map(
|
|
36273
|
+
(path) => `@if not exist "${path}" goto repair_sdk`
|
|
36274
|
+
),
|
|
36275
|
+
`@"${input2.nodeBin}" -e "${esbuildProbe}" "${versionDir}" >NUL 2>&1`,
|
|
36276
|
+
"@if errorlevel 1 goto repair_sdk",
|
|
36084
36277
|
`@"${input2.nodeBin}" "${input2.entryPath}" %*`,
|
|
36278
|
+
"@exit /b %ERRORLEVEL%",
|
|
36279
|
+
":repair_sdk",
|
|
36280
|
+
'@if defined DEEPLINE_REAL_BINARY "%DEEPLINE_REAL_BINARY%" --version=v2 %*',
|
|
36281
|
+
"@if defined DEEPLINE_REAL_BINARY exit /b %ERRORLEVEL%",
|
|
36282
|
+
"@echo Deepline SDK CLI install is incomplete. Run `deepline update` to repair it. 1>&2",
|
|
36283
|
+
"@exit /b 1",
|
|
36085
36284
|
""
|
|
36086
36285
|
].join("\r\n"),
|
|
36087
36286
|
"utf8"
|
|
36088
36287
|
);
|
|
36089
36288
|
return;
|
|
36090
36289
|
}
|
|
36091
|
-
(0,
|
|
36290
|
+
(0, import_node_fs20.writeFileSync)(
|
|
36092
36291
|
input2.path,
|
|
36093
36292
|
[
|
|
36094
36293
|
"#!/usr/bin/env sh",
|
|
36095
36294
|
`export DEEPLINE_HOST_URL=${shellQuote4(input2.hostUrl)}`,
|
|
36096
36295
|
`export DEEPLINE_CONFIG_SCOPE=${shellQuote4(input2.scope)}`,
|
|
36296
|
+
`if ${criticalPaths.map((path) => `[ ! -f ${shellQuote4(path)} ]`).join(" || ")}; then`,
|
|
36297
|
+
' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
|
|
36298
|
+
' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
|
|
36299
|
+
" fi",
|
|
36300
|
+
' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
|
|
36301
|
+
" exit 1",
|
|
36302
|
+
"fi",
|
|
36303
|
+
`if ! ${shellQuote4(input2.nodeBin)} -e ${shellQuote4(esbuildProbe)} ${shellQuote4(versionDir)} >/dev/null 2>&1; then`,
|
|
36304
|
+
' if [ -n "${DEEPLINE_REAL_BINARY:-}" ] && [ -x "$DEEPLINE_REAL_BINARY" ]; then',
|
|
36305
|
+
' exec "$DEEPLINE_REAL_BINARY" --version=v2 "$@"',
|
|
36306
|
+
" fi",
|
|
36307
|
+
' printf "%s\\n" "Deepline SDK CLI install is incomplete. Run \\`deepline update\\` to repair it." >&2',
|
|
36308
|
+
" exit 1",
|
|
36309
|
+
"fi",
|
|
36097
36310
|
`exec ${shellQuote4(input2.nodeBin)} ${shellQuote4(input2.entryPath)} "$@"`,
|
|
36098
36311
|
""
|
|
36099
36312
|
].join("\n"),
|
|
@@ -36101,17 +36314,17 @@ function writeSidecarLauncher(input2) {
|
|
|
36101
36314
|
);
|
|
36102
36315
|
}
|
|
36103
36316
|
async function runPythonSidecarUpdatePlan(plan) {
|
|
36104
|
-
const versionsDir = (0,
|
|
36105
|
-
const tempDir = (0,
|
|
36317
|
+
const versionsDir = (0, import_node_path23.join)(plan.stateDir, "versions");
|
|
36318
|
+
const tempDir = (0, import_node_path23.join)(
|
|
36106
36319
|
versionsDir,
|
|
36107
36320
|
`.tmp-sdk-update-${process.pid}-${Date.now()}`
|
|
36108
36321
|
);
|
|
36109
|
-
(0,
|
|
36110
|
-
(0,
|
|
36111
|
-
(0,
|
|
36322
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36323
|
+
(0, import_node_fs20.mkdirSync)(tempDir, { recursive: true });
|
|
36324
|
+
(0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
|
|
36112
36325
|
const env = {
|
|
36113
36326
|
...process.env,
|
|
36114
|
-
PATH: `${(0,
|
|
36327
|
+
PATH: `${(0, import_node_path23.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
|
|
36115
36328
|
};
|
|
36116
36329
|
const installResult = await runCommand(
|
|
36117
36330
|
plan.npmCommand,
|
|
@@ -36128,7 +36341,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
36128
36341
|
);
|
|
36129
36342
|
const installExitCode = installResult.exitCode;
|
|
36130
36343
|
if (installExitCode !== 0) {
|
|
36131
|
-
(0,
|
|
36344
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36132
36345
|
return installExitCode;
|
|
36133
36346
|
}
|
|
36134
36347
|
const installedVersion = installedPackageVersion(tempDir);
|
|
@@ -36136,33 +36349,94 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
36136
36349
|
process.stderr.write(
|
|
36137
36350
|
"Updated Deepline SDK package did not report a version.\n"
|
|
36138
36351
|
);
|
|
36139
|
-
(0,
|
|
36352
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36140
36353
|
return 1;
|
|
36141
36354
|
}
|
|
36142
|
-
const
|
|
36355
|
+
const stagedFailure = sidecarInstallFailure(tempDir);
|
|
36356
|
+
if (stagedFailure) {
|
|
36357
|
+
process.stderr.write(
|
|
36358
|
+
`Updated Deepline SDK package is incomplete: ${stagedFailure}.
|
|
36359
|
+
`
|
|
36360
|
+
);
|
|
36361
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36362
|
+
return 1;
|
|
36363
|
+
}
|
|
36364
|
+
const finalDir = (0, import_node_path23.join)(versionsDir, installedVersion);
|
|
36143
36365
|
const finalEntryPath = entryPathInVersionDir(finalDir);
|
|
36144
|
-
|
|
36145
|
-
|
|
36366
|
+
const finalFailure = sidecarInstallFailure(finalDir);
|
|
36367
|
+
let backupDir = null;
|
|
36368
|
+
if (!finalFailure) {
|
|
36369
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36146
36370
|
} else {
|
|
36147
|
-
|
|
36148
|
-
|
|
36149
|
-
(0,
|
|
36150
|
-
|
|
36151
|
-
|
|
36152
|
-
process.stderr.write(
|
|
36153
|
-
`Failed to publish Deepline SDK sidecar update: ${error.message}
|
|
36154
|
-
`
|
|
36371
|
+
let shouldPublishTemp = true;
|
|
36372
|
+
if ((0, import_node_fs20.existsSync)(finalDir)) {
|
|
36373
|
+
backupDir = (0, import_node_path23.join)(
|
|
36374
|
+
versionsDir,
|
|
36375
|
+
`.backup-${installedVersion}-${process.pid}-${Date.now()}`
|
|
36155
36376
|
);
|
|
36156
|
-
|
|
36377
|
+
try {
|
|
36378
|
+
(0, import_node_fs20.renameSync)(finalDir, backupDir);
|
|
36379
|
+
} catch (error) {
|
|
36380
|
+
const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
|
|
36381
|
+
if (!concurrentlyPublishedFailure) {
|
|
36382
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36383
|
+
backupDir = null;
|
|
36384
|
+
shouldPublishTemp = false;
|
|
36385
|
+
} else {
|
|
36386
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36387
|
+
process.stderr.write(
|
|
36388
|
+
`Failed to preserve the incomplete Deepline SDK sidecar before repair: ${error.message}.
|
|
36389
|
+
`
|
|
36390
|
+
);
|
|
36391
|
+
return 1;
|
|
36392
|
+
}
|
|
36393
|
+
}
|
|
36394
|
+
}
|
|
36395
|
+
if (shouldPublishTemp) {
|
|
36396
|
+
try {
|
|
36397
|
+
(0, import_node_fs20.renameSync)(tempDir, finalDir);
|
|
36398
|
+
} catch (error) {
|
|
36399
|
+
(0, import_node_fs20.rmSync)(tempDir, { recursive: true, force: true });
|
|
36400
|
+
const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
|
|
36401
|
+
if (!concurrentlyPublishedFailure) {
|
|
36402
|
+
if (backupDir) (0, import_node_fs20.rmSync)(backupDir, { recursive: true, force: true });
|
|
36403
|
+
backupDir = null;
|
|
36404
|
+
} else {
|
|
36405
|
+
let restoreFailure = "";
|
|
36406
|
+
if (backupDir && (0, import_node_fs20.existsSync)(backupDir) && !(0, import_node_fs20.existsSync)(finalDir)) {
|
|
36407
|
+
try {
|
|
36408
|
+
(0, import_node_fs20.renameSync)(backupDir, finalDir);
|
|
36409
|
+
backupDir = null;
|
|
36410
|
+
} catch (restoreError) {
|
|
36411
|
+
restoreFailure = `; failed to restore previous install: ${restoreError.message}`;
|
|
36412
|
+
}
|
|
36413
|
+
}
|
|
36414
|
+
process.stderr.write(
|
|
36415
|
+
`Failed to publish Deepline SDK sidecar update: ${error.message}; current install remains incomplete: ${concurrentlyPublishedFailure}${restoreFailure}.
|
|
36416
|
+
`
|
|
36417
|
+
);
|
|
36418
|
+
return 1;
|
|
36419
|
+
}
|
|
36420
|
+
}
|
|
36157
36421
|
}
|
|
36158
36422
|
}
|
|
36159
|
-
|
|
36423
|
+
const publishedFailure = sidecarStructureFailure(finalDir);
|
|
36424
|
+
if (publishedFailure) {
|
|
36425
|
+
if (backupDir && (0, import_node_fs20.existsSync)(backupDir)) {
|
|
36426
|
+
(0, import_node_fs20.rmSync)(finalDir, { recursive: true, force: true });
|
|
36427
|
+
try {
|
|
36428
|
+
(0, import_node_fs20.renameSync)(backupDir, finalDir);
|
|
36429
|
+
backupDir = null;
|
|
36430
|
+
} catch {
|
|
36431
|
+
}
|
|
36432
|
+
}
|
|
36160
36433
|
process.stderr.write(
|
|
36161
|
-
`Updated Deepline SDK CLI
|
|
36434
|
+
`Updated Deepline SDK CLI install is incomplete: ${publishedFailure}.
|
|
36162
36435
|
`
|
|
36163
36436
|
);
|
|
36164
36437
|
return 1;
|
|
36165
36438
|
}
|
|
36439
|
+
if (backupDir) (0, import_node_fs20.rmSync)(backupDir, { recursive: true, force: true });
|
|
36166
36440
|
writeSidecarLauncher({
|
|
36167
36441
|
path: plan.sidecarPath,
|
|
36168
36442
|
hostUrl: plan.hostUrl,
|
|
@@ -36170,28 +36444,28 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
36170
36444
|
nodeBin: plan.nodeBin,
|
|
36171
36445
|
entryPath: finalEntryPath
|
|
36172
36446
|
});
|
|
36173
|
-
(0,
|
|
36174
|
-
(0,
|
|
36447
|
+
(0, import_node_fs20.writeFileSync)(
|
|
36448
|
+
(0, import_node_path23.join)(plan.stateDir, ".version"),
|
|
36175
36449
|
`${installedVersion}
|
|
36176
36450
|
`,
|
|
36177
36451
|
"utf8"
|
|
36178
36452
|
);
|
|
36179
|
-
(0,
|
|
36180
|
-
(0,
|
|
36453
|
+
(0, import_node_fs20.writeFileSync)(
|
|
36454
|
+
(0, import_node_path23.join)(plan.stateDir, ".install-method"),
|
|
36181
36455
|
"python-sidecar\n",
|
|
36182
36456
|
"utf8"
|
|
36183
36457
|
);
|
|
36184
|
-
(0,
|
|
36185
|
-
(0,
|
|
36458
|
+
(0, import_node_fs20.writeFileSync)(
|
|
36459
|
+
(0, import_node_path23.join)(plan.stateDir, ".command-path"),
|
|
36186
36460
|
`${plan.sidecarPath}
|
|
36187
36461
|
`,
|
|
36188
36462
|
"utf8"
|
|
36189
36463
|
);
|
|
36190
|
-
(0,
|
|
36191
|
-
(0,
|
|
36464
|
+
(0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(plan.stateDir, ".runner"), "node\n", "utf8");
|
|
36465
|
+
(0, import_node_fs20.writeFileSync)((0, import_node_path23.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
|
|
36192
36466
|
`, "utf8");
|
|
36193
|
-
(0,
|
|
36194
|
-
(0,
|
|
36467
|
+
(0, import_node_fs20.writeFileSync)(
|
|
36468
|
+
(0, import_node_path23.join)(plan.stateDir, ".entry-path"),
|
|
36195
36469
|
`${finalEntryPath}
|
|
36196
36470
|
`,
|
|
36197
36471
|
"utf8"
|
|
@@ -36314,9 +36588,9 @@ Examples:
|
|
|
36314
36588
|
|
|
36315
36589
|
// src/cli/commands/setup.ts
|
|
36316
36590
|
var import_node_child_process4 = require("child_process");
|
|
36317
|
-
var
|
|
36591
|
+
var import_node_fs21 = require("fs");
|
|
36318
36592
|
var import_node_os17 = require("os");
|
|
36319
|
-
var
|
|
36593
|
+
var import_node_path24 = require("path");
|
|
36320
36594
|
var SETUP_PHASE_NAMES = [
|
|
36321
36595
|
"cli",
|
|
36322
36596
|
"cleanup",
|
|
@@ -36373,7 +36647,7 @@ function phasesFromLegacyStatus(status) {
|
|
|
36373
36647
|
function readSetupState(input2) {
|
|
36374
36648
|
try {
|
|
36375
36649
|
const parsed = JSON.parse(
|
|
36376
|
-
(0,
|
|
36650
|
+
(0, import_node_fs21.readFileSync)(
|
|
36377
36651
|
setupStatePath(input2.baseUrl, input2.scope, input2.root),
|
|
36378
36652
|
"utf8"
|
|
36379
36653
|
)
|
|
@@ -36449,7 +36723,7 @@ function buildPendingAuthorizationOutput(input2) {
|
|
|
36449
36723
|
};
|
|
36450
36724
|
}
|
|
36451
36725
|
function setupStatePath(baseUrl, scope, root) {
|
|
36452
|
-
return scope === "local" && root ? (0,
|
|
36726
|
+
return scope === "local" && root ? (0, import_node_path24.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path24.join)(sdkCliStateDirPath(baseUrl), "setup.json");
|
|
36453
36727
|
}
|
|
36454
36728
|
async function captureStdout2(run) {
|
|
36455
36729
|
let stdout = "";
|
|
@@ -36478,14 +36752,14 @@ function asRecord3(value) {
|
|
|
36478
36752
|
}
|
|
36479
36753
|
function safeRead(path) {
|
|
36480
36754
|
try {
|
|
36481
|
-
return (0,
|
|
36755
|
+
return (0, import_node_fs21.readFileSync)(path, "utf8");
|
|
36482
36756
|
} catch {
|
|
36483
36757
|
return "";
|
|
36484
36758
|
}
|
|
36485
36759
|
}
|
|
36486
36760
|
function isNpmManagedDeeplinePath(path) {
|
|
36487
36761
|
try {
|
|
36488
|
-
return (0,
|
|
36762
|
+
return (0, import_node_fs21.realpathSync)(path).includes(`${(0, import_node_path24.join)("node_modules", "deepline")}`);
|
|
36489
36763
|
} catch {
|
|
36490
36764
|
return false;
|
|
36491
36765
|
}
|
|
@@ -36496,32 +36770,32 @@ function isInstallerManagedLegacyLauncher(path) {
|
|
|
36496
36770
|
}
|
|
36497
36771
|
function removeKnownLegacyPaths(baseUrl) {
|
|
36498
36772
|
const home = (0, import_node_os17.homedir)();
|
|
36499
|
-
const hostDir = (0,
|
|
36500
|
-
const legacyLauncherPath = (0,
|
|
36773
|
+
const hostDir = (0, import_node_path24.join)(home, ".local", "deepline", baseUrlSlug(baseUrl));
|
|
36774
|
+
const legacyLauncherPath = (0, import_node_path24.join)(home, ".local", "bin", "deepline");
|
|
36501
36775
|
const installerCommandPath = safeRead(
|
|
36502
|
-
(0,
|
|
36776
|
+
(0, import_node_path24.join)(hostDir, "sdk", ".command-path")
|
|
36503
36777
|
).trim();
|
|
36504
36778
|
const candidates = [
|
|
36505
36779
|
...isInstallerManagedLegacyLauncher(legacyLauncherPath) ? [legacyLauncherPath] : [],
|
|
36506
|
-
(0,
|
|
36507
|
-
(0,
|
|
36508
|
-
(0,
|
|
36509
|
-
(0,
|
|
36510
|
-
(0,
|
|
36511
|
-
(0,
|
|
36512
|
-
(0,
|
|
36780
|
+
(0, import_node_path24.join)(home, ".local", "bin", "deepline-real"),
|
|
36781
|
+
(0, import_node_path24.join)(hostDir, "bin", "deepline"),
|
|
36782
|
+
(0, import_node_path24.join)(hostDir, "bin", "deepline-real"),
|
|
36783
|
+
(0, import_node_path24.join)(hostDir, "cli", ".install-method"),
|
|
36784
|
+
(0, import_node_path24.join)(hostDir, "cli", ".version"),
|
|
36785
|
+
(0, import_node_path24.join)(hostDir, "sdk", ".install-method"),
|
|
36786
|
+
(0, import_node_path24.join)(hostDir, "sdk", ".command-path"),
|
|
36513
36787
|
...installerCommandPath ? [
|
|
36514
36788
|
installerCommandPath,
|
|
36515
|
-
(0,
|
|
36789
|
+
(0, import_node_path24.join)((0, import_node_path24.dirname)(installerCommandPath), "deepline-sdk")
|
|
36516
36790
|
] : []
|
|
36517
36791
|
];
|
|
36518
36792
|
const removed = [];
|
|
36519
36793
|
for (const path of candidates) {
|
|
36520
|
-
if (!(0,
|
|
36794
|
+
if (!(0, import_node_fs21.existsSync)(path)) continue;
|
|
36521
36795
|
if (path === installerCommandPath && isNpmManagedDeeplinePath(path)) {
|
|
36522
36796
|
continue;
|
|
36523
36797
|
}
|
|
36524
|
-
(0,
|
|
36798
|
+
(0, import_node_fs21.rmSync)(path, { force: true });
|
|
36525
36799
|
removed.push(path);
|
|
36526
36800
|
}
|
|
36527
36801
|
return removed;
|
|
@@ -36534,7 +36808,7 @@ function resolvePathCommands(command) {
|
|
|
36534
36808
|
);
|
|
36535
36809
|
return [
|
|
36536
36810
|
...new Set(
|
|
36537
|
-
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0,
|
|
36811
|
+
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path24.resolve)(path))
|
|
36538
36812
|
)
|
|
36539
36813
|
];
|
|
36540
36814
|
}
|
|
@@ -36544,7 +36818,7 @@ function resolvePathCommand(command) {
|
|
|
36544
36818
|
function isHomebrewFormulaCommand(path) {
|
|
36545
36819
|
let resolvedPath = path;
|
|
36546
36820
|
try {
|
|
36547
|
-
resolvedPath = (0,
|
|
36821
|
+
resolvedPath = (0, import_node_fs21.realpathSync)(path);
|
|
36548
36822
|
} catch {
|
|
36549
36823
|
return false;
|
|
36550
36824
|
}
|
|
@@ -36555,7 +36829,7 @@ function isHomebrewFormulaCommand(path) {
|
|
|
36555
36829
|
function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
36556
36830
|
const platform3 = dependencies.platform ?? process.platform;
|
|
36557
36831
|
const run = dependencies.spawn ?? import_node_child_process4.spawnSync;
|
|
36558
|
-
const pathExists = dependencies.exists ??
|
|
36832
|
+
const pathExists = dependencies.exists ?? import_node_fs21.existsSync;
|
|
36559
36833
|
const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
|
|
36560
36834
|
const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
|
|
36561
36835
|
if (homebrewCommand) return homebrewCommand;
|
|
@@ -36567,7 +36841,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
|
36567
36841
|
if (prefix.status !== 0) return null;
|
|
36568
36842
|
const root = String(prefix.stdout ?? "").trim();
|
|
36569
36843
|
if (!root) return null;
|
|
36570
|
-
const candidates = platform3 === "win32" ? [(0,
|
|
36844
|
+
const candidates = platform3 === "win32" ? [(0, import_node_path24.join)(root, "deepline.cmd"), (0, import_node_path24.join)(root, "deepline")] : [(0, import_node_path24.join)(root, "bin", "deepline")];
|
|
36571
36845
|
return candidates.find((candidate) => pathExists(candidate)) ?? null;
|
|
36572
36846
|
}
|
|
36573
36847
|
function inspectGlobalCliAvailability(input2) {
|
|
@@ -36580,20 +36854,20 @@ function inspectGlobalCliAvailability(input2) {
|
|
|
36580
36854
|
}
|
|
36581
36855
|
function pathsResolveToSameFile(left, right) {
|
|
36582
36856
|
try {
|
|
36583
|
-
return (0,
|
|
36857
|
+
return (0, import_node_fs21.realpathSync)(left) === (0, import_node_fs21.realpathSync)(right);
|
|
36584
36858
|
} catch {
|
|
36585
|
-
return (0,
|
|
36859
|
+
return (0, import_node_path24.resolve)(left) === (0, import_node_path24.resolve)(right);
|
|
36586
36860
|
}
|
|
36587
36861
|
}
|
|
36588
36862
|
function isKnownDeeplineCommand(path) {
|
|
36589
|
-
const entrypoint = process.argv[1] ? (0,
|
|
36863
|
+
const entrypoint = process.argv[1] ? (0, import_node_path24.resolve)(process.argv[1]) : "";
|
|
36590
36864
|
let resolvedPath = path;
|
|
36591
36865
|
try {
|
|
36592
|
-
resolvedPath = (0,
|
|
36866
|
+
resolvedPath = (0, import_node_fs21.realpathSync)(path);
|
|
36593
36867
|
} catch {
|
|
36594
36868
|
}
|
|
36595
36869
|
if (entrypoint && resolvedPath === entrypoint) return true;
|
|
36596
|
-
if (resolvedPath.includes(`${(0,
|
|
36870
|
+
if (resolvedPath.includes(`${(0, import_node_path24.join)("node_modules", "deepline")}`)) return true;
|
|
36597
36871
|
const content = safeRead(path);
|
|
36598
36872
|
return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
|
|
36599
36873
|
}
|
|
@@ -36601,9 +36875,9 @@ function inspectPathConflict() {
|
|
|
36601
36875
|
const commandPath = resolvePathCommand("deepline");
|
|
36602
36876
|
if (!commandPath || isKnownDeeplineCommand(commandPath)) return null;
|
|
36603
36877
|
try {
|
|
36604
|
-
if ((0,
|
|
36605
|
-
const target = (0,
|
|
36606
|
-
if (target.includes(`${(0,
|
|
36878
|
+
if ((0, import_node_fs21.lstatSync)(commandPath).isSymbolicLink()) {
|
|
36879
|
+
const target = (0, import_node_fs21.realpathSync)(commandPath);
|
|
36880
|
+
if (target.includes(`${(0, import_node_path24.join)("node_modules", "deepline")}`)) return null;
|
|
36607
36881
|
}
|
|
36608
36882
|
} catch {
|
|
36609
36883
|
}
|
|
@@ -36611,8 +36885,8 @@ function inspectPathConflict() {
|
|
|
36611
36885
|
}
|
|
36612
36886
|
function writeSetupState(input2) {
|
|
36613
36887
|
const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
|
|
36614
|
-
(0,
|
|
36615
|
-
(0,
|
|
36888
|
+
(0, import_node_fs21.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
|
|
36889
|
+
(0, import_node_fs21.writeFileSync)(
|
|
36616
36890
|
path,
|
|
36617
36891
|
`${JSON.stringify(
|
|
36618
36892
|
{
|
|
@@ -36652,7 +36926,7 @@ function failSetupPhase(phases, phase, code) {
|
|
|
36652
36926
|
phases[phase] = { status: "failed", code };
|
|
36653
36927
|
}
|
|
36654
36928
|
function rollbackCommand(scope, root) {
|
|
36655
|
-
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0,
|
|
36929
|
+
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path24.join)(root, ".deepline", "runtime"))}` : "";
|
|
36656
36930
|
return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
|
|
36657
36931
|
}
|
|
36658
36932
|
function setupResumeCommand(baseUrl, scope) {
|
|
@@ -36739,12 +37013,12 @@ function buildDoctorAssessment(input2) {
|
|
|
36739
37013
|
const connected = input2.authStatus.payload?.connected === true;
|
|
36740
37014
|
const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
|
|
36741
37015
|
const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
|
|
36742
|
-
const runningCliPath = process.argv[1] ? (0,
|
|
37016
|
+
const runningCliPath = process.argv[1] ? (0, import_node_path24.resolve)(process.argv[1]) : null;
|
|
36743
37017
|
const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
|
|
36744
37018
|
const pathGlobalCli = globalCli?.path ?? null;
|
|
36745
37019
|
const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
|
|
36746
37020
|
const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
|
|
36747
|
-
input2.root && runningCliPath?.includes((0,
|
|
37021
|
+
input2.root && runningCliPath?.includes((0, import_node_path24.join)(input2.root, ".deepline", "runtime"))
|
|
36748
37022
|
);
|
|
36749
37023
|
const checks = {
|
|
36750
37024
|
cli: {
|
|
@@ -37390,7 +37664,7 @@ function isDowngradeAutoUpdateResponse(response) {
|
|
|
37390
37664
|
return compareSemver(target, current) < 0;
|
|
37391
37665
|
}
|
|
37392
37666
|
function relaunchCurrentCommand(plan) {
|
|
37393
|
-
return new Promise((
|
|
37667
|
+
return new Promise((resolve19) => {
|
|
37394
37668
|
const command = plan.kind === "python-sidecar" ? plan.sidecarPath : process.execPath;
|
|
37395
37669
|
const args = plan.kind === "python-sidecar" ? process.argv.slice(2) : process.argv.slice(1);
|
|
37396
37670
|
const child = (0, import_node_child_process5.spawn)(command, args, {
|
|
@@ -37406,9 +37680,9 @@ function relaunchCurrentCommand(plan) {
|
|
|
37406
37680
|
`Deepline SDK/CLI updated, but relaunch failed: ${error.message}
|
|
37407
37681
|
`
|
|
37408
37682
|
);
|
|
37409
|
-
|
|
37683
|
+
resolve19(1);
|
|
37410
37684
|
});
|
|
37411
|
-
child.on("close", (code) =>
|
|
37685
|
+
child.on("close", (code) => resolve19(code ?? 1));
|
|
37412
37686
|
});
|
|
37413
37687
|
}
|
|
37414
37688
|
async function maybeAutoUpdateAndRelaunch(response) {
|
|
@@ -37459,8 +37733,8 @@ async function maybeAutoUpdateAndRelaunch(response) {
|
|
|
37459
37733
|
|
|
37460
37734
|
// src/cli/skills-sync.ts
|
|
37461
37735
|
var import_node_child_process6 = require("child_process");
|
|
37462
|
-
var
|
|
37463
|
-
var
|
|
37736
|
+
var import_node_fs22 = require("fs");
|
|
37737
|
+
var import_node_path25 = require("path");
|
|
37464
37738
|
var CHECK_TIMEOUT_MS2 = 3e3;
|
|
37465
37739
|
var attemptedSync = false;
|
|
37466
37740
|
function shouldSkipSkillsSync() {
|
|
@@ -37476,51 +37750,51 @@ function activePluginSkillsDir() {
|
|
|
37476
37750
|
return "";
|
|
37477
37751
|
}
|
|
37478
37752
|
const dir = process.env.DEEPLINE_PLUGIN_SKILLS_DIR?.trim() ?? "";
|
|
37479
|
-
return dir && (0,
|
|
37753
|
+
return dir && (0, import_node_fs22.existsSync)(dir) ? dir : "";
|
|
37480
37754
|
}
|
|
37481
37755
|
function readPluginSkillsVersion() {
|
|
37482
37756
|
const dir = activePluginSkillsDir();
|
|
37483
37757
|
if (!dir) return "";
|
|
37484
37758
|
try {
|
|
37485
|
-
return (0,
|
|
37759
|
+
return (0, import_node_fs22.readFileSync)((0, import_node_path25.join)(dir, ".version"), "utf-8").trim();
|
|
37486
37760
|
} catch {
|
|
37487
37761
|
return "";
|
|
37488
37762
|
}
|
|
37489
37763
|
}
|
|
37490
37764
|
function sdkSkillsVersionPath(baseUrl) {
|
|
37491
|
-
return (0,
|
|
37765
|
+
return (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "skills-version");
|
|
37492
37766
|
}
|
|
37493
37767
|
function legacySdkSkillsVersionPath(baseUrl) {
|
|
37494
|
-
return (0,
|
|
37768
|
+
return (0, import_node_path25.join)((0, import_node_path25.dirname)(sdkCliStateDirPath(baseUrl)), "sdk-skills", ".version");
|
|
37495
37769
|
}
|
|
37496
37770
|
function unavailableSkillsNoticePath(baseUrl) {
|
|
37497
|
-
return (0,
|
|
37771
|
+
return (0, import_node_path25.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
|
|
37498
37772
|
}
|
|
37499
37773
|
function readSdkSkillsLocalVersion(baseUrl) {
|
|
37500
37774
|
const pluginVersion = readPluginSkillsVersion();
|
|
37501
37775
|
if (pluginVersion) return pluginVersion;
|
|
37502
|
-
const path = (0,
|
|
37503
|
-
if (!(0,
|
|
37776
|
+
const path = (0, import_node_fs22.existsSync)(sdkSkillsVersionPath(baseUrl)) ? sdkSkillsVersionPath(baseUrl) : legacySdkSkillsVersionPath(baseUrl);
|
|
37777
|
+
if (!(0, import_node_fs22.existsSync)(path)) return "";
|
|
37504
37778
|
try {
|
|
37505
|
-
return (0,
|
|
37779
|
+
return (0, import_node_fs22.readFileSync)(path, "utf-8").trim();
|
|
37506
37780
|
} catch {
|
|
37507
37781
|
return "";
|
|
37508
37782
|
}
|
|
37509
37783
|
}
|
|
37510
37784
|
function writeLocalSkillsVersion(baseUrl, version) {
|
|
37511
37785
|
const path = sdkSkillsVersionPath(baseUrl);
|
|
37512
|
-
(0,
|
|
37513
|
-
(0,
|
|
37786
|
+
(0, import_node_fs22.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
|
|
37787
|
+
(0, import_node_fs22.writeFileSync)(path, `${version}
|
|
37514
37788
|
`, "utf-8");
|
|
37515
37789
|
}
|
|
37516
37790
|
function writeUnavailableSkillsNotice(baseUrl, remoteVersion, skillNames) {
|
|
37517
37791
|
const path = unavailableSkillsNoticePath(baseUrl);
|
|
37518
37792
|
try {
|
|
37519
|
-
if ((0,
|
|
37793
|
+
if ((0, import_node_fs22.existsSync)(path) && (0, import_node_fs22.readFileSync)(path, "utf-8").trim() === remoteVersion) {
|
|
37520
37794
|
return;
|
|
37521
37795
|
}
|
|
37522
|
-
(0,
|
|
37523
|
-
(0,
|
|
37796
|
+
(0, import_node_fs22.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
|
|
37797
|
+
(0, import_node_fs22.writeFileSync)(path, `${remoteVersion}
|
|
37524
37798
|
`, "utf-8");
|
|
37525
37799
|
} catch {
|
|
37526
37800
|
}
|
|
@@ -37532,7 +37806,7 @@ ${manualCommand}`
|
|
|
37532
37806
|
}
|
|
37533
37807
|
function clearUnavailableSkillsNotice(baseUrl) {
|
|
37534
37808
|
try {
|
|
37535
|
-
(0,
|
|
37809
|
+
(0, import_node_fs22.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
|
|
37536
37810
|
} catch {
|
|
37537
37811
|
}
|
|
37538
37812
|
}
|
|
@@ -37654,7 +37928,7 @@ function resolveSkillsInstallCommands(baseUrl, skillNames = DEFAULT_SDK_SKILL_NA
|
|
|
37654
37928
|
return commands;
|
|
37655
37929
|
}
|
|
37656
37930
|
function runOneSkillsInstall(install) {
|
|
37657
|
-
return new Promise((
|
|
37931
|
+
return new Promise((resolve19) => {
|
|
37658
37932
|
const plan = resolveSkillsInstallSpawn(install);
|
|
37659
37933
|
const child = (0, import_node_child_process6.spawn)(plan.command, plan.args, {
|
|
37660
37934
|
stdio: ["ignore", "ignore", "pipe"],
|
|
@@ -37666,7 +37940,7 @@ function runOneSkillsInstall(install) {
|
|
|
37666
37940
|
stderr += chunk.toString("utf-8");
|
|
37667
37941
|
});
|
|
37668
37942
|
child.on("error", (error) => {
|
|
37669
|
-
|
|
37943
|
+
resolve19({
|
|
37670
37944
|
ok: false,
|
|
37671
37945
|
detail: `failed to start ${install.command}: ${error.message}`,
|
|
37672
37946
|
manualCommand: install.manualCommand
|
|
@@ -37674,11 +37948,11 @@ function runOneSkillsInstall(install) {
|
|
|
37674
37948
|
});
|
|
37675
37949
|
child.on("close", (code) => {
|
|
37676
37950
|
if (code === 0) {
|
|
37677
|
-
|
|
37951
|
+
resolve19({ ok: true, detail: "", manualCommand: install.manualCommand });
|
|
37678
37952
|
return;
|
|
37679
37953
|
}
|
|
37680
37954
|
const detail = stderr.trim();
|
|
37681
|
-
|
|
37955
|
+
resolve19({
|
|
37682
37956
|
ok: false,
|
|
37683
37957
|
detail: detail ? `${install.command}: ${detail}` : `${install.command} exited ${code}`,
|
|
37684
37958
|
manualCommand: install.manualCommand
|
|
@@ -38106,8 +38380,8 @@ function topLevelCommandKnown(program, commandName) {
|
|
|
38106
38380
|
);
|
|
38107
38381
|
}
|
|
38108
38382
|
async function runPlayRunnerHealthCheck() {
|
|
38109
|
-
const dir = await (0, import_promises8.mkdtemp)((0,
|
|
38110
|
-
const file = (0,
|
|
38383
|
+
const dir = await (0, import_promises8.mkdtemp)((0, import_node_path26.join)((0, import_node_os19.tmpdir)(), "deepline-health-play-"));
|
|
38384
|
+
const file = (0, import_node_path26.join)(dir, "health-check.play.ts");
|
|
38111
38385
|
try {
|
|
38112
38386
|
await (0, import_promises8.writeFile)(
|
|
38113
38387
|
file,
|