@agentvault/agentvault 0.14.6 → 0.14.8

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"}
package/dist/index.js CHANGED
@@ -45102,6 +45102,22 @@ var init_scan_engine = __esm({
45102
45102
  /\bghp_[a-zA-Z0-9]{36,}\b/g,
45103
45103
  /\bglpat-[a-zA-Z0-9_-]{20,}\b/g,
45104
45104
  /\bxoxb-[0-9]+-[0-9]+-[a-zA-Z0-9]+\b/g
45105
+ ],
45106
+ prompt_injection: [
45107
+ /\bignore\s+(?:all\s+)?(?:previous|above|prior)\s+instructions\b/gi,
45108
+ /\byou\s+are\s+now\s+(?:a|an)\s+/gi,
45109
+ /\bsystem\s*:\s*you\b/gi,
45110
+ /\bDAN\s+mode\b/gi,
45111
+ /\bdo\s+anything\s+now\b/gi,
45112
+ /\bdo\s+not\s+follow\s+any\s+(?:other\s+)?rules\b/gi,
45113
+ /\bjailbreak\b/gi
45114
+ ],
45115
+ shell_injection: [
45116
+ /\bcurl\s+.*\|\s*(?:sh|bash|zsh)\b/gi,
45117
+ /\beval\s*\(/gi,
45118
+ /\bexec\s*\(/gi,
45119
+ /\bchmod\s+\+x\b/gi,
45120
+ /\brm\s+-rf\s+\//gi
45105
45121
  ]
45106
45122
  };
45107
45123
  ScanEngine = class {
@@ -45213,6 +45229,24 @@ var init_scan_engine = __esm({
45213
45229
  }
45214
45230
  return false;
45215
45231
  }
45232
+ if (builtinId === "prompt_injection") {
45233
+ const patterns = BUILTIN_PATTERNS.prompt_injection;
45234
+ for (const p2 of patterns) {
45235
+ const regex = new RegExp(p2.source, p2.flags);
45236
+ if (regex.test(text))
45237
+ return true;
45238
+ }
45239
+ return false;
45240
+ }
45241
+ if (builtinId === "shell_injection") {
45242
+ const patterns = BUILTIN_PATTERNS.shell_injection;
45243
+ for (const p2 of patterns) {
45244
+ const regex = new RegExp(p2.source, p2.flags);
45245
+ if (regex.test(text))
45246
+ return true;
45247
+ }
45248
+ return false;
45249
+ }
45216
45250
  return false;
45217
45251
  }
45218
45252
  _buildMatchSummary(rule) {
@@ -45232,6 +45266,48 @@ var init_scan_engine = __esm({
45232
45266
  _escapeRegex(str) {
45233
45267
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
45234
45268
  }
45269
+ /**
45270
+ * Scan a workspace file (e.g. SOUL.md) against all builtin patterns.
45271
+ * Runs api_keys, pii_*, prompt_injection, and shell_injection checks
45272
+ * regardless of rule direction.
45273
+ */
45274
+ static scanWorkspaceFile(content) {
45275
+ const violations = [];
45276
+ let blocked = false;
45277
+ let flagged = false;
45278
+ const checks = [
45279
+ { id: "api_keys", action: "block" },
45280
+ { id: "prompt_injection", action: "block" },
45281
+ { id: "shell_injection", action: "block" },
45282
+ { id: "pii_ssn", action: "flag" },
45283
+ { id: "pii_credit_card", action: "flag" },
45284
+ { id: "pii_email", action: "flag" }
45285
+ ];
45286
+ for (const check of checks) {
45287
+ const patterns = BUILTIN_PATTERNS[check.id];
45288
+ if (!patterns)
45289
+ continue;
45290
+ for (const p2 of patterns) {
45291
+ const regex = new RegExp(p2.source, p2.flags);
45292
+ if (regex.test(content)) {
45293
+ violations.push({
45294
+ rule_id: `workspace_${check.id}`,
45295
+ rule_name: check.id,
45296
+ action: check.action,
45297
+ scanner_type: "builtin",
45298
+ match_summary: `builtin:${check.id}`
45299
+ });
45300
+ if (check.action === "block")
45301
+ blocked = true;
45302
+ if (check.action === "flag")
45303
+ flagged = true;
45304
+ break;
45305
+ }
45306
+ }
45307
+ }
45308
+ const status = blocked ? "blocked" : flagged ? "flagged" : "clean";
45309
+ return { status, violations };
45310
+ }
45235
45311
  };
45236
45312
  }
45237
45313
  });
@@ -46037,7 +46113,7 @@ __export(workspace_handlers_exports, {
46037
46113
  handleWorkspaceUpload: () => handleWorkspaceUpload,
46038
46114
  validateWorkspaceFilename: () => validateWorkspaceFilename
46039
46115
  });
46040
- import { readdir, readFile as readFile2, writeFile as writeFile2, rename as rename2, stat, unlink } from "node:fs/promises";
46116
+ import { readdir, readFile as readFile2, writeFile as writeFile2, rename as rename2, stat, unlink, mkdir as mkdir2 } from "node:fs/promises";
46041
46117
  import { join as join2 } from "node:path";
46042
46118
  import { randomUUID } from "node:crypto";
46043
46119
  function validateWorkspaceFilename(filename) {
@@ -46092,6 +46168,7 @@ async function handleWorkspaceUpload(data, workspaceDir) {
46092
46168
  if (!verified) {
46093
46169
  return { status: "error", error: "Invalid signature \u2014 file may have been tampered with" };
46094
46170
  }
46171
+ await mkdir2(workspaceDir, { recursive: true });
46095
46172
  const targetPath = join2(workspaceDir, data.filename);
46096
46173
  const tempPath = join2(workspaceDir, `.tmp_${randomUUID()}_${data.filename}`);
46097
46174
  try {
@@ -46172,7 +46249,7 @@ var init_workspace_handlers = __esm({
46172
46249
  import { EventEmitter } from "node:events";
46173
46250
  import { createServer } from "node:http";
46174
46251
  import { randomUUID as randomUUID2 } from "node:crypto";
46175
- import { writeFile as writeFile3, mkdir as mkdir2 } from "node:fs/promises";
46252
+ import { writeFile as writeFile3, mkdir as mkdir3 } from "node:fs/promises";
46176
46253
  import { join as join3 } from "node:path";
46177
46254
  import { readFile as readFile3 } from "node:fs/promises";
46178
46255
  import WebSocket from "ws";
@@ -48097,7 +48174,7 @@ ${messageText}`;
48097
48174
  */
48098
48175
  async _downloadAndDecryptAttachment(info) {
48099
48176
  const attachDir = join3(this.config.dataDir, "attachments");
48100
- await mkdir2(attachDir, { recursive: true });
48177
+ await mkdir3(attachDir, { recursive: true });
48101
48178
  const url = `${this.config.apiUrl}${info.blobUrl}`;
48102
48179
  const res = await fetch(url, {
48103
48180
  headers: { Authorization: `Bearer ${this._deviceJwt}` }
@@ -48232,22 +48309,23 @@ ${messageText}`;
48232
48309
  */
48233
48310
  _resolveWorkspaceDir() {
48234
48311
  const homedir = process.env.HOME ?? process.env.USERPROFILE ?? "/tmp";
48312
+ const agentName = this.config.agentName;
48235
48313
  try {
48236
48314
  const configPath = join3(homedir, ".openclaw", "openclaw.json");
48237
48315
  const raw = __require("node:fs").readFileSync(configPath, "utf-8");
48238
48316
  const config = JSON.parse(raw);
48239
48317
  const agents = config?.agents?.list;
48240
- if (Array.isArray(agents)) {
48318
+ if (Array.isArray(agents) && agentName) {
48241
48319
  for (const agent of agents) {
48242
- if (agent.workspace && typeof agent.workspace === "string") {
48320
+ if ((agent.id === agentName || agent.name === agentName) && agent.workspace && typeof agent.workspace === "string") {
48243
48321
  return agent.workspace;
48244
48322
  }
48245
48323
  }
48246
48324
  }
48247
48325
  } catch {
48248
48326
  }
48249
- if (this.config.dataDir) {
48250
- return join3(this.config.dataDir, "..", "workspace");
48327
+ if (agentName && agentName !== "CLI Agent" && agentName !== "OpenClaw Agent") {
48328
+ return join3(homedir, ".openclaw", `workspace-${agentName}`);
48251
48329
  }
48252
48330
  return join3(homedir, ".openclaw", "workspace");
48253
48331
  }