opensteer 0.6.7 → 0.6.9

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.
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  OpensteerCloudError,
3
3
  cloudNotLaunchedError,
4
+ cloudSessionContractVersion,
4
5
  cloudUnsupportedMethodError,
5
6
  createCloudRuntimeState,
6
7
  extractErrorMessage,
@@ -11,8 +12,9 @@ import {
11
12
  resolveConfigWithEnv,
12
13
  resolveNamespace,
13
14
  resolveNamespaceDir,
14
- selectCloudCredential
15
- } from "./chunk-KPPOTU3D.js";
15
+ selectCloudCredential,
16
+ withTokenQuery
17
+ } from "./chunk-GTT3A3RU.js";
16
18
  import {
17
19
  detectChromePaths,
18
20
  expandHome,
@@ -3125,6 +3127,47 @@ async function markInteractiveElements(page, {
3125
3127
  "search",
3126
3128
  "searchbox"
3127
3129
  ]);
3130
+ function isExplicitlyHidden(el, style) {
3131
+ if (el.hasAttribute("hidden")) {
3132
+ return true;
3133
+ }
3134
+ if (el.getAttribute("aria-hidden") === "true") {
3135
+ return true;
3136
+ }
3137
+ if (style.display === "none") {
3138
+ return true;
3139
+ }
3140
+ if (style.visibility === "hidden" || style.visibility === "collapse") {
3141
+ return true;
3142
+ }
3143
+ const opacity = Number.parseFloat(style.opacity);
3144
+ return Number.isFinite(opacity) && opacity <= 0;
3145
+ }
3146
+ function hasVisibleOutOfFlowChild(el) {
3147
+ const children = el.children;
3148
+ for (let i = 0; i < children.length; i++) {
3149
+ const child = children[i];
3150
+ const childStyle = window.getComputedStyle(child);
3151
+ if (childStyle.position !== "fixed" && childStyle.position !== "absolute") {
3152
+ continue;
3153
+ }
3154
+ const childRect = child.getBoundingClientRect();
3155
+ if (childRect.width > 0 && childRect.height > 0) {
3156
+ return true;
3157
+ }
3158
+ }
3159
+ return false;
3160
+ }
3161
+ function isHiddenByOwnRect(el, style) {
3162
+ if (style.display === "contents") {
3163
+ return false;
3164
+ }
3165
+ const rect = el.getBoundingClientRect();
3166
+ if (rect.width > 0 && rect.height > 0) {
3167
+ return false;
3168
+ }
3169
+ return !hasVisibleOutOfFlowChild(el);
3170
+ }
3128
3171
  const roots = [document];
3129
3172
  while (roots.length) {
3130
3173
  const root = roots.pop();
@@ -3140,42 +3183,7 @@ async function markInteractiveElements(page, {
3140
3183
  continue;
3141
3184
  }
3142
3185
  const style = window.getComputedStyle(el);
3143
- let hidden = false;
3144
- if (el.hasAttribute("hidden")) {
3145
- hidden = true;
3146
- } else if (el.getAttribute("aria-hidden") === "true") {
3147
- hidden = true;
3148
- } else if (style.display === "none") {
3149
- hidden = true;
3150
- } else if (style.visibility === "hidden" || style.visibility === "collapse") {
3151
- hidden = true;
3152
- }
3153
- if (!hidden) {
3154
- const opacity = Number.parseFloat(style.opacity);
3155
- if (Number.isFinite(opacity) && opacity <= 0) {
3156
- hidden = true;
3157
- }
3158
- }
3159
- if (!hidden) {
3160
- const rect = el.getBoundingClientRect();
3161
- if (rect.width <= 0 || rect.height <= 0) {
3162
- hidden = true;
3163
- const children = el.children;
3164
- for (let i = 0; i < children.length; i++) {
3165
- const childStyle = window.getComputedStyle(
3166
- children[i]
3167
- );
3168
- if (childStyle.position !== "fixed" && childStyle.position !== "absolute") {
3169
- continue;
3170
- }
3171
- const childRect = children[i].getBoundingClientRect();
3172
- if (childRect.width > 0 && childRect.height > 0) {
3173
- hidden = false;
3174
- break;
3175
- }
3176
- }
3177
- }
3178
- }
3186
+ const hidden = isExplicitlyHidden(el, style) || isHiddenByOwnRect(el, style);
3179
3187
  if (hidden) {
3180
3188
  el.setAttribute(hiddenAttr, "1");
3181
3189
  el.removeAttribute(markAttribute2);
@@ -6004,9 +6012,6 @@ var OpensteerActionError = class extends Error {
6004
6012
  }
6005
6013
  };
6006
6014
 
6007
- // src/cloud/contracts.ts
6008
- var cloudSessionContractVersion = "v3";
6009
-
6010
6015
  // src/cloud/action-ws-client.ts
6011
6016
  import WebSocket2 from "ws";
6012
6017
  var ActionWsClient = class _ActionWsClient {
@@ -6136,11 +6141,6 @@ function rawDataToUtf8(raw) {
6136
6141
  if (Array.isArray(raw)) return Buffer.concat(raw).toString("utf8");
6137
6142
  return raw.toString("utf8");
6138
6143
  }
6139
- function withTokenQuery(wsUrl, token) {
6140
- const url = new URL(wsUrl);
6141
- url.searchParams.set("token", token);
6142
- return url.toString();
6143
- }
6144
6144
 
6145
6145
  // src/cloud/local-cache-sync.ts
6146
6146
  import fs2 from "fs";
@@ -12997,7 +12997,6 @@ export {
12997
12997
  getPageTitle,
12998
12998
  performFileUpload,
12999
12999
  OpensteerActionError,
13000
- cloudSessionContractVersion,
13001
13000
  ActionWsClient,
13002
13001
  collectLocalSelectorCacheEntries,
13003
13002
  OpensteerAgentError,
@@ -5,7 +5,7 @@ import {
5
5
  resolveConfigWithEnv,
6
6
  selectCloudCredential,
7
7
  stripTrailingSlashes
8
- } from "./chunk-KPPOTU3D.js";
8
+ } from "./chunk-GTT3A3RU.js";
9
9
 
10
10
  // src/cli/auth.ts
11
11
  import open from "open";
@@ -986,7 +986,7 @@ function isCiEnvironment(env) {
986
986
  const value = env.CI?.trim().toLowerCase();
987
987
  return Boolean(value && value !== "0" && value !== "false");
988
988
  }
989
- function isCloudModeEnabledForRootDir(rootDir, env) {
989
+ function resolveCloudSessionEnvForRootDir(rootDir, env) {
990
990
  const resolved = resolveConfigWithEnv(
991
991
  {
992
992
  storage: { rootDir }
@@ -995,22 +995,29 @@ function isCloudModeEnabledForRootDir(rootDir, env) {
995
995
  env
996
996
  }
997
997
  );
998
- return resolveCloudSelection(
999
- {
1000
- cloud: resolved.config.cloud
1001
- },
1002
- resolved.env
1003
- ).cloud;
998
+ return {
999
+ cloud: resolveCloudSelection(
1000
+ {
1001
+ cloud: resolved.config.cloud
1002
+ },
1003
+ resolved.env
1004
+ ).cloud,
1005
+ env: resolved.env
1006
+ };
1007
+ }
1008
+ function isCloudModeEnabledForRootDir(rootDir, env) {
1009
+ return resolveCloudSessionEnvForRootDir(rootDir, env).cloud;
1004
1010
  }
1005
1011
  async function ensureCloudCredentialsForOpenCommand(options) {
1006
- const env = options.env ?? process.env;
1007
- if (!isCloudModeEnabledForRootDir(options.scopeDir, env)) {
1012
+ const processEnv = options.env ?? process.env;
1013
+ const runtime = resolveCloudSessionEnvForRootDir(options.scopeDir, processEnv);
1014
+ if (!runtime.cloud) {
1008
1015
  return null;
1009
1016
  }
1010
1017
  const writeStderr = options.writeStderr ?? ((message) => process.stderr.write(message));
1011
- return await ensureCloudCredentialsForCommand({
1018
+ const auth = await ensureCloudCredentialsForCommand({
1012
1019
  commandName: "opensteer open",
1013
- env,
1020
+ env: runtime.env,
1014
1021
  store: options.store,
1015
1022
  apiKeyFlag: options.apiKeyFlag,
1016
1023
  accessTokenFlag: options.accessTokenFlag,
@@ -1023,6 +1030,14 @@ async function ensureCloudCredentialsForOpenCommand(options) {
1023
1030
  now: options.now,
1024
1031
  openExternalUrl: options.openExternalUrl
1025
1032
  });
1033
+ applyCloudCredentialToEnv(processEnv, {
1034
+ kind: auth.kind,
1035
+ source: auth.source,
1036
+ token: auth.token,
1037
+ authScheme: auth.authScheme
1038
+ });
1039
+ processEnv.OPENSTEER_BASE_URL = auth.baseUrl;
1040
+ return auth;
1026
1041
  }
1027
1042
  async function ensureCloudCredentialsForCommand(options) {
1028
1043
  const env = options.env ?? process.env;
package/dist/cli/auth.cjs CHANGED
@@ -42,6 +42,88 @@ var import_open = __toESM(require("open"), 1);
42
42
  // src/cloud/cdp-client.ts
43
43
  var import_playwright = require("playwright");
44
44
 
45
+ // src/cloud/contracts.ts
46
+ var cloudActionMethods = [
47
+ "goto",
48
+ "snapshot",
49
+ "screenshot",
50
+ "state",
51
+ "click",
52
+ "dblclick",
53
+ "rightclick",
54
+ "hover",
55
+ "input",
56
+ "select",
57
+ "scroll",
58
+ "tabs",
59
+ "newTab",
60
+ "switchTab",
61
+ "closeTab",
62
+ "getCookies",
63
+ "setCookie",
64
+ "clearCookies",
65
+ "pressKey",
66
+ "type",
67
+ "getElementText",
68
+ "getElementValue",
69
+ "getElementAttributes",
70
+ "getElementBoundingBox",
71
+ "getHtml",
72
+ "getTitle",
73
+ "uploadFile",
74
+ "exportCookies",
75
+ "importCookies",
76
+ "waitForText",
77
+ "extract",
78
+ "extractFromPlan",
79
+ "clearCache"
80
+ ];
81
+ var cloudErrorCodes = [
82
+ "CLOUD_AUTH_FAILED",
83
+ "CLOUD_SESSION_NOT_FOUND",
84
+ "CLOUD_SESSION_CLOSED",
85
+ "CLOUD_UNSUPPORTED_METHOD",
86
+ "CLOUD_INVALID_REQUEST",
87
+ "CLOUD_MODEL_NOT_ALLOWED",
88
+ "CLOUD_ACTION_FAILED",
89
+ "CLOUD_CAPACITY_EXHAUSTED",
90
+ "CLOUD_RUNTIME_UNAVAILABLE",
91
+ "CLOUD_RUNTIME_MISMATCH",
92
+ "CLOUD_SESSION_STALE",
93
+ "CLOUD_CONTROL_PLANE_ERROR",
94
+ "CLOUD_CONTRACT_MISMATCH",
95
+ "CLOUD_PROXY_UNAVAILABLE",
96
+ "CLOUD_PROXY_REQUIRED",
97
+ "CLOUD_BILLING_LIMIT_REACHED",
98
+ "CLOUD_RATE_LIMITED",
99
+ "CLOUD_BROWSER_PROFILE_NOT_FOUND",
100
+ "CLOUD_BROWSER_PROFILE_BUSY",
101
+ "CLOUD_BROWSER_PROFILE_DISABLED",
102
+ "CLOUD_BROWSER_PROFILE_PROXY_UNAVAILABLE",
103
+ "CLOUD_BROWSER_PROFILE_SYNC_FAILED",
104
+ "CLOUD_INTERNAL"
105
+ ];
106
+ var cloudSessionStatuses = [
107
+ "provisioning",
108
+ "active",
109
+ "closing",
110
+ "closed",
111
+ "failed"
112
+ ];
113
+ var cloudSessionSourceTypes = [
114
+ "agent-thread",
115
+ "agent-run",
116
+ "project-agent-run",
117
+ "local-cloud",
118
+ "manual"
119
+ ];
120
+ var cloudActionMethodSet = new Set(cloudActionMethods);
121
+ var cloudErrorCodeSet = new Set(cloudErrorCodes);
122
+ var cloudSessionSourceTypeSet = new Set(
123
+ cloudSessionSourceTypes
124
+ );
125
+ var cloudSessionStatusSet = new Set(cloudSessionStatuses);
126
+
45
127
  // src/utils/strip-trailing-slashes.ts
46
128
  function stripTrailingSlashes(value) {
47
129
  let end = value.length;
@@ -1665,7 +1747,7 @@ function isCiEnvironment(env) {
1665
1747
  const value = env.CI?.trim().toLowerCase();
1666
1748
  return Boolean(value && value !== "0" && value !== "false");
1667
1749
  }
1668
- function isCloudModeEnabledForRootDir(rootDir, env) {
1750
+ function resolveCloudSessionEnvForRootDir(rootDir, env) {
1669
1751
  const resolved = resolveConfigWithEnv(
1670
1752
  {
1671
1753
  storage: { rootDir }
@@ -1674,22 +1756,29 @@ function isCloudModeEnabledForRootDir(rootDir, env) {
1674
1756
  env
1675
1757
  }
1676
1758
  );
1677
- return resolveCloudSelection(
1678
- {
1679
- cloud: resolved.config.cloud
1680
- },
1681
- resolved.env
1682
- ).cloud;
1759
+ return {
1760
+ cloud: resolveCloudSelection(
1761
+ {
1762
+ cloud: resolved.config.cloud
1763
+ },
1764
+ resolved.env
1765
+ ).cloud,
1766
+ env: resolved.env
1767
+ };
1768
+ }
1769
+ function isCloudModeEnabledForRootDir(rootDir, env) {
1770
+ return resolveCloudSessionEnvForRootDir(rootDir, env).cloud;
1683
1771
  }
1684
1772
  async function ensureCloudCredentialsForOpenCommand(options) {
1685
- const env = options.env ?? process.env;
1686
- if (!isCloudModeEnabledForRootDir(options.scopeDir, env)) {
1773
+ const processEnv = options.env ?? process.env;
1774
+ const runtime = resolveCloudSessionEnvForRootDir(options.scopeDir, processEnv);
1775
+ if (!runtime.cloud) {
1687
1776
  return null;
1688
1777
  }
1689
1778
  const writeStderr = options.writeStderr ?? ((message) => process.stderr.write(message));
1690
- return await ensureCloudCredentialsForCommand({
1779
+ const auth = await ensureCloudCredentialsForCommand({
1691
1780
  commandName: "opensteer open",
1692
- env,
1781
+ env: runtime.env,
1693
1782
  store: options.store,
1694
1783
  apiKeyFlag: options.apiKeyFlag,
1695
1784
  accessTokenFlag: options.accessTokenFlag,
@@ -1702,6 +1791,14 @@ async function ensureCloudCredentialsForOpenCommand(options) {
1702
1791
  now: options.now,
1703
1792
  openExternalUrl: options.openExternalUrl
1704
1793
  });
1794
+ applyCloudCredentialToEnv(processEnv, {
1795
+ kind: auth.kind,
1796
+ source: auth.source,
1797
+ token: auth.token,
1798
+ authScheme: auth.authScheme
1799
+ });
1800
+ processEnv.OPENSTEER_BASE_URL = auth.baseUrl;
1801
+ return auth;
1705
1802
  }
1706
1803
  async function ensureCloudCredentialsForCommand(options) {
1707
1804
  const env = options.env ?? process.env;
package/dist/cli/auth.js CHANGED
@@ -4,8 +4,8 @@ import {
4
4
  isCloudModeEnabledForRootDir,
5
5
  parseOpensteerAuthArgs,
6
6
  runOpensteerAuthCli
7
- } from "../chunk-54KNQTOL.js";
8
- import "../chunk-KPPOTU3D.js";
7
+ } from "../chunk-K7DQUSZG.js";
8
+ import "../chunk-GTT3A3RU.js";
9
9
  export {
10
10
  ensureCloudCredentialsForCommand,
11
11
  ensureCloudCredentialsForOpenCommand,
@@ -4496,6 +4496,47 @@ async function markInteractiveElements(page, {
4496
4496
  "search",
4497
4497
  "searchbox"
4498
4498
  ]);
4499
+ function isExplicitlyHidden(el, style) {
4500
+ if (el.hasAttribute("hidden")) {
4501
+ return true;
4502
+ }
4503
+ if (el.getAttribute("aria-hidden") === "true") {
4504
+ return true;
4505
+ }
4506
+ if (style.display === "none") {
4507
+ return true;
4508
+ }
4509
+ if (style.visibility === "hidden" || style.visibility === "collapse") {
4510
+ return true;
4511
+ }
4512
+ const opacity = Number.parseFloat(style.opacity);
4513
+ return Number.isFinite(opacity) && opacity <= 0;
4514
+ }
4515
+ function hasVisibleOutOfFlowChild(el) {
4516
+ const children = el.children;
4517
+ for (let i = 0; i < children.length; i++) {
4518
+ const child = children[i];
4519
+ const childStyle = window.getComputedStyle(child);
4520
+ if (childStyle.position !== "fixed" && childStyle.position !== "absolute") {
4521
+ continue;
4522
+ }
4523
+ const childRect = child.getBoundingClientRect();
4524
+ if (childRect.width > 0 && childRect.height > 0) {
4525
+ return true;
4526
+ }
4527
+ }
4528
+ return false;
4529
+ }
4530
+ function isHiddenByOwnRect(el, style) {
4531
+ if (style.display === "contents") {
4532
+ return false;
4533
+ }
4534
+ const rect = el.getBoundingClientRect();
4535
+ if (rect.width > 0 && rect.height > 0) {
4536
+ return false;
4537
+ }
4538
+ return !hasVisibleOutOfFlowChild(el);
4539
+ }
4499
4540
  const roots = [document];
4500
4541
  while (roots.length) {
4501
4542
  const root = roots.pop();
@@ -4511,42 +4552,7 @@ async function markInteractiveElements(page, {
4511
4552
  continue;
4512
4553
  }
4513
4554
  const style = window.getComputedStyle(el);
4514
- let hidden = false;
4515
- if (el.hasAttribute("hidden")) {
4516
- hidden = true;
4517
- } else if (el.getAttribute("aria-hidden") === "true") {
4518
- hidden = true;
4519
- } else if (style.display === "none") {
4520
- hidden = true;
4521
- } else if (style.visibility === "hidden" || style.visibility === "collapse") {
4522
- hidden = true;
4523
- }
4524
- if (!hidden) {
4525
- const opacity = Number.parseFloat(style.opacity);
4526
- if (Number.isFinite(opacity) && opacity <= 0) {
4527
- hidden = true;
4528
- }
4529
- }
4530
- if (!hidden) {
4531
- const rect = el.getBoundingClientRect();
4532
- if (rect.width <= 0 || rect.height <= 0) {
4533
- hidden = true;
4534
- const children = el.children;
4535
- for (let i = 0; i < children.length; i++) {
4536
- const childStyle = window.getComputedStyle(
4537
- children[i]
4538
- );
4539
- if (childStyle.position !== "fixed" && childStyle.position !== "absolute") {
4540
- continue;
4541
- }
4542
- const childRect = children[i].getBoundingClientRect();
4543
- if (childRect.width > 0 && childRect.height > 0) {
4544
- hidden = false;
4545
- break;
4546
- }
4547
- }
4548
- }
4549
- }
4555
+ const hidden = isExplicitlyHidden(el, style) || isHiddenByOwnRect(el, style);
4550
4556
  if (hidden) {
4551
4557
  el.setAttribute(hiddenAttr, "1");
4552
4558
  el.removeAttribute(markAttribute2);
@@ -8916,7 +8922,96 @@ function stripPositionClauses2(path7) {
8916
8922
  }
8917
8923
 
8918
8924
  // src/cloud/contracts.ts
8925
+ var cloudActionMethods = [
8926
+ "goto",
8927
+ "snapshot",
8928
+ "screenshot",
8929
+ "state",
8930
+ "click",
8931
+ "dblclick",
8932
+ "rightclick",
8933
+ "hover",
8934
+ "input",
8935
+ "select",
8936
+ "scroll",
8937
+ "tabs",
8938
+ "newTab",
8939
+ "switchTab",
8940
+ "closeTab",
8941
+ "getCookies",
8942
+ "setCookie",
8943
+ "clearCookies",
8944
+ "pressKey",
8945
+ "type",
8946
+ "getElementText",
8947
+ "getElementValue",
8948
+ "getElementAttributes",
8949
+ "getElementBoundingBox",
8950
+ "getHtml",
8951
+ "getTitle",
8952
+ "uploadFile",
8953
+ "exportCookies",
8954
+ "importCookies",
8955
+ "waitForText",
8956
+ "extract",
8957
+ "extractFromPlan",
8958
+ "clearCache"
8959
+ ];
8960
+ var cloudErrorCodes = [
8961
+ "CLOUD_AUTH_FAILED",
8962
+ "CLOUD_SESSION_NOT_FOUND",
8963
+ "CLOUD_SESSION_CLOSED",
8964
+ "CLOUD_UNSUPPORTED_METHOD",
8965
+ "CLOUD_INVALID_REQUEST",
8966
+ "CLOUD_MODEL_NOT_ALLOWED",
8967
+ "CLOUD_ACTION_FAILED",
8968
+ "CLOUD_CAPACITY_EXHAUSTED",
8969
+ "CLOUD_RUNTIME_UNAVAILABLE",
8970
+ "CLOUD_RUNTIME_MISMATCH",
8971
+ "CLOUD_SESSION_STALE",
8972
+ "CLOUD_CONTROL_PLANE_ERROR",
8973
+ "CLOUD_CONTRACT_MISMATCH",
8974
+ "CLOUD_PROXY_UNAVAILABLE",
8975
+ "CLOUD_PROXY_REQUIRED",
8976
+ "CLOUD_BILLING_LIMIT_REACHED",
8977
+ "CLOUD_RATE_LIMITED",
8978
+ "CLOUD_BROWSER_PROFILE_NOT_FOUND",
8979
+ "CLOUD_BROWSER_PROFILE_BUSY",
8980
+ "CLOUD_BROWSER_PROFILE_DISABLED",
8981
+ "CLOUD_BROWSER_PROFILE_PROXY_UNAVAILABLE",
8982
+ "CLOUD_BROWSER_PROFILE_SYNC_FAILED",
8983
+ "CLOUD_INTERNAL"
8984
+ ];
8985
+ var cloudSessionStatuses = [
8986
+ "provisioning",
8987
+ "active",
8988
+ "closing",
8989
+ "closed",
8990
+ "failed"
8991
+ ];
8919
8992
  var cloudSessionContractVersion = "v3";
8993
+ var cloudSessionSourceTypes = [
8994
+ "agent-thread",
8995
+ "agent-run",
8996
+ "project-agent-run",
8997
+ "local-cloud",
8998
+ "manual"
8999
+ ];
9000
+ var cloudActionMethodSet = new Set(cloudActionMethods);
9001
+ var cloudErrorCodeSet = new Set(cloudErrorCodes);
9002
+ var cloudSessionSourceTypeSet = new Set(
9003
+ cloudSessionSourceTypes
9004
+ );
9005
+ var cloudSessionStatusSet = new Set(cloudSessionStatuses);
9006
+ function isCloudErrorCode(value) {
9007
+ return typeof value === "string" && cloudErrorCodeSet.has(value);
9008
+ }
9009
+ function isCloudSessionSourceType(value) {
9010
+ return typeof value === "string" && cloudSessionSourceTypeSet.has(value);
9011
+ }
9012
+ function isCloudSessionStatus(value) {
9013
+ return typeof value === "string" && cloudSessionStatusSet.has(value);
9014
+ }
8920
9015
 
8921
9016
  // src/cloud/action-ws-client.ts
8922
9017
  var import_ws2 = __toESM(require("ws"), 1);
@@ -8947,6 +9042,13 @@ function cloudNotLaunchedError() {
8947
9042
  );
8948
9043
  }
8949
9044
 
9045
+ // src/cloud/ws-url.ts
9046
+ function withTokenQuery(wsUrl, token) {
9047
+ const url = new URL(wsUrl);
9048
+ url.searchParams.set("token", token);
9049
+ return url.toString();
9050
+ }
9051
+
8950
9052
  // src/cloud/action-ws-client.ts
8951
9053
  var ActionWsClient = class _ActionWsClient {
8952
9054
  ws;
@@ -9075,11 +9177,6 @@ function rawDataToUtf8(raw) {
9075
9177
  if (Array.isArray(raw)) return Buffer.concat(raw).toString("utf8");
9076
9178
  return raw.toString("utf8");
9077
9179
  }
9078
- function withTokenQuery(wsUrl, token) {
9079
- const url = new URL(wsUrl);
9080
- url.searchParams.set("token", token);
9081
- return url.toString();
9082
- }
9083
9180
 
9084
9181
  // src/cloud/local-cache-sync.ts
9085
9182
  var import_fs4 = __toESM(require("fs"), 1);
@@ -9219,7 +9316,7 @@ function dedupeNewest(entries) {
9219
9316
  var import_playwright2 = require("playwright");
9220
9317
  var CloudCdpClient = class {
9221
9318
  async connect(args) {
9222
- const endpoint = withTokenQuery2(args.wsUrl, args.token);
9319
+ const endpoint = withTokenQuery(args.wsUrl, args.token);
9223
9320
  let browser;
9224
9321
  try {
9225
9322
  browser = await import_playwright2.chromium.connectOverCDP(endpoint);
@@ -9271,11 +9368,6 @@ function isInternalOrEmptyUrl(url) {
9271
9368
  if (url === "about:blank") return true;
9272
9369
  return url.startsWith("chrome://") || url.startsWith("devtools://") || url.startsWith("edge://");
9273
9370
  }
9274
- function withTokenQuery2(wsUrl, token) {
9275
- const url = new URL(wsUrl);
9276
- url.searchParams.set("token", token);
9277
- return url.toString();
9278
- }
9279
9371
 
9280
9372
  // src/utils/strip-trailing-slashes.ts
9281
9373
  function stripTrailingSlashes(value) {
@@ -9312,10 +9404,7 @@ async function parseCloudHttpError(response) {
9312
9404
  return new OpensteerCloudError(code, message, response.status, body?.details);
9313
9405
  }
9314
9406
  function toCloudErrorCode(code) {
9315
- if (code === "CLOUD_AUTH_FAILED" || code === "CLOUD_SESSION_NOT_FOUND" || code === "CLOUD_SESSION_CLOSED" || code === "CLOUD_UNSUPPORTED_METHOD" || code === "CLOUD_INVALID_REQUEST" || code === "CLOUD_MODEL_NOT_ALLOWED" || code === "CLOUD_ACTION_FAILED" || code === "CLOUD_INTERNAL" || code === "CLOUD_CAPACITY_EXHAUSTED" || code === "CLOUD_RUNTIME_UNAVAILABLE" || code === "CLOUD_RUNTIME_MISMATCH" || code === "CLOUD_SESSION_STALE" || code === "CLOUD_CONTRACT_MISMATCH" || code === "CLOUD_CONTROL_PLANE_ERROR" || code === "CLOUD_PROXY_UNAVAILABLE" || code === "CLOUD_PROXY_REQUIRED" || code === "CLOUD_BILLING_LIMIT_REACHED" || code === "CLOUD_RATE_LIMITED" || code === "CLOUD_BROWSER_PROFILE_NOT_FOUND" || code === "CLOUD_BROWSER_PROFILE_BUSY" || code === "CLOUD_BROWSER_PROFILE_DISABLED" || code === "CLOUD_BROWSER_PROFILE_PROXY_UNAVAILABLE" || code === "CLOUD_BROWSER_PROFILE_SYNC_FAILED") {
9316
- return code;
9317
- }
9318
- return "CLOUD_TRANSPORT_ERROR";
9407
+ return isCloudErrorCode(code) ? code : "CLOUD_TRANSPORT_ERROR";
9319
9408
  }
9320
9409
 
9321
9410
  // src/cloud/session-client.ts
@@ -9422,7 +9511,12 @@ function parseCreateResponse(body, status) {
9422
9511
  status,
9423
9512
  "cloudSession"
9424
9513
  ),
9425
- state: requireString(cloudSessionRoot, "state", status, "cloudSession"),
9514
+ state: requireSessionStatus(
9515
+ cloudSessionRoot,
9516
+ "state",
9517
+ status,
9518
+ "cloudSession"
9519
+ ),
9426
9520
  createdAt: requireNumber(cloudSessionRoot, "createdAt", status, "cloudSession"),
9427
9521
  sourceType: requireSourceType(cloudSessionRoot, "sourceType", status, "cloudSession"),
9428
9522
  sourceRef: optionalString(cloudSessionRoot, "sourceRef", status, "cloudSession"),
@@ -9510,7 +9604,21 @@ function optionalNumber(source, field, status, parent) {
9510
9604
  }
9511
9605
  function requireSourceType(source, field, status, parent) {
9512
9606
  const value = source[field];
9513
- if (value === "agent-thread" || value === "agent-run" || value === "local-cloud" || value === "manual") {
9607
+ if (isCloudSessionSourceType(value)) {
9608
+ return value;
9609
+ }
9610
+ throw new OpensteerCloudError(
9611
+ "CLOUD_CONTRACT_MISMATCH",
9612
+ `Invalid cloud session create response: ${formatFieldPath(
9613
+ field,
9614
+ parent
9615
+ )} must be one of ${formatAllowedValues(cloudSessionSourceTypes)}.`,
9616
+ status
9617
+ );
9618
+ }
9619
+ function requireSessionStatus(source, field, status, parent) {
9620
+ const value = source[field];
9621
+ if (isCloudSessionStatus(value)) {
9514
9622
  return value;
9515
9623
  }
9516
9624
  throw new OpensteerCloudError(
@@ -9518,13 +9626,26 @@ function requireSourceType(source, field, status, parent) {
9518
9626
  `Invalid cloud session create response: ${formatFieldPath(
9519
9627
  field,
9520
9628
  parent
9521
- )} must be one of "agent-thread", "agent-run", "local-cloud", or "manual".`,
9629
+ )} must be one of ${formatAllowedValues(cloudSessionStatuses)}.`,
9522
9630
  status
9523
9631
  );
9524
9632
  }
9525
9633
  function formatFieldPath(field, parent) {
9526
9634
  return parent ? `"${parent}.${field}"` : `"${field}"`;
9527
9635
  }
9636
+ function formatAllowedValues(values) {
9637
+ if (values.length === 0) {
9638
+ return "";
9639
+ }
9640
+ if (values.length === 1) {
9641
+ return `"${values[0]}"`;
9642
+ }
9643
+ if (values.length === 2) {
9644
+ return `"${values[0]}" or "${values[1]}"`;
9645
+ }
9646
+ const quotedValues = values.map((value) => `"${value}"`);
9647
+ return `${quotedValues.slice(0, -1).join(", ")}, or ${quotedValues[quotedValues.length - 1]}`;
9648
+ }
9528
9649
  function zeroImportResponse() {
9529
9650
  return {
9530
9651
  imported: 0,
@@ -1,6 +1,6 @@
1
1
  import { Cookie } from 'playwright';
2
2
  import { O as OpensteerAuthScheme, a as OpensteerConfig, C as CookieParam } from '../types-Cr10igF3.cjs';
3
- import { B as BrowserProfileStatus, a as BrowserProfileListRequest, b as BrowserProfileListResponse, c as BrowserProfileCreateRequest, d as BrowserProfileDescriptor } from '../browser-profile-client-Biu6DyT6.cjs';
3
+ import { B as BrowserProfileStatus, a as BrowserProfileListRequest, b as BrowserProfileListResponse, c as BrowserProfileCreateRequest, d as BrowserProfileDescriptor } from '../browser-profile-client-CGXc0-P9.cjs';
4
4
 
5
5
  type ParsedProfileArgs = {
6
6
  mode: 'help';