@kubb/studio 5.11.5 → 5.11.6
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/dist/index.cjs +69 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +69 -34
- package/dist/index.js.map +1 -1
- package/dist/{protocol--vpA4DkB.d.ts → protocol-dCzUP4dH.d.cts} +42 -32
- package/dist/{protocol--vpA4DkB.d.cts → protocol-dCzUP4dH.d.ts} +42 -32
- package/dist/protocol.cjs +1 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +2 -2
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +1 -0
- package/dist/protocol.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -220,7 +220,7 @@ function getElapsedMs(hrStart) {
|
|
|
220
220
|
}
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region package.json
|
|
223
|
-
var version = "5.11.
|
|
223
|
+
var version = "5.11.6";
|
|
224
224
|
//#endregion
|
|
225
225
|
//#region src/resolveConfig.ts
|
|
226
226
|
/**
|
|
@@ -2069,19 +2069,25 @@ var Agent = class extends capnweb.RpcTarget {
|
|
|
2069
2069
|
}
|
|
2070
2070
|
async connect(info) {
|
|
2071
2071
|
this.#session.info = info;
|
|
2072
|
-
const { configPath, root, version: version$1,
|
|
2072
|
+
const { configPath, root, version: version$1, loadConfigs, configFile } = this.#options;
|
|
2073
2073
|
const source = read(configFile);
|
|
2074
|
-
const [
|
|
2075
|
-
|
|
2074
|
+
const [configs, file, extensions] = await Promise.all([
|
|
2075
|
+
loadConfigs(),
|
|
2076
2076
|
this.#readConfigFileView(source),
|
|
2077
2077
|
this.#installedExtensions(source)
|
|
2078
2078
|
]);
|
|
2079
|
-
const
|
|
2080
|
-
|
|
2081
|
-
|
|
2079
|
+
const entries = [];
|
|
2080
|
+
for (const config of configs) {
|
|
2081
|
+
const disk = await this.#readDiskOutput(config).catch(async (error) => {
|
|
2082
|
+
await this.#warn({ message: `Could not read the output directory: ${getErrorMessage(error)}` });
|
|
2083
|
+
});
|
|
2084
|
+
entries.push({
|
|
2085
|
+
...toEntryView(config, extensions),
|
|
2086
|
+
...disk && { disk }
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2082
2089
|
this.#session.connected.resolve(info);
|
|
2083
2090
|
return {
|
|
2084
|
-
output,
|
|
2085
2091
|
versions: {
|
|
2086
2092
|
kubb: version,
|
|
2087
2093
|
agent: version$1
|
|
@@ -2090,30 +2096,8 @@ var Agent = class extends capnweb.RpcTarget {
|
|
|
2090
2096
|
config: {
|
|
2091
2097
|
path: configPath,
|
|
2092
2098
|
file,
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
name: (0, _kubb_core.resolveMeta)(plugin).name,
|
|
2096
|
-
extensions
|
|
2097
|
-
}),
|
|
2098
|
-
options: toJSONOptions(plugin.options)
|
|
2099
|
-
})),
|
|
2100
|
-
adapter: config.adapter && {
|
|
2101
|
-
name: toStudioName({
|
|
2102
|
-
name: (0, _kubb_core.resolveMeta)(config.adapter).name,
|
|
2103
|
-
extensions,
|
|
2104
|
-
kind: "adapter"
|
|
2105
|
-
}),
|
|
2106
|
-
options: toJSONOptions(config.adapter.options)
|
|
2107
|
-
},
|
|
2108
|
-
parsers: config.parsers.map((parser) => ({
|
|
2109
|
-
name: toStudioName({
|
|
2110
|
-
name: (0, _kubb_core.resolveMeta)(parser).name,
|
|
2111
|
-
extensions,
|
|
2112
|
-
kind: "parser"
|
|
2113
|
-
}),
|
|
2114
|
-
options: toJSONOptions(parser.options)
|
|
2115
|
-
})),
|
|
2116
|
-
extensions: [...extensions.values()]
|
|
2099
|
+
extensions: [...extensions.values()],
|
|
2100
|
+
configs: entries
|
|
2117
2101
|
},
|
|
2118
2102
|
permissions: this.#permissions
|
|
2119
2103
|
};
|
|
@@ -2201,7 +2185,9 @@ var Agent = class extends capnweb.RpcTarget {
|
|
|
2201
2185
|
const { jobId, config: patch } = input;
|
|
2202
2186
|
const studioInput = this.#sandbox ? patch?.input : void 0;
|
|
2203
2187
|
if (this.#sandbox && (typeof studioInput !== "string" || !studioInput.trim() || (0, _kubb_core.getInputKind)(studioInput) !== "inline")) return this.#refuse({ message: require_protocol.AgentMessage.SANDBOX_INPUT_ONLY });
|
|
2204
|
-
const [
|
|
2188
|
+
const [configs, extensions] = await Promise.all([this.#options.loadConfigs(), this.#installedExtensions()]);
|
|
2189
|
+
const config = pickConfig(configs, patch?.config);
|
|
2190
|
+
if (!config) return this.#refuse({ message: require_protocol.AgentMessage.CONFIG_ENTRY_NOT_FOUND });
|
|
2205
2191
|
const [plugins, adapter, parsers] = await Promise.all([
|
|
2206
2192
|
mergePlugins({
|
|
2207
2193
|
diskPlugins: config.plugins,
|
|
@@ -2505,6 +2491,55 @@ async function runSession({ options, openRpc, url, instanceId }) {
|
|
|
2505
2491
|
/**
|
|
2506
2492
|
* The connection loop with a swappable transport. {@link connectAgent} passes a real WebSocket.
|
|
2507
2493
|
*/
|
|
2494
|
+
/** The entry Studio named by position or `name`, else the first. `undefined` for one the file does not have. */
|
|
2495
|
+
function pickConfig(configs, ref) {
|
|
2496
|
+
if (typeof ref === "string") return configs.find((config) => config.name === ref);
|
|
2497
|
+
if (ref !== void 0 && !Number.isSafeInteger(ref)) return void 0;
|
|
2498
|
+
return configs[ref ?? 0];
|
|
2499
|
+
}
|
|
2500
|
+
/** The input path or URL Studio may show: no inline document, and no credentials from a URL. */
|
|
2501
|
+
function reportedInput(input) {
|
|
2502
|
+
if (typeof input !== "string") return void 0;
|
|
2503
|
+
const kind = (0, _kubb_core.getInputKind)(input);
|
|
2504
|
+
if (kind === "inline") return void 0;
|
|
2505
|
+
if (kind !== "url") return input;
|
|
2506
|
+
const url = new URL(input);
|
|
2507
|
+
url.username = "";
|
|
2508
|
+
url.password = "";
|
|
2509
|
+
return url.href;
|
|
2510
|
+
}
|
|
2511
|
+
/** A JSON copy of one resolved entry, each extension named by the package its manifest is in. */
|
|
2512
|
+
function toEntryView(config, extensions) {
|
|
2513
|
+
const input = reportedInput(config.input);
|
|
2514
|
+
return {
|
|
2515
|
+
...config.name !== void 0 && { name: config.name },
|
|
2516
|
+
...input !== void 0 && { input },
|
|
2517
|
+
output: config.output.path,
|
|
2518
|
+
plugins: config.plugins.map((plugin) => ({
|
|
2519
|
+
name: toStudioName({
|
|
2520
|
+
name: (0, _kubb_core.resolveMeta)(plugin).name,
|
|
2521
|
+
extensions
|
|
2522
|
+
}),
|
|
2523
|
+
options: toJSONOptions(plugin.options)
|
|
2524
|
+
})),
|
|
2525
|
+
adapter: config.adapter && {
|
|
2526
|
+
name: toStudioName({
|
|
2527
|
+
name: (0, _kubb_core.resolveMeta)(config.adapter).name,
|
|
2528
|
+
extensions,
|
|
2529
|
+
kind: "adapter"
|
|
2530
|
+
}),
|
|
2531
|
+
options: toJSONOptions(config.adapter.options)
|
|
2532
|
+
},
|
|
2533
|
+
parsers: config.parsers.map((parser) => ({
|
|
2534
|
+
name: toStudioName({
|
|
2535
|
+
name: (0, _kubb_core.resolveMeta)(parser).name,
|
|
2536
|
+
extensions,
|
|
2537
|
+
kind: "parser"
|
|
2538
|
+
}),
|
|
2539
|
+
options: toJSONOptions(parser.options)
|
|
2540
|
+
}))
|
|
2541
|
+
};
|
|
2542
|
+
}
|
|
2508
2543
|
async function runAgent({ options, openRpc }) {
|
|
2509
2544
|
const root = options.root ?? node_process.default.cwd();
|
|
2510
2545
|
const resolved = {
|
|
@@ -2566,7 +2601,7 @@ async function runAgent({ options, openRpc }) {
|
|
|
2566
2601
|
* const hooks = new Hookable<KubbHooks>()
|
|
2567
2602
|
* hooks.hook('studio:connected', ({ agentSlug }) => console.log(`Connected as ${agentSlug}`))
|
|
2568
2603
|
*
|
|
2569
|
-
* await connectAgent({ token, configPath: 'kubb.config.ts',
|
|
2604
|
+
* await connectAgent({ token, configPath: 'kubb.config.ts', loadConfigs, version: '1.0.0', hooks, signal })
|
|
2570
2605
|
* ```
|
|
2571
2606
|
*/
|
|
2572
2607
|
function connectAgent(options) {
|