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.
- package/dist/activities-BEJRyDVU.d.cts +137 -0
- package/dist/activities-LVQdLF6I.d.ts +137 -0
- package/dist/adapters/sandbox/virtual/index.cjs.map +1 -1
- package/dist/adapters/sandbox/virtual/index.d.cts +8 -7
- package/dist/adapters/sandbox/virtual/index.d.ts +8 -7
- package/dist/adapters/sandbox/virtual/index.js.map +1 -1
- package/dist/adapters/sandbox/virtual/workflow.d.cts +3 -2
- package/dist/adapters/sandbox/virtual/workflow.d.ts +3 -2
- package/dist/adapters/thread/anthropic/index.cjs +356 -0
- package/dist/adapters/thread/anthropic/index.cjs.map +1 -0
- package/dist/adapters/thread/anthropic/index.d.cts +148 -0
- package/dist/adapters/thread/anthropic/index.d.ts +148 -0
- package/dist/adapters/thread/anthropic/index.js +351 -0
- package/dist/adapters/thread/anthropic/index.js.map +1 -0
- package/dist/adapters/thread/anthropic/workflow.cjs +38 -0
- package/dist/adapters/thread/anthropic/workflow.cjs.map +1 -0
- package/dist/adapters/thread/anthropic/workflow.d.cts +37 -0
- package/dist/adapters/thread/anthropic/workflow.d.ts +37 -0
- package/dist/adapters/thread/anthropic/workflow.js +36 -0
- package/dist/adapters/thread/anthropic/workflow.js.map +1 -0
- package/dist/adapters/thread/google-genai/index.cjs +95 -97
- package/dist/adapters/thread/google-genai/index.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/index.d.cts +9 -111
- package/dist/adapters/thread/google-genai/index.d.ts +9 -111
- package/dist/adapters/thread/google-genai/index.js +96 -97
- package/dist/adapters/thread/google-genai/index.js.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.cjs +9 -4
- package/dist/adapters/thread/google-genai/workflow.cjs.map +1 -1
- package/dist/adapters/thread/google-genai/workflow.d.cts +10 -5
- package/dist/adapters/thread/google-genai/workflow.d.ts +10 -5
- package/dist/adapters/thread/google-genai/workflow.js +9 -4
- package/dist/adapters/thread/google-genai/workflow.js.map +1 -1
- package/dist/adapters/thread/langchain/index.cjs +43 -60
- package/dist/adapters/thread/langchain/index.cjs.map +1 -1
- package/dist/adapters/thread/langchain/index.d.cts +24 -38
- package/dist/adapters/thread/langchain/index.d.ts +24 -38
- package/dist/adapters/thread/langchain/index.js +43 -60
- package/dist/adapters/thread/langchain/index.js.map +1 -1
- package/dist/adapters/thread/langchain/workflow.cjs +9 -4
- package/dist/adapters/thread/langchain/workflow.cjs.map +1 -1
- package/dist/adapters/thread/langchain/workflow.d.cts +10 -5
- package/dist/adapters/thread/langchain/workflow.d.ts +10 -5
- package/dist/adapters/thread/langchain/workflow.js +9 -4
- package/dist/adapters/thread/langchain/workflow.js.map +1 -1
- package/dist/index.cjs +27 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +28 -11
- package/dist/index.js.map +1 -1
- package/dist/proxy-BK1ydQt0.d.ts +24 -0
- package/dist/proxy-BMAsMHdp.d.cts +24 -0
- package/dist/{queries-DwBe2CAA.d.ts → queries-BCgJ9Sr5.d.ts} +1 -1
- package/dist/{queries-BYGBImeC.d.cts → queries-DwnE2bu3.d.cts} +1 -1
- package/dist/thread-manager-CH9krS3h.d.ts +37 -0
- package/dist/thread-manager-Czhpxbt6.d.ts +29 -0
- package/dist/thread-manager-DOnQzImf.d.cts +29 -0
- package/dist/thread-manager-b4DML-qu.d.cts +37 -0
- package/dist/{types-35POpVfa.d.ts → types-BDRDbm3h.d.cts} +22 -1
- package/dist/{types-hmferhc2.d.ts → types-CvJyXDYt.d.ts} +44 -123
- package/dist/{types-LVKmCNds.d.ts → types-DFUNSYbj.d.ts} +1 -1
- package/dist/{types-Bf8KV0Ci.d.cts → types-DRnz-OZp.d.cts} +1 -1
- package/dist/{types-7PeMi1bD.d.cts → types-DSOefLpY.d.cts} +44 -123
- package/dist/{types-35POpVfa.d.cts → types-WNSeZbWa.d.ts} +22 -1
- package/dist/{types-D_igp10o.d.cts → types-mCVxKIZb.d.cts} +233 -137
- package/dist/{types-D_igp10o.d.ts → types-mCVxKIZb.d.ts} +233 -137
- package/dist/workflow.cjs +25 -9
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +11 -11
- package/dist/workflow.d.ts +11 -11
- package/dist/workflow.js +26 -10
- package/dist/workflow.js.map +1 -1
- package/package.json +26 -1
- package/src/adapters/sandbox/virtual/with-virtual-sandbox.ts +8 -3
- package/src/adapters/thread/anthropic/activities.ts +223 -0
- package/src/adapters/thread/anthropic/index.ts +44 -0
- package/src/adapters/thread/anthropic/model-invoker.ts +124 -0
- package/src/adapters/thread/anthropic/proxy.ts +33 -0
- package/src/adapters/thread/anthropic/thread-manager.ts +191 -0
- package/src/adapters/thread/google-genai/activities.ts +107 -32
- package/src/adapters/thread/google-genai/index.ts +3 -1
- package/src/adapters/thread/google-genai/model-invoker.ts +7 -40
- package/src/adapters/thread/google-genai/proxy.ts +6 -34
- package/src/adapters/thread/google-genai/thread-manager.ts +84 -104
- package/src/adapters/thread/langchain/activities.ts +53 -20
- package/src/adapters/thread/langchain/index.ts +3 -1
- package/src/adapters/thread/langchain/model-invoker.ts +7 -9
- package/src/adapters/thread/langchain/proxy.ts +6 -34
- package/src/adapters/thread/langchain/thread-manager.ts +44 -98
- package/src/index.ts +5 -1
- package/src/lib/activity.ts +4 -3
- package/src/lib/hooks/types.ts +12 -12
- package/src/lib/model/types.ts +2 -0
- package/src/lib/session/session-edge-cases.integration.test.ts +24 -6
- package/src/lib/session/session.ts +18 -14
- package/src/lib/session/types.ts +31 -14
- package/src/lib/subagent/handler.ts +15 -8
- package/src/lib/subagent/types.ts +3 -2
- package/src/lib/thread/index.ts +2 -0
- package/src/lib/thread/manager.ts +4 -7
- package/src/lib/thread/proxy.ts +57 -0
- package/src/lib/thread/types.ts +31 -0
- package/src/lib/tool-router/auto-append-sandbox.integration.test.ts +54 -0
- package/src/lib/tool-router/auto-append.ts +5 -2
- package/src/lib/tool-router/router-edge-cases.integration.test.ts +9 -5
- package/src/lib/tool-router/router.ts +13 -7
- package/src/lib/tool-router/types.ts +20 -13
- package/src/lib/tool-router/with-sandbox.ts +4 -3
- package/src/lib/types.ts +7 -14
- package/src/workflow.ts +0 -4
- 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,
|
|
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 {
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
431
|
+
* Returns SDK-native content for the initial human message.
|
|
519
432
|
*/
|
|
520
|
-
buildContextMessage: () =>
|
|
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,
|
|
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 };
|