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.mjs
CHANGED
|
@@ -159,7 +159,7 @@ configureProxyFromEnv();
|
|
|
159
159
|
|
|
160
160
|
// src/cli/index.ts
|
|
161
161
|
import { mkdtemp as mkdtemp2, rm as rm2, writeFile as writeFile6 } from "fs/promises";
|
|
162
|
-
import { join as
|
|
162
|
+
import { join as join24 } from "path";
|
|
163
163
|
import { tmpdir as tmpdir6 } from "os";
|
|
164
164
|
import { Command as Command4 } from "commander";
|
|
165
165
|
|
|
@@ -1199,7 +1199,7 @@ var SDK_RELEASE = {
|
|
|
1199
1199
|
// available at toolResponse.rawV2 while toolResponse.raw and all declared
|
|
1200
1200
|
// getters keep their established compatibility behavior.
|
|
1201
1201
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
1202
|
-
version: "0.3.
|
|
1202
|
+
version: "0.3.71",
|
|
1203
1203
|
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.",
|
|
1204
1204
|
packageCapabilities: {
|
|
1205
1205
|
updatePreferences: 1
|
|
@@ -4839,6 +4839,8 @@ var DeeplineClient = class {
|
|
|
4839
4839
|
db;
|
|
4840
4840
|
/** Billing namespace: subscription status/cancel and invoice history. */
|
|
4841
4841
|
billing;
|
|
4842
|
+
/** Workspace lifecycle namespace. */
|
|
4843
|
+
workspaces;
|
|
4842
4844
|
/** Monitors namespace: access, catalog, deploy/check, and lifecycle. */
|
|
4843
4845
|
monitors;
|
|
4844
4846
|
/**
|
|
@@ -4887,6 +4889,9 @@ var DeeplineClient = class {
|
|
|
4887
4889
|
transitionPlan: (options2) => this.transitionTargetBillingPlan(options2),
|
|
4888
4890
|
portalSession: () => this.createTargetBillingPortalSession()
|
|
4889
4891
|
};
|
|
4892
|
+
this.workspaces = {
|
|
4893
|
+
create: (options2) => this.createWorkspace(options2)
|
|
4894
|
+
};
|
|
4890
4895
|
this.monitors = {
|
|
4891
4896
|
status: () => this.getMonitorsAccess(),
|
|
4892
4897
|
available: (toolIdOrOptions, options2) => this.getMonitorsAvailable(toolIdOrOptions, options2),
|
|
@@ -7038,6 +7043,23 @@ var DeeplineClient = class {
|
|
|
7038
7043
|
const response = await this.http.post("/api/v2/billing/portal-sessions", {});
|
|
7039
7044
|
return response.data;
|
|
7040
7045
|
}
|
|
7046
|
+
/** Create an additional workspace through the durable PAYG workflow. */
|
|
7047
|
+
async createWorkspace(options) {
|
|
7048
|
+
const idempotencyKey = requireTargetBillingIdempotencyKey(
|
|
7049
|
+
options.idempotencyKey
|
|
7050
|
+
);
|
|
7051
|
+
const response = await this.http.post(
|
|
7052
|
+
"/api/v2/workspaces",
|
|
7053
|
+
{ name: options.name },
|
|
7054
|
+
{ "Idempotency-Key": idempotencyKey },
|
|
7055
|
+
{ maxRetries: 0, exactUrlOnly: true }
|
|
7056
|
+
);
|
|
7057
|
+
return {
|
|
7058
|
+
...response.data,
|
|
7059
|
+
operation: response.operation,
|
|
7060
|
+
...response.request_id ? { request_id: response.request_id } : {}
|
|
7061
|
+
};
|
|
7062
|
+
}
|
|
7041
7063
|
// ——————————————————————————————————————————————————————————
|
|
7042
7064
|
// Monitors
|
|
7043
7065
|
// ——————————————————————————————————————————————————————————
|
|
@@ -33827,6 +33849,92 @@ Examples:
|
|
|
33827
33849
|
}
|
|
33828
33850
|
|
|
33829
33851
|
// src/cli/commands/org.ts
|
|
33852
|
+
import { createHash as createHash5, randomUUID as randomUUID6 } from "crypto";
|
|
33853
|
+
import {
|
|
33854
|
+
existsSync as existsSync11,
|
|
33855
|
+
mkdirSync as mkdirSync9,
|
|
33856
|
+
readFileSync as readFileSync12,
|
|
33857
|
+
unlinkSync,
|
|
33858
|
+
writeFileSync as writeFileSync13
|
|
33859
|
+
} from "fs";
|
|
33860
|
+
import { join as join13 } from "path";
|
|
33861
|
+
function pendingOrgCreatePath(baseUrl, accountId, sourceOrgId, name) {
|
|
33862
|
+
const intent = createHash5("sha256").update(accountId).update("\0").update(sourceOrgId).update("\0").update(name).digest("hex");
|
|
33863
|
+
return join13(sdkCliStateDirPath(baseUrl), `pending-org-create-${intent}.json`);
|
|
33864
|
+
}
|
|
33865
|
+
function readPendingOrgCreate(path, accountId, sourceOrgId, name) {
|
|
33866
|
+
let value;
|
|
33867
|
+
try {
|
|
33868
|
+
value = JSON.parse(readFileSync12(path, "utf8"));
|
|
33869
|
+
} catch (error) {
|
|
33870
|
+
throw new Error(
|
|
33871
|
+
`Cannot resume the pending workspace creation recorded at ${path}: ${error instanceof Error ? error.message : String(error)}`
|
|
33872
|
+
);
|
|
33873
|
+
}
|
|
33874
|
+
if (typeof value !== "object" || value === null || value.accountId !== accountId || value.sourceOrgId !== sourceOrgId || value.name !== name || typeof value.idempotencyKey !== "string" || !value.idempotencyKey.trim()) {
|
|
33875
|
+
throw new Error(
|
|
33876
|
+
`Cannot resume the pending workspace creation recorded at ${path}: the saved intent is invalid.`
|
|
33877
|
+
);
|
|
33878
|
+
}
|
|
33879
|
+
return value;
|
|
33880
|
+
}
|
|
33881
|
+
function loadOrCreatePendingOrgCreate(input2) {
|
|
33882
|
+
const stateDir = sdkCliStateDirPath(input2.baseUrl);
|
|
33883
|
+
const path = pendingOrgCreatePath(
|
|
33884
|
+
input2.baseUrl,
|
|
33885
|
+
input2.accountId,
|
|
33886
|
+
input2.sourceOrgId,
|
|
33887
|
+
input2.name
|
|
33888
|
+
);
|
|
33889
|
+
mkdirSync9(stateDir, { recursive: true });
|
|
33890
|
+
if (existsSync11(path)) {
|
|
33891
|
+
return {
|
|
33892
|
+
...readPendingOrgCreate(
|
|
33893
|
+
path,
|
|
33894
|
+
input2.accountId,
|
|
33895
|
+
input2.sourceOrgId,
|
|
33896
|
+
input2.name
|
|
33897
|
+
),
|
|
33898
|
+
path
|
|
33899
|
+
};
|
|
33900
|
+
}
|
|
33901
|
+
const pending = {
|
|
33902
|
+
accountId: input2.accountId,
|
|
33903
|
+
sourceOrgId: input2.sourceOrgId,
|
|
33904
|
+
name: input2.name,
|
|
33905
|
+
idempotencyKey: randomUUID6()
|
|
33906
|
+
};
|
|
33907
|
+
try {
|
|
33908
|
+
writeFileSync13(path, `${JSON.stringify(pending)}
|
|
33909
|
+
`, {
|
|
33910
|
+
encoding: "utf8",
|
|
33911
|
+
flag: "wx",
|
|
33912
|
+
mode: 384
|
|
33913
|
+
});
|
|
33914
|
+
return { ...pending, path };
|
|
33915
|
+
} catch (error) {
|
|
33916
|
+
if (error.code !== "EEXIST") throw error;
|
|
33917
|
+
return {
|
|
33918
|
+
...readPendingOrgCreate(
|
|
33919
|
+
path,
|
|
33920
|
+
input2.accountId,
|
|
33921
|
+
input2.sourceOrgId,
|
|
33922
|
+
input2.name
|
|
33923
|
+
),
|
|
33924
|
+
path
|
|
33925
|
+
};
|
|
33926
|
+
}
|
|
33927
|
+
}
|
|
33928
|
+
async function fetchWorkspaceCreationIdentity(http, apiKey) {
|
|
33929
|
+
const status = await http.post("/api/v2/auth/cli/status", { api_key: apiKey });
|
|
33930
|
+
const accountId = status.user_id?.trim();
|
|
33931
|
+
if (!accountId) {
|
|
33932
|
+
throw new Error(
|
|
33933
|
+
"Workspace creation requires an API key linked to a user account."
|
|
33934
|
+
);
|
|
33935
|
+
}
|
|
33936
|
+
return { accountId, orgId: status.org_id?.trim() || null };
|
|
33937
|
+
}
|
|
33830
33938
|
async function fetchOrganizations(http, apiKey) {
|
|
33831
33939
|
return http.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
|
|
33832
33940
|
}
|
|
@@ -34295,23 +34403,58 @@ async function handleOrgSwitch(selection, options) {
|
|
|
34295
34403
|
}
|
|
34296
34404
|
async function handleOrgCreate(name, options) {
|
|
34297
34405
|
const config = resolveConfig();
|
|
34406
|
+
const normalizedName = name.trim();
|
|
34407
|
+
if (!normalizedName) {
|
|
34408
|
+
throw new Error("Workspace name is required.");
|
|
34409
|
+
}
|
|
34298
34410
|
const http = new HttpClient(config);
|
|
34299
|
-
const
|
|
34300
|
-
|
|
34301
|
-
|
|
34302
|
-
|
|
34411
|
+
const identity = await fetchWorkspaceCreationIdentity(http, config.apiKey);
|
|
34412
|
+
let created;
|
|
34413
|
+
let workspaceApiKey;
|
|
34414
|
+
let pendingIntentPath = null;
|
|
34415
|
+
if (!identity.orgId) {
|
|
34416
|
+
const firstWorkspace = await http.post("/api/v2/auth/cli/org-create", {
|
|
34417
|
+
api_key: config.apiKey,
|
|
34418
|
+
name: normalizedName
|
|
34419
|
+
});
|
|
34420
|
+
const { api_key: apiKey, ...publicFirstWorkspace } = firstWorkspace;
|
|
34421
|
+
workspaceApiKey = apiKey;
|
|
34422
|
+
created = publicFirstWorkspace;
|
|
34423
|
+
} else {
|
|
34424
|
+
const pending = loadOrCreatePendingOrgCreate({
|
|
34425
|
+
baseUrl: config.baseUrl,
|
|
34426
|
+
accountId: identity.accountId,
|
|
34427
|
+
sourceOrgId: identity.orgId,
|
|
34428
|
+
name: normalizedName
|
|
34429
|
+
});
|
|
34430
|
+
const workspace = await new DeeplineClient({
|
|
34431
|
+
apiKey: config.apiKey,
|
|
34432
|
+
baseUrl: config.baseUrl
|
|
34433
|
+
}).workspaces.create({
|
|
34434
|
+
name: normalizedName,
|
|
34435
|
+
idempotencyKey: pending.idempotencyKey
|
|
34436
|
+
});
|
|
34437
|
+
const switched = await http.post("/api/v2/auth/cli/switch", {
|
|
34438
|
+
api_key: config.apiKey,
|
|
34439
|
+
org_id: workspace.org_id
|
|
34440
|
+
});
|
|
34441
|
+
workspaceApiKey = switched.api_key;
|
|
34442
|
+
created = { ...workspace };
|
|
34443
|
+
pendingIntentPath = pending.path;
|
|
34444
|
+
}
|
|
34303
34445
|
const authValues = organizationAuthValues({
|
|
34304
34446
|
baseUrl: config.baseUrl,
|
|
34305
|
-
apiKey:
|
|
34447
|
+
apiKey: workspaceApiKey,
|
|
34306
34448
|
orgId: created.org_id,
|
|
34307
34449
|
orgName: created.org_name
|
|
34308
34450
|
});
|
|
34309
34451
|
saveHostEnvValues(config.baseUrl, authValues);
|
|
34310
|
-
|
|
34452
|
+
if (pendingIntentPath) unlinkSync(pendingIntentPath);
|
|
34311
34453
|
printCommandEnvelope(
|
|
34312
34454
|
{
|
|
34313
34455
|
ok: true,
|
|
34314
|
-
...
|
|
34456
|
+
...created,
|
|
34457
|
+
initial_credits: typeof created.initial_credits === "number" ? created.initial_credits : 0,
|
|
34315
34458
|
api_key_saved: true,
|
|
34316
34459
|
switched: true,
|
|
34317
34460
|
host_env_path: hostEnvFilePath(config.baseUrl),
|
|
@@ -34394,9 +34537,9 @@ Examples:
|
|
|
34394
34537
|
"after",
|
|
34395
34538
|
`
|
|
34396
34539
|
Notes:
|
|
34397
|
-
Mutates workspace state. The new organization is created for the
|
|
34398
|
-
authenticated user
|
|
34399
|
-
CLI
|
|
34540
|
+
Mutates workspace and billing state. The new organization is created for the
|
|
34541
|
+
current authenticated user and provisioned on the active PAYG offer before
|
|
34542
|
+
this CLI switches to it. Interrupted requests resume automatically.
|
|
34400
34543
|
|
|
34401
34544
|
Examples:
|
|
34402
34545
|
deepline org create Acme
|
|
@@ -34854,27 +34997,27 @@ Examples:
|
|
|
34854
34997
|
// src/cli/commands/setup.ts
|
|
34855
34998
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
34856
34999
|
import {
|
|
34857
|
-
existsSync as
|
|
35000
|
+
existsSync as existsSync15,
|
|
34858
35001
|
lstatSync as lstatSync2,
|
|
34859
|
-
mkdirSync as
|
|
34860
|
-
readFileSync as
|
|
35002
|
+
mkdirSync as mkdirSync12,
|
|
35003
|
+
readFileSync as readFileSync16,
|
|
34861
35004
|
realpathSync as realpathSync4,
|
|
34862
|
-
writeFileSync as
|
|
35005
|
+
writeFileSync as writeFileSync16
|
|
34863
35006
|
} from "fs";
|
|
34864
35007
|
import { homedir as homedir9 } from "os";
|
|
34865
|
-
import { dirname as dirname16, join as
|
|
35008
|
+
import { dirname as dirname16, join as join17, resolve as resolve16 } from "path";
|
|
34866
35009
|
|
|
34867
35010
|
// src/cli/installation-lifecycle.ts
|
|
34868
35011
|
import {
|
|
34869
|
-
existsSync as
|
|
35012
|
+
existsSync as existsSync12,
|
|
34870
35013
|
lstatSync,
|
|
34871
|
-
readFileSync as
|
|
35014
|
+
readFileSync as readFileSync13,
|
|
34872
35015
|
realpathSync as realpathSync3,
|
|
34873
35016
|
rmSync as rmSync4
|
|
34874
35017
|
} from "fs";
|
|
34875
|
-
import { basename as basename6, dirname as dirname13, join as
|
|
35018
|
+
import { basename as basename6, dirname as dirname13, join as join14, relative as relative5, resolve as resolve15 } from "path";
|
|
34876
35019
|
var nodeFileSystem = {
|
|
34877
|
-
exists:
|
|
35020
|
+
exists: existsSync12,
|
|
34878
35021
|
isSymbolicLink(path) {
|
|
34879
35022
|
try {
|
|
34880
35023
|
return lstatSync(path).isSymbolicLink();
|
|
@@ -34884,7 +35027,7 @@ var nodeFileSystem = {
|
|
|
34884
35027
|
},
|
|
34885
35028
|
read(path) {
|
|
34886
35029
|
try {
|
|
34887
|
-
return
|
|
35030
|
+
return readFileSync13(path, "utf8");
|
|
34888
35031
|
} catch {
|
|
34889
35032
|
return "";
|
|
34890
35033
|
}
|
|
@@ -34928,25 +35071,25 @@ var CliInstallation = class _CliInstallation {
|
|
|
34928
35071
|
});
|
|
34929
35072
|
}
|
|
34930
35073
|
static isNpmPackagePath(path) {
|
|
34931
|
-
return path?.includes(`${
|
|
35074
|
+
return path?.includes(`${join14("node_modules", "deepline")}`) ?? false;
|
|
34932
35075
|
}
|
|
34933
35076
|
launcher(path) {
|
|
34934
35077
|
return inspectLauncher(path, this.input.fileSystem);
|
|
34935
35078
|
}
|
|
34936
35079
|
retiredArtifacts() {
|
|
34937
|
-
const hostDir =
|
|
35080
|
+
const hostDir = join14(
|
|
34938
35081
|
this.input.home,
|
|
34939
35082
|
".local",
|
|
34940
35083
|
"deepline",
|
|
34941
35084
|
this.input.baseUrlSlug
|
|
34942
35085
|
);
|
|
34943
|
-
const legacyLauncherPath =
|
|
35086
|
+
const legacyLauncherPath = join14(
|
|
34944
35087
|
this.input.home,
|
|
34945
35088
|
".local",
|
|
34946
35089
|
"bin",
|
|
34947
35090
|
"deepline"
|
|
34948
35091
|
);
|
|
34949
|
-
const installerCommandPath = this.input.fileSystem.read(
|
|
35092
|
+
const installerCommandPath = this.input.fileSystem.read(join14(hostDir, "sdk", ".command-path")).trim();
|
|
34950
35093
|
const ownedInstallerCommand = isOwnedInstallerCommandPath({
|
|
34951
35094
|
hostDir,
|
|
34952
35095
|
commandPath: installerCommandPath
|
|
@@ -34954,16 +35097,16 @@ var CliInstallation = class _CliInstallation {
|
|
|
34954
35097
|
const legacyLauncher = this.launcher(legacyLauncherPath);
|
|
34955
35098
|
const candidates = [
|
|
34956
35099
|
...legacyLauncher.ownership === "installer_legacy" ? [legacyLauncherPath] : [],
|
|
34957
|
-
|
|
34958
|
-
|
|
34959
|
-
|
|
34960
|
-
|
|
34961
|
-
|
|
34962
|
-
|
|
34963
|
-
|
|
35100
|
+
join14(this.input.home, ".local", "bin", "deepline-real"),
|
|
35101
|
+
join14(hostDir, "bin", "deepline"),
|
|
35102
|
+
join14(hostDir, "bin", "deepline-real"),
|
|
35103
|
+
join14(hostDir, "cli", ".install-method"),
|
|
35104
|
+
join14(hostDir, "cli", ".version"),
|
|
35105
|
+
join14(hostDir, "sdk", ".install-method"),
|
|
35106
|
+
join14(hostDir, "sdk", ".command-path"),
|
|
34964
35107
|
...ownedInstallerCommand ? [
|
|
34965
35108
|
installerCommandPath,
|
|
34966
|
-
|
|
35109
|
+
join14(dirname13(installerCommandPath), "deepline-sdk")
|
|
34967
35110
|
] : []
|
|
34968
35111
|
];
|
|
34969
35112
|
return {
|
|
@@ -34994,9 +35137,9 @@ function isOwnedInstallerCommandPath(input2) {
|
|
|
34994
35137
|
|
|
34995
35138
|
// src/cli/commands/skills.ts
|
|
34996
35139
|
import { spawn as spawn3 } from "child_process";
|
|
34997
|
-
import { existsSync as
|
|
35140
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync11, readFileSync as readFileSync15, writeFileSync as writeFileSync15 } from "fs";
|
|
34998
35141
|
import { homedir as homedir8 } from "os";
|
|
34999
|
-
import { dirname as dirname15, join as
|
|
35142
|
+
import { dirname as dirname15, join as join16 } from "path";
|
|
35000
35143
|
|
|
35001
35144
|
// ../../shared_libs/cli/install-commands.json
|
|
35002
35145
|
var install_commands_default = {
|
|
@@ -35107,13 +35250,13 @@ function buildSkillsAddArgs(baseUrl, skillName, options = {}) {
|
|
|
35107
35250
|
// src/cli/skills-sync.ts
|
|
35108
35251
|
import { spawn as spawn2, spawnSync } from "child_process";
|
|
35109
35252
|
import {
|
|
35110
|
-
existsSync as
|
|
35111
|
-
mkdirSync as
|
|
35112
|
-
readFileSync as
|
|
35113
|
-
unlinkSync,
|
|
35114
|
-
writeFileSync as
|
|
35253
|
+
existsSync as existsSync13,
|
|
35254
|
+
mkdirSync as mkdirSync10,
|
|
35255
|
+
readFileSync as readFileSync14,
|
|
35256
|
+
unlinkSync as unlinkSync2,
|
|
35257
|
+
writeFileSync as writeFileSync14
|
|
35115
35258
|
} from "fs";
|
|
35116
|
-
import { dirname as dirname14, join as
|
|
35259
|
+
import { dirname as dirname14, join as join15 } from "path";
|
|
35117
35260
|
|
|
35118
35261
|
// src/cli/windows-arg-escape.ts
|
|
35119
35262
|
var CMD_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
|
|
@@ -35460,10 +35603,10 @@ function shouldSkipSkillsSync() {
|
|
|
35460
35603
|
return value === "1" || value === "true" || value === "yes" || value === "on";
|
|
35461
35604
|
}
|
|
35462
35605
|
function unavailableSkillsNoticePath(baseUrl) {
|
|
35463
|
-
return
|
|
35606
|
+
return join15(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
|
|
35464
35607
|
}
|
|
35465
35608
|
function failedSkillsSyncPath(baseUrl, agents) {
|
|
35466
|
-
return
|
|
35609
|
+
return join15(
|
|
35467
35610
|
sdkCliStateDirPath(baseUrl),
|
|
35468
35611
|
`skills-sync-failed-${agents.join("-")}-version`
|
|
35469
35612
|
);
|
|
@@ -35473,15 +35616,15 @@ function hasMarkedSkillsSyncVersion(path, version) {
|
|
|
35473
35616
|
}
|
|
35474
35617
|
function readMarkedSkillsSyncVersion(path) {
|
|
35475
35618
|
try {
|
|
35476
|
-
return
|
|
35619
|
+
return existsSync13(path) ? readFileSync14(path, "utf-8").trim() : "";
|
|
35477
35620
|
} catch {
|
|
35478
35621
|
return "";
|
|
35479
35622
|
}
|
|
35480
35623
|
}
|
|
35481
35624
|
function writeMarkedSkillsSyncVersion(path, version) {
|
|
35482
35625
|
try {
|
|
35483
|
-
|
|
35484
|
-
|
|
35626
|
+
mkdirSync10(dirname14(path), { recursive: true });
|
|
35627
|
+
writeFileSync14(path, `${version}
|
|
35485
35628
|
`, "utf-8");
|
|
35486
35629
|
return true;
|
|
35487
35630
|
} catch {
|
|
@@ -35500,7 +35643,7 @@ ${manualCommand}`
|
|
|
35500
35643
|
}
|
|
35501
35644
|
function clearUnavailableSkillsNotice(baseUrl) {
|
|
35502
35645
|
try {
|
|
35503
|
-
|
|
35646
|
+
unlinkSync2(unavailableSkillsNoticePath(baseUrl));
|
|
35504
35647
|
} catch {
|
|
35505
35648
|
}
|
|
35506
35649
|
}
|
|
@@ -35511,7 +35654,7 @@ function hasFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
|
35511
35654
|
);
|
|
35512
35655
|
}
|
|
35513
35656
|
function hasFailedAutomaticSkillsSync(baseUrl, agents) {
|
|
35514
|
-
return
|
|
35657
|
+
return existsSync13(failedSkillsSyncPath(baseUrl, agents));
|
|
35515
35658
|
}
|
|
35516
35659
|
function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
35517
35660
|
return writeMarkedSkillsSyncVersion(
|
|
@@ -35521,7 +35664,7 @@ function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
|
|
|
35521
35664
|
}
|
|
35522
35665
|
function clearFailedSkillsSync(baseUrl, agents) {
|
|
35523
35666
|
try {
|
|
35524
|
-
|
|
35667
|
+
unlinkSync2(failedSkillsSyncPath(baseUrl, agents));
|
|
35525
35668
|
} catch {
|
|
35526
35669
|
}
|
|
35527
35670
|
}
|
|
@@ -35888,13 +36031,13 @@ function detectSkillsAgents(input2) {
|
|
|
35888
36031
|
];
|
|
35889
36032
|
const detected = AGENT_MARKERS.filter(
|
|
35890
36033
|
(marker) => roots.some(
|
|
35891
|
-
(root) => marker.paths.some((path) =>
|
|
36034
|
+
(root) => marker.paths.some((path) => existsSync14(join16(root, path)))
|
|
35892
36035
|
)
|
|
35893
36036
|
).map((marker) => marker.agent);
|
|
35894
36037
|
return detected.length > 0 ? detected : ["*"];
|
|
35895
36038
|
}
|
|
35896
36039
|
function skillsStatePathForScope(baseUrl, scope, root) {
|
|
35897
|
-
return scope === "local" && root ?
|
|
36040
|
+
return scope === "local" && root ? join16(root, ".deepline", "setup", "skills.json") : join16(sdkCliStateDirPath(baseUrl), "skills-install.json");
|
|
35898
36041
|
}
|
|
35899
36042
|
function buildSkillsPlan(input2) {
|
|
35900
36043
|
const scopeArgs = input2.scope === "global" ? ["--global"] : [];
|
|
@@ -35961,7 +36104,7 @@ function isSkillsPlanCurrent(plan, state) {
|
|
|
35961
36104
|
}
|
|
35962
36105
|
function readSkillsInstallState(path) {
|
|
35963
36106
|
try {
|
|
35964
|
-
const parsed = JSON.parse(
|
|
36107
|
+
const parsed = JSON.parse(readFileSync15(path, "utf8"));
|
|
35965
36108
|
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
35966
36109
|
} catch {
|
|
35967
36110
|
return null;
|
|
@@ -36114,8 +36257,8 @@ async function runSkillsCommand(options, dependencies = {}) {
|
|
|
36114
36257
|
`
|
|
36115
36258
|
);
|
|
36116
36259
|
}
|
|
36117
|
-
|
|
36118
|
-
|
|
36260
|
+
mkdirSync11(dirname15(plan.statePath), { recursive: true });
|
|
36261
|
+
writeFileSync15(
|
|
36119
36262
|
plan.statePath,
|
|
36120
36263
|
`${JSON.stringify(
|
|
36121
36264
|
{
|
|
@@ -36253,7 +36396,7 @@ function phasesFromLegacyStatus(status) {
|
|
|
36253
36396
|
function readSetupState(input2) {
|
|
36254
36397
|
try {
|
|
36255
36398
|
const parsed = JSON.parse(
|
|
36256
|
-
|
|
36399
|
+
readFileSync16(
|
|
36257
36400
|
setupStatePath(input2.baseUrl, input2.scope, input2.root),
|
|
36258
36401
|
"utf8"
|
|
36259
36402
|
)
|
|
@@ -36329,7 +36472,7 @@ function buildPendingAuthorizationOutput(input2) {
|
|
|
36329
36472
|
};
|
|
36330
36473
|
}
|
|
36331
36474
|
function setupStatePath(baseUrl, scope, root) {
|
|
36332
|
-
return scope === "local" && root ?
|
|
36475
|
+
return scope === "local" && root ? join17(root, ".deepline", "setup", "state.json") : join17(sdkCliStateDirPath(baseUrl), "setup.json");
|
|
36333
36476
|
}
|
|
36334
36477
|
async function captureStdout2(run) {
|
|
36335
36478
|
let stdout = "";
|
|
@@ -36358,7 +36501,7 @@ function asRecord3(value) {
|
|
|
36358
36501
|
}
|
|
36359
36502
|
function safeRead(path) {
|
|
36360
36503
|
try {
|
|
36361
|
-
return
|
|
36504
|
+
return readFileSync16(path, "utf8");
|
|
36362
36505
|
} catch {
|
|
36363
36506
|
return "";
|
|
36364
36507
|
}
|
|
@@ -36398,7 +36541,7 @@ function isHomebrewFormulaCommand(path) {
|
|
|
36398
36541
|
function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
36399
36542
|
const platform3 = dependencies.platform ?? process.platform;
|
|
36400
36543
|
const run = dependencies.spawn ?? spawnSync2;
|
|
36401
|
-
const pathExists = dependencies.exists ??
|
|
36544
|
+
const pathExists = dependencies.exists ?? existsSync15;
|
|
36402
36545
|
const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
|
|
36403
36546
|
const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
|
|
36404
36547
|
if (homebrewCommand) return homebrewCommand;
|
|
@@ -36410,7 +36553,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
|
|
|
36410
36553
|
if (prefix.status !== 0) return null;
|
|
36411
36554
|
const root = String(prefix.stdout ?? "").trim();
|
|
36412
36555
|
if (!root) return null;
|
|
36413
|
-
const candidates = platform3 === "win32" ? [
|
|
36556
|
+
const candidates = platform3 === "win32" ? [join17(root, "deepline.cmd"), join17(root, "deepline")] : [join17(root, "bin", "deepline")];
|
|
36414
36557
|
return candidates.find((candidate) => pathExists(candidate)) ?? null;
|
|
36415
36558
|
}
|
|
36416
36559
|
function inspectGlobalCliAvailability(input2) {
|
|
@@ -36436,7 +36579,7 @@ function isKnownDeeplineCommand(path) {
|
|
|
36436
36579
|
} catch {
|
|
36437
36580
|
}
|
|
36438
36581
|
if (entrypoint && resolvedPath === entrypoint) return true;
|
|
36439
|
-
if (resolvedPath.includes(`${
|
|
36582
|
+
if (resolvedPath.includes(`${join17("node_modules", "deepline")}`)) return true;
|
|
36440
36583
|
const content = safeRead(path);
|
|
36441
36584
|
return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
|
|
36442
36585
|
}
|
|
@@ -36446,7 +36589,7 @@ function inspectPathConflict() {
|
|
|
36446
36589
|
try {
|
|
36447
36590
|
if (lstatSync2(commandPath).isSymbolicLink()) {
|
|
36448
36591
|
const target = realpathSync4(commandPath);
|
|
36449
|
-
if (target.includes(`${
|
|
36592
|
+
if (target.includes(`${join17("node_modules", "deepline")}`)) return null;
|
|
36450
36593
|
}
|
|
36451
36594
|
} catch {
|
|
36452
36595
|
}
|
|
@@ -36454,8 +36597,8 @@ function inspectPathConflict() {
|
|
|
36454
36597
|
}
|
|
36455
36598
|
function writeSetupState(input2) {
|
|
36456
36599
|
const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
|
|
36457
|
-
|
|
36458
|
-
|
|
36600
|
+
mkdirSync12(dirname16(path), { recursive: true });
|
|
36601
|
+
writeFileSync16(
|
|
36459
36602
|
path,
|
|
36460
36603
|
`${JSON.stringify(
|
|
36461
36604
|
{
|
|
@@ -36495,7 +36638,7 @@ function failSetupPhase(phases, phase, code) {
|
|
|
36495
36638
|
phases[phase] = { status: "failed", code };
|
|
36496
36639
|
}
|
|
36497
36640
|
function rollbackCommand(scope, root) {
|
|
36498
|
-
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(
|
|
36641
|
+
const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify(join17(root, ".deepline", "runtime"))}` : "";
|
|
36499
36642
|
return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
|
|
36500
36643
|
}
|
|
36501
36644
|
function setupResumeCommand(baseUrl, scope) {
|
|
@@ -36587,7 +36730,7 @@ function buildDoctorAssessment(input2) {
|
|
|
36587
36730
|
const pathGlobalCli = globalCli?.path ?? null;
|
|
36588
36731
|
const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
|
|
36589
36732
|
const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
|
|
36590
|
-
input2.root && runningCliPath?.includes(
|
|
36733
|
+
input2.root && runningCliPath?.includes(join17(input2.root, ".deepline", "runtime"))
|
|
36591
36734
|
);
|
|
36592
36735
|
const checks = {
|
|
36593
36736
|
cli: {
|
|
@@ -37120,15 +37263,15 @@ Examples:
|
|
|
37120
37263
|
|
|
37121
37264
|
// src/cli/update-preferences.ts
|
|
37122
37265
|
import {
|
|
37123
|
-
existsSync as
|
|
37124
|
-
mkdirSync as
|
|
37125
|
-
readFileSync as
|
|
37266
|
+
existsSync as existsSync16,
|
|
37267
|
+
mkdirSync as mkdirSync13,
|
|
37268
|
+
readFileSync as readFileSync17,
|
|
37126
37269
|
renameSync,
|
|
37127
37270
|
rmSync as rmSync5,
|
|
37128
|
-
writeFileSync as
|
|
37271
|
+
writeFileSync as writeFileSync17
|
|
37129
37272
|
} from "fs";
|
|
37130
37273
|
import { homedir as homedir10 } from "os";
|
|
37131
|
-
import { dirname as dirname17, join as
|
|
37274
|
+
import { dirname as dirname17, join as join18 } from "path";
|
|
37132
37275
|
var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
|
|
37133
37276
|
var CLI_UPDATE_MESSAGES = [
|
|
37134
37277
|
{
|
|
@@ -37157,7 +37300,7 @@ function unreadablePreferences(path, error) {
|
|
|
37157
37300
|
};
|
|
37158
37301
|
}
|
|
37159
37302
|
function cliUpdatePreferencesPath(homeDir2 = homedir10()) {
|
|
37160
|
-
return
|
|
37303
|
+
return join18(
|
|
37161
37304
|
homeDir2,
|
|
37162
37305
|
".local",
|
|
37163
37306
|
"deepline",
|
|
@@ -37167,9 +37310,9 @@ function cliUpdatePreferencesPath(homeDir2 = homedir10()) {
|
|
|
37167
37310
|
}
|
|
37168
37311
|
function readCliUpdatePreferences(homeDir2 = homedir10()) {
|
|
37169
37312
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
37170
|
-
if (!
|
|
37313
|
+
if (!existsSync16(path)) return defaultPreferences();
|
|
37171
37314
|
try {
|
|
37172
|
-
const parsed = JSON.parse(
|
|
37315
|
+
const parsed = JSON.parse(readFileSync17(path, "utf8"));
|
|
37173
37316
|
return {
|
|
37174
37317
|
schemaVersion: UPDATE_PREFERENCES_SCHEMA_VERSION,
|
|
37175
37318
|
autoUpdateEnabled: typeof parsed.autoUpdateEnabled === "boolean" ? parsed.autoUpdateEnabled : true,
|
|
@@ -37185,9 +37328,9 @@ function readCliUpdatePreferences(homeDir2 = homedir10()) {
|
|
|
37185
37328
|
function writeCliUpdatePreferences(preferences, homeDir2 = homedir10()) {
|
|
37186
37329
|
const path = cliUpdatePreferencesPath(homeDir2);
|
|
37187
37330
|
const tempPath = `${path}.${process.pid}.tmp`;
|
|
37188
|
-
|
|
37331
|
+
mkdirSync13(dirname17(path), { recursive: true });
|
|
37189
37332
|
try {
|
|
37190
|
-
|
|
37333
|
+
writeFileSync17(tempPath, `${JSON.stringify(preferences, null, 2)}
|
|
37191
37334
|
`, {
|
|
37192
37335
|
encoding: "utf8",
|
|
37193
37336
|
mode: 384
|
|
@@ -37245,29 +37388,29 @@ function consumePendingCliUpdateMessages(homeDir2 = homedir10()) {
|
|
|
37245
37388
|
// src/cli/commands/update.ts
|
|
37246
37389
|
import { spawn as spawn4, spawnSync as spawnSync3 } from "child_process";
|
|
37247
37390
|
import {
|
|
37248
|
-
existsSync as
|
|
37249
|
-
mkdirSync as
|
|
37391
|
+
existsSync as existsSync18,
|
|
37392
|
+
mkdirSync as mkdirSync14,
|
|
37250
37393
|
realpathSync as realpathSync5,
|
|
37251
|
-
readFileSync as
|
|
37394
|
+
readFileSync as readFileSync19,
|
|
37252
37395
|
renameSync as renameSync2,
|
|
37253
37396
|
rmSync as rmSync6,
|
|
37254
|
-
unlinkSync as
|
|
37255
|
-
writeFileSync as
|
|
37397
|
+
unlinkSync as unlinkSync3,
|
|
37398
|
+
writeFileSync as writeFileSync18
|
|
37256
37399
|
} from "fs";
|
|
37257
37400
|
import { homedir as homedir11 } from "os";
|
|
37258
37401
|
import {
|
|
37259
37402
|
basename as basename7,
|
|
37260
37403
|
dirname as dirname18,
|
|
37261
37404
|
isAbsolute as isAbsolute7,
|
|
37262
|
-
join as
|
|
37405
|
+
join as join20,
|
|
37263
37406
|
relative as relative7,
|
|
37264
37407
|
resolve as resolve18
|
|
37265
37408
|
} from "path";
|
|
37266
37409
|
|
|
37267
37410
|
// src/cli/install-integrity.ts
|
|
37268
37411
|
import { createRequire } from "module";
|
|
37269
|
-
import { existsSync as
|
|
37270
|
-
import { isAbsolute as isAbsolute6, join as
|
|
37412
|
+
import { existsSync as existsSync17, readFileSync as readFileSync18, statSync as statSync5 } from "fs";
|
|
37413
|
+
import { isAbsolute as isAbsolute6, join as join19, relative as relative6, resolve as resolve17 } from "path";
|
|
37271
37414
|
var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
|
|
37272
37415
|
"dist/cli/index.mjs",
|
|
37273
37416
|
"dist/index.mjs",
|
|
@@ -37300,7 +37443,7 @@ function resolveContainedPath(root, value) {
|
|
|
37300
37443
|
return target;
|
|
37301
37444
|
}
|
|
37302
37445
|
function parseJson(path) {
|
|
37303
|
-
return JSON.parse(
|
|
37446
|
+
return JSON.parse(readFileSync18(path, "utf8"));
|
|
37304
37447
|
}
|
|
37305
37448
|
function isFile(path) {
|
|
37306
37449
|
try {
|
|
@@ -37310,7 +37453,7 @@ function isFile(path) {
|
|
|
37310
37453
|
}
|
|
37311
37454
|
}
|
|
37312
37455
|
function readManifest(packageRoot) {
|
|
37313
|
-
const packageJsonPath =
|
|
37456
|
+
const packageJsonPath = join19(packageRoot, "package.json");
|
|
37314
37457
|
let packageJson;
|
|
37315
37458
|
try {
|
|
37316
37459
|
packageJson = parseJson(packageJsonPath);
|
|
@@ -37318,7 +37461,7 @@ function readManifest(packageRoot) {
|
|
|
37318
37461
|
return {
|
|
37319
37462
|
mode: "manifest",
|
|
37320
37463
|
invalidReason: `invalid Deepline package metadata: ${error.message}`,
|
|
37321
|
-
missing:
|
|
37464
|
+
missing: existsSync17(packageJsonPath) ? [] : ["deepline/package.json"]
|
|
37322
37465
|
};
|
|
37323
37466
|
}
|
|
37324
37467
|
if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
|
|
@@ -37384,8 +37527,8 @@ function readManifest(packageRoot) {
|
|
|
37384
37527
|
return { mode: "manifest", manifest };
|
|
37385
37528
|
}
|
|
37386
37529
|
function inspectSdkSidecarInstall(versionDir) {
|
|
37387
|
-
const nodeModulesRoot =
|
|
37388
|
-
const packageRoot =
|
|
37530
|
+
const nodeModulesRoot = join19(versionDir, "node_modules");
|
|
37531
|
+
const packageRoot = join19(nodeModulesRoot, "deepline");
|
|
37389
37532
|
const manifestResult = readManifest(packageRoot);
|
|
37390
37533
|
if ("invalidReason" in manifestResult) {
|
|
37391
37534
|
return {
|
|
@@ -37396,8 +37539,8 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
37396
37539
|
};
|
|
37397
37540
|
}
|
|
37398
37541
|
const missing = [
|
|
37399
|
-
...manifestResult.manifest.packageFiles.filter((path) => !isFile(
|
|
37400
|
-
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(
|
|
37542
|
+
...manifestResult.manifest.packageFiles.filter((path) => !isFile(join19(packageRoot, path))).map((path) => `deepline/${path}`),
|
|
37543
|
+
...manifestResult.manifest.dependencyFiles.filter((path) => !isFile(join19(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
|
|
37401
37544
|
];
|
|
37402
37545
|
return {
|
|
37403
37546
|
ok: missing.length === 0,
|
|
@@ -37408,7 +37551,7 @@ function inspectSdkSidecarInstall(versionDir) {
|
|
|
37408
37551
|
}
|
|
37409
37552
|
function probeSdkSidecarEsbuild(versionDir) {
|
|
37410
37553
|
try {
|
|
37411
|
-
const requireFromInstall = createRequire(
|
|
37554
|
+
const requireFromInstall = createRequire(join19(versionDir, "package.json"));
|
|
37412
37555
|
const esbuild = requireFromInstall("esbuild");
|
|
37413
37556
|
if (typeof esbuild.transformSync !== "function") {
|
|
37414
37557
|
return "esbuild does not export transformSync";
|
|
@@ -37483,7 +37626,7 @@ function sidecarStateDir(input2) {
|
|
|
37483
37626
|
if (!scope || scope.includes("/") || scope.includes("\\")) {
|
|
37484
37627
|
return null;
|
|
37485
37628
|
}
|
|
37486
|
-
return
|
|
37629
|
+
return join20(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
|
|
37487
37630
|
}
|
|
37488
37631
|
function sidecarRegistryUrl(hostUrl) {
|
|
37489
37632
|
let url;
|
|
@@ -37510,7 +37653,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
|
|
|
37510
37653
|
}
|
|
37511
37654
|
function readOptionalText(path) {
|
|
37512
37655
|
try {
|
|
37513
|
-
return
|
|
37656
|
+
return readFileSync19(path, "utf8").trim();
|
|
37514
37657
|
} catch {
|
|
37515
37658
|
return "";
|
|
37516
37659
|
}
|
|
@@ -37525,12 +37668,12 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37525
37668
|
if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || isAbsolute7(relativeEntrypoint)) {
|
|
37526
37669
|
return null;
|
|
37527
37670
|
}
|
|
37528
|
-
const installMethod = readOptionalText(
|
|
37671
|
+
const installMethod = readOptionalText(join20(stateDir, ".install-method"));
|
|
37529
37672
|
if (installMethod !== "python-sidecar") return null;
|
|
37530
37673
|
const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
|
|
37531
37674
|
const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
|
|
37532
|
-
const nodeBin = readOptionalText(
|
|
37533
|
-
const sidecarPath = readOptionalText(
|
|
37675
|
+
const nodeBin = readOptionalText(join20(stateDir, ".node-bin")) || process.execPath;
|
|
37676
|
+
const sidecarPath = readOptionalText(join20(stateDir, ".command-path")) || join20(
|
|
37534
37677
|
stateDir,
|
|
37535
37678
|
"bin",
|
|
37536
37679
|
process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
|
|
@@ -37538,7 +37681,7 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37538
37681
|
const packageSpec = options.packageSpec || "deepline@latest";
|
|
37539
37682
|
const npmCommand = "npm";
|
|
37540
37683
|
const registryUrl = sidecarRegistryUrl(hostUrl);
|
|
37541
|
-
const versionDir =
|
|
37684
|
+
const versionDir = join20(stateDir, "versions", "<version>");
|
|
37542
37685
|
const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
|
|
37543
37686
|
return {
|
|
37544
37687
|
kind: "python-sidecar",
|
|
@@ -37556,11 +37699,11 @@ function resolvePythonSidecarUpdatePlan(options) {
|
|
|
37556
37699
|
function findRepoBackedSdkRoot(startPath) {
|
|
37557
37700
|
let current = resolve18(startPath);
|
|
37558
37701
|
while (true) {
|
|
37559
|
-
if (
|
|
37702
|
+
if (existsSync18(join20(current, "package.json")) && existsSync18(join20(current, "bin", "deepline-dev.ts"))) {
|
|
37560
37703
|
const parent2 = dirname18(current);
|
|
37561
37704
|
return basename7(parent2) === "packages" && basename7(current) === "sdk" ? dirname18(parent2) : parent2;
|
|
37562
37705
|
}
|
|
37563
|
-
if (
|
|
37706
|
+
if (existsSync18(join20(current, "sdk", "package.json")) && existsSync18(join20(current, "sdk", "bin", "deepline-dev.ts"))) {
|
|
37564
37707
|
return current;
|
|
37565
37708
|
}
|
|
37566
37709
|
const parent = dirname18(current);
|
|
@@ -37588,7 +37731,7 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
|
|
|
37588
37731
|
const directPrefix = prefixParts.join("/").toLowerCase();
|
|
37589
37732
|
const knownWindowsPrefixes = [
|
|
37590
37733
|
env.npm_config_prefix,
|
|
37591
|
-
env.APPDATA ?
|
|
37734
|
+
env.APPDATA ? join20(env.APPDATA, "npm") : void 0
|
|
37592
37735
|
].filter((value) => Boolean(value)).map((value) => resolve18(value).replace(/\\/g, "/").toLowerCase());
|
|
37593
37736
|
if (!knownWindowsPrefixes.includes(
|
|
37594
37737
|
resolve18(directPrefix).replace(/\\/g, "/").toLowerCase()
|
|
@@ -37693,9 +37836,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
|
|
|
37693
37836
|
function autoUpdateFailurePath(plan) {
|
|
37694
37837
|
if (plan.kind === "source" || plan.kind === "homebrew") return null;
|
|
37695
37838
|
if (plan.kind === "python-sidecar") {
|
|
37696
|
-
return
|
|
37839
|
+
return join20(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
|
|
37697
37840
|
}
|
|
37698
|
-
return
|
|
37841
|
+
return join20(
|
|
37699
37842
|
homedir11(),
|
|
37700
37843
|
".local",
|
|
37701
37844
|
"deepline",
|
|
@@ -37713,7 +37856,7 @@ function readAutoUpdateFailure(plan) {
|
|
|
37713
37856
|
if (!path) return null;
|
|
37714
37857
|
try {
|
|
37715
37858
|
const parsed = JSON.parse(
|
|
37716
|
-
|
|
37859
|
+
readFileSync19(path, "utf8")
|
|
37717
37860
|
);
|
|
37718
37861
|
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") {
|
|
37719
37862
|
return parsed;
|
|
@@ -37734,8 +37877,8 @@ function writeAutoUpdateFailure(plan, exitCode) {
|
|
|
37734
37877
|
manualCommand: plan.manualCommand
|
|
37735
37878
|
};
|
|
37736
37879
|
try {
|
|
37737
|
-
|
|
37738
|
-
|
|
37880
|
+
mkdirSync14(dirname18(path), { recursive: true });
|
|
37881
|
+
writeFileSync18(path, `${JSON.stringify(marker, null, 2)}
|
|
37739
37882
|
`, "utf8");
|
|
37740
37883
|
} catch {
|
|
37741
37884
|
}
|
|
@@ -37744,7 +37887,7 @@ function clearAutoUpdateFailure(plan) {
|
|
|
37744
37887
|
const path = autoUpdateFailurePath(plan);
|
|
37745
37888
|
if (!path) return;
|
|
37746
37889
|
try {
|
|
37747
|
-
|
|
37890
|
+
unlinkSync3(path);
|
|
37748
37891
|
} catch {
|
|
37749
37892
|
}
|
|
37750
37893
|
}
|
|
@@ -37782,7 +37925,7 @@ function safeVersionSegment(value) {
|
|
|
37782
37925
|
return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
|
|
37783
37926
|
}
|
|
37784
37927
|
function entryPathInVersionDir(versionDir) {
|
|
37785
|
-
return
|
|
37928
|
+
return join20(
|
|
37786
37929
|
versionDir,
|
|
37787
37930
|
"node_modules",
|
|
37788
37931
|
"deepline",
|
|
@@ -37792,14 +37935,14 @@ function entryPathInVersionDir(versionDir) {
|
|
|
37792
37935
|
);
|
|
37793
37936
|
}
|
|
37794
37937
|
function installedPackageVersion(versionDir) {
|
|
37795
|
-
const packageJsonPath =
|
|
37938
|
+
const packageJsonPath = join20(
|
|
37796
37939
|
versionDir,
|
|
37797
37940
|
"node_modules",
|
|
37798
37941
|
"deepline",
|
|
37799
37942
|
"package.json"
|
|
37800
37943
|
);
|
|
37801
37944
|
try {
|
|
37802
|
-
const parsed = JSON.parse(
|
|
37945
|
+
const parsed = JSON.parse(readFileSync19(packageJsonPath, "utf8"));
|
|
37803
37946
|
return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
|
|
37804
37947
|
} catch {
|
|
37805
37948
|
return "";
|
|
@@ -37914,20 +38057,20 @@ async function runNpmInstallWithRegistryFallback(input2) {
|
|
|
37914
38057
|
return first.exitCode;
|
|
37915
38058
|
}
|
|
37916
38059
|
function writeSidecarLauncher(input2) {
|
|
37917
|
-
|
|
38060
|
+
mkdirSync14(dirname18(input2.path), { recursive: true });
|
|
37918
38061
|
const packageRoot = dirname18(dirname18(dirname18(input2.entryPath)));
|
|
37919
38062
|
const versionDir = dirname18(dirname18(packageRoot));
|
|
37920
38063
|
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);";
|
|
37921
38064
|
const criticalPaths = [
|
|
37922
38065
|
...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
|
|
37923
|
-
(path) =>
|
|
38066
|
+
(path) => join20(packageRoot, path)
|
|
37924
38067
|
),
|
|
37925
38068
|
...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
|
|
37926
|
-
(path) =>
|
|
38069
|
+
(path) => join20(versionDir, "node_modules", path)
|
|
37927
38070
|
)
|
|
37928
38071
|
];
|
|
37929
38072
|
if (process.platform === "win32") {
|
|
37930
|
-
|
|
38073
|
+
writeFileSync18(
|
|
37931
38074
|
input2.path,
|
|
37932
38075
|
[
|
|
37933
38076
|
`@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
|
|
@@ -37950,7 +38093,7 @@ function writeSidecarLauncher(input2) {
|
|
|
37950
38093
|
);
|
|
37951
38094
|
return;
|
|
37952
38095
|
}
|
|
37953
|
-
|
|
38096
|
+
writeFileSync18(
|
|
37954
38097
|
input2.path,
|
|
37955
38098
|
[
|
|
37956
38099
|
"#!/usr/bin/env sh",
|
|
@@ -37977,14 +38120,14 @@ function writeSidecarLauncher(input2) {
|
|
|
37977
38120
|
);
|
|
37978
38121
|
}
|
|
37979
38122
|
async function runPythonSidecarUpdatePlan(plan) {
|
|
37980
|
-
const versionsDir =
|
|
37981
|
-
const tempDir =
|
|
38123
|
+
const versionsDir = join20(plan.stateDir, "versions");
|
|
38124
|
+
const tempDir = join20(
|
|
37982
38125
|
versionsDir,
|
|
37983
38126
|
`.tmp-sdk-update-${process.pid}-${Date.now()}`
|
|
37984
38127
|
);
|
|
37985
38128
|
rmSync6(tempDir, { recursive: true, force: true });
|
|
37986
|
-
|
|
37987
|
-
|
|
38129
|
+
mkdirSync14(tempDir, { recursive: true });
|
|
38130
|
+
writeFileSync18(join20(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
|
|
37988
38131
|
const env = {
|
|
37989
38132
|
...process.env,
|
|
37990
38133
|
PATH: `${dirname18(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
|
|
@@ -38024,7 +38167,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38024
38167
|
rmSync6(tempDir, { recursive: true, force: true });
|
|
38025
38168
|
return 1;
|
|
38026
38169
|
}
|
|
38027
|
-
const finalDir =
|
|
38170
|
+
const finalDir = join20(versionsDir, installedVersion);
|
|
38028
38171
|
const finalEntryPath = entryPathInVersionDir(finalDir);
|
|
38029
38172
|
const finalFailure = sidecarInstallFailure(finalDir);
|
|
38030
38173
|
let backupDir = null;
|
|
@@ -38032,8 +38175,8 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38032
38175
|
rmSync6(tempDir, { recursive: true, force: true });
|
|
38033
38176
|
} else {
|
|
38034
38177
|
let shouldPublishTemp = true;
|
|
38035
|
-
if (
|
|
38036
|
-
backupDir =
|
|
38178
|
+
if (existsSync18(finalDir)) {
|
|
38179
|
+
backupDir = join20(
|
|
38037
38180
|
versionsDir,
|
|
38038
38181
|
`.backup-${installedVersion}-${process.pid}-${Date.now()}`
|
|
38039
38182
|
);
|
|
@@ -38066,7 +38209,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38066
38209
|
backupDir = null;
|
|
38067
38210
|
} else {
|
|
38068
38211
|
let restoreFailure = "";
|
|
38069
|
-
if (backupDir &&
|
|
38212
|
+
if (backupDir && existsSync18(backupDir) && !existsSync18(finalDir)) {
|
|
38070
38213
|
try {
|
|
38071
38214
|
renameSync2(backupDir, finalDir);
|
|
38072
38215
|
backupDir = null;
|
|
@@ -38085,7 +38228,7 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38085
38228
|
}
|
|
38086
38229
|
const publishedFailure = sidecarStructureFailure(finalDir);
|
|
38087
38230
|
if (publishedFailure) {
|
|
38088
|
-
if (backupDir &&
|
|
38231
|
+
if (backupDir && existsSync18(backupDir)) {
|
|
38089
38232
|
rmSync6(finalDir, { recursive: true, force: true });
|
|
38090
38233
|
try {
|
|
38091
38234
|
renameSync2(backupDir, finalDir);
|
|
@@ -38107,28 +38250,28 @@ async function runPythonSidecarUpdatePlan(plan) {
|
|
|
38107
38250
|
nodeBin: plan.nodeBin,
|
|
38108
38251
|
entryPath: finalEntryPath
|
|
38109
38252
|
});
|
|
38110
|
-
|
|
38111
|
-
|
|
38253
|
+
writeFileSync18(
|
|
38254
|
+
join20(plan.stateDir, ".version"),
|
|
38112
38255
|
`${installedVersion}
|
|
38113
38256
|
`,
|
|
38114
38257
|
"utf8"
|
|
38115
38258
|
);
|
|
38116
|
-
|
|
38117
|
-
|
|
38259
|
+
writeFileSync18(
|
|
38260
|
+
join20(plan.stateDir, ".install-method"),
|
|
38118
38261
|
"python-sidecar\n",
|
|
38119
38262
|
"utf8"
|
|
38120
38263
|
);
|
|
38121
|
-
|
|
38122
|
-
|
|
38264
|
+
writeFileSync18(
|
|
38265
|
+
join20(plan.stateDir, ".command-path"),
|
|
38123
38266
|
`${plan.sidecarPath}
|
|
38124
38267
|
`,
|
|
38125
38268
|
"utf8"
|
|
38126
38269
|
);
|
|
38127
|
-
|
|
38128
|
-
|
|
38270
|
+
writeFileSync18(join20(plan.stateDir, ".runner"), "node\n", "utf8");
|
|
38271
|
+
writeFileSync18(join20(plan.stateDir, ".node-bin"), `${plan.nodeBin}
|
|
38129
38272
|
`, "utf8");
|
|
38130
|
-
|
|
38131
|
-
|
|
38273
|
+
writeFileSync18(
|
|
38274
|
+
join20(plan.stateDir, ".entry-path"),
|
|
38132
38275
|
`${finalEntryPath}
|
|
38133
38276
|
`,
|
|
38134
38277
|
"utf8"
|
|
@@ -39057,24 +39200,24 @@ chooses the connected Slack channel or member and the events it receives.
|
|
|
39057
39200
|
import { Option as Option2 } from "commander";
|
|
39058
39201
|
import {
|
|
39059
39202
|
chmodSync,
|
|
39060
|
-
existsSync as
|
|
39203
|
+
existsSync as existsSync19,
|
|
39061
39204
|
mkdtempSync,
|
|
39062
|
-
readFileSync as
|
|
39063
|
-
writeFileSync as
|
|
39205
|
+
readFileSync as readFileSync20,
|
|
39206
|
+
writeFileSync as writeFileSync20
|
|
39064
39207
|
} from "fs";
|
|
39065
39208
|
import { tmpdir as tmpdir5 } from "os";
|
|
39066
|
-
import { join as
|
|
39209
|
+
import { join as join22, resolve as resolve19 } from "path";
|
|
39067
39210
|
|
|
39068
39211
|
// src/tool-output.ts
|
|
39069
39212
|
import {
|
|
39070
39213
|
closeSync as closeSync3,
|
|
39071
|
-
mkdirSync as
|
|
39214
|
+
mkdirSync as mkdirSync15,
|
|
39072
39215
|
openSync as openSync3,
|
|
39073
|
-
writeFileSync as
|
|
39216
|
+
writeFileSync as writeFileSync19,
|
|
39074
39217
|
writeSync
|
|
39075
39218
|
} from "fs";
|
|
39076
39219
|
import { homedir as homedir12 } from "os";
|
|
39077
|
-
import { dirname as dirname19, join as
|
|
39220
|
+
import { dirname as dirname19, join as join21 } from "path";
|
|
39078
39221
|
function isPlainObject(value) {
|
|
39079
39222
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
39080
39223
|
}
|
|
@@ -39201,19 +39344,19 @@ function projectRowOutput(conversion) {
|
|
|
39201
39344
|
};
|
|
39202
39345
|
}
|
|
39203
39346
|
function ensureOutputDir() {
|
|
39204
|
-
const outputDir =
|
|
39205
|
-
|
|
39347
|
+
const outputDir = join21(homedir12(), ".local", "share", "deepline", "data");
|
|
39348
|
+
mkdirSync15(outputDir, { recursive: true });
|
|
39206
39349
|
return outputDir;
|
|
39207
39350
|
}
|
|
39208
39351
|
function writeJsonOutputFile(payload, stem) {
|
|
39209
39352
|
const outputDir = ensureOutputDir();
|
|
39210
|
-
const outputPath =
|
|
39211
|
-
|
|
39353
|
+
const outputPath = join21(outputDir, `${stem}_${Date.now()}.json`);
|
|
39354
|
+
writeFileSync19(outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
39212
39355
|
return outputPath;
|
|
39213
39356
|
}
|
|
39214
39357
|
function writeCsvOutputFile(rows, stem, options) {
|
|
39215
|
-
const outputPath = options?.outPath ? options.outPath :
|
|
39216
|
-
|
|
39358
|
+
const outputPath = options?.outPath ? options.outPath : join21(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
39359
|
+
mkdirSync15(dirname19(outputPath), { recursive: true });
|
|
39217
39360
|
const columns = columnsForRows(rows);
|
|
39218
39361
|
const escapeCell = (value) => {
|
|
39219
39362
|
const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
|
|
@@ -41174,10 +41317,10 @@ function normalizeOutputFormat(raw) {
|
|
|
41174
41317
|
function resolveAtFilePath(rawPath) {
|
|
41175
41318
|
const trimmed = rawPath.trim();
|
|
41176
41319
|
const resolved = resolve19(trimmed);
|
|
41177
|
-
if (
|
|
41320
|
+
if (existsSync19(resolved)) return resolved;
|
|
41178
41321
|
if (process.platform !== "win32" && trimmed.includes("\\")) {
|
|
41179
41322
|
const normalized = resolve19(trimmed.replace(/\\/g, "/"));
|
|
41180
|
-
if (
|
|
41323
|
+
if (existsSync19(normalized)) return normalized;
|
|
41181
41324
|
}
|
|
41182
41325
|
return resolved;
|
|
41183
41326
|
}
|
|
@@ -41188,7 +41331,7 @@ function readJsonArgument(raw, flagName) {
|
|
|
41188
41331
|
throw new Error(`Invalid ${flagName} value: empty @file path.`);
|
|
41189
41332
|
}
|
|
41190
41333
|
try {
|
|
41191
|
-
return
|
|
41334
|
+
return readFileSync20(resolveAtFilePath(filePath), "utf8").replace(
|
|
41192
41335
|
/^\uFEFF/,
|
|
41193
41336
|
""
|
|
41194
41337
|
);
|
|
@@ -41295,9 +41438,9 @@ function starterScriptJson(script) {
|
|
|
41295
41438
|
function seedToolListScript(input2) {
|
|
41296
41439
|
const stem = safeFileStem(input2.toolId);
|
|
41297
41440
|
const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
|
|
41298
|
-
const scriptDir = mkdtempSync(
|
|
41441
|
+
const scriptDir = mkdtempSync(join22(tmpdir5(), "deepline-workflow-seed-"));
|
|
41299
41442
|
chmodSync(scriptDir, 448);
|
|
41300
|
-
const scriptPath =
|
|
41443
|
+
const scriptPath = join22(scriptDir, fileName);
|
|
41301
41444
|
const projectDir = `deepline/projects/${stem}-workflow`;
|
|
41302
41445
|
const playName = `${stem}-workflow`;
|
|
41303
41446
|
const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
|
|
@@ -41340,7 +41483,7 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
|
|
|
41340
41483
|
description: ${JSON.stringify(`Seed ${input2.toolId} rows into a Deepline workflow-ready dataset.`)},
|
|
41341
41484
|
});
|
|
41342
41485
|
`;
|
|
41343
|
-
|
|
41486
|
+
writeFileSync20(scriptPath, script, { encoding: "utf-8", mode: 384 });
|
|
41344
41487
|
return {
|
|
41345
41488
|
path: scriptPath,
|
|
41346
41489
|
sourceCode: script,
|
|
@@ -41766,10 +41909,10 @@ Examples:
|
|
|
41766
41909
|
|
|
41767
41910
|
// src/cli/commands/workflow.ts
|
|
41768
41911
|
import { mkdir as mkdir5, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
|
|
41769
|
-
import { dirname as dirname20, join as
|
|
41912
|
+
import { dirname as dirname20, join as join23, resolve as resolve20 } from "path";
|
|
41770
41913
|
|
|
41771
41914
|
// src/cli/workflow-to-play.ts
|
|
41772
|
-
import { createHash as
|
|
41915
|
+
import { createHash as createHash6 } from "crypto";
|
|
41773
41916
|
var HITL_WAIT_FOR_SIGNAL_TOOL = "deepline_workflow_wait_for_signal";
|
|
41774
41917
|
var HITL_SLACK_TOOL = "slack_message_with_hitl";
|
|
41775
41918
|
var SUB_WORKFLOW_TOOL_PREFIX = "deepline_workflow_";
|
|
@@ -41875,7 +42018,7 @@ function sanitizePlayNameSegment(value) {
|
|
|
41875
42018
|
}
|
|
41876
42019
|
function deriveWorkflowPlayName(workflowName) {
|
|
41877
42020
|
const base = sanitizePlayNameSegment(workflowName) || "workflow";
|
|
41878
|
-
const suffix =
|
|
42021
|
+
const suffix = createHash6("sha256").update(workflowName).digest("hex").slice(0, 8);
|
|
41879
42022
|
const reserved = suffix.length + 1;
|
|
41880
42023
|
const allowedBase = Math.max(1, MAX_PLAY_NAME_LENGTH - reserved);
|
|
41881
42024
|
let name = `${base.slice(0, allowedBase)}_${suffix}`;
|
|
@@ -42017,7 +42160,7 @@ async function transformOne(api, workflowId, outDir, publish) {
|
|
|
42017
42160
|
revision.config,
|
|
42018
42161
|
{ workflowName: workflow.name, version: revision.version }
|
|
42019
42162
|
);
|
|
42020
|
-
const file =
|
|
42163
|
+
const file = join23(resolve20(outDir), `${compiled.playName}.play.ts`);
|
|
42021
42164
|
await mkdir5(dirname20(file), { recursive: true });
|
|
42022
42165
|
await writeFile5(file, compiled.sourceCode, "utf8");
|
|
42023
42166
|
let published = false;
|
|
@@ -42650,8 +42793,8 @@ function topLevelCommandKnown(program, commandName) {
|
|
|
42650
42793
|
);
|
|
42651
42794
|
}
|
|
42652
42795
|
async function runPlayRunnerHealthCheck() {
|
|
42653
|
-
const dir = await mkdtemp2(
|
|
42654
|
-
const file =
|
|
42796
|
+
const dir = await mkdtemp2(join24(tmpdir6(), "deepline-health-play-"));
|
|
42797
|
+
const file = join24(dir, "health-check.play.ts");
|
|
42655
42798
|
try {
|
|
42656
42799
|
await writeFile6(
|
|
42657
42800
|
file,
|