zeitlich 0.2.2 → 0.2.3
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/README.md +34 -31
- package/dist/index.cjs +305 -361
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -43
- package/dist/index.d.ts +24 -43
- package/dist/index.js +277 -336
- package/dist/index.js.map +1 -1
- package/dist/{workflow-BQf5EfNN.d.cts → workflow-D-2vp4Pq.d.cts} +265 -241
- package/dist/{workflow-BQf5EfNN.d.ts → workflow-D-2vp4Pq.d.ts} +265 -241
- package/dist/workflow.cjs +206 -253
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +2 -3
- package/dist/workflow.d.ts +2 -3
- package/dist/workflow.js +182 -231
- package/dist/workflow.js.map +1 -1
- package/package.json +3 -2
- package/src/activities.ts +1 -14
- package/src/index.ts +14 -11
- package/src/lib/session.ts +56 -99
- package/src/lib/thread-manager.ts +45 -37
- package/src/lib/tool-router.ts +143 -103
- package/src/lib/types.ts +32 -25
- package/src/tools/ask-user-question/handler.ts +5 -5
- package/src/tools/ask-user-question/tool.ts +3 -2
- package/src/tools/bash/bash.test.ts +12 -12
- package/src/tools/bash/handler.ts +5 -5
- package/src/tools/bash/tool.ts +3 -2
- package/src/tools/edit/handler.ts +78 -123
- package/src/tools/edit/tool.ts +3 -2
- package/src/tools/glob/handler.ts +17 -48
- package/src/tools/glob/tool.ts +3 -2
- package/src/tools/grep/tool.ts +3 -2
- package/src/tools/{read → read-file}/tool.ts +3 -2
- package/src/tools/task/handler.ts +2 -2
- package/src/tools/task/tool.ts +2 -9
- package/src/tools/task-create/handler.ts +5 -11
- package/src/tools/task-create/tool.ts +3 -2
- package/src/tools/task-get/handler.ts +5 -10
- package/src/tools/task-get/tool.ts +3 -2
- package/src/tools/task-list/handler.ts +5 -10
- package/src/tools/task-list/tool.ts +3 -2
- package/src/tools/task-update/handler.ts +5 -12
- package/src/tools/task-update/tool.ts +3 -2
- package/src/tools/{write → write-file}/tool.ts +5 -6
- package/src/workflow.ts +23 -19
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @example
|
|
10
10
|
* ```typescript
|
|
11
11
|
* // In your activities file
|
|
12
|
-
* import { invokeModel,
|
|
12
|
+
* import { invokeModel, createGlobHandler } from '@bead-ai/zeitlich';
|
|
13
13
|
*
|
|
14
14
|
* // In your worker file
|
|
15
15
|
* import { ZeitlichPlugin } from '@bead-ai/zeitlich';
|
|
@@ -28,25 +28,28 @@ export type { ZeitlichPluginOptions } from "./plugin";
|
|
|
28
28
|
export { createSharedActivities } from "./activities";
|
|
29
29
|
export type { ZeitlichSharedActivities } from "./activities";
|
|
30
30
|
|
|
31
|
+
// Auto-append wrapper for large tool results (activity-side only)
|
|
32
|
+
export { withAutoAppend } from "./lib/tool-router";
|
|
33
|
+
|
|
31
34
|
// Model invocation (requires Redis, LangChain)
|
|
32
35
|
export { invokeModel } from "./lib/model-invoker";
|
|
33
36
|
export type { InvokeModelConfig } from "./lib/model-invoker";
|
|
34
37
|
|
|
35
38
|
// Tool handlers (activity implementations)
|
|
36
|
-
//
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
+
// All handlers follow the factory pattern: createXHandler(deps) => handler(args)
|
|
40
|
+
export { createAskUserQuestionHandler } from "./tools/ask-user-question/handler";
|
|
41
|
+
export { createGlobHandler } from "./tools/glob/handler";
|
|
39
42
|
|
|
40
|
-
export {
|
|
41
|
-
export type {
|
|
42
|
-
EditResult,
|
|
43
|
-
EditHandlerResponse,
|
|
44
|
-
EditHandlerOptions,
|
|
45
|
-
} from "./tools/edit/handler";
|
|
43
|
+
export { createEditHandler } from "./tools/edit/handler";
|
|
46
44
|
|
|
47
|
-
export {
|
|
45
|
+
export { createBashHandler } from "./tools/bash/handler";
|
|
48
46
|
|
|
49
47
|
export { toTree } from "./lib/fs";
|
|
50
48
|
|
|
51
49
|
export { getStateQuery } from "./lib/state-manager";
|
|
52
50
|
export { createThreadManager } from "./lib/thread-manager";
|
|
51
|
+
export type {
|
|
52
|
+
BaseThreadManager,
|
|
53
|
+
ThreadManager,
|
|
54
|
+
ThreadManagerConfig,
|
|
55
|
+
} from "./lib/thread-manager";
|
package/src/lib/session.ts
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
import { proxyActivities } from "@temporalio/workflow";
|
|
2
2
|
import type { ZeitlichSharedActivities } from "../activities";
|
|
3
3
|
import type {
|
|
4
|
+
ThreadOps,
|
|
4
5
|
ZeitlichAgentConfig,
|
|
5
6
|
SessionStartHook,
|
|
6
7
|
SessionEndHook,
|
|
7
8
|
SessionExitReason,
|
|
8
|
-
SubagentConfig,
|
|
9
9
|
} from "./types";
|
|
10
|
+
import type { StoredMessage } from "@langchain/core/messages";
|
|
10
11
|
import { type AgentStateManager, type JsonSerializable } from "./state-manager";
|
|
11
12
|
import {
|
|
12
13
|
createToolRouter,
|
|
13
|
-
type ParsedToolCall,
|
|
14
14
|
type ParsedToolCallUnion,
|
|
15
15
|
type RawToolCall,
|
|
16
16
|
type ToolMap,
|
|
17
17
|
} from "./tool-router";
|
|
18
|
-
import type { StoredMessage } from "@langchain/core/messages";
|
|
19
|
-
import { createTaskTool, type TaskToolSchemaType } from "../tools/task/tool";
|
|
20
18
|
|
|
21
|
-
export interface ZeitlichSession {
|
|
19
|
+
export interface ZeitlichSession<M = unknown> {
|
|
22
20
|
runSession<T extends JsonSerializable<T>>(args: {
|
|
23
21
|
stateManager: AgentStateManager<T>;
|
|
24
|
-
}): Promise<
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function resolvePrompt(
|
|
28
|
-
prompt: string | (() => string | Promise<string>)
|
|
29
|
-
): Promise<string> {
|
|
30
|
-
if (typeof prompt === "function") {
|
|
31
|
-
return prompt();
|
|
32
|
-
}
|
|
33
|
-
return prompt;
|
|
22
|
+
}): Promise<M | null>;
|
|
34
23
|
}
|
|
35
24
|
|
|
36
25
|
/**
|
|
@@ -43,48 +32,24 @@ export interface SessionLifecycleHooks {
|
|
|
43
32
|
onSessionEnd?: SessionEndHook;
|
|
44
33
|
}
|
|
45
34
|
|
|
46
|
-
export const createSession = async <T extends ToolMap>({
|
|
35
|
+
export const createSession = async <T extends ToolMap, M = unknown>({
|
|
47
36
|
threadId,
|
|
48
37
|
agentName,
|
|
49
38
|
maxTurns = 50,
|
|
50
39
|
metadata = {},
|
|
51
40
|
runAgent,
|
|
52
|
-
|
|
53
|
-
instructionsPrompt,
|
|
41
|
+
threadOps,
|
|
54
42
|
buildContextMessage,
|
|
55
|
-
buildFileTree = async (): Promise<string> => "",
|
|
56
43
|
subagents,
|
|
57
44
|
tools = {} as T,
|
|
58
45
|
processToolsInParallel = true,
|
|
59
|
-
buildInTools = {},
|
|
60
46
|
hooks = {},
|
|
61
|
-
}: ZeitlichAgentConfig<T>): Promise<ZeitlichSession
|
|
62
|
-
const {
|
|
63
|
-
initializeThread,
|
|
64
|
-
appendHumanMessage,
|
|
65
|
-
parseToolCalls,
|
|
66
|
-
appendToolResult,
|
|
67
|
-
appendSystemMessage,
|
|
68
|
-
} = proxyActivities<ZeitlichSharedActivities>({
|
|
69
|
-
startToCloseTimeout: "30m",
|
|
70
|
-
retry: {
|
|
71
|
-
maximumAttempts: 6,
|
|
72
|
-
initialInterval: "5s",
|
|
73
|
-
maximumInterval: "15m",
|
|
74
|
-
backoffCoefficient: 4,
|
|
75
|
-
},
|
|
76
|
-
heartbeatTimeout: "5m",
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const fileTree = await buildFileTree();
|
|
80
|
-
|
|
47
|
+
}: ZeitlichAgentConfig<T, M>): Promise<ZeitlichSession<M>> => {
|
|
81
48
|
const toolRouter = createToolRouter({
|
|
82
49
|
tools,
|
|
83
|
-
appendToolResult,
|
|
50
|
+
appendToolResult: threadOps.appendToolResult,
|
|
84
51
|
threadId,
|
|
85
52
|
hooks,
|
|
86
|
-
buildInTools,
|
|
87
|
-
fileTree,
|
|
88
53
|
subagents,
|
|
89
54
|
parallel: processToolsInParallel,
|
|
90
55
|
});
|
|
@@ -106,7 +71,7 @@ export const createSession = async <T extends ToolMap>({
|
|
|
106
71
|
};
|
|
107
72
|
|
|
108
73
|
return {
|
|
109
|
-
runSession: async ({ stateManager }): Promise<
|
|
74
|
+
runSession: async ({ stateManager }): Promise<M | null> => {
|
|
110
75
|
if (hooks.onSessionStart) {
|
|
111
76
|
await hooks.onSessionStart({
|
|
112
77
|
threadId,
|
|
@@ -116,15 +81,8 @@ export const createSession = async <T extends ToolMap>({
|
|
|
116
81
|
}
|
|
117
82
|
stateManager.setTools(toolRouter.getToolDefinitions());
|
|
118
83
|
|
|
119
|
-
await initializeThread(threadId);
|
|
120
|
-
await
|
|
121
|
-
threadId,
|
|
122
|
-
[
|
|
123
|
-
await resolvePrompt(baseSystemPrompt),
|
|
124
|
-
await resolvePrompt(instructionsPrompt),
|
|
125
|
-
].join("\n")
|
|
126
|
-
);
|
|
127
|
-
await appendHumanMessage(threadId, await buildContextMessage());
|
|
84
|
+
await threadOps.initializeThread(threadId);
|
|
85
|
+
await threadOps.appendHumanMessage(threadId, await buildContextMessage());
|
|
128
86
|
|
|
129
87
|
let exitReason: SessionExitReason = "completed";
|
|
130
88
|
|
|
@@ -156,19 +114,19 @@ export const createSession = async <T extends ToolMap>({
|
|
|
156
114
|
return message;
|
|
157
115
|
}
|
|
158
116
|
|
|
159
|
-
const rawToolCalls: RawToolCall[] =
|
|
117
|
+
const rawToolCalls: RawToolCall[] =
|
|
118
|
+
await threadOps.parseToolCalls(message);
|
|
160
119
|
|
|
161
|
-
// Parse tool calls
|
|
120
|
+
// Parse all tool calls uniformly through the router
|
|
162
121
|
const parsedToolCalls: ParsedToolCallUnion<T>[] = [];
|
|
163
|
-
for (const tc of rawToolCalls
|
|
164
|
-
(tc: RawToolCall) => tc.name !== "Task"
|
|
165
|
-
)) {
|
|
122
|
+
for (const tc of rawToolCalls) {
|
|
166
123
|
try {
|
|
167
124
|
parsedToolCalls.push(toolRouter.parseToolCall(tc));
|
|
168
125
|
} catch (error) {
|
|
169
|
-
await appendToolResult({
|
|
126
|
+
await threadOps.appendToolResult({
|
|
170
127
|
threadId,
|
|
171
128
|
toolCallId: tc.id ?? "",
|
|
129
|
+
toolName: tc.name,
|
|
172
130
|
content: JSON.stringify({
|
|
173
131
|
error: `Invalid tool call for "${tc.name}": ${error instanceof Error ? error.message : String(error)}`,
|
|
174
132
|
}),
|
|
@@ -176,47 +134,10 @@ export const createSession = async <T extends ToolMap>({
|
|
|
176
134
|
}
|
|
177
135
|
}
|
|
178
136
|
|
|
179
|
-
const taskToolCalls: ParsedToolCall<
|
|
180
|
-
"Task",
|
|
181
|
-
TaskToolSchemaType<SubagentConfig[]>
|
|
182
|
-
>[] = [];
|
|
183
|
-
if (subagents && subagents.length > 0) {
|
|
184
|
-
for (const tc of rawToolCalls.filter(
|
|
185
|
-
(tc: RawToolCall) => tc.name === "Task"
|
|
186
|
-
)) {
|
|
187
|
-
try {
|
|
188
|
-
const parsedArgs = createTaskTool(subagents).schema.parse(
|
|
189
|
-
tc.args
|
|
190
|
-
);
|
|
191
|
-
taskToolCalls.push({
|
|
192
|
-
id: tc.id ?? "",
|
|
193
|
-
name: tc.name,
|
|
194
|
-
args: parsedArgs,
|
|
195
|
-
} as ParsedToolCall<
|
|
196
|
-
"Task",
|
|
197
|
-
TaskToolSchemaType<SubagentConfig[]>
|
|
198
|
-
>);
|
|
199
|
-
} catch (error) {
|
|
200
|
-
await appendToolResult({
|
|
201
|
-
threadId,
|
|
202
|
-
toolCallId: tc.id ?? "",
|
|
203
|
-
content: JSON.stringify({
|
|
204
|
-
error: `Invalid tool call for "Task": ${error instanceof Error ? error.message : String(error)}`,
|
|
205
|
-
}),
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
137
|
// Hooks can call stateManager.waitForInput() to pause the session
|
|
212
|
-
await toolRouter.processToolCalls(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
>[],
|
|
216
|
-
{
|
|
217
|
-
turn: currentTurn,
|
|
218
|
-
}
|
|
219
|
-
);
|
|
138
|
+
await toolRouter.processToolCalls(parsedToolCalls, {
|
|
139
|
+
turn: currentTurn,
|
|
140
|
+
});
|
|
220
141
|
|
|
221
142
|
if (stateManager.getStatus() === "WAITING_FOR_INPUT") {
|
|
222
143
|
exitReason = "waiting_for_input";
|
|
@@ -240,3 +161,39 @@ export const createSession = async <T extends ToolMap>({
|
|
|
240
161
|
},
|
|
241
162
|
};
|
|
242
163
|
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Proxy the default ZeitlichSharedActivities as ThreadOps<StoredMessage>.
|
|
167
|
+
* Call this in workflow code for the standard LangChain/StoredMessage setup.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const session = await createSession({
|
|
172
|
+
* threadOps: proxyDefaultThreadOps(),
|
|
173
|
+
* // ...
|
|
174
|
+
* });
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
export function proxyDefaultThreadOps(
|
|
178
|
+
options?: Parameters<typeof proxyActivities>[0]
|
|
179
|
+
): ThreadOps<StoredMessage> {
|
|
180
|
+
const activities = proxyActivities<ZeitlichSharedActivities>(
|
|
181
|
+
options ?? {
|
|
182
|
+
startToCloseTimeout: "30m",
|
|
183
|
+
retry: {
|
|
184
|
+
maximumAttempts: 6,
|
|
185
|
+
initialInterval: "5s",
|
|
186
|
+
maximumInterval: "15m",
|
|
187
|
+
backoffCoefficient: 4,
|
|
188
|
+
},
|
|
189
|
+
heartbeatTimeout: "5m",
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
return {
|
|
194
|
+
initializeThread: activities.initializeThread,
|
|
195
|
+
appendHumanMessage: activities.appendHumanMessage,
|
|
196
|
+
appendToolResult: activities.appendToolResult,
|
|
197
|
+
parseToolCalls: activities.parseToolCalls,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
type MessageContent,
|
|
8
8
|
type MessageStructure,
|
|
9
9
|
type StoredMessage,
|
|
10
|
-
SystemMessage,
|
|
11
10
|
ToolMessage,
|
|
12
11
|
} from "@langchain/core/messages";
|
|
13
12
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -24,28 +23,31 @@ function getThreadKey(threadId: string, key: string): string {
|
|
|
24
23
|
*/
|
|
25
24
|
export type ToolMessageContent = $InferMessageContent<MessageStructure, "tool">;
|
|
26
25
|
|
|
27
|
-
export interface ThreadManagerConfig {
|
|
26
|
+
export interface ThreadManagerConfig<T = StoredMessage> {
|
|
28
27
|
redis: Redis;
|
|
29
28
|
threadId: string;
|
|
30
29
|
/** Thread key, defaults to 'messages' */
|
|
31
30
|
key?: string;
|
|
31
|
+
/** Custom serializer, defaults to JSON.stringify */
|
|
32
|
+
serialize?: (message: T) => string;
|
|
33
|
+
/** Custom deserializer, defaults to JSON.parse */
|
|
34
|
+
deserialize?: (raw: string) => T;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
appendSystemMessage(content: string): Promise<void>;
|
|
37
|
+
/** Generic thread manager for any message type */
|
|
38
|
+
export interface BaseThreadManager<T> {
|
|
37
39
|
/** Initialize an empty thread */
|
|
38
40
|
initialize(): Promise<void>;
|
|
39
41
|
/** Load all messages from the thread */
|
|
40
|
-
load(): Promise<
|
|
42
|
+
load(): Promise<T[]>;
|
|
41
43
|
/** Append messages to the thread */
|
|
42
|
-
append(messages:
|
|
44
|
+
append(messages: T[]): Promise<void>;
|
|
43
45
|
/** Delete the thread */
|
|
44
46
|
delete(): Promise<void>;
|
|
47
|
+
}
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
/** Thread manager with StoredMessage convenience helpers */
|
|
50
|
+
export interface ThreadManager extends BaseThreadManager<StoredMessage> {
|
|
49
51
|
/** Create a HumanMessage (returns StoredMessage for storage) */
|
|
50
52
|
createHumanMessage(content: string | MessageContent): StoredMessage;
|
|
51
53
|
|
|
@@ -74,26 +76,38 @@ export interface ThreadManager {
|
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Creates a thread manager for handling conversation state in Redis.
|
|
79
|
+
* Without generic args, returns a full ThreadManager with StoredMessage helpers.
|
|
80
|
+
* With a custom type T, returns a BaseThreadManager<T>.
|
|
77
81
|
*/
|
|
78
|
-
export function createThreadManager(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
export function createThreadManager(config: ThreadManagerConfig): ThreadManager;
|
|
83
|
+
export function createThreadManager<T>(
|
|
84
|
+
config: ThreadManagerConfig<T>
|
|
85
|
+
): BaseThreadManager<T>;
|
|
86
|
+
export function createThreadManager<T>(
|
|
87
|
+
config: ThreadManagerConfig<T>
|
|
88
|
+
): BaseThreadManager<T> {
|
|
89
|
+
const {
|
|
90
|
+
redis,
|
|
91
|
+
threadId,
|
|
92
|
+
key = "messages",
|
|
93
|
+
serialize = (m: T): string => JSON.stringify(m),
|
|
94
|
+
deserialize = (raw: string): T => JSON.parse(raw) as T,
|
|
95
|
+
} = config;
|
|
82
96
|
const redisKey = getThreadKey(threadId, key);
|
|
83
97
|
|
|
84
|
-
|
|
98
|
+
const base: BaseThreadManager<T> = {
|
|
85
99
|
async initialize(): Promise<void> {
|
|
86
100
|
await redis.del(redisKey);
|
|
87
101
|
},
|
|
88
102
|
|
|
89
|
-
async load(): Promise<
|
|
103
|
+
async load(): Promise<T[]> {
|
|
90
104
|
const data = await redis.lrange(redisKey, 0, -1);
|
|
91
|
-
return data.map(
|
|
105
|
+
return data.map(deserialize);
|
|
92
106
|
},
|
|
93
107
|
|
|
94
|
-
async append(messages:
|
|
108
|
+
async append(messages: T[]): Promise<void> {
|
|
95
109
|
if (messages.length > 0) {
|
|
96
|
-
await redis.rpush(redisKey, ...messages.map(
|
|
110
|
+
await redis.rpush(redisKey, ...messages.map(serialize));
|
|
97
111
|
await redis.expire(redisKey, THREAD_TTL_SECONDS);
|
|
98
112
|
}
|
|
99
113
|
},
|
|
@@ -101,7 +115,11 @@ export function createThreadManager(
|
|
|
101
115
|
async delete(): Promise<void> {
|
|
102
116
|
await redis.del(redisKey);
|
|
103
117
|
},
|
|
118
|
+
};
|
|
104
119
|
|
|
120
|
+
// If no custom serialize/deserialize were provided and T defaults to StoredMessage,
|
|
121
|
+
// the overload guarantees the caller gets ThreadManager with convenience helpers.
|
|
122
|
+
const helpers = {
|
|
105
123
|
createHumanMessage(content: string | MessageContent): StoredMessage {
|
|
106
124
|
return new HumanMessage({
|
|
107
125
|
id: uuidv4(),
|
|
@@ -131,39 +149,29 @@ export function createThreadManager(
|
|
|
131
149
|
toolCallId: string
|
|
132
150
|
): StoredMessage {
|
|
133
151
|
return new ToolMessage({
|
|
134
|
-
// Cast needed due to langchain type compatibility
|
|
135
152
|
content: content as MessageContent,
|
|
136
153
|
tool_call_id: toolCallId,
|
|
137
154
|
}).toDict();
|
|
138
155
|
},
|
|
139
156
|
|
|
140
|
-
createSystemMessage(content: string): StoredMessage {
|
|
141
|
-
return new SystemMessage({
|
|
142
|
-
content,
|
|
143
|
-
}).toDict();
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
async appendSystemMessage(content: string): Promise<void> {
|
|
147
|
-
const message = this.createSystemMessage(content);
|
|
148
|
-
await this.append([message]);
|
|
149
|
-
},
|
|
150
|
-
|
|
151
157
|
async appendHumanMessage(content: string | MessageContent): Promise<void> {
|
|
152
|
-
const message =
|
|
153
|
-
await
|
|
158
|
+
const message = helpers.createHumanMessage(content);
|
|
159
|
+
await (base as BaseThreadManager<StoredMessage>).append([message]);
|
|
154
160
|
},
|
|
155
161
|
|
|
156
162
|
async appendToolMessage(
|
|
157
163
|
content: ToolMessageContent,
|
|
158
164
|
toolCallId: string
|
|
159
165
|
): Promise<void> {
|
|
160
|
-
const message =
|
|
161
|
-
await
|
|
166
|
+
const message = helpers.createToolMessage(content, toolCallId);
|
|
167
|
+
await (base as BaseThreadManager<StoredMessage>).append([message]);
|
|
162
168
|
},
|
|
163
169
|
|
|
164
170
|
async appendAIMessage(content: string | MessageContent): Promise<void> {
|
|
165
|
-
const message =
|
|
166
|
-
await
|
|
171
|
+
const message = helpers.createAIMessage(content as string);
|
|
172
|
+
await (base as BaseThreadManager<StoredMessage>).append([message]);
|
|
167
173
|
},
|
|
168
174
|
};
|
|
175
|
+
|
|
176
|
+
return Object.assign(base, helpers);
|
|
169
177
|
}
|