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

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 (88) hide show
  1. package/.babelrc +6 -0
  2. package/InterfaceTemplate/{utils.ts → __utils.ts} +3 -1
  3. package/InterfaceTemplate/index.playwright.ts +1 -1
  4. package/bin/intuned +0 -0
  5. package/bin/intuned-interface +7 -0
  6. package/dist/commands/api/run.js +3 -3
  7. package/dist/commands/auth-sessions/run-check.js +3 -3
  8. package/dist/commands/auth-sessions/run-create.js +3 -3
  9. package/dist/commands/build.js +1 -3
  10. package/dist/commands/common/browserUtils.d.ts +3 -3
  11. package/dist/commands/common/browserUtils.js +3 -4
  12. package/dist/commands/common/getFirstLineNumber.test.js +1 -2
  13. package/dist/commands/common/tsNodeImport.d.ts +1 -1
  14. package/dist/commands/common/tsNodeImport.js +1 -2
  15. package/dist/commands/common/utils/fileUtils.js +1 -2
  16. package/dist/commands/common/utils/{unixSocket.d.ts → interfaceClient.d.ts} +10 -2
  17. package/dist/commands/common/utils/{unixSocket.js → interfaceClient.js} +16 -5
  18. package/dist/commands/common/utils/template.js +1 -2
  19. package/dist/commands/interface/run.js +23 -49
  20. package/dist/commands/intuned-cli/commands/deploy.command.js +2 -2
  21. package/dist/commands/intuned-cli/commands/provision.command.d.ts +2 -2
  22. package/dist/commands/intuned-cli/commands/provision.command.js +1 -1
  23. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +5 -1
  24. package/dist/commands/intuned-cli/commands/types.d.ts +5 -1
  25. package/dist/commands/intuned-cli/commands/types.js +5 -3
  26. package/dist/commands/intuned-cli/controller/__test__/api.test.js +6 -5
  27. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +6 -5
  28. package/dist/commands/intuned-cli/controller/api.d.ts +2 -2
  29. package/dist/commands/intuned-cli/controller/api.js +3 -3
  30. package/dist/commands/intuned-cli/controller/authSession.d.ts +13 -13
  31. package/dist/commands/intuned-cli/controller/authSession.js +3 -2
  32. package/dist/commands/intuned-cli/controller/build.js +1 -2
  33. package/dist/commands/intuned-cli/controller/deploy.js +1 -2
  34. package/dist/commands/intuned-cli/controller/index.js +1 -2
  35. package/dist/commands/intuned-cli/controller/provision.js +1 -2
  36. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +39 -2
  37. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +3 -3
  38. package/dist/commands/intuned-cli/helpers/auth.d.ts +4 -4
  39. package/dist/commands/intuned-cli/helpers/auth.js +2 -2
  40. package/dist/commands/intuned-cli/helpers/browser.d.ts +3 -4
  41. package/dist/commands/intuned-cli/helpers/browser.js +31 -2
  42. package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
  43. package/dist/commands/intuned-cli/helpers/errors.js +2 -2
  44. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +6 -5
  45. package/dist/commands/intuned-cli/helpers/timeout.js +2 -2
  46. package/dist/commands/intuned-cli/helpers/traces.d.ts +1 -1
  47. package/dist/commands/intuned-cli/helpers/wrapper.js +2 -2
  48. package/dist/commands/intuned-cli/main.js +1 -2
  49. package/dist/commands/intuned-cli/types.d.ts +8 -8
  50. package/dist/commands/ts-check.js +1 -2
  51. package/dist/common/binStartupScript.js +16 -7
  52. package/dist/common/browserTabs.d.ts +72 -0
  53. package/dist/common/browserTabs.js +74 -0
  54. package/dist/common/constants.d.ts +1 -0
  55. package/dist/common/constants.js +2 -1
  56. package/dist/common/contextStorageStateHelpers.d.ts +4 -3
  57. package/dist/common/contextStorageStateHelpers.js +4 -1
  58. package/dist/common/extension/extensionsHelpers.d.ts +1 -1
  59. package/dist/common/extension/types.d.ts +14 -7
  60. package/dist/common/formatZodError.d.ts +1 -1
  61. package/dist/common/intunedJson.d.ts +29 -14
  62. package/dist/common/intunedJson.js +24 -3
  63. package/dist/common/jwtTokenManager.js +10 -6
  64. package/dist/common/launchBrowser.d.ts +1 -0
  65. package/dist/common/launchBrowser.js +32 -5
  66. package/dist/common/playwrightContext.d.ts +3 -5
  67. package/dist/common/playwrightContext.js +9 -11
  68. package/dist/common/runApi/importUsingImportFunction.d.ts +1 -3
  69. package/dist/common/runApi/importUsingImportFunction.js +7 -7
  70. package/dist/common/runApi/index.d.ts +3 -6
  71. package/dist/common/runApi/index.js +25 -51
  72. package/dist/common/settingsSchema.d.ts +49 -45
  73. package/dist/common/settingsSchema.js +1 -2
  74. package/dist/common/setupContextHook.d.ts +1 -2
  75. package/dist/common/setupContextHook.js +2 -2
  76. package/dist/common/telemetry.js +1 -2
  77. package/dist/index.d.ts +0 -1
  78. package/dist/index.js +0 -7
  79. package/dist/runtime/downloadDirectory.js +2 -2
  80. package/dist/vendor/runtime-interface.d.ts +1 -0
  81. package/dist/vendor/runtime-interface.js +491 -0
  82. package/package.json +17 -10
  83. package/tsup.config.ts +12 -0
  84. package/WebTemplate.zip +0 -0
  85. package/dist/common/runApi/errors.d.ts +0 -72
  86. package/dist/common/runApi/errors.js +0 -169
  87. package/dist/common/runApi/types.d.ts +0 -830
  88. package/dist/common/runApi/types.js +0 -73
@@ -6,6 +6,7 @@ var _authSession = require("../authSession");
6
6
  var _helpers = require("../../helpers");
7
7
  var _neverthrow = require("neverthrow");
8
8
  var _runApi = require("../../../../common/runApi");
9
+ var _runtimeInterface = require("../../../../vendor/runtime-interface");
9
10
  var _fsExtra = require("fs-extra");
10
11
  var _browser = require("../../helpers/browser");
11
12
  function getTerminal() {
@@ -224,7 +225,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
224
225
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
225
226
  });
226
227
  (0, _vitest.it)("stops retrying after max retries", async () => {
227
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
228
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed")));
228
229
  await (0, _vitest.expect)((0, _api.executeRunApiCLI)({
229
230
  apiName: "testApi",
230
231
  inputData: {},
@@ -242,7 +243,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
242
243
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
243
244
  });
244
245
  (0, _vitest.it)("stops retrying on success", async () => {
245
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
246
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
246
247
  result: "success"
247
248
  }));
248
249
  await (0, _api.executeRunApiCLI)({
@@ -253,7 +254,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
253
254
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(2);
254
255
  });
255
256
  (0, _vitest.it)("validates AuthSession before each attempt if provided", async () => {
256
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
257
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed"))).mockResolvedValue((0, _neverthrow.ok)({
257
258
  result: "success"
258
259
  }));
259
260
  await (0, _api.executeRunApiCLI)({
@@ -364,11 +365,11 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
364
365
  });
365
366
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
366
367
  _vitest.vi.mocked(_runApi.runApi).mockReset();
367
- _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runApi.AutomationError("runApi failed")));
368
+ _vitest.vi.mocked(_runApi.runApi).mockResolvedValue((0, _neverthrow.err)(new _runtimeInterface.AutomationError("runApi failed")));
368
369
  await (0, _vitest.expect)((0, _api.executeAttemptApiCLI)({
369
370
  apiName: "testApi",
370
371
  inputData: {}
371
- })).rejects.toThrow(_runApi.AutomationError);
372
+ })).rejects.toThrow(_runtimeInterface.AutomationError);
372
373
  (0, _vitest.expect)(_runApi.runApi).toHaveBeenCalledTimes(1);
373
374
  });
374
375
  (0, _vitest.it)("writes result to file if outputFile is provided", async () => {
@@ -5,6 +5,7 @@ var _authSession = require("../authSession");
5
5
  var _helpers = require("../../helpers");
6
6
  var _neverthrow = require("neverthrow");
7
7
  var _runApi = require("../../../../common/runApi");
8
+ var _runtimeInterface = require("../../../../vendor/runtime-interface");
8
9
  var _browser = require("../../helpers/browser");
9
10
  var _launchBrowser = require("../../../../common/launchBrowser");
10
11
  var _promises = require("timers/promises");
@@ -14,7 +15,7 @@ const _checkPassedResult = (0, _neverthrow.ok)({
14
15
  const _checkFailedResult = (0, _neverthrow.ok)({
15
16
  result: false
16
17
  });
17
- const _errorResult = (0, _neverthrow.err)(new _runApi.AutomationError("failed"));
18
+ const _errorResult = (0, _neverthrow.err)(new _runtimeInterface.AutomationError("failed"));
18
19
  function _createSuccessResult(session) {
19
20
  return (0, _neverthrow.ok)({
20
21
  session
@@ -559,7 +560,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
559
560
  (0, _vitest.beforeEach)(() => {
560
561
  _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkFailedResult);
561
562
  });
562
- afterEach(() => {
563
+ (0, _vitest.afterEach)(() => {
563
564
  _vitest.vi.mocked(_runApi.runApi).mockReset();
564
565
  _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
565
566
  });
@@ -725,7 +726,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
725
726
  }
726
727
  });
727
728
  });
728
- afterEach(() => {
729
+ (0, _vitest.afterEach)(() => {
729
730
  _vitest.vi.mocked(_runApi.runApi).mockReset();
730
731
  _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
731
732
  });
@@ -848,7 +849,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
848
849
  });
849
850
  _vitest.vi.mocked(_runApi.runApi).mockResolvedValueOnce(_checkPassedResult);
850
851
  });
851
- afterEach(() => {
852
+ (0, _vitest.afterEach)(() => {
852
853
  _vitest.vi.mocked(_runApi.runApi).mockReset();
853
854
  _vitest.vi.mocked(_helpers.loadAuthSessionInstance).mockReset();
854
855
  });
@@ -963,7 +964,7 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
963
964
  }
964
965
  });
965
966
  });
966
- afterEach(() => {
967
+ (0, _vitest.afterEach)(() => {
967
968
  _vitest.vi.mocked(_runApi.runApi).mockReset();
968
969
  _vitest.vi.mocked(_launchBrowser.launchChromium).mockReset();
969
970
  _vitest.vi.useRealTimers();
@@ -1,5 +1,5 @@
1
1
  import { Payload } from "../../../runtime/export";
2
- import { RunApiStorageState } from "../../../common/runApi";
2
+ import { RunApiStorageState } from "@intuned/runtime-interface";
3
3
  import type { BaseCommandOptions } from "../commands/types";
4
4
  export declare function executeRunApiCLI({ apiName, inputData, retries, authSession, outputFile, trace, ...rest }: {
5
5
  apiName: string;
@@ -36,7 +36,7 @@ declare function attemptApi({ apiName, inputData, auth, proxy, headless, timeout
36
36
  traceId?: string;
37
37
  } & Omit<BaseCommandOptions, "trace">): Promise<{
38
38
  result: any;
39
- payloadToAppend: Payload[] | undefined;
39
+ payloadToAppend: import("@intuned/runtime-interface").Payload[] | undefined;
40
40
  }>;
41
41
  export declare const _attemptApi: typeof attemptApi;
42
42
  export {};
@@ -10,14 +10,14 @@ var fs = _interopRequireWildcard(require("fs-extra"));
10
10
  var _runApi = require("../../../common/runApi");
11
11
  var _tsNodeImport = require("../../common/tsNodeImport");
12
12
  var _authSession = require("./authSession");
13
+ var _runtimeInterface = require("../../../vendor/runtime-interface");
13
14
  var _helpers = require("../helpers");
14
15
  var _terminal = require("../helpers/terminal");
15
16
  var _constants = require("../../../common/constants");
16
17
  var _browser = require("../helpers/browser");
17
18
  var _path = _interopRequireDefault(require("path"));
18
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
- 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); }
20
- 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; }
20
+ 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); }
21
21
  async function executeRunApiCLI({
22
22
  apiName,
23
23
  inputData,
@@ -50,7 +50,7 @@ async function executeRunApiCLI({
50
50
  ...rest
51
51
  });
52
52
  } catch (error) {
53
- if (error instanceof _runApi.RunAutomationError) {
53
+ if (error instanceof _runtimeInterface.RunAutomationError) {
54
54
  (0, _helpers.logAutomationError)(error);
55
55
  (0, _terminal.terminal)(`^r^+Attempt ${i + 1} failed^:\n`);
56
56
  continue;
@@ -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;
@@ -138,10 +138,10 @@ declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId
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;
@@ -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,
@@ -264,7 +265,7 @@ async function runCheckWithRetries({
264
265
  return true;
265
266
  }
266
267
  } catch (error) {
267
- if (error instanceof _runApi.RunAutomationError) {
268
+ if (error instanceof _runtimeInterface.RunAutomationError) {
268
269
  (0, _helpers.logAutomationError)(error);
269
270
  } else {
270
271
  throw error;
@@ -303,7 +304,7 @@ async function runCreateWithRetries({
303
304
  (0, _terminal.terminal)(`^+^gAuthSession create succeeded^:\n`);
304
305
  break;
305
306
  } catch (error) {
306
- if (error instanceof _runApi.RunAutomationError) {
307
+ if (error instanceof _runtimeInterface.RunAutomationError) {
307
308
  (0, _helpers.logAutomationError)(error);
308
309
  } else {
309
310
  throw error;
@@ -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(),
@@ -39,8 +40,21 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
39
40
  terminal: getTerminal()
40
41
  };
41
42
  });
43
+ _vitest.vi.mock("../../../../common/browserTabs", () => {
44
+ return {
45
+ getCDPTabs: _vitest.vi.fn().mockResolvedValue([{
46
+ id: "tab1",
47
+ title: "Tab 1",
48
+ url: "http://example.com/1"
49
+ }, {
50
+ id: "tab2",
51
+ title: "Tab 2",
52
+ url: "http://example.com/2"
53
+ }])
54
+ };
55
+ });
42
56
  (0, _vitest.describe)("Browser CLI options", () => {
43
- (0, _vitest.it)("returns cdp options if cdpUrl is set", async () => {
57
+ (0, _vitest.it)("returns cdp options with first tab if cdpUrl is set and no cdpTabId is not provided", async () => {
44
58
  const options = await (0, _browser.getCLIRunOptions)({
45
59
  keepBrowserOpen: true,
46
60
  headless: true,
@@ -48,9 +62,32 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
48
62
  });
49
63
  (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
50
64
  environment: "cdp",
51
- cdpAddress: "cdp_url"
65
+ cdpAddress: "cdp_url",
66
+ cdpTargetId: "tab1"
52
67
  }));
53
68
  });
69
+ (0, _vitest.it)("returns cdp options with selected tab if cdpUrl and cdpTabId are provided", async () => {
70
+ const options = await (0, _browser.getCLIRunOptions)({
71
+ keepBrowserOpen: true,
72
+ headless: true,
73
+ cdpUrl: "cdp_url",
74
+ cdpTabId: "tab2"
75
+ });
76
+ (0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
77
+ environment: "cdp",
78
+ cdpAddress: "cdp_url",
79
+ cdpTargetId: "tab2"
80
+ }));
81
+ });
82
+ (0, _vitest.it)("fails in cdp options if cdp url is provided and invalid tab id is provided", async () => {
83
+ const optionsPromise = (0, _browser.getCLIRunOptions)({
84
+ keepBrowserOpen: true,
85
+ headless: true,
86
+ cdpUrl: "cdp_url",
87
+ cdpTabId: "tab3"
88
+ });
89
+ await (0, _vitest.expect)(optionsPromise).rejects.toThrowError(_errors.CLIError);
90
+ });
54
91
  (0, _vitest.it)("returns standalone options if keepBrowserOpen is not set", async () => {
55
92
  const options = await (0, _browser.getCLIRunOptions)({
56
93
  keepBrowserOpen: false,
@@ -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,13 @@
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, }: {
8
6
  headless: boolean;
9
7
  proxy?: string;
10
8
  keepBrowserOpen: boolean;
11
9
  cdpUrl?: string;
10
+ cdpTabId?: string;
12
11
  }): Promise<RunApiRunOptions>;
13
12
  export declare function isCliBrowserLaunched(): boolean;
14
13
  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,7 +23,8 @@ async function getCLIRunOptions({
21
23
  headless,
22
24
  proxy,
23
25
  keepBrowserOpen,
24
- cdpUrl
26
+ cdpUrl,
27
+ cdpTabId
25
28
  }) {
26
29
  if (context) {
27
30
  await closeCliBrowser();
@@ -29,7 +32,11 @@ async function getCLIRunOptions({
29
32
  if (cdpUrl) {
30
33
  return {
31
34
  environment: "cdp",
32
- cdpAddress: cdpUrl
35
+ cdpAddress: cdpUrl,
36
+ cdpTargetId: await resolveCdpTargetId({
37
+ cdpAddress: cdpUrl,
38
+ cdpTabId
39
+ })
33
40
  };
34
41
  }
35
42
  if (!keepBrowserOpen) {
@@ -61,4 +68,26 @@ async function closeCliBrowser() {
61
68
  await context.close();
62
69
  context = null;
63
70
  } catch (e) {}
71
+ }
72
+ async function resolveCdpTargetId({
73
+ cdpAddress,
74
+ cdpTabId
75
+ }) {
76
+ let tabs = [];
77
+ try {
78
+ tabs = await (0, _browserTabs.getCDPTabs)(cdpAddress);
79
+ } catch (e) {
80
+ if (cdpTabId) {
81
+ throw new _errors.CLIError(`Failed to fetch tabs from browser: ${e}`);
82
+ }
83
+ }
84
+ if (!cdpTabId) {
85
+ return tabs[0]?.id;
86
+ }
87
+ for (const tab of tabs) {
88
+ if (tab.id.startsWith(cdpTabId)) {
89
+ return tab.id;
90
+ }
91
+ }
92
+ throw new _errors.CLIError(`Tab ${cdpTabId} not found at ${cdpAddress}`);
64
93
  }
@@ -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
+ type: "intunedBrowser" | "patchright";
4
+ enabled: boolean;
5
+ } | 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`