@modelprofile.com/flexharness-agent 6.0.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.
Files changed (43) hide show
  1. package/dist_ts_agent/index.d.ts +17 -0
  2. package/dist_ts_agent/index.js +14 -0
  3. package/dist_ts_agent/plugins.d.ts +16 -0
  4. package/dist_ts_agent/plugins.js +18 -0
  5. package/dist_ts_agent/smartagent.classes.agent.d.ts +2 -0
  6. package/dist_ts_agent/smartagent.classes.agent.js +95 -0
  7. package/dist_ts_agent/smartagent.classes.session.d.ts +90 -0
  8. package/dist_ts_agent/smartagent.classes.session.js +2139 -0
  9. package/dist_ts_agent/smartagent.classes.toolregistry.d.ts +12 -0
  10. package/dist_ts_agent/smartagent.classes.toolregistry.js +23 -0
  11. package/dist_ts_agent/smartagent.context.d.ts +3 -0
  12. package/dist_ts_agent/smartagent.context.js +247 -0
  13. package/dist_ts_agent/smartagent.events.d.ts +160 -0
  14. package/dist_ts_agent/smartagent.events.js +136 -0
  15. package/dist_ts_agent/smartagent.interfaces.d.ts +275 -0
  16. package/dist_ts_agent/smartagent.interfaces.js +24 -0
  17. package/dist_ts_agent/smartagent.persistence.d.ts +88 -0
  18. package/dist_ts_agent/smartagent.persistence.js +677 -0
  19. package/dist_ts_agent/smartagent.transactions.d.ts +15 -0
  20. package/dist_ts_agent/smartagent.transactions.js +141 -0
  21. package/dist_ts_agent/tool.adapter.d.ts +29 -0
  22. package/dist_ts_agent/tool.adapter.js +60 -0
  23. package/dist_ts_agent/tool.contracts.d.ts +126 -0
  24. package/dist_ts_agent/tool.contracts.js +2 -0
  25. package/dist_ts_agent/tool.persistence.d.ts +23 -0
  26. package/dist_ts_agent/tool.persistence.js +35 -0
  27. package/license.md +21 -0
  28. package/package.json +31 -0
  29. package/readme.md +37 -0
  30. package/ts_agent/index.ts +119 -0
  31. package/ts_agent/plugins.ts +62 -0
  32. package/ts_agent/readme.md +37 -0
  33. package/ts_agent/smartagent.classes.agent.ts +104 -0
  34. package/ts_agent/smartagent.classes.session.ts +2588 -0
  35. package/ts_agent/smartagent.classes.toolregistry.ts +26 -0
  36. package/ts_agent/smartagent.context.ts +280 -0
  37. package/ts_agent/smartagent.events.ts +347 -0
  38. package/ts_agent/smartagent.interfaces.ts +365 -0
  39. package/ts_agent/smartagent.persistence.ts +827 -0
  40. package/ts_agent/smartagent.transactions.ts +193 -0
  41. package/ts_agent/tool.adapter.ts +85 -0
  42. package/ts_agent/tool.contracts.ts +149 -0
  43. package/ts_agent/tool.persistence.ts +64 -0
@@ -0,0 +1,275 @@
1
+ import type { ISmartAiCacheOptions, ToolSet, ModelMessage, TSmartAiLanguageModel, ProviderOptions, IToolExecutionContext, IToolJobState, TSmartAiCacheRetention, TSmartAiCacheSetting } from './plugins.js';
2
+ import type { IAgentRuntimeEventPayload, IToolExecutionIntentEvent, TAgentEvent, TAgentGenerationOutcome, TAgentToolResultOutput } from './smartagent.events.js';
3
+ import type { TAgentEventArchive, TAgentEventStore } from './smartagent.persistence.js';
4
+ export type { ProviderOptions };
5
+ export interface IAgentCacheOptions extends ISmartAiCacheOptions {
6
+ }
7
+ export type TAgentCacheRetention = TSmartAiCacheRetention;
8
+ export type TAgentCacheSetting = TSmartAiCacheSetting;
9
+ export type TAgentPrompt = Extract<ModelMessage, {
10
+ role: 'user';
11
+ }>['content'];
12
+ export interface IAgentToolCallRecord {
13
+ toolCallId: string;
14
+ toolName: string;
15
+ input: unknown;
16
+ output?: unknown;
17
+ error?: string;
18
+ }
19
+ export interface IAgentToolCallStartEvent {
20
+ toolCallId: string;
21
+ toolName: string;
22
+ input: unknown;
23
+ }
24
+ export interface IAgentToolCallUpdateEvent extends IAgentToolCallStartEvent {
25
+ /** Transient streamed output. The authoritative final output is delivered through onToolCallFinish. */
26
+ output: unknown;
27
+ }
28
+ export type TAgentToolCallFinishEvent = (IAgentToolCallStartEvent & {
29
+ success: true;
30
+ output: unknown;
31
+ }) | (IAgentToolCallStartEvent & {
32
+ success: false;
33
+ error: string;
34
+ });
35
+ export interface IAgentContextOverflowInvocationOptions {
36
+ abortSignal?: AbortSignal;
37
+ }
38
+ export interface IAgentContextBuildOptions {
39
+ events: readonly TAgentEvent[];
40
+ }
41
+ export type TAgentContextBuilder = (options: IAgentContextBuildOptions) => ModelMessage[];
42
+ export interface IAgentContextCompactionOptions {
43
+ abortSignal?: AbortSignal;
44
+ reason: 'context-overflow' | 'retention' | 'manual';
45
+ }
46
+ export type TAgentContextCompactor = (messages: ModelMessage[], events: readonly TAgentEvent[], options: IAgentContextCompactionOptions) => Promise<ModelMessage[]>;
47
+ export interface IAgentEventRetentionOptions {
48
+ /** Compact and archive once the active event count exceeds this value. */
49
+ maxEvents: number;
50
+ }
51
+ export interface IAgentSessionChange {
52
+ type: 'committed' | 'updated' | 'archived';
53
+ events: readonly TAgentEvent[];
54
+ }
55
+ export type TAgentSessionChangeListener = (change: IAgentSessionChange) => void | Promise<void>;
56
+ export interface IAgentSessionOptions {
57
+ /** Default SmartAI language model. May be omitted when every generation supplies a model. */
58
+ model?: TSmartAiLanguageModel;
59
+ /** System prompt override */
60
+ system?: string;
61
+ /** Tools available to the agent */
62
+ tools?: ToolSet;
63
+ /** Provider-specific AI SDK request options passed through to streamText() */
64
+ providerOptions?: ProviderOptions;
65
+ /** Stable session id used as provider prompt-cache affinity key where supported. */
66
+ sessionId?: string;
67
+ /** Optional event store. Transactional persistence requires IAgentEventStoreV2. */
68
+ eventStore?: TAgentEventStore;
69
+ /** Prompt-cache policy. Default: 'auto'. Set false to disable smartagent cache defaults. */
70
+ cache?: TAgentCacheSetting;
71
+ /**
72
+ * Maximum number of LLM↔tool round trips.
73
+ * Each step may execute multiple tools in parallel.
74
+ * Default: 20
75
+ */
76
+ maxSteps?: number;
77
+ /** Initial canonical events. */
78
+ events?: readonly TAgentEvent[];
79
+ /** Initial AI SDK messages, converted to canonical events at the session boundary. */
80
+ messages?: ModelMessage[];
81
+ /** Optional host execution context, including background jobs. */
82
+ executionContext?: IToolExecutionContext;
83
+ /** Projects canonical events into model messages. Default: buildModelMessages(). */
84
+ contextBuilder?: TAgentContextBuilder;
85
+ /** Explicit context compactor used by manual and event-retention compaction. */
86
+ contextCompactor?: TAgentContextCompactor;
87
+ /** Optional bounded active-event policy. Requires contextCompactor and eventStore.archive. */
88
+ eventRetention?: IAgentEventRetentionOptions;
89
+ /** Maximum wait for each session change listener. Default: 30 seconds. */
90
+ changeListenerTimeoutMs?: number;
91
+ /** Maximum queued changes per listener before that listener is removed. Default: 1000. */
92
+ maxPendingSessionChanges?: number;
93
+ /** Maximum wait for each generation lease cleanup attempt. Default: 30 seconds. */
94
+ generationLeaseCleanupTimeoutMs?: number;
95
+ /** Recent archived transaction identities retained for idempotency/reuse checks. Default: 1000. */
96
+ maxArchivedTransactionTombstones?: number;
97
+ /** Projects persisted transactional interruption reasons. Defaults to the thrown error string. */
98
+ transactionOutcomeErrorProjector?: (error: unknown) => string;
99
+ /** Called for each streamed text delta */
100
+ onToken?: (delta: string) => void;
101
+ /** Called when the model starts a streamed reasoning summary */
102
+ onReasoningStart?: (id: string, providerMetadata?: unknown) => void;
103
+ /** Called for each streamed reasoning summary delta */
104
+ onReasoningDelta?: (id: string, delta: string, providerMetadata?: unknown) => void;
105
+ /** Called when a streamed reasoning summary completes */
106
+ onReasoningEnd?: (id: string, text: string, providerMetadata?: unknown) => void;
107
+ /** Called when a tool call starts, with its stable AI SDK call id. */
108
+ onToolCallStart?: (event: IAgentToolCallStartEvent) => void;
109
+ /**
110
+ * Called immediately for each distinct streamed tool output. Updates are transient and are not
111
+ * persisted; the last update may equal the authoritative output later sent to onToolCallFinish.
112
+ */
113
+ onToolCallUpdate?: (event: IAgentToolCallUpdateEvent) => void;
114
+ /** Called when a tool call finishes, with its stable AI SDK call id and success state. */
115
+ onToolCallFinish?: (event: TAgentToolCallFinishEvent) => void;
116
+ /** @deprecated Use onToolCallStart instead. */
117
+ onToolCall?: (toolName: string, input: unknown) => void;
118
+ /** @deprecated Use onToolCallFinish instead. */
119
+ onToolResult?: (toolName: string, result: unknown) => void;
120
+ /**
121
+ * Called when total token usage approaches the model's context limit.
122
+ * Receives the full message history and must return a compacted replacement.
123
+ * If not provided, generation throws a ContextOverflowError instead.
124
+ */
125
+ onContextOverflow?: (messages: ModelMessage[], invocationOptions: IAgentContextOverflowInvocationOptions) => Promise<ModelMessage[]>;
126
+ /** Maximum context-overflow compaction retries before throwing. Default: 3. */
127
+ maxContextOverflowRetries?: number;
128
+ }
129
+ export interface IAgentRunOptions extends IAgentSessionOptions {
130
+ /** The language model to use, for example from ModelRegistry.getModel(). */
131
+ model: TSmartAiLanguageModel;
132
+ /** Initial user message or task description */
133
+ prompt: TAgentPrompt;
134
+ /**
135
+ * Validate the completed run. Return a string to reject the run and reprompt,
136
+ * or return void to accept the result.
137
+ */
138
+ validateCompletion?: (result: IAgentRunResult) => Promise<string | void> | string | void;
139
+ /** Number of validation-triggered reprompts allowed. Default: 0 */
140
+ maxValidationRetries?: number;
141
+ /** AbortSignal to cancel this run. Background jobs have independent cancellation. */
142
+ abort?: AbortSignal;
143
+ }
144
+ export interface IAgentGenerationHandle {
145
+ readonly generationId: string;
146
+ readonly claimToken: string;
147
+ }
148
+ export interface IAgentBeginGenerationOptions {
149
+ /** Stable caller-owned identity used to make begin retries deterministic. */
150
+ generationId?: string;
151
+ }
152
+ export interface IAgentGenerationPreparationContext {
153
+ generationId: string;
154
+ abortSignal: AbortSignal;
155
+ }
156
+ export interface IAgentGenerationLease {
157
+ model?: TSmartAiLanguageModel;
158
+ system?: string;
159
+ tools?: ToolSet;
160
+ providerOptions?: ProviderOptions;
161
+ cache?: TAgentCacheSetting;
162
+ maxSteps?: number;
163
+ /**
164
+ * Must be safe to call repeatedly and concurrently after failure or timeout.
165
+ * A timeout does not cancel the original close attempt, so a retry may overlap it.
166
+ */
167
+ close?(): Promise<void>;
168
+ }
169
+ export declare class AgentGenerationLeaseCleanupError extends Error {
170
+ readonly lease: IAgentGenerationLease;
171
+ readonly cleanupCause: unknown;
172
+ private readonly retryCleanupFunction;
173
+ constructor(lease: IAgentGenerationLease, cleanupCause: unknown, retryCleanupFunction: () => Promise<void>);
174
+ retryCleanup(): Promise<void>;
175
+ }
176
+ export type TAgentGenerationPrepare = (context: IAgentGenerationPreparationContext) => Promise<IAgentGenerationLease> | IAgentGenerationLease;
177
+ export interface IAgentGenerateOptions {
178
+ /** Per-generation model override. A prepared lease takes precedence. */
179
+ model?: TSmartAiLanguageModel;
180
+ /** Per-generation system prompt override. A prepared lease takes precedence. */
181
+ system?: string;
182
+ /** Per-generation tool override. A prepared lease takes precedence. */
183
+ tools?: ToolSet;
184
+ /** Per-generation provider options override. A prepared lease takes precedence. */
185
+ providerOptions?: ProviderOptions;
186
+ /** Per-generation prompt-cache override. A prepared lease takes precedence. */
187
+ cache?: TAgentCacheSetting;
188
+ /** Maximum completed model steps for this generation. */
189
+ maxSteps?: number;
190
+ /** Cancels only this generation and its synchronous tool executions. */
191
+ abort?: AbortSignal;
192
+ /** Opt-in transactional claim returned by beginGeneration(). */
193
+ transaction?: IAgentGenerationHandle;
194
+ /**
195
+ * Optionally acquires generation-scoped resources in transactional or legacy mode.
196
+ * Called at most once, only if execution reaches preparation. Persisted transactions
197
+ * have durable V2 execution authority first; legacy/process-local calls do not.
198
+ * The callback owns cleanup of partial acquisition if it throws before returning a lease.
199
+ */
200
+ prepare?: TAgentGenerationPrepare;
201
+ }
202
+ export interface IAgentScheduleGenerateOptions extends IAgentGenerateOptions {
203
+ /** Coalescing identity for this scheduled generation. */
204
+ key: string;
205
+ /** Quiet period before the generation is queued. Reset by same-key calls. Default: 50ms. */
206
+ debounceMs?: number;
207
+ }
208
+ export interface IAgentCompactOptions {
209
+ abort?: AbortSignal;
210
+ reason?: 'retention' | 'manual';
211
+ }
212
+ export type TAgentToolExecutionReconciliationOptions = {
213
+ resolution: 'executed';
214
+ output: unknown;
215
+ modelOutput: TAgentToolResultOutput;
216
+ } | {
217
+ resolution: 'not-executed' | 'abandoned-unknown';
218
+ error?: string;
219
+ };
220
+ export interface IAgentRunResult {
221
+ /** Final text output from the model */
222
+ text: string;
223
+ /** Active model-message projection after any configured projection or compaction. */
224
+ messages: ModelMessage[];
225
+ /** Total steps taken */
226
+ steps: number;
227
+ /** Finish reason from the final step */
228
+ finishReason: string;
229
+ /** Accumulated token usage across all steps */
230
+ usage: {
231
+ inputTokens: number;
232
+ outputTokens: number;
233
+ totalTokens: number;
234
+ cacheReadTokens: number;
235
+ cacheWriteTokens: number;
236
+ };
237
+ /** Tool calls observed during the run, including inputs and outputs/errors when available */
238
+ toolCalls: IAgentToolCallRecord[];
239
+ }
240
+ export interface IAgentGenerateResult extends IAgentRunResult {
241
+ /** Raw canonical events remain available independently from model messages. */
242
+ events: readonly TAgentEvent[];
243
+ }
244
+ export interface IAgentSessionAbortOptions {
245
+ /** Also abort all currently running jobs owned by executionContext.jobs. Default: false. */
246
+ abortBackgroundJobs?: boolean;
247
+ }
248
+ export interface IAgentSession {
249
+ /** True once close() has released all retryable runtime cleanup ownership. */
250
+ readonly closeCleanupCompleted: boolean;
251
+ pushEvent(event: TAgentEvent): Promise<void>;
252
+ pushUserMessage(content: TAgentPrompt): Promise<void>;
253
+ pushRuntimeEvent(event: IAgentRuntimeEventPayload): Promise<void>;
254
+ beginGeneration(content: TAgentPrompt, options?: IAgentBeginGenerationOptions): Promise<IAgentGenerationHandle>;
255
+ generate(options?: IAgentGenerateOptions): Promise<IAgentGenerateResult>;
256
+ finalizeGeneration(transaction: IAgentGenerationHandle, outcome: TAgentGenerationOutcome): Promise<void>;
257
+ listUncertainToolExecutions(): IToolExecutionIntentEvent[];
258
+ reconcileToolExecution(intentId: string, reconciliation: TAgentToolExecutionReconciliationOptions): Promise<void>;
259
+ scheduleGenerate(options: IAgentScheduleGenerateOptions): Promise<IAgentGenerateResult>;
260
+ cancelScheduledGeneration(key: string, reason?: unknown): boolean;
261
+ compact(options?: IAgentCompactOptions): Promise<void>;
262
+ archiveCompactedEvents(compactionEventId?: string): Promise<TAgentEventArchive | undefined>;
263
+ subscribe(listener: TAgentSessionChangeListener): () => void;
264
+ getEvents(): readonly TAgentEvent[];
265
+ getModelMessages(): ModelMessage[];
266
+ getBackgroundExecution(executionId: string): Promise<IToolJobState>;
267
+ abortBackgroundExecution(executionId: string): Promise<void>;
268
+ abortCurrentGeneration(reason?: unknown): void;
269
+ abortSession(reason?: unknown, options?: IAgentSessionAbortOptions): Promise<void>;
270
+ /** Rejects when called from an active prepare, lease cleanup, tool, or compactor callback. */
271
+ close(): Promise<void>;
272
+ }
273
+ export declare class ContextOverflowError extends Error {
274
+ constructor(message?: string);
275
+ }
@@ -0,0 +1,24 @@
1
+ export class AgentGenerationLeaseCleanupError extends Error {
2
+ lease;
3
+ cleanupCause;
4
+ retryCleanupFunction;
5
+ constructor(lease, cleanupCause, retryCleanupFunction) {
6
+ super(`Generation lease cleanup failed: ${cleanupCause instanceof Error
7
+ ? cleanupCause.message
8
+ : String(cleanupCause)}`);
9
+ this.name = 'AgentGenerationLeaseCleanupError';
10
+ this.lease = lease;
11
+ this.cleanupCause = cleanupCause;
12
+ this.retryCleanupFunction = retryCleanupFunction;
13
+ }
14
+ retryCleanup() {
15
+ return this.retryCleanupFunction();
16
+ }
17
+ }
18
+ export class ContextOverflowError extends Error {
19
+ constructor(message = 'Agent context limit reached and no onContextOverflow handler provided') {
20
+ super(message);
21
+ this.name = 'ContextOverflowError';
22
+ }
23
+ }
24
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhZ2VudC5pbnRlcmZhY2VzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHNfYWdlbnQvc21hcnRhZ2VudC5pbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXNOQSxNQUFNLE9BQU8sZ0NBQWlDLFNBQVEsS0FBSztJQUN6QyxLQUFLLENBQXdCO0lBQzdCLFlBQVksQ0FBVTtJQUNyQixvQkFBb0IsQ0FBc0I7SUFFM0QsWUFDRSxLQUE0QixFQUM1QixZQUFxQixFQUNyQixvQkFBeUM7UUFFekMsS0FBSyxDQUNILG9DQUFvQyxZQUFZLFlBQVksS0FBSztZQUMvRCxDQUFDLENBQUMsWUFBWSxDQUFDLE9BQU87WUFDdEIsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxZQUFZLENBQUMsRUFBRSxDQUMzQixDQUFDO1FBQ0YsSUFBSSxDQUFDLElBQUksR0FBRyxrQ0FBa0MsQ0FBQztRQUMvQyxJQUFJLENBQUMsS0FBSyxHQUFHLEtBQUssQ0FBQztRQUNuQixJQUFJLENBQUMsWUFBWSxHQUFHLFlBQVksQ0FBQztRQUNqQyxJQUFJLENBQUMsb0JBQW9CLEdBQUcsb0JBQW9CLENBQUM7SUFDbkQsQ0FBQztJQUVNLFlBQVk7UUFDakIsT0FBTyxJQUFJLENBQUMsb0JBQW9CLEVBQUUsQ0FBQztJQUNyQyxDQUFDO0NBQ0Y7QUF5SEQsTUFBTSxPQUFPLG9CQUFxQixTQUFRLEtBQUs7SUFDN0MsWUFBWSxPQUFPLEdBQUcsdUVBQXVFO1FBQzNGLEtBQUssQ0FBQyxPQUFPLENBQUMsQ0FBQztRQUNmLElBQUksQ0FBQyxJQUFJLEdBQUcsc0JBQXNCLENBQUM7SUFDckMsQ0FBQztDQUNGIn0=
@@ -0,0 +1,88 @@
1
+ import type { TAgentEvent } from './smartagent.events.js';
2
+ interface IAgentEventSnapshotBase {
3
+ sessionId: string;
4
+ revision: number;
5
+ updatedAt: number;
6
+ events: TAgentEvent[];
7
+ }
8
+ /** Legacy schema-1 snapshot contract used by IAgentEventStore. */
9
+ export interface IAgentEventSnapshot extends IAgentEventSnapshotBase {
10
+ schemaVersion: 1;
11
+ }
12
+ export interface IAgentEventSnapshotV2 extends IAgentEventSnapshotBase {
13
+ schemaVersion: 2;
14
+ }
15
+ export type TAgentEventSnapshot = IAgentEventSnapshot | IAgentEventSnapshotV2;
16
+ interface IAgentEventArchiveBase {
17
+ sessionId: string;
18
+ archiveId: string;
19
+ createdAt: number;
20
+ events: TAgentEvent[];
21
+ }
22
+ /** Legacy schema-1 archive contract used by IAgentEventStore. */
23
+ export interface IAgentEventArchive extends IAgentEventArchiveBase {
24
+ schemaVersion: 1;
25
+ }
26
+ export interface IAgentEventArchiveV2 extends IAgentEventArchiveBase {
27
+ schemaVersion: 2;
28
+ }
29
+ export type TAgentEventArchive = IAgentEventArchive | IAgentEventArchiveV2;
30
+ /** Legacy custom-store contract. It must read and write schema 1 only. */
31
+ export interface IAgentEventStore {
32
+ load(sessionId: string): Promise<IAgentEventSnapshot | undefined>;
33
+ save(sessionId: string, events: readonly TAgentEvent[], expectedRevision: number): Promise<number>;
34
+ archive?(archive: IAgentEventArchive): Promise<void>;
35
+ loadArchive?(sessionId: string, archiveId: string): Promise<IAgentEventArchive | undefined>;
36
+ }
37
+ /** Schema-2 capability required for persisted transactional generations. */
38
+ export interface IAgentEventStoreV2 {
39
+ readonly eventSchemaVersion: 2;
40
+ load(sessionId: string): Promise<TAgentEventSnapshot | undefined>;
41
+ save(sessionId: string, events: readonly TAgentEvent[], expectedRevision: number): Promise<number>;
42
+ archive?(archive: IAgentEventArchiveV2): Promise<void>;
43
+ loadArchive?(sessionId: string, archiveId: string): Promise<TAgentEventArchive | undefined>;
44
+ }
45
+ export type TAgentEventStore = IAgentEventStore | IAgentEventStoreV2;
46
+ export declare const isAgentEventStoreV2: (store: TAgentEventStore | undefined) => store is IAgentEventStoreV2;
47
+ /** Validates and returns a canonical schema-2 Agent event snapshot. */
48
+ export declare const validateAgentEventSnapshotV2: (value: unknown, expectedSessionId?: string) => IAgentEventSnapshotV2;
49
+ /** Validates and returns a canonical schema-2 Agent event archive. */
50
+ export declare const validateAgentEventArchiveV2: (value: unknown, expectedSessionId?: string, expectedArchiveId?: string) => IAgentEventArchiveV2;
51
+ export declare class AgentEventStoreConflictError extends Error {
52
+ readonly sessionId: string;
53
+ readonly expectedRevision: number;
54
+ readonly actualRevision: number;
55
+ constructor(sessionId: string, expectedRevision: number, actualRevision: number);
56
+ }
57
+ export declare class InMemoryAgentEventStore implements IAgentEventStoreV2 {
58
+ readonly eventSchemaVersion: 2;
59
+ private readonly snapshots;
60
+ private readonly archives;
61
+ load(sessionId: string): Promise<TAgentEventSnapshot | undefined>;
62
+ save(sessionId: string, events: readonly TAgentEvent[], expectedRevision: number): Promise<number>;
63
+ archive(archive: IAgentEventArchiveV2): Promise<void>;
64
+ loadArchive(sessionId: string, archiveId: string): Promise<TAgentEventArchive | undefined>;
65
+ }
66
+ export interface IFileAgentEventStoreOptions {
67
+ rootDir: string;
68
+ /** Maximum time spent waiting for another writer. Default: 10 seconds. */
69
+ lockTimeoutMs?: number;
70
+ }
71
+ export declare class FileAgentEventStore implements IAgentEventStoreV2 {
72
+ readonly eventSchemaVersion: 2;
73
+ private readonly rootDir;
74
+ private readonly lockTimeoutMs;
75
+ constructor(options: IFileAgentEventStoreOptions);
76
+ private sessionKey;
77
+ private snapshotPath;
78
+ private archivePath;
79
+ private readValue;
80
+ private syncDirectory;
81
+ private writeAtomic;
82
+ private withSessionLock;
83
+ load(sessionId: string): Promise<TAgentEventSnapshot | undefined>;
84
+ save(sessionId: string, events: readonly TAgentEvent[], expectedRevision: number): Promise<number>;
85
+ archive(archive: IAgentEventArchiveV2): Promise<void>;
86
+ loadArchive(sessionId: string, archiveId: string): Promise<TAgentEventArchive | undefined>;
87
+ }
88
+ export {};