xmcp 0.7.0 → 0.7.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.
Files changed (155) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/index.js +1 -1
  3. package/package.json +2 -3
  4. package/src/auth/api-key.ts +0 -120
  5. package/src/auth/jwt.ts +0 -52
  6. package/src/cli/commands/create/__tests__/create.test.ts +0 -99
  7. package/src/cli/commands/create/index.ts +0 -74
  8. package/src/cli/commands/create/templates/index.ts +0 -4
  9. package/src/cli/commands/create/templates/prompt.ts +0 -30
  10. package/src/cli/commands/create/templates/resource.ts +0 -20
  11. package/src/cli/commands/create/templates/tool.ts +0 -34
  12. package/src/cli/commands/create/templates/widget.ts +0 -33
  13. package/src/cli/utils/naming.ts +0 -39
  14. package/src/cli.ts +0 -125
  15. package/src/client/headers.ts +0 -61
  16. package/src/client/index.ts +0 -180
  17. package/src/client/types.ts +0 -122
  18. package/src/client/utils.ts +0 -133
  19. package/src/cloudflare.ts +0 -6
  20. package/src/compiler/build-telemetry.ts +0 -88
  21. package/src/compiler/client/component-compiler.ts +0 -250
  22. package/src/compiler/client/transpile.ts +0 -21
  23. package/src/compiler/compiler-context.ts +0 -61
  24. package/src/compiler/config/__tests__/config.test.ts +0 -459
  25. package/src/compiler/config/index.ts +0 -62
  26. package/src/compiler/config/injection.ts +0 -210
  27. package/src/compiler/config/schemas/bundler.ts +0 -12
  28. package/src/compiler/config/schemas/experimental/index.ts +0 -22
  29. package/src/compiler/config/schemas/index.ts +0 -20
  30. package/src/compiler/config/schemas/paths.ts +0 -35
  31. package/src/compiler/config/schemas/template.ts +0 -80
  32. package/src/compiler/config/schemas/transport/http.ts +0 -116
  33. package/src/compiler/config/schemas/transport/stdio.ts +0 -31
  34. package/src/compiler/config/schemas/typescript.ts +0 -26
  35. package/src/compiler/config/utils.ts +0 -168
  36. package/src/compiler/generate-env-code.ts +0 -5
  37. package/src/compiler/generate-import-code.ts +0 -187
  38. package/src/compiler/generate-tools-code.ts +0 -174
  39. package/src/compiler/get-bundler-config/get-entries.ts +0 -44
  40. package/src/compiler/get-bundler-config/get-externals.ts +0 -114
  41. package/src/compiler/get-bundler-config/get-injected-variables.ts +0 -46
  42. package/src/compiler/get-bundler-config/index.ts +0 -288
  43. package/src/compiler/get-bundler-config/plugins/index.ts +0 -140
  44. package/src/compiler/get-bundler-config/plugins/types/express.ts +0 -3
  45. package/src/compiler/get-bundler-config/plugins/types/fastify.ts +0 -4
  46. package/src/compiler/get-bundler-config/plugins/types/index.ts +0 -5
  47. package/src/compiler/get-bundler-config/plugins/types/nest.ts +0 -65
  48. package/src/compiler/get-bundler-config/plugins/types/next.ts +0 -52
  49. package/src/compiler/get-bundler-config/resolve-tsconfig-paths.ts +0 -51
  50. package/src/compiler/index.ts +0 -484
  51. package/src/compiler/on-first-build.ts +0 -54
  52. package/src/compiler/parse-xmcp-config.ts +0 -200
  53. package/src/compiler/start-http-server.ts +0 -42
  54. package/src/compiler/utils/__tests__/config-detection.test.ts +0 -307
  55. package/src/compiler/utils/__tests__/path-utils.test.ts +0 -137
  56. package/src/compiler/utils/config-detection.ts +0 -34
  57. package/src/compiler/utils/path-utils.ts +0 -22
  58. package/src/compiler/watcher-recovery.ts +0 -72
  59. package/src/host-bridge.ts +0 -36
  60. package/src/index.ts +0 -94
  61. package/src/platforms/build-cloudflare-output.ts +0 -116
  62. package/src/platforms/build-vercel-output.ts +0 -131
  63. package/src/plugins/index.ts +0 -1
  64. package/src/plugins/x402/index.ts +0 -24
  65. package/src/runtime/adapters/express/index.ts +0 -75
  66. package/src/runtime/adapters/fastify/__tests__/fastify.test.ts +0 -115
  67. package/src/runtime/adapters/fastify/index.ts +0 -78
  68. package/src/runtime/adapters/nestjs/index.ts +0 -16
  69. package/src/runtime/adapters/nestjs/xmcp.controller.ts +0 -34
  70. package/src/runtime/adapters/nestjs/xmcp.guard.ts +0 -101
  71. package/src/runtime/adapters/nestjs/xmcp.oauth.controller.ts +0 -36
  72. package/src/runtime/adapters/nestjs/xmcp.oauth.module.ts +0 -21
  73. package/src/runtime/adapters/nestjs/xmcp.oauth.service.ts +0 -36
  74. package/src/runtime/adapters/nestjs/xmcp.service.ts +0 -96
  75. package/src/runtime/adapters/nestjs/xmcp.utils.ts +0 -11
  76. package/src/runtime/adapters/nextjs/auth.ts +0 -265
  77. package/src/runtime/adapters/nextjs/handler/error-handler.ts +0 -67
  78. package/src/runtime/adapters/nextjs/handler/node-to-web-adapter.ts +0 -143
  79. package/src/runtime/adapters/nextjs/handler/request-converter.ts +0 -74
  80. package/src/runtime/adapters/nextjs/handler/server-lifecycle.ts +0 -69
  81. package/src/runtime/adapters/nextjs/index.ts +0 -121
  82. package/src/runtime/contexts/client-info-context.ts +0 -16
  83. package/src/runtime/contexts/http-request-context.ts +0 -21
  84. package/src/runtime/contexts/http-transport-context.ts +0 -18
  85. package/src/runtime/headers.ts +0 -42
  86. package/src/runtime/middlewares/utils.ts +0 -72
  87. package/src/runtime/platforms/cloudflare/cors.ts +0 -44
  88. package/src/runtime/platforms/cloudflare/middlewares/api-key.ts +0 -102
  89. package/src/runtime/platforms/cloudflare/middlewares/jwt.ts +0 -127
  90. package/src/runtime/platforms/cloudflare/types.ts +0 -23
  91. package/src/runtime/platforms/cloudflare/worker.ts +0 -270
  92. package/src/runtime/templates/home.ts +0 -746
  93. package/src/runtime/transports/http/base-streamable-http.ts +0 -46
  94. package/src/runtime/transports/http/cors/headers.ts +0 -58
  95. package/src/runtime/transports/http/cors/index.ts +0 -34
  96. package/src/runtime/transports/http/index.ts +0 -78
  97. package/src/runtime/transports/http/stateless-streamable-http.ts +0 -353
  98. package/src/runtime/transports/http/web-stateless-http.ts +0 -288
  99. package/src/runtime/transports/stdio/index.ts +0 -109
  100. package/src/runtime/utils/__tests__/client-info.test.ts +0 -146
  101. package/src/runtime/utils/__tests__/tool-extra.test.ts +0 -239
  102. package/src/runtime/utils/client-info.ts +0 -114
  103. package/src/runtime/utils/elicitation.ts +0 -396
  104. package/src/runtime/utils/ext-apps-registry.ts +0 -151
  105. package/src/runtime/utils/mcp-app-protocol.ts +0 -16
  106. package/src/runtime/utils/mcp-app-types.ts +0 -113
  107. package/src/runtime/utils/mcp-host-bridge.ts +0 -473
  108. package/src/runtime/utils/path-to-tool-name.ts +0 -69
  109. package/src/runtime/utils/prompt-loader.ts +0 -151
  110. package/src/runtime/utils/prompts.ts +0 -69
  111. package/src/runtime/utils/react/generate-html.ts +0 -69
  112. package/src/runtime/utils/react/index.ts +0 -6
  113. package/src/runtime/utils/request-tool-names.ts +0 -48
  114. package/src/runtime/utils/resource-loader.ts +0 -151
  115. package/src/runtime/utils/resources.ts +0 -331
  116. package/src/runtime/utils/server.ts +0 -107
  117. package/src/runtime/utils/tool-loader.ts +0 -149
  118. package/src/runtime/utils/tools.ts +0 -183
  119. package/src/runtime/utils/transformers/prompt.ts +0 -120
  120. package/src/runtime/utils/transformers/resource.ts +0 -196
  121. package/src/runtime/utils/transformers/tool.ts +0 -400
  122. package/src/runtime/utils/ui/__tests__/split-meta.test.ts +0 -803
  123. package/src/runtime/utils/ui/flatten-meta.ts +0 -44
  124. package/src/runtime/utils/ui/split-meta.ts +0 -78
  125. package/src/runtime/utils/utils/resource-uri-composer.ts +0 -204
  126. package/src/runtime/utils/validators/index.ts +0 -138
  127. package/src/telemetry/ci-info.ts +0 -6
  128. package/src/telemetry/debug.ts +0 -8
  129. package/src/telemetry/events/definitions.ts +0 -52
  130. package/src/telemetry/events/detached-flush.ts +0 -83
  131. package/src/telemetry/events/post-payload.ts +0 -141
  132. package/src/telemetry/events/tracker.ts +0 -281
  133. package/src/telemetry/index.ts +0 -7
  134. package/src/telemetry/metadata.ts +0 -49
  135. package/src/telemetry/project-id.ts +0 -35
  136. package/src/telemetry/storage.ts +0 -218
  137. package/src/types/adapter.d.ts +0 -5
  138. package/src/types/client-info.ts +0 -20
  139. package/src/types/declarations.ts +0 -37
  140. package/src/types/injected.d.ts +0 -62
  141. package/src/types/middleware.ts +0 -19
  142. package/src/types/prompt.ts +0 -6
  143. package/src/types/resource.ts +0 -15
  144. package/src/types/tool.ts +0 -192
  145. package/src/types/ui-meta.ts +0 -42
  146. package/src/utils/cli-icons.ts +0 -5
  147. package/src/utils/constants.ts +0 -31
  148. package/src/utils/context.ts +0 -105
  149. package/src/utils/detect-package-manager.ts +0 -46
  150. package/src/utils/file-watcher.ts +0 -66
  151. package/src/utils/fs-utils.ts +0 -16
  152. package/src/utils/path-validation.ts +0 -66
  153. package/src/utils/port-utils.ts +0 -43
  154. package/src/utils/spawn-process.ts +0 -49
  155. package/src/utils/subscribable.ts +0 -62
@@ -1,141 +0,0 @@
1
- import retry from "async-retry";
2
- import type { TelemetryMeta } from "../metadata";
3
- import { isTelemetryDebugEnabled } from "../debug";
4
-
5
- /**
6
- * Build event data (only event type we track)
7
- */
8
- export interface BuildEventData {
9
- success: boolean;
10
- duration: number;
11
- toolsCount: number;
12
- reactToolsCount: number;
13
- promptsCount: number;
14
- resourcesCount: number;
15
- outputSize?: number;
16
- transport: string;
17
- adapter: string;
18
- nodeVersion?: string;
19
- xmcpVersion?: string;
20
- errorPhase?: string;
21
- errorType?: string;
22
- }
23
-
24
- /**
25
- * Telemetry payload structure
26
- */
27
- export interface TelemetryPayload {
28
- context: {
29
- anonymousId: string;
30
- projectHash: string;
31
- sessionId: string;
32
- };
33
-
34
- meta: TelemetryMeta;
35
-
36
- events: Array<{
37
- eventName: string;
38
- timestamp: string;
39
- fields: BuildEventData;
40
- }>;
41
- }
42
-
43
- /**
44
- * Post telemetry payload to the endpoint
45
- *
46
- * Features:
47
- * - Automatic retry with exponential backoff using async-retry
48
- * - Timeout handling (5s default)
49
- * - Error swallowing (never breaks the build)
50
- * - Voided promise (fire and forget)
51
- *
52
- * @param payload - The telemetry payload
53
- * @param signal - Optional AbortSignal for timeout control
54
- * @returns Voided promise
55
- */
56
- export interface PostTelemetryOptions {
57
- signal?: AbortSignal;
58
- /**
59
- * When true (default) errors are swallowed to avoid interrupting builds.
60
- * Set to false when the caller needs to know if the request failed.
61
- */
62
- swallowErrors?: boolean;
63
- }
64
-
65
- function debugLogTelemetryPayload(payload: TelemetryPayload) {
66
- if (!isTelemetryDebugEnabled()) {
67
- return;
68
- }
69
- try {
70
- console.log(
71
- "[telemetry] Sending payload",
72
- JSON.stringify(payload, null, 2)
73
- );
74
- } catch (_) {
75
- console.log("[telemetry] Sending payload (unable to stringify)");
76
- }
77
- }
78
-
79
- export async function postTelemetryPayload(
80
- payload: TelemetryPayload,
81
- options?: PostTelemetryOptions
82
- ): Promise<void> {
83
- let signal = options?.signal;
84
- const swallowErrors = options?.swallowErrors ?? true;
85
-
86
- if (!signal && "timeout" in AbortSignal) {
87
- signal = AbortSignal.timeout(5000);
88
- }
89
-
90
- try {
91
- debugLogTelemetryPayload(payload);
92
- await retry(
93
- async () => {
94
- const response = await fetch(
95
- "https://telemetry.xmcp.dev/api/telemetry/events",
96
- {
97
- method: "POST",
98
- body: JSON.stringify(payload),
99
- headers: { "content-type": "application/json" },
100
- signal,
101
- }
102
- );
103
-
104
- // Try to parse response body
105
- const responseText = await response.text();
106
- let responseData;
107
- try {
108
- responseData = JSON.parse(responseText);
109
- } catch (e) {
110
- // response might not be json
111
- // ignore
112
- }
113
-
114
- if (!response.ok) {
115
- const err = new Error(
116
- `HTTP ${response.status}: ${response.statusText}`
117
- );
118
- (err as any).response = response;
119
- (err as any).responseData = responseData;
120
- throw err;
121
- }
122
- },
123
- { minTimeout: 500, retries: 1, factor: 1 }
124
- );
125
- } catch (error) {
126
- if (!swallowErrors) {
127
- throw error;
128
- }
129
- }
130
- }
131
-
132
- /**
133
- * Helper to create payload from metadata and events
134
- */
135
- export function createPayload(
136
- context: TelemetryPayload["context"],
137
- meta: TelemetryMeta,
138
- events: TelemetryPayload["events"]
139
- ): TelemetryPayload {
140
- return { context, meta, events };
141
- }
@@ -1,281 +0,0 @@
1
- import { randomBytes } from "crypto";
2
- import { writeFileSync, mkdirSync } from "fs";
3
- import path from "path";
4
- import { TelemetryStorage } from "../storage";
5
- import { getAnonymousMeta } from "../metadata";
6
- import {
7
- postTelemetryPayload,
8
- createPayload,
9
- BuildEventData,
10
- } from "./post-payload";
11
- import { getProjectId } from "../project-id";
12
- import { isTelemetryDebugEnabled } from "../debug";
13
-
14
- export type TelemetryEvent = {
15
- eventName: string;
16
- fields: BuildEventData;
17
- timestamp?: string;
18
- };
19
-
20
- type RecordObject = {
21
- isFulfilled: boolean;
22
- isRejected: boolean;
23
- value?: any;
24
- reason?: any;
25
- };
26
-
27
- export class TelemetryTracker {
28
- private storage: TelemetryStorage;
29
- private sessionId: string;
30
- private queue: Set<Promise<RecordObject>>;
31
- private loadProjectId: undefined | string | Promise<string>;
32
- private distDir: string;
33
-
34
- constructor(distDir: string = ".xmcp") {
35
- this.storage = new TelemetryStorage();
36
- this.sessionId = randomBytes(32).toString("hex");
37
- this.queue = new Set();
38
- this.distDir = distDir;
39
-
40
- if (isTelemetryDebugEnabled()) {
41
- const enabled = this.storage.isEnabled;
42
- console.log(
43
- `[telemetry] Telemetry is ${enabled ? "enabled" : "disabled"}`
44
- );
45
- if (enabled) {
46
- console.log(`[telemetry] Anonymous ID ${this.storage.anonymousId}`);
47
- } else if (process.env.XMCP_TELEMETRY_DISABLED) {
48
- console.log(
49
- "[telemetry] Disabled via XMCP_TELEMETRY_DISABLED environment variable"
50
- );
51
- }
52
- }
53
- }
54
-
55
- get anonymousId(): string {
56
- return this.storage.anonymousId;
57
- }
58
-
59
- get isDisabled(): boolean {
60
- return this.storage.isDisabled;
61
- }
62
-
63
- get isEnabled(): boolean {
64
- return this.storage.isEnabled;
65
- }
66
-
67
- setEnabled(enabled: boolean): string | undefined {
68
- return this.storage.setEnabled(enabled);
69
- }
70
-
71
- private async getProjectId(): Promise<string> {
72
- this.loadProjectId =
73
- this.loadProjectId ||
74
- getProjectId(this.storage.oneWayHash.bind(this.storage));
75
- return await this.loadProjectId;
76
- }
77
-
78
- /**
79
- * Record telemetry events
80
- * Returns a promise that resolves to a RecordObject
81
- */
82
- record(
83
- _events: TelemetryEvent | TelemetryEvent[],
84
- deferred?: boolean
85
- ): Promise<RecordObject> {
86
- const eventsWithTimestamps = (
87
- Array.isArray(_events) ? _events : [_events]
88
- ).map((event) => ({
89
- ...event,
90
- timestamp: event.timestamp ?? new Date().toISOString(),
91
- }));
92
-
93
- const normalizedEvents = Array.isArray(_events)
94
- ? eventsWithTimestamps
95
- : eventsWithTimestamps[0];
96
-
97
- const prom = (
98
- deferred
99
- ? // if we know we are going to immediately call
100
- // flushDetached we can skip starting the initial
101
- // submitRecord which will then be cancelled
102
- new Promise((resolve) =>
103
- resolve({
104
- isFulfilled: true,
105
- isRejected: false,
106
- value: normalizedEvents,
107
- })
108
- )
109
- : this.submitRecord(normalizedEvents)
110
- )
111
- .then((value) => ({
112
- isFulfilled: true,
113
- isRejected: false,
114
- value,
115
- }))
116
- .catch((reason) => ({
117
- isFulfilled: false,
118
- isRejected: true,
119
- reason,
120
- }))
121
- // Acts as `Promise#finally` because `catch` transforms the error
122
- .then((res) => {
123
- // Clean up the event to prevent unbounded `Set` growth
124
- if (!deferred) {
125
- this.queue.delete(prom);
126
- }
127
- return res;
128
- });
129
-
130
- (prom as any)._events = eventsWithTimestamps;
131
-
132
- // Track this `Promise` so we can flush pending events
133
- this.queue.add(prom);
134
-
135
- return prom;
136
- }
137
-
138
- private async submitRecord(
139
- _events: TelemetryEvent | TelemetryEvent[]
140
- ): Promise<any> {
141
- let events: TelemetryEvent[];
142
- if (Array.isArray(_events)) {
143
- events = _events;
144
- } else {
145
- events = [_events];
146
- }
147
-
148
- if (events.length < 1) {
149
- return Promise.resolve();
150
- }
151
-
152
- // Skip recording telemetry if the feature is disabled
153
- if (this.isDisabled) {
154
- return Promise.resolve();
155
- }
156
-
157
- const meta = getAnonymousMeta();
158
-
159
- const payload = createPayload(
160
- {
161
- anonymousId: this.storage.anonymousId,
162
- projectHash: await this.getProjectId(),
163
- sessionId: this.sessionId,
164
- },
165
- meta,
166
- events.map((event) => ({
167
- eventName: event.eventName,
168
- timestamp: event.timestamp ?? new Date().toISOString(),
169
- fields: event.fields,
170
- }))
171
- );
172
-
173
- return await postTelemetryPayload(payload);
174
- }
175
-
176
- /**
177
- * Flush all pending telemetry events
178
- */
179
- async flush(): Promise<void> {
180
- await Promise.all(this.queue).catch(() => null);
181
- }
182
-
183
- /**
184
- * Writes current events to disk and spawns separate
185
- * detached process to submit the records without blocking
186
- * the main process from exiting
187
- */
188
- flushDetached(mode: "dev" | "build"): void {
189
- if (this.isDisabled) {
190
- this.queue.clear();
191
- return;
192
- }
193
-
194
- const allEvents: TelemetryEvent[] = [];
195
-
196
- this.queue.forEach((item: any) => {
197
- try {
198
- allEvents.push(...item._events);
199
- } catch (_) {
200
- // if we fail to collect events, ignore
201
- }
202
- });
203
-
204
- // Skip if no events to send
205
- if (allEvents.length === 0) {
206
- return;
207
- }
208
-
209
- try {
210
- mkdirSync(this.distDir, { recursive: true });
211
- const eventsFilePath = path.join(this.distDir, "_events.json");
212
- // Save both events and sessionId to preserve session across processes
213
- writeFileSync(
214
- eventsFilePath,
215
- JSON.stringify({
216
- sessionId: this.sessionId,
217
- events: allEvents,
218
- })
219
- );
220
-
221
- // Note: cross-spawn is not used here as it causes
222
- // a new command window to appear when we don't want it to
223
- const child_process =
224
- require("child_process") as typeof import("child_process");
225
-
226
- // we use spawnSync when debugging to ensure logs are piped
227
- // correctly to stdout/stderr
228
- const spawn = child_process.spawn;
229
-
230
- // Resolve the detached-flush script path
231
- // After webpack compilation, detached-flush.js is in the dist root
232
- // We need to go up from wherever this compiled file is to find it
233
- // This file will be bundled into index.js, so __dirname will be dist/
234
- const detachedFlushPath = path.join(__dirname, "detached-flush.js");
235
-
236
- const result = spawn(
237
- process.execPath,
238
- [detachedFlushPath, mode, this.distDir],
239
- {
240
- detached: true,
241
- windowsHide: true,
242
- shell: false,
243
- }
244
- );
245
-
246
- // Unref the child process so it doesn't keep the parent alive
247
- if ("unref" in result && result.unref) {
248
- result.unref();
249
- }
250
-
251
- this.queue.clear();
252
- } catch (error) {
253
- // Silently fail - telemetry should never break the build
254
- }
255
- }
256
-
257
- // For testing purposes
258
- getStorage(): TelemetryStorage {
259
- return this.storage;
260
- }
261
-
262
- getSessionId(): string {
263
- return this.sessionId;
264
- }
265
-
266
- getQueueSize(): number {
267
- return this.queue.size;
268
- }
269
- }
270
-
271
- // Singleton instance
272
- let telemetryInstance: TelemetryTracker | null = null;
273
-
274
- export function getTelemetry(): TelemetryTracker {
275
- if (!telemetryInstance) {
276
- telemetryInstance = new TelemetryTracker();
277
- }
278
- return telemetryInstance;
279
- }
280
-
281
- export const telemetry = getTelemetry();
@@ -1,7 +0,0 @@
1
- export { telemetry } from "./events/tracker";
2
- export {
3
- TelemetryEventName,
4
- TransportType,
5
- ErrorPhase,
6
- AdapterType,
7
- } from "./events/definitions";
@@ -1,49 +0,0 @@
1
- import isDockerFunction from "is-docker";
2
- import isWslBoolean from "is-wsl";
3
- import os from "os";
4
- import ciEnvironment from "ci-info";
5
-
6
- // CI details
7
- const { isCI: _isCI, name: _name } = ciEnvironment;
8
-
9
- export type TelemetryMeta = {
10
- platform: NodeJS.Platform;
11
- systemRelease: string;
12
- arch: string;
13
- cpuCores: number;
14
- cpuModel: string | null;
15
- cpuSpeed: number | null;
16
- memoryTotal: number;
17
- isDocker: boolean;
18
- isWsl: boolean;
19
- isCI: typeof _isCI;
20
- ciName: typeof _name | null;
21
- };
22
-
23
- let traits: TelemetryMeta | undefined;
24
-
25
- export function getAnonymousMeta(): TelemetryMeta {
26
- if (traits) {
27
- return traits;
28
- }
29
-
30
- const cpus = os.cpus() || [];
31
- traits = {
32
- // Software information
33
- platform: os.platform(),
34
- systemRelease: os.release(),
35
- arch: os.arch(),
36
- // Machine information
37
- cpuCores: cpus.length,
38
- cpuModel: cpus.length ? cpus[0].model : null,
39
- cpuSpeed: cpus.length ? cpus[0].speed : null,
40
- memoryTotal: Math.trunc(os.totalmem() / Math.pow(1024, 2)),
41
- // Environment information
42
- isDocker: isDockerFunction(),
43
- isWsl: isWslBoolean,
44
- isCI: _isCI,
45
- ciName: (_isCI && _name) || null,
46
- };
47
-
48
- return traits;
49
- }
@@ -1,35 +0,0 @@
1
- import { readFileSync } from "fs";
2
- import path from "path";
3
- import { createHash } from "crypto";
4
-
5
- /**
6
- * Get raw project ID from package.json
7
- */
8
- export async function getRawProjectId(): Promise<string> {
9
- try {
10
- // Try to read package.json from current working directory
11
- const packageJsonPath = path.join(process.cwd(), "package.json");
12
- const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
13
-
14
- // Use package name and version as stable identifier
15
- // This gives us a stable ID even across different machines
16
- const identifier = `${packageJson.name || "unknown"}@${
17
- packageJson.version || "0.0.0"
18
- }`;
19
-
20
- return identifier;
21
- } catch (error) {
22
- // Fallback to directory path if package.json not found
23
- return process.cwd();
24
- }
25
- }
26
-
27
- /**
28
- * Get a hashed project ID
29
- */
30
- export async function getProjectId(
31
- oneWayHash: (payload: string) => string
32
- ): Promise<string> {
33
- const rawId = await getRawProjectId();
34
- return oneWayHash(rawId);
35
- }