deepline 0.3.389 → 0.3.391

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.
Files changed (124) hide show
  1. package/dist/bundling-sources/sdk/src/agent-runtime.ts +21 -16
  2. package/dist/bundling-sources/sdk/src/billing-idempotency.ts +1 -1
  3. package/dist/bundling-sources/sdk/src/cli-invocation-id.ts +1 -1
  4. package/dist/bundling-sources/sdk/src/client.ts +75 -52
  5. package/dist/bundling-sources/sdk/src/config.ts +3 -2
  6. package/dist/bundling-sources/sdk/src/db/query.ts +3 -3
  7. package/dist/bundling-sources/sdk/src/deployment-protection.ts +7 -5
  8. package/dist/bundling-sources/sdk/src/http.ts +31 -41
  9. package/dist/bundling-sources/sdk/src/index.ts +26 -26
  10. package/dist/bundling-sources/sdk/src/play.ts +5 -5
  11. package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
  12. package/dist/bundling-sources/sdk/src/plays/local-play-execution.ts +2 -2
  13. package/dist/bundling-sources/sdk/src/plays/run-request.ts +2 -2
  14. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  15. package/dist/bundling-sources/sdk/src/runs/read-errors.ts +1 -1
  16. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +1 -1
  17. package/dist/bundling-sources/sdk/src/skills-version.ts +2 -2
  18. package/dist/bundling-sources/sdk/src/tool-calls.ts +3 -3
  19. package/dist/bundling-sources/sdk/src/types.ts +10 -1
  20. package/dist/bundling-sources/sdk/src/version.ts +1 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +87 -1
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +19 -11
  23. package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +1 -1
  24. package/dist/cli/{auth-DEASEYUJ.mjs → auth-6QET7NFP.mjs} +4 -4
  25. package/dist/cli/auth-6ZUH42ZA.js +39 -0
  26. package/dist/cli/{billing-TUTB4H6F.mjs → billing-HAQ2VDQX.mjs} +4 -4
  27. package/dist/cli/{billing-QIWD5GYZ.js → billing-KJAGTCFR.js} +73 -73
  28. package/dist/cli/{chunk-WRLYF4DS.js → chunk-4S6X74A3.js} +2 -2
  29. package/dist/cli/{chunk-HXENYWVS.js → chunk-4TCT77UF.js} +485 -114
  30. package/dist/cli/{chunk-KWGB3RWA.js → chunk-556BMGEB.js} +235 -220
  31. package/dist/cli/{chunk-CCIEPJSX.mjs → chunk-6L4P7Z6C.mjs} +2 -2
  32. package/dist/cli/{chunk-M6BQYSV3.mjs → chunk-DRZFTRZJ.mjs} +46 -31
  33. package/dist/cli/{chunk-7IPMWJNZ.js → chunk-ED42XCOW.js} +226 -226
  34. package/dist/cli/{chunk-B6BQ6EAR.mjs → chunk-H2ER7QWR.mjs} +6 -6
  35. package/dist/cli/{chunk-HHRQYYHK.mjs → chunk-H3DCZOXR.mjs} +5 -5
  36. package/dist/cli/{chunk-63ZXA57X.mjs → chunk-HFTOOZGN.mjs} +3 -3
  37. package/dist/cli/{chunk-PPKNOVMF.mjs → chunk-I3MKXASV.mjs} +2 -2
  38. package/dist/cli/{chunk-CLOICRTK.js → chunk-I7EVBLTW.js} +6 -6
  39. package/dist/cli/{chunk-7WQGDKNO.mjs → chunk-K3ODOHOI.mjs} +34 -26
  40. package/dist/cli/{chunk-MCWGQIDV.js → chunk-KA7X75HC.js} +48 -48
  41. package/dist/cli/{chunk-NBXJJBBT.mjs → chunk-KWF4HJF7.mjs} +1 -1
  42. package/dist/cli/{chunk-CMWDXAQH.js → chunk-ME2DZAHC.js} +26 -26
  43. package/dist/cli/{chunk-Z43SUQUL.js → chunk-MHLCMJ2E.js} +99 -91
  44. package/dist/cli/{chunk-MP7FWY76.mjs → chunk-PFPP4BKS.mjs} +2 -2
  45. package/dist/cli/{chunk-HVDBGPDP.mjs → chunk-PQSA443V.mjs} +485 -114
  46. package/dist/cli/{chunk-RHAP7ZW5.mjs → chunk-QCWIORKR.mjs} +2 -2
  47. package/dist/cli/{chunk-FZXZLFNC.js → chunk-RA2SDTSX.js} +15 -15
  48. package/dist/cli/{chunk-ABLS54ZL.js → chunk-RTH26NF3.js} +61 -61
  49. package/dist/cli/{chunk-Z4ZB2CDV.mjs → chunk-TLHF54VX.mjs} +1 -1
  50. package/dist/cli/{chunk-FZZC3A7J.js → chunk-UOSKJIXE.js} +8 -8
  51. package/dist/cli/{chunk-GB3KEA34.mjs → chunk-VH4B5OYM.mjs} +1 -1
  52. package/dist/cli/{chunk-RPGSXBS3.js → chunk-WLODHQ7S.js} +1 -1
  53. package/dist/cli/{chunk-OWP6SI5W.js → chunk-XBPLTHGB.js} +8 -8
  54. package/dist/cli/{chunk-5VCRXKAU.js → chunk-XEV5LMS2.js} +50 -50
  55. package/dist/cli/{chunk-2L6BBM7Z.mjs → chunk-YBZY3EZF.mjs} +4 -4
  56. package/dist/cli/command-docs.d.mts +24 -1
  57. package/dist/cli/command-docs.d.ts +24 -1
  58. package/dist/cli/command-docs.js +8 -2
  59. package/dist/cli/command-docs.mjs +9 -3
  60. package/dist/cli/{csv-FYI4XWEA.js → csv-2WSF5TEM.js} +12 -12
  61. package/dist/cli/{csv-GQ5K6MDD.mjs → csv-V7UHOBFE.mjs} +3 -3
  62. package/dist/cli/{db-WYSI3J43.js → db-42RL4FZD.js} +29 -29
  63. package/dist/cli/{db-DYXQOAWZ.mjs → db-TD375E4N.mjs} +4 -4
  64. package/dist/cli/{describe-T25AHZEJ.js → describe-7WFCBZUY.js} +18 -18
  65. package/dist/cli/{describe-YIIUMAZF.mjs → describe-GPUKAWOZ.mjs} +8 -8
  66. package/dist/cli/{executions-3D7KAJ2C.js → executions-LGVG3FPH.js} +6 -6
  67. package/dist/cli/{executions-RYFSOPMQ.mjs → executions-M7O63JNA.mjs} +4 -4
  68. package/dist/cli/{feedback-CIZXMDMJ.mjs → feedback-6PBSKVB2.mjs} +3 -3
  69. package/dist/cli/{feedback-I7FWPC7V.js → feedback-PZZA2M4S.js} +7 -7
  70. package/dist/cli/{git-JCURDXPQ.mjs → git-2VIFM5DI.mjs} +4 -4
  71. package/dist/cli/git-ZSJD3BID.js +23 -0
  72. package/dist/cli/index.js +93 -93
  73. package/dist/cli/index.mjs +33 -33
  74. package/dist/cli/{legacy-noops-4BW4EZJG.mjs → legacy-noops-DPUBZI7N.mjs} +4 -4
  75. package/dist/cli/{legacy-noops-G6F5LNUM.js → legacy-noops-IQ6QTZNZ.js} +7 -7
  76. package/dist/cli/{monitors-43UXU5C3.js → monitors-6GWAZFYV.js} +85 -85
  77. package/dist/cli/{monitors-LTKH5IWE.mjs → monitors-KBZVQG2U.mjs} +4 -4
  78. package/dist/cli/{org-I3WHUV67.mjs → org-CP3VSJBX.mjs} +4 -4
  79. package/dist/cli/{org-7MSUEPXL.js → org-JKGTHXOZ.js} +64 -64
  80. package/dist/cli/{play-HRZXSNXV.mjs → play-DD2ME4L4.mjs} +7 -7
  81. package/dist/cli/play-G5GVMIBN.js +157 -0
  82. package/dist/cli/{providers-BY6JPMKP.mjs → providers-JUNOFKI7.mjs} +4 -4
  83. package/dist/cli/{providers-DWLWK5VX.js → providers-P34QYYG6.js} +7 -7
  84. package/dist/cli/{quickstart-E647CKUQ.mjs → quickstart-N6SWOK7E.mjs} +3 -3
  85. package/dist/cli/{quickstart-QO6GCK4U.js → quickstart-UL3DEFA4.js} +5 -5
  86. package/dist/cli/{search-3WUQBHRV.mjs → search-SC7I56HX.mjs} +5 -5
  87. package/dist/cli/search-W4GXWTOM.js +26 -0
  88. package/dist/cli/{secrets-CPNHE5XI.js → secrets-6ZJE7ZPM.js} +13 -13
  89. package/dist/cli/{secrets-WTGMFFP7.mjs → secrets-RTARNYF5.mjs} +4 -4
  90. package/dist/cli/{sessions-UFGGEDZP.js → sessions-6IZ2XHGW.js} +5 -5
  91. package/dist/cli/{sessions-6Q5E7GSY.mjs → sessions-7RKV2T3O.mjs} +4 -4
  92. package/dist/cli/{settings-QMEIKOUI.mjs → settings-V6PXA6HY.mjs} +7 -7
  93. package/dist/cli/{settings-NF5726RU.js → settings-YX3XJDXE.js} +74 -74
  94. package/dist/cli/{setup-J35MMJ7C.js → setup-CQ5VRNNU.js} +41 -41
  95. package/dist/cli/{setup-ZOQOJMJ7.mjs → setup-V2O4UJNT.mjs} +6 -6
  96. package/dist/cli/skills-LBZPJTPI.js +28 -0
  97. package/dist/cli/{skills-UFDKCSYR.mjs → skills-VHJZWEHA.mjs} +4 -4
  98. package/dist/cli/{tools-3SU3EUQT.mjs → tools-OD5WKEWY.mjs} +6 -6
  99. package/dist/cli/tools-TQNM473H.js +40 -0
  100. package/dist/cli/{update-SXYX4PMC.mjs → update-CRMNOMJ3.mjs} +6 -6
  101. package/dist/cli/update-QY6GAK6B.js +28 -0
  102. package/dist/cli/{workflow-2LINUMOP.mjs → workflow-EVDYNCDD.mjs} +5 -5
  103. package/dist/cli/{workflow-XAIEXDUI.js → workflow-XHORSD5T.js} +15 -15
  104. package/dist/{client-DEKvymBI.d.ts → client-BhK9kix9.d.ts} +19 -0
  105. package/dist/{client-0avPvYBP.d.mts → client-DpzZi4fU.d.mts} +19 -0
  106. package/dist/index.d.mts +2 -2
  107. package/dist/index.d.ts +2 -2
  108. package/dist/index.js +6 -6
  109. package/dist/index.mjs +3 -3
  110. package/dist/install-integrity.json +76 -76
  111. package/dist/plays/run-request.d.mts +1 -1
  112. package/dist/plays/run-request.d.ts +1 -1
  113. package/dist/release.d.mts +1 -1
  114. package/dist/release.d.ts +1 -1
  115. package/dist/release.js +2 -2
  116. package/dist/release.mjs +1 -1
  117. package/package.json +1 -1
  118. package/dist/cli/auth-AOM2LA73.js +0 -39
  119. package/dist/cli/git-MVMIPHQ6.js +0 -23
  120. package/dist/cli/play-R5TYLP5L.js +0 -157
  121. package/dist/cli/search-34AC6FC7.js +0 -26
  122. package/dist/cli/skills-WGYISRE5.js +0 -28
  123. package/dist/cli/tools-Q642ZZ2M.js +0 -40
  124. package/dist/cli/update-T5MNWAQC.js +0 -28
@@ -41,7 +41,7 @@ const AGENT_SESSION_ID_VARIABLES = [
41
41
  * one. Every command that needs the session ID reads it here.
42
42
  */
43
43
  export function agentSessionIdFromEnvironment(
44
- env: NodeJS.ProcessEnv = process.env,
44
+ env: Readonly<Record<string, string | undefined>> = process.env,
45
45
  ): string | null {
46
46
  for (const variable of AGENT_SESSION_ID_VARIABLES) {
47
47
  const sessionId = env[variable]?.trim();
@@ -63,35 +63,40 @@ export function isCoworkLikeSandbox(): boolean {
63
63
  }
64
64
 
65
65
  export function detectAgentRuntime(
66
- options: { defaultRuntime?: string; detectCowork?: boolean } = {},
66
+ options: {
67
+ defaultRuntime?: string;
68
+ detectCowork?: boolean;
69
+ env?: Readonly<Record<string, string | undefined>>;
70
+ } = {},
67
71
  ): string {
68
- const explicit = normalizeAgentRuntime(process.env.DEEPLINE_AGENT_RUNTIME);
72
+ const env = options.env ?? process.env;
73
+ const explicit = normalizeAgentRuntime(env.DEEPLINE_AGENT_RUNTIME);
69
74
  if (explicit) return explicit;
70
- if (process.env.CODEX_THREAD_ID?.trim()) return 'codex';
75
+ if (env.CODEX_THREAD_ID?.trim()) return 'codex';
71
76
  if (options.detectCowork !== false && isCoworkLikeSandbox()) {
72
77
  return 'claude_cowork';
73
78
  }
74
- if (process.env.CLAUDECODE?.trim() === '1') return 'claude_code';
75
- if (process.env.CLINE_ACTIVE?.trim().toLowerCase() === 'true') return 'cline';
76
- if (process.env.CURSOR_TRACE_ID?.trim() || process.env.CURSOR_AGENT?.trim()) {
79
+ if (env.CLAUDECODE?.trim() === '1') return 'claude_code';
80
+ if (env.CLINE_ACTIVE?.trim().toLowerCase() === 'true') return 'cline';
81
+ if (env.CURSOR_TRACE_ID?.trim() || env.CURSOR_AGENT?.trim()) {
77
82
  return 'cursor';
78
83
  }
79
- if (process.env.WINDSURF?.trim() || process.env.CASCADE?.trim()) {
84
+ if (env.WINDSURF?.trim() || env.CASCADE?.trim()) {
80
85
  return 'windsurf';
81
86
  }
82
87
  if (
83
- process.env.ANTIGRAVITY?.trim() ||
84
- process.env.ANTIGRAVITY_CLI?.trim() ||
85
- process.env.ANTIGRAVITY_AGENT?.trim() ||
86
- process.env.ANTIGRAVITY_WORKSPACE?.trim()
88
+ env.ANTIGRAVITY?.trim() ||
89
+ env.ANTIGRAVITY_CLI?.trim() ||
90
+ env.ANTIGRAVITY_AGENT?.trim() ||
91
+ env.ANTIGRAVITY_WORKSPACE?.trim()
87
92
  ) {
88
93
  return 'antigravity';
89
94
  }
90
95
  if (
91
- process.env.GEMINI_CLI?.trim() ||
92
- process.env.GEMINI_CLI_VERSION?.trim() ||
93
- process.env.GEMINI_SANDBOX?.trim() ||
94
- process.env.GEMINI_CONFIG_DIR?.trim()
96
+ env.GEMINI_CLI?.trim() ||
97
+ env.GEMINI_CLI_VERSION?.trim() ||
98
+ env.GEMINI_SANDBOX?.trim() ||
99
+ env.GEMINI_CONFIG_DIR?.trim()
95
100
  ) {
96
101
  return 'gemini';
97
102
  }
@@ -1,4 +1,4 @@
1
- import { DeeplineError } from './errors.js';
1
+ import { DeeplineError } from './errors';
2
2
 
3
3
  export function requireBillingIdempotencyKey(value: string): string {
4
4
  const normalized = value.trim();
@@ -1,4 +1,4 @@
1
- import { DeeplineError } from './errors.js';
1
+ import { DeeplineError } from './errors';
2
2
 
3
3
  const CLI_INVOCATION_ID_PATTERN =
4
4
  /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
@@ -13,9 +13,9 @@ import type {
13
13
  // Value import from the dependency-free module: the client is bundled into
14
14
  // authored Plays, where `zod` (the contract's schemas) cannot resolve.
15
15
  import { playTriggerConfigPath } from '../../shared_libs/plays/trigger-config-route';
16
- import { CSV_HEADER_MATCHING_NOTE } from './csv-header-matching.js';
17
- import { iterateCursorPages } from './pagination.js';
18
- import { playInputExampleArgs } from './plays/input-example.js';
16
+ import { CSV_HEADER_MATCHING_NOTE } from './csv-header-matching';
17
+ import { iterateCursorPages } from './pagination';
18
+ import { playInputExampleArgs } from './plays/input-example';
19
19
  /**
20
20
  * The main API client for interacting with the Deepline platform.
21
21
  *
@@ -51,28 +51,28 @@ import { playInputExampleArgs } from './plays/input-example.js';
51
51
  *
52
52
  * @module
53
53
  */
54
- import { resolveConfig } from './config.js';
55
- import { DeeplineError } from './errors.js';
56
- import { requireBillingIdempotencyKey as requireTargetBillingIdempotencyKey } from './billing-idempotency.js';
54
+ import { resolveConfig } from './config';
55
+ import { DeeplineError } from './errors';
56
+ import { requireBillingIdempotencyKey as requireTargetBillingIdempotencyKey } from './billing-idempotency';
57
57
  import {
58
58
  planCustomerDbQuery,
59
59
  queryCustomerDatabase,
60
60
  type CustomerDbQueryOptions,
61
61
  type CustomerDbQueryPlan,
62
- } from './db/query.js';
62
+ } from './db/query';
63
63
  import {
64
64
  ToolCalls,
65
65
  type ExecuteToolRawOptions,
66
66
  type ExecutionByKeyResult,
67
67
  type ToolExecution,
68
- } from './tool-calls.js';
69
- import { validateCliInvocationId } from './cli-invocation-id.js';
68
+ } from './tool-calls';
69
+ import { validateCliInvocationId } from './cli-invocation-id';
70
70
  export type {
71
71
  ExecutionRecovery,
72
72
  ExecutionByKeyResult,
73
73
  ToolExecution,
74
- } from './tool-calls.js';
75
- import { HttpClient } from './http.js';
74
+ } from './tool-calls';
75
+ import { HttpClient } from './http';
76
76
  import { PRODUCT_NOTIFICATION_SLACK_OAUTH_SCOPES } from '../../shared_libs/product-notifications/contract.js';
77
77
  import {
78
78
  DEFAULT_PRODUCT_NOTIFICATION_DELIVERY_TIMING,
@@ -84,8 +84,8 @@ import {
84
84
  type EffectiveProductNotificationGroup,
85
85
  type ProductNotificationGroupDraft,
86
86
  } from '../../shared_libs/product-notifications/configuration.js';
87
- import { watchRunEvents as pollRunSnapshotEvents } from './runs/watch-polling.js';
88
- import { encodeRunLogsCursor, parseRunLogsCursor } from './runs/log-cursor.js';
87
+ import { watchRunEvents as pollRunSnapshotEvents } from './runs/watch-polling';
88
+ import { encodeRunLogsCursor, parseRunLogsCursor } from './runs/log-cursor';
89
89
  import {
90
90
  normalizeRunEventOperationRequest,
91
91
  RunEventQueryInputError,
@@ -143,11 +143,11 @@ import type {
143
143
  ChildRunSummary,
144
144
  SearchOptions,
145
145
  SearchResult,
146
- } from './types.js';
147
- import { isStopAllPlayRunsDryRunResult } from './types.js';
148
- import type { MonitorDefinition } from './monitors.js';
149
- import type { MonitorFleetDefinition } from './monitor-fleets.js';
150
- import type { PlayStagedFileRef } from './plays/local-file-discovery.js';
146
+ } from './types';
147
+ import { isStopAllPlayRunsDryRunResult } from './types';
148
+ import type { MonitorDefinition } from './monitors';
149
+ import type { MonitorFleetDefinition } from './monitor-fleets';
150
+ import type { PlayStagedFileRef } from './plays/local-file-discovery';
151
151
  import {
152
152
  buildPlayRunStartBody,
153
153
  isPlayRunPackage,
@@ -160,7 +160,7 @@ import {
160
160
  type ResolvedStartPlayRunRequest,
161
161
  } from './plays/run-request';
162
162
  import type { PlayCompilerManifest } from '../../shared_libs/plays/compiler-manifest.js';
163
- import type { EnrichCompiledConfig } from './cli/enrich-play-compiler.js';
163
+ import type { EnrichCompiledConfig } from './cli/enrich-play-compiler';
164
164
  import {
165
165
  COORDINATOR_INTERNAL_TOKEN_HEADER,
166
166
  RUNTIME_ENVIRONMENT_TOKEN_HEADER,
@@ -333,16 +333,20 @@ function normalizePlayRunIntegrationMode(
333
333
  return undefined;
334
334
  }
335
335
 
336
+ type ClientEnvironment = Readonly<Record<string, string | undefined>>;
337
+
336
338
  function resolvePlayRunIntegrationMode(
337
339
  request: StartPlayRunRequest,
340
+ env: ClientEnvironment,
338
341
  ): 'live' | 'eval_stub' | 'fixture' | undefined {
339
342
  return normalizePlayRunIntegrationMode(
340
- request.integrationMode ?? process.env.DEEPLINE_EVAL_INTEGRATION_MODE,
343
+ request.integrationMode ?? env.DEEPLINE_EVAL_INTEGRATION_MODE,
341
344
  );
342
345
  }
343
346
 
344
347
  function resolvePlayRunRuntimeSelection(
345
348
  request: StartPlayRunRequest,
349
+ env: ClientEnvironment,
346
350
  ): PlayRuntimeSelection | undefined {
347
351
  if (request.runtime !== undefined) {
348
352
  const runtime = normalizePlayRuntimeSelection(request.runtime);
@@ -360,12 +364,12 @@ function resolvePlayRunRuntimeSelection(
360
364
  // opts into remote preview routing, namespace names the isolated lane, and
361
365
  // the token only authorizes that selection. Omitting all three leaves the
362
366
  // app free to use its native runtime (local for a local app, prod for prod).
363
- const configured = process.env.DEEPLINE_RUNTIME_ENVIRONMENT?.trim();
364
- const configuredNamespace = process.env.DEEPLINE_RUNTIME_NAMESPACE?.trim();
367
+ const configured = env.DEEPLINE_RUNTIME_ENVIRONMENT?.trim();
368
+ const configuredNamespace = env.DEEPLINE_RUNTIME_NAMESPACE?.trim();
365
369
  const configuredToken =
366
- process.env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
370
+ env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
367
371
  const configuredPlacementPolicy =
368
- process.env.DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY?.trim();
372
+ env.DEEPLINE_RUNTIME_SANDBOX_PLACEMENT_POLICY?.trim();
369
373
  if (!configured) {
370
374
  if (configuredNamespace || configuredToken || configuredPlacementPolicy) {
371
375
  // Name the variables that are actually set. This branch is almost always
@@ -409,7 +413,7 @@ function resolvePlayRunRuntimeSelection(
409
413
  );
410
414
  }
411
415
  const configuredBackendValue =
412
- process.env.DEEPLINE_PLAY_RUNNER_BACKEND?.trim();
416
+ env.DEEPLINE_PLAY_RUNNER_BACKEND?.trim();
413
417
  const configuredBackend =
414
418
  configuredBackendValue === 'daytona' || configuredBackendValue === 'modal'
415
419
  ? configuredBackendValue
@@ -447,14 +451,17 @@ function resolvePlayRunRuntimeSelection(
447
451
  * order the SDK has always validated them. The shared body builder in
448
452
  * `plays/run-request` never reads the environment.
449
453
  */
450
- function resolveStartPlayRunRequest(request: StartPlayRunRequest): {
454
+ function resolveStartPlayRunRequest(
455
+ request: StartPlayRunRequest,
456
+ env: ClientEnvironment,
457
+ ): {
451
458
  request: ResolvedStartPlayRunRequest;
452
459
  runtime: PlayRuntimeSelection | undefined;
453
460
  } {
454
- const integrationMode = resolvePlayRunIntegrationMode(request);
461
+ const integrationMode = resolvePlayRunIntegrationMode(request, env);
455
462
  const testPolicyOverrides =
456
- request.testPolicyOverrides ?? parseEnvTestPolicyOverrides();
457
- const runtime = resolvePlayRunRuntimeSelection(request);
463
+ request.testPolicyOverrides ?? parseEnvTestPolicyOverrides(env);
464
+ const runtime = resolvePlayRunRuntimeSelection(request, env);
458
465
  const resolved: ResolvedStartPlayRunRequest = { ...request };
459
466
  delete resolved.integrationMode;
460
467
  delete resolved.runtime;
@@ -467,11 +474,12 @@ function resolveStartPlayRunRequest(request: StartPlayRunRequest): {
467
474
 
468
475
  function runtimeSelectionHeaders(
469
476
  runtime: PlayRuntimeSelection | undefined,
477
+ env: ClientEnvironment,
470
478
  ): Record<string, string> | undefined {
471
479
  if (!runtime) return undefined;
472
480
  // Keep the credential out of the typed runtime payload. The app consumes it
473
481
  // at the HTTP boundary and never forwards it to Fly, Absurd, or Daytona.
474
- const token = process.env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
482
+ const token = env.DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN?.trim();
475
483
  if (!token) {
476
484
  throw new DeeplineError(
477
485
  'DEEPLINE_RUNTIME_ENVIRONMENT_TOKEN is required for explicit preview runtime selection.',
@@ -480,7 +488,7 @@ function runtimeSelectionHeaders(
480
488
  );
481
489
  }
482
490
  const receivers =
483
- process.env.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim();
491
+ env.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim();
484
492
  return {
485
493
  [RUNTIME_ENVIRONMENT_TOKEN_HEADER]: token,
486
494
  ...(receivers ? { [RETAINED_PIPELINE_RECEIVERS_HEADER]: receivers } : {}),
@@ -488,18 +496,18 @@ function runtimeSelectionHeaders(
488
496
  }
489
497
 
490
498
  /** The isolated PR estate needs its existing internal credential to read its pinned scheduler scope. */
491
- function isolatedCiRuntimeEventReadHeaders():
492
- | Record<string, string>
493
- | undefined {
494
- const schema = process.env.DEEPLINE_RUNTIME_SCHEDULER_SCHEMA?.trim();
499
+ function isolatedCiRuntimeEventReadHeaders(
500
+ env: ClientEnvironment,
501
+ ): Record<string, string> | undefined {
502
+ const schema = env.DEEPLINE_RUNTIME_SCHEDULER_SCHEMA?.trim();
495
503
  if (
496
- process.env.DEEPLINE_SYNTHETIC_RUN?.trim() !== '1' ||
504
+ env.DEEPLINE_SYNTHETIC_RUN?.trim() !== '1' ||
497
505
  !schema ||
498
506
  !/^fly_absurd_pr_\d+_\d+(?:_\d+)?$/.test(schema)
499
507
  ) {
500
508
  return undefined;
501
509
  }
502
- const token = process.env.DEEPLINE_INTERNAL_TOKEN?.trim();
510
+ const token = env.DEEPLINE_INTERNAL_TOKEN?.trim();
503
511
  if (!token) {
504
512
  throw new DeeplineError(
505
513
  'DEEPLINE_INTERNAL_TOKEN is required for isolated CI runtime event reads.',
@@ -524,11 +532,10 @@ function normalizeTestPolicyOverrides(
524
532
  );
525
533
  }
526
534
 
527
- function parseEnvTestPolicyOverrides(): Record<string, unknown> | undefined {
528
- const raw =
529
- typeof process !== 'undefined'
530
- ? process.env?.DEEPLINE_TEST_POLICY_OVERRIDES
531
- : undefined;
535
+ function parseEnvTestPolicyOverrides(
536
+ env: ClientEnvironment,
537
+ ): Record<string, unknown> | undefined {
538
+ const raw = env.DEEPLINE_TEST_POLICY_OVERRIDES;
532
539
  const trimmed = raw?.trim();
533
540
  if (!trimmed) return undefined;
534
541
  let parsed: unknown;
@@ -2846,6 +2853,7 @@ export class DeeplineClient {
2846
2853
  private readonly http: HttpClient;
2847
2854
  private readonly toolCalls: ToolCalls;
2848
2855
  private readonly config: ResolvedConfig;
2856
+ private readonly environment: ClientEnvironment;
2849
2857
  /** Canonical run lifecycle namespace backed by `/api/v2/runs`. */
2850
2858
  readonly runs: RunsNamespace;
2851
2859
  /** Current mutable customer database namespace backed by `/api/v2/db/query`. */
@@ -2868,6 +2876,7 @@ export class DeeplineClient {
2868
2876
  */
2869
2877
  constructor(options?: DeeplineClientOptions) {
2870
2878
  this.config = resolveConfig(options);
2879
+ this.environment = this.config.environment ?? process.env;
2871
2880
  this.http = new HttpClient(this.config);
2872
2881
  this.toolCalls = new ToolCalls(
2873
2882
  this.http,
@@ -3556,11 +3565,11 @@ export class DeeplineClient {
3556
3565
  * ```
3557
3566
  */
3558
3567
  async startPlayRun(request: StartPlayRunRequest): Promise<PlayRunStart> {
3559
- const resolved = resolveStartPlayRunRequest(request);
3568
+ const resolved = resolveStartPlayRunRequest(request, this.environment);
3560
3569
  return startPlayRun(
3561
3570
  this.http,
3562
3571
  resolved.request,
3563
- runtimeSelectionHeaders(resolved.runtime),
3572
+ runtimeSelectionHeaders(resolved.runtime, this.environment),
3564
3573
  );
3565
3574
  }
3566
3575
 
@@ -3581,14 +3590,14 @@ export class DeeplineClient {
3581
3590
  request: StartPlayRunRequest,
3582
3591
  options?: { signal?: AbortSignal },
3583
3592
  ): AsyncGenerator<PlayLiveEvent> {
3584
- const resolved = resolveStartPlayRunRequest(request);
3593
+ const resolved = resolveStartPlayRunRequest(request, this.environment);
3585
3594
  const body = buildPlayRunStartBody(resolved.request);
3586
3595
  for await (const event of this.http.streamSse<PlayLiveEvent>(
3587
3596
  PLAY_RUN_START_STREAM_PATH,
3588
3597
  {
3589
3598
  method: 'POST',
3590
3599
  body,
3591
- headers: runtimeSelectionHeaders(resolved.runtime),
3600
+ headers: runtimeSelectionHeaders(resolved.runtime, this.environment),
3592
3601
  signal: options?.signal,
3593
3602
  },
3594
3603
  )) {
@@ -3806,7 +3815,7 @@ export class DeeplineClient {
3806
3815
  }>;
3807
3816
  }): Promise<PlayCheckResult> {
3808
3817
  const integrationMode = normalizePlayRunIntegrationMode(
3809
- input.integrationMode ?? process.env.DEEPLINE_EVAL_INTEGRATION_MODE,
3818
+ input.integrationMode ?? this.environment.DEEPLINE_EVAL_INTEGRATION_MODE,
3810
3819
  );
3811
3820
  return this.http.post('/api/v2/plays/check', {
3812
3821
  ...input,
@@ -4943,10 +4952,10 @@ export class DeeplineClient {
4943
4952
  params.set('runtime', 'preview');
4944
4953
  params.set('namespace', runtime.namespace);
4945
4954
  if (runtime.backend) params.set('backend', runtime.backend);
4946
- headers = runtimeSelectionHeaders(runtime);
4955
+ headers = runtimeSelectionHeaders(runtime, this.environment);
4947
4956
  selectedRuntime = runtime;
4948
4957
  } else {
4949
- headers = isolatedCiRuntimeEventReadHeaders();
4958
+ headers = isolatedCiRuntimeEventReadHeaders(this.environment);
4950
4959
  }
4951
4960
  const suffix = params.size > 0 ? `?${params.toString()}` : '';
4952
4961
  const result = await this.http.post<T>(
@@ -5015,9 +5024,9 @@ export class DeeplineClient {
5015
5024
  params.set('runtime', 'preview');
5016
5025
  params.set('namespace', runtime.namespace);
5017
5026
  if (runtime.backend) params.set('backend', runtime.backend);
5018
- headers = runtimeSelectionHeaders(runtime);
5027
+ headers = runtimeSelectionHeaders(runtime, this.environment);
5019
5028
  } else {
5020
- headers = isolatedCiRuntimeEventReadHeaders();
5029
+ headers = isolatedCiRuntimeEventReadHeaders(this.environment);
5021
5030
  }
5022
5031
  return this.http.get<RunsEventSearchResult>(
5023
5032
  `/api/v2/runs/events?${params.toString()}`,
@@ -7330,6 +7339,20 @@ export class DeeplineClient {
7330
7339
  }
7331
7340
  }
7332
7341
 
7342
+ /**
7343
+ * The workspace and user this client's API key authenticates as.
7344
+ *
7345
+ * @example
7346
+ * ```typescript
7347
+ * const status = await client.authStatus();
7348
+ * ```
7349
+ */
7350
+ async authStatus(): Promise<Record<string, unknown>> {
7351
+ return this.http.post<Record<string, unknown>>('/api/v2/auth/cli/status', {
7352
+ api_key: this.config.apiKey,
7353
+ });
7354
+ }
7355
+
7333
7356
  /**
7334
7357
  * Check API connectivity and server health.
7335
7358
  *
@@ -7361,4 +7384,4 @@ export class DeeplineClient {
7361
7384
  }
7362
7385
  }
7363
7386
 
7364
- export type { PlayRunListItem, PlayStatus } from './types.js';
7387
+ export type { PlayRunListItem, PlayStatus } from './types';
@@ -42,8 +42,8 @@ import {
42
42
  } from 'node:fs';
43
43
  import { homedir } from 'node:os';
44
44
  import { dirname, isAbsolute, join, resolve } from 'node:path';
45
- import type { DeeplineClientOptions, ResolvedConfig } from './types.js';
46
- import { ConfigError } from './errors.js';
45
+ import type { DeeplineClientOptions, ResolvedConfig } from './types';
46
+ import { ConfigError } from './errors';
47
47
 
48
48
  export const HOST_URL_ENV = 'DEEPLINE_HOST_URL';
49
49
  export const API_KEY_ENV = 'DEEPLINE_API_KEY';
@@ -659,6 +659,7 @@ export function resolveConfig(options?: DeeplineClientOptions): ResolvedConfig {
659
659
  // Pass through untouched: the transport owns case-insensitive merging so
660
660
  // there is exactly one place that decides which header wins.
661
661
  ...(options?.headers ? { headers: { ...options.headers } } : {}),
662
+ ...(options?.environment ? { environment: options.environment } : {}),
662
663
  };
663
664
  }
664
665
 
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  CustomerDbQueryOutcomeUnknownError,
3
3
  DeeplineError,
4
- } from '../errors.js';
5
- import type { HttpClient } from '../http.js';
6
- import type { CustomerDbQueryResult } from '../types.js';
4
+ } from '../errors';
5
+ import type { HttpClient } from '../http';
6
+ import type { CustomerDbQueryResult } from '../types';
7
7
 
8
8
  export type CustomerDbQueryOptions = {
9
9
  sql: string;
@@ -1,9 +1,11 @@
1
1
  /** Headers shared by SDK requests and the CLI's directory deployment body. */
2
- export function deploymentProtectionHeaders(): Record<string, string> {
3
- const token =
4
- typeof process !== 'undefined'
5
- ? process.env?.VERCEL_PROTECTION_BYPASS_TOKEN
6
- : undefined;
2
+ export function deploymentProtectionHeaders(
3
+ env: Readonly<Record<string, string | undefined>> = typeof process !==
4
+ 'undefined'
5
+ ? process.env
6
+ : {},
7
+ ): Record<string, string> {
8
+ const token = env.VERCEL_PROTECTION_BYPASS_TOKEN;
7
9
  return token ? { 'x-vercel-protection-bypass': token } : {};
8
10
  }
9
11
 
@@ -20,29 +20,29 @@
20
20
  *
21
21
  * @module
22
22
  */
23
- import type { ResolvedConfig } from './types.js';
23
+ import type { ResolvedConfig } from './types';
24
24
  import {
25
25
  AuthError,
26
26
  DeeplineError,
27
27
  RateLimitError,
28
28
  ToolExecutionError,
29
29
  ToolRateLimitError,
30
- } from './errors.js';
30
+ } from './errors';
31
31
  import {
32
32
  deserializeToolExecutionFailure,
33
33
  serializeToolExecutionFailure,
34
34
  TOOL_EXECUTION_ERROR_SCHEMA_VERSION,
35
35
  } from '../../shared_libs/plays/tool-execution-error';
36
- import { SDK_API_CONTRACT, SDK_VERSION } from './version.js';
36
+ import { SDK_API_CONTRACT, SDK_VERSION } from './version';
37
37
  import { apiErrorCodeFromResponse, apiErrorMessage } from './api-error';
38
- import type { LiveEventEnvelope } from './types.js';
38
+ import type { LiveEventEnvelope } from './types';
39
39
  import {
40
40
  agentSessionIdFromEnvironment,
41
41
  detectAgentRuntime,
42
42
  isCoworkLikeSandbox,
43
- } from './agent-runtime.js';
44
- import { readSdkSkillsLocalVersion } from './skills-version.js';
45
- import { deploymentProtectionHeaders } from './deployment-protection.js';
43
+ } from './agent-runtime';
44
+ import { readSdkSkillsLocalVersion } from './skills-version';
45
+ import { deploymentProtectionHeaders } from './deployment-protection';
46
46
  import {
47
47
  ABSURD_RELEASE_OVERRIDE_HEADER,
48
48
  RETAINED_PIPELINE_RECEIVERS_HEADER,
@@ -268,9 +268,16 @@ export class HttpClient {
268
268
  return normalized || null;
269
269
  }
270
270
 
271
+ private environment(): Readonly<Record<string, string | undefined>> {
272
+ return (
273
+ this.config.environment ??
274
+ (typeof process !== 'undefined' ? process.env : {})
275
+ );
276
+ }
277
+
271
278
  private readSkillsVersionHeader(): string | null {
272
279
  const explicit = this.cleanDiagnosticHeader(
273
- process.env.DEEPLINE_SKILLS_VERSION,
280
+ this.environment().DEEPLINE_SKILLS_VERSION,
274
281
  );
275
282
  if (explicit) return explicit;
276
283
  try {
@@ -283,63 +290,52 @@ export class HttpClient {
283
290
  }
284
291
 
285
292
  private authHeaders(extra?: Record<string, string>): Record<string, string> {
293
+ const env = this.environment();
286
294
  const transportHeaders: Record<string, string> = {
287
295
  Authorization: `Bearer ${this.config.apiKey}`,
288
296
  'User-Agent': `deepline-ts-sdk/${SDK_VERSION}`,
289
297
  'X-Deepline-Client-Family': 'sdk',
290
298
  'X-Deepline-CLI-Family': 'sdk',
291
- 'X-Deepline-Agent-Runtime': detectAgentRuntime(),
299
+ 'X-Deepline-Agent-Runtime': detectAgentRuntime(
300
+ this.config.environment ? { env, detectCowork: false } : {},
301
+ ),
292
302
  'X-Deepline-CLI-Version': SDK_VERSION,
293
303
  'X-Deepline-SDK-Version': SDK_VERSION,
294
304
  'X-Deepline-API-Contract': SDK_API_CONTRACT,
295
305
  'X-Deepline-Run-Result-Shape': 'canonical',
296
306
  };
297
- const headers = deploymentProtectionHeaders();
307
+ const headers = deploymentProtectionHeaders(env);
298
308
  const skillsVersion = this.readSkillsVersionHeader();
299
309
  if (skillsVersion) {
300
310
  headers['X-Deepline-Skills-Version'] = skillsVersion;
301
311
  }
302
- const agentSessionId = agentSessionIdFromEnvironment();
312
+ const agentSessionId = agentSessionIdFromEnvironment(env);
303
313
  if (agentSessionId) {
304
314
  headers['X-Deepline-Agent-Session-Id'] = agentSessionId;
305
315
  }
306
316
  const playArtifactR2Prefix =
307
- typeof process !== 'undefined'
308
- ? process.env?.DEEPLINE_PLAY_ARTIFACT_R2_PREFIX
309
- : undefined;
317
+ env.DEEPLINE_PLAY_ARTIFACT_R2_PREFIX;
310
318
  if (playArtifactR2Prefix) {
311
319
  headers['x-deepline-play-artifact-r2-prefix'] = playArtifactR2Prefix;
312
320
  }
313
321
  const coordinatorUrl =
314
- typeof process !== 'undefined'
315
- ? process.env?.DEEPLINE_COORDINATOR_URL
316
- : undefined;
322
+ env.DEEPLINE_COORDINATOR_URL;
317
323
  const coordinatorInternalToken =
318
- typeof process !== 'undefined'
319
- ? process.env?.DEEPLINE_INTERNAL_TOKEN
320
- : undefined;
324
+ env.DEEPLINE_INTERNAL_TOKEN;
321
325
  const absurdReleaseOverride =
322
- typeof process !== 'undefined'
323
- ? process.env?.DEEPLINE_ABSURD_RELEASE
324
- : undefined;
326
+ env.DEEPLINE_ABSURD_RELEASE;
325
327
  const preferredReceiptGatewayMachineId =
326
- typeof process !== 'undefined'
327
- ? process.env?.DEEPLINE_PREFERRED_RECEIPT_GATEWAY_MACHINE_ID
328
- : undefined;
328
+ env.DEEPLINE_PREFERRED_RECEIPT_GATEWAY_MACHINE_ID;
329
329
  if (coordinatorUrl?.trim()) {
330
330
  headers[COORDINATOR_URL_OVERRIDE_HEADER] = coordinatorUrl.trim();
331
331
  }
332
332
  const workerCallbackUrl =
333
- typeof process !== 'undefined'
334
- ? process.env?.DEEPLINE_WORKER_CALLBACK_URL
335
- : undefined;
333
+ env.DEEPLINE_WORKER_CALLBACK_URL;
336
334
  if (workerCallbackUrl?.trim()) {
337
335
  headers[WORKER_CALLBACK_URL_OVERRIDE_HEADER] = workerCallbackUrl.trim();
338
336
  }
339
337
  const runtimeSchedulerSchema =
340
- typeof process !== 'undefined'
341
- ? process.env?.DEEPLINE_RUNTIME_SCHEDULER_SCHEMA
342
- : undefined;
338
+ env.DEEPLINE_RUNTIME_SCHEDULER_SCHEMA;
343
339
  if (runtimeSchedulerSchema?.trim()) {
344
340
  headers[RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER] =
345
341
  runtimeSchedulerSchema.trim();
@@ -348,25 +344,19 @@ export class HttpClient {
348
344
  // so their intentionally failing plays do not page the SDK CLI error
349
345
  // channel. Honored server-side only in non-prod (see plays/run route).
350
346
  const syntheticRun =
351
- typeof process !== 'undefined'
352
- ? process.env?.DEEPLINE_SYNTHETIC_RUN
353
- : undefined;
347
+ env.DEEPLINE_SYNTHETIC_RUN;
354
348
  if (syntheticRun && syntheticRun.trim() && syntheticRun.trim() !== '0') {
355
349
  headers[SYNTHETIC_RUN_HEADER] = '1';
356
350
  }
357
351
  // Test-only runtime seam. The server validates both environment and value
358
352
  // before honoring this header.
359
353
  const runtimeTestFault =
360
- typeof process !== 'undefined'
361
- ? process.env?.DEEPLINE_TEST_RUNTIME_FAULT
362
- : undefined;
354
+ env.DEEPLINE_TEST_RUNTIME_FAULT;
363
355
  if (runtimeTestFault?.trim()) {
364
356
  headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
365
357
  }
366
358
  const retainedReceivers =
367
- typeof process !== 'undefined'
368
- ? process.env?.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim()
369
- : undefined;
359
+ env.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS?.trim();
370
360
  if (retainedReceivers && coordinatorInternalToken?.trim()) {
371
361
  headers[RETAINED_PIPELINE_RECEIVERS_HEADER] = retainedReceivers;
372
362
  headers[COORDINATOR_INTERNAL_TOKEN_HEADER] =