File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+ */
943960export function agent <
944961 const Input extends Schema = StringSchema ,
945962 const Output extends Schema = StringSchema
You can’t perform that action at this time.
0 commit comments