deepline 0.3.70 → 0.3.71
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/client.ts +54 -4
- package/dist/bundling-sources/sdk/src/index.ts +2 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/cli/index.js +346 -209
- package/dist/cli/index.mjs +302 -159
- package/dist/index.d.mts +30 -5
- package/dist/index.d.ts +30 -5
- package/dist/index.js +23 -1
- package/dist/index.mjs +23 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -182,7 +182,7 @@ configureProxyFromEnv();
|
|
|
182
182
|
|
|
183
183
|
// src/cli/index.ts
|
|
184
184
|
var import_promises11 = require("fs/promises");
|
|
185
|
-
var
|
|
185
|
+
var import_node_path29 = require("path");
|
|
186
186
|
var import_node_os18 = require("os");
|
|
187
187
|
var import_commander4 = require("commander");
|
|
188
188
|
|
|
@@ -1214,7 +1214,7 @@ var SDK_RELEASE = {
|
|
|
1214
1214
|
// available at toolResponse.rawV2 while toolResponse.raw and all declared
|
|
1215
1215
|
// getters keep their established compatibility behavior.
|
|
1216
1216
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
1217
|
-
version: "0.3.
|
|
1217
|
+
version: "0.3.71",
|
|
1218
1218
|
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.",
|
|
1219
1219
|
packageCapabilities: {
|
|
1220
1220
|
updatePreferences: 1
|
|
@@ -4854,6 +4854,8 @@ var DeeplineClient = class {
|
|
|
4854
4854
|
db;
|
|
4855
4855
|
/** Billing namespace: subscription status/cancel and invoice history. */
|
|
4856
4856
|
billing;
|
|
4857
|
+
/** Workspace lifecycle namespace. */
|
|
4858
|
+
workspaces;
|
|
4857
4859
|
/** Monitors namespace: access, catalog, deploy/check, and lifecycle. */
|
|
4858
4860
|
monitors;
|
|
4859
4861
|
/**
|
|
@@ -4902,6 +4904,9 @@ var DeeplineClient = class {
|
|
|
4902
4904
|
transitionPlan: (options2) => this.transitionTargetBillingPlan(options2),
|
|
4903
4905
|
portalSession: () => this.createTargetBillingPortalSession()
|
|
4904
4906
|
};
|
|
4907
|
+
this.workspaces = {
|
|
4908
|
+
create: (options2) => this.createWorkspace(options2)
|
|
4909
|
+
};
|
|
4905
4910
|
this.monitors = {
|
|
4906
4911
|
status: () => this.getMonitorsAccess(),
|
|
4907
4912
|
available: (toolIdOrOptions, options2) => this.getMonitorsAvailable(toolIdOrOptions, options2),
|
|
@@ -7053,6 +7058,23 @@ var DeeplineClient = class {
|
|
|
7053
7058
|
const response = await this.http.post("/api/v2/billing/portal-sessions", {});
|
|
7054
7059
|
return response.data;
|
|
7055
7060
|
}
|
|
7061
|
+
/** Create an additional workspace through the durable PAYG workflow. */
|
|
7062
|
+
async createWorkspace(options) {
|
|
7063
|
+
const idempotencyKey = requireTargetBillingIdempotencyKey(
|
|
7064
|
+
options.idempotencyKey
|
|
7065
|
+
);
|
|
7066
|
+
const response = await this.http.post(
|
|
7067
|
+
"/api/v2/workspaces",
|
|
7068
|
+
{ name: options.name },
|
|
7069
|
+
{ "Idempotency-Key": idempotencyKey },
|
|
7070
|
+
{ maxRetries: 0, exactUrlOnly: true }
|
|
7071
|
+
);
|
|
7072
|
+
return {
|
|
7073
|
+
...response.data,
|
|
7074
|
+
operation: response.operation,
|
|
7075
|
+
...response.request_id ? { request_id: response.request_id } : {}
|
|
7076
|
+
};
|
|
7077
|
+
}
|
|
7056
7078
|
// ——————————————————————————————————————————————————————————
|
|
7057
7079
|
// Monitors
|
|
7058
7080
|
// ——————————————————————————————————————————————————————————
|
|
@@ -33758,6 +33780,86 @@ Examples:
|
|
|
33758
33780
|
}
|
|
33759
33781
|
|
|
33760
33782
|
// src/cli/commands/org.ts
|
|
33783
|
+
var import_node_crypto9 = require("crypto");
|
|
33784
|
+
var import_node_fs16 = require("fs");
|
|
33785
|
+
var import_node_path18 = require("path");
|
|
33786
|
+
function pendingOrgCreatePath(baseUrl, accountId, sourceOrgId, name) {
|
|
33787
|
+
const intent = (0, import_node_crypto9.createHash)("sha256").update(accountId).update("\0").update(sourceOrgId).update("\0").update(name).digest("hex");
|
|
33788
|
+
return (0, import_node_path18.join)(sdkCliStateDirPath(baseUrl), `pending-org-create-${intent}.json`);
|
|
33789
|
+
}
|
|
33790
|
+
function readPendingOrgCreate(path, accountId, sourceOrgId, name) {
|
|
33791
|
+
let value;
|
|
33792
|
+
try {
|
|
33793
|
+
value = JSON.parse((0, import_node_fs16.readFileSync)(path, "utf8"));
|
|
33794
|
+
} catch (error) {
|
|
33795
|
+
throw new Error(
|
|
33796
|
+
`Cannot resume the pending workspace creation recorded at ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
33797
|
+
);
|
|
33798
|
+
}
|
|
33799
|
+
if (typeof value !== "object" || value === null || value.accountId !== accountId || value.sourceOrgId !== sourceOrgId || value.name !== name || typeof value.idempotencyKey !== "string" || !value.idempotencyKey.trim()) {
|
|
33800
|
+
throw new Error(
|
|
33801
|
+
`Cannot resume the pending workspace creation recorded at ${path}: the saved intent is invalid.`
|
|
33802
|
+
);
|
|
33803
|
+
}
|
|
33804
|
+
return value;
|
|
33805
|
+
}
|
|
33806
|
+
function loadOrCreatePendingOrgCreate(input2) {
|
|
33807
|
+
const stateDir = sdkCliStateDirPath(input2.baseUrl);
|
|
33808
|
+
const path = pendingOrgCreatePath(
|
|
33809
|
+
input2.baseUrl,
|
|
33810
|
+
input2.accountId,
|
|
33811
|
+
input2.sourceOrgId,
|
|
33812
|
+
input2.name
|
|
33813
|
+
);
|
|
33814
|
+
(0, import_node_fs16.mkdirSync)(stateDir, { recursive: true });
|
|
33815
|
+
if ((0, import_node_fs16.existsSync)(path)) {
|
|
33816
|
+
return {
|
|
33817
|
+
...readPendingOrgCreate(
|
|
33818
|
+
path,
|
|
33819
|
+
input2.accountId,
|
|
33820
|
+
input2.sourceOrgId,
|
|
33821
|
+
input2.name
|
|
33822
|
+
),
|
|
33823
|
+
path
|
|
33824
|
+
};
|
|
33825
|
+
}
|
|
33826
|
+
const pending = {
|
|
33827
|
+
accountId: input2.accountId,
|
|
33828
|
+
sourceOrgId: input2.sourceOrgId,
|
|
33829
|
+
name: input2.name,
|
|
33830
|
+
idempotencyKey: (0, import_node_crypto9.randomUUID)()
|
|
33831
|
+
};
|
|
33832
|
+
try {
|
|
33833
|
+
(0, import_node_fs16.writeFileSync)(path, `${JSON.stringify(pending)}
|
|
33834
|
+
`, {
|
|
33835
|
+
encoding: "utf8",
|
|
33836
|
+
flag: "wx",
|
|
33837
|
+
mode: 384
|
|
33838
|
+
});
|
|
33839
|
+
return { ...pending, path };
|
|
33840
|
+
} catch (error) {
|
|
33841
|
+
if (error.code !== "EEXIST") throw error;
|
|
33842
|
+
return {
|
|
33843
|
+
...readPendingOrgCreate(
|
|
33844
|
+
path,
|
|
33845
|
+
input2.accountId,
|
|
33846
|
+
input2.sourceOrgId,
|
|
33847
|
+
input2.name
|
|
33848
|
+
),
|
|
33849
|
+
path
|
|
33850
|
+
};
|
|
33851
|
+
}
|
|
33852
|
+
}
|
|
33853
|
+
async function fetchWorkspaceCreationIdentity(http, apiKey) {
|
|
33854
|
+
const status = await http.post("/api/v2/auth/cli/status", { api_key: apiKey });
|
|
33855
|
+
const accountId = status.user_id?.trim();
|
|
33856
|
+
if (!accountId) {
|
|
33857
|
+
throw new Error(
|
|
33858
|
+
"Workspace creation requires an API key linked to a user account."
|
|
33859
|
+
);
|
|
33860
|
+
}
|
|
33861
|
+
return { accountId, orgId: status.org_id?.trim() || null };
|
|
33862
|
+
}
|
|
33761
33863
|
async function fetchOrganizations(http, apiKey) {
|
|
33762
33864
|
return http.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
|
|
33763
33865
|
}
|
|
@@ -34226,23 +34328,58 @@ async function handleOrgSwitch(selection, options) {
|
|
|
34226
34328
|
}
|
|
34227
34329
|
async function handleOrgCreate(name, options) {
|
|
34228
34330
|
const config = resolveConfig();
|
|
34331
|
+
const normalizedName = name.trim();
|
|
34332
|
+
if (!normalizedName) {
|
|
34333
|
+
throw new Error("Workspace name is required.");
|
|
34334
|
+
}
|
|
34229
34335
|
const http = new HttpClient(config);
|
|
34230
|
-
const
|
|
34231
|
-
|
|
34232
|
-
|
|
34233
|
-
|
|
34336
|
+
const identity = await fetchWorkspaceCreationIdentity(http, config.apiKey);
|
|
34337
|
+
let created;
|
|
34338
|
+
let workspaceApiKey;
|
|
34339
|
+
let pendingIntentPath = null;
|
|
34340
|
+
if (!identity.orgId) {
|
|
34341
|
+
const firstWorkspace = await http.post("/api/v2/auth/cli/org-create", {
|
|
34342
|
+
api_key: config.apiKey,
|
|
34343
|
+
name: normalizedName
|
|
34344
|
+
});
|
|
34345
|
+
const { api_key: apiKey, ...publicFirstWorkspace } = firstWorkspace;
|
|
34346
|
+
workspaceApiKey = apiKey;
|
|
34347
|
+
created = publicFirstWorkspace;
|
|
34348
|
+
} else {
|
|
34349
|
+
const pending = loadOrCreatePendingOrgCreate({
|
|
34350
|
+
baseUrl: config.baseUrl,
|
|
34351
|
+
accountId: identity.accountId,
|
|
34352
|
+
sourceOrgId: identity.orgId,
|
|
34353
|
+
name: normalizedName
|
|
34354
|
+
});
|
|
34355
|
+
const workspace = await new DeeplineClient({
|
|
34356
|
+
apiKey: config.apiKey,
|
|
34357
|
+
baseUrl: config.baseUrl
|
|
34358
|
+
}).workspaces.create({
|
|
34359
|
+
name: normalizedName,
|
|
34360
|
+
idempotencyKey: pending.idempotencyKey
|
|
34361
|
+
});
|
|
34362
|
+
const switched = await http.post("/api/v2/auth/cli/switch", {
|
|
34363
|
+
api_key: config.apiKey,
|
|
34364
|
+
org_id: workspace.org_id
|
|
34365
|
+
});
|
|
34366
|
+
workspaceApiKey = switched.api_key;
|
|
34367
|
+
created = { ...workspace };
|
|
34368
|
+
pendingIntentPath = pending.path;
|
|
34369
|
+
}
|
|
34234
34370
|
const authValues = organizationAuthValues({
|
|
34235
34371
|
baseUrl: config.baseUrl,
|
|
34236
|
-
apiKey:
|
|
34372
|
+
apiKey: workspaceApiKey,
|
|
34237
34373
|
orgId: created.org_id,
|
|
34238
34374
|
orgName: created.org_name
|
|
34239
34375
|
});
|
|
34240
34376
|
saveHostEnvValues(config.baseUrl, authValues);
|
|
34241
|
-
|
|
34377
|
+
if (pendingIntentPath) (0, import_node_fs16.unlinkSync)(pendingIntentPath);
|
|
34242
34378
|
printCommandEnvelope(
|
|
34243
34379
|
{
|
|
34244
34380
|
ok: true,
|
|
34245
|
-
...
|
|
34381
|
+
...created,
|
|
34382
|
+
initial_credits: typeof created.initial_credits === "number" ? created.initial_credits : 0,
|
|
34246
34383
|
api_key_saved: true,
|
|
34247
34384
|
switched: true,
|
|
34248
34385
|
host_env_path: hostEnvFilePath(config.baseUrl),
|
|
@@ -34325,9 +34462,9 @@ Examples:
|
|
|
34325
34462
|
"after",
|
|
34326
34463
|
`
|
|
34327
34464
|
Notes:
|
|
34328
|
-
Mutates workspace state. The new organization is created for the
|
|
34329
|
-
authenticated user
|
|
34330
|
-
CLI
|
|
34465
|
+
Mutates workspace and billing state. The new organization is created for the
|
|
34466
|
+
current authenticated user and provisioned on the active PAYG offer before
|
|
34467
|
+
this CLI switches to it. Interrupted requests resume automatically.
|
|
34331
34468
|
|
|
34332
34469
|
Examples:
|
|
34333
34470
|
deepline org create Acme
|
|
@@ -34784,38 +34921,38 @@ Examples:
|
|
|
34784
34921
|
|
|
34785
34922
|
// src/cli/commands/setup.ts
|
|
34786
34923
|
var import_node_child_process4 = require("child_process");
|
|
34787
|
-
var
|
|
34924
|
+
var import_node_fs20 = require("fs");
|
|
34788
34925
|
var import_node_os13 = require("os");
|
|
34789
|
-
var
|
|
34926
|
+
var import_node_path22 = require("path");
|
|
34790
34927
|
|
|
34791
34928
|
// src/cli/installation-lifecycle.ts
|
|
34792
|
-
var
|
|
34793
|
-
var
|
|
34929
|
+
var import_node_fs17 = require("fs");
|
|
34930
|
+
var import_node_path19 = require("path");
|
|
34794
34931
|
var nodeFileSystem = {
|
|
34795
|
-
exists:
|
|
34932
|
+
exists: import_node_fs17.existsSync,
|
|
34796
34933
|
isSymbolicLink(path) {
|
|
34797
34934
|
try {
|
|
34798
|
-
return (0,
|
|
34935
|
+
return (0, import_node_fs17.lstatSync)(path).isSymbolicLink();
|
|
34799
34936
|
} catch {
|
|
34800
34937
|
return false;
|
|
34801
34938
|
}
|
|
34802
34939
|
},
|
|
34803
34940
|
read(path) {
|
|
34804
34941
|
try {
|
|
34805
|
-
return (0,
|
|
34942
|
+
return (0, import_node_fs17.readFileSync)(path, "utf8");
|
|
34806
34943
|
} catch {
|
|
34807
34944
|
return "";
|
|
34808
34945
|
}
|
|
34809
34946
|
},
|
|
34810
34947
|
realpath(path) {
|
|
34811
34948
|
try {
|
|
34812
|
-
return (0,
|
|
34949
|
+
return (0, import_node_fs17.realpathSync)(path);
|
|
34813
34950
|
} catch {
|
|
34814
34951
|
return null;
|
|
34815
34952
|
}
|
|
34816
34953
|
},
|
|
34817
34954
|
remove(path) {
|
|
34818
|
-
(0,
|
|
34955
|
+
(0, import_node_fs17.rmSync)(path, { force: true });
|
|
34819
34956
|
}
|
|
34820
34957
|
};
|
|
34821
34958
|
function inspectLauncher(path, fileSystem = nodeFileSystem) {
|
|
@@ -34846,25 +34983,25 @@ var CliInstallation = class _CliInstallation {
|
|
|
34846
34983
|
});
|
|
34847
34984
|
}
|
|
34848
34985
|
static isNpmPackagePath(path) {
|
|
34849
|
-
return path?.includes(`${(0,
|
|
34986
|
+
return path?.includes(`${(0, import_node_path19.join)("node_modules", "deepline")}`) ?? false;
|
|
34850
34987
|
}
|
|
34851
34988
|
launcher(path) {
|
|
34852
34989
|
return inspectLauncher(path, this.input.fileSystem);
|
|
34853
34990
|
}
|
|
34854
34991
|
retiredArtifacts() {
|
|
34855
|
-
const hostDir = (0,
|
|
34992
|
+
const hostDir = (0, import_node_path19.join)(
|
|
34856
34993
|
this.input.home,
|
|
34857
34994
|
".local",
|
|
34858
34995
|
"deepline",
|
|
34859
34996
|
this.input.baseUrlSlug
|
|
34860
34997
|
);
|
|
34861
|
-
const legacyLauncherPath = (0,
|
|
34998
|
+
const legacyLauncherPath = (0, import_node_path19.join)(
|
|
34862
34999
|
this.input.home,
|
|
34863
35000
|
".local",
|
|
34864
35001
|
"bin",
|
|
34865
35002
|
"deepline"
|
|
34866
35003
|
);
|
|
34867
|
-
const installerCommandPath = this.input.fileSystem.read((0,
|
|
35004
|
+
const installerCommandPath = this.input.fileSystem.read((0, import_node_path19.join)(hostDir, "sdk", ".command-path")).trim();
|
|
34868
35005
|
const ownedInstallerCommand = isOwnedInstallerCommandPath({
|
|
34869
35006
|
hostDir,
|
|
34870
35007
|
commandPath: installerCommandPath
|
|
@@ -34872,16 +35009,16 @@ var CliInstallation = class _CliInstallation {
|
|
|
34872
35009
|
const legacyLauncher = this.launcher(legacyLauncherPath);
|
|
34873
35010
|
const candidates = [
|
|
34874
35011
|
...legacyLauncher.ownership === "installer_legacy" ? [legacyLauncherPath] : [],
|
|
34875
|
-
(0,
|
|
34876
|
-
(0,
|
|
34877
|
-
(0,
|
|
34878
|
-
(0,
|
|
34879
|
-
(0,
|
|
34880
|
-
(0,
|
|
34881
|
-
(0,
|
|
35012
|
+
(0, import_node_path19.join)(this.input.home, ".local", "bin", "deepline-real"),
|
|
35013
|
+
(0, import_node_path19.join)(hostDir, "bin", "deepline"),
|
|
35014
|
+
(0, import_node_path19.join)(hostDir, "bin", "deepline-real"),
|
|
35015
|
+
(0, import_node_path19.join)(hostDir, "cli", ".install-method"),
|
|
35016
|
+
(0, import_node_path19.join)(hostDir, "cli", ".version"),
|
|
35017
|
+
(0, import_node_path19.join)(hostDir, "sdk", ".install-method"),
|
|
35018
|
+
(0, import_node_path19.join)(hostDir, "sdk", ".command-path"),
|
|
34882
35019
|
...ownedInstallerCommand ? [
|
|
34883
35020
|
installerCommandPath,
|
|
34884
|
-
(0,
|
|
35021
|
+
(0, import_node_path19.join)((0, import_node_path19.dirname)(installerCommandPath), "deepline-sdk")
|
|
34885
35022
|
] : []
|
|
34886
35023
|
];
|
|
34887
35024
|
return {
|
|
@@ -34902,19 +35039,19 @@ function removeArtifacts(plan, fileSystem) {
|
|
|
34902
35039
|
return plan.paths;
|
|
34903
35040
|
}
|
|
34904
35041
|
function isOwnedInstallerCommandPath(input2) {
|
|
34905
|
-
if (!input2.commandPath || (0,
|
|
35042
|
+
if (!input2.commandPath || (0, import_node_path19.basename)(input2.commandPath) !== "deepline") {
|
|
34906
35043
|
return false;
|
|
34907
35044
|
}
|
|
34908
|
-
const commandPath = (0,
|
|
34909
|
-
const fromHost = (0,
|
|
35045
|
+
const commandPath = (0, import_node_path19.resolve)(input2.commandPath);
|
|
35046
|
+
const fromHost = (0, import_node_path19.relative)((0, import_node_path19.resolve)(input2.hostDir), commandPath);
|
|
34910
35047
|
return fromHost !== "" && fromHost !== ".." && !fromHost.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
|
|
34911
35048
|
}
|
|
34912
35049
|
|
|
34913
35050
|
// src/cli/commands/skills.ts
|
|
34914
35051
|
var import_node_child_process3 = require("child_process");
|
|
34915
|
-
var
|
|
35052
|
+
var import_node_fs19 = require("fs");
|
|
34916
35053
|
var import_node_os12 = require("os");
|
|
34917
|
-
var
|
|
35054
|
+
var import_node_path21 = require("path");
|
|
34918
35055
|
|
|
34919
35056
|
// ../../shared_libs/cli/install-commands.json
|
|
34920
35057
|
var install_commands_default = {
|
|
@@ -35024,8 +35161,8 @@ function buildSkillsAddArgs(baseUrl, skillName, options = {}) {
|
|
|
35024
35161
|
|
|
35025
35162
|
// src/cli/skills-sync.ts
|
|
35026
35163
|
var import_node_child_process2 = require("child_process");
|
|
35027
|
-
var
|
|
35028
|
-
var
|
|
35164
|
+
var import_node_fs18 = require("fs");
|
|
35165
|
+
var import_node_path20 = require("path");
|
|
35029
35166
|
|
|
35030
35167
|
// src/cli/windows-arg-escape.ts
|
|
35031
35168
|
var CMD_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
|
|
@@ -35372,10 +35509,10 @@ function shouldSkipSkillsSync() {
|
|
|
35372
35509
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
35373
35510
|
}
|
|
35374
35511
|
function unavailableSkillsNoticePath(baseUrl) {
|
|
35375
|
-
return (0,
|
|
35512
|
+
return (0, import_node_path20.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
|
|
35376
35513
|
}
|
|
35377
35514
|
function failedSkillsSyncPath(baseUrl, agents) {
|
|
35378
|
-
return (0,
|
|
35515
|
+
return (0, import_node_path20.join)(
|
|
35379
35516
|
sdkCliStateDirPath(baseUrl),
|
|
35380
35517
|
`skills-sync-failed-${agents.join("-")}-version`
|
|
35381
35518
|
);
|
|
@@ -35385,15 +35522,15 @@ function hasMarkedSkillsSyncVersion(path, version) {
|
|
|
35385
35522
|
}
|
|
35386
35523
|
function readMarkedSkillsSyncVersion(path) {
|
|
35387
35524
|
try {
|
|
35388
|
-
return (0,
|
|
35525
|
+
return (0, import_node_fs18.existsSync)(path) ? (0, import_node_fs18.readFileSync)(path, "utf-8").trim() : "";
|
|
35389
35526
|
} catch {
|
|
35390
35527
|
return "";
|
|
35391
35528
|
}
|
|
35392
35529
|
}
|
|
35393
35530
|
function writeMarkedSkillsSyncVersion(path, version) {
|
|
35394
35531
|
try {
|
|
35395
|
-
(0,
|
|
35396
|
-
(0,
|
|
35532
|
+
(0, import_node_fs18.mkdirSync)((0, import_node_path20.dirname)(path), { recursive: true });
|
|
35533
|
+
(0, import_node_fs18.writeFileSync)(path, `${version}
|
|
35397
35534
|
`, "utf-8");
|
|
35398
35535
|
return true;
|
|
35399
35536
|
} catch {
|
|
@@ -35412,7 +35549,7 @@ ${manualCommand}`
|
|
|
35412
35549
|
}
|
|
35413
35550
|
function clearUnavailableSkillsNotice(baseUrl) {
|
|
35414
35551
|
try {
|
|
35415
|
-
(0,
|
|
35552
|
+
(0, import_node_fs18.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
|
|
35416
35553
|
} catch {
|
|
35417
35554
|
}
|
|
35418
35555
|
}
|
|
@@ -35423,7 +35560,7 @@ function hasFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
|
35423
35560
|
);
|
|
35424
35561
|
}
|
|
35425
35562
|
function hasFailedAutomaticSkillsSync(baseUrl, agents) {
|
|
35426
|
-
return (0,
|
|
35563
|
+
return (0, import_node_fs18.existsSync)(failedSkillsSyncPath(baseUrl, agents));
|
|
35427
35564
|
}
|
|
35428
35565
|
function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
35429
35566
|
return writeMarkedSkillsSyncVersion(
|
|
@@ -35433,7 +35570,7 @@ function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
|
35433
35570
|
}
|
|
35434
35571
|
function clearFailedSkillsSync(baseUrl, agents) {
|
|
35435
35572
|
try {
|
|
35436
|
-
(0,
|
|
35573
|
+
(0, import_node_fs18.unlinkSync)(failedSkillsSyncPath(baseUrl, agents));
|
|
35437
35574
|
} catch {
|
|
35438
35575
|
}
|
|
35439
35576
|
}
|
|
@@ -35800,13 +35937,13 @@ function detectSkillsAgents(input2) {
|
|
|
35800
35937
|
];
|
|
35801
35938
|
const detected = AGENT_MARKERS.filter(
|
|
35802
35939
|
(marker) => roots.some(
|
|
35803
|
-
(root) => marker.paths.some((path) => (0,
|
|
35940
|
+
(root) => marker.paths.some((path) => (0, import_node_fs19.existsSync)((0, import_node_path21.join)(root, path)))
|
|
35804
35941
|
)
|
|
35805
35942
|
).map((marker) => marker.agent);
|
|
35806
35943
|
return detected.length > 0 ? detected : ["*"];
|
|
35807
35944
|
}
|
|
35808
35945
|
function skillsStatePathForScope(baseUrl, scope, root) {
|
|
35809
|
-
return scope === "local" && root ? (0,
|
|
35946
|
+
return scope === "local" && root ? (0, import_node_path21.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path21.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
|
|
35810
35947
|
}
|
|
35811
35948
|
function buildSkillsPlan(input2) {
|
|
35812
35949
|
const scopeArgs = input2.scope === "global" ? ["--global"] : [];
|
|
@@ -35873,7 +36010,7 @@ function isSkillsPlanCurrent(plan, state) {
|
|
|
35873
36010
|
}
|
|
35874
36011
|
function readSkillsInstallState(path) {
|
|
35875
36012
|
try {
|
|
35876
|
-
const parsed = JSON.parse((0,
|
|
36013
|
+
const parsed = JSON.parse((0, import_node_fs19.readFileSync)(path, "utf8"));
|
|
35877
36014
|
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
35878
36015
|
} catch {
|
|
35879
36016
|
return null;
|
|
@@ -36026,8 +36163,8 @@ async function runSkillsCommand(options, dependencies = {}) {
|
|
|
36026
36163
|
`
|
|
36027
36164
|
);
|
|
36028
36165
|
}
|
|
36029
|
-
(0,
|
|
36030
|
-
(0,
|
|
36166
|
+
(0, import_node_fs19.mkdirSync)((0, import_node_path21.dirname)(plan.statePath), { recursive: true });
|
|
36167
|
+
(0, import_node_fs19.writeFileSync)(
|
|
36031
36168
|
plan.statePath,
|
|
36032
36169
|
`${JSON.stringify(
|
|
36033
36170
|
{
|
|
@@ -36165,7 +36302,7 @@ function phasesFromLegacyStatus(status) {
|
|
|
36165
36302
|
function readSetupState(input2) {
|
|
36166
36303
|
try {
|
|
36167
36304
|
const parsed = JSON.parse(
|
|
36168
|
-
(0,
|
|
36305
|
+
(0, import_node_fs20.readFileSync)(
|
|
36169
36306
|
setupStatePath(input2.baseUrl, input2.scope, input2.root),
|
|
36170
36307
|
"utf8"
|
|
36171
36308
|
)
|
|
@@ -36241,7 +36378,7 @@ function buildPendingAuthorizationOutput(input2) {
|
|
|
36241
36378
|
};
|
|
36242
36379
|
}
|
|
36243
36380
|
function setupStatePath(baseUrl, scope, root) {
|
|
36244
|
-
return scope === "local" && root ? (0,
|
|
36381
|
+
return scope === "local" && root ? (0, import_node_path22.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path22.join)(sdkCliStateDirPath(baseUrl), "setup.json");
|
|
36245
36382
|
}
|
|
36246
36383
|
async function captureStdout2(run) {
|
|
36247
36384
|
let stdout = "";
|
|
@@ -36270,7 +36407,7 @@ function asRecord3(value) {
|
|
|
36270
36407
|
}
|
|
36271
36408
|
function safeRead(path) {
|
|
36272
36409
|
try {
|
|
36273
|
-
return (0,
|
|
36410
|
+
return (0, import_node_fs20.readFileSync)(path, "utf8");
|
|
36274
36411
|
} catch {
|
|
36275
36412
|
return "";
|
|
36276
36413
|
}
|
|
@@ -36289,7 +36426,7 @@ function resolvePathCommands(command) {
|
|
|
36289
36426
|
);
|
|
36290
36427
|
return [
|
|
36291
36428
|
...new Set(
|
|
36292
|
-
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0,
|
|
36429
|
+
String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path22.resolve)(path))
|
|
36293
36430
|
)
|
|
36294
36431
|
];
|
|
36295
36432
|
}
|
|
@@ -36299,7 +36436,7 @@ function resolvePathCommand(command) {
|
|
|
36299
36436
|
function isHomebrewFormulaCommand(path) {
|
|
36300
36437
|
let resolvedPath = path;
|
|
36301
36438
|
try {
|
|
36302
|
-
resolvedPath = (0,
|
|
36439
|
+
resolvedPath = (0, import_node_fs20.realpathSync)(path);
|
|
36303
36440
|
} catch {
|
|
36304
36441
|
return false;
|
|
36305
36442
|
}
|
|
@@ -36310,7 +36447,7 @@ function isHomebrewFormulaCommand(path) {
|
|
|
36310
36447
|
function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
36311
36448
|
const platform3 = dependencies.platform ?? process.platform;
|
|
36312
36449
|
const run = dependencies.spawn ?? import_node_child_process4.spawnSync;
|
|
36313
|
-
const pathExists = dependencies.exists ??
|
|
36450
|
+
const pathExists = dependencies.exists ?? import_node_fs20.existsSync;
|
|
36314
36451
|
const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
|
|
36315
36452
|
const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
|
|
36316
36453
|
if (homebrewCommand) return homebrewCommand;
|
|
@@ -36322,7 +36459,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
|
36322
36459
|
if (prefix.status !== 0) return null;
|
|
36323
36460
|
const root = String(prefix.stdout ?? "").trim();
|
|
36324
36461
|
if (!root) return null;
|
|
36325
|
-
const candidates = platform3 === "win32" ? [(0,
|
|
36462
|
+
const candidates = platform3 === "win32" ? [(0, import_node_path22.join)(root, "deepline.cmd"), (0, import_node_path22.join)(root, "deepline")] : [(0, import_node_path22.join)(root, "bin", "deepline")];
|
|
36326
36463
|
return candidates.find((candidate) => pathExists(candidate)) ?? null;
|
|
36327
36464
|
}
|
|
36328
36465
|
function inspectGlobalCliAvailability(input2) {
|
|
@@ -36335,20 +36472,20 @@ function inspectGlobalCliAvailability(input2) {
|
|
|
36335
36472
|
}
|
|
36336
36473
|
function pathsResolveToSameFile(left, right) {
|
|
36337
36474
|
try {
|
|
36338
|
-
return (0,
|
|
36475
|
+
return (0, import_node_fs20.realpathSync)(left) === (0, import_node_fs20.realpathSync)(right);
|
|
36339
36476
|
} catch {
|
|
36340
|
-
return (0,
|
|
36477
|
+
return (0, import_node_path22.resolve)(left) === (0, import_node_path22.resolve)(right);
|
|
36341
36478
|
}
|
|
36342
36479
|
}
|
|
36343
36480
|
function isKnownDeeplineCommand(path) {
|
|
36344
|
-
const entrypoint = process.argv[1] ? (0,
|
|
36481
|
+
const entrypoint = process.argv[1] ? (0, import_node_path22.resolve)(process.argv[1]) : "";
|
|
36345
36482
|
let resolvedPath = path;
|
|
36346
36483
|
try {
|
|
36347
|
-
resolvedPath = (0,
|
|
36484
|
+
resolvedPath = (0, import_node_fs20.realpathSync)(path);
|
|
36348
36485
|
} catch {
|
|
36349
36486
|
}
|
|
36350
36487
|
if (entrypoint && resolvedPath === entrypoint) return true;
|
|
36351
|
-
if (resolvedPath.includes(`${(0,
|
|
36488
|
+
if (resolvedPath.includes(`${(0, import_node_path22.join)("node_modules", "deepline")}`)) return true;
|
|
36352
36489
|
const content = safeRead(path);
|
|
36353
36490
|
return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
|
|
36354
36491
|
}
|
|
@@ -36356,9 +36493,9 @@ function inspectPathConflict() {
|
|
|
36356
36493
|
const commandPath = resolvePathCommand("deepline");
|
|
36357
36494
|
if (!commandPath || isKnownDeeplineCommand(commandPath)) return null;
|
|
36358
36495
|
try {
|
|
36359
|
-
if ((0,
|
|
36360
|
-
const target = (0,
|
|
36361
|
-
if (target.includes(`${(0,
|
|
36496
|
+
if ((0, import_node_fs20.lstatSync)(commandPath).isSymbolicLink()) {
|
|
36497
|
+
const target = (0, import_node_fs20.realpathSync)(commandPath);
|
|
36498
|
+
if (target.includes(`${(0, import_node_path22.join)("node_modules", "deepline")}`)) return null;
|
|
36362
36499
|
}
|
|
36363
36500
|
} catch {
|
|
36364
36501
|
}
|
|
@@ -36366,8 +36503,8 @@ function inspectPathConflict() {
|
|
|
36366
36503
|
}
|
|
36367
36504
|
function writeSetupState(input2) {
|
|
36368
36505
|
const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
|
|
36369
|
-
(0,
|
|
36370
|
-
(0,
|
|
36506
|
+
(0, import_node_fs20.mkdirSync)((0, import_node_path22.dirname)(path), { recursive: true });
|
|
36507
|
+
(0, import_node_fs20.writeFileSync)(
|
|
36371
36508
|
path,
|
|
36372
36509
|
`${JSON.stringify(
|
|
36373
36510
|
{
|
|
@@ -36407,7 +36544,7 @@ function failSetupPhase(phases, phase, code) {
|
|
|
36407
36544
|
phases[phase] = { status: "failed", code };
|
|
36408
36545
|
}
|
|
36409
36546
|
function rollbackCommand(scope, root) {
|
|
36410
|
-
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0,
|
|
36547
|
+
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path22.join)(root, ".deepline", "runtime"))}` : "";
|
|
36411
36548
|
return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
|
|
36412
36549
|
}
|
|
36413
36550
|
function setupResumeCommand(baseUrl, scope) {
|
|
@@ -36494,12 +36631,12 @@ function buildDoctorAssessment(input2) {
|
|
|
36494
36631
|
const connected = input2.authStatus.payload?.connected === true;
|
|
36495
36632
|
const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
|
|
36496
36633
|
const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
|
|
36497
|
-
const runningCliPath = process.argv[1] ? (0,
|
|
36634
|
+
const runningCliPath = process.argv[1] ? (0, import_node_path22.resolve)(process.argv[1]) : null;
|
|
36498
36635
|
const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
|
|
36499
36636
|
const pathGlobalCli = globalCli?.path ?? null;
|
|
36500
36637
|
const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
|
|
36501
36638
|
const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
|
|
36502
|
-
input2.root && runningCliPath?.includes((0,
|
|
36639
|
+
input2.root && runningCliPath?.includes((0, import_node_path22.join)(input2.root, ".deepline", "runtime"))
|
|
36503
36640
|
);
|
|
36504
36641
|
const checks = {
|
|
36505
36642
|
cli: {
|
|
@@ -37031,9 +37168,9 @@ Examples:
|
|
|
37031
37168
|
}
|
|
37032
37169
|
|
|
37033
37170
|
// src/cli/update-preferences.ts
|
|
37034
|
-
var
|
|
37171
|
+
var import_node_fs21 = require("fs");
|
|
37035
37172
|
var import_node_os14 = require("os");
|
|
37036
|
-
var
|
|
37173
|
+
var import_node_path23 = require("path");
|
|
37037
37174
|
var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
|
|
37038
37175
|
var CLI_UPDATE_MESSAGES = [
|
|
37039
37176
|
{
|
|
@@ -37062,7 +37199,7 @@ function unreadablePreferences(path, error) {
|
|
|
37062
37199
|
};
|
|
37063
37200
|
}
|
|
37064
37201
|
function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
37065
|
-
return (0,
|
|
37202
|
+
return (0, import_node_path23.join)(
|
|
37066
37203
|
homeDir2,
|
|
37067
37204
|
".local",
|
|
37068
37205
|
"deepline",
|
|
@@ -37072,9 +37209,9 @@ function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
|
37072
37209
|
}
|
|
37073
37210
|
function readCliUpdatePreferences(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
37074
37211
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
37075
|
-
if (!(0,
|
|
37212
|
+
if (!(0, import_node_fs21.existsSync)(path)) return defaultPreferences();
|
|
37076
37213
|
try {
|
|
37077
|
-
const parsed = JSON.parse((0,
|
|
37214
|
+
const parsed = JSON.parse((0, import_node_fs21.readFileSync)(path, "utf8"));
|
|
37078
37215
|
return {
|
|
37079
37216
|
schemaVersion: UPDATE_PREFERENCES_SCHEMA_VERSION,
|
|
37080
37217
|
autoUpdateEnabled: typeof parsed.autoUpdateEnabled === "boolean" ? parsed.autoUpdateEnabled : true,
|
|
@@ -37090,16 +37227,16 @@ function readCliUpdatePreferences(homeDir2 = (0, import_node_os14.homedir)()) {
|
|
|
37090
37227
|
function writeCliUpdatePreferences(preferences, homeDir2 = (0, import_node_os14.homedir)()) {
|
|
37091
37228
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
37092
37229
|
const tempPath = `${path}.${process.pid}.tmp`;
|
|
37093
|
-
(0,
|
|
37230
|
+
(0, import_node_fs21.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
|
|
37094
37231
|
try {
|
|
37095
|
-
(0,
|
|
37232
|
+
(0, import_node_fs21.writeFileSync)(tempPath, `${JSON.stringify(preferences, null, 2)}
|
|
37096
37233
|
`, {
|
|
37097
37234
|
encoding: "utf8",
|
|
37098
37235
|
mode: 384
|
|
37099
37236
|
});
|
|
37100
|
-
(0,
|
|
37237
|
+
(0, import_node_fs21.renameSync)(tempPath, path);
|
|
37101
37238
|
} finally {
|
|
37102
|
-
(0,
|
|
37239
|
+
(0, import_node_fs21.rmSync)(tempPath, { force: true });
|
|
37103
37240
|
}
|
|
37104
37241
|
}
|
|
37105
37242
|
function setCliAutoUpdateEnabled(enabled, homeDir2 = (0, import_node_os14.homedir)()) {
|
|
@@ -37149,14 +37286,14 @@ function consumePendingCliUpdateMessages(homeDir2 = (0, import_node_os14.homedir
|
|
|
37149
37286
|
|
|
37150
37287
|
// src/cli/commands/update.ts
|
|
37151
37288
|
var import_node_child_process5 = require("child_process");
|
|
37152
|
-
var
|
|
37289
|
+
var import_node_fs23 = require("fs");
|
|
37153
37290
|
var import_node_os15 = require("os");
|
|
37154
|
-
var
|
|
37291
|
+
var import_node_path25 = require("path");
|
|
37155
37292
|
|
|
37156
37293
|
// src/cli/install-integrity.ts
|
|
37157
37294
|
var import_node_module2 = require("module");
|
|
37158
|
-
var
|
|
37159
|
-
var
|
|
37295
|
+
var import_node_fs22 = require("fs");
|
|
37296
|
+
var import_node_path24 = require("path");
|
|
37160
37297
|
var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
|
|
37161
37298
|
"dist/cli/index.mjs",
|
|
37162
37299
|
"dist/index.mjs",
|
|
@@ -37173,7 +37310,7 @@ var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
|
|
|
37173
37310
|
"esbuild/lib/main.js"
|
|
37174
37311
|
];
|
|
37175
37312
|
function safeRelativePath(value) {
|
|
37176
|
-
if (typeof value !== "string" || !value || (0,
|
|
37313
|
+
if (typeof value !== "string" || !value || (0, import_node_path24.isAbsolute)(value)) return false;
|
|
37177
37314
|
const segments = value.split(/[\\/]+/);
|
|
37178
37315
|
return segments.every(
|
|
37179
37316
|
(segment) => Boolean(segment) && segment !== "." && segment !== ".."
|
|
@@ -37181,25 +37318,25 @@ function safeRelativePath(value) {
|
|
|
37181
37318
|
}
|
|
37182
37319
|
function resolveContainedPath(root, value) {
|
|
37183
37320
|
if (!safeRelativePath(value)) return null;
|
|
37184
|
-
const target = (0,
|
|
37185
|
-
const relativeTarget = (0,
|
|
37186
|
-
if (!relativeTarget || relativeTarget.startsWith("..") || (0,
|
|
37321
|
+
const target = (0, import_node_path24.resolve)(root, value);
|
|
37322
|
+
const relativeTarget = (0, import_node_path24.relative)((0, import_node_path24.resolve)(root), target);
|
|
37323
|
+
if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path24.isAbsolute)(relativeTarget)) {
|
|
37187
37324
|
return null;
|
|
37188
37325
|
}
|
|
37189
37326
|
return target;
|
|
37190
37327
|
}
|
|
37191
37328
|
function parseJson(path) {
|
|
37192
|
-
return JSON.parse((0,
|
|
37329
|
+
return JSON.parse((0, import_node_fs22.readFileSync)(path, "utf8"));
|
|
37193
37330
|
}
|
|
37194
37331
|
function isFile(path) {
|
|
37195
37332
|
try {
|
|
37196
|
-
return (0,
|
|
37333
|
+
return (0, import_node_fs22.statSync)(path).isFile();
|
|
37197
37334
|
} catch {
|
|
37198
37335
|
return false;
|
|
37199
37336
|
}
|
|
37200
37337
|
}
|
|
37201
37338
|
function readManifest(packageRoot) {
|
|
37202
|
-
const packageJsonPath = (0,
|
|
37339
|
+
const packageJsonPath = (0, import_node_path24.join)(packageRoot, "package.json");
|
|
37203
37340
|
let packageJson;
|
|
37204
37341
|
try {
|
|
37205
37342
|
packageJson = parseJson(packageJsonPath);
|
|
@@ -37207,7 +37344,7 @@ function readManifest(packageRoot) {
|
|
|
37207
37344
|
return {
|
|
37208
37345
|
mode: "manifest",
|
|
37209
37346
|
invalidReason: `invalid Deepline package metadata: ${error.message}`,
|
|
37210
|
-
missing: (0,
|
|
37347
|
+
missing: (0, import_node_fs22.existsSync)(packageJsonPath) ? [] : ["deepline/package.json"]
|
|
37211
37348
|
};
|
|
37212
37349
|
}
|
|
37213
37350
|
if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
|
|
@@ -37273,8 +37410,8 @@ function readManifest(packageRoot) {
|
|
|
37273
37410
|
return { mode: "manifest", manifest };
|
|
37274
37411
|
}
|
|
37275
37412
|
function inspectSdkSidecarInstall(versionDir) {
|
|
37276
|
-
const nodeModulesRoot = (0,
|
|
37277
|
-
const packageRoot = (0,
|
|
37413
|
+
const nodeModulesRoot = (0, import_node_path24.join)(versionDir, "node_modules");
|
|
37414
|
+
const packageRoot = (0, import_node_path24.join)(nodeModulesRoot, "deepline");
|
|
37278
37415
|
const manifestResult = readManifest(packageRoot);
|
|
37279
37416
|
if ("invalidReason" in manifestResult) {
|
|
37280
37417
|
return {
|
|
@@ -37285,8 +37422,8 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
37285
37422
|
};
|
|
37286
37423
|
}
|
|
37287
37424
|
const missing = [
|
|
37288
|
-
...manifestResult.manifest.packageFiles.filter((path) => !isFile((0,
|
|
37289
|
-
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0,
|
|
37425
|
+
...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path24.join)(packageRoot, path))).map((path) => `deepline/${path}`),
|
|
37426
|
+
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path24.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
|
|
37290
37427
|
];
|
|
37291
37428
|
return {
|
|
37292
37429
|
ok: missing.length === 0,
|
|
@@ -37297,7 +37434,7 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
37297
37434
|
}
|
|
37298
37435
|
function probeSdkSidecarEsbuild(versionDir) {
|
|
37299
37436
|
try {
|
|
37300
|
-
const requireFromInstall = (0, import_node_module2.createRequire)((0,
|
|
37437
|
+
const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path24.join)(versionDir, "package.json"));
|
|
37301
37438
|
const esbuild = requireFromInstall("esbuild");
|
|
37302
37439
|
if (typeof esbuild.transformSync !== "function") {
|
|
37303
37440
|
return "esbuild does not export transformSync";
|
|
@@ -37372,7 +37509,7 @@ function sidecarStateDir(input2) {
|
|
|
37372
37509
|
if (!scope || scope.includes("/") || scope.includes("\\")) {
|
|
37373
37510
|
return null;
|
|
37374
37511
|
}
|
|
37375
|
-
return (0,
|
|
37512
|
+
return (0, import_node_path25.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
|
|
37376
37513
|
}
|
|
37377
37514
|
function sidecarRegistryUrl(hostUrl) {
|
|
37378
37515
|
let url;
|
|
@@ -37399,7 +37536,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
|
|
|
37399
37536
|
}
|
|
37400
37537
|
function readOptionalText(path) {
|
|
37401
37538
|
try {
|
|
37402
|
-
return (0,
|
|
37539
|
+
return (0, import_node_fs23.readFileSync)(path, "utf8").trim();
|
|
37403
37540
|
} catch {
|
|
37404
37541
|
return "";
|
|
37405
37542
|
}
|
|
@@ -37407,19 +37544,19 @@ function readOptionalText(path) {
|
|
|
37407
37544
|
function resolvePythonSidecarUpdatePlan(options) {
|
|
37408
37545
|
const stateDir = sidecarStateDir(options);
|
|
37409
37546
|
if (!stateDir) return null;
|
|
37410
|
-
const relativeEntrypoint = (0,
|
|
37411
|
-
(0,
|
|
37412
|
-
(0,
|
|
37547
|
+
const relativeEntrypoint = (0, import_node_path25.relative)(
|
|
37548
|
+
(0, import_node_path25.resolve)(stateDir),
|
|
37549
|
+
(0, import_node_path25.resolve)(options.entrypoint)
|
|
37413
37550
|
);
|
|
37414
|
-
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0,
|
|
37551
|
+
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path25.isAbsolute)(relativeEntrypoint)) {
|
|
37415
37552
|
return null;
|
|
37416
37553
|
}
|
|
37417
|
-
const installMethod = readOptionalText((0,
|
|
37554
|
+
const installMethod = readOptionalText((0, import_node_path25.join)(stateDir, ".install-method"));
|
|
37418
37555
|
if (installMethod !== "python-sidecar") return null;
|
|
37419
37556
|
const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
|
|
37420
37557
|
const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
|
|
37421
|
-
const nodeBin = readOptionalText((0,
|
|
37422
|
-
const sidecarPath = readOptionalText((0,
|
|
37558
|
+
const nodeBin = readOptionalText((0, import_node_path25.join)(stateDir, ".node-bin")) || process.execPath;
|
|
37559
|
+
const sidecarPath = readOptionalText((0, import_node_path25.join)(stateDir, ".command-path")) || (0, import_node_path25.join)(
|
|
37423
37560
|
stateDir,
|
|
37424
37561
|
"bin",
|
|
37425
37562
|
process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
|
|
@@ -37427,7 +37564,7 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37427
37564
|
const packageSpec = options.packageSpec || "deepline@latest";
|
|
37428
37565
|
const npmCommand = "npm";
|
|
37429
37566
|
const registryUrl = sidecarRegistryUrl(hostUrl);
|
|
37430
|
-
const versionDir = (0,
|
|
37567
|
+
const versionDir = (0, import_node_path25.join)(stateDir, "versions", "<version>");
|
|
37431
37568
|
const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
|
|
37432
37569
|
return {
|
|
37433
37570
|
kind: "python-sidecar",
|
|
@@ -37443,16 +37580,16 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37443
37580
|
};
|
|
37444
37581
|
}
|
|
37445
37582
|
function findRepoBackedSdkRoot(startPath) {
|
|
37446
|
-
let current = (0,
|
|
37583
|
+
let current = (0, import_node_path25.resolve)(startPath);
|
|
37447
37584
|
while (true) {
|
|
37448
|
-
if ((0,
|
|
37449
|
-
const parent2 = (0,
|
|
37450
|
-
return (0,
|
|
37585
|
+
if ((0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "bin", "deepline-dev.ts"))) {
|
|
37586
|
+
const parent2 = (0, import_node_path25.dirname)(current);
|
|
37587
|
+
return (0, import_node_path25.basename)(parent2) === "packages" && (0, import_node_path25.basename)(current) === "sdk" ? (0, import_node_path25.dirname)(parent2) : parent2;
|
|
37451
37588
|
}
|
|
37452
|
-
if ((0,
|
|
37589
|
+
if ((0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "sdk", "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
|
|
37453
37590
|
return current;
|
|
37454
37591
|
}
|
|
37455
|
-
const parent = (0,
|
|
37592
|
+
const parent = (0, import_node_path25.dirname)(current);
|
|
37456
37593
|
if (parent === current) return null;
|
|
37457
37594
|
current = parent;
|
|
37458
37595
|
}
|
|
@@ -37460,9 +37597,9 @@ function findRepoBackedSdkRoot(startPath) {
|
|
|
37460
37597
|
function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
|
|
37461
37598
|
const normalized = (() => {
|
|
37462
37599
|
try {
|
|
37463
|
-
return (0,
|
|
37600
|
+
return (0, import_node_fs23.realpathSync)(entrypoint);
|
|
37464
37601
|
} catch {
|
|
37465
|
-
return (0,
|
|
37602
|
+
return (0, import_node_path25.resolve)(entrypoint);
|
|
37466
37603
|
}
|
|
37467
37604
|
})();
|
|
37468
37605
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -37477,10 +37614,10 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
|
|
|
37477
37614
|
const directPrefix = prefixParts.join("/").toLowerCase();
|
|
37478
37615
|
const knownWindowsPrefixes = [
|
|
37479
37616
|
env.npm_config_prefix,
|
|
37480
|
-
env.APPDATA ? (0,
|
|
37481
|
-
].filter((value) => Boolean(value)).map((value) => (0,
|
|
37617
|
+
env.APPDATA ? (0, import_node_path25.join)(env.APPDATA, "npm") : void 0
|
|
37618
|
+
].filter((value) => Boolean(value)).map((value) => (0, import_node_path25.resolve)(value).replace(/\\/g, "/").toLowerCase());
|
|
37482
37619
|
if (!knownWindowsPrefixes.includes(
|
|
37483
|
-
(0,
|
|
37620
|
+
(0, import_node_path25.resolve)(directPrefix).replace(/\\/g, "/").toLowerCase()
|
|
37484
37621
|
)) {
|
|
37485
37622
|
return null;
|
|
37486
37623
|
}
|
|
@@ -37493,9 +37630,9 @@ function normalizedNpmPrefix(value) {
|
|
|
37493
37630
|
if (!trimmed) return null;
|
|
37494
37631
|
const normalized = (() => {
|
|
37495
37632
|
try {
|
|
37496
|
-
return (0,
|
|
37633
|
+
return (0, import_node_fs23.realpathSync)((0, import_node_path25.resolve)(trimmed));
|
|
37497
37634
|
} catch {
|
|
37498
|
-
return (0,
|
|
37635
|
+
return (0, import_node_path25.resolve)(trimmed);
|
|
37499
37636
|
}
|
|
37500
37637
|
})().replace(/\\/g, "/");
|
|
37501
37638
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
@@ -37518,9 +37655,9 @@ function resolveNpmGlobalPrefix(env) {
|
|
|
37518
37655
|
function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
37519
37656
|
const normalized = (() => {
|
|
37520
37657
|
try {
|
|
37521
|
-
return (0,
|
|
37658
|
+
return (0, import_node_fs23.realpathSync)(entrypoint);
|
|
37522
37659
|
} catch {
|
|
37523
|
-
return (0,
|
|
37660
|
+
return (0, import_node_path25.resolve)(entrypoint);
|
|
37524
37661
|
}
|
|
37525
37662
|
})();
|
|
37526
37663
|
const parts = normalized.split(/[\\/]+/);
|
|
@@ -37530,8 +37667,8 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
|
|
|
37530
37667
|
function resolveUpdatePlan(options = {}) {
|
|
37531
37668
|
const env = options.env ?? process.env;
|
|
37532
37669
|
const homeDir2 = options.homeDir ?? (0, import_node_os15.homedir)();
|
|
37533
|
-
const entrypoint = options.entrypoint ?? (process.argv[1] ? (0,
|
|
37534
|
-
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0,
|
|
37670
|
+
const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path25.resolve)(process.argv[1]) : "");
|
|
37671
|
+
const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path25.dirname)(entrypoint)) : null;
|
|
37535
37672
|
if (sourceRoot) {
|
|
37536
37673
|
return {
|
|
37537
37674
|
kind: "source",
|
|
@@ -37582,9 +37719,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
|
|
|
37582
37719
|
function autoUpdateFailurePath(plan) {
|
|
37583
37720
|
if (plan.kind === "source" || plan.kind === "homebrew") return null;
|
|
37584
37721
|
if (plan.kind === "python-sidecar") {
|
|
37585
|
-
return (0,
|
|
37722
|
+
return (0, import_node_path25.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
|
|
37586
37723
|
}
|
|
37587
|
-
return (0,
|
|
37724
|
+
return (0, import_node_path25.join)(
|
|
37588
37725
|
(0, import_node_os15.homedir)(),
|
|
37589
37726
|
".local",
|
|
37590
37727
|
"deepline",
|
|
@@ -37602,7 +37739,7 @@ function readAutoUpdateFailure(plan) {
|
|
|
37602
37739
|
if (!path) return null;
|
|
37603
37740
|
try {
|
|
37604
37741
|
const parsed = JSON.parse(
|
|
37605
|
-
(0,
|
|
37742
|
+
(0, import_node_fs23.readFileSync)(path, "utf8")
|
|
37606
37743
|
);
|
|
37607
37744
|
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") {
|
|
37608
37745
|
return parsed;
|
|
@@ -37623,8 +37760,8 @@ function writeAutoUpdateFailure(plan, exitCode) {
|
|
|
37623
37760
|
manualCommand: plan.manualCommand
|
|
37624
37761
|
};
|
|
37625
37762
|
try {
|
|
37626
|
-
(0,
|
|
37627
|
-
(0,
|
|
37763
|
+
(0, import_node_fs23.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
|
|
37764
|
+
(0, import_node_fs23.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
|
|
37628
37765
|
`, "utf8");
|
|
37629
37766
|
} catch {
|
|
37630
37767
|
}
|
|
@@ -37633,7 +37770,7 @@ function clearAutoUpdateFailure(plan) {
|
|
|
37633
37770
|
const path = autoUpdateFailurePath(plan);
|
|
37634
37771
|
if (!path) return;
|
|
37635
37772
|
try {
|
|
37636
|
-
(0,
|
|
37773
|
+
(0, import_node_fs23.unlinkSync)(path);
|
|
37637
37774
|
} catch {
|
|
37638
37775
|
}
|
|
37639
37776
|
}
|
|
@@ -37671,7 +37808,7 @@ function safeVersionSegment(value) {
|
|
|
37671
37808
|
return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
|
|
37672
37809
|
}
|
|
37673
37810
|
function entryPathInVersionDir(versionDir) {
|
|
37674
|
-
return (0,
|
|
37811
|
+
return (0, import_node_path25.join)(
|
|
37675
37812
|
versionDir,
|
|
37676
37813
|
"node_modules",
|
|
37677
37814
|
"deepline",
|
|
@@ -37681,14 +37818,14 @@ function entryPathInVersionDir(versionDir) {
|
|
|
37681
37818
|
);
|
|
37682
37819
|
}
|
|
37683
37820
|
function installedPackageVersion(versionDir) {
|
|
37684
|
-
const packageJsonPath = (0,
|
|
37821
|
+
const packageJsonPath = (0, import_node_path25.join)(
|
|
37685
37822
|
versionDir,
|
|
37686
37823
|
"node_modules",
|
|
37687
37824
|
"deepline",
|
|
37688
37825
|
"package.json"
|
|
37689
37826
|
);
|
|
37690
37827
|
try {
|
|
37691
|
-
const parsed = JSON.parse((0,
|
|
37828
|
+
const parsed = JSON.parse((0, import_node_fs23.readFileSync)(packageJsonPath, "utf8"));
|
|
37692
37829
|
return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
|
|
37693
37830
|
} catch {
|
|
37694
37831
|
return "";
|
|
@@ -37803,20 +37940,20 @@ async function runNpmInstallWithRegistryFallback(input2) {
|
|
|
37803
37940
|
return first.exitCode;
|
|
37804
37941
|
}
|
|
37805
37942
|
function writeSidecarLauncher(input2) {
|
|
37806
|
-
(0,
|
|
37807
|
-
const packageRoot = (0,
|
|
37808
|
-
const versionDir = (0,
|
|
37943
|
+
(0, import_node_fs23.mkdirSync)((0, import_node_path25.dirname)(input2.path), { recursive: true });
|
|
37944
|
+
const packageRoot = (0, import_node_path25.dirname)((0, import_node_path25.dirname)((0, import_node_path25.dirname)(input2.entryPath)));
|
|
37945
|
+
const versionDir = (0, import_node_path25.dirname)((0, import_node_path25.dirname)(packageRoot));
|
|
37809
37946
|
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);";
|
|
37810
37947
|
const criticalPaths = [
|
|
37811
37948
|
...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
|
|
37812
|
-
(path) => (0,
|
|
37949
|
+
(path) => (0, import_node_path25.join)(packageRoot, path)
|
|
37813
37950
|
),
|
|
37814
37951
|
...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
|
|
37815
|
-
(path) => (0,
|
|
37952
|
+
(path) => (0, import_node_path25.join)(versionDir, "node_modules", path)
|
|
37816
37953
|
)
|
|
37817
37954
|
];
|
|
37818
37955
|
if (process.platform === "win32") {
|
|
37819
|
-
(0,
|
|
37956
|
+
(0, import_node_fs23.writeFileSync)(
|
|
37820
37957
|
input2.path,
|
|
37821
37958
|
[
|
|
37822
37959
|
`@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
|
|
@@ -37839,7 +37976,7 @@ function writeSidecarLauncher(input2) {
|
|
|
37839
37976
|
);
|
|
37840
37977
|
return;
|
|
37841
37978
|
}
|
|
37842
|
-
(0,
|
|
37979
|
+
(0, import_node_fs23.writeFileSync)(
|
|
37843
37980
|
input2.path,
|
|
37844
37981
|
[
|
|
37845
37982
|
"#!/usr/bin/env sh",
|
|
@@ -37866,17 +38003,17 @@ function writeSidecarLauncher(input2) {
|
|
|
37866
38003
|
);
|
|
37867
38004
|
}
|
|
37868
38005
|
async function runPythonSidecarUpdatePlan(plan) {
|
|
37869
|
-
const versionsDir = (0,
|
|
37870
|
-
const tempDir = (0,
|
|
38006
|
+
const versionsDir = (0, import_node_path25.join)(plan.stateDir, "versions");
|
|
38007
|
+
const tempDir = (0, import_node_path25.join)(
|
|
37871
38008
|
versionsDir,
|
|
37872
38009
|
`.tmp-sdk-update-${process.pid}-${Date.now()}`
|
|
37873
38010
|
);
|
|
37874
|
-
(0,
|
|
37875
|
-
(0,
|
|
37876
|
-
(0,
|
|
38011
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
38012
|
+
(0, import_node_fs23.mkdirSync)(tempDir, { recursive: true });
|
|
38013
|
+
(0, import_node_fs23.writeFileSync)((0, import_node_path25.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
|
|
37877
38014
|
const env = {
|
|
37878
38015
|
...process.env,
|
|
37879
|
-
PATH: `${(0,
|
|
38016
|
+
PATH: `${(0, import_node_path25.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
|
|
37880
38017
|
};
|
|
37881
38018
|
const installResult = await runCommand(
|
|
37882
38019
|
plan.npmCommand,
|
|
@@ -37893,7 +38030,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
37893
38030
|
);
|
|
37894
38031
|
const installExitCode = installResult.exitCode;
|
|
37895
38032
|
if (installExitCode !== 0) {
|
|
37896
|
-
(0,
|
|
38033
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
37897
38034
|
return installExitCode;
|
|
37898
38035
|
}
|
|
37899
38036
|
const installedVersion = installedPackageVersion(tempDir);
|
|
@@ -37901,7 +38038,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
37901
38038
|
process.stderr.write(
|
|
37902
38039
|
"Updated Deepline SDK package did not report a version.\n"
|
|
37903
38040
|
);
|
|
37904
|
-
(0,
|
|
38041
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
37905
38042
|
return 1;
|
|
37906
38043
|
}
|
|
37907
38044
|
const stagedFailure = sidecarInstallFailure(tempDir);
|
|
@@ -37910,32 +38047,32 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
37910
38047
|
`Updated Deepline SDK package is incomplete: ${stagedFailure}.
|
|
37911
38048
|
`
|
|
37912
38049
|
);
|
|
37913
|
-
(0,
|
|
38050
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
37914
38051
|
return 1;
|
|
37915
38052
|
}
|
|
37916
|
-
const finalDir = (0,
|
|
38053
|
+
const finalDir = (0, import_node_path25.join)(versionsDir, installedVersion);
|
|
37917
38054
|
const finalEntryPath = entryPathInVersionDir(finalDir);
|
|
37918
38055
|
const finalFailure = sidecarInstallFailure(finalDir);
|
|
37919
38056
|
let backupDir = null;
|
|
37920
38057
|
if (!finalFailure) {
|
|
37921
|
-
(0,
|
|
38058
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
37922
38059
|
} else {
|
|
37923
38060
|
let shouldPublishTemp = true;
|
|
37924
|
-
if ((0,
|
|
37925
|
-
backupDir = (0,
|
|
38061
|
+
if ((0, import_node_fs23.existsSync)(finalDir)) {
|
|
38062
|
+
backupDir = (0, import_node_path25.join)(
|
|
37926
38063
|
versionsDir,
|
|
37927
38064
|
`.backup-${installedVersion}-${process.pid}-${Date.now()}`
|
|
37928
38065
|
);
|
|
37929
38066
|
try {
|
|
37930
|
-
(0,
|
|
38067
|
+
(0, import_node_fs23.renameSync)(finalDir, backupDir);
|
|
37931
38068
|
} catch (error) {
|
|
37932
38069
|
const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
|
|
37933
38070
|
if (!concurrentlyPublishedFailure) {
|
|
37934
|
-
(0,
|
|
38071
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
37935
38072
|
backupDir = null;
|
|
37936
38073
|
shouldPublishTemp = false;
|
|
37937
38074
|
} else {
|
|
37938
|
-
(0,
|
|
38075
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
37939
38076
|
process.stderr.write(
|
|
37940
38077
|
`Failed to preserve the incomplete Deepline SDK sidecar before repair: ${error.message}.
|
|
37941
38078
|
`
|
|
@@ -37946,18 +38083,18 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
37946
38083
|
}
|
|
37947
38084
|
if (shouldPublishTemp) {
|
|
37948
38085
|
try {
|
|
37949
|
-
(0,
|
|
38086
|
+
(0, import_node_fs23.renameSync)(tempDir, finalDir);
|
|
37950
38087
|
} catch (error) {
|
|
37951
|
-
(0,
|
|
38088
|
+
(0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
|
|
37952
38089
|
const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
|
|
37953
38090
|
if (!concurrentlyPublishedFailure) {
|
|
37954
|
-
if (backupDir) (0,
|
|
38091
|
+
if (backupDir) (0, import_node_fs23.rmSync)(backupDir, { recursive: true, force: true });
|
|
37955
38092
|
backupDir = null;
|
|
37956
38093
|
} else {
|
|
37957
38094
|
let restoreFailure = "";
|
|
37958
|
-
if (backupDir && (0,
|
|
38095
|
+
if (backupDir && (0, import_node_fs23.existsSync)(backupDir) && !(0, import_node_fs23.existsSync)(finalDir)) {
|
|
37959
38096
|
try {
|
|
37960
|
-
(0,
|
|
38097
|
+
(0, import_node_fs23.renameSync)(backupDir, finalDir);
|
|
37961
38098
|
backupDir = null;
|
|
37962
38099
|
} catch (restoreError) {
|
|
37963
38100
|
restoreFailure = `; failed to restore previous install: ${restoreError.message}`;
|
|
@@ -37974,10 +38111,10 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
37974
38111
|
}
|
|
37975
38112
|
const publishedFailure = sidecarStructureFailure(finalDir);
|
|
37976
38113
|
if (publishedFailure) {
|
|
37977
|
-
if (backupDir && (0,
|
|
37978
|
-
(0,
|
|
38114
|
+
if (backupDir && (0, import_node_fs23.existsSync)(backupDir)) {
|
|
38115
|
+
(0, import_node_fs23.rmSync)(finalDir, { recursive: true, force: true });
|
|
37979
38116
|
try {
|
|
37980
|
-
(0,
|
|
38117
|
+
(0, import_node_fs23.renameSync)(backupDir, finalDir);
|
|
37981
38118
|
backupDir = null;
|
|
37982
38119
|
} catch {
|
|
37983
38120
|
}
|
|
@@ -37988,7 +38125,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
37988
38125
|
);
|
|
37989
38126
|
return 1;
|
|
37990
38127
|
}
|
|
37991
|
-
if (backupDir) (0,
|
|
38128
|
+
if (backupDir) (0, import_node_fs23.rmSync)(backupDir, { recursive: true, force: true });
|
|
37992
38129
|
writeSidecarLauncher({
|
|
37993
38130
|
path: plan.sidecarPath,
|
|
37994
38131
|
hostUrl: plan.hostUrl,
|
|
@@ -37996,28 +38133,28 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
37996
38133
|
nodeBin: plan.nodeBin,
|
|
37997
38134
|
entryPath: finalEntryPath
|
|
37998
38135
|
});
|
|
37999
|
-
(0,
|
|
38000
|
-
(0,
|
|
38136
|
+
(0, import_node_fs23.writeFileSync)(
|
|
38137
|
+
(0, import_node_path25.join)(plan.stateDir, ".version"),
|
|
38001
38138
|
`${installedVersion}
|
|
38002
38139
|
`,
|
|
38003
38140
|
"utf8"
|
|
38004
38141
|
);
|
|
38005
|
-
(0,
|
|
38006
|
-
(0,
|
|
38142
|
+
(0, import_node_fs23.writeFileSync)(
|
|
38143
|
+
(0, import_node_path25.join)(plan.stateDir, ".install-method"),
|
|
38007
38144
|
"python-sidecar\n",
|
|
38008
38145
|
"utf8"
|
|
38009
38146
|
);
|
|
38010
|
-
(0,
|
|
38011
|
-
(0,
|
|
38147
|
+
(0, import_node_fs23.writeFileSync)(
|
|
38148
|
+
(0, import_node_path25.join)(plan.stateDir, ".command-path"),
|
|
38012
38149
|
`${plan.sidecarPath}
|
|
38013
38150
|
`,
|
|
38014
38151
|
"utf8"
|
|
38015
38152
|
);
|
|
38016
|
-
(0,
|
|
38017
|
-
(0,
|
|
38153
|
+
(0, import_node_fs23.writeFileSync)((0, import_node_path25.join)(plan.stateDir, ".runner"), "node\n", "utf8");
|
|
38154
|
+
(0, import_node_fs23.writeFileSync)((0, import_node_path25.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
|
|
38018
38155
|
`, "utf8");
|
|
38019
|
-
(0,
|
|
38020
|
-
(0,
|
|
38156
|
+
(0, import_node_fs23.writeFileSync)(
|
|
38157
|
+
(0, import_node_path25.join)(plan.stateDir, ".entry-path"),
|
|
38021
38158
|
`${finalEntryPath}
|
|
38022
38159
|
`,
|
|
38023
38160
|
"utf8"
|
|
@@ -38944,14 +39081,14 @@ chooses the connected Slack channel or member and the events it receives.
|
|
|
38944
39081
|
|
|
38945
39082
|
// src/cli/commands/tools.ts
|
|
38946
39083
|
var import_commander3 = require("commander");
|
|
38947
|
-
var
|
|
39084
|
+
var import_node_fs25 = require("fs");
|
|
38948
39085
|
var import_node_os17 = require("os");
|
|
38949
|
-
var
|
|
39086
|
+
var import_node_path27 = require("path");
|
|
38950
39087
|
|
|
38951
39088
|
// src/tool-output.ts
|
|
38952
|
-
var
|
|
39089
|
+
var import_node_fs24 = require("fs");
|
|
38953
39090
|
var import_node_os16 = require("os");
|
|
38954
|
-
var
|
|
39091
|
+
var import_node_path26 = require("path");
|
|
38955
39092
|
function isPlainObject(value) {
|
|
38956
39093
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
38957
39094
|
}
|
|
@@ -39078,19 +39215,19 @@ function projectRowOutput(conversion) {
|
|
|
39078
39215
|
};
|
|
39079
39216
|
}
|
|
39080
39217
|
function ensureOutputDir() {
|
|
39081
|
-
const outputDir = (0,
|
|
39082
|
-
(0,
|
|
39218
|
+
const outputDir = (0, import_node_path26.join)((0, import_node_os16.homedir)(), ".local", "share", "deepline", "data");
|
|
39219
|
+
(0, import_node_fs24.mkdirSync)(outputDir, { recursive: true });
|
|
39083
39220
|
return outputDir;
|
|
39084
39221
|
}
|
|
39085
39222
|
function writeJsonOutputFile(payload, stem) {
|
|
39086
39223
|
const outputDir = ensureOutputDir();
|
|
39087
|
-
const outputPath = (0,
|
|
39088
|
-
(0,
|
|
39224
|
+
const outputPath = (0, import_node_path26.join)(outputDir, `${stem}_${Date.now()}.json`);
|
|
39225
|
+
(0, import_node_fs24.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
39089
39226
|
return outputPath;
|
|
39090
39227
|
}
|
|
39091
39228
|
function writeCsvOutputFile(rows, stem, options) {
|
|
39092
|
-
const outputPath = options?.outPath ? options.outPath : (0,
|
|
39093
|
-
(0,
|
|
39229
|
+
const outputPath = options?.outPath ? options.outPath : (0, import_node_path26.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
39230
|
+
(0, import_node_fs24.mkdirSync)((0, import_node_path26.dirname)(outputPath), { recursive: true });
|
|
39094
39231
|
const columns = columnsForRows(rows);
|
|
39095
39232
|
const escapeCell = (value) => {
|
|
39096
39233
|
const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
|
|
@@ -39099,19 +39236,19 @@ function writeCsvOutputFile(rows, stem, options) {
|
|
|
39099
39236
|
}
|
|
39100
39237
|
return normalized;
|
|
39101
39238
|
};
|
|
39102
|
-
const fd = (0,
|
|
39239
|
+
const fd = (0, import_node_fs24.openSync)(outputPath, "w");
|
|
39103
39240
|
try {
|
|
39104
|
-
(0,
|
|
39241
|
+
(0, import_node_fs24.writeSync)(fd, `${columns.map(escapeCell).join(",")}
|
|
39105
39242
|
`);
|
|
39106
39243
|
for (const row of rows) {
|
|
39107
|
-
(0,
|
|
39244
|
+
(0, import_node_fs24.writeSync)(
|
|
39108
39245
|
fd,
|
|
39109
39246
|
`${columns.map((column) => escapeCell(row[column])).join(",")}
|
|
39110
39247
|
`
|
|
39111
39248
|
);
|
|
39112
39249
|
}
|
|
39113
39250
|
} finally {
|
|
39114
|
-
(0,
|
|
39251
|
+
(0, import_node_fs24.closeSync)(fd);
|
|
39115
39252
|
}
|
|
39116
39253
|
const previewRows = rows.slice(0, 5);
|
|
39117
39254
|
const previewColumns = columns.slice(0, 5);
|
|
@@ -41050,11 +41187,11 @@ function normalizeOutputFormat(raw) {
|
|
|
41050
41187
|
}
|
|
41051
41188
|
function resolveAtFilePath(rawPath) {
|
|
41052
41189
|
const trimmed = rawPath.trim();
|
|
41053
|
-
const resolved = (0,
|
|
41054
|
-
if ((0,
|
|
41190
|
+
const resolved = (0, import_node_path27.resolve)(trimmed);
|
|
41191
|
+
if ((0, import_node_fs25.existsSync)(resolved)) return resolved;
|
|
41055
41192
|
if (process.platform !== "win32" && trimmed.includes("\\")) {
|
|
41056
|
-
const normalized = (0,
|
|
41057
|
-
if ((0,
|
|
41193
|
+
const normalized = (0, import_node_path27.resolve)(trimmed.replace(/\\/g, "/"));
|
|
41194
|
+
if ((0, import_node_fs25.existsSync)(normalized)) return normalized;
|
|
41058
41195
|
}
|
|
41059
41196
|
return resolved;
|
|
41060
41197
|
}
|
|
@@ -41065,7 +41202,7 @@ function readJsonArgument(raw, flagName) {
|
|
|
41065
41202
|
throw new Error(`Invalid ${flagName} value: empty @file path.`);
|
|
41066
41203
|
}
|
|
41067
41204
|
try {
|
|
41068
|
-
return (0,
|
|
41205
|
+
return (0, import_node_fs25.readFileSync)(resolveAtFilePath(filePath), "utf8").replace(
|
|
41069
41206
|
/^\uFEFF/,
|
|
41070
41207
|
""
|
|
41071
41208
|
);
|
|
@@ -41142,7 +41279,7 @@ function parseExecuteOptions(args) {
|
|
|
41142
41279
|
continue;
|
|
41143
41280
|
}
|
|
41144
41281
|
if ((arg === "--out" || arg === "-o") && args[index + 1]) {
|
|
41145
|
-
outPath = (0,
|
|
41282
|
+
outPath = (0, import_node_path27.resolve)(args[++index]);
|
|
41146
41283
|
continue;
|
|
41147
41284
|
}
|
|
41148
41285
|
throw new Error(`Unknown option: ${arg}`);
|
|
@@ -41172,9 +41309,9 @@ function starterScriptJson(script) {
|
|
|
41172
41309
|
function seedToolListScript(input2) {
|
|
41173
41310
|
const stem = safeFileStem(input2.toolId);
|
|
41174
41311
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
41175
|
-
const scriptDir = (0,
|
|
41176
|
-
(0,
|
|
41177
|
-
const scriptPath = (0,
|
|
41312
|
+
const scriptDir = (0, import_node_fs25.mkdtempSync)((0, import_node_path27.join)((0, import_node_os17.tmpdir)(), "deepline-workflow-seed-"));
|
|
41313
|
+
(0, import_node_fs25.chmodSync)(scriptDir, 448);
|
|
41314
|
+
const scriptPath = (0, import_node_path27.join)(scriptDir, fileName);
|
|
41178
41315
|
const projectDir = `deepline/projects/${stem}-workflow`;
|
|
41179
41316
|
const playName = `${stem}-workflow`;
|
|
41180
41317
|
const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
|
|
@@ -41217,7 +41354,7 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
|
|
|
41217
41354
|
description: ${JSON.stringify(`Seed ${input2.toolId} rows into a Deepline workflow-ready dataset.`)},
|
|
41218
41355
|
});
|
|
41219
41356
|
`;
|
|
41220
|
-
(0,
|
|
41357
|
+
(0, import_node_fs25.writeFileSync)(scriptPath, script, { encoding: "utf-8", mode: 384 });
|
|
41221
41358
|
return {
|
|
41222
41359
|
path: scriptPath,
|
|
41223
41360
|
sourceCode: script,
|
|
@@ -41643,10 +41780,10 @@ Examples:
|
|
|
41643
41780
|
|
|
41644
41781
|
// src/cli/commands/workflow.ts
|
|
41645
41782
|
var import_promises10 = require("fs/promises");
|
|
41646
|
-
var
|
|
41783
|
+
var import_node_path28 = require("path");
|
|
41647
41784
|
|
|
41648
41785
|
// src/cli/workflow-to-play.ts
|
|
41649
|
-
var
|
|
41786
|
+
var import_node_crypto10 = require("crypto");
|
|
41650
41787
|
var HITL_WAIT_FOR_SIGNAL_TOOL = "deepline_workflow_wait_for_signal";
|
|
41651
41788
|
var HITL_SLACK_TOOL = "slack_message_with_hitl";
|
|
41652
41789
|
var SUB_WORKFLOW_TOOL_PREFIX = "deepline_workflow_";
|
|
@@ -41752,7 +41889,7 @@ function sanitizePlayNameSegment(value) {
|
|
|
41752
41889
|
}
|
|
41753
41890
|
function deriveWorkflowPlayName(workflowName) {
|
|
41754
41891
|
const base = sanitizePlayNameSegment(workflowName) || "workflow";
|
|
41755
|
-
const suffix = (0,
|
|
41892
|
+
const suffix = (0, import_node_crypto10.createHash)("sha256").update(workflowName).digest("hex").slice(0, 8);
|
|
41756
41893
|
const reserved = suffix.length + 1;
|
|
41757
41894
|
const allowedBase = Math.max(1, MAX_PLAY_NAME_LENGTH - reserved);
|
|
41758
41895
|
let name = `${base.slice(0, allowedBase)}_${suffix}`;
|
|
@@ -41860,7 +41997,7 @@ function readStatus(payload) {
|
|
|
41860
41997
|
}
|
|
41861
41998
|
async function readJsonOption(payload, file) {
|
|
41862
41999
|
if (file) {
|
|
41863
|
-
const raw = await (0, import_promises10.readFile)((0,
|
|
42000
|
+
const raw = await (0, import_promises10.readFile)((0, import_node_path28.resolve)(file), "utf8");
|
|
41864
42001
|
return JSON.parse(raw);
|
|
41865
42002
|
}
|
|
41866
42003
|
if (payload) {
|
|
@@ -41894,8 +42031,8 @@ async function transformOne(api, workflowId, outDir, publish) {
|
|
|
41894
42031
|
revision.config,
|
|
41895
42032
|
{ workflowName: workflow.name, version: revision.version }
|
|
41896
42033
|
);
|
|
41897
|
-
const file = (0,
|
|
41898
|
-
await (0, import_promises10.mkdir)((0,
|
|
42034
|
+
const file = (0, import_node_path28.join)((0, import_node_path28.resolve)(outDir), `${compiled.playName}.play.ts`);
|
|
42035
|
+
await (0, import_promises10.mkdir)((0, import_node_path28.dirname)(file), { recursive: true });
|
|
41899
42036
|
await (0, import_promises10.writeFile)(file, compiled.sourceCode, "utf8");
|
|
41900
42037
|
let published = false;
|
|
41901
42038
|
if (publish) {
|
|
@@ -42527,8 +42664,8 @@ function topLevelCommandKnown(program, commandName) {
|
|
|
42527
42664
|
);
|
|
42528
42665
|
}
|
|
42529
42666
|
async function runPlayRunnerHealthCheck() {
|
|
42530
|
-
const dir = await (0, import_promises11.mkdtemp)((0,
|
|
42531
|
-
const file = (0,
|
|
42667
|
+
const dir = await (0, import_promises11.mkdtemp)((0, import_node_path29.join)((0, import_node_os18.tmpdir)(), "deepline-health-play-"));
|
|
42668
|
+
const file = (0, import_node_path29.join)(dir, "health-check.play.ts");
|
|
42532
42669
|
try {
|
|
42533
42670
|
await (0, import_promises11.writeFile)(
|
|
42534
42671
|
file,
|