zeitlich 0.2.45 → 0.2.47

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 (109) hide show
  1. package/README.md +137 -11
  2. package/dist/{activities-Coafq5zr.d.cts → activities-CPwKoUlD.d.cts} +22 -2
  3. package/dist/{activities-CrN-ghLo.d.ts → activities-DlaBxNID.d.ts} +22 -2
  4. package/dist/adapters/thread/anthropic/index.cjs +276 -71
  5. package/dist/adapters/thread/anthropic/index.cjs.map +1 -1
  6. package/dist/adapters/thread/anthropic/index.d.cts +62 -8
  7. package/dist/adapters/thread/anthropic/index.d.ts +62 -8
  8. package/dist/adapters/thread/anthropic/index.js +275 -72
  9. package/dist/adapters/thread/anthropic/index.js.map +1 -1
  10. package/dist/adapters/thread/anthropic/workflow.cjs +38 -20
  11. package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -1
  12. package/dist/adapters/thread/anthropic/workflow.d.cts +5 -4
  13. package/dist/adapters/thread/anthropic/workflow.d.ts +5 -4
  14. package/dist/adapters/thread/anthropic/workflow.js +38 -20
  15. package/dist/adapters/thread/anthropic/workflow.js.map +1 -1
  16. package/dist/adapters/thread/google-genai/index.cjs +171 -69
  17. package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
  18. package/dist/adapters/thread/google-genai/index.d.cts +6 -4
  19. package/dist/adapters/thread/google-genai/index.d.ts +6 -4
  20. package/dist/adapters/thread/google-genai/index.js +171 -69
  21. package/dist/adapters/thread/google-genai/index.js.map +1 -1
  22. package/dist/adapters/thread/google-genai/workflow.cjs +38 -20
  23. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
  24. package/dist/adapters/thread/google-genai/workflow.d.cts +7 -4
  25. package/dist/adapters/thread/google-genai/workflow.d.ts +7 -4
  26. package/dist/adapters/thread/google-genai/workflow.js +38 -20
  27. package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
  28. package/dist/adapters/thread/langchain/index.cjs +170 -66
  29. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  30. package/dist/adapters/thread/langchain/index.d.cts +19 -4
  31. package/dist/adapters/thread/langchain/index.d.ts +19 -4
  32. package/dist/adapters/thread/langchain/index.js +170 -66
  33. package/dist/adapters/thread/langchain/index.js.map +1 -1
  34. package/dist/adapters/thread/langchain/workflow.cjs +38 -20
  35. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
  36. package/dist/adapters/thread/langchain/workflow.d.cts +5 -4
  37. package/dist/adapters/thread/langchain/workflow.d.ts +5 -4
  38. package/dist/adapters/thread/langchain/workflow.js +38 -20
  39. package/dist/adapters/thread/langchain/workflow.js.map +1 -1
  40. package/dist/cold-store-BDgJpwLI.d.ts +114 -0
  41. package/dist/cold-store-Z2wvK2cV.d.cts +114 -0
  42. package/dist/index.cjs +440 -67
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.cts +150 -8
  45. package/dist/index.d.ts +150 -8
  46. package/dist/index.js +432 -68
  47. package/dist/index.js.map +1 -1
  48. package/dist/proxy-CDh3Rsa7.d.cts +40 -0
  49. package/dist/proxy-Du8ggERu.d.ts +40 -0
  50. package/dist/{thread-manager-wRVVBFgj.d.cts → thread-manager-BjoYYXgd.d.cts} +8 -2
  51. package/dist/{thread-manager-BsLO3Fgc.d.cts → thread-manager-D8zKNFZ9.d.cts} +8 -2
  52. package/dist/{thread-manager-Bi1XlbpJ.d.ts → thread-manager-DtHYws2F.d.ts} +8 -2
  53. package/dist/{thread-manager-BhkOyQ1I.d.ts → thread-manager-Dw96FKH1.d.ts} +8 -2
  54. package/dist/{types-C66-BVBr.d.cts → types-BMJrsHo0.d.cts} +17 -1
  55. package/dist/{types-BkX4HLzi.d.ts → types-CtdOquo3.d.ts} +17 -1
  56. package/dist/{types-CdALEF3z.d.cts → types-DNEl5uxQ.d.cts} +38 -0
  57. package/dist/{types-ChAy_jSP.d.ts → types-qQVZfhoT.d.ts} +38 -0
  58. package/dist/{workflow-DMmiaw6w.d.cts → workflow-BH9ImDGq.d.cts} +48 -2
  59. package/dist/{workflow-BwT5EybR.d.ts → workflow-Cdw3-RNB.d.ts} +48 -2
  60. package/dist/workflow.cjs +47 -4
  61. package/dist/workflow.cjs.map +1 -1
  62. package/dist/workflow.d.cts +2 -2
  63. package/dist/workflow.d.ts +2 -2
  64. package/dist/workflow.js +47 -5
  65. package/dist/workflow.js.map +1 -1
  66. package/package.json +14 -3
  67. package/src/adapters/thread/anthropic/activities.ts +82 -39
  68. package/src/adapters/thread/anthropic/index.ts +8 -0
  69. package/src/adapters/thread/anthropic/model-invoker.test.ts +110 -0
  70. package/src/adapters/thread/anthropic/model-invoker.ts +26 -5
  71. package/src/adapters/thread/anthropic/prompt-cache.test.ts +134 -0
  72. package/src/adapters/thread/anthropic/prompt-cache.ts +163 -0
  73. package/src/adapters/thread/anthropic/proxy.ts +1 -0
  74. package/src/adapters/thread/anthropic/thread-manager.ts +9 -1
  75. package/src/adapters/thread/google-genai/activities.ts +64 -40
  76. package/src/adapters/thread/google-genai/proxy.ts +1 -0
  77. package/src/adapters/thread/google-genai/thread-manager.ts +9 -1
  78. package/src/adapters/thread/langchain/activities.ts +63 -36
  79. package/src/adapters/thread/langchain/proxy.ts +1 -0
  80. package/src/adapters/thread/langchain/thread-manager.ts +9 -1
  81. package/src/index.ts +21 -2
  82. package/src/lib/session/session-edge-cases.integration.test.ts +12 -0
  83. package/src/lib/session/session.integration.test.ts +138 -0
  84. package/src/lib/session/session.ts +29 -0
  85. package/src/lib/session/types.ts +22 -0
  86. package/src/lib/subagent/define.ts +1 -0
  87. package/src/lib/subagent/handler.ts +11 -2
  88. package/src/lib/subagent/subagent.integration.test.ts +139 -0
  89. package/src/lib/subagent/types.ts +16 -0
  90. package/src/lib/thread/cold-store.test.ts +221 -0
  91. package/src/lib/thread/cold-store.ts +269 -0
  92. package/src/lib/thread/index.ts +32 -0
  93. package/src/lib/thread/keys.ts +20 -0
  94. package/src/lib/thread/manager.ts +16 -27
  95. package/src/lib/thread/proxy.ts +79 -27
  96. package/src/lib/thread/snapshot.test.ts +443 -0
  97. package/src/lib/thread/snapshot.ts +163 -0
  98. package/src/lib/thread/test-utils.ts +228 -0
  99. package/src/lib/thread/tiered.test.ts +281 -0
  100. package/src/lib/thread/tiered.ts +135 -0
  101. package/src/lib/thread/types.ts +16 -0
  102. package/src/tools/edit/handler.test.ts +177 -0
  103. package/src/tools/edit/handler.ts +249 -47
  104. package/src/tools/edit/tool.ts +40 -0
  105. package/src/tools/task-create/handler.ts +1 -1
  106. package/src/tools/task-update/handler.ts +1 -1
  107. package/src/workflow.ts +2 -2
  108. package/dist/proxy-Bf7uI-Hw.d.cts +0 -24
  109. package/dist/proxy-COqA95FW.d.ts +0 -24
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  **Durable AI Agents for Temporal**
10
10
 
11
- Zeitlich is an opinionated framework for building reliable, stateful AI agents using [Temporal](https://temporal.io). It provides the building blocks for creating agents that can survive crashes, handle long-running tasks, and coordinate with other agents—all with full type safety.
11
+ Zeitlich is an opinionated harness for building reliable, stateful AI agents using [Temporal](https://temporal.io). It provides the building blocks for creating agents that can survive crashes, handle long-running tasks, and coordinate with other agents—all with full type safety.
12
12
 
13
13
  ## Why Zeitlich?
14
14
 
@@ -103,6 +103,8 @@ npm install zeitlich ioredis \
103
103
  - `@langchain/core` >= 1.0.0 (optional — only when using the LangChain adapter)
104
104
  - `@google/genai` >= 1.0.0 (optional — only when using the Google GenAI adapter)
105
105
  - `@aws-sdk/client-bedrock-agentcore` >= 3.900.0 (optional — only when using the Bedrock adapter)
106
+ - `@aws-sdk/client-s3` >= 3.700.0 (optional — only when using the built-in S3 cold thread tier)
107
+ - `@aws-sdk/lib-storage` >= 3.700.0 (optional — paired with `@aws-sdk/client-s3` for multipart uploads in the S3 cold tier)
106
108
 
107
109
  > **Why peer deps?** Zeitlich's public API surfaces `@temporalio/*` types
108
110
  > (`UpdateDefinition`, `ChildWorkflowOptions`, `Duration`, etc.) directly. Peer
@@ -666,6 +668,113 @@ const continuedSession = await createSession({
666
668
 
667
669
  `getShortId()` produces compact, workflow-deterministic IDs (~12 base-62 chars) that are more token-efficient than UUIDs.
668
670
 
671
+ #### Tiered Thread Storage (Redis hot + S3 cold)
672
+
673
+ By default every thread lives in Redis with a 90-day TTL — both messages and the persisted state slice. For long-lived agents, that ties up hot memory for inactive conversations and ties durability to your Redis retention. Zeitlich's tiered storage moves cold threads to a durable archive (S3, R2, GCS, …) while keeping Redis as the hot tier only for the duration of a workflow run.
674
+
675
+ | Tier | Backend | Lifetime |
676
+ | ---- | ----------------------------------------- | ------------------------------------------------------ |
677
+ | Hot | Redis | Only while a workflow run is active (configurable TTL) |
678
+ | Cold | Pluggable `ColdThreadStore` (built-in S3) | Durable across runs |
679
+
680
+ The session wiring is fully automatic:
681
+
682
+ - On entry — `mode: "continue"` and `mode: "fork"` call `hydrateThread`, which restores the latest cold-tier snapshot into Redis if Redis is cold. Idempotent (safe for Temporal activity retries).
683
+ - In `finally{}` — every exit path calls `flushThread` after `saveThreadState`, which writes the current Redis contents to the cold tier and (by default) deletes the Redis keys. A near-immediate `continue` re-hydrates in a single `GetObject`.
684
+
685
+ ##### Wiring the built-in S3 cold store
686
+
687
+ ```typescript
688
+ import { S3Client } from "@aws-sdk/client-s3";
689
+ import { createS3ColdStore } from "zeitlich";
690
+ import { createAnthropicAdapter } from "zeitlich/adapters/thread/anthropic";
691
+
692
+ const coldStore = createS3ColdStore({
693
+ s3: new S3Client({ region: "us-east-1" }),
694
+ bucket: "my-threads",
695
+ prefix: "prod/threads",
696
+ // gzip: true (default) — message lists compress well
697
+ });
698
+
699
+ const adapter = createAnthropicAdapter({
700
+ redis,
701
+ client: anthropic,
702
+ model: "claude-sonnet-4-20250514",
703
+ coldStore,
704
+ // Recommended: drop the Redis TTL to a small window when cold tiering
705
+ // is enabled. The cold tier is the source of truth.
706
+ ttlSeconds: 60 * 60 * 24, // 24h
707
+ });
708
+ ```
709
+
710
+ That's the only change required — `createSession`, all `ThreadInit` modes, and every adapter activity are already wired for the lifecycle. When `coldStore` is omitted, the adapter behaves identically to the Redis-only baseline.
711
+
712
+ ##### Anthropic prompt caching
713
+
714
+ The Anthropic adapter enables 5-minute ephemeral prompt caching by default. Before each `messages.stream()` call, it adds an explicit block-level `cache_control: { type: "ephemeral", ttl: "5m" }` marker to the last cacheable message content block. Zeitlich intentionally uses the block-level shape instead of Anthropic's top-level automatic cache-control parameter so the same request body works with Anthropic direct API clients and Anthropic-on-Bedrock `InvokeModel` clients.
715
+
716
+ ```typescript
717
+ const adapter = createAnthropicAdapter({
718
+ redis,
719
+ client: anthropic,
720
+ model: "claude-sonnet-4-20250514",
721
+ // Optional: 5m is the default; set explicitly if you prefer clarity.
722
+ promptCache: { ttl: "5m" },
723
+ });
724
+
725
+ // Disable if a model/provider route does not support prompt caching.
726
+ const uncachedAdapter = createAnthropicAdapter({
727
+ redis,
728
+ client: anthropic,
729
+ model: "claude-sonnet-4-20250514",
730
+ promptCache: false,
731
+ });
732
+ ```
733
+
734
+ If you already provide your own `cache_control` markers, Zeitlich preserves them and skips its automatic marker when the request already has the provider maximum of four cache breakpoints.
735
+
736
+ ##### Custom backends
737
+
738
+ `ColdThreadStore` is intentionally minimal:
739
+
740
+ ```typescript
741
+ interface ColdThreadStore {
742
+ read(threadKey: string, threadId: string): Promise<ThreadSnapshot | null>;
743
+ write(
744
+ threadKey: string,
745
+ threadId: string,
746
+ snapshot: ThreadSnapshot
747
+ ): Promise<void>;
748
+ delete(threadKey: string, threadId: string): Promise<void>;
749
+ }
750
+ ```
751
+
752
+ Any backend that can satisfy these three calls — Cloudflare R2, Google Cloud Storage, Postgres, the local filesystem — can plug into the same tiered manager. `ThreadSnapshot` is one JSON-friendly blob per thread; round-trip it however you like.
753
+
754
+ ##### Trade-offs
755
+
756
+ - **Cold writes are session-boundary only.** No per-append S3 traffic. Long-running sessions are durable via Temporal workflow history + Redis TTL.
757
+ - **Single-writer assumed.** Two sessions started simultaneously on the same `threadId` would race on flush. Use distinct `threadId`s or coordinate at a layer above zeitlich.
758
+ - **`deleteHot: true` by default on flush.** Memory drops immediately; the next continue re-hydrates in one `GetObject`. Override per-call via the tiered manager if you want to keep the hot tier warm.
759
+ - **`mode: "new"` overwrites the cold archive for that `threadId`.** A session entered with `mode: "new"` skips `hydrateThread`; on exit `flushThread` writes the fresh snapshot back, silently replacing any prior cold-tier blob at the same `(threadKey, threadId)`. To resume a thread, use `mode: "continue"` or `mode: "fork"` — passing a previously-used `threadId` with `mode: "new"` is destructive by design.
760
+
761
+ ##### Activity timeouts
762
+
763
+ `hydrateThread` and `flushThread` automatically get `startToCloseTimeout: "60s"` and `heartbeatTimeout: "15s"`. The S3 cold store uses multipart `Upload` for writes and streams the `GetObject` response on reads — each part completion / stream chunk emits a heartbeat, so a stalled upload or download trips `heartbeatTimeout` (15s) rather than waiting out `startToCloseTimeout` (60s). The Redis-only ops keep the tight `10s` baseline.
764
+
765
+ To override an individual op without inflating the rest:
766
+
767
+ ```typescript
768
+ const threadOps = proxyGoogleGenAIThreadOps(undefined, {
769
+ defaults: { startToCloseTimeout: "5s" }, // applied to every op
770
+ perOp: {
771
+ flushThread: { startToCloseTimeout: "180s" }, // overlays cold-tier defaults; heartbeatTimeout still inherited
772
+ },
773
+ });
774
+ ```
775
+
776
+ `perOp[op]` is layered shallow-rightmost over `defaults` and the built-in cold-tier overlays for `hydrateThread` / `flushThread` — so a partial override only replaces the fields you specify. A bare `ActivityOptions` object is also accepted and treated as `{ defaults: <that object> }`, with the cold-tier overlay still applied on top — to raise the cold-tier ceiling above `60s`, use `perOp.flushThread` / `perOp.hydrateThread`.
777
+
669
778
  #### Sandbox Initialization (`SandboxInit`)
670
779
 
671
780
  The `sandbox` field controls how a sandbox is created or reused:
@@ -770,6 +879,17 @@ Trade-off: cleanup is deferred to parent close (no eager GC of superseded thread
770
879
 
771
880
  The `thread` field accepts `"new"` (default), `"fork"`, or `"continue"`. When set to `"fork"` or `"continue"`, the parent agent can pass a `threadId` in a subsequent `Task` tool call to resume the conversation. The subagent returns its `threadId` in the response (surfaced as `[Thread ID: ...]`), which the parent can use for continuation.
772
881
 
882
+ The `newThreadSource` field controls what to do when the parent's tool call omits `threadId`. It accepts `"new"` (default — start a fresh thread) or `"from-parent"` (fork/continue the parent agent's own thread). Useful when you want a subagent that inherits the parent's conversation state by default without requiring the LLM to explicitly thread the id through:
883
+
884
+ ```typescript
885
+ export const researcherSubagent = defineSubagent(researcherWorkflow, {
886
+ thread: "fork",
887
+ newThreadSource: "from-parent", // no threadId → fork the parent's thread
888
+ });
889
+ ```
890
+
891
+ An explicit `threadId` from the parent's tool call always wins; `newThreadSource` only applies when none is provided. The field has no effect with `thread: "new"`.
892
+
773
893
  The `sandbox` field accepts `"none"` (default) or an object with `source`, `continuation`, and optional `init`/`shutdown` fields:
774
894
 
775
895
  - `source: "inherit"` — use the parent's sandbox. `continuation: "continue"` shares it directly; `"fork"` forks from it on every call.
@@ -983,16 +1103,22 @@ Safe for use in Temporal workflow files:
983
1103
 
984
1104
  Framework-agnostic utilities for activities, worker setup, and Node.js code:
985
1105
 
986
- | Export | Description |
987
- | ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
988
- | `createRunAgentActivity` | Wraps a handler into a scope-prefixed `RunAgentActivity` with auto-fetched parent workflow state |
989
- | `withParentWorkflowState` | Wraps a tool handler into an `ActivityToolHandler` with auto-fetched parent workflow state |
990
- | `createThreadManager` | Generic Redis-backed thread manager factory |
991
- | `toTree` | Generate file tree string from an `IFileSystem` instance |
992
- | `withSandbox` | Wraps a handler to auto-resolve sandbox from context (pairs with `withAutoAppend`) |
993
- | `NodeFsSandboxFileSystem` | `node:fs` adapter for `SandboxFileSystem` read skills from the worker's local disk |
994
- | `FileSystemSkillProvider` | Load skills from a directory following the agentskills.io layout |
995
- | Tool handlers | `bashHandler`, `editHandler`, `globHandler`, `readFileHandler`, `writeFileHandler`, `createAskUserQuestionHandler` |
1106
+ | Export | Description |
1107
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------ |
1108
+ | `createRunAgentActivity` | Wraps a handler into a scope-prefixed `RunAgentActivity` with auto-fetched parent workflow state |
1109
+ | `withParentWorkflowState` | Wraps a tool handler into an `ActivityToolHandler` with auto-fetched parent workflow state |
1110
+ | `getActivityContext` | Safely returns `{ heartbeat, signal }` from the current Temporal activity, or `{}` outside one |
1111
+ | `createThreadManager` | Generic Redis-backed thread manager factory |
1112
+ | `createTieredThreadManager` | Redis hot + pluggable cold tier; adds `hydrate()` / `flush()` to `BaseThreadManager<T>` |
1113
+ | `createS3ColdStore` | Built-in `ColdThreadStore` backed by an `@aws-sdk/client-s3` `S3Client` |
1114
+ | `encodeSnapshot` | Low-level helper that builds a `ThreadSnapshot` from the hot-tier Redis state |
1115
+ | `applySnapshot` | Low-level helper that restores a `ThreadSnapshot` into Redis (idempotent) |
1116
+ | `clearHotTier` | Low-level helper that deletes every Redis key the thread manager wrote for a given `(threadKey, threadId)` |
1117
+ | `toTree` | Generate file tree string from an `IFileSystem` instance |
1118
+ | `withSandbox` | Wraps a handler to auto-resolve sandbox from context (pairs with `withAutoAppend`) |
1119
+ | `NodeFsSandboxFileSystem` | `node:fs` adapter for `SandboxFileSystem` — read skills from the worker's local disk |
1120
+ | `FileSystemSkillProvider` | Load skills from a directory following the agentskills.io layout |
1121
+ | Tool handlers | `bashHandler`, `editHandler`, `globHandler`, `readFileHandler`, `writeFileHandler`, `createAskUserQuestionHandler` |
996
1122
 
997
1123
  ### Thread Adapter Entry Points
998
1124
 
@@ -1,7 +1,8 @@
1
1
  import Redis from 'ioredis';
2
2
  import { Part, Content, GoogleGenAI } from '@google/genai';
3
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-CdALEF3z.cjs';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-C66-BVBr.cjs';
3
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-DNEl5uxQ.cjs';
4
+ import { C as ColdThreadStore } from './cold-store-Z2wvK2cV.cjs';
5
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BMJrsHo0.cjs';
5
6
  import { A as ADAPTER_ID } from './adapter-id-BB-mmrts.cjs';
6
7
 
7
8
  /** SDK-native content type for Google GenAI human messages */
@@ -20,6 +21,12 @@ interface GoogleGenAIThreadManagerConfig {
20
21
  /** Thread key, defaults to 'messages' */
21
22
  key?: string;
22
23
  hooks?: GoogleGenAIThreadManagerHooks;
24
+ /**
25
+ * Override the default thread TTL (90 days). When pairing the
26
+ * adapter with a durable cold tier, a shorter TTL (hours) is
27
+ * typically more appropriate.
28
+ */
29
+ ttlSeconds?: number;
23
30
  }
24
31
  /** Prepared payload ready to send to the Google GenAI API */
25
32
  interface GoogleGenAIInvocationPayload {
@@ -45,6 +52,19 @@ interface GoogleGenAIAdapterConfig {
45
52
  /** Default model name (e.g. 'gemini-2.5-flash'). If omitted, use `createModelInvoker()` */
46
53
  model?: string;
47
54
  hooks?: GoogleGenAIThreadManagerHooks;
55
+ /**
56
+ * Optional durable cold tier (e.g. S3, R2, GCS). When provided,
57
+ * the session hydrates the thread on entry (`continue`/`fork`) and
58
+ * flushes it on every exit path. When omitted, the adapter is
59
+ * Redis-only and `hydrateThread`/`flushThread` activities are no-ops.
60
+ */
61
+ coldStore?: ColdThreadStore;
62
+ /**
63
+ * Override the default Redis TTL (90 days). When pairing the
64
+ * adapter with a `coldStore`, a shorter TTL (hours) is typically
65
+ * more appropriate.
66
+ */
67
+ ttlSeconds?: number;
48
68
  }
49
69
  /**
50
70
  * Tool response type accepted by the Google GenAI adapter.
@@ -1,7 +1,8 @@
1
1
  import Redis from 'ioredis';
2
2
  import { Part, Content, GoogleGenAI } from '@google/genai';
3
- import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-ChAy_jSP.js';
4
- import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-BkX4HLzi.js';
3
+ import { a as ModelInvoker, b as PrefixedThreadOps, S as ScopedPrefix, R as RouterContext, c as ToolHandlerResponse, d as ActivityToolHandler } from './types-qQVZfhoT.js';
4
+ import { C as ColdThreadStore } from './cold-store-BDgJpwLI.js';
5
+ import { T as ThreadManagerHooks, P as ProviderThreadManager } from './types-CtdOquo3.js';
5
6
  import { A as ADAPTER_ID } from './adapter-id-BB-mmrts.js';
6
7
 
7
8
  /** SDK-native content type for Google GenAI human messages */
@@ -20,6 +21,12 @@ interface GoogleGenAIThreadManagerConfig {
20
21
  /** Thread key, defaults to 'messages' */
21
22
  key?: string;
22
23
  hooks?: GoogleGenAIThreadManagerHooks;
24
+ /**
25
+ * Override the default thread TTL (90 days). When pairing the
26
+ * adapter with a durable cold tier, a shorter TTL (hours) is
27
+ * typically more appropriate.
28
+ */
29
+ ttlSeconds?: number;
23
30
  }
24
31
  /** Prepared payload ready to send to the Google GenAI API */
25
32
  interface GoogleGenAIInvocationPayload {
@@ -45,6 +52,19 @@ interface GoogleGenAIAdapterConfig {
45
52
  /** Default model name (e.g. 'gemini-2.5-flash'). If omitted, use `createModelInvoker()` */
46
53
  model?: string;
47
54
  hooks?: GoogleGenAIThreadManagerHooks;
55
+ /**
56
+ * Optional durable cold tier (e.g. S3, R2, GCS). When provided,
57
+ * the session hydrates the thread on entry (`continue`/`fork`) and
58
+ * flushes it on every exit path. When omitted, the adapter is
59
+ * Redis-only and `hydrateThread`/`flushThread` activities are no-ops.
60
+ */
61
+ coldStore?: ColdThreadStore;
62
+ /**
63
+ * Override the default Redis TTL (90 days). When pairing the
64
+ * adapter with a `coldStore`, a shorter TTL (hours) is typically
65
+ * more appropriate.
66
+ */
67
+ ttlSeconds?: number;
48
68
  }
49
69
  /**
50
70
  * Tool response type accepted by the Google GenAI adapter.