import type { DynamicAgentFunction, DynamicAgentRenderOptions } from './dynamic-agent.js'; import type { Schema } from './schema.js'; import type { AgentInit, FabricActor, FabricAgent, JsonValue, SessionStore } from './types.js'; declare const persistentAgentSymbol: unique symbol; /** * Per-interaction context passed to a {@link createAgent} initializer. `id` is * the URL `` of the addressed instance (or the dispatch target id); `env` * is the platform environment supplied by the runtime. */ export interface PersistentAgentContext> { readonly id: string; readonly env: TEnv; } /** * Public triggers supported by persistent agents. Scheduling requires a * concrete instance id and message, so cron belongs on a finite dispatcher job. */ export interface PersistentAgentTriggers { webhook?: boolean; manual?: boolean; schedule?: never; [key: string]: string | string[] | boolean | undefined; } /** Static retry and wall-clock budget applied to every durable submission. */ export interface PersistentAgentDurabilityConfig { /** Maximum total execution attempts, including the initial attempt. Default: 10. */ maxAttempts?: number; /** Maximum wall-clock time from admission until terminal settlement. Default: one hour. */ timeoutMs?: number; } /** * Runtime configuration returned by a {@link createAgent} initializer. Mirrors * the agent-level slice of {@link AgentInit}; `instructions` becomes the * session system prompt (a role), and `subagents` map to named roles. */ export interface PersistentAgentConfig extends Pick { name?: string; description?: string; /** System prompt for the instance's sessions. */ instructions?: string; /** Named subagent profiles, exposed as roles. */ subagents?: AgentInit['roles']; /** Optional schema validating direct-prompt / dispatch payloads. */ input?: Schema; /** Static schema validating immutable creation data before the first render. */ initialData?: Schema; /** * Static durable-submission policy. Declare this in createAgent()'s second * argument so admission can apply it even when rendering fails. */ durability?: PersistentAgentDurabilityConfig; /** Public exposure declarations. Persistent schedules are not supported; use a finite dispatcher job. */ triggers?: PersistentAgentTriggers; } /** * A persistent, addressable agent created with {@link createAgent}. Distinct * from a finite `defineAgent({ run })` job: it has no `run` — the initializer returns * configuration, and the runtime maintains sessions across interactions. */ export interface CreatedAgent> { readonly [persistentAgentSymbol]: true; /** Static metadata available to hosts without rendering interaction hooks. */ readonly definition: Readonly; readonly initialize: (context: PersistentAgentContext) => PersistentAgentConfig | Promise; /** Host-aware render used by persistent runtimes to attach durable hook state. */ readonly render: (context: PersistentAgentContext, options?: DynamicAgentRenderOptions) => Promise; } /** * Define a persistent, URL-addressable agent. Files in `.fabricharness/agents/` * default-export `createAgent(...)`; the runtime resolves a fresh config per * interaction and keeps sessions across direct prompts and dispatched inputs. */ export declare function createAgent>(initialize: ((context: PersistentAgentContext) => PersistentAgentConfig | Promise) | DynamicAgentFunction, definition?: PersistentAgentConfig): CreatedAgent; /** Validate and normalize a persistent agent's static submission policy. */ export declare function validatePersistentAgentDurability(durability: PersistentAgentDurabilityConfig): PersistentAgentDurabilityConfig; /** Resolve a static policy into the store's absolute durability stamp. */ export declare function persistentAgentSubmissionDurability(created: CreatedAgent, acceptedAt: number): import('./submission-store.js').AgentSubmissionDurability | undefined; /** Reject contradictory existing-incarnation and instance-creation inputs. */ export declare function validatePersistentInstanceContact(uid: string | null | undefined, initialData: unknown): void; /** Return the {@link CreatedAgent} carried by a value, or `undefined`. */ export declare function getCreatedAgent(value: unknown): CreatedAgent | undefined; /** Whether a value is a {@link CreatedAgent}. */ export declare function isCreatedAgent(value: unknown): value is CreatedAgent; /** Validate and normalize creation data before an instance generation is admitted. */ export declare function validatePersistentInitialData(created: CreatedAgent, initialData: unknown): JsonValue; /** * Store-session key for a persistent instance's named session. Collapses the * `(agentName, instanceId, sessionName)` identity onto Fabric's single-string * `sessionId`, keeping persistent sessions inside the existing session stores. */ export declare function persistentStoreSessionId(agentName: string, instanceId: string, sessionName?: string): string; /** Instance-scoped metadata key shared by every named session of one persistent agent. */ export declare function persistentInstanceStoreId(agentName: string, instanceId: string): string; export interface PersistentInstanceIdentity { uid: string; tenantId?: string; } /** Atomically resolve or create one tenant-scoped persistent instance generation. */ export declare function ensurePersistentInstanceIdentity(options: { store: SessionStore; agentName: string; instanceId: string; uid?: string | null; tenantId?: string; actor?: FabricActor; }): Promise; /** Decoded identity of a persistent instance session store key. */ export interface PersistentSessionIdentity { agent: string; instanceId: string; session: string; } /** * Inverse of {@link persistentStoreSessionId}: decode a store session id back * into `{ agent, instanceId, session }`, or `undefined` if it is not a * persistent-instance key. Useful for admin surfaces that list raw session ids. */ export declare function parsePersistentSessionId(storeSessionId: string): PersistentSessionIdentity | undefined; /** Translate a {@link PersistentAgentConfig} into an {@link AgentInit}. */ export declare function persistentConfigToAgentInit(config: PersistentAgentConfig, id: string): AgentInit; /** * Resolve a persistent agent's config for an instance and build a * {@link FabricAgent}. Runtime-specific resources (session store, workspace * roles/skills, loop runtime) are layered by the host that calls this. */ export declare function initializePersistentAgent(created: CreatedAgent, context: PersistentAgentContext, overrides?: AgentInit): Promise<{ config: PersistentAgentConfig; agent: FabricAgent; }>; export {}; //# sourceMappingURL=persistent-agent.d.ts.map