deepline 0.3.207 → 0.3.209
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +70 -3
- package/dist/cli/index.js +240 -101
- package/dist/cli/index.mjs +240 -101
- package/dist/index.js +5 -1
- package/dist/index.mjs +5 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +1 -1
- package/dist/release.mjs +1 -1
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -3046,7 +3046,7 @@ var SDK_RELEASE = {
|
|
|
3046
3046
|
// getters keep their established compatibility behavior.
|
|
3047
3047
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
3048
3048
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
3049
|
-
version: "0.3.
|
|
3049
|
+
version: "0.3.209",
|
|
3050
3050
|
updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
|
|
3051
3051
|
packageCapabilities: {
|
|
3052
3052
|
updatePreferences: 1
|
|
@@ -5445,6 +5445,8 @@ function createEmptyPlayRunLedgerSnapshot(input2) {
|
|
|
5445
5445
|
runId: input2.runId,
|
|
5446
5446
|
playName: input2.playName ?? null,
|
|
5447
5447
|
status,
|
|
5448
|
+
waitKind: null,
|
|
5449
|
+
waitUntil: null,
|
|
5448
5450
|
error: optionalNullableString(input2.error) ?? null,
|
|
5449
5451
|
createdAt: finiteNumber(input2.createdAt) ?? null,
|
|
5450
5452
|
startedAt,
|
|
@@ -5541,6 +5543,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
5541
5543
|
runId: optionalString(value.runId) ?? fallback.runId,
|
|
5542
5544
|
playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
|
|
5543
5545
|
status: normalizePlayRunLedgerStatus(value.status ?? fallback.status),
|
|
5546
|
+
waitKind: optionalNullableString(value.waitKind),
|
|
5547
|
+
waitUntil: finiteNumber(value.waitUntil),
|
|
5544
5548
|
error,
|
|
5545
5549
|
createdAt,
|
|
5546
5550
|
startedAt,
|
|
@@ -11652,6 +11656,7 @@ function printCommandEnvelope(envelope, options = {}) {
|
|
|
11652
11656
|
var EXIT_OK = 0;
|
|
11653
11657
|
var EXIT_AUTH = 3;
|
|
11654
11658
|
var EXIT_SERVER = 5;
|
|
11659
|
+
var EXIT_WORKSPACE_MISMATCH = 6;
|
|
11655
11660
|
var AUTH_HTTP_TIMEOUT_MS = 1e4;
|
|
11656
11661
|
var AUTH_REGISTER_HTTP_TIMEOUT_MS = 3e4;
|
|
11657
11662
|
function statusBannerLine(value) {
|
|
@@ -11742,7 +11747,8 @@ function readPendingAuthClaim(baseUrl, scope) {
|
|
|
11742
11747
|
if (!claimToken) return null;
|
|
11743
11748
|
return {
|
|
11744
11749
|
claimToken,
|
|
11745
|
-
claimUrl: typeof parsed.claimUrl === "string" ? parsed.claimUrl.trim() :
|
|
11750
|
+
claimUrl: typeof parsed.claimUrl === "string" && parsed.claimUrl.trim() ? parsed.claimUrl.trim() : `${baseUrl}/api/v2/auth/cli/claim/${encodeURIComponent(claimToken)}`,
|
|
11751
|
+
orgName: typeof parsed.orgName === "string" ? parsed.orgName.trim() : void 0,
|
|
11746
11752
|
// The record's own scope, when it has one. `register` writes this field
|
|
11747
11753
|
// precisely so a resume can learn where the credential belongs; reading
|
|
11748
11754
|
// back the caller's argument instead made it decorative, and a record
|
|
@@ -11763,6 +11769,14 @@ function clearPendingClaim(baseUrl, scope) {
|
|
|
11763
11769
|
} catch {
|
|
11764
11770
|
}
|
|
11765
11771
|
}
|
|
11772
|
+
function clearSatisfiedPendingClaim(baseUrl, scope, connectedWorkspaceName) {
|
|
11773
|
+
const pending = readPendingAuthClaim(baseUrl, scope);
|
|
11774
|
+
if (!pending) return;
|
|
11775
|
+
if (pending.orgName && pending.orgName.toLowerCase() !== connectedWorkspaceName?.trim().toLowerCase()) {
|
|
11776
|
+
return;
|
|
11777
|
+
}
|
|
11778
|
+
clearPendingClaim(baseUrl, scope);
|
|
11779
|
+
}
|
|
11766
11780
|
function parseRegisterWaitMode(args) {
|
|
11767
11781
|
let mode = "auto";
|
|
11768
11782
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -12000,7 +12014,12 @@ async function handleRegister(args) {
|
|
|
12000
12014
|
const claimUrl = String(data.claim_url || "");
|
|
12001
12015
|
const claimToken = String(data.claim_token || "");
|
|
12002
12016
|
if (claimToken) {
|
|
12003
|
-
savePendingClaim(baseUrl, {
|
|
12017
|
+
savePendingClaim(baseUrl, {
|
|
12018
|
+
claimToken,
|
|
12019
|
+
claimUrl,
|
|
12020
|
+
scope: authScope,
|
|
12021
|
+
...orgName ? { orgName } : {}
|
|
12022
|
+
});
|
|
12004
12023
|
saveEnvValues(
|
|
12005
12024
|
{
|
|
12006
12025
|
[HOST_URL_ENV]: baseUrl
|
|
@@ -12046,6 +12065,13 @@ async function handleRegister(args) {
|
|
|
12046
12065
|
return EXIT_SERVER;
|
|
12047
12066
|
}
|
|
12048
12067
|
const state = String(statusData.status || "").toLowerCase();
|
|
12068
|
+
if (statusData.code === "REQUESTED_WORKSPACE_NOT_IN_ACCOUNT") {
|
|
12069
|
+
clearPendingClaim(baseUrl, authScope);
|
|
12070
|
+
console.error(
|
|
12071
|
+
"The requested workspace does not exist in this account. Connect to an existing workspace first; then use `deepline org create` if you need a new one."
|
|
12072
|
+
);
|
|
12073
|
+
return EXIT_WORKSPACE_MISMATCH;
|
|
12074
|
+
}
|
|
12049
12075
|
if (state === "claimed") {
|
|
12050
12076
|
const apiKey = String(statusData.api_key || "");
|
|
12051
12077
|
if (apiKey) {
|
|
@@ -12107,12 +12133,13 @@ async function handleWait(args) {
|
|
|
12107
12133
|
return EXIT_AUTH;
|
|
12108
12134
|
}
|
|
12109
12135
|
const deadline = Date.now() + timeoutSeconds * 1e3;
|
|
12110
|
-
while (Date.now()
|
|
12136
|
+
while (Date.now() < deadline) {
|
|
12111
12137
|
const { status, data } = await httpJson(
|
|
12112
12138
|
"POST",
|
|
12113
12139
|
`${baseUrl}/api/v2/auth/cli/status`,
|
|
12114
12140
|
null,
|
|
12115
|
-
{ claim_token: claimToken, reveal: true }
|
|
12141
|
+
{ claim_token: claimToken, reveal: true },
|
|
12142
|
+
Math.min(AUTH_HTTP_TIMEOUT_MS, Math.max(1, deadline - Date.now()))
|
|
12116
12143
|
);
|
|
12117
12144
|
if (status === 401 || status === 403) {
|
|
12118
12145
|
clearPendingClaim(baseUrl, authScope);
|
|
@@ -12120,7 +12147,7 @@ async function handleWait(args) {
|
|
|
12120
12147
|
return EXIT_AUTH;
|
|
12121
12148
|
}
|
|
12122
12149
|
if (status >= 500 || status === 0 || status === 400) {
|
|
12123
|
-
await sleep4(2e3);
|
|
12150
|
+
await sleep4(Math.min(2e3, Math.max(0, deadline - Date.now())));
|
|
12124
12151
|
continue;
|
|
12125
12152
|
}
|
|
12126
12153
|
if (status >= 400) {
|
|
@@ -12128,6 +12155,13 @@ async function handleWait(args) {
|
|
|
12128
12155
|
return EXIT_SERVER;
|
|
12129
12156
|
}
|
|
12130
12157
|
const state = String(data.status || "").toLowerCase();
|
|
12158
|
+
if (data.code === "REQUESTED_WORKSPACE_NOT_IN_ACCOUNT") {
|
|
12159
|
+
clearPendingClaim(baseUrl, authScope);
|
|
12160
|
+
console.error(
|
|
12161
|
+
"The requested workspace does not exist in this account. Connect to an existing workspace first; then use `deepline org create` if you need a new one."
|
|
12162
|
+
);
|
|
12163
|
+
return EXIT_WORKSPACE_MISMATCH;
|
|
12164
|
+
}
|
|
12131
12165
|
if (state === "claimed") {
|
|
12132
12166
|
const apiKey = String(data.api_key || "");
|
|
12133
12167
|
if (apiKey) {
|
|
@@ -12150,7 +12184,7 @@ async function handleWait(args) {
|
|
|
12150
12184
|
console.error("That approval link expired. Run: deepline auth register");
|
|
12151
12185
|
return EXIT_AUTH;
|
|
12152
12186
|
}
|
|
12153
|
-
await sleep4(2e3);
|
|
12187
|
+
await sleep4(Math.min(2e3, Math.max(0, deadline - Date.now())));
|
|
12154
12188
|
}
|
|
12155
12189
|
console.error(
|
|
12156
12190
|
"Still pending. Approve the browser link, then run: deepline auth wait"
|
|
@@ -12295,7 +12329,11 @@ async function handleStatus(args) {
|
|
|
12295
12329
|
return EXIT_SERVER;
|
|
12296
12330
|
}
|
|
12297
12331
|
const resolvedAuthScope = authScope ?? (getResolvedProjectAuthSource(baseUrl, apiKey) ? "folder" : "global");
|
|
12298
|
-
|
|
12332
|
+
clearSatisfiedPendingClaim(
|
|
12333
|
+
baseUrl,
|
|
12334
|
+
resolvedAuthScope,
|
|
12335
|
+
typeof data.org_name === "string" ? data.org_name : null
|
|
12336
|
+
);
|
|
12299
12337
|
const payload = {
|
|
12300
12338
|
...hostStatusPayload ?? { host: baseUrl },
|
|
12301
12339
|
status: data.status || "(unknown)",
|
|
@@ -12309,6 +12347,7 @@ async function handleStatus(args) {
|
|
|
12309
12347
|
user: {
|
|
12310
12348
|
id: data.user_id ?? null
|
|
12311
12349
|
},
|
|
12350
|
+
businessDomain: typeof data.business_domain === "string" ? data.business_domain : null,
|
|
12312
12351
|
examples: Array.isArray(data.examples) ? data.examples : []
|
|
12313
12352
|
};
|
|
12314
12353
|
let savedApiKeyPath = null;
|
|
@@ -12420,7 +12459,7 @@ Examples:
|
|
|
12420
12459
|
`
|
|
12421
12460
|
).option(
|
|
12422
12461
|
"--org-name <name>",
|
|
12423
|
-
"
|
|
12462
|
+
"Connect to an existing workspace, or name your first workspace"
|
|
12424
12463
|
).option(
|
|
12425
12464
|
"--org-id <id>",
|
|
12426
12465
|
"Bind to this workspace directly, skipping the browser picker"
|
|
@@ -45562,11 +45601,24 @@ function openSetupAuthorization(authorizationUrl, options = {}) {
|
|
|
45562
45601
|
}
|
|
45563
45602
|
function buildPendingAuthorizationOutput(input2) {
|
|
45564
45603
|
const authorizationUrl = input2.authorizationUrl.trim();
|
|
45565
|
-
if (input2.browserOpenStatus === "
|
|
45604
|
+
if (input2.browserOpenStatus === "existing_claim" && authorizationUrl) {
|
|
45566
45605
|
return {
|
|
45567
|
-
authorizationUrl
|
|
45568
|
-
next: `
|
|
45569
|
-
lines: [
|
|
45606
|
+
authorizationUrl,
|
|
45607
|
+
next: `The existing approval is still pending. Use its authorization URL if needed, then run: ${input2.resumeCommand}`,
|
|
45608
|
+
lines: [
|
|
45609
|
+
"Deepline did not open another browser tab. Use the existing approval page or this link:",
|
|
45610
|
+
authorizationUrl
|
|
45611
|
+
]
|
|
45612
|
+
};
|
|
45613
|
+
}
|
|
45614
|
+
if (input2.browserOpenStatus === "timed_out" && authorizationUrl) {
|
|
45615
|
+
return {
|
|
45616
|
+
authorizationUrl,
|
|
45617
|
+
next: `Approval is still pending after five minutes. Use the authorization URL if needed, then run: ${input2.resumeCommand}`,
|
|
45618
|
+
lines: [
|
|
45619
|
+
"Approval is still pending. Use this link if the tab was missed:",
|
|
45620
|
+
authorizationUrl
|
|
45621
|
+
]
|
|
45570
45622
|
};
|
|
45571
45623
|
}
|
|
45572
45624
|
if (authorizationUrl) {
|
|
@@ -45756,15 +45808,16 @@ function rollbackCommand(scope, root) {
|
|
|
45756
45808
|
const allowScriptsFlag = npmSupportsAllowScripts(readNpmVersion(process.env)) ? " --allow-scripts=esbuild" : "";
|
|
45757
45809
|
return `npm install -g${prefix} --no-audit --no-fund --include=optional${allowScriptsFlag} deepline@${SDK_VERSION}`;
|
|
45758
45810
|
}
|
|
45759
|
-
function setupResumeCommand(baseUrl, scope) {
|
|
45811
|
+
function setupResumeCommand(baseUrl, scope, orgName) {
|
|
45760
45812
|
const hostPrefix = baseUrl === "https://code.deepline.com" ? "" : `DEEPLINE_HOST_URL=${JSON.stringify(baseUrl)} `;
|
|
45761
|
-
|
|
45813
|
+
const quotedOrgName = orgName ? process.platform === "win32" ? ` --org-name "${orgName.replace(/"/g, '""')}"` : ` --org-name '${orgName.replace(/'/g, `'\\''`)}'` : "";
|
|
45814
|
+
return `${hostPrefix}deepline setup --scope ${scope}${quotedOrgName} --json`;
|
|
45762
45815
|
}
|
|
45763
45816
|
function setupRetry(input2) {
|
|
45764
45817
|
return {
|
|
45765
45818
|
phase: input2.phase,
|
|
45766
|
-
command: setupResumeCommand(input2.baseUrl, input2.scope),
|
|
45767
|
-
automatic: true
|
|
45819
|
+
command: setupResumeCommand(input2.baseUrl, input2.scope, input2.orgName),
|
|
45820
|
+
automatic: input2.retryAutomatic ?? true
|
|
45768
45821
|
};
|
|
45769
45822
|
}
|
|
45770
45823
|
function reportSetupPhaseFailure(input2) {
|
|
@@ -45820,6 +45873,7 @@ function reportSetupAuthStatusFailure(input2) {
|
|
|
45820
45873
|
scope: input2.scope,
|
|
45821
45874
|
root: input2.root,
|
|
45822
45875
|
phases: input2.phases,
|
|
45876
|
+
orgName: input2.orgName,
|
|
45823
45877
|
phase: "auth",
|
|
45824
45878
|
code: "AUTH_STATUS_FAILED",
|
|
45825
45879
|
exitCode: 4,
|
|
@@ -45942,22 +45996,14 @@ function pendingResult(input2) {
|
|
|
45942
45996
|
status: "authorization_pending",
|
|
45943
45997
|
phases: input2.phases
|
|
45944
45998
|
});
|
|
45945
|
-
let browserOpenStatus = "failed";
|
|
45946
|
-
if (input2.authorizationUrl) {
|
|
45947
|
-
browserOpenStatus = openSetupAuthorization(input2.authorizationUrl);
|
|
45948
|
-
if (browserOpenStatus === "opened") {
|
|
45949
|
-
process.stderr.write(
|
|
45950
|
-
"Opened Deepline authorization in your browser. Complete approval there.\n"
|
|
45951
|
-
);
|
|
45952
|
-
} else if (browserOpenStatus === "failed") {
|
|
45953
|
-
process.stderr.write(`Authorize Deepline: ${input2.authorizationUrl}
|
|
45954
|
-
`);
|
|
45955
|
-
}
|
|
45956
|
-
}
|
|
45957
45999
|
const pendingOutput = buildPendingAuthorizationOutput({
|
|
45958
46000
|
authorizationUrl: input2.authorizationUrl,
|
|
45959
|
-
browserOpenStatus,
|
|
45960
|
-
resumeCommand: setupResumeCommand(
|
|
46001
|
+
browserOpenStatus: input2.browserOpenStatus,
|
|
46002
|
+
resumeCommand: setupResumeCommand(
|
|
46003
|
+
input2.baseUrl,
|
|
46004
|
+
input2.scope,
|
|
46005
|
+
input2.orgName
|
|
46006
|
+
)
|
|
45961
46007
|
});
|
|
45962
46008
|
printCommandEnvelope(
|
|
45963
46009
|
{
|
|
@@ -45966,8 +46012,9 @@ function pendingResult(input2) {
|
|
|
45966
46012
|
complete: false,
|
|
45967
46013
|
scope: input2.scope,
|
|
45968
46014
|
authorizationUrl: pendingOutput.authorizationUrl,
|
|
45969
|
-
browserOpened: browserOpenStatus === "
|
|
45970
|
-
browserOpenStatus,
|
|
46015
|
+
browserOpened: input2.browserOpenStatus === "timed_out",
|
|
46016
|
+
browserOpenStatus: input2.browserOpenStatus,
|
|
46017
|
+
authClaimSource: input2.authClaimSource,
|
|
45971
46018
|
statePath,
|
|
45972
46019
|
phases: input2.phases,
|
|
45973
46020
|
currentPhase: "auth",
|
|
@@ -45975,7 +46022,8 @@ function pendingResult(input2) {
|
|
|
45975
46022
|
retry: setupRetry({
|
|
45976
46023
|
baseUrl: input2.baseUrl,
|
|
45977
46024
|
scope: input2.scope,
|
|
45978
|
-
phase: "auth"
|
|
46025
|
+
phase: "auth",
|
|
46026
|
+
orgName: input2.orgName
|
|
45979
46027
|
}),
|
|
45980
46028
|
next: pendingOutput.next,
|
|
45981
46029
|
render: {
|
|
@@ -45992,6 +46040,20 @@ function pendingResult(input2) {
|
|
|
45992
46040
|
return 0;
|
|
45993
46041
|
}
|
|
45994
46042
|
async function runSetupCommand(options) {
|
|
46043
|
+
let orgName = options.orgName?.trim();
|
|
46044
|
+
if (options.orgName !== void 0 && !orgName) {
|
|
46045
|
+
printCommandEnvelope(
|
|
46046
|
+
{
|
|
46047
|
+
ok: false,
|
|
46048
|
+
status: "failed",
|
|
46049
|
+
code: "INVALID_ORG_NAME",
|
|
46050
|
+
exitCode: 2,
|
|
46051
|
+
message: "Workspace name cannot be empty."
|
|
46052
|
+
},
|
|
46053
|
+
{ json: options.json }
|
|
46054
|
+
);
|
|
46055
|
+
return 2;
|
|
46056
|
+
}
|
|
45995
46057
|
let scope;
|
|
45996
46058
|
let root;
|
|
45997
46059
|
try {
|
|
@@ -46036,6 +46098,7 @@ async function runSetupCommand(options) {
|
|
|
46036
46098
|
exitCode: 7,
|
|
46037
46099
|
message: installedButUnreachable ? `The global Deepline executable is not reachable on PATH: ${globalCli.persistentPath}` : "No persistent global Deepline executable was found.",
|
|
46038
46100
|
json: options.json,
|
|
46101
|
+
orgName,
|
|
46039
46102
|
extra: {
|
|
46040
46103
|
persistentPath: globalCli.persistentPath,
|
|
46041
46104
|
fallback: "https://code.deepline.com/INSTALL.md"
|
|
@@ -46055,6 +46118,7 @@ async function runSetupCommand(options) {
|
|
|
46055
46118
|
exitCode: 7,
|
|
46056
46119
|
message: `An unknown executable named deepline is first on PATH: ${conflict}`,
|
|
46057
46120
|
json: options.json,
|
|
46121
|
+
orgName,
|
|
46058
46122
|
extra: { path: conflict }
|
|
46059
46123
|
});
|
|
46060
46124
|
}
|
|
@@ -46088,7 +46152,8 @@ async function runSetupCommand(options) {
|
|
|
46088
46152
|
code: "LEGACY_CLEANUP_FAILED",
|
|
46089
46153
|
exitCode: 5,
|
|
46090
46154
|
message: error instanceof Error ? error.message : String(error),
|
|
46091
|
-
json: options.json
|
|
46155
|
+
json: options.json,
|
|
46156
|
+
orgName
|
|
46092
46157
|
});
|
|
46093
46158
|
}
|
|
46094
46159
|
}
|
|
@@ -46109,7 +46174,7 @@ async function runSetupCommand(options) {
|
|
|
46109
46174
|
process.stderr.write(
|
|
46110
46175
|
"Global skill setup failed. Trying project-local skills instead.\n"
|
|
46111
46176
|
);
|
|
46112
|
-
return runSetupCommand({ scope: "local", json: options.json });
|
|
46177
|
+
return runSetupCommand({ scope: "local", json: options.json, orgName });
|
|
46113
46178
|
}
|
|
46114
46179
|
return reportSetupPhaseFailure({
|
|
46115
46180
|
baseUrl,
|
|
@@ -46121,7 +46186,8 @@ async function runSetupCommand(options) {
|
|
|
46121
46186
|
exitCode: skills.exitCode,
|
|
46122
46187
|
message: typeof skillsPayload?.message === "string" ? skillsPayload.message : "Deepline skills could not be installed.",
|
|
46123
46188
|
json: options.json,
|
|
46124
|
-
|
|
46189
|
+
orgName,
|
|
46190
|
+
next: `! ${setupResumeCommand(baseUrl, scope, orgName)}`,
|
|
46125
46191
|
extra: { detail: skillsPayload }
|
|
46126
46192
|
});
|
|
46127
46193
|
}
|
|
@@ -46143,6 +46209,13 @@ async function runSetupCommand(options) {
|
|
|
46143
46209
|
);
|
|
46144
46210
|
}
|
|
46145
46211
|
const authScope = authScopeForSetup(scope);
|
|
46212
|
+
const pendingAtStart = readPendingAuthClaim(baseUrl, authScope);
|
|
46213
|
+
const replacingPendingClaim = Boolean(
|
|
46214
|
+
pendingAtStart && orgName && pendingAtStart.orgName?.toLowerCase() !== orgName.toLowerCase()
|
|
46215
|
+
);
|
|
46216
|
+
if (pendingAtStart && !replacingPendingClaim) {
|
|
46217
|
+
if (pendingAtStart.orgName) orgName = pendingAtStart.orgName;
|
|
46218
|
+
}
|
|
46146
46219
|
beginSetupPhase(phases, "auth");
|
|
46147
46220
|
persistSetupProgress({ baseUrl, scope, root, phases });
|
|
46148
46221
|
let auth = await readAuthStatus(authScope);
|
|
@@ -46153,88 +46226,146 @@ async function runSetupCommand(options) {
|
|
|
46153
46226
|
scope,
|
|
46154
46227
|
root,
|
|
46155
46228
|
phases,
|
|
46229
|
+
orgName,
|
|
46156
46230
|
json: options.json
|
|
46157
46231
|
});
|
|
46158
46232
|
if (initialAuthFailure !== null) return initialAuthFailure;
|
|
46159
|
-
|
|
46160
|
-
|
|
46161
|
-
if (
|
|
46162
|
-
|
|
46163
|
-
|
|
46164
|
-
|
|
46165
|
-
|
|
46166
|
-
|
|
46167
|
-
|
|
46168
|
-
|
|
46169
|
-
|
|
46170
|
-
|
|
46171
|
-
|
|
46172
|
-
|
|
46173
|
-
|
|
46174
|
-
|
|
46175
|
-
|
|
46176
|
-
|
|
46177
|
-
|
|
46178
|
-
|
|
46179
|
-
|
|
46180
|
-
|
|
46181
|
-
|
|
46182
|
-
|
|
46183
|
-
|
|
46184
|
-
|
|
46185
|
-
|
|
46186
|
-
|
|
46187
|
-
|
|
46188
|
-
|
|
46189
|
-
|
|
46233
|
+
const connectedToRequestedWorkspace = () => {
|
|
46234
|
+
if (auth.payload?.connected !== true) return false;
|
|
46235
|
+
if (!orgName) return true;
|
|
46236
|
+
const workspace = asRecord3(auth.payload.workspace);
|
|
46237
|
+
return typeof workspace?.name === "string" && workspace.name.trim().toLowerCase() === orgName.toLowerCase();
|
|
46238
|
+
};
|
|
46239
|
+
let pending = replacingPendingClaim ? null : readPendingAuthClaim(baseUrl, authScope);
|
|
46240
|
+
if (replacingPendingClaim && connectedToRequestedWorkspace()) {
|
|
46241
|
+
clearPendingClaim(baseUrl, authScope);
|
|
46242
|
+
}
|
|
46243
|
+
let authClaimSource = "none";
|
|
46244
|
+
if (pending || !connectedToRequestedWorkspace()) {
|
|
46245
|
+
const reusedClaim = Boolean(pending);
|
|
46246
|
+
authClaimSource = reusedClaim ? "existing" : "new";
|
|
46247
|
+
if (!pending) {
|
|
46248
|
+
process.stderr.write("Starting Deepline browser authorization...\n");
|
|
46249
|
+
const registered = await captureStdout2(
|
|
46250
|
+
() => handleRegister([
|
|
46251
|
+
"--wait",
|
|
46252
|
+
"no",
|
|
46253
|
+
"--auth-scope",
|
|
46254
|
+
authScope,
|
|
46255
|
+
...orgName ? ["--org-name", orgName] : []
|
|
46256
|
+
])
|
|
46257
|
+
);
|
|
46258
|
+
if (registered.exitCode !== 0) {
|
|
46259
|
+
return reportSetupPhaseFailure({
|
|
46260
|
+
baseUrl,
|
|
46261
|
+
scope,
|
|
46262
|
+
root,
|
|
46263
|
+
phases,
|
|
46264
|
+
phase: "auth",
|
|
46265
|
+
code: "AUTH_REGISTER_FAILED",
|
|
46266
|
+
exitCode: registered.exitCode,
|
|
46267
|
+
message: "Deepline browser authorization could not be started.",
|
|
46268
|
+
orgName,
|
|
46269
|
+
json: options.json,
|
|
46270
|
+
extra: { detail: parseCapturedJson(registered.stdout), authScope }
|
|
46271
|
+
});
|
|
46190
46272
|
}
|
|
46273
|
+
pending = readPendingAuthClaim(baseUrl, authScope);
|
|
46274
|
+
if (!pending?.claimUrl) {
|
|
46275
|
+
return reportSetupPhaseFailure({
|
|
46276
|
+
baseUrl,
|
|
46277
|
+
scope,
|
|
46278
|
+
root,
|
|
46279
|
+
phases,
|
|
46280
|
+
phase: "auth",
|
|
46281
|
+
code: "AUTH_CLAIM_URL_MISSING",
|
|
46282
|
+
exitCode: 4,
|
|
46283
|
+
message: "Deepline authorization did not return a usable claim URL.",
|
|
46284
|
+
orgName,
|
|
46285
|
+
json: options.json
|
|
46286
|
+
});
|
|
46287
|
+
}
|
|
46288
|
+
const browserOpenStatus = openSetupAuthorization(pending.claimUrl);
|
|
46289
|
+
if (browserOpenStatus === "failed") {
|
|
46290
|
+
return pendingResult({
|
|
46291
|
+
baseUrl,
|
|
46292
|
+
scope,
|
|
46293
|
+
root,
|
|
46294
|
+
phases,
|
|
46295
|
+
authorizationUrl: pending.claimUrl,
|
|
46296
|
+
browserOpenStatus: "failed",
|
|
46297
|
+
authClaimSource,
|
|
46298
|
+
orgName,
|
|
46299
|
+
resumed,
|
|
46300
|
+
json: options.json
|
|
46301
|
+
});
|
|
46302
|
+
}
|
|
46303
|
+
process.stderr.write("Opened Deepline sign-in in the browser.\n");
|
|
46191
46304
|
}
|
|
46192
|
-
|
|
46193
|
-
|
|
46194
|
-
|
|
46195
|
-
const
|
|
46196
|
-
|
|
46197
|
-
const waitMode = options.json || agentLed || !process.stdin.isTTY ? "no" : "auto";
|
|
46198
|
-
const registered = await captureStdout2(
|
|
46199
|
-
() => handleRegister(["--wait", waitMode, "--auth-scope", authScope])
|
|
46305
|
+
process.stderr.write(
|
|
46306
|
+
"Waiting up to five minutes for Deepline approval...\n"
|
|
46307
|
+
);
|
|
46308
|
+
const waited = await captureStdout2(
|
|
46309
|
+
() => handleWait(["--timeout", "300", "--auth-scope", authScope])
|
|
46200
46310
|
);
|
|
46201
|
-
if (registered.exitCode !== 0) {
|
|
46202
|
-
return reportSetupPhaseFailure({
|
|
46203
|
-
baseUrl,
|
|
46204
|
-
scope,
|
|
46205
|
-
root,
|
|
46206
|
-
phases,
|
|
46207
|
-
phase: "auth",
|
|
46208
|
-
code: "AUTH_REGISTER_FAILED",
|
|
46209
|
-
exitCode: registered.exitCode,
|
|
46210
|
-
message: "Deepline browser authorization could not be started.",
|
|
46211
|
-
json: options.json,
|
|
46212
|
-
extra: {
|
|
46213
|
-
detail: parseCapturedJson(registered.stdout),
|
|
46214
|
-
authScope
|
|
46215
|
-
}
|
|
46216
|
-
});
|
|
46217
|
-
}
|
|
46218
46311
|
auth = await readAuthStatus(authScope);
|
|
46219
|
-
const
|
|
46312
|
+
const authFailure = reportSetupAuthStatusFailure({
|
|
46220
46313
|
auth,
|
|
46221
46314
|
baseUrl,
|
|
46222
46315
|
authScope,
|
|
46223
46316
|
scope,
|
|
46224
46317
|
root,
|
|
46225
46318
|
phases,
|
|
46319
|
+
orgName,
|
|
46226
46320
|
json: options.json
|
|
46227
46321
|
});
|
|
46228
|
-
if (
|
|
46229
|
-
if (
|
|
46230
|
-
|
|
46231
|
-
return pendingResult({
|
|
46322
|
+
if (authFailure !== null) return authFailure;
|
|
46323
|
+
if (waited.exitCode === EXIT_WORKSPACE_MISMATCH) {
|
|
46324
|
+
return reportSetupPhaseFailure({
|
|
46232
46325
|
baseUrl,
|
|
46233
46326
|
scope,
|
|
46234
46327
|
root,
|
|
46235
46328
|
phases,
|
|
46236
|
-
|
|
46237
|
-
|
|
46329
|
+
phase: "auth",
|
|
46330
|
+
code: "REQUESTED_WORKSPACE_NOT_IN_ACCOUNT",
|
|
46331
|
+
exitCode: EXIT_WORKSPACE_MISMATCH,
|
|
46332
|
+
message: `The requested workspace${orgName ? ` ${orgName}` : ""} does not exist in this account. Connect to an existing workspace first; then use deepline org create if you need a new one.`,
|
|
46333
|
+
orgName,
|
|
46334
|
+
retryAutomatic: false,
|
|
46335
|
+
next: "Ask the user which existing workspace or account to use. Sign in with an account that can access it, then rerun setup with --org-name set to the confirmed workspace.",
|
|
46336
|
+
json: options.json
|
|
46337
|
+
});
|
|
46338
|
+
}
|
|
46339
|
+
if (!connectedToRequestedWorkspace()) {
|
|
46340
|
+
const stillPending = readPendingAuthClaim(baseUrl, authScope);
|
|
46341
|
+
if (stillPending?.claimUrl) {
|
|
46342
|
+
return pendingResult({
|
|
46343
|
+
baseUrl,
|
|
46344
|
+
scope,
|
|
46345
|
+
root,
|
|
46346
|
+
phases,
|
|
46347
|
+
authorizationUrl: stillPending.claimUrl,
|
|
46348
|
+
browserOpenStatus: reusedClaim ? "existing_claim" : "timed_out",
|
|
46349
|
+
authClaimSource,
|
|
46350
|
+
orgName,
|
|
46351
|
+
resumed,
|
|
46352
|
+
json: options.json
|
|
46353
|
+
});
|
|
46354
|
+
}
|
|
46355
|
+
return reportSetupPhaseFailure({
|
|
46356
|
+
baseUrl,
|
|
46357
|
+
scope,
|
|
46358
|
+
root,
|
|
46359
|
+
phases,
|
|
46360
|
+
phase: "auth",
|
|
46361
|
+
code: orgName && auth.payload?.connected ? "AUTH_WORKSPACE_MISMATCH" : "AUTH_WAIT_FAILED",
|
|
46362
|
+
exitCode: waited.exitCode || 4,
|
|
46363
|
+
message: orgName && auth.payload?.connected ? `Deepline is connected to a different workspace than ${orgName}.` : "Deepline authorization did not complete.",
|
|
46364
|
+
orgName,
|
|
46365
|
+
...orgName && auth.payload?.connected ? {
|
|
46366
|
+
retryAutomatic: false,
|
|
46367
|
+
next: "Ask the user which existing workspace or account to use. Rerun setup with --org-name set to the confirmed workspace."
|
|
46368
|
+
} : {},
|
|
46238
46369
|
json: options.json
|
|
46239
46370
|
});
|
|
46240
46371
|
}
|
|
@@ -46268,6 +46399,7 @@ async function runSetupCommand(options) {
|
|
|
46268
46399
|
code: "DOCTOR_FAILED",
|
|
46269
46400
|
exitCode: 7,
|
|
46270
46401
|
message: "Deepline setup verification found one or more failed checks.",
|
|
46402
|
+
orgName,
|
|
46271
46403
|
json: options.json,
|
|
46272
46404
|
extra: {
|
|
46273
46405
|
doctor: doctorPayload,
|
|
@@ -46308,6 +46440,9 @@ async function runSetupCommand(options) {
|
|
|
46308
46440
|
cliVersion: SDK_VERSION,
|
|
46309
46441
|
agents: installedAgents,
|
|
46310
46442
|
workspace: apiCheck?.workspace ?? null,
|
|
46443
|
+
businessDomain: typeof auth.payload?.businessDomain === "string" ? auth.payload.businessDomain : null,
|
|
46444
|
+
authClaimSource,
|
|
46445
|
+
browserOpened: authClaimSource === "new",
|
|
46311
46446
|
rollbackCommand: rollbackCommand(scope, root),
|
|
46312
46447
|
statePath,
|
|
46313
46448
|
doctor: doctorPayload,
|
|
@@ -46339,7 +46474,10 @@ async function runSetupCommand(options) {
|
|
|
46339
46474
|
return 0;
|
|
46340
46475
|
}
|
|
46341
46476
|
function registerSetupCommands(program) {
|
|
46342
|
-
program.command("setup").description("Install skills, authenticate, and verify Deepline.").option("--scope <scope>", "Setup scope: global or local", "global").option(
|
|
46477
|
+
program.command("setup").description("Install skills, authenticate, and verify Deepline.").option("--scope <scope>", "Setup scope: global or local", "global").option(
|
|
46478
|
+
"--org-name <name>",
|
|
46479
|
+
"Connect to an existing workspace, or name your first workspace"
|
|
46480
|
+
).option("--json", "Emit one final JSON result envelope").addHelpText(
|
|
46343
46481
|
"after",
|
|
46344
46482
|
`
|
|
46345
46483
|
Notes:
|
|
@@ -46349,6 +46487,7 @@ Notes:
|
|
|
46349
46487
|
|
|
46350
46488
|
Examples:
|
|
46351
46489
|
deepline setup --json
|
|
46490
|
+
deepline setup --org-name Acme --json
|
|
46352
46491
|
deepline setup --scope local --json
|
|
46353
46492
|
`
|
|
46354
46493
|
).action(async (options) => {
|
package/dist/index.js
CHANGED
|
@@ -864,7 +864,7 @@ var SDK_RELEASE = {
|
|
|
864
864
|
// getters keep their established compatibility behavior.
|
|
865
865
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
866
866
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
867
|
-
version: "0.3.
|
|
867
|
+
version: "0.3.209",
|
|
868
868
|
updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
|
|
869
869
|
packageCapabilities: {
|
|
870
870
|
updatePreferences: 1
|
|
@@ -3211,6 +3211,8 @@ function createEmptyPlayRunLedgerSnapshot(input) {
|
|
|
3211
3211
|
runId: input.runId,
|
|
3212
3212
|
playName: input.playName ?? null,
|
|
3213
3213
|
status,
|
|
3214
|
+
waitKind: null,
|
|
3215
|
+
waitUntil: null,
|
|
3214
3216
|
error: optionalNullableString(input.error) ?? null,
|
|
3215
3217
|
createdAt: finiteNumber(input.createdAt) ?? null,
|
|
3216
3218
|
startedAt,
|
|
@@ -3307,6 +3309,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
3307
3309
|
runId: optionalString(value.runId) ?? fallback.runId,
|
|
3308
3310
|
playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
|
|
3309
3311
|
status: normalizePlayRunLedgerStatus(value.status ?? fallback.status),
|
|
3312
|
+
waitKind: optionalNullableString(value.waitKind),
|
|
3313
|
+
waitUntil: finiteNumber(value.waitUntil),
|
|
3310
3314
|
error,
|
|
3311
3315
|
createdAt,
|
|
3312
3316
|
startedAt,
|
package/dist/index.mjs
CHANGED
|
@@ -768,7 +768,7 @@ var SDK_RELEASE = {
|
|
|
768
768
|
// getters keep their established compatibility behavior.
|
|
769
769
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
770
770
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
771
|
-
version: "0.3.
|
|
771
|
+
version: "0.3.209",
|
|
772
772
|
updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
|
|
773
773
|
packageCapabilities: {
|
|
774
774
|
updatePreferences: 1
|
|
@@ -3115,6 +3115,8 @@ function createEmptyPlayRunLedgerSnapshot(input) {
|
|
|
3115
3115
|
runId: input.runId,
|
|
3116
3116
|
playName: input.playName ?? null,
|
|
3117
3117
|
status,
|
|
3118
|
+
waitKind: null,
|
|
3119
|
+
waitUntil: null,
|
|
3118
3120
|
error: optionalNullableString(input.error) ?? null,
|
|
3119
3121
|
createdAt: finiteNumber(input.createdAt) ?? null,
|
|
3120
3122
|
startedAt,
|
|
@@ -3211,6 +3213,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
|
|
|
3211
3213
|
runId: optionalString(value.runId) ?? fallback.runId,
|
|
3212
3214
|
playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
|
|
3213
3215
|
status: normalizePlayRunLedgerStatus(value.status ?? fallback.status),
|
|
3216
|
+
waitKind: optionalNullableString(value.waitKind),
|
|
3217
|
+
waitUntil: finiteNumber(value.waitUntil),
|
|
3214
3218
|
error,
|
|
3215
3219
|
createdAt,
|
|
3216
3220
|
startedAt,
|
package/dist/release.d.mts
CHANGED
|
@@ -149,7 +149,7 @@ type SdkRelease = {
|
|
|
149
149
|
supportPolicy: SdkSupportPolicy;
|
|
150
150
|
};
|
|
151
151
|
declare const SDK_RELEASE: {
|
|
152
|
-
readonly version: "0.3.
|
|
152
|
+
readonly version: "0.3.209";
|
|
153
153
|
readonly updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.";
|
|
154
154
|
readonly packageCapabilities: {
|
|
155
155
|
readonly updatePreferences: 1;
|
package/dist/release.d.ts
CHANGED
|
@@ -149,7 +149,7 @@ type SdkRelease = {
|
|
|
149
149
|
supportPolicy: SdkSupportPolicy;
|
|
150
150
|
};
|
|
151
151
|
declare const SDK_RELEASE: {
|
|
152
|
-
readonly version: "0.3.
|
|
152
|
+
readonly version: "0.3.209";
|
|
153
153
|
readonly updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.";
|
|
154
154
|
readonly packageCapabilities: {
|
|
155
155
|
readonly updatePreferences: 1;
|
package/dist/release.js
CHANGED
|
@@ -74,7 +74,7 @@ var SDK_RELEASE = {
|
|
|
74
74
|
// getters keep their established compatibility behavior.
|
|
75
75
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
76
76
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
77
|
-
version: "0.3.
|
|
77
|
+
version: "0.3.209",
|
|
78
78
|
updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
|
|
79
79
|
packageCapabilities: {
|
|
80
80
|
updatePreferences: 1
|