@kilncraft/core 0.0.0-stage → 1.0.0
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 +21 -0
- package/dist/index.d.ts +491 -0
- package/dist/index.js +2885 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kilncraft contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import * as _kilncraft_shared from '@kilncraft/shared';
|
|
2
|
+
import { PermissionMode, PermissionRule, PermissionDecision, Plugin, PluginContext, ChatMessage, ToolCall, ToolOutput, KilncraftEvent, Session, ToolDefinition, ToolSpec, ToolContext, ProviderAdapter, SandboxAdapter, LspManagerLike, Usage, KilncraftError, ProviderCapabilities, ModelInfo, StreamRequest, StreamEvent } from '@kilncraft/shared';
|
|
3
|
+
import { Logger } from 'pino';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
interface PermissionRequest {
|
|
7
|
+
tool: string;
|
|
8
|
+
input: unknown;
|
|
9
|
+
}
|
|
10
|
+
interface PermissionEngineOptions {
|
|
11
|
+
mode: PermissionMode;
|
|
12
|
+
cwd: string;
|
|
13
|
+
rules?: PermissionRule[];
|
|
14
|
+
isReadOnly?: (tool: string) => boolean;
|
|
15
|
+
}
|
|
16
|
+
declare function getCommand(input: unknown): string;
|
|
17
|
+
declare function getPath(input: unknown): string | undefined;
|
|
18
|
+
declare function isDangerousCommand(command: string): boolean;
|
|
19
|
+
declare class PermissionEngine {
|
|
20
|
+
private readonly options;
|
|
21
|
+
private readonly rules;
|
|
22
|
+
constructor(options: PermissionEngineOptions);
|
|
23
|
+
get mode(): PermissionMode;
|
|
24
|
+
addRule(rule: PermissionRule): void;
|
|
25
|
+
decide(request: PermissionRequest): PermissionDecision;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare class PluginHost {
|
|
29
|
+
readonly plugins: Plugin[];
|
|
30
|
+
readonly context: PluginContext;
|
|
31
|
+
constructor(plugins: Plugin[], context: PluginContext);
|
|
32
|
+
getTools(): _kilncraft_shared.ToolDefinition<unknown>[];
|
|
33
|
+
getCommands(): _kilncraft_shared.PluginCommand[];
|
|
34
|
+
sessionStart(payload: {
|
|
35
|
+
sessionID: string;
|
|
36
|
+
cwd: string;
|
|
37
|
+
model: string;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
messageReceived(payload: {
|
|
40
|
+
sessionID: string;
|
|
41
|
+
message: ChatMessage;
|
|
42
|
+
}): Promise<ChatMessage | undefined>;
|
|
43
|
+
toolBefore(payload: {
|
|
44
|
+
sessionID: string;
|
|
45
|
+
call: ToolCall;
|
|
46
|
+
}): Promise<ToolCall | "block" | undefined>;
|
|
47
|
+
toolAfter(payload: {
|
|
48
|
+
sessionID: string;
|
|
49
|
+
call: ToolCall;
|
|
50
|
+
output: ToolOutput;
|
|
51
|
+
}): Promise<ToolOutput | undefined>;
|
|
52
|
+
emit(event: KilncraftEvent): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
declare function loadPlugins(paths: string[], context: PluginContext): Promise<PluginHost>;
|
|
55
|
+
|
|
56
|
+
interface AuditEntry {
|
|
57
|
+
timestamp: string;
|
|
58
|
+
sessionID: string;
|
|
59
|
+
tool: string;
|
|
60
|
+
decision: "allow" | "ask" | "deny";
|
|
61
|
+
cwd: string;
|
|
62
|
+
inputHash: string;
|
|
63
|
+
summary: string;
|
|
64
|
+
}
|
|
65
|
+
declare class AuditLog {
|
|
66
|
+
private readonly filePath;
|
|
67
|
+
constructor(filePath: string);
|
|
68
|
+
record(entry: Omit<AuditEntry, "timestamp">): void;
|
|
69
|
+
read(limit?: number): AuditEntry[];
|
|
70
|
+
}
|
|
71
|
+
declare function hashInput(input: unknown): string;
|
|
72
|
+
declare function summarizeInput(input: unknown): string;
|
|
73
|
+
|
|
74
|
+
interface Checkpoint {
|
|
75
|
+
hash: string;
|
|
76
|
+
path: string;
|
|
77
|
+
createdAt: string;
|
|
78
|
+
}
|
|
79
|
+
declare class CheckpointManager {
|
|
80
|
+
private readonly dataDir;
|
|
81
|
+
constructor(dataDir: string);
|
|
82
|
+
private root;
|
|
83
|
+
snapshot(sessionID: string, path: string): Checkpoint | undefined;
|
|
84
|
+
list(sessionID: string): Checkpoint[];
|
|
85
|
+
latest(sessionID: string): Checkpoint | undefined;
|
|
86
|
+
restore(sessionID: string, hash: string): number;
|
|
87
|
+
restoreLatest(sessionID: string): number;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface CreateSessionInput {
|
|
91
|
+
cwd: string;
|
|
92
|
+
model: string;
|
|
93
|
+
agent?: string;
|
|
94
|
+
title?: string;
|
|
95
|
+
parentID?: string;
|
|
96
|
+
permissions?: Session["permissions"];
|
|
97
|
+
metadata?: Record<string, unknown>;
|
|
98
|
+
}
|
|
99
|
+
interface SessionFilter {
|
|
100
|
+
cwd?: string;
|
|
101
|
+
limit?: number;
|
|
102
|
+
}
|
|
103
|
+
interface SearchResult {
|
|
104
|
+
sessionID: string;
|
|
105
|
+
messageID: string;
|
|
106
|
+
role: string;
|
|
107
|
+
content: string;
|
|
108
|
+
}
|
|
109
|
+
type ExportFormat = "json" | "md";
|
|
110
|
+
declare function resolveDataDir(env?: NodeJS.ProcessEnv): string;
|
|
111
|
+
declare class SessionStore {
|
|
112
|
+
readonly dataDir: string;
|
|
113
|
+
private readonly db;
|
|
114
|
+
private closed;
|
|
115
|
+
constructor(options?: {
|
|
116
|
+
dataDir?: string;
|
|
117
|
+
});
|
|
118
|
+
create(input: CreateSessionInput): Session;
|
|
119
|
+
get(id: string): Session | undefined;
|
|
120
|
+
list(filter?: SessionFilter): Session[];
|
|
121
|
+
update(id: string, patch: Partial<Session>): Session | undefined;
|
|
122
|
+
appendMessage(sessionID: string, message: ChatMessage): void;
|
|
123
|
+
readMessages(sessionID: string): ChatMessage[];
|
|
124
|
+
replaceMessages(sessionID: string, messages: ChatMessage[]): void;
|
|
125
|
+
appendEvent(sessionID: string, event: KilncraftEvent): void;
|
|
126
|
+
readEvents(sessionID: string): KilncraftEvent[];
|
|
127
|
+
search(query: string, limit?: number): SearchResult[];
|
|
128
|
+
export(sessionID: string, format?: ExportFormat): string;
|
|
129
|
+
delete(sessionID: string): boolean;
|
|
130
|
+
sessionDirectory(sessionID: string): string;
|
|
131
|
+
close(): void;
|
|
132
|
+
private nextSequence;
|
|
133
|
+
private rowToSession;
|
|
134
|
+
}
|
|
135
|
+
declare function sessionExists(store: SessionStore, sessionID: string): boolean;
|
|
136
|
+
declare function readSessionFile(store: SessionStore, sessionID: string, filename: string): string | undefined;
|
|
137
|
+
declare function writeSessionFile(store: SessionStore, sessionID: string, filename: string, contents: string): void;
|
|
138
|
+
|
|
139
|
+
declare class ToolRegistry {
|
|
140
|
+
private readonly tools;
|
|
141
|
+
register<TInput>(tool: ToolDefinition<TInput>): void;
|
|
142
|
+
get(id: string): ToolDefinition<unknown> | undefined;
|
|
143
|
+
list(): ToolDefinition<unknown>[];
|
|
144
|
+
toSpecs(): ToolSpec[];
|
|
145
|
+
execute(id: string, input: unknown, context: ToolContext): Promise<ToolOutput>;
|
|
146
|
+
}
|
|
147
|
+
declare function createDefaultToolRegistry(): ToolRegistry;
|
|
148
|
+
|
|
149
|
+
declare const todoSchema: z.ZodObject<{
|
|
150
|
+
content: z.ZodString;
|
|
151
|
+
status: z.ZodEnum<{
|
|
152
|
+
pending: "pending";
|
|
153
|
+
in_progress: "in_progress";
|
|
154
|
+
completed: "completed";
|
|
155
|
+
}>;
|
|
156
|
+
activeForm: z.ZodOptional<z.ZodString>;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
type Todo = z.infer<typeof todoSchema>;
|
|
159
|
+
declare const todoInput: z.ZodObject<{
|
|
160
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
161
|
+
content: z.ZodString;
|
|
162
|
+
status: z.ZodEnum<{
|
|
163
|
+
pending: "pending";
|
|
164
|
+
in_progress: "in_progress";
|
|
165
|
+
completed: "completed";
|
|
166
|
+
}>;
|
|
167
|
+
activeForm: z.ZodOptional<z.ZodString>;
|
|
168
|
+
}, z.core.$strip>>;
|
|
169
|
+
}, z.core.$strip>;
|
|
170
|
+
type TodoInput = z.infer<typeof todoInput>;
|
|
171
|
+
declare function formatTodos(todos: Todo[]): string;
|
|
172
|
+
declare const todoTool: ToolDefinition<TodoInput>;
|
|
173
|
+
|
|
174
|
+
interface CompactionOptions {
|
|
175
|
+
contextWindow: number;
|
|
176
|
+
threshold?: number;
|
|
177
|
+
keepRecent?: number;
|
|
178
|
+
systemTokens?: number;
|
|
179
|
+
}
|
|
180
|
+
interface CompactionResult {
|
|
181
|
+
messages: ChatMessage[];
|
|
182
|
+
summary: string;
|
|
183
|
+
omitted: number;
|
|
184
|
+
tokensBefore: number;
|
|
185
|
+
tokensAfter: number;
|
|
186
|
+
}
|
|
187
|
+
declare function estimateTokens(text: string): number;
|
|
188
|
+
declare function estimateMessagesTokens(messages: ChatMessage[]): number;
|
|
189
|
+
declare function shouldCompact(messages: ChatMessage[], options: CompactionOptions): boolean;
|
|
190
|
+
declare function compactMessages(messages: ChatMessage[], options: CompactionOptions): CompactionResult;
|
|
191
|
+
|
|
192
|
+
type AgentEvent = {
|
|
193
|
+
type: "turn.start";
|
|
194
|
+
prompt: string;
|
|
195
|
+
} | {
|
|
196
|
+
type: "assistant.text";
|
|
197
|
+
text: string;
|
|
198
|
+
} | {
|
|
199
|
+
type: "assistant.message";
|
|
200
|
+
text: string;
|
|
201
|
+
toolCalls: ToolCall[];
|
|
202
|
+
} | {
|
|
203
|
+
type: "tool.call";
|
|
204
|
+
call: ToolCall;
|
|
205
|
+
} | {
|
|
206
|
+
type: "tool.result";
|
|
207
|
+
callID: string;
|
|
208
|
+
tool: string;
|
|
209
|
+
output: ToolOutput;
|
|
210
|
+
decision: PermissionDecision;
|
|
211
|
+
durationMs: number;
|
|
212
|
+
} | {
|
|
213
|
+
type: "permission.requested";
|
|
214
|
+
requestID: string;
|
|
215
|
+
request: PermissionAskRequest;
|
|
216
|
+
} | {
|
|
217
|
+
type: "permission.denied";
|
|
218
|
+
call: ToolCall;
|
|
219
|
+
reason: string;
|
|
220
|
+
} | {
|
|
221
|
+
type: "compaction.started";
|
|
222
|
+
reason: string;
|
|
223
|
+
tokensBefore: number;
|
|
224
|
+
} | {
|
|
225
|
+
type: "compaction.completed";
|
|
226
|
+
summary: string;
|
|
227
|
+
tokensAfter: number;
|
|
228
|
+
} | {
|
|
229
|
+
type: "turn.end";
|
|
230
|
+
stopReason: string;
|
|
231
|
+
usage: Usage;
|
|
232
|
+
cost: number;
|
|
233
|
+
} | {
|
|
234
|
+
type: "error";
|
|
235
|
+
error: KilncraftError;
|
|
236
|
+
};
|
|
237
|
+
interface PermissionAskRequest {
|
|
238
|
+
id: string;
|
|
239
|
+
sessionID: string;
|
|
240
|
+
tool: string;
|
|
241
|
+
input: unknown;
|
|
242
|
+
reason?: string;
|
|
243
|
+
}
|
|
244
|
+
interface AgentOptions {
|
|
245
|
+
cwd: string;
|
|
246
|
+
provider: ProviderAdapter;
|
|
247
|
+
model: string;
|
|
248
|
+
tools: ToolRegistry;
|
|
249
|
+
permissions: PermissionEngine;
|
|
250
|
+
logger: Logger;
|
|
251
|
+
maxTurns?: number;
|
|
252
|
+
maxTokens?: number;
|
|
253
|
+
systemPrompt?: string;
|
|
254
|
+
agent?: string;
|
|
255
|
+
store?: SessionStore;
|
|
256
|
+
session?: Session;
|
|
257
|
+
audit?: AuditLog;
|
|
258
|
+
checkpoints?: CheckpointManager;
|
|
259
|
+
askPermission?: (request: PermissionAskRequest, requestID: string) => Promise<PermissionDecision>;
|
|
260
|
+
plugins?: PluginHost;
|
|
261
|
+
sandbox?: SandboxAdapter;
|
|
262
|
+
lsp?: LspManagerLike;
|
|
263
|
+
}
|
|
264
|
+
interface PromptRunOptions {
|
|
265
|
+
onEvent?: (event: AgentEvent) => void | Promise<void>;
|
|
266
|
+
signal?: AbortSignal;
|
|
267
|
+
}
|
|
268
|
+
interface TurnResult {
|
|
269
|
+
sessionID: string;
|
|
270
|
+
text: string;
|
|
271
|
+
usage: Usage;
|
|
272
|
+
cost: number;
|
|
273
|
+
toolCalls: number;
|
|
274
|
+
stopReason: string;
|
|
275
|
+
}
|
|
276
|
+
declare class Agent {
|
|
277
|
+
private readonly options;
|
|
278
|
+
private messages;
|
|
279
|
+
private readonly state;
|
|
280
|
+
private session;
|
|
281
|
+
private usage;
|
|
282
|
+
private cost;
|
|
283
|
+
private totalToolCalls;
|
|
284
|
+
private readonly modelInfo;
|
|
285
|
+
constructor(options: AgentOptions);
|
|
286
|
+
get id(): string;
|
|
287
|
+
getSession(): Session;
|
|
288
|
+
getMessages(): ChatMessage[];
|
|
289
|
+
replaceMessages(messages: ChatMessage[]): void;
|
|
290
|
+
getUsage(): Usage;
|
|
291
|
+
getCost(): number;
|
|
292
|
+
getPermissions(): PermissionEngine;
|
|
293
|
+
getTodos(): Todo[];
|
|
294
|
+
prompt(input: string, options?: PromptRunOptions): Promise<TurnResult>;
|
|
295
|
+
compact(): Promise<CompactionResult>;
|
|
296
|
+
private finish;
|
|
297
|
+
private result;
|
|
298
|
+
private pushMessage;
|
|
299
|
+
private updateSession;
|
|
300
|
+
private maybeCompact;
|
|
301
|
+
private persistEvent;
|
|
302
|
+
private toKilncraftEvent;
|
|
303
|
+
private consumeStream;
|
|
304
|
+
private executeCalls;
|
|
305
|
+
private executeOne;
|
|
306
|
+
private emitResult;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface PromptOptions {
|
|
310
|
+
cwd: string;
|
|
311
|
+
model: string;
|
|
312
|
+
tools: ToolDefinition<unknown>[];
|
|
313
|
+
todos: Todo[];
|
|
314
|
+
}
|
|
315
|
+
declare function buildSystemPrompt(options: PromptOptions): string;
|
|
316
|
+
|
|
317
|
+
interface AnthropicOptions {
|
|
318
|
+
apiKey: string;
|
|
319
|
+
baseURL?: string;
|
|
320
|
+
}
|
|
321
|
+
declare class AnthropicProvider implements ProviderAdapter {
|
|
322
|
+
private readonly options;
|
|
323
|
+
readonly id = "anthropic";
|
|
324
|
+
readonly capabilities: ProviderCapabilities;
|
|
325
|
+
constructor(options: AnthropicOptions);
|
|
326
|
+
private get baseURL();
|
|
327
|
+
private headers;
|
|
328
|
+
listModels(): Promise<ModelInfo[]>;
|
|
329
|
+
stream(request: StreamRequest): AsyncIterable<StreamEvent>;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
interface GeminiOptions {
|
|
333
|
+
apiKey: string;
|
|
334
|
+
baseURL?: string;
|
|
335
|
+
}
|
|
336
|
+
declare class GeminiProvider implements ProviderAdapter {
|
|
337
|
+
private readonly options;
|
|
338
|
+
readonly id = "gemini";
|
|
339
|
+
readonly capabilities: ProviderCapabilities;
|
|
340
|
+
constructor(options: GeminiOptions);
|
|
341
|
+
private get baseURL();
|
|
342
|
+
listModels(): Promise<ModelInfo[]>;
|
|
343
|
+
stream(request: StreamRequest): AsyncIterable<StreamEvent>;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
declare const MODEL_CATALOG: Record<string, ModelInfo>;
|
|
347
|
+
declare function modelInfoFor(provider: string, model: string): ModelInfo;
|
|
348
|
+
declare function listKnownModels(): ModelInfo[];
|
|
349
|
+
|
|
350
|
+
interface OpenAIOptions {
|
|
351
|
+
id: string;
|
|
352
|
+
apiKey?: string;
|
|
353
|
+
baseURL: string;
|
|
354
|
+
headers?: Record<string, string>;
|
|
355
|
+
}
|
|
356
|
+
interface OpenAIToolCallDelta {
|
|
357
|
+
index?: number;
|
|
358
|
+
id?: string;
|
|
359
|
+
function?: {
|
|
360
|
+
name?: string;
|
|
361
|
+
arguments?: string;
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
interface OpenAIChunk {
|
|
365
|
+
choices?: Array<{
|
|
366
|
+
delta?: {
|
|
367
|
+
content?: string;
|
|
368
|
+
tool_calls?: OpenAIToolCallDelta[];
|
|
369
|
+
};
|
|
370
|
+
finish_reason?: string;
|
|
371
|
+
}>;
|
|
372
|
+
usage?: {
|
|
373
|
+
prompt_tokens?: number;
|
|
374
|
+
completion_tokens?: number;
|
|
375
|
+
prompt_tokens_details?: {
|
|
376
|
+
cached_tokens?: number;
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
declare class OpenAIProvider implements ProviderAdapter {
|
|
381
|
+
private readonly options;
|
|
382
|
+
readonly capabilities: ProviderCapabilities;
|
|
383
|
+
constructor(options: OpenAIOptions);
|
|
384
|
+
get id(): string;
|
|
385
|
+
private get baseURL();
|
|
386
|
+
private headers;
|
|
387
|
+
listModels(): Promise<ModelInfo[]>;
|
|
388
|
+
stream(request: StreamRequest): AsyncIterable<StreamEvent>;
|
|
389
|
+
}
|
|
390
|
+
declare function isOpenAiChunk(value: unknown): value is OpenAIChunk;
|
|
391
|
+
|
|
392
|
+
declare class ProviderRegistry {
|
|
393
|
+
private readonly providers;
|
|
394
|
+
register(provider: ProviderAdapter): this;
|
|
395
|
+
get(id: string): ProviderAdapter | undefined;
|
|
396
|
+
has(id: string): boolean;
|
|
397
|
+
list(): ProviderAdapter[];
|
|
398
|
+
}
|
|
399
|
+
declare function createDefaultProviderRegistry(env?: NodeJS.ProcessEnv): ProviderRegistry;
|
|
400
|
+
declare function availableProviderIds(env?: NodeJS.ProcessEnv): string[];
|
|
401
|
+
|
|
402
|
+
declare const bashInput: z.ZodObject<{
|
|
403
|
+
command: z.ZodString;
|
|
404
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
405
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
406
|
+
}, z.core.$strip>;
|
|
407
|
+
type BashInput = z.infer<typeof bashInput>;
|
|
408
|
+
declare const bashTool: ToolDefinition<BashInput>;
|
|
409
|
+
|
|
410
|
+
declare const DEFAULT_IGNORE: Set<string>;
|
|
411
|
+
declare const GLOB_IGNORE: string[];
|
|
412
|
+
declare function resolveWorkspacePath(cwd: string, inputPath: string): string;
|
|
413
|
+
declare function isPathInside(cwd: string, target: string): boolean;
|
|
414
|
+
declare function assertInsideWorkspace(cwd: string, target: string): void;
|
|
415
|
+
declare function assertRealInside(cwd: string, target: string): Promise<void>;
|
|
416
|
+
declare function isBinary(buffer: Buffer): boolean;
|
|
417
|
+
declare function readTextFile(path: string, maxBytes?: number): Promise<string>;
|
|
418
|
+
declare function lineNumbered(content: string, startLine?: number): string;
|
|
419
|
+
declare function truncateText(text: string, maxChars?: number): {
|
|
420
|
+
text: string;
|
|
421
|
+
truncated: boolean;
|
|
422
|
+
};
|
|
423
|
+
declare function diffText(path: string, before: string, after: string): string;
|
|
424
|
+
declare function atomicWrite(path: string, content: string): Promise<void>;
|
|
425
|
+
declare function fileExists(path: string): Promise<boolean>;
|
|
426
|
+
declare function walkFiles(root: string, options?: {
|
|
427
|
+
maxDepth?: number;
|
|
428
|
+
ignore?: Set<string>;
|
|
429
|
+
}): AsyncGenerator<string>;
|
|
430
|
+
declare function globToRegExp(pattern: string): RegExp;
|
|
431
|
+
declare function matchesGlob(value: string, pattern: string): boolean;
|
|
432
|
+
declare function escapeRegExp(value: string): string;
|
|
433
|
+
declare function toolOutputToText(output: ToolOutput): string;
|
|
434
|
+
|
|
435
|
+
declare const editInput: z.ZodObject<{
|
|
436
|
+
path: z.ZodString;
|
|
437
|
+
oldString: z.ZodString;
|
|
438
|
+
newString: z.ZodString;
|
|
439
|
+
replaceAll: z.ZodOptional<z.ZodBoolean>;
|
|
440
|
+
}, z.core.$strip>;
|
|
441
|
+
type EditInput = z.infer<typeof editInput>;
|
|
442
|
+
declare const editTool: ToolDefinition<EditInput>;
|
|
443
|
+
|
|
444
|
+
declare const globInput: z.ZodObject<{
|
|
445
|
+
pattern: z.ZodString;
|
|
446
|
+
path: z.ZodOptional<z.ZodString>;
|
|
447
|
+
}, z.core.$strip>;
|
|
448
|
+
type GlobInput = z.infer<typeof globInput>;
|
|
449
|
+
declare const globTool: ToolDefinition<GlobInput>;
|
|
450
|
+
|
|
451
|
+
declare const grepInput: z.ZodObject<{
|
|
452
|
+
pattern: z.ZodString;
|
|
453
|
+
path: z.ZodOptional<z.ZodString>;
|
|
454
|
+
glob: z.ZodOptional<z.ZodString>;
|
|
455
|
+
caseSensitive: z.ZodOptional<z.ZodBoolean>;
|
|
456
|
+
context: z.ZodOptional<z.ZodNumber>;
|
|
457
|
+
maxResults: z.ZodOptional<z.ZodNumber>;
|
|
458
|
+
}, z.core.$strip>;
|
|
459
|
+
type GrepInput = z.infer<typeof grepInput>;
|
|
460
|
+
declare const grepTool: ToolDefinition<GrepInput>;
|
|
461
|
+
|
|
462
|
+
declare const lsInput: z.ZodObject<{
|
|
463
|
+
path: z.ZodOptional<z.ZodString>;
|
|
464
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
465
|
+
}, z.core.$strip>;
|
|
466
|
+
type LsInput = z.infer<typeof lsInput>;
|
|
467
|
+
declare const lsTool: ToolDefinition<LsInput>;
|
|
468
|
+
|
|
469
|
+
declare const pathInput: z.ZodObject<{
|
|
470
|
+
path: z.ZodString;
|
|
471
|
+
}, z.core.$strip>;
|
|
472
|
+
declare const lspDiagnosticsTool: ToolDefinition<z.infer<typeof pathInput>>;
|
|
473
|
+
declare const lspSymbolsTool: ToolDefinition<z.infer<typeof pathInput>>;
|
|
474
|
+
|
|
475
|
+
declare const readInput: z.ZodObject<{
|
|
476
|
+
path: z.ZodString;
|
|
477
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
478
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
479
|
+
}, z.core.$strip>;
|
|
480
|
+
type ReadInput = z.infer<typeof readInput>;
|
|
481
|
+
declare const readTool: ToolDefinition<ReadInput>;
|
|
482
|
+
|
|
483
|
+
declare const writeInput: z.ZodObject<{
|
|
484
|
+
path: z.ZodString;
|
|
485
|
+
content: z.ZodString;
|
|
486
|
+
}, z.core.$strip>;
|
|
487
|
+
type WriteInput = z.infer<typeof writeInput>;
|
|
488
|
+
declare const writeTool: ToolDefinition<WriteInput>;
|
|
489
|
+
|
|
490
|
+
export { Agent, AnthropicProvider, AuditLog, CheckpointManager, DEFAULT_IGNORE, GLOB_IGNORE, GeminiProvider, MODEL_CATALOG, OpenAIProvider, PermissionEngine, PluginHost, ProviderRegistry, SessionStore, ToolRegistry, assertInsideWorkspace, assertRealInside, atomicWrite, availableProviderIds, bashTool, buildSystemPrompt, compactMessages, createDefaultProviderRegistry, createDefaultToolRegistry, diffText, editTool, escapeRegExp, estimateMessagesTokens, estimateTokens, fileExists, formatTodos, getCommand, getPath, globToRegExp, globTool, grepTool, hashInput, isBinary, isDangerousCommand, isOpenAiChunk, isPathInside, lineNumbered, listKnownModels, loadPlugins, lsTool, lspDiagnosticsTool, lspSymbolsTool, matchesGlob, modelInfoFor, readSessionFile, readTextFile, readTool, resolveDataDir, resolveWorkspacePath, sessionExists, shouldCompact, summarizeInput, todoSchema, todoTool, toolOutputToText, truncateText, walkFiles, writeSessionFile, writeTool };
|
|
491
|
+
export type { AgentEvent, AgentOptions, AnthropicOptions, AuditEntry, BashInput, Checkpoint, CompactionOptions, CompactionResult, CreateSessionInput, EditInput, ExportFormat, GeminiOptions, GlobInput, GrepInput, LsInput, OpenAIOptions, PermissionAskRequest, PermissionEngineOptions, PermissionRequest, PromptOptions, PromptRunOptions, ReadInput, SearchResult, SessionFilter, Todo, TodoInput, TurnResult, WriteInput };
|