bioscode 0.1.5
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/LICENSE +306 -0
- package/NOTICE +45 -0
- package/README.md +277 -0
- package/dist/auth/index.d.ts +202 -0
- package/dist/brand/index.d.ts +7 -0
- package/dist/brand/loader.d.ts +463 -0
- package/dist/brand/rules.d.ts +25 -0
- package/dist/brand/schema.d.ts +246 -0
- package/dist/bus/bus-event.d.ts +10 -0
- package/dist/bus/global.d.ts +7 -0
- package/dist/bus/index.d.ts +26 -0
- package/dist/cli/auth.d.ts +23 -0
- package/dist/cli/brand.d.ts +6 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/ui.d.ts +26 -0
- package/dist/command/index.d.ts +54 -0
- package/dist/config/config.d.ts +6036 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/markdown.d.ts +415 -0
- package/dist/constants/index.d.ts +6 -0
- package/dist/constants/version.d.ts +5 -0
- package/dist/diff/engine.d.ts +15 -0
- package/dist/diff/index.d.ts +8 -0
- package/dist/diff/types.d.ts +66 -0
- package/dist/file/ignore.d.ts +7 -0
- package/dist/flag/index.d.ts +19 -0
- package/dist/gateway/bridge.d.ts +11 -0
- package/dist/gateway/handlers/llm.d.ts +7 -0
- package/dist/gateway/handlers/permission.d.ts +15 -0
- package/dist/gateway/handlers/session.d.ts +7 -0
- package/dist/gateway/handlers/system.d.ts +7 -0
- package/dist/gateway/handlers/tool.d.ts +7 -0
- package/dist/gateway/index.d.ts +18 -0
- package/dist/gateway/protocol.d.ts +159 -0
- package/dist/gateway/router.d.ts +7 -0
- package/dist/gateway/server.d.ts +24 -0
- package/dist/global/index.d.ts +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -0
- package/dist/permission/index.d.ts +2 -0
- package/dist/permission/permission.d.ts +172 -0
- package/dist/permission/types.d.ts +109 -0
- package/dist/project/index.d.ts +3 -0
- package/dist/project/instance.d.ts +33 -0
- package/dist/project/project.d.ts +82 -0
- package/dist/project/state.d.ts +4 -0
- package/dist/prompt/index.d.ts +5 -0
- package/dist/prompt/system.d.ts +29 -0
- package/dist/prompt/template.d.ts +24 -0
- package/dist/provider/index.d.ts +3 -0
- package/dist/provider/models.d.ts +14 -0
- package/dist/provider/provider.d.ts +848 -0
- package/dist/provider/types.d.ts +328 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/routes/api.d.ts +2 -0
- package/dist/server/routes/auth.d.ts +2 -0
- package/dist/server/routes/events.d.ts +2 -0
- package/dist/server/routes/health.d.ts +2 -0
- package/dist/server/routes/sessions.d.ts +2 -0
- package/dist/server/services/agent.d.ts +40 -0
- package/dist/server/services/permission.d.ts +43 -0
- package/dist/server/sse/emitter.d.ts +57 -0
- package/dist/session/context-cache.d.ts +75 -0
- package/dist/session/context-optimization.d.ts +165 -0
- package/dist/session/index.d.ts +5 -0
- package/dist/session/llm.d.ts +68 -0
- package/dist/session/message-optimizer.d.ts +32 -0
- package/dist/session/session.d.ts +524 -0
- package/dist/session/title-generator.d.ts +11 -0
- package/dist/session/types.d.ts +713 -0
- package/dist/snapshot/index.d.ts +40 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/storage.d.ts +34 -0
- package/dist/theme.d.ts +64 -0
- package/dist/tool/bash.d.ts +19 -0
- package/dist/tool/edit.d.ts +21 -0
- package/dist/tool/glob.d.ts +15 -0
- package/dist/tool/grep.d.ts +20 -0
- package/dist/tool/image.d.ts +22 -0
- package/dist/tool/index.d.ts +11 -0
- package/dist/tool/ls.d.ts +14 -0
- package/dist/tool/read.d.ts +17 -0
- package/dist/tool/registry.d.ts +30 -0
- package/dist/tool/think.d.ts +11 -0
- package/dist/tool/todo.d.ts +76 -0
- package/dist/tool/tool.d.ts +65 -0
- package/dist/tool/webfetch.d.ts +15 -0
- package/dist/tool/write.d.ts +16 -0
- package/dist/tui/App.d.ts +10 -0
- package/dist/tui/components/Header.d.ts +13 -0
- package/dist/tui/components/LoadingIndicator.d.ts +26 -0
- package/dist/tui/components/Message/AssistantMessage.d.ts +11 -0
- package/dist/tui/components/Message/ReasoningMessage.d.ts +21 -0
- package/dist/tui/components/Message/ToolCallMessage.d.ts +26 -0
- package/dist/tui/components/Message/UserMessage.d.ts +12 -0
- package/dist/tui/components/Message/index.d.ts +16 -0
- package/dist/tui/components/PermissionPrompt.d.ts +6 -0
- package/dist/tui/components/PromptInput.d.ts +33 -0
- package/dist/tui/components/REPL.d.ts +22 -0
- package/dist/tui/components/Spinner.d.ts +13 -0
- package/dist/tui/components/StatusBar.d.ts +13 -0
- package/dist/tui/components/TodoList.d.ts +17 -0
- package/dist/tui/components/WelcomeBox.d.ts +13 -0
- package/dist/tui/components/dialogs/DiagnosticsPanel.d.ts +12 -0
- package/dist/tui/components/dialogs/HelpPanel.d.ts +11 -0
- package/dist/tui/components/dialogs/ModelSelector.d.ts +14 -0
- package/dist/tui/components/dialogs/PermissionPrompt.d.ts +17 -0
- package/dist/tui/components/dialogs/SessionPicker.d.ts +20 -0
- package/dist/tui/components/dialogs/index.d.ts +10 -0
- package/dist/tui/components/diff/DiffHunk.d.ts +12 -0
- package/dist/tui/components/diff/DiffLine.d.ts +14 -0
- package/dist/tui/components/diff/DiffStats.d.ts +12 -0
- package/dist/tui/components/diff/DiffView.d.ts +15 -0
- package/dist/tui/components/diff/index.d.ts +9 -0
- package/dist/tui/hooks/useAnimatedLabel.d.ts +12 -0
- package/dist/tui/hooks/usePermission.d.ts +34 -0
- package/dist/tui/hooks/useTermWidth.d.ts +13 -0
- package/dist/tui/index.d.ts +20 -0
- package/dist/tui/theme.d.ts +8 -0
- package/dist/tui/utils/Cursor.d.ts +37 -0
- package/dist/tui/utils/clipboard.d.ts +3 -0
- package/dist/tui/utils/keypress.d.ts +39 -0
- package/dist/tui/utils/markdown.d.ts +13 -0
- package/dist/tui/utils/openContent.d.ts +22 -0
- package/dist/util/ascii.d.ts +22 -0
- package/dist/util/bell.d.ts +14 -0
- package/dist/util/color.d.ts +28 -0
- package/dist/util/context.d.ts +10 -0
- package/dist/util/debug.d.ts +51 -0
- package/dist/util/error.d.ts +294 -0
- package/dist/util/example-commands.d.ts +18 -0
- package/dist/util/filesystem.d.ts +17 -0
- package/dist/util/id.d.ts +24 -0
- package/dist/util/iife.d.ts +1 -0
- package/dist/util/index.d.ts +7 -0
- package/dist/util/lazy.d.ts +1 -0
- package/dist/util/log.d.ts +26 -0
- package/dist/util/paths.d.ts +45 -0
- package/dist/util/shell.d.ts +36 -0
- package/dist/util/timeout.d.ts +1 -0
- package/dist/util/wildcard.d.ts +8 -0
- package/package.json +87 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare namespace Snapshot {
|
|
3
|
+
function track(): Promise<string | undefined>;
|
|
4
|
+
const Patch: z.ZodObject<{
|
|
5
|
+
hash: z.ZodString;
|
|
6
|
+
files: z.ZodArray<z.ZodString, "many">;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
hash: string;
|
|
9
|
+
files: string[];
|
|
10
|
+
}, {
|
|
11
|
+
hash: string;
|
|
12
|
+
files: string[];
|
|
13
|
+
}>;
|
|
14
|
+
type Patch = z.infer<typeof Patch>;
|
|
15
|
+
function patch(hash: string): Promise<Patch>;
|
|
16
|
+
function restore(snapshot: string): Promise<void>;
|
|
17
|
+
function revert(patches: Patch[]): Promise<void>;
|
|
18
|
+
function diff(hash: string): Promise<string>;
|
|
19
|
+
const FileDiff: z.ZodObject<{
|
|
20
|
+
file: z.ZodString;
|
|
21
|
+
before: z.ZodString;
|
|
22
|
+
after: z.ZodString;
|
|
23
|
+
additions: z.ZodNumber;
|
|
24
|
+
deletions: z.ZodNumber;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
file: string;
|
|
27
|
+
before: string;
|
|
28
|
+
after: string;
|
|
29
|
+
additions: number;
|
|
30
|
+
deletions: number;
|
|
31
|
+
}, {
|
|
32
|
+
file: string;
|
|
33
|
+
before: string;
|
|
34
|
+
after: string;
|
|
35
|
+
additions: number;
|
|
36
|
+
deletions: number;
|
|
37
|
+
}>;
|
|
38
|
+
type FileDiff = z.infer<typeof FileDiff>;
|
|
39
|
+
function diffFull(from: string, to: string): Promise<FileDiff[]>;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Storage } from "./storage";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare namespace Storage {
|
|
2
|
+
/**
|
|
3
|
+
* Write data to storage
|
|
4
|
+
*/
|
|
5
|
+
function write<T>(key: string[], data: T): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Read data from storage
|
|
8
|
+
*/
|
|
9
|
+
function read<T>(key: string[]): Promise<T | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Update data in storage using an editor function
|
|
12
|
+
*/
|
|
13
|
+
function update<T>(key: string[], editor: (data: T) => void): Promise<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a key exists
|
|
16
|
+
*/
|
|
17
|
+
function exists(key: string[]): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Remove data from storage
|
|
20
|
+
*/
|
|
21
|
+
function remove(key: string[]): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* List all keys under a prefix
|
|
24
|
+
*/
|
|
25
|
+
function list(prefix: string[]): Promise<string[][]>;
|
|
26
|
+
/**
|
|
27
|
+
* List subdirectories under a prefix
|
|
28
|
+
*/
|
|
29
|
+
function listDirs(prefix: string[]): Promise<string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Clear all data under a prefix
|
|
32
|
+
*/
|
|
33
|
+
function clear(prefix: string[]): Promise<void>;
|
|
34
|
+
}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme & Brand Configuration
|
|
3
|
+
*
|
|
4
|
+
* This file contains all branding and theming configuration for the application.
|
|
5
|
+
* To customize the brand/theme, modify the values in this file directly.
|
|
6
|
+
*
|
|
7
|
+
* For a complete rebrand, you'll also need to update:
|
|
8
|
+
* - package.json: Change the "bin" field to match your command name
|
|
9
|
+
*/
|
|
10
|
+
/** Product display name shown in UI and messages */
|
|
11
|
+
export declare const PRODUCT_NAME = "Bioscode";
|
|
12
|
+
/** CLI command name (lowercase, alphanumeric with hyphens) */
|
|
13
|
+
export declare const PRODUCT_COMMAND = "bioscode";
|
|
14
|
+
/** Configuration directory name (hidden folder in project/home) */
|
|
15
|
+
export declare const CONFIG_DIR = ".bioscode";
|
|
16
|
+
/** Configuration file name */
|
|
17
|
+
export declare const CONFIG_FILE = "bioscode.jsonc";
|
|
18
|
+
/** Rules/instructions file name */
|
|
19
|
+
export declare const RULES_FILE = "BIOSCODE.md";
|
|
20
|
+
/** Environment variable prefix */
|
|
21
|
+
export declare const ENV_PREFIX = "BIOSCODE_";
|
|
22
|
+
/** Simple logo for compact spaces (e.g., welcome screen) */
|
|
23
|
+
export declare const LOGO_SIMPLE: string[];
|
|
24
|
+
/** Extended logo for larger displays (e.g., CLI mode) */
|
|
25
|
+
export declare const LOGO_EXTENDED: string[];
|
|
26
|
+
/** ASCII-only logo (fallback for terminals without UTF-8 support) */
|
|
27
|
+
export declare const LOGO_ASCII: string[];
|
|
28
|
+
/** Local rule files searched in project directories */
|
|
29
|
+
export declare const LOCAL_RULE_FILES: readonly ["BIOSCODE.md", "AGENTS.md", "CONTEXT.md"];
|
|
30
|
+
/** Global rule files searched in home directory */
|
|
31
|
+
export declare const GLOBAL_RULE_FILES: readonly ["BIOSCODE.md"];
|
|
32
|
+
/** Default theme name */
|
|
33
|
+
export declare const DEFAULT_THEME = "bios";
|
|
34
|
+
/** Primary brand color (used for logo, highlights, etc.) */
|
|
35
|
+
export declare const PRIMARY_COLOR = "#01b02aff";
|
|
36
|
+
/** Theme interface definition */
|
|
37
|
+
export interface Theme {
|
|
38
|
+
name: string;
|
|
39
|
+
background: string;
|
|
40
|
+
foreground: string;
|
|
41
|
+
text: string;
|
|
42
|
+
primary: string;
|
|
43
|
+
secondary: string;
|
|
44
|
+
success: string;
|
|
45
|
+
warning: string;
|
|
46
|
+
error: string;
|
|
47
|
+
muted: string;
|
|
48
|
+
border: string;
|
|
49
|
+
selection: string;
|
|
50
|
+
diffAdd: string;
|
|
51
|
+
diffRemove: string;
|
|
52
|
+
diffContext: string;
|
|
53
|
+
diffHunkHeader: string;
|
|
54
|
+
}
|
|
55
|
+
/** Available themes */
|
|
56
|
+
export declare const themes: Record<string, Theme>;
|
|
57
|
+
/** Get the current active theme */
|
|
58
|
+
export declare function getTheme(): Theme;
|
|
59
|
+
/** Set the active theme by name */
|
|
60
|
+
export declare function setTheme(name: string): void;
|
|
61
|
+
/** Get all available theme names */
|
|
62
|
+
export declare function getThemeNames(): string[];
|
|
63
|
+
/** Initialize theme (can be called at startup) */
|
|
64
|
+
export declare function initTheme(themeName?: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const BashTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
command: z.ZodString;
|
|
5
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
workdir: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
command: string;
|
|
9
|
+
timeout?: number | undefined;
|
|
10
|
+
workdir?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
command: string;
|
|
13
|
+
timeout?: number | undefined;
|
|
14
|
+
workdir?: string | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
exitCode: number;
|
|
17
|
+
preview: string;
|
|
18
|
+
error: string | undefined;
|
|
19
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const EditTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
filePath: z.ZodString;
|
|
5
|
+
oldString: z.ZodString;
|
|
6
|
+
newString: z.ZodString;
|
|
7
|
+
replaceAll: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
replaceAll: boolean;
|
|
10
|
+
filePath: string;
|
|
11
|
+
oldString: string;
|
|
12
|
+
newString: string;
|
|
13
|
+
}, {
|
|
14
|
+
filePath: string;
|
|
15
|
+
oldString: string;
|
|
16
|
+
newString: string;
|
|
17
|
+
replaceAll?: boolean | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
action: string;
|
|
20
|
+
replacements: number;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const GlobTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
pattern: z.ZodString;
|
|
5
|
+
path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
pattern: string;
|
|
8
|
+
path?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
pattern: string;
|
|
11
|
+
path?: string | undefined;
|
|
12
|
+
}>, {
|
|
13
|
+
count: number;
|
|
14
|
+
truncated: boolean;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const GrepTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
pattern: z.ZodString;
|
|
5
|
+
path: z.ZodOptional<z.ZodString>;
|
|
6
|
+
glob: z.ZodOptional<z.ZodString>;
|
|
7
|
+
output_mode: z.ZodOptional<z.ZodEnum<["content", "files_with_matches", "count"]>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
pattern: string;
|
|
10
|
+
path?: string | undefined;
|
|
11
|
+
glob?: string | undefined;
|
|
12
|
+
output_mode?: "content" | "count" | "files_with_matches" | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
pattern: string;
|
|
15
|
+
path?: string | undefined;
|
|
16
|
+
glob?: string | undefined;
|
|
17
|
+
output_mode?: "content" | "count" | "files_with_matches" | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
count: number;
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const ImageTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
prompt: z.ZodString;
|
|
5
|
+
filename: z.ZodString;
|
|
6
|
+
directory: z.ZodOptional<z.ZodString>;
|
|
7
|
+
aspectRatio: z.ZodOptional<z.ZodEnum<["1:1", "16:9", "9:16", "4:3", "3:4"]>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
filename: string;
|
|
10
|
+
prompt: string;
|
|
11
|
+
directory?: string | undefined;
|
|
12
|
+
aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
filename: string;
|
|
15
|
+
prompt: string;
|
|
16
|
+
directory?: string | undefined;
|
|
17
|
+
aspectRatio?: "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | undefined;
|
|
18
|
+
}>, {
|
|
19
|
+
path: string;
|
|
20
|
+
size: number;
|
|
21
|
+
duration: string;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { Tool } from "./tool";
|
|
2
|
+
export { ToolRegistry } from "./registry";
|
|
3
|
+
export { ReadTool } from "./read";
|
|
4
|
+
export { GlobTool } from "./glob";
|
|
5
|
+
export { GrepTool } from "./grep";
|
|
6
|
+
export { BashTool } from "./bash";
|
|
7
|
+
export { WriteTool } from "./write";
|
|
8
|
+
export { EditTool } from "./edit";
|
|
9
|
+
export { LsTool } from "./ls";
|
|
10
|
+
export { TodoTool, TodoEvent, getTodos, clearTodos, type TodoItem } from "./todo";
|
|
11
|
+
export { ImageTool } from "./image";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const LsTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
path: z.ZodOptional<z.ZodString>;
|
|
5
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
path?: string | undefined;
|
|
8
|
+
depth?: number | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
path?: string | undefined;
|
|
11
|
+
depth?: number | undefined;
|
|
12
|
+
}>, {
|
|
13
|
+
count: number;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const ReadTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
filePath: z.ZodString;
|
|
5
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
filePath: string;
|
|
9
|
+
offset?: number | undefined;
|
|
10
|
+
limit?: number | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
filePath: string;
|
|
13
|
+
offset?: number | undefined;
|
|
14
|
+
limit?: number | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
preview: string;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Tool } from "./tool";
|
|
2
|
+
export declare namespace ToolRegistry {
|
|
3
|
+
/**
|
|
4
|
+
* Get all registered tools
|
|
5
|
+
*/
|
|
6
|
+
function all(): readonly Tool.Info<any, any>[];
|
|
7
|
+
/**
|
|
8
|
+
* Get a tool by its ID
|
|
9
|
+
*/
|
|
10
|
+
function get(id: string): Tool.Info<any, any> | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a tool exists
|
|
13
|
+
*/
|
|
14
|
+
function has(id: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get all tool IDs
|
|
17
|
+
*/
|
|
18
|
+
function ids(): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Initialize all tools and return their definitions
|
|
21
|
+
* This is used when setting up the LLM with available tools
|
|
22
|
+
* Conditional tools that return null during init are skipped
|
|
23
|
+
*/
|
|
24
|
+
function initialize(ctx?: Tool.InitContext): Promise<Tool.Initialized[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Initialize a specific subset of tools
|
|
27
|
+
* Conditional tools that return null during init are skipped
|
|
28
|
+
*/
|
|
29
|
+
function initializeSubset(ids: string[], ctx?: Tool.InitContext): Promise<Tool.Initialized[]>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
/**
|
|
4
|
+
* Todo Tool
|
|
5
|
+
*
|
|
6
|
+
* Allows the agent to create and manage a task list for tracking progress.
|
|
7
|
+
* Tasks are displayed in the UI and help users understand what the agent is doing.
|
|
8
|
+
*/
|
|
9
|
+
export interface TodoItem {
|
|
10
|
+
content: string;
|
|
11
|
+
status: "pending" | "in_progress" | "completed";
|
|
12
|
+
activeForm: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const TodoEvent: {
|
|
15
|
+
Updated: {
|
|
16
|
+
type: "todo.updated";
|
|
17
|
+
properties: z.ZodObject<{
|
|
18
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
19
|
+
content: z.ZodString;
|
|
20
|
+
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
21
|
+
activeForm: z.ZodString;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
status: "completed" | "pending" | "in_progress";
|
|
24
|
+
content: string;
|
|
25
|
+
activeForm: string;
|
|
26
|
+
}, {
|
|
27
|
+
status: "completed" | "pending" | "in_progress";
|
|
28
|
+
content: string;
|
|
29
|
+
activeForm: string;
|
|
30
|
+
}>, "many">;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
todos: {
|
|
33
|
+
status: "completed" | "pending" | "in_progress";
|
|
34
|
+
content: string;
|
|
35
|
+
activeForm: string;
|
|
36
|
+
}[];
|
|
37
|
+
}, {
|
|
38
|
+
todos: {
|
|
39
|
+
status: "completed" | "pending" | "in_progress";
|
|
40
|
+
content: string;
|
|
41
|
+
activeForm: string;
|
|
42
|
+
}[];
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare function getTodos(sessionId: string): TodoItem[];
|
|
47
|
+
export declare function clearTodos(sessionId: string): void;
|
|
48
|
+
export declare const TodoTool: Tool.Info<z.ZodObject<{
|
|
49
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
50
|
+
content: z.ZodString;
|
|
51
|
+
status: z.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
52
|
+
activeForm: z.ZodString;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
status: "completed" | "pending" | "in_progress";
|
|
55
|
+
content: string;
|
|
56
|
+
activeForm: string;
|
|
57
|
+
}, {
|
|
58
|
+
status: "completed" | "pending" | "in_progress";
|
|
59
|
+
content: string;
|
|
60
|
+
activeForm: string;
|
|
61
|
+
}>, "many">;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
todos: {
|
|
64
|
+
status: "completed" | "pending" | "in_progress";
|
|
65
|
+
content: string;
|
|
66
|
+
activeForm: string;
|
|
67
|
+
}[];
|
|
68
|
+
}, {
|
|
69
|
+
todos: {
|
|
70
|
+
status: "completed" | "pending" | "in_progress";
|
|
71
|
+
content: string;
|
|
72
|
+
activeForm: string;
|
|
73
|
+
}[];
|
|
74
|
+
}>, {
|
|
75
|
+
todosCount: number;
|
|
76
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
export declare namespace Tool {
|
|
3
|
+
interface Metadata {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface InitContext {
|
|
7
|
+
agent?: any;
|
|
8
|
+
}
|
|
9
|
+
export type Context<M extends Metadata = Metadata> = {
|
|
10
|
+
sessionID: string;
|
|
11
|
+
messageID: string;
|
|
12
|
+
agent: string;
|
|
13
|
+
abort: AbortSignal;
|
|
14
|
+
callID?: string;
|
|
15
|
+
extra?: {
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
18
|
+
metadata(input: {
|
|
19
|
+
title?: string;
|
|
20
|
+
metadata?: M;
|
|
21
|
+
}): void;
|
|
22
|
+
};
|
|
23
|
+
export interface FilePart {
|
|
24
|
+
id: string;
|
|
25
|
+
sessionID: string;
|
|
26
|
+
messageID: string;
|
|
27
|
+
type: "file";
|
|
28
|
+
mime: string;
|
|
29
|
+
url: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ToolDefinition<Parameters extends z.ZodType = z.ZodType, M extends Metadata = Metadata> {
|
|
32
|
+
description: string;
|
|
33
|
+
parameters: Parameters;
|
|
34
|
+
execute(args: z.infer<Parameters>, ctx: Context): Promise<{
|
|
35
|
+
title: string;
|
|
36
|
+
metadata: M;
|
|
37
|
+
output: string;
|
|
38
|
+
attachments?: FilePart[];
|
|
39
|
+
}>;
|
|
40
|
+
formatValidationError?(error: z.ZodError): string;
|
|
41
|
+
}
|
|
42
|
+
export interface Info<Parameters extends z.ZodType = z.ZodType, M extends Metadata = Metadata> {
|
|
43
|
+
id: string;
|
|
44
|
+
init: (ctx?: InitContext) => Promise<ToolDefinition<Parameters, M> | null>;
|
|
45
|
+
}
|
|
46
|
+
export type InferParameters<T extends Info> = T extends Info<infer P> ? z.infer<P> : never;
|
|
47
|
+
export type InferMetadata<T extends Info> = T extends Info<any, infer M> ? M : never;
|
|
48
|
+
/**
|
|
49
|
+
* Represents an initialized tool ready for use
|
|
50
|
+
*/
|
|
51
|
+
export interface Initialized<P extends z.ZodType = z.ZodType, M extends Metadata = Metadata> {
|
|
52
|
+
id: string;
|
|
53
|
+
description: string;
|
|
54
|
+
parameters: P;
|
|
55
|
+
execute(args: z.infer<P>, ctx: Context): Promise<{
|
|
56
|
+
title: string;
|
|
57
|
+
metadata: M;
|
|
58
|
+
output: string;
|
|
59
|
+
attachments?: FilePart[];
|
|
60
|
+
}>;
|
|
61
|
+
formatValidationError?(error: z.ZodError): string;
|
|
62
|
+
}
|
|
63
|
+
export function define<Parameters extends z.ZodType, Result extends Metadata>(id: string, init: Info<Parameters, Result>["init"] | ToolDefinition<Parameters, Result> | null): Info<Parameters, Result>;
|
|
64
|
+
export {};
|
|
65
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const WebFetchTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
url: z.ZodString;
|
|
5
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
url: string;
|
|
8
|
+
selector?: string | undefined;
|
|
9
|
+
}, {
|
|
10
|
+
url: string;
|
|
11
|
+
selector?: string | undefined;
|
|
12
|
+
}>, {
|
|
13
|
+
url: string;
|
|
14
|
+
length: number;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { Tool } from "./tool";
|
|
3
|
+
export declare const WriteTool: Tool.Info<z.ZodObject<{
|
|
4
|
+
filePath: z.ZodString;
|
|
5
|
+
content: z.ZodString;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
content: string;
|
|
8
|
+
filePath: string;
|
|
9
|
+
}, {
|
|
10
|
+
content: string;
|
|
11
|
+
filePath: string;
|
|
12
|
+
}>, {
|
|
13
|
+
action: string;
|
|
14
|
+
lines: number;
|
|
15
|
+
preview: string;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main TUI Application Component
|
|
3
|
+
*
|
|
4
|
+
* Root React component that manages routing and global state.
|
|
5
|
+
*/
|
|
6
|
+
import type { TuiOptions } from "./index";
|
|
7
|
+
interface AppProps extends TuiOptions {
|
|
8
|
+
}
|
|
9
|
+
export declare function App({ sessionId: initialSessionId, onExit, instanceContext }: AppProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header Component
|
|
3
|
+
*
|
|
4
|
+
* Displays the app title, mode indicator, and session title.
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
type Mode = "auto" | "plan" | "ask";
|
|
8
|
+
interface HeaderProps {
|
|
9
|
+
title?: string;
|
|
10
|
+
mode: Mode;
|
|
11
|
+
}
|
|
12
|
+
export declare const Header: React.NamedExoticComponent<HeaderProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LoadingIndicator Component
|
|
3
|
+
*
|
|
4
|
+
* Isolated loading spinner with local animation state to prevent parent re-renders.
|
|
5
|
+
* CRITICAL: Animation loop is self-contained - does NOT cause parent (REPL) to re-render.
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
interface LoadingIndicatorProps {
|
|
9
|
+
baseActivity: string;
|
|
10
|
+
tokenUsage: {
|
|
11
|
+
input: number;
|
|
12
|
+
output: number;
|
|
13
|
+
};
|
|
14
|
+
escapePressed: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* LoadingIndicator with optimized animation
|
|
18
|
+
*
|
|
19
|
+
* CRITICAL ARCHITECTURE for flicker-free animation:
|
|
20
|
+
* - Local state for spinner frame, isolated from parent re-renders
|
|
21
|
+
* - Fixed-width layout to prevent text reflow
|
|
22
|
+
* - React.memo with custom comparison to prevent parent-triggered re-renders
|
|
23
|
+
* - Low frequency updates (8fps) to minimize layout recalculations
|
|
24
|
+
*/
|
|
25
|
+
export declare const LoadingIndicator: React.NamedExoticComponent<LoadingIndicatorProps>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AssistantMessage Component
|
|
3
|
+
*
|
|
4
|
+
* Displays an assistant message with markdown rendering.
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
interface AssistantMessageProps {
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const AssistantMessage: React.NamedExoticComponent<AssistantMessageProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReasoningMessage Component
|
|
3
|
+
*
|
|
4
|
+
* Displays agent reasoning/thinking in a compact format.
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
interface ReasoningMessageProps {
|
|
8
|
+
content: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
streaming?: boolean;
|
|
11
|
+
termWidth?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const ReasoningMessage: React.NamedExoticComponent<ReasoningMessageProps>;
|
|
14
|
+
/**
|
|
15
|
+
* Compact version for message history
|
|
16
|
+
*/
|
|
17
|
+
export declare function ReasoningHistoryMessage({ content, termWidth: termWidthProp }: {
|
|
18
|
+
content: string;
|
|
19
|
+
termWidth?: number;
|
|
20
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ToolCallMessage Component
|
|
3
|
+
*
|
|
4
|
+
* Displays a tool call with IN/OUT format.
|
|
5
|
+
* For edit/write tools, shows a compact diff preview.
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
type ToolStatus = "pending" | "running" | "completed" | "failed";
|
|
9
|
+
interface ToolCallMessageProps {
|
|
10
|
+
name: string;
|
|
11
|
+
args?: Record<string, any>;
|
|
12
|
+
status: ToolStatus;
|
|
13
|
+
output?: string;
|
|
14
|
+
termWidth?: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const ToolCallMessage: React.NamedExoticComponent<ToolCallMessageProps>;
|
|
17
|
+
/**
|
|
18
|
+
* Compact version for message history (tool results)
|
|
19
|
+
*/
|
|
20
|
+
export declare const ToolResultMessage: React.NamedExoticComponent<{
|
|
21
|
+
toolName?: string;
|
|
22
|
+
input?: Record<string, any>;
|
|
23
|
+
output?: string;
|
|
24
|
+
termWidth?: number;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UserMessage Component
|
|
3
|
+
*
|
|
4
|
+
* Displays a user message in the conversation.
|
|
5
|
+
* Long messages are truncated to 3 lines with a count indicator.
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
interface UserMessageProps {
|
|
9
|
+
content: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const UserMessage: React.NamedExoticComponent<UserMessageProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message Component
|
|
3
|
+
*
|
|
4
|
+
* Dispatcher that renders the appropriate message component based on type.
|
|
5
|
+
*/
|
|
6
|
+
import React from "react";
|
|
7
|
+
import type { MessageWithParts } from "../../../session/types";
|
|
8
|
+
interface MessageProps {
|
|
9
|
+
message: MessageWithParts;
|
|
10
|
+
termWidth?: number;
|
|
11
|
+
maxToolResults?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const Message: React.NamedExoticComponent<MessageProps>;
|
|
14
|
+
export { UserMessage } from "./UserMessage";
|
|
15
|
+
export { AssistantMessage } from "./AssistantMessage";
|
|
16
|
+
export { ToolCallMessage, ToolResultMessage } from "./ToolCallMessage";
|