@agent-phonon/protocol 0.2.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/LICENSE +21 -0
- package/README.md +70 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema/_index.json +3794 -0
- package/dist/json-schema/connect.hello.json +117 -0
- package/dist/json-schema/discovery.changed.json +190 -0
- package/dist/json-schema/discovery.get.json +183 -0
- package/dist/json-schema/discovery.list.json +182 -0
- package/dist/json-schema/document.prepare_upload.json +96 -0
- package/dist/json-schema/document.send.json +165 -0
- package/dist/json-schema/hook.fired.json +100 -0
- package/dist/json-schema/hook.resolve.json +96 -0
- package/dist/json-schema/interaction.cancel.json +48 -0
- package/dist/json-schema/interaction.request.json +376 -0
- package/dist/json-schema/interaction.response.json +68 -0
- package/dist/json-schema/project.create.json +89 -0
- package/dist/json-schema/project.get.json +76 -0
- package/dist/json-schema/project.git.deleteBranch.json +64 -0
- package/dist/json-schema/project.list.json +72 -0
- package/dist/json-schema/project.remove.json +69 -0
- package/dist/json-schema/project.worktree.create.json +88 -0
- package/dist/json-schema/project.worktree.list.json +77 -0
- package/dist/json-schema/project.worktree.remove.json +61 -0
- package/dist/json-schema/session.compress.json +72 -0
- package/dist/json-schema/session.create.json +128 -0
- package/dist/json-schema/session.inject.json +72 -0
- package/dist/json-schema/session.interrupt.json +58 -0
- package/dist/json-schema/session.list.json +127 -0
- package/dist/json-schema/session.send.json +132 -0
- package/dist/json-schema/session.status.json +94 -0
- package/dist/json-schema/session.switchModel.json +73 -0
- package/dist/json-schema/session.terminate.json +54 -0
- package/dist/json-schema/skill.install.json +171 -0
- package/dist/json-schema/skill.list.json +101 -0
- package/dist/json-schema/skill.uninstall.json +76 -0
- package/dist/json-schema/stream.ack.json +36 -0
- package/dist/json-schema/stream.event.json +381 -0
- package/dist/schemas/capabilities.d.ts +90 -0
- package/dist/schemas/capabilities.d.ts.map +1 -0
- package/dist/schemas/capabilities.js +59 -0
- package/dist/schemas/capabilities.js.map +1 -0
- package/dist/schemas/common.d.ts +66 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +97 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/connect.d.ts +111 -0
- package/dist/schemas/connect.d.ts.map +1 -0
- package/dist/schemas/connect.js +46 -0
- package/dist/schemas/connect.js.map +1 -0
- package/dist/schemas/device.d.ts +221 -0
- package/dist/schemas/device.d.ts.map +1 -0
- package/dist/schemas/device.js +59 -0
- package/dist/schemas/device.js.map +1 -0
- package/dist/schemas/discovery.d.ts +892 -0
- package/dist/schemas/discovery.d.ts.map +1 -0
- package/dist/schemas/discovery.js +66 -0
- package/dist/schemas/discovery.js.map +1 -0
- package/dist/schemas/document.d.ts +351 -0
- package/dist/schemas/document.d.ts.map +1 -0
- package/dist/schemas/document.js +103 -0
- package/dist/schemas/document.js.map +1 -0
- package/dist/schemas/env.d.ts +265 -0
- package/dist/schemas/env.d.ts.map +1 -0
- package/dist/schemas/env.js +44 -0
- package/dist/schemas/env.js.map +1 -0
- package/dist/schemas/file.d.ts +274 -0
- package/dist/schemas/file.d.ts.map +1 -0
- package/dist/schemas/file.js +72 -0
- package/dist/schemas/file.js.map +1 -0
- package/dist/schemas/hook.d.ts +132 -0
- package/dist/schemas/hook.d.ts.map +1 -0
- package/dist/schemas/hook.js +58 -0
- package/dist/schemas/hook.js.map +1 -0
- package/dist/schemas/interaction.d.ts +1583 -0
- package/dist/schemas/interaction.d.ts.map +1 -0
- package/dist/schemas/interaction.js +112 -0
- package/dist/schemas/interaction.js.map +1 -0
- package/dist/schemas/jsonrpc.d.ts +314 -0
- package/dist/schemas/jsonrpc.d.ts.map +1 -0
- package/dist/schemas/jsonrpc.js +64 -0
- package/dist/schemas/jsonrpc.js.map +1 -0
- package/dist/schemas/methods.d.ts +3826 -0
- package/dist/schemas/methods.d.ts.map +1 -0
- package/dist/schemas/methods.js +311 -0
- package/dist/schemas/methods.js.map +1 -0
- package/dist/schemas/policy.d.ts +81 -0
- package/dist/schemas/policy.d.ts.map +1 -0
- package/dist/schemas/policy.js +66 -0
- package/dist/schemas/policy.js.map +1 -0
- package/dist/schemas/project.d.ts +506 -0
- package/dist/schemas/project.d.ts.map +1 -0
- package/dist/schemas/project.js +148 -0
- package/dist/schemas/project.js.map +1 -0
- package/dist/schemas/session.d.ts +730 -0
- package/dist/schemas/session.d.ts.map +1 -0
- package/dist/schemas/session.js +287 -0
- package/dist/schemas/session.js.map +1 -0
- package/dist/schemas/skill.d.ts +465 -0
- package/dist/schemas/skill.d.ts.map +1 -0
- package/dist/schemas/skill.js +103 -0
- package/dist/schemas/skill.js.map +1 -0
- package/dist/schemas/stream.d.ts +688 -0
- package/dist/schemas/stream.d.ts.map +1 -0
- package/dist/schemas/stream.js +133 -0
- package/dist/schemas/stream.js.map +1 -0
- package/package.json +52 -0
- package/src/index.ts +24 -0
- package/src/schemas/capabilities.ts +62 -0
- package/src/schemas/common.ts +119 -0
- package/src/schemas/connect.ts +50 -0
- package/src/schemas/device.ts +67 -0
- package/src/schemas/discovery.ts +80 -0
- package/src/schemas/document.ts +121 -0
- package/src/schemas/env.ts +60 -0
- package/src/schemas/file.ts +97 -0
- package/src/schemas/hook.ts +66 -0
- package/src/schemas/interaction.ts +135 -0
- package/src/schemas/jsonrpc.ts +80 -0
- package/src/schemas/methods.ts +414 -0
- package/src/schemas/policy.ts +71 -0
- package/src/schemas/project.ts +185 -0
- package/src/schemas/session.ts +336 -0
- package/src/schemas/skill.ts +121 -0
- package/src/schemas/stream.ts +149 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../src/schemas/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;GAaG;AAEH,yBAAyB;AACzB,eAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGH,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,6DAA2D,CAAC;AAC1F,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE,sCAAsC;AACtC,eAAO,MAAM,wBAAwB;;IAEnC,sCAAsC;;IAEtC,wBAAwB;;;;;;;;;;EAExB,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAGhF,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;EAKpC,CAAC;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { SessionId, Timestamp } from "./common.js";
|
|
3
|
+
/**
|
|
4
|
+
* 人机交互协议(design 平面③ / D21)。
|
|
5
|
+
*
|
|
6
|
+
* 场景:HITL 时、或 agent 主动想问人,发一个**可交互卡片/表单**(抽象结构),
|
|
7
|
+
* phonon → server 渲染给人(飞书卡片/网页/TG 按钮…由服务端决定,复用「甩锅服务端」原则),
|
|
8
|
+
* 人填完 → 原路返回 → 注入回 agent。
|
|
9
|
+
*
|
|
10
|
+
* 两个层次:
|
|
11
|
+
* - InteractionDirective :agent emit 的表单定义(skill 教,让任何模型都能发)
|
|
12
|
+
* - interaction.request :phonon → server 线协议(带 requestId,阻塞等回填)
|
|
13
|
+
* - interaction.response :server → phonon 线协议(人填完的值)
|
|
14
|
+
*
|
|
15
|
+
* 表单只定义**抽象字段结构**,不绑定任何渲染方式——服务端自由渲染。
|
|
16
|
+
*/
|
|
17
|
+
/** 字段类型(抽象,渲染由服务端决定)。 */
|
|
18
|
+
export const FieldType = z.enum([
|
|
19
|
+
"text", // 单行文本
|
|
20
|
+
"textarea", // 多行文本
|
|
21
|
+
"number",
|
|
22
|
+
"boolean", // 开关/勾选
|
|
23
|
+
"select", // 单选
|
|
24
|
+
"multiselect", // 多选
|
|
25
|
+
"date",
|
|
26
|
+
]);
|
|
27
|
+
export const FormFieldOption = z.object({
|
|
28
|
+
label: z.string(),
|
|
29
|
+
value: z.string(),
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* 表单字段——按 type 的 discriminated union(P2-16)。
|
|
33
|
+
* 每种类型携自己的 defaultValue 类型与专属字段,避免「select 该传 string 还是 string[]」的歧义。
|
|
34
|
+
*/
|
|
35
|
+
const FieldBase = { key: z.string().min(1), label: z.string().min(1), required: z.boolean().default(false), help: z.string().optional() };
|
|
36
|
+
export const FormField = z.discriminatedUnion("type", [
|
|
37
|
+
z.object({ ...FieldBase, type: z.literal("text"), placeholder: z.string().optional(), defaultValue: z.string().optional() }),
|
|
38
|
+
z.object({ ...FieldBase, type: z.literal("textarea"), placeholder: z.string().optional(), defaultValue: z.string().optional() }),
|
|
39
|
+
z.object({ ...FieldBase, type: z.literal("number"), defaultValue: z.number().optional() }),
|
|
40
|
+
z.object({ ...FieldBase, type: z.literal("boolean"), defaultValue: z.boolean().optional() }),
|
|
41
|
+
z.object({ ...FieldBase, type: z.literal("select"), options: z.array(FormFieldOption), defaultValue: z.string().optional() }),
|
|
42
|
+
z.object({ ...FieldBase, type: z.literal("multiselect"), options: z.array(FormFieldOption), defaultValue: z.array(z.string()).optional() }),
|
|
43
|
+
z.object({ ...FieldBase, type: z.literal("date"), defaultValue: z.string().optional() }),
|
|
44
|
+
]);
|
|
45
|
+
/** 表单/卡片定义(抽象)。 */
|
|
46
|
+
export const InteractionForm = z.object({
|
|
47
|
+
title: z.string().min(1),
|
|
48
|
+
/** 卡片正文/说明(可选)。 */
|
|
49
|
+
description: z.string().optional(),
|
|
50
|
+
fields: z.array(FormField).default([]),
|
|
51
|
+
/** 提交/操作按钮;纯通知类可只放一个「知道了」。 */
|
|
52
|
+
submitLabel: z.string().default("提交"),
|
|
53
|
+
cancelLabel: z.string().optional(),
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* agent emit 的指令(skill 教)——和 interaction.request 结构基本一致,
|
|
57
|
+
* 但不带 requestId(由 phonon 生成)。
|
|
58
|
+
*/
|
|
59
|
+
export const InteractionDirective = z.object({
|
|
60
|
+
form: InteractionForm,
|
|
61
|
+
/** 是否阻塞等待人回填(true=问答;false=纯通知不等)。 */
|
|
62
|
+
blocking: z.boolean().default(true),
|
|
63
|
+
/** 关联 hookId(若由 HITL hook 触发,便于和 hook.resolve 合流)。 */
|
|
64
|
+
hookId: z.string().optional(),
|
|
65
|
+
});
|
|
66
|
+
// --- interaction.request(phonon → server)---
|
|
67
|
+
export const InteractionRequestParams = z.object({
|
|
68
|
+
/** 本次交互唯一 id,response 用它配对。 */
|
|
69
|
+
requestId: z.string().min(1),
|
|
70
|
+
sessionId: SessionId.optional(),
|
|
71
|
+
turnId: z.string().optional(),
|
|
72
|
+
form: InteractionForm,
|
|
73
|
+
blocking: z.boolean().default(true),
|
|
74
|
+
/** 关联 hookId(HITL 场景)。 */
|
|
75
|
+
hookId: z.string().optional(),
|
|
76
|
+
/**
|
|
77
|
+
* 可选超时(秒,P1-5)。超时后 phonon 以 timeout 收尾本次交互,agent 按预设继续。
|
|
78
|
+
* 0 或缺省 = 不超时(人可能去开会/带娃,长期挂起)。
|
|
79
|
+
*/
|
|
80
|
+
timeoutSeconds: z.number().int().nonnegative().optional(),
|
|
81
|
+
at: Timestamp,
|
|
82
|
+
});
|
|
83
|
+
/** 人机交互的生命周期状态(P1-5):pending → submitted | cancelled | timeout。 */
|
|
84
|
+
export const InteractionStatus = z.enum(["pending", "submitted", "cancelled", "timeout"]);
|
|
85
|
+
/** 阻塞模式下,request 的最终结果(人填完后服务端回的)。 */
|
|
86
|
+
export const InteractionRequestResult = z.object({
|
|
87
|
+
requestId: z.string(),
|
|
88
|
+
/** 结果状态:submit | cancel | timeout。 */
|
|
89
|
+
action: z.enum(["submit", "cancel", "timeout"]),
|
|
90
|
+
/** 提交时各字段值(key → 值)。 */
|
|
91
|
+
values: z.record(z.union([z.string(), z.array(z.string()), z.boolean(), z.number()])).optional(),
|
|
92
|
+
});
|
|
93
|
+
// --- interaction.cancel(server → phonon 或 phonon 内部):主动取消一个 pending 交互 ---
|
|
94
|
+
export const InteractionCancelParams = z.object({
|
|
95
|
+
requestId: z.string().min(1),
|
|
96
|
+
reason: z.string().optional(),
|
|
97
|
+
});
|
|
98
|
+
export const InteractionCancelResult = z.object({
|
|
99
|
+
requestId: z.string(),
|
|
100
|
+
cancelled: z.boolean(),
|
|
101
|
+
});
|
|
102
|
+
/**
|
|
103
|
+
* server → phonon 的回填(非阻塞模式或异步回填走这个 notification;
|
|
104
|
+
* 阻塞模式可直接用 interaction.request 的 result 返回,二选一,实现可都支持)。
|
|
105
|
+
*/
|
|
106
|
+
export const InteractionResponseParams = z.object({
|
|
107
|
+
requestId: z.string().min(1),
|
|
108
|
+
action: z.enum(["submit", "cancel", "timeout"]),
|
|
109
|
+
values: z.record(z.union([z.string(), z.array(z.string()), z.boolean(), z.number()])).optional(),
|
|
110
|
+
at: Timestamp,
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1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AAC,OAAO,EAAE;CACvB,CAAC,CAAC;AAGH;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC/C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChG,EAAE,EAAE,SAAS;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* JSON-RPC 2.0 信封(design D2)。
|
|
4
|
+
*
|
|
5
|
+
* 单条 WebSocket 上双向跑 JSON-RPC 2.0:两端皆可作 requester。
|
|
6
|
+
* - server → phonon:session.* / discovery.* / hook.resolve
|
|
7
|
+
* - phonon → server:stream.event / hook.fired / discovery.changed / connect.hello
|
|
8
|
+
*
|
|
9
|
+
* 这里只定义「信封」的通用形状;具体方法的 params/result 由 methods.ts 绑定。
|
|
10
|
+
*/
|
|
11
|
+
export declare const JsonRpcVersion: z.ZodLiteral<"2.0">;
|
|
12
|
+
/** 请求 id:字符串或数字(JSON-RPC 允许两者;notification 无 id)。 */
|
|
13
|
+
export declare const JsonRpcId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
14
|
+
export type JsonRpcId = z.infer<typeof JsonRpcId>;
|
|
15
|
+
/** 请求(需要响应)。 */
|
|
16
|
+
export declare const JsonRpcRequest: z.ZodObject<{
|
|
17
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
18
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
19
|
+
method: z.ZodString;
|
|
20
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
id: string | number;
|
|
23
|
+
method: string;
|
|
24
|
+
jsonrpc: "2.0";
|
|
25
|
+
params?: unknown;
|
|
26
|
+
}, {
|
|
27
|
+
id: string | number;
|
|
28
|
+
method: string;
|
|
29
|
+
jsonrpc: "2.0";
|
|
30
|
+
params?: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
export type JsonRpcRequest = z.infer<typeof JsonRpcRequest>;
|
|
33
|
+
/** 通知(不需要响应,无 id)——用于 stream.event / hook.fired / discovery.changed。 */
|
|
34
|
+
export declare const JsonRpcNotification: z.ZodObject<{
|
|
35
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
36
|
+
method: z.ZodString;
|
|
37
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
method: string;
|
|
40
|
+
jsonrpc: "2.0";
|
|
41
|
+
params?: unknown;
|
|
42
|
+
}, {
|
|
43
|
+
method: string;
|
|
44
|
+
jsonrpc: "2.0";
|
|
45
|
+
params?: unknown;
|
|
46
|
+
}>;
|
|
47
|
+
export type JsonRpcNotification = z.infer<typeof JsonRpcNotification>;
|
|
48
|
+
/** 成功响应。 */
|
|
49
|
+
export declare const JsonRpcSuccess: z.ZodObject<{
|
|
50
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
51
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
52
|
+
result: z.ZodUnknown;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
id: string | number;
|
|
55
|
+
jsonrpc: "2.0";
|
|
56
|
+
result?: unknown;
|
|
57
|
+
}, {
|
|
58
|
+
id: string | number;
|
|
59
|
+
jsonrpc: "2.0";
|
|
60
|
+
result?: unknown;
|
|
61
|
+
}>;
|
|
62
|
+
export type JsonRpcSuccess = z.infer<typeof JsonRpcSuccess>;
|
|
63
|
+
/** JSON-RPC error 对象;data 携带 phonon 应用级错误结构。 */
|
|
64
|
+
export declare const JsonRpcErrorObject: z.ZodObject<{
|
|
65
|
+
/** JSON-RPC 传输级 code(-32700..-32600 保留;应用错误用 data.appCode 判别)。 */
|
|
66
|
+
code: z.ZodNumber;
|
|
67
|
+
message: z.ZodString;
|
|
68
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
69
|
+
appCode: z.ZodEnum<["errProtocolMismatch", "errUnauthorized", "errSessionNotInTenant", "errTenantQuotaExceeded", "errDeviceQuotaExceeded", "errAgentUnavailable", "errModelUnavailable", "errSessionNotFound", "errSessionTerminated", "errSessionBusy", "errCapabilityUnsupported", "errHookResolveInvalid", "errHookTimeout", "errProjectNotFound", "errProjectExists", "errProjectHasActiveSessions", "errSkillNotFound", "errSkillScopeInvalid", "errSkillInstallFailed", "errWorktreeNotFound", "errWorktreeHasChanges", "errWorktreeInUse", "errBranchNotMerged", "errBranchInUse", "errDocumentTooLarge", "errDocumentPathDenied", "errPolicyDenied", "errDuplicateRequest", "errInvalidParams", "errInternal"]>;
|
|
70
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
71
|
+
sessionId: z.ZodOptional<z.ZodBranded<z.ZodString, "SessionId">>;
|
|
72
|
+
agentId: z.ZodOptional<z.ZodBranded<z.ZodString, "AgentId">>;
|
|
73
|
+
tenantId: z.ZodOptional<z.ZodBranded<z.ZodString, "TenantId">>;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
76
|
+
detail?: string | undefined;
|
|
77
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
78
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
79
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
80
|
+
}, {
|
|
81
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
82
|
+
detail?: string | undefined;
|
|
83
|
+
sessionId?: string | undefined;
|
|
84
|
+
agentId?: string | undefined;
|
|
85
|
+
tenantId?: string | undefined;
|
|
86
|
+
}>>;
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
code: number;
|
|
89
|
+
message: string;
|
|
90
|
+
data?: {
|
|
91
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
92
|
+
detail?: string | undefined;
|
|
93
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
94
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
95
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
}, {
|
|
98
|
+
code: number;
|
|
99
|
+
message: string;
|
|
100
|
+
data?: {
|
|
101
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
102
|
+
detail?: string | undefined;
|
|
103
|
+
sessionId?: string | undefined;
|
|
104
|
+
agentId?: string | undefined;
|
|
105
|
+
tenantId?: string | undefined;
|
|
106
|
+
} | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
export type JsonRpcErrorObject = z.infer<typeof JsonRpcErrorObject>;
|
|
109
|
+
/** 失败响应。 */
|
|
110
|
+
export declare const JsonRpcError: z.ZodObject<{
|
|
111
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
112
|
+
id: z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
113
|
+
error: z.ZodObject<{
|
|
114
|
+
/** JSON-RPC 传输级 code(-32700..-32600 保留;应用错误用 data.appCode 判别)。 */
|
|
115
|
+
code: z.ZodNumber;
|
|
116
|
+
message: z.ZodString;
|
|
117
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
118
|
+
appCode: z.ZodEnum<["errProtocolMismatch", "errUnauthorized", "errSessionNotInTenant", "errTenantQuotaExceeded", "errDeviceQuotaExceeded", "errAgentUnavailable", "errModelUnavailable", "errSessionNotFound", "errSessionTerminated", "errSessionBusy", "errCapabilityUnsupported", "errHookResolveInvalid", "errHookTimeout", "errProjectNotFound", "errProjectExists", "errProjectHasActiveSessions", "errSkillNotFound", "errSkillScopeInvalid", "errSkillInstallFailed", "errWorktreeNotFound", "errWorktreeHasChanges", "errWorktreeInUse", "errBranchNotMerged", "errBranchInUse", "errDocumentTooLarge", "errDocumentPathDenied", "errPolicyDenied", "errDuplicateRequest", "errInvalidParams", "errInternal"]>;
|
|
119
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
120
|
+
sessionId: z.ZodOptional<z.ZodBranded<z.ZodString, "SessionId">>;
|
|
121
|
+
agentId: z.ZodOptional<z.ZodBranded<z.ZodString, "AgentId">>;
|
|
122
|
+
tenantId: z.ZodOptional<z.ZodBranded<z.ZodString, "TenantId">>;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
125
|
+
detail?: string | undefined;
|
|
126
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
127
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
128
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
129
|
+
}, {
|
|
130
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
131
|
+
detail?: string | undefined;
|
|
132
|
+
sessionId?: string | undefined;
|
|
133
|
+
agentId?: string | undefined;
|
|
134
|
+
tenantId?: string | undefined;
|
|
135
|
+
}>>;
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
code: number;
|
|
138
|
+
message: string;
|
|
139
|
+
data?: {
|
|
140
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
141
|
+
detail?: string | undefined;
|
|
142
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
143
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
144
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
145
|
+
} | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
code: number;
|
|
148
|
+
message: string;
|
|
149
|
+
data?: {
|
|
150
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
151
|
+
detail?: string | undefined;
|
|
152
|
+
sessionId?: string | undefined;
|
|
153
|
+
agentId?: string | undefined;
|
|
154
|
+
tenantId?: string | undefined;
|
|
155
|
+
} | undefined;
|
|
156
|
+
}>;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
id: string | number | null;
|
|
159
|
+
error: {
|
|
160
|
+
code: number;
|
|
161
|
+
message: string;
|
|
162
|
+
data?: {
|
|
163
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
164
|
+
detail?: string | undefined;
|
|
165
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
166
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
167
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
168
|
+
} | undefined;
|
|
169
|
+
};
|
|
170
|
+
jsonrpc: "2.0";
|
|
171
|
+
}, {
|
|
172
|
+
id: string | number | null;
|
|
173
|
+
error: {
|
|
174
|
+
code: number;
|
|
175
|
+
message: string;
|
|
176
|
+
data?: {
|
|
177
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
178
|
+
detail?: string | undefined;
|
|
179
|
+
sessionId?: string | undefined;
|
|
180
|
+
agentId?: string | undefined;
|
|
181
|
+
tenantId?: string | undefined;
|
|
182
|
+
} | undefined;
|
|
183
|
+
};
|
|
184
|
+
jsonrpc: "2.0";
|
|
185
|
+
}>;
|
|
186
|
+
export type JsonRpcError = z.infer<typeof JsonRpcError>;
|
|
187
|
+
/** 任意一条 JSON-RPC 报文。 */
|
|
188
|
+
export declare const JsonRpcMessage: z.ZodUnion<[z.ZodObject<{
|
|
189
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
190
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
191
|
+
method: z.ZodString;
|
|
192
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
id: string | number;
|
|
195
|
+
method: string;
|
|
196
|
+
jsonrpc: "2.0";
|
|
197
|
+
params?: unknown;
|
|
198
|
+
}, {
|
|
199
|
+
id: string | number;
|
|
200
|
+
method: string;
|
|
201
|
+
jsonrpc: "2.0";
|
|
202
|
+
params?: unknown;
|
|
203
|
+
}>, z.ZodObject<{
|
|
204
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
205
|
+
method: z.ZodString;
|
|
206
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
method: string;
|
|
209
|
+
jsonrpc: "2.0";
|
|
210
|
+
params?: unknown;
|
|
211
|
+
}, {
|
|
212
|
+
method: string;
|
|
213
|
+
jsonrpc: "2.0";
|
|
214
|
+
params?: unknown;
|
|
215
|
+
}>, z.ZodObject<{
|
|
216
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
217
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
218
|
+
result: z.ZodUnknown;
|
|
219
|
+
}, "strip", z.ZodTypeAny, {
|
|
220
|
+
id: string | number;
|
|
221
|
+
jsonrpc: "2.0";
|
|
222
|
+
result?: unknown;
|
|
223
|
+
}, {
|
|
224
|
+
id: string | number;
|
|
225
|
+
jsonrpc: "2.0";
|
|
226
|
+
result?: unknown;
|
|
227
|
+
}>, z.ZodObject<{
|
|
228
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
229
|
+
id: z.ZodNullable<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
230
|
+
error: z.ZodObject<{
|
|
231
|
+
/** JSON-RPC 传输级 code(-32700..-32600 保留;应用错误用 data.appCode 判别)。 */
|
|
232
|
+
code: z.ZodNumber;
|
|
233
|
+
message: z.ZodString;
|
|
234
|
+
data: z.ZodOptional<z.ZodObject<{
|
|
235
|
+
appCode: z.ZodEnum<["errProtocolMismatch", "errUnauthorized", "errSessionNotInTenant", "errTenantQuotaExceeded", "errDeviceQuotaExceeded", "errAgentUnavailable", "errModelUnavailable", "errSessionNotFound", "errSessionTerminated", "errSessionBusy", "errCapabilityUnsupported", "errHookResolveInvalid", "errHookTimeout", "errProjectNotFound", "errProjectExists", "errProjectHasActiveSessions", "errSkillNotFound", "errSkillScopeInvalid", "errSkillInstallFailed", "errWorktreeNotFound", "errWorktreeHasChanges", "errWorktreeInUse", "errBranchNotMerged", "errBranchInUse", "errDocumentTooLarge", "errDocumentPathDenied", "errPolicyDenied", "errDuplicateRequest", "errInvalidParams", "errInternal"]>;
|
|
236
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
237
|
+
sessionId: z.ZodOptional<z.ZodBranded<z.ZodString, "SessionId">>;
|
|
238
|
+
agentId: z.ZodOptional<z.ZodBranded<z.ZodString, "AgentId">>;
|
|
239
|
+
tenantId: z.ZodOptional<z.ZodBranded<z.ZodString, "TenantId">>;
|
|
240
|
+
}, "strip", z.ZodTypeAny, {
|
|
241
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
242
|
+
detail?: string | undefined;
|
|
243
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
244
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
245
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
246
|
+
}, {
|
|
247
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
248
|
+
detail?: string | undefined;
|
|
249
|
+
sessionId?: string | undefined;
|
|
250
|
+
agentId?: string | undefined;
|
|
251
|
+
tenantId?: string | undefined;
|
|
252
|
+
}>>;
|
|
253
|
+
}, "strip", z.ZodTypeAny, {
|
|
254
|
+
code: number;
|
|
255
|
+
message: string;
|
|
256
|
+
data?: {
|
|
257
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
258
|
+
detail?: string | undefined;
|
|
259
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
260
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
261
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
262
|
+
} | undefined;
|
|
263
|
+
}, {
|
|
264
|
+
code: number;
|
|
265
|
+
message: string;
|
|
266
|
+
data?: {
|
|
267
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
268
|
+
detail?: string | undefined;
|
|
269
|
+
sessionId?: string | undefined;
|
|
270
|
+
agentId?: string | undefined;
|
|
271
|
+
tenantId?: string | undefined;
|
|
272
|
+
} | undefined;
|
|
273
|
+
}>;
|
|
274
|
+
}, "strip", z.ZodTypeAny, {
|
|
275
|
+
id: string | number | null;
|
|
276
|
+
error: {
|
|
277
|
+
code: number;
|
|
278
|
+
message: string;
|
|
279
|
+
data?: {
|
|
280
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
281
|
+
detail?: string | undefined;
|
|
282
|
+
sessionId?: (string & z.BRAND<"SessionId">) | undefined;
|
|
283
|
+
agentId?: (string & z.BRAND<"AgentId">) | undefined;
|
|
284
|
+
tenantId?: (string & z.BRAND<"TenantId">) | undefined;
|
|
285
|
+
} | undefined;
|
|
286
|
+
};
|
|
287
|
+
jsonrpc: "2.0";
|
|
288
|
+
}, {
|
|
289
|
+
id: string | number | null;
|
|
290
|
+
error: {
|
|
291
|
+
code: number;
|
|
292
|
+
message: string;
|
|
293
|
+
data?: {
|
|
294
|
+
appCode: "errProtocolMismatch" | "errUnauthorized" | "errSessionNotInTenant" | "errTenantQuotaExceeded" | "errDeviceQuotaExceeded" | "errAgentUnavailable" | "errModelUnavailable" | "errSessionNotFound" | "errSessionTerminated" | "errSessionBusy" | "errCapabilityUnsupported" | "errHookResolveInvalid" | "errHookTimeout" | "errProjectNotFound" | "errProjectExists" | "errProjectHasActiveSessions" | "errSkillNotFound" | "errSkillScopeInvalid" | "errSkillInstallFailed" | "errWorktreeNotFound" | "errWorktreeHasChanges" | "errWorktreeInUse" | "errBranchNotMerged" | "errBranchInUse" | "errDocumentTooLarge" | "errDocumentPathDenied" | "errPolicyDenied" | "errDuplicateRequest" | "errInvalidParams" | "errInternal";
|
|
295
|
+
detail?: string | undefined;
|
|
296
|
+
sessionId?: string | undefined;
|
|
297
|
+
agentId?: string | undefined;
|
|
298
|
+
tenantId?: string | undefined;
|
|
299
|
+
} | undefined;
|
|
300
|
+
};
|
|
301
|
+
jsonrpc: "2.0";
|
|
302
|
+
}>]>;
|
|
303
|
+
export type JsonRpcMessage = z.infer<typeof JsonRpcMessage>;
|
|
304
|
+
/** 标准 JSON-RPC 传输级错误码。 */
|
|
305
|
+
export declare const JSON_RPC_CODES: {
|
|
306
|
+
readonly parseError: -32700;
|
|
307
|
+
readonly invalidRequest: -32600;
|
|
308
|
+
readonly methodNotFound: -32601;
|
|
309
|
+
readonly invalidParams: -32602;
|
|
310
|
+
readonly internalError: -32603;
|
|
311
|
+
/** 应用级错误统一用这个 code,细分看 data.appCode。 */
|
|
312
|
+
readonly applicationError: -32000;
|
|
313
|
+
};
|
|
314
|
+
//# sourceMappingURL=jsonrpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/schemas/jsonrpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;GAQG;AAEH,eAAO,MAAM,cAAc,qBAAmB,CAAC;AAE/C,qDAAqD;AACrD,eAAO,MAAM,SAAS,wCAAoC,CAAC;AAC3D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,gBAAgB;AAChB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,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.0 信封(design D2)。
|
|
5
|
+
*
|
|
6
|
+
* 单条 WebSocket 上双向跑 JSON-RPC 2.0:两端皆可作 requester。
|
|
7
|
+
* - server → phonon:session.* / discovery.* / hook.resolve
|
|
8
|
+
* - phonon → server:stream.event / hook.fired / discovery.changed / connect.hello
|
|
9
|
+
*
|
|
10
|
+
* 这里只定义「信封」的通用形状;具体方法的 params/result 由 methods.ts 绑定。
|
|
11
|
+
*/
|
|
12
|
+
export const JsonRpcVersion = z.literal("2.0");
|
|
13
|
+
/** 请求 id:字符串或数字(JSON-RPC 允许两者;notification 无 id)。 */
|
|
14
|
+
export const JsonRpcId = z.union([z.string(), z.number()]);
|
|
15
|
+
/** 请求(需要响应)。 */
|
|
16
|
+
export const JsonRpcRequest = z.object({
|
|
17
|
+
jsonrpc: JsonRpcVersion,
|
|
18
|
+
id: JsonRpcId,
|
|
19
|
+
method: z.string(),
|
|
20
|
+
params: z.unknown().optional(),
|
|
21
|
+
});
|
|
22
|
+
/** 通知(不需要响应,无 id)——用于 stream.event / hook.fired / discovery.changed。 */
|
|
23
|
+
export const JsonRpcNotification = z.object({
|
|
24
|
+
jsonrpc: JsonRpcVersion,
|
|
25
|
+
method: z.string(),
|
|
26
|
+
params: z.unknown().optional(),
|
|
27
|
+
});
|
|
28
|
+
/** 成功响应。 */
|
|
29
|
+
export const JsonRpcSuccess = z.object({
|
|
30
|
+
jsonrpc: JsonRpcVersion,
|
|
31
|
+
id: JsonRpcId,
|
|
32
|
+
result: z.unknown(),
|
|
33
|
+
});
|
|
34
|
+
/** JSON-RPC error 对象;data 携带 phonon 应用级错误结构。 */
|
|
35
|
+
export const JsonRpcErrorObject = z.object({
|
|
36
|
+
/** JSON-RPC 传输级 code(-32700..-32600 保留;应用错误用 data.appCode 判别)。 */
|
|
37
|
+
code: z.number().int(),
|
|
38
|
+
message: z.string(),
|
|
39
|
+
data: PhononErrorData.optional(),
|
|
40
|
+
});
|
|
41
|
+
/** 失败响应。 */
|
|
42
|
+
export const JsonRpcError = z.object({
|
|
43
|
+
jsonrpc: JsonRpcVersion,
|
|
44
|
+
id: JsonRpcId.nullable(),
|
|
45
|
+
error: JsonRpcErrorObject,
|
|
46
|
+
});
|
|
47
|
+
/** 任意一条 JSON-RPC 报文。 */
|
|
48
|
+
export const JsonRpcMessage = z.union([
|
|
49
|
+
JsonRpcRequest,
|
|
50
|
+
JsonRpcNotification,
|
|
51
|
+
JsonRpcSuccess,
|
|
52
|
+
JsonRpcError,
|
|
53
|
+
]);
|
|
54
|
+
/** 标准 JSON-RPC 传输级错误码。 */
|
|
55
|
+
export const JSON_RPC_CODES = {
|
|
56
|
+
parseError: -32700,
|
|
57
|
+
invalidRequest: -32600,
|
|
58
|
+
methodNotFound: -32601,
|
|
59
|
+
invalidParams: -32602,
|
|
60
|
+
internalError: -32603,
|
|
61
|
+
/** 应用级错误统一用这个 code,细分看 data.appCode。 */
|
|
62
|
+
applicationError: -32000,
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=jsonrpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../../src/schemas/jsonrpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAE/C,qDAAqD;AACrD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAG3D,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,OAAO,EAAE,cAAc;IACvB,EAAE,EAAE,SAAS;IACb,MAAM,EAAE,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