@agentdock/wire 0.4.0 → 0.4.1
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 +11 -11
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @agentdock/wire
|
|
2
2
|
|
|
3
3
|
> 协议定义层 — 系统的「宪法」。所有组件通过这里定义的格式通信。
|
|
4
4
|
|
|
5
5
|
## 概述
|
|
6
6
|
|
|
7
|
-
wire 是
|
|
7
|
+
wire 是 AgentDock monorepo 的最底层包,**零运行时依赖**(仅 Zod + cuid2)。它定义了:
|
|
8
8
|
|
|
9
9
|
- 会话事件(agent 产生的文本、工具调用、文件变更等)
|
|
10
10
|
- 信封(给事件加上 id/时间戳/角色/turn 等元数据)
|
|
@@ -65,7 +65,7 @@ src/
|
|
|
65
65
|
| Answer | `answer` | `requestId`, `text` | 用户回答 |
|
|
66
66
|
|
|
67
67
|
```typescript
|
|
68
|
-
import { SessionEventSchema } from '@
|
|
68
|
+
import { SessionEventSchema } from '@agentdock/wire';
|
|
69
69
|
|
|
70
70
|
const result = SessionEventSchema.safeParse({
|
|
71
71
|
t: 'text',
|
|
@@ -80,7 +80,7 @@ const result = SessionEventSchema.safeParse({
|
|
|
80
80
|
`SessionEnvelope` 将事件包装为可传输的完整消息单元:
|
|
81
81
|
|
|
82
82
|
```typescript
|
|
83
|
-
import { createEnvelope } from '@
|
|
83
|
+
import { createEnvelope } from '@agentdock/wire';
|
|
84
84
|
|
|
85
85
|
const envelope = createEnvelope(
|
|
86
86
|
'agent',
|
|
@@ -98,7 +98,7 @@ const envelope = createEnvelope(
|
|
|
98
98
|
### 消息 (messages.ts)
|
|
99
99
|
|
|
100
100
|
```typescript
|
|
101
|
-
import type { SessionMessage } from '@
|
|
101
|
+
import type { SessionMessage } from '@agentdock/wire';
|
|
102
102
|
|
|
103
103
|
// SessionMessage = 加密后的消息格式
|
|
104
104
|
// content: { c: string (密文), n: string (nonce) }
|
|
@@ -110,14 +110,14 @@ import type { SessionMessage } from '@agentbox/wire';
|
|
|
110
110
|
定义 daemon ↔ server ↔ client 之间的远程调用方法:
|
|
111
111
|
|
|
112
112
|
```typescript
|
|
113
|
-
import { RpcMethodSchema } from '@
|
|
113
|
+
import { RpcMethodSchema } from '@agentdock/wire';
|
|
114
114
|
// 包含方法名、参数 schema、返回值 schema
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
### 同步协议 (sync.ts)
|
|
118
118
|
|
|
119
119
|
```typescript
|
|
120
|
-
import type { CoreUpdate } from '@
|
|
120
|
+
import type { CoreUpdate } from '@agentdock/wire';
|
|
121
121
|
// CoreUpdate: 增量更新载体
|
|
122
122
|
// VersionedEncryptedValue: 带版本号的加密值(乐观锁)
|
|
123
123
|
```
|
|
@@ -125,7 +125,7 @@ import type { CoreUpdate } from '@agentbox/wire';
|
|
|
125
125
|
### 控制深度 (controlLevel.ts)
|
|
126
126
|
|
|
127
127
|
```typescript
|
|
128
|
-
import { ControlLevelSchema, CliTypeSchema } from '@
|
|
128
|
+
import { ControlLevelSchema, CliTypeSchema } from '@agentdock/wire';
|
|
129
129
|
|
|
130
130
|
// ControlLevel: 0(最低) | 1(仅监控) | 2(高控制) | 3(完全控制)
|
|
131
131
|
// CliType: 'claude' | 'copilot' | 'opencode' | 'codex' | 'gemini' | 'qwen'
|
|
@@ -135,13 +135,13 @@ import { ControlLevelSchema, CliTypeSchema } from '@agentbox/wire';
|
|
|
135
135
|
|
|
136
136
|
```bash
|
|
137
137
|
# 运行测试(300 tests)
|
|
138
|
-
pnpm --filter @
|
|
138
|
+
pnpm --filter @agentdock/wire test
|
|
139
139
|
|
|
140
140
|
# 覆盖率(目标 95%+)
|
|
141
|
-
pnpm --filter @
|
|
141
|
+
pnpm --filter @agentdock/wire test:coverage
|
|
142
142
|
|
|
143
143
|
# 类型检查
|
|
144
|
-
pnpm --filter @
|
|
144
|
+
pnpm --filter @agentdock/wire typecheck
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
## 设计决策
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const RpcMethod: z.ZodEnum<["spawn-session", "stop-session", "abort", "switch-mode", "approve-permission", "deny-permission", "answer-question", "shutdown-daemon", "get-messages", "get-stats", "get-team-stats", "start-invite", "get-machine-info", "get-agent-settings", "set-agent-settings"]>;
|
|
3
3
|
/**
|
|
4
|
-
* Session-scoped RPC methods — registered by `
|
|
4
|
+
* Session-scoped RPC methods — registered by `agentdock start` (CLI process).
|
|
5
5
|
* These operate on a specific session and require the CLI to be running.
|
|
6
6
|
*/
|
|
7
7
|
export declare const SESSION_RPC_METHODS: readonly ["answer-question", "approve-permission", "deny-permission", "abort", "stop-session"];
|
package/dist/rpc.js
CHANGED
|
@@ -18,7 +18,7 @@ export const RpcMethod = z.enum([
|
|
|
18
18
|
'set-agent-settings',
|
|
19
19
|
]);
|
|
20
20
|
/**
|
|
21
|
-
* Session-scoped RPC methods — registered by `
|
|
21
|
+
* Session-scoped RPC methods — registered by `agentdock start` (CLI process).
|
|
22
22
|
* These operate on a specific session and require the CLI to be running.
|
|
23
23
|
*/
|
|
24
24
|
export const SESSION_RPC_METHODS = [
|