@tritard/waterbrother 0.16.98 → 0.16.100

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.98",
3
+ "version": "0.16.100",
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": {
package/src/gateway.js CHANGED
@@ -509,6 +509,32 @@ function summarizeRuntimeConflict(project, fallbackExecutor = {}) {
509
509
  };
510
510
  }
511
511
 
512
+ function cleanAgentDisplayValue(value = "") {
513
+ const cleaned = String(value || "").replace(/\bundefined\b/ig, "").trim();
514
+ if (!cleaned) return "";
515
+ if (/^terminal$/i.test(cleaned)) return "";
516
+ return cleaned;
517
+ }
518
+
519
+ function getAgentOwnerDisplay(agent = {}, fallback = "") {
520
+ const ownerName = cleanAgentDisplayValue(agent?.ownerName);
521
+ const ownerId = cleanAgentDisplayValue(agent?.ownerId);
522
+ const label = cleanAgentDisplayValue(agent?.label);
523
+ const fallbackValue = cleanAgentDisplayValue(fallback);
524
+ return ownerName || ownerId || fallbackValue || label || "unknown";
525
+ }
526
+
527
+ function getAgentTerminalDisplay(agent = {}, fallback = "") {
528
+ const label = cleanAgentDisplayValue(agent?.label);
529
+ const fallbackValue = cleanAgentDisplayValue(fallback);
530
+ if (label) return label;
531
+ if (fallbackValue) return fallbackValue;
532
+ const ownerName = cleanAgentDisplayValue(agent?.ownerName);
533
+ if (ownerName) return ownerName + " terminal";
534
+ const ownerId = cleanAgentDisplayValue(agent?.ownerId);
535
+ if (ownerId) return ownerId + " terminal";
536
+ return "current terminal";
537
+ }
512
538
  function formatBridgeHostLabel(host = {}) {
513
539
  const owner = String(host?.ownerName || host?.ownerId || "").trim();
514
540
  const label = String(host?.label || "").trim();
@@ -695,7 +721,11 @@ function formatTelegramProjectMarkup({ cwd, project, chatId = "", title = "" })
695
721
  }
696
722
 
697
723
  function normalizeTelegramProjectIntentText(text = "") {
698
- return String(text || "").trim().replace(/\s+/g, " ");
724
+ return String(text || "")
725
+ .replace(/[‘’′]/g, "'")
726
+ .replace(/[“”]/g, '"')
727
+ .trim()
728
+ .replace(/\s+/g, " ");
699
729
  }
700
730
 
701
731
  function parseTelegramProjectIntent(text = "") {
@@ -869,7 +899,7 @@ function parseTelegramStateIntent(text = "") {
869
899
  if (/\bwhat can i do here\b/.test(lower) || /\bhow do i use this room\b/.test(lower) || /\bhow do i use this chat\b/.test(lower) || /\bwhat do i do here\b/.test(lower)) {
870
900
  return { action: "room-guidance" };
871
901
  }
872
- if (/\bwho is the verifier\b/.test(lower) || /\bwhat is the verifier\b/.test(lower) || /\bwho should verify this\b/.test(lower)) {
902
+ if (/\bwho(?:'s| is)? the verifier\b/.test(lower) || /\bwhat is the verifier\b/.test(lower) || /\bwho should verify this\b/.test(lower)) {
873
903
  return { action: "verifier-status" };
874
904
  }
875
905
  if (/\bwho are the (?:bots|boys)\b/.test(lower) || /\bwho are the agents\b/.test(lower) || /\bwhat (?:bots|boys) are here\b/.test(lower) || /\bwhat agents are here\b/.test(lower)) {
@@ -2019,8 +2049,8 @@ class TelegramGateway {
2019
2049
  )) || {
2020
2050
  id: `agent:telegram-bridge:${String(host.sessionId || host.pid || "current").trim()}`,
2021
2051
  ownerId: String(host.ownerId || actor.userId || "").trim(),
2022
- ownerName: String(host.ownerName || actor.displayName || "").trim(),
2023
- label: String(host.label || `${actor.displayName || actor.userId || "current"} terminal`).trim(),
2052
+ ownerName: getAgentOwnerDisplay(host, actor.displayName || actor.userId || "current operator"),
2053
+ label: getAgentTerminalDisplay(host, actor.displayName ? actor.displayName + " terminal" : (actor.userId ? actor.userId + " terminal" : "current terminal")),
2024
2054
  surface: String(host.surface || "live-tui").trim(),
2025
2055
  role: "standby",
2026
2056
  provider: String(host.provider || "").trim(),
@@ -2058,15 +2088,15 @@ class TelegramGateway {
2058
2088
  ? "This sets the room verifier role. Use run verification when you want Waterbrother to run tests or build checks."
2059
2089
  : "";
2060
2090
  const followUp = intent.action === "agent-review" || intent.role === "reviewer"
2061
- ? `Should ${targetAgent.ownerName || targetAgent.label || "that terminal"} review be advisory or blocking?`
2091
+ ? `Should ${getAgentOwnerDisplay(targetAgent, actor.displayName || actor.userId || "that terminal")} review be advisory or blocking?`
2062
2092
  : "";
2063
2093
  return {
2064
2094
  kind: "agent",
2065
2095
  project: nextProject,
2066
2096
  markup: [
2067
2097
  `<b>${escapeTelegramHtml(actionTitle)}</b>`,
2068
- `owner: <code>${escapeTelegramHtml(targetAgent.ownerName || targetAgent.ownerId || targetAgent.label || targetAgent.id || "-")}</code>`,
2069
- `terminal: <code>${escapeTelegramHtml(targetAgent.label || targetAgent.id || "-")}</code>`,
2098
+ `owner: <code>${escapeTelegramHtml(getAgentOwnerDisplay(targetAgent, actor.displayName || actor.userId || "current operator"))}</code>`,
2099
+ `terminal: <code>${escapeTelegramHtml(getAgentTerminalDisplay(targetAgent, actor.displayName ? actor.displayName + " terminal" : "current terminal"))}</code>`,
2070
2100
  `role: <code>${escapeTelegramHtml(intent.role)}</code>`,
2071
2101
  `runtime: <code>${escapeTelegramHtml(runtimeLabel)}</code>`,
2072
2102
  `project: <code>${escapeTelegramHtml(nextProject.projectName || path.basename(session.cwd || this.cwd))}</code>`,
@@ -2375,7 +2405,7 @@ class TelegramGateway {
2375
2405
  }
2376
2406
  return [
2377
2407
  "<b>Verifier</b>",
2378
- `verifier: <code>${escapeTelegramHtml(verifier.ownerName || verifier.label || verifier.ownerId || verifier.id || "unknown")}</code>`,
2408
+ `verifier: <code>${escapeTelegramHtml(getAgentOwnerDisplay(verifier))}</code>`,
2379
2409
  `role: <code>${escapeTelegramHtml(verifier.role || "verifier")}</code>`,
2380
2410
  `runtime: <code>${escapeTelegramHtml(verifier.provider && verifier.model ? `${verifier.provider}/${verifier.model}` : "unknown")}</code>`,
2381
2411
  `verification mode: <code>${escapeTelegramHtml(String(project.verificationMode || "manual"))}</code>`
@@ -266,13 +266,23 @@ function scoreEntry(question, entry) {
266
266
  for (const keyword of entry.keywords || []) {
267
267
  const normalized = normalizeQuestion(keyword);
268
268
  if (!normalized) continue;
269
- if (q.includes(normalized)) score += Math.max(2, normalized.split(" ").length * 2);
270
269
  const tokens = normalized.split(" ").filter(Boolean);
271
- if (tokens.length > 1 && tokens.every((token) => qTokens.has(token))) {
270
+ if (tokens.length === 1) {
271
+ if (qTokens.has(tokens[0])) score += 2;
272
+ continue;
273
+ }
274
+ if (q.includes(normalized)) score += Math.max(2, tokens.length * 2);
275
+ if (tokens.every((token) => qTokens.has(token))) {
272
276
  score += tokens.length + 1;
273
277
  }
274
278
  }
275
- if (entry.id && q.includes(normalizeQuestion(entry.id))) score += 2;
279
+ if (entry.id) {
280
+ const normalizedId = normalizeQuestion(entry.id);
281
+ const idTokens = normalizedId.split(" ").filter(Boolean);
282
+ if (idTokens.length === 1 ? qTokens.has(idTokens[0]) : q.includes(normalizedId)) {
283
+ score += 2;
284
+ }
285
+ }
276
286
  return score;
277
287
  }
278
288