@agentvault/secure-channel 0.6.10 → 0.6.12

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { SecureChannel } from "./channel.js";
2
2
  export type { SecureChannelConfig, ChannelState, MessageMetadata, PersistedState, LegacyPersistedState, DeviceSession, HistoryEntry, } from "./types.js";
3
3
  export { agentVaultPlugin, setOcRuntime, getActiveChannel } from "./openclaw-plugin.js";
4
- export declare const VERSION = "0.5.1";
4
+ export declare const VERSION = "0.6.12";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -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,oBAAoB,EACpB,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExF,eAAO,MAAM,OAAO,UAAU,CAAC"}
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,oBAAoB,EACpB,aAAa,EACb,YAAY,GACb,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
@@ -1,5 +1,6 @@
1
1
  // src/channel.ts
2
2
  import { EventEmitter } from "node:events";
3
+ import { createServer } from "node:http";
3
4
  import { randomUUID } from "node:crypto";
4
5
 
5
6
  // ../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs
@@ -45081,6 +45082,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
45081
45082
  _ackTimer = null;
45082
45083
  _stopped = false;
45083
45084
  _persisted = null;
45085
+ _httpServer = null;
45084
45086
  static PING_INTERVAL_MS = 3e4;
45085
45087
  // Send ping every 30s
45086
45088
  static PING_TIMEOUT_MS = 1e4;
@@ -45193,6 +45195,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
45193
45195
  this._stopped = true;
45194
45196
  this._flushAcks();
45195
45197
  this._stopPing();
45198
+ this._stopHttpServer();
45196
45199
  if (this._ackTimer) {
45197
45200
  clearTimeout(this._ackTimer);
45198
45201
  this._ackTimer = null;
@@ -45212,6 +45215,61 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
45212
45215
  }
45213
45216
  this._setState("disconnected");
45214
45217
  }
45218
+ // --- Local HTTP server for proactive sends ---
45219
+ startHttpServer(port) {
45220
+ if (this._httpServer) return;
45221
+ this._httpServer = createServer(async (req, res) => {
45222
+ const remote = req.socket.remoteAddress;
45223
+ if (remote !== "127.0.0.1" && remote !== "::1" && remote !== "::ffff:127.0.0.1") {
45224
+ res.writeHead(403, { "Content-Type": "application/json" });
45225
+ res.end(JSON.stringify({ ok: false, error: "Forbidden" }));
45226
+ return;
45227
+ }
45228
+ if (req.method === "POST" && req.url === "/send") {
45229
+ let body = "";
45230
+ req.on("data", (chunk) => {
45231
+ body += chunk.toString();
45232
+ });
45233
+ req.on("end", async () => {
45234
+ try {
45235
+ const parsed = JSON.parse(body);
45236
+ const text = parsed.text;
45237
+ if (!text || typeof text !== "string") {
45238
+ res.writeHead(400, { "Content-Type": "application/json" });
45239
+ res.end(JSON.stringify({ ok: false, error: "Missing 'text' field" }));
45240
+ return;
45241
+ }
45242
+ await this.send(text, { topicId: parsed.topicId });
45243
+ res.writeHead(200, { "Content-Type": "application/json" });
45244
+ res.end(JSON.stringify({ ok: true }));
45245
+ } catch (err) {
45246
+ res.writeHead(500, { "Content-Type": "application/json" });
45247
+ res.end(JSON.stringify({ ok: false, error: String(err) }));
45248
+ }
45249
+ });
45250
+ } else if (req.method === "GET" && req.url === "/status") {
45251
+ res.writeHead(200, { "Content-Type": "application/json" });
45252
+ res.end(JSON.stringify({
45253
+ ok: true,
45254
+ state: this._state,
45255
+ deviceId: this._deviceId,
45256
+ sessions: this._sessions.size
45257
+ }));
45258
+ } else {
45259
+ res.writeHead(404, { "Content-Type": "application/json" });
45260
+ res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send or GET /status" }));
45261
+ }
45262
+ });
45263
+ this._httpServer.listen(port, "127.0.0.1", () => {
45264
+ this.emit("http-ready", port);
45265
+ });
45266
+ }
45267
+ _stopHttpServer() {
45268
+ if (this._httpServer) {
45269
+ this._httpServer.close();
45270
+ this._httpServer = null;
45271
+ }
45272
+ }
45215
45273
  // --- Topic management ---
45216
45274
  /**
45217
45275
  * Create a new topic within the conversation group.
@@ -45862,6 +45920,7 @@ var agentVaultPlugin = {
45862
45920
  dataDir: av.dataDir ?? "~/.openclaw/agentvault",
45863
45921
  apiUrl: av.apiUrl ?? "https://api.agentvault.chat",
45864
45922
  agentName: av.agentName ?? "OpenClaw Agent",
45923
+ httpPort: av.httpPort ?? 18790,
45865
45924
  configured: Boolean(av.dataDir)
45866
45925
  };
45867
45926
  }
@@ -45898,6 +45957,11 @@ var agentVaultPlugin = {
45898
45957
  }
45899
45958
  });
45900
45959
  _channels.set(account.accountId, channel);
45960
+ const httpPort = account.httpPort;
45961
+ channel.on("ready", () => {
45962
+ channel.startHttpServer(httpPort);
45963
+ log?.(`[AgentVault] HTTP send server listening on http://127.0.0.1:${httpPort}`);
45964
+ });
45901
45965
  abortSignal?.addEventListener("abort", () => {
45902
45966
  _channels.delete(account.accountId);
45903
45967
  });
@@ -45912,11 +45976,25 @@ var agentVaultPlugin = {
45912
45976
  },
45913
45977
  outbound: {
45914
45978
  deliveryMode: "direct",
45979
+ targets: [
45980
+ {
45981
+ id: "owner",
45982
+ label: "AgentVault Owner",
45983
+ accountId: "default"
45984
+ },
45985
+ {
45986
+ id: "default",
45987
+ label: "AgentVault Owner (default)",
45988
+ accountId: "default"
45989
+ }
45990
+ ],
45915
45991
  sendText: async ({
45916
45992
  text,
45917
- accountId
45993
+ accountId,
45994
+ targetId
45918
45995
  }) => {
45919
- const channel = _channels.get(accountId ?? "default");
45996
+ const resolvedId = accountId ?? (targetId === "owner" ? "default" : targetId ?? "default");
45997
+ const channel = _channels.get(resolvedId);
45920
45998
  if (!channel) {
45921
45999
  return { ok: false, error: "AgentVault channel is not connected" };
45922
46000
  }
@@ -46006,7 +46084,7 @@ async function _handleInbound(params) {
46006
46084
  }
46007
46085
 
46008
46086
  // src/index.ts
46009
- var VERSION = "0.5.1";
46087
+ var VERSION = "0.6.12";
46010
46088
  export {
46011
46089
  SecureChannel,
46012
46090
  VERSION,