// A model for working on berry itself without spending tokens. import type { MutableModels } from "@earendil-works/pi-ai"; import { fauxAssistantMessage, type FauxResponseFactory, fauxText, fauxThinking, fauxToolCall, } from "@earendil-works/pi-ai/providers/faux"; import { fauxProvider } from "@earendil-works/pi-ai/providers/faux"; /** * `dev/echo` echoes, thinks a little, and runs a message of the form `js ` as a codemode script. Its thinking * about a message of the form `quiet ` is empty, as encrypted reasoning is. */ export function installDevModel(models: MutableModels) { const faux = fauxProvider({ provider: "dev", models: [{ id: "echo", name: "dev echo", reasoning: true }], tokensPerSecond: 80, }); const respond: FauxResponseFactory = (context) => { faux.appendResponses([respond]); // a section patch may follow the message being answered const last = context.messages.findLast((message) => message.role !== "system"); if (last?.role === "toolResult") { return fauxAssistantMessage( `The script ${last.isError ? "failed" : "finished"}; its output is above.`, ); } const text = last?.role !== "user" ? "" : typeof last.content === "string" ? last.content : last.content.flatMap((block) => (block.type === "text" ? [block.text] : [])).join("\n"); if (text.startsWith("js ")) { return fauxAssistantMessage( [ fauxThinking("Running that in codemode."), fauxToolCall("codemode", { code: text.slice(3) }), ], { stopReason: "toolUse" }, ); } return fauxAssistantMessage([ fauxThinking(text.startsWith("quiet ") ? "" : `They wrote ${text.length} characters.`), fauxText(`You said:\n\n> ${text}\n\nTry \`js return await tools.bash({ command: "ls" })\`.`), ]); }; faux.setResponses([respond]); models.setProvider(faux.provider); }