Define the agent
Use agent() from @teasim/harness to name a model capability, write instructions and register tools. A tool describes its parameters to the model and validates input before running. An order lookup tool can call the same authorized action as the order API.
Start a run
Configure a model provider and register the agent with harness({ agents: [support] }). Once the application starts, use its Runs capability. Here, support is the registered agent and app is the running application.
import { Runs } from "@teasim/harness";
const run = app.get(Runs).start(support, "Look up order 42");
for await (const event of run.events) {
if (event.type === "text") process.stdout.write(event.text);
}
const result = await run.result;Handle a waiting run
Inspect result.state after the stream ends. A completed run has final output. A waiting run identifies tool calls that need a decision. In the support agent example, a supervisor reviews the refund before the run continues. A persistent run store can carry that waiting state across a process restart.