rivet-design 0.26.1 → 0.26.2

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 (93) hide show
  1. package/bin/rivet.js +13 -0
  2. package/dist/agent-variants/WorkerExecutorService.d.ts +0 -2
  3. package/dist/agent-variants/WorkerExecutorService.js +0 -18
  4. package/dist/agent-variants/WorktreeOrchestrator.testHelpers.js +0 -8
  5. package/dist/agent-variants/contracts.d.ts +897 -4764
  6. package/dist/agent-variants/contracts.js +1 -121
  7. package/dist/agent-variants/index.d.ts +1 -1
  8. package/dist/agent-variants/variantsTelemetry.d.ts +0 -8
  9. package/dist/agent-variants/workItemInput.d.ts +278 -278
  10. package/dist/cli/commands/contextRequest.js +1 -1
  11. package/dist/cli/commands/guidanceReferences.d.ts +2 -2
  12. package/dist/cli/commands/guidanceVerifierPackage.d.ts +2 -2
  13. package/dist/cli/editorSession.d.ts +1 -13
  14. package/dist/cli/runtimeInterruption.d.ts +2 -16
  15. package/dist/config/pluginMetrics.js +0 -1
  16. package/dist/hosts/workerDefaults.d.ts +0 -11
  17. package/dist/hosts/workerDefaults.js +1 -30
  18. package/dist/index-core.d.ts +0 -1
  19. package/dist/index.js +1 -1
  20. package/dist/install/automaticCliUpdate.d.ts +1 -0
  21. package/dist/install/automaticCliUpdate.js +32 -22
  22. package/dist/install/channelCli.d.ts +1 -1
  23. package/dist/install/channelCli.js +11 -6
  24. package/dist/install/channelManager.d.ts +5 -2
  25. package/dist/install/globalBootstrap.d.ts +5 -3
  26. package/dist/install/globalBootstrap.js +21 -9
  27. package/dist/install/npmCommand.d.ts +15 -0
  28. package/dist/install/npmCommand.js +59 -0
  29. package/dist/routes/agentVariants.js +3 -14
  30. package/dist/routes/library/browserAccess.js +6 -2
  31. package/dist/routes/library/guidance.js +3 -1
  32. package/dist/routes/library/middleware.js +4 -4
  33. package/dist/routes/library/navigation.js +3 -1
  34. package/dist/routes/library/profiles.js +5 -5
  35. package/dist/routes/library/projects.js +17 -7
  36. package/dist/routes/library/referenceOnboarding.js +4 -2
  37. package/dist/routes/library/schemas.d.ts +2 -15
  38. package/dist/routes/telemetry.js +1 -1
  39. package/dist/routes/variantRequestSchema.d.ts +4 -4
  40. package/dist/routes/variantRequestSchema.js +7 -2
  41. package/dist/services/AuthService.d.ts +3 -56
  42. package/dist/services/AuthService.js +0 -28
  43. package/dist/services/ConfigManager.d.ts +0 -2
  44. package/dist/services/ConfigManager.js +0 -14
  45. package/dist/services/HubDiscovery.d.ts +1 -9
  46. package/dist/services/IntegrationsClient.d.ts +16 -16
  47. package/dist/services/MCPOnboardingTelemetry.d.ts +0 -14
  48. package/dist/services/MCPOnboardingTelemetry.js +0 -62
  49. package/dist/services/ProjectRegistry.d.ts +5 -24
  50. package/dist/services/TelemetryService.d.ts +1 -62
  51. package/dist/services/TelemetryService.js +0 -113
  52. package/dist/services/TreeStore.d.ts +0 -2
  53. package/dist/services/TreeStore.js +0 -24
  54. package/dist/services/profiles/DesignProfiles.d.ts +180 -125
  55. package/dist/services/profiles/ProfilePlanning.d.ts +38 -38
  56. package/dist/services/profiles/ReferenceReader.d.ts +14 -14
  57. package/dist/services/profiles/modelContract.js +4 -4
  58. package/dist/storage/library/ProjectPreviewCache.d.ts +1 -13
  59. package/dist/storage/profiles/ProfilePlans.d.ts +137 -137
  60. package/dist/storage/profiles/ProfileRecords.d.ts +62 -37
  61. package/dist/storage/profiles/planSchema.d.ts +40 -40
  62. package/dist/storage/profiles/schema.d.ts +16 -16
  63. package/dist/types/api-responses.d.ts +174 -0
  64. package/dist/types/api-responses.js +108 -0
  65. package/dist/types/cosmos-profile.d.ts +17 -105
  66. package/dist/types/cosmos.d.ts +48 -266
  67. package/dist/types/design-library.d.ts +230 -61
  68. package/dist/types/design-library.js +38 -1
  69. package/dist/types/design-profile.d.ts +220 -529
  70. package/dist/types/design-profile.js +5 -1
  71. package/dist/types/guidance-references.d.ts +68 -316
  72. package/dist/types/guidance-verifier.d.ts +65 -558
  73. package/dist/types/guidance-verifier.js +1 -1
  74. package/dist/types/guidance.d.ts +182 -1643
  75. package/dist/types/guidance.js +4 -1
  76. package/dist/types/project-library.d.ts +60 -30
  77. package/dist/types/project-library.js +32 -1
  78. package/dist/types/reference-connectors.d.ts +38 -162
  79. package/dist/types/reference-onboarding.d.ts +144 -878
  80. package/dist/types/reference-pages.d.ts +27 -139
  81. package/dist/types/x-bookmarks.d.ts +40 -296
  82. package/dist/utils/displayLocale.d.ts +0 -1
  83. package/dist/utils/displayLocale.js +1 -3
  84. package/package.json +4 -4
  85. package/src/ui/dist/assets/LibraryEntry-92R_T-Xa.js +37 -0
  86. package/src/ui/dist/assets/main-D0UmAaUe.css +1 -0
  87. package/src/ui/dist/assets/main-DgEfJvYu.js +497 -0
  88. package/src/ui/dist/index.html +2 -2
  89. package/dist/types/change-types.d.ts +0 -66
  90. package/dist/types/change-types.js +0 -3
  91. package/src/ui/dist/assets/LibraryEntry-Cr4GFYXW.js +0 -37
  92. package/src/ui/dist/assets/main-W3oTuTTl.css +0 -1
  93. package/src/ui/dist/assets/main-tPO1OCpZ.js +0 -439
@@ -133,7 +133,7 @@ const contextRequest = async (args) => {
133
133
  },
134
134
  ]);
135
135
  request.verificationTarget = zod_1.z
136
- .record(zod_1.z.unknown())
136
+ .record(zod_1.z.string(), zod_1.z.unknown())
137
137
  .parse(JSON.parse(await (0, guidanceReferences_1.readGuidanceText)(path_1.default.resolve(inputFile))));
138
138
  request.endpoint += '/verifier';
139
139
  break;
@@ -1,11 +1,11 @@
1
1
  export declare const readGuidanceText: (file: string) => Promise<string>;
2
2
  export declare const guidanceReferences: (manifestPath: string) => Promise<({
3
- path: string;
4
3
  kind: "directory";
4
+ path: string;
5
5
  intent: string;
6
6
  } | {
7
- url: string;
8
7
  kind: "url" | "repository";
8
+ url: string;
9
9
  intent: string;
10
10
  revision?: string | undefined;
11
11
  files?: {
@@ -1,9 +1,9 @@
1
1
  export declare const guidanceVerifierPackage: (manifestPath: string) => Promise<{
2
+ runtime: "node";
3
+ entrypoint: string;
2
4
  files: {
3
5
  name: string;
4
6
  content: string;
5
7
  }[];
6
- runtime: "node";
7
- entrypoint: string;
8
8
  }>;
9
9
  //# sourceMappingURL=guidanceVerifierPackage.d.ts.map
@@ -5,19 +5,7 @@ declare const EditorSessionSchema: z.ZodObject<{
5
5
  projectPath: z.ZodString;
6
6
  startedAt: z.ZodString;
7
7
  token: z.ZodString;
8
- }, "strip", z.ZodTypeAny, {
9
- port: number;
10
- token: string;
11
- pid: number;
12
- projectPath: string;
13
- startedAt: string;
14
- }, {
15
- port: number;
16
- token: string;
17
- pid: number;
18
- projectPath: string;
19
- startedAt: string;
20
- }>;
8
+ }, z.core.$strip>;
21
9
  type EditorOwner = Omit<z.infer<typeof EditorSessionSchema>, 'token'>;
22
10
  export declare const createEditorAccessToken: () => string;
23
11
  export declare const writeEditorSession: (session: z.infer<typeof EditorSessionSchema>) => void;
@@ -5,23 +5,9 @@ declare const interruptionSchema: z.ZodObject<{
5
5
  serverVersion: z.ZodNullable<z.ZodString>;
6
6
  clientVersion: z.ZodString;
7
7
  createdAt: z.ZodString;
8
- workIds: z.ZodArray<z.ZodString, "many">;
8
+ workIds: z.ZodArray<z.ZodString>;
9
9
  message: z.ZodString;
10
- }, "strip", z.ZodTypeAny, {
11
- message: string;
12
- clientVersion: string;
13
- createdAt: string;
14
- receiptPath: string;
15
- serverVersion: string | null;
16
- workIds: string[];
17
- }, {
18
- message: string;
19
- clientVersion: string;
20
- createdAt: string;
21
- receiptPath: string;
22
- serverVersion: string | null;
23
- workIds: string[];
24
- }>;
10
+ }, z.core.$strip>;
25
11
  export type RuntimeInterruption = z.infer<typeof interruptionSchema>;
26
12
  export declare const recordRuntimeInterruption: ({ attached, snapshot, }: {
27
13
  attached: AttachedServer;
@@ -205,7 +205,6 @@ const PRODUCT_EVENTS = new Set([
205
205
  'visual_editor_reference_connection_failed',
206
206
  'agent_variants.request_started',
207
207
  'agent_variants.request_accepted',
208
- 'agent_variants.request_rejected',
209
208
  'agent_variants.refinement_requested',
210
209
  'agent_variants.refinement_completed',
211
210
  'agent_variants.refinement_failed',
@@ -5,22 +5,12 @@ type WorkerAgentDefinition = {
5
5
  filename: string;
6
6
  content: string;
7
7
  };
8
- export type WorkerHostId = 'claude' | 'codex' | 'cursor' | 'unknown';
9
8
  export type WorkerEffortLevel = 'low' | 'medium' | 'high';
10
9
  export declare const FIDELITY_WORKER_TIERS: Record<WorkerFidelity, {
11
10
  model: string;
12
11
  effort: WorkerEffortLevel;
13
12
  }>;
14
13
  export declare const DEFAULT_WORKER_FIDELITY: WorkerFidelity;
15
- export type HostWorkerProfile = {
16
- id: WorkerHostId;
17
- binding: 'agent_definition' | 'none';
18
- agentType?: string;
19
- defaults?: {
20
- model: string;
21
- effort: WorkerEffortLevel;
22
- };
23
- };
24
14
  export declare const RIVET_WORKER_AGENT_TYPE = "rivet-worker";
25
15
  export declare const RIVET_WORKER_AGENT_TYPES: Record<WorkerFidelity, string>;
26
16
  export declare const RIVET_WORKER_DEFAULTS: {
@@ -31,7 +21,6 @@ export declare const RIVET_WORKER_REFERENCE_CREATE_DEFAULTS: {
31
21
  model: string;
32
22
  effort: WorkerEffortLevel;
33
23
  };
34
- export declare const workerProfileFor: (callerAgent?: string, fidelity?: WorkerFidelity) => HostWorkerProfile;
35
24
  export declare const RIVET_WORKER_AGENT_VERSION = 3;
36
25
  export declare const RIVET_WORKER_AGENT_DEFINITIONS: Record<WorkerFidelity, WorkerAgentDefinition>;
37
26
  export declare const RIVET_WORKER_AGENT_FILENAME: string;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RIVET_WORKER_AGENT_FILENAME = exports.RIVET_WORKER_AGENT_DEFINITIONS = exports.RIVET_WORKER_AGENT_VERSION = exports.workerProfileFor = exports.RIVET_WORKER_REFERENCE_CREATE_DEFAULTS = exports.RIVET_WORKER_DEFAULTS = exports.RIVET_WORKER_AGENT_TYPES = exports.RIVET_WORKER_AGENT_TYPE = exports.DEFAULT_WORKER_FIDELITY = exports.FIDELITY_WORKER_TIERS = void 0;
4
- const pluginContext_1 = require("./pluginContext");
3
+ exports.RIVET_WORKER_AGENT_FILENAME = exports.RIVET_WORKER_AGENT_DEFINITIONS = exports.RIVET_WORKER_AGENT_VERSION = exports.RIVET_WORKER_REFERENCE_CREATE_DEFAULTS = exports.RIVET_WORKER_DEFAULTS = exports.RIVET_WORKER_AGENT_TYPES = exports.RIVET_WORKER_AGENT_TYPE = exports.DEFAULT_WORKER_FIDELITY = exports.FIDELITY_WORKER_TIERS = void 0;
5
4
  exports.FIDELITY_WORKER_TIERS = {
6
5
  low: { model: 'claude-opus-4-8', effort: 'low' },
7
6
  medium: { model: 'claude-opus-4-8', effort: 'medium' },
@@ -16,34 +15,6 @@ exports.RIVET_WORKER_AGENT_TYPES = {
16
15
  };
17
16
  exports.RIVET_WORKER_DEFAULTS = exports.FIDELITY_WORKER_TIERS[exports.DEFAULT_WORKER_FIDELITY];
18
17
  exports.RIVET_WORKER_REFERENCE_CREATE_DEFAULTS = exports.FIDELITY_WORKER_TIERS[exports.DEFAULT_WORKER_FIDELITY];
19
- const HOST_WORKER_PROFILES = {
20
- claude: {
21
- id: 'claude',
22
- binding: 'agent_definition',
23
- agentType: exports.RIVET_WORKER_AGENT_TYPE,
24
- defaults: exports.RIVET_WORKER_DEFAULTS,
25
- },
26
- codex: { id: 'codex', binding: 'none' },
27
- cursor: { id: 'cursor', binding: 'none' },
28
- unknown: { id: 'unknown', binding: 'none' },
29
- };
30
- const workerProfileFor = (callerAgent, fidelity = exports.DEFAULT_WORKER_FIDELITY) => {
31
- const key = (callerAgent ?? '').trim().toLowerCase();
32
- if (key === 'claude') {
33
- const pluginName = (0, pluginContext_1.getPluginName)();
34
- const agentType = exports.RIVET_WORKER_AGENT_TYPES[fidelity];
35
- return {
36
- ...HOST_WORKER_PROFILES.claude,
37
- agentType: pluginName ? `${pluginName}:${agentType}` : agentType,
38
- defaults: exports.FIDELITY_WORKER_TIERS[fidelity],
39
- };
40
- }
41
- if (key === 'codex' || key === 'cursor') {
42
- return HOST_WORKER_PROFILES[key];
43
- }
44
- return HOST_WORKER_PROFILES.unknown;
45
- };
46
- exports.workerProfileFor = workerProfileFor;
47
18
  exports.RIVET_WORKER_AGENT_VERSION = 3;
48
19
  const workerAgentContentFor = (fidelity) => {
49
20
  const agentType = exports.RIVET_WORKER_AGENT_TYPES[fidelity];
@@ -1,4 +1,3 @@
1
1
  export { ProjectDetectionService } from './services/ProjectDetectionService';
2
2
  export { createLogger, setLogLevel, redirectLogsToStderr, } from './utils/logger';
3
- export type { ChangeRecord, } from './types/change-types';
4
3
  //# sourceMappingURL=index-core.d.ts.map
package/dist/index.js CHANGED
@@ -861,7 +861,7 @@ const handleInstall = async (installArgs) => {
861
861
  (0, exports.rememberInstallRef)(installArgs, selection.targetIds.join(','));
862
862
  if (installRef)
863
863
  await reportInstallRefActivations();
864
- const bootstrap = (0, globalBootstrap_1.bootstrapGlobalInstall)(installArgs);
864
+ const bootstrap = await (0, globalBootstrap_1.bootstrapGlobalInstall)(installArgs);
865
865
  if (bootstrap.action === 'reexeced') {
866
866
  process.exit(bootstrap.exitCode);
867
867
  }
@@ -34,6 +34,7 @@ export type AutomaticCliUpdateOptions = {
34
34
  currentVersion: string;
35
35
  env?: NodeJS.ProcessEnv;
36
36
  homeDirectory?: string;
37
+ installTimeoutMs?: number;
37
38
  lockWaitTimeoutMs?: number;
38
39
  now?: () => number;
39
40
  packageRoot: string;
@@ -9,10 +9,11 @@ const fs_1 = __importDefault(require("fs"));
9
9
  const os_1 = __importDefault(require("os"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const serverVersion_1 = require("../cli/serverVersion");
12
+ const npmCommand_1 = require("./npmCommand");
13
+ const OperatingSystemServices_1 = require("../services/OperatingSystemServices");
12
14
  const errnoCode_1 = require("../utils/errnoCode");
13
15
  const writeFileAtomic_1 = require("../utils/writeFileAtomic");
14
16
  const pluginContext_1 = require("../hosts/pluginContext");
15
- const packageManagerProcess_1 = require("../services/packageManagerProcess");
16
17
  const subprocessEnvironment_1 = require("../utils/subprocessEnvironment");
17
18
  const AUTOMATIC_UPDATE_STATE_SCHEMA_VERSION = 1;
18
19
  const AUTOMATIC_UPDATE_STATE_FILENAME = 'automatic-cli-update.json';
@@ -102,8 +103,7 @@ const persistUpdateState = (statePath, state) => {
102
103
  try {
103
104
  writeUpdateState(statePath, state);
104
105
  }
105
- catch {
106
- }
106
+ catch { }
107
107
  };
108
108
  const normalizedPath = (filePath) => {
109
109
  try {
@@ -122,10 +122,11 @@ const isExcludedExecution = (options) => {
122
122
  pathSegments.includes('_npx') ||
123
123
  (pathSegments.includes('.rivet') && pathSegments.includes('channels')));
124
124
  };
125
- const resolveGlobalPackageRoot = (env) => {
126
- const result = (0, packageManagerProcess_1.spawnProcessSync)({ packageManager: 'npm', args: ['root', '-g'] }, {
125
+ const resolveGlobalPackageRoot = async (env) => {
126
+ const result = await (0, npmCommand_1.runNpm)({
127
+ args: ['root', '-g'],
127
128
  env: (0, subprocessEnvironment_1.subprocessEnvironment)('packageManager', env),
128
- timeout: NPM_ROOT_TIMEOUT_MS,
129
+ timeoutMs: NPM_ROOT_TIMEOUT_MS,
129
130
  });
130
131
  if (result.error || result.status !== 0 || !result.stdout.trim()) {
131
132
  return { failure: 'global_root_unavailable' };
@@ -221,6 +222,11 @@ const isProcessRunning = (pid) => {
221
222
  return (0, errnoCode_1.errnoCode)(error) !== 'ESRCH';
222
223
  }
223
224
  };
225
+ const readLockOwners = (lockPath) => fs_1.default
226
+ .readFileSync(lockPath, 'utf8')
227
+ .split('\n')
228
+ .map((line) => Number.parseInt(line, 10))
229
+ .filter((owner) => !Number.isNaN(owner));
224
230
  const acquireUpdateLock = (lockPath) => {
225
231
  fs_1.default.mkdirSync(path_1.default.dirname(lockPath), { recursive: true });
226
232
  const tryAcquire = () => {
@@ -246,10 +252,10 @@ const acquireUpdateLock = (lockPath) => {
246
252
  let isAcquired = tryAcquire();
247
253
  if (!isAcquired) {
248
254
  try {
249
- const owner = Number.parseInt(fs_1.default.readFileSync(lockPath, 'utf8'), 10);
250
- if (!Number.isNaN(owner) && isProcessRunning(owner))
255
+ const owners = readLockOwners(lockPath);
256
+ if (owners.some(isProcessRunning))
251
257
  return null;
252
- if (Number.isNaN(owner)) {
258
+ if (owners.length === 0) {
253
259
  const lockAge = Date.now() - fs_1.default.statSync(lockPath).mtimeMs;
254
260
  if (lockAge < LOCK_INITIALIZATION_GRACE_MS)
255
261
  return null;
@@ -263,21 +269,24 @@ const acquireUpdateLock = (lockPath) => {
263
269
  }
264
270
  if (!isAcquired)
265
271
  return null;
266
- return () => fs_1.default.rmSync(lockPath, { force: true });
272
+ return {
273
+ addOwner: (processId) => fs_1.default.appendFileSync(lockPath, `\n${processId}`, 'utf8'),
274
+ release: () => fs_1.default.rmSync(lockPath, { force: true }),
275
+ };
267
276
  };
268
277
  const waitForUpdateLock = async (lockPath, timeoutMs) => {
269
278
  const deadline = Date.now() + timeoutMs;
270
- let releaseLock = acquireUpdateLock(lockPath);
271
- while (releaseLock === null) {
279
+ let lock = acquireUpdateLock(lockPath);
280
+ while (lock === null) {
272
281
  const remainingMs = deadline - Date.now();
273
282
  if (remainingMs <= 0)
274
283
  return null;
275
284
  await new Promise((resolve) => {
276
285
  setTimeout(resolve, Math.min(LOCK_POLL_INTERVAL_MS, remainingMs));
277
286
  });
278
- releaseLock = acquireUpdateLock(lockPath);
287
+ lock = acquireUpdateLock(lockPath);
279
288
  }
280
- return releaseLock;
289
+ return lock;
281
290
  };
282
291
  const shouldUseCachedState = (options) => {
283
292
  if (options.isForced || !options.state)
@@ -306,7 +315,7 @@ const checkAndInstallCliUpdate = async (options) => {
306
315
  const isKnownGlobalPackage = state !== null &&
307
316
  normalizedPath(state.packageRoot) === normalizedPath(options.packageRoot);
308
317
  if (!isKnownGlobalPackage) {
309
- const globalPackage = resolveGlobalPackageRoot(env);
318
+ const globalPackage = await resolveGlobalPackageRoot(env);
310
319
  if (!globalPackage.packageRoot) {
311
320
  return failedResult({
312
321
  currentVersion: options.currentVersion,
@@ -375,8 +384,8 @@ const checkAndInstallCliUpdate = async (options) => {
375
384
  return { action: 'continue', checkedVersion: latest.version };
376
385
  }
377
386
  const lockPath = `${statePath}.lock`;
378
- const releaseLock = await waitForUpdateLock(lockPath, options.lockWaitTimeoutMs ?? LOCK_WAIT_TIMEOUT_MS);
379
- if (releaseLock === null) {
387
+ const lock = await waitForUpdateLock(lockPath, options.lockWaitTimeoutMs ?? LOCK_WAIT_TIMEOUT_MS);
388
+ if (lock === null) {
380
389
  return activeUpdateResult({
381
390
  currentVersion: options.currentVersion,
382
391
  durationMs: now() - startedAt,
@@ -403,12 +412,13 @@ const checkAndInstallCliUpdate = async (options) => {
403
412
  };
404
413
  }
405
414
  const packageSpec = env.RIVET_AUTO_UPDATE_PACKAGE_SPEC ?? RIVET_LATEST_PACKAGE_SPEC;
406
- const install = (0, packageManagerProcess_1.spawnProcessSync)({
407
- packageManager: 'npm',
415
+ const install = await (0, npmCommand_1.runNpm)({
408
416
  args: ['install', '-g', packageSpec, '--no-audit', '--no-fund'],
409
- }, {
410
417
  env: (0, subprocessEnvironment_1.subprocessEnvironment)('packageManager', env),
411
- timeout: NPM_INSTALL_TIMEOUT_MS,
418
+ onStarted: lock.addOwner,
419
+ timeoutMs: OperatingSystemServices_1.selectedOperatingSystemServices.operatingSystemFamily === 'windows'
420
+ ? undefined
421
+ : (options.installTimeoutMs ?? NPM_INSTALL_TIMEOUT_MS),
412
422
  });
413
423
  if (install.error || install.status !== 0) {
414
424
  const failure = failedResult({
@@ -457,7 +467,7 @@ const checkAndInstallCliUpdate = async (options) => {
457
467
  };
458
468
  }
459
469
  finally {
460
- releaseLock();
470
+ lock.release();
461
471
  }
462
472
  };
463
473
  exports.checkAndInstallCliUpdate = checkAndInstallCliUpdate;
@@ -1,2 +1,2 @@
1
- export declare const runChannelCli: (args: string[]) => number;
1
+ export declare const runChannelCli: (args: string[]) => Promise<number>;
2
2
  //# sourceMappingURL=channelCli.d.ts.map
@@ -9,8 +9,8 @@ const os_1 = __importDefault(require("os"));
9
9
  const subprocessEnvironment_1 = require("../utils/subprocessEnvironment");
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const channelManager_1 = require("./channelManager");
12
+ const npmCommand_1 = require("./npmCommand");
12
13
  const errorMessage_1 = require("../utils/errorMessage");
13
- const packageManagerProcess_1 = require("../services/packageManagerProcess");
14
14
  const CHANNEL_USAGE = `Rivet channel QA
15
15
 
16
16
  Usage:
@@ -22,8 +22,11 @@ Usage:
22
22
 
23
23
  Hosts: claude, claude-desktop, cursor, codex, all
24
24
  `;
25
- const resolveGlobalPrefix = () => {
26
- const result = (0, packageManagerProcess_1.spawnProcessSync)({ packageManager: 'npm', args: ['prefix', '--global'] }, { env: (0, subprocessEnvironment_1.subprocessEnvironment)('packageManager') });
25
+ const resolveGlobalPrefix = async () => {
26
+ const result = await (0, npmCommand_1.runNpm)({
27
+ args: ['prefix', '--global'],
28
+ env: (0, subprocessEnvironment_1.subprocessEnvironment)('packageManager'),
29
+ });
27
30
  if (result.error || result.status !== 0 || !result.stdout.trim()) {
28
31
  throw new Error('Could not resolve the global npm prefix');
29
32
  }
@@ -37,11 +40,11 @@ const printStatus = (channels) => {
37
40
  console.log(`Local: ${status.local.isAvailable ? (status.local.version ?? 'unknown version') : 'not built'} (${status.local.revision ?? 'unknown revision'})`);
38
41
  console.log(`Production: ${status.production.isAvailable ? (status.production.version ?? 'unknown version') : 'not installed'}`);
39
42
  };
40
- const runChannelCli = (args) => {
43
+ const runChannelCli = async (args) => {
41
44
  try {
42
45
  const repoRoot = path_1.default.resolve(__dirname, '..', '..');
43
46
  const channels = new channelManager_1.RivetChannels({
44
- globalPrefix: resolveGlobalPrefix(),
47
+ globalPrefix: await resolveGlobalPrefix(),
45
48
  homeDirectory: os_1.default.homedir(),
46
49
  repoRoot,
47
50
  });
@@ -92,6 +95,8 @@ const runChannelCli = (args) => {
92
95
  };
93
96
  exports.runChannelCli = runChannelCli;
94
97
  if (require.main === module) {
95
- process.exitCode = (0, exports.runChannelCli)(process.argv.slice(2));
98
+ void (0, exports.runChannelCli)(process.argv.slice(2)).then((exitCode) => {
99
+ process.exitCode = exitCode;
100
+ });
96
101
  }
97
102
  //# sourceMappingURL=channelCli.js.map
@@ -1,8 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { type ProcessCommand } from '../services/packageManagerProcess';
3
- declare const RivetChannelSchema: z.ZodEnum<["local", "production"]>;
3
+ declare const RivetChannelSchema: z.ZodEnum<{
4
+ production: "production";
5
+ local: "local";
6
+ }>;
4
7
  export type RivetChannel = z.infer<typeof RivetChannelSchema>;
5
- export type ChannelCommandOptions = {
8
+ type ChannelCommandOptions = {
6
9
  cwd?: string;
7
10
  env?: NodeJS.ProcessEnv;
8
11
  };
@@ -1,10 +1,11 @@
1
1
  import { type ProcessCommand } from '../services/packageManagerProcess';
2
2
  export type BootstrapExec = (command: ProcessCommand, options: {
3
+ env: NodeJS.ProcessEnv;
3
4
  stdio: 'inherit' | 'pipe';
4
- }) => {
5
+ }) => Promise<{
5
6
  status: number | null;
6
7
  stdout?: string;
7
- };
8
+ }>;
8
9
  export type BootstrapResult = {
9
10
  action: 'not_needed';
10
11
  } | {
@@ -17,7 +18,8 @@ export type BootstrapResult = {
17
18
  export declare const bootstrapGlobalInstall: (installArgs: string[], options?: {
18
19
  exec?: BootstrapExec;
19
20
  binPath?: string;
21
+ env?: NodeJS.ProcessEnv;
20
22
  version?: string;
21
- }) => BootstrapResult;
23
+ }) => Promise<BootstrapResult>;
22
24
  export declare const bootstrapFailureAdvisory: (reason: string) => string;
23
25
  //# sourceMappingURL=globalBootstrap.d.ts.map
@@ -8,36 +8,48 @@ const fs_1 = __importDefault(require("fs"));
8
8
  const subprocessEnvironment_1 = require("../utils/subprocessEnvironment");
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const mcpRegistration_1 = require("./mcpRegistration");
11
+ const npmCommand_1 = require("./npmCommand");
11
12
  const telemetry_1 = require("../config/telemetry");
12
13
  const errorMessage_1 = require("../utils/errorMessage");
13
14
  const packageManagerProcess_1 = require("../services/packageManagerProcess");
14
- const defaultExec = (command, options) => {
15
+ const defaultExec = async (command, { env, stdio }) => {
16
+ if ('packageManager' in command && command.packageManager === 'npm') {
17
+ const result = await (0, npmCommand_1.runNpm)({
18
+ args: command.args,
19
+ env: (0, subprocessEnvironment_1.subprocessEnvironment)('packageManager', env),
20
+ stdio,
21
+ });
22
+ if (result.error)
23
+ throw result.error;
24
+ return { status: result.status, stdout: result.stdout };
25
+ }
15
26
  const result = (0, packageManagerProcess_1.spawnProcessSync)(command, {
16
- ...options,
17
- env: (0, subprocessEnvironment_1.subprocessEnvironment)('packageManager' in command ? 'packageManager' : 'rivetRuntime'),
27
+ stdio,
28
+ env: (0, subprocessEnvironment_1.subprocessEnvironment)('packageManager' in command ? 'packageManager' : 'rivetRuntime', env),
18
29
  });
19
30
  if (result.error)
20
31
  throw result.error;
21
32
  return { status: result.status, stdout: result.stdout ?? undefined };
22
33
  };
23
- const bootstrapGlobalInstall = (installArgs, options) => {
34
+ const bootstrapGlobalInstall = async (installArgs, options) => {
24
35
  const exec = options?.exec ?? defaultExec;
36
+ const env = options?.env ?? process.env;
25
37
  if (!(0, mcpRegistration_1.isEphemeralNpxInstall)(options?.binPath)) {
26
38
  return { action: 'not_needed' };
27
39
  }
28
- const spec = process.env.RIVET_GLOBAL_INSTALL_SPEC ??
40
+ const spec = env.RIVET_GLOBAL_INSTALL_SPEC ??
29
41
  `rivet-design@${options?.version ?? telemetry_1.RIVET_VERSION}`;
30
42
  console.log(`Rivet is running from npx's temporary cache — installing ${spec} globally first so ` +
31
43
  'MCP registrations and `rivet` commands keep working...\n');
32
44
  try {
33
- const installResult = exec({ packageManager: 'npm', args: ['install', '-g', spec] }, { stdio: 'inherit' });
45
+ const installResult = await exec({ packageManager: 'npm', args: ['install', '-g', spec] }, { env, stdio: 'inherit' });
34
46
  if (installResult.status !== 0) {
35
47
  return {
36
48
  action: 'failed',
37
49
  reason: `npm install -g exited ${installResult.status}`,
38
50
  };
39
51
  }
40
- const rootResult = exec({ packageManager: 'npm', args: ['root', '-g'] }, { stdio: 'pipe' });
52
+ const rootResult = await exec({ packageManager: 'npm', args: ['root', '-g'] }, { env, stdio: 'pipe' });
41
53
  const globalRoot = String(rootResult.stdout ?? '').trim();
42
54
  const globalBin = path_1.default.join(globalRoot, 'rivet-design', 'bin', 'rivet.js');
43
55
  if (!globalRoot || !fs_1.default.existsSync(globalBin)) {
@@ -46,10 +58,10 @@ const bootstrapGlobalInstall = (installArgs, options) => {
46
58
  reason: `global install not found at ${globalBin || 'npm root -g'}`,
47
59
  };
48
60
  }
49
- const rerun = exec({
61
+ const rerun = await exec({
50
62
  executable: process.execPath,
51
63
  args: [globalBin, 'install', ...installArgs],
52
- }, { stdio: 'inherit' });
64
+ }, { env, stdio: 'inherit' });
53
65
  return { action: 'reexeced', exitCode: rerun.status ?? 0 };
54
66
  }
55
67
  catch (error) {
@@ -0,0 +1,15 @@
1
+ export type NpmCommandResult = {
2
+ error?: Error;
3
+ isTimedOut: boolean;
4
+ status: number | null;
5
+ stderr: string;
6
+ stdout: string;
7
+ };
8
+ export declare const runNpm: ({ args, env, onStarted, stdio, timeoutMs, }: {
9
+ args: string[];
10
+ env: NodeJS.ProcessEnv;
11
+ onStarted?: (processId: number) => void;
12
+ stdio?: "inherit" | "pipe";
13
+ timeoutMs?: number;
14
+ }) => Promise<NpmCommandResult>;
15
+ //# sourceMappingURL=npmCommand.d.ts.map
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runNpm = void 0;
4
+ const OperatingSystemServices_1 = require("../services/OperatingSystemServices");
5
+ const packageManagerProcess_1 = require("../services/packageManagerProcess");
6
+ const runNpm = ({ args, env, onStarted, stdio = 'pipe', timeoutMs, }) => new Promise((resolve) => {
7
+ const { operatingSystemFamily, projectProcesses } = OperatingSystemServices_1.selectedOperatingSystemServices;
8
+ const isProcessGroupLeader = timeoutMs !== undefined && operatingSystemFamily === 'posix';
9
+ let stdout = '';
10
+ let stderr = '';
11
+ let isTimedOut = false;
12
+ let spawnError;
13
+ const child = (0, packageManagerProcess_1.spawnProcess)({ packageManager: 'npm', args }, {
14
+ detached: isProcessGroupLeader,
15
+ env,
16
+ stdio: stdio === 'inherit' ? 'inherit' : ['ignore', 'pipe', 'pipe'],
17
+ });
18
+ if (child.pid !== undefined)
19
+ onStarted?.(child.pid);
20
+ child.stdout?.setEncoding('utf8');
21
+ child.stdout?.on('data', (chunk) => {
22
+ stdout += chunk;
23
+ });
24
+ child.stderr?.setEncoding('utf8');
25
+ child.stderr?.on('data', (chunk) => {
26
+ stderr += chunk;
27
+ });
28
+ child.on('error', (error) => {
29
+ spawnError = error;
30
+ stderr += error.message;
31
+ });
32
+ const stopProcessTree = async () => {
33
+ if (isProcessGroupLeader && child.pid !== undefined) {
34
+ process.kill(-child.pid, 'SIGTERM');
35
+ return;
36
+ }
37
+ await projectProcesses.terminate(child, { isForceful: false, env });
38
+ };
39
+ const timeout = timeoutMs === undefined
40
+ ? undefined
41
+ : setTimeout(() => {
42
+ isTimedOut = true;
43
+ stopProcessTree().catch((error) => {
44
+ stderr += String(error);
45
+ });
46
+ }, timeoutMs);
47
+ child.once('close', (status) => {
48
+ clearTimeout(timeout);
49
+ resolve({
50
+ error: spawnError,
51
+ isTimedOut,
52
+ status: isTimedOut ? null : status,
53
+ stderr,
54
+ stdout,
55
+ });
56
+ });
57
+ });
58
+ exports.runNpm = runNpm;
59
+ //# sourceMappingURL=npmCommand.js.map
@@ -21,6 +21,7 @@ const node_fs_1 = __importDefault(require("node:fs"));
21
21
  const path_1 = __importDefault(require("path"));
22
22
  const express_1 = require("express");
23
23
  const v3_1 = require("zod/v3");
24
+ const api_responses_1 = require("../types/api-responses");
24
25
  const logger_1 = require("../utils/logger");
25
26
  const agent_variants_1 = require("../agent-variants");
26
27
  const changeBatchClassification_1 = require("../mcp/changeBatchClassification");
@@ -154,22 +155,10 @@ const renameRunBody = v3_1.z.object({
154
155
  label: renameLabelSchema,
155
156
  projectPath: v3_1.z.string().optional(),
156
157
  });
157
- const uiStateKeySchema = v3_1.z.string().min(1).max(500);
158
- const uiStateSchema = v3_1.z.object({
159
- pinned: v3_1.z.array(uiStateKeySchema).max(1000),
160
- order: v3_1.z.object({
161
- groups: v3_1.z.array(uiStateKeySchema).max(1000),
162
- rows: v3_1.z.record(v3_1.z.array(uiStateKeySchema).max(1000)),
163
- }),
164
- });
165
158
  const EMPTY_UI_STATE = {
166
159
  pinned: [],
167
160
  order: { groups: [], rows: {} },
168
161
  };
169
- const uiStatePutBody = v3_1.z.object({
170
- uiState: uiStateSchema,
171
- projectPath: v3_1.z.string().optional(),
172
- });
173
162
  const HISTORY_STATUSES = new Set([
174
163
  'completed',
175
164
  'committed',
@@ -1218,7 +1207,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
1218
1207
  }
1219
1208
  catch { }
1220
1209
  }
1221
- const parsed = uiStateSchema.safeParse(stored);
1210
+ const parsed = api_responses_1.VariantsUiStateSchema.safeParse(stored);
1222
1211
  res.json({
1223
1212
  projectPath,
1224
1213
  uiState: parsed.success ? parsed.data : EMPTY_UI_STATE,
@@ -1231,7 +1220,7 @@ const createAgentVariantsRouter = (orchestrator, bridge, telemetry, variantHisto
1231
1220
  router.put('/variants/ui-state', async (req, res) => {
1232
1221
  if (rejectNonLocalRequest(req, res))
1233
1222
  return;
1234
- const parsed = uiStatePutBody.safeParse(req.body);
1223
+ const parsed = api_responses_1.VariantsUiStateUpdateSchema.safeParse(req.body);
1235
1224
  if (!parsed.success) {
1236
1225
  res.status(400).json({
1237
1226
  errorCode: 'SCHEMA_VALIDATION_FAILED',
@@ -28,7 +28,9 @@ const createBrowserAccessRouter = ({ token, sessions, telemetry, }) => {
28
28
  profile = await (0, AuthService_1.validateAccessToken)(sessions.config.getProxyUrl(), parsed.data.token);
29
29
  }
30
30
  catch {
31
- return res.status(502).json({ error: 'Could not verify Google sign-in' });
31
+ return res.status(502).json({
32
+ error: 'Could not verify Google sign-in',
33
+ });
32
34
  }
33
35
  if (!profile)
34
36
  return res.sendStatus(401);
@@ -68,7 +70,9 @@ const createBrowserAccessRouter = ({ token, sessions, telemetry, }) => {
68
70
  });
69
71
  const handleError = (error, _req, res, _next) => {
70
72
  if (error instanceof BrowserAuthorizationRecords_1.AuthorizationChanged)
71
- return res.status(409).json({ error: error.message });
73
+ return res
74
+ .status(409)
75
+ .json({ error: error.message });
72
76
  res.status(503).json({
73
77
  error: 'Browser authorization is unavailable. Please retry or sign in again.',
74
78
  });
@@ -59,7 +59,9 @@ const createGuidanceRoutes = (profiles, telemetry) => {
59
59
  .json({ guidance, ...(guidanceWarning ? { guidanceWarning } : {}) });
60
60
  });
61
61
  router.post('/guidance/resolutions', async (req, res) => {
62
- const { accountId, ...input } = zod_1.z.record(zod_1.z.unknown()).parse(req.body);
62
+ const { accountId, ...input } = zod_1.z
63
+ .record(zod_1.z.string(), zod_1.z.unknown())
64
+ .parse(req.body);
63
65
  const selection = guidance_1.GuidanceSelectionSchema.parse(input);
64
66
  const headerAccountId = callerAccount(req);
65
67
  const bodyAccountId = zod_1.z.string().min(1).optional().parse(accountId);