@ouro.bot/cli 0.1.0-alpha.1343 → 0.1.0-alpha.1344

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/changelog.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "_note": "This changelog is maintained as part of the PR/version-bump workflow. Agent-curated, not auto-generated. Agents read this file directly via read_file to understand what changed between versions.",
3
3
  "versions": [
4
+ {
5
+ "version": "0.1.0-alpha.1344",
6
+ "changes": [
7
+ "A tool catalog built from each tool's Ouro AX card, with a search that finds the right tool, ready for loading tools on demand; and a script that counts tool-definition tokens per request."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1343",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1343",
2
+ "runtimeVersion": "0.1.0-alpha.1344",
3
3
  "bundleSchemaVersion": 3,
4
4
  "lastUpdated": "2026-09-03T00:00:00.000Z"
5
5
  }
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0"?>
2
2
  <Container version="2">
3
3
  <Name>ouro-butler</Name>
4
- <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1343</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1344</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TURN_TOOL_NAMES = void 0;
4
+ exports.catalogDoor = catalogDoor;
5
+ exports.buildToolCatalog = buildToolCatalog;
6
+ exports.searchCatalog = searchCatalog;
7
+ const runtime_1 = require("../nerves/runtime");
8
+ /** The engine's turn tools: a turn can't end, think or reply without them, so they are never deferred. */
9
+ exports.TURN_TOOL_NAMES = new Set(["settle", "ponder", "observe", "rest", "speak", "surface"]);
10
+ const MAX_WHEN = 200;
11
+ function firstSentence(text) {
12
+ const line = text.trim().split("\n")[0].trim();
13
+ const end = line.search(/[.!?](\s|$)/);
14
+ const sentence = end >= 0 ? line.slice(0, end + 1) : line;
15
+ return sentence.length > MAX_WHEN ? `${sentence.slice(0, MAX_WHEN - 1)}…` : sentence;
16
+ }
17
+ function catalogDoor(source) {
18
+ const name = source.tool.function.name;
19
+ const card = source.ax;
20
+ return {
21
+ name,
22
+ group: card?.group ?? (source.mcpServer ? `mcp:${source.mcpServer}` : "other"),
23
+ when: card?.when ?? firstSentence(source.tool.function.description ?? ""),
24
+ effect: card?.effect ?? "write",
25
+ eager: exports.TURN_TOOL_NAMES.has(name) || card?.eager === true,
26
+ };
27
+ }
28
+ /** Builds the catalog for the doors selected this turn; groups keep their census `when` line, or none if unknown. */
29
+ function buildToolCatalog(sources, groups = []) {
30
+ const doors = sources.map(catalogDoor);
31
+ const known = new Map(groups.map((group) => [group.id, group.when]));
32
+ const used = [...new Set(doors.map((door) => door.group))].map((id) => ({ id, when: known.get(id) ?? "" }));
33
+ (0, runtime_1.emitNervesEvent)({
34
+ component: "repertoire", event: "repertoire.tool_catalog_built", message: "tool catalog built for the selected doors",
35
+ meta: { doors: doors.length, eager: doors.filter((door) => door.eager).length, groups: used.length },
36
+ });
37
+ return { doors, groups: used };
38
+ }
39
+ const STOPWORDS = new Set(["the", "and", "for", "with", "that", "this", "from", "into", "again", "please", "need", "use", "can", "you", "tool", "tools", "pick", "when", "what", "want", "how", "are", "its", "your", "his", "her", "their", "out", "about"]);
40
+ /** Lower-cased words with stopwords dropped and a light stem, so "downloading", "downloads" and "download" meet. */
41
+ function words(text) {
42
+ return text.toLowerCase().split(/[^a-z0-9]+/)
43
+ .filter((word) => word.length > 2 && !STOPWORDS.has(word))
44
+ .map(stem);
45
+ }
46
+ function stem(word) {
47
+ if (word.length > 5 && word.endsWith("ing"))
48
+ return word.slice(0, -3);
49
+ if (word.length > 4 && word.endsWith("ed"))
50
+ return word.slice(0, -2);
51
+ if (word.length > 3 && word.endsWith("s") && !word.endsWith("ss"))
52
+ return word.slice(0, -1);
53
+ return word;
54
+ }
55
+ const MAX_RESULTS = 8;
56
+ /**
57
+ * Finds deferred doors for a query. `select:a,b` loads by exact name. Otherwise each query word scores against the
58
+ * door's name (strongest), its card's `when` line, its group's `when` line and its description; weak hits are dropped
59
+ * when a strong one exists, so the reply stays short.
60
+ */
61
+ function searchCatalog(catalog, candidates, query) {
62
+ const trimmed = query.trim();
63
+ const names = new Set(candidates.map((tool) => tool.function.name));
64
+ if (trimmed.toLowerCase().startsWith("select:")) {
65
+ const wanted = trimmed.slice(7).split(",").map((name) => name.trim()).filter((name) => names.has(name));
66
+ return [...new Set(wanted)];
67
+ }
68
+ const terms = [...new Set(words(trimmed))];
69
+ const doors = new Map(catalog.doors.map((door) => [door.name, door]));
70
+ const groupWhen = new Map(catalog.groups.map((group) => [group.id, group.when]));
71
+ const scored = candidates.map((tool, index) => {
72
+ const name = tool.function.name.toLowerCase();
73
+ const door = doors.get(tool.function.name);
74
+ const nameWords = new Set(words(name));
75
+ const whenWords = new Set(words(door?.when ?? ""));
76
+ const groupWords = new Set(words(`${door?.group ?? ""} ${groupWhen.get(door?.group ?? "") ?? ""}`));
77
+ const descriptionWords = new Set(words(tool.function.description ?? ""));
78
+ const termScores = terms.map((term) => (name === term ? 8 : nameWords.has(term) ? 5 : name.includes(term) ? 2 : 0)
79
+ + (whenWords.has(term) ? 2 : 0)
80
+ + (groupWords.has(term) ? 1 : 0)
81
+ + (descriptionWords.has(term) ? 1 : 0));
82
+ // A door that answers more of the query's words beats one that matches a single word strongly.
83
+ const covered = termScores.filter((score) => score > 0).length;
84
+ const score = termScores.reduce((sum, termScore) => sum + termScore, 0) + (covered > 1 ? 3 * (covered - 1) : 0);
85
+ return { name: tool.function.name, score, index };
86
+ }).filter((entry) => entry.score > 0)
87
+ .sort((a, b) => b.score - a.score || a.index - b.index);
88
+ const floor = scored.length > 0 ? Math.ceil(scored[0].score / 3) : 0;
89
+ return scored.filter((entry) => entry.score >= floor).slice(0, MAX_RESULTS).map((entry) => entry.name);
90
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1343",
3
+ "version": "0.1.0-alpha.1344",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@ouro.bot/cli",
9
- "version": "0.1.0-alpha.1343",
9
+ "version": "0.1.0-alpha.1344",
10
10
  "bundleDependencies": [
11
11
  "@ouro.bot/friends"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1343",
3
+ "version": "0.1.0-alpha.1344",
4
4
  "description": "Ouroboros, the agent harness: agents with durable memory that live where you talk (terminal, Teams, iMessage, mail, voice) and use real tools. Start with npx ouro.bot@latest.",
5
5
  "homepage": "https://ouroboros.bot/",
6
6
  "engines": {