@bubblebrain-ai/bubble 0.0.12 → 0.0.14
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/dist/agent/execution-governor.js +1 -1
- package/dist/agent/input-controller.d.ts +11 -0
- package/dist/agent/input-controller.js +30 -0
- package/dist/agent/tool-intent.js +1 -0
- package/dist/agent.d.ts +8 -4
- package/dist/agent.js +623 -312
- package/dist/approval/controller.d.ts +1 -0
- package/dist/approval/controller.js +20 -3
- package/dist/approval/tool-helper.js +2 -0
- package/dist/approval/types.d.ts +14 -1
- package/dist/context/compact.js +9 -3
- package/dist/context/projector.js +27 -12
- package/dist/debug-trace.d.ts +27 -0
- package/dist/debug-trace.js +385 -0
- package/dist/feishu/agent-host/approval-card.js +9 -0
- package/dist/feishu/serve.js +7 -1
- package/dist/main.js +86 -9
- package/dist/model-catalog.js +1 -0
- package/dist/orchestrator/default-hooks.js +19 -8
- package/dist/orchestrator/hooks.d.ts +1 -0
- package/dist/prompt/environment.js +2 -0
- package/dist/prompt/reminders.d.ts +5 -6
- package/dist/prompt/reminders.js +8 -9
- package/dist/prompt/runtime.js +2 -2
- package/dist/provider-openai-codex.d.ts +7 -0
- package/dist/provider-openai-codex.js +265 -124
- package/dist/provider-registry.d.ts +2 -0
- package/dist/provider-registry.js +58 -9
- package/dist/provider.d.ts +3 -0
- package/dist/provider.js +5 -1
- package/dist/session-log.js +13 -1
- package/dist/slash-commands/commands.js +39 -0
- package/dist/slash-commands/types.d.ts +12 -0
- package/dist/stats/usage.d.ts +52 -0
- package/dist/stats/usage.js +414 -0
- package/dist/tools/apply-patch.d.ts +9 -0
- package/dist/tools/apply-patch.js +330 -0
- package/dist/tools/bash.js +205 -44
- package/dist/tools/edit-apply.d.ts +5 -2
- package/dist/tools/edit-apply.js +221 -31
- package/dist/tools/edit.js +12 -3
- package/dist/tools/file-mutation-queue.d.ts +1 -0
- package/dist/tools/file-mutation-queue.js +12 -1
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +7 -1
- package/dist/tools/patch-apply.d.ts +41 -0
- package/dist/tools/patch-apply.js +312 -0
- package/dist/tools/server-manager.d.ts +36 -0
- package/dist/tools/server-manager.js +234 -0
- package/dist/tools/server.d.ts +6 -0
- package/dist/tools/server.js +245 -0
- package/dist/tools/write.d.ts +3 -6
- package/dist/tools/write.js +26 -46
- package/dist/tui/clipboard.d.ts +1 -0
- package/dist/tui/clipboard.js +53 -0
- package/dist/tui/detect-theme.d.ts +2 -0
- package/dist/tui/detect-theme.js +87 -0
- package/dist/tui/display-history.d.ts +63 -0
- package/dist/tui/display-history.js +306 -0
- package/dist/tui/edit-diff.d.ts +11 -0
- package/dist/tui/edit-diff.js +57 -0
- package/dist/tui/escape-confirmation.d.ts +15 -0
- package/dist/tui/escape-confirmation.js +30 -0
- package/dist/tui/file-mentions.d.ts +29 -0
- package/dist/tui/file-mentions.js +174 -0
- package/dist/tui/global-key-router.d.ts +3 -0
- package/dist/tui/global-key-router.js +87 -0
- package/dist/tui/image-paste.d.ts +95 -0
- package/dist/tui/image-paste.js +505 -0
- package/dist/tui/input-history.d.ts +16 -0
- package/dist/tui/input-history.js +79 -0
- package/dist/tui/markdown-inline.d.ts +22 -0
- package/dist/tui/markdown-inline.js +68 -0
- package/dist/tui/markdown-theme-rules.d.ts +23 -0
- package/dist/tui/markdown-theme-rules.js +164 -0
- package/dist/tui/markdown-theme.d.ts +5 -0
- package/dist/tui/markdown-theme.js +27 -0
- package/dist/tui/model-picker-data.d.ts +10 -0
- package/dist/tui/model-picker-data.js +32 -0
- package/dist/tui/opencode-spinner.d.ts +22 -0
- package/dist/tui/opencode-spinner.js +216 -0
- package/dist/tui/prompt-keybindings.d.ts +42 -0
- package/dist/tui/prompt-keybindings.js +35 -0
- package/dist/tui/recent-activity.d.ts +8 -0
- package/dist/tui/recent-activity.js +71 -0
- package/dist/tui/render-signature.d.ts +1 -0
- package/dist/tui/render-signature.js +7 -0
- package/dist/tui/run.d.ts +45 -0
- package/dist/tui/run.js +9359 -0
- package/dist/tui/session-display.d.ts +6 -0
- package/dist/tui/session-display.js +12 -0
- package/dist/tui/sidebar-mcp.d.ts +31 -0
- package/dist/tui/sidebar-mcp.js +62 -0
- package/dist/tui/sidebar-state.d.ts +12 -0
- package/dist/tui/sidebar-state.js +69 -0
- package/dist/tui/streaming-tool-args.d.ts +15 -0
- package/dist/tui/streaming-tool-args.js +30 -0
- package/dist/tui/tool-renderers/fallback.d.ts +2 -0
- package/dist/tui/tool-renderers/fallback.js +75 -0
- package/dist/tui/tool-renderers/registry.d.ts +3 -0
- package/dist/tui/tool-renderers/registry.js +11 -0
- package/dist/tui/tool-renderers/subagent.d.ts +2 -0
- package/dist/tui/tool-renderers/subagent.js +135 -0
- package/dist/tui/tool-renderers/types.d.ts +36 -0
- package/dist/tui/tool-renderers/types.js +1 -0
- package/dist/tui/tool-renderers/write-preview.d.ts +12 -0
- package/dist/tui/tool-renderers/write-preview.js +32 -0
- package/dist/tui/tool-renderers/write.d.ts +6 -0
- package/dist/tui/tool-renderers/write.js +88 -0
- package/dist/tui/trace-groups.d.ts +27 -0
- package/dist/tui/trace-groups.js +419 -0
- package/dist/tui/wordmark.d.ts +15 -0
- package/dist/tui/wordmark.js +179 -0
- package/dist/tui-ink/app.js +45 -9
- package/dist/tui-ink/approval/approval-dialog.js +7 -1
- package/dist/tui-ink/display-history.d.ts +1 -0
- package/dist/tui-ink/display-history.js +5 -4
- package/dist/tui-ink/message-list.js +23 -9
- package/dist/tui-ink/theme.d.ts +3 -9
- package/dist/tui-ink/theme.js +39 -45
- package/dist/tui-ink/trace-groups.js +1 -1
- package/dist/tui-ink/welcome.js +22 -78
- package/dist/tui-opentui/app.d.ts +54 -0
- package/dist/tui-opentui/app.js +1365 -0
- package/dist/tui-opentui/approval/approval-dialog.d.ts +15 -0
- package/dist/tui-opentui/approval/approval-dialog.js +145 -0
- package/dist/tui-opentui/approval/diff-view.d.ts +9 -0
- package/dist/tui-opentui/approval/diff-view.js +43 -0
- package/dist/tui-opentui/approval/select.d.ts +37 -0
- package/dist/tui-opentui/approval/select.js +91 -0
- package/dist/tui-opentui/detect-theme.d.ts +2 -0
- package/dist/tui-opentui/detect-theme.js +87 -0
- package/dist/tui-opentui/display-history.d.ts +56 -0
- package/dist/tui-opentui/display-history.js +130 -0
- package/dist/tui-opentui/edit-diff.d.ts +11 -0
- package/dist/tui-opentui/edit-diff.js +57 -0
- package/dist/tui-opentui/feedback-dialog.d.ts +21 -0
- package/dist/tui-opentui/feedback-dialog.js +164 -0
- package/dist/tui-opentui/feishu-setup-picker.d.ts +7 -0
- package/dist/tui-opentui/feishu-setup-picker.js +272 -0
- package/dist/tui-opentui/file-mentions.d.ts +29 -0
- package/dist/tui-opentui/file-mentions.js +174 -0
- package/dist/tui-opentui/footer.d.ts +26 -0
- package/dist/tui-opentui/footer.js +40 -0
- package/dist/tui-opentui/image-paste.d.ts +54 -0
- package/dist/tui-opentui/image-paste.js +288 -0
- package/dist/tui-opentui/input-box.d.ts +34 -0
- package/dist/tui-opentui/input-box.js +471 -0
- package/dist/tui-opentui/input-history.d.ts +16 -0
- package/dist/tui-opentui/input-history.js +79 -0
- package/dist/tui-opentui/markdown.d.ts +66 -0
- package/dist/tui-opentui/markdown.js +127 -0
- package/dist/tui-opentui/message-list.d.ts +31 -0
- package/dist/tui-opentui/message-list.js +128 -0
- package/dist/tui-opentui/model-picker.d.ts +63 -0
- package/dist/tui-opentui/model-picker.js +450 -0
- package/dist/tui-opentui/plan-confirm.d.ts +9 -0
- package/dist/tui-opentui/plan-confirm.js +124 -0
- package/dist/tui-opentui/question-dialog.d.ts +10 -0
- package/dist/tui-opentui/question-dialog.js +110 -0
- package/dist/tui-opentui/recent-activity.d.ts +8 -0
- package/dist/tui-opentui/recent-activity.js +71 -0
- package/dist/tui-opentui/run-session-picker.d.ts +10 -0
- package/dist/tui-opentui/run-session-picker.js +28 -0
- package/dist/tui-opentui/run.d.ts +38 -0
- package/dist/tui-opentui/run.js +48 -0
- package/dist/tui-opentui/session-picker.d.ts +12 -0
- package/dist/tui-opentui/session-picker.js +120 -0
- package/dist/tui-opentui/theme.d.ts +89 -0
- package/dist/tui-opentui/theme.js +157 -0
- package/dist/tui-opentui/todos.d.ts +9 -0
- package/dist/tui-opentui/todos.js +45 -0
- package/dist/tui-opentui/trace-groups.d.ts +27 -0
- package/dist/tui-opentui/trace-groups.js +419 -0
- package/dist/tui-opentui/use-terminal-size.d.ts +4 -0
- package/dist/tui-opentui/use-terminal-size.js +5 -0
- package/dist/tui-opentui/welcome.d.ts +25 -0
- package/dist/tui-opentui/welcome.js +77 -0
- package/dist/types.d.ts +36 -2
- package/package.json +5 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function defaultHistoryFilePath(): string;
|
|
2
|
+
export declare function loadHistorySync(filePath?: string): string[];
|
|
3
|
+
export declare function appendHistoryEntry(entry: string, filePath?: string): void;
|
|
4
|
+
export interface HistoryNavState {
|
|
5
|
+
history: string[];
|
|
6
|
+
index: number | null;
|
|
7
|
+
draft: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HistoryNavResult {
|
|
10
|
+
text: string;
|
|
11
|
+
index: number | null;
|
|
12
|
+
draft: string;
|
|
13
|
+
changed: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function stepHistory(state: HistoryNavState, direction: "up" | "down", currentText: string): HistoryNavResult;
|
|
16
|
+
export declare function pushHistoryEntry(history: string[], entry: string): string[];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { getBubbleHome } from "../bubble-home.js";
|
|
4
|
+
const MAX_HISTORY_ENTRIES = 1000;
|
|
5
|
+
export function defaultHistoryFilePath() {
|
|
6
|
+
return join(getBubbleHome(), "input-history.jsonl");
|
|
7
|
+
}
|
|
8
|
+
// JSONL on disk: each line is a JSON-encoded string. JSON encoding handles
|
|
9
|
+
// embedded newlines and quotes so multi-line composer entries round-trip safely.
|
|
10
|
+
export function loadHistorySync(filePath = defaultHistoryFilePath()) {
|
|
11
|
+
try {
|
|
12
|
+
if (!existsSync(filePath))
|
|
13
|
+
return [];
|
|
14
|
+
const raw = readFileSync(filePath, "utf8");
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const line of raw.split("\n")) {
|
|
17
|
+
if (!line)
|
|
18
|
+
continue;
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse(line);
|
|
21
|
+
if (typeof parsed === "string" && parsed.length > 0)
|
|
22
|
+
out.push(parsed);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Malformed line - skip rather than fail the whole load.
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return out.length > MAX_HISTORY_ENTRIES ? out.slice(-MAX_HISTORY_ENTRIES) : out;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function appendHistoryEntry(entry, filePath = defaultHistoryFilePath()) {
|
|
35
|
+
if (!entry || entry.trim().length === 0)
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
39
|
+
appendFileSync(filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Persistence is best-effort; never crash the composer over disk IO.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// Pure transition for up/down navigation. `index === null` means the user is
|
|
46
|
+
// editing a fresh draft; otherwise it points at history[index]. When stepping
|
|
47
|
+
// from the draft into history we snapshot the current text so down past the
|
|
48
|
+
// newest entry can restore it.
|
|
49
|
+
export function stepHistory(state, direction, currentText) {
|
|
50
|
+
const { history, index, draft } = state;
|
|
51
|
+
const noChange = { text: currentText, index, draft, changed: false };
|
|
52
|
+
if (direction === "up") {
|
|
53
|
+
if (history.length === 0)
|
|
54
|
+
return noChange;
|
|
55
|
+
if (index === null) {
|
|
56
|
+
const newIdx = history.length - 1;
|
|
57
|
+
return { text: history[newIdx], index: newIdx, draft: currentText, changed: true };
|
|
58
|
+
}
|
|
59
|
+
if (index > 0) {
|
|
60
|
+
return { text: history[index - 1], index: index - 1, draft, changed: true };
|
|
61
|
+
}
|
|
62
|
+
return noChange;
|
|
63
|
+
}
|
|
64
|
+
if (index === null)
|
|
65
|
+
return noChange;
|
|
66
|
+
if (index < history.length - 1) {
|
|
67
|
+
return { text: history[index + 1], index: index + 1, draft, changed: true };
|
|
68
|
+
}
|
|
69
|
+
return { text: draft, index: null, draft: "", changed: true };
|
|
70
|
+
}
|
|
71
|
+
// Push to in-memory history with last-entry dedupe so repeated identical
|
|
72
|
+
// submissions don't spam the stack.
|
|
73
|
+
export function pushHistoryEntry(history, entry) {
|
|
74
|
+
if (!entry || entry.trim().length === 0)
|
|
75
|
+
return history;
|
|
76
|
+
if (history.length > 0 && history[history.length - 1] === entry)
|
|
77
|
+
return history;
|
|
78
|
+
return [...history, entry];
|
|
79
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface MarkdownInlineSegment {
|
|
2
|
+
text: string;
|
|
3
|
+
color?: "text" | "textMuted" | "success" | "warning" | "secondary";
|
|
4
|
+
bold?: boolean;
|
|
5
|
+
italic?: boolean;
|
|
6
|
+
dim?: boolean;
|
|
7
|
+
}
|
|
8
|
+
type InlineToken = {
|
|
9
|
+
type?: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
raw?: string;
|
|
12
|
+
href?: string;
|
|
13
|
+
tokens?: InlineToken[];
|
|
14
|
+
};
|
|
15
|
+
interface InlineStyle {
|
|
16
|
+
bold?: boolean;
|
|
17
|
+
italic?: boolean;
|
|
18
|
+
dim?: boolean;
|
|
19
|
+
color?: MarkdownInlineSegment["color"];
|
|
20
|
+
}
|
|
21
|
+
export declare function markdownInlineSegments(tokens: InlineToken[] | undefined, fallback?: string, style?: InlineStyle): MarkdownInlineSegment[];
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export function markdownInlineSegments(tokens, fallback = "", style = {}) {
|
|
2
|
+
const segments = [];
|
|
3
|
+
for (const token of tokens ?? []) {
|
|
4
|
+
appendInlineToken(segments, token, style);
|
|
5
|
+
}
|
|
6
|
+
if (segments.length === 0 && fallback) {
|
|
7
|
+
appendStyled(segments, fallback, style);
|
|
8
|
+
}
|
|
9
|
+
return segments;
|
|
10
|
+
}
|
|
11
|
+
function appendInlineToken(segments, token, style) {
|
|
12
|
+
switch (token.type) {
|
|
13
|
+
case "strong":
|
|
14
|
+
appendInlineTokens(segments, token.tokens, { ...style, bold: true });
|
|
15
|
+
return;
|
|
16
|
+
case "em":
|
|
17
|
+
appendInlineTokens(segments, token.tokens, { ...style, italic: true, color: style.color ?? "warning" });
|
|
18
|
+
return;
|
|
19
|
+
case "del":
|
|
20
|
+
appendInlineTokens(segments, token.tokens, { ...style, dim: true, color: style.color ?? "textMuted" });
|
|
21
|
+
return;
|
|
22
|
+
case "codespan":
|
|
23
|
+
appendStyled(segments, token.text ?? "", { ...style, color: "success" });
|
|
24
|
+
return;
|
|
25
|
+
case "link":
|
|
26
|
+
appendInlineTokens(segments, token.tokens, { ...style, color: style.color ?? "secondary" });
|
|
27
|
+
return;
|
|
28
|
+
case "br":
|
|
29
|
+
appendStyled(segments, "\n", style);
|
|
30
|
+
return;
|
|
31
|
+
case "text":
|
|
32
|
+
case "paragraph":
|
|
33
|
+
case "list_item":
|
|
34
|
+
case "heading":
|
|
35
|
+
if (token.tokens?.length) {
|
|
36
|
+
appendInlineTokens(segments, token.tokens, style);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
appendStyled(segments, token.text ?? token.raw ?? "", style);
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
case "space":
|
|
43
|
+
return;
|
|
44
|
+
default:
|
|
45
|
+
if (token.tokens?.length) {
|
|
46
|
+
appendInlineTokens(segments, token.tokens, style);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
appendStyled(segments, token.text ?? token.raw ?? "", style);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function appendInlineTokens(segments, tokens, style) {
|
|
54
|
+
for (const child of tokens ?? []) {
|
|
55
|
+
appendInlineToken(segments, child, style);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function appendStyled(segments, text, style) {
|
|
59
|
+
if (!text)
|
|
60
|
+
return;
|
|
61
|
+
segments.push({
|
|
62
|
+
text,
|
|
63
|
+
color: style.color ?? "text",
|
|
64
|
+
bold: style.bold,
|
|
65
|
+
italic: style.italic,
|
|
66
|
+
dim: style.dim,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface MarkdownThemePalette {
|
|
2
|
+
text: string;
|
|
3
|
+
textMuted: string;
|
|
4
|
+
background: string;
|
|
5
|
+
secondary: string;
|
|
6
|
+
info: string;
|
|
7
|
+
success: string;
|
|
8
|
+
warning: string;
|
|
9
|
+
accent: string;
|
|
10
|
+
error: string;
|
|
11
|
+
}
|
|
12
|
+
export interface SyntaxThemeRule {
|
|
13
|
+
scope: string[];
|
|
14
|
+
style: {
|
|
15
|
+
foreground?: string;
|
|
16
|
+
background?: string;
|
|
17
|
+
bold?: boolean;
|
|
18
|
+
italic?: boolean;
|
|
19
|
+
underline?: boolean;
|
|
20
|
+
dim?: boolean;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export declare function buildMarkdownThemeRules(theme: MarkdownThemePalette): SyntaxThemeRule[];
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
export function buildMarkdownThemeRules(theme) {
|
|
2
|
+
return [
|
|
3
|
+
{
|
|
4
|
+
scope: ["default"],
|
|
5
|
+
style: {
|
|
6
|
+
foreground: theme.text,
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
scope: ["comment", "comment.documentation"],
|
|
11
|
+
style: {
|
|
12
|
+
foreground: theme.textMuted,
|
|
13
|
+
italic: true,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
scope: ["string", "symbol", "character", "character.special", "string.escape"],
|
|
18
|
+
style: {
|
|
19
|
+
foreground: theme.success,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
scope: ["number", "boolean", "constant", "float"],
|
|
24
|
+
style: {
|
|
25
|
+
foreground: theme.warning,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
scope: [
|
|
30
|
+
"keyword",
|
|
31
|
+
"keyword.import",
|
|
32
|
+
"keyword.return",
|
|
33
|
+
"keyword.conditional",
|
|
34
|
+
"keyword.repeat",
|
|
35
|
+
"keyword.coroutine",
|
|
36
|
+
"keyword.directive",
|
|
37
|
+
"keyword.modifier",
|
|
38
|
+
"keyword.exception",
|
|
39
|
+
"string.regexp",
|
|
40
|
+
],
|
|
41
|
+
style: {
|
|
42
|
+
foreground: theme.accent,
|
|
43
|
+
italic: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
scope: ["keyword.type", "type", "class", "module"],
|
|
48
|
+
style: {
|
|
49
|
+
foreground: theme.info,
|
|
50
|
+
bold: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
scope: ["function", "function.call", "function.method", "function.method.call", "constructor"],
|
|
55
|
+
style: {
|
|
56
|
+
foreground: theme.secondary,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
scope: ["variable", "variable.parameter", "variable.member", "property", "parameter"],
|
|
61
|
+
style: {
|
|
62
|
+
foreground: theme.text,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
scope: ["operator", "keyword.operator", "punctuation.delimiter", "punctuation.special"],
|
|
67
|
+
style: {
|
|
68
|
+
foreground: theme.info,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
scope: ["punctuation", "punctuation.bracket"],
|
|
73
|
+
style: {
|
|
74
|
+
foreground: theme.text,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
scope: ["variable.builtin", "type.builtin", "function.builtin", "module.builtin", "constant.builtin", "variable.super"],
|
|
79
|
+
style: {
|
|
80
|
+
foreground: theme.error,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
scope: ["markup.heading", "markup.heading.1", "markup.heading.2", "markup.heading.3", "markup.heading.4", "markup.heading.5", "markup.heading.6"],
|
|
85
|
+
style: {
|
|
86
|
+
foreground: theme.text,
|
|
87
|
+
bold: true,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
scope: ["markup.bold", "markup.strong"],
|
|
92
|
+
style: {
|
|
93
|
+
foreground: theme.text,
|
|
94
|
+
bold: true,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
scope: ["markup.italic"],
|
|
99
|
+
style: {
|
|
100
|
+
foreground: theme.warning,
|
|
101
|
+
italic: true,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
scope: ["markup.strikethrough"],
|
|
106
|
+
style: {
|
|
107
|
+
foreground: theme.textMuted,
|
|
108
|
+
dim: true,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
scope: ["markup.list"],
|
|
113
|
+
style: {
|
|
114
|
+
foreground: theme.secondary,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
scope: ["markup.quote"],
|
|
119
|
+
style: {
|
|
120
|
+
foreground: theme.warning,
|
|
121
|
+
italic: true,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
scope: ["markup.raw", "markup.raw.block"],
|
|
126
|
+
style: {
|
|
127
|
+
foreground: theme.success,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
scope: ["markup.raw.inline"],
|
|
132
|
+
style: {
|
|
133
|
+
foreground: theme.success,
|
|
134
|
+
background: theme.background,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
scope: ["markup.link", "markup.link.url", "string.special.url"],
|
|
139
|
+
style: {
|
|
140
|
+
foreground: theme.secondary,
|
|
141
|
+
underline: true,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
scope: ["markup.link.label", "label"],
|
|
146
|
+
style: {
|
|
147
|
+
foreground: theme.info,
|
|
148
|
+
underline: true,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
scope: ["spell", "nospell"],
|
|
153
|
+
style: {
|
|
154
|
+
foreground: theme.text,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
scope: ["conceal"],
|
|
159
|
+
style: {
|
|
160
|
+
foreground: theme.textMuted,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
];
|
|
164
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SyntaxStyle } from "@opentui/core";
|
|
2
|
+
import { type MarkdownThemePalette } from "./markdown-theme-rules.js";
|
|
3
|
+
export type { MarkdownThemePalette } from "./markdown-theme-rules.js";
|
|
4
|
+
export declare function createMarkdownSyntaxStyle(theme: MarkdownThemePalette): SyntaxStyle;
|
|
5
|
+
export declare function createSubtleMarkdownSyntaxStyle(theme: MarkdownThemePalette, opacity?: number): SyntaxStyle;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SyntaxStyle } from "@opentui/core";
|
|
2
|
+
import { buildMarkdownThemeRules } from "./markdown-theme-rules.js";
|
|
3
|
+
export function createMarkdownSyntaxStyle(theme) {
|
|
4
|
+
return SyntaxStyle.fromTheme(buildMarkdownThemeRules(theme));
|
|
5
|
+
}
|
|
6
|
+
export function createSubtleMarkdownSyntaxStyle(theme, opacity = 0.6) {
|
|
7
|
+
const alpha = Math.max(0, Math.min(1, opacity));
|
|
8
|
+
return SyntaxStyle.fromTheme(buildMarkdownThemeRules(theme).map((rule) => ({
|
|
9
|
+
...rule,
|
|
10
|
+
style: {
|
|
11
|
+
...rule.style,
|
|
12
|
+
foreground: rule.style.foreground
|
|
13
|
+
? applyAlpha(rule.style.foreground, alpha)
|
|
14
|
+
: rule.style.foreground,
|
|
15
|
+
},
|
|
16
|
+
})));
|
|
17
|
+
}
|
|
18
|
+
function applyAlpha(color, opacity) {
|
|
19
|
+
if (!color.startsWith("#"))
|
|
20
|
+
return color;
|
|
21
|
+
const hex = color.slice(1);
|
|
22
|
+
if (hex.length !== 6 && hex.length !== 8)
|
|
23
|
+
return color;
|
|
24
|
+
const rgb = hex.slice(0, 6);
|
|
25
|
+
const alpha = Math.round(opacity * 255).toString(16).padStart(2, "0");
|
|
26
|
+
return `#${rgb}${alpha}`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ModelInfo, type ProviderProfile, type ProviderRegistry } from "../provider-registry.js";
|
|
2
|
+
type ModelPickerRegistry = Pick<ProviderRegistry, "getEnabled" | "getModelConfig" | "listModels">;
|
|
3
|
+
export type ModelProviderGroup = {
|
|
4
|
+
provider: ProviderProfile;
|
|
5
|
+
models: ModelInfo[];
|
|
6
|
+
};
|
|
7
|
+
export declare function localModelsForProvider(registry: Pick<ProviderRegistry, "getModelConfig">, provider: ProviderProfile): ModelInfo[];
|
|
8
|
+
export declare function getVisibleModelProviders(registry: Pick<ProviderRegistry, "getEnabled">, providerId?: string): ProviderProfile[];
|
|
9
|
+
export declare function discoverModelProviderGroups(registry: ModelPickerRegistry, providerId?: string): Promise<ModelProviderGroup[]>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { listBuiltinModels } from "../model-catalog.js";
|
|
2
|
+
import { isUserVisibleProvider, } from "../provider-registry.js";
|
|
3
|
+
export function localModelsForProvider(registry, provider) {
|
|
4
|
+
const customModels = registry.getModelConfig().getCustomModels(provider.id);
|
|
5
|
+
if (customModels.length > 0)
|
|
6
|
+
return customModels;
|
|
7
|
+
const builtinProviderId = provider.id === "openai" && provider.authType === "oauth"
|
|
8
|
+
? "openai-codex"
|
|
9
|
+
: provider.id;
|
|
10
|
+
return listBuiltinModels(builtinProviderId).map((model) => ({
|
|
11
|
+
id: model.id,
|
|
12
|
+
name: model.name,
|
|
13
|
+
providerId: provider.id,
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
export function getVisibleModelProviders(registry, providerId) {
|
|
17
|
+
return registry
|
|
18
|
+
.getEnabled()
|
|
19
|
+
.filter((provider) => isUserVisibleProvider(provider.id))
|
|
20
|
+
.filter((provider) => !providerId || provider.id === providerId);
|
|
21
|
+
}
|
|
22
|
+
export async function discoverModelProviderGroups(registry, providerId) {
|
|
23
|
+
const providers = getVisibleModelProviders(registry, providerId);
|
|
24
|
+
return Promise.all(providers.map(async (provider) => {
|
|
25
|
+
try {
|
|
26
|
+
return { provider, models: await registry.listModels(provider) };
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return { provider, models: localModelsForProvider(registry, provider) };
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ColorInput } from "@opentui/core";
|
|
2
|
+
import { RGBA } from "@opentui/core";
|
|
3
|
+
type ColorGenerator = (frameIndex: number, charIndex: number, totalFrames: number, totalChars: number) => ColorInput;
|
|
4
|
+
export declare function deriveTrailColors(brightColor: ColorInput, steps?: number): RGBA[];
|
|
5
|
+
export declare function deriveInactiveColor(brightColor: ColorInput, factor?: number): RGBA;
|
|
6
|
+
export type KnightRiderStyle = "blocks" | "diamonds";
|
|
7
|
+
export interface KnightRiderOptions {
|
|
8
|
+
width?: number;
|
|
9
|
+
style?: KnightRiderStyle;
|
|
10
|
+
holdStart?: number;
|
|
11
|
+
holdEnd?: number;
|
|
12
|
+
colors?: ColorInput[];
|
|
13
|
+
color?: ColorInput;
|
|
14
|
+
trailSteps?: number;
|
|
15
|
+
defaultColor?: ColorInput;
|
|
16
|
+
inactiveFactor?: number;
|
|
17
|
+
enableFading?: boolean;
|
|
18
|
+
minAlpha?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function createFrames(options?: KnightRiderOptions): string[];
|
|
21
|
+
export declare function createColors(options?: KnightRiderOptions): ColorGenerator;
|
|
22
|
+
export {};
|