Skip to content

Commit ae4ce0a

Browse files
ymansurozerclaude
andcommitted
feat: full 0.9.0 resume/recovery parity
Bring the Vue port up to parity with @cloudflare/ai-chat 0.9.x on resume/recovery: - Resume dedupe (0.8.5): fallback-ACK a resume offer at most once per socket, preventing duplicated assistant text when a stream resume is replayed twice. - isRecovering (0.8.0): reactive flag driven by the cf_agent_chat_recovering frame, distinct from streaming; not cleared by ordinary message sync. - cancelOnClientAbort (0.7.0): generic client aborts are local-only by default and the server turn keeps running and stays observable; explicit stop() always cancels via active-server-turn tracking (locally-initiated, resume-fallback-observed, and transport-resumed turns are all cancellable). - cf_agent_stream_pending (0.9.0): extend the resume probe 5s -> 60s during the server's pre-stream window. - connectionError (0.9.0): surface terminal WebSocket failures from the AgentClient. Bumps the agents dependency to 0.17.0 and raises the peer floor to >=0.17.0 (the version that first exports connectionError / onConnectionError / AgentConnectionError). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012MmBgJB6Z7GT9ZffT79YhA
1 parent 80d98c1 commit ae4ce0a

7 files changed

Lines changed: 1192 additions & 229 deletions

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Vue 3 composable for [Cloudflare Agents](https://github.com/cloudflare/agents)
66
77
## Status
88

9-
v0.1 — covers the surface needed for a working chat UI: streaming responses, client-side tools, tool approvals, stream resumption, broadcast handling. Deeper upstream features (the `useAgent` connection hook, initial-message HTTP cache, `isServerStreaming` flag) are on the roadmap.
9+
Covers the surface needed for a working chat UIstreaming responses, client-side tools, tool approvals, stream resumption, broadcast handling — at parity with upstream `@cloudflare/ai-chat` 0.9.x on resume/recovery: resume dedupe, `isRecovering`, `cancelOnClientAbort`, pre-stream `cf_agent_stream_pending`, and `connectionError`. Deeper upstream features (the `useAgent` connection hook, initial-message HTTP cache, `isServerStreaming` / `isStreaming` flags) are on the roadmap.
1010

1111
## Install
1212

@@ -21,7 +21,7 @@ Peer dependencies (must also be installed):
2121
| `vue` | `^3.3.4` |
2222
| `@ai-sdk/vue` | `^3.0.0` |
2323
| `ai` | `^6.0.0` |
24-
| `agents` | `>=0.11.0 <1.0.0` |
24+
| `agents` | `>=0.17.0 <1.0.0` |
2525

2626
## Usage
2727

@@ -78,7 +78,9 @@ Returns:
7878
| `addToolOutput` | `function` | Submit a tool result. Sends `cf_agent_tool_result` and triggers continuation if enabled. |
7979
| `addToolApprovalResponse` | `function` | Resolve a human-in-the-loop tool approval. Sends `cf_agent_tool_approval` and triggers continuation. |
8080
| `clearHistory` | `function` | Clear local state and broadcast `cf_agent_chat_clear` to the server. |
81-
| `stop` | `function` | Abort the active stream and any pending tool continuation. |
81+
| `stop` | `function` | Abort the active stream and any pending tool continuation. Always cancels the server turn (explicit cancel). |
82+
| `isRecovering` | `Ref<boolean>` | Reactive — `true` while the server is recovering a durable chat turn (distinct from streaming, so a UI can show "recovering…"). Driven by `cf_agent_chat_recovering`. |
83+
| `connectionError` | `Ref<AgentConnectionError \| null>` | Reactive — the terminal WebSocket connection failure, or `null`. Cleared on reconnect. |
8284

8385
### Options
8486

@@ -91,6 +93,7 @@ Returns:
9193
| `onToolCall` | `({ toolCall, addToolOutput }) => void \| Promise<void>` || Custom tool-call handler. Overrides per-tool `execute`. |
9294
| `autoContinueAfterToolResult` | `boolean` | `true` | Server resumes the stream after a tool result. |
9395
| `resume` | `boolean` | `true` | Resume in-flight streams on socket reconnect. |
96+
| `cancelOnClientAbort` | `boolean` | `false` | When `true`, a generic client-side abort cancels the server turn; when `false` (default) such aborts are local-only and the server turn keeps running and can resume. Explicit `stop()` always cancels. |
9497
| `onOpen` | `(event: Event) => void` || WebSocket open. |
9598
| `onClose` | `(event: CloseEvent) => void` || WebSocket close. |
9699
| `onSocketError` | `(event: Event) => void` || Connection-level error. |
@@ -157,6 +160,11 @@ const transport = new WebSocketChatTransport({
157160
| Partial-hydration replay rebuild ||
158161
| Broadcast handling (multi-tab) ||
159162
| Tool approval continuation merge across broadcasts ||
163+
| Resume dedupe (fallback-ACK at most once per socket) ||
164+
| `isRecovering` durable-recovery hint (`cf_agent_chat_recovering`) ||
165+
| `cancelOnClientAbort` (local-only abort, default) ||
166+
| Pre-stream `cf_agent_stream_pending` (extended resume probe) ||
167+
| `connectionError` (terminal WebSocket close) ||
160168
| `useAgent` connection hook | 🚧 roadmap |
161169
| Initial-message HTTP cache | 🚧 roadmap |
162170
| `isServerStreaming` / `isStreaming` flags | 🚧 roadmap |
@@ -166,7 +174,7 @@ const transport = new WebSocketChatTransport({
166174
```bash
167175
pnpm install
168176
pnpm exec playwright install chromium
169-
pnpm test # 59 tests in chromium (vitest-browser-vue)
177+
pnpm test # 79 tests in chromium (vitest-browser-vue)
170178
pnpm typecheck
171179
pnpm lint
172180
pnpm build

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
},
5151
"peerDependencies": {
5252
"@ai-sdk/vue": "^3.0.0",
53-
"agents": ">=0.11.0 <1.0.0",
53+
"agents": ">=0.17.0 <1.0.0",
5454
"ai": "^6.0.0",
5555
"vue": "^3.3.4"
5656
},
@@ -60,7 +60,7 @@
6060
"@types/node": "^22.0.0",
6161
"@vitest/browser": "^4.1.5",
6262
"@vitest/browser-playwright": "^4.1.5",
63-
"agents": "^0.11.4",
63+
"agents": "^0.17.0",
6464
"ai": "^6.0.0",
6565
"changelogen": "^0.6.2",
6666
"eslint": "^9.0.0",

0 commit comments

Comments
 (0)