@intuned/runtime 1.3.7 → 1.3.8
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/controller/deploy.js +1 -1
- package/dist/commands/intuned-cli/controller/save.js +1 -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;
|
|
@@ -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 => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
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",
|