@tritard/waterbrother 0.16.59 → 0.16.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tritard/waterbrother",
3
- "version": "0.16.59",
3
+ "version": "0.16.61",
4
4
  "description": "Waterbrother: bring-your-own-model coding CLI with local tools, sessions, operator modes, and approval controls",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,8 +31,11 @@ function normalizeBridgeRequest(parsed = {}) {
31
31
  chatId: String(parsed?.chatId || "").trim(),
32
32
  userId: String(parsed?.userId || "").trim(),
33
33
  username: String(parsed?.username || "").trim(),
34
+ usernameHandle: String(parsed?.usernameHandle || "").trim(),
35
+ displayName: String(parsed?.displayName || "").trim(),
34
36
  sessionId: String(parsed?.sessionId || "").trim(),
35
37
  text: String(parsed?.text || "").trim(),
38
+ explicitExecution: parsed?.explicitExecution === true,
36
39
  runtimeProfile: String(parsed?.runtimeProfile || "").trim(),
37
40
  replyToMessageId: Number.isFinite(Number(parsed?.replyToMessageId)) ? Math.floor(Number(parsed.replyToMessageId)) : 0,
38
41
  requestedAt: String(parsed?.requestedAt || "").trim(),
package/src/tools.js CHANGED
@@ -406,6 +406,13 @@ function matchesAnyPattern(value, patterns = []) {
406
406
  return uniqueStrings(patterns).some((pattern) => matchesPattern(value, pattern));
407
407
  }
408
408
 
409
+ function isAncestorPath(candidate, target) {
410
+ const from = normalizePathPattern(candidate);
411
+ const to = normalizePathPattern(target);
412
+ if (!from || !to || from === to) return false;
413
+ return to.startsWith(`${from}/`);
414
+ }
415
+
409
416
  function extractPatchPaths(patchText) {
410
417
  const matches = String(patchText || "").match(/^\+\+\+ b\/(.+)$/gm) || [];
411
418
  return uniqueStrings(matches.map((line) => line.replace(/^\+\+\+ b\//, "").trim()).filter((line) => line && line !== "/dev/null"));
@@ -1091,6 +1098,13 @@ export function createToolRuntime({
1091
1098
  ...getContractWriteRoots(),
1092
1099
  ...getCurrentWriteRoots()
1093
1100
  ]);
1101
+ if (
1102
+ toolName === "make_directory"
1103
+ && touchedPaths.length > 0
1104
+ && touchedPaths.every((item) => allowedPaths.some((allowed) => isAncestorPath(item, allowed)))
1105
+ ) {
1106
+ return { ok: true, reason: "Directory is a parent of declared contract paths" };
1107
+ }
1094
1108
  if (touchedPaths.length > 0 && !touchedPaths.every((item) => matchesAnyPattern(item, allowedPaths))) {
1095
1109
  return { ok: false, reason: `Action outside declared contract scope: ${touchedPaths.join(", ")}` };
1096
1110
  }