deepline 0.1.138 → 0.1.139
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/README.md +2 -2
- package/dist/bundling-sources/sdk/src/config.ts +13 -310
- package/dist/bundling-sources/sdk/src/release.ts +2 -2
- package/dist/cli/index.js +92 -576
- package/dist/cli/index.mjs +108 -600
- package/dist/index.js +14 -148
- package/dist/index.mjs +15 -157
- package/package.json +1 -1
package/dist/cli/index.mjs
CHANGED
|
@@ -164,15 +164,7 @@ import { tmpdir as tmpdir4 } from "os";
|
|
|
164
164
|
import { Command as Command3 } from "commander";
|
|
165
165
|
|
|
166
166
|
// src/config.ts
|
|
167
|
-
import {
|
|
168
|
-
existsSync,
|
|
169
|
-
mkdirSync,
|
|
170
|
-
readdirSync,
|
|
171
|
-
realpathSync,
|
|
172
|
-
readFileSync,
|
|
173
|
-
statSync,
|
|
174
|
-
writeFileSync
|
|
175
|
-
} from "fs";
|
|
167
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
176
168
|
import { homedir } from "os";
|
|
177
169
|
import { dirname, join, resolve } from "path";
|
|
178
170
|
|
|
@@ -222,22 +214,6 @@ var PROD_URL = "https://code.deepline.com";
|
|
|
222
214
|
var DEFAULT_TIMEOUT = 6e4;
|
|
223
215
|
var DEFAULT_MAX_RETRIES = 3;
|
|
224
216
|
var PROJECT_DEEPLINE_ENV_FILE = ".env.deepline";
|
|
225
|
-
var COWORK_IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
|
|
226
|
-
".auto-memory",
|
|
227
|
-
".claude",
|
|
228
|
-
".remote-plugins",
|
|
229
|
-
"outputs",
|
|
230
|
-
"plugins",
|
|
231
|
-
"uploads"
|
|
232
|
-
]);
|
|
233
|
-
var COWORK_PROJECT_MARKERS = [
|
|
234
|
-
".deepline",
|
|
235
|
-
".env.deepline",
|
|
236
|
-
".git",
|
|
237
|
-
"AGENTS.md",
|
|
238
|
-
"package.json",
|
|
239
|
-
"pyproject.toml"
|
|
240
|
-
];
|
|
241
217
|
function baseUrlSlug(baseUrl) {
|
|
242
218
|
let url;
|
|
243
219
|
try {
|
|
@@ -283,124 +259,9 @@ function findNearestEnvFile(name, startDir = process.cwd()) {
|
|
|
283
259
|
current = parent;
|
|
284
260
|
}
|
|
285
261
|
}
|
|
286
|
-
function
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
} catch {
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function canonicalPath(path) {
|
|
294
|
-
try {
|
|
295
|
-
return realpathSync(path);
|
|
296
|
-
} catch {
|
|
297
|
-
return resolve(path);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function isTruthy(value) {
|
|
301
|
-
return /^(1|true|yes|on)$/i.test(value?.trim() ?? "");
|
|
302
|
-
}
|
|
303
|
-
function sessionRootFromPath(path) {
|
|
304
|
-
const trimmed = path?.trim();
|
|
305
|
-
if (!trimmed) return null;
|
|
306
|
-
const match = /^\/sessions\/[^/]+(?=\/|$)/.exec(trimmed);
|
|
307
|
-
return match?.[0] ?? null;
|
|
308
|
-
}
|
|
309
|
-
function coworkSessionRoot() {
|
|
310
|
-
const home = process.env.HOME?.trim();
|
|
311
|
-
const homeSessionRoot = sessionRootFromPath(home);
|
|
312
|
-
if (homeSessionRoot && isDirectory(join(homeSessionRoot, "mnt"))) {
|
|
313
|
-
return homeSessionRoot;
|
|
314
|
-
}
|
|
315
|
-
const cwdSessionRoot = sessionRootFromPath(process.cwd());
|
|
316
|
-
if (cwdSessionRoot && isDirectory(join(cwdSessionRoot, "mnt"))) {
|
|
317
|
-
return cwdSessionRoot;
|
|
318
|
-
}
|
|
319
|
-
if (isTruthy(process.env.CLAUDE_CODE_REMOTE) && home) {
|
|
320
|
-
const mountedRoot = join(home, "mnt");
|
|
321
|
-
if (isDirectory(mountedRoot)) return resolve(home);
|
|
322
|
-
}
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
|
-
function isCoworkLikeSandbox() {
|
|
326
|
-
const home = process.env.HOME?.trim();
|
|
327
|
-
return isTruthy(process.env.CLAUDE_CODE_REMOTE) || sessionRootFromPath(home) !== null || sessionRootFromPath(process.cwd()) !== null;
|
|
328
|
-
}
|
|
329
|
-
function coworkProjectScore(path) {
|
|
330
|
-
let score = 0;
|
|
331
|
-
for (const marker of COWORK_PROJECT_MARKERS) {
|
|
332
|
-
if (existsSync(join(path, marker))) score += 1;
|
|
333
|
-
}
|
|
334
|
-
return score;
|
|
335
|
-
}
|
|
336
|
-
function listCoworkWorkspaceDirCandidates() {
|
|
337
|
-
if (!isCoworkLikeSandbox()) {
|
|
338
|
-
return [];
|
|
339
|
-
}
|
|
340
|
-
const explicitProjectDir = process.env.CLAUDE_PROJECT_DIR?.trim();
|
|
341
|
-
if (explicitProjectDir && isDirectory(explicitProjectDir)) {
|
|
342
|
-
return [resolve(explicitProjectDir)];
|
|
343
|
-
}
|
|
344
|
-
const sessionRoot = coworkSessionRoot();
|
|
345
|
-
if (!sessionRoot) return [];
|
|
346
|
-
const mountedRoot = join(sessionRoot, "mnt");
|
|
347
|
-
if (!isDirectory(mountedRoot)) return [];
|
|
348
|
-
let names;
|
|
349
|
-
try {
|
|
350
|
-
names = readdirSync(mountedRoot).sort();
|
|
351
|
-
} catch {
|
|
352
|
-
return [];
|
|
353
|
-
}
|
|
354
|
-
const candidates = [];
|
|
355
|
-
for (const name of names) {
|
|
356
|
-
if (name.startsWith(".") || COWORK_IGNORED_WORKSPACE_DIRS.has(name)) {
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
|
-
const candidate = join(mountedRoot, name);
|
|
360
|
-
if (isDirectory(candidate)) candidates.push(candidate);
|
|
361
|
-
}
|
|
362
|
-
if (candidates.length <= 1) return candidates;
|
|
363
|
-
const projectLike = candidates.filter(
|
|
364
|
-
(candidate) => coworkProjectScore(candidate) > 0
|
|
365
|
-
);
|
|
366
|
-
return projectLike.length > 0 ? projectLike : candidates;
|
|
367
|
-
}
|
|
368
|
-
function isInIgnoredCoworkMount(path) {
|
|
369
|
-
const sessionRoot = coworkSessionRoot();
|
|
370
|
-
if (!sessionRoot) return false;
|
|
371
|
-
const mountedRoot = canonicalPath(join(sessionRoot, "mnt"));
|
|
372
|
-
const resolvedPath = canonicalPath(path);
|
|
373
|
-
const prefix = `${mountedRoot}/`;
|
|
374
|
-
if (!resolvedPath.startsWith(prefix)) return false;
|
|
375
|
-
const relativePath = resolvedPath.slice(prefix.length);
|
|
376
|
-
const mountName = relativePath.split("/")[0];
|
|
377
|
-
return mountName.startsWith(".") || COWORK_IGNORED_WORKSPACE_DIRS.has(mountName);
|
|
378
|
-
}
|
|
379
|
-
function detectCoworkWorkspaceDir() {
|
|
380
|
-
const candidates = listCoworkWorkspaceDirCandidates();
|
|
381
|
-
return candidates.length === 1 ? candidates[0] : null;
|
|
382
|
-
}
|
|
383
|
-
function loadProjectEnvCandidates(startDir = process.cwd()) {
|
|
384
|
-
const filePaths = [];
|
|
385
|
-
const sources = /* @__PURE__ */ new Map();
|
|
386
|
-
const nearestFile = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
|
|
387
|
-
if (nearestFile && !isInIgnoredCoworkMount(nearestFile)) {
|
|
388
|
-
filePaths.push(nearestFile);
|
|
389
|
-
sources.set(resolve(nearestFile), "nearest");
|
|
390
|
-
}
|
|
391
|
-
const coworkWorkspaceDir = detectCoworkWorkspaceDir();
|
|
392
|
-
if (coworkWorkspaceDir) {
|
|
393
|
-
const coworkFile = join(coworkWorkspaceDir, PROJECT_DEEPLINE_ENV_FILE);
|
|
394
|
-
if (existsSync(coworkFile) && !filePaths.some((filePath) => resolve(filePath) === resolve(coworkFile))) {
|
|
395
|
-
filePaths.push(coworkFile);
|
|
396
|
-
sources.set(resolve(coworkFile), "cowork");
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
return filePaths.map((filePath) => ({
|
|
400
|
-
filePath,
|
|
401
|
-
env: parseEnvFile(filePath),
|
|
402
|
-
source: sources.get(resolve(filePath)) ?? "nearest"
|
|
403
|
-
}));
|
|
262
|
+
function loadProjectDeeplineEnv(startDir = process.cwd()) {
|
|
263
|
+
const filePath = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
|
|
264
|
+
return filePath ? parseEnvFile(filePath) : {};
|
|
404
265
|
}
|
|
405
266
|
function normalizeBaseUrl(baseUrl) {
|
|
406
267
|
const trimmed = baseUrl.trim().replace(/\/+$/, "");
|
|
@@ -464,35 +325,23 @@ function loadGlobalCliEnv() {
|
|
|
464
325
|
return loadCliEnv(PROD_URL);
|
|
465
326
|
}
|
|
466
327
|
function autoDetectBaseUrl() {
|
|
467
|
-
const
|
|
328
|
+
const projectEnv = loadProjectDeeplineEnv();
|
|
468
329
|
const globalEnv = loadGlobalCliEnv();
|
|
469
|
-
return normalizeBaseUrl(process.env[HOST_URL_ENV] ?? "") ||
|
|
470
|
-
...projectEnvs.map(({ env }) => normalizeBaseUrl(env[HOST_URL_ENV]))
|
|
471
|
-
) || normalizeBaseUrl(globalEnv[HOST_URL_ENV] ?? "") || PROD_URL;
|
|
330
|
+
return normalizeBaseUrl(process.env[HOST_URL_ENV] ?? "") || normalizeBaseUrl(projectEnv[HOST_URL_ENV] ?? "") || normalizeBaseUrl(globalEnv[HOST_URL_ENV] ?? "") || PROD_URL;
|
|
472
331
|
}
|
|
473
332
|
function resolveApiKeyForBaseUrl(baseUrl, explicitApiKey) {
|
|
474
333
|
const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
475
|
-
const
|
|
334
|
+
const projectEnv = loadProjectDeeplineEnv();
|
|
476
335
|
const cliEnv = loadCliEnv(normalizedBaseUrl || baseUrl);
|
|
336
|
+
const projectBaseUrl = normalizeBaseUrl(projectEnv[HOST_URL_ENV] ?? "");
|
|
337
|
+
const projectKeyApplies = projectBaseUrl === normalizedBaseUrl;
|
|
477
338
|
return firstNonEmpty(
|
|
478
339
|
explicitApiKey,
|
|
479
340
|
process.env[API_KEY_ENV],
|
|
480
|
-
|
|
481
|
-
const projectBaseUrl = normalizeBaseUrl(env[HOST_URL_ENV] ?? "");
|
|
482
|
-
return projectBaseUrl === normalizedBaseUrl ? env[API_KEY_ENV] : "";
|
|
483
|
-
}),
|
|
341
|
+
projectKeyApplies ? projectEnv[API_KEY_ENV] : "",
|
|
484
342
|
cliEnv[API_KEY_ENV]
|
|
485
343
|
);
|
|
486
344
|
}
|
|
487
|
-
function getResolvedProjectAuthSource(baseUrl, apiKey, startDir = process.cwd()) {
|
|
488
|
-
const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
489
|
-
const normalizedApiKey = apiKey.trim();
|
|
490
|
-
if (!normalizedBaseUrl || !normalizedApiKey) return null;
|
|
491
|
-
return loadProjectEnvCandidates(startDir).find(({ env }) => {
|
|
492
|
-
const projectBaseUrl = normalizeBaseUrl(env[HOST_URL_ENV] ?? "");
|
|
493
|
-
return projectBaseUrl === normalizedBaseUrl && (env[API_KEY_ENV] ?? "").trim() === normalizedApiKey;
|
|
494
|
-
}) ?? null;
|
|
495
|
-
}
|
|
496
345
|
function resolveConfig(options) {
|
|
497
346
|
const baseUrl = normalizeBaseUrl(
|
|
498
347
|
options?.baseUrl?.trim() || autoDetectBaseUrl()
|
|
@@ -515,69 +364,6 @@ function resolveConfig(options) {
|
|
|
515
364
|
maxRetries: options?.maxRetries ?? DEFAULT_MAX_RETRIES
|
|
516
365
|
};
|
|
517
366
|
}
|
|
518
|
-
function mergeProjectEnvFile(filePath, values) {
|
|
519
|
-
const existing = parseEnvFile(filePath);
|
|
520
|
-
const merged = { ...existing, ...values };
|
|
521
|
-
const dir = dirname(filePath);
|
|
522
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
523
|
-
ensureProjectEnvIsIgnored(dir);
|
|
524
|
-
const allowedKeys = /* @__PURE__ */ new Set([HOST_URL_ENV, API_KEY_ENV]);
|
|
525
|
-
const lines = Object.entries(merged).filter(([key, value]) => allowedKeys.has(key) && value !== "").map(([key, value]) => `${key}=${value}`);
|
|
526
|
-
writeFileSync(filePath, `${lines.join("\n")}
|
|
527
|
-
`, "utf-8");
|
|
528
|
-
}
|
|
529
|
-
function ensureProjectEnvIsIgnored(dir) {
|
|
530
|
-
const gitignorePath = join(dir, ".gitignore");
|
|
531
|
-
const entry = PROJECT_DEEPLINE_ENV_FILE;
|
|
532
|
-
const existing = existsSync(gitignorePath) ? readFileSync(gitignorePath, "utf-8") : "";
|
|
533
|
-
const alreadyIgnored = existing.split(/\r?\n/).map((line) => line.trim()).some((line) => line === entry || line === `/${entry}`);
|
|
534
|
-
if (alreadyIgnored) return;
|
|
535
|
-
const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
|
|
536
|
-
writeFileSync(gitignorePath, `${existing}${prefix}${entry}
|
|
537
|
-
`, "utf-8");
|
|
538
|
-
}
|
|
539
|
-
function saveProjectDeeplineEnvValues(values, startDir = process.cwd()) {
|
|
540
|
-
const target = resolveProjectPinTarget(startDir);
|
|
541
|
-
if (!target.ok) {
|
|
542
|
-
throw new ConfigError(
|
|
543
|
-
`Cowork project folder is ambiguous. Candidate folders: ${target.candidates.join(
|
|
544
|
-
", "
|
|
545
|
-
)}. Set CLAUDE_PROJECT_DIR or cd into the intended project folder before running this command.`
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
const filePath = join(target.dir, PROJECT_DEEPLINE_ENV_FILE);
|
|
549
|
-
mergeProjectEnvFile(filePath, values);
|
|
550
|
-
return [filePath];
|
|
551
|
-
}
|
|
552
|
-
function resolveProjectPinTarget(startDir = process.cwd()) {
|
|
553
|
-
const nearestFile = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
|
|
554
|
-
if (nearestFile && !isInIgnoredCoworkMount(nearestFile)) {
|
|
555
|
-
return { ok: true, dir: dirname(nearestFile), source: "nearest" };
|
|
556
|
-
}
|
|
557
|
-
const coworkCandidates = listCoworkWorkspaceDirCandidates();
|
|
558
|
-
if (coworkCandidates.length === 1) {
|
|
559
|
-
return { ok: true, dir: coworkCandidates[0], source: "cowork" };
|
|
560
|
-
}
|
|
561
|
-
if (coworkCandidates.length > 1) {
|
|
562
|
-
const resolvedStartDir = canonicalPath(startDir);
|
|
563
|
-
const cwdCandidate = coworkCandidates.find((candidate) => {
|
|
564
|
-
const resolvedCandidate = canonicalPath(candidate);
|
|
565
|
-
return resolvedStartDir === resolvedCandidate || resolvedStartDir.startsWith(`${resolvedCandidate}/`);
|
|
566
|
-
});
|
|
567
|
-
if (cwdCandidate) {
|
|
568
|
-
return { ok: true, dir: cwdCandidate, source: "cowork" };
|
|
569
|
-
}
|
|
570
|
-
return {
|
|
571
|
-
ok: false,
|
|
572
|
-
reason: "ambiguous_cowork_project",
|
|
573
|
-
candidates: coworkCandidates
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
return { ok: true, dir: resolve(startDir), source: "cwd" };
|
|
577
|
-
}
|
|
578
|
-
function getActiveProjectAuthSource(startDir = process.cwd()) {
|
|
579
|
-
return loadProjectEnvCandidates(startDir)[0] ?? null;
|
|
580
|
-
}
|
|
581
367
|
|
|
582
368
|
// src/http.ts
|
|
583
369
|
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
@@ -604,10 +390,10 @@ var SDK_RELEASE = {
|
|
|
604
390
|
// 0.1.108 ships explicit dataset column/tool recompute policy and removes
|
|
605
391
|
// the SDK enrich generator's one-second stale policy.
|
|
606
392
|
// 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
|
|
607
|
-
version: "0.1.
|
|
393
|
+
version: "0.1.139",
|
|
608
394
|
apiContract: "2026-06-dataset-column-cell-stale-hard-cutover",
|
|
609
395
|
supportPolicy: {
|
|
610
|
-
latest: "0.1.
|
|
396
|
+
latest: "0.1.139",
|
|
611
397
|
minimumSupported: "0.1.53",
|
|
612
398
|
deprecatedBelow: "0.1.53",
|
|
613
399
|
commandMinimumSupported: [
|
|
@@ -698,7 +484,7 @@ function normalizeAgentRuntime(value) {
|
|
|
698
484
|
if (explicit === "gemini_cli") return "gemini";
|
|
699
485
|
return EXPLICIT_AGENT_RUNTIMES.has(explicit) ? explicit : null;
|
|
700
486
|
}
|
|
701
|
-
function
|
|
487
|
+
function isCoworkLikeSandbox() {
|
|
702
488
|
const pluginMode = truthyEnv("DEEPLINE_PLUGIN_MODE");
|
|
703
489
|
const claudeRemote = truthyEnv("CLAUDE_CODE_REMOTE");
|
|
704
490
|
const projectDir = Boolean(process.env.CLAUDE_PROJECT_DIR?.trim());
|
|
@@ -711,7 +497,7 @@ function detectAgentRuntime(options = {}) {
|
|
|
711
497
|
const explicit = normalizeAgentRuntime(process.env.DEEPLINE_AGENT_RUNTIME);
|
|
712
498
|
if (explicit) return explicit;
|
|
713
499
|
if (process.env.CODEX_THREAD_ID?.trim()) return "codex";
|
|
714
|
-
if (options.detectCowork !== false &&
|
|
500
|
+
if (options.detectCowork !== false && isCoworkLikeSandbox()) {
|
|
715
501
|
return "claude_cowork";
|
|
716
502
|
}
|
|
717
503
|
if (process.env.CLAUDECODE?.trim() === "1") return "claude_code";
|
|
@@ -1177,7 +963,7 @@ function sleep(ms) {
|
|
|
1177
963
|
return new Promise((resolve13) => setTimeout(resolve13, ms));
|
|
1178
964
|
}
|
|
1179
965
|
function withCoworkNetworkHint(message) {
|
|
1180
|
-
if (!
|
|
966
|
+
if (!isCoworkLikeSandbox() || message.includes(COWORK_NETWORK_HINT)) {
|
|
1181
967
|
return message;
|
|
1182
968
|
}
|
|
1183
969
|
return `${message}
|
|
@@ -7197,9 +6983,9 @@ import { createHash as createHash2 } from "crypto";
|
|
|
7197
6983
|
import {
|
|
7198
6984
|
existsSync as existsSync6,
|
|
7199
6985
|
readFileSync as readFileSync6,
|
|
7200
|
-
readdirSync
|
|
7201
|
-
realpathSync
|
|
7202
|
-
statSync as
|
|
6986
|
+
readdirSync,
|
|
6987
|
+
realpathSync,
|
|
6988
|
+
statSync as statSync2,
|
|
7203
6989
|
writeFileSync as writeFileSync8
|
|
7204
6990
|
} from "fs";
|
|
7205
6991
|
import { basename, dirname as dirname6, join as join5, resolve as resolve7 } from "path";
|
|
@@ -7210,7 +6996,7 @@ import {
|
|
|
7210
6996
|
closeSync,
|
|
7211
6997
|
openSync,
|
|
7212
6998
|
readSync,
|
|
7213
|
-
statSync
|
|
6999
|
+
statSync,
|
|
7214
7000
|
writeFileSync as writeFileSync7
|
|
7215
7001
|
} from "fs";
|
|
7216
7002
|
import { isAbsolute, relative, resolve as resolve6 } from "path";
|
|
@@ -7643,7 +7429,7 @@ function inferCsvColumnSpecs(headers, rows) {
|
|
|
7643
7429
|
}
|
|
7644
7430
|
function readCsvSample(csvPath) {
|
|
7645
7431
|
const resolvedPath = resolve6(csvPath);
|
|
7646
|
-
const size =
|
|
7432
|
+
const size = statSync(resolvedPath).size;
|
|
7647
7433
|
const fd = openSync(resolvedPath, "r");
|
|
7648
7434
|
const byteLength = Math.min(size, CSV_HEADER_SAMPLE_BYTES);
|
|
7649
7435
|
const buffer = Buffer.alloc(byteLength);
|
|
@@ -9679,7 +9465,7 @@ function preflightLocalFileInputs(runtimeInput) {
|
|
|
9679
9465
|
}
|
|
9680
9466
|
let stat2;
|
|
9681
9467
|
try {
|
|
9682
|
-
stat2 =
|
|
9468
|
+
stat2 = statSync2(absolutePath);
|
|
9683
9469
|
} catch (error) {
|
|
9684
9470
|
throw new DeeplineError(
|
|
9685
9471
|
`Input ${ref.inputPath} references a local file that is not readable: ${ref.value} (${error instanceof Error ? error.message : String(error)}). No run was created.`,
|
|
@@ -9831,7 +9617,7 @@ function stageFile(logicalPath, absolutePath) {
|
|
|
9831
9617
|
}
|
|
9832
9618
|
function normalizePlayPath(filePath) {
|
|
9833
9619
|
try {
|
|
9834
|
-
return
|
|
9620
|
+
return realpathSync.native(resolve7(filePath));
|
|
9835
9621
|
} catch {
|
|
9836
9622
|
return resolve7(filePath);
|
|
9837
9623
|
}
|
|
@@ -13093,7 +12879,7 @@ async function handlePlayRun(args) {
|
|
|
13093
12879
|
if (existsSync6(dir)) {
|
|
13094
12880
|
const base = basename(resolved);
|
|
13095
12881
|
try {
|
|
13096
|
-
const siblings =
|
|
12882
|
+
const siblings = readdirSync(dir).filter(
|
|
13097
12883
|
(f) => f.includes(base.replace(/\.(play\.)?ts$/, "")) || f.endsWith(".play.ts")
|
|
13098
12884
|
);
|
|
13099
12885
|
if (siblings.length > 0) {
|
|
@@ -15277,6 +15063,7 @@ function renderPlayStep(command, options) {
|
|
|
15277
15063
|
` const templateRow = __dlPrepareEnrichRow(row, [${alias}]);`,
|
|
15278
15064
|
...runIfLines,
|
|
15279
15065
|
` const payload = __dlTemplate(${payload}, templateRow) as Record<string, unknown>;`,
|
|
15066
|
+
` if (__dlShouldSkipBlankPlayPayload(payload)) return null;`,
|
|
15280
15067
|
` let result: unknown;`,
|
|
15281
15068
|
` try {`,
|
|
15282
15069
|
` result = await stepCtx.runPlay(${callId}, ${playRef}, payload, {`,
|
|
@@ -16210,6 +15997,17 @@ function helperSource() {
|
|
|
16210
15997
|
` return false;`,
|
|
16211
15998
|
`}`,
|
|
16212
15999
|
``,
|
|
16000
|
+
`function __dlPayloadHasMeaningfulValue(value: unknown): boolean {`,
|
|
16001
|
+
` if (__dlBlankPayloadValue(value)) return false;`,
|
|
16002
|
+
` if (Array.isArray(value)) return value.some(__dlPayloadHasMeaningfulValue);`,
|
|
16003
|
+
` if (value && typeof value === 'object') return Object.values(value as Record<string, unknown>).some(__dlPayloadHasMeaningfulValue);`,
|
|
16004
|
+
` return true;`,
|
|
16005
|
+
`}`,
|
|
16006
|
+
``,
|
|
16007
|
+
`function __dlShouldSkipBlankPlayPayload(payload: Record<string, unknown>): boolean {`,
|
|
16008
|
+
` return Object.keys(payload).length > 0 && !__dlPayloadHasMeaningfulValue(payload);`,
|
|
16009
|
+
`}`,
|
|
16010
|
+
``,
|
|
16213
16011
|
`function __dlAliasCandidates(alias: string): string[] {`,
|
|
16214
16012
|
` const aliases: string[] = [];`,
|
|
16215
16013
|
` for (const candidate of [alias, alias.replace(/-/g, '_'), alias.replace(/_/g, '-')]) {`,
|
|
@@ -17886,9 +17684,9 @@ Examples:
|
|
|
17886
17684
|
import {
|
|
17887
17685
|
existsSync as existsSync7,
|
|
17888
17686
|
mkdirSync as mkdirSync5,
|
|
17889
|
-
readdirSync as
|
|
17687
|
+
readdirSync as readdirSync2,
|
|
17890
17688
|
readFileSync as readFileSync7,
|
|
17891
|
-
statSync as
|
|
17689
|
+
statSync as statSync3,
|
|
17892
17690
|
writeFileSync as writeFileSync9
|
|
17893
17691
|
} from "fs";
|
|
17894
17692
|
import { homedir as homedir7, platform } from "os";
|
|
@@ -17973,7 +17771,7 @@ function listSessionFiles(agent) {
|
|
|
17973
17771
|
}
|
|
17974
17772
|
function readDirectoryNames(dir) {
|
|
17975
17773
|
try {
|
|
17976
|
-
return
|
|
17774
|
+
return readdirSync2(dir);
|
|
17977
17775
|
} catch {
|
|
17978
17776
|
return [];
|
|
17979
17777
|
}
|
|
@@ -17984,7 +17782,7 @@ function listJsonlFilesRecursive(root, maxDepth) {
|
|
|
17984
17782
|
if (depth > maxDepth) return;
|
|
17985
17783
|
let entries;
|
|
17986
17784
|
try {
|
|
17987
|
-
entries =
|
|
17785
|
+
entries = readdirSync2(dir, { withFileTypes: true });
|
|
17988
17786
|
} catch {
|
|
17989
17787
|
return;
|
|
17990
17788
|
}
|
|
@@ -18002,7 +17800,7 @@ function listJsonlFilesRecursive(root, maxDepth) {
|
|
|
18002
17800
|
}
|
|
18003
17801
|
function statIfReadable(filePath) {
|
|
18004
17802
|
try {
|
|
18005
|
-
return
|
|
17803
|
+
return statSync3(filePath);
|
|
18006
17804
|
} catch {
|
|
18007
17805
|
return null;
|
|
18008
17806
|
}
|
|
@@ -18695,15 +18493,6 @@ Examples:
|
|
|
18695
18493
|
async function fetchOrganizations(http, apiKey) {
|
|
18696
18494
|
return http.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
|
|
18697
18495
|
}
|
|
18698
|
-
function normalizeAuthScope(value) {
|
|
18699
|
-
if (!value) return "auto";
|
|
18700
|
-
if (value === "auto" || value === "folder" || value === "global") {
|
|
18701
|
-
return value;
|
|
18702
|
-
}
|
|
18703
|
-
throw new Error(
|
|
18704
|
-
`Invalid --auth-scope "${value}". Expected one of: auto, folder, global.`
|
|
18705
|
-
);
|
|
18706
|
-
}
|
|
18707
18496
|
function orgListLines(orgs) {
|
|
18708
18497
|
return orgs.map((org, index) => {
|
|
18709
18498
|
const current = org.is_current ? " (current)" : "";
|
|
@@ -18711,90 +18500,6 @@ function orgListLines(orgs) {
|
|
|
18711
18500
|
return `${index + 1}. ${org.name}${role}${current}`;
|
|
18712
18501
|
});
|
|
18713
18502
|
}
|
|
18714
|
-
function redactApiKey(value) {
|
|
18715
|
-
if (!value) return null;
|
|
18716
|
-
if (value.length <= 10) return `${value.slice(0, 3)}...`;
|
|
18717
|
-
return `${value.slice(0, 8)}...${value.slice(-4)}`;
|
|
18718
|
-
}
|
|
18719
|
-
function processEnvValue(name) {
|
|
18720
|
-
return process.env[name]?.trim() ?? "";
|
|
18721
|
-
}
|
|
18722
|
-
function resolveOrgSwitchAuthTarget(scope, config) {
|
|
18723
|
-
const activeProject = getResolvedProjectAuthSource(
|
|
18724
|
-
config.baseUrl,
|
|
18725
|
-
config.apiKey
|
|
18726
|
-
);
|
|
18727
|
-
const folderTarget = resolveProjectPinTarget();
|
|
18728
|
-
const globalOverrideWarning = activeProject && scope === "global" ? [
|
|
18729
|
-
`Folder auth in ${activeProject.filePath} overrides global auth for commands run here.`
|
|
18730
|
-
] : [];
|
|
18731
|
-
if (scope === "folder") {
|
|
18732
|
-
if (!folderTarget.ok) {
|
|
18733
|
-
throw new Error(
|
|
18734
|
-
`Cowork project folder is ambiguous. Candidate folders: ${folderTarget.candidates.join(
|
|
18735
|
-
", "
|
|
18736
|
-
)}. Set CLAUDE_PROJECT_DIR or cd into the intended project folder before running this command.`
|
|
18737
|
-
);
|
|
18738
|
-
}
|
|
18739
|
-
return {
|
|
18740
|
-
kind: "folder",
|
|
18741
|
-
requested_scope: scope,
|
|
18742
|
-
effective_scope: "folder",
|
|
18743
|
-
reason: "explicit_folder",
|
|
18744
|
-
source: folderTarget.source,
|
|
18745
|
-
warnings: []
|
|
18746
|
-
};
|
|
18747
|
-
}
|
|
18748
|
-
if (scope === "global") {
|
|
18749
|
-
return {
|
|
18750
|
-
kind: "global",
|
|
18751
|
-
requested_scope: scope,
|
|
18752
|
-
effective_scope: "global",
|
|
18753
|
-
reason: "explicit_global",
|
|
18754
|
-
warnings: globalOverrideWarning
|
|
18755
|
-
};
|
|
18756
|
-
}
|
|
18757
|
-
if (activeProject) {
|
|
18758
|
-
return {
|
|
18759
|
-
kind: "folder",
|
|
18760
|
-
requested_scope: scope,
|
|
18761
|
-
effective_scope: "folder",
|
|
18762
|
-
reason: "existing_folder_auth",
|
|
18763
|
-
source: activeProject.source,
|
|
18764
|
-
warnings: []
|
|
18765
|
-
};
|
|
18766
|
-
}
|
|
18767
|
-
if (folderTarget.ok && folderTarget.source === "cowork") {
|
|
18768
|
-
return {
|
|
18769
|
-
kind: "folder",
|
|
18770
|
-
requested_scope: scope,
|
|
18771
|
-
effective_scope: "folder",
|
|
18772
|
-
reason: "detected_cowork_project",
|
|
18773
|
-
source: "cowork",
|
|
18774
|
-
warnings: []
|
|
18775
|
-
};
|
|
18776
|
-
}
|
|
18777
|
-
if (!folderTarget.ok) {
|
|
18778
|
-
return {
|
|
18779
|
-
kind: "global",
|
|
18780
|
-
requested_scope: scope,
|
|
18781
|
-
effective_scope: "global",
|
|
18782
|
-
reason: "ambiguous_cowork_fell_back_global",
|
|
18783
|
-
warnings: [
|
|
18784
|
-
`Cowork project folder is ambiguous, so global auth was updated. Candidate folders: ${folderTarget.candidates.join(
|
|
18785
|
-
", "
|
|
18786
|
-
)}. Set CLAUDE_PROJECT_DIR or cd into the intended project folder to update folder auth.`
|
|
18787
|
-
]
|
|
18788
|
-
};
|
|
18789
|
-
}
|
|
18790
|
-
return {
|
|
18791
|
-
kind: "global",
|
|
18792
|
-
requested_scope: scope,
|
|
18793
|
-
effective_scope: "global",
|
|
18794
|
-
reason: "default_global",
|
|
18795
|
-
warnings: []
|
|
18796
|
-
};
|
|
18797
|
-
}
|
|
18798
18503
|
async function handleOrgList(options) {
|
|
18799
18504
|
const config = resolveConfig();
|
|
18800
18505
|
const http = new HttpClient(config);
|
|
@@ -18814,89 +18519,7 @@ async function handleOrgList(options) {
|
|
|
18814
18519
|
{ json: options.json }
|
|
18815
18520
|
);
|
|
18816
18521
|
}
|
|
18817
|
-
async function handleOrgStatus(options) {
|
|
18818
|
-
const config = resolveConfig();
|
|
18819
|
-
const http = new HttpClient(config);
|
|
18820
|
-
const payload = await fetchOrganizations(http, config.apiKey);
|
|
18821
|
-
const current = payload.organizations.find((org) => org.is_current) ?? payload.organizations.find((org) => org.org_id === payload.current_org_id) ?? null;
|
|
18822
|
-
const projectCandidate = getActiveProjectAuthSource();
|
|
18823
|
-
const activeProject = getResolvedProjectAuthSource(
|
|
18824
|
-
config.baseUrl,
|
|
18825
|
-
config.apiKey
|
|
18826
|
-
);
|
|
18827
|
-
const folderTarget = resolveProjectPinTarget();
|
|
18828
|
-
const hostPath = hostEnvFilePath(config.baseUrl);
|
|
18829
|
-
const envApiKey = processEnvValue(API_KEY_ENV);
|
|
18830
|
-
const envHostUrl = processEnvValue(HOST_URL_ENV);
|
|
18831
|
-
const authSource = envApiKey ? {
|
|
18832
|
-
scope: "env",
|
|
18833
|
-
source: "process",
|
|
18834
|
-
path: null,
|
|
18835
|
-
api_key: redactApiKey(envApiKey),
|
|
18836
|
-
host: envHostUrl || null,
|
|
18837
|
-
overrides_global: true,
|
|
18838
|
-
overrides_folder: Boolean(projectCandidate)
|
|
18839
|
-
} : activeProject ? {
|
|
18840
|
-
scope: "folder",
|
|
18841
|
-
source: activeProject.source,
|
|
18842
|
-
path: activeProject.filePath,
|
|
18843
|
-
api_key: redactApiKey(activeProject.env.DEEPLINE_API_KEY),
|
|
18844
|
-
overrides_global: true
|
|
18845
|
-
} : {
|
|
18846
|
-
scope: "global",
|
|
18847
|
-
source: "host",
|
|
18848
|
-
path: hostPath,
|
|
18849
|
-
api_key: redactApiKey(config.apiKey),
|
|
18850
|
-
overrides_global: false
|
|
18851
|
-
};
|
|
18852
|
-
const folderTargetPayload = folderTarget.ok ? {
|
|
18853
|
-
ok: true,
|
|
18854
|
-
source: folderTarget.source,
|
|
18855
|
-
dir: folderTarget.dir,
|
|
18856
|
-
env_path: `${folderTarget.dir}/.env.deepline`
|
|
18857
|
-
} : {
|
|
18858
|
-
ok: false,
|
|
18859
|
-
reason: folderTarget.reason,
|
|
18860
|
-
candidates: folderTarget.candidates
|
|
18861
|
-
};
|
|
18862
|
-
const lines = [
|
|
18863
|
-
`Organization: ${current?.name ?? "(unknown)"}`,
|
|
18864
|
-
`Host: ${config.baseUrl}`,
|
|
18865
|
-
`Auth scope: ${authSource.scope}`
|
|
18866
|
-
];
|
|
18867
|
-
if (authSource.path) {
|
|
18868
|
-
lines.push(`Auth file: ${authSource.path}`);
|
|
18869
|
-
} else {
|
|
18870
|
-
lines.push(`Auth source: ${API_KEY_ENV} process environment`);
|
|
18871
|
-
}
|
|
18872
|
-
if (envApiKey) {
|
|
18873
|
-
lines.push(`${API_KEY_ENV} overrides saved auth for this process.`);
|
|
18874
|
-
} else if (activeProject) {
|
|
18875
|
-
lines.push("Global auth is overridden in this folder.");
|
|
18876
|
-
}
|
|
18877
|
-
printCommandEnvelope(
|
|
18878
|
-
{
|
|
18879
|
-
ok: true,
|
|
18880
|
-
host: config.baseUrl,
|
|
18881
|
-
organization: current,
|
|
18882
|
-
current_org_id: payload.current_org_id,
|
|
18883
|
-
auth_source: authSource,
|
|
18884
|
-
host_env_path: hostPath,
|
|
18885
|
-
folder_target: folderTargetPayload,
|
|
18886
|
-
next: {
|
|
18887
|
-
set_auto: "deepline org set <org>",
|
|
18888
|
-
set_folder: "deepline org set <org> --auth-scope folder",
|
|
18889
|
-
set_global: "deepline org set <org> --auth-scope global"
|
|
18890
|
-
},
|
|
18891
|
-
render: {
|
|
18892
|
-
sections: [{ title: "org status", lines }]
|
|
18893
|
-
}
|
|
18894
|
-
},
|
|
18895
|
-
{ json: options.json }
|
|
18896
|
-
);
|
|
18897
|
-
}
|
|
18898
18522
|
async function handleOrgSwitch(selection, options) {
|
|
18899
|
-
const authScope = normalizeAuthScope(options.authScope);
|
|
18900
18523
|
const config = resolveConfig();
|
|
18901
18524
|
const http = new HttpClient(config);
|
|
18902
18525
|
const payload = await fetchOrganizations(http, config.apiKey);
|
|
@@ -18904,10 +18527,7 @@ async function handleOrgSwitch(selection, options) {
|
|
|
18904
18527
|
printCommandEnvelope(
|
|
18905
18528
|
{
|
|
18906
18529
|
...payload,
|
|
18907
|
-
next: {
|
|
18908
|
-
deprecated_command: options.deprecatedSwitch ? "org switch" : null,
|
|
18909
|
-
replacement_command: options.deprecatedSwitch ? "deepline org set" : null,
|
|
18910
|
-
warnings: options.deprecatedSwitch ? ["org switch is deprecated; use org set."] : [],
|
|
18530
|
+
next: { switch: "deepline org switch <number>" },
|
|
18911
18531
|
render: {
|
|
18912
18532
|
sections: [
|
|
18913
18533
|
{
|
|
@@ -18915,7 +18535,7 @@ async function handleOrgSwitch(selection, options) {
|
|
|
18915
18535
|
lines: orgListLines(payload.organizations)
|
|
18916
18536
|
}
|
|
18917
18537
|
],
|
|
18918
|
-
actions: [{ label: "Run", command: "deepline org
|
|
18538
|
+
actions: [{ label: "Run", command: "deepline org switch <number>" }]
|
|
18919
18539
|
}
|
|
18920
18540
|
},
|
|
18921
18541
|
{ json: options.json }
|
|
@@ -18938,56 +18558,16 @@ async function handleOrgSwitch(selection, options) {
|
|
|
18938
18558
|
if (!target) {
|
|
18939
18559
|
throw new Error("Could not resolve the selected organization.");
|
|
18940
18560
|
}
|
|
18941
|
-
const authTarget = resolveOrgSwitchAuthTarget(authScope, config);
|
|
18942
18561
|
if (target.is_current) {
|
|
18943
|
-
let project_env_paths2 = [];
|
|
18944
|
-
if (authTarget.kind === "folder") {
|
|
18945
|
-
project_env_paths2 = saveProjectDeeplineEnvValues({
|
|
18946
|
-
DEEPLINE_HOST_URL: config.baseUrl,
|
|
18947
|
-
DEEPLINE_API_KEY: config.apiKey
|
|
18948
|
-
});
|
|
18949
|
-
} else {
|
|
18950
|
-
saveHostEnvValues(config.baseUrl, {
|
|
18951
|
-
DEEPLINE_HOST_URL: config.baseUrl,
|
|
18952
|
-
DEEPLINE_API_KEY: config.apiKey
|
|
18953
|
-
});
|
|
18954
|
-
}
|
|
18955
|
-
const renderLines2 = [`Already on ${target.name}.`];
|
|
18956
|
-
for (const projectPath of project_env_paths2) {
|
|
18957
|
-
renderLines2.push(`Saved folder auth in ${projectPath}`);
|
|
18958
|
-
}
|
|
18959
|
-
if (authTarget.kind === "global") {
|
|
18960
|
-
renderLines2.push(`Saved global auth in ${hostEnvFilePath(config.baseUrl)}`);
|
|
18961
|
-
}
|
|
18962
|
-
renderLines2.push(
|
|
18963
|
-
`Scope: ${authTarget.requested_scope} -> ${authTarget.effective_scope} (${authTarget.reason})`
|
|
18964
|
-
);
|
|
18965
|
-
if (options.deprecatedSwitch) {
|
|
18966
|
-
renderLines2.push("Warning: org switch is deprecated; use org set.");
|
|
18967
|
-
}
|
|
18968
|
-
for (const warning of authTarget.warnings) {
|
|
18969
|
-
renderLines2.push(`Warning: ${warning}`);
|
|
18970
|
-
}
|
|
18971
|
-
const warnings2 = [
|
|
18972
|
-
...options.deprecatedSwitch ? ["org switch is deprecated; use org set."] : [],
|
|
18973
|
-
...authTarget.warnings
|
|
18974
|
-
];
|
|
18975
18562
|
printCommandEnvelope(
|
|
18976
18563
|
{
|
|
18977
18564
|
ok: true,
|
|
18978
18565
|
unchanged: true,
|
|
18979
18566
|
organization: target,
|
|
18980
|
-
requested_auth_scope: authTarget.requested_scope,
|
|
18981
|
-
effective_auth_scope: authTarget.effective_scope,
|
|
18982
|
-
auth_scope_reason: authTarget.reason,
|
|
18983
|
-
auth_scope: authTarget.effective_scope,
|
|
18984
|
-
host_env_path: authTarget.kind === "global" ? hostEnvFilePath(config.baseUrl) : null,
|
|
18985
|
-
project_env_paths: project_env_paths2,
|
|
18986
|
-
deprecated_command: options.deprecatedSwitch ? "org switch" : null,
|
|
18987
|
-
replacement_command: options.deprecatedSwitch ? "deepline org set" : null,
|
|
18988
|
-
warnings: warnings2,
|
|
18989
18567
|
render: {
|
|
18990
|
-
sections: [
|
|
18568
|
+
sections: [
|
|
18569
|
+
{ title: "org switch", lines: [`Already on ${target.name}.`] }
|
|
18570
|
+
]
|
|
18991
18571
|
}
|
|
18992
18572
|
},
|
|
18993
18573
|
{ json: options.json }
|
|
@@ -18998,61 +18578,26 @@ async function handleOrgSwitch(selection, options) {
|
|
|
18998
18578
|
api_key: config.apiKey,
|
|
18999
18579
|
org_id: target.org_id
|
|
19000
18580
|
});
|
|
19001
|
-
|
|
19002
|
-
|
|
19003
|
-
|
|
19004
|
-
|
|
19005
|
-
|
|
19006
|
-
});
|
|
19007
|
-
} else {
|
|
19008
|
-
saveHostEnvValues(config.baseUrl, {
|
|
19009
|
-
DEEPLINE_HOST_URL: config.baseUrl,
|
|
19010
|
-
DEEPLINE_API_KEY: switched.api_key,
|
|
19011
|
-
DEEPLINE_ACTIVE_ORG_ID: switched.org_id,
|
|
19012
|
-
DEEPLINE_ACTIVE_ORG_NAME: switched.org_name
|
|
19013
|
-
});
|
|
19014
|
-
}
|
|
18581
|
+
saveHostEnvValues(config.baseUrl, {
|
|
18582
|
+
DEEPLINE_API_KEY: switched.api_key,
|
|
18583
|
+
DEEPLINE_ACTIVE_ORG_ID: switched.org_id,
|
|
18584
|
+
DEEPLINE_ACTIVE_ORG_NAME: switched.org_name
|
|
18585
|
+
});
|
|
19015
18586
|
const { api_key: _apiKey, ...publicSwitched } = switched;
|
|
19016
|
-
const renderLines = [`Switched to ${switched.org_name}.`];
|
|
19017
|
-
if (authTarget.kind === "folder") {
|
|
19018
|
-
for (const projectPath of project_env_paths) {
|
|
19019
|
-
renderLines.push(`Saved folder auth in ${projectPath}`);
|
|
19020
|
-
}
|
|
19021
|
-
} else {
|
|
19022
|
-
renderLines.push(`Saved global auth in ${hostEnvFilePath(config.baseUrl)}`);
|
|
19023
|
-
}
|
|
19024
|
-
renderLines.push(
|
|
19025
|
-
`Scope: ${authTarget.requested_scope} -> ${authTarget.effective_scope} (${authTarget.reason})`
|
|
19026
|
-
);
|
|
19027
|
-
if (options.deprecatedSwitch) {
|
|
19028
|
-
renderLines.push("Warning: org switch is deprecated; use org set.");
|
|
19029
|
-
}
|
|
19030
|
-
for (const warning of authTarget.warnings) {
|
|
19031
|
-
renderLines.push(`Warning: ${warning}`);
|
|
19032
|
-
}
|
|
19033
|
-
const warnings = [
|
|
19034
|
-
...options.deprecatedSwitch ? ["org switch is deprecated; use org set."] : [],
|
|
19035
|
-
...authTarget.warnings
|
|
19036
|
-
];
|
|
19037
18587
|
printCommandEnvelope(
|
|
19038
18588
|
{
|
|
19039
18589
|
ok: true,
|
|
19040
|
-
host_env_path:
|
|
19041
|
-
project_env_paths,
|
|
18590
|
+
host_env_path: hostEnvFilePath(config.baseUrl),
|
|
19042
18591
|
...publicSwitched,
|
|
19043
18592
|
api_key_saved: true,
|
|
19044
|
-
requested_auth_scope: authTarget.requested_scope,
|
|
19045
|
-
effective_auth_scope: authTarget.effective_scope,
|
|
19046
|
-
auth_scope_reason: authTarget.reason,
|
|
19047
|
-
auth_scope: authTarget.effective_scope,
|
|
19048
|
-
deprecated_command: options.deprecatedSwitch ? "org switch" : null,
|
|
19049
|
-
replacement_command: options.deprecatedSwitch ? "deepline org set" : null,
|
|
19050
|
-
warnings,
|
|
19051
18593
|
render: {
|
|
19052
18594
|
sections: [
|
|
19053
18595
|
{
|
|
19054
|
-
title: "org
|
|
19055
|
-
lines:
|
|
18596
|
+
title: "org switch",
|
|
18597
|
+
lines: [
|
|
18598
|
+
`Switched to ${switched.org_name}.`,
|
|
18599
|
+
`Saved host auth in ${hostEnvFilePath(config.baseUrl)}`
|
|
18600
|
+
]
|
|
19056
18601
|
}
|
|
19057
18602
|
]
|
|
19058
18603
|
}
|
|
@@ -19068,7 +18613,6 @@ async function handleOrgCreate(name, options) {
|
|
|
19068
18613
|
name
|
|
19069
18614
|
});
|
|
19070
18615
|
saveHostEnvValues(config.baseUrl, {
|
|
19071
|
-
DEEPLINE_HOST_URL: config.baseUrl,
|
|
19072
18616
|
DEEPLINE_API_KEY: created.api_key,
|
|
19073
18617
|
DEEPLINE_ACTIVE_ORG_ID: created.org_id,
|
|
19074
18618
|
DEEPLINE_ACTIVE_ORG_NAME: created.org_name
|
|
@@ -19098,20 +18642,18 @@ async function handleOrgCreate(name, options) {
|
|
|
19098
18642
|
);
|
|
19099
18643
|
}
|
|
19100
18644
|
function registerOrgCommands(program) {
|
|
19101
|
-
const org = program.command("org").description("List, create, and
|
|
18645
|
+
const org = program.command("org").description("List, create, and switch organizations.").addHelpText(
|
|
19102
18646
|
"after",
|
|
19103
18647
|
`
|
|
19104
18648
|
Notes:
|
|
19105
|
-
Organizations are workspaces.
|
|
19106
|
-
|
|
18649
|
+
Organizations are workspaces. Switching organizations mutates the saved host
|
|
18650
|
+
auth file so later CLI commands target the selected workspace.
|
|
19107
18651
|
|
|
19108
18652
|
Examples:
|
|
19109
18653
|
deepline org list --json
|
|
19110
|
-
deepline org status --json
|
|
19111
18654
|
deepline org create Acme --json
|
|
19112
|
-
deepline org
|
|
19113
|
-
deepline org
|
|
19114
|
-
deepline org set --org-id org_123 --json
|
|
18655
|
+
deepline org switch 2
|
|
18656
|
+
deepline org switch --org-id org_123 --json
|
|
19115
18657
|
`
|
|
19116
18658
|
);
|
|
19117
18659
|
org.command("list").description("List your organizations.").addHelpText(
|
|
@@ -19138,65 +18680,21 @@ Examples:
|
|
|
19138
18680
|
deepline org create "Acme Sales" --json
|
|
19139
18681
|
`
|
|
19140
18682
|
).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleOrgCreate);
|
|
19141
|
-
org.command("
|
|
18683
|
+
org.command("switch [selection]").description(
|
|
18684
|
+
"Switch to another organization and save the new API key in the host auth file."
|
|
18685
|
+
).addHelpText(
|
|
19142
18686
|
"after",
|
|
19143
18687
|
`
|
|
19144
18688
|
Notes:
|
|
19145
|
-
|
|
19146
|
-
|
|
19147
|
-
|
|
19148
|
-
Examples:
|
|
19149
|
-
deepline org status
|
|
19150
|
-
deepline org status --json
|
|
19151
|
-
`
|
|
19152
|
-
).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleOrgStatus);
|
|
19153
|
-
const addOrgSetOptions = (command) => command.option("--org-id <id>", "Set using an explicit organization id").option(
|
|
19154
|
-
"--auth-scope <scope>",
|
|
19155
|
-
"Where to save auth: auto, folder, or global",
|
|
19156
|
-
"auto"
|
|
19157
|
-
).option("--json", "Emit JSON output. Also automatic when stdout is piped");
|
|
19158
|
-
addOrgSetOptions(
|
|
19159
|
-
org.command("set [selection]").description("Set the organization for the selected auth scope.").addHelpText(
|
|
19160
|
-
"after",
|
|
19161
|
-
`
|
|
19162
|
-
Notes:
|
|
19163
|
-
Selection can be a list number, exact organization name, or organization id.
|
|
19164
|
-
Without a selection, prints choices. The default --auth-scope auto updates
|
|
19165
|
-
the folder auth file when one controls this command, updates the detected
|
|
19166
|
-
Cowork project folder when present, and otherwise updates global host auth.
|
|
19167
|
-
|
|
19168
|
-
Examples:
|
|
19169
|
-
deepline org set
|
|
19170
|
-
deepline org set 2
|
|
19171
|
-
deepline org set 2 --auth-scope folder
|
|
19172
|
-
deepline org set 2 --auth-scope global
|
|
19173
|
-
deepline org set --org-id org_123 --json
|
|
19174
|
-
`
|
|
19175
|
-
)
|
|
19176
|
-
).action(handleOrgSwitch);
|
|
19177
|
-
addOrgSetOptions(
|
|
19178
|
-
org.command("switch [selection]").description(
|
|
19179
|
-
"Deprecated alias for org set. Set the organization for the selected auth scope."
|
|
19180
|
-
).addHelpText(
|
|
19181
|
-
"after",
|
|
19182
|
-
`
|
|
19183
|
-
Notes:
|
|
19184
|
-
Deprecated alias. Use deepline org set instead. The default --auth-scope auto
|
|
19185
|
-
updates the folder auth file when one controls this command, updates the
|
|
19186
|
-
detected Cowork project folder when present, and otherwise updates global host
|
|
19187
|
-
auth.
|
|
18689
|
+
Mutates the saved host auth file. Selection can be a list number, exact
|
|
18690
|
+
organization name, or organization id. Without a selection, prints choices.
|
|
19188
18691
|
|
|
19189
18692
|
Examples:
|
|
19190
18693
|
deepline org switch
|
|
19191
18694
|
deepline org switch 2
|
|
19192
|
-
deepline org switch 2 --auth-scope folder
|
|
19193
|
-
deepline org switch 2 --auth-scope global
|
|
19194
18695
|
deepline org switch --org-id org_123 --json
|
|
19195
18696
|
`
|
|
19196
|
-
|
|
19197
|
-
).action(
|
|
19198
|
-
(selection, options) => handleOrgSwitch(selection, { ...options, deprecatedSwitch: true })
|
|
19199
|
-
);
|
|
18697
|
+
).option("--org-id <id>", "Switch using an explicit organization id").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(handleOrgSwitch);
|
|
19200
18698
|
}
|
|
19201
18699
|
|
|
19202
18700
|
// src/cli/commands/quickstart.ts
|
|
@@ -21970,7 +21468,7 @@ import { spawn as spawn3 } from "child_process";
|
|
|
21970
21468
|
import {
|
|
21971
21469
|
existsSync as existsSync11,
|
|
21972
21470
|
mkdirSync as mkdirSync9,
|
|
21973
|
-
realpathSync as
|
|
21471
|
+
realpathSync as realpathSync2,
|
|
21974
21472
|
readFileSync as readFileSync11,
|
|
21975
21473
|
renameSync,
|
|
21976
21474
|
rmSync as rmSync3,
|
|
@@ -22164,6 +21662,34 @@ async function fetchV1SkillNames(baseUrl) {
|
|
|
22164
21662
|
function buildSdkSkillNames(v1SkillNames) {
|
|
22165
21663
|
return sortedUniqueSkillNames(v1SkillNames);
|
|
22166
21664
|
}
|
|
21665
|
+
async function fetchSkillsUpdate(baseUrl, localVersion) {
|
|
21666
|
+
const controller = new AbortController();
|
|
21667
|
+
const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS2);
|
|
21668
|
+
try {
|
|
21669
|
+
const response = await fetch(new URL("/api/v2/cli/update-check", baseUrl), {
|
|
21670
|
+
method: "POST",
|
|
21671
|
+
headers: { "Content-Type": "application/json" },
|
|
21672
|
+
body: JSON.stringify({
|
|
21673
|
+
skills: {
|
|
21674
|
+
version: localVersion
|
|
21675
|
+
}
|
|
21676
|
+
}),
|
|
21677
|
+
signal: controller.signal
|
|
21678
|
+
});
|
|
21679
|
+
if (!response.ok) return null;
|
|
21680
|
+
const data = await response.json().catch(() => null);
|
|
21681
|
+
const skills = data?.skills;
|
|
21682
|
+
if (!skills) return null;
|
|
21683
|
+
return {
|
|
21684
|
+
needsUpdate: skills.needs_update === true,
|
|
21685
|
+
remoteVersion: typeof skills.remote?.version === "string" ? skills.remote.version.trim() : ""
|
|
21686
|
+
};
|
|
21687
|
+
} catch {
|
|
21688
|
+
return null;
|
|
21689
|
+
} finally {
|
|
21690
|
+
clearTimeout(timeout);
|
|
21691
|
+
}
|
|
21692
|
+
}
|
|
22167
21693
|
function buildSkillsInstallArgs(baseUrl, skillNames = DEFAULT_SDK_SKILL_NAMES) {
|
|
22168
21694
|
return buildSkillsAddArgs(baseUrl, sortedUniqueSkillNames(skillNames));
|
|
22169
21695
|
}
|
|
@@ -22304,12 +21830,6 @@ function writeSdkSkillsStatusLine(line) {
|
|
|
22304
21830
|
process.stderr.write(`${line}
|
|
22305
21831
|
`);
|
|
22306
21832
|
}
|
|
22307
|
-
function skillsStaleHintLine(update) {
|
|
22308
|
-
if (!update?.needs_update || !update.remote.version) {
|
|
22309
|
-
return null;
|
|
22310
|
-
}
|
|
22311
|
-
return "Deepline agent skills are out of date. Run `deepline update` to sync.";
|
|
22312
|
-
}
|
|
22313
21833
|
async function syncSdkSkillsIfNeeded(baseUrl, options = {}) {
|
|
22314
21834
|
if (attemptedSync || shouldSkipSkillsSync()) return;
|
|
22315
21835
|
attemptedSync = true;
|
|
@@ -22317,11 +21837,14 @@ async function syncSdkSkillsIfNeeded(baseUrl, options = {}) {
|
|
|
22317
21837
|
if (usingPluginSkills) {
|
|
22318
21838
|
return;
|
|
22319
21839
|
}
|
|
22320
|
-
const
|
|
22321
|
-
|
|
21840
|
+
const localVersion = readSdkSkillsLocalVersion(baseUrl);
|
|
21841
|
+
const update = options.update === void 0 ? await fetchSkillsUpdate(baseUrl, localVersion) : options.update ? {
|
|
21842
|
+
needsUpdate: options.update.needs_update,
|
|
21843
|
+
remoteVersion: options.update.remote.version
|
|
21844
|
+
} : null;
|
|
21845
|
+
if (!update?.needsUpdate || !update.remoteVersion) {
|
|
22322
21846
|
return;
|
|
22323
21847
|
}
|
|
22324
|
-
const remoteVersion = update.remote.version;
|
|
22325
21848
|
const remoteSkillNames = await fetchV1SkillNames(baseUrl);
|
|
22326
21849
|
const skillNames = buildSdkSkillNames(
|
|
22327
21850
|
remoteSkillNames.length > 0 ? remoteSkillNames : DEFAULT_SDK_SKILL_NAMES
|
|
@@ -22331,17 +21854,11 @@ async function syncSdkSkillsIfNeeded(baseUrl, options = {}) {
|
|
|
22331
21854
|
const installed = await runSkillsInstall(baseUrl, skillNames);
|
|
22332
21855
|
if (!installed) return;
|
|
22333
21856
|
runLegacySkillsCleanup();
|
|
22334
|
-
writeLocalSkillsVersion(baseUrl, remoteVersion);
|
|
21857
|
+
writeLocalSkillsVersion(baseUrl, update.remoteVersion);
|
|
22335
21858
|
writeSdkSkillsStatusLine("Deepline agent skills are up to date.");
|
|
22336
21859
|
}
|
|
22337
21860
|
|
|
22338
21861
|
// src/cli/commands/update.ts
|
|
22339
|
-
async function resolveSkillsVerdictFromCompat(baseUrl) {
|
|
22340
|
-
const { response } = await checkSdkCompatibility(baseUrl, {
|
|
22341
|
-
skillsVersion: readSdkSkillsLocalVersion(baseUrl)
|
|
22342
|
-
});
|
|
22343
|
-
return response?.skills ?? null;
|
|
22344
|
-
}
|
|
22345
21862
|
var NPM_SDK_INSTALL_COMMON_FLAGS = ["--no-audit", "--no-fund"];
|
|
22346
21863
|
var NPM_SDK_GLOBAL_INSTALL_FLAGS = [
|
|
22347
21864
|
"--no-audit",
|
|
@@ -22450,7 +21967,7 @@ function findRepoBackedSdkRoot(startPath) {
|
|
|
22450
21967
|
function inferNpmGlobalPrefixFromEntrypoint(entrypoint) {
|
|
22451
21968
|
const normalized = (() => {
|
|
22452
21969
|
try {
|
|
22453
|
-
return
|
|
21970
|
+
return realpathSync2(entrypoint);
|
|
22454
21971
|
} catch {
|
|
22455
21972
|
return resolve12(entrypoint);
|
|
22456
21973
|
}
|
|
@@ -22780,7 +22297,6 @@ async function runUpdateCommand(options, dependencies = {}) {
|
|
|
22780
22297
|
const detectBaseUrl = dependencies.detectBaseUrl ?? autoDetectBaseUrl;
|
|
22781
22298
|
const resolvePlan = dependencies.resolvePlan ?? resolveUpdatePlan;
|
|
22782
22299
|
const runPlan = dependencies.runPlan ?? runUpdatePlan;
|
|
22783
|
-
const resolveSkillsVerdict = dependencies.resolveSkillsVerdict ?? resolveSkillsVerdictFromCompat;
|
|
22784
22300
|
const syncSkills = dependencies.syncSkillsIfNeeded ?? syncSdkSkillsIfNeeded;
|
|
22785
22301
|
const stderr = dependencies.stderr ?? process.stderr;
|
|
22786
22302
|
const plan = resolvePlan();
|
|
@@ -22825,9 +22341,7 @@ async function runUpdateCommand(options, dependencies = {}) {
|
|
|
22825
22341
|
if (updateExitCode !== 0) {
|
|
22826
22342
|
return updateExitCode;
|
|
22827
22343
|
}
|
|
22828
|
-
|
|
22829
|
-
const skillsUpdate = await resolveSkillsVerdict(updatedBaseUrl);
|
|
22830
|
-
await syncSkills(updatedBaseUrl, { update: skillsUpdate });
|
|
22344
|
+
await syncSkills(normalizeBaseUrl3(detectBaseUrl()));
|
|
22831
22345
|
return 0;
|
|
22832
22346
|
}
|
|
22833
22347
|
function registerUpdateCommand(program) {
|
|
@@ -23544,7 +23058,7 @@ Exit codes:
|
|
|
23544
23058
|
const baseUrl = autoDetectBaseUrl().replace(/\/$/, "");
|
|
23545
23059
|
const compatibilityCommand = compatibilityCommandPath(actionCommand) || actionCommand.name();
|
|
23546
23060
|
const shouldDeferSkillsSync = shouldDeferSkillsSyncForCommand();
|
|
23547
|
-
const skillsVersion = readSdkSkillsLocalVersion(baseUrl);
|
|
23061
|
+
const skillsVersion = shouldDeferSkillsSync ? void 0 : readSdkSkillsLocalVersion(baseUrl);
|
|
23548
23062
|
const compatibility = await traceCliSpan(
|
|
23549
23063
|
"cli.sdk_compatibility",
|
|
23550
23064
|
{
|
|
@@ -23580,14 +23094,8 @@ Exit codes:
|
|
|
23580
23094
|
if (printStartupPhase) {
|
|
23581
23095
|
progress?.phase("checking sdk skills");
|
|
23582
23096
|
}
|
|
23583
|
-
|
|
23584
|
-
|
|
23585
|
-
const hint = skillsStaleHintLine(skillsUpdate);
|
|
23586
|
-
if (hint && !process.argv.includes("--json")) {
|
|
23587
|
-
process.stderr.write(`${hint}
|
|
23588
|
-
`);
|
|
23589
|
-
}
|
|
23590
|
-
} else {
|
|
23097
|
+
if (!shouldDeferSkillsSync) {
|
|
23098
|
+
const skillsUpdate = compatibility.response && Object.prototype.hasOwnProperty.call(compatibility.response, "skills") ? compatibility.response.skills ?? null : void 0;
|
|
23591
23099
|
await traceCliSpan(
|
|
23592
23100
|
"cli.sdk_skills_sync",
|
|
23593
23101
|
{ baseUrl },
|