UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

526 lines (525 loc) 23.1 kB
import { z } from "#compiled/zod/index.js"; import { type DiscoverDiagnosticsSummary } from "#discover/diagnostics.js"; import { type CompiledRemoteAgentNode } from "#compiler/remote-agent-node.js"; import type { ChannelRouteMethod } from "#public/definitions/channel.js"; import type { Node } from "#shared/node.js"; import type { MarkdownSourceRef, ModuleSourceRef, SkillPackageSourceRef } from "#shared/source-ref.js"; import type { NamedSkillDefinition } from "#shared/skill-definition.js"; import type { InternalAgentDefinition, InternalAgentModelDefinition, InternalAgentCompactionDefinition, ModelRouting } from "#shared/agent-definition.js"; import type { InternalToolDefinition } from "#shared/tool-definition.js"; /** * Stable manifest kind emitted by the compiler for runtime loading. */ export declare const COMPILED_AGENT_MANIFEST_KIND = "eve-agent-compiled-manifest"; /** * Stable node id used by compiled artifacts for the root authored agent. */ export declare const ROOT_COMPILED_AGENT_NODE_ID = "__root__"; /** * Current compiled manifest schema version. */ export declare const COMPILED_AGENT_MANIFEST_VERSION = 30; /** * Compiled channel entry preserved in the compiled manifest. */ export type CompiledChannelEntry = CompiledChannelDefinition | DisabledCompiledChannelEntry; /** * Active compiled channel entry — backed by an authored `Channel` module. */ export interface CompiledChannelDefinition { readonly kind: "channel"; readonly name: string; readonly logicalPath: string; readonly method: ChannelRouteMethod; readonly urlPath: string; readonly sourceId: string; readonly sourceKind: "module"; readonly exportName?: string; /** * Stable identifier of the `ChannelAdapter.kind` returned by the authored * route, captured at compile time. Examples: `"slack"`, `"http"`. Authors * may override the default kind on their adapter, so this field is the * adapter's reported value verbatim. Consumers (eg. dashboard surfaces) * normalize it for display via {@link normalizeChannelKindForDisplay}. * * Omitted when the route does not register an adapter. */ readonly adapterKind?: string; } /** * Disabled compiled channel entry — marker that an authored file at this * slug exported `disableRoute()` to remove the matching framework default. */ interface DisabledCompiledChannelEntry { readonly kind: "disabled"; readonly name: string; readonly logicalPath: string; } /** * Serializable runtime model reference preserved in the compiled manifest. * * Carries {@link ModelRouting} — decided at compile time from the authored model * value — so consumers (the dev server's `/eve/v1/info`, the TUI) can tell how * the model is reached without re-resolving it. Runtime model resolution uses * the routing-free {@link InternalAgentModelDefinition}; routing is a * compiled-output concern only. */ export type CompiledRuntimeModelReference = InternalAgentModelDefinition & { routing: ModelRouting; }; /** * Normalized authored compaction configuration preserved in the compiled * manifest. */ type CompiledAgentCompactionDefinition = Omit<InternalAgentCompactionDefinition, "model"> & { model?: CompiledRuntimeModelReference; }; /** * Normalized additive agent configuration preserved in the compiled manifest. */ export type CompiledAgentDefinition = Omit<InternalAgentDefinition, "model" | "compaction"> & { model: CompiledRuntimeModelReference; compaction?: CompiledAgentCompactionDefinition; }; /** * Normalized authored instructions prompt preserved in the compiled * manifest. */ export type CompiledInstructions = z.infer<typeof compiledInstructionsSchema>; /** * Normalized authored skill preserved in the compiled manifest. */ export type CompiledSkillDefinition = NamedSkillDefinition & (Omit<MarkdownSourceRef<undefined>, "definition"> | ModuleSourceRef | SkillPackageSourceRef); /** * Normalized authored schedule preserved in the compiled manifest. */ export type CompiledScheduleDefinition = z.infer<typeof compiledScheduleDefinitionSchema>; /** * Normalized authored sandbox metadata preserved in the compiled manifest. */ export type CompiledSandboxDefinition = z.infer<typeof compiledSandboxDefinitionSchema>; /** * Compiled sandbox workspace folder preserved in the compiled manifest. * * Corresponds to the `agent/sandbox/workspace/` directory discovered on * disk. Mounted into the live sandbox cwd at session bootstrap. */ type CompiledSandboxWorkspace = z.infer<typeof compiledSandboxWorkspaceSchema>; /** * Byte-free descriptor for the compiled workspace resource tree owned by one * graph node. */ export type CompiledWorkspaceResourceRoot = z.infer<typeof compiledWorkspaceResourceRootSchema>; /** * Normalized authored connection metadata preserved in the compiled manifest. */ export type CompiledConnectionDefinition = z.infer<typeof compiledConnectionDefinitionSchema>; /** * Normalized authored tool metadata preserved in the compiled manifest. */ export type CompiledToolDefinition = InternalToolDefinition & ModuleSourceRef; /** * Compiled dynamic tool resolver entry. The resolver function lives in the * compiled module map; the manifest entry carries only the metadata needed * to load and invoke it at runtime. */ export interface CompiledDynamicToolDefinition extends ModuleSourceRef { readonly slug: string; readonly eventNames: readonly string[]; } /** * Compiled dynamic skill resolver entry. Mirrors * {@link CompiledDynamicToolDefinition} — the resolver produces skill * packages at runtime rather than tool definitions. */ export interface CompiledDynamicSkillDefinition extends ModuleSourceRef { readonly slug: string; readonly eventNames: readonly string[]; } /** * Compiled dynamic instructions resolver entry. The resolver produces * {@link ModelMessage[]} at runtime rather than static markdown. */ export interface CompiledDynamicInstructionsDefinition extends ModuleSourceRef { readonly slug: string; readonly eventNames: readonly string[]; } /** * Normalized authored hook entry preserved in the compiled manifest. * * Hook event handlers are arbitrary functions — there is no static * shape the compiler can validate beyond the source ref. Per-handler * resolution happens at runtime via {@link resolveHookDefinition}. */ export interface CompiledHookDefinition extends ModuleSourceRef { /** * Path-relative slug used for diagnostics and ordering. Derived from * the authored file's logical path * (eg. `agent/hooks/auth/guard.ts` → `"auth/guard"`). */ readonly slug: string; } /** * Non-recursive compiled authored agent payload shared by the root agent and * every flattened subagent node. */ export type CompiledAgentNodeManifest = z.infer<typeof compiledAgentNodeManifestSchema>; /** * Flattened compiled subagent node emitted by the compiler. `name` and * `description` are copied from `agent.config` for fast registry lookup. */ export type CompiledSubagentNode = Readonly<ModuleSourceRef & Node & { agent: CompiledAgentNodeManifest; description: string; entryPath: string; name: string; rootPath: string; }>; export type { CompiledRemoteAgentNode } from "#compiler/remote-agent-node.js"; /** * Parent-child edge connecting two compiled agent nodes. */ export interface CompiledSubagentEdge { readonly childNodeId: string; readonly parentNodeId: string; } /** * Versioned compiled manifest emitted by the compiler and loaded by runtime. */ export type CompiledAgentManifest = z.infer<typeof compiledAgentManifestSchema>; declare const compiledInstructionsSchema: z.ZodObject<{ name: z.ZodString; logicalPath: z.ZodString; markdown: z.ZodString; sourceId: z.ZodString; sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>; }, z.core.$strict>; declare const compiledScheduleDefinitionSchema: z.ZodObject<{ cron: z.ZodString; hasRun: z.ZodBoolean; name: z.ZodString; logicalPath: z.ZodString; markdown: z.ZodOptional<z.ZodString>; sourceId: z.ZodString; sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>; }, z.core.$strict>; declare const compiledSandboxDefinitionSchema: z.ZodObject<{ backendName: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; exportName: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; revalidationKey: z.ZodOptional<z.ZodString>; sourceHash: z.ZodString; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; }, z.core.$strict>; declare const compiledSandboxWorkspaceSchema: z.ZodObject<{ logicalPath: z.ZodString; rootEntries: z.ZodReadonly<z.ZodArray<z.ZodString>>; sourceId: z.ZodString; sourcePath: z.ZodString; }, z.core.$strict>; declare const compiledWorkspaceResourceRootSchema: z.ZodObject<{ contentHash: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; rootEntries: z.ZodReadonly<z.ZodArray<z.ZodString>>; }, z.core.$strict>; declare const compiledConnectionDefinitionSchema: z.ZodObject<{ connectionName: z.ZodString; description: z.ZodString; exportName: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; protocol: z.ZodDefault<z.ZodEnum<{ mcp: "mcp"; openapi: "openapi"; }>>; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; url: z.ZodString; vercelConnect: z.ZodOptional<z.ZodObject<{ connector: z.ZodString; }, z.core.$strict>>; }, z.core.$strict>; /** * Zod schema for one non-recursive compiled authored agent payload. */ declare const compiledAgentNodeManifestSchema: z.ZodObject<{ agentRoot: z.ZodString; appRoot: z.ZodString; channels: z.ZodArray<z.ZodType<CompiledChannelEntry, unknown, z.core.$ZodTypeInternals<CompiledChannelEntry, unknown>>>; config: z.ZodType<CompiledAgentDefinition, unknown, z.core.$ZodTypeInternals<CompiledAgentDefinition, unknown>>; connections: z.ZodArray<z.ZodObject<{ connectionName: z.ZodString; description: z.ZodString; exportName: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; protocol: z.ZodDefault<z.ZodEnum<{ mcp: "mcp"; openapi: "openapi"; }>>; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; url: z.ZodString; vercelConnect: z.ZodOptional<z.ZodObject<{ connector: z.ZodString; }, z.core.$strict>>; }, z.core.$strict>>; diagnosticsSummary: z.ZodObject<{ errors: z.ZodNumber; warnings: z.ZodNumber; }, z.core.$strict>; disabledFrameworkTools: z.ZodReadonly<z.ZodArray<z.ZodString>>; workflowEnabled: z.ZodDefault<z.ZodBoolean>; dynamicInstructions: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicInstructionsDefinition, unknown>>>>; dynamicSkills: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicSkillDefinition, unknown>>>>; dynamicTools: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicToolDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicToolDefinition, unknown>>>>; hooks: z.ZodArray<z.ZodType<CompiledHookDefinition, unknown, z.core.$ZodTypeInternals<CompiledHookDefinition, unknown>>>; sandbox: z.ZodNullable<z.ZodObject<{ backendName: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; exportName: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; revalidationKey: z.ZodOptional<z.ZodString>; sourceHash: z.ZodString; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; }, z.core.$strict>>; sandboxWorkspaces: z.ZodArray<z.ZodObject<{ logicalPath: z.ZodString; rootEntries: z.ZodReadonly<z.ZodArray<z.ZodString>>; sourceId: z.ZodString; sourcePath: z.ZodString; }, z.core.$strict>>; schedules: z.ZodArray<z.ZodObject<{ cron: z.ZodString; hasRun: z.ZodBoolean; name: z.ZodString; logicalPath: z.ZodString; markdown: z.ZodOptional<z.ZodString>; sourceId: z.ZodString; sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>; }, z.core.$strict>>; remoteAgents: z.ZodArray<z.ZodType<Readonly<ModuleSourceRef & Node & { description: string; entryPath: string; name: string; outputSchema?: import("../shared/json.ts").JsonObject; path: string; rootPath: string; url: string; }>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & { description: string; entryPath: string; name: string; outputSchema?: import("../shared/json.ts").JsonObject; path: string; rootPath: string; url: string; }>, unknown>>>; skills: z.ZodReadonly<z.ZodArray<z.ZodType<CompiledSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledSkillDefinition, unknown>>>>; instructions: z.ZodOptional<z.ZodObject<{ name: z.ZodString; logicalPath: z.ZodString; markdown: z.ZodString; sourceId: z.ZodString; sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>; }, z.core.$strict>>; tools: z.ZodArray<z.ZodObject<{ description: z.ZodString; exportName: z.ZodOptional<z.ZodString>; inputSchema: z.ZodNullable<z.ZodType<import("../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.ts").JsonObject, unknown>>>; logicalPath: z.ZodString; name: z.ZodString; outputSchema: z.ZodOptional<z.ZodType<import("../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.ts").JsonObject, unknown>>>; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; }, z.core.$strict>>; workspaceResourceRoot: z.ZodObject<{ contentHash: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; rootEntries: z.ZodReadonly<z.ZodArray<z.ZodString>>; }, z.core.$strict>; }, z.core.$strict>; /** * Zod schema for the versioned compiled manifest emitted by the compiler. */ export declare const compiledAgentManifestSchema: z.ZodObject<{ agentRoot: z.ZodString; appRoot: z.ZodString; channels: z.ZodArray<z.ZodType<CompiledChannelEntry, unknown, z.core.$ZodTypeInternals<CompiledChannelEntry, unknown>>>; config: z.ZodType<CompiledAgentDefinition, unknown, z.core.$ZodTypeInternals<CompiledAgentDefinition, unknown>>; connections: z.ZodArray<z.ZodObject<{ connectionName: z.ZodString; description: z.ZodString; exportName: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; protocol: z.ZodDefault<z.ZodEnum<{ mcp: "mcp"; openapi: "openapi"; }>>; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; url: z.ZodString; vercelConnect: z.ZodOptional<z.ZodObject<{ connector: z.ZodString; }, z.core.$strict>>; }, z.core.$strict>>; diagnosticsSummary: z.ZodObject<{ errors: z.ZodNumber; warnings: z.ZodNumber; }, z.core.$strict>; disabledFrameworkTools: z.ZodReadonly<z.ZodArray<z.ZodString>>; workflowEnabled: z.ZodDefault<z.ZodBoolean>; dynamicInstructions: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicInstructionsDefinition, unknown>>>>; dynamicSkills: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicSkillDefinition, unknown>>>>; dynamicTools: z.ZodDefault<z.ZodArray<z.ZodType<CompiledDynamicToolDefinition, unknown, z.core.$ZodTypeInternals<CompiledDynamicToolDefinition, unknown>>>>; hooks: z.ZodArray<z.ZodType<CompiledHookDefinition, unknown, z.core.$ZodTypeInternals<CompiledHookDefinition, unknown>>>; kind: z.ZodLiteral<"eve-agent-compiled-manifest">; remoteAgents: z.ZodArray<z.ZodType<Readonly<ModuleSourceRef & Node & { description: string; entryPath: string; name: string; outputSchema?: import("../shared/json.ts").JsonObject; path: string; rootPath: string; url: string; }>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & { description: string; entryPath: string; name: string; outputSchema?: import("../shared/json.ts").JsonObject; path: string; rootPath: string; url: string; }>, unknown>>>; sandbox: z.ZodNullable<z.ZodObject<{ backendName: z.ZodOptional<z.ZodString>; description: z.ZodOptional<z.ZodString>; exportName: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; revalidationKey: z.ZodOptional<z.ZodString>; sourceHash: z.ZodString; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; }, z.core.$strict>>; sandboxWorkspaces: z.ZodArray<z.ZodObject<{ logicalPath: z.ZodString; rootEntries: z.ZodReadonly<z.ZodArray<z.ZodString>>; sourceId: z.ZodString; sourcePath: z.ZodString; }, z.core.$strict>>; schedules: z.ZodArray<z.ZodObject<{ cron: z.ZodString; hasRun: z.ZodBoolean; name: z.ZodString; logicalPath: z.ZodString; markdown: z.ZodOptional<z.ZodString>; sourceId: z.ZodString; sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>; }, z.core.$strict>>; skills: z.ZodReadonly<z.ZodArray<z.ZodType<CompiledSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledSkillDefinition, unknown>>>>; subagentEdges: z.ZodArray<z.ZodType<CompiledSubagentEdge, unknown, z.core.$ZodTypeInternals<CompiledSubagentEdge, unknown>>>; subagents: z.ZodArray<z.ZodType<Readonly<ModuleSourceRef & Node & { agent: CompiledAgentNodeManifest; description: string; entryPath: string; name: string; rootPath: string; }>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & { agent: CompiledAgentNodeManifest; description: string; entryPath: string; name: string; rootPath: string; }>, unknown>>>; instructions: z.ZodOptional<z.ZodObject<{ name: z.ZodString; logicalPath: z.ZodString; markdown: z.ZodString; sourceId: z.ZodString; sourceKind: z.ZodUnion<readonly [z.ZodLiteral<"markdown">, z.ZodLiteral<"module">]>; }, z.core.$strict>>; tools: z.ZodArray<z.ZodObject<{ description: z.ZodString; exportName: z.ZodOptional<z.ZodString>; inputSchema: z.ZodNullable<z.ZodType<import("../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.ts").JsonObject, unknown>>>; logicalPath: z.ZodString; name: z.ZodString; outputSchema: z.ZodOptional<z.ZodType<import("../shared/json.ts").JsonObject, unknown, z.core.$ZodTypeInternals<import("../shared/json.ts").JsonObject, unknown>>>; sourceId: z.ZodString; sourceKind: z.ZodLiteral<"module">; }, z.core.$strict>>; version: z.ZodLiteral<30>; workspaceResourceRoot: z.ZodObject<{ contentHash: z.ZodOptional<z.ZodString>; logicalPath: z.ZodString; rootEntries: z.ZodReadonly<z.ZodArray<z.ZodString>>; }, z.core.$strict>; }, z.core.$strict>; /** * Creates a compiled authored agent payload with stable defaults. */ export declare function createCompiledAgentNodeManifest(input: { readonly agentRoot: string; readonly appRoot: string; readonly channels?: readonly CompiledChannelEntry[]; readonly config: CompiledAgentDefinition; readonly connections?: readonly CompiledConnectionDefinition[]; readonly diagnosticsSummary?: DiscoverDiagnosticsSummary; readonly disabledFrameworkTools?: readonly string[]; readonly workflowEnabled?: boolean; readonly dynamicInstructions?: readonly CompiledDynamicInstructionsDefinition[]; readonly dynamicSkills?: readonly CompiledDynamicSkillDefinition[]; readonly dynamicTools?: readonly CompiledDynamicToolDefinition[]; readonly hooks?: readonly CompiledHookDefinition[]; readonly remoteAgents?: readonly CompiledRemoteAgentNode[]; readonly sandbox?: CompiledSandboxDefinition | null; readonly sandboxWorkspaces?: readonly CompiledSandboxWorkspace[]; readonly schedules?: readonly CompiledScheduleDefinition[]; readonly skills?: readonly CompiledSkillDefinition[]; readonly instructions?: CompiledInstructions; readonly tools?: readonly CompiledToolDefinition[]; readonly workspaceResourceRoot?: CompiledWorkspaceResourceRoot; }): CompiledAgentNodeManifest; /** * Computes the sorted `rootEntries` advertised by the workspace resource * tree for one graph node. * * Shared by the synthetic manifest factory (used in tests and the * in-memory compile path) and by `materializeWorkspaceResources` so both * paths emit identical descriptors. */ export declare function deriveResourceRootEntries(input: { readonly sandboxWorkspaces?: readonly CompiledSandboxWorkspace[]; readonly skills?: readonly CompiledSkillDefinition[]; }): readonly string[]; /** * Creates one stable compiled subagent node id from the parent node id and the * source entry discovered in that parent package. */ export declare function createCompiledSubagentNodeId(parentNodeId: string, sourceId: string): string; /** * Creates a compiled manifest with stable defaults. */ export declare function createCompiledAgentManifest(input: { readonly agentRoot: string; readonly appRoot: string; readonly channels?: readonly CompiledChannelEntry[]; readonly config: CompiledAgentDefinition; readonly connections?: readonly CompiledConnectionDefinition[]; readonly diagnosticsSummary?: DiscoverDiagnosticsSummary; readonly disabledFrameworkTools?: readonly string[]; readonly workflowEnabled?: boolean; readonly dynamicSkills?: readonly CompiledDynamicSkillDefinition[]; readonly dynamicTools?: readonly CompiledDynamicToolDefinition[]; readonly hooks?: readonly CompiledHookDefinition[]; readonly remoteAgents?: readonly CompiledRemoteAgentNode[]; readonly sandbox?: CompiledSandboxDefinition | null; readonly sandboxWorkspaces?: readonly CompiledSandboxWorkspace[]; readonly schedules?: readonly CompiledScheduleDefinition[]; readonly skills?: readonly CompiledSkillDefinition[]; readonly subagentEdges?: readonly CompiledSubagentEdge[]; readonly subagents?: readonly CompiledSubagentNode[]; readonly instructions?: CompiledInstructions; readonly tools?: readonly CompiledToolDefinition[]; }): CompiledAgentManifest;