@agentvault/secure-channel 0.6.18 → 0.6.20
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 +21 -4
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +97 -4
- package/dist/cli.js.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -2
- package/dist/index.js.map +3 -3
- 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 +40 -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, DecisionOption, DecisionRequest, DecisionResponse, ContextRef, } 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,EACX,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,UAAU,GACX,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
|
@@ -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,86 @@ 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
|
+
}
|
|
45279
|
+
/**
|
|
45280
|
+
* Send a decision request to the owner.
|
|
45281
|
+
* Builds a structured envelope with decision metadata and sends it
|
|
45282
|
+
* as a high-priority message. Returns the generated decision_id.
|
|
45283
|
+
*/
|
|
45284
|
+
async sendDecisionRequest(request) {
|
|
45285
|
+
const decision_id = `dec_${randomUUID().replace(/-/g, "").slice(0, 16)}`;
|
|
45286
|
+
const payload = JSON.stringify({
|
|
45287
|
+
type: "message",
|
|
45288
|
+
text: `\u{1F4CB} ${request.title}`,
|
|
45289
|
+
decision: {
|
|
45290
|
+
decision_id,
|
|
45291
|
+
...request
|
|
45292
|
+
}
|
|
45293
|
+
});
|
|
45294
|
+
await this.send(payload, {
|
|
45295
|
+
messageType: "decision_request",
|
|
45296
|
+
priority: "high",
|
|
45297
|
+
metadata: {
|
|
45298
|
+
decision_id,
|
|
45299
|
+
title: request.title,
|
|
45300
|
+
description: request.description,
|
|
45301
|
+
options: request.options,
|
|
45302
|
+
context_refs: request.context_refs,
|
|
45303
|
+
deadline: request.deadline,
|
|
45304
|
+
auto_action: request.auto_action
|
|
45305
|
+
}
|
|
45306
|
+
});
|
|
45307
|
+
return decision_id;
|
|
45308
|
+
}
|
|
45309
|
+
/**
|
|
45310
|
+
* Wait for a decision response matching the given decisionId.
|
|
45311
|
+
* Listens on the "message" event for messages where
|
|
45312
|
+
* metadata.messageType === "decision_response" and the parsed plaintext
|
|
45313
|
+
* contains a matching decision.decision_id.
|
|
45314
|
+
* Optional timeout rejects with an Error.
|
|
45315
|
+
*/
|
|
45316
|
+
waitForDecision(decisionId, timeoutMs) {
|
|
45317
|
+
return new Promise((resolve2, reject) => {
|
|
45318
|
+
let timer = null;
|
|
45319
|
+
const handler = (plaintext, metadata) => {
|
|
45320
|
+
if (metadata.messageType !== "decision_response") return;
|
|
45321
|
+
try {
|
|
45322
|
+
const parsed = JSON.parse(plaintext);
|
|
45323
|
+
if (parsed.decision?.decision_id === decisionId) {
|
|
45324
|
+
if (timer) clearTimeout(timer);
|
|
45325
|
+
this.removeListener("message", handler);
|
|
45326
|
+
resolve2({
|
|
45327
|
+
decision_id: parsed.decision.decision_id,
|
|
45328
|
+
selected_option_id: parsed.decision.selected_option_id,
|
|
45329
|
+
resolved_at: parsed.decision.resolved_at
|
|
45330
|
+
});
|
|
45331
|
+
}
|
|
45332
|
+
} catch {
|
|
45333
|
+
}
|
|
45334
|
+
};
|
|
45335
|
+
this.on("message", handler);
|
|
45336
|
+
if (timeoutMs !== void 0) {
|
|
45337
|
+
timer = setTimeout(() => {
|
|
45338
|
+
this.removeListener("message", handler);
|
|
45339
|
+
reject(new Error(`Decision ${decisionId} timed out after ${timeoutMs}ms`));
|
|
45340
|
+
}, timeoutMs);
|
|
45341
|
+
}
|
|
45342
|
+
});
|
|
45343
|
+
}
|
|
45256
45344
|
async stop() {
|
|
45257
45345
|
this._stopped = true;
|
|
45258
45346
|
this._flushAcks();
|
|
@@ -45735,7 +45823,12 @@ ${messageText}`;
|
|
|
45735
45823
|
conversationId: convId,
|
|
45736
45824
|
timestamp: msgData.created_at,
|
|
45737
45825
|
topicId,
|
|
45738
|
-
attachment: attachData
|
|
45826
|
+
attachment: attachData,
|
|
45827
|
+
spanId: msgData.span_id,
|
|
45828
|
+
parentSpanId: msgData.parent_span_id,
|
|
45829
|
+
messageType: msgData.message_type ?? "text",
|
|
45830
|
+
priority: msgData.priority ?? "normal",
|
|
45831
|
+
envelopeVersion: msgData.envelope_version ?? "1.0.0"
|
|
45739
45832
|
};
|
|
45740
45833
|
this.emit("message", emitText, metadata);
|
|
45741
45834
|
this.config.onMessage?.(emitText, metadata);
|