@xmoxmo/bncr 0.6.1 → 0.6.3

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.
Files changed (31) hide show
  1. package/README.md +65 -1
  2. package/package.json +1 -1
  3. package/scripts/check-pack.mjs +4 -1
  4. package/scripts/selfcheck.mjs +4 -1
  5. package/src/channel.ts +144 -5
  6. package/src/messaging/inbound/commands.ts +62 -26
  7. package/src/messaging/inbound/context-facts.ts +88 -58
  8. package/src/messaging/inbound/conversation-history-serial.ts +258 -0
  9. package/src/messaging/inbound/conversation-history.ts +450 -0
  10. package/src/messaging/inbound/dispatch.ts +568 -123
  11. package/src/messaging/inbound/history-shard-worker.ts +180 -0
  12. package/src/messaging/inbound/native-command.ts +89 -33
  13. package/src/messaging/inbound/outbound-replay-cache.ts +202 -17
  14. package/src/messaging/inbound/reply-dispatch.ts +7 -6
  15. package/src/messaging/inbound/scene-admin.ts +40 -20
  16. package/src/messaging/inbound/turn-context.ts +101 -37
  17. package/src/plugin/bridge-lifecycle.ts +8 -0
  18. package/src/plugin/bridge-outbox-facade.ts +15 -1
  19. package/src/plugin/channel-components.ts +5 -5
  20. package/src/plugin/channel-runtime-builders-delivery.ts +2 -2
  21. package/src/plugin/channel-runtime-constants.ts +2 -0
  22. package/src/plugin/channel-runtime-types.ts +9 -7
  23. package/src/plugin/inbound-acceptance.ts +9 -24
  24. package/src/plugin/inbound-handlers.ts +4 -4
  25. package/src/plugin/inbound-surface-handlers-group.ts +4 -2
  26. package/src/plugin/outbox-drain-post-push.ts +3 -0
  27. package/src/plugin/scene-registry.ts +4 -4
  28. package/src/plugin/sqlite-state.ts +2109 -0
  29. package/src/plugin/state-store.ts +731 -69
  30. package/src/plugin/state-transient-runtime-group.ts +17 -3
  31. package/src/messaging/inbound/group-history.ts +0 -264
@@ -1,7 +1,7 @@
1
1
  import type { GatewayRequestHandlerOptions } from 'openclaw/plugin-sdk/core';
2
2
  import { buildCanonicalBncrSessionKey } from '../core/targets.ts';
3
3
  import type { BncrConnection, BncrRoute } from '../core/types.ts';
4
- import type { BncrGroupHistoryMap } from '../messaging/inbound/group-history.ts';
4
+ import type { BncrConversationHistoryMap } from '../messaging/inbound/conversation-history.ts';
5
5
  import type { BncrOutboundReplayCache } from '../messaging/inbound/outbound-replay-cache.ts';
6
6
  import type { parseBncrInboundParams } from '../messaging/inbound/parse.ts';
7
7
  import type { ReplyPayloadInput } from '../messaging/outbound/reply-enqueue.ts';
@@ -134,7 +134,7 @@ export type BncrInboundHandlersRuntime = {
134
134
  }) => string;
135
135
  defaultPublicAgentId: () => string;
136
136
  sceneRegistry: Map<string, BncrSceneRecord>;
137
- groupHistories: BncrGroupHistoryMap;
137
+ conversationHistories: BncrConversationHistoryMap;
138
138
  outboundReplayCache: BncrOutboundReplayCache;
139
139
  prepareInboundAcceptance: (args: {
140
140
  parsed: ParsedInboundParams;
@@ -165,7 +165,7 @@ export type BncrInboundHandlersRuntime = {
165
165
  shouldDispatch: boolean;
166
166
  shouldAccumulate: boolean;
167
167
  sceneRegistry: Map<string, BncrSceneRecord>;
168
- groupHistories: BncrGroupHistoryMap;
168
+ conversationHistories: BncrConversationHistoryMap;
169
169
  outboundReplayCache: BncrOutboundReplayCache;
170
170
  defaultAdminAgentId: string;
171
171
  defaultPublicAgentId: string;
@@ -335,7 +335,7 @@ export function createBncrInboundHandlers(runtime: Omit<BncrInboundHandlersRunti
335
335
  shouldDispatch,
336
336
  shouldAccumulate,
337
337
  sceneRegistry: runtime.sceneRegistry,
338
- groupHistories: runtime.groupHistories,
338
+ conversationHistories: runtime.conversationHistories,
339
339
  outboundReplayCache: runtime.outboundReplayCache,
340
340
  defaultAdminAgentId,
341
341
  defaultPublicAgentId: runtime.defaultPublicAgentId(),
@@ -86,7 +86,9 @@ export function createBncrInboundSurfaceHandlersGroup(runtime: {
86
86
  typeof createBncrInboundHandlersComponent
87
87
  >[0]['defaultPublicAgentId'];
88
88
  sceneRegistry: Parameters<typeof createBncrInboundHandlersComponent>[0]['sceneRegistry'];
89
- groupHistories: Parameters<typeof createBncrInboundHandlersComponent>[0]['groupHistories'];
89
+ conversationHistories: Parameters<
90
+ typeof createBncrInboundHandlersComponent
91
+ >[0]['conversationHistories'];
90
92
  outboundReplayCache: BncrOutboundReplayCache;
91
93
  prepareInboundAcceptance: Parameters<
92
94
  typeof createBncrInboundHandlersComponent
@@ -153,7 +155,7 @@ export function createBncrInboundSurfaceHandlersGroup(runtime: {
153
155
  defaultAdminAgentId: runtime.defaultAdminAgentId,
154
156
  defaultPublicAgentId: runtime.defaultPublicAgentId,
155
157
  sceneRegistry: runtime.sceneRegistry,
156
- groupHistories: runtime.groupHistories,
158
+ conversationHistories: runtime.conversationHistories,
157
159
  outboundReplayCache: runtime.outboundReplayCache,
158
160
  prepareInboundAcceptance: runtime.prepareInboundAcceptance,
159
161
  logInboundSummary: runtime.logInboundSummary,
@@ -95,6 +95,9 @@ export function createBncrOutboxDrainPostPush(runtime: BncrOutboxDrainPostPushRu
95
95
  ackTimeoutMs,
96
96
  });
97
97
 
98
+ if (!requireAck && onlineNow) {
99
+ runtime.outbox.delete(entry.messageId);
100
+ }
98
101
  if (!runtime.outbox.has(entry.messageId)) {
99
102
  await runtime.sleepMs(runtime.pushDrainIntervalMs);
100
103
  return { action: 'continue', localNextDelay };
@@ -56,8 +56,8 @@ function buildSceneRecord(args: {
56
56
  ...(kind === 'group' && parsed.groupName ? { groupName: parsed.groupName } : {}),
57
57
  ...(agentId ? { agentId } : {}),
58
58
  ...(kind === 'group' ? { groupReplyMode: defaultGroupReplyMode(kind) } : {}),
59
- ...(kind === 'group' ? { historyLimit: 50 } : {}),
60
- ...(kind === 'group' ? { historyForce: true } : {}),
59
+ historyLimit: 50,
60
+ historyForce: true,
61
61
  lastSeenAt,
62
62
  };
63
63
  }
@@ -90,8 +90,8 @@ export function decideSceneAdmission(args: {
90
90
  ...(kind === 'group' && !existing.groupReplyMode
91
91
  ? { groupReplyMode: defaultGroupReplyMode(kind) }
92
92
  : {}),
93
- ...(kind === 'group' && existing.historyLimit === undefined ? { historyLimit: 50 } : {}),
94
- ...(kind === 'group' && existing.historyForce === undefined ? { historyForce: true } : {}),
93
+ ...(existing.historyLimit === undefined ? { historyLimit: 50 } : {}),
94
+ ...(existing.historyForce === undefined ? { historyForce: true } : {}),
95
95
  lastSeenAt: now,
96
96
  } satisfies BncrSceneRecord;
97
97