rivet-design 0.10.7 → 0.10.8
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.
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -23
- package/dist/index.js.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts +24 -0
- package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.js +114 -35
- package/dist/mcp/agent-variants/WorktreeOrchestrator.js.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.d.ts +1 -0
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.d.ts.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.js +17 -3
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.js.map +1 -1
- package/dist/mcp/agent-variants/contracts.d.ts +12 -0
- package/dist/mcp/agent-variants/contracts.d.ts.map +1 -1
- package/dist/mcp/agent-variants/contracts.js.map +1 -1
- package/dist/mcp/agent-variants/index.d.ts +1 -1
- package/dist/mcp/agent-variants/index.d.ts.map +1 -1
- package/dist/mcp/agent-variants/index.js.map +1 -1
- package/dist/mcp/agent-variants/pinterestSourceContext.d.ts.map +1 -1
- package/dist/mcp/agent-variants/pinterestSourceContext.js +11 -1
- package/dist/mcp/agent-variants/pinterestSourceContext.js.map +1 -1
- package/dist/mcp/agent-variants/tools.d.ts.map +1 -1
- package/dist/mcp/agent-variants/tools.js +7 -5
- package/dist/mcp/agent-variants/tools.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +13 -12
- package/dist/mcp/server.js.map +1 -1
- package/dist/routes/agentVariants.d.ts +2 -1
- package/dist/routes/agentVariants.d.ts.map +1 -1
- package/dist/routes/agentVariants.js +267 -19
- package/dist/routes/agentVariants.js.map +1 -1
- package/dist/routes/design.d.ts.map +1 -1
- package/dist/routes/design.js +0 -122
- package/dist/routes/design.js.map +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +11 -6
- package/dist/server.js.map +1 -1
- package/dist/services/AgentSessionService.d.ts +5 -1
- package/dist/services/AgentSessionService.d.ts.map +1 -1
- package/dist/services/AgentSessionService.js +11 -4
- package/dist/services/AgentSessionService.js.map +1 -1
- package/dist/services/InlineVariantGenerationService.d.ts +2 -3
- package/dist/services/InlineVariantGenerationService.d.ts.map +1 -1
- package/dist/services/InlineVariantGenerationService.js +7 -5
- package/dist/services/InlineVariantGenerationService.js.map +1 -1
- package/dist/services/IntegrationsClient.d.ts +20 -0
- package/dist/services/IntegrationsClient.d.ts.map +1 -1
- package/dist/services/IntegrationsClient.js +82 -24
- package/dist/services/IntegrationsClient.js.map +1 -1
- package/dist/services/TelemetryService.d.ts +2 -0
- package/dist/services/TelemetryService.d.ts.map +1 -1
- package/dist/services/TelemetryService.js +2 -0
- package/dist/services/TelemetryService.js.map +1 -1
- package/dist/services/VariantHistoryService.d.ts +8 -0
- package/dist/services/VariantHistoryService.d.ts.map +1 -1
- package/dist/services/VariantHistoryService.js +23 -0
- package/dist/services/VariantHistoryService.js.map +1 -1
- package/dist/services/VariantRunService.d.ts +56 -0
- package/dist/services/VariantRunService.d.ts.map +1 -0
- package/dist/services/VariantRunService.js +56 -0
- package/dist/services/VariantRunService.js.map +1 -0
- package/dist/services/VariantsRuntime.d.ts +22 -0
- package/dist/services/VariantsRuntime.d.ts.map +1 -0
- package/dist/services/VariantsRuntime.js +32 -0
- package/dist/services/VariantsRuntime.js.map +1 -0
- package/dist/services/VisualVariantAgentRunner.d.ts +20 -0
- package/dist/services/VisualVariantAgentRunner.d.ts.map +1 -0
- package/dist/services/VisualVariantAgentRunner.js +66 -0
- package/dist/services/VisualVariantAgentRunner.js.map +1 -0
- package/dist/services/WorktreeManager.d.ts +34 -0
- package/dist/services/WorktreeManager.d.ts.map +1 -1
- package/dist/services/WorktreeManager.js +172 -23
- package/dist/services/WorktreeManager.js.map +1 -1
- package/dist/services/createAgentVariantsOrchestrator.d.ts.map +1 -1
- package/dist/services/createAgentVariantsOrchestrator.js +2 -0
- package/dist/services/createAgentVariantsOrchestrator.js.map +1 -1
- package/dist/utils/devServerCommand.d.ts +11 -4
- package/dist/utils/devServerCommand.d.ts.map +1 -1
- package/dist/utils/devServerCommand.js +17 -8
- package/dist/utils/devServerCommand.js.map +1 -1
- package/dist/utils/devServerError.d.ts +34 -0
- package/dist/utils/devServerError.d.ts.map +1 -0
- package/dist/utils/devServerError.js +39 -0
- package/dist/utils/devServerError.js.map +1 -0
- package/dist/utils/elementRefToContext.d.ts +4 -0
- package/dist/utils/elementRefToContext.d.ts.map +1 -0
- package/dist/utils/elementRefToContext.js +63 -0
- package/dist/utils/elementRefToContext.js.map +1 -0
- package/package.json +3 -1
- package/src/ui/dist/assets/main-WqlDU4Ou.js +645 -0
- package/src/ui/dist/assets/main-auZA25j4.css +1 -0
- package/src/ui/dist/index.html +2 -2
- package/dist/services/CommentVariationService.d.ts +0 -34
- package/dist/services/CommentVariationService.d.ts.map +0 -1
- package/dist/services/CommentVariationService.js +0 -136
- package/dist/services/CommentVariationService.js.map +0 -1
- package/dist/services/VariantCodeGeneratorService.d.ts +0 -39
- package/dist/services/VariantCodeGeneratorService.d.ts.map +0 -1
- package/dist/services/VariantCodeGeneratorService.js +0 -109
- package/dist/services/VariantCodeGeneratorService.js.map +0 -1
- package/src/ui/dist/assets/main-DUIrSkV3.css +0 -1
- package/src/ui/dist/assets/main-DYpxGvCu.js +0 -646
|
@@ -13,6 +13,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
13
13
|
const child_process_1 = require("child_process");
|
|
14
14
|
const simple_git_1 = require("simple-git");
|
|
15
15
|
const logger_1 = require("../../utils/logger");
|
|
16
|
+
const devServerError_1 = require("../../utils/devServerError");
|
|
16
17
|
const errors_1 = require("./errors");
|
|
17
18
|
const createProjectArtifacts_1 = require("./createProjectArtifacts");
|
|
18
19
|
const contracts_1 = require("./contracts");
|
|
@@ -24,6 +25,9 @@ const previewQa_1 = require("./previewQa");
|
|
|
24
25
|
const VariantHistoryService_1 = require("../../services/VariantHistoryService");
|
|
25
26
|
const log = (0, logger_1.createLogger)('AgentVariantsOrchestrator');
|
|
26
27
|
const FRESH_DEV_SERVER_HOST = '127.0.0.1';
|
|
28
|
+
// Fresh worktrees run the Vite React template, whose dev server defaults to
|
|
29
|
+
// 5173. Used as the scan start when allocating a fresh variant's preview port.
|
|
30
|
+
const FRESH_DEV_SERVER_DEFAULT_PORT = 5173;
|
|
27
31
|
const DESIGN_CONTEXT_ROUTE_SEGMENT = 'design-md';
|
|
28
32
|
const DESIGN_CONTEXT_VIEW_SEGMENT = 'view';
|
|
29
33
|
// Hard ceiling on worktree provisioning so a slow/large host project can never
|
|
@@ -324,8 +328,7 @@ class AgentVariantsOrchestrator {
|
|
|
324
328
|
this.variantHistory = deps.variantHistory ?? new VariantHistoryService_1.VariantHistoryService();
|
|
325
329
|
this.startStaticPreviewServerImpl =
|
|
326
330
|
deps.startStaticPreviewServer ?? StaticPreviewServer_1.startStaticPreviewServer;
|
|
327
|
-
this.provisionTimeoutMs =
|
|
328
|
-
deps.provisionTimeoutMs ?? PROVISION_TIMEOUT_MS;
|
|
331
|
+
this.provisionTimeoutMs = deps.provisionTimeoutMs ?? PROVISION_TIMEOUT_MS;
|
|
329
332
|
}
|
|
330
333
|
// --- Pure delegations (no side effects) ---------------------------------
|
|
331
334
|
propose(args) {
|
|
@@ -634,6 +637,16 @@ class AgentVariantsOrchestrator {
|
|
|
634
637
|
const isSucceeded = variant.status === 'succeeded';
|
|
635
638
|
const qaFailed = qa?.status === 'failed';
|
|
636
639
|
const canView = Boolean(preview) || (isSucceeded && Boolean(port));
|
|
640
|
+
// A succeeded variant with no live preview whose dev server we tried and
|
|
641
|
+
// failed to start: surface the cause so the UI can show an accurate
|
|
642
|
+
// per-direction message instead of the generic disconnected overlay.
|
|
643
|
+
const previewFailure = resources?.previewFailures.get(variant.workItemId);
|
|
644
|
+
const previewUnavailable = !canView && isSucceeded && previewFailure
|
|
645
|
+
? {
|
|
646
|
+
reason: previewFailure.reason,
|
|
647
|
+
...(previewFailure.portInUse ? { portInUse: true } : {}),
|
|
648
|
+
}
|
|
649
|
+
: undefined;
|
|
637
650
|
const canCommit = isSucceeded && !qaFailed;
|
|
638
651
|
const commitDisabledReason = qaFailed
|
|
639
652
|
? (qa?.summary ?? 'Variant failed QA')
|
|
@@ -644,6 +657,7 @@ class AgentVariantsOrchestrator {
|
|
|
644
657
|
...(preview ? { preview } : {}),
|
|
645
658
|
port,
|
|
646
659
|
...(qa ? { qa } : {}),
|
|
660
|
+
...(previewUnavailable ? { previewUnavailable } : {}),
|
|
647
661
|
actions: {
|
|
648
662
|
view: canView
|
|
649
663
|
? { enabled: true }
|
|
@@ -2267,40 +2281,84 @@ class AgentVariantsOrchestrator {
|
|
|
2267
2281
|
// Bring up a dev server in the variant's worktree so the user can cycle
|
|
2268
2282
|
// through live variants in the iframe via the chip. Failures here are
|
|
2269
2283
|
// logged but non-fatal — the user can still pick by reading the diff.
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
record.port
|
|
2285
|
-
|
|
2286
|
-
|
|
2284
|
+
//
|
|
2285
|
+
// Pick a sensible port near the framework's default (3000 for Next, 5173
|
|
2286
|
+
// for Vite) and inject it via PORT + the CLI flag (see buildDevServerCommand)
|
|
2287
|
+
// so the server actually binds it — that's what moves a preview off a port
|
|
2288
|
+
// the user's own dev server already holds instead of colliding on it. On a
|
|
2289
|
+
// retry we scan past the port we just tried, so a transient race or a
|
|
2290
|
+
// briefly-held port resolves onto the next free one.
|
|
2291
|
+
const startPort = await this.resolveDevServerStartPort(sessionId, isFresh);
|
|
2292
|
+
let scanFrom = startPort;
|
|
2293
|
+
const maxAttempts = 2;
|
|
2294
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
2295
|
+
let port;
|
|
2296
|
+
try {
|
|
2297
|
+
port = await this.worktrees.findFreePortFrom(scanFrom);
|
|
2298
|
+
const dev = await this.resolveDevServer(sessionId, record.worktreePath, port, isFresh);
|
|
2299
|
+
const proc = await this.worktrees.startDevServer(dev.cwd, port, dev.cmd, dev.args, dev.env);
|
|
2300
|
+
record.port = port;
|
|
2301
|
+
record.devServerProcess = proc;
|
|
2302
|
+
// If the dev server dies on its own (crash, OOM, Vite hard-fail),
|
|
2303
|
+
// clear the port so the iframe stops routing the chip onto a dead
|
|
2304
|
+
// socket. Without this the proxy retargets onto an unreachable port
|
|
2305
|
+
// and the chip shows "upstream_unreachable" instead of the accurate
|
|
2306
|
+
// "Preview is unavailable for this variant".
|
|
2307
|
+
proc.once('exit', (code, signal) => {
|
|
2308
|
+
if (record.devServerProcess !== proc)
|
|
2309
|
+
return;
|
|
2310
|
+
record.port = undefined;
|
|
2311
|
+
record.devServerProcess = undefined;
|
|
2312
|
+
log.warn(`Variant ${workItemId} dev server exited unexpectedly (code=${code ?? 'null'}, signal=${signal ?? 'null'}); preview disabled`);
|
|
2313
|
+
this.emitChange();
|
|
2314
|
+
});
|
|
2287
2315
|
this.emitChange();
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
port
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2316
|
+
trackFreshDevServerStarted(this.telemetry, {
|
|
2317
|
+
sessionId,
|
|
2318
|
+
variantId: workItemId,
|
|
2319
|
+
port,
|
|
2320
|
+
});
|
|
2321
|
+
log.info(`Variant ${workItemId} dev server up on port ${port} (worktree ${record.worktreePath}; cmd: ${dev.cmd} ${dev.args.join(' ')})`);
|
|
2322
|
+
return;
|
|
2323
|
+
}
|
|
2324
|
+
catch (err) {
|
|
2325
|
+
const portInUse = (0, devServerError_1.isDevServerStartError)(err) && err.portInUse;
|
|
2326
|
+
const reason = (0, devServerError_1.isDevServerStartError)(err) ? err.reason : 'unknown';
|
|
2327
|
+
const willRetry = portInUse && attempt < maxAttempts;
|
|
2328
|
+
// Next attempt scans past the port we just tried so we don't re-pick a
|
|
2329
|
+
// port that's persistently held (vs. a transient race that freed it).
|
|
2330
|
+
scanFrom = (port ?? scanFrom) + 1;
|
|
2331
|
+
log.warn(`Failed to start dev server for variant ${workItemId} on port ${port ?? 'unallocated'} ` +
|
|
2332
|
+
`(attempt ${attempt}/${maxAttempts}, reason=${reason}, portInUse=${portInUse})` +
|
|
2333
|
+
(willRetry
|
|
2334
|
+
? '; retrying on a fresh port'
|
|
2335
|
+
: '; live preview disabled for this variant'), err);
|
|
2336
|
+
if (willRetry)
|
|
2337
|
+
continue;
|
|
2338
|
+
// Record the failure so getVariants can tell the UI this direction's
|
|
2339
|
+
// preview couldn't start (and why), then push a snapshot so the chip
|
|
2340
|
+
// updates from "loading" to the accurate per-direction message.
|
|
2341
|
+
this.resources.get(sessionId)?.previewFailures.set(workItemId, {
|
|
2342
|
+
reason,
|
|
2343
|
+
portInUse,
|
|
2344
|
+
});
|
|
2345
|
+
trackFreshDevServerFailed(this.telemetry, {
|
|
2346
|
+
sessionId,
|
|
2347
|
+
variantId: workItemId,
|
|
2348
|
+
errorCode: 'DEV_SERVER_START_FAILED',
|
|
2349
|
+
reason,
|
|
2350
|
+
portInUse,
|
|
2351
|
+
});
|
|
2352
|
+
this.emitChange();
|
|
2353
|
+
return;
|
|
2354
|
+
}
|
|
2355
|
+
finally {
|
|
2356
|
+
// Hand the reservation back whether the dev server bound the port
|
|
2357
|
+
// (now visible to the listener check, so the reservation is redundant),
|
|
2358
|
+
// it failed (port free again), or we're about to retry on the next port.
|
|
2359
|
+
if (port !== undefined)
|
|
2360
|
+
this.worktrees.releasePort?.(port);
|
|
2361
|
+
}
|
|
2304
2362
|
}
|
|
2305
2363
|
}
|
|
2306
2364
|
async handleStaticPreviewRefinement(args) {
|
|
@@ -2730,6 +2788,24 @@ class AgentVariantsOrchestrator {
|
|
|
2730
2788
|
return undefined;
|
|
2731
2789
|
}
|
|
2732
2790
|
}
|
|
2791
|
+
/**
|
|
2792
|
+
* The port to start scanning from when allocating a variant's preview dev
|
|
2793
|
+
* server. Fresh worktrees run the Vite template (5173); existing projects use
|
|
2794
|
+
* their detected framework's default (3000 for Next, etc.), falling back to
|
|
2795
|
+
* 3000 if detection fails. Scanning upward from here lands the preview on a
|
|
2796
|
+
* sensible, predictable port near the project's normal one.
|
|
2797
|
+
*/
|
|
2798
|
+
async resolveDevServerStartPort(sessionId, isFresh) {
|
|
2799
|
+
if (isFresh)
|
|
2800
|
+
return FRESH_DEV_SERVER_DEFAULT_PORT;
|
|
2801
|
+
try {
|
|
2802
|
+
const env = await this.resolveEnv(sessionId);
|
|
2803
|
+
return env.defaultPort ?? 3000;
|
|
2804
|
+
}
|
|
2805
|
+
catch {
|
|
2806
|
+
return 3000;
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2733
2809
|
/**
|
|
2734
2810
|
* Resolve dev server invocation for a worktree. Fresh-project worktrees
|
|
2735
2811
|
* always use the Vite template's npm command at the worktree root; existing
|
|
@@ -3190,6 +3266,7 @@ class AgentVariantsOrchestrator {
|
|
|
3190
3266
|
startedAt: Date.now(),
|
|
3191
3267
|
leasedAt: new Map(),
|
|
3192
3268
|
qaResults: new Map(),
|
|
3269
|
+
previewFailures: new Map(),
|
|
3193
3270
|
vitePreservedSiblings: false,
|
|
3194
3271
|
};
|
|
3195
3272
|
this.resources.set(sessionId, r);
|
|
@@ -3945,6 +4022,8 @@ const trackFreshDevServerFailed = (telemetry, data) => {
|
|
|
3945
4022
|
session_id: data.sessionId,
|
|
3946
4023
|
variant_id: data.variantId,
|
|
3947
4024
|
error_code: data.errorCode,
|
|
4025
|
+
failure_reason: data.reason,
|
|
4026
|
+
port_in_use: data.portInUse,
|
|
3948
4027
|
});
|
|
3949
4028
|
};
|
|
3950
4029
|
const trackStaticPreviewCompleted = (telemetry, data) => {
|