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
@@ -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
@@ -182,6 +182,7 @@ const buildMcpServer = async (options = {}) => {
182
182
  durationMs: Date.now() - startedAt,
183
183
  designContextKind: (0, telemetry_1.designContextKindForEnvelope)(result.envelope),
184
184
  ...(0, telemetry_1.variantContextMetadataForArgs)(command, rest),
185
+ ...(0, telemetry_1.verificationMetadataForEnvelope)(result.envelope),
185
186
  ...callerFields,
186
187
  source: 'mcp',
187
188
  });
@@ -113,6 +113,7 @@ const handleServe = async (args, io) => {
113
113
  stage: 'resolve_dev_server',
114
114
  failureReason: 'operation_failed',
115
115
  durationMs: Date.now() - serverStartStartedAt,
116
+ error,
116
117
  });
117
118
  await telemetry.shutdown();
118
119
  await logForwarder.shutdown();
@@ -299,6 +300,7 @@ const handleServe = async (args, io) => {
299
300
  stage: 'start_editor_server',
300
301
  failureReason: 'operation_failed',
301
302
  durationMs: Date.now() - serverStartStartedAt,
303
+ error,
302
304
  });
303
305
  await telemetry.shutdown();
304
306
  await logForwarder.shutdown();
@@ -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;
@@ -35,6 +35,7 @@ export type CallerTelemetryFields = {
35
35
  callerAgent?: string;
36
36
  callerModel?: string;
37
37
  callerAgentSource?: 'handoff' | 'env';
38
+ callerRunId?: string;
38
39
  };
39
40
  export declare const callerTelemetryFieldsFromArgs: (args: string[], env?: NodeJS.ProcessEnv) => CallerTelemetryFields;
40
41
  export declare const initiatorFor: (handoff: CallerHandoff | null) => WorkItemInitiator;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initiatorFor = exports.callerTelemetryFieldsFromArgs = exports.detectCallerAgentFromEnv = exports.callerAgentEvidenceFromEnv = exports.detectCallerAgentsFromEnv = exports.parseHandoff = exports.HANDOFF_ENV_VARS = exports.CALLER_AGENT_ALLOWLIST = void 0;
4
+ const node_crypto_1 = require("node:crypto");
4
5
  exports.CALLER_AGENT_ALLOWLIST = ['claude', 'codex', 'cursor'];
5
6
  exports.HANDOFF_ENV_VARS = {
6
7
  agent: 'RIVET_CALLER_AGENT',
@@ -84,6 +85,11 @@ const callerAgentEvidenceFromEnv = (env = process.env) => ENV_MARKERS_BY_AGENT.m
84
85
  exports.callerAgentEvidenceFromEnv = callerAgentEvidenceFromEnv;
85
86
  const detectCallerAgentFromEnv = (env = process.env) => (0, exports.detectCallerAgentsFromEnv)(env)[0];
86
87
  exports.detectCallerAgentFromEnv = detectCallerAgentFromEnv;
88
+ const CALLER_RUN_ID_HEX_LENGTH = 16;
89
+ const callerRunIdForSession = (session) => (0, node_crypto_1.createHash)('sha256')
90
+ .update(session)
91
+ .digest('hex')
92
+ .slice(0, CALLER_RUN_ID_HEX_LENGTH);
87
93
  const callerTelemetryFieldsFromArgs = (args, env = process.env) => {
88
94
  const valueOf = (flag) => {
89
95
  const index = args.indexOf(flag);
@@ -95,15 +101,25 @@ const callerTelemetryFieldsFromArgs = (args, env = process.env) => {
95
101
  callerSession: valueOf('--caller-session'),
96
102
  handoffJson: valueOf('--handoff'),
97
103
  }, env);
98
- if (parsed.ok && parsed.handoff) {
104
+ const handoff = parsed.ok ? parsed.handoff : null;
105
+ const session = handoff?.session ??
106
+ nonEmpty(env.CODEX_THREAD_ID) ??
107
+ nonEmpty(env.CLAUDE_CODE_SESSION_ID);
108
+ const callerRunId = session ? callerRunIdForSession(session) : undefined;
109
+ const runId = callerRunId ? { callerRunId } : {};
110
+ if (handoff) {
99
111
  return {
100
- callerAgent: parsed.handoff.agent,
101
- callerModel: parsed.handoff.model,
112
+ callerAgent: handoff.agent,
113
+ callerModel: handoff.model,
102
114
  callerAgentSource: 'handoff',
115
+ ...runId,
103
116
  };
104
117
  }
105
118
  const detected = (0, exports.detectCallerAgentFromEnv)(env);
106
- return detected ? { callerAgent: detected, callerAgentSource: 'env' } : {};
119
+ if (detected) {
120
+ return { callerAgent: detected, callerAgentSource: 'env', ...runId };
121
+ }
122
+ return runId;
107
123
  };
108
124
  exports.callerTelemetryFieldsFromArgs = callerTelemetryFieldsFromArgs;
109
125
  const initiatorFor = (handoff) => handoff
@@ -309,6 +309,7 @@ const runCliControlCommand = async (args, io = io_1.processCliIO) => {
309
309
  designContextKind: (0, telemetry_1.designContextKindForEnvelope)(result.envelope),
310
310
  ...(0, telemetry_1.variantContextMetadataForArgs)(command, rest),
311
311
  ...(0, telemetry_1.browserMetadataForEnvelope)(result.envelope),
312
+ ...(0, telemetry_1.verificationMetadataForEnvelope)(result.envelope),
312
313
  ...(0, handoff_1.callerTelemetryFieldsFromArgs)(rest),
313
314
  });
314
315
  telemetry.reportInstallRefActivations();
@@ -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;
@@ -1,6 +1,7 @@
1
1
  import type { CliEnvelope } from './envelope';
2
2
  import type { BrowserOpenResult } from './browser';
3
3
  import { type ServerUnavailableReason } from './serverUnavailable';
4
+ import { type GuidanceVerifierErrorReason } from '../types/guidance-verifier';
4
5
  export type { ServerUnavailableReason } from './serverUnavailable';
5
6
  export type DesignContextKind = 'arena' | 'pinterest' | 'reference' | 'unsupported' | 'website';
6
7
  export type VariantContextKind = 'image' | 'variant' | 'video' | 'website';
@@ -14,6 +15,15 @@ export type BrowserMetadata = {
14
15
  browserAction?: BrowserOpenResult['action'];
15
16
  browserReason?: BrowserOpenResult['reason'];
16
17
  };
18
+ declare const COMPLETED_VERIFICATION_STATUSES: readonly ["pass", "fail", "blocked"];
19
+ type CompletedVerificationStatus = (typeof COMPLETED_VERIFICATION_STATUSES)[number];
20
+ export type VerificationOutcome = CompletedVerificationStatus | GuidanceVerifierErrorReason;
21
+ export type VerificationMetadata = {
22
+ verificationOutcome?: VerificationOutcome;
23
+ verificationCheckCount?: number;
24
+ verificationDurationMs?: number;
25
+ };
26
+ export declare const verificationMetadataForEnvelope: (envelope: CliEnvelope) => VerificationMetadata;
17
27
  export declare const browserMetadataForEnvelope: (envelope: CliEnvelope) => BrowserMetadata;
18
28
  export declare const serverUnavailableReasonForEnvelope: (envelope: CliEnvelope) => ServerUnavailableReason | undefined;
19
29
  export declare const designContextKindForEnvelope: (envelope: CliEnvelope) => DesignContextKind | undefined;
@@ -1,10 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.variantContextMetadataForArgs = exports.designContextKindForEnvelope = exports.serverUnavailableReasonForEnvelope = exports.browserMetadataForEnvelope = void 0;
3
+ exports.variantContextMetadataForArgs = exports.designContextKindForEnvelope = exports.serverUnavailableReasonForEnvelope = exports.browserMetadataForEnvelope = exports.verificationMetadataForEnvelope = void 0;
4
4
  const serverUnavailable_1 = require("./serverUnavailable");
5
+ const guidance_verifier_1 = require("../types/guidance-verifier");
6
+ const COMPLETED_VERIFICATION_STATUSES = ['pass', 'fail', 'blocked'];
7
+ const isCompletedVerificationStatus = (value) => typeof value === 'string' &&
8
+ COMPLETED_VERIFICATION_STATUSES.includes(value);
9
+ const isGuidanceVerifierErrorReason = (value) => typeof value === 'string' &&
10
+ guidance_verifier_1.GUIDANCE_VERIFIER_ERROR_REASONS.includes(value);
11
+ const isNonNegativeDuration = (value) => typeof value === 'number' && Number.isFinite(value) && value >= 0;
12
+ const verificationOutcomeForReport = (report) => {
13
+ if (report.execution === 'completed' &&
14
+ isCompletedVerificationStatus(report.status)) {
15
+ return report.status;
16
+ }
17
+ if (report.execution === 'error' &&
18
+ isGuidanceVerifierErrorReason(report.reason)) {
19
+ return report.reason;
20
+ }
21
+ return undefined;
22
+ };
5
23
  const recordOf = (value) => value !== null && typeof value === 'object'
6
24
  ? value
7
25
  : {};
26
+ const verificationMetadataForEnvelope = (envelope) => {
27
+ if (envelope.command !== 'context.verify')
28
+ return {};
29
+ const report = recordOf(envelope.ok ? envelope.data : envelope.error.details);
30
+ const verificationOutcome = verificationOutcomeForReport(report);
31
+ const verificationCheckCount = Array.isArray(report.checks)
32
+ ? report.checks.length
33
+ : undefined;
34
+ const verificationDurationMs = isNonNegativeDuration(report.durationMs)
35
+ ? report.durationMs
36
+ : undefined;
37
+ return {
38
+ ...(verificationOutcome !== undefined ? { verificationOutcome } : {}),
39
+ ...(verificationCheckCount !== undefined ? { verificationCheckCount } : {}),
40
+ ...(verificationDurationMs !== undefined ? { verificationDurationMs } : {}),
41
+ };
42
+ };
43
+ exports.verificationMetadataForEnvelope = verificationMetadataForEnvelope;
8
44
  const browserMetadataForEnvelope = (envelope) => {
9
45
  if (envelope.command !== 'open')
10
46
  return {};
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.pluginMetricProperties = void 0;
4
4
  const zod_1 = require("zod");
5
+ const failureReason_1 = require("../utils/failureReason");
5
6
  const count = zod_1.z.number().finite().nonnegative().max(Number.MAX_SAFE_INTEGER);
6
7
  const metricProperties = zod_1.z.object({
7
8
  command: zod_1.z
@@ -19,6 +20,17 @@ const metricProperties = zod_1.z.object({
19
20
  'variants.cancel',
20
21
  'reference.fetch',
21
22
  'evidence.capture',
23
+ 'context.add',
24
+ 'context.update',
25
+ 'context.list',
26
+ 'context.show',
27
+ 'context.enable',
28
+ 'context.disable',
29
+ 'context.remove',
30
+ 'context.resolve',
31
+ 'context.inspect',
32
+ 'context.verifier',
33
+ 'context.verify',
22
34
  ])
23
35
  .optional(),
24
36
  tool_name: zod_1.z
@@ -112,8 +124,12 @@ const metricProperties = zod_1.z.object({
112
124
  'STATIC_PREVIEW_FAILED',
113
125
  'DEV_SERVER_FAILED',
114
126
  'PREVIEW_UNAVAILABLE',
127
+ 'DEPENDENCY_INSTALL_FAILED',
128
+ 'DEV_SERVER_START_FAILED',
129
+ 'DEV_SCRIPT_MISSING',
115
130
  ])
116
131
  .optional(),
132
+ reason_code: zod_1.z.enum(failureReason_1.FAILURE_REASON_CODES).optional(),
117
133
  failure_reason: zod_1.z
118
134
  .enum([
119
135
  'ack_failed',
@@ -169,6 +185,26 @@ const metricProperties = zod_1.z.object({
169
185
  'editor_server_start_failed',
170
186
  ])
171
187
  .optional(),
188
+ verification_outcome: zod_1.z
189
+ .enum([
190
+ 'pass',
191
+ 'fail',
192
+ 'blocked',
193
+ 'package_required',
194
+ 'verifier_missing',
195
+ 'verifier_stale',
196
+ 'cancelled',
197
+ 'timeout',
198
+ 'output_limit',
199
+ 'process_failed',
200
+ 'invalid_result',
201
+ 'invalid_evidence',
202
+ 'cleanup_failed',
203
+ 'setup_failed',
204
+ ])
205
+ .optional(),
206
+ verification_check_count: count.int().optional(),
207
+ verification_duration_ms: count.optional(),
172
208
  ok: zod_1.z.boolean().optional(),
173
209
  is_recoverable: zod_1.z.boolean().optional(),
174
210
  is_fresh: zod_1.z.boolean().optional(),
@@ -205,7 +241,6 @@ const PRODUCT_EVENTS = new Set([
205
241
  'visual_editor_reference_connection_failed',
206
242
  'agent_variants.request_started',
207
243
  'agent_variants.request_accepted',
208
- 'agent_variants.request_rejected',
209
244
  'agent_variants.refinement_requested',
210
245
  'agent_variants.refinement_completed',
211
246
  '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.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ProjectDetectionService } from './index-core';
2
+ import { AuthService } from './services/AuthService';
2
3
  import { SessionBridgeService } from './services/SessionBridgeService';
3
4
  import type { Framework } from './services/ProjectDetectionService';
4
5
  import { DevServerRuntimeService, type StartDevServerResult } from './services/DevServerRuntimeService';
@@ -75,6 +76,24 @@ export declare const authCommandOptionsForArgs: (args: string[]) => {
75
76
  };
76
77
  export declare const rememberInstallRef: (args: string[], downloadType?: string) => string[];
77
78
  export declare const authFailureReasonForError: (error: string | undefined) => "oauth_failed" | "timeout";
79
+ export declare const signInWithoutBrowser: (authService?: AuthService) => Promise<{
80
+ success: boolean;
81
+ token?: string | undefined;
82
+ refreshToken?: string | undefined;
83
+ user?: {
84
+ id: string;
85
+ email: string;
86
+ displayName?: string | undefined;
87
+ } | undefined;
88
+ profile?: {
89
+ remaining_spend_usd?: number | null | undefined;
90
+ monthly_limit_usd?: number | null | undefined;
91
+ current_month_spend_usd?: number | null | undefined;
92
+ total_spend_usd?: number | null | undefined;
93
+ } | null | undefined;
94
+ error?: string | undefined;
95
+ message?: string | undefined;
96
+ }>;
78
97
  export declare const main: (args?: string[]) => Promise<void>;
79
98
  export declare const parseArgs: (args: string[]) => CLIOptions;
80
99
  export declare const handleLogin: (options?: {
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.handleLogin = exports.parseArgs = exports.main = exports.authFailureReasonForError = exports.rememberInstallRef = exports.authCommandOptionsForArgs = exports.registerOwnedDevServerSignalHandlers = exports.isAgentVariantsEnabled = exports.updateOwnedDevServerHealthOnExit = exports.buildAgentDevServerHealth = exports.resolveAgentDevServer = exports.buildAgentDevServerContext = exports.DEFAULT_USER_PORT = exports.DEFAULT_PORT = void 0;
39
+ exports.handleLogin = exports.parseArgs = exports.main = exports.signInWithoutBrowser = exports.authFailureReasonForError = exports.rememberInstallRef = exports.authCommandOptionsForArgs = exports.registerOwnedDevServerSignalHandlers = exports.isAgentVariantsEnabled = exports.updateOwnedDevServerHealthOnExit = exports.buildAgentDevServerHealth = exports.resolveAgentDevServer = exports.buildAgentDevServerContext = exports.DEFAULT_USER_PORT = exports.DEFAULT_PORT = void 0;
40
40
  /* eslint-disable no-console */
41
41
  const dotenv = __importStar(require("dotenv"));
42
42
  const crypto_1 = require("crypto");
@@ -260,6 +260,18 @@ const discardInstallRefForValidatedSession = () => {
260
260
  };
261
261
  const authFailureReasonForError = (error) => error?.trim().toLowerCase() === 'timeout' ? 'timeout' : 'oauth_failed';
262
262
  exports.authFailureReasonForError = authFailureReasonForError;
263
+ const signInWithoutBrowser = async (authService = new AuthService_1.AuthService()) => {
264
+ console.log('\n🔐 Authentication required');
265
+ console.log('Open this link to sign in:');
266
+ return authService.loginWithGoogle({
267
+ source: 'cli',
268
+ noBrowser: true,
269
+ onAuthUrl: (url) => {
270
+ console.log(`\n ${url}\n`);
271
+ },
272
+ });
273
+ };
274
+ exports.signInWithoutBrowser = signInWithoutBrowser;
263
275
  const main = async (args = process.argv.slice(2)) => {
264
276
  if (args.includes('--no-telemetry'))
265
277
  process.env.RIVET_TELEMETRY_DISABLED = '1';
@@ -452,10 +464,7 @@ const main = async (args = process.argv.slice(2)) => {
452
464
  process.exit(1);
453
465
  }
454
466
  if (options.noBrowser) {
455
- console.log('\n🔐 Authentication required');
456
- console.log('Opening browser for Google login...\n');
457
- const authService = new AuthService_1.AuthService();
458
- const loginResult = await authService.loginWithGoogle();
467
+ const loginResult = await (0, exports.signInWithoutBrowser)();
459
468
  if (!loginResult.success) {
460
469
  console.log(`\n❌ Authentication failed: ${loginResult.error || loginResult.message}`);
461
470
  process.exit(1);
@@ -861,7 +870,7 @@ const handleInstall = async (installArgs) => {
861
870
  (0, exports.rememberInstallRef)(installArgs, selection.targetIds.join(','));
862
871
  if (installRef)
863
872
  await reportInstallRefActivations();
864
- const bootstrap = (0, globalBootstrap_1.bootstrapGlobalInstall)(installArgs);
873
+ const bootstrap = await (0, globalBootstrap_1.bootstrapGlobalInstall)(installArgs);
865
874
  if (bootstrap.action === 'reexeced') {
866
875
  process.exit(bootstrap.exitCode);
867
876
  }
@@ -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