@trama-dev/runtime 0.1.1 → 0.1.3

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/runner.d.ts CHANGED
@@ -1,6 +1,11 @@
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
+ /**
5
+ * Ensure project has ESM package.json and .gitignore.
6
+ * If package.json exists but lacks "type": "module", patches it in.
7
+ */
8
+ export declare function ensureProjectScaffold(projectDir: string): void;
4
9
  /**
5
10
  * Simplified API reference for LLM system prompts.
6
11
  * NOT the canonical type definitions (those live in types.ts).
@@ -8,7 +13,7 @@ export declare const PI_VERSION: string;
8
13
  * needs a concise reference, not the full implementation types.
9
14
  * If types.ts changes, review whether this summary needs updating.
10
15
  */
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 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;";
16
+ 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;";
12
17
  export declare function loadConfig(): TramaConfig;
13
18
  export declare function loadState(projectDir: string): Record<string, unknown>;
14
19
  /**
@@ -18,8 +23,17 @@ export declare function loadState(projectDir: string): Record<string, unknown>;
18
23
  * Create-time repairs go to index.jsonl only (reason: "create-repair").
19
24
  */
20
25
  export declare function copyToHistory(projectDir: string, reason: string, detail?: string): void;
26
+ /**
27
+ * Snapshot a directory, run fn, restore from snapshot if fn returns false
28
+ * or if fn throws. Always cleans up the snapshot. Returns whatever fn returns.
29
+ */
30
+ export declare function withSnapshot<T>(dir: string, fn: () => Promise<{
31
+ keep: boolean;
32
+ value: T;
33
+ }>): Promise<T>;
21
34
  /** Run fn in a temp directory, clean up afterwards regardless of outcome. */
22
35
  export declare function withTempDir<T>(prefix: string, fn: (dir: string) => Promise<T>): Promise<T>;
36
+ export declare function resolveSmokeTimeout(timeout?: number): number;
23
37
  export declare function smokeRunAndRepair(projectDir: string, adapter: PiAdapter, reason: "create" | "update", options?: {
24
38
  timeout?: number;
25
39
  maxRepairAttempts?: number;