@spotpatch/shared 1.5.0 → 1.7.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/README.md +1 -5
- package/dist/index.cjs +78 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -2
- package/dist/index.d.ts +31 -2
- package/dist/index.js +77 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
<
|
|
2
|
-
<a href="https://github.com/huanglvjing/spotpatch"><img src="https://raw.githubusercontent.com/huanglvjing/spotpatch/main/docs/assets/spotpatch-logo.svg" alt="SpotPatch" width="560" /></a>
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
# `@spotpatch/shared`
|
|
1
|
+
<h1><a href="https://github.com/huanglvjing/spotpatch"><img src="https://raw.githubusercontent.com/huanglvjing/spotpatch/main/docs/assets/spotpatch-npm-icon.png" alt="SpotPatch" width="48" height="48" align="absmiddle" /></a> <code>@spotpatch/shared</code></h1>
|
|
6
2
|
|
|
7
3
|
## English
|
|
8
4
|
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AGENT_APPLY_MODES: () => AGENT_APPLY_MODES,
|
|
23
24
|
AGENT_CAPABILITY_STATES: () => AGENT_CAPABILITY_STATES,
|
|
24
25
|
AGENT_CHECK_STATUSES: () => AGENT_CHECK_STATUSES,
|
|
25
26
|
AGENT_FILE_CHANGE_KINDS: () => AGENT_FILE_CHANGE_KINDS,
|
|
@@ -216,6 +217,69 @@ function getAgentJobEndpoint(jobId, action) {
|
|
|
216
217
|
// src/model/editor.ts
|
|
217
218
|
var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
|
|
218
219
|
|
|
220
|
+
// src/model/agent.ts
|
|
221
|
+
var AGENT_APPLY_MODES = Object.freeze([
|
|
222
|
+
"review",
|
|
223
|
+
"auto",
|
|
224
|
+
"trusted-auto"
|
|
225
|
+
]);
|
|
226
|
+
var DEFAULT_AGENT_LIMITS = Object.freeze({
|
|
227
|
+
maxTurns: 20,
|
|
228
|
+
maxToolCalls: 80,
|
|
229
|
+
maxChangedFiles: 20,
|
|
230
|
+
maxDiffBytes: 512e3,
|
|
231
|
+
maxReadBytesPerFile: 256e3,
|
|
232
|
+
maxToolOutputCharacters: 4e4,
|
|
233
|
+
maxProviderResponseBytes: 2e6,
|
|
234
|
+
providerConnectTimeoutMs: 15e3,
|
|
235
|
+
providerFirstByteTimeoutMs: 3e4,
|
|
236
|
+
providerIdleTimeoutMs: 6e4,
|
|
237
|
+
checkTimeoutMs: 12e4,
|
|
238
|
+
jobTimeoutMs: 6e5
|
|
239
|
+
});
|
|
240
|
+
var AGENT_JOB_STATUSES = Object.freeze([
|
|
241
|
+
"queued",
|
|
242
|
+
"preparing",
|
|
243
|
+
"running",
|
|
244
|
+
"validating",
|
|
245
|
+
"awaiting-review",
|
|
246
|
+
"applying",
|
|
247
|
+
"applied",
|
|
248
|
+
"completed",
|
|
249
|
+
"cancelling",
|
|
250
|
+
"cancelled",
|
|
251
|
+
"reverting",
|
|
252
|
+
"reverted",
|
|
253
|
+
"failed"
|
|
254
|
+
]);
|
|
255
|
+
var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
256
|
+
"unknown",
|
|
257
|
+
"probing",
|
|
258
|
+
"agent-ready",
|
|
259
|
+
"prompt-only",
|
|
260
|
+
"unavailable"
|
|
261
|
+
]);
|
|
262
|
+
var AGENT_WORKSPACE_STATES = Object.freeze([
|
|
263
|
+
"ready",
|
|
264
|
+
"consent-required",
|
|
265
|
+
"blocked"
|
|
266
|
+
]);
|
|
267
|
+
var AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({
|
|
268
|
+
maxUntrackedFiles: 1e3,
|
|
269
|
+
maxUntrackedBytes: 20 * 1024 * 1024
|
|
270
|
+
});
|
|
271
|
+
var AGENT_FILE_CHANGE_KINDS = Object.freeze([
|
|
272
|
+
"added",
|
|
273
|
+
"modified",
|
|
274
|
+
"deleted"
|
|
275
|
+
]);
|
|
276
|
+
var AGENT_CHECK_STATUSES = Object.freeze([
|
|
277
|
+
"passed",
|
|
278
|
+
"failed",
|
|
279
|
+
"cancelled",
|
|
280
|
+
"timed-out"
|
|
281
|
+
]);
|
|
282
|
+
|
|
219
283
|
// src/model/runtime-config.ts
|
|
220
284
|
var SPOTPATCH_NEXT_BUNDLERS = Object.freeze(["turbopack", "webpack"]);
|
|
221
285
|
var SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([
|
|
@@ -245,7 +309,7 @@ var runtimeAiConfigSchema = import_zod.z.discriminatedUnion("enabled", [
|
|
|
245
309
|
enabled: import_zod.z.literal(true),
|
|
246
310
|
providers: import_zod.z.array(runtimeAiProviderSchema).min(1).max(32),
|
|
247
311
|
defaultProvider: profileIdSchema,
|
|
248
|
-
applyMode: import_zod.z.enum(
|
|
312
|
+
applyMode: import_zod.z.enum(AGENT_APPLY_MODES)
|
|
249
313
|
}).refine(
|
|
250
314
|
({ defaultProvider, providers }) => providers.some(({ id }) => id === defaultProvider) && new Set(providers.map(({ id }) => id)).size === providers.length,
|
|
251
315
|
{ message: "Runtime AI provider profiles are inconsistent." }
|
|
@@ -269,6 +333,7 @@ var runtimeConfigBaseShape = {
|
|
|
269
333
|
locale: import_zod.z.enum(SPOTPATCH_LOCALE_PREFERENCES),
|
|
270
334
|
maxTargets: import_zod.z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
|
|
271
335
|
redact: import_zod.z.boolean(),
|
|
336
|
+
sessionId: import_zod.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
272
337
|
sessionToken: import_zod.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
273
338
|
shortcut: boundedText(128),
|
|
274
339
|
spotPatchVersion: boundedText(64)
|
|
@@ -286,64 +351,6 @@ var runtimeConfigSchema = import_zod.z.discriminatedUnion("framework", [
|
|
|
286
351
|
})
|
|
287
352
|
]);
|
|
288
353
|
|
|
289
|
-
// src/model/agent.ts
|
|
290
|
-
var DEFAULT_AGENT_LIMITS = Object.freeze({
|
|
291
|
-
maxTurns: 20,
|
|
292
|
-
maxToolCalls: 80,
|
|
293
|
-
maxChangedFiles: 20,
|
|
294
|
-
maxDiffBytes: 512e3,
|
|
295
|
-
maxReadBytesPerFile: 256e3,
|
|
296
|
-
maxToolOutputCharacters: 4e4,
|
|
297
|
-
maxProviderResponseBytes: 2e6,
|
|
298
|
-
providerConnectTimeoutMs: 15e3,
|
|
299
|
-
providerFirstByteTimeoutMs: 3e4,
|
|
300
|
-
providerIdleTimeoutMs: 6e4,
|
|
301
|
-
checkTimeoutMs: 12e4,
|
|
302
|
-
jobTimeoutMs: 6e5
|
|
303
|
-
});
|
|
304
|
-
var AGENT_JOB_STATUSES = Object.freeze([
|
|
305
|
-
"queued",
|
|
306
|
-
"preparing",
|
|
307
|
-
"running",
|
|
308
|
-
"validating",
|
|
309
|
-
"awaiting-review",
|
|
310
|
-
"applying",
|
|
311
|
-
"applied",
|
|
312
|
-
"completed",
|
|
313
|
-
"cancelling",
|
|
314
|
-
"cancelled",
|
|
315
|
-
"reverting",
|
|
316
|
-
"reverted",
|
|
317
|
-
"failed"
|
|
318
|
-
]);
|
|
319
|
-
var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
320
|
-
"unknown",
|
|
321
|
-
"probing",
|
|
322
|
-
"agent-ready",
|
|
323
|
-
"prompt-only",
|
|
324
|
-
"unavailable"
|
|
325
|
-
]);
|
|
326
|
-
var AGENT_WORKSPACE_STATES = Object.freeze([
|
|
327
|
-
"ready",
|
|
328
|
-
"consent-required",
|
|
329
|
-
"blocked"
|
|
330
|
-
]);
|
|
331
|
-
var AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({
|
|
332
|
-
maxUntrackedFiles: 1e3,
|
|
333
|
-
maxUntrackedBytes: 20 * 1024 * 1024
|
|
334
|
-
});
|
|
335
|
-
var AGENT_FILE_CHANGE_KINDS = Object.freeze([
|
|
336
|
-
"added",
|
|
337
|
-
"modified",
|
|
338
|
-
"deleted"
|
|
339
|
-
]);
|
|
340
|
-
var AGENT_CHECK_STATUSES = Object.freeze([
|
|
341
|
-
"passed",
|
|
342
|
-
"failed",
|
|
343
|
-
"cancelled",
|
|
344
|
-
"timed-out"
|
|
345
|
-
]);
|
|
346
|
-
|
|
347
354
|
// src/model/source-marker.ts
|
|
348
355
|
var SOURCE_MARKER_ATTRIBUTE = "data-spotpatch-source";
|
|
349
356
|
var SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)$/;
|
|
@@ -403,8 +410,17 @@ var codeContextSchema = import_zod2.z.strictObject({
|
|
|
403
410
|
excerpt: boundedString(16e3),
|
|
404
411
|
boundary: import_zod2.z.enum(["component", "nearby-lines"])
|
|
405
412
|
});
|
|
413
|
+
var pageContextSchema = import_zod2.z.strictObject({
|
|
414
|
+
url: boundedString(2048),
|
|
415
|
+
pathname: boundedString(2048),
|
|
416
|
+
title: boundedString(1024),
|
|
417
|
+
viewportWidth: import_zod2.z.number().nonnegative(),
|
|
418
|
+
viewportHeight: import_zod2.z.number().nonnegative(),
|
|
419
|
+
devicePixelRatio: import_zod2.z.number().positive()
|
|
420
|
+
});
|
|
406
421
|
var spotTargetContextRequestSchema = import_zod2.z.strictObject({
|
|
407
422
|
instruction: import_zod2.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
423
|
+
page: pageContextSchema.optional(),
|
|
408
424
|
source: sourceRefSchema,
|
|
409
425
|
react: import_zod2.z.strictObject({
|
|
410
426
|
supported: import_zod2.z.boolean(),
|
|
@@ -440,14 +456,7 @@ var spotAnnotationRequestSchema = import_zod2.z.strictObject({
|
|
|
440
456
|
schemaVersion: import_zod2.z.literal(3),
|
|
441
457
|
id: boundedString(128),
|
|
442
458
|
locale: import_zod2.z.enum(SPOTPATCH_LOCALES),
|
|
443
|
-
page:
|
|
444
|
-
url: boundedString(2048),
|
|
445
|
-
pathname: boundedString(2048),
|
|
446
|
-
title: boundedString(1024),
|
|
447
|
-
viewportWidth: import_zod2.z.number().nonnegative(),
|
|
448
|
-
viewportHeight: import_zod2.z.number().nonnegative(),
|
|
449
|
-
devicePixelRatio: import_zod2.z.number().positive()
|
|
450
|
-
}),
|
|
459
|
+
page: pageContextSchema,
|
|
451
460
|
targets: import_zod2.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
452
461
|
createdAt: import_zod2.z.iso.datetime()
|
|
453
462
|
}).superRefine((annotation, context) => {
|
|
@@ -473,6 +482,7 @@ var agentJobCreateRequestSchema = import_zod2.z.strictObject({
|
|
|
473
482
|
providerProfileId: profileIdSchema2,
|
|
474
483
|
modelProfileId: profileIdSchema2,
|
|
475
484
|
providerDataConsent: import_zod2.z.literal(true),
|
|
485
|
+
trustedFastModeConsent: import_zod2.z.literal(true).optional(),
|
|
476
486
|
workingTreeMode: import_zod2.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
477
487
|
});
|
|
478
488
|
var agentJobActionRequestSchema = import_zod2.z.strictObject({});
|
|
@@ -638,6 +648,7 @@ var agentJobEventSchema = import_zod3.z.discriminatedUnion("type", [
|
|
|
638
648
|
var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
639
649
|
// Annotate the CommonJS export names for ESM import in node:
|
|
640
650
|
0 && (module.exports = {
|
|
651
|
+
AGENT_APPLY_MODES,
|
|
641
652
|
AGENT_CAPABILITY_STATES,
|
|
642
653
|
AGENT_CHECK_STATUSES,
|
|
643
654
|
AGENT_FILE_CHANGE_KINDS,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors/spotpatch-error.ts","../src/errors/error-code.ts","../src/security/redaction.ts","../src/model/annotation.ts","../src/model/runtime-config.ts","../src/protocol/endpoints.ts","../src/model/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/requests.ts","../src/protocol/agent-schemas.ts","../src/product.ts"],"sourcesContent":["export { SpotPatchError } from \"./errors/spotpatch-error.js\";\nexport { ERROR_CODES, type ErrorCode } from \"./errors/error-code.js\";\nexport {\n isSensitiveName,\n redactSensitiveText,\n sanitizeUrl,\n} from \"./security/redaction.js\";\nexport {\n MAX_ANNOTATION_INSTRUCTION_CHARACTERS,\n MAX_ANNOTATION_TARGETS,\n MAX_TARGET_INSTRUCTION_CHARACTERS,\n SPOTPATCH_LOCALE_PREFERENCES,\n SPOTPATCH_LOCALES,\n type ElementContext,\n type PageContext,\n type SpotAnnotation,\n type SpotPatchLocale,\n type SpotPatchLocalePreference,\n type SpotTargetContext,\n} from \"./model/annotation.js\";\nexport type { CodeContext, ContextBudget } from \"./model/code-context.js\";\nexport {\n runtimeConfigSchema,\n SPOTPATCH_NEXT_BUNDLERS,\n SPOTPATCH_NEXT_ROUTER_KINDS,\n type SpotPatchNextBundler,\n type SpotPatchNextRouterKind,\n type SpotPatchRuntimeConfig,\n} from \"./model/runtime-config.js\";\nexport {\n SPOTPATCH_EDITOR_PREFERENCES,\n type EditorOpenResult,\n type SpotPatchEditorPreference,\n} from \"./model/editor.js\";\nexport {\n AGENT_CAPABILITY_STATES,\n AGENT_CHECK_STATUSES,\n AGENT_FILE_CHANGE_KINDS,\n AGENT_JOB_STATUSES,\n AGENT_WORKSPACE_SNAPSHOT_LIMITS,\n AGENT_WORKSPACE_STATES,\n DEFAULT_AGENT_LIMITS,\n type AgentApplyMode,\n type AgentCapabilitySnapshot,\n type AgentCapabilityState,\n type AgentChangedFile,\n type AgentCheckDefinition,\n type AgentCheckResult,\n type AgentCheckStatus,\n type AgentFileChangeKind,\n type AgentJobResult,\n type AgentJobResultResponse,\n type AgentJobSnapshot,\n type AgentJobStatus,\n type AgentWorkingTreeMode,\n type AgentWorkspaceChangeSummary,\n type AgentWorkspaceHealthSnapshot,\n type AgentWorkspaceState,\n type AgentLimits,\n type AiExecutionOptions,\n type AiModelProfile,\n type AiOptions,\n type AiProviderAuthentication,\n type AiProviderProtocol,\n type OpenAICompatibleProviderOptions,\n type ResolvedAgentCheckDefinition,\n type ResolvedAiExecutionOptions,\n type ResolvedAiModelProfile,\n type ResolvedAiOptions,\n type ResolvedOpenAICompatibleProviderOptions,\n type RuntimeAiConfig,\n type RuntimeAiModelProfile,\n type RuntimeAiProviderProfile,\n} from \"./model/agent.js\";\nexport type {\n ReactContext,\n SourceConfidence,\n SourceOrigin,\n SourceRef,\n} from \"./model/source-ref.js\";\nexport type { MatchedStyleRule, StyleContext } from \"./model/style-context.js\";\nexport {\n formatSourceMarker,\n parseSourceMarker,\n SOURCE_MARKER_ATTRIBUTE,\n type SourceMarker,\n} from \"./model/source-marker.js\";\nexport {\n getAgentJobEndpoint,\n SPOTPATCH_API_BASE,\n SPOTPATCH_ENDPOINTS,\n SPOTPATCH_TOKEN_HEADER,\n type AgentJobAction,\n} from \"./protocol/endpoints.js\";\nexport {\n agentCapabilityRequestSchema,\n agentWorkspaceHealthRequestSchema,\n agentJobActionRequestSchema,\n agentJobCreateRequestSchema,\n openEditorRequestSchema,\n runtimeBootstrapRequestSchema,\n sourceContextRequestSchema,\n spotAnnotationRequestSchema,\n spotTargetContextRequestSchema,\n type AgentCapabilityRequest,\n type AgentJobCreateRequest,\n type OpenEditorRequest,\n type RuntimeBootstrapRequest,\n type SourceContextRequest,\n} from \"./protocol/requests.js\";\nexport type { AgentJobEvent } from \"./protocol/agent-events.js\";\nexport {\n agentCapabilitySnapshotSchema,\n agentWorkspaceHealthSnapshotSchema,\n agentChangedFileSchema,\n agentCheckResultSchema,\n agentJobEventSchema,\n agentJobResultResponseSchema,\n agentJobResultSchema,\n agentJobSnapshotSchema,\n} from \"./protocol/agent-schemas.js\";\nexport type { ApiFailure, ApiResponse, ApiSuccess } from \"./protocol/responses.js\";\nexport { SPOTPATCH_REPOSITORY_URL } from \"./product.js\";\n","import type { ErrorCode } from \"./error-code.js\";\n\nexport class SpotPatchError extends Error {\n readonly code: ErrorCode;\n\n constructor(code: ErrorCode, message = code, options?: ErrorOptions) {\n super(message, options);\n this.name = \"SpotPatchError\";\n this.code = code;\n }\n}\n","export const ERROR_CODES = {\n INVALID_REQUEST: \"INVALID_REQUEST\",\n INVALID_TOKEN: \"INVALID_TOKEN\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n SOURCE_NOT_FOUND: \"SOURCE_NOT_FOUND\",\n SOURCE_OUTSIDE_ROOT: \"SOURCE_OUTSIDE_ROOT\",\n SOURCE_TOO_LARGE: \"SOURCE_TOO_LARGE\",\n EDITOR_OPEN_FAILED: \"EDITOR_OPEN_FAILED\",\n AI_DISABLED: \"AI_DISABLED\",\n PROVIDER_NOT_CONFIGURED: \"PROVIDER_NOT_CONFIGURED\",\n PROVIDER_AUTH_FAILED: \"PROVIDER_AUTH_FAILED\",\n PROVIDER_PROTOCOL_UNSUPPORTED: \"PROVIDER_PROTOCOL_UNSUPPORTED\",\n MODEL_NOT_ALLOWED: \"MODEL_NOT_ALLOWED\",\n MODEL_TOOL_CALL_UNSUPPORTED: \"MODEL_TOOL_CALL_UNSUPPORTED\",\n PROVIDER_RATE_LIMITED: \"PROVIDER_RATE_LIMITED\",\n AGENT_BUSY: \"AGENT_BUSY\",\n AGENT_LIMIT_EXCEEDED: \"AGENT_LIMIT_EXCEEDED\",\n AGENT_CANCELLED: \"AGENT_CANCELLED\",\n WORKTREE_DIRTY: \"WORKTREE_DIRTY\",\n WORKTREE_NOT_REPOSITORY: \"WORKTREE_NOT_REPOSITORY\",\n WORKTREE_OPERATION_IN_PROGRESS: \"WORKTREE_OPERATION_IN_PROGRESS\",\n WORKTREE_CONFLICTED: \"WORKTREE_CONFLICTED\",\n WORKTREE_LOCAL_CHANGES_TOO_LARGE: \"WORKTREE_LOCAL_CHANGES_TOO_LARGE\",\n WORKTREE_UNTRACKED_UNSUPPORTED: \"WORKTREE_UNTRACKED_UNSUPPORTED\",\n WORKTREE_LOCAL_CHANGES_UNSUPPORTED: \"WORKTREE_LOCAL_CHANGES_UNSUPPORTED\",\n TOOL_DENIED: \"TOOL_DENIED\",\n TOOL_INPUT_INVALID: \"TOOL_INPUT_INVALID\",\n TOOL_ARGUMENTS_INVALID: \"TOOL_ARGUMENTS_INVALID\",\n TOOL_CALL_ID_CONFLICT: \"TOOL_CALL_ID_CONFLICT\",\n TOOL_PATH_DENIED: \"TOOL_PATH_DENIED\",\n PATCH_REJECTED: \"PATCH_REJECTED\",\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n APPLY_CONFLICT: \"APPLY_CONFLICT\",\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n","const INLINE_DATA_PATTERN = /data:[^\\s\"'<>]*;base64,[a-z0-9+/_=-]+/giu;\nconst BLOB_URL_PATTERN = /blob:[^\\s\"'<>]+/giu;\nconst BEARER_PATTERN = /\\bbearer\\s+[a-z0-9._~+/-]+=*/giu;\nconst URL_CREDENTIAL_PATTERN = /\\b(https?:\\/\\/)[^/\\s:@]+:[^/\\s@]+@/giu;\nconst SECRET_ASSIGNMENT_PATTERN =\n /\\b(authorization|cookie|set-cookie|api[-_]?key|(?:access[-_]?|refresh[-_]?|auth[-_]?)?token|secret|password|default[-_]?value|value)\\b(\\s*[:=]\\s*)(\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*'|`(?:\\\\.|[^`\\\\\\r\\n])*`|[^\\s,;\"'<>]+)/giu;\nconst SENSITIVE_EXACT_NAMES = new Set([\n \"authorization\",\n \"cookie\",\n \"defaultvalue\",\n \"password\",\n \"setcookie\",\n \"value\",\n]);\nconst MAX_URL_CHARACTERS = 500;\n\nfunction compactName(name: string): string {\n return name.toLowerCase().replaceAll(/[-_:]/gu, \"\");\n}\n\nfunction truncate(value: string, maxCharacters: number): string {\n return value.length <= maxCharacters\n ? value\n : `${value.slice(0, Math.max(0, maxCharacters - 1))}…`;\n}\n\nexport function isSensitiveName(name: string): boolean {\n const compact = compactName(name);\n\n return (\n SENSITIVE_EXACT_NAMES.has(compact) ||\n compact.includes(\"apikey\") ||\n compact.includes(\"authorization\") ||\n compact.includes(\"secret\") ||\n compact.includes(\"token\")\n );\n}\n\nexport function redactSensitiveText(value: string): string {\n return value\n .replace(INLINE_DATA_PATTERN, \"[redacted inline data]\")\n .replace(BLOB_URL_PATTERN, \"[redacted blob URL]\")\n .replace(BEARER_PATTERN, \"Bearer [redacted]\")\n .replace(URL_CREDENTIAL_PATTERN, \"$1[redacted]@\")\n .replace(\n SECRET_ASSIGNMENT_PATTERN,\n (_match, name: string, separator: string, assignedValue: string) => {\n const quote = assignedValue.at(0);\n const quoted = quote === '\"' || quote === \"'\" || quote === \"`\";\n return `${name}${separator}${quoted ? quote : \"\"}[redacted]${quoted ? quote : \"\"}`;\n },\n );\n}\n\nfunction sanitizeParsedUrl(url: URL): string {\n url.username = \"\";\n url.password = \"\";\n\n for (const [name, value] of url.searchParams) {\n if (isSensitiveName(name)) {\n url.searchParams.set(name, \"[redacted]\");\n } else {\n url.searchParams.set(name, redactSensitiveText(value));\n }\n }\n\n if (/token|secret|authorization|api[-_]?key/iu.test(url.hash)) {\n url.hash = \"#[redacted]\";\n }\n\n return url.toString();\n}\n\nexport function sanitizeUrl(value: string, baseUrl: string): string {\n const trimmed = value.trim();\n\n if (/^(?:blob|data|javascript):/iu.test(trimmed)) {\n return \"[redacted URL]\";\n }\n\n const normalized = redactSensitiveText(trimmed);\n\n try {\n const parsed = new URL(normalized, baseUrl);\n const sanitized = sanitizeParsedUrl(parsed);\n const base = new URL(baseUrl);\n\n if (!/^[a-z][a-z\\d+.-]*:/iu.test(normalized) && parsed.origin === base.origin) {\n return `${parsed.pathname}${parsed.search}${parsed.hash}`;\n }\n\n return sanitized;\n } catch {\n return truncate(normalized, MAX_URL_CHARACTERS);\n }\n}\n","import type { CodeContext } from \"./code-context.js\";\nimport type { ReactContext, SourceRef } from \"./source-ref.js\";\nimport type { StyleContext } from \"./style-context.js\";\n\nexport interface PageContext {\n readonly url: string;\n readonly pathname: string;\n readonly title: string;\n readonly viewportWidth: number;\n readonly viewportHeight: number;\n readonly devicePixelRatio: number;\n}\n\nexport interface ElementContext {\n readonly tagName: string;\n readonly selector: string;\n readonly sanitizedHtml: string;\n readonly textPreview?: string;\n readonly role?: string;\n readonly rect: Readonly<{\n x: number;\n y: number;\n width: number;\n height: number;\n }>;\n}\n\n/** Protocol hard limit. Runtime configuration may choose a smaller limit. */\nexport const MAX_ANNOTATION_TARGETS = 20;\n\n/** Each target owns its requested change; the UI enforces the same bound. */\nexport const MAX_TARGET_INSTRUCTION_CHARACTERS = 2_000;\n\n/** Keeps the complete, atomic user intent within the prompt and request budgets. */\nexport const MAX_ANNOTATION_INSTRUCTION_CHARACTERS = 4_000;\n\nexport const SPOTPATCH_LOCALES = Object.freeze([\"en-US\", \"zh-CN\"] as const);\nexport type SpotPatchLocale = (typeof SPOTPATCH_LOCALES)[number];\nexport const SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([\n \"auto\",\n ...SPOTPATCH_LOCALES,\n] as const);\nexport type SpotPatchLocalePreference = (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n\nexport interface SpotTargetContext {\n readonly instruction: string;\n readonly source: SourceRef;\n readonly react: ReactContext;\n readonly element: ElementContext;\n readonly styles: StyleContext;\n readonly code?: CodeContext;\n readonly warnings: readonly string[];\n}\n\nexport interface SpotAnnotation {\n readonly schemaVersion: 3;\n readonly id: string;\n readonly locale: SpotPatchLocale;\n readonly page: Readonly<PageContext>;\n readonly targets: readonly SpotTargetContext[];\n readonly createdAt: string;\n}\n","import { z } from \"zod\";\n\nimport { SPOTPATCH_API_BASE } from \"../protocol/endpoints.js\";\nimport { MAX_ANNOTATION_TARGETS, SPOTPATCH_LOCALE_PREFERENCES } from \"./annotation.js\";\nimport { SPOTPATCH_EDITOR_PREFERENCES } from \"./editor.js\";\nimport type { ContextBudget } from \"./code-context.js\";\nimport type { RuntimeAiConfig } from \"./agent.js\";\n\nexport const SPOTPATCH_NEXT_BUNDLERS = Object.freeze([\"turbopack\", \"webpack\"] as const);\nexport const SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([\n \"app\",\n \"pages\",\n \"hybrid\",\n] as const);\n\nexport type SpotPatchNextBundler = (typeof SPOTPATCH_NEXT_BUNDLERS)[number];\nexport type SpotPatchNextRouterKind = (typeof SPOTPATCH_NEXT_ROUTER_KINDS)[number];\n\ninterface RuntimeConfigBase {\n readonly apiBase: typeof SPOTPATCH_API_BASE;\n readonly ai: RuntimeAiConfig;\n readonly budget: Readonly<ContextBudget>;\n readonly debug: boolean;\n readonly editor: (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n readonly frameworkVersion: string;\n readonly locale: (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n readonly maxTargets: number;\n readonly redact: boolean;\n readonly sessionToken: string;\n readonly shortcut: string;\n readonly spotPatchVersion: string;\n}\n\nexport type SpotPatchRuntimeConfig = RuntimeConfigBase &\n (\n | Readonly<{\n framework: \"vite\";\n }>\n | Readonly<{\n bundler: SpotPatchNextBundler;\n framework: \"next\";\n routerKind: SpotPatchNextRouterKind;\n }>\n );\n\nconst boundedText = (maximum: number): z.ZodString =>\n z.string().trim().min(1).max(maximum);\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);\nconst runtimeAiModelSchema = z.strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n});\nconst runtimeAiProviderSchema = z\n .strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n models: z.array(runtimeAiModelSchema).min(1).max(64),\n defaultModel: profileIdSchema,\n })\n .refine(\n ({ defaultModel, models }) =>\n models.some(({ id }) => id === defaultModel) &&\n new Set(models.map(({ id }) => id)).size === models.length,\n { message: \"Runtime AI model profiles are inconsistent.\" },\n );\nconst runtimeAiConfigSchema = z.discriminatedUnion(\"enabled\", [\n z.strictObject({ enabled: z.literal(false) }),\n z\n .strictObject({\n enabled: z.literal(true),\n providers: z.array(runtimeAiProviderSchema).min(1).max(32),\n defaultProvider: profileIdSchema,\n applyMode: z.enum([\"review\", \"auto\"]),\n })\n .refine(\n ({ defaultProvider, providers }) =>\n providers.some(({ id }) => id === defaultProvider) &&\n new Set(providers.map(({ id }) => id)).size === providers.length,\n { message: \"Runtime AI provider profiles are inconsistent.\" },\n ),\n]);\nconst positiveInteger = z.number().int().positive();\nconst runtimeConfigBaseShape = {\n apiBase: z.literal(SPOTPATCH_API_BASE),\n ai: runtimeAiConfigSchema,\n budget: z.strictObject({\n totalCharacters: positiveInteger,\n domCharacters: positiveInteger,\n cssCharacters: positiveInteger,\n codeCharacters: positiveInteger,\n maxCodeLines: positiveInteger,\n maxComponentDepth: positiveInteger,\n }),\n debug: z.boolean(),\n editor: z.enum(SPOTPATCH_EDITOR_PREFERENCES),\n frameworkVersion: boundedText(64),\n locale: z.enum(SPOTPATCH_LOCALE_PREFERENCES),\n maxTargets: z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),\n redact: z.boolean(),\n sessionToken: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/u),\n shortcut: boundedText(128),\n spotPatchVersion: boundedText(64),\n} as const;\n\nexport const runtimeConfigSchema: z.ZodType<SpotPatchRuntimeConfig> =\n z.discriminatedUnion(\"framework\", [\n z.strictObject({\n ...runtimeConfigBaseShape,\n framework: z.literal(\"vite\"),\n }),\n z.strictObject({\n ...runtimeConfigBaseShape,\n bundler: z.enum(SPOTPATCH_NEXT_BUNDLERS),\n framework: z.literal(\"next\"),\n routerKind: z.enum(SPOTPATCH_NEXT_ROUTER_KINDS),\n }),\n ]);\n","export const SPOTPATCH_API_BASE = \"/__spotpatch/v1\" as const;\nexport const SPOTPATCH_TOKEN_HEADER = \"X-SpotPatch-Token\" as const;\n\nexport const SPOTPATCH_ENDPOINTS = Object.freeze({\n bootstrap: `${SPOTPATCH_API_BASE}/bootstrap`,\n sourceContext: `${SPOTPATCH_API_BASE}/source-context`,\n openEditor: `${SPOTPATCH_API_BASE}/open-editor`,\n agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,\n agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,\n agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`,\n});\n\nexport type AgentJobAction = \"events\" | \"result\" | \"cancel\" | \"apply\" | \"revert\";\n\nexport function getAgentJobEndpoint(jobId: string, action: AgentJobAction): string {\n return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;\n}\n","export const SPOTPATCH_EDITOR_PREFERENCES = [\"auto\", \"vscode\", \"cursor\"] as const;\n\nexport type SpotPatchEditorPreference = (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n\nexport interface EditorOpenResult {\n readonly editor: SpotPatchEditorPreference;\n}\n","import type { ErrorCode } from \"../errors/error-code.js\";\n\nexport type AiProviderProtocol = \"responses\" | \"chat-completions\";\nexport type AiProviderAuthentication = \"bearer\" | \"x-api-key\";\nexport type AgentApplyMode = \"review\" | \"auto\";\nexport type AgentWorkingTreeMode = \"require-clean\" | \"include-local-changes\";\n\nexport interface AiModelProfile {\n readonly label: string;\n readonly model: string;\n}\n\nexport interface OpenAICompatibleProviderOptions {\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication?: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, AiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface AgentCheckDefinition {\n readonly label: string;\n readonly command: string;\n readonly args?: readonly string[];\n readonly required?: boolean;\n readonly timeoutMs?: number;\n}\n\nexport interface AgentLimits {\n readonly maxTurns: number;\n readonly maxToolCalls: number;\n readonly maxChangedFiles: number;\n readonly maxDiffBytes: number;\n readonly maxReadBytesPerFile: number;\n readonly maxToolOutputCharacters: number;\n readonly maxProviderResponseBytes: number;\n readonly providerConnectTimeoutMs: number;\n readonly providerFirstByteTimeoutMs: number;\n readonly providerIdleTimeoutMs: number;\n readonly checkTimeoutMs: number;\n readonly jobTimeoutMs: number;\n}\n\nexport const DEFAULT_AGENT_LIMITS = Object.freeze({\n maxTurns: 20,\n maxToolCalls: 80,\n maxChangedFiles: 20,\n maxDiffBytes: 512_000,\n maxReadBytesPerFile: 256_000,\n maxToolOutputCharacters: 40_000,\n maxProviderResponseBytes: 2_000_000,\n providerConnectTimeoutMs: 15_000,\n providerFirstByteTimeoutMs: 30_000,\n providerIdleTimeoutMs: 60_000,\n checkTimeoutMs: 120_000,\n jobTimeoutMs: 600_000,\n} satisfies AgentLimits);\n\nexport interface AiExecutionOptions {\n readonly isolation?: \"git-worktree\";\n readonly applyMode?: AgentApplyMode;\n readonly checks?: Readonly<Record<string, AgentCheckDefinition>>;\n readonly limits?: Partial<AgentLimits>;\n}\n\nexport interface AiOptions {\n readonly providers: Readonly<Record<string, OpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution?: AiExecutionOptions;\n}\n\nexport interface ResolvedAiModelProfile extends AiModelProfile {\n readonly id: string;\n}\n\nexport interface ResolvedOpenAICompatibleProviderOptions {\n readonly id: string;\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, ResolvedAiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface ResolvedAgentCheckDefinition {\n readonly id: string;\n readonly label: string;\n readonly command: string;\n readonly args: readonly string[];\n readonly required: boolean;\n readonly timeoutMs: number;\n}\n\nexport interface ResolvedAiExecutionOptions {\n readonly isolation: \"git-worktree\";\n readonly applyMode: AgentApplyMode;\n readonly checks: Readonly<Record<string, ResolvedAgentCheckDefinition>>;\n readonly limits: Readonly<AgentLimits>;\n}\n\nexport interface ResolvedAiOptions {\n readonly providers: Readonly<Record<string, ResolvedOpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution: ResolvedAiExecutionOptions;\n}\n\nexport interface RuntimeAiModelProfile {\n readonly id: string;\n readonly label: string;\n}\n\nexport interface RuntimeAiProviderProfile {\n readonly id: string;\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly models: readonly RuntimeAiModelProfile[];\n readonly defaultModel: string;\n}\n\nexport type RuntimeAiConfig =\n | Readonly<{ enabled: false }>\n | Readonly<{\n enabled: true;\n providers: readonly RuntimeAiProviderProfile[];\n defaultProvider: string;\n applyMode: AgentApplyMode;\n }>;\n\nexport const AGENT_JOB_STATUSES = Object.freeze([\n \"queued\",\n \"preparing\",\n \"running\",\n \"validating\",\n \"awaiting-review\",\n \"applying\",\n \"applied\",\n \"completed\",\n \"cancelling\",\n \"cancelled\",\n \"reverting\",\n \"reverted\",\n \"failed\",\n] as const);\n\nexport type AgentJobStatus = (typeof AGENT_JOB_STATUSES)[number];\n\nexport const AGENT_CAPABILITY_STATES = Object.freeze([\n \"unknown\",\n \"probing\",\n \"agent-ready\",\n \"prompt-only\",\n \"unavailable\",\n] as const);\n\nexport type AgentCapabilityState = (typeof AGENT_CAPABILITY_STATES)[number];\n\nexport interface AgentCapabilitySnapshot {\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly protocol: AiProviderProtocol;\n readonly state: AgentCapabilityState;\n readonly authenticated: boolean;\n readonly modelAvailable: boolean;\n readonly toolCalling: boolean;\n readonly toolResultContinuation: boolean;\n readonly streaming: boolean;\n readonly checkedAt?: string;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_WORKSPACE_STATES = Object.freeze([\n \"ready\",\n \"consent-required\",\n \"blocked\",\n] as const);\n\nexport const AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({\n maxUntrackedFiles: 1_000,\n maxUntrackedBytes: 20 * 1024 * 1024,\n});\n\nexport type AgentWorkspaceState = (typeof AGENT_WORKSPACE_STATES)[number];\n\nexport interface AgentWorkspaceChangeSummary {\n readonly staged: number;\n readonly unstaged: number;\n readonly untracked: number;\n readonly conflicted: number;\n readonly total: number;\n}\n\nexport interface AgentWorkspaceHealthSnapshot {\n readonly state: AgentWorkspaceState;\n readonly checkedAt: string;\n readonly changes: AgentWorkspaceChangeSummary;\n readonly canIncludeLocalChanges: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_FILE_CHANGE_KINDS = Object.freeze([\n \"added\",\n \"modified\",\n \"deleted\",\n] as const);\n\nexport type AgentFileChangeKind = (typeof AGENT_FILE_CHANGE_KINDS)[number];\n\nexport const AGENT_CHECK_STATUSES = Object.freeze([\n \"passed\",\n \"failed\",\n \"cancelled\",\n \"timed-out\",\n] as const);\n\nexport type AgentCheckStatus = (typeof AGENT_CHECK_STATUSES)[number];\n\nexport interface AgentChangedFile {\n readonly relativePath: string;\n readonly kind: AgentFileChangeKind;\n readonly additions: number;\n readonly deletions: number;\n}\n\nexport interface AgentCheckResult {\n readonly checkId: string;\n readonly label: string;\n readonly status: AgentCheckStatus;\n readonly durationMs: number;\n readonly output: string;\n}\n\nexport interface AgentJobSnapshot {\n readonly jobId: string;\n readonly status: AgentJobStatus;\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly phaseMessage: string;\n readonly createdAt: string;\n readonly updatedAt: string;\n readonly canCancel: boolean;\n readonly canApply: boolean;\n readonly canRevert: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport interface AgentJobResult {\n readonly jobId: string;\n readonly summary: string;\n readonly diff: string;\n readonly files: readonly AgentChangedFile[];\n readonly checks: readonly AgentCheckResult[];\n}\n\nexport interface AgentJobResultResponse {\n readonly snapshot: AgentJobSnapshot;\n readonly result?: AgentJobResult;\n}\n","export const SOURCE_MARKER_ATTRIBUTE = \"data-spotpatch-source\" as const;\n\nconst SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\\d*):([1-9]\\d*)$/;\n\nexport interface SourceMarker {\n readonly fileId: string;\n readonly line: number;\n readonly column: number;\n}\n\nexport function formatSourceMarker(marker: SourceMarker): string {\n return [marker.fileId, String(marker.line), String(marker.column)].join(\":\");\n}\n\nexport function parseSourceMarker(value: string | null): SourceMarker | undefined {\n if (value === null) {\n return undefined;\n }\n\n const match = SOURCE_MARKER_PATTERN.exec(value);\n\n if (match === null) {\n return undefined;\n }\n\n const fileId = match[1];\n const line = Number(match[2]);\n const column = Number(match[3]);\n\n if (\n fileId === undefined ||\n !Number.isSafeInteger(line) ||\n !Number.isSafeInteger(column)\n ) {\n return undefined;\n }\n\n return Object.freeze({ fileId, line, column });\n}\n","import { z } from \"zod\";\n\nimport {\n MAX_ANNOTATION_INSTRUCTION_CHARACTERS,\n MAX_ANNOTATION_TARGETS,\n MAX_TARGET_INSTRUCTION_CHARACTERS,\n SPOTPATCH_LOCALES,\n type SpotAnnotation,\n} from \"../model/annotation.js\";\n\nexport const runtimeBootstrapRequestSchema = z.strictObject({});\n\nconst sourceCoordinatesSchema = z.strictObject({\n fileId: z.string().min(1).max(128),\n line: z.number().int().positive(),\n column: z.number().int().positive(),\n});\n\nexport const sourceContextRequestSchema = sourceCoordinatesSchema\n .extend({\n maxLines: z.number().int().positive(),\n })\n .strict();\n\nexport const openEditorRequestSchema = sourceCoordinatesSchema.strict();\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\n\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst sourceRefSchema = z.strictObject({\n fileId: boundedString(128).optional(),\n relativePath: boundedString(1_024).optional(),\n line: z.number().int().positive().optional(),\n column: z.number().int().positive().optional(),\n origin: z.enum([\"jsx-host\", \"react-fiber\", \"dom-ancestor\", \"none\"]),\n confidence: z.enum([\"exact\", \"probable\", \"approximate\", \"unknown\"]),\n});\nconst matchedStyleRuleSchema = z.strictObject({\n selector: boundedString(2_048),\n declarations: boundedString(8_192),\n source: boundedString(1_024).optional(),\n media: boundedString(1_024).optional(),\n});\nconst codeContextSchema = z.strictObject({\n relativePath: boundedString(1_024),\n language: z.enum([\"tsx\", \"jsx\"]),\n startLine: z.number().int().positive(),\n endLine: z.number().int().positive(),\n excerpt: boundedString(16_000),\n boundary: z.enum([\"component\", \"nearby-lines\"]),\n});\n\nexport const spotTargetContextRequestSchema = z.strictObject({\n instruction: z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),\n source: sourceRefSchema,\n react: z.strictObject({\n supported: z.boolean(),\n version: boundedString(64).optional(),\n componentName: boundedString(256).optional(),\n componentStack: z.array(boundedString(256)).max(64),\n source: sourceRefSchema.optional(),\n }),\n element: z.strictObject({\n tagName: boundedString(128),\n selector: boundedString(2_048),\n sanitizedHtml: boundedString(8_192),\n textPreview: boundedString(2_048).optional(),\n role: boundedString(256).optional(),\n rect: z.strictObject({\n x: z.number(),\n y: z.number(),\n width: z.number().nonnegative(),\n height: z.number().nonnegative(),\n }),\n }),\n styles: z.strictObject({\n classNames: z.array(boundedString(512)).max(256),\n inlineStyle: boundedString(8_192).optional(),\n matchedRules: z.array(matchedStyleRuleSchema).max(256),\n computed: z.record(boundedString(256), boundedString(2_048)),\n warnings: z.array(boundedString(1_024)).max(64),\n }),\n code: codeContextSchema.optional(),\n warnings: z.array(boundedString(1_024)).max(64),\n});\n\nexport const spotAnnotationRequestSchema = z\n .strictObject({\n schemaVersion: z.literal(3),\n id: boundedString(128),\n locale: z.enum(SPOTPATCH_LOCALES),\n page: z.strictObject({\n url: boundedString(2_048),\n pathname: boundedString(2_048),\n title: boundedString(1_024),\n viewportWidth: z.number().nonnegative(),\n viewportHeight: z.number().nonnegative(),\n devicePixelRatio: z.number().positive(),\n }),\n targets: z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),\n createdAt: z.iso.datetime(),\n })\n .superRefine((annotation, context) => {\n const total = annotation.targets.reduce(\n (characters, target) => characters + target.instruction.length,\n 0,\n );\n\n if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {\n context.addIssue({\n code: \"custom\",\n message: \"Combined target instructions exceed the annotation limit.\",\n path: [\"targets\"],\n });\n }\n });\n\nexport const agentCapabilityRequestSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n});\n\nexport const agentWorkspaceHealthRequestSchema = z.strictObject({});\n\nexport const agentJobCreateRequestSchema = z.strictObject({\n annotation: spotAnnotationRequestSchema,\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n providerDataConsent: z.literal(true),\n workingTreeMode: z\n .enum([\"require-clean\", \"include-local-changes\"])\n .default(\"require-clean\"),\n});\n\nexport const agentJobActionRequestSchema = z.strictObject({});\n\nexport type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;\nexport type RuntimeBootstrapRequest = z.infer<typeof runtimeBootstrapRequestSchema>;\nexport type OpenEditorRequest = z.infer<typeof openEditorRequestSchema>;\nexport type AgentCapabilityRequest = z.infer<typeof agentCapabilityRequestSchema>;\nexport interface AgentJobCreateRequest {\n readonly annotation: SpotAnnotation;\n readonly providerProfileId: string;\n readonly modelProfileId: string;\n readonly providerDataConsent: true;\n readonly workingTreeMode: \"require-clean\" | \"include-local-changes\";\n}\n","import { z } from \"zod\";\n\nimport { ERROR_CODES } from \"../errors/error-code.js\";\nimport {\n AGENT_CAPABILITY_STATES,\n AGENT_CHECK_STATUSES,\n AGENT_FILE_CHANGE_KINDS,\n AGENT_JOB_STATUSES,\n AGENT_WORKSPACE_STATES,\n} from \"../model/agent.js\";\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst errorCodeSchema = z.enum(ERROR_CODES);\n\nexport const agentCapabilitySnapshotSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n state: z.enum(AGENT_CAPABILITY_STATES),\n authenticated: z.boolean(),\n modelAvailable: z.boolean(),\n toolCalling: z.boolean(),\n toolResultContinuation: z.boolean(),\n streaming: z.boolean(),\n checkedAt: z.iso.datetime().optional(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentWorkspaceHealthSnapshotSchema = z\n .strictObject({\n state: z.enum(AGENT_WORKSPACE_STATES),\n checkedAt: z.iso.datetime(),\n changes: z.strictObject({\n staged: z.number().int().nonnegative(),\n unstaged: z.number().int().nonnegative(),\n untracked: z.number().int().nonnegative(),\n conflicted: z.number().int().nonnegative(),\n total: z.number().int().nonnegative(),\n }),\n canIncludeLocalChanges: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n })\n .refine(\n ({ state, changes, canIncludeLocalChanges, errorCode }) => {\n const countsAreConsistent =\n changes.total >= changes.staged &&\n changes.total >= changes.unstaged &&\n changes.total >= changes.untracked &&\n changes.total >= changes.conflicted &&\n changes.total <= changes.staged + changes.unstaged + changes.untracked;\n\n if (!countsAreConsistent) {\n return false;\n }\n\n if (state === \"ready\") {\n return (\n changes.total === 0 && !canIncludeLocalChanges && errorCode === undefined\n );\n }\n\n if (state === \"consent-required\") {\n return (\n changes.total > 0 &&\n changes.conflicted === 0 &&\n canIncludeLocalChanges &&\n errorCode === undefined\n );\n }\n\n return !canIncludeLocalChanges && errorCode !== undefined;\n },\n { message: \"Agent workspace health fields are inconsistent.\" },\n );\n\nexport const agentChangedFileSchema = z.strictObject({\n relativePath: boundedString(1_024),\n kind: z.enum(AGENT_FILE_CHANGE_KINDS),\n additions: z.number().int().nonnegative(),\n deletions: z.number().int().nonnegative(),\n});\n\nexport const agentCheckResultSchema = z.strictObject({\n checkId: profileIdSchema,\n label: boundedString(100),\n status: z.enum(AGENT_CHECK_STATUSES),\n durationMs: z.number().int().nonnegative(),\n output: boundedString(80_000),\n});\n\nexport const agentJobSnapshotSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n phaseMessage: boundedString(1_024),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n canCancel: z.boolean(),\n canApply: z.boolean(),\n canRevert: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentJobResultSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n summary: boundedString(80_000),\n diff: boundedString(1_000_000),\n files: z.array(agentChangedFileSchema).max(100),\n checks: z.array(agentCheckResultSchema).max(100),\n});\n\nexport const agentJobResultResponseSchema = z\n .strictObject({\n snapshot: agentJobSnapshotSchema,\n result: agentJobResultSchema.optional(),\n })\n .superRefine((value, context) => {\n if (value.result !== undefined && value.result.jobId !== value.snapshot.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent result and snapshot job IDs must match.\",\n path: [\"result\", \"jobId\"],\n });\n }\n });\n\nconst agentJobEventBaseSchema = z.strictObject({\n schemaVersion: z.literal(2),\n sequence: z.number().int().positive(),\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n timestamp: z.iso.datetime(),\n});\n\nexport const agentJobEventSchema = z\n .discriminatedUnion(\"type\", [\n agentJobEventBaseSchema.extend({\n type: z.literal(\"snapshot\"),\n data: z.strictObject({ snapshot: agentJobSnapshotSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"phase\"),\n data: z.strictObject({ message: boundedString(1_024) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"tool\"),\n data: z.strictObject({\n turn: z.number().int().positive(),\n toolCallId: boundedString(256),\n toolName: boundedString(100),\n state: z.enum([\"started\", \"succeeded\", \"failed\"]),\n relativePath: boundedString(1_024).optional(),\n checkLabel: boundedString(100).optional(),\n }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"check\"),\n data: z.strictObject({ result: agentCheckResultSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"result-ready\"),\n data: z.strictObject({ hasResult: z.literal(true) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"error\"),\n data: z.strictObject({\n code: errorCodeSchema,\n message: boundedString(1_024),\n }),\n }),\n ])\n .superRefine((event, context) => {\n if (event.type !== \"snapshot\") {\n return;\n }\n\n if (event.data.snapshot.jobId !== event.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot job IDs must match.\",\n path: [\"data\", \"snapshot\", \"jobId\"],\n });\n }\n\n if (event.data.snapshot.status !== event.status) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot statuses must match.\",\n path: [\"data\", \"snapshot\", \"status\"],\n });\n }\n });\n","export const SPOTPATCH_REPOSITORY_URL =\n \"https://github.com/huanglvjing/spotpatch\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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EACD,wBAAwB,OAAO;AAAA,IAC7B,MAAM,cAAE,QAAQ,OAAO;AAAA,IACvB,MAAM,cAAE,aAAa,EAAE,QAAQ,uBAAuB,CAAC;AAAA,EACzD,CAAC;AAAA,EACD,wBAAwB,OAAO;AAAA,IAC7B,MAAM,cAAE,QAAQ,cAAc;AAAA,IAC9B,MAAM,cAAE,aAAa,EAAE,WAAW,cAAE,QAAQ,IAAI,EAAE,CAAC;AAAA,EACrD,CAAC;AAAA,EACD,wBAAwB,OAAO;AAAA,IAC7B,MAAM,cAAE,QAAQ,OAAO;AAAA,IACvB,MAAM,cAAE,aAAa;AAAA,MACnB,MAAM;AAAA,MACN,SAASA,eAAc,IAAK;AAAA,IAC9B,CAAC;AAAA,EACH,CAAC;AACH,CAAC,EACA,YAAY,CAAC,OAAO,YAAY;AAC/B,MAAI,MAAM,SAAS,YAAY;AAC7B;AAAA,EACF;AAEA,MAAI,MAAM,KAAK,SAAS,UAAU,MAAM,OAAO;AAC7C,YAAQ,SAAS;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM,CAAC,QAAQ,YAAY,OAAO;AAAA,IACpC,CAAC;AAAA,EACH;AAEA,MAAI,MAAM,KAAK,SAAS,WAAW,MAAM,QAAQ;AAC/C,YAAQ,SAAS;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM,CAAC,QAAQ,YAAY,QAAQ;AAAA,IACrC,CAAC;AAAA,EACH;AACF,CAAC;;;ACrNI,IAAM,2BACX;","names":["import_zod","profileIdSchema","import_zod","profileIdSchema","boundedString"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors/spotpatch-error.ts","../src/errors/error-code.ts","../src/security/redaction.ts","../src/model/annotation.ts","../src/model/runtime-config.ts","../src/protocol/endpoints.ts","../src/model/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/requests.ts","../src/protocol/agent-schemas.ts","../src/product.ts"],"sourcesContent":["export { SpotPatchError } from \"./errors/spotpatch-error.js\";\nexport { ERROR_CODES, type ErrorCode } from \"./errors/error-code.js\";\nexport {\n isSensitiveName,\n redactSensitiveText,\n sanitizeUrl,\n} from \"./security/redaction.js\";\nexport {\n MAX_ANNOTATION_INSTRUCTION_CHARACTERS,\n MAX_ANNOTATION_TARGETS,\n MAX_TARGET_INSTRUCTION_CHARACTERS,\n SPOTPATCH_LOCALE_PREFERENCES,\n SPOTPATCH_LOCALES,\n type ElementContext,\n type PageContext,\n type SpotAnnotation,\n type SpotPatchLocale,\n type SpotPatchLocalePreference,\n type SpotTargetContext,\n} from \"./model/annotation.js\";\nexport type { CodeContext, ContextBudget } from \"./model/code-context.js\";\nexport {\n runtimeConfigSchema,\n SPOTPATCH_NEXT_BUNDLERS,\n SPOTPATCH_NEXT_ROUTER_KINDS,\n type SpotPatchNextBundler,\n type SpotPatchNextRouterKind,\n type SpotPatchRuntimeConfig,\n} from \"./model/runtime-config.js\";\nexport {\n SPOTPATCH_EDITOR_PREFERENCES,\n type EditorOpenResult,\n type SpotPatchEditorPreference,\n} from \"./model/editor.js\";\nexport {\n AGENT_APPLY_MODES,\n AGENT_CAPABILITY_STATES,\n AGENT_CHECK_STATUSES,\n AGENT_FILE_CHANGE_KINDS,\n AGENT_JOB_STATUSES,\n AGENT_WORKSPACE_SNAPSHOT_LIMITS,\n AGENT_WORKSPACE_STATES,\n DEFAULT_AGENT_LIMITS,\n type AgentApplyMode,\n type AgentCapabilitySnapshot,\n type AgentCapabilityState,\n type AgentChangedFile,\n type AgentCheckDefinition,\n type AgentCheckResult,\n type AgentCheckStatus,\n type AgentFileChangeKind,\n type AgentJobResult,\n type AgentJobResultResponse,\n type AgentJobSnapshot,\n type AgentJobStatus,\n type AgentWorkingTreeMode,\n type AgentWorkspaceChangeSummary,\n type AgentWorkspaceHealthSnapshot,\n type AgentWorkspaceState,\n type AgentLimits,\n type AiExecutionOptions,\n type AiModelProfile,\n type AiOptions,\n type AiProviderAuthentication,\n type AiProviderProtocol,\n type OpenAICompatibleProviderOptions,\n type ResolvedAgentCheckDefinition,\n type ResolvedAiExecutionOptions,\n type ResolvedAiModelProfile,\n type ResolvedAiOptions,\n type ResolvedOpenAICompatibleProviderOptions,\n type RuntimeAiConfig,\n type RuntimeAiModelProfile,\n type RuntimeAiProviderProfile,\n} from \"./model/agent.js\";\nexport type {\n ReactContext,\n SourceConfidence,\n SourceOrigin,\n SourceRef,\n} from \"./model/source-ref.js\";\nexport type { MatchedStyleRule, StyleContext } from \"./model/style-context.js\";\nexport {\n formatSourceMarker,\n parseSourceMarker,\n SOURCE_MARKER_ATTRIBUTE,\n type SourceMarker,\n} from \"./model/source-marker.js\";\nexport {\n getAgentJobEndpoint,\n SPOTPATCH_API_BASE,\n SPOTPATCH_ENDPOINTS,\n SPOTPATCH_TOKEN_HEADER,\n type AgentJobAction,\n} from \"./protocol/endpoints.js\";\nexport {\n agentCapabilityRequestSchema,\n agentWorkspaceHealthRequestSchema,\n agentJobActionRequestSchema,\n agentJobCreateRequestSchema,\n openEditorRequestSchema,\n runtimeBootstrapRequestSchema,\n sourceContextRequestSchema,\n spotAnnotationRequestSchema,\n spotTargetContextRequestSchema,\n type AgentCapabilityRequest,\n type AgentJobCreateRequest,\n type OpenEditorRequest,\n type RuntimeBootstrapRequest,\n type SourceContextRequest,\n} from \"./protocol/requests.js\";\nexport type { AgentJobEvent } from \"./protocol/agent-events.js\";\nexport {\n agentCapabilitySnapshotSchema,\n agentWorkspaceHealthSnapshotSchema,\n agentChangedFileSchema,\n agentCheckResultSchema,\n agentJobEventSchema,\n agentJobResultResponseSchema,\n agentJobResultSchema,\n agentJobSnapshotSchema,\n} from \"./protocol/agent-schemas.js\";\nexport type { ApiFailure, ApiResponse, ApiSuccess } from \"./protocol/responses.js\";\nexport { SPOTPATCH_REPOSITORY_URL } from \"./product.js\";\n","import type { ErrorCode } from \"./error-code.js\";\n\nexport class SpotPatchError extends Error {\n readonly code: ErrorCode;\n\n constructor(code: ErrorCode, message = code, options?: ErrorOptions) {\n super(message, options);\n this.name = \"SpotPatchError\";\n this.code = code;\n }\n}\n","export const ERROR_CODES = {\n INVALID_REQUEST: \"INVALID_REQUEST\",\n INVALID_TOKEN: \"INVALID_TOKEN\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n SOURCE_NOT_FOUND: \"SOURCE_NOT_FOUND\",\n SOURCE_OUTSIDE_ROOT: \"SOURCE_OUTSIDE_ROOT\",\n SOURCE_TOO_LARGE: \"SOURCE_TOO_LARGE\",\n EDITOR_OPEN_FAILED: \"EDITOR_OPEN_FAILED\",\n AI_DISABLED: \"AI_DISABLED\",\n PROVIDER_NOT_CONFIGURED: \"PROVIDER_NOT_CONFIGURED\",\n PROVIDER_AUTH_FAILED: \"PROVIDER_AUTH_FAILED\",\n PROVIDER_PROTOCOL_UNSUPPORTED: \"PROVIDER_PROTOCOL_UNSUPPORTED\",\n MODEL_NOT_ALLOWED: \"MODEL_NOT_ALLOWED\",\n MODEL_TOOL_CALL_UNSUPPORTED: \"MODEL_TOOL_CALL_UNSUPPORTED\",\n PROVIDER_RATE_LIMITED: \"PROVIDER_RATE_LIMITED\",\n AGENT_BUSY: \"AGENT_BUSY\",\n AGENT_LIMIT_EXCEEDED: \"AGENT_LIMIT_EXCEEDED\",\n AGENT_CANCELLED: \"AGENT_CANCELLED\",\n WORKTREE_DIRTY: \"WORKTREE_DIRTY\",\n WORKTREE_NOT_REPOSITORY: \"WORKTREE_NOT_REPOSITORY\",\n WORKTREE_OPERATION_IN_PROGRESS: \"WORKTREE_OPERATION_IN_PROGRESS\",\n WORKTREE_CONFLICTED: \"WORKTREE_CONFLICTED\",\n WORKTREE_LOCAL_CHANGES_TOO_LARGE: \"WORKTREE_LOCAL_CHANGES_TOO_LARGE\",\n WORKTREE_UNTRACKED_UNSUPPORTED: \"WORKTREE_UNTRACKED_UNSUPPORTED\",\n WORKTREE_LOCAL_CHANGES_UNSUPPORTED: \"WORKTREE_LOCAL_CHANGES_UNSUPPORTED\",\n TOOL_DENIED: \"TOOL_DENIED\",\n TOOL_INPUT_INVALID: \"TOOL_INPUT_INVALID\",\n TOOL_ARGUMENTS_INVALID: \"TOOL_ARGUMENTS_INVALID\",\n TOOL_CALL_ID_CONFLICT: \"TOOL_CALL_ID_CONFLICT\",\n TOOL_PATH_DENIED: \"TOOL_PATH_DENIED\",\n PATCH_REJECTED: \"PATCH_REJECTED\",\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n APPLY_CONFLICT: \"APPLY_CONFLICT\",\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n","const INLINE_DATA_PATTERN = /data:[^\\s\"'<>]*;base64,[a-z0-9+/_=-]+/giu;\nconst BLOB_URL_PATTERN = /blob:[^\\s\"'<>]+/giu;\nconst BEARER_PATTERN = /\\bbearer\\s+[a-z0-9._~+/-]+=*/giu;\nconst URL_CREDENTIAL_PATTERN = /\\b(https?:\\/\\/)[^/\\s:@]+:[^/\\s@]+@/giu;\nconst SECRET_ASSIGNMENT_PATTERN =\n /\\b(authorization|cookie|set-cookie|api[-_]?key|(?:access[-_]?|refresh[-_]?|auth[-_]?)?token|secret|password|default[-_]?value|value)\\b(\\s*[:=]\\s*)(\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*'|`(?:\\\\.|[^`\\\\\\r\\n])*`|[^\\s,;\"'<>]+)/giu;\nconst SENSITIVE_EXACT_NAMES = new Set([\n \"authorization\",\n \"cookie\",\n \"defaultvalue\",\n \"password\",\n \"setcookie\",\n \"value\",\n]);\nconst MAX_URL_CHARACTERS = 500;\n\nfunction compactName(name: string): string {\n return name.toLowerCase().replaceAll(/[-_:]/gu, \"\");\n}\n\nfunction truncate(value: string, maxCharacters: number): string {\n return value.length <= maxCharacters\n ? value\n : `${value.slice(0, Math.max(0, maxCharacters - 1))}…`;\n}\n\nexport function isSensitiveName(name: string): boolean {\n const compact = compactName(name);\n\n return (\n SENSITIVE_EXACT_NAMES.has(compact) ||\n compact.includes(\"apikey\") ||\n compact.includes(\"authorization\") ||\n compact.includes(\"secret\") ||\n compact.includes(\"token\")\n );\n}\n\nexport function redactSensitiveText(value: string): string {\n return value\n .replace(INLINE_DATA_PATTERN, \"[redacted inline data]\")\n .replace(BLOB_URL_PATTERN, \"[redacted blob URL]\")\n .replace(BEARER_PATTERN, \"Bearer [redacted]\")\n .replace(URL_CREDENTIAL_PATTERN, \"$1[redacted]@\")\n .replace(\n SECRET_ASSIGNMENT_PATTERN,\n (_match, name: string, separator: string, assignedValue: string) => {\n const quote = assignedValue.at(0);\n const quoted = quote === '\"' || quote === \"'\" || quote === \"`\";\n return `${name}${separator}${quoted ? quote : \"\"}[redacted]${quoted ? quote : \"\"}`;\n },\n );\n}\n\nfunction sanitizeParsedUrl(url: URL): string {\n url.username = \"\";\n url.password = \"\";\n\n for (const [name, value] of url.searchParams) {\n if (isSensitiveName(name)) {\n url.searchParams.set(name, \"[redacted]\");\n } else {\n url.searchParams.set(name, redactSensitiveText(value));\n }\n }\n\n if (/token|secret|authorization|api[-_]?key/iu.test(url.hash)) {\n url.hash = \"#[redacted]\";\n }\n\n return url.toString();\n}\n\nexport function sanitizeUrl(value: string, baseUrl: string): string {\n const trimmed = value.trim();\n\n if (/^(?:blob|data|javascript):/iu.test(trimmed)) {\n return \"[redacted URL]\";\n }\n\n const normalized = redactSensitiveText(trimmed);\n\n try {\n const parsed = new URL(normalized, baseUrl);\n const sanitized = sanitizeParsedUrl(parsed);\n const base = new URL(baseUrl);\n\n if (!/^[a-z][a-z\\d+.-]*:/iu.test(normalized) && parsed.origin === base.origin) {\n return `${parsed.pathname}${parsed.search}${parsed.hash}`;\n }\n\n return sanitized;\n } catch {\n return truncate(normalized, MAX_URL_CHARACTERS);\n }\n}\n","import type { CodeContext } from \"./code-context.js\";\nimport type { ReactContext, SourceRef } from \"./source-ref.js\";\nimport type { StyleContext } from \"./style-context.js\";\n\nexport interface PageContext {\n readonly url: string;\n readonly pathname: string;\n readonly title: string;\n readonly viewportWidth: number;\n readonly viewportHeight: number;\n readonly devicePixelRatio: number;\n}\n\nexport interface ElementContext {\n readonly tagName: string;\n readonly selector: string;\n readonly sanitizedHtml: string;\n readonly textPreview?: string;\n readonly role?: string;\n readonly rect: Readonly<{\n x: number;\n y: number;\n width: number;\n height: number;\n }>;\n}\n\n/** Protocol hard limit. Runtime configuration may choose a smaller limit. */\nexport const MAX_ANNOTATION_TARGETS = 20;\n\n/** Each target owns its requested change; the UI enforces the same bound. */\nexport const MAX_TARGET_INSTRUCTION_CHARACTERS = 2_000;\n\n/** Keeps the complete, atomic user intent within the prompt and request budgets. */\nexport const MAX_ANNOTATION_INSTRUCTION_CHARACTERS = 4_000;\n\nexport const SPOTPATCH_LOCALES = Object.freeze([\"en-US\", \"zh-CN\"] as const);\nexport type SpotPatchLocale = (typeof SPOTPATCH_LOCALES)[number];\nexport const SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([\n \"auto\",\n ...SPOTPATCH_LOCALES,\n] as const);\nexport type SpotPatchLocalePreference = (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n\nexport interface SpotTargetContext {\n readonly instruction: string;\n readonly page?: Readonly<PageContext>;\n readonly source: SourceRef;\n readonly react: ReactContext;\n readonly element: ElementContext;\n readonly styles: StyleContext;\n readonly code?: CodeContext;\n readonly warnings: readonly string[];\n}\n\nexport interface SpotAnnotation {\n readonly schemaVersion: 3;\n readonly id: string;\n readonly locale: SpotPatchLocale;\n readonly page: Readonly<PageContext>;\n readonly targets: readonly SpotTargetContext[];\n readonly createdAt: string;\n}\n","import { z } from \"zod\";\n\nimport { SPOTPATCH_API_BASE } from \"../protocol/endpoints.js\";\nimport { MAX_ANNOTATION_TARGETS, SPOTPATCH_LOCALE_PREFERENCES } from \"./annotation.js\";\nimport { SPOTPATCH_EDITOR_PREFERENCES } from \"./editor.js\";\nimport type { ContextBudget } from \"./code-context.js\";\nimport { AGENT_APPLY_MODES, type RuntimeAiConfig } from \"./agent.js\";\n\nexport const SPOTPATCH_NEXT_BUNDLERS = Object.freeze([\"turbopack\", \"webpack\"] as const);\nexport const SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([\n \"app\",\n \"pages\",\n \"hybrid\",\n] as const);\n\nexport type SpotPatchNextBundler = (typeof SPOTPATCH_NEXT_BUNDLERS)[number];\nexport type SpotPatchNextRouterKind = (typeof SPOTPATCH_NEXT_ROUTER_KINDS)[number];\n\ninterface RuntimeConfigBase {\n readonly apiBase: typeof SPOTPATCH_API_BASE;\n readonly ai: RuntimeAiConfig;\n readonly budget: Readonly<ContextBudget>;\n readonly debug: boolean;\n readonly editor: (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n readonly frameworkVersion: string;\n readonly locale: (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n readonly maxTargets: number;\n readonly redact: boolean;\n readonly sessionId: string;\n readonly sessionToken: string;\n readonly shortcut: string;\n readonly spotPatchVersion: string;\n}\n\nexport type SpotPatchRuntimeConfig = RuntimeConfigBase &\n (\n | Readonly<{\n framework: \"vite\";\n }>\n | Readonly<{\n bundler: SpotPatchNextBundler;\n framework: \"next\";\n routerKind: SpotPatchNextRouterKind;\n }>\n );\n\nconst boundedText = (maximum: number): z.ZodString =>\n z.string().trim().min(1).max(maximum);\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);\nconst runtimeAiModelSchema = z.strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n});\nconst runtimeAiProviderSchema = z\n .strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n models: z.array(runtimeAiModelSchema).min(1).max(64),\n defaultModel: profileIdSchema,\n })\n .refine(\n ({ defaultModel, models }) =>\n models.some(({ id }) => id === defaultModel) &&\n new Set(models.map(({ id }) => id)).size === models.length,\n { message: \"Runtime AI model profiles are inconsistent.\" },\n );\nconst runtimeAiConfigSchema = z.discriminatedUnion(\"enabled\", [\n z.strictObject({ enabled: z.literal(false) }),\n z\n .strictObject({\n enabled: z.literal(true),\n providers: z.array(runtimeAiProviderSchema).min(1).max(32),\n defaultProvider: profileIdSchema,\n applyMode: z.enum(AGENT_APPLY_MODES),\n })\n .refine(\n ({ defaultProvider, providers }) =>\n providers.some(({ id }) => id === defaultProvider) &&\n new Set(providers.map(({ id }) => id)).size === providers.length,\n { message: \"Runtime AI provider profiles are inconsistent.\" },\n ),\n]);\nconst positiveInteger = z.number().int().positive();\nconst runtimeConfigBaseShape = {\n apiBase: z.literal(SPOTPATCH_API_BASE),\n ai: runtimeAiConfigSchema,\n budget: z.strictObject({\n totalCharacters: positiveInteger,\n domCharacters: positiveInteger,\n cssCharacters: positiveInteger,\n codeCharacters: positiveInteger,\n maxCodeLines: positiveInteger,\n maxComponentDepth: positiveInteger,\n }),\n debug: z.boolean(),\n editor: z.enum(SPOTPATCH_EDITOR_PREFERENCES),\n frameworkVersion: boundedText(64),\n locale: z.enum(SPOTPATCH_LOCALE_PREFERENCES),\n maxTargets: z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),\n redact: z.boolean(),\n sessionId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/u),\n sessionToken: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/u),\n shortcut: boundedText(128),\n spotPatchVersion: boundedText(64),\n} as const;\n\nexport const runtimeConfigSchema: z.ZodType<SpotPatchRuntimeConfig> =\n z.discriminatedUnion(\"framework\", [\n z.strictObject({\n ...runtimeConfigBaseShape,\n framework: z.literal(\"vite\"),\n }),\n z.strictObject({\n ...runtimeConfigBaseShape,\n bundler: z.enum(SPOTPATCH_NEXT_BUNDLERS),\n framework: z.literal(\"next\"),\n routerKind: z.enum(SPOTPATCH_NEXT_ROUTER_KINDS),\n }),\n ]);\n","export const SPOTPATCH_API_BASE = \"/__spotpatch/v1\" as const;\nexport const SPOTPATCH_TOKEN_HEADER = \"X-SpotPatch-Token\" as const;\n\nexport const SPOTPATCH_ENDPOINTS = Object.freeze({\n bootstrap: `${SPOTPATCH_API_BASE}/bootstrap`,\n sourceContext: `${SPOTPATCH_API_BASE}/source-context`,\n openEditor: `${SPOTPATCH_API_BASE}/open-editor`,\n agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,\n agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,\n agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`,\n});\n\nexport type AgentJobAction = \"events\" | \"result\" | \"cancel\" | \"apply\" | \"revert\";\n\nexport function getAgentJobEndpoint(jobId: string, action: AgentJobAction): string {\n return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;\n}\n","export const SPOTPATCH_EDITOR_PREFERENCES = [\"auto\", \"vscode\", \"cursor\"] as const;\n\nexport type SpotPatchEditorPreference = (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n\nexport interface EditorOpenResult {\n readonly editor: SpotPatchEditorPreference;\n}\n","import type { ErrorCode } from \"../errors/error-code.js\";\n\nexport type AiProviderProtocol = \"responses\" | \"chat-completions\";\nexport type AiProviderAuthentication = \"bearer\" | \"x-api-key\";\nexport const AGENT_APPLY_MODES = Object.freeze([\n \"review\",\n \"auto\",\n \"trusted-auto\",\n] as const);\nexport type AgentApplyMode = (typeof AGENT_APPLY_MODES)[number];\nexport type AgentWorkingTreeMode = \"require-clean\" | \"include-local-changes\";\n\nexport interface AiModelProfile {\n readonly label: string;\n readonly model: string;\n}\n\nexport interface OpenAICompatibleProviderOptions {\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication?: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, AiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface AgentCheckDefinition {\n readonly label: string;\n readonly command: string;\n readonly args?: readonly string[];\n readonly required?: boolean;\n readonly timeoutMs?: number;\n}\n\nexport interface AgentLimits {\n readonly maxTurns: number;\n readonly maxToolCalls: number;\n readonly maxChangedFiles: number;\n readonly maxDiffBytes: number;\n readonly maxReadBytesPerFile: number;\n readonly maxToolOutputCharacters: number;\n readonly maxProviderResponseBytes: number;\n readonly providerConnectTimeoutMs: number;\n readonly providerFirstByteTimeoutMs: number;\n readonly providerIdleTimeoutMs: number;\n readonly checkTimeoutMs: number;\n readonly jobTimeoutMs: number;\n}\n\nexport const DEFAULT_AGENT_LIMITS = Object.freeze({\n maxTurns: 20,\n maxToolCalls: 80,\n maxChangedFiles: 20,\n maxDiffBytes: 512_000,\n maxReadBytesPerFile: 256_000,\n maxToolOutputCharacters: 40_000,\n maxProviderResponseBytes: 2_000_000,\n providerConnectTimeoutMs: 15_000,\n providerFirstByteTimeoutMs: 30_000,\n providerIdleTimeoutMs: 60_000,\n checkTimeoutMs: 120_000,\n jobTimeoutMs: 600_000,\n} satisfies AgentLimits);\n\nexport interface AiExecutionOptions {\n readonly isolation?: \"git-worktree\";\n readonly applyMode?: AgentApplyMode;\n readonly checks?: Readonly<Record<string, AgentCheckDefinition>>;\n readonly limits?: Partial<AgentLimits>;\n}\n\nexport interface AiOptions {\n readonly providers: Readonly<Record<string, OpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution?: AiExecutionOptions;\n}\n\nexport interface ResolvedAiModelProfile extends AiModelProfile {\n readonly id: string;\n}\n\nexport interface ResolvedOpenAICompatibleProviderOptions {\n readonly id: string;\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, ResolvedAiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface ResolvedAgentCheckDefinition {\n readonly id: string;\n readonly label: string;\n readonly command: string;\n readonly args: readonly string[];\n readonly required: boolean;\n readonly timeoutMs: number;\n}\n\nexport interface ResolvedAiExecutionOptions {\n readonly isolation: \"git-worktree\";\n readonly applyMode: AgentApplyMode;\n readonly checks: Readonly<Record<string, ResolvedAgentCheckDefinition>>;\n readonly limits: Readonly<AgentLimits>;\n}\n\nexport interface ResolvedAiOptions {\n readonly providers: Readonly<Record<string, ResolvedOpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution: ResolvedAiExecutionOptions;\n}\n\nexport interface RuntimeAiModelProfile {\n readonly id: string;\n readonly label: string;\n}\n\nexport interface RuntimeAiProviderProfile {\n readonly id: string;\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly models: readonly RuntimeAiModelProfile[];\n readonly defaultModel: string;\n}\n\nexport type RuntimeAiConfig =\n | Readonly<{ enabled: false }>\n | Readonly<{\n enabled: true;\n providers: readonly RuntimeAiProviderProfile[];\n defaultProvider: string;\n applyMode: AgentApplyMode;\n }>;\n\nexport const AGENT_JOB_STATUSES = Object.freeze([\n \"queued\",\n \"preparing\",\n \"running\",\n \"validating\",\n \"awaiting-review\",\n \"applying\",\n \"applied\",\n \"completed\",\n \"cancelling\",\n \"cancelled\",\n \"reverting\",\n \"reverted\",\n \"failed\",\n] as const);\n\nexport type AgentJobStatus = (typeof AGENT_JOB_STATUSES)[number];\n\nexport const AGENT_CAPABILITY_STATES = Object.freeze([\n \"unknown\",\n \"probing\",\n \"agent-ready\",\n \"prompt-only\",\n \"unavailable\",\n] as const);\n\nexport type AgentCapabilityState = (typeof AGENT_CAPABILITY_STATES)[number];\n\nexport interface AgentCapabilitySnapshot {\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly protocol: AiProviderProtocol;\n readonly state: AgentCapabilityState;\n readonly authenticated: boolean;\n readonly modelAvailable: boolean;\n readonly toolCalling: boolean;\n readonly toolResultContinuation: boolean;\n readonly streaming: boolean;\n readonly checkedAt?: string;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_WORKSPACE_STATES = Object.freeze([\n \"ready\",\n \"consent-required\",\n \"blocked\",\n] as const);\n\nexport const AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({\n maxUntrackedFiles: 1_000,\n maxUntrackedBytes: 20 * 1024 * 1024,\n});\n\nexport type AgentWorkspaceState = (typeof AGENT_WORKSPACE_STATES)[number];\n\nexport interface AgentWorkspaceChangeSummary {\n readonly staged: number;\n readonly unstaged: number;\n readonly untracked: number;\n readonly conflicted: number;\n readonly total: number;\n}\n\nexport interface AgentWorkspaceHealthSnapshot {\n readonly state: AgentWorkspaceState;\n readonly checkedAt: string;\n readonly changes: AgentWorkspaceChangeSummary;\n readonly canIncludeLocalChanges: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_FILE_CHANGE_KINDS = Object.freeze([\n \"added\",\n \"modified\",\n \"deleted\",\n] as const);\n\nexport type AgentFileChangeKind = (typeof AGENT_FILE_CHANGE_KINDS)[number];\n\nexport const AGENT_CHECK_STATUSES = Object.freeze([\n \"passed\",\n \"failed\",\n \"cancelled\",\n \"timed-out\",\n] as const);\n\nexport type AgentCheckStatus = (typeof AGENT_CHECK_STATUSES)[number];\n\nexport interface AgentChangedFile {\n readonly relativePath: string;\n readonly kind: AgentFileChangeKind;\n readonly additions: number;\n readonly deletions: number;\n}\n\nexport interface AgentCheckResult {\n readonly checkId: string;\n readonly label: string;\n readonly status: AgentCheckStatus;\n readonly durationMs: number;\n readonly output: string;\n}\n\nexport interface AgentJobSnapshot {\n readonly jobId: string;\n readonly status: AgentJobStatus;\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly phaseMessage: string;\n readonly createdAt: string;\n readonly updatedAt: string;\n readonly canCancel: boolean;\n readonly canApply: boolean;\n readonly canRevert: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport interface AgentJobResult {\n readonly jobId: string;\n readonly summary: string;\n readonly diff: string;\n readonly files: readonly AgentChangedFile[];\n readonly checks: readonly AgentCheckResult[];\n}\n\nexport interface AgentJobResultResponse {\n readonly snapshot: AgentJobSnapshot;\n readonly result?: AgentJobResult;\n}\n","export const SOURCE_MARKER_ATTRIBUTE = \"data-spotpatch-source\" as const;\n\nconst SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\\d*):([1-9]\\d*)$/;\n\nexport interface SourceMarker {\n readonly fileId: string;\n readonly line: number;\n readonly column: number;\n}\n\nexport function formatSourceMarker(marker: SourceMarker): string {\n return [marker.fileId, String(marker.line), String(marker.column)].join(\":\");\n}\n\nexport function parseSourceMarker(value: string | null): SourceMarker | undefined {\n if (value === null) {\n return undefined;\n }\n\n const match = SOURCE_MARKER_PATTERN.exec(value);\n\n if (match === null) {\n return undefined;\n }\n\n const fileId = match[1];\n const line = Number(match[2]);\n const column = Number(match[3]);\n\n if (\n fileId === undefined ||\n !Number.isSafeInteger(line) ||\n !Number.isSafeInteger(column)\n ) {\n return undefined;\n }\n\n return Object.freeze({ fileId, line, column });\n}\n","import { z } from \"zod\";\n\nimport {\n MAX_ANNOTATION_INSTRUCTION_CHARACTERS,\n MAX_ANNOTATION_TARGETS,\n MAX_TARGET_INSTRUCTION_CHARACTERS,\n SPOTPATCH_LOCALES,\n type SpotAnnotation,\n} from \"../model/annotation.js\";\n\nexport const runtimeBootstrapRequestSchema = z.strictObject({});\n\nconst sourceCoordinatesSchema = z.strictObject({\n fileId: z.string().min(1).max(128),\n line: z.number().int().positive(),\n column: z.number().int().positive(),\n});\n\nexport const sourceContextRequestSchema = sourceCoordinatesSchema\n .extend({\n maxLines: z.number().int().positive(),\n })\n .strict();\n\nexport const openEditorRequestSchema = sourceCoordinatesSchema.strict();\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\n\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst sourceRefSchema = z.strictObject({\n fileId: boundedString(128).optional(),\n relativePath: boundedString(1_024).optional(),\n line: z.number().int().positive().optional(),\n column: z.number().int().positive().optional(),\n origin: z.enum([\"jsx-host\", \"react-fiber\", \"dom-ancestor\", \"none\"]),\n confidence: z.enum([\"exact\", \"probable\", \"approximate\", \"unknown\"]),\n});\nconst matchedStyleRuleSchema = z.strictObject({\n selector: boundedString(2_048),\n declarations: boundedString(8_192),\n source: boundedString(1_024).optional(),\n media: boundedString(1_024).optional(),\n});\nconst codeContextSchema = z.strictObject({\n relativePath: boundedString(1_024),\n language: z.enum([\"tsx\", \"jsx\"]),\n startLine: z.number().int().positive(),\n endLine: z.number().int().positive(),\n excerpt: boundedString(16_000),\n boundary: z.enum([\"component\", \"nearby-lines\"]),\n});\nconst pageContextSchema = z.strictObject({\n url: boundedString(2_048),\n pathname: boundedString(2_048),\n title: boundedString(1_024),\n viewportWidth: z.number().nonnegative(),\n viewportHeight: z.number().nonnegative(),\n devicePixelRatio: z.number().positive(),\n});\n\nexport const spotTargetContextRequestSchema = z.strictObject({\n instruction: z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),\n page: pageContextSchema.optional(),\n source: sourceRefSchema,\n react: z.strictObject({\n supported: z.boolean(),\n version: boundedString(64).optional(),\n componentName: boundedString(256).optional(),\n componentStack: z.array(boundedString(256)).max(64),\n source: sourceRefSchema.optional(),\n }),\n element: z.strictObject({\n tagName: boundedString(128),\n selector: boundedString(2_048),\n sanitizedHtml: boundedString(8_192),\n textPreview: boundedString(2_048).optional(),\n role: boundedString(256).optional(),\n rect: z.strictObject({\n x: z.number(),\n y: z.number(),\n width: z.number().nonnegative(),\n height: z.number().nonnegative(),\n }),\n }),\n styles: z.strictObject({\n classNames: z.array(boundedString(512)).max(256),\n inlineStyle: boundedString(8_192).optional(),\n matchedRules: z.array(matchedStyleRuleSchema).max(256),\n computed: z.record(boundedString(256), boundedString(2_048)),\n warnings: z.array(boundedString(1_024)).max(64),\n }),\n code: codeContextSchema.optional(),\n warnings: z.array(boundedString(1_024)).max(64),\n});\n\nexport const spotAnnotationRequestSchema = z\n .strictObject({\n schemaVersion: z.literal(3),\n id: boundedString(128),\n locale: z.enum(SPOTPATCH_LOCALES),\n page: pageContextSchema,\n targets: z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),\n createdAt: z.iso.datetime(),\n })\n .superRefine((annotation, context) => {\n const total = annotation.targets.reduce(\n (characters, target) => characters + target.instruction.length,\n 0,\n );\n\n if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {\n context.addIssue({\n code: \"custom\",\n message: \"Combined target instructions exceed the annotation limit.\",\n path: [\"targets\"],\n });\n }\n });\n\nexport const agentCapabilityRequestSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n});\n\nexport const agentWorkspaceHealthRequestSchema = z.strictObject({});\n\nexport const agentJobCreateRequestSchema = z.strictObject({\n annotation: spotAnnotationRequestSchema,\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n providerDataConsent: z.literal(true),\n trustedFastModeConsent: z.literal(true).optional(),\n workingTreeMode: z\n .enum([\"require-clean\", \"include-local-changes\"])\n .default(\"require-clean\"),\n});\n\nexport const agentJobActionRequestSchema = z.strictObject({});\n\nexport type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;\nexport type RuntimeBootstrapRequest = z.infer<typeof runtimeBootstrapRequestSchema>;\nexport type OpenEditorRequest = z.infer<typeof openEditorRequestSchema>;\nexport type AgentCapabilityRequest = z.infer<typeof agentCapabilityRequestSchema>;\nexport interface AgentJobCreateRequest {\n readonly annotation: SpotAnnotation;\n readonly providerProfileId: string;\n readonly modelProfileId: string;\n readonly providerDataConsent: true;\n readonly trustedFastModeConsent?: true;\n readonly workingTreeMode: \"require-clean\" | \"include-local-changes\";\n}\n","import { z } from \"zod\";\n\nimport { ERROR_CODES } from \"../errors/error-code.js\";\nimport {\n AGENT_CAPABILITY_STATES,\n AGENT_CHECK_STATUSES,\n AGENT_FILE_CHANGE_KINDS,\n AGENT_JOB_STATUSES,\n AGENT_WORKSPACE_STATES,\n} from \"../model/agent.js\";\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst errorCodeSchema = z.enum(ERROR_CODES);\n\nexport const agentCapabilitySnapshotSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n state: z.enum(AGENT_CAPABILITY_STATES),\n authenticated: z.boolean(),\n modelAvailable: z.boolean(),\n toolCalling: z.boolean(),\n toolResultContinuation: z.boolean(),\n streaming: z.boolean(),\n checkedAt: z.iso.datetime().optional(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentWorkspaceHealthSnapshotSchema = z\n .strictObject({\n state: z.enum(AGENT_WORKSPACE_STATES),\n checkedAt: z.iso.datetime(),\n changes: z.strictObject({\n staged: z.number().int().nonnegative(),\n unstaged: z.number().int().nonnegative(),\n untracked: z.number().int().nonnegative(),\n conflicted: z.number().int().nonnegative(),\n total: z.number().int().nonnegative(),\n }),\n canIncludeLocalChanges: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n })\n .refine(\n ({ state, changes, canIncludeLocalChanges, errorCode }) => {\n const countsAreConsistent =\n changes.total >= changes.staged &&\n changes.total >= changes.unstaged &&\n changes.total >= changes.untracked &&\n changes.total >= changes.conflicted &&\n changes.total <= changes.staged + changes.unstaged + changes.untracked;\n\n if (!countsAreConsistent) {\n return false;\n }\n\n if (state === \"ready\") {\n return (\n changes.total === 0 && !canIncludeLocalChanges && errorCode === undefined\n );\n }\n\n if (state === \"consent-required\") {\n return (\n changes.total > 0 &&\n changes.conflicted === 0 &&\n canIncludeLocalChanges &&\n errorCode === undefined\n );\n }\n\n return !canIncludeLocalChanges && errorCode !== undefined;\n },\n { message: \"Agent workspace health fields are inconsistent.\" },\n );\n\nexport const agentChangedFileSchema = z.strictObject({\n relativePath: boundedString(1_024),\n kind: z.enum(AGENT_FILE_CHANGE_KINDS),\n additions: z.number().int().nonnegative(),\n deletions: z.number().int().nonnegative(),\n});\n\nexport const agentCheckResultSchema = z.strictObject({\n checkId: profileIdSchema,\n label: boundedString(100),\n status: z.enum(AGENT_CHECK_STATUSES),\n durationMs: z.number().int().nonnegative(),\n output: boundedString(80_000),\n});\n\nexport const agentJobSnapshotSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n phaseMessage: boundedString(1_024),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n canCancel: z.boolean(),\n canApply: z.boolean(),\n canRevert: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentJobResultSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n summary: boundedString(80_000),\n diff: boundedString(1_000_000),\n files: z.array(agentChangedFileSchema).max(100),\n checks: z.array(agentCheckResultSchema).max(100),\n});\n\nexport const agentJobResultResponseSchema = z\n .strictObject({\n snapshot: agentJobSnapshotSchema,\n result: agentJobResultSchema.optional(),\n })\n .superRefine((value, context) => {\n if (value.result !== undefined && value.result.jobId !== value.snapshot.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent result and snapshot job IDs must match.\",\n path: [\"result\", \"jobId\"],\n });\n }\n });\n\nconst agentJobEventBaseSchema = z.strictObject({\n schemaVersion: z.literal(2),\n sequence: z.number().int().positive(),\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n timestamp: z.iso.datetime(),\n});\n\nexport const agentJobEventSchema = z\n .discriminatedUnion(\"type\", [\n agentJobEventBaseSchema.extend({\n type: z.literal(\"snapshot\"),\n data: z.strictObject({ snapshot: agentJobSnapshotSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"phase\"),\n data: z.strictObject({ message: boundedString(1_024) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"tool\"),\n data: z.strictObject({\n turn: z.number().int().positive(),\n toolCallId: boundedString(256),\n toolName: boundedString(100),\n state: z.enum([\"started\", \"succeeded\", \"failed\"]),\n relativePath: boundedString(1_024).optional(),\n checkLabel: boundedString(100).optional(),\n }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"check\"),\n data: z.strictObject({ result: agentCheckResultSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"result-ready\"),\n data: z.strictObject({ hasResult: z.literal(true) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"error\"),\n data: z.strictObject({\n code: errorCodeSchema,\n message: boundedString(1_024),\n }),\n }),\n ])\n .superRefine((event, context) => {\n if (event.type !== \"snapshot\") {\n return;\n }\n\n if (event.data.snapshot.jobId !== event.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot job IDs must match.\",\n path: [\"data\", \"snapshot\", \"jobId\"],\n });\n }\n\n if (event.data.snapshot.status !== event.status) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot statuses must match.\",\n path: [\"data\", \"snapshot\", \"status\"],\n });\n }\n });\n","export const SPOTPATCH_REPOSITORY_URL =\n \"https://github.com/huanglvjing/spotpatch\" as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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NI,IAAM,2BACX;","names":["import_zod","profileIdSchema","import_zod","profileIdSchema","boundedString"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -128,6 +128,7 @@ declare const SPOTPATCH_LOCALE_PREFERENCES: readonly ["auto", "en-US", "zh-CN"];
|
|
|
128
128
|
type SpotPatchLocalePreference = (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];
|
|
129
129
|
interface SpotTargetContext {
|
|
130
130
|
readonly instruction: string;
|
|
131
|
+
readonly page?: Readonly<PageContext>;
|
|
131
132
|
readonly source: SourceRef;
|
|
132
133
|
readonly react: ReactContext;
|
|
133
134
|
readonly element: ElementContext;
|
|
@@ -165,7 +166,8 @@ interface EditorOpenResult {
|
|
|
165
166
|
|
|
166
167
|
type AiProviderProtocol = "responses" | "chat-completions";
|
|
167
168
|
type AiProviderAuthentication = "bearer" | "x-api-key";
|
|
168
|
-
|
|
169
|
+
declare const AGENT_APPLY_MODES: readonly ["review", "auto", "trusted-auto"];
|
|
170
|
+
type AgentApplyMode = (typeof AGENT_APPLY_MODES)[number];
|
|
169
171
|
type AgentWorkingTreeMode = "require-clean" | "include-local-changes";
|
|
170
172
|
interface AiModelProfile {
|
|
171
173
|
readonly label: string;
|
|
@@ -376,6 +378,7 @@ interface RuntimeConfigBase {
|
|
|
376
378
|
readonly locale: (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];
|
|
377
379
|
readonly maxTargets: number;
|
|
378
380
|
readonly redact: boolean;
|
|
381
|
+
readonly sessionId: string;
|
|
379
382
|
readonly sessionToken: string;
|
|
380
383
|
readonly shortcut: string;
|
|
381
384
|
readonly spotPatchVersion: string;
|
|
@@ -412,6 +415,14 @@ declare const openEditorRequestSchema: z.ZodObject<{
|
|
|
412
415
|
}, z.core.$strict>;
|
|
413
416
|
declare const spotTargetContextRequestSchema: z.ZodObject<{
|
|
414
417
|
instruction: z.ZodString;
|
|
418
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
419
|
+
url: z.ZodString;
|
|
420
|
+
pathname: z.ZodString;
|
|
421
|
+
title: z.ZodString;
|
|
422
|
+
viewportWidth: z.ZodNumber;
|
|
423
|
+
viewportHeight: z.ZodNumber;
|
|
424
|
+
devicePixelRatio: z.ZodNumber;
|
|
425
|
+
}, z.core.$strict>>;
|
|
415
426
|
source: z.ZodObject<{
|
|
416
427
|
fileId: z.ZodOptional<z.ZodString>;
|
|
417
428
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
@@ -512,6 +523,14 @@ declare const spotAnnotationRequestSchema: z.ZodObject<{
|
|
|
512
523
|
}, z.core.$strict>;
|
|
513
524
|
targets: z.ZodArray<z.ZodObject<{
|
|
514
525
|
instruction: z.ZodString;
|
|
526
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
527
|
+
url: z.ZodString;
|
|
528
|
+
pathname: z.ZodString;
|
|
529
|
+
title: z.ZodString;
|
|
530
|
+
viewportWidth: z.ZodNumber;
|
|
531
|
+
viewportHeight: z.ZodNumber;
|
|
532
|
+
devicePixelRatio: z.ZodNumber;
|
|
533
|
+
}, z.core.$strict>>;
|
|
515
534
|
source: z.ZodObject<{
|
|
516
535
|
fileId: z.ZodOptional<z.ZodString>;
|
|
517
536
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
@@ -620,6 +639,14 @@ declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
|
620
639
|
}, z.core.$strict>;
|
|
621
640
|
targets: z.ZodArray<z.ZodObject<{
|
|
622
641
|
instruction: z.ZodString;
|
|
642
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
643
|
+
url: z.ZodString;
|
|
644
|
+
pathname: z.ZodString;
|
|
645
|
+
title: z.ZodString;
|
|
646
|
+
viewportWidth: z.ZodNumber;
|
|
647
|
+
viewportHeight: z.ZodNumber;
|
|
648
|
+
devicePixelRatio: z.ZodNumber;
|
|
649
|
+
}, z.core.$strict>>;
|
|
623
650
|
source: z.ZodObject<{
|
|
624
651
|
fileId: z.ZodOptional<z.ZodString>;
|
|
625
652
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
@@ -708,6 +735,7 @@ declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
|
708
735
|
providerProfileId: z.ZodString;
|
|
709
736
|
modelProfileId: z.ZodString;
|
|
710
737
|
providerDataConsent: z.ZodLiteral<true>;
|
|
738
|
+
trustedFastModeConsent: z.ZodOptional<z.ZodLiteral<true>>;
|
|
711
739
|
workingTreeMode: z.ZodDefault<z.ZodEnum<{
|
|
712
740
|
"require-clean": "require-clean";
|
|
713
741
|
"include-local-changes": "include-local-changes";
|
|
@@ -723,6 +751,7 @@ interface AgentJobCreateRequest {
|
|
|
723
751
|
readonly providerProfileId: string;
|
|
724
752
|
readonly modelProfileId: string;
|
|
725
753
|
readonly providerDataConsent: true;
|
|
754
|
+
readonly trustedFastModeConsent?: true;
|
|
726
755
|
readonly workingTreeMode: "require-clean" | "include-local-changes";
|
|
727
756
|
}
|
|
728
757
|
|
|
@@ -1362,4 +1391,4 @@ type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
|
|
|
1362
1391
|
|
|
1363
1392
|
declare const SPOTPATCH_REPOSITORY_URL: "https://github.com/huanglvjing/spotpatch";
|
|
1364
1393
|
|
|
1365
|
-
export { AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, AGENT_WORKSPACE_SNAPSHOT_LIMITS, AGENT_WORKSPACE_STATES, 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 AgentWorkingTreeMode, type AgentWorkspaceChangeSummary, type AgentWorkspaceHealthSnapshot, type AgentWorkspaceState, type AiExecutionOptions, type AiModelProfile, type AiOptions, type AiProviderAuthentication, type AiProviderProtocol, type ApiFailure, type ApiResponse, type ApiSuccess, type CodeContext, type ContextBudget, DEFAULT_AGENT_LIMITS, ERROR_CODES, type EditorOpenResult, 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, type RuntimeBootstrapRequest, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, SPOTPATCH_NEXT_BUNDLERS, SPOTPATCH_NEXT_ROUTER_KINDS, SPOTPATCH_REPOSITORY_URL, SPOTPATCH_TOKEN_HEADER, type SourceConfidence, type SourceContextRequest, type SourceMarker, type SourceOrigin, type SourceRef, type SpotAnnotation, type SpotPatchEditorPreference, SpotPatchError, type SpotPatchLocale, type SpotPatchLocalePreference, type SpotPatchNextBundler, type SpotPatchNextRouterKind, type SpotPatchRuntimeConfig, type SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, agentWorkspaceHealthRequestSchema, agentWorkspaceHealthSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, runtimeBootstrapRequestSchema, runtimeConfigSchema, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
|
1394
|
+
export { AGENT_APPLY_MODES, AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, AGENT_WORKSPACE_SNAPSHOT_LIMITS, AGENT_WORKSPACE_STATES, 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 AgentWorkingTreeMode, type AgentWorkspaceChangeSummary, type AgentWorkspaceHealthSnapshot, type AgentWorkspaceState, type AiExecutionOptions, type AiModelProfile, type AiOptions, type AiProviderAuthentication, type AiProviderProtocol, type ApiFailure, type ApiResponse, type ApiSuccess, type CodeContext, type ContextBudget, DEFAULT_AGENT_LIMITS, ERROR_CODES, type EditorOpenResult, 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, type RuntimeBootstrapRequest, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, SPOTPATCH_NEXT_BUNDLERS, SPOTPATCH_NEXT_ROUTER_KINDS, SPOTPATCH_REPOSITORY_URL, SPOTPATCH_TOKEN_HEADER, type SourceConfidence, type SourceContextRequest, type SourceMarker, type SourceOrigin, type SourceRef, type SpotAnnotation, type SpotPatchEditorPreference, SpotPatchError, type SpotPatchLocale, type SpotPatchLocalePreference, type SpotPatchNextBundler, type SpotPatchNextRouterKind, type SpotPatchRuntimeConfig, type SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, agentWorkspaceHealthRequestSchema, agentWorkspaceHealthSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, runtimeBootstrapRequestSchema, runtimeConfigSchema, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -128,6 +128,7 @@ declare const SPOTPATCH_LOCALE_PREFERENCES: readonly ["auto", "en-US", "zh-CN"];
|
|
|
128
128
|
type SpotPatchLocalePreference = (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];
|
|
129
129
|
interface SpotTargetContext {
|
|
130
130
|
readonly instruction: string;
|
|
131
|
+
readonly page?: Readonly<PageContext>;
|
|
131
132
|
readonly source: SourceRef;
|
|
132
133
|
readonly react: ReactContext;
|
|
133
134
|
readonly element: ElementContext;
|
|
@@ -165,7 +166,8 @@ interface EditorOpenResult {
|
|
|
165
166
|
|
|
166
167
|
type AiProviderProtocol = "responses" | "chat-completions";
|
|
167
168
|
type AiProviderAuthentication = "bearer" | "x-api-key";
|
|
168
|
-
|
|
169
|
+
declare const AGENT_APPLY_MODES: readonly ["review", "auto", "trusted-auto"];
|
|
170
|
+
type AgentApplyMode = (typeof AGENT_APPLY_MODES)[number];
|
|
169
171
|
type AgentWorkingTreeMode = "require-clean" | "include-local-changes";
|
|
170
172
|
interface AiModelProfile {
|
|
171
173
|
readonly label: string;
|
|
@@ -376,6 +378,7 @@ interface RuntimeConfigBase {
|
|
|
376
378
|
readonly locale: (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];
|
|
377
379
|
readonly maxTargets: number;
|
|
378
380
|
readonly redact: boolean;
|
|
381
|
+
readonly sessionId: string;
|
|
379
382
|
readonly sessionToken: string;
|
|
380
383
|
readonly shortcut: string;
|
|
381
384
|
readonly spotPatchVersion: string;
|
|
@@ -412,6 +415,14 @@ declare const openEditorRequestSchema: z.ZodObject<{
|
|
|
412
415
|
}, z.core.$strict>;
|
|
413
416
|
declare const spotTargetContextRequestSchema: z.ZodObject<{
|
|
414
417
|
instruction: z.ZodString;
|
|
418
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
419
|
+
url: z.ZodString;
|
|
420
|
+
pathname: z.ZodString;
|
|
421
|
+
title: z.ZodString;
|
|
422
|
+
viewportWidth: z.ZodNumber;
|
|
423
|
+
viewportHeight: z.ZodNumber;
|
|
424
|
+
devicePixelRatio: z.ZodNumber;
|
|
425
|
+
}, z.core.$strict>>;
|
|
415
426
|
source: z.ZodObject<{
|
|
416
427
|
fileId: z.ZodOptional<z.ZodString>;
|
|
417
428
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
@@ -512,6 +523,14 @@ declare const spotAnnotationRequestSchema: z.ZodObject<{
|
|
|
512
523
|
}, z.core.$strict>;
|
|
513
524
|
targets: z.ZodArray<z.ZodObject<{
|
|
514
525
|
instruction: z.ZodString;
|
|
526
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
527
|
+
url: z.ZodString;
|
|
528
|
+
pathname: z.ZodString;
|
|
529
|
+
title: z.ZodString;
|
|
530
|
+
viewportWidth: z.ZodNumber;
|
|
531
|
+
viewportHeight: z.ZodNumber;
|
|
532
|
+
devicePixelRatio: z.ZodNumber;
|
|
533
|
+
}, z.core.$strict>>;
|
|
515
534
|
source: z.ZodObject<{
|
|
516
535
|
fileId: z.ZodOptional<z.ZodString>;
|
|
517
536
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
@@ -620,6 +639,14 @@ declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
|
620
639
|
}, z.core.$strict>;
|
|
621
640
|
targets: z.ZodArray<z.ZodObject<{
|
|
622
641
|
instruction: z.ZodString;
|
|
642
|
+
page: z.ZodOptional<z.ZodObject<{
|
|
643
|
+
url: z.ZodString;
|
|
644
|
+
pathname: z.ZodString;
|
|
645
|
+
title: z.ZodString;
|
|
646
|
+
viewportWidth: z.ZodNumber;
|
|
647
|
+
viewportHeight: z.ZodNumber;
|
|
648
|
+
devicePixelRatio: z.ZodNumber;
|
|
649
|
+
}, z.core.$strict>>;
|
|
623
650
|
source: z.ZodObject<{
|
|
624
651
|
fileId: z.ZodOptional<z.ZodString>;
|
|
625
652
|
relativePath: z.ZodOptional<z.ZodString>;
|
|
@@ -708,6 +735,7 @@ declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
|
708
735
|
providerProfileId: z.ZodString;
|
|
709
736
|
modelProfileId: z.ZodString;
|
|
710
737
|
providerDataConsent: z.ZodLiteral<true>;
|
|
738
|
+
trustedFastModeConsent: z.ZodOptional<z.ZodLiteral<true>>;
|
|
711
739
|
workingTreeMode: z.ZodDefault<z.ZodEnum<{
|
|
712
740
|
"require-clean": "require-clean";
|
|
713
741
|
"include-local-changes": "include-local-changes";
|
|
@@ -723,6 +751,7 @@ interface AgentJobCreateRequest {
|
|
|
723
751
|
readonly providerProfileId: string;
|
|
724
752
|
readonly modelProfileId: string;
|
|
725
753
|
readonly providerDataConsent: true;
|
|
754
|
+
readonly trustedFastModeConsent?: true;
|
|
726
755
|
readonly workingTreeMode: "require-clean" | "include-local-changes";
|
|
727
756
|
}
|
|
728
757
|
|
|
@@ -1362,4 +1391,4 @@ type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
|
|
|
1362
1391
|
|
|
1363
1392
|
declare const SPOTPATCH_REPOSITORY_URL: "https://github.com/huanglvjing/spotpatch";
|
|
1364
1393
|
|
|
1365
|
-
export { AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, AGENT_WORKSPACE_SNAPSHOT_LIMITS, AGENT_WORKSPACE_STATES, 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 AgentWorkingTreeMode, type AgentWorkspaceChangeSummary, type AgentWorkspaceHealthSnapshot, type AgentWorkspaceState, type AiExecutionOptions, type AiModelProfile, type AiOptions, type AiProviderAuthentication, type AiProviderProtocol, type ApiFailure, type ApiResponse, type ApiSuccess, type CodeContext, type ContextBudget, DEFAULT_AGENT_LIMITS, ERROR_CODES, type EditorOpenResult, 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, type RuntimeBootstrapRequest, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, SPOTPATCH_NEXT_BUNDLERS, SPOTPATCH_NEXT_ROUTER_KINDS, SPOTPATCH_REPOSITORY_URL, SPOTPATCH_TOKEN_HEADER, type SourceConfidence, type SourceContextRequest, type SourceMarker, type SourceOrigin, type SourceRef, type SpotAnnotation, type SpotPatchEditorPreference, SpotPatchError, type SpotPatchLocale, type SpotPatchLocalePreference, type SpotPatchNextBundler, type SpotPatchNextRouterKind, type SpotPatchRuntimeConfig, type SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, agentWorkspaceHealthRequestSchema, agentWorkspaceHealthSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, runtimeBootstrapRequestSchema, runtimeConfigSchema, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
|
1394
|
+
export { AGENT_APPLY_MODES, AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, AGENT_WORKSPACE_SNAPSHOT_LIMITS, AGENT_WORKSPACE_STATES, 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 AgentWorkingTreeMode, type AgentWorkspaceChangeSummary, type AgentWorkspaceHealthSnapshot, type AgentWorkspaceState, type AiExecutionOptions, type AiModelProfile, type AiOptions, type AiProviderAuthentication, type AiProviderProtocol, type ApiFailure, type ApiResponse, type ApiSuccess, type CodeContext, type ContextBudget, DEFAULT_AGENT_LIMITS, ERROR_CODES, type EditorOpenResult, 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, type RuntimeBootstrapRequest, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, SPOTPATCH_NEXT_BUNDLERS, SPOTPATCH_NEXT_ROUTER_KINDS, SPOTPATCH_REPOSITORY_URL, SPOTPATCH_TOKEN_HEADER, type SourceConfidence, type SourceContextRequest, type SourceMarker, type SourceOrigin, type SourceRef, type SpotAnnotation, type SpotPatchEditorPreference, SpotPatchError, type SpotPatchLocale, type SpotPatchLocalePreference, type SpotPatchNextBundler, type SpotPatchNextRouterKind, type SpotPatchRuntimeConfig, type SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, agentWorkspaceHealthRequestSchema, agentWorkspaceHealthSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, runtimeBootstrapRequestSchema, runtimeConfigSchema, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
package/dist/index.js
CHANGED
|
@@ -145,6 +145,69 @@ function getAgentJobEndpoint(jobId, action) {
|
|
|
145
145
|
// src/model/editor.ts
|
|
146
146
|
var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
|
|
147
147
|
|
|
148
|
+
// src/model/agent.ts
|
|
149
|
+
var AGENT_APPLY_MODES = Object.freeze([
|
|
150
|
+
"review",
|
|
151
|
+
"auto",
|
|
152
|
+
"trusted-auto"
|
|
153
|
+
]);
|
|
154
|
+
var DEFAULT_AGENT_LIMITS = Object.freeze({
|
|
155
|
+
maxTurns: 20,
|
|
156
|
+
maxToolCalls: 80,
|
|
157
|
+
maxChangedFiles: 20,
|
|
158
|
+
maxDiffBytes: 512e3,
|
|
159
|
+
maxReadBytesPerFile: 256e3,
|
|
160
|
+
maxToolOutputCharacters: 4e4,
|
|
161
|
+
maxProviderResponseBytes: 2e6,
|
|
162
|
+
providerConnectTimeoutMs: 15e3,
|
|
163
|
+
providerFirstByteTimeoutMs: 3e4,
|
|
164
|
+
providerIdleTimeoutMs: 6e4,
|
|
165
|
+
checkTimeoutMs: 12e4,
|
|
166
|
+
jobTimeoutMs: 6e5
|
|
167
|
+
});
|
|
168
|
+
var AGENT_JOB_STATUSES = Object.freeze([
|
|
169
|
+
"queued",
|
|
170
|
+
"preparing",
|
|
171
|
+
"running",
|
|
172
|
+
"validating",
|
|
173
|
+
"awaiting-review",
|
|
174
|
+
"applying",
|
|
175
|
+
"applied",
|
|
176
|
+
"completed",
|
|
177
|
+
"cancelling",
|
|
178
|
+
"cancelled",
|
|
179
|
+
"reverting",
|
|
180
|
+
"reverted",
|
|
181
|
+
"failed"
|
|
182
|
+
]);
|
|
183
|
+
var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
184
|
+
"unknown",
|
|
185
|
+
"probing",
|
|
186
|
+
"agent-ready",
|
|
187
|
+
"prompt-only",
|
|
188
|
+
"unavailable"
|
|
189
|
+
]);
|
|
190
|
+
var AGENT_WORKSPACE_STATES = Object.freeze([
|
|
191
|
+
"ready",
|
|
192
|
+
"consent-required",
|
|
193
|
+
"blocked"
|
|
194
|
+
]);
|
|
195
|
+
var AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({
|
|
196
|
+
maxUntrackedFiles: 1e3,
|
|
197
|
+
maxUntrackedBytes: 20 * 1024 * 1024
|
|
198
|
+
});
|
|
199
|
+
var AGENT_FILE_CHANGE_KINDS = Object.freeze([
|
|
200
|
+
"added",
|
|
201
|
+
"modified",
|
|
202
|
+
"deleted"
|
|
203
|
+
]);
|
|
204
|
+
var AGENT_CHECK_STATUSES = Object.freeze([
|
|
205
|
+
"passed",
|
|
206
|
+
"failed",
|
|
207
|
+
"cancelled",
|
|
208
|
+
"timed-out"
|
|
209
|
+
]);
|
|
210
|
+
|
|
148
211
|
// src/model/runtime-config.ts
|
|
149
212
|
var SPOTPATCH_NEXT_BUNDLERS = Object.freeze(["turbopack", "webpack"]);
|
|
150
213
|
var SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([
|
|
@@ -174,7 +237,7 @@ var runtimeAiConfigSchema = z.discriminatedUnion("enabled", [
|
|
|
174
237
|
enabled: z.literal(true),
|
|
175
238
|
providers: z.array(runtimeAiProviderSchema).min(1).max(32),
|
|
176
239
|
defaultProvider: profileIdSchema,
|
|
177
|
-
applyMode: z.enum(
|
|
240
|
+
applyMode: z.enum(AGENT_APPLY_MODES)
|
|
178
241
|
}).refine(
|
|
179
242
|
({ defaultProvider, providers }) => providers.some(({ id }) => id === defaultProvider) && new Set(providers.map(({ id }) => id)).size === providers.length,
|
|
180
243
|
{ message: "Runtime AI provider profiles are inconsistent." }
|
|
@@ -198,6 +261,7 @@ var runtimeConfigBaseShape = {
|
|
|
198
261
|
locale: z.enum(SPOTPATCH_LOCALE_PREFERENCES),
|
|
199
262
|
maxTargets: z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
|
|
200
263
|
redact: z.boolean(),
|
|
264
|
+
sessionId: z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
201
265
|
sessionToken: z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
202
266
|
shortcut: boundedText(128),
|
|
203
267
|
spotPatchVersion: boundedText(64)
|
|
@@ -215,64 +279,6 @@ var runtimeConfigSchema = z.discriminatedUnion("framework", [
|
|
|
215
279
|
})
|
|
216
280
|
]);
|
|
217
281
|
|
|
218
|
-
// src/model/agent.ts
|
|
219
|
-
var DEFAULT_AGENT_LIMITS = Object.freeze({
|
|
220
|
-
maxTurns: 20,
|
|
221
|
-
maxToolCalls: 80,
|
|
222
|
-
maxChangedFiles: 20,
|
|
223
|
-
maxDiffBytes: 512e3,
|
|
224
|
-
maxReadBytesPerFile: 256e3,
|
|
225
|
-
maxToolOutputCharacters: 4e4,
|
|
226
|
-
maxProviderResponseBytes: 2e6,
|
|
227
|
-
providerConnectTimeoutMs: 15e3,
|
|
228
|
-
providerFirstByteTimeoutMs: 3e4,
|
|
229
|
-
providerIdleTimeoutMs: 6e4,
|
|
230
|
-
checkTimeoutMs: 12e4,
|
|
231
|
-
jobTimeoutMs: 6e5
|
|
232
|
-
});
|
|
233
|
-
var AGENT_JOB_STATUSES = Object.freeze([
|
|
234
|
-
"queued",
|
|
235
|
-
"preparing",
|
|
236
|
-
"running",
|
|
237
|
-
"validating",
|
|
238
|
-
"awaiting-review",
|
|
239
|
-
"applying",
|
|
240
|
-
"applied",
|
|
241
|
-
"completed",
|
|
242
|
-
"cancelling",
|
|
243
|
-
"cancelled",
|
|
244
|
-
"reverting",
|
|
245
|
-
"reverted",
|
|
246
|
-
"failed"
|
|
247
|
-
]);
|
|
248
|
-
var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
249
|
-
"unknown",
|
|
250
|
-
"probing",
|
|
251
|
-
"agent-ready",
|
|
252
|
-
"prompt-only",
|
|
253
|
-
"unavailable"
|
|
254
|
-
]);
|
|
255
|
-
var AGENT_WORKSPACE_STATES = Object.freeze([
|
|
256
|
-
"ready",
|
|
257
|
-
"consent-required",
|
|
258
|
-
"blocked"
|
|
259
|
-
]);
|
|
260
|
-
var AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({
|
|
261
|
-
maxUntrackedFiles: 1e3,
|
|
262
|
-
maxUntrackedBytes: 20 * 1024 * 1024
|
|
263
|
-
});
|
|
264
|
-
var AGENT_FILE_CHANGE_KINDS = Object.freeze([
|
|
265
|
-
"added",
|
|
266
|
-
"modified",
|
|
267
|
-
"deleted"
|
|
268
|
-
]);
|
|
269
|
-
var AGENT_CHECK_STATUSES = Object.freeze([
|
|
270
|
-
"passed",
|
|
271
|
-
"failed",
|
|
272
|
-
"cancelled",
|
|
273
|
-
"timed-out"
|
|
274
|
-
]);
|
|
275
|
-
|
|
276
282
|
// src/model/source-marker.ts
|
|
277
283
|
var SOURCE_MARKER_ATTRIBUTE = "data-spotpatch-source";
|
|
278
284
|
var SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\d*):([1-9]\d*)$/;
|
|
@@ -332,8 +338,17 @@ var codeContextSchema = z2.strictObject({
|
|
|
332
338
|
excerpt: boundedString(16e3),
|
|
333
339
|
boundary: z2.enum(["component", "nearby-lines"])
|
|
334
340
|
});
|
|
341
|
+
var pageContextSchema = z2.strictObject({
|
|
342
|
+
url: boundedString(2048),
|
|
343
|
+
pathname: boundedString(2048),
|
|
344
|
+
title: boundedString(1024),
|
|
345
|
+
viewportWidth: z2.number().nonnegative(),
|
|
346
|
+
viewportHeight: z2.number().nonnegative(),
|
|
347
|
+
devicePixelRatio: z2.number().positive()
|
|
348
|
+
});
|
|
335
349
|
var spotTargetContextRequestSchema = z2.strictObject({
|
|
336
350
|
instruction: z2.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
351
|
+
page: pageContextSchema.optional(),
|
|
337
352
|
source: sourceRefSchema,
|
|
338
353
|
react: z2.strictObject({
|
|
339
354
|
supported: z2.boolean(),
|
|
@@ -369,14 +384,7 @@ var spotAnnotationRequestSchema = z2.strictObject({
|
|
|
369
384
|
schemaVersion: z2.literal(3),
|
|
370
385
|
id: boundedString(128),
|
|
371
386
|
locale: z2.enum(SPOTPATCH_LOCALES),
|
|
372
|
-
page:
|
|
373
|
-
url: boundedString(2048),
|
|
374
|
-
pathname: boundedString(2048),
|
|
375
|
-
title: boundedString(1024),
|
|
376
|
-
viewportWidth: z2.number().nonnegative(),
|
|
377
|
-
viewportHeight: z2.number().nonnegative(),
|
|
378
|
-
devicePixelRatio: z2.number().positive()
|
|
379
|
-
}),
|
|
387
|
+
page: pageContextSchema,
|
|
380
388
|
targets: z2.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
381
389
|
createdAt: z2.iso.datetime()
|
|
382
390
|
}).superRefine((annotation, context) => {
|
|
@@ -402,6 +410,7 @@ var agentJobCreateRequestSchema = z2.strictObject({
|
|
|
402
410
|
providerProfileId: profileIdSchema2,
|
|
403
411
|
modelProfileId: profileIdSchema2,
|
|
404
412
|
providerDataConsent: z2.literal(true),
|
|
413
|
+
trustedFastModeConsent: z2.literal(true).optional(),
|
|
405
414
|
workingTreeMode: z2.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
406
415
|
});
|
|
407
416
|
var agentJobActionRequestSchema = z2.strictObject({});
|
|
@@ -566,6 +575,7 @@ var agentJobEventSchema = z3.discriminatedUnion("type", [
|
|
|
566
575
|
// src/product.ts
|
|
567
576
|
var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
568
577
|
export {
|
|
578
|
+
AGENT_APPLY_MODES,
|
|
569
579
|
AGENT_CAPABILITY_STATES,
|
|
570
580
|
AGENT_CHECK_STATUSES,
|
|
571
581
|
AGENT_FILE_CHANGE_KINDS,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors/spotpatch-error.ts","../src/errors/error-code.ts","../src/security/redaction.ts","../src/model/annotation.ts","../src/model/runtime-config.ts","../src/protocol/endpoints.ts","../src/model/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/requests.ts","../src/protocol/agent-schemas.ts","../src/product.ts"],"sourcesContent":["import type { ErrorCode } from \"./error-code.js\";\n\nexport class SpotPatchError extends Error {\n readonly code: ErrorCode;\n\n constructor(code: ErrorCode, message = code, options?: ErrorOptions) {\n super(message, options);\n this.name = \"SpotPatchError\";\n this.code = code;\n }\n}\n","export const ERROR_CODES = {\n INVALID_REQUEST: \"INVALID_REQUEST\",\n INVALID_TOKEN: \"INVALID_TOKEN\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n SOURCE_NOT_FOUND: \"SOURCE_NOT_FOUND\",\n SOURCE_OUTSIDE_ROOT: \"SOURCE_OUTSIDE_ROOT\",\n SOURCE_TOO_LARGE: \"SOURCE_TOO_LARGE\",\n EDITOR_OPEN_FAILED: \"EDITOR_OPEN_FAILED\",\n AI_DISABLED: \"AI_DISABLED\",\n PROVIDER_NOT_CONFIGURED: \"PROVIDER_NOT_CONFIGURED\",\n PROVIDER_AUTH_FAILED: \"PROVIDER_AUTH_FAILED\",\n PROVIDER_PROTOCOL_UNSUPPORTED: \"PROVIDER_PROTOCOL_UNSUPPORTED\",\n MODEL_NOT_ALLOWED: \"MODEL_NOT_ALLOWED\",\n MODEL_TOOL_CALL_UNSUPPORTED: \"MODEL_TOOL_CALL_UNSUPPORTED\",\n PROVIDER_RATE_LIMITED: \"PROVIDER_RATE_LIMITED\",\n AGENT_BUSY: \"AGENT_BUSY\",\n AGENT_LIMIT_EXCEEDED: \"AGENT_LIMIT_EXCEEDED\",\n AGENT_CANCELLED: \"AGENT_CANCELLED\",\n WORKTREE_DIRTY: \"WORKTREE_DIRTY\",\n WORKTREE_NOT_REPOSITORY: \"WORKTREE_NOT_REPOSITORY\",\n WORKTREE_OPERATION_IN_PROGRESS: \"WORKTREE_OPERATION_IN_PROGRESS\",\n WORKTREE_CONFLICTED: \"WORKTREE_CONFLICTED\",\n WORKTREE_LOCAL_CHANGES_TOO_LARGE: \"WORKTREE_LOCAL_CHANGES_TOO_LARGE\",\n WORKTREE_UNTRACKED_UNSUPPORTED: \"WORKTREE_UNTRACKED_UNSUPPORTED\",\n WORKTREE_LOCAL_CHANGES_UNSUPPORTED: \"WORKTREE_LOCAL_CHANGES_UNSUPPORTED\",\n TOOL_DENIED: \"TOOL_DENIED\",\n TOOL_INPUT_INVALID: \"TOOL_INPUT_INVALID\",\n TOOL_ARGUMENTS_INVALID: \"TOOL_ARGUMENTS_INVALID\",\n TOOL_CALL_ID_CONFLICT: \"TOOL_CALL_ID_CONFLICT\",\n TOOL_PATH_DENIED: \"TOOL_PATH_DENIED\",\n PATCH_REJECTED: \"PATCH_REJECTED\",\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n APPLY_CONFLICT: \"APPLY_CONFLICT\",\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n","const INLINE_DATA_PATTERN = /data:[^\\s\"'<>]*;base64,[a-z0-9+/_=-]+/giu;\nconst BLOB_URL_PATTERN = /blob:[^\\s\"'<>]+/giu;\nconst BEARER_PATTERN = /\\bbearer\\s+[a-z0-9._~+/-]+=*/giu;\nconst URL_CREDENTIAL_PATTERN = /\\b(https?:\\/\\/)[^/\\s:@]+:[^/\\s@]+@/giu;\nconst SECRET_ASSIGNMENT_PATTERN =\n /\\b(authorization|cookie|set-cookie|api[-_]?key|(?:access[-_]?|refresh[-_]?|auth[-_]?)?token|secret|password|default[-_]?value|value)\\b(\\s*[:=]\\s*)(\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*'|`(?:\\\\.|[^`\\\\\\r\\n])*`|[^\\s,;\"'<>]+)/giu;\nconst SENSITIVE_EXACT_NAMES = new Set([\n \"authorization\",\n \"cookie\",\n \"defaultvalue\",\n \"password\",\n \"setcookie\",\n \"value\",\n]);\nconst MAX_URL_CHARACTERS = 500;\n\nfunction compactName(name: string): string {\n return name.toLowerCase().replaceAll(/[-_:]/gu, \"\");\n}\n\nfunction truncate(value: string, maxCharacters: number): string {\n return value.length <= maxCharacters\n ? value\n : `${value.slice(0, Math.max(0, maxCharacters - 1))}…`;\n}\n\nexport function isSensitiveName(name: string): boolean {\n const compact = compactName(name);\n\n return (\n SENSITIVE_EXACT_NAMES.has(compact) ||\n compact.includes(\"apikey\") ||\n compact.includes(\"authorization\") ||\n compact.includes(\"secret\") ||\n compact.includes(\"token\")\n );\n}\n\nexport function redactSensitiveText(value: string): string {\n return value\n .replace(INLINE_DATA_PATTERN, \"[redacted inline data]\")\n .replace(BLOB_URL_PATTERN, \"[redacted blob URL]\")\n .replace(BEARER_PATTERN, \"Bearer [redacted]\")\n .replace(URL_CREDENTIAL_PATTERN, \"$1[redacted]@\")\n .replace(\n SECRET_ASSIGNMENT_PATTERN,\n (_match, name: string, separator: string, assignedValue: string) => {\n const quote = assignedValue.at(0);\n const quoted = quote === '\"' || quote === \"'\" || quote === \"`\";\n return `${name}${separator}${quoted ? quote : \"\"}[redacted]${quoted ? quote : \"\"}`;\n },\n );\n}\n\nfunction sanitizeParsedUrl(url: URL): string {\n url.username = \"\";\n url.password = \"\";\n\n for (const [name, value] of url.searchParams) {\n if (isSensitiveName(name)) {\n url.searchParams.set(name, \"[redacted]\");\n } else {\n url.searchParams.set(name, redactSensitiveText(value));\n }\n }\n\n if (/token|secret|authorization|api[-_]?key/iu.test(url.hash)) {\n url.hash = \"#[redacted]\";\n }\n\n return url.toString();\n}\n\nexport function sanitizeUrl(value: string, baseUrl: string): string {\n const trimmed = value.trim();\n\n if (/^(?:blob|data|javascript):/iu.test(trimmed)) {\n return \"[redacted URL]\";\n }\n\n const normalized = redactSensitiveText(trimmed);\n\n try {\n const parsed = new URL(normalized, baseUrl);\n const sanitized = sanitizeParsedUrl(parsed);\n const base = new URL(baseUrl);\n\n if (!/^[a-z][a-z\\d+.-]*:/iu.test(normalized) && parsed.origin === base.origin) {\n return `${parsed.pathname}${parsed.search}${parsed.hash}`;\n }\n\n return sanitized;\n } catch {\n return truncate(normalized, MAX_URL_CHARACTERS);\n }\n}\n","import type { CodeContext } from \"./code-context.js\";\nimport type { ReactContext, SourceRef } from \"./source-ref.js\";\nimport type { StyleContext } from \"./style-context.js\";\n\nexport interface PageContext {\n readonly url: string;\n readonly pathname: string;\n readonly title: string;\n readonly viewportWidth: number;\n readonly viewportHeight: number;\n readonly devicePixelRatio: number;\n}\n\nexport interface ElementContext {\n readonly tagName: string;\n readonly selector: string;\n readonly sanitizedHtml: string;\n readonly textPreview?: string;\n readonly role?: string;\n readonly rect: Readonly<{\n x: number;\n y: number;\n width: number;\n height: number;\n }>;\n}\n\n/** Protocol hard limit. Runtime configuration may choose a smaller limit. */\nexport const MAX_ANNOTATION_TARGETS = 20;\n\n/** Each target owns its requested change; the UI enforces the same bound. */\nexport const MAX_TARGET_INSTRUCTION_CHARACTERS = 2_000;\n\n/** Keeps the complete, atomic user intent within the prompt and request budgets. */\nexport const MAX_ANNOTATION_INSTRUCTION_CHARACTERS = 4_000;\n\nexport const SPOTPATCH_LOCALES = Object.freeze([\"en-US\", \"zh-CN\"] as const);\nexport type SpotPatchLocale = (typeof SPOTPATCH_LOCALES)[number];\nexport const SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([\n \"auto\",\n ...SPOTPATCH_LOCALES,\n] as const);\nexport type SpotPatchLocalePreference = (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n\nexport interface SpotTargetContext {\n readonly instruction: string;\n readonly source: SourceRef;\n readonly react: ReactContext;\n readonly element: ElementContext;\n readonly styles: StyleContext;\n readonly code?: CodeContext;\n readonly warnings: readonly string[];\n}\n\nexport interface SpotAnnotation {\n readonly schemaVersion: 3;\n readonly id: string;\n readonly locale: SpotPatchLocale;\n readonly page: Readonly<PageContext>;\n readonly targets: readonly SpotTargetContext[];\n readonly createdAt: string;\n}\n","import { z } from \"zod\";\n\nimport { SPOTPATCH_API_BASE } from \"../protocol/endpoints.js\";\nimport { MAX_ANNOTATION_TARGETS, SPOTPATCH_LOCALE_PREFERENCES } from \"./annotation.js\";\nimport { SPOTPATCH_EDITOR_PREFERENCES } from \"./editor.js\";\nimport type { ContextBudget } from \"./code-context.js\";\nimport type { RuntimeAiConfig } from \"./agent.js\";\n\nexport const SPOTPATCH_NEXT_BUNDLERS = Object.freeze([\"turbopack\", \"webpack\"] as const);\nexport const SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([\n \"app\",\n \"pages\",\n \"hybrid\",\n] as const);\n\nexport type SpotPatchNextBundler = (typeof SPOTPATCH_NEXT_BUNDLERS)[number];\nexport type SpotPatchNextRouterKind = (typeof SPOTPATCH_NEXT_ROUTER_KINDS)[number];\n\ninterface RuntimeConfigBase {\n readonly apiBase: typeof SPOTPATCH_API_BASE;\n readonly ai: RuntimeAiConfig;\n readonly budget: Readonly<ContextBudget>;\n readonly debug: boolean;\n readonly editor: (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n readonly frameworkVersion: string;\n readonly locale: (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n readonly maxTargets: number;\n readonly redact: boolean;\n readonly sessionToken: string;\n readonly shortcut: string;\n readonly spotPatchVersion: string;\n}\n\nexport type SpotPatchRuntimeConfig = RuntimeConfigBase &\n (\n | Readonly<{\n framework: \"vite\";\n }>\n | Readonly<{\n bundler: SpotPatchNextBundler;\n framework: \"next\";\n routerKind: SpotPatchNextRouterKind;\n }>\n );\n\nconst boundedText = (maximum: number): z.ZodString =>\n z.string().trim().min(1).max(maximum);\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);\nconst runtimeAiModelSchema = z.strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n});\nconst runtimeAiProviderSchema = z\n .strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n models: z.array(runtimeAiModelSchema).min(1).max(64),\n defaultModel: profileIdSchema,\n })\n .refine(\n ({ defaultModel, models }) =>\n models.some(({ id }) => id === defaultModel) &&\n new Set(models.map(({ id }) => id)).size === models.length,\n { message: \"Runtime AI model profiles are inconsistent.\" },\n );\nconst runtimeAiConfigSchema = z.discriminatedUnion(\"enabled\", [\n z.strictObject({ enabled: z.literal(false) }),\n z\n .strictObject({\n enabled: z.literal(true),\n providers: z.array(runtimeAiProviderSchema).min(1).max(32),\n defaultProvider: profileIdSchema,\n applyMode: z.enum([\"review\", \"auto\"]),\n })\n .refine(\n ({ defaultProvider, providers }) =>\n providers.some(({ id }) => id === defaultProvider) &&\n new Set(providers.map(({ id }) => id)).size === providers.length,\n { message: \"Runtime AI provider profiles are inconsistent.\" },\n ),\n]);\nconst positiveInteger = z.number().int().positive();\nconst runtimeConfigBaseShape = {\n apiBase: z.literal(SPOTPATCH_API_BASE),\n ai: runtimeAiConfigSchema,\n budget: z.strictObject({\n totalCharacters: positiveInteger,\n domCharacters: positiveInteger,\n cssCharacters: positiveInteger,\n codeCharacters: positiveInteger,\n maxCodeLines: positiveInteger,\n maxComponentDepth: positiveInteger,\n }),\n debug: z.boolean(),\n editor: z.enum(SPOTPATCH_EDITOR_PREFERENCES),\n frameworkVersion: boundedText(64),\n locale: z.enum(SPOTPATCH_LOCALE_PREFERENCES),\n maxTargets: z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),\n redact: z.boolean(),\n sessionToken: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/u),\n shortcut: boundedText(128),\n spotPatchVersion: boundedText(64),\n} as const;\n\nexport const runtimeConfigSchema: z.ZodType<SpotPatchRuntimeConfig> =\n z.discriminatedUnion(\"framework\", [\n z.strictObject({\n ...runtimeConfigBaseShape,\n framework: z.literal(\"vite\"),\n }),\n z.strictObject({\n ...runtimeConfigBaseShape,\n bundler: z.enum(SPOTPATCH_NEXT_BUNDLERS),\n framework: z.literal(\"next\"),\n routerKind: z.enum(SPOTPATCH_NEXT_ROUTER_KINDS),\n }),\n ]);\n","export const SPOTPATCH_API_BASE = \"/__spotpatch/v1\" as const;\nexport const SPOTPATCH_TOKEN_HEADER = \"X-SpotPatch-Token\" as const;\n\nexport const SPOTPATCH_ENDPOINTS = Object.freeze({\n bootstrap: `${SPOTPATCH_API_BASE}/bootstrap`,\n sourceContext: `${SPOTPATCH_API_BASE}/source-context`,\n openEditor: `${SPOTPATCH_API_BASE}/open-editor`,\n agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,\n agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,\n agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`,\n});\n\nexport type AgentJobAction = \"events\" | \"result\" | \"cancel\" | \"apply\" | \"revert\";\n\nexport function getAgentJobEndpoint(jobId: string, action: AgentJobAction): string {\n return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;\n}\n","export const SPOTPATCH_EDITOR_PREFERENCES = [\"auto\", \"vscode\", \"cursor\"] as const;\n\nexport type SpotPatchEditorPreference = (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n\nexport interface EditorOpenResult {\n readonly editor: SpotPatchEditorPreference;\n}\n","import type { ErrorCode } from \"../errors/error-code.js\";\n\nexport type AiProviderProtocol = \"responses\" | \"chat-completions\";\nexport type AiProviderAuthentication = \"bearer\" | \"x-api-key\";\nexport type AgentApplyMode = \"review\" | \"auto\";\nexport type AgentWorkingTreeMode = \"require-clean\" | \"include-local-changes\";\n\nexport interface AiModelProfile {\n readonly label: string;\n readonly model: string;\n}\n\nexport interface OpenAICompatibleProviderOptions {\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication?: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, AiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface AgentCheckDefinition {\n readonly label: string;\n readonly command: string;\n readonly args?: readonly string[];\n readonly required?: boolean;\n readonly timeoutMs?: number;\n}\n\nexport interface AgentLimits {\n readonly maxTurns: number;\n readonly maxToolCalls: number;\n readonly maxChangedFiles: number;\n readonly maxDiffBytes: number;\n readonly maxReadBytesPerFile: number;\n readonly maxToolOutputCharacters: number;\n readonly maxProviderResponseBytes: number;\n readonly providerConnectTimeoutMs: number;\n readonly providerFirstByteTimeoutMs: number;\n readonly providerIdleTimeoutMs: number;\n readonly checkTimeoutMs: number;\n readonly jobTimeoutMs: number;\n}\n\nexport const DEFAULT_AGENT_LIMITS = Object.freeze({\n maxTurns: 20,\n maxToolCalls: 80,\n maxChangedFiles: 20,\n maxDiffBytes: 512_000,\n maxReadBytesPerFile: 256_000,\n maxToolOutputCharacters: 40_000,\n maxProviderResponseBytes: 2_000_000,\n providerConnectTimeoutMs: 15_000,\n providerFirstByteTimeoutMs: 30_000,\n providerIdleTimeoutMs: 60_000,\n checkTimeoutMs: 120_000,\n jobTimeoutMs: 600_000,\n} satisfies AgentLimits);\n\nexport interface AiExecutionOptions {\n readonly isolation?: \"git-worktree\";\n readonly applyMode?: AgentApplyMode;\n readonly checks?: Readonly<Record<string, AgentCheckDefinition>>;\n readonly limits?: Partial<AgentLimits>;\n}\n\nexport interface AiOptions {\n readonly providers: Readonly<Record<string, OpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution?: AiExecutionOptions;\n}\n\nexport interface ResolvedAiModelProfile extends AiModelProfile {\n readonly id: string;\n}\n\nexport interface ResolvedOpenAICompatibleProviderOptions {\n readonly id: string;\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, ResolvedAiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface ResolvedAgentCheckDefinition {\n readonly id: string;\n readonly label: string;\n readonly command: string;\n readonly args: readonly string[];\n readonly required: boolean;\n readonly timeoutMs: number;\n}\n\nexport interface ResolvedAiExecutionOptions {\n readonly isolation: \"git-worktree\";\n readonly applyMode: AgentApplyMode;\n readonly checks: Readonly<Record<string, ResolvedAgentCheckDefinition>>;\n readonly limits: Readonly<AgentLimits>;\n}\n\nexport interface ResolvedAiOptions {\n readonly providers: Readonly<Record<string, ResolvedOpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution: ResolvedAiExecutionOptions;\n}\n\nexport interface RuntimeAiModelProfile {\n readonly id: string;\n readonly label: string;\n}\n\nexport interface RuntimeAiProviderProfile {\n readonly id: string;\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly models: readonly RuntimeAiModelProfile[];\n readonly defaultModel: string;\n}\n\nexport type RuntimeAiConfig =\n | Readonly<{ enabled: false }>\n | Readonly<{\n enabled: true;\n providers: readonly RuntimeAiProviderProfile[];\n defaultProvider: string;\n applyMode: AgentApplyMode;\n }>;\n\nexport const AGENT_JOB_STATUSES = Object.freeze([\n \"queued\",\n \"preparing\",\n \"running\",\n \"validating\",\n \"awaiting-review\",\n \"applying\",\n \"applied\",\n \"completed\",\n \"cancelling\",\n \"cancelled\",\n \"reverting\",\n \"reverted\",\n \"failed\",\n] as const);\n\nexport type AgentJobStatus = (typeof AGENT_JOB_STATUSES)[number];\n\nexport const AGENT_CAPABILITY_STATES = Object.freeze([\n \"unknown\",\n \"probing\",\n \"agent-ready\",\n \"prompt-only\",\n \"unavailable\",\n] as const);\n\nexport type AgentCapabilityState = (typeof AGENT_CAPABILITY_STATES)[number];\n\nexport interface AgentCapabilitySnapshot {\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly protocol: AiProviderProtocol;\n readonly state: AgentCapabilityState;\n readonly authenticated: boolean;\n readonly modelAvailable: boolean;\n readonly toolCalling: boolean;\n readonly toolResultContinuation: boolean;\n readonly streaming: boolean;\n readonly checkedAt?: string;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_WORKSPACE_STATES = Object.freeze([\n \"ready\",\n \"consent-required\",\n \"blocked\",\n] as const);\n\nexport const AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({\n maxUntrackedFiles: 1_000,\n maxUntrackedBytes: 20 * 1024 * 1024,\n});\n\nexport type AgentWorkspaceState = (typeof AGENT_WORKSPACE_STATES)[number];\n\nexport interface AgentWorkspaceChangeSummary {\n readonly staged: number;\n readonly unstaged: number;\n readonly untracked: number;\n readonly conflicted: number;\n readonly total: number;\n}\n\nexport interface AgentWorkspaceHealthSnapshot {\n readonly state: AgentWorkspaceState;\n readonly checkedAt: string;\n readonly changes: AgentWorkspaceChangeSummary;\n readonly canIncludeLocalChanges: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_FILE_CHANGE_KINDS = Object.freeze([\n \"added\",\n \"modified\",\n \"deleted\",\n] as const);\n\nexport type AgentFileChangeKind = (typeof AGENT_FILE_CHANGE_KINDS)[number];\n\nexport const AGENT_CHECK_STATUSES = Object.freeze([\n \"passed\",\n \"failed\",\n \"cancelled\",\n \"timed-out\",\n] as const);\n\nexport type AgentCheckStatus = (typeof AGENT_CHECK_STATUSES)[number];\n\nexport interface AgentChangedFile {\n readonly relativePath: string;\n readonly kind: AgentFileChangeKind;\n readonly additions: number;\n readonly deletions: number;\n}\n\nexport interface AgentCheckResult {\n readonly checkId: string;\n readonly label: string;\n readonly status: AgentCheckStatus;\n readonly durationMs: number;\n readonly output: string;\n}\n\nexport interface AgentJobSnapshot {\n readonly jobId: string;\n readonly status: AgentJobStatus;\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly phaseMessage: string;\n readonly createdAt: string;\n readonly updatedAt: string;\n readonly canCancel: boolean;\n readonly canApply: boolean;\n readonly canRevert: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport interface AgentJobResult {\n readonly jobId: string;\n readonly summary: string;\n readonly diff: string;\n readonly files: readonly AgentChangedFile[];\n readonly checks: readonly AgentCheckResult[];\n}\n\nexport interface AgentJobResultResponse {\n readonly snapshot: AgentJobSnapshot;\n readonly result?: AgentJobResult;\n}\n","export const SOURCE_MARKER_ATTRIBUTE = \"data-spotpatch-source\" as const;\n\nconst SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\\d*):([1-9]\\d*)$/;\n\nexport interface SourceMarker {\n readonly fileId: string;\n readonly line: number;\n readonly column: number;\n}\n\nexport function formatSourceMarker(marker: SourceMarker): string {\n return [marker.fileId, String(marker.line), String(marker.column)].join(\":\");\n}\n\nexport function parseSourceMarker(value: string | null): SourceMarker | undefined {\n if (value === null) {\n return undefined;\n }\n\n const match = SOURCE_MARKER_PATTERN.exec(value);\n\n if (match === null) {\n return undefined;\n }\n\n const fileId = match[1];\n const line = Number(match[2]);\n const column = Number(match[3]);\n\n if (\n fileId === undefined ||\n !Number.isSafeInteger(line) ||\n !Number.isSafeInteger(column)\n ) {\n return undefined;\n }\n\n return Object.freeze({ fileId, line, column });\n}\n","import { z } from \"zod\";\n\nimport {\n MAX_ANNOTATION_INSTRUCTION_CHARACTERS,\n MAX_ANNOTATION_TARGETS,\n MAX_TARGET_INSTRUCTION_CHARACTERS,\n SPOTPATCH_LOCALES,\n type SpotAnnotation,\n} from \"../model/annotation.js\";\n\nexport const runtimeBootstrapRequestSchema = z.strictObject({});\n\nconst sourceCoordinatesSchema = z.strictObject({\n fileId: z.string().min(1).max(128),\n line: z.number().int().positive(),\n column: z.number().int().positive(),\n});\n\nexport const sourceContextRequestSchema = sourceCoordinatesSchema\n .extend({\n maxLines: z.number().int().positive(),\n })\n .strict();\n\nexport const openEditorRequestSchema = sourceCoordinatesSchema.strict();\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\n\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst sourceRefSchema = z.strictObject({\n fileId: boundedString(128).optional(),\n relativePath: boundedString(1_024).optional(),\n line: z.number().int().positive().optional(),\n column: z.number().int().positive().optional(),\n origin: z.enum([\"jsx-host\", \"react-fiber\", \"dom-ancestor\", \"none\"]),\n confidence: z.enum([\"exact\", \"probable\", \"approximate\", \"unknown\"]),\n});\nconst matchedStyleRuleSchema = z.strictObject({\n selector: boundedString(2_048),\n declarations: boundedString(8_192),\n source: boundedString(1_024).optional(),\n media: boundedString(1_024).optional(),\n});\nconst codeContextSchema = z.strictObject({\n relativePath: boundedString(1_024),\n language: z.enum([\"tsx\", \"jsx\"]),\n startLine: z.number().int().positive(),\n endLine: z.number().int().positive(),\n excerpt: boundedString(16_000),\n boundary: z.enum([\"component\", \"nearby-lines\"]),\n});\n\nexport const spotTargetContextRequestSchema = z.strictObject({\n instruction: z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),\n source: sourceRefSchema,\n react: z.strictObject({\n supported: z.boolean(),\n version: boundedString(64).optional(),\n componentName: boundedString(256).optional(),\n componentStack: z.array(boundedString(256)).max(64),\n source: sourceRefSchema.optional(),\n }),\n element: z.strictObject({\n tagName: boundedString(128),\n selector: boundedString(2_048),\n sanitizedHtml: boundedString(8_192),\n textPreview: boundedString(2_048).optional(),\n role: boundedString(256).optional(),\n rect: z.strictObject({\n x: z.number(),\n y: z.number(),\n width: z.number().nonnegative(),\n height: z.number().nonnegative(),\n }),\n }),\n styles: z.strictObject({\n classNames: z.array(boundedString(512)).max(256),\n inlineStyle: boundedString(8_192).optional(),\n matchedRules: z.array(matchedStyleRuleSchema).max(256),\n computed: z.record(boundedString(256), boundedString(2_048)),\n warnings: z.array(boundedString(1_024)).max(64),\n }),\n code: codeContextSchema.optional(),\n warnings: z.array(boundedString(1_024)).max(64),\n});\n\nexport const spotAnnotationRequestSchema = z\n .strictObject({\n schemaVersion: z.literal(3),\n id: boundedString(128),\n locale: z.enum(SPOTPATCH_LOCALES),\n page: z.strictObject({\n url: boundedString(2_048),\n pathname: boundedString(2_048),\n title: boundedString(1_024),\n viewportWidth: z.number().nonnegative(),\n viewportHeight: z.number().nonnegative(),\n devicePixelRatio: z.number().positive(),\n }),\n targets: z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),\n createdAt: z.iso.datetime(),\n })\n .superRefine((annotation, context) => {\n const total = annotation.targets.reduce(\n (characters, target) => characters + target.instruction.length,\n 0,\n );\n\n if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {\n context.addIssue({\n code: \"custom\",\n message: \"Combined target instructions exceed the annotation limit.\",\n path: [\"targets\"],\n });\n }\n });\n\nexport const agentCapabilityRequestSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n});\n\nexport const agentWorkspaceHealthRequestSchema = z.strictObject({});\n\nexport const agentJobCreateRequestSchema = z.strictObject({\n annotation: spotAnnotationRequestSchema,\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n providerDataConsent: z.literal(true),\n workingTreeMode: z\n .enum([\"require-clean\", \"include-local-changes\"])\n .default(\"require-clean\"),\n});\n\nexport const agentJobActionRequestSchema = z.strictObject({});\n\nexport type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;\nexport type RuntimeBootstrapRequest = z.infer<typeof runtimeBootstrapRequestSchema>;\nexport type OpenEditorRequest = z.infer<typeof openEditorRequestSchema>;\nexport type AgentCapabilityRequest = z.infer<typeof agentCapabilityRequestSchema>;\nexport interface AgentJobCreateRequest {\n readonly annotation: SpotAnnotation;\n readonly providerProfileId: string;\n readonly modelProfileId: string;\n readonly providerDataConsent: true;\n readonly workingTreeMode: \"require-clean\" | \"include-local-changes\";\n}\n","import { z } from \"zod\";\n\nimport { ERROR_CODES } from \"../errors/error-code.js\";\nimport {\n AGENT_CAPABILITY_STATES,\n AGENT_CHECK_STATUSES,\n AGENT_FILE_CHANGE_KINDS,\n AGENT_JOB_STATUSES,\n AGENT_WORKSPACE_STATES,\n} from \"../model/agent.js\";\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst errorCodeSchema = z.enum(ERROR_CODES);\n\nexport const agentCapabilitySnapshotSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n state: z.enum(AGENT_CAPABILITY_STATES),\n authenticated: z.boolean(),\n modelAvailable: z.boolean(),\n toolCalling: z.boolean(),\n toolResultContinuation: z.boolean(),\n streaming: z.boolean(),\n checkedAt: z.iso.datetime().optional(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentWorkspaceHealthSnapshotSchema = z\n .strictObject({\n state: z.enum(AGENT_WORKSPACE_STATES),\n checkedAt: z.iso.datetime(),\n changes: z.strictObject({\n staged: z.number().int().nonnegative(),\n unstaged: z.number().int().nonnegative(),\n untracked: z.number().int().nonnegative(),\n conflicted: z.number().int().nonnegative(),\n total: z.number().int().nonnegative(),\n }),\n canIncludeLocalChanges: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n })\n .refine(\n ({ state, changes, canIncludeLocalChanges, errorCode }) => {\n const countsAreConsistent =\n changes.total >= changes.staged &&\n changes.total >= changes.unstaged &&\n changes.total >= changes.untracked &&\n changes.total >= changes.conflicted &&\n changes.total <= changes.staged + changes.unstaged + changes.untracked;\n\n if (!countsAreConsistent) {\n return false;\n }\n\n if (state === \"ready\") {\n return (\n changes.total === 0 && !canIncludeLocalChanges && errorCode === undefined\n );\n }\n\n if (state === \"consent-required\") {\n return (\n changes.total > 0 &&\n changes.conflicted === 0 &&\n canIncludeLocalChanges &&\n errorCode === undefined\n );\n }\n\n return !canIncludeLocalChanges && errorCode !== undefined;\n },\n { message: \"Agent workspace health fields are inconsistent.\" },\n );\n\nexport const agentChangedFileSchema = z.strictObject({\n relativePath: boundedString(1_024),\n kind: z.enum(AGENT_FILE_CHANGE_KINDS),\n additions: z.number().int().nonnegative(),\n deletions: z.number().int().nonnegative(),\n});\n\nexport const agentCheckResultSchema = z.strictObject({\n checkId: profileIdSchema,\n label: boundedString(100),\n status: z.enum(AGENT_CHECK_STATUSES),\n durationMs: z.number().int().nonnegative(),\n output: boundedString(80_000),\n});\n\nexport const agentJobSnapshotSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n phaseMessage: boundedString(1_024),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n canCancel: z.boolean(),\n canApply: z.boolean(),\n canRevert: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentJobResultSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n summary: boundedString(80_000),\n diff: boundedString(1_000_000),\n files: z.array(agentChangedFileSchema).max(100),\n checks: z.array(agentCheckResultSchema).max(100),\n});\n\nexport const agentJobResultResponseSchema = z\n .strictObject({\n snapshot: agentJobSnapshotSchema,\n result: agentJobResultSchema.optional(),\n })\n .superRefine((value, context) => {\n if (value.result !== undefined && value.result.jobId !== value.snapshot.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent result and snapshot job IDs must match.\",\n path: [\"result\", \"jobId\"],\n });\n }\n });\n\nconst agentJobEventBaseSchema = z.strictObject({\n schemaVersion: z.literal(2),\n sequence: z.number().int().positive(),\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n timestamp: z.iso.datetime(),\n});\n\nexport const agentJobEventSchema = z\n .discriminatedUnion(\"type\", [\n agentJobEventBaseSchema.extend({\n type: z.literal(\"snapshot\"),\n data: z.strictObject({ snapshot: agentJobSnapshotSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"phase\"),\n data: z.strictObject({ message: boundedString(1_024) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"tool\"),\n data: z.strictObject({\n turn: z.number().int().positive(),\n toolCallId: boundedString(256),\n toolName: boundedString(100),\n state: z.enum([\"started\", \"succeeded\", \"failed\"]),\n relativePath: boundedString(1_024).optional(),\n checkLabel: boundedString(100).optional(),\n }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"check\"),\n data: z.strictObject({ result: agentCheckResultSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"result-ready\"),\n data: z.strictObject({ hasResult: z.literal(true) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"error\"),\n data: z.strictObject({\n code: errorCodeSchema,\n message: boundedString(1_024),\n }),\n }),\n ])\n .superRefine((event, context) => {\n if (event.type !== \"snapshot\") {\n return;\n }\n\n if (event.data.snapshot.jobId !== event.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot job IDs must match.\",\n path: [\"data\", \"snapshot\", \"jobId\"],\n });\n }\n\n if (event.data.snapshot.status !== event.status) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot statuses must match.\",\n path: [\"data\", \"snapshot\", \"status\"],\n });\n }\n });\n","export const SPOTPATCH_REPOSITORY_URL =\n \"https://github.com/huanglvjing/spotpatch\" as const;\n"],"mappings":";AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAC/B;AAAA,EAET,YAAY,MAAiB,UAAU,MAAM,SAAwB;AACnE,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;;;ACVO,IAAM,cAAc;AAAA,EACzB,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,+BAA+B;AAAA,EAC/B,mBAAmB;AAAA,EACnB,6BAA6B;AAAA,EA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IAAK;AAAA,IAC9B,CAAC;AAAA,EACH,CAAC;AACH,CAAC,EACA,YAAY,CAAC,OAAO,YAAY;AAC/B,MAAI,MAAM,SAAS,YAAY;AAC7B;AAAA,EACF;AAEA,MAAI,MAAM,KAAK,SAAS,UAAU,MAAM,OAAO;AAC7C,YAAQ,SAAS;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM,CAAC,QAAQ,YAAY,OAAO;AAAA,IACpC,CAAC;AAAA,EACH;AAEA,MAAI,MAAM,KAAK,SAAS,WAAW,MAAM,QAAQ;AAC/C,YAAQ,SAAS;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM,CAAC,QAAQ,YAAY,QAAQ;AAAA,IACrC,CAAC;AAAA,EACH;AACF,CAAC;;;ACrNI,IAAM,2BACX;","names":["z","z","profileIdSchema","z","profileIdSchema","z","boundedString"]}
|
|
1
|
+
{"version":3,"sources":["../src/errors/spotpatch-error.ts","../src/errors/error-code.ts","../src/security/redaction.ts","../src/model/annotation.ts","../src/model/runtime-config.ts","../src/protocol/endpoints.ts","../src/model/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/requests.ts","../src/protocol/agent-schemas.ts","../src/product.ts"],"sourcesContent":["import type { ErrorCode } from \"./error-code.js\";\n\nexport class SpotPatchError extends Error {\n readonly code: ErrorCode;\n\n constructor(code: ErrorCode, message = code, options?: ErrorOptions) {\n super(message, options);\n this.name = \"SpotPatchError\";\n this.code = code;\n }\n}\n","export const ERROR_CODES = {\n INVALID_REQUEST: \"INVALID_REQUEST\",\n INVALID_TOKEN: \"INVALID_TOKEN\",\n ORIGIN_NOT_ALLOWED: \"ORIGIN_NOT_ALLOWED\",\n SOURCE_NOT_FOUND: \"SOURCE_NOT_FOUND\",\n SOURCE_OUTSIDE_ROOT: \"SOURCE_OUTSIDE_ROOT\",\n SOURCE_TOO_LARGE: \"SOURCE_TOO_LARGE\",\n EDITOR_OPEN_FAILED: \"EDITOR_OPEN_FAILED\",\n AI_DISABLED: \"AI_DISABLED\",\n PROVIDER_NOT_CONFIGURED: \"PROVIDER_NOT_CONFIGURED\",\n PROVIDER_AUTH_FAILED: \"PROVIDER_AUTH_FAILED\",\n PROVIDER_PROTOCOL_UNSUPPORTED: \"PROVIDER_PROTOCOL_UNSUPPORTED\",\n MODEL_NOT_ALLOWED: \"MODEL_NOT_ALLOWED\",\n MODEL_TOOL_CALL_UNSUPPORTED: \"MODEL_TOOL_CALL_UNSUPPORTED\",\n PROVIDER_RATE_LIMITED: \"PROVIDER_RATE_LIMITED\",\n AGENT_BUSY: \"AGENT_BUSY\",\n AGENT_LIMIT_EXCEEDED: \"AGENT_LIMIT_EXCEEDED\",\n AGENT_CANCELLED: \"AGENT_CANCELLED\",\n WORKTREE_DIRTY: \"WORKTREE_DIRTY\",\n WORKTREE_NOT_REPOSITORY: \"WORKTREE_NOT_REPOSITORY\",\n WORKTREE_OPERATION_IN_PROGRESS: \"WORKTREE_OPERATION_IN_PROGRESS\",\n WORKTREE_CONFLICTED: \"WORKTREE_CONFLICTED\",\n WORKTREE_LOCAL_CHANGES_TOO_LARGE: \"WORKTREE_LOCAL_CHANGES_TOO_LARGE\",\n WORKTREE_UNTRACKED_UNSUPPORTED: \"WORKTREE_UNTRACKED_UNSUPPORTED\",\n WORKTREE_LOCAL_CHANGES_UNSUPPORTED: \"WORKTREE_LOCAL_CHANGES_UNSUPPORTED\",\n TOOL_DENIED: \"TOOL_DENIED\",\n TOOL_INPUT_INVALID: \"TOOL_INPUT_INVALID\",\n TOOL_ARGUMENTS_INVALID: \"TOOL_ARGUMENTS_INVALID\",\n TOOL_CALL_ID_CONFLICT: \"TOOL_CALL_ID_CONFLICT\",\n TOOL_PATH_DENIED: \"TOOL_PATH_DENIED\",\n PATCH_REJECTED: \"PATCH_REJECTED\",\n VALIDATION_FAILED: \"VALIDATION_FAILED\",\n APPLY_CONFLICT: \"APPLY_CONFLICT\",\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n","const INLINE_DATA_PATTERN = /data:[^\\s\"'<>]*;base64,[a-z0-9+/_=-]+/giu;\nconst BLOB_URL_PATTERN = /blob:[^\\s\"'<>]+/giu;\nconst BEARER_PATTERN = /\\bbearer\\s+[a-z0-9._~+/-]+=*/giu;\nconst URL_CREDENTIAL_PATTERN = /\\b(https?:\\/\\/)[^/\\s:@]+:[^/\\s@]+@/giu;\nconst SECRET_ASSIGNMENT_PATTERN =\n /\\b(authorization|cookie|set-cookie|api[-_]?key|(?:access[-_]?|refresh[-_]?|auth[-_]?)?token|secret|password|default[-_]?value|value)\\b(\\s*[:=]\\s*)(\"(?:\\\\.|[^\"\\\\\\r\\n])*\"|'(?:\\\\.|[^'\\\\\\r\\n])*'|`(?:\\\\.|[^`\\\\\\r\\n])*`|[^\\s,;\"'<>]+)/giu;\nconst SENSITIVE_EXACT_NAMES = new Set([\n \"authorization\",\n \"cookie\",\n \"defaultvalue\",\n \"password\",\n \"setcookie\",\n \"value\",\n]);\nconst MAX_URL_CHARACTERS = 500;\n\nfunction compactName(name: string): string {\n return name.toLowerCase().replaceAll(/[-_:]/gu, \"\");\n}\n\nfunction truncate(value: string, maxCharacters: number): string {\n return value.length <= maxCharacters\n ? value\n : `${value.slice(0, Math.max(0, maxCharacters - 1))}…`;\n}\n\nexport function isSensitiveName(name: string): boolean {\n const compact = compactName(name);\n\n return (\n SENSITIVE_EXACT_NAMES.has(compact) ||\n compact.includes(\"apikey\") ||\n compact.includes(\"authorization\") ||\n compact.includes(\"secret\") ||\n compact.includes(\"token\")\n );\n}\n\nexport function redactSensitiveText(value: string): string {\n return value\n .replace(INLINE_DATA_PATTERN, \"[redacted inline data]\")\n .replace(BLOB_URL_PATTERN, \"[redacted blob URL]\")\n .replace(BEARER_PATTERN, \"Bearer [redacted]\")\n .replace(URL_CREDENTIAL_PATTERN, \"$1[redacted]@\")\n .replace(\n SECRET_ASSIGNMENT_PATTERN,\n (_match, name: string, separator: string, assignedValue: string) => {\n const quote = assignedValue.at(0);\n const quoted = quote === '\"' || quote === \"'\" || quote === \"`\";\n return `${name}${separator}${quoted ? quote : \"\"}[redacted]${quoted ? quote : \"\"}`;\n },\n );\n}\n\nfunction sanitizeParsedUrl(url: URL): string {\n url.username = \"\";\n url.password = \"\";\n\n for (const [name, value] of url.searchParams) {\n if (isSensitiveName(name)) {\n url.searchParams.set(name, \"[redacted]\");\n } else {\n url.searchParams.set(name, redactSensitiveText(value));\n }\n }\n\n if (/token|secret|authorization|api[-_]?key/iu.test(url.hash)) {\n url.hash = \"#[redacted]\";\n }\n\n return url.toString();\n}\n\nexport function sanitizeUrl(value: string, baseUrl: string): string {\n const trimmed = value.trim();\n\n if (/^(?:blob|data|javascript):/iu.test(trimmed)) {\n return \"[redacted URL]\";\n }\n\n const normalized = redactSensitiveText(trimmed);\n\n try {\n const parsed = new URL(normalized, baseUrl);\n const sanitized = sanitizeParsedUrl(parsed);\n const base = new URL(baseUrl);\n\n if (!/^[a-z][a-z\\d+.-]*:/iu.test(normalized) && parsed.origin === base.origin) {\n return `${parsed.pathname}${parsed.search}${parsed.hash}`;\n }\n\n return sanitized;\n } catch {\n return truncate(normalized, MAX_URL_CHARACTERS);\n }\n}\n","import type { CodeContext } from \"./code-context.js\";\nimport type { ReactContext, SourceRef } from \"./source-ref.js\";\nimport type { StyleContext } from \"./style-context.js\";\n\nexport interface PageContext {\n readonly url: string;\n readonly pathname: string;\n readonly title: string;\n readonly viewportWidth: number;\n readonly viewportHeight: number;\n readonly devicePixelRatio: number;\n}\n\nexport interface ElementContext {\n readonly tagName: string;\n readonly selector: string;\n readonly sanitizedHtml: string;\n readonly textPreview?: string;\n readonly role?: string;\n readonly rect: Readonly<{\n x: number;\n y: number;\n width: number;\n height: number;\n }>;\n}\n\n/** Protocol hard limit. Runtime configuration may choose a smaller limit. */\nexport const MAX_ANNOTATION_TARGETS = 20;\n\n/** Each target owns its requested change; the UI enforces the same bound. */\nexport const MAX_TARGET_INSTRUCTION_CHARACTERS = 2_000;\n\n/** Keeps the complete, atomic user intent within the prompt and request budgets. */\nexport const MAX_ANNOTATION_INSTRUCTION_CHARACTERS = 4_000;\n\nexport const SPOTPATCH_LOCALES = Object.freeze([\"en-US\", \"zh-CN\"] as const);\nexport type SpotPatchLocale = (typeof SPOTPATCH_LOCALES)[number];\nexport const SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([\n \"auto\",\n ...SPOTPATCH_LOCALES,\n] as const);\nexport type SpotPatchLocalePreference = (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n\nexport interface SpotTargetContext {\n readonly instruction: string;\n readonly page?: Readonly<PageContext>;\n readonly source: SourceRef;\n readonly react: ReactContext;\n readonly element: ElementContext;\n readonly styles: StyleContext;\n readonly code?: CodeContext;\n readonly warnings: readonly string[];\n}\n\nexport interface SpotAnnotation {\n readonly schemaVersion: 3;\n readonly id: string;\n readonly locale: SpotPatchLocale;\n readonly page: Readonly<PageContext>;\n readonly targets: readonly SpotTargetContext[];\n readonly createdAt: string;\n}\n","import { z } from \"zod\";\n\nimport { SPOTPATCH_API_BASE } from \"../protocol/endpoints.js\";\nimport { MAX_ANNOTATION_TARGETS, SPOTPATCH_LOCALE_PREFERENCES } from \"./annotation.js\";\nimport { SPOTPATCH_EDITOR_PREFERENCES } from \"./editor.js\";\nimport type { ContextBudget } from \"./code-context.js\";\nimport { AGENT_APPLY_MODES, type RuntimeAiConfig } from \"./agent.js\";\n\nexport const SPOTPATCH_NEXT_BUNDLERS = Object.freeze([\"turbopack\", \"webpack\"] as const);\nexport const SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([\n \"app\",\n \"pages\",\n \"hybrid\",\n] as const);\n\nexport type SpotPatchNextBundler = (typeof SPOTPATCH_NEXT_BUNDLERS)[number];\nexport type SpotPatchNextRouterKind = (typeof SPOTPATCH_NEXT_ROUTER_KINDS)[number];\n\ninterface RuntimeConfigBase {\n readonly apiBase: typeof SPOTPATCH_API_BASE;\n readonly ai: RuntimeAiConfig;\n readonly budget: Readonly<ContextBudget>;\n readonly debug: boolean;\n readonly editor: (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n readonly frameworkVersion: string;\n readonly locale: (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];\n readonly maxTargets: number;\n readonly redact: boolean;\n readonly sessionId: string;\n readonly sessionToken: string;\n readonly shortcut: string;\n readonly spotPatchVersion: string;\n}\n\nexport type SpotPatchRuntimeConfig = RuntimeConfigBase &\n (\n | Readonly<{\n framework: \"vite\";\n }>\n | Readonly<{\n bundler: SpotPatchNextBundler;\n framework: \"next\";\n routerKind: SpotPatchNextRouterKind;\n }>\n );\n\nconst boundedText = (maximum: number): z.ZodString =>\n z.string().trim().min(1).max(maximum);\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);\nconst runtimeAiModelSchema = z.strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n});\nconst runtimeAiProviderSchema = z\n .strictObject({\n id: profileIdSchema,\n label: boundedText(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n models: z.array(runtimeAiModelSchema).min(1).max(64),\n defaultModel: profileIdSchema,\n })\n .refine(\n ({ defaultModel, models }) =>\n models.some(({ id }) => id === defaultModel) &&\n new Set(models.map(({ id }) => id)).size === models.length,\n { message: \"Runtime AI model profiles are inconsistent.\" },\n );\nconst runtimeAiConfigSchema = z.discriminatedUnion(\"enabled\", [\n z.strictObject({ enabled: z.literal(false) }),\n z\n .strictObject({\n enabled: z.literal(true),\n providers: z.array(runtimeAiProviderSchema).min(1).max(32),\n defaultProvider: profileIdSchema,\n applyMode: z.enum(AGENT_APPLY_MODES),\n })\n .refine(\n ({ defaultProvider, providers }) =>\n providers.some(({ id }) => id === defaultProvider) &&\n new Set(providers.map(({ id }) => id)).size === providers.length,\n { message: \"Runtime AI provider profiles are inconsistent.\" },\n ),\n]);\nconst positiveInteger = z.number().int().positive();\nconst runtimeConfigBaseShape = {\n apiBase: z.literal(SPOTPATCH_API_BASE),\n ai: runtimeAiConfigSchema,\n budget: z.strictObject({\n totalCharacters: positiveInteger,\n domCharacters: positiveInteger,\n cssCharacters: positiveInteger,\n codeCharacters: positiveInteger,\n maxCodeLines: positiveInteger,\n maxComponentDepth: positiveInteger,\n }),\n debug: z.boolean(),\n editor: z.enum(SPOTPATCH_EDITOR_PREFERENCES),\n frameworkVersion: boundedText(64),\n locale: z.enum(SPOTPATCH_LOCALE_PREFERENCES),\n maxTargets: z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),\n redact: z.boolean(),\n sessionId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/u),\n sessionToken: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/u),\n shortcut: boundedText(128),\n spotPatchVersion: boundedText(64),\n} as const;\n\nexport const runtimeConfigSchema: z.ZodType<SpotPatchRuntimeConfig> =\n z.discriminatedUnion(\"framework\", [\n z.strictObject({\n ...runtimeConfigBaseShape,\n framework: z.literal(\"vite\"),\n }),\n z.strictObject({\n ...runtimeConfigBaseShape,\n bundler: z.enum(SPOTPATCH_NEXT_BUNDLERS),\n framework: z.literal(\"next\"),\n routerKind: z.enum(SPOTPATCH_NEXT_ROUTER_KINDS),\n }),\n ]);\n","export const SPOTPATCH_API_BASE = \"/__spotpatch/v1\" as const;\nexport const SPOTPATCH_TOKEN_HEADER = \"X-SpotPatch-Token\" as const;\n\nexport const SPOTPATCH_ENDPOINTS = Object.freeze({\n bootstrap: `${SPOTPATCH_API_BASE}/bootstrap`,\n sourceContext: `${SPOTPATCH_API_BASE}/source-context`,\n openEditor: `${SPOTPATCH_API_BASE}/open-editor`,\n agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,\n agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,\n agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`,\n});\n\nexport type AgentJobAction = \"events\" | \"result\" | \"cancel\" | \"apply\" | \"revert\";\n\nexport function getAgentJobEndpoint(jobId: string, action: AgentJobAction): string {\n return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;\n}\n","export const SPOTPATCH_EDITOR_PREFERENCES = [\"auto\", \"vscode\", \"cursor\"] as const;\n\nexport type SpotPatchEditorPreference = (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];\n\nexport interface EditorOpenResult {\n readonly editor: SpotPatchEditorPreference;\n}\n","import type { ErrorCode } from \"../errors/error-code.js\";\n\nexport type AiProviderProtocol = \"responses\" | \"chat-completions\";\nexport type AiProviderAuthentication = \"bearer\" | \"x-api-key\";\nexport const AGENT_APPLY_MODES = Object.freeze([\n \"review\",\n \"auto\",\n \"trusted-auto\",\n] as const);\nexport type AgentApplyMode = (typeof AGENT_APPLY_MODES)[number];\nexport type AgentWorkingTreeMode = \"require-clean\" | \"include-local-changes\";\n\nexport interface AiModelProfile {\n readonly label: string;\n readonly model: string;\n}\n\nexport interface OpenAICompatibleProviderOptions {\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication?: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, AiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface AgentCheckDefinition {\n readonly label: string;\n readonly command: string;\n readonly args?: readonly string[];\n readonly required?: boolean;\n readonly timeoutMs?: number;\n}\n\nexport interface AgentLimits {\n readonly maxTurns: number;\n readonly maxToolCalls: number;\n readonly maxChangedFiles: number;\n readonly maxDiffBytes: number;\n readonly maxReadBytesPerFile: number;\n readonly maxToolOutputCharacters: number;\n readonly maxProviderResponseBytes: number;\n readonly providerConnectTimeoutMs: number;\n readonly providerFirstByteTimeoutMs: number;\n readonly providerIdleTimeoutMs: number;\n readonly checkTimeoutMs: number;\n readonly jobTimeoutMs: number;\n}\n\nexport const DEFAULT_AGENT_LIMITS = Object.freeze({\n maxTurns: 20,\n maxToolCalls: 80,\n maxChangedFiles: 20,\n maxDiffBytes: 512_000,\n maxReadBytesPerFile: 256_000,\n maxToolOutputCharacters: 40_000,\n maxProviderResponseBytes: 2_000_000,\n providerConnectTimeoutMs: 15_000,\n providerFirstByteTimeoutMs: 30_000,\n providerIdleTimeoutMs: 60_000,\n checkTimeoutMs: 120_000,\n jobTimeoutMs: 600_000,\n} satisfies AgentLimits);\n\nexport interface AiExecutionOptions {\n readonly isolation?: \"git-worktree\";\n readonly applyMode?: AgentApplyMode;\n readonly checks?: Readonly<Record<string, AgentCheckDefinition>>;\n readonly limits?: Partial<AgentLimits>;\n}\n\nexport interface AiOptions {\n readonly providers: Readonly<Record<string, OpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution?: AiExecutionOptions;\n}\n\nexport interface ResolvedAiModelProfile extends AiModelProfile {\n readonly id: string;\n}\n\nexport interface ResolvedOpenAICompatibleProviderOptions {\n readonly id: string;\n readonly type: \"openai-compatible\";\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly authentication: AiProviderAuthentication;\n readonly baseURL: string;\n readonly apiKeyEnv: string;\n readonly models: Readonly<Record<string, ResolvedAiModelProfile>>;\n readonly defaultModel: string;\n}\n\nexport interface ResolvedAgentCheckDefinition {\n readonly id: string;\n readonly label: string;\n readonly command: string;\n readonly args: readonly string[];\n readonly required: boolean;\n readonly timeoutMs: number;\n}\n\nexport interface ResolvedAiExecutionOptions {\n readonly isolation: \"git-worktree\";\n readonly applyMode: AgentApplyMode;\n readonly checks: Readonly<Record<string, ResolvedAgentCheckDefinition>>;\n readonly limits: Readonly<AgentLimits>;\n}\n\nexport interface ResolvedAiOptions {\n readonly providers: Readonly<Record<string, ResolvedOpenAICompatibleProviderOptions>>;\n readonly defaultProvider: string;\n readonly execution: ResolvedAiExecutionOptions;\n}\n\nexport interface RuntimeAiModelProfile {\n readonly id: string;\n readonly label: string;\n}\n\nexport interface RuntimeAiProviderProfile {\n readonly id: string;\n readonly label: string;\n readonly protocol: AiProviderProtocol;\n readonly models: readonly RuntimeAiModelProfile[];\n readonly defaultModel: string;\n}\n\nexport type RuntimeAiConfig =\n | Readonly<{ enabled: false }>\n | Readonly<{\n enabled: true;\n providers: readonly RuntimeAiProviderProfile[];\n defaultProvider: string;\n applyMode: AgentApplyMode;\n }>;\n\nexport const AGENT_JOB_STATUSES = Object.freeze([\n \"queued\",\n \"preparing\",\n \"running\",\n \"validating\",\n \"awaiting-review\",\n \"applying\",\n \"applied\",\n \"completed\",\n \"cancelling\",\n \"cancelled\",\n \"reverting\",\n \"reverted\",\n \"failed\",\n] as const);\n\nexport type AgentJobStatus = (typeof AGENT_JOB_STATUSES)[number];\n\nexport const AGENT_CAPABILITY_STATES = Object.freeze([\n \"unknown\",\n \"probing\",\n \"agent-ready\",\n \"prompt-only\",\n \"unavailable\",\n] as const);\n\nexport type AgentCapabilityState = (typeof AGENT_CAPABILITY_STATES)[number];\n\nexport interface AgentCapabilitySnapshot {\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly protocol: AiProviderProtocol;\n readonly state: AgentCapabilityState;\n readonly authenticated: boolean;\n readonly modelAvailable: boolean;\n readonly toolCalling: boolean;\n readonly toolResultContinuation: boolean;\n readonly streaming: boolean;\n readonly checkedAt?: string;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_WORKSPACE_STATES = Object.freeze([\n \"ready\",\n \"consent-required\",\n \"blocked\",\n] as const);\n\nexport const AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({\n maxUntrackedFiles: 1_000,\n maxUntrackedBytes: 20 * 1024 * 1024,\n});\n\nexport type AgentWorkspaceState = (typeof AGENT_WORKSPACE_STATES)[number];\n\nexport interface AgentWorkspaceChangeSummary {\n readonly staged: number;\n readonly unstaged: number;\n readonly untracked: number;\n readonly conflicted: number;\n readonly total: number;\n}\n\nexport interface AgentWorkspaceHealthSnapshot {\n readonly state: AgentWorkspaceState;\n readonly checkedAt: string;\n readonly changes: AgentWorkspaceChangeSummary;\n readonly canIncludeLocalChanges: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport const AGENT_FILE_CHANGE_KINDS = Object.freeze([\n \"added\",\n \"modified\",\n \"deleted\",\n] as const);\n\nexport type AgentFileChangeKind = (typeof AGENT_FILE_CHANGE_KINDS)[number];\n\nexport const AGENT_CHECK_STATUSES = Object.freeze([\n \"passed\",\n \"failed\",\n \"cancelled\",\n \"timed-out\",\n] as const);\n\nexport type AgentCheckStatus = (typeof AGENT_CHECK_STATUSES)[number];\n\nexport interface AgentChangedFile {\n readonly relativePath: string;\n readonly kind: AgentFileChangeKind;\n readonly additions: number;\n readonly deletions: number;\n}\n\nexport interface AgentCheckResult {\n readonly checkId: string;\n readonly label: string;\n readonly status: AgentCheckStatus;\n readonly durationMs: number;\n readonly output: string;\n}\n\nexport interface AgentJobSnapshot {\n readonly jobId: string;\n readonly status: AgentJobStatus;\n readonly providerProfileId: string;\n readonly providerLabel: string;\n readonly modelProfileId: string;\n readonly modelLabel: string;\n readonly phaseMessage: string;\n readonly createdAt: string;\n readonly updatedAt: string;\n readonly canCancel: boolean;\n readonly canApply: boolean;\n readonly canRevert: boolean;\n readonly errorCode?: ErrorCode;\n}\n\nexport interface AgentJobResult {\n readonly jobId: string;\n readonly summary: string;\n readonly diff: string;\n readonly files: readonly AgentChangedFile[];\n readonly checks: readonly AgentCheckResult[];\n}\n\nexport interface AgentJobResultResponse {\n readonly snapshot: AgentJobSnapshot;\n readonly result?: AgentJobResult;\n}\n","export const SOURCE_MARKER_ATTRIBUTE = \"data-spotpatch-source\" as const;\n\nconst SOURCE_MARKER_PATTERN = /^([A-Za-z0-9_-]+):([1-9]\\d*):([1-9]\\d*)$/;\n\nexport interface SourceMarker {\n readonly fileId: string;\n readonly line: number;\n readonly column: number;\n}\n\nexport function formatSourceMarker(marker: SourceMarker): string {\n return [marker.fileId, String(marker.line), String(marker.column)].join(\":\");\n}\n\nexport function parseSourceMarker(value: string | null): SourceMarker | undefined {\n if (value === null) {\n return undefined;\n }\n\n const match = SOURCE_MARKER_PATTERN.exec(value);\n\n if (match === null) {\n return undefined;\n }\n\n const fileId = match[1];\n const line = Number(match[2]);\n const column = Number(match[3]);\n\n if (\n fileId === undefined ||\n !Number.isSafeInteger(line) ||\n !Number.isSafeInteger(column)\n ) {\n return undefined;\n }\n\n return Object.freeze({ fileId, line, column });\n}\n","import { z } from \"zod\";\n\nimport {\n MAX_ANNOTATION_INSTRUCTION_CHARACTERS,\n MAX_ANNOTATION_TARGETS,\n MAX_TARGET_INSTRUCTION_CHARACTERS,\n SPOTPATCH_LOCALES,\n type SpotAnnotation,\n} from \"../model/annotation.js\";\n\nexport const runtimeBootstrapRequestSchema = z.strictObject({});\n\nconst sourceCoordinatesSchema = z.strictObject({\n fileId: z.string().min(1).max(128),\n line: z.number().int().positive(),\n column: z.number().int().positive(),\n});\n\nexport const sourceContextRequestSchema = sourceCoordinatesSchema\n .extend({\n maxLines: z.number().int().positive(),\n })\n .strict();\n\nexport const openEditorRequestSchema = sourceCoordinatesSchema.strict();\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\n\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst sourceRefSchema = z.strictObject({\n fileId: boundedString(128).optional(),\n relativePath: boundedString(1_024).optional(),\n line: z.number().int().positive().optional(),\n column: z.number().int().positive().optional(),\n origin: z.enum([\"jsx-host\", \"react-fiber\", \"dom-ancestor\", \"none\"]),\n confidence: z.enum([\"exact\", \"probable\", \"approximate\", \"unknown\"]),\n});\nconst matchedStyleRuleSchema = z.strictObject({\n selector: boundedString(2_048),\n declarations: boundedString(8_192),\n source: boundedString(1_024).optional(),\n media: boundedString(1_024).optional(),\n});\nconst codeContextSchema = z.strictObject({\n relativePath: boundedString(1_024),\n language: z.enum([\"tsx\", \"jsx\"]),\n startLine: z.number().int().positive(),\n endLine: z.number().int().positive(),\n excerpt: boundedString(16_000),\n boundary: z.enum([\"component\", \"nearby-lines\"]),\n});\nconst pageContextSchema = z.strictObject({\n url: boundedString(2_048),\n pathname: boundedString(2_048),\n title: boundedString(1_024),\n viewportWidth: z.number().nonnegative(),\n viewportHeight: z.number().nonnegative(),\n devicePixelRatio: z.number().positive(),\n});\n\nexport const spotTargetContextRequestSchema = z.strictObject({\n instruction: z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),\n page: pageContextSchema.optional(),\n source: sourceRefSchema,\n react: z.strictObject({\n supported: z.boolean(),\n version: boundedString(64).optional(),\n componentName: boundedString(256).optional(),\n componentStack: z.array(boundedString(256)).max(64),\n source: sourceRefSchema.optional(),\n }),\n element: z.strictObject({\n tagName: boundedString(128),\n selector: boundedString(2_048),\n sanitizedHtml: boundedString(8_192),\n textPreview: boundedString(2_048).optional(),\n role: boundedString(256).optional(),\n rect: z.strictObject({\n x: z.number(),\n y: z.number(),\n width: z.number().nonnegative(),\n height: z.number().nonnegative(),\n }),\n }),\n styles: z.strictObject({\n classNames: z.array(boundedString(512)).max(256),\n inlineStyle: boundedString(8_192).optional(),\n matchedRules: z.array(matchedStyleRuleSchema).max(256),\n computed: z.record(boundedString(256), boundedString(2_048)),\n warnings: z.array(boundedString(1_024)).max(64),\n }),\n code: codeContextSchema.optional(),\n warnings: z.array(boundedString(1_024)).max(64),\n});\n\nexport const spotAnnotationRequestSchema = z\n .strictObject({\n schemaVersion: z.literal(3),\n id: boundedString(128),\n locale: z.enum(SPOTPATCH_LOCALES),\n page: pageContextSchema,\n targets: z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),\n createdAt: z.iso.datetime(),\n })\n .superRefine((annotation, context) => {\n const total = annotation.targets.reduce(\n (characters, target) => characters + target.instruction.length,\n 0,\n );\n\n if (total > MAX_ANNOTATION_INSTRUCTION_CHARACTERS) {\n context.addIssue({\n code: \"custom\",\n message: \"Combined target instructions exceed the annotation limit.\",\n path: [\"targets\"],\n });\n }\n });\n\nexport const agentCapabilityRequestSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n});\n\nexport const agentWorkspaceHealthRequestSchema = z.strictObject({});\n\nexport const agentJobCreateRequestSchema = z.strictObject({\n annotation: spotAnnotationRequestSchema,\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n providerDataConsent: z.literal(true),\n trustedFastModeConsent: z.literal(true).optional(),\n workingTreeMode: z\n .enum([\"require-clean\", \"include-local-changes\"])\n .default(\"require-clean\"),\n});\n\nexport const agentJobActionRequestSchema = z.strictObject({});\n\nexport type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;\nexport type RuntimeBootstrapRequest = z.infer<typeof runtimeBootstrapRequestSchema>;\nexport type OpenEditorRequest = z.infer<typeof openEditorRequestSchema>;\nexport type AgentCapabilityRequest = z.infer<typeof agentCapabilityRequestSchema>;\nexport interface AgentJobCreateRequest {\n readonly annotation: SpotAnnotation;\n readonly providerProfileId: string;\n readonly modelProfileId: string;\n readonly providerDataConsent: true;\n readonly trustedFastModeConsent?: true;\n readonly workingTreeMode: \"require-clean\" | \"include-local-changes\";\n}\n","import { z } from \"zod\";\n\nimport { ERROR_CODES } from \"../errors/error-code.js\";\nimport {\n AGENT_CAPABILITY_STATES,\n AGENT_CHECK_STATUSES,\n AGENT_FILE_CHANGE_KINDS,\n AGENT_JOB_STATUSES,\n AGENT_WORKSPACE_STATES,\n} from \"../model/agent.js\";\n\nconst profileIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);\nconst boundedString = (maximum: number): z.ZodString => z.string().max(maximum);\nconst errorCodeSchema = z.enum(ERROR_CODES);\n\nexport const agentCapabilitySnapshotSchema = z.strictObject({\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n protocol: z.enum([\"responses\", \"chat-completions\"]),\n state: z.enum(AGENT_CAPABILITY_STATES),\n authenticated: z.boolean(),\n modelAvailable: z.boolean(),\n toolCalling: z.boolean(),\n toolResultContinuation: z.boolean(),\n streaming: z.boolean(),\n checkedAt: z.iso.datetime().optional(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentWorkspaceHealthSnapshotSchema = z\n .strictObject({\n state: z.enum(AGENT_WORKSPACE_STATES),\n checkedAt: z.iso.datetime(),\n changes: z.strictObject({\n staged: z.number().int().nonnegative(),\n unstaged: z.number().int().nonnegative(),\n untracked: z.number().int().nonnegative(),\n conflicted: z.number().int().nonnegative(),\n total: z.number().int().nonnegative(),\n }),\n canIncludeLocalChanges: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n })\n .refine(\n ({ state, changes, canIncludeLocalChanges, errorCode }) => {\n const countsAreConsistent =\n changes.total >= changes.staged &&\n changes.total >= changes.unstaged &&\n changes.total >= changes.untracked &&\n changes.total >= changes.conflicted &&\n changes.total <= changes.staged + changes.unstaged + changes.untracked;\n\n if (!countsAreConsistent) {\n return false;\n }\n\n if (state === \"ready\") {\n return (\n changes.total === 0 && !canIncludeLocalChanges && errorCode === undefined\n );\n }\n\n if (state === \"consent-required\") {\n return (\n changes.total > 0 &&\n changes.conflicted === 0 &&\n canIncludeLocalChanges &&\n errorCode === undefined\n );\n }\n\n return !canIncludeLocalChanges && errorCode !== undefined;\n },\n { message: \"Agent workspace health fields are inconsistent.\" },\n );\n\nexport const agentChangedFileSchema = z.strictObject({\n relativePath: boundedString(1_024),\n kind: z.enum(AGENT_FILE_CHANGE_KINDS),\n additions: z.number().int().nonnegative(),\n deletions: z.number().int().nonnegative(),\n});\n\nexport const agentCheckResultSchema = z.strictObject({\n checkId: profileIdSchema,\n label: boundedString(100),\n status: z.enum(AGENT_CHECK_STATUSES),\n durationMs: z.number().int().nonnegative(),\n output: boundedString(80_000),\n});\n\nexport const agentJobSnapshotSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n providerProfileId: profileIdSchema,\n providerLabel: boundedString(100),\n modelProfileId: profileIdSchema,\n modelLabel: boundedString(100),\n phaseMessage: boundedString(1_024),\n createdAt: z.iso.datetime(),\n updatedAt: z.iso.datetime(),\n canCancel: z.boolean(),\n canApply: z.boolean(),\n canRevert: z.boolean(),\n errorCode: errorCodeSchema.optional(),\n});\n\nexport const agentJobResultSchema = z.strictObject({\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n summary: boundedString(80_000),\n diff: boundedString(1_000_000),\n files: z.array(agentChangedFileSchema).max(100),\n checks: z.array(agentCheckResultSchema).max(100),\n});\n\nexport const agentJobResultResponseSchema = z\n .strictObject({\n snapshot: agentJobSnapshotSchema,\n result: agentJobResultSchema.optional(),\n })\n .superRefine((value, context) => {\n if (value.result !== undefined && value.result.jobId !== value.snapshot.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent result and snapshot job IDs must match.\",\n path: [\"result\", \"jobId\"],\n });\n }\n });\n\nconst agentJobEventBaseSchema = z.strictObject({\n schemaVersion: z.literal(2),\n sequence: z.number().int().positive(),\n jobId: z\n .string()\n .min(22)\n .max(128)\n .regex(/^[A-Za-z0-9_-]+$/),\n status: z.enum(AGENT_JOB_STATUSES),\n timestamp: z.iso.datetime(),\n});\n\nexport const agentJobEventSchema = z\n .discriminatedUnion(\"type\", [\n agentJobEventBaseSchema.extend({\n type: z.literal(\"snapshot\"),\n data: z.strictObject({ snapshot: agentJobSnapshotSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"phase\"),\n data: z.strictObject({ message: boundedString(1_024) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"tool\"),\n data: z.strictObject({\n turn: z.number().int().positive(),\n toolCallId: boundedString(256),\n toolName: boundedString(100),\n state: z.enum([\"started\", \"succeeded\", \"failed\"]),\n relativePath: boundedString(1_024).optional(),\n checkLabel: boundedString(100).optional(),\n }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"check\"),\n data: z.strictObject({ result: agentCheckResultSchema }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"result-ready\"),\n data: z.strictObject({ hasResult: z.literal(true) }),\n }),\n agentJobEventBaseSchema.extend({\n type: z.literal(\"error\"),\n data: z.strictObject({\n code: errorCodeSchema,\n message: boundedString(1_024),\n }),\n }),\n ])\n .superRefine((event, context) => {\n if (event.type !== \"snapshot\") {\n return;\n }\n\n if (event.data.snapshot.jobId !== event.jobId) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot job IDs must match.\",\n path: [\"data\", \"snapshot\", \"jobId\"],\n });\n }\n\n if (event.data.snapshot.status !== event.status) {\n context.addIssue({\n code: \"custom\",\n message: \"Agent event and snapshot statuses must match.\",\n path: [\"data\", \"snapshot\", \"status\"],\n });\n }\n });\n","export const SPOTPATCH_REPOSITORY_URL =\n \"https://github.com/huanglvjing/spotpatch\" as const;\n"],"mappings":";AAEO,IAAM,iBAAN,cAA6B,MAAM;AAAA,EAC/B;AAAA,EAET,YAAY,MAAiB,UAAU,MAAM,SAAwB;AACnE,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;;;ACVO,IAAM,cAAc;AAAA,EACzB,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,yBAAyB;AAAA,EACzB,sBAAsB;AAAA,EACtB,+BAA+B;AAAA,EAC/B,mBAAmB;AAAA,EACnB,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,YAAY;AAAA,EACZ,sBAAsB;AAAA,EACt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