import type { AgentModelOverride, AgentTokenEntry, Context, DelayedSignalCancelRepeatKeyInput, DelayedSignalScheduleInput, SessionPermissions, Signal, SignalSubscription } from "@/types"; import type { AuthStore } from "../../auth/store.js"; import type { Storage } from "../../storage/storage.js"; import type { ConfigModule } from "../config/configModule.js"; import type { Crons } from "../cron/crons.js"; import type { Heartbeats } from "../heartbeat/heartbeats.js"; import type { EngineEventBus } from "../ipc/events.js"; import { Memory } from "../memory/memory.js"; import type { ConnectorRegistry } from "../modules/connectorRegistry.js"; import type { ImageGenerationRegistry } from "../modules/imageGenerationRegistry.js"; import type { InferenceRouter } from "../modules/inference/router.js"; import type { ToolResolver } from "../modules/toolResolver.js"; import type { PluginManager } from "../plugins/manager.js"; import type { Signals } from "../signals/signals.js"; import { UserHome } from "../users/userHome.js"; import type { AgentDescriptor, AgentFetchStrategy } from "./ops/agentDescriptorTypes.js"; import type { AgentInboxItem, AgentInboxResult, AgentInboxSteering, AgentPostTarget } from "./ops/agentTypes.js"; type DelayedSignalsFacade = { schedule: (input: DelayedSignalScheduleInput) => Promise; cancelByRepeatKey: (input: DelayedSignalCancelRepeatKeyInput) => Promise; }; export type AgentSystemOptions = { config: ConfigModule; eventBus: EngineEventBus; storage?: Storage; connectorRegistry: ConnectorRegistry; imageRegistry: ImageGenerationRegistry; toolResolver: ToolResolver; pluginManager: PluginManager; inferenceRouter: InferenceRouter; authStore: AuthStore; memory?: Memory; delayedSignals?: DelayedSignalsFacade; }; export declare class AgentSystem { readonly config: ConfigModule; readonly eventBus: EngineEventBus; readonly storage: Storage; readonly connectorRegistry: ConnectorRegistry; readonly imageRegistry: ImageGenerationRegistry; readonly toolResolver: ToolResolver; readonly pluginManager: PluginManager; readonly inferenceRouter: InferenceRouter; readonly authStore: AuthStore; readonly memory: Memory; private readonly delayedSignals; private _crons; private _heartbeats; private _signals; private entries; private keyMap; private stage; constructor(options: AgentSystemOptions); get crons(): Crons; setCrons(crons: Crons): void; get heartbeats(): Heartbeats; setHeartbeats(heartbeats: Heartbeats): void; get signals(): Signals; setSignals(signals: Signals): void; load(): Promise; start(): Promise; post(ctx: Context, target: AgentPostTarget, item: AgentInboxItem): Promise; postAndAwait(ctx: Context, target: AgentPostTarget, item: AgentInboxItem): Promise; /** * Posts an inbox item to all user-facing agents owned by a specific user. * Expects: targetUserId is an internal user id. */ postToUserAgents(targetUserId: string, item: AgentInboxItem): Promise; /** * Resolves a target to its concrete agent id, creating/restoring when needed. * Expects: descriptor targets are valid for agent creation. */ agentIdForTarget(ctx: Context, target: AgentPostTarget): Promise; tokensForTarget(ctx: Context, target: AgentPostTarget): Promise; agentExists(agentId: string): Promise; /** * Reads agent + user identity by agent id. * Returns: null when the agent does not exist in memory or storage. */ contextForAgentId(agentId: string): Promise; signalDeliver(signal: Signal, subscriptions: SignalSubscription[]): Promise; /** * Delivers a steering message to an agent, interrupting its current work. * The current tool completes but remaining queued tools are cancelled. * Wakes the agent if sleeping. */ steer(ctx: Context, agentId: string, steering: AgentInboxSteering): Promise; /** * Aborts the active inference call for a loaded agent target. * Returns false when the target is not loaded or has no active inference. */ abortInferenceForTarget(target: AgentPostTarget): boolean; markStopped(agentId: string, error?: unknown): void; sleepIfIdle(agentId: string, reason: "message" | "system_message" | "signal" | "reset" | "compact" | "restore"): Promise; agentFor(ctx: Context, strategy: AgentFetchStrategy): string | null; /** * Returns the descriptor for an agent by id. * Returns null if the agent is not found. */ getAgentDescriptor(agentId: string): AgentDescriptor | null; /** * Updates a loaded agent descriptor in memory without changing its identity. * Expects: descriptor type does not require keyMap changes (e.g. permanent agents). */ updateAgentDescriptor(agentId: string, descriptor: AgentDescriptor): void; /** * Updates a loaded agent's permissions in memory. * Expects: permissions have already been persisted if needed. */ updateAgentPermissions(agentId: string, permissions: SessionPermissions, updatedAt: number): void; /** * Updates a loaded agent's model override in memory and persists it. * Returns false when the agent is not loaded. */ updateAgentModelOverride(agentId: string, override: AgentModelOverride | null): Promise; inReadLock(operation: () => Promise): Promise; deleteInboxItem(id: string): Promise; private findLoadedEntry; private resolveEntry; private registerEntry; private startEntryIfRunning; private enqueueEntry; private replayPersistedInboxItems; private wakeEntryIfSleeping; private scheduleIdleSignal; private cancelIdleSignal; private schedulePoisonPill; private cancelPoisonPill; private signalLifecycle; private handlePoisonPill; private markEntryDead; private restoreAgent; private resolveUserIdForDescriptor; private resolveUserIdForConnectorKey; ownerCtxEnsure(): Promise; /** * Resolves a UserHome facade for a concrete user id. * Expects: userId belongs to an existing or soon-to-be-created runtime user. */ userHomeForUserId(userId: string): UserHome; /** * Resolves a UserHome facade from caller context. * Expects: ctx.userId belongs to an existing or soon-to-be-created runtime user. */ userHomeForCtx(ctx: Context): UserHome; private createCompletion; } export {}; //# sourceMappingURL=agentSystem.d.ts.map