sparkecoder 0.1.3 → 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/README.md +2 -2
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.js +813 -566
- package/dist/agent/index.js.map +1 -1
- package/dist/bash-CGAqW7HR.d.ts +80 -0
- package/dist/cli.js +3044 -1081
- package/dist/cli.js.map +1 -1
- package/dist/db/index.d.ts +67 -3
- package/dist/db/index.js +252 -13
- package/dist/db/index.js.map +1 -1
- package/dist/{index-BxpkHy7X.d.ts → index-Btr542-G.d.ts} +18 -2
- package/dist/index.d.ts +178 -77
- package/dist/index.js +2537 -976
- package/dist/index.js.map +1 -1
- package/dist/{schema-EPbMMFza.d.ts → schema-CkrIadxa.d.ts} +371 -5
- package/dist/server/index.d.ts +9 -2
- package/dist/server/index.js +2483 -945
- package/dist/server/index.js.map +1 -1
- package/dist/tools/index.d.ts +5 -138
- package/dist/tools/index.js +787 -723
- package/dist/tools/index.js.map +1 -1
- package/package.json +4 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ModelMessage, streamText } from 'ai';
|
|
2
|
-
import { S as Session,
|
|
2
|
+
import { S as Session, e as ToolExecution } from './schema-CkrIadxa.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { B as BashToolProgress } from './bash-CGAqW7HR.js';
|
|
4
5
|
|
|
5
6
|
declare const ToolApprovalConfigSchema: z.ZodObject<{
|
|
6
7
|
bash: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
@@ -228,6 +229,9 @@ interface AgentOptions {
|
|
|
228
229
|
}
|
|
229
230
|
interface AgentRunOptions {
|
|
230
231
|
prompt: string;
|
|
232
|
+
abortSignal?: AbortSignal;
|
|
233
|
+
/** Skip saving user message (if already saved externally) */
|
|
234
|
+
skipSaveUserMessage?: boolean;
|
|
231
235
|
onText?: (text: string) => void;
|
|
232
236
|
onToolCall?: (toolCall: {
|
|
233
237
|
toolCallId: string;
|
|
@@ -245,6 +249,14 @@ interface AgentRunOptions {
|
|
|
245
249
|
toolCalls?: unknown[];
|
|
246
250
|
usage?: unknown;
|
|
247
251
|
}) => void;
|
|
252
|
+
onAbort?: (info: {
|
|
253
|
+
steps: unknown[];
|
|
254
|
+
}) => void;
|
|
255
|
+
/** Called when a tool (like bash) has progress to report (e.g., terminal started) */
|
|
256
|
+
onToolProgress?: (progress: {
|
|
257
|
+
toolName: string;
|
|
258
|
+
data: BashToolProgress;
|
|
259
|
+
}) => void;
|
|
248
260
|
}
|
|
249
261
|
interface AgentStreamResult {
|
|
250
262
|
sessionId: string;
|
|
@@ -259,9 +271,13 @@ interface AgentStreamResult {
|
|
|
259
271
|
declare class Agent {
|
|
260
272
|
private session;
|
|
261
273
|
private context;
|
|
262
|
-
private
|
|
274
|
+
private baseTools;
|
|
263
275
|
private pendingApprovals;
|
|
264
276
|
private constructor();
|
|
277
|
+
/**
|
|
278
|
+
* Create tools with optional progress callbacks
|
|
279
|
+
*/
|
|
280
|
+
private createToolsWithCallbacks;
|
|
265
281
|
/**
|
|
266
282
|
* Create or resume an agent session
|
|
267
283
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { R as ResolvedConfig } from './index-
|
|
2
|
-
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, S as SparkcoderConfig, T as ToolApprovalConfig } from './index-
|
|
1
|
+
import { R as ResolvedConfig } from './index-Btr542-G.js';
|
|
2
|
+
export { A as Agent, a as AgentOptions, b as AgentRunOptions, c as AgentStreamResult, S as SparkcoderConfig, T as ToolApprovalConfig } from './index-Btr542-G.js';
|
|
3
3
|
export { ServerOptions, createApp, startServer, stopServer } from './server/index.js';
|
|
4
|
-
export { closeDatabase, getDb, initDatabase, messageQueries, sessionQueries, skillQueries,
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
|
|
4
|
+
export { checkpointQueries, closeDatabase, fileBackupQueries, getDb, initDatabase, messageQueries, sessionQueries, skillQueries, todoQueries, toolExecutionQueries } from './db/index.js';
|
|
5
|
+
import { F as FileBackup, C as Checkpoint } from './schema-CkrIadxa.js';
|
|
6
|
+
export { a as Message, M as ModelMessage, S as Session, b as SessionConfig, g as Terminal, T as TodoItem, e as ToolExecution } from './schema-CkrIadxa.js';
|
|
7
|
+
export { createLoadSkillTool, createReadFileTool, createTodoTool, createTools, createWriteFileTool } from './tools/index.js';
|
|
8
|
+
export { c as createBashTool } from './bash-CGAqW7HR.js';
|
|
8
9
|
import 'ai';
|
|
9
10
|
import 'zod';
|
|
10
11
|
import 'hono/types';
|
|
@@ -18,90 +19,190 @@ import 'drizzle-orm/sqlite-core';
|
|
|
18
19
|
*/
|
|
19
20
|
declare function loadConfig(configPath?: string, workingDirectory?: string): ResolvedConfig;
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Checkpoint system for session revert functionality
|
|
24
|
+
*
|
|
25
|
+
* Creates checkpoints before each user message, backs up modified files,
|
|
26
|
+
* and allows reverting to any previous checkpoint.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
interface CheckpointManager {
|
|
22
30
|
sessionId: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
name?: string;
|
|
26
|
-
env?: Record<string, string>;
|
|
31
|
+
workingDirectory: string;
|
|
32
|
+
currentCheckpointId: string | null;
|
|
27
33
|
}
|
|
28
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Get or create a checkpoint manager for a session
|
|
36
|
+
*/
|
|
37
|
+
declare function getCheckpointManager(sessionId: string, workingDirectory: string): CheckpointManager;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new checkpoint before processing a user message
|
|
40
|
+
* Called when a user message is about to be processed
|
|
41
|
+
*/
|
|
42
|
+
declare function createCheckpoint(sessionId: string, workingDirectory: string, messageSequence: number): Promise<Checkpoint>;
|
|
43
|
+
/**
|
|
44
|
+
* Backup a file before it's modified
|
|
45
|
+
* Called by the write_file tool before writing
|
|
46
|
+
*/
|
|
47
|
+
declare function backupFile(sessionId: string, workingDirectory: string, filePath: string): Promise<FileBackup | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Revert a session to a specific checkpoint
|
|
50
|
+
* This will:
|
|
51
|
+
* 1. Restore all files to their state at that checkpoint
|
|
52
|
+
* 2. Delete all messages after the checkpoint's message sequence
|
|
53
|
+
* 3. Delete all tool executions after the checkpoint
|
|
54
|
+
* 4. Delete all checkpoints after this one
|
|
55
|
+
*/
|
|
56
|
+
declare function revertToCheckpoint(sessionId: string, checkpointId: string): Promise<{
|
|
57
|
+
success: boolean;
|
|
58
|
+
filesRestored: number;
|
|
59
|
+
filesDeleted: number;
|
|
60
|
+
messagesDeleted: number;
|
|
61
|
+
checkpointsDeleted: number;
|
|
62
|
+
error?: string;
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Get all checkpoints for a session
|
|
66
|
+
*/
|
|
67
|
+
declare function getCheckpoints(sessionId: string): Checkpoint[];
|
|
68
|
+
/**
|
|
69
|
+
* Get the diff for an entire session (all file changes from start to now)
|
|
70
|
+
*/
|
|
71
|
+
declare function getSessionDiff(sessionId: string): Promise<{
|
|
72
|
+
files: Array<{
|
|
73
|
+
path: string;
|
|
74
|
+
status: 'created' | 'modified' | 'deleted';
|
|
75
|
+
originalContent: string | null;
|
|
76
|
+
currentContent: string | null;
|
|
77
|
+
}>;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Clear the checkpoint manager for a session (called when session is deleted)
|
|
81
|
+
*/
|
|
82
|
+
declare function clearCheckpointManager(sessionId: string): void;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* tmux wrapper for terminal session management
|
|
86
|
+
*
|
|
87
|
+
* Provides a thin abstraction over tmux commands for:
|
|
88
|
+
* - Session creation and management
|
|
89
|
+
* - Output capture and logging
|
|
90
|
+
* - Process lifecycle management
|
|
91
|
+
*/
|
|
92
|
+
interface TerminalMeta {
|
|
29
93
|
id: string;
|
|
30
|
-
name: string | null;
|
|
31
94
|
command: string;
|
|
32
95
|
cwd: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
error: string | null;
|
|
37
|
-
createdAt: Date;
|
|
38
|
-
stoppedAt: Date | null;
|
|
96
|
+
createdAt: string;
|
|
97
|
+
sessionId: string;
|
|
98
|
+
background: boolean;
|
|
39
99
|
}
|
|
100
|
+
interface TerminalResult {
|
|
101
|
+
id: string;
|
|
102
|
+
output: string;
|
|
103
|
+
exitCode: number;
|
|
104
|
+
status: 'completed' | 'running' | 'stopped' | 'error';
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check if tmux is installed and available
|
|
108
|
+
*/
|
|
109
|
+
declare function isTmuxAvailable(): Promise<boolean>;
|
|
40
110
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
* Generate a unique terminal ID
|
|
112
|
+
* Ensure it starts with a letter (tmux session names work better this way)
|
|
113
|
+
*/
|
|
114
|
+
declare function generateTerminalId(): string;
|
|
115
|
+
/**
|
|
116
|
+
* Get the tmux session name for a terminal ID
|
|
117
|
+
*/
|
|
118
|
+
declare function getSessionName(terminalId: string): string;
|
|
119
|
+
/**
|
|
120
|
+
* Get the log directory for a terminal (session-scoped)
|
|
121
|
+
*/
|
|
122
|
+
declare function getLogDir(terminalId: string, workingDirectory: string, sessionId?: string): string;
|
|
123
|
+
/**
|
|
124
|
+
* Run a command synchronously in tmux (waits for completion)
|
|
125
|
+
*/
|
|
126
|
+
declare function runSync(command: string, workingDirectory: string, options: {
|
|
127
|
+
sessionId: string;
|
|
128
|
+
timeout?: number;
|
|
129
|
+
terminalId?: string;
|
|
130
|
+
}): Promise<TerminalResult>;
|
|
131
|
+
/**
|
|
132
|
+
* Run a command in the background (returns immediately)
|
|
133
|
+
*/
|
|
134
|
+
declare function runBackground(command: string, workingDirectory: string, options: {
|
|
135
|
+
sessionId: string;
|
|
136
|
+
terminalId?: string;
|
|
137
|
+
}): Promise<TerminalResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Get logs from a terminal
|
|
140
|
+
*/
|
|
141
|
+
declare function getLogs(terminalId: string, workingDirectory: string, options?: {
|
|
142
|
+
tail?: number;
|
|
143
|
+
sessionId?: string;
|
|
144
|
+
}): Promise<{
|
|
145
|
+
output: string;
|
|
146
|
+
status: 'running' | 'stopped' | 'unknown';
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Check if a terminal is running
|
|
150
|
+
*/
|
|
151
|
+
declare function isRunning(terminalId: string): Promise<boolean>;
|
|
152
|
+
/**
|
|
153
|
+
* Kill a terminal session
|
|
154
|
+
*/
|
|
155
|
+
declare function killTerminal(terminalId: string): Promise<boolean>;
|
|
156
|
+
/**
|
|
157
|
+
* List all sparkecoder terminal sessions
|
|
158
|
+
*/
|
|
159
|
+
declare function listSessions(): Promise<string[]>;
|
|
160
|
+
/**
|
|
161
|
+
* Get metadata for a terminal
|
|
162
|
+
*/
|
|
163
|
+
declare function getMeta(terminalId: string, workingDirectory: string, sessionId?: string): Promise<TerminalMeta | null>;
|
|
164
|
+
/**
|
|
165
|
+
* List all terminals for a session
|
|
166
|
+
*/
|
|
167
|
+
declare function listSessionTerminals(sessionId: string, workingDirectory: string): Promise<TerminalMeta[]>;
|
|
168
|
+
/**
|
|
169
|
+
* Send input (keystrokes) to a running terminal
|
|
170
|
+
* Use this to respond to interactive prompts
|
|
171
|
+
*/
|
|
172
|
+
declare function sendInput(terminalId: string, input: string, options?: {
|
|
173
|
+
pressEnter?: boolean;
|
|
174
|
+
}): Promise<boolean>;
|
|
175
|
+
/**
|
|
176
|
+
* Send special keys to a terminal (like arrow keys, escape, etc.)
|
|
177
|
+
*/
|
|
178
|
+
declare function sendKey(terminalId: string, key: 'Enter' | 'Escape' | 'Up' | 'Down' | 'Left' | 'Right' | 'Tab' | 'C-c' | 'C-d' | 'y' | 'n'): Promise<boolean>;
|
|
179
|
+
|
|
180
|
+
type tmux_TerminalMeta = TerminalMeta;
|
|
181
|
+
type tmux_TerminalResult = TerminalResult;
|
|
182
|
+
declare const tmux_generateTerminalId: typeof generateTerminalId;
|
|
183
|
+
declare const tmux_getLogDir: typeof getLogDir;
|
|
184
|
+
declare const tmux_getLogs: typeof getLogs;
|
|
185
|
+
declare const tmux_getMeta: typeof getMeta;
|
|
186
|
+
declare const tmux_getSessionName: typeof getSessionName;
|
|
187
|
+
declare const tmux_isRunning: typeof isRunning;
|
|
188
|
+
declare const tmux_isTmuxAvailable: typeof isTmuxAvailable;
|
|
189
|
+
declare const tmux_killTerminal: typeof killTerminal;
|
|
190
|
+
declare const tmux_listSessionTerminals: typeof listSessionTerminals;
|
|
191
|
+
declare const tmux_listSessions: typeof listSessions;
|
|
192
|
+
declare const tmux_runBackground: typeof runBackground;
|
|
193
|
+
declare const tmux_runSync: typeof runSync;
|
|
194
|
+
declare const tmux_sendInput: typeof sendInput;
|
|
195
|
+
declare const tmux_sendKey: typeof sendKey;
|
|
196
|
+
declare namespace tmux {
|
|
197
|
+
export { type tmux_TerminalMeta as TerminalMeta, type tmux_TerminalResult as TerminalResult, tmux_generateTerminalId as generateTerminalId, tmux_getLogDir as getLogDir, tmux_getLogs as getLogs, tmux_getMeta as getMeta, tmux_getSessionName as getSessionName, tmux_isRunning as isRunning, tmux_isTmuxAvailable as isTmuxAvailable, tmux_killTerminal as killTerminal, tmux_listSessionTerminals as listSessionTerminals, tmux_listSessions as listSessions, tmux_runBackground as runBackground, tmux_runSync as runSync, tmux_sendInput as sendInput, tmux_sendKey as sendKey };
|
|
96
198
|
}
|
|
97
|
-
declare function getTerminalManager(): TerminalManager;
|
|
98
199
|
|
|
99
200
|
/**
|
|
100
|
-
*
|
|
201
|
+
* SparkECoder - A powerful coding agent CLI with HTTP API
|
|
101
202
|
*
|
|
102
203
|
* @packageDocumentation
|
|
103
204
|
*/
|
|
104
205
|
|
|
105
206
|
declare const VERSION = "0.1.0";
|
|
106
207
|
|
|
107
|
-
export {
|
|
208
|
+
export { Checkpoint, FileBackup, ResolvedConfig, VERSION, backupFile, clearCheckpointManager, createCheckpoint, getCheckpointManager, getCheckpoints, getSessionDiff, loadConfig, revertToCheckpoint, tmux };
|