@spotpatch/shared 1.4.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 +24 -8
- package/dist/index.cjs +221 -138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -13
- package/dist/index.d.ts +43 -13
- package/dist/index.js +217 -138
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
4
|
-
shared by the SpotPatch packages.
|
|
5
|
+
# `@spotpatch/shared`
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
[`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite) instead of
|
|
8
|
-
depending on this internal package directly.
|
|
7
|
+
## English
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
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,
|
|
@@ -191,9 +195,97 @@ var SPOTPATCH_LOCALE_PREFERENCES = Object.freeze([
|
|
|
191
195
|
...SPOTPATCH_LOCALES
|
|
192
196
|
]);
|
|
193
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
|
+
|
|
194
216
|
// src/model/editor.ts
|
|
195
217
|
var SPOTPATCH_EDITOR_PREFERENCES = ["auto", "vscode", "cursor"];
|
|
196
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
|
+
|
|
197
289
|
// src/model/agent.ts
|
|
198
290
|
var DEFAULT_AGENT_LIMITS = Object.freeze({
|
|
199
291
|
maxTurns: 20,
|
|
@@ -275,102 +367,89 @@ function parseSourceMarker(value) {
|
|
|
275
367
|
return Object.freeze({ fileId, line, column });
|
|
276
368
|
}
|
|
277
369
|
|
|
278
|
-
// src/protocol/endpoints.ts
|
|
279
|
-
var SPOTPATCH_API_BASE = "/__spotpatch/v1";
|
|
280
|
-
var SPOTPATCH_TOKEN_HEADER = "X-SpotPatch-Token";
|
|
281
|
-
var SPOTPATCH_ENDPOINTS = Object.freeze({
|
|
282
|
-
sourceContext: `${SPOTPATCH_API_BASE}/source-context`,
|
|
283
|
-
openEditor: `${SPOTPATCH_API_BASE}/open-editor`,
|
|
284
|
-
agentCapability: `${SPOTPATCH_API_BASE}/agent/capability`,
|
|
285
|
-
agentWorkspaceHealth: `${SPOTPATCH_API_BASE}/agent/workspace-health`,
|
|
286
|
-
agentJobs: `${SPOTPATCH_API_BASE}/agent/jobs`
|
|
287
|
-
});
|
|
288
|
-
function getAgentJobEndpoint(jobId, action) {
|
|
289
|
-
return `${SPOTPATCH_ENDPOINTS.agentJobs}/${encodeURIComponent(jobId)}/${action}`;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
370
|
// src/protocol/requests.ts
|
|
293
|
-
var
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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()
|
|
298
377
|
});
|
|
299
378
|
var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
|
|
300
|
-
maxLines:
|
|
379
|
+
maxLines: import_zod2.z.number().int().positive()
|
|
301
380
|
}).strict();
|
|
302
381
|
var openEditorRequestSchema = sourceCoordinatesSchema.strict();
|
|
303
|
-
var
|
|
304
|
-
var boundedString = (maximum) =>
|
|
305
|
-
var sourceRefSchema =
|
|
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({
|
|
306
385
|
fileId: boundedString(128).optional(),
|
|
307
386
|
relativePath: boundedString(1024).optional(),
|
|
308
|
-
line:
|
|
309
|
-
column:
|
|
310
|
-
origin:
|
|
311
|
-
confidence:
|
|
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"])
|
|
312
391
|
});
|
|
313
|
-
var matchedStyleRuleSchema =
|
|
392
|
+
var matchedStyleRuleSchema = import_zod2.z.strictObject({
|
|
314
393
|
selector: boundedString(2048),
|
|
315
394
|
declarations: boundedString(8192),
|
|
316
395
|
source: boundedString(1024).optional(),
|
|
317
396
|
media: boundedString(1024).optional()
|
|
318
397
|
});
|
|
319
|
-
var codeContextSchema =
|
|
398
|
+
var codeContextSchema = import_zod2.z.strictObject({
|
|
320
399
|
relativePath: boundedString(1024),
|
|
321
|
-
language:
|
|
322
|
-
startLine:
|
|
323
|
-
endLine:
|
|
400
|
+
language: import_zod2.z.enum(["tsx", "jsx"]),
|
|
401
|
+
startLine: import_zod2.z.number().int().positive(),
|
|
402
|
+
endLine: import_zod2.z.number().int().positive(),
|
|
324
403
|
excerpt: boundedString(16e3),
|
|
325
|
-
boundary:
|
|
404
|
+
boundary: import_zod2.z.enum(["component", "nearby-lines"])
|
|
326
405
|
});
|
|
327
|
-
var spotTargetContextRequestSchema =
|
|
328
|
-
instruction:
|
|
406
|
+
var spotTargetContextRequestSchema = import_zod2.z.strictObject({
|
|
407
|
+
instruction: import_zod2.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
329
408
|
source: sourceRefSchema,
|
|
330
|
-
react:
|
|
331
|
-
supported:
|
|
409
|
+
react: import_zod2.z.strictObject({
|
|
410
|
+
supported: import_zod2.z.boolean(),
|
|
332
411
|
version: boundedString(64).optional(),
|
|
333
412
|
componentName: boundedString(256).optional(),
|
|
334
|
-
componentStack:
|
|
413
|
+
componentStack: import_zod2.z.array(boundedString(256)).max(64),
|
|
335
414
|
source: sourceRefSchema.optional()
|
|
336
415
|
}),
|
|
337
|
-
element:
|
|
416
|
+
element: import_zod2.z.strictObject({
|
|
338
417
|
tagName: boundedString(128),
|
|
339
418
|
selector: boundedString(2048),
|
|
340
419
|
sanitizedHtml: boundedString(8192),
|
|
341
420
|
textPreview: boundedString(2048).optional(),
|
|
342
421
|
role: boundedString(256).optional(),
|
|
343
|
-
rect:
|
|
344
|
-
x:
|
|
345
|
-
y:
|
|
346
|
-
width:
|
|
347
|
-
height:
|
|
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()
|
|
348
427
|
})
|
|
349
428
|
}),
|
|
350
|
-
styles:
|
|
351
|
-
classNames:
|
|
429
|
+
styles: import_zod2.z.strictObject({
|
|
430
|
+
classNames: import_zod2.z.array(boundedString(512)).max(256),
|
|
352
431
|
inlineStyle: boundedString(8192).optional(),
|
|
353
|
-
matchedRules:
|
|
354
|
-
computed:
|
|
355
|
-
warnings:
|
|
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)
|
|
356
435
|
}),
|
|
357
436
|
code: codeContextSchema.optional(),
|
|
358
|
-
warnings:
|
|
437
|
+
warnings: import_zod2.z.array(boundedString(1024)).max(64)
|
|
359
438
|
});
|
|
360
|
-
var spotAnnotationRequestSchema =
|
|
361
|
-
schemaVersion:
|
|
439
|
+
var spotAnnotationRequestSchema = import_zod2.z.strictObject({
|
|
440
|
+
schemaVersion: import_zod2.z.literal(3),
|
|
362
441
|
id: boundedString(128),
|
|
363
|
-
locale:
|
|
364
|
-
page:
|
|
442
|
+
locale: import_zod2.z.enum(SPOTPATCH_LOCALES),
|
|
443
|
+
page: import_zod2.z.strictObject({
|
|
365
444
|
url: boundedString(2048),
|
|
366
445
|
pathname: boundedString(2048),
|
|
367
446
|
title: boundedString(1024),
|
|
368
|
-
viewportWidth:
|
|
369
|
-
viewportHeight:
|
|
370
|
-
devicePixelRatio:
|
|
447
|
+
viewportWidth: import_zod2.z.number().nonnegative(),
|
|
448
|
+
viewportHeight: import_zod2.z.number().nonnegative(),
|
|
449
|
+
devicePixelRatio: import_zod2.z.number().positive()
|
|
371
450
|
}),
|
|
372
|
-
targets:
|
|
373
|
-
createdAt:
|
|
451
|
+
targets: import_zod2.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
452
|
+
createdAt: import_zod2.z.iso.datetime()
|
|
374
453
|
}).superRefine((annotation, context) => {
|
|
375
454
|
const total = annotation.targets.reduce(
|
|
376
455
|
(characters, target) => characters + target.instruction.length,
|
|
@@ -384,51 +463,51 @@ var spotAnnotationRequestSchema = import_zod.z.strictObject({
|
|
|
384
463
|
});
|
|
385
464
|
}
|
|
386
465
|
});
|
|
387
|
-
var agentCapabilityRequestSchema =
|
|
388
|
-
providerProfileId:
|
|
389
|
-
modelProfileId:
|
|
466
|
+
var agentCapabilityRequestSchema = import_zod2.z.strictObject({
|
|
467
|
+
providerProfileId: profileIdSchema2,
|
|
468
|
+
modelProfileId: profileIdSchema2
|
|
390
469
|
});
|
|
391
|
-
var agentWorkspaceHealthRequestSchema =
|
|
392
|
-
var agentJobCreateRequestSchema =
|
|
470
|
+
var agentWorkspaceHealthRequestSchema = import_zod2.z.strictObject({});
|
|
471
|
+
var agentJobCreateRequestSchema = import_zod2.z.strictObject({
|
|
393
472
|
annotation: spotAnnotationRequestSchema,
|
|
394
|
-
providerProfileId:
|
|
395
|
-
modelProfileId:
|
|
396
|
-
providerDataConsent:
|
|
397
|
-
workingTreeMode:
|
|
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")
|
|
398
477
|
});
|
|
399
|
-
var agentJobActionRequestSchema =
|
|
478
|
+
var agentJobActionRequestSchema = import_zod2.z.strictObject({});
|
|
400
479
|
|
|
401
480
|
// src/protocol/agent-schemas.ts
|
|
402
|
-
var
|
|
403
|
-
var
|
|
404
|
-
var boundedString2 = (maximum) =>
|
|
405
|
-
var errorCodeSchema =
|
|
406
|
-
var agentCapabilitySnapshotSchema =
|
|
407
|
-
providerProfileId:
|
|
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,
|
|
408
487
|
providerLabel: boundedString2(100),
|
|
409
|
-
modelProfileId:
|
|
488
|
+
modelProfileId: profileIdSchema3,
|
|
410
489
|
modelLabel: boundedString2(100),
|
|
411
|
-
protocol:
|
|
412
|
-
state:
|
|
413
|
-
authenticated:
|
|
414
|
-
modelAvailable:
|
|
415
|
-
toolCalling:
|
|
416
|
-
toolResultContinuation:
|
|
417
|
-
streaming:
|
|
418
|
-
checkedAt:
|
|
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(),
|
|
419
498
|
errorCode: errorCodeSchema.optional()
|
|
420
499
|
});
|
|
421
|
-
var agentWorkspaceHealthSnapshotSchema =
|
|
422
|
-
state:
|
|
423
|
-
checkedAt:
|
|
424
|
-
changes:
|
|
425
|
-
staged:
|
|
426
|
-
unstaged:
|
|
427
|
-
untracked:
|
|
428
|
-
conflicted:
|
|
429
|
-
total:
|
|
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()
|
|
430
509
|
}),
|
|
431
|
-
canIncludeLocalChanges:
|
|
510
|
+
canIncludeLocalChanges: import_zod3.z.boolean(),
|
|
432
511
|
errorCode: errorCodeSchema.optional()
|
|
433
512
|
}).refine(
|
|
434
513
|
({ state, changes, canIncludeLocalChanges, errorCode }) => {
|
|
@@ -446,42 +525,42 @@ var agentWorkspaceHealthSnapshotSchema = import_zod2.z.strictObject({
|
|
|
446
525
|
},
|
|
447
526
|
{ message: "Agent workspace health fields are inconsistent." }
|
|
448
527
|
);
|
|
449
|
-
var agentChangedFileSchema =
|
|
528
|
+
var agentChangedFileSchema = import_zod3.z.strictObject({
|
|
450
529
|
relativePath: boundedString2(1024),
|
|
451
|
-
kind:
|
|
452
|
-
additions:
|
|
453
|
-
deletions:
|
|
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()
|
|
454
533
|
});
|
|
455
|
-
var agentCheckResultSchema =
|
|
456
|
-
checkId:
|
|
534
|
+
var agentCheckResultSchema = import_zod3.z.strictObject({
|
|
535
|
+
checkId: profileIdSchema3,
|
|
457
536
|
label: boundedString2(100),
|
|
458
|
-
status:
|
|
459
|
-
durationMs:
|
|
537
|
+
status: import_zod3.z.enum(AGENT_CHECK_STATUSES),
|
|
538
|
+
durationMs: import_zod3.z.number().int().nonnegative(),
|
|
460
539
|
output: boundedString2(8e4)
|
|
461
540
|
});
|
|
462
|
-
var agentJobSnapshotSchema =
|
|
463
|
-
jobId:
|
|
464
|
-
status:
|
|
465
|
-
providerProfileId:
|
|
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,
|
|
466
545
|
providerLabel: boundedString2(100),
|
|
467
|
-
modelProfileId:
|
|
546
|
+
modelProfileId: profileIdSchema3,
|
|
468
547
|
modelLabel: boundedString2(100),
|
|
469
548
|
phaseMessage: boundedString2(1024),
|
|
470
|
-
createdAt:
|
|
471
|
-
updatedAt:
|
|
472
|
-
canCancel:
|
|
473
|
-
canApply:
|
|
474
|
-
canRevert:
|
|
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(),
|
|
475
554
|
errorCode: errorCodeSchema.optional()
|
|
476
555
|
});
|
|
477
|
-
var agentJobResultSchema =
|
|
478
|
-
jobId:
|
|
556
|
+
var agentJobResultSchema = import_zod3.z.strictObject({
|
|
557
|
+
jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
479
558
|
summary: boundedString2(8e4),
|
|
480
559
|
diff: boundedString2(1e6),
|
|
481
|
-
files:
|
|
482
|
-
checks:
|
|
560
|
+
files: import_zod3.z.array(agentChangedFileSchema).max(100),
|
|
561
|
+
checks: import_zod3.z.array(agentCheckResultSchema).max(100)
|
|
483
562
|
});
|
|
484
|
-
var agentJobResultResponseSchema =
|
|
563
|
+
var agentJobResultResponseSchema = import_zod3.z.strictObject({
|
|
485
564
|
snapshot: agentJobSnapshotSchema,
|
|
486
565
|
result: agentJobResultSchema.optional()
|
|
487
566
|
}).superRefine((value, context) => {
|
|
@@ -493,44 +572,44 @@ var agentJobResultResponseSchema = import_zod2.z.strictObject({
|
|
|
493
572
|
});
|
|
494
573
|
}
|
|
495
574
|
});
|
|
496
|
-
var agentJobEventBaseSchema =
|
|
497
|
-
schemaVersion:
|
|
498
|
-
sequence:
|
|
499
|
-
jobId:
|
|
500
|
-
status:
|
|
501
|
-
timestamp:
|
|
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()
|
|
502
581
|
});
|
|
503
|
-
var agentJobEventSchema =
|
|
582
|
+
var agentJobEventSchema = import_zod3.z.discriminatedUnion("type", [
|
|
504
583
|
agentJobEventBaseSchema.extend({
|
|
505
|
-
type:
|
|
506
|
-
data:
|
|
584
|
+
type: import_zod3.z.literal("snapshot"),
|
|
585
|
+
data: import_zod3.z.strictObject({ snapshot: agentJobSnapshotSchema })
|
|
507
586
|
}),
|
|
508
587
|
agentJobEventBaseSchema.extend({
|
|
509
|
-
type:
|
|
510
|
-
data:
|
|
588
|
+
type: import_zod3.z.literal("phase"),
|
|
589
|
+
data: import_zod3.z.strictObject({ message: boundedString2(1024) })
|
|
511
590
|
}),
|
|
512
591
|
agentJobEventBaseSchema.extend({
|
|
513
|
-
type:
|
|
514
|
-
data:
|
|
515
|
-
turn:
|
|
592
|
+
type: import_zod3.z.literal("tool"),
|
|
593
|
+
data: import_zod3.z.strictObject({
|
|
594
|
+
turn: import_zod3.z.number().int().positive(),
|
|
516
595
|
toolCallId: boundedString2(256),
|
|
517
596
|
toolName: boundedString2(100),
|
|
518
|
-
state:
|
|
597
|
+
state: import_zod3.z.enum(["started", "succeeded", "failed"]),
|
|
519
598
|
relativePath: boundedString2(1024).optional(),
|
|
520
599
|
checkLabel: boundedString2(100).optional()
|
|
521
600
|
})
|
|
522
601
|
}),
|
|
523
602
|
agentJobEventBaseSchema.extend({
|
|
524
|
-
type:
|
|
525
|
-
data:
|
|
603
|
+
type: import_zod3.z.literal("check"),
|
|
604
|
+
data: import_zod3.z.strictObject({ result: agentCheckResultSchema })
|
|
526
605
|
}),
|
|
527
606
|
agentJobEventBaseSchema.extend({
|
|
528
|
-
type:
|
|
529
|
-
data:
|
|
607
|
+
type: import_zod3.z.literal("result-ready"),
|
|
608
|
+
data: import_zod3.z.strictObject({ hasResult: import_zod3.z.literal(true) })
|
|
530
609
|
}),
|
|
531
610
|
agentJobEventBaseSchema.extend({
|
|
532
|
-
type:
|
|
533
|
-
data:
|
|
611
|
+
type: import_zod3.z.literal("error"),
|
|
612
|
+
data: import_zod3.z.strictObject({
|
|
534
613
|
code: errorCodeSchema,
|
|
535
614
|
message: boundedString2(1024)
|
|
536
615
|
})
|
|
@@ -576,6 +655,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
576
655
|
SPOTPATCH_ENDPOINTS,
|
|
577
656
|
SPOTPATCH_LOCALES,
|
|
578
657
|
SPOTPATCH_LOCALE_PREFERENCES,
|
|
658
|
+
SPOTPATCH_NEXT_BUNDLERS,
|
|
659
|
+
SPOTPATCH_NEXT_ROUTER_KINDS,
|
|
579
660
|
SPOTPATCH_REPOSITORY_URL,
|
|
580
661
|
SPOTPATCH_TOKEN_HEADER,
|
|
581
662
|
SpotPatchError,
|
|
@@ -597,6 +678,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
597
678
|
openEditorRequestSchema,
|
|
598
679
|
parseSourceMarker,
|
|
599
680
|
redactSensitiveText,
|
|
681
|
+
runtimeBootstrapRequestSchema,
|
|
682
|
+
runtimeConfigSchema,
|
|
600
683
|
sanitizeUrl,
|
|
601
684
|
sourceContextRequestSchema,
|
|
602
685
|
spotAnnotationRequestSchema,
|