@ouro.bot/cli 0.1.0-alpha.1285 → 0.1.0-alpha.1286

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.1286",
6
+ "changes": [
7
+ "In an Orca terminal, ouro chat reports its status (working, done with the reply, error) through Orca's terminal status protocol (OSC 7501), so the chat appears in Orca's sidebar, Agent Dashboard, notifications and orca agent list. Other terminals get nothing new."
8
+ ]
9
+ },
4
10
  {
5
11
  "version": "0.1.0-alpha.1285",
6
12
  "changes": [
@@ -1,5 +1,5 @@
1
1
  {
2
- "runtimeVersion": "0.1.0-alpha.1285",
2
+ "runtimeVersion": "0.1.0-alpha.1286",
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.1285</Repository>
4
+ <Repository>ghcr.io/ourostack/ouroboros-butler:0.1.0-alpha.1286</Repository>
5
5
  <Registry>https://github.com/ourostack/ouroboros/pkgs/container/ouroboros-butler</Registry>
6
6
  <Network>host</Network>
7
7
  <Shell>sh</Shell>
@@ -70,6 +70,7 @@ const runtime_1 = require("../nerves/runtime");
70
70
  const trust_gate_1 = require("./trust-gate");
71
71
  const pipeline_1 = require("./pipeline");
72
72
  const session_transaction_1 = require("../mind/session-transaction");
73
+ const program_status_1 = require("./program-status");
73
74
  const update_hooks_1 = require("../heart/versioning/update-hooks");
74
75
  const bundle_meta_1 = require("../heart/daemon/hooks/bundle-meta");
75
76
  const agent_config_v2_1 = require("../heart/daemon/hooks/agent-config-v2");
@@ -684,6 +685,16 @@ async function runCliSession(options) {
684
685
  console.log(`\n${bannerText}\n`);
685
686
  }
686
687
  }
688
+ const programStatus = options.programStatus ?? (0, program_status_1.createProgramStatusReporter)({ agentName: options.agentName });
689
+ cliCallbacks = programStatus.wrap(cliCallbacks);
690
+ let messagesBeforeTurn = new Set();
691
+ const reportTurnStart = () => {
692
+ messagesBeforeTurn = new Set(messages);
693
+ programStatus.working();
694
+ };
695
+ const reportTurnEnd = (aborted, outcome) => {
696
+ programStatus.turnEnded({ outcome, aborted, reply: (0, program_status_1.assistantTextSince)(messages, messagesBeforeTurn) });
697
+ };
687
698
  // Display helpers: route to TUI store or imperative stderr/stdout
688
699
  const display = {
689
700
  error: (msg) => {
@@ -753,6 +764,8 @@ async function runCliSession(options) {
753
764
  // speaks first (e.g. specialist greeting). Only triggers when explicitly opted in.
754
765
  if (options.autoFirstTurn && messages.length > 0 && messages[messages.length - 1]?.role === "user") {
755
766
  currentAbort = new AbortController();
767
+ // The person's message is already in place, so the reply comes after it.
768
+ reportTurnStart();
756
769
  const traceId = (0, nerves_1.createTraceId)();
757
770
  display.suppressInput();
758
771
  let result;
@@ -768,10 +781,12 @@ async function runCliSession(options) {
768
781
  catch (err) {
769
782
  if (!(err instanceof DOMException && err.name === "AbortError")) {
770
783
  display.error(err instanceof Error ? err.message : String(err));
784
+ programStatus.error(err instanceof Error ? err.message : String(err));
771
785
  }
772
786
  }
773
787
  cliCallbacks.flushMarkdown();
774
788
  display.restoreInput();
789
+ reportTurnEnd(currentAbort.signal.aborted, result?.outcome);
775
790
  currentAbort = null;
776
791
  if (exitToolFired) {
777
792
  exitReason = "tool_exit";
@@ -787,6 +802,7 @@ async function runCliSession(options) {
787
802
  }
788
803
  }
789
804
  }
805
+ programStatus.idle();
790
806
  try {
791
807
  // Input source: TUI queue for Ink, test source for tests, readline fallback
792
808
  let inputSource;
@@ -847,6 +863,7 @@ async function runCliSession(options) {
847
863
  if (tuiStore)
848
864
  tuiStore.addUserMessage(input);
849
865
  currentAbort = new AbortController();
866
+ reportTurnStart();
850
867
  if (tuiStore)
851
868
  tuiStore.suppressInput();
852
869
  inputCtrl?.suppress(() => { currentAbort?.abort(); });
@@ -870,6 +887,8 @@ async function runCliSession(options) {
870
887
  }
871
888
  // For "response" commands: the pipeline already emitted the response via onTextChunk
872
889
  cliCallbacks.flushMarkdown();
890
+ // A slash command is not a turn the person waits on, so the chat goes back to rest.
891
+ programStatus.idle();
873
892
  continue;
874
893
  }
875
894
  }
@@ -895,6 +914,7 @@ async function runCliSession(options) {
895
914
  catch (err) {
896
915
  if (!(err instanceof DOMException && err.name === "AbortError")) {
897
916
  display.error(err instanceof Error ? err.message : String(err));
917
+ programStatus.error(err instanceof Error ? err.message : String(err));
898
918
  }
899
919
  }
900
920
  cliCallbacks.flushMarkdown();
@@ -903,6 +923,7 @@ async function runCliSession(options) {
903
923
  if (tuiStore)
904
924
  tuiStore.restoreInput();
905
925
  inputCtrl?.restore();
926
+ reportTurnEnd(currentAbort.signal.aborted, result?.turnOutcome ?? result?.outcome);
906
927
  currentAbort = null;
907
928
  // Check if exit tool was fired during this turn
908
929
  if (exitToolFired) {
@@ -927,6 +948,7 @@ async function runCliSession(options) {
927
948
  }
928
949
  }
929
950
  finally {
951
+ programStatus.clear();
930
952
  rl?.close();
931
953
  releaseTerminal?.();
932
954
  if (inkRef) {
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROGRAM_STATUS_APP = void 0;
4
+ exports.programStatusText = programStatusText;
5
+ exports.formatProgramStatus = formatProgramStatus;
6
+ exports.terminalReadsProgramStatus = terminalReadsProgramStatus;
7
+ exports.createProgramStatusReporter = createProgramStatusReporter;
8
+ exports.assistantTextSince = assistantTextSince;
9
+ const runtime_1 = require("../nerves/runtime");
10
+ /** The `app` id Orca shows as the agent's type. */
11
+ exports.PROGRAM_STATUS_APP = "ouro";
12
+ // The protocol caps msg at 2048 decoded bytes and title at 192; these stay well inside both.
13
+ const MAX_MSG_CHARS = 240;
14
+ const MAX_TITLE_CHARS = 48;
15
+ // The protocol drops a report whose text holds C0, DEL or C1 controls.
16
+ // eslint-disable-next-line no-control-regex -- matching the controls the protocol refuses
17
+ const CONTROLS = /[\u0000-\u001f\u007f-\u009f]+/g;
18
+ /** One line of plain text, or undefined when nothing is left. */
19
+ function programStatusText(text, maxChars) {
20
+ if (!text)
21
+ return undefined;
22
+ const line = text.replace(CONTROLS, " ").replace(/\s+/g, " ").trim();
23
+ if (!line)
24
+ return undefined;
25
+ const chars = Array.from(line);
26
+ return chars.length <= maxChars ? line : `${chars.slice(0, maxChars - 1).join("").trimEnd()}…`;
27
+ }
28
+ /** The OSC 7501 sequence for one report. */
29
+ function formatProgramStatus(report, app = exports.PROGRAM_STATUS_APP) {
30
+ const pairs = [`state=${report.state}`];
31
+ if (report.state !== "clear") {
32
+ pairs.push(`app=${app}`);
33
+ if (report.state === "blocked" && report.kind)
34
+ pairs.push(`kind=${report.kind}`);
35
+ const msg = programStatusText(report.msg, MAX_MSG_CHARS);
36
+ if (msg)
37
+ pairs.push(`msg=${Buffer.from(msg, "utf8").toString("base64")}`);
38
+ const title = programStatusText(report.title, MAX_TITLE_CHARS);
39
+ if (title)
40
+ pairs.push(`title=${Buffer.from(title, "utf8").toString("base64")}`);
41
+ }
42
+ return `\x1b]7501;${pairs.join(":")}\x1b\\`;
43
+ }
44
+ /** Whether this terminal reads OSC 7501. Only Orca is known to, so other terminals get nothing. */
45
+ function terminalReadsProgramStatus(env, isTTY) {
46
+ if (!isTTY)
47
+ return false;
48
+ return env.TERM_PROGRAM === "Orca" || Boolean(env.ORCA_PANE_KEY);
49
+ }
50
+ /** "query_calendar" → "query calendar". */
51
+ function toolLabel(name) {
52
+ return name.replace(/[_-]+/g, " ").trim() || name;
53
+ }
54
+ function createProgramStatusReporter(options) {
55
+ const env = options.env ?? process.env;
56
+ const isTTY = options.isTTY ?? process.stdout.isTTY === true;
57
+ const enabled = terminalReadsProgramStatus(env, isTTY);
58
+ const write = options.write ?? ((chunk) => { process.stdout.write(chunk); });
59
+ const title = options.agentName;
60
+ let last = null;
61
+ let lastState = null;
62
+ const report = (next) => {
63
+ if (!enabled)
64
+ return;
65
+ // A failed turn stays failed: the turn's end must not paint it done.
66
+ if (next.state === "done" && lastState === "error")
67
+ return;
68
+ lastState = next.state;
69
+ const sequence = formatProgramStatus({ ...next, title });
70
+ // Repeats carry nothing new, so a busy turn does not flood the terminal.
71
+ if (sequence === last)
72
+ return;
73
+ last = sequence;
74
+ try {
75
+ write(sequence);
76
+ }
77
+ catch (error) {
78
+ // A closed terminal must never break the chat.
79
+ (0, runtime_1.emitNervesEvent)({
80
+ level: "warn",
81
+ component: "senses",
82
+ event: "senses.program_status_write_error",
83
+ message: "could not write a program status report",
84
+ meta: { state: next.state, error: error instanceof Error ? error.message : String(error) },
85
+ });
86
+ return;
87
+ }
88
+ (0, runtime_1.emitNervesEvent)({
89
+ component: "senses",
90
+ event: "senses.program_status_report",
91
+ message: "reported chat status to the terminal",
92
+ meta: { state: next.state },
93
+ });
94
+ };
95
+ const reporter = {
96
+ enabled,
97
+ idle: () => report({ state: "idle" }),
98
+ working: (msg) => report({ state: "working", msg }),
99
+ done: (reply) => report({ state: "done", msg: reply }),
100
+ error: (msg) => report({ state: "error", msg }),
101
+ blocked: (kind, msg) => report({ state: "blocked", kind, msg }),
102
+ clear: () => report({ state: "clear" }),
103
+ turnEnded: ({ outcome, aborted, reply }) => {
104
+ const line = firstLine(reply);
105
+ if (aborted || outcome === "aborted")
106
+ return reporter.idle();
107
+ // Keep the more specific error a terminal onError already reported for this turn.
108
+ if (outcome === "errored")
109
+ return lastState === "error" ? undefined : reporter.error(line ?? "The turn failed.");
110
+ // The engine failed closed and said why.
111
+ if (outcome === "blocked")
112
+ return reporter.error(line ?? "The turn was blocked.");
113
+ if (outcome === "suspended")
114
+ return reporter.blocked("permission", line ?? "Waiting for your approval.");
115
+ // A turn that was declined, or produced no reply, has nothing to show.
116
+ if (line === undefined)
117
+ return reporter.idle();
118
+ reporter.done(line);
119
+ },
120
+ wrap: (callbacks) => {
121
+ if (!enabled)
122
+ return callbacks;
123
+ return {
124
+ ...callbacks,
125
+ onToolStart: (name, args) => {
126
+ reporter.working(`Using ${toolLabel(name)}`);
127
+ callbacks.onToolStart(name, args);
128
+ },
129
+ onError: (error, severity) => {
130
+ if (severity === "terminal")
131
+ reporter.error(error.message);
132
+ callbacks.onError(error, severity);
133
+ },
134
+ };
135
+ },
136
+ };
137
+ return reporter;
138
+ }
139
+ /** The first line of text that has something on it. */
140
+ function firstLine(text) {
141
+ return text?.split(/\r?\n/).find((line) => line.trim());
142
+ }
143
+ /** The newest assistant text added since the turn began, so a turn never shows an earlier turn's reply.
144
+ * `before` holds the messages present when it began; identity, not position, because trimming rewrites the array. */
145
+ function assistantTextSince(messages, before) {
146
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
147
+ const message = messages[index];
148
+ if (before.has(message) || message.role === "user")
149
+ return undefined;
150
+ if (message.role === "assistant" && typeof message.content === "string" && message.content.trim()) {
151
+ return message.content;
152
+ }
153
+ }
154
+ return undefined;
155
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.1285",
3
+ "version": "0.1.0-alpha.1286",
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.1285",
9
+ "version": "0.1.0-alpha.1286",
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.1285",
3
+ "version": "0.1.0-alpha.1286",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },