@axiom-lattice/core 2.1.100 → 2.1.102
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 +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +1091 -520
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1116 -545
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -72,6 +72,12 @@ var ModelLattice = class extends BaseChatModel {
|
|
|
72
72
|
async _generate(messages, options, runManager) {
|
|
73
73
|
return this.llm._generate(messages, options, runManager);
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Whether the configured model supports vision/image inputs.
|
|
77
|
+
*/
|
|
78
|
+
get supportsVision() {
|
|
79
|
+
return this.config.supportsVision || false;
|
|
80
|
+
}
|
|
75
81
|
/**
|
|
76
82
|
* 将工具绑定到模型
|
|
77
83
|
* @param tools 工具列表
|
|
@@ -2636,11 +2642,17 @@ var InMemoryTaskStore = class {
|
|
|
2636
2642
|
description: params.description,
|
|
2637
2643
|
status: params.status || "pending",
|
|
2638
2644
|
priority: params.priority || "medium",
|
|
2645
|
+
workspaceId: params.workspaceId,
|
|
2646
|
+
projectId: params.projectId,
|
|
2639
2647
|
dueDate: params.dueDate,
|
|
2640
2648
|
metadata: params.metadata,
|
|
2641
2649
|
parentId: params.parentId,
|
|
2642
2650
|
sourceId: params.sourceId,
|
|
2643
2651
|
context: params.context,
|
|
2652
|
+
requireReview: params.requireReview ?? false,
|
|
2653
|
+
dependencies: params.dependencies,
|
|
2654
|
+
result: params.result,
|
|
2655
|
+
failureReason: params.failureReason,
|
|
2644
2656
|
createdAt: now,
|
|
2645
2657
|
updatedAt: now
|
|
2646
2658
|
};
|
|
@@ -2666,6 +2678,8 @@ var InMemoryTaskStore = class {
|
|
|
2666
2678
|
if (filter2.ownerId) results = results.filter((t) => t.ownerId === filter2.ownerId);
|
|
2667
2679
|
if (filter2.status) results = results.filter((t) => t.status === filter2.status);
|
|
2668
2680
|
if (filter2.priority) results = results.filter((t) => t.priority === filter2.priority);
|
|
2681
|
+
if (filter2.workspaceId) results = results.filter((t) => t.workspaceId === filter2.workspaceId);
|
|
2682
|
+
if (filter2.projectId) results = results.filter((t) => t.projectId === filter2.projectId);
|
|
2669
2683
|
if (filter2.parentId) results = results.filter((t) => t.parentId === filter2.parentId);
|
|
2670
2684
|
if (filter2.sourceId) results = results.filter((t) => t.sourceId === filter2.sourceId);
|
|
2671
2685
|
if (filter2.metadata) {
|
|
@@ -2714,6 +2728,63 @@ var InMemoryTaskStore = class {
|
|
|
2714
2728
|
}
|
|
2715
2729
|
};
|
|
2716
2730
|
|
|
2731
|
+
// src/store_lattice/InMemoryTaskWorkItemStore.ts
|
|
2732
|
+
import { v4 } from "uuid";
|
|
2733
|
+
var InMemoryTaskWorkItemStore = class {
|
|
2734
|
+
constructor() {
|
|
2735
|
+
this.store = /* @__PURE__ */ new Map();
|
|
2736
|
+
}
|
|
2737
|
+
/**
|
|
2738
|
+
* Create a new work item
|
|
2739
|
+
*/
|
|
2740
|
+
async create(params) {
|
|
2741
|
+
const id = v4();
|
|
2742
|
+
const item = {
|
|
2743
|
+
id,
|
|
2744
|
+
taskId: params.taskId,
|
|
2745
|
+
tenantId: params.tenantId,
|
|
2746
|
+
workspaceId: params.workspaceId,
|
|
2747
|
+
projectId: params.projectId,
|
|
2748
|
+
action: params.action,
|
|
2749
|
+
actor: params.actor,
|
|
2750
|
+
threadId: params.threadId,
|
|
2751
|
+
summary: params.summary,
|
|
2752
|
+
detail: params.detail,
|
|
2753
|
+
attempt: params.attempt,
|
|
2754
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
2755
|
+
};
|
|
2756
|
+
if (!this.store.has(params.tenantId)) {
|
|
2757
|
+
this.store.set(params.tenantId, /* @__PURE__ */ new Map());
|
|
2758
|
+
}
|
|
2759
|
+
const tenantStore = this.store.get(params.tenantId);
|
|
2760
|
+
if (!tenantStore.has(params.taskId)) {
|
|
2761
|
+
tenantStore.set(params.taskId, []);
|
|
2762
|
+
}
|
|
2763
|
+
tenantStore.get(params.taskId).push(item);
|
|
2764
|
+
return item;
|
|
2765
|
+
}
|
|
2766
|
+
/**
|
|
2767
|
+
* List work items matching filter criteria
|
|
2768
|
+
*/
|
|
2769
|
+
async list(filter2) {
|
|
2770
|
+
const tenantStore = this.store.get(filter2.tenantId);
|
|
2771
|
+
if (!tenantStore) return [];
|
|
2772
|
+
const items = tenantStore.get(filter2.taskId) || [];
|
|
2773
|
+
let result = [...items];
|
|
2774
|
+
if (filter2.action) {
|
|
2775
|
+
result = result.filter((item) => item.action === filter2.action);
|
|
2776
|
+
}
|
|
2777
|
+
result.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
2778
|
+
if (filter2.offset) {
|
|
2779
|
+
result = result.slice(filter2.offset);
|
|
2780
|
+
}
|
|
2781
|
+
if (filter2.limit) {
|
|
2782
|
+
result = result.slice(0, filter2.limit);
|
|
2783
|
+
}
|
|
2784
|
+
return result;
|
|
2785
|
+
}
|
|
2786
|
+
};
|
|
2787
|
+
|
|
2717
2788
|
// src/store_lattice/InMemoryCollectionStore.ts
|
|
2718
2789
|
import { v4 as uuidv42 } from "uuid";
|
|
2719
2790
|
var InMemoryCollectionStore = class {
|
|
@@ -2985,6 +3056,12 @@ storeLatticeManager.registerLattice(
|
|
|
2985
3056
|
"task",
|
|
2986
3057
|
defaultTaskStore
|
|
2987
3058
|
);
|
|
3059
|
+
var defaultTaskWorkItemStore = new InMemoryTaskWorkItemStore();
|
|
3060
|
+
storeLatticeManager.registerLattice(
|
|
3061
|
+
"default",
|
|
3062
|
+
"taskWorkItem",
|
|
3063
|
+
defaultTaskWorkItemStore
|
|
3064
|
+
);
|
|
2988
3065
|
var defaultCollectionStore = new InMemoryCollectionStore();
|
|
2989
3066
|
storeLatticeManager.registerLattice(
|
|
2990
3067
|
"default",
|
|
@@ -7063,7 +7140,7 @@ var createBrowserGetInfoTool = ({ vmIsolation }) => {
|
|
|
7063
7140
|
};
|
|
7064
7141
|
|
|
7065
7142
|
// src/index.ts
|
|
7066
|
-
import { HumanMessage as
|
|
7143
|
+
import { HumanMessage as HumanMessage5 } from "@langchain/core/messages";
|
|
7067
7144
|
|
|
7068
7145
|
// src/agent_lattice/types.ts
|
|
7069
7146
|
import {
|
|
@@ -7697,6 +7774,72 @@ var StateBackend = class {
|
|
|
7697
7774
|
}
|
|
7698
7775
|
};
|
|
7699
7776
|
|
|
7777
|
+
// src/deep_agent_new/backends/imageUtils.ts
|
|
7778
|
+
var IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
7779
|
+
".png",
|
|
7780
|
+
".jpg",
|
|
7781
|
+
".jpeg",
|
|
7782
|
+
".gif",
|
|
7783
|
+
".webp",
|
|
7784
|
+
".bmp",
|
|
7785
|
+
".svg",
|
|
7786
|
+
".ico",
|
|
7787
|
+
".tiff",
|
|
7788
|
+
".tif"
|
|
7789
|
+
]);
|
|
7790
|
+
var MIME_MAP = {
|
|
7791
|
+
".png": "image/png",
|
|
7792
|
+
".jpg": "image/jpeg",
|
|
7793
|
+
".jpeg": "image/jpeg",
|
|
7794
|
+
".gif": "image/gif",
|
|
7795
|
+
".webp": "image/webp",
|
|
7796
|
+
".bmp": "image/bmp",
|
|
7797
|
+
".svg": "image/svg+xml",
|
|
7798
|
+
".ico": "image/x-icon",
|
|
7799
|
+
".tiff": "image/tiff",
|
|
7800
|
+
".tif": "image/tiff"
|
|
7801
|
+
};
|
|
7802
|
+
function isImageFile(filePath) {
|
|
7803
|
+
const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
|
|
7804
|
+
return IMAGE_EXTENSIONS.has(ext);
|
|
7805
|
+
}
|
|
7806
|
+
function detectMimeType(filePath) {
|
|
7807
|
+
const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
|
|
7808
|
+
return MIME_MAP[ext] || "application/octet-stream";
|
|
7809
|
+
}
|
|
7810
|
+
var MAX_IMAGE_SIZE = 50 * 1024 * 1024;
|
|
7811
|
+
function validateImageSize(sizeBytes) {
|
|
7812
|
+
if (sizeBytes > MAX_IMAGE_SIZE) {
|
|
7813
|
+
return `Image too large (${(sizeBytes / 1024 / 1024).toFixed(1)}MB). Maximum is 50MB.`;
|
|
7814
|
+
}
|
|
7815
|
+
return null;
|
|
7816
|
+
}
|
|
7817
|
+
|
|
7818
|
+
// src/deep_agent_new/backends/describeImage.ts
|
|
7819
|
+
import { HumanMessage } from "@langchain/core/messages";
|
|
7820
|
+
async function describeImage(options) {
|
|
7821
|
+
const { modelKey, mimeType, base64, prompt } = options;
|
|
7822
|
+
const { client } = modelLatticeManager.getModelLattice(modelKey);
|
|
7823
|
+
if (!client.supportsVision) {
|
|
7824
|
+
throw new Error(`Model "${modelKey}" does not support vision.`);
|
|
7825
|
+
}
|
|
7826
|
+
const result = await client.invoke([
|
|
7827
|
+
new HumanMessage({
|
|
7828
|
+
content: [
|
|
7829
|
+
{
|
|
7830
|
+
type: "text",
|
|
7831
|
+
text: prompt || "Please describe this image in detail."
|
|
7832
|
+
},
|
|
7833
|
+
{
|
|
7834
|
+
type: "image_url",
|
|
7835
|
+
image_url: { url: `data:${mimeType};base64,${base64}` }
|
|
7836
|
+
}
|
|
7837
|
+
]
|
|
7838
|
+
})
|
|
7839
|
+
]);
|
|
7840
|
+
return result.content || "";
|
|
7841
|
+
}
|
|
7842
|
+
|
|
7700
7843
|
// src/deep_agent_new/middleware/fs.ts
|
|
7701
7844
|
var FileDataSchema = z310.object({
|
|
7702
7845
|
content: z310.array(z310.string()),
|
|
@@ -7755,7 +7898,7 @@ Path conventions:
|
|
|
7755
7898
|
- glob: find files matching a pattern (e.g., "/project/**/*.py")
|
|
7756
7899
|
- grep: search for text within files`;
|
|
7757
7900
|
var LS_TOOL_DESCRIPTION = "List files and directories in a directory";
|
|
7758
|
-
var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file";
|
|
7901
|
+
var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file. For image files (png, jpg, gif, webp, bmp, svg), returns a visual description when the current model supports vision. For unsupported models, returns an error suggesting to switch to a vision-capable model.";
|
|
7759
7902
|
var WRITE_FILE_TOOL_DESCRIPTION = "Write content to a new file. Returns an error if the file already exists";
|
|
7760
7903
|
var EDIT_FILE_TOOL_DESCRIPTION = "Edit a file by replacing a specific string with a new string";
|
|
7761
7904
|
var GLOB_TOOL_DESCRIPTION = "Find files matching a glob pattern (e.g., '**/*.py' for all Python files)";
|
|
@@ -7808,6 +7951,38 @@ function createReadFileTool(backend, options) {
|
|
|
7808
7951
|
};
|
|
7809
7952
|
const resolvedBackend = await getBackend(backend, stateAndStore);
|
|
7810
7953
|
const { file_path, offset = 0, limit = 2e3 } = input;
|
|
7954
|
+
if (isImageFile(file_path)) {
|
|
7955
|
+
const modelKey = runConfig?.modelConfig?.modelKey || "default";
|
|
7956
|
+
const { client } = modelLatticeManager.getModelLattice(modelKey);
|
|
7957
|
+
if (!client.supportsVision) {
|
|
7958
|
+
return `[\u56FE\u7247] ${file_path}
|
|
7959
|
+
\u5F53\u524D\u6A21\u578B "${modelKey}" \u4E0D\u652F\u6301\u89C6\u89C9\u80FD\u529B\uFF0C\u65E0\u6CD5\u8BFB\u53D6\u56FE\u7247\u5185\u5BB9\u3002\u8BF7\u5207\u6362\u5230\u652F\u6301\u591A\u6A21\u6001\u7684\u6A21\u578B\uFF08\u5982 GPT-4o\uFF09\u3002`;
|
|
7960
|
+
}
|
|
7961
|
+
if (!resolvedBackend.readBinary) {
|
|
7962
|
+
return `[\u56FE\u7247] ${file_path}
|
|
7963
|
+
\u5F53\u524D\u540E\u7AEF\u4E0D\u652F\u6301\u4E8C\u8FDB\u5236\u8BFB\u53D6\uFF0C\u65E0\u6CD5\u5904\u7406\u56FE\u7247\u3002`;
|
|
7964
|
+
}
|
|
7965
|
+
try {
|
|
7966
|
+
const buffer2 = await resolvedBackend.readBinary(file_path);
|
|
7967
|
+
const sizeWarning = validateImageSize(buffer2.length);
|
|
7968
|
+
if (sizeWarning) {
|
|
7969
|
+
return `[\u56FE\u7247] ${file_path}
|
|
7970
|
+
${sizeWarning}`;
|
|
7971
|
+
}
|
|
7972
|
+
const mimeType = detectMimeType(file_path);
|
|
7973
|
+
const description = await describeImage({
|
|
7974
|
+
modelKey,
|
|
7975
|
+
mimeType,
|
|
7976
|
+
base64: buffer2.toString("base64")
|
|
7977
|
+
});
|
|
7978
|
+
return `[\u56FE\u7247] ${file_path}\uFF08${mimeType}\uFF0C${(buffer2.length / 1024).toFixed(1)}KB\uFF09
|
|
7979
|
+
|
|
7980
|
+
${description}`;
|
|
7981
|
+
} catch (error) {
|
|
7982
|
+
return `[\u56FE\u7247] ${file_path}
|
|
7983
|
+
\u8BFB\u53D6\u56FE\u7247\u5931\u8D25\uFF1A${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
|
|
7984
|
+
}
|
|
7985
|
+
}
|
|
7811
7986
|
return await resolvedBackend.read(file_path, offset, limit);
|
|
7812
7987
|
},
|
|
7813
7988
|
{
|
|
@@ -9401,19 +9576,13 @@ var SandboxFilesystem = class {
|
|
|
9401
9576
|
throw new Error(`Error reading file '${filePath}': ${e.message}`);
|
|
9402
9577
|
}
|
|
9403
9578
|
}
|
|
9579
|
+
async readBinary(filePath) {
|
|
9580
|
+
return this.sandbox.file.downloadFile({ file: filePath });
|
|
9581
|
+
}
|
|
9404
9582
|
async write(filePath, content) {
|
|
9405
9583
|
try {
|
|
9406
9584
|
await this.sandbox.file.writeFile(filePath, content);
|
|
9407
|
-
return {
|
|
9408
|
-
path: filePath,
|
|
9409
|
-
filesUpdate: {
|
|
9410
|
-
[filePath]: {
|
|
9411
|
-
content: content.split("\n"),
|
|
9412
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9413
|
-
modified_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
9414
|
-
}
|
|
9415
|
-
}
|
|
9416
|
-
};
|
|
9585
|
+
return { path: filePath, filesUpdate: null };
|
|
9417
9586
|
} catch (e) {
|
|
9418
9587
|
throw new Error(`Error writing file '${filePath}': ${e.message}`);
|
|
9419
9588
|
}
|
|
@@ -9427,10 +9596,7 @@ var SandboxFilesystem = class {
|
|
|
9427
9596
|
new_str: newString,
|
|
9428
9597
|
replace_mode: replaceAll ? "ALL" : "FIRST"
|
|
9429
9598
|
});
|
|
9430
|
-
return {
|
|
9431
|
-
path: filePath,
|
|
9432
|
-
filesUpdate: null
|
|
9433
|
-
};
|
|
9599
|
+
return { path: filePath, filesUpdate: null };
|
|
9434
9600
|
} catch (e) {
|
|
9435
9601
|
throw new Error(`Error editing file '${filePath}': ${e.message}`);
|
|
9436
9602
|
}
|
|
@@ -9535,16 +9701,16 @@ import {
|
|
|
9535
9701
|
} from "langchain";
|
|
9536
9702
|
|
|
9537
9703
|
// src/deep_agent_new/middleware/subagents.ts
|
|
9538
|
-
import { z as
|
|
9704
|
+
import { z as z43 } from "zod/v3";
|
|
9539
9705
|
import {
|
|
9540
|
-
createMiddleware as
|
|
9706
|
+
createMiddleware as createMiddleware10,
|
|
9541
9707
|
createAgent as createAgent2,
|
|
9542
|
-
tool as
|
|
9708
|
+
tool as tool40,
|
|
9543
9709
|
ToolMessage as ToolMessage3,
|
|
9544
9710
|
humanInTheLoopMiddleware
|
|
9545
9711
|
} from "langchain";
|
|
9546
9712
|
import { Command as Command3, getCurrentTaskInput as getCurrentTaskInput2, GraphInterrupt as GraphInterrupt2 } from "@langchain/langgraph";
|
|
9547
|
-
import { HumanMessage as
|
|
9713
|
+
import { HumanMessage as HumanMessage3 } from "@langchain/core/messages";
|
|
9548
9714
|
|
|
9549
9715
|
// src/agent_worker/agent_worker_graph.ts
|
|
9550
9716
|
import {
|
|
@@ -9960,7 +10126,7 @@ var QueueMode = /* @__PURE__ */ ((QueueMode2) => {
|
|
|
9960
10126
|
|
|
9961
10127
|
// src/services/Agent.ts
|
|
9962
10128
|
import { Command as Command2 } from "@langchain/langgraph";
|
|
9963
|
-
import { HumanMessage, filterMessages } from "langchain";
|
|
10129
|
+
import { HumanMessage as HumanMessage2, filterMessages } from "langchain";
|
|
9964
10130
|
|
|
9965
10131
|
// src/chunk_buffer_lattice/ChunkBuffer.ts
|
|
9966
10132
|
var ChunkBuffer = class {
|
|
@@ -10277,7 +10443,7 @@ var buffer = new InMemoryChunkBuffer({
|
|
|
10277
10443
|
registerChunkBuffer("default", buffer);
|
|
10278
10444
|
|
|
10279
10445
|
// src/services/Agent.ts
|
|
10280
|
-
import { v4 } from "uuid";
|
|
10446
|
+
import { v4 as v42 } from "uuid";
|
|
10281
10447
|
var ThreadStatus2 = /* @__PURE__ */ ((ThreadStatus3) => {
|
|
10282
10448
|
ThreadStatus3["IDLE"] = "idle";
|
|
10283
10449
|
ThreadStatus3["BUSY"] = "busy";
|
|
@@ -10323,7 +10489,7 @@ var Agent = class {
|
|
|
10323
10489
|
runConfig
|
|
10324
10490
|
},
|
|
10325
10491
|
configurable: {
|
|
10326
|
-
run_id:
|
|
10492
|
+
run_id: v42(),
|
|
10327
10493
|
...runConfig,
|
|
10328
10494
|
runConfig
|
|
10329
10495
|
},
|
|
@@ -10396,7 +10562,7 @@ var Agent = class {
|
|
|
10396
10562
|
runConfig
|
|
10397
10563
|
},
|
|
10398
10564
|
configurable: {
|
|
10399
|
-
run_id:
|
|
10565
|
+
run_id: v42(),
|
|
10400
10566
|
...runConfig,
|
|
10401
10567
|
runConfig
|
|
10402
10568
|
// Inject runConfig for tools to access
|
|
@@ -10460,7 +10626,7 @@ var Agent = class {
|
|
|
10460
10626
|
});
|
|
10461
10627
|
const humanContent = p.content;
|
|
10462
10628
|
const input = {
|
|
10463
|
-
messages: [new
|
|
10629
|
+
messages: [new HumanMessage2({ id: humanContent.id, content: humanContent.message })]
|
|
10464
10630
|
};
|
|
10465
10631
|
if (files) {
|
|
10466
10632
|
input.files = files;
|
|
@@ -10534,7 +10700,7 @@ var Agent = class {
|
|
|
10534
10700
|
remainingPendings.forEach((p) => {
|
|
10535
10701
|
this.queueStore?.markProcessing(p.id);
|
|
10536
10702
|
const humanContent = p.content;
|
|
10537
|
-
userMessages.push(new
|
|
10703
|
+
userMessages.push(new HumanMessage2({ id: humanContent.id, content: humanContent.message }));
|
|
10538
10704
|
this.publish("message:started", {
|
|
10539
10705
|
type: "message:started",
|
|
10540
10706
|
messageId: humanContent.id,
|
|
@@ -10614,7 +10780,7 @@ var Agent = class {
|
|
|
10614
10780
|
if (signal?.aborted) break;
|
|
10615
10781
|
await this.queueStore?.markProcessing(p.id);
|
|
10616
10782
|
const humanContent = p.content;
|
|
10617
|
-
const message = new
|
|
10783
|
+
const message = new HumanMessage2({ id: humanContent.id, content: humanContent.message });
|
|
10618
10784
|
const startTime = Date.now();
|
|
10619
10785
|
this.publish("message:started", {
|
|
10620
10786
|
type: "message:started",
|
|
@@ -10782,10 +10948,10 @@ var Agent = class {
|
|
|
10782
10948
|
};
|
|
10783
10949
|
}
|
|
10784
10950
|
async invoke(queueMessage, signal) {
|
|
10785
|
-
const messageId =
|
|
10951
|
+
const messageId = v42();
|
|
10786
10952
|
const input = {
|
|
10787
10953
|
...queueMessage.input,
|
|
10788
|
-
messages: [new
|
|
10954
|
+
messages: [new HumanMessage2({ id: messageId, content: queueMessage.input.message })]
|
|
10789
10955
|
};
|
|
10790
10956
|
const inputMessage = { ...queueMessage, input };
|
|
10791
10957
|
return this.agentExecutor(inputMessage, signal);
|
|
@@ -10801,10 +10967,10 @@ var Agent = class {
|
|
|
10801
10967
|
* to avoid exposing internal annotation data.
|
|
10802
10968
|
*/
|
|
10803
10969
|
async invokeWithState(queueMessage, signal) {
|
|
10804
|
-
const messageId =
|
|
10970
|
+
const messageId = v42();
|
|
10805
10971
|
const input = {
|
|
10806
10972
|
...queueMessage.input,
|
|
10807
|
-
messages: [new
|
|
10973
|
+
messages: [new HumanMessage2({ id: messageId, content: queueMessage.input.message })]
|
|
10808
10974
|
};
|
|
10809
10975
|
const inputMessage = { ...queueMessage, input };
|
|
10810
10976
|
const { runnable_agent, runConfig } = await this.getLatticeClientAndRuntimeConfig(inputMessage.custom_run_config);
|
|
@@ -10817,7 +10983,7 @@ var Agent = class {
|
|
|
10817
10983
|
{
|
|
10818
10984
|
context: { runConfig },
|
|
10819
10985
|
configurable: {
|
|
10820
|
-
run_id:
|
|
10986
|
+
run_id: v42(),
|
|
10821
10987
|
...runConfig,
|
|
10822
10988
|
runConfig
|
|
10823
10989
|
},
|
|
@@ -10993,7 +11159,7 @@ var Agent = class {
|
|
|
10993
11159
|
*/
|
|
10994
11160
|
async addMessage(queueMessage, mode) {
|
|
10995
11161
|
const useMode = mode ?? this.queueMode.mode;
|
|
10996
|
-
const messageId = queueMessage.input.id ||
|
|
11162
|
+
const messageId = queueMessage.input.id || v42();
|
|
10997
11163
|
const messages = queueMessage.input.messages;
|
|
10998
11164
|
const legacyMessage = queueMessage.input.message;
|
|
10999
11165
|
if (!messages && !legacyMessage) {
|
|
@@ -11485,6 +11651,348 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
11485
11651
|
};
|
|
11486
11652
|
var agentInstanceManager = AgentInstanceManager.getInstance();
|
|
11487
11653
|
|
|
11654
|
+
// src/middlewares/taskMiddleware.ts
|
|
11655
|
+
import { createMiddleware as createMiddleware9, tool as tool39 } from "langchain";
|
|
11656
|
+
import { z as z42 } from "zod";
|
|
11657
|
+
function getRunConfig(config) {
|
|
11658
|
+
const c = config;
|
|
11659
|
+
return c?.configurable?.runConfig ?? {};
|
|
11660
|
+
}
|
|
11661
|
+
function getTaskStore() {
|
|
11662
|
+
return getStoreLattice("default", "task").store;
|
|
11663
|
+
}
|
|
11664
|
+
var VALID_TRANSITIONS = {
|
|
11665
|
+
pending: ["in_progress", "cancelled"],
|
|
11666
|
+
in_progress: ["completed", "review", "failed", "interrupted", "cancelled"],
|
|
11667
|
+
review: ["completed", "in_progress", "cancelled"],
|
|
11668
|
+
failed: ["in_progress", "cancelled"],
|
|
11669
|
+
interrupted: ["in_progress", "cancelled"],
|
|
11670
|
+
completed: [],
|
|
11671
|
+
cancelled: []
|
|
11672
|
+
};
|
|
11673
|
+
function isValidTransition(from, to) {
|
|
11674
|
+
const allowed = VALID_TRANSITIONS[from];
|
|
11675
|
+
if (!allowed) return false;
|
|
11676
|
+
return allowed.includes(to);
|
|
11677
|
+
}
|
|
11678
|
+
function getTaskWorkItemStore() {
|
|
11679
|
+
return getStoreLattice("default", "taskWorkItem").store;
|
|
11680
|
+
}
|
|
11681
|
+
var manageTaskSchema = z42.object({
|
|
11682
|
+
action: z42.enum(["create", "list", "update", "delete"]).describe("Action to perform. Available: create, list, update, delete. To mark a task complete, use update with status='completed'"),
|
|
11683
|
+
id: z42.string().optional().describe("Task ID (required for update and delete)"),
|
|
11684
|
+
title: z42.string().optional().describe("Task title (required for create)"),
|
|
11685
|
+
description: z42.string().optional().describe("Task description in Markdown"),
|
|
11686
|
+
priority: z42.enum(["low", "medium", "high"]).optional().describe("Priority level"),
|
|
11687
|
+
status: z42.enum(["pending", "in_progress", "review", "failed", "interrupted", "completed", "cancelled"]).optional().describe("Task status"),
|
|
11688
|
+
dueDate: z42.string().optional().describe("Due date (ISO 8601 format)"),
|
|
11689
|
+
metadata: z42.record(z42.unknown()).optional().describe("Structured metadata (e.g. projectId, module)"),
|
|
11690
|
+
parentId: z42.string().optional().describe("Parent task ID for grouping subtasks"),
|
|
11691
|
+
sourceId: z42.string().optional().describe("Source session/thread ID"),
|
|
11692
|
+
context: z42.record(z42.unknown()).optional().describe("Additional context data"),
|
|
11693
|
+
ownerType: z42.enum(["user", "agent"]).optional().describe("Owner type. Defaults to 'user' if omitted"),
|
|
11694
|
+
ownerId: z42.string().optional().describe("Owner ID. Auto-filled from current user/agent if omitted"),
|
|
11695
|
+
requireReview: z42.boolean().optional().describe("If true, completing sends task to 'review' status instead of 'completed'"),
|
|
11696
|
+
dependencies: z42.array(z42.string()).optional().describe("List of task IDs that must be completed before this task can start"),
|
|
11697
|
+
result: z42.string().optional().describe("Result summary when task is completed"),
|
|
11698
|
+
failureReason: z42.string().optional().describe("Reason for failure (use when status='failed')"),
|
|
11699
|
+
summary: z42.string().optional().describe("Brief summary of the operation")
|
|
11700
|
+
});
|
|
11701
|
+
function createTaskMiddleware() {
|
|
11702
|
+
const handleManageTask = async (input, config) => {
|
|
11703
|
+
const rc = getRunConfig(config);
|
|
11704
|
+
const tenantId2 = rc.tenantId || "default";
|
|
11705
|
+
const workspaceId = rc.workspaceId;
|
|
11706
|
+
const projectId = rc.projectId;
|
|
11707
|
+
const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
|
|
11708
|
+
const store = getTaskStore();
|
|
11709
|
+
switch (input.action) {
|
|
11710
|
+
case "create": {
|
|
11711
|
+
if (!input.title) {
|
|
11712
|
+
return JSON.stringify({
|
|
11713
|
+
success: false,
|
|
11714
|
+
error: "title is required for create action",
|
|
11715
|
+
hint: "Provide a short, descriptive title for the task"
|
|
11716
|
+
});
|
|
11717
|
+
}
|
|
11718
|
+
const task = await store.create({
|
|
11719
|
+
tenantId: tenantId2,
|
|
11720
|
+
ownerType: input.ownerType || "user",
|
|
11721
|
+
ownerId,
|
|
11722
|
+
title: input.title,
|
|
11723
|
+
description: input.description,
|
|
11724
|
+
priority: input.priority || "medium",
|
|
11725
|
+
status: input.status || "pending",
|
|
11726
|
+
dueDate: input.dueDate,
|
|
11727
|
+
metadata: input.metadata,
|
|
11728
|
+
parentId: input.parentId,
|
|
11729
|
+
sourceId: input.sourceId,
|
|
11730
|
+
context: input.context,
|
|
11731
|
+
requireReview: input.requireReview,
|
|
11732
|
+
dependencies: input.dependencies,
|
|
11733
|
+
workspaceId,
|
|
11734
|
+
projectId
|
|
11735
|
+
});
|
|
11736
|
+
return JSON.stringify({ success: true, data: task });
|
|
11737
|
+
}
|
|
11738
|
+
case "list": {
|
|
11739
|
+
const filter2 = {
|
|
11740
|
+
tenantId: tenantId2,
|
|
11741
|
+
ownerType: input.ownerType,
|
|
11742
|
+
ownerId: input.ownerId,
|
|
11743
|
+
status: input.status,
|
|
11744
|
+
priority: input.priority,
|
|
11745
|
+
projectId
|
|
11746
|
+
};
|
|
11747
|
+
const tasks = await store.list(filter2);
|
|
11748
|
+
return JSON.stringify({ success: true, data: tasks, count: tasks.length });
|
|
11749
|
+
}
|
|
11750
|
+
case "update": {
|
|
11751
|
+
if (!input.id) {
|
|
11752
|
+
return JSON.stringify({
|
|
11753
|
+
success: false,
|
|
11754
|
+
error: "id is required for update action",
|
|
11755
|
+
hint: "Pass the task ID you want to update"
|
|
11756
|
+
});
|
|
11757
|
+
}
|
|
11758
|
+
const existing = await store.getById(tenantId2, input.id);
|
|
11759
|
+
if (!existing) {
|
|
11760
|
+
return JSON.stringify({
|
|
11761
|
+
success: false,
|
|
11762
|
+
error: `Task '${input.id}' not found`,
|
|
11763
|
+
hint: "Use list to see available tasks and their IDs"
|
|
11764
|
+
});
|
|
11765
|
+
}
|
|
11766
|
+
if (input.status) {
|
|
11767
|
+
if (!isValidTransition(existing.status, input.status)) {
|
|
11768
|
+
const allowed = VALID_TRANSITIONS[existing.status] || [];
|
|
11769
|
+
return JSON.stringify({
|
|
11770
|
+
success: false,
|
|
11771
|
+
error: `Cannot transition task from '${existing.status}' to '${input.status}'`,
|
|
11772
|
+
allowedTransitions: allowed,
|
|
11773
|
+
hint: `From '${existing.status}', valid transitions are: ${allowed.join(", ")}`
|
|
11774
|
+
});
|
|
11775
|
+
}
|
|
11776
|
+
}
|
|
11777
|
+
if (input.status === "in_progress" && existing.dependencies && existing.dependencies.length > 0) {
|
|
11778
|
+
const incompleteDeps = [];
|
|
11779
|
+
for (const depId of existing.dependencies) {
|
|
11780
|
+
const depTask = await store.getById(tenantId2, depId);
|
|
11781
|
+
if (!depTask || depTask.status !== "completed") {
|
|
11782
|
+
incompleteDeps.push(depId);
|
|
11783
|
+
}
|
|
11784
|
+
}
|
|
11785
|
+
if (incompleteDeps.length > 0) {
|
|
11786
|
+
return JSON.stringify({
|
|
11787
|
+
success: false,
|
|
11788
|
+
error: `Cannot start task '${input.id}': ${incompleteDeps.length} dependencies not completed`,
|
|
11789
|
+
blockedBy: incompleteDeps,
|
|
11790
|
+
hint: `These tasks must be completed first: ${incompleteDeps.join(", ")}`
|
|
11791
|
+
});
|
|
11792
|
+
}
|
|
11793
|
+
}
|
|
11794
|
+
let effectiveStatus = input.status;
|
|
11795
|
+
if (existing.requireReview && input.status === "completed" && existing.status === "in_progress") {
|
|
11796
|
+
effectiveStatus = "review";
|
|
11797
|
+
}
|
|
11798
|
+
const updates = {};
|
|
11799
|
+
const settableFields = [
|
|
11800
|
+
"title",
|
|
11801
|
+
"description",
|
|
11802
|
+
"priority",
|
|
11803
|
+
"dueDate",
|
|
11804
|
+
"metadata",
|
|
11805
|
+
"parentId",
|
|
11806
|
+
"sourceId",
|
|
11807
|
+
"context",
|
|
11808
|
+
"ownerType",
|
|
11809
|
+
"ownerId",
|
|
11810
|
+
"result",
|
|
11811
|
+
"failureReason",
|
|
11812
|
+
"requireReview",
|
|
11813
|
+
"dependencies"
|
|
11814
|
+
];
|
|
11815
|
+
for (const field of settableFields) {
|
|
11816
|
+
if (input[field] !== void 0) {
|
|
11817
|
+
updates[field] = input[field];
|
|
11818
|
+
}
|
|
11819
|
+
}
|
|
11820
|
+
if (effectiveStatus !== void 0) {
|
|
11821
|
+
updates.status = effectiveStatus;
|
|
11822
|
+
}
|
|
11823
|
+
const updated = await store.update(tenantId2, input.id, updates);
|
|
11824
|
+
if (!updated) {
|
|
11825
|
+
return JSON.stringify({
|
|
11826
|
+
success: false,
|
|
11827
|
+
error: `Failed to update task '${input.id}'`,
|
|
11828
|
+
hint: "The task may have been deleted or the ID is incorrect"
|
|
11829
|
+
});
|
|
11830
|
+
}
|
|
11831
|
+
const actionMap = {
|
|
11832
|
+
pending: "pending",
|
|
11833
|
+
in_progress: "started",
|
|
11834
|
+
review: "submitted",
|
|
11835
|
+
failed: "failed",
|
|
11836
|
+
interrupted: "interrupted",
|
|
11837
|
+
completed: "completed",
|
|
11838
|
+
cancelled: "cancelled"
|
|
11839
|
+
};
|
|
11840
|
+
const workItemAction = effectiveStatus ? actionMap[effectiveStatus] || "updated" : "updated";
|
|
11841
|
+
const workItemSummary = input.summary || (effectiveStatus ? `Status changed to ${effectiveStatus}` : void 0);
|
|
11842
|
+
const workItemStore = getTaskWorkItemStore();
|
|
11843
|
+
await workItemStore.create({
|
|
11844
|
+
taskId: input.id,
|
|
11845
|
+
tenantId: tenantId2,
|
|
11846
|
+
action: workItemAction,
|
|
11847
|
+
actor: input.ownerType === "agent" ? `agent:${ownerId}` : `user:${ownerId}`,
|
|
11848
|
+
threadId: input.sourceId,
|
|
11849
|
+
summary: workItemSummary,
|
|
11850
|
+
detail: {
|
|
11851
|
+
...input.result !== void 0 && { result: input.result },
|
|
11852
|
+
...input.failureReason !== void 0 && { failureReason: input.failureReason }
|
|
11853
|
+
},
|
|
11854
|
+
workspaceId,
|
|
11855
|
+
projectId
|
|
11856
|
+
});
|
|
11857
|
+
return JSON.stringify({ success: true, data: updated });
|
|
11858
|
+
}
|
|
11859
|
+
case "delete": {
|
|
11860
|
+
if (!input.id) {
|
|
11861
|
+
return JSON.stringify({
|
|
11862
|
+
success: false,
|
|
11863
|
+
error: "id is required for delete action",
|
|
11864
|
+
hint: "Pass the task ID you want to delete"
|
|
11865
|
+
});
|
|
11866
|
+
}
|
|
11867
|
+
const deleted = await store.delete(tenantId2, input.id);
|
|
11868
|
+
if (!deleted) {
|
|
11869
|
+
return JSON.stringify({
|
|
11870
|
+
success: false,
|
|
11871
|
+
error: `Task '${input.id}' not found or could not be deleted`,
|
|
11872
|
+
hint: "Use list to verify the task exists"
|
|
11873
|
+
});
|
|
11874
|
+
}
|
|
11875
|
+
return JSON.stringify({ success: true, message: `Task '${input.id}' deleted` });
|
|
11876
|
+
}
|
|
11877
|
+
default:
|
|
11878
|
+
return JSON.stringify({
|
|
11879
|
+
success: false,
|
|
11880
|
+
error: `Unknown action '${input.action}'`,
|
|
11881
|
+
availableActions: ["create", "list", "update", "delete"],
|
|
11882
|
+
hint: "To mark a task complete, use action='update' with status='completed'"
|
|
11883
|
+
});
|
|
11884
|
+
}
|
|
11885
|
+
};
|
|
11886
|
+
return createMiddleware9({
|
|
11887
|
+
name: "TaskMiddleware",
|
|
11888
|
+
contextSchema,
|
|
11889
|
+
wrapModelCall: async (request, handler) => {
|
|
11890
|
+
const taskPrompt = `## Task Management
|
|
11891
|
+
|
|
11892
|
+
You can use the \`manage_task\` tool to create persistent tasks for user-visible work tracking.
|
|
11893
|
+
|
|
11894
|
+
### When to create a task
|
|
11895
|
+
- The user explicitly asks you to track, manage, or follow up on work
|
|
11896
|
+
- The work spans multiple sessions or might need resumption later
|
|
11897
|
+
- The user needs to review or approve output before it is considered done
|
|
11898
|
+
- There are multiple independent work items the user wants visibility into
|
|
11899
|
+
|
|
11900
|
+
### When NOT to create a task
|
|
11901
|
+
- One-shot lookups or simple Q&A ("what is X?", "search for Y")
|
|
11902
|
+
- Internal exploration steps you take to understand the problem (use \`write_todos\` for your execution plan instead)
|
|
11903
|
+
- Trivial single-step actions that complete in the same turn
|
|
11904
|
+
- Conversational or informational requests with no deliverable
|
|
11905
|
+
|
|
11906
|
+
### Ownership defaults
|
|
11907
|
+
- No params: ownerType defaults to "user" with current user's ID
|
|
11908
|
+
- ownerType="agent": auto-fills ownerId from current agent (subtask for yourself)
|
|
11909
|
+
- Explicit ownerId: assign to a specific agent or user`;
|
|
11910
|
+
return handler({
|
|
11911
|
+
...request,
|
|
11912
|
+
systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
|
|
11913
|
+
});
|
|
11914
|
+
},
|
|
11915
|
+
tools: [
|
|
11916
|
+
tool39(
|
|
11917
|
+
handleManageTask,
|
|
11918
|
+
{
|
|
11919
|
+
name: "manage_task",
|
|
11920
|
+
description: `Manage persistent tasks. CRUD operations for user and agent tasks.
|
|
11921
|
+
|
|
11922
|
+
## Owner defaults
|
|
11923
|
+
- No ownerType/ownerId: auto-assigned to current user
|
|
11924
|
+
- ownerType="agent" without ownerId: auto-assigned to current agent
|
|
11925
|
+
- Explicit ownerId: assign to a specific agent (cross-agent delegation)
|
|
11926
|
+
|
|
11927
|
+
## Actions
|
|
11928
|
+
- create: Create a task (title required; priority/description/dueDate/metadata/parentId/context optional)
|
|
11929
|
+
- list: List tasks, filterable by ownerType/status/priority
|
|
11930
|
+
- update: Update a task (id required; pass only the fields to change)
|
|
11931
|
+
To mark complete: update with status='completed'
|
|
11932
|
+
To mark failed: update with status='failed', failureReason='...'
|
|
11933
|
+
Status transitions are validated \u2014 only allowed transitions will succeed.
|
|
11934
|
+
- delete: Delete a task (id required)`,
|
|
11935
|
+
schema: manageTaskSchema
|
|
11936
|
+
}
|
|
11937
|
+
)
|
|
11938
|
+
]
|
|
11939
|
+
});
|
|
11940
|
+
}
|
|
11941
|
+
var taskPlugin = {
|
|
11942
|
+
meta: {
|
|
11943
|
+
type: "task",
|
|
11944
|
+
name: "Task Management",
|
|
11945
|
+
description: "Enables persistent task management with delegation and tracking",
|
|
11946
|
+
configSchema: {
|
|
11947
|
+
type: "object",
|
|
11948
|
+
title: "Task Management Configuration",
|
|
11949
|
+
description: "Zero-configuration task management",
|
|
11950
|
+
properties: {}
|
|
11951
|
+
},
|
|
11952
|
+
defaultConfig: {}
|
|
11953
|
+
},
|
|
11954
|
+
middleware: () => createTaskMiddleware(),
|
|
11955
|
+
skills: {
|
|
11956
|
+
"task-definition": `## Using manage_task
|
|
11957
|
+
|
|
11958
|
+
### Task description format
|
|
11959
|
+
|
|
11960
|
+
When creating a task with manage_task, write the description in this Markdown structure:
|
|
11961
|
+
|
|
11962
|
+
## Objective
|
|
11963
|
+
[One sentence \u2014 what result to achieve, as measurable as possible]
|
|
11964
|
+
|
|
11965
|
+
## Acceptance Criteria
|
|
11966
|
+
- [ ] Criterion 1
|
|
11967
|
+
- [ ] Criterion 2
|
|
11968
|
+
|
|
11969
|
+
## Deliverables
|
|
11970
|
+
- Deliverable description
|
|
11971
|
+
|
|
11972
|
+
Update the checklist as you work: change \`[ ]\` to \`[x]\` when a criterion is met.
|
|
11973
|
+
|
|
11974
|
+
### Subtasks (parentId)
|
|
11975
|
+
|
|
11976
|
+
Use \`parentId\` to group related tasks under a parent. Create the parent task first, then create each subtask with \`parentId\` pointing to the parent.
|
|
11977
|
+
|
|
11978
|
+
### Dependencies
|
|
11979
|
+
|
|
11980
|
+
Use the \`dependencies\` field to declare prerequisites. A task cannot be started (\`in_progress\`) until all its dependencies are \`completed\`. The validation happens automatically \u2014 no manual checking needed.
|
|
11981
|
+
|
|
11982
|
+
### requireReview
|
|
11983
|
+
|
|
11984
|
+
Set \`requireReview: true\` if the user should approve output before the task is considered done. When enabled, completing the task sends it to \`review\` status instead of \`completed\`.
|
|
11985
|
+
|
|
11986
|
+
### Reporting results
|
|
11987
|
+
|
|
11988
|
+
When a task is finished:
|
|
11989
|
+
- \`update(status: "completed", result: "summary of what was done")\`
|
|
11990
|
+
- If unable to complete: \`update(status: "failed", failureReason: "specific reason")\`
|
|
11991
|
+
- If blocked waiting for user input: \`update(status: "interrupted", summary: "what you need")\`
|
|
11992
|
+
- Use description updates to append progress notes between status changes.`
|
|
11993
|
+
}
|
|
11994
|
+
};
|
|
11995
|
+
|
|
11488
11996
|
// src/deep_agent_new/middleware/subagents.ts
|
|
11489
11997
|
var DEFAULT_SUBAGENT_PROMPT = "In order to complete the objective that the user asks of you, you have access to a number of standard tools.";
|
|
11490
11998
|
var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
|
|
@@ -11667,8 +12175,12 @@ function getSubagents(options) {
|
|
|
11667
12175
|
const defaultSubagentMiddleware = defaultMiddleware || [];
|
|
11668
12176
|
const agents = {};
|
|
11669
12177
|
const subagentDescriptions = [];
|
|
12178
|
+
const hasTaskMiddleware = defaultSubagentMiddleware.some(
|
|
12179
|
+
(m) => m?.name === "TaskMiddleware"
|
|
12180
|
+
);
|
|
12181
|
+
const taskMiddleware = hasTaskMiddleware ? [] : [createTaskMiddleware()];
|
|
11670
12182
|
if (generalPurposeAgent) {
|
|
11671
|
-
const generalPurposeMiddleware = [...defaultSubagentMiddleware];
|
|
12183
|
+
const generalPurposeMiddleware = [...defaultSubagentMiddleware, ...taskMiddleware];
|
|
11672
12184
|
if (defaultInterruptOn) {
|
|
11673
12185
|
generalPurposeMiddleware.push(
|
|
11674
12186
|
humanInTheLoopMiddleware({ interruptOn: defaultInterruptOn })
|
|
@@ -11694,7 +12206,7 @@ function getSubagents(options) {
|
|
|
11694
12206
|
if ("runnable" in agentParams) {
|
|
11695
12207
|
agents[agentParams.key] = agentParams.runnable;
|
|
11696
12208
|
} else {
|
|
11697
|
-
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
|
|
12209
|
+
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...taskMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware, ...taskMiddleware];
|
|
11698
12210
|
const interruptOn = agentParams.interruptOn || defaultInterruptOn;
|
|
11699
12211
|
if (interruptOn)
|
|
11700
12212
|
middleware.push(humanInTheLoopMiddleware({ interruptOn }));
|
|
@@ -11748,7 +12260,7 @@ function createTaskTool(options) {
|
|
|
11748
12260
|
generalPurposeAgent
|
|
11749
12261
|
});
|
|
11750
12262
|
const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
|
|
11751
|
-
return
|
|
12263
|
+
return tool40(
|
|
11752
12264
|
async (input, config) => {
|
|
11753
12265
|
const { description, subagent_type, async } = input;
|
|
11754
12266
|
let assistant_id = subagent_type;
|
|
@@ -11778,7 +12290,17 @@ function createTaskTool(options) {
|
|
|
11778
12290
|
}
|
|
11779
12291
|
const currentState = getCurrentTaskInput2();
|
|
11780
12292
|
const subagentState = filterStateForSubagent(currentState);
|
|
11781
|
-
subagentState.messages =
|
|
12293
|
+
subagentState.messages = input.taskId ? [
|
|
12294
|
+
new HumanMessage3({
|
|
12295
|
+
content: `${description}
|
|
12296
|
+
|
|
12297
|
+
---
|
|
12298
|
+
You are executing a persistent task (ID: ${input.taskId}). Use manage_task.update to report your progress:
|
|
12299
|
+
- Set status to 'in_progress' when you start working
|
|
12300
|
+
- Set status to 'completed' when done (or 'review' if requireReview is true, or 'failed' if you cannot complete, or 'interrupted' if you need more information)
|
|
12301
|
+
- You can also update the description to append progress notes or update the acceptance criteria checklist.`
|
|
12302
|
+
})
|
|
12303
|
+
] : [new HumanMessage3({ content: description })];
|
|
11782
12304
|
const subagent_thread_id = config.configurable?.thread_id + "____" + assistant_id + "_" + config.toolCall.id;
|
|
11783
12305
|
if (async) {
|
|
11784
12306
|
const tenantId2 = config.configurable?.runConfig?.tenantId;
|
|
@@ -11810,11 +12332,12 @@ function createTaskTool(options) {
|
|
|
11810
12332
|
runConfig: {
|
|
11811
12333
|
...config.configurable?.runConfig,
|
|
11812
12334
|
assistant_id,
|
|
11813
|
-
thread_id: subagent_thread_id
|
|
12335
|
+
thread_id: subagent_thread_id,
|
|
12336
|
+
taskId: input.taskId
|
|
11814
12337
|
},
|
|
11815
|
-
main_thread_id: mainThreadId,
|
|
11816
12338
|
main_tenant_id: tenantId2,
|
|
11817
|
-
main_assistant_id: mainAssistantId
|
|
12339
|
+
main_assistant_id: mainAssistantId,
|
|
12340
|
+
main_thread_id: mainThreadId
|
|
11818
12341
|
}, false).catch((err) => {
|
|
11819
12342
|
console.error(`Failed to start async subagent ${subagent_thread_id}:`, err);
|
|
11820
12343
|
});
|
|
@@ -11842,7 +12365,8 @@ The result will be delivered as a notification when complete. Do not poll.`,
|
|
|
11842
12365
|
runConfig: {
|
|
11843
12366
|
...config.configurable?.runConfig,
|
|
11844
12367
|
assistant_id,
|
|
11845
|
-
thread_id: subagent_thread_id
|
|
12368
|
+
thread_id: subagent_thread_id,
|
|
12369
|
+
taskId: input.taskId
|
|
11846
12370
|
}
|
|
11847
12371
|
});
|
|
11848
12372
|
const result = workerResult.finalState?.values;
|
|
@@ -11870,18 +12394,21 @@ The result will be delivered as a notification when complete. Do not poll.`,
|
|
|
11870
12394
|
{
|
|
11871
12395
|
name: "task",
|
|
11872
12396
|
description: finalTaskDescription,
|
|
11873
|
-
schema:
|
|
11874
|
-
description:
|
|
11875
|
-
subagent_type:
|
|
12397
|
+
schema: z43.object({
|
|
12398
|
+
description: z43.string().describe("The task to execute with the selected agent"),
|
|
12399
|
+
subagent_type: z43.string().describe(
|
|
11876
12400
|
`Name of the agent to use. Available: ${Object.keys(
|
|
11877
12401
|
subagentGraphs
|
|
11878
12402
|
).join(", ")}`
|
|
11879
12403
|
),
|
|
11880
12404
|
...allowAsync ? {
|
|
11881
|
-
async:
|
|
12405
|
+
async: z43.boolean().default(false).describe(
|
|
11882
12406
|
"When true, runs the task in the background and returns immediately. Use for independent tasks that can run in parallel. The result is delivered as a notification when complete. Use check_async_task or list_async_tasks to monitor progress."
|
|
11883
12407
|
)
|
|
11884
|
-
} : {}
|
|
12408
|
+
} : {},
|
|
12409
|
+
taskId: z43.string().optional().describe(
|
|
12410
|
+
"Optional: ID of a TaskItem created via manage_task. When set, the subagent will update this task's status as it works. Use this when executing a persistent task from the task board."
|
|
12411
|
+
)
|
|
11885
12412
|
})
|
|
11886
12413
|
}
|
|
11887
12414
|
);
|
|
@@ -11897,7 +12424,7 @@ function getMainAgentFromConfig(config) {
|
|
|
11897
12424
|
});
|
|
11898
12425
|
}
|
|
11899
12426
|
function createCheckAsyncTaskTool() {
|
|
11900
|
-
return
|
|
12427
|
+
return tool40(
|
|
11901
12428
|
async (input, config) => {
|
|
11902
12429
|
const { task_id } = input;
|
|
11903
12430
|
const mainAgent = getMainAgentFromConfig(config);
|
|
@@ -11957,14 +12484,14 @@ Description: ${cached.description}`;
|
|
|
11957
12484
|
{
|
|
11958
12485
|
name: "check_async_task",
|
|
11959
12486
|
description: "Get the current status and result of an async background task. Use this to check if a previously launched async task has completed.",
|
|
11960
|
-
schema:
|
|
11961
|
-
task_id:
|
|
12487
|
+
schema: z43.object({
|
|
12488
|
+
task_id: z43.string().describe("The task ID returned when the async task was started")
|
|
11962
12489
|
})
|
|
11963
12490
|
}
|
|
11964
12491
|
);
|
|
11965
12492
|
}
|
|
11966
12493
|
function createListAsyncTasksTool() {
|
|
11967
|
-
return
|
|
12494
|
+
return tool40(
|
|
11968
12495
|
async (_input, config) => {
|
|
11969
12496
|
const mainAgent = getMainAgentFromConfig(config);
|
|
11970
12497
|
if (!mainAgent) {
|
|
@@ -12010,12 +12537,12 @@ function createListAsyncTasksTool() {
|
|
|
12010
12537
|
{
|
|
12011
12538
|
name: "list_async_tasks",
|
|
12012
12539
|
description: "List all async background tasks with their current status. Use this before reporting task status to the user. Statuses in conversation history may be stale.",
|
|
12013
|
-
schema:
|
|
12540
|
+
schema: z43.object({})
|
|
12014
12541
|
}
|
|
12015
12542
|
);
|
|
12016
12543
|
}
|
|
12017
12544
|
function createCancelAsyncTaskTool() {
|
|
12018
|
-
return
|
|
12545
|
+
return tool40(
|
|
12019
12546
|
async (input, config) => {
|
|
12020
12547
|
const { task_id } = input;
|
|
12021
12548
|
const mainAgent = getMainAgentFromConfig(config);
|
|
@@ -12054,8 +12581,8 @@ function createCancelAsyncTaskTool() {
|
|
|
12054
12581
|
{
|
|
12055
12582
|
name: "cancel_async_task",
|
|
12056
12583
|
description: "Cancel a running async background task.",
|
|
12057
|
-
schema:
|
|
12058
|
-
task_id:
|
|
12584
|
+
schema: z43.object({
|
|
12585
|
+
task_id: z43.string().describe("The task ID to cancel")
|
|
12059
12586
|
})
|
|
12060
12587
|
}
|
|
12061
12588
|
);
|
|
@@ -12091,7 +12618,7 @@ function createSubAgentMiddleware(options) {
|
|
|
12091
12618
|
);
|
|
12092
12619
|
}
|
|
12093
12620
|
const effectiveSystemPrompt = allowAsync ? systemPrompt + getAsyncPromptText() : systemPrompt;
|
|
12094
|
-
return
|
|
12621
|
+
return createMiddleware10({
|
|
12095
12622
|
name: "subAgentMiddleware",
|
|
12096
12623
|
tools: allTools,
|
|
12097
12624
|
wrapModelCall: async (request, handler) => {
|
|
@@ -12112,12 +12639,12 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
|
|
|
12112
12639
|
|
|
12113
12640
|
// src/deep_agent_new/middleware/patch_tool_calls.ts
|
|
12114
12641
|
import {
|
|
12115
|
-
createMiddleware as
|
|
12642
|
+
createMiddleware as createMiddleware11,
|
|
12116
12643
|
ToolMessage as ToolMessage4,
|
|
12117
12644
|
AIMessage as AIMessage2
|
|
12118
12645
|
} from "langchain";
|
|
12119
12646
|
function createPatchToolCallsMiddleware() {
|
|
12120
|
-
return
|
|
12647
|
+
return createMiddleware11({
|
|
12121
12648
|
name: "patchToolCallsMiddleware",
|
|
12122
12649
|
beforeAgent: async (state) => {
|
|
12123
12650
|
const messages = state.messages;
|
|
@@ -12158,8 +12685,8 @@ function createPatchToolCallsMiddleware() {
|
|
|
12158
12685
|
}
|
|
12159
12686
|
|
|
12160
12687
|
// src/deep_agent_new/middleware/date.ts
|
|
12161
|
-
import { createMiddleware as
|
|
12162
|
-
import { z as
|
|
12688
|
+
import { createMiddleware as createMiddleware12, tool as tool41 } from "langchain";
|
|
12689
|
+
import { z as z44 } from "zod";
|
|
12163
12690
|
function formatCurrentDate(timezone = "UTC") {
|
|
12164
12691
|
const now = /* @__PURE__ */ new Date();
|
|
12165
12692
|
let validTimezone = timezone;
|
|
@@ -12187,10 +12714,10 @@ function generateDateContext(timezone = "UTC") {
|
|
|
12187
12714
|
function createDateMiddleware(options = {}) {
|
|
12188
12715
|
const timezone = options.timezone || "UTC";
|
|
12189
12716
|
const dateContext = generateDateContext(timezone);
|
|
12190
|
-
return
|
|
12717
|
+
return createMiddleware12({
|
|
12191
12718
|
name: "DateMiddleware",
|
|
12192
12719
|
tools: [
|
|
12193
|
-
|
|
12720
|
+
tool41(
|
|
12194
12721
|
async () => {
|
|
12195
12722
|
const now = /* @__PURE__ */ new Date();
|
|
12196
12723
|
let validTimezone = timezone;
|
|
@@ -12220,7 +12747,7 @@ function createDateMiddleware(options = {}) {
|
|
|
12220
12747
|
{
|
|
12221
12748
|
name: "get_current_date_time",
|
|
12222
12749
|
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.",
|
|
12223
|
-
schema:
|
|
12750
|
+
schema: z44.object({})
|
|
12224
12751
|
}
|
|
12225
12752
|
)
|
|
12226
12753
|
],
|
|
@@ -12285,8 +12812,8 @@ var datePlugin = {
|
|
|
12285
12812
|
};
|
|
12286
12813
|
|
|
12287
12814
|
// src/deep_agent_new/middleware/scheduler.ts
|
|
12288
|
-
import { tool as
|
|
12289
|
-
import { z as
|
|
12815
|
+
import { tool as tool42, createMiddleware as createMiddleware13 } from "langchain";
|
|
12816
|
+
import { z as z45 } from "zod";
|
|
12290
12817
|
import { v4 as uuidv43 } from "uuid";
|
|
12291
12818
|
import { ScheduledTaskStatus as ScheduledTaskStatus3, ScheduleExecutionType as ScheduleExecutionType3 } from "@axiom-lattice/protocols";
|
|
12292
12819
|
|
|
@@ -13288,7 +13815,7 @@ var getScheduleLattice = (key4) => scheduleLatticeManager.getScheduleLattice(key
|
|
|
13288
13815
|
// src/deep_agent_new/middleware/scheduler.ts
|
|
13289
13816
|
var SCHEDULE_LATTICE_KEY = "default";
|
|
13290
13817
|
var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
|
|
13291
|
-
function
|
|
13818
|
+
function getRunConfig2(config) {
|
|
13292
13819
|
const configurable = config;
|
|
13293
13820
|
return configurable?.configurable?.runConfig ?? {};
|
|
13294
13821
|
}
|
|
@@ -13360,12 +13887,12 @@ function registerAgentAddMessageHandler() {
|
|
|
13360
13887
|
function createSchedulerMiddleware(options = {}) {
|
|
13361
13888
|
const defaultMaxRetries = options.defaultMaxRetries ?? 0;
|
|
13362
13889
|
registerAgentAddMessageHandler();
|
|
13363
|
-
return
|
|
13890
|
+
return createMiddleware13({
|
|
13364
13891
|
name: "SchedulerMiddleware",
|
|
13365
13892
|
tools: [
|
|
13366
|
-
|
|
13893
|
+
tool42(
|
|
13367
13894
|
async (input, config) => {
|
|
13368
|
-
const runConfig =
|
|
13895
|
+
const runConfig = getRunConfig2(config);
|
|
13369
13896
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13370
13897
|
const taskId = uuidv43();
|
|
13371
13898
|
const executeAt = input.executeAt;
|
|
@@ -13391,16 +13918,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13391
13918
|
{
|
|
13392
13919
|
name: "schedule_at",
|
|
13393
13920
|
description: "Schedule a system message for an absolute future timestamp",
|
|
13394
|
-
schema:
|
|
13395
|
-
executeAt:
|
|
13396
|
-
maxRetries:
|
|
13397
|
-
message:
|
|
13921
|
+
schema: z45.object({
|
|
13922
|
+
executeAt: z45.number(),
|
|
13923
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
13924
|
+
message: z45.string()
|
|
13398
13925
|
})
|
|
13399
13926
|
}
|
|
13400
13927
|
),
|
|
13401
|
-
|
|
13928
|
+
tool42(
|
|
13402
13929
|
async (input, config) => {
|
|
13403
|
-
const runConfig =
|
|
13930
|
+
const runConfig = getRunConfig2(config);
|
|
13404
13931
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13405
13932
|
const taskId = uuidv43();
|
|
13406
13933
|
const executeAt = Date.now() + input.delayMs;
|
|
@@ -13426,16 +13953,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13426
13953
|
{
|
|
13427
13954
|
name: "schedule_after",
|
|
13428
13955
|
description: "Schedule a system message after a relative delay",
|
|
13429
|
-
schema:
|
|
13430
|
-
delayMs:
|
|
13431
|
-
maxRetries:
|
|
13432
|
-
message:
|
|
13956
|
+
schema: z45.object({
|
|
13957
|
+
delayMs: z45.number().positive(),
|
|
13958
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
13959
|
+
message: z45.string()
|
|
13433
13960
|
})
|
|
13434
13961
|
}
|
|
13435
13962
|
),
|
|
13436
|
-
|
|
13963
|
+
tool42(
|
|
13437
13964
|
async (input, config) => {
|
|
13438
|
-
const runConfig =
|
|
13965
|
+
const runConfig = getRunConfig2(config);
|
|
13439
13966
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13440
13967
|
const taskId = uuidv43();
|
|
13441
13968
|
const success = await scheduleLattice.client.scheduleCron(
|
|
@@ -13468,16 +13995,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13468
13995
|
{
|
|
13469
13996
|
name: "schedule_recurring",
|
|
13470
13997
|
description: "Schedule a recurring system message with a cron expression",
|
|
13471
|
-
schema:
|
|
13472
|
-
cronExpression:
|
|
13473
|
-
maxRuns:
|
|
13474
|
-
expiresAt:
|
|
13475
|
-
maxRetries:
|
|
13476
|
-
message:
|
|
13998
|
+
schema: z45.object({
|
|
13999
|
+
cronExpression: z45.string(),
|
|
14000
|
+
maxRuns: z45.number().int().positive().optional(),
|
|
14001
|
+
expiresAt: z45.number().optional(),
|
|
14002
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
14003
|
+
message: z45.string()
|
|
13477
14004
|
})
|
|
13478
14005
|
}
|
|
13479
14006
|
),
|
|
13480
|
-
|
|
14007
|
+
tool42(
|
|
13481
14008
|
async (input) => {
|
|
13482
14009
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13483
14010
|
const success = await scheduleLattice.client.cancel(input.taskId);
|
|
@@ -13486,14 +14013,14 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13486
14013
|
{
|
|
13487
14014
|
name: "cancel_scheduled_task",
|
|
13488
14015
|
description: "Cancel a scheduled task by task id",
|
|
13489
|
-
schema:
|
|
13490
|
-
taskId:
|
|
14016
|
+
schema: z45.object({
|
|
14017
|
+
taskId: z45.string()
|
|
13491
14018
|
})
|
|
13492
14019
|
}
|
|
13493
14020
|
),
|
|
13494
|
-
|
|
14021
|
+
tool42(
|
|
13495
14022
|
async (input, config) => {
|
|
13496
|
-
const runConfig =
|
|
14023
|
+
const runConfig = getRunConfig2(config);
|
|
13497
14024
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13498
14025
|
const storage = scheduleLattice.client.getStorage();
|
|
13499
14026
|
if (!storage) {
|
|
@@ -13513,11 +14040,11 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13513
14040
|
{
|
|
13514
14041
|
name: "list_scheduled_tasks",
|
|
13515
14042
|
description: "List scheduled tasks for the current agent context",
|
|
13516
|
-
schema:
|
|
13517
|
-
status:
|
|
13518
|
-
executionType:
|
|
13519
|
-
limit:
|
|
13520
|
-
offset:
|
|
14043
|
+
schema: z45.object({
|
|
14044
|
+
status: z45.enum(["pending", "running", "completed", "failed", "cancelled", "paused"]).optional(),
|
|
14045
|
+
executionType: z45.enum(["once", "cron"]).optional(),
|
|
14046
|
+
limit: z45.number().int().positive().optional(),
|
|
14047
|
+
offset: z45.number().int().min(0).optional()
|
|
13521
14048
|
})
|
|
13522
14049
|
}
|
|
13523
14050
|
)
|
|
@@ -14658,8 +15185,8 @@ var MemoryBackend = class {
|
|
|
14658
15185
|
|
|
14659
15186
|
// src/deep_agent_new/middleware/todos.ts
|
|
14660
15187
|
import { Command as Command4 } from "@langchain/langgraph";
|
|
14661
|
-
import { z as
|
|
14662
|
-
import { createMiddleware as
|
|
15188
|
+
import { z as z46 } from "zod";
|
|
15189
|
+
import { createMiddleware as createMiddleware14, tool as tool43, ToolMessage as ToolMessage5 } from "langchain";
|
|
14663
15190
|
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.
|
|
14664
15191
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
14665
15192
|
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.
|
|
@@ -14886,14 +15413,14 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
|
|
|
14886
15413
|
## Important To-Do List Usage Notes to Remember
|
|
14887
15414
|
- The \`write_todos\` tool should never be called multiple times in parallel.
|
|
14888
15415
|
- 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.`;
|
|
14889
|
-
var TodoStatus =
|
|
14890
|
-
var TodoSchema =
|
|
14891
|
-
content:
|
|
15416
|
+
var TodoStatus = z46.enum(["pending", "in_progress", "completed"]).describe("Status of the todo");
|
|
15417
|
+
var TodoSchema = z46.object({
|
|
15418
|
+
content: z46.string().describe("Content of the todo item"),
|
|
14892
15419
|
status: TodoStatus
|
|
14893
15420
|
});
|
|
14894
|
-
var stateSchema =
|
|
15421
|
+
var stateSchema = z46.object({ todos: z46.array(TodoSchema).default([]) });
|
|
14895
15422
|
function todoListMiddleware(options) {
|
|
14896
|
-
const writeTodos =
|
|
15423
|
+
const writeTodos = tool43(
|
|
14897
15424
|
({ todos }, config) => {
|
|
14898
15425
|
return new Command4({
|
|
14899
15426
|
update: {
|
|
@@ -14910,12 +15437,12 @@ function todoListMiddleware(options) {
|
|
|
14910
15437
|
{
|
|
14911
15438
|
name: "write_todos",
|
|
14912
15439
|
description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
|
|
14913
|
-
schema:
|
|
14914
|
-
todos:
|
|
15440
|
+
schema: z46.object({
|
|
15441
|
+
todos: z46.array(TodoSchema).describe("List of todo items to update")
|
|
14915
15442
|
})
|
|
14916
15443
|
}
|
|
14917
15444
|
);
|
|
14918
|
-
return
|
|
15445
|
+
return createMiddleware14({
|
|
14919
15446
|
name: "todoListMiddleware",
|
|
14920
15447
|
stateSchema,
|
|
14921
15448
|
tools: [writeTodos],
|
|
@@ -15068,7 +15595,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
15068
15595
|
};
|
|
15069
15596
|
|
|
15070
15597
|
// src/agent_team/agent_team.ts
|
|
15071
|
-
import { z as
|
|
15598
|
+
import { z as z49 } from "zod/v3";
|
|
15072
15599
|
import { createAgent as createAgent5 } from "langchain";
|
|
15073
15600
|
|
|
15074
15601
|
// src/agent_team/types.ts
|
|
@@ -15504,14 +16031,14 @@ var InMemoryMailboxStore = class {
|
|
|
15504
16031
|
};
|
|
15505
16032
|
|
|
15506
16033
|
// src/agent_team/middleware/team.ts
|
|
15507
|
-
import { z as
|
|
15508
|
-
import { createMiddleware as
|
|
16034
|
+
import { z as z48 } from "zod/v3";
|
|
16035
|
+
import { createMiddleware as createMiddleware15, createAgent as createAgent4, tool as tool45, ToolMessage as ToolMessage7 } from "langchain";
|
|
15509
16036
|
import { Command as Command6, getCurrentTaskInput as getCurrentTaskInput3 } from "@langchain/langgraph";
|
|
15510
16037
|
import { v4 as uuidv44 } from "uuid";
|
|
15511
16038
|
|
|
15512
16039
|
// src/agent_team/middleware/teammate_tools.ts
|
|
15513
|
-
import { z as
|
|
15514
|
-
import { tool as
|
|
16040
|
+
import { z as z47 } from "zod/v3";
|
|
16041
|
+
import { tool as tool44, ToolMessage as ToolMessage6 } from "langchain";
|
|
15515
16042
|
import { Command as Command5 } from "@langchain/langgraph";
|
|
15516
16043
|
|
|
15517
16044
|
// src/agent_team/middleware/formatMessages.ts
|
|
@@ -15536,7 +16063,7 @@ ${meta}${body}`;
|
|
|
15536
16063
|
// src/agent_team/middleware/teammate_tools.ts
|
|
15537
16064
|
function createTeammateTools(options) {
|
|
15538
16065
|
const { teamId, agentId, taskListStore, mailboxStore } = options;
|
|
15539
|
-
const claimTaskTool =
|
|
16066
|
+
const claimTaskTool = tool44(
|
|
15540
16067
|
async (input) => {
|
|
15541
16068
|
const task = await taskListStore.claimTaskById(
|
|
15542
16069
|
teamId,
|
|
@@ -15561,12 +16088,12 @@ function createTeammateTools(options) {
|
|
|
15561
16088
|
{
|
|
15562
16089
|
name: "claim_task",
|
|
15563
16090
|
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.",
|
|
15564
|
-
schema:
|
|
15565
|
-
task_id:
|
|
16091
|
+
schema: z47.object({
|
|
16092
|
+
task_id: z47.string().describe("ID of the task to claim (e.g. task-01). Use check_tasks to see IDs.")
|
|
15566
16093
|
})
|
|
15567
16094
|
}
|
|
15568
16095
|
);
|
|
15569
|
-
const completeTaskTool =
|
|
16096
|
+
const completeTaskTool = tool44(
|
|
15570
16097
|
async (input) => {
|
|
15571
16098
|
const task = await taskListStore.completeTask(
|
|
15572
16099
|
teamId,
|
|
@@ -15587,13 +16114,13 @@ function createTeammateTools(options) {
|
|
|
15587
16114
|
{
|
|
15588
16115
|
name: "complete_task",
|
|
15589
16116
|
description: "Mark a claimed task as completed with a result summary. Call this after you have finished working on a task.",
|
|
15590
|
-
schema:
|
|
15591
|
-
task_id:
|
|
15592
|
-
result:
|
|
16117
|
+
schema: z47.object({
|
|
16118
|
+
task_id: z47.string().describe("ID of the task to complete"),
|
|
16119
|
+
result: z47.string().describe("Summary of the task result")
|
|
15593
16120
|
})
|
|
15594
16121
|
}
|
|
15595
16122
|
);
|
|
15596
|
-
const failTaskTool =
|
|
16123
|
+
const failTaskTool = tool44(
|
|
15597
16124
|
async (input) => {
|
|
15598
16125
|
const task = await taskListStore.failTask(
|
|
15599
16126
|
teamId,
|
|
@@ -15614,13 +16141,13 @@ function createTeammateTools(options) {
|
|
|
15614
16141
|
{
|
|
15615
16142
|
name: "fail_task",
|
|
15616
16143
|
description: "Mark a claimed task as failed with an error description. Call this if you cannot complete the task.",
|
|
15617
|
-
schema:
|
|
15618
|
-
task_id:
|
|
15619
|
-
error:
|
|
16144
|
+
schema: z47.object({
|
|
16145
|
+
task_id: z47.string().describe("ID of the task to fail"),
|
|
16146
|
+
error: z47.string().describe("Description of why the task failed")
|
|
15620
16147
|
})
|
|
15621
16148
|
}
|
|
15622
16149
|
);
|
|
15623
|
-
const sendMessageTool =
|
|
16150
|
+
const sendMessageTool = tool44(
|
|
15624
16151
|
async (input) => {
|
|
15625
16152
|
await mailboxStore.sendMessage(
|
|
15626
16153
|
teamId,
|
|
@@ -15634,11 +16161,11 @@ function createTeammateTools(options) {
|
|
|
15634
16161
|
{
|
|
15635
16162
|
name: "send_message",
|
|
15636
16163
|
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.',
|
|
15637
|
-
schema:
|
|
15638
|
-
to:
|
|
16164
|
+
schema: z47.object({
|
|
16165
|
+
to: z47.string().describe(
|
|
15639
16166
|
'Recipient agent name (e.g. "team_lead" or a teammate name)'
|
|
15640
16167
|
),
|
|
15641
|
-
content:
|
|
16168
|
+
content: z47.string().describe("Message content")
|
|
15642
16169
|
})
|
|
15643
16170
|
}
|
|
15644
16171
|
);
|
|
@@ -15658,7 +16185,7 @@ function createTeammateTools(options) {
|
|
|
15658
16185
|
read: msg.read
|
|
15659
16186
|
}));
|
|
15660
16187
|
};
|
|
15661
|
-
const readMessagesTool =
|
|
16188
|
+
const readMessagesTool = tool44(
|
|
15662
16189
|
async (input, config) => {
|
|
15663
16190
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
15664
16191
|
for (const msg of msgs2) {
|
|
@@ -15717,10 +16244,10 @@ function createTeammateTools(options) {
|
|
|
15717
16244
|
{
|
|
15718
16245
|
name: "read_messages",
|
|
15719
16246
|
description: "Read unread messages from the mailbox. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
15720
|
-
schema:
|
|
16247
|
+
schema: z47.object({})
|
|
15721
16248
|
}
|
|
15722
16249
|
);
|
|
15723
|
-
const checkTasksTool =
|
|
16250
|
+
const checkTasksTool = tool44(
|
|
15724
16251
|
async () => {
|
|
15725
16252
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
15726
16253
|
return formatTaskSummary(tasks);
|
|
@@ -15728,10 +16255,10 @@ function createTeammateTools(options) {
|
|
|
15728
16255
|
{
|
|
15729
16256
|
name: "check_tasks",
|
|
15730
16257
|
description: "Use this tool to get the current status of all tasks in a team. This is your primary way to monitor task progress.",
|
|
15731
|
-
schema:
|
|
16258
|
+
schema: z47.object({})
|
|
15732
16259
|
}
|
|
15733
16260
|
);
|
|
15734
|
-
const broadcastMessageTool =
|
|
16261
|
+
const broadcastMessageTool = tool44(
|
|
15735
16262
|
async (input) => {
|
|
15736
16263
|
const allAgents = await mailboxStore.getRegisteredAgents(teamId);
|
|
15737
16264
|
const recipients = allAgents.filter((a) => a !== agentId);
|
|
@@ -15750,8 +16277,8 @@ function createTeammateTools(options) {
|
|
|
15750
16277
|
{
|
|
15751
16278
|
name: "broadcast_message",
|
|
15752
16279
|
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.",
|
|
15753
|
-
schema:
|
|
15754
|
-
content:
|
|
16280
|
+
schema: z47.object({
|
|
16281
|
+
content: z47.string().describe("Message content to broadcast to others")
|
|
15755
16282
|
})
|
|
15756
16283
|
}
|
|
15757
16284
|
);
|
|
@@ -15985,7 +16512,7 @@ async function spawnTeammate(options) {
|
|
|
15985
16512
|
function createTeamMiddleware(options) {
|
|
15986
16513
|
const { teamConfig, taskListStore, mailboxStore, tenantId: tenantId2 } = options;
|
|
15987
16514
|
const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
|
|
15988
|
-
const createTeamTool =
|
|
16515
|
+
const createTeamTool = tool45(
|
|
15989
16516
|
async (input, config) => {
|
|
15990
16517
|
const state = getCurrentTaskInput3();
|
|
15991
16518
|
if (state?.team?.teamId) {
|
|
@@ -16140,20 +16667,20 @@ After calling create_team, you MUST:
|
|
|
16140
16667
|
2. When messages indicate task changes, call check_tasks to get full task status
|
|
16141
16668
|
3. Continue until all tasks show "completed" or "failed"
|
|
16142
16669
|
4. Do NOT assume tasks are done - always verify with check_tasks`,
|
|
16143
|
-
schema:
|
|
16144
|
-
tasks:
|
|
16145
|
-
|
|
16146
|
-
id:
|
|
16147
|
-
title:
|
|
16148
|
-
description:
|
|
16149
|
-
dependencies:
|
|
16670
|
+
schema: z48.object({
|
|
16671
|
+
tasks: z48.array(
|
|
16672
|
+
z48.object({
|
|
16673
|
+
id: z48.string().describe("Task ID in format task-01, task-02, etc."),
|
|
16674
|
+
title: z48.string().describe("Short task title"),
|
|
16675
|
+
description: z48.string().describe("Detailed task description - what exactly needs to be done"),
|
|
16676
|
+
dependencies: z48.array(z48.string()).optional().default([]).describe('Array of task IDs that must complete before this task (e.g. ["task-01"])')
|
|
16150
16677
|
})
|
|
16151
16678
|
).describe("List of tasks for teammates to work on. Each task needs unique ID (task-01, task-02, etc.)."),
|
|
16152
|
-
teammates:
|
|
16153
|
-
|
|
16154
|
-
name:
|
|
16155
|
-
role:
|
|
16156
|
-
description:
|
|
16679
|
+
teammates: z48.array(
|
|
16680
|
+
z48.object({
|
|
16681
|
+
name: z48.string().describe("Teammate name (must match a pre-configured teammate type)"),
|
|
16682
|
+
role: z48.string().describe("Role category (e.g. researcher, writer, coder, reviewer)"),
|
|
16683
|
+
description: z48.string().describe("What this teammate will focus on - specific instructions for their work")
|
|
16157
16684
|
})
|
|
16158
16685
|
).describe("Teammate agents to create. Each should have a clear role and focus.")
|
|
16159
16686
|
})
|
|
@@ -16164,7 +16691,7 @@ After calling create_team, you MUST:
|
|
|
16164
16691
|
if (state?.team?.teamId) return state.team.teamId;
|
|
16165
16692
|
throw new Error("No team_id provided and no team in state. Call create_team first.");
|
|
16166
16693
|
};
|
|
16167
|
-
const addTasksTool =
|
|
16694
|
+
const addTasksTool = tool45(
|
|
16168
16695
|
async (input, config) => {
|
|
16169
16696
|
const teamId = resolveTeamId();
|
|
16170
16697
|
const created = await taskListStore.addTasks(
|
|
@@ -16216,20 +16743,20 @@ IMPORTANT: Dependencies
|
|
|
16216
16743
|
|
|
16217
16744
|
IMPORTANT: Assigning to a specific teammate
|
|
16218
16745
|
- 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.`,
|
|
16219
|
-
schema:
|
|
16220
|
-
tasks:
|
|
16221
|
-
|
|
16222
|
-
id:
|
|
16223
|
-
title:
|
|
16224
|
-
description:
|
|
16225
|
-
assignee:
|
|
16226
|
-
dependencies:
|
|
16746
|
+
schema: z48.object({
|
|
16747
|
+
tasks: z48.array(
|
|
16748
|
+
z48.object({
|
|
16749
|
+
id: z48.string().describe("Task ID in format task-01, task-02, etc. Must be unique."),
|
|
16750
|
+
title: z48.string().describe("Short task title"),
|
|
16751
|
+
description: z48.string().describe("Detailed task description - what needs to be done"),
|
|
16752
|
+
assignee: z48.string().optional().describe("Teammate name to assign this task to (use when you need that person to do the work)"),
|
|
16753
|
+
dependencies: z48.array(z48.string()).optional().default([]).describe("Array of task IDs that must complete before this task")
|
|
16227
16754
|
})
|
|
16228
16755
|
).describe("New tasks to add to the team")
|
|
16229
16756
|
})
|
|
16230
16757
|
}
|
|
16231
16758
|
);
|
|
16232
|
-
const assignTaskTool =
|
|
16759
|
+
const assignTaskTool = tool45(
|
|
16233
16760
|
async (input, config) => {
|
|
16234
16761
|
const teamId = resolveTeamId();
|
|
16235
16762
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16251,13 +16778,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16251
16778
|
{
|
|
16252
16779
|
name: "assign_task",
|
|
16253
16780
|
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.",
|
|
16254
|
-
schema:
|
|
16255
|
-
task_id:
|
|
16256
|
-
assignee:
|
|
16781
|
+
schema: z48.object({
|
|
16782
|
+
task_id: z48.string().describe("Task ID to assign"),
|
|
16783
|
+
assignee: z48.string().describe("Teammate name to assign this task to")
|
|
16257
16784
|
})
|
|
16258
16785
|
}
|
|
16259
16786
|
);
|
|
16260
|
-
const setTaskStatusTool =
|
|
16787
|
+
const setTaskStatusTool = tool45(
|
|
16261
16788
|
async (input, config) => {
|
|
16262
16789
|
const teamId = resolveTeamId();
|
|
16263
16790
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16279,13 +16806,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16279
16806
|
{
|
|
16280
16807
|
name: "set_task_status",
|
|
16281
16808
|
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.",
|
|
16282
|
-
schema:
|
|
16283
|
-
task_id:
|
|
16284
|
-
status:
|
|
16809
|
+
schema: z48.object({
|
|
16810
|
+
task_id: z48.string().describe("Task ID to update"),
|
|
16811
|
+
status: z48.enum(["pending", "claimed", "in_progress", "completed", "failed"]).describe("New status for the task")
|
|
16285
16812
|
})
|
|
16286
16813
|
}
|
|
16287
16814
|
);
|
|
16288
|
-
const setTaskDependenciesTool =
|
|
16815
|
+
const setTaskDependenciesTool = tool45(
|
|
16289
16816
|
async (input, config) => {
|
|
16290
16817
|
const teamId = resolveTeamId();
|
|
16291
16818
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16307,13 +16834,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16307
16834
|
{
|
|
16308
16835
|
name: "set_task_dependencies",
|
|
16309
16836
|
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.',
|
|
16310
|
-
schema:
|
|
16311
|
-
task_id:
|
|
16312
|
-
dependencies:
|
|
16837
|
+
schema: z48.object({
|
|
16838
|
+
task_id: z48.string().describe("Task ID to update"),
|
|
16839
|
+
dependencies: z48.array(z48.string()).describe("Task IDs that must complete before this task can be claimed")
|
|
16313
16840
|
})
|
|
16314
16841
|
}
|
|
16315
16842
|
);
|
|
16316
|
-
const checkTasksTool =
|
|
16843
|
+
const checkTasksTool = tool45(
|
|
16317
16844
|
async (input, config) => {
|
|
16318
16845
|
const teamId = resolveTeamId();
|
|
16319
16846
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
@@ -16353,12 +16880,12 @@ Task Status Values:
|
|
|
16353
16880
|
- in_progress: Teammate is actively working on this task
|
|
16354
16881
|
- completed: Task finished successfully
|
|
16355
16882
|
- failed: Task encountered an error`,
|
|
16356
|
-
schema:
|
|
16357
|
-
team_id:
|
|
16883
|
+
schema: z48.object({
|
|
16884
|
+
team_id: z48.string().optional().describe("Team ID (omit to use active team)")
|
|
16358
16885
|
})
|
|
16359
16886
|
}
|
|
16360
16887
|
);
|
|
16361
|
-
const sendMessageTool =
|
|
16888
|
+
const sendMessageTool = tool45(
|
|
16362
16889
|
async (input, config) => {
|
|
16363
16890
|
const teamId = resolveTeamId();
|
|
16364
16891
|
await mailboxStore.sendMessage(
|
|
@@ -16377,13 +16904,13 @@ Task Status Values:
|
|
|
16377
16904
|
{
|
|
16378
16905
|
name: "send_message",
|
|
16379
16906
|
description: "Send a message to a specific teammate in the team. Omit team_id to use the active team from state.",
|
|
16380
|
-
schema:
|
|
16381
|
-
to:
|
|
16382
|
-
content:
|
|
16907
|
+
schema: z48.object({
|
|
16908
|
+
to: z48.string().describe("Recipient teammate name"),
|
|
16909
|
+
content: z48.string().describe("Message content")
|
|
16383
16910
|
})
|
|
16384
16911
|
}
|
|
16385
16912
|
);
|
|
16386
|
-
const readMessagesTool =
|
|
16913
|
+
const readMessagesTool = tool45(
|
|
16387
16914
|
async (input, config) => {
|
|
16388
16915
|
const teamId = resolveTeamId();
|
|
16389
16916
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
@@ -16465,12 +16992,12 @@ Task Status Values:
|
|
|
16465
16992
|
{
|
|
16466
16993
|
name: "read_messages",
|
|
16467
16994
|
description: "Read unread messages from teammates. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
16468
|
-
schema:
|
|
16469
|
-
team_id:
|
|
16995
|
+
schema: z48.object({
|
|
16996
|
+
team_id: z48.string().optional().describe("Team ID (omit to use active team)")
|
|
16470
16997
|
})
|
|
16471
16998
|
}
|
|
16472
16999
|
);
|
|
16473
|
-
const disbandTeamTool =
|
|
17000
|
+
const disbandTeamTool = tool45(
|
|
16474
17001
|
async (input, config) => {
|
|
16475
17002
|
const teamId = resolveTeamId();
|
|
16476
17003
|
await mailboxStore.broadcastMessage(
|
|
@@ -16491,7 +17018,7 @@ Task Status Values:
|
|
|
16491
17018
|
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."
|
|
16492
17019
|
}
|
|
16493
17020
|
);
|
|
16494
|
-
const broadcastMessageTool =
|
|
17021
|
+
const broadcastMessageTool = tool45(
|
|
16495
17022
|
async (input, config) => {
|
|
16496
17023
|
const teamId = resolveTeamId();
|
|
16497
17024
|
await mailboxStore.broadcastMessage(
|
|
@@ -16509,12 +17036,12 @@ Task Status Values:
|
|
|
16509
17036
|
{
|
|
16510
17037
|
name: "broadcast_message",
|
|
16511
17038
|
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.",
|
|
16512
|
-
schema:
|
|
16513
|
-
content:
|
|
17039
|
+
schema: z48.object({
|
|
17040
|
+
content: z48.string().describe("Message content to broadcast to all teammates")
|
|
16514
17041
|
})
|
|
16515
17042
|
}
|
|
16516
17043
|
);
|
|
16517
|
-
return
|
|
17044
|
+
return createMiddleware15({
|
|
16518
17045
|
name: "teamMiddleware",
|
|
16519
17046
|
tools: [
|
|
16520
17047
|
createTeamTool,
|
|
@@ -16542,37 +17069,37 @@ ${TEAM_SYSTEM_PROMPT}` : TEAM_SYSTEM_PROMPT;
|
|
|
16542
17069
|
}
|
|
16543
17070
|
|
|
16544
17071
|
// src/agent_team/agent_team.ts
|
|
16545
|
-
var TeammateInfoSchema =
|
|
16546
|
-
name:
|
|
16547
|
-
role:
|
|
16548
|
-
description:
|
|
17072
|
+
var TeammateInfoSchema = z49.object({
|
|
17073
|
+
name: z49.string().describe("Teammate name"),
|
|
17074
|
+
role: z49.string().describe("Role category (e.g. research, writing, review)"),
|
|
17075
|
+
description: z49.string().describe("What this teammate focuses on")
|
|
16549
17076
|
});
|
|
16550
|
-
var TeamTaskInfoSchema =
|
|
16551
|
-
id:
|
|
16552
|
-
title:
|
|
16553
|
-
description:
|
|
16554
|
-
status:
|
|
17077
|
+
var TeamTaskInfoSchema = z49.object({
|
|
17078
|
+
id: z49.string(),
|
|
17079
|
+
title: z49.string(),
|
|
17080
|
+
description: z49.string(),
|
|
17081
|
+
status: z49.string().optional()
|
|
16555
17082
|
});
|
|
16556
|
-
var MailboxMessageSchema =
|
|
16557
|
-
id:
|
|
16558
|
-
from:
|
|
16559
|
-
to:
|
|
16560
|
-
content:
|
|
16561
|
-
timestamp:
|
|
16562
|
-
type:
|
|
16563
|
-
read:
|
|
17083
|
+
var MailboxMessageSchema = z49.object({
|
|
17084
|
+
id: z49.string().describe("Unique message identifier"),
|
|
17085
|
+
from: z49.string().describe("Sender agent name"),
|
|
17086
|
+
to: z49.string().describe("Recipient agent name"),
|
|
17087
|
+
content: z49.string().describe("Message content"),
|
|
17088
|
+
timestamp: z49.string().describe("ISO timestamp when the message was sent"),
|
|
17089
|
+
type: z49.nativeEnum(MessageType).describe("Message type"),
|
|
17090
|
+
read: z49.boolean().describe("Whether the recipient has read this message")
|
|
16564
17091
|
});
|
|
16565
|
-
var TeamInfoSchema =
|
|
16566
|
-
teamId:
|
|
16567
|
-
teamLeadId:
|
|
16568
|
-
teammates:
|
|
16569
|
-
tasks:
|
|
16570
|
-
createdAt:
|
|
17092
|
+
var TeamInfoSchema = z49.object({
|
|
17093
|
+
teamId: z49.string().describe("Unique team identifier"),
|
|
17094
|
+
teamLeadId: z49.string().default("team_lead").describe("Team lead agent ID"),
|
|
17095
|
+
teammates: z49.array(TeammateInfoSchema).describe("Active teammates in this team"),
|
|
17096
|
+
tasks: z49.array(TeamTaskInfoSchema).optional().describe("Initial tasks snapshot"),
|
|
17097
|
+
createdAt: z49.string().optional().describe("ISO timestamp when team was created")
|
|
16571
17098
|
});
|
|
16572
|
-
var TEAM_STATE_SCHEMA =
|
|
17099
|
+
var TEAM_STATE_SCHEMA = z49.object({
|
|
16573
17100
|
team: TeamInfoSchema.optional().describe("Team info: teamId, teamLeadId, teammates, tasks. Set when create_team succeeds."),
|
|
16574
|
-
tasks:
|
|
16575
|
-
team_mailbox:
|
|
17101
|
+
tasks: z49.array(TeamTaskInfoSchema).optional().describe("Current tasks snapshot from check_tasks. Updated on each check."),
|
|
17102
|
+
team_mailbox: z49.array(MailboxMessageSchema).optional().describe("All team mailbox messages for display")
|
|
16576
17103
|
});
|
|
16577
17104
|
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:
|
|
16578
17105
|
|
|
@@ -16695,7 +17222,7 @@ import { StateGraph as StateGraph2, MessagesAnnotation } from "@langchain/langgr
|
|
|
16695
17222
|
import { AIMessage as AIMessage3 } from "@langchain/core/messages";
|
|
16696
17223
|
|
|
16697
17224
|
// src/services/a2a-client.ts
|
|
16698
|
-
import { v4 as
|
|
17225
|
+
import { v4 as v43 } from "uuid";
|
|
16699
17226
|
var A2ARemoteError = class extends Error {
|
|
16700
17227
|
constructor(message, statusCode, body) {
|
|
16701
17228
|
super(message);
|
|
@@ -16742,7 +17269,7 @@ var A2ARemoteClient = class {
|
|
|
16742
17269
|
*/
|
|
16743
17270
|
async sendMessage(text) {
|
|
16744
17271
|
await this.resolve();
|
|
16745
|
-
const taskId =
|
|
17272
|
+
const taskId = v43();
|
|
16746
17273
|
const body = JSON.stringify({
|
|
16747
17274
|
jsonrpc: "2.0",
|
|
16748
17275
|
method: "tasks/send",
|
|
@@ -17528,6 +18055,22 @@ async function configureStores(stores, options = {}) {
|
|
|
17528
18055
|
storeLatticeManager.registerLattice("default", t, store);
|
|
17529
18056
|
}
|
|
17530
18057
|
}
|
|
18058
|
+
if (options.discoverPlugins) {
|
|
18059
|
+
const pluginTypes = PluginRegistry.list();
|
|
18060
|
+
for (const pluginType of pluginTypes) {
|
|
18061
|
+
const plugin = PluginRegistry.get(pluginType);
|
|
18062
|
+
if (!plugin?.stores) continue;
|
|
18063
|
+
for (const [storeType, storeOrFactory] of Object.entries(plugin.stores)) {
|
|
18064
|
+
const store = typeof storeOrFactory === "function" ? storeOrFactory() : storeOrFactory;
|
|
18065
|
+
await initAndRegister(store, localDisposables);
|
|
18066
|
+
const t = storeType;
|
|
18067
|
+
if (storeLatticeManager.hasLattice("default", t)) {
|
|
18068
|
+
storeLatticeManager.removeLattice("default", t);
|
|
18069
|
+
}
|
|
18070
|
+
storeLatticeManager.registerLattice("default", t, store);
|
|
18071
|
+
}
|
|
18072
|
+
}
|
|
18073
|
+
}
|
|
17531
18074
|
if (options.autoDisposeStores) {
|
|
17532
18075
|
registerSignalCleanup();
|
|
17533
18076
|
_disposables.push(...localDisposables);
|
|
@@ -17672,7 +18215,7 @@ description: Create new skills, modify and improve existing skills. Use this ski
|
|
|
17672
18215
|
license: MIT
|
|
17673
18216
|
metadata:
|
|
17674
18217
|
category: meta
|
|
17675
|
-
version: "
|
|
18218
|
+
version: "3.0"
|
|
17676
18219
|
---
|
|
17677
18220
|
|
|
17678
18221
|
# Skill Creator
|
|
@@ -17771,6 +18314,160 @@ Instructional content for the agent.
|
|
|
17771
18314
|
|
|
17772
18315
|
---
|
|
17773
18316
|
|
|
18317
|
+
## subSkills: Building the Skill Graph
|
|
18318
|
+
|
|
18319
|
+
\`subSkills\` is how skills reference each other. It forms a graph \u2014
|
|
18320
|
+
visualized in the Skills view as connected nodes.
|
|
18321
|
+
|
|
18322
|
+
### What subSkills Means
|
|
18323
|
+
|
|
18324
|
+
It declares: "this skill is conceptually composed of these sub-skills."
|
|
18325
|
+
It does NOT mean the agent automatically loads them. The agent reads the
|
|
18326
|
+
body and decides what to load next.
|
|
18327
|
+
|
|
18328
|
+
### When to Use subSkills
|
|
18329
|
+
|
|
18330
|
+
**YES \u2014 split into subSkills when another task would independently
|
|
18331
|
+
reference that piece.** The test:
|
|
18332
|
+
|
|
18333
|
+
> "Will a future learning task about a DIFFERENT document type
|
|
18334
|
+
> need to reference this?"
|
|
18335
|
+
|
|
18336
|
+
For example:
|
|
18337
|
+
- \`engine-selection\` \u2192 YES, PO extraction AND invoice extraction both need it
|
|
18338
|
+
- \`sap-bp-validation\` \u2192 YES, multiple tasks validate BP through SAP
|
|
18339
|
+
- \`po-bp-extraction\` \u2192 NO, nobody extracts BP without extracting the whole PO
|
|
18340
|
+
|
|
18341
|
+
**NO \u2014 keep in one file when the steps are a single pipeline that's
|
|
18342
|
+
always used together.** Field extraction, validation, and formatting
|
|
18343
|
+
for one document type belong in one skill file.
|
|
18344
|
+
|
|
18345
|
+
### Examples
|
|
18346
|
+
|
|
18347
|
+
Good (shared skills split out):
|
|
18348
|
+
\`\`\`yaml
|
|
18349
|
+
---
|
|
18350
|
+
name: po-extraction
|
|
18351
|
+
description: Extract BP, items, notes from PO PDFs with SAP validation
|
|
18352
|
+
subSkills:
|
|
18353
|
+
- engine-selection # Shared \u2014 also used by invoice-extraction
|
|
18354
|
+
---
|
|
18355
|
+
# Body describes the full PO extraction flow:
|
|
18356
|
+
# 1. Use [[engine-selection]] to pick best parser
|
|
18357
|
+
# 2. Find BP in document header
|
|
18358
|
+
# 3. Parse items table
|
|
18359
|
+
# ...
|
|
18360
|
+
|
|
18361
|
+
---
|
|
18362
|
+
name: engine-selection
|
|
18363
|
+
description: Choose the best parsing engine based on document type
|
|
18364
|
+
---
|
|
18365
|
+
# Body describes decision logic with confidence scores
|
|
18366
|
+
\`\`\`
|
|
18367
|
+
|
|
18368
|
+
Bad (over-split \u2014 these are never used independently):
|
|
18369
|
+
\`\`\`yaml
|
|
18370
|
+
---
|
|
18371
|
+
name: po-bp-extraction
|
|
18372
|
+
description: Extract BP field from PO
|
|
18373
|
+
subSkills: []
|
|
18374
|
+
---
|
|
18375
|
+
# This is always used with items-extraction and notes-extraction.
|
|
18376
|
+
# They should be one skill: po-extraction
|
|
18377
|
+
\`\`\`
|
|
18378
|
+
|
|
18379
|
+
### Growing the Graph
|
|
18380
|
+
|
|
18381
|
+
Skills are discovered incrementally. When a learning task produces
|
|
18382
|
+
new knowledge:
|
|
18383
|
+
|
|
18384
|
+
1. \`ls /root/.agents/knowledge/\` to see what already exists
|
|
18385
|
+
2. If a reusable piece already exists \u2192 reference it via subSkills
|
|
18386
|
+
3. If a reusable piece doesn't exist \u2192 create it, then reference it
|
|
18387
|
+
4. If it's not reusable \u2192 keep it in the parent skill's body
|
|
18388
|
+
|
|
18389
|
+
The graph grows naturally \u2014 each new learning task adds nodes
|
|
18390
|
+
and edges by creating skills and declaring subSkills.
|
|
18391
|
+
|
|
18392
|
+
---
|
|
18393
|
+
|
|
18394
|
+
## Verifying subSkills Are Correct
|
|
18395
|
+
|
|
18396
|
+
After writing the body, check consistency between frontmatter and content.
|
|
18397
|
+
You MUST run these checks before finalizing the skill.
|
|
18398
|
+
|
|
18399
|
+
### Self-Check Rules
|
|
18400
|
+
|
|
18401
|
+
**For each entry in subSkills:**
|
|
18402
|
+
Find where in the body it's actually referenced. If you can't find it \u2014
|
|
18403
|
+
either the body is missing the reference, or the subSkill shouldn't
|
|
18404
|
+
be there.
|
|
18405
|
+
|
|
18406
|
+
**For each skill referenced in the body:**
|
|
18407
|
+
Check that it appears in subSkills. If the body references a skill
|
|
18408
|
+
but subSkills doesn't list it \u2014 add it.
|
|
18409
|
+
|
|
18410
|
+
### Automated Consistency Check
|
|
18411
|
+
|
|
18412
|
+
Since body references use \`[[skill-name]]\` format, you can verify
|
|
18413
|
+
automatically:
|
|
18414
|
+
|
|
18415
|
+
\`\`\`bash
|
|
18416
|
+
# Extract all skill references from body
|
|
18417
|
+
grep -oE '\\[\\[[^]]+\\]\\]' /root/.agents/skills/{skill-name}/SKILL.md \\
|
|
18418
|
+
| sed 's/\\[\\[//;s/\\]\\]//' | sort -u
|
|
18419
|
+
|
|
18420
|
+
# Then compare with the subSkills list in frontmatter.
|
|
18421
|
+
# Every [[ref]] in body should have a corresponding subSkills entry.
|
|
18422
|
+
# Every subSkills entry should appear as [[ref]] somewhere in body.
|
|
18423
|
+
\`\`\`
|
|
18424
|
+
|
|
18425
|
+
### Quick Checklist Before Writing
|
|
18426
|
+
|
|
18427
|
+
1. List all subSkills in frontmatter
|
|
18428
|
+
2. grep the body for each name using \`[[name]]\` format \u2014 does it appear?
|
|
18429
|
+
3. grep the body for \`[[...]]\` patterns \u2014 are they all in subSkills?
|
|
18430
|
+
4. Mismatches \u2192 fix either the body or the frontmatter
|
|
18431
|
+
5. Remove any subSkills entry that's never referenced in the body
|
|
18432
|
+
|
|
18433
|
+
---
|
|
18434
|
+
|
|
18435
|
+
## Referencing Other Skills in the Body
|
|
18436
|
+
|
|
18437
|
+
When the body instructs the agent to consult another skill,
|
|
18438
|
+
use the \`[[skill-name]]\` format:
|
|
18439
|
+
|
|
18440
|
+
\`\`\`markdown
|
|
18441
|
+
## Procedure
|
|
18442
|
+
|
|
18443
|
+
1. First, use [[engine-selection]] to pick the best parsing engine
|
|
18444
|
+
2. Load [[sap-bp-validation]] to verify the extracted Business Partner
|
|
18445
|
+
3. For edge cases, refer to [[ocr-fallback]]
|
|
18446
|
+
|
|
18447
|
+
## Dependencies
|
|
18448
|
+
|
|
18449
|
+
This skill depends on:
|
|
18450
|
+
- [[engine-selection]] \u2014 chooses the parsing engine
|
|
18451
|
+
- [[sap-bp-validation]] \u2014 validates BP codes against SAP
|
|
18452
|
+
\`\`\`
|
|
18453
|
+
|
|
18454
|
+
### Why [[wiki-links]]
|
|
18455
|
+
|
|
18456
|
+
- **Visually distinct** \u2014 clearly not regular text
|
|
18457
|
+
- **Grepable** \u2014 \`grep -o '\\[\\[.*?\\]\\]'\` extracts all references
|
|
18458
|
+
- **Verifiable** \u2014 the consistency check against subSkills can be automated
|
|
18459
|
+
- **Human-readable** \u2014 anyone reading the SKILL.md knows this is a skill reference
|
|
18460
|
+
|
|
18461
|
+
### Rules
|
|
18462
|
+
- Always use the exact skill name (kebab-case) inside \`[[]]\`
|
|
18463
|
+
- Before writing, check each referenced skill:
|
|
18464
|
+
- If it exists \u2014 reference it directly
|
|
18465
|
+
- If it doesn't exist \u2014 create it first, then reference it in the parent
|
|
18466
|
+
- Every \`[[ref]]\` in the body must have a corresponding \`subSkills\` entry
|
|
18467
|
+
- Every \`subSkills\` entry must appear as \`[[ref]]\` somewhere in the body
|
|
18468
|
+
|
|
18469
|
+
---
|
|
18470
|
+
|
|
17774
18471
|
## Writing Guide
|
|
17775
18472
|
|
|
17776
18473
|
### The Description Field
|
|
@@ -17821,6 +18518,7 @@ A well-written skill body typically includes:
|
|
|
17821
18518
|
- **Guidelines**: Rules, constraints, quality standards, and the WHY behind them
|
|
17822
18519
|
- **Scenarios**: 2-3 common scenarios with concrete examples of inputs and expected outputs
|
|
17823
18520
|
- **Edge cases**: What to do when things go wrong, when data is missing, etc.
|
|
18521
|
+
- **Skill references**: Use \`[[skill-name]]\` to reference other skills \u2014 see the subSkills section above
|
|
17824
18522
|
|
|
17825
18523
|
---
|
|
17826
18524
|
|
|
@@ -17828,10 +18526,11 @@ A well-written skill body typically includes:
|
|
|
17828
18526
|
|
|
17829
18527
|
After writing the draft, test it:
|
|
17830
18528
|
|
|
17831
|
-
1. **
|
|
17832
|
-
2. **
|
|
17833
|
-
3. **
|
|
17834
|
-
4. **
|
|
18529
|
+
1. **Run the consistency check** from the Verifying subSkills section \u2014 fix any mismatches
|
|
18530
|
+
2. **Create 2-3 test prompts** \u2014 the kind of thing a real user would actually say. Share them with the user: "Here are a few test cases I'd like to try. Do these look right?"
|
|
18531
|
+
3. **Run the skill** against each test prompt to see what the agent produces
|
|
18532
|
+
4. **Review outputs with the user**: evaluate both qualitatively (does the output look right?) and quantitatively (did it follow the workflow? use the right tools?)
|
|
18533
|
+
5. **Collect feedback**: What worked? What didn't? What surprised the user?
|
|
17835
18534
|
|
|
17836
18535
|
### Improving the Skill
|
|
17837
18536
|
|
|
@@ -17867,10 +18566,11 @@ The agent sees skills as a list of name + description pairs. It decides whether
|
|
|
17867
18566
|
## Step 6: Package and Present
|
|
17868
18567
|
|
|
17869
18568
|
When the skill is ready:
|
|
17870
|
-
1.
|
|
17871
|
-
2.
|
|
17872
|
-
3.
|
|
17873
|
-
4.
|
|
18569
|
+
1. Run the subSkills consistency check one final time
|
|
18570
|
+
2. Verify the SKILL.md is at \`/root/.agents/skills/{skill-name}/SKILL.md\` with correct frontmatter
|
|
18571
|
+
3. Confirm all resource files are in place under \`resources/\`
|
|
18572
|
+
4. Tell the user the skill is ready and available at its path
|
|
18573
|
+
5. Remind them that the skill will now appear in the available skills list for any agent using the skill system
|
|
17874
18574
|
|
|
17875
18575
|
## Updating Existing Skills
|
|
17876
18576
|
|
|
@@ -17879,7 +18579,8 @@ When the user wants to improve an existing skill:
|
|
|
17879
18579
|
2. Understand what it currently does and where it falls short
|
|
17880
18580
|
3. Follow the same interview \u2192 draft \u2192 test \u2192 iterate loop
|
|
17881
18581
|
4. **Preserve the original name** \u2014 the directory name and \`name\` frontmatter field should stay the same
|
|
17882
|
-
5.
|
|
18582
|
+
5. Run the subSkills consistency check after making changes
|
|
18583
|
+
6. Write the updated version back to the same path
|
|
17883
18584
|
|
|
17884
18585
|
---
|
|
17885
18586
|
|
|
@@ -17913,6 +18614,8 @@ metadata:
|
|
|
17913
18614
|
|
|
17914
18615
|
**You** (write): Create \`/root/.agents/skills/csv-analyzer/SKILL.md\`
|
|
17915
18616
|
|
|
18617
|
+
**You** (verify): Run the subSkills consistency check \u2014 no subSkills, no \`[[refs]]\`, all good.
|
|
18618
|
+
|
|
17916
18619
|
**You** (test): "Here are 3 test cases \u2014 'summarize this sales CSV', 'filter rows where region is West', 'show monthly revenue trends'. Let me run these and we'll review."
|
|
17917
18620
|
|
|
17918
18621
|
Then iterate based on what the user says.
|
|
@@ -18972,8 +19675,8 @@ var InMemoryMenuStore = class {
|
|
|
18972
19675
|
};
|
|
18973
19676
|
|
|
18974
19677
|
// src/agent_lattice/agentArchitectTools.ts
|
|
18975
|
-
import
|
|
18976
|
-
import { v4 as
|
|
19678
|
+
import z50 from "zod";
|
|
19679
|
+
import { v4 as v44 } from "uuid";
|
|
18977
19680
|
import { AgentType as AgentType3 } from "@axiom-lattice/protocols";
|
|
18978
19681
|
function getTenantId(exeConfig) {
|
|
18979
19682
|
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
@@ -19002,7 +19705,7 @@ registerToolLattice(
|
|
|
19002
19705
|
{
|
|
19003
19706
|
name: "list_agents",
|
|
19004
19707
|
description: "List all agents for the current workspace. Returns a summary with id, name, description, and type for each agent.",
|
|
19005
|
-
schema:
|
|
19708
|
+
schema: z50.object({})
|
|
19006
19709
|
},
|
|
19007
19710
|
async (_input, exeConfig) => {
|
|
19008
19711
|
try {
|
|
@@ -19029,8 +19732,8 @@ registerToolLattice(
|
|
|
19029
19732
|
{
|
|
19030
19733
|
name: "get_agent",
|
|
19031
19734
|
description: "Get the full configuration of a specific agent by its ID. Returns the complete AgentConfig including prompt, middleware, tools, and sub-agents.",
|
|
19032
|
-
schema:
|
|
19033
|
-
id:
|
|
19735
|
+
schema: z50.object({
|
|
19736
|
+
id: z50.string().describe("The agent ID to retrieve")
|
|
19034
19737
|
})
|
|
19035
19738
|
},
|
|
19036
19739
|
async (input, exeConfig) => {
|
|
@@ -19047,24 +19750,24 @@ registerToolLattice(
|
|
|
19047
19750
|
}
|
|
19048
19751
|
}
|
|
19049
19752
|
);
|
|
19050
|
-
var middlewareConfigSchema =
|
|
19051
|
-
id:
|
|
19052
|
-
type:
|
|
19053
|
-
name:
|
|
19054
|
-
description:
|
|
19055
|
-
enabled:
|
|
19056
|
-
config:
|
|
19753
|
+
var middlewareConfigSchema = z50.object({
|
|
19754
|
+
id: z50.string(),
|
|
19755
|
+
type: z50.string(),
|
|
19756
|
+
name: z50.string(),
|
|
19757
|
+
description: z50.string(),
|
|
19758
|
+
enabled: z50.boolean(),
|
|
19759
|
+
config: z50.record(z50.any()).optional()
|
|
19057
19760
|
});
|
|
19058
|
-
var createAgentSchema =
|
|
19059
|
-
name:
|
|
19060
|
-
description:
|
|
19061
|
-
type:
|
|
19062
|
-
prompt:
|
|
19063
|
-
tools:
|
|
19064
|
-
middleware:
|
|
19065
|
-
subAgents:
|
|
19066
|
-
internalSubAgents:
|
|
19067
|
-
modelKey:
|
|
19761
|
+
var createAgentSchema = z50.object({
|
|
19762
|
+
name: z50.string().describe("Human-friendly display name for the agent. The machine ID (used in other tools) is auto-generated as a slug from this name (e.g. 'My Cool Agent' \u2192 'my-cool-agent')."),
|
|
19763
|
+
description: z50.string().optional().describe("Short description"),
|
|
19764
|
+
type: z50.enum(["react", "deep_agent"]).describe("Agent type. Use 'react' for simple single-responsibility agents, 'deep_agent' for complex open-ended agents. For PROCESSING agents (workflow orchestration), use create_processing_agent instead."),
|
|
19765
|
+
prompt: z50.string().describe("System prompt for the agent"),
|
|
19766
|
+
tools: z50.array(z50.string()).optional().describe("Tool keys (strings) to assign. Call list_tools first to see available keys. Each element is a plain string like 'sap_api_search'. IMPORTANT: tools is a FLAT string array of tool names. Do NOT put middleware-like objects here \u2014 middleware goes in the separate 'middleware' field."),
|
|
19767
|
+
middleware: z50.array(middlewareConfigSchema).optional().describe("Middleware configuration objects. Each has {id, type, name, description, enabled, config}. IMPORTANT: middleware objects are NOT tools. Do NOT put tool keys (strings) here \u2014 tool names go in the separate 'tools' array. For user approval/confirmation scenarios, use type: 'ask_user_to_clarify' with config: {}."),
|
|
19768
|
+
subAgents: z50.array(z50.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
|
|
19769
|
+
internalSubAgents: z50.array(z50.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
|
|
19770
|
+
modelKey: z50.string().optional().describe("Model key to use")
|
|
19068
19771
|
});
|
|
19069
19772
|
registerToolLattice(
|
|
19070
19773
|
"create_agent",
|
|
@@ -19102,14 +19805,14 @@ registerToolLattice(
|
|
|
19102
19805
|
}
|
|
19103
19806
|
}
|
|
19104
19807
|
);
|
|
19105
|
-
var createWorkflowSchema =
|
|
19106
|
-
name:
|
|
19107
|
-
description:
|
|
19108
|
-
skillLoaded:
|
|
19109
|
-
yaml:
|
|
19110
|
-
tools:
|
|
19111
|
-
middleware:
|
|
19112
|
-
modelKey:
|
|
19808
|
+
var createWorkflowSchema = z50.object({
|
|
19809
|
+
name: z50.string().describe("Display name for the workflow agent"),
|
|
19810
|
+
description: z50.string().optional().describe("Short description"),
|
|
19811
|
+
skillLoaded: z50.literal(true).describe("MUST be true. Set after loading the 'create-workflow' skill."),
|
|
19812
|
+
yaml: z50.string().describe("The YAML workflow definition in linear DSL format (steps execute top-to-bottom, use parallel: for concurrency)"),
|
|
19813
|
+
tools: z50.array(z50.string()).optional().describe("Tool keys for the workflow agent"),
|
|
19814
|
+
middleware: z50.array(middlewareConfigSchema).optional().describe("Middleware configs"),
|
|
19815
|
+
modelKey: z50.string().optional().describe("Model key")
|
|
19113
19816
|
});
|
|
19114
19817
|
registerToolLattice(
|
|
19115
19818
|
"create_workflow",
|
|
@@ -19158,8 +19861,8 @@ registerToolLattice(
|
|
|
19158
19861
|
{
|
|
19159
19862
|
name: "validate_workflow",
|
|
19160
19863
|
description: "Validate a workflow agent's DSL for correctness by compiling it.",
|
|
19161
|
-
schema:
|
|
19162
|
-
id:
|
|
19864
|
+
schema: z50.object({
|
|
19865
|
+
id: z50.string().describe("The workflow agent ID to validate")
|
|
19163
19866
|
})
|
|
19164
19867
|
},
|
|
19165
19868
|
async (input, exeConfig) => {
|
|
@@ -19256,14 +19959,14 @@ registerToolLattice(
|
|
|
19256
19959
|
}
|
|
19257
19960
|
}
|
|
19258
19961
|
);
|
|
19259
|
-
var updateWorkflowSchema =
|
|
19260
|
-
id:
|
|
19261
|
-
name:
|
|
19262
|
-
description:
|
|
19263
|
-
yaml:
|
|
19264
|
-
tools:
|
|
19265
|
-
middleware:
|
|
19266
|
-
modelKey:
|
|
19962
|
+
var updateWorkflowSchema = z50.object({
|
|
19963
|
+
id: z50.string().describe("The workflow agent ID to update"),
|
|
19964
|
+
name: z50.string().optional().describe("New display name"),
|
|
19965
|
+
description: z50.string().optional().describe("New description"),
|
|
19966
|
+
yaml: z50.string().optional().describe("Replacement YAML workflow DSL. Omit to keep existing."),
|
|
19967
|
+
tools: z50.array(z50.string()).optional().describe("Replacement tool keys"),
|
|
19968
|
+
middleware: z50.array(middlewareConfigSchema).optional().describe("Replacement middleware configs"),
|
|
19969
|
+
modelKey: z50.string().optional().describe("Replacement model key")
|
|
19267
19970
|
});
|
|
19268
19971
|
registerToolLattice(
|
|
19269
19972
|
"update_workflow",
|
|
@@ -19324,18 +20027,18 @@ registerToolLattice(
|
|
|
19324
20027
|
}
|
|
19325
20028
|
}
|
|
19326
20029
|
);
|
|
19327
|
-
var updateAgentSchema =
|
|
19328
|
-
id:
|
|
19329
|
-
config:
|
|
19330
|
-
name:
|
|
19331
|
-
description:
|
|
19332
|
-
type:
|
|
19333
|
-
prompt:
|
|
19334
|
-
tools:
|
|
19335
|
-
middleware:
|
|
19336
|
-
subAgents:
|
|
19337
|
-
internalSubAgents:
|
|
19338
|
-
modelKey:
|
|
20030
|
+
var updateAgentSchema = z50.object({
|
|
20031
|
+
id: z50.string().describe("The agent ID to update"),
|
|
20032
|
+
config: z50.object({
|
|
20033
|
+
name: z50.string().optional().describe("New display name for the agent"),
|
|
20034
|
+
description: z50.string().optional().describe("New short description"),
|
|
20035
|
+
type: z50.enum(["react", "deep_agent"]).optional().describe("Agent type"),
|
|
20036
|
+
prompt: z50.string().optional().describe("New system prompt for the agent"),
|
|
20037
|
+
tools: z50.array(z50.string()).optional().describe("Tool keys to assign to this agent. These are registered tool names (strings), NOT middleware objects."),
|
|
20038
|
+
middleware: z50.array(middlewareConfigSchema).optional().describe("Middleware configurations. NOTE: middleware objects have type/name/description/enabled/config fields and are NOT the same as tools. Tool keys go in the 'tools' array. For user approval/confirmation scenarios, use type: 'ask_user_to_clarify' with config: {}."),
|
|
20039
|
+
subAgents: z50.array(z50.string()).optional().describe("Sub-agent IDs (deep_agent only)"),
|
|
20040
|
+
internalSubAgents: z50.array(z50.any()).optional().describe("Inline sub-agent configs (deep_agent only)"),
|
|
20041
|
+
modelKey: z50.string().optional().describe("Model key to use")
|
|
19339
20042
|
}).describe("Configuration fields to update. Only include the fields you want to change.")
|
|
19340
20043
|
});
|
|
19341
20044
|
registerToolLattice(
|
|
@@ -19373,8 +20076,8 @@ registerToolLattice(
|
|
|
19373
20076
|
{
|
|
19374
20077
|
name: "delete_agent",
|
|
19375
20078
|
description: "Permanently delete an agent by its ID. This action cannot be undone.",
|
|
19376
|
-
schema:
|
|
19377
|
-
id:
|
|
20079
|
+
schema: z50.object({
|
|
20080
|
+
id: z50.string().describe("The agent ID to delete")
|
|
19378
20081
|
})
|
|
19379
20082
|
},
|
|
19380
20083
|
async (input, exeConfig) => {
|
|
@@ -19400,7 +20103,7 @@ registerToolLattice(
|
|
|
19400
20103
|
{
|
|
19401
20104
|
name: "list_tools",
|
|
19402
20105
|
description: "List all available tools that can be assigned to agents. Returns each tool's name (use this string value in the 'tools' array), description, and whether it requires user approval. The tool names from this list are what you pass as strings in the 'tools' field of create_agent or update_agent.",
|
|
19403
|
-
schema:
|
|
20106
|
+
schema: z50.object({})
|
|
19404
20107
|
},
|
|
19405
20108
|
async (_input, _exeConfig) => {
|
|
19406
20109
|
try {
|
|
@@ -19422,9 +20125,9 @@ registerToolLattice(
|
|
|
19422
20125
|
{
|
|
19423
20126
|
name: "invoke_agent",
|
|
19424
20127
|
description: "Invoke an agent with a test message and return its response. Use this to verify an agent works correctly after creating or modifying it. The agent must be compiled (already created and valid).",
|
|
19425
|
-
schema:
|
|
19426
|
-
id:
|
|
19427
|
-
message:
|
|
20128
|
+
schema: z50.object({
|
|
20129
|
+
id: z50.string().describe("The agent ID to invoke"),
|
|
20130
|
+
message: z50.string().describe("The test message to send to the agent")
|
|
19428
20131
|
})
|
|
19429
20132
|
},
|
|
19430
20133
|
async (input, exeConfig) => {
|
|
@@ -19439,7 +20142,7 @@ registerToolLattice(
|
|
|
19439
20142
|
if (!existing) {
|
|
19440
20143
|
return JSON.stringify({ error: `Agent '${id}' not found` });
|
|
19441
20144
|
}
|
|
19442
|
-
const threadId =
|
|
20145
|
+
const threadId = v44();
|
|
19443
20146
|
const agent = new Agent({
|
|
19444
20147
|
tenant_id: tenantId2,
|
|
19445
20148
|
assistant_id: id,
|
|
@@ -19460,7 +20163,7 @@ registerToolLattice(
|
|
|
19460
20163
|
{
|
|
19461
20164
|
name: "list_middleware_types",
|
|
19462
20165
|
description: "\u5217\u51FA\u5F53\u524D\u7CFB\u7EDF\u4E2D\u6240\u6709\u53EF\u7528\u7684\u4E2D\u95F4\u4EF6\u7C7B\u578B\uFF08Middlewares\uFF09\uFF0C\u5305\u62EC\u5185\u7F6E\u548C\u81EA\u5B9A\u4E49\u63D2\u4EF6\u3002\u8FD4\u56DE\u6BCF\u4E2A\u4E2D\u95F4\u4EF6\u7684 type\u3001name\u3001description\u3001tools \u6E05\u5355\uFF08\u652F\u6301 allowedTools \u8FC7\u6EE4\uFF09\u3001configSchema\uFF08\u914D\u7F6E\u9762\u677F\u9700\u8981\u54EA\u4E9B\u5B57\u6BB5\uFF09\u548C connectionSchema\uFF08\u662F\u5426\u652F\u6301\u8FDE\u63A5\u6D4B\u8BD5\u548C\u8D44\u6E90\u53D1\u73B0\uFF09\u3002\n\n\u4F7F\u7528\u573A\u666F\uFF1A\n1. \u5728\u521B\u5EFA agent \u524D\uFF0C\u5148\u8C03\u6B64\u5DE5\u5177\u4E86\u89E3\u6709\u54EA\u4E9B\u4E2D\u95F4\u4EF6\u53EF\u914D\u7F6E\n2. \u6839\u636E configSchema \u51B3\u5B9A\u9700\u8981\u63D0\u4F9B\u54EA\u4E9B\u914D\u7F6E\u5B57\u6BB5\uFF08\u5982 databaseKeys\u3001connections \u7B49\uFF09\n3. \u5982\u679C\u67D0\u4E2A\u4E2D\u95F4\u4EF6\u7684 connectionSchema \u5B58\u5728\uFF0C\u8BF4\u660E\u5B83\u662F\u8FDE\u63A5\u578B\u4E2D\u95F4\u4EF6\uFF0C\u9700\u8981\u518D\u8C03 list_connections \u83B7\u53D6\u53EF\u7528\u8FDE\u63A5\n4. \u7528\u8FD4\u56DE\u7684 type \u5B57\u6BB5\u6784\u5EFA middleware \u6570\u7EC4\u4F20\u7ED9 create_agent / update_agent",
|
|
19463
|
-
schema:
|
|
20166
|
+
schema: z50.object({})
|
|
19464
20167
|
},
|
|
19465
20168
|
async () => {
|
|
19466
20169
|
const metas = PluginRegistry.listMeta();
|
|
@@ -19472,8 +20175,8 @@ registerToolLattice(
|
|
|
19472
20175
|
{
|
|
19473
20176
|
name: "list_connections",
|
|
19474
20177
|
description: "\u5217\u51FA\u6307\u5B9A\u63D2\u4EF6\u7C7B\u578B\u7684\u6240\u6709\u5DF2\u914D\u7F6E\u8FDE\u63A5\u3002\u7528\u4E8E\u67E5\u8BE2\u6709\u54EA\u4E9B\u53EF\u7528\u7684\u8FDE\u63A5\u5B9E\u4F8B\uFF08\u5982 'sap-prod', 'sap-dev'\uFF09\uFF0C\u65B9\u4FBF\u5728 agent \u914D\u7F6E\u4E2D\u9009\u62E9\u5177\u4F53\u8FDE\u63A5\u3002\n\n\u4F7F\u7528\u573A\u666F\uFF1A\n1. \u5148\u8C03 list_middleware_types \u786E\u5B9A\u67D0\u4E2A\u4E2D\u95F4\u4EF6\u662F\u8FDE\u63A5\u578B\uFF08\u6709 connectionSchema\uFF09\n2. \u8C03\u6B64\u5DE5\u5177\u4F20\u5165 type\uFF08\u5982 'erp'\uFF09\uFF0C\u83B7\u53D6\u8BE5\u7C7B\u578B\u4E0B\u5DF2\u914D\u597D\u7684\u8FDE\u63A5\u5217\u8868\n3. \u5728 create_agent \u7684 middleware[i].config.connections \u4E2D\u586B\u5165\u5BF9\u5E94\u7684 key \u503C\n\n\u8FD4\u56DE\u683C\u5F0F\uFF1A{ success: true, data: { records: [{ key, name, ... }] } }",
|
|
19475
|
-
schema:
|
|
19476
|
-
type:
|
|
20178
|
+
schema: z50.object({
|
|
20179
|
+
type: z50.string().describe("\u63D2\u4EF6\u7C7B\u578B\u6807\u8BC6\uFF0C\u5982 'erp'\u3002\u4ECE list_middleware_types \u7684\u8FD4\u56DE\u4E2D\u83B7\u53D6")
|
|
19477
20180
|
}),
|
|
19478
20181
|
needUserApprove: false
|
|
19479
20182
|
},
|
|
@@ -20054,6 +20757,20 @@ function ensureBuiltinAgentsForTenant(tenantId2) {
|
|
|
20054
20757
|
}
|
|
20055
20758
|
}
|
|
20056
20759
|
|
|
20760
|
+
// src/agent_lattice/pluginAgents.ts
|
|
20761
|
+
function ensurePluginAgentsForTenant(tenantId2) {
|
|
20762
|
+
const pluginTypes = PluginRegistry.list();
|
|
20763
|
+
for (const pluginType of pluginTypes) {
|
|
20764
|
+
const plugin = PluginRegistry.get(pluginType);
|
|
20765
|
+
if (!plugin?.agents) continue;
|
|
20766
|
+
for (const [key4, config] of Object.entries(plugin.agents)) {
|
|
20767
|
+
if (!agentLatticeManager.hasWithTenant(tenantId2, key4)) {
|
|
20768
|
+
agentLatticeManager.registerLatticeWithTenant(tenantId2, config);
|
|
20769
|
+
}
|
|
20770
|
+
}
|
|
20771
|
+
}
|
|
20772
|
+
}
|
|
20773
|
+
|
|
20057
20774
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
20058
20775
|
function assistantToConfig(assistant) {
|
|
20059
20776
|
const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? { ...assistant.graphDefinition } : {};
|
|
@@ -20252,6 +20969,7 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
20252
20969
|
*/
|
|
20253
20970
|
async initializeStoredAssistantsForTenant(tenantId2) {
|
|
20254
20971
|
ensureBuiltinAgentsForTenant(tenantId2);
|
|
20972
|
+
ensurePluginAgentsForTenant(tenantId2);
|
|
20255
20973
|
try {
|
|
20256
20974
|
const storeLattice = getStoreLattice("default", "assistant");
|
|
20257
20975
|
const assistants = await storeLattice.store.getAllAssistants(tenantId2);
|
|
@@ -23426,8 +24144,8 @@ function clearEvalRunService() {
|
|
|
23426
24144
|
}
|
|
23427
24145
|
|
|
23428
24146
|
// src/eval_lattice/LatticeEval.ts
|
|
23429
|
-
import { HumanMessage as
|
|
23430
|
-
import { v4 as
|
|
24147
|
+
import { HumanMessage as HumanMessage4 } from "@langchain/core/messages";
|
|
24148
|
+
import { v4 as v45 } from "uuid";
|
|
23431
24149
|
var _LatticeEval = class _LatticeEval {
|
|
23432
24150
|
constructor(config = {}) {
|
|
23433
24151
|
this.inMemoryLogs = [];
|
|
@@ -23567,7 +24285,7 @@ var _LatticeEval = class _LatticeEval {
|
|
|
23567
24285
|
}
|
|
23568
24286
|
async evaluateCase(evalCase) {
|
|
23569
24287
|
const startedAt = Date.now();
|
|
23570
|
-
const threadId = `${evalCase.caseId}||${
|
|
24288
|
+
const threadId = `${evalCase.caseId}||${v45()}`;
|
|
23571
24289
|
this.inMemoryLogs = [];
|
|
23572
24290
|
this.lastThreadId = threadId;
|
|
23573
24291
|
this.lastJudgeThreadId = void 0;
|
|
@@ -23709,7 +24427,7 @@ ${rubricsSection}
|
|
|
23709
24427
|
|
|
23710
24428
|
\u6CE8\u610F\uFF1A\u5982\u679C final_score >= 80 \u4E14\u6CA1\u6709\u81F4\u547D\u6027\u9519\u8BEF\uFF0Cpass \u5E94\u4E3A true\uFF1B\u5426\u5219\u4E3A false\u3002`;
|
|
23711
24429
|
this.lastTestPrompt = testPrompt;
|
|
23712
|
-
const judgeThreadId =
|
|
24430
|
+
const judgeThreadId = v45();
|
|
23713
24431
|
this.lastJudgeThreadId = judgeThreadId;
|
|
23714
24432
|
const judgeAgentKey = this.config.judge_agent_key || "LatticeTest";
|
|
23715
24433
|
const judgeTenantId = this.config.tenant_id || "default";
|
|
@@ -23717,7 +24435,7 @@ ${rubricsSection}
|
|
|
23717
24435
|
const judgeAgent = await getAgentClient(judgeTenantId, judgeAgentKey);
|
|
23718
24436
|
const testResponse = await judgeAgent.invoke(
|
|
23719
24437
|
{
|
|
23720
|
-
messages: [new
|
|
24438
|
+
messages: [new HumanMessage4(testPrompt)]
|
|
23721
24439
|
},
|
|
23722
24440
|
{
|
|
23723
24441
|
configurable: {
|
|
@@ -24309,15 +25027,15 @@ function clearEncryptionKeyCache() {
|
|
|
24309
25027
|
}
|
|
24310
25028
|
|
|
24311
25029
|
// src/middlewares/skillMiddleware.ts
|
|
24312
|
-
import { createMiddleware as
|
|
25030
|
+
import { createMiddleware as createMiddleware16 } from "langchain";
|
|
24313
25031
|
|
|
24314
25032
|
// src/tool_lattice/skill/load_skills.ts
|
|
24315
|
-
import z50 from "zod";
|
|
24316
|
-
import { tool as tool45 } from "langchain";
|
|
24317
|
-
|
|
24318
|
-
// src/tool_lattice/skill/load_skill_content.ts
|
|
24319
25033
|
import z51 from "zod";
|
|
24320
25034
|
import { tool as tool46 } from "langchain";
|
|
25035
|
+
|
|
25036
|
+
// src/tool_lattice/skill/load_skill_content.ts
|
|
25037
|
+
import z52 from "zod";
|
|
25038
|
+
import { tool as tool47 } from "langchain";
|
|
24321
25039
|
var LOAD_SKILL_CONTENT_DESCRIPTION = `
|
|
24322
25040
|
Execute a skill within the main conversation
|
|
24323
25041
|
|
|
@@ -24355,7 +25073,7 @@ function getSandboxFromExeConfig(_exe_config) {
|
|
|
24355
25073
|
});
|
|
24356
25074
|
}
|
|
24357
25075
|
var createLoadSkillContentTool = (pluginSkillContents) => {
|
|
24358
|
-
return
|
|
25076
|
+
return tool47(
|
|
24359
25077
|
async (input, _exe_config) => {
|
|
24360
25078
|
try {
|
|
24361
25079
|
if (pluginSkillContents?.[input.skill_name]) {
|
|
@@ -24404,8 +25122,8 @@ var createLoadSkillContentTool = (pluginSkillContents) => {
|
|
|
24404
25122
|
{
|
|
24405
25123
|
name: "skill",
|
|
24406
25124
|
description: LOAD_SKILL_CONTENT_DESCRIPTION,
|
|
24407
|
-
schema:
|
|
24408
|
-
skill_name:
|
|
25125
|
+
schema: z52.object({
|
|
25126
|
+
skill_name: z52.string().describe("The name of the skill to load")
|
|
24409
25127
|
})
|
|
24410
25128
|
}
|
|
24411
25129
|
);
|
|
@@ -24419,7 +25137,7 @@ function createSkillMiddleware(params = {}) {
|
|
|
24419
25137
|
} = params;
|
|
24420
25138
|
const skills = params.skills;
|
|
24421
25139
|
let latestSkills = [];
|
|
24422
|
-
return
|
|
25140
|
+
return createMiddleware16({
|
|
24423
25141
|
name: "skillMiddleware",
|
|
24424
25142
|
contextSchema,
|
|
24425
25143
|
tools: [
|
|
@@ -24551,17 +25269,17 @@ var skillPlugin = {
|
|
|
24551
25269
|
};
|
|
24552
25270
|
|
|
24553
25271
|
// src/middlewares/collectionMiddleware.ts
|
|
24554
|
-
import { createMiddleware as
|
|
25272
|
+
import { createMiddleware as createMiddleware17 } from "langchain";
|
|
24555
25273
|
|
|
24556
25274
|
// src/tool_lattice/collection/list_collections.ts
|
|
24557
|
-
import
|
|
24558
|
-
import { tool as
|
|
25275
|
+
import z53 from "zod";
|
|
25276
|
+
import { tool as tool48 } from "langchain";
|
|
24559
25277
|
var LIST_COLLECTIONS_DESCRIPTION = `List all available collections for the current tenant. Returns collection names, labels, and field definitions (including field types and enum values). Use this tool to discover what collections are available before searching.`;
|
|
24560
25278
|
var createListCollectionsTool = ({
|
|
24561
25279
|
collectionKeys,
|
|
24562
25280
|
connectAll
|
|
24563
25281
|
}) => {
|
|
24564
|
-
return
|
|
25282
|
+
return tool48(
|
|
24565
25283
|
async (_input, _exeConfig) => {
|
|
24566
25284
|
try {
|
|
24567
25285
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24595,23 +25313,23 @@ var createListCollectionsTool = ({
|
|
|
24595
25313
|
{
|
|
24596
25314
|
name: "list_collections",
|
|
24597
25315
|
description: LIST_COLLECTIONS_DESCRIPTION,
|
|
24598
|
-
schema:
|
|
25316
|
+
schema: z53.object({})
|
|
24599
25317
|
}
|
|
24600
25318
|
);
|
|
24601
25319
|
};
|
|
24602
25320
|
|
|
24603
25321
|
// src/tool_lattice/collection/search_collection.ts
|
|
24604
|
-
import
|
|
24605
|
-
import { tool as
|
|
25322
|
+
import z54 from "zod";
|
|
25323
|
+
import { tool as tool49 } from "langchain";
|
|
24606
25324
|
var SEARCH_COLLECTION_DESCRIPTION = `Search for content within a specific collection using semantic (vector) similarity. Use the 'filter' parameter to narrow results by metadata fields (e.g., {"category": "cardiovascular"}). Returns the most relevant content entries with similarity scores.`;
|
|
24607
|
-
var searchSchema =
|
|
24608
|
-
collection:
|
|
24609
|
-
query:
|
|
24610
|
-
filter:
|
|
24611
|
-
top_k:
|
|
25325
|
+
var searchSchema = z54.object({
|
|
25326
|
+
collection: z54.string().describe("The collection name to search in"),
|
|
25327
|
+
query: z54.string().describe("The search query text"),
|
|
25328
|
+
filter: z54.record(z54.unknown()).optional().describe("Metadata filter conditions"),
|
|
25329
|
+
top_k: z54.number().optional().default(5).describe("Number of results to return")
|
|
24612
25330
|
});
|
|
24613
25331
|
var createSearchCollectionTool = () => {
|
|
24614
|
-
return
|
|
25332
|
+
return tool49(
|
|
24615
25333
|
async (input, _exeConfig) => {
|
|
24616
25334
|
try {
|
|
24617
25335
|
const { collection, query, filter: filter2, top_k } = input;
|
|
@@ -24661,10 +25379,10 @@ var createSearchCollectionTool = () => {
|
|
|
24661
25379
|
};
|
|
24662
25380
|
|
|
24663
25381
|
// src/tool_lattice/collection/get_collection.ts
|
|
24664
|
-
import
|
|
24665
|
-
import { tool as
|
|
25382
|
+
import z55 from "zod";
|
|
25383
|
+
import { tool as tool50 } from "langchain";
|
|
24666
25384
|
var GET_COLLECTION_DESCRIPTION = `Get a collection's full definition including its custom fields schema. Use this to discover what metadata fields are available before adding entries.`;
|
|
24667
|
-
var createGetCollectionTool = () =>
|
|
25385
|
+
var createGetCollectionTool = () => tool50(
|
|
24668
25386
|
async (input, _exeConfig) => {
|
|
24669
25387
|
try {
|
|
24670
25388
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24687,24 +25405,24 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
|
|
|
24687
25405
|
return `Error: ${error.message}`;
|
|
24688
25406
|
}
|
|
24689
25407
|
},
|
|
24690
|
-
{ name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema:
|
|
25408
|
+
{ name: "get_collection", description: GET_COLLECTION_DESCRIPTION, schema: z55.object({ name: z55.string().describe("Collection name") }) }
|
|
24691
25409
|
);
|
|
24692
25410
|
|
|
24693
25411
|
// src/tool_lattice/collection/create_collection.ts
|
|
24694
|
-
import
|
|
24695
|
-
import { tool as
|
|
24696
|
-
var createSchema =
|
|
24697
|
-
name:
|
|
24698
|
-
label:
|
|
24699
|
-
embeddingKey:
|
|
24700
|
-
fields:
|
|
24701
|
-
key:
|
|
24702
|
-
type:
|
|
24703
|
-
enumValues:
|
|
24704
|
-
required:
|
|
25412
|
+
import z56 from "zod";
|
|
25413
|
+
import { tool as tool51 } from "langchain";
|
|
25414
|
+
var createSchema = z56.object({
|
|
25415
|
+
name: z56.string().describe("Collection name (lowercase, underscores only)"),
|
|
25416
|
+
label: z56.string().describe("Display name"),
|
|
25417
|
+
embeddingKey: z56.string().describe("Embedding model key"),
|
|
25418
|
+
fields: z56.array(z56.object({
|
|
25419
|
+
key: z56.string().describe("Field key name"),
|
|
25420
|
+
type: z56.enum(["string", "number", "enum"]).describe("Field data type"),
|
|
25421
|
+
enumValues: z56.array(z56.string()).optional().describe("Valid values for enum type"),
|
|
25422
|
+
required: z56.boolean().optional().default(false).describe("Whether field is required")
|
|
24705
25423
|
})).optional().describe("Custom field definitions for entries in this collection")
|
|
24706
25424
|
});
|
|
24707
|
-
var createCreateCollectionTool = () =>
|
|
25425
|
+
var createCreateCollectionTool = () => tool51(
|
|
24708
25426
|
async (input, _exeConfig) => {
|
|
24709
25427
|
try {
|
|
24710
25428
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24729,20 +25447,20 @@ var createCreateCollectionTool = () => tool50(
|
|
|
24729
25447
|
);
|
|
24730
25448
|
|
|
24731
25449
|
// src/tool_lattice/collection/update_collection.ts
|
|
24732
|
-
import
|
|
24733
|
-
import { tool as
|
|
24734
|
-
var schema =
|
|
24735
|
-
name:
|
|
24736
|
-
label:
|
|
24737
|
-
embeddingKey:
|
|
24738
|
-
fields:
|
|
24739
|
-
key:
|
|
24740
|
-
type:
|
|
24741
|
-
enumValues:
|
|
24742
|
-
required:
|
|
25450
|
+
import z57 from "zod";
|
|
25451
|
+
import { tool as tool52 } from "langchain";
|
|
25452
|
+
var schema = z57.object({
|
|
25453
|
+
name: z57.string().describe("Collection name"),
|
|
25454
|
+
label: z57.string().optional().describe("New display name"),
|
|
25455
|
+
embeddingKey: z57.string().optional().describe("New embedding model key"),
|
|
25456
|
+
fields: z57.array(z57.object({
|
|
25457
|
+
key: z57.string().describe("Field key name"),
|
|
25458
|
+
type: z57.enum(["string", "number", "enum"]).describe("Field data type"),
|
|
25459
|
+
enumValues: z57.array(z57.string()).optional().describe("Valid values for enum type"),
|
|
25460
|
+
required: z57.boolean().optional().default(false).describe("Whether field is required")
|
|
24743
25461
|
})).optional().describe("Custom field definitions for entries (replaces existing schema)")
|
|
24744
25462
|
});
|
|
24745
|
-
var createUpdateCollectionTool = () =>
|
|
25463
|
+
var createUpdateCollectionTool = () => tool52(
|
|
24746
25464
|
async (input, _exeConfig) => {
|
|
24747
25465
|
try {
|
|
24748
25466
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24761,9 +25479,9 @@ var createUpdateCollectionTool = () => tool51(
|
|
|
24761
25479
|
);
|
|
24762
25480
|
|
|
24763
25481
|
// src/tool_lattice/collection/delete_collection.ts
|
|
24764
|
-
import
|
|
24765
|
-
import { tool as
|
|
24766
|
-
var createDeleteCollectionTool = () =>
|
|
25482
|
+
import z58 from "zod";
|
|
25483
|
+
import { tool as tool53 } from "langchain";
|
|
25484
|
+
var createDeleteCollectionTool = () => tool53(
|
|
24767
25485
|
async (input, _exeConfig) => {
|
|
24768
25486
|
try {
|
|
24769
25487
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24773,19 +25491,19 @@ var createDeleteCollectionTool = () => tool52(
|
|
|
24773
25491
|
return `Error: ${e.message}`;
|
|
24774
25492
|
}
|
|
24775
25493
|
},
|
|
24776
|
-
{ name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema:
|
|
25494
|
+
{ name: "delete_collection", description: `Delete a collection and all its entries. This cannot be undone.`, schema: z58.object({ name: z58.string().describe("Collection name") }) }
|
|
24777
25495
|
);
|
|
24778
25496
|
|
|
24779
25497
|
// src/tool_lattice/collection/list_entries.ts
|
|
24780
|
-
import
|
|
24781
|
-
import { tool as
|
|
24782
|
-
var schema2 =
|
|
24783
|
-
collection:
|
|
25498
|
+
import z59 from "zod";
|
|
25499
|
+
import { tool as tool54 } from "langchain";
|
|
25500
|
+
var schema2 = z59.object({
|
|
25501
|
+
collection: z59.string().describe("Collection name")
|
|
24784
25502
|
});
|
|
24785
25503
|
function buildKey2(tenantId2, name) {
|
|
24786
25504
|
return `${tenantId2}:${name}`;
|
|
24787
25505
|
}
|
|
24788
|
-
var createListEntriesTool = () =>
|
|
25506
|
+
var createListEntriesTool = () => tool54(
|
|
24789
25507
|
async (input, _exeConfig) => {
|
|
24790
25508
|
try {
|
|
24791
25509
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24812,19 +25530,19 @@ var createListEntriesTool = () => tool53(
|
|
|
24812
25530
|
);
|
|
24813
25531
|
|
|
24814
25532
|
// src/tool_lattice/collection/add_entry.ts
|
|
24815
|
-
import
|
|
24816
|
-
import { tool as
|
|
25533
|
+
import z60 from "zod";
|
|
25534
|
+
import { tool as tool55 } from "langchain";
|
|
24817
25535
|
import { Document } from "@langchain/core/documents";
|
|
24818
25536
|
import { v4 as uuidv45 } from "uuid";
|
|
24819
|
-
var schema3 =
|
|
24820
|
-
collection:
|
|
24821
|
-
content:
|
|
24822
|
-
metadata:
|
|
25537
|
+
var schema3 = z60.object({
|
|
25538
|
+
collection: z60.string().describe("Collection name"),
|
|
25539
|
+
content: z60.string().describe("Entry content text"),
|
|
25540
|
+
metadata: z60.record(z60.unknown()).optional().describe("Metadata fields matching the collection schema")
|
|
24823
25541
|
});
|
|
24824
25542
|
function key(t, n) {
|
|
24825
25543
|
return `${t}:${n}`;
|
|
24826
25544
|
}
|
|
24827
|
-
var createAddEntryTool = () =>
|
|
25545
|
+
var createAddEntryTool = () => tool55(
|
|
24828
25546
|
async (input, _exeConfig) => {
|
|
24829
25547
|
try {
|
|
24830
25548
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24843,18 +25561,18 @@ var createAddEntryTool = () => tool54(
|
|
|
24843
25561
|
);
|
|
24844
25562
|
|
|
24845
25563
|
// src/tool_lattice/collection/update_entry.ts
|
|
24846
|
-
import
|
|
24847
|
-
import { tool as
|
|
24848
|
-
var schema4 =
|
|
24849
|
-
collection:
|
|
24850
|
-
entryId:
|
|
24851
|
-
content:
|
|
24852
|
-
metadata:
|
|
25564
|
+
import z61 from "zod";
|
|
25565
|
+
import { tool as tool56 } from "langchain";
|
|
25566
|
+
var schema4 = z61.object({
|
|
25567
|
+
collection: z61.string().describe("Collection name"),
|
|
25568
|
+
entryId: z61.string().describe("Entry ID to update"),
|
|
25569
|
+
content: z61.string().optional().describe("New content"),
|
|
25570
|
+
metadata: z61.record(z61.unknown()).optional().describe("New metadata")
|
|
24853
25571
|
});
|
|
24854
25572
|
function key2(t, n) {
|
|
24855
25573
|
return `${t}:${n}`;
|
|
24856
25574
|
}
|
|
24857
|
-
var createUpdateEntryTool = () =>
|
|
25575
|
+
var createUpdateEntryTool = () => tool56(
|
|
24858
25576
|
async (input, _exeConfig) => {
|
|
24859
25577
|
try {
|
|
24860
25578
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24873,16 +25591,16 @@ var createUpdateEntryTool = () => tool55(
|
|
|
24873
25591
|
);
|
|
24874
25592
|
|
|
24875
25593
|
// src/tool_lattice/collection/delete_entry.ts
|
|
24876
|
-
import
|
|
24877
|
-
import { tool as
|
|
24878
|
-
var schema5 =
|
|
24879
|
-
collection:
|
|
24880
|
-
entryId:
|
|
25594
|
+
import z62 from "zod";
|
|
25595
|
+
import { tool as tool57 } from "langchain";
|
|
25596
|
+
var schema5 = z62.object({
|
|
25597
|
+
collection: z62.string().describe("Collection name"),
|
|
25598
|
+
entryId: z62.string().describe("Entry ID to delete")
|
|
24881
25599
|
});
|
|
24882
25600
|
function key3(t, n) {
|
|
24883
25601
|
return `${t}:${n}`;
|
|
24884
25602
|
}
|
|
24885
|
-
var createDeleteEntryTool = () =>
|
|
25603
|
+
var createDeleteEntryTool = () => tool57(
|
|
24886
25604
|
async (input, _exeConfig) => {
|
|
24887
25605
|
try {
|
|
24888
25606
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24900,7 +25618,7 @@ var createDeleteEntryTool = () => tool56(
|
|
|
24900
25618
|
function createCollectionMiddleware(params) {
|
|
24901
25619
|
const { collectionKeys, connectAll } = params;
|
|
24902
25620
|
if (!connectAll && (!collectionKeys || collectionKeys.length === 0)) {
|
|
24903
|
-
return
|
|
25621
|
+
return createMiddleware17({
|
|
24904
25622
|
name: "collectionMiddleware",
|
|
24905
25623
|
contextSchema,
|
|
24906
25624
|
tools: [
|
|
@@ -24910,7 +25628,7 @@ function createCollectionMiddleware(params) {
|
|
|
24910
25628
|
});
|
|
24911
25629
|
}
|
|
24912
25630
|
const listToolParams = { collectionKeys, connectAll };
|
|
24913
|
-
return
|
|
25631
|
+
return createMiddleware17({
|
|
24914
25632
|
name: "collectionMiddleware",
|
|
24915
25633
|
contextSchema,
|
|
24916
25634
|
tools: [
|
|
@@ -24971,24 +25689,24 @@ var collectionPlugin = {
|
|
|
24971
25689
|
};
|
|
24972
25690
|
|
|
24973
25691
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
24974
|
-
import { createMiddleware as
|
|
25692
|
+
import { createMiddleware as createMiddleware18, ToolMessage as ToolMessage8 } from "langchain";
|
|
24975
25693
|
import { GraphInterrupt as GraphInterrupt3, interrupt as interrupt3 } from "@langchain/langgraph";
|
|
24976
25694
|
|
|
24977
25695
|
// src/tool_lattice/ask_user_to_clarify/index.ts
|
|
24978
|
-
import { tool as
|
|
24979
|
-
import
|
|
24980
|
-
var questionSchema =
|
|
24981
|
-
question:
|
|
24982
|
-
options:
|
|
24983
|
-
type:
|
|
24984
|
-
required:
|
|
24985
|
-
allowOther:
|
|
25696
|
+
import { tool as tool58 } from "langchain";
|
|
25697
|
+
import z63 from "zod";
|
|
25698
|
+
var questionSchema = z63.object({
|
|
25699
|
+
question: z63.string().describe("The question text to ask the user"),
|
|
25700
|
+
options: z63.array(z63.string()).optional().default([]).describe("List of EXACT, selectable values. Maximum 3 options allowed. DO NOT include placeholder values like 'Other' or 'Enter manually'. For free-text with predefined choices, use allowOther=true (works with 'single' and 'multiple'). For pure free-text without choices, use type='input' instead. For file_upload and input, pass an empty array."),
|
|
25701
|
+
type: z63.enum(["single", "multiple", "file_upload", "input"]).describe("The question format. 'single' = pick one from options (default, see tool description for guidance). 'multiple' = pick several from options. 'input' = free-text field (only when options cannot express the answer). 'file_upload' = file picker."),
|
|
25702
|
+
required: z63.boolean().optional().default(false).describe("Whether this question must be answered"),
|
|
25703
|
+
allowOther: z63.boolean().optional().default(true).describe("Set to true to append an 'Other' checkbox with a free-text input field. Works with 'single' and 'multiple' types. Use for open-ended answers or when the options cannot cover all possibilities. Not applicable for 'input' or 'file_upload' types.")
|
|
24986
25704
|
});
|
|
24987
|
-
var inputSchema =
|
|
24988
|
-
questions:
|
|
25705
|
+
var inputSchema = z63.object({
|
|
25706
|
+
questions: z63.array(questionSchema).min(1, "At least one question is required").describe("A structured sequence of clarification questions. Use these to gather missing parameters or disambiguate user intent before proceeding.")
|
|
24989
25707
|
});
|
|
24990
25708
|
function createAskUserToClarifyTool() {
|
|
24991
|
-
return
|
|
25709
|
+
return tool58(
|
|
24992
25710
|
async (input) => {
|
|
24993
25711
|
return JSON.stringify(input);
|
|
24994
25712
|
},
|
|
@@ -25002,7 +25720,7 @@ function createAskUserToClarifyTool() {
|
|
|
25002
25720
|
|
|
25003
25721
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
25004
25722
|
function createAskUserClarifyMiddleware() {
|
|
25005
|
-
return
|
|
25723
|
+
return createMiddleware18({
|
|
25006
25724
|
name: "AskUserClarifyMiddleware",
|
|
25007
25725
|
tools: [createAskUserToClarifyTool()],
|
|
25008
25726
|
wrapToolCall: async (request, handler) => {
|
|
@@ -25110,11 +25828,11 @@ var askUserClarifyPlugin = {
|
|
|
25110
25828
|
};
|
|
25111
25829
|
|
|
25112
25830
|
// src/middlewares/widgetMiddleware.ts
|
|
25113
|
-
import { createMiddleware as
|
|
25831
|
+
import { createMiddleware as createMiddleware19 } from "langchain";
|
|
25114
25832
|
|
|
25115
25833
|
// src/tool_lattice/widget/loadGuidelines.ts
|
|
25116
|
-
import { tool as
|
|
25117
|
-
import { z as
|
|
25834
|
+
import { tool as tool59 } from "langchain";
|
|
25835
|
+
import { z as z64 } from "zod";
|
|
25118
25836
|
|
|
25119
25837
|
// src/middlewares/guidelines/index.ts
|
|
25120
25838
|
var CORE = `# Imagine \u2014 Visual Creation Suite
|
|
@@ -25905,13 +26623,13 @@ function getGuidelines(modules) {
|
|
|
25905
26623
|
var AVAILABLE_MODULES = Object.keys(MODULE_SECTIONS);
|
|
25906
26624
|
|
|
25907
26625
|
// src/tool_lattice/widget/loadGuidelines.ts
|
|
25908
|
-
var LoadGuidelinesInputSchema =
|
|
25909
|
-
modules:
|
|
26626
|
+
var LoadGuidelinesInputSchema = z64.object({
|
|
26627
|
+
modules: z64.array(z64.string()).describe(
|
|
25910
26628
|
"Which design modules to load. Choose all that apply. Available modules: [" + AVAILABLE_MODULES.join(",") + "]"
|
|
25911
26629
|
)
|
|
25912
26630
|
});
|
|
25913
26631
|
function createLoadGuidelinesTool() {
|
|
25914
|
-
return
|
|
26632
|
+
return tool59(
|
|
25915
26633
|
async (input) => {
|
|
25916
26634
|
const result = getGuidelines(input.modules);
|
|
25917
26635
|
return result;
|
|
@@ -25925,8 +26643,8 @@ function createLoadGuidelinesTool() {
|
|
|
25925
26643
|
}
|
|
25926
26644
|
|
|
25927
26645
|
// src/tool_lattice/widget/showWidget.ts
|
|
25928
|
-
import { tool as
|
|
25929
|
-
import { z as
|
|
26646
|
+
import { tool as tool60 } from "langchain";
|
|
26647
|
+
import { z as z65 } from "zod";
|
|
25930
26648
|
function containsForbiddenTags(code) {
|
|
25931
26649
|
const forbiddenPatterns = [
|
|
25932
26650
|
/<!DOCTYPE/i,
|
|
@@ -25948,20 +26666,20 @@ function validateWidgetCode(code) {
|
|
|
25948
26666
|
}
|
|
25949
26667
|
return { valid: true };
|
|
25950
26668
|
}
|
|
25951
|
-
var ShowWidgetInputSchema =
|
|
25952
|
-
i_have_seen_guidelines:
|
|
26669
|
+
var ShowWidgetInputSchema = z65.object({
|
|
26670
|
+
i_have_seen_guidelines: z65.boolean().describe(
|
|
25953
26671
|
"Must be true. Confirm you have called load_guidelines first."
|
|
25954
26672
|
),
|
|
25955
|
-
title:
|
|
25956
|
-
loading_messages:
|
|
26673
|
+
title: z65.string().describe("Title displayed above the widget"),
|
|
26674
|
+
loading_messages: z65.array(z65.string()).optional().describe(
|
|
25957
26675
|
"1-4 short strings shown while the widget renders"
|
|
25958
26676
|
),
|
|
25959
|
-
widget_code:
|
|
26677
|
+
widget_code: z65.string().describe(
|
|
25960
26678
|
"HTML fragment to render. Rules: 1. No DOCTYPE, <html>, <head>, or <body> tags. 2. Order: <style> block first, then HTML content, then <script> last. 3. Use only CSS variables for colors (e.g. var(--color-accent)). 4. No gradients, shadows, or blur effects. For SVG: start directly with <svg> tag."
|
|
25961
26679
|
)
|
|
25962
26680
|
});
|
|
25963
26681
|
function createShowWidgetTool() {
|
|
25964
|
-
return
|
|
26682
|
+
return tool60(
|
|
25965
26683
|
async (input) => {
|
|
25966
26684
|
if (!input.i_have_seen_guidelines) {
|
|
25967
26685
|
return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
|
|
@@ -25992,7 +26710,7 @@ function createWidgetMiddleware() {
|
|
|
25992
26710
|
createLoadGuidelinesTool(),
|
|
25993
26711
|
createShowWidgetTool()
|
|
25994
26712
|
];
|
|
25995
|
-
return
|
|
26713
|
+
return createMiddleware19({
|
|
25996
26714
|
name: "widgetMiddleware",
|
|
25997
26715
|
contextSchema,
|
|
25998
26716
|
tools
|
|
@@ -26014,153 +26732,6 @@ var widgetPlugin = {
|
|
|
26014
26732
|
middleware: () => createWidgetMiddleware()
|
|
26015
26733
|
};
|
|
26016
26734
|
|
|
26017
|
-
// src/middlewares/taskMiddleware.ts
|
|
26018
|
-
import { createMiddleware as createMiddleware19, tool as tool60 } from "langchain";
|
|
26019
|
-
import { z as z65 } from "zod";
|
|
26020
|
-
function getRunConfig2(config) {
|
|
26021
|
-
const c = config;
|
|
26022
|
-
return c?.configurable?.runConfig ?? {};
|
|
26023
|
-
}
|
|
26024
|
-
function getTaskStore() {
|
|
26025
|
-
return getStoreLattice("default", "task").store;
|
|
26026
|
-
}
|
|
26027
|
-
var manageTaskSchema = z65.object({
|
|
26028
|
-
action: z65.enum(["create", "list", "update", "delete", "complete"]).describe("\u64CD\u4F5C\u7C7B\u578B"),
|
|
26029
|
-
id: z65.string().optional().describe("\u4EFB\u52A1 ID (update/delete/complete \u5FC5\u586B)"),
|
|
26030
|
-
title: z65.string().optional().describe("\u4EFB\u52A1\u6807\u9898 (create \u5FC5\u586B)"),
|
|
26031
|
-
description: z65.string().optional().describe("\u4EFB\u52A1\u63CF\u8FF0"),
|
|
26032
|
-
priority: z65.enum(["low", "medium", "high"]).optional().describe("\u4F18\u5148\u7EA7"),
|
|
26033
|
-
status: z65.enum(["pending", "in_progress", "completed", "cancelled"]).optional().describe("\u72B6\u6001"),
|
|
26034
|
-
dueDate: z65.string().optional().describe("\u622A\u6B62\u65E5\u671F (ISO 8601)"),
|
|
26035
|
-
metadata: z65.record(z65.unknown()).optional().describe("\u7ED3\u6784\u5316\u5143\u6570\u636E (projectId, module \u7B49)"),
|
|
26036
|
-
parentId: z65.string().optional().describe("\u7236\u4EFB\u52A1 ID (\u5B50\u4EFB\u52A1\u5173\u8054)"),
|
|
26037
|
-
sourceId: z65.string().optional().describe("\u6765\u6E90\u4F1A\u8BDD/thread ID"),
|
|
26038
|
-
context: z65.record(z65.unknown()).optional().describe("\u9644\u52A0\u4E0A\u4E0B\u6587"),
|
|
26039
|
-
ownerType: z65.enum(["user", "agent"]).optional().describe("\u6240\u6709\u8005\u7C7B\u578B\uFF0C\u4E0D\u4F20\u9ED8\u8BA4\u4E3A user"),
|
|
26040
|
-
ownerId: z65.string().optional().describe("\u6240\u6709\u8005 ID\uFF0C\u4E0D\u4F20\u81EA\u52A8\u53D6\u5F53\u524D\u7528\u6237/Agent")
|
|
26041
|
-
});
|
|
26042
|
-
function createTaskMiddleware() {
|
|
26043
|
-
return createMiddleware19({
|
|
26044
|
-
name: "TaskMiddleware",
|
|
26045
|
-
contextSchema,
|
|
26046
|
-
wrapModelCall: async (request, handler) => {
|
|
26047
|
-
const taskPrompt = `## \u4EFB\u52A1\u7BA1\u7406\u80FD\u529B
|
|
26048
|
-
\u4F60\u53EF\u4EE5\u901A\u8FC7 manage_task \u5DE5\u5177\u7BA1\u7406\u6301\u4E45\u5316\u4EFB\u52A1\u3002ownerType \u548C ownerId \u7684\u9ED8\u8BA4\u884C\u4E3A\uFF1A
|
|
26049
|
-
- \u4E0D\u4F20\u53C2\u6570: \u9ED8\u8BA4\u4E3A\u5F53\u524D\u7528\u6237\u521B\u5EFA\u4EFB\u52A1 (ownerType="user", ownerId \u81EA\u52A8\u53D6\u5F53\u524D\u7528\u6237)
|
|
26050
|
-
- ownerType="agent": \u4E3A\u81EA\u5DF1\u521B\u5EFA\u6267\u884C\u5B50\u4EFB\u52A1 (ownerId \u81EA\u52A8\u53D6\u5F53\u524D Agent)
|
|
26051
|
-
- \u663E\u5F0F\u4F20 ownerId: \u4E3A\u6307\u5B9A agent/user \u521B\u5EFA\u4EFB\u52A1\uFF08\u62D3\u6251\u573A\u666F\uFF09`;
|
|
26052
|
-
return handler({
|
|
26053
|
-
...request,
|
|
26054
|
-
systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
|
|
26055
|
-
});
|
|
26056
|
-
},
|
|
26057
|
-
tools: [
|
|
26058
|
-
tool60(
|
|
26059
|
-
async (input, config) => {
|
|
26060
|
-
const rc = getRunConfig2(config);
|
|
26061
|
-
const tenantId2 = rc.tenantId || "default";
|
|
26062
|
-
const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
|
|
26063
|
-
const store = getTaskStore();
|
|
26064
|
-
switch (input.action) {
|
|
26065
|
-
case "create": {
|
|
26066
|
-
if (!input.title) {
|
|
26067
|
-
return JSON.stringify({ success: false, error: "create requires title" });
|
|
26068
|
-
}
|
|
26069
|
-
const task = await store.create({
|
|
26070
|
-
tenantId: tenantId2,
|
|
26071
|
-
ownerType: input.ownerType || "user",
|
|
26072
|
-
ownerId,
|
|
26073
|
-
title: input.title,
|
|
26074
|
-
description: input.description,
|
|
26075
|
-
priority: input.priority || "medium",
|
|
26076
|
-
status: input.status || "pending",
|
|
26077
|
-
dueDate: input.dueDate,
|
|
26078
|
-
metadata: input.metadata,
|
|
26079
|
-
parentId: input.parentId,
|
|
26080
|
-
sourceId: input.sourceId,
|
|
26081
|
-
context: input.context
|
|
26082
|
-
});
|
|
26083
|
-
return JSON.stringify({ success: true, data: task });
|
|
26084
|
-
}
|
|
26085
|
-
case "list": {
|
|
26086
|
-
const tasks = await store.list({
|
|
26087
|
-
tenantId: tenantId2,
|
|
26088
|
-
ownerType: input.ownerType,
|
|
26089
|
-
ownerId: input.ownerId,
|
|
26090
|
-
status: input.status,
|
|
26091
|
-
priority: input.priority
|
|
26092
|
-
});
|
|
26093
|
-
return JSON.stringify({ success: true, data: tasks, count: tasks.length });
|
|
26094
|
-
}
|
|
26095
|
-
case "update": {
|
|
26096
|
-
if (!input.id) {
|
|
26097
|
-
return JSON.stringify({ success: false, error: "update requires id" });
|
|
26098
|
-
}
|
|
26099
|
-
const { action, ...updates } = input;
|
|
26100
|
-
const updated = await store.update(tenantId2, input.id, updates);
|
|
26101
|
-
if (!updated) {
|
|
26102
|
-
return JSON.stringify({ success: false, error: "Task not found" });
|
|
26103
|
-
}
|
|
26104
|
-
return JSON.stringify({ success: true, data: updated });
|
|
26105
|
-
}
|
|
26106
|
-
case "delete": {
|
|
26107
|
-
if (!input.id) {
|
|
26108
|
-
return JSON.stringify({ success: false, error: "delete requires id" });
|
|
26109
|
-
}
|
|
26110
|
-
const deleted = await store.delete(tenantId2, input.id);
|
|
26111
|
-
return JSON.stringify({ success: deleted, message: deleted ? "Task deleted" : "Task not found" });
|
|
26112
|
-
}
|
|
26113
|
-
case "complete": {
|
|
26114
|
-
if (!input.id) {
|
|
26115
|
-
return JSON.stringify({ success: false, error: "complete requires id" });
|
|
26116
|
-
}
|
|
26117
|
-
const updated = await store.update(tenantId2, input.id, { status: "completed" });
|
|
26118
|
-
if (!updated) {
|
|
26119
|
-
return JSON.stringify({ success: false, error: "Task not found" });
|
|
26120
|
-
}
|
|
26121
|
-
return JSON.stringify({ success: true, data: updated });
|
|
26122
|
-
}
|
|
26123
|
-
default:
|
|
26124
|
-
return JSON.stringify({ success: false, error: `Unknown action: ${input.action}` });
|
|
26125
|
-
}
|
|
26126
|
-
},
|
|
26127
|
-
{
|
|
26128
|
-
name: "manage_task",
|
|
26129
|
-
description: `\u7BA1\u7406\u6301\u4E45\u5316\u4EFB\u52A1\u7CFB\u7EDF\u3002CRUD \u64CD\u4F5C\u7528\u6237\u548C Agent \u7684\u4EFB\u52A1\u3002
|
|
26130
|
-
|
|
26131
|
-
## ownerType \u548C ownerId \u7684\u9ED8\u8BA4\u903B\u8F91
|
|
26132
|
-
- \u4E0D\u4F20 ownerType \u548C ownerId: \u7CFB\u7EDF\u81EA\u52A8\u4E3A\u5F53\u524D\u7528\u6237\u521B\u5EFA\u4EFB\u52A1 (ownerType="user", ownerId \u53D6\u81EA\u5F53\u524D\u767B\u5F55\u7528\u6237)
|
|
26133
|
-
- \u4F20 ownerType="agent" \u4E0D\u4F20 ownerId: \u7CFB\u7EDF\u81EA\u52A8\u4E3A\u5F53\u524D Agent \u521B\u5EFA\u5B50\u4EFB\u52A1
|
|
26134
|
-
- \u663E\u5F0F\u4F20 ownerId: \u7CFB\u7EDF\u4F7F\u7528\u4F60\u6307\u5B9A\u7684 ID\uFF0C\u53EF\u8DE8 Agent \u6D3E\u53D1\u4EFB\u52A1\uFF08\u62D3\u6251\u573A\u666F\uFF09
|
|
26135
|
-
|
|
26136
|
-
## Actions
|
|
26137
|
-
- create: \u521B\u5EFA\u4EFB\u52A1 (title \u5FC5\u586B, priority/description/dueDate/metadata/parentId/context \u53EF\u9009)
|
|
26138
|
-
- list: \u5217\u51FA\u4EFB\u52A1\uFF0C\u53EF\u6309 ownerType/status/priority \u8FC7\u6EE4
|
|
26139
|
-
- update: \u66F4\u65B0\u4EFB\u52A1 (id \u5FC5\u586B\uFF0C\u53EA\u4F20\u8981\u6539\u7684\u5B57\u6BB5)
|
|
26140
|
-
- delete: \u5220\u9664\u4EFB\u52A1 (id \u5FC5\u586B)
|
|
26141
|
-
- complete: \u5FEB\u901F\u6807\u8BB0\u5B8C\u6210 (id \u5FC5\u586B)`,
|
|
26142
|
-
schema: manageTaskSchema
|
|
26143
|
-
}
|
|
26144
|
-
)
|
|
26145
|
-
]
|
|
26146
|
-
});
|
|
26147
|
-
}
|
|
26148
|
-
var taskPlugin = {
|
|
26149
|
-
meta: {
|
|
26150
|
-
type: "task",
|
|
26151
|
-
name: "Task Management",
|
|
26152
|
-
description: "Enables persistent task management with delegation and tracking",
|
|
26153
|
-
configSchema: {
|
|
26154
|
-
type: "object",
|
|
26155
|
-
title: "Task Management Configuration",
|
|
26156
|
-
description: "Zero-configuration task management",
|
|
26157
|
-
properties: {}
|
|
26158
|
-
},
|
|
26159
|
-
defaultConfig: {}
|
|
26160
|
-
},
|
|
26161
|
-
middleware: () => createTaskMiddleware()
|
|
26162
|
-
};
|
|
26163
|
-
|
|
26164
26735
|
// src/middlewares/evalMiddleware.ts
|
|
26165
26736
|
import { createMiddleware as createMiddleware20, tool as tool61 } from "langchain";
|
|
26166
26737
|
import { z as z66 } from "zod";
|
|
@@ -26974,7 +27545,7 @@ export {
|
|
|
26974
27545
|
ExportableEntityRegistry,
|
|
26975
27546
|
FileSystemSkillStore,
|
|
26976
27547
|
FilesystemBackend,
|
|
26977
|
-
|
|
27548
|
+
HumanMessage5 as HumanMessage,
|
|
26978
27549
|
IdRemapper,
|
|
26979
27550
|
InMemoryA2AApiKeyStore,
|
|
26980
27551
|
InMemoryAssistantStore,
|