@spotpatch/shared 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +57 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +126 -1
- package/dist/index.d.ts +126 -1
- package/dist/index.js +53 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,8 @@ __export(index_exports, {
|
|
|
24
24
|
AGENT_CHECK_STATUSES: () => AGENT_CHECK_STATUSES,
|
|
25
25
|
AGENT_FILE_CHANGE_KINDS: () => AGENT_FILE_CHANGE_KINDS,
|
|
26
26
|
AGENT_JOB_STATUSES: () => AGENT_JOB_STATUSES,
|
|
27
|
+
AGENT_WORKSPACE_SNAPSHOT_LIMITS: () => AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
28
|
+
AGENT_WORKSPACE_STATES: () => AGENT_WORKSPACE_STATES,
|
|
27
29
|
DEFAULT_AGENT_LIMITS: () => DEFAULT_AGENT_LIMITS,
|
|
28
30
|
ERROR_CODES: () => ERROR_CODES,
|
|
29
31
|
MAX_ANNOTATION_INSTRUCTION_CHARACTERS: () => MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
|
|
@@ -48,6 +50,8 @@ __export(index_exports, {
|
|
|
48
50
|
agentJobResultResponseSchema: () => agentJobResultResponseSchema,
|
|
49
51
|
agentJobResultSchema: () => agentJobResultSchema,
|
|
50
52
|
agentJobSnapshotSchema: () => agentJobSnapshotSchema,
|
|
53
|
+
agentWorkspaceHealthRequestSchema: () => agentWorkspaceHealthRequestSchema,
|
|
54
|
+
agentWorkspaceHealthSnapshotSchema: () => agentWorkspaceHealthSnapshotSchema,
|
|
51
55
|
formatSourceMarker: () => formatSourceMarker,
|
|
52
56
|
getAgentJobEndpoint: () => getAgentJobEndpoint,
|
|
53
57
|
isSensitiveName: () => isSensitiveName,
|
|
@@ -91,7 +95,15 @@ var ERROR_CODES = {
|
|
|
91
95
|
AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED",
|
|
92
96
|
AGENT_CANCELLED: "AGENT_CANCELLED",
|
|
93
97
|
WORKTREE_DIRTY: "WORKTREE_DIRTY",
|
|
98
|
+
WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY",
|
|
99
|
+
WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS",
|
|
100
|
+
WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED",
|
|
101
|
+
WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE",
|
|
102
|
+
WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED",
|
|
103
|
+
WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED",
|
|
94
104
|
TOOL_DENIED: "TOOL_DENIED",
|
|
105
|
+
TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
|
|
106
|
+
TOOL_PATH_DENIED: "TOOL_PATH_DENIED",
|
|
95
107
|
PATCH_REJECTED: "PATCH_REJECTED",
|
|
96
108
|
VALIDATION_FAILED: "VALIDATION_FAILED",
|
|
97
109
|
APPLY_CONFLICT: "APPLY_CONFLICT",
|
|
@@ -217,6 +229,15 @@ var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
|
217
229
|
"prompt-only",
|
|
218
230
|
"unavailable"
|
|
219
231
|
]);
|
|
232
|
+
var AGENT_WORKSPACE_STATES = Object.freeze([
|
|
233
|
+
"ready",
|
|
234
|
+
"consent-required",
|
|
235
|
+
"blocked"
|
|
236
|
+
]);
|
|
237
|
+
var AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({
|
|
238
|
+
maxUntrackedFiles: 1e3,
|
|
239
|
+
maxUntrackedBytes: 20 * 1024 * 1024
|
|
240
|
+
});
|
|
220
241
|
var AGENT_FILE_CHANGE_KINDS = Object.freeze([
|
|
221
242
|
"added",
|
|
222
243
|
"modified",
|
|
@@ -259,6 +280,7 @@ var SPOTPATCH_ENDPOINTS = Object.freeze({
|
|
|
259
280
|
sourceContext: `${SPOTPATCH_API_BASE}/source-context`,
|
|
260
281
|
openEditor: `${SPOTPATCH_API_BASE}/open-editor`,
|
|
261
282
|
agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
|
|
283
|
+
agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
|
|
262
284
|
agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`
|
|
263
285
|
});
|
|
264
286
|
function getAgentJobEndpoint(jobId, action) {
|
|
@@ -364,11 +386,13 @@ var agentCapabilityRequestSchema = import_zod.z.strictObject({
|
|
|
364
386
|
providerProfileId: profileIdSchema,
|
|
365
387
|
modelProfileId: profileIdSchema
|
|
366
388
|
});
|
|
389
|
+
var agentWorkspaceHealthRequestSchema = import_zod.z.strictObject({});
|
|
367
390
|
var agentJobCreateRequestSchema = import_zod.z.strictObject({
|
|
368
391
|
annotation: spotAnnotationRequestSchema,
|
|
369
392
|
providerProfileId: profileIdSchema,
|
|
370
393
|
modelProfileId: profileIdSchema,
|
|
371
|
-
providerDataConsent: import_zod.z.literal(true)
|
|
394
|
+
providerDataConsent: import_zod.z.literal(true),
|
|
395
|
+
workingTreeMode: import_zod.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
372
396
|
});
|
|
373
397
|
var agentJobActionRequestSchema = import_zod.z.strictObject({});
|
|
374
398
|
|
|
@@ -392,6 +416,34 @@ var agentCapabilitySnapshotSchema = import_zod2.z.strictObject({
|
|
|
392
416
|
checkedAt: import_zod2.z.iso.datetime().optional(),
|
|
393
417
|
errorCode: errorCodeSchema.optional()
|
|
394
418
|
});
|
|
419
|
+
var agentWorkspaceHealthSnapshotSchema = import_zod2.z.strictObject({
|
|
420
|
+
state: import_zod2.z.enum(AGENT_WORKSPACE_STATES),
|
|
421
|
+
checkedAt: import_zod2.z.iso.datetime(),
|
|
422
|
+
changes: import_zod2.z.strictObject({
|
|
423
|
+
staged: import_zod2.z.number().int().nonnegative(),
|
|
424
|
+
unstaged: import_zod2.z.number().int().nonnegative(),
|
|
425
|
+
untracked: import_zod2.z.number().int().nonnegative(),
|
|
426
|
+
conflicted: import_zod2.z.number().int().nonnegative(),
|
|
427
|
+
total: import_zod2.z.number().int().nonnegative()
|
|
428
|
+
}),
|
|
429
|
+
canIncludeLocalChanges: import_zod2.z.boolean(),
|
|
430
|
+
errorCode: errorCodeSchema.optional()
|
|
431
|
+
}).refine(
|
|
432
|
+
({ state, changes, canIncludeLocalChanges, errorCode }) => {
|
|
433
|
+
const countsAreConsistent = changes.total >= changes.staged && changes.total >= changes.unstaged && changes.total >= changes.untracked && changes.total >= changes.conflicted && changes.total <= changes.staged + changes.unstaged + changes.untracked;
|
|
434
|
+
if (!countsAreConsistent) {
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
437
|
+
if (state === "ready") {
|
|
438
|
+
return changes.total === 0 && !canIncludeLocalChanges && errorCode === void 0;
|
|
439
|
+
}
|
|
440
|
+
if (state === "consent-required") {
|
|
441
|
+
return changes.total > 0 && changes.conflicted === 0 && canIncludeLocalChanges && errorCode === void 0;
|
|
442
|
+
}
|
|
443
|
+
return !canIncludeLocalChanges && errorCode !== void 0;
|
|
444
|
+
},
|
|
445
|
+
{ message: "Agent workspace health fields are inconsistent." }
|
|
446
|
+
);
|
|
395
447
|
var agentChangedFileSchema = import_zod2.z.strictObject({
|
|
396
448
|
relativePath: boundedString2(1024),
|
|
397
449
|
kind: import_zod2.z.enum(AGENT_FILE_CHANGE_KINDS),
|
|
@@ -508,6 +560,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
508
560
|
AGENT_CHECK_STATUSES,
|
|
509
561
|
AGENT_FILE_CHANGE_KINDS,
|
|
510
562
|
AGENT_JOB_STATUSES,
|
|
563
|
+
AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
564
|
+
AGENT_WORKSPACE_STATES,
|
|
511
565
|
DEFAULT_AGENT_LIMITS,
|
|
512
566
|
ERROR_CODES,
|
|
513
567
|
MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
|
|
@@ -532,6 +586,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
532
586
|
agentJobResultResponseSchema,
|
|
533
587
|
agentJobResultSchema,
|
|
534
588
|
agentJobSnapshotSchema,
|
|
589
|
+
agentWorkspaceHealthRequestSchema,
|
|
590
|
+
agentWorkspaceHealthSnapshotSchema,
|
|
535
591
|
formatSourceMarker,
|
|
536
592
|
getAgentJobEndpoint,
|
|
537
593
|
isSensitiveName,
|
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/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/endpoints.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 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 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 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 agentJobActionRequestSchema,\n agentJobCreateRequestSchema,\n openEditorRequestSchema,\n sourceContextRequestSchema,\n spotAnnotationRequestSchema,\n spotTargetContextRequestSchema,\n type AgentCapabilityRequest,\n type AgentJobCreateRequest,\n type OpenEditorRequest,\n type SourceContextRequest,\n} from \"./protocol/requests.js\";\nexport type { AgentJobEvent } from \"./protocol/agent-events.js\";\nexport {\n agentCapabilitySnapshotSchema,\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 TOOL_DENIED: \"TOOL_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","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\";\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_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","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 sourceContext: `${SPOTPATCH_API_BASE}/source-context`,\n openEditor: `${SPOTPATCH_API_BASE}/open-editor`,\n agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,\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","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\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 agentJobCreateRequestSchema = z.strictObject({\n annotation: spotAnnotationRequestSchema,\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n providerDataConsent: z.literal(true),\n});\n\nexport const agentJobActionRequestSchema = z.strictObject({});\n\nexport type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;\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}\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} 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 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(1),\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 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,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,EACtB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;;;ACxBA,IAAM,sBAAsB;AAC5B,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AACvB,IAAM,yBAAyB;AAC/B,IAAM,4BACJ;AACF,IAAM,wBAAwB,oBAAI,IAAI;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAA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,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;;;ACpKI,IAAM,2BACX;","names":["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/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/endpoints.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 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 sourceContextRequestSchema,\n spotAnnotationRequestSchema,\n spotTargetContextRequestSchema,\n type AgentCapabilityRequest,\n type AgentJobCreateRequest,\n type OpenEditorRequest,\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_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","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","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 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","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\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 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(1),\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 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;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,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;;;ACpNI,IAAM,2BACX;","names":["import_zod","profileIdSchema","boundedString"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -19,7 +19,15 @@ declare const ERROR_CODES: {
|
|
|
19
19
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
20
20
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
21
21
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
22
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
23
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
24
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
25
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
26
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
27
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
22
28
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
29
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
30
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
23
31
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
24
32
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
25
33
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -143,6 +151,7 @@ interface EditorOpenResult {
|
|
|
143
151
|
type AiProviderProtocol = "responses" | "chat-completions";
|
|
144
152
|
type AiProviderAuthentication = "bearer" | "x-api-key";
|
|
145
153
|
type AgentApplyMode = "review" | "auto";
|
|
154
|
+
type AgentWorkingTreeMode = "require-clean" | "include-local-changes";
|
|
146
155
|
interface AiModelProfile {
|
|
147
156
|
readonly label: string;
|
|
148
157
|
readonly model: string;
|
|
@@ -274,6 +283,26 @@ interface AgentCapabilitySnapshot {
|
|
|
274
283
|
readonly checkedAt?: string;
|
|
275
284
|
readonly errorCode?: ErrorCode;
|
|
276
285
|
}
|
|
286
|
+
declare const AGENT_WORKSPACE_STATES: readonly ["ready", "consent-required", "blocked"];
|
|
287
|
+
declare const AGENT_WORKSPACE_SNAPSHOT_LIMITS: Readonly<{
|
|
288
|
+
maxUntrackedFiles: 1000;
|
|
289
|
+
maxUntrackedBytes: number;
|
|
290
|
+
}>;
|
|
291
|
+
type AgentWorkspaceState = (typeof AGENT_WORKSPACE_STATES)[number];
|
|
292
|
+
interface AgentWorkspaceChangeSummary {
|
|
293
|
+
readonly staged: number;
|
|
294
|
+
readonly unstaged: number;
|
|
295
|
+
readonly untracked: number;
|
|
296
|
+
readonly conflicted: number;
|
|
297
|
+
readonly total: number;
|
|
298
|
+
}
|
|
299
|
+
interface AgentWorkspaceHealthSnapshot {
|
|
300
|
+
readonly state: AgentWorkspaceState;
|
|
301
|
+
readonly checkedAt: string;
|
|
302
|
+
readonly changes: AgentWorkspaceChangeSummary;
|
|
303
|
+
readonly canIncludeLocalChanges: boolean;
|
|
304
|
+
readonly errorCode?: ErrorCode;
|
|
305
|
+
}
|
|
277
306
|
declare const AGENT_FILE_CHANGE_KINDS: readonly ["added", "modified", "deleted"];
|
|
278
307
|
type AgentFileChangeKind = (typeof AGENT_FILE_CHANGE_KINDS)[number];
|
|
279
308
|
declare const AGENT_CHECK_STATUSES: readonly ["passed", "failed", "cancelled", "timed-out"];
|
|
@@ -333,6 +362,7 @@ declare const SPOTPATCH_ENDPOINTS: Readonly<{
|
|
|
333
362
|
sourceContext: "/__spotpatch/v1/source-context";
|
|
334
363
|
openEditor: "/__spotpatch/v1/open-editor";
|
|
335
364
|
agentCapability: "/__spotpatch/v1/agent/capability";
|
|
365
|
+
agentWorkspaceHealth: "/__spotpatch/v1/agent/workspace-health";
|
|
336
366
|
agentJobs: "/__spotpatch/v1/agent/jobs";
|
|
337
367
|
}>;
|
|
338
368
|
type AgentJobAction = "events" | "result" | "cancel" | "apply" | "revert";
|
|
@@ -540,6 +570,7 @@ declare const agentCapabilityRequestSchema: z.ZodObject<{
|
|
|
540
570
|
providerProfileId: z.ZodString;
|
|
541
571
|
modelProfileId: z.ZodString;
|
|
542
572
|
}, z.core.$strict>;
|
|
573
|
+
declare const agentWorkspaceHealthRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
543
574
|
declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
544
575
|
annotation: z.ZodObject<{
|
|
545
576
|
schemaVersion: z.ZodLiteral<3>;
|
|
@@ -646,6 +677,10 @@ declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
|
646
677
|
providerProfileId: z.ZodString;
|
|
647
678
|
modelProfileId: z.ZodString;
|
|
648
679
|
providerDataConsent: z.ZodLiteral<true>;
|
|
680
|
+
workingTreeMode: z.ZodDefault<z.ZodEnum<{
|
|
681
|
+
"require-clean": "require-clean";
|
|
682
|
+
"include-local-changes": "include-local-changes";
|
|
683
|
+
}>>;
|
|
649
684
|
}, z.core.$strict>;
|
|
650
685
|
declare const agentJobActionRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
651
686
|
type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;
|
|
@@ -656,6 +691,7 @@ interface AgentJobCreateRequest {
|
|
|
656
691
|
readonly providerProfileId: string;
|
|
657
692
|
readonly modelProfileId: string;
|
|
658
693
|
readonly providerDataConsent: true;
|
|
694
|
+
readonly workingTreeMode: "require-clean" | "include-local-changes";
|
|
659
695
|
}
|
|
660
696
|
|
|
661
697
|
interface AgentJobEventBase {
|
|
@@ -743,7 +779,64 @@ declare const agentCapabilitySnapshotSchema: z.ZodObject<{
|
|
|
743
779
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
744
780
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
745
781
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
782
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
783
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
784
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
785
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
786
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
787
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
788
|
+
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
789
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
790
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
791
|
+
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
792
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
793
|
+
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
794
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
795
|
+
}>>;
|
|
796
|
+
}, z.core.$strict>;
|
|
797
|
+
declare const agentWorkspaceHealthSnapshotSchema: z.ZodObject<{
|
|
798
|
+
state: z.ZodEnum<{
|
|
799
|
+
ready: "ready";
|
|
800
|
+
"consent-required": "consent-required";
|
|
801
|
+
blocked: "blocked";
|
|
802
|
+
}>;
|
|
803
|
+
checkedAt: z.ZodISODateTime;
|
|
804
|
+
changes: z.ZodObject<{
|
|
805
|
+
staged: z.ZodNumber;
|
|
806
|
+
unstaged: z.ZodNumber;
|
|
807
|
+
untracked: z.ZodNumber;
|
|
808
|
+
conflicted: z.ZodNumber;
|
|
809
|
+
total: z.ZodNumber;
|
|
810
|
+
}, z.core.$strict>;
|
|
811
|
+
canIncludeLocalChanges: z.ZodBoolean;
|
|
812
|
+
errorCode: z.ZodOptional<z.ZodEnum<{
|
|
813
|
+
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
814
|
+
readonly INVALID_TOKEN: "INVALID_TOKEN";
|
|
815
|
+
readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
|
|
816
|
+
readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
|
|
817
|
+
readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
|
|
818
|
+
readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
|
|
819
|
+
readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
|
|
820
|
+
readonly AI_DISABLED: "AI_DISABLED";
|
|
821
|
+
readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
|
|
822
|
+
readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
|
|
823
|
+
readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
|
|
824
|
+
readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
|
|
825
|
+
readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
|
|
826
|
+
readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
|
|
827
|
+
readonly AGENT_BUSY: "AGENT_BUSY";
|
|
828
|
+
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
829
|
+
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
830
|
+
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
831
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
832
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
833
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
834
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
835
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
836
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
746
837
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
838
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
839
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
747
840
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
748
841
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
749
842
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -818,7 +911,15 @@ declare const agentJobSnapshotSchema: z.ZodObject<{
|
|
|
818
911
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
819
912
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
820
913
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
914
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
915
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
916
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
917
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
918
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
919
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
821
920
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
921
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
922
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
822
923
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
823
924
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
824
925
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -899,7 +1000,15 @@ declare const agentJobResultResponseSchema: z.ZodObject<{
|
|
|
899
1000
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
900
1001
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
901
1002
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
1003
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
1004
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
1005
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
1006
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
1007
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
1008
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
902
1009
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
1010
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
1011
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
903
1012
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
904
1013
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
905
1014
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -1002,7 +1111,15 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1002
1111
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
1003
1112
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
1004
1113
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
1114
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
1115
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
1116
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
1117
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
1118
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
1119
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
1005
1120
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
1121
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
1122
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
1006
1123
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
1007
1124
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
1008
1125
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -1166,7 +1283,15 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1166
1283
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
1167
1284
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
1168
1285
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
1286
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
1287
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
1288
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
1289
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
1290
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
1291
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
1169
1292
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
1293
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
1294
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
1170
1295
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
1171
1296
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
1172
1297
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -1191,4 +1316,4 @@ type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
|
|
|
1191
1316
|
|
|
1192
1317
|
declare const SPOTPATCH_REPOSITORY_URL: "https://github.com/huanglvjing/spotpatch";
|
|
1193
1318
|
|
|
1194
|
-
export { AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, type AgentApplyMode, type AgentCapabilityRequest, type AgentCapabilitySnapshot, type AgentCapabilityState, type AgentChangedFile, type AgentCheckDefinition, type AgentCheckResult, type AgentCheckStatus, type AgentFileChangeKind, type AgentJobAction, type AgentJobCreateRequest, type AgentJobEvent, type AgentJobResult, type AgentJobResultResponse, type AgentJobSnapshot, type AgentJobStatus, type AgentLimits, type AiExecutionOptions, type AiModelProfile, type AiOptions, type 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, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, 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 SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
|
1319
|
+
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, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, 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 SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, agentWorkspaceHealthRequestSchema, agentWorkspaceHealthSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,15 @@ declare const ERROR_CODES: {
|
|
|
19
19
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
20
20
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
21
21
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
22
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
23
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
24
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
25
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
26
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
27
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
22
28
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
29
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
30
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
23
31
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
24
32
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
25
33
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -143,6 +151,7 @@ interface EditorOpenResult {
|
|
|
143
151
|
type AiProviderProtocol = "responses" | "chat-completions";
|
|
144
152
|
type AiProviderAuthentication = "bearer" | "x-api-key";
|
|
145
153
|
type AgentApplyMode = "review" | "auto";
|
|
154
|
+
type AgentWorkingTreeMode = "require-clean" | "include-local-changes";
|
|
146
155
|
interface AiModelProfile {
|
|
147
156
|
readonly label: string;
|
|
148
157
|
readonly model: string;
|
|
@@ -274,6 +283,26 @@ interface AgentCapabilitySnapshot {
|
|
|
274
283
|
readonly checkedAt?: string;
|
|
275
284
|
readonly errorCode?: ErrorCode;
|
|
276
285
|
}
|
|
286
|
+
declare const AGENT_WORKSPACE_STATES: readonly ["ready", "consent-required", "blocked"];
|
|
287
|
+
declare const AGENT_WORKSPACE_SNAPSHOT_LIMITS: Readonly<{
|
|
288
|
+
maxUntrackedFiles: 1000;
|
|
289
|
+
maxUntrackedBytes: number;
|
|
290
|
+
}>;
|
|
291
|
+
type AgentWorkspaceState = (typeof AGENT_WORKSPACE_STATES)[number];
|
|
292
|
+
interface AgentWorkspaceChangeSummary {
|
|
293
|
+
readonly staged: number;
|
|
294
|
+
readonly unstaged: number;
|
|
295
|
+
readonly untracked: number;
|
|
296
|
+
readonly conflicted: number;
|
|
297
|
+
readonly total: number;
|
|
298
|
+
}
|
|
299
|
+
interface AgentWorkspaceHealthSnapshot {
|
|
300
|
+
readonly state: AgentWorkspaceState;
|
|
301
|
+
readonly checkedAt: string;
|
|
302
|
+
readonly changes: AgentWorkspaceChangeSummary;
|
|
303
|
+
readonly canIncludeLocalChanges: boolean;
|
|
304
|
+
readonly errorCode?: ErrorCode;
|
|
305
|
+
}
|
|
277
306
|
declare const AGENT_FILE_CHANGE_KINDS: readonly ["added", "modified", "deleted"];
|
|
278
307
|
type AgentFileChangeKind = (typeof AGENT_FILE_CHANGE_KINDS)[number];
|
|
279
308
|
declare const AGENT_CHECK_STATUSES: readonly ["passed", "failed", "cancelled", "timed-out"];
|
|
@@ -333,6 +362,7 @@ declare const SPOTPATCH_ENDPOINTS: Readonly<{
|
|
|
333
362
|
sourceContext: "/__spotpatch/v1/source-context";
|
|
334
363
|
openEditor: "/__spotpatch/v1/open-editor";
|
|
335
364
|
agentCapability: "/__spotpatch/v1/agent/capability";
|
|
365
|
+
agentWorkspaceHealth: "/__spotpatch/v1/agent/workspace-health";
|
|
336
366
|
agentJobs: "/__spotpatch/v1/agent/jobs";
|
|
337
367
|
}>;
|
|
338
368
|
type AgentJobAction = "events" | "result" | "cancel" | "apply" | "revert";
|
|
@@ -540,6 +570,7 @@ declare const agentCapabilityRequestSchema: z.ZodObject<{
|
|
|
540
570
|
providerProfileId: z.ZodString;
|
|
541
571
|
modelProfileId: z.ZodString;
|
|
542
572
|
}, z.core.$strict>;
|
|
573
|
+
declare const agentWorkspaceHealthRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
543
574
|
declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
544
575
|
annotation: z.ZodObject<{
|
|
545
576
|
schemaVersion: z.ZodLiteral<3>;
|
|
@@ -646,6 +677,10 @@ declare const agentJobCreateRequestSchema: z.ZodObject<{
|
|
|
646
677
|
providerProfileId: z.ZodString;
|
|
647
678
|
modelProfileId: z.ZodString;
|
|
648
679
|
providerDataConsent: z.ZodLiteral<true>;
|
|
680
|
+
workingTreeMode: z.ZodDefault<z.ZodEnum<{
|
|
681
|
+
"require-clean": "require-clean";
|
|
682
|
+
"include-local-changes": "include-local-changes";
|
|
683
|
+
}>>;
|
|
649
684
|
}, z.core.$strict>;
|
|
650
685
|
declare const agentJobActionRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
651
686
|
type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;
|
|
@@ -656,6 +691,7 @@ interface AgentJobCreateRequest {
|
|
|
656
691
|
readonly providerProfileId: string;
|
|
657
692
|
readonly modelProfileId: string;
|
|
658
693
|
readonly providerDataConsent: true;
|
|
694
|
+
readonly workingTreeMode: "require-clean" | "include-local-changes";
|
|
659
695
|
}
|
|
660
696
|
|
|
661
697
|
interface AgentJobEventBase {
|
|
@@ -743,7 +779,64 @@ declare const agentCapabilitySnapshotSchema: z.ZodObject<{
|
|
|
743
779
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
744
780
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
745
781
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
782
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
783
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
784
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
785
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
786
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
787
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
788
|
+
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
789
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
790
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
791
|
+
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
792
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
793
|
+
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
794
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
795
|
+
}>>;
|
|
796
|
+
}, z.core.$strict>;
|
|
797
|
+
declare const agentWorkspaceHealthSnapshotSchema: z.ZodObject<{
|
|
798
|
+
state: z.ZodEnum<{
|
|
799
|
+
ready: "ready";
|
|
800
|
+
"consent-required": "consent-required";
|
|
801
|
+
blocked: "blocked";
|
|
802
|
+
}>;
|
|
803
|
+
checkedAt: z.ZodISODateTime;
|
|
804
|
+
changes: z.ZodObject<{
|
|
805
|
+
staged: z.ZodNumber;
|
|
806
|
+
unstaged: z.ZodNumber;
|
|
807
|
+
untracked: z.ZodNumber;
|
|
808
|
+
conflicted: z.ZodNumber;
|
|
809
|
+
total: z.ZodNumber;
|
|
810
|
+
}, z.core.$strict>;
|
|
811
|
+
canIncludeLocalChanges: z.ZodBoolean;
|
|
812
|
+
errorCode: z.ZodOptional<z.ZodEnum<{
|
|
813
|
+
readonly INVALID_REQUEST: "INVALID_REQUEST";
|
|
814
|
+
readonly INVALID_TOKEN: "INVALID_TOKEN";
|
|
815
|
+
readonly ORIGIN_NOT_ALLOWED: "ORIGIN_NOT_ALLOWED";
|
|
816
|
+
readonly SOURCE_NOT_FOUND: "SOURCE_NOT_FOUND";
|
|
817
|
+
readonly SOURCE_OUTSIDE_ROOT: "SOURCE_OUTSIDE_ROOT";
|
|
818
|
+
readonly SOURCE_TOO_LARGE: "SOURCE_TOO_LARGE";
|
|
819
|
+
readonly EDITOR_OPEN_FAILED: "EDITOR_OPEN_FAILED";
|
|
820
|
+
readonly AI_DISABLED: "AI_DISABLED";
|
|
821
|
+
readonly PROVIDER_NOT_CONFIGURED: "PROVIDER_NOT_CONFIGURED";
|
|
822
|
+
readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
|
|
823
|
+
readonly PROVIDER_PROTOCOL_UNSUPPORTED: "PROVIDER_PROTOCOL_UNSUPPORTED";
|
|
824
|
+
readonly MODEL_NOT_ALLOWED: "MODEL_NOT_ALLOWED";
|
|
825
|
+
readonly MODEL_TOOL_CALL_UNSUPPORTED: "MODEL_TOOL_CALL_UNSUPPORTED";
|
|
826
|
+
readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
|
|
827
|
+
readonly AGENT_BUSY: "AGENT_BUSY";
|
|
828
|
+
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
829
|
+
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
830
|
+
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
831
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
832
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
833
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
834
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
835
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
836
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
746
837
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
838
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
839
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
747
840
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
748
841
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
749
842
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -818,7 +911,15 @@ declare const agentJobSnapshotSchema: z.ZodObject<{
|
|
|
818
911
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
819
912
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
820
913
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
914
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
915
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
916
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
917
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
918
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
919
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
821
920
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
921
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
922
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
822
923
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
823
924
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
824
925
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -899,7 +1000,15 @@ declare const agentJobResultResponseSchema: z.ZodObject<{
|
|
|
899
1000
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
900
1001
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
901
1002
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
1003
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
1004
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
1005
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
1006
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
1007
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
1008
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
902
1009
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
1010
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
1011
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
903
1012
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
904
1013
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
905
1014
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -1002,7 +1111,15 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1002
1111
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
1003
1112
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
1004
1113
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
1114
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
1115
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
1116
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
1117
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
1118
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
1119
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
1005
1120
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
1121
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
1122
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
1006
1123
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
1007
1124
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
1008
1125
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -1166,7 +1283,15 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1166
1283
|
readonly AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED";
|
|
1167
1284
|
readonly AGENT_CANCELLED: "AGENT_CANCELLED";
|
|
1168
1285
|
readonly WORKTREE_DIRTY: "WORKTREE_DIRTY";
|
|
1286
|
+
readonly WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY";
|
|
1287
|
+
readonly WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS";
|
|
1288
|
+
readonly WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED";
|
|
1289
|
+
readonly WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE";
|
|
1290
|
+
readonly WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED";
|
|
1291
|
+
readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
|
|
1169
1292
|
readonly TOOL_DENIED: "TOOL_DENIED";
|
|
1293
|
+
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
1294
|
+
readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
|
|
1170
1295
|
readonly PATCH_REJECTED: "PATCH_REJECTED";
|
|
1171
1296
|
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
1172
1297
|
readonly APPLY_CONFLICT: "APPLY_CONFLICT";
|
|
@@ -1191,4 +1316,4 @@ type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
|
|
|
1191
1316
|
|
|
1192
1317
|
declare const SPOTPATCH_REPOSITORY_URL: "https://github.com/huanglvjing/spotpatch";
|
|
1193
1318
|
|
|
1194
|
-
export { AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, type AgentApplyMode, type AgentCapabilityRequest, type AgentCapabilitySnapshot, type AgentCapabilityState, type AgentChangedFile, type AgentCheckDefinition, type AgentCheckResult, type AgentCheckStatus, type AgentFileChangeKind, type AgentJobAction, type AgentJobCreateRequest, type AgentJobEvent, type AgentJobResult, type AgentJobResultResponse, type AgentJobSnapshot, type AgentJobStatus, type AgentLimits, type AiExecutionOptions, type AiModelProfile, type AiOptions, type 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, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, 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 SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
|
1319
|
+
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, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, 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 SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, agentWorkspaceHealthRequestSchema, agentWorkspaceHealthSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,15 @@ var ERROR_CODES = {
|
|
|
28
28
|
AGENT_LIMIT_EXCEEDED: "AGENT_LIMIT_EXCEEDED",
|
|
29
29
|
AGENT_CANCELLED: "AGENT_CANCELLED",
|
|
30
30
|
WORKTREE_DIRTY: "WORKTREE_DIRTY",
|
|
31
|
+
WORKTREE_NOT_REPOSITORY: "WORKTREE_NOT_REPOSITORY",
|
|
32
|
+
WORKTREE_OPERATION_IN_PROGRESS: "WORKTREE_OPERATION_IN_PROGRESS",
|
|
33
|
+
WORKTREE_CONFLICTED: "WORKTREE_CONFLICTED",
|
|
34
|
+
WORKTREE_LOCAL_CHANGES_TOO_LARGE: "WORKTREE_LOCAL_CHANGES_TOO_LARGE",
|
|
35
|
+
WORKTREE_UNTRACKED_UNSUPPORTED: "WORKTREE_UNTRACKED_UNSUPPORTED",
|
|
36
|
+
WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED",
|
|
31
37
|
TOOL_DENIED: "TOOL_DENIED",
|
|
38
|
+
TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
|
|
39
|
+
TOOL_PATH_DENIED: "TOOL_PATH_DENIED",
|
|
32
40
|
PATCH_REJECTED: "PATCH_REJECTED",
|
|
33
41
|
VALIDATION_FAILED: "VALIDATION_FAILED",
|
|
34
42
|
APPLY_CONFLICT: "APPLY_CONFLICT",
|
|
@@ -154,6 +162,15 @@ var AGENT_CAPABILITY_STATES = Object.freeze([
|
|
|
154
162
|
"prompt-only",
|
|
155
163
|
"unavailable"
|
|
156
164
|
]);
|
|
165
|
+
var AGENT_WORKSPACE_STATES = Object.freeze([
|
|
166
|
+
"ready",
|
|
167
|
+
"consent-required",
|
|
168
|
+
"blocked"
|
|
169
|
+
]);
|
|
170
|
+
var AGENT_WORKSPACE_SNAPSHOT_LIMITS = Object.freeze({
|
|
171
|
+
maxUntrackedFiles: 1e3,
|
|
172
|
+
maxUntrackedBytes: 20 * 1024 * 1024
|
|
173
|
+
});
|
|
157
174
|
var AGENT_FILE_CHANGE_KINDS = Object.freeze([
|
|
158
175
|
"added",
|
|
159
176
|
"modified",
|
|
@@ -196,6 +213,7 @@ var SPOTPATCH_ENDPOINTS = Object.freeze({
|
|
|
196
213
|
sourceContext: `${SPOTPATCH_API_BASE}/source-context`,
|
|
197
214
|
openEditor: `${SPOTPATCH_API_BASE}/open-editor`,
|
|
198
215
|
agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
|
|
216
|
+
agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
|
|
199
217
|
agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`
|
|
200
218
|
});
|
|
201
219
|
function getAgentJobEndpoint(jobId, action) {
|
|
@@ -301,11 +319,13 @@ var agentCapabilityRequestSchema = z.strictObject({
|
|
|
301
319
|
providerProfileId: profileIdSchema,
|
|
302
320
|
modelProfileId: profileIdSchema
|
|
303
321
|
});
|
|
322
|
+
var agentWorkspaceHealthRequestSchema = z.strictObject({});
|
|
304
323
|
var agentJobCreateRequestSchema = z.strictObject({
|
|
305
324
|
annotation: spotAnnotationRequestSchema,
|
|
306
325
|
providerProfileId: profileIdSchema,
|
|
307
326
|
modelProfileId: profileIdSchema,
|
|
308
|
-
providerDataConsent: z.literal(true)
|
|
327
|
+
providerDataConsent: z.literal(true),
|
|
328
|
+
workingTreeMode: z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
309
329
|
});
|
|
310
330
|
var agentJobActionRequestSchema = z.strictObject({});
|
|
311
331
|
|
|
@@ -329,6 +349,34 @@ var agentCapabilitySnapshotSchema = z2.strictObject({
|
|
|
329
349
|
checkedAt: z2.iso.datetime().optional(),
|
|
330
350
|
errorCode: errorCodeSchema.optional()
|
|
331
351
|
});
|
|
352
|
+
var agentWorkspaceHealthSnapshotSchema = z2.strictObject({
|
|
353
|
+
state: z2.enum(AGENT_WORKSPACE_STATES),
|
|
354
|
+
checkedAt: z2.iso.datetime(),
|
|
355
|
+
changes: z2.strictObject({
|
|
356
|
+
staged: z2.number().int().nonnegative(),
|
|
357
|
+
unstaged: z2.number().int().nonnegative(),
|
|
358
|
+
untracked: z2.number().int().nonnegative(),
|
|
359
|
+
conflicted: z2.number().int().nonnegative(),
|
|
360
|
+
total: z2.number().int().nonnegative()
|
|
361
|
+
}),
|
|
362
|
+
canIncludeLocalChanges: z2.boolean(),
|
|
363
|
+
errorCode: errorCodeSchema.optional()
|
|
364
|
+
}).refine(
|
|
365
|
+
({ state, changes, canIncludeLocalChanges, errorCode }) => {
|
|
366
|
+
const countsAreConsistent = changes.total >= changes.staged && changes.total >= changes.unstaged && changes.total >= changes.untracked && changes.total >= changes.conflicted && changes.total <= changes.staged + changes.unstaged + changes.untracked;
|
|
367
|
+
if (!countsAreConsistent) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
if (state === "ready") {
|
|
371
|
+
return changes.total === 0 && !canIncludeLocalChanges && errorCode === void 0;
|
|
372
|
+
}
|
|
373
|
+
if (state === "consent-required") {
|
|
374
|
+
return changes.total > 0 && changes.conflicted === 0 && canIncludeLocalChanges && errorCode === void 0;
|
|
375
|
+
}
|
|
376
|
+
return !canIncludeLocalChanges && errorCode !== void 0;
|
|
377
|
+
},
|
|
378
|
+
{ message: "Agent workspace health fields are inconsistent." }
|
|
379
|
+
);
|
|
332
380
|
var agentChangedFileSchema = z2.strictObject({
|
|
333
381
|
relativePath: boundedString2(1024),
|
|
334
382
|
kind: z2.enum(AGENT_FILE_CHANGE_KINDS),
|
|
@@ -444,6 +492,8 @@ export {
|
|
|
444
492
|
AGENT_CHECK_STATUSES,
|
|
445
493
|
AGENT_FILE_CHANGE_KINDS,
|
|
446
494
|
AGENT_JOB_STATUSES,
|
|
495
|
+
AGENT_WORKSPACE_SNAPSHOT_LIMITS,
|
|
496
|
+
AGENT_WORKSPACE_STATES,
|
|
447
497
|
DEFAULT_AGENT_LIMITS,
|
|
448
498
|
ERROR_CODES,
|
|
449
499
|
MAX_ANNOTATION_INSTRUCTION_CHARACTERS,
|
|
@@ -468,6 +518,8 @@ export {
|
|
|
468
518
|
agentJobResultResponseSchema,
|
|
469
519
|
agentJobResultSchema,
|
|
470
520
|
agentJobSnapshotSchema,
|
|
521
|
+
agentWorkspaceHealthRequestSchema,
|
|
522
|
+
agentWorkspaceHealthSnapshotSchema,
|
|
471
523
|
formatSourceMarker,
|
|
472
524
|
getAgentJobEndpoint,
|
|
473
525
|
isSensitiveName,
|
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/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/endpoints.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 TOOL_DENIED: \"TOOL_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","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\";\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_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","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 sourceContext: `${SPOTPATCH_API_BASE}/source-context`,\n openEditor: `${SPOTPATCH_API_BASE}/open-editor`,\n agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,\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","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\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 agentJobCreateRequestSchema = z.strictObject({\n annotation: spotAnnotationRequestSchema,\n providerProfileId: profileIdSchema,\n modelProfileId: profileIdSchema,\n providerDataConsent: z.literal(true),\n});\n\nexport const agentJobActionRequestSchema = z.strictObject({});\n\nexport type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;\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}\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} 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 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(1),\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 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,EACtB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,gBAAgB;AAClB;;;ACxBA,IAAM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;AAAA,IAC7B,MAAMD,GAAE,QAAQ,OAAO;AAAA,IACvB,MAAMA,GAAE,aAAa,EAAE,QAAQ,uBAAuB,CAAC;AAAA,EACzD,CAAC;AAAA,EACD,wBAAwB,OAAO;AAAA,IAC7B,MAAMA,GAAE,QAAQ,cAAc;AAAA,IAC9B,MAAMA,GAAE,aAAa,EAAE,WAAWA,GAAE,QAAQ,IAAI,EAAE,CAAC;AAAA,EACrD,CAAC;AAAA,EACD,wBAAwB,OAAO;AAAA,IAC7B,MAAMA,GAAE,QAAQ,OAAO;AAAA,IACvB,MAAMA,GAAE,aAAa;AAAA,MACnB,MAAM;AAAA,MACN,SAASC,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;;;ACpKI,IAAM,2BACX;","names":["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/editor.ts","../src/model/agent.ts","../src/model/source-marker.ts","../src/protocol/endpoints.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_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","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","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 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","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\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 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(1),\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 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,EACtB,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,yBAAyB;AAAA,EACzB,gCAAgC;AAAA,EAChC,qBAAqB;AAAA,EACrB,kCAAkC;AAAA,EAClC,gCAAgC;AAAA,EAChC,oCAAoC;AAAA,EACpC,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,mBAA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