@intuned/runtime-dev 1.3.17-source.0 → 1.3.18-dev.2

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 (89) hide show
  1. package/.babelrc +6 -0
  2. package/CHANGELOG.md +1 -1
  3. package/InterfaceTemplate/{utils.ts → __utils.ts} +3 -1
  4. package/InterfaceTemplate/index.playwright.ts +1 -1
  5. package/bin/intuned +0 -0
  6. package/bin/intuned-interface +7 -0
  7. package/dist/commands/api/run.js +3 -3
  8. package/dist/commands/auth-sessions/run-check.js +3 -3
  9. package/dist/commands/auth-sessions/run-create.js +3 -3
  10. package/dist/commands/build.js +1 -3
  11. package/dist/commands/common/browserUtils.d.ts +3 -3
  12. package/dist/commands/common/browserUtils.js +3 -4
  13. package/dist/commands/common/getFirstLineNumber.test.js +1 -2
  14. package/dist/commands/common/tsNodeImport.d.ts +1 -1
  15. package/dist/commands/common/tsNodeImport.js +1 -2
  16. package/dist/commands/common/utils/fileUtils.js +1 -2
  17. package/dist/commands/common/utils/{unixSocket.d.ts → interfaceClient.d.ts} +10 -2
  18. package/dist/commands/common/utils/{unixSocket.js → interfaceClient.js} +16 -5
  19. package/dist/commands/common/utils/template.js +1 -2
  20. package/dist/commands/interface/run.js +23 -49
  21. package/dist/commands/intuned-cli/commands/deploy.command.js +2 -2
  22. package/dist/commands/intuned-cli/commands/provision.command.d.ts +2 -2
  23. package/dist/commands/intuned-cli/commands/provision.command.js +1 -1
  24. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +8 -1
  25. package/dist/commands/intuned-cli/commands/types.d.ts +9 -1
  26. package/dist/commands/intuned-cli/commands/types.js +7 -3
  27. package/dist/commands/intuned-cli/controller/__test__/api.test.js +24 -14
  28. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +128 -66
  29. package/dist/commands/intuned-cli/controller/api.d.ts +2 -2
  30. package/dist/commands/intuned-cli/controller/api.js +3 -3
  31. package/dist/commands/intuned-cli/controller/authSession.d.ts +16 -16
  32. package/dist/commands/intuned-cli/controller/authSession.js +22 -11
  33. package/dist/commands/intuned-cli/controller/build.js +1 -2
  34. package/dist/commands/intuned-cli/controller/deploy.js +1 -2
  35. package/dist/commands/intuned-cli/controller/index.js +1 -2
  36. package/dist/commands/intuned-cli/controller/provision.js +1 -2
  37. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +44 -5
  38. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +3 -3
  39. package/dist/commands/intuned-cli/helpers/auth.d.ts +4 -4
  40. package/dist/commands/intuned-cli/helpers/auth.js +2 -2
  41. package/dist/commands/intuned-cli/helpers/browser.d.ts +4 -4
  42. package/dist/commands/intuned-cli/helpers/browser.js +40 -5
  43. package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
  44. package/dist/commands/intuned-cli/helpers/errors.js +2 -2
  45. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +6 -5
  46. package/dist/commands/intuned-cli/helpers/timeout.js +2 -2
  47. package/dist/commands/intuned-cli/helpers/traces.d.ts +1 -1
  48. package/dist/commands/intuned-cli/helpers/wrapper.js +2 -2
  49. package/dist/commands/intuned-cli/main.js +1 -2
  50. package/dist/commands/intuned-cli/types.d.ts +8 -8
  51. package/dist/commands/ts-check.js +1 -2
  52. package/dist/common/binStartupScript.js +1 -2
  53. package/dist/common/browserTabs.d.ts +72 -0
  54. package/dist/common/browserTabs.js +74 -0
  55. package/dist/common/constants.d.ts +1 -0
  56. package/dist/common/constants.js +2 -1
  57. package/dist/common/contextStorageStateHelpers.d.ts +4 -3
  58. package/dist/common/contextStorageStateHelpers.js +4 -1
  59. package/dist/common/extension/extensionsHelpers.d.ts +1 -1
  60. package/dist/common/extension/types.d.ts +14 -7
  61. package/dist/common/formatZodError.d.ts +1 -1
  62. package/dist/common/intunedJson.d.ts +19 -14
  63. package/dist/common/intunedJson.js +2 -2
  64. package/dist/common/jwtTokenManager.js +10 -6
  65. package/dist/common/launchBrowser.d.ts +8 -0
  66. package/dist/common/launchBrowser.js +39 -7
  67. package/dist/common/playwrightContext.d.ts +5 -5
  68. package/dist/common/playwrightContext.js +17 -13
  69. package/dist/common/runApi/importUsingImportFunction.d.ts +1 -3
  70. package/dist/common/runApi/importUsingImportFunction.js +7 -7
  71. package/dist/common/runApi/index.d.ts +3 -6
  72. package/dist/common/runApi/index.js +27 -51
  73. package/dist/common/settingsSchema.d.ts +52 -45
  74. package/dist/common/settingsSchema.js +3 -3
  75. package/dist/common/setupContextHook.d.ts +1 -2
  76. package/dist/common/setupContextHook.js +2 -2
  77. package/dist/common/telemetry.js +1 -2
  78. package/dist/index.d.ts +0 -1
  79. package/dist/index.js +0 -7
  80. package/dist/runtime/downloadDirectory.js +2 -2
  81. package/dist/vendor/runtime-interface.d.ts +1 -0
  82. package/dist/vendor/runtime-interface.js +493 -0
  83. package/package.json +17 -10
  84. package/tsup.config.ts +12 -0
  85. package/WebTemplate.zip +0 -0
  86. package/dist/common/runApi/errors.d.ts +0 -72
  87. package/dist/common/runApi/errors.js +0 -169
  88. package/dist/common/runApi/types.d.ts +0 -830
  89. package/dist/common/runApi/types.js +0 -73
@@ -1,6 +1,6 @@
1
1
  import type { BaseCommandOptions } from "../commands/types";
2
- import { RunApiStorageState } from "../../../common/runApi";
3
2
  import { AuthSessionMetadata } from "../types";
3
+ import { RunApiStorageState } from "@intuned/runtime-interface";
4
4
  export declare function executeRunValidateAuthSessionCLI({ id, autoRecreate, checkRetries, createRetries, ...rest }: {
5
5
  id: string;
6
6
  autoRecreate: boolean;
@@ -16,10 +16,10 @@ export declare function executeRunCreateAuthSessionCLI({ id, input, checkRetries
16
16
  metadata?: AuthSessionMetadata;
17
17
  } & BaseCommandOptions): Promise<{
18
18
  cookies: {
19
- path: string;
20
19
  value: string;
21
- domain: string;
20
+ path: string;
22
21
  name: string;
22
+ domain: string;
23
23
  expires: number;
24
24
  httpOnly: boolean;
25
25
  secure: boolean;
@@ -47,10 +47,10 @@ export declare function executeRunUpdateAuthSessionCLI({ id, input, checkRetries
47
47
  createRetries: number;
48
48
  } & BaseCommandOptions): Promise<{
49
49
  cookies: {
50
- path: string;
51
50
  value: string;
52
- domain: string;
51
+ path: string;
53
52
  name: string;
53
+ domain: string;
54
54
  expires: number;
55
55
  httpOnly: boolean;
56
56
  secure: boolean;
@@ -76,10 +76,10 @@ export declare function executeAttemptCreateAuthSessionCLI({ id, input, ...rest
76
76
  input: any;
77
77
  } & BaseCommandOptions): Promise<{
78
78
  cookies: {
79
- path: string;
80
79
  value: string;
81
- domain: string;
80
+ path: string;
82
81
  name: string;
82
+ domain: string;
83
83
  expires: number;
84
84
  httpOnly: boolean;
85
85
  secure: boolean;
@@ -104,10 +104,10 @@ export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
104
104
  id: string;
105
105
  } & BaseCommandOptions): Promise<{
106
106
  cookies: {
107
- path: string;
108
107
  value: string;
109
- domain: string;
108
+ path: string;
110
109
  name: string;
110
+ domain: string;
111
111
  expires: number;
112
112
  httpOnly: boolean;
113
113
  secure: boolean;
@@ -128,20 +128,20 @@ export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
128
128
  }[];
129
129
  }[] | undefined;
130
130
  }>;
131
- declare function runCheck({ auth, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, }: {
131
+ declare function runCheck({ auth, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, ignoreHttpErrors, }: {
132
132
  auth: RunApiStorageState;
133
133
  traceId?: string;
134
134
  } & Omit<BaseCommandOptions, "trace">): Promise<boolean>;
135
135
  export declare const _runCheck: typeof runCheck;
136
- declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, }: {
136
+ declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, ignoreHttpErrors, }: {
137
137
  authSessionInput: Record<string, any>;
138
138
  traceId?: string;
139
139
  } & Omit<BaseCommandOptions, "trace">): Promise<{
140
140
  cookies: {
141
- path: string;
142
141
  value: string;
143
- domain: string;
142
+ path: string;
144
143
  name: string;
144
+ domain: string;
145
145
  expires: number;
146
146
  httpOnly: boolean;
147
147
  secure: boolean;
@@ -175,10 +175,10 @@ declare function runCreateWithRetries({ authSessionId, authSessionInput, retries
175
175
  metadata?: AuthSessionMetadata;
176
176
  } & BaseCommandOptions): Promise<{
177
177
  cookies: {
178
- path: string;
179
178
  value: string;
180
- domain: string;
179
+ path: string;
181
180
  name: string;
181
+ domain: string;
182
182
  expires: number;
183
183
  httpOnly: boolean;
184
184
  secure: boolean;
@@ -200,7 +200,7 @@ declare function runCreateWithRetries({ authSessionId, authSessionInput, retries
200
200
  }[] | undefined;
201
201
  }>;
202
202
  export declare const _runCreateWithRetries: typeof runCreateWithRetries;
203
- export declare function executeRecordAuthSessionCLI({ id, checkRetries, timeout, headless, proxy, trace, keepBrowserOpen, startUrl, finishUrl, }: {
203
+ export declare function executeRecordAuthSessionCLI({ id, checkRetries, timeout, headless, proxy, trace, keepBrowserOpen, startUrl, finishUrl, ignoreHttpErrors, }: {
204
204
  id?: string;
205
205
  checkRetries: number;
206
206
  startUrl: string;
@@ -19,6 +19,7 @@ var _browser = require("../helpers/browser");
19
19
  var _launchBrowser = require("../../../common/launchBrowser");
20
20
  var _promises = require("timers/promises");
21
21
  var _contextStorageStateHelpers = require("../../../common/contextStorageStateHelpers");
22
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
22
23
  async function executeRunValidateAuthSessionCLI({
23
24
  id,
24
25
  autoRecreate,
@@ -172,7 +173,8 @@ async function runCheck({
172
173
  timeout,
173
174
  traceId,
174
175
  keepBrowserOpen,
175
- cdpUrl
176
+ cdpUrl,
177
+ ignoreHttpErrors
176
178
  }) {
177
179
  return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
178
180
  const runApiResult = await (0, _runApi.runApi)({
@@ -183,7 +185,8 @@ async function runCheck({
183
185
  headless,
184
186
  proxy,
185
187
  keepBrowserOpen,
186
- cdpUrl
188
+ cdpUrl,
189
+ ignoreHttpErrors
187
190
  }),
188
191
  auth: {
189
192
  session: {
@@ -213,7 +216,8 @@ async function runCreate({
213
216
  timeout,
214
217
  traceId,
215
218
  keepBrowserOpen,
216
- cdpUrl
219
+ cdpUrl,
220
+ ignoreHttpErrors
217
221
  }) {
218
222
  return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
219
223
  const result = await (0, _runApi.runApi)({
@@ -225,7 +229,8 @@ async function runCreate({
225
229
  headless,
226
230
  proxy,
227
231
  keepBrowserOpen,
228
- cdpUrl
232
+ cdpUrl,
233
+ ignoreHttpErrors
229
234
  }),
230
235
  retrieveSession: true,
231
236
  tracing,
@@ -264,7 +269,7 @@ async function runCheckWithRetries({
264
269
  return true;
265
270
  }
266
271
  } catch (error) {
267
- if (error instanceof _runApi.RunAutomationError) {
272
+ if (error instanceof _runtimeInterface.RunAutomationError) {
268
273
  (0, _helpers.logAutomationError)(error);
269
274
  } else {
270
275
  throw error;
@@ -303,7 +308,7 @@ async function runCreateWithRetries({
303
308
  (0, _terminal.terminal)(`^+^gAuthSession create succeeded^:\n`);
304
309
  break;
305
310
  } catch (error) {
306
- if (error instanceof _runApi.RunAutomationError) {
311
+ if (error instanceof _runtimeInterface.RunAutomationError) {
307
312
  (0, _helpers.logAutomationError)(error);
308
313
  } else {
309
314
  throw error;
@@ -333,7 +338,8 @@ async function executeRecordAuthSessionCLI({
333
338
  trace = false,
334
339
  keepBrowserOpen,
335
340
  startUrl,
336
- finishUrl
341
+ finishUrl,
342
+ ignoreHttpErrors
337
343
  }) {
338
344
  id = id ?? generateAuthSessionId();
339
345
  (0, _terminal.terminal)(`^+Recording AuthSession with id ^c${id}^:\n`);
@@ -343,7 +349,8 @@ async function executeRecordAuthSessionCLI({
343
349
  startUrl,
344
350
  finishUrl,
345
351
  timeout,
346
- proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined
352
+ proxy: proxy ? (0, _helpers.parseUrlProxy)(proxy) : undefined,
353
+ ignoreHttpErrors
347
354
  });
348
355
  } catch (error) {
349
356
  if (error instanceof _helpers.CLIError) {
@@ -373,7 +380,8 @@ async function executeRecordAuthSessionCLI({
373
380
  checkRetries,
374
381
  createRetries: 0,
375
382
  trace,
376
- keepBrowserOpen
383
+ keepBrowserOpen,
384
+ ignoreHttpErrors
377
385
  });
378
386
  (0, _terminal.terminal)(`^+^gAuthSession ^c${id}^ ^+^grecorded successfully^:\n`);
379
387
  }
@@ -381,15 +389,18 @@ async function recordAuthSession({
381
389
  startUrl,
382
390
  finishUrl,
383
391
  timeout,
384
- proxy
392
+ proxy,
393
+ ignoreHttpErrors: cliIgnoreHttpErrors
385
394
  }) {
395
+ const ignoreHttpErrors = await (0, _launchBrowser.getIgnoreHttpErrorsFromConfig)(cliIgnoreHttpErrors);
386
396
  const {
387
397
  context,
388
398
  page
389
399
  } = await (0, _launchBrowser.launchChromium)({
390
400
  headless: false,
391
401
  proxy,
392
- appModeInitialUrl: startUrl
402
+ appModeInitialUrl: startUrl,
403
+ ignoreHttpErrors
393
404
  });
394
405
  try {
395
406
  if (!page.url().startsWith(startUrl)) {
@@ -9,8 +9,7 @@ var path = _interopRequireWildcard(require("path"));
9
9
  var _child_process = require("child_process");
10
10
  var _util = require("util");
11
11
  var _terminal = require("../helpers/terminal");
12
- 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); }
13
- 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; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
13
  const execPromise = (0, _util.promisify)(_child_process.exec);
15
14
  const runBuild = async () => {
16
15
  const distPath = path.join(process.cwd(), "dist");
@@ -18,8 +18,7 @@ var fs = _interopRequireWildcard(require("fs-extra"));
18
18
  var _prompts = _interopRequireDefault(require("prompts"));
19
19
  var _terminalLink = _interopRequireDefault(require("terminal-link"));
20
20
  var _pressAnyKey = _interopRequireDefault(require("press-any-key"));
21
- 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
- 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; }
21
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
23
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
23
  const START_RUN_INPUT_QUERY_PARAM_KEY = exports.START_RUN_INPUT_QUERY_PARAM_KEY = "startRunInput";
25
24
  async function runDeployProject(projectName, auth) {
@@ -6,8 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.loadParameters = loadParameters;
7
7
  var fs = _interopRequireWildcard(require("fs-extra"));
8
8
  var _helpers = require("../helpers");
9
- 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); }
10
- 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; }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
10
  async function loadParameters(parameters) {
12
11
  let inputData;
13
12
  if (await fs.exists(parameters)) {
@@ -18,8 +18,7 @@ var dotenv = _interopRequireWildcard(require("dotenv"));
18
18
  var _constants2 = require("../../../common/constants");
19
19
  var _ignore = _interopRequireDefault(require("ignore"));
20
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
- 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
- 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; }
21
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
23
22
  const provisionProjectApiResponseSchema = _zod.z.string().transform((val, ctx) => {
24
23
  try {
25
24
  return JSON.parse(val);
@@ -3,6 +3,7 @@
3
3
  var _vitest = require("vitest");
4
4
  var _browser = require("../browser");
5
5
  var _launchBrowser = require("../../../../common/launchBrowser");
6
+ var _errors = require("../errors");
6
7
  function getTerminal() {
7
8
  return new Proxy(() => ({}), {
8
9
  get: () => getTerminal(),
@@ -22,7 +23,8 @@ _vitest.vi.mock("../../../../common/launchBrowser", () => ({
22
23
  close: _vitest.vi.fn().mockResolvedValue(undefined)
23
24
  },
24
25
  page: {}
25
- }))
26
+ })),
27
+ getIgnoreHttpErrorsFromConfig: _vitest.vi.fn().mockResolvedValue(false)
26
28
  }));
27
29
  _vitest.vi.mock("../../helpers/terminal", () => ({
28
30
  terminal: getTerminal()
@@ -39,8 +41,21 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
39
41
  terminal: getTerminal()
40
42
  };
41
43
  });
44
+ _vitest.vi.mock("../../../../common/browserTabs", () => {
45
+ return {
46
+ getCDPTabs: _vitest.vi.fn().mockResolvedValue([{
47
+ id: "tab1",
48
+ title: "Tab 1",
49
+ url: "http://example.com/1"
50
+ }, {
51
+ id: "tab2",
52
+ title: "Tab 2",
53
+ url: "http://example.com/2"
54
+ }])
55
+ };
56
+ });
42
57
  (0, _vitest.describe)("Browser CLI options", () => {
43
- (0, _vitest.it)("returns cdp options if cdpUrl is set", async () => {
58
+ (0, _vitest.it)("returns cdp options with first tab if cdpUrl is set and no cdpTabId is not provided", async () => {
44
59
  const options = await (0, _browser.getCLIRunOptions)({
45
60
  keepBrowserOpen: true,
46
61
  headless: true,
@@ -48,9 +63,32 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
48
63
  });
49
64
  (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
50
65
  environment: "cdp",
51
- cdpAddress: "cdp_url"
66
+ cdpAddress: "cdp_url",
67
+ cdpTargetId: "tab1"
68
+ }));
69
+ });
70
+ (0, _vitest.it)("returns cdp options with selected tab if cdpUrl and cdpTabId are provided", async () => {
71
+ const options = await (0, _browser.getCLIRunOptions)({
72
+ keepBrowserOpen: true,
73
+ headless: true,
74
+ cdpUrl: "cdp_url",
75
+ cdpTabId: "tab2"
76
+ });
77
+ (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
78
+ environment: "cdp",
79
+ cdpAddress: "cdp_url",
80
+ cdpTargetId: "tab2"
52
81
  }));
53
82
  });
83
+ (0, _vitest.it)("fails in cdp options if cdp url is provided and invalid tab id is provided", async () => {
84
+ const optionsPromise = (0, _browser.getCLIRunOptions)({
85
+ keepBrowserOpen: true,
86
+ headless: true,
87
+ cdpUrl: "cdp_url",
88
+ cdpTabId: "tab3"
89
+ });
90
+ await (0, _vitest.expect)(optionsPromise).rejects.toThrowError(_errors.CLIError);
91
+ });
54
92
  (0, _vitest.it)("returns standalone options if keepBrowserOpen is not set", async () => {
55
93
  const options = await (0, _browser.getCLIRunOptions)({
56
94
  keepBrowserOpen: false,
@@ -62,7 +100,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
62
100
  }));
63
101
  });
64
102
  (0, _vitest.describe)("when keepBrowserOpen is set", () => {
65
- beforeEach(async () => {
103
+ (0, _vitest.beforeEach)(async () => {
66
104
  _vitest.vi.clearAllMocks();
67
105
  await (0, _browser.closeCliBrowser)();
68
106
  });
@@ -75,7 +113,8 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
75
113
  (0, _vitest.expect)(_launchBrowser.launchChromium).toHaveBeenCalledWith({
76
114
  headless: false,
77
115
  cdpPort: 1234,
78
- proxy: "proxy"
116
+ proxy: "proxy",
117
+ ignoreHttpErrors: false
79
118
  });
80
119
  (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
81
120
  environment: "cdp",
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _vitest = require("vitest");
4
- var _ = require("..");
4
+ var _dist = require("../../../../../dist");
5
5
  function getTerminal() {
6
6
  return new Proxy(() => ({}), {
7
7
  get: () => getTerminal(),
@@ -25,14 +25,14 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
25
25
  (0, _vitest.describe)("Tracing wrapper", () => {
26
26
  (0, _vitest.it)("calls wrapped function with disabled tracing when id is undefined", async () => {
27
27
  const fn = _vitest.vi.fn();
28
- await (0, _.withCLITrace)(fn, undefined);
28
+ await (0, _dist.withCLITrace)(fn, undefined);
29
29
  (0, _vitest.expect)(fn).toHaveBeenCalledWith({
30
30
  enabled: false
31
31
  });
32
32
  });
33
33
  (0, _vitest.it)("calls wrapped function with enabled tracing when id is defined", async () => {
34
34
  const fn = _vitest.vi.fn();
35
- await (0, _.withCLITrace)(fn, "trace-id");
35
+ await (0, _dist.withCLITrace)(fn, "trace-id");
36
36
  (0, _vitest.expect)(fn).toHaveBeenCalledWith({
37
37
  enabled: true,
38
38
  filePath: _vitest.expect.stringContaining("trace-id")
@@ -1,15 +1,15 @@
1
1
  import type { AuthSessionMetadata } from "../types";
2
- import { RunApiStorageState as StorageState } from "../../../common/runApi";
2
+ import { RunApiStorageState } from "@intuned/runtime-interface";
3
3
  export declare function isAuthEnabled(): Promise<boolean>;
4
4
  export declare function assertAuthEnabled(): Promise<void>;
5
5
  export declare function assertAuthConsistent(authSession: string | undefined): Promise<void>;
6
6
  export declare function loadAuthSessionInstance(authSessionId: string): Promise<{
7
7
  storageState: {
8
8
  cookies: {
9
- path: string;
10
9
  value: string;
11
- domain: string;
10
+ path: string;
12
11
  name: string;
12
+ domain: string;
13
13
  expires: number;
14
14
  httpOnly: boolean;
15
15
  secure: boolean;
@@ -33,7 +33,7 @@ export declare function loadAuthSessionInstance(authSessionId: string): Promise<
33
33
  metadata: AuthSessionMetadata;
34
34
  }>;
35
35
  export declare function storeAuthSessionInstance({ state, id, input, proxy, metadata, }: {
36
- state: StorageState;
36
+ state: RunApiStorageState;
37
37
  id: string;
38
38
  input?: Record<string, any>;
39
39
  proxy?: string;
@@ -15,7 +15,7 @@ var _path = _interopRequireDefault(require("path"));
15
15
  var _fsExtra = require("fs-extra");
16
16
  var _intunedJson = require("./intunedJson");
17
17
  var _errors = require("./errors");
18
- var _runApi = require("../../../common/runApi");
18
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
19
19
  var _formatZodError = require("../../../common/formatZodError");
20
20
  var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -46,7 +46,7 @@ async function loadAuthSessionInstance(authSessionId) {
46
46
  throw new _errors.CLIError(`AuthSession instance with ID ${authSessionId} not found. Make sure the ID is correct.`);
47
47
  }
48
48
  const authSessionInstanceJson = await (0, _fsExtra.readJSON)(authSessionInstanceStoragePath);
49
- const authSessionInstanceParseResult = _runApi.runApiStorageStateSchema.safeParse(authSessionInstanceJson);
49
+ const authSessionInstanceParseResult = _runtimeInterface.runApiStorageStateSchema.safeParse(authSessionInstanceJson);
50
50
  if (!authSessionInstanceParseResult.success) {
51
51
  throw new _errors.CLIError(`AuthSession instance with ID ${authSessionId} is not valid: ${(0, _formatZodError.formatZodError)(authSessionInstanceParseResult.error)}`);
52
52
  }
@@ -1,14 +1,14 @@
1
1
  import type { BrowserContext } from "playwright";
2
- import type { runApiParametersSchema } from "../../../common/runApi";
3
- import { z } from "zod";
2
+ import type { RunApiRunOptions } from "@intuned/runtime-interface";
4
3
  declare let context: BrowserContext | null;
5
4
  export declare function _getContextForTest(): typeof context;
6
- type RunApiRunOptions = z.infer<typeof runApiParametersSchema>["runOptions"];
7
- export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, cdpUrl, }: {
5
+ export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, cdpUrl, cdpTabId, ignoreHttpErrors: cliIgnoreHttpErrors, }: {
8
6
  headless: boolean;
9
7
  proxy?: string;
10
8
  keepBrowserOpen: boolean;
11
9
  cdpUrl?: string;
10
+ cdpTabId?: string;
11
+ ignoreHttpErrors?: boolean;
12
12
  }): Promise<RunApiRunOptions>;
13
13
  export declare function isCliBrowserLaunched(): boolean;
14
14
  export declare function closeCliBrowser(): Promise<void>;
@@ -10,6 +10,8 @@ exports.isCliBrowserLaunched = isCliBrowserLaunched;
10
10
  var _launchBrowser = require("../../../common/launchBrowser");
11
11
  var _portfinder = require("portfinder");
12
12
  var _proxy = require("./proxy");
13
+ var _browserTabs = require("../../../common/browserTabs");
14
+ var _errors = require("./errors");
13
15
  let context = null;
14
16
  function _getContextForTest() {
15
17
  if (process.env.NODE_ENV !== "test") {
@@ -21,22 +23,31 @@ async function getCLIRunOptions({
21
23
  headless,
22
24
  proxy,
23
25
  keepBrowserOpen,
24
- cdpUrl
26
+ cdpUrl,
27
+ cdpTabId,
28
+ ignoreHttpErrors: cliIgnoreHttpErrors
25
29
  }) {
26
30
  if (context) {
27
31
  await closeCliBrowser();
28
32
  }
33
+ const ignoreHttpErrors = await (0, _launchBrowser.getIgnoreHttpErrorsFromConfig)(cliIgnoreHttpErrors);
29
34
  if (cdpUrl) {
30
35
  return {
31
36
  environment: "cdp",
32
- cdpAddress: cdpUrl
37
+ cdpAddress: cdpUrl,
38
+ cdpTargetId: await resolveCdpTargetId({
39
+ cdpAddress: cdpUrl,
40
+ cdpTabId
41
+ }),
42
+ ignoreHttpErrors
33
43
  };
34
44
  }
35
45
  if (!keepBrowserOpen) {
36
46
  return {
37
47
  environment: "standalone",
38
48
  headless,
39
- proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined
49
+ proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined,
50
+ ignoreHttpErrors
40
51
  };
41
52
  }
42
53
  const port = await (0, _portfinder.getPort)({});
@@ -45,11 +56,13 @@ async function getCLIRunOptions({
45
56
  } = await (0, _launchBrowser.launchChromium)({
46
57
  headless,
47
58
  proxy: proxy ? (0, _proxy.parseUrlProxy)(proxy) : undefined,
48
- cdpPort: port
59
+ cdpPort: port,
60
+ ignoreHttpErrors
49
61
  }));
50
62
  return {
51
63
  environment: "cdp",
52
- cdpAddress: `http://localhost:${port}`
64
+ cdpAddress: `http://localhost:${port}`,
65
+ ignoreHttpErrors
53
66
  };
54
67
  }
55
68
  function isCliBrowserLaunched() {
@@ -61,4 +74,26 @@ async function closeCliBrowser() {
61
74
  await context.close();
62
75
  context = null;
63
76
  } catch (e) {}
77
+ }
78
+ async function resolveCdpTargetId({
79
+ cdpAddress,
80
+ cdpTabId
81
+ }) {
82
+ let tabs = [];
83
+ try {
84
+ tabs = await (0, _browserTabs.getCDPTabs)(cdpAddress);
85
+ } catch (e) {
86
+ if (cdpTabId) {
87
+ throw new _errors.CLIError(`Failed to fetch tabs from browser: ${e}`);
88
+ }
89
+ }
90
+ if (!cdpTabId) {
91
+ return tabs[0]?.id;
92
+ }
93
+ for (const tab of tabs) {
94
+ if (tab.id.startsWith(cdpTabId)) {
95
+ return tab.id;
96
+ }
97
+ }
98
+ throw new _errors.CLIError(`Tab ${cdpTabId} not found at ${cdpAddress}`);
64
99
  }
@@ -1,4 +1,4 @@
1
- import { RunAutomationError } from "../../../common/runApi/errors";
1
+ import { RunAutomationError } from "@intuned/runtime-interface";
2
2
  export declare class CLIError extends Error {
3
3
  autoColor: boolean;
4
4
  constructor(message: string, options?: {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.CLIError = exports.CLIAssertionError = exports.AbortedCLIError = void 0;
7
7
  exports.logAutomationError = logAutomationError;
8
- var _errors = require("../../../common/runApi/errors");
8
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
9
9
  var _terminal = require("./terminal");
10
10
  class CLIError extends Error {
11
11
  constructor(message, options) {
@@ -31,7 +31,7 @@ class CLIAssertionError extends CLIError {
31
31
  exports.CLIAssertionError = CLIAssertionError;
32
32
  function logAutomationError(error) {
33
33
  (0, _terminal.terminal)(`^r^+An error occurred while running the API:^:\n`);
34
- if (error instanceof _errors.AutomationError) {
34
+ if (error instanceof _runtimeInterface.AutomationError && error.error) {
35
35
  if (error.error.stack) {
36
36
  const stackLines = error.error.stack.split("\n").filter(line => !line.includes("@intuned/runtime") && !line.includes("node:"));
37
37
  (0, _terminal.terminal)(`^r${stackLines.join("\n")}^:\n`);
@@ -1,14 +1,15 @@
1
1
  export declare const loadIntunedJson: () => Promise<{
2
- projectName?: string | undefined;
2
+ stealthMode?: {
3
+ enabled: boolean;
4
+ } | undefined;
5
+ ignoreHttpErrors?: boolean | undefined;
3
6
  workspaceId?: string | undefined;
7
+ projectName?: string | undefined;
4
8
  metadata?: {
5
9
  defaultJobInput?: Record<string, any> | undefined;
6
10
  defaultRunPlaygroundInput?: Record<string, any> | undefined;
7
11
  testAuthSessionInput?: Record<string, any> | undefined;
8
12
  } | undefined;
9
- stealthMode?: {
10
- enabled: boolean;
11
- } | undefined;
12
13
  } & {
13
14
  [k: string]: unknown;
14
15
  } & ({
@@ -22,7 +23,7 @@ export declare const loadIntunedJson: () => Promise<{
22
23
  authSessions: {
23
24
  enabled: false;
24
25
  } | {
25
- type: "API" | "MANUAL";
26
+ type: "MANUAL" | "API";
26
27
  enabled: true;
27
28
  startUrl?: string | undefined;
28
29
  finishUrl?: string | undefined;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.withTimeout = withTimeout;
7
7
  var _asyncLocalStorage = require("../../../common/asyncLocalStorage");
8
- var _runApi = require("../../../common/runApi");
8
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
9
9
  function withTimeout(fn, timeout) {
10
10
  let reject;
11
11
  const abortController = new AbortController();
@@ -14,7 +14,7 @@ function withTimeout(fn, timeout) {
14
14
  });
15
15
  const timeoutId = setTimeout(() => {
16
16
  abortController.abort();
17
- reject(new _runApi.AutomationError(new Error("Timed out")));
17
+ reject(new _runtimeInterface.AutomationError(new Error("Timed out")));
18
18
  }, timeout);
19
19
  (0, _asyncLocalStorage.getExecutionContext)().timeoutInfo.extendTimeoutCallback = async () => {
20
20
  timeoutId.refresh();
@@ -1,2 +1,2 @@
1
- import { RunApiParameters } from "../../../common/runApi";
1
+ import { RunApiParameters } from "@intuned/runtime-interface";
2
2
  export declare function withCLITrace<T>(fn: (tracing: NonNullable<RunApiParameters["tracing"]>) => T | Promise<T>, id: string | undefined): Promise<T>;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.cliCommandWrapper = cliCommandWrapper;
7
7
  var _terminal = require("./terminal");
8
- var _runApi = require("../../../common/runApi");
8
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
9
9
  var _browser = require("./browser");
10
10
  var _errors = require("./errors");
11
11
  var _zod = require("zod");
@@ -47,7 +47,7 @@ function cliCommandWrapper(argsSchema, optionsSchema, fn) {
47
47
  } else {
48
48
  (0, _terminal.terminal)(`${error.message}\n`);
49
49
  }
50
- } else if (error instanceof _runApi.AutomationError) {
50
+ } else if (error instanceof _runtimeInterface.AutomationError) {
51
51
  (0, _errors.logAutomationError)(error);
52
52
  } else {
53
53
  (0, _terminal.terminal)(`^r^+An error occurred:^: ^R${error.message}^:\n^r^+Please report this issue to the Intuned team.^:\n`);
@@ -5,8 +5,7 @@ var _constants = require("../../common/constants");
5
5
  var _backend = require("./helpers/backend");
6
6
  var _intunedJson = require("../../common/intunedJson");
7
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
- 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); }
9
- 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; }
8
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
9
  require("../../common/binStartupScript");
11
10
  _dotenv.default.config({
12
11
  path: `.env`