@trama-dev/runtime 0.1.3 → 0.1.4

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/README.md CHANGED
@@ -12,7 +12,7 @@ The runtime behind [trama](https://github.com/NaNhkNaN/trama) — execution, sta
12
12
  import { ctx, agent, tools } from "@trama-dev/runtime";
13
13
 
14
14
  const data = await tools.read("input.csv");
15
- const report = await agent.ask(`Analyze this:\n${data}`);
15
+ const report = await agent.instruct(`Analyze this:\n${data}`);
16
16
  await tools.write("report.md", report);
17
17
  await ctx.done();
18
18
  ```
package/dist/agent.js CHANGED
@@ -21,10 +21,10 @@ function validateShape(result, schema) {
21
21
  return null;
22
22
  }
23
23
  export function createAgent(adapter, signal) {
24
+ const instructImpl = async (prompt, options) => adapter.ask(prompt, signal ? { ...options, signal } : options);
24
25
  return {
25
- async ask(prompt, options) {
26
- return adapter.ask(prompt, signal ? { ...options, signal } : options);
27
- },
26
+ instruct: instructImpl,
27
+ ask: instructImpl,
28
28
  async generate(input) {
29
29
  const schemaInstruction = `Respond with ONLY a JSON object matching this shape:\n${JSON.stringify(input.schema, null, 2)}\nNo markdown. No explanation. Just the JSON.`;
30
30
  const fullPrompt = `${input.prompt}\n\n${schemaInstruction}`;
package/dist/client.js CHANGED
@@ -81,8 +81,10 @@ export const ctx = {
81
81
  }
82
82
  },
83
83
  };
84
+ const instructImpl = (prompt, opts) => call("/agent/ask", { prompt, ...opts }).then(r => r.result);
84
85
  export const agent = {
85
- ask: (prompt, opts) => call("/agent/ask", { prompt, ...opts }).then(r => r.result),
86
+ instruct: instructImpl,
87
+ ask: instructImpl,
86
88
  generate: (input) => call("/agent/generate", input).then(r => r.result),
87
89
  };
88
90
  export const tools = {
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ await ctx.done();
19
19
  import { ctx, agent, tools } from "@trama-dev/runtime";
20
20
 
21
21
  const data = await tools.read(ctx.input.args.file as string);
22
- const summary = await agent.ask("Summarize this data concisely:\\n" + data);
22
+ const summary = await agent.instruct("Summarize this data concisely:\\n" + data);
23
23
  await tools.write("summary.md", summary);
24
24
  await ctx.done({ summaryLength: summary.length });
25
25
 
@@ -109,7 +109,7 @@ export function resolveProject(name) {
109
109
  return dir;
110
110
  }
111
111
  // --- Helpers ---
112
- /** Run an LLM ask() in an isolated temp cwd so pi-coding-agent tools can't write into the real project. */
112
+ /** Run an LLM instruction in an isolated temp cwd so pi-coding-agent tools can't write into the real project. */
113
113
  async function isolatedAsk(adapter, prompt, options) {
114
114
  return withTempDir("trama-gen-", (dir) => adapter.withCwd(dir).ask(prompt, options));
115
115
  }
package/dist/runner.d.ts CHANGED
@@ -13,7 +13,7 @@ export declare function ensureProjectScaffold(projectDir: string): void;
13
13
  * needs a concise reference, not the full implementation types.
14
14
  * If types.ts changes, review whether this summary needs updating.
15
15
  */
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;";
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 instruct(prompt: string, options?: { system?: string }): Promise<string>;\n /** @deprecated Use instruct() instead */\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;";
17
17
  export declare function loadConfig(): TramaConfig;
18
18
  export declare function loadState(projectDir: string): Record<string, unknown>;
19
19
  /**
package/dist/runner.js CHANGED
@@ -128,6 +128,8 @@ export interface Ctx {
128
128
  }
129
129
 
130
130
  export interface Agent {
131
+ instruct(prompt: string, options?: { system?: string }): Promise<string>;
132
+ /** @deprecated Use instruct() instead */
131
133
  ask(prompt: string, options?: { system?: string }): Promise<string>;
132
134
  generate<T>(input: {
133
135
  prompt: string;
package/dist/types.d.ts CHANGED
@@ -37,9 +37,14 @@ export interface Ctx {
37
37
  }
38
38
  export interface Agent {
39
39
  /**
40
- * LLM call via pi-coding-agent. Returns plain text.
41
- * The underlying pi agent may use its built-in tools autonomously.
40
+ * Instruct the pi-coding-agent to perform a task. Returns plain text.
41
+ * The underlying agent may autonomously use its built-in tools
42
+ * (bash, file read/write/edit) to fulfill the instruction.
42
43
  */
44
+ instruct(prompt: string, options?: {
45
+ system?: string;
46
+ }): Promise<string>;
47
+ /** @deprecated Use instruct() instead. Alias kept for backwards compatibility. */
43
48
  ask(prompt: string, options?: {
44
49
  system?: string;
45
50
  }): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trama-dev/runtime",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {