@kubb/studio 5.2.5 → 5.2.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 +20 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +4 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.ts +584 -2
- package/dist/protocol.js +4 -1
- package/dist/protocol.js.map +1 -1
- package/package.json +4 -4
- package/dist/index-Dq2uq38g.d.ts +0 -579
package/dist/index.cjs
CHANGED
|
@@ -564,12 +564,14 @@ async function disconnect({ sessionId, token, studioUrl, slug }) {
|
|
|
564
564
|
});
|
|
565
565
|
console.log((0, node_util.styleText)("green", `[${tag}] Disconnected from Studio`));
|
|
566
566
|
} catch (error) {
|
|
567
|
+
const statusCode = error?.statusCode;
|
|
568
|
+
if (statusCode !== void 0 && statusCode >= 400 && statusCode < 500) return;
|
|
567
569
|
console.warn((0, node_util.styleText)("yellow", `[${tag}] Failed to notify Studio of disconnection: ${getErrorMessage(error)}`));
|
|
568
570
|
}
|
|
569
571
|
}
|
|
570
572
|
//#endregion
|
|
571
573
|
//#region package.json
|
|
572
|
-
var version = "5.2.
|
|
574
|
+
var version = "5.2.6";
|
|
573
575
|
//#endregion
|
|
574
576
|
//#region src/hooks.ts
|
|
575
577
|
/**
|
|
@@ -1522,6 +1524,9 @@ const CONNECT_TIMEOUT_MS = 5e3;
|
|
|
1522
1524
|
*/
|
|
1523
1525
|
const eventSeqCounters = /* @__PURE__ */ new WeakMap();
|
|
1524
1526
|
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
1527
|
+
function relativeStoragePath(root, filePath) {
|
|
1528
|
+
return ((0, node_path.isAbsolute)(filePath) ? (0, node_path.relative)((0, node_path.resolve)(root), filePath) : filePath).replaceAll("\\", "/");
|
|
1529
|
+
}
|
|
1525
1530
|
async function resolvePeerDependencies(names) {
|
|
1526
1531
|
const uniqueNames = [...new Set(names.map(toPackageName))];
|
|
1527
1532
|
const peerDependencies = {};
|
|
@@ -1576,9 +1581,10 @@ function sendAgentMessage(ws$3, message) {
|
|
|
1576
1581
|
* Sends a single `kubb:error` payload to Studio, stamped from the same per-socket counter the event stream
|
|
1577
1582
|
* uses so Studio can still order it against the generation events around it.
|
|
1578
1583
|
*/
|
|
1579
|
-
function sendErrorMessage(ws$4, error) {
|
|
1584
|
+
function sendErrorMessage(ws$4, error, jobId) {
|
|
1580
1585
|
sendAgentMessage(ws$4, {
|
|
1581
1586
|
type: "agent:data",
|
|
1587
|
+
jobId,
|
|
1582
1588
|
payload: {
|
|
1583
1589
|
type: "kubb:error",
|
|
1584
1590
|
data: [{
|
|
@@ -1593,7 +1599,7 @@ function sendErrorMessage(ws$4, error) {
|
|
|
1593
1599
|
/**
|
|
1594
1600
|
* Forwards selected Kubb lifecycle events to Studio as data messages for the active session.
|
|
1595
1601
|
*/
|
|
1596
|
-
function setupEventsStream(ws$5, hooks) {
|
|
1602
|
+
function setupEventsStream(ws$5, hooks, jobId) {
|
|
1597
1603
|
const unhooks = [];
|
|
1598
1604
|
/**
|
|
1599
1605
|
* Registers a listener and keeps its remover, so one generation's listeners come off the session
|
|
@@ -1605,6 +1611,7 @@ function setupEventsStream(ws$5, hooks) {
|
|
|
1605
1611
|
function sendDataMessage(payload) {
|
|
1606
1612
|
sendAgentMessage(ws$5, {
|
|
1607
1613
|
type: "agent:data",
|
|
1614
|
+
jobId,
|
|
1608
1615
|
payload: {
|
|
1609
1616
|
...payload,
|
|
1610
1617
|
timestamp: Date.now(),
|
|
@@ -1703,7 +1710,7 @@ function setupEventsStream(ws$5, hooks) {
|
|
|
1703
1710
|
limit: FILE_READ_CONCURRENCY,
|
|
1704
1711
|
run: async (path) => {
|
|
1705
1712
|
const content = await storage.readItem(path);
|
|
1706
|
-
if (content !== null) files[path] = content;
|
|
1713
|
+
if (content !== null) files[relativeStoragePath(config.root, path)] = content;
|
|
1707
1714
|
}
|
|
1708
1715
|
});
|
|
1709
1716
|
sendDataMessage({
|
|
@@ -1864,6 +1871,7 @@ var StudioSession = class {
|
|
|
1864
1871
|
#session;
|
|
1865
1872
|
#ws;
|
|
1866
1873
|
#studioVersion;
|
|
1874
|
+
#activeJobId = null;
|
|
1867
1875
|
#disposed = false;
|
|
1868
1876
|
#isGenerating = false;
|
|
1869
1877
|
#heartbeatTimer;
|
|
@@ -1911,7 +1919,7 @@ var StudioSession = class {
|
|
|
1911
1919
|
signal?.addEventListener("abort", this.#onAbort, { once: true });
|
|
1912
1920
|
this.#unhooks.push(() => signal?.removeEventListener("abort", this.#onAbort));
|
|
1913
1921
|
this.#heartbeatTimer = setInterval(() => this.#sendHeartbeat(), heartbeatInterval);
|
|
1914
|
-
this.#unhooks.push(this.#hooks.hook("kubb:error", ({ error }) => sendErrorMessage(ws, error)));
|
|
1922
|
+
this.#unhooks.push(this.#hooks.hook("kubb:error", ({ error }) => sendErrorMessage(ws, error, this.#activeJobId ?? "connection")));
|
|
1915
1923
|
} catch (error) {
|
|
1916
1924
|
await this.#hooks.callHook("studio:error", { error: toError(error) });
|
|
1917
1925
|
if (error instanceof InvalidAgentTokenError) throw error;
|
|
@@ -2132,6 +2140,7 @@ var StudioSession = class {
|
|
|
2132
2140
|
return;
|
|
2133
2141
|
}
|
|
2134
2142
|
this.#isGenerating = true;
|
|
2143
|
+
this.#activeJobId = data.jobId;
|
|
2135
2144
|
try {
|
|
2136
2145
|
const config = await loadConfig();
|
|
2137
2146
|
const patch = data.payload;
|
|
@@ -2144,7 +2153,7 @@ var StudioSession = class {
|
|
|
2144
2153
|
await this.#warn(`Ignored the spec from Studio; set ${remedy} to generate from it`);
|
|
2145
2154
|
}
|
|
2146
2155
|
const resolvedPlugins = plugins ?? config.plugins;
|
|
2147
|
-
const detach = [setupHookListener(this.#hooks, root), setupEventsStream(ws, this.#hooks)];
|
|
2156
|
+
const detach = [setupHookListener(this.#hooks, root), setupEventsStream(ws, this.#hooks, data.jobId)];
|
|
2148
2157
|
try {
|
|
2149
2158
|
await generate({
|
|
2150
2159
|
config: {
|
|
@@ -2172,6 +2181,7 @@ var StudioSession = class {
|
|
|
2172
2181
|
});
|
|
2173
2182
|
} finally {
|
|
2174
2183
|
this.#isGenerating = false;
|
|
2184
|
+
this.#activeJobId = null;
|
|
2175
2185
|
}
|
|
2176
2186
|
}
|
|
2177
2187
|
async #handleSave(ws, data, command) {
|
|
@@ -2180,6 +2190,7 @@ var StudioSession = class {
|
|
|
2180
2190
|
await this.#warn("Ignored save: the message carried no edits");
|
|
2181
2191
|
sendAgentMessage(ws, {
|
|
2182
2192
|
type: "agent:save",
|
|
2193
|
+
jobId: data.jobId,
|
|
2183
2194
|
payload: {
|
|
2184
2195
|
outcomes: [],
|
|
2185
2196
|
changed: false
|
|
@@ -2190,6 +2201,7 @@ var StudioSession = class {
|
|
|
2190
2201
|
const edits = data.edits;
|
|
2191
2202
|
const refuse = (reason) => sendAgentMessage(ws, {
|
|
2192
2203
|
type: "agent:save",
|
|
2204
|
+
jobId: data.jobId,
|
|
2193
2205
|
payload: {
|
|
2194
2206
|
outcomes: edits.map((edit) => ({
|
|
2195
2207
|
edit,
|
|
@@ -2213,6 +2225,7 @@ var StudioSession = class {
|
|
|
2213
2225
|
if (changed) await (0, node_fs_promises.writeFile)(configFile, patched, "utf-8");
|
|
2214
2226
|
sendAgentMessage(ws, {
|
|
2215
2227
|
type: "agent:save",
|
|
2228
|
+
jobId: data.jobId,
|
|
2216
2229
|
payload: {
|
|
2217
2230
|
outcomes,
|
|
2218
2231
|
changed,
|
|
@@ -2438,6 +2451,7 @@ exports.InvalidAgentTokenError = InvalidAgentTokenError;
|
|
|
2438
2451
|
exports.PairingCanceledError = PairingCanceledError;
|
|
2439
2452
|
exports.createClient = createClient;
|
|
2440
2453
|
exports.createFileStorage = createFileStorage;
|
|
2454
|
+
exports.createJobId = require_protocol.createJobId;
|
|
2441
2455
|
exports.defaultStudioUrl = defaultStudioUrl;
|
|
2442
2456
|
exports.pollForPairingToken = pollForPairingToken;
|
|
2443
2457
|
exports.runConnection = runConnection;
|