@spotpatch/shared 1.4.0 → 1.6.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 +20 -8
- package/dist/index.cjs +228 -142
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -13
- package/dist/index.d.ts +69 -13
- package/dist/index.js +224 -142
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
<h1><a href="https://github.com/huanglvjing/spotpatch"><img src="https://raw.githubusercontent.com/huanglvjing/spotpatch/main/docs/assets/spotpatch-npm-icon.png" alt="SpotPatch" width="48" height="48" align="absmiddle" /></a> <code>@spotpatch/shared</code></h1>
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
shared by the SpotPatch packages.
|
|
3
|
+
## English
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
[`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite) instead of
|
|
8
|
-
depending on this internal package directly.
|
|
5
|
+
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.
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
Requires Node.js `>=20.19.0` when used in Node environments.
|
|
10
|
+
|
|
11
|
+
## 简体中文
|
|
12
|
+
|
|
13
|
+
这是 SpotPatch 的共享契约包,提供不可变数据模型、有界协议 Schema、端点常量、错误码、Runtime bootstrap 类型、Agent 事件和 AI 配置类型,供 Node 与浏览器包共同使用。
|
|
14
|
+
|
|
15
|
+
业务应用应安装 [`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite) 等框架适配器,而不是把本包当作 UI 接入。该包独立版本化,是因为它定义了不同 SpotPatch 构建产物之间的兼容契约。
|
|
16
|
+
|
|
17
|
+
在 Node 环境中使用时要求 Node.js `>=20.19.0`。
|
|
18
|
+
|
|
19
|
+
## Links / 链接
|
|
20
|
+
|
|
21
|
+
- [Repository / 仓库](https://github.com/huanglvjing/spotpatch)
|
|
22
|
+
- [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)
|
|
23
|
+
- [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,98 @@ 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
|
+
sessionId: import_zod.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
273
|
+
sessionToken: import_zod.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/u),
|
|
274
|
+
shortcut: boundedText(128),
|
|
275
|
+
spotPatchVersion: boundedText(64)
|
|
276
|
+
};
|
|
277
|
+
var runtimeConfigSchema = import_zod.z.discriminatedUnion("framework", [
|
|
278
|
+
import_zod.z.strictObject({
|
|
279
|
+
...runtimeConfigBaseShape,
|
|
280
|
+
framework: import_zod.z.literal("vite")
|
|
281
|
+
}),
|
|
282
|
+
import_zod.z.strictObject({
|
|
283
|
+
...runtimeConfigBaseShape,
|
|
284
|
+
bundler: import_zod.z.enum(SPOTPATCH_NEXT_BUNDLERS),
|
|
285
|
+
framework: import_zod.z.literal("next"),
|
|
286
|
+
routerKind: import_zod.z.enum(SPOTPATCH_NEXT_ROUTER_KINDS)
|
|
287
|
+
})
|
|
288
|
+
]);
|
|
289
|
+
|
|
197
290
|
// src/model/agent.ts
|
|
198
291
|
var DEFAULT_AGENT_LIMITS = Object.freeze({
|
|
199
292
|
maxTurns: 20,
|
|
@@ -275,102 +368,91 @@ function parseSourceMarker(value) {
|
|
|
275
368
|
return Object.freeze({ fileId, line, column });
|
|
276
369
|
}
|
|
277
370
|
|
|
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
371
|
// src/protocol/requests.ts
|
|
293
|
-
var
|
|
294
|
-
var
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
372
|
+
var import_zod2 = require("zod");
|
|
373
|
+
var runtimeBootstrapRequestSchema = import_zod2.z.strictObject({});
|
|
374
|
+
var sourceCoordinatesSchema = import_zod2.z.strictObject({
|
|
375
|
+
fileId: import_zod2.z.string().min(1).max(128),
|
|
376
|
+
line: import_zod2.z.number().int().positive(),
|
|
377
|
+
column: import_zod2.z.number().int().positive()
|
|
298
378
|
});
|
|
299
379
|
var sourceContextRequestSchema = sourceCoordinatesSchema.extend({
|
|
300
|
-
maxLines:
|
|
380
|
+
maxLines: import_zod2.z.number().int().positive()
|
|
301
381
|
}).strict();
|
|
302
382
|
var openEditorRequestSchema = sourceCoordinatesSchema.strict();
|
|
303
|
-
var
|
|
304
|
-
var boundedString = (maximum) =>
|
|
305
|
-
var sourceRefSchema =
|
|
383
|
+
var profileIdSchema2 = import_zod2.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
384
|
+
var boundedString = (maximum) => import_zod2.z.string().max(maximum);
|
|
385
|
+
var sourceRefSchema = import_zod2.z.strictObject({
|
|
306
386
|
fileId: boundedString(128).optional(),
|
|
307
387
|
relativePath: boundedString(1024).optional(),
|
|
308
|
-
line:
|
|
309
|
-
column:
|
|
310
|
-
origin:
|
|
311
|
-
confidence:
|
|
388
|
+
line: import_zod2.z.number().int().positive().optional(),
|
|
389
|
+
column: import_zod2.z.number().int().positive().optional(),
|
|
390
|
+
origin: import_zod2.z.enum(["jsx-host", "react-fiber", "dom-ancestor", "none"]),
|
|
391
|
+
confidence: import_zod2.z.enum(["exact", "probable", "approximate", "unknown"])
|
|
312
392
|
});
|
|
313
|
-
var matchedStyleRuleSchema =
|
|
393
|
+
var matchedStyleRuleSchema = import_zod2.z.strictObject({
|
|
314
394
|
selector: boundedString(2048),
|
|
315
395
|
declarations: boundedString(8192),
|
|
316
396
|
source: boundedString(1024).optional(),
|
|
317
397
|
media: boundedString(1024).optional()
|
|
318
398
|
});
|
|
319
|
-
var codeContextSchema =
|
|
399
|
+
var codeContextSchema = import_zod2.z.strictObject({
|
|
320
400
|
relativePath: boundedString(1024),
|
|
321
|
-
language:
|
|
322
|
-
startLine:
|
|
323
|
-
endLine:
|
|
401
|
+
language: import_zod2.z.enum(["tsx", "jsx"]),
|
|
402
|
+
startLine: import_zod2.z.number().int().positive(),
|
|
403
|
+
endLine: import_zod2.z.number().int().positive(),
|
|
324
404
|
excerpt: boundedString(16e3),
|
|
325
|
-
boundary:
|
|
405
|
+
boundary: import_zod2.z.enum(["component", "nearby-lines"])
|
|
326
406
|
});
|
|
327
|
-
var
|
|
328
|
-
|
|
407
|
+
var pageContextSchema = import_zod2.z.strictObject({
|
|
408
|
+
url: boundedString(2048),
|
|
409
|
+
pathname: boundedString(2048),
|
|
410
|
+
title: boundedString(1024),
|
|
411
|
+
viewportWidth: import_zod2.z.number().nonnegative(),
|
|
412
|
+
viewportHeight: import_zod2.z.number().nonnegative(),
|
|
413
|
+
devicePixelRatio: import_zod2.z.number().positive()
|
|
414
|
+
});
|
|
415
|
+
var spotTargetContextRequestSchema = import_zod2.z.strictObject({
|
|
416
|
+
instruction: import_zod2.z.string().trim().min(1).max(MAX_TARGET_INSTRUCTION_CHARACTERS),
|
|
417
|
+
page: pageContextSchema.optional(),
|
|
329
418
|
source: sourceRefSchema,
|
|
330
|
-
react:
|
|
331
|
-
supported:
|
|
419
|
+
react: import_zod2.z.strictObject({
|
|
420
|
+
supported: import_zod2.z.boolean(),
|
|
332
421
|
version: boundedString(64).optional(),
|
|
333
422
|
componentName: boundedString(256).optional(),
|
|
334
|
-
componentStack:
|
|
423
|
+
componentStack: import_zod2.z.array(boundedString(256)).max(64),
|
|
335
424
|
source: sourceRefSchema.optional()
|
|
336
425
|
}),
|
|
337
|
-
element:
|
|
426
|
+
element: import_zod2.z.strictObject({
|
|
338
427
|
tagName: boundedString(128),
|
|
339
428
|
selector: boundedString(2048),
|
|
340
429
|
sanitizedHtml: boundedString(8192),
|
|
341
430
|
textPreview: boundedString(2048).optional(),
|
|
342
431
|
role: boundedString(256).optional(),
|
|
343
|
-
rect:
|
|
344
|
-
x:
|
|
345
|
-
y:
|
|
346
|
-
width:
|
|
347
|
-
height:
|
|
432
|
+
rect: import_zod2.z.strictObject({
|
|
433
|
+
x: import_zod2.z.number(),
|
|
434
|
+
y: import_zod2.z.number(),
|
|
435
|
+
width: import_zod2.z.number().nonnegative(),
|
|
436
|
+
height: import_zod2.z.number().nonnegative()
|
|
348
437
|
})
|
|
349
438
|
}),
|
|
350
|
-
styles:
|
|
351
|
-
classNames:
|
|
439
|
+
styles: import_zod2.z.strictObject({
|
|
440
|
+
classNames: import_zod2.z.array(boundedString(512)).max(256),
|
|
352
441
|
inlineStyle: boundedString(8192).optional(),
|
|
353
|
-
matchedRules:
|
|
354
|
-
computed:
|
|
355
|
-
warnings:
|
|
442
|
+
matchedRules: import_zod2.z.array(matchedStyleRuleSchema).max(256),
|
|
443
|
+
computed: import_zod2.z.record(boundedString(256), boundedString(2048)),
|
|
444
|
+
warnings: import_zod2.z.array(boundedString(1024)).max(64)
|
|
356
445
|
}),
|
|
357
446
|
code: codeContextSchema.optional(),
|
|
358
|
-
warnings:
|
|
447
|
+
warnings: import_zod2.z.array(boundedString(1024)).max(64)
|
|
359
448
|
});
|
|
360
|
-
var spotAnnotationRequestSchema =
|
|
361
|
-
schemaVersion:
|
|
449
|
+
var spotAnnotationRequestSchema = import_zod2.z.strictObject({
|
|
450
|
+
schemaVersion: import_zod2.z.literal(3),
|
|
362
451
|
id: boundedString(128),
|
|
363
|
-
locale:
|
|
364
|
-
page:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
title: boundedString(1024),
|
|
368
|
-
viewportWidth: import_zod.z.number().nonnegative(),
|
|
369
|
-
viewportHeight: import_zod.z.number().nonnegative(),
|
|
370
|
-
devicePixelRatio: import_zod.z.number().positive()
|
|
371
|
-
}),
|
|
372
|
-
targets: import_zod.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
373
|
-
createdAt: import_zod.z.iso.datetime()
|
|
452
|
+
locale: import_zod2.z.enum(SPOTPATCH_LOCALES),
|
|
453
|
+
page: pageContextSchema,
|
|
454
|
+
targets: import_zod2.z.array(spotTargetContextRequestSchema).min(1).max(MAX_ANNOTATION_TARGETS),
|
|
455
|
+
createdAt: import_zod2.z.iso.datetime()
|
|
374
456
|
}).superRefine((annotation, context) => {
|
|
375
457
|
const total = annotation.targets.reduce(
|
|
376
458
|
(characters, target) => characters + target.instruction.length,
|
|
@@ -384,51 +466,51 @@ var spotAnnotationRequestSchema = import_zod.z.strictObject({
|
|
|
384
466
|
});
|
|
385
467
|
}
|
|
386
468
|
});
|
|
387
|
-
var agentCapabilityRequestSchema =
|
|
388
|
-
providerProfileId:
|
|
389
|
-
modelProfileId:
|
|
469
|
+
var agentCapabilityRequestSchema = import_zod2.z.strictObject({
|
|
470
|
+
providerProfileId: profileIdSchema2,
|
|
471
|
+
modelProfileId: profileIdSchema2
|
|
390
472
|
});
|
|
391
|
-
var agentWorkspaceHealthRequestSchema =
|
|
392
|
-
var agentJobCreateRequestSchema =
|
|
473
|
+
var agentWorkspaceHealthRequestSchema = import_zod2.z.strictObject({});
|
|
474
|
+
var agentJobCreateRequestSchema = import_zod2.z.strictObject({
|
|
393
475
|
annotation: spotAnnotationRequestSchema,
|
|
394
|
-
providerProfileId:
|
|
395
|
-
modelProfileId:
|
|
396
|
-
providerDataConsent:
|
|
397
|
-
workingTreeMode:
|
|
476
|
+
providerProfileId: profileIdSchema2,
|
|
477
|
+
modelProfileId: profileIdSchema2,
|
|
478
|
+
providerDataConsent: import_zod2.z.literal(true),
|
|
479
|
+
workingTreeMode: import_zod2.z.enum(["require-clean", "include-local-changes"]).default("require-clean")
|
|
398
480
|
});
|
|
399
|
-
var agentJobActionRequestSchema =
|
|
481
|
+
var agentJobActionRequestSchema = import_zod2.z.strictObject({});
|
|
400
482
|
|
|
401
483
|
// src/protocol/agent-schemas.ts
|
|
402
|
-
var
|
|
403
|
-
var
|
|
404
|
-
var boundedString2 = (maximum) =>
|
|
405
|
-
var errorCodeSchema =
|
|
406
|
-
var agentCapabilitySnapshotSchema =
|
|
407
|
-
providerProfileId:
|
|
484
|
+
var import_zod3 = require("zod");
|
|
485
|
+
var profileIdSchema3 = import_zod3.z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/);
|
|
486
|
+
var boundedString2 = (maximum) => import_zod3.z.string().max(maximum);
|
|
487
|
+
var errorCodeSchema = import_zod3.z.enum(ERROR_CODES);
|
|
488
|
+
var agentCapabilitySnapshotSchema = import_zod3.z.strictObject({
|
|
489
|
+
providerProfileId: profileIdSchema3,
|
|
408
490
|
providerLabel: boundedString2(100),
|
|
409
|
-
modelProfileId:
|
|
491
|
+
modelProfileId: profileIdSchema3,
|
|
410
492
|
modelLabel: boundedString2(100),
|
|
411
|
-
protocol:
|
|
412
|
-
state:
|
|
413
|
-
authenticated:
|
|
414
|
-
modelAvailable:
|
|
415
|
-
toolCalling:
|
|
416
|
-
toolResultContinuation:
|
|
417
|
-
streaming:
|
|
418
|
-
checkedAt:
|
|
493
|
+
protocol: import_zod3.z.enum(["responses", "chat-completions"]),
|
|
494
|
+
state: import_zod3.z.enum(AGENT_CAPABILITY_STATES),
|
|
495
|
+
authenticated: import_zod3.z.boolean(),
|
|
496
|
+
modelAvailable: import_zod3.z.boolean(),
|
|
497
|
+
toolCalling: import_zod3.z.boolean(),
|
|
498
|
+
toolResultContinuation: import_zod3.z.boolean(),
|
|
499
|
+
streaming: import_zod3.z.boolean(),
|
|
500
|
+
checkedAt: import_zod3.z.iso.datetime().optional(),
|
|
419
501
|
errorCode: errorCodeSchema.optional()
|
|
420
502
|
});
|
|
421
|
-
var agentWorkspaceHealthSnapshotSchema =
|
|
422
|
-
state:
|
|
423
|
-
checkedAt:
|
|
424
|
-
changes:
|
|
425
|
-
staged:
|
|
426
|
-
unstaged:
|
|
427
|
-
untracked:
|
|
428
|
-
conflicted:
|
|
429
|
-
total:
|
|
503
|
+
var agentWorkspaceHealthSnapshotSchema = import_zod3.z.strictObject({
|
|
504
|
+
state: import_zod3.z.enum(AGENT_WORKSPACE_STATES),
|
|
505
|
+
checkedAt: import_zod3.z.iso.datetime(),
|
|
506
|
+
changes: import_zod3.z.strictObject({
|
|
507
|
+
staged: import_zod3.z.number().int().nonnegative(),
|
|
508
|
+
unstaged: import_zod3.z.number().int().nonnegative(),
|
|
509
|
+
untracked: import_zod3.z.number().int().nonnegative(),
|
|
510
|
+
conflicted: import_zod3.z.number().int().nonnegative(),
|
|
511
|
+
total: import_zod3.z.number().int().nonnegative()
|
|
430
512
|
}),
|
|
431
|
-
canIncludeLocalChanges:
|
|
513
|
+
canIncludeLocalChanges: import_zod3.z.boolean(),
|
|
432
514
|
errorCode: errorCodeSchema.optional()
|
|
433
515
|
}).refine(
|
|
434
516
|
({ state, changes, canIncludeLocalChanges, errorCode }) => {
|
|
@@ -446,42 +528,42 @@ var agentWorkspaceHealthSnapshotSchema = import_zod2.z.strictObject({
|
|
|
446
528
|
},
|
|
447
529
|
{ message: "Agent workspace health fields are inconsistent." }
|
|
448
530
|
);
|
|
449
|
-
var agentChangedFileSchema =
|
|
531
|
+
var agentChangedFileSchema = import_zod3.z.strictObject({
|
|
450
532
|
relativePath: boundedString2(1024),
|
|
451
|
-
kind:
|
|
452
|
-
additions:
|
|
453
|
-
deletions:
|
|
533
|
+
kind: import_zod3.z.enum(AGENT_FILE_CHANGE_KINDS),
|
|
534
|
+
additions: import_zod3.z.number().int().nonnegative(),
|
|
535
|
+
deletions: import_zod3.z.number().int().nonnegative()
|
|
454
536
|
});
|
|
455
|
-
var agentCheckResultSchema =
|
|
456
|
-
checkId:
|
|
537
|
+
var agentCheckResultSchema = import_zod3.z.strictObject({
|
|
538
|
+
checkId: profileIdSchema3,
|
|
457
539
|
label: boundedString2(100),
|
|
458
|
-
status:
|
|
459
|
-
durationMs:
|
|
540
|
+
status: import_zod3.z.enum(AGENT_CHECK_STATUSES),
|
|
541
|
+
durationMs: import_zod3.z.number().int().nonnegative(),
|
|
460
542
|
output: boundedString2(8e4)
|
|
461
543
|
});
|
|
462
|
-
var agentJobSnapshotSchema =
|
|
463
|
-
jobId:
|
|
464
|
-
status:
|
|
465
|
-
providerProfileId:
|
|
544
|
+
var agentJobSnapshotSchema = import_zod3.z.strictObject({
|
|
545
|
+
jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
546
|
+
status: import_zod3.z.enum(AGENT_JOB_STATUSES),
|
|
547
|
+
providerProfileId: profileIdSchema3,
|
|
466
548
|
providerLabel: boundedString2(100),
|
|
467
|
-
modelProfileId:
|
|
549
|
+
modelProfileId: profileIdSchema3,
|
|
468
550
|
modelLabel: boundedString2(100),
|
|
469
551
|
phaseMessage: boundedString2(1024),
|
|
470
|
-
createdAt:
|
|
471
|
-
updatedAt:
|
|
472
|
-
canCancel:
|
|
473
|
-
canApply:
|
|
474
|
-
canRevert:
|
|
552
|
+
createdAt: import_zod3.z.iso.datetime(),
|
|
553
|
+
updatedAt: import_zod3.z.iso.datetime(),
|
|
554
|
+
canCancel: import_zod3.z.boolean(),
|
|
555
|
+
canApply: import_zod3.z.boolean(),
|
|
556
|
+
canRevert: import_zod3.z.boolean(),
|
|
475
557
|
errorCode: errorCodeSchema.optional()
|
|
476
558
|
});
|
|
477
|
-
var agentJobResultSchema =
|
|
478
|
-
jobId:
|
|
559
|
+
var agentJobResultSchema = import_zod3.z.strictObject({
|
|
560
|
+
jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
479
561
|
summary: boundedString2(8e4),
|
|
480
562
|
diff: boundedString2(1e6),
|
|
481
|
-
files:
|
|
482
|
-
checks:
|
|
563
|
+
files: import_zod3.z.array(agentChangedFileSchema).max(100),
|
|
564
|
+
checks: import_zod3.z.array(agentCheckResultSchema).max(100)
|
|
483
565
|
});
|
|
484
|
-
var agentJobResultResponseSchema =
|
|
566
|
+
var agentJobResultResponseSchema = import_zod3.z.strictObject({
|
|
485
567
|
snapshot: agentJobSnapshotSchema,
|
|
486
568
|
result: agentJobResultSchema.optional()
|
|
487
569
|
}).superRefine((value, context) => {
|
|
@@ -493,44 +575,44 @@ var agentJobResultResponseSchema = import_zod2.z.strictObject({
|
|
|
493
575
|
});
|
|
494
576
|
}
|
|
495
577
|
});
|
|
496
|
-
var agentJobEventBaseSchema =
|
|
497
|
-
schemaVersion:
|
|
498
|
-
sequence:
|
|
499
|
-
jobId:
|
|
500
|
-
status:
|
|
501
|
-
timestamp:
|
|
578
|
+
var agentJobEventBaseSchema = import_zod3.z.strictObject({
|
|
579
|
+
schemaVersion: import_zod3.z.literal(2),
|
|
580
|
+
sequence: import_zod3.z.number().int().positive(),
|
|
581
|
+
jobId: import_zod3.z.string().min(22).max(128).regex(/^[A-Za-z0-9_-]+$/),
|
|
582
|
+
status: import_zod3.z.enum(AGENT_JOB_STATUSES),
|
|
583
|
+
timestamp: import_zod3.z.iso.datetime()
|
|
502
584
|
});
|
|
503
|
-
var agentJobEventSchema =
|
|
585
|
+
var agentJobEventSchema = import_zod3.z.discriminatedUnion("type", [
|
|
504
586
|
agentJobEventBaseSchema.extend({
|
|
505
|
-
type:
|
|
506
|
-
data:
|
|
587
|
+
type: import_zod3.z.literal("snapshot"),
|
|
588
|
+
data: import_zod3.z.strictObject({ snapshot: agentJobSnapshotSchema })
|
|
507
589
|
}),
|
|
508
590
|
agentJobEventBaseSchema.extend({
|
|
509
|
-
type:
|
|
510
|
-
data:
|
|
591
|
+
type: import_zod3.z.literal("phase"),
|
|
592
|
+
data: import_zod3.z.strictObject({ message: boundedString2(1024) })
|
|
511
593
|
}),
|
|
512
594
|
agentJobEventBaseSchema.extend({
|
|
513
|
-
type:
|
|
514
|
-
data:
|
|
515
|
-
turn:
|
|
595
|
+
type: import_zod3.z.literal("tool"),
|
|
596
|
+
data: import_zod3.z.strictObject({
|
|
597
|
+
turn: import_zod3.z.number().int().positive(),
|
|
516
598
|
toolCallId: boundedString2(256),
|
|
517
599
|
toolName: boundedString2(100),
|
|
518
|
-
state:
|
|
600
|
+
state: import_zod3.z.enum(["started", "succeeded", "failed"]),
|
|
519
601
|
relativePath: boundedString2(1024).optional(),
|
|
520
602
|
checkLabel: boundedString2(100).optional()
|
|
521
603
|
})
|
|
522
604
|
}),
|
|
523
605
|
agentJobEventBaseSchema.extend({
|
|
524
|
-
type:
|
|
525
|
-
data:
|
|
606
|
+
type: import_zod3.z.literal("check"),
|
|
607
|
+
data: import_zod3.z.strictObject({ result: agentCheckResultSchema })
|
|
526
608
|
}),
|
|
527
609
|
agentJobEventBaseSchema.extend({
|
|
528
|
-
type:
|
|
529
|
-
data:
|
|
610
|
+
type: import_zod3.z.literal("result-ready"),
|
|
611
|
+
data: import_zod3.z.strictObject({ hasResult: import_zod3.z.literal(true) })
|
|
530
612
|
}),
|
|
531
613
|
agentJobEventBaseSchema.extend({
|
|
532
|
-
type:
|
|
533
|
-
data:
|
|
614
|
+
type: import_zod3.z.literal("error"),
|
|
615
|
+
data: import_zod3.z.strictObject({
|
|
534
616
|
code: errorCodeSchema,
|
|
535
617
|
message: boundedString2(1024)
|
|
536
618
|
})
|
|
@@ -576,6 +658,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
576
658
|
SPOTPATCH_ENDPOINTS,
|
|
577
659
|
SPOTPATCH_LOCALES,
|
|
578
660
|
SPOTPATCH_LOCALE_PREFERENCES,
|
|
661
|
+
SPOTPATCH_NEXT_BUNDLERS,
|
|
662
|
+
SPOTPATCH_NEXT_ROUTER_KINDS,
|
|
579
663
|
SPOTPATCH_REPOSITORY_URL,
|
|
580
664
|
SPOTPATCH_TOKEN_HEADER,
|
|
581
665
|
SpotPatchError,
|
|
@@ -597,6 +681,8 @@ var SPOTPATCH_REPOSITORY_URL = "https://github.com/huanglvjing/spotpatch";
|
|
|
597
681
|
openEditorRequestSchema,
|
|
598
682
|
parseSourceMarker,
|
|
599
683
|
redactSensitiveText,
|
|
684
|
+
runtimeBootstrapRequestSchema,
|
|
685
|
+
runtimeConfigSchema,
|
|
600
686
|
sanitizeUrl,
|
|
601
687
|
sourceContextRequestSchema,
|
|
602
688
|
spotAnnotationRequestSchema,
|