@spotpatch/shared 1.3.0 → 1.5.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.d.ts CHANGED
@@ -27,6 +27,8 @@ declare const ERROR_CODES: {
27
27
  readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
28
28
  readonly TOOL_DENIED: "TOOL_DENIED";
29
29
  readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
30
+ readonly TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID";
31
+ readonly TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT";
30
32
  readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
31
33
  readonly PATCH_REJECTED: "PATCH_REJECTED";
32
34
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -142,6 +144,19 @@ interface SpotAnnotation {
142
144
  readonly createdAt: string;
143
145
  }
144
146
 
147
+ declare const SPOTPATCH_API_BASE: "/__spotpatch/v1";
148
+ declare const SPOTPATCH_TOKEN_HEADER: "X-SpotPatch-Token";
149
+ declare const SPOTPATCH_ENDPOINTS: Readonly<{
150
+ bootstrap: "/__spotpatch/v1/bootstrap";
151
+ sourceContext: "/__spotpatch/v1/source-context";
152
+ openEditor: "/__spotpatch/v1/open-editor";
153
+ agentCapability: "/__spotpatch/v1/agent/capability";
154
+ agentWorkspaceHealth: "/__spotpatch/v1/agent/workspace-health";
155
+ agentJobs: "/__spotpatch/v1/agent/jobs";
156
+ }>;
157
+ type AgentJobAction = "events" | "result" | "cancel" | "apply" | "revert";
158
+ declare function getAgentJobEndpoint(jobId: string, action: AgentJobAction): string;
159
+
145
160
  declare const SPOTPATCH_EDITOR_PREFERENCES: readonly ["auto", "vscode", "cursor"];
146
161
  type SpotPatchEditorPreference = (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];
147
162
  interface EditorOpenResult {
@@ -347,6 +362,33 @@ interface AgentJobResultResponse {
347
362
  readonly result?: AgentJobResult;
348
363
  }
349
364
 
365
+ declare const SPOTPATCH_NEXT_BUNDLERS: readonly ["turbopack", "webpack"];
366
+ declare const SPOTPATCH_NEXT_ROUTER_KINDS: readonly ["app", "pages", "hybrid"];
367
+ type SpotPatchNextBundler = (typeof SPOTPATCH_NEXT_BUNDLERS)[number];
368
+ type SpotPatchNextRouterKind = (typeof SPOTPATCH_NEXT_ROUTER_KINDS)[number];
369
+ interface RuntimeConfigBase {
370
+ readonly apiBase: typeof SPOTPATCH_API_BASE;
371
+ readonly ai: RuntimeAiConfig;
372
+ readonly budget: Readonly<ContextBudget>;
373
+ readonly debug: boolean;
374
+ readonly editor: (typeof SPOTPATCH_EDITOR_PREFERENCES)[number];
375
+ readonly frameworkVersion: string;
376
+ readonly locale: (typeof SPOTPATCH_LOCALE_PREFERENCES)[number];
377
+ readonly maxTargets: number;
378
+ readonly redact: boolean;
379
+ readonly sessionToken: string;
380
+ readonly shortcut: string;
381
+ readonly spotPatchVersion: string;
382
+ }
383
+ type SpotPatchRuntimeConfig = RuntimeConfigBase & (Readonly<{
384
+ framework: "vite";
385
+ }> | Readonly<{
386
+ bundler: SpotPatchNextBundler;
387
+ framework: "next";
388
+ routerKind: SpotPatchNextRouterKind;
389
+ }>);
390
+ declare const runtimeConfigSchema: z.ZodType<SpotPatchRuntimeConfig>;
391
+
350
392
  declare const SOURCE_MARKER_ATTRIBUTE: "data-spotpatch-source";
351
393
  interface SourceMarker {
352
394
  readonly fileId: string;
@@ -356,18 +398,7 @@ interface SourceMarker {
356
398
  declare function formatSourceMarker(marker: SourceMarker): string;
357
399
  declare function parseSourceMarker(value: string | null): SourceMarker | undefined;
358
400
 
359
- declare const SPOTPATCH_API_BASE: "/__spotpatch/v1";
360
- declare const SPOTPATCH_TOKEN_HEADER: "X-SpotPatch-Token";
361
- declare const SPOTPATCH_ENDPOINTS: Readonly<{
362
- sourceContext: "/__spotpatch/v1/source-context";
363
- openEditor: "/__spotpatch/v1/open-editor";
364
- agentCapability: "/__spotpatch/v1/agent/capability";
365
- agentWorkspaceHealth: "/__spotpatch/v1/agent/workspace-health";
366
- agentJobs: "/__spotpatch/v1/agent/jobs";
367
- }>;
368
- type AgentJobAction = "events" | "result" | "cancel" | "apply" | "revert";
369
- declare function getAgentJobEndpoint(jobId: string, action: AgentJobAction): string;
370
-
401
+ declare const runtimeBootstrapRequestSchema: z.ZodObject<{}, z.core.$strict>;
371
402
  declare const sourceContextRequestSchema: z.ZodObject<{
372
403
  fileId: z.ZodString;
373
404
  line: z.ZodNumber;
@@ -684,6 +715,7 @@ declare const agentJobCreateRequestSchema: z.ZodObject<{
684
715
  }, z.core.$strict>;
685
716
  declare const agentJobActionRequestSchema: z.ZodObject<{}, z.core.$strict>;
686
717
  type SourceContextRequest = z.infer<typeof sourceContextRequestSchema>;
718
+ type RuntimeBootstrapRequest = z.infer<typeof runtimeBootstrapRequestSchema>;
687
719
  type OpenEditorRequest = z.infer<typeof openEditorRequestSchema>;
688
720
  type AgentCapabilityRequest = z.infer<typeof agentCapabilityRequestSchema>;
689
721
  interface AgentJobCreateRequest {
@@ -695,7 +727,7 @@ interface AgentJobCreateRequest {
695
727
  }
696
728
 
697
729
  interface AgentJobEventBase {
698
- readonly schemaVersion: 1;
730
+ readonly schemaVersion: 2;
699
731
  readonly sequence: number;
700
732
  readonly jobId: string;
701
733
  readonly status: AgentJobStatus;
@@ -714,6 +746,7 @@ type AgentJobEvent = (AgentJobEventBase & {
714
746
  }) | (AgentJobEventBase & {
715
747
  readonly type: "tool";
716
748
  readonly data: Readonly<{
749
+ turn: number;
717
750
  toolCallId: string;
718
751
  toolName: string;
719
752
  state: "started" | "succeeded" | "failed";
@@ -787,6 +820,8 @@ declare const agentCapabilitySnapshotSchema: z.ZodObject<{
787
820
  readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
788
821
  readonly TOOL_DENIED: "TOOL_DENIED";
789
822
  readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
823
+ readonly TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID";
824
+ readonly TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT";
790
825
  readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
791
826
  readonly PATCH_REJECTED: "PATCH_REJECTED";
792
827
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -836,6 +871,8 @@ declare const agentWorkspaceHealthSnapshotSchema: z.ZodObject<{
836
871
  readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
837
872
  readonly TOOL_DENIED: "TOOL_DENIED";
838
873
  readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
874
+ readonly TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID";
875
+ readonly TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT";
839
876
  readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
840
877
  readonly PATCH_REJECTED: "PATCH_REJECTED";
841
878
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -919,6 +956,8 @@ declare const agentJobSnapshotSchema: z.ZodObject<{
919
956
  readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
920
957
  readonly TOOL_DENIED: "TOOL_DENIED";
921
958
  readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
959
+ readonly TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID";
960
+ readonly TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT";
922
961
  readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
923
962
  readonly PATCH_REJECTED: "PATCH_REJECTED";
924
963
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -1008,6 +1047,8 @@ declare const agentJobResultResponseSchema: z.ZodObject<{
1008
1047
  readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
1009
1048
  readonly TOOL_DENIED: "TOOL_DENIED";
1010
1049
  readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
1050
+ readonly TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID";
1051
+ readonly TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT";
1011
1052
  readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
1012
1053
  readonly PATCH_REJECTED: "PATCH_REJECTED";
1013
1054
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -1044,7 +1085,7 @@ declare const agentJobResultResponseSchema: z.ZodObject<{
1044
1085
  }, z.core.$strict>>;
1045
1086
  }, z.core.$strict>;
1046
1087
  declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1047
- schemaVersion: z.ZodLiteral<1>;
1088
+ schemaVersion: z.ZodLiteral<2>;
1048
1089
  sequence: z.ZodNumber;
1049
1090
  jobId: z.ZodString;
1050
1091
  status: z.ZodEnum<{
@@ -1119,6 +1160,8 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1119
1160
  readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
1120
1161
  readonly TOOL_DENIED: "TOOL_DENIED";
1121
1162
  readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
1163
+ readonly TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID";
1164
+ readonly TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT";
1122
1165
  readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
1123
1166
  readonly PATCH_REJECTED: "PATCH_REJECTED";
1124
1167
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -1128,7 +1171,7 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1128
1171
  }, z.core.$strict>;
1129
1172
  }, z.core.$strict>;
1130
1173
  }, z.core.$strict>, z.ZodObject<{
1131
- schemaVersion: z.ZodLiteral<1>;
1174
+ schemaVersion: z.ZodLiteral<2>;
1132
1175
  sequence: z.ZodNumber;
1133
1176
  jobId: z.ZodString;
1134
1177
  status: z.ZodEnum<{
@@ -1152,7 +1195,7 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1152
1195
  message: z.ZodString;
1153
1196
  }, z.core.$strict>;
1154
1197
  }, z.core.$strict>, z.ZodObject<{
1155
- schemaVersion: z.ZodLiteral<1>;
1198
+ schemaVersion: z.ZodLiteral<2>;
1156
1199
  sequence: z.ZodNumber;
1157
1200
  jobId: z.ZodString;
1158
1201
  status: z.ZodEnum<{
@@ -1173,6 +1216,7 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1173
1216
  timestamp: z.ZodISODateTime;
1174
1217
  type: z.ZodLiteral<"tool">;
1175
1218
  data: z.ZodObject<{
1219
+ turn: z.ZodNumber;
1176
1220
  toolCallId: z.ZodString;
1177
1221
  toolName: z.ZodString;
1178
1222
  state: z.ZodEnum<{
@@ -1184,7 +1228,7 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1184
1228
  checkLabel: z.ZodOptional<z.ZodString>;
1185
1229
  }, z.core.$strict>;
1186
1230
  }, z.core.$strict>, z.ZodObject<{
1187
- schemaVersion: z.ZodLiteral<1>;
1231
+ schemaVersion: z.ZodLiteral<2>;
1188
1232
  sequence: z.ZodNumber;
1189
1233
  jobId: z.ZodString;
1190
1234
  status: z.ZodEnum<{
@@ -1219,7 +1263,7 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1219
1263
  }, z.core.$strict>;
1220
1264
  }, z.core.$strict>;
1221
1265
  }, z.core.$strict>, z.ZodObject<{
1222
- schemaVersion: z.ZodLiteral<1>;
1266
+ schemaVersion: z.ZodLiteral<2>;
1223
1267
  sequence: z.ZodNumber;
1224
1268
  jobId: z.ZodString;
1225
1269
  status: z.ZodEnum<{
@@ -1243,7 +1287,7 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1243
1287
  hasResult: z.ZodLiteral<true>;
1244
1288
  }, z.core.$strict>;
1245
1289
  }, z.core.$strict>, z.ZodObject<{
1246
- schemaVersion: z.ZodLiteral<1>;
1290
+ schemaVersion: z.ZodLiteral<2>;
1247
1291
  sequence: z.ZodNumber;
1248
1292
  jobId: z.ZodString;
1249
1293
  status: z.ZodEnum<{
@@ -1291,6 +1335,8 @@ declare const agentJobEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
1291
1335
  readonly WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED";
1292
1336
  readonly TOOL_DENIED: "TOOL_DENIED";
1293
1337
  readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
1338
+ readonly TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID";
1339
+ readonly TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT";
1294
1340
  readonly TOOL_PATH_DENIED: "TOOL_PATH_DENIED";
1295
1341
  readonly PATCH_REJECTED: "PATCH_REJECTED";
1296
1342
  readonly VALIDATION_FAILED: "VALIDATION_FAILED";
@@ -1316,4 +1362,4 @@ type ApiResponse<T> = ApiSuccess<T> | ApiFailure;
1316
1362
 
1317
1363
  declare const SPOTPATCH_REPOSITORY_URL: "https://github.com/huanglvjing/spotpatch";
1318
1364
 
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 };
1365
+ export { AGENT_CAPABILITY_STATES, AGENT_CHECK_STATUSES, AGENT_FILE_CHANGE_KINDS, AGENT_JOB_STATUSES, AGENT_WORKSPACE_SNAPSHOT_LIMITS, AGENT_WORKSPACE_STATES, type AgentApplyMode, type AgentCapabilityRequest, type AgentCapabilitySnapshot, type AgentCapabilityState, type AgentChangedFile, type AgentCheckDefinition, type AgentCheckResult, type AgentCheckStatus, type AgentFileChangeKind, type AgentJobAction, type AgentJobCreateRequest, type AgentJobEvent, type AgentJobResult, type AgentJobResultResponse, type AgentJobSnapshot, type AgentJobStatus, type AgentLimits, type AgentWorkingTreeMode, type AgentWorkspaceChangeSummary, type AgentWorkspaceHealthSnapshot, type AgentWorkspaceState, type AiExecutionOptions, type AiModelProfile, type AiOptions, type AiProviderAuthentication, type AiProviderProtocol, type ApiFailure, type ApiResponse, type ApiSuccess, type CodeContext, type ContextBudget, DEFAULT_AGENT_LIMITS, ERROR_CODES, type EditorOpenResult, type ElementContext, type ErrorCode, MAX_ANNOTATION_INSTRUCTION_CHARACTERS, MAX_ANNOTATION_TARGETS, MAX_TARGET_INSTRUCTION_CHARACTERS, type MatchedStyleRule, type OpenAICompatibleProviderOptions, type OpenEditorRequest, type PageContext, type ReactContext, type ResolvedAgentCheckDefinition, type ResolvedAiExecutionOptions, type ResolvedAiModelProfile, type ResolvedAiOptions, type ResolvedOpenAICompatibleProviderOptions, type RuntimeAiConfig, type RuntimeAiModelProfile, type RuntimeAiProviderProfile, type RuntimeBootstrapRequest, SOURCE_MARKER_ATTRIBUTE, SPOTPATCH_API_BASE, SPOTPATCH_EDITOR_PREFERENCES, SPOTPATCH_ENDPOINTS, SPOTPATCH_LOCALES, SPOTPATCH_LOCALE_PREFERENCES, SPOTPATCH_NEXT_BUNDLERS, SPOTPATCH_NEXT_ROUTER_KINDS, SPOTPATCH_REPOSITORY_URL, SPOTPATCH_TOKEN_HEADER, type SourceConfidence, type SourceContextRequest, type SourceMarker, type SourceOrigin, type SourceRef, type SpotAnnotation, type SpotPatchEditorPreference, SpotPatchError, type SpotPatchLocale, type SpotPatchLocalePreference, type SpotPatchNextBundler, type SpotPatchNextRouterKind, type SpotPatchRuntimeConfig, type SpotTargetContext, type StyleContext, agentCapabilityRequestSchema, agentCapabilitySnapshotSchema, agentChangedFileSchema, agentCheckResultSchema, agentJobActionRequestSchema, agentJobCreateRequestSchema, agentJobEventSchema, agentJobResultResponseSchema, agentJobResultSchema, agentJobSnapshotSchema, agentWorkspaceHealthRequestSchema, agentWorkspaceHealthSnapshotSchema, formatSourceMarker, getAgentJobEndpoint, isSensitiveName, openEditorRequestSchema, parseSourceMarker, redactSensitiveText, runtimeBootstrapRequestSchema, runtimeConfigSchema, sanitizeUrl, sourceContextRequestSchema, spotAnnotationRequestSchema, spotTargetContextRequestSchema };