@kubb/agent 4.31.6 → 4.32.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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +174 -247
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/node_modules/@clack/core/dist/index.mjs +6 -6
- package/.output/server/node_modules/@clack/core/package.json +1 -2
- package/.output/server/node_modules/@clack/prompts/dist/index.mjs +106 -106
- package/.output/server/node_modules/@clack/prompts/package.json +2 -3
- package/.output/server/package.json +3 -3
- package/README.md +0 -2
- package/package.json +16 -16
|
@@ -4478,52 +4478,6 @@ const _a2VEEUGb5K4b1gyM9hOmO1Xz0hUJSFuGyIT3cHsvE = defineNitroPlugin((nitro) =>
|
|
|
4478
4478
|
});
|
|
4479
4479
|
});
|
|
4480
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
4481
|
function generateToken() {
|
|
4528
4482
|
return randomBytes(32).toString("hex");
|
|
4529
4483
|
}
|
|
@@ -4536,22 +4490,11 @@ function getMachineToken() {
|
|
|
4536
4490
|
return hashToken((_a = process.env.KUBB_AGENT_SECRET) != null ? _a : _fallbackSecret);
|
|
4537
4491
|
}
|
|
4538
4492
|
|
|
4539
|
-
async function createAgentSession({ token, studioUrl
|
|
4540
|
-
const
|
|
4541
|
-
const maskedSessionKey = maskedString(sessionKey.replace("sessions:", ""));
|
|
4542
|
-
const connectUrl = `${studioUrl}/api/agent/session/create`;
|
|
4543
|
-
const canCache = !noCache;
|
|
4544
|
-
if (canCache) {
|
|
4545
|
-
const cachedSession = await getCachedSession(sessionKey);
|
|
4546
|
-
if (cachedSession) {
|
|
4547
|
-
logger.success(`[${maskedSessionKey}] Using cached agent session`);
|
|
4548
|
-
return cachedSession;
|
|
4549
|
-
}
|
|
4550
|
-
await removeCachedSession(sessionKey);
|
|
4551
|
-
}
|
|
4493
|
+
async function createAgentSession({ token, studioUrl }) {
|
|
4494
|
+
const url = `${studioUrl}/api/agent/session/create`;
|
|
4552
4495
|
try {
|
|
4553
|
-
logger.info(
|
|
4554
|
-
const data = await $fetch(
|
|
4496
|
+
logger.info("Creating agent session with Studio...");
|
|
4497
|
+
const data = await $fetch(url, {
|
|
4555
4498
|
method: "POST",
|
|
4556
4499
|
headers: { Authorization: `Bearer ${token}` },
|
|
4557
4500
|
body: { machineToken: getMachineToken() }
|
|
@@ -4559,11 +4502,7 @@ async function createAgentSession({ token, studioUrl, noCache, cacheKey }) {
|
|
|
4559
4502
|
if (!data) {
|
|
4560
4503
|
throw new Error("No data available for agent session");
|
|
4561
4504
|
}
|
|
4562
|
-
|
|
4563
|
-
await cacheSession({ sessionKey, session: { ...data, storedAt: (/* @__PURE__ */ new Date()).toISOString(), configs: [] } });
|
|
4564
|
-
logger.success(`[${maskedSessionKey}] Saved agent session to cache`);
|
|
4565
|
-
}
|
|
4566
|
-
logger.info(`[${maskedSessionKey}] Created agent session with Studio`);
|
|
4505
|
+
logger.info("Created agent session with Studio");
|
|
4567
4506
|
return data;
|
|
4568
4507
|
} catch (error) {
|
|
4569
4508
|
throw new Error("Failed to get agent session from Kubb Studio", { cause: error });
|
|
@@ -4571,10 +4510,10 @@ async function createAgentSession({ token, studioUrl, noCache, cacheKey }) {
|
|
|
4571
4510
|
}
|
|
4572
4511
|
async function registerAgent({ token, studioUrl, poolSize }) {
|
|
4573
4512
|
var _a, _b;
|
|
4574
|
-
const
|
|
4513
|
+
const url = `${studioUrl}/api/agent/connect`;
|
|
4575
4514
|
try {
|
|
4576
4515
|
logger.info("Registering agent with Studio...");
|
|
4577
|
-
await $fetch(
|
|
4516
|
+
await $fetch(url, {
|
|
4578
4517
|
method: "POST",
|
|
4579
4518
|
headers: {
|
|
4580
4519
|
Authorization: `Bearer ${token}`
|
|
@@ -4587,11 +4526,11 @@ async function registerAgent({ token, studioUrl, poolSize }) {
|
|
|
4587
4526
|
}
|
|
4588
4527
|
}
|
|
4589
4528
|
async function disconnect({ sessionId, token, studioUrl }) {
|
|
4590
|
-
const
|
|
4529
|
+
const url = `${studioUrl}/api/agent/session/${sessionId}/disconnect`;
|
|
4591
4530
|
const maskedSessionKey = maskedString(sessionId);
|
|
4592
4531
|
try {
|
|
4593
4532
|
logger.info(`[${maskedSessionKey}] Disconnecting from Studio...`);
|
|
4594
|
-
await $fetch(
|
|
4533
|
+
await $fetch(url, {
|
|
4595
4534
|
method: "POST",
|
|
4596
4535
|
headers: {
|
|
4597
4536
|
Authorization: `Bearer ${token}`
|
|
@@ -4884,6 +4823,26 @@ function toRegExpString(text, func = "RegExp") {
|
|
|
4884
4823
|
if (func === null) return `/${source}/${flags}`;
|
|
4885
4824
|
return `new ${func}(${JSON.stringify(source)}${flags ? `, ${JSON.stringify(flags)}` : ""})`;
|
|
4886
4825
|
}
|
|
4826
|
+
var transformers_default = {
|
|
4827
|
+
combineCodes,
|
|
4828
|
+
escape,
|
|
4829
|
+
jsStringEscape,
|
|
4830
|
+
createIndent,
|
|
4831
|
+
transformReservedWord,
|
|
4832
|
+
isValidVarName,
|
|
4833
|
+
nameSorter,
|
|
4834
|
+
searchAndReplace,
|
|
4835
|
+
stringify,
|
|
4836
|
+
stringifyObject,
|
|
4837
|
+
toRegExpString,
|
|
4838
|
+
trim,
|
|
4839
|
+
trimQuotes,
|
|
4840
|
+
JSDoc: { createJSDocBlockText },
|
|
4841
|
+
camelCase,
|
|
4842
|
+
pascalCase,
|
|
4843
|
+
snakeCase,
|
|
4844
|
+
screamingSnakeCase
|
|
4845
|
+
};
|
|
4887
4846
|
|
|
4888
4847
|
var __defProp$9 = Object.defineProperty;
|
|
4889
4848
|
var __typeError$5 = (msg) => {
|
|
@@ -6076,7 +6035,7 @@ function tokenize(command) {
|
|
|
6076
6035
|
return args;
|
|
6077
6036
|
}
|
|
6078
6037
|
|
|
6079
|
-
var version = "4.
|
|
6038
|
+
var version = "4.32.1";
|
|
6080
6039
|
|
|
6081
6040
|
function isCommandMessage(msg) {
|
|
6082
6041
|
return msg.type === "command";
|
|
@@ -6091,6 +6050,24 @@ function isPublishCommandMessage(msg) {
|
|
|
6091
6050
|
return msg.type === "command" && msg.command === "publish";
|
|
6092
6051
|
}
|
|
6093
6052
|
|
|
6053
|
+
function getStorage() {
|
|
6054
|
+
return useStorage("kubb");
|
|
6055
|
+
}
|
|
6056
|
+
async function saveStudioConfigToStorage({ sessionId, config }) {
|
|
6057
|
+
var _a;
|
|
6058
|
+
const storage = getStorage();
|
|
6059
|
+
const key = `configs:${sessionId}`;
|
|
6060
|
+
const existing = (_a = await storage.getItem(key)) != null ? _a : [];
|
|
6061
|
+
await storage.setItem(key, [...existing, { config, storedAt: (/* @__PURE__ */ new Date()).toISOString() }]);
|
|
6062
|
+
}
|
|
6063
|
+
async function getLatestStudioConfigFromStorage({ sessionId }) {
|
|
6064
|
+
const storage = getStorage();
|
|
6065
|
+
const key = `configs:${sessionId}`;
|
|
6066
|
+
const existing = await storage.getItem(key);
|
|
6067
|
+
if (!(existing == null ? void 0 : existing.length)) return null;
|
|
6068
|
+
return existing[existing.length - 1].config;
|
|
6069
|
+
}
|
|
6070
|
+
|
|
6094
6071
|
var __typeError$3 = (msg) => {
|
|
6095
6072
|
throw TypeError(msg);
|
|
6096
6073
|
};
|
|
@@ -6124,7 +6101,7 @@ var BaseGenerator = (_a$3 = class {
|
|
|
6124
6101
|
function isInputPath(config) {
|
|
6125
6102
|
return typeof (config == null ? void 0 : config.input) === "object" && config.input !== null && "path" in config.input;
|
|
6126
6103
|
}
|
|
6127
|
-
var version$1 = "4.
|
|
6104
|
+
var version$1 = "4.32.1";
|
|
6128
6105
|
function getDiagnosticInfo() {
|
|
6129
6106
|
return {
|
|
6130
6107
|
nodeVersion: version$2,
|
|
@@ -6670,27 +6647,6 @@ function isKeyword(meta, keyword) {
|
|
|
6670
6647
|
return meta.keyword === keyword;
|
|
6671
6648
|
}
|
|
6672
6649
|
|
|
6673
|
-
var transformers_default = {
|
|
6674
|
-
combineCodes,
|
|
6675
|
-
escape,
|
|
6676
|
-
jsStringEscape,
|
|
6677
|
-
createIndent,
|
|
6678
|
-
transformReservedWord,
|
|
6679
|
-
isValidVarName,
|
|
6680
|
-
nameSorter,
|
|
6681
|
-
searchAndReplace,
|
|
6682
|
-
stringify,
|
|
6683
|
-
stringifyObject,
|
|
6684
|
-
toRegExpString,
|
|
6685
|
-
trim,
|
|
6686
|
-
trimQuotes,
|
|
6687
|
-
JSDoc: { createJSDocBlockText },
|
|
6688
|
-
camelCase,
|
|
6689
|
-
pascalCase,
|
|
6690
|
-
snakeCase,
|
|
6691
|
-
screamingSnakeCase
|
|
6692
|
-
};
|
|
6693
|
-
|
|
6694
6650
|
var __create = Object.create;
|
|
6695
6651
|
var __defProp$7 = Object.defineProperty;
|
|
6696
6652
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -6701,28 +6657,20 @@ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
|
6701
6657
|
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
6702
6658
|
var __exportAll = (all, no_symbols) => {
|
|
6703
6659
|
let target = {};
|
|
6704
|
-
for (var name in all) {
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
}
|
|
6710
|
-
{
|
|
6711
|
-
__defProp$7(target, Symbol.toStringTag, { value: "Module" });
|
|
6712
|
-
}
|
|
6660
|
+
for (var name in all) __defProp$7(target, name, {
|
|
6661
|
+
get: all[name],
|
|
6662
|
+
enumerable: true
|
|
6663
|
+
});
|
|
6664
|
+
__defProp$7(target, Symbol.toStringTag, { value: "Module" });
|
|
6713
6665
|
return target;
|
|
6714
6666
|
};
|
|
6715
6667
|
var __copyProps = (to, from, except, desc) => {
|
|
6716
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
6723
|
-
});
|
|
6724
|
-
}
|
|
6725
|
-
}
|
|
6668
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
6669
|
+
key = keys[i];
|
|
6670
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp$7(to, key, {
|
|
6671
|
+
get: ((k) => from[k]).bind(null, key),
|
|
6672
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
6673
|
+
});
|
|
6726
6674
|
}
|
|
6727
6675
|
return to;
|
|
6728
6676
|
};
|
|
@@ -7631,8 +7579,7 @@ var require_schema = /* @__PURE__ */ __commonJSMin(((exports$1) => {
|
|
|
7631
7579
|
};
|
|
7632
7580
|
}));
|
|
7633
7581
|
var require_str = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7634
|
-
|
|
7635
|
-
module.exports = new type_1.Type("tag:yaml.org,2002:str", {
|
|
7582
|
+
module.exports = new (require_type()).Type("tag:yaml.org,2002:str", {
|
|
7636
7583
|
kind: "scalar",
|
|
7637
7584
|
construct: function(data) {
|
|
7638
7585
|
return null !== data ? data : "";
|
|
@@ -7640,8 +7587,7 @@ var require_str = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
|
7640
7587
|
});
|
|
7641
7588
|
}));
|
|
7642
7589
|
var require_seq = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7643
|
-
|
|
7644
|
-
module.exports = new type_1.Type("tag:yaml.org,2002:seq", {
|
|
7590
|
+
module.exports = new (require_type()).Type("tag:yaml.org,2002:seq", {
|
|
7645
7591
|
kind: "sequence",
|
|
7646
7592
|
construct: function(data) {
|
|
7647
7593
|
return null !== data ? data : [];
|
|
@@ -7649,8 +7595,7 @@ var require_seq = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
|
7649
7595
|
});
|
|
7650
7596
|
}));
|
|
7651
7597
|
var require_map = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7652
|
-
|
|
7653
|
-
module.exports = new type_1.Type("tag:yaml.org,2002:map", {
|
|
7598
|
+
module.exports = new (require_type()).Type("tag:yaml.org,2002:map", {
|
|
7654
7599
|
kind: "mapping",
|
|
7655
7600
|
construct: function(data) {
|
|
7656
7601
|
return null !== data ? data : {};
|
|
@@ -7658,8 +7603,7 @@ var require_map = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
|
7658
7603
|
});
|
|
7659
7604
|
}));
|
|
7660
7605
|
var require_failsafe = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7661
|
-
|
|
7662
|
-
module.exports = new schema_1.Schema({ explicit: [
|
|
7606
|
+
module.exports = new (require_schema()).Schema({ explicit: [
|
|
7663
7607
|
require_str(),
|
|
7664
7608
|
require_seq(),
|
|
7665
7609
|
require_map()
|
|
@@ -7866,7 +7810,7 @@ var require_int = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
|
7866
7810
|
var require_float = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7867
7811
|
const common = require_common();
|
|
7868
7812
|
const type_1 = require_type();
|
|
7869
|
-
var YAML_FLOAT_PATTERN = new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
7813
|
+
var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
7870
7814
|
function resolveYamlFloat(data) {
|
|
7871
7815
|
if (null === data) return false;
|
|
7872
7816
|
if (!YAML_FLOAT_PATTERN.test(data)) return false;
|
|
@@ -7935,8 +7879,7 @@ var require_float = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
|
7935
7879
|
});
|
|
7936
7880
|
}));
|
|
7937
7881
|
var require_json = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7938
|
-
|
|
7939
|
-
module.exports = new schema_1.Schema({
|
|
7882
|
+
module.exports = new (require_schema()).Schema({
|
|
7940
7883
|
include: [require_failsafe()],
|
|
7941
7884
|
implicit: [
|
|
7942
7885
|
require_null(),
|
|
@@ -7947,12 +7890,11 @@ var require_json = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
|
7947
7890
|
});
|
|
7948
7891
|
}));
|
|
7949
7892
|
var require_core = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7950
|
-
|
|
7951
|
-
module.exports = new schema_1.Schema({ include: [require_json()] });
|
|
7893
|
+
module.exports = new (require_schema()).Schema({ include: [require_json()] });
|
|
7952
7894
|
}));
|
|
7953
7895
|
var require_timestamp = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
7954
7896
|
const type_1 = require_type();
|
|
7955
|
-
var YAML_TIMESTAMP_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$");
|
|
7897
|
+
var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?)?$");
|
|
7956
7898
|
function resolveYamlTimestamp(data) {
|
|
7957
7899
|
if (null === data) return false;
|
|
7958
7900
|
if (null === YAML_TIMESTAMP_REGEXP.exec(data)) return false;
|
|
@@ -8209,7 +8151,7 @@ var require_set = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
|
8209
8151
|
});
|
|
8210
8152
|
}));
|
|
8211
8153
|
var require_default_safe = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
8212
|
-
|
|
8154
|
+
module.exports = new (require_schema()).Schema({
|
|
8213
8155
|
include: [require_core()],
|
|
8214
8156
|
implicit: [require_timestamp(), require_merge()],
|
|
8215
8157
|
explicit: [
|
|
@@ -8219,7 +8161,6 @@ var require_default_safe = /* @__PURE__ */ __commonJSMin(((exports$1, module) =>
|
|
|
8219
8161
|
require_set()
|
|
8220
8162
|
]
|
|
8221
8163
|
});
|
|
8222
|
-
module.exports = schema;
|
|
8223
8164
|
}));
|
|
8224
8165
|
var require_undefined = /* @__PURE__ */ __commonJSMin(((exports$1, module) => {
|
|
8225
8166
|
const type_1 = require_type();
|
|
@@ -10860,7 +10801,7 @@ var require_trapAccess = /* @__PURE__ */ __commonJSMin(((exports$1) => {
|
|
|
10860
10801
|
} };
|
|
10861
10802
|
exports$1.trapAccess = (target) => new Proxy(target, traps);
|
|
10862
10803
|
}));
|
|
10863
|
-
var
|
|
10804
|
+
var import_yaml = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports$1) => {
|
|
10864
10805
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
10865
10806
|
const tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports));
|
|
10866
10807
|
tslib_1.__exportStar(require_buildJsonPath(), exports$1);
|
|
@@ -10868,15 +10809,12 @@ var require_yaml = /* @__PURE__ */ __commonJSMin(((exports$1) => {
|
|
|
10868
10809
|
tslib_1.__exportStar(require_getJsonPathForPosition(), exports$1);
|
|
10869
10810
|
tslib_1.__exportStar(require_getLocationForJsonPath(), exports$1);
|
|
10870
10811
|
tslib_1.__exportStar(require_lineForPosition(), exports$1);
|
|
10871
|
-
|
|
10872
|
-
exports$1.
|
|
10873
|
-
var parseWithPointers_1 = require_parseWithPointers();
|
|
10874
|
-
exports$1.parseWithPointers = parseWithPointers_1.parseWithPointers;
|
|
10812
|
+
exports$1.parse = require_parse().parse;
|
|
10813
|
+
exports$1.parseWithPointers = require_parseWithPointers().parseWithPointers;
|
|
10875
10814
|
tslib_1.__exportStar(require_safeStringify(), exports$1);
|
|
10876
10815
|
tslib_1.__exportStar(require_types(), exports$1);
|
|
10877
10816
|
tslib_1.__exportStar(require_trapAccess(), exports$1);
|
|
10878
|
-
}));
|
|
10879
|
-
var import_yaml = /* @__PURE__ */ __toESM(require_yaml());
|
|
10817
|
+
})))());
|
|
10880
10818
|
const STRUCTURAL_KEYS = /* @__PURE__ */ new Set([
|
|
10881
10819
|
"properties",
|
|
10882
10820
|
"items",
|
|
@@ -12658,6 +12596,18 @@ function withRequiredRequestBodySchema(operationSchema) {
|
|
|
12658
12596
|
}
|
|
12659
12597
|
};
|
|
12660
12598
|
}
|
|
12599
|
+
function resolveServerUrl(server, overrides) {
|
|
12600
|
+
var _a2, _b2;
|
|
12601
|
+
if (!server.variables) return server.url;
|
|
12602
|
+
let url = server.url;
|
|
12603
|
+
for (const [key, variable] of Object.entries(server.variables)) {
|
|
12604
|
+
const value = (_a2 = overrides == null ? void 0 : overrides[key]) != null ? _a2 : variable.default != null ? String(variable.default) : void 0;
|
|
12605
|
+
if (value === void 0) continue;
|
|
12606
|
+
if (((_b2 = variable.enum) == null ? void 0 : _b2.length) && !variable.enum.some((e) => String(e) === value)) throw new Error(`Invalid server variable value '${value}' for '${key}' when resolving ${server.url}. Valid values are: ${variable.enum.join(", ")}.`);
|
|
12607
|
+
url = url.replaceAll(`{${key}}`, value);
|
|
12608
|
+
}
|
|
12609
|
+
return url;
|
|
12610
|
+
}
|
|
12661
12611
|
|
|
12662
12612
|
function getDefaultBanner({ title, description, version, config }) {
|
|
12663
12613
|
try {
|
|
@@ -12844,7 +12794,7 @@ function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseU
|
|
|
12844
12794
|
export: isExportable,
|
|
12845
12795
|
params: params.toConstructor(),
|
|
12846
12796
|
children: [
|
|
12847
|
-
pathParamsMapping && Object.entries(pathParamsMapping).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
12797
|
+
pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
12848
12798
|
pathParamsMapping && /* @__PURE__ */ jsx("br", {}),
|
|
12849
12799
|
/* @__PURE__ */ jsx(Const, {
|
|
12850
12800
|
name: "res",
|
|
@@ -12979,7 +12929,7 @@ function Client({ name, isExportable = true, isIndexable = true, returnType, typ
|
|
|
12979
12929
|
isConfigurable ? "const { client: request = fetch, ...requestConfig } = config" : "",
|
|
12980
12930
|
/* @__PURE__ */ jsx("br", {}),
|
|
12981
12931
|
/* @__PURE__ */ jsx("br", {}),
|
|
12982
|
-
pathParamsMapping && Object.entries(pathParamsMapping).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
12932
|
+
pathParamsMapping && Object.entries(pathParamsMapping).filter(([originalName, camelCaseName]) => originalName !== camelCaseName && isValidVarName(originalName)).map(([originalName, camelCaseName]) => `const ${originalName} = ${camelCaseName}`).join("\n"),
|
|
12983
12933
|
pathParamsMapping && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("br", {}), /* @__PURE__ */ jsx("br", {})] }),
|
|
12984
12934
|
queryParamsMapping && ((_f = typeSchemas.queryParams) == null ? void 0 : _f.name) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12985
12935
|
`const mappedParams = params ? { ${Object.entries(queryParamsMapping).map(([originalName, camelCaseName]) => `"${originalName}": params.${camelCaseName}`).join(", ")} } : undefined`,
|
|
@@ -13578,7 +13528,7 @@ var OperationGenerator = (_a = class extends BaseGenerator {
|
|
|
13578
13528
|
}, _a);
|
|
13579
13529
|
const pluginOasName = "plugin-oas";
|
|
13580
13530
|
const pluginOas = definePlugin((options) => {
|
|
13581
|
-
const { output = { path: "schemas" }, group, validate = true, generators = [jsonGenerator], serverIndex, contentType, oasClass, discriminator = "strict", collisionDetection = false } = options;
|
|
13531
|
+
const { output = { path: "schemas" }, group, validate = true, generators = [jsonGenerator], serverIndex, serverVariables, contentType, oasClass, discriminator = "strict", collisionDetection = false } = options;
|
|
13582
13532
|
const getOas = async ({ validate: validate2, config, events }) => {
|
|
13583
13533
|
const oas = await parseFromConfig(config, oasClass);
|
|
13584
13534
|
oas.setOptions({
|
|
@@ -13622,13 +13572,16 @@ const pluginOas = definePlugin((options) => {
|
|
|
13622
13572
|
return oas;
|
|
13623
13573
|
},
|
|
13624
13574
|
async getBaseURL() {
|
|
13625
|
-
var _a2
|
|
13575
|
+
var _a2;
|
|
13626
13576
|
const oas2 = await getOas({
|
|
13627
13577
|
config,
|
|
13628
13578
|
events,
|
|
13629
13579
|
validate: false
|
|
13630
13580
|
});
|
|
13631
|
-
if (serverIndex
|
|
13581
|
+
if (serverIndex === void 0) return;
|
|
13582
|
+
const server = (_a2 = oas2.api.servers) == null ? void 0 : _a2.at(serverIndex);
|
|
13583
|
+
if (!(server == null ? void 0 : server.url)) return;
|
|
13584
|
+
return resolveServerUrl(server, serverVariables);
|
|
13632
13585
|
}
|
|
13633
13586
|
};
|
|
13634
13587
|
},
|
|
@@ -14339,12 +14292,11 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
|
|
|
14339
14292
|
});
|
|
14340
14293
|
const baseSchemas = mini ? filterMiniModifiers(schemas) : schemas;
|
|
14341
14294
|
const output = baseSchemas.map((schemaKeyword, index) => {
|
|
14342
|
-
const siblings = baseSchemas.filter((_, i) => i !== index);
|
|
14343
14295
|
return parse$2({
|
|
14344
14296
|
schema,
|
|
14345
14297
|
parent: void 0,
|
|
14346
14298
|
current: schemaKeyword,
|
|
14347
|
-
siblings,
|
|
14299
|
+
siblings: baseSchemas.filter((_, i) => i !== index),
|
|
14348
14300
|
name
|
|
14349
14301
|
}, {
|
|
14350
14302
|
mapper,
|
|
@@ -212689,14 +212641,13 @@ const parse$1 = createParser({
|
|
|
212689
212641
|
if (isNullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
212690
212642
|
if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
212691
212643
|
if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
212692
|
-
const propertyNode = createPropertySignature({
|
|
212693
|
-
questionToken: isOptional || isNullish ? ["questionToken", "questionTokenAndUndefined"].includes(options.optionalType) : false,
|
|
212694
|
-
name: mappedName,
|
|
212695
|
-
type,
|
|
212696
|
-
readOnly: isReadonly
|
|
212697
|
-
});
|
|
212698
212644
|
return appendJSDocToNode({
|
|
212699
|
-
node:
|
|
212645
|
+
node: createPropertySignature({
|
|
212646
|
+
questionToken: isOptional || isNullish ? ["questionToken", "questionTokenAndUndefined"].includes(options.optionalType) : false,
|
|
212647
|
+
name: mappedName,
|
|
212648
|
+
type,
|
|
212649
|
+
readOnly: isReadonly
|
|
212650
|
+
}),
|
|
212700
212651
|
comments: [
|
|
212701
212652
|
describeSchema ? `@description ${transformers_default.jsStringEscape(describeSchema.args)}` : void 0,
|
|
212702
212653
|
deprecatedSchema ? "@deprecated" : void 0,
|
|
@@ -212719,8 +212670,7 @@ const parse$1 = createParser({
|
|
|
212719
212670
|
siblings: []
|
|
212720
212671
|
}, options)).filter(Boolean).at(0);
|
|
212721
212672
|
if ((_d = current.args) == null ? void 0 : _d.additionalProperties.some((schema2) => isKeyword(schema2, schemaKeywords.nullable))) additionalPropertiesType = createUnionDeclaration({ nodes: [additionalPropertiesType, keywordTypeNodes.null] });
|
|
212722
|
-
|
|
212723
|
-
additionalProperties = createIndexSignature(indexSignatureType);
|
|
212673
|
+
additionalProperties = createIndexSignature(properties.length > 0 ? keywordTypeNodes.unknown : additionalPropertiesType);
|
|
212724
212674
|
}
|
|
212725
212675
|
let patternProperties;
|
|
212726
212676
|
if ((_e = current.args) == null ? void 0 : _e.patternProperties) {
|
|
@@ -212777,8 +212727,7 @@ function Type({ name, typedName, tree, keysToOmit, schema, optionalType, arrayTy
|
|
|
212777
212727
|
const isDirectEnum = schema.type === "array" && schema.items !== void 0;
|
|
212778
212728
|
const isEnumOnly = "enum" in schema && schema.enum;
|
|
212779
212729
|
if (isDirectEnum || isEnumOnly) {
|
|
212780
|
-
|
|
212781
|
-
type = createTypeReferenceNode(typeNameWithKey);
|
|
212730
|
+
type = createTypeReferenceNode(`${enumSchemas[0].args.typeName}Key`);
|
|
212782
212731
|
if (schema.type === "array") if (arrayType === "generic") type = createTypeReferenceNode(createIdentifier("Array"), [type]);
|
|
212783
212732
|
else type = createArrayTypeNode(type);
|
|
212784
212733
|
}
|
|
@@ -213045,52 +212994,38 @@ function useSchemaManager() {
|
|
|
213045
212994
|
function printCombinedSchema({ name, schemas, pluginManager }) {
|
|
213046
212995
|
const properties = {};
|
|
213047
212996
|
if (schemas.response) properties["response"] = createUnionDeclaration({ nodes: schemas.responses.map((res) => {
|
|
213048
|
-
|
|
212997
|
+
return createTypeReferenceNode(createIdentifier(pluginManager.resolveName({
|
|
213049
212998
|
name: res.name,
|
|
213050
212999
|
pluginKey: [pluginTsName],
|
|
213051
213000
|
type: "function"
|
|
213052
|
-
});
|
|
213053
|
-
return createTypeReferenceNode(createIdentifier(identifier), void 0);
|
|
213001
|
+
})), void 0);
|
|
213054
213002
|
}) });
|
|
213055
|
-
if (schemas.request) {
|
|
213056
|
-
|
|
213057
|
-
|
|
213058
|
-
|
|
213059
|
-
|
|
213060
|
-
|
|
213061
|
-
|
|
213062
|
-
|
|
213063
|
-
|
|
213064
|
-
|
|
213065
|
-
|
|
213066
|
-
|
|
213067
|
-
|
|
213068
|
-
|
|
213069
|
-
|
|
213070
|
-
|
|
213071
|
-
|
|
213072
|
-
|
|
213073
|
-
|
|
213074
|
-
|
|
213075
|
-
type: "function"
|
|
213076
|
-
});
|
|
213077
|
-
properties["queryParams"] = createTypeReferenceNode(createIdentifier(identifier), void 0);
|
|
213078
|
-
}
|
|
213079
|
-
if (schemas.headerParams) {
|
|
213080
|
-
const identifier = pluginManager.resolveName({
|
|
213081
|
-
name: schemas.headerParams.name,
|
|
213082
|
-
pluginKey: [pluginTsName],
|
|
213083
|
-
type: "function"
|
|
213084
|
-
});
|
|
213085
|
-
properties["headerParams"] = createTypeReferenceNode(createIdentifier(identifier), void 0);
|
|
213086
|
-
}
|
|
213003
|
+
if (schemas.request) properties["request"] = createTypeReferenceNode(createIdentifier(pluginManager.resolveName({
|
|
213004
|
+
name: schemas.request.name,
|
|
213005
|
+
pluginKey: [pluginTsName],
|
|
213006
|
+
type: "function"
|
|
213007
|
+
})), void 0);
|
|
213008
|
+
if (schemas.pathParams) properties["pathParams"] = createTypeReferenceNode(createIdentifier(pluginManager.resolveName({
|
|
213009
|
+
name: schemas.pathParams.name,
|
|
213010
|
+
pluginKey: [pluginTsName],
|
|
213011
|
+
type: "function"
|
|
213012
|
+
})), void 0);
|
|
213013
|
+
if (schemas.queryParams) properties["queryParams"] = createTypeReferenceNode(createIdentifier(pluginManager.resolveName({
|
|
213014
|
+
name: schemas.queryParams.name,
|
|
213015
|
+
pluginKey: [pluginTsName],
|
|
213016
|
+
type: "function"
|
|
213017
|
+
})), void 0);
|
|
213018
|
+
if (schemas.headerParams) properties["headerParams"] = createTypeReferenceNode(createIdentifier(pluginManager.resolveName({
|
|
213019
|
+
name: schemas.headerParams.name,
|
|
213020
|
+
pluginKey: [pluginTsName],
|
|
213021
|
+
type: "function"
|
|
213022
|
+
})), void 0);
|
|
213087
213023
|
if (schemas.errors) properties["errors"] = createUnionDeclaration({ nodes: schemas.errors.map((error) => {
|
|
213088
|
-
|
|
213024
|
+
return createTypeReferenceNode(createIdentifier(pluginManager.resolveName({
|
|
213089
213025
|
name: error.name,
|
|
213090
213026
|
pluginKey: [pluginTsName],
|
|
213091
213027
|
type: "function"
|
|
213092
|
-
});
|
|
213093
|
-
return createTypeReferenceNode(createIdentifier(identifier), void 0);
|
|
213028
|
+
})), void 0);
|
|
213094
213029
|
}) });
|
|
213095
213030
|
return safePrint(createTypeAliasDeclaration({
|
|
213096
213031
|
name,
|
|
@@ -223928,12 +223863,20 @@ function mergePlugins(diskPlugins, studioPlugins) {
|
|
|
223928
223863
|
if (!studioPlugins) return diskPlugins;
|
|
223929
223864
|
const resolvedStudio = resolvePlugins(studioPlugins);
|
|
223930
223865
|
if (!diskPlugins) return resolvedStudio;
|
|
223931
|
-
const
|
|
223866
|
+
const studioEntryByResolvedName = /* @__PURE__ */ new Map();
|
|
223867
|
+
resolvedStudio.forEach((resolved, i) => {
|
|
223868
|
+
const entry = studioPlugins[i];
|
|
223869
|
+
if (entry) {
|
|
223870
|
+
studioEntryByResolvedName.set(resolved.name, entry);
|
|
223871
|
+
}
|
|
223872
|
+
});
|
|
223932
223873
|
const diskNames = new Set(diskPlugins.map((p) => p.name));
|
|
223933
223874
|
const mergedDisk = diskPlugins.map((diskPlugin) => {
|
|
223934
|
-
|
|
223935
|
-
|
|
223936
|
-
|
|
223875
|
+
var _a;
|
|
223876
|
+
const studioEntry = studioEntryByResolvedName.get(diskPlugin.name);
|
|
223877
|
+
if (!studioEntry) return diskPlugin;
|
|
223878
|
+
const mergedOptions = mergeDeep(diskPlugin.options, studioEntry.options);
|
|
223879
|
+
return (_a = resolvePlugins([{ name: studioEntry.name, options: mergedOptions }])[0]) != null ? _a : diskPlugin;
|
|
223937
223880
|
});
|
|
223938
223881
|
const studioOnly = resolvedStudio.filter((p) => !diskNames.has(p.name));
|
|
223939
223882
|
return [...mergedDisk, ...studioOnly];
|
|
@@ -224134,7 +224077,6 @@ async function connectToStudio(options) {
|
|
|
224134
224077
|
studioUrl,
|
|
224135
224078
|
configPath,
|
|
224136
224079
|
resolvedConfigPath,
|
|
224137
|
-
noCache,
|
|
224138
224080
|
allowAll,
|
|
224139
224081
|
allowWrite,
|
|
224140
224082
|
allowPublish,
|
|
@@ -224142,27 +224084,20 @@ async function connectToStudio(options) {
|
|
|
224142
224084
|
retryInterval,
|
|
224143
224085
|
heartbeatInterval = 3e4,
|
|
224144
224086
|
initialSession,
|
|
224145
|
-
sessionKey,
|
|
224146
224087
|
nitro
|
|
224147
224088
|
} = options;
|
|
224148
224089
|
const events = new AsyncEventEmitter();
|
|
224149
224090
|
let currentSource;
|
|
224150
|
-
const maskedSessionKey = maskedString(sessionKey.replace("sessions:", ""));
|
|
224151
|
-
async function removeSession() {
|
|
224152
|
-
if (!noCache) {
|
|
224153
|
-
await removeCachedSession(sessionKey);
|
|
224154
|
-
}
|
|
224155
|
-
}
|
|
224156
224091
|
async function reconnect() {
|
|
224157
|
-
logger.info(`
|
|
224158
|
-
await removeSession();
|
|
224092
|
+
logger.info(`Retrying connection in ${formatMs(retryInterval)} to Kubb Studio ...`);
|
|
224159
224093
|
setTimeout(() => connectToStudio({ ...options, initialSession: void 0 }), retryInterval);
|
|
224160
224094
|
}
|
|
224161
224095
|
try {
|
|
224162
224096
|
setupHookListener(events, root);
|
|
224163
|
-
const { sessionId, wsUrl, isSandbox } = initialSession != null ? initialSession : await createAgentSession({
|
|
224097
|
+
const { sessionId, wsUrl, isSandbox } = initialSession != null ? initialSession : await createAgentSession({ token, studioUrl });
|
|
224164
224098
|
const ws = createWebsocket(wsUrl, { headers: { Authorization: `Bearer ${token}` } });
|
|
224165
224099
|
const maskedWsUrl = maskedString(wsUrl);
|
|
224100
|
+
const maskedSessionId = maskedString(sessionId);
|
|
224166
224101
|
const effectiveAllowAll = isSandbox ? false : allowAll;
|
|
224167
224102
|
const effectiveWrite = isSandbox ? false : allowWrite;
|
|
224168
224103
|
const effectivePublish = isSandbox ? false : allowPublish;
|
|
@@ -224181,7 +224116,7 @@ async function connectToStudio(options) {
|
|
|
224181
224116
|
}
|
|
224182
224117
|
}
|
|
224183
224118
|
const onOpen = () => {
|
|
224184
|
-
logger.success(`[${
|
|
224119
|
+
logger.success(`[${maskedSessionId}] Connected to Kubb Studio on "${maskedWsUrl}"`);
|
|
224185
224120
|
};
|
|
224186
224121
|
const onClose = async () => {
|
|
224187
224122
|
if (serverDisconnected) {
|
|
@@ -224194,8 +224129,10 @@ async function connectToStudio(options) {
|
|
|
224194
224129
|
await reconnect();
|
|
224195
224130
|
};
|
|
224196
224131
|
const onError = async () => {
|
|
224197
|
-
logger.error(`[${
|
|
224132
|
+
logger.error(`[${maskedSessionId}] Failed to connect to Kubb Studio on "${maskedWsUrl}"`);
|
|
224198
224133
|
await cleanup();
|
|
224134
|
+
await disconnect({ sessionId, studioUrl, token }).catch(() => {
|
|
224135
|
+
});
|
|
224199
224136
|
await reconnect();
|
|
224200
224137
|
};
|
|
224201
224138
|
ws.addEventListener("open", onOpen);
|
|
@@ -224209,18 +224146,17 @@ async function connectToStudio(options) {
|
|
|
224209
224146
|
heartbeatTimer = setInterval(() => sendAgentMessage(ws, { type: "ping" }), heartbeatInterval);
|
|
224210
224147
|
setupEventsStream(ws, events, () => currentSource);
|
|
224211
224148
|
ws.addEventListener("message", async (message) => {
|
|
224212
|
-
var _a2, _b, _c, _d, _e;
|
|
224149
|
+
var _a2, _b, _c, _d, _e, _f, _g;
|
|
224213
224150
|
try {
|
|
224214
224151
|
const data = JSON.parse(message.data);
|
|
224215
|
-
logger.info(`[${
|
|
224152
|
+
logger.info(`[${maskedSessionId}] Received "${data.type}" from Studio`);
|
|
224216
224153
|
if (isPongMessage(data)) {
|
|
224217
224154
|
return;
|
|
224218
224155
|
}
|
|
224219
224156
|
if (isDisconnectMessage(data)) {
|
|
224220
|
-
logger.warn(`[${
|
|
224157
|
+
logger.warn(`[${maskedSessionId}] Agent session disconnected by Studio with reason: ${data.reason}`);
|
|
224221
224158
|
if (data.reason === "revoked") {
|
|
224222
224159
|
await cleanup(`session_${data.reason}`);
|
|
224223
|
-
await removeSession();
|
|
224224
224160
|
return;
|
|
224225
224161
|
}
|
|
224226
224162
|
if (data.reason === "expired") {
|
|
@@ -224234,18 +224170,19 @@ async function connectToStudio(options) {
|
|
|
224234
224170
|
if (data.command === "generate") {
|
|
224235
224171
|
currentSource = "generate";
|
|
224236
224172
|
const config = await loadConfig(resolvedConfigPath);
|
|
224237
|
-
const
|
|
224173
|
+
const storedConfig = data.payload ? null : await getLatestStudioConfigFromStorage({ sessionId }).catch(() => null);
|
|
224174
|
+
const patch = (_b = (_a2 = data.payload) != null ? _a2 : storedConfig) != null ? _b : void 0;
|
|
224238
224175
|
const plugins = mergePlugins(config.plugins, patch == null ? void 0 : patch.plugins);
|
|
224239
|
-
const inputOverride = isSandbox ? { data: (
|
|
224176
|
+
const inputOverride = isSandbox ? { data: (_c = patch == null ? void 0 : patch.input) != null ? _c : "" } : void 0;
|
|
224240
224177
|
if (allowWrite && isSandbox) {
|
|
224241
|
-
logger.warn(`[${
|
|
224178
|
+
logger.warn(`[${maskedSessionId}] Agent is running in a sandbox environment, write will be disabled`);
|
|
224242
224179
|
}
|
|
224243
224180
|
if ((patch == null ? void 0 : patch.input) && !isSandbox) {
|
|
224244
|
-
logger.warn(`[${
|
|
224181
|
+
logger.warn(`[${maskedSessionId}] Input override via payload is only supported in sandbox mode and will be ignored`);
|
|
224245
224182
|
}
|
|
224246
224183
|
if (data.payload && effectiveWrite) {
|
|
224247
|
-
await saveStudioConfigToStorage({
|
|
224248
|
-
logger.warn(`[${
|
|
224184
|
+
await saveStudioConfigToStorage({ sessionId, config: data.payload }).catch((err) => {
|
|
224185
|
+
logger.warn(`[${maskedSessionId}] Failed to save studio config: ${err == null ? void 0 : err.message}`);
|
|
224249
224186
|
});
|
|
224250
224187
|
}
|
|
224251
224188
|
await generate({
|
|
@@ -224258,7 +224195,7 @@ async function connectToStudio(options) {
|
|
|
224258
224195
|
},
|
|
224259
224196
|
events
|
|
224260
224197
|
});
|
|
224261
|
-
logger.success(`[${
|
|
224198
|
+
logger.success(`[${maskedSessionId}] Completed "${data.type}" from Studio`);
|
|
224262
224199
|
currentSource = void 0;
|
|
224263
224200
|
return;
|
|
224264
224201
|
}
|
|
@@ -224271,38 +224208,38 @@ async function connectToStudio(options) {
|
|
|
224271
224208
|
configPath,
|
|
224272
224209
|
permissions: { allowAll: effectiveAllowAll, allowWrite: effectiveWrite, allowPublish: effectivePublish },
|
|
224273
224210
|
config: {
|
|
224274
|
-
plugins: (
|
|
224211
|
+
plugins: (_d = config.plugins) == null ? void 0 : _d.map((plugin) => ({
|
|
224275
224212
|
name: `@kubb/${plugin.name}`,
|
|
224276
224213
|
options: serializePluginOptions(plugin.options)
|
|
224277
224214
|
}))
|
|
224278
224215
|
}
|
|
224279
224216
|
}
|
|
224280
224217
|
});
|
|
224281
|
-
logger.success(`[${
|
|
224218
|
+
logger.success(`[${maskedSessionId}] Completed "${data.type}" from Studio`);
|
|
224282
224219
|
return;
|
|
224283
224220
|
}
|
|
224284
224221
|
if (isPublishCommandMessage(data)) {
|
|
224285
224222
|
if (!effectivePublish) {
|
|
224286
|
-
logger.warn(`[${
|
|
224223
|
+
logger.warn(`[${maskedSessionId}] Publish command rejected \u2014 KUBB_AGENT_ALLOW_PUBLISH is not enabled`);
|
|
224287
224224
|
return;
|
|
224288
224225
|
}
|
|
224289
224226
|
currentSource = "publish";
|
|
224290
224227
|
const config = await loadConfig(resolvedConfigPath);
|
|
224291
|
-
const resolvedCommand = (
|
|
224228
|
+
const resolvedCommand = (_f = (_e = data.payload.command) != null ? _e : process.env.KUBB_AGENT_PUBLISH_COMMAND) != null ? _f : "npm publish";
|
|
224292
224229
|
await publish({
|
|
224293
224230
|
command: resolvedCommand,
|
|
224294
224231
|
outputPath: config.output.path,
|
|
224295
224232
|
root,
|
|
224296
224233
|
events
|
|
224297
224234
|
});
|
|
224298
|
-
logger.success(`[${
|
|
224235
|
+
logger.success(`[${maskedSessionId}] Completed "${data.command}" from Studio`);
|
|
224299
224236
|
currentSource = void 0;
|
|
224300
224237
|
return;
|
|
224301
224238
|
}
|
|
224302
224239
|
}
|
|
224303
|
-
logger.warn(`[${
|
|
224240
|
+
logger.warn(`[${maskedSessionId}] Unknown message type from Kubb Studio: ${message.data}`);
|
|
224304
224241
|
} catch (error) {
|
|
224305
|
-
logger.error(`[${
|
|
224242
|
+
logger.error(`[${maskedSessionId}] [unhandledRejection] ${(_g = error == null ? void 0 : error.message) != null ? _g : error}`);
|
|
224306
224243
|
}
|
|
224307
224244
|
});
|
|
224308
224245
|
} catch (error) {
|
|
@@ -224314,7 +224251,6 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224314
224251
|
const studioUrl = process$1.env.KUBB_STUDIO_URL || "https://studio.kubb.dev";
|
|
224315
224252
|
const token = process$1.env.KUBB_AGENT_TOKEN;
|
|
224316
224253
|
const configPath = process$1.env.KUBB_AGENT_CONFIG || "kubb.config.ts";
|
|
224317
|
-
const noCache = process$1.env.KUBB_AGENT_NO_CACHE === "true";
|
|
224318
224254
|
const retryInterval = process$1.env.KUBB_AGENT_RETRY_TIMEOUT ? Number.parseInt(process$1.env.KUBB_AGENT_RETRY_TIMEOUT, 10) : 3e4;
|
|
224319
224255
|
const heartbeatInterval = process$1.env.KUBB_AGENT_HEARTBEAT_INTERVAL ? Number.parseInt(process$1.env.KUBB_AGENT_HEARTBEAT_INTERVAL, 10) : 3e4;
|
|
224320
224256
|
const root = process$1.env.KUBB_AGENT_ROOT || process$1.cwd();
|
|
@@ -224330,9 +224266,7 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224330
224266
|
logger.warn("KUBB_AGENT_SECRET not set", "secret should be set");
|
|
224331
224267
|
}
|
|
224332
224268
|
const resolvedConfigPath = path$2.isAbsolute(configPath) ? configPath : path$2.resolve(root, configPath);
|
|
224333
|
-
const
|
|
224334
|
-
const sessionKey = getSessionKey(token);
|
|
224335
|
-
const maskedSessionKey = maskedString(sessionKey.replace("sessions:", ""));
|
|
224269
|
+
const maskedToken = maskedString(token);
|
|
224336
224270
|
try {
|
|
224337
224271
|
await registerAgent({ token, studioUrl, poolSize });
|
|
224338
224272
|
const baseOptions = {
|
|
@@ -224340,38 +224274,31 @@ const _zcw7I4pYH8OiCfaDcjy_x7I6IH1tLDQR3W_yRZgP6E = defineNitroPlugin(async (nit
|
|
|
224340
224274
|
studioUrl,
|
|
224341
224275
|
configPath,
|
|
224342
224276
|
resolvedConfigPath,
|
|
224343
|
-
noCache,
|
|
224344
224277
|
allowAll,
|
|
224345
224278
|
allowWrite,
|
|
224346
224279
|
allowPublish,
|
|
224347
224280
|
root,
|
|
224348
224281
|
retryInterval,
|
|
224349
224282
|
heartbeatInterval,
|
|
224350
|
-
storage,
|
|
224351
|
-
sessionKey,
|
|
224352
224283
|
nitro
|
|
224353
224284
|
};
|
|
224354
|
-
logger.info(`[${
|
|
224285
|
+
logger.info(`[${maskedToken}] Starting session pool of ${poolSize} connection(s)`);
|
|
224355
224286
|
const sessions = /* @__PURE__ */ new Map();
|
|
224356
|
-
for (const
|
|
224357
|
-
const
|
|
224358
|
-
|
|
224359
|
-
const session = await createAgentSession({ noCache, token, studioUrl, cacheKey }).catch((err) => {
|
|
224360
|
-
logger.warn(`[${maskedSessionKey2}] Failed to pre-create pool session:`, err == null ? void 0 : err.message);
|
|
224287
|
+
for (const index of Array.from({ length: poolSize }, (_, i) => i)) {
|
|
224288
|
+
const session = await createAgentSession({ token, studioUrl }).catch((err) => {
|
|
224289
|
+
logger.warn(`[${maskedToken}] Failed to pre-create pool session ${index}:`, err == null ? void 0 : err.message);
|
|
224361
224290
|
return null;
|
|
224362
224291
|
});
|
|
224363
|
-
sessions.set(
|
|
224292
|
+
sessions.set(index, session);
|
|
224364
224293
|
}
|
|
224365
|
-
|
|
224366
|
-
for (const [cacheKey, session] of sessions) {
|
|
224367
|
-
index++;
|
|
224294
|
+
for (const [index, session] of sessions.entries()) {
|
|
224368
224295
|
if (!session) {
|
|
224369
224296
|
continue;
|
|
224370
224297
|
}
|
|
224371
|
-
const
|
|
224372
|
-
logger.info(`[${
|
|
224373
|
-
await connectToStudio({ ...baseOptions, initialSession: session
|
|
224374
|
-
logger.warn(`[${
|
|
224298
|
+
const maskedSessionId = maskedString(session.sessionId);
|
|
224299
|
+
logger.info(`[${maskedSessionId}] Connecting session ${index + 1}/${sessions.size}`);
|
|
224300
|
+
await connectToStudio({ ...baseOptions, initialSession: session }).catch((err) => {
|
|
224301
|
+
logger.warn(`[${maskedSessionId}] Session ${index + 1} failed to connect:`, err == null ? void 0 : err.message);
|
|
224375
224302
|
});
|
|
224376
224303
|
}
|
|
224377
224304
|
} catch (error) {
|