@intuned/runtime-dev 1.3.15-ts-helpers-fix → 1.3.17-cdp.0

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.
Binary file
package/bin/intuned CHANGED
File without changes
@@ -62,7 +62,6 @@ class ExtensionServer {
62
62
  if (this.app) {
63
63
  return;
64
64
  }
65
- console.error(`Starting on port ${port}`);
66
65
  this.app = (0, _fastify.default)({
67
66
  logger: false,
68
67
  bodyLimit: 1_000_000
@@ -70,7 +69,6 @@ class ExtensionServer {
70
69
  this.app.post("/state", async (request, reply) => {
71
70
  try {
72
71
  const result = _types.captchaSchema.safeParse(request.body);
73
- console.error(`Recieved call at /state`);
74
72
  if (!result.success) {
75
73
  return reply.code(400).send({
76
74
  error: "Invalid captcha payload",
@@ -1,4 +1,5 @@
1
1
  import * as playwright from "playwright";
2
+ import { Result } from "neverthrow";
2
3
  export interface Proxy {
3
4
  server: string;
4
5
  username: string;
@@ -24,6 +25,7 @@ export declare function launchChromium(options: LaunchChromiumCdpOptions): Promi
24
25
  export declare function getBrowserExecutablePath(): Promise<string | undefined>;
25
26
  export declare function launchBrowser(options: Omit<LaunchChromiumStandaloneOptions, "executablePath"> | LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
26
27
  export declare function getLocalCdpAddress(port: number): string;
28
+ export declare function getCdpWebSocketUrl(cdpAddress: string): Promise<Result<string, string>>;
27
29
  export declare function getHeadlessUserAgent({ executablePath, args, ignoreDefaultArgs, }: {
28
30
  executablePath?: string;
29
31
  args?: string[];
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getBrowserExecutablePath = getBrowserExecutablePath;
7
+ exports.getCdpWebSocketUrl = getCdpWebSocketUrl;
7
8
  exports.getHeadlessUserAgent = getHeadlessUserAgent;
8
9
  exports.getLocalCdpAddress = getLocalCdpAddress;
9
10
  exports.launchBrowser = launchBrowser;
@@ -17,6 +18,8 @@ var _child_process = require("child_process");
17
18
  var _extensionsHelpers = require("./extension/extensionsHelpers");
18
19
  var _intunedExtensionServer = require("./extension/intunedExtensionServer");
19
20
  var _util = require("util");
21
+ var _neverthrow = require("neverthrow");
22
+ var _zod = require("zod");
20
23
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
24
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
22
25
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -173,6 +176,21 @@ async function getBraveExecutablePath() {
173
176
  function getLocalCdpAddress(port) {
174
177
  return `http://localhost:${port}`;
175
178
  }
179
+ async function getCdpWebSocketUrl(cdpAddress) {
180
+ const response = await fetch(`${cdpAddress}/json/version`);
181
+ if (!response.ok) {
182
+ return (0, _neverthrow.err)(`Failed to get CDP WebSocket URL from ${cdpAddress}: ${response.status} ${response.statusText}`);
183
+ }
184
+ const data = await response.json();
185
+ const cdpJsonVersionResponseSchema = _zod.z.object({
186
+ webSocketDebuggerUrl: _zod.z.string().url()
187
+ });
188
+ const parseResult = cdpJsonVersionResponseSchema.safeParse(data);
189
+ if (!parseResult.success) {
190
+ return (0, _neverthrow.err)(`Invalid CDP version response from ${cdpAddress}: ${JSON.stringify(parseResult.error.format())}`);
191
+ }
192
+ return (0, _neverthrow.ok)(parseResult.data.webSocketDebuggerUrl);
193
+ }
176
194
  async function waitOnCdpAddress(cdpAddress) {
177
195
  const cdpAddressWithoutProtocol = cdpAddress.replace("http://", "").replace("https://", "").replace("localhost", "127.0.0.1");
178
196
  await (0, _waitOn.default)({
@@ -71,7 +71,6 @@ async function withPlaywrightContext({
71
71
  const port = await (0, _portfinder.getPort)({
72
72
  port: 9222
73
73
  });
74
- hookCdpUrl = (0, _launchBrowser.getLocalCdpAddress)(port);
75
74
  ({
76
75
  context,
77
76
  page
@@ -81,6 +80,11 @@ async function withPlaywrightContext({
81
80
  downloadsPath,
82
81
  cdpPort: port
83
82
  }));
83
+ hookCdpUrl = (0, _launchBrowser.getLocalCdpAddress)(port);
84
+ const wsUrlResult = await (0, _launchBrowser.getCdpWebSocketUrl)(hookCdpUrl);
85
+ if (wsUrlResult.isOk()) {
86
+ hookCdpUrl = wsUrlResult.value;
87
+ }
84
88
  }
85
89
  let hookResult;
86
90
  try {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { extendPayload, extendTimeout, runInfo, RunError, getAuthSessionParameters, attemptStore, persistentStore, } from "./runtime";
1
+ export { extendPayload, extendTimeout, runInfo, RunError, getAuthSessionParameters, attemptStore, persistentStore, getAiGatewayConfig, } from "./runtime";
2
2
  export { runWithContext, getExecutionContext, } from "./common/asyncLocalStorage";
3
3
  export { getDownloadDirectoryPath } from "./runtime/downloadDirectory";
4
4
  export { withPlaywrightContext } from "./common/playwrightContext";
package/dist/index.js CHANGED
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "extendTimeout", {
27
27
  return _runtime.extendTimeout;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "getAiGatewayConfig", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _runtime.getAiGatewayConfig;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "getAuthSessionParameters", {
31
37
  enumerable: true,
32
38
  get: function () {
@@ -116,14 +116,12 @@ async function waitForCaptchaSolve(page, {
116
116
  timeoutInMs = 10_000,
117
117
  settleDurationMs = 5_000
118
118
  } = {}) {
119
- console.error(`waitForCaptchaSolve called with timeout=${timeoutInMs}ms, settleDuration=${settleDurationMs}ms`);
120
119
  await withWaitForCaptchaSolve(async () => undefined, {
121
120
  page,
122
121
  timeoutInMs,
123
122
  settleDurationMs,
124
123
  waitForNetworkSettled: false
125
124
  });
126
- console.error("waitForCaptchaSolve completed");
127
125
  }
128
126
  async function removeCaptchaEventListener(page, status, f) {
129
127
  const extensionServer = (0, _intunedExtensionServer.getIntunedExtensionServer)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.3.15-ts-helpers-fix",
3
+ "version": "1.3.17-cdp.0",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",