@liquidmetal-ai/raindrop-code 0.0.6 → 0.0.8
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/package.json +8 -6
- package/types/bash.d.ts +55 -0
- package/types/control.d.ts +126 -0
- package/types/files.d.ts +118 -0
- package/types/git.d.ts +99 -0
- package/types/index.d.ts +20 -0
- package/types/log.d.ts +58 -0
- package/types/resumable.d.ts +90 -0
- package/types/runtime.d.ts +46 -0
- package/types/state.d.ts +72 -0
- package/types/ui.d.ts +61 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liquidmetal-ai/raindrop-code",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "AI-powered terminal coding assistant with deep code understanding, file operations, and extensible tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -35,15 +35,17 @@
|
|
|
35
35
|
"bin": {
|
|
36
36
|
"raindrop-code": "bin/raindrop-code"
|
|
37
37
|
},
|
|
38
|
+
"types": "types/index.d.ts",
|
|
38
39
|
"files": [
|
|
39
40
|
"install.js",
|
|
40
41
|
"README.md",
|
|
41
|
-
"bin/"
|
|
42
|
+
"bin/",
|
|
43
|
+
"types/"
|
|
42
44
|
],
|
|
43
45
|
"optionalDependencies": {
|
|
44
|
-
"@liquidmetal-ai/raindrop-code-darwin-universal": "0.0.
|
|
45
|
-
"@liquidmetal-ai/raindrop-code-linux-x64": "0.0.
|
|
46
|
-
"@liquidmetal-ai/raindrop-code-linux-arm64": "0.0.
|
|
47
|
-
"@liquidmetal-ai/raindrop-code-win32-x64": "0.0.
|
|
46
|
+
"@liquidmetal-ai/raindrop-code-darwin-universal": "0.0.8",
|
|
47
|
+
"@liquidmetal-ai/raindrop-code-linux-x64": "0.0.8",
|
|
48
|
+
"@liquidmetal-ai/raindrop-code-linux-arm64": "0.0.8",
|
|
49
|
+
"@liquidmetal-ai/raindrop-code-win32-x64": "0.0.8"
|
|
48
50
|
}
|
|
49
51
|
}
|
package/types/bash.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/bash' {
|
|
2
|
+
/**
|
|
3
|
+
* Options for bash command execution
|
|
4
|
+
*/
|
|
5
|
+
export interface BashOptions {
|
|
6
|
+
/** Working directory for command execution */
|
|
7
|
+
cwd?: string;
|
|
8
|
+
/** Timeout in seconds */
|
|
9
|
+
timeout?: number;
|
|
10
|
+
/** Run command in background (don't wait for completion) */
|
|
11
|
+
background?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Result from bash command execution
|
|
16
|
+
*/
|
|
17
|
+
export interface BashResult {
|
|
18
|
+
/** Standard output */
|
|
19
|
+
output: string;
|
|
20
|
+
/** Standard error */
|
|
21
|
+
error: string;
|
|
22
|
+
/** Exit code */
|
|
23
|
+
exitCode: number;
|
|
24
|
+
/** Whether command succeeded (exit code 0) */
|
|
25
|
+
success: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Execute a shell command.
|
|
30
|
+
*
|
|
31
|
+
* @param command - Shell command to execute
|
|
32
|
+
* @param opts - Optional execution options
|
|
33
|
+
* @returns Promise resolving to execution result
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const result = await run('ls -la');
|
|
38
|
+
* if (result.success) {
|
|
39
|
+
* console.log(result.output);
|
|
40
|
+
* } else {
|
|
41
|
+
* console.error(result.error);
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // With options
|
|
48
|
+
* const result = await run('npm test', {
|
|
49
|
+
* cwd: './project',
|
|
50
|
+
* timeout: 300
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function run(command: string, opts?: BashOptions): Promise<BashResult>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/control' {
|
|
2
|
+
/**
|
|
3
|
+
* Options for passing control to AI
|
|
4
|
+
*/
|
|
5
|
+
export interface PassToAIOptions {
|
|
6
|
+
/** The prompt to send to the AI */
|
|
7
|
+
prompt: string;
|
|
8
|
+
/** Signal name to wait for from session_control tool */
|
|
9
|
+
untilSignal: string;
|
|
10
|
+
/** Timeout in seconds (default: 3600) */
|
|
11
|
+
timeout?: number;
|
|
12
|
+
/** Optional: Specific tools to enable for this AI session */
|
|
13
|
+
tools?: string[];
|
|
14
|
+
/** Optional: Specific skills to enable for this AI session */
|
|
15
|
+
skills?: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Data returned from AI via session_control signal
|
|
20
|
+
*/
|
|
21
|
+
export type SignalData = Record<string, any>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Options for passing control to user
|
|
25
|
+
*/
|
|
26
|
+
export interface PassToUserOptions {
|
|
27
|
+
/** Message to display to the user */
|
|
28
|
+
message: string;
|
|
29
|
+
/** Available actions for the user to choose from */
|
|
30
|
+
actions: string[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Options for passing control to another coordinator
|
|
35
|
+
*/
|
|
36
|
+
export interface PassToCoordinatorOptions {
|
|
37
|
+
/** Name of the coordinator to execute */
|
|
38
|
+
coordinator: string;
|
|
39
|
+
/** Input data to pass to the coordinator */
|
|
40
|
+
input: Record<string, any>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Pass control to AI by sending a prompt and waiting for a signal.
|
|
45
|
+
*
|
|
46
|
+
* The AI must use the session_control tool to send back the expected signal:
|
|
47
|
+
* ```xml
|
|
48
|
+
* <tool_use>
|
|
49
|
+
* <name>session_control</name>
|
|
50
|
+
* <input>
|
|
51
|
+
* <signal>your_signal_name</signal>
|
|
52
|
+
* <data>
|
|
53
|
+
* <key>value</key>
|
|
54
|
+
* </data>
|
|
55
|
+
* </input>
|
|
56
|
+
* </tool_use>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param opts - Options for the AI session
|
|
60
|
+
* @returns Promise resolving to the signal data sent by AI
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const result = await passToAI({
|
|
65
|
+
* prompt: 'Analyze this code and signal when done',
|
|
66
|
+
* untilSignal: 'analysis_complete',
|
|
67
|
+
* timeout: 300
|
|
68
|
+
* });
|
|
69
|
+
* console.log(result.findings);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export function passToAI(opts: PassToAIOptions): Promise<SignalData>;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Pass control to the user for manual input/decision.
|
|
76
|
+
*
|
|
77
|
+
* @param opts - Options for user interaction
|
|
78
|
+
* @returns Promise resolving to the user's selected action or entered text
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* // Choice selection (default)
|
|
83
|
+
* const choice = await passToUser({
|
|
84
|
+
* message: 'How should we proceed?',
|
|
85
|
+
* type: 'choice',
|
|
86
|
+
* actions: ['Continue', 'Skip', 'Abort']
|
|
87
|
+
* });
|
|
88
|
+
* if (choice === 'Abort') {
|
|
89
|
+
* return { success: false };
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* // Freeform text input
|
|
93
|
+
* const name = await passToUser({
|
|
94
|
+
* message: 'What is your project name?',
|
|
95
|
+
* type: 'text',
|
|
96
|
+
* placeholder: 'my-project'
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export function passToUser(opts: PassToUserOptions): Promise<string>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Pass control to another coordinator.
|
|
104
|
+
*
|
|
105
|
+
* @param opts - Options for coordinator execution
|
|
106
|
+
* @returns Promise resolving to the coordinator's result
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const result = await passToCoordinator({
|
|
111
|
+
* coordinator: 'helper-coordinator',
|
|
112
|
+
* input: { task: 'process data' }
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export function passToCoordinator(opts: PassToCoordinatorOptions): Promise<Record<string, any>>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get the current control state.
|
|
120
|
+
*
|
|
121
|
+
* @returns The current state ('coordinator', 'ai', or 'user')
|
|
122
|
+
*/
|
|
123
|
+
export function current(): string;
|
|
124
|
+
}
|
|
125
|
+
tring;
|
|
126
|
+
}
|
package/types/files.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/files' {
|
|
2
|
+
/**
|
|
3
|
+
* Read a file's contents as a string.
|
|
4
|
+
* Paths are resolved relative to the working directory.
|
|
5
|
+
*
|
|
6
|
+
* @param path - Path to the file (relative or absolute)
|
|
7
|
+
* @returns Promise resolving to file contents
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const content = await read('config.json');
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function read(path: string): Promise<string>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Write content to a file.
|
|
18
|
+
* Creates parent directories if needed.
|
|
19
|
+
*
|
|
20
|
+
* @param path - Path to the file (relative or absolute)
|
|
21
|
+
* @param content - Content to write
|
|
22
|
+
* @returns Promise resolving when write completes
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* await write('output.txt', 'Hello, world!');
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function write(path: string, content: string): Promise<void>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Append content to a file.
|
|
33
|
+
* Creates the file if it doesn't exist.
|
|
34
|
+
*
|
|
35
|
+
* @param path - Path to the file (relative or absolute)
|
|
36
|
+
* @param content - Content to append
|
|
37
|
+
* @returns Promise resolving when append completes
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* await append('log.txt', 'New log entry\n');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function append(path: string, content: string): Promise<void>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Read a JSON file and parse it.
|
|
48
|
+
*
|
|
49
|
+
* @param path - Path to the JSON file
|
|
50
|
+
* @returns Promise resolving to parsed JSON object
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const config = await readJSON('config.json');
|
|
55
|
+
* console.log(config.version);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function readJSON(path: string): Promise<Record<string, any>>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Write data to a JSON file with pretty formatting.
|
|
62
|
+
* Creates parent directories if needed.
|
|
63
|
+
*
|
|
64
|
+
* @param path - Path to the JSON file
|
|
65
|
+
* @param data - Data to write
|
|
66
|
+
* @returns Promise resolving when write completes
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* await writeJSON('data.json', { results: [1, 2, 3] });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function writeJSON(path: string, data: Record<string, any>): Promise<void>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Check if a file or directory exists.
|
|
77
|
+
*
|
|
78
|
+
* @param path - Path to check
|
|
79
|
+
* @returns Promise resolving to true if exists, false otherwise
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* if (await exists('config.json')) {
|
|
84
|
+
* const config = await readJSON('config.json');
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function exists(path: string): Promise<boolean>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* List contents of a directory.
|
|
92
|
+
*
|
|
93
|
+
* @param path - Path to directory
|
|
94
|
+
* @returns Promise resolving to array of file/directory names
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const files = await list('src/');
|
|
99
|
+
* for (const file of files) {
|
|
100
|
+
* console.log(file);
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export function list(path: string): Promise<string[]>;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Delete a file.
|
|
108
|
+
*
|
|
109
|
+
* @param path - Path to file
|
|
110
|
+
* @returns Promise resolving when deletion completes
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* await del('temp.txt');
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export function del(path: string): Promise<void>;
|
|
118
|
+
}
|
package/types/git.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/git' {
|
|
2
|
+
/**
|
|
3
|
+
* Git repository status
|
|
4
|
+
*/
|
|
5
|
+
export interface GitStatus {
|
|
6
|
+
/** List of modified files */
|
|
7
|
+
modified: string[];
|
|
8
|
+
/** List of added files */
|
|
9
|
+
added: string[];
|
|
10
|
+
/** List of deleted files */
|
|
11
|
+
deleted: string[];
|
|
12
|
+
/** List of untracked files */
|
|
13
|
+
untracked: string[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Commit changes to git.
|
|
18
|
+
* Optionally add files before committing.
|
|
19
|
+
*
|
|
20
|
+
* @param message - Commit message
|
|
21
|
+
* @param files - Optional array of files to add before committing
|
|
22
|
+
* @returns Promise resolving when commit completes
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* await commit('Add new feature', ['src/feature.ts']);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function commit(message: string, files?: string[]): Promise<void>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get git log entries.
|
|
33
|
+
*
|
|
34
|
+
* @param count - Number of log entries to retrieve
|
|
35
|
+
* @returns Promise resolving to log output
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const log = await getLog(10);
|
|
40
|
+
* console.log(log);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function log(count: number): Promise<string>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get git repository status.
|
|
47
|
+
*
|
|
48
|
+
* @returns Promise resolving to status object
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const status = await getStatus();
|
|
53
|
+
* if (status.modified.length > 0) {
|
|
54
|
+
* console.log('Modified files:', status.modified);
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function status(): Promise<GitStatus>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Add files to git staging area.
|
|
62
|
+
*
|
|
63
|
+
* @param files - Array of file paths to add
|
|
64
|
+
* @returns Promise resolving when add completes
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* await add(['src/main.ts', 'README.md']);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function add(files: string[]): Promise<void>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get current git branch name.
|
|
75
|
+
*
|
|
76
|
+
* @returns Promise resolving to branch name
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const branch = await getBranch();
|
|
81
|
+
* console.log('Current branch:', branch);
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export function branch(): Promise<string>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get git diff output.
|
|
88
|
+
*
|
|
89
|
+
* @param files - Optional array of files to diff (if empty, diffs all changes)
|
|
90
|
+
* @returns Promise resolving to diff output
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const diff = await getDiff(['src/main.ts']);
|
|
95
|
+
* console.log(diff);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export function diff(files?: string[]): Promise<string>;
|
|
99
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript definitions for Raindrop Code coordinator runtime APIs.
|
|
3
|
+
*
|
|
4
|
+
* These modules are provided by the Raindrop Code runtime and are available
|
|
5
|
+
* when writing coordinators. They do not exist as real npm packages, but are
|
|
6
|
+
* injected at runtime by the Go coordinator executor.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Re-export all modules for convenience
|
|
12
|
+
export * from '@liquidmetal-ai/raindrop-code/control';
|
|
13
|
+
export * from '@liquidmetal-ai/raindrop-code/files';
|
|
14
|
+
export * from '@liquidmetal-ai/raindrop-code/git';
|
|
15
|
+
export * from '@liquidmetal-ai/raindrop-code/bash';
|
|
16
|
+
export * from '@liquidmetal-ai/raindrop-code/ui';
|
|
17
|
+
export * from '@liquidmetal-ai/raindrop-code/log';
|
|
18
|
+
export * from '@liquidmetal-ai/raindrop-code/state';
|
|
19
|
+
export * from '@liquidmetal-ai/raindrop-code/runtime';
|
|
20
|
+
export * from '@liquidmetal-ai/raindrop-code/resumable';
|
package/types/log.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/log' {
|
|
2
|
+
/**
|
|
3
|
+
* Metadata to include with log messages
|
|
4
|
+
*/
|
|
5
|
+
export type LogMetadata = Record<string, any>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Log an info message.
|
|
9
|
+
*
|
|
10
|
+
* @param message - Message to log
|
|
11
|
+
* @param metadata - Optional metadata to include
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* info('Processing started', { fileCount: 10 });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function info(message: string, metadata?: LogMetadata): void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Log a warning message.
|
|
22
|
+
*
|
|
23
|
+
* @param message - Message to log
|
|
24
|
+
* @param metadata - Optional metadata to include
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* warn('Deprecated API used', { api: 'oldFunction' });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function warn(message: string, metadata?: LogMetadata): void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Log an error message.
|
|
35
|
+
*
|
|
36
|
+
* @param message - Message to log
|
|
37
|
+
* @param metadata - Optional metadata to include
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* error('Failed to connect', { host: 'example.com', port: 443 });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function error(message: string, metadata?: LogMetadata): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Log a debug message.
|
|
48
|
+
*
|
|
49
|
+
* @param message - Message to log
|
|
50
|
+
* @param metadata - Optional metadata to include
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* debug('Cache hit', { key: 'user:123', ttl: 3600 });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function debug(message: string, metadata?: LogMetadata): void;
|
|
58
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/resumable' {
|
|
2
|
+
import { SignalData } from '@liquidmetal-ai/raindrop-code/control';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Context provided to resumable coordinator functions.
|
|
6
|
+
* Handles automatic checkpoint management and step execution.
|
|
7
|
+
*/
|
|
8
|
+
export interface ResumableContext {
|
|
9
|
+
/**
|
|
10
|
+
* Execute a named step in the coordinator workflow.
|
|
11
|
+
* Automatically handles:
|
|
12
|
+
* - Skipping already-completed steps (returns cached result)
|
|
13
|
+
* - Resuming at the current checkpoint (returns signal data)
|
|
14
|
+
* - Executing new steps (runs function, saves checkpoint and result)
|
|
15
|
+
*
|
|
16
|
+
* @param stepName - Unique name for this step
|
|
17
|
+
* @param fn - Async function to execute for this step
|
|
18
|
+
* @returns Promise resolving to the step's result
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = await ctx.step('greeting', async () => {
|
|
23
|
+
* return await passToAI({
|
|
24
|
+
* prompt: 'Greet the user...',
|
|
25
|
+
* untilSignal: 'done'
|
|
26
|
+
* });
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
step<T = any>(stepName: string, fn: () => Promise<T>): Promise<T>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Check if we're resuming from a checkpoint.
|
|
34
|
+
*/
|
|
35
|
+
readonly isResuming: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The signal name we received when resuming (if any).
|
|
39
|
+
*/
|
|
40
|
+
readonly resumeSignal?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The signal data we received when resuming (if any).
|
|
44
|
+
*/
|
|
45
|
+
readonly resumeData?: SignalData;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The original input passed to the coordinator.
|
|
49
|
+
*/
|
|
50
|
+
readonly input: Record<string, any>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Coordinator function that supports resumption.
|
|
55
|
+
*/
|
|
56
|
+
export type ResumableCoordinator = (ctx: ResumableContext) => Promise<any>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Wraps a coordinator function to make it resumable.
|
|
60
|
+
*
|
|
61
|
+
* The wrapped function receives a context that provides automatic
|
|
62
|
+
* checkpoint management through ctx.step(). Each step is saved to
|
|
63
|
+
* state, allowing the coordinator to resume from the last checkpoint.
|
|
64
|
+
*
|
|
65
|
+
* @param fn - The coordinator function to wrap
|
|
66
|
+
* @returns A coordinator main function that handles resume logic
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* export const main = resumable(async (ctx) => {
|
|
71
|
+
* const result1 = await ctx.step('greeting', async () => {
|
|
72
|
+
* return await passToAI({
|
|
73
|
+
* prompt: 'Greet the user...',
|
|
74
|
+
* untilSignal: 'done'
|
|
75
|
+
* });
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const result2 = await ctx.step('analysis', async () => {
|
|
79
|
+
* return await passToAI({
|
|
80
|
+
* prompt: `Analyze: ${result1}...`,
|
|
81
|
+
* untilSignal: 'done'
|
|
82
|
+
* });
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* return { success: true, results: [result1, result2] };
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export function resumable(fn: ResumableCoordinator): (input: Record<string, any>) => Promise<any>;
|
|
90
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/runtime' {
|
|
2
|
+
/**
|
|
3
|
+
* Get the current context usage as a decimal (0.0 to 1.0).
|
|
4
|
+
* Useful for monitoring context window usage and deciding when to clear context.
|
|
5
|
+
*
|
|
6
|
+
* @returns Context usage from 0.0 (empty) to 1.0 (full)
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* if (contextUsage() > 0.75) {
|
|
11
|
+
* console.log('Context usage high, consider clearing');
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function contextUsage(): number;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Clear the conversation context.
|
|
19
|
+
* Removes all messages from the conversation history (system prompt is preserved).
|
|
20
|
+
* Use this in long-running coordinators to prevent context overflow.
|
|
21
|
+
*
|
|
22
|
+
* After clearing, you may want to re-inject important context.
|
|
23
|
+
*
|
|
24
|
+
* @returns Promise resolving when context is cleared
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // In a long-running loop
|
|
29
|
+
* for (const item of largeDataset) {
|
|
30
|
+
* if (contextUsage() > 0.75) {
|
|
31
|
+
* const summary = buildSummary();
|
|
32
|
+
* await clearContext();
|
|
33
|
+
*
|
|
34
|
+
* // Re-inject summary
|
|
35
|
+
* await passToAI({
|
|
36
|
+
* prompt: `Context was cleared. Here's what we've done so far:\n${summary}`,
|
|
37
|
+
* untilSignal: 'acknowledged'
|
|
38
|
+
* });
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* // Process item...
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function clearContext(): Promise<void>;
|
|
46
|
+
}
|
package/types/state.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/state' {
|
|
2
|
+
/**
|
|
3
|
+
* Get a value from coordinator state.
|
|
4
|
+
* Returns the default value if the key doesn't exist.
|
|
5
|
+
*
|
|
6
|
+
* @param key - State key
|
|
7
|
+
* @param defaultValue - Default value if key doesn't exist
|
|
8
|
+
* @returns Promise resolving to the value or default
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const count = await get('processedCount', 0);
|
|
13
|
+
* console.log('Processed:', count);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export function get<T = any>(key: string, defaultValue: T): Promise<T>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set a value in coordinator state.
|
|
20
|
+
* State is persisted to disk and survives coordinator restarts.
|
|
21
|
+
*
|
|
22
|
+
* @param key - State key
|
|
23
|
+
* @param value - Value to store
|
|
24
|
+
* @returns Promise resolving when state is saved
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* await set('processedCount', 42);
|
|
29
|
+
* await set('results', { success: true, data: [...] });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function set(key: string, value: any): Promise<void>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Delete a key from coordinator state.
|
|
36
|
+
*
|
|
37
|
+
* @param key - State key to delete
|
|
38
|
+
* @returns Promise resolving when deletion completes
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* await del('temporaryData');
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function del(key: string): Promise<void>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Clear all coordinator state.
|
|
49
|
+
*
|
|
50
|
+
* @returns Promise resolving when state is cleared
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // At the start of coordinator
|
|
55
|
+
* await clear();
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function clear(): Promise<void>;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get all keys in coordinator state.
|
|
62
|
+
*
|
|
63
|
+
* @returns Promise resolving to array of keys
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const keys = await getKeys();
|
|
68
|
+
* console.log('State keys:', keys);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function keys(): Promise<string[]>;
|
|
72
|
+
}
|
package/types/ui.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare module '@liquidmetal-ai/raindrop-code/ui' {
|
|
2
|
+
/**
|
|
3
|
+
* Show a status message in the UI.
|
|
4
|
+
*
|
|
5
|
+
* @param message - Status message to display
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* showStatus('Processing data...');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export function showStatus(message: string): void;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Show a progress message in the UI.
|
|
16
|
+
*
|
|
17
|
+
* @param message - Progress message to display
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* showProgress('Step 2/5: Analyzing code...');
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function showProgress(message: string): void;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Show a success message in the UI.
|
|
28
|
+
*
|
|
29
|
+
* @param message - Success message to display
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* showSuccess('Task completed successfully!');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function showSuccess(message: string): void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Show an error message in the UI.
|
|
40
|
+
*
|
|
41
|
+
* @param message - Error message to display
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* showError('Failed to process file');
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function showError(message: string): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Show a warning message in the UI.
|
|
52
|
+
*
|
|
53
|
+
* @param message - Warning message to display
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* showWarning('Configuration file not found, using defaults');
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function showWarning(message: string): void;
|
|
61
|
+
}
|