rivet-design 0.26.1 → 0.27.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.
Files changed (122) hide show
  1. package/bin/rivet.js +13 -0
  2. package/dist/agent-variants/PreviewRuntime.js +20 -7
  3. package/dist/agent-variants/WorkerExecutorService.d.ts +0 -2
  4. package/dist/agent-variants/WorkerExecutorService.js +0 -18
  5. package/dist/agent-variants/WorktreeOrchestrator.testHelpers.js +0 -8
  6. package/dist/agent-variants/contracts.d.ts +1001 -4868
  7. package/dist/agent-variants/contracts.js +1 -121
  8. package/dist/agent-variants/index.d.ts +1 -1
  9. package/dist/agent-variants/variantsTelemetry.d.ts +4 -8
  10. package/dist/agent-variants/variantsTelemetry.js +3 -0
  11. package/dist/agent-variants/workItemInput.d.ts +386 -386
  12. package/dist/cli/commands/contextRequest.js +1 -1
  13. package/dist/cli/commands/guidanceReferences.d.ts +2 -2
  14. package/dist/cli/commands/guidanceVerifierPackage.d.ts +2 -2
  15. package/dist/cli/commands/mcpServe.js +1 -0
  16. package/dist/cli/commands/serve.js +2 -0
  17. package/dist/cli/editorSession.d.ts +1 -13
  18. package/dist/cli/handoff.d.ts +1 -0
  19. package/dist/cli/handoff.js +20 -4
  20. package/dist/cli/router.js +1 -0
  21. package/dist/cli/runtimeInterruption.d.ts +2 -16
  22. package/dist/cli/telemetry.d.ts +10 -0
  23. package/dist/cli/telemetry.js +37 -1
  24. package/dist/config/pluginMetrics.js +36 -1
  25. package/dist/hosts/workerDefaults.d.ts +0 -11
  26. package/dist/hosts/workerDefaults.js +1 -30
  27. package/dist/index-core.d.ts +0 -1
  28. package/dist/index.d.ts +19 -0
  29. package/dist/index.js +15 -6
  30. package/dist/install/automaticCliUpdate.d.ts +1 -0
  31. package/dist/install/automaticCliUpdate.js +32 -22
  32. package/dist/install/channelCli.d.ts +1 -1
  33. package/dist/install/channelCli.js +11 -6
  34. package/dist/install/channelManager.d.ts +5 -2
  35. package/dist/install/globalBootstrap.d.ts +5 -3
  36. package/dist/install/globalBootstrap.js +21 -9
  37. package/dist/install/npmCommand.d.ts +15 -0
  38. package/dist/install/npmCommand.js +59 -0
  39. package/dist/routes/agentVariants.js +3 -14
  40. package/dist/routes/library/browserAccess.js +6 -2
  41. package/dist/routes/library/guidance.js +3 -1
  42. package/dist/routes/library/middleware.js +15 -9
  43. package/dist/routes/library/navigation.js +3 -1
  44. package/dist/routes/library/profiles.js +5 -5
  45. package/dist/routes/library/projects.js +17 -7
  46. package/dist/routes/library/referenceOnboarding.js +4 -2
  47. package/dist/routes/library/schemas.d.ts +2 -15
  48. package/dist/routes/telemetry.js +1 -1
  49. package/dist/routes/variantRequestSchema.d.ts +4 -4
  50. package/dist/routes/variantRequestSchema.js +7 -2
  51. package/dist/server.js +8 -0
  52. package/dist/services/AuthService.d.ts +3 -56
  53. package/dist/services/AuthService.js +0 -28
  54. package/dist/services/ConfigManager.d.ts +0 -2
  55. package/dist/services/ConfigManager.js +0 -14
  56. package/dist/services/DependencyPreparationService.js +57 -19
  57. package/dist/services/GuidanceVerifierRunner.js +4 -4
  58. package/dist/services/HubDiscovery.d.ts +1 -9
  59. package/dist/services/IntegrationsClient.d.ts +16 -16
  60. package/dist/services/MCPOnboardingTelemetry.d.ts +0 -14
  61. package/dist/services/MCPOnboardingTelemetry.js +0 -62
  62. package/dist/services/ProjectPackageManager.d.ts +5 -0
  63. package/dist/services/ProjectPackageManager.js +33 -11
  64. package/dist/services/ProjectRegistry.d.ts +5 -24
  65. package/dist/services/TelemetryService.d.ts +9 -64
  66. package/dist/services/TelemetryService.js +10 -113
  67. package/dist/services/TreeStore.d.ts +0 -2
  68. package/dist/services/TreeStore.js +0 -24
  69. package/dist/services/WorktreeManager.js +5 -0
  70. package/dist/services/profiles/DesignProfiles.d.ts +180 -125
  71. package/dist/services/profiles/DesignProfiles.js +16 -8
  72. package/dist/services/profiles/ProfilePlanning.d.ts +38 -38
  73. package/dist/services/profiles/ReferenceReader.d.ts +14 -14
  74. package/dist/services/profiles/modelContract.js +4 -4
  75. package/dist/storage/library/ProjectPreviewCache.d.ts +1 -13
  76. package/dist/storage/profiles/ProfilePlans.d.ts +137 -137
  77. package/dist/storage/profiles/ProfileRecords.d.ts +62 -37
  78. package/dist/storage/profiles/planSchema.d.ts +40 -40
  79. package/dist/storage/profiles/schema.d.ts +16 -16
  80. package/dist/types/api-responses.d.ts +174 -0
  81. package/dist/types/api-responses.js +108 -0
  82. package/dist/types/cosmos-profile.d.ts +17 -105
  83. package/dist/types/cosmos.d.ts +48 -266
  84. package/dist/types/design-library.d.ts +230 -61
  85. package/dist/types/design-library.js +38 -1
  86. package/dist/types/design-profile.d.ts +220 -529
  87. package/dist/types/design-profile.js +5 -1
  88. package/dist/types/guidance-references.d.ts +68 -316
  89. package/dist/types/guidance-verifier.d.ts +69 -560
  90. package/dist/types/guidance-verifier.js +15 -2
  91. package/dist/types/guidance.d.ts +182 -1643
  92. package/dist/types/guidance.js +4 -1
  93. package/dist/types/project-library.d.ts +60 -30
  94. package/dist/types/project-library.js +32 -1
  95. package/dist/types/reference-connectors.d.ts +38 -162
  96. package/dist/types/reference-onboarding.d.ts +144 -878
  97. package/dist/types/reference-pages.d.ts +27 -139
  98. package/dist/types/x-bookmarks.d.ts +40 -296
  99. package/dist/utils/devServerError.d.ts +5 -0
  100. package/dist/utils/devServerError.js +4 -0
  101. package/dist/utils/displayLocale.d.ts +0 -1
  102. package/dist/utils/displayLocale.js +1 -3
  103. package/dist/utils/failureReason.d.ts +16 -0
  104. package/dist/utils/failureReason.js +106 -0
  105. package/dist/utils/hostedLogPrivacy.d.ts +1 -0
  106. package/dist/utils/hostedLogPrivacy.js +10 -4
  107. package/dist/utils/skills/claude-skill.d.ts +1 -1
  108. package/dist/utils/skills/claude-skill.js +1 -1
  109. package/dist/utils/skills/cli-guidance.d.ts +1 -1
  110. package/dist/utils/skills/cli-guidance.js +3 -3
  111. package/dist/utils/skills/cursor-rules.d.ts +1 -1
  112. package/dist/utils/skills/cursor-rules.js +1 -1
  113. package/package.json +5 -5
  114. package/src/ui/dist/assets/LibraryEntry-RI9Lc7P3.js +37 -0
  115. package/src/ui/dist/assets/main-D0UmAaUe.css +1 -0
  116. package/src/ui/dist/assets/main-DgrLzS5j.js +497 -0
  117. package/src/ui/dist/index.html +2 -2
  118. package/dist/types/change-types.d.ts +0 -66
  119. package/dist/types/change-types.js +0 -3
  120. package/src/ui/dist/assets/LibraryEntry-Cr4GFYXW.js +0 -37
  121. package/src/ui/dist/assets/main-W3oTuTTl.css +0 -1
  122. package/src/ui/dist/assets/main-tPO1OCpZ.js +0 -439
@@ -18,68 +18,16 @@ declare const LoginResponseSchema: z.ZodObject<{
18
18
  id: z.ZodString;
19
19
  email: z.ZodString;
20
20
  displayName: z.ZodOptional<z.ZodString>;
21
- }, "strip", z.ZodTypeAny, {
22
- email: string;
23
- id: string;
24
- displayName?: string | undefined;
25
- }, {
26
- email: string;
27
- id: string;
28
- displayName?: string | undefined;
29
- }>>;
21
+ }, z.core.$strip>>;
30
22
  profile: z.ZodOptional<z.ZodNullable<z.ZodObject<{
31
23
  remaining_spend_usd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
32
24
  monthly_limit_usd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
33
25
  current_month_spend_usd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
34
26
  total_spend_usd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
35
- }, "strip", z.ZodTypeAny, {
36
- remaining_spend_usd?: number | null | undefined;
37
- monthly_limit_usd?: number | null | undefined;
38
- current_month_spend_usd?: number | null | undefined;
39
- total_spend_usd?: number | null | undefined;
40
- }, {
41
- remaining_spend_usd?: number | null | undefined;
42
- monthly_limit_usd?: number | null | undefined;
43
- current_month_spend_usd?: number | null | undefined;
44
- total_spend_usd?: number | null | undefined;
45
- }>>>;
27
+ }, z.core.$strip>>>;
46
28
  error: z.ZodOptional<z.ZodString>;
47
29
  message: z.ZodOptional<z.ZodString>;
48
- }, "strip", z.ZodTypeAny, {
49
- success: boolean;
50
- error?: string | undefined;
51
- token?: string | undefined;
52
- message?: string | undefined;
53
- refreshToken?: string | undefined;
54
- user?: {
55
- email: string;
56
- id: string;
57
- displayName?: string | undefined;
58
- } | undefined;
59
- profile?: {
60
- remaining_spend_usd?: number | null | undefined;
61
- monthly_limit_usd?: number | null | undefined;
62
- current_month_spend_usd?: number | null | undefined;
63
- total_spend_usd?: number | null | undefined;
64
- } | null | undefined;
65
- }, {
66
- success: boolean;
67
- error?: string | undefined;
68
- token?: string | undefined;
69
- message?: string | undefined;
70
- refreshToken?: string | undefined;
71
- user?: {
72
- email: string;
73
- id: string;
74
- displayName?: string | undefined;
75
- } | undefined;
76
- profile?: {
77
- remaining_spend_usd?: number | null | undefined;
78
- monthly_limit_usd?: number | null | undefined;
79
- current_month_spend_usd?: number | null | undefined;
80
- total_spend_usd?: number | null | undefined;
81
- } | null | undefined;
82
- }>;
30
+ }, z.core.$strip>;
83
31
  type LoginResponse = z.infer<typeof LoginResponseSchema>;
84
32
  type UserProfile = {
85
33
  user: {
@@ -123,7 +71,6 @@ export declare class AuthService {
123
71
  resumePendingLogin(maxAttempts?: number): Promise<LoginResponse | null>;
124
72
  private pollForToken;
125
73
  logout(options?: LogoutOptions): Promise<void>;
126
- getProfile(): Promise<UserProfile | null>;
127
74
  ensureAuthenticated(): Promise<boolean>;
128
75
  getValidatedProfile(): Promise<UserProfile | null>;
129
76
  isAuthenticated(): boolean;
@@ -600,34 +600,6 @@ class AuthService {
600
600
  }
601
601
  log.info('Logged out successfully');
602
602
  }
603
- async getProfile() {
604
- const token = this.configManager.getAuthToken();
605
- if (!token) {
606
- log.warn('No authentication token found');
607
- return null;
608
- }
609
- try {
610
- const response = await fetch(`${this.proxyUrl}/api/user/profile`, {
611
- method: 'GET',
612
- headers: {
613
- 'Content-Type': 'application/json',
614
- Authorization: `Bearer ${token}`,
615
- },
616
- signal: AbortSignal.timeout(PROFILE_FETCH_TIMEOUT_MS),
617
- });
618
- if (!response.ok) {
619
- const error = await response.json().catch(() => ({}));
620
- log.warn('Failed to fetch profile:', error);
621
- return null;
622
- }
623
- const result = await response.json();
624
- return result.success ? result : null;
625
- }
626
- catch (error) {
627
- log.warn('Profile fetch error:', error);
628
- return null;
629
- }
630
- }
631
603
  async ensureAuthenticated() {
632
604
  const profile = await this.getValidatedProfile();
633
605
  return profile !== null;
@@ -76,8 +76,6 @@ export declare class ConfigManager {
76
76
  setTelemetryIdentifiedEmail(email: string): void;
77
77
  getTelemetryIdentifiedUserId(): string | undefined;
78
78
  setTelemetryIdentifiedUserId(userId: string): void;
79
- hasCompletedFirstVariantsRun(): boolean;
80
- markFirstVariantsRun(): void;
81
79
  claimMcpRemovedTelemetryWindow(now?: Date): boolean;
82
80
  getInstallRef(): string | undefined;
83
81
  setInstallRef(installRef: string, downloadType?: string): void;
@@ -276,20 +276,6 @@ class ConfigManager {
276
276
  this.config.telemetryIdentifiedUserId = userId;
277
277
  this.saveConfig();
278
278
  }
279
- hasCompletedFirstVariantsRun() {
280
- this.reloadConfigFromDisk();
281
- return Boolean(this.config.firstVariantsRunAt);
282
- }
283
- markFirstVariantsRun() {
284
- if (this.config.firstVariantsRunAt)
285
- return;
286
- this.reloadConfigFromDisk();
287
- if (this.config.firstVariantsRunAt)
288
- return;
289
- this.config.firstVariantsRunAt = new Date().toISOString();
290
- this.saveConfig();
291
- log.debug('Recorded first variants run for onboarding gate');
292
- }
293
279
  claimMcpRemovedTelemetryWindow(now = new Date()) {
294
280
  const day = now.toISOString().slice(0, 10);
295
281
  this.reloadConfigFromDisk();
@@ -16,6 +16,7 @@ const ProjectPackageManager_1 = require("./ProjectPackageManager");
16
16
  const errnoCode_1 = require("../utils/errnoCode");
17
17
  const pathContainment_1 = require("../utils/pathContainment");
18
18
  const errorMessage_1 = require("../utils/errorMessage");
19
+ const failureReason_1 = require("../utils/failureReason");
19
20
  const subprocessEnvironment_1 = require("../utils/subprocessEnvironment");
20
21
  const MAX_CONCURRENT_INSTALLS = 2;
21
22
  const INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
@@ -43,11 +44,13 @@ const isInstallEnvironmentKey = (key) => {
43
44
  INSTALL_ENVIRONMENT_KEYS.has(lower));
44
45
  };
45
46
  const yarnAgentForVersion = (version) => Number.parseInt(version, 10) > 1 ? 'yarn@berry' : 'yarn';
46
- const preparationError = (message, detail = '') => new devServerError_1.DevServerStartError({
47
+ const preparationError = ({ reasonCode, message, detail = '', }) => new devServerError_1.DevServerStartError({
47
48
  message: detail ? `${message}\n${detail}` : message,
48
49
  reason: 'dependency_install_failed',
49
50
  portInUse: false,
50
51
  detail,
52
+ reasonCode,
53
+ summary: message,
51
54
  });
52
55
  class DependencyPreparationService {
53
56
  pending = new Map();
@@ -78,7 +81,10 @@ class DependencyPreparationService {
78
81
  catch (error) {
79
82
  if (error instanceof devServerError_1.DevServerStartError)
80
83
  throw error;
81
- throw preparationError(`Could not prepare preview dependencies: ${(0, errorMessage_1.errorMessage)(error)}`);
84
+ throw preparationError({
85
+ reasonCode: (0, failureReason_1.failureReasonCode)(error),
86
+ message: `Could not prepare preview dependencies: ${(0, errorMessage_1.errorMessage)(error)}`,
87
+ });
82
88
  }
83
89
  }
84
90
  forget(workspaceRoot) {
@@ -116,9 +122,16 @@ class DependencyPreparationService {
116
122
  .reverse()
117
123
  .find((line) => /^\d+\.\d+\.\d+(?:-.+)?$/.test(line));
118
124
  if (!version)
119
- throw preparationError(`Could not identify the ${project.name} version`, versionOutput);
125
+ throw preparationError({
126
+ reasonCode: 'version_unreadable',
127
+ message: `Could not identify the ${project.name} version`,
128
+ detail: versionOutput,
129
+ });
120
130
  if (project.version && version !== project.version) {
121
- throw preparationError(`This project requires ${project.name}@${project.version}, but the available command reports ${version}. Activate the project's package manager version, then retry the preview.`);
131
+ throw preparationError({
132
+ reasonCode: 'version_mismatch',
133
+ message: `This project requires ${project.name}@${project.version}, but the available command reports ${version}. Activate the project's package manager version, then retry the preview.`,
134
+ });
122
135
  }
123
136
  const agent = project.name === 'yarn' ? yarnAgentForVersion(version) : project.agent;
124
137
  const fingerprint = await this.fingerprint(project, version);
@@ -134,7 +147,10 @@ class DependencyPreparationService {
134
147
  : await this.fingerprint(project, version, true);
135
148
  const command = (0, package_manager_detector_1.resolveCommand)(agent, project.hasLockfile ? 'frozen' : 'install', []);
136
149
  if (!command)
137
- throw preparationError(`No dependency install command is available for ${project.name}`);
150
+ throw preparationError({
151
+ reasonCode: 'no_install_command',
152
+ message: `No dependency install command is available for ${project.name}`,
153
+ });
138
154
  if (project.name === 'npm')
139
155
  command.args.push('--no-audit', '--no-fund');
140
156
  if (this.activeInstalls >= MAX_CONCURRENT_INSTALLS) {
@@ -166,7 +182,10 @@ class DependencyPreparationService {
166
182
  ? completedFingerprint
167
183
  : await this.fingerprint(project, version, true);
168
184
  if (inputsAfterInstall !== inputsBeforeInstall) {
169
- throw preparationError('Dependency inputs changed during installation. Retry the preview to prepare the updated project.');
185
+ throw preparationError({
186
+ reasonCode: 'inputs_changed',
187
+ message: 'Dependency inputs changed during installation. Retry the preview to prepare the updated project.',
188
+ });
170
189
  }
171
190
  this.prepared.set(project.rootPath, {
172
191
  fingerprint: completedFingerprint,
@@ -194,14 +213,20 @@ class DependencyPreparationService {
194
213
  try {
195
214
  const resolved = await promises_1.default.realpath(candidate);
196
215
  if (!(0, pathContainment_1.isPathWithinRoot)(boundary, resolved))
197
- throw preparationError(`Dependency path resolves outside the preview workspace: ${candidate}`);
216
+ throw preparationError({
217
+ reasonCode: 'path_outside_workspace',
218
+ message: `Dependency path resolves outside the preview workspace: ${candidate}`,
219
+ });
198
220
  }
199
221
  catch (error) {
200
222
  if ((0, errnoCode_1.errnoCode)(error) !== 'ENOENT')
201
223
  throw error;
202
224
  const entry = await promises_1.default.lstat(candidate).catch(() => null);
203
225
  if (entry?.isSymbolicLink())
204
- throw preparationError(`Dependency path is a dangling symlink: ${candidate}`);
226
+ throw preparationError({
227
+ reasonCode: 'dangling_symlink',
228
+ message: `Dependency path is a dangling symlink: ${candidate}`,
229
+ });
205
230
  }
206
231
  }
207
232
  }
@@ -284,7 +309,7 @@ class DependencyPreparationService {
284
309
  stdio: 'pipe',
285
310
  });
286
311
  let output = '';
287
- let interrupted = false;
312
+ let interruption;
288
313
  let settleTimer;
289
314
  const drain = (chunk) => {
290
315
  output = (output + chunk.toString()).slice(-OUTPUT_TAIL_LIMIT);
@@ -292,35 +317,48 @@ class DependencyPreparationService {
292
317
  proc.stdout?.on('data', drain);
293
318
  proc.stderr?.on('data', drain);
294
319
  proc.stdin?.end();
295
- const stop = () => {
296
- interrupted = true;
320
+ const stop = (cause) => {
321
+ interruption ??= cause;
297
322
  void OperatingSystemServices_1.selectedOperatingSystemServices.projectProcesses
298
323
  .terminate(proc, { isForceful: true })
299
324
  .catch(() => undefined);
300
325
  settleTimer ??= setTimeout(() => {
301
326
  cleanup();
302
- reject(preparationError(`Dependency preparation could not be stopped: ${project.name} ${args.join(' ')} is still running. Stop the process, then retry the preview.`, output.trim()));
327
+ reject(preparationError({
328
+ reasonCode: 'installer_unstoppable',
329
+ message: `Dependency preparation could not be stopped: ${project.name} ${args.join(' ')} is still running. Stop the process, then retry the preview.`,
330
+ detail: output.trim(),
331
+ }));
303
332
  }, this.terminationSettleTimeoutMs);
304
333
  };
305
- const timer = setTimeout(stop, timeoutMs);
306
- signal?.addEventListener('abort', stop, { once: true });
334
+ const abort = () => stop('aborted');
335
+ const timer = setTimeout(() => stop('timeout'), timeoutMs);
336
+ signal?.addEventListener('abort', abort, { once: true });
307
337
  if (signal?.aborted)
308
- stop();
338
+ abort();
309
339
  const cleanup = () => {
310
340
  clearTimeout(timer);
311
341
  clearTimeout(settleTimer);
312
- signal?.removeEventListener('abort', stop);
342
+ signal?.removeEventListener('abort', abort);
313
343
  };
314
344
  proc.once('error', (error) => {
315
345
  cleanup();
316
- reject(preparationError(`Could not run ${project.name} ${args.join(' ')}: ${error.message}`, output));
346
+ reject(preparationError({
347
+ reasonCode: (0, failureReason_1.failureReasonCode)(error),
348
+ message: `Could not run ${project.name} ${args.join(' ')}: ${error.message}`,
349
+ detail: output,
350
+ }));
317
351
  });
318
352
  proc.once('close', (code) => {
319
353
  cleanup();
320
- if (code === 0 && !interrupted)
354
+ if (code === 0 && !interruption)
321
355
  resolve(output);
322
356
  else
323
- reject(preparationError(`Dependency preparation failed: ${project.name} ${args.join(' ')} (${interrupted ? 'cancelled or timed out' : `exit ${code}`}). Fix the installation error, then retry the preview.`, output.trim()));
357
+ reject(preparationError({
358
+ reasonCode: interruption ?? 'install_failed',
359
+ message: `Dependency preparation failed: ${project.name} ${args.join(' ')} (${interruption ? 'cancelled or timed out' : `exit ${code}`}). Fix the installation error, then retry the preview.`,
360
+ detail: output.trim(),
361
+ }));
324
362
  });
325
363
  });
326
364
  }
@@ -254,16 +254,16 @@ const executeGuidanceVerifier = async (args) => {
254
254
  durationMs: Date.now() - started,
255
255
  });
256
256
  try {
257
- await promises_1.default.mkdir(args.runsDirectory, { recursive: true, mode: 0o700 });
258
- runDirectory = await promises_1.default.mkdtemp(path_1.default.join(await promises_1.default.realpath(args.runsDirectory), 'run-'));
259
- if (args.signal?.aborted)
260
- return failed('cancelled');
261
257
  if (args.packet.verifierState === 'missing')
262
258
  return failed('verifier_missing');
263
259
  if (args.packet.verifierState === 'stale')
264
260
  return failed('verifier_stale');
265
261
  if (!args.packet.verifier.package)
266
262
  return failed('package_required');
263
+ await promises_1.default.mkdir(args.runsDirectory, { recursive: true, mode: 0o700 });
264
+ runDirectory = await promises_1.default.mkdtemp(path_1.default.join(await promises_1.default.realpath(args.runsDirectory), 'run-'));
265
+ if (args.signal?.aborted)
266
+ return failed('cancelled');
267
267
  const executable = guidance_verifier_1.GuidanceVerifierPackageSchema.parse(args.packet.verifier.package);
268
268
  const packageDirectory = await (0, retainedTextFiles_1.materializeTextFiles)({
269
269
  files: executable.files,
@@ -3,15 +3,7 @@ declare const HubRecordSchema: z.ZodObject<{
3
3
  pid: z.ZodNumber;
4
4
  token: z.ZodString;
5
5
  port: z.ZodNullable<z.ZodNumber>;
6
- }, "strip", z.ZodTypeAny, {
7
- port: number | null;
8
- token: string;
9
- pid: number;
10
- }, {
11
- port: number | null;
12
- token: string;
13
- pid: number;
14
- }>;
6
+ }, z.core.$strip>;
15
7
  export type HubRecord = z.infer<typeof HubRecordSchema>;
16
8
  type ClaimResult = {
17
9
  status: 'owned';
@@ -139,22 +139,22 @@ export declare class IntegrationsClient {
139
139
  cursor?: string;
140
140
  signal?: AbortSignal;
141
141
  }): Promise<{
142
- total: number | null;
143
- nextCursor: string | null;
144
142
  collections: {
143
+ id: string;
144
+ title: string;
145
145
  description: string | null;
146
146
  url: string | null;
147
- title: string;
148
- id: string;
149
- children: string[];
150
147
  total: number | null;
151
148
  parentId: string | null;
149
+ children: string[];
152
150
  }[];
151
+ total: number | null;
152
+ nextCursor: string | null;
153
153
  profile: {
154
- url: string;
155
- title: string;
156
154
  id: string;
157
155
  username: string;
156
+ title: string;
157
+ url: string;
158
158
  };
159
159
  }>;
160
160
  readReferenceCollection(input: {
@@ -165,11 +165,11 @@ export declare class IntegrationsClient {
165
165
  signal?: AbortSignal;
166
166
  }): Promise<{
167
167
  accountId: string;
168
+ collectionId: string;
168
169
  references: {
170
+ remoteId: string;
169
171
  title: string;
170
172
  text: string;
171
- provider: "pinterest" | "arena" | "cosmos" | "x";
172
- remoteId: string;
173
173
  media: {
174
174
  hash: string;
175
175
  mimeType: "image/png" | "image/jpeg" | "image/webp" | "image/gif";
@@ -177,21 +177,21 @@ export declare class IntegrationsClient {
177
177
  representation: "variant" | "image" | "video-cover" | "page";
178
178
  page?: number | undefined;
179
179
  }[];
180
+ provider: "pinterest" | "arena" | "cosmos" | "x";
181
+ url?: string | undefined;
182
+ remoteImages?: string[] | undefined;
183
+ remoteImageRepresentations?: ("image" | "video-cover")[] | undefined;
184
+ unsupportedReason?: string | undefined;
180
185
  variant?: {
181
186
  projectId: string;
182
187
  sessionId: string;
183
188
  variantId: string;
184
189
  treeSha?: string | undefined;
185
190
  } | undefined;
186
- url?: string | undefined;
187
191
  note?: string | undefined;
188
- remoteImages?: string[] | undefined;
189
- remoteImageRepresentations?: ("image" | "video-cover")[] | undefined;
190
- unsupportedReason?: string | undefined;
191
192
  }[];
192
193
  total: number | null;
193
194
  nextCursor: string | null;
194
- collectionId: string;
195
195
  isCollectionComplete: boolean;
196
196
  }>;
197
197
  referenceAccount(input: {
@@ -199,10 +199,10 @@ export declare class IntegrationsClient {
199
199
  expectedAccountId: string;
200
200
  signal?: AbortSignal;
201
201
  }): Promise<{
202
- url: string;
203
- title: string;
204
202
  id: string;
205
203
  username: string;
204
+ title: string;
205
+ url: string;
206
206
  }>;
207
207
  discoverCosmos({ url, cursor, signal, }: CosmosDiscoveryInput): Promise<CosmosProfilePage>;
208
208
  fetchCosmos({ url, collectionId, cursor, signal, }: CosmosFetchInput): Promise<CosmosResult>;
@@ -1,9 +1,6 @@
1
- import type { ChangeRequest } from '../types/change-request-types';
2
1
  export type MCPSource = 'mcp' | 'ui' | 'core';
3
2
  export type MCPAuthState = 'authenticated' | 'unauthenticated' | 'unknown';
4
3
  export type MCPAuthMethod = 'google' | 'existing_session' | 'hosted_oauth';
5
- export type MCPTargetKind = 'app' | 'variant' | 'static_preview' | 'unknown';
6
- export type MCPHandoffPathCategory = 'landing' | 'local_rivet' | 'mcp_client_connect' | 'oauth_callback' | 'unknown';
7
4
  export type MCPOAuthCallbackResult = 'accepted' | 'missing_state' | 'missing_code' | 'state_mismatch' | 'exchange_failed' | 'credential_store_failed' | 'unknown';
8
5
  export type MCPOnboardingCorrelation = {
9
6
  onboardingAttemptId?: string;
@@ -16,15 +13,4 @@ export type MCPOnboardingCorrelation = {
16
13
  mcpEditor?: string;
17
14
  source?: MCPSource;
18
15
  };
19
- export type MCPConversationTurnMetadata = MCPOnboardingCorrelation & {
20
- round: number;
21
- messageCount: number;
22
- instructionLengthTotal: number;
23
- maxInstructionLength: number;
24
- imageCount: number;
25
- elementCount: number;
26
- sourceFileCount: number;
27
- targetKind: MCPTargetKind;
28
- };
29
- export declare const summarizeMCPConversationTurn: (request: ChangeRequest, round: number, sessionId: string) => MCPConversationTurnMetadata;
30
16
  //# sourceMappingURL=MCPOnboardingTelemetry.d.ts.map
@@ -1,65 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.summarizeMCPConversationTurn = void 0;
4
- const commentElements = (item) => [
5
- item.element,
6
- ...(item.elements ?? []),
7
- ];
8
- const getTargetKind = (isStaticPreviewTarget, isVariantTarget) => {
9
- if (isStaticPreviewTarget) {
10
- return 'static_preview';
11
- }
12
- if (isVariantTarget) {
13
- return 'variant';
14
- }
15
- return 'app';
16
- };
17
- const summarizeMCPConversationTurn = (request, round, sessionId) => {
18
- let messageCount = 0;
19
- let instructionLengthTotal = 0;
20
- let maxInstructionLength = 0;
21
- let imageCount = 0;
22
- let elementCount = 0;
23
- let isVariantTarget = Boolean(request.target);
24
- let isStaticPreviewTarget = Boolean(request.staticPreviewTarget);
25
- for (const item of request.changes) {
26
- if (item.kind === 'comment') {
27
- messageCount++;
28
- instructionLengthTotal += item.instruction.length;
29
- maxInstructionLength = Math.max(maxInstructionLength, item.instruction.length);
30
- imageCount += item.images?.length ?? 0;
31
- elementCount += commentElements(item).length;
32
- isVariantTarget = isVariantTarget || Boolean(item.target);
33
- isStaticPreviewTarget =
34
- isStaticPreviewTarget || Boolean(item.staticPreviewTarget);
35
- continue;
36
- }
37
- if (item.kind === 'chat') {
38
- messageCount++;
39
- instructionLengthTotal += item.instruction.length;
40
- maxInstructionLength = Math.max(maxInstructionLength, item.instruction.length);
41
- imageCount += item.images?.length ?? 0;
42
- continue;
43
- }
44
- if ('element' in item) {
45
- elementCount++;
46
- }
47
- }
48
- return {
49
- sessionId,
50
- round,
51
- messageCount,
52
- instructionLengthTotal,
53
- maxInstructionLength,
54
- imageCount,
55
- elementCount,
56
- sourceFileCount: new Set(request.sourceFiles ?? []).size,
57
- targetKind: getTargetKind(isStaticPreviewTarget, isVariantTarget),
58
- traceId: request.traceId,
59
- agentRunId: request.agentRunId,
60
- browserSessionId: request.telemetryContext?.browserSessionId,
61
- browserDistinctId: request.telemetryContext?.browserDistinctId,
62
- };
63
- };
64
- exports.summarizeMCPConversationTurn = summarizeMCPConversationTurn;
65
3
  //# sourceMappingURL=MCPOnboardingTelemetry.js.map
@@ -1,5 +1,10 @@
1
1
  import { type Agent } from 'package-manager-detector';
2
+ import type { FailureReasonCode } from '../utils/failureReason';
2
3
  export type PreviewPackageManager = 'npm' | 'yarn' | 'pnpm';
4
+ export declare class PackageManagerError extends Error {
5
+ readonly reasonCode: FailureReasonCode;
6
+ constructor(reasonCode: FailureReasonCode, message: string);
7
+ }
3
8
  export interface ProjectPackageManager {
4
9
  name: PreviewPackageManager;
5
10
  agent: Agent;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveProjectPackageManager = exports.readProjectFile = exports.isInstallOutputPath = exports.forEveryPackageManager = exports.INSTALL_CONTENT_GLOBS = exports.INSTALL_ARTIFACTS = exports.INSTALL_CONFIG_FILES = exports.LOCKFILES = void 0;
6
+ exports.resolveProjectPackageManager = exports.readProjectFile = exports.isInstallOutputPath = exports.forEveryPackageManager = exports.INSTALL_CONTENT_GLOBS = exports.INSTALL_ARTIFACTS = exports.INSTALL_CONFIG_FILES = exports.LOCKFILES = exports.PackageManagerError = void 0;
7
7
  const promises_1 = __importDefault(require("fs/promises"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const glob_1 = require("glob");
@@ -11,6 +11,15 @@ const js_yaml_1 = require("js-yaml");
11
11
  const package_manager_detector_1 = require("package-manager-detector");
12
12
  const errnoCode_1 = require("../utils/errnoCode");
13
13
  const pathContainment_1 = require("../utils/pathContainment");
14
+ class PackageManagerError extends Error {
15
+ reasonCode;
16
+ constructor(reasonCode, message) {
17
+ super(message);
18
+ this.reasonCode = reasonCode;
19
+ this.name = 'PackageManagerError';
20
+ }
21
+ }
22
+ exports.PackageManagerError = PackageManagerError;
14
23
  exports.LOCKFILES = {
15
24
  npm: ['package-lock.json', 'npm-shrinkwrap.json'],
16
25
  yarn: ['yarn.lock'],
@@ -79,13 +88,26 @@ const readProjectFile = async (file) => {
79
88
  exports.readProjectFile = readProjectFile;
80
89
  const readManifest = async (root) => {
81
90
  const source = await (0, exports.readProjectFile)(path_1.default.join(root, 'package.json'));
82
- return source === null ? null : JSON.parse(source);
91
+ if (source === null)
92
+ return null;
93
+ try {
94
+ return JSON.parse(source);
95
+ }
96
+ catch {
97
+ throw new PackageManagerError('invalid_manifest', 'package.json is not valid JSON');
98
+ }
99
+ };
100
+ const readPnpmWorkspace = (source) => {
101
+ try {
102
+ return (0, js_yaml_1.load)(source, { schema: js_yaml_1.JSON_SCHEMA });
103
+ }
104
+ catch {
105
+ throw new PackageManagerError('invalid_workspace', 'pnpm-workspace.yaml is not valid YAML');
106
+ }
83
107
  };
84
108
  const packagePathsFor = async (root, manifest) => {
85
109
  const pnpmSource = await (0, exports.readProjectFile)(path_1.default.join(root, 'pnpm-workspace.yaml'));
86
- const pnpmConfig = pnpmSource === null
87
- ? null
88
- : (0, js_yaml_1.load)(pnpmSource, { schema: js_yaml_1.JSON_SCHEMA });
110
+ const pnpmConfig = pnpmSource === null ? null : readPnpmWorkspace(pnpmSource);
89
111
  const patterns = pnpmConfig?.packages ??
90
112
  (Array.isArray(manifest.workspaces)
91
113
  ? manifest.workspaces
@@ -93,7 +115,7 @@ const packagePathsFor = async (root, manifest) => {
93
115
  [];
94
116
  if (!Array.isArray(patterns) ||
95
117
  patterns.some((pattern) => typeof pattern !== 'string')) {
96
- throw new Error('Workspace packages must be an array of directory patterns');
118
+ throw new PackageManagerError('invalid_workspace', 'Workspace packages must be an array of directory patterns');
97
119
  }
98
120
  const included = patterns.filter((pattern) => !pattern.startsWith('!'));
99
121
  const excluded = patterns
@@ -107,7 +129,7 @@ const packagePathsFor = async (root, manifest) => {
107
129
  });
108
130
  const members = await Promise.all(files.map((file) => promises_1.default.realpath(path_1.default.dirname(file))));
109
131
  if (members.some((member) => !(0, pathContainment_1.isPathWithinRoot)(root, member))) {
110
- throw new Error('A workspace package resolves outside the preview workspace');
132
+ throw new PackageManagerError('path_outside_workspace', 'A workspace package resolves outside the preview workspace');
111
133
  }
112
134
  return [...new Set([root, ...members.sort()])];
113
135
  };
@@ -115,7 +137,7 @@ const resolveProjectPackageManager = async (options) => {
115
137
  const cwd = await promises_1.default.realpath(options.cwd);
116
138
  const boundary = await promises_1.default.realpath(options.workspaceRoot);
117
139
  if (!(0, pathContainment_1.isPathWithinRoot)(boundary, cwd)) {
118
- throw new Error('Dependency preparation directory is outside the preview workspace');
140
+ throw new PackageManagerError('path_outside_workspace', 'Dependency preparation directory is outside the preview workspace');
119
141
  }
120
142
  let rootPath = cwd;
121
143
  let manifest = await readManifest(cwd);
@@ -139,7 +161,7 @@ const resolveProjectPackageManager = async (options) => {
139
161
  const declared = manifest.packageManager;
140
162
  const declaration = declared ? parsePackageManagerDeclaration(declared) : null;
141
163
  if (declared && !declaration) {
142
- throw new Error(`Unsupported packageManager declaration: ${declared}. Preview preparation supports pinned npm, Yarn, and pnpm versions.`);
164
+ throw new PackageManagerError('invalid_package_manager_field', `Unsupported packageManager declaration: ${declared}. Preview preparation supports pinned npm, Yarn, and pnpm versions.`);
143
165
  }
144
166
  const managersWithLockfiles = [];
145
167
  for (const name of Object.keys(exports.LOCKFILES)) {
@@ -164,7 +186,7 @@ const resolveProjectPackageManager = async (options) => {
164
186
  !manifest.devEngines?.packageManager &&
165
187
  managersWithLockfiles.length > 1 &&
166
188
  !selectedManager) {
167
- throw new Error('Multiple package manager lockfiles found. Set package.json packageManager to select the project tool.');
189
+ throw new PackageManagerError('multiple_lockfiles', 'Multiple package manager lockfiles found. Set package.json packageManager to select the project tool.');
168
190
  }
169
191
  const detected = selectedManager
170
192
  ? null
@@ -175,7 +197,7 @@ const resolveProjectPackageManager = async (options) => {
175
197
  });
176
198
  const name = selectedManager ?? detected?.name ?? 'npm';
177
199
  if (name !== 'npm' && name !== 'yarn' && name !== 'pnpm') {
178
- throw new Error(`Preview dependency preparation does not support ${name}`);
200
+ throw new PackageManagerError('unsupported_package_manager', `Preview dependency preparation does not support ${name}`);
179
201
  }
180
202
  let agent = selectedManager ?? detected?.agent ?? name;
181
203
  if (name === 'yarn' &&