@agent-api/sdk 1.0.8 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog — @agent-api/sdk
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Added
6
+
7
+ - Node-only `@agent-api/sdk/local` entrypoint for framework-neutral local app and CLI runtime support.
8
+ - Cross-platform app directory resolution for data, config, cache, logs, and temp files.
9
+ - Root-scoped local file stores with path traversal protection, atomic writes, JSON helpers, recursive listing, and local skill discovery.
10
+ - Local workdir operations for entry search, file delivery, line-range reads and edits, literal grep, and directory summaries.
11
+ - `LocalWorkspace` and `LocalWorkspaceManager` for project roots, default ignore rules, patch previews, snapshots, diffs, and file-watch handles.
12
+ - Typed local errors, `.gitignore` loading, sensitivity classification for likely secret paths, and multi-file line-edit plans with conflict detection and rollback.
13
+ - `createLocalContextPackage()` for bounded, secret-aware local workspace manifests that app integrations can hand to agent workflows.
14
+
15
+ ### Changed
16
+
17
+ - Split the local SDK source behind a small `@agent-api/sdk/local` barrel so runtime and context APIs can grow without a monolithic entrypoint.
18
+
3
19
  ## 1.0.8
4
20
 
5
21
  ### Changed
package/README.md CHANGED
@@ -96,6 +96,93 @@ const response = await client.responses.create({
96
96
  });
97
97
  ```
98
98
 
99
+ ## Local Runtime
100
+
101
+ Local app integrations can use the Node-only `@agent-api/sdk/local` entrypoint for core filesystem/runtime support. This layer is framework-neutral: it does not depend on Electron, Tauri, native UI kits, or browser APIs.
102
+
103
+ ```typescript
104
+ import { createLocalRuntime } from "@agent-api/sdk/local";
105
+
106
+ const local = createLocalRuntime({
107
+ appName: "agent-studio",
108
+ });
109
+
110
+ await local.ensure();
111
+
112
+ await local.config.set("settings.json", "baseURL", "https://api.agentsway.dev");
113
+ const baseURL = await local.config.get<string>("settings.json", "baseURL");
114
+
115
+ await local.cache.writeJSON("models.json", [{ id: "openai/gpt-5.5" }]);
116
+ const skills = await local.skills.discover();
117
+ ```
118
+
119
+ The runtime provides:
120
+
121
+ - Cross-platform app directories for data, config, cache, logs, and temp files.
122
+ - Root-scoped file stores with path traversal protection.
123
+ - Atomic text/JSON writes, byte reads/writes, recursive listing, copy, remove, and stat helpers.
124
+ - Local workdir operations inspired by platform volumes: `listEntries`, `searchEntries`, `readFile`, `writeFile`, `deletePath`, `createDirectory`, `readLines`, `patchLines`, `grep`, and `summarize`.
125
+ - First-class local workspaces with default ignore rules, scoped workbench operations, patch previews, snapshots, diffs, file-watch handles, and budgeted context packaging.
126
+ - Typed local errors, `.gitignore` loading, sensitivity classification, and multi-file edit plans with rollback on failure.
127
+ - JSON config helpers for typed app settings.
128
+ - Local skill discovery built on `localSkillFromDirectory()`.
129
+
130
+ Keep UI and OS interaction policy in your host framework. Electron, Tauri, Qt, or native apps should call this layer from their trusted local process and expose only the capabilities their UI needs.
131
+
132
+ ```typescript
133
+ const workspace = local.data.child("workspaces/demo");
134
+
135
+ await workspace.writeText("src/index.ts", "console.log('hello');\n");
136
+
137
+ const matches = await workspace.grep({ pattern: "hello", path: "src" });
138
+ const lines = await workspace.readLines("src/index.ts", { startLine: 1, endLine: 20 });
139
+ await workspace.patchLines("src/index.ts", {
140
+ startLine: 1,
141
+ replacement: "console.log('patched');",
142
+ });
143
+
144
+ const summary = await workspace.summarize();
145
+ ```
146
+
147
+ For project/workspace roots, prefer `local.workspace()` so SDK defaults protect common generated directories such as `.git`, `node_modules`, `dist`, and build caches.
148
+
149
+ ```typescript
150
+ const project = local.workspace("/path/to/project", {
151
+ name: "my-project",
152
+ trusted: true,
153
+ ignore: ["vendor", /^tmp\//],
154
+ });
155
+ await project.loadIgnoreFiles();
156
+
157
+ const before = await project.snapshot();
158
+ const plan = await project.previewEdits([
159
+ {
160
+ path: "src/index.ts",
161
+ startLine: 1,
162
+ endLine: 1,
163
+ replacement: "console.log('patched');",
164
+ },
165
+ ]);
166
+ await project.applyEdits(plan.edits);
167
+ const after = await project.snapshot();
168
+ const diff = project.diff(before, after);
169
+
170
+ const sensitivity = project.classifyPath(".env");
171
+ ```
172
+
173
+ Use `createLocalContextPackage()` when a local app needs to prepare bounded workspace context for an agent request. The package includes a manifest, selected file previews, optional search matches, hashes, sensitivity labels, and secret-aware omission by default.
174
+
175
+ ```typescript
176
+ import { createLocalContextPackage } from "@agent-api/sdk/local";
177
+
178
+ const context = await createLocalContextPackage(project, {
179
+ query: "billing",
180
+ includeSearch: true,
181
+ maxFiles: 80,
182
+ maxBytes: 256 * 1024,
183
+ });
184
+ ```
185
+
99
186
  ## Production features
100
187
 
101
188
  - **Retries:** automatic exponential backoff for network failures, 429, and 5xx (default 2 retries).
@@ -0,0 +1,49 @@
1
+ import { type LocalFileDeliver, type LocalGrepResponse, type LocalPathSensitivity, type LocalPathSensitivityInfo, type LocalSummary, type LocalWorkspace, type LocalWorkspaceSnapshotFile } from "./core.js";
2
+ export interface LocalContextPackageParams {
3
+ path?: string;
4
+ include?: string[];
5
+ exclude?: string[];
6
+ query?: string;
7
+ maxFiles?: number;
8
+ maxBytes?: number;
9
+ maxBytesPerFile?: number;
10
+ previewBytes?: number;
11
+ includeContent?: boolean;
12
+ includeHashes?: boolean;
13
+ includeSummary?: boolean;
14
+ includeSearch?: boolean;
15
+ includeSecrets?: boolean;
16
+ }
17
+ export interface LocalContextFile {
18
+ path: string;
19
+ size: number;
20
+ sha256?: string;
21
+ mime_type?: string;
22
+ sensitivity: LocalPathSensitivity;
23
+ sensitivity_reason?: string;
24
+ content?: string;
25
+ content_base64?: string;
26
+ encoding?: LocalFileDeliver["encoding"];
27
+ truncated?: boolean;
28
+ omitted_reason?: string;
29
+ }
30
+ export interface LocalContextManifest {
31
+ object: "local_context_manifest";
32
+ root: string;
33
+ workspace_name: string;
34
+ generated_at_unix: number;
35
+ base_path: string;
36
+ file_count: number;
37
+ total_bytes: number;
38
+ included_bytes: number;
39
+ truncated: boolean;
40
+ files: LocalContextFile[];
41
+ summary?: LocalSummary;
42
+ search?: LocalGrepResponse;
43
+ }
44
+ export declare function createLocalContextPackage(workspace: LocalWorkspace, params?: LocalContextPackageParams): Promise<LocalContextManifest>;
45
+ export declare function summarizeLocalContextSensitivity(files: Array<Pick<LocalContextFile, "path" | "sensitivity" | "sensitivity_reason">>): {
46
+ highest: LocalPathSensitivity;
47
+ files: LocalPathSensitivityInfo[];
48
+ };
49
+ export type LocalContextSnapshotFile = LocalWorkspaceSnapshotFile;
@@ -0,0 +1,154 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFile } from "node:fs/promises";
3
+ import { classifyLocalPathSensitivity, } from "./core.js";
4
+ export async function createLocalContextPackage(workspace, params = {}) {
5
+ const basePath = params.path ?? ".";
6
+ const maxFiles = positiveInt(params.maxFiles, 80);
7
+ const maxBytes = positiveInt(params.maxBytes, 256 * 1024);
8
+ const maxBytesPerFile = positiveInt(params.maxBytesPerFile, 32 * 1024);
9
+ const previewBytes = positiveInt(params.previewBytes, maxBytesPerFile);
10
+ const includeContent = params.includeContent ?? true;
11
+ const includeHashes = params.includeHashes ?? true;
12
+ const includeSummary = params.includeSummary ?? true;
13
+ const includeSearch = Boolean(params.includeSearch && params.query?.trim());
14
+ const includeSecrets = params.includeSecrets ?? false;
15
+ const stats = await workspace.list(basePath, { recursive: true });
16
+ const fileStats = stats
17
+ .filter((item) => item.type === "file")
18
+ .filter((item) => matchesPathFilters(item.path, params.include, params.exclude))
19
+ .sort((a, b) => a.path.localeCompare(b.path));
20
+ const files = [];
21
+ let includedBytes = 0;
22
+ let truncated = fileStats.length > maxFiles;
23
+ for (const item of fileStats.slice(0, maxFiles)) {
24
+ const sensitivity = classifyLocalPathSensitivity(item.path);
25
+ const baseFile = {
26
+ path: item.path,
27
+ size: item.size,
28
+ sensitivity: sensitivity.sensitivity,
29
+ sensitivity_reason: sensitivity.reason,
30
+ };
31
+ if (!includeSecrets && sensitivity.sensitivity === "secret") {
32
+ files.push({ ...baseFile, omitted_reason: "secret_path" });
33
+ continue;
34
+ }
35
+ if (item.size > maxBytesPerFile) {
36
+ files.push({ ...baseFile, omitted_reason: "file_too_large" });
37
+ truncated = true;
38
+ continue;
39
+ }
40
+ if (includedBytes >= maxBytes) {
41
+ files.push({ ...baseFile, omitted_reason: "package_budget_exceeded" });
42
+ truncated = true;
43
+ continue;
44
+ }
45
+ const remaining = maxBytes - includedBytes;
46
+ const readBudget = Math.min(previewBytes, maxBytesPerFile, remaining);
47
+ if (readBudget <= 0) {
48
+ files.push({ ...baseFile, omitted_reason: "package_budget_exceeded" });
49
+ truncated = true;
50
+ continue;
51
+ }
52
+ const delivered = await workspace.readFile(item.path, { maxBytes: readBudget });
53
+ includedBytes += delivered.encoding === "text"
54
+ ? Buffer.byteLength(delivered.content ?? "", "utf8")
55
+ : Buffer.byteLength(delivered.content_base64 ?? "", "base64");
56
+ const packaged = {
57
+ ...baseFile,
58
+ mime_type: delivered.mime_type,
59
+ encoding: delivered.encoding,
60
+ truncated: delivered.truncated || undefined,
61
+ };
62
+ if (includeContent) {
63
+ packaged.content = delivered.content;
64
+ packaged.content_base64 = delivered.content_base64;
65
+ }
66
+ if (includeHashes) {
67
+ packaged.sha256 = await sha256File(workspace, item.path);
68
+ }
69
+ if (delivered.truncated) {
70
+ truncated = true;
71
+ }
72
+ files.push(packaged);
73
+ }
74
+ const summary = includeSummary
75
+ ? await workspace.summarize({
76
+ path: basePath,
77
+ maxFiles,
78
+ previewBytes,
79
+ ignore: params.exclude,
80
+ })
81
+ : undefined;
82
+ const search = includeSearch
83
+ ? await workspace.grep({
84
+ pattern: params.query,
85
+ path: basePath,
86
+ limit: maxFiles,
87
+ maxBytesPerFile,
88
+ ignore: params.exclude,
89
+ })
90
+ : undefined;
91
+ return {
92
+ object: "local_context_manifest",
93
+ root: workspace.root,
94
+ workspace_name: workspace.name,
95
+ generated_at_unix: Math.floor(Date.now() / 1000),
96
+ base_path: basePath,
97
+ file_count: fileStats.length,
98
+ total_bytes: fileStats.reduce((sum, item) => sum + item.size, 0),
99
+ included_bytes: includedBytes,
100
+ truncated,
101
+ files,
102
+ summary,
103
+ search,
104
+ };
105
+ }
106
+ export function summarizeLocalContextSensitivity(files) {
107
+ const order = { normal: 0, sensitive: 1, secret: 2 };
108
+ let highest = "normal";
109
+ const sensitiveFiles = [];
110
+ for (const file of files) {
111
+ if (order[file.sensitivity] > order[highest]) {
112
+ highest = file.sensitivity;
113
+ }
114
+ if (file.sensitivity !== "normal") {
115
+ sensitiveFiles.push({
116
+ path: file.path,
117
+ sensitivity: file.sensitivity,
118
+ reason: file.sensitivity_reason,
119
+ });
120
+ }
121
+ }
122
+ return { highest, files: sensitiveFiles };
123
+ }
124
+ function matchesPathFilters(relativePath, include, exclude) {
125
+ if (include?.length && !include.some((pattern) => pathMatches(relativePath, pattern))) {
126
+ return false;
127
+ }
128
+ if (exclude?.some((pattern) => pathMatches(relativePath, pattern))) {
129
+ return false;
130
+ }
131
+ return true;
132
+ }
133
+ function pathMatches(relativePath, pattern) {
134
+ const clean = pattern.replace(/\\/g, "/").replace(/^\/+/, "");
135
+ if (!clean || clean === ".") {
136
+ return true;
137
+ }
138
+ if (!clean.includes("*")) {
139
+ return relativePath === clean || relativePath.startsWith(`${clean}/`);
140
+ }
141
+ const escaped = clean
142
+ .split("*")
143
+ .map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&"))
144
+ .join(".*");
145
+ return new RegExp(`^${escaped}$`).test(relativePath);
146
+ }
147
+ function positiveInt(value, fallback) {
148
+ const parsed = Number(value);
149
+ return Number.isFinite(parsed) && parsed > 0 ? Math.trunc(parsed) : fallback;
150
+ }
151
+ async function sha256File(workspace, relativePath) {
152
+ const fullPath = workspace.files.resolvePath(relativePath);
153
+ return createHash("sha256").update(await readFile(fullPath)).digest("hex");
154
+ }
@@ -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;