@ouro.bot/cli 0.1.0-alpha.153 → 0.1.0-alpha.154

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,16 @@
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.154",
6
+ "changes": [
7
+ "feat: clean tool status messages \u2014 human-readable by default, /debug toggle",
8
+ "humanReadableToolDescription derives from tool name+args, not hardcoded map",
9
+ "Shared tool activity callbacks (DRY) \u2014 senses only provide render function",
10
+ "Slash command handling moved to pipeline \u2014 all senses get /debug for free",
11
+ "BlueBubbles: one clean iMessage per tool, not raw shared work: processing"
12
+ ]
13
+ },
4
14
  {
5
15
  "version": "0.1.0-alpha.153",
6
16
  "changes": [
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createToolActivityCallbacks = createToolActivityCallbacks;
4
+ const tool_description_1 = require("./tool-description");
5
+ const runtime_1 = require("../nerves/runtime");
6
+ function createToolActivityCallbacks(options) {
7
+ (0, runtime_1.emitNervesEvent)({
8
+ component: "engine",
9
+ event: "engine.tool_activity_callbacks_created",
10
+ message: "tool activity callbacks initialized",
11
+ meta: { isDebug: options.isDebug },
12
+ });
13
+ return {
14
+ onToolStart(name, args) {
15
+ const description = (0, tool_description_1.humanReadableToolDescription)(name, args);
16
+ if (description === null)
17
+ return; // hidden tool (settle, rest)
18
+ options.onDescription(description);
19
+ },
20
+ onToolEnd(name, summary, success) {
21
+ if (!success) {
22
+ options.onFailure(`${name} failed: ${summary}`);
23
+ return;
24
+ }
25
+ if (options.isDebug) {
26
+ options.onResult(`${name}: ${summary}`);
27
+ }
28
+ },
29
+ };
30
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.humanReadableToolDescription = humanReadableToolDescription;
4
+ const runtime_1 = require("../nerves/runtime");
5
+ function basename(filePath) {
6
+ const idx = filePath.lastIndexOf("/");
7
+ return idx >= 0 ? filePath.slice(idx + 1) : filePath;
8
+ }
9
+ function truncate(text, max) {
10
+ if (text.length <= max)
11
+ return text;
12
+ return text.slice(0, max - 1) + "\u2026";
13
+ }
14
+ const TOOL_DESCRIPTIONS = {
15
+ shell: (args) => {
16
+ const cmd = args.command;
17
+ if (!cmd)
18
+ return "running a command...";
19
+ return `running ${truncate(cmd, 50)}...`;
20
+ },
21
+ read_file: (args) => {
22
+ const fp = args.path || args.file_path;
23
+ if (!fp)
24
+ return "reading a file...";
25
+ return `reading ${basename(fp)}...`;
26
+ },
27
+ write_file: (args) => {
28
+ const fp = args.path || args.file_path;
29
+ if (!fp)
30
+ return "writing a file...";
31
+ return `writing ${basename(fp)}...`;
32
+ },
33
+ edit_file: (args) => {
34
+ const fp = args.path || args.file_path;
35
+ if (!fp)
36
+ return "editing a file...";
37
+ return `editing ${basename(fp)}...`;
38
+ },
39
+ recall: (args) => {
40
+ const q = args.query;
41
+ if (!q)
42
+ return "searching memory...";
43
+ return `searching memory for '${truncate(q, 40)}'...`;
44
+ },
45
+ grep: (args) => {
46
+ const p = args.pattern;
47
+ if (!p)
48
+ return "searching code...";
49
+ return `searching code for '${truncate(p, 40)}'...`;
50
+ },
51
+ glob: (args) => {
52
+ const p = args.pattern;
53
+ if (!p)
54
+ return "searching for files...";
55
+ return `searching for ${truncate(p, 40)}...`;
56
+ },
57
+ query_session: () => "checking session history...",
58
+ web_search: () => "searching the web...",
59
+ coding_spawn: () => "starting coding session...",
60
+ ponder: () => "thinking deeper...",
61
+ observe: () => "listening...",
62
+ diary_write: () => "noting something down...",
63
+ save_friend_note: () => "making a note...",
64
+ settle: () => null,
65
+ rest: () => null,
66
+ };
67
+ function humanReadableToolDescription(name, args) {
68
+ (0, runtime_1.emitNervesEvent)({
69
+ component: "engine",
70
+ event: "engine.tool_description",
71
+ message: "generated human-readable tool description",
72
+ meta: { tool: name },
73
+ });
74
+ const builder = TOOL_DESCRIPTIONS[name];
75
+ if (builder)
76
+ return builder(args);
77
+ // MCP tools: mcp__server__toolname — extract last segment
78
+ if (name.startsWith("mcp__")) {
79
+ const parts = name.split("__");
80
+ const toolName = parts[parts.length - 1];
81
+ return `using ${toolName}...`;
82
+ }
83
+ return `using ${name}...`;
84
+ }
@@ -57,7 +57,7 @@ const channel_1 = require("../mind/friends/channel");
57
57
  const pending_1 = require("../mind/pending");
58
58
  const prompt_1 = require("../mind/prompt");
59
59
  const mcp_manager_1 = require("../repertoire/mcp-manager");
60
- const phrases_1 = require("../mind/phrases");
60
+ // getPhrases removed — no longer needed after debug-activity cleanup
61
61
  const runtime_1 = require("../nerves/runtime");
62
62
  const bluebubbles_model_1 = require("./bluebubbles-model");
63
63
  const bluebubbles_client_1 = require("./bluebubbles-client");
@@ -65,7 +65,8 @@ const bluebubbles_inbound_log_1 = require("./bluebubbles-inbound-log");
65
65
  const bluebubbles_mutation_log_1 = require("./bluebubbles-mutation-log");
66
66
  const bluebubbles_runtime_state_1 = require("./bluebubbles-runtime-state");
67
67
  const bluebubbles_session_cleanup_1 = require("./bluebubbles-session-cleanup");
68
- const debug_activity_1 = require("./debug-activity");
68
+ const tool_activity_callbacks_1 = require("../heart/tool-activity-callbacks");
69
+ const commands_1 = require("./commands");
69
70
  const trust_gate_1 = require("./trust-gate");
70
71
  const pipeline_1 = require("./pipeline");
71
72
  const bbFailoverStates = new Map();
@@ -362,63 +363,58 @@ function emitBlueBubblesMarkReadWarning(chat, error) {
362
363
  }
363
364
  function createBlueBubblesCallbacks(client, chat, replyTarget, isGroupChat) {
364
365
  let textBuffer = "";
365
- const phrases = (0, phrases_1.getPhrases)();
366
- const activity = (0, debug_activity_1.createDebugActivityController)({
367
- thinkingPhrases: phrases.thinking,
368
- followupPhrases: phrases.followup,
369
- startTypingOnModelStart: !isGroupChat,
370
- startTypingOnFirstTextChunk: isGroupChat,
371
- suppressInitialModelStatus: true,
372
- suppressFollowupPhraseStatus: true,
373
- transport: {
374
- sendStatus: async (text) => {
375
- const sent = await client.sendText({
376
- chat,
377
- text,
378
- replyToMessageGuid: replyTarget.getReplyToMessageGuid(),
379
- });
380
- return sent.messageGuid;
381
- },
382
- editStatus: async (_messageGuid, text) => {
383
- await client.sendText({
384
- chat,
385
- text,
386
- replyToMessageGuid: replyTarget.getReplyToMessageGuid(),
387
- });
388
- },
389
- setTyping: async (active) => {
390
- if (!active) {
391
- await client.setTyping(chat, false);
392
- return;
393
- }
394
- const [markReadResult, typingResult] = await Promise.allSettled([
395
- client.markChatRead(chat),
396
- client.setTyping(chat, true),
397
- ]);
398
- if (markReadResult.status === "rejected") {
399
- emitBlueBubblesMarkReadWarning(chat, markReadResult.reason);
400
- }
401
- if (typingResult.status === "rejected") {
402
- throw typingResult.reason;
403
- }
404
- },
405
- },
406
- onTransportError: (operation, error) => {
366
+ let typingActive = false;
367
+ let queue = Promise.resolve();
368
+ function enqueue(operation, task) {
369
+ queue = queue.then(task).catch((error) => {
407
370
  (0, runtime_1.emitNervesEvent)({
408
371
  level: "warn",
409
372
  component: "senses",
410
373
  event: "senses.bluebubbles_activity_error",
411
374
  message: "bluebubbles activity transport failed",
412
- meta: {
413
- operation,
414
- reason: error instanceof Error ? error.message : String(error),
415
- },
375
+ meta: { operation, reason: error instanceof Error ? error.message : String(error) },
416
376
  });
417
- },
377
+ });
378
+ }
379
+ function startTypingNow() {
380
+ /* v8 ignore next -- defensive guard: callers already check typingActive @preserve */
381
+ if (typingActive)
382
+ return;
383
+ typingActive = true;
384
+ enqueue("typing_start", async () => {
385
+ const [markReadResult, typingResult] = await Promise.allSettled([
386
+ client.markChatRead(chat),
387
+ client.setTyping(chat, true),
388
+ ]);
389
+ if (markReadResult.status === "rejected") {
390
+ emitBlueBubblesMarkReadWarning(chat, markReadResult.reason);
391
+ }
392
+ if (typingResult.status === "rejected") {
393
+ throw typingResult.reason;
394
+ }
395
+ });
396
+ }
397
+ function sendStatus(text) {
398
+ enqueue("send_status", async () => {
399
+ await client.sendText({
400
+ chat,
401
+ text,
402
+ replyToMessageGuid: replyTarget.getReplyToMessageGuid(),
403
+ });
404
+ });
405
+ }
406
+ const toolCallbacks = (0, tool_activity_callbacks_1.createToolActivityCallbacks)({
407
+ onDescription: (text) => sendStatus(text),
408
+ /* v8 ignore next -- onResult only called in debug mode; tested via tool-activity-callbacks.test.ts @preserve */
409
+ onResult: (text) => sendStatus(text),
410
+ /* v8 ignore next -- onFailure only called on tool failure; tested via tool-activity-callbacks.test.ts @preserve */
411
+ onFailure: (text) => sendStatus(`\u2717 ${text}`),
412
+ isDebug: (0, commands_1.getDebugMode)(),
418
413
  });
419
414
  return {
420
415
  onModelStart() {
421
- activity.onModelStart();
416
+ if (!isGroupChat)
417
+ startTypingNow();
422
418
  (0, runtime_1.emitNervesEvent)({
423
419
  component: "senses",
424
420
  event: "senses.bluebubbles_turn_start",
@@ -435,12 +431,16 @@ function createBlueBubblesCallbacks(client, chat, replyTarget, isGroupChat) {
435
431
  });
436
432
  },
437
433
  onTextChunk(text) {
438
- activity.onTextChunk(text);
434
+ if (isGroupChat && !typingActive)
435
+ startTypingNow();
439
436
  textBuffer += text;
440
437
  },
441
438
  onReasoningChunk(_text) { },
442
439
  onToolStart(name, _args) {
443
- activity.onToolStart(name, _args);
440
+ // Tool activity is a reply commitment — start typing if not already
441
+ if (!typingActive)
442
+ startTypingNow();
443
+ toolCallbacks.onToolStart(name, _args);
444
444
  (0, runtime_1.emitNervesEvent)({
445
445
  component: "senses",
446
446
  event: "senses.bluebubbles_tool_start",
@@ -449,7 +449,7 @@ function createBlueBubblesCallbacks(client, chat, replyTarget, isGroupChat) {
449
449
  });
450
450
  },
451
451
  onToolEnd(name, summary, success) {
452
- activity.onToolEnd(name, summary, success);
452
+ toolCallbacks.onToolEnd(name, summary, success);
453
453
  (0, runtime_1.emitNervesEvent)({
454
454
  component: "senses",
455
455
  event: "senses.bluebubbles_tool_end",
@@ -458,7 +458,7 @@ function createBlueBubblesCallbacks(client, chat, replyTarget, isGroupChat) {
458
458
  });
459
459
  },
460
460
  onError(error, severity) {
461
- activity.onError(error);
461
+ sendStatus(`\u2717 ${error.message}`);
462
462
  (0, runtime_1.emitNervesEvent)({
463
463
  level: severity === "terminal" ? "error" : "warn",
464
464
  component: "senses",
@@ -471,14 +471,23 @@ function createBlueBubblesCallbacks(client, chat, replyTarget, isGroupChat) {
471
471
  textBuffer = "";
472
472
  },
473
473
  async flush() {
474
- await activity.drain();
474
+ await queue;
475
475
  const trimmed = textBuffer.trim();
476
476
  if (!trimmed) {
477
- await activity.finish();
477
+ if (typingActive) {
478
+ typingActive = false;
479
+ enqueue("typing_stop", async () => { await client.setTyping(chat, false); });
480
+ await queue;
481
+ }
478
482
  return;
479
483
  }
480
484
  textBuffer = "";
481
- await activity.finish();
485
+ /* v8 ignore next 4 -- branch: typing may already be stopped before flush @preserve */
486
+ if (typingActive) {
487
+ typingActive = false;
488
+ enqueue("typing_stop", async () => { await client.setTyping(chat, false); });
489
+ await queue;
490
+ }
482
491
  await client.sendText({
483
492
  chat,
484
493
  text: trimmed,
@@ -486,7 +495,13 @@ function createBlueBubblesCallbacks(client, chat, replyTarget, isGroupChat) {
486
495
  });
487
496
  },
488
497
  async finish() {
489
- await activity.finish();
498
+ if (!typingActive) {
499
+ await queue;
500
+ return;
501
+ }
502
+ typingActive = false;
503
+ enqueue("typing_stop", async () => { await client.setTyping(chat, false); });
504
+ await queue;
490
505
  },
491
506
  };
492
507
  }
@@ -660,28 +660,30 @@ async function runCliSession(options) {
660
660
  continue;
661
661
  }
662
662
  }
663
- // Check for slash commands
664
- const parsed = (0, commands_1.parseSlashCommand)(input);
665
- if (parsed) {
666
- const dispatchResult = registry.dispatch(parsed.command, { channel: "cli" });
667
- if (dispatchResult.handled && dispatchResult.result) {
668
- if (dispatchResult.result.action === "exit") {
669
- break;
670
- }
671
- else if (dispatchResult.result.action === "new") {
672
- messages.length = 0;
673
- messages.push({ role: "system", content: await (0, prompt_1.buildSystem)("cli") });
674
- await options.onNewSession?.();
675
- // eslint-disable-next-line no-console -- terminal UX: session cleared
676
- console.log("session cleared");
677
- process.stdout.write(CLI_PROMPT);
678
- continue;
679
- }
680
- else if (dispatchResult.result.action === "response") {
681
- // eslint-disable-next-line no-console -- terminal UX: command dispatch result
682
- console.log(dispatchResult.result.message || "");
683
- process.stdout.write(CLI_PROMPT);
684
- continue;
663
+ // Check for slash commands (legacy path only — pipeline handles commands for runTurn path)
664
+ if (!options.runTurn) {
665
+ const parsed = (0, commands_1.parseSlashCommand)(input);
666
+ if (parsed) {
667
+ const dispatchResult = registry.dispatch(parsed.command, { channel: "cli" });
668
+ if (dispatchResult.handled && dispatchResult.result) {
669
+ if (dispatchResult.result.action === "exit") {
670
+ break;
671
+ }
672
+ else if (dispatchResult.result.action === "new") {
673
+ messages.length = 0;
674
+ messages.push({ role: "system", content: await (0, prompt_1.buildSystem)("cli") });
675
+ await options.onNewSession?.();
676
+ // eslint-disable-next-line no-console -- terminal UX: session cleared
677
+ console.log("session cleared");
678
+ process.stdout.write(CLI_PROMPT);
679
+ continue;
680
+ }
681
+ else if (dispatchResult.result.action === "response") {
682
+ // eslint-disable-next-line no-console -- terminal UX: command dispatch result
683
+ console.log(dispatchResult.result.message || "");
684
+ process.stdout.write(CLI_PROMPT);
685
+ continue;
686
+ }
685
687
  }
686
688
  }
687
689
  }
@@ -696,7 +698,27 @@ async function runCliSession(options) {
696
698
  if (options.runTurn) {
697
699
  // Pipeline-based turn: the runTurn callback handles user message assembly,
698
700
  // pending drain, trust gate, runAgent, postTurn, and token accumulation.
701
+ // Commands (e.g. /debug, /exit, /new) are intercepted in the pipeline.
699
702
  result = await options.runTurn(messages, input, cliCallbacks, currentAbort.signal, effectiveToolContext);
703
+ // Handle pipeline-intercepted commands with loop-control side effects
704
+ if (result?.turnOutcome === "command") {
705
+ if (result.commandAction === "exit") {
706
+ break;
707
+ }
708
+ else if (result.commandAction === "new") {
709
+ messages.length = 0;
710
+ messages.push({ role: "system", content: await (0, prompt_1.buildSystem)("cli") });
711
+ await options.onNewSession?.();
712
+ // eslint-disable-next-line no-console -- terminal UX: session cleared
713
+ console.log("session cleared");
714
+ process.stdout.write(CLI_PROMPT);
715
+ continue;
716
+ }
717
+ // For "response" commands: the pipeline already emitted the response via onTextChunk
718
+ cliCallbacks.flushMarkdown();
719
+ process.stdout.write(CLI_PROMPT);
720
+ continue;
721
+ }
700
722
  }
701
723
  else {
702
724
  // Legacy path: inline runAgent (used by adoption specialist and tests)
@@ -898,7 +920,7 @@ async function main(agentName, options) {
898
920
  process.stdout.write(`${result.gateResult.autoReply}\n`);
899
921
  }
900
922
  }
901
- return { usage: result.usage };
923
+ return { usage: result.usage, turnOutcome: result.turnOutcome, commandAction: result.commandAction };
902
924
  },
903
925
  onNewSession: () => {
904
926
  (0, context_1.deleteSession)(sessPath);
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCommandRegistry = createCommandRegistry;
4
4
  exports.getToolChoiceRequired = getToolChoiceRequired;
5
5
  exports.resetToolChoiceRequired = resetToolChoiceRequired;
6
+ exports.getDebugMode = getDebugMode;
7
+ exports.resetDebugMode = resetDebugMode;
6
8
  exports.registerDefaultCommands = registerDefaultCommands;
9
+ exports.getSharedCommandRegistry = getSharedCommandRegistry;
10
+ exports.resetSharedCommandRegistry = resetSharedCommandRegistry;
7
11
  exports.parseSlashCommand = parseSlashCommand;
8
12
  const identity_1 = require("../heart/identity");
9
13
  const runtime_1 = require("../nerves/runtime");
@@ -35,6 +39,14 @@ function getToolChoiceRequired() {
35
39
  function resetToolChoiceRequired() {
36
40
  _toolChoiceRequired = false;
37
41
  }
42
+ // Module-level toggle for debug mode
43
+ let _debugMode = false;
44
+ function getDebugMode() {
45
+ return _debugMode;
46
+ }
47
+ function resetDebugMode() {
48
+ _debugMode = false;
49
+ }
38
50
  function registerDefaultCommands(registry) {
39
51
  (0, runtime_1.emitNervesEvent)({
40
52
  event: "repertoire.load_start",
@@ -73,6 +85,15 @@ function registerDefaultCommands(registry) {
73
85
  return { action: "response", message: `tool-required mode: ${_toolChoiceRequired ? "ON" : "OFF"}` };
74
86
  },
75
87
  });
88
+ registry.register({
89
+ name: "debug",
90
+ description: "toggle debug mode (verbose tool output)",
91
+ channels: ["cli", "teams", "bluebubbles"],
92
+ handler: () => {
93
+ _debugMode = !_debugMode;
94
+ return { action: "response", message: `debug mode: ${_debugMode ? "ON" : "OFF"}` };
95
+ },
96
+ });
76
97
  (0, runtime_1.emitNervesEvent)({
77
98
  event: "repertoire.load_end",
78
99
  component: "repertoire",
@@ -80,6 +101,17 @@ function registerDefaultCommands(registry) {
80
101
  meta: {},
81
102
  });
82
103
  }
104
+ let _sharedRegistry = null;
105
+ function getSharedCommandRegistry() {
106
+ if (!_sharedRegistry) {
107
+ _sharedRegistry = createCommandRegistry();
108
+ registerDefaultCommands(_sharedRegistry);
109
+ }
110
+ return _sharedRegistry;
111
+ }
112
+ function resetSharedCommandRegistry() {
113
+ _sharedRegistry = null;
114
+ }
83
115
  function parseSlashCommand(input) {
84
116
  const trimmed = input.trim();
85
117
  if (!trimmed.startsWith("/"))
@@ -7,6 +7,7 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.handleInboundTurn = handleInboundTurn;
9
9
  const runtime_1 = require("../nerves/runtime");
10
+ const commands_1 = require("./commands");
10
11
  const continuity_1 = require("./continuity");
11
12
  const manager_1 = require("../heart/bridges/manager");
12
13
  const identity_1 = require("../heart/identity");
@@ -167,6 +168,41 @@ async function handleInboundTurn(input) {
167
168
  // Switch failed OR succeeded — either way, fall through to normal processing.
168
169
  }
169
170
  }
171
+ // Step 0b: Slash command interception (before friend resolution / agent turn)
172
+ {
173
+ const firstUserMsg = input.messages.find((m) => m.role === "user");
174
+ const userText = firstUserMsg
175
+ ? (typeof firstUserMsg.content === "string"
176
+ ? firstUserMsg.content
177
+ : Array.isArray(firstUserMsg.content)
178
+ ? firstUserMsg.content.find((p) => p.type === "text")?.text ?? ""
179
+ : /* v8 ignore next -- defensive: content is always string or array @preserve */ "")
180
+ : "";
181
+ const parsed = (0, commands_1.parseSlashCommand)(userText);
182
+ if (parsed) {
183
+ const registry = (0, commands_1.getSharedCommandRegistry)();
184
+ const dispatchResult = registry.dispatch(parsed.command, { channel: input.channel });
185
+ if (dispatchResult.handled && dispatchResult.result) {
186
+ (0, runtime_1.emitNervesEvent)({
187
+ component: "senses",
188
+ event: "senses.pipeline_command",
189
+ message: `slash command intercepted: /${parsed.command}`,
190
+ meta: { command: parsed.command, channel: input.channel },
191
+ });
192
+ if (dispatchResult.result.message) {
193
+ input.callbacks.onTextChunk(dispatchResult.result.message);
194
+ }
195
+ // Return a minimal result — no agent turn, no session write
196
+ const resolvedContext = await input.friendResolver.resolve();
197
+ return {
198
+ resolvedContext,
199
+ gateResult: { allowed: true },
200
+ turnOutcome: "command",
201
+ commandAction: dispatchResult.result.action,
202
+ };
203
+ }
204
+ }
205
+ }
170
206
  // Step 1: Resolve friend
171
207
  const resolvedContext = await input.friendResolver.resolve();
172
208
  (0, runtime_1.emitNervesEvent)({
@@ -70,6 +70,8 @@ const turn_coordinator_1 = require("../heart/turn-coordinator");
70
70
  const identity_1 = require("../heart/identity");
71
71
  const mcp_manager_1 = require("../repertoire/mcp-manager");
72
72
  const progress_story_1 = require("../heart/progress-story");
73
+ const tool_activity_callbacks_1 = require("../heart/tool-activity-callbacks");
74
+ const commands_2 = require("./commands");
73
75
  const http = __importStar(require("http"));
74
76
  const path = __importStar(require("path"));
75
77
  const trust_gate_1 = require("./trust-gate");
@@ -425,35 +427,37 @@ function createTeamsCallbacks(stream, controller, sendMessage, options) {
425
427
  onClearText: () => {
426
428
  textBuffer = "";
427
429
  },
428
- onToolStart: (name, args) => {
429
- stopPhraseRotation();
430
- // Force-flush any accumulated text, bypassing MIN_INITIAL_CHARS threshold
431
- firstContentEmitted = true;
432
- flushTextBuffer();
433
- // Emit a placeholder to satisfy the 15s Copilot timeout for initial
434
- // stream.emit(). Without this, long tool chains (e.g. ADO batch ops)
435
- // never emit before the timeout and the user sees "this response was
436
- // stopped". The placeholder is replaced by actual content on next emit.
437
- // https://learn.microsoft.com/en-us/answers/questions/2288017/m365-custom-engine-agents-timeout-message-after-15
438
- if (!streamHasContent)
439
- safeEmit("⏳");
440
- const argSummary = (0, tools_1.summarizeArgs)(name, args) || Object.keys(args).join(", ");
441
- safeUpdate((0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
442
- scope: "shared-work",
443
- phase: "processing",
444
- objective: `running ${name} (${argSummary})...`,
445
- })));
446
- hadToolRun = true;
447
- },
448
- onToolEnd: (name, summary, success) => {
449
- stopPhraseRotation();
450
- const msg = (0, format_1.formatToolResult)(name, summary, success);
451
- safeUpdate((0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
452
- scope: "shared-work",
453
- phase: "processing",
454
- objective: msg,
455
- })));
456
- },
430
+ ...(() => {
431
+ const toolCbs = (0, tool_activity_callbacks_1.createToolActivityCallbacks)({
432
+ onDescription: (text) => safeUpdate(text),
433
+ /* v8 ignore next -- onResult only called in debug mode; tested via tool-activity-callbacks.test.ts @preserve */
434
+ onResult: (text) => safeUpdate(text),
435
+ /* v8 ignore next -- onFailure tested via onToolEnd failure test @preserve */
436
+ onFailure: (text) => safeUpdate(`\u2717 ${text}`),
437
+ isDebug: (0, commands_2.getDebugMode)(),
438
+ });
439
+ return {
440
+ onToolStart: (name, args) => {
441
+ stopPhraseRotation();
442
+ // Force-flush any accumulated text, bypassing MIN_INITIAL_CHARS threshold
443
+ firstContentEmitted = true;
444
+ flushTextBuffer();
445
+ // Emit a placeholder to satisfy the 15s Copilot timeout for initial
446
+ // stream.emit(). Without this, long tool chains (e.g. ADO batch ops)
447
+ // never emit before the timeout and the user sees "this response was
448
+ // stopped". The placeholder is replaced by actual content on next emit.
449
+ // https://learn.microsoft.com/en-us/answers/questions/2288017/m365-custom-engine-agents-timeout-message-after-15
450
+ if (!streamHasContent)
451
+ safeEmit("\u23f3");
452
+ toolCbs.onToolStart(name, args);
453
+ hadToolRun = true;
454
+ },
455
+ onToolEnd: (name, summary, success) => {
456
+ stopPhraseRotation();
457
+ toolCbs.onToolEnd(name, summary, success);
458
+ },
459
+ };
460
+ })(),
457
461
  onKick: () => {
458
462
  stopPhraseRotation();
459
463
  const msg = (0, format_1.formatKick)();
@@ -568,6 +572,7 @@ function createTeamsCommandRegistry() {
568
572
  (0, commands_1.registerDefaultCommands)(registry);
569
573
  return registry;
570
574
  }
575
+ /* v8 ignore start -- superseding follow-up slash command handler; tested via startTeamsApp integration tests @preserve */
571
576
  function handleTeamsSlashCommand(text, registry, friendId, conversationId, stream, emitResponse = true) {
572
577
  const parsed = (0, commands_1.parseSlashCommand)(text);
573
578
  if (!parsed)
@@ -591,6 +596,7 @@ function handleTeamsSlashCommand(text, registry, friendId, conversationId, strea
591
596
  }
592
597
  return null;
593
598
  }
599
+ /* v8 ignore stop */
594
600
  // Handle an incoming Teams message
595
601
  async function handleTeamsMessage(text, stream, conversationId, teamsContext, sendMessage, reactionOverrides) {
596
602
  const turnKey = teamsTurnKey(conversationId);
@@ -619,11 +625,6 @@ async function handleTeamsMessage(text, stream, conversationId, teamsContext, se
619
625
  // Pre-resolve friend for session path + slash commands (pipeline will re-use the cached result)
620
626
  const resolvedContext = await resolver.resolve();
621
627
  const friendId = resolvedContext.friend.id;
622
- const registry = createTeamsCommandRegistry();
623
- // Check for slash commands (before pipeline -- these are transport-level concerns)
624
- if (handleTeamsSlashCommand(text, registry, friendId, conversationId, stream)) {
625
- return;
626
- }
627
628
  // ── Teams adapter concerns: controller, callbacks, session path ──────────
628
629
  const controller = new AbortController();
629
630
  const channelConfig = (0, config_2.getTeamsChannelConfig)();
@@ -729,6 +730,16 @@ async function handleTeamsMessage(text, stream, conversationId, teamsContext, se
729
730
  runAgentOptions: agentOptions,
730
731
  failoverState: teamsFailoverState,
731
732
  });
733
+ // ── Handle pipeline-intercepted commands ────────────────────────
734
+ if (result.turnOutcome === "command") {
735
+ if (result.commandAction === "new") {
736
+ (0, context_1.deleteSession)(sessPath);
737
+ stream.emit("session cleared");
738
+ }
739
+ // For "response" commands: pipeline already emitted the response via onTextChunk
740
+ await callbacks.flush();
741
+ return;
742
+ }
732
743
  /* v8 ignore start -- failover display: tested via pipeline integration tests @preserve */
733
744
  if (result.failoverMessage) {
734
745
  stream.emit(result.failoverMessage);
@@ -776,7 +787,7 @@ async function handleTeamsMessage(text, stream, conversationId, teamsContext, se
776
787
  currentText = replayTail;
777
788
  continue;
778
789
  }
779
- if (handleTeamsSlashCommand(supersedingFollowUp.text, registry, friendId, conversationId, stream, false)) {
790
+ if (handleTeamsSlashCommand(supersedingFollowUp.text, createTeamsCommandRegistry(), friendId, conversationId, stream, false)) {
780
791
  return;
781
792
  }
782
793
  currentText = supersedingFollowUp.text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouro.bot/cli",
3
- "version": "0.1.0-alpha.153",
3
+ "version": "0.1.0-alpha.154",
4
4
  "main": "dist/heart/daemon/ouro-entry.js",
5
5
  "bin": {
6
6
  "cli": "dist/heart/daemon/ouro-bot-entry.js",
@@ -1,154 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDebugActivityController = createDebugActivityController;
4
- const format_1 = require("../mind/format");
5
- const phrases_1 = require("../mind/phrases");
6
- const runtime_1 = require("../nerves/runtime");
7
- const progress_story_1 = require("../heart/progress-story");
8
- function createDebugActivityController(options) {
9
- let queue = Promise.resolve();
10
- let statusMessageGuid;
11
- let typingActive = false;
12
- let hadToolRun = false;
13
- let followupShown = false;
14
- let lastPhrase = "";
15
- function reportTransportError(operation, error) {
16
- (0, runtime_1.emitNervesEvent)({
17
- level: "warn",
18
- component: "senses",
19
- event: "senses.debug_activity_transport_error",
20
- message: "debug activity transport failed",
21
- meta: {
22
- operation,
23
- reason: error instanceof Error ? error.message : String(error),
24
- },
25
- });
26
- options.onTransportError?.(operation, error);
27
- }
28
- function enqueue(operation, task) {
29
- queue = queue
30
- .then(task)
31
- .catch((error) => {
32
- reportTransportError(operation, error);
33
- });
34
- }
35
- function nextPhrase(pool) {
36
- const phrase = (0, phrases_1.pickPhrase)(pool, lastPhrase);
37
- lastPhrase = phrase;
38
- return phrase;
39
- }
40
- function startTypingNow() {
41
- if (typingActive) {
42
- return;
43
- }
44
- typingActive = true;
45
- enqueue("typing_start", async () => {
46
- await options.transport.setTyping(true);
47
- });
48
- }
49
- function setStatus(text) {
50
- (0, runtime_1.emitNervesEvent)({
51
- component: "senses",
52
- event: "senses.debug_activity_update",
53
- message: "debug activity status updated",
54
- meta: {
55
- hasStatusGuid: Boolean(statusMessageGuid),
56
- textLength: text.length,
57
- },
58
- });
59
- const shouldStartTyping = !typingActive;
60
- if (shouldStartTyping) {
61
- typingActive = true;
62
- }
63
- enqueue("status_update", async () => {
64
- if (statusMessageGuid) {
65
- await options.transport.editStatus(statusMessageGuid, text);
66
- }
67
- else {
68
- statusMessageGuid = await options.transport.sendStatus(text);
69
- }
70
- if (shouldStartTyping) {
71
- await options.transport.setTyping(true);
72
- }
73
- });
74
- }
75
- return {
76
- onModelStart() {
77
- const pool = hadToolRun ? options.followupPhrases : options.thinkingPhrases;
78
- if (options.startTypingOnModelStart) {
79
- startTypingNow();
80
- }
81
- if (options.suppressInitialModelStatus && !statusMessageGuid && !hadToolRun) {
82
- nextPhrase(pool);
83
- return;
84
- }
85
- setStatus((0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
86
- scope: "shared-work",
87
- phase: "processing",
88
- objective: `${nextPhrase(pool)}...`,
89
- })));
90
- },
91
- onToolStart(name, args) {
92
- hadToolRun = true;
93
- followupShown = false;
94
- const argSummary = Object.values(args).join(", ");
95
- const detail = argSummary ? ` (${argSummary})` : "";
96
- setStatus((0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
97
- scope: "shared-work",
98
- phase: "processing",
99
- objective: `running ${name}${detail}...`,
100
- })));
101
- },
102
- onToolEnd(name, summary, success) {
103
- hadToolRun = true;
104
- followupShown = false;
105
- setStatus((0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
106
- scope: "shared-work",
107
- phase: "processing",
108
- objective: (0, format_1.formatToolResult)(name, summary, success),
109
- })));
110
- },
111
- onTextChunk(text) {
112
- if (!text) {
113
- return;
114
- }
115
- if (!hadToolRun && options.startTypingOnFirstTextChunk) {
116
- startTypingNow();
117
- }
118
- if (!hadToolRun || followupShown) {
119
- return;
120
- }
121
- followupShown = true;
122
- if (options.suppressFollowupPhraseStatus) {
123
- return;
124
- }
125
- setStatus((0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
126
- scope: "shared-work",
127
- phase: "processing",
128
- objective: `${nextPhrase(options.followupPhrases)}...`,
129
- })));
130
- },
131
- onError(error) {
132
- setStatus((0, progress_story_1.renderProgressStory)((0, progress_story_1.buildProgressStory)({
133
- scope: "shared-work",
134
- phase: "errored",
135
- outcomeText: (0, format_1.formatError)(error),
136
- })));
137
- this.finish();
138
- },
139
- async drain() {
140
- await queue;
141
- },
142
- async finish() {
143
- if (!typingActive) {
144
- await queue;
145
- return;
146
- }
147
- typingActive = false;
148
- enqueue("typing_stop", async () => {
149
- await options.transport.setTyping(false);
150
- });
151
- await queue;
152
- },
153
- };
154
- }