@agentvault/agentvault 0.20.33 → 0.20.35

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 (66) hide show
  1. package/dist/_cp.d.ts +10 -0
  2. package/dist/_cp.d.ts.map +1 -0
  3. package/dist/account-config.d.ts +20 -0
  4. package/dist/account-config.d.ts.map +1 -0
  5. package/dist/channel.d.ts +430 -0
  6. package/dist/channel.d.ts.map +1 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +12 -2
  10. package/dist/cli.js.map +2 -2
  11. package/dist/create-agent.d.ts +28 -0
  12. package/dist/create-agent.d.ts.map +1 -0
  13. package/dist/credential-store.d.ts +62 -0
  14. package/dist/credential-store.d.ts.map +1 -0
  15. package/dist/crypto-helpers.d.ts +2 -0
  16. package/dist/crypto-helpers.d.ts.map +1 -0
  17. package/dist/doctor.d.ts +41 -0
  18. package/dist/doctor.d.ts.map +1 -0
  19. package/dist/fetch-interceptor.d.ts +32 -0
  20. package/dist/fetch-interceptor.d.ts.map +1 -0
  21. package/dist/gateway-send.d.ts +98 -0
  22. package/dist/gateway-send.d.ts.map +1 -0
  23. package/dist/http-handlers.d.ts +53 -0
  24. package/dist/http-handlers.d.ts.map +1 -0
  25. package/dist/index.d.ts +27 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +12 -2
  28. package/dist/index.js.map +2 -2
  29. package/dist/mcp-handlers.d.ts +26 -0
  30. package/dist/mcp-handlers.d.ts.map +1 -0
  31. package/dist/mcp-proxy-helpers.d.ts +9 -0
  32. package/dist/mcp-proxy-helpers.d.ts.map +1 -0
  33. package/dist/mcp-server.d.ts +91 -0
  34. package/dist/mcp-server.d.ts.map +1 -0
  35. package/dist/mls-state.d.ts +54 -0
  36. package/dist/mls-state.d.ts.map +1 -0
  37. package/dist/openclaw-compat.d.ts +33 -0
  38. package/dist/openclaw-compat.d.ts.map +1 -0
  39. package/dist/openclaw-entry.d.ts +32 -0
  40. package/dist/openclaw-entry.d.ts.map +1 -0
  41. package/dist/openclaw-plugin.d.ts +102 -0
  42. package/dist/openclaw-plugin.d.ts.map +1 -0
  43. package/dist/openclaw-types.d.ts +186 -0
  44. package/dist/openclaw-types.d.ts.map +1 -0
  45. package/dist/policy-enforcer.d.ts +78 -0
  46. package/dist/policy-enforcer.d.ts.map +1 -0
  47. package/dist/setup.d.ts +27 -0
  48. package/dist/setup.d.ts.map +1 -0
  49. package/dist/skill-invoker.d.ts +30 -0
  50. package/dist/skill-invoker.d.ts.map +1 -0
  51. package/dist/skill-manifest.d.ts +30 -0
  52. package/dist/skill-manifest.d.ts.map +1 -0
  53. package/dist/skill-telemetry.d.ts +36 -0
  54. package/dist/skill-telemetry.d.ts.map +1 -0
  55. package/dist/skills-publish.d.ts +8 -0
  56. package/dist/skills-publish.d.ts.map +1 -0
  57. package/dist/state.d.ts +32 -0
  58. package/dist/state.d.ts.map +1 -0
  59. package/dist/transport.d.ts +24 -0
  60. package/dist/transport.d.ts.map +1 -0
  61. package/dist/types.d.ts +454 -0
  62. package/dist/types.d.ts.map +1 -0
  63. package/dist/workspace-handlers.d.ts +62 -0
  64. package/dist/workspace-handlers.d.ts.map +1 -0
  65. package/openclaw.plugin.json +1 -1
  66. package/package.json +1 -1
package/dist/_cp.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Lazy shell wrapper for CLI-only commands (setup, doctor, create).
3
+ *
4
+ * Loads the underlying module lazily at first call so the OpenClaw
5
+ * plugin entry point never references it. Type declarations use
6
+ * generic signatures to keep the .d.ts clean for the scanner too.
7
+ */
8
+ export declare function execSync(command: string, options?: any): any;
9
+ export declare function spawnSync(command: string, args?: string[], options?: any): any;
10
+ //# sourceMappingURL=_cp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_cp.d.ts","sourceRoot":"","sources":["../src/_cp.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,CAE5D;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,CAE9E"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Shared multi-account config resolution for AgentVault OpenClaw plugin.
3
+ *
4
+ * Supports two config shapes:
5
+ * 1. Legacy single-agent: channels.agentvault.dataDir (returns ["default"])
6
+ * 2. Multi-agent: channels.agentvault.accounts.{id}.dataDir (returns account keys)
7
+ *
8
+ * When `accounts` key is present, it takes precedence over top-level dataDir.
9
+ */
10
+ export interface ResolvedAccount {
11
+ accountId: string;
12
+ dataDir: string;
13
+ apiUrl: string;
14
+ agentName: string;
15
+ httpPort: number;
16
+ configured: boolean;
17
+ }
18
+ export declare function listAccountIds(cfg: any): string[];
19
+ export declare function resolveAccount(cfg: any, accountId?: string): ResolvedAccount;
20
+ //# sourceMappingURL=account-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-config.d.ts","sourceRoot":"","sources":["../src/account-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,EAAE,CAOjD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CA0C5E"}
@@ -0,0 +1,430 @@
1
+ import { EventEmitter } from "node:events";
2
+ import { TelemetryReporter } from "@agentvault/crypto";
3
+ import type { SecureChannelConfig, ChannelState, HistoryEntry, SendOptions, DecisionRequest, DecisionResponse, HeartbeatStatus, StatusAlert, RoomMemberInfo, RoomConversationInfo, RoomInfo, A2AChannel, DeliveryTarget, DeliveryContent, DeliveryOptions, DeliveryReceipt, TargetInfo } from "./types.js";
4
+ export declare class SecureChannel extends EventEmitter {
5
+ private config;
6
+ private _state;
7
+ private _deviceId;
8
+ private _fingerprint;
9
+ private _primaryConversationId;
10
+ private _deviceJwt;
11
+ private _sessions;
12
+ private _ws;
13
+ private _pollTimer;
14
+ private _reconnectAttempt;
15
+ private _reconnectTimer;
16
+ private _rapidDisconnects;
17
+ private _lastWsOpenTime;
18
+ private _pingTimer;
19
+ private _lastServerMessage;
20
+ private _pendingAcks;
21
+ private _ackTimer;
22
+ private _stopped;
23
+ private _persisted;
24
+ private _httpServer;
25
+ private _mcpServer;
26
+ private _pollFallbackTimer;
27
+ private _heartbeatTimer;
28
+ private _heartbeatCallback;
29
+ private _heartbeatIntervalSeconds;
30
+ private _wakeDetectorTimer;
31
+ private _lastWakeTick;
32
+ private _trustToken;
33
+ private _trustTier;
34
+ private _trustTokenExpiresAt;
35
+ private _trustTokenInterval;
36
+ private _pendingPollTimer;
37
+ private _syncMessageIds;
38
+ private _deliveryHeartbeat;
39
+ private _deliveryPulling;
40
+ private _drDeliveryPulling;
41
+ /** MLS group managers per room/conversation (roomId or conv:conversationId -> MLSGroupManager) */
42
+ private _mlsGroups;
43
+ /** Cached MLS KeyPackage bundle for this device (regenerated on each connect). */
44
+ private _mlsKeyPackage;
45
+ /** Pending KeyPackage bundle from request-Welcome flow (used by _handleMlsWelcome). */
46
+ private _pendingMlsKpBundle;
47
+ /** Buffer for MLS commits received before Welcome (keyed by groupId, sorted by epoch). */
48
+ private _pendingMlsCommits;
49
+ /** In-memory credential store for renter-provided credentials (never persisted). */
50
+ private _credentialStore;
51
+ /** Dedup buffer for A2A message IDs (prevents double-delivery via direct + Redis) */
52
+ private _a2aSeenMessageIds;
53
+ private static readonly A2A_SEEN_MAX;
54
+ /** Dedup buffer for regular message IDs (prevents double-decrypt via direct WS + Redis pub/sub) */
55
+ private _seenMessageIds;
56
+ private static readonly SEEN_MSG_MAX;
57
+ private _scanEngine;
58
+ private _scanRuleSetVersion;
59
+ private _telemetryReporter;
60
+ /** Topic ID from the most recent inbound message — used as fallback for replies. */
61
+ private _lastIncomingTopicId;
62
+ /** Room ID from the most recent inbound room message — used as fallback for HTTP /send replies. */
63
+ private _lastInboundRoomId;
64
+ /** Rate-limit: last resync_request timestamp per conversation (5-min cooldown). */
65
+ private _lastResyncRequest;
66
+ /** Debounce timer for server backup uploads (60s). */
67
+ private _serverBackupTimer;
68
+ private _serverBackupRunning;
69
+ private static readonly PING_INTERVAL_MS;
70
+ private static readonly SILENCE_TIMEOUT_MS;
71
+ private static readonly POLL_FALLBACK_INTERVAL_MS;
72
+ private static readonly POLL_FALLBACK_IDLE_MS;
73
+ constructor(config: SecureChannelConfig);
74
+ get state(): ChannelState;
75
+ get deviceId(): string | null;
76
+ get fingerprint(): string | null;
77
+ /** Returns the primary conversation ID (backward-compatible). */
78
+ get conversationId(): string | null;
79
+ /** Returns all active conversation IDs. */
80
+ get conversationIds(): string[];
81
+ /** Returns the number of active sessions. */
82
+ get sessionCount(): number;
83
+ /** Room ID from the most recent inbound room message (for HTTP /send fallback). */
84
+ get lastInboundRoomId(): string | undefined;
85
+ /** Returns all persisted room IDs and names (for outbound target registration). */
86
+ get roomIds(): Array<{
87
+ roomId: string;
88
+ name: string;
89
+ }>;
90
+ /** Returns hub addresses of all persisted A2A peer participants. */
91
+ get a2aPeerAddresses(): string[];
92
+ /** Resolves an A2A channel ID to the first active peer's hub address, or null if not found. */
93
+ resolveA2AChannelHub(channelId: string): string | null;
94
+ /** Returns the TelemetryReporter instance (available after WebSocket connect). */
95
+ get telemetry(): TelemetryReporter | null;
96
+ /**
97
+ * Check if a skill is in shadow mode. Returns the shadow config if active, undefined otherwise.
98
+ */
99
+ getShadowConfig(skillName: string): {
100
+ sessionId: string;
101
+ autonomyLevel: string;
102
+ decisionClass: string;
103
+ } | undefined;
104
+ start(): Promise<void>;
105
+ /**
106
+ * Fetch scan rules from the server and load them into the ScanEngine.
107
+ */
108
+ private _fetchScanRules;
109
+ /**
110
+ * Activate all sibling 1:1 sessions when any session receives an owner message.
111
+ * Ensures agent replies fan out to ALL owner devices, not just the active one.
112
+ */
113
+ private _activateSiblings;
114
+ /**
115
+ * Append a message to persistent history for cross-device replay.
116
+ */
117
+ private _appendHistory;
118
+ /**
119
+ * Get recent message history for a specific room, for LLM context injection.
120
+ * Returns the last N messages tagged with `room:{roomId}`.
121
+ */
122
+ getRoomHistory(roomId: string, maxMessages?: number): HistoryEntry[];
123
+ /**
124
+ * Encrypt and send a message to ALL owner devices (fanout).
125
+ * Each session gets the same plaintext encrypted independently.
126
+ */
127
+ send(plaintext: string, options?: SendOptions): Promise<void>;
128
+ /**
129
+ * Send a typing indicator to all owner devices.
130
+ * Ephemeral (unencrypted metadata), no ratchet advancement.
131
+ */
132
+ sendTyping(): void;
133
+ /**
134
+ * Send an activity span to all owner devices via WS.
135
+ * Ephemeral (unencrypted metadata, like typing), no ratchet advancement.
136
+ */
137
+ sendActivitySpan(spanData: Record<string, unknown>): void;
138
+ /**
139
+ * Send a decision request to the owner.
140
+ * Builds a structured envelope with decision metadata and sends it
141
+ * as a high-priority message. Returns the generated decision_id.
142
+ */
143
+ sendDecisionRequest(request: DecisionRequest): Promise<string>;
144
+ /**
145
+ * Wait for a decision response matching the given decisionId.
146
+ * Listens on the "message" event for messages where
147
+ * metadata.messageType === "decision_response" and the parsed plaintext
148
+ * contains a matching decision.decision_id.
149
+ * Optional timeout rejects with an Error.
150
+ */
151
+ waitForDecision(decisionId: string, timeoutMs?: number): Promise<DecisionResponse>;
152
+ /**
153
+ * Join a room by collecting pairwise conversation IDs involving this device.
154
+ * Encryption is handled by MLS group operations, not per-member DR sessions.
155
+ */
156
+ joinRoom(roomData: {
157
+ roomId: string;
158
+ name: string;
159
+ members: RoomMemberInfo[];
160
+ conversations: RoomConversationInfo[];
161
+ forceRekey?: boolean;
162
+ }): Promise<void>;
163
+ /**
164
+ * Send an encrypted message to all members of a room.
165
+ * Uses MLS (preferred) or pairwise fan-out as fallback.
166
+ */
167
+ sendToRoom(roomId: string, plaintext: string, opts?: {
168
+ messageType?: string;
169
+ priority?: string;
170
+ metadata?: Record<string, unknown>;
171
+ }): Promise<void>;
172
+ /**
173
+ * Leave a room: remove sessions and persisted room state.
174
+ */
175
+ leaveRoom(roomId: string): Promise<void>;
176
+ /**
177
+ * Return info for all joined rooms.
178
+ */
179
+ getRooms(): RoomInfo[];
180
+ startHeartbeat(intervalSeconds: number, statusCallback: () => HeartbeatStatus): void;
181
+ stopHeartbeat(): Promise<void>;
182
+ sendStatusAlert(alert: StatusAlert): Promise<void>;
183
+ sendArtifact(artifact: {
184
+ filePath: string;
185
+ filename: string;
186
+ mimeType: string;
187
+ description?: string;
188
+ }): Promise<void>;
189
+ sendActionConfirmation(confirmation: {
190
+ action: string;
191
+ status: "completed" | "failed" | "partial";
192
+ decisionId?: string;
193
+ detail?: string;
194
+ }): Promise<void>;
195
+ sendActionConfirmationToRoom(roomId: string, confirmation: {
196
+ action: string;
197
+ status: "completed" | "failed" | "partial";
198
+ decisionId?: string;
199
+ detail?: string;
200
+ estimated_cost?: number;
201
+ }): Promise<void>;
202
+ /**
203
+ * Canonical message dispatcher. ALL outbound messages should flow through this method.
204
+ * Routes based on explicit target — never silently falls back to a room.
205
+ */
206
+ deliver(target: DeliveryTarget, content: DeliveryContent, options?: DeliveryOptions): Promise<DeliveryReceipt>;
207
+ /**
208
+ * Returns all available delivery destinations with availability status.
209
+ */
210
+ listTargets(): TargetInfo[];
211
+ private _sendHeartbeat;
212
+ getTrustHeaders(): Record<string, string>;
213
+ get trustToken(): string | null;
214
+ get trustTier(): string | null;
215
+ get trustTokenExpiresAt(): string | null;
216
+ refreshTrustToken(): Promise<void>;
217
+ startTrustTokenRefresh(): void;
218
+ stopTrustTokenRefresh(): void;
219
+ stop(): Promise<void>;
220
+ startHttpServer(port: number): void;
221
+ private _stopHttpServer;
222
+ /**
223
+ * Attach an MCP server instance to this channel.
224
+ * The MCP server will be served at /mcp on the local HTTP server.
225
+ */
226
+ setMcpServer(mcpServer: import("./mcp-server.js").AgentVaultMcpServer): void;
227
+ /** The attached MCP server, if any. */
228
+ get mcpServer(): import("./mcp-server.js").AgentVaultMcpServer | null;
229
+ /**
230
+ * Create a new topic within the conversation group.
231
+ * Requires the channel to be initialized with a groupId (from activation).
232
+ */
233
+ createTopic(name: string): Promise<{
234
+ id: string;
235
+ name: string;
236
+ isDefault: boolean;
237
+ }>;
238
+ /**
239
+ * List all topics in the conversation group.
240
+ * Requires the channel to be initialized with a groupId (from activation).
241
+ */
242
+ listTopics(): Promise<Array<{
243
+ id: string;
244
+ name: string;
245
+ isDefault: boolean;
246
+ }>>;
247
+ /**
248
+ * Request a new A2A channel with another agent by their hub address.
249
+ * Returns the channel_id from the server response.
250
+ */
251
+ requestA2AChannel(responderHubAddress: string): Promise<string>;
252
+ /**
253
+ * Invite another agent to an existing A2A channel by their hub address.
254
+ */
255
+ inviteToA2AChannel(channelId: string, hubAddress: string): Promise<void>;
256
+ /**
257
+ * Send a message to another agent via an active A2A channel.
258
+ * Looks up the A2A conversation by hub address and sends via WS.
259
+ *
260
+ * If the channel has an established E2E session, the message is encrypted
261
+ * with the Double Ratchet. If the responder hasn't received the initiator's
262
+ * first message yet (ratchet not activated), the message is queued locally
263
+ * and flushed when the first inbound message arrives.
264
+ *
265
+ * Falls back to plaintext for channels without a session (legacy/pre-encryption).
266
+ */
267
+ sendToAgent(hubAddress: string, text: string, opts?: {
268
+ parentSpanId?: string;
269
+ }): Promise<void>;
270
+ /**
271
+ * Send a message to a specific A2A channel by channel ID.
272
+ * Used for multi-agent channels where hub address routing is ambiguous.
273
+ */
274
+ sendToA2AChannel(channelId: string, text: string): Promise<void>;
275
+ /**
276
+ * List all A2A channels for this agent.
277
+ * Fetches from the server and updates local persisted state.
278
+ */
279
+ listA2AChannels(): Promise<A2AChannel[]>;
280
+ private _enroll;
281
+ private _poll;
282
+ private _activate;
283
+ private _connect;
284
+ /**
285
+ * Handle an incoming encrypted message from a specific conversation.
286
+ * Decrypts using the appropriate session ratchet, emits to the agent,
287
+ * and relays as sync messages to sibling sessions.
288
+ */
289
+ /**
290
+ * Handle an incoming MLS-encrypted 1:1 message.
291
+ * Decrypts via the conversation's MLSGroupManager and emits the plaintext.
292
+ */
293
+ private _handleMessageMLS;
294
+ private _handleIncomingMessage;
295
+ /**
296
+ * Download an encrypted attachment blob, decrypt it, verify integrity,
297
+ * and save the plaintext file to disk.
298
+ */
299
+ private _downloadAndDecryptAttachment;
300
+ /**
301
+ * Upload an attachment file: encrypt, upload to server, return metadata
302
+ * for inclusion in the message envelope.
303
+ */
304
+ private _uploadAttachment;
305
+ /**
306
+ * Send a message with an attached file. Encrypts the file, uploads it,
307
+ * then sends the envelope with attachment metadata via Double Ratchet.
308
+ */
309
+ sendWithAttachment(plaintext: string, filePath: string, options?: {
310
+ topicId?: string;
311
+ }): Promise<void>;
312
+ /**
313
+ * Relay an owner's message to all sibling sessions as encrypted sync messages.
314
+ * This allows all owner devices to see messages from any single device.
315
+ */
316
+ private _relaySyncToSiblings;
317
+ /**
318
+ * Resolve the agent's workspace directory.
319
+ * Looks for OpenClaw workspace config, falls back to default path.
320
+ */
321
+ private _resolveWorkspaceDir;
322
+ /**
323
+ * Send a structured JSON reply to a specific conversation.
324
+ * Encrypts the payload via the conversation's ratchet and sends via WebSocket.
325
+ */
326
+ private _sendStructuredReply;
327
+ /**
328
+ * Send stored message history to a newly-activated session.
329
+ * Batches all history into a single encrypted message.
330
+ */
331
+ private _replayHistoryToSession;
332
+ /**
333
+ * Handle a device_linked event: a new owner device has joined.
334
+ * Fetches the new device's public keys, performs X3DH, and initializes
335
+ * a new ratchet session.
336
+ */
337
+ private _handleDeviceLinked;
338
+ /**
339
+ * Handle a resync_request from the owner (owner-initiated ratchet re-establishment).
340
+ * Re-derives shared secret via X3DH as responder, initializes fresh receiver ratchet,
341
+ * and sends resync_ack back with agent's public keys.
342
+ */
343
+ private _handleResyncRequest;
344
+ /**
345
+ * Handle credential protocol messages (grant, revoke, request).
346
+ * These are intercepted before reaching the agent's onMessage callback.
347
+ */
348
+ private _handleCredentialMessage;
349
+ /**
350
+ * Send a credential_ack back to a room.
351
+ */
352
+ private _sendCredentialAck;
353
+ /** Get a specific renter credential for a room. */
354
+ getCredential(roomId: string, key: string): import("./credential-store.js").RenterCredential | undefined;
355
+ /** Get all renter credentials for a room (includes values — for agent context). */
356
+ getCredentials(roomId: string): import("./credential-store.js").RenterCredential[];
357
+ /** Get credential key→value map for a room (for context injection). */
358
+ getCredentialMap(roomId: string): Record<string, string>;
359
+ /** Check if a specific credential exists for a room. */
360
+ hasCredential(roomId: string, key: string): boolean;
361
+ /** Purge all credentials for a room (call on rental end). */
362
+ purgeRoomCredentials(roomId: string): void;
363
+ private _handleRoomMessageMLS;
364
+ /**
365
+ * Handle a history catch-up request from a device that just rejoined a room.
366
+ * Only the elected agent (smallest device_id among agents) responds.
367
+ */
368
+ private _handleHistoryCatchupRequest;
369
+ private _handleMlsCommit;
370
+ /** Buffer an MLS commit for replay after Welcome join. Max 50 per group. */
371
+ private _bufferMlsCommit;
372
+ /** Apply buffered MLS commits after Welcome join. */
373
+ private _applyBufferedMlsCommits;
374
+ private _handleMlsWelcome;
375
+ /**
376
+ * Pull pending MLS messages from the delivery queue and process them.
377
+ * Called on WS connect, on mls_delivery ping, and every 30s heartbeat.
378
+ */
379
+ private _pullDeliveryQueue;
380
+ /**
381
+ * Pull pending DR (Double Ratchet) messages from the delivery queue.
382
+ * Signal-model queue-first: called on WS connect and on dr_delivery ping.
383
+ */
384
+ private _pullDrDeliveryQueue;
385
+ private _handleMlsSyncResponse;
386
+ /**
387
+ * Handle an incoming MLS-encrypted A2A message.
388
+ * The observer (owner device) decrypts as a regular MLS group member.
389
+ */
390
+ private _handleA2AMessageMLS;
391
+ /**
392
+ * Found the MLS group for an A2A channel as the creator agent.
393
+ * Calls /mls/a2a/{channelId}/init, creates the local MLS group, and sends
394
+ * Welcome messages to all active/invited participants.
395
+ * Extracted from the a2a_channel_approved WS handler so it can also be called
396
+ * from the sync fallback in listA2AChannels.
397
+ */
398
+ private _foundA2AGroup;
399
+ /**
400
+ * Paginated sync: fetch missed messages in pages of 200, up to 5 pages (1000 messages).
401
+ * Tracks message IDs in _syncMessageIds to prevent duplicate processing from concurrent WS messages.
402
+ */
403
+ private _syncMissedMessages;
404
+ private _sendAck;
405
+ private _flushAcks;
406
+ private _flushOutboundQueue;
407
+ private _startPing;
408
+ private _stopPing;
409
+ private _startWakeDetector;
410
+ private _stopWakeDetector;
411
+ private _startPendingPoll;
412
+ private _stopPendingPoll;
413
+ private _checkPendingMessages;
414
+ private _scheduleReconnect;
415
+ private _setState;
416
+ private _startPollFallback;
417
+ private _stopPollFallback;
418
+ private _handleError;
419
+ /**
420
+ * Persist all ratchet session states to disk.
421
+ * Syncs live ratchet states back into the persisted sessions map.
422
+ */
423
+ private _persistState;
424
+ /**
425
+ * Debounced server backup upload (60s after last state change).
426
+ * Only runs when backupCode is configured.
427
+ */
428
+ private _scheduleServerBackup;
429
+ }
430
+ //# sourceMappingURL=channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAU3C,OAAO,EAWL,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAKZ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,QAAQ,EAER,UAAU,EAEV,cAAc,EACd,eAAe,EACf,eAAe,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OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,gBAAgB;YAOV,qBAAqB;IAuCnC,OAAO,CAAC,kBAAkB;IA4C1B,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,kBAAkB;IA2H1B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,YAAY;IAKpB;;;OAGG;YACW,aAAa;IA6B3B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAqB9B"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js CHANGED
@@ -64061,7 +64061,7 @@ var init_channel = __esm({
64061
64061
  try {
64062
64062
  const mlsGroup = this._mlsGroups.get(`conv:${convId}`);
64063
64063
  const mlsGroupId = this._persisted?.mlsConversations?.[convId]?.mlsGroupId;
64064
- if (mlsGroup?.isInitialized && mlsGroupId && this._state === "ready" && this._ws) {
64064
+ if (mlsGroup?.isInitialized && mlsGroupId && Number(mlsGroup.epoch) > 0 && this._state === "ready" && this._ws) {
64065
64065
  const plaintextBytes = new TextEncoder().encode(plaintext);
64066
64066
  const cipherBytes = await mlsGroup.encrypt(plaintextBytes);
64067
64067
  await saveMlsState(this.config.dataDir, mlsGroupId, JSON.stringify(mlsGroup.exportState()));
@@ -66312,6 +66312,16 @@ var init_channel = __esm({
66312
66312
  topicId = parsed.topicId ?? topicId;
66313
66313
  } catch {
66314
66314
  }
66315
+ if (convId) {
66316
+ const session = this._sessions.get(convId);
66317
+ if (session && !session.activated) {
66318
+ session.activated = true;
66319
+ if (this._persisted?.sessions?.[convId]) {
66320
+ this._persisted.sessions[convId].activated = true;
66321
+ }
66322
+ console.log(`[SecureChannel] Session ${convId.slice(0, 8)} activated via MLS message`);
66323
+ }
66324
+ }
66315
66325
  const metadata = {
66316
66326
  messageId: data.message_id ?? `mls_${Date.now()}`,
66317
66327
  conversationId: convId ?? this._primaryConversationId,
@@ -89289,7 +89299,7 @@ var init_index = __esm({
89289
89299
  init_skill_invoker();
89290
89300
  await init_skill_telemetry();
89291
89301
  await init_policy_enforcer();
89292
- VERSION = true ? "0.20.33" : "0.0.0-dev";
89302
+ VERSION = true ? "0.20.35" : "0.0.0-dev";
89293
89303
  }
89294
89304
  });
89295
89305