@kubb/cli 5.5.6 → 5.6.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/dist/{Telemetry-DDHXBdEz.cjs → Telemetry-CDyZhMHb.cjs} +27 -89
- package/dist/Telemetry-CDyZhMHb.cjs.map +1 -0
- package/dist/{Telemetry-CMXOVUKB.js → Telemetry-WZD1Le7A.js} +18 -43
- package/dist/Telemetry-WZD1Le7A.js.map +1 -0
- package/dist/agent-BPIqnEl2.js +59 -0
- package/dist/agent-BPIqnEl2.js.map +1 -0
- package/dist/agent-DElUuYuy.cjs +120 -0
- package/dist/agent-DElUuYuy.cjs.map +1 -0
- package/dist/{background-DxlRE9O5.js → background-CQmrmXMz.js} +7 -10
- package/dist/background-CQmrmXMz.js.map +1 -0
- package/dist/{background-Bbcc2TdN.cjs → background-Ch3napsn.cjs} +8 -7
- package/dist/background-Ch3napsn.cjs.map +1 -0
- package/dist/background-D7IE4acj.js +2 -0
- package/dist/commands-CCMgXgwc.cjs +87 -0
- package/dist/commands-CCMgXgwc.cjs.map +1 -0
- package/dist/commands-ECaVqjMu.js +81 -0
- package/dist/commands-ECaVqjMu.js.map +1 -0
- package/dist/config-B2BlaYOU.cjs +164 -0
- package/dist/config-B2BlaYOU.cjs.map +1 -0
- package/dist/config-CCxOcwWu.js +146 -0
- package/dist/config-CCxOcwWu.js.map +1 -0
- package/dist/constants-CdxpgX3_.cjs.map +1 -1
- package/dist/constants-DHRspBTo.js.map +1 -1
- package/dist/{errors-C-wEou02.cjs → errors-CMbMAwyW.cjs} +2 -2
- package/dist/{errors-C-wEou02.cjs.map → errors-CMbMAwyW.cjs.map} +1 -1
- package/dist/index.cjs +425 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +423 -20
- package/dist/index.js.map +1 -1
- package/dist/output-CnSY0tCG.js +766 -0
- package/dist/output-CnSY0tCG.js.map +1 -0
- package/dist/output-gox62nKo.cjs +868 -0
- package/dist/output-gox62nKo.cjs.map +1 -0
- package/dist/{run-CZz_GbE4.cjs → run-3xcH2h63.cjs} +12 -26
- package/dist/run-3xcH2h63.cjs.map +1 -0
- package/dist/{run-y6LRyWdS.cjs → run-BIK3c6u-.cjs} +96 -186
- package/dist/run-BIK3c6u-.cjs.map +1 -0
- package/dist/run-BKHV1Apt.cjs +31 -0
- package/dist/run-BKHV1Apt.cjs.map +1 -0
- package/dist/{run-Dn8HVjnM.js → run-BP_Z7A4e.js} +23 -44
- package/dist/run-BP_Z7A4e.js.map +1 -0
- package/dist/{run-C-jBKNbI.cjs → run-BvKVx0qs.cjs} +22 -43
- package/dist/run-BvKVx0qs.cjs.map +1 -0
- package/dist/run-DAYWA84e.js +349 -0
- package/dist/run-DAYWA84e.js.map +1 -0
- package/dist/run-J7ekQ_kc.js +30 -0
- package/dist/run-J7ekQ_kc.js.map +1 -0
- package/dist/{run-BDaZPU-1.js → run-TsXMXWSj.js} +91 -174
- package/dist/run-TsXMXWSj.js.map +1 -0
- package/dist/run-UY0fzPon.cjs +351 -0
- package/dist/run-UY0fzPon.cjs.map +1 -0
- package/dist/{run-BdTwxLCW.js → run-sM7YjAc9.js} +9 -23
- package/dist/run-sM7YjAc9.js.map +1 -0
- package/dist/{snapshot-B5mc4gpC.js → snapshot-7yPYU6ol.js} +68 -136
- package/dist/snapshot-7yPYU6ol.js.map +1 -0
- package/dist/{snapshot-DnCxZfmM.cjs → snapshot-Bi1Jy0hs.cjs} +69 -137
- package/dist/snapshot-Bi1Jy0hs.cjs.map +1 -0
- package/dist/studioWorker.js +3 -9
- package/dist/studioWorker.js.map +1 -1
- package/package.json +8 -12
- package/dist/Telemetry-CMXOVUKB.js.map +0 -1
- package/dist/Telemetry-DDHXBdEz.cjs.map +0 -1
- package/dist/agent-DiB4CRre.cjs +0 -38
- package/dist/agent-DiB4CRre.cjs.map +0 -1
- package/dist/agent-yA5vrXJB.js +0 -26
- package/dist/agent-yA5vrXJB.js.map +0 -1
- package/dist/background-Bbcc2TdN.cjs.map +0 -1
- package/dist/background-CFNncNYT.js +0 -2
- package/dist/background-DxlRE9O5.js.map +0 -1
- package/dist/connect-C9tTngda.js +0 -11
- package/dist/connect-C9tTngda.js.map +0 -1
- package/dist/connect-CJ7BhOcs.cjs +0 -11
- package/dist/connect-CJ7BhOcs.cjs.map +0 -1
- package/dist/generate-BUqZ_7GB.cjs +0 -92
- package/dist/generate-BUqZ_7GB.cjs.map +0 -1
- package/dist/generate-q2m01zRd.js +0 -92
- package/dist/generate-q2m01zRd.js.map +0 -1
- package/dist/gunshiDryRun-DdKJuVn1.js +0 -2
- package/dist/init-Ckpwkfvz.cjs +0 -58
- package/dist/init-Ckpwkfvz.cjs.map +0 -1
- package/dist/init-DukE9Uw4.js +0 -58
- package/dist/init-DukE9Uw4.js.map +0 -1
- package/dist/login-Bc19oiFE.cjs +0 -11
- package/dist/login-Bc19oiFE.cjs.map +0 -1
- package/dist/login-Do3nns0B.js +0 -11
- package/dist/login-Do3nns0B.js.map +0 -1
- package/dist/logout-BvHFvCeI.cjs +0 -16
- package/dist/logout-BvHFvCeI.cjs.map +0 -1
- package/dist/logout-COxoIMum.js +0 -16
- package/dist/logout-COxoIMum.js.map +0 -1
- package/dist/mcp-B-GxGgVr.js +0 -19
- package/dist/mcp-B-GxGgVr.js.map +0 -1
- package/dist/mcp-B3B-rE7W.cjs +0 -18
- package/dist/mcp-B3B-rE7W.cjs.map +0 -1
- package/dist/output-CVLosNZq.cjs +0 -411
- package/dist/output-CVLosNZq.cjs.map +0 -1
- package/dist/output-FDo-db-w.js +0 -321
- package/dist/output-FDo-db-w.js.map +0 -1
- package/dist/package-Ci2fcoOV.js +0 -6
- package/dist/package-Ci2fcoOV.js.map +0 -1
- package/dist/package-Do9rJ7D3.cjs +0 -11
- package/dist/package-Do9rJ7D3.cjs.map +0 -1
- package/dist/rolldown-runtime-qbf5tadS.cjs +0 -38
- package/dist/run-BDaZPU-1.js.map +0 -1
- package/dist/run-BdTwxLCW.js.map +0 -1
- package/dist/run-C-jBKNbI.cjs.map +0 -1
- package/dist/run-CAcQlhub.js +0 -295
- package/dist/run-CAcQlhub.js.map +0 -1
- package/dist/run-CSoFhDyK.cjs +0 -297
- package/dist/run-CSoFhDyK.cjs.map +0 -1
- package/dist/run-CZz_GbE4.cjs.map +0 -1
- package/dist/run-CaEbo-te.js +0 -40
- package/dist/run-CaEbo-te.js.map +0 -1
- package/dist/run-CihzLZmR.cjs +0 -41
- package/dist/run-CihzLZmR.cjs.map +0 -1
- package/dist/run-Dn8HVjnM.js.map +0 -1
- package/dist/run-y6LRyWdS.cjs.map +0 -1
- package/dist/shared-Cl-OLpNh.cjs +0 -81
- package/dist/shared-Cl-OLpNh.cjs.map +0 -1
- package/dist/shared-DaHA7QFQ.js +0 -58
- package/dist/shared-DaHA7QFQ.js.map +0 -1
- package/dist/snapshot-B5mc4gpC.js.map +0 -1
- package/dist/snapshot-DnCxZfmM.cjs.map +0 -1
- package/dist/start-B-GXO8tS.cjs +0 -12
- package/dist/start-B-GXO8tS.cjs.map +0 -1
- package/dist/start-Dbfx_8zG.js +0 -12
- package/dist/start-Dbfx_8zG.js.map +0 -1
- package/dist/status-DDajNc8w.js +0 -17
- package/dist/status-DDajNc8w.js.map +0 -1
- package/dist/status-DusS7DfO.cjs +0 -17
- package/dist/status-DusS7DfO.cjs.map +0 -1
- package/dist/stop-C5t7Yx0t.js +0 -11
- package/dist/stop-C5t7Yx0t.js.map +0 -1
- package/dist/stop-zmM3A0Re.cjs +0 -11
- package/dist/stop-zmM3A0Re.cjs.map +0 -1
- package/dist/studio--IOOl_VB.js +0 -174
- package/dist/studio--IOOl_VB.js.map +0 -1
- package/dist/studio-CJ2XhtRd.cjs +0 -174
- package/dist/studio-CJ2XhtRd.cjs.map +0 -1
- package/dist/utils-C3HZOWL_.js +0 -1107
- package/dist/utils-C3HZOWL_.js.map +0 -1
- package/dist/utils-ClRbJfxu.cjs +0 -1210
- package/dist/utils-ClRbJfxu.cjs.map +0 -1
- package/dist/validate-BcB0tFQ6.cjs +0 -19
- package/dist/validate-BcB0tFQ6.cjs.map +0 -1
- package/dist/validate-QpkCbIFJ.js +0 -20
- package/dist/validate-QpkCbIFJ.js.map +0 -1
|
@@ -1,98 +1,50 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
2
|
import { t as toError } from "./errors-BQJzaUwP.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { f as setupReporters, l as plainLogger, n as getConfigs } from "./utils-C3HZOWL_.js";
|
|
6
|
-
import { f as canUseTTY, o as logIntro, r as logBlock, s as logOutro, t as createSpinner, u as logTip } from "./output-FDo-db-w.js";
|
|
7
|
-
import { t as version } from "./package-Ci2fcoOV.js";
|
|
3
|
+
import { i as isCIEnvironment } from "./agent-BPIqnEl2.js";
|
|
4
|
+
import { n as trackRun, r as version } from "./Telemetry-WZD1Le7A.js";
|
|
8
5
|
import { t as KUBB_CONFIG_FILENAME } from "./constants-DHRspBTo.js";
|
|
6
|
+
import { r as setupReporters, t as getConfigs } from "./config-CCxOcwWu.js";
|
|
7
|
+
import { g as plainLogger, o as logIntro, p as canUseTTY, r as logBlock, s as logOutro, t as createSpinner, u as logTip } from "./output-CnSY0tCG.js";
|
|
9
8
|
import { styleText } from "node:util";
|
|
10
|
-
import { hash } from "node:crypto";
|
|
11
|
-
import {
|
|
9
|
+
import { hash, randomBytes } from "node:crypto";
|
|
10
|
+
import { hostname } from "node:os";
|
|
12
11
|
import process from "node:process";
|
|
13
|
-
import {
|
|
14
|
-
import { access, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
12
|
+
import { x } from "tinyexec";
|
|
15
13
|
import path from "node:path";
|
|
16
|
-
import {
|
|
14
|
+
import { Hookable, cliReporter, kubbStorage, logLevel, resolveKubbDir } from "@kubb/core";
|
|
17
15
|
import * as prompts from "@clack/prompts";
|
|
18
|
-
import {
|
|
16
|
+
import { InvalidAgentTokenError, PairingCanceledError, connectAgent, defaultStudioUrl, pairAgent } from "@kubb/studio";
|
|
19
17
|
//#region ../../internals/utils/src/openInBrowser.ts
|
|
18
|
+
const ignore = () => {};
|
|
20
19
|
/**
|
|
21
20
|
* Opens a URL or local file in the default browser, unless running in CI.
|
|
22
21
|
*/
|
|
23
22
|
function openInBrowser(target) {
|
|
24
23
|
if (isCIEnvironment()) return;
|
|
25
|
-
if (process.platform === "win32")
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Resolves to `true` when the file or directory at `path` exists.
|
|
37
|
-
* Uses `Bun.file().exists()` when running under Bun, `fs.access` otherwise.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* if (await exists('./kubb.config.ts')) {
|
|
42
|
-
* const content = await read('./kubb.config.ts')
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
async function exists(path) {
|
|
47
|
-
if (runtime.isBun) return Bun.file(path).exists();
|
|
48
|
-
return access(path).then(() => true, () => false);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Reads the file at `path` as a UTF-8 string.
|
|
52
|
-
* Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* const source = await read('./src/Pet.ts')
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
async function read(path) {
|
|
60
|
-
if (runtime.isBun) return Bun.file(path).text();
|
|
61
|
-
return readFile(path, { encoding: "utf8" });
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Recursively removes `path`. Silently succeeds when `path` does not exist.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* await clean('./dist')
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
async function clean(path) {
|
|
72
|
-
return rm(path, {
|
|
73
|
-
recursive: true,
|
|
74
|
-
force: true
|
|
75
|
-
});
|
|
24
|
+
if (process.platform === "win32") {
|
|
25
|
+
x("cmd", [
|
|
26
|
+
"/c",
|
|
27
|
+
"start",
|
|
28
|
+
"",
|
|
29
|
+
target
|
|
30
|
+
]).then(ignore, ignore);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
x(process.platform === "darwin" ? "open" : "xdg-open", [target]).then(ignore, ignore);
|
|
76
34
|
}
|
|
77
35
|
//#endregion
|
|
78
36
|
//#region src/runners/studio/credentials.ts
|
|
37
|
+
const projectBase = (project = process.cwd()) => path.join("projects", hash("sha256", project));
|
|
79
38
|
/**
|
|
80
|
-
* Root for
|
|
81
|
-
* the last Studio config, and the live-session registry. `KUBB_HOME` relocates all of it.
|
|
82
|
-
*/
|
|
83
|
-
function getKubbHome() {
|
|
84
|
-
return process.env.KUBB_HOME ?? path.join(homedir(), ".kubb");
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Root for the credential and machine identity of the current project.
|
|
39
|
+
* Root for the credential and machine identity of the current project, inside `KUBB_HOME`.
|
|
88
40
|
*
|
|
89
41
|
* Studio agents are project connections, so two projects on one machine must not share the same
|
|
90
42
|
* persisted token or machine secret.
|
|
91
43
|
*/
|
|
92
44
|
function getProjectKubbHome(project = process.cwd()) {
|
|
93
|
-
|
|
94
|
-
return path.join(getKubbHome(), "projects", projectId);
|
|
45
|
+
return resolveKubbDir(projectBase(project));
|
|
95
46
|
}
|
|
47
|
+
const projectStorage = () => kubbStorage({ base: projectBase() });
|
|
96
48
|
const CREDENTIALS_FILENAME = "credentials.json";
|
|
97
49
|
/**
|
|
98
50
|
* Absolute path of the stored credential, so callers can name it in output without rebuilding it.
|
|
@@ -106,32 +58,33 @@ function getCredentialsPath() {
|
|
|
106
58
|
* overwrite it rather than the CLI dying on it.
|
|
107
59
|
*/
|
|
108
60
|
async function readCredentials() {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
return JSON.parse(raw);
|
|
113
|
-
} catch {
|
|
114
|
-
return null;
|
|
115
|
-
}
|
|
61
|
+
const stored = await projectStorage().getItem(CREDENTIALS_FILENAME).catch(() => null);
|
|
62
|
+
return typeof stored?.token === "string" && stored.token !== "" ? stored : null;
|
|
116
63
|
}
|
|
117
64
|
/**
|
|
118
|
-
* Writes the credential
|
|
119
|
-
* is set at creation time rather than left to the process umask or fixed up afterward, which
|
|
120
|
-
* would leave the token briefly readable under the umask's default mode.
|
|
65
|
+
* Writes the credential into the project folder, which only its owner can open.
|
|
121
66
|
*/
|
|
122
67
|
async function writeCredentials(credentials) {
|
|
123
|
-
|
|
124
|
-
await mkdir(path.dirname(file), {
|
|
125
|
-
recursive: true,
|
|
126
|
-
mode: 448
|
|
127
|
-
});
|
|
128
|
-
await writeFile(file, JSON.stringify(credentials, null, 2), { mode: 384 });
|
|
68
|
+
await projectStorage().setItem(CREDENTIALS_FILENAME, credentials);
|
|
129
69
|
}
|
|
130
70
|
/**
|
|
131
71
|
* Forgets the stored credential. Succeeds when there was nothing to forget.
|
|
132
72
|
*/
|
|
133
73
|
async function clearCredentials() {
|
|
134
|
-
await
|
|
74
|
+
await projectStorage().removeItem(CREDENTIALS_FILENAME);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Reads this project's machine secret, creating it on first use. Pairing sends its hash, so pairing
|
|
78
|
+
* the same project again rotates one agent's token instead of creating a second agent. It lives
|
|
79
|
+
* apart from the credential, which {@link clearCredentials} deletes.
|
|
80
|
+
*/
|
|
81
|
+
async function getMachineId() {
|
|
82
|
+
const storage = projectStorage();
|
|
83
|
+
const stored = await storage.getItem("machine-secret").catch(() => null);
|
|
84
|
+
if (typeof stored === "string" && stored.trim()) return stored.trim();
|
|
85
|
+
const secret = randomBytes(32).toString("hex");
|
|
86
|
+
await storage.setItem("machine-secret", secret);
|
|
87
|
+
return secret;
|
|
135
88
|
}
|
|
136
89
|
//#endregion
|
|
137
90
|
//#region src/runners/studio/run.ts
|
|
@@ -166,6 +119,7 @@ async function login({ studioUrl, autoOpen }, { signal, previousCredentials } =
|
|
|
166
119
|
type: "cli",
|
|
167
120
|
name: path.basename(process.cwd()),
|
|
168
121
|
hostname: hostname(),
|
|
122
|
+
machineId: await getMachineId(),
|
|
169
123
|
signal,
|
|
170
124
|
onCode: (session) => {
|
|
171
125
|
console.log(`\nOpen ${styleText("cyan", session.verification_uri)} and approve the code ${styleText("bold", session.user_code)}`);
|
|
@@ -323,68 +277,59 @@ async function connect(options, context = {}) {
|
|
|
323
277
|
events.once("SIGINT", stop);
|
|
324
278
|
events.once("SIGTERM", stop);
|
|
325
279
|
}
|
|
326
|
-
let hinted = false;
|
|
327
|
-
let reauthenticated = false;
|
|
328
280
|
try {
|
|
329
281
|
if (!context.prepared) {
|
|
330
|
-
const { getWorkerStatus } = await import("./background-
|
|
282
|
+
const { getWorkerStatus } = await import("./background-D7IE4acj.js");
|
|
331
283
|
if ((await getWorkerStatus()).running) throw new Error("This project is running in the background. Run `kubb studio stop` first.");
|
|
332
284
|
}
|
|
333
285
|
const prepared = context.prepared ?? await prepareConnection(options, signal);
|
|
334
286
|
let { credentials, permissions } = prepared;
|
|
335
287
|
const { configPath } = prepared;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
288
|
+
let hinted = false;
|
|
289
|
+
let pairedAgain = false;
|
|
290
|
+
const hooks = new Hookable();
|
|
291
|
+
setupReporters(hooks, {
|
|
292
|
+
logLevel: logLevel[options.logLevel ?? "info"],
|
|
293
|
+
reporters: [cliReporter],
|
|
294
|
+
...context.onState ? { logger: plainLogger } : {}
|
|
295
|
+
});
|
|
296
|
+
hooks.hook("studio:connected", async () => {
|
|
297
|
+
pairedAgain = false;
|
|
298
|
+
await context.onState?.("connected");
|
|
299
|
+
if (hinted || context.onState || options.logLevel === "silent") return;
|
|
300
|
+
hinted = true;
|
|
301
|
+
logBlock(styleText("dim", "Press Ctrl+C to disconnect"));
|
|
302
|
+
logTip();
|
|
303
|
+
});
|
|
304
|
+
hooks.hook("studio:reconnecting", () => context.onState?.("reconnecting"));
|
|
305
|
+
for (;;) try {
|
|
306
|
+
await connectAgent({
|
|
307
|
+
token: credentials.token,
|
|
340
308
|
studioUrl: options.studioUrl,
|
|
341
309
|
configPath,
|
|
342
310
|
version: options.version,
|
|
343
311
|
root: process.cwd(),
|
|
344
312
|
permissions,
|
|
345
313
|
loadConfig: async () => (await loadConfigs(options)).config,
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
if (process.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, "envToken");
|
|
366
|
-
if (!live) await clearCredentials();
|
|
367
|
-
if (reauthenticated) throw explainRejectedToken(error, "reauthExhausted");
|
|
368
|
-
if (context.onState || isCIEnvironment() || !canUseTTY()) throw explainRejectedToken(error, "nonInteractive");
|
|
369
|
-
console.log(styleText("yellow", live ? `${error.message} Studio needs you to approve access again.` : `${error.message} Pairing again...`));
|
|
370
|
-
if (live) await clearCredentials();
|
|
371
|
-
try {
|
|
372
|
-
credentials = await login(options, {
|
|
373
|
-
signal,
|
|
374
|
-
previousCredentials: credentials
|
|
375
|
-
});
|
|
376
|
-
} catch (error) {
|
|
377
|
-
if (error instanceof PairingCanceledError) {
|
|
378
|
-
if (live && options.logLevel !== "silent") logOutro("Disconnected");
|
|
379
|
-
return null;
|
|
380
|
-
}
|
|
381
|
-
throw error;
|
|
382
|
-
}
|
|
383
|
-
reauthenticated = true;
|
|
384
|
-
permissions = await resolvePermissions(options, credentials, configPath, !process.env.KUBB_AGENT_TOKEN);
|
|
385
|
-
return credentials;
|
|
386
|
-
}
|
|
387
|
-
});
|
|
314
|
+
hooks,
|
|
315
|
+
signal
|
|
316
|
+
});
|
|
317
|
+
break;
|
|
318
|
+
} catch (error) {
|
|
319
|
+
if (!(error instanceof InvalidAgentTokenError)) throw error;
|
|
320
|
+
await context.onState?.("authentication required");
|
|
321
|
+
if (process.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, "envToken");
|
|
322
|
+
await clearCredentials();
|
|
323
|
+
if (pairedAgain) throw explainRejectedToken(error, "reauthExhausted");
|
|
324
|
+
if (context.onState || isCIEnvironment() || !canUseTTY()) throw explainRejectedToken(error, "nonInteractive");
|
|
325
|
+
console.log(styleText("yellow", `${error.message} Pairing again...`));
|
|
326
|
+
credentials = await login(options, {
|
|
327
|
+
signal,
|
|
328
|
+
previousCredentials: credentials
|
|
329
|
+
});
|
|
330
|
+
pairedAgain = true;
|
|
331
|
+
permissions = await resolvePermissions(options, credentials, configPath);
|
|
332
|
+
}
|
|
388
333
|
if (!context.onState && signal.aborted && options.logLevel !== "silent") logOutro("Disconnected");
|
|
389
334
|
} catch (error) {
|
|
390
335
|
if (!(error instanceof PairingCanceledError)) throw error;
|
|
@@ -394,55 +339,27 @@ async function connect(options, context = {}) {
|
|
|
394
339
|
}
|
|
395
340
|
}
|
|
396
341
|
/**
|
|
397
|
-
* Reports the paired agent and any saved permissions for the current project.
|
|
398
|
-
*/
|
|
399
|
-
async function status(options) {
|
|
400
|
-
const credentials = await readCredentials();
|
|
401
|
-
if (!credentials) {
|
|
402
|
-
console.log("Not paired. Run `kubb studio login`.");
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
console.log(`Paired with ${credentials.studioUrl} as ${styleText("cyan", credentials.agentSlug || credentials.agentId)}`);
|
|
406
|
-
if (credentials.studioUrl !== options.studioUrl) console.log(styleText("yellow", `Connecting to ${options.studioUrl} needs pairing again.`));
|
|
407
|
-
const remembered = credentials.projects?.[process.cwd()];
|
|
408
|
-
if (!remembered) {
|
|
409
|
-
console.log(styleText("dim", "No saved permissions for this project. Run `kubb studio` to connect and choose."));
|
|
410
|
-
return;
|
|
411
|
-
}
|
|
412
|
-
console.log(styleText("dim", "Saved permissions"));
|
|
413
|
-
for (const row of formatPermissionRows({
|
|
414
|
-
allowRead: remembered.allowRead === true,
|
|
415
|
-
allowWrite: remembered.allowWrite === true,
|
|
416
|
-
allowConfigEdit: remembered.allowConfigEdit === true,
|
|
417
|
-
allowExec: remembered.allowExec === true
|
|
418
|
-
})) console.log(row);
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
342
|
* Runs a Studio command with shared setup and telemetry reporting.
|
|
422
343
|
*/
|
|
423
|
-
async function run(options, action,
|
|
424
|
-
|
|
425
|
-
const hrStart = process.hrtime();
|
|
426
|
-
const report = (status) => sendTelemetry(buildTelemetryEvent({
|
|
344
|
+
async function run({ options, action, block = false, json = false }) {
|
|
345
|
+
const report = trackRun({
|
|
427
346
|
command: "studio",
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
status
|
|
431
|
-
}));
|
|
347
|
+
hrStart: process.hrtime()
|
|
348
|
+
});
|
|
432
349
|
try {
|
|
433
350
|
if (options.logLevel !== "silent" && !json) logIntro({
|
|
434
351
|
warning: styleText("yellow", "This feature is still under development, use with caution"),
|
|
435
352
|
block
|
|
436
353
|
});
|
|
437
354
|
await action();
|
|
438
|
-
await report("success");
|
|
355
|
+
await report({ status: "success" });
|
|
439
356
|
} catch (error) {
|
|
440
|
-
await report("failed");
|
|
357
|
+
await report({ status: "failed" });
|
|
441
358
|
console.error(toError(error).message);
|
|
442
359
|
process.exitCode = 1;
|
|
443
360
|
}
|
|
444
361
|
}
|
|
445
362
|
//#endregion
|
|
446
|
-
export {
|
|
363
|
+
export { login as a, clearCredentials as c, loadConfigs as i, getProjectKubbHome as l, createStudioOptions as n, prepareConnection as o, formatPermissionRows as r, run as s, connect as t, readCredentials as u };
|
|
447
364
|
|
|
448
|
-
//# sourceMappingURL=run-
|
|
365
|
+
//# sourceMappingURL=run-TsXMXWSj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-TsXMXWSj.js","names":["logLevelMap"],"sources":["../../../internals/utils/src/openInBrowser.ts","../src/runners/studio/credentials.ts","../src/runners/studio/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { x } from 'tinyexec'\nimport { isCIEnvironment } from './isCIEnvironment.ts'\n\nconst ignore = () => {}\n\n/**\n * Opens a URL or local file in the default browser, unless running in CI.\n */\nexport function openInBrowser(target: string): void {\n if (isCIEnvironment()) return\n\n if (process.platform === 'win32') {\n x('cmd', ['/c', 'start', '', target]).then(ignore, ignore)\n return\n }\n x(process.platform === 'darwin' ? 'open' : 'xdg-open', [target]).then(ignore, ignore)\n}\n","import { hash, randomBytes } from 'node:crypto'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { kubbStorage, resolveKubbDir } from '@kubb/core'\n\nconst projectBase = (project = process.cwd()) => path.join('projects', hash('sha256', project))\n\n/**\n * Root for the credential and machine identity of the current project, inside `KUBB_HOME`.\n *\n * Studio agents are project connections, so two projects on one machine must not share the same\n * persisted token or machine secret.\n */\nexport function getProjectKubbHome(project = process.cwd()): string {\n return resolveKubbDir(projectBase(project))\n}\n\nconst projectStorage = () => kubbStorage({ base: projectBase() })\n\nconst CREDENTIALS_FILENAME = 'credentials.json'\n\n/**\n * Absolute path of the stored credential, so callers can name it in output without rebuilding it.\n */\nexport function getCredentialsPath(): string {\n return path.join(getProjectKubbHome(), CREDENTIALS_FILENAME)\n}\n\nexport type Credentials = {\n /**\n * The Studio instance this machine paired with. A different `--url` means re-pairing.\n */\n studioUrl: string\n /**\n * Bearer token for this machine. Never logged, never printed.\n */\n token: string\n agentId: string\n agentSlug: string\n /**\n * Permissions the user has already granted, keyed by absolute project path, so the CLI asks\n * once per project instead of on every run.\n */\n projects?: Record<string, { allowRead?: boolean; allowWrite?: boolean; allowConfigEdit?: boolean; allowExec?: boolean }>\n}\n\n/**\n * Reads the stored credential, or null when this machine has not paired yet or the file is\n * unreadable or corrupt. A bad file is treated as \"not paired\" so `kubb studio login` can\n * overwrite it rather than the CLI dying on it.\n */\nexport async function readCredentials(): Promise<Credentials | null> {\n const stored = await projectStorage()\n .getItem<Credentials>(CREDENTIALS_FILENAME)\n .catch(() => null)\n\n return typeof stored?.token === 'string' && stored.token !== '' ? stored : null\n}\n\n/**\n * Writes the credential into the project folder, which only its owner can open.\n */\nexport async function writeCredentials(credentials: Credentials): Promise<void> {\n await projectStorage().setItem(CREDENTIALS_FILENAME, credentials)\n}\n\n/**\n * Forgets the stored credential. Succeeds when there was nothing to forget.\n */\nexport async function clearCredentials(): Promise<void> {\n await projectStorage().removeItem(CREDENTIALS_FILENAME)\n}\n\n/**\n * Reads this project's machine secret, creating it on first use. Pairing sends its hash, so pairing\n * the same project again rotates one agent's token instead of creating a second agent. It lives\n * apart from the credential, which {@link clearCredentials} deletes.\n */\nexport async function getMachineId(): Promise<string> {\n const storage = projectStorage()\n const stored = await storage.getItem('machine-secret').catch(() => null)\n if (typeof stored === 'string' && stored.trim()) return stored.trim()\n\n const secret = randomBytes(32).toString('hex')\n await storage.setItem('machine-secret', secret)\n\n return secret\n}\n","import { hostname } from 'node:os'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as prompts from '@clack/prompts'\nimport { KUBB_CONFIG_FILENAME } from '@internals/shared'\nimport { isCIEnvironment, openInBrowser, toError } from '@internals/utils'\nimport type { CLIOptions, Config } from '@kubb/core'\nimport { cliReporter, Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport { connectAgent, defaultStudioUrl, InvalidAgentTokenError, pairAgent, PairingCanceledError } from '@kubb/studio'\nimport { trackRun } from '../../Telemetry.ts'\nimport { plainLogger } from '../../loggers/plainLogger.ts'\nimport setupReporters from '../../loggers/reporters.ts'\nimport { createSpinner, logBlock, logIntro, logOutro, logTip } from '../../loggers/output.ts'\nimport { canUseTTY } from '../../utils/env.ts'\nimport { getConfigs } from '../../config.ts'\nimport { clearCredentials, type Credentials, getCredentialsPath, getMachineId, readCredentials, writeCredentials } from './credentials.ts'\nimport { version } from '../../../package.json'\n\ntype Permission = 'allowRead' | 'allowWrite' | 'allowConfigEdit' | 'allowExec'\n\nexport type StudioOptions = {\n /**\n * Current `@kubb/cli` version, reported to Studio and used for the telemetry payload.\n */\n version: string\n configPath?: string\n /**\n * Base URL of the Studio instance, for a self-hosted deployment. Resolved before it reaches here,\n * since stored credentials are bound to it.\n */\n studioUrl: string\n /**\n * What Studio may do in this project. Each flag grants outright; the rest are asked once per\n * project through {@link resolvePermissions}.\n */\n permission: Record<Permission, boolean>\n /**\n * Whether to open the approval page in a browser during pairing.\n */\n autoOpen: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport type SnapshotOptions = Pick<StudioOptions, 'configPath' | 'studioUrl' | 'logLevel'> & {\n /**\n * Organization CI API key. Falls back to `KUBB_TOKEN`.\n */\n token?: string\n /**\n * Stable identity for the CI agent. Falls back to CI auto-detection.\n */\n id?: string\n /** Identity of another CI agent to also compare with. Falls back to CI auto-detection. */\n baseId?: string\n /**\n * Package name for the generated tarball. Falls back to the nearest package.json.\n */\n name?: string\n /**\n * Package version for the generated tarball. Falls back to the nearest package.json.\n */\n packageVersion?: string\n /**\n * Print the result as one JSON object instead of a summary.\n */\n json?: boolean\n}\n\ntype StudioValues = {\n config?: string\n url?: string\n allowRead: boolean\n allowWrite: boolean\n allowConfigEdit: boolean\n allowExec: boolean\n open?: boolean\n logLevel?: CLIOptions['logLevel']\n}\n\nexport function createStudioOptions(values: StudioValues): StudioOptions {\n return {\n version,\n configPath: values.config,\n studioUrl: values.url ?? defaultStudioUrl,\n permission: {\n allowRead: values.allowRead,\n allowWrite: values.allowWrite,\n allowConfigEdit: values.allowConfigEdit,\n allowExec: values.allowExec,\n },\n autoOpen: values.open ?? true,\n logLevel: values.logLevel,\n }\n}\n\ntype LoginOptions = {\n /**\n * Aborting this cancels an in-flight pairing request or poll and rejects with\n * {@link PairingCanceledError}. Wired to `kubb studio`'s shutdown signal, so Ctrl+C during\n * pairing cancels it instead of leaving the poll running.\n */\n signal?: AbortSignal\n /**\n * Credentials from before this login. When the fresh pairing resolves to the same agent on the\n * same Studio, its saved project permissions carry forward instead of being asked again.\n * Left out for an explicitly requested `kubb studio login`, which always starts clean.\n */\n previousCredentials?: Credentials | null\n}\n\n/**\n * Pairs this machine with Studio and stores the resulting token.\n *\n * The CLI holds a code and the browser approves it, rather than the user copying a token out of\n * the UI. The token comes back over the CLI's own HTTPS POST, so it never lands in a URL, a\n * server log, or a `Referer` header.\n */\nexport async function login({ studioUrl, autoOpen }: StudioOptions, { signal, previousCredentials }: LoginOptions = {}): Promise<Credentials> {\n const spinner = createSpinner()\n // The spinner only starts once a code is shown.\n let waiting = false\n\n try {\n const { token, agent } = await pairAgent({\n studioUrl,\n type: 'cli',\n name: path.basename(process.cwd()),\n hostname: hostname(),\n machineId: await getMachineId(),\n signal,\n onCode: (session) => {\n console.log(`\\nOpen ${styleText('cyan', session.verification_uri)} and approve the code ${styleText('bold', session.user_code)}`)\n\n if (autoOpen) {\n openInBrowser(session.verification_uri_complete)\n }\n\n spinner.start('Waiting for approval')\n waiting = true\n },\n onRetry: (error) => spinner.message(`Could not reach Kubb Studio, retrying: ${error.message}`),\n })\n spinner.stop(`Paired as ${agent.name}`)\n\n const keepsIdentity = previousCredentials?.studioUrl === studioUrl && previousCredentials.agentId === agent.id\n const credentials: Credentials = {\n studioUrl,\n token,\n agentId: agent.id,\n agentSlug: agent.slug,\n ...(keepsIdentity && previousCredentials?.projects ? { projects: previousCredentials.projects } : {}),\n }\n await writeCredentials(credentials)\n\n console.log(`Credentials stored in ${getCredentialsPath()}`)\n\n return credentials\n } catch (error) {\n if (waiting) {\n spinner.stop(error instanceof PairingCanceledError ? 'Pairing canceled' : 'Pairing failed')\n }\n throw error\n }\n}\n\n/**\n * What each permission is asked as, in the order the questions appear.\n */\nconst PERMISSIONS: ReadonlyArray<{\n key: Permission\n /**\n * Short label for status output and the connect summary.\n */\n label: string\n question: (project: string, configPath: string) => string\n}> = [\n {\n key: 'allowRead',\n label: 'read generated files',\n question: () => 'Let Kubb Studio read the files a generation produced?',\n },\n { key: 'allowWrite', label: 'write generated files', question: (project) => `Let Kubb Studio write generated files into ${project}?` },\n {\n key: 'allowConfigEdit',\n label: 'edit kubb.config.ts',\n question: (_project, configPath) => `Let Kubb Studio change plugin options in ${configPath}?`,\n },\n {\n key: 'allowExec',\n label: 'run formatter, linter, postGenerate',\n question: () => 'Let Kubb Studio run the formatter, the linter, and output.postGenerate?',\n },\n]\n\n/**\n * One row per permission, for the connect banner and `kubb studio status`. A list rather than a\n * joined line: four labels this long read as one run-on sentence side by side.\n */\nexport function formatPermissionRows(granted: Record<Permission, boolean>): Array<string> {\n return PERMISSIONS.map(({ key, label }) => `${granted[key] ? styleText('green', '✔') : styleText('red', '✘')} ${label}`)\n}\n\n/**\n * Resolves Studio permissions for the current project.\n * Flags win, saved answers are reused, and new answers are stored unless `persist` is false.\n */\nexport async function resolvePermissions(\n options: StudioOptions,\n credentials: Credentials,\n configPath: string = KUBB_CONFIG_FILENAME,\n /**\n * Stores new answers in `~/.kubb/credentials.json`.\n * Pass `false` for `KUBB_AGENT_TOKEN` sessions so a temporary token is not written back to disk.\n */\n persist = true,\n): Promise<Record<Permission, boolean>> {\n const project = process.cwd()\n const remembered = credentials.projects?.[project]\n const granted: Record<Permission, boolean> = { allowRead: false, allowWrite: false, allowConfigEdit: false, allowExec: false }\n const answers: Partial<Record<Permission, boolean>> = {}\n prompts.updateSettings({ withGuide: true })\n\n for (const { key, question } of PERMISSIONS) {\n if (options.permission[key] || typeof remembered?.[key] === 'boolean') {\n granted[key] = options.permission[key] || remembered?.[key] === true\n continue\n }\n\n if (isCIEnvironment() || !canUseTTY()) {\n granted[key] = false\n continue\n }\n\n granted[key] = (await prompts.confirm({ message: question(project, configPath), initialValue: false })) === true\n answers[key] = granted[key]\n }\n if (persist && Object.keys(answers).length) {\n await writeCredentials({\n ...credentials,\n projects: { ...credentials.projects, [project]: { ...remembered, ...answers } },\n })\n }\n\n return granted\n}\n\n/**\n * Loads the project's Kubb config the same way `kubb generate` does.\n * Returns the first config.\n */\nexport async function loadConfigs(options: Pick<StudioOptions, 'configPath' | 'logLevel'>): Promise<{ configPath: string; config: Config }> {\n const { configPath, configs } = await getConfigs({ configPath: options.configPath, logLevel: options.logLevel })\n const [config] = configs\n\n if (!config) {\n throw new Error('Config not defined, create a kubb.config.ts or pass it with --config')\n }\n\n // `getConfigs` resolves this to an absolute path. Relativized here, once, so the permission\n // prompt and the path Studio receives over the wire both show the project-relative form instead\n // of leaking the local filesystem layout.\n return { configPath: path.relative(process.cwd(), configPath) || configPath, config }\n}\n\n/**\n * Why a rejected token could not be recovered automatically: it came from `KUBB_AGENT_TOKEN`, no\n * browser is available to re-pair with, or the token this run already re-paired for was rejected\n * again.\n */\ntype RejectedTokenReason = 'envToken' | 'nonInteractive' | 'reauthExhausted'\n\n/**\n * Explains a rejected token to the operator. Builds the error and nothing else, so each caller\n * decides what happens to the credentials.\n */\nfunction explainRejectedToken(error: InvalidAgentTokenError, reason: RejectedTokenReason): Error {\n if (reason === 'envToken') {\n return new Error(`${error.message} Pair again and update KUBB_AGENT_TOKEN.`)\n }\n\n if (reason === 'reauthExhausted') {\n return new Error(`${error.message} Studio rejected the newly approved token too. Run \\`kubb studio login\\` and try again.`)\n }\n\n return new Error(`${error.message} Run \\`kubb studio login\\` to pair again.`)\n}\n\nexport type PreparedConnection = {\n configPath: string\n credentials: Credentials\n permissions: StudioOptions['permission']\n}\n\n/** Validates the project and resolves pairing and permissions before starting its worker. */\nexport async function prepareConnection(options: StudioOptions, signal?: AbortSignal): Promise<PreparedConnection> {\n const { configPath } = await loadConfigs(options)\n const envToken = process.env.KUBB_AGENT_TOKEN\n const stored = envToken ? null : await readCredentials()\n const credentials = await (async () => {\n if (envToken) return { studioUrl: options.studioUrl, token: envToken, agentId: '', agentSlug: '' }\n if (stored?.studioUrl === options.studioUrl) return stored\n if (isCIEnvironment()) {\n throw new Error(`Not paired with ${options.studioUrl}. Set KUBB_AGENT_TOKEN, or run \\`kubb studio login\\` on a machine with a browser.`)\n }\n return login(options, { signal })\n })()\n const permissions = await resolvePermissions(options, credentials, configPath, !envToken)\n return { configPath, credentials, permissions }\n}\n\nexport type WorkerState = 'starting' | 'connected' | 'reconnecting' | 'authentication required' | 'stopped'\n\n/** Runs the same project connection in the foreground or in a background worker. */\nexport async function connect(\n options: StudioOptions,\n context: {\n prepared?: PreparedConnection\n signal?: AbortSignal\n onState?: (state: WorkerState) => void | Promise<void>\n } = {},\n): Promise<void> {\n const shutdown = new AbortController()\n const signal = context.signal ?? shutdown.signal\n const stop = () => shutdown.abort()\n const events = process as unknown as NodeJS.EventEmitter\n if (!context.signal) {\n events.once('SIGINT', stop)\n events.once('SIGTERM', stop)\n }\n try {\n if (!context.prepared) {\n const { getWorkerStatus } = await import('./background.ts')\n const worker = await getWorkerStatus()\n if (worker.running) throw new Error('This project is running in the background. Run `kubb studio stop` first.')\n }\n const prepared = context.prepared ?? (await prepareConnection(options, signal))\n let { credentials, permissions } = prepared\n const { configPath } = prepared\n let hinted = false\n // Set by a fresh pairing until it connects, so a token rejected right after approval fails the run instead of looping.\n let pairedAgain = false\n\n // The background worker writes to a log file, so it gets the plain logger rather than the\n // animated one. The logger also covers the `studio:*` events and each generation run.\n const hooks = new Hookable<KubbHooks>()\n setupReporters(hooks, {\n logLevel: logLevelMap[options.logLevel ?? 'info'],\n reporters: [cliReporter],\n ...(context.onState ? { logger: plainLogger } : {}),\n })\n hooks.hook('studio:connected', async () => {\n pairedAgain = false\n await context.onState?.('connected')\n if (hinted || context.onState || options.logLevel === 'silent') return\n hinted = true\n logBlock(styleText('dim', 'Press Ctrl+C to disconnect'))\n logTip()\n })\n hooks.hook('studio:reconnecting', () => context.onState?.('reconnecting'))\n\n for (;;) {\n try {\n await connectAgent({\n token: credentials.token,\n studioUrl: options.studioUrl,\n configPath,\n version: options.version,\n root: process.cwd(),\n permissions,\n loadConfig: async () => (await loadConfigs(options)).config,\n hooks,\n signal,\n })\n break\n } catch (error) {\n if (!(error instanceof InvalidAgentTokenError)) throw error\n await context.onState?.('authentication required')\n if (process.env.KUBB_AGENT_TOKEN) throw explainRejectedToken(error, 'envToken')\n await clearCredentials()\n if (pairedAgain) throw explainRejectedToken(error, 'reauthExhausted')\n if (context.onState || isCIEnvironment() || !canUseTTY()) throw explainRejectedToken(error, 'nonInteractive')\n\n console.log(styleText('yellow', `${error.message} Pairing again...`))\n credentials = await login(options, { signal, previousCredentials: credentials })\n pairedAgain = true\n permissions = await resolvePermissions(options, credentials, configPath)\n }\n }\n if (!context.onState && signal.aborted && options.logLevel !== 'silent') logOutro('Disconnected')\n } catch (error) {\n if (!(error instanceof PairingCanceledError)) throw error\n } finally {\n events.off('SIGINT', stop)\n events.off('SIGTERM', stop)\n }\n}\n\n/**\n * Runs a Studio command with shared setup and telemetry reporting.\n */\nexport async function run({\n options,\n action,\n block = false,\n json = false,\n}: {\n options: Pick<StudioOptions, 'logLevel'>\n action: () => Promise<unknown>\n block?: boolean\n json?: boolean\n}): Promise<void> {\n const report = trackRun({ command: 'studio', hrStart: process.hrtime() })\n\n try {\n if (options.logLevel !== 'silent' && !json) {\n logIntro({\n warning: styleText('yellow', 'This feature is still under development, use with caution'),\n block,\n })\n }\n\n await action()\n\n await report({ status: 'success' })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,MAAM,eAAe,CAAC;;;;AAKtB,SAAgB,cAAc,QAAsB;CAClD,IAAI,gBAAgB,GAAG;CAEvB,IAAI,QAAQ,aAAa,SAAS;EAChC,EAAE,OAAO;GAAC;GAAM;GAAS;GAAI;EAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,MAAM;EACzD;CACF;C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