eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
82 lines (81 loc) • 3.18 kB
TypeScript
import type { DurableSession } from "#execution/durable-session-store.js";
import type { HarnessSession } from "#harness/types.js";
import type { RuntimeTurnAgent } from "#runtime/agent/bootstrap.js";
/**
* Creates the durable compaction configuration used by one harness session.
*/
export declare function createCompactionConfig(input?: {
readonly contextWindowTokens?: number;
readonly lastKnownInputTokens?: number;
readonly lastKnownPromptMessageCount?: number;
readonly thresholdPercent?: number;
}): {
recentWindowSize: number;
threshold: number;
} | {
recentWindowSize: number;
threshold: number;
lastKnownInputTokens: number;
lastKnownPromptMessageCount: number | undefined;
};
export interface CreateSessionInput {
readonly continuationToken: string;
readonly compactionOverrides?: {
readonly thresholdPercent?: number;
};
/**
* Optional root session id passed in by the runtime when this
* session is a delegated subagent child. `undefined` for top-level
* sessions — `sessionId` is the root for those.
*/
readonly rootSessionId?: string;
readonly sessionId: string;
readonly turnAgent: RuntimeTurnAgent;
readonly outputSchema?: HarnessSession["outputSchema"];
}
/**
* Creates a fresh {@link HarnessSession}. The only site that derives
* `session.agent.system` from a `turnAgent` — every subsequent turn
* preserves the prompt via {@link refreshSessionFromTurnAgent}.
*/
export declare function createSession(input: CreateSessionInput): HarnessSession;
/**
* Refreshes a session with the latest `turnAgent` — replaces model/tool
* metadata and recalculates compaction thresholds; preserves history and
* state. Production callers keep the session-start `agent.system` prompt,
* while dev HMR callers can opt into refreshing it from authored source.
*/
export declare function refreshSessionFromTurnAgent(input: {
readonly session: HarnessSession;
readonly turnAgent: RuntimeTurnAgent;
readonly refreshSystemPrompt?: boolean;
readonly compactionOverrides?: {
readonly thresholdPercent?: number;
};
}): HarnessSession;
/**
* Mints a continuation token for a delegated subagent session.
* Deterministic when `suffix` is provided so retries address the same
* child hook.
*/
export declare function mintSubagentContinuationToken(suffix?: string): string;
/**
* Projects a {@link HarnessSession} to {@link DurableSession}.
*
* Drops fields rebuilt every turn from `bundle.turnAgent`; keeps
* `agent.system` and `compaction.lastKnown*` so compaction stays
* informed after rehydration.
*/
export declare function projectToDurableSession(session: HarnessSession): DurableSession;
/**
* Rehydrates a {@link HarnessSession} from a {@link DurableSession}
* plus the current `turnAgent`, rebuilding the runtime-only agent and
* compaction fields the durable shape omits.
*/
export declare function hydrateDurableSession(input: {
readonly durable: DurableSession;
readonly turnAgent: RuntimeTurnAgent;
readonly compactionOverrides?: {
readonly thresholdPercent?: number;
};
}): HarnessSession;