@kernel.chat/kbot 3.99.10 → 3.99.12

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/dist/agent.js CHANGED
@@ -327,6 +327,21 @@ function tryParseInlineToolCalls(content, knownTools) {
327
327
  if (parsed)
328
328
  calls.push(parsed);
329
329
  }
330
+ if (calls.length > 0)
331
+ return calls;
332
+ // Pattern 3b: ANY fenced code block whose first line starts with a known tool name.
333
+ // Catches ```bash\nread_file "path.json"\n``` and ```\nread_file path.ts\n```,
334
+ // which small local models like gemma4 emit when asked to use tools.
335
+ const anyBlockPattern = /```(?:[a-z_]+)?\s*\n([\s\S]*?)```/g;
336
+ while ((match = anyBlockPattern.exec(content)) !== null) {
337
+ const block = match[1].trim();
338
+ const firstWord = block.split(/\s/)[0];
339
+ if (firstWord && knownTools.includes(firstWord)) {
340
+ const parsed = parseToolCodeBlock(block, knownTools);
341
+ if (parsed)
342
+ calls.push(parsed);
343
+ }
344
+ }
330
345
  if (calls.length > 0)
331
346
  return calls;
332
347
  // Pattern 4: Natural language tool invocations — "I'll use write_file to create..."
@@ -370,14 +385,22 @@ function parseToolCodeBlock(block, knownTools) {
370
385
  }
371
386
  return null;
372
387
  }
388
+ /** Strip surrounding quotes from a CLI-style argument string */
389
+ function unquote(s) {
390
+ const t = s.trim();
391
+ if ((t.startsWith('"') && t.endsWith('"')) || (t.startsWith("'") && t.endsWith("'"))) {
392
+ return t.slice(1, -1);
393
+ }
394
+ return t;
395
+ }
373
396
  /** Build structured args from a tool_code invocation */
374
397
  function buildArgsFromToolCode(tool, argStr, restContent) {
375
398
  switch (tool) {
376
399
  case 'read_file':
377
400
  case 'list_directory':
378
- return { path: argStr || '.' };
401
+ return { path: unquote(argStr) || '.' };
379
402
  case 'write_file':
380
- return { path: argStr, content: restContent };
403
+ return { path: unquote(argStr), content: restContent };
381
404
  case 'bash':
382
405
  return { command: argStr || restContent };
383
406
  case 'grep':
@@ -22,7 +22,7 @@ export function getSelfAwarenessPrompt() {
22
22
  return cached;
23
23
  const lines = [
24
24
  '[kbot Ground Truth — AUTHORITATIVE. When asked about yourself (version, model, provider, architecture, capabilities, weaknesses, history, what you are, what you can do), answer ONLY from this block. Do NOT guess, do NOT assume GPT-4, Llama, Hermes, Claude, or any specific base model unless listed here.]',
25
- '[TOOL POLICY FOR SELF-INTROSPECTION: If the user asks about YOU (your runtime, your model, your provider, your version, your architecture, your skills, your tools, your weaknesses), DO NOT call web_search, url_fetch, research, or any external-lookup tool. The answer is in this block. Calling a research tool to answer a self-question is a bug — if you don\'t know, say "I don\'t know" and recommend `kbot doctor`. Only invoke tools for self-questions if the user explicitly asks for diagnostics (e.g., "run doctor", "check config").]',
25
+ '[TOOL POLICY FOR SELF-INTROSPECTION: If the user asks about YOU (your runtime, your model, your provider, your version, your architecture, your skills, your tools, your weaknesses), DO NOT call web_search, url_fetch, research, or other INTERNET-LOOKUP tools the answer is in this block. HOWEVER, file tools (read_file, glob, grep, bash) and git tools ARE ENCOURAGED — if the user asks about a specific file (e.g., "what version is in package.json"), INVOKE read_file on that file and quote the actual contents. Hallucinating file contents without reading them is a bug; so is denying you have file access.]',
26
26
  ];
27
27
  // Version (read from package.json)
28
28
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernel.chat/kbot",
3
- "version": "3.99.10",
3
+ "version": "3.99.12",
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": {