@spotpatch/shared 1.0.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.
@@ -0,0 +1,1183 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const ERROR_CODES: {
4
+ readonly INVALID_REQUEST: "INVALID_REQUEST";
5
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
6
+ readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
7
+ readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
8
+ readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
9
+ readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
10
+ readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
11
+ readonly AI_DISABLED: "AI_DISABLED";
12
+ readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
13
+ readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
14
+ readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
15
+ readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
16
+ readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
17
+ readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
18
+ readonly AGENT_BUSY: "AGENT_BUSY";
19
+ readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
20
+ readonly AGENT_CANCELLED: "AGENT_CANCELLED";
21
+ readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
22
+ readonly TOOL_DENIED: "TOOL_DENIED";
23
+ readonly PATCH_REJECTED: "PATCH_REJECTED";
24
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
25
+ readonly APPLY_CONFLICT: "APPLY_CONFLICT";
26
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
27
+ };
28
+ type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
29
+
30
+ declare class SpotPatchError extends Error {
31
+ readonly code: ErrorCode;
32
+ constructor(code: ErrorCode, message?: ErrorCode, options?: ErrorOptions);
33
+ }
34
+
35
+ declare function isSensitiveName(name: string): boolean;
36
+ declare function redactSensitiveText(value: string): string;
37
+ declare function sanitizeUrl(value: string, baseUrl: string): string;
38
+
39
+ interface ContextBudget {
40
+ readonly totalCharacters: number;
41
+ readonly domCharacters: number;
42
+ readonly cssCharacters: number;
43
+ readonly codeCharacters: number;
44
+ readonly maxCodeLines: number;
45
+ readonly maxComponentDepth: number;
46
+ }
47
+ interface CodeContext {
48
+ readonly relativePath: string;
49
+ readonly language: "tsx" | "jsx";
50
+ readonly startLine: number;
51
+ readonly endLine: number;
52
+ readonly excerpt: string;
53
+ readonly boundary: "component" | "nearby-lines";
54
+ }
55
+
56
+ type SourceConfidence = "exact" | "probable" | "approximate" | "unknown";
57
+ type SourceOrigin = "jsx-host" | "react-fiber" | "dom-ancestor" | "none";
58
+ interface SourceRef {
59
+ readonly fileId?: string;
60
+ readonly relativePath?: string;
61
+ readonly line?: number;
62
+ readonly column?: number;
63
+ readonly origin: SourceOrigin;
64
+ readonly confidence: SourceConfidence;
65
+ }
66
+ interface ReactContext {
67
+ readonly supported: boolean;
68
+ readonly version?: string;
69
+ readonly componentName?: string;
70
+ readonly componentStack: readonly string[];
71
+ readonly source?: SourceRef;
72
+ }
73
+
74
+ interface MatchedStyleRule {
75
+ readonly selector: string;
76
+ readonly declarations: string;
77
+ readonly source?: string;
78
+ readonly media?: string;
79
+ }
80
+ interface StyleContext {
81
+ readonly classNames: readonly string[];
82
+ readonly inlineStyle?: string;
83
+ readonly matchedRules: readonly MatchedStyleRule[];
84
+ readonly computed: Readonly<Record<string, string>>;
85
+ readonly warnings: readonly string[];
86
+ }
87
+
88
+ interface PageContext {
89
+ readonly url: string;
90
+ readonly pathname: string;
91
+ readonly title: string;
92
+ readonly viewportWidth: number;
93
+ readonly viewportHeight: number;
94
+ readonly devicePixelRatio: number;
95
+ }
96
+ interface ElementContext {
97
+ readonly tagName: string;
98
+ readonly selector: string;
99
+ readonly sanitizedHtml: string;
100
+ readonly textPreview?: string;
101
+ readonly role?: string;
102
+ readonly rect: Readonly<{
103
+ x: number;
104
+ y: number;
105
+ width: number;
106
+ height: number;
107
+ }>;
108
+ }
109
+ /** Protocol hard limit. Runtime configuration may choose a smaller limit. */
110
+ declare const MAX_ANNOTATION_TARGETS = 20;
111
+ /** Each target owns its requested change; the UI enforces the same bound. */
112
+ declare const MAX_TARGET_INSTRUCTION_CHARACTERS = 2000;
113
+ /** Keeps the complete, atomic user intent within the prompt and request budgets. */
114
+ declare const MAX_ANNOTATION_INSTRUCTION_CHARACTERS = 4000;
115
+ declare const SPOTPATCH_LOCALES: readonly ["en-US", "zh-CN"];
116
+ type SpotPatchLocale = (typeof SPOTPATCH_LOCALES)[number];
117
+ declare const SPOTPATCH_LOCALE_PREFERENCES: readonly ["auto", "en-US", "zh-CN"];
118
+ type SpotPatchLocalePreference = (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];
119
+ interface SpotTargetContext {
120
+ readonly instruction: string;
121
+ readonly source: SourceRef;
122
+ readonly react: ReactContext;
123
+ readonly element: ElementContext;
124
+ readonly styles: StyleContext;
125
+ readonly code?: CodeContext;
126
+ readonly warnings: readonly string[];
127
+ }
128
+ interface SpotAnnotation {
129
+ readonly schemaVersion: 3;
130
+ readonly id: string;
131
+ readonly locale: SpotPatchLocale;
132
+ readonly page: Readonly<PageContext>;
133
+ readonly targets: readonly SpotTargetContext[];
134
+ readonly createdAt: string;
135
+ }
136
+
137
+ type AiProviderProtocol = "responses" | "chat-completions";
138
+ type AgentApplyMode = "review" | "auto";
139
+ interface AiModelProfile {
140
+ readonly label: string;
141
+ readonly model: string;
142
+ }
143
+ interface OpenAICompatibleProviderOptions {
144
+ readonly type: "openai-compatible";
145
+ readonly label: string;
146
+ readonly protocol: AiProviderProtocol;
147
+ readonly baseURL: string;
148
+ readonly apiKeyEnv: string;
149
+ readonly models: Readonly<Record<string, AiModelProfile>>;
150
+ readonly defaultModel: string;
151
+ }
152
+ interface AgentCheckDefinition {
153
+ readonly label: string;
154
+ readonly command: string;
155
+ readonly args?: readonly string[];
156
+ readonly required?: boolean;
157
+ readonly timeoutMs?: number;
158
+ }
159
+ interface AgentLimits {
160
+ readonly maxTurns: number;
161
+ readonly maxToolCalls: number;
162
+ readonly maxChangedFiles: number;
163
+ readonly maxDiffBytes: number;
164
+ readonly maxReadBytesPerFile: number;
165
+ readonly maxToolOutputCharacters: number;
166
+ readonly maxProviderResponseBytes: number;
167
+ readonly providerConnectTimeoutMs: number;
168
+ readonly providerFirstByteTimeoutMs: number;
169
+ readonly providerIdleTimeoutMs: number;
170
+ readonly checkTimeoutMs: number;
171
+ readonly jobTimeoutMs: number;
172
+ }
173
+ declare const DEFAULT_AGENT_LIMITS: Readonly<{
174
+ maxTurns: number;
175
+ maxToolCalls: number;
176
+ maxChangedFiles: number;
177
+ maxDiffBytes: number;
178
+ maxReadBytesPerFile: number;
179
+ maxToolOutputCharacters: number;
180
+ maxProviderResponseBytes: number;
181
+ providerConnectTimeoutMs: number;
182
+ providerFirstByteTimeoutMs: number;
183
+ providerIdleTimeoutMs: number;
184
+ checkTimeoutMs: number;
185
+ jobTimeoutMs: number;
186
+ }>;
187
+ interface AiExecutionOptions {
188
+ readonly isolation?: "git-worktree";
189
+ readonly applyMode?: AgentApplyMode;
190
+ readonly checks?: Readonly<Record<string, AgentCheckDefinition>>;
191
+ readonly limits?: Partial<AgentLimits>;
192
+ }
193
+ interface AiOptions {
194
+ readonly providers: Readonly<Record<string, OpenAICompatibleProviderOptions>>;
195
+ readonly defaultProvider: string;
196
+ readonly execution?: AiExecutionOptions;
197
+ }
198
+ interface ResolvedAiModelProfile extends AiModelProfile {
199
+ readonly id: string;
200
+ }
201
+ interface ResolvedOpenAICompatibleProviderOptions {
202
+ readonly id: string;
203
+ readonly type: "openai-compatible";
204
+ readonly label: string;
205
+ readonly protocol: AiProviderProtocol;
206
+ readonly baseURL: string;
207
+ readonly apiKeyEnv: string;
208
+ readonly models: Readonly<Record<string, ResolvedAiModelProfile>>;
209
+ readonly defaultModel: string;
210
+ }
211
+ interface ResolvedAgentCheckDefinition {
212
+ readonly id: string;
213
+ readonly label: string;
214
+ readonly command: string;
215
+ readonly args: readonly string[];
216
+ readonly required: boolean;
217
+ readonly timeoutMs: number;
218
+ }
219
+ interface ResolvedAiExecutionOptions {
220
+ readonly isolation: "git-worktree";
221
+ readonly applyMode: AgentApplyMode;
222
+ readonly checks: Readonly<Record<string, ResolvedAgentCheckDefinition>>;
223
+ readonly limits: Readonly<AgentLimits>;
224
+ }
225
+ interface ResolvedAiOptions {
226
+ readonly providers: Readonly<Record<string, ResolvedOpenAICompatibleProviderOptions>>;
227
+ readonly defaultProvider: string;
228
+ readonly execution: ResolvedAiExecutionOptions;
229
+ }
230
+ interface RuntimeAiModelProfile {
231
+ readonly id: string;
232
+ readonly label: string;
233
+ }
234
+ interface RuntimeAiProviderProfile {
235
+ readonly id: string;
236
+ readonly label: string;
237
+ readonly protocol: AiProviderProtocol;
238
+ readonly models: readonly RuntimeAiModelProfile[];
239
+ readonly defaultModel: string;
240
+ }
241
+ type RuntimeAiConfig = Readonly<{
242
+ enabled: false;
243
+ }> | Readonly<{
244
+ enabled: true;
245
+ providers: readonly RuntimeAiProviderProfile[];
246
+ defaultProvider: string;
247
+ applyMode: AgentApplyMode;
248
+ }>;
249
+ declare const AGENT_JOB_STATUSES: readonly ["queued", "preparing", "running", "validating", "awaiting-review", "applying", "applied", "completed", "cancelling", "cancelled", "reverting", "reverted", "failed"];
250
+ type AgentJobStatus = (typeof AGENT_JOB_STATUSES)[number];
251
+ declare const AGENT_CAPABILITY_STATES: readonly ["unknown", "probing", "agent-ready", "prompt-only", "unavailable"];
252
+ type AgentCapabilityState = (typeof AGENT_CAPABILITY_STATES)[number];
253
+ interface AgentCapabilitySnapshot {
254
+ readonly providerProfileId: string;
255
+ readonly providerLabel: string;
256
+ readonly modelProfileId: string;
257
+ readonly modelLabel: string;
258
+ readonly protocol: AiProviderProtocol;
259
+ readonly state: AgentCapabilityState;
260
+ readonly authenticated: boolean;
261
+ readonly modelAvailable: boolean;
262
+ readonly toolCalling: boolean;
263
+ readonly toolResultContinuation: boolean;
264
+ readonly streaming: boolean;
265
+ readonly checkedAt?: string;
266
+ readonly errorCode?: ErrorCode;
267
+ }
268
+ declare const AGENT_FILE_CHANGE_KINDS: readonly ["added", "modified", "deleted"];
269
+ type AgentFileChangeKind = (typeof AGENT_FILE_CHANGE_KINDS)[number];
270
+ declare const AGENT_CHECK_STATUSES: readonly ["passed", "failed", "cancelled", "timed-out"];
271
+ type AgentCheckStatus = (typeof AGENT_CHECK_STATUSES)[number];
272
+ interface AgentChangedFile {
273
+ readonly relativePath: string;
274
+ readonly kind: AgentFileChangeKind;
275
+ readonly additions: number;
276
+ readonly deletions: number;
277
+ }
278
+ interface AgentCheckResult {
279
+ readonly checkId: string;
280
+ readonly label: string;
281
+ readonly status: AgentCheckStatus;
282
+ readonly durationMs: number;
283
+ readonly output: string;
284
+ }
285
+ interface AgentJobSnapshot {
286
+ readonly jobId: string;
287
+ readonly status: AgentJobStatus;
288
+ readonly providerProfileId: string;
289
+ readonly providerLabel: string;
290
+ readonly modelProfileId: string;
291
+ readonly modelLabel: string;
292
+ readonly phaseMessage: string;
293
+ readonly createdAt: string;
294
+ readonly updatedAt: string;
295
+ readonly canCancel: boolean;
296
+ readonly canApply: boolean;
297
+ readonly canRevert: boolean;
298
+ readonly errorCode?: ErrorCode;
299
+ }
300
+ interface AgentJobResult {
301
+ readonly jobId: string;
302
+ readonly summary: string;
303
+ readonly diff: string;
304
+ readonly files: readonly AgentChangedFile[];
305
+ readonly checks: readonly AgentCheckResult[];
306
+ }
307
+ interface AgentJobResultResponse {
308
+ readonly snapshot: AgentJobSnapshot;
309
+ readonly result?: AgentJobResult;
310
+ }
311
+
312
+ declare const SOURCE_MARKER_ATTRIBUTE: "data-spotpatch-source";
313
+ interface SourceMarker {
314
+ readonly fileId: string;
315
+ readonly line: number;
316
+ readonly column: number;
317
+ }
318
+ declare function formatSourceMarker(marker: SourceMarker): string;
319
+ declare function parseSourceMarker(value: string | null): SourceMarker | undefined;
320
+
321
+ declare const SPOTPATCH_API_BASE: "/__spotpatch/v1";
322
+ declare const SPOTPATCH_TOKEN_HEADER: "X-SpotPatch-Token";
323
+ declare const SPOTPATCH_ENDPOINTS: Readonly<{
324
+ sourceContext: "/__spotpatch/v1/source-context";
325
+ openEditor: "/__spotpatch/v1/open-editor";
326
+ agentCapability: "/__spotpatch/v1/agent/capability";
327
+ agentJobs: "/__spotpatch/v1/agent/jobs";
328
+ }>;
329
+ type AgentJobAction = "events" | "result" | "cancel" | "apply" | "revert";
330
+ declare function getAgentJobEndpoint(jobId: string, action: AgentJobAction): string;
331
+
332
+ declare const sourceContextRequestSchema: z.ZodObject<{
333
+ fileId: z.ZodString;
334
+ line: z.ZodNumber;
335
+ column: z.ZodNumber;
336
+ maxLines: z.ZodNumber;
337
+ }, z.core.$strict>;
338
+ declare const openEditorRequestSchema: z.ZodObject<{
339
+ fileId: z.ZodString;
340
+ line: z.ZodNumber;
341
+ column: z.ZodNumber;
342
+ }, z.core.$strict>;
343
+ declare const spotTargetContextRequestSchema: z.ZodObject<{
344
+ instruction: z.ZodString;
345
+ source: z.ZodObject<{
346
+ fileId: z.ZodOptional<z.ZodString>;
347
+ relativePath: z.ZodOptional<z.ZodString>;
348
+ line: z.ZodOptional<z.ZodNumber>;
349
+ column: z.ZodOptional<z.ZodNumber>;
350
+ origin: z.ZodEnum<{
351
+ "jsx-host": "jsx-host";
352
+ "react-fiber": "react-fiber";
353
+ "dom-ancestor": "dom-ancestor";
354
+ none: "none";
355
+ }>;
356
+ confidence: z.ZodEnum<{
357
+ exact: "exact";
358
+ probable: "probable";
359
+ approximate: "approximate";
360
+ unknown: "unknown";
361
+ }>;
362
+ }, z.core.$strict>;
363
+ react: z.ZodObject<{
364
+ supported: z.ZodBoolean;
365
+ version: z.ZodOptional<z.ZodString>;
366
+ componentName: z.ZodOptional<z.ZodString>;
367
+ componentStack: z.ZodArray<z.ZodString>;
368
+ source: z.ZodOptional<z.ZodObject<{
369
+ fileId: z.ZodOptional<z.ZodString>;
370
+ relativePath: z.ZodOptional<z.ZodString>;
371
+ line: z.ZodOptional<z.ZodNumber>;
372
+ column: z.ZodOptional<z.ZodNumber>;
373
+ origin: z.ZodEnum<{
374
+ "jsx-host": "jsx-host";
375
+ "react-fiber": "react-fiber";
376
+ "dom-ancestor": "dom-ancestor";
377
+ none: "none";
378
+ }>;
379
+ confidence: z.ZodEnum<{
380
+ exact: "exact";
381
+ probable: "probable";
382
+ approximate: "approximate";
383
+ unknown: "unknown";
384
+ }>;
385
+ }, z.core.$strict>>;
386
+ }, z.core.$strict>;
387
+ element: z.ZodObject<{
388
+ tagName: z.ZodString;
389
+ selector: z.ZodString;
390
+ sanitizedHtml: z.ZodString;
391
+ textPreview: z.ZodOptional<z.ZodString>;
392
+ role: z.ZodOptional<z.ZodString>;
393
+ rect: z.ZodObject<{
394
+ x: z.ZodNumber;
395
+ y: z.ZodNumber;
396
+ width: z.ZodNumber;
397
+ height: z.ZodNumber;
398
+ }, z.core.$strict>;
399
+ }, z.core.$strict>;
400
+ styles: z.ZodObject<{
401
+ classNames: z.ZodArray<z.ZodString>;
402
+ inlineStyle: z.ZodOptional<z.ZodString>;
403
+ matchedRules: z.ZodArray<z.ZodObject<{
404
+ selector: z.ZodString;
405
+ declarations: z.ZodString;
406
+ source: z.ZodOptional<z.ZodString>;
407
+ media: z.ZodOptional<z.ZodString>;
408
+ }, z.core.$strict>>;
409
+ computed: z.ZodRecord<z.ZodString, z.ZodString>;
410
+ warnings: z.ZodArray<z.ZodString>;
411
+ }, z.core.$strict>;
412
+ code: z.ZodOptional<z.ZodObject<{
413
+ relativePath: z.ZodString;
414
+ language: z.ZodEnum<{
415
+ tsx: "tsx";
416
+ jsx: "jsx";
417
+ }>;
418
+ startLine: z.ZodNumber;
419
+ endLine: z.ZodNumber;
420
+ excerpt: z.ZodString;
421
+ boundary: z.ZodEnum<{
422
+ component: "component";
423
+ "nearby-lines": "nearby-lines";
424
+ }>;
425
+ }, z.core.$strict>>;
426
+ warnings: z.ZodArray<z.ZodString>;
427
+ }, z.core.$strict>;
428
+ declare const spotAnnotationRequestSchema: z.ZodObject<{
429
+ schemaVersion: z.ZodLiteral<3>;
430
+ id: z.ZodString;
431
+ locale: z.ZodEnum<{
432
+ "en-US": "en-US";
433
+ "zh-CN": "zh-CN";
434
+ }>;
435
+ page: z.ZodObject<{
436
+ url: z.ZodString;
437
+ pathname: z.ZodString;
438
+ title: z.ZodString;
439
+ viewportWidth: z.ZodNumber;
440
+ viewportHeight: z.ZodNumber;
441
+ devicePixelRatio: z.ZodNumber;
442
+ }, z.core.$strict>;
443
+ targets: z.ZodArray<z.ZodObject<{
444
+ instruction: z.ZodString;
445
+ source: z.ZodObject<{
446
+ fileId: z.ZodOptional<z.ZodString>;
447
+ relativePath: z.ZodOptional<z.ZodString>;
448
+ line: z.ZodOptional<z.ZodNumber>;
449
+ column: z.ZodOptional<z.ZodNumber>;
450
+ origin: z.ZodEnum<{
451
+ "jsx-host": "jsx-host";
452
+ "react-fiber": "react-fiber";
453
+ "dom-ancestor": "dom-ancestor";
454
+ none: "none";
455
+ }>;
456
+ confidence: z.ZodEnum<{
457
+ exact: "exact";
458
+ probable: "probable";
459
+ approximate: "approximate";
460
+ unknown: "unknown";
461
+ }>;
462
+ }, z.core.$strict>;
463
+ react: z.ZodObject<{
464
+ supported: z.ZodBoolean;
465
+ version: z.ZodOptional<z.ZodString>;
466
+ componentName: z.ZodOptional<z.ZodString>;
467
+ componentStack: z.ZodArray<z.ZodString>;
468
+ source: z.ZodOptional<z.ZodObject<{
469
+ fileId: z.ZodOptional<z.ZodString>;
470
+ relativePath: z.ZodOptional<z.ZodString>;
471
+ line: z.ZodOptional<z.ZodNumber>;
472
+ column: z.ZodOptional<z.ZodNumber>;
473
+ origin: z.ZodEnum<{
474
+ "jsx-host": "jsx-host";
475
+ "react-fiber": "react-fiber";
476
+ "dom-ancestor": "dom-ancestor";
477
+ none: "none";
478
+ }>;
479
+ confidence: z.ZodEnum<{
480
+ exact: "exact";
481
+ probable: "probable";
482
+ approximate: "approximate";
483
+ unknown: "unknown";
484
+ }>;
485
+ }, z.core.$strict>>;
486
+ }, z.core.$strict>;
487
+ element: z.ZodObject<{
488
+ tagName: z.ZodString;
489
+ selector: z.ZodString;
490
+ sanitizedHtml: z.ZodString;
491
+ textPreview: z.ZodOptional<z.ZodString>;
492
+ role: z.ZodOptional<z.ZodString>;
493
+ rect: z.ZodObject<{
494
+ x: z.ZodNumber;
495
+ y: z.ZodNumber;
496
+ width: z.ZodNumber;
497
+ height: z.ZodNumber;
498
+ }, z.core.$strict>;
499
+ }, z.core.$strict>;
500
+ styles: z.ZodObject<{
501
+ classNames: z.ZodArray<z.ZodString>;
502
+ inlineStyle: z.ZodOptional<z.ZodString>;
503
+ matchedRules: z.ZodArray<z.ZodObject<{
504
+ selector: z.ZodString;
505
+ declarations: z.ZodString;
506
+ source: z.ZodOptional<z.ZodString>;
507
+ media: z.ZodOptional<z.ZodString>;
508
+ }, z.core.$strict>>;
509
+ computed: z.ZodRecord<z.ZodString, z.ZodString>;
510
+ warnings: z.ZodArray<z.ZodString>;
511
+ }, z.core.$strict>;
512
+ code: z.ZodOptional<z.ZodObject<{
513
+ relativePath: z.ZodString;
514
+ language: z.ZodEnum<{
515
+ tsx: "tsx";
516
+ jsx: "jsx";
517
+ }>;
518
+ startLine: z.ZodNumber;
519
+ endLine: z.ZodNumber;
520
+ excerpt: z.ZodString;
521
+ boundary: z.ZodEnum<{
522
+ component: "component";
523
+ "nearby-lines": "nearby-lines";
524
+ }>;
525
+ }, z.core.$strict>>;
526
+ warnings: z.ZodArray<z.ZodString>;
527
+ }, z.core.$strict>>;
528
+ createdAt: z.ZodISODateTime;
529
+ }, z.core.$strict>;
530
+ declare const agentCapabilityRequestSchema: z.ZodObject<{
531
+ providerProfileId: z.ZodString;
532
+ modelProfileId: z.ZodString;
533
+ }, z.core.$strict>;
534
+ declare const agentJobCreateRequestSchema: z.ZodObject<{
535
+ annotation: z.ZodObject<{
536
+ schemaVersion: z.ZodLiteral<3>;
537
+ id: z.ZodString;
538
+ locale: z.ZodEnum<{
539
+ "en-US": "en-US";
540
+ "zh-CN": "zh-CN";
541
+ }>;
542
+ page: z.ZodObject<{
543
+ url: z.ZodString;
544
+ pathname: z.ZodString;
545
+ title: z.ZodString;
546
+ viewportWidth: z.ZodNumber;
547
+ viewportHeight: z.ZodNumber;
548
+ devicePixelRatio: z.ZodNumber;
549
+ }, z.core.$strict>;
550
+ targets: z.ZodArray<z.ZodObject<{
551
+ instruction: z.ZodString;
552
+ source: z.ZodObject<{
553
+ fileId: z.ZodOptional<z.ZodString>;
554
+ relativePath: z.ZodOptional<z.ZodString>;
555
+ line: z.ZodOptional<z.ZodNumber>;
556
+ column: z.ZodOptional<z.ZodNumber>;
557
+ origin: z.ZodEnum<{
558
+ "jsx-host": "jsx-host";
559
+ "react-fiber": "react-fiber";
560
+ "dom-ancestor": "dom-ancestor";
561
+ none: "none";
562
+ }>;
563
+ confidence: z.ZodEnum<{
564
+ exact: "exact";
565
+ probable: "probable";
566
+ approximate: "approximate";
567
+ unknown: "unknown";
568
+ }>;
569
+ }, z.core.$strict>;
570
+ react: z.ZodObject<{
571
+ supported: z.ZodBoolean;
572
+ version: z.ZodOptional<z.ZodString>;
573
+ componentName: z.ZodOptional<z.ZodString>;
574
+ componentStack: z.ZodArray<z.ZodString>;
575
+ source: z.ZodOptional<z.ZodObject<{
576
+ fileId: z.ZodOptional<z.ZodString>;
577
+ relativePath: z.ZodOptional<z.ZodString>;
578
+ line: z.ZodOptional<z.ZodNumber>;
579
+ column: z.ZodOptional<z.ZodNumber>;
580
+ origin: z.ZodEnum<{
581
+ "jsx-host": "jsx-host";
582
+ "react-fiber": "react-fiber";
583
+ "dom-ancestor": "dom-ancestor";
584
+ none: "none";
585
+ }>;
586
+ confidence: z.ZodEnum<{
587
+ exact: "exact";
588
+ probable: "probable";
589
+ approximate: "approximate";
590
+ unknown: "unknown";
591
+ }>;
592
+ }, z.core.$strict>>;
593
+ }, z.core.$strict>;
594
+ element: z.ZodObject<{
595
+ tagName: z.ZodString;
596
+ selector: z.ZodString;
597
+ sanitizedHtml: z.ZodString;
598
+ textPreview: z.ZodOptional<z.ZodString>;
599
+ role: z.ZodOptional<z.ZodString>;
600
+ rect: z.ZodObject<{
601
+ x: z.ZodNumber;
602
+ y: z.ZodNumber;
603
+ width: z.ZodNumber;
604
+ height: z.ZodNumber;
605
+ }, z.core.$strict>;
606
+ }, z.core.$strict>;
607
+ styles: z.ZodObject<{
608
+ classNames: z.ZodArray<z.ZodString>;
609
+ inlineStyle: z.ZodOptional<z.ZodString>;
610
+ matchedRules: z.ZodArray<z.ZodObject<{
611
+ selector: z.ZodString;
612
+ declarations: z.ZodString;
613
+ source: z.ZodOptional<z.ZodString>;
614
+ media: z.ZodOptional<z.ZodString>;
615
+ }, z.core.$strict>>;
616
+ computed: z.ZodRecord<z.ZodString, z.ZodString>;
617
+ warnings: z.ZodArray<z.ZodString>;
618
+ }, z.core.$strict>;
619
+ code: z.ZodOptional<z.ZodObject<{
620
+ relativePath: z.ZodString;
621
+ language: z.ZodEnum<{
622
+ tsx: "tsx";
623
+ jsx: "jsx";
624
+ }>;
625
+ startLine: z.ZodNumber;
626
+ endLine: z.ZodNumber;
627
+ excerpt: z.ZodString;
628
+ boundary: z.ZodEnum<{
629
+ component: "component";
630
+ "nearby-lines": "nearby-lines";
631
+ }>;
632
+ }, z.core.$strict>>;
633
+ warnings: z.ZodArray<z.ZodString>;
634
+ }, z.core.$strict>>;
635
+ createdAt: z.ZodISODateTime;
636
+ }, z.core.$strict>;
637
+ providerProfileId: z.ZodString;
638
+ modelProfileId: z.ZodString;
639
+ providerDataConsent: z.ZodLiteral<true>;
640
+ }, z.core.$strict>;
641
+ declare const agentJobActionRequestSchema: z.ZodObject<{}, z.core.$strict>;
642
+ type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;
643
+ type OpenEditorRequest = z.infer<typeof openEditorRequestSchema>;
644
+ type AgentCapabilityRequest = z.infer<typeof agentCapabilityRequestSchema>;
645
+ interface AgentJobCreateRequest {
646
+ readonly annotation: SpotAnnotation;
647
+ readonly providerProfileId: string;
648
+ readonly modelProfileId: string;
649
+ readonly providerDataConsent: true;
650
+ }
651
+
652
+ interface AgentJobEventBase {
653
+ readonly schemaVersion: 1;
654
+ readonly sequence: number;
655
+ readonly jobId: string;
656
+ readonly status: AgentJobStatus;
657
+ readonly timestamp: string;
658
+ }
659
+ type AgentJobEvent = (AgentJobEventBase & {
660
+ readonly type: "snapshot";
661
+ readonly data: Readonly<{
662
+ snapshot: AgentJobSnapshot;
663
+ }>;
664
+ }) | (AgentJobEventBase & {
665
+ readonly type: "phase";
666
+ readonly data: Readonly<{
667
+ message: string;
668
+ }>;
669
+ }) | (AgentJobEventBase & {
670
+ readonly type: "tool";
671
+ readonly data: Readonly<{
672
+ toolCallId: string;
673
+ toolName: string;
674
+ state: "started" | "succeeded" | "failed";
675
+ relativePath?: string;
676
+ checkLabel?: string;
677
+ }>;
678
+ }) | (AgentJobEventBase & {
679
+ readonly type: "check";
680
+ readonly data: Readonly<{
681
+ result: AgentCheckResult;
682
+ }>;
683
+ }) | (AgentJobEventBase & {
684
+ readonly type: "result-ready";
685
+ readonly data: Readonly<{
686
+ hasResult: true;
687
+ }>;
688
+ }) | (AgentJobEventBase & {
689
+ readonly type: "error";
690
+ readonly data: Readonly<{
691
+ code: ErrorCode;
692
+ message: string;
693
+ }>;
694
+ });
695
+
696
+ declare const agentCapabilitySnapshotSchema: z.ZodObject<{
697
+ providerProfileId: z.ZodString;
698
+ providerLabel: z.ZodString;
699
+ modelProfileId: z.ZodString;
700
+ modelLabel: z.ZodString;
701
+ protocol: z.ZodEnum<{
702
+ responses: "responses";
703
+ "chat-completions": "chat-completions";
704
+ }>;
705
+ state: z.ZodEnum<{
706
+ unknown: "unknown";
707
+ probing: "probing";
708
+ "agent-ready": "agent-ready";
709
+ "prompt-only": "prompt-only";
710
+ unavailable: "unavailable";
711
+ }>;
712
+ authenticated: z.ZodBoolean;
713
+ modelAvailable: z.ZodBoolean;
714
+ toolCalling: z.ZodBoolean;
715
+ toolResultContinuation: z.ZodBoolean;
716
+ streaming: z.ZodBoolean;
717
+ checkedAt: z.ZodOptional<z.ZodISODateTime>;
718
+ errorCode: z.ZodOptional<z.ZodEnum<{
719
+ readonly INVALID_REQUEST: "INVALID_REQUEST";
720
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
721
+ readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
722
+ readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
723
+ readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
724
+ readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
725
+ readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
726
+ readonly AI_DISABLED: "AI_DISABLED";
727
+ readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
728
+ readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
729
+ readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
730
+ readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
731
+ readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
732
+ readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
733
+ readonly AGENT_BUSY: "AGENT_BUSY";
734
+ readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
735
+ readonly AGENT_CANCELLED: "AGENT_CANCELLED";
736
+ readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
737
+ readonly TOOL_DENIED: "TOOL_DENIED";
738
+ readonly PATCH_REJECTED: "PATCH_REJECTED";
739
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
740
+ readonly APPLY_CONFLICT: "APPLY_CONFLICT";
741
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
742
+ }>>;
743
+ }, z.core.$strict>;
744
+ declare const agentChangedFileSchema: z.ZodObject<{
745
+ relativePath: z.ZodString;
746
+ kind: z.ZodEnum<{
747
+ added: "added";
748
+ modified: "modified";
749
+ deleted: "deleted";
750
+ }>;
751
+ additions: z.ZodNumber;
752
+ deletions: z.ZodNumber;
753
+ }, z.core.$strict>;
754
+ declare const agentCheckResultSchema: z.ZodObject<{
755
+ checkId: z.ZodString;
756
+ label: z.ZodString;
757
+ status: z.ZodEnum<{
758
+ cancelled: "cancelled";
759
+ failed: "failed";
760
+ passed: "passed";
761
+ "timed-out": "timed-out";
762
+ }>;
763
+ durationMs: z.ZodNumber;
764
+ output: z.ZodString;
765
+ }, z.core.$strict>;
766
+ declare const agentJobSnapshotSchema: z.ZodObject<{
767
+ jobId: z.ZodString;
768
+ status: z.ZodEnum<{
769
+ queued: "queued";
770
+ preparing: "preparing";
771
+ running: "running";
772
+ validating: "validating";
773
+ "awaiting-review": "awaiting-review";
774
+ applying: "applying";
775
+ applied: "applied";
776
+ completed: "completed";
777
+ cancelling: "cancelling";
778
+ cancelled: "cancelled";
779
+ reverting: "reverting";
780
+ reverted: "reverted";
781
+ failed: "failed";
782
+ }>;
783
+ providerProfileId: z.ZodString;
784
+ providerLabel: z.ZodString;
785
+ modelProfileId: z.ZodString;
786
+ modelLabel: z.ZodString;
787
+ phaseMessage: z.ZodString;
788
+ createdAt: z.ZodISODateTime;
789
+ updatedAt: z.ZodISODateTime;
790
+ canCancel: z.ZodBoolean;
791
+ canApply: z.ZodBoolean;
792
+ canRevert: z.ZodBoolean;
793
+ errorCode: z.ZodOptional<z.ZodEnum<{
794
+ readonly INVALID_REQUEST: "INVALID_REQUEST";
795
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
796
+ readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
797
+ readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
798
+ readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
799
+ readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
800
+ readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
801
+ readonly AI_DISABLED: "AI_DISABLED";
802
+ readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
803
+ readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
804
+ readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
805
+ readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
806
+ readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
807
+ readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
808
+ readonly AGENT_BUSY: "AGENT_BUSY";
809
+ readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
810
+ readonly AGENT_CANCELLED: "AGENT_CANCELLED";
811
+ readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
812
+ readonly TOOL_DENIED: "TOOL_DENIED";
813
+ readonly PATCH_REJECTED: "PATCH_REJECTED";
814
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
815
+ readonly APPLY_CONFLICT: "APPLY_CONFLICT";
816
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
817
+ }>>;
818
+ }, z.core.$strict>;
819
+ declare const agentJobResultSchema: z.ZodObject<{
820
+ jobId: z.ZodString;
821
+ summary: z.ZodString;
822
+ diff: z.ZodString;
823
+ files: z.ZodArray<z.ZodObject<{
824
+ relativePath: z.ZodString;
825
+ kind: z.ZodEnum<{
826
+ added: "added";
827
+ modified: "modified";
828
+ deleted: "deleted";
829
+ }>;
830
+ additions: z.ZodNumber;
831
+ deletions: z.ZodNumber;
832
+ }, z.core.$strict>>;
833
+ checks: z.ZodArray<z.ZodObject<{
834
+ checkId: z.ZodString;
835
+ label: z.ZodString;
836
+ status: z.ZodEnum<{
837
+ cancelled: "cancelled";
838
+ failed: "failed";
839
+ passed: "passed";
840
+ "timed-out": "timed-out";
841
+ }>;
842
+ durationMs: z.ZodNumber;
843
+ output: z.ZodString;
844
+ }, z.core.$strict>>;
845
+ }, z.core.$strict>;
846
+ declare const agentJobResultResponseSchema: z.ZodObject<{
847
+ snapshot: z.ZodObject<{
848
+ jobId: z.ZodString;
849
+ status: z.ZodEnum<{
850
+ queued: "queued";
851
+ preparing: "preparing";
852
+ running: "running";
853
+ validating: "validating";
854
+ "awaiting-review": "awaiting-review";
855
+ applying: "applying";
856
+ applied: "applied";
857
+ completed: "completed";
858
+ cancelling: "cancelling";
859
+ cancelled: "cancelled";
860
+ reverting: "reverting";
861
+ reverted: "reverted";
862
+ failed: "failed";
863
+ }>;
864
+ providerProfileId: z.ZodString;
865
+ providerLabel: z.ZodString;
866
+ modelProfileId: z.ZodString;
867
+ modelLabel: z.ZodString;
868
+ phaseMessage: z.ZodString;
869
+ createdAt: z.ZodISODateTime;
870
+ updatedAt: z.ZodISODateTime;
871
+ canCancel: z.ZodBoolean;
872
+ canApply: z.ZodBoolean;
873
+ canRevert: z.ZodBoolean;
874
+ errorCode: z.ZodOptional<z.ZodEnum<{
875
+ readonly INVALID_REQUEST: "INVALID_REQUEST";
876
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
877
+ readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
878
+ readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
879
+ readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
880
+ readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
881
+ readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
882
+ readonly AI_DISABLED: "AI_DISABLED";
883
+ readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
884
+ readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
885
+ readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
886
+ readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
887
+ readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
888
+ readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
889
+ readonly AGENT_BUSY: "AGENT_BUSY";
890
+ readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
891
+ readonly AGENT_CANCELLED: "AGENT_CANCELLED";
892
+ readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
893
+ readonly TOOL_DENIED: "TOOL_DENIED";
894
+ readonly PATCH_REJECTED: "PATCH_REJECTED";
895
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
896
+ readonly APPLY_CONFLICT: "APPLY_CONFLICT";
897
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
898
+ }>>;
899
+ }, z.core.$strict>;
900
+ result: z.ZodOptional<z.ZodObject<{
901
+ jobId: z.ZodString;
902
+ summary: z.ZodString;
903
+ diff: z.ZodString;
904
+ files: z.ZodArray<z.ZodObject<{
905
+ relativePath: z.ZodString;
906
+ kind: z.ZodEnum<{
907
+ added: "added";
908
+ modified: "modified";
909
+ deleted: "deleted";
910
+ }>;
911
+ additions: z.ZodNumber;
912
+ deletions: z.ZodNumber;
913
+ }, z.core.$strict>>;
914
+ checks: z.ZodArray<z.ZodObject<{
915
+ checkId: z.ZodString;
916
+ label: z.ZodString;
917
+ status: z.ZodEnum<{
918
+ cancelled: "cancelled";
919
+ failed: "failed";
920
+ passed: "passed";
921
+ "timed-out": "timed-out";
922
+ }>;
923
+ durationMs: z.ZodNumber;
924
+ output: z.ZodString;
925
+ }, z.core.$strict>>;
926
+ }, z.core.$strict>>;
927
+ }, z.core.$strict>;
928
+ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
929
+ schemaVersion: z.ZodLiteral<1>;
930
+ sequence: z.ZodNumber;
931
+ jobId: z.ZodString;
932
+ status: z.ZodEnum<{
933
+ queued: "queued";
934
+ preparing: "preparing";
935
+ running: "running";
936
+ validating: "validating";
937
+ "awaiting-review": "awaiting-review";
938
+ applying: "applying";
939
+ applied: "applied";
940
+ completed: "completed";
941
+ cancelling: "cancelling";
942
+ cancelled: "cancelled";
943
+ reverting: "reverting";
944
+ reverted: "reverted";
945
+ failed: "failed";
946
+ }>;
947
+ timestamp: z.ZodISODateTime;
948
+ type: z.ZodLiteral<"snapshot">;
949
+ data: z.ZodObject<{
950
+ snapshot: z.ZodObject<{
951
+ jobId: z.ZodString;
952
+ status: z.ZodEnum<{
953
+ queued: "queued";
954
+ preparing: "preparing";
955
+ running: "running";
956
+ validating: "validating";
957
+ "awaiting-review": "awaiting-review";
958
+ applying: "applying";
959
+ applied: "applied";
960
+ completed: "completed";
961
+ cancelling: "cancelling";
962
+ cancelled: "cancelled";
963
+ reverting: "reverting";
964
+ reverted: "reverted";
965
+ failed: "failed";
966
+ }>;
967
+ providerProfileId: z.ZodString;
968
+ providerLabel: z.ZodString;
969
+ modelProfileId: z.ZodString;
970
+ modelLabel: z.ZodString;
971
+ phaseMessage: z.ZodString;
972
+ createdAt: z.ZodISODateTime;
973
+ updatedAt: z.ZodISODateTime;
974
+ canCancel: z.ZodBoolean;
975
+ canApply: z.ZodBoolean;
976
+ canRevert: z.ZodBoolean;
977
+ errorCode: z.ZodOptional<z.ZodEnum<{
978
+ readonly INVALID_REQUEST: "INVALID_REQUEST";
979
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
980
+ readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
981
+ readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
982
+ readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
983
+ readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
984
+ readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
985
+ readonly AI_DISABLED: "AI_DISABLED";
986
+ readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
987
+ readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
988
+ readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
989
+ readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
990
+ readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
991
+ readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
992
+ readonly AGENT_BUSY: "AGENT_BUSY";
993
+ readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
994
+ readonly AGENT_CANCELLED: "AGENT_CANCELLED";
995
+ readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
996
+ readonly TOOL_DENIED: "TOOL_DENIED";
997
+ readonly PATCH_REJECTED: "PATCH_REJECTED";
998
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
999
+ readonly APPLY_CONFLICT: "APPLY_CONFLICT";
1000
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
1001
+ }>>;
1002
+ }, z.core.$strict>;
1003
+ }, z.core.$strict>;
1004
+ }, z.core.$strict>, z.ZodObject<{
1005
+ schemaVersion: z.ZodLiteral<1>;
1006
+ sequence: z.ZodNumber;
1007
+ jobId: z.ZodString;
1008
+ status: z.ZodEnum<{
1009
+ queued: "queued";
1010
+ preparing: "preparing";
1011
+ running: "running";
1012
+ validating: "validating";
1013
+ "awaiting-review": "awaiting-review";
1014
+ applying: "applying";
1015
+ applied: "applied";
1016
+ completed: "completed";
1017
+ cancelling: "cancelling";
1018
+ cancelled: "cancelled";
1019
+ reverting: "reverting";
1020
+ reverted: "reverted";
1021
+ failed: "failed";
1022
+ }>;
1023
+ timestamp: z.ZodISODateTime;
1024
+ type: z.ZodLiteral<"phase">;
1025
+ data: z.ZodObject<{
1026
+ message: z.ZodString;
1027
+ }, z.core.$strict>;
1028
+ }, z.core.$strict>, z.ZodObject<{
1029
+ schemaVersion: z.ZodLiteral<1>;
1030
+ sequence: z.ZodNumber;
1031
+ jobId: z.ZodString;
1032
+ status: z.ZodEnum<{
1033
+ queued: "queued";
1034
+ preparing: "preparing";
1035
+ running: "running";
1036
+ validating: "validating";
1037
+ "awaiting-review": "awaiting-review";
1038
+ applying: "applying";
1039
+ applied: "applied";
1040
+ completed: "completed";
1041
+ cancelling: "cancelling";
1042
+ cancelled: "cancelled";
1043
+ reverting: "reverting";
1044
+ reverted: "reverted";
1045
+ failed: "failed";
1046
+ }>;
1047
+ timestamp: z.ZodISODateTime;
1048
+ type: z.ZodLiteral<"tool">;
1049
+ data: z.ZodObject<{
1050
+ toolCallId: z.ZodString;
1051
+ toolName: z.ZodString;
1052
+ state: z.ZodEnum<{
1053
+ failed: "failed";
1054
+ started: "started";
1055
+ succeeded: "succeeded";
1056
+ }>;
1057
+ relativePath: z.ZodOptional<z.ZodString>;
1058
+ checkLabel: z.ZodOptional<z.ZodString>;
1059
+ }, z.core.$strict>;
1060
+ }, z.core.$strict>, z.ZodObject<{
1061
+ schemaVersion: z.ZodLiteral<1>;
1062
+ sequence: z.ZodNumber;
1063
+ jobId: z.ZodString;
1064
+ status: z.ZodEnum<{
1065
+ queued: "queued";
1066
+ preparing: "preparing";
1067
+ running: "running";
1068
+ validating: "validating";
1069
+ "awaiting-review": "awaiting-review";
1070
+ applying: "applying";
1071
+ applied: "applied";
1072
+ completed: "completed";
1073
+ cancelling: "cancelling";
1074
+ cancelled: "cancelled";
1075
+ reverting: "reverting";
1076
+ reverted: "reverted";
1077
+ failed: "failed";
1078
+ }>;
1079
+ timestamp: z.ZodISODateTime;
1080
+ type: z.ZodLiteral<"check">;
1081
+ data: z.ZodObject<{
1082
+ result: z.ZodObject<{
1083
+ checkId: z.ZodString;
1084
+ label: z.ZodString;
1085
+ status: z.ZodEnum<{
1086
+ cancelled: "cancelled";
1087
+ failed: "failed";
1088
+ passed: "passed";
1089
+ "timed-out": "timed-out";
1090
+ }>;
1091
+ durationMs: z.ZodNumber;
1092
+ output: z.ZodString;
1093
+ }, z.core.$strict>;
1094
+ }, z.core.$strict>;
1095
+ }, z.core.$strict>, z.ZodObject<{
1096
+ schemaVersion: z.ZodLiteral<1>;
1097
+ sequence: z.ZodNumber;
1098
+ jobId: z.ZodString;
1099
+ status: z.ZodEnum<{
1100
+ queued: "queued";
1101
+ preparing: "preparing";
1102
+ running: "running";
1103
+ validating: "validating";
1104
+ "awaiting-review": "awaiting-review";
1105
+ applying: "applying";
1106
+ applied: "applied";
1107
+ completed: "completed";
1108
+ cancelling: "cancelling";
1109
+ cancelled: "cancelled";
1110
+ reverting: "reverting";
1111
+ reverted: "reverted";
1112
+ failed: "failed";
1113
+ }>;
1114
+ timestamp: z.ZodISODateTime;
1115
+ type: z.ZodLiteral<"result-ready">;
1116
+ data: z.ZodObject<{
1117
+ hasResult: z.ZodLiteral<true>;
1118
+ }, z.core.$strict>;
1119
+ }, z.core.$strict>, z.ZodObject<{
1120
+ schemaVersion: z.ZodLiteral<1>;
1121
+ sequence: z.ZodNumber;
1122
+ jobId: z.ZodString;
1123
+ status: z.ZodEnum<{
1124
+ queued: "queued";
1125
+ preparing: "preparing";
1126
+ running: "running";
1127
+ validating: "validating";
1128
+ "awaiting-review": "awaiting-review";
1129
+ applying: "applying";
1130
+ applied: "applied";
1131
+ completed: "completed";
1132
+ cancelling: "cancelling";
1133
+ cancelled: "cancelled";
1134
+ reverting: "reverting";
1135
+ reverted: "reverted";
1136
+ failed: "failed";
1137
+ }>;
1138
+ timestamp: z.ZodISODateTime;
1139
+ type: z.ZodLiteral<"error">;
1140
+ data: z.ZodObject<{
1141
+ code: z.ZodEnum<{
1142
+ readonly INVALID_REQUEST: "INVALID_REQUEST";
1143
+ readonly INVALID_TOKEN: "INVALID_TOKEN";
1144
+ readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
1145
+ readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
1146
+ readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
1147
+ readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
1148
+ readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
1149
+ readonly AI_DISABLED: "AI_DISABLED";
1150
+ readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
1151
+ readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
1152
+ readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
1153
+ readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
1154
+ readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
1155
+ readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
1156
+ readonly AGENT_BUSY: "AGENT_BUSY";
1157
+ readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
1158
+ readonly AGENT_CANCELLED: "AGENT_CANCELLED";
1159
+ readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
1160
+ readonly TOOL_DENIED: "TOOL_DENIED";
1161
+ readonly PATCH_REJECTED: "PATCH_REJECTED";
1162
+ readonly VALIDATION_FAILED: "VALIDATION_FAILED";
1163
+ readonly APPLY_CONFLICT: "APPLY_CONFLICT";
1164
+ readonly INTERNAL_ERROR: "INTERNAL_ERROR";
1165
+ }>;
1166
+ message: z.ZodString;
1167
+ }, z.core.$strict>;
1168
+ }, z.core.$strict>], "type">;
1169
+
1170
+ interface ApiSuccess<T> {
1171
+ readonly ok: true;
1172
+ readonly data: T;
1173
+ }
1174
+ interface ApiFailure {
1175
+ readonly ok: false;
1176
+ readonly error: Readonly<{
1177
+ code: ErrorCode;
1178
+ message: string;
1179
+ }>;
1180
+ }
1181
+ type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
1182
+
1183
+ export { AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, type AgentApplyMode, type AgentCapabilityRequest, type AgentCapabilitySnapshot, type AgentCapabilityState, type AgentChangedFile, type AgentCheckDefinition, type AgentCheckResult, type AgentCheckStatus, type AgentFileChangeKind, type AgentJobAction, type AgentJobCreateRequest, type AgentJobEvent, type AgentJobResult, type AgentJobResultResponse, type AgentJobSnapshot, type AgentJobStatus, type AgentLimits, type AiExecutionOptions, type AiModelProfile, type AiOptions, type AiProviderProtocol, type ApiFailure, type ApiResponse, type ApiSuccess, type CodeContext, type ContextBudget, DEFAULT_AGENT_LIMITS, ERROR_CODES, type ElementContext, type ErrorCode, MAX_ANNOTATION_INSTRUCTION_CHARACTERS, MAX_ANNOTATION_TARGETS, MAX_TARGET_INSTRUCTION_CHARACTERS, type MatchedStyleRule, type OpenAICompatibleProviderOptions, type OpenEditorRequest, type PageContext, type ReactContext, type ResolvedAgentCheckDefinition, type ResolvedAiExecutionOptions, type ResolvedAiModelProfile, type ResolvedAiOptions, type ResolvedOpenAICompatibleProviderOptions, type RuntimeAiConfig, type RuntimeAiModelProfile, type RuntimeAiProviderProfile, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, SPOTPATCH_TOKEN_HEADER, type SourceConfidence, type SourceContextRequest, type SourceMarker, type SourceOrigin, type SourceRef, type SpotAnnotation, SpotPatchError, type SpotPatchLocale, type SpotPatchLocalePreference, type SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };