rivet-design 0.27.0 → 0.28.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 (76) hide show
  1. package/dist/agent-variants/DirectionRefReservations.d.ts +11 -0
  2. package/dist/agent-variants/DirectionRefReservations.js +47 -0
  3. package/dist/agent-variants/PreviewRuntime.d.ts +4 -0
  4. package/dist/agent-variants/PreviewRuntime.js +5 -3
  5. package/dist/agent-variants/SessionStore.d.ts +10 -1
  6. package/dist/agent-variants/SessionStore.js +25 -2
  7. package/dist/agent-variants/WorkItemRequestTimes.d.ts +6 -0
  8. package/dist/agent-variants/WorkItemRequestTimes.js +21 -0
  9. package/dist/agent-variants/WorktreeOrchestrator.d.ts +2 -1
  10. package/dist/agent-variants/WorktreeOrchestrator.js +92 -78
  11. package/dist/agent-variants/contracts.d.ts +8 -0
  12. package/dist/agent-variants/existingStaticEntry.d.ts +34 -0
  13. package/dist/agent-variants/existingStaticEntry.js +136 -0
  14. package/dist/agent-variants/staticPreviewFiles.js +1 -1
  15. package/dist/agent-variants/variant-project-runtime.d.ts +2 -1
  16. package/dist/agent-variants/variantsTelemetry.d.ts +4 -0
  17. package/dist/agent-variants/variantsTelemetry.js +2 -0
  18. package/dist/agent-variants/workItemInput.d.ts +22 -0
  19. package/dist/agent-variants/workItemInput.js +12 -1
  20. package/dist/cli/commands/directionTarget.d.ts +23 -0
  21. package/dist/cli/commands/directionTarget.js +87 -0
  22. package/dist/cli/commands/open.js +28 -4
  23. package/dist/cli/commands/variants.js +36 -43
  24. package/dist/cli/envelope.d.ts +1 -1
  25. package/dist/cli/envelope.js +1 -0
  26. package/dist/cli/projectRuntimeUpgrade.d.ts +11 -0
  27. package/dist/cli/projectRuntimeUpgrade.js +43 -11
  28. package/dist/config/pluginMetrics.js +2 -0
  29. package/dist/config/posthog.d.ts +2 -0
  30. package/dist/config/posthog.js +5 -0
  31. package/dist/mcp/explorationSchema.js +1 -1
  32. package/dist/mcp/getExploration.js +11 -5
  33. package/dist/proxy-middleware/proxy-config.js +7 -0
  34. package/dist/routes/agentVariants.js +4 -0
  35. package/dist/routes/cli.js +10 -1
  36. package/dist/server.js +12 -6
  37. package/dist/services/DependencyPreparationService.js +44 -6
  38. package/dist/services/FeatureFlagService.js +2 -2
  39. package/dist/services/ProjectLibrary.d.ts +4 -1
  40. package/dist/services/ProjectLibrary.js +14 -9
  41. package/dist/services/ProjectRuntimeService.d.ts +8 -0
  42. package/dist/services/ProjectRuntimeService.js +15 -2
  43. package/dist/services/TelemetryService.d.ts +5 -0
  44. package/dist/services/TelemetryService.js +21 -2
  45. package/dist/services/VariantHistoryService.d.ts +8 -0
  46. package/dist/services/VariantHistoryService.js +40 -0
  47. package/dist/services/WorktreeManager.d.ts +1 -0
  48. package/dist/services/WorktreeManager.js +12 -0
  49. package/dist/services/createAgentVariantsOrchestrator.js +9 -2
  50. package/dist/services/directionRefs.d.ts +21 -0
  51. package/dist/services/directionRefs.js +148 -0
  52. package/dist/services/projectDirections.d.ts +22 -0
  53. package/dist/services/projectDirections.js +38 -0
  54. package/dist/types/direction-ref.d.ts +36 -0
  55. package/dist/types/direction-ref.js +3 -0
  56. package/dist/types/variant-history.d.ts +3 -1
  57. package/dist/utils/failureReason.d.ts +1 -1
  58. package/dist/utils/failureReason.js +3 -0
  59. package/dist/utils/skills/cli-guidance.js +4 -3
  60. package/dist/utils/subprocessEnvironment.d.ts +1 -1
  61. package/dist/utils/subprocessEnvironment.js +0 -1
  62. package/package.json +4 -4
  63. package/src/ui/dist/assets/LibraryEntry-BE8nZneH.js +37 -0
  64. package/src/ui/dist/assets/logo.png +0 -0
  65. package/src/ui/dist/assets/main-1EDrDqgn.js +498 -0
  66. package/src/ui/dist/assets/main-qgqnlUkI.css +1 -0
  67. package/src/ui/dist/assets/rivet-wordmark-orange-CYKVQDmG.svg +7 -0
  68. package/src/ui/dist/index.html +2 -2
  69. package/dist/services/StaticPreviewServer.d.ts +0 -8
  70. package/dist/services/StaticPreviewServer.js +0 -207
  71. package/src/ui/dist/assets/LibraryEntry-RI9Lc7P3.js +0 -37
  72. package/src/ui/dist/assets/main-D0UmAaUe.css +0 -1
  73. package/src/ui/dist/assets/main-DgrLzS5j.js +0 -497
  74. package/src/ui/dist/assets/rivet.svg +0 -3
  75. package/src/ui/dist/fonts/Goldman-Bold.woff2 +0 -0
  76. package/src/ui/dist/fonts/Goldman-Regular.woff2 +0 -0
@@ -0,0 +1,11 @@
1
+ import type { VariantHistoryService } from '../services/VariantHistoryService';
2
+ import type { DirectionRef } from '../types/direction-ref';
3
+ export declare class DirectionRefReservations {
4
+ private readonly taken;
5
+ reserve(label: string): DirectionRef;
6
+ load(args: {
7
+ projectPath: string;
8
+ history: VariantHistoryService;
9
+ }): Promise<void>;
10
+ }
11
+ //# sourceMappingURL=DirectionRefReservations.d.ts.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DirectionRefReservations = void 0;
4
+ const directionRefs_1 = require("../services/directionRefs");
5
+ const projectDirections_1 = require("../services/projectDirections");
6
+ const logger_1 = require("../utils/logger");
7
+ const log = (0, logger_1.createLogger)('DirectionRefReservations');
8
+ class DirectionRefReservations {
9
+ taken = new Set();
10
+ reserve(label) {
11
+ const directionRef = (0, directionRefs_1.nextDirectionRef)({ label, taken: this.taken });
12
+ this.taken.add(directionRef);
13
+ return directionRef;
14
+ }
15
+ async load(args) {
16
+ let directions;
17
+ try {
18
+ directions = await (0, projectDirections_1.listProjectDirections)({
19
+ kind: 'history',
20
+ history: args.history,
21
+ projectPath: args.projectPath,
22
+ });
23
+ }
24
+ catch (error) {
25
+ log.warn('Direction ref history could not be listed', error);
26
+ return;
27
+ }
28
+ for (const direction of directions) {
29
+ this.taken.add(direction.directionRef);
30
+ if (direction.manifest.directionRef)
31
+ continue;
32
+ try {
33
+ await args.history.assignDirectionRef({
34
+ projectPath: direction.projectPath,
35
+ sessionId: direction.manifest.sessionId,
36
+ variantId: direction.manifest.variantId,
37
+ directionRef: direction.directionRef,
38
+ });
39
+ }
40
+ catch (error) {
41
+ log.warn(`Direction ref backfill failed for ${direction.manifest.sessionId}:${direction.manifest.variantId}`, error);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ exports.DirectionRefReservations = DirectionRefReservations;
47
+ //# sourceMappingURL=DirectionRefReservations.js.map
@@ -3,6 +3,7 @@ import { type DevServerFailureReason } from '../utils/devServerError';
3
3
  import type { ProjectContext } from './contracts';
4
4
  import type { ProjectEnvironment, WorktreeManagerLike } from './variant-project-runtime';
5
5
  import { type VariantsTelemetry } from './variantsTelemetry';
6
+ import { type FailureReasonCode } from '../utils/failureReason';
6
7
  export type ResolvedDevServer = {
7
8
  cwd: string;
8
9
  cmd: string;
@@ -14,6 +15,9 @@ export type PreviewFailure = {
14
15
  reason: DevServerFailureReason | 'missing_static_entry' | 'idle_timeout' | 'unknown';
15
16
  portInUse: boolean;
16
17
  detail?: string;
18
+ reasonCode?: FailureReasonCode;
19
+ reasonDetail?: string;
20
+ nodeVersion?: string;
17
21
  };
18
22
  type PreviewRuntimeDeps = {
19
23
  worktreeManager: WorktreeManagerLike;
@@ -364,9 +364,14 @@ class PreviewRuntime {
364
364
  const detail = devError?.detail ||
365
365
  failure.detail ||
366
366
  (error === undefined ? '' : (0, errorMessage_1.errorMessage)(error));
367
+ const reportedError = REPORTED_FAILURE_REASONS.has(failure.reason)
368
+ ? error
369
+ : undefined;
367
370
  this.requireSession(args.sessionId).failures.set(args.workItemId, {
368
371
  ...failure,
369
372
  ...(detail ? { detail } : {}),
373
+ ...(reportedError === undefined ? {} : (0, failureReason_1.failureReason)(reportedError)),
374
+ nodeVersion: process.version,
370
375
  });
371
376
  let errorCode = 'DEV_SERVER_START_FAILED';
372
377
  if (failure.reason === 'dependency_install_failed') {
@@ -374,9 +379,6 @@ class PreviewRuntime {
374
379
  }
375
380
  if (failure.reason === 'missing_dev_script')
376
381
  errorCode = 'DEV_SCRIPT_MISSING';
377
- const reportedError = REPORTED_FAILURE_REASONS.has(failure.reason)
378
- ? error
379
- : undefined;
380
382
  (0, variantsTelemetry_1.trackFreshDevServerFailed)(this.deps.telemetry, {
381
383
  sessionId: args.sessionId,
382
384
  variantId: args.workItemId,
@@ -2,6 +2,8 @@ import type { GuidanceDocument } from '../types/guidance';
2
2
  import type { WorkerSelection } from '../types/change-request-types';
3
3
  import { type VariantReference } from '../types/variant-reference';
4
4
  import { type Brief, type ActiveVariantSnapshot, type LeasedWorkItemDescriptor, type ProjectContext, type Stage, type StartVariantsBriefContent, type StaticPreviewTargetElement, type Target, type TerminalSummary, type VariantContextBinding, type VariantContextBundle, type VariantQaResult, type VariantWorkItemContext, type WorkItem, type WorkItemKind, type WorkItemStatus, type WorkerFidelity, type WorkerRuntimeInfo } from './contracts';
5
+ import { DirectionRefReservations } from './DirectionRefReservations';
6
+ import type { DirectionRef } from '../types/direction-ref';
5
7
  import { type VariantWorkItemInput, type VariantWorkItemInputByKind, type VariantWorkItemKind } from './workItemInput';
6
8
  export declare const DEFAULT_LEASE_TTL_MS: number;
7
9
  export declare const SCAFFOLD_LEASE_TTL_MS: number;
@@ -60,7 +62,8 @@ export declare const buildImageRefs: (artifacts: ReadonlyArray<{
60
62
  export declare class SessionStore {
61
63
  private readonly sessions;
62
64
  private readonly clock;
63
- constructor(clock?: SessionStoreClock);
65
+ readonly directionRefs: DirectionRefReservations;
66
+ constructor(clock?: SessionStoreClock, directionRefs?: DirectionRefReservations);
64
67
  propose(args: ProposeArgs): ProposeResult;
65
68
  reportBriefs(args: {
66
69
  sessionId: string;
@@ -163,6 +166,7 @@ export declare class SessionStore {
163
166
  references?: VariantReference[];
164
167
  previewRoutes?: string[];
165
168
  runLabel?: string;
169
+ sourceDirectionRef?: DirectionRef;
166
170
  }): {
167
171
  workItemId: string;
168
172
  briefId: string;
@@ -180,12 +184,17 @@ export declare class SessionStore {
180
184
  references?: VariantReference[];
181
185
  previewRoutes?: string[];
182
186
  runLabel?: string;
187
+ sourceDirectionRef?: DirectionRef;
183
188
  projectContext: ProjectContext;
184
189
  }): {
185
190
  sessionId: string;
186
191
  workItemId: string;
187
192
  briefId: string;
188
193
  };
194
+ claimDirectionRef(args: {
195
+ sessionId: string;
196
+ workItemId: string;
197
+ }): DirectionRef;
189
198
  private findAdoptedVariant;
190
199
  assignVariantPreviewRoutes(args: {
191
200
  sessionId: string;
@@ -7,6 +7,7 @@ const crypto_1 = require("crypto");
7
7
  const errors_1 = require("./errors");
8
8
  const contracts_1 = require("./contracts");
9
9
  const briefContent_1 = require("./briefContent");
10
+ const DirectionRefReservations_1 = require("./DirectionRefReservations");
10
11
  const runLabel_1 = require("./runLabel");
11
12
  const runPlan_1 = require("./runPlan");
12
13
  const workItemInput_1 = require("./workItemInput");
@@ -185,8 +186,10 @@ const resolveVariantWorkItemContext = (args) => {
185
186
  class SessionStore {
186
187
  sessions = new Map();
187
188
  clock;
188
- constructor(clock = SYSTEM_CLOCK) {
189
+ directionRefs;
190
+ constructor(clock = SYSTEM_CLOCK, directionRefs = new DirectionRefReservations_1.DirectionRefReservations()) {
189
191
  this.clock = clock;
192
+ this.directionRefs = directionRefs;
190
193
  }
191
194
  propose(args) {
192
195
  const sessionId = args.sessionId ?? (0, crypto_1.randomUUID)();
@@ -345,6 +348,7 @@ class SessionStore {
345
348
  input: {
346
349
  briefId: brief.briefId,
347
350
  briefLabel: brief.label,
351
+ directionRef: this.directionRefs.reserve(brief.label),
348
352
  briefBody: sel.bodyOverride ?? brief.body,
349
353
  instruction: session.prompt,
350
354
  guidance: session.guidance,
@@ -376,6 +380,7 @@ class SessionStore {
376
380
  input: {
377
381
  briefId: brief.briefId,
378
382
  briefLabel: brief.label,
383
+ directionRef: this.directionRefs.reserve(brief.label),
379
384
  briefBody: sel.bodyOverride ?? brief.body,
380
385
  instruction: session.prompt,
381
386
  guidance: session.guidance,
@@ -582,6 +587,7 @@ class SessionStore {
582
587
  guidance: args.guidance ?? [],
583
588
  briefId: targetInput.briefId,
584
589
  briefLabel: targetInput.briefLabel,
590
+ ...(0, workItemInput_1.shownDirectionRef)(targetInput),
585
591
  briefBody: targetInput.briefBody,
586
592
  references: targetInput.references,
587
593
  ...(targetInput.briefNotes
@@ -660,6 +666,7 @@ class SessionStore {
660
666
  },
661
667
  }
662
668
  : sourceInput.context;
669
+ const briefLabel = brief?.label ?? `${labelBase}${suffix}`;
663
670
  const item = {
664
671
  id: (0, crypto_1.randomUUID)(),
665
672
  kind: 'static_preview',
@@ -668,7 +675,8 @@ class SessionStore {
668
675
  dependsOn: [],
669
676
  input: {
670
677
  briefId: `${sourceInput.briefId ?? 'v'}-vary-${(0, crypto_1.randomUUID)().slice(0, 8)}`,
671
- briefLabel: brief?.label ?? `${labelBase}${suffix}`,
678
+ briefLabel,
679
+ directionRef: this.directionRefs.reserve(briefLabel),
672
680
  briefBody: brief?.body ?? prettyInstruction,
673
681
  ...(brief?.notes ? { briefNotes: brief.notes } : {}),
674
682
  ...(previewRoutes.length ? { previewRoutes } : {}),
@@ -757,6 +765,7 @@ class SessionStore {
757
765
  input: {
758
766
  briefId: brief.briefId,
759
767
  briefLabel: brief.label,
768
+ directionRef: this.directionRefs.reserve(brief.label),
760
769
  briefBody: brief.body,
761
770
  references: (0, variant_reference_1.mergeVariantReferences)(sourceInput?.references, context?.references),
762
771
  instruction: args.instruction,
@@ -815,6 +824,9 @@ class SessionStore {
815
824
  input: {
816
825
  briefId,
817
826
  briefLabel: args.label,
827
+ ...(args.sourceDirectionRef
828
+ ? { sourceDirectionRef: args.sourceDirectionRef }
829
+ : {}),
818
830
  ...(args.description ? { briefBody: args.description } : {}),
819
831
  ...(args.runLabel ? { runLabel: args.runLabel } : {}),
820
832
  adoptedFrom: { ...args.source },
@@ -854,6 +866,7 @@ class SessionStore {
854
866
  references: args.references,
855
867
  previewRoutes: args.previewRoutes,
856
868
  runLabel: args.runLabel,
869
+ sourceDirectionRef: args.sourceDirectionRef,
857
870
  });
858
871
  return {
859
872
  sessionId,
@@ -861,6 +874,15 @@ class SessionStore {
861
874
  briefId: adopted.briefId,
862
875
  };
863
876
  }
877
+ claimDirectionRef(args) {
878
+ const item = this.requireWorkItem(this.requireSession(args.sessionId), args.workItemId);
879
+ if (!(0, workItemInput_1.isVariantWorkItem)(item))
880
+ throw new errors_1.AgentVariantsError('WORK_ITEM_NOT_FOUND', `Work item ${item.id} is a ${item.kind} work item, not a direction`);
881
+ const directionRef = item.input.directionRef ??
882
+ this.directionRefs.reserve(item.input.briefLabel ?? '');
883
+ item.input.directionRef = directionRef;
884
+ return directionRef;
885
+ }
864
886
  findAdoptedVariant(session, source) {
865
887
  for (const item of session.workItems.values()) {
866
888
  if (item.removed || !(0, workItemInput_1.isVariantWorkItem)(item))
@@ -1427,6 +1449,7 @@ class SessionStore {
1427
1449
  ? { previewRoutes: [...input.previewRoutes] }
1428
1450
  : {}),
1429
1451
  briefId: input.briefId ?? '',
1452
+ ...(0, workItemInput_1.shownDirectionRef)(input),
1430
1453
  label: input.briefLabel ?? 'Variant',
1431
1454
  references: input.references,
1432
1455
  status: item.status,
@@ -0,0 +1,6 @@
1
+ export declare class WorkItemRequestTimes {
2
+ private readonly requestedAt;
3
+ record(workItemIds: readonly string[], requestedAt: number): void;
4
+ elapsedSinceRequestMs(workItemId: string, at: number | undefined): number | null;
5
+ }
6
+ //# sourceMappingURL=WorkItemRequestTimes.d.ts.map
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkItemRequestTimes = void 0;
4
+ class WorkItemRequestTimes {
5
+ requestedAt = new Map();
6
+ record(workItemIds, requestedAt) {
7
+ for (const workItemId of workItemIds) {
8
+ if (!this.requestedAt.has(workItemId)) {
9
+ this.requestedAt.set(workItemId, requestedAt);
10
+ }
11
+ }
12
+ }
13
+ elapsedSinceRequestMs(workItemId, at) {
14
+ const requestedAt = this.requestedAt.get(workItemId);
15
+ if (requestedAt === undefined || at === undefined)
16
+ return null;
17
+ return at - requestedAt;
18
+ }
19
+ }
20
+ exports.WorkItemRequestTimes = WorkItemRequestTimes;
21
+ //# sourceMappingURL=WorkItemRequestTimes.js.map
@@ -4,7 +4,7 @@ import type { VariantStartRequest, VariantStartResult } from './variant-start-ty
4
4
  import { AgentVariantsError } from './errors';
5
5
  import { SessionStore, type ApprovedBriefSelection, type ApproveResult, type ProposeArgs, type ProposeResult, type ReportCompleteResult, type RequestWorkResult } from './SessionStore';
6
6
  import type { ActiveProjectContext, AdoptPastVariantArgs, BootstrapPastVariantSessionArgs, BootstrapPastVariantSessionResult, ActiveVariantSnapshot, Brief, ProjectContext, Stage, TerminalSummary, VariantContextBinding, HostVariantWorkItemSnapshot, VariantQaResult, WorkItemStatus } from './contracts';
7
- import type { VariantWorkItemInput } from './workItemInput';
7
+ import { type VariantWorkItemInput } from './workItemInput';
8
8
  import { VariantHistoryService } from '../services/VariantHistoryService';
9
9
  import type { MCPVariantsTelemetryMetadata } from '../services/MCPVariantsTelemetry';
10
10
  import type { ProjectEnvironment, WorktreeManagerLike } from './variant-project-runtime';
@@ -249,6 +249,7 @@ export declare class AgentVariantsOrchestrator {
249
249
  private readonly pendingHistoryPersists;
250
250
  private trackHistoryPersist;
251
251
  settleHistoryPersists(): Promise<void>;
252
+ loadDirectionRefs(): Promise<void>;
252
253
  private getSavedVariant;
253
254
  isHistoryDurableForRestart(isForced?: boolean): Promise<boolean>;
254
255
  private persistCompletedExistingVariant;