rivet-design 0.11.13 → 0.11.15
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/config/flags.d.ts +7 -1
- package/dist/config/flags.d.ts.map +1 -1
- package/dist/config/flags.js +9 -1
- package/dist/config/flags.js.map +1 -1
- package/dist/config/proxy.d.ts +6 -0
- package/dist/config/proxy.d.ts.map +1 -1
- package/dist/config/proxy.js +36 -19
- package/dist/config/proxy.js.map +1 -1
- package/dist/install/harnesses.d.ts.map +1 -1
- package/dist/install/harnesses.js +78 -42
- package/dist/install/harnesses.js.map +1 -1
- package/dist/mcp/agent-variants/SessionStore.d.ts.map +1 -1
- package/dist/mcp/agent-variants/SessionStore.js +1 -2
- package/dist/mcp/agent-variants/SessionStore.js.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts +29 -0
- package/dist/mcp/agent-variants/WorktreeOrchestrator.d.ts.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.js +474 -10
- package/dist/mcp/agent-variants/WorktreeOrchestrator.js.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.d.ts.map +1 -1
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.js +64 -0
- package/dist/mcp/agent-variants/WorktreeOrchestrator.testHelpers.js.map +1 -1
- package/dist/mcp/agent-variants/contracts.d.ts +380 -378
- package/dist/mcp/agent-variants/contracts.d.ts.map +1 -1
- package/dist/mcp/agent-variants/contracts.js +13 -2
- package/dist/mcp/agent-variants/contracts.js.map +1 -1
- package/dist/mcp/agent-variants/createZeroToOneTool.d.ts.map +1 -1
- package/dist/mcp/agent-variants/createZeroToOneTool.js +1 -2
- package/dist/mcp/agent-variants/createZeroToOneTool.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 +2 -1
- package/dist/mcp/agent-variants/index.js.map +1 -1
- package/dist/mcp/agent-variants/tools.d.ts +29 -1
- package/dist/mcp/agent-variants/tools.d.ts.map +1 -1
- package/dist/mcp/agent-variants/tools.js +142 -13
- package/dist/mcp/agent-variants/tools.js.map +1 -1
- package/dist/mcp/auth/tools.d.ts.map +1 -1
- package/dist/mcp/auth/tools.js +68 -2
- package/dist/mcp/auth/tools.js.map +1 -1
- package/dist/mcp/server.d.ts +54 -2
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +191 -42
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/toolAnalytics.d.ts +15 -0
- package/dist/mcp/toolAnalytics.d.ts.map +1 -0
- package/dist/mcp/toolAnalytics.js +87 -0
- package/dist/mcp/toolAnalytics.js.map +1 -0
- package/dist/onboarding/signin.d.ts +10 -0
- package/dist/onboarding/signin.d.ts.map +1 -1
- package/dist/onboarding/signin.js +41 -3
- package/dist/onboarding/signin.js.map +1 -1
- package/dist/routes/agentVariants.d.ts +2 -2
- package/dist/routes/agentVariants.d.ts.map +1 -1
- package/dist/routes/agentVariants.js +12 -7
- package/dist/routes/agentVariants.js.map +1 -1
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +153 -2
- package/dist/routes/mcp.js.map +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +52 -37
- package/dist/server.js.map +1 -1
- package/dist/services/BridgeBatchPipeline.d.ts +4 -0
- package/dist/services/BridgeBatchPipeline.d.ts.map +1 -1
- package/dist/services/BridgeBatchPipeline.js +18 -1
- package/dist/services/BridgeBatchPipeline.js.map +1 -1
- package/dist/services/MCPOnboardingTelemetry.d.ts +41 -0
- package/dist/services/MCPOnboardingTelemetry.d.ts.map +1 -0
- package/dist/services/MCPOnboardingTelemetry.js +158 -0
- package/dist/services/MCPOnboardingTelemetry.js.map +1 -0
- package/dist/services/MCPVariantsTelemetry.d.ts +59 -0
- package/dist/services/MCPVariantsTelemetry.d.ts.map +1 -0
- package/dist/services/MCPVariantsTelemetry.js +153 -0
- package/dist/services/MCPVariantsTelemetry.js.map +1 -0
- package/dist/services/SessionBridgeService.d.ts +28 -7
- package/dist/services/SessionBridgeService.d.ts.map +1 -1
- package/dist/services/SessionBridgeService.js +46 -9
- package/dist/services/SessionBridgeService.js.map +1 -1
- package/dist/services/TelemetryService.d.ts +108 -0
- package/dist/services/TelemetryService.d.ts.map +1 -1
- package/dist/services/TelemetryService.js +269 -1
- package/dist/services/TelemetryService.js.map +1 -1
- package/dist/services/WorktreeManager.d.ts.map +1 -1
- package/dist/services/WorktreeManager.js +3 -0
- package/dist/services/WorktreeManager.js.map +1 -1
- package/dist/utils/skills/claude-skill.js +1 -1
- package/dist/utils/skills/shared-variants-protocol.d.ts +1 -1
- package/dist/utils/skills/shared-variants-protocol.d.ts.map +1 -1
- package/dist/utils/skills/shared-variants-protocol.js +4 -4
- package/dist/utils/skills/shared-variants-protocol.js.map +1 -1
- package/package.json +2 -2
- package/src/ui/dist/assets/main-RWAqAMXv.css +1 -0
- package/src/ui/dist/assets/main-qwlwk15E.js +655 -0
- package/src/ui/dist/index.html +2 -2
- package/src/ui/dist/assets/main-DREt3GGU.css +0 -1
- package/src/ui/dist/assets/main-Dt7ShmjM.js +0 -655
package/dist/mcp/server.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { type DevServerHealth } from '../services/SessionBridgeService';
|
|
1
|
+
import { SessionBridgeService, type ActiveLeaseMetadata, type DevServerHealth } from '../services/SessionBridgeService';
|
|
2
2
|
import type { LeasedBatchRecord } from '../services/BridgeBatchPipeline';
|
|
3
|
+
import { TelemetryService } from '../services/TelemetryService';
|
|
3
4
|
import { type DroppedRefinement, type VisualEditorWatchAction } from './agent-variants';
|
|
4
5
|
import { type ImageContent } from './changeBatchClassification';
|
|
5
6
|
import type { ChangeRequest, CommentChangeItem, StaticPreviewChangeTarget } from '../types/change-request-types';
|
|
7
|
+
import type { WorkItemStatus } from './agent-variants/contracts';
|
|
6
8
|
import type { RivetMcpHandle } from './types';
|
|
7
9
|
type McpStdioLoggingDeps = {
|
|
8
10
|
env: Partial<Pick<NodeJS.ProcessEnv, 'RIVET_LOG_LEVEL'>>;
|
|
@@ -53,7 +55,7 @@ type StaticPreviewRefineTargetInstruction = {
|
|
|
53
55
|
requestId?: string;
|
|
54
56
|
};
|
|
55
57
|
export declare const buildMixedVariantBatchResponse: (rejectedRequest: ChangeRequest | null | undefined) => MCPTextResponse;
|
|
56
|
-
export declare const buildVariantRequestBatchResponse: (intent: ChangeRequest | null | undefined, lease?: LeasedBatchRecord) => MCPChangeResponse;
|
|
58
|
+
export declare const buildVariantRequestBatchResponse: (intent: ChangeRequest | null | undefined, lease?: LeasedBatchRecord, projectPath?: string | null) => MCPChangeResponse;
|
|
57
59
|
/**
|
|
58
60
|
* Resolves whether `watch_for_changes` / `get_pending_changes` should pass
|
|
59
61
|
* `requestId` into lease pickup. requestId is only for idempotent re-poll of
|
|
@@ -64,6 +66,14 @@ export declare const resolveLeasePickupRequestId: (args: {
|
|
|
64
66
|
ack_batch?: boolean;
|
|
65
67
|
requestId?: string;
|
|
66
68
|
}) => string | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Lease work for a poll. A matching requestId keeps idempotent re-polls on the
|
|
71
|
+
* same in-flight batch; a stale requestId must not strand unrelated queued work.
|
|
72
|
+
*/
|
|
73
|
+
export declare const leaseAvailableBatchForPoll: (args: {
|
|
74
|
+
bridge: SessionBridgeService;
|
|
75
|
+
requestId?: string;
|
|
76
|
+
}) => LeasedBatchRecord | null;
|
|
67
77
|
/**
|
|
68
78
|
* Builds a poll response for an empty apply queue.
|
|
69
79
|
*/
|
|
@@ -71,6 +81,7 @@ export declare const buildNoPendingChangesResponse: (params?: {
|
|
|
71
81
|
message?: string;
|
|
72
82
|
devServerHealth?: DevServerHealth | null;
|
|
73
83
|
pendingVariantRequests?: number;
|
|
84
|
+
activeLeases?: ActiveLeaseMetadata[];
|
|
74
85
|
}) => MCPTextResponse;
|
|
75
86
|
/**
|
|
76
87
|
* Builds a poll response for a normal apply batch.
|
|
@@ -90,7 +101,48 @@ export declare const buildLeasedVariantResponse: (params: {
|
|
|
90
101
|
isFreshStaticPreviewVariantRequestBatch: (intent: ChangeRequest) => boolean;
|
|
91
102
|
handleStaticPreviewRefineBatch: (intent: ChangeRequest, lease: LeasedBatchRecord) => MCPChangeResponse;
|
|
92
103
|
withPendingVariantRequests: (response: MCPChangeResponse) => MCPChangeResponse;
|
|
104
|
+
projectPath?: string | null;
|
|
93
105
|
}) => MCPChangeResponse;
|
|
106
|
+
type VariantRequestLeaseTracker = {
|
|
107
|
+
claim(args: {
|
|
108
|
+
requestId?: string;
|
|
109
|
+
sessionId: string;
|
|
110
|
+
workItemIds: string[];
|
|
111
|
+
}): void;
|
|
112
|
+
complete(args: {
|
|
113
|
+
sessionId: string;
|
|
114
|
+
workItemId: string;
|
|
115
|
+
status: WorkItemStatus;
|
|
116
|
+
requeuedForRegeneration?: boolean;
|
|
117
|
+
aborted?: boolean;
|
|
118
|
+
}): void;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Tracks a UI-originated variant request lease across the variant work items
|
|
122
|
+
* that satisfy it, releasing the bridge lease once the whole batch has
|
|
123
|
+
* finished.
|
|
124
|
+
*/
|
|
125
|
+
export declare const createVariantRequestLeaseTracker: (params: {
|
|
126
|
+
leaseRequest: (requestId: string) => LeasedBatchRecord | null;
|
|
127
|
+
ackRequest: (args: {
|
|
128
|
+
leaseId: string;
|
|
129
|
+
requestId?: string;
|
|
130
|
+
}) => void;
|
|
131
|
+
}) => VariantRequestLeaseTracker;
|
|
132
|
+
type MCPAckTelemetry = Pick<TelemetryService, 'trackMCPChangeAcked' | 'trackMCPChangeAckFailed'>;
|
|
133
|
+
export declare const ackApplyBridgeLease: (args: {
|
|
134
|
+
bridge: SessionBridgeService;
|
|
135
|
+
telemetry: MCPAckTelemetry;
|
|
136
|
+
sessionId: string;
|
|
137
|
+
leaseId: string;
|
|
138
|
+
requestId?: string;
|
|
139
|
+
}) => void;
|
|
140
|
+
export declare const ackVariantBridgeLease: (args: {
|
|
141
|
+
bridge: SessionBridgeService;
|
|
142
|
+
telemetry: MCPAckTelemetry;
|
|
143
|
+
leaseId?: string;
|
|
144
|
+
requestId?: string;
|
|
145
|
+
}) => void;
|
|
94
146
|
export type RivetMcpOptions = {
|
|
95
147
|
mcpEditor?: string;
|
|
96
148
|
revokeBearerToken?: (token: string) => void;
|
package/dist/mcp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AASA,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAGrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAGzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AA0BhE,OAAO,EAEL,KAAK,iBAAiB,EAEtB,KAAK,uBAAuB,EAC7B,MAAM,kBAAkB,CAAC;AAgB1B,OAAO,EAOL,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACzD,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,Q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E,oBAAoB,CAAC;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,KAAG,IAuBH,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,MAAM;IAC1C,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,KAAG,IAyBH,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,eAAe,KAAG,cA6/C1D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAmCrE,CAAC"}
|
package/dist/mcp/server.js
CHANGED
|
@@ -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.startMCPServer = exports.createRivetMcp = exports.buildLeasedVariantResponse = exports.buildStaticPreviewRefineResponse = exports.collectStaticPreviewRefineTargetInstructions = exports.buildApplyChangesResponse = exports.buildNoPendingChangesResponse = exports.resolveLeasePickupRequestId = exports.buildVariantRequestBatchResponse = exports.buildMixedVariantBatchResponse = exports.startParentProcessMonitor = exports.buildVisualEditorWatchAction = exports.configureMcpStdioLogging = void 0;
|
|
6
|
+
exports.startMCPServer = exports.createRivetMcp = exports.ackVariantBridgeLease = exports.ackApplyBridgeLease = exports.createVariantRequestLeaseTracker = exports.buildLeasedVariantResponse = exports.buildStaticPreviewRefineResponse = exports.collectStaticPreviewRefineTargetInstructions = exports.buildApplyChangesResponse = exports.buildNoPendingChangesResponse = exports.leaseAvailableBatchForPoll = exports.resolveLeasePickupRequestId = exports.buildVariantRequestBatchResponse = exports.buildMixedVariantBatchResponse = exports.startParentProcessMonitor = exports.buildVisualEditorWatchAction = exports.configureMcpStdioLogging = void 0;
|
|
7
7
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
8
8
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
9
9
|
const v3_1 = require("zod/v3");
|
|
@@ -15,9 +15,11 @@ const TelemetryService_1 = require("../services/TelemetryService");
|
|
|
15
15
|
const AuthService_1 = require("../services/AuthService");
|
|
16
16
|
const IntegrationsClient_1 = require("../services/IntegrationsClient");
|
|
17
17
|
const tools_1 = require("./auth/tools");
|
|
18
|
+
const toolAnalytics_1 = require("./toolAnalytics");
|
|
18
19
|
const tools_2 = require("./integrations/tools");
|
|
19
20
|
const instructions_1 = require("./instructions");
|
|
20
21
|
const ConfigManager_1 = require("../services/ConfigManager");
|
|
22
|
+
const MCPOnboardingTelemetry_1 = require("../services/MCPOnboardingTelemetry");
|
|
21
23
|
const open_1 = __importDefault(require("open"));
|
|
22
24
|
const index_1 = require("../index");
|
|
23
25
|
const evaluateFlags_1 = require("../config/evaluateFlags");
|
|
@@ -414,16 +416,16 @@ const requestHasResolvedReferences = (request) => request.changes.some((c) => c.
|
|
|
414
416
|
Array.isArray(c.resolvedReferences) &&
|
|
415
417
|
c.resolvedReferences.length > 0);
|
|
416
418
|
const VARIANT_REQUEST_GUIDE = 'This batch is a Rivet variant request — do NOT edit files directly. ' +
|
|
417
|
-
'The pending change is a single CommentChangeItem; `variantRequest.count` is only the editor\'s default placeholder count — YOU own the real number. Decide how many directions to generate from the user\'s `instruction` text
|
|
419
|
+
'The pending change is a single CommentChangeItem; `variantRequest.count` is only the editor\'s default placeholder count — YOU own the real number. Decide how many directions to generate from the user\'s `instruction` text — honor an explicit number ("give me 5"), a relative ask ("more options"), or a qualitative cue ("lots of variety"); default to 3 only when the instruction gives no count signal. ' +
|
|
418
420
|
"Derive the structured `start_variants.target` from the comment's `element` using this priority: " +
|
|
419
421
|
'(a) `{ type: "file", ref: filePaths[0] }` when `filePaths.length === 1`; otherwise ' +
|
|
420
422
|
'(b) `{ type: "element", ref: `[data-rivet-id="${rivetId}"]` }` when `rivetId` is present, then ' +
|
|
421
423
|
'(c) `{ type: "element", ref: `#${id}` }` when `id` has no whitespace, then ' +
|
|
422
424
|
'(d) `{ type: "element", ref: xpath }`, then ' +
|
|
423
425
|
'(e) `{ type: "element", ref: `.${token}` }` for a single-token `className`. ' +
|
|
424
|
-
|
|
426
|
+
"When you set a `target` from the comment's `element`, scope each variant's change to THAT element and its immediate section/card — do not restyle the rest of the page. " +
|
|
425
427
|
'If the comment has imageCount > 0, inspect the following image content items before calling `start_variants`; pass each image through `userContext` as `{ transport: "upload", dataUrl, label: "Reference image N", userIntent: "Inline variant visual reference" }` when your client exposes a data URL, or pass concise visual observations as `{ transport: "text", content, label: "Reference image observations", userIntent: "Inline variant visual reference" }` when it does not. ' +
|
|
426
|
-
'Then call `start_variants` with `{ mode: "existing", prompt: instruction, target, userContext, requestId, briefs }`, passing this batch\'s `requestId` through verbatim so the editor can map its loading placeholders to the new cards. Set the count by supplying `briefs` (one distinct `{ label, body }` per variant — `briefs.length` is the count, and each card is named by what it changes); the editor seeds a few placeholders and reconciles to however many you actually generate. Do NOT use the older `propose_variants` chain for this path. ' +
|
|
428
|
+
'Then call `start_variants` with `{ mode: "existing", prompt: instruction, projectPath, target, userContext, requestId, briefs }`, passing this batch\'s `projectPath` and `requestId` through verbatim so the run stays attached to the visual editor project and the editor can map its loading placeholders to the new cards. Set the count by supplying `briefs` (one distinct `{ label, body }` per variant — `briefs.length` is the count, and each card is named by what it changes); the editor seeds a few placeholders and reconciles to however many you actually generate. Do NOT use the older `propose_variants` chain for this path. ' +
|
|
427
429
|
'ACCUMULATION: when a variants session is already live for this project, calling `start_variants` again does NOT discard it — Rivet APPENDS the new directions to that same active session (they show up alongside the existing ones), so just call `start_variants` per Vary; never try to reuse a prior sessionId or worry about orphaning earlier variants. ' +
|
|
428
430
|
'`start_variants` returns leased work items; generate each variant in its worktree and call `report_variant_complete` for each leased item. ' +
|
|
429
431
|
'After the user picks a variant via `commit_variant`, STOP and tell the user their variant has been committed.';
|
|
@@ -435,7 +437,7 @@ const VARIANT_MIXED_BATCH_GUIDE = 'Mixed batch rejected: a `variantRequest` comm
|
|
|
435
437
|
const STATIC_PREVIEW_REFINE_GUIDE_PREAMBLE = 'STATIC_PREVIEW_REFINE_GUIDE: These changes target static_preview variant(s). ' +
|
|
436
438
|
'Do NOT edit base project files. ' +
|
|
437
439
|
"Lease ONLY this batch's work items: call `continue_variants({ action: 'request_work', workItemIds: <the response.workItemIds array> })`. " +
|
|
438
|
-
|
|
440
|
+
"Passing workItemIds (rather than a bare requestedLeaseCount) keeps concurrent runs from leasing each other's work, so several batches can be handled in parallel. " +
|
|
439
441
|
'When input.targetElement is present it is the specific element the user selected (match it in the HTML by tagName/className/id/textContent): ' +
|
|
440
442
|
'scope the change to THAT element and its immediate section/card — do not restyle the rest of the page. ';
|
|
441
443
|
// "Vary" flow: the server forked N NEW sibling variants; the original is left
|
|
@@ -476,6 +478,7 @@ const buildLeasePayloadFields = (lease) => ({
|
|
|
476
478
|
mergedRequestIds: lease.mergedRequestIds,
|
|
477
479
|
mergedFrom: lease.mergedFrom,
|
|
478
480
|
});
|
|
481
|
+
const getActiveLeaseMetadata = (bridge) => bridge.getActiveLeaseMetadata();
|
|
479
482
|
const buildSupersededChangesResponse = () => ({
|
|
480
483
|
content: [
|
|
481
484
|
{
|
|
@@ -508,7 +511,7 @@ const buildMixedVariantBatchResponse = (rejectedRequest) => {
|
|
|
508
511
|
};
|
|
509
512
|
};
|
|
510
513
|
exports.buildMixedVariantBatchResponse = buildMixedVariantBatchResponse;
|
|
511
|
-
const buildVariantRequestBatchResponse = (intent, lease) => {
|
|
514
|
+
const buildVariantRequestBatchResponse = (intent, lease, projectPath) => {
|
|
512
515
|
if (!intent) {
|
|
513
516
|
return buildSupersededChangesResponse();
|
|
514
517
|
}
|
|
@@ -523,6 +526,7 @@ const buildVariantRequestBatchResponse = (intent, lease) => {
|
|
|
523
526
|
kind: 'variant_request',
|
|
524
527
|
changes,
|
|
525
528
|
sourceFiles: intent.sourceFiles,
|
|
529
|
+
...(projectPath ? { projectPath } : {}),
|
|
526
530
|
...(requestId ? { requestId } : {}),
|
|
527
531
|
...(intent.target ? { target: intent.target } : {}),
|
|
528
532
|
...(lease ? buildLeasePayloadFields(lease) : {}),
|
|
@@ -541,6 +545,20 @@ exports.buildVariantRequestBatchResponse = buildVariantRequestBatchResponse;
|
|
|
541
545
|
*/
|
|
542
546
|
const resolveLeasePickupRequestId = (args) => args.refresh_git || args.ack_batch ? undefined : args.requestId;
|
|
543
547
|
exports.resolveLeasePickupRequestId = resolveLeasePickupRequestId;
|
|
548
|
+
/**
|
|
549
|
+
* Lease work for a poll. A matching requestId keeps idempotent re-polls on the
|
|
550
|
+
* same in-flight batch; a stale requestId must not strand unrelated queued work.
|
|
551
|
+
*/
|
|
552
|
+
const leaseAvailableBatchForPoll = (args) => {
|
|
553
|
+
if (args.requestId) {
|
|
554
|
+
const requestedLease = args.bridge.leaseBatch(args.requestId);
|
|
555
|
+
if (requestedLease) {
|
|
556
|
+
return requestedLease;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
return args.bridge.leaseBatch();
|
|
560
|
+
};
|
|
561
|
+
exports.leaseAvailableBatchForPoll = leaseAvailableBatchForPoll;
|
|
544
562
|
/**
|
|
545
563
|
* Builds a poll response for an empty apply queue.
|
|
546
564
|
*/
|
|
@@ -557,6 +575,9 @@ const buildNoPendingChangesResponse = (params = {}) => ({
|
|
|
557
575
|
...(params.pendingVariantRequests !== undefined
|
|
558
576
|
? { pendingVariantRequests: params.pendingVariantRequests }
|
|
559
577
|
: {}),
|
|
578
|
+
...(params.activeLeases !== undefined
|
|
579
|
+
? { activeLeases: params.activeLeases }
|
|
580
|
+
: {}),
|
|
560
581
|
}),
|
|
561
582
|
},
|
|
562
583
|
],
|
|
@@ -651,7 +672,9 @@ const buildStaticPreviewRefineResponse = (consumedRequest, droppedRefinements =
|
|
|
651
672
|
// The exact work items THIS batch created. Lease ONLY these (pass them
|
|
652
673
|
// as `workItemIds` to request_work) so concurrent runs each pick up
|
|
653
674
|
// their own batch instead of one greedily leasing everything.
|
|
654
|
-
...(createdWorkItemIds.length > 0
|
|
675
|
+
...(createdWorkItemIds.length > 0
|
|
676
|
+
? { workItemIds: createdWorkItemIds }
|
|
677
|
+
: {}),
|
|
655
678
|
// In-place refinements the server could not apply (the variant was
|
|
656
679
|
// already sent / no longer editable). Surfaced structurally so the
|
|
657
680
|
// agent knows the instruction was NOT applied, instead of the poll
|
|
@@ -675,14 +698,136 @@ const buildLeasedVariantResponse = (params) => {
|
|
|
675
698
|
return params.withPendingVariantRequests(params.handleStaticPreviewRefineBatch(intent, params.lease));
|
|
676
699
|
}
|
|
677
700
|
if ((0, changeBatchClassification_1.isSingleVariantRequestBatch)(intent)) {
|
|
678
|
-
return params.withPendingVariantRequests((0, exports.buildVariantRequestBatchResponse)(intent, params.lease));
|
|
701
|
+
return params.withPendingVariantRequests((0, exports.buildVariantRequestBatchResponse)(intent, params.lease, params.projectPath));
|
|
679
702
|
}
|
|
680
703
|
if ((0, changeBatchClassification_1.isStaticPreviewRefineBatch)(intent)) {
|
|
681
704
|
return params.withPendingVariantRequests(params.handleStaticPreviewRefineBatch(intent, params.lease));
|
|
682
705
|
}
|
|
683
|
-
return params.withPendingVariantRequests((0, exports.buildVariantRequestBatchResponse)(intent, params.lease));
|
|
706
|
+
return params.withPendingVariantRequests((0, exports.buildVariantRequestBatchResponse)(intent, params.lease, params.projectPath));
|
|
684
707
|
};
|
|
685
708
|
exports.buildLeasedVariantResponse = buildLeasedVariantResponse;
|
|
709
|
+
const FINISHED_VARIANT_REPORT_STATUSES = new Set([
|
|
710
|
+
'succeeded',
|
|
711
|
+
'failed',
|
|
712
|
+
'cancelled',
|
|
713
|
+
]);
|
|
714
|
+
const variantRequestWorkKey = (sessionId, workItemId) => `${sessionId}:${workItemId}`;
|
|
715
|
+
/**
|
|
716
|
+
* Tracks a UI-originated variant request lease across the variant work items
|
|
717
|
+
* that satisfy it, releasing the bridge lease once the whole batch has
|
|
718
|
+
* finished.
|
|
719
|
+
*/
|
|
720
|
+
const createVariantRequestLeaseTracker = (params) => {
|
|
721
|
+
const trackedByWorkItem = new Map();
|
|
722
|
+
const trackedByRequest = new Map();
|
|
723
|
+
return {
|
|
724
|
+
claim(args) {
|
|
725
|
+
if (!args.requestId) {
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const lease = params.leaseRequest(args.requestId);
|
|
729
|
+
if (!lease || lease.kind !== 'variant') {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if (args.workItemIds.length === 0) {
|
|
733
|
+
if (trackedByRequest.has(lease.requestId)) {
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
params.ackRequest({
|
|
737
|
+
leaseId: lease.leaseId,
|
|
738
|
+
requestId: lease.requestId,
|
|
739
|
+
});
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
const tracked = trackedByRequest.get(lease.requestId) ??
|
|
743
|
+
{
|
|
744
|
+
leaseId: lease.leaseId,
|
|
745
|
+
requestId: lease.requestId,
|
|
746
|
+
remainingWorkItemIds: new Set(),
|
|
747
|
+
};
|
|
748
|
+
trackedByRequest.set(lease.requestId, tracked);
|
|
749
|
+
for (const workItemId of args.workItemIds) {
|
|
750
|
+
tracked.remainingWorkItemIds.add(workItemId);
|
|
751
|
+
trackedByWorkItem.set(variantRequestWorkKey(args.sessionId, workItemId), tracked);
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
complete(args) {
|
|
755
|
+
if (args.requeuedForRegeneration ||
|
|
756
|
+
(!args.aborted && !FINISHED_VARIANT_REPORT_STATUSES.has(args.status))) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
const key = variantRequestWorkKey(args.sessionId, args.workItemId);
|
|
760
|
+
const tracked = trackedByWorkItem.get(key);
|
|
761
|
+
if (!tracked) {
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
tracked.remainingWorkItemIds.delete(args.workItemId);
|
|
765
|
+
trackedByWorkItem.delete(key);
|
|
766
|
+
if (tracked.remainingWorkItemIds.size > 0) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
trackedByRequest.delete(tracked.requestId);
|
|
770
|
+
params.ackRequest({
|
|
771
|
+
leaseId: tracked.leaseId,
|
|
772
|
+
requestId: tracked.requestId,
|
|
773
|
+
});
|
|
774
|
+
},
|
|
775
|
+
};
|
|
776
|
+
};
|
|
777
|
+
exports.createVariantRequestLeaseTracker = createVariantRequestLeaseTracker;
|
|
778
|
+
const ackApplyBridgeLease = (args) => {
|
|
779
|
+
const ackResult = args.bridge.ackBatch({
|
|
780
|
+
leaseId: args.leaseId,
|
|
781
|
+
requestId: args.requestId,
|
|
782
|
+
});
|
|
783
|
+
if (ackResult.kind === 'apply' && ackResult.mergedRequestIds.length > 0) {
|
|
784
|
+
args.telemetry.trackMCPChangeAcked({
|
|
785
|
+
channel: 'apply',
|
|
786
|
+
leaseId: args.leaseId,
|
|
787
|
+
requestId: args.requestId ?? ackResult.mergedRequestIds[0],
|
|
788
|
+
changeCount: ackResult.mergedRequestIds.length,
|
|
789
|
+
sessionId: args.sessionId,
|
|
790
|
+
});
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
args.telemetry.trackMCPChangeAckFailed({
|
|
794
|
+
channel: 'apply',
|
|
795
|
+
leaseId: args.leaseId,
|
|
796
|
+
requestId: args.requestId,
|
|
797
|
+
changeCount: 0,
|
|
798
|
+
sessionId: args.sessionId,
|
|
799
|
+
failureReason: 'ack_failed',
|
|
800
|
+
});
|
|
801
|
+
};
|
|
802
|
+
exports.ackApplyBridgeLease = ackApplyBridgeLease;
|
|
803
|
+
const ackVariantBridgeLease = (args) => {
|
|
804
|
+
if (!args.leaseId)
|
|
805
|
+
return;
|
|
806
|
+
const ackResult = args.bridge.ackBatch({
|
|
807
|
+
leaseId: args.leaseId,
|
|
808
|
+
requestId: args.requestId,
|
|
809
|
+
});
|
|
810
|
+
const sessionId = args.bridge.getSessionId() ?? undefined;
|
|
811
|
+
if (ackResult.kind === 'variant' && ackResult.mergedRequestIds.length > 0) {
|
|
812
|
+
args.telemetry.trackMCPChangeAcked({
|
|
813
|
+
channel: 'variant',
|
|
814
|
+
leaseId: args.leaseId,
|
|
815
|
+
requestId: args.requestId ?? ackResult.mergedRequestIds[0],
|
|
816
|
+
changeCount: ackResult.mergedRequestIds.length,
|
|
817
|
+
sessionId,
|
|
818
|
+
});
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
args.telemetry.trackMCPChangeAckFailed({
|
|
822
|
+
channel: 'variant',
|
|
823
|
+
leaseId: args.leaseId,
|
|
824
|
+
requestId: args.requestId,
|
|
825
|
+
changeCount: 0,
|
|
826
|
+
sessionId,
|
|
827
|
+
failureReason: 'ack_failed',
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
exports.ackVariantBridgeLease = ackVariantBridgeLease;
|
|
686
831
|
/**
|
|
687
832
|
* Builds the fully configured Rivet MCP server (tools, auth gating, session
|
|
688
833
|
* bridge, telemetry) without binding it to a transport. Shared by the stdio
|
|
@@ -762,6 +907,11 @@ const createRivetMcp = (options) => {
|
|
|
762
907
|
requestId,
|
|
763
908
|
})),
|
|
764
909
|
}));
|
|
910
|
+
variantRequestLeaseTracker.claim({
|
|
911
|
+
requestId: lease.requestId,
|
|
912
|
+
sessionId,
|
|
913
|
+
workItemIds: createdWorkItemIds,
|
|
914
|
+
});
|
|
765
915
|
}
|
|
766
916
|
}
|
|
767
917
|
return (0, exports.buildStaticPreviewRefineResponse)(consumedRequest, droppedRefinements, createdWorkItemIds, lease);
|
|
@@ -770,42 +920,25 @@ const createRivetMcp = (options) => {
|
|
|
770
920
|
const handleApplyAck = (sessionId, args) => {
|
|
771
921
|
const leaseId = args.leaseId ?? bridge.findActiveApplyLease()?.leaseId ?? undefined;
|
|
772
922
|
if (leaseId) {
|
|
773
|
-
|
|
923
|
+
(0, exports.ackApplyBridgeLease)({
|
|
924
|
+
bridge,
|
|
925
|
+
telemetry,
|
|
926
|
+
sessionId,
|
|
774
927
|
leaseId,
|
|
775
928
|
requestId: args.requestId,
|
|
776
929
|
});
|
|
777
|
-
if (ackResult.kind === 'apply' && ackResult.mergedRequestIds.length > 0) {
|
|
778
|
-
telemetry.trackMCPChangeAcked({
|
|
779
|
-
channel: 'apply',
|
|
780
|
-
leaseId,
|
|
781
|
-
requestId: args.requestId ?? ackResult.mergedRequestIds[0],
|
|
782
|
-
changeCount: ackResult.mergedRequestIds.length,
|
|
783
|
-
sessionId,
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
930
|
}
|
|
787
931
|
handleRefreshGit(sessionId);
|
|
788
932
|
bridge.setStatus('READY');
|
|
789
933
|
};
|
|
790
934
|
/** Release a variant lease after the agent finishes the batch. */
|
|
791
935
|
const handleVariantAck = (args) => {
|
|
792
|
-
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
const ackResult = bridge.ackBatch({
|
|
796
|
-
leaseId: args.leaseId,
|
|
797
|
-
requestId: args.requestId,
|
|
798
|
-
});
|
|
799
|
-
if (ackResult.kind === 'variant' && ackResult.mergedRequestIds.length > 0) {
|
|
800
|
-
telemetry.trackMCPChangeAcked({
|
|
801
|
-
channel: 'variant',
|
|
802
|
-
leaseId: args.leaseId,
|
|
803
|
-
requestId: args.requestId ?? ackResult.mergedRequestIds[0],
|
|
804
|
-
changeCount: ackResult.mergedRequestIds.length,
|
|
805
|
-
sessionId: bridge.getSessionId() ?? undefined,
|
|
806
|
-
});
|
|
807
|
-
}
|
|
936
|
+
(0, exports.ackVariantBridgeLease)({ bridge, telemetry, ...args });
|
|
808
937
|
};
|
|
938
|
+
const variantRequestLeaseTracker = (0, exports.createVariantRequestLeaseTracker)({
|
|
939
|
+
leaseRequest: (requestId) => bridge.leaseBatch(requestId),
|
|
940
|
+
ackRequest: handleVariantAck,
|
|
941
|
+
});
|
|
809
942
|
/** Complete the active run correlation and refresh git status in the Rivet UI. */
|
|
810
943
|
const handleRefreshGit = (sessionId) => {
|
|
811
944
|
const activeRunCorrelation = bridge.completeActiveRunCorrelation();
|
|
@@ -827,6 +960,7 @@ const createRivetMcp = (options) => {
|
|
|
827
960
|
const beginApplyingRun = (intent, sessionId, _lease) => {
|
|
828
961
|
bridge.setStatus('APPLYING');
|
|
829
962
|
const { newRun, orphanedRun } = bridge.startApplyingRun(intent);
|
|
963
|
+
const turnMetadata = (0, MCPOnboardingTelemetry_1.summarizeMCPConversationTurn)(intent, bridge.getRoundsCompleted() + 1, sessionId);
|
|
830
964
|
trackChangesQueuedFromIntent(intent, bridge, telemetry, sessionId);
|
|
831
965
|
if (orphanedRun) {
|
|
832
966
|
trackOrphanedMCPRun(telemetry, sessionId, orphanedRun);
|
|
@@ -834,8 +968,8 @@ const createRivetMcp = (options) => {
|
|
|
834
968
|
telemetry.trackAgentRunStarted({
|
|
835
969
|
traceId: newRun.traceId,
|
|
836
970
|
agentRunId: newRun.agentRunId,
|
|
837
|
-
instructionLength:
|
|
838
|
-
elementCount:
|
|
971
|
+
instructionLength: turnMetadata.instructionLengthTotal,
|
|
972
|
+
elementCount: turnMetadata.elementCount,
|
|
839
973
|
posthogSessionId: newRun.browserSessionId,
|
|
840
974
|
resumeSessionId: sessionId,
|
|
841
975
|
source: 'mcp',
|
|
@@ -853,7 +987,7 @@ const createRivetMcp = (options) => {
|
|
|
853
987
|
const rejectedRequest = bridge.rejectMixedVariantRequestBatch(applyHead);
|
|
854
988
|
return withPendingVariantRequests((0, exports.buildMixedVariantBatchResponse)(rejectedRequest));
|
|
855
989
|
}
|
|
856
|
-
const lease =
|
|
990
|
+
const lease = (0, exports.leaseAvailableBatchForPoll)({ bridge, requestId });
|
|
857
991
|
if (!lease) {
|
|
858
992
|
return null;
|
|
859
993
|
}
|
|
@@ -870,6 +1004,7 @@ const createRivetMcp = (options) => {
|
|
|
870
1004
|
isFreshStaticPreviewVariantRequestBatch,
|
|
871
1005
|
handleStaticPreviewRefineBatch,
|
|
872
1006
|
withPendingVariantRequests,
|
|
1007
|
+
projectPath: bridge.getProjectPath(),
|
|
873
1008
|
});
|
|
874
1009
|
}
|
|
875
1010
|
beginApplyingRun(lease.intent, sessionId, lease);
|
|
@@ -913,11 +1048,19 @@ const createRivetMcp = (options) => {
|
|
|
913
1048
|
capabilities: { tools: {} },
|
|
914
1049
|
instructions: (0, instructions_1.buildRivetMcpInstructions)(hasStoredCredentials ? 'authenticated' : 'unauthenticated'),
|
|
915
1050
|
});
|
|
1051
|
+
const analyticsMcp = (0, toolAnalytics_1.withMCPToolAnalytics)(mcp, {
|
|
1052
|
+
telemetry,
|
|
1053
|
+
getSessionId: () => bridge.getSessionId() ?? undefined,
|
|
1054
|
+
getAuthState: () => configManager.isAuthenticated() || Boolean(configManager.getRefreshToken())
|
|
1055
|
+
? 'authenticated'
|
|
1056
|
+
: 'unauthenticated',
|
|
1057
|
+
mcpEditor,
|
|
1058
|
+
});
|
|
916
1059
|
// Every substantive tool is gated behind login: register them on `guardedMcp`
|
|
917
1060
|
// so an unauthenticated call returns AUTH_REQUIRED instead of running. The
|
|
918
|
-
// login/logout/auth_status tools register on
|
|
919
|
-
// reachable while logged out.
|
|
920
|
-
const guardedMcp = (0, tools_1.withAuthGuard)(
|
|
1061
|
+
// login/logout/auth_status tools register on `analyticsMcp` so they stay
|
|
1062
|
+
// reachable while logged out and still emit tool analytics.
|
|
1063
|
+
const guardedMcp = (0, tools_1.withAuthGuard)(analyticsMcp, requireAuth);
|
|
921
1064
|
// Track the Express server
|
|
922
1065
|
let serverHandle = null;
|
|
923
1066
|
let sessionStartedAt = null;
|
|
@@ -1784,6 +1927,7 @@ const createRivetMcp = (options) => {
|
|
|
1784
1927
|
message: 'Timed out waiting for changes. Call watch_for_changes again to keep waiting.',
|
|
1785
1928
|
devServerHealth: health,
|
|
1786
1929
|
pendingVariantRequests: bridge.pendingVariantRequestCount(),
|
|
1930
|
+
activeLeases: getActiveLeaseMetadata(bridge),
|
|
1787
1931
|
});
|
|
1788
1932
|
}
|
|
1789
1933
|
const routed = leaseAndRouteBatch(args.sessionId, (0, exports.resolveLeasePickupRequestId)(args));
|
|
@@ -1795,6 +1939,7 @@ const createRivetMcp = (options) => {
|
|
|
1795
1939
|
message: 'No pending changes. Call watch_for_changes again to keep waiting.',
|
|
1796
1940
|
devServerHealth: health,
|
|
1797
1941
|
pendingVariantRequests: bridge.pendingVariantRequestCount(),
|
|
1942
|
+
activeLeases: getActiveLeaseMetadata(bridge),
|
|
1798
1943
|
});
|
|
1799
1944
|
});
|
|
1800
1945
|
guardedMcp.tool('get_pending_changes', `Pick up pending design changes from the Rivet visual editor. Returns a leased batch with leaseId and kind when work is queued. After editing files (apply), call again with refresh_git: true and leaseId to ack and refresh git. After variant batches, call with ack_batch: true and leaseId. Returns hasChanges: false if no changes are queued yet.`, {
|
|
@@ -1854,6 +1999,7 @@ const createRivetMcp = (options) => {
|
|
|
1854
1999
|
}
|
|
1855
2000
|
return (0, exports.buildNoPendingChangesResponse)({
|
|
1856
2001
|
pendingVariantRequests: bridge.pendingVariantRequestCount(),
|
|
2002
|
+
activeLeases: getActiveLeaseMetadata(bridge),
|
|
1857
2003
|
});
|
|
1858
2004
|
});
|
|
1859
2005
|
guardedMcp.tool('close_visual_editor', 'Stop the Rivet visual editing session and clean up resources. Call this when the user is done making visual changes.', sessionIdArgs, async (args) => {
|
|
@@ -1890,7 +2036,10 @@ const createRivetMcp = (options) => {
|
|
|
1890
2036
|
leaseOwner: () => 'mcp-server',
|
|
1891
2037
|
ensureVisualEditorOpen: ensureZeroToOneVisualEditorOpen,
|
|
1892
2038
|
getProjectPath: () => bridge.getProjectPath(),
|
|
2039
|
+
resolveVariantRequestProjectPath: (requestId) => bridge.resolveVariantRequestProjectPath(requestId),
|
|
1893
2040
|
pendingVariantRequestCount: () => bridge.pendingVariantRequestCount(),
|
|
2041
|
+
claimVariantRequestLease: variantRequestLeaseTracker.claim,
|
|
2042
|
+
completeVariantRequestWork: variantRequestLeaseTracker.complete,
|
|
1894
2043
|
isVariantSendEnabled: async () => {
|
|
1895
2044
|
const flags = await (0, evaluateFlags_1.getFeatureFlags)();
|
|
1896
2045
|
return flags.variantSend.isEnabled;
|
|
@@ -1903,7 +2052,7 @@ const createRivetMcp = (options) => {
|
|
|
1903
2052
|
integrationsClient,
|
|
1904
2053
|
openIntegrationConnectUrl,
|
|
1905
2054
|
});
|
|
1906
|
-
(0, tools_1.registerAuthTools)(
|
|
2055
|
+
(0, tools_1.registerAuthTools)(analyticsMcp, {
|
|
1907
2056
|
authService,
|
|
1908
2057
|
telemetry,
|
|
1909
2058
|
mcpEditor,
|