@kubb/cli 5.5.6 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Telemetry-CMXOVUKB.js → Telemetry-RBcAjNxj.js} +18 -43
- package/dist/Telemetry-RBcAjNxj.js.map +1 -0
- package/dist/{Telemetry-DDHXBdEz.cjs → Telemetry-bGdFBaGt.cjs} +27 -89
- package/dist/Telemetry-bGdFBaGt.cjs.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-0PMj56FJ.js} +6 -5
- package/dist/background-0PMj56FJ.js.map +1 -0
- package/dist/background-BqS01QDb.js +2 -0
- package/dist/{background-Bbcc2TdN.cjs → background-R0T_7Szu.cjs} +8 -7
- package/dist/background-R0T_7Szu.cjs.map +1 -0
- package/dist/commands-BAgGrcvc.js +65 -0
- package/dist/commands-BAgGrcvc.js.map +1 -0
- package/dist/commands-Si-RFAS6.cjs +71 -0
- package/dist/commands-Si-RFAS6.cjs.map +1 -0
- package/dist/config-8Xl4yZmw.js +146 -0
- package/dist/config-8Xl4yZmw.js.map +1 -0
- package/dist/config-ByfJSj3q.cjs +164 -0
- package/dist/config-ByfJSj3q.cjs.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 +431 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +429 -20
- package/dist/index.js.map +1 -1
- package/dist/output-B6Ondw0g.js +776 -0
- package/dist/output-B6Ondw0g.js.map +1 -0
- package/dist/output-i3s5c4Xu.cjs +878 -0
- package/dist/output-i3s5c4Xu.cjs.map +1 -0
- package/dist/run-3I2NPeXG.cjs +31 -0
- package/dist/run-3I2NPeXG.cjs.map +1 -0
- package/dist/{run-C-jBKNbI.cjs → run-BkLJ5mXn.cjs} +22 -43
- package/dist/run-BkLJ5mXn.cjs.map +1 -0
- package/dist/run-CZlkqkDc.js +30 -0
- package/dist/run-CZlkqkDc.js.map +1 -0
- package/dist/run-CmNDNEjR.js +346 -0
- package/dist/run-CmNDNEjR.js.map +1 -0
- package/dist/{run-BdTwxLCW.js → run-D5AeacqK.js} +9 -23
- package/dist/run-D5AeacqK.js.map +1 -0
- package/dist/{run-y6LRyWdS.cjs → run-D8Wz_17X.cjs} +41 -60
- package/dist/run-D8Wz_17X.cjs.map +1 -0
- package/dist/{run-Dn8HVjnM.js → run-DQoKTiGk.js} +23 -44
- package/dist/run-DQoKTiGk.js.map +1 -0
- package/dist/{run-BDaZPU-1.js → run-Dgph0WYk.js} +25 -49
- package/dist/run-Dgph0WYk.js.map +1 -0
- package/dist/run-t8nm7zcT.cjs +348 -0
- package/dist/run-t8nm7zcT.cjs.map +1 -0
- package/dist/{run-CZz_GbE4.cjs → run-yvuot2N9.cjs} +12 -26
- package/dist/run-yvuot2N9.cjs.map +1 -0
- package/dist/{snapshot-B5mc4gpC.js → snapshot-CkHXR0Nl.js} +5 -5
- package/dist/snapshot-CkHXR0Nl.js.map +1 -0
- package/dist/{snapshot-DnCxZfmM.cjs → snapshot-D4nKbwkw.cjs} +9 -9
- package/dist/snapshot-D4nKbwkw.cjs.map +1 -0
- package/dist/studioWorker.js +2 -2
- package/package.json +7 -7
- 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,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import {
|
|
2
|
+
import { i as isCIEnvironment, r as getElapsedMs, t as getAgentName } from "./agent-BPIqnEl2.js";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import process$1 from "node:process";
|
|
@@ -73,57 +73,23 @@ var Runtime = class {
|
|
|
73
73
|
*/
|
|
74
74
|
const runtime = new Runtime();
|
|
75
75
|
//#endregion
|
|
76
|
-
//#region
|
|
77
|
-
|
|
78
|
-
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
79
|
-
*/
|
|
80
|
-
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
81
|
-
/**
|
|
82
|
-
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
83
|
-
*/
|
|
84
|
-
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
85
|
-
/**
|
|
86
|
-
* Glob pattern for paths the file watcher ignores.
|
|
87
|
-
*/
|
|
88
|
-
const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
|
|
89
|
-
/**
|
|
90
|
-
* Interval in milliseconds between polls of a remote `input` URL in watch mode. A remote document
|
|
91
|
-
* emits no filesystem events, so watch mode falls back to fetching it and comparing bodies.
|
|
92
|
-
*/
|
|
93
|
-
const URL_WATCHER_INTERVAL_MS = 2e3;
|
|
94
|
-
/**
|
|
95
|
-
* Upper bound in milliseconds for a single URL watcher request, covering both the response headers
|
|
96
|
-
* and the body read. A server that hangs mid-response would otherwise stall polling forever.
|
|
97
|
-
*/
|
|
98
|
-
const URL_WATCHER_TIMEOUT_MS = 1e4;
|
|
99
|
-
/**
|
|
100
|
-
* Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.
|
|
101
|
-
*/
|
|
102
|
-
const UPDATE_CHECK_TIMEOUT_MS = 3e3;
|
|
103
|
-
/**
|
|
104
|
-
* Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
|
|
105
|
-
*/
|
|
106
|
-
const QUIET_FLAGS = /* @__PURE__ */ new Set([
|
|
107
|
-
"--help",
|
|
108
|
-
"-h",
|
|
109
|
-
"--version",
|
|
110
|
-
"-v",
|
|
111
|
-
"--json"
|
|
112
|
-
]);
|
|
76
|
+
//#region package.json
|
|
77
|
+
var version = "5.6.0";
|
|
113
78
|
//#endregion
|
|
114
79
|
//#region src/Telemetry.ts
|
|
80
|
+
/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */
|
|
81
|
+
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
115
82
|
/**
|
|
116
83
|
* Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
|
|
117
84
|
*/
|
|
118
85
|
function isDisabled() {
|
|
119
|
-
return
|
|
86
|
+
return ["DO_NOT_TRACK", "KUBB_DISABLE_TELEMETRY"].some((name) => ["1", "true"].includes(process$1.env[name] ?? ""));
|
|
120
87
|
}
|
|
121
88
|
/**
|
|
122
89
|
* Build an anonymous telemetry payload from a completed generation run.
|
|
123
90
|
*/
|
|
124
91
|
function buildTelemetryEvent(options) {
|
|
125
|
-
const
|
|
126
|
-
const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
|
|
92
|
+
const duration = Math.round(getElapsedMs(options.hrStart));
|
|
127
93
|
return {
|
|
128
94
|
command: options.command,
|
|
129
95
|
kubbVersion: options.kubbVersion,
|
|
@@ -139,6 +105,15 @@ function buildTelemetryEvent(options) {
|
|
|
139
105
|
status: options.status
|
|
140
106
|
};
|
|
141
107
|
}
|
|
108
|
+
/** Tracks one command run for the running CLI version; returns the reporter the command calls once it knows how it ended. */
|
|
109
|
+
function trackRun({ command, hrStart }) {
|
|
110
|
+
return (result) => sendTelemetry(buildTelemetryEvent({
|
|
111
|
+
command,
|
|
112
|
+
kubbVersion: version,
|
|
113
|
+
hrStart,
|
|
114
|
+
...result
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
142
117
|
/**
|
|
143
118
|
* Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
|
|
144
119
|
*
|
|
@@ -267,6 +242,6 @@ async function sendTelemetry(event) {
|
|
|
267
242
|
} catch (_e) {}
|
|
268
243
|
}
|
|
269
244
|
//#endregion
|
|
270
|
-
export {
|
|
245
|
+
export { runtime as i, trackRun as n, version as r, isDisabled as t };
|
|
271
246
|
|
|
272
|
-
//# sourceMappingURL=Telemetry-
|
|
247
|
+
//# sourceMappingURL=Telemetry-RBcAjNxj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Telemetry-RBcAjNxj.js","names":["process"],"sources":["../../../internals/utils/src/runtime.ts","../package.json","../src/Telemetry.ts"],"sourcesContent":["/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { getElapsedMs, isCIEnvironment, runtime } from '@internals/utils'\nimport { getAgentName } from './agent.ts'\nimport { version } from '../package.json'\n\n/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */\nconst OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\ntype TelemetryCommand = 'generate' | 'mcp' | 'studio' | 'validate'\n\ntype OtlpValue =\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { arrayValue: { values: Array<OtlpValue> } }\n | { kvlistValue: { values: Array<OtlpKeyValue> } }\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpValue\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n name: string\n kind: 1\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes: Array<OtlpKeyValue>\n status: { code: 1 | 2 }\n}\n\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<{\n resource: { attributes: Array<OtlpKeyValue> }\n scopeSpans: Array<{\n scope: { name: string; version: string }\n spans: Array<OtlpSpan>\n }>\n }>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\n/**\n * Anonymous snapshot of a single Kubb run, built by {@link buildTelemetryEvent} and sent by {@link sendTelemetry}.\n */\ntype TelemetryEvent = {\n command: string\n kubbVersion: string\n /**\n * Major version of Node that executed the run, e.g. `'22'`.\n */\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n /**\n * Name of the detected AI coding agent (e.g. `'claude'`, `'cursor'`), when the CLI is invoked\n * by one. `undefined` when run by a human or an unrecognized caller.\n */\n agent?: string\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function isDisabled(): boolean {\n return ['DO_NOT_TRACK', 'KUBB_DISABLE_TELEMETRY'].some((name) => ['1', 'true'].includes(process.env[name] ?? ''))\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n */\nexport function buildTelemetryEvent(options: {\n command: TelemetryCommand\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n}): TelemetryEvent {\n const duration = Math.round(getElapsedMs(options.hrStart))\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n agent: getAgentName(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n\ntype TrackRunOptions = {\n command: TelemetryCommand\n /** `process.hrtime()` snapshot taken when the command started. */\n hrStart: [number, number]\n}\n\ntype RunResult = Pick<TelemetryEvent, 'status'> & Partial<Pick<TelemetryEvent, 'plugins' | 'filesCreated'>>\n\n/** Tracks one command run for the running CLI version; returns the reporter the command calls once it knows how it ended. */\nexport function trackRun({ command, hrStart }: TrackRunOptions): (result: RunResult) => Promise<void> {\n return (result) => sendTelemetry(buildTelemetryEvent({ command, kubbVersion: version, hrStart, ...result }))\n}\n\n/**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n *\n * @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\nexport function buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n const pluginNames = [...new Set(event.plugins.map((plugin) => plugin.name))].sort()\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n ...(event.agent ? [{ key: 'kubb.agent', value: { stringValue: event.agent } }] : []),\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: { arrayValue: { values: pluginNames.map((name) => ({ stringValue: name })) } },\n },\n ...pluginNames.map((name) => ({ key: `kubb.plugin.${name}`, value: { boolValue: true } })),\n {\n key: 'kubb.plugin_options',\n value: {\n arrayValue: {\n values: event.plugins.map((p) => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n })),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: event.status === 'success' ? 1 : 2,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file\n * paths, OpenAPI specs, or secrets are sent.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isDisabled()) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-cli',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;CACxB;;;;CAKA,IAAI,SAAkB;EACpB,OAAO,OAAQ,WAAkC,SAAS;CAC5D;;;;;;CAOA,IAAI,SAAkB;EACpB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU,OAAO,YAAY,eAAe,QAAQ,UAAU,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AAa,EAAE,KAAK;GAAE,GAC9C;IACE,KAAK;IACL,OAAO,EACL,aAAa,KAAK,UAAU;KAC1B,GAAG,EAAE;KACL,eAAe,KAAA;IACjB,CAAC,EACH;GACF,CACF,EACF,EACF,EAAE,EACJ,EACF;EACF;CACF;CAEA,OAAO,EACL,eAAe,CACb;EACE,UAAU,EACR,YAAY;GACV;IAAE,KAAK;IAAgB,OAAO,EAAE,aAAa,OAAO;GAAE;GACtD;IACE,KAAK;IACL,OAAO,EAAE,aAAa,MAAM,YAAY;GAC1C;GACA;IAAE,KAAK;IAA0B,OAAO,EAAE,aAAa,SAAS;GAAE;EACpE,EACF;EACA,YAAY,CACV;GACE,OAAO;IAAE,MAAM;IAAa,SAAS,MAAM;GAAY;GACvD,OAAO,CACL;IACE;IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,WAAW;IACrC,iBAAiB,OAAO,SAAS;IACjC;IACA,QAAQ,EACN,MAAM,MAAM,WAAW,YAAY,IAAI,EACzC;GACF,CACF;EACF,CACF;CACF,CACF,EACF;AACF;;;;;;AAOA,eAAsB,cAAc,OAAsC;CACxE,IAAI,WAAW,GACb;CAGF,IAAI;EACF,MAAM,MAAM,GAAG,cAAc,aAAa;GACxC,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,0BAA0B;IAC1B,yBAAyB;GAC3B;GACA,MAAM,KAAK,UAAU,iBAAiB,KAAK,CAAC;GAC5C,QAAQ,YAAY,QAAQ,GAAK;EACnC,CAAC;CACH,SAAS,IAAI,CAEb;AACF"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_agent = require("./agent-DiB4CRre.cjs");
|
|
1
|
+
const require_agent = require("./agent-DElUuYuy.cjs");
|
|
3
2
|
let node_crypto = require("node:crypto");
|
|
4
3
|
let node_os = require("node:os");
|
|
5
|
-
node_os =
|
|
4
|
+
node_os = require_agent.__toESM(node_os, 1);
|
|
6
5
|
let node_process = require("node:process");
|
|
7
|
-
node_process =
|
|
6
|
+
node_process = require_agent.__toESM(node_process, 1);
|
|
8
7
|
//#region ../../internals/utils/src/runtime.ts
|
|
9
8
|
/**
|
|
10
9
|
* Detects the JavaScript runtime executing the current process and exposes its name and version.
|
|
@@ -75,57 +74,23 @@ var Runtime = class {
|
|
|
75
74
|
*/
|
|
76
75
|
const runtime = new Runtime();
|
|
77
76
|
//#endregion
|
|
78
|
-
//#region
|
|
79
|
-
|
|
80
|
-
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
81
|
-
*/
|
|
82
|
-
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
83
|
-
/**
|
|
84
|
-
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
85
|
-
*/
|
|
86
|
-
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
87
|
-
/**
|
|
88
|
-
* Glob pattern for paths the file watcher ignores.
|
|
89
|
-
*/
|
|
90
|
-
const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
|
|
91
|
-
/**
|
|
92
|
-
* Interval in milliseconds between polls of a remote `input` URL in watch mode. A remote document
|
|
93
|
-
* emits no filesystem events, so watch mode falls back to fetching it and comparing bodies.
|
|
94
|
-
*/
|
|
95
|
-
const URL_WATCHER_INTERVAL_MS = 2e3;
|
|
96
|
-
/**
|
|
97
|
-
* Upper bound in milliseconds for a single URL watcher request, covering both the response headers
|
|
98
|
-
* and the body read. A server that hangs mid-response would otherwise stall polling forever.
|
|
99
|
-
*/
|
|
100
|
-
const URL_WATCHER_TIMEOUT_MS = 1e4;
|
|
101
|
-
/**
|
|
102
|
-
* Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.
|
|
103
|
-
*/
|
|
104
|
-
const UPDATE_CHECK_TIMEOUT_MS = 3e3;
|
|
105
|
-
/**
|
|
106
|
-
* Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
|
|
107
|
-
*/
|
|
108
|
-
const QUIET_FLAGS = /* @__PURE__ */ new Set([
|
|
109
|
-
"--help",
|
|
110
|
-
"-h",
|
|
111
|
-
"--version",
|
|
112
|
-
"-v",
|
|
113
|
-
"--json"
|
|
114
|
-
]);
|
|
77
|
+
//#region package.json
|
|
78
|
+
var version = "5.6.0";
|
|
115
79
|
//#endregion
|
|
116
80
|
//#region src/Telemetry.ts
|
|
81
|
+
/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */
|
|
82
|
+
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
117
83
|
/**
|
|
118
84
|
* Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
|
|
119
85
|
*/
|
|
120
86
|
function isDisabled() {
|
|
121
|
-
return
|
|
87
|
+
return ["DO_NOT_TRACK", "KUBB_DISABLE_TELEMETRY"].some((name) => ["1", "true"].includes(node_process.default.env[name] ?? ""));
|
|
122
88
|
}
|
|
123
89
|
/**
|
|
124
90
|
* Build an anonymous telemetry payload from a completed generation run.
|
|
125
91
|
*/
|
|
126
92
|
function buildTelemetryEvent(options) {
|
|
127
|
-
const
|
|
128
|
-
const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
|
|
93
|
+
const duration = Math.round(require_agent.getElapsedMs(options.hrStart));
|
|
129
94
|
return {
|
|
130
95
|
command: options.command,
|
|
131
96
|
kubbVersion: options.kubbVersion,
|
|
@@ -141,6 +106,15 @@ function buildTelemetryEvent(options) {
|
|
|
141
106
|
status: options.status
|
|
142
107
|
};
|
|
143
108
|
}
|
|
109
|
+
/** Tracks one command run for the running CLI version; returns the reporter the command calls once it knows how it ended. */
|
|
110
|
+
function trackRun({ command, hrStart }) {
|
|
111
|
+
return (result) => sendTelemetry(buildTelemetryEvent({
|
|
112
|
+
command,
|
|
113
|
+
kubbVersion: version,
|
|
114
|
+
hrStart,
|
|
115
|
+
...result
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
144
118
|
/**
|
|
145
119
|
* Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
|
|
146
120
|
*
|
|
@@ -269,48 +243,6 @@ async function sendTelemetry(event) {
|
|
|
269
243
|
} catch (_e) {}
|
|
270
244
|
}
|
|
271
245
|
//#endregion
|
|
272
|
-
Object.defineProperty(exports, "KUBB_NPM_PACKAGE_URL", {
|
|
273
|
-
enumerable: true,
|
|
274
|
-
get: function() {
|
|
275
|
-
return KUBB_NPM_PACKAGE_URL;
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
Object.defineProperty(exports, "QUIET_FLAGS", {
|
|
279
|
-
enumerable: true,
|
|
280
|
-
get: function() {
|
|
281
|
-
return QUIET_FLAGS;
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
Object.defineProperty(exports, "UPDATE_CHECK_TIMEOUT_MS", {
|
|
285
|
-
enumerable: true,
|
|
286
|
-
get: function() {
|
|
287
|
-
return UPDATE_CHECK_TIMEOUT_MS;
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
Object.defineProperty(exports, "URL_WATCHER_INTERVAL_MS", {
|
|
291
|
-
enumerable: true,
|
|
292
|
-
get: function() {
|
|
293
|
-
return URL_WATCHER_INTERVAL_MS;
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
Object.defineProperty(exports, "URL_WATCHER_TIMEOUT_MS", {
|
|
297
|
-
enumerable: true,
|
|
298
|
-
get: function() {
|
|
299
|
-
return URL_WATCHER_TIMEOUT_MS;
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
Object.defineProperty(exports, "WATCHER_IGNORED_PATHS", {
|
|
303
|
-
enumerable: true,
|
|
304
|
-
get: function() {
|
|
305
|
-
return WATCHER_IGNORED_PATHS;
|
|
306
|
-
}
|
|
307
|
-
});
|
|
308
|
-
Object.defineProperty(exports, "buildTelemetryEvent", {
|
|
309
|
-
enumerable: true,
|
|
310
|
-
get: function() {
|
|
311
|
-
return buildTelemetryEvent;
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
246
|
Object.defineProperty(exports, "isDisabled", {
|
|
315
247
|
enumerable: true,
|
|
316
248
|
get: function() {
|
|
@@ -323,11 +255,17 @@ Object.defineProperty(exports, "runtime", {
|
|
|
323
255
|
return runtime;
|
|
324
256
|
}
|
|
325
257
|
});
|
|
326
|
-
Object.defineProperty(exports, "
|
|
258
|
+
Object.defineProperty(exports, "trackRun", {
|
|
259
|
+
enumerable: true,
|
|
260
|
+
get: function() {
|
|
261
|
+
return trackRun;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
Object.defineProperty(exports, "version", {
|
|
327
265
|
enumerable: true,
|
|
328
266
|
get: function() {
|
|
329
|
-
return
|
|
267
|
+
return version;
|
|
330
268
|
}
|
|
331
269
|
});
|
|
332
270
|
|
|
333
|
-
//# sourceMappingURL=Telemetry-
|
|
271
|
+
//# sourceMappingURL=Telemetry-bGdFBaGt.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Telemetry-bGdFBaGt.cjs","names":["process","getElapsedMs","os","isCIEnvironment","getAgentName","randomBytes"],"sources":["../../../internals/utils/src/runtime.ts","../package.json","../src/Telemetry.ts"],"sourcesContent":["/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { getElapsedMs, isCIEnvironment, runtime } from '@internals/utils'\nimport { getAgentName } from './agent.ts'\nimport { version } from '../package.json'\n\n/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */\nconst OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\ntype TelemetryCommand = 'generate' | 'mcp' | 'studio' | 'validate'\n\ntype OtlpValue =\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { arrayValue: { values: Array<OtlpValue> } }\n | { kvlistValue: { values: Array<OtlpKeyValue> } }\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpValue\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n name: string\n kind: 1\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes: Array<OtlpKeyValue>\n status: { code: 1 | 2 }\n}\n\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<{\n resource: { attributes: Array<OtlpKeyValue> }\n scopeSpans: Array<{\n scope: { name: string; version: string }\n spans: Array<OtlpSpan>\n }>\n }>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\n/**\n * Anonymous snapshot of a single Kubb run, built by {@link buildTelemetryEvent} and sent by {@link sendTelemetry}.\n */\ntype TelemetryEvent = {\n command: string\n kubbVersion: string\n /**\n * Major version of Node that executed the run, e.g. `'22'`.\n */\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n /**\n * Name of the detected AI coding agent (e.g. `'claude'`, `'cursor'`), when the CLI is invoked\n * by one. `undefined` when run by a human or an unrecognized caller.\n */\n agent?: string\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function isDisabled(): boolean {\n return ['DO_NOT_TRACK', 'KUBB_DISABLE_TELEMETRY'].some((name) => ['1', 'true'].includes(process.env[name] ?? ''))\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n */\nexport function buildTelemetryEvent(options: {\n command: TelemetryCommand\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n}): TelemetryEvent {\n const duration = Math.round(getElapsedMs(options.hrStart))\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n agent: getAgentName(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n\ntype TrackRunOptions = {\n command: TelemetryCommand\n /** `process.hrtime()` snapshot taken when the command started. */\n hrStart: [number, number]\n}\n\ntype RunResult = Pick<TelemetryEvent, 'status'> & Partial<Pick<TelemetryEvent, 'plugins' | 'filesCreated'>>\n\n/** Tracks one command run for the running CLI version; returns the reporter the command calls once it knows how it ended. */\nexport function trackRun({ command, hrStart }: TrackRunOptions): (result: RunResult) => Promise<void> {\n return (result) => sendTelemetry(buildTelemetryEvent({ command, kubbVersion: version, hrStart, ...result }))\n}\n\n/**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n *\n * @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\nexport function buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n const pluginNames = [...new Set(event.plugins.map((plugin) => plugin.name))].sort()\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n ...(event.agent ? [{ key: 'kubb.agent', value: { stringValue: event.agent } }] : []),\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: { arrayValue: { values: pluginNames.map((name) => ({ stringValue: name })) } },\n },\n ...pluginNames.map((name) => ({ key: `kubb.plugin.${name}`, value: { boolValue: true } })),\n {\n key: 'kubb.plugin_options',\n value: {\n arrayValue: {\n values: event.plugins.map((p) => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n })),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: event.status === 'success' ? 1 : 2,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file\n * paths, OpenAPI specs, or secrets are sent.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isDisabled()) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-cli',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n}\n"],"mappings":";;;;;;;;;;;;AAUA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;CACxB;;;;CAKA,IAAI,SAAkB;EACpB,OAAO,OAAQ,WAAkC,SA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.js";
|
|
2
|
+
import process$1 from "node:process";
|
|
3
|
+
import { getAgentProfile } from "gunshi/agent";
|
|
4
|
+
//#region ../../internals/utils/src/isCIEnvironment.ts
|
|
5
|
+
/**
|
|
6
|
+
* Returns `true` when a known CI provider has set its environment variable.
|
|
7
|
+
* `CI=false` and `CI=0` count as not CI, so a user can opt out locally.
|
|
8
|
+
*/
|
|
9
|
+
function isCIEnvironment() {
|
|
10
|
+
const ci = process$1.env.CI;
|
|
11
|
+
return !!(ci && ci !== "false" && ci !== "0" || process$1.env.GITHUB_ACTIONS || process$1.env.GITLAB_CI || process$1.env.BITBUCKET_BUILD_NUMBER || process$1.env.JENKINS_URL || process$1.env.CIRCLECI || process$1.env.TRAVIS || process$1.env.TEAMCITY_VERSION || process$1.env.BUILDKITE || process$1.env.TF_BUILD);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../../internals/utils/src/time.ts
|
|
15
|
+
/**
|
|
16
|
+
* Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
|
|
17
|
+
* Rounds to 2 decimal places for sub-millisecond precision without noise.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const start = process.hrtime()
|
|
22
|
+
* doWork()
|
|
23
|
+
* getElapsedMs(start) // 42.35
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function getElapsedMs(hrStart) {
|
|
27
|
+
const [seconds, nanoseconds] = process.hrtime(hrStart);
|
|
28
|
+
const ms = seconds * 1e3 + nanoseconds / 1e6;
|
|
29
|
+
return Math.round(ms * 100) / 100;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Converts a millisecond duration into a human-readable string (`ms`, `s`, or `m s`).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* formatMs(250) // '250ms'
|
|
37
|
+
* formatMs(1500) // '1.50s'
|
|
38
|
+
* formatMs(90000) // '1m 30.0s'
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function formatMs(ms) {
|
|
42
|
+
if (ms >= 6e4) return `${Math.floor(ms / 6e4)}m ${(ms % 6e4 / 1e3).toFixed(1)}s`;
|
|
43
|
+
if (ms >= 1e3) return `${(ms / 1e3).toFixed(2)}s`;
|
|
44
|
+
return `${Math.round(ms)}ms`;
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/agent.ts
|
|
48
|
+
/**
|
|
49
|
+
* Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,
|
|
50
|
+
* `'cursor'`). `undefined` when run by a human or an unrecognized caller.
|
|
51
|
+
*/
|
|
52
|
+
function getAgentName() {
|
|
53
|
+
const profile = getAgentProfile();
|
|
54
|
+
return profile.isAgent ? profile.name : void 0;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
export { isCIEnvironment as i, formatMs as n, getElapsedMs as r, getAgentName as t };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=agent-BPIqnEl2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-BPIqnEl2.js","names":["process"],"sources":["../../../internals/utils/src/isCIEnvironment.ts","../../../internals/utils/src/time.ts","../src/agent.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\n * `CI=false` and `CI=0` count as not CI, so a user can opt out locally.\n */\nexport function isCIEnvironment(): boolean {\n const ci = process.env.CI\n return !!(\n (ci && ci !== 'false' && ci !== '0') ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n","/**\n * Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.\n * Rounds to 2 decimal places for sub-millisecond precision without noise.\n *\n * @example\n * ```ts\n * const start = process.hrtime()\n * doWork()\n * getElapsedMs(start) // 42.35\n * ```\n */\nexport function getElapsedMs(hrStart: [number, number]): number {\n const [seconds, nanoseconds] = process.hrtime(hrStart)\n const ms = seconds * 1000 + nanoseconds / 1e6\n return Math.round(ms * 100) / 100\n}\n\n/**\n * Converts a millisecond duration into a human-readable string (`ms`, `s`, or `m s`).\n *\n * @example\n * ```ts\n * formatMs(250) // '250ms'\n * formatMs(1500) // '1.50s'\n * formatMs(90000) // '1m 30.0s'\n * ```\n */\nexport function formatMs(ms: number): string {\n if (ms >= 60000) {\n const mins = Math.floor(ms / 60000)\n const secs = ((ms % 60000) / 1000).toFixed(1)\n return `${mins}m ${secs}s`\n }\n\n if (ms >= 1000) {\n return `${(ms / 1000).toFixed(2)}s`\n }\n return `${Math.round(ms)}ms`\n}\n","import { getAgentProfile } from 'gunshi/agent'\n\n/**\n * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,\n * `'cursor'`). `undefined` when run by a human or an unrecognized caller.\n */\nexport function getAgentName(): string | undefined {\n const profile = getAgentProfile()\n return profile.isAgent ? profile.name : undefined\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,kBAA2B;CACzC,MAAM,KAAKA,UAAQ,IAAI;CACvB,OAAO,CAAC,EACL,MAAM,OAAO,WAAW,OAAO,OAChCA,UAAQ,IAAI,kBACZA,UAAQ,IAAI,aACZA,UAAQ,IAAI,0BACZA,UAAQ,IAAI,eACZA,UAAQ,IAAI,YACZA,UAAQ,IAAI,UACZA,UAAQ,IAAI,oBACZA,UAAQ,IAAI,aACZA,UAAQ,IAAI;AAEhB;;;;;;;;;;;;;;ACTA,SAAgB,aAAa,SAAmC;CAC9D,MAAM,CAAC,SAAS,eAAe,QAAQ,OAAO,OAAO;CACrD,MAAM,KAAK,UAAU,MAAO,cAAc;CAC1C,OAAO,KAAK,MAAM,KAAK,GAAG,IAAI;AAChC;;;;;;;;;;;AAYA,SAAgB,SAAS,IAAoB;CAC3C,IAAI,MAAM,KAGR,OAAO,GAFM,KAAK,MAAM,KAAK,GAEhB,EAAE,KADA,KAAK,MAAS,IAAA,CAAM,QAAQ,CACrB,EAAE;CAG1B,IAAI,MAAM,KACR,OAAO,IAAI,KAAK,IAAA,CAAM,QAAQ,CAAC,EAAE;CAEnC,OAAO,GAAG,KAAK,MAAM,EAAE,EAAE;AAC3B;;;;;;;AChCA,SAAgB,eAAmC;CACjD,MAAM,UAAU,gBAAgB;CAChC,OAAO,QAAQ,UAAU,QAAQ,OAAO,KAAA;AAC1C"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", {
|
|
5
|
+
value,
|
|
6
|
+
configurable: true
|
|
7
|
+
});
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: ((k) => from[k]).bind(null, key),
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
//#endregion
|
|
27
|
+
let node_process = require("node:process");
|
|
28
|
+
node_process = __toESM(node_process, 1);
|
|
29
|
+
let gunshi_agent = require("gunshi/agent");
|
|
30
|
+
//#region ../../internals/utils/src/isCIEnvironment.ts
|
|
31
|
+
/**
|
|
32
|
+
* Returns `true` when a known CI provider has set its environment variable.
|
|
33
|
+
* `CI=false` and `CI=0` count as not CI, so a user can opt out locally.
|
|
34
|
+
*/
|
|
35
|
+
function isCIEnvironment() {
|
|
36
|
+
const ci = node_process.default.env.CI;
|
|
37
|
+
return !!(ci && ci !== "false" && ci !== "0" || node_process.default.env.GITHUB_ACTIONS || node_process.default.env.GITLAB_CI || node_process.default.env.BITBUCKET_BUILD_NUMBER || node_process.default.env.JENKINS_URL || node_process.default.env.CIRCLECI || node_process.default.env.TRAVIS || node_process.default.env.TEAMCITY_VERSION || node_process.default.env.BUILDKITE || node_process.default.env.TF_BUILD);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region ../../internals/utils/src/time.ts
|
|
41
|
+
/**
|
|
42
|
+
* Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
|
|
43
|
+
* Rounds to 2 decimal places for sub-millisecond precision without noise.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const start = process.hrtime()
|
|
48
|
+
* doWork()
|
|
49
|
+
* getElapsedMs(start) // 42.35
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
function getElapsedMs(hrStart) {
|
|
53
|
+
const [seconds, nanoseconds] = process.hrtime(hrStart);
|
|
54
|
+
const ms = seconds * 1e3 + nanoseconds / 1e6;
|
|
55
|
+
return Math.round(ms * 100) / 100;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Converts a millisecond duration into a human-readable string (`ms`, `s`, or `m s`).
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* formatMs(250) // '250ms'
|
|
63
|
+
* formatMs(1500) // '1.50s'
|
|
64
|
+
* formatMs(90000) // '1m 30.0s'
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function formatMs(ms) {
|
|
68
|
+
if (ms >= 6e4) return `${Math.floor(ms / 6e4)}m ${(ms % 6e4 / 1e3).toFixed(1)}s`;
|
|
69
|
+
if (ms >= 1e3) return `${(ms / 1e3).toFixed(2)}s`;
|
|
70
|
+
return `${Math.round(ms)}ms`;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/agent.ts
|
|
74
|
+
/**
|
|
75
|
+
* Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,
|
|
76
|
+
* `'cursor'`). `undefined` when run by a human or an unrecognized caller.
|
|
77
|
+
*/
|
|
78
|
+
function getAgentName() {
|
|
79
|
+
const profile = (0, gunshi_agent.getAgentProfile)();
|
|
80
|
+
return profile.isAgent ? profile.name : void 0;
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
Object.defineProperty(exports, "__name", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function() {
|
|
86
|
+
return __name;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "__toESM", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function() {
|
|
92
|
+
return __toESM;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(exports, "formatMs", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
get: function() {
|
|
98
|
+
return formatMs;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "getAgentName", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function() {
|
|
104
|
+
return getAgentName;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(exports, "getElapsedMs", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
get: function() {
|
|
110
|
+
return getElapsedMs;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "isCIEnvironment", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function() {
|
|
116
|
+
return isCIEnvironment;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=agent-DElUuYuy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-DElUuYuy.cjs","names":["process","getAgentProfile"],"sources":["../../../internals/utils/src/isCIEnvironment.ts","../../../internals/utils/src/time.ts","../src/agent.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\n * `CI=false` and `CI=0` count as not CI, so a user can opt out locally.\n */\nexport function isCIEnvironment(): boolean {\n const ci = process.env.CI\n return !!(\n (ci && ci !== 'false' && ci !== '0') ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n","/**\n * Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.\n * Rounds to 2 decimal places for sub-millisecond precision without noise.\n *\n * @example\n * ```ts\n * const start = process.hrtime()\n * doWork()\n * getElapsedMs(start) // 42.35\n * ```\n */\nexport function getElapsedMs(hrStart: [number, number]): number {\n const [seconds, nanoseconds] = process.hrtime(hrStart)\n const ms = seconds * 1000 + nanoseconds / 1e6\n return Math.round(ms * 100) / 100\n}\n\n/**\n * Converts a millisecond duration into a human-readable string (`ms`, `s`, or `m s`).\n *\n * @example\n * ```ts\n * formatMs(250) // '250ms'\n * formatMs(1500) // '1.50s'\n * formatMs(90000) // '1m 30.0s'\n * ```\n */\nexport function formatMs(ms: number): string {\n if (ms >= 60000) {\n const mins = Math.floor(ms / 60000)\n const secs = ((ms % 60000) / 1000).toFixed(1)\n return `${mins}m ${secs}s`\n }\n\n if (ms >= 1000) {\n return `${(ms / 1000).toFixed(2)}s`\n }\n return `${Math.round(ms)}ms`\n}\n","import { getAgentProfile } from 'gunshi/agent'\n\n/**\n * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,\n * `'cursor'`). `undefined` when run by a human or an unrecognized caller.\n */\nexport function getAgentName(): string | undefined {\n const profile = getAgentProfile()\n return profile.isAgent ? profile.name : undefined\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAgB,kBAA2B;CACzC,MAAM,KAAKA,aAAAA,QAAQ,IAAI;CACvB,OAAO,CAAC,EACL,MAAM,OAAO,WAAW,OAAO,OAChCA,aAAAA,QAAQ,IAAI,kBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI,0BACZA,aAAAA,QAAQ,IAAI,eACZA,aAAAA,QAAQ,IAAI,YACZA,aAAAA,QAAQ,IAAI,UACZA,aAAAA,QAAQ,IAAI,oBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI;AAEhB;;;;;;;;;;;;;;ACTA,SAAgB,aAAa,SAAmC;CAC9D,MAAM,CAAC,SAAS,eAAe,QAAQ,OAAO,OAAO;CACrD,MAAM,KAAK,UAAU,MAAO,cAAc;CAC1C,OAAO,KAAK,MAAM,KAAK,GAAG,IAAI;AAChC;;;;;;;;;;;AAYA,SAAgB,SAAS,IAAoB;CAC3C,IAAI,MAAM,KAGR,OAAO,GAFM,KAAK,MAAM,KAAK,GAEhB,EAAE,KADA,KAAK,MAAS,IAAA,CAAM,QAAQ,CACrB,EAAE;CAG1B,IAAI,MAAM,KACR,OAAO,IAAI,KAAK,IAAA,CAAM,QAAQ,CAAC,EAAE;CAEnC,OAAO,GAAG,KAAK,MAAM,EAAE,EAAE;AAC3B;;;;;;;AChCA,SAAgB,eAAmC;CACjD,MAAM,WAAA,GAAUC,aAAAA,gBAAAA,CAAgB;CAChC,OAAO,QAAQ,UAAU,QAAQ,OAAO,KAAA;AAC1C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import {
|
|
2
|
+
import { l as getProjectKubbHome, o as prepareConnection } from "./run-Dgph0WYk.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { hash, randomBytes } from "node:crypto";
|
|
5
|
-
import {
|
|
5
|
+
import { x } from "tinyexec";
|
|
6
6
|
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { connect, createServer } from "node:net";
|
|
@@ -197,7 +197,7 @@ async function startWorker(options) {
|
|
|
197
197
|
}
|
|
198
198
|
const prepared = await prepareConnection(options);
|
|
199
199
|
const entry = path.join(path.dirname(createRequire(import.meta.url).resolve("@kubb/cli/package.json")), "dist", "studioWorker.js");
|
|
200
|
-
const child =
|
|
200
|
+
const child = x(process.execPath, [...process.execArgv, entry], { nodeOptions: {
|
|
201
201
|
cwd: process.cwd(),
|
|
202
202
|
detached: true,
|
|
203
203
|
stdio: [
|
|
@@ -206,7 +206,8 @@ async function startWorker(options) {
|
|
|
206
206
|
"ignore",
|
|
207
207
|
"ipc"
|
|
208
208
|
]
|
|
209
|
-
});
|
|
209
|
+
} }).process;
|
|
210
|
+
if (!child) throw new Error("Background worker failed to start");
|
|
210
211
|
try {
|
|
211
212
|
await new Promise((resolve, reject) => {
|
|
212
213
|
const timer = setTimeout(() => done(/* @__PURE__ */ new Error("Background worker startup timed out")), 2e4);
|
|
@@ -249,4 +250,4 @@ async function startWorker(options) {
|
|
|
249
250
|
//#endregion
|
|
250
251
|
export { stopWorker as a, startWorker as i, getWorkerStatus as n, serveWorker as r, getWorkerLogPath as t };
|
|
251
252
|
|
|
252
|
-
//# sourceMappingURL=background-
|
|
253
|
+
//# sourceMappingURL=background-0PMj56FJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"background-0PMj56FJ.js","names":["connectSocket","delay"],"sources":["../src/runners/studio/background.ts"],"sourcesContent":["import { hash, randomBytes } from 'node:crypto'\nimport { mkdir, readFile, rename, writeFile } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { connect as connectSocket, createServer } from 'node:net'\nimport path from 'node:path'\nimport { setTimeout as delay } from 'node:timers/promises'\nimport { x } from 'tinyexec'\nimport { getProjectKubbHome } from './credentials.ts'\nimport { prepareConnection, type PreparedConnection, type StudioOptions, type WorkerState } from './run.ts'\n\nexport type WorkerRecord = { id: string; pid: number; port: number; state: WorkerState }\nconst states: Array<WorkerState> = ['starting', 'connected', 'reconnecting', 'authentication required', 'stopped']\nexport const getWorkerLogPath = () => path.join(getProjectKubbHome(), 'worker.log')\nconst statePath = () => path.join(getProjectKubbHome(), 'worker.json')\n\nasync function readWorker(): Promise<WorkerRecord | null> {\n try {\n const value: unknown = JSON.parse(await readFile(statePath(), 'utf8'))\n if (!value || typeof value !== 'object') return null\n const record = value as Partial<WorkerRecord>\n return typeof record.id === 'string' &&\n /^[a-f0-9]{32}$/.test(record.id) &&\n Number.isInteger(record.pid) &&\n (record.pid ?? 0) > 1 &&\n Number.isInteger(record.port) &&\n (record.port ?? 0) > 0 &&\n (record.port ?? 0) <= 65535 &&\n states.includes(record.state as WorkerState)\n ? (record as WorkerRecord)\n : null\n } catch {\n return null\n }\n}\n\nfunction isAlive(pid: number): boolean {\n try {\n process.kill(pid, 0)\n return true\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === 'EPERM'\n }\n}\n\n/** Authenticated loopback IPC; a stored PID never authorizes sending a process signal. */\nfunction requestWorker(record: WorkerRecord, command: 'status' | 'stop'): Promise<WorkerRecord> {\n return new Promise((resolve, reject) => {\n const socket = connectSocket({ host: '127.0.0.1', port: record.port })\n let received = ''\n socket.setTimeout(2_000, () => socket.destroy(new Error('Worker control timed out')))\n socket.once('error', reject)\n socket.once('connect', () => socket.write(JSON.stringify({ id: record.id, command }) + '\\n'))\n socket.on('data', (chunk: Buffer) => {\n received += chunk.toString()\n if (received.length > 4096) socket.destroy(new Error('Invalid worker response'))\n })\n socket.once('end', () => {\n try {\n const response = JSON.parse(received) as WorkerRecord\n if (response.id !== record.id || response.pid !== record.pid || !states.includes(response.state)) throw new Error('Worker identity changed')\n resolve(response)\n } catch (error) {\n reject(error)\n }\n })\n })\n}\n\nexport async function getWorkerStatus(): Promise<{ running: boolean; state: WorkerState; pid?: number }> {\n const record = await readWorker()\n if (!record) return { running: false, state: 'stopped' }\n try {\n const response = await requestWorker(record, 'status')\n return { running: true, state: response.state, pid: response.pid }\n } catch {\n return { running: false, state: record.state === 'authentication required' ? record.state : 'stopped' }\n }\n}\n\nexport async function stopWorker(): Promise<void> {\n const record = await readWorker()\n if (!record) return\n try {\n await requestWorker(record, 'stop')\n } catch (error) {\n if (\n (error as NodeJS.ErrnoException).code !== 'ECONNREFUSED' &&\n isAlive(record.pid) &&\n record.state !== 'stopped' &&\n record.state !== 'authentication required'\n ) {\n throw new Error('Cannot verify the background worker. No process was signaled.')\n }\n return\n }\n const deadline = Date.now() + 15_000\n while (Date.now() < deadline) {\n try {\n await requestWorker(record, 'status')\n } catch {\n return\n }\n await delay(100)\n }\n throw new Error('The worker has not finished shutting down. Check worker.log and try again.')\n}\n\n/** The listening port is the project lock, so stale state never needs a PID-based takeover. */\nexport async function serveWorker(shutdown: AbortController) {\n const record: WorkerRecord = { id: randomBytes(16).toString('hex'), pid: process.pid, port: 0, state: 'starting' }\n const server = createServer((socket) => {\n let input = ''\n socket.setTimeout(2_000, () => socket.destroy())\n socket.on('error', () => {})\n socket.on('data', (chunk: Buffer) => {\n input += chunk.toString()\n if (input.length > 4096) {\n socket.destroy()\n return\n }\n if (!input.includes('\\n')) return\n try {\n const request = JSON.parse(input) as { id?: unknown; command?: unknown }\n if (request.id !== record.id || !['status', 'stop'].includes(String(request.command))) {\n socket.destroy()\n return\n }\n socket.end(JSON.stringify(record))\n if (request.command === 'stop') shutdown.abort()\n } catch {\n socket.destroy()\n }\n })\n })\n // Hash the project directory to choose its loopback port; fail on collisions.\n const port = 20_000 + (Number.parseInt(hash('sha256', getProjectKubbHome()).slice(0, 8), 16) % 30_000)\n try {\n await new Promise<void>((resolve, reject) => {\n server.once('error', reject)\n server.listen(port, '127.0.0.1', resolve)\n })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EADDRINUSE') throw error\n // Let a simultaneous starter finish writing its record before checking ownership.\n await delay(100)\n const existing = await readWorker()\n if (existing?.port === port) {\n try {\n return { existing: await requestWorker(existing, 'status') }\n } catch {\n /* Refuse an unverified listener. */\n }\n }\n throw new Error('The project control port is occupied or another worker is starting. Try again after stopping that listener.')\n }\n record.port = port\n let saving = Promise.resolve()\n const save = () => {\n const value = JSON.stringify(record)\n saving = saving.then(async () => {\n const temporary = `${statePath()}.${record.id}`\n await writeFile(temporary, value, { mode: 0o600 })\n await rename(temporary, statePath())\n })\n return saving\n }\n try {\n await mkdir(getProjectKubbHome(), { recursive: true, mode: 0o700 })\n await save()\n } catch (error) {\n server.close()\n throw error\n }\n return {\n async state(state: WorkerState) {\n record.state = state\n await save()\n },\n async close() {\n try {\n if (record.state !== 'authentication required') {\n record.state = 'stopped'\n await save()\n }\n } finally {\n await new Promise<void>((resolve, reject) => server.close((error) => (error ? reject(error) : resolve())))\n }\n },\n }\n}\n\nexport type WorkerLaunch = { options: StudioOptions; prepared: PreparedConnection }\n\nexport async function startWorker(options: StudioOptions): Promise<void> {\n const current = await getWorkerStatus()\n if (current.running) {\n console.log(`Already running (${current.state}, PID ${current.pid}).`)\n return\n }\n const prepared = await prepareConnection(options)\n const entry = path.join(path.dirname(createRequire(import.meta.url).resolve('@kubb/cli/package.json')), 'dist', 'studioWorker.js')\n const child = x(process.execPath, [...process.execArgv, entry], {\n nodeOptions: { cwd: process.cwd(), detached: true, stdio: ['ignore', 'ignore', 'ignore', 'ipc'] },\n }).process\n if (!child) throw new Error('Background worker failed to start')\n try {\n const started = new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => done(new Error('Background worker startup timed out')), 20_000)\n const done = (error?: Error) => {\n clearTimeout(timer)\n child.removeListener('error', failed)\n child.removeListener('exit', exited)\n child.removeListener('message', ready)\n if (error) reject(error)\n else resolve()\n }\n const failed = (error: Error) => done(error)\n const exited = () => done(new Error(`Background worker exited during startup. Check ${getWorkerLogPath()}`))\n child.once('error', failed)\n child.once('exit', exited)\n const ready = (message: unknown) => {\n if (!message || typeof message !== 'object' || !('started' in message) || message.started !== true)\n return done(new Error('Invalid worker startup response'))\n done()\n }\n child.once('message', ready)\n child.send({ options: { ...options, autoOpen: false }, prepared } satisfies WorkerLaunch, (error) => {\n if (error) done(error)\n })\n })\n await started\n if (child.connected) child.disconnect()\n child.unref()\n const status = await getWorkerStatus()\n console.log(`Background worker ${status.state} (PID ${status.pid ?? child.pid}). Logs: ${getWorkerLogPath()}`)\n } catch (error) {\n // This is the child we just spawned, not a PID recovered from disk.\n child.kill('SIGTERM')\n throw error\n }\n}\n"],"mappings":";;;;;;;;;;AAWA,MAAM,SAA6B;CAAC;CAAY;CAAa;CAAgB;CAA2B;AAAS;AACjH,MAAa,yBAAyB,KAAK,KAAK,mBAAmB,GAAG,YAAY;AAClF,MAAM,kBAAkB,KAAK,KAAK,mBAAmB,GAAG,aAAa;AAErE,eAAe,aAA2C;CACxD,IAAI;EACF,MAAM,QAAiB,KAAK,MAAM,MAAM,SAAS,UAAU,GAAG,MAAM,CAAC;EACrE,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;EAChD,MAAM,SAAS;EACf,OAAO,OAAO,OAAO,OAAO,YAC1B,iBAAiB,KAAK,OAAO,EAAE,KAC/B,OAAO,UAAU,OAAO,GAAG,MAC1B,OAAO,OAAO,KAAK,KACpB,OAAO,UAAU,OAAO,IAAI,MAC3B,OAAO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qB;IAClC,IAAI,CAAC,WAAW,OAAO,YAAY,YAAY,EAAE,aAAa,YAAY,QAAQ,YAAY,MAC5F,OAAO,qBAAK,IAAI,MAAM,iCAAiC,CAAC;IAC1D,KAAK;GACP;GACA,MAAM,KAAK,WAAW,KAAK;GAC3B,MAAM,KAAK;IAAE,SAAS;KAAE,GAAG;KAAS,UAAU;IAAM;IAAG;GAAS,IAA2B,UAAU;IACnG,IAAI,OAAO,KAAK,KAAK;GACvB,CAAC;EACH,CACY;EACZ,IAAI,MAAM,WAAW,MAAM,WAAW;EACtC,MAAM,MAAM;EACZ,MAAM,SAAS,MAAM,gBAAgB;EACrC,QAAQ,IAAI,qBAAqB,OAAO,MAAM,QAAQ,OAAO,OAAO,MAAM,IAAI,WAAW,iBAAiB,GAAG;CAC/G,SAAS,OAAO;EAEd,MAAM,KAAK,SAAS;EACpB,MAAM;CACR;AACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_run = require("./run-
|
|
1
|
+
const require_agent = require("./agent-DElUuYuy.cjs");
|
|
2
|
+
const require_run = require("./run-D8Wz_17X.cjs");
|
|
3
3
|
require("node:crypto");
|
|
4
|
-
let
|
|
4
|
+
let tinyexec = require("tinyexec");
|
|
5
5
|
let node_fs_promises = require("node:fs/promises");
|
|
6
6
|
let node_path = require("node:path");
|
|
7
|
-
node_path =
|
|
7
|
+
node_path = require_agent.__toESM(node_path, 1);
|
|
8
8
|
let node_module = require("node:module");
|
|
9
9
|
let node_net = require("node:net");
|
|
10
10
|
let node_timers_promises = require("node:timers/promises");
|
|
@@ -113,7 +113,7 @@ async function startWorker(options) {
|
|
|
113
113
|
}
|
|
114
114
|
const prepared = await require_run.prepareConnection(options);
|
|
115
115
|
const entry = node_path.default.join(node_path.default.dirname((0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve("@kubb/cli/package.json")), "dist", "studioWorker.js");
|
|
116
|
-
const child = (0,
|
|
116
|
+
const child = (0, tinyexec.x)(process.execPath, [...process.execArgv, entry], { nodeOptions: {
|
|
117
117
|
cwd: process.cwd(),
|
|
118
118
|
detached: true,
|
|
119
119
|
stdio: [
|
|
@@ -122,7 +122,8 @@ async function startWorker(options) {
|
|
|
122
122
|
"ignore",
|
|
123
123
|
"ipc"
|
|
124
124
|
]
|
|
125
|
-
});
|
|
125
|
+
} }).process;
|
|
126
|
+
if (!child) throw new Error("Background worker failed to start");
|
|
126
127
|
try {
|
|
127
128
|
await new Promise((resolve, reject) => {
|
|
128
129
|
const timer = setTimeout(() => done(/* @__PURE__ */ new Error("Background worker startup timed out")), 2e4);
|
|
@@ -168,4 +169,4 @@ exports.getWorkerStatus = getWorkerStatus;
|
|
|
168
169
|
exports.startWorker = startWorker;
|
|
169
170
|
exports.stopWorker = stopWorker;
|
|
170
171
|
|
|
171
|
-
//# sourceMappingURL=background-
|
|
172
|
+
//# sourceMappingURL=background-R0T_7Szu.cjs.map
|