import { type GroupTaskFocus } from './channels/qq/task-focus.js'; import type { ChannelActivityRegistry } from './channels/activity-registry.js'; import { type ImageInputOrigin } from './conversation-history-recall.js'; import type { SleepService } from './character/sleep-service.js'; import type { ScheduledPartnerTask } from './scheduler/domain.js'; import type { Context } from '@deepseek-ai/cordis'; import type { Agent } from '@deepseek-ai/dsh-agent'; import type { AgentDefaultModelConfig } from '@deepseek-ai/dsh-agent-default-model'; import type { AgentPresetRegistry as AgentPresets } from '@deepseek-ai/dsh-agent-preset-registry'; import type { UserMessage } from '@deepseek-ai/dsh-llm'; import type { SessionId } from '@deepseek-ai/dsh-session'; import type { Session, SessionEvent } from '@deepseek-ai/dsh-session'; import type { WorkspaceRegistry } from '@deepseek-ai/dsh-workspace'; import type { ToolRuntime } from '@deepseek-ai/dsh-tools'; import type { Companion, ChannelSession } from './domain.js'; import { PartnerStore } from './store.js'; import type { PartnerMemoryStore } from './memory-store.js'; import type { MemoryContextConnection } from './memory-domain.js'; import type { MemoryReflectionService } from './memory-reflection.js'; import { type ConcernObservation, type ConcernObservationCandidate, type PartnerConcern } from './concern-domain.js'; import type { PartnerConcernStore } from './concern-store.js'; import type { BoardTask } from './tasks/domain.js'; import type { PartnerInboundMessage, PartnerReply } from './channel-message.js'; import { type ConcernSource } from './concern-sources.js'; import type { ConcernExecutionReceipt } from './concern-execution.js'; import { type ReplyProgress } from './execution/reply-progress.js'; export { extractOutboundAttachments } from './channels/outbound-media.js'; export { renderToolProtocol, resolvePartnerAgentOptions as resolveAgentOptions } from './execution/agent-support.js'; type RuntimeContext = Context & { agents: Context['agents']; agentDefaultModel: AgentDefaultModelConfig; agentPresets: AgentPresets; workspaceRegistry: WorkspaceRegistry; tools: ToolRuntime; }; export interface PartnerAgentComposer { compose(ctx: Context & { tools: ToolRuntime; }, companion: Companion): (() => void) | Promise<() => void>; } export type PartnerQuestionAnswerer = (ctx: Context, route: ChannelSession) => () => void; export interface HeartbeatToolTrace { name: string; input: string; output: string; startedAt: number; completedAt: number; status: 'completed' | 'failed'; } export interface HeartbeatExecution { recording?: Array<{ concernId: string; state: 'synced' | 'pending'; }>; rounds?: Array<{ round: number; phase: 'check' | 'final'; modelMs: number; outputChars: number; retries?: import('./observation-model-retry.js').ObservationRetry[]; }>; blocked?: string[]; blockedReasons?: Record; checkOutcomes?: Record; failures?: Record; concerns: PartnerConcern[]; candidates: ConcernObservationCandidate[]; observations?: ConcernObservation[]; startedAt: number; completedAt: number; output?: string; error?: string; tools: HeartbeatToolTrace[]; } export type HeartbeatOutcome = 'notified' | 'quiet' | 'failed'; export declare class PartnerAgentRuntime { private readonly ctx; private readonly store; private readonly defaultCwd; private readonly memory?; private readonly reflection?; private readonly concerns?; private readonly composer?; private readonly channelActivities; private readonly timeZone; private readonly backgroundArtifacts; runtimePolicyForSession(sessionId: string): import("./companions/runtime-policy.js").CompanionRuntimePolicy | undefined; private interestRequests; interestClaim(sessionId: string): { owner: string; messageId: import("@deepseek-ai/dsh-llm").MessageId; counter: { messageId: string; steps: number; }; valid: boolean; } | undefined; stopInterest(sessionId: string, messageId: string): void; interestLimit(sessionId: string, reason: string): Promise; private continuousService?; private continuousClaims; setContinuousService(service: import('./continuous/service.js').ContinuousService): void; continuousClaim(sessionId: string): { owner: string; task: import("./continuous/domain.js").ContinuousTask; agent: Agent; messageId: string; userMessageId: string; steps: number; } | undefined; continuousBusy(sessionId: string): boolean; continuousConversation(task: import('./continuous/domain.js').ContinuousTask): string; cancelContinuous(task: import('./continuous/domain.js').ContinuousTask): void; wakeContinuous(owner: string, task: import('./continuous/domain.js').ContinuousTask): Promise; private readonly latestPostReplyInput; private readonly handles; private readonly queues; private readonly replyQueue; private readonly replySlots; private readonly heartbeatQueues; private readonly taskQueues; private readonly preparingGroupInputs; private readonly steeringQueues; private readonly channelReplyOwners; private readonly channelReplyFocus; groupReplyFocus(channelId: string, userId: string): GroupTaskFocus | undefined; private readonly workspaces; private readonly restoredCompositions; private readonly restoredCompositionJobs; private readonly disposeAgentListener; private readonly disposeConfigurationListener; private readonly disposeToolAuthority; private readonly disposeAssemblyListener; private readonly disposeRollingContext; private readonly disposePreparation; private readonly autonomousAssemblyContexts; private readonly rebuildingAssemblies; private readonly configurations; private browserContexts?; private readonly characterContexts; private readonly preparedTurns; private readonly observationJobs; private readonly agentSetupJobs; private readonly sessionRecoveryJobs; private closed; private stickerTagsContext?; setStickerTagsContext(provider: (route: ChannelSession, signal: AbortSignal) => Promise): void; private questionAnswerer; constructor(ctx: RuntimeContext, store: PartnerStore, defaultCwd: string, memory?: PartnerMemoryStore | undefined, reflection?: MemoryReflectionService | undefined, concerns?: PartnerConcernStore | undefined, composer?: PartnerAgentComposer | undefined, channelActivities?: ChannelActivityRegistry, timeZone?: string, backgroundArtifacts?: boolean); private sleepService; setSleepService(service: SleepService): void; setQuestionAnswerer(answerer: PartnerQuestionAnswerer): void; /** Cancel pending/claimed continuations as soon as another real input is admitted. */ cancelPostReply(companionId: string, keepUserMessageId?: string, sessionId?: string): Promise; localReplyDisplayed(source: NonNullable): Promise; /** Called only after delivery succeeds; autonomous notices never carry this provenance. */ replyDelivered(source: NonNullable): Promise; /** Only a model-authored intention can continue; no random post-reply draw. */ continueCompletedActivity(companionId: string): Promise; /** Use the existing timer and real conversation; never impersonate user input. */ idleContact(companionId: string, timeZone?: string): Promise; idleContactDeliveryCurrent(origin: NonNullable): Promise; reply(companion: Companion, channelId: string, userId: string, message: PartnerInboundMessage, progress?: ReplyProgress): Promise; private enqueueReply; steer(companion: Companion, channelId: string, userId: string, message: PartnerInboundMessage): Promise; private deliverSteering; prepareSession(routeId: string): Promise; ensureLocalSessionRecord(companionId: string): Promise; createLocalSession(companionId: string): Promise; prepareBackgroundDelivery(run: import('./execution/domain.js').ExecutionRun, reply: PartnerReply): Promise; deliverLocalBackgroundResult(run: import('./execution/domain.js').ExecutionRun, reply: PartnerReply): Promise; private restoreBackgroundArtifacts; notifyTaskProgress(task: BoardTask, previousStatus: BoardTask['status']): Promise; wakeSchedule(entry: ScheduledPartnerTask, signal: AbortSignal): Promise; reconcileConcern(receipt: ConcernExecutionReceipt): Promise; canResumeConcern(receipt: ConcernExecutionReceipt): Promise; executeConcern(receipt: ConcernExecutionReceipt, concern: PartnerConcern, prompt: string): Promise; executeTask(input: { sourceId: string; companion: Companion; prompt: string; parentSessionId?: string; signal?: AbortSignal; }): Promise<{ run: { id: string; }; output: string; }>; isArchived(route: ChannelSession): boolean; renewSession(routeId: string): Promise; heartbeat(companion: Companion, route: ChannelSession, concerns: PartnerConcern[]): Promise; concernSources(companion: Companion, query?: string): Promise; recordingSources(companion: Companion, query?: string): Promise<({ kind: "file"; locator: string; label: string; } | { kind: "note"; locator: string; label: string; })[]>; validateRecordingTarget(companion: Companion, raw: unknown): Promise; private runHeartbeatWhenIdle; observeSessionEvent(session: Session, event: SessionEvent): Promise; private processSessionEvent; recordConcernCreatedNotice(companion: Companion, scopeId: string, concerns: PartnerConcern[]): Promise; recordConcernNotification(companion: Companion, observation: ConcernObservation): Promise; private isCurrentConcernSession; private appendConcernNotice; /** Append a visible receipt without starting another agent turn; its receipt survives restarts. */ recordRequirementResult(route: ChannelSession, receipt: string, text: string, files: import('./attachments/service.js').AttachmentDelivery[], service: import('./attachments/service.js').AttachmentDeliveryService, prefix: string): Promise; private driveScopedHeartbeat; recordHeartbeatActivity(companion: Companion, execution: HeartbeatExecution, outcome: HeartbeatOutcome, deliveryError?: string): Promise; resetCompanion(companionId: string): Promise; removeCompanionWorkspace(companionId: string): Promise; private sharedDirectoryPaths; validateCompanionDirectory(companionId: string): Promise; removeCompanionDirectory(companionId: string): Promise; reloadCompanion(companionId: string): Promise; /** Prepare per-turn context after the Agent's scoped tool registrations are committed. */ prepareAgentTurn(agent: Agent, turn: number, signal: AbortSignal, messages?: readonly UserMessage[]): Promise; /** Also used by assembly: never return a model-facing snapshot before setup. */ prepareAgentAssembly(agent: Agent, signal: AbortSignal): Promise; private readonly replyPresentations; private readonly contextRevisions; private conversationClocks?; private groupMemoryWindows?; private readonly admittedInputTimes; private readonly admittedInputs; /** Projection only: the host commits admitted input after prompt preparation. */ private inputEvents; private admittedInputTime; private prepareConversationContext; /** Recover missed completed private turns from original events, without replaying * tools, sending replies, or changing the rolling conversation window. */ recoverConversationMemory(companionId: string): Promise; /** Catch up visible legacy/interrupted turns before the final review; retries use stable IDs. */ prepareRenewalMemory(companionId: string): Promise; renewReviewedContexts(companionId: string, day: string): Promise; companionActivity(companionId: string, channelId?: string): { kind: string; label: string; sessionId?: string; }[]; isCompanionBusy(companionId: string): boolean; private releaseCompanion; resetChannel(channelId: string): Promise; close(): Promise; private releaseRestoredComposition; private drive; quotedImages(companionId: string, channelId: string, userId: string, messageId: string): Promise>; private rememberMessageOrigin; private persistInbound; reconcileQqSessions(): Promise; private ensureSession; private nameQqSession; private ensureAgent; private ensureAgentReady; private composeRestoredAgent; private attachSession; } export declare function selectTaskNotificationRoute(routes: readonly ChannelSession[], creatorSessionId: string | undefined, archived: (route: ChannelSession) => boolean): ChannelSession | undefined; export declare function completedTurnEvents(events: readonly SessionEvent[], end: Extract): readonly SessionEvent[]; export declare function memoryScope(channelId: string, userId: string): string; export declare function renderMemory(entries: NonNullable>>, connections?: MemoryContextConnection[], scenes?: import('./memory-artifacts.js').SceneView[], history?: import('./memory-domain.js').MemoryRecallContext['history']): string; export declare function canReuseSession(route: ChannelSession, companionId: string, archivedSessionIds: readonly SessionId[]): boolean; export declare function renewedSession(previous: ChannelSession, now?: number): ChannelSession; export declare function partnerCwd(root: string, companionId: string): string; interface HeartbeatToolPolicy { allowed: Set; } export declare function heartbeatToolPolicy(concerns: PartnerConcern[], available: Iterable): HeartbeatToolPolicy; export declare function parseConcernObservations(raw: string, allowedIds: Set): ConcernObservationCandidate[]; interface HeartbeatFileAccess { root: string; writable: Set; } export declare function heartbeatToolDenial(name: string, argumentsValue: unknown, access?: HeartbeatFileAccess): string | undefined; export declare function renderHeartbeatActivity(execution: HeartbeatExecution, outcome: HeartbeatOutcome, deliveryError?: string): string; //# sourceMappingURL=agent-runtime.d.ts.map