@axiom-lattice/core 2.1.99 → 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 +276 -2
- package/dist/index.d.ts +276 -2
- package/dist/index.js +1331 -529
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1354 -555
- 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 {
|
|
@@ -9974,7 +10140,7 @@ import {
|
|
|
9974
10140
|
asyncScheduler
|
|
9975
10141
|
} from "rxjs";
|
|
9976
10142
|
import { eachValueFrom } from "rxjs-for-await";
|
|
9977
|
-
import {
|
|
10143
|
+
import { takeWhile, skip } from "rxjs/operators";
|
|
9978
10144
|
var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
9979
10145
|
constructor(config) {
|
|
9980
10146
|
super();
|
|
@@ -10184,17 +10350,18 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
|
|
|
10184
10350
|
MessageChunkTypes.THREAD_IDLE
|
|
10185
10351
|
];
|
|
10186
10352
|
const typesToStop = stopTypes ?? defaultStopTypes;
|
|
10187
|
-
let
|
|
10188
|
-
|
|
10353
|
+
let startIndex = 0;
|
|
10354
|
+
for (let i = buffer2.chunks.length - 1; i >= 0; i--) {
|
|
10355
|
+
if (buffer2.chunks[i].data?.id === messageId) {
|
|
10356
|
+
startIndex = i;
|
|
10357
|
+
break;
|
|
10358
|
+
}
|
|
10359
|
+
}
|
|
10360
|
+
const stopSet = new Set(typesToStop);
|
|
10189
10361
|
const filtered$ = buffer2.chunks$.pipe(
|
|
10190
10362
|
observeOn(asyncScheduler),
|
|
10191
|
-
|
|
10192
|
-
|
|
10193
|
-
if (chunk.data?.id === messageId) startYieldChunk = true;
|
|
10194
|
-
return startYieldChunk;
|
|
10195
|
-
}),
|
|
10196
|
-
// 2. 包含指定的停止类型,但收到后停止
|
|
10197
|
-
takeWhile((chunk) => !typesToStop.includes(chunk.type), true)
|
|
10363
|
+
skip(startIndex),
|
|
10364
|
+
takeWhile((chunk) => !stopSet.has(chunk.type), true)
|
|
10198
10365
|
);
|
|
10199
10366
|
yield* eachValueFrom(filtered$);
|
|
10200
10367
|
}
|
|
@@ -10276,7 +10443,7 @@ var buffer = new InMemoryChunkBuffer({
|
|
|
10276
10443
|
registerChunkBuffer("default", buffer);
|
|
10277
10444
|
|
|
10278
10445
|
// src/services/Agent.ts
|
|
10279
|
-
import { v4 } from "uuid";
|
|
10446
|
+
import { v4 as v42 } from "uuid";
|
|
10280
10447
|
var ThreadStatus2 = /* @__PURE__ */ ((ThreadStatus3) => {
|
|
10281
10448
|
ThreadStatus3["IDLE"] = "idle";
|
|
10282
10449
|
ThreadStatus3["BUSY"] = "busy";
|
|
@@ -10322,7 +10489,7 @@ var Agent = class {
|
|
|
10322
10489
|
runConfig
|
|
10323
10490
|
},
|
|
10324
10491
|
configurable: {
|
|
10325
|
-
run_id:
|
|
10492
|
+
run_id: v42(),
|
|
10326
10493
|
...runConfig,
|
|
10327
10494
|
runConfig
|
|
10328
10495
|
},
|
|
@@ -10395,7 +10562,7 @@ var Agent = class {
|
|
|
10395
10562
|
runConfig
|
|
10396
10563
|
},
|
|
10397
10564
|
configurable: {
|
|
10398
|
-
run_id:
|
|
10565
|
+
run_id: v42(),
|
|
10399
10566
|
...runConfig,
|
|
10400
10567
|
runConfig
|
|
10401
10568
|
// Inject runConfig for tools to access
|
|
@@ -10459,7 +10626,7 @@ var Agent = class {
|
|
|
10459
10626
|
});
|
|
10460
10627
|
const humanContent = p.content;
|
|
10461
10628
|
const input = {
|
|
10462
|
-
messages: [new
|
|
10629
|
+
messages: [new HumanMessage2({ id: humanContent.id, content: humanContent.message })]
|
|
10463
10630
|
};
|
|
10464
10631
|
if (files) {
|
|
10465
10632
|
input.files = files;
|
|
@@ -10533,7 +10700,7 @@ var Agent = class {
|
|
|
10533
10700
|
remainingPendings.forEach((p) => {
|
|
10534
10701
|
this.queueStore?.markProcessing(p.id);
|
|
10535
10702
|
const humanContent = p.content;
|
|
10536
|
-
userMessages.push(new
|
|
10703
|
+
userMessages.push(new HumanMessage2({ id: humanContent.id, content: humanContent.message }));
|
|
10537
10704
|
this.publish("message:started", {
|
|
10538
10705
|
type: "message:started",
|
|
10539
10706
|
messageId: humanContent.id,
|
|
@@ -10613,7 +10780,7 @@ var Agent = class {
|
|
|
10613
10780
|
if (signal?.aborted) break;
|
|
10614
10781
|
await this.queueStore?.markProcessing(p.id);
|
|
10615
10782
|
const humanContent = p.content;
|
|
10616
|
-
const message = new
|
|
10783
|
+
const message = new HumanMessage2({ id: humanContent.id, content: humanContent.message });
|
|
10617
10784
|
const startTime = Date.now();
|
|
10618
10785
|
this.publish("message:started", {
|
|
10619
10786
|
type: "message:started",
|
|
@@ -10781,10 +10948,10 @@ var Agent = class {
|
|
|
10781
10948
|
};
|
|
10782
10949
|
}
|
|
10783
10950
|
async invoke(queueMessage, signal) {
|
|
10784
|
-
const messageId =
|
|
10951
|
+
const messageId = v42();
|
|
10785
10952
|
const input = {
|
|
10786
10953
|
...queueMessage.input,
|
|
10787
|
-
messages: [new
|
|
10954
|
+
messages: [new HumanMessage2({ id: messageId, content: queueMessage.input.message })]
|
|
10788
10955
|
};
|
|
10789
10956
|
const inputMessage = { ...queueMessage, input };
|
|
10790
10957
|
return this.agentExecutor(inputMessage, signal);
|
|
@@ -10800,10 +10967,10 @@ var Agent = class {
|
|
|
10800
10967
|
* to avoid exposing internal annotation data.
|
|
10801
10968
|
*/
|
|
10802
10969
|
async invokeWithState(queueMessage, signal) {
|
|
10803
|
-
const messageId =
|
|
10970
|
+
const messageId = v42();
|
|
10804
10971
|
const input = {
|
|
10805
10972
|
...queueMessage.input,
|
|
10806
|
-
messages: [new
|
|
10973
|
+
messages: [new HumanMessage2({ id: messageId, content: queueMessage.input.message })]
|
|
10807
10974
|
};
|
|
10808
10975
|
const inputMessage = { ...queueMessage, input };
|
|
10809
10976
|
const { runnable_agent, runConfig } = await this.getLatticeClientAndRuntimeConfig(inputMessage.custom_run_config);
|
|
@@ -10816,7 +10983,7 @@ var Agent = class {
|
|
|
10816
10983
|
{
|
|
10817
10984
|
context: { runConfig },
|
|
10818
10985
|
configurable: {
|
|
10819
|
-
run_id:
|
|
10986
|
+
run_id: v42(),
|
|
10820
10987
|
...runConfig,
|
|
10821
10988
|
runConfig
|
|
10822
10989
|
},
|
|
@@ -10992,7 +11159,7 @@ var Agent = class {
|
|
|
10992
11159
|
*/
|
|
10993
11160
|
async addMessage(queueMessage, mode) {
|
|
10994
11161
|
const useMode = mode ?? this.queueMode.mode;
|
|
10995
|
-
const messageId = queueMessage.input.id ||
|
|
11162
|
+
const messageId = queueMessage.input.id || v42();
|
|
10996
11163
|
const messages = queueMessage.input.messages;
|
|
10997
11164
|
const legacyMessage = queueMessage.input.message;
|
|
10998
11165
|
if (!messages && !legacyMessage) {
|
|
@@ -11484,6 +11651,348 @@ var AgentInstanceManager = class _AgentInstanceManager {
|
|
|
11484
11651
|
};
|
|
11485
11652
|
var agentInstanceManager = AgentInstanceManager.getInstance();
|
|
11486
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
|
+
|
|
11487
11996
|
// src/deep_agent_new/middleware/subagents.ts
|
|
11488
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.";
|
|
11489
11998
|
var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
|
|
@@ -11666,8 +12175,12 @@ function getSubagents(options) {
|
|
|
11666
12175
|
const defaultSubagentMiddleware = defaultMiddleware || [];
|
|
11667
12176
|
const agents = {};
|
|
11668
12177
|
const subagentDescriptions = [];
|
|
12178
|
+
const hasTaskMiddleware = defaultSubagentMiddleware.some(
|
|
12179
|
+
(m) => m?.name === "TaskMiddleware"
|
|
12180
|
+
);
|
|
12181
|
+
const taskMiddleware = hasTaskMiddleware ? [] : [createTaskMiddleware()];
|
|
11669
12182
|
if (generalPurposeAgent) {
|
|
11670
|
-
const generalPurposeMiddleware = [...defaultSubagentMiddleware];
|
|
12183
|
+
const generalPurposeMiddleware = [...defaultSubagentMiddleware, ...taskMiddleware];
|
|
11671
12184
|
if (defaultInterruptOn) {
|
|
11672
12185
|
generalPurposeMiddleware.push(
|
|
11673
12186
|
humanInTheLoopMiddleware({ interruptOn: defaultInterruptOn })
|
|
@@ -11693,7 +12206,7 @@ function getSubagents(options) {
|
|
|
11693
12206
|
if ("runnable" in agentParams) {
|
|
11694
12207
|
agents[agentParams.key] = agentParams.runnable;
|
|
11695
12208
|
} else {
|
|
11696
|
-
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
|
|
12209
|
+
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...taskMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware, ...taskMiddleware];
|
|
11697
12210
|
const interruptOn = agentParams.interruptOn || defaultInterruptOn;
|
|
11698
12211
|
if (interruptOn)
|
|
11699
12212
|
middleware.push(humanInTheLoopMiddleware({ interruptOn }));
|
|
@@ -11747,7 +12260,7 @@ function createTaskTool(options) {
|
|
|
11747
12260
|
generalPurposeAgent
|
|
11748
12261
|
});
|
|
11749
12262
|
const finalTaskDescription = taskDescription ? taskDescription : getTaskToolDescription(subagentDescriptions);
|
|
11750
|
-
return
|
|
12263
|
+
return tool40(
|
|
11751
12264
|
async (input, config) => {
|
|
11752
12265
|
const { description, subagent_type, async } = input;
|
|
11753
12266
|
let assistant_id = subagent_type;
|
|
@@ -11777,7 +12290,17 @@ function createTaskTool(options) {
|
|
|
11777
12290
|
}
|
|
11778
12291
|
const currentState = getCurrentTaskInput2();
|
|
11779
12292
|
const subagentState = filterStateForSubagent(currentState);
|
|
11780
|
-
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 })];
|
|
11781
12304
|
const subagent_thread_id = config.configurable?.thread_id + "____" + assistant_id + "_" + config.toolCall.id;
|
|
11782
12305
|
if (async) {
|
|
11783
12306
|
const tenantId2 = config.configurable?.runConfig?.tenantId;
|
|
@@ -11809,11 +12332,12 @@ function createTaskTool(options) {
|
|
|
11809
12332
|
runConfig: {
|
|
11810
12333
|
...config.configurable?.runConfig,
|
|
11811
12334
|
assistant_id,
|
|
11812
|
-
thread_id: subagent_thread_id
|
|
12335
|
+
thread_id: subagent_thread_id,
|
|
12336
|
+
taskId: input.taskId
|
|
11813
12337
|
},
|
|
11814
|
-
main_thread_id: mainThreadId,
|
|
11815
12338
|
main_tenant_id: tenantId2,
|
|
11816
|
-
main_assistant_id: mainAssistantId
|
|
12339
|
+
main_assistant_id: mainAssistantId,
|
|
12340
|
+
main_thread_id: mainThreadId
|
|
11817
12341
|
}, false).catch((err) => {
|
|
11818
12342
|
console.error(`Failed to start async subagent ${subagent_thread_id}:`, err);
|
|
11819
12343
|
});
|
|
@@ -11841,7 +12365,8 @@ The result will be delivered as a notification when complete. Do not poll.`,
|
|
|
11841
12365
|
runConfig: {
|
|
11842
12366
|
...config.configurable?.runConfig,
|
|
11843
12367
|
assistant_id,
|
|
11844
|
-
thread_id: subagent_thread_id
|
|
12368
|
+
thread_id: subagent_thread_id,
|
|
12369
|
+
taskId: input.taskId
|
|
11845
12370
|
}
|
|
11846
12371
|
});
|
|
11847
12372
|
const result = workerResult.finalState?.values;
|
|
@@ -11869,18 +12394,21 @@ The result will be delivered as a notification when complete. Do not poll.`,
|
|
|
11869
12394
|
{
|
|
11870
12395
|
name: "task",
|
|
11871
12396
|
description: finalTaskDescription,
|
|
11872
|
-
schema:
|
|
11873
|
-
description:
|
|
11874
|
-
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(
|
|
11875
12400
|
`Name of the agent to use. Available: ${Object.keys(
|
|
11876
12401
|
subagentGraphs
|
|
11877
12402
|
).join(", ")}`
|
|
11878
12403
|
),
|
|
11879
12404
|
...allowAsync ? {
|
|
11880
|
-
async:
|
|
12405
|
+
async: z43.boolean().default(false).describe(
|
|
11881
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."
|
|
11882
12407
|
)
|
|
11883
|
-
} : {}
|
|
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
|
+
)
|
|
11884
12412
|
})
|
|
11885
12413
|
}
|
|
11886
12414
|
);
|
|
@@ -11896,7 +12424,7 @@ function getMainAgentFromConfig(config) {
|
|
|
11896
12424
|
});
|
|
11897
12425
|
}
|
|
11898
12426
|
function createCheckAsyncTaskTool() {
|
|
11899
|
-
return
|
|
12427
|
+
return tool40(
|
|
11900
12428
|
async (input, config) => {
|
|
11901
12429
|
const { task_id } = input;
|
|
11902
12430
|
const mainAgent = getMainAgentFromConfig(config);
|
|
@@ -11956,14 +12484,14 @@ Description: ${cached.description}`;
|
|
|
11956
12484
|
{
|
|
11957
12485
|
name: "check_async_task",
|
|
11958
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.",
|
|
11959
|
-
schema:
|
|
11960
|
-
task_id:
|
|
12487
|
+
schema: z43.object({
|
|
12488
|
+
task_id: z43.string().describe("The task ID returned when the async task was started")
|
|
11961
12489
|
})
|
|
11962
12490
|
}
|
|
11963
12491
|
);
|
|
11964
12492
|
}
|
|
11965
12493
|
function createListAsyncTasksTool() {
|
|
11966
|
-
return
|
|
12494
|
+
return tool40(
|
|
11967
12495
|
async (_input, config) => {
|
|
11968
12496
|
const mainAgent = getMainAgentFromConfig(config);
|
|
11969
12497
|
if (!mainAgent) {
|
|
@@ -12009,12 +12537,12 @@ function createListAsyncTasksTool() {
|
|
|
12009
12537
|
{
|
|
12010
12538
|
name: "list_async_tasks",
|
|
12011
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.",
|
|
12012
|
-
schema:
|
|
12540
|
+
schema: z43.object({})
|
|
12013
12541
|
}
|
|
12014
12542
|
);
|
|
12015
12543
|
}
|
|
12016
12544
|
function createCancelAsyncTaskTool() {
|
|
12017
|
-
return
|
|
12545
|
+
return tool40(
|
|
12018
12546
|
async (input, config) => {
|
|
12019
12547
|
const { task_id } = input;
|
|
12020
12548
|
const mainAgent = getMainAgentFromConfig(config);
|
|
@@ -12053,8 +12581,8 @@ function createCancelAsyncTaskTool() {
|
|
|
12053
12581
|
{
|
|
12054
12582
|
name: "cancel_async_task",
|
|
12055
12583
|
description: "Cancel a running async background task.",
|
|
12056
|
-
schema:
|
|
12057
|
-
task_id:
|
|
12584
|
+
schema: z43.object({
|
|
12585
|
+
task_id: z43.string().describe("The task ID to cancel")
|
|
12058
12586
|
})
|
|
12059
12587
|
}
|
|
12060
12588
|
);
|
|
@@ -12090,7 +12618,7 @@ function createSubAgentMiddleware(options) {
|
|
|
12090
12618
|
);
|
|
12091
12619
|
}
|
|
12092
12620
|
const effectiveSystemPrompt = allowAsync ? systemPrompt + getAsyncPromptText() : systemPrompt;
|
|
12093
|
-
return
|
|
12621
|
+
return createMiddleware10({
|
|
12094
12622
|
name: "subAgentMiddleware",
|
|
12095
12623
|
tools: allTools,
|
|
12096
12624
|
wrapModelCall: async (request, handler) => {
|
|
@@ -12111,12 +12639,12 @@ ${effectiveSystemPrompt}` : effectiveSystemPrompt;
|
|
|
12111
12639
|
|
|
12112
12640
|
// src/deep_agent_new/middleware/patch_tool_calls.ts
|
|
12113
12641
|
import {
|
|
12114
|
-
createMiddleware as
|
|
12642
|
+
createMiddleware as createMiddleware11,
|
|
12115
12643
|
ToolMessage as ToolMessage4,
|
|
12116
12644
|
AIMessage as AIMessage2
|
|
12117
12645
|
} from "langchain";
|
|
12118
12646
|
function createPatchToolCallsMiddleware() {
|
|
12119
|
-
return
|
|
12647
|
+
return createMiddleware11({
|
|
12120
12648
|
name: "patchToolCallsMiddleware",
|
|
12121
12649
|
beforeAgent: async (state) => {
|
|
12122
12650
|
const messages = state.messages;
|
|
@@ -12157,8 +12685,8 @@ function createPatchToolCallsMiddleware() {
|
|
|
12157
12685
|
}
|
|
12158
12686
|
|
|
12159
12687
|
// src/deep_agent_new/middleware/date.ts
|
|
12160
|
-
import { createMiddleware as
|
|
12161
|
-
import { z as
|
|
12688
|
+
import { createMiddleware as createMiddleware12, tool as tool41 } from "langchain";
|
|
12689
|
+
import { z as z44 } from "zod";
|
|
12162
12690
|
function formatCurrentDate(timezone = "UTC") {
|
|
12163
12691
|
const now = /* @__PURE__ */ new Date();
|
|
12164
12692
|
let validTimezone = timezone;
|
|
@@ -12186,10 +12714,10 @@ function generateDateContext(timezone = "UTC") {
|
|
|
12186
12714
|
function createDateMiddleware(options = {}) {
|
|
12187
12715
|
const timezone = options.timezone || "UTC";
|
|
12188
12716
|
const dateContext = generateDateContext(timezone);
|
|
12189
|
-
return
|
|
12717
|
+
return createMiddleware12({
|
|
12190
12718
|
name: "DateMiddleware",
|
|
12191
12719
|
tools: [
|
|
12192
|
-
|
|
12720
|
+
tool41(
|
|
12193
12721
|
async () => {
|
|
12194
12722
|
const now = /* @__PURE__ */ new Date();
|
|
12195
12723
|
let validTimezone = timezone;
|
|
@@ -12219,7 +12747,7 @@ function createDateMiddleware(options = {}) {
|
|
|
12219
12747
|
{
|
|
12220
12748
|
name: "get_current_date_time",
|
|
12221
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.",
|
|
12222
|
-
schema:
|
|
12750
|
+
schema: z44.object({})
|
|
12223
12751
|
}
|
|
12224
12752
|
)
|
|
12225
12753
|
],
|
|
@@ -12284,8 +12812,8 @@ var datePlugin = {
|
|
|
12284
12812
|
};
|
|
12285
12813
|
|
|
12286
12814
|
// src/deep_agent_new/middleware/scheduler.ts
|
|
12287
|
-
import { tool as
|
|
12288
|
-
import { z as
|
|
12815
|
+
import { tool as tool42, createMiddleware as createMiddleware13 } from "langchain";
|
|
12816
|
+
import { z as z45 } from "zod";
|
|
12289
12817
|
import { v4 as uuidv43 } from "uuid";
|
|
12290
12818
|
import { ScheduledTaskStatus as ScheduledTaskStatus3, ScheduleExecutionType as ScheduleExecutionType3 } from "@axiom-lattice/protocols";
|
|
12291
12819
|
|
|
@@ -13287,7 +13815,7 @@ var getScheduleLattice = (key4) => scheduleLatticeManager.getScheduleLattice(key
|
|
|
13287
13815
|
// src/deep_agent_new/middleware/scheduler.ts
|
|
13288
13816
|
var SCHEDULE_LATTICE_KEY = "default";
|
|
13289
13817
|
var AGENT_ADD_MESSAGE_TASK_TYPE = "agent.add_message";
|
|
13290
|
-
function
|
|
13818
|
+
function getRunConfig2(config) {
|
|
13291
13819
|
const configurable = config;
|
|
13292
13820
|
return configurable?.configurable?.runConfig ?? {};
|
|
13293
13821
|
}
|
|
@@ -13359,12 +13887,12 @@ function registerAgentAddMessageHandler() {
|
|
|
13359
13887
|
function createSchedulerMiddleware(options = {}) {
|
|
13360
13888
|
const defaultMaxRetries = options.defaultMaxRetries ?? 0;
|
|
13361
13889
|
registerAgentAddMessageHandler();
|
|
13362
|
-
return
|
|
13890
|
+
return createMiddleware13({
|
|
13363
13891
|
name: "SchedulerMiddleware",
|
|
13364
13892
|
tools: [
|
|
13365
|
-
|
|
13893
|
+
tool42(
|
|
13366
13894
|
async (input, config) => {
|
|
13367
|
-
const runConfig =
|
|
13895
|
+
const runConfig = getRunConfig2(config);
|
|
13368
13896
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13369
13897
|
const taskId = uuidv43();
|
|
13370
13898
|
const executeAt = input.executeAt;
|
|
@@ -13390,16 +13918,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13390
13918
|
{
|
|
13391
13919
|
name: "schedule_at",
|
|
13392
13920
|
description: "Schedule a system message for an absolute future timestamp",
|
|
13393
|
-
schema:
|
|
13394
|
-
executeAt:
|
|
13395
|
-
maxRetries:
|
|
13396
|
-
message:
|
|
13921
|
+
schema: z45.object({
|
|
13922
|
+
executeAt: z45.number(),
|
|
13923
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
13924
|
+
message: z45.string()
|
|
13397
13925
|
})
|
|
13398
13926
|
}
|
|
13399
13927
|
),
|
|
13400
|
-
|
|
13928
|
+
tool42(
|
|
13401
13929
|
async (input, config) => {
|
|
13402
|
-
const runConfig =
|
|
13930
|
+
const runConfig = getRunConfig2(config);
|
|
13403
13931
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13404
13932
|
const taskId = uuidv43();
|
|
13405
13933
|
const executeAt = Date.now() + input.delayMs;
|
|
@@ -13425,16 +13953,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13425
13953
|
{
|
|
13426
13954
|
name: "schedule_after",
|
|
13427
13955
|
description: "Schedule a system message after a relative delay",
|
|
13428
|
-
schema:
|
|
13429
|
-
delayMs:
|
|
13430
|
-
maxRetries:
|
|
13431
|
-
message:
|
|
13956
|
+
schema: z45.object({
|
|
13957
|
+
delayMs: z45.number().positive(),
|
|
13958
|
+
maxRetries: z45.number().int().min(0).optional(),
|
|
13959
|
+
message: z45.string()
|
|
13432
13960
|
})
|
|
13433
13961
|
}
|
|
13434
13962
|
),
|
|
13435
|
-
|
|
13963
|
+
tool42(
|
|
13436
13964
|
async (input, config) => {
|
|
13437
|
-
const runConfig =
|
|
13965
|
+
const runConfig = getRunConfig2(config);
|
|
13438
13966
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13439
13967
|
const taskId = uuidv43();
|
|
13440
13968
|
const success = await scheduleLattice.client.scheduleCron(
|
|
@@ -13467,16 +13995,16 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13467
13995
|
{
|
|
13468
13996
|
name: "schedule_recurring",
|
|
13469
13997
|
description: "Schedule a recurring system message with a cron expression",
|
|
13470
|
-
schema:
|
|
13471
|
-
cronExpression:
|
|
13472
|
-
maxRuns:
|
|
13473
|
-
expiresAt:
|
|
13474
|
-
maxRetries:
|
|
13475
|
-
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()
|
|
13476
14004
|
})
|
|
13477
14005
|
}
|
|
13478
14006
|
),
|
|
13479
|
-
|
|
14007
|
+
tool42(
|
|
13480
14008
|
async (input) => {
|
|
13481
14009
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13482
14010
|
const success = await scheduleLattice.client.cancel(input.taskId);
|
|
@@ -13485,14 +14013,14 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13485
14013
|
{
|
|
13486
14014
|
name: "cancel_scheduled_task",
|
|
13487
14015
|
description: "Cancel a scheduled task by task id",
|
|
13488
|
-
schema:
|
|
13489
|
-
taskId:
|
|
14016
|
+
schema: z45.object({
|
|
14017
|
+
taskId: z45.string()
|
|
13490
14018
|
})
|
|
13491
14019
|
}
|
|
13492
14020
|
),
|
|
13493
|
-
|
|
14021
|
+
tool42(
|
|
13494
14022
|
async (input, config) => {
|
|
13495
|
-
const runConfig =
|
|
14023
|
+
const runConfig = getRunConfig2(config);
|
|
13496
14024
|
const scheduleLattice = getScheduleLattice(SCHEDULE_LATTICE_KEY);
|
|
13497
14025
|
const storage = scheduleLattice.client.getStorage();
|
|
13498
14026
|
if (!storage) {
|
|
@@ -13512,11 +14040,11 @@ function createSchedulerMiddleware(options = {}) {
|
|
|
13512
14040
|
{
|
|
13513
14041
|
name: "list_scheduled_tasks",
|
|
13514
14042
|
description: "List scheduled tasks for the current agent context",
|
|
13515
|
-
schema:
|
|
13516
|
-
status:
|
|
13517
|
-
executionType:
|
|
13518
|
-
limit:
|
|
13519
|
-
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()
|
|
13520
14048
|
})
|
|
13521
14049
|
}
|
|
13522
14050
|
)
|
|
@@ -14657,8 +15185,8 @@ var MemoryBackend = class {
|
|
|
14657
15185
|
|
|
14658
15186
|
// src/deep_agent_new/middleware/todos.ts
|
|
14659
15187
|
import { Command as Command4 } from "@langchain/langgraph";
|
|
14660
|
-
import { z as
|
|
14661
|
-
import { createMiddleware as
|
|
15188
|
+
import { z as z46 } from "zod";
|
|
15189
|
+
import { createMiddleware as createMiddleware14, tool as tool43, ToolMessage as ToolMessage5 } from "langchain";
|
|
14662
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.
|
|
14663
15191
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
14664
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.
|
|
@@ -14885,14 +15413,14 @@ Writing todos takes time and tokens, use it when it is helpful for managing comp
|
|
|
14885
15413
|
## Important To-Do List Usage Notes to Remember
|
|
14886
15414
|
- The \`write_todos\` tool should never be called multiple times in parallel.
|
|
14887
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.`;
|
|
14888
|
-
var TodoStatus =
|
|
14889
|
-
var TodoSchema =
|
|
14890
|
-
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"),
|
|
14891
15419
|
status: TodoStatus
|
|
14892
15420
|
});
|
|
14893
|
-
var stateSchema =
|
|
15421
|
+
var stateSchema = z46.object({ todos: z46.array(TodoSchema).default([]) });
|
|
14894
15422
|
function todoListMiddleware(options) {
|
|
14895
|
-
const writeTodos =
|
|
15423
|
+
const writeTodos = tool43(
|
|
14896
15424
|
({ todos }, config) => {
|
|
14897
15425
|
return new Command4({
|
|
14898
15426
|
update: {
|
|
@@ -14909,12 +15437,12 @@ function todoListMiddleware(options) {
|
|
|
14909
15437
|
{
|
|
14910
15438
|
name: "write_todos",
|
|
14911
15439
|
description: options?.toolDescription ?? WRITE_TODOS_DESCRIPTION,
|
|
14912
|
-
schema:
|
|
14913
|
-
todos:
|
|
15440
|
+
schema: z46.object({
|
|
15441
|
+
todos: z46.array(TodoSchema).describe("List of todo items to update")
|
|
14914
15442
|
})
|
|
14915
15443
|
}
|
|
14916
15444
|
);
|
|
14917
|
-
return
|
|
15445
|
+
return createMiddleware14({
|
|
14918
15446
|
name: "todoListMiddleware",
|
|
14919
15447
|
stateSchema,
|
|
14920
15448
|
tools: [writeTodos],
|
|
@@ -15067,7 +15595,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
15067
15595
|
};
|
|
15068
15596
|
|
|
15069
15597
|
// src/agent_team/agent_team.ts
|
|
15070
|
-
import { z as
|
|
15598
|
+
import { z as z49 } from "zod/v3";
|
|
15071
15599
|
import { createAgent as createAgent5 } from "langchain";
|
|
15072
15600
|
|
|
15073
15601
|
// src/agent_team/types.ts
|
|
@@ -15503,14 +16031,14 @@ var InMemoryMailboxStore = class {
|
|
|
15503
16031
|
};
|
|
15504
16032
|
|
|
15505
16033
|
// src/agent_team/middleware/team.ts
|
|
15506
|
-
import { z as
|
|
15507
|
-
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";
|
|
15508
16036
|
import { Command as Command6, getCurrentTaskInput as getCurrentTaskInput3 } from "@langchain/langgraph";
|
|
15509
16037
|
import { v4 as uuidv44 } from "uuid";
|
|
15510
16038
|
|
|
15511
16039
|
// src/agent_team/middleware/teammate_tools.ts
|
|
15512
|
-
import { z as
|
|
15513
|
-
import { tool as
|
|
16040
|
+
import { z as z47 } from "zod/v3";
|
|
16041
|
+
import { tool as tool44, ToolMessage as ToolMessage6 } from "langchain";
|
|
15514
16042
|
import { Command as Command5 } from "@langchain/langgraph";
|
|
15515
16043
|
|
|
15516
16044
|
// src/agent_team/middleware/formatMessages.ts
|
|
@@ -15535,7 +16063,7 @@ ${meta}${body}`;
|
|
|
15535
16063
|
// src/agent_team/middleware/teammate_tools.ts
|
|
15536
16064
|
function createTeammateTools(options) {
|
|
15537
16065
|
const { teamId, agentId, taskListStore, mailboxStore } = options;
|
|
15538
|
-
const claimTaskTool =
|
|
16066
|
+
const claimTaskTool = tool44(
|
|
15539
16067
|
async (input) => {
|
|
15540
16068
|
const task = await taskListStore.claimTaskById(
|
|
15541
16069
|
teamId,
|
|
@@ -15560,12 +16088,12 @@ function createTeammateTools(options) {
|
|
|
15560
16088
|
{
|
|
15561
16089
|
name: "claim_task",
|
|
15562
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.",
|
|
15563
|
-
schema:
|
|
15564
|
-
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.")
|
|
15565
16093
|
})
|
|
15566
16094
|
}
|
|
15567
16095
|
);
|
|
15568
|
-
const completeTaskTool =
|
|
16096
|
+
const completeTaskTool = tool44(
|
|
15569
16097
|
async (input) => {
|
|
15570
16098
|
const task = await taskListStore.completeTask(
|
|
15571
16099
|
teamId,
|
|
@@ -15586,13 +16114,13 @@ function createTeammateTools(options) {
|
|
|
15586
16114
|
{
|
|
15587
16115
|
name: "complete_task",
|
|
15588
16116
|
description: "Mark a claimed task as completed with a result summary. Call this after you have finished working on a task.",
|
|
15589
|
-
schema:
|
|
15590
|
-
task_id:
|
|
15591
|
-
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")
|
|
15592
16120
|
})
|
|
15593
16121
|
}
|
|
15594
16122
|
);
|
|
15595
|
-
const failTaskTool =
|
|
16123
|
+
const failTaskTool = tool44(
|
|
15596
16124
|
async (input) => {
|
|
15597
16125
|
const task = await taskListStore.failTask(
|
|
15598
16126
|
teamId,
|
|
@@ -15613,13 +16141,13 @@ function createTeammateTools(options) {
|
|
|
15613
16141
|
{
|
|
15614
16142
|
name: "fail_task",
|
|
15615
16143
|
description: "Mark a claimed task as failed with an error description. Call this if you cannot complete the task.",
|
|
15616
|
-
schema:
|
|
15617
|
-
task_id:
|
|
15618
|
-
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")
|
|
15619
16147
|
})
|
|
15620
16148
|
}
|
|
15621
16149
|
);
|
|
15622
|
-
const sendMessageTool =
|
|
16150
|
+
const sendMessageTool = tool44(
|
|
15623
16151
|
async (input) => {
|
|
15624
16152
|
await mailboxStore.sendMessage(
|
|
15625
16153
|
teamId,
|
|
@@ -15633,11 +16161,11 @@ function createTeammateTools(options) {
|
|
|
15633
16161
|
{
|
|
15634
16162
|
name: "send_message",
|
|
15635
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.',
|
|
15636
|
-
schema:
|
|
15637
|
-
to:
|
|
16164
|
+
schema: z47.object({
|
|
16165
|
+
to: z47.string().describe(
|
|
15638
16166
|
'Recipient agent name (e.g. "team_lead" or a teammate name)'
|
|
15639
16167
|
),
|
|
15640
|
-
content:
|
|
16168
|
+
content: z47.string().describe("Message content")
|
|
15641
16169
|
})
|
|
15642
16170
|
}
|
|
15643
16171
|
);
|
|
@@ -15657,7 +16185,7 @@ function createTeammateTools(options) {
|
|
|
15657
16185
|
read: msg.read
|
|
15658
16186
|
}));
|
|
15659
16187
|
};
|
|
15660
|
-
const readMessagesTool =
|
|
16188
|
+
const readMessagesTool = tool44(
|
|
15661
16189
|
async (input, config) => {
|
|
15662
16190
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
15663
16191
|
for (const msg of msgs2) {
|
|
@@ -15716,10 +16244,10 @@ function createTeammateTools(options) {
|
|
|
15716
16244
|
{
|
|
15717
16245
|
name: "read_messages",
|
|
15718
16246
|
description: "Read unread messages from the mailbox. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
15719
|
-
schema:
|
|
16247
|
+
schema: z47.object({})
|
|
15720
16248
|
}
|
|
15721
16249
|
);
|
|
15722
|
-
const checkTasksTool =
|
|
16250
|
+
const checkTasksTool = tool44(
|
|
15723
16251
|
async () => {
|
|
15724
16252
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
15725
16253
|
return formatTaskSummary(tasks);
|
|
@@ -15727,10 +16255,10 @@ function createTeammateTools(options) {
|
|
|
15727
16255
|
{
|
|
15728
16256
|
name: "check_tasks",
|
|
15729
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.",
|
|
15730
|
-
schema:
|
|
16258
|
+
schema: z47.object({})
|
|
15731
16259
|
}
|
|
15732
16260
|
);
|
|
15733
|
-
const broadcastMessageTool =
|
|
16261
|
+
const broadcastMessageTool = tool44(
|
|
15734
16262
|
async (input) => {
|
|
15735
16263
|
const allAgents = await mailboxStore.getRegisteredAgents(teamId);
|
|
15736
16264
|
const recipients = allAgents.filter((a) => a !== agentId);
|
|
@@ -15749,8 +16277,8 @@ function createTeammateTools(options) {
|
|
|
15749
16277
|
{
|
|
15750
16278
|
name: "broadcast_message",
|
|
15751
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.",
|
|
15752
|
-
schema:
|
|
15753
|
-
content:
|
|
16280
|
+
schema: z47.object({
|
|
16281
|
+
content: z47.string().describe("Message content to broadcast to others")
|
|
15754
16282
|
})
|
|
15755
16283
|
}
|
|
15756
16284
|
);
|
|
@@ -15984,7 +16512,7 @@ async function spawnTeammate(options) {
|
|
|
15984
16512
|
function createTeamMiddleware(options) {
|
|
15985
16513
|
const { teamConfig, taskListStore, mailboxStore, tenantId: tenantId2 } = options;
|
|
15986
16514
|
const defaultModel = teamConfig.model ?? "claude-sonnet-4-5-20250929";
|
|
15987
|
-
const createTeamTool =
|
|
16515
|
+
const createTeamTool = tool45(
|
|
15988
16516
|
async (input, config) => {
|
|
15989
16517
|
const state = getCurrentTaskInput3();
|
|
15990
16518
|
if (state?.team?.teamId) {
|
|
@@ -16139,20 +16667,20 @@ After calling create_team, you MUST:
|
|
|
16139
16667
|
2. When messages indicate task changes, call check_tasks to get full task status
|
|
16140
16668
|
3. Continue until all tasks show "completed" or "failed"
|
|
16141
16669
|
4. Do NOT assume tasks are done - always verify with check_tasks`,
|
|
16142
|
-
schema:
|
|
16143
|
-
tasks:
|
|
16144
|
-
|
|
16145
|
-
id:
|
|
16146
|
-
title:
|
|
16147
|
-
description:
|
|
16148
|
-
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"])')
|
|
16149
16677
|
})
|
|
16150
16678
|
).describe("List of tasks for teammates to work on. Each task needs unique ID (task-01, task-02, etc.)."),
|
|
16151
|
-
teammates:
|
|
16152
|
-
|
|
16153
|
-
name:
|
|
16154
|
-
role:
|
|
16155
|
-
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")
|
|
16156
16684
|
})
|
|
16157
16685
|
).describe("Teammate agents to create. Each should have a clear role and focus.")
|
|
16158
16686
|
})
|
|
@@ -16163,7 +16691,7 @@ After calling create_team, you MUST:
|
|
|
16163
16691
|
if (state?.team?.teamId) return state.team.teamId;
|
|
16164
16692
|
throw new Error("No team_id provided and no team in state. Call create_team first.");
|
|
16165
16693
|
};
|
|
16166
|
-
const addTasksTool =
|
|
16694
|
+
const addTasksTool = tool45(
|
|
16167
16695
|
async (input, config) => {
|
|
16168
16696
|
const teamId = resolveTeamId();
|
|
16169
16697
|
const created = await taskListStore.addTasks(
|
|
@@ -16215,20 +16743,20 @@ IMPORTANT: Dependencies
|
|
|
16215
16743
|
|
|
16216
16744
|
IMPORTANT: Assigning to a specific teammate
|
|
16217
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.`,
|
|
16218
|
-
schema:
|
|
16219
|
-
tasks:
|
|
16220
|
-
|
|
16221
|
-
id:
|
|
16222
|
-
title:
|
|
16223
|
-
description:
|
|
16224
|
-
assignee:
|
|
16225
|
-
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")
|
|
16226
16754
|
})
|
|
16227
16755
|
).describe("New tasks to add to the team")
|
|
16228
16756
|
})
|
|
16229
16757
|
}
|
|
16230
16758
|
);
|
|
16231
|
-
const assignTaskTool =
|
|
16759
|
+
const assignTaskTool = tool45(
|
|
16232
16760
|
async (input, config) => {
|
|
16233
16761
|
const teamId = resolveTeamId();
|
|
16234
16762
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16250,13 +16778,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16250
16778
|
{
|
|
16251
16779
|
name: "assign_task",
|
|
16252
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.",
|
|
16253
|
-
schema:
|
|
16254
|
-
task_id:
|
|
16255
|
-
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")
|
|
16256
16784
|
})
|
|
16257
16785
|
}
|
|
16258
16786
|
);
|
|
16259
|
-
const setTaskStatusTool =
|
|
16787
|
+
const setTaskStatusTool = tool45(
|
|
16260
16788
|
async (input, config) => {
|
|
16261
16789
|
const teamId = resolveTeamId();
|
|
16262
16790
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16278,13 +16806,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16278
16806
|
{
|
|
16279
16807
|
name: "set_task_status",
|
|
16280
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.",
|
|
16281
|
-
schema:
|
|
16282
|
-
task_id:
|
|
16283
|
-
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")
|
|
16284
16812
|
})
|
|
16285
16813
|
}
|
|
16286
16814
|
);
|
|
16287
|
-
const setTaskDependenciesTool =
|
|
16815
|
+
const setTaskDependenciesTool = tool45(
|
|
16288
16816
|
async (input, config) => {
|
|
16289
16817
|
const teamId = resolveTeamId();
|
|
16290
16818
|
const task = await taskListStore.updateTask(teamId, input.task_id, {
|
|
@@ -16306,13 +16834,13 @@ IMPORTANT: Assigning to a specific teammate
|
|
|
16306
16834
|
{
|
|
16307
16835
|
name: "set_task_dependencies",
|
|
16308
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.',
|
|
16309
|
-
schema:
|
|
16310
|
-
task_id:
|
|
16311
|
-
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")
|
|
16312
16840
|
})
|
|
16313
16841
|
}
|
|
16314
16842
|
);
|
|
16315
|
-
const checkTasksTool =
|
|
16843
|
+
const checkTasksTool = tool45(
|
|
16316
16844
|
async (input, config) => {
|
|
16317
16845
|
const teamId = resolveTeamId();
|
|
16318
16846
|
const tasks = await taskListStore.getAllTasks(teamId);
|
|
@@ -16352,12 +16880,12 @@ Task Status Values:
|
|
|
16352
16880
|
- in_progress: Teammate is actively working on this task
|
|
16353
16881
|
- completed: Task finished successfully
|
|
16354
16882
|
- failed: Task encountered an error`,
|
|
16355
|
-
schema:
|
|
16356
|
-
team_id:
|
|
16883
|
+
schema: z48.object({
|
|
16884
|
+
team_id: z48.string().optional().describe("Team ID (omit to use active team)")
|
|
16357
16885
|
})
|
|
16358
16886
|
}
|
|
16359
16887
|
);
|
|
16360
|
-
const sendMessageTool =
|
|
16888
|
+
const sendMessageTool = tool45(
|
|
16361
16889
|
async (input, config) => {
|
|
16362
16890
|
const teamId = resolveTeamId();
|
|
16363
16891
|
await mailboxStore.sendMessage(
|
|
@@ -16376,13 +16904,13 @@ Task Status Values:
|
|
|
16376
16904
|
{
|
|
16377
16905
|
name: "send_message",
|
|
16378
16906
|
description: "Send a message to a specific teammate in the team. Omit team_id to use the active team from state.",
|
|
16379
|
-
schema:
|
|
16380
|
-
to:
|
|
16381
|
-
content:
|
|
16907
|
+
schema: z48.object({
|
|
16908
|
+
to: z48.string().describe("Recipient teammate name"),
|
|
16909
|
+
content: z48.string().describe("Message content")
|
|
16382
16910
|
})
|
|
16383
16911
|
}
|
|
16384
16912
|
);
|
|
16385
|
-
const readMessagesTool =
|
|
16913
|
+
const readMessagesTool = tool45(
|
|
16386
16914
|
async (input, config) => {
|
|
16387
16915
|
const teamId = resolveTeamId();
|
|
16388
16916
|
const formatAndMarkAsRead = async (msgs2) => {
|
|
@@ -16464,12 +16992,12 @@ Task Status Values:
|
|
|
16464
16992
|
{
|
|
16465
16993
|
name: "read_messages",
|
|
16466
16994
|
description: "Read unread messages from teammates. Returns immediately if messages exist, otherwise waits for up to 3 minutes for new messages.",
|
|
16467
|
-
schema:
|
|
16468
|
-
team_id:
|
|
16995
|
+
schema: z48.object({
|
|
16996
|
+
team_id: z48.string().optional().describe("Team ID (omit to use active team)")
|
|
16469
16997
|
})
|
|
16470
16998
|
}
|
|
16471
16999
|
);
|
|
16472
|
-
const disbandTeamTool =
|
|
17000
|
+
const disbandTeamTool = tool45(
|
|
16473
17001
|
async (input, config) => {
|
|
16474
17002
|
const teamId = resolveTeamId();
|
|
16475
17003
|
await mailboxStore.broadcastMessage(
|
|
@@ -16490,7 +17018,7 @@ Task Status Values:
|
|
|
16490
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."
|
|
16491
17019
|
}
|
|
16492
17020
|
);
|
|
16493
|
-
const broadcastMessageTool =
|
|
17021
|
+
const broadcastMessageTool = tool45(
|
|
16494
17022
|
async (input, config) => {
|
|
16495
17023
|
const teamId = resolveTeamId();
|
|
16496
17024
|
await mailboxStore.broadcastMessage(
|
|
@@ -16508,12 +17036,12 @@ Task Status Values:
|
|
|
16508
17036
|
{
|
|
16509
17037
|
name: "broadcast_message",
|
|
16510
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.",
|
|
16511
|
-
schema:
|
|
16512
|
-
content:
|
|
17039
|
+
schema: z48.object({
|
|
17040
|
+
content: z48.string().describe("Message content to broadcast to all teammates")
|
|
16513
17041
|
})
|
|
16514
17042
|
}
|
|
16515
17043
|
);
|
|
16516
|
-
return
|
|
17044
|
+
return createMiddleware15({
|
|
16517
17045
|
name: "teamMiddleware",
|
|
16518
17046
|
tools: [
|
|
16519
17047
|
createTeamTool,
|
|
@@ -16541,37 +17069,37 @@ ${TEAM_SYSTEM_PROMPT}` : TEAM_SYSTEM_PROMPT;
|
|
|
16541
17069
|
}
|
|
16542
17070
|
|
|
16543
17071
|
// src/agent_team/agent_team.ts
|
|
16544
|
-
var TeammateInfoSchema =
|
|
16545
|
-
name:
|
|
16546
|
-
role:
|
|
16547
|
-
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")
|
|
16548
17076
|
});
|
|
16549
|
-
var TeamTaskInfoSchema =
|
|
16550
|
-
id:
|
|
16551
|
-
title:
|
|
16552
|
-
description:
|
|
16553
|
-
status:
|
|
17077
|
+
var TeamTaskInfoSchema = z49.object({
|
|
17078
|
+
id: z49.string(),
|
|
17079
|
+
title: z49.string(),
|
|
17080
|
+
description: z49.string(),
|
|
17081
|
+
status: z49.string().optional()
|
|
16554
17082
|
});
|
|
16555
|
-
var MailboxMessageSchema =
|
|
16556
|
-
id:
|
|
16557
|
-
from:
|
|
16558
|
-
to:
|
|
16559
|
-
content:
|
|
16560
|
-
timestamp:
|
|
16561
|
-
type:
|
|
16562
|
-
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")
|
|
16563
17091
|
});
|
|
16564
|
-
var TeamInfoSchema =
|
|
16565
|
-
teamId:
|
|
16566
|
-
teamLeadId:
|
|
16567
|
-
teammates:
|
|
16568
|
-
tasks:
|
|
16569
|
-
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")
|
|
16570
17098
|
});
|
|
16571
|
-
var TEAM_STATE_SCHEMA =
|
|
17099
|
+
var TEAM_STATE_SCHEMA = z49.object({
|
|
16572
17100
|
team: TeamInfoSchema.optional().describe("Team info: teamId, teamLeadId, teammates, tasks. Set when create_team succeeds."),
|
|
16573
|
-
tasks:
|
|
16574
|
-
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")
|
|
16575
17103
|
});
|
|
16576
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:
|
|
16577
17105
|
|
|
@@ -16694,7 +17222,7 @@ import { StateGraph as StateGraph2, MessagesAnnotation } from "@langchain/langgr
|
|
|
16694
17222
|
import { AIMessage as AIMessage3 } from "@langchain/core/messages";
|
|
16695
17223
|
|
|
16696
17224
|
// src/services/a2a-client.ts
|
|
16697
|
-
import { v4 as
|
|
17225
|
+
import { v4 as v43 } from "uuid";
|
|
16698
17226
|
var A2ARemoteError = class extends Error {
|
|
16699
17227
|
constructor(message, statusCode, body) {
|
|
16700
17228
|
super(message);
|
|
@@ -16741,7 +17269,7 @@ var A2ARemoteClient = class {
|
|
|
16741
17269
|
*/
|
|
16742
17270
|
async sendMessage(text) {
|
|
16743
17271
|
await this.resolve();
|
|
16744
|
-
const taskId =
|
|
17272
|
+
const taskId = v43();
|
|
16745
17273
|
const body = JSON.stringify({
|
|
16746
17274
|
jsonrpc: "2.0",
|
|
16747
17275
|
method: "tasks/send",
|
|
@@ -17527,6 +18055,22 @@ async function configureStores(stores, options = {}) {
|
|
|
17527
18055
|
storeLatticeManager.registerLattice("default", t, store);
|
|
17528
18056
|
}
|
|
17529
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
|
+
}
|
|
17530
18074
|
if (options.autoDisposeStores) {
|
|
17531
18075
|
registerSignalCleanup();
|
|
17532
18076
|
_disposables.push(...localDisposables);
|
|
@@ -17671,7 +18215,7 @@ description: Create new skills, modify and improve existing skills. Use this ski
|
|
|
17671
18215
|
license: MIT
|
|
17672
18216
|
metadata:
|
|
17673
18217
|
category: meta
|
|
17674
|
-
version: "
|
|
18218
|
+
version: "3.0"
|
|
17675
18219
|
---
|
|
17676
18220
|
|
|
17677
18221
|
# Skill Creator
|
|
@@ -17770,6 +18314,160 @@ Instructional content for the agent.
|
|
|
17770
18314
|
|
|
17771
18315
|
---
|
|
17772
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
|
+
|
|
17773
18471
|
## Writing Guide
|
|
17774
18472
|
|
|
17775
18473
|
### The Description Field
|
|
@@ -17820,6 +18518,7 @@ A well-written skill body typically includes:
|
|
|
17820
18518
|
- **Guidelines**: Rules, constraints, quality standards, and the WHY behind them
|
|
17821
18519
|
- **Scenarios**: 2-3 common scenarios with concrete examples of inputs and expected outputs
|
|
17822
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
|
|
17823
18522
|
|
|
17824
18523
|
---
|
|
17825
18524
|
|
|
@@ -17827,10 +18526,11 @@ A well-written skill body typically includes:
|
|
|
17827
18526
|
|
|
17828
18527
|
After writing the draft, test it:
|
|
17829
18528
|
|
|
17830
|
-
1. **
|
|
17831
|
-
2. **
|
|
17832
|
-
3. **
|
|
17833
|
-
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?
|
|
17834
18534
|
|
|
17835
18535
|
### Improving the Skill
|
|
17836
18536
|
|
|
@@ -17866,10 +18566,11 @@ The agent sees skills as a list of name + description pairs. It decides whether
|
|
|
17866
18566
|
## Step 6: Package and Present
|
|
17867
18567
|
|
|
17868
18568
|
When the skill is ready:
|
|
17869
|
-
1.
|
|
17870
|
-
2.
|
|
17871
|
-
3.
|
|
17872
|
-
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
|
|
17873
18574
|
|
|
17874
18575
|
## Updating Existing Skills
|
|
17875
18576
|
|
|
@@ -17878,7 +18579,8 @@ When the user wants to improve an existing skill:
|
|
|
17878
18579
|
2. Understand what it currently does and where it falls short
|
|
17879
18580
|
3. Follow the same interview \u2192 draft \u2192 test \u2192 iterate loop
|
|
17880
18581
|
4. **Preserve the original name** \u2014 the directory name and \`name\` frontmatter field should stay the same
|
|
17881
|
-
5.
|
|
18582
|
+
5. Run the subSkills consistency check after making changes
|
|
18583
|
+
6. Write the updated version back to the same path
|
|
17882
18584
|
|
|
17883
18585
|
---
|
|
17884
18586
|
|
|
@@ -17912,6 +18614,8 @@ metadata:
|
|
|
17912
18614
|
|
|
17913
18615
|
**You** (write): Create \`/root/.agents/skills/csv-analyzer/SKILL.md\`
|
|
17914
18616
|
|
|
18617
|
+
**You** (verify): Run the subSkills consistency check \u2014 no subSkills, no \`[[refs]]\`, all good.
|
|
18618
|
+
|
|
17915
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."
|
|
17916
18620
|
|
|
17917
18621
|
Then iterate based on what the user says.
|
|
@@ -18971,8 +19675,8 @@ var InMemoryMenuStore = class {
|
|
|
18971
19675
|
};
|
|
18972
19676
|
|
|
18973
19677
|
// src/agent_lattice/agentArchitectTools.ts
|
|
18974
|
-
import
|
|
18975
|
-
import { v4 as
|
|
19678
|
+
import z50 from "zod";
|
|
19679
|
+
import { v4 as v44 } from "uuid";
|
|
18976
19680
|
import { AgentType as AgentType3 } from "@axiom-lattice/protocols";
|
|
18977
19681
|
function getTenantId(exeConfig) {
|
|
18978
19682
|
const runConfig = exeConfig?.configurable?.runConfig || {};
|
|
@@ -19001,7 +19705,7 @@ registerToolLattice(
|
|
|
19001
19705
|
{
|
|
19002
19706
|
name: "list_agents",
|
|
19003
19707
|
description: "List all agents for the current workspace. Returns a summary with id, name, description, and type for each agent.",
|
|
19004
|
-
schema:
|
|
19708
|
+
schema: z50.object({})
|
|
19005
19709
|
},
|
|
19006
19710
|
async (_input, exeConfig) => {
|
|
19007
19711
|
try {
|
|
@@ -19028,8 +19732,8 @@ registerToolLattice(
|
|
|
19028
19732
|
{
|
|
19029
19733
|
name: "get_agent",
|
|
19030
19734
|
description: "Get the full configuration of a specific agent by its ID. Returns the complete AgentConfig including prompt, middleware, tools, and sub-agents.",
|
|
19031
|
-
schema:
|
|
19032
|
-
id:
|
|
19735
|
+
schema: z50.object({
|
|
19736
|
+
id: z50.string().describe("The agent ID to retrieve")
|
|
19033
19737
|
})
|
|
19034
19738
|
},
|
|
19035
19739
|
async (input, exeConfig) => {
|
|
@@ -19046,24 +19750,24 @@ registerToolLattice(
|
|
|
19046
19750
|
}
|
|
19047
19751
|
}
|
|
19048
19752
|
);
|
|
19049
|
-
var middlewareConfigSchema =
|
|
19050
|
-
id:
|
|
19051
|
-
type:
|
|
19052
|
-
name:
|
|
19053
|
-
description:
|
|
19054
|
-
enabled:
|
|
19055
|
-
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()
|
|
19056
19760
|
});
|
|
19057
|
-
var createAgentSchema =
|
|
19058
|
-
name:
|
|
19059
|
-
description:
|
|
19060
|
-
type:
|
|
19061
|
-
prompt:
|
|
19062
|
-
tools:
|
|
19063
|
-
middleware:
|
|
19064
|
-
subAgents:
|
|
19065
|
-
internalSubAgents:
|
|
19066
|
-
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")
|
|
19067
19771
|
});
|
|
19068
19772
|
registerToolLattice(
|
|
19069
19773
|
"create_agent",
|
|
@@ -19101,14 +19805,14 @@ registerToolLattice(
|
|
|
19101
19805
|
}
|
|
19102
19806
|
}
|
|
19103
19807
|
);
|
|
19104
|
-
var createWorkflowSchema =
|
|
19105
|
-
name:
|
|
19106
|
-
description:
|
|
19107
|
-
skillLoaded:
|
|
19108
|
-
yaml:
|
|
19109
|
-
tools:
|
|
19110
|
-
middleware:
|
|
19111
|
-
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")
|
|
19112
19816
|
});
|
|
19113
19817
|
registerToolLattice(
|
|
19114
19818
|
"create_workflow",
|
|
@@ -19157,8 +19861,8 @@ registerToolLattice(
|
|
|
19157
19861
|
{
|
|
19158
19862
|
name: "validate_workflow",
|
|
19159
19863
|
description: "Validate a workflow agent's DSL for correctness by compiling it.",
|
|
19160
|
-
schema:
|
|
19161
|
-
id:
|
|
19864
|
+
schema: z50.object({
|
|
19865
|
+
id: z50.string().describe("The workflow agent ID to validate")
|
|
19162
19866
|
})
|
|
19163
19867
|
},
|
|
19164
19868
|
async (input, exeConfig) => {
|
|
@@ -19255,14 +19959,14 @@ registerToolLattice(
|
|
|
19255
19959
|
}
|
|
19256
19960
|
}
|
|
19257
19961
|
);
|
|
19258
|
-
var updateWorkflowSchema =
|
|
19259
|
-
id:
|
|
19260
|
-
name:
|
|
19261
|
-
description:
|
|
19262
|
-
yaml:
|
|
19263
|
-
tools:
|
|
19264
|
-
middleware:
|
|
19265
|
-
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")
|
|
19266
19970
|
});
|
|
19267
19971
|
registerToolLattice(
|
|
19268
19972
|
"update_workflow",
|
|
@@ -19323,18 +20027,18 @@ registerToolLattice(
|
|
|
19323
20027
|
}
|
|
19324
20028
|
}
|
|
19325
20029
|
);
|
|
19326
|
-
var updateAgentSchema =
|
|
19327
|
-
id:
|
|
19328
|
-
config:
|
|
19329
|
-
name:
|
|
19330
|
-
description:
|
|
19331
|
-
type:
|
|
19332
|
-
prompt:
|
|
19333
|
-
tools:
|
|
19334
|
-
middleware:
|
|
19335
|
-
subAgents:
|
|
19336
|
-
internalSubAgents:
|
|
19337
|
-
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")
|
|
19338
20042
|
}).describe("Configuration fields to update. Only include the fields you want to change.")
|
|
19339
20043
|
});
|
|
19340
20044
|
registerToolLattice(
|
|
@@ -19372,8 +20076,8 @@ registerToolLattice(
|
|
|
19372
20076
|
{
|
|
19373
20077
|
name: "delete_agent",
|
|
19374
20078
|
description: "Permanently delete an agent by its ID. This action cannot be undone.",
|
|
19375
|
-
schema:
|
|
19376
|
-
id:
|
|
20079
|
+
schema: z50.object({
|
|
20080
|
+
id: z50.string().describe("The agent ID to delete")
|
|
19377
20081
|
})
|
|
19378
20082
|
},
|
|
19379
20083
|
async (input, exeConfig) => {
|
|
@@ -19399,7 +20103,7 @@ registerToolLattice(
|
|
|
19399
20103
|
{
|
|
19400
20104
|
name: "list_tools",
|
|
19401
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.",
|
|
19402
|
-
schema:
|
|
20106
|
+
schema: z50.object({})
|
|
19403
20107
|
},
|
|
19404
20108
|
async (_input, _exeConfig) => {
|
|
19405
20109
|
try {
|
|
@@ -19421,9 +20125,9 @@ registerToolLattice(
|
|
|
19421
20125
|
{
|
|
19422
20126
|
name: "invoke_agent",
|
|
19423
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).",
|
|
19424
|
-
schema:
|
|
19425
|
-
id:
|
|
19426
|
-
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")
|
|
19427
20131
|
})
|
|
19428
20132
|
},
|
|
19429
20133
|
async (input, exeConfig) => {
|
|
@@ -19438,7 +20142,7 @@ registerToolLattice(
|
|
|
19438
20142
|
if (!existing) {
|
|
19439
20143
|
return JSON.stringify({ error: `Agent '${id}' not found` });
|
|
19440
20144
|
}
|
|
19441
|
-
const threadId =
|
|
20145
|
+
const threadId = v44();
|
|
19442
20146
|
const agent = new Agent({
|
|
19443
20147
|
tenant_id: tenantId2,
|
|
19444
20148
|
assistant_id: id,
|
|
@@ -19459,7 +20163,7 @@ registerToolLattice(
|
|
|
19459
20163
|
{
|
|
19460
20164
|
name: "list_middleware_types",
|
|
19461
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",
|
|
19462
|
-
schema:
|
|
20166
|
+
schema: z50.object({})
|
|
19463
20167
|
},
|
|
19464
20168
|
async () => {
|
|
19465
20169
|
const metas = PluginRegistry.listMeta();
|
|
@@ -19471,8 +20175,8 @@ registerToolLattice(
|
|
|
19471
20175
|
{
|
|
19472
20176
|
name: "list_connections",
|
|
19473
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, ... }] } }",
|
|
19474
|
-
schema:
|
|
19475
|
-
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")
|
|
19476
20180
|
}),
|
|
19477
20181
|
needUserApprove: false
|
|
19478
20182
|
},
|
|
@@ -20053,6 +20757,20 @@ function ensureBuiltinAgentsForTenant(tenantId2) {
|
|
|
20053
20757
|
}
|
|
20054
20758
|
}
|
|
20055
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
|
+
|
|
20056
20774
|
// src/agent_lattice/AgentLatticeManager.ts
|
|
20057
20775
|
function assistantToConfig(assistant) {
|
|
20058
20776
|
const graphDef = typeof assistant.graphDefinition === "object" && assistant.graphDefinition !== null ? { ...assistant.graphDefinition } : {};
|
|
@@ -20251,6 +20969,7 @@ var AgentLatticeManager = class _AgentLatticeManager extends BaseLatticeManager
|
|
|
20251
20969
|
*/
|
|
20252
20970
|
async initializeStoredAssistantsForTenant(tenantId2) {
|
|
20253
20971
|
ensureBuiltinAgentsForTenant(tenantId2);
|
|
20972
|
+
ensurePluginAgentsForTenant(tenantId2);
|
|
20254
20973
|
try {
|
|
20255
20974
|
const storeLattice = getStoreLattice("default", "assistant");
|
|
20256
20975
|
const assistants = await storeLattice.store.getAllAssistants(tenantId2);
|
|
@@ -23425,8 +24144,8 @@ function clearEvalRunService() {
|
|
|
23425
24144
|
}
|
|
23426
24145
|
|
|
23427
24146
|
// src/eval_lattice/LatticeEval.ts
|
|
23428
|
-
import { HumanMessage as
|
|
23429
|
-
import { v4 as
|
|
24147
|
+
import { HumanMessage as HumanMessage4 } from "@langchain/core/messages";
|
|
24148
|
+
import { v4 as v45 } from "uuid";
|
|
23430
24149
|
var _LatticeEval = class _LatticeEval {
|
|
23431
24150
|
constructor(config = {}) {
|
|
23432
24151
|
this.inMemoryLogs = [];
|
|
@@ -23566,7 +24285,7 @@ var _LatticeEval = class _LatticeEval {
|
|
|
23566
24285
|
}
|
|
23567
24286
|
async evaluateCase(evalCase) {
|
|
23568
24287
|
const startedAt = Date.now();
|
|
23569
|
-
const threadId = `${evalCase.caseId}||${
|
|
24288
|
+
const threadId = `${evalCase.caseId}||${v45()}`;
|
|
23570
24289
|
this.inMemoryLogs = [];
|
|
23571
24290
|
this.lastThreadId = threadId;
|
|
23572
24291
|
this.lastJudgeThreadId = void 0;
|
|
@@ -23708,7 +24427,7 @@ ${rubricsSection}
|
|
|
23708
24427
|
|
|
23709
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`;
|
|
23710
24429
|
this.lastTestPrompt = testPrompt;
|
|
23711
|
-
const judgeThreadId =
|
|
24430
|
+
const judgeThreadId = v45();
|
|
23712
24431
|
this.lastJudgeThreadId = judgeThreadId;
|
|
23713
24432
|
const judgeAgentKey = this.config.judge_agent_key || "LatticeTest";
|
|
23714
24433
|
const judgeTenantId = this.config.tenant_id || "default";
|
|
@@ -23716,7 +24435,7 @@ ${rubricsSection}
|
|
|
23716
24435
|
const judgeAgent = await getAgentClient(judgeTenantId, judgeAgentKey);
|
|
23717
24436
|
const testResponse = await judgeAgent.invoke(
|
|
23718
24437
|
{
|
|
23719
|
-
messages: [new
|
|
24438
|
+
messages: [new HumanMessage4(testPrompt)]
|
|
23720
24439
|
},
|
|
23721
24440
|
{
|
|
23722
24441
|
configurable: {
|
|
@@ -24308,15 +25027,15 @@ function clearEncryptionKeyCache() {
|
|
|
24308
25027
|
}
|
|
24309
25028
|
|
|
24310
25029
|
// src/middlewares/skillMiddleware.ts
|
|
24311
|
-
import { createMiddleware as
|
|
25030
|
+
import { createMiddleware as createMiddleware16 } from "langchain";
|
|
24312
25031
|
|
|
24313
25032
|
// src/tool_lattice/skill/load_skills.ts
|
|
24314
|
-
import z50 from "zod";
|
|
24315
|
-
import { tool as tool45 } from "langchain";
|
|
24316
|
-
|
|
24317
|
-
// src/tool_lattice/skill/load_skill_content.ts
|
|
24318
25033
|
import z51 from "zod";
|
|
24319
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";
|
|
24320
25039
|
var LOAD_SKILL_CONTENT_DESCRIPTION = `
|
|
24321
25040
|
Execute a skill within the main conversation
|
|
24322
25041
|
|
|
@@ -24354,7 +25073,7 @@ function getSandboxFromExeConfig(_exe_config) {
|
|
|
24354
25073
|
});
|
|
24355
25074
|
}
|
|
24356
25075
|
var createLoadSkillContentTool = (pluginSkillContents) => {
|
|
24357
|
-
return
|
|
25076
|
+
return tool47(
|
|
24358
25077
|
async (input, _exe_config) => {
|
|
24359
25078
|
try {
|
|
24360
25079
|
if (pluginSkillContents?.[input.skill_name]) {
|
|
@@ -24403,8 +25122,8 @@ var createLoadSkillContentTool = (pluginSkillContents) => {
|
|
|
24403
25122
|
{
|
|
24404
25123
|
name: "skill",
|
|
24405
25124
|
description: LOAD_SKILL_CONTENT_DESCRIPTION,
|
|
24406
|
-
schema:
|
|
24407
|
-
skill_name:
|
|
25125
|
+
schema: z52.object({
|
|
25126
|
+
skill_name: z52.string().describe("The name of the skill to load")
|
|
24408
25127
|
})
|
|
24409
25128
|
}
|
|
24410
25129
|
);
|
|
@@ -24418,7 +25137,7 @@ function createSkillMiddleware(params = {}) {
|
|
|
24418
25137
|
} = params;
|
|
24419
25138
|
const skills = params.skills;
|
|
24420
25139
|
let latestSkills = [];
|
|
24421
|
-
return
|
|
25140
|
+
return createMiddleware16({
|
|
24422
25141
|
name: "skillMiddleware",
|
|
24423
25142
|
contextSchema,
|
|
24424
25143
|
tools: [
|
|
@@ -24550,17 +25269,17 @@ var skillPlugin = {
|
|
|
24550
25269
|
};
|
|
24551
25270
|
|
|
24552
25271
|
// src/middlewares/collectionMiddleware.ts
|
|
24553
|
-
import { createMiddleware as
|
|
25272
|
+
import { createMiddleware as createMiddleware17 } from "langchain";
|
|
24554
25273
|
|
|
24555
25274
|
// src/tool_lattice/collection/list_collections.ts
|
|
24556
|
-
import
|
|
24557
|
-
import { tool as
|
|
25275
|
+
import z53 from "zod";
|
|
25276
|
+
import { tool as tool48 } from "langchain";
|
|
24558
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.`;
|
|
24559
25278
|
var createListCollectionsTool = ({
|
|
24560
25279
|
collectionKeys,
|
|
24561
25280
|
connectAll
|
|
24562
25281
|
}) => {
|
|
24563
|
-
return
|
|
25282
|
+
return tool48(
|
|
24564
25283
|
async (_input, _exeConfig) => {
|
|
24565
25284
|
try {
|
|
24566
25285
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24594,23 +25313,23 @@ var createListCollectionsTool = ({
|
|
|
24594
25313
|
{
|
|
24595
25314
|
name: "list_collections",
|
|
24596
25315
|
description: LIST_COLLECTIONS_DESCRIPTION,
|
|
24597
|
-
schema:
|
|
25316
|
+
schema: z53.object({})
|
|
24598
25317
|
}
|
|
24599
25318
|
);
|
|
24600
25319
|
};
|
|
24601
25320
|
|
|
24602
25321
|
// src/tool_lattice/collection/search_collection.ts
|
|
24603
|
-
import
|
|
24604
|
-
import { tool as
|
|
25322
|
+
import z54 from "zod";
|
|
25323
|
+
import { tool as tool49 } from "langchain";
|
|
24605
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.`;
|
|
24606
|
-
var searchSchema =
|
|
24607
|
-
collection:
|
|
24608
|
-
query:
|
|
24609
|
-
filter:
|
|
24610
|
-
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")
|
|
24611
25330
|
});
|
|
24612
25331
|
var createSearchCollectionTool = () => {
|
|
24613
|
-
return
|
|
25332
|
+
return tool49(
|
|
24614
25333
|
async (input, _exeConfig) => {
|
|
24615
25334
|
try {
|
|
24616
25335
|
const { collection, query, filter: filter2, top_k } = input;
|
|
@@ -24660,10 +25379,10 @@ var createSearchCollectionTool = () => {
|
|
|
24660
25379
|
};
|
|
24661
25380
|
|
|
24662
25381
|
// src/tool_lattice/collection/get_collection.ts
|
|
24663
|
-
import
|
|
24664
|
-
import { tool as
|
|
25382
|
+
import z55 from "zod";
|
|
25383
|
+
import { tool as tool50 } from "langchain";
|
|
24665
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.`;
|
|
24666
|
-
var createGetCollectionTool = () =>
|
|
25385
|
+
var createGetCollectionTool = () => tool50(
|
|
24667
25386
|
async (input, _exeConfig) => {
|
|
24668
25387
|
try {
|
|
24669
25388
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24686,24 +25405,24 @@ Embedding: ${c.embeddingKey}${fieldsDesc}`;
|
|
|
24686
25405
|
return `Error: ${error.message}`;
|
|
24687
25406
|
}
|
|
24688
25407
|
},
|
|
24689
|
-
{ 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") }) }
|
|
24690
25409
|
);
|
|
24691
25410
|
|
|
24692
25411
|
// src/tool_lattice/collection/create_collection.ts
|
|
24693
|
-
import
|
|
24694
|
-
import { tool as
|
|
24695
|
-
var createSchema =
|
|
24696
|
-
name:
|
|
24697
|
-
label:
|
|
24698
|
-
embeddingKey:
|
|
24699
|
-
fields:
|
|
24700
|
-
key:
|
|
24701
|
-
type:
|
|
24702
|
-
enumValues:
|
|
24703
|
-
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")
|
|
24704
25423
|
})).optional().describe("Custom field definitions for entries in this collection")
|
|
24705
25424
|
});
|
|
24706
|
-
var createCreateCollectionTool = () =>
|
|
25425
|
+
var createCreateCollectionTool = () => tool51(
|
|
24707
25426
|
async (input, _exeConfig) => {
|
|
24708
25427
|
try {
|
|
24709
25428
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24728,20 +25447,20 @@ var createCreateCollectionTool = () => tool50(
|
|
|
24728
25447
|
);
|
|
24729
25448
|
|
|
24730
25449
|
// src/tool_lattice/collection/update_collection.ts
|
|
24731
|
-
import
|
|
24732
|
-
import { tool as
|
|
24733
|
-
var schema =
|
|
24734
|
-
name:
|
|
24735
|
-
label:
|
|
24736
|
-
embeddingKey:
|
|
24737
|
-
fields:
|
|
24738
|
-
key:
|
|
24739
|
-
type:
|
|
24740
|
-
enumValues:
|
|
24741
|
-
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")
|
|
24742
25461
|
})).optional().describe("Custom field definitions for entries (replaces existing schema)")
|
|
24743
25462
|
});
|
|
24744
|
-
var createUpdateCollectionTool = () =>
|
|
25463
|
+
var createUpdateCollectionTool = () => tool52(
|
|
24745
25464
|
async (input, _exeConfig) => {
|
|
24746
25465
|
try {
|
|
24747
25466
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24760,9 +25479,9 @@ var createUpdateCollectionTool = () => tool51(
|
|
|
24760
25479
|
);
|
|
24761
25480
|
|
|
24762
25481
|
// src/tool_lattice/collection/delete_collection.ts
|
|
24763
|
-
import
|
|
24764
|
-
import { tool as
|
|
24765
|
-
var createDeleteCollectionTool = () =>
|
|
25482
|
+
import z58 from "zod";
|
|
25483
|
+
import { tool as tool53 } from "langchain";
|
|
25484
|
+
var createDeleteCollectionTool = () => tool53(
|
|
24766
25485
|
async (input, _exeConfig) => {
|
|
24767
25486
|
try {
|
|
24768
25487
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24772,19 +25491,19 @@ var createDeleteCollectionTool = () => tool52(
|
|
|
24772
25491
|
return `Error: ${e.message}`;
|
|
24773
25492
|
}
|
|
24774
25493
|
},
|
|
24775
|
-
{ 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") }) }
|
|
24776
25495
|
);
|
|
24777
25496
|
|
|
24778
25497
|
// src/tool_lattice/collection/list_entries.ts
|
|
24779
|
-
import
|
|
24780
|
-
import { tool as
|
|
24781
|
-
var schema2 =
|
|
24782
|
-
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")
|
|
24783
25502
|
});
|
|
24784
25503
|
function buildKey2(tenantId2, name) {
|
|
24785
25504
|
return `${tenantId2}:${name}`;
|
|
24786
25505
|
}
|
|
24787
|
-
var createListEntriesTool = () =>
|
|
25506
|
+
var createListEntriesTool = () => tool54(
|
|
24788
25507
|
async (input, _exeConfig) => {
|
|
24789
25508
|
try {
|
|
24790
25509
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24811,19 +25530,19 @@ var createListEntriesTool = () => tool53(
|
|
|
24811
25530
|
);
|
|
24812
25531
|
|
|
24813
25532
|
// src/tool_lattice/collection/add_entry.ts
|
|
24814
|
-
import
|
|
24815
|
-
import { tool as
|
|
25533
|
+
import z60 from "zod";
|
|
25534
|
+
import { tool as tool55 } from "langchain";
|
|
24816
25535
|
import { Document } from "@langchain/core/documents";
|
|
24817
25536
|
import { v4 as uuidv45 } from "uuid";
|
|
24818
|
-
var schema3 =
|
|
24819
|
-
collection:
|
|
24820
|
-
content:
|
|
24821
|
-
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")
|
|
24822
25541
|
});
|
|
24823
25542
|
function key(t, n) {
|
|
24824
25543
|
return `${t}:${n}`;
|
|
24825
25544
|
}
|
|
24826
|
-
var createAddEntryTool = () =>
|
|
25545
|
+
var createAddEntryTool = () => tool55(
|
|
24827
25546
|
async (input, _exeConfig) => {
|
|
24828
25547
|
try {
|
|
24829
25548
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24842,18 +25561,18 @@ var createAddEntryTool = () => tool54(
|
|
|
24842
25561
|
);
|
|
24843
25562
|
|
|
24844
25563
|
// src/tool_lattice/collection/update_entry.ts
|
|
24845
|
-
import
|
|
24846
|
-
import { tool as
|
|
24847
|
-
var schema4 =
|
|
24848
|
-
collection:
|
|
24849
|
-
entryId:
|
|
24850
|
-
content:
|
|
24851
|
-
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")
|
|
24852
25571
|
});
|
|
24853
25572
|
function key2(t, n) {
|
|
24854
25573
|
return `${t}:${n}`;
|
|
24855
25574
|
}
|
|
24856
|
-
var createUpdateEntryTool = () =>
|
|
25575
|
+
var createUpdateEntryTool = () => tool56(
|
|
24857
25576
|
async (input, _exeConfig) => {
|
|
24858
25577
|
try {
|
|
24859
25578
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24872,16 +25591,16 @@ var createUpdateEntryTool = () => tool55(
|
|
|
24872
25591
|
);
|
|
24873
25592
|
|
|
24874
25593
|
// src/tool_lattice/collection/delete_entry.ts
|
|
24875
|
-
import
|
|
24876
|
-
import { tool as
|
|
24877
|
-
var schema5 =
|
|
24878
|
-
collection:
|
|
24879
|
-
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")
|
|
24880
25599
|
});
|
|
24881
25600
|
function key3(t, n) {
|
|
24882
25601
|
return `${t}:${n}`;
|
|
24883
25602
|
}
|
|
24884
|
-
var createDeleteEntryTool = () =>
|
|
25603
|
+
var createDeleteEntryTool = () => tool57(
|
|
24885
25604
|
async (input, _exeConfig) => {
|
|
24886
25605
|
try {
|
|
24887
25606
|
const tenantId2 = _exeConfig?.configurable?.runConfig?.tenantId || "default";
|
|
@@ -24899,7 +25618,7 @@ var createDeleteEntryTool = () => tool56(
|
|
|
24899
25618
|
function createCollectionMiddleware(params) {
|
|
24900
25619
|
const { collectionKeys, connectAll } = params;
|
|
24901
25620
|
if (!connectAll && (!collectionKeys || collectionKeys.length === 0)) {
|
|
24902
|
-
return
|
|
25621
|
+
return createMiddleware17({
|
|
24903
25622
|
name: "collectionMiddleware",
|
|
24904
25623
|
contextSchema,
|
|
24905
25624
|
tools: [
|
|
@@ -24909,7 +25628,7 @@ function createCollectionMiddleware(params) {
|
|
|
24909
25628
|
});
|
|
24910
25629
|
}
|
|
24911
25630
|
const listToolParams = { collectionKeys, connectAll };
|
|
24912
|
-
return
|
|
25631
|
+
return createMiddleware17({
|
|
24913
25632
|
name: "collectionMiddleware",
|
|
24914
25633
|
contextSchema,
|
|
24915
25634
|
tools: [
|
|
@@ -24970,24 +25689,24 @@ var collectionPlugin = {
|
|
|
24970
25689
|
};
|
|
24971
25690
|
|
|
24972
25691
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
24973
|
-
import { createMiddleware as
|
|
25692
|
+
import { createMiddleware as createMiddleware18, ToolMessage as ToolMessage8 } from "langchain";
|
|
24974
25693
|
import { GraphInterrupt as GraphInterrupt3, interrupt as interrupt3 } from "@langchain/langgraph";
|
|
24975
25694
|
|
|
24976
25695
|
// src/tool_lattice/ask_user_to_clarify/index.ts
|
|
24977
|
-
import { tool as
|
|
24978
|
-
import
|
|
24979
|
-
var questionSchema =
|
|
24980
|
-
question:
|
|
24981
|
-
options:
|
|
24982
|
-
type:
|
|
24983
|
-
required:
|
|
24984
|
-
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.")
|
|
24985
25704
|
});
|
|
24986
|
-
var inputSchema =
|
|
24987
|
-
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.")
|
|
24988
25707
|
});
|
|
24989
25708
|
function createAskUserToClarifyTool() {
|
|
24990
|
-
return
|
|
25709
|
+
return tool58(
|
|
24991
25710
|
async (input) => {
|
|
24992
25711
|
return JSON.stringify(input);
|
|
24993
25712
|
},
|
|
@@ -25001,7 +25720,7 @@ function createAskUserToClarifyTool() {
|
|
|
25001
25720
|
|
|
25002
25721
|
// src/middlewares/askUserClarifyMiddleware.ts
|
|
25003
25722
|
function createAskUserClarifyMiddleware() {
|
|
25004
|
-
return
|
|
25723
|
+
return createMiddleware18({
|
|
25005
25724
|
name: "AskUserClarifyMiddleware",
|
|
25006
25725
|
tools: [createAskUserToClarifyTool()],
|
|
25007
25726
|
wrapToolCall: async (request, handler) => {
|
|
@@ -25109,11 +25828,11 @@ var askUserClarifyPlugin = {
|
|
|
25109
25828
|
};
|
|
25110
25829
|
|
|
25111
25830
|
// src/middlewares/widgetMiddleware.ts
|
|
25112
|
-
import { createMiddleware as
|
|
25831
|
+
import { createMiddleware as createMiddleware19 } from "langchain";
|
|
25113
25832
|
|
|
25114
25833
|
// src/tool_lattice/widget/loadGuidelines.ts
|
|
25115
|
-
import { tool as
|
|
25116
|
-
import { z as
|
|
25834
|
+
import { tool as tool59 } from "langchain";
|
|
25835
|
+
import { z as z64 } from "zod";
|
|
25117
25836
|
|
|
25118
25837
|
// src/middlewares/guidelines/index.ts
|
|
25119
25838
|
var CORE = `# Imagine \u2014 Visual Creation Suite
|
|
@@ -25904,13 +26623,13 @@ function getGuidelines(modules) {
|
|
|
25904
26623
|
var AVAILABLE_MODULES = Object.keys(MODULE_SECTIONS);
|
|
25905
26624
|
|
|
25906
26625
|
// src/tool_lattice/widget/loadGuidelines.ts
|
|
25907
|
-
var LoadGuidelinesInputSchema =
|
|
25908
|
-
modules:
|
|
26626
|
+
var LoadGuidelinesInputSchema = z64.object({
|
|
26627
|
+
modules: z64.array(z64.string()).describe(
|
|
25909
26628
|
"Which design modules to load. Choose all that apply. Available modules: [" + AVAILABLE_MODULES.join(",") + "]"
|
|
25910
26629
|
)
|
|
25911
26630
|
});
|
|
25912
26631
|
function createLoadGuidelinesTool() {
|
|
25913
|
-
return
|
|
26632
|
+
return tool59(
|
|
25914
26633
|
async (input) => {
|
|
25915
26634
|
const result = getGuidelines(input.modules);
|
|
25916
26635
|
return result;
|
|
@@ -25924,8 +26643,8 @@ function createLoadGuidelinesTool() {
|
|
|
25924
26643
|
}
|
|
25925
26644
|
|
|
25926
26645
|
// src/tool_lattice/widget/showWidget.ts
|
|
25927
|
-
import { tool as
|
|
25928
|
-
import { z as
|
|
26646
|
+
import { tool as tool60 } from "langchain";
|
|
26647
|
+
import { z as z65 } from "zod";
|
|
25929
26648
|
function containsForbiddenTags(code) {
|
|
25930
26649
|
const forbiddenPatterns = [
|
|
25931
26650
|
/<!DOCTYPE/i,
|
|
@@ -25947,20 +26666,20 @@ function validateWidgetCode(code) {
|
|
|
25947
26666
|
}
|
|
25948
26667
|
return { valid: true };
|
|
25949
26668
|
}
|
|
25950
|
-
var ShowWidgetInputSchema =
|
|
25951
|
-
i_have_seen_guidelines:
|
|
26669
|
+
var ShowWidgetInputSchema = z65.object({
|
|
26670
|
+
i_have_seen_guidelines: z65.boolean().describe(
|
|
25952
26671
|
"Must be true. Confirm you have called load_guidelines first."
|
|
25953
26672
|
),
|
|
25954
|
-
title:
|
|
25955
|
-
loading_messages:
|
|
26673
|
+
title: z65.string().describe("Title displayed above the widget"),
|
|
26674
|
+
loading_messages: z65.array(z65.string()).optional().describe(
|
|
25956
26675
|
"1-4 short strings shown while the widget renders"
|
|
25957
26676
|
),
|
|
25958
|
-
widget_code:
|
|
26677
|
+
widget_code: z65.string().describe(
|
|
25959
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."
|
|
25960
26679
|
)
|
|
25961
26680
|
});
|
|
25962
26681
|
function createShowWidgetTool() {
|
|
25963
|
-
return
|
|
26682
|
+
return tool60(
|
|
25964
26683
|
async (input) => {
|
|
25965
26684
|
if (!input.i_have_seen_guidelines) {
|
|
25966
26685
|
return "Error: You must call load_guidelines before using show_widget. Set i_have_seen_guidelines to true only after loading guidelines.";
|
|
@@ -25991,7 +26710,7 @@ function createWidgetMiddleware() {
|
|
|
25991
26710
|
createLoadGuidelinesTool(),
|
|
25992
26711
|
createShowWidgetTool()
|
|
25993
26712
|
];
|
|
25994
|
-
return
|
|
26713
|
+
return createMiddleware19({
|
|
25995
26714
|
name: "widgetMiddleware",
|
|
25996
26715
|
contextSchema,
|
|
25997
26716
|
tools
|
|
@@ -26013,153 +26732,6 @@ var widgetPlugin = {
|
|
|
26013
26732
|
middleware: () => createWidgetMiddleware()
|
|
26014
26733
|
};
|
|
26015
26734
|
|
|
26016
|
-
// src/middlewares/taskMiddleware.ts
|
|
26017
|
-
import { createMiddleware as createMiddleware19, tool as tool60 } from "langchain";
|
|
26018
|
-
import { z as z65 } from "zod";
|
|
26019
|
-
function getRunConfig2(config) {
|
|
26020
|
-
const c = config;
|
|
26021
|
-
return c?.configurable?.runConfig ?? {};
|
|
26022
|
-
}
|
|
26023
|
-
function getTaskStore() {
|
|
26024
|
-
return getStoreLattice("default", "task").store;
|
|
26025
|
-
}
|
|
26026
|
-
var manageTaskSchema = z65.object({
|
|
26027
|
-
action: z65.enum(["create", "list", "update", "delete", "complete"]).describe("\u64CD\u4F5C\u7C7B\u578B"),
|
|
26028
|
-
id: z65.string().optional().describe("\u4EFB\u52A1 ID (update/delete/complete \u5FC5\u586B)"),
|
|
26029
|
-
title: z65.string().optional().describe("\u4EFB\u52A1\u6807\u9898 (create \u5FC5\u586B)"),
|
|
26030
|
-
description: z65.string().optional().describe("\u4EFB\u52A1\u63CF\u8FF0"),
|
|
26031
|
-
priority: z65.enum(["low", "medium", "high"]).optional().describe("\u4F18\u5148\u7EA7"),
|
|
26032
|
-
status: z65.enum(["pending", "in_progress", "completed", "cancelled"]).optional().describe("\u72B6\u6001"),
|
|
26033
|
-
dueDate: z65.string().optional().describe("\u622A\u6B62\u65E5\u671F (ISO 8601)"),
|
|
26034
|
-
metadata: z65.record(z65.unknown()).optional().describe("\u7ED3\u6784\u5316\u5143\u6570\u636E (projectId, module \u7B49)"),
|
|
26035
|
-
parentId: z65.string().optional().describe("\u7236\u4EFB\u52A1 ID (\u5B50\u4EFB\u52A1\u5173\u8054)"),
|
|
26036
|
-
sourceId: z65.string().optional().describe("\u6765\u6E90\u4F1A\u8BDD/thread ID"),
|
|
26037
|
-
context: z65.record(z65.unknown()).optional().describe("\u9644\u52A0\u4E0A\u4E0B\u6587"),
|
|
26038
|
-
ownerType: z65.enum(["user", "agent"]).optional().describe("\u6240\u6709\u8005\u7C7B\u578B\uFF0C\u4E0D\u4F20\u9ED8\u8BA4\u4E3A user"),
|
|
26039
|
-
ownerId: z65.string().optional().describe("\u6240\u6709\u8005 ID\uFF0C\u4E0D\u4F20\u81EA\u52A8\u53D6\u5F53\u524D\u7528\u6237/Agent")
|
|
26040
|
-
});
|
|
26041
|
-
function createTaskMiddleware() {
|
|
26042
|
-
return createMiddleware19({
|
|
26043
|
-
name: "TaskMiddleware",
|
|
26044
|
-
contextSchema,
|
|
26045
|
-
wrapModelCall: async (request, handler) => {
|
|
26046
|
-
const taskPrompt = `## \u4EFB\u52A1\u7BA1\u7406\u80FD\u529B
|
|
26047
|
-
\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
|
|
26048
|
-
- \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)
|
|
26049
|
-
- ownerType="agent": \u4E3A\u81EA\u5DF1\u521B\u5EFA\u6267\u884C\u5B50\u4EFB\u52A1 (ownerId \u81EA\u52A8\u53D6\u5F53\u524D Agent)
|
|
26050
|
-
- \u663E\u5F0F\u4F20 ownerId: \u4E3A\u6307\u5B9A agent/user \u521B\u5EFA\u4EFB\u52A1\uFF08\u62D3\u6251\u573A\u666F\uFF09`;
|
|
26051
|
-
return handler({
|
|
26052
|
-
...request,
|
|
26053
|
-
systemPrompt: taskPrompt + "\n\n" + (request.systemPrompt ?? "")
|
|
26054
|
-
});
|
|
26055
|
-
},
|
|
26056
|
-
tools: [
|
|
26057
|
-
tool60(
|
|
26058
|
-
async (input, config) => {
|
|
26059
|
-
const rc = getRunConfig2(config);
|
|
26060
|
-
const tenantId2 = rc.tenantId || "default";
|
|
26061
|
-
const ownerId = input.ownerId || (input.ownerType === "agent" ? rc.assistant_id : null) || rc.user_id;
|
|
26062
|
-
const store = getTaskStore();
|
|
26063
|
-
switch (input.action) {
|
|
26064
|
-
case "create": {
|
|
26065
|
-
if (!input.title) {
|
|
26066
|
-
return JSON.stringify({ success: false, error: "create requires title" });
|
|
26067
|
-
}
|
|
26068
|
-
const task = await store.create({
|
|
26069
|
-
tenantId: tenantId2,
|
|
26070
|
-
ownerType: input.ownerType || "user",
|
|
26071
|
-
ownerId,
|
|
26072
|
-
title: input.title,
|
|
26073
|
-
description: input.description,
|
|
26074
|
-
priority: input.priority || "medium",
|
|
26075
|
-
status: input.status || "pending",
|
|
26076
|
-
dueDate: input.dueDate,
|
|
26077
|
-
metadata: input.metadata,
|
|
26078
|
-
parentId: input.parentId,
|
|
26079
|
-
sourceId: input.sourceId,
|
|
26080
|
-
context: input.context
|
|
26081
|
-
});
|
|
26082
|
-
return JSON.stringify({ success: true, data: task });
|
|
26083
|
-
}
|
|
26084
|
-
case "list": {
|
|
26085
|
-
const tasks = await store.list({
|
|
26086
|
-
tenantId: tenantId2,
|
|
26087
|
-
ownerType: input.ownerType,
|
|
26088
|
-
ownerId: input.ownerId,
|
|
26089
|
-
status: input.status,
|
|
26090
|
-
priority: input.priority
|
|
26091
|
-
});
|
|
26092
|
-
return JSON.stringify({ success: true, data: tasks, count: tasks.length });
|
|
26093
|
-
}
|
|
26094
|
-
case "update": {
|
|
26095
|
-
if (!input.id) {
|
|
26096
|
-
return JSON.stringify({ success: false, error: "update requires id" });
|
|
26097
|
-
}
|
|
26098
|
-
const { action, ...updates } = input;
|
|
26099
|
-
const updated = await store.update(tenantId2, input.id, updates);
|
|
26100
|
-
if (!updated) {
|
|
26101
|
-
return JSON.stringify({ success: false, error: "Task not found" });
|
|
26102
|
-
}
|
|
26103
|
-
return JSON.stringify({ success: true, data: updated });
|
|
26104
|
-
}
|
|
26105
|
-
case "delete": {
|
|
26106
|
-
if (!input.id) {
|
|
26107
|
-
return JSON.stringify({ success: false, error: "delete requires id" });
|
|
26108
|
-
}
|
|
26109
|
-
const deleted = await store.delete(tenantId2, input.id);
|
|
26110
|
-
return JSON.stringify({ success: deleted, message: deleted ? "Task deleted" : "Task not found" });
|
|
26111
|
-
}
|
|
26112
|
-
case "complete": {
|
|
26113
|
-
if (!input.id) {
|
|
26114
|
-
return JSON.stringify({ success: false, error: "complete requires id" });
|
|
26115
|
-
}
|
|
26116
|
-
const updated = await store.update(tenantId2, input.id, { status: "completed" });
|
|
26117
|
-
if (!updated) {
|
|
26118
|
-
return JSON.stringify({ success: false, error: "Task not found" });
|
|
26119
|
-
}
|
|
26120
|
-
return JSON.stringify({ success: true, data: updated });
|
|
26121
|
-
}
|
|
26122
|
-
default:
|
|
26123
|
-
return JSON.stringify({ success: false, error: `Unknown action: ${input.action}` });
|
|
26124
|
-
}
|
|
26125
|
-
},
|
|
26126
|
-
{
|
|
26127
|
-
name: "manage_task",
|
|
26128
|
-
description: `\u7BA1\u7406\u6301\u4E45\u5316\u4EFB\u52A1\u7CFB\u7EDF\u3002CRUD \u64CD\u4F5C\u7528\u6237\u548C Agent \u7684\u4EFB\u52A1\u3002
|
|
26129
|
-
|
|
26130
|
-
## ownerType \u548C ownerId \u7684\u9ED8\u8BA4\u903B\u8F91
|
|
26131
|
-
- \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)
|
|
26132
|
-
- \u4F20 ownerType="agent" \u4E0D\u4F20 ownerId: \u7CFB\u7EDF\u81EA\u52A8\u4E3A\u5F53\u524D Agent \u521B\u5EFA\u5B50\u4EFB\u52A1
|
|
26133
|
-
- \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
|
|
26134
|
-
|
|
26135
|
-
## Actions
|
|
26136
|
-
- create: \u521B\u5EFA\u4EFB\u52A1 (title \u5FC5\u586B, priority/description/dueDate/metadata/parentId/context \u53EF\u9009)
|
|
26137
|
-
- list: \u5217\u51FA\u4EFB\u52A1\uFF0C\u53EF\u6309 ownerType/status/priority \u8FC7\u6EE4
|
|
26138
|
-
- update: \u66F4\u65B0\u4EFB\u52A1 (id \u5FC5\u586B\uFF0C\u53EA\u4F20\u8981\u6539\u7684\u5B57\u6BB5)
|
|
26139
|
-
- delete: \u5220\u9664\u4EFB\u52A1 (id \u5FC5\u586B)
|
|
26140
|
-
- complete: \u5FEB\u901F\u6807\u8BB0\u5B8C\u6210 (id \u5FC5\u586B)`,
|
|
26141
|
-
schema: manageTaskSchema
|
|
26142
|
-
}
|
|
26143
|
-
)
|
|
26144
|
-
]
|
|
26145
|
-
});
|
|
26146
|
-
}
|
|
26147
|
-
var taskPlugin = {
|
|
26148
|
-
meta: {
|
|
26149
|
-
type: "task",
|
|
26150
|
-
name: "Task Management",
|
|
26151
|
-
description: "Enables persistent task management with delegation and tracking",
|
|
26152
|
-
configSchema: {
|
|
26153
|
-
type: "object",
|
|
26154
|
-
title: "Task Management Configuration",
|
|
26155
|
-
description: "Zero-configuration task management",
|
|
26156
|
-
properties: {}
|
|
26157
|
-
},
|
|
26158
|
-
defaultConfig: {}
|
|
26159
|
-
},
|
|
26160
|
-
middleware: () => createTaskMiddleware()
|
|
26161
|
-
};
|
|
26162
|
-
|
|
26163
26735
|
// src/middlewares/evalMiddleware.ts
|
|
26164
26736
|
import { createMiddleware as createMiddleware20, tool as tool61 } from "langchain";
|
|
26165
26737
|
import { z as z66 } from "zod";
|
|
@@ -26719,6 +27291,230 @@ var PersonalAssistantConfig = class {
|
|
|
26719
27291
|
};
|
|
26720
27292
|
PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
|
|
26721
27293
|
|
|
27294
|
+
// src/export_import/ExportableEntityRegistry.ts
|
|
27295
|
+
var ExportableEntityRegistry = class _ExportableEntityRegistry {
|
|
27296
|
+
constructor() {
|
|
27297
|
+
this.definitions = /* @__PURE__ */ new Map();
|
|
27298
|
+
}
|
|
27299
|
+
/**
|
|
27300
|
+
* Returns the singleton registry instance, creating it if necessary.
|
|
27301
|
+
*
|
|
27302
|
+
* @returns The singleton {@link ExportableEntityRegistry} instance.
|
|
27303
|
+
*/
|
|
27304
|
+
static getInstance() {
|
|
27305
|
+
if (!_ExportableEntityRegistry.instance) {
|
|
27306
|
+
_ExportableEntityRegistry.instance = new _ExportableEntityRegistry();
|
|
27307
|
+
}
|
|
27308
|
+
return _ExportableEntityRegistry.instance;
|
|
27309
|
+
}
|
|
27310
|
+
/**
|
|
27311
|
+
* Registers an exportable entity type definition.
|
|
27312
|
+
*
|
|
27313
|
+
* @param def - The entity definition to register.
|
|
27314
|
+
*
|
|
27315
|
+
* @throws If an entity type with the same `entityType` is already registered.
|
|
27316
|
+
*/
|
|
27317
|
+
register(def) {
|
|
27318
|
+
if (this.definitions.has(def.entityType)) {
|
|
27319
|
+
throw new Error(
|
|
27320
|
+
`Exportable entity type "${def.entityType}" is already registered`
|
|
27321
|
+
);
|
|
27322
|
+
}
|
|
27323
|
+
this.definitions.set(def.entityType, def);
|
|
27324
|
+
}
|
|
27325
|
+
/**
|
|
27326
|
+
* Retrieves a registered entity definition by type name.
|
|
27327
|
+
*
|
|
27328
|
+
* @param entityType - The entity type identifier (e.g. `'skill'`, `'agent'`).
|
|
27329
|
+
*
|
|
27330
|
+
* @returns The registered {@link ExportableEntityDefinition}.
|
|
27331
|
+
*
|
|
27332
|
+
* @throws If no definition is registered for the given type.
|
|
27333
|
+
*/
|
|
27334
|
+
get(entityType) {
|
|
27335
|
+
const def = this.definitions.get(entityType);
|
|
27336
|
+
if (!def) {
|
|
27337
|
+
throw new Error(`Exportable entity type "${entityType}" not found`);
|
|
27338
|
+
}
|
|
27339
|
+
return def;
|
|
27340
|
+
}
|
|
27341
|
+
/**
|
|
27342
|
+
* Returns lightweight metadata for all registered types (for the frontend).
|
|
27343
|
+
*
|
|
27344
|
+
* @returns An array of {@link ExportableTypeInfo} objects.
|
|
27345
|
+
*/
|
|
27346
|
+
listTypes() {
|
|
27347
|
+
return [...this.definitions.values()].map((d) => ({
|
|
27348
|
+
entityType: d.entityType,
|
|
27349
|
+
label: d.label,
|
|
27350
|
+
category: d.category,
|
|
27351
|
+
dependsOn: d.dependsOn,
|
|
27352
|
+
cascadeParents: d.cascadeParents
|
|
27353
|
+
}));
|
|
27354
|
+
}
|
|
27355
|
+
/**
|
|
27356
|
+
* Returns all registered entity definitions.
|
|
27357
|
+
*
|
|
27358
|
+
* @returns An array of all registered {@link ExportableEntityDefinition} objects.
|
|
27359
|
+
*/
|
|
27360
|
+
getAll() {
|
|
27361
|
+
return [...this.definitions.values()];
|
|
27362
|
+
}
|
|
27363
|
+
/**
|
|
27364
|
+
* Removes a registered entity type definition.
|
|
27365
|
+
*
|
|
27366
|
+
* @param entityType - The entity type identifier to remove.
|
|
27367
|
+
*/
|
|
27368
|
+
unregister(entityType) {
|
|
27369
|
+
this.definitions.delete(entityType);
|
|
27370
|
+
}
|
|
27371
|
+
};
|
|
27372
|
+
|
|
27373
|
+
// src/export_import/DependencyResolver.ts
|
|
27374
|
+
var DependencyResolver = class {
|
|
27375
|
+
/**
|
|
27376
|
+
* Topological sort of entity types based on their {@link ExportableEntityDefinition.dependsOn}
|
|
27377
|
+
* declarations. Entities with no dependencies come first.
|
|
27378
|
+
*
|
|
27379
|
+
* @param defs - All registered exportable entity definitions.
|
|
27380
|
+
* @returns Entity type names in dependency-first order.
|
|
27381
|
+
*/
|
|
27382
|
+
static resolveOrder(defs) {
|
|
27383
|
+
const typeMap = new Map(defs.map((d) => [d.entityType, d]));
|
|
27384
|
+
const visited = /* @__PURE__ */ new Set();
|
|
27385
|
+
const result = [];
|
|
27386
|
+
function visit(type) {
|
|
27387
|
+
if (visited.has(type)) return;
|
|
27388
|
+
visited.add(type);
|
|
27389
|
+
const def = typeMap.get(type);
|
|
27390
|
+
if (def) {
|
|
27391
|
+
for (const dep of def.dependsOn) {
|
|
27392
|
+
if (typeMap.has(dep)) {
|
|
27393
|
+
visit(dep);
|
|
27394
|
+
}
|
|
27395
|
+
}
|
|
27396
|
+
}
|
|
27397
|
+
result.push(type);
|
|
27398
|
+
}
|
|
27399
|
+
for (const def of defs) {
|
|
27400
|
+
visit(def.entityType);
|
|
27401
|
+
}
|
|
27402
|
+
return result;
|
|
27403
|
+
}
|
|
27404
|
+
/**
|
|
27405
|
+
* Given a set of selected entity types, expand to include all CASCADE
|
|
27406
|
+
* parents. Only walks **upward** (parents), never downward (children).
|
|
27407
|
+
*
|
|
27408
|
+
* @param defs - All registered exportable entity definitions.
|
|
27409
|
+
* @param selected - Entity type names the user explicitly chose.
|
|
27410
|
+
* @returns The original selection plus every reachable cascade parent.
|
|
27411
|
+
*/
|
|
27412
|
+
static expandCascade(defs, selected) {
|
|
27413
|
+
const typeMap = new Map(defs.map((d) => [d.entityType, d]));
|
|
27414
|
+
const result = new Set(selected);
|
|
27415
|
+
let changed = true;
|
|
27416
|
+
while (changed) {
|
|
27417
|
+
changed = false;
|
|
27418
|
+
for (const type of [...result]) {
|
|
27419
|
+
const def = typeMap.get(type);
|
|
27420
|
+
if (def) {
|
|
27421
|
+
for (const parent of def.cascadeParents) {
|
|
27422
|
+
if (!result.has(parent)) {
|
|
27423
|
+
result.add(parent);
|
|
27424
|
+
changed = true;
|
|
27425
|
+
}
|
|
27426
|
+
}
|
|
27427
|
+
}
|
|
27428
|
+
}
|
|
27429
|
+
}
|
|
27430
|
+
return [...result];
|
|
27431
|
+
}
|
|
27432
|
+
/**
|
|
27433
|
+
* Compute which required dependencies are missing from the selected types.
|
|
27434
|
+
*
|
|
27435
|
+
* Only considers dependencies that are themselves registered as exportable
|
|
27436
|
+
* entity types. Unregistered dependencies (e.g. `Workspace`, `Project` —
|
|
27437
|
+
* infrastructure types) are silently excluded.
|
|
27438
|
+
*
|
|
27439
|
+
* @param defs - All registered exportable entity definitions.
|
|
27440
|
+
* @param selected - Entity type names the user has selected.
|
|
27441
|
+
* @returns The list of entity types that must also be selected (or
|
|
27442
|
+
* auto-included).
|
|
27443
|
+
*/
|
|
27444
|
+
static computeDependencies(defs, selected) {
|
|
27445
|
+
const typeMap = new Map(defs.map((d) => [d.entityType, d]));
|
|
27446
|
+
const selectedSet = new Set(selected);
|
|
27447
|
+
const missing = /* @__PURE__ */ new Set();
|
|
27448
|
+
function collectMissing(type) {
|
|
27449
|
+
if (selectedSet.has(type)) return;
|
|
27450
|
+
const def = typeMap.get(type);
|
|
27451
|
+
if (!def) return;
|
|
27452
|
+
missing.add(type);
|
|
27453
|
+
for (const dep of def.dependsOn) {
|
|
27454
|
+
collectMissing(dep);
|
|
27455
|
+
}
|
|
27456
|
+
}
|
|
27457
|
+
for (const type of selected) {
|
|
27458
|
+
const def = typeMap.get(type);
|
|
27459
|
+
if (def) {
|
|
27460
|
+
for (const dep of def.dependsOn) {
|
|
27461
|
+
collectMissing(dep);
|
|
27462
|
+
}
|
|
27463
|
+
}
|
|
27464
|
+
}
|
|
27465
|
+
return { missing: [...missing] };
|
|
27466
|
+
}
|
|
27467
|
+
};
|
|
27468
|
+
|
|
27469
|
+
// src/export_import/IdRemapper.ts
|
|
27470
|
+
var REF_PATTERN = /^@(\w+)\/(.+)$/;
|
|
27471
|
+
var IdRemapper = class {
|
|
27472
|
+
constructor(idMap) {
|
|
27473
|
+
this.idMap = idMap;
|
|
27474
|
+
}
|
|
27475
|
+
/**
|
|
27476
|
+
* Deep-traverse an object/array and replace all @type/exportId string values
|
|
27477
|
+
* with their corresponding real IDs from the idMap.
|
|
27478
|
+
* Values not matching the @type/exportId pattern are returned unchanged.
|
|
27479
|
+
*/
|
|
27480
|
+
remapReferences(value) {
|
|
27481
|
+
if (value === null || value === void 0) return value;
|
|
27482
|
+
if (typeof value === "string") {
|
|
27483
|
+
const match = value.match(REF_PATTERN);
|
|
27484
|
+
if (match) {
|
|
27485
|
+
const exportId = match[2];
|
|
27486
|
+
if (this.idMap[exportId] !== void 0) {
|
|
27487
|
+
return this.idMap[exportId];
|
|
27488
|
+
}
|
|
27489
|
+
}
|
|
27490
|
+
return value;
|
|
27491
|
+
}
|
|
27492
|
+
if (Array.isArray(value)) {
|
|
27493
|
+
return value.map((item) => this.remapReferences(item));
|
|
27494
|
+
}
|
|
27495
|
+
if (typeof value === "object") {
|
|
27496
|
+
const result = {};
|
|
27497
|
+
for (const [key4, val] of Object.entries(value)) {
|
|
27498
|
+
result[key4] = this.remapReferences(val);
|
|
27499
|
+
}
|
|
27500
|
+
return result;
|
|
27501
|
+
}
|
|
27502
|
+
return value;
|
|
27503
|
+
}
|
|
27504
|
+
/**
|
|
27505
|
+
* Replace raw skill IDs in an agent's graphDefinition.skillIds array.
|
|
27506
|
+
* This handles the implicit agent->skill reference that uses raw skill IDs
|
|
27507
|
+
* (not @type/exportId format). Agents reference skills by their string ID.
|
|
27508
|
+
*/
|
|
27509
|
+
remapSkillIds(graphDefinition, skillRemap) {
|
|
27510
|
+
const cloned = structuredClone(graphDefinition);
|
|
27511
|
+
if (Array.isArray(cloned.skillIds)) {
|
|
27512
|
+
cloned.skillIds = cloned.skillIds.map((id) => skillRemap[id] ?? id);
|
|
27513
|
+
}
|
|
27514
|
+
return cloned;
|
|
27515
|
+
}
|
|
27516
|
+
};
|
|
27517
|
+
|
|
26722
27518
|
// src/index.ts
|
|
26723
27519
|
registerBuiltinPlugins();
|
|
26724
27520
|
export {
|
|
@@ -26741,13 +27537,16 @@ export {
|
|
|
26741
27537
|
DaytonaInstance,
|
|
26742
27538
|
DaytonaProvider,
|
|
26743
27539
|
DefaultScheduleClient,
|
|
27540
|
+
DependencyResolver,
|
|
26744
27541
|
E2BInstance,
|
|
26745
27542
|
E2BProvider,
|
|
26746
27543
|
EMPTY_CONTENT_WARNING,
|
|
26747
27544
|
EmbeddingsLatticeManager,
|
|
27545
|
+
ExportableEntityRegistry,
|
|
26748
27546
|
FileSystemSkillStore,
|
|
26749
27547
|
FilesystemBackend,
|
|
26750
|
-
|
|
27548
|
+
HumanMessage5 as HumanMessage,
|
|
27549
|
+
IdRemapper,
|
|
26751
27550
|
InMemoryA2AApiKeyStore,
|
|
26752
27551
|
InMemoryAssistantStore,
|
|
26753
27552
|
InMemoryBindingStore,
|