rednode API - v0.50.0
    Preparing search index...

    Variable agentConst

    agent: {
        ask(prompt: string, options?: AskOptions): Promise<AgentAnswer>;
        serve(
            handler: (request: AgentRequest) => Promise<void | AgentResult>,
        ): () => void;
    } = ...

    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.

    Type Declaration

    • ask: function
    • serve: function
      • 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.

        Parameters

        Returns () => void

    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)}`);