/** * `setupAgent` — the one-call ergonomic entry to the moxxy runtime. * * Constructing a {@link Session}, registering a mode + provider plugins + tools, * activating a provider, and calling {@link runTurn} is the standard boilerplate. * This wraps all of it in a single SYNCHRONOUS call and hands back a small * {@link Agent} you destructure: * * import { setupAgent } from '@moxxy/core'; * import defaultMode from '@moxxy/mode-default'; * import openai from '@moxxy/plugin-provider-openai'; * * const { ask, stream, session } = setupAgent({ * plugins: [defaultMode, openai], * provider: { name: 'openai', config: { apiKey: process.env.OPENAI_API_KEY } }, * tools: [myTool], * }); * * console.log(await ask('Hello!')); // final reply text (async) * for await (const e of stream('Go on…')) { … } // event stream (async generator) * * Two ways to run a turn: `stream()` is a proper async generator that YIELDS each * {@link MoxxyEvent} as it happens; `ask()`/`collect()` are async — the final * text, or every event. The methods close over the session (no `this`), so * destructuring is safe. `session` is the LIVE session — hot-change blocks * between turns through it (or the `setProvider`/`setMode`/`use`/`addTool` sugar). * It stays block-agnostic: you pass the provider/mode PLUGINS in, so `@moxxy/core` * never depends on a vendor. */ import type { MoxxyEvent, PermissionResolver, Plugin, RunTurnOptions, ToolDef } from '@moxxy/sdk'; import { Session, type SessionOptions } from './session.js'; export interface SetupAgentOptions { /** Working directory the agent operates in. Defaults to `process.cwd()`. */ readonly cwd?: string; /** Plugins to register up front — modes, providers, tool-packs, … (order kept). */ readonly plugins?: readonly Plugin[]; /** Tools to register directly (sugar over authoring a one-tool plugin). */ readonly tools?: readonly ToolDef[]; /** Activate a provider after registration: its registered `name` + the config * its `createClient` needs (e.g. `{ apiKey }`). */ readonly provider?: { readonly name: string; readonly config?: Record; }; /** Permission policy: `'auto'` (approve every tool call — frictionless headless * default), `'deny'` (refuse all), or a custom {@link PermissionResolver}. */ readonly permissions?: 'auto' | 'deny' | PermissionResolver; /** Any other {@link SessionOptions} (logger, secretResolver, pluginLoader, * pluginDiscoveryPaths, …). */ readonly session?: Omit; } export interface Agent { /** The underlying live {@link Session} — full control + hot-change escape hatch * (`session.providers`, `session.tools`, `session.modes`, `session.pluginHost`). */ readonly session: Session; /** Run one turn as an async generator, YIELDING each event as it happens: * `for await (const e of stream(prompt)) …`. */ stream(prompt: string, opts?: RunTurnOptions): AsyncGenerator; /** Run one turn; resolve with the final assistant text (`''` if none). */ ask(prompt: string, opts?: RunTurnOptions): Promise; /** Run one turn; resolve with every emitted event. */ collect(prompt: string, opts?: RunTurnOptions): Promise>; /** Discover + load plugins from `node_modules` (and `pluginDiscoveryPaths`). * Async; resolves with this agent for chaining. */ discover(): Promise; /** Register another plugin (mode / provider / tool-pack) on the live session. */ use(plugin: Plugin): Agent; /** Register a tool on the live session. */ addTool(tool: ToolDef): Agent; /** Remove a registered tool by name. */ removeTool(name: string): Agent; /** Swap the active provider (and its config) for subsequent turns. */ setProvider(name: string, config?: Record): Agent; /** Swap the active loop strategy (mode) for subsequent turns. */ setMode(name: string): Agent; } /** A reusable, pre-filled chunk of {@link SetupAgentOptions} — e.g. a provider * "preset" that bundles a provider plugin + the default mode + its config, so * `setupAgent(openaiPreset({ apiKey }))` is a one-line drop-in. A preset is just * an options object, so presets compose: pass an array and they merge. */ export type AgentPreset = SetupAgentOptions; /** * Build a ready-to-run {@link Agent}. Synchronous — destructure the result. * Accepts a full options object, a single {@link AgentPreset}, or an ARRAY of * presets that are merged (see {@link mergePresets}): * * setupAgent(openaiPreset({ apiKey })) * setupAgent([openaiPreset({ apiKey }), anthropicPreset({ apiKey })]) // both; openai active */ export declare function setupAgent(input?: SetupAgentOptions | readonly SetupAgentOptions[]): Agent; //# sourceMappingURL=setup-agent.d.ts.map