@xmoxmo/bncr 0.1.4 → 0.1.5
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/package.json
CHANGED
|
@@ -31,6 +31,12 @@ export const BncrConfigSchema = {
|
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
+
allowTool: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
default: false,
|
|
37
|
+
description:
|
|
38
|
+
'Allow tool messages to be forwarded when streaming is enabled. Defaults to false; only explicit true enables forwarding. When enabled, bncr also requests upstream tool summaries/results.',
|
|
39
|
+
},
|
|
34
40
|
requireMention: {
|
|
35
41
|
type: 'boolean',
|
|
36
42
|
default: false,
|
|
@@ -135,6 +135,12 @@ export async function handleBncrNativeCommand(params: {
|
|
|
135
135
|
info?: { kind?: 'tool' | 'block' | 'final' },
|
|
136
136
|
) => {
|
|
137
137
|
const kind = info?.kind;
|
|
138
|
+
const shouldForwardTool = effectiveReply.blockStreaming && effectiveReply.allowTool;
|
|
139
|
+
|
|
140
|
+
if (kind === 'tool' && !shouldForwardTool) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
138
144
|
const hasPayload = Boolean(
|
|
139
145
|
payload?.text ||
|
|
140
146
|
payload?.mediaUrl ||
|
|
@@ -155,6 +161,7 @@ export async function handleBncrNativeCommand(params: {
|
|
|
155
161
|
},
|
|
156
162
|
replyOptions: {
|
|
157
163
|
disableBlockStreaming: !effectiveReply.blockStreaming,
|
|
164
|
+
shouldEmitToolResult: effectiveReply.allowTool ? () => true : undefined,
|
|
158
165
|
},
|
|
159
166
|
});
|
|
160
167
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import {
|
|
3
2
|
formatDisplayScope,
|
|
4
3
|
normalizeInboundSessionKey,
|
|
@@ -191,6 +190,11 @@ export async function dispatchBncrInbound(params: {
|
|
|
191
190
|
info?: { kind?: 'tool' | 'block' | 'final' },
|
|
192
191
|
) => {
|
|
193
192
|
const kind = info?.kind;
|
|
193
|
+
const shouldForwardTool = effectiveReply.blockStreaming && effectiveReply.allowTool;
|
|
194
|
+
|
|
195
|
+
if (kind === 'tool' && !shouldForwardTool) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
194
198
|
|
|
195
199
|
await enqueueFromReply({
|
|
196
200
|
accountId,
|
|
@@ -208,6 +212,7 @@ export async function dispatchBncrInbound(params: {
|
|
|
208
212
|
},
|
|
209
213
|
replyOptions: {
|
|
210
214
|
disableBlockStreaming: !effectiveReply.blockStreaming,
|
|
215
|
+
shouldEmitToolResult: effectiveReply.allowTool ? () => true : undefined,
|
|
211
216
|
},
|
|
212
217
|
});
|
|
213
218
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
type BncrReplyConfigResult = {
|
|
2
2
|
blockStreaming: boolean;
|
|
3
|
+
allowTool: boolean;
|
|
3
4
|
replyCfg: any;
|
|
4
5
|
};
|
|
5
6
|
|
|
@@ -29,8 +30,13 @@ export function resolveBncrBlockStreaming(cfg: any): boolean {
|
|
|
29
30
|
return true;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
export function resolveBncrAllowTool(cfg: any): boolean {
|
|
34
|
+
return cfg?.channels?.bncr?.allowTool === true;
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
export function buildBncrReplyConfig(cfg: any): BncrReplyConfigResult {
|
|
33
38
|
const blockStreaming = resolveBncrBlockStreaming(cfg);
|
|
39
|
+
const allowTool = resolveBncrAllowTool(cfg);
|
|
34
40
|
|
|
35
41
|
const replyCfg = {
|
|
36
42
|
...cfg,
|
|
@@ -46,5 +52,12 @@ export function buildBncrReplyConfig(cfg: any): BncrReplyConfigResult {
|
|
|
46
52
|
replyCfg.agents.defaults.blockStreamingBreak = 'message_end';
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
if (replyCfg.agents.defaults.blockStreamingChunk == null) {
|
|
56
|
+
replyCfg.agents.defaults.blockStreamingChunk = {
|
|
57
|
+
minChars: 500,
|
|
58
|
+
maxChars: 4096,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return { blockStreaming, allowTool, replyCfg };
|
|
50
63
|
}
|