@xmoxmo/bncr 0.5.6 → 0.5.8

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 (90) hide show
  1. package/dist/index.js +1 -9
  2. package/index.ts +1 -9
  3. package/package.json +1 -1
  4. package/scripts/check-pack.mjs +0 -8
  5. package/scripts/selfcheck.mjs +0 -10
  6. package/src/bootstrap/runtime-loader.ts +1 -1
  7. package/src/channel.ts +118 -171
  8. package/src/core/accounts.ts +1 -6
  9. package/src/core/connection-reachability.ts +2 -6
  10. package/src/core/dead-letter-diagnostics.ts +4 -10
  11. package/src/core/logging.ts +1 -1
  12. package/src/core/outbox-entry-builders.ts +78 -84
  13. package/src/core/outbox-file-transfer-failure.ts +5 -0
  14. package/src/core/outbox-file-transfer-guards.ts +6 -0
  15. package/src/core/outbox-file-transfer-prep.ts +8 -5
  16. package/src/core/outbox-file-transfer-success.ts +5 -0
  17. package/src/core/outbox-queue.ts +1 -7
  18. package/src/core/outbox-summary.ts +10 -56
  19. package/src/core/permissions.ts +2 -10
  20. package/src/core/persisted-outbox-entry.ts +54 -11
  21. package/src/core/policy.ts +1 -11
  22. package/src/core/register-trace.ts +4 -7
  23. package/src/core/status-meta.ts +1 -9
  24. package/src/core/status.ts +1 -21
  25. package/src/core/targets.ts +52 -70
  26. package/src/core/types.ts +1 -17
  27. package/src/core/value-sanitize.ts +38 -1
  28. package/src/messaging/inbound/commands.ts +2 -24
  29. package/src/messaging/inbound/dispatch-prep.ts +1 -1
  30. package/src/messaging/inbound/gate.ts +2 -31
  31. package/src/messaging/inbound/group-history.ts +0 -75
  32. package/src/messaging/inbound/parse.ts +2 -32
  33. package/src/messaging/inbound/scene-admin.ts +8 -8
  34. package/src/messaging/outbound/diagnostics-debug-builders.ts +0 -15
  35. package/src/messaging/outbound/diagnostics.ts +1 -7
  36. package/src/messaging/outbound/durable-queue-adapter.ts +17 -11
  37. package/src/messaging/outbound/marker-parser.ts +277 -28
  38. package/src/messaging/outbound/media-dedupe.ts +3 -10
  39. package/src/messaging/outbound/media.ts +1 -6
  40. package/src/messaging/outbound/normalize-outbound-send.ts +329 -0
  41. package/src/messaging/outbound/queue-selectors.ts +1 -5
  42. package/src/messaging/outbound/reply-enqueue-media.ts +1 -184
  43. package/src/messaging/outbound/reply-enqueue.ts +313 -175
  44. package/src/messaging/outbound/session-route.ts +6 -11
  45. package/src/messaging/outbound/target-resolver.ts +1 -6
  46. package/src/openclaw/media-runtime.ts +1 -1
  47. package/src/openclaw/routing-runtime.ts +0 -11
  48. package/src/openclaw/sdk-helpers.ts +0 -2
  49. package/src/plugin/bridge-media-facade.ts +0 -4
  50. package/src/plugin/bridge-outbox-facade.ts +0 -1
  51. package/src/plugin/channel-components.ts +0 -13
  52. package/src/plugin/channel-plugin-surface-group.ts +52 -65
  53. package/src/plugin/channel-runtime-builders-delivery.ts +3 -362
  54. package/src/plugin/channel-runtime-builders-status.ts +0 -160
  55. package/src/plugin/channel-runtime-builders.ts +3 -17
  56. package/src/plugin/channel-runtime-constants.ts +1 -1
  57. package/src/plugin/channel-runtime-types.ts +2 -24
  58. package/src/plugin/channel-send.ts +206 -221
  59. package/src/plugin/channel-utils.ts +8 -29
  60. package/src/plugin/connection-handlers-helpers.ts +0 -15
  61. package/src/plugin/connection-handlers.ts +6 -5
  62. package/src/plugin/file-inbound-abort.ts +5 -0
  63. package/src/plugin/file-inbound-chunk.ts +5 -0
  64. package/src/plugin/file-inbound-complete.ts +5 -0
  65. package/src/plugin/file-transfer-orchestrator.ts +39 -2
  66. package/src/plugin/media-dedupe-runtime.ts +1 -6
  67. package/src/plugin/media-orchestrators-runtime-group.ts +20 -149
  68. package/src/plugin/message-send.ts +7 -8
  69. package/src/plugin/messaging.ts +3 -3
  70. package/src/plugin/outbound.ts +6 -26
  71. package/src/plugin/outbox-drain-loop.ts +2 -2
  72. package/src/plugin/outbox-push.ts +1 -52
  73. package/src/plugin/outbox-unified-push-flow.ts +307 -0
  74. package/src/plugin/scene-registry.ts +1 -1
  75. package/src/plugin/target-runtime.ts +1 -6
  76. package/src/runtime/log-dedupe.ts +3 -3
  77. package/src/runtime/outbound-ack-timeout.ts +3 -12
  78. package/src/runtime/outbox-transitions.ts +1 -4
  79. package/src/runtime/status-snapshots.ts +2 -2
  80. package/src/runtime/status-worker.ts +3 -15
  81. package/src/core/outbox-text-push-prep.ts +0 -36
  82. package/src/messaging/outbound/build-send-action.ts +0 -130
  83. package/src/messaging/outbound/durable-message-adapter.ts +0 -121
  84. package/src/messaging/outbound/send-params.ts +0 -114
  85. package/src/messaging/outbound/send.ts +0 -127
  86. package/src/openclaw/ingress-runtime.ts +0 -25
  87. package/src/plugin/bridge-file-transfer-push-facade.ts +0 -142
  88. package/src/plugin/channel-send-runtime-group.ts +0 -37
  89. package/src/plugin/outbox-file-push-flow.ts +0 -69
  90. package/src/plugin/outbox-text-push-flow.ts +0 -90
@@ -1,24 +1,17 @@
1
1
  import type { GatewayRequestHandlerOptions } from 'openclaw/plugin-sdk/core';
2
2
  import type { BncrExtendedDiagnostics } from '../core/extended-diagnostics.ts';
3
- import type { RegisterTraceSummary } from '../core/register-trace.ts';
4
3
  import type {
5
4
  BncrAccountRuntimeSnapshot,
6
5
  buildIntegratedDiagnostics as buildIntegratedDiagnosticsFromRuntime,
7
6
  } from '../core/status.ts';
8
7
  import type {
9
- BncrAckObservability,
10
- BncrConnection,
11
8
  BncrDeadLetterDiagnosticsSummary,
12
- BncrDiagnosticsSummary,
13
9
  BncrDownlinkHealthSummary,
14
- BncrOutboxQueueDiagnostics,
15
- BncrRoute,
16
10
  FileSendTransferState,
17
11
  OutboxEntry,
18
12
  } from '../core/types.ts';
19
13
  import type { BncrRuntimeFlags } from '../runtime/outbound-flags.ts';
20
14
  import type { createBncrBridgeDiagnosticsHandlersComponent } from './channel-components.ts';
21
- import type { BncrChannelConfigRoot } from './channel-runtime-types.ts';
22
15
  import type {
23
16
  ConnectionQueueCounters,
24
17
  FileAckPayload,
@@ -37,9 +30,6 @@ type DiagnosticsRuntimeStatusOverrides = {
37
30
  legacyAccountResidue?: number;
38
31
  };
39
32
 
40
- type StoredRouteRecord = { accountId: string; route: BncrRoute; updatedAt: number };
41
- type StoredLastSessionRecord = { sessionKey: string; scope: string; updatedAt: number };
42
-
43
33
  // Status/diagnostics-side wiring catalog.
44
34
  //
45
35
  // Order is intentional:
@@ -179,153 +169,3 @@ export function buildBncrBridgeSurfaceHandlersRuntime(deps: {
179
169
  }) {
180
170
  return { ...deps };
181
171
  }
182
-
183
- export function buildBncrTargetStatusRuntime(deps: {
184
- api: unknown;
185
- channelId: string;
186
- canonicalAgentId: string | null;
187
- getPluginRoot: () => string | null;
188
- startedAt: number;
189
- debugVerbose: boolean;
190
- adaptiveAckTimeoutEnabled: boolean;
191
- defaultMessageAckTimeoutMs: number;
192
- fileAckTimeoutMs: number;
193
- maxAckTimeoutMs: number;
194
- now: () => number;
195
- normalizeAccountId: (accountId: string) => string;
196
- sessionRoutes: Map<string, StoredRouteRecord>;
197
- routeAliases: Map<string, StoredRouteRecord>;
198
- lastSessionByAccount: Map<string, StoredLastSessionRecord>;
199
- markActivity: (accountId: string, at?: number) => void;
200
- scheduleSave: () => void;
201
- logInfo: (scope: string | undefined, message: string, options?: { debugOnly?: boolean }) => void;
202
- logWarn: (scope: string | undefined, message: string, options?: { debugOnly?: boolean }) => void;
203
- ensureCanonicalAgentId: (args: {
204
- cfg: BncrChannelConfigRoot;
205
- accountId: string;
206
- peer?: unknown;
207
- channelId?: string;
208
- }) => string;
209
- recentMediaDedupeBySession: Map<string, Map<string, unknown>>;
210
- resolveMessageAckTimeoutMs: (accountId?: string) => number;
211
- isOnline: (accountId: string) => boolean;
212
- outboxValues: () => Iterable<OutboxEntry>;
213
- deadLetterEntries: () => OutboxEntry[];
214
- sessionRouteValues: () => Iterable<{ accountId: string }>;
215
- countInvalidOutboxSessionKeys: (accountId: string) => number;
216
- countLegacyAccountResidue: (accountId: string) => number;
217
- connectEventsByAccount: Map<string, number>;
218
- inboundEventsByAccount: Map<string, number>;
219
- activityEventsByAccount: Map<string, number>;
220
- ackEventsByAccount: Map<string, number>;
221
- activeConnectionCount: (accountId: string) => number;
222
- lastActivityByAccount: Map<string, number>;
223
- lastInboundByAccount: Map<string, number>;
224
- lastOutboundByAccount: Map<string, number>;
225
- buildRuntimeAckObservability: (accountId: string) => BncrAckObservability;
226
- buildRuntimeAckStrategy: (ackObservability: BncrAckObservability) => {
227
- timeoutMs: number;
228
- reason:
229
- | 'static-default'
230
- | 'adaptive-disabled'
231
- | 'invalid-observability'
232
- | 'late-ack-observed'
233
- | 'capped-max';
234
- };
235
- lastAckOkByAccount: Map<string, number>;
236
- lastAckTimeoutByAccount: Map<string, number>;
237
- getAckTimeoutCount: (accountId: string) => number;
238
- getAccountPendingOutboxEntries: (accountId: string) => OutboxEntry[];
239
- getAccountDeadLetterEntries: (accountId: string) => OutboxEntry[];
240
- connectionsValues: () => Iterable<{ lastSeenAt: number }>;
241
- connectTtlMs: number;
242
- }) {
243
- return { ...deps };
244
- }
245
-
246
- export function buildBncrDiagnosticsSelectionRuntime(deps: {
247
- normalizeAccountId: (accountId: string) => string;
248
- outboxValues: () => Iterable<OutboxEntry>;
249
- getDeadLetterEntries: () => OutboxEntry[];
250
- connectionsValues: () => Iterable<BncrConnection>;
251
- }) {
252
- return { ...deps };
253
- }
254
-
255
- export function buildBncrOutboxDiagnosticsRuntime(deps: {
256
- normalizeAccountId: (accountId: string) => string;
257
- outboxValues: () => Iterable<OutboxEntry>;
258
- pendingAllAccounts: () => number;
259
- resolvePushConnIds: (accountId: string) => Set<string>;
260
- }) {
261
- return { ...deps };
262
- }
263
-
264
- export function buildBncrRuntimeAckObservabilityRuntime(deps: {
265
- normalizeAccountId: (accountId: string) => string;
266
- getCounter: (map: Map<string, number>, accountId: string) => number;
267
- ackTimeoutCountByAccount: Map<string, number>;
268
- lateAckOkCountByAccount: Map<string, number>;
269
- lastLateAckPushLatencyMsByAccount: Map<string, number>;
270
- lastLateAckOkByAccount: Map<string, number>;
271
- adaptiveAckRecoveryOkCountByAccount: Map<string, number>;
272
- lastAckOkByAccount: Map<string, number>;
273
- lastAckTimeoutByAccount: Map<string, number>;
274
- lastAckQueueLatencyMsByAccount: Map<string, number>;
275
- lastAckPushLatencyMsByAccount: Map<string, number>;
276
- lastLateAckQueueLatencyMsByAccount: Map<string, number>;
277
- adaptiveAckTimeoutEnabled: boolean;
278
- defaultAckTimeoutMs: number;
279
- resolveMessageAckTimeoutMs: (accountId: string) => number;
280
- minAckTimeoutMs: number;
281
- maxAckTimeoutMs: number;
282
- lateAckObservationTtlMs: number;
283
- recoveryOkThreshold: number;
284
- now: () => number;
285
- }) {
286
- return { ...deps };
287
- }
288
-
289
- export function buildBncrDeadLetterDiagnosticsRuntime(deps: {
290
- normalizeAccountId: (accountId: string) => string;
291
- getDeadLetterEntries: () => OutboxEntry[];
292
- maxDeadLetterEntries: number;
293
- getCounter: (map: Map<string, number>, accountId: string) => number;
294
- deadLetterSinceStartByAccount: Map<string, number>;
295
- getAccountDeadLetterEntries: (accountId: string) => OutboxEntry[];
296
- logInfo: (scope: string, message: string, options?: { debugOnly?: boolean }) => void;
297
- logInfoDedup: (
298
- scope: string,
299
- message: string,
300
- options: { key: string; sig: string; windowMs?: number },
301
- ) => void;
302
- }) {
303
- return { ...deps };
304
- }
305
-
306
- export function buildBncrExtendedDiagnosticsAssemblerRuntime(deps: {
307
- normalizeAccountId: (accountId: string) => string;
308
- buildIntegratedDiagnostics: (
309
- accountId: string,
310
- runtimeStatusInput?: Parameters<typeof buildIntegratedDiagnosticsFromRuntime>[0],
311
- ) => BncrDiagnosticsSummary;
312
- buildOutboxDiagnostics: (accountId: string) => BncrOutboxQueueDiagnostics;
313
- buildRuntimeAckObservability: (accountId: string) => BncrAckObservability;
314
- getCounter: (map: Map<string, number>, accountId: string) => number;
315
- prePushGuardSkipCountByAccount: Map<string, number>;
316
- lastPrePushGuardSkipAtByAccount: Map<string, number>;
317
- lastPrePushGuardSkipReasonByAccount: Map<string, string>;
318
- hasGatewayContext: () => boolean;
319
- buildRuntimeSurfaceDiagnostics: () => Record<string, unknown>;
320
- getRegisterRuntime: () => Record<string, unknown>;
321
- buildRegisterTraceSummary: () => RegisterTraceSummary;
322
- activeConnectionCount: (accountId: string) => number;
323
- getConnectionRuntime: () => Record<string, unknown>;
324
- getOutboundRuntime: () => Record<string, unknown>;
325
- buildDeadLetterDiagnostics: (accountId: string) => BncrDeadLetterDiagnosticsSummary;
326
- bridgeVersion: number;
327
- staleCounters: Record<string, number>;
328
- now: () => number;
329
- }) {
330
- return { ...deps };
331
- }
@@ -1,25 +1,11 @@
1
1
  // Aggregated runtime wiring entrypoint.
2
2
  //
3
- // Delivery and status/diagnostics slices now live in dedicated files so the
4
- // bridge wiring catalog stays readable without changing import sites.
3
+ // Only builders actively called from channel.ts are kept here.
4
+ // Dead builder projections have been removed.
5
5
 
6
6
  export {
7
- buildBncrAckOutboxRuntime,
8
7
  buildBncrChannelSendRuntime,
9
- buildBncrConnectionStateRuntime,
10
- buildBncrFileTransferRuntime,
11
8
  buildBncrInboundSurfaceRuntime,
12
- buildBncrMediaOrchestratorsRuntime,
13
- buildBncrOutboxPushRouteRuntime,
14
- buildBncrStateTransientRuntime,
15
9
  } from './channel-runtime-builders-delivery.ts';
16
10
 
17
- export {
18
- buildBncrBridgeSurfaceHandlersRuntime,
19
- buildBncrDeadLetterDiagnosticsRuntime,
20
- buildBncrDiagnosticsSelectionRuntime,
21
- buildBncrExtendedDiagnosticsAssemblerRuntime,
22
- buildBncrOutboxDiagnosticsRuntime,
23
- buildBncrRuntimeAckObservabilityRuntime,
24
- buildBncrTargetStatusRuntime,
25
- } from './channel-runtime-builders-status.ts';
11
+ export { buildBncrBridgeSurfaceHandlersRuntime } from './channel-runtime-builders-status.ts';
@@ -28,7 +28,7 @@ export const OUTBOUND_READY_TTL_MS = 30_000;
28
28
  export const PREFERRED_OUTBOUND_TTL_MS = 12_000;
29
29
  export const FILE_FORCE_CHUNK = true;
30
30
  export const FILE_INLINE_THRESHOLD = 5 * 1024 * 1024;
31
- export const FILE_CHUNK_SIZE = 256 * 1024;
31
+ const FILE_CHUNK_SIZE = 256 * 1024;
32
32
  export const INBOUND_FILE_TRANSFER_MAX_BYTES = 50 * 1024 * 1024;
33
33
  export const INBOUND_FILE_TRANSFER_MAX_CHUNKS =
34
34
  Math.ceil(INBOUND_FILE_TRANSFER_MAX_BYTES / FILE_CHUNK_SIZE) + 1;
@@ -1,4 +1,4 @@
1
- import type { RegisterDriftSnapshot, RegisterTraceEntry } from '../core/register-trace.ts';
1
+ import type { RegisterDriftSnapshot } from '../core/register-trace.ts';
2
2
  import type { BncrDiagnosticsSummary, BncrRoute, OutboxEntry } from '../core/types.ts';
3
3
  import type { OpenClawChannelToolSend, openClawJsonResult } from '../openclaw/sdk-helpers.ts';
4
4
 
@@ -133,7 +133,7 @@ export type BncrChannelSendContext = {
133
133
  payload?: Record<string, unknown>;
134
134
  sessionKey?: string;
135
135
  mirror?: { sessionKey?: string };
136
- threadId?: string;
136
+ threadId?: string | number | null;
137
137
  /** Pass-through fields from host - bncr plugin does NOT consume these. */
138
138
  forceDocument?: boolean;
139
139
  gifPlayback?: boolean;
@@ -143,28 +143,6 @@ export type BncrChannelSendContext = {
143
143
  extra?: Record<string, unknown>;
144
144
  };
145
145
 
146
- export type BncrRegisterRuntimeSnapshot = {
147
- bridgeId: string;
148
- gatewayPid: number;
149
- pluginVersion: string | null;
150
- pluginSource: string | null;
151
- lastApiInstanceId: string | null;
152
- lastRegistryFingerprint: string | null;
153
- registerCount: number;
154
- firstRegisterAt: number | null;
155
- lastRegisterAt: number | null;
156
- lastApiRebindAt: number | null;
157
- apiGeneration: number;
158
- registerTraceRecent: RegisterTraceEntry[];
159
- lastDriftSnapshot: RegisterDriftSnapshot | null;
160
- };
161
-
162
- export type FileAckPayloadState = {
163
- payload: Record<string, unknown>;
164
- ok: boolean;
165
- at: number;
166
- };
167
-
168
146
  export type ChannelMessageActionAdapter = {
169
147
  describeMessageTool: (ctx: { cfg: BncrChannelConfigRoot }) => {
170
148
  actions: readonly ['send'];