zeitlich 0.2.4 → 0.2.6
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 +70 -40
- package/dist/index.cjs +71 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +72 -37
- package/dist/index.js.map +1 -1
- package/dist/{workflow-PjeURKw4.d.cts → workflow-Dg5JMeOC.d.cts} +18 -4
- package/dist/{workflow-PjeURKw4.d.ts → workflow-Dg5JMeOC.d.ts} +18 -4
- package/dist/workflow.cjs +52 -35
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +1 -1
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.js +52 -35
- package/dist/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/activities.ts +11 -0
- package/src/index.ts +4 -4
- package/src/lib/model-invoker.ts +5 -4
- package/src/lib/session.ts +17 -4
- package/src/lib/thread-manager.ts +15 -3
- package/src/lib/tool-router.ts +40 -31
- package/src/lib/types.ts +10 -2
- package/src/tools/subagent/handler.ts +4 -5
- package/src/tools/subagent/tool.ts +3 -3
- package/src/workflow.ts +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionArgs, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-
|
|
2
|
-
export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as BaseAgentState, j as BaseThreadManager, k as FileReadArgs, l as FileWriteArgs, m as GrepArgs, I as InferToolResults, J as JsonPrimitive, n as JsonSerializable, o as JsonValue, P as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, s as PostToolUseFailureHookResult, t as PostToolUseHook, u as PostToolUseHookContext, v as PreToolUseHook, w as PreToolUseHookContext, x as PreToolUseHookResult, y as ProcessToolCallsContext, R as RawToolCall, z as RunAgentActivity, C as RunAgentConfig, S as SessionEndHook, D as SessionEndHookContext, E as SessionExitReason, H as SessionLifecycleHooks, K as SessionStartHook, L as SessionStartHookContext, M as SubagentArgs, N as SubagentConfig, O as SubagentHooks, Q as SubagentInput, T as TaskCreateArgs, U as TaskGetArgs, V as TaskListArgs, W as TaskStatus, X as TaskUpdateArgs, Y as ThreadManager, Z as ThreadManagerConfig, _ as ThreadOps, $ as ToolArgs, a0 as ToolCallResult, a1 as ToolCallResultUnion, a2 as ToolDefinition, a3 as ToolHandler, a4 as ToolHandlerContext, a5 as ToolHandlerResponse, a6 as ToolHooks, a7 as ToolMap, a8 as ToolMessageContent, a9 as ToolNames, aa as ToolResult, ab as ToolResultConfig, ac as ToolRouter, ad as ToolWithHandler, ae as WorkflowTask, af as ZeitlichAgentConfig, ag as ZeitlichSession, ah as ZeitlichSharedActivities, ai as askUserQuestionTool, aj as bashTool, ak as createAgentStateManager, al as createBashToolDescription, am as createSession, an as createSharedActivities, ao as createSubagentTool, ap as createTaskCreateHandler, aq as createTaskGetHandler, ar as createTaskListHandler, as as createTaskUpdateHandler, at as createThreadManager, au as createToolRouter, av as defineSubagent, aw as defineTool, ax as editTool, ay as getStateQuery, az as globTool, aA as grepTool, aB as hasNoOtherToolCalls, aC as isTerminalStatus, aD as proxyDefaultThreadOps, aE as readTool, aF as taskCreateTool, aG as taskGetTool, aH as taskListTool, aI as taskUpdateTool, aJ as withAutoAppend, aK as writeTool } from './workflow-
|
|
1
|
+
import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionArgs, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-Dg5JMeOC.cjs';
|
|
2
|
+
export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as BaseAgentState, j as BaseThreadManager, k as FileReadArgs, l as FileWriteArgs, m as GrepArgs, I as InferToolResults, J as JsonPrimitive, n as JsonSerializable, o as JsonValue, P as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, s as PostToolUseFailureHookResult, t as PostToolUseHook, u as PostToolUseHookContext, v as PreToolUseHook, w as PreToolUseHookContext, x as PreToolUseHookResult, y as ProcessToolCallsContext, R as RawToolCall, z as RunAgentActivity, C as RunAgentConfig, S as SessionEndHook, D as SessionEndHookContext, E as SessionExitReason, H as SessionLifecycleHooks, K as SessionStartHook, L as SessionStartHookContext, M as SubagentArgs, N as SubagentConfig, O as SubagentHooks, Q as SubagentInput, T as TaskCreateArgs, U as TaskGetArgs, V as TaskListArgs, W as TaskStatus, X as TaskUpdateArgs, Y as ThreadManager, Z as ThreadManagerConfig, _ as ThreadOps, $ as ToolArgs, a0 as ToolCallResult, a1 as ToolCallResultUnion, a2 as ToolDefinition, a3 as ToolHandler, a4 as ToolHandlerContext, a5 as ToolHandlerResponse, a6 as ToolHooks, a7 as ToolMap, a8 as ToolMessageContent, a9 as ToolNames, aa as ToolResult, ab as ToolResultConfig, ac as ToolRouter, ad as ToolWithHandler, ae as WorkflowTask, af as ZeitlichAgentConfig, ag as ZeitlichSession, ah as ZeitlichSharedActivities, ai as askUserQuestionTool, aj as bashTool, ak as createAgentStateManager, al as createBashToolDescription, am as createSession, an as createSharedActivities, ao as createSubagentTool, ap as createTaskCreateHandler, aq as createTaskGetHandler, ar as createTaskListHandler, as as createTaskUpdateHandler, at as createThreadManager, au as createToolRouter, av as defineSubagent, aw as defineTool, ax as editTool, ay as getStateQuery, az as globTool, aA as grepTool, aB as hasNoOtherToolCalls, aC as isTerminalStatus, aD as proxyDefaultThreadOps, aE as readTool, aF as taskCreateTool, aG as taskGetTool, aH as taskListTool, aI as taskUpdateTool, aJ as withAutoAppend, aK as writeTool } from './workflow-Dg5JMeOC.cjs';
|
|
3
3
|
import { SimplePlugin } from '@temporalio/plugin';
|
|
4
4
|
import Redis from 'ioredis';
|
|
5
5
|
import { WorkflowClient } from '@temporalio/client';
|
|
@@ -39,10 +39,11 @@ interface InvokeModelConfig {
|
|
|
39
39
|
/**
|
|
40
40
|
* Core model invocation logic - shared utility for workflow-specific activities
|
|
41
41
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
42
|
+
* @param options - Named options object
|
|
43
|
+
* @param options.redis - Redis client for thread management
|
|
44
|
+
* @param options.config - Model invocation configuration (threadId, agentName)
|
|
45
|
+
* @param options.model - Pre-instantiated LangChain chat model
|
|
46
|
+
* @param options.client - Temporal WorkflowClient for querying workflow state
|
|
46
47
|
* @returns Agent response with message and metadata
|
|
47
48
|
*/
|
|
48
49
|
declare function invokeModel({ redis, model, client, config: { threadId, agentName }, }: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionArgs, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-
|
|
2
|
-
export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as BaseAgentState, j as BaseThreadManager, k as FileReadArgs, l as FileWriteArgs, m as GrepArgs, I as InferToolResults, J as JsonPrimitive, n as JsonSerializable, o as JsonValue, P as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, s as PostToolUseFailureHookResult, t as PostToolUseHook, u as PostToolUseHookContext, v as PreToolUseHook, w as PreToolUseHookContext, x as PreToolUseHookResult, y as ProcessToolCallsContext, R as RawToolCall, z as RunAgentActivity, C as RunAgentConfig, S as SessionEndHook, D as SessionEndHookContext, E as SessionExitReason, H as SessionLifecycleHooks, K as SessionStartHook, L as SessionStartHookContext, M as SubagentArgs, N as SubagentConfig, O as SubagentHooks, Q as SubagentInput, T as TaskCreateArgs, U as TaskGetArgs, V as TaskListArgs, W as TaskStatus, X as TaskUpdateArgs, Y as ThreadManager, Z as ThreadManagerConfig, _ as ThreadOps, $ as ToolArgs, a0 as ToolCallResult, a1 as ToolCallResultUnion, a2 as ToolDefinition, a3 as ToolHandler, a4 as ToolHandlerContext, a5 as ToolHandlerResponse, a6 as ToolHooks, a7 as ToolMap, a8 as ToolMessageContent, a9 as ToolNames, aa as ToolResult, ab as ToolResultConfig, ac as ToolRouter, ad as ToolWithHandler, ae as WorkflowTask, af as ZeitlichAgentConfig, ag as ZeitlichSession, ah as ZeitlichSharedActivities, ai as askUserQuestionTool, aj as bashTool, ak as createAgentStateManager, al as createBashToolDescription, am as createSession, an as createSharedActivities, ao as createSubagentTool, ap as createTaskCreateHandler, aq as createTaskGetHandler, ar as createTaskListHandler, as as createTaskUpdateHandler, at as createThreadManager, au as createToolRouter, av as defineSubagent, aw as defineTool, ax as editTool, ay as getStateQuery, az as globTool, aA as grepTool, aB as hasNoOtherToolCalls, aC as isTerminalStatus, aD as proxyDefaultThreadOps, aE as readTool, aF as taskCreateTool, aG as taskGetTool, aH as taskListTool, aI as taskUpdateTool, aJ as withAutoAppend, aK as writeTool } from './workflow-
|
|
1
|
+
import { A as AgentResponse, a as ActivityToolHandler, b as AskUserQuestionArgs, G as GlobArgs, F as FileEditArgs, B as BashArgs } from './workflow-Dg5JMeOC.js';
|
|
2
|
+
export { c as AGENT_HANDLER_NAMES, d as AgentFile, e as AgentState, f as AgentStateManager, g as AgentStatus, h as AppendToolResultFn, i as BaseAgentState, j as BaseThreadManager, k as FileReadArgs, l as FileWriteArgs, m as GrepArgs, I as InferToolResults, J as JsonPrimitive, n as JsonSerializable, o as JsonValue, P as ParsedToolCall, p as ParsedToolCallUnion, q as PostToolUseFailureHook, r as PostToolUseFailureHookContext, s as PostToolUseFailureHookResult, t as PostToolUseHook, u as PostToolUseHookContext, v as PreToolUseHook, w as PreToolUseHookContext, x as PreToolUseHookResult, y as ProcessToolCallsContext, R as RawToolCall, z as RunAgentActivity, C as RunAgentConfig, S as SessionEndHook, D as SessionEndHookContext, E as SessionExitReason, H as SessionLifecycleHooks, K as SessionStartHook, L as SessionStartHookContext, M as SubagentArgs, N as SubagentConfig, O as SubagentHooks, Q as SubagentInput, T as TaskCreateArgs, U as TaskGetArgs, V as TaskListArgs, W as TaskStatus, X as TaskUpdateArgs, Y as ThreadManager, Z as ThreadManagerConfig, _ as ThreadOps, $ as ToolArgs, a0 as ToolCallResult, a1 as ToolCallResultUnion, a2 as ToolDefinition, a3 as ToolHandler, a4 as ToolHandlerContext, a5 as ToolHandlerResponse, a6 as ToolHooks, a7 as ToolMap, a8 as ToolMessageContent, a9 as ToolNames, aa as ToolResult, ab as ToolResultConfig, ac as ToolRouter, ad as ToolWithHandler, ae as WorkflowTask, af as ZeitlichAgentConfig, ag as ZeitlichSession, ah as ZeitlichSharedActivities, ai as askUserQuestionTool, aj as bashTool, ak as createAgentStateManager, al as createBashToolDescription, am as createSession, an as createSharedActivities, ao as createSubagentTool, ap as createTaskCreateHandler, aq as createTaskGetHandler, ar as createTaskListHandler, as as createTaskUpdateHandler, at as createThreadManager, au as createToolRouter, av as defineSubagent, aw as defineTool, ax as editTool, ay as getStateQuery, az as globTool, aA as grepTool, aB as hasNoOtherToolCalls, aC as isTerminalStatus, aD as proxyDefaultThreadOps, aE as readTool, aF as taskCreateTool, aG as taskGetTool, aH as taskListTool, aI as taskUpdateTool, aJ as withAutoAppend, aK as writeTool } from './workflow-Dg5JMeOC.js';
|
|
3
3
|
import { SimplePlugin } from '@temporalio/plugin';
|
|
4
4
|
import Redis from 'ioredis';
|
|
5
5
|
import { WorkflowClient } from '@temporalio/client';
|
|
@@ -39,10 +39,11 @@ interface InvokeModelConfig {
|
|
|
39
39
|
/**
|
|
40
40
|
* Core model invocation logic - shared utility for workflow-specific activities
|
|
41
41
|
*
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
42
|
+
* @param options - Named options object
|
|
43
|
+
* @param options.redis - Redis client for thread management
|
|
44
|
+
* @param options.config - Model invocation configuration (threadId, agentName)
|
|
45
|
+
* @param options.model - Pre-instantiated LangChain chat model
|
|
46
|
+
* @param options.client - Temporal WorkflowClient for querying workflow state
|
|
46
47
|
* @returns Agent response with message and metadata
|
|
47
48
|
*/
|
|
48
49
|
declare function invokeModel({ redis, model, client, config: { threadId, agentName }, }: {
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineQuery, proxyActivities, setHandler, uuid4, workflowInfo, executeChild } from '@temporalio/workflow';
|
|
2
2
|
import z3, { z } from 'zod';
|
|
3
3
|
import { SimplePlugin } from '@temporalio/plugin';
|
|
4
|
-
import { mapStoredMessagesToChatMessages, AIMessage, ToolMessage, HumanMessage } from '@langchain/core/messages';
|
|
4
|
+
import { mapStoredMessagesToChatMessages, AIMessage, ToolMessage, SystemMessage, HumanMessage } from '@langchain/core/messages';
|
|
5
5
|
import crypto from 'crypto';
|
|
6
6
|
import { Context } from '@temporalio/activity';
|
|
7
7
|
import { Bash } from 'just-bash';
|
|
@@ -9,7 +9,7 @@ import { Bash } from 'just-bash';
|
|
|
9
9
|
// src/lib/session.ts
|
|
10
10
|
var SUBAGENT_TOOL = "Subagent";
|
|
11
11
|
function buildSubagentDescription(subagents) {
|
|
12
|
-
const subagentList = subagents.map((s) => `- **${s.
|
|
12
|
+
const subagentList = subagents.map((s) => `- **${s.agentName}**: ${s.description}`).join("\n");
|
|
13
13
|
return `Launch a new agent to handle complex tasks autonomously.
|
|
14
14
|
|
|
15
15
|
The ${SUBAGENT_TOOL} tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
|
|
@@ -35,7 +35,7 @@ function createSubagentTool(subagents) {
|
|
|
35
35
|
if (subagents.length === 0) {
|
|
36
36
|
throw new Error("createTaskTool requires at least one subagent");
|
|
37
37
|
}
|
|
38
|
-
const names = subagents.map((s) => s.
|
|
38
|
+
const names = subagents.map((s) => s.agentName);
|
|
39
39
|
return {
|
|
40
40
|
name: SUBAGENT_TOOL,
|
|
41
41
|
description: buildSubagentDescription(subagents),
|
|
@@ -47,15 +47,15 @@ function createSubagentTool(subagents) {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
function createSubagentHandler(subagents) {
|
|
50
|
-
const {
|
|
50
|
+
const { taskQueue: parentTaskQueue } = workflowInfo();
|
|
51
51
|
return async (args) => {
|
|
52
|
-
const config = subagents.find((s) => s.
|
|
52
|
+
const config = subagents.find((s) => s.agentName === args.subagent);
|
|
53
53
|
if (!config) {
|
|
54
54
|
throw new Error(
|
|
55
|
-
`Unknown subagent: ${args.subagent}. Available: ${subagents.map((s) => s.
|
|
55
|
+
`Unknown subagent: ${args.subagent}. Available: ${subagents.map((s) => s.agentName).join(", ")}`
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
const childWorkflowId = `${
|
|
58
|
+
const childWorkflowId = `${args.subagent}-${uuid4()}`;
|
|
59
59
|
const input = {
|
|
60
60
|
prompt: args.prompt,
|
|
61
61
|
...config.context && { context: config.context }
|
|
@@ -83,31 +83,36 @@ function createToolRouter(options) {
|
|
|
83
83
|
}
|
|
84
84
|
const isEnabled = (tool) => tool.enabled !== false;
|
|
85
85
|
if (options.subagents) {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
86
|
+
const enabledSubagents = options.subagents.filter(
|
|
87
|
+
(s) => s.enabled !== false
|
|
88
|
+
);
|
|
89
|
+
if (enabledSubagents.length > 0) {
|
|
90
|
+
const subagentHooksMap = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const s of enabledSubagents) {
|
|
92
|
+
if (s.hooks) subagentHooksMap.set(s.agentName, s.hooks);
|
|
93
|
+
}
|
|
94
|
+
const resolveSubagentName = (args) => args.subagent;
|
|
95
|
+
toolMap.set("Subagent", {
|
|
96
|
+
...createSubagentTool(enabledSubagents),
|
|
97
|
+
handler: createSubagentHandler(enabledSubagents),
|
|
98
|
+
...subagentHooksMap.size > 0 && {
|
|
99
|
+
hooks: {
|
|
100
|
+
onPreToolUse: async (ctx) => {
|
|
101
|
+
const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
|
|
102
|
+
return hooks?.onPreExecution?.(ctx) ?? {};
|
|
103
|
+
},
|
|
104
|
+
onPostToolUse: async (ctx) => {
|
|
105
|
+
const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
|
|
106
|
+
await hooks?.onPostExecution?.(ctx);
|
|
107
|
+
},
|
|
108
|
+
onPostToolUseFailure: async (ctx) => {
|
|
109
|
+
const hooks = subagentHooksMap.get(resolveSubagentName(ctx.args));
|
|
110
|
+
return hooks?.onExecutionFailure?.(ctx) ?? {};
|
|
111
|
+
}
|
|
107
112
|
}
|
|
108
113
|
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
111
116
|
}
|
|
112
117
|
async function processToolCall(toolCall, turn, handlerContext) {
|
|
113
118
|
const startTime = Date.now();
|
|
@@ -378,7 +383,11 @@ function withAutoAppend(threadHandler, handler) {
|
|
|
378
383
|
toolName,
|
|
379
384
|
content: response.toolResponse
|
|
380
385
|
});
|
|
381
|
-
return {
|
|
386
|
+
return {
|
|
387
|
+
toolResponse: "Response appended via withAutoAppend",
|
|
388
|
+
data: response.data,
|
|
389
|
+
resultAppended: true
|
|
390
|
+
};
|
|
382
391
|
};
|
|
383
392
|
}
|
|
384
393
|
function defineTool(tool) {
|
|
@@ -403,11 +412,19 @@ var createSession = async ({
|
|
|
403
412
|
subagents,
|
|
404
413
|
tools = {},
|
|
405
414
|
processToolsInParallel = true,
|
|
406
|
-
hooks = {}
|
|
415
|
+
hooks = {},
|
|
416
|
+
appendSystemPrompt = true,
|
|
417
|
+
systemPrompt
|
|
407
418
|
}) => {
|
|
419
|
+
const {
|
|
420
|
+
appendToolResult,
|
|
421
|
+
appendHumanMessage,
|
|
422
|
+
initializeThread,
|
|
423
|
+
appendSystemMessage
|
|
424
|
+
} = threadOps ?? proxyDefaultThreadOps();
|
|
408
425
|
const toolRouter = createToolRouter({
|
|
409
426
|
tools,
|
|
410
|
-
appendToolResult
|
|
427
|
+
appendToolResult,
|
|
411
428
|
threadId,
|
|
412
429
|
hooks,
|
|
413
430
|
subagents,
|
|
@@ -434,8 +451,11 @@ var createSession = async ({
|
|
|
434
451
|
});
|
|
435
452
|
}
|
|
436
453
|
stateManager.setTools(toolRouter.getToolDefinitions());
|
|
437
|
-
await
|
|
438
|
-
|
|
454
|
+
await initializeThread(threadId);
|
|
455
|
+
if (appendSystemPrompt && systemPrompt && systemPrompt.trim() !== "") {
|
|
456
|
+
await appendSystemMessage(threadId, systemPrompt);
|
|
457
|
+
}
|
|
458
|
+
await appendHumanMessage(threadId, await buildContextMessage());
|
|
439
459
|
let exitReason = "completed";
|
|
440
460
|
try {
|
|
441
461
|
while (stateManager.isRunning() && !stateManager.isTerminal() && stateManager.getTurns() < maxTurns) {
|
|
@@ -456,7 +476,7 @@ var createSession = async ({
|
|
|
456
476
|
try {
|
|
457
477
|
parsedToolCalls.push(toolRouter.parseToolCall(tc));
|
|
458
478
|
} catch (error) {
|
|
459
|
-
await
|
|
479
|
+
await appendToolResult({
|
|
460
480
|
threadId,
|
|
461
481
|
toolCallId: tc.id ?? "",
|
|
462
482
|
toolName: tc.name,
|
|
@@ -503,7 +523,8 @@ function proxyDefaultThreadOps(options) {
|
|
|
503
523
|
return {
|
|
504
524
|
initializeThread: activities.initializeThread,
|
|
505
525
|
appendHumanMessage: activities.appendHumanMessage,
|
|
506
|
-
appendToolResult: activities.appendToolResult
|
|
526
|
+
appendToolResult: activities.appendToolResult,
|
|
527
|
+
appendSystemMessage: activities.appendSystemMessage
|
|
507
528
|
};
|
|
508
529
|
}
|
|
509
530
|
|
|
@@ -1050,6 +1071,12 @@ function createThreadManager(config) {
|
|
|
1050
1071
|
content
|
|
1051
1072
|
}).toDict();
|
|
1052
1073
|
},
|
|
1074
|
+
createSystemMessage(content) {
|
|
1075
|
+
return new SystemMessage({
|
|
1076
|
+
id: v4_default(),
|
|
1077
|
+
content
|
|
1078
|
+
}).toDict();
|
|
1079
|
+
},
|
|
1053
1080
|
createAIMessage(content, kwargs) {
|
|
1054
1081
|
return new AIMessage({
|
|
1055
1082
|
id: v4_default(),
|
|
@@ -1078,6 +1105,10 @@ function createThreadManager(config) {
|
|
|
1078
1105
|
async appendAIMessage(content) {
|
|
1079
1106
|
const message = helpers.createAIMessage(content);
|
|
1080
1107
|
await base.append([message]);
|
|
1108
|
+
},
|
|
1109
|
+
async appendSystemMessage(content) {
|
|
1110
|
+
const message = helpers.createSystemMessage(content);
|
|
1111
|
+
await base.append([message]);
|
|
1081
1112
|
}
|
|
1082
1113
|
};
|
|
1083
1114
|
return Object.assign(base, helpers);
|
|
@@ -1102,6 +1133,10 @@ function createSharedActivities(redis) {
|
|
|
1102
1133
|
async appendHumanMessage(threadId, content) {
|
|
1103
1134
|
const thread = createThreadManager({ redis, threadId });
|
|
1104
1135
|
await thread.appendHumanMessage(content);
|
|
1136
|
+
},
|
|
1137
|
+
async appendSystemMessage(threadId, content) {
|
|
1138
|
+
const thread = createThreadManager({ redis, threadId });
|
|
1139
|
+
await thread.appendSystemMessage(content);
|
|
1105
1140
|
}
|
|
1106
1141
|
};
|
|
1107
1142
|
}
|