@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/index.cjs CHANGED
@@ -27,7 +27,22 @@ __export(index_exports, {
27
27
  AGENT_JOB_STATUSES: () => AGENT_JOB_STATUSES,
28
28
  AGENT_WORKSPACE_SNAPSHOT_LIMITS: () => AGENT_WORKSPACE_SNAPSHOT_LIMITS,
29
29
  AGENT_WORKSPACE_STATES: () => AGENT_WORKSPACE_STATES,
30
+ DATA_FLOW_ASSOCIATION_KINDS: () => DATA_FLOW_ASSOCIATION_KINDS,
31
+ DATA_FLOW_DIAGNOSTIC_CODES: () => DATA_FLOW_DIAGNOSTIC_CODES,
32
+ DATA_FLOW_EXECUTION_STATES: () => DATA_FLOW_EXECUTION_STATES,
33
+ DATA_FLOW_FRESHNESS_STATES: () => DATA_FLOW_FRESHNESS_STATES,
34
+ DATA_FLOW_PROOF_STATES: () => DATA_FLOW_PROOF_STATES,
35
+ DATA_FLOW_QUERY_ADAPTER_MODULES: () => DATA_FLOW_QUERY_ADAPTER_MODULES,
36
+ DATA_FLOW_QUERY_HOOK_NAMES: () => DATA_FLOW_QUERY_HOOK_NAMES,
37
+ DATA_FLOW_SCHEMA_VERSION: () => DATA_FLOW_SCHEMA_VERSION,
38
+ DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES: () => DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES,
39
+ DATA_FLOW_TRPC_PROXY_FACTORY_NAMES: () => DATA_FLOW_TRPC_PROXY_FACTORY_NAMES,
40
+ DATA_FLOW_TRPC_REQUEST_METHODS: () => DATA_FLOW_TRPC_REQUEST_METHODS,
41
+ DATA_FLOW_TRPC_ROOT_FACTORY_NAMES: () => DATA_FLOW_TRPC_ROOT_FACTORY_NAMES,
42
+ DATA_FLOW_URL_QUERY_KEY_LIMIT: () => DATA_FLOW_URL_QUERY_KEY_LIMIT,
30
43
  DEFAULT_AGENT_LIMITS: () => DEFAULT_AGENT_LIMITS,
44
+ DEFAULT_DATA_FLOW_LIMITS: () => DEFAULT_DATA_FLOW_LIMITS,
45
+ DEFAULT_RUNTIME_DATA_FLOW_LIMITS: () => DEFAULT_RUNTIME_DATA_FLOW_LIMITS,
31
46
  ERROR_CODES: () => ERROR_CODES,
32
47
  MAX_ANNOTATION_INSTRUCTION_CHARACTERS: () => MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
33
48
  MAX_ANNOTATION_TARGETS: () => MAX_ANNOTATION_TARGETS,
@@ -55,14 +70,22 @@ __export(index_exports, {
55
70
  agentJobSnapshotSchema: () => agentJobSnapshotSchema,
56
71
  agentWorkspaceHealthRequestSchema: () => agentWorkspaceHealthRequestSchema,
57
72
  agentWorkspaceHealthSnapshotSchema: () => agentWorkspaceHealthSnapshotSchema,
73
+ componentDataFlowReportSchema: () => componentDataFlowReportSchema,
74
+ dataDependencySchema: () => dataDependencySchema,
75
+ dataFlowComponentReportRequestSchema: () => dataFlowComponentReportRequestSchema,
76
+ dataFlowPageReportRequestSchema: () => dataFlowPageReportRequestSchema,
58
77
  formatSourceMarker: () => formatSourceMarker,
59
78
  getAgentJobEndpoint: () => getAgentJobEndpoint,
60
79
  isSensitiveName: () => isSensitiveName,
80
+ limitDataFlowReportCollections: () => limitDataFlowReportCollections,
81
+ networkObservationSchema: () => networkObservationSchema,
61
82
  openEditorRequestSchema: () => openEditorRequestSchema,
83
+ pageDataFlowReportSchema: () => pageDataFlowReportSchema,
62
84
  parseSourceMarker: () => parseSourceMarker,
63
85
  redactSensitiveText: () => redactSensitiveText,
64
86
  runtimeBootstrapRequestSchema: () => runtimeBootstrapRequestSchema,
65
87
  runtimeConfigSchema: () => runtimeConfigSchema,
88
+ runtimeDataFlowConfigSchema: () => runtimeDataFlowConfigSchema,
66
89
  sanitizeUrl: () => sanitizeUrl,
67
90
  sourceContextRequestSchema: () => sourceContextRequestSchema,
68
91
  spotAnnotationRequestSchema: () => spotAnnotationRequestSchema,
@@ -89,6 +112,9 @@ var ERROR_CODES = {
89
112
  SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT",
90
113
  SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE",
91
114
  EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED",
115
+ DATA_FLOW_DISABLED: "DATA_FLOW_DISABLED",
116
+ DATA_FLOW_SOURCE_STALE: "DATA_FLOW_SOURCE_STALE",
117
+ DATA_FLOW_ANALYSIS_CANCELLED: "DATA_FLOW_ANALYSIS_CANCELLED",
92
118
  AI_DISABLED: "AI_DISABLED",
93
119
  PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED",
94
120
  PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
@@ -196,9 +222,485 @@ var SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([
196
222
  ...SPOTPATCH_LOCALES
197
223
  ]);
198
224
 
199
- // src/model/runtime-config.ts
225
+ // src/model/data-flow-adapters.ts
226
+ var DATA_FLOW_QUERY_ADAPTER_MODULES = Object.freeze([
227
+ "@tanstack/react-query",
228
+ "react-query"
229
+ ]);
230
+ var DATA_FLOW_QUERY_HOOK_NAMES = Object.freeze([
231
+ "useInfiniteQuery",
232
+ "useMutation",
233
+ "useQuery"
234
+ ]);
235
+ var DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES = Object.freeze([
236
+ "createTRPCClient",
237
+ "createTRPCProxyClient"
238
+ ]);
239
+ var DATA_FLOW_TRPC_PROXY_FACTORY_NAMES = Object.freeze([
240
+ "createTRPCNext",
241
+ "createTRPCReact"
242
+ ]);
243
+ var DATA_FLOW_TRPC_ROOT_FACTORY_NAMES = Object.freeze([
244
+ ...DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES,
245
+ ...DATA_FLOW_TRPC_PROXY_FACTORY_NAMES,
246
+ "createTRPCContext",
247
+ "createTRPCOptionsProxy"
248
+ ]);
249
+ var DATA_FLOW_TRPC_REQUEST_METHODS = Object.freeze([
250
+ "infiniteQueryOptions",
251
+ "mutate",
252
+ "mutateAsync",
253
+ "mutationOptions",
254
+ "query",
255
+ "queryOptions",
256
+ "refetch",
257
+ "subscribe",
258
+ "subscriptionOptions",
259
+ "useInfiniteQuery",
260
+ "useMutation",
261
+ "useQuery",
262
+ "useSubscription",
263
+ "useSuspenseInfiniteQuery",
264
+ "useSuspenseQuery"
265
+ ]);
266
+
267
+ // src/model/data-flow.ts
200
268
  var import_zod = require("zod");
201
269
 
270
+ // src/model/data-flow-limits.ts
271
+ var DEFAULT_DATA_FLOW_LIMITS = Object.freeze({
272
+ observationMaxEntries: 100,
273
+ observationMaxBytes: 256 * 1024,
274
+ observationTtlMs: 3e5,
275
+ protocolRequestMaxBytes: 32 * 1024,
276
+ reportMaxBytes: 128 * 1024,
277
+ reportMaxEvidence: 200,
278
+ reportMaxDiagnostics: 256,
279
+ capabilityMaxReasons: 64,
280
+ graphMaxDepth: 5,
281
+ graphMaxModules: 50,
282
+ graphMaxCallsites: 100,
283
+ analysisTimeoutMs: 2e3,
284
+ reportMaxFields: 100
285
+ });
286
+ var DATA_FLOW_URL_QUERY_KEY_LIMIT = DEFAULT_DATA_FLOW_LIMITS.reportMaxFields;
287
+ var DEFAULT_RUNTIME_DATA_FLOW_LIMITS = Object.freeze({
288
+ observationMaxEntries: DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries,
289
+ observationMaxBytes: DEFAULT_DATA_FLOW_LIMITS.observationMaxBytes,
290
+ observationTtlMs: DEFAULT_DATA_FLOW_LIMITS.observationTtlMs,
291
+ reportMaxBytes: DEFAULT_DATA_FLOW_LIMITS.reportMaxBytes
292
+ });
293
+
294
+ // src/model/data-flow-version.ts
295
+ var DATA_FLOW_SCHEMA_VERSION = 1;
296
+
297
+ // src/model/data-flow.ts
298
+ var DATA_FLOW_EXECUTION_STATES = Object.freeze([
299
+ "observed",
300
+ "declared-not-observed",
301
+ "not-applicable",
302
+ "unknown"
303
+ ]);
304
+ var DATA_FLOW_PROOF_STATES = Object.freeze([
305
+ "proven",
306
+ "candidate",
307
+ "unavailable",
308
+ "conflict"
309
+ ]);
310
+ var DATA_FLOW_ASSOCIATION_KINDS = Object.freeze([
311
+ "direct",
312
+ "transitive",
313
+ "upstream",
314
+ "possible",
315
+ "unassigned",
316
+ "unknown"
317
+ ]);
318
+ var DATA_FLOW_FRESHNESS_STATES = Object.freeze([
319
+ "current",
320
+ "stale-source",
321
+ "stale-route",
322
+ "expired"
323
+ ]);
324
+ var DATA_FLOW_DIAGNOSTIC_CODES = Object.freeze([
325
+ "DATA_FLOW_CAPABILITY_DISABLED",
326
+ "DATA_FLOW_CAPABILITY_PRELUDE_UNAVAILABLE",
327
+ "DATA_FLOW_CAPABILITY_UNSUPPORTED_FRAMEWORK",
328
+ "DATA_FLOW_SOURCE_UNAVAILABLE",
329
+ "DATA_FLOW_SOURCE_STALE",
330
+ "DATA_FLOW_ANALYSIS_TIMEOUT",
331
+ "DATA_FLOW_ANALYSIS_TRUNCATED",
332
+ "DATA_FLOW_ANALYSIS_UNRESOLVED_CALL",
333
+ "DATA_FLOW_OBSERVATION_UNASSIGNED",
334
+ "DATA_FLOW_OBSERVATION_DROPPED",
335
+ "DATA_FLOW_REDACTION_APPLIED",
336
+ "DATA_FLOW_AI_DISABLED"
337
+ ]);
338
+ var boundedText = (maximum) => import_zod.z.string().trim().min(1).max(maximum);
339
+ var opaqueIdSchema = boundedText(128).regex(/^[A-Za-z0-9_-]+$/u);
340
+ var diagnosticCodeSchema = import_zod.z.enum(DATA_FLOW_DIAGNOSTIC_CODES);
341
+ var evidenceSourceSchema = import_zod.z.strictObject({
342
+ fileId: opaqueIdSchema,
343
+ displayPath: boundedText(1024),
344
+ line: import_zod.z.number().int().positive(),
345
+ column: import_zod.z.number().int().positive(),
346
+ sourceVersion: opaqueIdSchema
347
+ });
348
+ var sanitizedObservedUrlSchema = import_zod.z.strictObject({
349
+ origin: boundedText(512).optional(),
350
+ pathname: boundedText(2048),
351
+ queryKeys: import_zod.z.array(boundedText(256)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
352
+ });
353
+ var dataParameterSchema = import_zod.z.strictObject({
354
+ path: boundedText(1024),
355
+ position: import_zod.z.enum([
356
+ "path",
357
+ "query",
358
+ "body",
359
+ "header",
360
+ "cookie",
361
+ "variable",
362
+ "form",
363
+ "unknown"
364
+ ]),
365
+ type: boundedText(512).optional(),
366
+ source: boundedText(1024).optional(),
367
+ condition: boundedText(1024).optional(),
368
+ sensitive: import_zod.z.boolean(),
369
+ valueState: import_zod.z.literal("not-collected"),
370
+ evidenceIds: import_zod.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
371
+ });
372
+ var dataResponseSchema = import_zod.z.strictObject({
373
+ consumedFields: import_zod.z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields)
374
+ });
375
+ var requestOriginSchema = import_zod.z.strictObject({
376
+ componentSourceId: opaqueIdSchema.optional(),
377
+ triggerCallsiteId: opaqueIdSchema.optional(),
378
+ requestCallsiteId: opaqueIdSchema,
379
+ sourceVersion: opaqueIdSchema
380
+ });
381
+ var capabilityReasonSchema = import_zod.z.strictObject({
382
+ code: diagnosticCodeSchema,
383
+ retryable: import_zod.z.boolean()
384
+ });
385
+ var capabilitySchema = import_zod.z.strictObject({
386
+ enabled: import_zod.z.boolean(),
387
+ staticAnalysis: import_zod.z.enum(["available", "partial", "unavailable"]),
388
+ runtimeObservation: import_zod.z.literal("dispatch-only"),
389
+ responseShape: import_zod.z.literal("consumed-fields-only"),
390
+ aiAssistance: import_zod.z.literal("disabled"),
391
+ reasons: import_zod.z.array(capabilityReasonSchema).max(DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons)
392
+ });
393
+ var evidenceSchema = import_zod.z.strictObject({
394
+ id: opaqueIdSchema,
395
+ kind: import_zod.z.enum([
396
+ "source-anchor",
397
+ "import-resolution",
398
+ "symbol-edge",
399
+ "trigger-edge",
400
+ "call-edge",
401
+ "data-binding",
402
+ "adapter-rule",
403
+ "runtime-observation",
404
+ "runtime-reference",
405
+ "diagnostic"
406
+ ]),
407
+ source: evidenceSourceSchema.optional(),
408
+ adapter: import_zod.z.strictObject({ id: boundedText(128), version: boundedText(64) }).optional(),
409
+ summaryKey: boundedText(256)
410
+ });
411
+ var diagnosticSchema = import_zod.z.strictObject({
412
+ id: opaqueIdSchema,
413
+ code: diagnosticCodeSchema,
414
+ severity: import_zod.z.enum(["info", "warning", "error"]),
415
+ retryable: import_zod.z.boolean(),
416
+ evidenceIds: import_zod.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
417
+ });
418
+ var baselineSchema = import_zod.z.strictObject({
419
+ registryEpoch: opaqueIdSchema,
420
+ analyzerVersion: boundedText(64),
421
+ adapterSetHash: boundedText(128),
422
+ analyzedSourceVersions: import_zod.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxModules)
423
+ });
424
+ var completenessSchema = import_zod.z.strictObject({
425
+ complete: import_zod.z.boolean(),
426
+ visitedModules: import_zod.z.number().int().nonnegative(),
427
+ visitedCallsites: import_zod.z.number().int().nonnegative(),
428
+ frontierCount: import_zod.z.number().int().nonnegative(),
429
+ truncatedBy: import_zod.z.enum(["depth", "modules", "callsites", "bytes", "timeout"]).optional()
430
+ });
431
+ var dataDependencySchema = import_zod.z.strictObject({
432
+ id: opaqueIdSchema,
433
+ kind: import_zod.z.enum(["http", "graphql", "rpc", "server-action", "unknown"]),
434
+ direction: import_zod.z.enum(["read", "write", "read-write", "unknown"]),
435
+ execution: import_zod.z.enum(DATA_FLOW_EXECUTION_STATES),
436
+ proof: import_zod.z.enum(DATA_FLOW_PROOF_STATES),
437
+ association: import_zod.z.enum(DATA_FLOW_ASSOCIATION_KINDS),
438
+ method: boundedText(32).optional(),
439
+ operation: boundedText(512).optional(),
440
+ url: sanitizedObservedUrlSchema.optional(),
441
+ parameters: import_zod.z.array(dataParameterSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxFields),
442
+ response: dataResponseSchema,
443
+ origin: requestOriginSchema.optional(),
444
+ suppliedBindings: import_zod.z.array(boundedText(1024)).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
445
+ locationIds: import_zod.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
446
+ evidenceIds: import_zod.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
447
+ observationIds: import_zod.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries)
448
+ });
449
+ var networkObservationSchema = import_zod.z.strictObject({
450
+ schemaVersion: import_zod.z.literal(DATA_FLOW_SCHEMA_VERSION),
451
+ id: opaqueIdSchema,
452
+ pageEpoch: opaqueIdSchema,
453
+ routeEpoch: opaqueIdSchema,
454
+ requestCallsiteId: opaqueIdSchema.optional(),
455
+ invocationId: opaqueIdSchema.optional(),
456
+ componentSourceId: opaqueIdSchema.optional(),
457
+ triggerCallsiteId: opaqueIdSchema.optional(),
458
+ sourceVersion: opaqueIdSchema.optional(),
459
+ transport: import_zod.z.enum(["fetch", "trpc", "xhr"]),
460
+ method: boundedText(32),
461
+ operation: boundedText(512).optional(),
462
+ url: sanitizedObservedUrlSchema,
463
+ outcome: import_zod.z.literal("dispatched"),
464
+ freshness: import_zod.z.enum(DATA_FLOW_FRESHNESS_STATES),
465
+ diagnosticIds: import_zod.z.array(opaqueIdSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence)
466
+ });
467
+ var componentIdentitySchema = import_zod.z.strictObject({
468
+ componentSourceId: opaqueIdSchema.optional(),
469
+ displayName: boundedText(256).optional(),
470
+ source: evidenceSourceSchema
471
+ });
472
+ var componentDataFlowReportSchema = import_zod.z.strictObject({
473
+ schemaVersion: import_zod.z.literal(DATA_FLOW_SCHEMA_VERSION),
474
+ reportId: opaqueIdSchema,
475
+ baseline: baselineSchema,
476
+ capability: capabilitySchema,
477
+ component: componentIdentitySchema,
478
+ dependencies: import_zod.z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
479
+ evidence: import_zod.z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
480
+ diagnostics: import_zod.z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
481
+ completeness: completenessSchema
482
+ });
483
+ var pageDataFlowReportSchema = import_zod.z.strictObject({
484
+ schemaVersion: import_zod.z.literal(DATA_FLOW_SCHEMA_VERSION),
485
+ reportId: opaqueIdSchema,
486
+ baseline: baselineSchema,
487
+ capability: capabilitySchema,
488
+ dependencies: import_zod.z.array(dataDependencySchema).max(DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites),
489
+ evidence: import_zod.z.array(evidenceSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence),
490
+ diagnostics: import_zod.z.array(diagnosticSchema).max(DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics),
491
+ completeness: completenessSchema
492
+ });
493
+ var runtimeDataFlowConfigSchema = import_zod.z.strictObject({
494
+ enabled: import_zod.z.boolean(),
495
+ runtime: import_zod.z.literal("dispatch"),
496
+ limits: import_zod.z.strictObject({
497
+ observationMaxEntries: import_zod.z.number().int().positive(),
498
+ observationMaxBytes: import_zod.z.number().int().positive(),
499
+ observationTtlMs: import_zod.z.number().int().positive(),
500
+ reportMaxBytes: import_zod.z.number().int().positive()
501
+ })
502
+ });
503
+
504
+ // src/model/data-flow-budget.ts
505
+ function prefix(values, maximum) {
506
+ return Object.freeze(values.slice(0, Math.max(0, maximum)));
507
+ }
508
+ function limitDependency(dependency) {
509
+ const queryKeys = dependency.url === void 0 ? void 0 : prefix(dependency.url.queryKeys, DEFAULT_DATA_FLOW_LIMITS.reportMaxFields);
510
+ const parameters = prefix(
511
+ dependency.parameters,
512
+ DEFAULT_DATA_FLOW_LIMITS.reportMaxFields
513
+ ).map(
514
+ (parameter) => Object.freeze({
515
+ ...parameter,
516
+ evidenceIds: prefix(
517
+ parameter.evidenceIds,
518
+ DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence
519
+ )
520
+ })
521
+ );
522
+ const consumedFields = prefix(
523
+ dependency.response.consumedFields,
524
+ DEFAULT_DATA_FLOW_LIMITS.reportMaxFields
525
+ );
526
+ const suppliedBindings = prefix(
527
+ dependency.suppliedBindings,
528
+ DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
529
+ );
530
+ const locationIds = prefix(
531
+ dependency.locationIds,
532
+ DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
533
+ );
534
+ const evidenceIds = prefix(
535
+ dependency.evidenceIds,
536
+ DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence
537
+ );
538
+ const observationIds = prefix(
539
+ dependency.observationIds,
540
+ DEFAULT_DATA_FLOW_LIMITS.observationMaxEntries
541
+ );
542
+ const trimmed = queryKeys?.length !== dependency.url?.queryKeys.length || parameters.length !== dependency.parameters.length || parameters.some(
543
+ (parameter, index) => parameter.evidenceIds.length !== dependency.parameters[index]?.evidenceIds.length
544
+ ) || 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;
545
+ if (!trimmed) return Object.freeze({ dependency, trimmed: false });
546
+ return Object.freeze({
547
+ dependency: Object.freeze({
548
+ ...dependency,
549
+ ...dependency.url === void 0 ? {} : {
550
+ url: Object.freeze({
551
+ ...dependency.url,
552
+ queryKeys: queryKeys ?? Object.freeze([])
553
+ })
554
+ },
555
+ parameters: Object.freeze(parameters),
556
+ response: Object.freeze({ consumedFields }),
557
+ suppliedBindings,
558
+ locationIds,
559
+ evidenceIds,
560
+ observationIds
561
+ }),
562
+ trimmed: true
563
+ });
564
+ }
565
+ function referencedEvidenceIds(dependencies, diagnostics) {
566
+ return Object.freeze([
567
+ .../* @__PURE__ */ new Set([
568
+ ...dependencies.flatMap((dependency) => [
569
+ ...dependency.evidenceIds,
570
+ ...dependency.parameters.flatMap((parameter) => parameter.evidenceIds)
571
+ ]),
572
+ ...diagnostics.flatMap((diagnostic) => diagnostic.evidenceIds)
573
+ ])
574
+ ]);
575
+ }
576
+ function prioritizeEvidence(evidence, referencedIds, retainUnreferenced) {
577
+ const byId = new Map(evidence.map((entry) => [entry.id, entry]));
578
+ const ordered = [];
579
+ const retained = /* @__PURE__ */ new Set();
580
+ for (const id of referencedIds) {
581
+ const entry = byId.get(id);
582
+ if (entry !== void 0 && !retained.has(id)) {
583
+ ordered.push(entry);
584
+ retained.add(id);
585
+ }
586
+ }
587
+ if (retainUnreferenced) {
588
+ for (const entry of evidence) {
589
+ if (!retained.has(entry.id)) ordered.push(entry);
590
+ }
591
+ }
592
+ return prefix(ordered, DEFAULT_DATA_FLOW_LIMITS.reportMaxEvidence);
593
+ }
594
+ function pruneEvidenceReferences(dependency, retainedIds) {
595
+ return Object.freeze({
596
+ ...dependency,
597
+ parameters: Object.freeze(
598
+ dependency.parameters.map(
599
+ (parameter) => Object.freeze({
600
+ ...parameter,
601
+ evidenceIds: Object.freeze(
602
+ parameter.evidenceIds.filter((id) => retainedIds.has(id))
603
+ )
604
+ })
605
+ )
606
+ ),
607
+ evidenceIds: Object.freeze(
608
+ dependency.evidenceIds.filter((id) => retainedIds.has(id))
609
+ )
610
+ });
611
+ }
612
+ function truncationCode(mode) {
613
+ return mode === "analysis" ? "DATA_FLOW_ANALYSIS_TRUNCATED" : "DATA_FLOW_OBSERVATION_DROPPED";
614
+ }
615
+ function limitDataFlowReportCollections(report, options = {}) {
616
+ const maximumDependencies = Math.min(
617
+ Math.max(
618
+ 0,
619
+ options.maximumDependencies ?? DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
620
+ ),
621
+ DEFAULT_DATA_FLOW_LIMITS.graphMaxCallsites
622
+ );
623
+ const dependencyResults = prefix(report.dependencies, maximumDependencies).map(
624
+ limitDependency
625
+ );
626
+ const dependencies = dependencyResults.map(({ dependency }) => dependency);
627
+ const analyzedSourceVersions = prefix(
628
+ report.baseline.analyzedSourceVersions,
629
+ DEFAULT_DATA_FLOW_LIMITS.graphMaxModules
630
+ );
631
+ 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;
632
+ const truncated = options.forceTruncation === true || collectionTrimmed;
633
+ if (!truncated) return report;
634
+ const mode = options.mode ?? "analysis";
635
+ const code = truncationCode(mode);
636
+ const diagnosticId = `${report.reportId}_collection_${mode}`;
637
+ const reasons = Object.freeze([
638
+ ...report.capability.reasons.filter((reason) => reason.code !== code).slice(0, DEFAULT_DATA_FLOW_LIMITS.capabilityMaxReasons - 1),
639
+ Object.freeze({ code, retryable: false })
640
+ ]);
641
+ const diagnostics = Object.freeze([
642
+ ...report.diagnostics.filter((diagnostic) => diagnostic.id !== diagnosticId).slice(0, DEFAULT_DATA_FLOW_LIMITS.reportMaxDiagnostics - 1),
643
+ Object.freeze({
644
+ id: diagnosticId,
645
+ code,
646
+ severity: "warning",
647
+ retryable: false,
648
+ evidenceIds: Object.freeze([])
649
+ })
650
+ ]);
651
+ const referencedIds = referencedEvidenceIds(dependencies, diagnostics);
652
+ const evidence = prioritizeEvidence(
653
+ report.evidence,
654
+ referencedIds,
655
+ report.dependencies.length === dependencies.length
656
+ );
657
+ const retainedEvidenceIds = new Set(evidence.map(({ id }) => id));
658
+ const prunedDependencies = Object.freeze(
659
+ dependencies.map(
660
+ (dependency) => pruneEvidenceReferences(dependency, retainedEvidenceIds)
661
+ )
662
+ );
663
+ const prunedDiagnostics = Object.freeze(
664
+ diagnostics.map(
665
+ (diagnostic) => Object.freeze({
666
+ ...diagnostic,
667
+ evidenceIds: Object.freeze(
668
+ diagnostic.evidenceIds.filter((id) => retainedEvidenceIds.has(id))
669
+ )
670
+ })
671
+ )
672
+ );
673
+ const removedDependencies = report.dependencies.length - dependencies.length;
674
+ const removedModules = report.baseline.analyzedSourceVersions.length - analyzedSourceVersions.length;
675
+ const derivedTruncation = removedModules > 0 && removedDependencies === 0 ? "modules" : "callsites";
676
+ return Object.freeze({
677
+ ...report,
678
+ baseline: Object.freeze({
679
+ ...report.baseline,
680
+ analyzedSourceVersions
681
+ }),
682
+ capability: Object.freeze({
683
+ ...report.capability,
684
+ ...mode === "analysis" && report.capability.staticAnalysis === "available" ? { staticAnalysis: "partial" } : {},
685
+ reasons
686
+ }),
687
+ dependencies: prunedDependencies,
688
+ evidence,
689
+ diagnostics: prunedDiagnostics,
690
+ ...mode === "analysis" ? {
691
+ completeness: Object.freeze({
692
+ ...report.completeness,
693
+ complete: false,
694
+ frontierCount: report.completeness.frontierCount + removedDependencies + removedModules + (collectionTrimmed && removedDependencies === 0 && removedModules === 0 ? 1 : 0),
695
+ truncatedBy: options.truncatedBy ?? report.completeness.truncatedBy ?? derivedTruncation
696
+ })
697
+ } : {}
698
+ });
699
+ }
700
+
701
+ // src/model/runtime-config.ts
702
+ var import_zod2 = require("zod");
703
+
202
704
  // src/protocol/endpoints.ts
203
705
  var SPOTPATCH_API_BASE = "/__spotpatch/v1";
204
706
  var SPOTPATCH_TOKEN_HEADER = "X-SpotPatch-Token";
@@ -206,6 +708,8 @@ var SPOTPATCH_ENDPOINTS = Object.freeze({
206
708
  bootstrap: `${SPOTPATCH_API_BASE}/bootstrap`,
207
709
  sourceContext: `${SPOTPATCH_API_BASE}/source-context`,
208
710
  openEditor: `${SPOTPATCH_API_BASE}/open-editor`,
711
+ dataFlowComponentReport: `${SPOTPATCH_API_BASE}/data-flow/component-report`,
712
+ dataFlowPageReport: `${SPOTPATCH_API_BASE}/data-flow/page-report`,
209
713
  agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
210
714
  agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
211
715
  agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`
@@ -287,39 +791,39 @@ var SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([
287
791
  "pages",
288
792
  "hybrid"
289
793
  ]);
290
- var boundedText = (maximum) => import_zod.z.string().trim().min(1).max(maximum);
291
- var profileIdSchema = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
292
- var runtimeAiModelSchema = import_zod.z.strictObject({
794
+ var boundedText2 = (maximum) => import_zod2.z.string().trim().min(1).max(maximum);
795
+ var profileIdSchema = import_zod2.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
796
+ var runtimeAiModelSchema = import_zod2.z.strictObject({
293
797
  id: profileIdSchema,
294
- label: boundedText(100)
798
+ label: boundedText2(100)
295
799
  });
296
- var runtimeAiProviderSchema = import_zod.z.strictObject({
800
+ var runtimeAiProviderSchema = import_zod2.z.strictObject({
297
801
  id: profileIdSchema,
298
- label: boundedText(100),
299
- protocol: import_zod.z.enum(["responses", "chat-completions"]),
300
- models: import_zod.z.array(runtimeAiModelSchema).min(1).max(64),
802
+ label: boundedText2(100),
803
+ protocol: import_zod2.z.enum(["responses", "chat-completions"]),
804
+ models: import_zod2.z.array(runtimeAiModelSchema).min(1).max(64),
301
805
  defaultModel: profileIdSchema
302
806
  }).refine(
303
807
  ({ defaultModel, models }) => models.some(({ id }) => id === defaultModel) && new Set(models.map(({ id }) => id)).size === models.length,
304
808
  { message: "Runtime AI model profiles are inconsistent." }
305
809
  );
306
- var runtimeAiConfigSchema = import_zod.z.discriminatedUnion("enabled", [
307
- import_zod.z.strictObject({ enabled: import_zod.z.literal(false) }),
308
- import_zod.z.strictObject({
309
- enabled: import_zod.z.literal(true),
310
- providers: import_zod.z.array(runtimeAiProviderSchema).min(1).max(32),
810
+ var runtimeAiConfigSchema = import_zod2.z.discriminatedUnion("enabled", [
811
+ import_zod2.z.strictObject({ enabled: import_zod2.z.literal(false) }),
812
+ import_zod2.z.strictObject({
813
+ enabled: import_zod2.z.literal(true),
814
+ providers: import_zod2.z.array(runtimeAiProviderSchema).min(1).max(32),
311
815
  defaultProvider: profileIdSchema,
312
- applyMode: import_zod.z.enum(AGENT_APPLY_MODES)
816
+ applyMode: import_zod2.z.enum(AGENT_APPLY_MODES)
313
817
  }).refine(
314
818
  ({ defaultProvider, providers }) => providers.some(({ id }) => id === defaultProvider) && new Set(providers.map(({ id }) => id)).size === providers.length,
315
819
  { message: "Runtime AI provider profiles are inconsistent." }
316
820
  )
317
821
  ]);
318
- var positiveInteger = import_zod.z.number().int().positive();
822
+ var positiveInteger = import_zod2.z.number().int().positive();
319
823
  var runtimeConfigBaseShape = {
320
- apiBase: import_zod.z.literal(SPOTPATCH_API_BASE),
824
+ apiBase: import_zod2.z.literal(SPOTPATCH_API_BASE),
321
825
  ai: runtimeAiConfigSchema,
322
- budget: import_zod.z.strictObject({
826
+ budget: import_zod2.z.strictObject({
323
827
  totalCharacters: positiveInteger,
324
828
  domCharacters: positiveInteger,
325
829
  cssCharacters: positiveInteger,
@@ -327,27 +831,28 @@ var runtimeConfigBaseShape = {
327
831
  maxCodeLines: positiveInteger,
328
832
  maxComponentDepth: positiveInteger
329
833
  }),
330
- debug: import_zod.z.boolean(),
331
- editor: import_zod.z.enum(SPOTPATCH_EDITOR_PREFERENCES),
332
- frameworkVersion: boundedText(64),
333
- locale: import_zod.z.enum(SPOTPATCH_LOCALE_PREFERENCES),
334
- maxTargets: import_zod.z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
335
- redact: import_zod.z.boolean(),
336
- sessionId: import_zod.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
337
- sessionToken: import_zod.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
338
- shortcut: boundedText(128),
339
- spotPatchVersion: boundedText(64)
834
+ debug: import_zod2.z.boolean(),
835
+ dataFlow: runtimeDataFlowConfigSchema,
836
+ editor: import_zod2.z.enum(SPOTPATCH_EDITOR_PREFERENCES),
837
+ frameworkVersion: boundedText2(64),
838
+ locale: import_zod2.z.enum(SPOTPATCH_LOCALE_PREFERENCES),
839
+ maxTargets: import_zod2.z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
840
+ redact: import_zod2.z.boolean(),
841
+ sessionId: import_zod2.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
842
+ sessionToken: import_zod2.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
843
+ shortcut: boundedText2(128),
844
+ spotPatchVersion: boundedText2(64)
340
845
  };
341
- var runtimeConfigSchema = import_zod.z.discriminatedUnion("framework", [
342
- import_zod.z.strictObject({
846
+ var runtimeConfigSchema = import_zod2.z.discriminatedUnion("framework", [
847
+ import_zod2.z.strictObject({
343
848
  ...runtimeConfigBaseShape,
344
- framework: import_zod.z.literal("vite")
849
+ framework: import_zod2.z.literal("vite")
345
850
  }),
346
- import_zod.z.strictObject({
851
+ import_zod2.z.strictObject({
347
852
  ...runtimeConfigBaseShape,
348
- bundler: import_zod.z.enum(SPOTPATCH_NEXT_BUNDLERS),
349
- framework: import_zod.z.literal("next"),
350
- routerKind: import_zod.z.enum(SPOTPATCH_NEXT_ROUTER_KINDS)
853
+ bundler: import_zod2.z.enum(SPOTPATCH_NEXT_BUNDLERS),
854
+ framework: import_zod2.z.literal("next"),
855
+ routerKind: import_zod2.z.enum(SPOTPATCH_NEXT_ROUTER_KINDS)
351
856
  })
352
857
  ]);
353
858
 
@@ -375,90 +880,109 @@ function parseSourceMarker(value) {
375
880
  }
376
881
 
377
882
  // src/protocol/requests.ts
378
- var import_zod2 = require("zod");
379
- var runtimeBootstrapRequestSchema = import_zod2.z.strictObject({});
380
- var sourceCoordinatesSchema = import_zod2.z.strictObject({
381
- fileId: import_zod2.z.string().min(1).max(128),
382
- line: import_zod2.z.number().int().positive(),
383
- column: import_zod2.z.number().int().positive()
883
+ var import_zod3 = require("zod");
884
+ var runtimeBootstrapRequestSchema = import_zod3.z.strictObject({});
885
+ var sourceCoordinatesSchema = import_zod3.z.strictObject({
886
+ fileId: import_zod3.z.string().min(1).max(128),
887
+ line: import_zod3.z.number().int().positive(),
888
+ column: import_zod3.z.number().int().positive()
384
889
  });
385
890
  var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
386
- maxLines: import_zod2.z.number().int().positive()
891
+ maxLines: import_zod3.z.number().int().positive()
387
892
  }).strict();
388
893
  var openEditorRequestSchema = sourceCoordinatesSchema.strict();
389
- var profileIdSchema2 = import_zod2.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
390
- var boundedString = (maximum) => import_zod2.z.string().max(maximum);
391
- var sourceRefSchema = import_zod2.z.strictObject({
894
+ var dataFlowSourceCoordinatesRequestSchema = sourceCoordinatesSchema.extend({
895
+ schemaVersion: import_zod3.z.literal(1),
896
+ sourceVersion: import_zod3.z.string().min(1).max(128).optional()
897
+ }).strict();
898
+ var dataFlowComponentIdentityRequestSchema = import_zod3.z.strictObject({
899
+ schemaVersion: import_zod3.z.literal(1),
900
+ componentSourceId: import_zod3.z.string().min(1).max(128),
901
+ sourceVersion: import_zod3.z.string().min(1).max(128)
902
+ });
903
+ var dataFlowComponentReportRequestSchema = import_zod3.z.union([
904
+ dataFlowSourceCoordinatesRequestSchema,
905
+ dataFlowComponentIdentityRequestSchema
906
+ ]);
907
+ var dataFlowPageReportRequestSchema = import_zod3.z.strictObject({
908
+ schemaVersion: import_zod3.z.literal(1),
909
+ targets: import_zod3.z.array(dataFlowComponentReportRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS)
910
+ });
911
+ var profileIdSchema2 = import_zod3.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
912
+ var boundedString = (maximum) => import_zod3.z.string().max(maximum);
913
+ var sourceRefSchema = import_zod3.z.strictObject({
392
914
  fileId: boundedString(128).optional(),
393
915
  relativePath: boundedString(1024).optional(),
394
- line: import_zod2.z.number().int().positive().optional(),
395
- column: import_zod2.z.number().int().positive().optional(),
396
- origin: import_zod2.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
397
- confidence: import_zod2.z.enum(["exact", "probable", "approximate", "unknown"])
916
+ line: import_zod3.z.number().int().positive().optional(),
917
+ column: import_zod3.z.number().int().positive().optional(),
918
+ origin: import_zod3.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
919
+ confidence: import_zod3.z.enum(["exact", "probable", "approximate", "unknown"])
398
920
  });
399
- var matchedStyleRuleSchema = import_zod2.z.strictObject({
921
+ var matchedStyleRuleSchema = import_zod3.z.strictObject({
400
922
  selector: boundedString(2048),
401
923
  declarations: boundedString(8192),
402
924
  source: boundedString(1024).optional(),
403
925
  media: boundedString(1024).optional()
404
926
  });
405
- var codeContextSchema = import_zod2.z.strictObject({
927
+ var codeContextSchema = import_zod3.z.strictObject({
406
928
  relativePath: boundedString(1024),
407
- language: import_zod2.z.enum(["tsx", "jsx"]),
408
- startLine: import_zod2.z.number().int().positive(),
409
- endLine: import_zod2.z.number().int().positive(),
929
+ language: import_zod3.z.enum(["tsx", "jsx"]),
930
+ startLine: import_zod3.z.number().int().positive(),
931
+ endLine: import_zod3.z.number().int().positive(),
410
932
  excerpt: boundedString(16e3),
411
- boundary: import_zod2.z.enum(["component", "nearby-lines"])
933
+ boundary: import_zod3.z.enum(["component", "nearby-lines"])
412
934
  });
413
- var pageContextSchema = import_zod2.z.strictObject({
935
+ var pageContextSchema = import_zod3.z.strictObject({
414
936
  url: boundedString(2048),
415
937
  pathname: boundedString(2048),
416
938
  title: boundedString(1024),
417
- viewportWidth: import_zod2.z.number().nonnegative(),
418
- viewportHeight: import_zod2.z.number().nonnegative(),
419
- devicePixelRatio: import_zod2.z.number().positive()
939
+ viewportWidth: import_zod3.z.number().nonnegative(),
940
+ viewportHeight: import_zod3.z.number().nonnegative(),
941
+ devicePixelRatio: import_zod3.z.number().positive()
420
942
  });
421
- var spotTargetContextRequestSchema = import_zod2.z.strictObject({
422
- instruction: import_zod2.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
943
+ var spotTargetContextRequestSchema = import_zod3.z.strictObject({
944
+ instruction: import_zod3.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
423
945
  page: pageContextSchema.optional(),
424
946
  source: sourceRefSchema,
425
- react: import_zod2.z.strictObject({
426
- supported: import_zod2.z.boolean(),
947
+ react: import_zod3.z.strictObject({
948
+ supported: import_zod3.z.boolean(),
427
949
  version: boundedString(64).optional(),
428
950
  componentName: boundedString(256).optional(),
429
- componentStack: import_zod2.z.array(boundedString(256)).max(64),
951
+ componentSourceId: boundedString(128).optional(),
952
+ sourceVersion: boundedString(128).optional(),
953
+ componentStack: import_zod3.z.array(boundedString(256)).max(64),
430
954
  source: sourceRefSchema.optional()
431
955
  }),
432
- element: import_zod2.z.strictObject({
956
+ element: import_zod3.z.strictObject({
433
957
  tagName: boundedString(128),
434
958
  selector: boundedString(2048),
435
959
  sanitizedHtml: boundedString(8192),
436
960
  textPreview: boundedString(2048).optional(),
437
961
  role: boundedString(256).optional(),
438
- rect: import_zod2.z.strictObject({
439
- x: import_zod2.z.number(),
440
- y: import_zod2.z.number(),
441
- width: import_zod2.z.number().nonnegative(),
442
- height: import_zod2.z.number().nonnegative()
962
+ rect: import_zod3.z.strictObject({
963
+ x: import_zod3.z.number(),
964
+ y: import_zod3.z.number(),
965
+ width: import_zod3.z.number().nonnegative(),
966
+ height: import_zod3.z.number().nonnegative()
443
967
  })
444
968
  }),
445
- styles: import_zod2.z.strictObject({
446
- classNames: import_zod2.z.array(boundedString(512)).max(256),
969
+ styles: import_zod3.z.strictObject({
970
+ classNames: import_zod3.z.array(boundedString(512)).max(256),
447
971
  inlineStyle: boundedString(8192).optional(),
448
- matchedRules: import_zod2.z.array(matchedStyleRuleSchema).max(256),
449
- computed: import_zod2.z.record(boundedString(256), boundedString(2048)),
450
- warnings: import_zod2.z.array(boundedString(1024)).max(64)
972
+ matchedRules: import_zod3.z.array(matchedStyleRuleSchema).max(256),
973
+ computed: import_zod3.z.record(boundedString(256), boundedString(2048)),
974
+ warnings: import_zod3.z.array(boundedString(1024)).max(64)
451
975
  }),
452
976
  code: codeContextSchema.optional(),
453
- warnings: import_zod2.z.array(boundedString(1024)).max(64)
977
+ warnings: import_zod3.z.array(boundedString(1024)).max(64)
454
978
  });
455
- var spotAnnotationRequestSchema = import_zod2.z.strictObject({
456
- schemaVersion: import_zod2.z.literal(3),
979
+ var spotAnnotationRequestSchema = import_zod3.z.strictObject({
980
+ schemaVersion: import_zod3.z.literal(3),
457
981
  id: boundedString(128),
458
- locale: import_zod2.z.enum(SPOTPATCH_LOCALES),
982
+ locale: import_zod3.z.enum(SPOTPATCH_LOCALES),
459
983
  page: pageContextSchema,
460
- targets: import_zod2.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
461
- createdAt: import_zod2.z.iso.datetime()
984
+ targets: import_zod3.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
985
+ createdAt: import_zod3.z.iso.datetime()
462
986
  }).superRefine((annotation, context) => {
463
987
  const total = annotation.targets.reduce(
464
988
  (characters, target) => characters + target.instruction.length,
@@ -472,52 +996,53 @@ var spotAnnotationRequestSchema = import_zod2.z.strictObject({
472
996
  });
473
997
  }
474
998
  });
475
- var agentCapabilityRequestSchema = import_zod2.z.strictObject({
999
+ var agentCapabilityRequestSchema = import_zod3.z.strictObject({
476
1000
  providerProfileId: profileIdSchema2,
477
1001
  modelProfileId: profileIdSchema2
478
1002
  });
479
- var agentWorkspaceHealthRequestSchema = import_zod2.z.strictObject({});
480
- var agentJobCreateRequestSchema = import_zod2.z.strictObject({
1003
+ var agentWorkspaceHealthRequestSchema = import_zod3.z.strictObject({});
1004
+ var agentJobCreateRequestSchema = import_zod3.z.strictObject({
481
1005
  annotation: spotAnnotationRequestSchema,
1006
+ applyMode: import_zod3.z.enum(AGENT_APPLY_MODES).optional(),
482
1007
  providerProfileId: profileIdSchema2,
483
1008
  modelProfileId: profileIdSchema2,
484
- providerDataConsent: import_zod2.z.literal(true),
485
- trustedFastModeConsent: import_zod2.z.literal(true).optional(),
486
- workingTreeMode: import_zod2.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
1009
+ providerDataConsent: import_zod3.z.literal(true),
1010
+ trustedFastModeConsent: import_zod3.z.literal(true).optional(),
1011
+ workingTreeMode: import_zod3.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
487
1012
  });
488
- var agentJobActionRequestSchema = import_zod2.z.strictObject({});
1013
+ var agentJobActionRequestSchema = import_zod3.z.strictObject({});
489
1014
 
490
1015
  // src/protocol/agent-schemas.ts
491
- var import_zod3 = require("zod");
492
- var profileIdSchema3 = import_zod3.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
493
- var boundedString2 = (maximum) => import_zod3.z.string().max(maximum);
494
- var errorCodeSchema = import_zod3.z.enum(ERROR_CODES);
495
- var agentCapabilitySnapshotSchema = import_zod3.z.strictObject({
1016
+ var import_zod4 = require("zod");
1017
+ var profileIdSchema3 = import_zod4.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
1018
+ var boundedString2 = (maximum) => import_zod4.z.string().max(maximum);
1019
+ var errorCodeSchema = import_zod4.z.enum(ERROR_CODES);
1020
+ var agentCapabilitySnapshotSchema = import_zod4.z.strictObject({
496
1021
  providerProfileId: profileIdSchema3,
497
1022
  providerLabel: boundedString2(100),
498
1023
  modelProfileId: profileIdSchema3,
499
1024
  modelLabel: boundedString2(100),
500
- protocol: import_zod3.z.enum(["responses", "chat-completions"]),
501
- state: import_zod3.z.enum(AGENT_CAPABILITY_STATES),
502
- authenticated: import_zod3.z.boolean(),
503
- modelAvailable: import_zod3.z.boolean(),
504
- toolCalling: import_zod3.z.boolean(),
505
- toolResultContinuation: import_zod3.z.boolean(),
506
- streaming: import_zod3.z.boolean(),
507
- checkedAt: import_zod3.z.iso.datetime().optional(),
1025
+ protocol: import_zod4.z.enum(["responses", "chat-completions"]),
1026
+ state: import_zod4.z.enum(AGENT_CAPABILITY_STATES),
1027
+ authenticated: import_zod4.z.boolean(),
1028
+ modelAvailable: import_zod4.z.boolean(),
1029
+ toolCalling: import_zod4.z.boolean(),
1030
+ toolResultContinuation: import_zod4.z.boolean(),
1031
+ streaming: import_zod4.z.boolean(),
1032
+ checkedAt: import_zod4.z.iso.datetime().optional(),
508
1033
  errorCode: errorCodeSchema.optional()
509
1034
  });
510
- var agentWorkspaceHealthSnapshotSchema = import_zod3.z.strictObject({
511
- state: import_zod3.z.enum(AGENT_WORKSPACE_STATES),
512
- checkedAt: import_zod3.z.iso.datetime(),
513
- changes: import_zod3.z.strictObject({
514
- staged: import_zod3.z.number().int().nonnegative(),
515
- unstaged: import_zod3.z.number().int().nonnegative(),
516
- untracked: import_zod3.z.number().int().nonnegative(),
517
- conflicted: import_zod3.z.number().int().nonnegative(),
518
- total: import_zod3.z.number().int().nonnegative()
1035
+ var agentWorkspaceHealthSnapshotSchema = import_zod4.z.strictObject({
1036
+ state: import_zod4.z.enum(AGENT_WORKSPACE_STATES),
1037
+ checkedAt: import_zod4.z.iso.datetime(),
1038
+ changes: import_zod4.z.strictObject({
1039
+ staged: import_zod4.z.number().int().nonnegative(),
1040
+ unstaged: import_zod4.z.number().int().nonnegative(),
1041
+ untracked: import_zod4.z.number().int().nonnegative(),
1042
+ conflicted: import_zod4.z.number().int().nonnegative(),
1043
+ total: import_zod4.z.number().int().nonnegative()
519
1044
  }),
520
- canIncludeLocalChanges: import_zod3.z.boolean(),
1045
+ canIncludeLocalChanges: import_zod4.z.boolean(),
521
1046
  errorCode: errorCodeSchema.optional()
522
1047
  }).refine(
523
1048
  ({ state, changes, canIncludeLocalChanges, errorCode }) => {
@@ -535,42 +1060,42 @@ var agentWorkspaceHealthSnapshotSchema = import_zod3.z.strictObject({
535
1060
  },
536
1061
  { message: "Agent workspace health fields are inconsistent." }
537
1062
  );
538
- var agentChangedFileSchema = import_zod3.z.strictObject({
1063
+ var agentChangedFileSchema = import_zod4.z.strictObject({
539
1064
  relativePath: boundedString2(1024),
540
- kind: import_zod3.z.enum(AGENT_FILE_CHANGE_KINDS),
541
- additions: import_zod3.z.number().int().nonnegative(),
542
- deletions: import_zod3.z.number().int().nonnegative()
1065
+ kind: import_zod4.z.enum(AGENT_FILE_CHANGE_KINDS),
1066
+ additions: import_zod4.z.number().int().nonnegative(),
1067
+ deletions: import_zod4.z.number().int().nonnegative()
543
1068
  });
544
- var agentCheckResultSchema = import_zod3.z.strictObject({
1069
+ var agentCheckResultSchema = import_zod4.z.strictObject({
545
1070
  checkId: profileIdSchema3,
546
1071
  label: boundedString2(100),
547
- status: import_zod3.z.enum(AGENT_CHECK_STATUSES),
548
- durationMs: import_zod3.z.number().int().nonnegative(),
1072
+ status: import_zod4.z.enum(AGENT_CHECK_STATUSES),
1073
+ durationMs: import_zod4.z.number().int().nonnegative(),
549
1074
  output: boundedString2(8e4)
550
1075
  });
551
- var agentJobSnapshotSchema = import_zod3.z.strictObject({
552
- jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
553
- status: import_zod3.z.enum(AGENT_JOB_STATUSES),
1076
+ var agentJobSnapshotSchema = import_zod4.z.strictObject({
1077
+ jobId: import_zod4.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
1078
+ status: import_zod4.z.enum(AGENT_JOB_STATUSES),
554
1079
  providerProfileId: profileIdSchema3,
555
1080
  providerLabel: boundedString2(100),
556
1081
  modelProfileId: profileIdSchema3,
557
1082
  modelLabel: boundedString2(100),
558
1083
  phaseMessage: boundedString2(1024),
559
- createdAt: import_zod3.z.iso.datetime(),
560
- updatedAt: import_zod3.z.iso.datetime(),
561
- canCancel: import_zod3.z.boolean(),
562
- canApply: import_zod3.z.boolean(),
563
- canRevert: import_zod3.z.boolean(),
1084
+ createdAt: import_zod4.z.iso.datetime(),
1085
+ updatedAt: import_zod4.z.iso.datetime(),
1086
+ canCancel: import_zod4.z.boolean(),
1087
+ canApply: import_zod4.z.boolean(),
1088
+ canRevert: import_zod4.z.boolean(),
564
1089
  errorCode: errorCodeSchema.optional()
565
1090
  });
566
- var agentJobResultSchema = import_zod3.z.strictObject({
567
- jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
1091
+ var agentJobResultSchema = import_zod4.z.strictObject({
1092
+ jobId: import_zod4.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
568
1093
  summary: boundedString2(8e4),
569
1094
  diff: boundedString2(1e6),
570
- files: import_zod3.z.array(agentChangedFileSchema).max(100),
571
- checks: import_zod3.z.array(agentCheckResultSchema).max(100)
1095
+ files: import_zod4.z.array(agentChangedFileSchema).max(100),
1096
+ checks: import_zod4.z.array(agentCheckResultSchema).max(100)
572
1097
  });
573
- var agentJobResultResponseSchema = import_zod3.z.strictObject({
1098
+ var agentJobResultResponseSchema = import_zod4.z.strictObject({
574
1099
  snapshot: agentJobSnapshotSchema,
575
1100
  result: agentJobResultSchema.optional()
576
1101
  }).superRefine((value, context) => {
@@ -582,44 +1107,44 @@ var agentJobResultResponseSchema = import_zod3.z.strictObject({
582
1107
  });
583
1108
  }
584
1109
  });
585
- var agentJobEventBaseSchema = import_zod3.z.strictObject({
586
- schemaVersion: import_zod3.z.literal(2),
587
- sequence: import_zod3.z.number().int().positive(),
588
- jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
589
- status: import_zod3.z.enum(AGENT_JOB_STATUSES),
590
- timestamp: import_zod3.z.iso.datetime()
1110
+ var agentJobEventBaseSchema = import_zod4.z.strictObject({
1111
+ schemaVersion: import_zod4.z.literal(2),
1112
+ sequence: import_zod4.z.number().int().positive(),
1113
+ jobId: import_zod4.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
1114
+ status: import_zod4.z.enum(AGENT_JOB_STATUSES),
1115
+ timestamp: import_zod4.z.iso.datetime()
591
1116
  });
592
- var agentJobEventSchema = import_zod3.z.discriminatedUnion("type", [
1117
+ var agentJobEventSchema = import_zod4.z.discriminatedUnion("type", [
593
1118
  agentJobEventBaseSchema.extend({
594
- type: import_zod3.z.literal("snapshot"),
595
- data: import_zod3.z.strictObject({ snapshot: agentJobSnapshotSchema })
1119
+ type: import_zod4.z.literal("snapshot"),
1120
+ data: import_zod4.z.strictObject({ snapshot: agentJobSnapshotSchema })
596
1121
  }),
597
1122
  agentJobEventBaseSchema.extend({
598
- type: import_zod3.z.literal("phase"),
599
- data: import_zod3.z.strictObject({ message: boundedString2(1024) })
1123
+ type: import_zod4.z.literal("phase"),
1124
+ data: import_zod4.z.strictObject({ message: boundedString2(1024) })
600
1125
  }),
601
1126
  agentJobEventBaseSchema.extend({
602
- type: import_zod3.z.literal("tool"),
603
- data: import_zod3.z.strictObject({
604
- turn: import_zod3.z.number().int().positive(),
1127
+ type: import_zod4.z.literal("tool"),
1128
+ data: import_zod4.z.strictObject({
1129
+ turn: import_zod4.z.number().int().positive(),
605
1130
  toolCallId: boundedString2(256),
606
1131
  toolName: boundedString2(100),
607
- state: import_zod3.z.enum(["started", "succeeded", "failed"]),
1132
+ state: import_zod4.z.enum(["started", "succeeded", "failed"]),
608
1133
  relativePath: boundedString2(1024).optional(),
609
1134
  checkLabel: boundedString2(100).optional()
610
1135
  })
611
1136
  }),
612
1137
  agentJobEventBaseSchema.extend({
613
- type: import_zod3.z.literal("check"),
614
- data: import_zod3.z.strictObject({ result: agentCheckResultSchema })
1138
+ type: import_zod4.z.literal("check"),
1139
+ data: import_zod4.z.strictObject({ result: agentCheckResultSchema })
615
1140
  }),
616
1141
  agentJobEventBaseSchema.extend({
617
- type: import_zod3.z.literal("result-ready"),
618
- data: import_zod3.z.strictObject({ hasResult: import_zod3.z.literal(true) })
1142
+ type: import_zod4.z.literal("result-ready"),
1143
+ data: import_zod4.z.strictObject({ hasResult: import_zod4.z.literal(true) })
619
1144
  }),
620
1145
  agentJobEventBaseSchema.extend({
621
- type: import_zod3.z.literal("error"),
622
- data: import_zod3.z.strictObject({
1146
+ type: import_zod4.z.literal("error"),
1147
+ data: import_zod4.z.strictObject({
623
1148
  code: errorCodeSchema,
624
1149
  message: boundedString2(1024)
625
1150
  })
@@ -655,7 +1180,22 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
655
1180
  AGENT_JOB_STATUSES,
656
1181
  AGENT_WORKSPACE_SNAPSHOT_LIMITS,
657
1182
  AGENT_WORKSPACE_STATES,
1183
+ DATA_FLOW_ASSOCIATION_KINDS,
1184
+ DATA_FLOW_DIAGNOSTIC_CODES,
1185
+ DATA_FLOW_EXECUTION_STATES,
1186
+ DATA_FLOW_FRESHNESS_STATES,
1187
+ DATA_FLOW_PROOF_STATES,
1188
+ DATA_FLOW_QUERY_ADAPTER_MODULES,
1189
+ DATA_FLOW_QUERY_HOOK_NAMES,
1190
+ DATA_FLOW_SCHEMA_VERSION,
1191
+ DATA_FLOW_TRPC_CLIENT_FACTORY_NAMES,
1192
+ DATA_FLOW_TRPC_PROXY_FACTORY_NAMES,
1193
+ DATA_FLOW_TRPC_REQUEST_METHODS,
1194
+ DATA_FLOW_TRPC_ROOT_FACTORY_NAMES,
1195
+ DATA_FLOW_URL_QUERY_KEY_LIMIT,
658
1196
  DEFAULT_AGENT_LIMITS,
1197
+ DEFAULT_DATA_FLOW_LIMITS,
1198
+ DEFAULT_RUNTIME_DATA_FLOW_LIMITS,
659
1199
  ERROR_CODES,
660
1200
  MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
661
1201
  MAX_ANNOTATION_TARGETS,
@@ -683,14 +1223,22 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
683
1223
  agentJobSnapshotSchema,
684
1224
  agentWorkspaceHealthRequestSchema,
685
1225
  agentWorkspaceHealthSnapshotSchema,
1226
+ componentDataFlowReportSchema,
1227
+ dataDependencySchema,
1228
+ dataFlowComponentReportRequestSchema,
1229
+ dataFlowPageReportRequestSchema,
686
1230
  formatSourceMarker,
687
1231
  getAgentJobEndpoint,
688
1232
  isSensitiveName,
1233
+ limitDataFlowReportCollections,
1234
+ networkObservationSchema,
689
1235
  openEditorRequestSchema,
1236
+ pageDataFlowReportSchema,
690
1237
  parseSourceMarker,
691
1238
  redactSensitiveText,
692
1239
  runtimeBootstrapRequestSchema,
693
1240
  runtimeConfigSchema,
1241
+ runtimeDataFlowConfigSchema,
694
1242
  sanitizeUrl,
695
1243
  sourceContextRequestSchema,
696
1244
  spotAnnotationRequestSchema,