@theokit/sdk 2.27.0 → 2.29.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 +34 -0
- package/dist/a2a/index.cjs +373 -17
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +373 -17
- package/dist/a2a/index.js.map +1 -1
- package/dist/{cron-BR1NCSk1.d.cts → cron-COSAehOL.d.ts} +110 -3
- package/dist/{cron-DgEQCJ2i.d.ts → cron-yJoNUZxe.d.cts} +110 -3
- package/dist/cron.cjs +914 -508
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +915 -509
- package/dist/cron.js.map +1 -1
- package/dist/{errors-CbY3pxY7.d.ts → errors-BxMIlgLP.d.ts} +1 -1
- package/dist/{errors-DLMNb4Ka.d.cts → errors-tP-8O-hR.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +914 -508
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +915 -509
- package/dist/eval.js.map +1 -1
- package/dist/filesystem/index.cjs +304 -0
- package/dist/filesystem/index.cjs.map +1 -0
- package/dist/filesystem/index.d.cts +12 -0
- package/dist/filesystem/index.d.ts +12 -0
- package/dist/filesystem/index.js +295 -0
- package/dist/filesystem/index.js.map +1 -0
- package/dist/filesystem/local-filesystem.d.cts +36 -0
- package/dist/filesystem/local-filesystem.d.ts +36 -0
- package/dist/filesystem/types.d.cts +118 -0
- package/dist/filesystem/types.d.ts +118 -0
- package/dist/index.cjs +973 -570
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +972 -568
- package/dist/index.js.map +1 -1
- package/dist/internal/persistence/conversation-storage-fs.d.cts +4 -0
- package/dist/internal/persistence/conversation-storage-fs.d.ts +4 -0
- package/dist/internal/persistence/conversation-storage-memory.d.cts +4 -0
- package/dist/internal/persistence/conversation-storage-memory.d.ts +4 -0
- package/dist/internal/persistence/objective-coerce.d.cts +9 -0
- package/dist/internal/persistence/objective-coerce.d.ts +9 -0
- package/dist/internal/runtime/lifecycle/wrap-completion-check-run.d.ts +30 -0
- package/dist/internal/runtime/local-agent/local-agent-goal-extensions.d.ts +80 -0
- package/dist/internal/runtime/objective/objective-store.d.ts +33 -0
- package/dist/{run-CdWiihyU.d.cts → run-q_P0vHlY.d.cts} +71 -2
- package/dist/{run-CdWiihyU.d.ts → run-q_P0vHlY.d.ts} +71 -2
- package/dist/types/agent.d.ts +32 -1
- package/dist/types/conversation-storage.d.ts +23 -0
- package/dist/types/goal-events.d.ts +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/objective.d.ts +45 -0
- package/dist/types/run-events.d.ts +12 -1
- package/dist/types/run.d.ts +58 -0
- package/package.json +11 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filesystem backend protocol — a pluggable file *storage* provider for agent
|
|
3
|
+
* tools, the storage-side twin of {@link SandboxBackend} (execution-side).
|
|
4
|
+
*
|
|
5
|
+
* SE31 (Mastra Workspaces comparison). Mirrors `SandboxBackend`'s shape: a small
|
|
6
|
+
* set of abstract methods (`readFile` / `writeFile` / `stat` / `list`) with
|
|
7
|
+
* `exists()` derived on the base class, a boundary `basePath`, a `readOnly`
|
|
8
|
+
* flag, and typed errors. Unlike `SandboxBackend` (whose file ops shell out via
|
|
9
|
+
* `execute`, requiring command execution and giving NO structured `stat`), a
|
|
10
|
+
* `FilesystemBackend` serves a *filesystem-only* workspace with no sandbox and
|
|
11
|
+
* exposes a real `stat().mtimeMs` — the primitive SE32's read-before-write
|
|
12
|
+
* safety compares against. See ADR 0011.
|
|
13
|
+
*
|
|
14
|
+
* New backends (S3, GCS, in-memory) implement the four abstract methods; higher
|
|
15
|
+
* level helpers derive on the base. This is the backend *seam* — it does NOT
|
|
16
|
+
* ship agent-facing tools nor a bundled workspace (bring-your-own-tools stands).
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
/** Structured file metadata. `mtimeMs` is the read-before-write oracle (SE32). */
|
|
21
|
+
export interface FileStat {
|
|
22
|
+
readonly size: number;
|
|
23
|
+
readonly mtimeMs: number;
|
|
24
|
+
readonly isFile: boolean;
|
|
25
|
+
readonly isDirectory: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Options a write may carry. SE32 adds `expectedMtime` (stale-write guard). */
|
|
28
|
+
export interface WriteFileOptions {
|
|
29
|
+
/**
|
|
30
|
+
* SE32 — when set, the write fails with {@link StaleFileError} if the file's
|
|
31
|
+
* current `mtimeMs` differs (someone changed it since it was last read).
|
|
32
|
+
*/
|
|
33
|
+
readonly expectedMtime?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface FilesystemConfig {
|
|
36
|
+
/** Boundary root. Every path is resolved within it; escapes are rejected. */
|
|
37
|
+
readonly basePath?: string;
|
|
38
|
+
/** When true, every write throws {@link FilesystemReadOnlyError}. */
|
|
39
|
+
readonly readOnly?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/** A path escaped the backend's `basePath` (traversal or symlink). */
|
|
42
|
+
export declare class FilesystemSecurityError extends Error {
|
|
43
|
+
readonly code: "filesystem_security";
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
/** A write was attempted on a read-only backend. */
|
|
47
|
+
export declare class FilesystemReadOnlyError extends Error {
|
|
48
|
+
readonly code: "filesystem_readonly";
|
|
49
|
+
constructor(message: string);
|
|
50
|
+
}
|
|
51
|
+
/** A read/stat targeted a path that does not exist. */
|
|
52
|
+
export declare class FileNotFoundError extends Error {
|
|
53
|
+
readonly path: string;
|
|
54
|
+
readonly code: "filesystem_not_found";
|
|
55
|
+
constructor(path: string);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A filesystem I/O operation failed for a reason other than not-found /
|
|
59
|
+
* read-only / stale / security (e.g. `ENOTDIR` — a path component is a file, or
|
|
60
|
+
* `EACCES` / `ENOSPC`). Carries the original error as `cause` so no raw,
|
|
61
|
+
* untyped Node `SystemError` ever escapes the backend (Unbreakable Rule 8).
|
|
62
|
+
*/
|
|
63
|
+
export declare class FilesystemError extends Error {
|
|
64
|
+
readonly path: string;
|
|
65
|
+
readonly code: "filesystem_io";
|
|
66
|
+
constructor(path: string, cause: unknown);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* SE32 — a write's `expectedMtime` did not match the file's current mtime: the
|
|
70
|
+
* file changed since it was last read, so the write would silently clobber.
|
|
71
|
+
*/
|
|
72
|
+
export declare class StaleFileError extends Error {
|
|
73
|
+
readonly path: string;
|
|
74
|
+
readonly expectedMtime: number;
|
|
75
|
+
readonly actualMtime: number;
|
|
76
|
+
readonly code: "filesystem_stale";
|
|
77
|
+
constructor(path: string, expectedMtime: number, actualMtime: number);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Pluggable filesystem backend. Implement the four abstract methods; `exists()`
|
|
81
|
+
* and the `readOnly`/`basePath` accessors derive on the base class.
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export declare abstract class FilesystemBackend {
|
|
86
|
+
protected readonly _basePath: string;
|
|
87
|
+
protected readonly _readOnly: boolean;
|
|
88
|
+
constructor(config?: FilesystemConfig);
|
|
89
|
+
/** Read a boundary-relative file as UTF-8. Throws {@link FileNotFoundError}. */
|
|
90
|
+
abstract readFile(path: string): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Write UTF-8 content to a boundary-relative path (creating parents). Returns
|
|
93
|
+
* the new {@link FileStat}. Throws {@link FilesystemReadOnlyError} on a
|
|
94
|
+
* read-only backend and {@link StaleFileError} when `opts.expectedMtime`
|
|
95
|
+
* mismatches (SE32).
|
|
96
|
+
*/
|
|
97
|
+
abstract writeFile(path: string, content: string, opts?: WriteFileOptions): Promise<FileStat>;
|
|
98
|
+
/** Structured metadata for a path. Throws {@link FileNotFoundError}. */
|
|
99
|
+
abstract stat(path: string): Promise<FileStat>;
|
|
100
|
+
/** Directory entry names (not recursive). Throws {@link FileNotFoundError}. */
|
|
101
|
+
abstract list(path: string): Promise<string[]>;
|
|
102
|
+
/** Derived — true iff `stat(path)` resolves (absent ⇒ false). */
|
|
103
|
+
exists(path: string): Promise<boolean>;
|
|
104
|
+
/** Throw {@link FilesystemReadOnlyError} when the backend is read-only. */
|
|
105
|
+
protected assertWritable(): void;
|
|
106
|
+
get readOnly(): boolean;
|
|
107
|
+
get basePath(): string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A backend OR a per-request resolver of one. A resolver runs at tool-execution
|
|
111
|
+
* time (the request scope), so multi-tenant / multi-role agents get a distinct
|
|
112
|
+
* root or permission set per request without a shared mutable backend.
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export type FilesystemProvider<Ctx = unknown> = FilesystemBackend | ((ctx: Ctx) => FilesystemBackend | Promise<FilesystemBackend>);
|
|
117
|
+
/** Resolve a {@link FilesystemProvider} to a concrete backend for `ctx`. */
|
|
118
|
+
export declare function resolveFilesystem<Ctx>(provider: FilesystemProvider<Ctx>, ctx: Ctx): Promise<FilesystemBackend>;
|