@bubblebrain-ai/bubble 0.0.58 → 0.0.60

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 (177) hide show
  1. package/README.md +56 -6
  2. package/dist/agent/child-runner.js +5 -1
  3. package/dist/agent/internal-reminder-sanitizer.d.ts +1 -1
  4. package/dist/agent/internal-reminder-sanitizer.js +7 -1
  5. package/dist/agent/profiles.js +4 -4
  6. package/dist/agent/routing-catalog.d.ts +19 -1
  7. package/dist/agent/routing-catalog.js +32 -13
  8. package/dist/agent/subagent/runtime.d.ts +28 -0
  9. package/dist/agent/subagent/runtime.js +34 -30
  10. package/dist/agent/subagent-control.d.ts +7 -0
  11. package/dist/agent/subagent-control.js +2 -0
  12. package/dist/agent/subagent-lifecycle-reminder.js +2 -1
  13. package/dist/agent/subagent-wait-guidance.d.ts +2 -0
  14. package/dist/agent/subagent-wait-guidance.js +8 -0
  15. package/dist/agent/subtask-policy.js +4 -4
  16. package/dist/agent.d.ts +20 -11
  17. package/dist/agent.js +200 -117
  18. package/dist/anthropic-thinking.d.ts +4 -0
  19. package/dist/anthropic-thinking.js +11 -0
  20. package/dist/approval/controller.d.ts +20 -6
  21. package/dist/approval/controller.js +67 -8
  22. package/dist/approval/protected-paths.d.ts +1 -0
  23. package/dist/approval/protected-paths.js +35 -0
  24. package/dist/approval/session-cache.d.ts +12 -26
  25. package/dist/approval/session-cache.js +20 -50
  26. package/dist/approval/types.d.ts +27 -1
  27. package/dist/cli.d.ts +5 -0
  28. package/dist/cli.js +25 -2
  29. package/dist/config.d.ts +3 -0
  30. package/dist/config.js +7 -0
  31. package/dist/context/checkpoint.d.ts +18 -0
  32. package/dist/context/checkpoint.js +117 -0
  33. package/dist/context/compact-llm.js +7 -0
  34. package/dist/context/compact.d.ts +8 -0
  35. package/dist/context/compact.js +40 -7
  36. package/dist/context/llm-compactor.d.ts +36 -2
  37. package/dist/context/llm-compactor.js +227 -44
  38. package/dist/context/session-write-lock.d.ts +20 -0
  39. package/dist/context/session-write-lock.js +162 -0
  40. package/dist/context/tool-images.d.ts +3 -0
  41. package/dist/context/tool-images.js +35 -0
  42. package/dist/context/usage.js +22 -5
  43. package/dist/feishu/agent-host/run-driver.js +56 -9
  44. package/dist/lsp/service.d.ts +13 -1
  45. package/dist/lsp/service.js +163 -43
  46. package/dist/main.js +82 -16
  47. package/dist/mcp/config.d.ts +4 -0
  48. package/dist/mcp/config.js +17 -0
  49. package/dist/mcp/manager.d.ts +13 -1
  50. package/dist/mcp/manager.js +32 -1
  51. package/dist/mcp/transports.js +11 -0
  52. package/dist/memory/db.d.ts +1 -0
  53. package/dist/memory/db.js +20 -4
  54. package/dist/memory/phase1.js +122 -16
  55. package/dist/memory/prompts.js +3 -0
  56. package/dist/model-catalog.js +19 -3
  57. package/dist/model-config.d.ts +1 -0
  58. package/dist/model-config.js +5 -5
  59. package/dist/model-pricing.js +26 -9
  60. package/dist/network/provider-transport-log.d.ts +12 -0
  61. package/dist/network/provider-transport-log.js +32 -0
  62. package/dist/network/provider-transport.js +6 -1
  63. package/dist/network/retry.d.ts +1 -1
  64. package/dist/network/retry.js +1 -1
  65. package/dist/oauth/grok.d.ts +1 -0
  66. package/dist/oauth/grok.js +20 -16
  67. package/dist/oauth/openai-codex.d.ts +1 -0
  68. package/dist/oauth/openai-codex.js +29 -25
  69. package/dist/oauth/refresh-control.d.ts +12 -0
  70. package/dist/oauth/refresh-control.js +42 -0
  71. package/dist/oauth/storage.d.ts +55 -1
  72. package/dist/oauth/storage.js +281 -16
  73. package/dist/permissions/rule.d.ts +6 -3
  74. package/dist/permissions/rule.js +71 -12
  75. package/dist/permissions/settings.d.ts +28 -1
  76. package/dist/permissions/settings.js +93 -3
  77. package/dist/permissions/shell-command.d.ts +36 -0
  78. package/dist/permissions/shell-command.js +226 -0
  79. package/dist/permissions/trust-prompt.d.ts +10 -0
  80. package/dist/permissions/trust-prompt.js +34 -0
  81. package/dist/permissions/trust.d.ts +26 -0
  82. package/dist/permissions/trust.js +113 -0
  83. package/dist/prompt/compose.d.ts +3 -0
  84. package/dist/prompt/compose.js +24 -7
  85. package/dist/prompt/environment.js +2 -2
  86. package/dist/prompt/reminders.js +1 -1
  87. package/dist/prompt/runtime.js +1 -1
  88. package/dist/provider-anthropic.d.ts +6 -2
  89. package/dist/provider-anthropic.js +98 -18
  90. package/dist/provider-error-record.d.ts +9 -0
  91. package/dist/provider-error-record.js +42 -14
  92. package/dist/provider-grok.js +5 -1
  93. package/dist/provider-openai-codex.d.ts +8 -0
  94. package/dist/provider-openai-codex.js +107 -24
  95. package/dist/provider-registry.d.ts +45 -2
  96. package/dist/provider-registry.js +300 -88
  97. package/dist/provider-transform.js +8 -0
  98. package/dist/provider-zen-errors.d.ts +9 -0
  99. package/dist/provider-zen-errors.js +36 -0
  100. package/dist/provider.js +36 -5
  101. package/dist/sdk/index.d.ts +69 -8
  102. package/dist/sdk/index.js +252 -39
  103. package/dist/sdk/replay-event-log.d.ts +7 -0
  104. package/dist/sdk/replay-event-log.js +66 -16
  105. package/dist/session-context-fence.d.ts +16 -0
  106. package/dist/session-context-fence.js +26 -0
  107. package/dist/session-log.d.ts +11 -2
  108. package/dist/session-log.js +187 -39
  109. package/dist/session-types.d.ts +5 -1
  110. package/dist/session.d.ts +39 -7
  111. package/dist/session.js +341 -93
  112. package/dist/skills/format.d.ts +31 -1
  113. package/dist/skills/format.js +45 -24
  114. package/dist/slash-commands/commands.d.ts +3 -0
  115. package/dist/slash-commands/commands.js +29 -14
  116. package/dist/system-prompt.d.ts +3 -1
  117. package/dist/tasks/manager.d.ts +7 -0
  118. package/dist/tasks/manager.js +97 -18
  119. package/dist/tools/agent-lifecycle.js +11 -7
  120. package/dist/tools/child-tools.d.ts +1 -1
  121. package/dist/tools/child-tools.js +4 -4
  122. package/dist/tools/edit-apply.d.ts +0 -3
  123. package/dist/tools/edit-apply.js +45 -249
  124. package/dist/tools/edit.js +3 -3
  125. package/dist/tools/exit-plan-mode.d.ts +5 -0
  126. package/dist/tools/exit-plan-mode.js +3 -2
  127. package/dist/tools/file-state.d.ts +4 -0
  128. package/dist/tools/file-state.js +12 -3
  129. package/dist/tools/grep.js +20 -1
  130. package/dist/tools/index.d.ts +1 -1
  131. package/dist/tools/index.js +3 -3
  132. package/dist/tools/ls.d.ts +3 -0
  133. package/dist/tools/ls.js +85 -0
  134. package/dist/tools/path-utils.d.ts +6 -0
  135. package/dist/tools/path-utils.js +38 -1
  136. package/dist/tools/sensitive-paths.d.ts +8 -0
  137. package/dist/tools/sensitive-paths.js +85 -3
  138. package/dist/tools/skill.d.ts +2 -0
  139. package/dist/tools/skill.js +34 -2
  140. package/dist/tools/task-tools.js +11 -7
  141. package/dist/tui/app.js +22 -12
  142. package/dist/tui/components/approval-dialog.d.ts +5 -5
  143. package/dist/tui/components/approval-dialog.js +16 -51
  144. package/dist/tui/components/skills-panel.d.ts +4 -0
  145. package/dist/tui/components/skills-panel.js +15 -1
  146. package/dist/tui/components/streaming-message.js +7 -2
  147. package/dist/tui/components/tasks-pane.d.ts +38 -0
  148. package/dist/tui/components/tasks-pane.js +182 -32
  149. package/dist/tui/components/transcript.d.ts +11 -4
  150. package/dist/tui/components/transcript.js +158 -71
  151. package/dist/tui/composer-autocomplete.d.ts +17 -2
  152. package/dist/tui/composer-autocomplete.js +79 -2
  153. package/dist/tui/controller/controller.d.ts +9 -4
  154. package/dist/tui/controller/controller.js +87 -95
  155. package/dist/tui/controller/goal-runtime-controller.js +1 -1
  156. package/dist/tui/controller/session-transition.js +1 -1
  157. package/dist/tui/model/subagent-view.d.ts +11 -19
  158. package/dist/tui/model/subagent-view.js +56 -85
  159. package/dist/tui/model/task-lifecycle.d.ts +57 -0
  160. package/dist/tui/model/task-lifecycle.js +124 -0
  161. package/dist/tui/model/trace-groups.js +10 -9
  162. package/dist/tui/trace-groups.js +10 -9
  163. package/dist/types.d.ts +20 -0
  164. package/dist/variant/variant-resolver.js +2 -0
  165. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.d.ts +1 -0
  166. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.d.ts.map +1 -1
  167. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.js +6 -0
  168. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui-alt-screen.js.map +1 -1
  169. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.d.ts +2 -0
  170. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.d.ts.map +1 -1
  171. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.js +8 -4
  172. package/node_modules/@bubblebrain-ai/pi-tui/dist/src/tui.js.map +1 -1
  173. package/package.json +11 -3
  174. package/dist/prompt/skills.d.ts +0 -2
  175. package/dist/prompt/skills.js +0 -4
  176. package/dist/tools/glob.d.ts +0 -5
  177. package/dist/tools/glob.js +0 -199
@@ -1,199 +0,0 @@
1
- /**
2
- * Glob tool - discover files by path pattern without shell access.
3
- */
4
- import { readdir, stat } from "node:fs/promises";
5
- import { basename, dirname, isAbsolute, relative, resolve } from "node:path";
6
- import picomatch from "picomatch";
7
- import { isSensitivePath } from "./sensitive-paths.js";
8
- import { expandHomePath, resolveToolPath } from "./path-utils.js";
9
- const MAX_RESULTS = 100;
10
- const DEFAULT_IGNORES = new Set([
11
- ".git",
12
- "node_modules",
13
- "dist",
14
- "build",
15
- ".next",
16
- ".turbo",
17
- ".cache",
18
- "coverage",
19
- ]);
20
- export function createGlobTool(cwd) {
21
- return {
22
- name: "glob",
23
- readOnly: true,
24
- effect: "read",
25
- description: `Find files by glob pattern without using the shell. Use this for project structure discovery and filename searches. Returns up to ${MAX_RESULTS} files sorted by recent modification time.`,
26
- parameters: {
27
- type: "object",
28
- properties: {
29
- pattern: { type: "string", description: "Glob pattern to match files, e.g. '**/*', '**/*.ts', 'src/**/*.tsx'" },
30
- path: { type: "string", description: "Directory to search in (optional, default: cwd)" },
31
- },
32
- required: ["pattern"],
33
- },
34
- async execute(args, ctx) {
35
- const requestedRoot = resolveToolPath(cwd, typeof args.path === "string" && args.path.trim() ? args.path : ".");
36
- const originalPattern = String(args.pattern || "").trim();
37
- if (!originalPattern) {
38
- return { content: "Error: glob pattern is required", isError: true, status: "command_error" };
39
- }
40
- const normalized = normalizeGlobSearch(requestedRoot, originalPattern);
41
- if (normalized.error) {
42
- return normalized.error;
43
- }
44
- const { root, pattern, normalizedPattern } = normalized;
45
- if (isSensitivePath(root)) {
46
- return {
47
- content: `Error: Glob blocked for sensitive credential storage: ${root}`,
48
- isError: true,
49
- status: "blocked",
50
- metadata: {
51
- kind: "security",
52
- path: root,
53
- pattern: normalizedPattern,
54
- originalPattern,
55
- normalizedPattern,
56
- reason: "Sensitive credential storage is not searchable from general-purpose tasks.",
57
- },
58
- };
59
- }
60
- const matcher = picomatch(pattern, { dot: true });
61
- const files = [];
62
- const truncated = { value: false };
63
- try {
64
- const rootStat = await stat(root);
65
- if (!rootStat.isDirectory()) {
66
- return { content: `Error: Path is not a directory: ${root}`, isError: true, status: "command_error" };
67
- }
68
- await walk(root, root, matcher, files, truncated, ctx.abortSignal);
69
- }
70
- catch (error) {
71
- return { content: `Error: Cannot glob path: ${root} (${error?.message || String(error)})`, isError: true, status: "command_error" };
72
- }
73
- files.sort((a, b) => b.mtimeMs - a.mtimeMs || a.path.localeCompare(b.path));
74
- const matches = files.slice(0, MAX_RESULTS).map((item) => item.path);
75
- const absoluteMatches = matches.map((item) => resolve(root, item));
76
- const wasTruncated = truncated.value || files.length > MAX_RESULTS;
77
- if (matches.length === 0) {
78
- return {
79
- content: "No files found.",
80
- status: "no_match",
81
- metadata: {
82
- kind: "search",
83
- path: root,
84
- pattern: normalizedPattern,
85
- originalPattern,
86
- normalizedPattern,
87
- matches: 0,
88
- truncated: false,
89
- searchSignature: `glob:${root}:${normalizedPattern}`,
90
- searchFamily: `glob:${normalizedPattern}`,
91
- paths: [],
92
- },
93
- };
94
- }
95
- return {
96
- content: `${matches.join("\n")}${wasTruncated ? `\n[More than ${MAX_RESULTS} files, output truncated]` : ""}`,
97
- status: wasTruncated ? "partial" : "success",
98
- metadata: {
99
- kind: "search",
100
- path: root,
101
- pattern: normalizedPattern,
102
- originalPattern,
103
- normalizedPattern,
104
- matches: matches.length,
105
- truncated: wasTruncated,
106
- searchSignature: `glob:${root}:${normalizedPattern}`,
107
- searchFamily: `glob:${normalizedPattern}`,
108
- paths: absoluteMatches,
109
- },
110
- };
111
- },
112
- };
113
- }
114
- function normalizeGlobSearch(requestedRoot, originalPattern) {
115
- const expandedPattern = expandGlobPatternHome(originalPattern);
116
- const scan = picomatch.scan(expandedPattern);
117
- const prefix = scan.prefix ?? "";
118
- if (!isAbsolute(scan.base)) {
119
- if (escapesSearchRoot(scan.base)) {
120
- return {
121
- error: {
122
- content: `Error: Glob pattern must stay within the search path: ${originalPattern}`,
123
- isError: true,
124
- status: "command_error",
125
- metadata: {
126
- kind: "search",
127
- path: requestedRoot,
128
- pattern: originalPattern,
129
- originalPattern,
130
- normalizedPattern: originalPattern,
131
- reason: "pattern_outside_search_path",
132
- },
133
- },
134
- };
135
- }
136
- return { root: requestedRoot, pattern: originalPattern, normalizedPattern: originalPattern };
137
- }
138
- const absoluteBase = resolve(scan.base);
139
- const patternRoot = scan.isGlob ? absoluteBase : dirname(absoluteBase);
140
- const patternBody = scan.isGlob ? scan.glob : basename(absoluteBase);
141
- const normalizedRoot = isWithinSearchRoot(requestedRoot, patternRoot) ? requestedRoot : patternRoot;
142
- const relativeBase = toPosix(relative(normalizedRoot, patternRoot));
143
- const normalizedBody = [relativeBase, patternBody].filter(Boolean).join("/");
144
- const normalizedPattern = `${prefix}${normalizedBody}`;
145
- return {
146
- root: normalizedRoot,
147
- pattern: normalizedPattern,
148
- normalizedPattern,
149
- };
150
- }
151
- function expandGlobPatternHome(pattern) {
152
- if (pattern.startsWith("!")) {
153
- return `!${expandHomePath(pattern.slice(1))}`;
154
- }
155
- return expandHomePath(pattern);
156
- }
157
- function escapesSearchRoot(base) {
158
- const normalized = toPosix(base);
159
- return normalized === ".." || normalized.startsWith("../");
160
- }
161
- function isWithinSearchRoot(root, target) {
162
- const rel = relative(root, target);
163
- return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
164
- }
165
- async function walk(root, dir, matcher, files, truncated, abortSignal) {
166
- if (abortSignal?.aborted || files.length >= MAX_RESULTS) {
167
- truncated.value = true;
168
- return;
169
- }
170
- const entries = await readdir(dir, { withFileTypes: true });
171
- for (const entry of entries) {
172
- if (abortSignal?.aborted || files.length >= MAX_RESULTS) {
173
- truncated.value = true;
174
- return;
175
- }
176
- if (entry.isDirectory() && DEFAULT_IGNORES.has(entry.name)) {
177
- continue;
178
- }
179
- const absolute = resolve(dir, entry.name);
180
- if (isSensitivePath(absolute)) {
181
- continue;
182
- }
183
- const rel = toPosix(relative(root, absolute));
184
- if (entry.isDirectory()) {
185
- await walk(root, absolute, matcher, files, truncated, abortSignal);
186
- continue;
187
- }
188
- if (!entry.isFile()) {
189
- continue;
190
- }
191
- if (matcher(rel)) {
192
- const info = await stat(absolute);
193
- files.push({ path: rel, mtimeMs: info.mtimeMs });
194
- }
195
- }
196
- }
197
- function toPosix(path) {
198
- return path.split("\\").join("/");
199
- }