@agentvault/agentvault 0.11.1 → 0.12.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,4 @@
1
+ // Re-export transport utilities from shared @agentvault/crypto package.
2
+ // Plugin code continues importing from ./crypto-helpers.js — no import changes needed.
3
+ export { hexToBytes, bytesToHex, base64ToBytes, bytesToBase64, encryptedMessageToTransport, transportToEncryptedMessage, } from "@agentvault/crypto";
4
+ //# sourceMappingURL=crypto-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-helpers.js","sourceRoot":"","sources":["../src/crypto-helpers.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,uFAAuF;AACvF,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,2BAA2B,EAC3B,2BAA2B,GAE5B,MAAM,oBAAoB,CAAC"}
@@ -29,6 +29,20 @@ export interface GatewayStatusResult {
29
29
  * Never throws — returns `{ ok: false, error }` on failure.
30
30
  */
31
31
  export declare function sendToOwner(text: string, options?: GatewaySendOptions): Promise<GatewaySendResult>;
32
+ export interface ActionReport {
33
+ action: string;
34
+ status: "completed" | "failed" | "partial";
35
+ room_id?: string;
36
+ detail?: string;
37
+ estimated_cost?: number;
38
+ decision_id?: string;
39
+ }
40
+ /**
41
+ * Report an action (deploy, execute, etc.) via the gateway HTTP server.
42
+ * Routes to sendActionConfirmationToRoom() (if room_id) or sendActionConfirmation().
43
+ * Never throws — returns `{ ok: false, error }` on failure.
44
+ */
45
+ export declare function sendAction(report: ActionReport, options?: GatewaySendOptions): Promise<GatewaySendResult>;
32
46
  /**
33
47
  * Check gateway health / status.
34
48
  * Never throws — returns `{ ok: false, error }` on failure.
@@ -1 +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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ClB,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,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,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
@@ -3,7 +3,7 @@ export type { SecureChannelConfig, ChannelState, MessageMetadata, AttachmentData
3
3
  export { listAccountIds, resolveAccount } from "./account-config.js";
4
4
  export type { ResolvedAccount } from "./account-config.js";
5
5
  export { agentVaultPlugin, setOcRuntime, getActiveChannel } from "./openclaw-plugin.js";
6
- export { sendToOwner, checkGateway } from "./gateway-send.js";
7
- export type { GatewaySendOptions, GatewaySendResult, GatewayStatusResult, } from "./gateway-send.js";
8
- export declare const VERSION = "0.11.0";
6
+ export { sendToOwner, sendAction, checkGateway } from "./gateway-send.js";
7
+ export type { GatewaySendOptions, GatewaySendResult, GatewayStatusResult, ActionReport, } from "./gateway-send.js";
8
+ export declare const VERSION = "0.12.0";
9
9
  //# 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,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,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,WAAW,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,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrE,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxF,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC1E,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -45907,7 +45907,9 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
45907
45907
  data: {
45908
45908
  room_id: roomId,
45909
45909
  recipients,
45910
- message_type: messageType
45910
+ message_type: messageType,
45911
+ priority: opts?.priority ?? "normal",
45912
+ metadata: opts?.metadata
45911
45913
  }
45912
45914
  })
45913
45915
  );
@@ -45921,7 +45923,12 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
45921
45923
  "Content-Type": "application/json",
45922
45924
  Authorization: `Bearer ${this._deviceJwt}`
45923
45925
  },
45924
- body: JSON.stringify({ recipients, message_type: messageType })
45926
+ body: JSON.stringify({
45927
+ recipients,
45928
+ message_type: messageType,
45929
+ priority: opts?.priority ?? "normal",
45930
+ metadata: opts?.metadata
45931
+ })
45925
45932
  }
45926
45933
  );
45927
45934
  if (!res.ok) {
@@ -46066,6 +46073,27 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
46066
46073
  }
46067
46074
  );
46068
46075
  }
46076
+ async sendActionConfirmationToRoom(roomId, confirmation) {
46077
+ const envelope = {
46078
+ type: "action_confirmation",
46079
+ action: confirmation.action,
46080
+ status: confirmation.status
46081
+ };
46082
+ if (confirmation.decisionId !== void 0) envelope.decision_id = confirmation.decisionId;
46083
+ if (confirmation.detail !== void 0) envelope.detail = confirmation.detail;
46084
+ const metadata = {
46085
+ action: confirmation.action,
46086
+ status: confirmation.status
46087
+ };
46088
+ if (confirmation.estimated_cost !== void 0) {
46089
+ metadata.estimated_cost = confirmation.estimated_cost;
46090
+ }
46091
+ await this.sendToRoom(roomId, JSON.stringify(envelope), {
46092
+ messageType: "action_confirmation",
46093
+ priority: "high",
46094
+ metadata
46095
+ });
46096
+ }
46069
46097
  _sendHeartbeat() {
46070
46098
  if (this._state !== "ready" || !this._heartbeatCallback) return;
46071
46099
  const status = this._heartbeatCallback();
@@ -46140,10 +46168,52 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
46140
46168
  res.end(JSON.stringify({ ok: false, error: "Missing 'text' field" }));
46141
46169
  return;
46142
46170
  }
46143
- if (parsed.file_path && typeof parsed.file_path === "string") {
46171
+ if (parsed.room_id && typeof parsed.room_id === "string") {
46172
+ await this.sendToRoom(parsed.room_id, text, {
46173
+ messageType: parsed.message_type,
46174
+ priority: parsed.priority,
46175
+ metadata: parsed.metadata
46176
+ });
46177
+ } else if (parsed.file_path && typeof parsed.file_path === "string") {
46144
46178
  await this.sendWithAttachment(text, parsed.file_path, { topicId: parsed.topicId });
46145
46179
  } else {
46146
- await this.send(text, { topicId: parsed.topicId });
46180
+ await this.send(text, {
46181
+ topicId: parsed.topicId,
46182
+ messageType: parsed.message_type,
46183
+ metadata: parsed.metadata
46184
+ });
46185
+ }
46186
+ res.writeHead(200, { "Content-Type": "application/json" });
46187
+ res.end(JSON.stringify({ ok: true }));
46188
+ } catch (err) {
46189
+ res.writeHead(500, { "Content-Type": "application/json" });
46190
+ res.end(JSON.stringify({ ok: false, error: String(err) }));
46191
+ }
46192
+ });
46193
+ } else if (req.method === "POST" && req.url === "/action") {
46194
+ let body = "";
46195
+ req.on("data", (chunk) => {
46196
+ body += chunk.toString();
46197
+ });
46198
+ req.on("end", async () => {
46199
+ try {
46200
+ const parsed = JSON.parse(body);
46201
+ if (!parsed.action || typeof parsed.action !== "string") {
46202
+ res.writeHead(400, { "Content-Type": "application/json" });
46203
+ res.end(JSON.stringify({ ok: false, error: "Missing 'action' field" }));
46204
+ return;
46205
+ }
46206
+ const confirmation = {
46207
+ action: parsed.action,
46208
+ status: parsed.status ?? "completed",
46209
+ decisionId: parsed.decision_id,
46210
+ detail: parsed.detail,
46211
+ estimated_cost: parsed.estimated_cost
46212
+ };
46213
+ if (parsed.room_id && typeof parsed.room_id === "string") {
46214
+ await this.sendActionConfirmationToRoom(parsed.room_id, confirmation);
46215
+ } else {
46216
+ await this.sendActionConfirmation(confirmation);
46147
46217
  }
46148
46218
  res.writeHead(200, { "Content-Type": "application/json" });
46149
46219
  res.end(JSON.stringify({ ok: true }));
@@ -46162,7 +46232,7 @@ var SecureChannel = class _SecureChannel extends EventEmitter {
46162
46232
  }));
46163
46233
  } else {
46164
46234
  res.writeHead(404, { "Content-Type": "application/json" });
46165
- res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send or GET /status" }));
46235
+ res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /action, or GET /status" }));
46166
46236
  }
46167
46237
  });
46168
46238
  this._httpServer.listen(port, "127.0.0.1", () => {
@@ -48169,6 +48239,27 @@ async function sendToOwner(text, options) {
48169
48239
  return { ok: false, error: friendlyError(err) };
48170
48240
  }
48171
48241
  }
48242
+ async function sendAction(report, options) {
48243
+ if (typeof report.action !== "string" || report.action.trim().length === 0) {
48244
+ return { ok: false, error: "Action must be a non-empty string" };
48245
+ }
48246
+ try {
48247
+ const base = resolveBaseUrl(options);
48248
+ const res = await fetch(`${base}/action`, {
48249
+ method: "POST",
48250
+ headers: { "Content-Type": "application/json" },
48251
+ body: JSON.stringify(report),
48252
+ signal: options?.signal
48253
+ });
48254
+ if (!res.ok) {
48255
+ const body = await res.text().catch(() => "");
48256
+ return { ok: false, error: `HTTP ${res.status}${body ? `: ${body}` : ""}` };
48257
+ }
48258
+ return { ok: true };
48259
+ } catch (err) {
48260
+ return { ok: false, error: friendlyError(err) };
48261
+ }
48262
+ }
48172
48263
  async function checkGateway(options) {
48173
48264
  try {
48174
48265
  const base = resolveBaseUrl(options);
@@ -48189,7 +48280,7 @@ async function checkGateway(options) {
48189
48280
  }
48190
48281
 
48191
48282
  // src/index.ts
48192
- var VERSION = "0.11.0";
48283
+ var VERSION = "0.12.0";
48193
48284
  export {
48194
48285
  SecureChannel,
48195
48286
  VERSION,
@@ -48198,6 +48289,7 @@ export {
48198
48289
  getActiveChannel,
48199
48290
  listAccountIds,
48200
48291
  resolveAccount,
48292
+ sendAction,
48201
48293
  sendToOwner,
48202
48294
  setOcRuntime
48203
48295
  };