@agentvault/secure-channel 0.6.17 → 0.6.19
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/dist/channel.d.ts +9 -6
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +44 -22
- package/dist/cli.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -20
- package/dist/index.js.map +2 -2
- package/dist/openclaw-entry.d.ts.map +1 -1
- package/dist/openclaw-entry.js +25 -24
- package/dist/openclaw-entry.js.map +2 -2
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/openclaw.plugin.json +2 -2
- package/package.json +1 -1
package/dist/channel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import type { SecureChannelConfig, ChannelState } from "./types.js";
|
|
2
|
+
import type { SecureChannelConfig, ChannelState, SendOptions } from "./types.js";
|
|
3
3
|
export declare class SecureChannel extends EventEmitter {
|
|
4
4
|
private config;
|
|
5
5
|
private _state;
|
|
@@ -13,7 +13,7 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
13
13
|
private _reconnectAttempt;
|
|
14
14
|
private _reconnectTimer;
|
|
15
15
|
private _pingTimer;
|
|
16
|
-
private
|
|
16
|
+
private _lastServerMessage;
|
|
17
17
|
private _pendingAcks;
|
|
18
18
|
private _ackTimer;
|
|
19
19
|
private _stopped;
|
|
@@ -22,7 +22,7 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
22
22
|
private _pollFallbackTimer;
|
|
23
23
|
private _syncMessageIds;
|
|
24
24
|
private static readonly PING_INTERVAL_MS;
|
|
25
|
-
private static readonly
|
|
25
|
+
private static readonly SILENCE_TIMEOUT_MS;
|
|
26
26
|
private static readonly POLL_FALLBACK_INTERVAL_MS;
|
|
27
27
|
private static readonly POLL_FALLBACK_IDLE_MS;
|
|
28
28
|
constructor(config: SecureChannelConfig);
|
|
@@ -44,9 +44,12 @@ export declare class SecureChannel extends EventEmitter {
|
|
|
44
44
|
* Encrypt and send a message to ALL owner devices (fanout).
|
|
45
45
|
* Each session gets the same plaintext encrypted independently.
|
|
46
46
|
*/
|
|
47
|
-
send(plaintext: string, options?:
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
send(plaintext: string, options?: SendOptions): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Send a typing indicator to all owner devices.
|
|
50
|
+
* Ephemeral (unencrypted metadata), no ratchet advancement.
|
|
51
|
+
*/
|
|
52
|
+
sendTyping(): void;
|
|
50
53
|
stop(): Promise<void>;
|
|
51
54
|
startHttpServer(port: number): void;
|
|
52
55
|
private _stopHttpServer;
|
package/dist/channel.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoB3C,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EAMZ,WAAW,EACZ,MAAM,YAAY,CAAC;AAmDpB,qBAAa,aAAc,SAAQ,YAAY;IA+BjC,OAAO,CAAC,MAAM;IA9B1B,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,sBAAsB,CAAc;IAC5C,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,SAAS,CAGH;IACd,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,iBAAiB,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reconnectTimer = null;
|
|
45184
45184
|
_pingTimer = null;
|
|
45185
|
-
|
|
45185
|
+
_lastServerMessage = 0;
|
|
45186
45186
|
_pendingAcks = [];
|
|
45187
45187
|
_ackTimer = null;
|
|
45188
45188
|
_stopped = false;
|
|
@@ -45190,10 +45190,10 @@ var init_channel = __esm({
|
|
|
45190
45190
|
_httpServer = null;
|
|
45191
45191
|
_pollFallbackTimer = null;
|
|
45192
45192
|
_syncMessageIds = null;
|
|
45193
|
+
// Liveness detection: server sends app-level {"event":"ping"} every 30s.
|
|
45194
|
+
// We check every 30s; if no data received in 90s (3 missed pings), connection is dead.
|
|
45193
45195
|
static PING_INTERVAL_MS = 3e4;
|
|
45194
|
-
|
|
45195
|
-
static PING_TIMEOUT_MS = 1e4;
|
|
45196
|
-
// Treat as dead if no pong within 10s
|
|
45196
|
+
static SILENCE_TIMEOUT_MS = 9e4;
|
|
45197
45197
|
static POLL_FALLBACK_INTERVAL_MS = 3e4;
|
|
45198
45198
|
// 30s when messages found
|
|
45199
45199
|
static POLL_FALLBACK_IDLE_MS = 6e4;
|
|
@@ -45282,6 +45282,10 @@ var init_channel = __esm({
|
|
|
45282
45282
|
throw new Error("No active sessions");
|
|
45283
45283
|
}
|
|
45284
45284
|
const topicId = options?.topicId ?? this._persisted?.defaultTopicId;
|
|
45285
|
+
const messageType = options?.messageType ?? "text";
|
|
45286
|
+
const priority = options?.priority ?? "normal";
|
|
45287
|
+
const parentSpanId = options?.parentSpanId;
|
|
45288
|
+
const envelopeMetadata = options?.metadata;
|
|
45285
45289
|
this._appendHistory("agent", plaintext, topicId);
|
|
45286
45290
|
const messageGroupId = randomUUID();
|
|
45287
45291
|
for (const [convId, session] of this._sessions) {
|
|
@@ -45304,7 +45308,11 @@ var init_channel = __esm({
|
|
|
45304
45308
|
header_blob: msg.headerBlob,
|
|
45305
45309
|
ciphertext: msg.ciphertext,
|
|
45306
45310
|
message_group_id: msg.messageGroupId,
|
|
45307
|
-
topic_id: msg.topicId
|
|
45311
|
+
topic_id: msg.topicId,
|
|
45312
|
+
message_type: messageType,
|
|
45313
|
+
priority,
|
|
45314
|
+
parent_span_id: parentSpanId,
|
|
45315
|
+
metadata: envelopeMetadata
|
|
45308
45316
|
}
|
|
45309
45317
|
})
|
|
45310
45318
|
);
|
|
@@ -45322,6 +45330,21 @@ var init_channel = __esm({
|
|
|
45322
45330
|
}
|
|
45323
45331
|
await this._persistState();
|
|
45324
45332
|
}
|
|
45333
|
+
/**
|
|
45334
|
+
* Send a typing indicator to all owner devices.
|
|
45335
|
+
* Ephemeral (unencrypted metadata), no ratchet advancement.
|
|
45336
|
+
*/
|
|
45337
|
+
sendTyping() {
|
|
45338
|
+
if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
|
|
45339
|
+
for (const convId of this._sessions.keys()) {
|
|
45340
|
+
this._ws.send(
|
|
45341
|
+
JSON.stringify({
|
|
45342
|
+
event: "typing",
|
|
45343
|
+
data: { conversation_id: convId }
|
|
45344
|
+
})
|
|
45345
|
+
);
|
|
45346
|
+
}
|
|
45347
|
+
}
|
|
45325
45348
|
async stop() {
|
|
45326
45349
|
this._stopped = true;
|
|
45327
45350
|
this._flushAcks();
|
|
@@ -45674,6 +45697,7 @@ var init_channel = __esm({
|
|
|
45674
45697
|
this.emit("ready");
|
|
45675
45698
|
});
|
|
45676
45699
|
ws.on("message", async (raw) => {
|
|
45700
|
+
this._lastServerMessage = Date.now();
|
|
45677
45701
|
try {
|
|
45678
45702
|
const data = JSON.parse(raw.toString());
|
|
45679
45703
|
if (data.event === "ping") {
|
|
@@ -45803,7 +45827,12 @@ ${messageText}`;
|
|
|
45803
45827
|
conversationId: convId,
|
|
45804
45828
|
timestamp: msgData.created_at,
|
|
45805
45829
|
topicId,
|
|
45806
|
-
attachment: attachData
|
|
45830
|
+
attachment: attachData,
|
|
45831
|
+
spanId: msgData.span_id,
|
|
45832
|
+
parentSpanId: msgData.parent_span_id,
|
|
45833
|
+
messageType: msgData.message_type ?? "text",
|
|
45834
|
+
priority: msgData.priority ?? "normal",
|
|
45835
|
+
envelopeVersion: msgData.envelope_version ?? "1.0.0"
|
|
45807
45836
|
};
|
|
45808
45837
|
this.emit("message", emitText, metadata);
|
|
45809
45838
|
this.config.onMessage?.(emitText, metadata);
|
|
@@ -46164,30 +46193,23 @@ ${messageText}`;
|
|
|
46164
46193
|
}
|
|
46165
46194
|
_startPing(ws) {
|
|
46166
46195
|
this._stopPing();
|
|
46196
|
+
this._lastServerMessage = Date.now();
|
|
46167
46197
|
this._pingTimer = setInterval(() => {
|
|
46168
46198
|
if (ws.readyState !== WebSocket.OPEN) return;
|
|
46169
|
-
|
|
46170
|
-
|
|
46199
|
+
const silence = Date.now() - this._lastServerMessage;
|
|
46200
|
+
if (silence > _SecureChannel.SILENCE_TIMEOUT_MS) {
|
|
46201
|
+
console.log(
|
|
46202
|
+
`[SecureChannel] No server data for ${Math.round(silence / 1e3)}s \u2014 reconnecting stale WebSocket`
|
|
46203
|
+
);
|
|
46171
46204
|
ws.terminate();
|
|
46172
|
-
}, _SecureChannel.PING_TIMEOUT_MS);
|
|
46173
|
-
ws.ping();
|
|
46174
|
-
}, _SecureChannel.PING_INTERVAL_MS);
|
|
46175
|
-
ws.on("pong", () => {
|
|
46176
|
-
if (this._pingTimeout) {
|
|
46177
|
-
clearTimeout(this._pingTimeout);
|
|
46178
|
-
this._pingTimeout = null;
|
|
46179
46205
|
}
|
|
46180
|
-
});
|
|
46206
|
+
}, _SecureChannel.PING_INTERVAL_MS);
|
|
46181
46207
|
}
|
|
46182
46208
|
_stopPing() {
|
|
46183
46209
|
if (this._pingTimer) {
|
|
46184
46210
|
clearInterval(this._pingTimer);
|
|
46185
46211
|
this._pingTimer = null;
|
|
46186
46212
|
}
|
|
46187
|
-
if (this._pingTimeout) {
|
|
46188
|
-
clearTimeout(this._pingTimeout);
|
|
46189
|
-
this._pingTimeout = null;
|
|
46190
|
-
}
|
|
46191
46213
|
}
|
|
46192
46214
|
_scheduleReconnect() {
|
|
46193
46215
|
if (this._stopped) return;
|
|
@@ -46496,7 +46518,7 @@ async function runSetupCommand(options) {
|
|
|
46496
46518
|
}
|
|
46497
46519
|
function installPlugin(env) {
|
|
46498
46520
|
try {
|
|
46499
|
-
const info = execSync("openclaw plugins info
|
|
46521
|
+
const info = execSync("openclaw plugins info agentvault", {
|
|
46500
46522
|
stdio: "pipe",
|
|
46501
46523
|
env
|
|
46502
46524
|
});
|
|
@@ -46505,7 +46527,7 @@ function installPlugin(env) {
|
|
|
46505
46527
|
const installedVersion = versionMatch?.[1];
|
|
46506
46528
|
if (installedVersion && installedVersion !== VERSION) {
|
|
46507
46529
|
console.log(` Updating plugin ${installedVersion} \u2192 ${VERSION}...`);
|
|
46508
|
-
spawnSync("openclaw", ["plugins", "uninstall", "
|
|
46530
|
+
spawnSync("openclaw", ["plugins", "uninstall", "agentvault"], {
|
|
46509
46531
|
stdio: "pipe",
|
|
46510
46532
|
input: "y\n",
|
|
46511
46533
|
env
|