@temporalio/agent-harness 0.0.0-stage → 0.2.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/README.md +5 -2
- package/dist/src/ai-sdks/google-genai-plugin/index.d.ts +6 -0
- package/dist/src/ai-sdks/google-genai-plugin/index.js +24 -0
- package/dist/src/ai-sdks/google-genai-plugin/interactions-conversation.d.ts +35 -0
- package/dist/src/ai-sdks/google-genai-plugin/interactions-conversation.js +178 -0
- package/dist/src/ai-sdks/google-genai-plugin/interactions-models.d.ts +8 -0
- package/dist/src/ai-sdks/google-genai-plugin/interactions-models.js +4 -0
- package/dist/src/ai-sdks/google-genai-plugin/interactions-workflow.d.ts +8 -0
- package/dist/src/ai-sdks/google-genai-plugin/interactions-workflow.js +15 -0
- package/dist/src/ai-sdks/google-genai-plugin/temporal-async-client.d.ts +10 -0
- package/dist/src/ai-sdks/google-genai-plugin/temporal-async-client.js +9 -0
- package/dist/src/ai-sdks/google-genai-plugin/temporal-interactions.d.ts +31 -0
- package/dist/src/ai-sdks/google-genai-plugin/temporal-interactions.js +43 -0
- package/dist/src/ai-sdks/google-genai-plugin/workflow.d.ts +16 -0
- package/dist/src/ai-sdks/google-genai-plugin/workflow.js +14 -0
- package/dist/src/ai-sdks/jev/evaluator.d.ts +38 -0
- package/dist/src/ai-sdks/jev/evaluator.js +155 -0
- package/dist/src/ai-sdks/openai-agents-harness.d.ts +94 -0
- package/dist/src/ai-sdks/openai-agents-harness.js +347 -0
- package/dist/src/harness/agent-protocol/agent-interface.d.ts +369 -0
- package/dist/src/harness/agent-protocol/agent-interface.js +222 -0
- package/dist/src/harness/agent-protocol/events.d.ts +10 -0
- package/dist/src/harness/agent-protocol/events.js +6 -0
- package/dist/src/harness/agent-protocol/index.d.ts +5 -0
- package/dist/src/harness/agent-protocol/index.js +7 -0
- package/dist/src/harness/agent-protocol/schema.d.ts +34 -0
- package/dist/src/harness/agent-protocol/schema.js +53 -0
- package/dist/src/harness/agent-protocol/subagent-interface.d.ts +25 -0
- package/dist/src/harness/agent-protocol/subagent-interface.js +17 -0
- package/dist/src/harness/agent-schema.d.ts +4 -0
- package/dist/src/harness/agent-schema.js +106 -0
- package/dist/src/harness/agent-workflow/errors.d.ts +26 -0
- package/dist/src/harness/agent-workflow/errors.js +67 -0
- package/dist/src/harness/agent-workflow/types.d.ts +88 -0
- package/dist/src/harness/agent-workflow/types.js +1 -0
- package/dist/src/harness/agent-workflow.d.ts +79 -0
- package/dist/src/harness/agent-workflow.js +824 -0
- package/dist/src/harness/agent.d.ts +137 -0
- package/dist/src/harness/agent.js +272 -0
- package/dist/src/harness/code-mode/activity-fs.d.ts +46 -0
- package/dist/src/harness/code-mode/activity-fs.js +102 -0
- package/dist/src/harness/code-mode/base64.d.ts +2 -0
- package/dist/src/harness/code-mode/base64.js +41 -0
- package/dist/src/harness/code-mode/driver.d.ts +78 -0
- package/dist/src/harness/code-mode/driver.js +266 -0
- package/dist/src/harness/code-mode/index.d.ts +4 -0
- package/dist/src/harness/code-mode/index.js +6 -0
- package/dist/src/harness/code-mode/mount-decl.d.ts +43 -0
- package/dist/src/harness/code-mode/mount-decl.js +100 -0
- package/dist/src/harness/code-mode/okf-tool.d.ts +10 -0
- package/dist/src/harness/code-mode/okf-tool.js +89 -0
- package/dist/src/harness/code-mode/okf.d.ts +91 -0
- package/dist/src/harness/code-mode/okf.js +315 -0
- package/dist/src/harness/code-mode/stubs.d.ts +13 -0
- package/dist/src/harness/code-mode/stubs.js +203 -0
- package/dist/src/harness/code-mode/texts.d.ts +4 -0
- package/dist/src/harness/code-mode/texts.js +6 -0
- package/dist/src/harness/code-mode/tool.d.ts +37 -0
- package/dist/src/harness/code-mode/tool.js +79 -0
- package/dist/src/harness/code-mode/vfs.d.ts +209 -0
- package/dist/src/harness/code-mode/vfs.js +862 -0
- package/dist/src/harness/py-repr.d.ts +2 -0
- package/dist/src/harness/py-repr.js +24 -0
- package/dist/src/harness/state/index.d.ts +40 -0
- package/dist/src/harness/state/index.js +142 -0
- package/dist/src/harness/stream-context.d.ts +8 -0
- package/dist/src/harness/stream-context.js +9 -0
- package/dist/src/harness/subagent-toolset.d.ts +29 -0
- package/dist/src/harness/subagent-toolset.js +87 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +13 -0
- package/dist/src/sandbox.d.ts +12 -0
- package/package.json +95 -3
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { ApplicationFailure } from "@temporalio/workflow";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { type AnyHarnessTool } from "../agent.ts";
|
|
4
|
+
import type { StateRef } from "../state/index.ts";
|
|
5
|
+
/** What a backend reports about one path. */
|
|
6
|
+
export interface FileStat {
|
|
7
|
+
is_dir: boolean;
|
|
8
|
+
size?: number;
|
|
9
|
+
/** Unix seconds. Absent until a stat says; `0` is treated as unknown by an index. */
|
|
10
|
+
mtime?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Storage behind a `Mount`. Methods are awaited in workflow code, so their bodies must be
|
|
14
|
+
* workflow-safe. Paths are relative to the mount and normalized; the mount's root is ".". Throw
|
|
15
|
+
* `osError(...)` for failures; from an activity, throw an `ApplicationFailure` whose `type` is the
|
|
16
|
+
* built-in name (`FileNotFoundError`, ...), and the script sees the built-in exception.
|
|
17
|
+
* `write`, `mkdir`, `delete` and `rename` are only needed for a writable mount.
|
|
18
|
+
*/
|
|
19
|
+
export interface FileSystem {
|
|
20
|
+
stat(path: string): Promise<FileStat | null>;
|
|
21
|
+
read(path: string): Promise<Uint8Array>;
|
|
22
|
+
list(path: string): Promise<string[]>;
|
|
23
|
+
write?(path: string, data: Uint8Array): Promise<void>;
|
|
24
|
+
mkdir?(path: string): Promise<void>;
|
|
25
|
+
delete?(path: string): Promise<void>;
|
|
26
|
+
rename?(path: string, target: string): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export declare const ROOT = ".";
|
|
29
|
+
/** The Python `OSError` subclasses a failed file operation raises inside the script. */
|
|
30
|
+
export type OsErrorType = "OSError" | "FileNotFoundError" | "FileExistsError" | "IsADirectoryError" | "NotADirectoryError" | "PermissionError";
|
|
31
|
+
/** A failure the script sees as the built-in `type`, with Python's message for `errno` and `path`. */
|
|
32
|
+
export declare function osError(type: OsErrorType, errno: number, path: string, strerror?: string): ApplicationFailure;
|
|
33
|
+
/**
|
|
34
|
+
* An OS error thrown by activity filesystem code (disk, a walk). The activity wrapper turns it
|
|
35
|
+
* into an `ApplicationFailure` the script sees as the built-in of the same name.
|
|
36
|
+
*/
|
|
37
|
+
export declare class FsError extends Error {
|
|
38
|
+
readonly fsType: OsErrorType;
|
|
39
|
+
readonly errno: number;
|
|
40
|
+
readonly strerror: string;
|
|
41
|
+
readonly path: string;
|
|
42
|
+
constructor(fsType: OsErrorType, errno: number, strerror: string, path: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A `FileSystem` at a virtual path inside the sandbox. `path` is absolute and normalized
|
|
46
|
+
* (`/skills`, not `/skills/`). `readOnly` is enforced before any backend call. `description` is
|
|
47
|
+
* shown to the model next to the mount, so say what is there and how to use it.
|
|
48
|
+
*/
|
|
49
|
+
export declare class Mount {
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly backend: FileSystem;
|
|
52
|
+
readonly readOnly: boolean;
|
|
53
|
+
readonly description: string;
|
|
54
|
+
/** Set for an activity-backed mount, so successful operations update its FileIndex. */
|
|
55
|
+
readonly tracked: IndexTrack | null;
|
|
56
|
+
constructor(path: string, backend: FileSystem, { readOnly, description, tracked, }?: {
|
|
57
|
+
readOnly?: boolean;
|
|
58
|
+
description?: string;
|
|
59
|
+
tracked?: IndexTrack | null;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** Reject mounts that repeat or nest, so every path belongs to at most one mount. */
|
|
63
|
+
export declare function validateMounts(mounts: readonly Mount[]): readonly Mount[];
|
|
64
|
+
/** The mount `path` falls in and the path relative to it, matching whole segments; null outside every mount. */
|
|
65
|
+
export declare function route(mounts: readonly Mount[], path: string): {
|
|
66
|
+
mount: Mount;
|
|
67
|
+
relative: string;
|
|
68
|
+
} | null;
|
|
69
|
+
/** Monty's file operations. Every other OS call (clock, entropy, environment) is not a file one. */
|
|
70
|
+
export declare const FILE_OPERATIONS: Set<string>;
|
|
71
|
+
/** Bytes as they cross an activity boundary. */
|
|
72
|
+
export interface EncodedBytes {
|
|
73
|
+
__monty__: "bytes";
|
|
74
|
+
base64: string;
|
|
75
|
+
}
|
|
76
|
+
/** An `open` that succeeded: the worker answers it with a Monty file handle. */
|
|
77
|
+
export interface OpenedFile {
|
|
78
|
+
__monty__: "handle";
|
|
79
|
+
path: string;
|
|
80
|
+
mode: string;
|
|
81
|
+
}
|
|
82
|
+
/** A file operation the workflow leaves to Monty's default: the error for an unavailable OS call. */
|
|
83
|
+
export interface NotHandled {
|
|
84
|
+
__monty__: "not_handled";
|
|
85
|
+
}
|
|
86
|
+
export declare const encodeBytes: (data: Uint8Array) => EncodedBytes;
|
|
87
|
+
/** The file operation a script's step stopped at, as the worker hands it over. */
|
|
88
|
+
export interface FileOpCall {
|
|
89
|
+
call_id: number;
|
|
90
|
+
operation: string;
|
|
91
|
+
/** The script's absolute path. */
|
|
92
|
+
path: string;
|
|
93
|
+
/** The operation's remaining arguments: the data of a write, the mode of an `open`, a rename's destination. */
|
|
94
|
+
args: unknown[];
|
|
95
|
+
kwargs: Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
/** Runs one fs_* tool against a mount's backend, through the runner. */
|
|
98
|
+
export type CallFsTool = (tool: AnyHarnessTool, input: Record<string, unknown>, backend: FileSystem) => Promise<unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* What the script's file operation returns (encoded for the worker), or the failure it raises.
|
|
101
|
+
* Routing, read-only mounts and renames across mounts are decided here, before any backend call.
|
|
102
|
+
* A backend's error that names a mount-relative path is raised naming the virtual path instead.
|
|
103
|
+
*/
|
|
104
|
+
export declare function performFileOp(mounts: readonly Mount[], op: FileOpCall, call: CallFsTool): Promise<unknown>;
|
|
105
|
+
/**
|
|
106
|
+
* An `InMemoryFileSystem`'s files as agent state: `files` keyed by mount-relative path
|
|
107
|
+
* (`"notes/todo.md"`), and `directories` lists every directory except the mount's root. Declare
|
|
108
|
+
* it with `states: { workspace: state(FileTree) }` and pass the ref as
|
|
109
|
+
* `new InMemoryFileSystem({ state })`: the files then live in the state, and every change to them
|
|
110
|
+
* is published as a state patch.
|
|
111
|
+
*/
|
|
112
|
+
export declare const FileTree: z.ZodObject<{
|
|
113
|
+
files: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
114
|
+
content: z.ZodString;
|
|
115
|
+
encoding: z.ZodDefault<z.ZodEnum<{
|
|
116
|
+
base64: "base64";
|
|
117
|
+
"utf-8": "utf-8";
|
|
118
|
+
}>>;
|
|
119
|
+
size: z.ZodNumber;
|
|
120
|
+
}, z.core.$strip>>>;
|
|
121
|
+
directories: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
export type FileTree = z.output<typeof FileTree>;
|
|
124
|
+
/** The initial files of an `InMemoryFileSystem`, as `{ mount-relative path: content }`. */
|
|
125
|
+
export type Seed = () => Promise<Record<string, string | Uint8Array>>;
|
|
126
|
+
/**
|
|
127
|
+
* A `FileSystem` held in workflow memory. Build it in `create`, so each workflow gets its own; its
|
|
128
|
+
* files then last across the run's scripts, and replay rebuilds them. A continue-as-new carries
|
|
129
|
+
* only declared states, so without `state` the next run starts empty and seeds again.
|
|
130
|
+
*
|
|
131
|
+
* `seed` runs in workflow code, once, before the first operation on the mount, and returns the
|
|
132
|
+
* initial files. Load files from disk inside an activity the seed awaits: the activity's result is
|
|
133
|
+
* recorded, so a running workflow keeps the files it seeded even after a deploy changes them.
|
|
134
|
+
* `maxBytes` caps the total size of the files, seeded ones included.
|
|
135
|
+
*
|
|
136
|
+
* `state` (opt-in) keeps the files in a declared `FileTree` state instead, so every change is
|
|
137
|
+
* published as a state patch the UI can show. A patch carries each written file whole, and anyone
|
|
138
|
+
* who can view the session sees the files, so track only filesystems whose files are worth
|
|
139
|
+
* streaming to every viewer.
|
|
140
|
+
*/
|
|
141
|
+
export declare class InMemoryFileSystem<T extends {
|
|
142
|
+
files: FileTree["files"];
|
|
143
|
+
directories: string[];
|
|
144
|
+
} = FileTree> implements Required<FileSystem> {
|
|
145
|
+
#private;
|
|
146
|
+
constructor({ seed, maxBytes, state, }?: {
|
|
147
|
+
seed?: Seed;
|
|
148
|
+
maxBytes?: number;
|
|
149
|
+
state?: StateRef<T>;
|
|
150
|
+
});
|
|
151
|
+
get needsSeed(): boolean;
|
|
152
|
+
/** Run the seed and load its files, as one change. Called by the fs_seed tool. */
|
|
153
|
+
seedNow(): Promise<[count: number, bytes: number]>;
|
|
154
|
+
stat(path: string): Promise<FileStat | null>;
|
|
155
|
+
read(path: string): Promise<Uint8Array>;
|
|
156
|
+
list(path: string): Promise<string[]>;
|
|
157
|
+
write(path: string, data: Uint8Array): Promise<void>;
|
|
158
|
+
mkdir(path: string): Promise<void>;
|
|
159
|
+
delete(path: string): Promise<void>;
|
|
160
|
+
rename(path: string, target: string): Promise<void>;
|
|
161
|
+
}
|
|
162
|
+
export declare const IndexEntry: z.ZodObject<{
|
|
163
|
+
is_dir: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
|
|
164
|
+
size: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
165
|
+
mtime: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
166
|
+
writes: z.ZodDefault<z.ZodNumber>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
export type IndexEntry = z.output<typeof IndexEntry>;
|
|
169
|
+
export declare const IndexSource: z.ZodObject<{
|
|
170
|
+
filesystem: z.ZodString;
|
|
171
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
172
|
+
task_queue: z.ZodString;
|
|
173
|
+
}, z.core.$strip>;
|
|
174
|
+
export type IndexSource = z.output<typeof IndexSource>;
|
|
175
|
+
export declare const FileIndex: z.ZodObject<{
|
|
176
|
+
kind: z.ZodDefault<z.ZodLiteral<"file_index">>;
|
|
177
|
+
mount: z.ZodDefault<z.ZodString>;
|
|
178
|
+
description: z.ZodDefault<z.ZodString>;
|
|
179
|
+
read_only: z.ZodDefault<z.ZodBoolean>;
|
|
180
|
+
okf_version: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
181
|
+
source: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
182
|
+
filesystem: z.ZodString;
|
|
183
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
184
|
+
task_queue: z.ZodString;
|
|
185
|
+
}, z.core.$strip>>>;
|
|
186
|
+
entries: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
187
|
+
is_dir: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
|
|
188
|
+
size: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
189
|
+
mtime: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
190
|
+
writes: z.ZodDefault<z.ZodNumber>;
|
|
191
|
+
}, z.core.$strip>>>;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
export type FileIndex = z.output<typeof FileIndex>;
|
|
194
|
+
/** Where an activity-backed mount's files live, before the task queue is known. */
|
|
195
|
+
export interface FileSource {
|
|
196
|
+
filesystem: string;
|
|
197
|
+
config: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
/** Records successful mount operations. A no-op change publishes nothing. */
|
|
200
|
+
export interface IndexTrack {
|
|
201
|
+
noteStat(path: string, found: FileStat | null): void;
|
|
202
|
+
noteRead(path: string, size: number): void;
|
|
203
|
+
noteList(path: string, names: readonly string[]): void;
|
|
204
|
+
noteWrite(path: string, size: number): void;
|
|
205
|
+
noteMkdir(path: string): void;
|
|
206
|
+
noteRemove(path: string): void;
|
|
207
|
+
noteRename(path: string, target: string): void;
|
|
208
|
+
}
|
|
209
|
+
export declare function indexTrack(ref: StateRef<FileIndex>, source: FileSource): IndexTrack;
|