@xmoxmo/bncr 0.5.3 → 0.5.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
|
@@ -17,6 +17,7 @@ export type BncrStructuredContextFactsInput = {
|
|
|
17
17
|
reply: {
|
|
18
18
|
to: string;
|
|
19
19
|
originatingTo: string;
|
|
20
|
+
rawTo?: string;
|
|
20
21
|
};
|
|
21
22
|
sender: {
|
|
22
23
|
id: string;
|
|
@@ -125,6 +126,7 @@ export function buildBncrStructuredContextFacts(input: BncrStructuredContextFact
|
|
|
125
126
|
reply: {
|
|
126
127
|
to: input.reply.to,
|
|
127
128
|
originatingTo: input.reply.originatingTo,
|
|
129
|
+
...(input.reply.rawTo ? { rawTo: input.reply.rawTo } : {}),
|
|
128
130
|
},
|
|
129
131
|
sender: {
|
|
130
132
|
id: input.sender.id,
|
|
@@ -200,6 +202,7 @@ export function buildBncrPromptVisibleContextFacts(
|
|
|
200
202
|
reply?: {
|
|
201
203
|
to: string;
|
|
202
204
|
originatingTo: string;
|
|
205
|
+
rawTo?: string;
|
|
203
206
|
};
|
|
204
207
|
media?: Array<{
|
|
205
208
|
path?: string;
|
|
@@ -249,10 +252,11 @@ export function buildBncrPromptVisibleContextFacts(
|
|
|
249
252
|
};
|
|
250
253
|
}
|
|
251
254
|
|
|
252
|
-
if (facts.reply.originatingTo !== facts.reply.to) {
|
|
255
|
+
if (facts.reply.originatingTo !== facts.reply.to || facts.reply.rawTo) {
|
|
253
256
|
result.reply = {
|
|
254
257
|
to: facts.reply.to,
|
|
255
258
|
originatingTo: facts.reply.originatingTo,
|
|
259
|
+
...(facts.reply.rawTo ? { rawTo: facts.reply.rawTo } : {}),
|
|
256
260
|
};
|
|
257
261
|
}
|
|
258
262
|
|
|
@@ -268,7 +272,6 @@ export function buildBncrPromptVisibleContextFacts(
|
|
|
268
272
|
return Object.values(payload).some((field) => field !== undefined) ? [payload] : [];
|
|
269
273
|
});
|
|
270
274
|
}
|
|
271
|
-
|
|
272
275
|
if (facts.pendingMediaContext?.length) {
|
|
273
276
|
result.pendingMediaContext = facts.pendingMediaContext.flatMap((entry) => {
|
|
274
277
|
const media = (entry.media || []).flatMap((item) => {
|
|
@@ -331,6 +334,7 @@ export type BncrStructuredContextFactsFromInboundPartsInput = {
|
|
|
331
334
|
resolution: {
|
|
332
335
|
chatType: string;
|
|
333
336
|
canonicalTo: string;
|
|
337
|
+
rawTo: string;
|
|
334
338
|
originatingTo: string;
|
|
335
339
|
resolvedRoute: {
|
|
336
340
|
agentId?: string;
|
|
@@ -354,7 +358,7 @@ export type BncrStructuredContextFactsFromInboundPartsInput = {
|
|
|
354
358
|
bridgeSenderName?: string;
|
|
355
359
|
senderIsOwner?: boolean;
|
|
356
360
|
senderIsAuthorized?: boolean;
|
|
357
|
-
|
|
361
|
+
pendingHistoryContext?: Array<{
|
|
358
362
|
messageId?: string;
|
|
359
363
|
sender?: string;
|
|
360
364
|
senderId?: string;
|
|
@@ -367,11 +371,13 @@ export type BncrStructuredContextFactsFromInboundPartsInput = {
|
|
|
367
371
|
}>;
|
|
368
372
|
}>;
|
|
369
373
|
};
|
|
370
|
-
|
|
371
374
|
export function buildBncrStructuredContextFactsFromInboundParts(
|
|
372
375
|
input: BncrStructuredContextFactsFromInboundPartsInput,
|
|
373
376
|
) {
|
|
374
377
|
const mediaItems = Array.isArray(input.prepared.mediaItems) ? input.prepared.mediaItems : [];
|
|
378
|
+
const pendingHistoryContext = Array.isArray(input.pendingHistoryContext)
|
|
379
|
+
? input.pendingHistoryContext
|
|
380
|
+
: [];
|
|
375
381
|
return buildBncrStructuredContextFacts({
|
|
376
382
|
channelId: input.channelId,
|
|
377
383
|
accountId: input.parsed.accountId,
|
|
@@ -389,6 +395,7 @@ export function buildBncrStructuredContextFactsFromInboundParts(
|
|
|
389
395
|
reply: {
|
|
390
396
|
to: input.resolution.canonicalTo,
|
|
391
397
|
originatingTo: input.resolution.originatingTo,
|
|
398
|
+
rawTo: input.resolution.rawTo,
|
|
392
399
|
},
|
|
393
400
|
sender: {
|
|
394
401
|
id: input.senderIdForContext,
|
|
@@ -428,6 +435,6 @@ export function buildBncrStructuredContextFactsFromInboundParts(
|
|
|
428
435
|
kind: item.kind || inferBncrStructuredMediaKind(item.contentType),
|
|
429
436
|
messageId: input.parsed.msgId,
|
|
430
437
|
})),
|
|
431
|
-
pendingMediaContext:
|
|
438
|
+
pendingMediaContext: pendingHistoryContext,
|
|
432
439
|
});
|
|
433
440
|
}
|
|
@@ -48,6 +48,7 @@ export type BncrInboundReplyRouteFact = {
|
|
|
48
48
|
sessionKey: string;
|
|
49
49
|
route: ParsedInbound['route'];
|
|
50
50
|
canonicalTo: string;
|
|
51
|
+
rawTo: string;
|
|
51
52
|
originatingTo: string;
|
|
52
53
|
chatType: 'direct' | 'group';
|
|
53
54
|
};
|
|
@@ -270,7 +271,7 @@ export function resolveBncrInboundConversation(args: {
|
|
|
270
271
|
const dispatchSessionKey = taskSessionKey || baseSessionKey;
|
|
271
272
|
const rawTo = formatRawBncrInboundTarget(route);
|
|
272
273
|
const canonicalTo = formatDisplayScope(route);
|
|
273
|
-
const originatingTo = providedOriginatingTo ||
|
|
274
|
+
const originatingTo = providedOriginatingTo || canonicalTo;
|
|
274
275
|
|
|
275
276
|
return {
|
|
276
277
|
accountId,
|
|
@@ -419,6 +420,7 @@ export function buildBncrInboundReplyRouteFact(
|
|
|
419
420
|
sessionKey: resolution.dispatchSessionKey,
|
|
420
421
|
route: resolution.route,
|
|
421
422
|
canonicalTo: resolution.canonicalTo,
|
|
423
|
+
rawTo: resolution.rawTo,
|
|
422
424
|
originatingTo: resolution.originatingTo,
|
|
423
425
|
chatType: resolution.chatType,
|
|
424
426
|
};
|
|
@@ -226,7 +226,10 @@ export function buildBncrGroupContextFromEntries(args: {
|
|
|
226
226
|
.map((entry) =>
|
|
227
227
|
formatOpenClawAgentEnvelope(args.api, {
|
|
228
228
|
channel: 'Bncr',
|
|
229
|
-
from:
|
|
229
|
+
from:
|
|
230
|
+
(entry.senderId
|
|
231
|
+
? `${entry.sender} (${entry.senderId})`
|
|
232
|
+
: entry.sender || args.channelLabel) + (entry.messageId ? ` #${entry.messageId}` : ''),
|
|
230
233
|
timestamp: entry.timestamp || args.currentTimestamp,
|
|
231
234
|
previousTimestamp: args.previousTimestamp,
|
|
232
235
|
envelope: args.envelope,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HistoryMediaEntry } from 'openclaw/plugin-sdk/reply-history';
|
|
1
2
|
import { readBncrSessionUpdatedAt } from '../../openclaw/inbound-session-runtime.ts';
|
|
2
3
|
import {
|
|
3
4
|
formatOpenClawAgentEnvelope,
|
|
@@ -125,6 +126,20 @@ export function buildBncrInboundTurnContext(args: {
|
|
|
125
126
|
const pendingHistoryMedia = shouldDispatch
|
|
126
127
|
? collectBncrHistoryMediaFromEntries({ entries: pendingHistoryEntries })
|
|
127
128
|
: [];
|
|
129
|
+
const pendingHistoryContext = shouldDispatch
|
|
130
|
+
? pendingHistoryEntries.map((entry) => ({
|
|
131
|
+
messageId: entry.messageId,
|
|
132
|
+
sender: entry.sender,
|
|
133
|
+
senderId: entry.senderId,
|
|
134
|
+
body: entry.body,
|
|
135
|
+
media: (entry.media || []).map((item: HistoryMediaEntry) => ({
|
|
136
|
+
path: item.path,
|
|
137
|
+
contentType: item.contentType,
|
|
138
|
+
kind: item.kind,
|
|
139
|
+
messageId: item.messageId,
|
|
140
|
+
})),
|
|
141
|
+
}))
|
|
142
|
+
: [];
|
|
128
143
|
const structuredContextFacts = buildBncrStructuredContextFactsFromInboundParts({
|
|
129
144
|
channelId,
|
|
130
145
|
parsed,
|
|
@@ -140,6 +155,7 @@ export function buildBncrInboundTurnContext(args: {
|
|
|
140
155
|
bridgeSenderName,
|
|
141
156
|
senderIsOwner,
|
|
142
157
|
senderIsAuthorized,
|
|
158
|
+
pendingHistoryContext,
|
|
143
159
|
});
|
|
144
160
|
const promptVisibleContextFacts = buildBncrPromptVisibleContextFacts(structuredContextFacts);
|
|
145
161
|
const supplementalUntrustedContext = [
|
|
@@ -220,6 +236,7 @@ export function buildBncrInboundTurnContext(args: {
|
|
|
220
236
|
reply: {
|
|
221
237
|
to: resolution.canonicalTo,
|
|
222
238
|
originatingTo: resolution.originatingTo,
|
|
239
|
+
rawTo: resolution.rawTo,
|
|
223
240
|
},
|
|
224
241
|
message: {
|
|
225
242
|
inboundEventKind: 'user_request',
|