@vibearound/plugin-channel-sdk 0.3.0 → 0.4.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 +62 -108
- package/dist/advanced.d.ts +19 -0
- package/dist/advanced.d.ts.map +1 -0
- package/dist/advanced.js +18 -0
- package/dist/advanced.js.map +1 -0
- package/dist/connection.d.ts +10 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +10 -4
- package/dist/connection.js.map +1 -1
- package/dist/index.d.ts +27 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -45
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +80 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/{run-plugin.js → plugin.js} +43 -44
- package/dist/plugin.js.map +1 -0
- package/dist/renderer.d.ts +52 -46
- package/dist/renderer.d.ts.map +1 -1
- package/dist/renderer.js +114 -90
- package/dist/renderer.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/advanced.ts +43 -0
- package/src/connection.ts +10 -4
- package/src/index.ts +41 -60
- package/src/{run-plugin.ts → plugin.ts} +70 -72
- package/src/renderer.ts +142 -97
- package/src/types.ts +24 -0
- package/dist/run-plugin.d.ts +0 -95
- package/dist/run-plugin.d.ts.map +0 -1
- package/dist/run-plugin.js.map +0 -1
package/dist/renderer.js
CHANGED
|
@@ -25,32 +25,26 @@
|
|
|
25
25
|
*
|
|
26
26
|
* ## Usage
|
|
27
27
|
*
|
|
28
|
+
* Subclass and implement `sendText` + `sendBlock` (+ optionally `editBlock`):
|
|
29
|
+
*
|
|
28
30
|
* ```ts
|
|
29
31
|
* class MyRenderer extends BlockRenderer<string> {
|
|
30
|
-
* protected async
|
|
31
|
-
*
|
|
32
|
+
* protected async sendText(chatId, text) {
|
|
33
|
+
* await myApi.sendMessage(chatId, text);
|
|
34
|
+
* }
|
|
35
|
+
* protected async sendBlock(chatId, kind, content) {
|
|
36
|
+
* const msg = await myApi.sendMessage(chatId, content);
|
|
32
37
|
* return msg.id;
|
|
33
38
|
* }
|
|
34
|
-
* protected async editBlock(
|
|
39
|
+
* protected async editBlock(chatId, ref, kind, content, sealed) {
|
|
35
40
|
* await myApi.editMessage(ref, content);
|
|
36
41
|
* }
|
|
37
42
|
* }
|
|
38
|
-
*
|
|
39
|
-
* // In main.ts:
|
|
40
|
-
* const renderer = new MyRenderer({ verbose: { showThinking: false } });
|
|
41
|
-
*
|
|
42
|
-
* // When user sends a message:
|
|
43
|
-
* renderer.onPromptSent(channelId);
|
|
44
|
-
* try {
|
|
45
|
-
* await agent.prompt({ sessionId, content });
|
|
46
|
-
* await renderer.onTurnEnd(channelId);
|
|
47
|
-
* } catch (e) {
|
|
48
|
-
* await renderer.onTurnError(channelId, String(e));
|
|
49
|
-
* }
|
|
50
|
-
*
|
|
51
|
-
* // In the ACP client's sessionUpdate handler:
|
|
52
|
-
* renderer.onSessionUpdate(notification);
|
|
53
43
|
* ```
|
|
44
|
+
*
|
|
45
|
+
* The SDK's `runChannelPlugin` wires all ACP events to this renderer
|
|
46
|
+
* automatically — plugins don't call onSessionUpdate/onPromptSent/etc
|
|
47
|
+
* directly.
|
|
54
48
|
*/
|
|
55
49
|
// ---------------------------------------------------------------------------
|
|
56
50
|
// Constants
|
|
@@ -68,11 +62,18 @@ const DEFAULT_MIN_EDIT_INTERVAL_MS = 1000;
|
|
|
68
62
|
* return type of `sendBlock` and the first argument of `editBlock`.
|
|
69
63
|
*/
|
|
70
64
|
export class BlockRenderer {
|
|
65
|
+
/** When true, blocks are sent and edited in real-time. When false, each
|
|
66
|
+
* block is held until complete, then sent once (send-only mode). */
|
|
67
|
+
streaming;
|
|
71
68
|
flushIntervalMs;
|
|
72
69
|
minEditIntervalMs;
|
|
73
70
|
verbose;
|
|
74
71
|
states = new Map();
|
|
72
|
+
/** The chatId of the most recent prompt. Used as fallback target for
|
|
73
|
+
* notifications that arrive without an explicit chatId. */
|
|
74
|
+
lastActiveChatId = null;
|
|
75
75
|
constructor(options = {}) {
|
|
76
|
+
this.streaming = options.streaming ?? true;
|
|
76
77
|
this.flushIntervalMs = options.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;
|
|
77
78
|
this.minEditIntervalMs = options.minEditIntervalMs ?? DEFAULT_MIN_EDIT_INTERVAL_MS;
|
|
78
79
|
this.verbose = {
|
|
@@ -99,29 +100,17 @@ export class BlockRenderer {
|
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
101
102
|
* Called after the last block has been flushed and the turn is complete.
|
|
102
|
-
* Override to perform cleanup (e.g. remove a "typing" indicator
|
|
103
|
-
* processing reaction, etc.).
|
|
103
|
+
* Override to perform cleanup (e.g. remove a "typing" indicator).
|
|
104
104
|
*/
|
|
105
|
-
onAfterTurnEnd(
|
|
105
|
+
onAfterTurnEnd(_chatId) {
|
|
106
106
|
return Promise.resolve();
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
* Called after a turn error
|
|
110
|
-
* Override
|
|
109
|
+
* Called after a turn error. Default sends an error message via sendText.
|
|
110
|
+
* Override for platform-specific error rendering (e.g. error card).
|
|
111
111
|
*/
|
|
112
|
-
onAfterTurnError(
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Map an ACP `sessionId` to the channel ID used internally.
|
|
117
|
-
*
|
|
118
|
-
* Default: identity (sessionId === channelId).
|
|
119
|
-
*
|
|
120
|
-
* Override if your plugin namespaces channel IDs (e.g. Feishu uses
|
|
121
|
-
* `"feishu:<sessionId>"`, WeChat uses `"weixin-openclaw-bridge:<sessionId>"`).
|
|
122
|
-
*/
|
|
123
|
-
sessionIdToChannelId(sessionId) {
|
|
124
|
-
return sessionId;
|
|
112
|
+
async onAfterTurnError(chatId, error) {
|
|
113
|
+
await this.sendText(chatId, `❌ Error: ${error}`);
|
|
125
114
|
}
|
|
126
115
|
// ---------------------------------------------------------------------------
|
|
127
116
|
// Public API
|
|
@@ -132,14 +121,12 @@ export class BlockRenderer {
|
|
|
132
121
|
* Routes the event to the correct block based on its variant, appending
|
|
133
122
|
* deltas to the current block or starting a new one when the kind changes.
|
|
134
123
|
*
|
|
135
|
-
*
|
|
124
|
+
* Called automatically by `runChannelPlugin` — plugins don't call this directly.
|
|
136
125
|
*/
|
|
137
126
|
onSessionUpdate(notification) {
|
|
138
|
-
|
|
139
|
-
//
|
|
140
|
-
|
|
141
|
-
// of importing the SDK's own union. Variants other than the four we
|
|
142
|
-
// handle are treated as no-ops.
|
|
127
|
+
// sessionId from ACP = chatId (the host replaces the real agent session
|
|
128
|
+
// ID with the chat ID before forwarding to the plugin).
|
|
129
|
+
const chatId = notification.sessionId;
|
|
143
130
|
const rawUpdate = notification.update;
|
|
144
131
|
const variant = rawUpdate.sessionUpdate;
|
|
145
132
|
if (variant !== "agent_message_chunk" &&
|
|
@@ -149,66 +136,108 @@ export class BlockRenderer {
|
|
|
149
136
|
return;
|
|
150
137
|
}
|
|
151
138
|
const update = rawUpdate;
|
|
152
|
-
const channelId = this.sessionIdToChannelId(sessionId);
|
|
153
139
|
switch (update.sessionUpdate) {
|
|
154
140
|
case "agent_message_chunk": {
|
|
155
141
|
const delta = update.content?.text ?? "";
|
|
156
142
|
if (delta)
|
|
157
|
-
this.appendToBlock(
|
|
143
|
+
this.appendToBlock(chatId, "text", delta);
|
|
158
144
|
break;
|
|
159
145
|
}
|
|
160
146
|
case "agent_thought_chunk": {
|
|
161
147
|
if (!this.verbose.showThinking)
|
|
162
|
-
return;
|
|
148
|
+
return;
|
|
163
149
|
const delta = update.content?.text ?? "";
|
|
164
150
|
if (delta)
|
|
165
|
-
this.appendToBlock(
|
|
151
|
+
this.appendToBlock(chatId, "thinking", delta);
|
|
166
152
|
break;
|
|
167
153
|
}
|
|
168
154
|
case "tool_call": {
|
|
169
155
|
if (!this.verbose.showToolUse)
|
|
170
|
-
return;
|
|
156
|
+
return;
|
|
171
157
|
if (update.title)
|
|
172
|
-
this.appendToBlock(
|
|
158
|
+
this.appendToBlock(chatId, "tool", `🔧 ${update.title}\n`);
|
|
173
159
|
break;
|
|
174
160
|
}
|
|
175
161
|
case "tool_call_update": {
|
|
176
162
|
if (!this.verbose.showToolUse)
|
|
177
|
-
return;
|
|
163
|
+
return;
|
|
178
164
|
const title = update.title ?? "tool";
|
|
179
165
|
if (update.status === "completed" || update.status === "error") {
|
|
180
|
-
this.appendToBlock(
|
|
166
|
+
this.appendToBlock(chatId, "tool", `✅ ${title}\n`);
|
|
181
167
|
}
|
|
182
168
|
break;
|
|
183
169
|
}
|
|
184
|
-
// Unknown / unconsumed variant — ignore.
|
|
185
170
|
}
|
|
186
171
|
}
|
|
187
172
|
/**
|
|
188
|
-
* Call
|
|
189
|
-
*
|
|
190
|
-
* Clears any leftover state from a previous turn so the new turn starts
|
|
191
|
-
* with a clean slate.
|
|
173
|
+
* Call before sending a prompt. Tracks the active chatId and clears
|
|
174
|
+
* leftover state from a previous turn.
|
|
192
175
|
*/
|
|
193
|
-
onPromptSent(
|
|
194
|
-
|
|
176
|
+
onPromptSent(chatId) {
|
|
177
|
+
this.lastActiveChatId = chatId;
|
|
178
|
+
const old = this.states.get(chatId);
|
|
195
179
|
if (old?.flushTimer)
|
|
196
180
|
clearTimeout(old.flushTimer);
|
|
197
|
-
this.states.set(
|
|
181
|
+
this.states.set(chatId, {
|
|
198
182
|
blocks: [],
|
|
199
183
|
flushTimer: null,
|
|
200
184
|
lastEditMs: 0,
|
|
201
185
|
sendChain: Promise.resolve(),
|
|
202
186
|
});
|
|
203
187
|
}
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
// Host notification handlers — built-in defaults, no per-plugin duplication
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
/** Handle `va/system_text` from host. */
|
|
192
|
+
onSystemText(chatId, text) {
|
|
193
|
+
this.sendText(chatId, text).catch(() => { });
|
|
194
|
+
}
|
|
195
|
+
/** Handle `va/agent_ready` from host. */
|
|
196
|
+
onAgentReady(chatId, agent, version) {
|
|
197
|
+
this.sendText(chatId, `🤖 Agent: ${agent} v${version}`).catch(() => { });
|
|
198
|
+
}
|
|
199
|
+
/** Handle `va/session_ready` from host. */
|
|
200
|
+
onSessionReady(chatId, sessionId) {
|
|
201
|
+
this.sendText(chatId, `📋 Session: ${sessionId}`).catch(() => { });
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Handle `va/command_menu` from host — display available commands.
|
|
205
|
+
*
|
|
206
|
+
* Default renders a plain-text list. Override for platform-specific
|
|
207
|
+
* rendering (e.g. Feishu interactive card, Slack Block Kit, Telegram
|
|
208
|
+
* inline keyboard).
|
|
209
|
+
*/
|
|
210
|
+
onCommandMenu(chatId, systemCommands, agentCommands) {
|
|
211
|
+
const lines = [];
|
|
212
|
+
lines.push("System commands:");
|
|
213
|
+
for (const cmd of systemCommands) {
|
|
214
|
+
const usage = cmd.args ? `/${cmd.name} ${cmd.args}` : `/${cmd.name}`;
|
|
215
|
+
lines.push(` ${usage} — ${cmd.description}`);
|
|
216
|
+
}
|
|
217
|
+
if (agentCommands.length > 0) {
|
|
218
|
+
lines.push("");
|
|
219
|
+
lines.push("Agent commands (use /agent <command>):");
|
|
220
|
+
for (const cmd of agentCommands) {
|
|
221
|
+
const desc = cmd.description.length > 80
|
|
222
|
+
? `${cmd.description.slice(0, 77)}...`
|
|
223
|
+
: cmd.description;
|
|
224
|
+
lines.push(` /${cmd.name} — ${desc}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
lines.push("");
|
|
229
|
+
lines.push("Agent commands will appear after sending your first message.");
|
|
230
|
+
}
|
|
231
|
+
this.sendText(chatId, lines.join("\n")).catch(() => { });
|
|
232
|
+
}
|
|
204
233
|
/**
|
|
205
234
|
* Call this after `agent.prompt()` resolves (turn complete).
|
|
206
235
|
*
|
|
207
236
|
* Seals and flushes the last block, then waits for all pending sends/edits
|
|
208
237
|
* to complete before calling `onAfterTurnEnd`.
|
|
209
238
|
*/
|
|
210
|
-
async onTurnEnd(
|
|
211
|
-
const state = this.states.get(
|
|
239
|
+
async onTurnEnd(chatId) {
|
|
240
|
+
const state = this.states.get(chatId);
|
|
212
241
|
if (!state)
|
|
213
242
|
return;
|
|
214
243
|
if (state.flushTimer) {
|
|
@@ -220,33 +249,31 @@ export class BlockRenderer {
|
|
|
220
249
|
last.sealed = true;
|
|
221
250
|
this.enqueueFlush(state, last);
|
|
222
251
|
}
|
|
223
|
-
// Wait for the entire chain to drain before cleanup
|
|
224
252
|
await state.sendChain;
|
|
225
|
-
this.states.delete(
|
|
226
|
-
await this.onAfterTurnEnd(
|
|
253
|
+
this.states.delete(chatId);
|
|
254
|
+
await this.onAfterTurnEnd(chatId);
|
|
227
255
|
}
|
|
228
256
|
/**
|
|
229
257
|
* Call this when `agent.prompt()` throws (turn error).
|
|
230
258
|
*
|
|
231
|
-
* Discards pending state and calls `onAfterTurnError
|
|
232
|
-
* send an error message to the user.
|
|
259
|
+
* Discards pending state and calls `onAfterTurnError`.
|
|
233
260
|
*/
|
|
234
|
-
async onTurnError(
|
|
235
|
-
const state = this.states.get(
|
|
261
|
+
async onTurnError(chatId, error) {
|
|
262
|
+
const state = this.states.get(chatId);
|
|
236
263
|
if (state?.flushTimer)
|
|
237
264
|
clearTimeout(state.flushTimer);
|
|
238
|
-
this.states.delete(
|
|
239
|
-
await this.onAfterTurnError(
|
|
265
|
+
this.states.delete(chatId);
|
|
266
|
+
await this.onAfterTurnError(chatId, error);
|
|
240
267
|
}
|
|
241
268
|
// ---------------------------------------------------------------------------
|
|
242
269
|
// Internal — block management
|
|
243
270
|
// ---------------------------------------------------------------------------
|
|
244
|
-
appendToBlock(
|
|
245
|
-
let state = this.states.get(
|
|
271
|
+
appendToBlock(chatId, kind, delta) {
|
|
272
|
+
let state = this.states.get(chatId);
|
|
246
273
|
if (!state) {
|
|
247
274
|
// Auto-create state if onPromptSent wasn't called (e.g. host-initiated turns)
|
|
248
275
|
state = { blocks: [], flushTimer: null, lastEditMs: 0, sendChain: Promise.resolve() };
|
|
249
|
-
this.states.set(
|
|
276
|
+
this.states.set(chatId, state);
|
|
250
277
|
}
|
|
251
278
|
const last = state.blocks.at(-1);
|
|
252
279
|
if (last && !last.sealed && last.kind === kind) {
|
|
@@ -264,30 +291,27 @@ export class BlockRenderer {
|
|
|
264
291
|
}
|
|
265
292
|
this.enqueueFlush(state, last);
|
|
266
293
|
}
|
|
267
|
-
state.blocks.push({
|
|
294
|
+
state.blocks.push({ chatId, kind, content: delta, ref: null, creating: false, sealed: false });
|
|
268
295
|
}
|
|
269
|
-
this.scheduleFlush(
|
|
296
|
+
this.scheduleFlush(chatId, state);
|
|
270
297
|
}
|
|
271
|
-
scheduleFlush(
|
|
298
|
+
scheduleFlush(chatId, state) {
|
|
272
299
|
if (state.flushTimer)
|
|
273
300
|
return; // already scheduled
|
|
274
301
|
state.flushTimer = setTimeout(() => {
|
|
275
302
|
state.flushTimer = null;
|
|
276
|
-
this.flush(
|
|
303
|
+
this.flush(chatId, state);
|
|
277
304
|
}, this.flushIntervalMs);
|
|
278
305
|
}
|
|
279
|
-
flush(
|
|
306
|
+
flush(chatId, state) {
|
|
280
307
|
const block = state.blocks.at(-1);
|
|
281
308
|
if (!block || block.sealed || !block.content)
|
|
282
309
|
return;
|
|
283
|
-
// Send-only mode:
|
|
284
|
-
//
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
|
|
288
|
-
// boundary transitions inside `appendToBlock` (which seal the block
|
|
289
|
-
// first) will actually POST.
|
|
290
|
-
if (!this.editBlock) {
|
|
310
|
+
// Send-only mode (streaming=false): defer intermediate sends.
|
|
311
|
+
// Only sealed blocks (from onTurnEnd or block boundary transitions)
|
|
312
|
+
// will actually POST. This prevents the user seeing a partial chunk
|
|
313
|
+
// followed by the full message as two separate messages.
|
|
314
|
+
if (!this.streaming) {
|
|
291
315
|
return;
|
|
292
316
|
}
|
|
293
317
|
const now = Date.now();
|
|
@@ -297,7 +321,7 @@ export class BlockRenderer {
|
|
|
297
321
|
if (!state.flushTimer) {
|
|
298
322
|
state.flushTimer = setTimeout(() => {
|
|
299
323
|
state.flushTimer = null;
|
|
300
|
-
this.flush(
|
|
324
|
+
this.flush(chatId, state);
|
|
301
325
|
}, delay);
|
|
302
326
|
}
|
|
303
327
|
return;
|
|
@@ -317,13 +341,13 @@ export class BlockRenderer {
|
|
|
317
341
|
if (block.ref === null && !block.creating) {
|
|
318
342
|
// First send — use sentinel to prevent concurrent creates
|
|
319
343
|
block.creating = true;
|
|
320
|
-
block.ref = await this.sendBlock(block.
|
|
344
|
+
block.ref = await this.sendBlock(block.chatId, block.kind, content);
|
|
321
345
|
block.creating = false;
|
|
322
346
|
state.lastEditMs = Date.now();
|
|
323
347
|
}
|
|
324
|
-
else if (block.ref !== null && !block.creating && this.editBlock) {
|
|
325
|
-
// Subsequent update — edit in-place
|
|
326
|
-
await this.editBlock(block.
|
|
348
|
+
else if (block.ref !== null && !block.creating && this.streaming && this.editBlock) {
|
|
349
|
+
// Subsequent update — edit in-place (streaming mode only)
|
|
350
|
+
await this.editBlock(block.chatId, block.ref, block.kind, content, block.sealed);
|
|
327
351
|
state.lastEditMs = Date.now();
|
|
328
352
|
}
|
|
329
353
|
// else: create is in-flight (creating === true) — skip
|
package/dist/renderer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAqEH,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,yBAAyB,GAAG,GAAG,CAAC;AACtC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAE1C,8EAA8E;AAC9E,gBAAgB;AAChB,8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AA0D;gBAC1D,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBACjF,KAAK,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YAChC,CAAC;YACD,uDAAuD;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,CAAC;IACH,CAAC;CACF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ export interface PluginManifest {
|
|
|
29
29
|
configSchema?: Record<string, unknown>;
|
|
30
30
|
capabilities?: PluginCapabilities;
|
|
31
31
|
}
|
|
32
|
+
/** A command entry from the host's command list. */
|
|
33
|
+
export interface CommandEntry {
|
|
34
|
+
name: string;
|
|
35
|
+
description: string;
|
|
36
|
+
args?: string;
|
|
37
|
+
aliases?: string[];
|
|
38
|
+
}
|
|
32
39
|
/** The three kinds of content blocks a plugin renders. */
|
|
33
40
|
export type BlockKind = "text" | "thinking" | "tool";
|
|
34
41
|
export interface VerboseConfig {
|
|
@@ -38,6 +45,18 @@ export interface VerboseConfig {
|
|
|
38
45
|
showToolUse: boolean;
|
|
39
46
|
}
|
|
40
47
|
export interface BlockRendererOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Whether the IM platform supports message editing (streaming mode).
|
|
50
|
+
*
|
|
51
|
+
* - `true` (default): blocks stream in real-time — `sendBlock()` creates
|
|
52
|
+
* the message, `editBlock()` updates it as more content arrives.
|
|
53
|
+
* - `false`: each block is held until complete, then sent once via
|
|
54
|
+
* `sendBlock()`. `editBlock()` is never called.
|
|
55
|
+
*
|
|
56
|
+
* Set to `false` for platforms that don't support editing sent messages
|
|
57
|
+
* (e.g. QQ Bot, WhatsApp, WeChat, LINE).
|
|
58
|
+
*/
|
|
59
|
+
streaming?: boolean;
|
|
41
60
|
/**
|
|
42
61
|
* Debounce interval before flushing an unsealed block (ms).
|
|
43
62
|
* Controls how often in-progress blocks are sent to the platform.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,YAAY,EACZ,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,kBAAkB;IACjC,mDAAmD;IACnD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8DAA8D;IAC9D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,uDAAuD;IACvD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,8CAA8C;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC/B;AAED,uDAAuD;AACvD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAMD,0DAA0D;AAC1D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,YAAY,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,e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AAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAMD,0DAA0D;AAC1D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,4DAA4D;IAC5D,YAAY,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibearound/plugin-channel-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "VibeAround Plugin SDK — base classes and utilities for building channel plugins",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
".": {
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"types": "./dist/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./advanced": {
|
|
19
|
+
"import": "./dist/advanced.js",
|
|
20
|
+
"types": "./dist/advanced.d.ts"
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"scripts": {
|
package/src/advanced.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vibearound/plugin-channel-sdk — Advanced / low-level API
|
|
3
|
+
*
|
|
4
|
+
* For plugins that need custom ACP lifecycle control instead of
|
|
5
|
+
* the standard `runChannelPlugin()` flow.
|
|
6
|
+
*
|
|
7
|
+
* Normal plugins should use the main entry point instead:
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { runChannelPlugin, BlockRenderer } from "@vibearound/plugin-channel-sdk";
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Low-level ACP connection
|
|
14
|
+
export { connectToHost, stripExtPrefix, redirectConsoleToStderr } from "./connection.js";
|
|
15
|
+
export type { PluginInfo, ConnectResult, AgentInfo } from "./connection.js";
|
|
16
|
+
|
|
17
|
+
// All types (including internal ones)
|
|
18
|
+
export type {
|
|
19
|
+
Agent,
|
|
20
|
+
Client,
|
|
21
|
+
ContentBlock,
|
|
22
|
+
SessionNotification,
|
|
23
|
+
RequestPermissionRequest,
|
|
24
|
+
RequestPermissionResponse,
|
|
25
|
+
BlockKind,
|
|
26
|
+
VerboseConfig,
|
|
27
|
+
BlockRendererOptions,
|
|
28
|
+
PluginCapabilities,
|
|
29
|
+
PluginManifest,
|
|
30
|
+
PluginInitMeta,
|
|
31
|
+
} from "./types.js";
|
|
32
|
+
|
|
33
|
+
// Re-export high-level API too (so advanced users don't need two imports)
|
|
34
|
+
export { runChannelPlugin } from "./plugin.js";
|
|
35
|
+
export { BlockRenderer } from "./renderer.js";
|
|
36
|
+
export { extractErrorMessage } from "./errors.js";
|
|
37
|
+
export type {
|
|
38
|
+
ChannelBot,
|
|
39
|
+
ChannelPluginLogger,
|
|
40
|
+
CreateBotContext,
|
|
41
|
+
RunChannelPluginSpec,
|
|
42
|
+
VerboseOptions,
|
|
43
|
+
} from "./plugin.js";
|
package/src/connection.ts
CHANGED
|
@@ -111,12 +111,18 @@ export async function connectToHost(
|
|
|
111
111
|
// ---------------------------------------------------------------------------
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
114
|
+
* Strip the `_` prefix from ACP extension method names.
|
|
115
115
|
*
|
|
116
|
-
* The ACP SDK
|
|
117
|
-
*
|
|
116
|
+
* The Rust ACP SDK adds `_` when sending ext notifications on the wire,
|
|
117
|
+
* but the TypeScript ACP SDK does not strip it on receipt. This function
|
|
118
|
+
* normalizes the received method name so handlers can match the canonical
|
|
119
|
+
* name (e.g. `_va/system_text` → `va/system_text`).
|
|
120
|
+
*
|
|
121
|
+
* Note: when sending ext notifications FROM TypeScript TO the Rust host,
|
|
122
|
+
* the method name must include the `_` prefix manually (e.g. `_va/callback`)
|
|
123
|
+
* because the TypeScript SDK does not add it automatically.
|
|
118
124
|
*/
|
|
119
|
-
export function
|
|
125
|
+
export function stripExtPrefix(method: string): string {
|
|
120
126
|
return method.startsWith("_") ? method.slice(1) : method;
|
|
121
127
|
}
|
|
122
128
|
|