@intuned/runtime 1.3.21 → 1.3.23

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 (112) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/bin/intuned +20 -2
  3. package/dist/commands/api/run.js +1 -1
  4. package/dist/commands/common/browserUtils.js +10 -1
  5. package/dist/common/binStartupScript.js +1 -40
  6. package/dist/common/intunedJson.d.ts +42 -12
  7. package/dist/common/intunedJson.js +19 -9
  8. package/dist/common/launchBrowser.d.ts +6 -0
  9. package/dist/common/launchBrowser.js +37 -5
  10. package/dist/common/playwrightContext.d.ts +1 -0
  11. package/dist/common/playwrightContext.js +6 -2
  12. package/dist/common/runApi/index.js +1 -0
  13. package/dist/runtime/getAiGatewayConfig.js +1 -1
  14. package/dist/vendor/runtime-interface.js +9 -11
  15. package/package.json +3 -3
  16. package/.claude/settings.local.json +0 -7
  17. package/dist/commands/intuned-cli/commands/attempt.command.d.ts +0 -1
  18. package/dist/commands/intuned-cli/commands/attempt.command.js +0 -8
  19. package/dist/commands/intuned-cli/commands/attempt_api.command.d.ts +0 -1
  20. package/dist/commands/intuned-cli/commands/attempt_api.command.js +0 -30
  21. package/dist/commands/intuned-cli/commands/attempt_authsession.command.d.ts +0 -1
  22. package/dist/commands/intuned-cli/commands/attempt_authsession.command.js +0 -8
  23. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.d.ts +0 -1
  24. package/dist/commands/intuned-cli/commands/attempt_authsession_check.command.js +0 -19
  25. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.d.ts +0 -1
  26. package/dist/commands/intuned-cli/commands/attempt_authsession_create.command.js +0 -24
  27. package/dist/commands/intuned-cli/commands/authsession.command.d.ts +0 -1
  28. package/dist/commands/intuned-cli/commands/authsession.command.js +0 -8
  29. package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +0 -1
  30. package/dist/commands/intuned-cli/commands/authsession_record.command.js +0 -32
  31. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.d.ts +0 -1
  32. package/dist/commands/intuned-cli/commands/authsession_scaffold.command.js +0 -16
  33. package/dist/commands/intuned-cli/commands/build.command.d.ts +0 -1
  34. package/dist/commands/intuned-cli/commands/build.command.js +0 -12
  35. package/dist/commands/intuned-cli/commands/command.d.ts +0 -2
  36. package/dist/commands/intuned-cli/commands/command.js +0 -9
  37. package/dist/commands/intuned-cli/commands/deploy.command.d.ts +0 -1
  38. package/dist/commands/intuned-cli/commands/deploy.command.js +0 -42
  39. package/dist/commands/intuned-cli/commands/index.d.ts +0 -18
  40. package/dist/commands/intuned-cli/commands/index.js +0 -203
  41. package/dist/commands/intuned-cli/commands/provision.command.d.ts +0 -13
  42. package/dist/commands/intuned-cli/commands/provision.command.js +0 -50
  43. package/dist/commands/intuned-cli/commands/run.command.d.ts +0 -1
  44. package/dist/commands/intuned-cli/commands/run.command.js +0 -8
  45. package/dist/commands/intuned-cli/commands/run_api.command.d.ts +0 -1
  46. package/dist/commands/intuned-cli/commands/run_api.command.js +0 -46
  47. package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +0 -35
  48. package/dist/commands/intuned-cli/commands/run_authsession.command.js +0 -17
  49. package/dist/commands/intuned-cli/commands/run_authsession_create.command.d.ts +0 -1
  50. package/dist/commands/intuned-cli/commands/run_authsession_create.command.js +0 -35
  51. package/dist/commands/intuned-cli/commands/run_authsession_update.command.d.ts +0 -1
  52. package/dist/commands/intuned-cli/commands/run_authsession_update.command.js +0 -35
  53. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.d.ts +0 -1
  54. package/dist/commands/intuned-cli/commands/run_authsession_validate.command.js +0 -33
  55. package/dist/commands/intuned-cli/commands/types.d.ts +0 -39
  56. package/dist/commands/intuned-cli/commands/types.js +0 -33
  57. package/dist/commands/intuned-cli/constants/index.d.ts +0 -17
  58. package/dist/commands/intuned-cli/constants/index.js +0 -25
  59. package/dist/commands/intuned-cli/controller/__test__/api.test.js +0 -399
  60. package/dist/commands/intuned-cli/controller/__test__/authSession.test.js +0 -1061
  61. package/dist/commands/intuned-cli/controller/api.d.ts +0 -42
  62. package/dist/commands/intuned-cli/controller/api.js +0 -194
  63. package/dist/commands/intuned-cli/controller/authSession.d.ts +0 -209
  64. package/dist/commands/intuned-cli/controller/authSession.js +0 -425
  65. package/dist/commands/intuned-cli/controller/build.d.ts +0 -1
  66. package/dist/commands/intuned-cli/controller/build.js +0 -35
  67. package/dist/commands/intuned-cli/controller/deploy.d.ts +0 -5
  68. package/dist/commands/intuned-cli/controller/deploy.js +0 -317
  69. package/dist/commands/intuned-cli/controller/index.d.ts +0 -1
  70. package/dist/commands/intuned-cli/controller/index.js +0 -45
  71. package/dist/commands/intuned-cli/controller/provision.d.ts +0 -21
  72. package/dist/commands/intuned-cli/controller/provision.js +0 -299
  73. package/dist/commands/intuned-cli/controller/scaffold.d.ts +0 -1
  74. package/dist/commands/intuned-cli/controller/scaffold.js +0 -77
  75. package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +0 -152
  76. package/dist/commands/intuned-cli/helpers/__test__/tracing.test.js +0 -41
  77. package/dist/commands/intuned-cli/helpers/api.d.ts +0 -3
  78. package/dist/commands/intuned-cli/helpers/api.js +0 -16
  79. package/dist/commands/intuned-cli/helpers/auth.d.ts +0 -46
  80. package/dist/commands/intuned-cli/helpers/auth.js +0 -147
  81. package/dist/commands/intuned-cli/helpers/backend.d.ts +0 -8
  82. package/dist/commands/intuned-cli/helpers/backend.js +0 -35
  83. package/dist/commands/intuned-cli/helpers/browser.d.ts +0 -14
  84. package/dist/commands/intuned-cli/helpers/browser.js +0 -93
  85. package/dist/commands/intuned-cli/helpers/context.d.ts +0 -3
  86. package/dist/commands/intuned-cli/helpers/context.js +0 -33
  87. package/dist/commands/intuned-cli/helpers/errors.d.ts +0 -16
  88. package/dist/commands/intuned-cli/helpers/errors.js +0 -44
  89. package/dist/commands/intuned-cli/helpers/index.d.ts +0 -12
  90. package/dist/commands/intuned-cli/helpers/index.js +0 -137
  91. package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +0 -40
  92. package/dist/commands/intuned-cli/helpers/intunedJson.js +0 -20
  93. package/dist/commands/intuned-cli/helpers/prompts.d.ts +0 -3
  94. package/dist/commands/intuned-cli/helpers/prompts.js +0 -71
  95. package/dist/commands/intuned-cli/helpers/proxy.d.ts +0 -5
  96. package/dist/commands/intuned-cli/helpers/proxy.js +0 -23
  97. package/dist/commands/intuned-cli/helpers/terminal.d.ts +0 -5
  98. package/dist/commands/intuned-cli/helpers/terminal.js +0 -13
  99. package/dist/commands/intuned-cli/helpers/timeout.d.ts +0 -1
  100. package/dist/commands/intuned-cli/helpers/timeout.js +0 -23
  101. package/dist/commands/intuned-cli/helpers/traces.d.ts +0 -2
  102. package/dist/commands/intuned-cli/helpers/traces.js +0 -32
  103. package/dist/commands/intuned-cli/helpers/validation.d.ts +0 -2
  104. package/dist/commands/intuned-cli/helpers/validation.js +0 -14
  105. package/dist/commands/intuned-cli/helpers/wrapper.d.ts +0 -2
  106. package/dist/commands/intuned-cli/helpers/wrapper.js +0 -76
  107. package/dist/commands/intuned-cli/index.d.ts +0 -1
  108. package/dist/commands/intuned-cli/index.js +0 -16
  109. package/dist/commands/intuned-cli/main.d.ts +0 -1
  110. package/dist/commands/intuned-cli/main.js +0 -35
  111. package/dist/commands/intuned-cli/types.d.ts +0 -70
  112. package/dist/commands/intuned-cli/types.js +0 -22
package/CHANGELOG.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # UNRELEASED
2
2
 
3
+ - Add support for `ignoreHttpErrors` parameter to handle HTTP errors during browser navigation via `INTUNED_PLAYWRIGHT_CONTEXT_IGNORE_HTTP_ERRORS` environment variable.
3
4
  - Add `timeout` parameter (in seconds, defaults to 30) to `launchBrowser` and `launchChromium` functions
4
5
 
5
6
  # 1.3.11
package/bin/intuned CHANGED
@@ -1,4 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require("../dist/common/binStartupScript.js");
4
- require("../dist/commands/intuned-cli/main.js");
3
+ // detect `intunedctl` in PATH and run it with the provided arguments
4
+ const spawn = require("child_process").spawn;
5
+ const which = require("which");
6
+
7
+ const intunedctlPath = which.sync("intunedctl", { nothrow: true });
8
+
9
+ if (!intunedctlPath) {
10
+ console.error(
11
+ "Install Intuned CLI globally with `npm install -g @intuned/cli` to run this command."
12
+ );
13
+ process.exit(1);
14
+ }
15
+
16
+ const child = spawn(intunedctlPath, process.argv.slice(2), {
17
+ stdio: "inherit",
18
+ });
19
+
20
+ child.on("exit", (code) => {
21
+ process.exit(code ?? 0);
22
+ });
@@ -113,7 +113,7 @@ _commander.program.description("run the user function in the cli for testing pur
113
113
  runId: (0, _nanoid.nanoid)(),
114
114
  proxy: options.proxy,
115
115
  getAuthSessionParameters: authSessionParametersJson !== undefined ? async () => authSessionParametersJson : undefined
116
- }, async () => await executeCLI(apiName, mode, inputData, options));
116
+ }, () => executeCLI(apiName, mode, inputData, options));
117
117
  process.exit(0);
118
118
  });
119
119
  _commander.program.parse(process.argv);
@@ -15,7 +15,16 @@ var _contextStorageStateHelpers = require("../../common/contextStorageStateHelpe
15
15
  var playwright = _interopRequireWildcard(require("playwright"));
16
16
  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); }
17
17
  const REMOTE_DEBUGGING_PORT = exports.REMOTE_DEBUGGING_PORT = 9222;
18
- const getChromiumLaunchArgs = () => ["--no-sandbox", `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`, `--user-data-dir=/tmp/${Date.now()}`, "--new-window", "--start-maximized", "--disable-popup-blocking"];
18
+ function getMacKeychainBypassArgs() {
19
+ if (process.platform !== "darwin") {
20
+ return [];
21
+ }
22
+ if (process.env.INTUNED_MAC_DISABLE_KEYCHAIN_PROMPTS === "0") {
23
+ return [];
24
+ }
25
+ return ["--use-mock-keychain", "--password-store=basic"];
26
+ }
27
+ const getChromiumLaunchArgs = () => ["--no-sandbox", `--remote-debugging-port=${REMOTE_DEBUGGING_PORT}`, `--user-data-dir=/tmp/${Date.now()}`, "--new-window", "--start-maximized", "--disable-popup-blocking", ...getMacKeychainBypassArgs()];
19
28
  exports.getChromiumLaunchArgs = getChromiumLaunchArgs;
20
29
  async function getBrowser() {
21
30
  let playwrightBrowser = null;
@@ -1,46 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _dotenv = _interopRequireDefault(require("dotenv"));
4
- var path = _interopRequireWildcard(require("path"));
5
- var _intunedJson = require("./intunedJson");
6
- 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); }
7
4
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
5
  _dotenv.default.config({
9
6
  path: `.env`
10
- });
11
- function getStealthModeConfig() {
12
- try {
13
- const settingsResult = (0, _intunedJson.loadIntunedJsonSync)();
14
- if (settingsResult.isErr()) {
15
- console.error(`Warning: Failed to load Intuned settings: ${settingsResult.error}
16
- Stealth mode will not be enabled.`);
17
- return {
18
- enabled: false,
19
- type: "patchright"
20
- };
21
- }
22
- return {
23
- enabled: settingsResult.value.stealthMode?.enabled === true,
24
- type: settingsResult.value.stealthMode?.type || "patchright"
25
- };
26
- } catch (error) {
27
- console.error("Error reading Intuned.json:", error.message);
28
- return {
29
- enabled: false,
30
- type: "patchright"
31
- };
32
- }
33
- }
34
- try {
35
- const stealthConfig = getStealthModeConfig();
36
- if (stealthConfig.enabled && stealthConfig.type === "patchright") {
37
- const currentNodeModules = path.resolve(process.cwd(), "node_modules");
38
- process.env.NODE_PATH = process.env.NODE_PATH ? `${process.env.NODE_PATH}:${currentNodeModules}` : currentNodeModules;
39
- require("module").Module._initPaths();
40
- if (process.env.PLAYWRIGHT_PATCH_SCRIPT_PATH) {
41
- require(process.env.PLAYWRIGHT_PATCH_SCRIPT_PATH);
42
- }
43
- }
44
- } catch (e) {
45
- console.error("Failed to apply stealth mode");
46
- }
7
+ });
@@ -16,15 +16,22 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
16
16
  defaultRunPlaygroundInput?: unknown;
17
17
  testAuthSessionInput?: unknown;
18
18
  }>>>;
19
+ browserSize: z.ZodCatch<z.ZodOptional<z.ZodObject<{
20
+ width: z.ZodNumber;
21
+ height: z.ZodNumber;
22
+ }, "strip", z.ZodTypeAny, {
23
+ width: number;
24
+ height: number;
25
+ }, {
26
+ width: number;
27
+ height: number;
28
+ }>>>;
19
29
  stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
20
30
  enabled: z.ZodBoolean;
21
- type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["intunedBrowser", "patchright"]>>>;
22
31
  }, "strip", z.ZodTypeAny, {
23
- type: "intunedBrowser" | "patchright";
24
32
  enabled: boolean;
25
33
  }, {
26
34
  enabled: boolean;
27
- type?: "intunedBrowser" | "patchright" | undefined;
28
35
  }>>>;
29
36
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
30
37
  projectName: z.ZodOptional<z.ZodString>;
@@ -42,15 +49,22 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
42
49
  defaultRunPlaygroundInput?: unknown;
43
50
  testAuthSessionInput?: unknown;
44
51
  }>>>;
52
+ browserSize: z.ZodCatch<z.ZodOptional<z.ZodObject<{
53
+ width: z.ZodNumber;
54
+ height: z.ZodNumber;
55
+ }, "strip", z.ZodTypeAny, {
56
+ width: number;
57
+ height: number;
58
+ }, {
59
+ width: number;
60
+ height: number;
61
+ }>>>;
45
62
  stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
46
63
  enabled: z.ZodBoolean;
47
- type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["intunedBrowser", "patchright"]>>>;
48
64
  }, "strip", z.ZodTypeAny, {
49
- type: "intunedBrowser" | "patchright";
50
65
  enabled: boolean;
51
66
  }, {
52
67
  enabled: boolean;
53
- type?: "intunedBrowser" | "patchright" | undefined;
54
68
  }>>>;
55
69
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
56
70
  projectName: z.ZodOptional<z.ZodString>;
@@ -68,15 +82,22 @@ export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
68
82
  defaultRunPlaygroundInput?: unknown;
69
83
  testAuthSessionInput?: unknown;
70
84
  }>>>;
85
+ browserSize: z.ZodCatch<z.ZodOptional<z.ZodObject<{
86
+ width: z.ZodNumber;
87
+ height: z.ZodNumber;
88
+ }, "strip", z.ZodTypeAny, {
89
+ width: number;
90
+ height: number;
91
+ }, {
92
+ width: number;
93
+ height: number;
94
+ }>>>;
71
95
  stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
72
96
  enabled: z.ZodBoolean;
73
- type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["intunedBrowser", "patchright"]>>>;
74
97
  }, "strip", z.ZodTypeAny, {
75
- type: "intunedBrowser" | "patchright";
76
98
  enabled: boolean;
77
99
  }, {
78
100
  enabled: boolean;
79
- type?: "intunedBrowser" | "patchright" | undefined;
80
101
  }>>>;
81
102
  }, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
82
103
  authSessions: z.ZodObject<{
@@ -166,7 +187,6 @@ export type IntunedJson = z.infer<typeof intunedJsonSchema>;
166
187
  export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
167
188
  export declare function loadIntunedJson(): Promise<Err<never, string> | Ok<{
168
189
  stealthMode?: {
169
- type: "intunedBrowser" | "patchright";
170
190
  enabled: boolean;
171
191
  } | undefined;
172
192
  workspaceId?: string | undefined;
@@ -176,6 +196,10 @@ export declare function loadIntunedJson(): Promise<Err<never, string> | Ok<{
176
196
  defaultRunPlaygroundInput?: Record<string, any> | undefined;
177
197
  testAuthSessionInput?: Record<string, any> | undefined;
178
198
  } | undefined;
199
+ browserSize?: {
200
+ width: number;
201
+ height: number;
202
+ } | undefined;
179
203
  } & {
180
204
  [k: string]: unknown;
181
205
  } & ({
@@ -206,7 +230,6 @@ export declare function getIntunedSettingsFile(): Promise<Ok<{
206
230
  export declare function getIntunedSettingsFileName(): Promise<Err<never, string> | Ok<"Intuned.json" | "Intuned.jsonc" | "Intuned.yaml" | "Intuned.yml" | "Intuned.toml", never>>;
207
231
  export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
208
232
  stealthMode?: {
209
- type: "intunedBrowser" | "patchright";
210
233
  enabled: boolean;
211
234
  } | undefined;
212
235
  workspaceId?: string | undefined;
@@ -216,6 +239,10 @@ export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
216
239
  defaultRunPlaygroundInput?: Record<string, any> | undefined;
217
240
  testAuthSessionInput?: Record<string, any> | undefined;
218
241
  } | undefined;
242
+ browserSize?: {
243
+ width: number;
244
+ height: number;
245
+ } | undefined;
219
246
  } & {
220
247
  [k: string]: unknown;
221
248
  } & ({
@@ -238,7 +265,10 @@ export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
238
265
  enabled: true;
239
266
  };
240
267
  }), never>;
268
+ export declare function getBrowserSizeConfig(): Promise<{
269
+ width: number;
270
+ height: number;
271
+ }>;
241
272
  export declare function getStealthModeConfig(): Promise<{
242
273
  enabled: boolean;
243
- type: "intunedBrowser" | "patchright";
244
274
  }>;
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getBrowserSizeConfig = getBrowserSizeConfig;
6
7
  exports.getIntunedSettingsFile = getIntunedSettingsFile;
7
8
  exports.getIntunedSettingsFileName = getIntunedSettingsFileName;
8
9
  exports.getStealthModeConfig = getStealthModeConfig;
@@ -19,7 +20,6 @@ var _neverthrow = require("neverthrow");
19
20
  var _formatZodError = require("./formatZodError");
20
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); }
21
22
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- const playwright = undefined;
23
23
  const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
24
24
  projectName: _zod.z.string().optional(),
25
25
  workspaceId: _zod.z.string().optional(),
@@ -28,9 +28,12 @@ const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
28
28
  defaultRunPlaygroundInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
29
29
  testAuthSessionInput: _zod.z.record(_zod.z.any()).optional().catch(undefined)
30
30
  }).optional().catch(undefined),
31
+ browserSize: _zod.z.object({
32
+ width: _zod.z.number().int().min(200).max(3840),
33
+ height: _zod.z.number().int().min(200).max(2160)
34
+ }).optional().catch(undefined),
31
35
  stealthMode: _zod.z.object({
32
- enabled: _zod.z.boolean(),
33
- type: _zod.z.enum(["intunedBrowser", "patchright"]).optional().default("patchright")
36
+ enabled: _zod.z.boolean()
34
37
  }).optional().catch(undefined)
35
38
  }).passthrough().and(_zod.z.union([_zod.z.object({
36
39
  authSessions: _zod.z.object({
@@ -132,23 +135,30 @@ function getIntunedSettingsFileSync() {
132
135
  }
133
136
  return (0, _neverthrow.err)("No Intuned settings file found.");
134
137
  }
138
+ async function getBrowserSizeConfig() {
139
+ const settingsResult = await loadIntunedJson();
140
+ if (settingsResult.isOk() && settingsResult.value.browserSize) {
141
+ return settingsResult.value.browserSize;
142
+ }
143
+ return {
144
+ width: 1024,
145
+ height: 800
146
+ };
147
+ }
135
148
  async function getStealthModeConfig() {
136
149
  try {
137
150
  const settingsResult = await loadIntunedJson();
138
151
  if (settingsResult.isErr()) {
139
152
  return {
140
- enabled: false,
141
- type: "patchright"
153
+ enabled: false
142
154
  };
143
155
  }
144
156
  return {
145
- enabled: settingsResult.value.stealthMode?.enabled === true,
146
- type: settingsResult.value.stealthMode?.type || "patchright"
157
+ enabled: settingsResult.value.stealthMode?.enabled === true
147
158
  };
148
159
  } catch {
149
160
  return {
150
- enabled: false,
151
- type: "patchright"
161
+ enabled: false
152
162
  };
153
163
  }
154
164
  }
@@ -5,6 +5,11 @@ export interface Proxy {
5
5
  username: string;
6
6
  password: string;
7
7
  }
8
+ /**
9
+ * Get ignore_http_errors setting from CLI option or environment variable.
10
+ * Priority: cliOption(true only) > environment variable > false
11
+ */
12
+ export declare function getIgnoreHttpErrorsFromConfig(cliOption?: boolean): Promise<boolean>;
8
13
  export type LaunchBrowserResult = {
9
14
  page: playwright.Page;
10
15
  context: playwright.BrowserContext;
@@ -16,6 +21,7 @@ export type LaunchChromiumStandaloneOptions = {
16
21
  cdpPort?: number;
17
22
  appModeInitialUrl?: string;
18
23
  executablePath?: string;
24
+ ignoreHttpErrors?: boolean;
19
25
  timeout?: number;
20
26
  };
21
27
  export type LaunchChromiumCdpOptions = {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getBrowserExecutablePath = getBrowserExecutablePath;
7
7
  exports.getCdpWebSocketUrl = getCdpWebSocketUrl;
8
8
  exports.getHeadlessUserAgent = getHeadlessUserAgent;
9
+ exports.getIgnoreHttpErrorsFromConfig = getIgnoreHttpErrorsFromConfig;
9
10
  exports.getLocalCdpAddress = getLocalCdpAddress;
10
11
  exports.launchBrowser = launchBrowser;
11
12
  exports.launchChromium = launchChromium;
@@ -24,6 +25,15 @@ var _intunedJson = require("./intunedJson");
24
25
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
26
  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); }
26
27
  const execAsync = (0, _util.promisify)(_child_process.exec);
28
+ function getMacKeychainBypassArgs() {
29
+ if (process.platform !== "darwin") {
30
+ return [];
31
+ }
32
+ if (process.env.INTUNED_MAC_DISABLE_KEYCHAIN_PROMPTS === "0") {
33
+ return [];
34
+ }
35
+ return ["--use-mock-keychain", "--password-store=basic"];
36
+ }
27
37
  async function createUserDirWithPreferences() {
28
38
  const playwrightTempDir = await (0, _fsExtra.mkdtemp)("/tmp/pw-");
29
39
  const userDir = (0, _path.join)(playwrightTempDir, "userdir");
@@ -34,11 +44,25 @@ async function createUserDirWithPreferences() {
34
44
  const preferences = {
35
45
  plugins: {
36
46
  always_open_pdf_externally: true
47
+ },
48
+ credentials_enable_service: false,
49
+ profile: {
50
+ password_manager_enabled: false
37
51
  }
38
52
  };
39
53
  await (0, _fsExtra.writeFile)((0, _path.join)(defaultDir, "Preferences"), JSON.stringify(preferences));
40
54
  return userDir;
41
55
  }
56
+ async function getIgnoreHttpErrorsFromConfig(cliOption) {
57
+ if (cliOption === true) {
58
+ return true;
59
+ }
60
+ const envValue = process.env.INTUNED_PLAYWRIGHT_CONTEXT_IGNORE_HTTP_ERRORS;
61
+ if (envValue !== undefined) {
62
+ return envValue.toLowerCase() === "true" || envValue === "1" || envValue.toLowerCase() === "yes";
63
+ }
64
+ return false;
65
+ }
42
66
  async function launchChromium(options) {
43
67
  if ("cdpAddress" in options) {
44
68
  if (await (0, _extensionsHelpers.isIntunedExtensionEnabled)()) {
@@ -80,15 +104,19 @@ async function launchChromium(options) {
80
104
  cdpPort,
81
105
  proxy,
82
106
  downloadsPath,
107
+ ignoreHttpErrors: ignoreHttpErrorsParam,
83
108
  timeout
84
109
  } = options;
85
110
  let {
86
111
  executablePath
87
112
  } = options;
113
+ const ignoreHttpErrors = await getIgnoreHttpErrorsFromConfig(ignoreHttpErrorsParam);
88
114
  const defaultArgsToIgnore = ["--disable-extensions", "--disable-component-extensions-with-background-pages", "--disable-background-networking", "--disable-backgrounding-occluded-windows", "--disable-background-timer-throttling"];
89
- const extraArgs = [];
115
+ const extraArgs = ["--disable-notifications"];
116
+ const macKeychainBypassArgs = getMacKeychainBypassArgs();
117
+ extraArgs.push(...macKeychainBypassArgs);
90
118
  const stealthConfig = await (0, _intunedJson.getStealthModeConfig)();
91
- if (stealthConfig.enabled && stealthConfig.type === "intunedBrowser") {
119
+ if (stealthConfig.enabled) {
92
120
  extraArgs.push("--stealth-mode");
93
121
  }
94
122
  const userDataDir = await createUserDirWithPreferences();
@@ -114,7 +142,7 @@ async function launchChromium(options) {
114
142
  if (appModeInitialUrl) {
115
143
  extraArgs.push(`--app=${appModeInitialUrl}`);
116
144
  }
117
- if (stealthConfig.enabled && stealthConfig.type === "intunedBrowser") {
145
+ if (stealthConfig.enabled) {
118
146
  const stealthExecutablePath = await getIntunedBrowserExecutablePath();
119
147
  executablePath = stealthExecutablePath;
120
148
  } else if (executablePath) {
@@ -124,9 +152,12 @@ async function launchChromium(options) {
124
152
  executablePath = undefined;
125
153
  }
126
154
  }
155
+ const browserSize = await (0, _intunedJson.getBrowserSizeConfig)();
156
+ extraArgs.push(`--window-size=${browserSize.width},${browserSize.height}`);
127
157
  const viewport = null;
128
158
  const userAgent = process.env.__PLAYWRIGHT_USER_AGENT_OVERRIDE ?? (await getHeadlessUserAgent({
129
- executablePath
159
+ executablePath,
160
+ args: macKeychainBypassArgs
130
161
  }));
131
162
  const context = await playwright.chromium.launchPersistentContext(userDataDir, {
132
163
  userAgent,
@@ -136,7 +167,8 @@ async function launchChromium(options) {
136
167
  proxy,
137
168
  downloadsPath,
138
169
  args: extraArgs,
139
- ignoreDefaultArgs: defaultArgsToIgnore
170
+ ignoreDefaultArgs: defaultArgsToIgnore,
171
+ ignoreHTTPSErrors: ignoreHttpErrors
140
172
  });
141
173
  if (timeout !== undefined) {
142
174
  context.setDefaultTimeout(timeout * 1000);
@@ -17,6 +17,7 @@ export declare function withPlaywrightContext<R>(options: {
17
17
  proxy?: Proxy;
18
18
  headless: boolean;
19
19
  downloadsPath: string;
20
+ ignoreHttpErrors?: boolean;
20
21
  } & WithPlaywrightContextParameters, fn: WithPlaywrightContextWrappedFunction<R>): Promise<Ok<R, any> | Err<any, RunAutomationError>>;
21
22
  export declare function withPlaywrightContext<R>(options: {
22
23
  cdpAddress: string;
@@ -20,6 +20,7 @@ async function withPlaywrightContext({
20
20
  proxy,
21
21
  headless = true,
22
22
  downloadsPath,
23
+ ignoreHttpErrors: cliIgnoreHttpErrors,
23
24
  importFunction,
24
25
  apiName,
25
26
  apiParameters
@@ -27,6 +28,7 @@ async function withPlaywrightContext({
27
28
  let context;
28
29
  let page;
29
30
  try {
31
+ const ignoreHttpErrors = await (0, _launchBrowser.getIgnoreHttpErrorsFromConfig)(cliIgnoreHttpErrors);
30
32
  const setupContextHookResult = importFunction ? await (0, _setupContextHook.loadSetupContextHook)({
31
33
  importFunction
32
34
  }) : (0, _neverthrow.ok)(null);
@@ -50,7 +52,8 @@ async function withPlaywrightContext({
50
52
  } = await (0, _launchBrowser.launchBrowser)({
51
53
  proxy,
52
54
  headless,
53
- downloadsPath
55
+ downloadsPath,
56
+ ignoreHttpErrors
54
57
  }));
55
58
  }
56
59
  return await fn(context, page);
@@ -76,7 +79,8 @@ async function withPlaywrightContext({
76
79
  proxy,
77
80
  headless,
78
81
  downloadsPath,
79
- cdpPort: port
82
+ cdpPort: port,
83
+ ignoreHttpErrors
80
84
  }));
81
85
  hookCdpUrl = (0, _launchBrowser.getLocalCdpAddress)(port);
82
86
  }
@@ -147,6 +147,7 @@ async function runApi({
147
147
  headless: runOptions.headless,
148
148
  proxy: runOptions.proxy,
149
149
  downloadsPath,
150
+ ignoreHttpErrors: runOptions.ignoreHttpErrors,
150
151
  ...playwrightContextParameters
151
152
  }, runAutomationWithContext);
152
153
  } finally {
@@ -8,7 +8,7 @@ var _constants = require("../common/constants");
8
8
  var _jwtTokenManager = require("../common/jwtTokenManager");
9
9
  function getAiGatewayConfig() {
10
10
  const baseUrl = `${_jwtTokenManager.backendFunctionsTokenManager.backendFunctionsBaseUrl}/intuned-ai-gateway`;
11
- const apiKey = _jwtTokenManager.backendFunctionsTokenManager.token ?? process.env[_constants.API_KEY_ENV_VAR_KEY] ?? "";
11
+ const apiKey = _jwtTokenManager.backendFunctionsTokenManager.token ?? process.env[_constants.API_KEY_ENV_VAR_KEY] ?? process.env[_constants.AUTH_TOKEN_ENV_VAR_KEY] ?? "";
12
12
  return {
13
13
  baseUrl,
14
14
  apiKey
@@ -163,7 +163,7 @@ var require_types = __commonJS({
163
163
  return mod && mod.__esModule ? mod : { "default": mod };
164
164
  };
165
165
  Object.defineProperty(exports2, "__esModule", { value: true });
166
- exports2.outputRunApiSchema = exports2.pongMessageSchema = exports2.doneMessageSchema = exports2.extendMessageSchema = exports2.runApiInputSchema = exports2.pingSchema = exports2.tokenUpdateSchema = exports2.abortRunApiSchema = exports2.startRunApiSchema = exports2.startRunApiParametersSchema = exports2.runApiParametersSchema = exports2.runApiRunOptionsSchema = exports2.runApiCdpRunOptionsSchema = exports2.runApiStandaloneRunOptionsSchema = exports2.runApiAuthSchema = exports2.runApiTracingSchema = exports2.runApiAutomationFunctionSchema = exports2.runApiSessionSchema = exports2.runApiStorageStateSchema = void 0;
166
+ exports2.outputRunApiSchema = exports2.pongMessageSchema = exports2.doneMessageSchema = exports2.extendMessageSchema = exports2.runApiInputSchema = exports2.pingSchema = exports2.tokenUpdateSchema = exports2.abortRunApiSchema = exports2.startRunApiSchema = exports2.startRunApiParametersSchema = exports2.runApiParametersSchema = exports2.runApiRunOptionsSchema = exports2.runApiCdpRunOptionsSchema = exports2.runApiStandaloneRunOptionsSchema = exports2.runApiProxySchema = exports2.runApiAuthSchema = exports2.runApiTracingSchema = exports2.runApiAutomationFunctionSchema = exports2.runApiSessionSchema = exports2.runApiStorageStateSchema = void 0;
167
167
  exports2.runApiResultOkSchema = runApiResultOkSchema;
168
168
  exports2.runApiResultWithSessionOkSchema = runApiResultWithSessionOkSchema;
169
169
  var zod_1 = __importDefault(require("zod"));
@@ -215,14 +215,16 @@ var require_types = __commonJS({
215
215
  session: exports2.runApiSessionSchema,
216
216
  parameters: zod_1.default.record(zod_1.default.any()).optional()
217
217
  }).optional();
218
+ exports2.runApiProxySchema = zod_1.default.object({
219
+ server: zod_1.default.string(),
220
+ username: zod_1.default.string(),
221
+ password: zod_1.default.string()
222
+ });
218
223
  exports2.runApiStandaloneRunOptionsSchema = zod_1.default.object({
219
224
  environment: zod_1.default.literal("standalone"),
220
225
  headless: zod_1.default.boolean().default(true),
221
- proxy: zod_1.default.object({
222
- server: zod_1.default.string(),
223
- username: zod_1.default.string(),
224
- password: zod_1.default.string()
225
- }).optional()
226
+ proxy: exports2.runApiProxySchema.optional(),
227
+ ignoreHttpErrors: zod_1.default.boolean().optional()
226
228
  });
227
229
  exports2.runApiCdpRunOptionsSchema = zod_1.default.object({
228
230
  environment: zod_1.default.literal("cdp"),
@@ -403,11 +405,7 @@ var require_interfaceClient = __commonJS({
403
405
  }
404
406
  async close() {
405
407
  this.socket.end();
406
- await Promise.race([
407
- new Promise((resolve) => this.socket.once("close", resolve)),
408
- new Promise((resolve) => this.socket.once("error", resolve)),
409
- (0, promises_1.setTimeout)(3e3)
410
- ]);
408
+ this.socket.destroy();
411
409
  }
412
410
  get closed() {
413
411
  return this.socket.closed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime",
3
- "version": "1.3.21",
3
+ "version": "1.3.23",
4
4
  "description": "Intuned runtime",
5
5
  "packageManager": "yarn@4.12.0",
6
6
  "main": "./dist/index.js",
@@ -33,7 +33,6 @@
33
33
  "intuned-auth-session-create": "vite-node ./src/commands/auth/run-create.ts",
34
34
  "intuned-auth-session-load": "vite-node ./src/commands/auth/load.ts",
35
35
  "intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
36
- "intuned": "vite-node ./src/commands/intuned-cli/main.ts",
37
36
  "intuned-get-headless-user-agent": "vite-node ./src/commands/get-headless-user-agent.ts",
38
37
  "build": "rm -rf dist && tsc -p tsconfig.json && yarn copy-dts && babel src --out-dir dist --extensions '.ts' && tsup && cp -r ./src/common/assets dist/common/assets",
39
38
  "test": "vitest run",
@@ -90,7 +89,7 @@
90
89
  "prettier": "2.8.0",
91
90
  "promptly": "3.2.0",
92
91
  "prompts": "^2.4.2",
93
- "rollup": "3.26.2",
92
+ "rollup": "3.30.0",
94
93
  "smol-toml": "^1.4.2",
95
94
  "source-map": "0.7.4",
96
95
  "terminal-kit": "^3.1.2",
@@ -101,6 +100,7 @@
101
100
  "typescript": "5.1.6",
102
101
  "uuid": "11.1.0",
103
102
  "wait-on": "7.2.0",
103
+ "which": "^6.0.1",
104
104
  "yaml": "2.8.1",
105
105
  "zod": "^3.21.4"
106
106
  },
@@ -1,7 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm info:*)"
5
- ]
6
- }
7
- }
@@ -1 +0,0 @@
1
- export declare const attemptCommand: import("commander").Command;
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.attemptCommand = void 0;
7
- var _command = require("./command");
8
- const attemptCommand = exports.attemptCommand = _command.program.command("attempt").description("Execute an Intuned attempt");
@@ -1 +0,0 @@
1
- export declare const attemptApiCommand: import("commander").Command;
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.attemptApiCommand = void 0;
7
- var _api = require("../controller/api");
8
- var _controller = require("../controller");
9
- var _zod = require("zod");
10
- var _types = require("./types");
11
- var _helpers = require("../helpers");
12
- var _attempt = require("./attempt.command");
13
- const argsSchema = _zod.z.tuple([_zod.z.string().min(1, "API name is required"), _zod.z.string().min(1, "Parameters are required")]);
14
- const optionsSchema = _types.baseCommandOptionsSchema.extend({
15
- authSession: _zod.z.string().optional(),
16
- outputFile: _zod.z.string().optional()
17
- });
18
- const attemptApiCommand = exports.attemptApiCommand = (0, _types.withBaseOptions)(_attempt.attemptCommand.command("api").description("Execute an Intuned API attempt with parameters").argument("<api-name>", "Name of the API to run").argument("<parameters>", "Path to the JSON file containing API parameters OR the parameters as a JSON string").option("-a, --auth-session <id>", "ID of the AuthSession to use for the API. This is expected to be in ./auth-sessions-instances/<id>.json").option("-o, --output-file <path>", "output file path")).action((0, _helpers.cliCommandWrapper)(argsSchema, optionsSchema, async ([apiName, parameters], {
19
- authSession,
20
- ...rest
21
- }) => {
22
- await (0, _helpers.assertAuthConsistent)(authSession);
23
- const parametersData = await (0, _controller.loadParameters)(parameters);
24
- await (0, _api.executeAttemptApiCLI)({
25
- apiName,
26
- inputData: parametersData,
27
- authSessionId: authSession,
28
- ...rest
29
- });
30
- }));
@@ -1 +0,0 @@
1
- export declare const attemptAuthSessionCommand: import("commander").Command;
@@ -1,8 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.attemptAuthSessionCommand = void 0;
7
- var _attempt = require("./attempt.command");
8
- const attemptAuthSessionCommand = exports.attemptAuthSessionCommand = _attempt.attemptCommand.command("authsession").description("Manage AuthSessions");
@@ -1 +0,0 @@
1
- export declare const attemptAuthSessionCheckCommand: import("commander").Command;