@spotpatch/runtime 1.2.1 → 1.4.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 +25 -7
- package/dist/index.cjs +26 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -15
- package/dist/index.d.ts +2 -15
- package/dist/index.js +26 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,9 +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
|
-
and CSS collectors, localized Shadow DOM workbench, and prompt composer.
|
|
5
|
+
# `@spotpatch/runtime`
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
## English
|
|
8
|
+
|
|
9
|
+
The browser Runtime used by SpotPatch framework adapters. It contains the element picker, bounded DOM and CSS collectors, source-context client, localized Shadow DOM workbench, multi-target state, prompt composer, and optional Agent review UI.
|
|
10
|
+
|
|
11
|
+
Applications should install and configure [`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite) rather than bootstrap this package directly. The adapter supplies authenticated development configuration and guarantees that the Runtime is absent from production output.
|
|
12
|
+
|
|
13
|
+
This package never owns provider credentials or unrestricted filesystem access.
|
|
14
|
+
|
|
15
|
+
## 简体中文
|
|
16
|
+
|
|
17
|
+
这是 SpotPatch 框架适配器使用的浏览器 Runtime,包含元素选择器、有界 DOM/CSS 采集器、源码上下文客户端、本地化 Shadow DOM 工作台、多目标状态、Prompt 生成器和可选 Agent 审阅界面。
|
|
18
|
+
|
|
19
|
+
业务应用应安装并配置 [`@spotpatch/vite`](https://www.npmjs.com/package/@spotpatch/vite),而不是直接启动本包。框架适配器负责提供经过认证的开发期配置,并保证生产产物不包含 Runtime。
|
|
20
|
+
|
|
21
|
+
本包不持有 Provider 凭据,也不具备不受限制的文件系统访问能力。
|
|
22
|
+
|
|
23
|
+
## Links / 链接
|
|
24
|
+
|
|
25
|
+
- [Repository / 仓库](https://github.com/huanglvjing/spotpatch)
|
|
26
|
+
- [UI and diagnostics / UI 与诊断](https://github.com/huanglvjing/spotpatch/blob/main/docs/%E6%8A%80%E6%9C%AF%E6%96%B9%E6%A1%88/10-UI%E4%B8%8E%E8%AF%8A%E6%96%AD.md)
|
|
27
|
+
- [MIT License / 许可证](https://github.com/huanglvjing/spotpatch/blob/main/LICENSE)
|
package/dist/index.cjs
CHANGED
|
@@ -227,7 +227,7 @@ function isAgentEventBase(value) {
|
|
|
227
227
|
"timestamp",
|
|
228
228
|
"type",
|
|
229
229
|
"data"
|
|
230
|
-
]) && value.schemaVersion ===
|
|
230
|
+
]) && value.schemaVersion === 2 && isPositiveInteger(value.sequence) && isJobId(value.jobId) && typeof value.status === "string" && JOB_STATUS_VALUES.has(value.status) && isIsoTimestamp(value.timestamp) && typeof value.type === "string" && isRecord(value.data);
|
|
231
231
|
}
|
|
232
232
|
function isAgentJobEvent(value) {
|
|
233
233
|
if (!isAgentEventBase(value)) {
|
|
@@ -241,12 +241,13 @@ function isAgentJobEvent(value) {
|
|
|
241
241
|
return hasOnlyKeys(data, ["message"]) && isBoundedString(data.message, 1024);
|
|
242
242
|
case "tool":
|
|
243
243
|
return hasOnlyKeys(data, [
|
|
244
|
+
"turn",
|
|
244
245
|
"toolCallId",
|
|
245
246
|
"toolName",
|
|
246
247
|
"state",
|
|
247
248
|
"relativePath",
|
|
248
249
|
"checkLabel"
|
|
249
|
-
]) && isBoundedString(data.toolCallId, 256) && isBoundedString(data.toolName, 100) && (data.state === "started" || data.state === "succeeded" || data.state === "failed") && isOptionalBoundedString(data.relativePath, 1024) && isOptionalBoundedString(data.checkLabel, 100);
|
|
250
|
+
]) && isPositiveInteger(data.turn) && isBoundedString(data.toolCallId, 256) && isBoundedString(data.toolName, 100) && (data.state === "started" || data.state === "succeeded" || data.state === "failed") && isOptionalBoundedString(data.relativePath, 1024) && isOptionalBoundedString(data.checkLabel, 100);
|
|
250
251
|
case "check":
|
|
251
252
|
return hasOnlyKeys(data, ["result"]) && isAgentCheckResult(data.result);
|
|
252
253
|
case "result-ready":
|
|
@@ -2347,13 +2348,15 @@ var ERROR_MESSAGES_EN = Object.freeze({
|
|
|
2347
2348
|
[import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: "Reduce untracked files below the safe count and size limits.",
|
|
2348
2349
|
[import_shared6.ERROR_CODES.WORKTREE_UNTRACKED_UNSUPPORTED]: "An untracked path is missing, linked, or not a regular file.",
|
|
2349
2350
|
[import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: "Local changes cannot be isolated safely.",
|
|
2350
|
-
[import_shared6.ERROR_CODES.TOOL_DENIED]: "A
|
|
2351
|
-
[import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "
|
|
2352
|
-
[import_shared6.ERROR_CODES.
|
|
2353
|
-
[import_shared6.ERROR_CODES.
|
|
2354
|
-
[import_shared6.ERROR_CODES.
|
|
2355
|
-
[import_shared6.ERROR_CODES.
|
|
2356
|
-
[import_shared6.ERROR_CODES.
|
|
2351
|
+
[import_shared6.ERROR_CODES.TOOL_DENIED]: "A tool request violated local safety policy.",
|
|
2352
|
+
[import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "Invalid tool request.",
|
|
2353
|
+
[import_shared6.ERROR_CODES.TOOL_ARGUMENTS_INVALID]: "Tool arguments are invalid.",
|
|
2354
|
+
[import_shared6.ERROR_CODES.TOOL_CALL_ID_CONFLICT]: "Tool ID conflicts in this turn.",
|
|
2355
|
+
[import_shared6.ERROR_CODES.TOOL_PATH_DENIED]: "The model requested a protected or external path.",
|
|
2356
|
+
[import_shared6.ERROR_CODES.PATCH_REJECTED]: "The patch violated local policy.",
|
|
2357
|
+
[import_shared6.ERROR_CODES.VALIDATION_FAILED]: "Required checks failed; changes cannot be applied.",
|
|
2358
|
+
[import_shared6.ERROR_CODES.APPLY_CONFLICT]: "Agent-touched files changed; nothing was overwritten.",
|
|
2359
|
+
[import_shared6.ERROR_CODES.INTERNAL_ERROR]: "The Agent failed without exposing private details."
|
|
2357
2360
|
});
|
|
2358
2361
|
var ERROR_MESSAGES_ZH = Object.freeze({
|
|
2359
2362
|
[import_shared6.ERROR_CODES.INVALID_REQUEST]: "Agent \u8BF7\u6C42\u65E0\u6548\uFF0C\u5DF2\u88AB\u62D2\u7EDD\u3002",
|
|
@@ -2380,13 +2383,15 @@ var ERROR_MESSAGES_ZH = Object.freeze({
|
|
|
2380
2383
|
[import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_TOO_LARGE]: "\u672A\u8DDF\u8E2A\u6587\u4EF6\u8D85\u8FC7\u5B89\u5168\u6570\u91CF\u6216\u4F53\u79EF\u4E0A\u9650\uFF0C\u8BF7\u5148\u7CBE\u7B80\u3002",
|
|
2381
2384
|
[import_shared6.ERROR_CODES.WORKTREE_UNTRACKED_UNSUPPORTED]: "\u672A\u8DDF\u8E2A\u9879\u5DF2\u4E22\u5931\u3001\u662F\u7B26\u53F7\u94FE\u63A5\u6216\u4E0D\u662F\u666E\u901A\u6587\u4EF6\u3002",
|
|
2382
2385
|
[import_shared6.ERROR_CODES.WORKTREE_LOCAL_CHANGES_UNSUPPORTED]: "\u5F53\u524D\u672C\u5730\u4FEE\u6539\u65E0\u6CD5\u5B89\u5168\u9694\u79BB\u3002",
|
|
2383
|
-
[import_shared6.ERROR_CODES.TOOL_DENIED]: "\
|
|
2384
|
-
[import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "\
|
|
2385
|
-
[import_shared6.ERROR_CODES.
|
|
2386
|
-
[import_shared6.ERROR_CODES.
|
|
2387
|
-
[import_shared6.ERROR_CODES.
|
|
2388
|
-
[import_shared6.ERROR_CODES.
|
|
2389
|
-
[import_shared6.ERROR_CODES.
|
|
2386
|
+
[import_shared6.ERROR_CODES.TOOL_DENIED]: "\u5DE5\u5177\u8BF7\u6C42\u8FDD\u53CD\u672C\u5730\u5B89\u5168\u7B56\u7565\u3002",
|
|
2387
|
+
[import_shared6.ERROR_CODES.TOOL_INPUT_INVALID]: "\u5DE5\u5177\u8BF7\u6C42\u65E0\u6548\u3002",
|
|
2388
|
+
[import_shared6.ERROR_CODES.TOOL_ARGUMENTS_INVALID]: "\u5DE5\u5177\u53C2\u6570\u65E0\u6548\u3002",
|
|
2389
|
+
[import_shared6.ERROR_CODES.TOOL_CALL_ID_CONFLICT]: "\u672C\u8F6E\u5DE5\u5177 ID \u51B2\u7A81\u3002",
|
|
2390
|
+
[import_shared6.ERROR_CODES.TOOL_PATH_DENIED]: "\u6A21\u578B\u8BF7\u6C42\u4E86\u53D7\u4FDD\u62A4\u6216\u9879\u76EE\u5916\u8DEF\u5F84\u3002",
|
|
2391
|
+
[import_shared6.ERROR_CODES.PATCH_REJECTED]: "\u8865\u4E01\u8FDD\u53CD\u672C\u5730\u7B56\u7565\u3002",
|
|
2392
|
+
[import_shared6.ERROR_CODES.VALIDATION_FAILED]: "\u5FC5\u9700\u68C0\u67E5\u5931\u8D25\uFF0C\u65E0\u6CD5\u5E94\u7528\u53D8\u66F4\u3002",
|
|
2393
|
+
[import_shared6.ERROR_CODES.APPLY_CONFLICT]: "Agent \u89E6\u53CA\u6587\u4EF6\u5DF2\u53D8\u5316\uFF0C\u672A\u8986\u76D6\u3002",
|
|
2394
|
+
[import_shared6.ERROR_CODES.INTERNAL_ERROR]: "Agent \u5931\u8D25\uFF0C\u672A\u66B4\u9732\u79C1\u6709\u7EC6\u8282\u3002"
|
|
2390
2395
|
});
|
|
2391
2396
|
var SUMMARY_MESSAGES_EN = Object.freeze({
|
|
2392
2397
|
adapter: "React adapter",
|
|
@@ -4115,7 +4120,7 @@ function sourceLocation2(resolution, context, messages) {
|
|
|
4115
4120
|
function createSelectionSummary(input, messages) {
|
|
4116
4121
|
const lines = [
|
|
4117
4122
|
`SpotPatch: ${input.spotPatchVersion}`,
|
|
4118
|
-
|
|
4123
|
+
`${input.framework === "next" ? "Next.js" : "Vite"}: ${input.frameworkVersion}`,
|
|
4119
4124
|
`${messages.source}: ${sourceLocation2(input.resolution, input.code, messages)}`,
|
|
4120
4125
|
`${messages.confidence}: ${input.resolution.source.confidence} (${messages.confidenceLabels[input.resolution.source.confidence]})`,
|
|
4121
4126
|
`${messages.origin}: ${input.resolution.source.origin}`
|
|
@@ -4160,7 +4165,7 @@ function capabilityKey(providerProfileId, modelProfileId) {
|
|
|
4160
4165
|
function activityFromEvent(event) {
|
|
4161
4166
|
if (event.type === "tool") {
|
|
4162
4167
|
return Object.freeze({
|
|
4163
|
-
key: `tool:${event.data.toolCallId}`,
|
|
4168
|
+
key: `tool:${String(event.data.turn)}:${event.data.toolCallId}`,
|
|
4164
4169
|
label: `${event.data.toolName} \xB7 ${event.data.state}`,
|
|
4165
4170
|
state: event.data.state === "started" ? "active" : event.data.state === "succeeded" ? "success" : "failure"
|
|
4166
4171
|
});
|
|
@@ -4650,8 +4655,9 @@ function createController(config, dependencies = {}) {
|
|
|
4650
4655
|
...target.styles === void 0 ? {} : { styles: target.styles },
|
|
4651
4656
|
apiStatus: target.apiStatus,
|
|
4652
4657
|
collectionStatus: target.collectionStatus,
|
|
4653
|
-
|
|
4654
|
-
|
|
4658
|
+
framework: config.framework,
|
|
4659
|
+
frameworkVersion: config.frameworkVersion,
|
|
4660
|
+
spotPatchVersion: config.spotPatchVersion
|
|
4655
4661
|
},
|
|
4656
4662
|
messages
|
|
4657
4663
|
);
|