@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/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { SecureChannel } from "./channel.js";
|
|
2
|
-
export type { SecureChannelConfig, ChannelState, MessageMetadata, AttachmentData, PersistedState, LegacyPersistedState, DeviceSession, HistoryEntry, } from "./types.js";
|
|
2
|
+
export type { SecureChannelConfig, ChannelState, MessageMetadata, AttachmentData, PersistedState, LegacyPersistedState, DeviceSession, HistoryEntry, SendOptions, } from "./types.js";
|
|
3
3
|
export { agentVaultPlugin, setOcRuntime, getActiveChannel } from "./openclaw-plugin.js";
|
|
4
4
|
export declare const VERSION = "0.6.13";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExF,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -45113,7 +45113,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45113
45113
|
_reconnectAttempt = 0;
|
|
45114
45114
|
_reconnectTimer = null;
|
|
45115
45115
|
_pingTimer = null;
|
|
45116
|
-
|
|
45116
|
+
_lastServerMessage = 0;
|
|
45117
45117
|
_pendingAcks = [];
|
|
45118
45118
|
_ackTimer = null;
|
|
45119
45119
|
_stopped = false;
|
|
@@ -45121,10 +45121,10 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45121
45121
|
_httpServer = null;
|
|
45122
45122
|
_pollFallbackTimer = null;
|
|
45123
45123
|
_syncMessageIds = null;
|
|
45124
|
+
// Liveness detection: server sends app-level {"event":"ping"} every 30s.
|
|
45125
|
+
// We check every 30s; if no data received in 90s (3 missed pings), connection is dead.
|
|
45124
45126
|
static PING_INTERVAL_MS = 3e4;
|
|
45125
|
-
|
|
45126
|
-
static PING_TIMEOUT_MS = 1e4;
|
|
45127
|
-
// Treat as dead if no pong within 10s
|
|
45127
|
+
static SILENCE_TIMEOUT_MS = 9e4;
|
|
45128
45128
|
static POLL_FALLBACK_INTERVAL_MS = 3e4;
|
|
45129
45129
|
// 30s when messages found
|
|
45130
45130
|
static POLL_FALLBACK_IDLE_MS = 6e4;
|
|
@@ -45213,6 +45213,10 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45213
45213
|
throw new Error("No active sessions");
|
|
45214
45214
|
}
|
|
45215
45215
|
const topicId = options?.topicId ?? this._persisted?.defaultTopicId;
|
|
45216
|
+
const messageType = options?.messageType ?? "text";
|
|
45217
|
+
const priority = options?.priority ?? "normal";
|
|
45218
|
+
const parentSpanId = options?.parentSpanId;
|
|
45219
|
+
const envelopeMetadata = options?.metadata;
|
|
45216
45220
|
this._appendHistory("agent", plaintext, topicId);
|
|
45217
45221
|
const messageGroupId = randomUUID();
|
|
45218
45222
|
for (const [convId, session] of this._sessions) {
|
|
@@ -45235,7 +45239,11 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45235
45239
|
header_blob: msg.headerBlob,
|
|
45236
45240
|
ciphertext: msg.ciphertext,
|
|
45237
45241
|
message_group_id: msg.messageGroupId,
|
|
45238
|
-
topic_id: msg.topicId
|
|
45242
|
+
topic_id: msg.topicId,
|
|
45243
|
+
message_type: messageType,
|
|
45244
|
+
priority,
|
|
45245
|
+
parent_span_id: parentSpanId,
|
|
45246
|
+
metadata: envelopeMetadata
|
|
45239
45247
|
}
|
|
45240
45248
|
})
|
|
45241
45249
|
);
|
|
@@ -45253,6 +45261,21 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45253
45261
|
}
|
|
45254
45262
|
await this._persistState();
|
|
45255
45263
|
}
|
|
45264
|
+
/**
|
|
45265
|
+
* Send a typing indicator to all owner devices.
|
|
45266
|
+
* Ephemeral (unencrypted metadata), no ratchet advancement.
|
|
45267
|
+
*/
|
|
45268
|
+
sendTyping() {
|
|
45269
|
+
if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
|
|
45270
|
+
for (const convId of this._sessions.keys()) {
|
|
45271
|
+
this._ws.send(
|
|
45272
|
+
JSON.stringify({
|
|
45273
|
+
event: "typing",
|
|
45274
|
+
data: { conversation_id: convId }
|
|
45275
|
+
})
|
|
45276
|
+
);
|
|
45277
|
+
}
|
|
45278
|
+
}
|
|
45256
45279
|
async stop() {
|
|
45257
45280
|
this._stopped = true;
|
|
45258
45281
|
this._flushAcks();
|
|
@@ -45605,6 +45628,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45605
45628
|
this.emit("ready");
|
|
45606
45629
|
});
|
|
45607
45630
|
ws.on("message", async (raw) => {
|
|
45631
|
+
this._lastServerMessage = Date.now();
|
|
45608
45632
|
try {
|
|
45609
45633
|
const data = JSON.parse(raw.toString());
|
|
45610
45634
|
if (data.event === "ping") {
|
|
@@ -45734,7 +45758,12 @@ ${messageText}`;
|
|
|
45734
45758
|
conversationId: convId,
|
|
45735
45759
|
timestamp: msgData.created_at,
|
|
45736
45760
|
topicId,
|
|
45737
|
-
attachment: attachData
|
|
45761
|
+
attachment: attachData,
|
|
45762
|
+
spanId: msgData.span_id,
|
|
45763
|
+
parentSpanId: msgData.parent_span_id,
|
|
45764
|
+
messageType: msgData.message_type ?? "text",
|
|
45765
|
+
priority: msgData.priority ?? "normal",
|
|
45766
|
+
envelopeVersion: msgData.envelope_version ?? "1.0.0"
|
|
45738
45767
|
};
|
|
45739
45768
|
this.emit("message", emitText, metadata);
|
|
45740
45769
|
this.config.onMessage?.(emitText, metadata);
|
|
@@ -46095,30 +46124,23 @@ ${messageText}`;
|
|
|
46095
46124
|
}
|
|
46096
46125
|
_startPing(ws) {
|
|
46097
46126
|
this._stopPing();
|
|
46127
|
+
this._lastServerMessage = Date.now();
|
|
46098
46128
|
this._pingTimer = setInterval(() => {
|
|
46099
46129
|
if (ws.readyState !== WebSocket.OPEN) return;
|
|
46100
|
-
|
|
46101
|
-
|
|
46130
|
+
const silence = Date.now() - this._lastServerMessage;
|
|
46131
|
+
if (silence > _SecureChannel.SILENCE_TIMEOUT_MS) {
|
|
46132
|
+
console.log(
|
|
46133
|
+
`[SecureChannel] No server data for ${Math.round(silence / 1e3)}s \u2014 reconnecting stale WebSocket`
|
|
46134
|
+
);
|
|
46102
46135
|
ws.terminate();
|
|
46103
|
-
}, _SecureChannel.PING_TIMEOUT_MS);
|
|
46104
|
-
ws.ping();
|
|
46105
|
-
}, _SecureChannel.PING_INTERVAL_MS);
|
|
46106
|
-
ws.on("pong", () => {
|
|
46107
|
-
if (this._pingTimeout) {
|
|
46108
|
-
clearTimeout(this._pingTimeout);
|
|
46109
|
-
this._pingTimeout = null;
|
|
46110
46136
|
}
|
|
46111
|
-
});
|
|
46137
|
+
}, _SecureChannel.PING_INTERVAL_MS);
|
|
46112
46138
|
}
|
|
46113
46139
|
_stopPing() {
|
|
46114
46140
|
if (this._pingTimer) {
|
|
46115
46141
|
clearInterval(this._pingTimer);
|
|
46116
46142
|
this._pingTimer = null;
|
|
46117
46143
|
}
|
|
46118
|
-
if (this._pingTimeout) {
|
|
46119
|
-
clearTimeout(this._pingTimeout);
|
|
46120
|
-
this._pingTimeout = null;
|
|
46121
|
-
}
|
|
46122
46144
|
}
|
|
46123
46145
|
_scheduleReconnect() {
|
|
46124
46146
|
if (this._stopped) return;
|