deepline 0.3.390 → 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 (123) 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/plays/local-file-discovery.ts +1 -1
  23. package/dist/cli/{auth-THPE72WM.mjs → auth-6QET7NFP.mjs} +4 -4
  24. package/dist/cli/auth-6ZUH42ZA.js +39 -0
  25. package/dist/cli/{billing-52KJIWW2.mjs → billing-HAQ2VDQX.mjs} +4 -4
  26. package/dist/cli/{billing-YRXEPKPB.js → billing-KJAGTCFR.js} +73 -73
  27. package/dist/cli/{chunk-TLCCVMSB.js → chunk-4S6X74A3.js} +2 -2
  28. package/dist/cli/{chunk-HXENYWVS.js → chunk-4TCT77UF.js} +485 -114
  29. package/dist/cli/{chunk-KUEYQLM3.js → chunk-556BMGEB.js} +235 -220
  30. package/dist/cli/{chunk-KZOKUN3N.mjs → chunk-6L4P7Z6C.mjs} +2 -2
  31. package/dist/cli/{chunk-NQZW72DN.mjs → chunk-DRZFTRZJ.mjs} +46 -31
  32. package/dist/cli/{chunk-ENJWB4SX.js → chunk-ED42XCOW.js} +226 -226
  33. package/dist/cli/{chunk-B22POC3J.mjs → chunk-H2ER7QWR.mjs} +6 -6
  34. package/dist/cli/{chunk-Z7LX4WYM.mjs → chunk-H3DCZOXR.mjs} +5 -5
  35. package/dist/cli/{chunk-JV7YZMNK.mjs → chunk-HFTOOZGN.mjs} +3 -3
  36. package/dist/cli/{chunk-FKFE3WH3.mjs → chunk-I3MKXASV.mjs} +2 -2
  37. package/dist/cli/{chunk-MI2JQCYZ.js → chunk-I7EVBLTW.js} +6 -6
  38. package/dist/cli/{chunk-DNYNJU5J.mjs → chunk-K3ODOHOI.mjs} +34 -26
  39. package/dist/cli/{chunk-L7NEMEUI.js → chunk-KA7X75HC.js} +48 -48
  40. package/dist/cli/{chunk-EMJB62SM.mjs → chunk-KWF4HJF7.mjs} +1 -1
  41. package/dist/cli/{chunk-UCPH7S5H.js → chunk-ME2DZAHC.js} +26 -26
  42. package/dist/cli/{chunk-CZUGLUQK.js → chunk-MHLCMJ2E.js} +99 -91
  43. package/dist/cli/{chunk-RWOX543D.mjs → chunk-PFPP4BKS.mjs} +2 -2
  44. package/dist/cli/{chunk-HVDBGPDP.mjs → chunk-PQSA443V.mjs} +485 -114
  45. package/dist/cli/{chunk-CU7GDBBM.mjs → chunk-QCWIORKR.mjs} +2 -2
  46. package/dist/cli/{chunk-PMNJLCIA.js → chunk-RA2SDTSX.js} +15 -15
  47. package/dist/cli/{chunk-QANTWJXH.js → chunk-RTH26NF3.js} +61 -61
  48. package/dist/cli/{chunk-653YVNNZ.mjs → chunk-TLHF54VX.mjs} +1 -1
  49. package/dist/cli/{chunk-T5JMOYB4.js → chunk-UOSKJIXE.js} +8 -8
  50. package/dist/cli/{chunk-5KD4F7NR.mjs → chunk-VH4B5OYM.mjs} +1 -1
  51. package/dist/cli/{chunk-OV567DMC.js → chunk-WLODHQ7S.js} +1 -1
  52. package/dist/cli/{chunk-ZFZ5PICC.js → chunk-XBPLTHGB.js} +8 -8
  53. package/dist/cli/{chunk-QVMRQYSO.js → chunk-XEV5LMS2.js} +50 -50
  54. package/dist/cli/{chunk-ICZQGDYM.mjs → chunk-YBZY3EZF.mjs} +4 -4
  55. package/dist/cli/command-docs.d.mts +24 -1
  56. package/dist/cli/command-docs.d.ts +24 -1
  57. package/dist/cli/command-docs.js +8 -2
  58. package/dist/cli/command-docs.mjs +9 -3
  59. package/dist/cli/{csv-JYDWK56E.js → csv-2WSF5TEM.js} +12 -12
  60. package/dist/cli/{csv-IPUY3W6Z.mjs → csv-V7UHOBFE.mjs} +3 -3
  61. package/dist/cli/{db-DAWM3T76.js → db-42RL4FZD.js} +29 -29
  62. package/dist/cli/{db-IP5IPYJQ.mjs → db-TD375E4N.mjs} +4 -4
  63. package/dist/cli/{describe-5UWGF33U.js → describe-7WFCBZUY.js} +18 -18
  64. package/dist/cli/{describe-3RTUG7EW.mjs → describe-GPUKAWOZ.mjs} +8 -8
  65. package/dist/cli/{executions-OEKC7TL5.js → executions-LGVG3FPH.js} +6 -6
  66. package/dist/cli/{executions-7ZNMR443.mjs → executions-M7O63JNA.mjs} +4 -4
  67. package/dist/cli/{feedback-IUJV565X.mjs → feedback-6PBSKVB2.mjs} +3 -3
  68. package/dist/cli/{feedback-5F2NQJP4.js → feedback-PZZA2M4S.js} +7 -7
  69. package/dist/cli/{git-IPV5G2PS.mjs → git-2VIFM5DI.mjs} +4 -4
  70. package/dist/cli/git-ZSJD3BID.js +23 -0
  71. package/dist/cli/index.js +93 -93
  72. package/dist/cli/index.mjs +33 -33
  73. package/dist/cli/{legacy-noops-UQOWD66P.mjs → legacy-noops-DPUBZI7N.mjs} +4 -4
  74. package/dist/cli/{legacy-noops-IZZRWI7V.js → legacy-noops-IQ6QTZNZ.js} +7 -7
  75. package/dist/cli/{monitors-N6WK7YPE.js → monitors-6GWAZFYV.js} +85 -85
  76. package/dist/cli/{monitors-SULGYCTF.mjs → monitors-KBZVQG2U.mjs} +4 -4
  77. package/dist/cli/{org-EPVTTBDK.mjs → org-CP3VSJBX.mjs} +4 -4
  78. package/dist/cli/{org-COMHSC5H.js → org-JKGTHXOZ.js} +64 -64
  79. package/dist/cli/{play-OCTPASJI.mjs → play-DD2ME4L4.mjs} +7 -7
  80. package/dist/cli/play-G5GVMIBN.js +157 -0
  81. package/dist/cli/{providers-QBVNC5EV.mjs → providers-JUNOFKI7.mjs} +4 -4
  82. package/dist/cli/{providers-34D6ATLE.js → providers-P34QYYG6.js} +7 -7
  83. package/dist/cli/{quickstart-SYGV5XVH.mjs → quickstart-N6SWOK7E.mjs} +3 -3
  84. package/dist/cli/{quickstart-3XR45BHI.js → quickstart-UL3DEFA4.js} +5 -5
  85. package/dist/cli/{search-UUJ7EHBV.mjs → search-SC7I56HX.mjs} +5 -5
  86. package/dist/cli/search-W4GXWTOM.js +26 -0
  87. package/dist/cli/{secrets-TIL6DESO.js → secrets-6ZJE7ZPM.js} +13 -13
  88. package/dist/cli/{secrets-MWRFHNIT.mjs → secrets-RTARNYF5.mjs} +4 -4
  89. package/dist/cli/{sessions-2LXC6ZYD.js → sessions-6IZ2XHGW.js} +5 -5
  90. package/dist/cli/{sessions-5TKMBU5P.mjs → sessions-7RKV2T3O.mjs} +4 -4
  91. package/dist/cli/{settings-NRIACLPU.mjs → settings-V6PXA6HY.mjs} +7 -7
  92. package/dist/cli/{settings-II3IQECQ.js → settings-YX3XJDXE.js} +74 -74
  93. package/dist/cli/{setup-AF3UMIIC.js → setup-CQ5VRNNU.js} +41 -41
  94. package/dist/cli/{setup-VIMZ4U73.mjs → setup-V2O4UJNT.mjs} +6 -6
  95. package/dist/cli/skills-LBZPJTPI.js +28 -0
  96. package/dist/cli/{skills-5OKAXXWJ.mjs → skills-VHJZWEHA.mjs} +4 -4
  97. package/dist/cli/{tools-5UXNV4YY.mjs → tools-OD5WKEWY.mjs} +6 -6
  98. package/dist/cli/tools-TQNM473H.js +40 -0
  99. package/dist/cli/{update-Q4HX6CR3.mjs → update-CRMNOMJ3.mjs} +6 -6
  100. package/dist/cli/update-QY6GAK6B.js +28 -0
  101. package/dist/cli/{workflow-45BLG7GN.mjs → workflow-EVDYNCDD.mjs} +5 -5
  102. package/dist/cli/{workflow-NZZ5H4P4.js → workflow-XHORSD5T.js} +15 -15
  103. package/dist/{client-DEKvymBI.d.ts → client-BhK9kix9.d.ts} +19 -0
  104. package/dist/{client-0avPvYBP.d.mts → client-DpzZi4fU.d.mts} +19 -0
  105. package/dist/index.d.mts +2 -2
  106. package/dist/index.d.ts +2 -2
  107. package/dist/index.js +6 -6
  108. package/dist/index.mjs +3 -3
  109. package/dist/install-integrity.json +76 -76
  110. package/dist/plays/run-request.d.mts +1 -1
  111. package/dist/plays/run-request.d.ts +1 -1
  112. package/dist/release.d.mts +1 -1
  113. package/dist/release.d.ts +1 -1
  114. package/dist/release.js +2 -2
  115. package/dist/release.mjs +1 -1
  116. package/package.json +1 -1
  117. package/dist/cli/auth-OVT7BZ5A.js +0 -39
  118. package/dist/cli/git-ZZ5MD2KG.js +0 -23
  119. package/dist/cli/play-RWY2JHAP.js +0 -157
  120. package/dist/cli/search-PTG76HU3.js +0 -26
  121. package/dist/cli/skills-I6NTZMBZ.js +0 -28
  122. package/dist/cli/tools-NXD7YFYV.js +0 -40
  123. package/dist/cli/update-SZ6AMT3M.js +0 -28
@@ -14,7 +14,7 @@ var _chunkXNYIZMNQjs = require('./chunk-XNYIZMNQ.js');
14
14
  var _chunk7P5AA3SNjs = require('./chunk-7P5AA3SN.js');
15
15
 
16
16
 
17
- var _chunkOV567DMCjs = require('./chunk-OV567DMC.js');
17
+ var _chunkWLODHQ7Sjs = require('./chunk-WLODHQ7S.js');
18
18
 
19
19
  // src/errors.ts
20
20
  var CustomerDbQueryOutcomeUnknownError = (_class = class extends _chunk7P5AA3SNjs.DeeplineError {
@@ -501,7 +501,8 @@ function resolveConfig(options) {
501
501
  maxRetries: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _40 => _40.maxRetries]), () => ( DEFAULT_MAX_RETRIES)),
502
502
  // Pass through untouched: the transport owns case-insensitive merging so
503
503
  // there is exactly one place that decides which header wins.
504
- ..._optionalChain([options, 'optionalAccess', _41 => _41.headers]) ? { headers: { ...options.headers } } : {}
504
+ ..._optionalChain([options, 'optionalAccess', _41 => _41.headers]) ? { headers: { ...options.headers } } : {},
505
+ ..._optionalChain([options, 'optionalAccess', _42 => _42.environment]) ? { environment: options.environment } : {}
505
506
  };
506
507
  }
507
508
  function mergeProjectEnvFile(filePath, values) {
@@ -571,7 +572,7 @@ function findNearestGitCommonDir(startDir) {
571
572
  const match = _fs.readFileSync.call(void 0, candidate, "utf8").match(
572
573
  /^gitdir:\s*(.+)$/m
573
574
  );
574
- const rawGitDir = _optionalChain([match, 'optionalAccess', _42 => _42[1], 'optionalAccess', _43 => _43.trim, 'call', _44 => _44()]);
575
+ const rawGitDir = _optionalChain([match, 'optionalAccess', _43 => _43[1], 'optionalAccess', _44 => _44.trim, 'call', _45 => _45()]);
575
576
  if (rawGitDir) {
576
577
  const gitDir = _path.isAbsolute.call(void 0, rawGitDir) ? rawGitDir : _path.resolve.call(void 0, _path.dirname.call(void 0, candidate), rawGitDir);
577
578
  const commonDirPath = _path.join.call(void 0, gitDir, "commondir");
@@ -643,7 +644,7 @@ function findNearestProjectMarkerDir(startDir) {
643
644
  }
644
645
  }
645
646
  function resolveCliAuthProvenance(config, startDir = process.cwd()) {
646
- const envApiKey = _optionalChain([process, 'access', _45 => _45.env, 'access', _46 => _46[API_KEY_ENV], 'optionalAccess', _47 => _47.trim, 'call', _48 => _48()]);
647
+ const envApiKey = _optionalChain([process, 'access', _46 => _46.env, 'access', _47 => _47[API_KEY_ENV], 'optionalAccess', _48 => _48.trim, 'call', _49 => _49()]);
647
648
  const folderAuth = getResolvedProjectAuthSource(
648
649
  config.baseUrl,
649
650
  config.apiKey,
@@ -673,13 +674,13 @@ function resolveCliAuthProvenance(config, startDir = process.cwd()) {
673
674
  return {
674
675
  scope: envApiKey ? "env" : folderAuth ? "folder" : "global",
675
676
  project,
676
- folderAuthPath: _nullishCoalesce(_optionalChain([folderAuth, 'optionalAccess', _49 => _49.filePath]), () => ( null))
677
+ folderAuthPath: _nullishCoalesce(_optionalChain([folderAuth, 'optionalAccess', _50 => _50.filePath]), () => ( null))
677
678
  };
678
679
  }
679
680
  function activeOrganizationFromEnv(env) {
680
- const orgId = _optionalChain([env, 'access', _50 => _50[ACTIVE_ORG_ID_ENV], 'optionalAccess', _51 => _51.trim, 'call', _52 => _52()]);
681
+ const orgId = _optionalChain([env, 'access', _51 => _51[ACTIVE_ORG_ID_ENV], 'optionalAccess', _52 => _52.trim, 'call', _53 => _53()]);
681
682
  if (!orgId) return null;
682
- const orgName = _optionalChain([env, 'access', _53 => _53[ACTIVE_ORG_NAME_ENV], 'optionalAccess', _54 => _54.trim, 'call', _55 => _55()]) || null;
683
+ const orgName = _optionalChain([env, 'access', _54 => _54[ACTIVE_ORG_NAME_ENV], 'optionalAccess', _55 => _55.trim, 'call', _56 => _56()]) || null;
683
684
  return { org_id: orgId, org_name: orgName };
684
685
  }
685
686
  function resolveCliCommandContext(inputConfig, requestedScope) {
@@ -697,7 +698,7 @@ function resolveCliCommandContext(inputConfig, requestedScope) {
697
698
  }
698
699
  const contextForScope = (scope) => {
699
700
  if (scope === "env") {
700
- const processApiKey = _optionalChain([process, 'access', _56 => _56.env, 'access', _57 => _57[API_KEY_ENV], 'optionalAccess', _58 => _58.trim, 'call', _59 => _59()]);
701
+ const processApiKey = _optionalChain([process, 'access', _57 => _57.env, 'access', _58 => _58[API_KEY_ENV], 'optionalAccess', _59 => _59.trim, 'call', _60 => _60()]);
701
702
  return processApiKey && processApiKey === config.apiKey ? {
702
703
  active_organization: activeOrganizationFromEnv(process.env),
703
704
  auth_scope: "env",
@@ -743,9 +744,9 @@ function resolveCliCommandContext(inputConfig, requestedScope) {
743
744
  }
744
745
 
745
746
  // src/version.ts
746
- var SDK_VERSION = _chunkOV567DMCjs.SDK_RELEASE.version;
747
- var SDK_API_MAJOR = _chunkOV567DMCjs.SDK_RELEASE.contracts.api.currentMajor;
748
- var SDK_API_CONTRACT = _nullishCoalesce(_chunkOV567DMCjs.SDK_RELEASE.contracts.api.legacyWireIds[0], () => ( `api-v${SDK_API_MAJOR}`));
747
+ var SDK_VERSION = _chunkWLODHQ7Sjs.SDK_RELEASE.version;
748
+ var SDK_API_MAJOR = _chunkWLODHQ7Sjs.SDK_RELEASE.contracts.api.currentMajor;
749
+ var SDK_API_CONTRACT = _nullishCoalesce(_chunkWLODHQ7Sjs.SDK_RELEASE.contracts.api.legacyWireIds[0], () => ( `api-v${SDK_API_MAJOR}`));
749
750
 
750
751
  // src/agent-runtime.ts
751
752
 
@@ -766,7 +767,7 @@ function truthyEnv(name) {
766
767
  );
767
768
  }
768
769
  function normalizeAgentRuntime(value) {
769
- const explicit = _optionalChain([value, 'optionalAccess', _60 => _60.trim, 'call', _61 => _61(), 'access', _62 => _62.toLowerCase, 'call', _63 => _63(), 'access', _64 => _64.replace, 'call', _65 => _65(/-/g, "_")]);
770
+ const explicit = _optionalChain([value, 'optionalAccess', _61 => _61.trim, 'call', _62 => _62(), 'access', _63 => _63.toLowerCase, 'call', _64 => _64(), 'access', _65 => _65.replace, 'call', _66 => _66(/-/g, "_")]);
770
771
  if (!explicit) return null;
771
772
  if (explicit === "gemini_cli") return "gemini";
772
773
  return EXPLICIT_AGENT_RUNTIMES.has(explicit) ? explicit : null;
@@ -778,7 +779,7 @@ var AGENT_SESSION_ID_VARIABLES = [
778
779
  ];
779
780
  function agentSessionIdFromEnvironment(env = process.env) {
780
781
  for (const variable of AGENT_SESSION_ID_VARIABLES) {
781
- const sessionId = _optionalChain([env, 'access', _66 => _66[variable], 'optionalAccess', _67 => _67.trim, 'call', _68 => _68()]);
782
+ const sessionId = _optionalChain([env, 'access', _67 => _67[variable], 'optionalAccess', _68 => _68.trim, 'call', _69 => _69()]);
782
783
  if (sessionId) return sessionId;
783
784
  }
784
785
  return null;
@@ -786,31 +787,32 @@ function agentSessionIdFromEnvironment(env = process.env) {
786
787
  function isCoworkLikeSandbox2() {
787
788
  const pluginMode = truthyEnv("DEEPLINE_PLUGIN_MODE");
788
789
  const claudeRemote = truthyEnv("CLAUDE_CODE_REMOTE");
789
- const projectDir = Boolean(_optionalChain([process, 'access', _69 => _69.env, 'access', _70 => _70.CLAUDE_PROJECT_DIR, 'optionalAccess', _71 => _71.trim, 'call', _72 => _72()]));
790
- const pluginRoot = Boolean(_optionalChain([process, 'access', _73 => _73.env, 'access', _74 => _74.DEEPLINE_PLUGIN_ROOT, 'optionalAccess', _75 => _75.trim, 'call', _76 => _76()]));
791
- const home = _optionalChain([process, 'access', _77 => _77.env, 'access', _78 => _78.HOME, 'optionalAccess', _79 => _79.trim, 'call', _80 => _80()]) || _os.homedir.call(void 0, );
790
+ const projectDir = Boolean(_optionalChain([process, 'access', _70 => _70.env, 'access', _71 => _71.CLAUDE_PROJECT_DIR, 'optionalAccess', _72 => _72.trim, 'call', _73 => _73()]));
791
+ const pluginRoot = Boolean(_optionalChain([process, 'access', _74 => _74.env, 'access', _75 => _75.DEEPLINE_PLUGIN_ROOT, 'optionalAccess', _76 => _76.trim, 'call', _77 => _77()]));
792
+ const home = _optionalChain([process, 'access', _78 => _78.env, 'access', _79 => _79.HOME, 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]) || _os.homedir.call(void 0, );
792
793
  const sessionHome = home === "/sessions" || home.startsWith("/sessions/");
793
794
  return claudeRemote || sessionHome || (pluginMode || pluginRoot) && projectDir;
794
795
  }
795
796
  function detectAgentRuntime(options = {}) {
796
- const explicit = normalizeAgentRuntime(process.env.DEEPLINE_AGENT_RUNTIME);
797
+ const env = _nullishCoalesce(options.env, () => ( process.env));
798
+ const explicit = normalizeAgentRuntime(env.DEEPLINE_AGENT_RUNTIME);
797
799
  if (explicit) return explicit;
798
- if (_optionalChain([process, 'access', _81 => _81.env, 'access', _82 => _82.CODEX_THREAD_ID, 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()])) return "codex";
800
+ if (_optionalChain([env, 'access', _82 => _82.CODEX_THREAD_ID, 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()])) return "codex";
799
801
  if (options.detectCowork !== false && isCoworkLikeSandbox2()) {
800
802
  return "claude_cowork";
801
803
  }
802
- if (_optionalChain([process, 'access', _85 => _85.env, 'access', _86 => _86.CLAUDECODE, 'optionalAccess', _87 => _87.trim, 'call', _88 => _88()]) === "1") return "claude_code";
803
- if (_optionalChain([process, 'access', _89 => _89.env, 'access', _90 => _90.CLINE_ACTIVE, 'optionalAccess', _91 => _91.trim, 'call', _92 => _92(), 'access', _93 => _93.toLowerCase, 'call', _94 => _94()]) === "true") return "cline";
804
- if (_optionalChain([process, 'access', _95 => _95.env, 'access', _96 => _96.CURSOR_TRACE_ID, 'optionalAccess', _97 => _97.trim, 'call', _98 => _98()]) || _optionalChain([process, 'access', _99 => _99.env, 'access', _100 => _100.CURSOR_AGENT, 'optionalAccess', _101 => _101.trim, 'call', _102 => _102()])) {
804
+ if (_optionalChain([env, 'access', _85 => _85.CLAUDECODE, 'optionalAccess', _86 => _86.trim, 'call', _87 => _87()]) === "1") return "claude_code";
805
+ if (_optionalChain([env, 'access', _88 => _88.CLINE_ACTIVE, 'optionalAccess', _89 => _89.trim, 'call', _90 => _90(), 'access', _91 => _91.toLowerCase, 'call', _92 => _92()]) === "true") return "cline";
806
+ if (_optionalChain([env, 'access', _93 => _93.CURSOR_TRACE_ID, 'optionalAccess', _94 => _94.trim, 'call', _95 => _95()]) || _optionalChain([env, 'access', _96 => _96.CURSOR_AGENT, 'optionalAccess', _97 => _97.trim, 'call', _98 => _98()])) {
805
807
  return "cursor";
806
808
  }
807
- if (_optionalChain([process, 'access', _103 => _103.env, 'access', _104 => _104.WINDSURF, 'optionalAccess', _105 => _105.trim, 'call', _106 => _106()]) || _optionalChain([process, 'access', _107 => _107.env, 'access', _108 => _108.CASCADE, 'optionalAccess', _109 => _109.trim, 'call', _110 => _110()])) {
809
+ if (_optionalChain([env, 'access', _99 => _99.WINDSURF, 'optionalAccess', _100 => _100.trim, 'call', _101 => _101()]) || _optionalChain([env, 'access', _102 => _102.CASCADE, 'optionalAccess', _103 => _103.trim, 'call', _104 => _104()])) {
808
810
  return "windsurf";
809
811
  }
810
- if (_optionalChain([process, 'access', _111 => _111.env, 'access', _112 => _112.ANTIGRAVITY, 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()]) || _optionalChain([process, 'access', _115 => _115.env, 'access', _116 => _116.ANTIGRAVITY_CLI, 'optionalAccess', _117 => _117.trim, 'call', _118 => _118()]) || _optionalChain([process, 'access', _119 => _119.env, 'access', _120 => _120.ANTIGRAVITY_AGENT, 'optionalAccess', _121 => _121.trim, 'call', _122 => _122()]) || _optionalChain([process, 'access', _123 => _123.env, 'access', _124 => _124.ANTIGRAVITY_WORKSPACE, 'optionalAccess', _125 => _125.trim, 'call', _126 => _126()])) {
812
+ if (_optionalChain([env, 'access', _105 => _105.ANTIGRAVITY, 'optionalAccess', _106 => _106.trim, 'call', _107 => _107()]) || _optionalChain([env, 'access', _108 => _108.ANTIGRAVITY_CLI, 'optionalAccess', _109 => _109.trim, 'call', _110 => _110()]) || _optionalChain([env, 'access', _111 => _111.ANTIGRAVITY_AGENT, 'optionalAccess', _112 => _112.trim, 'call', _113 => _113()]) || _optionalChain([env, 'access', _114 => _114.ANTIGRAVITY_WORKSPACE, 'optionalAccess', _115 => _115.trim, 'call', _116 => _116()])) {
811
813
  return "antigravity";
812
814
  }
813
- if (_optionalChain([process, 'access', _127 => _127.env, 'access', _128 => _128.GEMINI_CLI, 'optionalAccess', _129 => _129.trim, 'call', _130 => _130()]) || _optionalChain([process, 'access', _131 => _131.env, 'access', _132 => _132.GEMINI_CLI_VERSION, 'optionalAccess', _133 => _133.trim, 'call', _134 => _134()]) || _optionalChain([process, 'access', _135 => _135.env, 'access', _136 => _136.GEMINI_SANDBOX, 'optionalAccess', _137 => _137.trim, 'call', _138 => _138()]) || _optionalChain([process, 'access', _139 => _139.env, 'access', _140 => _140.GEMINI_CONFIG_DIR, 'optionalAccess', _141 => _141.trim, 'call', _142 => _142()])) {
815
+ if (_optionalChain([env, 'access', _117 => _117.GEMINI_CLI, 'optionalAccess', _118 => _118.trim, 'call', _119 => _119()]) || _optionalChain([env, 'access', _120 => _120.GEMINI_CLI_VERSION, 'optionalAccess', _121 => _121.trim, 'call', _122 => _122()]) || _optionalChain([env, 'access', _123 => _123.GEMINI_SANDBOX, 'optionalAccess', _124 => _124.trim, 'call', _125 => _125()]) || _optionalChain([env, 'access', _126 => _126.GEMINI_CONFIG_DIR, 'optionalAccess', _127 => _127.trim, 'call', _128 => _128()])) {
814
816
  return "gemini";
815
817
  }
816
818
  return _nullishCoalesce(options.defaultRuntime, () => ( "unknown"));
@@ -820,11 +822,11 @@ function detectAgentRuntime(options = {}) {
820
822
 
821
823
 
822
824
  function activePluginSkillsDir() {
823
- const pluginMode = _optionalChain([process, 'access', _143 => _143.env, 'access', _144 => _144.DEEPLINE_PLUGIN_MODE, 'optionalAccess', _145 => _145.trim, 'call', _146 => _146(), 'access', _147 => _147.toLowerCase, 'call', _148 => _148()]);
825
+ const pluginMode = _optionalChain([process, 'access', _129 => _129.env, 'access', _130 => _130.DEEPLINE_PLUGIN_MODE, 'optionalAccess', _131 => _131.trim, 'call', _132 => _132(), 'access', _133 => _133.toLowerCase, 'call', _134 => _134()]);
824
826
  if (pluginMode !== "true" && pluginMode !== "1" && pluginMode !== "yes" && pluginMode !== "on") {
825
827
  return "";
826
828
  }
827
- const dir = _nullishCoalesce(_optionalChain([process, 'access', _149 => _149.env, 'access', _150 => _150.DEEPLINE_PLUGIN_SKILLS_DIR, 'optionalAccess', _151 => _151.trim, 'call', _152 => _152()]), () => ( ""));
829
+ const dir = _nullishCoalesce(_optionalChain([process, 'access', _135 => _135.env, 'access', _136 => _136.DEEPLINE_PLUGIN_SKILLS_DIR, 'optionalAccess', _137 => _137.trim, 'call', _138 => _138()]), () => ( ""));
828
830
  return dir && _fs.existsSync.call(void 0, dir) ? dir : "";
829
831
  }
830
832
  function hasActivePluginSkills() {
@@ -945,15 +947,15 @@ function writeSdkSkillsLocalVersion(baseUrl, version, agents) {
945
947
  }
946
948
 
947
949
  // src/deployment-protection.ts
948
- function deploymentProtectionHeaders() {
949
- const token = typeof process !== "undefined" ? _optionalChain([process, 'access', _153 => _153.env, 'optionalAccess', _154 => _154.VERCEL_PROTECTION_BYPASS_TOKEN]) : void 0;
950
+ function deploymentProtectionHeaders(env = typeof process !== "undefined" ? process.env : {}) {
951
+ const token = env.VERCEL_PROTECTION_BYPASS_TOKEN;
950
952
  return token ? { "x-vercel-protection-bypass": token } : {};
951
953
  }
952
954
  var fetchWithDeploymentProtection = (input, init) => {
953
955
  const headers = new Headers(
954
956
  input instanceof Request ? input.headers : void 0
955
957
  );
956
- new Headers(_optionalChain([init, 'optionalAccess', _155 => _155.headers])).forEach((value, name) => headers.set(name, value));
958
+ new Headers(_optionalChain([init, 'optionalAccess', _139 => _139.headers])).forEach((value, name) => headers.set(name, value));
957
959
  for (const [name, value] of Object.entries(deploymentProtectionHeaders())) {
958
960
  headers.set(name, value);
959
961
  }
@@ -1300,7 +1302,7 @@ function withErrorCause(error, cause) {
1300
1302
  }
1301
1303
  function mapNetworkError(baseUrl, error, targetLabel) {
1302
1304
  const tagged = error;
1303
- const timeoutMs = _optionalChain([tagged, 'optionalAccess', _156 => _156[REQUEST_TIMEOUT_MARKER]]);
1305
+ const timeoutMs = _optionalChain([tagged, 'optionalAccess', _140 => _140[REQUEST_TIMEOUT_MARKER]]);
1304
1306
  if (typeof timeoutMs === "number") {
1305
1307
  return {
1306
1308
  message: `Request to ${targetLabel} timed out after ${timeoutMs}ms while waiting for a response.`,
@@ -1308,14 +1310,14 @@ function mapNetworkError(baseUrl, error, targetLabel) {
1308
1310
  details: { timeoutMs, target: targetLabel }
1309
1311
  };
1310
1312
  }
1311
- if (_optionalChain([tagged, 'optionalAccess', _157 => _157[REQUEST_ABORT_MARKER]])) {
1313
+ if (_optionalChain([tagged, 'optionalAccess', _141 => _141[REQUEST_ABORT_MARKER]])) {
1312
1314
  return {
1313
1315
  message: `Request to ${targetLabel} was aborted before it completed.`,
1314
1316
  code: "NETWORK_ABORTED"
1315
1317
  };
1316
1318
  }
1317
1319
  return {
1318
- message: _optionalChain([error, 'optionalAccess', _158 => _158.message]) ? `Unable to connect to ${baseUrl}. ${error.message}` : `Unable to connect to ${baseUrl}. Is the computer able to access the url?`,
1320
+ message: _optionalChain([error, 'optionalAccess', _142 => _142.message]) ? `Unable to connect to ${baseUrl}. ${error.message}` : `Unable to connect to ${baseUrl}. Is the computer able to access the url?`,
1319
1321
  code: "NETWORK_ERROR"
1320
1322
  };
1321
1323
  }
@@ -1353,9 +1355,12 @@ var HttpClient = class {
1353
1355
  const normalized = String(_nullishCoalesce(value, () => ( ""))).replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, MAX_DIAGNOSTIC_HEADER_LENGTH);
1354
1356
  return normalized || null;
1355
1357
  }
1358
+ environment() {
1359
+ return _nullishCoalesce(this.config.environment, () => ( (typeof process !== "undefined" ? process.env : {})));
1360
+ }
1356
1361
  readSkillsVersionHeader() {
1357
1362
  const explicit = this.cleanDiagnosticHeader(
1358
- process.env.DEEPLINE_SKILLS_VERSION
1363
+ this.environment().DEEPLINE_SKILLS_VERSION
1359
1364
  );
1360
1365
  if (explicit) return explicit;
1361
1366
  try {
@@ -1367,65 +1372,68 @@ var HttpClient = class {
1367
1372
  }
1368
1373
  }
1369
1374
  authHeaders(extra) {
1375
+ const env = this.environment();
1370
1376
  const transportHeaders = {
1371
1377
  Authorization: `Bearer ${this.config.apiKey}`,
1372
1378
  "User-Agent": `deepline-ts-sdk/${SDK_VERSION}`,
1373
1379
  "X-Deepline-Client-Family": "sdk",
1374
1380
  "X-Deepline-CLI-Family": "sdk",
1375
- "X-Deepline-Agent-Runtime": detectAgentRuntime(),
1381
+ "X-Deepline-Agent-Runtime": detectAgentRuntime(
1382
+ this.config.environment ? { env, detectCowork: false } : {}
1383
+ ),
1376
1384
  "X-Deepline-CLI-Version": SDK_VERSION,
1377
1385
  "X-Deepline-SDK-Version": SDK_VERSION,
1378
1386
  "X-Deepline-API-Contract": SDK_API_CONTRACT,
1379
1387
  "X-Deepline-Run-Result-Shape": "canonical"
1380
1388
  };
1381
- const headers = deploymentProtectionHeaders();
1389
+ const headers = deploymentProtectionHeaders(env);
1382
1390
  const skillsVersion = this.readSkillsVersionHeader();
1383
1391
  if (skillsVersion) {
1384
1392
  headers["X-Deepline-Skills-Version"] = skillsVersion;
1385
1393
  }
1386
- const agentSessionId = agentSessionIdFromEnvironment();
1394
+ const agentSessionId = agentSessionIdFromEnvironment(env);
1387
1395
  if (agentSessionId) {
1388
1396
  headers["X-Deepline-Agent-Session-Id"] = agentSessionId;
1389
1397
  }
1390
- const playArtifactR2Prefix = typeof process !== "undefined" ? _optionalChain([process, 'access', _159 => _159.env, 'optionalAccess', _160 => _160.DEEPLINE_PLAY_ARTIFACT_R2_PREFIX]) : void 0;
1398
+ const playArtifactR2Prefix = env.DEEPLINE_PLAY_ARTIFACT_R2_PREFIX;
1391
1399
  if (playArtifactR2Prefix) {
1392
1400
  headers["x-deepline-play-artifact-r2-prefix"] = playArtifactR2Prefix;
1393
1401
  }
1394
- const coordinatorUrl = typeof process !== "undefined" ? _optionalChain([process, 'access', _161 => _161.env, 'optionalAccess', _162 => _162.DEEPLINE_COORDINATOR_URL]) : void 0;
1395
- const coordinatorInternalToken = typeof process !== "undefined" ? _optionalChain([process, 'access', _163 => _163.env, 'optionalAccess', _164 => _164.DEEPLINE_INTERNAL_TOKEN]) : void 0;
1396
- const absurdReleaseOverride = typeof process !== "undefined" ? _optionalChain([process, 'access', _165 => _165.env, 'optionalAccess', _166 => _166.DEEPLINE_ABSURD_RELEASE]) : void 0;
1397
- const preferredReceiptGatewayMachineId = typeof process !== "undefined" ? _optionalChain([process, 'access', _167 => _167.env, 'optionalAccess', _168 => _168.DEEPLINE_PREFERRED_RECEIPT_GATEWAY_MACHINE_ID]) : void 0;
1398
- if (_optionalChain([coordinatorUrl, 'optionalAccess', _169 => _169.trim, 'call', _170 => _170()])) {
1402
+ const coordinatorUrl = env.DEEPLINE_COORDINATOR_URL;
1403
+ const coordinatorInternalToken = env.DEEPLINE_INTERNAL_TOKEN;
1404
+ const absurdReleaseOverride = env.DEEPLINE_ABSURD_RELEASE;
1405
+ const preferredReceiptGatewayMachineId = env.DEEPLINE_PREFERRED_RECEIPT_GATEWAY_MACHINE_ID;
1406
+ if (_optionalChain([coordinatorUrl, 'optionalAccess', _143 => _143.trim, 'call', _144 => _144()])) {
1399
1407
  headers[COORDINATOR_URL_OVERRIDE_HEADER] = coordinatorUrl.trim();
1400
1408
  }
1401
- const workerCallbackUrl = typeof process !== "undefined" ? _optionalChain([process, 'access', _171 => _171.env, 'optionalAccess', _172 => _172.DEEPLINE_WORKER_CALLBACK_URL]) : void 0;
1402
- if (_optionalChain([workerCallbackUrl, 'optionalAccess', _173 => _173.trim, 'call', _174 => _174()])) {
1409
+ const workerCallbackUrl = env.DEEPLINE_WORKER_CALLBACK_URL;
1410
+ if (_optionalChain([workerCallbackUrl, 'optionalAccess', _145 => _145.trim, 'call', _146 => _146()])) {
1403
1411
  headers[WORKER_CALLBACK_URL_OVERRIDE_HEADER] = workerCallbackUrl.trim();
1404
1412
  }
1405
- const runtimeSchedulerSchema = typeof process !== "undefined" ? _optionalChain([process, 'access', _175 => _175.env, 'optionalAccess', _176 => _176.DEEPLINE_RUNTIME_SCHEDULER_SCHEMA]) : void 0;
1406
- if (_optionalChain([runtimeSchedulerSchema, 'optionalAccess', _177 => _177.trim, 'call', _178 => _178()])) {
1413
+ const runtimeSchedulerSchema = env.DEEPLINE_RUNTIME_SCHEDULER_SCHEMA;
1414
+ if (_optionalChain([runtimeSchedulerSchema, 'optionalAccess', _147 => _147.trim, 'call', _148 => _148()])) {
1407
1415
  headers[RUNTIME_SCHEDULER_SCHEMA_OVERRIDE_HEADER] = runtimeSchedulerSchema.trim();
1408
1416
  }
1409
- const syntheticRun = typeof process !== "undefined" ? _optionalChain([process, 'access', _179 => _179.env, 'optionalAccess', _180 => _180.DEEPLINE_SYNTHETIC_RUN]) : void 0;
1417
+ const syntheticRun = env.DEEPLINE_SYNTHETIC_RUN;
1410
1418
  if (syntheticRun && syntheticRun.trim() && syntheticRun.trim() !== "0") {
1411
1419
  headers[SYNTHETIC_RUN_HEADER] = "1";
1412
1420
  }
1413
- const runtimeTestFault = typeof process !== "undefined" ? _optionalChain([process, 'access', _181 => _181.env, 'optionalAccess', _182 => _182.DEEPLINE_TEST_RUNTIME_FAULT]) : void 0;
1414
- if (_optionalChain([runtimeTestFault, 'optionalAccess', _183 => _183.trim, 'call', _184 => _184()])) {
1421
+ const runtimeTestFault = env.DEEPLINE_TEST_RUNTIME_FAULT;
1422
+ if (_optionalChain([runtimeTestFault, 'optionalAccess', _149 => _149.trim, 'call', _150 => _150()])) {
1415
1423
  headers[PLAY_RUNTIME_TEST_FAULT_HEADER] = runtimeTestFault.trim();
1416
1424
  }
1417
- const retainedReceivers = typeof process !== "undefined" ? _optionalChain([process, 'access', _185 => _185.env, 'optionalAccess', _186 => _186.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS, 'optionalAccess', _187 => _187.trim, 'call', _188 => _188()]) : void 0;
1418
- if (retainedReceivers && _optionalChain([coordinatorInternalToken, 'optionalAccess', _189 => _189.trim, 'call', _190 => _190()])) {
1425
+ const retainedReceivers = _optionalChain([env, 'access', _151 => _151.DEEPLINE_RUNTIME_RETAINED_PIPELINE_RECEIVERS, 'optionalAccess', _152 => _152.trim, 'call', _153 => _153()]);
1426
+ if (retainedReceivers && _optionalChain([coordinatorInternalToken, 'optionalAccess', _154 => _154.trim, 'call', _155 => _155()])) {
1419
1427
  headers[RETAINED_PIPELINE_RECEIVERS_HEADER] = retainedReceivers;
1420
1428
  headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
1421
1429
  }
1422
- if (_optionalChain([absurdReleaseOverride, 'optionalAccess', _191 => _191.trim, 'call', _192 => _192()]) && _optionalChain([coordinatorInternalToken, 'optionalAccess', _193 => _193.trim, 'call', _194 => _194()])) {
1430
+ if (_optionalChain([absurdReleaseOverride, 'optionalAccess', _156 => _156.trim, 'call', _157 => _157()]) && _optionalChain([coordinatorInternalToken, 'optionalAccess', _158 => _158.trim, 'call', _159 => _159()])) {
1423
1431
  headers[ABSURD_RELEASE_OVERRIDE_HEADER] = absurdReleaseOverride.trim();
1424
1432
  }
1425
- if (_optionalChain([preferredReceiptGatewayMachineId, 'optionalAccess', _195 => _195.trim, 'call', _196 => _196()]) && _optionalChain([coordinatorInternalToken, 'optionalAccess', _197 => _197.trim, 'call', _198 => _198()])) {
1433
+ if (_optionalChain([preferredReceiptGatewayMachineId, 'optionalAccess', _160 => _160.trim, 'call', _161 => _161()]) && _optionalChain([coordinatorInternalToken, 'optionalAccess', _162 => _162.trim, 'call', _163 => _163()])) {
1426
1434
  headers[PREFERRED_RECEIPT_GATEWAY_MACHINE_ID_HEADER] = preferredReceiptGatewayMachineId.trim();
1427
1435
  }
1428
- if (_optionalChain([coordinatorInternalToken, 'optionalAccess', _199 => _199.trim, 'call', _200 => _200()]) && (_optionalChain([coordinatorUrl, 'optionalAccess', _201 => _201.trim, 'call', _202 => _202()]) || _optionalChain([workerCallbackUrl, 'optionalAccess', _203 => _203.trim, 'call', _204 => _204()]) || _optionalChain([runtimeTestFault, 'optionalAccess', _205 => _205.trim, 'call', _206 => _206()]) || _optionalChain([absurdReleaseOverride, 'optionalAccess', _207 => _207.trim, 'call', _208 => _208()]) || _optionalChain([preferredReceiptGatewayMachineId, 'optionalAccess', _209 => _209.trim, 'call', _210 => _210()]))) {
1436
+ if (_optionalChain([coordinatorInternalToken, 'optionalAccess', _164 => _164.trim, 'call', _165 => _165()]) && (_optionalChain([coordinatorUrl, 'optionalAccess', _166 => _166.trim, 'call', _167 => _167()]) || _optionalChain([workerCallbackUrl, 'optionalAccess', _168 => _168.trim, 'call', _169 => _169()]) || _optionalChain([runtimeTestFault, 'optionalAccess', _170 => _170.trim, 'call', _171 => _171()]) || _optionalChain([absurdReleaseOverride, 'optionalAccess', _172 => _172.trim, 'call', _173 => _173()]) || _optionalChain([preferredReceiptGatewayMachineId, 'optionalAccess', _174 => _174.trim, 'call', _175 => _175()]))) {
1429
1437
  headers[COORDINATOR_INTERNAL_TOKEN_HEADER] = coordinatorInternalToken.trim();
1430
1438
  }
1431
1439
  return applyExplicitHeaders(
@@ -1450,23 +1458,23 @@ var HttpClient = class {
1450
1458
  async request(path, options) {
1451
1459
  const baseUrl = this.config.baseUrl;
1452
1460
  const url = `${baseUrl}${path}`;
1453
- const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _211 => _211.method]), () => ( "GET"));
1461
+ const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _176 => _176.method]), () => ( "GET"));
1454
1462
  const requestStartedAt = Date.now();
1455
1463
  let fetchAttempts = 0;
1456
1464
  let lastRequestUrl = url;
1457
1465
  let networkFailedAt;
1458
1466
  let networkPhase = "before_request";
1459
- const headers = this.authHeaders(_optionalChain([options, 'optionalAccess', _212 => _212.headers]));
1460
- if (_optionalChain([options, 'optionalAccess', _213 => _213.body]) !== void 0) {
1467
+ const headers = this.authHeaders(_optionalChain([options, 'optionalAccess', _177 => _177.headers]));
1468
+ if (_optionalChain([options, 'optionalAccess', _178 => _178.body]) !== void 0) {
1461
1469
  applyExplicitHeaders(headers, { "Content-Type": "application/json" });
1462
1470
  }
1463
1471
  let lastError = null;
1464
- const candidateUrls = _optionalChain([options, 'optionalAccess', _214 => _214.exactUrlOnly]) ? [url] : buildCandidateUrls(url);
1472
+ const candidateUrls = _optionalChain([options, 'optionalAccess', _179 => _179.exactUrlOnly]) ? [url] : buildCandidateUrls(url);
1465
1473
  let retryAfterDelayMs = null;
1466
1474
  let totalRetryWaitMs = 0;
1467
- const maxRetries = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _215 => _215.maxRetries]), () => ( this.config.maxRetries));
1475
+ const maxRetries = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _180 => _180.maxRetries]), () => ( this.config.maxRetries));
1468
1476
  requestAttempts: for (let attempt = 0; attempt <= maxRetries; attempt++) {
1469
- if (_optionalChain([options, 'optionalAccess', _216 => _216.signal, 'optionalAccess', _217 => _217.aborted])) {
1477
+ if (_optionalChain([options, 'optionalAccess', _181 => _181.signal, 'optionalAccess', _182 => _182.aborted])) {
1470
1478
  lastError = requestCancelledError(options.signal);
1471
1479
  networkFailedAt = Date.now();
1472
1480
  break;
@@ -1481,7 +1489,7 @@ var HttpClient = class {
1481
1489
  totalRetryWaitMs += delayMs;
1482
1490
  networkPhase = "retry_wait";
1483
1491
  try {
1484
- await sleep(delayMs, _optionalChain([options, 'optionalAccess', _218 => _218.signal]));
1492
+ await sleep(delayMs, _optionalChain([options, 'optionalAccess', _183 => _183.signal]));
1485
1493
  } catch (error) {
1486
1494
  lastError = error instanceof Error ? error : new Error(String(error));
1487
1495
  networkFailedAt = Date.now();
@@ -1489,25 +1497,25 @@ var HttpClient = class {
1489
1497
  }
1490
1498
  }
1491
1499
  for (const candidateUrl of candidateUrls) {
1492
- if (_optionalChain([options, 'optionalAccess', _219 => _219.signal, 'optionalAccess', _220 => _220.aborted])) {
1500
+ if (_optionalChain([options, 'optionalAccess', _184 => _184.signal, 'optionalAccess', _185 => _185.aborted])) {
1493
1501
  lastError = requestCancelledError(options.signal);
1494
1502
  networkFailedAt = Date.now();
1495
1503
  break requestAttempts;
1496
1504
  }
1497
1505
  const controller = new AbortController();
1498
- const timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _221 => _221.timeout]), () => ( this.config.timeout));
1506
+ const timeoutMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _186 => _186.timeout]), () => ( this.config.timeout));
1499
1507
  let requestTimedOut = false;
1500
1508
  const timeoutId = setTimeout(() => {
1501
1509
  requestTimedOut = true;
1502
1510
  controller.abort();
1503
1511
  }, timeoutMs);
1504
1512
  const abortRequest = () => controller.abort();
1505
- _optionalChain([options, 'optionalAccess', _222 => _222.signal, 'optionalAccess', _223 => _223.addEventListener, 'call', _224 => _224("abort", abortRequest, {
1513
+ _optionalChain([options, 'optionalAccess', _187 => _187.signal, 'optionalAccess', _188 => _188.addEventListener, 'call', _189 => _189("abort", abortRequest, {
1506
1514
  once: true
1507
1515
  })]);
1508
1516
  networkPhase = "before_request";
1509
1517
  try {
1510
- const requestBody = _optionalChain([options, 'optionalAccess', _225 => _225.formData]) !== void 0 ? typeof options.formData === "function" ? options.formData() : options.formData : _optionalChain([options, 'optionalAccess', _226 => _226.body]) !== void 0 ? JSON.stringify(options.body) : void 0;
1518
+ const requestBody = _optionalChain([options, 'optionalAccess', _190 => _190.formData]) !== void 0 ? typeof options.formData === "function" ? options.formData() : options.formData : _optionalChain([options, 'optionalAccess', _191 => _191.body]) !== void 0 ? JSON.stringify(options.body) : void 0;
1511
1519
  fetchAttempts += 1;
1512
1520
  lastRequestUrl = candidateUrl;
1513
1521
  networkPhase = "awaiting_headers";
@@ -1518,8 +1526,8 @@ var HttpClient = class {
1518
1526
  signal: controller.signal
1519
1527
  });
1520
1528
  networkPhase = "reading_body";
1521
- _optionalChain([options, 'optionalAccess', _227 => _227.onResponse, 'optionalCall', _228 => _228(response)]);
1522
- if (response.status === 404 && _optionalChain([options, 'optionalAccess', _229 => _229.allowNotFound])) {
1529
+ _optionalChain([options, 'optionalAccess', _192 => _192.onResponse, 'optionalCall', _193 => _193(response)]);
1530
+ if (response.status === 404 && _optionalChain([options, 'optionalAccess', _194 => _194.allowNotFound])) {
1523
1531
  clearTimeout(timeoutId);
1524
1532
  return null;
1525
1533
  }
@@ -1527,12 +1535,12 @@ var HttpClient = class {
1527
1535
  const receivedAtMs = Date.now();
1528
1536
  clearTimeout(timeoutId);
1529
1537
  const parsed = parseResponseBody(body);
1530
- _optionalChain([options, 'optionalAccess', _230 => _230.onResponseBody, 'optionalCall', _231 => _231({
1538
+ _optionalChain([options, 'optionalAccess', _195 => _195.onResponseBody, 'optionalCall', _196 => _196({
1531
1539
  receivedAtMs,
1532
1540
  httpStatus: response.status,
1533
1541
  body: parsed
1534
1542
  })]);
1535
- const structuredToolError = _optionalChain([options, 'optionalAccess', _232 => _232.toolId]) && !response.ok ? _chunk7P5AA3SNjs.deserializeToolExecutionFailure.call(void 0,
1543
+ const structuredToolError = _optionalChain([options, 'optionalAccess', _197 => _197.toolId]) && !response.ok ? _chunk7P5AA3SNjs.deserializeToolExecutionFailure.call(void 0,
1536
1544
  _chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status),
1537
1545
  isRecord(parsed) ? parsed.tool_error : null,
1538
1546
  _chunk7P5AA3SNjs.TOOL_EXECUTION_ERROR_SCHEMA_VERSION
@@ -1554,7 +1562,7 @@ var HttpClient = class {
1554
1562
  throw structuredToolError;
1555
1563
  }
1556
1564
  if (response.status === 429) {
1557
- if (_optionalChain([options, 'optionalAccess', _233 => _233.preserveRateLimitResponse]) && isMonitorRateLimitEnvelope(parsed)) {
1565
+ if (_optionalChain([options, 'optionalAccess', _198 => _198.preserveRateLimitResponse]) && isMonitorRateLimitEnvelope(parsed)) {
1558
1566
  throw new (0, _chunk7P5AA3SNjs.DeeplineError)(
1559
1567
  _chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status),
1560
1568
  response.status,
@@ -1574,7 +1582,7 @@ var HttpClient = class {
1574
1582
  throw new AuthError(_chunkXNYIZMNQjs.apiErrorMessage.call(void 0, parsed, response.status));
1575
1583
  }
1576
1584
  if (!response.ok) {
1577
- const retryableApiError = _optionalChain([options, 'optionalAccess', _234 => _234.retryApiErrors]) === true && isRetryableApiErrorResponse(response.status);
1585
+ const retryableApiError = _optionalChain([options, 'optionalAccess', _199 => _199.retryApiErrors]) === true && isRetryableApiErrorResponse(response.status);
1578
1586
  const htmlError = detectHtmlErrorBody(
1579
1587
  body,
1580
1588
  response.headers.get("content-type")
@@ -1626,7 +1634,7 @@ var HttpClient = class {
1626
1634
  } catch (error) {
1627
1635
  clearTimeout(timeoutId);
1628
1636
  networkFailedAt = Date.now();
1629
- if (_optionalChain([options, 'optionalAccess', _235 => _235.signal, 'optionalAccess', _236 => _236.aborted])) {
1637
+ if (_optionalChain([options, 'optionalAccess', _200 => _200.signal, 'optionalAccess', _201 => _201.aborted])) {
1630
1638
  lastError = requestCancelledError(options.signal);
1631
1639
  break requestAttempts;
1632
1640
  }
@@ -1643,7 +1651,7 @@ var HttpClient = class {
1643
1651
  });
1644
1652
  } finally {
1645
1653
  clearTimeout(timeoutId);
1646
- _optionalChain([options, 'optionalAccess', _237 => _237.signal, 'optionalAccess', _238 => _238.removeEventListener, 'call', _239 => _239("abort", abortRequest)]);
1654
+ _optionalChain([options, 'optionalAccess', _202 => _202.signal, 'optionalAccess', _203 => _203.removeEventListener, 'call', _204 => _204("abort", abortRequest)]);
1647
1655
  }
1648
1656
  }
1649
1657
  if (attempt < maxRetries) continue;
@@ -1670,7 +1678,7 @@ var HttpClient = class {
1670
1678
  phase: networkPhase
1671
1679
  }
1672
1680
  };
1673
- if (_optionalChain([options, 'optionalAccess', _240 => _240.toolId])) {
1681
+ if (_optionalChain([options, 'optionalAccess', _205 => _205.toolId])) {
1674
1682
  const code = mappedNetworkError.code;
1675
1683
  throw withErrorCause(
1676
1684
  new (0, _chunk7P5AA3SNjs.ToolExecutionError)(
@@ -1722,12 +1730,12 @@ var HttpClient = class {
1722
1730
  }
1723
1731
  async *streamSse(path, options) {
1724
1732
  const url = `${this.config.baseUrl}${path}`;
1725
- const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _241 => _241.method]), () => ( "GET"));
1733
+ const method = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _206 => _206.method]), () => ( "GET"));
1726
1734
  const headers = this.authHeaders({
1727
1735
  Accept: "text/event-stream",
1728
- ..._optionalChain([options, 'optionalAccess', _242 => _242.headers])
1736
+ ..._optionalChain([options, 'optionalAccess', _207 => _207.headers])
1729
1737
  });
1730
- if (_optionalChain([options, 'optionalAccess', _243 => _243.body]) !== void 0) {
1738
+ if (_optionalChain([options, 'optionalAccess', _208 => _208.body]) !== void 0) {
1731
1739
  applyExplicitHeaders(headers, { "Content-Type": "application/json" });
1732
1740
  }
1733
1741
  let lastError = null;
@@ -1736,8 +1744,8 @@ var HttpClient = class {
1736
1744
  const response = await fetch(candidateUrl, {
1737
1745
  method,
1738
1746
  headers,
1739
- body: _optionalChain([options, 'optionalAccess', _244 => _244.body]) !== void 0 ? JSON.stringify(options.body) : void 0,
1740
- signal: _optionalChain([options, 'optionalAccess', _245 => _245.signal])
1747
+ body: _optionalChain([options, 'optionalAccess', _209 => _209.body]) !== void 0 ? JSON.stringify(options.body) : void 0,
1748
+ signal: _optionalChain([options, 'optionalAccess', _210 => _210.signal])
1741
1749
  });
1742
1750
  if (!response.ok) {
1743
1751
  const body = await response.text();
@@ -1778,7 +1786,7 @@ var HttpClient = class {
1778
1786
  throw error;
1779
1787
  }
1780
1788
  const normalized = error instanceof Error ? error : new Error(String(error));
1781
- if (isAbortLikeError(normalized) && _optionalChain([options, 'optionalAccess', _246 => _246.signal, 'optionalAccess', _247 => _247.aborted])) {
1789
+ if (isAbortLikeError(normalized) && _optionalChain([options, 'optionalAccess', _211 => _211.signal, 'optionalAccess', _212 => _212.aborted])) {
1782
1790
  throw new (0, _chunk7P5AA3SNjs.DeeplineError)(
1783
1791
  `Stream from ${this.config.baseUrl} was aborted by the caller.`,
1784
1792
  void 0,
@@ -1799,7 +1807,7 @@ var HttpClient = class {
1799
1807
  }
1800
1808
  throw new (0, _chunk7P5AA3SNjs.DeeplineError)(
1801
1809
  withCoworkNetworkHint(
1802
- _optionalChain([lastError, 'optionalAccess', _248 => _248.message]) ? `Unable to stream from ${this.config.baseUrl}. ${lastError.message}` : `Unable to stream from ${this.config.baseUrl}.`
1810
+ _optionalChain([lastError, 'optionalAccess', _213 => _213.message]) ? `Unable to stream from ${this.config.baseUrl}. ${lastError.message}` : `Unable to stream from ${this.config.baseUrl}.`
1803
1811
  )
1804
1812
  );
1805
1813
  }
@@ -1861,15 +1869,15 @@ function parseResponseBody(body) {
1861
1869
  }
1862
1870
  function isProviderOriginatedHttpError(parsed) {
1863
1871
  const response = asRecord(parsed);
1864
- const error = asRecord(_optionalChain([response, 'optionalAccess', _249 => _249.error]));
1865
- const failureOrigin = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _250 => _250.failure_origin]), () => ( _optionalChain([response, 'optionalAccess', _251 => _251.failure_origin])));
1866
- const code = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _252 => _252.code]), () => ( _optionalChain([response, 'optionalAccess', _253 => _253.code])));
1872
+ const error = asRecord(_optionalChain([response, 'optionalAccess', _214 => _214.error]));
1873
+ const failureOrigin = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _215 => _215.failure_origin]), () => ( _optionalChain([response, 'optionalAccess', _216 => _216.failure_origin])));
1874
+ const code = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _217 => _217.code]), () => ( _optionalChain([response, 'optionalAccess', _218 => _218.code])));
1867
1875
  return failureOrigin === "provider" || code === "UPSTREAM_BLOCKED";
1868
1876
  }
1869
1877
  function isMonitorRateLimitEnvelope(parsed) {
1870
1878
  const response = asRecord(parsed);
1871
- const error = asRecord(_optionalChain([response, 'optionalAccess', _254 => _254.error]));
1872
- return _optionalChain([error, 'optionalAccess', _255 => _255.code]) === "monitor_upstream_rate_limited" && typeof error.message === "string";
1879
+ const error = asRecord(_optionalChain([response, 'optionalAccess', _219 => _219.error]));
1880
+ return _optionalChain([error, 'optionalAccess', _220 => _220.code]) === "monitor_upstream_rate_limited" && typeof error.message === "string";
1873
1881
  }
1874
1882
  function asRecord(value) {
1875
1883
  return typeof value === "object" && value !== null ? value : null;
@@ -1885,7 +1893,7 @@ function detectHtmlErrorBody(body, contentType) {
1885
1893
  return null;
1886
1894
  }
1887
1895
  const titleMatch = trimmed.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
1888
- const title = _optionalChain([titleMatch, 'optionalAccess', _256 => _256[1], 'optionalAccess', _257 => _257.replace, 'call', _258 => _258(/\s+/g, " "), 'access', _259 => _259.trim, 'call', _260 => _260()]) || void 0;
1896
+ const title = _optionalChain([titleMatch, 'optionalAccess', _221 => _221[1], 'optionalAccess', _222 => _222.replace, 'call', _223 => _223(/\s+/g, " "), 'access', _224 => _224.trim, 'call', _225 => _225()]) || void 0;
1889
1897
  const workerThrewException = /worker threw exception/i.test(trimmed);
1890
1898
  return {
1891
1899
  title,
@@ -1969,20 +1977,20 @@ function decodeSseFrame(frame) {
1969
1977
  }
1970
1978
  function sleep(ms, signal) {
1971
1979
  return new Promise((resolve2, reject) => {
1972
- if (_optionalChain([signal, 'optionalAccess', _261 => _261.aborted])) {
1980
+ if (_optionalChain([signal, 'optionalAccess', _226 => _226.aborted])) {
1973
1981
  reject(requestCancelledError(signal));
1974
1982
  return;
1975
1983
  }
1976
1984
  const timeoutId = setTimeout(() => {
1977
- _optionalChain([signal, 'optionalAccess', _262 => _262.removeEventListener, 'call', _263 => _263("abort", abort)]);
1985
+ _optionalChain([signal, 'optionalAccess', _227 => _227.removeEventListener, 'call', _228 => _228("abort", abort)]);
1978
1986
  resolve2();
1979
1987
  }, ms);
1980
1988
  const abort = () => {
1981
1989
  clearTimeout(timeoutId);
1982
- _optionalChain([signal, 'optionalAccess', _264 => _264.removeEventListener, 'call', _265 => _265("abort", abort)]);
1990
+ _optionalChain([signal, 'optionalAccess', _229 => _229.removeEventListener, 'call', _230 => _230("abort", abort)]);
1983
1991
  reject(requestCancelledError(signal));
1984
1992
  };
1985
- _optionalChain([signal, 'optionalAccess', _266 => _266.addEventListener, 'call', _267 => _267("abort", abort, { once: true })]);
1993
+ _optionalChain([signal, 'optionalAccess', _231 => _231.addEventListener, 'call', _232 => _232("abort", abort, { once: true })]);
1986
1994
  });
1987
1995
  }
1988
1996
  function withCoworkNetworkHint(message) {
@@ -2,7 +2,7 @@ import {
2
2
  argsWantJson,
3
3
  openInBrowser,
4
4
  printCommandEnvelope
5
- } from "./chunk-5KD4F7NR.mjs";
5
+ } from "./chunk-VH4B5OYM.mjs";
6
6
  import {
7
7
  ACTIVE_ORG_ID_ENV,
8
8
  ACTIVE_ORG_NAME_ENV,
@@ -25,7 +25,7 @@ import {
25
25
  saveHostEnvValues,
26
26
  saveProjectDeeplineEnvValues,
27
27
  storedHostApiKey
28
- } from "./chunk-DNYNJU5J.mjs";
28
+ } from "./chunk-K3ODOHOI.mjs";
29
29
 
30
30
  // src/cli/commands/auth.ts
31
31
  import {