import type { LanguageModel } from "ai";
import type { StandardJSONSchemaV1 } from "#compiled/@standard-schema/spec/index.js";
import type { JsonObject } from "#shared/json.js";
import type { ModuleSourceRef } from "#shared/source-ref.js";
/**
 * Optional overrides that Eve forwards to the AI SDK model runtime call for
 * this model.
 */
export interface AgentModelOptionsDefinition {
    readonly providerOptions?: Record<string, JsonObject>;
}
export type InternalAgentModelDefinition = {
    id: string;
    contextWindowTokens?: number;
    source?: ModuleSourceRef;
    providerOptions?: Record<string, JsonObject>;
};
/**
 * The model handle you assign to an agent's `model` field. This is the AI SDK
 * `LanguageModel` value (for example, the result of a provider or gateway
 * model call), not an Eve-authored definition object.
 */
export type PublicAgentModelDefinition = LanguageModel;
export interface InternalAgentCompactionDefinition {
    /**
     * Optional model used only for generating compaction summaries.
     *
     * When omitted, Eve uses the active turn model for the summary call.
     */
    model?: InternalAgentModelDefinition;
    /**
     * Fraction of the primary model context window that triggers compaction.
     *
     * Eve defaults to `0.9` when this is omitted.
     */
    thresholdPercent?: number;
}
/**
 * Configures conversation compaction: when the model context window fills past
 * `thresholdPercent`, Eve summarizes earlier turns to reclaim space. Every
 * field is optional; omit the block to use Eve's defaults.
 */
export interface PublicAgentCompactionDefinition {
    /**
     * Optional override for the compaction summary model's context window size,
     * in tokens.
     *
     * Same escape hatch as the agent-level `modelContextWindowTokens`. When set,
     * Eve uses this value verbatim and skips the AI Gateway lookup for the
     * compaction summary model.
     */
    readonly modelContextWindowTokens?: number;
    /**
     * Optional model used only for generating compaction summaries.
     *
     * When omitted, Eve uses the active turn model for the summary call.
     */
    readonly model?: PublicAgentModelDefinition;
    /**
     * Fraction of the primary model context window that triggers compaction.
     *
     * Eve defaults to `0.9` when this is omitted.
     */
    readonly thresholdPercent?: number;
}
/**
 * Experimental, opt-in agent capabilities authored in `agent.ts`.
 *
 * These options are unstable and may change or be removed in any release.
 * Each agent (the root agent and every subagent) carries its own flags, so
 * code mode can be enabled for the whole graph, only a subagent, or only
 * the parent.
 */
export interface AgentExperimentalDefinition {
    /**
     * Routes executable tools through a sandboxed code-execution wrapper
     * instead of exposing them directly to the model. The model writes
     * JavaScript that calls the tools inside the sandbox.
     *
     * When unset, Eve falls back to the `EVE_EXPERIMENTAL_CODE_MODE`
     * environment variable (`"1"` enables it) for backwards compatibility.
     */
    readonly codeMode?: boolean;
}
/**
 * Advanced hosted-build controls authored in `agent.ts`.
 *
 * Eve uses these only while packaging the application host. They do not affect
 * the runtime prompt or authored execution APIs.
 */
export interface AgentBuildDefinition {
    /**
     * Additional imported package names that Eve should keep external and trace
     * into hosted build output.
     *
     * Prefer this when a package is sensitive to bundling and should ship via
     * `server/node_modules` in hosted output.
     */
    readonly externalDependencies?: string[];
}
/**
 * Compiled-side agent definition. Carries a `name` because the compiler
 * stamps the path-derived `agentId` onto every compiled agent node.
 */
export type InternalAgentDefinition = {
    name: string;
    description?: string;
    build?: AgentBuildDefinition;
    compaction?: InternalAgentCompactionDefinition;
    experimental?: AgentExperimentalDefinition;
    model: InternalAgentModelDefinition;
    outputSchema?: JsonObject;
    source?: ModuleSourceRef;
};
/**
 * Shared public definition for an agent.
 *
 * Identity is derived at compile time from `manifest.agentId` (the
 * package name or app-root basename). Authored definitions do not carry
 * a `name` field.
 */
export type PublicAgentDefinition = {
    /**
     * Human-readable description of the agent's purpose. Required for
     * subagents (authored under `subagents/<id>/agent.ts`): surfaced to
     * the parent agent as the lowered subagent tool's description.
     */
    readonly description?: string;
    readonly build?: AgentBuildDefinition;
    readonly compaction?: PublicAgentCompactionDefinition;
    /**
     * Experimental, opt-in capabilities. Unstable, see
     * {@link AgentExperimentalDefinition}.
     */
    readonly experimental?: AgentExperimentalDefinition;
    /**
     * Language model used for agent turns. Accepts an AI Gateway model ID or any
     * AI SDK-compatible language model.
     */
    readonly model: PublicAgentModelDefinition;
    /**
     * Optional override for the primary model's context window size, in tokens.
     *
     * Escape hatch for cases where Eve cannot resolve the model's metadata via
     * the AI Gateway model catalog (e.g. a custom or unlisted model id). When
     * set, Eve uses this value verbatim and skips the AI Gateway lookup. Prefer
     * leaving this unset so Eve can stay in sync with provider metadata.
     */
    readonly modelContextWindowTokens?: number;
    readonly modelOptions?: AgentModelOptionsDefinition;
    /**
     * Optional structured return type used when this agent runs in task mode
     * (for example as a subagent, schedule, or remote job). Interactive
     * conversation turns ignore this field unless the client supplies a
     * per-message output schema.
     */
    readonly outputSchema?: StandardJSONSchemaV1<unknown, unknown> | JsonObject;
};
