@kubb/agent 4.29.1 → 4.31.0
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +505 -339
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +3 -1
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +3 -1
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +6 -3
- package/.output/server/node_modules/@kubb/fabric-core/dist/{onProcessExit-CF200hsz.js → onProcessExit-B0rJqX4s.js} +7 -1
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +1 -1
- package/.output/server/node_modules/@kubb/fabric-core/package.json +1 -1
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +1 -1
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +1 -1
- package/.output/server/node_modules/@kubb/react-fabric/dist/{reactPlugin-BkDkx1cs.js → reactPlugin-tE73eBS_.js} +5 -1
- package/.output/server/node_modules/@kubb/react-fabric/package.json +2 -2
- package/.output/server/node_modules/@logtail/core/dist/cjs/base.js +339 -0
- package/.output/server/node_modules/@logtail/core/dist/cjs/index.js +9 -0
- package/.output/server/node_modules/@logtail/core/package.json +45 -0
- package/.output/server/node_modules/@logtail/node/dist/cjs/context.js +93 -0
- package/.output/server/node_modules/@logtail/node/dist/cjs/index.js +6 -0
- package/.output/server/node_modules/@logtail/node/dist/cjs/node.js +106 -0
- package/.output/server/node_modules/@logtail/node/package.json +53 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/batch.js +122 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/burstProtection.js +50 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/encode.js +12 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/index.js +41 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/queue.js +41 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/throttle.js +67 -0
- package/.output/server/node_modules/@logtail/tools/package.json +39 -0
- package/.output/server/node_modules/@logtail/types/dist/cjs/types.js +21 -0
- package/.output/server/node_modules/@logtail/types/package.json +45 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/CachedKeyDecoder.js +63 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/DecodeError.js +18 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/Decoder.js +583 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/Encoder.js +408 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/ExtData.js +14 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/ExtensionCodec.js +72 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/decode.js +32 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/decodeAsync.js +44 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/encode.js +17 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/index.js +34 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/timestamp.js +104 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/int.js +34 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/prettyByte.js +8 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/stream.js +40 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/typedArrays.js +28 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/utf8.js +167 -0
- package/.output/server/node_modules/@msgpack/msgpack/package.json +100 -0
- package/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/.output/server/node_modules/consola/dist/core.mjs +512 -0
- package/.output/server/node_modules/consola/dist/index.mjs +651 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/.output/server/node_modules/consola/package.json +136 -0
- package/.output/server/node_modules/serialize-error/index.js +154 -0
- package/.output/server/node_modules/serialize-error/package.json +41 -0
- package/.output/server/node_modules/stack-trace/lib/stack-trace.js +136 -0
- package/.output/server/node_modules/stack-trace/package.json +21 -0
- package/.output/server/package.json +11 -3
- package/README.md +3 -3
- package/package.json +23 -18
|
@@ -6,14 +6,15 @@ import http, { Server as Server$2 } from 'node:http';
|
|
|
6
6
|
import https, { Server as Server$1 } from 'node:https';
|
|
7
7
|
import { EventEmitter } from 'node:events';
|
|
8
8
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
9
|
-
import fs$1, { promises, existsSync, readFileSync
|
|
9
|
+
import fs$1, { promises, existsSync, readFileSync } from 'node:fs';
|
|
10
10
|
import path$2, { resolve, dirname, relative, join, normalize } from 'node:path';
|
|
11
11
|
import anymatch from 'anymatch';
|
|
12
|
-
import { createHash } from 'node:crypto';
|
|
12
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
13
13
|
import process$1, { version as version$2 } from 'node:process';
|
|
14
|
+
import { Logtail } from '@logtail/node';
|
|
15
|
+
import { consola } from 'consola';
|
|
14
16
|
import { sortBy, mergeDeep, isPlainObject as isPlainObject$1, uniqueWith, isDeepEqual, isNumber, isFunction, difference } from 'remeda';
|
|
15
17
|
import { x } from 'tinyexec';
|
|
16
|
-
import os$1 from 'node:os';
|
|
17
18
|
import { styleText } from 'node:util';
|
|
18
19
|
import { access, rm, readFile as readFile$1, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
19
20
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
@@ -21,6 +22,7 @@ import mod, { createRequire } from 'node:module';
|
|
|
21
22
|
import { createFabric, createReactFabric, App, File, Function as Function$1, Const, FunctionParams, Type as Type$1, useApp } from '@kubb/react-fabric';
|
|
22
23
|
import { typescriptParser } from '@kubb/react-fabric/parsers';
|
|
23
24
|
import { fsPlugin } from '@kubb/react-fabric/plugins';
|
|
25
|
+
import os$1 from 'node:os';
|
|
24
26
|
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
25
27
|
import * as pkg from 'empathic/package';
|
|
26
28
|
import { coerce, satisfies } from 'semver';
|
|
@@ -4387,28 +4389,217 @@ function defineNitroPlugin(def) {
|
|
|
4387
4389
|
return def;
|
|
4388
4390
|
}
|
|
4389
4391
|
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
}
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
}
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4392
|
+
let logtail = null;
|
|
4393
|
+
function getLogtail() {
|
|
4394
|
+
if (logtail) {
|
|
4395
|
+
return logtail;
|
|
4396
|
+
}
|
|
4397
|
+
const token = process.env.OTLP_TOKEN;
|
|
4398
|
+
if (!token) {
|
|
4399
|
+
return null;
|
|
4400
|
+
}
|
|
4401
|
+
try {
|
|
4402
|
+
logtail = new Logtail(token, {
|
|
4403
|
+
endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT
|
|
4404
|
+
});
|
|
4405
|
+
return logtail;
|
|
4406
|
+
} catch {
|
|
4407
|
+
return null;
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
function toBetterStackContext(ctx) {
|
|
4411
|
+
if (!ctx) return void 0;
|
|
4412
|
+
const filtered = Object.fromEntries(Object.entries(ctx).filter(([, v]) => v !== void 0 && v !== null));
|
|
4413
|
+
return Object.keys(filtered).length ? filtered : void 0;
|
|
4414
|
+
}
|
|
4415
|
+
function sendToBetterStack(level, tag, message, ctx) {
|
|
4416
|
+
const client = getLogtail();
|
|
4417
|
+
if (!client) {
|
|
4418
|
+
return;
|
|
4419
|
+
}
|
|
4420
|
+
try {
|
|
4421
|
+
const fullMessage = message !== void 0 ? `[${tag}] ${message}` : tag;
|
|
4422
|
+
const context = toBetterStackContext(ctx);
|
|
4423
|
+
if (level === "error") {
|
|
4424
|
+
client.error(fullMessage, context).then(() => client.flush());
|
|
4425
|
+
} else if (level === "warn") {
|
|
4426
|
+
client.warn(fullMessage, context).then(() => client.flush());
|
|
4427
|
+
} else {
|
|
4428
|
+
client.info(fullMessage, context).then(() => client.flush());
|
|
4429
|
+
}
|
|
4430
|
+
} catch (_e) {
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
function log(level, tag, message, ctx) {
|
|
4434
|
+
const displayMessage = message !== void 0 ? `[${tag}] ${message}` : tag;
|
|
4435
|
+
consola[level](displayMessage);
|
|
4436
|
+
if (ctx) {
|
|
4437
|
+
const filtered = Object.fromEntries(Object.entries(ctx).filter(([, v]) => v !== void 0 && v !== null));
|
|
4438
|
+
if (Object.keys(filtered).length) {
|
|
4439
|
+
console.table(filtered);
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
if (process.env.OTEL_EXPORTER_OTLP_ENDPOINT && process.env.OTLP_TOKEN) {
|
|
4443
|
+
sendToBetterStack(level, tag, message, ctx);
|
|
4406
4444
|
}
|
|
4445
|
+
}
|
|
4446
|
+
const logger = {
|
|
4447
|
+
info: (tag, message, ctx) => log("info", tag, message, ctx),
|
|
4448
|
+
success: (tag, message, ctx) => log("success", tag, message, ctx),
|
|
4449
|
+
warn: (tag, message, ctx) => log("warn", tag, message, ctx),
|
|
4450
|
+
error: (tag, message, ctx) => log("error", tag, message, ctx)
|
|
4407
4451
|
};
|
|
4408
4452
|
|
|
4409
4453
|
const _KZ9YuROWp70nNn4X1C4BxF_W0D7H9EWgBo03XvMd7w0 = defineNitroPlugin(() => {
|
|
4410
4454
|
});
|
|
4411
4455
|
|
|
4456
|
+
function maskedString(value, start = 8, end = 4) {
|
|
4457
|
+
if (value.length <= start + end) return value;
|
|
4458
|
+
return `${value.slice(0, start)}\u2026${value.slice(-end)}`;
|
|
4459
|
+
}
|
|
4460
|
+
|
|
4461
|
+
const HEARTBEAT_INTERVAL_MS = 5 * 60 * 1e3;
|
|
4462
|
+
const _a2VEEUGb5K4b1gyM9hOmO1Xz0hUJSFuGyIT3cHsvE = defineNitroPlugin((nitro) => {
|
|
4463
|
+
const heartbeatUrl = process$1.env.KUBB_AGENT_HEARTBEAT_URL;
|
|
4464
|
+
if (!heartbeatUrl) {
|
|
4465
|
+
return;
|
|
4466
|
+
}
|
|
4467
|
+
const maskedUrl = maskedString(heartbeatUrl);
|
|
4468
|
+
const timer = setInterval(async () => {
|
|
4469
|
+
try {
|
|
4470
|
+
await $fetch(heartbeatUrl, { method: "GET" });
|
|
4471
|
+
logger.info(`Heartbeat sent to ${maskedUrl}`);
|
|
4472
|
+
} catch (error) {
|
|
4473
|
+
logger.warn(`Failed to send heartbeat to ${maskedUrl}`, error == null ? void 0 : error.message);
|
|
4474
|
+
}
|
|
4475
|
+
}, HEARTBEAT_INTERVAL_MS);
|
|
4476
|
+
nitro.hooks.hook("close", () => {
|
|
4477
|
+
clearInterval(timer);
|
|
4478
|
+
});
|
|
4479
|
+
});
|
|
4480
|
+
|
|
4481
|
+
function getStorage() {
|
|
4482
|
+
return useStorage("kubb");
|
|
4483
|
+
}
|
|
4484
|
+
function isSessionValid(session) {
|
|
4485
|
+
try {
|
|
4486
|
+
const expiresAt = new Date(session.expiresAt);
|
|
4487
|
+
const now = /* @__PURE__ */ new Date();
|
|
4488
|
+
return now.getTime() < expiresAt.getTime() - 6e4;
|
|
4489
|
+
} catch {
|
|
4490
|
+
return false;
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
function getSessionKey(token) {
|
|
4494
|
+
return `sessions:${createHash("sha512").update(token).digest("hex")}`;
|
|
4495
|
+
}
|
|
4496
|
+
async function getCachedSession(sessionKey) {
|
|
4497
|
+
const storage = getStorage();
|
|
4498
|
+
const agentSession = await storage.getItem(sessionKey);
|
|
4499
|
+
if (!agentSession) {
|
|
4500
|
+
return null;
|
|
4501
|
+
}
|
|
4502
|
+
if (!isSessionValid(agentSession)) {
|
|
4503
|
+
return null;
|
|
4504
|
+
}
|
|
4505
|
+
return agentSession;
|
|
4506
|
+
}
|
|
4507
|
+
async function cacheSession({ sessionKey, session }) {
|
|
4508
|
+
const storage = getStorage();
|
|
4509
|
+
await storage.setItem(sessionKey, { ...session, storedAt: (/* @__PURE__ */ new Date()).toISOString(), configs: [] });
|
|
4510
|
+
}
|
|
4511
|
+
async function removeCachedSession(sessionKey) {
|
|
4512
|
+
const storage = getStorage();
|
|
4513
|
+
const maskedSessionKey = maskedString(sessionKey.replace("sessions:", ""));
|
|
4514
|
+
logger.info(`[${maskedSessionKey}] Removing expired agent session from cache...`);
|
|
4515
|
+
await storage.removeItem(sessionKey);
|
|
4516
|
+
logger.success(`[${maskedSessionKey}] Removed expired agent session from cache`);
|
|
4517
|
+
}
|
|
4518
|
+
async function saveStudioConfigToStorage({ sessionKey, config }) {
|
|
4519
|
+
const storage = getStorage();
|
|
4520
|
+
const agentSession = await getCachedSession(sessionKey);
|
|
4521
|
+
if (!agentSession) {
|
|
4522
|
+
throw new Error("No valid session found for retrieving previous configs");
|
|
4523
|
+
}
|
|
4524
|
+
await storage.setItem(sessionKey, { ...agentSession, configs: [...agentSession.configs, { config, storedAt: (/* @__PURE__ */ new Date()).toISOString() }] });
|
|
4525
|
+
}
|
|
4526
|
+
|
|
4527
|
+
function generateToken() {
|
|
4528
|
+
return randomBytes(32).toString("hex");
|
|
4529
|
+
}
|
|
4530
|
+
function generateMachineToken() {
|
|
4531
|
+
return process.env.KUBB_AGENT_SECRET ? process.env.KUBB_AGENT_SECRET : createHash("sha256").update(generateToken()).digest("hex");
|
|
4532
|
+
}
|
|
4533
|
+
|
|
4534
|
+
async function createAgentSession({ token, studioUrl, noCache, cacheKey }) {
|
|
4535
|
+
const machineToken = generateMachineToken();
|
|
4536
|
+
const sessionKey = cacheKey != null ? cacheKey : getSessionKey(token);
|
|
4537
|
+
const maskedSessionKey = maskedString(sessionKey.replace("sessions:", ""));
|
|
4538
|
+
const connectUrl = `${studioUrl}/api/agent/session/create`;
|
|
4539
|
+
const canCache = !noCache;
|
|
4540
|
+
if (canCache) {
|
|
4541
|
+
const cachedSession = await getCachedSession(sessionKey);
|
|
4542
|
+
if (cachedSession) {
|
|
4543
|
+
logger.success(`[${maskedSessionKey}] Using cached agent session`);
|
|
4544
|
+
return cachedSession;
|
|
4545
|
+
}
|
|
4546
|
+
await removeCachedSession(sessionKey);
|
|
4547
|
+
}
|
|
4548
|
+
try {
|
|
4549
|
+
logger.info(`[${maskedSessionKey}] Creating agent session with Studio...`);
|
|
4550
|
+
const data = await $fetch(connectUrl, {
|
|
4551
|
+
method: "POST",
|
|
4552
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
4553
|
+
body: { machineToken }
|
|
4554
|
+
});
|
|
4555
|
+
if (!data) {
|
|
4556
|
+
throw new Error("No data available for agent session");
|
|
4557
|
+
}
|
|
4558
|
+
if (canCache) {
|
|
4559
|
+
await cacheSession({ sessionKey, session: { ...data, storedAt: (/* @__PURE__ */ new Date()).toISOString(), configs: [] } });
|
|
4560
|
+
logger.success(`[${maskedSessionKey}] Saved agent session to cache`);
|
|
4561
|
+
}
|
|
4562
|
+
logger.info(`[${maskedSessionKey}] Created agent session with Studio`);
|
|
4563
|
+
return data;
|
|
4564
|
+
} catch (error) {
|
|
4565
|
+
throw new Error("Failed to get agent session from Kubb Studio", { cause: error });
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
async function registerAgent({ token, studioUrl, poolSize }) {
|
|
4569
|
+
var _a, _b;
|
|
4570
|
+
const machineToken = generateMachineToken();
|
|
4571
|
+
const registerUrl = `${studioUrl}/api/agent/register`;
|
|
4572
|
+
try {
|
|
4573
|
+
logger.info("Registering agent with Studio...");
|
|
4574
|
+
await $fetch(registerUrl, {
|
|
4575
|
+
method: "POST",
|
|
4576
|
+
headers: {
|
|
4577
|
+
Authorization: `Bearer ${token}`
|
|
4578
|
+
},
|
|
4579
|
+
body: { machineToken, poolSize }
|
|
4580
|
+
});
|
|
4581
|
+
logger.success(`Agent registered with Studio with token ${maskedString(token)}`);
|
|
4582
|
+
} catch (error) {
|
|
4583
|
+
logger.error("Failed to register agent with Studio", (_b = (_a = error == null ? void 0 : error.cause) == null ? void 0 : _a.message) != null ? _b : error == null ? void 0 : error.message);
|
|
4584
|
+
}
|
|
4585
|
+
}
|
|
4586
|
+
async function disconnect({ sessionId, token, studioUrl }) {
|
|
4587
|
+
const disconnectUrl = `${studioUrl}/api/agent/session/${sessionId}/disconnect`;
|
|
4588
|
+
const maskedSessionKey = maskedString(sessionId);
|
|
4589
|
+
try {
|
|
4590
|
+
logger.info(`[${maskedSessionKey}] Disconnecting from Studio...`);
|
|
4591
|
+
await $fetch(disconnectUrl, {
|
|
4592
|
+
method: "POST",
|
|
4593
|
+
headers: {
|
|
4594
|
+
Authorization: `Bearer ${token}`
|
|
4595
|
+
}
|
|
4596
|
+
});
|
|
4597
|
+
logger.success(`[${maskedSessionKey}] Disconnected from Studio`);
|
|
4598
|
+
} catch (error) {
|
|
4599
|
+
throw new Error("Failed to notify Studio of disconnection on exit", { cause: error });
|
|
4600
|
+
}
|
|
4601
|
+
}
|
|
4602
|
+
|
|
4412
4603
|
async function clean(path) {
|
|
4413
4604
|
return rm(path, {
|
|
4414
4605
|
recursive: true,
|
|
@@ -5882,116 +6073,16 @@ function tokenize(command) {
|
|
|
5882
6073
|
return args;
|
|
5883
6074
|
}
|
|
5884
6075
|
|
|
6076
|
+
var version = "4.31.0";
|
|
6077
|
+
|
|
5885
6078
|
function isCommandMessage(msg) {
|
|
5886
6079
|
return msg.type === "command";
|
|
5887
6080
|
}
|
|
5888
6081
|
function isPongMessage(msg) {
|
|
5889
6082
|
return msg.type === "pong";
|
|
5890
6083
|
}
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
return `sessions:${createHash("sha512").update(token).digest("hex")}`;
|
|
5894
|
-
}
|
|
5895
|
-
|
|
5896
|
-
function isSessionValid(session) {
|
|
5897
|
-
try {
|
|
5898
|
-
const expiresAt = new Date(session.expiresAt);
|
|
5899
|
-
const now = /* @__PURE__ */ new Date();
|
|
5900
|
-
return now.getTime() < expiresAt.getTime() - 6e4;
|
|
5901
|
-
} catch {
|
|
5902
|
-
return false;
|
|
5903
|
-
}
|
|
5904
|
-
}
|
|
5905
|
-
|
|
5906
|
-
function hashToken(input) {
|
|
5907
|
-
return createHash("sha256").update(input).digest("hex");
|
|
5908
|
-
}
|
|
5909
|
-
function generateMachineToken() {
|
|
5910
|
-
if (process.env.KUBB_STUDIO_SECRET) {
|
|
5911
|
-
return hashToken(process.env.KUBB_STUDIO_SECRET);
|
|
5912
|
-
}
|
|
5913
|
-
const interfaces = os$1.networkInterfaces();
|
|
5914
|
-
const macs = [];
|
|
5915
|
-
for (const name in interfaces) {
|
|
5916
|
-
for (const iface of interfaces[name]) {
|
|
5917
|
-
if (!iface.internal && iface.mac !== "00:00:00:00:00:00") {
|
|
5918
|
-
macs.push(iface.mac);
|
|
5919
|
-
}
|
|
5920
|
-
}
|
|
5921
|
-
}
|
|
5922
|
-
return hashToken(macs.join(",") + os$1.hostname());
|
|
5923
|
-
}
|
|
5924
|
-
|
|
5925
|
-
async function createAgentSession({ token, studioUrl, noCache }) {
|
|
5926
|
-
const storage = useStorage("kubb");
|
|
5927
|
-
if (!noCache) {
|
|
5928
|
-
const sessionKey = getSessionKey(token);
|
|
5929
|
-
const stored = await storage.getItem(sessionKey);
|
|
5930
|
-
if (stored && isSessionValid(stored)) {
|
|
5931
|
-
logger.success("Using cached agent session");
|
|
5932
|
-
return stored;
|
|
5933
|
-
}
|
|
5934
|
-
if (stored) {
|
|
5935
|
-
await storage.removeItem(sessionKey);
|
|
5936
|
-
}
|
|
5937
|
-
}
|
|
5938
|
-
const connectUrl = `${studioUrl}/api/agent/session/create`;
|
|
5939
|
-
try {
|
|
5940
|
-
const machineToken = generateMachineToken();
|
|
5941
|
-
const data = await $fetch(connectUrl, {
|
|
5942
|
-
method: "POST",
|
|
5943
|
-
headers: {
|
|
5944
|
-
Authorization: `Bearer ${token}`
|
|
5945
|
-
},
|
|
5946
|
-
body: { machineToken }
|
|
5947
|
-
});
|
|
5948
|
-
if (!data) {
|
|
5949
|
-
throw new Error("No data available for agent session");
|
|
5950
|
-
}
|
|
5951
|
-
if (!noCache) {
|
|
5952
|
-
const sessionKey = getSessionKey(token);
|
|
5953
|
-
await storage.setItem(sessionKey, {
|
|
5954
|
-
...data,
|
|
5955
|
-
storedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5956
|
-
});
|
|
5957
|
-
logger.success("Cached agent session");
|
|
5958
|
-
}
|
|
5959
|
-
logger.success("Agent session created");
|
|
5960
|
-
return data;
|
|
5961
|
-
} catch (error) {
|
|
5962
|
-
throw new Error("Failed to get agent session from Kubb Studio", { cause: error });
|
|
5963
|
-
}
|
|
5964
|
-
}
|
|
5965
|
-
async function registerAgent({ token, studioUrl }) {
|
|
5966
|
-
var _a, _b;
|
|
5967
|
-
const machineToken = generateMachineToken();
|
|
5968
|
-
const registerUrl = `${studioUrl}/api/agent/register`;
|
|
5969
|
-
try {
|
|
5970
|
-
await $fetch(registerUrl, {
|
|
5971
|
-
method: "POST",
|
|
5972
|
-
headers: {
|
|
5973
|
-
Authorization: `Bearer ${token}`
|
|
5974
|
-
},
|
|
5975
|
-
body: { machineToken }
|
|
5976
|
-
});
|
|
5977
|
-
logger.success("Agent registered with Studio");
|
|
5978
|
-
} catch (error) {
|
|
5979
|
-
logger.warn("Failed to register agent with Studio", (_b = (_a = error == null ? void 0 : error.cause) == null ? void 0 : _a.message) != null ? _b : error == null ? void 0 : error.message);
|
|
5980
|
-
}
|
|
5981
|
-
}
|
|
5982
|
-
async function disconnect({ sessionToken, token, studioUrl }) {
|
|
5983
|
-
try {
|
|
5984
|
-
const disconnectUrl = `${studioUrl}/api/agent/session/${sessionToken}/disconnect`;
|
|
5985
|
-
await $fetch(disconnectUrl, {
|
|
5986
|
-
method: "POST",
|
|
5987
|
-
headers: {
|
|
5988
|
-
Authorization: `Bearer ${token}`
|
|
5989
|
-
}
|
|
5990
|
-
});
|
|
5991
|
-
logger.success("Sent disconnect notification to Studio on exit");
|
|
5992
|
-
} catch (error) {
|
|
5993
|
-
throw new Error("Failed to notify Studio of disconnection on exit", { cause: error });
|
|
5994
|
-
}
|
|
6084
|
+
function isDisconnectMessage(msg) {
|
|
6085
|
+
return msg.type === "disconnect";
|
|
5995
6086
|
}
|
|
5996
6087
|
|
|
5997
6088
|
var __typeError$3 = (msg) => {
|
|
@@ -6027,7 +6118,7 @@ var BaseGenerator = (_a$3 = class {
|
|
|
6027
6118
|
function isInputPath(config) {
|
|
6028
6119
|
return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
|
|
6029
6120
|
}
|
|
6030
|
-
var version$1 = "4.
|
|
6121
|
+
var version$1 = "4.31.0";
|
|
6031
6122
|
function getDiagnosticInfo() {
|
|
6032
6123
|
return {
|
|
6033
6124
|
nodeVersion: version$2,
|
|
@@ -6505,6 +6596,15 @@ async function getCosmiConfig(configPath) {
|
|
|
6505
6596
|
}
|
|
6506
6597
|
}
|
|
6507
6598
|
|
|
6599
|
+
async function loadConfig(resolvedConfigPath) {
|
|
6600
|
+
const result = await getCosmiConfig(resolvedConfigPath);
|
|
6601
|
+
const configs = await getConfigs(result.config, {});
|
|
6602
|
+
if (configs.length === 0) {
|
|
6603
|
+
throw new Error("No configs found");
|
|
6604
|
+
}
|
|
6605
|
+
return configs[0];
|
|
6606
|
+
}
|
|
6607
|
+
|
|
6508
6608
|
var __defProp$8 = Object.defineProperty;
|
|
6509
6609
|
var __name$5 = (target, value) => __defProp$8(target, "name", {
|
|
6510
6610
|
value,
|
|
@@ -11464,6 +11564,7 @@ async function buildOperations(operations, { config, fabric, plugin, generator,
|
|
|
11464
11564
|
})
|
|
11465
11565
|
}));
|
|
11466
11566
|
await fabric.context.fileManager.upsert(...fabricChild.files);
|
|
11567
|
+
fabricChild.unmount();
|
|
11467
11568
|
}
|
|
11468
11569
|
async function buildOperation(operation, { config, fabric, plugin, generator, Component }) {
|
|
11469
11570
|
if (!Component) return;
|
|
@@ -11484,6 +11585,7 @@ async function buildOperation(operation, { config, fabric, plugin, generator, Co
|
|
|
11484
11585
|
})
|
|
11485
11586
|
}));
|
|
11486
11587
|
await fabric.context.fileManager.upsert(...fabricChild.files);
|
|
11588
|
+
fabricChild.unmount();
|
|
11487
11589
|
}
|
|
11488
11590
|
async function buildSchema(schema, { config, fabric, plugin, Component, generator }) {
|
|
11489
11591
|
if (!Component) return;
|
|
@@ -11504,6 +11606,7 @@ async function buildSchema(schema, { config, fabric, plugin, Component, generato
|
|
|
11504
11606
|
})
|
|
11505
11607
|
}));
|
|
11506
11608
|
await fabric.context.fileManager.upsert(...fabricChild.files);
|
|
11609
|
+
fabricChild.unmount();
|
|
11507
11610
|
}
|
|
11508
11611
|
var SchemaGenerator = (_b = class extends BaseGenerator {
|
|
11509
11612
|
constructor() {
|
|
@@ -11781,6 +11884,16 @@ getRefAlias_fn = function(schemaObject, name) {
|
|
|
11781
11884
|
}
|
|
11782
11885
|
}];
|
|
11783
11886
|
}
|
|
11887
|
+
if ($ref.startsWith("#") && !$ref.startsWith("#/components/")) try {
|
|
11888
|
+
const inlineSchema = this.context.oas.get($ref);
|
|
11889
|
+
if (inlineSchema && !isReference(inlineSchema)) return this.parse({
|
|
11890
|
+
schema: inlineSchema,
|
|
11891
|
+
name,
|
|
11892
|
+
parentName: null,
|
|
11893
|
+
rootName: null
|
|
11894
|
+
});
|
|
11895
|
+
} catch {
|
|
11896
|
+
}
|
|
11784
11897
|
__privateMethod$1(this, _SchemaGenerator_instances, ensureNameMapping_fn).call(this);
|
|
11785
11898
|
const originalName = $ref.replace(/.+\//, "");
|
|
11786
11899
|
const resolvedName = __privateGet(this, _schemaNameMapping).get($ref) || originalName;
|
|
@@ -217747,7 +217860,7 @@ const infiniteQueryGenerator$1 = createReactGenerator({
|
|
|
217747
217860
|
path: zod.file.path
|
|
217748
217861
|
}),
|
|
217749
217862
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
217750
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
217863
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
217751
217864
|
name: "fetch",
|
|
217752
217865
|
path: options.client.importPath
|
|
217753
217866
|
}),
|
|
@@ -217766,7 +217879,7 @@ const infiniteQueryGenerator$1 = createReactGenerator({
|
|
|
217766
217879
|
isTypeOnly: true
|
|
217767
217880
|
})
|
|
217768
217881
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
217769
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
217882
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
217770
217883
|
name: ["fetch"],
|
|
217771
217884
|
root: query.file.path,
|
|
217772
217885
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -217973,7 +218086,7 @@ const mutationGenerator$4 = createReactGenerator({
|
|
|
217973
218086
|
path: zod.file.path
|
|
217974
218087
|
}),
|
|
217975
218088
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
217976
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218089
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
217977
218090
|
name: "fetch",
|
|
217978
218091
|
path: options.client.importPath
|
|
217979
218092
|
}),
|
|
@@ -217992,7 +218105,7 @@ const mutationGenerator$4 = createReactGenerator({
|
|
|
217992
218105
|
isTypeOnly: true
|
|
217993
218106
|
})
|
|
217994
218107
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
217995
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218108
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
217996
218109
|
name: ["fetch"],
|
|
217997
218110
|
root: mutation.file.path,
|
|
217998
218111
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -218183,7 +218296,7 @@ const queryGenerator$4 = createReactGenerator({
|
|
|
218183
218296
|
path: zod.file.path
|
|
218184
218297
|
}),
|
|
218185
218298
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
218186
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218299
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
218187
218300
|
name: "fetch",
|
|
218188
218301
|
path: options.client.importPath
|
|
218189
218302
|
}),
|
|
@@ -218202,7 +218315,7 @@ const queryGenerator$4 = createReactGenerator({
|
|
|
218202
218315
|
isTypeOnly: true
|
|
218203
218316
|
})
|
|
218204
218317
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
218205
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218318
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
218206
218319
|
name: ["fetch"],
|
|
218207
218320
|
root: query.file.path,
|
|
218208
218321
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -218405,7 +218518,7 @@ const suspenseInfiniteQueryGenerator = createReactGenerator({
|
|
|
218405
218518
|
path: zod.file.path
|
|
218406
218519
|
}),
|
|
218407
218520
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
218408
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218521
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
218409
218522
|
name: "fetch",
|
|
218410
218523
|
path: options.client.importPath
|
|
218411
218524
|
}),
|
|
@@ -218424,7 +218537,7 @@ const suspenseInfiniteQueryGenerator = createReactGenerator({
|
|
|
218424
218537
|
isTypeOnly: true
|
|
218425
218538
|
})
|
|
218426
218539
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
218427
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218540
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
218428
218541
|
name: ["fetch"],
|
|
218429
218542
|
root: query.file.path,
|
|
218430
218543
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -218639,7 +218752,7 @@ const suspenseQueryGenerator = createReactGenerator({
|
|
|
218639
218752
|
path: zod.file.path
|
|
218640
218753
|
}),
|
|
218641
218754
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
218642
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218755
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
218643
218756
|
name: "fetch",
|
|
218644
218757
|
path: options.client.importPath
|
|
218645
218758
|
}),
|
|
@@ -218658,7 +218771,7 @@ const suspenseQueryGenerator = createReactGenerator({
|
|
|
218658
218771
|
isTypeOnly: true
|
|
218659
218772
|
})
|
|
218660
218773
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
218661
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
218774
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
218662
218775
|
name: ["fetch"],
|
|
218663
218776
|
root: query.file.path,
|
|
218664
218777
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -219538,7 +219651,7 @@ const mutationGenerator$3 = createReactGenerator({
|
|
|
219538
219651
|
path: zod.file.path
|
|
219539
219652
|
}),
|
|
219540
219653
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
219541
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
219654
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
219542
219655
|
name: "fetch",
|
|
219543
219656
|
path: options.client.importPath
|
|
219544
219657
|
}),
|
|
@@ -219557,7 +219670,7 @@ const mutationGenerator$3 = createReactGenerator({
|
|
|
219557
219670
|
isTypeOnly: true
|
|
219558
219671
|
})
|
|
219559
219672
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
219560
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
219673
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
219561
219674
|
name: ["fetch"],
|
|
219562
219675
|
root: mutation.file.path,
|
|
219563
219676
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -219731,7 +219844,7 @@ const queryGenerator$3 = createReactGenerator({
|
|
|
219731
219844
|
path: zod.file.path
|
|
219732
219845
|
}),
|
|
219733
219846
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
219734
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
219847
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
219735
219848
|
name: "fetch",
|
|
219736
219849
|
path: options.client.importPath
|
|
219737
219850
|
}),
|
|
@@ -219750,7 +219863,7 @@ const queryGenerator$3 = createReactGenerator({
|
|
|
219750
219863
|
isTypeOnly: true
|
|
219751
219864
|
})
|
|
219752
219865
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
219753
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
219866
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
219754
219867
|
name: ["fetch"],
|
|
219755
219868
|
root: query.file.path,
|
|
219756
219869
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -220552,7 +220665,7 @@ const mutationGenerator$2 = createReactGenerator({
|
|
|
220552
220665
|
path: zod.file.path
|
|
220553
220666
|
}),
|
|
220554
220667
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220555
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
220668
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
220556
220669
|
name: "fetch",
|
|
220557
220670
|
path: options.client.importPath
|
|
220558
220671
|
}),
|
|
@@ -220571,7 +220684,7 @@ const mutationGenerator$2 = createReactGenerator({
|
|
|
220571
220684
|
isTypeOnly: true
|
|
220572
220685
|
})
|
|
220573
220686
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220574
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
220687
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
220575
220688
|
name: ["fetch"],
|
|
220576
220689
|
root: mutation.file.path,
|
|
220577
220690
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -220744,7 +220857,7 @@ const queryGenerator$2 = createReactGenerator({
|
|
|
220744
220857
|
path: zod.file.path
|
|
220745
220858
|
}),
|
|
220746
220859
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220747
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
220860
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
220748
220861
|
name: "fetch",
|
|
220749
220862
|
path: options.client.importPath
|
|
220750
220863
|
}),
|
|
@@ -220763,7 +220876,7 @@ const queryGenerator$2 = createReactGenerator({
|
|
|
220763
220876
|
isTypeOnly: true
|
|
220764
220877
|
})
|
|
220765
220878
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220766
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
220879
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
220767
220880
|
name: ["fetch"],
|
|
220768
220881
|
root: query.file.path,
|
|
220769
220882
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -221603,7 +221716,7 @@ const mutationGenerator$1 = createReactGenerator({
|
|
|
221603
221716
|
path: zod.file.path
|
|
221604
221717
|
}),
|
|
221605
221718
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
221606
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
221719
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
221607
221720
|
name: "fetch",
|
|
221608
221721
|
path: options.client.importPath
|
|
221609
221722
|
}),
|
|
@@ -221622,7 +221735,7 @@ const mutationGenerator$1 = createReactGenerator({
|
|
|
221622
221735
|
isTypeOnly: true
|
|
221623
221736
|
})
|
|
221624
221737
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
221625
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
221738
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
221626
221739
|
name: ["fetch"],
|
|
221627
221740
|
root: mutation.file.path,
|
|
221628
221741
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -221791,7 +221904,7 @@ const queryGenerator$1 = createReactGenerator({
|
|
|
221791
221904
|
path: zod.file.path
|
|
221792
221905
|
}),
|
|
221793
221906
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
221794
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
221907
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
221795
221908
|
name: "fetch",
|
|
221796
221909
|
path: options.client.importPath
|
|
221797
221910
|
}),
|
|
@@ -221810,7 +221923,7 @@ const queryGenerator$1 = createReactGenerator({
|
|
|
221810
221923
|
isTypeOnly: true
|
|
221811
221924
|
})
|
|
221812
221925
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
221813
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
221926
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
221814
221927
|
name: ["fetch"],
|
|
221815
221928
|
root: query.file.path,
|
|
221816
221929
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -222965,7 +223078,7 @@ const infiniteQueryGenerator = createReactGenerator({
|
|
|
222965
223078
|
path: zod.file.path
|
|
222966
223079
|
}),
|
|
222967
223080
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
222968
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
223081
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
222969
223082
|
name: "fetch",
|
|
222970
223083
|
path: options.client.importPath
|
|
222971
223084
|
}),
|
|
@@ -222984,7 +223097,7 @@ const infiniteQueryGenerator = createReactGenerator({
|
|
|
222984
223097
|
isTypeOnly: true
|
|
222985
223098
|
})
|
|
222986
223099
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
222987
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
223100
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
222988
223101
|
name: ["fetch"],
|
|
222989
223102
|
root: query.file.path,
|
|
222990
223103
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -223189,7 +223302,7 @@ const mutationGenerator = createReactGenerator({
|
|
|
223189
223302
|
path: zod.file.path
|
|
223190
223303
|
}),
|
|
223191
223304
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
223192
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
223305
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
223193
223306
|
name: "fetch",
|
|
223194
223307
|
path: options.client.importPath
|
|
223195
223308
|
}),
|
|
@@ -223208,7 +223321,7 @@ const mutationGenerator = createReactGenerator({
|
|
|
223208
223321
|
isTypeOnly: true
|
|
223209
223322
|
})
|
|
223210
223323
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
223211
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
223324
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
223212
223325
|
name: ["fetch"],
|
|
223213
223326
|
root: mutation.file.path,
|
|
223214
223327
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -223382,7 +223495,7 @@ const queryGenerator = createReactGenerator({
|
|
|
223382
223495
|
path: zod.file.path
|
|
223383
223496
|
}),
|
|
223384
223497
|
options.client.importPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
223385
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
223498
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
223386
223499
|
name: "fetch",
|
|
223387
223500
|
path: options.client.importPath
|
|
223388
223501
|
}),
|
|
@@ -223401,7 +223514,7 @@ const queryGenerator = createReactGenerator({
|
|
|
223401
223514
|
isTypeOnly: true
|
|
223402
223515
|
})
|
|
223403
223516
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
223404
|
-
/* @__PURE__ */ jsx(File.Import, {
|
|
223517
|
+
!shouldUseClientPlugin && /* @__PURE__ */ jsx(File.Import, {
|
|
223405
223518
|
name: ["fetch"],
|
|
223406
223519
|
root: query.file.path,
|
|
223407
223520
|
path: path$2.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
@@ -223690,20 +223803,41 @@ function resolvePlugins(plugins) {
|
|
|
223690
223803
|
});
|
|
223691
223804
|
}
|
|
223692
223805
|
|
|
223693
|
-
function
|
|
223694
|
-
|
|
223695
|
-
if (!
|
|
223696
|
-
|
|
223697
|
-
|
|
223698
|
-
|
|
223699
|
-
|
|
223700
|
-
|
|
223701
|
-
|
|
223702
|
-
|
|
223806
|
+
function mergePlugins(diskPlugins, studioPlugins) {
|
|
223807
|
+
if (!diskPlugins && !studioPlugins) return void 0;
|
|
223808
|
+
if (!studioPlugins) return diskPlugins;
|
|
223809
|
+
const resolvedStudio = resolvePlugins(studioPlugins);
|
|
223810
|
+
if (!diskPlugins) return resolvedStudio;
|
|
223811
|
+
const studioByName = new Map(resolvedStudio.map((p) => [p.name, p]));
|
|
223812
|
+
const diskNames = new Set(diskPlugins.map((p) => p.name));
|
|
223813
|
+
const mergedDisk = diskPlugins.map((diskPlugin) => {
|
|
223814
|
+
const studioPlugin = studioByName.get(diskPlugin.name);
|
|
223815
|
+
if (!studioPlugin) return diskPlugin;
|
|
223816
|
+
return { ...diskPlugin, options: mergeDeep(diskPlugin.options, studioPlugin.options) };
|
|
223817
|
+
});
|
|
223818
|
+
const studioOnly = resolvedStudio.filter((p) => !diskNames.has(p.name));
|
|
223819
|
+
return [...mergedDisk, ...studioOnly];
|
|
223703
223820
|
}
|
|
223704
|
-
|
|
223705
|
-
|
|
223706
|
-
|
|
223821
|
+
|
|
223822
|
+
function setupHookListener(events, root) {
|
|
223823
|
+
events.on("hook:start", async ({ id, command, args }) => {
|
|
223824
|
+
if (!id) {
|
|
223825
|
+
return;
|
|
223826
|
+
}
|
|
223827
|
+
const commandWithArgs = (args == null ? void 0 : args.length) ? `${command} ${args.join(" ")}` : command;
|
|
223828
|
+
try {
|
|
223829
|
+
const result = await x(command, [...args != null ? args : []], {
|
|
223830
|
+
nodeOptions: { cwd: root, detached: true },
|
|
223831
|
+
throwOnError: true
|
|
223832
|
+
});
|
|
223833
|
+
console.log(result.stdout.trimEnd());
|
|
223834
|
+
await events.emit("hook:end", { command, args, id, success: true, error: null });
|
|
223835
|
+
} catch (_err) {
|
|
223836
|
+
const errorMessage = new Error(`Hook execute failed: ${commandWithArgs}`);
|
|
223837
|
+
await events.emit("hook:end", { command, args, id, success: false, error: errorMessage });
|
|
223838
|
+
await events.emit("error", errorMessage);
|
|
223839
|
+
}
|
|
223840
|
+
});
|
|
223707
223841
|
}
|
|
223708
223842
|
|
|
223709
223843
|
const WEBSOCKET_READY = 1;
|
|
@@ -223835,7 +223969,165 @@ function setupEventsStream(ws, events) {
|
|
|
223835
223969
|
});
|
|
223836
223970
|
}
|
|
223837
223971
|
|
|
223838
|
-
|
|
223972
|
+
async function connectToStudio(options) {
|
|
223973
|
+
var _a;
|
|
223974
|
+
const {
|
|
223975
|
+
token,
|
|
223976
|
+
studioUrl,
|
|
223977
|
+
configPath,
|
|
223978
|
+
resolvedConfigPath,
|
|
223979
|
+
noCache,
|
|
223980
|
+
allowAll,
|
|
223981
|
+
allowWrite,
|
|
223982
|
+
root,
|
|
223983
|
+
retryInterval,
|
|
223984
|
+
heartbeatInterval = 3e4,
|
|
223985
|
+
initialSession,
|
|
223986
|
+
sessionKey,
|
|
223987
|
+
nitro
|
|
223988
|
+
} = options;
|
|
223989
|
+
const events = new AsyncEventEmitter();
|
|
223990
|
+
const maskedSessionKey = maskedString(sessionKey.replace("sessions:", ""));
|
|
223991
|
+
async function removeSession() {
|
|
223992
|
+
if (!noCache) {
|
|
223993
|
+
await removeCachedSession(sessionKey);
|
|
223994
|
+
}
|
|
223995
|
+
}
|
|
223996
|
+
async function reconnect() {
|
|
223997
|
+
logger.info(`[${maskedSessionKey}] Retrying connection in ${formatMs(retryInterval)} to Kubb Studio ...`);
|
|
223998
|
+
await removeSession();
|
|
223999
|
+
setTimeout(() => connectToStudio({ ...options, initialSession: void 0 }), retryInterval);
|
|
224000
|
+
}
|
|
224001
|
+
try {
|
|
224002
|
+
setupHookListener(events, root);
|
|
224003
|
+
const { sessionId, wsUrl, isSandbox } = initialSession != null ? initialSession : await createAgentSession({ noCache, token, studioUrl, cacheKey: sessionKey });
|
|
224004
|
+
const ws = createWebsocket(wsUrl, { headers: { Authorization: `Bearer ${token}` } });
|
|
224005
|
+
const maskedWsUrl = maskedString(wsUrl);
|
|
224006
|
+
const effectiveAllowAll = isSandbox ? false : allowAll;
|
|
224007
|
+
const effectiveWrite = isSandbox ? false : allowWrite;
|
|
224008
|
+
let serverDisconnected = false;
|
|
224009
|
+
let heartbeatTimer;
|
|
224010
|
+
async function cleanup(reason = "cleanup") {
|
|
224011
|
+
try {
|
|
224012
|
+
clearInterval(heartbeatTimer);
|
|
224013
|
+
heartbeatTimer = void 0;
|
|
224014
|
+
events.removeAll();
|
|
224015
|
+
ws.close(1e3, reason);
|
|
224016
|
+
ws.removeEventListener("open", onOpen);
|
|
224017
|
+
ws.removeEventListener("close", onClose);
|
|
224018
|
+
ws.removeEventListener("error", onError);
|
|
224019
|
+
} catch (_error) {
|
|
224020
|
+
}
|
|
224021
|
+
}
|
|
224022
|
+
const onOpen = () => {
|
|
224023
|
+
logger.success(`[${maskedSessionKey}] Connected to Kubb Studio on "${maskedWsUrl}"`);
|
|
224024
|
+
};
|
|
224025
|
+
const onClose = async () => {
|
|
224026
|
+
if (serverDisconnected) {
|
|
224027
|
+
return;
|
|
224028
|
+
}
|
|
224029
|
+
serverDisconnected = true;
|
|
224030
|
+
await cleanup();
|
|
224031
|
+
await disconnect({ sessionId, studioUrl, token }).catch(() => {
|
|
224032
|
+
});
|
|
224033
|
+
await reconnect();
|
|
224034
|
+
};
|
|
224035
|
+
const onError = async () => {
|
|
224036
|
+
logger.error(`[${maskedSessionKey}] Failed to connect to Kubb Studio on "${maskedWsUrl}"`);
|
|
224037
|
+
await cleanup();
|
|
224038
|
+
await reconnect();
|
|
224039
|
+
};
|
|
224040
|
+
ws.addEventListener("open", onOpen);
|
|
224041
|
+
ws.addEventListener("close", onClose);
|
|
224042
|
+
ws.addEventListener("error", onError);
|
|
224043
|
+
nitro.hooks.hook("close", async () => {
|
|
224044
|
+
await cleanup();
|
|
224045
|
+
await disconnect({ sessionId, studioUrl, token }).catch(() => {
|
|
224046
|
+
});
|
|
224047
|
+
});
|
|
224048
|
+
heartbeatTimer = setInterval(() => sendAgentMessage(ws, { type: "ping" }), heartbeatInterval);
|
|
224049
|
+
setupEventsStream(ws, events);
|
|
224050
|
+
ws.addEventListener("message", async (message) => {
|
|
224051
|
+
var _a2, _b, _c;
|
|
224052
|
+
try {
|
|
224053
|
+
const data = JSON.parse(message.data);
|
|
224054
|
+
logger.info(`[${maskedSessionKey}] Received "${data.type}" from Studio`);
|
|
224055
|
+
if (isPongMessage(data)) {
|
|
224056
|
+
return;
|
|
224057
|
+
}
|
|
224058
|
+
if (isDisconnectMessage(data)) {
|
|
224059
|
+
logger.warn(`[${maskedSessionKey}] Agent session disconnected by Studio with reason: ${data.reason}`);
|
|
224060
|
+
if (data.reason === "revoked") {
|
|
224061
|
+
await cleanup(`session_${data.reason}`);
|
|
224062
|
+
await removeSession();
|
|
224063
|
+
return;
|
|
224064
|
+
}
|
|
224065
|
+
if (data.reason === "expired") {
|
|
224066
|
+
await cleanup();
|
|
224067
|
+
await reconnect();
|
|
224068
|
+
return;
|
|
224069
|
+
}
|
|
224070
|
+
return;
|
|
224071
|
+
}
|
|
224072
|
+
if (isCommandMessage(data)) {
|
|
224073
|
+
if (data.command === "generate") {
|
|
224074
|
+
const config = await loadConfig(resolvedConfigPath);
|
|
224075
|
+
const patch = data.payload;
|
|
224076
|
+
const plugins = mergePlugins(config.plugins, patch == null ? void 0 : patch.plugins);
|
|
224077
|
+
const inputOverride = isSandbox ? { data: (_a2 = patch == null ? void 0 : patch.input) != null ? _a2 : "" } : void 0;
|
|
224078
|
+
if (allowWrite && isSandbox) {
|
|
224079
|
+
logger.warn(`[${maskedSessionKey}] Agent is running in a sandbox environment, write will be disabled`);
|
|
224080
|
+
}
|
|
224081
|
+
if ((patch == null ? void 0 : patch.input) && !isSandbox) {
|
|
224082
|
+
logger.warn(`[${maskedSessionKey}] Input override via payload is only supported in sandbox mode and will be ignored`);
|
|
224083
|
+
}
|
|
224084
|
+
if (data.payload && effectiveWrite) {
|
|
224085
|
+
await saveStudioConfigToStorage({ sessionKey, config: data.payload }).catch((err) => {
|
|
224086
|
+
logger.warn(`[${maskedSessionKey}] Failed to save studio config: ${err == null ? void 0 : err.message}`);
|
|
224087
|
+
});
|
|
224088
|
+
}
|
|
224089
|
+
await generate({
|
|
224090
|
+
config: {
|
|
224091
|
+
...config,
|
|
224092
|
+
root,
|
|
224093
|
+
input: inputOverride != null ? inputOverride : config.input,
|
|
224094
|
+
output: { ...config.output, write: effectiveWrite },
|
|
224095
|
+
plugins
|
|
224096
|
+
},
|
|
224097
|
+
events
|
|
224098
|
+
});
|
|
224099
|
+
logger.success(`[${maskedSessionKey}] Completed "${data.type}" from Studio`);
|
|
224100
|
+
return;
|
|
224101
|
+
}
|
|
224102
|
+
if (data.command === "connect") {
|
|
224103
|
+
const config = await loadConfig(resolvedConfigPath);
|
|
224104
|
+
sendAgentMessage(ws, {
|
|
224105
|
+
type: "connected",
|
|
224106
|
+
payload: {
|
|
224107
|
+
version,
|
|
224108
|
+
configPath,
|
|
224109
|
+
permissions: { allowAll: effectiveAllowAll, allowWrite: effectiveWrite },
|
|
224110
|
+
config: {
|
|
224111
|
+
plugins: (_b = config.plugins) == null ? void 0 : _b.map((plugin) => ({
|
|
224112
|
+
name: `@kubb/${plugin.name}`,
|
|
224113
|
+
options: serializePluginOptions(plugin.options)
|
|
224114
|
+
}))
|
|
224115
|
+
}
|
|
224116
|
+
}
|
|
224117
|
+
});
|
|
224118
|
+
logger.success(`[${maskedSessionKey}] Completed "${data.type}" from Studio`);
|
|
224119
|
+
return;
|
|
224120
|
+
}
|
|
224121
|
+
}
|
|
224122
|
+
logger.warn(`[${maskedSessionKey}] Unknown message type from Kubb Studio: ${message.data}`);
|
|
224123
|
+
} catch (error) {
|
|
224124
|
+
logger.error(`[${maskedSessionKey}] [unhandledRejection] ${(_c = error == null ? void 0 : error.message) != null ? _c : error}`);
|
|
224125
|
+
}
|
|
224126
|
+
});
|
|
224127
|
+
} catch (error) {
|
|
224128
|
+
throw new Error(`[unhandledRejection] ${(_a = error == null ? void 0 : error.message) != null ? _a : error}`, { cause: error });
|
|
224129
|
+
}
|
|
224130
|
+
}
|
|
223839
224131
|
|
|
223840
224132
|
const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nitro) => {
|
|
223841
224133
|
const studioUrl = process$1.env.KUBB_STUDIO_URL || "https://studio.kubb.dev";
|
|
@@ -223843,196 +224135,70 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
223843
224135
|
const configPath = process$1.env.KUBB_AGENT_CONFIG || "kubb.config.ts";
|
|
223844
224136
|
const noCache = process$1.env.KUBB_AGENT_NO_CACHE === "true";
|
|
223845
224137
|
const retryInterval = process$1.env.KUBB_AGENT_RETRY_TIMEOUT ? Number.parseInt(process$1.env.KUBB_AGENT_RETRY_TIMEOUT, 10) : 3e4;
|
|
224138
|
+
const heartbeatInterval = process$1.env.KUBB_AGENT_HEARTBEAT_INTERVAL ? Number.parseInt(process$1.env.KUBB_AGENT_HEARTBEAT_INTERVAL, 10) : 3e4;
|
|
223846
224139
|
const root = process$1.env.KUBB_AGENT_ROOT || process$1.cwd();
|
|
223847
224140
|
const allowAll = process$1.env.KUBB_AGENT_ALLOW_ALL === "true";
|
|
223848
224141
|
const allowWrite = allowAll || process$1.env.KUBB_AGENT_ALLOW_WRITE === "true";
|
|
224142
|
+
const poolSize = process$1.env.KUBB_AGENT_POOL_SIZE ? Number.parseInt(process$1.env.KUBB_AGENT_POOL_SIZE, 10) : 1;
|
|
223849
224143
|
if (!token) {
|
|
223850
224144
|
logger.warn("KUBB_AGENT_TOKEN not set", "cannot authenticate with studio");
|
|
223851
224145
|
return null;
|
|
223852
224146
|
}
|
|
224147
|
+
if (!process$1.env.KUBB_AGENT_SECRET) {
|
|
224148
|
+
logger.warn("KUBB_AGENT_SECRET not set", "secret should be set");
|
|
224149
|
+
}
|
|
223853
224150
|
const resolvedConfigPath = path$2.isAbsolute(configPath) ? configPath : path$2.resolve(root, configPath);
|
|
223854
|
-
const events = new AsyncEventEmitter();
|
|
223855
224151
|
const storage = useStorage("kubb");
|
|
223856
|
-
|
|
223857
|
-
|
|
223858
|
-
|
|
223859
|
-
|
|
223860
|
-
|
|
223861
|
-
|
|
223862
|
-
|
|
223863
|
-
|
|
223864
|
-
|
|
223865
|
-
|
|
223866
|
-
|
|
223867
|
-
|
|
223868
|
-
|
|
223869
|
-
|
|
223870
|
-
|
|
223871
|
-
|
|
223872
|
-
|
|
223873
|
-
|
|
223874
|
-
|
|
223875
|
-
|
|
223876
|
-
|
|
223877
|
-
|
|
223878
|
-
|
|
223879
|
-
|
|
223880
|
-
|
|
223881
|
-
|
|
223882
|
-
|
|
223883
|
-
try {
|
|
223884
|
-
const result = await x(command, [...args != null ? args : []], {
|
|
223885
|
-
nodeOptions: { cwd: root, detached: true },
|
|
223886
|
-
throwOnError: true
|
|
223887
|
-
});
|
|
223888
|
-
console.log(result.stdout.trimEnd());
|
|
223889
|
-
await events.emit("hook:end", {
|
|
223890
|
-
command,
|
|
223891
|
-
args,
|
|
223892
|
-
id,
|
|
223893
|
-
success: true,
|
|
223894
|
-
error: null
|
|
223895
|
-
});
|
|
223896
|
-
} catch (_err) {
|
|
223897
|
-
const errorMessage = new Error(`Hook execute failed: ${commandWithArgs}`);
|
|
223898
|
-
await events.emit("hook:end", {
|
|
223899
|
-
command,
|
|
223900
|
-
args,
|
|
223901
|
-
id,
|
|
223902
|
-
success: false,
|
|
223903
|
-
error: errorMessage
|
|
223904
|
-
});
|
|
223905
|
-
await events.emit("error", errorMessage);
|
|
223906
|
-
}
|
|
223907
|
-
});
|
|
223908
|
-
const { sessionToken, wsUrl, isSandbox } = await createAgentSession({
|
|
223909
|
-
noCache,
|
|
223910
|
-
token,
|
|
223911
|
-
studioUrl
|
|
224152
|
+
const sessionKey = getSessionKey(token);
|
|
224153
|
+
const maskedSessionKey = maskedString(sessionKey.replace("sessions:", ""));
|
|
224154
|
+
try {
|
|
224155
|
+
await registerAgent({ token, studioUrl, poolSize });
|
|
224156
|
+
const baseOptions = {
|
|
224157
|
+
token,
|
|
224158
|
+
studioUrl,
|
|
224159
|
+
configPath,
|
|
224160
|
+
resolvedConfigPath,
|
|
224161
|
+
noCache,
|
|
224162
|
+
allowAll,
|
|
224163
|
+
allowWrite,
|
|
224164
|
+
root,
|
|
224165
|
+
retryInterval,
|
|
224166
|
+
heartbeatInterval,
|
|
224167
|
+
storage,
|
|
224168
|
+
sessionKey,
|
|
224169
|
+
nitro
|
|
224170
|
+
};
|
|
224171
|
+
logger.info(`[${maskedSessionKey}] Starting session pool of ${poolSize} connection(s)`);
|
|
224172
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
224173
|
+
for (const index2 of Array.from({ length: poolSize }, (_, i) => i)) {
|
|
224174
|
+
const cacheKey = `${sessionKey}-${index2}`;
|
|
224175
|
+
const maskedSessionKey2 = maskedString(cacheKey);
|
|
224176
|
+
const session = await createAgentSession({ noCache, token, studioUrl, cacheKey }).catch((err) => {
|
|
224177
|
+
logger.warn(`[${maskedSessionKey2}] Failed to pre-create pool session:`, err == null ? void 0 : err.message);
|
|
224178
|
+
return null;
|
|
223912
224179
|
});
|
|
223913
|
-
|
|
223914
|
-
|
|
223915
|
-
|
|
223916
|
-
|
|
223917
|
-
|
|
223918
|
-
|
|
223919
|
-
|
|
223920
|
-
|
|
223921
|
-
|
|
223922
|
-
|
|
223923
|
-
|
|
223924
|
-
}
|
|
223925
|
-
};
|
|
223926
|
-
const onOpen = () => {
|
|
223927
|
-
logger.success(`Connected to Kubb Studio on "${wsUrl}"`);
|
|
223928
|
-
};
|
|
223929
|
-
const onClose = async () => {
|
|
223930
|
-
cleanup();
|
|
223931
|
-
logger.info("Disconnecting from Studio ...");
|
|
223932
|
-
if (sessionToken) {
|
|
223933
|
-
await disconnect({
|
|
223934
|
-
sessionToken,
|
|
223935
|
-
studioUrl,
|
|
223936
|
-
token
|
|
223937
|
-
}).catch(async () => {
|
|
223938
|
-
});
|
|
223939
|
-
await storage.removeItem(getSessionKey(token));
|
|
223940
|
-
await reconnectToStudio();
|
|
223941
|
-
}
|
|
223942
|
-
};
|
|
223943
|
-
const cleanup = () => {
|
|
223944
|
-
ws.removeEventListener("open", onOpen);
|
|
223945
|
-
ws.removeEventListener("close", onClose);
|
|
223946
|
-
ws.removeEventListener("error", onError);
|
|
223947
|
-
};
|
|
223948
|
-
ws.addEventListener("open", onOpen);
|
|
223949
|
-
ws.addEventListener("close", onClose);
|
|
223950
|
-
ws.addEventListener("error", onError);
|
|
223951
|
-
nitro.hooks.hook("close", onClose);
|
|
223952
|
-
setInterval(() => {
|
|
223953
|
-
sendAgentMessage(ws, {
|
|
223954
|
-
type: "ping"
|
|
223955
|
-
});
|
|
223956
|
-
}, 3e4);
|
|
223957
|
-
setupEventsStream(ws, events);
|
|
223958
|
-
ws.addEventListener("message", async (message) => {
|
|
223959
|
-
var _a, _b, _c, _d;
|
|
223960
|
-
try {
|
|
223961
|
-
const data = JSON.parse(message.data);
|
|
223962
|
-
if (isPongMessage(data)) {
|
|
223963
|
-
logger.info("Received pong from Studio");
|
|
223964
|
-
return;
|
|
223965
|
-
}
|
|
223966
|
-
if (isCommandMessage(data)) {
|
|
223967
|
-
if (data.command === "generate") {
|
|
223968
|
-
const config = await loadConfig();
|
|
223969
|
-
const studioConfig = readStudioConfig(resolvedConfigPath);
|
|
223970
|
-
const patch = (_a = data.payload) != null ? _a : studioConfig;
|
|
223971
|
-
const resolvedPlugins = (patch == null ? void 0 : patch.plugins) ? resolvePlugins(patch.plugins) : void 0;
|
|
223972
|
-
if (allowWrite && isSandbox) {
|
|
223973
|
-
logger.warn("Agent is running in a sandbox environment, write will be disabled");
|
|
223974
|
-
}
|
|
223975
|
-
if ((patch == null ? void 0 : patch.input) && !isSandbox) {
|
|
223976
|
-
logger.warn("Input override via payload is only supported in sandbox mode and will be ignored");
|
|
223977
|
-
}
|
|
223978
|
-
const inputOverride = isSandbox ? { data: (_b = patch.input) != null ? _b : "" } : void 0;
|
|
223979
|
-
await generate({
|
|
223980
|
-
config: {
|
|
223981
|
-
...config,
|
|
223982
|
-
input: inputOverride != null ? inputOverride : config.input,
|
|
223983
|
-
plugins: resolvedPlugins != null ? resolvedPlugins : config.plugins,
|
|
223984
|
-
root,
|
|
223985
|
-
output: {
|
|
223986
|
-
...config.output,
|
|
223987
|
-
write: isSandbox ? false : allowWrite
|
|
223988
|
-
}
|
|
223989
|
-
},
|
|
223990
|
-
events
|
|
223991
|
-
});
|
|
223992
|
-
if (allowWrite) {
|
|
223993
|
-
writeStudioConfig(resolvedConfigPath, data.payload);
|
|
223994
|
-
}
|
|
223995
|
-
logger.success("Generated command success");
|
|
223996
|
-
}
|
|
223997
|
-
if (data.command === "connect") {
|
|
223998
|
-
const config = await loadConfig();
|
|
223999
|
-
sendAgentMessage(ws, {
|
|
224000
|
-
type: "connected",
|
|
224001
|
-
payload: {
|
|
224002
|
-
version,
|
|
224003
|
-
configPath,
|
|
224004
|
-
permissions: {
|
|
224005
|
-
allowAll: isSandbox ? false : allowWrite,
|
|
224006
|
-
allowWrite: isSandbox ? false : allowWrite
|
|
224007
|
-
},
|
|
224008
|
-
config: {
|
|
224009
|
-
plugins: (_c = config.plugins) == null ? void 0 : _c.map((plugin) => ({
|
|
224010
|
-
name: `@kubb/${plugin.name}`,
|
|
224011
|
-
options: serializePluginOptions(plugin.options)
|
|
224012
|
-
}))
|
|
224013
|
-
}
|
|
224014
|
-
}
|
|
224015
|
-
});
|
|
224016
|
-
}
|
|
224017
|
-
return;
|
|
224018
|
-
}
|
|
224019
|
-
logger.warn(`Unknown message type from Kubb Studio: ${message.data}`);
|
|
224020
|
-
} catch (error) {
|
|
224021
|
-
logger.error(`[unhandledRejection] ${(_d = error == null ? void 0 : error.message) != null ? _d : error}`);
|
|
224022
|
-
}
|
|
224180
|
+
sessions.set(cacheKey, session);
|
|
224181
|
+
}
|
|
224182
|
+
let index = 0;
|
|
224183
|
+
for (const [cacheKey, session] of sessions) {
|
|
224184
|
+
index++;
|
|
224185
|
+
if (!session) {
|
|
224186
|
+
continue;
|
|
224187
|
+
}
|
|
224188
|
+
const maskedSessionKey2 = maskedString(session.sessionId);
|
|
224189
|
+
logger.info(`[${maskedSessionKey2}] Connecting session ${index}/${sessions.size}`);
|
|
224190
|
+
await connectToStudio({ ...baseOptions, initialSession: session, sessionKey: cacheKey }).catch((err) => {
|
|
224191
|
+
logger.warn(`[${maskedSessionKey2}] Session ${index} failed to connect:`, err == null ? void 0 : err.message);
|
|
224023
224192
|
});
|
|
224024
|
-
} catch (error) {
|
|
224025
|
-
await storage.removeItem(getSessionKey(token));
|
|
224026
|
-
logger.error(`Something went wrong ${error}`);
|
|
224027
|
-
await reconnectToStudio();
|
|
224028
224193
|
}
|
|
224194
|
+
} catch (error) {
|
|
224195
|
+
logger.error("Failed to connect to Kubb Studio\n", error == null ? void 0 : error.message);
|
|
224029
224196
|
}
|
|
224030
|
-
await registerAgent({ token, studioUrl });
|
|
224031
|
-
await connectToStudio();
|
|
224032
224197
|
});
|
|
224033
224198
|
|
|
224034
224199
|
const plugins = [
|
|
224035
224200
|
_KZ9YuROWp70nNn4X1C4BxF_W0D7H9EWgBo03XvMd7w0,
|
|
224201
|
+
_a2VEEUGb5K4b1gyM9hOmO1Xz0hUJSFuGyIT3cHsvE,
|
|
224036
224202
|
_zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E
|
|
224037
224203
|
];
|
|
224038
224204
|
|