Skip to content

Commit cdc3ca2

Browse files
authored
Merge pull request #18 from githubnext/rig-sampler/04-generate-readme-a9e3fec1aed8e03d
2 parents b940bf9 + 3cdf0f7 commit cdc3ca2

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

skills/rig/rig.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,23 @@ export async function runLauncherCli(
940940
await runProgramCodeFromStdin(mergedOptions, io, scriptName);
941941
}
942942

943+
/**
944+
* Defines a typed agent from a declarative spec and returns a callable function.
945+
*
946+
* The returned function accepts an input value (plain JS or with `p.*` prompt intents)
947+
* and returns a Promise of the validated output. The harness renders the prompt,
948+
* invokes the configured engine, parses the JSON response, validates it against
949+
* `spec.output`, and retries up to `spec.maxTurns` times on failure.
950+
*
951+
* @example
952+
* const summarize = agent({
953+
* model: "mini",
954+
* input: s.object({ text: s.string }),
955+
* output: s.object({ summary: s.string, keywords: s.array(s.string) }),
956+
* instructions: "Summarize the text and extract keywords.",
957+
* });
958+
* const result = await summarize({ text: p.read("README.md") });
959+
*/
943960
export function agent<
944961
const Input extends Schema = StringSchema,
945962
const Output extends Schema = StringSchema

0 commit comments

Comments
 (0)