opensteer 0.6.7 → 0.6.8

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.
@@ -890,6 +890,101 @@ function getCallerFilePath() {
890
890
  return null;
891
891
  }
892
892
 
893
+ // src/cloud/contracts.ts
894
+ var cloudActionMethods = [
895
+ "goto",
896
+ "snapshot",
897
+ "screenshot",
898
+ "state",
899
+ "click",
900
+ "dblclick",
901
+ "rightclick",
902
+ "hover",
903
+ "input",
904
+ "select",
905
+ "scroll",
906
+ "tabs",
907
+ "newTab",
908
+ "switchTab",
909
+ "closeTab",
910
+ "getCookies",
911
+ "setCookie",
912
+ "clearCookies",
913
+ "pressKey",
914
+ "type",
915
+ "getElementText",
916
+ "getElementValue",
917
+ "getElementAttributes",
918
+ "getElementBoundingBox",
919
+ "getHtml",
920
+ "getTitle",
921
+ "uploadFile",
922
+ "exportCookies",
923
+ "importCookies",
924
+ "waitForText",
925
+ "extract",
926
+ "extractFromPlan",
927
+ "clearCache"
928
+ ];
929
+ var cloudErrorCodes = [
930
+ "CLOUD_AUTH_FAILED",
931
+ "CLOUD_SESSION_NOT_FOUND",
932
+ "CLOUD_SESSION_CLOSED",
933
+ "CLOUD_UNSUPPORTED_METHOD",
934
+ "CLOUD_INVALID_REQUEST",
935
+ "CLOUD_MODEL_NOT_ALLOWED",
936
+ "CLOUD_ACTION_FAILED",
937
+ "CLOUD_CAPACITY_EXHAUSTED",
938
+ "CLOUD_RUNTIME_UNAVAILABLE",
939
+ "CLOUD_RUNTIME_MISMATCH",
940
+ "CLOUD_SESSION_STALE",
941
+ "CLOUD_CONTROL_PLANE_ERROR",
942
+ "CLOUD_CONTRACT_MISMATCH",
943
+ "CLOUD_PROXY_UNAVAILABLE",
944
+ "CLOUD_PROXY_REQUIRED",
945
+ "CLOUD_BILLING_LIMIT_REACHED",
946
+ "CLOUD_RATE_LIMITED",
947
+ "CLOUD_BROWSER_PROFILE_NOT_FOUND",
948
+ "CLOUD_BROWSER_PROFILE_BUSY",
949
+ "CLOUD_BROWSER_PROFILE_DISABLED",
950
+ "CLOUD_BROWSER_PROFILE_PROXY_UNAVAILABLE",
951
+ "CLOUD_BROWSER_PROFILE_SYNC_FAILED",
952
+ "CLOUD_INTERNAL"
953
+ ];
954
+ var cloudSessionStatuses = [
955
+ "provisioning",
956
+ "active",
957
+ "closing",
958
+ "closed",
959
+ "failed"
960
+ ];
961
+ var cloudSessionContractVersion = "v3";
962
+ var cloudSessionSourceTypes = [
963
+ "agent-thread",
964
+ "agent-run",
965
+ "project-agent-run",
966
+ "local-cloud",
967
+ "manual"
968
+ ];
969
+ var cloudActionMethodSet = new Set(cloudActionMethods);
970
+ var cloudErrorCodeSet = new Set(cloudErrorCodes);
971
+ var cloudSessionSourceTypeSet = new Set(
972
+ cloudSessionSourceTypes
973
+ );
974
+ var cloudSessionStatusSet = new Set(cloudSessionStatuses);
975
+ function isCloudActionMethod(value) {
976
+ return typeof value === "string" && cloudActionMethodSet.has(value);
977
+ }
978
+ function isCloudErrorCode(value) {
979
+ return typeof value === "string" && cloudErrorCodeSet.has(value);
980
+ }
981
+ function isCloudSessionSourceType(value) {
982
+ return typeof value === "string" && cloudSessionSourceTypeSet.has(value);
983
+ }
984
+ function isCloudSessionStatus(value) {
985
+ return typeof value === "string" && cloudSessionStatusSet.has(value);
986
+ }
987
+
893
988
  // src/cloud/errors.ts
894
989
  var OpensteerCloudError = class extends Error {
895
990
  code;
@@ -920,6 +1015,15 @@ function cloudNotLaunchedError() {
920
1015
  import {
921
1016
  chromium
922
1017
  } from "playwright";
1018
+
1019
+ // src/cloud/ws-url.ts
1020
+ function withTokenQuery(wsUrl, token) {
1021
+ const url = new URL(wsUrl);
1022
+ url.searchParams.set("token", token);
1023
+ return url.toString();
1024
+ }
1025
+
1026
+ // src/cloud/cdp-client.ts
923
1027
  var CloudCdpClient = class {
924
1028
  async connect(args) {
925
1029
  const endpoint = withTokenQuery(args.wsUrl, args.token);
@@ -974,11 +1078,6 @@ function isInternalOrEmptyUrl(url) {
974
1078
  if (url === "about:blank") return true;
975
1079
  return url.startsWith("chrome://") || url.startsWith("devtools://") || url.startsWith("edge://");
976
1080
  }
977
- function withTokenQuery(wsUrl, token) {
978
- const url = new URL(wsUrl);
979
- url.searchParams.set("token", token);
980
- return url.toString();
981
- }
982
1081
 
983
1082
  // src/utils/strip-trailing-slashes.ts
984
1083
  function stripTrailingSlashes(value) {
@@ -1015,10 +1114,7 @@ async function parseCloudHttpError(response) {
1015
1114
  return new OpensteerCloudError(code, message, response.status, body?.details);
1016
1115
  }
1017
1116
  function toCloudErrorCode(code) {
1018
- 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") {
1019
- return code;
1020
- }
1021
- return "CLOUD_TRANSPORT_ERROR";
1117
+ return isCloudErrorCode(code) ? code : "CLOUD_TRANSPORT_ERROR";
1022
1118
  }
1023
1119
 
1024
1120
  // src/cloud/session-client.ts
@@ -1125,7 +1221,12 @@ function parseCreateResponse(body, status) {
1125
1221
  status,
1126
1222
  "cloudSession"
1127
1223
  ),
1128
- state: requireString(cloudSessionRoot, "state", status, "cloudSession"),
1224
+ state: requireSessionStatus(
1225
+ cloudSessionRoot,
1226
+ "state",
1227
+ status,
1228
+ "cloudSession"
1229
+ ),
1129
1230
  createdAt: requireNumber(cloudSessionRoot, "createdAt", status, "cloudSession"),
1130
1231
  sourceType: requireSourceType(cloudSessionRoot, "sourceType", status, "cloudSession"),
1131
1232
  sourceRef: optionalString(cloudSessionRoot, "sourceRef", status, "cloudSession"),
@@ -1213,7 +1314,21 @@ function optionalNumber(source, field, status, parent) {
1213
1314
  }
1214
1315
  function requireSourceType(source, field, status, parent) {
1215
1316
  const value = source[field];
1216
- if (value === "agent-thread" || value === "agent-run" || value === "local-cloud" || value === "manual") {
1317
+ if (isCloudSessionSourceType(value)) {
1318
+ return value;
1319
+ }
1320
+ throw new OpensteerCloudError(
1321
+ "CLOUD_CONTRACT_MISMATCH",
1322
+ `Invalid cloud session create response: ${formatFieldPath(
1323
+ field,
1324
+ parent
1325
+ )} must be one of ${formatAllowedValues(cloudSessionSourceTypes)}.`,
1326
+ status
1327
+ );
1328
+ }
1329
+ function requireSessionStatus(source, field, status, parent) {
1330
+ const value = source[field];
1331
+ if (isCloudSessionStatus(value)) {
1217
1332
  return value;
1218
1333
  }
1219
1334
  throw new OpensteerCloudError(
@@ -1221,13 +1336,16 @@ function requireSourceType(source, field, status, parent) {
1221
1336
  `Invalid cloud session create response: ${formatFieldPath(
1222
1337
  field,
1223
1338
  parent
1224
- )} must be one of "agent-thread", "agent-run", "local-cloud", or "manual".`,
1339
+ )} must be one of ${formatAllowedValues(cloudSessionStatuses)}.`,
1225
1340
  status
1226
1341
  );
1227
1342
  }
1228
1343
  function formatFieldPath(field, parent) {
1229
1344
  return parent ? `"${parent}.${field}"` : `"${field}"`;
1230
1345
  }
1346
+ function formatAllowedValues(values) {
1347
+ return values.map((value) => `"${value}"`).join(", ");
1348
+ }
1231
1349
  function zeroImportResponse() {
1232
1350
  return {
1233
1351
  imported: 0,
@@ -1284,9 +1402,19 @@ export {
1284
1402
  resolveCloudSelection,
1285
1403
  resolveConfigWithEnv,
1286
1404
  resolveNamespace,
1405
+ cloudActionMethods,
1406
+ cloudErrorCodes,
1407
+ cloudSessionStatuses,
1408
+ cloudSessionContractVersion,
1409
+ cloudSessionSourceTypes,
1410
+ isCloudActionMethod,
1411
+ isCloudErrorCode,
1412
+ isCloudSessionSourceType,
1413
+ isCloudSessionStatus,
1287
1414
  OpensteerCloudError,
1288
1415
  cloudUnsupportedMethodError,
1289
1416
  cloudNotLaunchedError,
1417
+ withTokenQuery,
1290
1418
  CloudCdpClient,
1291
1419
  stripTrailingSlashes,
1292
1420
  normalizeCloudBaseUrl,
@@ -2,7 +2,7 @@ import {
2
2
  cloudAuthHeaders,
3
3
  normalizeCloudBaseUrl,
4
4
  parseCloudHttpError
5
- } from "./chunk-KPPOTU3D.js";
5
+ } from "./chunk-LTREUXLO.js";
6
6
 
7
7
  // src/cloud/browser-profile-client.ts
8
8
  var BrowserProfileClient = class {
@@ -5,7 +5,7 @@ import {
5
5
  resolveConfigWithEnv,
6
6
  selectCloudCredential,
7
7
  stripTrailingSlashes
8
- } from "./chunk-KPPOTU3D.js";
8
+ } from "./chunk-LTREUXLO.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-UQYVMJOZ.js";
8
+ import "../chunk-LTREUXLO.js";
9
9
  export {
10
10
  ensureCloudCredentialsForCommand,
11
11
  ensureCloudCredentialsForOpenCommand,
@@ -8916,7 +8916,96 @@ function stripPositionClauses2(path7) {
8916
8916
  }
8917
8917
 
8918
8918
  // src/cloud/contracts.ts
8919
+ var cloudActionMethods = [
8920
+ "goto",
8921
+ "snapshot",
8922
+ "screenshot",
8923
+ "state",
8924
+ "click",
8925
+ "dblclick",
8926
+ "rightclick",
8927
+ "hover",
8928
+ "input",
8929
+ "select",
8930
+ "scroll",
8931
+ "tabs",
8932
+ "newTab",
8933
+ "switchTab",
8934
+ "closeTab",
8935
+ "getCookies",
8936
+ "setCookie",
8937
+ "clearCookies",
8938
+ "pressKey",
8939
+ "type",
8940
+ "getElementText",
8941
+ "getElementValue",
8942
+ "getElementAttributes",
8943
+ "getElementBoundingBox",
8944
+ "getHtml",
8945
+ "getTitle",
8946
+ "uploadFile",
8947
+ "exportCookies",
8948
+ "importCookies",
8949
+ "waitForText",
8950
+ "extract",
8951
+ "extractFromPlan",
8952
+ "clearCache"
8953
+ ];
8954
+ var cloudErrorCodes = [
8955
+ "CLOUD_AUTH_FAILED",
8956
+ "CLOUD_SESSION_NOT_FOUND",
8957
+ "CLOUD_SESSION_CLOSED",
8958
+ "CLOUD_UNSUPPORTED_METHOD",
8959
+ "CLOUD_INVALID_REQUEST",
8960
+ "CLOUD_MODEL_NOT_ALLOWED",
8961
+ "CLOUD_ACTION_FAILED",
8962
+ "CLOUD_CAPACITY_EXHAUSTED",
8963
+ "CLOUD_RUNTIME_UNAVAILABLE",
8964
+ "CLOUD_RUNTIME_MISMATCH",
8965
+ "CLOUD_SESSION_STALE",
8966
+ "CLOUD_CONTROL_PLANE_ERROR",
8967
+ "CLOUD_CONTRACT_MISMATCH",
8968
+ "CLOUD_PROXY_UNAVAILABLE",
8969
+ "CLOUD_PROXY_REQUIRED",
8970
+ "CLOUD_BILLING_LIMIT_REACHED",
8971
+ "CLOUD_RATE_LIMITED",
8972
+ "CLOUD_BROWSER_PROFILE_NOT_FOUND",
8973
+ "CLOUD_BROWSER_PROFILE_BUSY",
8974
+ "CLOUD_BROWSER_PROFILE_DISABLED",
8975
+ "CLOUD_BROWSER_PROFILE_PROXY_UNAVAILABLE",
8976
+ "CLOUD_BROWSER_PROFILE_SYNC_FAILED",
8977
+ "CLOUD_INTERNAL"
8978
+ ];
8979
+ var cloudSessionStatuses = [
8980
+ "provisioning",
8981
+ "active",
8982
+ "closing",
8983
+ "closed",
8984
+ "failed"
8985
+ ];
8919
8986
  var cloudSessionContractVersion = "v3";
8987
+ var cloudSessionSourceTypes = [
8988
+ "agent-thread",
8989
+ "agent-run",
8990
+ "project-agent-run",
8991
+ "local-cloud",
8992
+ "manual"
8993
+ ];
8994
+ var cloudActionMethodSet = new Set(cloudActionMethods);
8995
+ var cloudErrorCodeSet = new Set(cloudErrorCodes);
8996
+ var cloudSessionSourceTypeSet = new Set(
8997
+ cloudSessionSourceTypes
8998
+ );
8999
+ var cloudSessionStatusSet = new Set(cloudSessionStatuses);
9000
+ function isCloudErrorCode(value) {
9001
+ return typeof value === "string" && cloudErrorCodeSet.has(value);
9002
+ }
9003
+ function isCloudSessionSourceType(value) {
9004
+ return typeof value === "string" && cloudSessionSourceTypeSet.has(value);
9005
+ }
9006
+ function isCloudSessionStatus(value) {
9007
+ return typeof value === "string" && cloudSessionStatusSet.has(value);
9008
+ }
8920
9009
 
8921
9010
  // src/cloud/action-ws-client.ts
8922
9011
  var import_ws2 = __toESM(require("ws"), 1);
@@ -8947,6 +9036,13 @@ function cloudNotLaunchedError() {
8947
9036
  );
8948
9037
  }
8949
9038
 
9039
+ // src/cloud/ws-url.ts
9040
+ function withTokenQuery(wsUrl, token) {
9041
+ const url = new URL(wsUrl);
9042
+ url.searchParams.set("token", token);
9043
+ return url.toString();
9044
+ }
9045
+
8950
9046
  // src/cloud/action-ws-client.ts
8951
9047
  var ActionWsClient = class _ActionWsClient {
8952
9048
  ws;
@@ -9075,11 +9171,6 @@ function rawDataToUtf8(raw) {
9075
9171
  if (Array.isArray(raw)) return Buffer.concat(raw).toString("utf8");
9076
9172
  return raw.toString("utf8");
9077
9173
  }
9078
- function withTokenQuery(wsUrl, token) {
9079
- const url = new URL(wsUrl);
9080
- url.searchParams.set("token", token);
9081
- return url.toString();
9082
- }
9083
9174
 
9084
9175
  // src/cloud/local-cache-sync.ts
9085
9176
  var import_fs4 = __toESM(require("fs"), 1);
@@ -9219,7 +9310,7 @@ function dedupeNewest(entries) {
9219
9310
  var import_playwright2 = require("playwright");
9220
9311
  var CloudCdpClient = class {
9221
9312
  async connect(args) {
9222
- const endpoint = withTokenQuery2(args.wsUrl, args.token);
9313
+ const endpoint = withTokenQuery(args.wsUrl, args.token);
9223
9314
  let browser;
9224
9315
  try {
9225
9316
  browser = await import_playwright2.chromium.connectOverCDP(endpoint);
@@ -9271,11 +9362,6 @@ function isInternalOrEmptyUrl(url) {
9271
9362
  if (url === "about:blank") return true;
9272
9363
  return url.startsWith("chrome://") || url.startsWith("devtools://") || url.startsWith("edge://");
9273
9364
  }
9274
- function withTokenQuery2(wsUrl, token) {
9275
- const url = new URL(wsUrl);
9276
- url.searchParams.set("token", token);
9277
- return url.toString();
9278
- }
9279
9365
 
9280
9366
  // src/utils/strip-trailing-slashes.ts
9281
9367
  function stripTrailingSlashes(value) {
@@ -9312,10 +9398,7 @@ async function parseCloudHttpError(response) {
9312
9398
  return new OpensteerCloudError(code, message, response.status, body?.details);
9313
9399
  }
9314
9400
  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";
9401
+ return isCloudErrorCode(code) ? code : "CLOUD_TRANSPORT_ERROR";
9319
9402
  }
9320
9403
 
9321
9404
  // src/cloud/session-client.ts
@@ -9422,7 +9505,12 @@ function parseCreateResponse(body, status) {
9422
9505
  status,
9423
9506
  "cloudSession"
9424
9507
  ),
9425
- state: requireString(cloudSessionRoot, "state", status, "cloudSession"),
9508
+ state: requireSessionStatus(
9509
+ cloudSessionRoot,
9510
+ "state",
9511
+ status,
9512
+ "cloudSession"
9513
+ ),
9426
9514
  createdAt: requireNumber(cloudSessionRoot, "createdAt", status, "cloudSession"),
9427
9515
  sourceType: requireSourceType(cloudSessionRoot, "sourceType", status, "cloudSession"),
9428
9516
  sourceRef: optionalString(cloudSessionRoot, "sourceRef", status, "cloudSession"),
@@ -9510,7 +9598,7 @@ function optionalNumber(source, field, status, parent) {
9510
9598
  }
9511
9599
  function requireSourceType(source, field, status, parent) {
9512
9600
  const value = source[field];
9513
- if (value === "agent-thread" || value === "agent-run" || value === "local-cloud" || value === "manual") {
9601
+ if (isCloudSessionSourceType(value)) {
9514
9602
  return value;
9515
9603
  }
9516
9604
  throw new OpensteerCloudError(
@@ -9518,13 +9606,30 @@ function requireSourceType(source, field, status, parent) {
9518
9606
  `Invalid cloud session create response: ${formatFieldPath(
9519
9607
  field,
9520
9608
  parent
9521
- )} must be one of "agent-thread", "agent-run", "local-cloud", or "manual".`,
9609
+ )} must be one of ${formatAllowedValues(cloudSessionSourceTypes)}.`,
9610
+ status
9611
+ );
9612
+ }
9613
+ function requireSessionStatus(source, field, status, parent) {
9614
+ const value = source[field];
9615
+ if (isCloudSessionStatus(value)) {
9616
+ return value;
9617
+ }
9618
+ throw new OpensteerCloudError(
9619
+ "CLOUD_CONTRACT_MISMATCH",
9620
+ `Invalid cloud session create response: ${formatFieldPath(
9621
+ field,
9622
+ parent
9623
+ )} must be one of ${formatAllowedValues(cloudSessionStatuses)}.`,
9522
9624
  status
9523
9625
  );
9524
9626
  }
9525
9627
  function formatFieldPath(field, parent) {
9526
9628
  return parent ? `"${parent}.${field}"` : `"${field}"`;
9527
9629
  }
9630
+ function formatAllowedValues(values) {
9631
+ return values.map((value) => `"${value}"`).join(", ");
9632
+ }
9528
9633
  function zeroImportResponse() {
9529
9634
  return {
9530
9635
  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';
@@ -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.js';
3
- import { B as BrowserProfileStatus, a as BrowserProfileListRequest, b as BrowserProfileListResponse, c as BrowserProfileCreateRequest, d as BrowserProfileDescriptor } from '../browser-profile-client-AGTsLQxT.js';
3
+ import { B as BrowserProfileStatus, a as BrowserProfileListRequest, b as BrowserProfileListResponse, c as BrowserProfileCreateRequest, d as BrowserProfileDescriptor } from '../browser-profile-client-DHLzMf-K.js';
4
4
 
5
5
  type ParsedProfileArgs = {
6
6
  mode: 'help';