@axiom-lattice/core 2.1.44 → 2.1.46
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/index.d.mts +62 -5
- package/dist/index.d.ts +62 -5
- package/dist/index.js +370 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +431 -191
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -648,11 +648,11 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
648
648
|
* @param key Lattice键名
|
|
649
649
|
* @param tool 已有的StructuredTool实例
|
|
650
650
|
*/
|
|
651
|
-
registerExistingTool(key,
|
|
651
|
+
registerExistingTool(key, tool51) {
|
|
652
652
|
const config = {
|
|
653
|
-
name:
|
|
654
|
-
description:
|
|
655
|
-
schema:
|
|
653
|
+
name: tool51.name,
|
|
654
|
+
description: tool51.description,
|
|
655
|
+
schema: tool51.schema,
|
|
656
656
|
// StructuredTool的schema已经是Zod兼容的
|
|
657
657
|
needUserApprove: false
|
|
658
658
|
// MCP工具默认不需要用户批准
|
|
@@ -660,7 +660,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
660
660
|
const toolLattice = {
|
|
661
661
|
key,
|
|
662
662
|
config,
|
|
663
|
-
client:
|
|
663
|
+
client: tool51
|
|
664
664
|
};
|
|
665
665
|
this.register(key, toolLattice);
|
|
666
666
|
}
|
|
@@ -686,7 +686,7 @@ var ToolLatticeManager = class _ToolLatticeManager extends BaseLatticeManager {
|
|
|
686
686
|
};
|
|
687
687
|
var toolLatticeManager = ToolLatticeManager.getInstance();
|
|
688
688
|
var registerToolLattice = (key, config, executor) => toolLatticeManager.registerLattice(key, config, executor);
|
|
689
|
-
var registerExistingTool = (key,
|
|
689
|
+
var registerExistingTool = (key, tool51) => toolLatticeManager.registerExistingTool(key, tool51);
|
|
690
690
|
var getToolLattice = (key) => toolLatticeManager.getToolLattice(key);
|
|
691
691
|
var getToolDefinition = (key) => toolLatticeManager.getToolDefinition(key);
|
|
692
692
|
var getToolClient = (key) => toolLatticeManager.getToolClient(key);
|
|
@@ -5017,7 +5017,7 @@ var InMemoryThreadStore = class {
|
|
|
5017
5017
|
/**
|
|
5018
5018
|
* Get all threads for a specific tenant and assistant
|
|
5019
5019
|
*/
|
|
5020
|
-
async getThreadsByAssistantId(tenantId, assistantId) {
|
|
5020
|
+
async getThreadsByAssistantId(tenantId, assistantId, metadataFilter) {
|
|
5021
5021
|
const tenantThreads = this.threads.get(tenantId);
|
|
5022
5022
|
if (!tenantThreads) {
|
|
5023
5023
|
return [];
|
|
@@ -5026,7 +5026,15 @@ var InMemoryThreadStore = class {
|
|
|
5026
5026
|
if (!assistantThreads) {
|
|
5027
5027
|
return [];
|
|
5028
5028
|
}
|
|
5029
|
-
|
|
5029
|
+
let threads = Array.from(assistantThreads.values());
|
|
5030
|
+
if (metadataFilter && Object.keys(metadataFilter).length > 0) {
|
|
5031
|
+
threads = threads.filter(
|
|
5032
|
+
(thread) => Object.entries(metadataFilter).every(
|
|
5033
|
+
([key, value]) => thread.metadata?.[key] === value
|
|
5034
|
+
)
|
|
5035
|
+
);
|
|
5036
|
+
}
|
|
5037
|
+
return threads;
|
|
5030
5038
|
}
|
|
5031
5039
|
/**
|
|
5032
5040
|
* Get a thread by ID for a specific tenant
|
|
@@ -6452,7 +6460,7 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6452
6460
|
return this.messages.get(threadId);
|
|
6453
6461
|
}
|
|
6454
6462
|
async addMessage(params) {
|
|
6455
|
-
const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command, id } = params;
|
|
6463
|
+
const { threadId, tenantId, assistantId, content, type = "human", priority = 0, command, custom_run_config, id } = params;
|
|
6456
6464
|
const threadMessages = this.getMessagesForThread(threadId);
|
|
6457
6465
|
const message = {
|
|
6458
6466
|
id: id || this.generateId(),
|
|
@@ -6464,18 +6472,20 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6464
6472
|
tenantId,
|
|
6465
6473
|
assistantId,
|
|
6466
6474
|
priority,
|
|
6467
|
-
command
|
|
6475
|
+
command,
|
|
6476
|
+
custom_run_config
|
|
6468
6477
|
};
|
|
6469
6478
|
threadMessages.push(message);
|
|
6470
6479
|
return message;
|
|
6471
6480
|
}
|
|
6472
|
-
async addMessageAtHead(
|
|
6481
|
+
async addMessageAtHead(params) {
|
|
6482
|
+
const { threadId, tenantId, assistantId, content, type = "system", id, command, custom_run_config } = params;
|
|
6473
6483
|
const threadMessages = this.getMessagesForThread(threadId);
|
|
6474
|
-
let
|
|
6475
|
-
let
|
|
6476
|
-
if (threadMessages.length > 0) {
|
|
6477
|
-
|
|
6478
|
-
|
|
6484
|
+
let resolvedTenantId = tenantId || "default";
|
|
6485
|
+
let resolvedAssistantId = assistantId || "";
|
|
6486
|
+
if (!tenantId && !assistantId && threadMessages.length > 0) {
|
|
6487
|
+
resolvedTenantId = threadMessages[0].tenantId || "default";
|
|
6488
|
+
resolvedAssistantId = threadMessages[0].assistantId || "";
|
|
6479
6489
|
}
|
|
6480
6490
|
const nextSequence = threadMessages.length;
|
|
6481
6491
|
const message = {
|
|
@@ -6485,11 +6495,12 @@ var InMemoryThreadMessageQueueStore = class {
|
|
|
6485
6495
|
sequence: nextSequence,
|
|
6486
6496
|
createdAt: /* @__PURE__ */ new Date(),
|
|
6487
6497
|
status: "pending",
|
|
6488
|
-
tenantId,
|
|
6489
|
-
assistantId,
|
|
6498
|
+
tenantId: resolvedTenantId,
|
|
6499
|
+
assistantId: resolvedAssistantId,
|
|
6490
6500
|
priority: 100,
|
|
6491
6501
|
// High priority for head messages (STEER/Command)
|
|
6492
|
-
command
|
|
6502
|
+
command,
|
|
6503
|
+
custom_run_config
|
|
6493
6504
|
};
|
|
6494
6505
|
threadMessages.push(message);
|
|
6495
6506
|
return message;
|
|
@@ -9228,7 +9239,7 @@ function createShowWidgetTool() {
|
|
|
9228
9239
|
},
|
|
9229
9240
|
{
|
|
9230
9241
|
name: "show_widget",
|
|
9231
|
-
description: "Render an interactive HTML widget or SVG diagram visible to the user. Use for: charts, dashboards, calculators, forms, diagrams, timers, games, visualizations. The widget appears in a panel next to the chat. Users can interact with it and send data back via window.
|
|
9242
|
+
description: "Render an interactive HTML widget or SVG diagram visible to the user. Use for: charts, dashboards, calculators, forms, diagrams, timers, games, visualizations. The widget appears in a panel next to the chat. Users can interact with it and send data back via window.sendPrompt(data). IMPORTANT: Always call load_guidelines before your first show_widget.",
|
|
9232
9243
|
schema: ShowWidgetInputSchema
|
|
9233
9244
|
}
|
|
9234
9245
|
);
|
|
@@ -9759,9 +9770,198 @@ ${bootstrapSections.join("\n\n")}
|
|
|
9759
9770
|
});
|
|
9760
9771
|
}
|
|
9761
9772
|
|
|
9773
|
+
// src/middlewares/unknownToolHandlerMiddleware.ts
|
|
9774
|
+
import { createMiddleware as createMiddleware11 } from "langchain";
|
|
9775
|
+
import { AIMessage as AIMessage2, ToolMessage as ToolMessage3 } from "@langchain/core/messages";
|
|
9776
|
+
function createUnknownToolHandlerMiddleware(config = {}) {
|
|
9777
|
+
const {
|
|
9778
|
+
strategy = "error",
|
|
9779
|
+
errorMessageTemplate = (name, tools) => `Error: Tool "${name}" does not exist.
|
|
9780
|
+
|
|
9781
|
+
Available tools:
|
|
9782
|
+
` + tools.map((t) => ` - ${t}`).join("\n") + `
|
|
9783
|
+
|
|
9784
|
+
Please select a valid tool from the list above.`
|
|
9785
|
+
} = config;
|
|
9786
|
+
return createMiddleware11({
|
|
9787
|
+
name: "UnknownToolHandlerMiddleware",
|
|
9788
|
+
/**
|
|
9789
|
+
* wrapModelCall hook
|
|
9790
|
+
*
|
|
9791
|
+
* The only place to access request.tools (all available tools).
|
|
9792
|
+
* Identifies unknown tools and stores error info in metadata.
|
|
9793
|
+
*
|
|
9794
|
+
* Key: Preserve all tool_calls in original AIMessage, including unknown ones.
|
|
9795
|
+
* This allows the model to see what it selected in the next round.
|
|
9796
|
+
*/
|
|
9797
|
+
wrapModelCall: async (request, handler) => {
|
|
9798
|
+
const availableTools = request.tools || [];
|
|
9799
|
+
const availableToolNames = availableTools.map((t) => t.name);
|
|
9800
|
+
const availableToolSet = new Set(availableToolNames);
|
|
9801
|
+
const aiResponse = await handler(request);
|
|
9802
|
+
if (!aiResponse.tool_calls || aiResponse.tool_calls.length === 0) {
|
|
9803
|
+
return aiResponse;
|
|
9804
|
+
}
|
|
9805
|
+
const unknownToolCalls = [];
|
|
9806
|
+
for (const toolCall of aiResponse.tool_calls) {
|
|
9807
|
+
if (!availableToolSet.has(toolCall.name)) {
|
|
9808
|
+
unknownToolCalls.push(toolCall);
|
|
9809
|
+
}
|
|
9810
|
+
}
|
|
9811
|
+
if (unknownToolCalls.length === 0) {
|
|
9812
|
+
return aiResponse;
|
|
9813
|
+
}
|
|
9814
|
+
if (strategy === "strict") {
|
|
9815
|
+
const unknownNames = unknownToolCalls.map((t) => t.name).join(", ");
|
|
9816
|
+
throw new Error(
|
|
9817
|
+
`Unknown tools detected: ${unknownNames}. Available tools: ${availableToolNames.join(", ")}`
|
|
9818
|
+
);
|
|
9819
|
+
}
|
|
9820
|
+
const unknownToolErrors = unknownToolCalls.map((toolCall) => ({
|
|
9821
|
+
toolName: toolCall.name,
|
|
9822
|
+
toolCallId: toolCall.id,
|
|
9823
|
+
errorMessage: errorMessageTemplate(toolCall.name, availableToolNames)
|
|
9824
|
+
}));
|
|
9825
|
+
const modifiedResponse = new AIMessage2({
|
|
9826
|
+
content: aiResponse.content,
|
|
9827
|
+
tool_calls: aiResponse.tool_calls,
|
|
9828
|
+
// Key: preserve all tool_calls, don't delete unknown
|
|
9829
|
+
response_metadata: {
|
|
9830
|
+
...aiResponse.response_metadata,
|
|
9831
|
+
_unknownToolErrors: unknownToolErrors
|
|
9832
|
+
}
|
|
9833
|
+
});
|
|
9834
|
+
if (aiResponse.id) {
|
|
9835
|
+
modifiedResponse.id = aiResponse.id;
|
|
9836
|
+
}
|
|
9837
|
+
return modifiedResponse;
|
|
9838
|
+
},
|
|
9839
|
+
/**
|
|
9840
|
+
* afterModel hook
|
|
9841
|
+
*
|
|
9842
|
+
* Processes unknown tool errors stored in metadata.
|
|
9843
|
+
* Generates error ToolMessages and jumps back to model.
|
|
9844
|
+
*
|
|
9845
|
+
* Key: Uses jumpTo: "model" to form agent loop.
|
|
9846
|
+
* Without jumpTo, the graph would end after ToolNode without returning to model.
|
|
9847
|
+
*/
|
|
9848
|
+
afterModel: {
|
|
9849
|
+
canJumpTo: ["model"],
|
|
9850
|
+
hook: async (state) => {
|
|
9851
|
+
const { messages } = state;
|
|
9852
|
+
if (!messages || messages.length === 0) {
|
|
9853
|
+
return;
|
|
9854
|
+
}
|
|
9855
|
+
const lastMessage = messages[messages.length - 1];
|
|
9856
|
+
if (!AIMessage2.isInstance(lastMessage)) {
|
|
9857
|
+
return;
|
|
9858
|
+
}
|
|
9859
|
+
const unknownToolErrors = lastMessage.response_metadata?._unknownToolErrors;
|
|
9860
|
+
if (!unknownToolErrors || !Array.isArray(unknownToolErrors) || unknownToolErrors.length === 0) {
|
|
9861
|
+
return;
|
|
9862
|
+
}
|
|
9863
|
+
const errorToolMessages = unknownToolErrors.map(
|
|
9864
|
+
(error) => new ToolMessage3({
|
|
9865
|
+
content: error.errorMessage,
|
|
9866
|
+
name: error.toolName,
|
|
9867
|
+
tool_call_id: error.toolCallId,
|
|
9868
|
+
status: "error"
|
|
9869
|
+
})
|
|
9870
|
+
);
|
|
9871
|
+
delete lastMessage.response_metadata._unknownToolErrors;
|
|
9872
|
+
return {
|
|
9873
|
+
messages: errorToolMessages,
|
|
9874
|
+
jumpTo: "model"
|
|
9875
|
+
};
|
|
9876
|
+
}
|
|
9877
|
+
}
|
|
9878
|
+
});
|
|
9879
|
+
}
|
|
9880
|
+
|
|
9881
|
+
// src/deep_agent_new/middleware/date.ts
|
|
9882
|
+
import { createMiddleware as createMiddleware12, tool as tool46 } from "langchain";
|
|
9883
|
+
import { z as z47 } from "zod";
|
|
9884
|
+
function formatCurrentDate(timezone = "UTC") {
|
|
9885
|
+
const now = /* @__PURE__ */ new Date();
|
|
9886
|
+
let validTimezone = timezone;
|
|
9887
|
+
try {
|
|
9888
|
+
Intl.DateTimeFormat(void 0, { timeZone: timezone });
|
|
9889
|
+
} catch {
|
|
9890
|
+
validTimezone = "UTC";
|
|
9891
|
+
}
|
|
9892
|
+
const dateFormatOptions = {
|
|
9893
|
+
timeZone: validTimezone,
|
|
9894
|
+
year: "numeric",
|
|
9895
|
+
month: "2-digit",
|
|
9896
|
+
day: "2-digit"
|
|
9897
|
+
};
|
|
9898
|
+
return new Intl.DateTimeFormat("en-US", dateFormatOptions).format(now);
|
|
9899
|
+
}
|
|
9900
|
+
function generateDateContext(timezone = "UTC") {
|
|
9901
|
+
const formattedDate = formatCurrentDate(timezone);
|
|
9902
|
+
if (timezone === "UTC") {
|
|
9903
|
+
return `Current Date: ${formattedDate}`;
|
|
9904
|
+
}
|
|
9905
|
+
const utcDate = formatCurrentDate("UTC");
|
|
9906
|
+
return `Current Date: ${formattedDate} (UTC: ${utcDate})`;
|
|
9907
|
+
}
|
|
9908
|
+
function createDateMiddleware(options = {}) {
|
|
9909
|
+
const timezone = options.timezone || "UTC";
|
|
9910
|
+
const dateContext = generateDateContext(timezone);
|
|
9911
|
+
return createMiddleware12({
|
|
9912
|
+
name: "DateMiddleware",
|
|
9913
|
+
tools: [
|
|
9914
|
+
tool46(
|
|
9915
|
+
async () => {
|
|
9916
|
+
const now = /* @__PURE__ */ new Date();
|
|
9917
|
+
let validTimezone = timezone;
|
|
9918
|
+
try {
|
|
9919
|
+
Intl.DateTimeFormat(void 0, { timeZone: timezone });
|
|
9920
|
+
} catch {
|
|
9921
|
+
validTimezone = "UTC";
|
|
9922
|
+
}
|
|
9923
|
+
const localTimeOptions = {
|
|
9924
|
+
timeZone: validTimezone,
|
|
9925
|
+
year: "numeric",
|
|
9926
|
+
month: "2-digit",
|
|
9927
|
+
day: "2-digit",
|
|
9928
|
+
hour: "2-digit",
|
|
9929
|
+
minute: "2-digit",
|
|
9930
|
+
second: "2-digit",
|
|
9931
|
+
hour12: false
|
|
9932
|
+
};
|
|
9933
|
+
const localTime = new Intl.DateTimeFormat("en-US", localTimeOptions).format(now);
|
|
9934
|
+
return JSON.stringify({
|
|
9935
|
+
local_time: `${localTime} (${validTimezone})`,
|
|
9936
|
+
iso_date: now.toISOString().split("T")[0],
|
|
9937
|
+
timestamp: now.toISOString(),
|
|
9938
|
+
timezone: validTimezone
|
|
9939
|
+
});
|
|
9940
|
+
},
|
|
9941
|
+
{
|
|
9942
|
+
name: "get_current_date_time",
|
|
9943
|
+
description: "Get the exact current date and time at the moment of invocation. Use this when the user asks about the current time (e.g., 'what time is it', '\u51E0\u70B9\u4E86', '\u73B0\u5728\u51E0\u70B9'), or when you need to know the precise time for scheduling, deadlines, or time-sensitive operations.",
|
|
9944
|
+
schema: z47.object({})
|
|
9945
|
+
}
|
|
9946
|
+
)
|
|
9947
|
+
],
|
|
9948
|
+
wrapModelCall: async (request, handler) => {
|
|
9949
|
+
const currentSystemPrompt = request.systemPrompt || "";
|
|
9950
|
+
const newSystemPrompt = currentSystemPrompt ? `${dateContext}
|
|
9951
|
+
|
|
9952
|
+
${currentSystemPrompt}` : dateContext;
|
|
9953
|
+
return handler({
|
|
9954
|
+
...request,
|
|
9955
|
+
systemPrompt: newSystemPrompt
|
|
9956
|
+
});
|
|
9957
|
+
}
|
|
9958
|
+
});
|
|
9959
|
+
}
|
|
9960
|
+
|
|
9762
9961
|
// src/agent_lattice/builders/commonMiddleware.ts
|
|
9763
9962
|
async function createCommonMiddlewares(middlewareConfigs, filesystemBackend) {
|
|
9764
9963
|
const middlewares = [];
|
|
9964
|
+
middlewares.push(createUnknownToolHandlerMiddleware());
|
|
9765
9965
|
middlewares.push(createModelSelectorMiddleware());
|
|
9766
9966
|
const filesystemConfig = middlewareConfigs.find((m) => m.type === "filesystem");
|
|
9767
9967
|
if (filesystemConfig?.enabled && filesystemBackend) {
|
|
@@ -9822,6 +10022,9 @@ async function createCommonMiddlewares(middlewareConfigs, filesystemBackend) {
|
|
|
9822
10022
|
}));
|
|
9823
10023
|
}
|
|
9824
10024
|
break;
|
|
10025
|
+
case "date":
|
|
10026
|
+
middlewares.push(createDateMiddleware(config.config));
|
|
10027
|
+
break;
|
|
9825
10028
|
}
|
|
9826
10029
|
}
|
|
9827
10030
|
return middlewares;
|
|
@@ -9875,9 +10078,9 @@ var ReActAgentGraphBuilder = class {
|
|
|
9875
10078
|
*/
|
|
9876
10079
|
async build(agentLattice, params) {
|
|
9877
10080
|
const tools = params.tools.map((t) => {
|
|
9878
|
-
const
|
|
9879
|
-
return
|
|
9880
|
-
}).filter((
|
|
10081
|
+
const tool51 = getToolClient(t.key);
|
|
10082
|
+
return tool51;
|
|
10083
|
+
}).filter((tool51) => tool51 !== void 0);
|
|
9881
10084
|
const stateSchema2 = createReactAgentSchema(params.stateSchema);
|
|
9882
10085
|
const middlewareConfigs = params.middleware || [];
|
|
9883
10086
|
const filesystemBackend = this.createFilesystemBackendFactory(middlewareConfigs, agentLattice);
|
|
@@ -9903,12 +10106,12 @@ import {
|
|
|
9903
10106
|
} from "langchain";
|
|
9904
10107
|
|
|
9905
10108
|
// src/deep_agent_new/middleware/subagents.ts
|
|
9906
|
-
import { z as
|
|
10109
|
+
import { z as z48 } from "zod/v3";
|
|
9907
10110
|
import {
|
|
9908
|
-
createMiddleware as
|
|
10111
|
+
createMiddleware as createMiddleware13,
|
|
9909
10112
|
createAgent as createAgent2,
|
|
9910
|
-
tool as
|
|
9911
|
-
ToolMessage as
|
|
10113
|
+
tool as tool47,
|
|
10114
|
+
ToolMessage as ToolMessage4,
|
|
9912
10115
|
humanInTheLoopMiddleware
|
|
9913
10116
|
} from "langchain";
|
|
9914
10117
|
import { Command as Command2, getCurrentTaskInput as getCurrentTaskInput2, GraphInterrupt as GraphInterrupt3 } from "@langchain/langgraph";
|
|
@@ -10479,7 +10682,7 @@ function returnCommandWithStateUpdate(result, toolCallId) {
|
|
|
10479
10682
|
update: {
|
|
10480
10683
|
...stateUpdate,
|
|
10481
10684
|
messages: [
|
|
10482
|
-
new
|
|
10685
|
+
new ToolMessage4({
|
|
10483
10686
|
content: lastMessage?.content || "Task Failed to complete",
|
|
10484
10687
|
tool_call_id: toolCallId,
|
|
10485
10688
|
name: "task"
|
|
@@ -10561,7 +10764,7 @@ function createTaskTool(options) {
|
|
|
10561
10764
|
generalPurposeAgent
|
|
10562
10765
|
});
|
|
10563
10766
|
const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
|
|
10564
|
-
return
|
|
10767
|
+
return tool47(
|
|
10565
10768
|
async (input, config) => {
|
|
10566
10769
|
const { description, subagent_type } = input;
|
|
10567
10770
|
let assistant_id = subagent_type;
|
|
@@ -10615,7 +10818,7 @@ function createTaskTool(options) {
|
|
|
10615
10818
|
return new Command2({
|
|
10616
10819
|
update: {
|
|
10617
10820
|
messages: [
|
|
10618
|
-
new
|
|
10821
|
+
new ToolMessage4({
|
|
10619
10822
|
content: error instanceof Error ? error.message : "Task Failed to complete",
|
|
10620
10823
|
tool_call_id: config.toolCall.id,
|
|
10621
10824
|
name: "task"
|
|
@@ -10628,9 +10831,9 @@ function createTaskTool(options) {
|
|
|
10628
10831
|
{
|
|
10629
10832
|
name: "task",
|
|
10630
10833
|
description: finalTaskDescription,
|
|
10631
|
-
schema:
|
|
10632
|
-
description:
|
|
10633
|
-
subagent_type:
|
|
10834
|
+
schema: z48.object({
|
|
10835
|
+
description: z48.string().describe("The task to execute with the selected agent"),
|
|
10836
|
+
subagent_type: z48.string().describe(
|
|
10634
10837
|
`Name of the agent to use. Available: ${Object.keys(
|
|
10635
10838
|
subagentGraphs
|
|
10636
10839
|
).join(", ")}`
|
|
@@ -10659,7 +10862,7 @@ function createSubAgentMiddleware(options) {
|
|
|
10659
10862
|
generalPurposeAgent,
|
|
10660
10863
|
taskDescription
|
|
10661
10864
|
});
|
|
10662
|
-
return
|
|
10865
|
+
return createMiddleware13({
|
|
10663
10866
|
name: "subAgentMiddleware",
|
|
10664
10867
|
tools: [taskTool],
|
|
10665
10868
|
wrapModelCall: async (request, handler) => {
|
|
@@ -10680,14 +10883,14 @@ ${systemPrompt}` : systemPrompt;
|
|
|
10680
10883
|
|
|
10681
10884
|
// src/deep_agent_new/middleware/patch_tool_calls.ts
|
|
10682
10885
|
import {
|
|
10683
|
-
createMiddleware as
|
|
10684
|
-
ToolMessage as
|
|
10685
|
-
AIMessage as
|
|
10886
|
+
createMiddleware as createMiddleware14,
|
|
10887
|
+
ToolMessage as ToolMessage5,
|
|
10888
|
+
AIMessage as AIMessage3
|
|
10686
10889
|
} from "langchain";
|
|
10687
10890
|
import { RemoveMessage } from "@langchain/core/messages";
|
|
10688
10891
|
import { REMOVE_ALL_MESSAGES } from "@langchain/langgraph";
|
|
10689
10892
|
function createPatchToolCallsMiddleware() {
|
|
10690
|
-
return
|
|
10893
|
+
return createMiddleware14({
|
|
10691
10894
|
name: "patchToolCallsMiddleware",
|
|
10692
10895
|
beforeAgent: async (state) => {
|
|
10693
10896
|
const messages = state.messages;
|
|
@@ -10698,15 +10901,15 @@ function createPatchToolCallsMiddleware() {
|
|
|
10698
10901
|
for (let i = 0; i < messages.length; i++) {
|
|
10699
10902
|
const msg = messages[i];
|
|
10700
10903
|
patchedMessages.push(msg);
|
|
10701
|
-
if (
|
|
10904
|
+
if (AIMessage3.isInstance(msg) && msg.tool_calls != null) {
|
|
10702
10905
|
for (const toolCall of msg.tool_calls) {
|
|
10703
10906
|
const correspondingToolMsg = messages.slice(i).find(
|
|
10704
|
-
(m) =>
|
|
10907
|
+
(m) => ToolMessage5.isInstance(m) && m.tool_call_id === toolCall.id
|
|
10705
10908
|
);
|
|
10706
10909
|
if (!correspondingToolMsg) {
|
|
10707
10910
|
const toolMsg = `Tool call ${toolCall.name} with id ${toolCall.id} was cancelled - another message came in before it could be completed.`;
|
|
10708
10911
|
patchedMessages.push(
|
|
10709
|
-
new
|
|
10912
|
+
new ToolMessage5({
|
|
10710
10913
|
content: toolMsg,
|
|
10711
10914
|
name: toolCall.name,
|
|
10712
10915
|
tool_call_id: toolCall.id
|
|
@@ -11823,8 +12026,8 @@ var MemoryBackend = class {
|
|
|
11823
12026
|
|
|
11824
12027
|
// src/deep_agent_new/middleware/todos.ts
|
|
11825
12028
|
import { Command as Command3 } from "@langchain/langgraph";
|
|
11826
|
-
import { z as
|
|
11827
|
-
import { createMiddleware as
|
|
12029
|
+
import { z as z49 } from "zod";
|
|
12030
|
+
import { createMiddleware as createMiddleware15, tool as tool48, ToolMessage as ToolMessage6 } from "langchain";
|
|
11828
12031
|
var WRITE_TODOS_DESCRIPTION = `Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
11829
12032
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
11830
12033
|
Only use this tool if you think it will be helpful in staying organized. If the user's request is trivial and takes less than 3 steps, it is better to NOT use this tool and just do the taks directly.
|
|
@@ -12051,20 +12254,20 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
|
|
|
12051
12254
|
## Important To-Do List Usage Notes to Remember
|
|
12052
12255
|
- The \`write_todos\` tool should never be called multiple times in parallel.
|
|
12053
12256
|
- Don't be afraid to revise the To-Do list as you go. New information may reveal new tasks that need to be done, or old tasks that are irrelevant.`;
|
|
12054
|
-
var TodoStatus =
|
|
12055
|
-
var TodoSchema =
|
|
12056
|
-
content:
|
|
12257
|
+
var TodoStatus = z49.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
|
|
12258
|
+
var TodoSchema = z49.object({
|
|
12259
|
+
content: z49.string().describe("Content of the todo item"),
|
|
12057
12260
|
status: TodoStatus
|
|
12058
12261
|
});
|
|
12059
|
-
var stateSchema =
|
|
12262
|
+
var stateSchema = z49.object({ todos: z49.array(TodoSchema).default([]) });
|
|
12060
12263
|
function todoListMiddleware(options) {
|
|
12061
|
-
const writeTodos =
|
|
12264
|
+
const writeTodos = tool48(
|
|
12062
12265
|
({ todos }, config) => {
|
|
12063
12266
|
return new Command3({
|
|
12064
12267
|
update: {
|
|
12065
12268
|
todos,
|
|
12066
12269
|
messages: [
|
|
12067
|
-
new
|
|
12270
|
+
new ToolMessage6({
|
|
12068
12271
|
content: genUIMarkdown("todo_list", todos),
|
|
12069
12272
|
tool_call_id: config.toolCall?.id
|
|
12070
12273
|
})
|
|
@@ -12075,12 +12278,12 @@ function todoListMiddleware(options) {
|
|
|
12075
12278
|
{
|
|
12076
12279
|
name: "write_todos",
|
|
12077
12280
|
description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
|
|
12078
|
-
schema:
|
|
12079
|
-
todos:
|
|
12281
|
+
schema: z49.object({
|
|
12282
|
+
todos: z49.array(TodoSchema).describe("List of todo items to update")
|
|
12080
12283
|
})
|
|
12081
12284
|
}
|
|
12082
12285
|
);
|
|
12083
|
-
return
|
|
12286
|
+
return createMiddleware15({
|
|
12084
12287
|
name: "todoListMiddleware",
|
|
12085
12288
|
stateSchema,
|
|
12086
12289
|
tools: [writeTodos],
|
|
@@ -12234,7 +12437,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
12234
12437
|
const tools = params.tools.map((t) => {
|
|
12235
12438
|
const toolClient = getToolClient(t.key);
|
|
12236
12439
|
return toolClient;
|
|
12237
|
-
}).filter((
|
|
12440
|
+
}).filter((tool51) => tool51 !== void 0);
|
|
12238
12441
|
const subagents = await Promise.all(params.subAgents.map(async (sa) => {
|
|
12239
12442
|
if (sa.client) {
|
|
12240
12443
|
return {
|
|
@@ -12274,7 +12477,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
12274
12477
|
};
|
|
12275
12478
|
|
|
12276
12479
|
// src/agent_team/agent_team.ts
|
|
12277
|
-
import { z as
|
|
12480
|
+
import { z as z52 } from "zod/v3";
|
|
12278
12481
|
import { createAgent as createAgent5 } from "langchain";
|
|
12279
12482
|
|
|
12280
12483
|
// src/agent_team/types.ts
|
|
@@ -12710,14 +12913,14 @@ var InMemoryMailboxStore = class {
|
|
|
12710
12913
|
};
|
|
12711
12914
|
|
|
12712
12915
|
// src/agent_team/middleware/team.ts
|
|
12713
|
-
import { z as
|
|
12714
|
-
import { createMiddleware as
|
|
12916
|
+
import { z as z51 } from "zod/v3";
|
|
12917
|
+
import { createMiddleware as createMiddleware16, createAgent as createAgent4, tool as tool50, ToolMessage as ToolMessage8 } from "langchain";
|
|
12715
12918
|
import { Command as Command5, getCurrentTaskInput as getCurrentTaskInput3 } from "@langchain/langgraph";
|
|
12716
12919
|
import { v4 as uuidv4 } from "uuid";
|
|
12717
12920
|
|
|
12718
12921
|
// src/agent_team/middleware/teammate_tools.ts
|
|
12719
|
-
import { z as
|
|
12720
|
-
import { tool as
|
|
12922
|
+
import { z as z50 } from "zod/v3";
|
|
12923
|
+
import { tool as tool49, ToolMessage as ToolMessage7 } from "langchain";
|
|
12721
12924
|
import { Command as Command4 } from "@langchain/langgraph";
|
|
12722
12925
|
|
|
12723
12926
|
// src/agent_team/middleware/formatMessages.ts
|
|
@@ -12742,7 +12945,7 @@ ${meta}${body}`;
|
|
|
12742
12945
|
// src/agent_team/middleware/teammate_tools.ts
|
|
12743
12946
|
function createTeammateTools(options) {
|
|
12744
12947
|
const { teamId, agentId, taskListStore, mailboxStore } = options;
|
|
12745
|
-
const claimTaskTool =
|
|
12948
|
+
const claimTaskTool = tool49(
|
|
12746
12949
|
async (input) => {
|
|
12747
12950
|
const task = await taskListStore.claimTaskById(
|
|
12748
12951
|
teamId,
|
|
@@ -12767,12 +12970,12 @@ function createTeammateTools(options) {
|
|
|
12767
12970
|
{
|
|
12768
12971
|
name: "claim_task",
|
|
12769
12972
|
description: "Pick a task to work on by task_id. Use check_tasks first to see all tasks; then call this with the task_id you choose. The task's assignee is set to you and you should focus on that task until you complete_task or fail_task it.",
|
|
12770
|
-
schema:
|
|
12771
|
-
task_id:
|
|
12973
|
+
schema: z50.object({
|
|
12974
|
+
task_id: z50.string().describe("ID of the task to claim (e.g. task-01). Use check_tasks to see IDs.")
|
|
12772
12975
|
})
|
|
12773
12976
|
}
|
|
12774
12977
|
);
|
|
12775
|
-
const completeTaskTool =
|
|
12978
|
+
const completeTaskTool = tool49(
|
|
12776
12979
|
async (input) => {
|
|
12777
12980
|
const task = await taskListStore.completeTask(
|
|
12778
12981
|
teamId,
|
|
@@ -12793,13 +12996,13 @@ function createTeammateTools(options) {
|
|
|
12793
12996
|
{
|
|
12794
12997
|
name: "complete_task",
|
|
12795
12998
|
description: "Mark a claimed task as completed with a result summary. Call this after you have finished working on a task.",
|
|
12796
|
-
schema:
|
|
12797
|
-
task_id:
|
|
12798
|
-
result:
|
|
12999
|
+
schema: z50.object({
|
|
13000
|
+
task_id: z50.string().describe("ID of the task to complete"),
|
|
13001
|
+
result: z50.string().describe("Summary of the task result")
|
|
12799
13002
|
})
|
|
12800
13003
|
}
|
|
12801
13004
|
);
|
|
12802
|
-
const failTaskTool =
|
|
13005
|
+
const failTaskTool = tool49(
|
|
12803
13006
|
async (input) => {
|
|
12804
13007
|
const task = await taskListStore.failTask(
|
|
12805
13008
|
teamId,
|
|
@@ -12820,13 +13023,13 @@ function createTeammateTools(options) {
|
|
|
12820
13023
|
{
|
|
12821
13024
|
name: "fail_task",
|
|
12822
13025
|
description: "Mark a claimed task as failed with an error description. Call this if you cannot complete the task.",
|
|
12823
|
-
schema:
|
|
12824
|
-
task_id:
|
|
12825
|
-
error:
|
|
13026
|
+
schema: z50.object({
|
|
13027
|
+
task_id: z50.string().describe("ID of the task to fail"),
|
|
13028
|
+
error: z50.string().describe("Description of why the task failed")
|
|
12826
13029
|
})
|
|
12827
13030
|
}
|
|
12828
13031
|
);
|
|
12829
|
-
const sendMessageTool =
|
|
13032
|
+
const sendMessageTool = tool49(
|
|
12830
13033
|
async (input) => {
|
|
12831
13034
|
await mailboxStore.sendMessage(
|
|
12832
13035
|
teamId,
|
|
@@ -12840,11 +13043,11 @@ function createTeammateTools(options) {
|
|
|
12840
13043
|
{
|
|
12841
13044
|
name: "send_message",
|
|
12842
13045
|
description: 'Send a message to the team lead or another teammate via the mailbox. Use "team_lead" to message the team lead. Use this to report discoveries, request guidance, or suggest new tasks.',
|
|
12843
|
-
schema:
|
|
12844
|
-
to:
|
|
13046
|
+
schema: z50.object({
|
|
13047
|
+
to: z50.string().describe(
|
|
12845
13048
|
'Recipient agent name (e.g. "team_lead" or a teammate name)'
|
|
12846
13049
|
),
|
|
12847
|
-
content:
|
|
13050
|
+
content: z50.string().describe("Message content")
|
|
12848
13051
|
})
|
|
12849
13052
|
}
|
|
12850
13053
|
);
|
|
@@ -12864,7 +13067,7 @@ function createTeammateTools(options) {
|
|
|
12864
13067
|
read: msg.read
|
|
12865
13068
|
}));
|
|
12866
13069
|
};
|
|
12867
|
-
const readMessagesTool =
|
|
13070
|
+
const readMessagesTool = tool49(
|
|
12868
13071
|
async (input, config) => {
|
|
12869
13072
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
12870
13073
|
for (const msg of msgs2) {
|
|
@@ -12876,7 +13079,7 @@ function createTeammateTools(options) {
|
|
|
12876
13079
|
if (msgs.length > 0) {
|
|
12877
13080
|
const formatted2 = await formatAndMarkAsRead(msgs);
|
|
12878
13081
|
const relevantMsgs2 = await getRelevantMessagesForState();
|
|
12879
|
-
const toolMessage2 = new
|
|
13082
|
+
const toolMessage2 = new ToolMessage7({
|
|
12880
13083
|
content: formatted2,
|
|
12881
13084
|
tool_call_id: config.toolCall?.id,
|
|
12882
13085
|
name: "read_messages"
|
|
@@ -12901,7 +13104,7 @@ function createTeammateTools(options) {
|
|
|
12901
13104
|
});
|
|
12902
13105
|
const relevantMsgs = await getRelevantMessagesForState();
|
|
12903
13106
|
if (msgs.length === 0) {
|
|
12904
|
-
const toolMessage2 = new
|
|
13107
|
+
const toolMessage2 = new ToolMessage7({
|
|
12905
13108
|
content: "No unread messages.",
|
|
12906
13109
|
tool_call_id: config.toolCall?.id,
|
|
12907
13110
|
name: "read_messages"
|
|
@@ -12911,7 +13114,7 @@ function createTeammateTools(options) {
|
|
|
12911
13114
|
});
|
|
12912
13115
|
}
|
|
12913
13116
|
const formatted = await formatAndMarkAsRead(msgs);
|
|
12914
|
-
const toolMessage = new
|
|
13117
|
+
const toolMessage = new ToolMessage7({
|
|
12915
13118
|
content: formatted,
|
|
12916
13119
|
tool_call_id: config.toolCall?.id,
|
|
12917
13120
|
name: "read_messages"
|
|
@@ -12923,10 +13126,10 @@ function createTeammateTools(options) {
|
|
|
12923
13126
|
{
|
|
12924
13127
|
name: "read_messages",
|
|
12925
13128
|
description: "Read unread messages from the mailbox. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
12926
|
-
schema:
|
|
13129
|
+
schema: z50.object({})
|
|
12927
13130
|
}
|
|
12928
13131
|
);
|
|
12929
|
-
const checkTasksTool =
|
|
13132
|
+
const checkTasksTool = tool49(
|
|
12930
13133
|
async () => {
|
|
12931
13134
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
12932
13135
|
return formatTaskSummary(tasks);
|
|
@@ -12934,10 +13137,10 @@ function createTeammateTools(options) {
|
|
|
12934
13137
|
{
|
|
12935
13138
|
name: "check_tasks",
|
|
12936
13139
|
description: "Use this tool to get the current status of all tasks in a team. This is your primary way to monitor task progress.",
|
|
12937
|
-
schema:
|
|
13140
|
+
schema: z50.object({})
|
|
12938
13141
|
}
|
|
12939
13142
|
);
|
|
12940
|
-
const broadcastMessageTool =
|
|
13143
|
+
const broadcastMessageTool = tool49(
|
|
12941
13144
|
async (input) => {
|
|
12942
13145
|
const allAgents = await mailboxStore.getRegisteredAgents(teamId);
|
|
12943
13146
|
const recipients = allAgents.filter((a) => a !== agentId);
|
|
@@ -12956,8 +13159,8 @@ function createTeammateTools(options) {
|
|
|
12956
13159
|
{
|
|
12957
13160
|
name: "broadcast_message",
|
|
12958
13161
|
description: "Send a message to everyone in the team except yourself. Use this to share updates or information with all teammates and the team lead at once.",
|
|
12959
|
-
schema:
|
|
12960
|
-
content:
|
|
13162
|
+
schema: z50.object({
|
|
13163
|
+
content: z50.string().describe("Message content to broadcast to others")
|
|
12961
13164
|
})
|
|
12962
13165
|
}
|
|
12963
13166
|
);
|
|
@@ -13191,12 +13394,12 @@ async function spawnTeammate(options) {
|
|
|
13191
13394
|
function createTeamMiddleware(options) {
|
|
13192
13395
|
const { teamConfig, taskListStore, mailboxStore, tenantId } = options;
|
|
13193
13396
|
const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
|
|
13194
|
-
const createTeamTool =
|
|
13397
|
+
const createTeamTool = tool50(
|
|
13195
13398
|
async (input, config) => {
|
|
13196
13399
|
const state = getCurrentTaskInput3();
|
|
13197
13400
|
if (state?.team?.teamId) {
|
|
13198
13401
|
const existingId = state.team.teamId;
|
|
13199
|
-
const msg = new
|
|
13402
|
+
const msg = new ToolMessage8({
|
|
13200
13403
|
content: `A team is already active (id: ${existingId}). Use this team_id for \`check_tasks\`, \`read_messages\`, \`add_tasks\`, \`send_message\`, \`assign_task\`, \`set_task_status\`, and \`set_task_dependencies\`. Do not call \`create_team\` again unless you need a fresh team for a new objective.`,
|
|
13201
13404
|
tool_call_id: config.toolCall?.id,
|
|
13202
13405
|
name: "create_team"
|
|
@@ -13285,7 +13488,7 @@ Teammates are now working in the background. Keep calling \`check_tasks\` and \`
|
|
|
13285
13488
|
\`\`\`json
|
|
13286
13489
|
${teamJson}
|
|
13287
13490
|
\`\`\``;
|
|
13288
|
-
const toolMessage = new
|
|
13491
|
+
const toolMessage = new ToolMessage8({
|
|
13289
13492
|
content: summary,
|
|
13290
13493
|
tool_call_id: config.toolCall?.id,
|
|
13291
13494
|
name: "create_team"
|
|
@@ -13346,20 +13549,20 @@ After calling create_team, you MUST:
|
|
|
13346
13549
|
2. When messages indicate task changes, call check_tasks to get full task status
|
|
13347
13550
|
3. Continue until all tasks show "completed" or "failed"
|
|
13348
13551
|
4. Do NOT assume tasks are done - always verify with check_tasks`,
|
|
13349
|
-
schema:
|
|
13350
|
-
tasks:
|
|
13351
|
-
|
|
13352
|
-
id:
|
|
13353
|
-
title:
|
|
13354
|
-
description:
|
|
13355
|
-
dependencies:
|
|
13552
|
+
schema: z51.object({
|
|
13553
|
+
tasks: z51.array(
|
|
13554
|
+
z51.object({
|
|
13555
|
+
id: z51.string().describe("Task ID in format task-01, task-02, etc."),
|
|
13556
|
+
title: z51.string().describe("Short task title"),
|
|
13557
|
+
description: z51.string().describe("Detailed task description - what exactly needs to be done"),
|
|
13558
|
+
dependencies: z51.array(z51.string()).optional().default([]).describe('Array of task IDs that must complete before this task (e.g. ["task-01"])')
|
|
13356
13559
|
})
|
|
13357
13560
|
).describe("List of tasks for teammates to work on. Each task needs unique ID (task-01, task-02, etc.)."),
|
|
13358
|
-
teammates:
|
|
13359
|
-
|
|
13360
|
-
name:
|
|
13361
|
-
role:
|
|
13362
|
-
description:
|
|
13561
|
+
teammates: z51.array(
|
|
13562
|
+
z51.object({
|
|
13563
|
+
name: z51.string().describe("Teammate name (must match a pre-configured teammate type)"),
|
|
13564
|
+
role: z51.string().describe("Role category (e.g. researcher, writer, coder, reviewer)"),
|
|
13565
|
+
description: z51.string().describe("What this teammate will focus on - specific instructions for their work")
|
|
13363
13566
|
})
|
|
13364
13567
|
).describe("Teammate agents to create. Each should have a clear role and focus.")
|
|
13365
13568
|
})
|
|
@@ -13370,7 +13573,7 @@ After calling create_team, you MUST:
|
|
|
13370
13573
|
if (state?.team?.teamId) return state.team.teamId;
|
|
13371
13574
|
throw new Error("No team_id provided and no team in state. Call create_team first.");
|
|
13372
13575
|
};
|
|
13373
|
-
const addTasksTool =
|
|
13576
|
+
const addTasksTool = tool50(
|
|
13374
13577
|
async (input, config) => {
|
|
13375
13578
|
const teamId = resolveTeamId();
|
|
13376
13579
|
const created = await taskListStore.addTasks(
|
|
@@ -13384,7 +13587,7 @@ After calling create_team, you MUST:
|
|
|
13384
13587
|
}))
|
|
13385
13588
|
);
|
|
13386
13589
|
const summary = created.map((t) => `- ${t.id}: "${t.title}"`).join("\n");
|
|
13387
|
-
return new
|
|
13590
|
+
return new ToolMessage8({
|
|
13388
13591
|
content: `Added ${created.length} task(s) to team ${teamId}:
|
|
13389
13592
|
${summary}
|
|
13390
13593
|
Sleeping teammates will wake up and claim these.`,
|
|
@@ -13422,33 +13625,33 @@ IMPORTANT: Dependencies
|
|
|
13422
13625
|
|
|
13423
13626
|
IMPORTANT: Assigning to a specific teammate
|
|
13424
13627
|
- When you need a particular teammate to do the work, set assignee to that teammate's name (e.g. assignee: "researcher"). They can then claim or see the task as assigned to them.`,
|
|
13425
|
-
schema:
|
|
13426
|
-
tasks:
|
|
13427
|
-
|
|
13428
|
-
id:
|
|
13429
|
-
title:
|
|
13430
|
-
description:
|
|
13431
|
-
assignee:
|
|
13432
|
-
dependencies:
|
|
13628
|
+
schema: z51.object({
|
|
13629
|
+
tasks: z51.array(
|
|
13630
|
+
z51.object({
|
|
13631
|
+
id: z51.string().describe("Task ID in format task-01, task-02, etc. Must be unique."),
|
|
13632
|
+
title: z51.string().describe("Short task title"),
|
|
13633
|
+
description: z51.string().describe("Detailed task description - what needs to be done"),
|
|
13634
|
+
assignee: z51.string().optional().describe("Teammate name to assign this task to (use when you need that person to do the work)"),
|
|
13635
|
+
dependencies: z51.array(z51.string()).optional().default([]).describe("Array of task IDs that must complete before this task")
|
|
13433
13636
|
})
|
|
13434
13637
|
).describe("New tasks to add to the team")
|
|
13435
13638
|
})
|
|
13436
13639
|
}
|
|
13437
13640
|
);
|
|
13438
|
-
const assignTaskTool =
|
|
13641
|
+
const assignTaskTool = tool50(
|
|
13439
13642
|
async (input, config) => {
|
|
13440
13643
|
const teamId = resolveTeamId();
|
|
13441
13644
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
13442
13645
|
assignee: input.assignee
|
|
13443
13646
|
});
|
|
13444
13647
|
if (!task) {
|
|
13445
|
-
return new
|
|
13648
|
+
return new ToolMessage8({
|
|
13446
13649
|
content: `Task ${input.task_id} not found in team ${teamId}.`,
|
|
13447
13650
|
tool_call_id: config.toolCall?.id,
|
|
13448
13651
|
name: "assign_task"
|
|
13449
13652
|
});
|
|
13450
13653
|
}
|
|
13451
|
-
return new
|
|
13654
|
+
return new ToolMessage8({
|
|
13452
13655
|
content: `Task "${task.title}" (${task.id}) assigned to ${input.assignee}.`,
|
|
13453
13656
|
tool_call_id: config.toolCall?.id,
|
|
13454
13657
|
name: "assign_task"
|
|
@@ -13457,26 +13660,26 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
13457
13660
|
{
|
|
13458
13661
|
name: "assign_task",
|
|
13459
13662
|
description: "Assign a task to a specific teammate. Use when you need to reassign work to a different teammate. Omit team_id to use the active team from state.",
|
|
13460
|
-
schema:
|
|
13461
|
-
task_id:
|
|
13462
|
-
assignee:
|
|
13663
|
+
schema: z51.object({
|
|
13664
|
+
task_id: z51.string().describe("Task ID to assign"),
|
|
13665
|
+
assignee: z51.string().describe("Teammate name to assign this task to")
|
|
13463
13666
|
})
|
|
13464
13667
|
}
|
|
13465
13668
|
);
|
|
13466
|
-
const setTaskStatusTool =
|
|
13669
|
+
const setTaskStatusTool = tool50(
|
|
13467
13670
|
async (input, config) => {
|
|
13468
13671
|
const teamId = resolveTeamId();
|
|
13469
13672
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
13470
13673
|
status: input.status
|
|
13471
13674
|
});
|
|
13472
13675
|
if (!task) {
|
|
13473
|
-
return new
|
|
13676
|
+
return new ToolMessage8({
|
|
13474
13677
|
content: `Task ${input.task_id} not found in team ${teamId}.`,
|
|
13475
13678
|
tool_call_id: config.toolCall?.id,
|
|
13476
13679
|
name: "set_task_status"
|
|
13477
13680
|
});
|
|
13478
13681
|
}
|
|
13479
|
-
return new
|
|
13682
|
+
return new ToolMessage8({
|
|
13480
13683
|
content: `Task "${task.title}" (${task.id}) status set to ${input.status}.`,
|
|
13481
13684
|
tool_call_id: config.toolCall?.id,
|
|
13482
13685
|
name: "set_task_status"
|
|
@@ -13485,26 +13688,26 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
13485
13688
|
{
|
|
13486
13689
|
name: "set_task_status",
|
|
13487
13690
|
description: "Set a task's status. Use to reopen a task (set to pending), mark as failed, or correct status. Values: pending, claimed, in_progress, completed, failed. Omit team_id to use the active team from state.",
|
|
13488
|
-
schema:
|
|
13489
|
-
task_id:
|
|
13490
|
-
status:
|
|
13691
|
+
schema: z51.object({
|
|
13692
|
+
task_id: z51.string().describe("Task ID to update"),
|
|
13693
|
+
status: z51.enum(["pending", "claimed", "in_progress", "completed", "failed"]).describe("New status for the task")
|
|
13491
13694
|
})
|
|
13492
13695
|
}
|
|
13493
13696
|
);
|
|
13494
|
-
const setTaskDependenciesTool =
|
|
13697
|
+
const setTaskDependenciesTool = tool50(
|
|
13495
13698
|
async (input, config) => {
|
|
13496
13699
|
const teamId = resolveTeamId();
|
|
13497
13700
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
13498
13701
|
dependencies: input.dependencies
|
|
13499
13702
|
});
|
|
13500
13703
|
if (!task) {
|
|
13501
|
-
return new
|
|
13704
|
+
return new ToolMessage8({
|
|
13502
13705
|
content: `Task ${input.task_id} not found in team ${teamId}.`,
|
|
13503
13706
|
tool_call_id: config.toolCall?.id,
|
|
13504
13707
|
name: "set_task_dependencies"
|
|
13505
13708
|
});
|
|
13506
13709
|
}
|
|
13507
|
-
return new
|
|
13710
|
+
return new ToolMessage8({
|
|
13508
13711
|
content: `Task "${task.title}" (${task.id}) dependencies set to [${input.dependencies.join(", ")}].`,
|
|
13509
13712
|
tool_call_id: config.toolCall?.id,
|
|
13510
13713
|
name: "set_task_dependencies"
|
|
@@ -13513,13 +13716,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
13513
13716
|
{
|
|
13514
13717
|
name: "set_task_dependencies",
|
|
13515
13718
|
description: 'Set which task IDs must complete before this task can be claimed. Pass an array of task IDs (e.g. ["task-01", "task-02"]). Use to fix task order or add/remove dependencies. Omit team_id to use the active team from state.',
|
|
13516
|
-
schema:
|
|
13517
|
-
task_id:
|
|
13518
|
-
dependencies:
|
|
13719
|
+
schema: z51.object({
|
|
13720
|
+
task_id: z51.string().describe("Task ID to update"),
|
|
13721
|
+
dependencies: z51.array(z51.string()).describe("Task IDs that must complete before this task can be claimed")
|
|
13519
13722
|
})
|
|
13520
13723
|
}
|
|
13521
13724
|
);
|
|
13522
|
-
const checkTasksTool =
|
|
13725
|
+
const checkTasksTool = tool50(
|
|
13523
13726
|
async (input, config) => {
|
|
13524
13727
|
const teamId = resolveTeamId();
|
|
13525
13728
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
@@ -13528,7 +13731,7 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
13528
13731
|
update: {
|
|
13529
13732
|
tasks: tasksSnapshot,
|
|
13530
13733
|
messages: [
|
|
13531
|
-
new
|
|
13734
|
+
new ToolMessage8({
|
|
13532
13735
|
content: formatTaskSummary(tasks),
|
|
13533
13736
|
tool_call_id: config.toolCall?.id,
|
|
13534
13737
|
name: "check_tasks"
|
|
@@ -13559,12 +13762,12 @@ Task Status Values:
|
|
|
13559
13762
|
- in_progress: Teammate is actively working on this task
|
|
13560
13763
|
- completed: Task finished successfully
|
|
13561
13764
|
- failed: Task encountered an error`,
|
|
13562
|
-
schema:
|
|
13563
|
-
team_id:
|
|
13765
|
+
schema: z51.object({
|
|
13766
|
+
team_id: z51.string().optional().describe("Team ID (omit to use active team)")
|
|
13564
13767
|
})
|
|
13565
13768
|
}
|
|
13566
13769
|
);
|
|
13567
|
-
const sendMessageTool =
|
|
13770
|
+
const sendMessageTool = tool50(
|
|
13568
13771
|
async (input, config) => {
|
|
13569
13772
|
const teamId = resolveTeamId();
|
|
13570
13773
|
await mailboxStore.sendMessage(
|
|
@@ -13574,7 +13777,7 @@ Task Status Values:
|
|
|
13574
13777
|
input.content,
|
|
13575
13778
|
"direct_message" /* DIRECT_MESSAGE */
|
|
13576
13779
|
);
|
|
13577
|
-
return new
|
|
13780
|
+
return new ToolMessage8({
|
|
13578
13781
|
content: `Message sent to ${input.to}.`,
|
|
13579
13782
|
tool_call_id: config.toolCall?.id,
|
|
13580
13783
|
name: "send_message"
|
|
@@ -13583,13 +13786,13 @@ Task Status Values:
|
|
|
13583
13786
|
{
|
|
13584
13787
|
name: "send_message",
|
|
13585
13788
|
description: "Send a message to a specific teammate in the team. Omit team_id to use the active team from state.",
|
|
13586
|
-
schema:
|
|
13587
|
-
to:
|
|
13588
|
-
content:
|
|
13789
|
+
schema: z51.object({
|
|
13790
|
+
to: z51.string().describe("Recipient teammate name"),
|
|
13791
|
+
content: z51.string().describe("Message content")
|
|
13589
13792
|
})
|
|
13590
13793
|
}
|
|
13591
13794
|
);
|
|
13592
|
-
const readMessagesTool =
|
|
13795
|
+
const readMessagesTool = tool50(
|
|
13593
13796
|
async (input, config) => {
|
|
13594
13797
|
const teamId = resolveTeamId();
|
|
13595
13798
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
@@ -13617,7 +13820,7 @@ Task Status Values:
|
|
|
13617
13820
|
if (msgs.length > 0) {
|
|
13618
13821
|
const formatted2 = await formatAndMarkAsRead(msgs);
|
|
13619
13822
|
const allTeamMessages2 = await getAllTeamMessagesForState();
|
|
13620
|
-
const toolMessage2 = new
|
|
13823
|
+
const toolMessage2 = new ToolMessage8({
|
|
13621
13824
|
content: formatted2,
|
|
13622
13825
|
tool_call_id: config.toolCall?.id,
|
|
13623
13826
|
name: "read_messages"
|
|
@@ -13649,7 +13852,7 @@ Task Status Values:
|
|
|
13649
13852
|
);
|
|
13650
13853
|
const allTeamMessages = await getAllTeamMessagesForState();
|
|
13651
13854
|
if (msgs.length === 0) {
|
|
13652
|
-
const toolMessage2 = new
|
|
13855
|
+
const toolMessage2 = new ToolMessage8({
|
|
13653
13856
|
content: "No unread messages from teammates.",
|
|
13654
13857
|
tool_call_id: config.toolCall?.id,
|
|
13655
13858
|
name: "read_messages"
|
|
@@ -13659,7 +13862,7 @@ Task Status Values:
|
|
|
13659
13862
|
});
|
|
13660
13863
|
}
|
|
13661
13864
|
const formatted = await formatAndMarkAsRead(msgs);
|
|
13662
|
-
const toolMessage = new
|
|
13865
|
+
const toolMessage = new ToolMessage8({
|
|
13663
13866
|
content: formatted,
|
|
13664
13867
|
tool_call_id: config.toolCall?.id,
|
|
13665
13868
|
name: "read_messages"
|
|
@@ -13671,12 +13874,12 @@ Task Status Values:
|
|
|
13671
13874
|
{
|
|
13672
13875
|
name: "read_messages",
|
|
13673
13876
|
description: "Read unread messages from teammates. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
13674
|
-
schema:
|
|
13675
|
-
team_id:
|
|
13877
|
+
schema: z51.object({
|
|
13878
|
+
team_id: z51.string().optional().describe("Team ID (omit to use active team)")
|
|
13676
13879
|
})
|
|
13677
13880
|
}
|
|
13678
13881
|
);
|
|
13679
|
-
const disbandTeamTool =
|
|
13882
|
+
const disbandTeamTool = tool50(
|
|
13680
13883
|
async (input, config) => {
|
|
13681
13884
|
const teamId = resolveTeamId();
|
|
13682
13885
|
await mailboxStore.broadcastMessage(
|
|
@@ -13686,7 +13889,7 @@ Task Status Values:
|
|
|
13686
13889
|
"shutdown_request" /* SHUTDOWN_REQUEST */
|
|
13687
13890
|
);
|
|
13688
13891
|
await new Promise((r) => setTimeout(r, 2e3));
|
|
13689
|
-
return new
|
|
13892
|
+
return new ToolMessage8({
|
|
13690
13893
|
content: `Team ${teamId} has been disbanded. All teammates notified and resources cleaned up.`,
|
|
13691
13894
|
tool_call_id: config.toolCall?.id,
|
|
13692
13895
|
name: "disband_team"
|
|
@@ -13697,7 +13900,7 @@ Task Status Values:
|
|
|
13697
13900
|
description: "Disband a team when all work is done. Before calling: (1) Call check_tasks to verify no tasks are still pending/in_progress; (2) if any are, discuss with the team via read_messages and broadcast_message/send_message whether to continue or stop/cancel them; (3) only after alignment (all tasks completed/failed or explicitly stopped), then call this tool. This will: 1) Send a shutdown message to all teammates, 2) Wait briefly for them to clean up, 3) Clear all tasks and messages. Omit team_id to use the active team from state."
|
|
13698
13901
|
}
|
|
13699
13902
|
);
|
|
13700
|
-
const broadcastMessageTool =
|
|
13903
|
+
const broadcastMessageTool = tool50(
|
|
13701
13904
|
async (input, config) => {
|
|
13702
13905
|
const teamId = resolveTeamId();
|
|
13703
13906
|
await mailboxStore.broadcastMessage(
|
|
@@ -13706,7 +13909,7 @@ Task Status Values:
|
|
|
13706
13909
|
input.content,
|
|
13707
13910
|
"broadcast" /* BROADCAST */
|
|
13708
13911
|
);
|
|
13709
|
-
return new
|
|
13912
|
+
return new ToolMessage8({
|
|
13710
13913
|
content: `Broadcast message sent to all teammates.`,
|
|
13711
13914
|
tool_call_id: config.toolCall?.id,
|
|
13712
13915
|
name: "broadcast_message"
|
|
@@ -13715,12 +13918,12 @@ Task Status Values:
|
|
|
13715
13918
|
{
|
|
13716
13919
|
name: "broadcast_message",
|
|
13717
13920
|
description: "Send a message to all teammates at once. Use this to communicate with everyone in the team. Omit team_id to use the active team from state.",
|
|
13718
|
-
schema:
|
|
13719
|
-
content:
|
|
13921
|
+
schema: z51.object({
|
|
13922
|
+
content: z51.string().describe("Message content to broadcast to all teammates")
|
|
13720
13923
|
})
|
|
13721
13924
|
}
|
|
13722
13925
|
);
|
|
13723
|
-
return
|
|
13926
|
+
return createMiddleware16({
|
|
13724
13927
|
name: "teamMiddleware",
|
|
13725
13928
|
tools: [
|
|
13726
13929
|
createTeamTool,
|
|
@@ -13748,37 +13951,37 @@ ${TEAM_SYSTEM_PROMPT}` : TEAM_SYSTEM_PROMPT;
|
|
|
13748
13951
|
}
|
|
13749
13952
|
|
|
13750
13953
|
// src/agent_team/agent_team.ts
|
|
13751
|
-
var TeammateInfoSchema =
|
|
13752
|
-
name:
|
|
13753
|
-
role:
|
|
13754
|
-
description:
|
|
13954
|
+
var TeammateInfoSchema = z52.object({
|
|
13955
|
+
name: z52.string().describe("Teammate name"),
|
|
13956
|
+
role: z52.string().describe("Role category (e.g. research, writing, review)"),
|
|
13957
|
+
description: z52.string().describe("What this teammate focuses on")
|
|
13755
13958
|
});
|
|
13756
|
-
var TeamTaskInfoSchema =
|
|
13757
|
-
id:
|
|
13758
|
-
title:
|
|
13759
|
-
description:
|
|
13760
|
-
status:
|
|
13959
|
+
var TeamTaskInfoSchema = z52.object({
|
|
13960
|
+
id: z52.string(),
|
|
13961
|
+
title: z52.string(),
|
|
13962
|
+
description: z52.string(),
|
|
13963
|
+
status: z52.string().optional()
|
|
13761
13964
|
});
|
|
13762
|
-
var MailboxMessageSchema =
|
|
13763
|
-
id:
|
|
13764
|
-
from:
|
|
13765
|
-
to:
|
|
13766
|
-
content:
|
|
13767
|
-
timestamp:
|
|
13768
|
-
type:
|
|
13769
|
-
read:
|
|
13965
|
+
var MailboxMessageSchema = z52.object({
|
|
13966
|
+
id: z52.string().describe("Unique message identifier"),
|
|
13967
|
+
from: z52.string().describe("Sender agent name"),
|
|
13968
|
+
to: z52.string().describe("Recipient agent name"),
|
|
13969
|
+
content: z52.string().describe("Message content"),
|
|
13970
|
+
timestamp: z52.string().describe("ISO timestamp when the message was sent"),
|
|
13971
|
+
type: z52.nativeEnum(MessageType).describe("Message type"),
|
|
13972
|
+
read: z52.boolean().describe("Whether the recipient has read this message")
|
|
13770
13973
|
});
|
|
13771
|
-
var TeamInfoSchema =
|
|
13772
|
-
teamId:
|
|
13773
|
-
teamLeadId:
|
|
13774
|
-
teammates:
|
|
13775
|
-
tasks:
|
|
13776
|
-
createdAt:
|
|
13974
|
+
var TeamInfoSchema = z52.object({
|
|
13975
|
+
teamId: z52.string().describe("Unique team identifier"),
|
|
13976
|
+
teamLeadId: z52.string().default("team_lead").describe("Team lead agent ID"),
|
|
13977
|
+
teammates: z52.array(TeammateInfoSchema).describe("Active teammates in this team"),
|
|
13978
|
+
tasks: z52.array(TeamTaskInfoSchema).optional().describe("Initial tasks snapshot"),
|
|
13979
|
+
createdAt: z52.string().optional().describe("ISO timestamp when team was created")
|
|
13777
13980
|
});
|
|
13778
|
-
var TEAM_STATE_SCHEMA =
|
|
13981
|
+
var TEAM_STATE_SCHEMA = z52.object({
|
|
13779
13982
|
team: TeamInfoSchema.optional().describe("Team info: teamId, teamLeadId, teammates, tasks. Set when create_team succeeds."),
|
|
13780
|
-
tasks:
|
|
13781
|
-
team_mailbox:
|
|
13983
|
+
tasks: z52.array(TeamTaskInfoSchema).optional().describe("Current tasks snapshot from check_tasks. Updated on each check."),
|
|
13984
|
+
team_mailbox: z52.array(MailboxMessageSchema).optional().describe("All team mailbox messages for display")
|
|
13782
13985
|
});
|
|
13783
13986
|
var TEAM_LEAD_BASE_PROMPT = `You are a team lead that coordinates a team of specialized agents. In order to complete the objective that the user asks of you, you will need to:
|
|
13784
13987
|
|
|
@@ -13859,7 +14062,7 @@ var TeamAgentGraphBuilder = class {
|
|
|
13859
14062
|
const tools = params.tools.map((t) => {
|
|
13860
14063
|
const toolClient = getToolClient(t.key);
|
|
13861
14064
|
return toolClient;
|
|
13862
|
-
}).filter((
|
|
14065
|
+
}).filter((tool51) => tool51 !== void 0);
|
|
13863
14066
|
const teammates = params.subAgents.map((sa) => {
|
|
13864
14067
|
const baseConfig = sa.config;
|
|
13865
14068
|
return {
|
|
@@ -14592,6 +14795,9 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
|
14592
14795
|
buffer2.expiresAt = Date.now() + this.config.ttl;
|
|
14593
14796
|
buffer2.status = "active" /* ACTIVE */;
|
|
14594
14797
|
}
|
|
14798
|
+
async ensureThread(threadId) {
|
|
14799
|
+
this.getOrCreateBuffer(threadId);
|
|
14800
|
+
}
|
|
14595
14801
|
async completeThread(threadId) {
|
|
14596
14802
|
const buffer2 = this.getBufferIfValid(threadId);
|
|
14597
14803
|
if (buffer2) {
|
|
@@ -16745,10 +16951,10 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
16745
16951
|
}
|
|
16746
16952
|
const tools = await this.getAllTools();
|
|
16747
16953
|
console.log(`[MCP] Registering ${tools.length} tools to Tool Lattice...`);
|
|
16748
|
-
for (const
|
|
16749
|
-
const toolKey = prefix ? `${prefix}_${
|
|
16750
|
-
|
|
16751
|
-
toolLatticeManager.registerExistingTool(toolKey,
|
|
16954
|
+
for (const tool51 of tools) {
|
|
16955
|
+
const toolKey = prefix ? `${prefix}_${tool51.name}` : tool51.name;
|
|
16956
|
+
tool51.name = toolKey;
|
|
16957
|
+
toolLatticeManager.registerExistingTool(toolKey, tool51);
|
|
16752
16958
|
console.log(`[MCP] Registered tool: ${toolKey}`);
|
|
16753
16959
|
}
|
|
16754
16960
|
console.log(`[MCP] Successfully registered ${tools.length} tools to Tool Lattice`);
|
|
@@ -16955,6 +17161,7 @@ var Agent = class {
|
|
|
16955
17161
|
break;
|
|
16956
17162
|
}
|
|
16957
17163
|
const firstMessage = pendings[0];
|
|
17164
|
+
const files = firstMessage.content?.queueMessage?.input?.files;
|
|
16958
17165
|
const hasCommand = firstMessage.command;
|
|
16959
17166
|
if (hasCommand) {
|
|
16960
17167
|
for (const p of pendings) {
|
|
@@ -16973,12 +17180,15 @@ var Agent = class {
|
|
|
16973
17180
|
const input = {
|
|
16974
17181
|
messages: [new HumanMessage2({ id: humanContent.id, content: humanContent.message })]
|
|
16975
17182
|
};
|
|
17183
|
+
if (files) {
|
|
17184
|
+
input.files = files;
|
|
17185
|
+
}
|
|
16976
17186
|
const queueMessageData = humanContent.queueMessage;
|
|
16977
17187
|
try {
|
|
16978
17188
|
await this.agentStreamExecutor({
|
|
16979
17189
|
input,
|
|
16980
17190
|
command: p.command,
|
|
16981
|
-
custom_run_config: queueMessageData.custom_run_config
|
|
17191
|
+
custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
|
|
16982
17192
|
}, signal);
|
|
16983
17193
|
await this.queueStore?.markCompleted(p.id);
|
|
16984
17194
|
const runStatus = await this.getRunStatus();
|
|
@@ -17044,10 +17254,16 @@ var Agent = class {
|
|
|
17044
17254
|
});
|
|
17045
17255
|
});
|
|
17046
17256
|
const firstQueueMessage = remainingPendings[0] ? this.getHumanPendingContent(remainingPendings[0]).queueMessage : void 0;
|
|
17257
|
+
const input = {
|
|
17258
|
+
messages: userMessages
|
|
17259
|
+
};
|
|
17260
|
+
if (files) {
|
|
17261
|
+
input.files = files;
|
|
17262
|
+
}
|
|
17047
17263
|
try {
|
|
17048
17264
|
await this.agentStreamExecutor({
|
|
17049
|
-
input
|
|
17050
|
-
custom_run_config: firstQueueMessage?.custom_run_config
|
|
17265
|
+
input,
|
|
17266
|
+
custom_run_config: remainingPendings[0]?.custom_run_config ?? firstQueueMessage?.custom_run_config
|
|
17051
17267
|
}, signal);
|
|
17052
17268
|
const runStatus = await this.getRunStatus();
|
|
17053
17269
|
const state = await this.getCurrentState();
|
|
@@ -17112,10 +17328,16 @@ var Agent = class {
|
|
|
17112
17328
|
queueMode: "followup" /* FOLLOWUP */
|
|
17113
17329
|
});
|
|
17114
17330
|
const queueMessageData = humanContent.queueMessage || {};
|
|
17331
|
+
const input = {
|
|
17332
|
+
messages: [message]
|
|
17333
|
+
};
|
|
17334
|
+
if (files) {
|
|
17335
|
+
input.files = files;
|
|
17336
|
+
}
|
|
17115
17337
|
try {
|
|
17116
17338
|
await this.agentStreamExecutor({
|
|
17117
|
-
input
|
|
17118
|
-
custom_run_config: queueMessageData.custom_run_config
|
|
17339
|
+
input,
|
|
17340
|
+
custom_run_config: p.custom_run_config ?? queueMessageData.custom_run_config
|
|
17119
17341
|
}, signal);
|
|
17120
17342
|
await this.queueStore?.markCompleted(p.id);
|
|
17121
17343
|
const runStatus = await this.getRunStatus();
|
|
@@ -17312,7 +17534,16 @@ var Agent = class {
|
|
|
17312
17534
|
}
|
|
17313
17535
|
};
|
|
17314
17536
|
if (isHighPriority) {
|
|
17315
|
-
await store.addMessageAtHead(
|
|
17537
|
+
await store.addMessageAtHead({
|
|
17538
|
+
threadId: this.thread_id,
|
|
17539
|
+
tenantId: this.tenant_id,
|
|
17540
|
+
assistantId: this.assistant_id,
|
|
17541
|
+
content,
|
|
17542
|
+
type: "human",
|
|
17543
|
+
command: queueMessage.command,
|
|
17544
|
+
custom_run_config: queueMessage.custom_run_config,
|
|
17545
|
+
id: messageId
|
|
17546
|
+
});
|
|
17316
17547
|
if (useMode === "steer" /* STEER */) {
|
|
17317
17548
|
this.stopQueueProcessor();
|
|
17318
17549
|
await store.resetProcessingToPending(this.thread_id);
|
|
@@ -17326,9 +17557,11 @@ var Agent = class {
|
|
|
17326
17557
|
content,
|
|
17327
17558
|
type: "human",
|
|
17328
17559
|
command: queueMessage.command,
|
|
17560
|
+
custom_run_config: queueMessage.custom_run_config,
|
|
17329
17561
|
id: messageId
|
|
17330
17562
|
});
|
|
17331
17563
|
}
|
|
17564
|
+
await this.chunkBuffer.ensureThread(this.thread_id);
|
|
17332
17565
|
this.startQueueProcessorIfNeeded().catch((err) => {
|
|
17333
17566
|
console.error("Failed to start queue processor:", err);
|
|
17334
17567
|
});
|
|
@@ -17385,11 +17618,13 @@ var Agent = class {
|
|
|
17385
17618
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
17386
17619
|
}
|
|
17387
17620
|
};
|
|
17388
|
-
await this.queueStore.addMessageAtHead(
|
|
17389
|
-
thread.threadId,
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
17621
|
+
await this.queueStore.addMessageAtHead({
|
|
17622
|
+
threadId: thread.threadId,
|
|
17623
|
+
tenantId: thread.tenantId,
|
|
17624
|
+
assistantId: thread.assistantId,
|
|
17625
|
+
content: reminderContent,
|
|
17626
|
+
type: "system"
|
|
17627
|
+
});
|
|
17393
17628
|
}
|
|
17394
17629
|
async getCurrentState() {
|
|
17395
17630
|
const { runnable_agent } = await this.getLatticeClientAndRuntimeConfig();
|
|
@@ -17460,12 +17695,16 @@ var Agent = class {
|
|
|
17460
17695
|
/**
|
|
17461
17696
|
* Abort the current agent execution
|
|
17462
17697
|
* This will cancel any ongoing invoke or stream operations
|
|
17698
|
+
* and clear all queued messages (pending + processing)
|
|
17463
17699
|
*/
|
|
17464
|
-
abort() {
|
|
17700
|
+
async abort() {
|
|
17465
17701
|
if (this.abortController) {
|
|
17466
17702
|
this.abortController.abort();
|
|
17467
17703
|
this.abortController = null;
|
|
17468
17704
|
}
|
|
17705
|
+
await this.chunkBuffer.abortThread(this.thread_id);
|
|
17706
|
+
const store = this.getQueueStore();
|
|
17707
|
+
await store.clearMessages(this.thread_id);
|
|
17469
17708
|
}
|
|
17470
17709
|
/**
|
|
17471
17710
|
* Check if the agent is currently being aborted
|
|
@@ -17773,6 +18012,7 @@ export {
|
|
|
17773
18012
|
createQueryTablesListTool,
|
|
17774
18013
|
createTeamMiddleware,
|
|
17775
18014
|
createTeammateTools,
|
|
18015
|
+
createUnknownToolHandlerMiddleware,
|
|
17776
18016
|
createWidgetMiddleware,
|
|
17777
18017
|
decrypt,
|
|
17778
18018
|
describeCronExpression,
|