rivet-design 0.26.2 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) 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.js +20 -7
  4. package/dist/agent-variants/SessionStore.d.ts +10 -1
  5. package/dist/agent-variants/SessionStore.js +25 -2
  6. package/dist/agent-variants/WorkItemRequestTimes.d.ts +6 -0
  7. package/dist/agent-variants/WorkItemRequestTimes.js +21 -0
  8. package/dist/agent-variants/WorktreeOrchestrator.d.ts +2 -1
  9. package/dist/agent-variants/WorktreeOrchestrator.js +92 -78
  10. package/dist/agent-variants/contracts.d.ts +120 -116
  11. package/dist/agent-variants/existingStaticEntry.d.ts +34 -0
  12. package/dist/agent-variants/existingStaticEntry.js +136 -0
  13. package/dist/agent-variants/staticPreviewFiles.js +1 -1
  14. package/dist/agent-variants/variant-project-runtime.d.ts +2 -1
  15. package/dist/agent-variants/variantsTelemetry.d.ts +8 -0
  16. package/dist/agent-variants/variantsTelemetry.js +5 -0
  17. package/dist/agent-variants/workItemInput.d.ts +168 -146
  18. package/dist/agent-variants/workItemInput.js +12 -1
  19. package/dist/cli/commands/directionTarget.d.ts +23 -0
  20. package/dist/cli/commands/directionTarget.js +87 -0
  21. package/dist/cli/commands/mcpServe.js +1 -0
  22. package/dist/cli/commands/open.js +28 -4
  23. package/dist/cli/commands/serve.js +2 -0
  24. package/dist/cli/commands/variants.js +36 -43
  25. package/dist/cli/envelope.d.ts +1 -1
  26. package/dist/cli/envelope.js +1 -0
  27. package/dist/cli/handoff.d.ts +1 -0
  28. package/dist/cli/handoff.js +20 -4
  29. package/dist/cli/projectRuntimeUpgrade.d.ts +11 -0
  30. package/dist/cli/projectRuntimeUpgrade.js +43 -11
  31. package/dist/cli/router.js +1 -0
  32. package/dist/cli/telemetry.d.ts +10 -0
  33. package/dist/cli/telemetry.js +37 -1
  34. package/dist/config/pluginMetrics.js +38 -0
  35. package/dist/index.d.ts +19 -0
  36. package/dist/index.js +14 -5
  37. package/dist/mcp/explorationSchema.js +1 -1
  38. package/dist/mcp/getExploration.js +11 -5
  39. package/dist/proxy-middleware/proxy-config.js +7 -0
  40. package/dist/routes/agentVariants.js +4 -0
  41. package/dist/routes/cli.js +10 -1
  42. package/dist/routes/library/middleware.js +11 -5
  43. package/dist/server.js +20 -6
  44. package/dist/services/DependencyPreparationService.js +57 -19
  45. package/dist/services/GuidanceVerifierRunner.js +4 -4
  46. package/dist/services/ProjectLibrary.d.ts +4 -1
  47. package/dist/services/ProjectLibrary.js +14 -9
  48. package/dist/services/ProjectPackageManager.d.ts +5 -0
  49. package/dist/services/ProjectPackageManager.js +33 -11
  50. package/dist/services/ProjectRuntimeService.d.ts +8 -0
  51. package/dist/services/ProjectRuntimeService.js +15 -2
  52. package/dist/services/TelemetryService.d.ts +13 -2
  53. package/dist/services/TelemetryService.js +29 -0
  54. package/dist/services/VariantHistoryService.d.ts +8 -0
  55. package/dist/services/VariantHistoryService.js +40 -0
  56. package/dist/services/WorktreeManager.d.ts +1 -0
  57. package/dist/services/WorktreeManager.js +17 -0
  58. package/dist/services/createAgentVariantsOrchestrator.js +9 -2
  59. package/dist/services/directionRefs.d.ts +21 -0
  60. package/dist/services/directionRefs.js +148 -0
  61. package/dist/services/profiles/DesignProfiles.js +16 -8
  62. package/dist/services/projectDirections.d.ts +22 -0
  63. package/dist/services/projectDirections.js +38 -0
  64. package/dist/types/direction-ref.d.ts +36 -0
  65. package/dist/types/direction-ref.js +3 -0
  66. package/dist/types/guidance-verifier.d.ts +7 -5
  67. package/dist/types/guidance-verifier.js +14 -1
  68. package/dist/types/variant-history.d.ts +3 -1
  69. package/dist/utils/devServerError.d.ts +5 -0
  70. package/dist/utils/devServerError.js +4 -0
  71. package/dist/utils/failureReason.d.ts +16 -0
  72. package/dist/utils/failureReason.js +106 -0
  73. package/dist/utils/hostedLogPrivacy.d.ts +1 -0
  74. package/dist/utils/hostedLogPrivacy.js +10 -4
  75. package/dist/utils/skills/claude-skill.d.ts +1 -1
  76. package/dist/utils/skills/claude-skill.js +1 -1
  77. package/dist/utils/skills/cli-guidance.d.ts +1 -1
  78. package/dist/utils/skills/cli-guidance.js +7 -6
  79. package/dist/utils/skills/cursor-rules.d.ts +1 -1
  80. package/dist/utils/skills/cursor-rules.js +1 -1
  81. package/dist/utils/subprocessEnvironment.d.ts +1 -1
  82. package/dist/utils/subprocessEnvironment.js +0 -1
  83. package/package.json +4 -4
  84. package/src/ui/dist/assets/LibraryEntry-BZ5EdFgA.js +37 -0
  85. package/src/ui/dist/assets/main-MepMmTwb.css +1 -0
  86. package/src/ui/dist/assets/main-RriU35pI.js +497 -0
  87. package/src/ui/dist/index.html +2 -2
  88. package/dist/services/StaticPreviewServer.d.ts +0 -8
  89. package/dist/services/StaticPreviewServer.js +0 -207
  90. package/src/ui/dist/assets/LibraryEntry-92R_T-Xa.js +0 -37
  91. package/src/ui/dist/assets/main-D0UmAaUe.css +0 -1
  92. package/src/ui/dist/assets/main-DgEfJvYu.js +0 -497
  93. package/src/ui/dist/fonts/Goldman-Bold.woff2 +0 -0
  94. package/src/ui/dist/fonts/Goldman-Regular.woff2 +0 -0
@@ -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' &&
@@ -1,7 +1,15 @@
1
1
  import type { ProjectRegistry } from './ProjectRegistry';
2
+ import { type ServerUnavailableReason } from '../cli/telemetry';
2
3
  interface ProjectRuntime {
3
4
  editorUrl: string;
4
5
  }
6
+ export declare class ProjectRuntimeUnavailable extends Error {
7
+ readonly serverUnavailableReason?: ServerUnavailableReason;
8
+ constructor({ message, serverUnavailableReason, }: {
9
+ message: string;
10
+ serverUnavailableReason?: ServerUnavailableReason;
11
+ });
12
+ }
5
13
  export declare class ProjectRuntimeService {
6
14
  private readonly registry;
7
15
  private readonly activations;
@@ -36,14 +36,24 @@ 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.ProjectRuntimeService = void 0;
39
+ exports.ProjectRuntimeService = exports.ProjectRuntimeUnavailable = void 0;
40
40
  const fs_1 = __importDefault(require("fs"));
41
41
  const zod_1 = require("zod");
42
42
  const installationChannel_1 = require("../install/installationChannel");
43
43
  const libraryErrors_1 = require("./libraryErrors");
44
44
  const serverHandshake_1 = require("../cli/serverHandshake");
45
45
  const shared_1 = require("../cli/commands/shared");
46
+ const telemetry_1 = require("../cli/telemetry");
46
47
  const HEALTH_TIMEOUT_MS = 2_000;
48
+ class ProjectRuntimeUnavailable extends Error {
49
+ serverUnavailableReason;
50
+ constructor({ message, serverUnavailableReason, }) {
51
+ super(message);
52
+ this.name = 'ProjectRuntimeUnavailable';
53
+ this.serverUnavailableReason = serverUnavailableReason;
54
+ }
55
+ }
56
+ exports.ProjectRuntimeUnavailable = ProjectRuntimeUnavailable;
47
57
  class ProjectRuntimeService {
48
58
  registry;
49
59
  activations = new Map();
@@ -118,7 +128,10 @@ class ProjectRuntimeService {
118
128
  writeEnvelope: () => { },
119
129
  });
120
130
  if (!result.envelope.ok)
121
- throw new Error(result.envelope.error.message);
131
+ throw new ProjectRuntimeUnavailable({
132
+ message: result.envelope.error.message,
133
+ serverUnavailableReason: (0, telemetry_1.serverUnavailableReasonForEnvelope)(result.envelope),
134
+ });
122
135
  const data = zod_1.z
123
136
  .object({ editorUrl: zod_1.z.string().url() })
124
137
  .parse(result.envelope.data);
@@ -1,8 +1,9 @@
1
1
  import { type AccountIdentity } from './ConfigManager';
2
- import type { BrowserMetadata, DesignContextKind, ServerUnavailableReason, VariantContextMetadata } from '../cli/telemetry';
2
+ import type { BrowserMetadata, DesignContextKind, ServerUnavailableReason, VariantContextMetadata, VerificationMetadata } from '../cli/telemetry';
3
3
  import type { GuidanceErrorCode, GuidanceSelection } from '../types/guidance';
4
4
  import type { MCPAuthMethod, MCPAuthState, MCPOnboardingCorrelation, MCPOAuthCallbackResult } from './MCPOnboardingTelemetry';
5
5
  import { type MCPVariantsTelemetryMetadata } from './MCPVariantsTelemetry';
6
+ export type RequestRejectionReason = 'host_not_allowed' | 'origin_not_allowed' | 'editor_token_on_preview';
6
7
  export type TelemetryOptions = {
7
8
  enabled?: boolean;
8
9
  source?: 'cli' | 'mcp' | 'core';
@@ -17,6 +18,7 @@ export interface LibraryOperation {
17
18
  operation: 'project_open' | 'project_rename' | 'project_remove' | 'project_pin' | 'project_unpin' | 'folder_select' | 'workspace_open' | 'preview_open' | 'thumbnail_capture' | 'direction_update' | 'navigation';
18
19
  outcome: 'completed' | 'failed';
19
20
  durationMs: number;
21
+ error?: unknown;
20
22
  }
21
23
  export interface ProfileOperation {
22
24
  stage: 'action' | 'import' | 'preparation' | 'maintenance';
@@ -25,6 +27,7 @@ export interface ProfileOperation {
25
27
  durationMs: number;
26
28
  referenceCount?: number;
27
29
  status?: 'selected' | 'empty' | 'off' | 'unavailable' | 'timeout';
30
+ error?: unknown;
28
31
  }
29
32
  export interface GuidanceOperation {
30
33
  operation: 'add' | 'update' | 'remove' | 'resolve' | 'delivery' | 'verifier';
@@ -39,12 +42,14 @@ export declare class TelemetryService {
39
42
  trackGuidanceOperation(data: GuidanceOperation): void;
40
43
  trackProfileOperation(data: ProfileOperation): void;
41
44
  trackLibraryOperation(data: LibraryOperation): void;
45
+ trackRequestRejected(reason: RequestRejectionReason): void;
42
46
  private hashTelemetryValue;
43
47
  private posthog;
44
48
  private isEnabled;
45
49
  private readonly defaultSource;
46
50
  private readonly editor?;
47
51
  private readonly identifiedAccounts;
52
+ private readonly reportedRequestRejections;
48
53
  constructor(options?: boolean | TelemetryOptions);
49
54
  private get distinctId();
50
55
  identifyUser(identity?: AccountIdentity): void;
@@ -70,9 +75,10 @@ export declare class TelemetryService {
70
75
  callerAgent?: string;
71
76
  callerModel?: string;
72
77
  callerAgentSource?: 'handoff' | 'env';
78
+ callerRunId?: string;
73
79
  designContextKind?: DesignContextKind;
74
80
  source?: 'cli' | 'mcp';
75
- } & VariantContextMetadata & BrowserMetadata): void;
81
+ } & VariantContextMetadata & BrowserMetadata & VerificationMetadata): void;
76
82
  trackAuthStarted(data: {
77
83
  surface: AuthTelemetrySurface;
78
84
  authAttemptId: string;
@@ -128,6 +134,7 @@ export declare class TelemetryService {
128
134
  stage: 'resolve_dev_server' | 'start_editor_server' | 'port_exhausted';
129
135
  failureReason: 'operation_failed' | 'port_unavailable';
130
136
  durationMs: number;
137
+ error?: unknown;
131
138
  }): void;
132
139
  trackServerStarted(data: {
133
140
  mode: 'attached' | 'static';
@@ -265,6 +272,7 @@ export declare class TelemetryService {
265
272
  exitCode?: number | null;
266
273
  signal?: string | null;
267
274
  missingDeps?: boolean;
275
+ error?: unknown;
268
276
  }): void;
269
277
  trackAgentVariantsPreviewStarted(data: {
270
278
  sessionId: string;
@@ -280,6 +288,7 @@ export declare class TelemetryService {
280
288
  hasPort: boolean;
281
289
  port?: number;
282
290
  durationMs?: number | null;
291
+ staticEntrySource?: string;
283
292
  }): void;
284
293
  trackAgentVariantsPreviewFailed(data: {
285
294
  sessionId: string;
@@ -293,6 +302,8 @@ export declare class TelemetryService {
293
302
  exitCode?: number | null;
294
303
  signal?: string | null;
295
304
  missingDeps?: boolean;
305
+ staticEntrySource?: string;
306
+ error?: unknown;
296
307
  }): void;
297
308
  trackAgentVariantsPreviewSwitchStarted(data: {
298
309
  sessionId: string;
@@ -10,10 +10,20 @@ const telemetry_1 = require("../config/telemetry");
10
10
  const telemetryPolicy_1 = require("../config/telemetryPolicy");
11
11
  const pluginMetrics_1 = require("../config/pluginMetrics");
12
12
  const telemetryContract_1 = require("../config/telemetryContract");
13
+ const failureReason_1 = require("../utils/failureReason");
13
14
  const proxy_1 = require("../config/proxy");
14
15
  const MCPVariantsTelemetry_1 = require("./MCPVariantsTelemetry");
15
16
  const errorMessage_1 = require("../utils/errorMessage");
17
+ const serverUnavailable_1 = require("../cli/serverUnavailable");
16
18
  const log = (0, logger_1.createLogger)('TelemetryService');
19
+ const serverUnavailableReasonProperties = (error) => {
20
+ const reason = typeof error === 'object' && error !== null
21
+ ? Reflect.get(error, 'serverUnavailableReason')
22
+ : undefined;
23
+ return (0, serverUnavailable_1.isServerUnavailableReason)(reason)
24
+ ? { server_unavailable_reason: reason }
25
+ : {};
26
+ };
17
27
  const KNOWN_MCP_EDITORS = new Set([
18
28
  'cursor',
19
29
  'codex',
@@ -53,13 +63,22 @@ class TelemetryService {
53
63
  ? { reference_count: data.referenceCount }
54
64
  : {}),
55
65
  ...(data.status ? { status: data.status } : {}),
66
+ ...(0, failureReason_1.failureReasonCodeProperties)(data.error),
56
67
  });
57
68
  }
58
69
  trackLibraryOperation(data) {
59
70
  this.track(`library_${data.operation}_${data.outcome}`, {
60
71
  duration_ms: data.durationMs,
72
+ ...(0, failureReason_1.failureReasonCodeProperties)(data.error),
73
+ ...serverUnavailableReasonProperties(data.error),
61
74
  });
62
75
  }
76
+ trackRequestRejected(reason) {
77
+ if (this.reportedRequestRejections.has(reason))
78
+ return;
79
+ this.reportedRequestRejections.add(reason);
80
+ this.track('server_request_rejected', { reason });
81
+ }
63
82
  hashTelemetryValue(value) {
64
83
  return (0, crypto_1.createHash)('sha256')
65
84
  .update(value)
@@ -71,6 +90,7 @@ class TelemetryService {
71
90
  defaultSource;
72
91
  editor;
73
92
  identifiedAccounts = new Set();
93
+ reportedRequestRejections = new Set();
74
94
  constructor(options = true) {
75
95
  const opts = typeof options === 'boolean' ? { enabled: options } : options;
76
96
  this.isEnabled = (opts.enabled ?? true) && (0, telemetryPolicy_1.getTelemetryMode)() !== 'off';
@@ -290,6 +310,10 @@ class TelemetryService {
290
310
  caller_agent: data.callerAgent,
291
311
  caller_model: data.callerModel,
292
312
  caller_agent_source: data.callerAgentSource,
313
+ caller_run_id: data.callerRunId,
314
+ verification_outcome: data.verificationOutcome,
315
+ verification_check_count: data.verificationCheckCount,
316
+ verification_duration_ms: data.verificationDurationMs,
293
317
  design_context_kind: data.designContextKind,
294
318
  design_context_kinds: data.contextKinds,
295
319
  context_image_count: data.contextImageCount,
@@ -372,6 +396,7 @@ class TelemetryService {
372
396
  stage: data.stage,
373
397
  failure_reason: data.failureReason,
374
398
  duration_ms: data.durationMs,
399
+ ...(0, failureReason_1.failureReasonCodeProperties)(data.error),
375
400
  });
376
401
  }
377
402
  trackServerStarted(data) {
@@ -652,6 +677,7 @@ class TelemetryService {
652
677
  exit_code: data.exitCode,
653
678
  term_signal: data.signal,
654
679
  missing_deps: data.missingDeps,
680
+ ...(0, failureReason_1.failureReasonProperties)(data.error),
655
681
  source: 'mcp',
656
682
  });
657
683
  }
@@ -673,6 +699,7 @@ class TelemetryService {
673
699
  has_port: data.hasPort,
674
700
  port: data.port,
675
701
  duration_ms: data.durationMs,
702
+ static_entry_source: data.staticEntrySource,
676
703
  source: 'mcp',
677
704
  });
678
705
  }
@@ -689,6 +716,8 @@ class TelemetryService {
689
716
  exit_code: data.exitCode,
690
717
  term_signal: data.signal,
691
718
  missing_deps: data.missingDeps,
719
+ static_entry_source: data.staticEntrySource,
720
+ ...(0, failureReason_1.failureReasonProperties)(data.error),
692
721
  source: 'mcp',
693
722
  });
694
723
  }
@@ -3,6 +3,7 @@ import type { GuidanceDocument } from '../types/guidance';
3
3
  import { type ReferenceImage } from './referenceImages';
4
4
  import { type VariantReference } from '../types/variant-reference';
5
5
  import type { VariantHistoryStatus, VariantHistoryKind, PersistVariantPreview, VariantServeSpec, VariantDesignSource, VariantDeployment, VariantCanvasDeployment, VariantHistoryManifest } from '../types/variant-history';
6
+ import type { DirectionRef } from '../types/direction-ref';
6
7
  export type { VariantHistoryStatus, VariantHistoryKind, VariantHistoryPreview, PersistVariantPreview, VariantTreePointer, VariantBasePointer, DevServerRecipe, VariantServeSpec, VariantHistoryArtifact, VariantDesignSource, VariantDeployment, VariantCanvasDeployment, VariantHistoryManifest, VariantHistorySessionFile, } from '../types/variant-history';
7
8
  import type { BundleMetadataStore } from '../storage/library/BundleMetadataStore';
8
9
  import { TreeStore } from './TreeStore';
@@ -13,6 +14,7 @@ export interface PersistVariantArgs {
13
14
  sessionId: string;
14
15
  variantId: string;
15
16
  requestId?: string;
17
+ directionRef?: DirectionRef;
16
18
  label: string;
17
19
  brief: string;
18
20
  references?: VariantReference[];
@@ -116,6 +118,12 @@ export declare class VariantHistoryService {
116
118
  label?: string;
117
119
  runLabel?: string;
118
120
  }): Promise<void>;
121
+ assignDirectionRef(args: {
122
+ projectPath: string;
123
+ sessionId: string;
124
+ variantId: string;
125
+ directionRef: DirectionRef;
126
+ }): Promise<void>;
119
127
  renameRun(args: {
120
128
  projectPath: string;
121
129
  sessionId: string;
@@ -203,6 +203,7 @@ class VariantHistoryService {
203
203
  let preservedDestinationPath;
204
204
  let preservedCreatedAt;
205
205
  let preservedRequestId;
206
+ let preservedDirectionRef;
206
207
  let preservedReferences;
207
208
  let preservedPreviewRoutes;
208
209
  let preservedTree;
@@ -219,6 +220,7 @@ class VariantHistoryService {
219
220
  });
220
221
  preservedCreatedAt = prior.createdAt;
221
222
  preservedRequestId = prior.requestId;
223
+ preservedDirectionRef = prior.directionRef;
222
224
  preservedReferences = prior.references;
223
225
  preservedPreviewRoutes = prior.previewRoutes;
224
226
  preservedTree = prior.tree;
@@ -363,6 +365,9 @@ class VariantHistoryService {
363
365
  ...((args.requestId ?? preservedRequestId)
364
366
  ? { requestId: args.requestId ?? preservedRequestId }
365
367
  : {}),
368
+ ...((preservedDirectionRef ?? args.directionRef)
369
+ ? { directionRef: preservedDirectionRef ?? args.directionRef }
370
+ : {}),
366
371
  label: args.label,
367
372
  brief: args.brief,
368
373
  references: (0, variant_reference_1.mergeVariantReferences)(references),
@@ -527,6 +532,41 @@ class VariantHistoryService {
527
532
  manifest,
528
533
  });
529
534
  }
535
+ async assignDirectionRef(args) {
536
+ assertSafeId(args.sessionId, 'sessionId');
537
+ assertSafeId(args.variantId, 'variantId');
538
+ const bundle = this.bundleFor(args.projectPath);
539
+ if (bundle) {
540
+ bundle.updateVariant({
541
+ ...args,
542
+ update: (manifest) => {
543
+ manifest.directionRef ??= args.directionRef;
544
+ },
545
+ });
546
+ return;
547
+ }
548
+ const manifestPath = path_1.default.join(this.variantDir(args.projectPath, args.sessionId, args.variantId), MANIFEST_FILENAME);
549
+ let manifest;
550
+ try {
551
+ const raw = await promises_1.default.readFile(manifestPath, 'utf8');
552
+ manifest = JSON.parse(raw);
553
+ }
554
+ catch (err) {
555
+ const code = (0, errnoCode_1.errnoCode)(err);
556
+ if (code !== 'ENOENT') {
557
+ log.warn(`assignDirectionRef: manifest read failed at ${manifestPath} (session ${args.sessionId} variant ${args.variantId})`, err);
558
+ }
559
+ return;
560
+ }
561
+ if (manifest.directionRef)
562
+ return;
563
+ manifest.directionRef = args.directionRef;
564
+ await writeManifestFile(manifestPath, manifest);
565
+ await this.projectManifestToIndex({
566
+ projectPath: args.projectPath,
567
+ manifest,
568
+ });
569
+ }
530
570
  async renameRun(args) {
531
571
  const entries = await this.listVariants({ projectPath: args.projectPath });
532
572
  const targets = entries.filter((entry) => {
@@ -23,6 +23,7 @@ export declare class WorktreeManager {
23
23
  createWorktrees(sessionId: string, count: number, instanceKeyPrefix?: string): Promise<string[]>;
24
24
  forkWorktreesFrom(sourceWorktreePath: string, sessionId: string, count: number, instanceKeyPrefix?: string): Promise<string[]>;
25
25
  getDiff(worktreePath: string): Promise<string>;
26
+ getChangedFiles(worktreePath: string): Promise<string[]>;
26
27
  getFreePort(): Promise<number>;
27
28
  findFreePortFrom(startPort: number, scanWindow?: number): Promise<number>;
28
29
  releasePort(port: number): void;
@@ -22,6 +22,7 @@ const ProjectPackageManager_1 = require("./ProjectPackageManager");
22
22
  const OperatingSystemServices_1 = require("./OperatingSystemServices");
23
23
  const errnoCode_1 = require("../utils/errnoCode");
24
24
  const errorMessage_1 = require("../utils/errorMessage");
25
+ const failureReason_1 = require("../utils/failureReason");
25
26
  const log = (0, logger_1.createLogger)('WorktreeManager');
26
27
  const DEV_SERVER_READY_INACTIVITY_MS = 30_000;
27
28
  const DEV_SERVER_READY_MAX_MS = 120_000;
@@ -275,6 +276,18 @@ class WorktreeManager {
275
276
  await git.raw(['add', '--intent-to-add', '.']).catch(() => { });
276
277
  return git.diff(['--binary', '--full-index', 'HEAD']);
277
278
  }
279
+ async getChangedFiles(worktreePath) {
280
+ const git = (0, simple_git_1.simpleGit)(worktreePath, GIT_OPTS);
281
+ await git.raw(['add', '--intent-to-add', '.']).catch(() => { });
282
+ const names = await git.raw([
283
+ 'diff',
284
+ '--name-only',
285
+ '--diff-filter=d',
286
+ '-z',
287
+ 'HEAD',
288
+ ]);
289
+ return names.split('\0').filter(Boolean);
290
+ }
278
291
  getFreePort() {
279
292
  return new Promise((resolve, reject) => {
280
293
  const server = net_1.default.createServer();
@@ -403,6 +416,10 @@ class WorktreeManager {
403
416
  detail,
404
417
  exitCode: term.exited?.code ?? null,
405
418
  signal: term.exited?.signal ?? null,
419
+ reasonCode: term.spawnError
420
+ ? (0, failureReason_1.failureReasonCode)(term.spawnError)
421
+ : undefined,
422
+ summary: term.spawnError ? message : undefined,
406
423
  });
407
424
  };
408
425
  const hardDeadline = Date.now() + DEV_SERVER_READY_MAX_MS;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.createAgentVariantsOrchestrator = exports.withVariantsSessionReplayLinking = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
4
9
  const index_core_1 = require("../index-core");
5
10
  const agent_variants_1 = require("../agent-variants");
6
11
  const devServerCommand_1 = require("../utils/devServerCommand");
@@ -69,11 +74,13 @@ const createAgentVariantsOrchestrator = (options) => {
69
74
  targetPath: projectPath,
70
75
  entryPath: options.staticEntry,
71
76
  }).entryPath;
72
- log.info(`Resolved env for variants session ${sessionId}: static/${entryPath}`);
77
+ const hasEntry = options.staticEntry !== undefined ||
78
+ fs_1.default.existsSync(path_1.default.join(projectPath, entryPath));
79
+ log.info(`Resolved env for variants session ${sessionId}: static/${hasEntry ? entryPath : '(no entry page)'}`);
73
80
  return {
74
81
  projectPath,
75
82
  framework,
76
- entryPath,
83
+ ...(hasEntry ? { entryPath } : {}),
77
84
  };
78
85
  }
79
86
  const packageManager = await detection.detectPackageManager(projectPath);
@@ -0,0 +1,21 @@
1
+ import type { DirectionAddress, DirectionCandidate, DirectionRef, DirectionResolution, DirectionSearchAddress } from '../types/direction-ref';
2
+ import type { VariantHistoryManifest, VariantHistoryStatus } from '../types/variant-history';
3
+ export declare const isDirectionActive: (status: VariantHistoryStatus) => boolean;
4
+ type DirectionRefSource = {
5
+ manifest: Pick<VariantHistoryManifest, 'sessionId' | 'variantId' | 'label' | 'createdAt' | 'directionRef'>;
6
+ };
7
+ export declare const slugifyDirectionLabel: (label: string) => string;
8
+ export declare const nextDirectionRef: (args: {
9
+ label: string;
10
+ taken: ReadonlySet<string>;
11
+ }) => DirectionRef;
12
+ export declare const withDirectionRefs: <Entry extends DirectionRefSource>(entries: readonly Entry[]) => Array<Entry & {
13
+ directionRef: DirectionRef;
14
+ }>;
15
+ export declare const parseDirectionAddress: (raw: string) => DirectionAddress | null;
16
+ export declare const resolveDirectionAddress: (args: {
17
+ address: DirectionSearchAddress;
18
+ candidates: readonly DirectionCandidate[];
19
+ }) => DirectionResolution;
20
+ export {};
21
+ //# sourceMappingURL=directionRefs.d.ts.map