@roll-agent/protocol 0.5.0 → 0.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 +9 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +33 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -162,6 +162,15 @@ Protocol `"1.0"` / `"1.1"` 的 strict 顶层结构不变,旧 GUI 可以继续
|
|
|
162
162
|
时才向用户展示风险 `reason`;仅因无法证明安全而复用 `destructiveHint` 的 `unknown`
|
|
163
163
|
命令不会显示“破坏性操作”。GUI 在 `reason` 缺失时应使用中性提示或直接省略。
|
|
164
164
|
|
|
165
|
+
文件编辑类审批(`edit_file` / `write_file`)的变更预览位于 `approval.preview.diff`,形状为
|
|
166
|
+
`fileChangeDiffSchema`(`path`、`change: "create" | "modify"`、`added`、`removed`、`hunks`、可选的
|
|
167
|
+
`unified` 文本、`truncated`);`getApprovalDiffPreview()` 完成校验。写入成功后的
|
|
168
|
+
`tool.completed.display` 为 `{ text, diff }` 对象(`fileChangeDisplaySchema`),`getFileChangeDisplay()`
|
|
169
|
+
读取;`text` 是与旧版本一致的人类可读摘要。`operationView.display`(`thread.snapshot` /
|
|
170
|
+
`operation.get`)沿用台账信封 `{ version, encoding, value }`,`value` 才是同一 `{ text, diff }` 对象,
|
|
171
|
+
读取时传 `display.value`。两者同样刻意放在既有 JSON 槽位内:strict 顶层结构不变,旧客户端把它们当
|
|
172
|
+
普通 JSON 忽略;`unified` 缺席表示只有统计(超大文件),`truncated: true` 表示正文按上限截断。
|
|
173
|
+
|
|
165
174
|
## 文档
|
|
166
175
|
|
|
167
176
|
- [Runtime Protocol v1 参考](https://github.com/steveoon/roll-agent/blob/main/docs/runtime-protocol-v1-reference.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export declare const RUNTIME_V13_RECOVERY_SNAPSHOT_METADATA_MAX_CHARS = 1024;
|
|
|
22
22
|
export declare const RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS = 64;
|
|
23
23
|
export declare const APPROVAL_EXPLANATION_PREVIEW_KEY: "explanation";
|
|
24
24
|
export declare const APPROVAL_EXPLANATION_MAX_CHARS = 100;
|
|
25
|
+
export declare const APPROVAL_DIFF_PREVIEW_KEY: "diff";
|
|
26
|
+
export declare const FILE_CHANGE_DIFF_PATH_MAX_CHARS = 4096;
|
|
27
|
+
export declare const FILE_CHANGE_DIFF_UNIFIED_MAX_CHARS = 20000;
|
|
28
|
+
export declare const FILE_CHANGE_KINDS: readonly ["create", "modify"];
|
|
25
29
|
export declare const CLIENT_CAPABILITY_METHOD_MAX_COUNT = 64;
|
|
26
30
|
export declare const CLIENT_CAPABILITY_METHOD_MAX_CHARS = 100;
|
|
27
31
|
export declare const USER_INPUT_CONTROL_MAX_COUNT = 16;
|
|
@@ -277,6 +281,33 @@ export declare const runtimeInteractionMetadataSchema: z.ZodReadonly<z.ZodObject
|
|
|
277
281
|
}>;
|
|
278
282
|
}, z.core.$strict>>;
|
|
279
283
|
export declare const approvalExplanationSchema: z.ZodString;
|
|
284
|
+
export declare const fileChangeDiffSchema: z.ZodReadonly<z.ZodObject<{
|
|
285
|
+
path: z.ZodString;
|
|
286
|
+
change: z.ZodEnum<{
|
|
287
|
+
create: "create";
|
|
288
|
+
modify: "modify";
|
|
289
|
+
}>;
|
|
290
|
+
added: z.ZodNumber;
|
|
291
|
+
removed: z.ZodNumber;
|
|
292
|
+
hunks: z.ZodNumber;
|
|
293
|
+
unified: z.ZodOptional<z.ZodString>;
|
|
294
|
+
truncated: z.ZodBoolean;
|
|
295
|
+
}, z.core.$strip>>;
|
|
296
|
+
export declare const fileChangeDisplaySchema: z.ZodReadonly<z.ZodObject<{
|
|
297
|
+
text: z.ZodString;
|
|
298
|
+
diff: z.ZodReadonly<z.ZodObject<{
|
|
299
|
+
path: z.ZodString;
|
|
300
|
+
change: z.ZodEnum<{
|
|
301
|
+
create: "create";
|
|
302
|
+
modify: "modify";
|
|
303
|
+
}>;
|
|
304
|
+
added: z.ZodNumber;
|
|
305
|
+
removed: z.ZodNumber;
|
|
306
|
+
hunks: z.ZodNumber;
|
|
307
|
+
unified: z.ZodOptional<z.ZodString>;
|
|
308
|
+
truncated: z.ZodBoolean;
|
|
309
|
+
}, z.core.$strip>>;
|
|
310
|
+
}, z.core.$strip>>;
|
|
280
311
|
export type ThreadId = z.infer<typeof threadIdSchema>;
|
|
281
312
|
export type TurnId = z.infer<typeof turnIdSchema>;
|
|
282
313
|
export type ApprovalId = z.infer<typeof approvalIdSchema>;
|
|
@@ -13294,6 +13325,9 @@ export type UserInputResult = z.infer<typeof userInputResultSchema>;
|
|
|
13294
13325
|
/** A submitted result whose values were correlated and ordered against the original form. */
|
|
13295
13326
|
export type NormalizedUserInputResult = UserInputResult;
|
|
13296
13327
|
export type ApprovalExplanation = z.infer<typeof approvalExplanationSchema>;
|
|
13328
|
+
export type FileChangeKind = (typeof FILE_CHANGE_KINDS)[number];
|
|
13329
|
+
export type FileChangeDiff = z.infer<typeof fileChangeDiffSchema>;
|
|
13330
|
+
export type FileChangeDisplay = z.infer<typeof fileChangeDisplaySchema>;
|
|
13297
13331
|
export type ActiveTurn = z.infer<typeof activeTurnSchema>;
|
|
13298
13332
|
export type ActiveTurnV11 = z.infer<typeof activeTurnV11Schema>;
|
|
13299
13333
|
export type ActiveTurnV12 = z.infer<typeof activeTurnV12Schema>;
|
|
@@ -13317,6 +13351,8 @@ export declare function isRuntimeMethodAvailable<TVersion extends RuntimeProtoco
|
|
|
13317
13351
|
export declare function isRuntimeServerRequestMethodAvailable<TVersion extends RuntimeProtocolVersion>(version: TVersion, method: string): method is RuntimeServerRequestMethodForVersion<TVersion>;
|
|
13318
13352
|
export declare function projectClientCapabilitiesSetResult(value: unknown): ClientCapabilitiesSetResult;
|
|
13319
13353
|
export declare function getApprovalExplanation(approval: Pick<PendingApproval, "preview">): ApprovalExplanation | undefined;
|
|
13354
|
+
export declare function getApprovalDiffPreview(approval: Pick<PendingApproval, "preview">): FileChangeDiff | undefined;
|
|
13355
|
+
export declare function getFileChangeDisplay(display: unknown): FileChangeDisplay | undefined;
|
|
13320
13356
|
/**
|
|
13321
13357
|
* Correlates a structurally valid Client result with the original form and returns values in
|
|
13322
13358
|
* form definition order. Unknown, duplicate, missing or type-incompatible values are rejected.
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,10 @@ export const RUNTIME_V13_RECOVERY_SNAPSHOT_METADATA_MAX_CHARS = 1_024;
|
|
|
30
30
|
export const RUNTIME_V13_RECOVERY_SNAPSHOT_TIMESTAMP_MAX_CHARS = 64;
|
|
31
31
|
export const APPROVAL_EXPLANATION_PREVIEW_KEY = "explanation";
|
|
32
32
|
export const APPROVAL_EXPLANATION_MAX_CHARS = 100;
|
|
33
|
+
export const APPROVAL_DIFF_PREVIEW_KEY = "diff";
|
|
34
|
+
export const FILE_CHANGE_DIFF_PATH_MAX_CHARS = 4_096;
|
|
35
|
+
export const FILE_CHANGE_DIFF_UNIFIED_MAX_CHARS = 20_000;
|
|
36
|
+
export const FILE_CHANGE_KINDS = ["create", "modify"];
|
|
33
37
|
export const CLIENT_CAPABILITY_METHOD_MAX_COUNT = 64;
|
|
34
38
|
export const CLIENT_CAPABILITY_METHOD_MAX_CHARS = 100;
|
|
35
39
|
export const USER_INPUT_CONTROL_MAX_COUNT = 16;
|
|
@@ -243,6 +247,23 @@ export const approvalExplanationSchema = z
|
|
|
243
247
|
.trim()
|
|
244
248
|
.min(1)
|
|
245
249
|
.max(APPROVAL_EXPLANATION_MAX_CHARS);
|
|
250
|
+
export const fileChangeDiffSchema = z
|
|
251
|
+
.object({
|
|
252
|
+
path: z.string().min(1).max(FILE_CHANGE_DIFF_PATH_MAX_CHARS),
|
|
253
|
+
change: z.enum(FILE_CHANGE_KINDS),
|
|
254
|
+
added: z.number().int().nonnegative(),
|
|
255
|
+
removed: z.number().int().nonnegative(),
|
|
256
|
+
hunks: z.number().int().nonnegative(),
|
|
257
|
+
unified: z.string().max(FILE_CHANGE_DIFF_UNIFIED_MAX_CHARS).optional(),
|
|
258
|
+
truncated: z.boolean(),
|
|
259
|
+
})
|
|
260
|
+
.readonly();
|
|
261
|
+
export const fileChangeDisplaySchema = z
|
|
262
|
+
.object({
|
|
263
|
+
text: z.string(),
|
|
264
|
+
diff: fileChangeDiffSchema,
|
|
265
|
+
})
|
|
266
|
+
.readonly();
|
|
246
267
|
function runtimeEventCursorParts(cursor) {
|
|
247
268
|
const parsed = runtimeEventCursorSchema.parse(cursor);
|
|
248
269
|
const [, eventLogId, threadSequence, eventId] = parsed.split(":");
|
|
@@ -1780,6 +1801,18 @@ export function getApprovalExplanation(approval) {
|
|
|
1780
1801
|
const parsed = approvalExplanationSchema.safeParse(preview[APPROVAL_EXPLANATION_PREVIEW_KEY]);
|
|
1781
1802
|
return parsed.success ? parsed.data : undefined;
|
|
1782
1803
|
}
|
|
1804
|
+
export function getApprovalDiffPreview(approval) {
|
|
1805
|
+
const preview = approval.preview;
|
|
1806
|
+
if (typeof preview !== "object" || preview === null || Array.isArray(preview)) {
|
|
1807
|
+
return undefined;
|
|
1808
|
+
}
|
|
1809
|
+
const parsed = fileChangeDiffSchema.safeParse(preview[APPROVAL_DIFF_PREVIEW_KEY]);
|
|
1810
|
+
return parsed.success ? parsed.data : undefined;
|
|
1811
|
+
}
|
|
1812
|
+
export function getFileChangeDisplay(display) {
|
|
1813
|
+
const parsed = fileChangeDisplaySchema.safeParse(display);
|
|
1814
|
+
return parsed.success ? parsed.data : undefined;
|
|
1815
|
+
}
|
|
1783
1816
|
function validateUserInputTextValue(control, value, path, addIssue) {
|
|
1784
1817
|
if (typeof value !== "string") {
|
|
1785
1818
|
addIssue(path, `${control.type} control requires a string value`);
|