@rowan-agent/agent 0.15.4 → 0.15.5

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.
package/dist/index.d.ts CHANGED
@@ -2268,10 +2268,51 @@ declare class AgentRuntime implements AgentRuntime$1 {
2268
2268
  private startHeartbeat;
2269
2269
  }
2270
2270
 
2271
+ type Mutable<T> = {
2272
+ -readonly [Key in keyof T]: T[Key];
2273
+ };
2274
+ type StoredAgent = Mutable<AgentRecord>;
2275
+ type StoredRun = Mutable<RunRecord>;
2276
+ type StoredToolCall = {
2277
+ id: ToolCallId;
2278
+ providerToolCallId: string;
2279
+ agentId: AgentId;
2280
+ runId: RunId;
2281
+ executionId: ExecutionId;
2282
+ requestMessageId: MessageId;
2283
+ name: string;
2284
+ args: JsonValue;
2285
+ state: ToolCallState;
2286
+ result?: DurableToolResult;
2287
+ resultMessageId?: MessageId;
2288
+ reason?: string;
2289
+ createdAt: string;
2290
+ updatedAt: string;
2291
+ };
2271
2292
  type IdempotencyReceipt = {
2272
2293
  payload: string;
2273
2294
  result: unknown;
2274
2295
  };
2296
+ type StoreMutationRecorder = {
2297
+ onAgentUpsert(agent: StoredAgent): void;
2298
+ onAgentDelete(agentId: AgentId): void;
2299
+ onRunUpsert(run: StoredRun): void;
2300
+ onRunDelete(runId: RunId): void;
2301
+ onMessageInsert(message: Message): void;
2302
+ onMessageDelete(messageId: MessageId): void;
2303
+ onToolCallUpsert(toolCall: StoredToolCall): void;
2304
+ onToolCallDelete(toolCallId: ToolCallId): void;
2305
+ onEventAppend(event: DurableRunEvent): void;
2306
+ onEventsTruncate(deletedEventIds: string[]): void;
2307
+ onIdempotencyUpsert(scope: string, receipt: IdempotencyReceipt): void;
2308
+ onIdempotencyDelete(scope: string): void;
2309
+ onOperationReceiptUpsert(key: string, receipt: IdempotencyReceipt): void;
2310
+ onOperationReceiptDelete(key: string): void;
2311
+ onConsumerCheckpointUpsert(consumerId: string, cursor: EventCursor): void;
2312
+ onConsumerCheckpointDelete(consumerId: string): void;
2313
+ onContextCompactionUpsert(agentId: AgentId, record: ContextCompactionRecord): void;
2314
+ onRetentionFloorChange(floor: number): void;
2315
+ };
2275
2316
  type InMemoryStoreState = Readonly<{
2276
2317
  incarnation: string;
2277
2318
  agents: readonly AgentRecord[];
@@ -2282,7 +2323,7 @@ type InMemoryStoreState = Readonly<{
2282
2323
  idempotency: readonly (readonly [string, IdempotencyReceipt])[];
2283
2324
  operationReceipts: readonly (readonly [string, IdempotencyReceipt])[];
2284
2325
  historySeeds?: readonly (readonly [AgentId, readonly Message[]])[];
2285
- consumerCheckpoints: readonly (readonly [string, EventCursor])[];
2326
+ consumerCheckpoints?: readonly (readonly [string, EventCursor])[];
2286
2327
  retentionFloor?: number;
2287
2328
  nextAgentSequence: readonly (readonly [AgentId, number])[];
2288
2329
  nextReadySequence: readonly (readonly [AgentId, number])[];
@@ -2307,11 +2348,23 @@ declare class InMemoryStore implements DurableStore {
2307
2348
  private eventSequence;
2308
2349
  private retentionFloor;
2309
2350
  private readonly contextCompactions;
2351
+ private recorder?;
2352
+ private readonly runReceiptKeys;
2310
2353
  constructor(options?: {
2311
2354
  incarnation?: string;
2312
2355
  });
2356
+ setChangeRecorder(recorder?: StoreMutationRecorder): void;
2357
+ private touchAgent;
2358
+ private touchRun;
2359
+ private storeMessage;
2360
+ private storeToolCall;
2361
+ private appendEvent;
2362
+ inferRunIdForReceipt(key: string, payload: string): RunId | undefined;
2363
+ dropRunOperationReceipts(runId: RunId): void;
2364
+ compactTerminalReceipts(): number;
2313
2365
  static fromState(state: InMemoryStoreState): InMemoryStore;
2314
2366
  exportState(): InMemoryStoreState;
2367
+ exportMetadata(): Record<string, unknown>;
2315
2368
  attachOwner(lease: OwnerLease): void;
2316
2369
  interruptOwner(ownerEpoch: number, message?: string): void;
2317
2370
  openOwner(input: {
@@ -2521,12 +2574,32 @@ declare class SqliteStore implements DurableStore {
2521
2574
  private mirroredAgents;
2522
2575
  private closed;
2523
2576
  private configured;
2577
+ private cachedMemory?;
2578
+ private cachedOwner?;
2579
+ private isLegacyState;
2580
+ private stmtUpsertAgent?;
2581
+ private stmtDeleteAgent?;
2582
+ private stmtUpsertRun?;
2583
+ private stmtDeleteRun?;
2584
+ private stmtInsertMessage?;
2585
+ private stmtDeleteMessage?;
2586
+ private stmtUpsertToolCall?;
2587
+ private stmtDeleteToolCall?;
2588
+ private stmtInsertEvent?;
2589
+ private stmtDeleteEvent?;
2590
+ private stmtUpsertIdempotency?;
2591
+ private stmtDeleteIdempotency?;
2592
+ private stmtUpsertCheckpoint?;
2593
+ private stmtDeleteCheckpoint?;
2594
+ private stmtUpdateMeta?;
2595
+ private stmtUpdateState?;
2524
2596
  constructor(filename?: string);
2525
2597
  openOwner(input: {
2526
2598
  ownerId: string;
2527
2599
  leaseMs: number;
2528
2600
  }): Promise<OwnedStore>;
2529
2601
  close(): void;
2602
+ exportState(): InMemoryStoreState;
2530
2603
  /** Filesystem location owned by this Store for one Agent's readable archive. */
2531
2604
  contextArchiveDir(agentId: AgentId): string;
2532
2605
  reserveAgent(lease: OwnerLease, input: {
@@ -2687,6 +2760,8 @@ declare class SqliteStore implements DurableStore {
2687
2760
  }): Promise<RetentionResult>;
2688
2761
  renewOwner(lease: OwnerLease, leaseMs: number): Promise<OwnerLease>;
2689
2762
  sealAndReleaseOwner(lease: OwnerLease): Promise<void>;
2763
+ private read;
2764
+ private write;
2690
2765
  private invoke;
2691
2766
  private ensureSchema;
2692
2767
  private isCurrentSchema;
@@ -2695,10 +2770,29 @@ declare class SqliteStore implements DurableStore {
2695
2770
  private readOwner;
2696
2771
  private writeOwner;
2697
2772
  private readState;
2698
- private writeState;
2699
- private persistState;
2773
+ private loadTableBackedState;
2774
+ private ensureTableBackedStorage;
2775
+ private getStmtUpsertAgent;
2776
+ private getStmtDeleteAgent;
2777
+ private getStmtUpsertRun;
2778
+ private getStmtDeleteRun;
2779
+ private getStmtInsertMessage;
2780
+ private getStmtDeleteMessage;
2781
+ private getStmtUpsertToolCall;
2782
+ private getStmtDeleteToolCall;
2783
+ private getStmtInsertEvent;
2784
+ private getStmtDeleteEvent;
2785
+ private getStmtUpsertIdempotency;
2786
+ private getStmtDeleteIdempotency;
2787
+ private getStmtUpsertCheckpoint;
2788
+ private getStmtDeleteCheckpoint;
2789
+ private getStmtUpdateMeta;
2790
+ private getStmtUpdateState;
2791
+ private persistChanges;
2792
+ private writeFullStateToTables;
2793
+ private mirrorChanges;
2700
2794
  /** Append the semantic durable event mirror and remove deleted Agent sidecars. */
2701
- private mirrorState;
2795
+ private mirrorInitialState;
2702
2796
  private requireMatchingOwner;
2703
2797
  private immediateTransaction;
2704
2798
  private readTransaction;