@vibearound/plugin-channel-sdk 0.1.0 → 0.1.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present VibeAround Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # @vibearound/plugin-channel-sdk
2
+
3
+ Base classes and utilities for building [VibeAround](https://github.com/anthropics/vibearound) channel plugins.
4
+
5
+ VibeAround channel plugins bridge messaging platforms (Telegram, Feishu, WeChat, etc.) to the VibeAround agent runtime via the [Agent Client Protocol (ACP)](https://github.com/anthropics/agent-client-protocol). This SDK extracts the shared patterns so you can focus on platform integration.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @vibearound/plugin-channel-sdk
11
+ ```
12
+
13
+ ## What it provides
14
+
15
+ - **`connectToHost()`** — Sets up the ACP stdio connection, performs the initialize handshake, extracts plugin config from the host, and redirects console output to stderr.
16
+ - **`BlockRenderer<TRef>`** — Abstract base class that handles block-based message rendering: accumulation of streaming deltas, kind-change detection, debounced flushing, edit throttling, and ordered delivery via a serialized Promise chain.
17
+ - **`normalizeExtMethod()`** — Strips the `_` prefix the ACP SDK adds to extension method names.
18
+ - **Types** — Re-exports common ACP SDK types (`Agent`, `Client`, `SessionNotification`, etc.) plus SDK-specific types (`BlockKind`, `VerboseConfig`, `PluginManifest`, etc.).
19
+
20
+ ## Quick start
21
+
22
+ ```ts
23
+ import {
24
+ connectToHost,
25
+ BlockRenderer,
26
+ normalizeExtMethod,
27
+ type Agent,
28
+ type BlockKind,
29
+ type SessionNotification,
30
+ } from "@vibearound/plugin-channel-sdk";
31
+
32
+ // 1. Implement a renderer for your platform
33
+ class MyRenderer extends BlockRenderer<string> {
34
+ protected async sendBlock(channelId: string, kind: BlockKind, content: string) {
35
+ const msg = await myPlatform.send(channelId, content);
36
+ return msg.id; // platform message reference for future edits
37
+ }
38
+
39
+ // Optional — omit for platforms that don't support editing
40
+ protected async editBlock(channelId: string, ref: string, kind: BlockKind, content: string, sealed: boolean) {
41
+ await myPlatform.edit(ref, content);
42
+ }
43
+ }
44
+
45
+ // 2. Connect to the VibeAround host
46
+ const renderer = new MyRenderer({ minEditIntervalMs: 600 });
47
+
48
+ const { agent, meta, agentInfo, conn } = await connectToHost(
49
+ { name: "vibearound-myplatform", version: "0.1.0" },
50
+ (_agent) => ({
51
+ async sessionUpdate(params: SessionNotification) {
52
+ renderer.onSessionUpdate(params);
53
+ },
54
+ async requestPermission(params) {
55
+ return { outcome: { outcome: "selected", optionId: params.options![0].optionId } };
56
+ },
57
+ async extNotification(method, params) {
58
+ switch (normalizeExtMethod(method)) {
59
+ case "channel/system_text":
60
+ await myPlatform.send(params.channelId as string, params.text as string);
61
+ break;
62
+ }
63
+ },
64
+ }),
65
+ );
66
+
67
+ // 3. Use the config and start your platform bot
68
+ const botToken = meta.config.bot_token as string;
69
+ // ... initialize your platform SDK ...
70
+
71
+ // 4. On each incoming message:
72
+ renderer.onPromptSent(channelId);
73
+ try {
74
+ await agent.prompt({ sessionId: chatId, prompt: contentBlocks });
75
+ await renderer.onTurnEnd(channelId);
76
+ } catch (e) {
77
+ await renderer.onTurnError(channelId, String(e));
78
+ }
79
+
80
+ // 5. Keep alive until host disconnects
81
+ await conn.closed;
82
+ ```
83
+
84
+ ## BlockRenderer
85
+
86
+ The `BlockRenderer<TRef>` groups streaming ACP events into contiguous blocks by kind (`text`, `thinking`, `tool`), then renders them to your platform via `sendBlock` / `editBlock`.
87
+
88
+ ### Constructor options
89
+
90
+ | Option | Default | Description |
91
+ |---|---|---|
92
+ | `flushIntervalMs` | `500` | Debounce interval before flushing an in-progress block |
93
+ | `minEditIntervalMs` | `1000` | Minimum gap between consecutive edits (rate limit protection) |
94
+ | `verbose.showThinking` | `false` | Render agent thinking/reasoning blocks |
95
+ | `verbose.showToolUse` | `false` | Render tool call/result blocks |
96
+
97
+ ### Methods to implement
98
+
99
+ | Method | Required | Description |
100
+ |---|---|---|
101
+ | `sendBlock(channelId, kind, content)` | Yes | Send a new message, return a platform ref (or `null` if no editing) |
102
+ | `editBlock(channelId, ref, kind, content, sealed)` | No | Edit an existing message in-place |
103
+ | `formatContent(kind, content, sealed)` | No | Format block content before send/edit (default: emoji prefixes) |
104
+
105
+ ### Lifecycle hooks
106
+
107
+ | Hook | Description |
108
+ |---|---|
109
+ | `onAfterTurnEnd(channelId)` | Cleanup after all blocks are flushed (e.g. remove typing indicator) |
110
+ | `onAfterTurnError(channelId, error)` | Send error message to user |
111
+ | `sessionIdToChannelId(sessionId)` | Map ACP session ID to your channel ID (default: identity) |
112
+
113
+ ## Plugin manifest
114
+
115
+ Each channel plugin needs a `plugin.json` at its root:
116
+
117
+ ```json
118
+ {
119
+ "id": "my-platform",
120
+ "name": "My Platform Channel",
121
+ "version": "0.1.0",
122
+ "kind": "channel",
123
+ "runtime": "node",
124
+ "entry": "dist/main.js",
125
+ "build": "npm install && npm run build",
126
+ "configSchema": {
127
+ "type": "object",
128
+ "properties": {
129
+ "bot_token": { "type": "string" }
130
+ },
131
+ "required": ["bot_token"]
132
+ },
133
+ "capabilities": {
134
+ "streaming": true,
135
+ "editMessage": true,
136
+ "media": false
137
+ }
138
+ }
139
+ ```
140
+
141
+ ## Examples
142
+
143
+ See the official channel plugins for real-world usage:
144
+
145
+ - **Feishu** — Interactive cards, streaming updates, reactions
146
+ - **Telegram** — Plain text messages with inline editing
147
+ - **WeChat** — Send-only mode (no editing), typing indicators
148
+
149
+ ## License
150
+
151
+ MIT
package/dist/index.d.ts CHANGED
@@ -55,5 +55,5 @@
55
55
  export { connectToHost, normalizeExtMethod, redirectConsoleToStderr } from "./connection.js";
56
56
  export type { PluginInfo, ConnectResult, AgentInfo } from "./connection.js";
57
57
  export { BlockRenderer } from "./renderer.js";
58
- export type { Agent, Client, SessionNotification, RequestPermissionRequest, RequestPermissionResponse, BlockKind, VerboseConfig, BlockRendererOptions, PluginCapabilities, PluginManifest, PluginInitMeta, } from "./types.js";
58
+ export type { Agent, Client, ContentBlock, SessionNotification, RequestPermissionRequest, RequestPermissionResponse, BlockKind, VerboseConfig, BlockRendererOptions, PluginCapabilities, PluginManifest, PluginInitMeta, } from "./types.js";
59
59
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,YAAY,EAEV,KAAK,EACL,MAAM,EACN,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAEzB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAGH,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC7F,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,YAAY,EAEV,KAAK,EACL,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAEzB,SAAS,EACT,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
package/dist/types.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Re-exports the ACP SDK types plugins commonly need, plus SDK-specific types
5
5
  * for block rendering, plugin manifests, and verbose configuration.
6
6
  */
7
- export type { Agent, Client, SessionNotification, RequestPermissionRequest, RequestPermissionResponse, } from "@agentclientprotocol/sdk";
7
+ export type { Agent, Client, ContentBlock, SessionNotification, RequestPermissionRequest, RequestPermissionResponse, } from "@agentclientprotocol/sdk";
8
8
  export interface PluginCapabilities {
9
9
  /** Plugin supports real-time streaming updates. */
10
10
  streaming?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EACV,KAAK,EACL,MAAM,EACN,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM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AC,CAAC;CAClC;AAMD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@vibearound/plugin-channel-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "VibeAround Plugin SDK — base classes and utilities for building channel plugins",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "files": ["dist", "src"],
7
+ "files": [
8
+ "dist",
9
+ "src"
10
+ ],
8
11
  "main": "dist/index.js",
9
12
  "types": "dist/index.d.ts",
10
13
  "exports": {
package/src/index.ts CHANGED
@@ -65,6 +65,7 @@ export type {
65
65
  // ACP SDK
66
66
  Agent,
67
67
  Client,
68
+ ContentBlock,
68
69
  SessionNotification,
69
70
  RequestPermissionRequest,
70
71
  RequestPermissionResponse,
package/src/types.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  export type {
10
10
  Agent,
11
11
  Client,
12
+ ContentBlock,
12
13
  SessionNotification,
13
14
  RequestPermissionRequest,
14
15
  RequestPermissionResponse,