@agentvault/agentvault 0.8.0 → 0.9.0

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=install-plugin.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-plugin.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/install-plugin.test.ts"],"names":[],"mappings":""}
package/dist/cli.js CHANGED
@@ -45151,21 +45151,7 @@ var init_merkle = __esm({
45151
45151
  }
45152
45152
  });
45153
45153
 
45154
- // ../crypto/dist/index.js
45155
- var init_dist = __esm({
45156
- async "../crypto/dist/index.js"() {
45157
- "use strict";
45158
- await init_keys();
45159
- await init_x3dh();
45160
- await init_ratchet();
45161
- await init_file_crypto();
45162
- await init_did();
45163
- init_scan_engine();
45164
- await init_merkle();
45165
- }
45166
- });
45167
-
45168
- // src/crypto-helpers.ts
45154
+ // ../crypto/dist/transport.js
45169
45155
  function hexToBytes(hex) {
45170
45156
  return libsodium_wrappers_default.from_hex(hex);
45171
45157
  }
@@ -45187,18 +45173,14 @@ function encryptedMessageToTransport(msg) {
45187
45173
  nonce: bytesToBase64(msg.nonce)
45188
45174
  };
45189
45175
  const headerJson = JSON.stringify(headerObj);
45190
- const headerBlob = bytesToBase64(
45191
- new TextEncoder().encode(headerJson)
45192
- );
45176
+ const headerBlob = bytesToBase64(new TextEncoder().encode(headerJson));
45193
45177
  return {
45194
45178
  header_blob: headerBlob,
45195
45179
  ciphertext: bytesToBase64(msg.ciphertext)
45196
45180
  };
45197
45181
  }
45198
45182
  function transportToEncryptedMessage(transport) {
45199
- const headerJson = new TextDecoder().decode(
45200
- base64ToBytes(transport.header_blob)
45201
- );
45183
+ const headerJson = new TextDecoder().decode(base64ToBytes(transport.header_blob));
45202
45184
  const headerObj = JSON.parse(headerJson);
45203
45185
  return {
45204
45186
  header: {
@@ -45211,10 +45193,33 @@ function transportToEncryptedMessage(transport) {
45211
45193
  ciphertext: base64ToBytes(transport.ciphertext)
45212
45194
  };
45213
45195
  }
45196
+ var init_transport = __esm({
45197
+ async "../crypto/dist/transport.js"() {
45198
+ "use strict";
45199
+ await init_libsodium_wrappers();
45200
+ }
45201
+ });
45202
+
45203
+ // ../crypto/dist/index.js
45204
+ var init_dist = __esm({
45205
+ async "../crypto/dist/index.js"() {
45206
+ "use strict";
45207
+ await init_keys();
45208
+ await init_x3dh();
45209
+ await init_ratchet();
45210
+ await init_file_crypto();
45211
+ await init_did();
45212
+ init_scan_engine();
45213
+ await init_merkle();
45214
+ await init_transport();
45215
+ }
45216
+ });
45217
+
45218
+ // src/crypto-helpers.ts
45214
45219
  var init_crypto_helpers = __esm({
45215
45220
  async "src/crypto-helpers.ts"() {
45216
45221
  "use strict";
45217
- await init_libsodium_wrappers();
45222
+ await init_dist();
45218
45223
  }
45219
45224
  });
45220
45225
 
@@ -45308,7 +45313,7 @@ async function activateDevice(apiUrl2, deviceId) {
45308
45313
  }
45309
45314
  return res.json();
45310
45315
  }
45311
- var init_transport = __esm({
45316
+ var init_transport2 = __esm({
45312
45317
  "src/transport.ts"() {
45313
45318
  "use strict";
45314
45319
  }
@@ -45352,7 +45357,7 @@ var init_channel = __esm({
45352
45357
  await init_dist();
45353
45358
  await init_crypto_helpers();
45354
45359
  init_state();
45355
- init_transport();
45360
+ init_transport2();
45356
45361
  POLL_INTERVAL_MS = 6e3;
45357
45362
  RECONNECT_BASE_MS = 1e3;
45358
45363
  RECONNECT_MAX_MS = 3e4;
@@ -47501,6 +47506,68 @@ var init_openclaw_plugin = __esm({
47501
47506
  }
47502
47507
  });
47503
47508
 
47509
+ // src/gateway-send.ts
47510
+ var gateway_send_exports = {};
47511
+ __export(gateway_send_exports, {
47512
+ checkGateway: () => checkGateway,
47513
+ sendToOwner: () => sendToOwner
47514
+ });
47515
+ function resolveBaseUrl(options) {
47516
+ const host = options?.host ?? "127.0.0.1";
47517
+ const port = options?.port ?? (process.env.GATEWAY_SEND_PORT ? Number(process.env.GATEWAY_SEND_PORT) : 18790);
47518
+ return `http://${host}:${port}`;
47519
+ }
47520
+ function friendlyError(err) {
47521
+ if (err instanceof TypeError && String(err.cause ?? err.message).includes("ECONNREFUSED")) {
47522
+ return "Gateway not reachable \u2014 is OpenClaw running?";
47523
+ }
47524
+ return err instanceof Error ? err.message : String(err);
47525
+ }
47526
+ async function sendToOwner(text, options) {
47527
+ if (typeof text !== "string" || text.trim().length === 0) {
47528
+ return { ok: false, error: "Message text must be a non-empty string" };
47529
+ }
47530
+ try {
47531
+ const base = resolveBaseUrl(options);
47532
+ const res = await fetch(`${base}/send`, {
47533
+ method: "POST",
47534
+ headers: { "Content-Type": "application/json" },
47535
+ body: JSON.stringify({ text }),
47536
+ signal: options?.signal
47537
+ });
47538
+ if (!res.ok) {
47539
+ const body = await res.text().catch(() => "");
47540
+ return { ok: false, error: `HTTP ${res.status}${body ? `: ${body}` : ""}` };
47541
+ }
47542
+ return { ok: true };
47543
+ } catch (err) {
47544
+ return { ok: false, error: friendlyError(err) };
47545
+ }
47546
+ }
47547
+ async function checkGateway(options) {
47548
+ try {
47549
+ const base = resolveBaseUrl(options);
47550
+ const res = await fetch(`${base}/status`, { signal: options?.signal });
47551
+ if (!res.ok) {
47552
+ return { ok: false, error: `HTTP ${res.status}` };
47553
+ }
47554
+ const data = await res.json();
47555
+ return {
47556
+ ok: true,
47557
+ state: data.state,
47558
+ deviceId: data.deviceId,
47559
+ sessions: data.sessions
47560
+ };
47561
+ } catch (err) {
47562
+ return { ok: false, error: friendlyError(err) };
47563
+ }
47564
+ }
47565
+ var init_gateway_send = __esm({
47566
+ "src/gateway-send.ts"() {
47567
+ "use strict";
47568
+ }
47569
+ });
47570
+
47504
47571
  // src/index.ts
47505
47572
  var VERSION;
47506
47573
  var init_index = __esm({
@@ -47508,7 +47575,8 @@ var init_index = __esm({
47508
47575
  "use strict";
47509
47576
  await init_channel();
47510
47577
  await init_openclaw_plugin();
47511
- VERSION = "0.7.0";
47578
+ init_gateway_send();
47579
+ VERSION = "0.9.0";
47512
47580
  }
47513
47581
  });
47514
47582
 
@@ -47892,6 +47960,37 @@ if (subcommand === "pm2-setup") {
47892
47960
  configurePm22(env);
47893
47961
  process.exit(0);
47894
47962
  }
47963
+ if (subcommand === "send") {
47964
+ const message = args.slice(1).filter((a2) => !a2.startsWith("--")).join(" ").trim();
47965
+ if (!message) {
47966
+ console.error('Usage: agentvault send "your message here" [--port=PORT]');
47967
+ process.exit(1);
47968
+ }
47969
+ const port = flags["port"] ? Number(flags["port"]) : void 0;
47970
+ const { sendToOwner: sendToOwner2 } = await Promise.resolve().then(() => (init_gateway_send(), gateway_send_exports));
47971
+ const result = await sendToOwner2(message, { port });
47972
+ if (result.ok) {
47973
+ console.log("Sent.");
47974
+ } else {
47975
+ console.error(`Failed: ${result.error}`);
47976
+ process.exit(1);
47977
+ }
47978
+ process.exit(0);
47979
+ }
47980
+ if (subcommand === "status") {
47981
+ const port = flags["port"] ? Number(flags["port"]) : void 0;
47982
+ const { checkGateway: checkGateway2 } = await Promise.resolve().then(() => (init_gateway_send(), gateway_send_exports));
47983
+ const result = await checkGateway2({ port });
47984
+ if (result.ok) {
47985
+ console.log(` State: ${result.state ?? "unknown"}`);
47986
+ console.log(` Device: ${result.deviceId ?? "unknown"}`);
47987
+ console.log(` Sessions: ${result.sessions ?? 0}`);
47988
+ } else {
47989
+ console.error(`Failed: ${result.error}`);
47990
+ process.exit(1);
47991
+ }
47992
+ process.exit(0);
47993
+ }
47895
47994
  if (!token) {
47896
47995
  console.error(`
47897
47996
  AgentVault Secure Channel CLI
@@ -47899,6 +47998,8 @@ AgentVault Secure Channel CLI
47899
47998
  Usage:
47900
47999
  npx @agentvault/agentvault setup --token=TOKEN # First-time OpenClaw setup
47901
48000
  npx @agentvault/agentvault pm2-setup # Configure pm2 (existing install)
48001
+ npx @agentvault/agentvault send "message" # Send a message to the owner
48002
+ npx @agentvault/agentvault status # Check gateway status
47902
48003
  npx @agentvault/agentvault --token=TOKEN # Standalone interactive CLI
47903
48004
 
47904
48005
  Options:
@@ -47908,6 +48009,7 @@ Options:
47908
48009
  --api-url=URL API endpoint (default: https://api.agentvault.chat)
47909
48010
  --webhook-url=URL URL for HTTP webhook notifications on new messages
47910
48011
  --no-notifications Disable OS desktop notifications
48012
+ --port=PORT Gateway port for send/status (default: 18790)
47911
48013
 
47912
48014
  Environment variables:
47913
48015
  AGENTVAULT_INVITE_TOKEN Same as --token
@@ -47916,11 +48018,18 @@ Environment variables:
47916
48018
  AGENTVAULT_API_URL Same as --api-url
47917
48019
  AGENTVAULT_WEBHOOK_URL Same as --webhook-url
47918
48020
  AGENTVAULT_NO_NOTIFICATIONS Set to "1" to disable desktop notifications
48021
+ GATEWAY_SEND_PORT Same as --port for send/status
47919
48022
 
47920
48023
  Examples:
47921
48024
  # One-time OpenClaw setup (recommended):
47922
48025
  npx @agentvault/agentvault setup --token=av_tok_abc123
47923
48026
 
48027
+ # Send a message to the owner:
48028
+ npx @agentvault/agentvault send "Hello from the agent"
48029
+
48030
+ # Check gateway status:
48031
+ npx @agentvault/agentvault status
48032
+
47924
48033
  # Standalone interactive CLI:
47925
48034
  npx @agentvault/agentvault --token=av_tok_abc123 --name="My Agent"
47926
48035
  `);