ConstAsks a question. Resolves with the whole answer; rejects if it is refused, fails or is stopped.
For the assistant package only (its manifest says "provides": ["agent"]):
answers other packages' questions. The handler writes the answer with
request.write as it streams, or returns it, and returns the cost.
A thrown error goes back to the asker as the reason.
import { agent, ui } from "rednode";
const answer = ui.text("");
const { text, cost } = await agent.ask("Suggest a build for a netrunner at level 12.", {
context: { level: 12, attributes: { intelligence: 9 } },
onText: (t) => answer.set({ text: answer.props.text + t }),
});
console.log(`That cost $${cost.toFixed(3)}`);
The AI assistant, for any package. Asking needs
"permissions": ["agent"]in the package's rednode-app.json and the player's OK in the launcher or the Mod Manager. Every answer costs the player a little, so ask when it helps them, not on a timer. The assistant (REDagent) answers with read-only tools: it can look at logs, the game state and the game API, but never changes anything. It keeps a daily spending limit per package; past it, questions fail.