@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.
@@ -1,12 +1,2 @@
1
- import type { EncryptedMessage } from "@agentvault/crypto";
2
- export declare function hexToBytes(hex: string): Uint8Array;
3
- export declare function bytesToHex(bytes: Uint8Array): string;
4
- export declare function base64ToBytes(b64: string): Uint8Array;
5
- export declare function bytesToBase64(bytes: Uint8Array): string;
6
- export interface TransportMessage {
7
- header_blob: string;
8
- ciphertext: string;
9
- }
10
- export declare function encryptedMessageToTransport(msg: EncryptedMessage): TransportMessage;
11
- export declare function transportToEncryptedMessage(transport: TransportMessage): EncryptedMessage;
1
+ export { hexToBytes, bytesToHex, base64ToBytes, bytesToBase64, encryptedMessageToTransport, transportToEncryptedMessage, type TransportMessage, } from "@agentvault/crypto";
12
2
  //# sourceMappingURL=crypto-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-helpers.d.ts","sourceRoot":"","sources":["../src/crypto-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAElD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEpD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAErD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEvD;AAKD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,2BAA2B,CACzC,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAgBlB;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,gBAAgB,GAC1B,gBAAgB,CAelB"}
1
+ {"version":3,"file":"crypto-helpers.d.ts","sourceRoot":"","sources":["../src/crypto-helpers.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,gBAAgB,GACtB,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Gateway send helper — lets agents send messages to their owner
3
+ * via the plugin's local HTTP server (port 18790).
4
+ *
5
+ * Delivery path: sendToOwner() → plugin HTTP /send → SecureChannel.send()
6
+ * → Double Ratchet encrypt → WebSocket → backend → owner's app
7
+ */
8
+ export interface GatewaySendOptions {
9
+ /** Override the gateway port (default: env GATEWAY_SEND_PORT or 18790) */
10
+ port?: number;
11
+ /** Override the gateway host (default: 127.0.0.1) */
12
+ host?: string;
13
+ /** AbortSignal for cancellation */
14
+ signal?: AbortSignal;
15
+ }
16
+ export interface GatewaySendResult {
17
+ ok: boolean;
18
+ error?: string;
19
+ }
20
+ export interface GatewayStatusResult {
21
+ ok: boolean;
22
+ state?: string;
23
+ deviceId?: string;
24
+ sessions?: number;
25
+ error?: string;
26
+ }
27
+ /**
28
+ * Send a plaintext message to the agent's owner via the gateway HTTP server.
29
+ * Never throws — returns `{ ok: false, error }` on failure.
30
+ */
31
+ export declare function sendToOwner(text: string, options?: GatewaySendOptions): Promise<GatewaySendResult>;
32
+ /**
33
+ * Check gateway health / status.
34
+ * Never throws — returns `{ ok: false, error }` on failure.
35
+ */
36
+ export declare function checkGateway(options?: GatewaySendOptions): Promise<GatewayStatusResult>;
37
+ //# sourceMappingURL=gateway-send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway-send.d.ts","sourceRoot":"","sources":["../src/gateway-send.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAsBD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAuB5B;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CAmB9B"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { SecureChannel } from "./channel.js";
2
2
  export type { SecureChannelConfig, ChannelState, MessageMetadata, AttachmentData, PersistedState, LegacyPersistedState, DeviceSession, HistoryEntry, SendOptions, DecisionOption, DecisionRequest, DecisionResponse, ContextRef, HeartbeatStatus, StatusAlert, RoomInfo, RoomMemberInfo, RoomConversationInfo, RoomState, A2AChannel, A2AMessage, RoomParticipantEvent, } from "./types.js";
3
3
  export { agentVaultPlugin, setOcRuntime, getActiveChannel } from "./openclaw-plugin.js";
4
- export declare const VERSION = "0.7.0";
4
+ export { sendToOwner, checkGateway } from "./gateway-send.js";
5
+ export type { GatewaySendOptions, GatewaySendResult, GatewayStatusResult, } from "./gateway-send.js";
6
+ export declare const VERSION = "0.9.0";
5
7
  //# 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,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,WAAW,EACX,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,UAAU,EACV,oBAAoB,GACrB,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,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,WAAW,EACX,QAAQ,EACR,cAAc,EACd,oBAAoB,EACpB,SAAS,EACT,UAAU,EACV,UAAU,EACV,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -45106,7 +45106,7 @@ var ScanEngine = class {
45106
45106
  }
45107
45107
  };
45108
45108
 
45109
- // src/crypto-helpers.ts
45109
+ // ../crypto/dist/transport.js
45110
45110
  function hexToBytes(hex) {
45111
45111
  return libsodium_wrappers_default.from_hex(hex);
45112
45112
  }
@@ -45128,18 +45128,14 @@ function encryptedMessageToTransport(msg) {
45128
45128
  nonce: bytesToBase64(msg.nonce)
45129
45129
  };
45130
45130
  const headerJson = JSON.stringify(headerObj);
45131
- const headerBlob = bytesToBase64(
45132
- new TextEncoder().encode(headerJson)
45133
- );
45131
+ const headerBlob = bytesToBase64(new TextEncoder().encode(headerJson));
45134
45132
  return {
45135
45133
  header_blob: headerBlob,
45136
45134
  ciphertext: bytesToBase64(msg.ciphertext)
45137
45135
  };
45138
45136
  }
45139
45137
  function transportToEncryptedMessage(transport) {
45140
- const headerJson = new TextDecoder().decode(
45141
- base64ToBytes(transport.header_blob)
45142
- );
45138
+ const headerJson = new TextDecoder().decode(base64ToBytes(transport.header_blob));
45143
45139
  const headerObj = JSON.parse(headerJson);
45144
45140
  return {
45145
45141
  header: {
@@ -47597,13 +47593,67 @@ async function _handleInbound(params) {
47597
47593
  });
47598
47594
  }
47599
47595
 
47596
+ // src/gateway-send.ts
47597
+ function resolveBaseUrl(options) {
47598
+ const host = options?.host ?? "127.0.0.1";
47599
+ const port = options?.port ?? (process.env.GATEWAY_SEND_PORT ? Number(process.env.GATEWAY_SEND_PORT) : 18790);
47600
+ return `http://${host}:${port}`;
47601
+ }
47602
+ function friendlyError(err) {
47603
+ if (err instanceof TypeError && String(err.cause ?? err.message).includes("ECONNREFUSED")) {
47604
+ return "Gateway not reachable \u2014 is OpenClaw running?";
47605
+ }
47606
+ return err instanceof Error ? err.message : String(err);
47607
+ }
47608
+ async function sendToOwner(text, options) {
47609
+ if (typeof text !== "string" || text.trim().length === 0) {
47610
+ return { ok: false, error: "Message text must be a non-empty string" };
47611
+ }
47612
+ try {
47613
+ const base = resolveBaseUrl(options);
47614
+ const res = await fetch(`${base}/send`, {
47615
+ method: "POST",
47616
+ headers: { "Content-Type": "application/json" },
47617
+ body: JSON.stringify({ text }),
47618
+ signal: options?.signal
47619
+ });
47620
+ if (!res.ok) {
47621
+ const body = await res.text().catch(() => "");
47622
+ return { ok: false, error: `HTTP ${res.status}${body ? `: ${body}` : ""}` };
47623
+ }
47624
+ return { ok: true };
47625
+ } catch (err) {
47626
+ return { ok: false, error: friendlyError(err) };
47627
+ }
47628
+ }
47629
+ async function checkGateway(options) {
47630
+ try {
47631
+ const base = resolveBaseUrl(options);
47632
+ const res = await fetch(`${base}/status`, { signal: options?.signal });
47633
+ if (!res.ok) {
47634
+ return { ok: false, error: `HTTP ${res.status}` };
47635
+ }
47636
+ const data = await res.json();
47637
+ return {
47638
+ ok: true,
47639
+ state: data.state,
47640
+ deviceId: data.deviceId,
47641
+ sessions: data.sessions
47642
+ };
47643
+ } catch (err) {
47644
+ return { ok: false, error: friendlyError(err) };
47645
+ }
47646
+ }
47647
+
47600
47648
  // src/index.ts
47601
- var VERSION = "0.7.0";
47649
+ var VERSION = "0.9.0";
47602
47650
  export {
47603
47651
  SecureChannel,
47604
47652
  VERSION,
47605
47653
  agentVaultPlugin,
47654
+ checkGateway,
47606
47655
  getActiveChannel,
47656
+ sendToOwner,
47607
47657
  setOcRuntime
47608
47658
  };
47609
47659
  //# sourceMappingURL=index.js.map