// 1. Create the plan
const stream = sdk.agent.stream({
agentWallet,
message: "/plan Build a REST API with auth, routes, and tests",
threadId: "api-build",
});
for await (const event of stream) {
if (event.type === "plan.proposed") {
console.log(event.markdown); // human-readable plan summary
}
}
// 2. Run it
const runStream = sdk.agent.stream({
agentWallet,
message: "/plan run",
threadId: "api-build",
});
for await (const event of runStream) {
switch (event.type) {
case "task.completed":
console.log(`Done: ${event.taskId}`);
break;
case "task.blocked":
case "task.failed":
console.log(`${event.type}: ${event.taskId}`);
break;
}
}