Skip to content

Commit d2e0596

Browse files
Copilotpelikhan
andauthored
Refresh runtime reference (#285)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent e46c188 commit d2e0596

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

skills/rig/references/runtime.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ RIG
1616
Inline mode:
1717

1818
- writes the root result to stdout
19-
- accepts an agent, string, or prompt builder as the default export
19+
- accepts an agent, workflow, string, or prompt builder as the default export
2020
- injects `import { agent, p, s } from "rig"` when omitted
21-
- accepts a root with no `input`, `input: s.object({})`, or the default `s.string` input invoked with `""`
21+
- accepts a root with no `input`, `input: s.object({})`, `input: s.object({ text: s.string })`, or the default `s.string` input; omitted values become `{}`, `{ text: "" }`, or `""`
2222
- falls back to the first `const`/`let`/`var` assigned from `agent(...)` if `export default` is omitted
2323

2424
Prefer an explicit default export even though the fallback exists.
@@ -37,7 +37,11 @@ Stdin coercion follows the root schema:
3737
- object containing `text`: `{ text: "<stdin>" }`
3838
- any other schema: stdin must be valid JSON
3939

40-
Add `--server` in either mode to start the Copilot server over stdio. Without it, `copilotEngine()` connects over HTTP using `COPILOT_SDK_URI`, then `localhost:7777`.
40+
The launcher writes string results, or the string `text` field of an object result, directly to stdout. It JSON-serializes other results.
41+
42+
Add `--server` in either mode to start the Copilot server over stdio and force the Copilot engine. Without it, `copilotEngine()` connects over HTTP using `COPILOT_SDK_URI`, then `localhost:7777`.
43+
44+
Use `--help`, `-h`, `help`, `/help`, or `/?` to print launcher usage.
4145

4246
## Typechecking
4347

@@ -74,12 +78,15 @@ Adapters implement the SDK-neutral interface:
7478

7579
```ts
7680
interface Agent {
77-
ask(prompt: string, options?: { signal?: AbortSignal }): Promise<string>;
81+
ask(prompt: string, options?: {
82+
signal?: AbortSignal;
83+
outputSchema?: Record<string, unknown>;
84+
}): Promise<string>;
7885
close(): Promise<void>;
7986
}
8087
```
8188

82-
Register a factory with `configureAgent(factory)`. Rig creates one adapter instance per invocation and preserves it across repair turns.
89+
An `AgentFactory` receives the resolved `model`, `systemMessage`, and tools. Register a factory with `configureAgent(factory)`. Rig creates one adapter instance per invocation and preserves it across repair turns.
8390

8491
## Included engines
8592

@@ -108,12 +115,22 @@ configureAgent(geminiEngine());
108115
- `OPENAI_API_KEY` → `codexEngine()`
109116
- `GEMINI_API_KEY` or `GOOGLE_API_KEY` → `geminiEngine()`
110117
- otherwise → `copilotEngine()`
111-
- `copilotEngine()` uses the Copilot SDK HTTP transport by default; launcher `--server` selects stdio.
112-
- `piEngine({ provider })` uses `@earendil-works/pi-agent-core` and requires a provider for model lookup.
113-
- `anthropicEngine()` uses `@anthropic-ai/sdk` and reads `ANTHROPIC_API_KEY`.
114-
- `codexEngine(options)` uses `@openai/codex-sdk`, accepts thread options under `thread`, preserves the thread across repair turns, and maps Rig system messages to developer instructions. It rejects Rig tools because the SDK does not expose custom tool registration.
118+
- `copilotEngine(options)` accepts Copilot client options plus `server` and `connection`. It supports Rig tools and uses the Copilot SDK HTTP transport by default; launcher `--server` selects stdio.
119+
- `piEngine({ provider, models? })` uses `@earendil-works/pi-agent-core`, requires a provider for model lookup, and supports Rig tools.
120+
- `anthropicEngine(options)` uses `@anthropic-ai/sdk`, reads `ANTHROPIC_API_KEY`, supports Rig tools, and accepts `maxTokens` and `maxIterations`.
121+
- `codexEngine(options)` uses `@openai/codex-sdk`, accepts thread options under `thread`, preserves the thread across repair turns, maps Rig system messages to developer instructions, and forwards structured output schemas. It rejects Rig tools because the SDK does not expose custom tool registration.
115122
- `geminiEngine(options)` runs an installed Gemini CLI in headless JSON mode and resumes its session across repair turns. It accepts `command`, `cwd`, CLI `args`, environment variables, and `approvalMode`; it rejects Rig tools because the CLI does not expose registration.
116123

124+
## Debug logging
125+
126+
Set `RIG_DEBUG` to comma- or whitespace-separated categories. A category includes its descendants, `*` matches all categories, and a leading `-` excludes a match:
127+
128+
```bash
129+
RIG_DEBUG="engine,agent:turn,-engine:copilot:event" node skills/rig/rig.ts src/program.ts
130+
```
131+
132+
Debug records are `rig.*` JSONL events on stderr and never replace the final stdout result.
133+
117134
## Operational conventions
118135

119136
- Assume Node.js 24.

0 commit comments

Comments
 (0)