@trama-dev/runtime 0.1.0 → 0.1.2
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/dist/agent.d.ts +1 -1
- package/dist/agent.js +35 -20
- package/dist/client.js +23 -8
- package/dist/context.d.ts +2 -0
- package/dist/context.js +18 -43
- package/dist/index.d.ts +2 -0
- package/dist/index.js +96 -42
- package/dist/pi-adapter.d.ts +11 -1
- package/dist/pi-adapter.js +63 -9
- package/dist/runner.d.ts +23 -2
- package/dist/runner.js +471 -147
- package/dist/serializable.d.ts +8 -0
- package/dist/serializable.js +40 -0
- package/dist/tools.d.ts +5 -1
- package/dist/tools.js +173 -21
- package/dist/types.d.ts +7 -0
- package/package.json +4 -4
package/dist/runner.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { RunOptions, TramaConfig } from "./types.js";
|
|
2
2
|
import { PiAdapter } from "./pi-adapter.js";
|
|
3
3
|
export declare const PI_VERSION: string;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Simplified API reference for LLM system prompts.
|
|
6
|
+
* NOT the canonical type definitions (those live in types.ts).
|
|
7
|
+
* Kept as a readable string rather than auto-generated, because the LLM
|
|
8
|
+
* needs a concise reference, not the full implementation types.
|
|
9
|
+
* If types.ts changes, review whether this summary needs updating.
|
|
10
|
+
*/
|
|
11
|
+
export declare const RUNTIME_TYPES = "// @trama-dev/runtime - Complete API\n\nexport interface Ctx {\n input: { prompt: string; args: Record<string, unknown> };\n state: Record<string, unknown>;\n iteration: number;\n maxIterations: number;\n log(message: string, data?: Record<string, unknown>): Promise<void>;\n ready(data?: Record<string, unknown>): Promise<void>;\n checkpoint(): Promise<void>;\n done(result?: Record<string, unknown>): Promise<void>;\n}\n\nexport interface Agent {\n ask(prompt: string, options?: { system?: string }): Promise<string>;\n generate<T>(input: {\n prompt: string;\n schema: Record<string, string>;\n system?: string;\n }): Promise<T>;\n}\n\nexport interface ShellResult {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\nexport interface Tools {\n read(path: string): Promise<string>;\n write(path: string, content: string): Promise<void>;\n shell(command: string, options?: { cwd?: string; timeout?: number }): Promise<ShellResult>;\n fetch(url: string, options?: {\n method?: string;\n headers?: Record<string, string>;\n body?: string;\n }): Promise<{ status: number; body: string; headers: Record<string, string> }>;\n}\n\nexport declare const ctx: Ctx;\nexport declare const agent: Agent;\nexport declare const tools: Tools;";
|
|
5
12
|
export declare function loadConfig(): TramaConfig;
|
|
6
13
|
export declare function loadState(projectDir: string): Record<string, unknown>;
|
|
7
14
|
/**
|
|
@@ -11,5 +18,19 @@ export declare function loadState(projectDir: string): Record<string, unknown>;
|
|
|
11
18
|
* Create-time repairs go to index.jsonl only (reason: "create-repair").
|
|
12
19
|
*/
|
|
13
20
|
export declare function copyToHistory(projectDir: string, reason: string, detail?: string): void;
|
|
14
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Snapshot a directory, run fn, restore from snapshot if fn returns false
|
|
23
|
+
* or if fn throws. Always cleans up the snapshot. Returns whatever fn returns.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withSnapshot<T>(dir: string, fn: () => Promise<{
|
|
26
|
+
keep: boolean;
|
|
27
|
+
value: T;
|
|
28
|
+
}>): Promise<T>;
|
|
29
|
+
/** Run fn in a temp directory, clean up afterwards regardless of outcome. */
|
|
30
|
+
export declare function withTempDir<T>(prefix: string, fn: (dir: string) => Promise<T>): Promise<T>;
|
|
31
|
+
export declare function smokeRunAndRepair(projectDir: string, adapter: PiAdapter, reason: "create" | "update", options?: {
|
|
32
|
+
timeout?: number;
|
|
33
|
+
maxRepairAttempts?: number;
|
|
34
|
+
maxIterations?: number;
|
|
35
|
+
}): Promise<void>;
|
|
15
36
|
export declare function runProgram(options: RunOptions): Promise<void>;
|