zeitlich 0.2.25 → 0.2.26

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 (111) hide show
  1. package/dist/activities-BEJRyDVU.d.cts +137 -0
  2. package/dist/activities-LVQdLF6I.d.ts +137 -0
  3. package/dist/adapters/sandbox/virtual/index.cjs.map +1 -1
  4. package/dist/adapters/sandbox/virtual/index.d.cts +8 -7
  5. package/dist/adapters/sandbox/virtual/index.d.ts +8 -7
  6. package/dist/adapters/sandbox/virtual/index.js.map +1 -1
  7. package/dist/adapters/sandbox/virtual/workflow.d.cts +3 -2
  8. package/dist/adapters/sandbox/virtual/workflow.d.ts +3 -2
  9. package/dist/adapters/thread/anthropic/index.cjs +356 -0
  10. package/dist/adapters/thread/anthropic/index.cjs.map +1 -0
  11. package/dist/adapters/thread/anthropic/index.d.cts +148 -0
  12. package/dist/adapters/thread/anthropic/index.d.ts +148 -0
  13. package/dist/adapters/thread/anthropic/index.js +351 -0
  14. package/dist/adapters/thread/anthropic/index.js.map +1 -0
  15. package/dist/adapters/thread/anthropic/workflow.cjs +38 -0
  16. package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -0
  17. package/dist/adapters/thread/anthropic/workflow.d.cts +37 -0
  18. package/dist/adapters/thread/anthropic/workflow.d.ts +37 -0
  19. package/dist/adapters/thread/anthropic/workflow.js +36 -0
  20. package/dist/adapters/thread/anthropic/workflow.js.map +1 -0
  21. package/dist/adapters/thread/google-genai/index.cjs +95 -97
  22. package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
  23. package/dist/adapters/thread/google-genai/index.d.cts +9 -111
  24. package/dist/adapters/thread/google-genai/index.d.ts +9 -111
  25. package/dist/adapters/thread/google-genai/index.js +96 -97
  26. package/dist/adapters/thread/google-genai/index.js.map +1 -1
  27. package/dist/adapters/thread/google-genai/workflow.cjs +9 -4
  28. package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
  29. package/dist/adapters/thread/google-genai/workflow.d.cts +10 -5
  30. package/dist/adapters/thread/google-genai/workflow.d.ts +10 -5
  31. package/dist/adapters/thread/google-genai/workflow.js +9 -4
  32. package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
  33. package/dist/adapters/thread/langchain/index.cjs +43 -60
  34. package/dist/adapters/thread/langchain/index.cjs.map +1 -1
  35. package/dist/adapters/thread/langchain/index.d.cts +24 -38
  36. package/dist/adapters/thread/langchain/index.d.ts +24 -38
  37. package/dist/adapters/thread/langchain/index.js +43 -60
  38. package/dist/adapters/thread/langchain/index.js.map +1 -1
  39. package/dist/adapters/thread/langchain/workflow.cjs +9 -4
  40. package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
  41. package/dist/adapters/thread/langchain/workflow.d.cts +10 -5
  42. package/dist/adapters/thread/langchain/workflow.d.ts +10 -5
  43. package/dist/adapters/thread/langchain/workflow.js +9 -4
  44. package/dist/adapters/thread/langchain/workflow.js.map +1 -1
  45. package/dist/index.cjs +27 -10
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +13 -12
  48. package/dist/index.d.ts +13 -12
  49. package/dist/index.js +28 -11
  50. package/dist/index.js.map +1 -1
  51. package/dist/proxy-BK1ydQt0.d.ts +24 -0
  52. package/dist/proxy-BMAsMHdp.d.cts +24 -0
  53. package/dist/{queries-DwBe2CAA.d.ts → queries-BCgJ9Sr5.d.ts} +1 -1
  54. package/dist/{queries-BYGBImeC.d.cts → queries-DwnE2bu3.d.cts} +1 -1
  55. package/dist/thread-manager-CH9krS3h.d.ts +37 -0
  56. package/dist/thread-manager-Czhpxbt6.d.ts +29 -0
  57. package/dist/thread-manager-DOnQzImf.d.cts +29 -0
  58. package/dist/thread-manager-b4DML-qu.d.cts +37 -0
  59. package/dist/{types-35POpVfa.d.ts → types-BDRDbm3h.d.cts} +22 -1
  60. package/dist/{types-hmferhc2.d.ts → types-CvJyXDYt.d.ts} +44 -123
  61. package/dist/{types-LVKmCNds.d.ts → types-DFUNSYbj.d.ts} +1 -1
  62. package/dist/{types-Bf8KV0Ci.d.cts → types-DRnz-OZp.d.cts} +1 -1
  63. package/dist/{types-7PeMi1bD.d.cts → types-DSOefLpY.d.cts} +44 -123
  64. package/dist/{types-35POpVfa.d.cts → types-WNSeZbWa.d.ts} +22 -1
  65. package/dist/{types-D_igp10o.d.cts → types-mCVxKIZb.d.cts} +233 -137
  66. package/dist/{types-D_igp10o.d.ts → types-mCVxKIZb.d.ts} +233 -137
  67. package/dist/workflow.cjs +25 -9
  68. package/dist/workflow.cjs.map +1 -1
  69. package/dist/workflow.d.cts +11 -11
  70. package/dist/workflow.d.ts +11 -11
  71. package/dist/workflow.js +26 -10
  72. package/dist/workflow.js.map +1 -1
  73. package/package.json +26 -1
  74. package/src/adapters/sandbox/virtual/with-virtual-sandbox.ts +8 -3
  75. package/src/adapters/thread/anthropic/activities.ts +223 -0
  76. package/src/adapters/thread/anthropic/index.ts +44 -0
  77. package/src/adapters/thread/anthropic/model-invoker.ts +124 -0
  78. package/src/adapters/thread/anthropic/proxy.ts +33 -0
  79. package/src/adapters/thread/anthropic/thread-manager.ts +191 -0
  80. package/src/adapters/thread/google-genai/activities.ts +107 -32
  81. package/src/adapters/thread/google-genai/index.ts +3 -1
  82. package/src/adapters/thread/google-genai/model-invoker.ts +7 -40
  83. package/src/adapters/thread/google-genai/proxy.ts +6 -34
  84. package/src/adapters/thread/google-genai/thread-manager.ts +84 -104
  85. package/src/adapters/thread/langchain/activities.ts +53 -20
  86. package/src/adapters/thread/langchain/index.ts +3 -1
  87. package/src/adapters/thread/langchain/model-invoker.ts +7 -9
  88. package/src/adapters/thread/langchain/proxy.ts +6 -34
  89. package/src/adapters/thread/langchain/thread-manager.ts +44 -98
  90. package/src/index.ts +5 -1
  91. package/src/lib/activity.ts +4 -3
  92. package/src/lib/hooks/types.ts +12 -12
  93. package/src/lib/model/types.ts +2 -0
  94. package/src/lib/session/session-edge-cases.integration.test.ts +24 -6
  95. package/src/lib/session/session.ts +18 -14
  96. package/src/lib/session/types.ts +31 -14
  97. package/src/lib/subagent/handler.ts +15 -8
  98. package/src/lib/subagent/types.ts +3 -2
  99. package/src/lib/thread/index.ts +2 -0
  100. package/src/lib/thread/manager.ts +4 -7
  101. package/src/lib/thread/proxy.ts +57 -0
  102. package/src/lib/thread/types.ts +31 -0
  103. package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +54 -0
  104. package/src/lib/tool-router/auto-append.ts +5 -2
  105. package/src/lib/tool-router/router-edge-cases.integration.test.ts +9 -5
  106. package/src/lib/tool-router/router.ts +13 -7
  107. package/src/lib/tool-router/types.ts +20 -13
  108. package/src/lib/tool-router/with-sandbox.ts +4 -3
  109. package/src/lib/types.ts +7 -14
  110. package/src/workflow.ts +0 -4
  111. package/tsup.config.ts +5 -0
@@ -1,9 +1,8 @@
1
1
  import { Duration } from '@temporalio/common';
2
- import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-D_igp10o.cjs';
2
+ import { a as ToolMap, b as ToolRouterHooks, S as SessionExitReason, J as JsonValue, T as ToolHandlerResponse, P as PreToolUseHookResult, c as PostToolUseFailureHookResult, d as RawToolCall, e as TokenUsage, B as BaseAgentState, f as RunAgentConfig, g as ToolResultConfig, h as ToolCallResultUnion, I as InferToolResults, i as JsonSerializable, j as AgentStateManager } from './types-mCVxKIZb.cjs';
3
3
  import { z } from 'zod';
4
4
  import { g as SandboxOps } from './types-ChAMwU3q.cjs';
5
- import { QueryDefinition, ActivityInterfaceFor } from '@temporalio/workflow';
6
- import { UpdateDefinition } from '@temporalio/common/lib/interfaces';
5
+ import { ActivityInterfaceFor } from '@temporalio/workflow';
7
6
 
8
7
  /**
9
8
  * Context for SessionStart hook - called when session begins
@@ -34,35 +33,35 @@ type SessionEndHook = (ctx: SessionEndHookContext) => void | Promise<void>;
34
33
  /**
35
34
  * Context for PreHumanMessageAppend hook - called before each human message is appended to the thread
36
35
  */
37
- interface PreHumanMessageAppendHookContext {
38
- message: MessageContent;
36
+ interface PreHumanMessageAppendHookContext<TContent = unknown> {
37
+ message: TContent;
39
38
  threadId: string;
40
39
  }
41
40
  /**
42
41
  * PreHumanMessageAppend hook - called before each human message is appended to the thread
43
42
  */
44
- type PreHumanMessageAppendHook = (ctx: PreHumanMessageAppendHookContext) => void | Promise<void>;
43
+ type PreHumanMessageAppendHook<TContent = unknown> = (ctx: PreHumanMessageAppendHookContext<TContent>) => void | Promise<void>;
45
44
  /**
46
45
  * Context for PostHumanMessageAppend hook - called after each human message is appended to the thread
47
46
  */
48
- interface PostHumanMessageAppendHookContext {
49
- message: MessageContent;
47
+ interface PostHumanMessageAppendHookContext<TContent = unknown> {
48
+ message: TContent;
50
49
  threadId: string;
51
50
  }
52
51
  /**
53
52
  * PostHumanMessageAppend hook - called after each human message is appended to the thread
54
53
  */
55
- type PostHumanMessageAppendHook = (ctx: PostHumanMessageAppendHookContext) => void | Promise<void>;
54
+ type PostHumanMessageAppendHook<TContent = unknown> = (ctx: PostHumanMessageAppendHookContext<TContent>) => void | Promise<void>;
56
55
  /**
57
56
  * Full hooks interface for a session — combines tool execution hooks
58
57
  * (consumed by the router) with session/message lifecycle hooks
59
58
  * (consumed directly by the session).
60
59
  */
61
- interface Hooks<T extends ToolMap, TResult = unknown> extends ToolRouterHooks<T, TResult> {
60
+ interface Hooks<T extends ToolMap, TResult = unknown, TContent = unknown> extends ToolRouterHooks<T, TResult> {
62
61
  /** Called before each human message is appended to the thread */
63
- onPreHumanMessageAppend?: PreHumanMessageAppendHook;
62
+ onPreHumanMessageAppend?: PreHumanMessageAppendHook<TContent>;
64
63
  /** Called after each human message is appended to the thread */
65
- onPostHumanMessageAppend?: PostHumanMessageAppendHook;
64
+ onPostHumanMessageAppend?: PostHumanMessageAppendHook<TContent>;
66
65
  /** Called when session starts */
67
66
  onSessionStart?: SessionStartHook;
68
67
  /** Called when session ends */
@@ -129,7 +128,7 @@ type SandboxShutdown = "destroy" | "pause" | "keep";
129
128
  type SubagentSandboxShutdown = SandboxShutdown | "pause-until-parent-close";
130
129
 
131
130
  /** ToolHandlerResponse with threadId required (subagents must always surface their thread) */
132
- type SubagentHandlerResponse<TResult = null> = ToolHandlerResponse<TResult> & {
131
+ type SubagentHandlerResponse<TResult = null, TToolResponse = JsonValue> = ToolHandlerResponse<TResult, TToolResponse> & {
133
132
  threadId: string;
134
133
  sandboxId?: string;
135
134
  };
@@ -335,6 +334,8 @@ type RunAgentActivity<M = unknown> = (config: RunAgentConfig) => Promise<AgentRe
335
334
  */
336
335
  interface ModelInvokerConfig {
337
336
  threadId: string;
337
+ /** Redis key suffix for thread storage. Defaults to 'messages'. */
338
+ threadKey?: string;
338
339
  agentName: string;
339
340
  state: BaseAgentState;
340
341
  metadata?: Record<string, unknown>;
@@ -349,117 +350,25 @@ interface ModelInvokerConfig {
349
350
  */
350
351
  type ModelInvoker<M = unknown> = (config: ModelInvokerConfig) => Promise<AgentResponse<M>>;
351
352
 
352
- /**
353
- * JSON primitive types that Temporal can serialize
354
- */
355
- type JsonPrimitive = string | number | boolean | null | undefined;
356
- /**
357
- * JSON-serializable value (recursive type for Temporal compatibility)
358
- */
359
- type JsonValue = JsonPrimitive | JsonValue[] | {
360
- [key: string]: JsonValue;
361
- };
362
- /**
363
- * Type constraint ensuring T only contains JSON-serializable values.
364
- * Use this for custom state to ensure Temporal workflow compatibility.
365
- *
366
- * Allows: primitives, arrays, plain objects, and JsonValue
367
- * Rejects: functions, symbols, undefined, class instances with methods
368
- */
369
- type JsonSerializable<T> = {
370
- [K in keyof T]: T[K] extends JsonValue ? T[K] : T[K] extends JsonPrimitive ? T[K] : T[K] extends (infer U)[] ? U extends JsonValue ? T[K] : JsonSerializable<U>[] : T[K] extends object ? JsonSerializable<T[K]> : never;
371
- };
372
- /**
373
- * Full state type combining base state with custom state
374
- */
375
- type AgentState<TCustom extends JsonSerializable<TCustom>> = BaseAgentState & TCustom;
376
- /**
377
- * Agent state manager interface
378
- * Note: Temporal handlers must be set up in the workflow file due to
379
- * Temporal's workflow isolation requirements. This manager provides
380
- * the state and helpers needed for those handlers.
381
- */
382
- interface AgentStateManager<TCustom extends JsonSerializable<TCustom>> {
383
- /** Typed query definition registered for this agent's state */
384
- readonly stateQuery: QueryDefinition<AgentState<TCustom>>;
385
- /** Typed update definition registered for waiting on this agent's state change */
386
- readonly stateChangeUpdate: UpdateDefinition<AgentState<TCustom>, [number]>;
387
- /** Get current status */
388
- getStatus(): AgentStatus;
389
- /** Check if agent is running */
390
- isRunning(): boolean;
391
- /** Check if agent is in terminal state */
392
- isTerminal(): boolean;
393
- /** Get current state version */
394
- getVersion(): number;
395
- /** Set status to RUNNING */
396
- run(): void;
397
- /** Set status to WAITING_FOR_INPUT */
398
- waitForInput(): void;
399
- /** Set status to COMPLETED */
400
- complete(): void;
401
- /** Set status to FAILED */
402
- fail(): void;
403
- /** Set status to CANCELLED */
404
- cancel(): void;
405
- /** Increment state version (call after state changes) */
406
- incrementVersion(): void;
407
- /** Increment turns (call after each turn) */
408
- incrementTurns(): void;
409
- /** Get current turns */
410
- getTurns(): number;
411
- /** Get the system prompt */
412
- getSystemPrompt(): string | undefined;
413
- /** Set the system prompt */
414
- setSystemPrompt(newSystemPrompt: string): void;
415
- /** Get a custom state value by key */
416
- get<K extends keyof TCustom>(key: K): TCustom[K];
417
- /** Set a custom state value by key */
418
- set<K extends keyof TCustom>(key: K, value: TCustom[K]): void;
419
- /** Bulk-merge a partial update into custom state (e.g. from sandbox stateUpdate) */
420
- mergeUpdate(update: Partial<TCustom>): void;
421
- /** Get full state for query handler */
422
- getCurrentState(): AgentState<TCustom>;
423
- /** Check if should return from waitForStateChange */
424
- shouldReturnFromWait(lastKnownVersion: number): boolean;
425
- /** Get all tasks */
426
- getTasks(): WorkflowTask[];
427
- /** Get a task by ID */
428
- getTask(id: string): WorkflowTask | undefined;
429
- /** Add or update a task */
430
- setTask(task: WorkflowTask): void;
431
- /** Delete a task by ID */
432
- deleteTask(id: string): boolean;
433
- /** Set the tools (converts Zod schemas to JSON Schema for serialization) */
434
- setTools(newTools: ToolDefinition[]): void;
435
- /** Update the usage */
436
- updateUsage(usage: TokenUsage): void;
437
- /** Get the total usage */
438
- getTotalUsage(): {
439
- totalInputTokens: number;
440
- totalOutputTokens: number;
441
- totalCachedWriteTokens: number;
442
- totalCachedReadTokens: number;
443
- totalReasonTokens: number;
444
- turns: number;
445
- };
446
- }
447
-
448
353
  /**
449
354
  * Thread operations required by a session.
450
355
  * Consumers provide these — typically by wrapping Temporal activities.
356
+ *
357
+ * `TContent` is the SDK-native content type for human messages.
358
+ * Each adapter supplies its own type (e.g. Anthropic ContentBlockParam[],
359
+ * Google GenAI Part[], LangChain MessageContent). Defaults to `string`.
451
360
  */
452
- interface ThreadOps {
361
+ interface ThreadOps<TContent = string> {
453
362
  /** Initialize an empty thread */
454
- initializeThread(threadId: string): Promise<void>;
363
+ initializeThread(threadId: string, threadKey?: string): Promise<void>;
455
364
  /** Append a human message to the thread */
456
- appendHumanMessage(threadId: string, id: string, content: string | MessageContent): Promise<void>;
365
+ appendHumanMessage(threadId: string, id: string, content: TContent, threadKey?: string): Promise<void>;
457
366
  /** Append a tool result to the thread */
458
367
  appendToolResult(id: string, config: ToolResultConfig): Promise<void>;
459
368
  /** Append a system message to the thread */
460
- appendSystemMessage(threadId: string, id: string, content: string): Promise<void>;
369
+ appendSystemMessage(threadId: string, id: string, content: string, threadKey?: string): Promise<void>;
461
370
  /** Copy all messages from sourceThreadId into a new thread at targetThreadId */
462
- forkThread(sourceThreadId: string, targetThreadId: string): Promise<void>;
371
+ forkThread(sourceThreadId: string, targetThreadId: string, threadKey?: string): Promise<void>;
463
372
  }
464
373
  /**
465
374
  * Composes an adapter prefix + workflow scope for activity naming.
@@ -484,13 +393,17 @@ type ScopedPrefix<TScope extends string, TAdapter extends string> = TScope exten
484
393
  * // → { googleGenAIInitializeThread, googleGenAIAppendHumanMessage, … }
485
394
  * ```
486
395
  */
487
- type PrefixedThreadOps<TPrefix extends string> = {
488
- [K in keyof ThreadOps as `${TPrefix}${Capitalize<K & string>}`]: ThreadOps[K];
396
+ type PrefixedThreadOps<TPrefix extends string, TContent = string> = {
397
+ [K in keyof ThreadOps<TContent> as `${TPrefix}${Capitalize<K & string>}`]: ThreadOps<TContent>[K];
489
398
  };
490
399
  /**
491
- * Configuration for a Zeitlich agent session
400
+ * Configuration for a Zeitlich agent session.
401
+ *
402
+ * @typeParam T - Tool map
403
+ * @typeParam M - SDK-native message type returned by the model invoker
404
+ * @typeParam TContent - SDK-native content type for human messages (defaults to `string`)
492
405
  */
493
- interface SessionConfig<T extends ToolMap, M = unknown> {
406
+ interface SessionConfig<T extends ToolMap, M = unknown, TContent = string> {
494
407
  /** The name of the agent, should be unique within the workflows */
495
408
  agentName: string;
496
409
  /** Metadata for the session */
@@ -502,7 +415,7 @@ interface SessionConfig<T extends ToolMap, M = unknown> {
502
415
  /** Workflow-specific runAgent activity (with tools pre-bound) */
503
416
  runAgent: RunAgentActivity<M>;
504
417
  /** Thread operations (initialize, append messages, parse tool calls) */
505
- threadOps: ActivityInterfaceFor<ThreadOps>;
418
+ threadOps: ActivityInterfaceFor<ThreadOps<TContent>>;
506
419
  /** Tool router for processing tool calls (optional if agent has no tools) */
507
420
  tools?: T;
508
421
  /** Subagent configurations */
@@ -510,14 +423,14 @@ interface SessionConfig<T extends ToolMap, M = unknown> {
510
423
  /** Skills available to this agent (metadata + instructions, loaded before session creation) */
511
424
  skills?: Skill[];
512
425
  /** Session lifecycle hooks */
513
- hooks?: Hooks<T, ToolCallResultUnion<InferToolResults<T>>>;
426
+ hooks?: Hooks<T, ToolCallResultUnion<InferToolResults<T>>, TContent>;
514
427
  /** Whether to process tools in parallel */
515
428
  processToolsInParallel?: boolean;
516
429
  /**
517
430
  * Build context message content from agent-specific context.
518
- * Returns MessageContent array for the initial HumanMessage.
431
+ * Returns SDK-native content for the initial human message.
519
432
  */
520
- buildContextMessage: () => MessageContent | Promise<MessageContent>;
433
+ buildContextMessage: () => TContent | Promise<TContent>;
521
434
  /** How long to wait for input before cancelling the workflow */
522
435
  waitForInputTimeout?: Duration;
523
436
  /**
@@ -529,6 +442,14 @@ interface SessionConfig<T extends ToolMap, M = unknown> {
529
442
  * - `{ mode: "fork", threadId: "..." }` — fork an existing thread and continue in the copy.
530
443
  */
531
444
  thread?: ThreadInit;
445
+ /**
446
+ * Redis key suffix for thread storage. Defaults to `"messages"`.
447
+ *
448
+ * Controls the Redis key layout: `thread:${threadId}:${threadKey}`.
449
+ * Use different keys to isolate storage across sessions sharing the
450
+ * same adapter instance.
451
+ */
452
+ threadKey?: string;
532
453
  /** Sandbox lifecycle operations (optional — omit for agents that don't need a sandbox) */
533
454
  sandboxOps?: SandboxOps;
534
455
  /**
@@ -566,4 +487,4 @@ interface ZeitlichSession<M = unknown, HasSandbox extends boolean = boolean> {
566
487
  }): Promise<SessionResult<M, T, HasSandbox>>;
567
488
  }
568
489
 
569
- export type { AgentResponse as A, SubagentSandboxShutdown as B, SubagentSessionInput as C, SubagentWorkflow as D, SubagentWorkflowInput as E, ThreadInit as F, Hooks as H, JsonPrimitive as J, ModelInvoker as M, PrefixedThreadOps as P, RunAgentActivity as R, ScopedPrefix as S, ThreadOps as T, ZeitlichSession as Z, ModelInvokerConfig as a, SkillProvider as b, SkillMetadata as c, Skill as d, AgentState as e, AgentStateManager as f, JsonSerializable as g, JsonValue as h, PostHumanMessageAppendHook as i, PostHumanMessageAppendHookContext as j, PreHumanMessageAppendHook as k, PreHumanMessageAppendHookContext as l, SandboxInit as m, SandboxShutdown as n, SessionConfig as o, SessionEndHook as p, SessionEndHookContext as q, SessionResult as r, SessionStartHook as s, SessionStartHookContext as t, SubagentConfig as u, SubagentDefinition as v, SubagentFnResult as w, SubagentHandlerResponse as x, SubagentHooks as y, SubagentSandboxConfig as z };
490
+ export type { AgentResponse as A, ThreadInit as B, Hooks as H, ModelInvokerConfig as M, PrefixedThreadOps as P, RunAgentActivity as R, ScopedPrefix as S, ThreadOps as T, ZeitlichSession as Z, ModelInvoker as a, SkillProvider as b, SkillMetadata as c, Skill as d, PostHumanMessageAppendHook as e, PostHumanMessageAppendHookContext as f, PreHumanMessageAppendHook as g, PreHumanMessageAppendHookContext as h, SandboxInit as i, SandboxShutdown as j, SessionConfig as k, SessionEndHook as l, SessionEndHookContext as m, SessionResult as n, SessionStartHook as o, SessionStartHookContext as p, SubagentConfig as q, SubagentDefinition as r, SubagentFnResult as s, SubagentHandlerResponse as t, SubagentHooks as u, SubagentSandboxConfig as v, SubagentSandboxShutdown as w, SubagentSessionInput as x, SubagentWorkflow as y, SubagentWorkflowInput as z };
@@ -1,4 +1,5 @@
1
1
  import Redis from 'ioredis';
2
+ import { J as JsonValue } from './types-mCVxKIZb.js';
2
3
 
3
4
  interface ThreadManagerConfig<T> {
4
5
  redis: Redis;
@@ -36,5 +37,25 @@ interface BaseThreadManager<T> {
36
37
  /** Delete the thread */
37
38
  delete(): Promise<void>;
38
39
  }
40
+ /**
41
+ * Shared contract for provider-specific thread managers.
42
+ *
43
+ * Extends {@link BaseThreadManager} with the append operations that the
44
+ * session layer calls via {@link ThreadOps} activities. Each adapter
45
+ * implements this interface to translate generic append calls into
46
+ * SDK-native stored messages.
47
+ *
48
+ * `appendAssistantMessage` / `appendModelContent` are intentionally NOT
49
+ * part of this interface — they are adapter-specific and only called by
50
+ * the model invoker inside the adapter.
51
+ *
52
+ * @typeParam TStored - The stored message envelope (includes id + SDK payload)
53
+ * @typeParam TContent - SDK-native content type for human messages
54
+ */
55
+ interface ProviderThreadManager<TStored, TContent = string, TToolContent = JsonValue> extends BaseThreadManager<TStored> {
56
+ appendUserMessage(id: string, content: TContent): Promise<void>;
57
+ appendSystemMessage(id: string, content: string): Promise<void>;
58
+ appendToolResult(id: string, toolCallId: string, toolName: string, content: TToolContent): Promise<void>;
59
+ }
39
60
 
40
- export type { BaseThreadManager as B, ThreadManagerConfig as T };
61
+ export type { BaseThreadManager as B, ProviderThreadManager as P, ThreadManagerConfig as T };