@ouro.bot/cli 0.1.0-alpha.1371 → 0.1.0-alpha.1373

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,18 @@
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.1373",
6
+ "changes": [
7
+ "The Ouro AX census now runs ouro-ui's census from v1.3.448 (scripts/ouro-census) instead of the harness's own copy, and checks booklet words, with the 37 doors that say one today on the baseline; report_failure's description says what a local save means instead of giving a rule."
8
+ ]
9
+ },
10
+ {
11
+ "version": "0.1.0-alpha.1372",
12
+ "changes": [
13
+ "ouro hook post-tool-use no longer loads the whole CLI: it sends from a small module, skips subagents, and sends at most one note per Claude Code session every five minutes. Measured on a stand-in agent with no daemon, the hook's node process went from a median 178 ms, 0.20 s of CPU and 80 MB to 86 ms, 0.07 s and 44 MB (bare node is 67 ms)."
14
+ ]
15
+ },
4
16
  {
5
17
  "version": "0.1.0-alpha.1371",
6
18
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1371",
2
+ "runtimeVersion": "0.1.0-alpha.1373",
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.1371</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1373</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,149 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.POST_TOOL_USE_SEND_TIMEOUT_MS = exports.POST_TOOL_USE_QUIET_MS = void 0;
37
+ exports.isPostToolUseHook = isPostToolUseHook;
38
+ exports.runPostToolUseHook = runPostToolUseHook;
39
+ exports.defaultPostToolUseDeps = defaultPostToolUseDeps;
40
+ /**
41
+ * `ouro hook post-tool-use --agent <agent>`, without loading the CLI.
42
+ *
43
+ * Claude Code runs this after every Bash, Edit and Write call in every session (`ouro setup`'s PostToolUse hook), so
44
+ * with 20 sessions open it runs many times a minute. Through the full CLI each call took about 340 ms of wall time and
45
+ * 0.3 s of CPU (measured 2026-11-22 on alpha.1354, recorded in the PR), almost all of it loading modules to send one
46
+ * message. The entry point sends it here instead, importing only node modules and the socket client, and sends at most
47
+ * one note per session in each quiet window: the note says only that the session used a tool, which the agent already
48
+ * knows from the first one, and the hook never wakes the agent.
49
+ *
50
+ * It skips without a send when the hook fires inside a subagent (Claude Code puts `agent_id` on the event), when the
51
+ * session already sent within the quiet window, or when the daemon's socket is missing. It always answers
52
+ * `{"continue":true}`, so a slow or absent daemon never holds up the tool call.
53
+ */
54
+ const crypto = __importStar(require("crypto"));
55
+ const fs = __importStar(require("fs"));
56
+ const os = __importStar(require("os"));
57
+ const path = __importStar(require("path"));
58
+ const socket_client_1 = require("./socket-client");
59
+ const runtime_1 = require("../../nerves/runtime");
60
+ /** How long a session's tool use stays news: one note per session in each window. */
61
+ exports.POST_TOOL_USE_QUIET_MS = 5 * 60 * 1000;
62
+ /** The hook's whole budget for the send; Claude Code's own timeout is 5 s. */
63
+ exports.POST_TOOL_USE_SEND_TIMEOUT_MS = 2_000;
64
+ /** True for exactly `hook post-tool-use --agent <agent>`, the argv the entry point hands this module. */
65
+ function isPostToolUseHook(argv) {
66
+ return argv.length === 4 && argv[0] === "hook" && argv[1] === "post-tool-use" && argv[2] === "--agent" && /^[A-Za-z0-9._-]+$/.test(argv[3]);
67
+ }
68
+ function stampPath(dir, agent, sessionId) {
69
+ return path.join(dir, `${agent}-${crypto.createHash("sha256").update(sessionId).digest("hex").slice(0, 32)}`);
70
+ }
71
+ /** Within the quiet window since this session's last send. A missing or unreadable stamp is not. */
72
+ function quiet(file, now) {
73
+ try {
74
+ return now - fs.statSync(file).mtimeMs < exports.POST_TOOL_USE_QUIET_MS;
75
+ }
76
+ catch {
77
+ return false;
78
+ }
79
+ }
80
+ function stamp(dir, file, now) {
81
+ try {
82
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
83
+ fs.writeFileSync(file, "");
84
+ fs.utimesSync(file, now / 1000, now / 1000);
85
+ }
86
+ catch {
87
+ // An unwritable stamp only means the next call sends again.
88
+ }
89
+ }
90
+ async function runPostToolUseHook(agent, deps) {
91
+ const outcome = await decide(agent, deps);
92
+ // Nothing configures a log sink in this process, so this costs only the runtime's import (about 10 ms).
93
+ (0, runtime_1.emitNervesEvent)({ event: "daemon.hook_post_tool_use", component: "daemon", message: `post-tool-use hook: ${outcome}`, meta: { agent, outcome } });
94
+ return outcome;
95
+ }
96
+ async function decide(agent, deps) {
97
+ try {
98
+ let event = {};
99
+ try {
100
+ const parsed = JSON.parse(deps.readStdin());
101
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
102
+ event = parsed;
103
+ }
104
+ catch {
105
+ // Malformed or missing input still answers continue, as the CLI did.
106
+ }
107
+ if (typeof event.agent_id === "string" && event.agent_id !== "")
108
+ return "subagent";
109
+ const sessionId = typeof event.session_id === "string" && event.session_id !== "" ? event.session_id : "unknown";
110
+ const toolName = typeof event.tool_name === "string" ? event.tool_name : "";
111
+ const file = stampPath(deps.stampDir, agent, sessionId);
112
+ const now = deps.now();
113
+ if (quiet(file, now))
114
+ return "quiet";
115
+ if (!fs.existsSync(deps.socketPath))
116
+ return "no-daemon";
117
+ stamp(deps.stampDir, file, now);
118
+ try {
119
+ await deps.send(deps.socketPath, {
120
+ kind: "message.send", from: `claude-code:${sessionId}`, to: agent,
121
+ content: `[Claude Code used ${toolName} in session ${sessionId}]`,
122
+ }, { timeoutMs: exports.POST_TOOL_USE_SEND_TIMEOUT_MS });
123
+ return "sent";
124
+ }
125
+ catch {
126
+ return "send-failed";
127
+ }
128
+ }
129
+ finally {
130
+ deps.writeStdout(JSON.stringify({ continue: true }));
131
+ }
132
+ }
133
+ /* v8 ignore start -- the real process's stdin, stdout and socket @preserve */
134
+ function defaultPostToolUseDeps() {
135
+ return {
136
+ readStdin: () => { try {
137
+ return fs.readFileSync(0, "utf-8");
138
+ }
139
+ catch {
140
+ return "";
141
+ } },
142
+ writeStdout: (text) => { process.stdout.write(text); },
143
+ socketPath: socket_client_1.DEFAULT_DAEMON_SOCKET_PATH,
144
+ stampDir: path.join(os.tmpdir(), "ouro-hook-post-tool-use"),
145
+ now: () => Date.now(),
146
+ send: (socketPath, command, options) => (0, socket_client_1.sendDaemonCommand)(socketPath, command, options),
147
+ };
148
+ }
149
+ /* v8 ignore stop */
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runOuroEntry = runOuroEntry;
4
+ // The ouro CLI, which ouro-entry.ts loads and runs for every command but the per-tool hook.
5
+ const compile_cache_1 = require("./compile-cache");
6
+ const runtime_1 = require("../../nerves/runtime");
7
+ const cli_arg_redaction_1 = require("./cli-arg-redaction");
8
+ const daemon_cli_1 = require("./daemon-cli");
9
+ const cli_gate_1 = require("./cli-gate");
10
+ const runtime_logging_1 = require("./runtime-logging");
11
+ const portable_git_1 = require("./portable-git");
12
+ /** Runs the CLI on the arguments after `ouro`. */
13
+ function runOuroEntry(args) {
14
+ if (args[0] === "shepherd" && args[1] !== "chat")
15
+ (0, runtime_logging_1.configureDaemonRuntimeLogger)("ouro", { machine: true });
16
+ else
17
+ (0, runtime_logging_1.configureDaemonRuntimeLogger)("ouro");
18
+ (0, portable_git_1.activatePortableGit)();
19
+ (0, runtime_1.emitNervesEvent)({
20
+ component: "daemon",
21
+ event: "daemon.cli_entry_start",
22
+ message: "starting ouro CLI entrypoint",
23
+ meta: { args: (0, cli_arg_redaction_1.redactCliArgs)(args), compileCache: compile_cache_1.ouroCompileCacheDirectory },
24
+ });
25
+ const gate = (0, cli_gate_1.gateCommandArgs)(args);
26
+ // A failure ends with the code its Ouro AX card names (see `ouro help --json`), so an agent can look up the fix.
27
+ const withCode = (message, code) => (typeof code === "string" ? `${message}\ncode: ${code}\n` : `${message}\n`);
28
+ if (gate.kind === "refuse") {
29
+ process.stderr.write(withCode(gate.message, gate.code));
30
+ process.exitCode = 1;
31
+ }
32
+ else if (gate.kind === "preview" || gate.kind === "help") {
33
+ process.stdout.write(`${gate.text}\n`);
34
+ }
35
+ else {
36
+ void (0, daemon_cli_1.runOuroCli)(gate.args).catch((error) => {
37
+ const message = error instanceof Error ? error.message : String(error);
38
+ const code = error instanceof Error ? error.code : undefined;
39
+ process.stderr.write(withCode(message, code));
40
+ (0, runtime_1.emitNervesEvent)({
41
+ level: "error",
42
+ component: "daemon",
43
+ event: "daemon.cli_entry_error",
44
+ message: "ouro CLI entrypoint failed",
45
+ meta: typeof code === "string" ? { error: message, code } : { error: message },
46
+ });
47
+ process.exit(1);
48
+ });
49
+ }
50
+ }
@@ -1,47 +1,46 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
4
37
  // First, so every later module can come from the compile cache.
5
- const compile_cache_1 = require("./compile-cache");
6
- const runtime_1 = require("../../nerves/runtime");
7
- const cli_arg_redaction_1 = require("./cli-arg-redaction");
8
- const daemon_cli_1 = require("./daemon-cli");
9
- const cli_gate_1 = require("./cli-gate");
10
- const runtime_logging_1 = require("./runtime-logging");
11
- const portable_git_1 = require("./portable-git");
12
- if (process.argv[2] === "shepherd" && process.argv[3] !== "chat")
13
- (0, runtime_logging_1.configureDaemonRuntimeLogger)("ouro", { machine: true });
38
+ require("./compile-cache");
39
+ const hook_post_tool_use_1 = require("./hook-post-tool-use");
40
+ // Claude Code runs `ouro hook post-tool-use` after every tool call in every session, so it skips loading the CLI
41
+ // (hook-post-tool-use.ts). Every other command loads it.
42
+ const argv = process.argv.slice(2);
43
+ if ((0, hook_post_tool_use_1.isPostToolUseHook)(argv))
44
+ void (0, hook_post_tool_use_1.runPostToolUseHook)(argv[3], (0, hook_post_tool_use_1.defaultPostToolUseDeps)());
14
45
  else
15
- (0, runtime_logging_1.configureDaemonRuntimeLogger)("ouro");
16
- (0, portable_git_1.activatePortableGit)();
17
- (0, runtime_1.emitNervesEvent)({
18
- component: "daemon",
19
- event: "daemon.cli_entry_start",
20
- message: "starting ouro CLI entrypoint",
21
- meta: { args: (0, cli_arg_redaction_1.redactCliArgs)(process.argv.slice(2)), compileCache: compile_cache_1.ouroCompileCacheDirectory },
22
- });
23
- const gate = (0, cli_gate_1.gateCommandArgs)(process.argv.slice(2));
24
- // A failure ends with the code its Ouro AX card names (see `ouro help --json`), so an agent can look up the fix.
25
- const withCode = (message, code) => (typeof code === "string" ? `${message}\ncode: ${code}\n` : `${message}\n`);
26
- if (gate.kind === "refuse") {
27
- process.stderr.write(withCode(gate.message, gate.code));
28
- process.exitCode = 1;
29
- }
30
- else if (gate.kind === "preview" || gate.kind === "help") {
31
- process.stdout.write(`${gate.text}\n`);
32
- }
33
- else {
34
- void (0, daemon_cli_1.runOuroCli)(gate.args).catch((error) => {
35
- const message = error instanceof Error ? error.message : String(error);
36
- const code = error instanceof Error ? error.code : undefined;
37
- process.stderr.write(withCode(message, code));
38
- (0, runtime_1.emitNervesEvent)({
39
- level: "error",
40
- component: "daemon",
41
- event: "daemon.cli_entry_error",
42
- message: "ouro CLI entrypoint failed",
43
- meta: typeof code === "string" ? { error: message, code } : { error: message },
44
- });
45
- process.exit(1);
46
- });
47
- }
46
+ void Promise.resolve().then(() => __importStar(require("./ouro-cli-main"))).then(({ runOuroEntry }) => runOuroEntry(argv));
@@ -176,6 +176,9 @@ const DISPATCH_EXEMPT_PATTERNS = [
176
176
  // Loaded first by the CLI entry points, before any project module, so it cannot import nerves; the entry's own
177
177
  // start event reports the compile cache directory it chose.
178
178
  "daemon/compile-cache",
179
+ // The CLI's entry point only picks a module: the per-tool hook (which emits daemon.hook_post_tool_use) or the CLI
180
+ // (ouro-cli-main.ts, which emits the entry's start events). It stays this small so the hook loads nothing else.
181
+ "heart/daemon/ouro-entry.ts",
179
182
  ];
180
183
  function isDispatchExempt(filePath) {
181
184
  return DISPATCH_EXEMPT_PATTERNS.some((pattern) => filePath.includes(pattern));
@@ -51,7 +51,7 @@ exports.reportFailureToolDefinition = {
51
51
  type: "function",
52
52
  function: {
53
53
  name: "report_failure",
54
- description: "File a failure report for the engineers who fix you, when a tool you need is missing or errors in a way you cannot work around. Finding that no tool covers what the owner asked is exactly this case: file the report before you settle, so the gap reaches someone who can fill it. File it at once and ask the owner for nothing. Report the actual result (queued, or saved locally pending authorization); never claim delivery or a GitHub issue from a local save. A repeat retries the same report.",
54
+ description: "File a failure report for the engineers who fix you, when a tool you need is missing or errors in a way you cannot work around. Finding that no tool covers what the owner asked is exactly this case: file the report before you settle, so the gap reaches someone who can fill it. File it at once and ask the owner for nothing. The result says what happened: queued, or saved locally pending authorization; a local save is not a delivery or a GitHub issue. A repeat retries the same report.",
55
55
  parameters: {
56
56
  type: "object",
57
57
  properties: {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1371",
3
+ "version": "0.1.0-alpha.1373",
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.1371",
9
+ "version": "0.1.0-alpha.1373",
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.1371",
3
+ "version": "0.1.0-alpha.1373",
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": {