@ouro.bot/cli 0.1.0-alpha.20 → 0.1.0-alpha.201

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.
Files changed (204) hide show
  1. package/README.md +187 -191
  2. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
  3. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +1 -1
  4. package/changelog.json +1254 -0
  5. package/dist/heart/active-work.js +832 -0
  6. package/dist/heart/bridges/manager.js +358 -0
  7. package/dist/heart/bridges/state-machine.js +135 -0
  8. package/dist/heart/bridges/store.js +123 -0
  9. package/dist/heart/cares.js +179 -0
  10. package/dist/heart/commitments.js +111 -0
  11. package/dist/heart/config.js +54 -30
  12. package/dist/heart/core.js +620 -124
  13. package/dist/heart/cross-chat-delivery.js +146 -0
  14. package/dist/heart/daemon/agent-config-check.js +149 -0
  15. package/dist/heart/daemon/agent-discovery.js +81 -0
  16. package/dist/heart/daemon/agent-service.js +360 -0
  17. package/dist/heart/daemon/auth-flow.js +477 -0
  18. package/dist/heart/daemon/cadence.js +70 -0
  19. package/dist/heart/daemon/daemon-cli.js +2444 -217
  20. package/dist/heart/daemon/daemon-entry.js +182 -4
  21. package/dist/heart/daemon/daemon-health.js +136 -0
  22. package/dist/heart/daemon/daemon-runtime-sync.js +231 -0
  23. package/dist/heart/daemon/daemon-tombstone.js +123 -0
  24. package/dist/heart/daemon/daemon.js +460 -18
  25. package/dist/heart/daemon/habit-migration.js +181 -0
  26. package/dist/heart/daemon/habit-parser.js +119 -0
  27. package/dist/heart/daemon/habit-scheduler.js +369 -0
  28. package/dist/heart/daemon/hatch-flow.js +31 -112
  29. package/dist/heart/daemon/hatch-specialist.js +3 -3
  30. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  31. package/dist/heart/daemon/hooks/bundle-meta.js +206 -0
  32. package/dist/heart/daemon/inner-status.js +89 -0
  33. package/dist/heart/daemon/launchd.js +165 -0
  34. package/dist/heart/daemon/log-tailer.js +4 -3
  35. package/dist/heart/daemon/mcp-server.js +591 -0
  36. package/dist/heart/daemon/message-router.js +17 -8
  37. package/dist/heart/daemon/os-cron-deps.js +134 -0
  38. package/dist/heart/daemon/ouro-bot-global-installer.js +128 -0
  39. package/dist/heart/daemon/ouro-path-installer.js +78 -34
  40. package/dist/heart/daemon/ouro-version-manager.js +171 -0
  41. package/dist/heart/daemon/outlook-http.js +439 -0
  42. package/dist/heart/daemon/outlook-read.js +1618 -0
  43. package/dist/heart/daemon/outlook-render.js +1032 -0
  44. package/dist/heart/daemon/outlook-types.js +7 -0
  45. package/dist/heart/daemon/outlook-view.js +194 -0
  46. package/dist/heart/daemon/process-manager.js +93 -0
  47. package/dist/heart/daemon/run-hooks.js +39 -0
  48. package/dist/heart/daemon/runtime-logging.js +58 -15
  49. package/dist/heart/daemon/runtime-metadata.js +101 -0
  50. package/dist/heart/daemon/runtime-mode.js +67 -0
  51. package/dist/heart/daemon/safe-mode.js +161 -0
  52. package/dist/heart/daemon/sense-manager.js +50 -2
  53. package/dist/heart/daemon/session-id-resolver.js +131 -0
  54. package/dist/heart/daemon/skill-management-installer.js +94 -0
  55. package/dist/heart/daemon/socket-client.js +202 -0
  56. package/dist/heart/daemon/specialist-prompt.js +10 -7
  57. package/dist/heart/daemon/specialist-tools.js +49 -3
  58. package/dist/heart/daemon/staged-restart.js +138 -0
  59. package/dist/heart/daemon/task-scheduler.js +3 -25
  60. package/dist/heart/daemon/thoughts.js +507 -0
  61. package/dist/heart/daemon/update-checker.js +111 -0
  62. package/dist/heart/daemon/update-hooks.js +138 -0
  63. package/dist/heart/daemon/wrapper-publish-guard.js +86 -0
  64. package/dist/heart/delegation.js +62 -0
  65. package/dist/heart/identity.js +147 -55
  66. package/dist/heart/intentions.js +173 -0
  67. package/dist/heart/kicks.js +2 -20
  68. package/dist/heart/migrate-config.js +127 -0
  69. package/dist/heart/model-capabilities.js +48 -0
  70. package/dist/heart/obligations.js +225 -0
  71. package/dist/heart/presence.js +185 -0
  72. package/dist/heart/progress-story.js +42 -0
  73. package/dist/heart/provider-failover.js +88 -0
  74. package/dist/heart/provider-ping.js +178 -0
  75. package/dist/heart/providers/anthropic-token.js +163 -0
  76. package/dist/heart/providers/anthropic.js +187 -41
  77. package/dist/heart/providers/azure.js +116 -10
  78. package/dist/heart/providers/github-copilot.js +157 -0
  79. package/dist/heart/providers/minimax.js +33 -3
  80. package/dist/heart/providers/openai-codex.js +51 -16
  81. package/dist/heart/session-activity.js +172 -0
  82. package/dist/heart/session-recall.js +216 -0
  83. package/dist/heart/start-of-turn-packet.js +232 -0
  84. package/dist/heart/streaming.js +36 -27
  85. package/dist/heart/sync.js +217 -0
  86. package/dist/heart/target-resolution.js +127 -0
  87. package/dist/heart/tempo.js +93 -0
  88. package/dist/heart/temporal-view.js +41 -0
  89. package/dist/heart/tool-activity-callbacks.js +36 -0
  90. package/dist/heart/tool-description.js +135 -0
  91. package/dist/heart/tool-loop.js +200 -0
  92. package/dist/heart/turn-coordinator.js +28 -0
  93. package/dist/mind/associative-recall.js +122 -32
  94. package/dist/mind/bundle-manifest.js +19 -1
  95. package/dist/mind/context.js +125 -14
  96. package/dist/mind/{memory.js → diary.js} +69 -56
  97. package/dist/mind/episodes.js +119 -0
  98. package/dist/mind/file-state.js +179 -0
  99. package/dist/mind/first-impressions.js +16 -2
  100. package/dist/mind/friends/channel.js +56 -0
  101. package/dist/mind/friends/group-context.js +144 -0
  102. package/dist/mind/friends/store-file.js +36 -0
  103. package/dist/mind/friends/trust-explanation.js +74 -0
  104. package/dist/mind/friends/types.js +8 -0
  105. package/dist/mind/journal-index.js +161 -0
  106. package/dist/mind/obligation-steering.js +221 -0
  107. package/dist/mind/obligations.js +138 -0
  108. package/dist/mind/pending.js +76 -9
  109. package/dist/mind/phrases.js +1 -0
  110. package/dist/mind/prompt.js +785 -103
  111. package/dist/mind/scrutiny.js +173 -0
  112. package/dist/mind/token-estimate.js +8 -12
  113. package/dist/nerves/coverage/audit.js +1 -1
  114. package/dist/nerves/coverage/run-artifacts.js +1 -1
  115. package/dist/nerves/event-buffer.js +111 -0
  116. package/dist/nerves/index.js +63 -3
  117. package/dist/nerves/observation.js +20 -0
  118. package/dist/nerves/runtime.js +5 -1
  119. package/dist/outlook-ui/assets/index-Ck8agNeO.js +61 -0
  120. package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
  121. package/dist/outlook-ui/index.html +15 -0
  122. package/dist/repertoire/ado-semantic.js +11 -5
  123. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  124. package/dist/repertoire/coding/context-pack.js +330 -0
  125. package/dist/repertoire/coding/feedback.js +197 -30
  126. package/dist/repertoire/coding/manager.js +149 -2
  127. package/dist/repertoire/coding/spawner.js +55 -9
  128. package/dist/repertoire/coding/tools.js +170 -7
  129. package/dist/repertoire/guardrails.js +291 -0
  130. package/dist/repertoire/mcp-client.js +254 -0
  131. package/dist/repertoire/mcp-manager.js +251 -0
  132. package/dist/repertoire/shell-sessions.js +133 -0
  133. package/dist/repertoire/skills.js +14 -23
  134. package/dist/repertoire/tasks/board.js +43 -5
  135. package/dist/repertoire/tasks/fix.js +182 -0
  136. package/dist/repertoire/tasks/index.js +28 -10
  137. package/dist/repertoire/tasks/lifecycle.js +2 -2
  138. package/dist/repertoire/tasks/parser.js +3 -2
  139. package/dist/repertoire/tasks/scanner.js +194 -37
  140. package/dist/repertoire/tasks/transitions.js +11 -28
  141. package/dist/repertoire/tools-base.js +1345 -320
  142. package/dist/repertoire/tools-bluebubbles.js +94 -0
  143. package/dist/repertoire/tools-github.js +1 -6
  144. package/dist/repertoire/tools-teams.js +12 -59
  145. package/dist/repertoire/tools.js +318 -124
  146. package/dist/scripts/claude-code-hook.js +41 -0
  147. package/dist/scripts/claude-code-stop-hook.js +47 -0
  148. package/dist/senses/attention-queue.js +97 -0
  149. package/dist/senses/bluebubbles-client.js +102 -3
  150. package/dist/senses/bluebubbles-entry.js +2 -0
  151. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  152. package/dist/senses/bluebubbles-media.js +118 -23
  153. package/dist/senses/bluebubbles-model.js +12 -4
  154. package/dist/senses/bluebubbles-mutation-log.js +45 -5
  155. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  156. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  157. package/dist/senses/bluebubbles.js +1008 -102
  158. package/dist/senses/cli/adapter.js +274 -0
  159. package/dist/senses/cli/ink-app.js +156 -0
  160. package/dist/senses/cli/inline-diff.js +64 -0
  161. package/dist/senses/cli/message-list.js +51 -0
  162. package/dist/senses/cli/ouro-tui.js +349 -0
  163. package/dist/senses/cli/spinner-imperative.js +135 -0
  164. package/dist/senses/cli/spinner.js +101 -0
  165. package/dist/senses/cli/status-line.js +60 -0
  166. package/dist/senses/cli/streaming-markdown.js +526 -0
  167. package/dist/senses/cli/tool-display.js +83 -0
  168. package/dist/senses/cli/tool-render.js +85 -0
  169. package/dist/senses/cli/tui-store.js +198 -0
  170. package/dist/senses/cli/virtual-list.js +35 -0
  171. package/dist/senses/cli-entry.js +1 -1
  172. package/dist/senses/cli-layout.js +187 -0
  173. package/dist/senses/cli.js +508 -243
  174. package/dist/senses/commands.js +65 -1
  175. package/dist/senses/continuity.js +94 -0
  176. package/dist/senses/habit-turn-message.js +108 -0
  177. package/dist/senses/inner-dialog-worker.js +112 -19
  178. package/dist/senses/inner-dialog.js +592 -84
  179. package/dist/senses/pipeline.js +693 -0
  180. package/dist/senses/shared-turn.js +196 -0
  181. package/dist/senses/surface-tool.js +95 -0
  182. package/dist/senses/teams.js +667 -120
  183. package/dist/senses/trust-gate.js +112 -2
  184. package/package.json +16 -6
  185. package/skills/configure-dev-tools.md +81 -0
  186. package/subagents/README.md +4 -70
  187. package/dist/heart/daemon/subagent-installer.js +0 -134
  188. package/dist/senses/debug-activity.js +0 -107
  189. package/subagents/work-doer.md +0 -235
  190. package/subagents/work-merger.md +0 -618
  191. package/subagents/work-planner.md +0 -382
  192. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  193. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  194. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  195. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  196. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  197. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
  198. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  199. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  200. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
  201. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  202. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  203. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
  204. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToolBadge = ToolBadge;
4
+ exports.ToolParams = ToolParams;
5
+ exports.ToolProgress = ToolProgress;
6
+ exports.ToolResultCard = ToolResultCard;
7
+ exports.ToolExecutionBlock = ToolExecutionBlock;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const ink_1 = require("ink");
10
+ const inline_diff_1 = require("./inline-diff");
11
+ /**
12
+ * Tool execution display components for the CLI TUI.
13
+ *
14
+ * Provides: ToolBadge, ToolParams, ToolProgress, ToolResultCard, ToolExecutionBlock.
15
+ *
16
+ * Design: Ouroboros-themed. Inline diffs use green/red with +/- markers and line numbers.
17
+ * No padding -- visual separation via color/bold/dim only.
18
+ *
19
+ * Files >50KB get a summary instead of inline diff (scrutiny finding 17).
20
+ */
21
+ // Ouroboros brand palette
22
+ const OURO_GREEN = "#2ecc40";
23
+ const OURO_RED = "#e74c3c";
24
+ const OURO_TEAL = "#4ec9b0";
25
+ // 50KB threshold for inline diff vs summary
26
+ const LARGE_FILE_THRESHOLD = 50 * 1024;
27
+ // Tool name -> primary parameter key mapping
28
+ const PRIMARY_PARAM = {
29
+ edit_file: "path",
30
+ write_file: "path",
31
+ read_file: "path",
32
+ glob: "pattern",
33
+ grep: "pattern",
34
+ shell: "command",
35
+ coding_spawn: "task",
36
+ coding_status: "session_id",
37
+ coding_tail: "session_id",
38
+ };
39
+ function truncate(s, max) {
40
+ return s.length > max ? s.slice(0, max - 3) + "..." : s;
41
+ }
42
+ function ToolBadge({ name }) {
43
+ return (0, jsx_runtime_1.jsx)(ink_1.Text, { color: OURO_TEAL, bold: true, children: name });
44
+ }
45
+ function ToolParams({ name, args, }) {
46
+ // Find primary parameter to show inline
47
+ const primaryKey = PRIMARY_PARAM[name];
48
+ let display = "";
49
+ if (primaryKey && typeof args[primaryKey] === "string") {
50
+ display = truncate(args[primaryKey], 80);
51
+ }
52
+ else {
53
+ // Fallback: show first string value
54
+ for (const val of Object.values(args)) {
55
+ if (typeof val === "string") {
56
+ display = truncate(val, 80);
57
+ break;
58
+ }
59
+ }
60
+ }
61
+ if (!display)
62
+ return (0, jsx_runtime_1.jsx)(ink_1.Text, { children: "" });
63
+ return (0, jsx_runtime_1.jsxs)(ink_1.Text, { dimColor: true, children: [" ", display] });
64
+ }
65
+ function ToolProgress({ name }) {
66
+ return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { color: OURO_GREEN, children: "\u25CF " }), (0, jsx_runtime_1.jsxs)(ink_1.Text, { dimColor: true, children: [name, " running..."] })] }));
67
+ }
68
+ function ToolResultCard({ name, result, success, expanded, }) {
69
+ const icon = success ? "\u2713" : "\u2717";
70
+ const color = success ? OURO_GREEN : OURO_RED;
71
+ if (expanded) {
72
+ return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", children: [(0, jsx_runtime_1.jsxs)(ink_1.Box, { children: [(0, jsx_runtime_1.jsxs)(ink_1.Text, { color: color, children: [icon, " "] }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: OURO_TEAL, bold: true, children: name })] }), (0, jsx_runtime_1.jsx)(ink_1.Text, { children: result })] }));
73
+ }
74
+ // Collapsed: one-line summary
75
+ const summary = truncate(result.replace(/\n/g, " "), 100);
76
+ return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { children: [(0, jsx_runtime_1.jsxs)(ink_1.Text, { color: color, children: [icon, " "] }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: OURO_TEAL, bold: true, children: name }), (0, jsx_runtime_1.jsxs)(ink_1.Text, { dimColor: true, children: [" ", summary] })] }));
77
+ }
78
+ function ToolExecutionBlock({ name, args, result, success, fileBefore, fileAfter, }) {
79
+ const filePath = typeof args.path === "string" ? args.path : undefined;
80
+ const showDiff = name === "edit_file" && fileBefore !== undefined && fileAfter !== undefined;
81
+ // Check file size threshold
82
+ const tooLarge = showDiff && ((fileBefore?.length ?? 0) > LARGE_FILE_THRESHOLD ||
83
+ (fileAfter?.length ?? 0) > LARGE_FILE_THRESHOLD);
84
+ return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", children: [(0, jsx_runtime_1.jsxs)(ink_1.Box, { children: [(0, jsx_runtime_1.jsx)(ToolBadge, { name: name }), (0, jsx_runtime_1.jsx)(ToolParams, { name: name, args: args })] }), showDiff && !tooLarge ? ((0, jsx_runtime_1.jsx)(inline_diff_1.InlineDiff, { before: fileBefore, after: fileAfter, filePath: filePath ?? "unknown" })) : /* v8 ignore next -- tooLarge branch not exercised in render tests @preserve */ showDiff && tooLarge ? ((0, jsx_runtime_1.jsxs)(ink_1.Text, { dimColor: true, children: ["large file changed (", Math.round((fileAfter?.length ?? 0) / 1024), "KB)"] })) : ((0, jsx_runtime_1.jsx)(ToolResultCard, { name: name, result: result, success: success }))] }));
85
+ }
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TuiStore = void 0;
4
+ exports.createTuiCallbacks = createTuiCallbacks;
5
+ /**
6
+ * TUI Store — mutable external state for the OuroTui component.
7
+ *
8
+ * Tracks two buckets:
9
+ * 1. completedMessages — fed to Ink's <Static>, rendered once
10
+ * 2. live — current turn state, re-renders on change
11
+ *
12
+ * ZERO business logic. Just state + notify.
13
+ */
14
+ const phrases_1 = require("../../mind/phrases");
15
+ const format_1 = require("../../mind/format");
16
+ const runtime_1 = require("../../nerves/runtime");
17
+ class TuiStore {
18
+ _completed = [];
19
+ _live = {
20
+ streamingText: "",
21
+ loading: false,
22
+ spinnerPhrase: "",
23
+ spinnerPhrasePool: [],
24
+ activeTool: null,
25
+ errorMessage: null,
26
+ kickMessage: null,
27
+ inputSuppressed: false,
28
+ };
29
+ _spinnerStart = 0;
30
+ _hadTool = false;
31
+ _turnId = 0;
32
+ _listeners = new Set();
33
+ _headerShown = false;
34
+ _inputHistory = [];
35
+ get completedMessages() { return this._completed; }
36
+ get live() { return this._live; }
37
+ get headerShown() { return this._headerShown; }
38
+ get inputHistory() { return this._inputHistory; }
39
+ /** Elapsed seconds since spinner started — computed on demand, not stored */
40
+ getElapsed() {
41
+ if (this._live.loading && this._spinnerStart > 0) {
42
+ return Math.floor((Date.now() - this._spinnerStart) / 1000);
43
+ }
44
+ return 0;
45
+ }
46
+ subscribe(fn) {
47
+ this._listeners.add(fn);
48
+ return () => { this._listeners.delete(fn); };
49
+ }
50
+ notify() {
51
+ for (const fn of this._listeners)
52
+ fn();
53
+ }
54
+ // ─── Called by business logic (via callbacks) ───
55
+ modelStart() {
56
+ const phrases = (0, phrases_1.getPhrases)();
57
+ const pool = this._hadTool ? phrases.followup : phrases.thinking;
58
+ this._live = {
59
+ ...this._live,
60
+ loading: true,
61
+ spinnerPhrase: (0, phrases_1.pickPhrase)(pool),
62
+ spinnerPhrasePool: pool,
63
+ streamingText: "",
64
+ activeTool: null,
65
+ errorMessage: null,
66
+ kickMessage: null,
67
+ };
68
+ this._spinnerStart = Date.now();
69
+ this._turnId++;
70
+ this.notify();
71
+ }
72
+ appendText(text) {
73
+ this._live = {
74
+ ...this._live,
75
+ loading: false,
76
+ streamingText: this._live.streamingText + text,
77
+ };
78
+ this.notify();
79
+ }
80
+ clearText() {
81
+ this._live = { ...this._live, streamingText: "" };
82
+ this.notify();
83
+ }
84
+ toolStart(name, args) {
85
+ this._hadTool = true;
86
+ // Before showing tool in-progress, commit any buffered streaming text
87
+ // so it doesn't disappear when the live area switches to tool display
88
+ if (this._live.streamingText.trim()) {
89
+ this._completed = [...this._completed, {
90
+ id: `asst-${this._turnId}-${Date.now()}`,
91
+ role: "assistant",
92
+ content: this._live.streamingText.trim(),
93
+ }];
94
+ }
95
+ this._live = {
96
+ ...this._live,
97
+ loading: true,
98
+ streamingText: "",
99
+ activeTool: { name, args },
100
+ spinnerPhrase: (0, phrases_1.pickPhrase)((0, phrases_1.getPhrases)().tool),
101
+ spinnerPhrasePool: (0, phrases_1.getPhrases)().tool,
102
+ };
103
+ this._spinnerStart = Date.now();
104
+ this.notify();
105
+ }
106
+ toolEnd(name, argSummary, success) {
107
+ // Move tool result to completed messages (so it renders via Static)
108
+ this._completed = [...this._completed, {
109
+ id: `tool-${this._turnId}-${Date.now()}`,
110
+ role: "tool",
111
+ content: "",
112
+ toolCalls: [{ name, argSummary, success }],
113
+ }];
114
+ this._live = {
115
+ ...this._live,
116
+ loading: false,
117
+ activeTool: null,
118
+ };
119
+ this.notify();
120
+ }
121
+ setError(msg) {
122
+ this._live = { ...this._live, loading: false, errorMessage: msg };
123
+ this.notify();
124
+ }
125
+ setKick() {
126
+ this._live = { ...this._live, loading: false, kickMessage: (0, format_1.formatKick)() };
127
+ this.notify();
128
+ }
129
+ suppressInput() {
130
+ this._live = { ...this._live, inputSuppressed: true };
131
+ this.notify();
132
+ }
133
+ restoreInput() {
134
+ this._live = { ...this._live, inputSuppressed: false };
135
+ this.notify();
136
+ }
137
+ /** Commit current streaming text as a completed assistant message */
138
+ commitAssistantMessage() {
139
+ if (this._live.streamingText.trim()) {
140
+ this._completed = [...this._completed, {
141
+ id: `asst-${this._turnId}-${Date.now()}`,
142
+ role: "assistant",
143
+ content: this._live.streamingText.trim(),
144
+ }];
145
+ }
146
+ // Clear streaming text immediately — prevents double display
147
+ this._live = {
148
+ ...this._live,
149
+ loading: false,
150
+ streamingText: "",
151
+ activeTool: null,
152
+ errorMessage: null,
153
+ kickMessage: null,
154
+ };
155
+ this.notify();
156
+ }
157
+ /** Add a user message to completed (for display) AND input history */
158
+ addUserMessage(text) {
159
+ if (this._completed.length === 0) {
160
+ this._headerShown = false;
161
+ }
162
+ this._completed = [...this._completed, {
163
+ id: `user-${Date.now()}`,
164
+ role: "user",
165
+ content: text,
166
+ }];
167
+ this._inputHistory.push(text);
168
+ this.notify();
169
+ }
170
+ /** Seed input history from previous session messages (display only, no rendering) */
171
+ seedHistory(texts) {
172
+ this._inputHistory.push(...texts);
173
+ }
174
+ }
175
+ exports.TuiStore = TuiStore;
176
+ // ─── Callbacks factory ──────────────────────────────────────────────
177
+ function createTuiCallbacks(store) {
178
+ (0, runtime_1.emitNervesEvent)({
179
+ component: "senses",
180
+ event: "senses.tui_callbacks_created",
181
+ message: "TUI callbacks created",
182
+ meta: {},
183
+ });
184
+ return {
185
+ onModelStart: () => { store.modelStart(); },
186
+ onModelStreamStart: () => { },
187
+ onClearText: () => { store.clearText(); },
188
+ onTextChunk: (text) => { store.appendText(text); },
189
+ onReasoningChunk: () => { },
190
+ onToolStart: (name, args) => { store.toolStart(name, args); },
191
+ onToolEnd: (name, argSummary, success) => { store.toolEnd(name, argSummary, success); },
192
+ onError: (error, severity) => {
193
+ store.setError(severity === "terminal" ? (0, format_1.formatError)(error) : error.message);
194
+ },
195
+ onKick: () => { store.setKick(); },
196
+ flushMarkdown: () => { store.commitAssistantMessage(); },
197
+ };
198
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VirtualList = VirtualList;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const ink_1 = require("ink");
7
+ function VirtualList({ items, viewportHeight, scrollOffset, renderItem, }) {
8
+ const { startIndex, visibleItems } = (0, react_1.useMemo)(() => {
9
+ if (items.length === 0) {
10
+ return { startIndex: 0, visibleItems: [] };
11
+ }
12
+ // Determine the start index for the visible window
13
+ let start;
14
+ if (scrollOffset !== undefined) {
15
+ // Scroll-locked: show items starting at the given offset
16
+ start = Math.max(0, Math.min(scrollOffset, items.length - 1));
17
+ }
18
+ else {
19
+ // Auto-scroll: pin to bottom, show last viewportHeight items
20
+ start = Math.max(0, items.length - viewportHeight);
21
+ }
22
+ const end = Math.min(start + viewportHeight, items.length);
23
+ return {
24
+ startIndex: start,
25
+ visibleItems: items.slice(start, end),
26
+ };
27
+ }, [items, viewportHeight, scrollOffset]);
28
+ if (visibleItems.length === 0) {
29
+ return (0, jsx_runtime_1.jsx)(ink_1.Box, { children: (0, jsx_runtime_1.jsx)(ink_1.Text, { children: "" }) });
30
+ }
31
+ return ((0, jsx_runtime_1.jsx)(ink_1.Box, { flexDirection: "column", children: visibleItems.map((item, i) => {
32
+ const globalIndex = startIndex + i;
33
+ return ((0, jsx_runtime_1.jsx)(ink_1.Box, { children: (0, jsx_runtime_1.jsx)(ink_1.Text, { children: renderItem(item, globalIndex) }) }, globalIndex));
34
+ }) }));
35
+ }
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Thin entrypoint for `npm run dev` / `node dist/senses/cli-entry.js --agent <name>`.
2
+ // Thin entrypoint for `npm run cli` / `node dist/senses/cli-entry.js --agent <name>`.
3
3
  // Separated from cli.ts so the CLI adapter is pure library code with clean
4
4
  // 100% test coverage -- entrypoints can't be covered by vitest since
5
5
  // require.main !== module in the test runner.
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamingWordWrapper = void 0;
4
+ exports.wrapCliText = wrapCliText;
5
+ exports.formatEchoedInputSummary = formatEchoedInputSummary;
6
+ const runtime_1 = require("../nerves/runtime");
7
+ // Strip ANSI escape sequences to measure visible text width.
8
+ const ANSI_RE = /\x1b\[[0-9;]*[A-Za-z]/g;
9
+ function visibleLength(text) {
10
+ return text.replace(ANSI_RE, "").length;
11
+ }
12
+ /**
13
+ * Streaming word wrapper for terminal output.
14
+ *
15
+ * Text arrives in small chunks (sometimes single characters). This class
16
+ * buffers a partial line and emits complete wrapped lines at word boundaries
17
+ * when the visible width approaches the terminal column limit.
18
+ *
19
+ * ANSI escape sequences are treated as zero-width so colours and styles
20
+ * pass through without affecting line-break decisions.
21
+ */
22
+ class StreamingWordWrapper {
23
+ col = 0; // visible columns consumed on the current line
24
+ buf = ""; // buffered text for the current line (not yet emitted)
25
+ width; // terminal column count
26
+ constructor(cols) {
27
+ this.width = Math.max(cols ?? (process.stdout.columns || 80), 1);
28
+ }
29
+ /** Accept a chunk of already-rendered text and return text ready for stdout. */
30
+ push(text) {
31
+ let out = "";
32
+ for (let i = 0; i < text.length; i++) {
33
+ const ch = text[i];
34
+ // Pass through ANSI escape sequences without counting width
35
+ /* v8 ignore start -- ANSI handling: tested via StreamingWordWrapper ANSI test @preserve */
36
+ if (ch === "\x1b") {
37
+ const rest = text.slice(i);
38
+ const m = rest.match(/^\x1b\[[0-9;]*[A-Za-z]/);
39
+ if (m) {
40
+ this.buf += m[0];
41
+ i += m[0].length - 1;
42
+ continue;
43
+ }
44
+ }
45
+ /* v8 ignore stop */
46
+ // Explicit newline: flush current line and reset
47
+ if (ch === "\n") {
48
+ out += this.buf + "\n";
49
+ this.buf = "";
50
+ this.col = 0;
51
+ continue;
52
+ }
53
+ // Space: if the current line is already at or past width, wrap now.
54
+ // Otherwise just append.
55
+ if (ch === " ") {
56
+ /* v8 ignore start -- wrap-at-space: tested via StreamingWordWrapper unit tests @preserve */
57
+ if (this.col >= this.width) {
58
+ out += this.buf + "\n";
59
+ this.buf = "";
60
+ this.col = 0;
61
+ // Drop the space at the wrap point
62
+ continue;
63
+ /* v8 ignore stop */
64
+ }
65
+ this.buf += ch;
66
+ this.col++;
67
+ continue;
68
+ }
69
+ // Non-space character
70
+ this.col++;
71
+ if (this.col > this.width) {
72
+ // We've exceeded the width. Try to break at the last space.
73
+ const lastSpace = this.buf.lastIndexOf(" ");
74
+ if (lastSpace !== -1) {
75
+ out += this.buf.slice(0, lastSpace) + "\n";
76
+ // Keep the remainder (after space) plus current char
77
+ this.buf = this.buf.slice(lastSpace + 1) + ch;
78
+ this.col = visibleLength(this.buf);
79
+ }
80
+ else {
81
+ // No space to break at — hard wrap
82
+ out += this.buf + "\n";
83
+ this.buf = ch;
84
+ this.col = 1;
85
+ }
86
+ continue;
87
+ }
88
+ this.buf += ch;
89
+ }
90
+ return out;
91
+ }
92
+ /** Flush any remaining buffered text (call at end of response). */
93
+ flush() {
94
+ const remainder = this.buf;
95
+ this.buf = "";
96
+ this.col = 0;
97
+ return remainder;
98
+ }
99
+ /** Reset wrapper state (call at start of new model turn). */
100
+ reset() {
101
+ this.buf = "";
102
+ this.col = 0;
103
+ }
104
+ }
105
+ exports.StreamingWordWrapper = StreamingWordWrapper;
106
+ function splitLongWord(word, width) {
107
+ const chunks = [];
108
+ for (let index = 0; index < word.length; index += width) {
109
+ chunks.push(word.slice(index, index + width));
110
+ }
111
+ return chunks;
112
+ }
113
+ function wrapCliText(text, cols) {
114
+ const width = Math.max(cols, 1);
115
+ const wrapped = [];
116
+ for (const rawLine of text.split("\n")) {
117
+ if (rawLine.trim().length === 0) {
118
+ wrapped.push("");
119
+ continue;
120
+ }
121
+ const words = rawLine.trim().split(/\s+/);
122
+ let current = "";
123
+ for (const word of words) {
124
+ if (!current) {
125
+ if (word.length <= width) {
126
+ current = word;
127
+ continue;
128
+ }
129
+ const chunks = splitLongWord(word, width);
130
+ wrapped.push(...chunks.slice(0, -1));
131
+ current = chunks[chunks.length - 1];
132
+ continue;
133
+ }
134
+ const candidate = `${current} ${word}`;
135
+ if (candidate.length <= width) {
136
+ current = candidate;
137
+ continue;
138
+ }
139
+ wrapped.push(current);
140
+ if (word.length <= width) {
141
+ current = word;
142
+ continue;
143
+ }
144
+ const chunks = splitLongWord(word, width);
145
+ wrapped.push(...chunks.slice(0, -1));
146
+ current = chunks[chunks.length - 1];
147
+ }
148
+ wrapped.push(current);
149
+ }
150
+ return wrapped;
151
+ }
152
+ function countEchoedInputRows(input, cols) {
153
+ const width = Math.max(cols, 1);
154
+ return input.split("\n").reduce((sum, line, index) => {
155
+ const promptWidth = index === 0 ? 2 : 0;
156
+ return sum + Math.max(1, Math.ceil((promptWidth + line.length) / width));
157
+ }, 0);
158
+ }
159
+ function formatEchoedInputSummary(input, cols) {
160
+ const inputLines = input.split("\n");
161
+ const summary = `> ${inputLines[0]}${inputLines.length > 1 ? ` (+${inputLines.length - 1} lines)` : ""}`;
162
+ const wrappedSummary = wrapCliText(summary, cols);
163
+ const echoRows = countEchoedInputRows(input, cols);
164
+ (0, runtime_1.emitNervesEvent)({
165
+ component: "senses",
166
+ event: "senses.cli_echo_summary_formatted",
167
+ message: "formatted echoed cli input summary",
168
+ meta: {
169
+ cols,
170
+ echo_rows: echoRows,
171
+ input_line_count: inputLines.length,
172
+ wrapped_line_count: wrappedSummary.length,
173
+ },
174
+ });
175
+ let output = `\x1b[${echoRows}A`;
176
+ for (let i = 0; i < echoRows; i += 1) {
177
+ output += "\r\x1b[K";
178
+ if (i < echoRows - 1) {
179
+ output += "\x1b[1B";
180
+ }
181
+ }
182
+ if (echoRows > 1) {
183
+ output += `\x1b[${echoRows - 1}A`;
184
+ }
185
+ output += `\x1b[1m${wrappedSummary.join("\n")}\x1b[0m\n\n`;
186
+ return output;
187
+ }