@xmoxmo/bncr 0.6.2 → 0.6.4
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 +65 -1
- package/package.json +1 -1
- package/scripts/check-pack.mjs +3 -0
- package/scripts/selfcheck.mjs +3 -0
- package/src/channel.ts +134 -7
- package/src/messaging/inbound/commands.ts +62 -26
- package/src/messaging/inbound/conversation-history-serial.ts +258 -0
- package/src/messaging/inbound/conversation-history.ts +174 -60
- package/src/messaging/inbound/dispatch.ts +557 -137
- package/src/messaging/inbound/history-shard-worker.ts +180 -0
- package/src/messaging/inbound/native-command.ts +89 -33
- package/src/messaging/inbound/outbound-replay-cache.ts +128 -19
- package/src/messaging/inbound/reply-dispatch.ts +7 -6
- package/src/messaging/inbound/scene-admin.ts +17 -12
- package/src/messaging/inbound/turn-context.ts +2 -9
- package/src/plugin/bridge-lifecycle.ts +8 -0
- package/src/plugin/bridge-outbox-facade.ts +6 -1
- package/src/plugin/channel-runtime-constants.ts +2 -0
- package/src/plugin/outbox-drain-post-push.ts +3 -0
- package/src/plugin/sqlite-state.ts +2109 -0
- package/src/plugin/state-store.ts +704 -46
- package/src/plugin/state-transient-runtime-group.ts +14 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
1
3
|
import type { RegisterDriftSnapshot } from '../core/register-trace.ts';
|
|
2
4
|
import type {
|
|
3
5
|
BncrConnection,
|
|
@@ -17,6 +19,13 @@ import { createBncrTransientStateRuntime } from './transient-state-runtime.ts';
|
|
|
17
19
|
type StoredRouteRecord = { accountId: string; route: BncrRoute; updatedAt: number };
|
|
18
20
|
type StoredLastSessionRecord = { sessionKey: string; scope: string; updatedAt: number };
|
|
19
21
|
|
|
22
|
+
export function shouldEnableBncrSqliteState(statePath: string | null): boolean {
|
|
23
|
+
if (!statePath) return false;
|
|
24
|
+
if (process.env.BNCR_SQLITE_STORE === '0') return false;
|
|
25
|
+
if (process.env.BNCR_SQLITE_STORE === '1') return true;
|
|
26
|
+
return existsSync(path.join(path.dirname(statePath), 'bncr.sqlite3'));
|
|
27
|
+
}
|
|
28
|
+
|
|
20
29
|
export function createBncrStateTransientRuntimeGroup(runtime: {
|
|
21
30
|
bridgeId: string;
|
|
22
31
|
getStatePath: () => string | null;
|
|
@@ -92,6 +101,11 @@ export function createBncrStateTransientRuntimeGroup(runtime: {
|
|
|
92
101
|
lastOutboundByAccount: runtime.lastOutboundByAccount,
|
|
93
102
|
getLastDriftSnapshot: runtime.getLastDriftSnapshot,
|
|
94
103
|
setLastDriftSnapshot: runtime.setLastDriftSnapshot,
|
|
104
|
+
createSqliteState: async (statePath) => {
|
|
105
|
+
if (!statePath || !shouldEnableBncrSqliteState(statePath)) return null;
|
|
106
|
+
const { createBncrSqliteStateDatabase } = await import('./sqlite-state.ts');
|
|
107
|
+
return createBncrSqliteStateDatabase(path.join(path.dirname(statePath), 'bncr.sqlite3'));
|
|
108
|
+
},
|
|
95
109
|
});
|
|
96
110
|
|
|
97
111
|
const transientStateRuntime = createBncrTransientStateRuntime({
|