deepline 0.3.70 → 0.3.72

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/cli/index.js CHANGED
@@ -182,7 +182,7 @@ configureProxyFromEnv();
182
182
 
183
183
  // src/cli/index.ts
184
184
  var import_promises11 = require("fs/promises");
185
- var import_node_path28 = require("path");
185
+ var import_node_path29 = require("path");
186
186
  var import_node_os18 = require("os");
187
187
  var import_commander4 = require("commander");
188
188
 
@@ -1214,7 +1214,7 @@ var SDK_RELEASE = {
1214
1214
  // available at toolResponse.rawV2 while toolResponse.raw and all declared
1215
1215
  // getters keep their established compatibility behavior.
1216
1216
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
1217
- version: "0.3.70",
1217
+ version: "0.3.72",
1218
1218
  updateSummary: "Automatic CLI updates are now enabled by default. To opt out, run `deepline settings autoupdate off`; use `deepline settings autoupdate on` to re-enable updates or `deepline settings autoupdate pin <version>` to hold an exact release. This release also adds raw-v2 tool responses at toolResponse.rawV2 while preserving existing toolResponse.raw and declared getters.",
1219
1219
  packageCapabilities: {
1220
1220
  updatePreferences: 1
@@ -3554,6 +3554,133 @@ function decodePlayRunPublicStatus(value) {
3554
3554
  }
3555
3555
  }
3556
3556
 
3557
+ // ../play-runtime/log-provenance.ts
3558
+ var LOG_LEVELS = [
3559
+ "debug",
3560
+ "info",
3561
+ "warn",
3562
+ "error"
3563
+ ];
3564
+ var LOG_LEVEL_RANK = {
3565
+ debug: 0,
3566
+ info: 1,
3567
+ warn: 2,
3568
+ error: 3
3569
+ };
3570
+ var LOG_PROVENANCE_CLASSES = [
3571
+ "user",
3572
+ "lifecycle",
3573
+ "replay",
3574
+ "infra",
3575
+ "diagnostic",
3576
+ "receipt"
3577
+ ];
3578
+ var LOG_PROVENANCE_POLICY = {
3579
+ user: { watch: true, ui: true, debug: true },
3580
+ lifecycle: { watch: true, ui: true, debug: true },
3581
+ replay: { watch: false, ui: false, debug: true },
3582
+ infra: { watch: false, ui: false, debug: true },
3583
+ diagnostic: { watch: true, ui: true, debug: true },
3584
+ receipt: { watch: false, ui: false, debug: true }
3585
+ };
3586
+ function logProvenanceReaches(provenance, surface) {
3587
+ return LOG_PROVENANCE_POLICY[provenance][surface];
3588
+ }
3589
+ var PROVENANCE_SENTINEL = "";
3590
+ var PROVENANCE_PREFIX = `${PROVENANCE_SENTINEL}prov:`;
3591
+ function logLevelReaches(level, minimum) {
3592
+ return LOG_LEVEL_RANK[level] >= LOG_LEVEL_RANK[minimum];
3593
+ }
3594
+ function parseLogLevel(value) {
3595
+ const normalized = value.trim().toLowerCase();
3596
+ return LOG_LEVELS.includes(normalized) ? normalized : null;
3597
+ }
3598
+ function readProvenanceTag(line) {
3599
+ if (!line.startsWith(PROVENANCE_PREFIX)) {
3600
+ return { provenance: null, line };
3601
+ }
3602
+ const end = line.indexOf(PROVENANCE_SENTINEL, PROVENANCE_PREFIX.length);
3603
+ if (end === -1) {
3604
+ return { provenance: null, line };
3605
+ }
3606
+ const candidate = line.slice(PROVENANCE_PREFIX.length, end);
3607
+ const provenance = LOG_PROVENANCE_CLASSES.includes(candidate) ? candidate : null;
3608
+ return { provenance, line: line.slice(end + 1) };
3609
+ }
3610
+ function stripProvenanceTag(line) {
3611
+ return readProvenanceTag(line).line;
3612
+ }
3613
+ function classifyLegacyLogLine(line) {
3614
+ const message = stripLeadingTimestamp(line);
3615
+ if (/recovered (?:from checkpoint|response from checkpoint)/i.test(message)) {
3616
+ return "replay";
3617
+ }
3618
+ if (/^\[perf\] runtime receipt\b/i.test(message)) {
3619
+ return "receipt";
3620
+ }
3621
+ if (/^\[perf\] runtime (?:map|state)\b/i.test(message) || /\[worker\] picked up run\b/.test(message) || /\[worker\] heartbeat\b/.test(message) || /\[worker\] progress completedRows=\d+ totalRows=\d+ rowUpdates=\d+/.test(
3622
+ message
3623
+ ) || /\[worker\] step started\b/.test(message) || /\[worker\] Preparing run files\b/.test(message) || /\[worker\] Run files ready\b/.test(message) || /\[worker\] Runtime ready\b/.test(message) || /\[worker\] Sandbox (?:starting|create start|create done|workspace ready|upload start|runner uploaded)\b/.test(
3624
+ message
3625
+ ) || /^\[event\] play\.step\.progress\b/.test(message) || /^\[event\] play\.run\.snapshot\b/.test(message) || /^\[event\] play\.sheet\.summary\b/.test(message)) {
3626
+ return "infra";
3627
+ }
3628
+ if (/^\[warn\]/i.test(message) || /^\[error\]/i.test(message) || /^\[runtime\.[a-z_]*(?:failure|error)\]/i.test(message)) {
3629
+ return "diagnostic";
3630
+ }
3631
+ return "user";
3632
+ }
3633
+ function classifyLogLine(line) {
3634
+ const tagged = readProvenanceTag(line);
3635
+ const provenance = tagged.provenance ?? classifyLegacyLogLine(tagged.line);
3636
+ if (tagged.provenance !== null) {
3637
+ return {
3638
+ provenance,
3639
+ level: inferLogLevel(provenance, tagged.line),
3640
+ line: tagged.line
3641
+ };
3642
+ }
3643
+ return {
3644
+ provenance,
3645
+ level: inferLogLevel(provenance, tagged.line),
3646
+ line: tagged.line
3647
+ };
3648
+ }
3649
+ function inferLogLevel(provenance, line) {
3650
+ const message = stripLeadingTimestamp(line);
3651
+ if (/^\[info\]/i.test(message)) {
3652
+ return "info";
3653
+ }
3654
+ if (/^\[debug\]/i.test(message)) {
3655
+ return "debug";
3656
+ }
3657
+ if (/^\[console\.error\]/i.test(message) || /^\[error\]/i.test(message)) {
3658
+ return "error";
3659
+ }
3660
+ if (/^\[console\.warn\]/i.test(message) || /^\[warn\]/i.test(message)) {
3661
+ return "warn";
3662
+ }
3663
+ if (/^\[console\.debug\]/i.test(message)) {
3664
+ return "debug";
3665
+ }
3666
+ if (provenance === "replay" || provenance === "infra" || provenance === "receipt") {
3667
+ return "debug";
3668
+ }
3669
+ if (provenance === "diagnostic") {
3670
+ return "warn";
3671
+ }
3672
+ return "info";
3673
+ }
3674
+ function stripLeadingTimestamp(line) {
3675
+ const match = line.match(/^\[([^\]]+)\]\s*([\s\S]*)$/);
3676
+ if (!match) {
3677
+ return line;
3678
+ }
3679
+ const inner = match[1] ?? "";
3680
+ const isTimestamp = !Number.isNaN(new Date(inner).getTime());
3681
+ return isTimestamp ? match[2] ?? line : line;
3682
+ }
3683
+
3557
3684
  // ../play-runtime/run-snapshot-stream.ts
3558
3685
  function normalizePlayRunLiveStatus(value) {
3559
3686
  return normalizePlayRunLifecycleStatus(value);
@@ -3626,7 +3753,9 @@ function buildSnapshotFromLedger(snapshot) {
3626
3753
  finishedAt: snapshot.finishedAt ?? null,
3627
3754
  durationMs: snapshot.durationMs ?? null,
3628
3755
  updatedAt: snapshot.updatedAt ?? snapshot.finishedAt ?? snapshot.startedAt ?? null,
3629
- logs: snapshot.logTail,
3756
+ // This snapshot is public SDK/API transport. Keep the historical plain
3757
+ // timestamp-prefixed text while provenance remains runtime metadata.
3758
+ logs: snapshot.logTail.map(stripProvenanceTag),
3630
3759
  totalLogCount: snapshot.totalLogCount,
3631
3760
  ...snapshot.logsTruncated ? { logsTruncated: true } : {},
3632
3761
  activeArtifactTableNamespace: snapshot.activeArtifactTableNamespace ?? null,
@@ -4854,6 +4983,8 @@ var DeeplineClient = class {
4854
4983
  db;
4855
4984
  /** Billing namespace: subscription status/cancel and invoice history. */
4856
4985
  billing;
4986
+ /** Workspace lifecycle namespace. */
4987
+ workspaces;
4857
4988
  /** Monitors namespace: access, catalog, deploy/check, and lifecycle. */
4858
4989
  monitors;
4859
4990
  /**
@@ -4902,6 +5033,9 @@ var DeeplineClient = class {
4902
5033
  transitionPlan: (options2) => this.transitionTargetBillingPlan(options2),
4903
5034
  portalSession: () => this.createTargetBillingPortalSession()
4904
5035
  };
5036
+ this.workspaces = {
5037
+ create: (options2) => this.createWorkspace(options2)
5038
+ };
4905
5039
  this.monitors = {
4906
5040
  status: () => this.getMonitorsAccess(),
4907
5041
  available: (toolIdOrOptions, options2) => this.getMonitorsAvailable(toolIdOrOptions, options2),
@@ -7053,6 +7187,23 @@ var DeeplineClient = class {
7053
7187
  const response = await this.http.post("/api/v2/billing/portal-sessions", {});
7054
7188
  return response.data;
7055
7189
  }
7190
+ /** Create an additional workspace through the durable PAYG workflow. */
7191
+ async createWorkspace(options) {
7192
+ const idempotencyKey = requireTargetBillingIdempotencyKey(
7193
+ options.idempotencyKey
7194
+ );
7195
+ const response = await this.http.post(
7196
+ "/api/v2/workspaces",
7197
+ { name: options.name },
7198
+ { "Idempotency-Key": idempotencyKey },
7199
+ { maxRetries: 0, exactUrlOnly: true }
7200
+ );
7201
+ return {
7202
+ ...response.data,
7203
+ operation: response.operation,
7204
+ ...response.request_id ? { request_id: response.request_id } : {}
7205
+ };
7206
+ }
7056
7207
  // ——————————————————————————————————————————————————————————
7057
7208
  // Monitors
7058
7209
  // ——————————————————————————————————————————————————————————
@@ -15177,7 +15328,7 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
15177
15328
  " fetch(key: string, url: string | URL, init?: RequestInit & { headers?: HeadersInit & { 'Idempotency-Key'?: string; 'X-Idempotency-Key'?: string }; auth?: SecretAuthInput }, options?: FetchOptions): Promise<PlayFetchResponse>;",
15178
15329
  " secrets: { get(name: string): SecretPromise; bearer(secret: string | SecretPromise | SecretHandle): SecretAuth; header(header: string, secret: string | SecretPromise | SecretHandle): SecretAuth };",
15179
15330
  ` runPlay<TOutput = unknown>(key: string, playRef: ${cloudReferenceType("ctx.runPlay.playRef")}, input: ${cloudReferenceType("ctx.runPlay.input")}, options: PlayCallOptions): Promise<TOutput>;`,
15180
- " log(message: string): void;",
15331
+ " log(message: string, options?: { level?: 'debug' | 'info' | 'warn' | 'error' }): void;",
15181
15332
  ` sleep(ms: ${cloudReferenceType("ctx.sleep.ms")}): Promise<void>;`,
15182
15333
  "}",
15183
15334
  "export type DefinePlayConfig<TInput, TOutput extends PlayReturnObject> = { id: string; description?: string; input: PlayInputContract<TInput>; run: (ctx: DeeplinePlayRuntimeContext, input: TInput) => Promise<TOutput>; bindings?: PlayBindings<TInput>; billing?: PlayBindings<TInput>['billing']; runtime?: PlayBindings<TInput>['runtime']; compatibility?: PlayBindings<TInput>['compatibility'] };",
@@ -16727,77 +16878,6 @@ function isInternalGlueStepId(stepId) {
16727
16878
  return typeof stepId === "string" && stepId.startsWith(INTERNAL_GLUE_NODE_ID_PREFIX);
16728
16879
  }
16729
16880
 
16730
- // ../play-runtime/log-provenance.ts
16731
- var LOG_PROVENANCE_CLASSES = [
16732
- "user",
16733
- "lifecycle",
16734
- "replay",
16735
- "infra",
16736
- "diagnostic",
16737
- "receipt"
16738
- ];
16739
- var LOG_PROVENANCE_POLICY = {
16740
- user: { watch: true, ui: true, debug: true },
16741
- lifecycle: { watch: true, ui: true, debug: true },
16742
- replay: { watch: false, ui: false, debug: true },
16743
- infra: { watch: false, ui: false, debug: true },
16744
- diagnostic: { watch: true, ui: true, debug: true },
16745
- receipt: { watch: false, ui: false, debug: true }
16746
- };
16747
- function logProvenanceReaches(provenance, surface) {
16748
- return LOG_PROVENANCE_POLICY[provenance][surface];
16749
- }
16750
- var PROVENANCE_SENTINEL = "";
16751
- var PROVENANCE_PREFIX = `${PROVENANCE_SENTINEL}prov:`;
16752
- function readProvenanceTag(line) {
16753
- if (!line.startsWith(PROVENANCE_PREFIX)) {
16754
- return { provenance: null, line };
16755
- }
16756
- const end = line.indexOf(PROVENANCE_SENTINEL, PROVENANCE_PREFIX.length);
16757
- if (end === -1) {
16758
- return { provenance: null, line };
16759
- }
16760
- const candidate = line.slice(PROVENANCE_PREFIX.length, end);
16761
- const provenance = LOG_PROVENANCE_CLASSES.includes(candidate) ? candidate : null;
16762
- return { provenance, line: line.slice(end + 1) };
16763
- }
16764
- function classifyLegacyLogLine(line) {
16765
- const message = stripLeadingTimestamp(line);
16766
- if (/recovered (?:from checkpoint|response from checkpoint)/i.test(message)) {
16767
- return "replay";
16768
- }
16769
- if (/^\[perf\] runtime receipt\b/i.test(message)) {
16770
- return "receipt";
16771
- }
16772
- if (/^\[perf\] runtime (?:map|state)\b/i.test(message) || /\[worker\] picked up run\b/.test(message) || /\[worker\] heartbeat\b/.test(message) || /\[worker\] progress completedRows=\d+ totalRows=\d+ rowUpdates=\d+/.test(
16773
- message
16774
- ) || /\[worker\] step started\b/.test(message) || /\[worker\] Preparing run files\b/.test(message) || /\[worker\] Run files ready\b/.test(message) || /\[worker\] Runtime ready\b/.test(message) || /\[worker\] Sandbox (?:starting|create start|create done|workspace ready|upload start|runner uploaded)\b/.test(
16775
- message
16776
- ) || /^\[event\] play\.step\.progress\b/.test(message) || /^\[event\] play\.run\.snapshot\b/.test(message) || /^\[event\] play\.sheet\.summary\b/.test(message)) {
16777
- return "infra";
16778
- }
16779
- if (/^\[warn\]/i.test(message) || /^\[error\]/i.test(message) || /^\[runtime\.[a-z_]*(?:failure|error)\]/i.test(message)) {
16780
- return "diagnostic";
16781
- }
16782
- return "user";
16783
- }
16784
- function classifyLogLine(line) {
16785
- const tagged = readProvenanceTag(line);
16786
- if (tagged.provenance !== null) {
16787
- return { provenance: tagged.provenance, line: tagged.line };
16788
- }
16789
- return { provenance: classifyLegacyLogLine(tagged.line), line: tagged.line };
16790
- }
16791
- function stripLeadingTimestamp(line) {
16792
- const match = line.match(/^\[([^\]]+)\]\s*([\s\S]*)$/);
16793
- if (!match) {
16794
- return line;
16795
- }
16796
- const inner = match[1] ?? "";
16797
- const isTimestamp = !Number.isNaN(new Date(inner).getTime());
16798
- return isTimestamp ? match[2] ?? line : line;
16799
- }
16800
-
16801
16881
  // ../play-runtime/fixture-behavior.ts
16802
16882
  var FIXTURE_BEHAVIOR_VERSION = 1;
16803
16883
  var FIXTURE_BEHAVIOR_RESPONSE_VERSION = 2;
@@ -18225,7 +18305,11 @@ var TERMINAL_PLAY_STATUSES2 = /* @__PURE__ */ new Set([
18225
18305
  var PLAY_START_TRANSIENT_RETRY_DELAYS_MS = [500, 1500];
18226
18306
  var PLAY_PROGRESS_HEARTBEAT_INTERVAL_MS = 15e3;
18227
18307
  var PLAY_STATUS_HEARTBEAT_INTERVAL_MS = 15e3;
18228
- function watchSurfaceReaches(state, provenance) {
18308
+ function watchSurfaceReaches(state, provenance, level) {
18309
+ const minimumLevel = state.logLevel ?? (state.verbose ? "debug" : "info");
18310
+ if (!logLevelReaches(level, minimumLevel)) {
18311
+ return false;
18312
+ }
18229
18313
  if (logProvenanceReaches(provenance, "watch")) {
18230
18314
  return true;
18231
18315
  }
@@ -18420,7 +18504,7 @@ function emitLiveDebugTableHints(input2) {
18420
18504
  process.stdout
18421
18505
  );
18422
18506
  }
18423
- if (!watchSurfaceReaches(input2.state, "infra")) {
18507
+ if (!watchSurfaceReaches(input2.state, "infra", "debug")) {
18424
18508
  return;
18425
18509
  }
18426
18510
  const tableNamespace = extractTableNamespaceFromLiveEvent(input2.event);
@@ -18523,7 +18607,7 @@ function getStepTransitionLineFromLiveEvent(event, state) {
18523
18607
  if (isTerminal) {
18524
18608
  state.terminalStepIds.add(stepId);
18525
18609
  }
18526
- if (isReplayEcho && !watchSurfaceReaches(state, "replay")) {
18610
+ if (isReplayEcho && !watchSurfaceReaches(state, "replay", "debug")) {
18527
18611
  return null;
18528
18612
  }
18529
18613
  return `step ${label}: ${status}`;
@@ -18927,6 +19011,7 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
18927
19011
  lastLogIndex: 0,
18928
19012
  emittedRunnerStarted: false,
18929
19013
  verbose: input2.verboseLogs === true,
19014
+ logLevel: input2.logLevel ?? "info",
18930
19015
  lastProgressSignature: null,
18931
19016
  lastProgressHeartbeatAt: 0,
18932
19017
  lastStatusHeartbeatAt: 0
@@ -19305,6 +19390,9 @@ function formatPlayLogLine(rawLine, status, state) {
19305
19390
  const message = timestampMatch?.[2] ?? line;
19306
19391
  const prefix = timestamp ? `${timestamp} ` : "";
19307
19392
  if (/\[worker\] picked up run\b/.test(message)) {
19393
+ if (!logLevelReaches("info", state.logLevel ?? "info")) {
19394
+ return null;
19395
+ }
19308
19396
  if (state.emittedRunnerStarted) {
19309
19397
  return null;
19310
19398
  }
@@ -19321,6 +19409,9 @@ function formatPlayLogLine(rawLine, status, state) {
19321
19409
  /^Starting map over (\d+) items with (\d+) fields \(key: ([^;]+); (\d+) already satisfied; (\d+) pending\)$/
19322
19410
  );
19323
19411
  if (mapStart) {
19412
+ if (!logLevelReaches("info", state.logLevel ?? "info")) {
19413
+ return null;
19414
+ }
19324
19415
  const [, rows, fields, namespace, cached, pending] = mapStart;
19325
19416
  return `${prefix}map ${sourceLabelForNamespace(namespace)}: ${formatInteger(Number(rows))} rows, ${fields} fields, ${formatInteger(Number(cached))} cached, ${formatInteger(Number(pending))} pending`;
19326
19417
  }
@@ -19328,10 +19419,13 @@ function formatPlayLogLine(rawLine, status, state) {
19328
19419
  /^Map completed: (\d+) results \((\d+) executed, (\d+) already satisfied\)$/
19329
19420
  );
19330
19421
  if (mapDone) {
19422
+ if (!logLevelReaches("info", state.logLevel ?? "info")) {
19423
+ return null;
19424
+ }
19331
19425
  const [, results, executed, cached] = mapDone;
19332
19426
  return `${prefix}done: ${formatInteger(Number(results))} results, ${formatInteger(Number(executed))} executed, ${formatInteger(Number(cached))} cached`;
19333
19427
  }
19334
- if (!watchSurfaceReaches(state, classified.provenance)) {
19428
+ if (!watchSurfaceReaches(state, classified.provenance, classified.level)) {
19335
19429
  return null;
19336
19430
  }
19337
19431
  return `${prefix}${message}`;
@@ -21067,13 +21161,12 @@ function parsePlayRunOptions(args) {
21067
21161
  const watch = !args.includes("--no-wait");
21068
21162
  let jsonOutput = watch ? args.includes("--json") : argsWantJson(args);
21069
21163
  const fullJson = args.includes("--full");
21070
- const explicitDebugLogs = args.includes("--logs") || args.some((_, index) => isBarePlayRunDebugFlag(args, index));
21071
- const emitLogs = !jsonOutput || explicitDebugLogs;
21072
21164
  const force = args.includes("--force");
21073
21165
  const forceToolRefresh = args.includes("--force-tool-refresh");
21074
21166
  const open2 = args.includes("--open");
21075
21167
  const debugMapLatency = args.includes("--debug-map-latency");
21076
- const verboseLogs = explicitDebugLogs || debugMapLatency;
21168
+ let logLevel = "info";
21169
+ let hasExplicitLogLevel = false;
21077
21170
  let waitTimeoutMs = null;
21078
21171
  let maxConcurrentExternalCalls = null;
21079
21172
  let maxConcurrentRows = null;
@@ -21094,6 +21187,23 @@ function parsePlayRunOptions(args) {
21094
21187
  input2 = parseJsonInput(args[++index]);
21095
21188
  continue;
21096
21189
  }
21190
+ if (arg === "--log-level" || arg.startsWith("--log-level=")) {
21191
+ const value = arg === "--log-level" ? args[++index] : arg.slice("--log-level=".length);
21192
+ if (!value || value.startsWith("--")) {
21193
+ throw new Error(
21194
+ "--log-level requires one of: debug, info, warn, error."
21195
+ );
21196
+ }
21197
+ const parsed = parseLogLevel(value);
21198
+ if (!parsed) {
21199
+ throw new Error(
21200
+ `Unsupported --log-level ${JSON.stringify(value)}. Use debug, info, warn, or error.`
21201
+ );
21202
+ }
21203
+ logLevel = parsed;
21204
+ hasExplicitLogLevel = true;
21205
+ continue;
21206
+ }
21097
21207
  if (arg === "--run-id-file") {
21098
21208
  const value = args[index + 1];
21099
21209
  if (!value || value.startsWith("--")) {
@@ -21272,6 +21382,17 @@ function parsePlayRunOptions(args) {
21272
21382
  "--live, --latest, and --revision-id only apply to named plays."
21273
21383
  );
21274
21384
  }
21385
+ if (debugMapLatency && logLevel === "info") logLevel = "debug";
21386
+ const usesDebugAlias = args.includes("--logs") || args.some((_, index) => isBarePlayRunDebugFlag(args, index));
21387
+ if (usesDebugAlias && hasExplicitLogLevel && logLevel !== "debug") {
21388
+ throw new Error(
21389
+ "--debug/--logs conflicts with a non-debug --log-level. Use one level selector."
21390
+ );
21391
+ }
21392
+ if (usesDebugAlias) logLevel = "debug";
21393
+ const explicitDebugLogs = usesDebugAlias || logLevel === "debug";
21394
+ const emitLogs = !jsonOutput || explicitDebugLogs || hasExplicitLogLevel;
21395
+ const verboseLogs = explicitDebugLogs || debugMapLatency;
21275
21396
  return {
21276
21397
  target: filePath ? { kind: "file", path: filePath } : { kind: "name", name: playName },
21277
21398
  input: input2,
@@ -21280,6 +21401,7 @@ function parsePlayRunOptions(args) {
21280
21401
  watch,
21281
21402
  emitLogs,
21282
21403
  verboseLogs,
21404
+ logLevel,
21283
21405
  jsonOutput,
21284
21406
  fullJson,
21285
21407
  waitTimeoutMs,
@@ -22177,6 +22299,7 @@ async function handleFileBackedRun(options, hooks) {
22177
22299
  jsonOutput: options.jsonOutput,
22178
22300
  emitLogs: options.emitLogs,
22179
22301
  verboseLogs: options.verboseLogs,
22302
+ logLevel: options.logLevel,
22180
22303
  waitTimeoutMs: options.waitTimeoutMs,
22181
22304
  open: options.open,
22182
22305
  progress,
@@ -22359,6 +22482,7 @@ async function handleNamedRun(options, hooks) {
22359
22482
  jsonOutput: options.jsonOutput,
22360
22483
  emitLogs: options.emitLogs,
22361
22484
  verboseLogs: options.verboseLogs,
22485
+ logLevel: options.logLevel,
22362
22486
  waitTimeoutMs: options.waitTimeoutMs,
22363
22487
  open: options.open,
22364
22488
  progress,
@@ -22476,12 +22600,13 @@ async function handlePlayRun(args, hooks) {
22476
22600
  function parseRunIdPositional(args, usage) {
22477
22601
  for (let index = 0; index < args.length; index += 1) {
22478
22602
  const arg = args[index];
22479
- if (arg === "--json" || arg === "--full" || arg === "--input" || arg === "--logs" || arg === "--debug" || arg === "--compact" || arg === "--log-failed" || arg === "--failed" || arg === "--limit") {
22480
- if (arg === "--limit" && args[index + 1]) {
22603
+ if (arg === "--json" || arg === "--full" || arg === "--input" || arg === "--logs" || arg === "--debug" || arg === "--compact" || arg === "--log-failed" || arg === "--failed" || arg === "--limit" || arg === "--log-level") {
22604
+ if ((arg === "--limit" || arg === "--log-level") && args[index + 1]) {
22481
22605
  index += 1;
22482
22606
  }
22483
22607
  continue;
22484
22608
  }
22609
+ if (arg.startsWith("--log-level=")) continue;
22485
22610
  if ((arg === "--out" || arg === "--reason" || arg === "--dataset") && args[index + 1]) {
22486
22611
  index += 1;
22487
22612
  continue;
@@ -22643,7 +22768,7 @@ async function handleRunsList(args) {
22643
22768
  return 0;
22644
22769
  }
22645
22770
  async function handleRunTail(args) {
22646
- const usage = "Usage: deepline runs tail <run-id> [--json | --jsonl] [--compact] [--debug]";
22771
+ const usage = "Usage: deepline runs tail <run-id> [--json | --jsonl] [--compact] [--log-level debug|info|warn|error]";
22647
22772
  let runId;
22648
22773
  try {
22649
22774
  runId = parseRunIdPositional(args, usage);
@@ -22651,6 +22776,9 @@ async function handleRunTail(args) {
22651
22776
  console.error(error instanceof Error ? error.message : usage);
22652
22777
  return 1;
22653
22778
  }
22779
+ let logLevel = "info";
22780
+ let hasExplicitLogLevel = false;
22781
+ let usesDebugAlias = false;
22654
22782
  for (let index = 0; index < args.length; index += 1) {
22655
22783
  const arg = args[index];
22656
22784
  if (arg === "--cursor") {
@@ -22659,7 +22787,28 @@ async function handleRunTail(args) {
22659
22787
  );
22660
22788
  return 1;
22661
22789
  }
22662
- if (arg.startsWith("--") && arg !== "--json" && arg !== "--jsonl" && arg !== "--compact" && arg !== "--logs" && arg !== "--debug") {
22790
+ if (arg === "--log-level" || arg.startsWith("--log-level=")) {
22791
+ const value = arg === "--log-level" ? args[++index] : arg.slice("--log-level=".length);
22792
+ if (!value || value.startsWith("--")) {
22793
+ console.error("--log-level requires one of: debug, info, warn, error.");
22794
+ return 1;
22795
+ }
22796
+ const parsed = parseLogLevel(value);
22797
+ if (!parsed) {
22798
+ console.error(
22799
+ `Unsupported --log-level ${JSON.stringify(value)}. Use debug, info, warn, or error.`
22800
+ );
22801
+ return 1;
22802
+ }
22803
+ logLevel = parsed;
22804
+ hasExplicitLogLevel = true;
22805
+ continue;
22806
+ }
22807
+ if (arg === "--logs" || arg === "--debug") {
22808
+ usesDebugAlias = true;
22809
+ continue;
22810
+ }
22811
+ if (arg.startsWith("--") && arg !== "--json" && arg !== "--jsonl" && arg !== "--compact") {
22663
22812
  console.error(`${arg} is not supported by deepline runs tail.`);
22664
22813
  return 1;
22665
22814
  }
@@ -22668,10 +22817,17 @@ async function handleRunTail(args) {
22668
22817
  console.error("--json and --jsonl cannot be used together.");
22669
22818
  return 1;
22670
22819
  }
22671
- const debug = args.includes("--logs") || args.includes("--debug");
22672
- if (args.includes("--jsonl") && debug) {
22820
+ if (usesDebugAlias && hasExplicitLogLevel && logLevel !== "debug") {
22673
22821
  console.error(
22674
- "--debug is redundant with --jsonl: JSON Lines already includes every canonical live event."
22822
+ "--debug conflicts with a non-debug --log-level. Use one level selector."
22823
+ );
22824
+ return 1;
22825
+ }
22826
+ if (usesDebugAlias) logLevel = "debug";
22827
+ const debug = logLevel === "debug";
22828
+ if (args.includes("--jsonl") && (debug || hasExplicitLogLevel)) {
22829
+ console.error(
22830
+ "--log-level cannot be combined with --jsonl: JSON Lines already includes every canonical live event."
22675
22831
  );
22676
22832
  return 1;
22677
22833
  }
@@ -22685,7 +22841,8 @@ async function handleRunTail(args) {
22685
22841
  lastProgressSignature: null,
22686
22842
  lastProgressHeartbeatAt: 0,
22687
22843
  lastStatusHeartbeatAt: 0,
22688
- verbose: debug
22844
+ verbose: debug,
22845
+ logLevel
22689
22846
  };
22690
22847
  const status = await client2.runs.tail(runId, {
22691
22848
  onEvent: jsonLines ? (event) => {
@@ -22697,8 +22854,8 @@ async function handleRunTail(args) {
22697
22854
  })}
22698
22855
  `
22699
22856
  );
22700
- } : compact || debug ? (event) => {
22701
- if (debug) {
22857
+ } : compact || debug || hasExplicitLogLevel ? (event) => {
22858
+ if (debug || hasExplicitLogLevel) {
22702
22859
  for (const line of getLogLinesFromLiveEvent(event)) {
22703
22860
  const formatted = formatPlayLogLine(
22704
22861
  line,
@@ -22733,7 +22890,7 @@ async function handleRunTail(args) {
22733
22890
  }
22734
22891
  } : void 0,
22735
22892
  // Human mode only: in --json mode emit nothing non-protocol.
22736
- onReconnect: jsonOutput && !debug ? void 0 : ({ reason }) => {
22893
+ onReconnect: jsonOutput && !debug && !hasExplicitLogLevel ? void 0 : ({ reason }) => {
22737
22894
  process.stderr.write(
22738
22895
  `[runs tail] stream ended without a terminal status; reconnecting to run ${runId} (${reason})
22739
22896
  `
@@ -22749,7 +22906,7 @@ async function handleRunTail(args) {
22749
22906
  return status.status === "failed" ? 1 : 0;
22750
22907
  }
22751
22908
  async function handleRunLogs(args) {
22752
- const usage = "Usage: deepline runs logs <run-id> [--limit 200] [--failed] [--out run.log] [--json] [--debug]";
22909
+ const usage = "Usage: deepline runs logs <run-id> [--limit 200] [--failed] [--out run.log] [--log-level debug|info|warn|error] [--json]";
22753
22910
  let runId;
22754
22911
  try {
22755
22912
  runId = parseRunIdPositional(args, usage);
@@ -22759,10 +22916,34 @@ async function handleRunLogs(args) {
22759
22916
  }
22760
22917
  let limit = 200;
22761
22918
  let outPath = null;
22919
+ let logLevel = "debug";
22920
+ let hasExplicitLogLevel = false;
22921
+ let usesDebugAlias = false;
22762
22922
  const failed = args.includes("--failed");
22763
22923
  for (let index = 0; index < args.length; index += 1) {
22764
22924
  const arg = args[index];
22765
- if (arg === "--debug" || arg === "--logs" || arg === "--json" || arg === "--failed") {
22925
+ if (arg === "--debug" || arg === "--logs") {
22926
+ usesDebugAlias = true;
22927
+ continue;
22928
+ }
22929
+ if (arg === "--json" || arg === "--failed") {
22930
+ continue;
22931
+ }
22932
+ if (arg === "--log-level" || arg.startsWith("--log-level=")) {
22933
+ const value = arg === "--log-level" ? args[++index] : arg.slice("--log-level=".length);
22934
+ if (!value || value.startsWith("--")) {
22935
+ console.error("--log-level requires one of: debug, info, warn, error.");
22936
+ return 1;
22937
+ }
22938
+ const parsed = parseLogLevel(value);
22939
+ if (!parsed) {
22940
+ console.error(
22941
+ `Unsupported --log-level ${JSON.stringify(value)}. Use debug, info, warn, or error.`
22942
+ );
22943
+ return 1;
22944
+ }
22945
+ logLevel = parsed;
22946
+ hasExplicitLogLevel = true;
22766
22947
  continue;
22767
22948
  }
22768
22949
  if (arg === "--limit" && args[index + 1]) {
@@ -22778,6 +22959,13 @@ async function handleRunLogs(args) {
22778
22959
  return 1;
22779
22960
  }
22780
22961
  }
22962
+ if (usesDebugAlias && hasExplicitLogLevel && logLevel !== "debug") {
22963
+ console.error(
22964
+ "--debug conflicts with a non-debug --log-level. Use one level selector."
22965
+ );
22966
+ return 1;
22967
+ }
22968
+ if (usesDebugAlias) logLevel = "debug";
22781
22969
  if (failed && outPath) {
22782
22970
  console.error(
22783
22971
  "--failed cannot be combined with --out. Remove --failed to export the full persisted log stream."
@@ -22787,7 +22975,7 @@ async function handleRunLogs(args) {
22787
22975
  const client2 = new DeeplineClient();
22788
22976
  if (outPath) {
22789
22977
  const result2 = await client2.runs.logs(runId, { all: true });
22790
- const logs = result2.entries;
22978
+ const logs = result2.entries.filter((line) => logLevelReaches(classifyLogLine(line).level, logLevel)).map((line) => classifyLogLine(line).line);
22791
22979
  (0, import_node_fs12.writeFileSync)(outPath, `${logs.join("\n")}${logs.length > 0 ? "\n" : ""}`);
22792
22980
  printCommandEnvelope(
22793
22981
  {
@@ -22795,6 +22983,7 @@ async function handleRunLogs(args) {
22795
22983
  log_path: outPath,
22796
22984
  lineCount: logs.length,
22797
22985
  totalCount: result2.totalCount,
22986
+ logLevel,
22798
22987
  ...result2.logsTruncated ? { logsTruncated: true } : {},
22799
22988
  local: { log_path: outPath },
22800
22989
  render: {
@@ -22815,27 +23004,47 @@ async function handleRunLogs(args) {
22815
23004
  );
22816
23005
  return 0;
22817
23006
  }
22818
- const result = await client2.runs.logs(runId, { limit, failed });
22819
- const text = buildRunLogsText(result);
23007
+ const result = await client2.runs.logs(runId, {
23008
+ ...failed ? { limit, failed: true } : { all: logLevel !== "debug", limit }
23009
+ });
23010
+ const matchingEntries = result.entries.filter(
23011
+ (line) => logLevelReaches(classifyLogLine(line).level, logLevel)
23012
+ );
23013
+ const entries = failed ? matchingEntries : matchingEntries.slice(-limit);
23014
+ const matchingEntriesTruncated = !failed && matchingEntries.length > limit;
23015
+ const filteredResult = {
23016
+ ...result,
23017
+ entries,
23018
+ returnedCount: entries.length,
23019
+ truncated: result.truncated || matchingEntriesTruncated,
23020
+ hasMore: result.hasMore || matchingEntriesTruncated,
23021
+ view: failed ? result.view : "tail",
23022
+ next: {
23023
+ ...result.next ?? {},
23024
+ logs: `deepline runs logs ${result.runId} --out run.log --log-level ${logLevel} --json`
23025
+ }
23026
+ };
23027
+ const text = buildRunLogsText(filteredResult);
22820
23028
  printCommandEnvelope(
22821
23029
  {
22822
23030
  runId: result.runId,
22823
23031
  totalCount: result.totalCount,
22824
- returnedCount: result.returnedCount,
23032
+ returnedCount: entries.length,
22825
23033
  firstSequence: result.firstSequence,
22826
23034
  lastSequence: result.lastSequence,
22827
- truncated: result.truncated,
22828
- hasMore: result.hasMore,
23035
+ truncated: filteredResult.truncated,
23036
+ hasMore: filteredResult.hasMore,
23037
+ logLevel,
22829
23038
  ...result.logsTruncated ? { logsTruncated: true } : {},
22830
- entries: result.entries,
22831
- ...result.view ? { view: result.view } : {},
23039
+ entries,
23040
+ ...filteredResult.view ? { view: filteredResult.view } : {},
22832
23041
  ...result.association ? { association: result.association } : {},
22833
23042
  ...result.warning ? { warning: result.warning } : {},
22834
23043
  next: {
22835
23044
  ...result.next ?? {},
22836
- export: `deepline runs logs ${result.runId} --out run.log --json`
23045
+ export: `deepline runs logs ${result.runId} --out run.log --log-level ${logLevel} --json`
22837
23046
  },
22838
- render: { sections: [{ title: "run logs", lines: result.entries }] }
23047
+ render: { sections: [{ title: "run logs", lines: entries }] }
22839
23048
  },
22840
23049
  {
22841
23050
  json: argsWantJson(args),
@@ -22845,7 +23054,7 @@ async function handleRunLogs(args) {
22845
23054
  return 0;
22846
23055
  }
22847
23056
  function buildRunLogsText(result) {
22848
- const lines = [...result.entries];
23057
+ const lines = result.entries.map((line) => classifyLogLine(line).line);
22849
23058
  if (result.warning) {
22850
23059
  if (lines.length > 0) lines.push("");
22851
23060
  lines.push(`warning: ${result.warning}`);
@@ -24229,6 +24438,7 @@ Examples:
24229
24438
  deepline plays run long-background-play --no-wait
24230
24439
  deepline plays run long-background-play --run-id-file ./run-id.json
24231
24440
  deepline plays run my.play.ts --input '{"domain":"stripe.com"}'
24441
+ deepline plays run my.play.ts --input '{"domain":"stripe.com"}' --log-level debug
24232
24442
  deepline plays run my.play.ts --profile absurd
24233
24443
  deepline plays run my.play.ts --max-concurrent-external-calls 20
24234
24444
  deepline plays run my.play.ts --input @input.json --json
@@ -24248,9 +24458,12 @@ Examples:
24248
24458
  ).option("--watch", "Compatibility alias; run waits by default").option("--wait", "Compatibility alias; run waits by default").option("--no-wait", "Start the run and return immediately").option(
24249
24459
  "--run-id-file <path>",
24250
24460
  "Atomically write the accepted run id to a new JSON file"
24251
- ).option("--logs", "Compatibility alias for --debug").option(
24461
+ ).option("--logs", "Compatibility alias for --log-level debug").option(
24252
24462
  "--debug [value]",
24253
- "Stream complete customer-safe runtime logs when passed without a value; otherwise pass input.debug"
24463
+ "Compatibility alias for --log-level debug when bare; --debug <value> remains legacy Play input.debug"
24464
+ ).option(
24465
+ "--log-level <level>",
24466
+ "Minimum live log severity: debug, info (default), warn, or error"
24254
24467
  ).option("--tail-timeout-ms <ms>", "Timeout while watching the run stream").option("--force", "Start a fresh run graph").option(
24255
24468
  "--force-tool-refresh",
24256
24469
  "Refresh completed tool receipts; may repeat billed provider calls"
@@ -24300,6 +24513,7 @@ Pass-through input flags:
24300
24513
  ...options.watch || options.wait ? ["--watch"] : [],
24301
24514
  ...options.logs ? ["--logs"] : [],
24302
24515
  ...options.debug === true ? ["--debug"] : typeof options.debug === "string" ? ["--debug", options.debug] : [],
24516
+ ...options.logLevel ? ["--log-level", options.logLevel] : [],
24303
24517
  ...options.tailTimeoutMs ? ["--tail-timeout-ms", options.tailTimeoutMs] : [],
24304
24518
  ...options.force ? ["--force"] : [],
24305
24519
  ...options.forceToolRefresh ? ["--force-tool-refresh"] : [],
@@ -24608,10 +24822,15 @@ Concepts:
24608
24822
  tail reads the live stream. logs fetches persisted logs after the fact.
24609
24823
  stop mutates cloud state by requesting cancellation.
24610
24824
 
24825
+ Debug a run:
24826
+ Active: deepline runs tail <run-id> --log-level debug
24827
+ Historical: deepline runs logs <run-id> --out run.log --log-level debug --json
24828
+ Full state: deepline runs get <run-id> --full --json
24829
+
24611
24830
  Examples:
24612
24831
  deepline runs get play/my-play/run/20260501t000000-000 --json
24613
24832
  deepline runs tail play/my-play/run/20260501t000000-000
24614
- deepline runs logs play/my-play/run/20260501t000000-000 --out run.log --json
24833
+ deepline runs logs play/my-play/run/20260501t000000-000 --out run.log --log-level debug --json
24615
24834
  deepline runs list --play my-play --status failed --json
24616
24835
  deepline runs list --status running --json
24617
24836
  deepline runs stop play/my-play/run/20260501t000000-000 --reason "stale lock" --json
@@ -24717,13 +24936,15 @@ Notes:
24717
24936
  logs for persisted log history. In human output, --compact prints deduplicated
24718
24937
  step transitions and progress instead of the full event stream. --json emits
24719
24938
  one terminal package. --jsonl emits canonical live events as JSON Lines and
24720
- ends with the same compact package shape as runs get --json. Use --debug
24721
- (or legacy --logs) to also print customer-safe runtime log lines to stderr.
24939
+ ends with the same compact package shape as runs get --json. --log-level
24940
+ filters the rendered customer-safe runtime log lines; debug includes runtime
24941
+ and receipt diagnostics and writes them to stderr alongside JSON output.
24722
24942
 
24723
24943
  Examples:
24724
24944
  deepline runs tail play/my-play/run/20260501t000000-000
24725
24945
  deepline runs tail play/my-play/run/20260501t000000-000 --compact
24726
- deepline runs tail play/my-play/run/20260501t000000-000 --debug
24946
+ deepline runs tail play/my-play/run/20260501t000000-000 --log-level debug
24947
+ deepline runs tail play/my-play/run/20260501t000000-000 --log-level error
24727
24948
  deepline runs tail play/my-play/run/20260501t000000-000 --jsonl
24728
24949
  `
24729
24950
  ).option("--json", "Emit one terminal JSON package after the run completes").option(
@@ -24732,9 +24953,9 @@ Examples:
24732
24953
  ).option(
24733
24954
  "--compact",
24734
24955
  "Show deduplicated human step transitions and progress"
24735
- ).option("--logs", "Compatibility alias for --debug").option(
24736
- "--debug",
24737
- "Print customer-safe runtime log lines to stderr while tailing"
24956
+ ).option("--logs", "Compatibility alias for --log-level debug").option("--debug", "Compatibility alias for --log-level debug").option(
24957
+ "--log-level <level>",
24958
+ "Minimum severity: debug, info (default), warn, or error"
24738
24959
  ).action(async (runId, options) => {
24739
24960
  process.exitCode = await handleRunTail([
24740
24961
  runId,
@@ -24742,7 +24963,8 @@ Examples:
24742
24963
  ...options.jsonl ? ["--jsonl"] : [],
24743
24964
  ...options.compact ? ["--compact"] : [],
24744
24965
  ...options.logs ? ["--logs"] : [],
24745
- ...options.debug ? ["--debug"] : []
24966
+ ...options.debug ? ["--debug"] : [],
24967
+ ...options.logLevel ? ["--log-level", options.logLevel] : []
24746
24968
  ]);
24747
24969
  });
24748
24970
  runs.command("logs <runId>").description("Fetch persisted logs for a play run.").addHelpText(
@@ -24750,29 +24972,30 @@ Examples:
24750
24972
  `
24751
24973
  Notes:
24752
24974
  Prints a bounded recent log preview by default. Use --out to write the full
24753
- persisted log stream to a local file. --debug (or legacy --logs) is accepted
24754
- for script parity; this command already returns the unfiltered durable stream.
24975
+ retained stream to a local file. Use --log-level to filter by severity;
24976
+ default debug preserves the complete historical stream.
24755
24977
 
24756
24978
  Examples:
24757
24979
  deepline runs logs play/my-play/run/20260501t000000-000
24758
24980
  deepline runs logs play/my-play/run/20260501t000000-000 --limit 500
24759
24981
  deepline runs logs play/my-play/run/20260501t000000-000 --failed --json
24760
- deepline runs logs play/my-play/run/20260501t000000-000 --debug
24761
- deepline runs logs play/my-play/run/20260501t000000-000 --out run.log --json
24982
+ deepline runs logs play/my-play/run/20260501t000000-000 --log-level error
24983
+ deepline runs logs play/my-play/run/20260501t000000-000 --out run.log --log-level debug --json
24762
24984
  `
24763
24985
  ).option(
24764
24986
  "--limit <count>",
24765
24987
  "Maximum recent log lines to print without --out",
24766
24988
  "200"
24767
- ).option("--out <path>", "Write the full persisted log stream to a file").option("--failed", "Show the bounded terminal-failure log window").option("--logs", "Compatibility alias for --debug").option(
24768
- "--debug",
24769
- "Explicitly request the same persisted log view (no provenance filtering)"
24770
- ).option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (runId, options) => {
24989
+ ).option("--out <path>", "Write the full retained log stream to a file").option("--failed", "Show the bounded terminal-failure log window").option(
24990
+ "--log-level <level>",
24991
+ "Minimum severity: debug (default), info, warn, or error"
24992
+ ).option("--logs", "Compatibility alias for --log-level debug").option("--debug", "Compatibility alias for --log-level debug").option("--json", "Emit JSON output. Also automatic when stdout is piped").action(async (runId, options) => {
24771
24993
  process.exitCode = await handleRunLogs([
24772
24994
  runId,
24773
24995
  ...options.limit ? ["--limit", options.limit] : [],
24774
24996
  ...options.out ? ["--out", options.out] : [],
24775
24997
  ...options.failed ? ["--failed"] : [],
24998
+ ...options.logLevel ? ["--log-level", options.logLevel] : [],
24776
24999
  ...options.logs ? ["--logs"] : [],
24777
25000
  ...options.debug ? ["--debug"] : [],
24778
25001
  ...options.json ? ["--json"] : []
@@ -33758,6 +33981,86 @@ Examples:
33758
33981
  }
33759
33982
 
33760
33983
  // src/cli/commands/org.ts
33984
+ var import_node_crypto9 = require("crypto");
33985
+ var import_node_fs16 = require("fs");
33986
+ var import_node_path18 = require("path");
33987
+ function pendingOrgCreatePath(baseUrl, accountId, sourceOrgId, name) {
33988
+ const intent = (0, import_node_crypto9.createHash)("sha256").update(accountId).update("\0").update(sourceOrgId).update("\0").update(name).digest("hex");
33989
+ return (0, import_node_path18.join)(sdkCliStateDirPath(baseUrl), `pending-org-create-${intent}.json`);
33990
+ }
33991
+ function readPendingOrgCreate(path, accountId, sourceOrgId, name) {
33992
+ let value;
33993
+ try {
33994
+ value = JSON.parse((0, import_node_fs16.readFileSync)(path, "utf8"));
33995
+ } catch (error) {
33996
+ throw new Error(
33997
+ `Cannot resume the pending workspace creation recorded at ${path}: ${error instanceof Error ? error.message : String(error)}`
33998
+ );
33999
+ }
34000
+ if (typeof value !== "object" || value === null || value.accountId !== accountId || value.sourceOrgId !== sourceOrgId || value.name !== name || typeof value.idempotencyKey !== "string" || !value.idempotencyKey.trim()) {
34001
+ throw new Error(
34002
+ `Cannot resume the pending workspace creation recorded at ${path}: the saved intent is invalid.`
34003
+ );
34004
+ }
34005
+ return value;
34006
+ }
34007
+ function loadOrCreatePendingOrgCreate(input2) {
34008
+ const stateDir = sdkCliStateDirPath(input2.baseUrl);
34009
+ const path = pendingOrgCreatePath(
34010
+ input2.baseUrl,
34011
+ input2.accountId,
34012
+ input2.sourceOrgId,
34013
+ input2.name
34014
+ );
34015
+ (0, import_node_fs16.mkdirSync)(stateDir, { recursive: true });
34016
+ if ((0, import_node_fs16.existsSync)(path)) {
34017
+ return {
34018
+ ...readPendingOrgCreate(
34019
+ path,
34020
+ input2.accountId,
34021
+ input2.sourceOrgId,
34022
+ input2.name
34023
+ ),
34024
+ path
34025
+ };
34026
+ }
34027
+ const pending = {
34028
+ accountId: input2.accountId,
34029
+ sourceOrgId: input2.sourceOrgId,
34030
+ name: input2.name,
34031
+ idempotencyKey: (0, import_node_crypto9.randomUUID)()
34032
+ };
34033
+ try {
34034
+ (0, import_node_fs16.writeFileSync)(path, `${JSON.stringify(pending)}
34035
+ `, {
34036
+ encoding: "utf8",
34037
+ flag: "wx",
34038
+ mode: 384
34039
+ });
34040
+ return { ...pending, path };
34041
+ } catch (error) {
34042
+ if (error.code !== "EEXIST") throw error;
34043
+ return {
34044
+ ...readPendingOrgCreate(
34045
+ path,
34046
+ input2.accountId,
34047
+ input2.sourceOrgId,
34048
+ input2.name
34049
+ ),
34050
+ path
34051
+ };
34052
+ }
34053
+ }
34054
+ async function fetchWorkspaceCreationIdentity(http, apiKey) {
34055
+ const status = await http.post("/api/v2/auth/cli/status", { api_key: apiKey });
34056
+ const accountId = status.user_id?.trim();
34057
+ if (!accountId) {
34058
+ throw new Error(
34059
+ "Workspace creation requires an API key linked to a user account."
34060
+ );
34061
+ }
34062
+ return { accountId, orgId: status.org_id?.trim() || null };
34063
+ }
33761
34064
  async function fetchOrganizations(http, apiKey) {
33762
34065
  return http.post("/api/v2/auth/cli/organizations", { api_key: apiKey });
33763
34066
  }
@@ -34226,23 +34529,58 @@ async function handleOrgSwitch(selection, options) {
34226
34529
  }
34227
34530
  async function handleOrgCreate(name, options) {
34228
34531
  const config = resolveConfig();
34532
+ const normalizedName = name.trim();
34533
+ if (!normalizedName) {
34534
+ throw new Error("Workspace name is required.");
34535
+ }
34229
34536
  const http = new HttpClient(config);
34230
- const created = await http.post("/api/v2/auth/cli/org-create", {
34231
- api_key: config.apiKey,
34232
- name
34233
- });
34537
+ const identity = await fetchWorkspaceCreationIdentity(http, config.apiKey);
34538
+ let created;
34539
+ let workspaceApiKey;
34540
+ let pendingIntentPath = null;
34541
+ if (!identity.orgId) {
34542
+ const firstWorkspace = await http.post("/api/v2/auth/cli/org-create", {
34543
+ api_key: config.apiKey,
34544
+ name: normalizedName
34545
+ });
34546
+ const { api_key: apiKey, ...publicFirstWorkspace } = firstWorkspace;
34547
+ workspaceApiKey = apiKey;
34548
+ created = publicFirstWorkspace;
34549
+ } else {
34550
+ const pending = loadOrCreatePendingOrgCreate({
34551
+ baseUrl: config.baseUrl,
34552
+ accountId: identity.accountId,
34553
+ sourceOrgId: identity.orgId,
34554
+ name: normalizedName
34555
+ });
34556
+ const workspace = await new DeeplineClient({
34557
+ apiKey: config.apiKey,
34558
+ baseUrl: config.baseUrl
34559
+ }).workspaces.create({
34560
+ name: normalizedName,
34561
+ idempotencyKey: pending.idempotencyKey
34562
+ });
34563
+ const switched = await http.post("/api/v2/auth/cli/switch", {
34564
+ api_key: config.apiKey,
34565
+ org_id: workspace.org_id
34566
+ });
34567
+ workspaceApiKey = switched.api_key;
34568
+ created = { ...workspace };
34569
+ pendingIntentPath = pending.path;
34570
+ }
34234
34571
  const authValues = organizationAuthValues({
34235
34572
  baseUrl: config.baseUrl,
34236
- apiKey: created.api_key,
34573
+ apiKey: workspaceApiKey,
34237
34574
  orgId: created.org_id,
34238
34575
  orgName: created.org_name
34239
34576
  });
34240
34577
  saveHostEnvValues(config.baseUrl, authValues);
34241
- const { api_key: _apiKey, ...publicCreated } = created;
34578
+ if (pendingIntentPath) (0, import_node_fs16.unlinkSync)(pendingIntentPath);
34242
34579
  printCommandEnvelope(
34243
34580
  {
34244
34581
  ok: true,
34245
- ...publicCreated,
34582
+ ...created,
34583
+ initial_credits: typeof created.initial_credits === "number" ? created.initial_credits : 0,
34246
34584
  api_key_saved: true,
34247
34585
  switched: true,
34248
34586
  host_env_path: hostEnvFilePath(config.baseUrl),
@@ -34325,9 +34663,9 @@ Examples:
34325
34663
  "after",
34326
34664
  `
34327
34665
  Notes:
34328
- Mutates workspace state. The new organization is created for the current
34329
- authenticated user, then the returned API key is saved for this host so later
34330
- CLI commands target the new organization.
34666
+ Mutates workspace and billing state. The new organization is created for the
34667
+ current authenticated user and provisioned on the active PAYG offer before
34668
+ this CLI switches to it. Interrupted requests resume automatically.
34331
34669
 
34332
34670
  Examples:
34333
34671
  deepline org create Acme
@@ -34784,38 +35122,38 @@ Examples:
34784
35122
 
34785
35123
  // src/cli/commands/setup.ts
34786
35124
  var import_node_child_process4 = require("child_process");
34787
- var import_node_fs19 = require("fs");
35125
+ var import_node_fs20 = require("fs");
34788
35126
  var import_node_os13 = require("os");
34789
- var import_node_path21 = require("path");
35127
+ var import_node_path22 = require("path");
34790
35128
 
34791
35129
  // src/cli/installation-lifecycle.ts
34792
- var import_node_fs16 = require("fs");
34793
- var import_node_path18 = require("path");
35130
+ var import_node_fs17 = require("fs");
35131
+ var import_node_path19 = require("path");
34794
35132
  var nodeFileSystem = {
34795
- exists: import_node_fs16.existsSync,
35133
+ exists: import_node_fs17.existsSync,
34796
35134
  isSymbolicLink(path) {
34797
35135
  try {
34798
- return (0, import_node_fs16.lstatSync)(path).isSymbolicLink();
35136
+ return (0, import_node_fs17.lstatSync)(path).isSymbolicLink();
34799
35137
  } catch {
34800
35138
  return false;
34801
35139
  }
34802
35140
  },
34803
35141
  read(path) {
34804
35142
  try {
34805
- return (0, import_node_fs16.readFileSync)(path, "utf8");
35143
+ return (0, import_node_fs17.readFileSync)(path, "utf8");
34806
35144
  } catch {
34807
35145
  return "";
34808
35146
  }
34809
35147
  },
34810
35148
  realpath(path) {
34811
35149
  try {
34812
- return (0, import_node_fs16.realpathSync)(path);
35150
+ return (0, import_node_fs17.realpathSync)(path);
34813
35151
  } catch {
34814
35152
  return null;
34815
35153
  }
34816
35154
  },
34817
35155
  remove(path) {
34818
- (0, import_node_fs16.rmSync)(path, { force: true });
35156
+ (0, import_node_fs17.rmSync)(path, { force: true });
34819
35157
  }
34820
35158
  };
34821
35159
  function inspectLauncher(path, fileSystem = nodeFileSystem) {
@@ -34846,25 +35184,25 @@ var CliInstallation = class _CliInstallation {
34846
35184
  });
34847
35185
  }
34848
35186
  static isNpmPackagePath(path) {
34849
- return path?.includes(`${(0, import_node_path18.join)("node_modules", "deepline")}`) ?? false;
35187
+ return path?.includes(`${(0, import_node_path19.join)("node_modules", "deepline")}`) ?? false;
34850
35188
  }
34851
35189
  launcher(path) {
34852
35190
  return inspectLauncher(path, this.input.fileSystem);
34853
35191
  }
34854
35192
  retiredArtifacts() {
34855
- const hostDir = (0, import_node_path18.join)(
35193
+ const hostDir = (0, import_node_path19.join)(
34856
35194
  this.input.home,
34857
35195
  ".local",
34858
35196
  "deepline",
34859
35197
  this.input.baseUrlSlug
34860
35198
  );
34861
- const legacyLauncherPath = (0, import_node_path18.join)(
35199
+ const legacyLauncherPath = (0, import_node_path19.join)(
34862
35200
  this.input.home,
34863
35201
  ".local",
34864
35202
  "bin",
34865
35203
  "deepline"
34866
35204
  );
34867
- const installerCommandPath = this.input.fileSystem.read((0, import_node_path18.join)(hostDir, "sdk", ".command-path")).trim();
35205
+ const installerCommandPath = this.input.fileSystem.read((0, import_node_path19.join)(hostDir, "sdk", ".command-path")).trim();
34868
35206
  const ownedInstallerCommand = isOwnedInstallerCommandPath({
34869
35207
  hostDir,
34870
35208
  commandPath: installerCommandPath
@@ -34872,16 +35210,16 @@ var CliInstallation = class _CliInstallation {
34872
35210
  const legacyLauncher = this.launcher(legacyLauncherPath);
34873
35211
  const candidates = [
34874
35212
  ...legacyLauncher.ownership === "installer_legacy" ? [legacyLauncherPath] : [],
34875
- (0, import_node_path18.join)(this.input.home, ".local", "bin", "deepline-real"),
34876
- (0, import_node_path18.join)(hostDir, "bin", "deepline"),
34877
- (0, import_node_path18.join)(hostDir, "bin", "deepline-real"),
34878
- (0, import_node_path18.join)(hostDir, "cli", ".install-method"),
34879
- (0, import_node_path18.join)(hostDir, "cli", ".version"),
34880
- (0, import_node_path18.join)(hostDir, "sdk", ".install-method"),
34881
- (0, import_node_path18.join)(hostDir, "sdk", ".command-path"),
35213
+ (0, import_node_path19.join)(this.input.home, ".local", "bin", "deepline-real"),
35214
+ (0, import_node_path19.join)(hostDir, "bin", "deepline"),
35215
+ (0, import_node_path19.join)(hostDir, "bin", "deepline-real"),
35216
+ (0, import_node_path19.join)(hostDir, "cli", ".install-method"),
35217
+ (0, import_node_path19.join)(hostDir, "cli", ".version"),
35218
+ (0, import_node_path19.join)(hostDir, "sdk", ".install-method"),
35219
+ (0, import_node_path19.join)(hostDir, "sdk", ".command-path"),
34882
35220
  ...ownedInstallerCommand ? [
34883
35221
  installerCommandPath,
34884
- (0, import_node_path18.join)((0, import_node_path18.dirname)(installerCommandPath), "deepline-sdk")
35222
+ (0, import_node_path19.join)((0, import_node_path19.dirname)(installerCommandPath), "deepline-sdk")
34885
35223
  ] : []
34886
35224
  ];
34887
35225
  return {
@@ -34902,19 +35240,19 @@ function removeArtifacts(plan, fileSystem) {
34902
35240
  return plan.paths;
34903
35241
  }
34904
35242
  function isOwnedInstallerCommandPath(input2) {
34905
- if (!input2.commandPath || (0, import_node_path18.basename)(input2.commandPath) !== "deepline") {
35243
+ if (!input2.commandPath || (0, import_node_path19.basename)(input2.commandPath) !== "deepline") {
34906
35244
  return false;
34907
35245
  }
34908
- const commandPath = (0, import_node_path18.resolve)(input2.commandPath);
34909
- const fromHost = (0, import_node_path18.relative)((0, import_node_path18.resolve)(input2.hostDir), commandPath);
35246
+ const commandPath = (0, import_node_path19.resolve)(input2.commandPath);
35247
+ const fromHost = (0, import_node_path19.relative)((0, import_node_path19.resolve)(input2.hostDir), commandPath);
34910
35248
  return fromHost !== "" && fromHost !== ".." && !fromHost.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`);
34911
35249
  }
34912
35250
 
34913
35251
  // src/cli/commands/skills.ts
34914
35252
  var import_node_child_process3 = require("child_process");
34915
- var import_node_fs18 = require("fs");
35253
+ var import_node_fs19 = require("fs");
34916
35254
  var import_node_os12 = require("os");
34917
- var import_node_path20 = require("path");
35255
+ var import_node_path21 = require("path");
34918
35256
 
34919
35257
  // ../../shared_libs/cli/install-commands.json
34920
35258
  var install_commands_default = {
@@ -35024,8 +35362,8 @@ function buildSkillsAddArgs(baseUrl, skillName, options = {}) {
35024
35362
 
35025
35363
  // src/cli/skills-sync.ts
35026
35364
  var import_node_child_process2 = require("child_process");
35027
- var import_node_fs17 = require("fs");
35028
- var import_node_path19 = require("path");
35365
+ var import_node_fs18 = require("fs");
35366
+ var import_node_path20 = require("path");
35029
35367
 
35030
35368
  // src/cli/windows-arg-escape.ts
35031
35369
  var CMD_META_CHARS = /([()\][%!^"`<>&|;, *?])/g;
@@ -35372,10 +35710,10 @@ function shouldSkipSkillsSync() {
35372
35710
  return value === "1" || value === "true" || value === "yes" || value === "on";
35373
35711
  }
35374
35712
  function unavailableSkillsNoticePath(baseUrl) {
35375
- return (0, import_node_path19.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
35713
+ return (0, import_node_path20.join)(sdkCliStateDirPath(baseUrl), "skills-sync-unavailable-version");
35376
35714
  }
35377
35715
  function failedSkillsSyncPath(baseUrl, agents) {
35378
- return (0, import_node_path19.join)(
35716
+ return (0, import_node_path20.join)(
35379
35717
  sdkCliStateDirPath(baseUrl),
35380
35718
  `skills-sync-failed-${agents.join("-")}-version`
35381
35719
  );
@@ -35385,15 +35723,15 @@ function hasMarkedSkillsSyncVersion(path, version) {
35385
35723
  }
35386
35724
  function readMarkedSkillsSyncVersion(path) {
35387
35725
  try {
35388
- return (0, import_node_fs17.existsSync)(path) ? (0, import_node_fs17.readFileSync)(path, "utf-8").trim() : "";
35726
+ return (0, import_node_fs18.existsSync)(path) ? (0, import_node_fs18.readFileSync)(path, "utf-8").trim() : "";
35389
35727
  } catch {
35390
35728
  return "";
35391
35729
  }
35392
35730
  }
35393
35731
  function writeMarkedSkillsSyncVersion(path, version) {
35394
35732
  try {
35395
- (0, import_node_fs17.mkdirSync)((0, import_node_path19.dirname)(path), { recursive: true });
35396
- (0, import_node_fs17.writeFileSync)(path, `${version}
35733
+ (0, import_node_fs18.mkdirSync)((0, import_node_path20.dirname)(path), { recursive: true });
35734
+ (0, import_node_fs18.writeFileSync)(path, `${version}
35397
35735
  `, "utf-8");
35398
35736
  return true;
35399
35737
  } catch {
@@ -35412,7 +35750,7 @@ ${manualCommand}`
35412
35750
  }
35413
35751
  function clearUnavailableSkillsNotice(baseUrl) {
35414
35752
  try {
35415
- (0, import_node_fs17.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
35753
+ (0, import_node_fs18.unlinkSync)(unavailableSkillsNoticePath(baseUrl));
35416
35754
  } catch {
35417
35755
  }
35418
35756
  }
@@ -35423,7 +35761,7 @@ function hasFailedSkillsSync(baseUrl, remoteVersion, agents) {
35423
35761
  );
35424
35762
  }
35425
35763
  function hasFailedAutomaticSkillsSync(baseUrl, agents) {
35426
- return (0, import_node_fs17.existsSync)(failedSkillsSyncPath(baseUrl, agents));
35764
+ return (0, import_node_fs18.existsSync)(failedSkillsSyncPath(baseUrl, agents));
35427
35765
  }
35428
35766
  function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
35429
35767
  return writeMarkedSkillsSyncVersion(
@@ -35433,7 +35771,7 @@ function markFailedSkillsSync(baseUrl, remoteVersion, agents) {
35433
35771
  }
35434
35772
  function clearFailedSkillsSync(baseUrl, agents) {
35435
35773
  try {
35436
- (0, import_node_fs17.unlinkSync)(failedSkillsSyncPath(baseUrl, agents));
35774
+ (0, import_node_fs18.unlinkSync)(failedSkillsSyncPath(baseUrl, agents));
35437
35775
  } catch {
35438
35776
  }
35439
35777
  }
@@ -35800,13 +36138,13 @@ function detectSkillsAgents(input2) {
35800
36138
  ];
35801
36139
  const detected = AGENT_MARKERS.filter(
35802
36140
  (marker) => roots.some(
35803
- (root) => marker.paths.some((path) => (0, import_node_fs18.existsSync)((0, import_node_path20.join)(root, path)))
36141
+ (root) => marker.paths.some((path) => (0, import_node_fs19.existsSync)((0, import_node_path21.join)(root, path)))
35804
36142
  )
35805
36143
  ).map((marker) => marker.agent);
35806
36144
  return detected.length > 0 ? detected : ["*"];
35807
36145
  }
35808
36146
  function skillsStatePathForScope(baseUrl, scope, root) {
35809
- return scope === "local" && root ? (0, import_node_path20.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path20.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
36147
+ return scope === "local" && root ? (0, import_node_path21.join)(root, ".deepline", "setup", "skills.json") : (0, import_node_path21.join)(sdkCliStateDirPath(baseUrl), "skills-install.json");
35810
36148
  }
35811
36149
  function buildSkillsPlan(input2) {
35812
36150
  const scopeArgs = input2.scope === "global" ? ["--global"] : [];
@@ -35873,7 +36211,7 @@ function isSkillsPlanCurrent(plan, state) {
35873
36211
  }
35874
36212
  function readSkillsInstallState(path) {
35875
36213
  try {
35876
- const parsed = JSON.parse((0, import_node_fs18.readFileSync)(path, "utf8"));
36214
+ const parsed = JSON.parse((0, import_node_fs19.readFileSync)(path, "utf8"));
35877
36215
  return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
35878
36216
  } catch {
35879
36217
  return null;
@@ -36026,8 +36364,8 @@ async function runSkillsCommand(options, dependencies = {}) {
36026
36364
  `
36027
36365
  );
36028
36366
  }
36029
- (0, import_node_fs18.mkdirSync)((0, import_node_path20.dirname)(plan.statePath), { recursive: true });
36030
- (0, import_node_fs18.writeFileSync)(
36367
+ (0, import_node_fs19.mkdirSync)((0, import_node_path21.dirname)(plan.statePath), { recursive: true });
36368
+ (0, import_node_fs19.writeFileSync)(
36031
36369
  plan.statePath,
36032
36370
  `${JSON.stringify(
36033
36371
  {
@@ -36165,7 +36503,7 @@ function phasesFromLegacyStatus(status) {
36165
36503
  function readSetupState(input2) {
36166
36504
  try {
36167
36505
  const parsed = JSON.parse(
36168
- (0, import_node_fs19.readFileSync)(
36506
+ (0, import_node_fs20.readFileSync)(
36169
36507
  setupStatePath(input2.baseUrl, input2.scope, input2.root),
36170
36508
  "utf8"
36171
36509
  )
@@ -36241,7 +36579,7 @@ function buildPendingAuthorizationOutput(input2) {
36241
36579
  };
36242
36580
  }
36243
36581
  function setupStatePath(baseUrl, scope, root) {
36244
- return scope === "local" && root ? (0, import_node_path21.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path21.join)(sdkCliStateDirPath(baseUrl), "setup.json");
36582
+ return scope === "local" && root ? (0, import_node_path22.join)(root, ".deepline", "setup", "state.json") : (0, import_node_path22.join)(sdkCliStateDirPath(baseUrl), "setup.json");
36245
36583
  }
36246
36584
  async function captureStdout2(run) {
36247
36585
  let stdout = "";
@@ -36270,7 +36608,7 @@ function asRecord3(value) {
36270
36608
  }
36271
36609
  function safeRead(path) {
36272
36610
  try {
36273
- return (0, import_node_fs19.readFileSync)(path, "utf8");
36611
+ return (0, import_node_fs20.readFileSync)(path, "utf8");
36274
36612
  } catch {
36275
36613
  return "";
36276
36614
  }
@@ -36289,7 +36627,7 @@ function resolvePathCommands(command) {
36289
36627
  );
36290
36628
  return [
36291
36629
  ...new Set(
36292
- String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path21.resolve)(path))
36630
+ String(lookup.stdout ?? "").split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((path) => (0, import_node_path22.resolve)(path))
36293
36631
  )
36294
36632
  ];
36295
36633
  }
@@ -36299,7 +36637,7 @@ function resolvePathCommand(command) {
36299
36637
  function isHomebrewFormulaCommand(path) {
36300
36638
  let resolvedPath = path;
36301
36639
  try {
36302
- resolvedPath = (0, import_node_fs19.realpathSync)(path);
36640
+ resolvedPath = (0, import_node_fs20.realpathSync)(path);
36303
36641
  } catch {
36304
36642
  return false;
36305
36643
  }
@@ -36310,7 +36648,7 @@ function isHomebrewFormulaCommand(path) {
36310
36648
  function resolvePersistentGlobalCommand(dependencies = {}) {
36311
36649
  const platform3 = dependencies.platform ?? process.platform;
36312
36650
  const run = dependencies.spawn ?? import_node_child_process4.spawnSync;
36313
- const pathExists = dependencies.exists ?? import_node_fs19.existsSync;
36651
+ const pathExists = dependencies.exists ?? import_node_fs20.existsSync;
36314
36652
  const pathClis = dependencies.pathClis ?? resolvePathCommands("deepline");
36315
36653
  const homebrewCommand = pathClis.find(isHomebrewFormulaCommand);
36316
36654
  if (homebrewCommand) return homebrewCommand;
@@ -36322,7 +36660,7 @@ function resolvePersistentGlobalCommand(dependencies = {}) {
36322
36660
  if (prefix.status !== 0) return null;
36323
36661
  const root = String(prefix.stdout ?? "").trim();
36324
36662
  if (!root) return null;
36325
- const candidates = platform3 === "win32" ? [(0, import_node_path21.join)(root, "deepline.cmd"), (0, import_node_path21.join)(root, "deepline")] : [(0, import_node_path21.join)(root, "bin", "deepline")];
36663
+ const candidates = platform3 === "win32" ? [(0, import_node_path22.join)(root, "deepline.cmd"), (0, import_node_path22.join)(root, "deepline")] : [(0, import_node_path22.join)(root, "bin", "deepline")];
36326
36664
  return candidates.find((candidate) => pathExists(candidate)) ?? null;
36327
36665
  }
36328
36666
  function inspectGlobalCliAvailability(input2) {
@@ -36335,20 +36673,20 @@ function inspectGlobalCliAvailability(input2) {
36335
36673
  }
36336
36674
  function pathsResolveToSameFile(left, right) {
36337
36675
  try {
36338
- return (0, import_node_fs19.realpathSync)(left) === (0, import_node_fs19.realpathSync)(right);
36676
+ return (0, import_node_fs20.realpathSync)(left) === (0, import_node_fs20.realpathSync)(right);
36339
36677
  } catch {
36340
- return (0, import_node_path21.resolve)(left) === (0, import_node_path21.resolve)(right);
36678
+ return (0, import_node_path22.resolve)(left) === (0, import_node_path22.resolve)(right);
36341
36679
  }
36342
36680
  }
36343
36681
  function isKnownDeeplineCommand(path) {
36344
- const entrypoint = process.argv[1] ? (0, import_node_path21.resolve)(process.argv[1]) : "";
36682
+ const entrypoint = process.argv[1] ? (0, import_node_path22.resolve)(process.argv[1]) : "";
36345
36683
  let resolvedPath = path;
36346
36684
  try {
36347
- resolvedPath = (0, import_node_fs19.realpathSync)(path);
36685
+ resolvedPath = (0, import_node_fs20.realpathSync)(path);
36348
36686
  } catch {
36349
36687
  }
36350
36688
  if (entrypoint && resolvedPath === entrypoint) return true;
36351
- if (resolvedPath.includes(`${(0, import_node_path21.join)("node_modules", "deepline")}`)) return true;
36689
+ if (resolvedPath.includes(`${(0, import_node_path22.join)("node_modules", "deepline")}`)) return true;
36352
36690
  const content = safeRead(path);
36353
36691
  return content.includes("node_modules/deepline") || content.includes("node_modules\\deepline") || content.includes("DEEPLINE_CONFIG_SCOPE") || content.includes("deepline-real");
36354
36692
  }
@@ -36356,9 +36694,9 @@ function inspectPathConflict() {
36356
36694
  const commandPath = resolvePathCommand("deepline");
36357
36695
  if (!commandPath || isKnownDeeplineCommand(commandPath)) return null;
36358
36696
  try {
36359
- if ((0, import_node_fs19.lstatSync)(commandPath).isSymbolicLink()) {
36360
- const target = (0, import_node_fs19.realpathSync)(commandPath);
36361
- if (target.includes(`${(0, import_node_path21.join)("node_modules", "deepline")}`)) return null;
36697
+ if ((0, import_node_fs20.lstatSync)(commandPath).isSymbolicLink()) {
36698
+ const target = (0, import_node_fs20.realpathSync)(commandPath);
36699
+ if (target.includes(`${(0, import_node_path22.join)("node_modules", "deepline")}`)) return null;
36362
36700
  }
36363
36701
  } catch {
36364
36702
  }
@@ -36366,8 +36704,8 @@ function inspectPathConflict() {
36366
36704
  }
36367
36705
  function writeSetupState(input2) {
36368
36706
  const path = setupStatePath(input2.baseUrl, input2.scope, input2.root);
36369
- (0, import_node_fs19.mkdirSync)((0, import_node_path21.dirname)(path), { recursive: true });
36370
- (0, import_node_fs19.writeFileSync)(
36707
+ (0, import_node_fs20.mkdirSync)((0, import_node_path22.dirname)(path), { recursive: true });
36708
+ (0, import_node_fs20.writeFileSync)(
36371
36709
  path,
36372
36710
  `${JSON.stringify(
36373
36711
  {
@@ -36407,7 +36745,7 @@ function failSetupPhase(phases, phase, code) {
36407
36745
  phases[phase] = { status: "failed", code };
36408
36746
  }
36409
36747
  function rollbackCommand(scope, root) {
36410
- const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path21.join)(root, ".deepline", "runtime"))}` : "";
36748
+ const prefix = scope === "local" && root ? ` --prefix ${JSON.stringify((0, import_node_path22.join)(root, ".deepline", "runtime"))}` : "";
36411
36749
  return `npm install -g${prefix} --no-audit --no-fund --include=optional --allow-scripts=esbuild deepline@${SDK_VERSION}`;
36412
36750
  }
36413
36751
  function setupResumeCommand(baseUrl, scope) {
@@ -36494,12 +36832,12 @@ function buildDoctorAssessment(input2) {
36494
36832
  const connected = input2.authStatus.payload?.connected === true;
36495
36833
  const authScopeOk = input2.scope === "local" ? Boolean(projectAuth) : Boolean(apiKey && !projectAuth);
36496
36834
  const skillsOk = skillsState?.scope === input2.scope && typeof skillsState.skillsVersion === "string" && Array.isArray(skillsState.agents) && skillsState.agents.length > 0;
36497
- const runningCliPath = process.argv[1] ? (0, import_node_path21.resolve)(process.argv[1]) : null;
36835
+ const runningCliPath = process.argv[1] ? (0, import_node_path22.resolve)(process.argv[1]) : null;
36498
36836
  const globalCli = input2.scope === "global" ? inspectGlobalCliAvailability() : null;
36499
36837
  const pathGlobalCli = globalCli?.path ?? null;
36500
36838
  const cliPath = input2.scope === "global" ? pathGlobalCli : runningCliPath;
36501
36839
  const cliScopeOk = input2.scope === "global" ? Boolean(pathGlobalCli) : Boolean(
36502
- input2.root && runningCliPath?.includes((0, import_node_path21.join)(input2.root, ".deepline", "runtime"))
36840
+ input2.root && runningCliPath?.includes((0, import_node_path22.join)(input2.root, ".deepline", "runtime"))
36503
36841
  );
36504
36842
  const checks = {
36505
36843
  cli: {
@@ -37031,9 +37369,9 @@ Examples:
37031
37369
  }
37032
37370
 
37033
37371
  // src/cli/update-preferences.ts
37034
- var import_node_fs20 = require("fs");
37372
+ var import_node_fs21 = require("fs");
37035
37373
  var import_node_os14 = require("os");
37036
- var import_node_path22 = require("path");
37374
+ var import_node_path23 = require("path");
37037
37375
  var UPDATE_PREFERENCES_SCHEMA_VERSION = 1;
37038
37376
  var CLI_UPDATE_MESSAGES = [
37039
37377
  {
@@ -37062,7 +37400,7 @@ function unreadablePreferences(path, error) {
37062
37400
  };
37063
37401
  }
37064
37402
  function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os14.homedir)()) {
37065
- return (0, import_node_path22.join)(
37403
+ return (0, import_node_path23.join)(
37066
37404
  homeDir2,
37067
37405
  ".local",
37068
37406
  "deepline",
@@ -37072,9 +37410,9 @@ function cliUpdatePreferencesPath(homeDir2 = (0, import_node_os14.homedir)()) {
37072
37410
  }
37073
37411
  function readCliUpdatePreferences(homeDir2 = (0, import_node_os14.homedir)()) {
37074
37412
  const path = cliUpdatePreferencesPath(homeDir2);
37075
- if (!(0, import_node_fs20.existsSync)(path)) return defaultPreferences();
37413
+ if (!(0, import_node_fs21.existsSync)(path)) return defaultPreferences();
37076
37414
  try {
37077
- const parsed = JSON.parse((0, import_node_fs20.readFileSync)(path, "utf8"));
37415
+ const parsed = JSON.parse((0, import_node_fs21.readFileSync)(path, "utf8"));
37078
37416
  return {
37079
37417
  schemaVersion: UPDATE_PREFERENCES_SCHEMA_VERSION,
37080
37418
  autoUpdateEnabled: typeof parsed.autoUpdateEnabled === "boolean" ? parsed.autoUpdateEnabled : true,
@@ -37090,16 +37428,16 @@ function readCliUpdatePreferences(homeDir2 = (0, import_node_os14.homedir)()) {
37090
37428
  function writeCliUpdatePreferences(preferences, homeDir2 = (0, import_node_os14.homedir)()) {
37091
37429
  const path = cliUpdatePreferencesPath(homeDir2);
37092
37430
  const tempPath = `${path}.${process.pid}.tmp`;
37093
- (0, import_node_fs20.mkdirSync)((0, import_node_path22.dirname)(path), { recursive: true });
37431
+ (0, import_node_fs21.mkdirSync)((0, import_node_path23.dirname)(path), { recursive: true });
37094
37432
  try {
37095
- (0, import_node_fs20.writeFileSync)(tempPath, `${JSON.stringify(preferences, null, 2)}
37433
+ (0, import_node_fs21.writeFileSync)(tempPath, `${JSON.stringify(preferences, null, 2)}
37096
37434
  `, {
37097
37435
  encoding: "utf8",
37098
37436
  mode: 384
37099
37437
  });
37100
- (0, import_node_fs20.renameSync)(tempPath, path);
37438
+ (0, import_node_fs21.renameSync)(tempPath, path);
37101
37439
  } finally {
37102
- (0, import_node_fs20.rmSync)(tempPath, { force: true });
37440
+ (0, import_node_fs21.rmSync)(tempPath, { force: true });
37103
37441
  }
37104
37442
  }
37105
37443
  function setCliAutoUpdateEnabled(enabled, homeDir2 = (0, import_node_os14.homedir)()) {
@@ -37149,14 +37487,14 @@ function consumePendingCliUpdateMessages(homeDir2 = (0, import_node_os14.homedir
37149
37487
 
37150
37488
  // src/cli/commands/update.ts
37151
37489
  var import_node_child_process5 = require("child_process");
37152
- var import_node_fs22 = require("fs");
37490
+ var import_node_fs23 = require("fs");
37153
37491
  var import_node_os15 = require("os");
37154
- var import_node_path24 = require("path");
37492
+ var import_node_path25 = require("path");
37155
37493
 
37156
37494
  // src/cli/install-integrity.ts
37157
37495
  var import_node_module2 = require("module");
37158
- var import_node_fs21 = require("fs");
37159
- var import_node_path23 = require("path");
37496
+ var import_node_fs22 = require("fs");
37497
+ var import_node_path24 = require("path");
37160
37498
  var SDK_SIDECAR_CRITICAL_PACKAGE_FILES = [
37161
37499
  "dist/cli/index.mjs",
37162
37500
  "dist/index.mjs",
@@ -37173,7 +37511,7 @@ var SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES = [
37173
37511
  "esbuild/lib/main.js"
37174
37512
  ];
37175
37513
  function safeRelativePath(value) {
37176
- if (typeof value !== "string" || !value || (0, import_node_path23.isAbsolute)(value)) return false;
37514
+ if (typeof value !== "string" || !value || (0, import_node_path24.isAbsolute)(value)) return false;
37177
37515
  const segments = value.split(/[\\/]+/);
37178
37516
  return segments.every(
37179
37517
  (segment) => Boolean(segment) && segment !== "." && segment !== ".."
@@ -37181,25 +37519,25 @@ function safeRelativePath(value) {
37181
37519
  }
37182
37520
  function resolveContainedPath(root, value) {
37183
37521
  if (!safeRelativePath(value)) return null;
37184
- const target = (0, import_node_path23.resolve)(root, value);
37185
- const relativeTarget = (0, import_node_path23.relative)((0, import_node_path23.resolve)(root), target);
37186
- if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path23.isAbsolute)(relativeTarget)) {
37522
+ const target = (0, import_node_path24.resolve)(root, value);
37523
+ const relativeTarget = (0, import_node_path24.relative)((0, import_node_path24.resolve)(root), target);
37524
+ if (!relativeTarget || relativeTarget.startsWith("..") || (0, import_node_path24.isAbsolute)(relativeTarget)) {
37187
37525
  return null;
37188
37526
  }
37189
37527
  return target;
37190
37528
  }
37191
37529
  function parseJson(path) {
37192
- return JSON.parse((0, import_node_fs21.readFileSync)(path, "utf8"));
37530
+ return JSON.parse((0, import_node_fs22.readFileSync)(path, "utf8"));
37193
37531
  }
37194
37532
  function isFile(path) {
37195
37533
  try {
37196
- return (0, import_node_fs21.statSync)(path).isFile();
37534
+ return (0, import_node_fs22.statSync)(path).isFile();
37197
37535
  } catch {
37198
37536
  return false;
37199
37537
  }
37200
37538
  }
37201
37539
  function readManifest(packageRoot) {
37202
- const packageJsonPath = (0, import_node_path23.join)(packageRoot, "package.json");
37540
+ const packageJsonPath = (0, import_node_path24.join)(packageRoot, "package.json");
37203
37541
  let packageJson;
37204
37542
  try {
37205
37543
  packageJson = parseJson(packageJsonPath);
@@ -37207,7 +37545,7 @@ function readManifest(packageRoot) {
37207
37545
  return {
37208
37546
  mode: "manifest",
37209
37547
  invalidReason: `invalid Deepline package metadata: ${error.message}`,
37210
- missing: (0, import_node_fs21.existsSync)(packageJsonPath) ? [] : ["deepline/package.json"]
37548
+ missing: (0, import_node_fs22.existsSync)(packageJsonPath) ? [] : ["deepline/package.json"]
37211
37549
  };
37212
37550
  }
37213
37551
  if (!packageJson || typeof packageJson !== "object" || Array.isArray(packageJson)) {
@@ -37273,8 +37611,8 @@ function readManifest(packageRoot) {
37273
37611
  return { mode: "manifest", manifest };
37274
37612
  }
37275
37613
  function inspectSdkSidecarInstall(versionDir) {
37276
- const nodeModulesRoot = (0, import_node_path23.join)(versionDir, "node_modules");
37277
- const packageRoot = (0, import_node_path23.join)(nodeModulesRoot, "deepline");
37614
+ const nodeModulesRoot = (0, import_node_path24.join)(versionDir, "node_modules");
37615
+ const packageRoot = (0, import_node_path24.join)(nodeModulesRoot, "deepline");
37278
37616
  const manifestResult = readManifest(packageRoot);
37279
37617
  if ("invalidReason" in manifestResult) {
37280
37618
  return {
@@ -37285,8 +37623,8 @@ function inspectSdkSidecarInstall(versionDir) {
37285
37623
  };
37286
37624
  }
37287
37625
  const missing = [
37288
- ...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path23.join)(packageRoot, path))).map((path) => `deepline/${path}`),
37289
- ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path23.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
37626
+ ...manifestResult.manifest.packageFiles.filter((path) => !isFile((0, import_node_path24.join)(packageRoot, path))).map((path) => `deepline/${path}`),
37627
+ ...manifestResult.manifest.dependencyFiles.filter((path) => !isFile((0, import_node_path24.join)(nodeModulesRoot, path))).map((path) => `node_modules/${path}`)
37290
37628
  ];
37291
37629
  return {
37292
37630
  ok: missing.length === 0,
@@ -37297,7 +37635,7 @@ function inspectSdkSidecarInstall(versionDir) {
37297
37635
  }
37298
37636
  function probeSdkSidecarEsbuild(versionDir) {
37299
37637
  try {
37300
- const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path23.join)(versionDir, "package.json"));
37638
+ const requireFromInstall = (0, import_node_module2.createRequire)((0, import_node_path24.join)(versionDir, "package.json"));
37301
37639
  const esbuild = requireFromInstall("esbuild");
37302
37640
  if (typeof esbuild.transformSync !== "function") {
37303
37641
  return "esbuild does not export transformSync";
@@ -37372,7 +37710,7 @@ function sidecarStateDir(input2) {
37372
37710
  if (!scope || scope.includes("/") || scope.includes("\\")) {
37373
37711
  return null;
37374
37712
  }
37375
- return (0, import_node_path24.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
37713
+ return (0, import_node_path25.join)(input2.homeDir, ".local", "deepline", scope, "sdk-cli");
37376
37714
  }
37377
37715
  function sidecarRegistryUrl(hostUrl) {
37378
37716
  let url;
@@ -37399,7 +37737,7 @@ function publicNpmFallbackRegistryUrl(hostUrl) {
37399
37737
  }
37400
37738
  function readOptionalText(path) {
37401
37739
  try {
37402
- return (0, import_node_fs22.readFileSync)(path, "utf8").trim();
37740
+ return (0, import_node_fs23.readFileSync)(path, "utf8").trim();
37403
37741
  } catch {
37404
37742
  return "";
37405
37743
  }
@@ -37407,19 +37745,19 @@ function readOptionalText(path) {
37407
37745
  function resolvePythonSidecarUpdatePlan(options) {
37408
37746
  const stateDir = sidecarStateDir(options);
37409
37747
  if (!stateDir) return null;
37410
- const relativeEntrypoint = (0, import_node_path24.relative)(
37411
- (0, import_node_path24.resolve)(stateDir),
37412
- (0, import_node_path24.resolve)(options.entrypoint)
37748
+ const relativeEntrypoint = (0, import_node_path25.relative)(
37749
+ (0, import_node_path25.resolve)(stateDir),
37750
+ (0, import_node_path25.resolve)(options.entrypoint)
37413
37751
  );
37414
- if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path24.isAbsolute)(relativeEntrypoint)) {
37752
+ if (!relativeEntrypoint || relativeEntrypoint.startsWith("..") || (0, import_node_path25.isAbsolute)(relativeEntrypoint)) {
37415
37753
  return null;
37416
37754
  }
37417
- const installMethod = readOptionalText((0, import_node_path24.join)(stateDir, ".install-method"));
37755
+ const installMethod = readOptionalText((0, import_node_path25.join)(stateDir, ".install-method"));
37418
37756
  if (installMethod !== "python-sidecar") return null;
37419
37757
  const scope = options.env.DEEPLINE_CONFIG_SCOPE?.trim() || "";
37420
37758
  const hostUrl = options.env.DEEPLINE_HOST_URL?.trim() || "";
37421
- const nodeBin = readOptionalText((0, import_node_path24.join)(stateDir, ".node-bin")) || process.execPath;
37422
- const sidecarPath = readOptionalText((0, import_node_path24.join)(stateDir, ".command-path")) || (0, import_node_path24.join)(
37759
+ const nodeBin = readOptionalText((0, import_node_path25.join)(stateDir, ".node-bin")) || process.execPath;
37760
+ const sidecarPath = readOptionalText((0, import_node_path25.join)(stateDir, ".command-path")) || (0, import_node_path25.join)(
37423
37761
  stateDir,
37424
37762
  "bin",
37425
37763
  process.platform === "win32" ? "deepline-sdk.cmd" : "deepline-sdk"
@@ -37427,7 +37765,7 @@ function resolvePythonSidecarUpdatePlan(options) {
37427
37765
  const packageSpec = options.packageSpec || "deepline@latest";
37428
37766
  const npmCommand = "npm";
37429
37767
  const registryUrl = sidecarRegistryUrl(hostUrl);
37430
- const versionDir = (0, import_node_path24.join)(stateDir, "versions", "<version>");
37768
+ const versionDir = (0, import_node_path25.join)(stateDir, "versions", "<version>");
37431
37769
  const manualCommand = `${buildSidecarProjectConfigCommand(versionDir, nodeBin)} && ${npmCommand} install --prefix ${shellQuote4(versionDir)} --registry ${shellQuote4(registryUrl)} ${NPM_SDK_INSTALL_COMMON_FLAGS.map(shellQuote4).join(" ")} ${shellQuote4(packageSpec)}`;
37432
37770
  return {
37433
37771
  kind: "python-sidecar",
@@ -37443,16 +37781,16 @@ function resolvePythonSidecarUpdatePlan(options) {
37443
37781
  };
37444
37782
  }
37445
37783
  function findRepoBackedSdkRoot(startPath) {
37446
- let current = (0, import_node_path24.resolve)(startPath);
37784
+ let current = (0, import_node_path25.resolve)(startPath);
37447
37785
  while (true) {
37448
- if ((0, import_node_fs22.existsSync)((0, import_node_path24.join)(current, "package.json")) && (0, import_node_fs22.existsSync)((0, import_node_path24.join)(current, "bin", "deepline-dev.ts"))) {
37449
- const parent2 = (0, import_node_path24.dirname)(current);
37450
- return (0, import_node_path24.basename)(parent2) === "packages" && (0, import_node_path24.basename)(current) === "sdk" ? (0, import_node_path24.dirname)(parent2) : parent2;
37786
+ if ((0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "bin", "deepline-dev.ts"))) {
37787
+ const parent2 = (0, import_node_path25.dirname)(current);
37788
+ return (0, import_node_path25.basename)(parent2) === "packages" && (0, import_node_path25.basename)(current) === "sdk" ? (0, import_node_path25.dirname)(parent2) : parent2;
37451
37789
  }
37452
- if ((0, import_node_fs22.existsSync)((0, import_node_path24.join)(current, "sdk", "package.json")) && (0, import_node_fs22.existsSync)((0, import_node_path24.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
37790
+ if ((0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "sdk", "package.json")) && (0, import_node_fs23.existsSync)((0, import_node_path25.join)(current, "sdk", "bin", "deepline-dev.ts"))) {
37453
37791
  return current;
37454
37792
  }
37455
- const parent = (0, import_node_path24.dirname)(current);
37793
+ const parent = (0, import_node_path25.dirname)(current);
37456
37794
  if (parent === current) return null;
37457
37795
  current = parent;
37458
37796
  }
@@ -37460,9 +37798,9 @@ function findRepoBackedSdkRoot(startPath) {
37460
37798
  function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
37461
37799
  const normalized = (() => {
37462
37800
  try {
37463
- return (0, import_node_fs22.realpathSync)(entrypoint);
37801
+ return (0, import_node_fs23.realpathSync)(entrypoint);
37464
37802
  } catch {
37465
- return (0, import_node_path24.resolve)(entrypoint);
37803
+ return (0, import_node_path25.resolve)(entrypoint);
37466
37804
  }
37467
37805
  })();
37468
37806
  const parts = normalized.split(/[\\/]+/);
@@ -37477,10 +37815,10 @@ function inferNpmGlobalPrefixFromEntrypoint(entrypoint, env) {
37477
37815
  const directPrefix = prefixParts.join("/").toLowerCase();
37478
37816
  const knownWindowsPrefixes = [
37479
37817
  env.npm_config_prefix,
37480
- env.APPDATA ? (0, import_node_path24.join)(env.APPDATA, "npm") : void 0
37481
- ].filter((value) => Boolean(value)).map((value) => (0, import_node_path24.resolve)(value).replace(/\\/g, "/").toLowerCase());
37818
+ env.APPDATA ? (0, import_node_path25.join)(env.APPDATA, "npm") : void 0
37819
+ ].filter((value) => Boolean(value)).map((value) => (0, import_node_path25.resolve)(value).replace(/\\/g, "/").toLowerCase());
37482
37820
  if (!knownWindowsPrefixes.includes(
37483
- (0, import_node_path24.resolve)(directPrefix).replace(/\\/g, "/").toLowerCase()
37821
+ (0, import_node_path25.resolve)(directPrefix).replace(/\\/g, "/").toLowerCase()
37484
37822
  )) {
37485
37823
  return null;
37486
37824
  }
@@ -37493,9 +37831,9 @@ function normalizedNpmPrefix(value) {
37493
37831
  if (!trimmed) return null;
37494
37832
  const normalized = (() => {
37495
37833
  try {
37496
- return (0, import_node_fs22.realpathSync)((0, import_node_path24.resolve)(trimmed));
37834
+ return (0, import_node_fs23.realpathSync)((0, import_node_path25.resolve)(trimmed));
37497
37835
  } catch {
37498
- return (0, import_node_path24.resolve)(trimmed);
37836
+ return (0, import_node_path25.resolve)(trimmed);
37499
37837
  }
37500
37838
  })().replace(/\\/g, "/");
37501
37839
  return process.platform === "win32" ? normalized.toLowerCase() : normalized;
@@ -37518,9 +37856,9 @@ function resolveNpmGlobalPrefix(env) {
37518
37856
  function isHomebrewFormulaEntrypoint(entrypoint) {
37519
37857
  const normalized = (() => {
37520
37858
  try {
37521
- return (0, import_node_fs22.realpathSync)(entrypoint);
37859
+ return (0, import_node_fs23.realpathSync)(entrypoint);
37522
37860
  } catch {
37523
- return (0, import_node_path24.resolve)(entrypoint);
37861
+ return (0, import_node_path25.resolve)(entrypoint);
37524
37862
  }
37525
37863
  })();
37526
37864
  const parts = normalized.split(/[\\/]+/);
@@ -37530,8 +37868,8 @@ function isHomebrewFormulaEntrypoint(entrypoint) {
37530
37868
  function resolveUpdatePlan(options = {}) {
37531
37869
  const env = options.env ?? process.env;
37532
37870
  const homeDir2 = options.homeDir ?? (0, import_node_os15.homedir)();
37533
- const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path24.resolve)(process.argv[1]) : "");
37534
- const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path24.dirname)(entrypoint)) : null;
37871
+ const entrypoint = options.entrypoint ?? (process.argv[1] ? (0, import_node_path25.resolve)(process.argv[1]) : "");
37872
+ const sourceRoot = entrypoint ? findRepoBackedSdkRoot((0, import_node_path25.dirname)(entrypoint)) : null;
37535
37873
  if (sourceRoot) {
37536
37874
  return {
37537
37875
  kind: "source",
@@ -37582,9 +37920,9 @@ var AUTO_UPDATE_FAILURE_FILE = ".auto-update-failure.json";
37582
37920
  function autoUpdateFailurePath(plan) {
37583
37921
  if (plan.kind === "source" || plan.kind === "homebrew") return null;
37584
37922
  if (plan.kind === "python-sidecar") {
37585
- return (0, import_node_path24.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
37923
+ return (0, import_node_path25.join)(plan.stateDir, AUTO_UPDATE_FAILURE_FILE);
37586
37924
  }
37587
- return (0, import_node_path24.join)(
37925
+ return (0, import_node_path25.join)(
37588
37926
  (0, import_node_os15.homedir)(),
37589
37927
  ".local",
37590
37928
  "deepline",
@@ -37602,7 +37940,7 @@ function readAutoUpdateFailure(plan) {
37602
37940
  if (!path) return null;
37603
37941
  try {
37604
37942
  const parsed = JSON.parse(
37605
- (0, import_node_fs22.readFileSync)(path, "utf8")
37943
+ (0, import_node_fs23.readFileSync)(path, "utf8")
37606
37944
  );
37607
37945
  if ((parsed.kind === "npm-global" || parsed.kind === "python-sidecar") && typeof parsed.packageSpec === "string" && typeof parsed.failedAt === "string" && typeof parsed.exitCode === "number" && typeof parsed.manualCommand === "string") {
37608
37946
  return parsed;
@@ -37623,8 +37961,8 @@ function writeAutoUpdateFailure(plan, exitCode) {
37623
37961
  manualCommand: plan.manualCommand
37624
37962
  };
37625
37963
  try {
37626
- (0, import_node_fs22.mkdirSync)((0, import_node_path24.dirname)(path), { recursive: true });
37627
- (0, import_node_fs22.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
37964
+ (0, import_node_fs23.mkdirSync)((0, import_node_path25.dirname)(path), { recursive: true });
37965
+ (0, import_node_fs23.writeFileSync)(path, `${JSON.stringify(marker, null, 2)}
37628
37966
  `, "utf8");
37629
37967
  } catch {
37630
37968
  }
@@ -37633,7 +37971,7 @@ function clearAutoUpdateFailure(plan) {
37633
37971
  const path = autoUpdateFailurePath(plan);
37634
37972
  if (!path) return;
37635
37973
  try {
37636
- (0, import_node_fs22.unlinkSync)(path);
37974
+ (0, import_node_fs23.unlinkSync)(path);
37637
37975
  } catch {
37638
37976
  }
37639
37977
  }
@@ -37671,7 +38009,7 @@ function safeVersionSegment(value) {
37671
38009
  return /^[0-9A-Za-z._-]+$/.test(normalized) ? normalized : "";
37672
38010
  }
37673
38011
  function entryPathInVersionDir(versionDir) {
37674
- return (0, import_node_path24.join)(
38012
+ return (0, import_node_path25.join)(
37675
38013
  versionDir,
37676
38014
  "node_modules",
37677
38015
  "deepline",
@@ -37681,14 +38019,14 @@ function entryPathInVersionDir(versionDir) {
37681
38019
  );
37682
38020
  }
37683
38021
  function installedPackageVersion(versionDir) {
37684
- const packageJsonPath = (0, import_node_path24.join)(
38022
+ const packageJsonPath = (0, import_node_path25.join)(
37685
38023
  versionDir,
37686
38024
  "node_modules",
37687
38025
  "deepline",
37688
38026
  "package.json"
37689
38027
  );
37690
38028
  try {
37691
- const parsed = JSON.parse((0, import_node_fs22.readFileSync)(packageJsonPath, "utf8"));
38029
+ const parsed = JSON.parse((0, import_node_fs23.readFileSync)(packageJsonPath, "utf8"));
37692
38030
  return typeof parsed.version === "string" ? safeVersionSegment(parsed.version) : "";
37693
38031
  } catch {
37694
38032
  return "";
@@ -37803,20 +38141,20 @@ async function runNpmInstallWithRegistryFallback(input2) {
37803
38141
  return first.exitCode;
37804
38142
  }
37805
38143
  function writeSidecarLauncher(input2) {
37806
- (0, import_node_fs22.mkdirSync)((0, import_node_path24.dirname)(input2.path), { recursive: true });
37807
- const packageRoot = (0, import_node_path24.dirname)((0, import_node_path24.dirname)((0, import_node_path24.dirname)(input2.entryPath)));
37808
- const versionDir = (0, import_node_path24.dirname)((0, import_node_path24.dirname)(packageRoot));
38144
+ (0, import_node_fs23.mkdirSync)((0, import_node_path25.dirname)(input2.path), { recursive: true });
38145
+ const packageRoot = (0, import_node_path25.dirname)((0, import_node_path25.dirname)((0, import_node_path25.dirname)(input2.entryPath)));
38146
+ const versionDir = (0, import_node_path25.dirname)((0, import_node_path25.dirname)(packageRoot));
37809
38147
  const esbuildProbe = "const {createRequire}=require('node:module');const path=require('node:path');const req=createRequire(path.join(process.argv[1],'package.json'));const result=req('esbuild').transformSync('const value: number = 1;',{loader:'ts'});if(!result||typeof result.code!=='string')process.exit(3);";
37810
38148
  const criticalPaths = [
37811
38149
  ...SDK_SIDECAR_CRITICAL_PACKAGE_FILES.map(
37812
- (path) => (0, import_node_path24.join)(packageRoot, path)
38150
+ (path) => (0, import_node_path25.join)(packageRoot, path)
37813
38151
  ),
37814
38152
  ...SDK_SIDECAR_CRITICAL_DEPENDENCY_FILES.map(
37815
- (path) => (0, import_node_path24.join)(versionDir, "node_modules", path)
38153
+ (path) => (0, import_node_path25.join)(versionDir, "node_modules", path)
37816
38154
  )
37817
38155
  ];
37818
38156
  if (process.platform === "win32") {
37819
- (0, import_node_fs22.writeFileSync)(
38157
+ (0, import_node_fs23.writeFileSync)(
37820
38158
  input2.path,
37821
38159
  [
37822
38160
  `@set DEEPLINE_HOST_URL=${input2.hostUrl.replace(/\r?\n/g, "")}`,
@@ -37839,7 +38177,7 @@ function writeSidecarLauncher(input2) {
37839
38177
  );
37840
38178
  return;
37841
38179
  }
37842
- (0, import_node_fs22.writeFileSync)(
38180
+ (0, import_node_fs23.writeFileSync)(
37843
38181
  input2.path,
37844
38182
  [
37845
38183
  "#!/usr/bin/env sh",
@@ -37866,17 +38204,17 @@ function writeSidecarLauncher(input2) {
37866
38204
  );
37867
38205
  }
37868
38206
  async function runPythonSidecarUpdatePlan(plan) {
37869
- const versionsDir = (0, import_node_path24.join)(plan.stateDir, "versions");
37870
- const tempDir = (0, import_node_path24.join)(
38207
+ const versionsDir = (0, import_node_path25.join)(plan.stateDir, "versions");
38208
+ const tempDir = (0, import_node_path25.join)(
37871
38209
  versionsDir,
37872
38210
  `.tmp-sdk-update-${process.pid}-${Date.now()}`
37873
38211
  );
37874
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
37875
- (0, import_node_fs22.mkdirSync)(tempDir, { recursive: true });
37876
- (0, import_node_fs22.writeFileSync)((0, import_node_path24.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
38212
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
38213
+ (0, import_node_fs23.mkdirSync)(tempDir, { recursive: true });
38214
+ (0, import_node_fs23.writeFileSync)((0, import_node_path25.join)(tempDir, "package.json"), NPM_SDK_SIDECAR_PACKAGE_JSON);
37877
38215
  const env = {
37878
38216
  ...process.env,
37879
- PATH: `${(0, import_node_path24.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
38217
+ PATH: `${(0, import_node_path25.dirname)(plan.nodeBin)}${process.platform === "win32" ? ";" : ":"}${process.env.PATH ?? ""}`
37880
38218
  };
37881
38219
  const installResult = await runCommand(
37882
38220
  plan.npmCommand,
@@ -37893,7 +38231,7 @@ async function runPythonSidecarUpdatePlan(plan) {
37893
38231
  );
37894
38232
  const installExitCode = installResult.exitCode;
37895
38233
  if (installExitCode !== 0) {
37896
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
38234
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
37897
38235
  return installExitCode;
37898
38236
  }
37899
38237
  const installedVersion = installedPackageVersion(tempDir);
@@ -37901,7 +38239,7 @@ async function runPythonSidecarUpdatePlan(plan) {
37901
38239
  process.stderr.write(
37902
38240
  "Updated Deepline SDK package did not report a version.\n"
37903
38241
  );
37904
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
38242
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
37905
38243
  return 1;
37906
38244
  }
37907
38245
  const stagedFailure = sidecarInstallFailure(tempDir);
@@ -37910,32 +38248,32 @@ async function runPythonSidecarUpdatePlan(plan) {
37910
38248
  `Updated Deepline SDK package is incomplete: ${stagedFailure}.
37911
38249
  `
37912
38250
  );
37913
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
38251
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
37914
38252
  return 1;
37915
38253
  }
37916
- const finalDir = (0, import_node_path24.join)(versionsDir, installedVersion);
38254
+ const finalDir = (0, import_node_path25.join)(versionsDir, installedVersion);
37917
38255
  const finalEntryPath = entryPathInVersionDir(finalDir);
37918
38256
  const finalFailure = sidecarInstallFailure(finalDir);
37919
38257
  let backupDir = null;
37920
38258
  if (!finalFailure) {
37921
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
38259
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
37922
38260
  } else {
37923
38261
  let shouldPublishTemp = true;
37924
- if ((0, import_node_fs22.existsSync)(finalDir)) {
37925
- backupDir = (0, import_node_path24.join)(
38262
+ if ((0, import_node_fs23.existsSync)(finalDir)) {
38263
+ backupDir = (0, import_node_path25.join)(
37926
38264
  versionsDir,
37927
38265
  `.backup-${installedVersion}-${process.pid}-${Date.now()}`
37928
38266
  );
37929
38267
  try {
37930
- (0, import_node_fs22.renameSync)(finalDir, backupDir);
38268
+ (0, import_node_fs23.renameSync)(finalDir, backupDir);
37931
38269
  } catch (error) {
37932
38270
  const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
37933
38271
  if (!concurrentlyPublishedFailure) {
37934
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
38272
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
37935
38273
  backupDir = null;
37936
38274
  shouldPublishTemp = false;
37937
38275
  } else {
37938
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
38276
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
37939
38277
  process.stderr.write(
37940
38278
  `Failed to preserve the incomplete Deepline SDK sidecar before repair: ${error.message}.
37941
38279
  `
@@ -37946,18 +38284,18 @@ async function runPythonSidecarUpdatePlan(plan) {
37946
38284
  }
37947
38285
  if (shouldPublishTemp) {
37948
38286
  try {
37949
- (0, import_node_fs22.renameSync)(tempDir, finalDir);
38287
+ (0, import_node_fs23.renameSync)(tempDir, finalDir);
37950
38288
  } catch (error) {
37951
- (0, import_node_fs22.rmSync)(tempDir, { recursive: true, force: true });
38289
+ (0, import_node_fs23.rmSync)(tempDir, { recursive: true, force: true });
37952
38290
  const concurrentlyPublishedFailure = sidecarInstallFailure(finalDir);
37953
38291
  if (!concurrentlyPublishedFailure) {
37954
- if (backupDir) (0, import_node_fs22.rmSync)(backupDir, { recursive: true, force: true });
38292
+ if (backupDir) (0, import_node_fs23.rmSync)(backupDir, { recursive: true, force: true });
37955
38293
  backupDir = null;
37956
38294
  } else {
37957
38295
  let restoreFailure = "";
37958
- if (backupDir && (0, import_node_fs22.existsSync)(backupDir) && !(0, import_node_fs22.existsSync)(finalDir)) {
38296
+ if (backupDir && (0, import_node_fs23.existsSync)(backupDir) && !(0, import_node_fs23.existsSync)(finalDir)) {
37959
38297
  try {
37960
- (0, import_node_fs22.renameSync)(backupDir, finalDir);
38298
+ (0, import_node_fs23.renameSync)(backupDir, finalDir);
37961
38299
  backupDir = null;
37962
38300
  } catch (restoreError) {
37963
38301
  restoreFailure = `; failed to restore previous install: ${restoreError.message}`;
@@ -37974,10 +38312,10 @@ async function runPythonSidecarUpdatePlan(plan) {
37974
38312
  }
37975
38313
  const publishedFailure = sidecarStructureFailure(finalDir);
37976
38314
  if (publishedFailure) {
37977
- if (backupDir && (0, import_node_fs22.existsSync)(backupDir)) {
37978
- (0, import_node_fs22.rmSync)(finalDir, { recursive: true, force: true });
38315
+ if (backupDir && (0, import_node_fs23.existsSync)(backupDir)) {
38316
+ (0, import_node_fs23.rmSync)(finalDir, { recursive: true, force: true });
37979
38317
  try {
37980
- (0, import_node_fs22.renameSync)(backupDir, finalDir);
38318
+ (0, import_node_fs23.renameSync)(backupDir, finalDir);
37981
38319
  backupDir = null;
37982
38320
  } catch {
37983
38321
  }
@@ -37988,7 +38326,7 @@ async function runPythonSidecarUpdatePlan(plan) {
37988
38326
  );
37989
38327
  return 1;
37990
38328
  }
37991
- if (backupDir) (0, import_node_fs22.rmSync)(backupDir, { recursive: true, force: true });
38329
+ if (backupDir) (0, import_node_fs23.rmSync)(backupDir, { recursive: true, force: true });
37992
38330
  writeSidecarLauncher({
37993
38331
  path: plan.sidecarPath,
37994
38332
  hostUrl: plan.hostUrl,
@@ -37996,28 +38334,28 @@ async function runPythonSidecarUpdatePlan(plan) {
37996
38334
  nodeBin: plan.nodeBin,
37997
38335
  entryPath: finalEntryPath
37998
38336
  });
37999
- (0, import_node_fs22.writeFileSync)(
38000
- (0, import_node_path24.join)(plan.stateDir, ".version"),
38337
+ (0, import_node_fs23.writeFileSync)(
38338
+ (0, import_node_path25.join)(plan.stateDir, ".version"),
38001
38339
  `${installedVersion}
38002
38340
  `,
38003
38341
  "utf8"
38004
38342
  );
38005
- (0, import_node_fs22.writeFileSync)(
38006
- (0, import_node_path24.join)(plan.stateDir, ".install-method"),
38343
+ (0, import_node_fs23.writeFileSync)(
38344
+ (0, import_node_path25.join)(plan.stateDir, ".install-method"),
38007
38345
  "python-sidecar\n",
38008
38346
  "utf8"
38009
38347
  );
38010
- (0, import_node_fs22.writeFileSync)(
38011
- (0, import_node_path24.join)(plan.stateDir, ".command-path"),
38348
+ (0, import_node_fs23.writeFileSync)(
38349
+ (0, import_node_path25.join)(plan.stateDir, ".command-path"),
38012
38350
  `${plan.sidecarPath}
38013
38351
  `,
38014
38352
  "utf8"
38015
38353
  );
38016
- (0, import_node_fs22.writeFileSync)((0, import_node_path24.join)(plan.stateDir, ".runner"), "node\n", "utf8");
38017
- (0, import_node_fs22.writeFileSync)((0, import_node_path24.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
38354
+ (0, import_node_fs23.writeFileSync)((0, import_node_path25.join)(plan.stateDir, ".runner"), "node\n", "utf8");
38355
+ (0, import_node_fs23.writeFileSync)((0, import_node_path25.join)(plan.stateDir, ".node-bin"), `${plan.nodeBin}
38018
38356
  `, "utf8");
38019
- (0, import_node_fs22.writeFileSync)(
38020
- (0, import_node_path24.join)(plan.stateDir, ".entry-path"),
38357
+ (0, import_node_fs23.writeFileSync)(
38358
+ (0, import_node_path25.join)(plan.stateDir, ".entry-path"),
38021
38359
  `${finalEntryPath}
38022
38360
  `,
38023
38361
  "utf8"
@@ -38944,14 +39282,14 @@ chooses the connected Slack channel or member and the events it receives.
38944
39282
 
38945
39283
  // src/cli/commands/tools.ts
38946
39284
  var import_commander3 = require("commander");
38947
- var import_node_fs24 = require("fs");
39285
+ var import_node_fs25 = require("fs");
38948
39286
  var import_node_os17 = require("os");
38949
- var import_node_path26 = require("path");
39287
+ var import_node_path27 = require("path");
38950
39288
 
38951
39289
  // src/tool-output.ts
38952
- var import_node_fs23 = require("fs");
39290
+ var import_node_fs24 = require("fs");
38953
39291
  var import_node_os16 = require("os");
38954
- var import_node_path25 = require("path");
39292
+ var import_node_path26 = require("path");
38955
39293
  function isPlainObject(value) {
38956
39294
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
38957
39295
  }
@@ -39078,19 +39416,19 @@ function projectRowOutput(conversion) {
39078
39416
  };
39079
39417
  }
39080
39418
  function ensureOutputDir() {
39081
- const outputDir = (0, import_node_path25.join)((0, import_node_os16.homedir)(), ".local", "share", "deepline", "data");
39082
- (0, import_node_fs23.mkdirSync)(outputDir, { recursive: true });
39419
+ const outputDir = (0, import_node_path26.join)((0, import_node_os16.homedir)(), ".local", "share", "deepline", "data");
39420
+ (0, import_node_fs24.mkdirSync)(outputDir, { recursive: true });
39083
39421
  return outputDir;
39084
39422
  }
39085
39423
  function writeJsonOutputFile(payload, stem) {
39086
39424
  const outputDir = ensureOutputDir();
39087
- const outputPath = (0, import_node_path25.join)(outputDir, `${stem}_${Date.now()}.json`);
39088
- (0, import_node_fs23.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
39425
+ const outputPath = (0, import_node_path26.join)(outputDir, `${stem}_${Date.now()}.json`);
39426
+ (0, import_node_fs24.writeFileSync)(outputPath, JSON.stringify(payload, null, 2), "utf-8");
39089
39427
  return outputPath;
39090
39428
  }
39091
39429
  function writeCsvOutputFile(rows, stem, options) {
39092
- const outputPath = options?.outPath ? options.outPath : (0, import_node_path25.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
39093
- (0, import_node_fs23.mkdirSync)((0, import_node_path25.dirname)(outputPath), { recursive: true });
39430
+ const outputPath = options?.outPath ? options.outPath : (0, import_node_path26.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
39431
+ (0, import_node_fs24.mkdirSync)((0, import_node_path26.dirname)(outputPath), { recursive: true });
39094
39432
  const columns = columnsForRows(rows);
39095
39433
  const escapeCell = (value) => {
39096
39434
  const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
@@ -39099,19 +39437,19 @@ function writeCsvOutputFile(rows, stem, options) {
39099
39437
  }
39100
39438
  return normalized;
39101
39439
  };
39102
- const fd = (0, import_node_fs23.openSync)(outputPath, "w");
39440
+ const fd = (0, import_node_fs24.openSync)(outputPath, "w");
39103
39441
  try {
39104
- (0, import_node_fs23.writeSync)(fd, `${columns.map(escapeCell).join(",")}
39442
+ (0, import_node_fs24.writeSync)(fd, `${columns.map(escapeCell).join(",")}
39105
39443
  `);
39106
39444
  for (const row of rows) {
39107
- (0, import_node_fs23.writeSync)(
39445
+ (0, import_node_fs24.writeSync)(
39108
39446
  fd,
39109
39447
  `${columns.map((column) => escapeCell(row[column])).join(",")}
39110
39448
  `
39111
39449
  );
39112
39450
  }
39113
39451
  } finally {
39114
- (0, import_node_fs23.closeSync)(fd);
39452
+ (0, import_node_fs24.closeSync)(fd);
39115
39453
  }
39116
39454
  const previewRows = rows.slice(0, 5);
39117
39455
  const previewColumns = columns.slice(0, 5);
@@ -41050,11 +41388,11 @@ function normalizeOutputFormat(raw) {
41050
41388
  }
41051
41389
  function resolveAtFilePath(rawPath) {
41052
41390
  const trimmed = rawPath.trim();
41053
- const resolved = (0, import_node_path26.resolve)(trimmed);
41054
- if ((0, import_node_fs24.existsSync)(resolved)) return resolved;
41391
+ const resolved = (0, import_node_path27.resolve)(trimmed);
41392
+ if ((0, import_node_fs25.existsSync)(resolved)) return resolved;
41055
41393
  if (process.platform !== "win32" && trimmed.includes("\\")) {
41056
- const normalized = (0, import_node_path26.resolve)(trimmed.replace(/\\/g, "/"));
41057
- if ((0, import_node_fs24.existsSync)(normalized)) return normalized;
41394
+ const normalized = (0, import_node_path27.resolve)(trimmed.replace(/\\/g, "/"));
41395
+ if ((0, import_node_fs25.existsSync)(normalized)) return normalized;
41058
41396
  }
41059
41397
  return resolved;
41060
41398
  }
@@ -41065,7 +41403,7 @@ function readJsonArgument(raw, flagName) {
41065
41403
  throw new Error(`Invalid ${flagName} value: empty @file path.`);
41066
41404
  }
41067
41405
  try {
41068
- return (0, import_node_fs24.readFileSync)(resolveAtFilePath(filePath), "utf8").replace(
41406
+ return (0, import_node_fs25.readFileSync)(resolveAtFilePath(filePath), "utf8").replace(
41069
41407
  /^\uFEFF/,
41070
41408
  ""
41071
41409
  );
@@ -41142,7 +41480,7 @@ function parseExecuteOptions(args) {
41142
41480
  continue;
41143
41481
  }
41144
41482
  if ((arg === "--out" || arg === "-o") && args[index + 1]) {
41145
- outPath = (0, import_node_path26.resolve)(args[++index]);
41483
+ outPath = (0, import_node_path27.resolve)(args[++index]);
41146
41484
  continue;
41147
41485
  }
41148
41486
  throw new Error(`Unknown option: ${arg}`);
@@ -41172,9 +41510,9 @@ function starterScriptJson(script) {
41172
41510
  function seedToolListScript(input2) {
41173
41511
  const stem = safeFileStem(input2.toolId);
41174
41512
  const fileName = `${stem}-workflow-seed-${Date.now()}.play.ts`;
41175
- const scriptDir = (0, import_node_fs24.mkdtempSync)((0, import_node_path26.join)((0, import_node_os17.tmpdir)(), "deepline-workflow-seed-"));
41176
- (0, import_node_fs24.chmodSync)(scriptDir, 448);
41177
- const scriptPath = (0, import_node_path26.join)(scriptDir, fileName);
41513
+ const scriptDir = (0, import_node_fs25.mkdtempSync)((0, import_node_path27.join)((0, import_node_os17.tmpdir)(), "deepline-workflow-seed-"));
41514
+ (0, import_node_fs25.chmodSync)(scriptDir, 448);
41515
+ const scriptPath = (0, import_node_path27.join)(scriptDir, fileName);
41178
41516
  const projectDir = `deepline/projects/${stem}-workflow`;
41179
41517
  const playName = `${stem}-workflow`;
41180
41518
  const sampleRows = input2.rows.length > 0 ? `${JSON.stringify(input2.rows.slice(0, 2)).replace(/\]$/, "")}, ...]` : "[]";
@@ -41217,7 +41555,7 @@ export default definePlay(${JSON.stringify(playName)}, async (ctx) => {
41217
41555
  description: ${JSON.stringify(`Seed ${input2.toolId} rows into a Deepline workflow-ready dataset.`)},
41218
41556
  });
41219
41557
  `;
41220
- (0, import_node_fs24.writeFileSync)(scriptPath, script, { encoding: "utf-8", mode: 384 });
41558
+ (0, import_node_fs25.writeFileSync)(scriptPath, script, { encoding: "utf-8", mode: 384 });
41221
41559
  return {
41222
41560
  path: scriptPath,
41223
41561
  sourceCode: script,
@@ -41643,10 +41981,10 @@ Examples:
41643
41981
 
41644
41982
  // src/cli/commands/workflow.ts
41645
41983
  var import_promises10 = require("fs/promises");
41646
- var import_node_path27 = require("path");
41984
+ var import_node_path28 = require("path");
41647
41985
 
41648
41986
  // src/cli/workflow-to-play.ts
41649
- var import_node_crypto9 = require("crypto");
41987
+ var import_node_crypto10 = require("crypto");
41650
41988
  var HITL_WAIT_FOR_SIGNAL_TOOL = "deepline_workflow_wait_for_signal";
41651
41989
  var HITL_SLACK_TOOL = "slack_message_with_hitl";
41652
41990
  var SUB_WORKFLOW_TOOL_PREFIX = "deepline_workflow_";
@@ -41752,7 +42090,7 @@ function sanitizePlayNameSegment(value) {
41752
42090
  }
41753
42091
  function deriveWorkflowPlayName(workflowName) {
41754
42092
  const base = sanitizePlayNameSegment(workflowName) || "workflow";
41755
- const suffix = (0, import_node_crypto9.createHash)("sha256").update(workflowName).digest("hex").slice(0, 8);
42093
+ const suffix = (0, import_node_crypto10.createHash)("sha256").update(workflowName).digest("hex").slice(0, 8);
41756
42094
  const reserved = suffix.length + 1;
41757
42095
  const allowedBase = Math.max(1, MAX_PLAY_NAME_LENGTH - reserved);
41758
42096
  let name = `${base.slice(0, allowedBase)}_${suffix}`;
@@ -41860,7 +42198,7 @@ function readStatus(payload) {
41860
42198
  }
41861
42199
  async function readJsonOption(payload, file) {
41862
42200
  if (file) {
41863
- const raw = await (0, import_promises10.readFile)((0, import_node_path27.resolve)(file), "utf8");
42201
+ const raw = await (0, import_promises10.readFile)((0, import_node_path28.resolve)(file), "utf8");
41864
42202
  return JSON.parse(raw);
41865
42203
  }
41866
42204
  if (payload) {
@@ -41894,8 +42232,8 @@ async function transformOne(api, workflowId, outDir, publish) {
41894
42232
  revision.config,
41895
42233
  { workflowName: workflow.name, version: revision.version }
41896
42234
  );
41897
- const file = (0, import_node_path27.join)((0, import_node_path27.resolve)(outDir), `${compiled.playName}.play.ts`);
41898
- await (0, import_promises10.mkdir)((0, import_node_path27.dirname)(file), { recursive: true });
42235
+ const file = (0, import_node_path28.join)((0, import_node_path28.resolve)(outDir), `${compiled.playName}.play.ts`);
42236
+ await (0, import_promises10.mkdir)((0, import_node_path28.dirname)(file), { recursive: true });
41899
42237
  await (0, import_promises10.writeFile)(file, compiled.sourceCode, "utf8");
41900
42238
  let published = false;
41901
42239
  if (publish) {
@@ -42527,8 +42865,8 @@ function topLevelCommandKnown(program, commandName) {
42527
42865
  );
42528
42866
  }
42529
42867
  async function runPlayRunnerHealthCheck() {
42530
- const dir = await (0, import_promises11.mkdtemp)((0, import_node_path28.join)((0, import_node_os18.tmpdir)(), "deepline-health-play-"));
42531
- const file = (0, import_node_path28.join)(dir, "health-check.play.ts");
42868
+ const dir = await (0, import_promises11.mkdtemp)((0, import_node_path29.join)((0, import_node_os18.tmpdir)(), "deepline-health-play-"));
42869
+ const file = (0, import_node_path29.join)(dir, "health-check.play.ts");
42532
42870
  try {
42533
42871
  await (0, import_promises11.writeFile)(
42534
42872
  file,