@agentvault/secure-channel 0.6.19 → 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 +15 -1
- package/dist/channel.d.ts.map +1 -1
- package/dist/cli.js +65 -0
- 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 +65 -0
- package/dist/index.js.map +3 -3
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -1
- 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, SendOptions, } 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,EACZ,WAAW,
|
|
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
|
@@ -45276,6 +45276,71 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
|
|
|
45276
45276
|
);
|
|
45277
45277
|
}
|
|
45278
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
|
+
}
|
|
45279
45344
|
async stop() {
|
|
45280
45345
|
this._stopped = true;
|
|
45281
45346
|
this._flushAcks();
|