@kernel.chat/kbot 3.99.25 → 3.99.27

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.
Files changed (2) hide show
  1. package/dist/agent.js +17 -0
  2. package/package.json +3 -2
package/dist/agent.js CHANGED
@@ -112,6 +112,23 @@ let weakModelWarningShown = false;
112
112
  // ── Local-first execution ──
113
113
  async function tryLocalFirst(message) {
114
114
  const lower = message.toLowerCase().trim();
115
+ // Pure-arithmetic short-circuit. If the message contains exactly one
116
+ // arithmetic expression and reads as a request for the numeric answer
117
+ // ("what is X", "calculate X", or bare X), return the JS-computed answer
118
+ // directly — never involve an LLM. Eval on 2026-04-20 showed gemma4:latest
119
+ // ignoring an injected MATH GUARD ("123 % 7 = 4" prepended to the user
120
+ // message, answer still "2"). If the answer is deterministic, do not ask
121
+ // the model.
122
+ const looksArithmetic = /\b(?:what\s+is|what['']s|compute|calculate|evaluate)\b/i.test(lower)
123
+ || /^[-\d.\s+*×/÷%()?]+$/.test(lower);
124
+ if (looksArithmetic && message.length < 200) {
125
+ const { extractArithmetic } = await import('./math-guard.js');
126
+ const exprs = extractArithmetic(message);
127
+ if (exprs.length === 1) {
128
+ const r = exprs[0].result;
129
+ return Number.isInteger(r) ? r.toString() : Number.parseFloat(r.toFixed(6)).toString();
130
+ }
131
+ }
115
132
  // Only match simple "read <single-filepath>" — reject anything with trailing
116
133
  // conversational text. Prevents "Read package.json and tell me X" from
117
134
  // feeding the whole prompt to read_file as a filename.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernel.chat/kbot",
3
- "version": "3.99.25",
3
+ "version": "3.99.27",
4
4
  "description": "Open-source terminal AI agent. 787+ tools, 35 agents, 20 providers. Dreams, learns, watches your system. Controls your phone. Fully local, fully sovereign. MIT.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -40,7 +40,8 @@
40
40
  "dev": "tsx src/cli.ts",
41
41
  "start": "node dist/cli.js",
42
42
  "test": "vitest run",
43
- "typecheck": "tsc --noEmit"
43
+ "typecheck": "tsc --noEmit",
44
+ "eval": "tsx eval/run.ts"
44
45
  },
45
46
  "keywords": [
46
47
  "ai-agent",