@agent-api/sdk 1.0.6 → 1.1.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.
@@ -0,0 +1,382 @@
1
+ import type { LocalSkillDirectoryOptions } from "../local-skills.js";
2
+ import type { LocalSkillDescriptor } from "../types/skills.js";
3
+ export interface LocalAppDirs {
4
+ home: string;
5
+ data: string;
6
+ config: string;
7
+ cache: string;
8
+ logs: string;
9
+ temp: string;
10
+ }
11
+ export interface LocalRuntimeOptions {
12
+ appName: string;
13
+ appAuthor?: string;
14
+ baseDir?: string;
15
+ dirs?: Partial<Omit<LocalAppDirs, "home">>;
16
+ env?: Record<string, string | undefined>;
17
+ platform?: NodeJS.Platform;
18
+ }
19
+ export interface LocalFileStoreOptions {
20
+ label?: string;
21
+ }
22
+ export declare class LocalError extends Error {
23
+ readonly code: string;
24
+ readonly path?: string;
25
+ constructor(code: string, message: string, options?: {
26
+ path?: string;
27
+ cause?: unknown;
28
+ });
29
+ }
30
+ export declare class LocalPathError extends LocalError {
31
+ constructor(message: string, path?: string);
32
+ }
33
+ export declare class LocalIgnoredPathError extends LocalError {
34
+ constructor(path: string);
35
+ }
36
+ export declare class LocalFileTooLargeError extends LocalError {
37
+ constructor(path: string);
38
+ }
39
+ export declare class LocalNotTextFileError extends LocalError {
40
+ constructor(path: string);
41
+ }
42
+ export declare class LocalConfigError extends LocalError {
43
+ constructor(message: string, path?: string);
44
+ }
45
+ export type LocalFileType = "file" | "directory" | "symlink" | "other";
46
+ export interface LocalFileStat {
47
+ path: string;
48
+ fullPath: string;
49
+ type: LocalFileType;
50
+ size: number;
51
+ modifiedAt: Date;
52
+ }
53
+ export interface LocalListOptions {
54
+ recursive?: boolean;
55
+ includeDirectories?: boolean;
56
+ maxDepth?: number;
57
+ ignore?: Array<string | RegExp | ((relativePath: string) => boolean)>;
58
+ }
59
+ export type LocalIgnoreRule = NonNullable<LocalListOptions["ignore"]>[number];
60
+ export interface LocalEntry {
61
+ path: string;
62
+ is_dir: boolean;
63
+ size: number;
64
+ modified_at_unix?: number;
65
+ }
66
+ export interface LocalEntryList {
67
+ object: "list";
68
+ entries: LocalEntry[];
69
+ }
70
+ export interface LocalSearchEntriesParams {
71
+ query: string;
72
+ path?: string;
73
+ limit?: number;
74
+ }
75
+ export interface LocalReadFileParams {
76
+ maxBytes?: number;
77
+ format?: "text";
78
+ }
79
+ export interface LocalReadFileRawParams {
80
+ maxBytes?: number;
81
+ format: "raw";
82
+ }
83
+ export interface LocalFileDeliver {
84
+ path: string;
85
+ encoding: "text" | "base64";
86
+ mime_type: string;
87
+ size: number;
88
+ truncated: boolean;
89
+ content?: string;
90
+ content_base64?: string;
91
+ }
92
+ export interface LocalFileRaw {
93
+ path: string;
94
+ size: number;
95
+ truncated: boolean;
96
+ content: Uint8Array;
97
+ content_type?: string;
98
+ }
99
+ export interface LocalFileWrite {
100
+ path: string;
101
+ size: number;
102
+ }
103
+ export interface LocalPathDelete {
104
+ path: string;
105
+ recursive: boolean;
106
+ }
107
+ export interface LocalReadLinesParams {
108
+ startLine: number;
109
+ endLine?: number;
110
+ maxBytes?: number;
111
+ }
112
+ export interface LocalFileLines {
113
+ path: string;
114
+ start_line: number;
115
+ end_line: number;
116
+ total_lines: number;
117
+ lines: string[];
118
+ file_truncated: boolean;
119
+ size: number;
120
+ }
121
+ export interface LocalPatchLinesParams {
122
+ startLine: number;
123
+ endLine?: number;
124
+ replacement?: string;
125
+ maxBytes?: number;
126
+ }
127
+ export interface LocalFileLinesPatch {
128
+ path: string;
129
+ start_line: number;
130
+ end_line: number;
131
+ total_lines: number;
132
+ size: number;
133
+ }
134
+ export interface LocalGrepParams {
135
+ pattern: string;
136
+ path?: string;
137
+ limit?: number;
138
+ maxFiles?: number;
139
+ maxBytesPerFile?: number;
140
+ maxLineLength?: number;
141
+ ignore?: LocalListOptions["ignore"];
142
+ }
143
+ export interface LocalGrepMatch {
144
+ path: string;
145
+ line_number: number;
146
+ line: string;
147
+ }
148
+ export interface LocalGrepResponse {
149
+ object: "list";
150
+ matches: LocalGrepMatch[];
151
+ files_scanned: number;
152
+ scan_truncated: boolean;
153
+ }
154
+ export interface LocalSummarizeParams {
155
+ path?: string;
156
+ maxFiles?: number;
157
+ maxPreviews?: number;
158
+ previewBytes?: number;
159
+ topPaths?: number;
160
+ ignore?: LocalListOptions["ignore"];
161
+ }
162
+ export interface LocalSummaryPreview {
163
+ path: string;
164
+ size: number;
165
+ preview: string;
166
+ preview_truncated?: boolean;
167
+ }
168
+ export interface LocalSummary {
169
+ summary_path: string;
170
+ file_count: number;
171
+ total_bytes: number;
172
+ top_paths_by_size: string[];
173
+ text_previews: LocalSummaryPreview[];
174
+ generated_at_unix: number;
175
+ scan_truncated: boolean;
176
+ }
177
+ export interface LocalWorkspaceOptions {
178
+ name?: string;
179
+ metadata?: Record<string, unknown>;
180
+ trusted?: boolean;
181
+ ignore?: LocalIgnoreRule[];
182
+ gitignore?: boolean;
183
+ maxFileBytes?: number;
184
+ }
185
+ export interface LocalWorkspaceSnapshotParams {
186
+ path?: string;
187
+ hash?: boolean;
188
+ maxBytesPerFile?: number;
189
+ }
190
+ export interface LocalWorkspaceSnapshotFile {
191
+ path: string;
192
+ size: number;
193
+ modified_at_unix?: number;
194
+ sha256?: string;
195
+ }
196
+ export interface LocalWorkspaceSnapshot {
197
+ root: string;
198
+ name: string;
199
+ generated_at_unix: number;
200
+ files: LocalWorkspaceSnapshotFile[];
201
+ }
202
+ export interface LocalWorkspaceDiff {
203
+ added: LocalWorkspaceSnapshotFile[];
204
+ modified: Array<{
205
+ before: LocalWorkspaceSnapshotFile;
206
+ after: LocalWorkspaceSnapshotFile;
207
+ }>;
208
+ deleted: LocalWorkspaceSnapshotFile[];
209
+ unchanged: LocalWorkspaceSnapshotFile[];
210
+ }
211
+ export interface LocalLinePatchPreview {
212
+ path: string;
213
+ start_line: number;
214
+ end_line: number;
215
+ total_lines: number;
216
+ before: string[];
217
+ after: string[];
218
+ }
219
+ export interface LocalWorkspaceLineEdit {
220
+ path: string;
221
+ startLine: number;
222
+ endLine?: number;
223
+ replacement?: string;
224
+ expectedSha256?: string;
225
+ }
226
+ export interface LocalWorkspaceEditPlan {
227
+ edits: LocalWorkspaceLineEdit[];
228
+ previews: LocalLinePatchPreview[];
229
+ }
230
+ export interface LocalWorkspaceEditResult {
231
+ applied: LocalFileLinesPatch[];
232
+ backups: Array<{
233
+ path: string;
234
+ content: string;
235
+ }>;
236
+ }
237
+ export type LocalPathSensitivity = "normal" | "sensitive" | "secret";
238
+ export interface LocalPathSensitivityInfo {
239
+ path: string;
240
+ sensitivity: LocalPathSensitivity;
241
+ reason?: string;
242
+ }
243
+ export interface LocalWorkspaceWatchEvent {
244
+ type: "change" | "rename";
245
+ path: string;
246
+ }
247
+ export interface LocalWorkspaceWatcher {
248
+ close(): void;
249
+ }
250
+ export interface LocalSkillDiscoveryOptions extends LocalSkillDirectoryOptions {
251
+ roots?: string[];
252
+ recursive?: boolean;
253
+ maxDepth?: number;
254
+ }
255
+ export interface LocalRuntime {
256
+ appName: string;
257
+ dirs: LocalAppDirs;
258
+ files: LocalFileStore;
259
+ data: LocalFileStore;
260
+ cache: LocalFileStore;
261
+ logs: LocalFileStore;
262
+ temp: LocalFileStore;
263
+ config: LocalConfigStore;
264
+ skills: LocalSkillStore;
265
+ workspaces: LocalWorkspaceManager;
266
+ workspace(root: string, options?: LocalWorkspaceOptions): LocalWorkspace;
267
+ ensure(): Promise<void>;
268
+ }
269
+ export declare function createLocalRuntime(options: LocalRuntimeOptions): LocalRuntime;
270
+ export declare function localAppDirs(options: LocalRuntimeOptions): LocalAppDirs;
271
+ export declare class LocalFileStore {
272
+ readonly root: string;
273
+ readonly label: string;
274
+ constructor(root: string, options?: LocalFileStoreOptions);
275
+ child(relativePath: string, options?: LocalFileStoreOptions): LocalFileStore;
276
+ ensure(): Promise<void>;
277
+ resolvePath(relativePath?: string): string;
278
+ relativePath(fullPath: string): string;
279
+ exists(relativePath?: string): Promise<boolean>;
280
+ stat(relativePath?: string): Promise<LocalFileStat>;
281
+ mkdir(relativePath?: string): Promise<string>;
282
+ list(relativePath?: string, options?: LocalListOptions): Promise<LocalFileStat[]>;
283
+ listEntries(relativePath?: string, options?: LocalListOptions): Promise<LocalEntryList>;
284
+ searchEntries(params: LocalSearchEntriesParams): Promise<LocalEntryList>;
285
+ readText(relativePath: string): Promise<string>;
286
+ readJSON<T = unknown>(relativePath: string): Promise<T>;
287
+ readBytes(relativePath: string): Promise<Uint8Array>;
288
+ readFile(relativePath: string, params: LocalReadFileRawParams): Promise<LocalFileRaw>;
289
+ readFile(relativePath: string, params?: LocalReadFileParams): Promise<LocalFileDeliver>;
290
+ writeText(relativePath: string, content: string, options?: {
291
+ atomic?: boolean;
292
+ }): Promise<string>;
293
+ writeJSON(relativePath: string, value: unknown, options?: {
294
+ pretty?: boolean;
295
+ atomic?: boolean;
296
+ }): Promise<string>;
297
+ writeBytes(relativePath: string, content: Uint8Array, options?: {
298
+ atomic?: boolean;
299
+ }): Promise<string>;
300
+ writeFile(relativePath: string, content: string | Uint8Array, options?: {
301
+ atomic?: boolean;
302
+ }): Promise<LocalFileWrite>;
303
+ remove(relativePath: string): Promise<void>;
304
+ deletePath(relativePath: string): Promise<LocalPathDelete>;
305
+ createDirectory(relativePath?: string): Promise<{
306
+ path: string;
307
+ }>;
308
+ copy(fromRelativePath: string, toRelativePath: string): Promise<string>;
309
+ readLines(relativePath: string, params: LocalReadLinesParams): Promise<LocalFileLines>;
310
+ patchLines(relativePath: string, params: LocalPatchLinesParams): Promise<LocalFileLinesPatch>;
311
+ grep(params: LocalGrepParams): Promise<LocalGrepResponse>;
312
+ summarize(params?: LocalSummarizeParams): Promise<LocalSummary>;
313
+ private walk;
314
+ }
315
+ export declare class LocalConfigStore {
316
+ readonly files: LocalFileStore;
317
+ constructor(files: LocalFileStore);
318
+ read<T = Record<string, unknown>>(name?: string, fallback?: T): Promise<T>;
319
+ write(name: string, value: unknown): Promise<string>;
320
+ get<T = unknown>(name: string, key: string, fallback?: T): Promise<T>;
321
+ set(name: string, key: string, value: unknown): Promise<string>;
322
+ delete(name: string, key: string): Promise<string>;
323
+ private readRecord;
324
+ }
325
+ export declare class LocalWorkspaceManager {
326
+ open(root: string, options?: LocalWorkspaceOptions): LocalWorkspace;
327
+ }
328
+ export declare class LocalWorkspace {
329
+ readonly root: string;
330
+ readonly name: string;
331
+ readonly metadata: Record<string, unknown>;
332
+ readonly trusted: boolean;
333
+ readonly files: LocalFileStore;
334
+ readonly ignore: LocalIgnoreRule[];
335
+ readonly gitignore: boolean;
336
+ readonly maxFileBytes: number;
337
+ constructor(root: string, options?: LocalWorkspaceOptions);
338
+ ensure(): Promise<void>;
339
+ loadIgnoreFiles(files?: string[]): Promise<LocalIgnoreRule[]>;
340
+ child(relativePath: string, options?: LocalWorkspaceOptions): LocalWorkspace;
341
+ resolvePath(relativePath?: string): string;
342
+ list(relativePath?: string, options?: LocalListOptions): Promise<LocalFileStat[]>;
343
+ listEntries(relativePath?: string, options?: LocalListOptions): Promise<LocalEntryList>;
344
+ searchEntries(params: LocalSearchEntriesParams): Promise<LocalEntryList>;
345
+ readFile(relativePath: string, params: LocalReadFileRawParams): Promise<LocalFileRaw>;
346
+ readFile(relativePath: string, params?: LocalReadFileParams): Promise<LocalFileDeliver>;
347
+ writeFile(relativePath: string, content: string | Uint8Array, options?: {
348
+ atomic?: boolean;
349
+ }): Promise<LocalFileWrite>;
350
+ readText(relativePath: string): Promise<string>;
351
+ writeText(relativePath: string, content: string, options?: {
352
+ atomic?: boolean;
353
+ }): Promise<string>;
354
+ deletePath(relativePath: string): Promise<LocalPathDelete>;
355
+ createDirectory(relativePath?: string): Promise<{
356
+ path: string;
357
+ }>;
358
+ readLines(relativePath: string, params: LocalReadLinesParams): Promise<LocalFileLines>;
359
+ previewPatchLines(relativePath: string, params: LocalPatchLinesParams): Promise<LocalLinePatchPreview>;
360
+ patchLines(relativePath: string, params: LocalPatchLinesParams): Promise<LocalFileLinesPatch>;
361
+ previewEdits(edits: LocalWorkspaceLineEdit[]): Promise<LocalWorkspaceEditPlan>;
362
+ applyEdits(edits: LocalWorkspaceLineEdit[]): Promise<LocalWorkspaceEditResult>;
363
+ classifyPath(relativePath: string): LocalPathSensitivityInfo;
364
+ grep(params: LocalGrepParams): Promise<LocalGrepResponse>;
365
+ summarize(params?: LocalSummarizeParams): Promise<LocalSummary>;
366
+ snapshot(params?: LocalWorkspaceSnapshotParams): Promise<LocalWorkspaceSnapshot>;
367
+ diff(before: LocalWorkspaceSnapshot, after: LocalWorkspaceSnapshot): LocalWorkspaceDiff;
368
+ watch(onEvent: (event: LocalWorkspaceWatchEvent) => void, options?: {
369
+ recursive?: boolean;
370
+ }): LocalWorkspaceWatcher;
371
+ private scopedListOptions;
372
+ private mergeIgnore;
373
+ private assertAllowed;
374
+ private assertExpectedHash;
375
+ }
376
+ export declare class LocalSkillStore {
377
+ readonly files: LocalFileStore;
378
+ constructor(files: LocalFileStore);
379
+ fromDirectory(rootDir: string, options?: LocalSkillDirectoryOptions): Promise<LocalSkillDescriptor>;
380
+ discover(options?: LocalSkillDiscoveryOptions): Promise<LocalSkillDescriptor[]>;
381
+ }
382
+ export declare function classifyLocalPathSensitivity(relativePath: string): LocalPathSensitivityInfo;