@agentvault/agentvault 0.13.7 → 0.13.9

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
@@ -5,5 +5,5 @@ export type { ResolvedAccount } from "./account-config.js";
5
5
  export { agentVaultPlugin, setOcRuntime, getActiveChannel } from "./openclaw-plugin.js";
6
6
  export { sendToOwner, checkGateway } from "./gateway-send.js";
7
7
  export type { GatewaySendOptions, GatewaySendResult, GatewayStatusResult, } from "./gateway-send.js";
8
- export declare const VERSION = "0.13.7";
8
+ export declare const VERSION = "0.13.9";
9
9
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -45447,10 +45447,12 @@ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
45447
45447
  import { join } from "node:path";
45448
45448
  var STATE_FILE = "agentvault.json";
45449
45449
  var LEGACY_STATE_FILE = "secure-channel.json";
45450
+ var DIR_MODE = 448;
45451
+ var FILE_MODE = 384;
45450
45452
  async function saveState(dataDir, state) {
45451
- await mkdir(dataDir, { recursive: true });
45453
+ await mkdir(dataDir, { recursive: true, mode: DIR_MODE });
45452
45454
  const filePath = join(dataDir, STATE_FILE);
45453
- await writeFile(filePath, JSON.stringify(state, null, 2), "utf-8");
45455
+ await writeFile(filePath, JSON.stringify(state, null, 2), { encoding: "utf-8", mode: FILE_MODE });
45454
45456
  try {
45455
45457
  await rm(join(dataDir, LEGACY_STATE_FILE));
45456
45458
  } catch {
@@ -45467,8 +45469,8 @@ async function loadState(dataDir) {
45467
45469
  try {
45468
45470
  const raw = await readFile(legacyPath, "utf-8");
45469
45471
  const parsed = JSON.parse(raw);
45470
- await mkdir(dataDir, { recursive: true });
45471
- await writeFile(filePath, JSON.stringify(parsed, null, 2), "utf-8");
45472
+ await mkdir(dataDir, { recursive: true, mode: DIR_MODE });
45473
+ await writeFile(filePath, JSON.stringify(parsed, null, 2), { encoding: "utf-8", mode: FILE_MODE });
45472
45474
  await rm(legacyPath);
45473
45475
  return parsed;
45474
45476
  } catch {
@@ -45491,7 +45493,7 @@ async function backupState(dataDir) {
45491
45493
  const tmp = join(dataDir, `${STATE_FILE}.bak.tmp`);
45492
45494
  try {
45493
45495
  const data = await readFile(src, "utf-8");
45494
- await writeFile(tmp, data, "utf-8");
45496
+ await writeFile(tmp, data, { encoding: "utf-8", mode: FILE_MODE });
45495
45497
  await rename(tmp, bak);
45496
45498
  } catch {
45497
45499
  }
@@ -45506,8 +45508,8 @@ async function restoreState(dataDir) {
45506
45508
  if (!parsed || !parsed.deviceId || !parsed.deviceJwt || !parsed.sessions || Object.keys(parsed.sessions).length === 0) {
45507
45509
  return false;
45508
45510
  }
45509
- await mkdir(dataDir, { recursive: true });
45510
- await writeFile(join(dataDir, STATE_FILE), data, "utf-8");
45511
+ await mkdir(dataDir, { recursive: true, mode: DIR_MODE });
45512
+ await writeFile(join(dataDir, STATE_FILE), data, { encoding: "utf-8", mode: FILE_MODE });
45511
45513
  return true;
45512
45514
  } catch {
45513
45515
  return false;
@@ -48246,13 +48248,39 @@ var agentVaultPlugin = {
48246
48248
  aliases: ["av", "agent-vault"]
48247
48249
  },
48248
48250
  capabilities: {
48249
- chatTypes: ["direct"]
48251
+ chatTypes: ["direct", "room"]
48250
48252
  },
48251
48253
  config: {
48252
48254
  listAccountIds,
48253
48255
  resolveAccount
48254
48256
  },
48255
48257
  gateway: {
48258
+ /** Health probe for `openclaw channels status --probe` */
48259
+ probe: async (ctx) => {
48260
+ const accountId = ctx?.accountId ?? "default";
48261
+ const ch = _channels.get(accountId);
48262
+ if (!ch) return { ok: false, status: "disconnected", error: "Channel not started" };
48263
+ const state = ch.state;
48264
+ return {
48265
+ ok: state === "ready",
48266
+ status: state,
48267
+ deviceId: ch.deviceId ?? void 0,
48268
+ sessions: ch.sessionCount
48269
+ };
48270
+ },
48271
+ /** Status for `openclaw health --json` per-channel summary */
48272
+ status: (ctx) => {
48273
+ const accountId = ctx?.accountId ?? "default";
48274
+ const ch = _channels.get(accountId);
48275
+ if (!ch) return { connected: false, status: "not_started" };
48276
+ return {
48277
+ connected: ch.state === "ready",
48278
+ status: ch.state,
48279
+ deviceId: ch.deviceId ?? void 0,
48280
+ sessions: ch.sessionCount,
48281
+ encrypted: true
48282
+ };
48283
+ },
48256
48284
  startAccount: async (ctx) => {
48257
48285
  const { account, cfg, log, abortSignal } = ctx;
48258
48286
  if (!account.configured) {
@@ -48262,43 +48290,46 @@ var agentVaultPlugin = {
48262
48290
  }
48263
48291
  const dataDir = resolve(account.dataDir.replace(/^~/, process.env.HOME ?? "~"));
48264
48292
  log?.(`[AgentVault] starting channel (dataDir=${dataDir})`);
48265
- const channel = new SecureChannel({
48266
- // No invite token needed — resuming from persisted enrolled state
48267
- inviteToken: "",
48268
- dataDir,
48269
- apiUrl: account.apiUrl,
48270
- agentName: account.agentName,
48271
- onMessage: async (plaintext, metadata) => {
48272
- if (!_ocRuntime) {
48273
- log?.("[AgentVault] runtime not ready \u2014 dropping inbound message");
48274
- return;
48275
- }
48276
- try {
48277
- await _handleInbound({ plaintext, metadata, channel, account, cfg });
48278
- } catch (err) {
48279
- log?.(`[AgentVault] inbound dispatch error: ${String(err)}`);
48293
+ await new Promise((resolvePromise, reject) => {
48294
+ const channel = new SecureChannel({
48295
+ inviteToken: "",
48296
+ dataDir,
48297
+ apiUrl: account.apiUrl,
48298
+ agentName: account.agentName,
48299
+ onMessage: async (plaintext, metadata) => {
48300
+ if (!_ocRuntime) {
48301
+ log?.("[AgentVault] runtime not ready \u2014 dropping inbound message");
48302
+ return;
48303
+ }
48304
+ try {
48305
+ await _handleInbound({ plaintext, metadata, channel, account, cfg });
48306
+ } catch (err) {
48307
+ log?.(`[AgentVault] inbound dispatch error: ${String(err)}`);
48308
+ }
48309
+ },
48310
+ onStateChange: (state) => {
48311
+ log?.(`[AgentVault] state \u2192 ${state}`);
48312
+ if (state === "error") reject(new Error("AgentVault channel permanent error"));
48280
48313
  }
48281
- },
48282
- onStateChange: (state) => {
48283
- log?.(`[AgentVault] state \u2192 ${state}`);
48284
- }
48285
- });
48286
- _channels.set(account.accountId, channel);
48287
- const httpPort = account.httpPort;
48288
- channel.on("ready", () => {
48289
- channel.startHttpServer(httpPort);
48290
- log?.(`[AgentVault] HTTP send server listening on http://127.0.0.1:${httpPort}`);
48291
- });
48292
- abortSignal?.addEventListener("abort", () => {
48293
- _channels.delete(account.accountId);
48294
- });
48295
- await channel.start();
48296
- return {
48297
- stop: async () => {
48314
+ });
48315
+ _channels.set(account.accountId, channel);
48316
+ channel.on("error", (err) => {
48317
+ log?.(`[AgentVault] channel error (non-fatal): ${String(err)}`);
48318
+ });
48319
+ const httpPort = account.httpPort;
48320
+ channel.on("ready", () => {
48321
+ channel.startHttpServer(httpPort);
48322
+ log?.(`[AgentVault] HTTP send server listening on http://127.0.0.1:${httpPort}`);
48323
+ });
48324
+ abortSignal?.addEventListener("abort", async () => {
48298
48325
  await channel.stop();
48299
48326
  _channels.delete(account.accountId);
48300
- }
48301
- };
48327
+ resolvePromise();
48328
+ });
48329
+ channel.start().catch(reject);
48330
+ });
48331
+ return { stop: async () => {
48332
+ } };
48302
48333
  }
48303
48334
  },
48304
48335
  outbound: {
@@ -48331,6 +48362,25 @@ var agentVaultPlugin = {
48331
48362
  } catch (err) {
48332
48363
  return { ok: false, error: String(err) };
48333
48364
  }
48365
+ },
48366
+ sendMedia: async ({
48367
+ text,
48368
+ mediaUrl,
48369
+ accountId
48370
+ }) => {
48371
+ const resolvedId = accountId ?? "default";
48372
+ const channel = _channels.get(resolvedId);
48373
+ if (!channel) {
48374
+ return { ok: false, error: "AgentVault channel is not connected" };
48375
+ }
48376
+ try {
48377
+ const message = text ? `${text}
48378
+ ${mediaUrl}` : mediaUrl;
48379
+ await channel.send(message);
48380
+ return { ok: true };
48381
+ } catch (err) {
48382
+ return { ok: false, error: String(err) };
48383
+ }
48334
48384
  }
48335
48385
  }
48336
48386
  };
@@ -48463,7 +48513,7 @@ async function checkGateway(options) {
48463
48513
  }
48464
48514
 
48465
48515
  // src/index.ts
48466
- var VERSION = "0.13.7";
48516
+ var VERSION = "0.13.9";
48467
48517
  export {
48468
48518
  SecureChannel,
48469
48519
  VERSION,