@spotpatch/shared 1.7.0 → 1.9.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-K2UAPG7T.js +55 -0
- package/dist/chunk-K2UAPG7T.js.map +1 -0
- package/dist/data-flow-runtime-zwbvImvl.d.cts +672 -0
- package/dist/data-flow-runtime-zwbvImvl.d.ts +672 -0
- package/dist/data-flow-runtime.cjs +74 -0
- package/dist/data-flow-runtime.cjs.map +1 -0
- package/dist/data-flow-runtime.d.cts +2 -0
- package/dist/data-flow-runtime.d.ts +2 -0
- package/dist/data-flow-runtime.js +11 -0
- package/dist/data-flow-runtime.js.map +1 -0
- package/dist/index.cjs +700 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -14
- package/dist/index.d.ts +88 -14
- package/dist/index.js +655 -165
- package/dist/index.js.map +1 -1
- package/package.json +19 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
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
|
+
SPOTPATCH_API_BASE,
|
|
7
|
+
SPOTPATCH_ENDPOINTS,
|
|
8
|
+
SPOTPATCH_TOKEN_HEADER,
|
|
9
|
+
getAgentJobEndpoint
|
|
10
|
+
} from "./chunk-K2UAPG7T.js";
|
|
11
|
+
|
|
1
12
|
// src/errors/spotpatch-error.ts
|
|
2
13
|
var SpotPatchError = class extends Error {
|
|
3
14
|
code;
|
|
@@ -17,6 +28,9 @@ var ERROR_CODES = {
|
|
|
17
28
|
SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT",
|
|
18
29
|
SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE",
|
|
19
30
|
EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED",
|
|
31
|
+
DATA_FLOW_DISABLED: "DATA_FLOW_DISABLED",
|
|
32
|
+
DATA_FLOW_SOURCE_STALE: "DATA_FLOW_SOURCE_STALE",
|
|
33
|
+
DATA_FLOW_ANALYSIS_CANCELLED: "DATA_FLOW_ANALYSIS_CANCELLED",
|
|
20
34
|
AI_DISABLED: "AI_DISABLED",
|
|
21
35
|
PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED",
|
|
22
36
|
PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
|
|
@@ -124,23 +138,455 @@ var SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([
|
|
|
124
138
|
...SPOTPATCH_LOCALES
|
|
125
139
|
]);
|
|
126
140
|
|
|
127
|
-
// src/model/
|
|
141
|
+
// src/model/data-flow-adapters.ts
|
|
142
|
+
var DATA_FLOW_QUERY_ADAPTER_MODULES = Object.freeze([
|
|
143
|
+
"@tanstack/react-query",
|
|
144
|
+
"react-query"
|
|
145
|
+
]);
|
|
146
|
+
var DATA_FLOW_QUERY_HOOK_NAMES = Object.freeze([
|
|
147
|
+
"useInfiniteQuery",
|
|
148
|
+
"useMutation",
|
|
149
|
+
"useQuery"
|
|
150
|
+
]);
|
|
151
|
+
var DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES = Object.freeze([
|
|
152
|
+
"createTRPCClient",
|
|
153
|
+
"createTRPCProxyClient"
|
|
154
|
+
]);
|
|
155
|
+
var DATA_FLOW_TRPC_PROXY_FACTORY_NAMES = Object.freeze([
|
|
156
|
+
"createTRPCNext",
|
|
157
|
+
"createTRPCReact"
|
|
158
|
+
]);
|
|
159
|
+
var DATA_FLOW_TRPC_ROOT_FACTORY_NAMES = Object.freeze([
|
|
160
|
+
...DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES,
|
|
161
|
+
...DATA_FLOW_TRPC_PROXY_FACTORY_NAMES,
|
|
162
|
+
"createTRPCContext",
|
|
163
|
+
"createTRPCOptionsProxy"
|
|
164
|
+
]);
|
|
165
|
+
var DATA_FLOW_TRPC_REQUEST_METHODS = Object.freeze([
|
|
166
|
+
"infiniteQueryOptions",
|
|
167
|
+
"mutate",
|
|
168
|
+
"mutateAsync",
|
|
169
|
+
"mutationOptions",
|
|
170
|
+
"query",
|
|
171
|
+
"queryOptions",
|
|
172
|
+
"refetch",
|
|
173
|
+
"subscribe",
|
|
174
|
+
"subscriptionOptions",
|
|
175
|
+
"useInfiniteQuery",
|
|
176
|
+
"useMutation",
|
|
177
|
+
"useQuery",
|
|
178
|
+
"useSubscription",
|
|
179
|
+
"useSuspenseInfiniteQuery",
|
|
180
|
+
"useSuspenseQuery"
|
|
181
|
+
]);
|
|
182
|
+
|
|
183
|
+
// src/model/data-flow.ts
|
|
128
184
|
import { z } from "zod";
|
|
185
|
+
var DATA_FLOW_EXECUTION_STATES = Object.freeze([
|
|
186
|
+
"observed",
|
|
187
|
+
"declared-not-observed",
|
|
188
|
+
"not-applicable",
|
|
189
|
+
"unknown"
|
|
190
|
+
]);
|
|
191
|
+
var DATA_FLOW_PROOF_STATES = Object.freeze([
|
|
192
|
+
"proven",
|
|
193
|
+
"candidate",
|
|
194
|
+
"unavailable",
|
|
195
|
+
"conflict"
|
|
196
|
+
]);
|
|
197
|
+
var DATA_FLOW_ASSOCIATION_KINDS = Object.freeze([
|
|
198
|
+
"direct",
|
|
199
|
+
"transitive",
|
|
200
|
+
"upstream",
|
|
201
|
+
"possible",
|
|
202
|
+
"unassigned",
|
|
203
|
+
"unknown"
|
|
204
|
+
]);
|
|
205
|
+
var DATA_FLOW_FRESHNESS_STATES = Object.freeze([
|
|
206
|
+
"current",
|
|
207
|
+
"stale-source",
|
|
208
|
+
"stale-route",
|
|
209
|
+
"expired"
|
|
210
|
+
]);
|
|
211
|
+
var DATA_FLOW_DIAGNOSTIC_CODES = Object.freeze([
|
|
212
|
+
"DATA_FLOW_CAPABILITY_DISABLED",
|
|
213
|
+
"DATA_FLOW_CAPABILITY_PRELUDE_UNAVAILABLE",
|
|
214
|
+
"DATA_FLOW_CAPABILITY_UNSUPPORTED_FRAMEWORK",
|
|
215
|
+
"DATA_FLOW_SOURCE_UNAVAILABLE",
|
|
216
|
+
"DATA_FLOW_SOURCE_STALE",
|
|
217
|
+
"DATA_FLOW_ANALYSIS_TIMEOUT",
|
|
218
|
+
"DATA_FLOW_ANALYSIS_TRUNCATED",
|
|
219
|
+
"DATA_FLOW_ANALYSIS_UNRESOLVED_CALL",
|
|
220
|
+
"DATA_FLOW_OBSERVATION_UNASSIGNED",
|
|
221
|
+
"DATA_FLOW_OBSERVATION_DROPPED",
|
|
222
|
+
"DATA_FLOW_REDACTION_APPLIED",
|
|
223
|
+
"DATA_FLOW_AI_DISABLED"
|
|
224
|
+
]);
|
|
225
|
+
var boundedText = (maximum) => z.string().trim().min(1).max(maximum);
|
|
226
|
+
var opaqueIdSchema = boundedText(128).regex(/^[A-Za-z0-9_-]+$/u);
|
|
227
|
+
var diagnosticCodeSchema = z.enum(DATA_FLOW_DIAGNOSTIC_CODES);
|
|
228
|
+
var evidenceSourceSchema = z.strictObject({
|
|
229
|
+
fileId: opaqueIdSchema,
|
|
230
|
+
displayPath: boundedText(1024),
|
|
231
|
+
line: z.number().int().positive(),
|
|
232
|
+
column: z.number().int().positive(),
|
|
233
|
+
sourceVersion: opaqueIdSchema
|
|
234
|
+
});
|
|
235
|
+
var sanitizedObservedUrlSchema = z.strictObject({
|
|
236
|
+
origin: boundedText(512).optional(),
|
|
237
|
+
pathname: boundedText(2048),
|
|
238
|
+
queryKeys: z.array(boundedText(256)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
|
|
239
|
+
});
|
|
240
|
+
var dataParameterSchema = z.strictObject({
|
|
241
|
+
path: boundedText(1024),
|
|
242
|
+
position: z.enum([
|
|
243
|
+
"path",
|
|
244
|
+
"query",
|
|
245
|
+
"body",
|
|
246
|
+
"header",
|
|
247
|
+
"cookie",
|
|
248
|
+
"variable",
|
|
249
|
+
"form",
|
|
250
|
+
"unknown"
|
|
251
|
+
]),
|
|
252
|
+
type: boundedText(512).optional(),
|
|
253
|
+
source: boundedText(1024).optional(),
|
|
254
|
+
condition: boundedText(1024).optional(),
|
|
255
|
+
sensitive: z.boolean(),
|
|
256
|
+
valueState: z.literal("not-collected"),
|
|
257
|
+
evidenceIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
258
|
+
});
|
|
259
|
+
var dataResponseSchema = z.strictObject({
|
|
260
|
+
consumedFields: z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
|
|
261
|
+
});
|
|
262
|
+
var requestOriginSchema = z.strictObject({
|
|
263
|
+
componentSourceId: opaqueIdSchema.optional(),
|
|
264
|
+
triggerCallsiteId: opaqueIdSchema.optional(),
|
|
265
|
+
requestCallsiteId: opaqueIdSchema,
|
|
266
|
+
sourceVersion: opaqueIdSchema
|
|
267
|
+
});
|
|
268
|
+
var capabilityReasonSchema = z.strictObject({
|
|
269
|
+
code: diagnosticCodeSchema,
|
|
270
|
+
retryable: z.boolean()
|
|
271
|
+
});
|
|
272
|
+
var capabilitySchema = z.strictObject({
|
|
273
|
+
enabled: z.boolean(),
|
|
274
|
+
staticAnalysis: z.enum(["available", "partial", "unavailable"]),
|
|
275
|
+
runtimeObservation: z.literal("dispatch-only"),
|
|
276
|
+
responseShape: z.literal("consumed-fields-only"),
|
|
277
|
+
aiAssistance: z.literal("disabled"),
|
|
278
|
+
reasons: z.array(capabilityReasonSchema).max(DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons)
|
|
279
|
+
});
|
|
280
|
+
var evidenceSchema = z.strictObject({
|
|
281
|
+
id: opaqueIdSchema,
|
|
282
|
+
kind: z.enum([
|
|
283
|
+
"source-anchor",
|
|
284
|
+
"import-resolution",
|
|
285
|
+
"symbol-edge",
|
|
286
|
+
"trigger-edge",
|
|
287
|
+
"call-edge",
|
|
288
|
+
"data-binding",
|
|
289
|
+
"adapter-rule",
|
|
290
|
+
"runtime-observation",
|
|
291
|
+
"runtime-reference",
|
|
292
|
+
"diagnostic"
|
|
293
|
+
]),
|
|
294
|
+
source: evidenceSourceSchema.optional(),
|
|
295
|
+
adapter: z.strictObject({ id: boundedText(128), version: boundedText(64) }).optional(),
|
|
296
|
+
summaryKey: boundedText(256)
|
|
297
|
+
});
|
|
298
|
+
var diagnosticSchema = z.strictObject({
|
|
299
|
+
id: opaqueIdSchema,
|
|
300
|
+
code: diagnosticCodeSchema,
|
|
301
|
+
severity: z.enum(["info", "warning", "error"]),
|
|
302
|
+
retryable: z.boolean(),
|
|
303
|
+
evidenceIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
304
|
+
});
|
|
305
|
+
var baselineSchema = z.strictObject({
|
|
306
|
+
registryEpoch: opaqueIdSchema,
|
|
307
|
+
analyzerVersion: boundedText(64),
|
|
308
|
+
adapterSetHash: boundedText(128),
|
|
309
|
+
analyzedSourceVersions: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxModules)
|
|
310
|
+
});
|
|
311
|
+
var completenessSchema = z.strictObject({
|
|
312
|
+
complete: z.boolean(),
|
|
313
|
+
visitedModules: z.number().int().nonnegative(),
|
|
314
|
+
visitedCallsites: z.number().int().nonnegative(),
|
|
315
|
+
frontierCount: z.number().int().nonnegative(),
|
|
316
|
+
truncatedBy: z.enum(["depth", "modules", "callsites", "bytes", "timeout"]).optional()
|
|
317
|
+
});
|
|
318
|
+
var dataDependencySchema = z.strictObject({
|
|
319
|
+
id: opaqueIdSchema,
|
|
320
|
+
kind: z.enum(["http", "graphql", "rpc", "server-action", "unknown"]),
|
|
321
|
+
direction: z.enum(["read", "write", "read-write", "unknown"]),
|
|
322
|
+
execution: z.enum(DATA_FLOW_EXECUTION_STATES),
|
|
323
|
+
proof: z.enum(DATA_FLOW_PROOF_STATES),
|
|
324
|
+
association: z.enum(DATA_FLOW_ASSOCIATION_KINDS),
|
|
325
|
+
method: boundedText(32).optional(),
|
|
326
|
+
operation: boundedText(512).optional(),
|
|
327
|
+
url: sanitizedObservedUrlSchema.optional(),
|
|
328
|
+
parameters: z.array(dataParameterSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields),
|
|
329
|
+
response: dataResponseSchema,
|
|
330
|
+
origin: requestOriginSchema.optional(),
|
|
331
|
+
suppliedBindings: z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
332
|
+
locationIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
333
|
+
evidenceIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
334
|
+
observationIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries)
|
|
335
|
+
});
|
|
336
|
+
var networkObservationSchema = z.strictObject({
|
|
337
|
+
schemaVersion: z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
338
|
+
id: opaqueIdSchema,
|
|
339
|
+
pageEpoch: opaqueIdSchema,
|
|
340
|
+
routeEpoch: opaqueIdSchema,
|
|
341
|
+
requestCallsiteId: opaqueIdSchema.optional(),
|
|
342
|
+
invocationId: opaqueIdSchema.optional(),
|
|
343
|
+
componentSourceId: opaqueIdSchema.optional(),
|
|
344
|
+
triggerCallsiteId: opaqueIdSchema.optional(),
|
|
345
|
+
sourceVersion: opaqueIdSchema.optional(),
|
|
346
|
+
transport: z.enum(["fetch", "trpc", "xhr"]),
|
|
347
|
+
method: boundedText(32),
|
|
348
|
+
operation: boundedText(512).optional(),
|
|
349
|
+
url: sanitizedObservedUrlSchema,
|
|
350
|
+
outcome: z.literal("dispatched"),
|
|
351
|
+
freshness: z.enum(DATA_FLOW_FRESHNESS_STATES),
|
|
352
|
+
diagnosticIds: z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
|
|
353
|
+
});
|
|
354
|
+
var componentIdentitySchema = z.strictObject({
|
|
355
|
+
componentSourceId: opaqueIdSchema.optional(),
|
|
356
|
+
displayName: boundedText(256).optional(),
|
|
357
|
+
source: evidenceSourceSchema
|
|
358
|
+
});
|
|
359
|
+
var componentDataFlowReportSchema = z.strictObject({
|
|
360
|
+
schemaVersion: z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
361
|
+
reportId: opaqueIdSchema,
|
|
362
|
+
baseline: baselineSchema,
|
|
363
|
+
capability: capabilitySchema,
|
|
364
|
+
component: componentIdentitySchema,
|
|
365
|
+
dependencies: z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
366
|
+
evidence: z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
367
|
+
diagnostics: z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
|
|
368
|
+
completeness: completenessSchema
|
|
369
|
+
});
|
|
370
|
+
var pageDataFlowReportSchema = z.strictObject({
|
|
371
|
+
schemaVersion: z.literal(DATA_FLOW_SCHEMA_VERSION),
|
|
372
|
+
reportId: opaqueIdSchema,
|
|
373
|
+
baseline: baselineSchema,
|
|
374
|
+
capability: capabilitySchema,
|
|
375
|
+
dependencies: z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
|
|
376
|
+
evidence: z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
|
|
377
|
+
diagnostics: z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
|
|
378
|
+
completeness: completenessSchema
|
|
379
|
+
});
|
|
380
|
+
var runtimeDataFlowConfigSchema = z.strictObject({
|
|
381
|
+
enabled: z.boolean(),
|
|
382
|
+
runtime: z.literal("dispatch"),
|
|
383
|
+
limits: z.strictObject({
|
|
384
|
+
observationMaxEntries: z.number().int().positive(),
|
|
385
|
+
observationMaxBytes: z.number().int().positive(),
|
|
386
|
+
observationTtlMs: z.number().int().positive(),
|
|
387
|
+
reportMaxBytes: z.number().int().positive()
|
|
388
|
+
})
|
|
389
|
+
});
|
|
129
390
|
|
|
130
|
-
// src/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var SPOTPATCH_ENDPOINTS = Object.freeze({
|
|
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}`;
|
|
391
|
+
// src/model/data-flow-budget.ts
|
|
392
|
+
function prefix(values, maximum) {
|
|
393
|
+
return Object.freeze(values.slice(0, Math.max(0, maximum)));
|
|
143
394
|
}
|
|
395
|
+
function limitDependency(dependency) {
|
|
396
|
+
const queryKeys = dependency.url === void 0 ? void 0 : prefix(dependency.url.queryKeys, DEFAULT_DATA_FLOW_LIMITS.reportMaxFields);
|
|
397
|
+
const parameters = prefix(
|
|
398
|
+
dependency.parameters,
|
|
399
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxFields
|
|
400
|
+
).map(
|
|
401
|
+
(parameter) => Object.freeze({
|
|
402
|
+
...parameter,
|
|
403
|
+
evidenceIds: prefix(
|
|
404
|
+
parameter.evidenceIds,
|
|
405
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence
|
|
406
|
+
)
|
|
407
|
+
})
|
|
408
|
+
);
|
|
409
|
+
const consumedFields = prefix(
|
|
410
|
+
dependency.response.consumedFields,
|
|
411
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxFields
|
|
412
|
+
);
|
|
413
|
+
const suppliedBindings = prefix(
|
|
414
|
+
dependency.suppliedBindings,
|
|
415
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
416
|
+
);
|
|
417
|
+
const locationIds = prefix(
|
|
418
|
+
dependency.locationIds,
|
|
419
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
420
|
+
);
|
|
421
|
+
const evidenceIds = prefix(
|
|
422
|
+
dependency.evidenceIds,
|
|
423
|
+
DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence
|
|
424
|
+
);
|
|
425
|
+
const observationIds = prefix(
|
|
426
|
+
dependency.observationIds,
|
|
427
|
+
DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries
|
|
428
|
+
);
|
|
429
|
+
const trimmed = queryKeys?.length !== dependency.url?.queryKeys.length || parameters.length !== dependency.parameters.length || parameters.some(
|
|
430
|
+
(parameter, index) => parameter.evidenceIds.length !== dependency.parameters[index]?.evidenceIds.length
|
|
431
|
+
) || 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;
|
|
432
|
+
if (!trimmed) return Object.freeze({ dependency, trimmed: false });
|
|
433
|
+
return Object.freeze({
|
|
434
|
+
dependency: Object.freeze({
|
|
435
|
+
...dependency,
|
|
436
|
+
...dependency.url === void 0 ? {} : {
|
|
437
|
+
url: Object.freeze({
|
|
438
|
+
...dependency.url,
|
|
439
|
+
queryKeys: queryKeys ?? Object.freeze([])
|
|
440
|
+
})
|
|
441
|
+
},
|
|
442
|
+
parameters: Object.freeze(parameters),
|
|
443
|
+
response: Object.freeze({ consumedFields }),
|
|
444
|
+
suppliedBindings,
|
|
445
|
+
locationIds,
|
|
446
|
+
evidenceIds,
|
|
447
|
+
observationIds
|
|
448
|
+
}),
|
|
449
|
+
trimmed: true
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function referencedEvidenceIds(dependencies, diagnostics) {
|
|
453
|
+
return Object.freeze([
|
|
454
|
+
.../* @__PURE__ */ new Set([
|
|
455
|
+
...dependencies.flatMap((dependency) => [
|
|
456
|
+
...dependency.evidenceIds,
|
|
457
|
+
...dependency.parameters.flatMap((parameter) => parameter.evidenceIds)
|
|
458
|
+
]),
|
|
459
|
+
...diagnostics.flatMap((diagnostic) => diagnostic.evidenceIds)
|
|
460
|
+
])
|
|
461
|
+
]);
|
|
462
|
+
}
|
|
463
|
+
function prioritizeEvidence(evidence, referencedIds, retainUnreferenced) {
|
|
464
|
+
const byId = new Map(evidence.map((entry) => [entry.id, entry]));
|
|
465
|
+
const ordered = [];
|
|
466
|
+
const retained = /* @__PURE__ */ new Set();
|
|
467
|
+
for (const id of referencedIds) {
|
|
468
|
+
const entry = byId.get(id);
|
|
469
|
+
if (entry !== void 0 && !retained.has(id)) {
|
|
470
|
+
ordered.push(entry);
|
|
471
|
+
retained.add(id);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (retainUnreferenced) {
|
|
475
|
+
for (const entry of evidence) {
|
|
476
|
+
if (!retained.has(entry.id)) ordered.push(entry);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return prefix(ordered, DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence);
|
|
480
|
+
}
|
|
481
|
+
function pruneEvidenceReferences(dependency, retainedIds) {
|
|
482
|
+
return Object.freeze({
|
|
483
|
+
...dependency,
|
|
484
|
+
parameters: Object.freeze(
|
|
485
|
+
dependency.parameters.map(
|
|
486
|
+
(parameter) => Object.freeze({
|
|
487
|
+
...parameter,
|
|
488
|
+
evidenceIds: Object.freeze(
|
|
489
|
+
parameter.evidenceIds.filter((id) => retainedIds.has(id))
|
|
490
|
+
)
|
|
491
|
+
})
|
|
492
|
+
)
|
|
493
|
+
),
|
|
494
|
+
evidenceIds: Object.freeze(
|
|
495
|
+
dependency.evidenceIds.filter((id) => retainedIds.has(id))
|
|
496
|
+
)
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
function truncationCode(mode) {
|
|
500
|
+
return mode === "analysis" ? "DATA_FLOW_ANALYSIS_TRUNCATED" : "DATA_FLOW_OBSERVATION_DROPPED";
|
|
501
|
+
}
|
|
502
|
+
function limitDataFlowReportCollections(report, options = {}) {
|
|
503
|
+
const maximumDependencies = Math.min(
|
|
504
|
+
Math.max(
|
|
505
|
+
0,
|
|
506
|
+
options.maximumDependencies ?? DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
507
|
+
),
|
|
508
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
|
|
509
|
+
);
|
|
510
|
+
const dependencyResults = prefix(report.dependencies, maximumDependencies).map(
|
|
511
|
+
limitDependency
|
|
512
|
+
);
|
|
513
|
+
const dependencies = dependencyResults.map(({ dependency }) => dependency);
|
|
514
|
+
const analyzedSourceVersions = prefix(
|
|
515
|
+
report.baseline.analyzedSourceVersions,
|
|
516
|
+
DEFAULT_DATA_FLOW_LIMITS.graphMaxModules
|
|
517
|
+
);
|
|
518
|
+
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;
|
|
519
|
+
const truncated = options.forceTruncation === true || collectionTrimmed;
|
|
520
|
+
if (!truncated) return report;
|
|
521
|
+
const mode = options.mode ?? "analysis";
|
|
522
|
+
const code = truncationCode(mode);
|
|
523
|
+
const diagnosticId = `${report.reportId}_collection_${mode}`;
|
|
524
|
+
const reasons = Object.freeze([
|
|
525
|
+
...report.capability.reasons.filter((reason) => reason.code !== code).slice(0, DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons - 1),
|
|
526
|
+
Object.freeze({ code, retryable: false })
|
|
527
|
+
]);
|
|
528
|
+
const diagnostics = Object.freeze([
|
|
529
|
+
...report.diagnostics.filter((diagnostic) => diagnostic.id !== diagnosticId).slice(0, DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics - 1),
|
|
530
|
+
Object.freeze({
|
|
531
|
+
id: diagnosticId,
|
|
532
|
+
code,
|
|
533
|
+
severity: "warning",
|
|
534
|
+
retryable: false,
|
|
535
|
+
evidenceIds: Object.freeze([])
|
|
536
|
+
})
|
|
537
|
+
]);
|
|
538
|
+
const referencedIds = referencedEvidenceIds(dependencies, diagnostics);
|
|
539
|
+
const evidence = prioritizeEvidence(
|
|
540
|
+
report.evidence,
|
|
541
|
+
referencedIds,
|
|
542
|
+
report.dependencies.length === dependencies.length
|
|
543
|
+
);
|
|
544
|
+
const retainedEvidenceIds = new Set(evidence.map(({ id }) => id));
|
|
545
|
+
const prunedDependencies = Object.freeze(
|
|
546
|
+
dependencies.map(
|
|
547
|
+
(dependency) => pruneEvidenceReferences(dependency, retainedEvidenceIds)
|
|
548
|
+
)
|
|
549
|
+
);
|
|
550
|
+
const prunedDiagnostics = Object.freeze(
|
|
551
|
+
diagnostics.map(
|
|
552
|
+
(diagnostic) => Object.freeze({
|
|
553
|
+
...diagnostic,
|
|
554
|
+
evidenceIds: Object.freeze(
|
|
555
|
+
diagnostic.evidenceIds.filter((id) => retainedEvidenceIds.has(id))
|
|
556
|
+
)
|
|
557
|
+
})
|
|
558
|
+
)
|
|
559
|
+
);
|
|
560
|
+
const removedDependencies = report.dependencies.length - dependencies.length;
|
|
561
|
+
const removedModules = report.baseline.analyzedSourceVersions.length - analyzedSourceVersions.length;
|
|
562
|
+
const derivedTruncation = removedModules > 0 && removedDependencies === 0 ? "modules" : "callsites";
|
|
563
|
+
return Object.freeze({
|
|
564
|
+
...report,
|
|
565
|
+
baseline: Object.freeze({
|
|
566
|
+
...report.baseline,
|
|
567
|
+
analyzedSourceVersions
|
|
568
|
+
}),
|
|
569
|
+
capability: Object.freeze({
|
|
570
|
+
...report.capability,
|
|
571
|
+
...mode === "analysis" && report.capability.staticAnalysis === "available" ? { staticAnalysis: "partial" } : {},
|
|
572
|
+
reasons
|
|
573
|
+
}),
|
|
574
|
+
dependencies: prunedDependencies,
|
|
575
|
+
evidence,
|
|
576
|
+
diagnostics: prunedDiagnostics,
|
|
577
|
+
...mode === "analysis" ? {
|
|
578
|
+
completeness: Object.freeze({
|
|
579
|
+
...report.completeness,
|
|
580
|
+
complete: false,
|
|
581
|
+
frontierCount: report.completeness.frontierCount + removedDependencies + removedModules + (collectionTrimmed && removedDependencies === 0 && removedModules === 0 ? 1 : 0),
|
|
582
|
+
truncatedBy: options.truncatedBy ?? report.completeness.truncatedBy ?? derivedTruncation
|
|
583
|
+
})
|
|
584
|
+
} : {}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// src/model/runtime-config.ts
|
|
589
|
+
import { z as z2 } from "zod";
|
|
144
590
|
|
|
145
591
|
// src/model/editor.ts
|
|
146
592
|
var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
|
|
@@ -215,39 +661,39 @@ var SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([
|
|
|
215
661
|
"pages",
|
|
216
662
|
"hybrid"
|
|
217
663
|
]);
|
|
218
|
-
var
|
|
219
|
-
var profileIdSchema =
|
|
220
|
-
var runtimeAiModelSchema =
|
|
664
|
+
var boundedText2 = (maximum) => z2.string().trim().min(1).max(maximum);
|
|
665
|
+
var profileIdSchema = z2.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
|
|
666
|
+
var runtimeAiModelSchema = z2.strictObject({
|
|
221
667
|
id: profileIdSchema,
|
|
222
|
-
label:
|
|
668
|
+
label: boundedText2(100)
|
|
223
669
|
});
|
|
224
|
-
var runtimeAiProviderSchema =
|
|
670
|
+
var runtimeAiProviderSchema = z2.strictObject({
|
|
225
671
|
id: profileIdSchema,
|
|
226
|
-
label:
|
|
227
|
-
protocol:
|
|
228
|
-
models:
|
|
672
|
+
label: boundedText2(100),
|
|
673
|
+
protocol: z2.enum(["responses", "chat-completions"]),
|
|
674
|
+
models: z2.array(runtimeAiModelSchema).min(1).max(64),
|
|
229
675
|
defaultModel: profileIdSchema
|
|
230
676
|
}).refine(
|
|
231
677
|
({ defaultModel, models }) => models.some(({ id }) => id === defaultModel) && new Set(models.map(({ id }) => id)).size === models.length,
|
|
232
678
|
{ message: "Runtime AI model profiles are inconsistent." }
|
|
233
679
|
);
|
|
234
|
-
var runtimeAiConfigSchema =
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
enabled:
|
|
238
|
-
providers:
|
|
680
|
+
var runtimeAiConfigSchema = z2.discriminatedUnion("enabled", [
|
|
681
|
+
z2.strictObject({ enabled: z2.literal(false) }),
|
|
682
|
+
z2.strictObject({
|
|
683
|
+
enabled: z2.literal(true),
|
|
684
|
+
providers: z2.array(runtimeAiProviderSchema).min(1).max(32),
|
|
239
685
|
defaultProvider: profileIdSchema,
|
|
240
|
-
applyMode:
|
|
686
|
+
applyMode: z2.enum(AGENT_APPLY_MODES)
|
|
241
687
|
}).refine(
|
|
242
688
|
({ defaultProvider, providers }) => providers.some(({ id }) => id === defaultProvider) && new Set(providers.map(({ id }) => id)).size === providers.length,
|
|
243
689
|
{ message: "Runtime AI provider profiles are inconsistent." }
|
|
244
690
|
)
|
|
245
691
|
]);
|
|
246
|
-
var positiveInteger =
|
|
692
|
+
var positiveInteger = z2.number().int().positive();
|
|
247
693
|
var runtimeConfigBaseShape = {
|
|
248
|
-
apiBase:
|
|
694
|
+
apiBase: z2.literal(SPOTPATCH_API_BASE),
|
|
249
695
|
ai: runtimeAiConfigSchema,
|
|
250
|
-
budget:
|
|
696
|
+
budget: z2.strictObject({
|
|
251
697
|
totalCharacters: positiveInteger,
|
|
252
698
|
domCharacters: positiveInteger,
|
|
253
699
|
cssCharacters: positiveInteger,
|
|
@@ -255,27 +701,28 @@ var runtimeConfigBaseShape = {
|
|
|
255
701
|
maxCodeLines: positiveInteger,
|
|
256
702
|
maxComponentDepth: positiveInteger
|
|
257
703
|
}),
|
|
258
|
-
debug:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
704
|
+
debug: z2.boolean(),
|
|
705
|
+
dataFlow: runtimeDataFlowConfigSchema,
|
|
706
|
+
editor: z2.enum(SPOTPATCH_EDITOR_PREFERENCES),
|
|
707
|
+
frameworkVersion: boundedText2(64),
|
|
708
|
+
locale: z2.enum(SPOTPATCH_LOCALE_PREFERENCES),
|
|
709
|
+
maxTargets: z2.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
|
|
710
|
+
redact: z2.boolean(),
|
|
711
|
+
sessionId: z2.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
712
|
+
sessionToken: z2.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
713
|
+
shortcut: boundedText2(128),
|
|
714
|
+
spotPatchVersion: boundedText2(64)
|
|
268
715
|
};
|
|
269
|
-
var runtimeConfigSchema =
|
|
270
|
-
|
|
716
|
+
var runtimeConfigSchema = z2.discriminatedUnion("framework", [
|
|
717
|
+
z2.strictObject({
|
|
271
718
|
...runtimeConfigBaseShape,
|
|
272
|
-
framework:
|
|
719
|
+
framework: z2.literal("vite")
|
|
273
720
|
}),
|
|
274
|
-
|
|
721
|
+
z2.strictObject({
|
|
275
722
|
...runtimeConfigBaseShape,
|
|
276
|
-
bundler:
|
|
277
|
-
framework:
|
|
278
|
-
routerKind:
|
|
723
|
+
bundler: z2.enum(SPOTPATCH_NEXT_BUNDLERS),
|
|
724
|
+
framework: z2.literal("next"),
|
|
725
|
+
routerKind: z2.enum(SPOTPATCH_NEXT_ROUTER_KINDS)
|
|
279
726
|
})
|
|
280
727
|
]);
|
|
281
728
|
|
|
@@ -303,90 +750,109 @@ function parseSourceMarker(value) {
|
|
|
303
750
|
}
|
|
304
751
|
|
|
305
752
|
// src/protocol/requests.ts
|
|
306
|
-
import { z as
|
|
307
|
-
var runtimeBootstrapRequestSchema =
|
|
308
|
-
var sourceCoordinatesSchema =
|
|
309
|
-
fileId:
|
|
310
|
-
line:
|
|
311
|
-
column:
|
|
753
|
+
import { z as z3 } from "zod";
|
|
754
|
+
var runtimeBootstrapRequestSchema = z3.strictObject({});
|
|
755
|
+
var sourceCoordinatesSchema = z3.strictObject({
|
|
756
|
+
fileId: z3.string().min(1).max(128),
|
|
757
|
+
line: z3.number().int().positive(),
|
|
758
|
+
column: z3.number().int().positive()
|
|
312
759
|
});
|
|
313
760
|
var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
|
|
314
|
-
maxLines:
|
|
761
|
+
maxLines: z3.number().int().positive()
|
|
315
762
|
}).strict();
|
|
316
763
|
var openEditorRequestSchema = sourceCoordinatesSchema.strict();
|
|
317
|
-
var
|
|
318
|
-
|
|
319
|
-
|
|
764
|
+
var dataFlowSourceCoordinatesRequestSchema = sourceCoordinatesSchema.extend({
|
|
765
|
+
schemaVersion: z3.literal(1),
|
|
766
|
+
sourceVersion: z3.string().min(1).max(128).optional()
|
|
767
|
+
}).strict();
|
|
768
|
+
var dataFlowComponentIdentityRequestSchema = z3.strictObject({
|
|
769
|
+
schemaVersion: z3.literal(1),
|
|
770
|
+
componentSourceId: z3.string().min(1).max(128),
|
|
771
|
+
sourceVersion: z3.string().min(1).max(128)
|
|
772
|
+
});
|
|
773
|
+
var dataFlowComponentReportRequestSchema = z3.union([
|
|
774
|
+
dataFlowSourceCoordinatesRequestSchema,
|
|
775
|
+
dataFlowComponentIdentityRequestSchema
|
|
776
|
+
]);
|
|
777
|
+
var dataFlowPageReportRequestSchema = z3.strictObject({
|
|
778
|
+
schemaVersion: z3.literal(1),
|
|
779
|
+
targets: z3.array(dataFlowComponentReportRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS)
|
|
780
|
+
});
|
|
781
|
+
var profileIdSchema2 = z3.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
782
|
+
var boundedString = (maximum) => z3.string().max(maximum);
|
|
783
|
+
var sourceRefSchema = z3.strictObject({
|
|
320
784
|
fileId: boundedString(128).optional(),
|
|
321
785
|
relativePath: boundedString(1024).optional(),
|
|
322
|
-
line:
|
|
323
|
-
column:
|
|
324
|
-
origin:
|
|
325
|
-
confidence:
|
|
786
|
+
line: z3.number().int().positive().optional(),
|
|
787
|
+
column: z3.number().int().positive().optional(),
|
|
788
|
+
origin: z3.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
|
|
789
|
+
confidence: z3.enum(["exact", "probable", "approximate", "unknown"])
|
|
326
790
|
});
|
|
327
|
-
var matchedStyleRuleSchema =
|
|
791
|
+
var matchedStyleRuleSchema = z3.strictObject({
|
|
328
792
|
selector: boundedString(2048),
|
|
329
793
|
declarations: boundedString(8192),
|
|
330
794
|
source: boundedString(1024).optional(),
|
|
331
795
|
media: boundedString(1024).optional()
|
|
332
796
|
});
|
|
333
|
-
var codeContextSchema =
|
|
797
|
+
var codeContextSchema = z3.strictObject({
|
|
334
798
|
relativePath: boundedString(1024),
|
|
335
|
-
language:
|
|
336
|
-
startLine:
|
|
337
|
-
endLine:
|
|
799
|
+
language: z3.enum(["tsx", "jsx"]),
|
|
800
|
+
startLine: z3.number().int().positive(),
|
|
801
|
+
endLine: z3.number().int().positive(),
|
|
338
802
|
excerpt: boundedString(16e3),
|
|
339
|
-
boundary:
|
|
803
|
+
boundary: z3.enum(["component", "nearby-lines"])
|
|
340
804
|
});
|
|
341
|
-
var pageContextSchema =
|
|
805
|
+
var pageContextSchema = z3.strictObject({
|
|
342
806
|
url: boundedString(2048),
|
|
343
807
|
pathname: boundedString(2048),
|
|
344
808
|
title: boundedString(1024),
|
|
345
|
-
viewportWidth:
|
|
346
|
-
viewportHeight:
|
|
347
|
-
devicePixelRatio:
|
|
809
|
+
viewportWidth: z3.number().nonnegative(),
|
|
810
|
+
viewportHeight: z3.number().nonnegative(),
|
|
811
|
+
devicePixelRatio: z3.number().positive()
|
|
348
812
|
});
|
|
349
|
-
var spotTargetContextRequestSchema =
|
|
350
|
-
instruction:
|
|
813
|
+
var spotTargetContextRequestSchema = z3.strictObject({
|
|
814
|
+
instruction: z3.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
351
815
|
page: pageContextSchema.optional(),
|
|
352
816
|
source: sourceRefSchema,
|
|
353
|
-
react:
|
|
354
|
-
supported:
|
|
817
|
+
react: z3.strictObject({
|
|
818
|
+
supported: z3.boolean(),
|
|
355
819
|
version: boundedString(64).optional(),
|
|
356
820
|
componentName: boundedString(256).optional(),
|
|
357
|
-
|
|
821
|
+
componentSourceId: boundedString(128).optional(),
|
|
822
|
+
sourceVersion: boundedString(128).optional(),
|
|
823
|
+
componentStack: z3.array(boundedString(256)).max(64),
|
|
358
824
|
source: sourceRefSchema.optional()
|
|
359
825
|
}),
|
|
360
|
-
element:
|
|
826
|
+
element: z3.strictObject({
|
|
361
827
|
tagName: boundedString(128),
|
|
362
828
|
selector: boundedString(2048),
|
|
363
829
|
sanitizedHtml: boundedString(8192),
|
|
364
830
|
textPreview: boundedString(2048).optional(),
|
|
365
831
|
role: boundedString(256).optional(),
|
|
366
|
-
rect:
|
|
367
|
-
x:
|
|
368
|
-
y:
|
|
369
|
-
width:
|
|
370
|
-
height:
|
|
832
|
+
rect: z3.strictObject({
|
|
833
|
+
x: z3.number(),
|
|
834
|
+
y: z3.number(),
|
|
835
|
+
width: z3.number().nonnegative(),
|
|
836
|
+
height: z3.number().nonnegative()
|
|
371
837
|
})
|
|
372
838
|
}),
|
|
373
|
-
styles:
|
|
374
|
-
classNames:
|
|
839
|
+
styles: z3.strictObject({
|
|
840
|
+
classNames: z3.array(boundedString(512)).max(256),
|
|
375
841
|
inlineStyle: boundedString(8192).optional(),
|
|
376
|
-
matchedRules:
|
|
377
|
-
computed:
|
|
378
|
-
warnings:
|
|
842
|
+
matchedRules: z3.array(matchedStyleRuleSchema).max(256),
|
|
843
|
+
computed: z3.record(boundedString(256), boundedString(2048)),
|
|
844
|
+
warnings: z3.array(boundedString(1024)).max(64)
|
|
379
845
|
}),
|
|
380
846
|
code: codeContextSchema.optional(),
|
|
381
|
-
warnings:
|
|
847
|
+
warnings: z3.array(boundedString(1024)).max(64)
|
|
382
848
|
});
|
|
383
|
-
var spotAnnotationRequestSchema =
|
|
384
|
-
schemaVersion:
|
|
849
|
+
var spotAnnotationRequestSchema = z3.strictObject({
|
|
850
|
+
schemaVersion: z3.literal(3),
|
|
385
851
|
id: boundedString(128),
|
|
386
|
-
locale:
|
|
852
|
+
locale: z3.enum(SPOTPATCH_LOCALES),
|
|
387
853
|
page: pageContextSchema,
|
|
388
|
-
targets:
|
|
389
|
-
createdAt:
|
|
854
|
+
targets: z3.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
855
|
+
createdAt: z3.iso.datetime()
|
|
390
856
|
}).superRefine((annotation, context) => {
|
|
391
857
|
const total = annotation.targets.reduce(
|
|
392
858
|
(characters, target) => characters + target.instruction.length,
|
|
@@ -400,52 +866,53 @@ var spotAnnotationRequestSchema = z2.strictObject({
|
|
|
400
866
|
});
|
|
401
867
|
}
|
|
402
868
|
});
|
|
403
|
-
var agentCapabilityRequestSchema =
|
|
869
|
+
var agentCapabilityRequestSchema = z3.strictObject({
|
|
404
870
|
providerProfileId: profileIdSchema2,
|
|
405
871
|
modelProfileId: profileIdSchema2
|
|
406
872
|
});
|
|
407
|
-
var agentWorkspaceHealthRequestSchema =
|
|
408
|
-
var agentJobCreateRequestSchema =
|
|
873
|
+
var agentWorkspaceHealthRequestSchema = z3.strictObject({});
|
|
874
|
+
var agentJobCreateRequestSchema = z3.strictObject({
|
|
409
875
|
annotation: spotAnnotationRequestSchema,
|
|
876
|
+
applyMode: z3.enum(AGENT_APPLY_MODES).optional(),
|
|
410
877
|
providerProfileId: profileIdSchema2,
|
|
411
878
|
modelProfileId: profileIdSchema2,
|
|
412
|
-
providerDataConsent:
|
|
413
|
-
trustedFastModeConsent:
|
|
414
|
-
workingTreeMode:
|
|
879
|
+
providerDataConsent: z3.literal(true),
|
|
880
|
+
trustedFastModeConsent: z3.literal(true).optional(),
|
|
881
|
+
workingTreeMode: z3.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
415
882
|
});
|
|
416
|
-
var agentJobActionRequestSchema =
|
|
883
|
+
var agentJobActionRequestSchema = z3.strictObject({});
|
|
417
884
|
|
|
418
885
|
// src/protocol/agent-schemas.ts
|
|
419
|
-
import { z as
|
|
420
|
-
var profileIdSchema3 =
|
|
421
|
-
var boundedString2 = (maximum) =>
|
|
422
|
-
var errorCodeSchema =
|
|
423
|
-
var agentCapabilitySnapshotSchema =
|
|
886
|
+
import { z as z4 } from "zod";
|
|
887
|
+
var profileIdSchema3 = z4.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
888
|
+
var boundedString2 = (maximum) => z4.string().max(maximum);
|
|
889
|
+
var errorCodeSchema = z4.enum(ERROR_CODES);
|
|
890
|
+
var agentCapabilitySnapshotSchema = z4.strictObject({
|
|
424
891
|
providerProfileId: profileIdSchema3,
|
|
425
892
|
providerLabel: boundedString2(100),
|
|
426
893
|
modelProfileId: profileIdSchema3,
|
|
427
894
|
modelLabel: boundedString2(100),
|
|
428
|
-
protocol:
|
|
429
|
-
state:
|
|
430
|
-
authenticated:
|
|
431
|
-
modelAvailable:
|
|
432
|
-
toolCalling:
|
|
433
|
-
toolResultContinuation:
|
|
434
|
-
streaming:
|
|
435
|
-
checkedAt:
|
|
895
|
+
protocol: z4.enum(["responses", "chat-completions"]),
|
|
896
|
+
state: z4.enum(AGENT_CAPABILITY_STATES),
|
|
897
|
+
authenticated: z4.boolean(),
|
|
898
|
+
modelAvailable: z4.boolean(),
|
|
899
|
+
toolCalling: z4.boolean(),
|
|
900
|
+
toolResultContinuation: z4.boolean(),
|
|
901
|
+
streaming: z4.boolean(),
|
|
902
|
+
checkedAt: z4.iso.datetime().optional(),
|
|
436
903
|
errorCode: errorCodeSchema.optional()
|
|
437
904
|
});
|
|
438
|
-
var agentWorkspaceHealthSnapshotSchema =
|
|
439
|
-
state:
|
|
440
|
-
checkedAt:
|
|
441
|
-
changes:
|
|
442
|
-
staged:
|
|
443
|
-
unstaged:
|
|
444
|
-
untracked:
|
|
445
|
-
conflicted:
|
|
446
|
-
total:
|
|
905
|
+
var agentWorkspaceHealthSnapshotSchema = z4.strictObject({
|
|
906
|
+
state: z4.enum(AGENT_WORKSPACE_STATES),
|
|
907
|
+
checkedAt: z4.iso.datetime(),
|
|
908
|
+
changes: z4.strictObject({
|
|
909
|
+
staged: z4.number().int().nonnegative(),
|
|
910
|
+
unstaged: z4.number().int().nonnegative(),
|
|
911
|
+
untracked: z4.number().int().nonnegative(),
|
|
912
|
+
conflicted: z4.number().int().nonnegative(),
|
|
913
|
+
total: z4.number().int().nonnegative()
|
|
447
914
|
}),
|
|
448
|
-
canIncludeLocalChanges:
|
|
915
|
+
canIncludeLocalChanges: z4.boolean(),
|
|
449
916
|
errorCode: errorCodeSchema.optional()
|
|
450
917
|
}).refine(
|
|
451
918
|
({ state, changes, canIncludeLocalChanges, errorCode }) => {
|
|
@@ -463,42 +930,42 @@ var agentWorkspaceHealthSnapshotSchema = z3.strictObject({
|
|
|
463
930
|
},
|
|
464
931
|
{ message: "Agent workspace health fields are inconsistent." }
|
|
465
932
|
);
|
|
466
|
-
var agentChangedFileSchema =
|
|
933
|
+
var agentChangedFileSchema = z4.strictObject({
|
|
467
934
|
relativePath: boundedString2(1024),
|
|
468
|
-
kind:
|
|
469
|
-
additions:
|
|
470
|
-
deletions:
|
|
935
|
+
kind: z4.enum(AGENT_FILE_CHANGE_KINDS),
|
|
936
|
+
additions: z4.number().int().nonnegative(),
|
|
937
|
+
deletions: z4.number().int().nonnegative()
|
|
471
938
|
});
|
|
472
|
-
var agentCheckResultSchema =
|
|
939
|
+
var agentCheckResultSchema = z4.strictObject({
|
|
473
940
|
checkId: profileIdSchema3,
|
|
474
941
|
label: boundedString2(100),
|
|
475
|
-
status:
|
|
476
|
-
durationMs:
|
|
942
|
+
status: z4.enum(AGENT_CHECK_STATUSES),
|
|
943
|
+
durationMs: z4.number().int().nonnegative(),
|
|
477
944
|
output: boundedString2(8e4)
|
|
478
945
|
});
|
|
479
|
-
var agentJobSnapshotSchema =
|
|
480
|
-
jobId:
|
|
481
|
-
status:
|
|
946
|
+
var agentJobSnapshotSchema = z4.strictObject({
|
|
947
|
+
jobId: z4.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
948
|
+
status: z4.enum(AGENT_JOB_STATUSES),
|
|
482
949
|
providerProfileId: profileIdSchema3,
|
|
483
950
|
providerLabel: boundedString2(100),
|
|
484
951
|
modelProfileId: profileIdSchema3,
|
|
485
952
|
modelLabel: boundedString2(100),
|
|
486
953
|
phaseMessage: boundedString2(1024),
|
|
487
|
-
createdAt:
|
|
488
|
-
updatedAt:
|
|
489
|
-
canCancel:
|
|
490
|
-
canApply:
|
|
491
|
-
canRevert:
|
|
954
|
+
createdAt: z4.iso.datetime(),
|
|
955
|
+
updatedAt: z4.iso.datetime(),
|
|
956
|
+
canCancel: z4.boolean(),
|
|
957
|
+
canApply: z4.boolean(),
|
|
958
|
+
canRevert: z4.boolean(),
|
|
492
959
|
errorCode: errorCodeSchema.optional()
|
|
493
960
|
});
|
|
494
|
-
var agentJobResultSchema =
|
|
495
|
-
jobId:
|
|
961
|
+
var agentJobResultSchema = z4.strictObject({
|
|
962
|
+
jobId: z4.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
496
963
|
summary: boundedString2(8e4),
|
|
497
964
|
diff: boundedString2(1e6),
|
|
498
|
-
files:
|
|
499
|
-
checks:
|
|
965
|
+
files: z4.array(agentChangedFileSchema).max(100),
|
|
966
|
+
checks: z4.array(agentCheckResultSchema).max(100)
|
|
500
967
|
});
|
|
501
|
-
var agentJobResultResponseSchema =
|
|
968
|
+
var agentJobResultResponseSchema = z4.strictObject({
|
|
502
969
|
snapshot: agentJobSnapshotSchema,
|
|
503
970
|
result: agentJobResultSchema.optional()
|
|
504
971
|
}).superRefine((value, context) => {
|
|
@@ -510,44 +977,44 @@ var agentJobResultResponseSchema = z3.strictObject({
|
|
|
510
977
|
});
|
|
511
978
|
}
|
|
512
979
|
});
|
|
513
|
-
var agentJobEventBaseSchema =
|
|
514
|
-
schemaVersion:
|
|
515
|
-
sequence:
|
|
516
|
-
jobId:
|
|
517
|
-
status:
|
|
518
|
-
timestamp:
|
|
980
|
+
var agentJobEventBaseSchema = z4.strictObject({
|
|
981
|
+
schemaVersion: z4.literal(2),
|
|
982
|
+
sequence: z4.number().int().positive(),
|
|
983
|
+
jobId: z4.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
984
|
+
status: z4.enum(AGENT_JOB_STATUSES),
|
|
985
|
+
timestamp: z4.iso.datetime()
|
|
519
986
|
});
|
|
520
|
-
var agentJobEventSchema =
|
|
987
|
+
var agentJobEventSchema = z4.discriminatedUnion("type", [
|
|
521
988
|
agentJobEventBaseSchema.extend({
|
|
522
|
-
type:
|
|
523
|
-
data:
|
|
989
|
+
type: z4.literal("snapshot"),
|
|
990
|
+
data: z4.strictObject({ snapshot: agentJobSnapshotSchema })
|
|
524
991
|
}),
|
|
525
992
|
agentJobEventBaseSchema.extend({
|
|
526
|
-
type:
|
|
527
|
-
data:
|
|
993
|
+
type: z4.literal("phase"),
|
|
994
|
+
data: z4.strictObject({ message: boundedString2(1024) })
|
|
528
995
|
}),
|
|
529
996
|
agentJobEventBaseSchema.extend({
|
|
530
|
-
type:
|
|
531
|
-
data:
|
|
532
|
-
turn:
|
|
997
|
+
type: z4.literal("tool"),
|
|
998
|
+
data: z4.strictObject({
|
|
999
|
+
turn: z4.number().int().positive(),
|
|
533
1000
|
toolCallId: boundedString2(256),
|
|
534
1001
|
toolName: boundedString2(100),
|
|
535
|
-
state:
|
|
1002
|
+
state: z4.enum(["started", "succeeded", "failed"]),
|
|
536
1003
|
relativePath: boundedString2(1024).optional(),
|
|
537
1004
|
checkLabel: boundedString2(100).optional()
|
|
538
1005
|
})
|
|
539
1006
|
}),
|
|
540
1007
|
agentJobEventBaseSchema.extend({
|
|
541
|
-
type:
|
|
542
|
-
data:
|
|
1008
|
+
type: z4.literal("check"),
|
|
1009
|
+
data: z4.strictObject({ result: agentCheckResultSchema })
|
|
543
1010
|
}),
|
|
544
1011
|
agentJobEventBaseSchema.extend({
|
|
545
|
-
type:
|
|
546
|
-
data:
|
|
1012
|
+
type: z4.literal("result-ready"),
|
|
1013
|
+
data: z4.strictObject({ hasResult: z4.literal(true) })
|
|
547
1014
|
}),
|
|
548
1015
|
agentJobEventBaseSchema.extend({
|
|
549
|
-
type:
|
|
550
|
-
data:
|
|
1016
|
+
type: z4.literal("error"),
|
|
1017
|
+
data: z4.strictObject({
|
|
551
1018
|
code: errorCodeSchema,
|
|
552
1019
|
message: boundedString2(1024)
|
|
553
1020
|
})
|
|
@@ -582,7 +1049,22 @@ export {
|
|
|
582
1049
|
AGENT_JOB_STATUSES,
|
|
583
1050
|
AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
584
1051
|
AGENT_WORKSPACE_STATES,
|
|
1052
|
+
DATA_FLOW_ASSOCIATION_KINDS,
|
|
1053
|
+
DATA_FLOW_DIAGNOSTIC_CODES,
|
|
1054
|
+
DATA_FLOW_EXECUTION_STATES,
|
|
1055
|
+
DATA_FLOW_FRESHNESS_STATES,
|
|
1056
|
+
DATA_FLOW_PROOF_STATES,
|
|
1057
|
+
DATA_FLOW_QUERY_ADAPTER_MODULES,
|
|
1058
|
+
DATA_FLOW_QUERY_HOOK_NAMES,
|
|
1059
|
+
DATA_FLOW_SCHEMA_VERSION,
|
|
1060
|
+
DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES,
|
|
1061
|
+
DATA_FLOW_TRPC_PROXY_FACTORY_NAMES,
|
|
1062
|
+
DATA_FLOW_TRPC_REQUEST_METHODS,
|
|
1063
|
+
DATA_FLOW_TRPC_ROOT_FACTORY_NAMES,
|
|
1064
|
+
DATA_FLOW_URL_QUERY_KEY_LIMIT,
|
|
585
1065
|
DEFAULT_AGENT_LIMITS,
|
|
1066
|
+
DEFAULT_DATA_FLOW_LIMITS,
|
|
1067
|
+
DEFAULT_RUNTIME_DATA_FLOW_LIMITS,
|
|
586
1068
|
ERROR_CODES,
|
|
587
1069
|
MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
|
|
588
1070
|
MAX_ANNOTATION_TARGETS,
|
|
@@ -610,14 +1092,22 @@ export {
|
|
|
610
1092
|
agentJobSnapshotSchema,
|
|
611
1093
|
agentWorkspaceHealthRequestSchema,
|
|
612
1094
|
agentWorkspaceHealthSnapshotSchema,
|
|
1095
|
+
componentDataFlowReportSchema,
|
|
1096
|
+
dataDependencySchema,
|
|
1097
|
+
dataFlowComponentReportRequestSchema,
|
|
1098
|
+
dataFlowPageReportRequestSchema,
|
|
613
1099
|
formatSourceMarker,
|
|
614
1100
|
getAgentJobEndpoint,
|
|
615
1101
|
isSensitiveName,
|
|
1102
|
+
limitDataFlowReportCollections,
|
|
1103
|
+
networkObservationSchema,
|
|
616
1104
|
openEditorRequestSchema,
|
|
1105
|
+
pageDataFlowReportSchema,
|
|
617
1106
|
parseSourceMarker,
|
|
618
1107
|
redactSensitiveText,
|
|
619
1108
|
runtimeBootstrapRequestSchema,
|
|
620
1109
|
runtimeConfigSchema,
|
|
1110
|
+
runtimeDataFlowConfigSchema,
|
|
621
1111
|
sanitizeUrl,
|
|
622
1112
|
sourceContextRequestSchema,
|
|
623
1113
|
spotAnnotationRequestSchema,
|