opensteer 0.6.6 → 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;
@@ -1,4 +1,4 @@
1
- import { O as OpensteerAuthScheme } from '../types-BWItZPl_.cjs';
1
+ import { O as OpensteerAuthScheme } from '../types-Cr10igF3.cjs';
2
2
  import 'playwright';
3
3
 
4
4
  interface StoredMachineCloudCredential {
@@ -1,4 +1,4 @@
1
- import { O as OpensteerAuthScheme } from '../types-BWItZPl_.js';
1
+ import { O as OpensteerAuthScheme } from '../types-Cr10igF3.js';
2
2
  import 'playwright';
3
3
 
4
4
  interface StoredMachineCloudCredential {
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,