miladyai 2.0.0-alpha.27

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 (241) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +7 -0
  2. package/dist/actions/emote.js +64 -0
  3. package/dist/actions/restart.js +81 -0
  4. package/dist/actions/send-message.js +152 -0
  5. package/dist/agent-admin-routes.js +82 -0
  6. package/dist/agent-lifecycle-routes.js +79 -0
  7. package/dist/agent-transfer-routes.js +102 -0
  8. package/dist/api/agent-admin-routes.js +82 -0
  9. package/dist/api/agent-lifecycle-routes.js +79 -0
  10. package/dist/api/agent-transfer-routes.js +102 -0
  11. package/dist/api/apps-hyperscape-routes.js +58 -0
  12. package/dist/api/apps-routes.js +114 -0
  13. package/dist/api/auth-routes.js +56 -0
  14. package/dist/api/autonomy-routes.js +44 -0
  15. package/dist/api/bug-report-routes.js +111 -0
  16. package/dist/api/character-routes.js +195 -0
  17. package/dist/api/cloud-routes.js +330 -0
  18. package/dist/api/cloud-status-routes.js +155 -0
  19. package/dist/api/compat-utils.js +111 -0
  20. package/dist/api/database.js +735 -0
  21. package/dist/api/diagnostics-routes.js +205 -0
  22. package/dist/api/drop-service.js +134 -0
  23. package/dist/api/early-logs.js +86 -0
  24. package/dist/api/http-helpers.js +131 -0
  25. package/dist/api/knowledge-routes.js +534 -0
  26. package/dist/api/memory-bounds.js +71 -0
  27. package/dist/api/models-routes.js +28 -0
  28. package/dist/api/og-tracker.js +36 -0
  29. package/dist/api/permissions-routes.js +109 -0
  30. package/dist/api/plugin-validation.js +198 -0
  31. package/dist/api/provider-switch-config.js +41 -0
  32. package/dist/api/registry-routes.js +86 -0
  33. package/dist/api/registry-service.js +164 -0
  34. package/dist/api/sandbox-routes.js +1112 -0
  35. package/dist/api/server.js +7949 -0
  36. package/dist/api/subscription-routes.js +172 -0
  37. package/dist/api/terminal-run-limits.js +24 -0
  38. package/dist/api/training-routes.js +158 -0
  39. package/dist/api/trajectory-routes.js +300 -0
  40. package/dist/api/trigger-routes.js +246 -0
  41. package/dist/api/twitter-verify.js +134 -0
  42. package/dist/api/tx-service.js +108 -0
  43. package/dist/api/wallet-routes.js +266 -0
  44. package/dist/api/wallet.js +568 -0
  45. package/dist/api/whatsapp-routes.js +182 -0
  46. package/dist/api/zip-utils.js +109 -0
  47. package/dist/apps-hyperscape-routes.js +58 -0
  48. package/dist/apps-routes.js +114 -0
  49. package/dist/ascii.js +20 -0
  50. package/dist/auth/anthropic.js +44 -0
  51. package/dist/auth/apply-stealth.js +41 -0
  52. package/dist/auth/claude-code-stealth.js +78 -0
  53. package/dist/auth/credentials.js +156 -0
  54. package/dist/auth/index.js +5 -0
  55. package/dist/auth/openai-codex.js +66 -0
  56. package/dist/auth/types.js +9 -0
  57. package/dist/auth-routes.js +56 -0
  58. package/dist/autonomy-routes.js +44 -0
  59. package/dist/bug-report-routes.js +111 -0
  60. package/dist/build-info.json +6 -0
  61. package/dist/character-routes.js +195 -0
  62. package/dist/cli/argv.js +63 -0
  63. package/dist/cli/banner.js +34 -0
  64. package/dist/cli/cli-name.js +21 -0
  65. package/dist/cli/cli-utils.js +16 -0
  66. package/dist/cli/git-commit.js +78 -0
  67. package/dist/cli/parse-duration.js +15 -0
  68. package/dist/cli/plugins-cli.js +590 -0
  69. package/dist/cli/profile-utils.js +9 -0
  70. package/dist/cli/profile.js +95 -0
  71. package/dist/cli/program/build-program.js +17 -0
  72. package/dist/cli/program/command-registry.js +23 -0
  73. package/dist/cli/program/help.js +47 -0
  74. package/dist/cli/program/preaction.js +33 -0
  75. package/dist/cli/program/register.config.js +106 -0
  76. package/dist/cli/program/register.configure.js +20 -0
  77. package/dist/cli/program/register.dashboard.js +124 -0
  78. package/dist/cli/program/register.models.js +23 -0
  79. package/dist/cli/program/register.setup.js +36 -0
  80. package/dist/cli/program/register.start.js +22 -0
  81. package/dist/cli/program/register.subclis.js +70 -0
  82. package/dist/cli/program/register.tui.js +163 -0
  83. package/dist/cli/program/register.update.js +154 -0
  84. package/dist/cli/program.js +3 -0
  85. package/dist/cli/run-main.js +37 -0
  86. package/dist/cli/version.js +7 -0
  87. package/dist/cloud/validate-url.js +93 -0
  88. package/dist/cloud-routes.js +330 -0
  89. package/dist/cloud-status-routes.js +155 -0
  90. package/dist/compat-utils.js +111 -0
  91. package/dist/config/config.js +69 -0
  92. package/dist/config/env-vars.js +19 -0
  93. package/dist/config/includes.js +121 -0
  94. package/dist/config/object-utils.js +7 -0
  95. package/dist/config/paths.js +38 -0
  96. package/dist/config/plugin-auto-enable.js +231 -0
  97. package/dist/config/schema.js +864 -0
  98. package/dist/config/telegram-custom-commands.js +76 -0
  99. package/dist/config/zod-schema.agent-runtime.js +519 -0
  100. package/dist/config/zod-schema.core.js +538 -0
  101. package/dist/config/zod-schema.hooks.js +103 -0
  102. package/dist/config/zod-schema.js +488 -0
  103. package/dist/config/zod-schema.providers-core.js +785 -0
  104. package/dist/config/zod-schema.session.js +73 -0
  105. package/dist/core-plugins.js +37 -0
  106. package/dist/custom-actions.js +250 -0
  107. package/dist/database.js +735 -0
  108. package/dist/diagnostics/integration-observability.js +57 -0
  109. package/dist/diagnostics-routes.js +205 -0
  110. package/dist/drop-service.js +134 -0
  111. package/dist/early-logs.js +24 -0
  112. package/dist/eliza.js +2061 -0
  113. package/dist/emotes/catalog.js +271 -0
  114. package/dist/entry.js +40 -0
  115. package/dist/hooks/discovery.js +167 -0
  116. package/dist/hooks/eligibility.js +64 -0
  117. package/dist/hooks/index.js +4 -0
  118. package/dist/hooks/loader.js +147 -0
  119. package/dist/hooks/registry.js +55 -0
  120. package/dist/http-helpers.js +131 -0
  121. package/dist/index.js +49 -0
  122. package/dist/knowledge-routes.js +534 -0
  123. package/dist/memory-bounds.js +71 -0
  124. package/dist/milady-plugin.js +90 -0
  125. package/dist/models-routes.js +28 -0
  126. package/dist/onboarding-names.js +78 -0
  127. package/dist/onboarding-presets.js +922 -0
  128. package/dist/package.json +1 -0
  129. package/dist/permissions-routes.js +109 -0
  130. package/dist/plugin-validation.js +107 -0
  131. package/dist/plugins/whatsapp/actions.js +91 -0
  132. package/dist/plugins/whatsapp/index.js +16 -0
  133. package/dist/plugins/whatsapp/service.js +270 -0
  134. package/dist/provider-switch-config.js +41 -0
  135. package/dist/providers/admin-trust.js +46 -0
  136. package/dist/providers/autonomous-state.js +101 -0
  137. package/dist/providers/session-bridge.js +86 -0
  138. package/dist/providers/session-utils.js +36 -0
  139. package/dist/providers/simple-mode.js +50 -0
  140. package/dist/providers/ui-catalog.js +15 -0
  141. package/dist/providers/workspace-provider.js +93 -0
  142. package/dist/providers/workspace.js +348 -0
  143. package/dist/registry-routes.js +86 -0
  144. package/dist/registry-service.js +164 -0
  145. package/dist/restart.js +40 -0
  146. package/dist/runtime/core-plugins.js +37 -0
  147. package/dist/runtime/custom-actions.js +250 -0
  148. package/dist/runtime/eliza.js +2061 -0
  149. package/dist/runtime/embedding-manager-support.js +185 -0
  150. package/dist/runtime/embedding-manager.js +193 -0
  151. package/dist/runtime/embedding-presets.js +54 -0
  152. package/dist/runtime/embedding-state.js +8 -0
  153. package/dist/runtime/milady-plugin.js +90 -0
  154. package/dist/runtime/onboarding-names.js +78 -0
  155. package/dist/runtime/restart.js +40 -0
  156. package/dist/runtime/version.js +7 -0
  157. package/dist/sandbox-routes.js +1112 -0
  158. package/dist/security/audit-log.js +149 -0
  159. package/dist/security/network-policy.js +70 -0
  160. package/dist/server.js +7949 -0
  161. package/dist/services/agent-export.js +559 -0
  162. package/dist/services/app-manager.js +389 -0
  163. package/dist/services/browser-capture.js +86 -0
  164. package/dist/services/fallback-training-service.js +128 -0
  165. package/dist/services/mcp-marketplace.js +134 -0
  166. package/dist/services/plugin-installer.js +396 -0
  167. package/dist/services/plugin-manager-types.js +15 -0
  168. package/dist/services/registry-client-app-meta.js +144 -0
  169. package/dist/services/registry-client-endpoints.js +166 -0
  170. package/dist/services/registry-client-local.js +271 -0
  171. package/dist/services/registry-client-network.js +93 -0
  172. package/dist/services/registry-client-queries.js +70 -0
  173. package/dist/services/registry-client.js +157 -0
  174. package/dist/services/sandbox-engine.js +511 -0
  175. package/dist/services/sandbox-manager.js +297 -0
  176. package/dist/services/self-updater.js +175 -0
  177. package/dist/services/skill-catalog-client.js +119 -0
  178. package/dist/services/skill-marketplace.js +521 -0
  179. package/dist/services/stream-manager.js +236 -0
  180. package/dist/services/update-checker.js +121 -0
  181. package/dist/services/update-notifier.js +29 -0
  182. package/dist/services/version-compat.js +78 -0
  183. package/dist/services/whatsapp-pairing.js +196 -0
  184. package/dist/shared/ui-catalog-prompt.js +728 -0
  185. package/dist/subscription-routes.js +172 -0
  186. package/dist/terminal/links.js +19 -0
  187. package/dist/terminal/palette.js +14 -0
  188. package/dist/terminal/theme.js +25 -0
  189. package/dist/terminal-run-limits.js +24 -0
  190. package/dist/training-routes.js +158 -0
  191. package/dist/trajectory-routes.js +300 -0
  192. package/dist/trigger-routes.js +246 -0
  193. package/dist/triggers/action.js +218 -0
  194. package/dist/triggers/runtime.js +281 -0
  195. package/dist/triggers/scheduling.js +295 -0
  196. package/dist/triggers/types.js +5 -0
  197. package/dist/tui/components/assistant-message.js +76 -0
  198. package/dist/tui/components/chat-editor.js +34 -0
  199. package/dist/tui/components/embeddings-overlay.js +46 -0
  200. package/dist/tui/components/footer.js +60 -0
  201. package/dist/tui/components/index.js +15 -0
  202. package/dist/tui/components/modal-frame.js +45 -0
  203. package/dist/tui/components/modal-style.js +15 -0
  204. package/dist/tui/components/model-selector.js +70 -0
  205. package/dist/tui/components/pinned-chat-layout.js +46 -0
  206. package/dist/tui/components/plugins-endpoints-tab.js +196 -0
  207. package/dist/tui/components/plugins-installed-tab-view.js +69 -0
  208. package/dist/tui/components/plugins-installed-tab.js +319 -0
  209. package/dist/tui/components/plugins-overlay-catalog.js +81 -0
  210. package/dist/tui/components/plugins-overlay-data-api.js +21 -0
  211. package/dist/tui/components/plugins-overlay-data-shared.js +20 -0
  212. package/dist/tui/components/plugins-overlay-data.js +323 -0
  213. package/dist/tui/components/plugins-overlay.js +117 -0
  214. package/dist/tui/components/plugins-store-tab.js +148 -0
  215. package/dist/tui/components/settings-overlay.js +61 -0
  216. package/dist/tui/components/status-bar.js +64 -0
  217. package/dist/tui/components/tool-execution.js +68 -0
  218. package/dist/tui/components/user-message.js +22 -0
  219. package/dist/tui/eliza-tui-bridge.js +606 -0
  220. package/dist/tui/index.js +370 -0
  221. package/dist/tui/modal-presets.js +33 -0
  222. package/dist/tui/model-spec.js +46 -0
  223. package/dist/tui/sse-parser.js +78 -0
  224. package/dist/tui/theme.js +110 -0
  225. package/dist/tui/titlebar-spinner.js +62 -0
  226. package/dist/tui/tui-app.js +311 -0
  227. package/dist/tui/ws-client.js +215 -0
  228. package/dist/twitter-verify.js +134 -0
  229. package/dist/tx-service.js +108 -0
  230. package/dist/utils/exec-safety.js +17 -0
  231. package/dist/utils/globals.js +20 -0
  232. package/dist/utils/milady-root.js +61 -0
  233. package/dist/utils/number-parsing.js +37 -0
  234. package/dist/version-resolver.js +37 -0
  235. package/dist/version.js +7 -0
  236. package/dist/wallet-routes.js +266 -0
  237. package/dist/wallet.js +568 -0
  238. package/dist/whatsapp-routes.js +182 -0
  239. package/dist/zip-utils.js +109 -0
  240. package/milady.mjs +14 -0
  241. package/package.json +111 -0
@@ -0,0 +1,148 @@
1
+ import { tuiTheme } from "../theme.js";
2
+ import { Input, SelectList, getEditorKeybindings } from "@mariozechner/pi-tui";
3
+
4
+ //#region src/tui/components/plugins-store-tab.ts
5
+ /**
6
+ * Plugin Store tab — browse and search the remote plugin registry,
7
+ * install plugins directly from the TUI.
8
+ */
9
+ var PluginStoreTab = class {
10
+ constructor(options) {
11
+ this.focused = false;
12
+ this.searchInput = new Input();
13
+ this.allItems = [];
14
+ this.loading = true;
15
+ this.installing = null;
16
+ this.installStatus = "";
17
+ this.searchTimeout = null;
18
+ this.options = options;
19
+ this.selectList = new SelectList([], 14, tuiTheme.selectList);
20
+ this.selectList.onCancel = () => options.onClose();
21
+ this.selectList.onSelect = (item) => {
22
+ this.handleSelect(item.value);
23
+ };
24
+ this.searchInput.setValue("");
25
+ this.loadTopPlugins();
26
+ }
27
+ /** Whether the tab is in an input-consuming state. Always false for store tab. */
28
+ isCapturingInput() {
29
+ return false;
30
+ }
31
+ async loadTopPlugins() {
32
+ this.loading = true;
33
+ this.options.requestRender();
34
+ try {
35
+ const plugins = await this.options.getRegistryPlugins();
36
+ this.updateList(plugins);
37
+ } catch {} finally {
38
+ this.loading = false;
39
+ this.options.requestRender();
40
+ }
41
+ }
42
+ updateList(plugins) {
43
+ this.allItems = plugins.map((p) => {
44
+ const installedBadge = p.installed ? tuiTheme.success(" ✓ installed") : "";
45
+ const version = p.latestVersion ? `v${p.latestVersion}` : "";
46
+ const stars = p.stars > 0 ? `★${p.stars}` : "";
47
+ return {
48
+ value: p.name,
49
+ label: `${p.name}${installedBadge}`,
50
+ description: [
51
+ p.description,
52
+ version,
53
+ stars
54
+ ].filter(Boolean).join(" ")
55
+ };
56
+ });
57
+ this.selectList = new SelectList(this.allItems, 14, tuiTheme.selectList);
58
+ this.selectList.onCancel = () => this.options.onClose();
59
+ this.selectList.onSelect = (item) => {
60
+ this.handleSelect(item.value);
61
+ };
62
+ }
63
+ async handleSelect(name) {
64
+ if (this.installing) return;
65
+ if (this.options.isInstalled(name)) return;
66
+ this.installing = name;
67
+ this.installStatus = "installing…";
68
+ this.options.requestRender();
69
+ try {
70
+ const result = await this.options.installPlugin(name);
71
+ this.installStatus = result.success ? tuiTheme.success("✓ installed") : tuiTheme.error(`✗ ${result.message}`);
72
+ } catch (err) {
73
+ this.installStatus = tuiTheme.error(`✗ ${err instanceof Error ? err.message : String(err)}`);
74
+ } finally {
75
+ this.installing = null;
76
+ this.options.requestRender();
77
+ setTimeout(() => {
78
+ this.loadTopPlugins();
79
+ }, 1500);
80
+ }
81
+ }
82
+ scheduleSearch(query) {
83
+ if (this.searchTimeout) clearTimeout(this.searchTimeout);
84
+ this.searchTimeout = setTimeout(async () => {
85
+ this.loading = true;
86
+ this.options.requestRender();
87
+ try {
88
+ if (!query.trim()) {
89
+ await this.loadTopPlugins();
90
+ return;
91
+ }
92
+ const results = await this.options.searchPlugins(query);
93
+ this.updateList(results);
94
+ } catch {} finally {
95
+ this.loading = false;
96
+ this.options.requestRender();
97
+ }
98
+ }, 300);
99
+ }
100
+ handleInput(data) {
101
+ const kb = getEditorKeybindings();
102
+ if (kb.matches(data, "selectUp") || kb.matches(data, "selectDown") || kb.matches(data, "selectConfirm") || kb.matches(data, "selectCancel")) {
103
+ this.selectList.handleInput(data);
104
+ return;
105
+ }
106
+ const before = this.searchInput.getValue();
107
+ this.searchInput.handleInput(data);
108
+ const after = this.searchInput.getValue();
109
+ if (after !== before) this.scheduleSearch(after);
110
+ }
111
+ render(width) {
112
+ this.searchInput.focused = this.focused;
113
+ const lines = [...this.searchInput.render(width).map((l) => ` ${l}`), ""];
114
+ if (this.loading) {
115
+ lines.push(tuiTheme.dim(" Loading plugins from registry…"));
116
+ return lines;
117
+ }
118
+ if (this.installing) {
119
+ lines.push(` ${tuiTheme.accent("Installing")} ${this.installing}… ${this.installStatus}`);
120
+ lines.push("");
121
+ } else if (this.installStatus) {
122
+ lines.push(` ${this.installStatus}`);
123
+ lines.push("");
124
+ }
125
+ if (this.allItems.length === 0) {
126
+ const query = this.searchInput.getValue().trim();
127
+ if (query) lines.push(tuiTheme.dim(` No plugins match "${query}".`));
128
+ else lines.push(tuiTheme.dim(" No plugins available."));
129
+ } else lines.push(...this.selectList.render(width));
130
+ lines.push("");
131
+ lines.push(tuiTheme.dim(" ↑↓ navigate • Enter details • type to search"));
132
+ return lines;
133
+ }
134
+ /** Cancel any pending debounced search. */
135
+ dispose() {
136
+ if (this.searchTimeout) {
137
+ clearTimeout(this.searchTimeout);
138
+ this.searchTimeout = null;
139
+ }
140
+ }
141
+ invalidate() {
142
+ this.searchInput.invalidate();
143
+ this.selectList.invalidate();
144
+ }
145
+ };
146
+
147
+ //#endregion
148
+ export { PluginStoreTab };
@@ -0,0 +1,61 @@
1
+ import { tuiTheme } from "../theme.js";
2
+ import { ModalFrame } from "./modal-frame.js";
3
+ import { SettingsList } from "@mariozechner/pi-tui";
4
+
5
+ //#region src/tui/components/settings-overlay.ts
6
+ const settingsListTheme = {
7
+ label: (text, selected) => selected ? tuiTheme.accent(text) : text,
8
+ value: (text, selected) => selected ? tuiTheme.accent(text) : tuiTheme.muted(text),
9
+ description: (text) => tuiTheme.dim(text),
10
+ cursor: tuiTheme.accent("→ "),
11
+ hint: (text) => tuiTheme.dim(text)
12
+ };
13
+ /**
14
+ * Settings overlay using pi-tui SettingsList.
15
+ * Toggleable options for the TUI session.
16
+ */
17
+ var SettingsOverlayComponent = class {
18
+ constructor(options) {
19
+ this.focused = false;
20
+ this.frame = new ModalFrame({
21
+ title: "Settings",
22
+ hint: "↑↓ navigate • Enter/Space toggle • Esc close"
23
+ });
24
+ this.list = new SettingsList([{
25
+ id: "thinking",
26
+ label: "Show thinking",
27
+ description: "Display model thinking/reasoning traces",
28
+ currentValue: options.showThinking ? "on" : "off",
29
+ values: ["on", "off"]
30
+ }, {
31
+ id: "toolExpand",
32
+ label: "Expand tool output",
33
+ description: "Show full tool/action output",
34
+ currentValue: options.toolExpand ? "on" : "off",
35
+ values: ["on", "off"]
36
+ }], 10, settingsListTheme, (id, newValue) => {
37
+ switch (id) {
38
+ case "thinking":
39
+ options.onToggleThinking(newValue === "on");
40
+ break;
41
+ case "toolExpand":
42
+ options.onToggleToolExpand(newValue === "on");
43
+ break;
44
+ }
45
+ }, () => {
46
+ options.onClose();
47
+ });
48
+ }
49
+ handleInput(data) {
50
+ this.list.handleInput(data);
51
+ }
52
+ render(width) {
53
+ return this.frame.render(width, this.list.render(width));
54
+ }
55
+ invalidate() {
56
+ this.list.invalidate();
57
+ }
58
+ };
59
+
60
+ //#endregion
61
+ export { SettingsOverlayComponent };
@@ -0,0 +1,64 @@
1
+ import { tuiTheme } from "../theme.js";
2
+ import { truncateToWidth, visibleWidth } from "@mariozechner/pi-tui";
3
+
4
+ //#region src/tui/components/status-bar.ts
5
+ /**
6
+ * Format token counts compactly (similar to Pi TUI).
7
+ */
8
+ function formatTokens(count) {
9
+ if (count < 1e3) return count.toString();
10
+ if (count < 1e4) return `${(count / 1e3).toFixed(1)}k`;
11
+ if (count < 1e6) return `${Math.round(count / 1e3)}k`;
12
+ return `${(count / 1e6).toFixed(1)}M`;
13
+ }
14
+ /**
15
+ * Status bar showing pwd, token stats, and model info (Pi-style footer).
16
+ *
17
+ * Line 1: cwd (with ~ substitution)
18
+ * Line 2: token stats (left) + model (right)
19
+ */
20
+ var StatusBar = class {
21
+ constructor() {
22
+ this.data = {
23
+ modelId: "",
24
+ modelProvider: "",
25
+ inputTokens: 0,
26
+ outputTokens: 0,
27
+ isStreaming: false,
28
+ agentName: "milady"
29
+ };
30
+ }
31
+ update(partial) {
32
+ Object.assign(this.data, partial);
33
+ }
34
+ render(width) {
35
+ const safeWidth = Math.max(1, width);
36
+ const d = this.data;
37
+ let pwd = process.cwd();
38
+ const home = process.env.HOME || process.env.USERPROFILE;
39
+ if (home && pwd.startsWith(home)) pwd = `~${pwd.slice(home.length)}`;
40
+ const pwdLine = tuiTheme.dim(truncateToWidth(pwd, safeWidth, "..."));
41
+ const statsParts = [];
42
+ if (d.inputTokens) statsParts.push(`↑${formatTokens(d.inputTokens)}`);
43
+ if (d.outputTokens) statsParts.push(`↓${formatTokens(d.outputTokens)}`);
44
+ if (d.isStreaming) statsParts.push(tuiTheme.warning("● streaming"));
45
+ const statsLeft = statsParts.length > 0 ? statsParts.join(" ") : "";
46
+ const modelName = d.modelId ? `${d.modelProvider}/${d.modelId}` : "no model";
47
+ const dimLeft = tuiTheme.dim(statsLeft);
48
+ const dimRight = tuiTheme.dim(modelName);
49
+ const leftWidth = visibleWidth(dimLeft);
50
+ const rightWidth = visibleWidth(dimRight);
51
+ const minPad = 2;
52
+ let statsLine;
53
+ if (leftWidth + minPad + rightWidth <= safeWidth) statsLine = dimLeft + " ".repeat(safeWidth - leftWidth - rightWidth) + dimRight;
54
+ else if (leftWidth + minPad < safeWidth) {
55
+ const availRight = safeWidth - leftWidth - minPad;
56
+ statsLine = dimLeft + " ".repeat(minPad) + truncateToWidth(dimRight, availRight, "");
57
+ } else statsLine = truncateToWidth(dimLeft, safeWidth, "");
58
+ return [pwdLine, statsLine];
59
+ }
60
+ invalidate() {}
61
+ };
62
+
63
+ //#endregion
64
+ export { StatusBar };
@@ -0,0 +1,68 @@
1
+ import { tuiTheme } from "../theme.js";
2
+ import { Box, Loader, Text } from "@mariozechner/pi-tui";
3
+
4
+ //#region src/tui/components/tool-execution.ts
5
+ /**
6
+ * Tool execution component styled with background tints (like Pi TUI).
7
+ * Uses Box with bg color that changes based on status.
8
+ */
9
+ var ToolExecutionComponent = class {
10
+ constructor(actionName, args, tui) {
11
+ this.actionName = actionName;
12
+ this.args = args;
13
+ this.status = "running";
14
+ this.resultText = "";
15
+ this.expanded = false;
16
+ this.loader = new Loader(tui, (spinner) => tuiTheme.warning(spinner), (text) => tuiTheme.muted(text), `Running ${actionName}...`);
17
+ this.box = new Box(1, 0, (text) => tuiTheme.toolPendingBg(text));
18
+ this.rebuildBox();
19
+ }
20
+ updateResult(result) {
21
+ this.status = result.isError ? "error" : "success";
22
+ this.resultText = result.text ?? "";
23
+ this.loader?.stop();
24
+ this.loader = null;
25
+ const bgFn = this.status === "error" ? (text) => tuiTheme.toolErrorBg(text) : (text) => tuiTheme.toolSuccessBg(text);
26
+ this.box.setBgFn(bgFn);
27
+ this.rebuildBox();
28
+ }
29
+ setExpanded(expanded) {
30
+ this.expanded = expanded;
31
+ this.rebuildBox();
32
+ }
33
+ render(width) {
34
+ return this.box.render(width);
35
+ }
36
+ invalidate() {
37
+ this.box.invalidate();
38
+ this.loader?.invalidate();
39
+ }
40
+ rebuildBox() {
41
+ this.box.clear();
42
+ const argSummary = this.summarizeArgs(80);
43
+ const headerText = argSummary ? `${tuiTheme.bold(this.actionName)} ${tuiTheme.muted(argSummary)}` : tuiTheme.bold(this.actionName);
44
+ this.box.addChild(new Text(headerText, 0, 0));
45
+ if (this.status === "running" && this.loader) this.box.addChild(this.loader);
46
+ if (this.status !== "running" && this.resultText) {
47
+ const resultLines = this.resultText.split("\n");
48
+ const isShort = resultLines.length <= 5;
49
+ const showAll = this.expanded || isShort;
50
+ const display = showAll ? resultLines : resultLines.slice(0, 5);
51
+ const colorFn = this.status === "error" ? (t) => tuiTheme.error(t) : (t) => tuiTheme.muted(t);
52
+ const body = display.map((line) => colorFn(line)).join("\n");
53
+ this.box.addChild(new Text(`\n${body}`, 0, 0));
54
+ if (!showAll) this.box.addChild(new Text(tuiTheme.dim(`... (${resultLines.length - 5} more lines, Ctrl+E to expand)`), 0, 0));
55
+ }
56
+ }
57
+ summarizeArgs(maxWidth) {
58
+ const entries = Object.entries(this.args);
59
+ if (entries.length === 0) return "";
60
+ const summary = entries.map(([k, v]) => {
61
+ return `${k}=${typeof v === "string" ? v.length > 30 ? `${v.slice(0, 27)}...` : v : JSON.stringify(v)}`;
62
+ }).join(" ");
63
+ return summary.length > maxWidth ? `${summary.slice(0, Math.max(0, maxWidth - 3))}...` : summary;
64
+ }
65
+ };
66
+
67
+ //#endregion
68
+ export { ToolExecutionComponent };
@@ -0,0 +1,22 @@
1
+ import { miladyMarkdownTheme, tuiTheme } from "../theme.js";
2
+ import { Markdown } from "@mariozechner/pi-tui";
3
+
4
+ //#region src/tui/components/user-message.ts
5
+ /**
6
+ * User message with a tinted background (Pi-style).
7
+ * Renders exactly: 1 blank line + markdown-with-bg.
8
+ */
9
+ var UserMessageComponent = class {
10
+ constructor(text, markdownTheme = miladyMarkdownTheme) {
11
+ this.markdown = new Markdown(text, 1, 0, markdownTheme, { bgColor: (t) => tuiTheme.userMsgBg(t) });
12
+ }
13
+ render(width) {
14
+ return ["", ...this.markdown.render(width)];
15
+ }
16
+ invalidate() {
17
+ this.markdown.invalidate();
18
+ }
19
+ };
20
+
21
+ //#endregion
22
+ export { UserMessageComponent };