import type { Context } from '@deepseek-ai/cordis'; import type { Agent, AgentHandle, AgentSetup, CreateAgentOptions, ResumeAgentOptions } from '@deepseek-ai/dsh-agent'; import type { SessionLease, SessionLeaseClaim, SessionLeaseTarget } from './session-lease-types.js'; export type CompatibleAgentSetup = (ctx: Context, agent?: Agent) => ReturnType; export interface SessionLeasePort { leaseMs: number; /** Whether this durable Session is Delivery-owned and must have a local execution lease. */ requiresLease(sessionId: string): boolean; claim(target: SessionLeaseTarget, holderId: string, leaseMs: number): SessionLeaseClaim; dispatch(lease: SessionLease): boolean; valid(lease: SessionLease): boolean; renew(lease: SessionLease, leaseMs: number): boolean; finish(lease: SessionLease, input: { quiescent: boolean; }): boolean; } export declare class SessionLeaseUnavailable extends Error { readonly kind: 'busy' | 'unknown' | 'denied'; constructor(kind: 'busy' | 'unknown' | 'denied'); } /** One process-local owner of a durable token. Unknown is never a takeover grant. */ export declare class SessionExecutionLease { #private; readonly token: SessionLease; private readonly port; private readonly released; readonly controller: AbortController; readonly agents: Map; constructor(token: SessionLease, port: SessionLeasePort, outer: AbortSignal, released: () => void); get signal(): AbortSignal; assert(): void; assertAgent(agent: Agent): void; dispatch(): void; attach(agent: Agent): void; disposed(agent: Agent): void; enter(): () => void; cancel(reason?: unknown): void; close(): void; /** A rejected cold resume can leave an unobservable, abort-raced load behind. */ abandonConstruction(): void; } /** Shared by bound foreground work and unbound Session construction; wake must use this same port. */ export declare class DeliverySessionLeases { #private; private readonly ctx; private readonly port; constructor(ctx: Context, port: SessionLeasePort); /** Host-only, one occurrence: a client source tag alone never grants owner authority. */ admitNativeInput(agent: Agent, input: { requestId: string; content: readonly unknown[]; onClaimed(turn: number): void; }): { inserted(): boolean; dispose(): void; }; get leaseMs(): number; /** * Use the host's one factory and the caller's ownership scope. These methods * only consume an already admitted lease; they do not authorize Web input. */ create(owner: Context, options: CreateAgentOptions): Promise; resume(owner: Context, options: ResumeAgentOptions): Promise; open(target: SessionLeaseTarget, signal: AbortSignal): SessionExecutionLease; attach(agent: Agent): void; assert(sessionId: string): void; cancel(sessionId: string, reason: unknown): void; disposed(agent: Agent): void; } //# sourceMappingURL=session-lease-runtime.d.ts.map