@epoch-agent/view 5.0.0 → 6.0.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 CHANGED
@@ -78,10 +78,14 @@
78
78
 
79
79
  ```bash
80
80
  pnpm --filter @epoch-agent/view test
81
- pnpm --filter @epoch-agent/view build # tui / web 都从 dist 解析它,改完必须 build
81
+ pnpm --filter @epoch-agent/view build # 应用侧(vite build / tsx)从 dist 解析它
82
82
  ```
83
83
 
84
- > ⚠️ [web](../web) 和 [tui](../tui) 是按 package.json 的 `exports` 从**本包的 `dist/`**
85
- > 解析的。只改源码不 build,vite / tsx 那边看到的还是上一次的产物——症状是
86
- > `vite build` 报 `MISSING_EXPORT`,或者新加的字段在界面上永远不出现。
87
- > 根目录的 `pnpm build` 会自己排好顺序。
84
+ > ⚠️ [web](../web) 和 [tui](../tui) 的**应用侧**(`vite build`、`tsx`)是按
85
+ > package.json 的 `exports` 从**本包的 `dist/`** 解析的。只改源码不 build,那边看到的
86
+ > 还是上一次的产物——症状是 `vite build` 报 `MISSING_EXPORT`,或者新加的字段在界面上
87
+ > 永远不出现。根目录的 `pnpm build` 会自己排好顺序。
88
+ >
89
+ > ⚠️ **用例不是这一档**:web / tui 的 `vitest.config.ts` 把 `@epoch-agent/view`
90
+ > alias 到 `src/index.ts`,所以 `pnpm test` 不需要先 build。判据和实测在那两份配置的
91
+ > 注释里——那之前 `pnpm test` 读的是 `dist`,改了源码没重建时全绿但测的是旧代码。
package/dist/index.d.ts CHANGED
@@ -178,6 +178,22 @@ type HistoryItemThinking = HistoryItemBase & {
178
178
  type HistoryItemDiff = HistoryItemBase & {
179
179
  type: 'diff';
180
180
  filePath: string;
181
+ /**
182
+ * 产出这张补丁的那次调用(`tool-call` 的 `callId`)。
183
+ *
184
+ * 补丁帧自己不带它(protocol 的 `type: 'diff'` 只有路径和两边内容),而它在流里
185
+ * 恒排在产出者那次调用的 `tool-result` **之前**,引擎又是**一次调用一次地**跑工具
186
+ * (`core/src/agent/loop.ts` 那个 for 循环)—— 于是收帧那一刻还没收口的那一次调用
187
+ * 就是它的产出者,`reducer` 据此补上。
188
+ *
189
+ * 有了这一格,宿主才能把补丁认回**那一张**卡;没有就只剩「同一路径的第 k 张」,
190
+ * 中间夹一个也带着这个路径、却不写文件的调用(读、或者名字认不出来的 MCP 工具)
191
+ * 时就认错一张 —— 补丁从自己那张卡后面跳到前一张后面。
192
+ *
193
+ * ⚠️ **只有实时流里补得出来**:落盘的补丁项没有这一格(库表里就没有),所以
194
+ * 渲染层必须容忍它缺席。
195
+ */
196
+ callId?: string;
181
197
  oldContent?: string;
182
198
  newContent?: string;
183
199
  /**
package/dist/index.js CHANGED
@@ -30,6 +30,17 @@ function patchTool(pending, callId, patch) {
30
30
  }
31
31
  return null;
32
32
  }
33
+ function openCallId(pending) {
34
+ for (let i = pending.length - 1; i >= 0; i--) {
35
+ const item = pending[i];
36
+ if (item?.type !== "tool_group") continue;
37
+ for (let j = item.tools.length - 1; j >= 0; j--) {
38
+ const tool = item.tools[j];
39
+ if (tool?.status === "pending") return tool.callId;
40
+ }
41
+ }
42
+ return void 0;
43
+ }
33
44
  function applyStreamEvent(state, event, meta) {
34
45
  const { pending, thought } = state;
35
46
  const carry = (next) => state.sealed === void 0 || next.sealed !== void 0 ? next : { ...next, sealed: state.sealed };
@@ -88,7 +99,8 @@ function applyStreamEvent(state, event, meta) {
88
99
  });
89
100
  return next ? carry({ pending: next, thought }) : state;
90
101
  }
91
- case "diff":
102
+ case "diff": {
103
+ const producer = openCallId(pending);
92
104
  return carry({
93
105
  pending: [
94
106
  ...pending,
@@ -97,11 +109,13 @@ function applyStreamEvent(state, event, meta) {
97
109
  filePath: event.filePath,
98
110
  ...event.oldContent !== void 0 ? { oldContent: event.oldContent } : {},
99
111
  ...event.newContent !== void 0 ? { newContent: event.newContent } : {},
112
+ ...producer !== void 0 ? { callId: producer } : {},
100
113
  ...anchor(meta)
101
114
  }
102
115
  ],
103
116
  thought
104
117
  });
118
+ }
105
119
  case "notice":
106
120
  return carry({
107
121
  pending: [...pending, { type: "info", text: event.text, ...anchor(meta) }],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epoch-agent/view",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "private": false,
5
5
  "description": "epoch-agent 展示层纯逻辑:AgentEvent → 可渲染 item,tui 与 web 共用",
6
6
  "repository": {
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@epoch-agent/protocol": "5.0.0"
25
+ "@epoch-agent/protocol": "6.0.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "tsup": "^8.3.6",