@intuned/runtime 1.3.7 → 1.3.9
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.
- package/WebTemplate.zip +0 -0
- package/dist/commands/common/utils/unixSocket.d.ts +19 -5
- package/dist/commands/common/utils/unixSocket.js +53 -10
- package/dist/commands/interface/run.js +11 -12
- package/dist/commands/intuned-cli/commands/authsession_record.command.d.ts +1 -1
- package/dist/commands/intuned-cli/commands/authsession_record.command.js +3 -2
- package/dist/commands/intuned-cli/commands/run_authsession.command.d.ts +3 -0
- package/dist/commands/intuned-cli/commands/types.d.ts +4 -0
- package/dist/commands/intuned-cli/commands/types.js +5 -3
- package/dist/commands/intuned-cli/controller/api.d.ts +1 -1
- package/dist/commands/intuned-cli/controller/api.js +4 -2
- package/dist/commands/intuned-cli/controller/authSession.d.ts +2 -2
- package/dist/commands/intuned-cli/controller/authSession.js +8 -4
- package/dist/commands/intuned-cli/controller/deploy.js +1 -1
- package/dist/commands/intuned-cli/controller/save.js +1 -1
- package/dist/commands/intuned-cli/helpers/__test__/browser.test.js +11 -0
- package/dist/commands/intuned-cli/helpers/browser.d.ts +2 -1
- package/dist/commands/intuned-cli/helpers/browser.js +8 -1
- package/dist/commands/intuned-cli/helpers/wrapper.js +2 -1
- package/package.json +1 -2
package/WebTemplate.zip
ADDED
|
Binary file
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export interface InterfaceClient {
|
|
2
|
+
sendJSON(data: any): void;
|
|
3
|
+
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
4
|
+
close(): void;
|
|
5
|
+
get closed(): boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class SocketClient implements InterfaceClient {
|
|
5
8
|
static readonly LENGTH_HEADER_LENGTH = 4;
|
|
6
|
-
|
|
9
|
+
private readonly socket;
|
|
10
|
+
constructor(socketPath: string);
|
|
11
|
+
sendJSON(data: any): void;
|
|
12
|
+
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
get closed(): boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class JSONLFileClient implements InterfaceClient {
|
|
17
|
+
private readonly fileStream;
|
|
18
|
+
constructor(filePath: string);
|
|
7
19
|
sendJSON(data: any): void;
|
|
8
20
|
receiveJSON(): AsyncGenerator<any, void, unknown>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
get closed(): boolean;
|
|
9
23
|
}
|
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.SocketClient = exports.JSONLFileClient = void 0;
|
|
7
|
+
var net = _interopRequireWildcard(require("net"));
|
|
8
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
9
|
+
var _readline = require("readline");
|
|
10
|
+
var _promises = require("timers/promises");
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
class SocketClient {
|
|
8
14
|
static LENGTH_HEADER_LENGTH = 4;
|
|
9
|
-
constructor(
|
|
10
|
-
this.socket =
|
|
15
|
+
constructor(socketPath) {
|
|
16
|
+
this.socket = net.createConnection(socketPath);
|
|
11
17
|
}
|
|
12
18
|
sendJSON(data) {
|
|
13
19
|
const dataToSend = JSON.stringify(data);
|
|
14
20
|
const length = Buffer.byteLength(dataToSend);
|
|
15
|
-
const buffer = Buffer.alloc(
|
|
21
|
+
const buffer = Buffer.alloc(SocketClient.LENGTH_HEADER_LENGTH + length);
|
|
16
22
|
buffer.writeUInt32BE(length, 0);
|
|
17
|
-
buffer.write(dataToSend,
|
|
23
|
+
buffer.write(dataToSend, SocketClient.LENGTH_HEADER_LENGTH);
|
|
18
24
|
this.socket.write(buffer);
|
|
19
25
|
}
|
|
20
26
|
async *receiveJSON() {
|
|
@@ -32,13 +38,50 @@ class JSONUnixSocket {
|
|
|
32
38
|
}
|
|
33
39
|
buffer = Buffer.concat([buffer, chunk]);
|
|
34
40
|
const length = buffer.readUInt32BE(0);
|
|
35
|
-
if (buffer.length < length +
|
|
41
|
+
if (buffer.length < length + SocketClient.LENGTH_HEADER_LENGTH) {
|
|
36
42
|
continue;
|
|
37
43
|
}
|
|
38
|
-
const data = buffer.subarray(
|
|
39
|
-
buffer = buffer.subarray(length +
|
|
44
|
+
const data = buffer.subarray(SocketClient.LENGTH_HEADER_LENGTH, length + SocketClient.LENGTH_HEADER_LENGTH);
|
|
45
|
+
buffer = buffer.subarray(length + SocketClient.LENGTH_HEADER_LENGTH);
|
|
40
46
|
yield JSON.parse(data.toString());
|
|
41
47
|
}
|
|
42
48
|
}
|
|
49
|
+
async close() {
|
|
50
|
+
this.socket.end();
|
|
51
|
+
await Promise.race([new Promise(resolve => this.socket.once("close", resolve)), new Promise(resolve => this.socket.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
|
|
52
|
+
}
|
|
53
|
+
get closed() {
|
|
54
|
+
return this.socket.closed;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.SocketClient = SocketClient;
|
|
58
|
+
class JSONLFileClient {
|
|
59
|
+
constructor(filePath) {
|
|
60
|
+
this.fileStream = fs.createReadStream(filePath, {
|
|
61
|
+
encoding: "utf-8"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
sendJSON(data) {
|
|
65
|
+
console.log("Sending message", data);
|
|
66
|
+
}
|
|
67
|
+
async *receiveJSON() {
|
|
68
|
+
const rl = (0, _readline.createInterface)({
|
|
69
|
+
input: this.fileStream,
|
|
70
|
+
crlfDelay: Infinity
|
|
71
|
+
});
|
|
72
|
+
for await (const line of rl) {
|
|
73
|
+
if (line.trim() === "") {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
yield JSON.parse(line);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async close() {
|
|
80
|
+
this.fileStream.close();
|
|
81
|
+
await Promise.race([new Promise(resolve => this.fileStream.once("close", resolve)), new Promise(resolve => this.fileStream.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
|
|
82
|
+
}
|
|
83
|
+
get closed() {
|
|
84
|
+
return this.fileStream.closed;
|
|
85
|
+
}
|
|
43
86
|
}
|
|
44
|
-
exports.
|
|
87
|
+
exports.JSONLFileClient = JSONLFileClient;
|
|
@@ -7,7 +7,6 @@ exports.runAutomationCLI = runAutomationCLI;
|
|
|
7
7
|
var _commander = require("commander");
|
|
8
8
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
9
9
|
var _asyncLocalStorage = require("../../common/asyncLocalStorage");
|
|
10
|
-
var net = _interopRequireWildcard(require("net"));
|
|
11
10
|
var _zod = _interopRequireDefault(require("zod"));
|
|
12
11
|
var _runApi = require("../../common/runApi");
|
|
13
12
|
var _enums = require("../../runtime/enums");
|
|
@@ -59,22 +58,23 @@ _dotenv.default.config({
|
|
|
59
58
|
path: `.env`
|
|
60
59
|
});
|
|
61
60
|
function runAutomationCLI(importFunction) {
|
|
62
|
-
_commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").action(async socketPath
|
|
61
|
+
_commander.program.description("run user automation and communicate using unix socket").argument("<socket-path>", "path to unix socket").option("--jsonl", "use a JSONL client instead of socket.", false).action(async (socketPath, {
|
|
62
|
+
jsonl
|
|
63
|
+
}) => {
|
|
63
64
|
let context;
|
|
64
65
|
const throttleTime = 60 * 1000;
|
|
65
66
|
let timeoutTimestamp = Date.now();
|
|
66
|
-
const client =
|
|
67
|
+
const client = jsonl ? new _unixSocket.JSONLFileClient(socketPath) : new _unixSocket.SocketClient(socketPath);
|
|
67
68
|
const abortController = new AbortController();
|
|
68
69
|
const interruptSignalHandler = async () => {
|
|
69
70
|
abortController.abort();
|
|
70
71
|
await (0, _promises.setTimeout)(60_000);
|
|
71
|
-
client.
|
|
72
|
+
await client.close();
|
|
72
73
|
process.exit(1);
|
|
73
74
|
};
|
|
74
75
|
process.on("SIGINT", interruptSignalHandler);
|
|
75
76
|
process.on("SIGTERM", interruptSignalHandler);
|
|
76
|
-
const
|
|
77
|
-
const messagesGenerator = jsonUnixSocket.receiveJSON();
|
|
77
|
+
const messagesGenerator = client.receiveJSON();
|
|
78
78
|
async function receiveMessages() {
|
|
79
79
|
const data = await messagesGenerator.next();
|
|
80
80
|
if (data.done) {
|
|
@@ -109,7 +109,7 @@ function runAutomationCLI(importFunction) {
|
|
|
109
109
|
extendTimeoutCallback: async () => {
|
|
110
110
|
if (Date.now() - timeoutTimestamp < throttleTime) return;
|
|
111
111
|
timeoutTimestamp = Date.now();
|
|
112
|
-
|
|
112
|
+
client.sendJSON({
|
|
113
113
|
type: "extend"
|
|
114
114
|
});
|
|
115
115
|
}
|
|
@@ -149,7 +149,7 @@ function runAutomationCLI(importFunction) {
|
|
|
149
149
|
break;
|
|
150
150
|
}
|
|
151
151
|
if (message.type === "error") {
|
|
152
|
-
|
|
152
|
+
client.sendJSON({
|
|
153
153
|
type: "done",
|
|
154
154
|
result: message.error.json,
|
|
155
155
|
success: false
|
|
@@ -157,7 +157,7 @@ function runAutomationCLI(importFunction) {
|
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
159
|
if (message.type === "ping") {
|
|
160
|
-
|
|
160
|
+
client.sendJSON({
|
|
161
161
|
type: "pong"
|
|
162
162
|
});
|
|
163
163
|
break;
|
|
@@ -171,7 +171,7 @@ function runAutomationCLI(importFunction) {
|
|
|
171
171
|
} = messageOrResult;
|
|
172
172
|
const success = result.isOk();
|
|
173
173
|
const resultToSend = success ? result.value : result.error.json;
|
|
174
|
-
|
|
174
|
+
client.sendJSON({
|
|
175
175
|
type: "done",
|
|
176
176
|
result: resultToSend,
|
|
177
177
|
success
|
|
@@ -179,8 +179,7 @@ function runAutomationCLI(importFunction) {
|
|
|
179
179
|
break;
|
|
180
180
|
}
|
|
181
181
|
if (!client.closed) {
|
|
182
|
-
client.
|
|
183
|
-
await Promise.race([new Promise(resolve => client.once("close", resolve)), new Promise(resolve => client.once("error", resolve)), (0, _promises.setTimeout)(3000)]);
|
|
182
|
+
await client.close();
|
|
184
183
|
}
|
|
185
184
|
process.exit(0);
|
|
186
185
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const authSessionRecordCommand: import("commander").Command;
|
|
1
|
+
export declare const authSessionRecordCommand: import("commander").Command | null;
|
|
@@ -13,7 +13,8 @@ var _types = require("./types");
|
|
|
13
13
|
const optionsSchema = _run_authsession.baseRunAuthSessionCommandOptionsSchema.extend({
|
|
14
14
|
id: _zod.z.string().optional()
|
|
15
15
|
});
|
|
16
|
-
const
|
|
16
|
+
const isAuthSessionRecorderEnabled = process.env.INTUNED_AUTH_SESSION_RECORDER_ENABLED === "true";
|
|
17
|
+
const authSessionRecordCommand = exports.authSessionRecordCommand = isAuthSessionRecorderEnabled ? (0, _types.withBaseOptions)(_authsession.authSessionCommand.command("record").description("Record a new auth session").option("--id <id>", "ID of the auth session to use for the command. Defaults to auth-session-[current timestamp]").option("--check-attempts <number>", "Number of attempts to check the auth session validity", "1")).action((0, _helpers.cliCommandWrapper)(undefined, optionsSchema, async (_, {
|
|
17
18
|
checkAttempts,
|
|
18
19
|
...rest
|
|
19
20
|
}) => {
|
|
@@ -28,4 +29,4 @@ const authSessionRecordCommand = exports.authSessionRecordCommand = (0, _types.w
|
|
|
28
29
|
finishUrl,
|
|
29
30
|
...rest
|
|
30
31
|
});
|
|
31
|
-
}));
|
|
32
|
+
})) : null;
|
|
@@ -4,6 +4,7 @@ export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodOb
|
|
|
4
4
|
headless: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
5
5
|
timeout: import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodDefault<import("zod").ZodString>, import("ms").StringValue, string | undefined>, number, string | undefined>;
|
|
6
6
|
keepBrowserOpen: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
7
|
+
cdpUrl: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
8
|
trace: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
8
9
|
checkAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
9
10
|
createAttempts: import("zod").ZodDefault<import("zod").ZodNumber>;
|
|
@@ -15,11 +16,13 @@ export declare const baseRunAuthSessionCommandOptionsSchema: import("zod").ZodOb
|
|
|
15
16
|
checkAttempts: number;
|
|
16
17
|
createAttempts: number;
|
|
17
18
|
proxy?: string | undefined;
|
|
19
|
+
cdpUrl?: string | undefined;
|
|
18
20
|
}, {
|
|
19
21
|
proxy?: string | undefined;
|
|
20
22
|
headless?: boolean | undefined;
|
|
21
23
|
timeout?: string | undefined;
|
|
22
24
|
keepBrowserOpen?: boolean | undefined;
|
|
25
|
+
cdpUrl?: string | undefined;
|
|
23
26
|
trace?: boolean | undefined;
|
|
24
27
|
checkAttempts?: number | undefined;
|
|
25
28
|
createAttempts?: number | undefined;
|
|
@@ -8,24 +8,28 @@ export declare const timeoutSchema: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.Zod
|
|
|
8
8
|
export declare const headlessSchema: z.ZodDefault<z.ZodBoolean>;
|
|
9
9
|
export declare const traceSchema: z.ZodDefault<z.ZodBoolean>;
|
|
10
10
|
export declare const keepBrowserOpenSchema: z.ZodDefault<z.ZodBoolean>;
|
|
11
|
+
export declare const cdpUrlSchema: z.ZodOptional<z.ZodString>;
|
|
11
12
|
export declare const baseCommandOptionsSchema: z.ZodObject<{
|
|
12
13
|
proxy: z.ZodOptional<z.ZodString>;
|
|
13
14
|
timeout: z.ZodEffects<z.ZodEffects<z.ZodDefault<z.ZodString>, ms.StringValue, string | undefined>, number, string | undefined>;
|
|
14
15
|
headless: z.ZodDefault<z.ZodBoolean>;
|
|
15
16
|
trace: z.ZodDefault<z.ZodBoolean>;
|
|
16
17
|
keepBrowserOpen: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
cdpUrl: z.ZodOptional<z.ZodString>;
|
|
17
19
|
}, "strip", z.ZodTypeAny, {
|
|
18
20
|
headless: boolean;
|
|
19
21
|
timeout: number;
|
|
20
22
|
keepBrowserOpen: boolean;
|
|
21
23
|
trace: boolean;
|
|
22
24
|
proxy?: string | undefined;
|
|
25
|
+
cdpUrl?: string | undefined;
|
|
23
26
|
}, {
|
|
24
27
|
proxy?: string | undefined;
|
|
25
28
|
timeout?: string | undefined;
|
|
26
29
|
headless?: boolean | undefined;
|
|
27
30
|
trace?: boolean | undefined;
|
|
28
31
|
keepBrowserOpen?: boolean | undefined;
|
|
32
|
+
cdpUrl?: string | undefined;
|
|
29
33
|
}>;
|
|
30
34
|
export type BaseCommandOptions = z.infer<typeof baseCommandOptionsSchema>;
|
|
31
35
|
export declare function withBaseOptions(command: Command): Command;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.traceSchema = exports.timeoutSchema = exports.proxySchema = exports.keepBrowserOpenSchema = exports.headlessSchema = exports.baseCommandOptionsSchema = exports.authSessionCreateAttemptsSchema = exports.authSessionCheckAttemptsSchema = void 0;
|
|
6
|
+
exports.traceSchema = exports.timeoutSchema = exports.proxySchema = exports.keepBrowserOpenSchema = exports.headlessSchema = exports.cdpUrlSchema = exports.baseCommandOptionsSchema = exports.authSessionCreateAttemptsSchema = exports.authSessionCheckAttemptsSchema = void 0;
|
|
7
7
|
exports.withBaseOptions = withBaseOptions;
|
|
8
8
|
var _ms = _interopRequireDefault(require("ms"));
|
|
9
9
|
var _zod = require("zod");
|
|
@@ -17,13 +17,15 @@ const timeoutSchema = exports.timeoutSchema = _zod.z.string().default("10 mins")
|
|
|
17
17
|
const headlessSchema = exports.headlessSchema = _zod.z.boolean().default(false);
|
|
18
18
|
const traceSchema = exports.traceSchema = _zod.z.boolean().default(false);
|
|
19
19
|
const keepBrowserOpenSchema = exports.keepBrowserOpenSchema = _zod.z.boolean().default(false);
|
|
20
|
+
const cdpUrlSchema = exports.cdpUrlSchema = _zod.z.string().url().optional();
|
|
20
21
|
const baseCommandOptionsSchema = exports.baseCommandOptionsSchema = _zod.z.object({
|
|
21
22
|
proxy: proxySchema,
|
|
22
23
|
timeout: timeoutSchema,
|
|
23
24
|
headless: headlessSchema,
|
|
24
25
|
trace: traceSchema,
|
|
25
|
-
keepBrowserOpen: keepBrowserOpenSchema
|
|
26
|
+
keepBrowserOpen: keepBrowserOpenSchema,
|
|
27
|
+
cdpUrl: cdpUrlSchema
|
|
26
28
|
});
|
|
27
29
|
function withBaseOptions(command) {
|
|
28
|
-
return command.option("--proxy <url>", "Proxy URL to use for browser").option("--timeout <time>", "Timeout for each attempt - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the attempts in a headless browser (default: false). This will not open a browser window.").option("--trace", "Capture a trace of each attempt, useful for debugging.").option("--keep-browser-open", "Keep the last browser open after the command completes, useful for debugging.");
|
|
30
|
+
return command.option("--proxy <url>", "Proxy URL to use for browser").option("--timeout <time>", "Timeout for each attempt - milliseconds or ms-formatted string", "10 mins").option("--headless", "Run the attempts in a headless browser (default: false). This will not open a browser window.").option("--trace", "Capture a trace of each attempt, useful for debugging.").option("--keep-browser-open", "Keep the last browser open after the command completes, useful for debugging.").option("--cdp-url <url>", "[Experimental] Chrome DevTools Protocol URL to connect to an existing browser instance. Disables proxy, headless, keep_browser_open options.");
|
|
29
31
|
}
|
|
@@ -29,7 +29,7 @@ declare function handleApiResult({ apiResult, outputFile, }: {
|
|
|
29
29
|
export declare const _handleApiResult: typeof handleApiResult;
|
|
30
30
|
declare function writeResultToFile(outputFile: string, result: any, payloadToAppend?: Payload[]): Promise<void>;
|
|
31
31
|
export declare const _writeResultToFile: typeof writeResultToFile;
|
|
32
|
-
declare function attemptApi({ apiName, inputData, auth, proxy, headless, timeout, traceId, keepBrowserOpen, }: {
|
|
32
|
+
declare function attemptApi({ apiName, inputData, auth, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, }: {
|
|
33
33
|
apiName: string;
|
|
34
34
|
inputData: object | null | undefined;
|
|
35
35
|
auth?: RunApiStorageState;
|
|
@@ -150,7 +150,8 @@ async function attemptApi({
|
|
|
150
150
|
headless,
|
|
151
151
|
timeout,
|
|
152
152
|
traceId,
|
|
153
|
-
keepBrowserOpen
|
|
153
|
+
keepBrowserOpen,
|
|
154
|
+
cdpUrl
|
|
154
155
|
}) {
|
|
155
156
|
return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
|
|
156
157
|
const runApiResult = await (0, _runApi.runApi)({
|
|
@@ -161,7 +162,8 @@ async function attemptApi({
|
|
|
161
162
|
runOptions: await (0, _browser.getCLIRunOptions)({
|
|
162
163
|
headless,
|
|
163
164
|
proxy,
|
|
164
|
-
keepBrowserOpen
|
|
165
|
+
keepBrowserOpen,
|
|
166
|
+
cdpUrl
|
|
165
167
|
}),
|
|
166
168
|
auth: auth ? {
|
|
167
169
|
session: {
|
|
@@ -128,12 +128,12 @@ export declare function executeAttemptCheckAuthSessionCLI({ id, ...rest }: {
|
|
|
128
128
|
origin: string;
|
|
129
129
|
}[] | undefined;
|
|
130
130
|
}>;
|
|
131
|
-
declare function runCheck({ auth, proxy, headless, timeout, traceId, keepBrowserOpen, }: {
|
|
131
|
+
declare function runCheck({ auth, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, }: {
|
|
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, }: {
|
|
136
|
+
declare function runCreate({ authSessionInput, proxy, headless, timeout, traceId, keepBrowserOpen, cdpUrl, }: {
|
|
137
137
|
authSessionInput: Record<string, any>;
|
|
138
138
|
traceId?: string;
|
|
139
139
|
} & Omit<BaseCommandOptions, "trace">): Promise<{
|
|
@@ -171,7 +171,8 @@ async function runCheck({
|
|
|
171
171
|
headless,
|
|
172
172
|
timeout,
|
|
173
173
|
traceId,
|
|
174
|
-
keepBrowserOpen
|
|
174
|
+
keepBrowserOpen,
|
|
175
|
+
cdpUrl
|
|
175
176
|
}) {
|
|
176
177
|
return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
|
|
177
178
|
const runApiResult = await (0, _runApi.runApi)({
|
|
@@ -181,7 +182,8 @@ async function runCheck({
|
|
|
181
182
|
runOptions: await (0, _browser.getCLIRunOptions)({
|
|
182
183
|
headless,
|
|
183
184
|
proxy,
|
|
184
|
-
keepBrowserOpen
|
|
185
|
+
keepBrowserOpen,
|
|
186
|
+
cdpUrl
|
|
185
187
|
}),
|
|
186
188
|
auth: {
|
|
187
189
|
session: {
|
|
@@ -210,7 +212,8 @@ async function runCreate({
|
|
|
210
212
|
headless,
|
|
211
213
|
timeout,
|
|
212
214
|
traceId,
|
|
213
|
-
keepBrowserOpen
|
|
215
|
+
keepBrowserOpen,
|
|
216
|
+
cdpUrl
|
|
214
217
|
}) {
|
|
215
218
|
return await (0, _helpers.withTimeout)(async abortSignal => (0, _helpers.withCLITrace)(async tracing => {
|
|
216
219
|
const result = await (0, _runApi.runApi)({
|
|
@@ -221,7 +224,8 @@ async function runCreate({
|
|
|
221
224
|
runOptions: await (0, _browser.getCLIRunOptions)({
|
|
222
225
|
headless,
|
|
223
226
|
proxy,
|
|
224
|
-
keepBrowserOpen
|
|
227
|
+
keepBrowserOpen,
|
|
228
|
+
cdpUrl
|
|
225
229
|
}),
|
|
226
230
|
retrieveSession: true,
|
|
227
231
|
tracing,
|
|
@@ -105,7 +105,7 @@ async function runDeployProject(projectName, auth) {
|
|
|
105
105
|
throw e;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(
|
|
108
|
+
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
|
|
109
109
|
message: "Name cannot be a UUID"
|
|
110
110
|
});
|
|
111
111
|
const checkIntunedProjectDeployStatus = async (workspaceId, projectName, apiKey) => {
|
|
@@ -112,7 +112,7 @@ ${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
|
|
|
112
112
|
(0, _terminal.terminal)(`^g^+Updated .env file with project credentials.^:\n`);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(
|
|
115
|
+
const projectNameSchema = exports.projectNameSchema = _zod.z.string().min(1, "Project Name is required").max(200, "Name must be 200 characters or less").regex(/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/, "Name can only contain lowercase letters, numbers, hyphens, and underscores in between").refine(value => !_zod.z.string().uuid().safeParse(value).success, {
|
|
116
116
|
message: "Name cannot be a UUID"
|
|
117
117
|
});
|
|
118
118
|
const validateProjectName = projectName => {
|
|
@@ -39,6 +39,17 @@ _vitest.vi.mock("../../helpers", async importOriginal => {
|
|
|
39
39
|
};
|
|
40
40
|
});
|
|
41
41
|
(0, _vitest.describe)("Browser CLI options", () => {
|
|
42
|
+
(0, _vitest.it)("returns cdp options if cdpUrl is set", async () => {
|
|
43
|
+
const options = await (0, _browser.getCLIRunOptions)({
|
|
44
|
+
keepBrowserOpen: true,
|
|
45
|
+
headless: true,
|
|
46
|
+
cdpUrl: "cdp_url"
|
|
47
|
+
});
|
|
48
|
+
(0, _vitest.expect)(options).toEqual(_vitest.expect.objectContaining({
|
|
49
|
+
environment: "cdp",
|
|
50
|
+
cdpAddress: "cdp_url"
|
|
51
|
+
}));
|
|
52
|
+
});
|
|
42
53
|
(0, _vitest.it)("returns standalone options if keepBrowserOpen is not set", async () => {
|
|
43
54
|
const options = await (0, _browser.getCLIRunOptions)({
|
|
44
55
|
keepBrowserOpen: false,
|
|
@@ -4,10 +4,11 @@ import { z } from "zod";
|
|
|
4
4
|
declare let context: BrowserContext | null;
|
|
5
5
|
export declare function _getContextForTest(): typeof context;
|
|
6
6
|
type RunApiRunOptions = z.infer<typeof runApiParametersSchema>["runOptions"];
|
|
7
|
-
export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, }: {
|
|
7
|
+
export declare function getCLIRunOptions({ headless, proxy, keepBrowserOpen, cdpUrl, }: {
|
|
8
8
|
headless: boolean;
|
|
9
9
|
proxy?: string;
|
|
10
10
|
keepBrowserOpen: boolean;
|
|
11
|
+
cdpUrl?: string;
|
|
11
12
|
}): Promise<RunApiRunOptions>;
|
|
12
13
|
export declare function isCliBrowserLaunched(): boolean;
|
|
13
14
|
export declare function closeCliBrowser(): Promise<void>;
|
|
@@ -20,11 +20,18 @@ function _getContextForTest() {
|
|
|
20
20
|
async function getCLIRunOptions({
|
|
21
21
|
headless,
|
|
22
22
|
proxy,
|
|
23
|
-
keepBrowserOpen
|
|
23
|
+
keepBrowserOpen,
|
|
24
|
+
cdpUrl
|
|
24
25
|
}) {
|
|
25
26
|
if (context) {
|
|
26
27
|
await closeCliBrowser();
|
|
27
28
|
}
|
|
29
|
+
if (cdpUrl) {
|
|
30
|
+
return {
|
|
31
|
+
environment: "cdp",
|
|
32
|
+
cdpAddress: cdpUrl
|
|
33
|
+
};
|
|
34
|
+
}
|
|
28
35
|
if (!keepBrowserOpen) {
|
|
29
36
|
return {
|
|
30
37
|
environment: "standalone",
|
|
@@ -22,7 +22,8 @@ function cliCommandWrapper(argsSchema, optionsSchema, fn) {
|
|
|
22
22
|
return (0, _validation.logInvalidInput)(parseResult);
|
|
23
23
|
}
|
|
24
24
|
const [_, parsedOptions] = parseResult.data;
|
|
25
|
-
|
|
25
|
+
const cdpUrl = "cdpUrl" in parsedOptions ? parsedOptions.cdpUrl : undefined;
|
|
26
|
+
keepBrowserOpen = !cdpUrl && "keepBrowserOpen" in parsedOptions && parsedOptions.keepBrowserOpen === true;
|
|
26
27
|
if (keepBrowserOpen) {
|
|
27
28
|
(0, _terminal.terminal)(`^+--keep-open is set, the CLI will not close the last browser after the command completes^:\n`);
|
|
28
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.9",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -71,7 +71,6 @@
|
|
|
71
71
|
"dotenv": "^16.3.1",
|
|
72
72
|
"fs-extra": "^11.3.0",
|
|
73
73
|
"image-size": "^1.1.1",
|
|
74
|
-
"inquirer": "12.6.0",
|
|
75
74
|
"jsonc-parser": "^3.3.1",
|
|
76
75
|
"jsonwebtoken": "9.0.2",
|
|
77
76
|
"lodash": "4.17.21",
|