@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 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, DecisionRequest, DecisionResponse } from "./types.js";
3
3
  export declare class SecureChannel extends EventEmitter {
4
4
  private config;
5
5
  private _state;
@@ -44,9 +44,26 @@ 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
- topicId?: string;
49
- }): Promise<void>;
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;
53
+ /**
54
+ * Send a decision request to the owner.
55
+ * Builds a structured envelope with decision metadata and sends it
56
+ * as a high-priority message. Returns the generated decision_id.
57
+ */
58
+ sendDecisionRequest(request: DecisionRequest): Promise<string>;
59
+ /**
60
+ * Wait for a decision response matching the given decisionId.
61
+ * Listens on the "message" event for messages where
62
+ * metadata.messageType === "decision_response" and the parsed plaintext
63
+ * contains a matching decision.decision_id.
64
+ * Optional timeout rejects with an Error.
65
+ */
66
+ waitForDecision(decisionId: string, timeoutMs?: number): Promise<DecisionResponse>;
50
67
  stop(): Promise<void>;
51
68
  startHttpServer(port: number): void;
52
69
  private _stopHttpServer;
@@ -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,EAMb,MAAM,YAAY,CAAC;AAmDpB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;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;YAiCtE,OAAO;IAgDrB,OAAO,CAAC,KAAK;YAsCC,SAAS;IAyIvB,OAAO,CAAC,QAAQ;IAgFhB;;;;OAIG;YACW,sBAAsB;IAsJpC;;;OAGG;YACW,6BAA6B;IA6C3C;;;OAGG;YACW,iBAAiB;IAwD/B;;;OAGG;IACG,kBAAkB,CACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,IAAI,CAAC;IA8ChB;;;OAGG;YACW,oBAAoB;IAqClC;;;OAGG;YACW,uBAAuB;IAkCrC;;;;OAIG;YACW,mBAAmB;IAkEjC;;;OAGG;IACH;;;OAGG;YACW,mBAAmB;IA8GjC,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,UAAU;YAMJ,mBAAmB;IAmCjC,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,kBAAkB;IAiH1B,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,YAAY;IAKpB;;;OAGG;YACW,aAAa;CAc5B"}
package/dist/cli.js CHANGED
@@ -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,86 @@ 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
+ }
45348
+ /**
45349
+ * Send a decision request to the owner.
45350
+ * Builds a structured envelope with decision metadata and sends it
45351
+ * as a high-priority message. Returns the generated decision_id.
45352
+ */
45353
+ async sendDecisionRequest(request) {
45354
+ const decision_id = `dec_${randomUUID().replace(/-/g, "").slice(0, 16)}`;
45355
+ const payload = JSON.stringify({
45356
+ type: "message",
45357
+ text: `\u{1F4CB} ${request.title}`,
45358
+ decision: {
45359
+ decision_id,
45360
+ ...request
45361
+ }
45362
+ });
45363
+ await this.send(payload, {
45364
+ messageType: "decision_request",
45365
+ priority: "high",
45366
+ metadata: {
45367
+ decision_id,
45368
+ title: request.title,
45369
+ description: request.description,
45370
+ options: request.options,
45371
+ context_refs: request.context_refs,
45372
+ deadline: request.deadline,
45373
+ auto_action: request.auto_action
45374
+ }
45375
+ });
45376
+ return decision_id;
45377
+ }
45378
+ /**
45379
+ * Wait for a decision response matching the given decisionId.
45380
+ * Listens on the "message" event for messages where
45381
+ * metadata.messageType === "decision_response" and the parsed plaintext
45382
+ * contains a matching decision.decision_id.
45383
+ * Optional timeout rejects with an Error.
45384
+ */
45385
+ waitForDecision(decisionId, timeoutMs) {
45386
+ return new Promise((resolve3, reject) => {
45387
+ let timer = null;
45388
+ const handler = (plaintext, metadata) => {
45389
+ if (metadata.messageType !== "decision_response") return;
45390
+ try {
45391
+ const parsed = JSON.parse(plaintext);
45392
+ if (parsed.decision?.decision_id === decisionId) {
45393
+ if (timer) clearTimeout(timer);
45394
+ this.removeListener("message", handler);
45395
+ resolve3({
45396
+ decision_id: parsed.decision.decision_id,
45397
+ selected_option_id: parsed.decision.selected_option_id,
45398
+ resolved_at: parsed.decision.resolved_at
45399
+ });
45400
+ }
45401
+ } catch {
45402
+ }
45403
+ };
45404
+ this.on("message", handler);
45405
+ if (timeoutMs !== void 0) {
45406
+ timer = setTimeout(() => {
45407
+ this.removeListener("message", handler);
45408
+ reject(new Error(`Decision ${decisionId} timed out after ${timeoutMs}ms`));
45409
+ }, timeoutMs);
45410
+ }
45411
+ });
45412
+ }
45325
45413
  async stop() {
45326
45414
  this._stopped = true;
45327
45415
  this._flushAcks();
@@ -45804,7 +45892,12 @@ ${messageText}`;
45804
45892
  conversationId: convId,
45805
45893
  timestamp: msgData.created_at,
45806
45894
  topicId,
45807
- attachment: attachData
45895
+ attachment: attachData,
45896
+ spanId: msgData.span_id,
45897
+ parentSpanId: msgData.parent_span_id,
45898
+ messageType: msgData.message_type ?? "text",
45899
+ priority: msgData.priority ?? "normal",
45900
+ envelopeVersion: msgData.envelope_version ?? "1.0.0"
45808
45901
  };
45809
45902
  this.emit("message", emitText, metadata);
45810
45903
  this.config.onMessage?.(emitText, metadata);
@@ -46490,7 +46583,7 @@ async function runSetupCommand(options) {
46490
46583
  }
46491
46584
  function installPlugin(env) {
46492
46585
  try {
46493
- const info = execSync("openclaw plugins info secure-channel", {
46586
+ const info = execSync("openclaw plugins info agentvault", {
46494
46587
  stdio: "pipe",
46495
46588
  env
46496
46589
  });
@@ -46499,7 +46592,7 @@ function installPlugin(env) {
46499
46592
  const installedVersion = versionMatch?.[1];
46500
46593
  if (installedVersion && installedVersion !== VERSION) {
46501
46594
  console.log(` Updating plugin ${installedVersion} \u2192 ${VERSION}...`);
46502
- spawnSync("openclaw", ["plugins", "uninstall", "secure-channel"], {
46595
+ spawnSync("openclaw", ["plugins", "uninstall", "agentvault"], {
46503
46596
  stdio: "pipe",
46504
46597
  input: "y\n",
46505
46598
  env