@saturn-universe/runtime 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ import type { ExecutionEnvironment, RunConfig, LoggerPort, AgentInput, AgentResult, ExecutionEnvironmentReader, RuntimeStateReader, RuntimeJournal, RuntimeClock, ContextComposer, ModelGateway, ToolExecutor, ToolRegistry, SurfaceReader, ModelStreamEvent, RequestId, Hash, RuntimeHooks, LiveAgentTelemetry, HostCommand, CommandId, RunId, AgentSessionId } from '@saturn-universe/core';
2
+ import { type AutoCompactionOptions } from './compaction.js';
3
+ type LiveAgentState = Omit<LiveAgentTelemetry, 'memberId' | 'agentSessionId' | 'reasoningSummary'>;
4
+ export type LiveAgentUpdate = {
5
+ [K in keyof LiveAgentState]?: LiveAgentState[K] | undefined;
6
+ } & {
7
+ readonly reasoningDelta?: string;
8
+ readonly resetReasoning?: boolean;
9
+ };
10
+ export interface AgentLoopDependencies {
11
+ logger: LoggerPort;
12
+ environment: ExecutionEnvironmentReader;
13
+ state: RuntimeStateReader;
14
+ surface: SurfaceReader;
15
+ journal: RuntimeJournal;
16
+ clock: RuntimeClock;
17
+ composer: ContextComposer;
18
+ gateway: ModelGateway;
19
+ hooks?: (config: RunConfig, environment: ExecutionEnvironment) => RuntimeHooks;
20
+ executor: ToolExecutor;
21
+ registry: ToolRegistry;
22
+ hash: Hash;
23
+ id(): string;
24
+ random?: () => number;
25
+ checkpointOnContextPressure?: boolean;
26
+ autoCompaction?: boolean | AutoCompactionOptions;
27
+ liveText?: {
28
+ append(input: AgentInput, delta: Extract<ModelStreamEvent, {
29
+ type: 'text_delta';
30
+ }>): void;
31
+ clear(requestId: RequestId): void;
32
+ };
33
+ liveAgents?: {
34
+ update(input: AgentInput, patch: LiveAgentUpdate): void;
35
+ clearAgent(input: AgentInput): void;
36
+ };
37
+ }
38
+ export declare function modelRetryDelayMs(retry: RunConfig['retry'], attempt: number, retryAfterMs: number | undefined, random?: () => number): number;
39
+ type SteeringCommand = Extract<HostCommand, {
40
+ type: 'run.steer';
41
+ }>;
42
+ export declare function createAgentLoop(d: AgentLoopDependencies): {
43
+ execute: (input: AgentInput, signal: AbortSignal) => Promise<AgentResult>;
44
+ resume: (input: AgentInput, signal: AbortSignal) => Promise<AgentResult>;
45
+ steer(agentSessionId: AgentSessionId, commandId: CommandId, command: SteeringCommand): Promise<void>;
46
+ clearSteering(runId: RunId): void;
47
+ };
48
+ export {};