@bubblebrain-ai/bubble 0.0.12 → 0.0.13

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 (128) hide show
  1. package/dist/agent/input-controller.d.ts +11 -0
  2. package/dist/agent/input-controller.js +30 -0
  3. package/dist/agent.d.ts +6 -4
  4. package/dist/agent.js +38 -0
  5. package/dist/main.js +58 -9
  6. package/dist/slash-commands/commands.js +27 -0
  7. package/dist/slash-commands/types.d.ts +10 -0
  8. package/dist/tui/clipboard.d.ts +1 -0
  9. package/dist/tui/clipboard.js +53 -0
  10. package/dist/tui/detect-theme.d.ts +2 -0
  11. package/dist/tui/detect-theme.js +87 -0
  12. package/dist/tui/display-history.d.ts +62 -0
  13. package/dist/tui/display-history.js +305 -0
  14. package/dist/tui/edit-diff.d.ts +11 -0
  15. package/dist/tui/edit-diff.js +52 -0
  16. package/dist/tui/escape-confirmation.d.ts +15 -0
  17. package/dist/tui/escape-confirmation.js +30 -0
  18. package/dist/tui/file-mentions.d.ts +29 -0
  19. package/dist/tui/file-mentions.js +174 -0
  20. package/dist/tui/global-key-router.d.ts +3 -0
  21. package/dist/tui/global-key-router.js +87 -0
  22. package/dist/tui/image-paste.d.ts +95 -0
  23. package/dist/tui/image-paste.js +505 -0
  24. package/dist/tui/input-history.d.ts +16 -0
  25. package/dist/tui/input-history.js +79 -0
  26. package/dist/tui/markdown-inline.d.ts +22 -0
  27. package/dist/tui/markdown-inline.js +68 -0
  28. package/dist/tui/markdown-theme-rules.d.ts +23 -0
  29. package/dist/tui/markdown-theme-rules.js +164 -0
  30. package/dist/tui/markdown-theme.d.ts +5 -0
  31. package/dist/tui/markdown-theme.js +27 -0
  32. package/dist/tui/opencode-spinner.d.ts +22 -0
  33. package/dist/tui/opencode-spinner.js +216 -0
  34. package/dist/tui/prompt-keybindings.d.ts +42 -0
  35. package/dist/tui/prompt-keybindings.js +35 -0
  36. package/dist/tui/recent-activity.d.ts +8 -0
  37. package/dist/tui/recent-activity.js +71 -0
  38. package/dist/tui/render-signature.d.ts +1 -0
  39. package/dist/tui/render-signature.js +7 -0
  40. package/dist/tui/run.d.ts +45 -0
  41. package/dist/tui/run.js +8816 -0
  42. package/dist/tui/session-display.d.ts +6 -0
  43. package/dist/tui/session-display.js +12 -0
  44. package/dist/tui/sidebar-mcp.d.ts +31 -0
  45. package/dist/tui/sidebar-mcp.js +62 -0
  46. package/dist/tui/sidebar-state.d.ts +12 -0
  47. package/dist/tui/sidebar-state.js +69 -0
  48. package/dist/tui/streaming-tool-args.d.ts +15 -0
  49. package/dist/tui/streaming-tool-args.js +30 -0
  50. package/dist/tui/tool-renderers/fallback.d.ts +2 -0
  51. package/dist/tui/tool-renderers/fallback.js +75 -0
  52. package/dist/tui/tool-renderers/registry.d.ts +3 -0
  53. package/dist/tui/tool-renderers/registry.js +11 -0
  54. package/dist/tui/tool-renderers/subagent.d.ts +2 -0
  55. package/dist/tui/tool-renderers/subagent.js +135 -0
  56. package/dist/tui/tool-renderers/types.d.ts +36 -0
  57. package/dist/tui/tool-renderers/types.js +1 -0
  58. package/dist/tui/tool-renderers/write-preview.d.ts +12 -0
  59. package/dist/tui/tool-renderers/write-preview.js +30 -0
  60. package/dist/tui/tool-renderers/write.d.ts +6 -0
  61. package/dist/tui/tool-renderers/write.js +88 -0
  62. package/dist/tui/trace-groups.d.ts +27 -0
  63. package/dist/tui/trace-groups.js +412 -0
  64. package/dist/tui/wordmark.d.ts +15 -0
  65. package/dist/tui/wordmark.js +179 -0
  66. package/dist/tui-ink/app.js +44 -5
  67. package/dist/tui-ink/message-list.js +9 -1
  68. package/dist/tui-ink/theme.d.ts +3 -9
  69. package/dist/tui-ink/theme.js +39 -45
  70. package/dist/tui-ink/welcome.js +22 -78
  71. package/dist/tui-opentui/app.d.ts +54 -0
  72. package/dist/tui-opentui/app.js +1363 -0
  73. package/dist/tui-opentui/approval/approval-dialog.d.ts +15 -0
  74. package/dist/tui-opentui/approval/approval-dialog.js +139 -0
  75. package/dist/tui-opentui/approval/diff-view.d.ts +9 -0
  76. package/dist/tui-opentui/approval/diff-view.js +43 -0
  77. package/dist/tui-opentui/approval/select.d.ts +37 -0
  78. package/dist/tui-opentui/approval/select.js +91 -0
  79. package/dist/tui-opentui/detect-theme.d.ts +2 -0
  80. package/dist/tui-opentui/detect-theme.js +87 -0
  81. package/dist/tui-opentui/display-history.d.ts +55 -0
  82. package/dist/tui-opentui/display-history.js +129 -0
  83. package/dist/tui-opentui/edit-diff.d.ts +11 -0
  84. package/dist/tui-opentui/edit-diff.js +52 -0
  85. package/dist/tui-opentui/feedback-dialog.d.ts +21 -0
  86. package/dist/tui-opentui/feedback-dialog.js +164 -0
  87. package/dist/tui-opentui/feishu-setup-picker.d.ts +7 -0
  88. package/dist/tui-opentui/feishu-setup-picker.js +272 -0
  89. package/dist/tui-opentui/file-mentions.d.ts +29 -0
  90. package/dist/tui-opentui/file-mentions.js +174 -0
  91. package/dist/tui-opentui/footer.d.ts +26 -0
  92. package/dist/tui-opentui/footer.js +40 -0
  93. package/dist/tui-opentui/image-paste.d.ts +54 -0
  94. package/dist/tui-opentui/image-paste.js +288 -0
  95. package/dist/tui-opentui/input-box.d.ts +34 -0
  96. package/dist/tui-opentui/input-box.js +471 -0
  97. package/dist/tui-opentui/input-history.d.ts +16 -0
  98. package/dist/tui-opentui/input-history.js +79 -0
  99. package/dist/tui-opentui/markdown.d.ts +66 -0
  100. package/dist/tui-opentui/markdown.js +127 -0
  101. package/dist/tui-opentui/message-list.d.ts +31 -0
  102. package/dist/tui-opentui/message-list.js +125 -0
  103. package/dist/tui-opentui/model-picker.d.ts +63 -0
  104. package/dist/tui-opentui/model-picker.js +450 -0
  105. package/dist/tui-opentui/plan-confirm.d.ts +9 -0
  106. package/dist/tui-opentui/plan-confirm.js +124 -0
  107. package/dist/tui-opentui/question-dialog.d.ts +10 -0
  108. package/dist/tui-opentui/question-dialog.js +110 -0
  109. package/dist/tui-opentui/recent-activity.d.ts +8 -0
  110. package/dist/tui-opentui/recent-activity.js +71 -0
  111. package/dist/tui-opentui/run-session-picker.d.ts +10 -0
  112. package/dist/tui-opentui/run-session-picker.js +28 -0
  113. package/dist/tui-opentui/run.d.ts +38 -0
  114. package/dist/tui-opentui/run.js +48 -0
  115. package/dist/tui-opentui/session-picker.d.ts +12 -0
  116. package/dist/tui-opentui/session-picker.js +120 -0
  117. package/dist/tui-opentui/theme.d.ts +89 -0
  118. package/dist/tui-opentui/theme.js +157 -0
  119. package/dist/tui-opentui/todos.d.ts +9 -0
  120. package/dist/tui-opentui/todos.js +45 -0
  121. package/dist/tui-opentui/trace-groups.d.ts +27 -0
  122. package/dist/tui-opentui/trace-groups.js +412 -0
  123. package/dist/tui-opentui/use-terminal-size.d.ts +4 -0
  124. package/dist/tui-opentui/use-terminal-size.js +5 -0
  125. package/dist/tui-opentui/welcome.d.ts +25 -0
  126. package/dist/tui-opentui/welcome.js +77 -0
  127. package/dist/types.d.ts +24 -0
  128. package/package.json +5 -1
@@ -0,0 +1,35 @@
1
+ export const PROMPT_TEXTAREA_KEYBINDINGS = [
2
+ { name: "return", action: "submit" },
3
+ { name: "return", shift: true, action: "newline" },
4
+ { name: "return", ctrl: true, action: "newline" },
5
+ { name: "return", meta: true, action: "newline" },
6
+ { name: "j", ctrl: true, action: "newline" },
7
+ { name: "linefeed", action: "newline" },
8
+ ];
9
+ export function isModifiedEnterSequence(input) {
10
+ const value = input.sequence || input.raw || "";
11
+ return /^\x1b\[13;[2-9]\d*[u~]$/.test(value)
12
+ || /^\x1b\[27;[2-9]\d*;13~$/.test(value);
13
+ }
14
+ export function isModeCycleSequence(value) {
15
+ if (!value)
16
+ return false;
17
+ return value === "\t"
18
+ || value === "\x1b[Z"
19
+ || /^\x1b\[(?:9|57346);[12]u$/.test(value)
20
+ || /^\x1b\[27;2;9~$/.test(value);
21
+ }
22
+ export function isEscapeSequence(value) {
23
+ if (!value)
24
+ return false;
25
+ return value === "\x1b"
26
+ || /^\x1b\[(?:27|57344)(?:;[1-9]\d*(?::[1-3])?)?u$/.test(value)
27
+ || /^\x1b\[27;[1-9]\d*(?::[1-3])?;(?:27|57344)~$/.test(value);
28
+ }
29
+ export function isModeCycleKeyEvent(input) {
30
+ const name = String(input.name || "").toLowerCase();
31
+ return name === "tab"
32
+ || name === "backtab"
33
+ || name === "shift+tab"
34
+ || isModeCycleSequence(input.raw || input.sequence);
35
+ }
@@ -0,0 +1,8 @@
1
+ export interface RecentSession {
2
+ file: string;
3
+ modifiedAt: number;
4
+ preview: string;
5
+ }
6
+ export declare function getRecentSessions(cwd: string, limit?: number): RecentSession[];
7
+ export declare function formatRelativeTime(timestampMs: number, now?: number): string;
8
+ export declare function truncatePreview(preview: string, maxLen: number): string;
@@ -0,0 +1,71 @@
1
+ import { readFileSync, readdirSync, statSync, existsSync } from "node:fs";
2
+ import path from "node:path";
3
+ import { getSessionsDir } from "../session.js";
4
+ export function getRecentSessions(cwd, limit = 3) {
5
+ const dir = getSessionsDir(cwd);
6
+ if (!existsSync(dir))
7
+ return [];
8
+ const files = readdirSync(dir).filter((f) => f.endsWith(".jsonl"));
9
+ const withMtime = files.map((f) => {
10
+ const full = path.join(dir, f);
11
+ try {
12
+ return { file: f, full, modifiedAt: statSync(full).mtimeMs };
13
+ }
14
+ catch {
15
+ return { file: f, full, modifiedAt: 0 };
16
+ }
17
+ });
18
+ withMtime.sort((a, b) => b.modifiedAt - a.modifiedAt);
19
+ return withMtime.slice(0, limit).map(({ file, full, modifiedAt }) => ({
20
+ file,
21
+ modifiedAt,
22
+ preview: extractFirstUserMessage(full) ?? "(no messages)",
23
+ }));
24
+ }
25
+ export function formatRelativeTime(timestampMs, now = Date.now()) {
26
+ const diffSec = Math.max(0, Math.floor((now - timestampMs) / 1000));
27
+ if (diffSec < 60)
28
+ return "just now";
29
+ if (diffSec < 3600)
30
+ return `${Math.floor(diffSec / 60)}m ago`;
31
+ if (diffSec < 86400)
32
+ return `${Math.floor(diffSec / 3600)}h ago`;
33
+ if (diffSec < 604800)
34
+ return `${Math.floor(diffSec / 86400)}d ago`;
35
+ const weeks = Math.floor(diffSec / 604800);
36
+ if (weeks < 5)
37
+ return `${weeks}w ago`;
38
+ const months = Math.floor(diffSec / (30 * 86400));
39
+ return `${months}mo ago`;
40
+ }
41
+ function extractFirstUserMessage(file) {
42
+ let raw;
43
+ try {
44
+ raw = readFileSync(file, "utf-8");
45
+ }
46
+ catch {
47
+ return null;
48
+ }
49
+ const lines = raw.split("\n");
50
+ for (const line of lines) {
51
+ if (!line.trim())
52
+ continue;
53
+ let entry;
54
+ try {
55
+ entry = JSON.parse(line);
56
+ }
57
+ catch {
58
+ continue;
59
+ }
60
+ if (entry.type === "user_message" && typeof entry.message?.content === "string") {
61
+ return entry.message.content;
62
+ }
63
+ }
64
+ return null;
65
+ }
66
+ export function truncatePreview(preview, maxLen) {
67
+ const firstLine = preview.split("\n")[0]?.trim() ?? "";
68
+ if (firstLine.length <= maxLen)
69
+ return firstLine;
70
+ return firstLine.slice(0, Math.max(1, maxLen - 1)) + "…";
71
+ }
@@ -0,0 +1 @@
1
+ export declare function hashString(value: string): string;
@@ -0,0 +1,7 @@
1
+ export function hashString(value) {
2
+ let hash = 5381;
3
+ for (let index = 0; index < value.length; index++) {
4
+ hash = ((hash << 5) + hash) ^ value.charCodeAt(index);
5
+ }
6
+ return (hash >>> 0).toString(36);
7
+ }
@@ -0,0 +1,45 @@
1
+ import { type Agent } from "../agent.js";
2
+ import type { CliArgs } from "../cli.js";
3
+ import type { ThemeMode } from "../config.js";
4
+ import type { SessionManager } from "../session.js";
5
+ import type { PlanDecision, Provider } from "../types.js";
6
+ import type { ProviderRegistry } from "../provider-registry.js";
7
+ import type { SkillRegistry } from "../skills/registry.js";
8
+ import { type LspService } from "../lsp/index.js";
9
+ import { type BashAllowlist } from "../approval/session-cache.js";
10
+ import type { SettingsManager } from "../permissions/settings.js";
11
+ import type { McpManager } from "../mcp/manager.js";
12
+ import type { ApprovalDecision, ApprovalRequest } from "../approval/types.js";
13
+ import type { QuestionController } from "../question/index.js";
14
+ import type { MemoryScope } from "../memory/index.js";
15
+ import type { ResolvedTheme } from "./detect-theme.js";
16
+ export interface PlanHandlerRef {
17
+ current?: (plan: string) => Promise<PlanDecision>;
18
+ }
19
+ export interface ApprovalHandlerRef {
20
+ current?: (req: ApprovalRequest) => Promise<ApprovalDecision>;
21
+ }
22
+ export interface RunTuiOptions {
23
+ sessionManager?: SessionManager;
24
+ createProvider?: (providerId: string, apiKey: string, baseURL: string) => Provider;
25
+ registry?: ProviderRegistry;
26
+ skillRegistry?: SkillRegistry;
27
+ planHandlerRef?: PlanHandlerRef;
28
+ approvalHandlerRef?: ApprovalHandlerRef;
29
+ questionController?: QuestionController;
30
+ bashAllowlist?: BashAllowlist;
31
+ settingsManager?: SettingsManager;
32
+ lspService?: LspService;
33
+ mcpManager?: McpManager;
34
+ themeMode?: ThemeMode;
35
+ themeOverrides?: Record<string, string>;
36
+ detectedTheme?: ResolvedTheme;
37
+ onThemeModeChange?: (mode: ThemeMode) => void;
38
+ /** Legacy dark-palette overrides. Prefer themeOverrides for new callers. */
39
+ theme?: Record<string, string>;
40
+ flushMemory?: () => Promise<void>;
41
+ runMemoryCompaction?: () => Promise<string>;
42
+ runMemorySummary?: (scope?: MemoryScope) => Promise<string>;
43
+ runMemoryRefresh?: (scope?: MemoryScope) => Promise<string>;
44
+ }
45
+ export declare function runTui(agent: Agent, args: CliArgs, options?: RunTuiOptions): Promise<void>;