@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/README.md CHANGED
@@ -1,11 +1,27 @@
1
- # @spotpatch/shared
1
+ <p align="center">
2
+ <a href="https://github.com/huanglvjing/spotpatch"><img src="https://raw.githubusercontent.com/huanglvjing/spotpatch/main/docs/assets/spotpatch-logo.svg" alt="SpotPatch" width="560" /></a>
3
+ </p>
2
4
 
3
- Immutable data models, bounded protocol schemas, constants, and error codes
4
- shared by the SpotPatch packages.
5
+ # `@spotpatch/shared`
5
6
 
6
- Applications should install and configure
7
- [`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite) instead of
8
- depending on this internal package directly.
7
+ ## English
9
8
 
10
- See the [SpotPatch repository](https://github.com/huanglvjing/spotpatch) for the
11
- public API and protocol documentation.
9
+ The shared contract package for SpotPatch. It provides immutable data models, bounded protocol schemas, endpoint constants, error codes, runtime bootstrap types, Agent events, and AI configuration types used across Node and browser packages.
10
+
11
+ Applications should install a framework adapter such as [`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite) instead of depending on this package for UI integration. Changes to this package are versioned because they define compatibility between independently built SpotPatch packages.
12
+
13
+ Requires Node.js `>=20.19.0` when used in Node environments.
14
+
15
+ ## 简体中文
16
+
17
+ 这是 SpotPatch 的共享契约包,提供不可变数据模型、有界协议 Schema、端点常量、错误码、Runtime bootstrap 类型、Agent 事件和 AI 配置类型,供 Node 与浏览器包共同使用。
18
+
19
+ 业务应用应安装 [`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite) 等框架适配器,而不是把本包当作 UI 接入。该包独立版本化,是因为它定义了不同 SpotPatch 构建产物之间的兼容契约。
20
+
21
+ 在 Node 环境中使用时要求 Node.js `>=20.19.0`。
22
+
23
+ ## Links / 链接
24
+
25
+ - [Repository / 仓库](https://github.com/huanglvjing/spotpatch)
26
+ - [Public models / 公共模型](https://github.com/huanglvjing/spotpatch/blob/main/docs/%E6%8A%80%E6%9C%AF%E6%96%B9%E6%A1%88/03-%E5%85%AC%E5%85%B1API%E4%B8%8E%E6%95%B0%E6%8D%AE%E6%A8%A1%E5%9E%8B.md)
27
+ - [MIT License / 许可证](https://github.com/huanglvjing/spotpatch/blob/main/LICENSE)
package/dist/index.cjs CHANGED
@@ -37,6 +37,8 @@ __export(index_exports, {
37
37
  SPOTPATCH_ENDPOINTS: () => SPOTPATCH_ENDPOINTS,
38
38
  SPOTPATCH_LOCALES: () => SPOTPATCH_LOCALES,
39
39
  SPOTPATCH_LOCALE_PREFERENCES: () => SPOTPATCH_LOCALE_PREFERENCES,
40
+ SPOTPATCH_NEXT_BUNDLERS: () => SPOTPATCH_NEXT_BUNDLERS,
41
+ SPOTPATCH_NEXT_ROUTER_KINDS: () => SPOTPATCH_NEXT_ROUTER_KINDS,
40
42
  SPOTPATCH_REPOSITORY_URL: () => SPOTPATCH_REPOSITORY_URL,
41
43
  SPOTPATCH_TOKEN_HEADER: () => SPOTPATCH_TOKEN_HEADER,
42
44
  SpotPatchError: () => SpotPatchError,
@@ -58,6 +60,8 @@ __export(index_exports, {
58
60
  openEditorRequestSchema: () => openEditorRequestSchema,
59
61
  parseSourceMarker: () => parseSourceMarker,
60
62
  redactSensitiveText: () => redactSensitiveText,
63
+ runtimeBootstrapRequestSchema: () => runtimeBootstrapRequestSchema,
64
+ runtimeConfigSchema: () => runtimeConfigSchema,
61
65
  sanitizeUrl: () => sanitizeUrl,
62
66
  sourceContextRequestSchema: () => sourceContextRequestSchema,
63
67
  spotAnnotationRequestSchema: () => spotAnnotationRequestSchema,
@@ -103,6 +107,8 @@ var ERROR_CODES = {
103
107
  WORKTREE_LOCAL_CHANGES_UNSUPPORTED: "WORKTREE_LOCAL_CHANGES_UNSUPPORTED",
104
108
  TOOL_DENIED: "TOOL_DENIED",
105
109
  TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
110
+ TOOL_ARGUMENTS_INVALID: "TOOL_ARGUMENTS_INVALID",
111
+ TOOL_CALL_ID_CONFLICT: "TOOL_CALL_ID_CONFLICT",
106
112
  TOOL_PATH_DENIED: "TOOL_PATH_DENIED",
107
113
  PATCH_REJECTED: "PATCH_REJECTED",
108
114
  VALIDATION_FAILED: "VALIDATION_FAILED",
@@ -189,9 +195,97 @@ var SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([
189
195
  ...SPOTPATCH_LOCALES
190
196
  ]);
191
197
 
198
+ // src/model/runtime-config.ts
199
+ var import_zod = require("zod");
200
+
201
+ // src/protocol/endpoints.ts
202
+ var SPOTPATCH_API_BASE = "/__spotpatch/v1";
203
+ var SPOTPATCH_TOKEN_HEADER = "X-SpotPatch-Token";
204
+ var SPOTPATCH_ENDPOINTS = Object.freeze({
205
+ bootstrap: `${SPOTPATCH_API_BASE}/bootstrap`,
206
+ sourceContext: `${SPOTPATCH_API_BASE}/source-context`,
207
+ openEditor: `${SPOTPATCH_API_BASE}/open-editor`,
208
+ agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
209
+ agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
210
+ agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`
211
+ });
212
+ function getAgentJobEndpoint(jobId, action) {
213
+ return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;
214
+ }
215
+
192
216
  // src/model/editor.ts
193
217
  var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
194
218
 
219
+ // src/model/runtime-config.ts
220
+ var SPOTPATCH_NEXT_BUNDLERS = Object.freeze(["turbopack", "webpack"]);
221
+ var SPOTPATCH_NEXT_ROUTER_KINDS = Object.freeze([
222
+ "app",
223
+ "pages",
224
+ "hybrid"
225
+ ]);
226
+ var boundedText = (maximum) => import_zod.z.string().trim().min(1).max(maximum);
227
+ var profileIdSchema = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/u);
228
+ var runtimeAiModelSchema = import_zod.z.strictObject({
229
+ id: profileIdSchema,
230
+ label: boundedText(100)
231
+ });
232
+ var runtimeAiProviderSchema = import_zod.z.strictObject({
233
+ id: profileIdSchema,
234
+ label: boundedText(100),
235
+ protocol: import_zod.z.enum(["responses", "chat-completions"]),
236
+ models: import_zod.z.array(runtimeAiModelSchema).min(1).max(64),
237
+ defaultModel: profileIdSchema
238
+ }).refine(
239
+ ({ defaultModel, models }) => models.some(({ id }) => id === defaultModel) && new Set(models.map(({ id }) => id)).size === models.length,
240
+ { message: "Runtime AI model profiles are inconsistent." }
241
+ );
242
+ var runtimeAiConfigSchema = import_zod.z.discriminatedUnion("enabled", [
243
+ import_zod.z.strictObject({ enabled: import_zod.z.literal(false) }),
244
+ import_zod.z.strictObject({
245
+ enabled: import_zod.z.literal(true),
246
+ providers: import_zod.z.array(runtimeAiProviderSchema).min(1).max(32),
247
+ defaultProvider: profileIdSchema,
248
+ applyMode: import_zod.z.enum(["review", "auto"])
249
+ }).refine(
250
+ ({ defaultProvider, providers }) => providers.some(({ id }) => id === defaultProvider) && new Set(providers.map(({ id }) => id)).size === providers.length,
251
+ { message: "Runtime AI provider profiles are inconsistent." }
252
+ )
253
+ ]);
254
+ var positiveInteger = import_zod.z.number().int().positive();
255
+ var runtimeConfigBaseShape = {
256
+ apiBase: import_zod.z.literal(SPOTPATCH_API_BASE),
257
+ ai: runtimeAiConfigSchema,
258
+ budget: import_zod.z.strictObject({
259
+ totalCharacters: positiveInteger,
260
+ domCharacters: positiveInteger,
261
+ cssCharacters: positiveInteger,
262
+ codeCharacters: positiveInteger,
263
+ maxCodeLines: positiveInteger,
264
+ maxComponentDepth: positiveInteger
265
+ }),
266
+ debug: import_zod.z.boolean(),
267
+ editor: import_zod.z.enum(SPOTPATCH_EDITOR_PREFERENCES),
268
+ frameworkVersion: boundedText(64),
269
+ locale: import_zod.z.enum(SPOTPATCH_LOCALE_PREFERENCES),
270
+ maxTargets: import_zod.z.number().int().min(1).max(MAX_ANNOTATION_TARGETS),
271
+ redact: import_zod.z.boolean(),
272
+ sessionToken: import_zod.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
273
+ shortcut: boundedText(128),
274
+ spotPatchVersion: boundedText(64)
275
+ };
276
+ var runtimeConfigSchema = import_zod.z.discriminatedUnion("framework", [
277
+ import_zod.z.strictObject({
278
+ ...runtimeConfigBaseShape,
279
+ framework: import_zod.z.literal("vite")
280
+ }),
281
+ import_zod.z.strictObject({
282
+ ...runtimeConfigBaseShape,
283
+ bundler: import_zod.z.enum(SPOTPATCH_NEXT_BUNDLERS),
284
+ framework: import_zod.z.literal("next"),
285
+ routerKind: import_zod.z.enum(SPOTPATCH_NEXT_ROUTER_KINDS)
286
+ })
287
+ ]);
288
+
195
289
  // src/model/agent.ts
196
290
  var DEFAULT_AGENT_LIMITS = Object.freeze({
197
291
  maxTurns: 20,
@@ -273,102 +367,89 @@ function parseSourceMarker(value) {
273
367
  return Object.freeze({ fileId, line, column });
274
368
  }
275
369
 
276
- // src/protocol/endpoints.ts
277
- var SPOTPATCH_API_BASE = "/__spotpatch/v1";
278
- var SPOTPATCH_TOKEN_HEADER = "X-SpotPatch-Token";
279
- var SPOTPATCH_ENDPOINTS = Object.freeze({
280
- sourceContext: `${SPOTPATCH_API_BASE}/source-context`,
281
- openEditor: `${SPOTPATCH_API_BASE}/open-editor`,
282
- agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
283
- agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
284
- agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`
285
- });
286
- function getAgentJobEndpoint(jobId, action) {
287
- return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;
288
- }
289
-
290
370
  // src/protocol/requests.ts
291
- var import_zod = require("zod");
292
- var sourceCoordinatesSchema = import_zod.z.strictObject({
293
- fileId: import_zod.z.string().min(1).max(128),
294
- line: import_zod.z.number().int().positive(),
295
- column: import_zod.z.number().int().positive()
371
+ var import_zod2 = require("zod");
372
+ var runtimeBootstrapRequestSchema = import_zod2.z.strictObject({});
373
+ var sourceCoordinatesSchema = import_zod2.z.strictObject({
374
+ fileId: import_zod2.z.string().min(1).max(128),
375
+ line: import_zod2.z.number().int().positive(),
376
+ column: import_zod2.z.number().int().positive()
296
377
  });
297
378
  var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
298
- maxLines: import_zod.z.number().int().positive()
379
+ maxLines: import_zod2.z.number().int().positive()
299
380
  }).strict();
300
381
  var openEditorRequestSchema = sourceCoordinatesSchema.strict();
301
- var profileIdSchema = import_zod.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
302
- var boundedString = (maximum) => import_zod.z.string().max(maximum);
303
- var sourceRefSchema = import_zod.z.strictObject({
382
+ var profileIdSchema2 = import_zod2.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
383
+ var boundedString = (maximum) => import_zod2.z.string().max(maximum);
384
+ var sourceRefSchema = import_zod2.z.strictObject({
304
385
  fileId: boundedString(128).optional(),
305
386
  relativePath: boundedString(1024).optional(),
306
- line: import_zod.z.number().int().positive().optional(),
307
- column: import_zod.z.number().int().positive().optional(),
308
- origin: import_zod.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
309
- confidence: import_zod.z.enum(["exact", "probable", "approximate", "unknown"])
387
+ line: import_zod2.z.number().int().positive().optional(),
388
+ column: import_zod2.z.number().int().positive().optional(),
389
+ origin: import_zod2.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
390
+ confidence: import_zod2.z.enum(["exact", "probable", "approximate", "unknown"])
310
391
  });
311
- var matchedStyleRuleSchema = import_zod.z.strictObject({
392
+ var matchedStyleRuleSchema = import_zod2.z.strictObject({
312
393
  selector: boundedString(2048),
313
394
  declarations: boundedString(8192),
314
395
  source: boundedString(1024).optional(),
315
396
  media: boundedString(1024).optional()
316
397
  });
317
- var codeContextSchema = import_zod.z.strictObject({
398
+ var codeContextSchema = import_zod2.z.strictObject({
318
399
  relativePath: boundedString(1024),
319
- language: import_zod.z.enum(["tsx", "jsx"]),
320
- startLine: import_zod.z.number().int().positive(),
321
- endLine: import_zod.z.number().int().positive(),
400
+ language: import_zod2.z.enum(["tsx", "jsx"]),
401
+ startLine: import_zod2.z.number().int().positive(),
402
+ endLine: import_zod2.z.number().int().positive(),
322
403
  excerpt: boundedString(16e3),
323
- boundary: import_zod.z.enum(["component", "nearby-lines"])
404
+ boundary: import_zod2.z.enum(["component", "nearby-lines"])
324
405
  });
325
- var spotTargetContextRequestSchema = import_zod.z.strictObject({
326
- instruction: import_zod.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
406
+ var spotTargetContextRequestSchema = import_zod2.z.strictObject({
407
+ instruction: import_zod2.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
327
408
  source: sourceRefSchema,
328
- react: import_zod.z.strictObject({
329
- supported: import_zod.z.boolean(),
409
+ react: import_zod2.z.strictObject({
410
+ supported: import_zod2.z.boolean(),
330
411
  version: boundedString(64).optional(),
331
412
  componentName: boundedString(256).optional(),
332
- componentStack: import_zod.z.array(boundedString(256)).max(64),
413
+ componentStack: import_zod2.z.array(boundedString(256)).max(64),
333
414
  source: sourceRefSchema.optional()
334
415
  }),
335
- element: import_zod.z.strictObject({
416
+ element: import_zod2.z.strictObject({
336
417
  tagName: boundedString(128),
337
418
  selector: boundedString(2048),
338
419
  sanitizedHtml: boundedString(8192),
339
420
  textPreview: boundedString(2048).optional(),
340
421
  role: boundedString(256).optional(),
341
- rect: import_zod.z.strictObject({
342
- x: import_zod.z.number(),
343
- y: import_zod.z.number(),
344
- width: import_zod.z.number().nonnegative(),
345
- height: import_zod.z.number().nonnegative()
422
+ rect: import_zod2.z.strictObject({
423
+ x: import_zod2.z.number(),
424
+ y: import_zod2.z.number(),
425
+ width: import_zod2.z.number().nonnegative(),
426
+ height: import_zod2.z.number().nonnegative()
346
427
  })
347
428
  }),
348
- styles: import_zod.z.strictObject({
349
- classNames: import_zod.z.array(boundedString(512)).max(256),
429
+ styles: import_zod2.z.strictObject({
430
+ classNames: import_zod2.z.array(boundedString(512)).max(256),
350
431
  inlineStyle: boundedString(8192).optional(),
351
- matchedRules: import_zod.z.array(matchedStyleRuleSchema).max(256),
352
- computed: import_zod.z.record(boundedString(256), boundedString(2048)),
353
- warnings: import_zod.z.array(boundedString(1024)).max(64)
432
+ matchedRules: import_zod2.z.array(matchedStyleRuleSchema).max(256),
433
+ computed: import_zod2.z.record(boundedString(256), boundedString(2048)),
434
+ warnings: import_zod2.z.array(boundedString(1024)).max(64)
354
435
  }),
355
436
  code: codeContextSchema.optional(),
356
- warnings: import_zod.z.array(boundedString(1024)).max(64)
437
+ warnings: import_zod2.z.array(boundedString(1024)).max(64)
357
438
  });
358
- var spotAnnotationRequestSchema = import_zod.z.strictObject({
359
- schemaVersion: import_zod.z.literal(3),
439
+ var spotAnnotationRequestSchema = import_zod2.z.strictObject({
440
+ schemaVersion: import_zod2.z.literal(3),
360
441
  id: boundedString(128),
361
- locale: import_zod.z.enum(SPOTPATCH_LOCALES),
362
- page: import_zod.z.strictObject({
442
+ locale: import_zod2.z.enum(SPOTPATCH_LOCALES),
443
+ page: import_zod2.z.strictObject({
363
444
  url: boundedString(2048),
364
445
  pathname: boundedString(2048),
365
446
  title: boundedString(1024),
366
- viewportWidth: import_zod.z.number().nonnegative(),
367
- viewportHeight: import_zod.z.number().nonnegative(),
368
- devicePixelRatio: import_zod.z.number().positive()
447
+ viewportWidth: import_zod2.z.number().nonnegative(),
448
+ viewportHeight: import_zod2.z.number().nonnegative(),
449
+ devicePixelRatio: import_zod2.z.number().positive()
369
450
  }),
370
- targets: import_zod.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
371
- createdAt: import_zod.z.iso.datetime()
451
+ targets: import_zod2.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
452
+ createdAt: import_zod2.z.iso.datetime()
372
453
  }).superRefine((annotation, context) => {
373
454
  const total = annotation.targets.reduce(
374
455
  (characters, target) => characters + target.instruction.length,
@@ -382,51 +463,51 @@ var spotAnnotationRequestSchema = import_zod.z.strictObject({
382
463
  });
383
464
  }
384
465
  });
385
- var agentCapabilityRequestSchema = import_zod.z.strictObject({
386
- providerProfileId: profileIdSchema,
387
- modelProfileId: profileIdSchema
466
+ var agentCapabilityRequestSchema = import_zod2.z.strictObject({
467
+ providerProfileId: profileIdSchema2,
468
+ modelProfileId: profileIdSchema2
388
469
  });
389
- var agentWorkspaceHealthRequestSchema = import_zod.z.strictObject({});
390
- var agentJobCreateRequestSchema = import_zod.z.strictObject({
470
+ var agentWorkspaceHealthRequestSchema = import_zod2.z.strictObject({});
471
+ var agentJobCreateRequestSchema = import_zod2.z.strictObject({
391
472
  annotation: spotAnnotationRequestSchema,
392
- providerProfileId: profileIdSchema,
393
- modelProfileId: profileIdSchema,
394
- providerDataConsent: import_zod.z.literal(true),
395
- workingTreeMode: import_zod.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
473
+ providerProfileId: profileIdSchema2,
474
+ modelProfileId: profileIdSchema2,
475
+ providerDataConsent: import_zod2.z.literal(true),
476
+ workingTreeMode: import_zod2.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
396
477
  });
397
- var agentJobActionRequestSchema = import_zod.z.strictObject({});
478
+ var agentJobActionRequestSchema = import_zod2.z.strictObject({});
398
479
 
399
480
  // src/protocol/agent-schemas.ts
400
- var import_zod2 = require("zod");
401
- var profileIdSchema2 = import_zod2.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
402
- var boundedString2 = (maximum) => import_zod2.z.string().max(maximum);
403
- var errorCodeSchema = import_zod2.z.enum(ERROR_CODES);
404
- var agentCapabilitySnapshotSchema = import_zod2.z.strictObject({
405
- providerProfileId: profileIdSchema2,
481
+ var import_zod3 = require("zod");
482
+ var profileIdSchema3 = import_zod3.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
483
+ var boundedString2 = (maximum) => import_zod3.z.string().max(maximum);
484
+ var errorCodeSchema = import_zod3.z.enum(ERROR_CODES);
485
+ var agentCapabilitySnapshotSchema = import_zod3.z.strictObject({
486
+ providerProfileId: profileIdSchema3,
406
487
  providerLabel: boundedString2(100),
407
- modelProfileId: profileIdSchema2,
488
+ modelProfileId: profileIdSchema3,
408
489
  modelLabel: boundedString2(100),
409
- protocol: import_zod2.z.enum(["responses", "chat-completions"]),
410
- state: import_zod2.z.enum(AGENT_CAPABILITY_STATES),
411
- authenticated: import_zod2.z.boolean(),
412
- modelAvailable: import_zod2.z.boolean(),
413
- toolCalling: import_zod2.z.boolean(),
414
- toolResultContinuation: import_zod2.z.boolean(),
415
- streaming: import_zod2.z.boolean(),
416
- checkedAt: import_zod2.z.iso.datetime().optional(),
490
+ protocol: import_zod3.z.enum(["responses", "chat-completions"]),
491
+ state: import_zod3.z.enum(AGENT_CAPABILITY_STATES),
492
+ authenticated: import_zod3.z.boolean(),
493
+ modelAvailable: import_zod3.z.boolean(),
494
+ toolCalling: import_zod3.z.boolean(),
495
+ toolResultContinuation: import_zod3.z.boolean(),
496
+ streaming: import_zod3.z.boolean(),
497
+ checkedAt: import_zod3.z.iso.datetime().optional(),
417
498
  errorCode: errorCodeSchema.optional()
418
499
  });
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()
500
+ var agentWorkspaceHealthSnapshotSchema = import_zod3.z.strictObject({
501
+ state: import_zod3.z.enum(AGENT_WORKSPACE_STATES),
502
+ checkedAt: import_zod3.z.iso.datetime(),
503
+ changes: import_zod3.z.strictObject({
504
+ staged: import_zod3.z.number().int().nonnegative(),
505
+ unstaged: import_zod3.z.number().int().nonnegative(),
506
+ untracked: import_zod3.z.number().int().nonnegative(),
507
+ conflicted: import_zod3.z.number().int().nonnegative(),
508
+ total: import_zod3.z.number().int().nonnegative()
428
509
  }),
429
- canIncludeLocalChanges: import_zod2.z.boolean(),
510
+ canIncludeLocalChanges: import_zod3.z.boolean(),
430
511
  errorCode: errorCodeSchema.optional()
431
512
  }).refine(
432
513
  ({ state, changes, canIncludeLocalChanges, errorCode }) => {
@@ -444,42 +525,42 @@ var agentWorkspaceHealthSnapshotSchema = import_zod2.z.strictObject({
444
525
  },
445
526
  { message: "Agent workspace health fields are inconsistent." }
446
527
  );
447
- var agentChangedFileSchema = import_zod2.z.strictObject({
528
+ var agentChangedFileSchema = import_zod3.z.strictObject({
448
529
  relativePath: boundedString2(1024),
449
- kind: import_zod2.z.enum(AGENT_FILE_CHANGE_KINDS),
450
- additions: import_zod2.z.number().int().nonnegative(),
451
- deletions: import_zod2.z.number().int().nonnegative()
530
+ kind: import_zod3.z.enum(AGENT_FILE_CHANGE_KINDS),
531
+ additions: import_zod3.z.number().int().nonnegative(),
532
+ deletions: import_zod3.z.number().int().nonnegative()
452
533
  });
453
- var agentCheckResultSchema = import_zod2.z.strictObject({
454
- checkId: profileIdSchema2,
534
+ var agentCheckResultSchema = import_zod3.z.strictObject({
535
+ checkId: profileIdSchema3,
455
536
  label: boundedString2(100),
456
- status: import_zod2.z.enum(AGENT_CHECK_STATUSES),
457
- durationMs: import_zod2.z.number().int().nonnegative(),
537
+ status: import_zod3.z.enum(AGENT_CHECK_STATUSES),
538
+ durationMs: import_zod3.z.number().int().nonnegative(),
458
539
  output: boundedString2(8e4)
459
540
  });
460
- var agentJobSnapshotSchema = import_zod2.z.strictObject({
461
- jobId: import_zod2.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
462
- status: import_zod2.z.enum(AGENT_JOB_STATUSES),
463
- providerProfileId: profileIdSchema2,
541
+ var agentJobSnapshotSchema = import_zod3.z.strictObject({
542
+ jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
543
+ status: import_zod3.z.enum(AGENT_JOB_STATUSES),
544
+ providerProfileId: profileIdSchema3,
464
545
  providerLabel: boundedString2(100),
465
- modelProfileId: profileIdSchema2,
546
+ modelProfileId: profileIdSchema3,
466
547
  modelLabel: boundedString2(100),
467
548
  phaseMessage: boundedString2(1024),
468
- createdAt: import_zod2.z.iso.datetime(),
469
- updatedAt: import_zod2.z.iso.datetime(),
470
- canCancel: import_zod2.z.boolean(),
471
- canApply: import_zod2.z.boolean(),
472
- canRevert: import_zod2.z.boolean(),
549
+ createdAt: import_zod3.z.iso.datetime(),
550
+ updatedAt: import_zod3.z.iso.datetime(),
551
+ canCancel: import_zod3.z.boolean(),
552
+ canApply: import_zod3.z.boolean(),
553
+ canRevert: import_zod3.z.boolean(),
473
554
  errorCode: errorCodeSchema.optional()
474
555
  });
475
- var agentJobResultSchema = import_zod2.z.strictObject({
476
- jobId: import_zod2.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
556
+ var agentJobResultSchema = import_zod3.z.strictObject({
557
+ jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
477
558
  summary: boundedString2(8e4),
478
559
  diff: boundedString2(1e6),
479
- files: import_zod2.z.array(agentChangedFileSchema).max(100),
480
- checks: import_zod2.z.array(agentCheckResultSchema).max(100)
560
+ files: import_zod3.z.array(agentChangedFileSchema).max(100),
561
+ checks: import_zod3.z.array(agentCheckResultSchema).max(100)
481
562
  });
482
- var agentJobResultResponseSchema = import_zod2.z.strictObject({
563
+ var agentJobResultResponseSchema = import_zod3.z.strictObject({
483
564
  snapshot: agentJobSnapshotSchema,
484
565
  result: agentJobResultSchema.optional()
485
566
  }).superRefine((value, context) => {
@@ -491,43 +572,44 @@ var agentJobResultResponseSchema = import_zod2.z.strictObject({
491
572
  });
492
573
  }
493
574
  });
494
- var agentJobEventBaseSchema = import_zod2.z.strictObject({
495
- schemaVersion: import_zod2.z.literal(1),
496
- sequence: import_zod2.z.number().int().positive(),
497
- jobId: import_zod2.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
498
- status: import_zod2.z.enum(AGENT_JOB_STATUSES),
499
- timestamp: import_zod2.z.iso.datetime()
575
+ var agentJobEventBaseSchema = import_zod3.z.strictObject({
576
+ schemaVersion: import_zod3.z.literal(2),
577
+ sequence: import_zod3.z.number().int().positive(),
578
+ jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
579
+ status: import_zod3.z.enum(AGENT_JOB_STATUSES),
580
+ timestamp: import_zod3.z.iso.datetime()
500
581
  });
501
- var agentJobEventSchema = import_zod2.z.discriminatedUnion("type", [
582
+ var agentJobEventSchema = import_zod3.z.discriminatedUnion("type", [
502
583
  agentJobEventBaseSchema.extend({
503
- type: import_zod2.z.literal("snapshot"),
504
- data: import_zod2.z.strictObject({ snapshot: agentJobSnapshotSchema })
584
+ type: import_zod3.z.literal("snapshot"),
585
+ data: import_zod3.z.strictObject({ snapshot: agentJobSnapshotSchema })
505
586
  }),
506
587
  agentJobEventBaseSchema.extend({
507
- type: import_zod2.z.literal("phase"),
508
- data: import_zod2.z.strictObject({ message: boundedString2(1024) })
588
+ type: import_zod3.z.literal("phase"),
589
+ data: import_zod3.z.strictObject({ message: boundedString2(1024) })
509
590
  }),
510
591
  agentJobEventBaseSchema.extend({
511
- type: import_zod2.z.literal("tool"),
512
- data: import_zod2.z.strictObject({
592
+ type: import_zod3.z.literal("tool"),
593
+ data: import_zod3.z.strictObject({
594
+ turn: import_zod3.z.number().int().positive(),
513
595
  toolCallId: boundedString2(256),
514
596
  toolName: boundedString2(100),
515
- state: import_zod2.z.enum(["started", "succeeded", "failed"]),
597
+ state: import_zod3.z.enum(["started", "succeeded", "failed"]),
516
598
  relativePath: boundedString2(1024).optional(),
517
599
  checkLabel: boundedString2(100).optional()
518
600
  })
519
601
  }),
520
602
  agentJobEventBaseSchema.extend({
521
- type: import_zod2.z.literal("check"),
522
- data: import_zod2.z.strictObject({ result: agentCheckResultSchema })
603
+ type: import_zod3.z.literal("check"),
604
+ data: import_zod3.z.strictObject({ result: agentCheckResultSchema })
523
605
  }),
524
606
  agentJobEventBaseSchema.extend({
525
- type: import_zod2.z.literal("result-ready"),
526
- data: import_zod2.z.strictObject({ hasResult: import_zod2.z.literal(true) })
607
+ type: import_zod3.z.literal("result-ready"),
608
+ data: import_zod3.z.strictObject({ hasResult: import_zod3.z.literal(true) })
527
609
  }),
528
610
  agentJobEventBaseSchema.extend({
529
- type: import_zod2.z.literal("error"),
530
- data: import_zod2.z.strictObject({
611
+ type: import_zod3.z.literal("error"),
612
+ data: import_zod3.z.strictObject({
531
613
  code: errorCodeSchema,
532
614
  message: boundedString2(1024)
533
615
  })
@@ -573,6 +655,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
573
655
  SPOTPATCH_ENDPOINTS,
574
656
  SPOTPATCH_LOCALES,
575
657
  SPOTPATCH_LOCALE_PREFERENCES,
658
+ SPOTPATCH_NEXT_BUNDLERS,
659
+ SPOTPATCH_NEXT_ROUTER_KINDS,
576
660
  SPOTPATCH_REPOSITORY_URL,
577
661
  SPOTPATCH_TOKEN_HEADER,
578
662
  SpotPatchError,
@@ -594,6 +678,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
594
678
  openEditorRequestSchema,
595
679
  parseSourceMarker,
596
680
  redactSensitiveText,
681
+ runtimeBootstrapRequestSchema,
682
+ runtimeConfigSchema,
597
683
  sanitizeUrl,
598
684
  sourceContextRequestSchema,
599
685
  spotAnnotationRequestSchema,