@intuned/runtime-dev 1.3.13-ai-ootb.1 → 1.3.13-kv.1
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/intuned-cli/helpers/errors.d.ts +1 -1
- package/dist/commands/intuned-cli/helpers/errors.js +2 -2
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +139 -7
- package/dist/commands/intuned-cli/helpers/intunedJson.js +79 -12
- package/dist/common/binStartupScript.js +5 -8
- package/dist/common/constants.d.ts +0 -2
- package/dist/common/constants.js +2 -4
- package/dist/common/launchBrowser.d.ts +0 -6
- package/dist/common/launchBrowser.js +16 -39
- package/dist/common/runApi/index.js +0 -6
- package/package.json +1 -3
- package/bin/intuned-get-headless-user-agent +0 -4
- package/dist/commands/get-headless-user-agent.d.ts +0 -1
- package/dist/commands/get-headless-user-agent.js +0 -18
- package/dist/common/intunedJson.d.ts +0 -229
- package/dist/common/intunedJson.js +0 -133
- package/dist/runtime/persistentStore.test.js +0 -101
package/WebTemplate.zip
ADDED
|
Binary file
|
|
@@ -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
|
|
8
|
+
var _runApi = require("../../../common/runApi");
|
|
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
|
|
34
|
+
if (error instanceof _runApi.AutomationError) {
|
|
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,4 +1,139 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
|
|
3
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
4
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
5
|
+
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
7
|
+
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
8
|
+
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
11
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
12
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
defaultJobInput?: unknown;
|
|
15
|
+
defaultRunPlaygroundInput?: unknown;
|
|
16
|
+
testAuthSessionInput?: unknown;
|
|
17
|
+
}>>>;
|
|
18
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
19
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
20
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
21
|
+
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
22
|
+
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
23
|
+
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
24
|
+
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
27
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
28
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
defaultJobInput?: unknown;
|
|
31
|
+
defaultRunPlaygroundInput?: unknown;
|
|
32
|
+
testAuthSessionInput?: unknown;
|
|
33
|
+
}>>>;
|
|
34
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
35
|
+
projectName: z.ZodOptional<z.ZodString>;
|
|
36
|
+
workspaceId: z.ZodOptional<z.ZodString>;
|
|
37
|
+
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
38
|
+
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
39
|
+
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
40
|
+
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
defaultJobInput?: Record<string, any> | undefined;
|
|
43
|
+
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
44
|
+
testAuthSessionInput?: Record<string, any> | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
defaultJobInput?: unknown;
|
|
47
|
+
defaultRunPlaygroundInput?: unknown;
|
|
48
|
+
testAuthSessionInput?: unknown;
|
|
49
|
+
}>>>;
|
|
50
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
|
|
51
|
+
authSessions: z.ZodObject<{
|
|
52
|
+
enabled: z.ZodLiteral<false>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
enabled: false;
|
|
55
|
+
}, {
|
|
56
|
+
enabled: false;
|
|
57
|
+
}>;
|
|
58
|
+
apiAccess: z.ZodObject<{
|
|
59
|
+
enabled: z.ZodLiteral<false>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
enabled: false;
|
|
62
|
+
}, {
|
|
63
|
+
enabled: false;
|
|
64
|
+
}>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
authSessions: {
|
|
67
|
+
enabled: false;
|
|
68
|
+
};
|
|
69
|
+
apiAccess: {
|
|
70
|
+
enabled: false;
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
authSessions: {
|
|
74
|
+
enabled: false;
|
|
75
|
+
};
|
|
76
|
+
apiAccess: {
|
|
77
|
+
enabled: false;
|
|
78
|
+
};
|
|
79
|
+
}>, z.ZodObject<{
|
|
80
|
+
authSessions: z.ZodUnion<[z.ZodObject<{
|
|
81
|
+
enabled: z.ZodLiteral<false>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
enabled: false;
|
|
84
|
+
}, {
|
|
85
|
+
enabled: false;
|
|
86
|
+
}>, z.ZodObject<{
|
|
87
|
+
enabled: z.ZodLiteral<true>;
|
|
88
|
+
type: z.ZodEnum<["MANUAL", "API"]>;
|
|
89
|
+
startUrl: z.ZodOptional<z.ZodString>;
|
|
90
|
+
finishUrl: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
type: "API" | "MANUAL";
|
|
93
|
+
enabled: true;
|
|
94
|
+
startUrl?: string | undefined;
|
|
95
|
+
finishUrl?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
type: "API" | "MANUAL";
|
|
98
|
+
enabled: true;
|
|
99
|
+
startUrl?: string | undefined;
|
|
100
|
+
finishUrl?: string | undefined;
|
|
101
|
+
}>]>;
|
|
102
|
+
apiAccess: z.ZodObject<{
|
|
103
|
+
enabled: z.ZodLiteral<true>;
|
|
104
|
+
}, "strip", z.ZodTypeAny, {
|
|
105
|
+
enabled: true;
|
|
106
|
+
}, {
|
|
107
|
+
enabled: true;
|
|
108
|
+
}>;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
authSessions: {
|
|
111
|
+
enabled: false;
|
|
112
|
+
} | {
|
|
113
|
+
type: "API" | "MANUAL";
|
|
114
|
+
enabled: true;
|
|
115
|
+
startUrl?: string | undefined;
|
|
116
|
+
finishUrl?: string | undefined;
|
|
117
|
+
};
|
|
118
|
+
apiAccess: {
|
|
119
|
+
enabled: true;
|
|
120
|
+
};
|
|
121
|
+
}, {
|
|
122
|
+
authSessions: {
|
|
123
|
+
enabled: false;
|
|
124
|
+
} | {
|
|
125
|
+
type: "API" | "MANUAL";
|
|
126
|
+
enabled: true;
|
|
127
|
+
startUrl?: string | undefined;
|
|
128
|
+
finishUrl?: string | undefined;
|
|
129
|
+
};
|
|
130
|
+
apiAccess: {
|
|
131
|
+
enabled: true;
|
|
132
|
+
};
|
|
133
|
+
}>]>>;
|
|
134
|
+
export type IntunedJson = z.infer<typeof intunedJsonSchema>;
|
|
135
|
+
export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
136
|
+
export declare function loadIntunedJson(): Promise<{
|
|
2
137
|
projectName?: string | undefined;
|
|
3
138
|
workspaceId?: string | undefined;
|
|
4
139
|
metadata?: {
|
|
@@ -6,9 +141,6 @@ export declare const loadIntunedJson: () => Promise<{
|
|
|
6
141
|
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
7
142
|
testAuthSessionInput?: Record<string, any> | undefined;
|
|
8
143
|
} | undefined;
|
|
9
|
-
stealthMode?: {
|
|
10
|
-
enabled: boolean;
|
|
11
|
-
} | undefined;
|
|
12
144
|
} & {
|
|
13
145
|
[k: string]: unknown;
|
|
14
146
|
} & ({
|
|
@@ -31,9 +163,9 @@ export declare const loadIntunedJson: () => Promise<{
|
|
|
31
163
|
enabled: true;
|
|
32
164
|
};
|
|
33
165
|
})>;
|
|
34
|
-
export declare
|
|
35
|
-
name:
|
|
166
|
+
export declare function getIntunedSettingsFile(): Promise<{
|
|
167
|
+
name: typeof intunedSettingsFileNames[number];
|
|
36
168
|
path: string;
|
|
37
169
|
parse: (content: string) => any;
|
|
38
170
|
}>;
|
|
39
|
-
export declare
|
|
171
|
+
export declare function getIntunedSettingsFileName(): Promise<string>;
|
|
@@ -3,18 +3,85 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getIntunedSettingsFile = getIntunedSettingsFile;
|
|
7
|
+
exports.getIntunedSettingsFileName = getIntunedSettingsFileName;
|
|
8
|
+
exports.intunedSettingsFileNames = exports.intunedJsonSchema = void 0;
|
|
9
|
+
exports.loadIntunedJson = loadIntunedJson;
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
12
|
+
var _zod = require("zod");
|
|
7
13
|
var _errors = require("./errors");
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
var JSONC = _interopRequireWildcard(require("jsonc-parser"));
|
|
15
|
+
var YAML = _interopRequireWildcard(require("yaml"));
|
|
16
|
+
var TOML = _interopRequireWildcard(require("smol-toml"));
|
|
17
|
+
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); }
|
|
18
|
+
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; }
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
|
+
const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
21
|
+
projectName: _zod.z.string().optional(),
|
|
22
|
+
workspaceId: _zod.z.string().optional(),
|
|
23
|
+
metadata: _zod.z.object({
|
|
24
|
+
defaultJobInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
25
|
+
defaultRunPlaygroundInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
26
|
+
testAuthSessionInput: _zod.z.record(_zod.z.any()).optional().catch(undefined)
|
|
27
|
+
}).optional().catch(undefined)
|
|
28
|
+
}).passthrough().and(_zod.z.union([_zod.z.object({
|
|
29
|
+
authSessions: _zod.z.object({
|
|
30
|
+
enabled: _zod.z.literal(false)
|
|
31
|
+
}),
|
|
32
|
+
apiAccess: _zod.z.object({
|
|
33
|
+
enabled: _zod.z.literal(false)
|
|
34
|
+
})
|
|
35
|
+
}), _zod.z.object({
|
|
36
|
+
authSessions: _zod.z.union([_zod.z.object({
|
|
37
|
+
enabled: _zod.z.literal(false)
|
|
38
|
+
}), _zod.z.object({
|
|
39
|
+
enabled: _zod.z.literal(true),
|
|
40
|
+
type: _zod.z.enum(["MANUAL", "API"]),
|
|
41
|
+
startUrl: _zod.z.string().optional(),
|
|
42
|
+
finishUrl: _zod.z.string().optional()
|
|
43
|
+
})]),
|
|
44
|
+
apiAccess: _zod.z.object({
|
|
45
|
+
enabled: _zod.z.literal(true)
|
|
46
|
+
})
|
|
47
|
+
})]));
|
|
48
|
+
const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
49
|
+
async function loadIntunedJson() {
|
|
50
|
+
const settingsFile = await getIntunedSettingsFile();
|
|
51
|
+
const intunedJsonContent = await fs.readFile(settingsFile.path, "utf-8");
|
|
52
|
+
let intunedJson;
|
|
53
|
+
try {
|
|
54
|
+
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
throw new _errors.CLIError(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
57
|
+
}
|
|
58
|
+
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
59
|
+
if (!parseResult.success) {
|
|
60
|
+
const formattedError = parseResult.error.errors.map(e => `- ${e.path.join(".")}: ${e.message}`).join("\n");
|
|
61
|
+
throw new _errors.CLIError(`${settingsFile.name} is not valid:\n${formattedError}\nPlease fix the errors and try again.`);
|
|
62
|
+
}
|
|
63
|
+
return parseResult.data;
|
|
64
|
+
}
|
|
65
|
+
const intunedSettingsParsers = {
|
|
66
|
+
"Intuned.json": JSON.parse,
|
|
67
|
+
"Intuned.jsonc": JSONC.parse,
|
|
68
|
+
"Intuned.yaml": YAML.parse,
|
|
69
|
+
"Intuned.yml": YAML.parse,
|
|
70
|
+
"Intuned.toml": TOML.parse
|
|
71
|
+
};
|
|
72
|
+
async function getIntunedSettingsFile() {
|
|
73
|
+
for (const fileName of intunedSettingsFileNames) {
|
|
74
|
+
const filePath = _path.default.join(process.cwd(), fileName);
|
|
75
|
+
if (await fs.exists(filePath)) {
|
|
76
|
+
return {
|
|
77
|
+
name: fileName,
|
|
78
|
+
path: filePath,
|
|
79
|
+
parse: intunedSettingsParsers[fileName]
|
|
80
|
+
};
|
|
14
81
|
}
|
|
15
|
-
|
|
16
|
-
|
|
82
|
+
}
|
|
83
|
+
throw new _errors.CLIError(`No Intuned settings file found.`);
|
|
17
84
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
85
|
+
async function getIntunedSettingsFileName() {
|
|
86
|
+
return (await getIntunedSettingsFile()).name;
|
|
87
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
4
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
4
5
|
var path = _interopRequireWildcard(require("path"));
|
|
5
|
-
var _intunedJson = require("./intunedJson");
|
|
6
6
|
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); }
|
|
7
7
|
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
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -11,13 +11,10 @@ _dotenv.default.config({
|
|
|
11
11
|
});
|
|
12
12
|
function isStealthModeEnabled() {
|
|
13
13
|
try {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return settingsResult.value.stealthMode?.enabled === true;
|
|
14
|
+
const intunedConfigPath = path.resolve(process.cwd(), process.env.ROOT || "./", "Intuned.json");
|
|
15
|
+
const configContent = fs.readFileSync(intunedConfigPath, "utf8");
|
|
16
|
+
const config = JSON.parse(configContent);
|
|
17
|
+
return config.stealthMode?.enabled === true;
|
|
21
18
|
} catch (error) {
|
|
22
19
|
console.error("Error reading Intuned.json:", error.message);
|
|
23
20
|
return false;
|
|
@@ -8,5 +8,3 @@ export declare const API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
|
8
8
|
export declare const API_KEY_HEADER_NAME = "x-api-key";
|
|
9
9
|
export declare const API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
10
10
|
export declare const CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
11
|
-
export declare const INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = "INTUNED_AI_GATEWAY_BASE_URL";
|
|
12
|
-
export declare const INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = "INTUNED_AI_GATEWAY_API_KEY";
|
package/dist/common/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WORKSPACE_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = exports.
|
|
6
|
+
exports.WORKSPACE_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = exports.EXTENSION_PATH_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = exports.API_KEY_HEADER_NAME = exports.API_KEY_ENV_VAR_KEY = exports.API_FOLDER_NAME = exports.API_BASE_URL_ENV_VAR_KEY = void 0;
|
|
7
7
|
const API_FOLDER_NAME = exports.API_FOLDER_NAME = "api";
|
|
8
8
|
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
9
9
|
const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|
|
@@ -13,6 +13,4 @@ const PROJECT_ID_ENV_VAR_KEY = exports.PROJECT_ID_ENV_VAR_KEY = "INTUNED_PROJECT
|
|
|
13
13
|
const API_KEY_ENV_VAR_KEY = exports.API_KEY_ENV_VAR_KEY = "INTUNED_API_KEY";
|
|
14
14
|
const API_KEY_HEADER_NAME = exports.API_KEY_HEADER_NAME = "x-api-key";
|
|
15
15
|
const API_BASE_URL_ENV_VAR_KEY = exports.API_BASE_URL_ENV_VAR_KEY = "INTUNED_API_BASE_URL";
|
|
16
|
-
const CLI_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
17
|
-
const INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = exports.INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR = "INTUNED_AI_GATEWAY_BASE_URL";
|
|
18
|
-
const INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = exports.INTUNED_AI_GATEWAY_API_KEY_ENV_VAR = "INTUNED_AI_GATEWAY_API_KEY";
|
|
16
|
+
const CLI_ENV_VAR_KEY = exports.CLI_ENV_VAR_KEY = "INTUNED_CLI";
|
|
@@ -21,11 +21,5 @@ export type LaunchChromiumCdpOptions = {
|
|
|
21
21
|
};
|
|
22
22
|
export declare function launchChromium(options: LaunchChromiumStandaloneOptions): Promise<LaunchBrowserResult>;
|
|
23
23
|
export declare function launchChromium(options: LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
|
|
24
|
-
export declare function getBrowserExecutablePath(): Promise<string | undefined>;
|
|
25
24
|
export declare function launchBrowser(options: Omit<LaunchChromiumStandaloneOptions, "executablePath"> | LaunchChromiumCdpOptions): Promise<LaunchBrowserResult>;
|
|
26
25
|
export declare function getLocalCdpAddress(port: number): string;
|
|
27
|
-
export declare function getHeadlessUserAgent({ executablePath, args, ignoreDefaultArgs, }: {
|
|
28
|
-
executablePath?: string;
|
|
29
|
-
args?: string[];
|
|
30
|
-
ignoreDefaultArgs?: string[];
|
|
31
|
-
}): Promise<string | undefined>;
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getBrowserExecutablePath = getBrowserExecutablePath;
|
|
7
|
-
exports.getHeadlessUserAgent = getHeadlessUserAgent;
|
|
8
6
|
exports.getLocalCdpAddress = getLocalCdpAddress;
|
|
9
7
|
exports.launchBrowser = launchBrowser;
|
|
10
8
|
exports.launchChromium = launchChromium;
|
|
@@ -88,15 +86,10 @@ async function launchChromium(options) {
|
|
|
88
86
|
executablePath = undefined;
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
|
-
const viewport = null;
|
|
92
|
-
const userAgent = process.env.__PLAYWRIGHT_USER_AGENT_OVERRIDE ?? (await getHeadlessUserAgent({
|
|
93
|
-
executablePath
|
|
94
|
-
}));
|
|
95
89
|
const context = await playwright.chromium.launchPersistentContext(userDataDir, {
|
|
96
|
-
userAgent,
|
|
97
90
|
executablePath,
|
|
98
91
|
headless,
|
|
99
|
-
viewport,
|
|
92
|
+
viewport: null,
|
|
100
93
|
proxy,
|
|
101
94
|
downloadsPath,
|
|
102
95
|
args: extraArgs,
|
|
@@ -127,20 +120,25 @@ async function launchChromium(options) {
|
|
|
127
120
|
context
|
|
128
121
|
};
|
|
129
122
|
}
|
|
130
|
-
async function getBrowserExecutablePath() {
|
|
131
|
-
const browserType = getBrowserType();
|
|
132
|
-
if (browserType === "brave") {
|
|
133
|
-
return await getBraveExecutablePath();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
123
|
async function launchBrowser(options) {
|
|
137
124
|
if ("cdpAddress" in options) {
|
|
138
125
|
return launchChromium(options);
|
|
139
126
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
127
|
+
const browserType = getBrowserType();
|
|
128
|
+
switch (browserType) {
|
|
129
|
+
case "chromium":
|
|
130
|
+
{
|
|
131
|
+
return launchChromium(options);
|
|
132
|
+
}
|
|
133
|
+
case "brave":
|
|
134
|
+
{
|
|
135
|
+
const braveExecutablePath = await getBraveExecutablePath();
|
|
136
|
+
return launchChromium({
|
|
137
|
+
...options,
|
|
138
|
+
executablePath: braveExecutablePath
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
144
142
|
}
|
|
145
143
|
function getBrowserType() {
|
|
146
144
|
if (process.env.BROWSER_TYPE === "brave") {
|
|
@@ -171,25 +169,4 @@ async function waitOnCdpAddress(cdpAddress) {
|
|
|
171
169
|
tcpTimeout: 1000,
|
|
172
170
|
window: 1000
|
|
173
171
|
});
|
|
174
|
-
}
|
|
175
|
-
async function getHeadlessUserAgent({
|
|
176
|
-
executablePath,
|
|
177
|
-
args,
|
|
178
|
-
ignoreDefaultArgs
|
|
179
|
-
}) {
|
|
180
|
-
const browser = await playwright.chromium.launch({
|
|
181
|
-
headless: true,
|
|
182
|
-
executablePath,
|
|
183
|
-
args,
|
|
184
|
-
ignoreDefaultArgs
|
|
185
|
-
});
|
|
186
|
-
const context = await browser.newContext();
|
|
187
|
-
const page = await context.newPage();
|
|
188
|
-
let userAgent = await page.evaluate(() => navigator.userAgent);
|
|
189
|
-
await browser.close();
|
|
190
|
-
if (!userAgent || typeof userAgent !== "string") {
|
|
191
|
-
return undefined;
|
|
192
|
-
}
|
|
193
|
-
userAgent = userAgent.replace("HeadlessChrome", "Chrome");
|
|
194
|
-
return userAgent;
|
|
195
172
|
}
|
|
@@ -44,7 +44,6 @@ Object.keys(_types).forEach(function (key) {
|
|
|
44
44
|
var _formatZodError = require("../formatZodError");
|
|
45
45
|
var _cleanEnvironmentVariables = require("../cleanEnvironmentVariables");
|
|
46
46
|
var _importUsingImportFunction = require("./importUsingImportFunction");
|
|
47
|
-
var _jwtTokenManager = require("../jwtTokenManager");
|
|
48
47
|
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); }
|
|
49
48
|
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; }
|
|
50
49
|
function getObjectSizeInBytes(obj) {
|
|
@@ -54,10 +53,6 @@ function getObjectSizeInBytes(obj) {
|
|
|
54
53
|
return new TextEncoder().encode(String(obj)).length;
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
|
-
function injectRuntimeEnvVars() {
|
|
58
|
-
process.env[_constants.INTUNED_AI_GATEWAY_BASE_URL_ENV_VAR] = `${_jwtTokenManager.backendFunctionsTokenManager.backendFunctionsBaseUrl}/intuned-ai-gateway`;
|
|
59
|
-
process.env[_constants.INTUNED_AI_GATEWAY_API_KEY_ENV_VAR] = _jwtTokenManager.backendFunctionsTokenManager.token ?? process.env[_constants.API_KEY_ENV_VAR_KEY];
|
|
60
|
-
}
|
|
61
56
|
async function runApi({
|
|
62
57
|
abortSignal,
|
|
63
58
|
importFunction,
|
|
@@ -85,7 +80,6 @@ async function runApi({
|
|
|
85
80
|
resolve(abortSymbol);
|
|
86
81
|
});
|
|
87
82
|
});
|
|
88
|
-
injectRuntimeEnvVars();
|
|
89
83
|
async function runAutomation() {
|
|
90
84
|
const validatedModuleResult = await (0, _importUsingImportFunction.importUsingImportFunction)({
|
|
91
85
|
path: name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime-dev",
|
|
3
|
-
"version": "1.3.13-
|
|
3
|
+
"version": "1.3.13-kv.1",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"intuned-auth-session-load": "vite-node ./src/commands/auth/load.ts",
|
|
31
31
|
"intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
|
|
32
32
|
"intuned": "vite-node ./src/commands/intuned-cli/main.ts",
|
|
33
|
-
"intuned-get-headless-user-agent": "vite-node ./src/commands/get-headless-user-agent.ts",
|
|
34
33
|
"build": "rm -rf dist && tsc -p tsconfig.json && yarn copy-dts && babel src --out-dir dist --extensions '.ts' && cp -r ./src/common/assets dist/common/assets",
|
|
35
34
|
"test": "vitest run",
|
|
36
35
|
"test:watch": "vitest",
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
"intuned-browser-start": "bin/intuned-browser-start",
|
|
52
51
|
"intuned-browser-save-state": "bin/intuned-browser-save-state",
|
|
53
52
|
"intuned-ts-check": "bin/intuned-ts-check",
|
|
54
|
-
"intuned-get-headless-user-agent": "bin/intuned-get-headless-user-agent",
|
|
55
53
|
"intuned": "bin/intuned"
|
|
56
54
|
},
|
|
57
55
|
"dependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _commander = require("commander");
|
|
4
|
-
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
5
|
-
var _launchBrowser = require("../common/launchBrowser");
|
|
6
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
_dotenv.default.config();
|
|
8
|
-
_commander.program.description("get headless user agent").action(async () => {
|
|
9
|
-
try {
|
|
10
|
-
console.log(await (0, _launchBrowser.getHeadlessUserAgent)({
|
|
11
|
-
executablePath: await (0, _launchBrowser.getBrowserExecutablePath)()
|
|
12
|
-
}));
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.error("Error getting headless user agent:", error);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
_commander.program.parse(process.argv);
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { type Err, type Ok } from "neverthrow";
|
|
3
|
-
export declare const intunedJsonSchema: z.ZodIntersection<z.ZodObject<{
|
|
4
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
5
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
6
|
-
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
7
|
-
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
8
|
-
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
9
|
-
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
defaultJobInput?: Record<string, any> | undefined;
|
|
12
|
-
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
13
|
-
testAuthSessionInput?: Record<string, any> | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
defaultJobInput?: unknown;
|
|
16
|
-
defaultRunPlaygroundInput?: unknown;
|
|
17
|
-
testAuthSessionInput?: unknown;
|
|
18
|
-
}>>>;
|
|
19
|
-
stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
20
|
-
enabled: z.ZodBoolean;
|
|
21
|
-
}, "strip", z.ZodTypeAny, {
|
|
22
|
-
enabled: boolean;
|
|
23
|
-
}, {
|
|
24
|
-
enabled: boolean;
|
|
25
|
-
}>>>;
|
|
26
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
27
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
28
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
29
|
-
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
30
|
-
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
31
|
-
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
32
|
-
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
defaultJobInput?: Record<string, any> | undefined;
|
|
35
|
-
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
36
|
-
testAuthSessionInput?: Record<string, any> | undefined;
|
|
37
|
-
}, {
|
|
38
|
-
defaultJobInput?: unknown;
|
|
39
|
-
defaultRunPlaygroundInput?: unknown;
|
|
40
|
-
testAuthSessionInput?: unknown;
|
|
41
|
-
}>>>;
|
|
42
|
-
stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
43
|
-
enabled: z.ZodBoolean;
|
|
44
|
-
}, "strip", z.ZodTypeAny, {
|
|
45
|
-
enabled: boolean;
|
|
46
|
-
}, {
|
|
47
|
-
enabled: boolean;
|
|
48
|
-
}>>>;
|
|
49
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
50
|
-
projectName: z.ZodOptional<z.ZodString>;
|
|
51
|
-
workspaceId: z.ZodOptional<z.ZodString>;
|
|
52
|
-
metadata: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
53
|
-
defaultJobInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
54
|
-
defaultRunPlaygroundInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
55
|
-
testAuthSessionInput: z.ZodCatch<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
56
|
-
}, "strip", z.ZodTypeAny, {
|
|
57
|
-
defaultJobInput?: Record<string, any> | undefined;
|
|
58
|
-
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
59
|
-
testAuthSessionInput?: Record<string, any> | undefined;
|
|
60
|
-
}, {
|
|
61
|
-
defaultJobInput?: unknown;
|
|
62
|
-
defaultRunPlaygroundInput?: unknown;
|
|
63
|
-
testAuthSessionInput?: unknown;
|
|
64
|
-
}>>>;
|
|
65
|
-
stealthMode: z.ZodCatch<z.ZodOptional<z.ZodObject<{
|
|
66
|
-
enabled: z.ZodBoolean;
|
|
67
|
-
}, "strip", z.ZodTypeAny, {
|
|
68
|
-
enabled: boolean;
|
|
69
|
-
}, {
|
|
70
|
-
enabled: boolean;
|
|
71
|
-
}>>>;
|
|
72
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodUnion<[z.ZodObject<{
|
|
73
|
-
authSessions: z.ZodObject<{
|
|
74
|
-
enabled: z.ZodLiteral<false>;
|
|
75
|
-
}, "strip", z.ZodTypeAny, {
|
|
76
|
-
enabled: false;
|
|
77
|
-
}, {
|
|
78
|
-
enabled: false;
|
|
79
|
-
}>;
|
|
80
|
-
apiAccess: z.ZodObject<{
|
|
81
|
-
enabled: z.ZodLiteral<false>;
|
|
82
|
-
}, "strip", z.ZodTypeAny, {
|
|
83
|
-
enabled: false;
|
|
84
|
-
}, {
|
|
85
|
-
enabled: false;
|
|
86
|
-
}>;
|
|
87
|
-
}, "strip", z.ZodTypeAny, {
|
|
88
|
-
authSessions: {
|
|
89
|
-
enabled: false;
|
|
90
|
-
};
|
|
91
|
-
apiAccess: {
|
|
92
|
-
enabled: false;
|
|
93
|
-
};
|
|
94
|
-
}, {
|
|
95
|
-
authSessions: {
|
|
96
|
-
enabled: false;
|
|
97
|
-
};
|
|
98
|
-
apiAccess: {
|
|
99
|
-
enabled: false;
|
|
100
|
-
};
|
|
101
|
-
}>, z.ZodObject<{
|
|
102
|
-
authSessions: z.ZodUnion<[z.ZodObject<{
|
|
103
|
-
enabled: z.ZodLiteral<false>;
|
|
104
|
-
}, "strip", z.ZodTypeAny, {
|
|
105
|
-
enabled: false;
|
|
106
|
-
}, {
|
|
107
|
-
enabled: false;
|
|
108
|
-
}>, z.ZodObject<{
|
|
109
|
-
enabled: z.ZodLiteral<true>;
|
|
110
|
-
type: z.ZodEnum<["MANUAL", "API"]>;
|
|
111
|
-
startUrl: z.ZodOptional<z.ZodString>;
|
|
112
|
-
finishUrl: z.ZodOptional<z.ZodString>;
|
|
113
|
-
}, "strip", z.ZodTypeAny, {
|
|
114
|
-
type: "API" | "MANUAL";
|
|
115
|
-
enabled: true;
|
|
116
|
-
startUrl?: string | undefined;
|
|
117
|
-
finishUrl?: string | undefined;
|
|
118
|
-
}, {
|
|
119
|
-
type: "API" | "MANUAL";
|
|
120
|
-
enabled: true;
|
|
121
|
-
startUrl?: string | undefined;
|
|
122
|
-
finishUrl?: string | undefined;
|
|
123
|
-
}>]>;
|
|
124
|
-
apiAccess: z.ZodObject<{
|
|
125
|
-
enabled: z.ZodLiteral<true>;
|
|
126
|
-
}, "strip", z.ZodTypeAny, {
|
|
127
|
-
enabled: true;
|
|
128
|
-
}, {
|
|
129
|
-
enabled: true;
|
|
130
|
-
}>;
|
|
131
|
-
}, "strip", z.ZodTypeAny, {
|
|
132
|
-
authSessions: {
|
|
133
|
-
enabled: false;
|
|
134
|
-
} | {
|
|
135
|
-
type: "API" | "MANUAL";
|
|
136
|
-
enabled: true;
|
|
137
|
-
startUrl?: string | undefined;
|
|
138
|
-
finishUrl?: string | undefined;
|
|
139
|
-
};
|
|
140
|
-
apiAccess: {
|
|
141
|
-
enabled: true;
|
|
142
|
-
};
|
|
143
|
-
}, {
|
|
144
|
-
authSessions: {
|
|
145
|
-
enabled: false;
|
|
146
|
-
} | {
|
|
147
|
-
type: "API" | "MANUAL";
|
|
148
|
-
enabled: true;
|
|
149
|
-
startUrl?: string | undefined;
|
|
150
|
-
finishUrl?: string | undefined;
|
|
151
|
-
};
|
|
152
|
-
apiAccess: {
|
|
153
|
-
enabled: true;
|
|
154
|
-
};
|
|
155
|
-
}>]>>;
|
|
156
|
-
export type IntunedJson = z.infer<typeof intunedJsonSchema>;
|
|
157
|
-
export declare const intunedSettingsFileNames: readonly ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
158
|
-
export declare function loadIntunedJson(): Promise<Err<never, string> | Ok<{
|
|
159
|
-
projectName?: string | undefined;
|
|
160
|
-
workspaceId?: string | undefined;
|
|
161
|
-
metadata?: {
|
|
162
|
-
defaultJobInput?: Record<string, any> | undefined;
|
|
163
|
-
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
164
|
-
testAuthSessionInput?: Record<string, any> | undefined;
|
|
165
|
-
} | undefined;
|
|
166
|
-
stealthMode?: {
|
|
167
|
-
enabled: boolean;
|
|
168
|
-
} | undefined;
|
|
169
|
-
} & {
|
|
170
|
-
[k: string]: unknown;
|
|
171
|
-
} & ({
|
|
172
|
-
authSessions: {
|
|
173
|
-
enabled: false;
|
|
174
|
-
};
|
|
175
|
-
apiAccess: {
|
|
176
|
-
enabled: false;
|
|
177
|
-
};
|
|
178
|
-
} | {
|
|
179
|
-
authSessions: {
|
|
180
|
-
enabled: false;
|
|
181
|
-
} | {
|
|
182
|
-
type: "API" | "MANUAL";
|
|
183
|
-
enabled: true;
|
|
184
|
-
startUrl?: string | undefined;
|
|
185
|
-
finishUrl?: string | undefined;
|
|
186
|
-
};
|
|
187
|
-
apiAccess: {
|
|
188
|
-
enabled: true;
|
|
189
|
-
};
|
|
190
|
-
}), never>>;
|
|
191
|
-
export declare function getIntunedSettingsFile(): Promise<Ok<{
|
|
192
|
-
name: typeof intunedSettingsFileNames[number];
|
|
193
|
-
path: string;
|
|
194
|
-
parse: (content: string) => any;
|
|
195
|
-
}, never> | Err<never, string>>;
|
|
196
|
-
export declare function getIntunedSettingsFileName(): Promise<Err<never, string> | Ok<"Intuned.json" | "Intuned.jsonc" | "Intuned.yaml" | "Intuned.yml" | "Intuned.toml", never>>;
|
|
197
|
-
export declare function loadIntunedJsonSync(): Err<never, string> | Ok<{
|
|
198
|
-
projectName?: string | undefined;
|
|
199
|
-
workspaceId?: string | undefined;
|
|
200
|
-
metadata?: {
|
|
201
|
-
defaultJobInput?: Record<string, any> | undefined;
|
|
202
|
-
defaultRunPlaygroundInput?: Record<string, any> | undefined;
|
|
203
|
-
testAuthSessionInput?: Record<string, any> | undefined;
|
|
204
|
-
} | undefined;
|
|
205
|
-
stealthMode?: {
|
|
206
|
-
enabled: boolean;
|
|
207
|
-
} | undefined;
|
|
208
|
-
} & {
|
|
209
|
-
[k: string]: unknown;
|
|
210
|
-
} & ({
|
|
211
|
-
authSessions: {
|
|
212
|
-
enabled: false;
|
|
213
|
-
};
|
|
214
|
-
apiAccess: {
|
|
215
|
-
enabled: false;
|
|
216
|
-
};
|
|
217
|
-
} | {
|
|
218
|
-
authSessions: {
|
|
219
|
-
enabled: false;
|
|
220
|
-
} | {
|
|
221
|
-
type: "API" | "MANUAL";
|
|
222
|
-
enabled: true;
|
|
223
|
-
startUrl?: string | undefined;
|
|
224
|
-
finishUrl?: string | undefined;
|
|
225
|
-
};
|
|
226
|
-
apiAccess: {
|
|
227
|
-
enabled: true;
|
|
228
|
-
};
|
|
229
|
-
}), never>;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getIntunedSettingsFile = getIntunedSettingsFile;
|
|
7
|
-
exports.getIntunedSettingsFileName = getIntunedSettingsFileName;
|
|
8
|
-
exports.intunedSettingsFileNames = exports.intunedJsonSchema = void 0;
|
|
9
|
-
exports.loadIntunedJson = loadIntunedJson;
|
|
10
|
-
exports.loadIntunedJsonSync = loadIntunedJsonSync;
|
|
11
|
-
var _path = _interopRequireDefault(require("path"));
|
|
12
|
-
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
13
|
-
var _zod = require("zod");
|
|
14
|
-
var JSONC = _interopRequireWildcard(require("jsonc-parser"));
|
|
15
|
-
var YAML = _interopRequireWildcard(require("yaml"));
|
|
16
|
-
var TOML = _interopRequireWildcard(require("smol-toml"));
|
|
17
|
-
var _neverthrow = require("neverthrow");
|
|
18
|
-
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); }
|
|
19
|
-
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 _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
|
-
const playwright = undefined;
|
|
22
|
-
const intunedJsonSchema = exports.intunedJsonSchema = _zod.z.object({
|
|
23
|
-
projectName: _zod.z.string().optional(),
|
|
24
|
-
workspaceId: _zod.z.string().optional(),
|
|
25
|
-
metadata: _zod.z.object({
|
|
26
|
-
defaultJobInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
27
|
-
defaultRunPlaygroundInput: _zod.z.record(_zod.z.any()).optional().catch(undefined),
|
|
28
|
-
testAuthSessionInput: _zod.z.record(_zod.z.any()).optional().catch(undefined)
|
|
29
|
-
}).optional().catch(undefined),
|
|
30
|
-
stealthMode: _zod.z.object({
|
|
31
|
-
enabled: _zod.z.boolean()
|
|
32
|
-
}).optional().catch(undefined)
|
|
33
|
-
}).passthrough().and(_zod.z.union([_zod.z.object({
|
|
34
|
-
authSessions: _zod.z.object({
|
|
35
|
-
enabled: _zod.z.literal(false)
|
|
36
|
-
}),
|
|
37
|
-
apiAccess: _zod.z.object({
|
|
38
|
-
enabled: _zod.z.literal(false)
|
|
39
|
-
})
|
|
40
|
-
}), _zod.z.object({
|
|
41
|
-
authSessions: _zod.z.union([_zod.z.object({
|
|
42
|
-
enabled: _zod.z.literal(false)
|
|
43
|
-
}), _zod.z.object({
|
|
44
|
-
enabled: _zod.z.literal(true),
|
|
45
|
-
type: _zod.z.enum(["MANUAL", "API"]),
|
|
46
|
-
startUrl: _zod.z.string().optional(),
|
|
47
|
-
finishUrl: _zod.z.string().optional()
|
|
48
|
-
})]),
|
|
49
|
-
apiAccess: _zod.z.object({
|
|
50
|
-
enabled: _zod.z.literal(true)
|
|
51
|
-
})
|
|
52
|
-
})]));
|
|
53
|
-
const intunedSettingsFileNames = exports.intunedSettingsFileNames = ["Intuned.json", "Intuned.jsonc", "Intuned.yaml", "Intuned.yml", "Intuned.toml"];
|
|
54
|
-
async function loadIntunedJson() {
|
|
55
|
-
const settingsFileResult = await getIntunedSettingsFile();
|
|
56
|
-
if (!settingsFileResult.isOk()) {
|
|
57
|
-
return settingsFileResult;
|
|
58
|
-
}
|
|
59
|
-
const settingsFile = settingsFileResult.value;
|
|
60
|
-
const intunedJsonContent = await fs.readFile(settingsFile.path, "utf-8");
|
|
61
|
-
let intunedJson;
|
|
62
|
-
try {
|
|
63
|
-
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
64
|
-
} catch (e) {
|
|
65
|
-
return (0, _neverthrow.err)(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
66
|
-
}
|
|
67
|
-
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
68
|
-
if (!parseResult.success) {
|
|
69
|
-
const formattedError = parseResult.error.errors.map(e => `- ${e.path.join(".")}: ${e.message}`).join("\n");
|
|
70
|
-
return (0, _neverthrow.err)(`${settingsFile.name} is not valid:\n${formattedError}\nPlease fix the errors and try again.`);
|
|
71
|
-
}
|
|
72
|
-
return (0, _neverthrow.ok)(parseResult.data);
|
|
73
|
-
}
|
|
74
|
-
const intunedSettingsParsers = {
|
|
75
|
-
"Intuned.json": JSON.parse,
|
|
76
|
-
"Intuned.jsonc": JSONC.parse,
|
|
77
|
-
"Intuned.yaml": YAML.parse,
|
|
78
|
-
"Intuned.yml": YAML.parse,
|
|
79
|
-
"Intuned.toml": TOML.parse
|
|
80
|
-
};
|
|
81
|
-
async function getIntunedSettingsFile() {
|
|
82
|
-
for (const fileName of intunedSettingsFileNames) {
|
|
83
|
-
const filePath = _path.default.join(process.cwd(), fileName);
|
|
84
|
-
if (await fs.exists(filePath)) {
|
|
85
|
-
return (0, _neverthrow.ok)({
|
|
86
|
-
name: fileName,
|
|
87
|
-
path: filePath,
|
|
88
|
-
parse: intunedSettingsParsers[fileName]
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return (0, _neverthrow.err)("No Intuned settings file found.");
|
|
93
|
-
}
|
|
94
|
-
async function getIntunedSettingsFileName() {
|
|
95
|
-
const settingsFileResult = await getIntunedSettingsFile();
|
|
96
|
-
if (!settingsFileResult.isOk()) {
|
|
97
|
-
return settingsFileResult;
|
|
98
|
-
}
|
|
99
|
-
return (0, _neverthrow.ok)(settingsFileResult.value.name);
|
|
100
|
-
}
|
|
101
|
-
function loadIntunedJsonSync() {
|
|
102
|
-
const settingsFileResult = getIntunedSettingsFileSync();
|
|
103
|
-
if (!settingsFileResult.isOk()) {
|
|
104
|
-
return settingsFileResult;
|
|
105
|
-
}
|
|
106
|
-
const settingsFile = settingsFileResult.value;
|
|
107
|
-
const intunedJsonContent = fs.readFileSync(settingsFile.path, "utf-8");
|
|
108
|
-
let intunedJson;
|
|
109
|
-
try {
|
|
110
|
-
intunedJson = settingsFile.parse(intunedJsonContent);
|
|
111
|
-
} catch (e) {
|
|
112
|
-
return (0, _neverthrow.err)(`Failed to parse ${settingsFile.name}: ${e.message}`);
|
|
113
|
-
}
|
|
114
|
-
const parseResult = intunedJsonSchema.safeParse(intunedJson);
|
|
115
|
-
if (!parseResult.success) {
|
|
116
|
-
const formattedError = parseResult.error.errors.map(e => `- ${e.path.join(".")}: ${e.message}`).join("\n");
|
|
117
|
-
return (0, _neverthrow.err)(`${settingsFile.name} is not valid:\n${formattedError}\nPlease fix the errors and try again.`);
|
|
118
|
-
}
|
|
119
|
-
return (0, _neverthrow.ok)(parseResult.data);
|
|
120
|
-
}
|
|
121
|
-
function getIntunedSettingsFileSync() {
|
|
122
|
-
for (const fileName of intunedSettingsFileNames) {
|
|
123
|
-
const filePath = _path.default.join(process.cwd(), fileName);
|
|
124
|
-
if (fs.existsSync(filePath)) {
|
|
125
|
-
return (0, _neverthrow.ok)({
|
|
126
|
-
name: fileName,
|
|
127
|
-
path: filePath,
|
|
128
|
-
parse: intunedSettingsParsers[fileName]
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return (0, _neverthrow.err)("No Intuned settings file found.");
|
|
133
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _zod = require("zod");
|
|
5
|
-
var _persistentStore = require("./persistentStore");
|
|
6
|
-
var _jwtTokenManager = require("../common/jwtTokenManager");
|
|
7
|
-
_vitest.vi.mock("../common/jwtTokenManager", () => ({
|
|
8
|
-
callBackendFunctionWithToken: _vitest.vi.fn()
|
|
9
|
-
}));
|
|
10
|
-
(0, _vitest.describe)("Cache", () => {
|
|
11
|
-
(0, _vitest.beforeEach)(() => {
|
|
12
|
-
_vitest.vi.clearAllMocks();
|
|
13
|
-
});
|
|
14
|
-
(0, _vitest.describe)("get", () => {
|
|
15
|
-
(0, _vitest.it)("should return value when successful", async () => {
|
|
16
|
-
const mockResponse = {
|
|
17
|
-
ok: true,
|
|
18
|
-
json: _vitest.vi.fn().mockResolvedValue({
|
|
19
|
-
value: "cached_data"
|
|
20
|
-
})
|
|
21
|
-
};
|
|
22
|
-
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
23
|
-
const result = await _persistentStore.persistentStore.get("test_key");
|
|
24
|
-
(0, _vitest.expect)(result).toBe("cached_data");
|
|
25
|
-
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledWith("kv-store/test_key", {
|
|
26
|
-
method: "GET"
|
|
27
|
-
});
|
|
28
|
-
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
29
|
-
});
|
|
30
|
-
(0, _vitest.it)("should throw error when response is not ok", async () => {
|
|
31
|
-
const mockResponse = {
|
|
32
|
-
ok: false,
|
|
33
|
-
json: _vitest.vi.fn().mockResolvedValue({
|
|
34
|
-
message: "Cache miss"
|
|
35
|
-
})
|
|
36
|
-
};
|
|
37
|
-
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
38
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.get("test_key")).rejects.toThrow("Cache miss");
|
|
39
|
-
});
|
|
40
|
-
(0, _vitest.it)("should throw error for empty key", async () => {
|
|
41
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.get("")).rejects.toThrow(_zod.ZodError);
|
|
42
|
-
});
|
|
43
|
-
(0, _vitest.it)("should throw error for key with colon", async () => {
|
|
44
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.get("invalid:key")).rejects.toThrow(_zod.ZodError);
|
|
45
|
-
});
|
|
46
|
-
(0, _vitest.it)("should throw error for key with hash", async () => {
|
|
47
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.get("invalid#key")).rejects.toThrow(_zod.ZodError);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
(0, _vitest.describe)("set", () => {
|
|
51
|
-
(0, _vitest.it)("should call backend correctly when successful", async () => {
|
|
52
|
-
const mockResponse = {
|
|
53
|
-
ok: true,
|
|
54
|
-
json: _vitest.vi.fn().mockResolvedValue({})
|
|
55
|
-
};
|
|
56
|
-
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
57
|
-
const testValue = {
|
|
58
|
-
data: "test"
|
|
59
|
-
};
|
|
60
|
-
await _persistentStore.persistentStore.set("test_key", testValue);
|
|
61
|
-
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledWith("kv-store/test_key", {
|
|
62
|
-
method: "PUT",
|
|
63
|
-
body: JSON.stringify(testValue),
|
|
64
|
-
headers: {
|
|
65
|
-
"Content-Type": "application/json"
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
69
|
-
});
|
|
70
|
-
(0, _vitest.it)("should throw error when response is not ok", async () => {
|
|
71
|
-
const mockResponse = {
|
|
72
|
-
ok: false,
|
|
73
|
-
json: _vitest.vi.fn().mockResolvedValue({
|
|
74
|
-
message: "Set failed"
|
|
75
|
-
})
|
|
76
|
-
};
|
|
77
|
-
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
78
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.set("test_key", "value")).rejects.toThrow("Set failed");
|
|
79
|
-
});
|
|
80
|
-
(0, _vitest.it)("should throw error for empty key", async () => {
|
|
81
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.set("", "value")).rejects.toThrow(_zod.ZodError);
|
|
82
|
-
});
|
|
83
|
-
(0, _vitest.it)("should throw error for key with forbidden characters", async () => {
|
|
84
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.set("invalid:key", "value")).rejects.toThrow(_zod.ZodError);
|
|
85
|
-
await (0, _vitest.expect)(_persistentStore.persistentStore.set("invalid#key", "value")).rejects.toThrow(_zod.ZodError);
|
|
86
|
-
});
|
|
87
|
-
(0, _vitest.it)("should handle different value types", async () => {
|
|
88
|
-
const mockResponse = {
|
|
89
|
-
ok: true,
|
|
90
|
-
json: _vitest.vi.fn().mockResolvedValue({})
|
|
91
|
-
};
|
|
92
|
-
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
93
|
-
await _persistentStore.persistentStore.set("key1", "string_value");
|
|
94
|
-
await _persistentStore.persistentStore.set("key2", {
|
|
95
|
-
object: "value"
|
|
96
|
-
});
|
|
97
|
-
await _persistentStore.persistentStore.set("key3", 123);
|
|
98
|
-
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledTimes(3);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|