@spotpatch/shared 1.8.0 → 1.10.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.
- package/dist/chunk-2LVIH7OA.js +75 -0
- package/dist/chunk-2LVIH7OA.js.map +1 -0
- package/dist/chunk-MOGITGPP.js +431 -0
- package/dist/chunk-MOGITGPP.js.map +1 -0
- package/dist/chunk-RK46Y7LD.js +34 -0
- package/dist/chunk-RK46Y7LD.js.map +1 -0
- package/dist/chunk-ZCG3DLSW.js +28 -0
- package/dist/chunk-ZCG3DLSW.js.map +1 -0
- package/dist/data-flow-runtime-BMm3F-eV.d.cts +658 -0
- package/dist/data-flow-runtime-Dp-xznQW.d.ts +658 -0
- package/dist/data-flow-runtime.cjs +78 -0
- package/dist/data-flow-runtime.cjs.map +1 -0
- package/dist/data-flow-runtime.d.cts +3 -0
- package/dist/data-flow-runtime.d.ts +3 -0
- package/dist/data-flow-runtime.js +13 -0
- package/dist/data-flow-runtime.js.map +1 -0
- package/dist/endpoints-BT-Bl1WS.d.cts +20 -0
- package/dist/endpoints-BT-Bl1WS.d.ts +20 -0
- package/dist/external-agent-node.cjs +692 -0
- package/dist/external-agent-node.cjs.map +1 -0
- package/dist/external-agent-node.d.cts +556 -0
- package/dist/external-agent-node.d.ts +556 -0
- package/dist/external-agent-node.js +210 -0
- package/dist/external-agent-node.js.map +1 -0
- package/dist/external-handoff-CWoooqhp.d.cts +720 -0
- package/dist/external-handoff-CWoooqhp.d.ts +720 -0
- package/dist/external-handoff-browser.cjs +163 -0
- package/dist/external-handoff-browser.cjs.map +1 -0
- package/dist/external-handoff-browser.d.cts +32 -0
- package/dist/external-handoff-browser.d.ts +32 -0
- package/dist/external-handoff-browser.js +58 -0
- package/dist/external-handoff-browser.js.map +1 -0
- package/dist/index.cjs +938 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +212 -110
- package/dist/index.d.ts +212 -110
- package/dist/index.js +616 -302
- package/dist/index.js.map +1 -1
- package/package.json +45 -2
package/dist/index.js
CHANGED
|
@@ -1,49 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import {
|
|
2
|
+
DATA_FLOW_SCHEMA_VERSION,
|
|
3
|
+
DATA_FLOW_URL_QUERY_KEY_LIMIT,
|
|
4
|
+
DEFAULT_DATA_FLOW_LIMITS,
|
|
5
|
+
DEFAULT_RUNTIME_DATA_FLOW_LIMITS
|
|
6
|
+
} from "./chunk-RK46Y7LD.js";
|
|
7
|
+
import {
|
|
8
|
+
AGENT_APPLY_MODES,
|
|
9
|
+
AGENT_CAPABILITY_STATES,
|
|
10
|
+
AGENT_CHECK_STATUSES,
|
|
11
|
+
AGENT_FILE_CHANGE_KINDS,
|
|
12
|
+
AGENT_JOB_STATUSES,
|
|
13
|
+
AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
14
|
+
AGENT_WORKSPACE_STATES,
|
|
15
|
+
DEFAULT_AGENT_LIMITS,
|
|
16
|
+
ERROR_CODES,
|
|
17
|
+
ERROR_CODE_VALUES,
|
|
18
|
+
MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
|
|
19
|
+
MAX_ANNOTATION_TARGETS,
|
|
20
|
+
MAX_TARGET_INSTRUCTION_CHARACTERS,
|
|
21
|
+
SPOTPATCH_LOCALES,
|
|
22
|
+
SPOTPATCH_LOCALE_PREFERENCES,
|
|
23
|
+
SpotPatchError,
|
|
24
|
+
activeAdapterSummarySchema,
|
|
25
|
+
agentCapabilityRequestSchema,
|
|
26
|
+
agentJobActionRequestSchema,
|
|
27
|
+
agentJobCreateRequestSchema,
|
|
28
|
+
agentWorkspaceHealthRequestSchema,
|
|
29
|
+
dataFlowComponentReportRequestSchema,
|
|
30
|
+
dataFlowPageReportRequestSchema,
|
|
31
|
+
dispatchSummarySchema,
|
|
32
|
+
externalHandoffCapabilityRequestSchema,
|
|
33
|
+
externalHandoffCapabilitySchema,
|
|
34
|
+
externalHandoffPublishDeliverySchema,
|
|
35
|
+
externalHandoffPublishRequestSchema,
|
|
36
|
+
externalHandoffPublishResultSchema,
|
|
37
|
+
externalHandoffReportableDispatchPhaseSchema,
|
|
38
|
+
externalHandoffResolveDeliveryRequestSchema,
|
|
39
|
+
externalHandoffSnapshotSchema,
|
|
40
|
+
externalHandoffStatusRequestSchema,
|
|
41
|
+
externalHandoffStatusResultSchema,
|
|
42
|
+
externalHandoffSummarySchema,
|
|
43
|
+
isErrorCode,
|
|
44
|
+
openEditorRequestSchema,
|
|
45
|
+
runtimeBootstrapRequestSchema,
|
|
46
|
+
sourceContextRequestSchema,
|
|
47
|
+
spotAnnotationRequestSchema,
|
|
48
|
+
spotTargetContextRequestSchema
|
|
49
|
+
} from "./chunk-MOGITGPP.js";
|
|
50
|
+
import {
|
|
51
|
+
SPOTPATCH_API_BASE,
|
|
52
|
+
SPOTPATCH_ENDPOINTS,
|
|
53
|
+
SPOTPATCH_TOKEN_HEADER,
|
|
54
|
+
getAgentJobEndpoint
|
|
55
|
+
} from "./chunk-ZCG3DLSW.js";
|
|
56
|
+
import {
|
|
57
|
+
EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS,
|
|
58
|
+
EXTERNAL_HANDOFF_ACTIVE_ADAPTER_STATES,
|
|
59
|
+
EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION,
|
|
60
|
+
EXTERNAL_HANDOFF_DISPATCH_PHASES,
|
|
61
|
+
EXTERNAL_HANDOFF_FRAMEWORKS,
|
|
62
|
+
EXTERNAL_HANDOFF_LIMITS,
|
|
63
|
+
EXTERNAL_HANDOFF_REPORTABLE_DISPATCH_PHASES,
|
|
64
|
+
EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION,
|
|
65
|
+
EXTERNAL_HANDOFF_STATES
|
|
66
|
+
} from "./chunk-2LVIH7OA.js";
|
|
47
67
|
|
|
48
68
|
// src/security/redaction.ts
|
|
49
69
|
var INLINE_DATA_PATTERN = /data:[^\s"'<>]*;base64,[a-z0-9+/_=-]+/giu;
|
|
@@ -114,99 +134,458 @@ function sanitizeUrl(value, baseUrl) {
|
|
|
114
134
|
}
|
|
115
135
|
}
|
|
116
136
|
|
|
117
|
-
// src/model/
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
var
|
|
123
|
-
"
|
|
124
|
-
|
|
137
|
+
// src/model/data-flow-adapters.ts
|
|
138
|
+
var DATA_FLOW_QUERY_ADAPTER_MODULES = Object.freeze([
|
|
139
|
+
"@tanstack/react-query",
|
|
140
|
+
"react-query"
|
|
141
|
+
]);
|
|
142
|
+
var DATA_FLOW_QUERY_HOOK_NAMES = Object.freeze([
|
|
143
|
+
"useInfiniteQuery",
|
|
144
|
+
"useMutation",
|
|
145
|
+
"useQuery"
|
|
146
|
+
]);
|
|
147
|
+
var DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES = Object.freeze([
|
|
148
|
+
"createTRPCClient",
|
|
149
|
+
"createTRPCProxyClient"
|
|
150
|
+
]);
|
|
151
|
+
var DATA_FLOW_TRPC_PROXY_FACTORY_NAMES = Object.freeze([
|
|
152
|
+
"createTRPCNext",
|
|
153
|
+
"createTRPCReact"
|
|
154
|
+
]);
|
|
155
|
+
var DATA_FLOW_TRPC_ROOT_FACTORY_NAMES = Object.freeze([
|
|
156
|
+
...DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES,
|
|
157
|
+
...DATA_FLOW_TRPC_PROXY_FACTORY_NAMES,
|
|
158
|
+
"createTRPCContext",
|
|
159
|
+
"createTRPCOptionsProxy"
|
|
160
|
+
]);
|
|
161
|
+
var DATA_FLOW_TRPC_REQUEST_METHODS = Object.freeze([
|
|
162
|
+
"infiniteQueryOptions",
|
|
163
|
+
"mutate",
|
|
164
|
+
"mutateAsync",
|
|
165
|
+
"mutationOptions",
|
|
166
|
+
"query",
|
|
167
|
+
"queryOptions",
|
|
168
|
+
"refetch",
|
|
169
|
+
"subscribe",
|
|
170
|
+
"subscriptionOptions",
|
|
171
|
+
"useInfiniteQuery",
|
|
172
|
+
"useMutation",
|
|
173
|
+
"useQuery",
|
|
174
|
+
"useSubscription",
|
|
175
|
+
"useSuspenseInfiniteQuery",
|
|
176
|
+
"useSuspenseQuery"
|
|
125
177
|
]);
|
|
126
178
|
|
|
127
|
-
// src/model/
|
|
179
|
+
// src/model/data-flow.ts
|
|
128
180
|
import { z } from "zod";
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
bootstrap: `${SPOTPATCH_API_BASE}/bootstrap`,
|
|
135
|
-
sourceContext: `${SPOTPATCH_API_BASE}/source-context`,
|
|
136
|
-
openEditor: `${SPOTPATCH_API_BASE}/open-editor`,
|
|
137
|
-
agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
|
|
138
|
-
agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
|
|
139
|
-
agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`
|
|
140
|
-
});
|
|
141
|
-
function getAgentJobEndpoint(jobId, action) {
|
|
142
|
-
return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// src/model/editor.ts
|
|
146
|
-
var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
|
|
147
|
-
|
|
148
|
-
// src/model/agent.ts
|
|
149
|
-
var AGENT_APPLY_MODES = Object.freeze([
|
|
150
|
-
"review",
|
|
151
|
-
"auto",
|
|
152
|
-
"trusted-auto"
|
|
181
|
+
var DATA_FLOW_EXECUTION_STATES = Object.freeze([
|
|
182
|
+
"observed",
|
|
183
|
+
"declared-not-observed",
|
|
184
|
+
"not-applicable",
|
|
185
|
+
"unknown"
|
|
153
186
|
]);
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
maxReadBytesPerFile: 256e3,
|
|
160
|
-
maxToolOutputCharacters: 4e4,
|
|
161
|
-
maxProviderResponseBytes: 2e6,
|
|
162
|
-
providerConnectTimeoutMs: 15e3,
|
|
163
|
-
providerFirstByteTimeoutMs: 3e4,
|
|
164
|
-
providerIdleTimeoutMs: 6e4,
|
|
165
|
-
checkTimeoutMs: 12e4,
|
|
166
|
-
jobTimeoutMs: 6e5
|
|
167
|
-
});
|
|
168
|
-
var AGENT_JOB_STATUSES = Object.freeze([
|
|
169
|
-
"queued",
|
|
170
|
-
"preparing",
|
|
171
|
-
"running",
|
|
172
|
-
"validating",
|
|
173
|
-
"awaiting-review",
|
|
174
|
-
"applying",
|
|
175
|
-
"applied",
|
|
176
|
-
"completed",
|
|
177
|
-
"cancelling",
|
|
178
|
-
"cancelled",
|
|
179
|
-
"reverting",
|
|
180
|
-
"reverted",
|
|
181
|
-
"failed"
|
|
182
|
-
]);
|
|
183
|
-
var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
184
|
-
"unknown",
|
|
185
|
-
"probing",
|
|
186
|
-
"agent-ready",
|
|
187
|
-
"prompt-only",
|
|
188
|
-
"unavailable"
|
|
187
|
+
var DATA_FLOW_PROOF_STATES = Object.freeze([
|
|
188
|
+
"proven",
|
|
189
|
+
"candidate",
|
|
190
|
+
"unavailable",
|
|
191
|
+
"conflict"
|
|
189
192
|
]);
|
|
190
|
-
var
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
193
|
+
var DATA_FLOW_ASSOCIATION_KINDS = Object.freeze([
|
|
194
|
+
"direct",
|
|
195
|
+
"transitive",
|
|
196
|
+
"upstream",
|
|
197
|
+
"possible",
|
|
198
|
+
"unassigned",
|
|
199
|
+
"unknown"
|
|
194
200
|
]);
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
"added",
|
|
201
|
-
"modified",
|
|
202
|
-
"deleted"
|
|
201
|
+
var DATA_FLOW_FRESHNESS_STATES = Object.freeze([
|
|
202
|
+
"current",
|
|
203
|
+
"stale-source",
|
|
204
|
+
"stale-route",
|
|
205
|
+
"expired"
|
|
203
206
|
]);
|
|
204
|
-
var
|
|
205
|
-
"
|
|
206
|
-
"
|
|
207
|
-
"
|
|
208
|
-
"
|
|
207
|
+
var DATA_FLOW_DIAGNOSTIC_CODES = Object.freeze([
|
|
208
|
+
"DATA_FLOW_CAPABILITY_DISABLED",
|
|
209
|
+
"DATA_FLOW_CAPABILITY_PRELUDE_UNAVAILABLE",
|
|
210
|
+
"DATA_FLOW_CAPABILITY_UNSUPPORTED_FRAMEWORK",
|
|
211
|
+
"DATA_FLOW_SOURCE_UNAVAILABLE",
|
|
212
|
+
"DATA_FLOW_SOURCE_STALE",
|
|
213
|
+
"DATA_FLOW_ANALYSIS_TIMEOUT",
|
|
214
|
+
"DATA_FLOW_ANALYSIS_TRUNCATED",
|
|
215
|
+
"DATA_FLOW_ANALYSIS_UNRESOLVED_CALL",
|
|
216
|
+
"DATA_FLOW_OBSERVATION_UNASSIGNED",
|
|
217
|
+
"DATA_FLOW_OBSERVATION_DROPPED",
|
|
218
|
+
"DATA_FLOW_REDACTION_APPLIED",
|
|
219
|
+
"DATA_FLOW_AI_DISABLED"
|
|
209
220
|
]);
|
|
221
|
+
var boundedText = (maximum) => z.string().trim().min(1).max(maximum);
|
|
222
|
+
var opaqueIdSchema = boundedText(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
223
|
+
var diagnosticCodeSchema = z.enum(DATA_FLOW_DIAGNOSTIC_CODES);
|
|
224
|
+
var evidenceSourceSchema = z.strictObject({
|
|
225
|
+
fileId: opaqueIdSchema,
|
|
226
|
+
displayPath: boundedText(1024),
|
|
227
|
+
line: z.number().int().positive(),
|
|
228
|
+
column: z.number().int().positive(),
|
|
229
|
+
sourceVersion: opaqueIdSchema
|
|
230
|
+
});
|
|
231
|
+
var sanitizedObservedUrlSchema = z.strictObject({
|
|
232
|
+
origin: boundedText(512).optional(),
|
|
233
|
+
pathname: boundedText(2048),
|
|
234
|
+
queryKeys: z.array(boundedText(256)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
|
|
235
|
+
});
|
|
236
|
+
var dataParameterSchema = z.strictObject({
|
|
237
|
+
path: boundedText(1024),
|
|
238
|
+
position: z.enum([
|
|
239
|
+
"path",
|
|
240
|
+
"query",
|
|
241
|
+
"body",
|
|
242
|
+
"header",
|
|
243
|
+
"cookie",
|
|
244
|
+
"variable",
|
|
245
|
+
"form",
|
|
246
|
+
"unknown"
|
|
247
|
+
]),
|
|
248
|
+
type: boundedText(512).optional(),
|
|
249
|
+
source: boundedText(1024).optional(),
|
|
250
|
+
condition: boundedText(1024).optional(),
|
|
251
|
+
sensitive: z.boolean(),
|
|
252
|
+
valueState: z.literal("not-collected"),
|
|
253
|
+
evidenceIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
254
|
+
});
|
|
255
|
+
var dataResponseSchema = z.strictObject({
|
|
256
|
+
consumedFields: z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
|
|
257
|
+
});
|
|
258
|
+
var requestOriginSchema = z.strictObject({
|
|
259
|
+
componentSourceId: opaqueIdSchema.optional(),
|
|
260
|
+
triggerCallsiteId: opaqueIdSchema.optional(),
|
|
261
|
+
requestCallsiteId: opaqueIdSchema,
|
|
262
|
+
sourceVersion: opaqueIdSchema
|
|
263
|
+
});
|
|
264
|
+
var capabilityReasonSchema = z.strictObject({
|
|
265
|
+
code: diagnosticCodeSchema,
|
|
266
|
+
retryable: z.boolean()
|
|
267
|
+
});
|
|
268
|
+
var capabilitySchema = z.strictObject({
|
|
269
|
+
enabled: z.boolean(),
|
|
270
|
+
staticAnalysis: z.enum(["available", "partial", "unavailable"]),
|
|
271
|
+
runtimeObservation: z.literal("dispatch-only"),
|
|
272
|
+
responseShape: z.literal("consumed-fields-only"),
|
|
273
|
+
aiAssistance: z.literal("disabled"),
|
|
274
|
+
reasons: z.array(capabilityReasonSchema).max(DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons)
|
|
275
|
+
});
|
|
276
|
+
var evidenceSchema = z.strictObject({
|
|
277
|
+
id: opaqueIdSchema,
|
|
278
|
+
kind: z.enum([
|
|
279
|
+
"source-anchor",
|
|
280
|
+
"import-resolution",
|
|
281
|
+
"symbol-edge",
|
|
282
|
+
"trigger-edge",
|
|
283
|
+
"call-edge",
|
|
284
|
+
"data-binding",
|
|
285
|
+
"adapter-rule",
|
|
286
|
+
"runtime-observation",
|
|
287
|
+
"runtime-reference",
|
|
288
|
+
"diagnostic"
|
|
289
|
+
]),
|
|
290
|
+
source: evidenceSourceSchema.optional(),
|
|
291
|
+
adapter: z.strictObject({ id: boundedText(128), version: boundedText(64) }).optional(),
|
|
292
|
+
summaryKey: boundedText(256)
|
|
293
|
+
});
|
|
294
|
+
var diagnosticSchema = z.strictObject({
|
|
295
|
+
id: opaqueIdSchema,
|
|
296
|
+
code: diagnosticCodeSchema,
|
|
297
|
+
severity: z.enum(["info", "warning", "error"]),
|
|
298
|
+
retryable: z.boolean(),
|
|
299
|
+
evidenceIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
300
|
+
});
|
|
301
|
+
var baselineSchema = z.strictObject({
|
|
302
|
+
registryEpoch: opaqueIdSchema,
|
|
303
|
+
analyzerVersion: boundedText(64),
|
|
304
|
+
adapterSetHash: boundedText(128),
|
|
305
|
+
analyzedSourceVersions: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxModules)
|
|
306
|
+
});
|
|
307
|
+
var completenessSchema = z.strictObject({
|
|
308
|
+
complete: z.boolean(),
|
|
309
|
+
visitedModules: z.number().int().nonnegative(),
|
|
310
|
+
visitedCallsites: z.number().int().nonnegative(),
|
|
311
|
+
frontierCount: z.number().int().nonnegative(),
|
|
312
|
+
truncatedBy: z.enum(["depth", "modules", "callsites", "bytes", "timeout"]).optional()
|
|
313
|
+
});
|
|
314
|
+
var dataDependencySchema = z.strictObject({
|
|
315
|
+
id: opaqueIdSchema,
|
|
316
|
+
kind: z.enum(["http", "graphql", "rpc", "server-action", "unknown"]),
|
|
317
|
+
direction: z.enum(["read", "write", "read-write", "unknown"]),
|
|
318
|
+
execution: z.enum(DATA_FLOW_EXECUTION_STATES),
|
|
319
|
+
proof: z.enum(DATA_FLOW_PROOF_STATES),
|
|
320
|
+
association: z.enum(DATA_FLOW_ASSOCIATION_KINDS),
|
|
321
|
+
method: boundedText(32).optional(),
|
|
322
|
+
operation: boundedText(512).optional(),
|
|
323
|
+
url: sanitizedObservedUrlSchema.optional(),
|
|
324
|
+
parameters: z.array(dataParameterSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields),
|
|
325
|
+
response: dataResponseSchema,
|
|
326
|
+
origin: requestOriginSchema.optional(),
|
|
327
|
+
suppliedBindings: z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
328
|
+
locationIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
329
|
+
evidenceIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
330
|
+
observationIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries)
|
|
331
|
+
});
|
|
332
|
+
var networkObservationSchema = z.strictObject({
|
|
333
|
+
schemaVersion: z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
334
|
+
id: opaqueIdSchema,
|
|
335
|
+
pageEpoch: opaqueIdSchema,
|
|
336
|
+
routeEpoch: opaqueIdSchema,
|
|
337
|
+
requestCallsiteId: opaqueIdSchema.optional(),
|
|
338
|
+
invocationId: opaqueIdSchema.optional(),
|
|
339
|
+
componentSourceId: opaqueIdSchema.optional(),
|
|
340
|
+
triggerCallsiteId: opaqueIdSchema.optional(),
|
|
341
|
+
sourceVersion: opaqueIdSchema.optional(),
|
|
342
|
+
transport: z.enum(["fetch", "trpc", "xhr"]),
|
|
343
|
+
method: boundedText(32),
|
|
344
|
+
operation: boundedText(512).optional(),
|
|
345
|
+
url: sanitizedObservedUrlSchema,
|
|
346
|
+
outcome: z.literal("dispatched"),
|
|
347
|
+
freshness: z.enum(DATA_FLOW_FRESHNESS_STATES),
|
|
348
|
+
diagnosticIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
349
|
+
});
|
|
350
|
+
var componentIdentitySchema = z.strictObject({
|
|
351
|
+
componentSourceId: opaqueIdSchema.optional(),
|
|
352
|
+
displayName: boundedText(256).optional(),
|
|
353
|
+
source: evidenceSourceSchema
|
|
354
|
+
});
|
|
355
|
+
var componentDataFlowReportSchema = z.strictObject({
|
|
356
|
+
schemaVersion: z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
357
|
+
reportId: opaqueIdSchema,
|
|
358
|
+
baseline: baselineSchema,
|
|
359
|
+
capability: capabilitySchema,
|
|
360
|
+
component: componentIdentitySchema,
|
|
361
|
+
dependencies: z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
362
|
+
evidence: z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
363
|
+
diagnostics: z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
|
|
364
|
+
completeness: completenessSchema
|
|
365
|
+
});
|
|
366
|
+
var pageDataFlowReportSchema = z.strictObject({
|
|
367
|
+
schemaVersion: z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
368
|
+
reportId: opaqueIdSchema,
|
|
369
|
+
baseline: baselineSchema,
|
|
370
|
+
capability: capabilitySchema,
|
|
371
|
+
dependencies: z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
372
|
+
evidence: z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
373
|
+
diagnostics: z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
|
|
374
|
+
completeness: completenessSchema
|
|
375
|
+
});
|
|
376
|
+
var runtimeDataFlowConfigSchema = z.strictObject({
|
|
377
|
+
enabled: z.boolean(),
|
|
378
|
+
runtime: z.literal("dispatch"),
|
|
379
|
+
limits: z.strictObject({
|
|
380
|
+
observationMaxEntries: z.number().int().positive(),
|
|
381
|
+
observationMaxBytes: z.number().int().positive(),
|
|
382
|
+
observationTtlMs: z.number().int().positive(),
|
|
383
|
+
reportMaxBytes: z.number().int().positive()
|
|
384
|
+
})
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// src/model/data-flow-budget.ts
|
|
388
|
+
function prefix(values, maximum) {
|
|
389
|
+
return Object.freeze(values.slice(0, Math.max(0, maximum)));
|
|
390
|
+
}
|
|
391
|
+
function limitDependency(dependency) {
|
|
392
|
+
const queryKeys = dependency.url === void 0 ? void 0 : prefix(dependency.url.queryKeys, DEFAULT_DATA_FLOW_LIMITS.reportMaxFields);
|
|
393
|
+
const parameters = prefix(
|
|
394
|
+
dependency.parameters,
|
|
395
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxFields
|
|
396
|
+
).map(
|
|
397
|
+
(parameter) => Object.freeze({
|
|
398
|
+
...parameter,
|
|
399
|
+
evidenceIds: prefix(
|
|
400
|
+
parameter.evidenceIds,
|
|
401
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence
|
|
402
|
+
)
|
|
403
|
+
})
|
|
404
|
+
);
|
|
405
|
+
const consumedFields = prefix(
|
|
406
|
+
dependency.response.consumedFields,
|
|
407
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxFields
|
|
408
|
+
);
|
|
409
|
+
const suppliedBindings = prefix(
|
|
410
|
+
dependency.suppliedBindings,
|
|
411
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
412
|
+
);
|
|
413
|
+
const locationIds = prefix(
|
|
414
|
+
dependency.locationIds,
|
|
415
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
416
|
+
);
|
|
417
|
+
const evidenceIds = prefix(
|
|
418
|
+
dependency.evidenceIds,
|
|
419
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence
|
|
420
|
+
);
|
|
421
|
+
const observationIds = prefix(
|
|
422
|
+
dependency.observationIds,
|
|
423
|
+
DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries
|
|
424
|
+
);
|
|
425
|
+
const trimmed = queryKeys?.length !== dependency.url?.queryKeys.length || parameters.length !== dependency.parameters.length || parameters.some(
|
|
426
|
+
(parameter, index) => parameter.evidenceIds.length !== dependency.parameters[index]?.evidenceIds.length
|
|
427
|
+
) || consumedFields.length !== dependency.response.consumedFields.length || suppliedBindings.length !== dependency.suppliedBindings.length || locationIds.length !== dependency.locationIds.length || evidenceIds.length !== dependency.evidenceIds.length || observationIds.length !== dependency.observationIds.length;
|
|
428
|
+
if (!trimmed) return Object.freeze({ dependency, trimmed: false });
|
|
429
|
+
return Object.freeze({
|
|
430
|
+
dependency: Object.freeze({
|
|
431
|
+
...dependency,
|
|
432
|
+
...dependency.url === void 0 ? {} : {
|
|
433
|
+
url: Object.freeze({
|
|
434
|
+
...dependency.url,
|
|
435
|
+
queryKeys: queryKeys ?? Object.freeze([])
|
|
436
|
+
})
|
|
437
|
+
},
|
|
438
|
+
parameters: Object.freeze(parameters),
|
|
439
|
+
response: Object.freeze({ consumedFields }),
|
|
440
|
+
suppliedBindings,
|
|
441
|
+
locationIds,
|
|
442
|
+
evidenceIds,
|
|
443
|
+
observationIds
|
|
444
|
+
}),
|
|
445
|
+
trimmed: true
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function referencedEvidenceIds(dependencies, diagnostics) {
|
|
449
|
+
return Object.freeze([
|
|
450
|
+
.../* @__PURE__ */ new Set([
|
|
451
|
+
...dependencies.flatMap((dependency) => [
|
|
452
|
+
...dependency.evidenceIds,
|
|
453
|
+
...dependency.parameters.flatMap((parameter) => parameter.evidenceIds)
|
|
454
|
+
]),
|
|
455
|
+
...diagnostics.flatMap((diagnostic) => diagnostic.evidenceIds)
|
|
456
|
+
])
|
|
457
|
+
]);
|
|
458
|
+
}
|
|
459
|
+
function prioritizeEvidence(evidence, referencedIds, retainUnreferenced) {
|
|
460
|
+
const byId = new Map(evidence.map((entry) => [entry.id, entry]));
|
|
461
|
+
const ordered = [];
|
|
462
|
+
const retained = /* @__PURE__ */ new Set();
|
|
463
|
+
for (const id of referencedIds) {
|
|
464
|
+
const entry = byId.get(id);
|
|
465
|
+
if (entry !== void 0 && !retained.has(id)) {
|
|
466
|
+
ordered.push(entry);
|
|
467
|
+
retained.add(id);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (retainUnreferenced) {
|
|
471
|
+
for (const entry of evidence) {
|
|
472
|
+
if (!retained.has(entry.id)) ordered.push(entry);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return prefix(ordered, DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence);
|
|
476
|
+
}
|
|
477
|
+
function pruneEvidenceReferences(dependency, retainedIds) {
|
|
478
|
+
return Object.freeze({
|
|
479
|
+
...dependency,
|
|
480
|
+
parameters: Object.freeze(
|
|
481
|
+
dependency.parameters.map(
|
|
482
|
+
(parameter) => Object.freeze({
|
|
483
|
+
...parameter,
|
|
484
|
+
evidenceIds: Object.freeze(
|
|
485
|
+
parameter.evidenceIds.filter((id) => retainedIds.has(id))
|
|
486
|
+
)
|
|
487
|
+
})
|
|
488
|
+
)
|
|
489
|
+
),
|
|
490
|
+
evidenceIds: Object.freeze(
|
|
491
|
+
dependency.evidenceIds.filter((id) => retainedIds.has(id))
|
|
492
|
+
)
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
function truncationCode(mode) {
|
|
496
|
+
return mode === "analysis" ? "DATA_FLOW_ANALYSIS_TRUNCATED" : "DATA_FLOW_OBSERVATION_DROPPED";
|
|
497
|
+
}
|
|
498
|
+
function limitDataFlowReportCollections(report, options = {}) {
|
|
499
|
+
const maximumDependencies = Math.min(
|
|
500
|
+
Math.max(
|
|
501
|
+
0,
|
|
502
|
+
options.maximumDependencies ?? DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
503
|
+
),
|
|
504
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
505
|
+
);
|
|
506
|
+
const dependencyResults = prefix(report.dependencies, maximumDependencies).map(
|
|
507
|
+
limitDependency
|
|
508
|
+
);
|
|
509
|
+
const dependencies = dependencyResults.map(({ dependency }) => dependency);
|
|
510
|
+
const analyzedSourceVersions = prefix(
|
|
511
|
+
report.baseline.analyzedSourceVersions,
|
|
512
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxModules
|
|
513
|
+
);
|
|
514
|
+
const collectionTrimmed = report.dependencies.length > dependencies.length || dependencyResults.some(({ trimmed }) => trimmed) || report.baseline.analyzedSourceVersions.length > analyzedSourceVersions.length || report.capability.reasons.length > DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons || report.evidence.length > DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence || report.diagnostics.length > DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics;
|
|
515
|
+
const truncated = options.forceTruncation === true || collectionTrimmed;
|
|
516
|
+
if (!truncated) return report;
|
|
517
|
+
const mode = options.mode ?? "analysis";
|
|
518
|
+
const code = truncationCode(mode);
|
|
519
|
+
const diagnosticId = `${report.reportId}_collection_${mode}`;
|
|
520
|
+
const reasons = Object.freeze([
|
|
521
|
+
...report.capability.reasons.filter((reason) => reason.code !== code).slice(0, DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons - 1),
|
|
522
|
+
Object.freeze({ code, retryable: false })
|
|
523
|
+
]);
|
|
524
|
+
const diagnostics = Object.freeze([
|
|
525
|
+
...report.diagnostics.filter((diagnostic) => diagnostic.id !== diagnosticId).slice(0, DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics - 1),
|
|
526
|
+
Object.freeze({
|
|
527
|
+
id: diagnosticId,
|
|
528
|
+
code,
|
|
529
|
+
severity: "warning",
|
|
530
|
+
retryable: false,
|
|
531
|
+
evidenceIds: Object.freeze([])
|
|
532
|
+
})
|
|
533
|
+
]);
|
|
534
|
+
const referencedIds = referencedEvidenceIds(dependencies, diagnostics);
|
|
535
|
+
const evidence = prioritizeEvidence(
|
|
536
|
+
report.evidence,
|
|
537
|
+
referencedIds,
|
|
538
|
+
report.dependencies.length === dependencies.length
|
|
539
|
+
);
|
|
540
|
+
const retainedEvidenceIds = new Set(evidence.map(({ id }) => id));
|
|
541
|
+
const prunedDependencies = Object.freeze(
|
|
542
|
+
dependencies.map(
|
|
543
|
+
(dependency) => pruneEvidenceReferences(dependency, retainedEvidenceIds)
|
|
544
|
+
)
|
|
545
|
+
);
|
|
546
|
+
const prunedDiagnostics = Object.freeze(
|
|
547
|
+
diagnostics.map(
|
|
548
|
+
(diagnostic) => Object.freeze({
|
|
549
|
+
...diagnostic,
|
|
550
|
+
evidenceIds: Object.freeze(
|
|
551
|
+
diagnostic.evidenceIds.filter((id) => retainedEvidenceIds.has(id))
|
|
552
|
+
)
|
|
553
|
+
})
|
|
554
|
+
)
|
|
555
|
+
);
|
|
556
|
+
const removedDependencies = report.dependencies.length - dependencies.length;
|
|
557
|
+
const removedModules = report.baseline.analyzedSourceVersions.length - analyzedSourceVersions.length;
|
|
558
|
+
const derivedTruncation = removedModules > 0 && removedDependencies === 0 ? "modules" : "callsites";
|
|
559
|
+
return Object.freeze({
|
|
560
|
+
...report,
|
|
561
|
+
baseline: Object.freeze({
|
|
562
|
+
...report.baseline,
|
|
563
|
+
analyzedSourceVersions
|
|
564
|
+
}),
|
|
565
|
+
capability: Object.freeze({
|
|
566
|
+
...report.capability,
|
|
567
|
+
...mode === "analysis" && report.capability.staticAnalysis === "available" ? { staticAnalysis: "partial" } : {},
|
|
568
|
+
reasons
|
|
569
|
+
}),
|
|
570
|
+
dependencies: prunedDependencies,
|
|
571
|
+
evidence,
|
|
572
|
+
diagnostics: prunedDiagnostics,
|
|
573
|
+
...mode === "analysis" ? {
|
|
574
|
+
completeness: Object.freeze({
|
|
575
|
+
...report.completeness,
|
|
576
|
+
complete: false,
|
|
577
|
+
frontierCount: report.completeness.frontierCount + removedDependencies + removedModules + (collectionTrimmed && removedDependencies === 0 && removedModules === 0 ? 1 : 0),
|
|
578
|
+
truncatedBy: options.truncatedBy ?? report.completeness.truncatedBy ?? derivedTruncation
|
|
579
|
+
})
|
|
580
|
+
} : {}
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// src/model/runtime-config.ts
|
|
585
|
+
import { z as z2 } from "zod";
|
|
586
|
+
|
|
587
|
+
// src/model/editor.ts
|
|
588
|
+
var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
|
|
210
589
|
|
|
211
590
|
// src/model/runtime-config.ts
|
|
212
591
|
var SPOTPATCH_NEXT_BUNDLERS = Object.freeze(["turbopack", "webpack"]);
|
|
@@ -215,39 +594,39 @@ var SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([
|
|
|
215
594
|
"pages",
|
|
216
595
|
"hybrid"
|
|
217
596
|
]);
|
|
218
|
-
var
|
|
219
|
-
var profileIdSchema =
|
|
220
|
-
var runtimeAiModelSchema =
|
|
597
|
+
var boundedText2 = (maximum) => z2.string().trim().min(1).max(maximum);
|
|
598
|
+
var profileIdSchema = z2.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
|
|
599
|
+
var runtimeAiModelSchema = z2.strictObject({
|
|
221
600
|
id: profileIdSchema,
|
|
222
|
-
label:
|
|
601
|
+
label: boundedText2(100)
|
|
223
602
|
});
|
|
224
|
-
var runtimeAiProviderSchema =
|
|
603
|
+
var runtimeAiProviderSchema = z2.strictObject({
|
|
225
604
|
id: profileIdSchema,
|
|
226
|
-
label:
|
|
227
|
-
protocol:
|
|
228
|
-
models:
|
|
605
|
+
label: boundedText2(100),
|
|
606
|
+
protocol: z2.enum(["responses", "chat-completions"]),
|
|
607
|
+
models: z2.array(runtimeAiModelSchema).min(1).max(64),
|
|
229
608
|
defaultModel: profileIdSchema
|
|
230
609
|
}).refine(
|
|
231
610
|
({ defaultModel, models }) => models.some(({ id }) => id === defaultModel) && new Set(models.map(({ id }) => id)).size === models.length,
|
|
232
611
|
{ message: "Runtime AI model profiles are inconsistent." }
|
|
233
612
|
);
|
|
234
|
-
var runtimeAiConfigSchema =
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
enabled:
|
|
238
|
-
providers:
|
|
613
|
+
var runtimeAiConfigSchema = z2.discriminatedUnion("enabled", [
|
|
614
|
+
z2.strictObject({ enabled: z2.literal(false) }),
|
|
615
|
+
z2.strictObject({
|
|
616
|
+
enabled: z2.literal(true),
|
|
617
|
+
providers: z2.array(runtimeAiProviderSchema).min(1).max(32),
|
|
239
618
|
defaultProvider: profileIdSchema,
|
|
240
|
-
applyMode:
|
|
619
|
+
applyMode: z2.enum(AGENT_APPLY_MODES)
|
|
241
620
|
}).refine(
|
|
242
621
|
({ defaultProvider, providers }) => providers.some(({ id }) => id === defaultProvider) && new Set(providers.map(({ id }) => id)).size === providers.length,
|
|
243
622
|
{ message: "Runtime AI provider profiles are inconsistent." }
|
|
244
623
|
)
|
|
245
624
|
]);
|
|
246
|
-
var positiveInteger =
|
|
625
|
+
var positiveInteger = z2.number().int().positive();
|
|
247
626
|
var runtimeConfigBaseShape = {
|
|
248
|
-
apiBase:
|
|
627
|
+
apiBase: z2.literal(SPOTPATCH_API_BASE),
|
|
249
628
|
ai: runtimeAiConfigSchema,
|
|
250
|
-
budget:
|
|
629
|
+
budget: z2.strictObject({
|
|
251
630
|
totalCharacters: positiveInteger,
|
|
252
631
|
domCharacters: positiveInteger,
|
|
253
632
|
cssCharacters: positiveInteger,
|
|
@@ -255,27 +634,29 @@ var runtimeConfigBaseShape = {
|
|
|
255
634
|
maxCodeLines: positiveInteger,
|
|
256
635
|
maxComponentDepth: positiveInteger
|
|
257
636
|
}),
|
|
258
|
-
debug:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
637
|
+
debug: z2.boolean(),
|
|
638
|
+
dataFlow: runtimeDataFlowConfigSchema,
|
|
639
|
+
editor: z2.enum(SPOTPATCH_EDITOR_PREFERENCES),
|
|
640
|
+
externalAgent: z2.strictObject({ enabled: z2.boolean() }),
|
|
641
|
+
frameworkVersion: boundedText2(64),
|
|
642
|
+
locale: z2.enum(SPOTPATCH_LOCALE_PREFERENCES),
|
|
643
|
+
maxTargets: z2.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
|
|
644
|
+
redact: z2.boolean(),
|
|
645
|
+
sessionId: z2.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
646
|
+
sessionToken: z2.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
647
|
+
shortcut: boundedText2(128),
|
|
648
|
+
spotPatchVersion: boundedText2(64)
|
|
268
649
|
};
|
|
269
|
-
var runtimeConfigSchema =
|
|
270
|
-
|
|
650
|
+
var runtimeConfigSchema = z2.discriminatedUnion("framework", [
|
|
651
|
+
z2.strictObject({
|
|
271
652
|
...runtimeConfigBaseShape,
|
|
272
|
-
framework:
|
|
653
|
+
framework: z2.literal("vite")
|
|
273
654
|
}),
|
|
274
|
-
|
|
655
|
+
z2.strictObject({
|
|
275
656
|
...runtimeConfigBaseShape,
|
|
276
|
-
bundler:
|
|
277
|
-
framework:
|
|
278
|
-
routerKind:
|
|
657
|
+
bundler: z2.enum(SPOTPATCH_NEXT_BUNDLERS),
|
|
658
|
+
framework: z2.literal("next"),
|
|
659
|
+
routerKind: z2.enum(SPOTPATCH_NEXT_ROUTER_KINDS)
|
|
279
660
|
})
|
|
280
661
|
]);
|
|
281
662
|
|
|
@@ -302,130 +683,16 @@ function parseSourceMarker(value) {
|
|
|
302
683
|
return Object.freeze({ fileId, line, column });
|
|
303
684
|
}
|
|
304
685
|
|
|
305
|
-
// src/protocol/requests.ts
|
|
306
|
-
import { z as z2 } from "zod";
|
|
307
|
-
var runtimeBootstrapRequestSchema = z2.strictObject({});
|
|
308
|
-
var sourceCoordinatesSchema = z2.strictObject({
|
|
309
|
-
fileId: z2.string().min(1).max(128),
|
|
310
|
-
line: z2.number().int().positive(),
|
|
311
|
-
column: z2.number().int().positive()
|
|
312
|
-
});
|
|
313
|
-
var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
|
|
314
|
-
maxLines: z2.number().int().positive()
|
|
315
|
-
}).strict();
|
|
316
|
-
var openEditorRequestSchema = sourceCoordinatesSchema.strict();
|
|
317
|
-
var profileIdSchema2 = z2.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
318
|
-
var boundedString = (maximum) => z2.string().max(maximum);
|
|
319
|
-
var sourceRefSchema = z2.strictObject({
|
|
320
|
-
fileId: boundedString(128).optional(),
|
|
321
|
-
relativePath: boundedString(1024).optional(),
|
|
322
|
-
line: z2.number().int().positive().optional(),
|
|
323
|
-
column: z2.number().int().positive().optional(),
|
|
324
|
-
origin: z2.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
|
|
325
|
-
confidence: z2.enum(["exact", "probable", "approximate", "unknown"])
|
|
326
|
-
});
|
|
327
|
-
var matchedStyleRuleSchema = z2.strictObject({
|
|
328
|
-
selector: boundedString(2048),
|
|
329
|
-
declarations: boundedString(8192),
|
|
330
|
-
source: boundedString(1024).optional(),
|
|
331
|
-
media: boundedString(1024).optional()
|
|
332
|
-
});
|
|
333
|
-
var codeContextSchema = z2.strictObject({
|
|
334
|
-
relativePath: boundedString(1024),
|
|
335
|
-
language: z2.enum(["tsx", "jsx"]),
|
|
336
|
-
startLine: z2.number().int().positive(),
|
|
337
|
-
endLine: z2.number().int().positive(),
|
|
338
|
-
excerpt: boundedString(16e3),
|
|
339
|
-
boundary: z2.enum(["component", "nearby-lines"])
|
|
340
|
-
});
|
|
341
|
-
var pageContextSchema = z2.strictObject({
|
|
342
|
-
url: boundedString(2048),
|
|
343
|
-
pathname: boundedString(2048),
|
|
344
|
-
title: boundedString(1024),
|
|
345
|
-
viewportWidth: z2.number().nonnegative(),
|
|
346
|
-
viewportHeight: z2.number().nonnegative(),
|
|
347
|
-
devicePixelRatio: z2.number().positive()
|
|
348
|
-
});
|
|
349
|
-
var spotTargetContextRequestSchema = z2.strictObject({
|
|
350
|
-
instruction: z2.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
351
|
-
page: pageContextSchema.optional(),
|
|
352
|
-
source: sourceRefSchema,
|
|
353
|
-
react: z2.strictObject({
|
|
354
|
-
supported: z2.boolean(),
|
|
355
|
-
version: boundedString(64).optional(),
|
|
356
|
-
componentName: boundedString(256).optional(),
|
|
357
|
-
componentStack: z2.array(boundedString(256)).max(64),
|
|
358
|
-
source: sourceRefSchema.optional()
|
|
359
|
-
}),
|
|
360
|
-
element: z2.strictObject({
|
|
361
|
-
tagName: boundedString(128),
|
|
362
|
-
selector: boundedString(2048),
|
|
363
|
-
sanitizedHtml: boundedString(8192),
|
|
364
|
-
textPreview: boundedString(2048).optional(),
|
|
365
|
-
role: boundedString(256).optional(),
|
|
366
|
-
rect: z2.strictObject({
|
|
367
|
-
x: z2.number(),
|
|
368
|
-
y: z2.number(),
|
|
369
|
-
width: z2.number().nonnegative(),
|
|
370
|
-
height: z2.number().nonnegative()
|
|
371
|
-
})
|
|
372
|
-
}),
|
|
373
|
-
styles: z2.strictObject({
|
|
374
|
-
classNames: z2.array(boundedString(512)).max(256),
|
|
375
|
-
inlineStyle: boundedString(8192).optional(),
|
|
376
|
-
matchedRules: z2.array(matchedStyleRuleSchema).max(256),
|
|
377
|
-
computed: z2.record(boundedString(256), boundedString(2048)),
|
|
378
|
-
warnings: z2.array(boundedString(1024)).max(64)
|
|
379
|
-
}),
|
|
380
|
-
code: codeContextSchema.optional(),
|
|
381
|
-
warnings: z2.array(boundedString(1024)).max(64)
|
|
382
|
-
});
|
|
383
|
-
var spotAnnotationRequestSchema = z2.strictObject({
|
|
384
|
-
schemaVersion: z2.literal(3),
|
|
385
|
-
id: boundedString(128),
|
|
386
|
-
locale: z2.enum(SPOTPATCH_LOCALES),
|
|
387
|
-
page: pageContextSchema,
|
|
388
|
-
targets: z2.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
389
|
-
createdAt: z2.iso.datetime()
|
|
390
|
-
}).superRefine((annotation, context) => {
|
|
391
|
-
const total = annotation.targets.reduce(
|
|
392
|
-
(characters, target) => characters + target.instruction.length,
|
|
393
|
-
0
|
|
394
|
-
);
|
|
395
|
-
if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {
|
|
396
|
-
context.addIssue({
|
|
397
|
-
code: "custom",
|
|
398
|
-
message: "Combined target instructions exceed the annotation limit.",
|
|
399
|
-
path: ["targets"]
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
var agentCapabilityRequestSchema = z2.strictObject({
|
|
404
|
-
providerProfileId: profileIdSchema2,
|
|
405
|
-
modelProfileId: profileIdSchema2
|
|
406
|
-
});
|
|
407
|
-
var agentWorkspaceHealthRequestSchema = z2.strictObject({});
|
|
408
|
-
var agentJobCreateRequestSchema = z2.strictObject({
|
|
409
|
-
annotation: spotAnnotationRequestSchema,
|
|
410
|
-
applyMode: z2.enum(AGENT_APPLY_MODES).optional(),
|
|
411
|
-
providerProfileId: profileIdSchema2,
|
|
412
|
-
modelProfileId: profileIdSchema2,
|
|
413
|
-
providerDataConsent: z2.literal(true),
|
|
414
|
-
trustedFastModeConsent: z2.literal(true).optional(),
|
|
415
|
-
workingTreeMode: z2.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
416
|
-
});
|
|
417
|
-
var agentJobActionRequestSchema = z2.strictObject({});
|
|
418
|
-
|
|
419
686
|
// src/protocol/agent-schemas.ts
|
|
420
687
|
import { z as z3 } from "zod";
|
|
421
|
-
var
|
|
422
|
-
var
|
|
688
|
+
var profileIdSchema2 = z3.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
689
|
+
var boundedString = (maximum) => z3.string().max(maximum);
|
|
423
690
|
var errorCodeSchema = z3.enum(ERROR_CODES);
|
|
424
691
|
var agentCapabilitySnapshotSchema = z3.strictObject({
|
|
425
|
-
providerProfileId:
|
|
426
|
-
providerLabel:
|
|
427
|
-
modelProfileId:
|
|
428
|
-
modelLabel:
|
|
692
|
+
providerProfileId: profileIdSchema2,
|
|
693
|
+
providerLabel: boundedString(100),
|
|
694
|
+
modelProfileId: profileIdSchema2,
|
|
695
|
+
modelLabel: boundedString(100),
|
|
429
696
|
protocol: z3.enum(["responses", "chat-completions"]),
|
|
430
697
|
state: z3.enum(AGENT_CAPABILITY_STATES),
|
|
431
698
|
authenticated: z3.boolean(),
|
|
@@ -465,26 +732,26 @@ var agentWorkspaceHealthSnapshotSchema = z3.strictObject({
|
|
|
465
732
|
{ message: "Agent workspace health fields are inconsistent." }
|
|
466
733
|
);
|
|
467
734
|
var agentChangedFileSchema = z3.strictObject({
|
|
468
|
-
relativePath:
|
|
735
|
+
relativePath: boundedString(1024),
|
|
469
736
|
kind: z3.enum(AGENT_FILE_CHANGE_KINDS),
|
|
470
737
|
additions: z3.number().int().nonnegative(),
|
|
471
738
|
deletions: z3.number().int().nonnegative()
|
|
472
739
|
});
|
|
473
740
|
var agentCheckResultSchema = z3.strictObject({
|
|
474
|
-
checkId:
|
|
475
|
-
label:
|
|
741
|
+
checkId: profileIdSchema2,
|
|
742
|
+
label: boundedString(100),
|
|
476
743
|
status: z3.enum(AGENT_CHECK_STATUSES),
|
|
477
744
|
durationMs: z3.number().int().nonnegative(),
|
|
478
|
-
output:
|
|
745
|
+
output: boundedString(8e4)
|
|
479
746
|
});
|
|
480
747
|
var agentJobSnapshotSchema = z3.strictObject({
|
|
481
748
|
jobId: z3.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
482
749
|
status: z3.enum(AGENT_JOB_STATUSES),
|
|
483
|
-
providerProfileId:
|
|
484
|
-
providerLabel:
|
|
485
|
-
modelProfileId:
|
|
486
|
-
modelLabel:
|
|
487
|
-
phaseMessage:
|
|
750
|
+
providerProfileId: profileIdSchema2,
|
|
751
|
+
providerLabel: boundedString(100),
|
|
752
|
+
modelProfileId: profileIdSchema2,
|
|
753
|
+
modelLabel: boundedString(100),
|
|
754
|
+
phaseMessage: boundedString(1024),
|
|
488
755
|
createdAt: z3.iso.datetime(),
|
|
489
756
|
updatedAt: z3.iso.datetime(),
|
|
490
757
|
canCancel: z3.boolean(),
|
|
@@ -494,8 +761,8 @@ var agentJobSnapshotSchema = z3.strictObject({
|
|
|
494
761
|
});
|
|
495
762
|
var agentJobResultSchema = z3.strictObject({
|
|
496
763
|
jobId: z3.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
497
|
-
summary:
|
|
498
|
-
diff:
|
|
764
|
+
summary: boundedString(8e4),
|
|
765
|
+
diff: boundedString(1e6),
|
|
499
766
|
files: z3.array(agentChangedFileSchema).max(100),
|
|
500
767
|
checks: z3.array(agentCheckResultSchema).max(100)
|
|
501
768
|
});
|
|
@@ -525,17 +792,17 @@ var agentJobEventSchema = z3.discriminatedUnion("type", [
|
|
|
525
792
|
}),
|
|
526
793
|
agentJobEventBaseSchema.extend({
|
|
527
794
|
type: z3.literal("phase"),
|
|
528
|
-
data: z3.strictObject({ message:
|
|
795
|
+
data: z3.strictObject({ message: boundedString(1024) })
|
|
529
796
|
}),
|
|
530
797
|
agentJobEventBaseSchema.extend({
|
|
531
798
|
type: z3.literal("tool"),
|
|
532
799
|
data: z3.strictObject({
|
|
533
800
|
turn: z3.number().int().positive(),
|
|
534
|
-
toolCallId:
|
|
535
|
-
toolName:
|
|
801
|
+
toolCallId: boundedString(256),
|
|
802
|
+
toolName: boundedString(100),
|
|
536
803
|
state: z3.enum(["started", "succeeded", "failed"]),
|
|
537
|
-
relativePath:
|
|
538
|
-
checkLabel:
|
|
804
|
+
relativePath: boundedString(1024).optional(),
|
|
805
|
+
checkLabel: boundedString(100).optional()
|
|
539
806
|
})
|
|
540
807
|
}),
|
|
541
808
|
agentJobEventBaseSchema.extend({
|
|
@@ -550,7 +817,7 @@ var agentJobEventSchema = z3.discriminatedUnion("type", [
|
|
|
550
817
|
type: z3.literal("error"),
|
|
551
818
|
data: z3.strictObject({
|
|
552
819
|
code: errorCodeSchema,
|
|
553
|
-
message:
|
|
820
|
+
message: boundedString(1024)
|
|
554
821
|
})
|
|
555
822
|
})
|
|
556
823
|
]).superRefine((event, context) => {
|
|
@@ -583,8 +850,33 @@ export {
|
|
|
583
850
|
AGENT_JOB_STATUSES,
|
|
584
851
|
AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
585
852
|
AGENT_WORKSPACE_STATES,
|
|
853
|
+
DATA_FLOW_ASSOCIATION_KINDS,
|
|
854
|
+
DATA_FLOW_DIAGNOSTIC_CODES,
|
|
855
|
+
DATA_FLOW_EXECUTION_STATES,
|
|
856
|
+
DATA_FLOW_FRESHNESS_STATES,
|
|
857
|
+
DATA_FLOW_PROOF_STATES,
|
|
858
|
+
DATA_FLOW_QUERY_ADAPTER_MODULES,
|
|
859
|
+
DATA_FLOW_QUERY_HOOK_NAMES,
|
|
860
|
+
DATA_FLOW_SCHEMA_VERSION,
|
|
861
|
+
DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES,
|
|
862
|
+
DATA_FLOW_TRPC_PROXY_FACTORY_NAMES,
|
|
863
|
+
DATA_FLOW_TRPC_REQUEST_METHODS,
|
|
864
|
+
DATA_FLOW_TRPC_ROOT_FACTORY_NAMES,
|
|
865
|
+
DATA_FLOW_URL_QUERY_KEY_LIMIT,
|
|
586
866
|
DEFAULT_AGENT_LIMITS,
|
|
867
|
+
DEFAULT_DATA_FLOW_LIMITS,
|
|
868
|
+
DEFAULT_RUNTIME_DATA_FLOW_LIMITS,
|
|
587
869
|
ERROR_CODES,
|
|
870
|
+
ERROR_CODE_VALUES,
|
|
871
|
+
EXTERNAL_HANDOFF_ACTIVE_ADAPTER_KINDS,
|
|
872
|
+
EXTERNAL_HANDOFF_ACTIVE_ADAPTER_STATES,
|
|
873
|
+
EXTERNAL_HANDOFF_BROKER_PROTOCOL_VERSION,
|
|
874
|
+
EXTERNAL_HANDOFF_DISPATCH_PHASES,
|
|
875
|
+
EXTERNAL_HANDOFF_FRAMEWORKS,
|
|
876
|
+
EXTERNAL_HANDOFF_LIMITS,
|
|
877
|
+
EXTERNAL_HANDOFF_REPORTABLE_DISPATCH_PHASES,
|
|
878
|
+
EXTERNAL_HANDOFF_SNAPSHOT_SCHEMA_VERSION,
|
|
879
|
+
EXTERNAL_HANDOFF_STATES,
|
|
588
880
|
MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
|
|
589
881
|
MAX_ANNOTATION_TARGETS,
|
|
590
882
|
MAX_TARGET_INSTRUCTION_CHARACTERS,
|
|
@@ -599,6 +891,7 @@ export {
|
|
|
599
891
|
SPOTPATCH_REPOSITORY_URL,
|
|
600
892
|
SPOTPATCH_TOKEN_HEADER,
|
|
601
893
|
SpotPatchError,
|
|
894
|
+
activeAdapterSummarySchema,
|
|
602
895
|
agentCapabilityRequestSchema,
|
|
603
896
|
agentCapabilitySnapshotSchema,
|
|
604
897
|
agentChangedFileSchema,
|
|
@@ -611,14 +904,35 @@ export {
|
|
|
611
904
|
agentJobSnapshotSchema,
|
|
612
905
|
agentWorkspaceHealthRequestSchema,
|
|
613
906
|
agentWorkspaceHealthSnapshotSchema,
|
|
907
|
+
componentDataFlowReportSchema,
|
|
908
|
+
dataDependencySchema,
|
|
909
|
+
dataFlowComponentReportRequestSchema,
|
|
910
|
+
dataFlowPageReportRequestSchema,
|
|
911
|
+
dispatchSummarySchema,
|
|
912
|
+
externalHandoffCapabilityRequestSchema,
|
|
913
|
+
externalHandoffCapabilitySchema,
|
|
914
|
+
externalHandoffPublishDeliverySchema,
|
|
915
|
+
externalHandoffPublishRequestSchema,
|
|
916
|
+
externalHandoffPublishResultSchema,
|
|
917
|
+
externalHandoffReportableDispatchPhaseSchema,
|
|
918
|
+
externalHandoffResolveDeliveryRequestSchema,
|
|
919
|
+
externalHandoffSnapshotSchema,
|
|
920
|
+
externalHandoffStatusRequestSchema,
|
|
921
|
+
externalHandoffStatusResultSchema,
|
|
922
|
+
externalHandoffSummarySchema,
|
|
614
923
|
formatSourceMarker,
|
|
615
924
|
getAgentJobEndpoint,
|
|
925
|
+
isErrorCode,
|
|
616
926
|
isSensitiveName,
|
|
927
|
+
limitDataFlowReportCollections,
|
|
928
|
+
networkObservationSchema,
|
|
617
929
|
openEditorRequestSchema,
|
|
930
|
+
pageDataFlowReportSchema,
|
|
618
931
|
parseSourceMarker,
|
|
619
932
|
redactSensitiveText,
|
|
620
933
|
runtimeBootstrapRequestSchema,
|
|
621
934
|
runtimeConfigSchema,
|
|
935
|
+
runtimeDataFlowConfigSchema,
|
|
622
936
|
sanitizeUrl,
|
|
623
937
|
sourceContextRequestSchema,
|
|
624
938
|
spotAnnotationRequestSchema,
|